import { createPagePaginationSchema, paginationInfoSchema, successResponseSchema } from './chunk-USZD5AX2.js';
import z from 'zod';

var threadIdPathParams = z.object({
  threadId: z.string().describe("Unique identifier for the conversation thread")
});
var agentIdQuerySchema = z.object({
  agentId: z.string()
});
var optionalAgentIdQuerySchema = z.object({
  agentId: z.string().optional()
});
var storageOrderBySchema = z.preprocess(
  (val) => {
    if (typeof val === "string") {
      try {
        return JSON.parse(val);
      } catch {
        return void 0;
      }
    }
    return val;
  },
  z.object({
    field: z.enum(["createdAt", "updatedAt"]).optional(),
    direction: z.enum(["ASC", "DESC"]).optional()
  }).optional()
);
var messageOrderBySchema = z.preprocess(
  (val) => {
    if (typeof val === "string") {
      try {
        return JSON.parse(val);
      } catch {
        return void 0;
      }
    }
    return val;
  },
  z.object({
    field: z.enum(["createdAt"]).optional(),
    direction: z.enum(["ASC", "DESC"]).optional()
  }).optional()
);
var includeSchema = z.preprocess(
  (val) => {
    if (typeof val === "string") {
      try {
        return JSON.parse(val);
      } catch {
        return val;
      }
    }
    return val;
  },
  z.array(
    z.object({
      id: z.string(),
      threadId: z.string().optional(),
      withPreviousMessages: z.number().optional(),
      withNextMessages: z.number().optional()
    })
  ).optional()
);
var filterSchema = z.preprocess(
  (val) => {
    if (typeof val === "string") {
      try {
        return JSON.parse(val);
      } catch {
        return val;
      }
    }
    return val;
  },
  z.object({
    dateRange: z.object({
      start: z.coerce.date().optional(),
      end: z.coerce.date().optional()
    }).optional(),
    roles: z.array(z.string()).optional()
  }).optional()
);
var memoryConfigSchema = z.preprocess((val) => {
  if (typeof val === "string") {
    try {
      return JSON.parse(val);
    } catch {
      return val;
    }
  }
  return val;
}, z.record(z.string(), z.unknown()).optional());
var threadSchema = z.object({
  id: z.string(),
  title: z.string().optional(),
  resourceId: z.string(),
  createdAt: z.date(),
  updatedAt: z.date(),
  metadata: z.record(z.string(), z.unknown()).optional()
});
var messageSchema = z.any();
var getMemoryStatusQuerySchema = agentIdQuerySchema.extend({
  resourceId: z.string().optional(),
  threadId: z.string().optional()
});
var getMemoryConfigQuerySchema = agentIdQuerySchema;
var listThreadsQuerySchema = createPagePaginationSchema(100).extend({
  agentId: z.string().optional(),
  resourceId: z.string().optional(),
  metadata: z.preprocess(
    (val) => {
      if (typeof val === "string") {
        try {
          return JSON.parse(val);
        } catch {
          return val;
        }
      }
      return val;
    },
    z.optional(z.record(z.string(), z.any()))
  ),
  orderBy: storageOrderBySchema
});
var getThreadByIdQuerySchema = optionalAgentIdQuerySchema.extend({
  resourceId: z.string().optional()
});
var listMessagesQuerySchema = createPagePaginationSchema(40).extend({
  agentId: z.string().optional(),
  resourceId: z.string().optional(),
  orderBy: messageOrderBySchema,
  include: includeSchema,
  filter: filterSchema
});
var getWorkingMemoryQuerySchema = z.object({
  agentId: z.string(),
  resourceId: z.string().optional(),
  memoryConfig: memoryConfigSchema
});
var deleteThreadQuerySchema = agentIdQuerySchema.extend({
  resourceId: z.string().optional()
});
var deleteMessagesQuerySchema = agentIdQuerySchema.extend({
  resourceId: z.string().optional()
});
var getMemoryStatusNetworkQuerySchema = agentIdQuerySchema;
var listThreadsNetworkQuerySchema = createPagePaginationSchema(100).extend({
  agentId: z.string().optional(),
  resourceId: z.string().optional(),
  metadata: z.preprocess(
    (val) => {
      if (typeof val === "string") {
        try {
          return JSON.parse(val);
        } catch {
          return val;
        }
      }
      return val;
    },
    z.optional(z.record(z.string(), z.any()))
  ),
  orderBy: storageOrderBySchema
});
var getThreadByIdNetworkQuerySchema = optionalAgentIdQuerySchema.extend({
  resourceId: z.string().optional()
});
var listMessagesNetworkQuerySchema = createPagePaginationSchema(40).extend({
  agentId: z.string().optional(),
  resourceId: z.string().optional(),
  orderBy: messageOrderBySchema,
  include: includeSchema,
  filter: filterSchema
});
var saveMessagesNetworkQuerySchema = agentIdQuerySchema;
var createThreadNetworkQuerySchema = agentIdQuerySchema;
var updateThreadNetworkQuerySchema = agentIdQuerySchema;
var deleteThreadNetworkQuerySchema = agentIdQuerySchema.extend({
  resourceId: z.string().optional()
});
var deleteMessagesNetworkQuerySchema = agentIdQuerySchema.extend({
  resourceId: z.string().optional()
});
var memoryStatusResponseSchema = z.object({
  result: z.boolean(),
  observationalMemory: z.object({
    enabled: z.boolean(),
    hasRecord: z.boolean().optional(),
    originType: z.string().optional(),
    lastObservedAt: z.date().optional(),
    tokenCount: z.number().optional(),
    observationTokenCount: z.number().optional(),
    isObserving: z.boolean().optional(),
    isReflecting: z.boolean().optional()
  }).optional()
});
var observationalMemoryConfigSchema = z.object({
  enabled: z.boolean(),
  scope: z.enum(["thread", "resource"]).optional(),
  shareTokenBudget: z.boolean().optional(),
  messageTokens: z.union([z.number(), z.object({ min: z.number(), max: z.number() })]).optional(),
  observationTokens: z.union([z.number(), z.object({ min: z.number(), max: z.number() })]).optional(),
  observationModel: z.string().optional(),
  reflectionModel: z.string().optional()
});
var memoryConfigResponseSchema = z.object({
  config: z.object({
    lastMessages: z.union([z.number(), z.literal(false)]).optional(),
    semanticRecall: z.union([z.boolean(), z.any()]).optional(),
    workingMemory: z.any().optional(),
    observationalMemory: observationalMemoryConfigSchema.optional()
  })
});
var listThreadsResponseSchema = paginationInfoSchema.extend({
  threads: z.array(threadSchema)
});
var getThreadByIdResponseSchema = threadSchema;
var listMessagesResponseSchema = z.object({
  messages: z.array(messageSchema),
  uiMessages: z.unknown()
  // Converted messages in UI format
});
var getWorkingMemoryResponseSchema = z.object({
  workingMemory: z.unknown(),
  // Can be string or structured object depending on template
  source: z.enum(["thread", "resource"]),
  workingMemoryTemplate: z.unknown(),
  // Template structure varies
  threadExists: z.boolean()
});
var saveMessagesBodySchema = z.object({
  messages: z.array(messageSchema)
});
var createThreadBodySchema = z.object({
  resourceId: z.string(),
  title: z.string().optional(),
  metadata: z.record(z.string(), z.unknown()).optional(),
  threadId: z.string().optional()
});
var updateThreadBodySchema = z.object({
  title: z.string().optional(),
  metadata: z.record(z.string(), z.unknown()).optional(),
  resourceId: z.string().optional()
});
var updateWorkingMemoryBodySchema = z.object({
  workingMemory: z.string(),
  resourceId: z.string().optional(),
  memoryConfig: z.record(z.string(), z.unknown()).optional()
});
var deleteMessagesBodySchema = z.object({
  messageIds: z.union([
    z.string(),
    z.array(z.string()),
    z.object({ id: z.string() }),
    z.array(z.object({ id: z.string() }))
  ])
});
var searchMemoryQuerySchema = z.object({
  agentId: z.string(),
  searchQuery: z.string(),
  resourceId: z.string(),
  threadId: z.string().optional(),
  limit: z.coerce.number().optional().default(20),
  memoryConfig: memoryConfigSchema
});
var saveMessagesResponseSchema = z.object({
  messages: z.array(messageSchema)
});
var deleteThreadResponseSchema = z.object({
  result: z.string()
});
var updateWorkingMemoryResponseSchema = successResponseSchema;
var deleteMessagesResponseSchema = successResponseSchema.extend({
  message: z.string()
});
var searchMemoryResponseSchema = z.object({
  results: z.array(z.unknown()),
  count: z.number(),
  query: z.string(),
  searchScope: z.string().optional(),
  searchType: z.string().optional()
});
var cloneThreadBodySchema = z.object({
  newThreadId: z.string().optional(),
  resourceId: z.string().optional(),
  title: z.string().optional(),
  metadata: z.record(z.string(), z.unknown()).optional(),
  options: z.object({
    messageLimit: z.number().optional(),
    messageFilter: z.object({
      startDate: z.coerce.date().optional(),
      endDate: z.coerce.date().optional(),
      messageIds: z.array(z.string()).optional()
    }).optional()
  }).optional()
});
var cloneThreadResponseSchema = z.object({
  thread: threadSchema,
  clonedMessages: z.array(messageSchema)
});
var getObservationalMemoryQuerySchema = z.object({
  agentId: z.string(),
  resourceId: z.string().optional(),
  threadId: z.string().optional()
});
var observationalMemoryRecordSchema = z.object({
  id: z.string(),
  scope: z.enum(["thread", "resource"]),
  resourceId: z.string(),
  threadId: z.string().nullable(),
  activeObservations: z.string(),
  bufferedObservations: z.string().optional(),
  bufferedReflection: z.string().optional(),
  originType: z.enum(["initial", "observation", "reflection"]),
  generationCount: z.number(),
  lastObservedAt: z.date().optional(),
  totalTokensObserved: z.number(),
  observationTokenCount: z.number(),
  pendingMessageTokens: z.number(),
  isObserving: z.boolean(),
  isReflecting: z.boolean(),
  config: z.record(z.string(), z.unknown()),
  metadata: z.record(z.string(), z.unknown()).optional(),
  createdAt: z.date(),
  updatedAt: z.date()
});
var getObservationalMemoryResponseSchema = z.object({
  record: observationalMemoryRecordSchema.nullable(),
  history: z.array(observationalMemoryRecordSchema).optional()
});
var awaitBufferStatusBodySchema = z.object({
  agentId: z.string(),
  resourceId: z.string().optional(),
  threadId: z.string().optional()
});
var awaitBufferStatusResponseSchema = z.object({
  record: observationalMemoryRecordSchema.nullable()
});

