@framers/agentos 0.3.0 → 0.3.2

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.
Files changed (61) hide show
  1. package/dist/memory/retrieval/store/Brain.d.ts +6 -11
  2. package/dist/memory/retrieval/store/Brain.d.ts.map +1 -1
  3. package/dist/memory/retrieval/store/Brain.js +122 -68
  4. package/dist/memory/retrieval/store/Brain.js.map +1 -1
  5. package/dist/memory/retrieval/store/migrations/MigrationRunner.d.ts +50 -0
  6. package/dist/memory/retrieval/store/migrations/MigrationRunner.d.ts.map +1 -0
  7. package/dist/memory/retrieval/store/migrations/MigrationRunner.js +100 -0
  8. package/dist/memory/retrieval/store/migrations/MigrationRunner.js.map +1 -0
  9. package/dist/memory/retrieval/store/migrations/index.d.ts +20 -0
  10. package/dist/memory/retrieval/store/migrations/index.d.ts.map +1 -0
  11. package/dist/memory/retrieval/store/migrations/index.js +19 -0
  12. package/dist/memory/retrieval/store/migrations/index.js.map +1 -0
  13. package/dist/memory/retrieval/store/migrations/types.d.ts +28 -0
  14. package/dist/memory/retrieval/store/migrations/types.d.ts.map +1 -0
  15. package/dist/memory/retrieval/store/migrations/types.js +7 -0
  16. package/dist/memory/retrieval/store/migrations/types.js.map +1 -0
  17. package/dist/memory/retrieval/store/migrations/v1-to-v2.d.ts +9 -0
  18. package/dist/memory/retrieval/store/migrations/v1-to-v2.d.ts.map +1 -1
  19. package/dist/memory/retrieval/store/migrations/v1-to-v2.js +72 -4
  20. package/dist/memory/retrieval/store/migrations/v1-to-v2.js.map +1 -1
  21. package/dist/memory/retrieval/store/portable-tables.d.ts +27 -0
  22. package/dist/memory/retrieval/store/portable-tables.d.ts.map +1 -0
  23. package/dist/memory/retrieval/store/portable-tables.js +56 -0
  24. package/dist/memory/retrieval/store/portable-tables.js.map +1 -0
  25. package/dist/memory/retrieval/typed-network/FourWayRrf.d.ts +51 -0
  26. package/dist/memory/retrieval/typed-network/FourWayRrf.d.ts.map +1 -0
  27. package/dist/memory/retrieval/typed-network/FourWayRrf.js +47 -0
  28. package/dist/memory/retrieval/typed-network/FourWayRrf.js.map +1 -0
  29. package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.d.ts +34 -0
  30. package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.d.ts.map +1 -0
  31. package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.js +86 -0
  32. package/dist/memory/retrieval/typed-network/TemporalIntervalOverlap.js.map +1 -0
  33. package/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts +67 -0
  34. package/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts.map +1 -0
  35. package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js +78 -0
  36. package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js.map +1 -0
  37. package/dist/memory/retrieval/typed-network/TypedNetworkStore.d.ts +83 -0
  38. package/dist/memory/retrieval/typed-network/TypedNetworkStore.d.ts.map +1 -0
  39. package/dist/memory/retrieval/typed-network/TypedNetworkStore.js +109 -0
  40. package/dist/memory/retrieval/typed-network/TypedNetworkStore.js.map +1 -0
  41. package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.d.ts +80 -0
  42. package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.d.ts.map +1 -0
  43. package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.js +97 -0
  44. package/dist/memory/retrieval/typed-network/TypedSpreadingActivation.js.map +1 -0
  45. package/dist/memory/retrieval/typed-network/index.d.ts +18 -0
  46. package/dist/memory/retrieval/typed-network/index.d.ts.map +1 -0
  47. package/dist/memory/retrieval/typed-network/index.js +18 -0
  48. package/dist/memory/retrieval/typed-network/index.js.map +1 -0
  49. package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.d.ts +30 -0
  50. package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.d.ts.map +1 -0
  51. package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.js +47 -0
  52. package/dist/memory/retrieval/typed-network/prompts/extraction-prompt.js.map +1 -0
  53. package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts +71 -0
  54. package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts.map +1 -0
  55. package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js +39 -0
  56. package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js.map +1 -0
  57. package/dist/memory/retrieval/typed-network/types.d.ts +123 -0
  58. package/dist/memory/retrieval/typed-network/types.d.ts.map +1 -0
  59. package/dist/memory/retrieval/typed-network/types.js +48 -0
  60. package/dist/memory/retrieval/typed-network/types.js.map +1 -0
  61. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @fileoverview Migration interface and shared types for MigrationRunner.
