"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/memory/index.ts
var memory_exports = {};
__export(memory_exports, {
  AgentMemoryRecordType: () => AgentMemoryRecordType,
  findCalibrationsForScope: () => findCalibrationsForScope,
  findRecentEpisodes: () => findRecentEpisodes,
  writeBelief: () => writeBelief,
  writeCalibration: () => writeCalibration,
  writeEpisode: () => writeEpisode,
  writePreference: () => writePreference,
  writeWatchItem: () => writeWatchItem,
  writeWorkflow: () => writeWorkflow
});
module.exports = __toCommonJS(memory_exports);

// 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" }
  });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  AgentMemoryRecordType,
  findCalibrationsForScope,
  findRecentEpisodes,
  writeBelief,
  writeCalibration,
  writeEpisode,
  writePreference,
  writeWatchItem,
  writeWorkflow
});
//# sourceMappingURL=index.js.map