export { agentIdQuerySchema, awaitBufferStatusBodySchema, awaitBufferStatusResponseSchema, cloneThreadBodySchema, cloneThreadResponseSchema, createThreadBodySchema, createThreadNetworkQuerySchema, deleteMessagesBodySchema, deleteMessagesNetworkQuerySchema, deleteMessagesQuerySchema, deleteMessagesResponseSchema, deleteThreadNetworkQuerySchema, deleteThreadQuerySchema, deleteThreadResponseSchema, getMemoryConfigQuerySchema, getMemoryStatusNetworkQuerySchema, getMemoryStatusQuerySchema, getObservationalMemoryQuerySchema, getObservationalMemoryResponseSchema, getThreadByIdNetworkQuerySchema, getThreadByIdQuerySchema, getThreadByIdResponseSchema, getWorkingMemoryQuerySchema, getWorkingMemoryResponseSchema, listMessagesNetworkQuerySchema, listMessagesQuerySchema, listMessagesResponseSchema, listThreadsNetworkQuerySchema, listThreadsQuerySchema, listThreadsResponseSchema, memoryConfigResponseSchema, memoryStatusResponseSchema, optionalAgentIdQuerySchema, saveMessagesBodySchema, saveMessagesNetworkQuerySchema, saveMessagesResponseSchema, searchMemoryQuerySchema, searchMemoryResponseSchema, threadIdPathParams, updateThreadBodySchema, updateThreadNetworkQuerySchema, updateWorkingMemoryBodySchema, updateWorkingMemoryResponseSchema };
//# sourceMappingURL=chunk-VDG7SNSS.js.map
//# sourceMappingURL=chunk-VDG7SNSS.js.map