3
+ *
4
+ * @module memory/retrieval/store/migrations/types
5
+ */
6
+ import type { StorageAdapter, StorageFeatures } from '@framers/sql-storage-adapter';
7
+ /**
8
+ * A single schema migration. The runner handles transaction wrapping, advisory
9
+ * locking, and the schema_version bump. The migration's `up` function only
10
+ * needs to apply the schema diff (DDL + data backfill) for its target version.
11
+ *
12
+ * Migrations MUST NOT manage their own transactions. The adapter passed into
13
+ * `up` is the runner's transactional adapter; calling BEGIN/COMMIT inside `up`
14
+ * breaks the runner's transaction model on both Postgres and SQLite.
15
+ */
16
+ export interface Migration {
17
+ /** Target schema version this migration upgrades the database to. */
18
+ version: number;
19
+ /**
20
+ * Apply the schema diff for this migration's target version.
21
+ *
22
+ * @param adapter - Transactional storage adapter (do NOT BEGIN/COMMIT inside).
23
+ * @param features - Platform-aware feature bundle.
24
+ * @param brainId - The brain identifier to scope writes to.
25
+ */
26
+ up(adapter: StorageAdapter, features: StorageFeatures, brainId: string): Promise<void>;
27
+ }
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/memory/retrieval/store/migrations/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpF;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @fileoverview Migration interface and shared types for MigrationRunner.
3
+ *
4
+ * @module memory/retrieval/store/migrations/types
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/memory/retrieval/store/migrations/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -15,6 +15,7 @@
15
15
  * @module memory/retrieval/store/migrations/v1-to-v2
16
16
  */
17
17
  import type { StorageAdapter, StorageFeatures } from '@framers/sql-storage-adapter';
18
+ import type { Migration } from './types.js';
18
19
  /**
19
20
  * Run the v1 -> v2 migration on the given storage adapter.
20
21
  *
@@ -28,4 +29,12 @@ import type { StorageAdapter, StorageFeatures } from '@framers/sql-storage-adapt
28
29
  export declare function migrateV1ToV2(adapter: StorageAdapter, features: StorageFeatures, brainId: string): Promise<{
29
30
  migrated: boolean;
30
31
  }>;
32
+ /**
33
+ * The v1 -> v2 schema migration as a Migration object for MigrationRunner.
34
+ *
35
+ * The runner handles transaction wrapping, advisory locking, and the
36
+ * schema_version bump. This Migration's `up` function only runs the schema
37
+ * diff (the 14-table walk).
38
+ */
39
+ export declare const v1ToV2: Migration;
31
40
  //# sourceMappingURL=v1-to-v2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v1-to-v2.d.ts","sourceRoot":"","sources":["../../../../../src/memory/retrieval/store/migrations/v1-to-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AA2SpF;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAqChC"}
