@ainyc/canonry 1.48.4 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,8 @@ import { drizzle } from "drizzle-orm/better-sqlite3";
16
16
  // ../db/src/schema.ts
17
17
  var schema_exports = {};
18
18
  __export(schema_exports, {
19
+ agentMemory: () => agentMemory,
20
+ agentSessions: () => agentSessions,
19
21
  apiKeys: () => apiKeys,
20
22
  auditLog: () => auditLog,
21
23
  bingConnections: () => bingConnections,
@@ -410,6 +412,32 @@ var healthSnapshots = sqliteTable("health_snapshots", {
410
412
  index("idx_health_snapshots_run").on(table.runId),
411
413
  index("idx_health_snapshots_created").on(table.createdAt)
412
414
  ]);
415
+ var agentSessions = sqliteTable("agent_sessions", {
416
+ id: text("id").primaryKey(),
417
+ projectId: text("project_id").notNull().unique().references(() => projects.id, { onDelete: "cascade" }),
418
+ systemPrompt: text("system_prompt").notNull(),
419
+ modelProvider: text("model_provider").notNull(),
420
+ modelId: text("model_id").notNull(),
421
+ messages: text("messages").notNull().default("[]"),
422
+ followUpQueue: text("follow_up_queue").notNull().default("[]"),
423
+ createdAt: text("created_at").notNull(),
424
+ updatedAt: text("updated_at").notNull()
425
+ }, (table) => [
426
+ index("idx_agent_sessions_project").on(table.projectId),
427
+ index("idx_agent_sessions_updated").on(table.updatedAt)
428
+ ]);
429
+ var agentMemory = sqliteTable("agent_memory", {
430
+ id: text("id").primaryKey(),
431
+ projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
432
+ key: text("key").notNull(),
433
+ value: text("value").notNull(),
434
+ source: text("source").notNull(),
435
+ createdAt: text("created_at").notNull(),
436
+ updatedAt: text("updated_at").notNull()
437
+ }, (table) => [
438
+ uniqueIndex("uniq_agent_memory_project_key").on(table.projectId, table.key),
439
+ index("idx_agent_memory_project_updated").on(table.projectId, table.updatedAt)
440
+ ]);
413
441
 
414
442
  // ../db/src/client.ts
415
443
  function createClient(databasePath) {
@@ -851,7 +879,7 @@ var MIGRATIONS = [
851
879
  `DROP INDEX IF EXISTS idx_bing_coverage_snap_project_date`,
852
880
  `CREATE UNIQUE INDEX IF NOT EXISTS idx_bing_coverage_snap_project_date_unique ON bing_coverage_snapshots(project_id, date)`,
853
881
  // v35: Add missing index for query_snapshots createdAt for time-series filtering
854
- `CREATE INDEX IF NOT EXISTS idx_snapshots_created_at ON query_snapshots(created_at)`
882
+ `CREATE INDEX IF NOT EXISTS idx_snapshots_created_at ON query_snapshots(created_at)`,
855
883
  // v36: Transaction handling and SQL injection review: verified all strings use SQLite ? binding via Drizzle.
856
884
  // No changes required for parameterization.
857
885
  // v37: The legacy credential columns (private_key on ga_connections; access_token,
@@ -860,6 +888,40 @@ var MIGRATIONS = [
860
888
  // read the rows, persist them to config.yaml, and only then drop the columns
861
889
  // so a failed config write doesn't permanently lose credentials. Keeping the
862
890
  // DROPs as raw SQL here would race with that read.
891
+ // v38: Aero session registry — one rolling session per project.
892
+ `CREATE TABLE IF NOT EXISTS agent_sessions (
893
+ id TEXT PRIMARY KEY,
894
+ project_id TEXT NOT NULL UNIQUE REFERENCES projects(id) ON DELETE CASCADE,
895
+ system_prompt TEXT NOT NULL,
896
+ model_provider TEXT NOT NULL,
897
+ model_id TEXT NOT NULL,
898
+ messages TEXT NOT NULL DEFAULT '[]',
899
+ follow_up_queue TEXT NOT NULL DEFAULT '[]',
900
+ created_at TEXT NOT NULL,
901
+ updated_at TEXT NOT NULL
902
+ )`,
903
+ `CREATE INDEX IF NOT EXISTS idx_agent_sessions_project ON agent_sessions(project_id)`,
904
+ `CREATE INDEX IF NOT EXISTS idx_agent_sessions_updated ON agent_sessions(updated_at)`,
905
+ // v39: Align Aero provider IDs with sweep naming — anthropic→claude, google→gemini.
906
+ // Old rows predating the rename would fail to rehydrate because the canonical
907
+ // registry no longer recognizes 'anthropic'/'google'. Safe to re-run: the
908
+ // UPDATE is a no-op once the rename has been applied.
909
+ `UPDATE agent_sessions SET model_provider = 'claude' WHERE model_provider = 'anthropic'`,
910
+ `UPDATE agent_sessions SET model_provider = 'gemini' WHERE model_provider = 'google'`,
911
+ // v40: Aero durable memory — project-scoped notes + compaction summaries.
912
+ `CREATE TABLE IF NOT EXISTS agent_memory (
913
+ id TEXT PRIMARY KEY,
914
+ project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
915
+ key TEXT NOT NULL,
916
+ value TEXT NOT NULL,
917
+ source TEXT NOT NULL,
918
+ created_at TEXT NOT NULL,
919
+ updated_at TEXT NOT NULL
920
+ )`,
921
+ `CREATE UNIQUE INDEX IF NOT EXISTS uniq_agent_memory_project_key
922
+ ON agent_memory(project_id, key)`,
923
+ `CREATE INDEX IF NOT EXISTS idx_agent_memory_project_updated
924
+ ON agent_memory(project_id, updated_at)`
863
925
  ];
864
926
  function isDuplicateColumnError(err) {
865
927
  if (!(err instanceof Error)) return false;
@@ -1389,6 +1451,8 @@ export {
1389
1451
  usageCounters,
1390
1452
  insights,
1391
1453
  healthSnapshots,
1454
+ agentSessions,
1455
+ agentMemory,
1392
1456
  createClient,
1393
1457
  parseJsonColumn,
1394
1458
  extractLegacyCredentials,