// src/memory/types.ts
var AgentMemoryRecordType = {
  EPISODE: "EPISODE",
  PREFERENCE: "PREFERENCE",
  BELIEF: "BELIEF",
  WORKFLOW: "WORKFLOW",
  WATCHITEM: "WATCHITEM",
  CALIBRATION: "CALIBRATION"
};

// src/memory/client.ts
function writeRecord(client, type, args) {
  return client.agentMemoryRecord.create({
    data: {
      type,
      scope: args.scope,
      domain: args.domain ?? null,
      payload: args.payload,
      source: args.source ?? null,
      confidence: args.confidence ?? null,
      expiresAt: args.expiresAt ?? null
    }
  });
}
function writeEpisode(client, args) {
  return writeRecord(client, AgentMemoryRecordType.EPISODE, args);
}
function writePreference(client, args) {
  return writeRecord(client, AgentMemoryRecordType.PREFERENCE, args);
}
function writeBelief(client, args) {
  return writeRecord(client, AgentMemoryRecordType.BELIEF, args);
}
function writeWorkflow(client, args) {
  return writeRecord(client, AgentMemoryRecordType.WORKFLOW, args);
}
function writeWatchItem(client, args) {
  return writeRecord(client, AgentMemoryRecordType.WATCHITEM, args);
}
function writeCalibration(client, args) {
  return writeRecord(client, AgentMemoryRecordType.CALIBRATION, args);
}
function findRecentEpisodes(client, args) {
  const since = new Date(Date.now() - args.sinceHours * 60 * 60 * 1e3);
  return client.agentMemoryRecord.findMany({
    where: {
      type: AgentMemoryRecordType.EPISODE,
      scope: args.scope,
      createdAt: { gte: since }
    },
    orderBy: { createdAt: "desc" },
    take: args.limit ?? 50
  });
}
function findCalibrationsForScope(client, scope) {
  return client.agentMemoryRecord.findMany({
    where: {
      type: AgentMemoryRecordType.CALIBRATION,
      scope
    },
    orderBy: { createdAt: "desc" }
  });
}
export {
  AgentMemoryRecordType,
  findCalibrationsForScope,
  findRecentEpisodes,
  writeBelief,
  writeCalibration,
  writeEpisode,
  writePreference,
  writeWatchItem,
  writeWorkflow
};
//# sourceMappingURL=index.mjs.map