1
+ {"version":3,"file":"v1-to-v2.d.ts","sourceRoot":"","sources":["../../../../../src/memory/retrieval/store/migrations/v1-to-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAgU5C;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAqChC;AA+JD;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,EAAE,SA+BpB,CAAC"}
@@ -14,6 +14,7 @@
14
14
  *
15
15
  * @module memory/retrieval/store/migrations/v1-to-v2
16
16
  */
17
+ import { PORTABLE_TABLES } from '../portable-tables.js';
17
18
  /**
18
19
  * The 14 tables that gain `brain_id` in v2. Order matters for FK resolution:
19
20
  * documents must exist before document_chunks; conversations before messages.
@@ -266,6 +267,12 @@ const V2_TABLES = [
266
267
  primaryKey: ['brain_id', 'trace_id'],
267
268
  // Migration: copy existing agent_id column into brain_id (legacy archive
268
269
  // already discriminated by agent_id, which is semantically the same).
270
+ //
271
+ // CAVEAT: if the caller passes an explicit brainId override that differs
272
+ // from the original agent_id, archived_traces row brain_ids stay at the
273
+ // original agent_id values (not the override). Live tables receive the
274
+ // override; only archived_traces inherits agent_id. To rebrand archives,
275
+ // run a separate UPDATE statement after migration.
269
276
  brainIdSourceColumn: 'agent_id',
270
277
  indexes: [
271
278
  `CREATE INDEX IF NOT EXISTS idx_archived_traces_brain_time
@@ -289,6 +296,16 @@ const V2_TABLES = [
289
296
  ],
290
297
  },
291
298
  ];
299
+ // Sanity check: V2_TABLES names must exactly equal PORTABLE_TABLES order.
300
+ // Failing this assertion means the migration order would not match the
301
+ // portable-artifact order, breaking import/export.
302
+ const v2TableNames = V2_TABLES.map((t) => t.name);
303
+ const portableTableNames = [...PORTABLE_TABLES];
304
+ if (v2TableNames.length !== portableTableNames.length ||
305
+ v2TableNames.some((n, i) => n !== portableTableNames[i])) {
306
+ throw new Error(`v1-to-v2.ts: V2_TABLES order (${v2TableNames.join(',')}) does not match ` +
307
+ `PORTABLE_TABLES (${portableTableNames.join(',')}). Reconcile portable-tables.ts.`);
308
+ }
292
309
  /**
293
310
  * Run the v1 -> v2 migration on the given storage adapter.
294
311
  *
@@ -402,10 +419,23 @@ async function migrateSqliteTable(adapter, table, brainId) {
402
419
  async function migratePostgresTable(adapter, table, brainId) {
403
420
  const escapedBrainId = brainId.replace(/'/g, "''");
404
421
  if (table.brainIdSourceColumn) {
405
- // Add nullable, then UPDATE from source column, then SET NOT NULL.
406
- await adapter.exec(`ALTER TABLE ${table.name} ADD COLUMN brain_id TEXT`);
407
- await adapter.exec(`UPDATE ${table.name} SET brain_id = ${table.brainIdSourceColumn}`);
408
- await adapter.exec(`ALTER TABLE ${table.name} ALTER COLUMN brain_id SET NOT NULL`);
422
+ // Defensive: an old archived_traces table might exist without the
423
+ // expected source column (e.g., schema drift from manual SQL or pre-
424
+ // archive-feature deployments). Mirror the SQLite path's column-existence
425
+ // check (see migrateSqliteTable) so a missing source column falls back
426
+ // to the supplied brainId default rather than crashing the migration.
427
+ const hasSourceColumn = await postgresHasColumn(adapter, table.name, table.brainIdSourceColumn);
428
+ if (hasSourceColumn) {
429
+ await adapter.exec(`ALTER TABLE ${table.name} ADD COLUMN brain_id TEXT`);
430
+ await adapter.exec(`UPDATE ${table.name} SET brain_id = ${table.brainIdSourceColumn}`);
431
+ await adapter.exec(`ALTER TABLE ${table.name} ALTER COLUMN brain_id SET NOT NULL`);
432
+ }
433
+ else {
434
+ // Source column missing: fall back to the supplied brainId default,
435
+ // same as the no-source-column path.
436
+ await adapter.exec(`ALTER TABLE ${table.name} ADD COLUMN brain_id TEXT NOT NULL DEFAULT '${escapedBrainId}'`);
437
+ await adapter.exec(`ALTER TABLE ${table.name} ALTER COLUMN brain_id DROP DEFAULT`);
438
+ }
409
439
  }
410
440
  else {
411
441
  await adapter.exec(`ALTER TABLE ${table.name} ADD COLUMN brain_id TEXT NOT NULL DEFAULT '${escapedBrainId}'`);
@@ -420,4 +450,42 @@ async function migratePostgresTable(adapter, table, brainId) {
420
450
  await adapter.exec(idx);
421
451
  }
422
452
  }
453
+ /**
454
+ * The v1 -> v2 schema migration as a Migration object for MigrationRunner.
455
+ *
456
+ * The runner handles transaction wrapping, advisory locking, and the
457
+ * schema_version bump. This Migration's `up` function only runs the schema
458
+ * diff (the 14-table walk).
459
+ */
460
+ export const v1ToV2 = {
461
+ version: 2,
462
+ up: async (adapter, _features, brainId) => {
463
+ // The runner already detected that schema_version < 2 (or null=fresh; in
464
+ // the fresh case the runner would have skipped this migration entirely).
465
+ // We still defensively check brain_meta column existence so a partial v1
466
+ // schema doesn't blow up the migration.
467
+ const isPostgres = adapter.kind.includes('postgres');
468
+ const hasBrainId = isPostgres
469
+ ? await postgresHasColumn(adapter, 'brain_meta', 'brain_id')
470
+ : await sqliteHasColumn(adapter, 'brain_meta', 'brain_id');
471
+ if (hasBrainId) {
472
+ // Schema is already at v2 column shape; runner's version filter caught
473
+ // this case. Defensive no-op.
474
+ return;
475
+ }
476
+ for (const table of V2_TABLES) {
477
+ const exists = isPostgres
478
+ ? await postgresTableExists(adapter, table.name)
479
+ : await sqliteTableExists(adapter, table.name);
480
+ if (!exists)
481
+ continue;
482
+ if (isPostgres) {
483
+ await migratePostgresTable(adapter, table, brainId);
484
+ }
485
+ else {
486
+ await migrateSqliteTable(adapter, table, brainId);
487
+ }
488
+ }
489
+ },
490
+ };
423
491
  //# sourceMappingURL=v1-to-v2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"v1-to-v2.js","sourceRoot":"","sources":["../../../../../src/memory/retrieval/store/migrations/v1-to-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAyBH;;;GAGG;AACH,MAAM,SAAS,GAAgB;IAC7B;QACE,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,gEAAgE;QAC5E,UAAU,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;QAC/B,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,eAAe;QACrB,UAAU,EAAE;;;;;;;;;;;;;;;KAeX;QACD,UAAU,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAC9B,OAAO,EAAE;YACP;4DACsD;YACtD;4CACsC;SACvC;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE;;;;;;;;;;KAUX;QACD,UAAU,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAC9B,OAAO,EAAE;YACP;6CACuC;SACxC;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE;;;;;;;;;;KAUX;QACD,UAAU,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAC9B,WAAW,EAAE;YACX,4EAA4E;YAC5E,4EAA4E;SAC7E;QACD,OAAO,EAAE;YACP;kDAC4C;YAC5C;kDAC4C;SAC7C;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE;;;;;;;;;;KAUX;QACD,UAAU,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAC9B,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE;;;;;;;;;KASX;QACD,UAAU,EAAE,CAAC,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C,gEAAgE;QAChE,MAAM,OAAO,CAAC,IAAI,CAAC,eAAe,KAAK,CAAC,IAAI,8BAA8B,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC;QAC7F,MAAM,OAAO,CAAC,IAAI,CAChB,eAAe,KAAK,CAAC,IAAI,qBAAqB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7E,CAAC;IACJ,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"v1-to-v2.js","sourceRoot":"","sources":["../../../../../src/memory/retrieval/store/migrations/v1-to-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAwBxD;;;GAGG;AACH,MAAM,SAAS,GAAgB;IAC7B;QACE,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,gEAAgE;QAC5E,UAAU,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;QAC/B,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,eAAe;QACrB,UAAU,EAAE;;;;;;;;;;;;;;;KAeX;QACD,UAAU,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAC9B,OAAO,EAAE;YACP;4DACsD;YACtD;4CACsC;SACvC;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE;;;;;;;;;;KAUX;QACD,UAAU,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAC9B,OAAO,EAAE;YACP;6CACuC;SACxC;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE;;;;;;;;;;KAUX;QACD,UAAU,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC;QAC9B,WAAW,EAAE;YACX,4EAA4E;YAC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E,KAAK,CAAC,IAAI,CAAC;gBAChD,CAAC,CAAC,MAAM,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,MAAM;gBAAE,SAAS;YAEtB,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACN,MAAM,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview Single source of truth for the list of brain-owned tables that
3
+ * are exported, imported, and migrated as a portable artifact.
4
+ *
5
+ * Three call sites import from here:
6
+ * 1. `Brain.exportToSqlite` / `importFromSqlite` (export/import row copies)
7
+ * 2. `migrations/v1-to-v2.ts` (migration walk order: parents before children for FKs)
8
+ * 3. `__tests__/Brain.postgres.test.ts` (cleanup between tests)
9
+ *
10
+ * Adding a new portable table requires editing only this file.
11
+ *
12
+ * @module memory/retrieval/store/portable-tables
13
+ */
14
+ /**
15
+ * Order matters: parents before children to satisfy FK constraints during import.
16
+ */
17
+ export declare const PORTABLE_TABLES: readonly ["brain_meta", "memory_traces", "knowledge_nodes", "knowledge_edges", "documents", "document_chunks", "document_images", "consolidation_log", "retrieval_feedback", "conversations", "messages", "prospective_items", "archived_traces", "archive_access_log"];
18
+ /**
19
+ * Composite primary key columns for each portable table, used by
20
+ * `dialect.insertOrReplace` as the conflict target during merge import.
21
+ *
22
+ * Tables with `INTEGER PRIMARY KEY AUTOINCREMENT` (consolidation_log,
23
+ * retrieval_feedback) use `id` alone since their PK is system-generated.
24
+ */
25
+ export declare const PORTABLE_TABLE_PRIMARY_KEYS: Record<string, string>;
26
+ export type PortableTable = typeof PORTABLE_TABLES[number];
27
+ //# sourceMappingURL=portable-tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portable-tables.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/store/portable-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,yQAelB,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAe9D,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @fileoverview Single source of truth for the list of brain-owned tables that
3
+ * are exported, imported, and migrated as a portable artifact.
4
+ *
5
+ * Three call sites import from here:
6
+ * 1. `Brain.exportToSqlite` / `importFromSqlite` (export/import row copies)
7
+ * 2. `migrations/v1-to-v2.ts` (migration walk order: parents before children for FKs)
8
+ * 3. `__tests__/Brain.postgres.test.ts` (cleanup between tests)
9
+ *
10
+ * Adding a new portable table requires editing only this file.
11
+ *
12
+ * @module memory/retrieval/store/portable-tables
13
+ */
14
+ /**
15
+ * Order matters: parents before children to satisfy FK constraints during import.
16
+ */
17
+ export const PORTABLE_TABLES = [
18
+ 'brain_meta',
19
+ 'memory_traces',
20
+ 'knowledge_nodes',
21
+ 'knowledge_edges',
22
+ 'documents',
23
+ 'document_chunks',
24
+ 'document_images',
25
+ 'consolidation_log',
26
+ 'retrieval_feedback',
27
+ 'conversations',
28
+ 'messages',
29
+ 'prospective_items',
30
+ 'archived_traces',
31
+ 'archive_access_log',
32
+ ];
33
+ /**
34
+ * Composite primary key columns for each portable table, used by
35
+ * `dialect.insertOrReplace` as the conflict target during merge import.
36
+ *
37
+ * Tables with `INTEGER PRIMARY KEY AUTOINCREMENT` (consolidation_log,
38
+ * retrieval_feedback) use `id` alone since their PK is system-generated.
39
+ */
40
+ export const PORTABLE_TABLE_PRIMARY_KEYS = {
41
+ brain_meta: 'brain_id, key',
42
+ memory_traces: 'brain_id, id',
43
+ knowledge_nodes: 'brain_id, id',
44
+ knowledge_edges: 'brain_id, id',
45
+ documents: 'brain_id, id',
46
+ document_chunks: 'brain_id, id',
47
+ document_images: 'brain_id, id',
48
+ consolidation_log: 'id',
49
+ retrieval_feedback: 'id',
50
+ conversations: 'brain_id, id',
51
+ messages: 'brain_id, id',
52
+ prospective_items: 'brain_id, id',
53
+ archived_traces: 'brain_id, trace_id',
54
+ archive_access_log: 'brain_id, trace_id, accessed_at',
55
+ };
56
+ //# sourceMappingURL=portable-tables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portable-tables.js","sourceRoot":"","sources":["../../../../src/memory/retrieval/store/portable-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY;IACZ,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,WAAW;IACX,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;IACnB,oBAAoB;IACpB,eAAe;IACf,UAAU;IACV,mBAAmB;IACnB,iBAAiB;IACjB,oBAAoB;CACZ,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA2B;IACjE,UAAU,EAAE,eAAe;IAC3B,aAAa,EAAE,cAAc;IAC7B,eAAe,EAAE,cAAc;IAC/B,eAAe,EAAE,cAAc;IAC/B,SAAS,EAAE,cAAc;IACzB,eAAe,EAAE,cAAc;IAC/B,eAAe,EAAE,cAAc;IAC/B,iBAAiB,EAAE,IAAI;IACvB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,cAAc;IAC7B,QAAQ,EAAE,cAAc;IACxB,iBAAiB,EAAE,cAAc;IACjC,eAAe,EAAE,oBAAoB;IACrC,kBAAkB,EAAE,iCAAiC;CACtD,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @file FourWayRrf.ts
3
+ * @description Four-way Reciprocal Rank Fusion over the typed-network
4
+ * retrieval signals: semantic similarity, BM25 lexical match, graph
5
+ * spreading activation, and temporal interval overlap. Per Hindsight
6
+ * §2.4.3, the fusion uses standard RRF with `k=60`:
7
+ *
8
+ * score(f) = Σ over rankings R of [1 / (k + rank_R(f))]
9
+ *
10
+ * Output is a single ranked list combining all four signals. Facts
11
+ * present in only some rankings are still scored — RRF naturally
12
+ * tolerates missing rankings because absent IDs contribute zero.
13
+ *
14
+ * @module @framers/agentos/memory/retrieval/typed-network/FourWayRrf
15
+ */
16
+ /**
17
+ * Inputs to the fusion. Each list is an ordered array of fact IDs
18
+ * from a separate retrieval signal.
19
+ */
20
+ export interface FourWayRrfInput {
21
+ /** Cosine-similarity ranking over fact embeddings. */
22
+ semantic: string[];
23
+ /** BM25 ranking over fact text. */
24
+ bm25: string[];
25
+ /** Spreading-activation ranking over the typed-network graph. */
26
+ graphActivation: string[];
27
+ /** Temporal-interval-overlap ranking against the query timestamp. */
28
+ temporalOverlap: string[];
29
+ }
30
+ /**
31
+ * Fusion options.
32
+ */
33
+ export interface FourWayRrfOptions {
34
+ /** RRF constant. Default 60 per the standard literature. */
35
+ k?: number;
36
+ /**
37
+ * Optional per-signal weight multiplier. Defaults to {1, 1, 1, 1}
38
+ * (uniform RRF). Use to emphasize one signal over others — e.g.
39
+ * downweighting graph activation when the typed network is sparse.
40
+ */
41
+ weights?: Partial<Record<keyof FourWayRrfInput, number>>;
42
+ }
43
+ /**
44
+ * Fuse four retrieval rankings via Reciprocal Rank Fusion. Returns
45
+ * the merged list ordered by descending fused score.
46
+ *
47
+ * @param input - Four ranked lists (semantic, BM25, graph, temporal).
48
+ * @param options - RRF k constant + optional per-signal weights.
49
+ */
50
+ export declare function fourWayRrf(input: FourWayRrfInput, options?: FourWayRrfOptions): string[];
51
+ //# sourceMappingURL=FourWayRrf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FourWayRrf.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/FourWayRrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mCAAmC;IACnC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iEAAiE;IACjE,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,qEAAqE;IACrE,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;CAC1D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,iBAAsB,GAC9B,MAAM,EAAE,CA8BV"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @file FourWayRrf.ts
3
+ * @description Four-way Reciprocal Rank Fusion over the typed-network
4
+ * retrieval signals: semantic similarity, BM25 lexical match, graph
5
+ * spreading activation, and temporal interval overlap. Per Hindsight
6
+ * §2.4.3, the fusion uses standard RRF with `k=60`:
7
+ *
8
+ * score(f) = Σ over rankings R of [1 / (k + rank_R(f))]
9
+ *
10
+ * Output is a single ranked list combining all four signals. Facts
11
+ * present in only some rankings are still scored — RRF naturally
12
+ * tolerates missing rankings because absent IDs contribute zero.
13
+ *
14
+ * @module @framers/agentos/memory/retrieval/typed-network/FourWayRrf
15
+ */
16
+ /**
17
+ * Fuse four retrieval rankings via Reciprocal Rank Fusion. Returns
18
+ * the merged list ordered by descending fused score.
19
+ *
20
+ * @param input - Four ranked lists (semantic, BM25, graph, temporal).
21
+ * @param options - RRF k constant + optional per-signal weights.
22
+ */
23
+ export function fourWayRrf(input, options = {}) {
24
+ const k = options.k ?? 60;
25
+ const w = {
26
+ semantic: options.weights?.semantic ?? 1,
27
+ bm25: options.weights?.bm25 ?? 1,
28
+ graphActivation: options.weights?.graphActivation ?? 1,
29
+ temporalOverlap: options.weights?.temporalOverlap ?? 1,
30
+ };
31
+ const scores = new Map();
32
+ const accumulate = (ranking, weight) => {
33
+ ranking.forEach((id, idx) => {
34
+ const rank = idx + 1;
35
+ const contribution = (1.0 / (k + rank)) * weight;
36
+ scores.set(id, (scores.get(id) ?? 0) + contribution);
37
+ });
38
+ };
39
+ accumulate(input.semantic, w.semantic);
40
+ accumulate(input.bm25, w.bm25);
41
+ accumulate(input.graphActivation, w.graphActivation);
42
+ accumulate(input.temporalOverlap, w.temporalOverlap);
43
+ return [...scores.entries()]
44
+ .sort((a, b) => b[1] - a[1])
45
+ .map(([id]) => id);
46
+ }
47
+ //# sourceMappingURL=FourWayRrf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FourWayRrf.js","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/FourWayRrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA+BH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB,EACtB,UAA6B,EAAE;IAE/B,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1B,MAAM,CAAC,GAAG;QACR,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,IAAI,CAAC;QACxC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC;QAChC,eAAe,EAAE,OAAO,CAAC,OAAO,EAAE,eAAe,IAAI,CAAC;QACtD,eAAe,EAAE,OAAO,CAAC,OAAO,EAAE,eAAe,IAAI,CAAC;KACvD,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,MAAM,UAAU,GAAG,CACjB,OAAiB,EACjB,MAAc,EACR,EAAE;QACR,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;YAC1B,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;YACrB,MAAM,YAAY,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC;YACjD,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/B,UAAU,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IACrD,UAAU,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAErD,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;SACzB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file TemporalIntervalOverlap.ts
3
+ * @description Temporal-overlap ranking signal for the 4-way RRF
4
+ * fusion. Given a query timestamp and a set of typed facts, ranks the
5
+ * facts by how tightly their occurrence intervals (`τs, τe`) bracket
6
+ * the query timestamp, with a graceful fallback to mention-timestamp
7
+ * distance for facts without a full interval.
8
+ *
9
+ * Hindsight Eq. 12 weighs temporal edges by `exp(−Δt / σt)`. This
10
+ * file's `rankByTemporalOverlap` produces the same monotone signal in
11
+ * a form suitable for the BM25 / semantic / spreading-activation /
12
+ * temporal four-way RRF fusion (see {@link FourWayRrf}).
13
+ *
14
+ * @module @framers/agentos/memory/retrieval/typed-network/TemporalIntervalOverlap
15
+ */
16
+ import type { TypedFact } from './types.js';
17
+ /**
18
+ * Rank an array of typed facts by their temporal proximity to a query
19
+ * timestamp. Facts whose `(start, end)` interval contains the query
20
+ * rank highest, with tighter intervals (smaller width) scoring higher
21
+ * within the contained set. Facts whose interval lies outside the
22
+ * query rank by the minimum endpoint distance. Facts with only a
23
+ * mention timestamp fall back to mention-distance.
24
+ *
25
+ * Returns a new array; the input is not mutated. Stable ordering
26
+ * within tied scores follows JavaScript's `Array.prototype.sort`
27
+ * insertion order.
28
+ *
29
+ * @param facts - Typed facts to rank.
30
+ * @param queryTimestamp - ISO 8601 string. Invalid timestamps fall
31
+ * back to original ordering.
32
+ */
33
+ export declare function rankByTemporalOverlap(facts: TypedFact[], queryTimestamp: string): TypedFact[];
34
+ //# sourceMappingURL=TemporalIntervalOverlap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemporalIntervalOverlap.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/TemporalIntervalOverlap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,EAAE,EAClB,cAAc,EAAE,MAAM,GACrB,SAAS,EAAE,CAUb"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @file TemporalIntervalOverlap.ts
3
+ * @description Temporal-overlap ranking signal for the 4-way RRF
4
+ * fusion. Given a query timestamp and a set of typed facts, ranks the
5
+ * facts by how tightly their occurrence intervals (`τs, τe`) bracket
6
+ * the query timestamp, with a graceful fallback to mention-timestamp
7
+ * distance for facts without a full interval.
8
+ *
9
+ * Hindsight Eq. 12 weighs temporal edges by `exp(−Δt / σt)`. This
10
+ * file's `rankByTemporalOverlap` produces the same monotone signal in
11
+ * a form suitable for the BM25 / semantic / spreading-activation /
12
+ * temporal four-way RRF fusion (see {@link FourWayRrf}).
13
+ *
14
+ * @module @framers/agentos/memory/retrieval/typed-network/TemporalIntervalOverlap
15
+ */
16
+ /** One day in milliseconds — used as the natural unit for distance penalties. */
17
+ const DAY_MS = 86400000;
18
+ /**
19
+ * Rank an array of typed facts by their temporal proximity to a query
20
+ * timestamp. Facts whose `(start, end)` interval contains the query
21
+ * rank highest, with tighter intervals (smaller width) scoring higher
22
+ * within the contained set. Facts whose interval lies outside the
23
+ * query rank by the minimum endpoint distance. Facts with only a
24
+ * mention timestamp fall back to mention-distance.
25
+ *
26
+ * Returns a new array; the input is not mutated. Stable ordering
27
+ * within tied scores follows JavaScript's `Array.prototype.sort`
28
+ * insertion order.
29
+ *
30
+ * @param facts - Typed facts to rank.
31
+ * @param queryTimestamp - ISO 8601 string. Invalid timestamps fall
32
+ * back to original ordering.
33
+ */
34
+ export function rankByTemporalOverlap(facts, queryTimestamp) {
35
+ const queryMs = Date.parse(queryTimestamp);
36
+ if (Number.isNaN(queryMs))
37
+ return [...facts];
38
+ const scored = facts.map((f) => ({
39
+ fact: f,
40
+ score: scoreOverlap(f, queryMs),
41
+ }));
42
+ scored.sort((a, b) => b.score - a.score);
43
+ return scored.map((s) => s.fact);
44
+ }
45
+ /**
46
+ * Score a single fact against the query timestamp. Higher = more
47
+ * relevant.
48
+ *
49
+ * Score scale:
50
+ * - In-interval facts produce scores in (1.0, 2.0] — every in-interval
51
+ * fact outranks every out-of-interval fact regardless of width vs
52
+ * endpoint-distance. Tighter intervals score closer to 2.0.
53
+ * - Out-of-interval facts produce scores in (0, 1.0) — closer
54
+ * endpoint distances score nearer to 1.0.
55
+ * - Mention-only facts produce scores in (0, 1.0) — same scale as
56
+ * out-of-interval (the mention timestamp is treated as a degenerate
57
+ * point-interval).
58
+ *
59
+ * The +1.0 boost on in-interval guarantees the order semantics the
60
+ * Hindsight paper §2.4.1 implies: temporal containment is a
61
+ * categorical match; width breaks ties within that category. Without
62
+ * the boost, a wide containing interval can score below a narrow non-
63
+ * containing one (which is geometrically wrong).
64
+ */
65
+ function scoreOverlap(fact, queryMs) {
66
+ const start = fact.temporal.start ? Date.parse(fact.temporal.start) : NaN;
67
+ const end = fact.temporal.end ? Date.parse(fact.temporal.end) : NaN;
68
+ const mention = Date.parse(fact.temporal.mention);
69
+ if (!Number.isNaN(start) && !Number.isNaN(end)) {
70
+ if (queryMs >= start && queryMs <= end) {
71
+ // Query inside interval — score by inverse interval width,
72
+ // boosted by +1.0 so it outranks all out-of-interval facts.
73
+ const width = Math.max(1, end - start);
74
+ return 1.0 + 1.0 / (1 + width / DAY_MS);
75
+ }
76
+ // Query outside — penalize by distance to nearest endpoint.
77
+ const dist = Math.min(Math.abs(queryMs - start), Math.abs(queryMs - end));
78
+ return 1.0 / (1 + dist / DAY_MS);
79
+ }
80
+ // Fall back to mention-timestamp distance.
81
+ if (Number.isNaN(mention))
82
+ return 0;
83
+ const dist = Math.abs(queryMs - mention);
84
+ return 1.0 / (1 + dist / DAY_MS);
85
+ }
86
+ //# sourceMappingURL=TemporalIntervalOverlap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemporalIntervalOverlap.js","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/TemporalIntervalOverlap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,iFAAiF;AACjF,MAAM,MAAM,GAAG,QAAU,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAkB,EAClB,cAAsB;IAEtB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAE7C,MAAM,MAAM,GAAG,KAAK,CAAC,G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GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;QAC1C,CAAC;QACD,4DAA4D;QAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC;QAC1E,OAAO,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,2CAA2C;IAC3C,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;IACzC,OAAO,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @file TypedNetworkObserver.ts
3
+ * @description LLM-driven extractor that turns a conversation block
4
+ * into 0+ {@link TypedFact}s. Wraps the 6-step extraction prompt and
5
+ * the zod-validated parsing of the LLM's structured-output response.
6
+ *
7
+ * Production wiring: a typical caller constructs the observer once per
8
+ * pipeline (re-using the same `gpt-5-mini` adapter), then invokes
9
+ * {@link TypedNetworkObserver.extract} per session. The returned facts
10
+ * are then upserted into a {@link TypedNetworkStore} and embedded by
11
+ * the host's {@link IEmbeddingManager}.
12
+ *
13
+ * @module @framers/agentos/memory/retrieval/typed-network/TypedNetworkObserver
14
+ */
15
+ import type { TypedFact } from './types.js';
16
+ /**
17
+ * Provider-agnostic LLM interface for the extractor. Matches the
18
+ * shape used elsewhere in agentos for classifier / observer LLM
19
+ * adapters: a single `invoke(args)` async method returning the raw
20
+ * text response. Implementations wrap OpenAI, Anthropic, local
21
+ * models, or test mocks.
22
+ */
23
+ export interface ITypedExtractionLLM {
24
+ invoke(args: {
25
+ system: string;
26
+ user: string;
27
+ maxTokens: number;
28
+ temperature: number;
29
+ }): Promise<string>;
30
+ }
31
+ /**
32
+ * Construction options for the observer.
33
+ */
34
+ export interface TypedNetworkObserverOptions {
35
+ /** LLM adapter implementing the 6-step extraction call. */
36
+ llm: ITypedExtractionLLM;
37
+ /** Max output tokens. Default 4096 (Hindsight extractions are typically 50-200 facts × ~30 tokens each). */
38
+ maxTokens?: number;
39
+ /** Temperature. Default 0 for deterministic extraction. */
40
+ temperature?: number;
41
+ }
42
+ /**
43
+ * The 6-step extractor. Stateless aside from its constructor options;
44
+ * safe to share across concurrent extractions.
45
+ */
46
+ export declare class TypedNetworkObserver {
47
+ private readonly llm;
48
+ private readonly maxTokens;
49
+ private readonly temperature;
50
+ constructor(options: TypedNetworkObserverOptions);
51
+ /**
52
+ * Extract typed facts from a conversation block. Uses the 6-step
53
+ * prompt + zod-validated parsing. The resulting facts have stable
54
+ * IDs of the form `<sessionId>-fact-<index>` so re-extraction
55
+ * against the same content reproduces the same IDs.
56
+ *
57
+ * @param sessionText - Full conversation text. Will be wrapped in
58
+ * the user prompt's delimiters automatically.
59
+ * @param sessionId - Stable identifier used to namespace the
60
+ * resulting fact IDs.
61
+ * @returns Array of {@link TypedFact}s, possibly empty.
62
+ * @throws ZodError if the LLM output fails schema validation.
63
+ * @throws SyntaxError if the LLM output is not valid JSON.
64
+ */
65
+ extract(sessionText: string, sessionId: string): Promise<TypedFact[]>;
66
+ }
67
+ //# sourceMappingURL=TypedNetworkObserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypedNetworkObserver.d.ts","sourceRoot":"","sources":["../../../../src/memory/retrieval/typed-network/TypedNetworkObserver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,IAAI,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,2DAA2D;IAC3D,GAAG,EAAE,mBAAmB,CAAC;IACzB,4GAA4G;IAC5G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAsB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,OAAO,EAAE,2BAA2B;IAMhD;;;;;;;;;;;;;OAaG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CAwB5E"}