'use strict';

var chunkDIG2K5CV_cjs = require('./chunk-DIG2K5CV.cjs');
var v4 = require('zod/v4');

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

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