@codemem/core 0.0.0 → 0.20.0-alpha.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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/dist/address-utils.d.ts +24 -0
  3. package/dist/address-utils.d.ts.map +1 -0
  4. package/dist/api-types.d.ts +580 -0
  5. package/dist/api-types.d.ts.map +1 -0
  6. package/dist/claude-hooks.d.ts +62 -0
  7. package/dist/claude-hooks.d.ts.map +1 -0
  8. package/dist/coordinator-api.d.ts +11 -0
  9. package/dist/coordinator-api.d.ts.map +1 -0
  10. package/dist/coordinator-invites.d.ts +28 -0
  11. package/dist/coordinator-invites.d.ts.map +1 -0
  12. package/dist/coordinator-store.d.ts +67 -0
  13. package/dist/coordinator-store.d.ts.map +1 -0
  14. package/dist/db.d.ts +97 -0
  15. package/dist/db.d.ts.map +1 -0
  16. package/dist/embeddings.d.ts +39 -0
  17. package/dist/embeddings.d.ts.map +1 -0
  18. package/dist/export-import.d.ts +48 -0
  19. package/dist/export-import.d.ts.map +1 -0
  20. package/dist/filters.d.ts +34 -0
  21. package/dist/filters.d.ts.map +1 -0
  22. package/dist/index.d.ts +66 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +7287 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/ingest-events.d.ts +34 -0
  27. package/dist/ingest-events.d.ts.map +1 -0
  28. package/dist/ingest-filters.d.ts +16 -0
  29. package/dist/ingest-filters.d.ts.map +1 -0
  30. package/dist/ingest-pipeline.d.ts +56 -0
  31. package/dist/ingest-pipeline.d.ts.map +1 -0
  32. package/dist/ingest-prompts.d.ts +22 -0
  33. package/dist/ingest-prompts.d.ts.map +1 -0
  34. package/dist/ingest-sanitize.d.ts +18 -0
  35. package/dist/ingest-sanitize.d.ts.map +1 -0
  36. package/dist/ingest-transcript.d.ts +41 -0
  37. package/dist/ingest-transcript.d.ts.map +1 -0
  38. package/dist/ingest-types.d.ts +70 -0
  39. package/dist/ingest-types.d.ts.map +1 -0
  40. package/dist/ingest-xml-parser.d.ts +20 -0
  41. package/dist/ingest-xml-parser.d.ts.map +1 -0
  42. package/dist/integers.d.ts +13 -0
  43. package/dist/integers.d.ts.map +1 -0
  44. package/dist/maintenance.d.ts +71 -0
  45. package/dist/maintenance.d.ts.map +1 -0
  46. package/dist/observer-auth.d.ts +65 -0
  47. package/dist/observer-auth.d.ts.map +1 -0
  48. package/dist/observer-client.d.ts +104 -0
  49. package/dist/observer-client.d.ts.map +1 -0
  50. package/dist/observer-config.d.ts +57 -0
  51. package/dist/observer-config.d.ts.map +1 -0
  52. package/dist/pack.d.ts +36 -0
  53. package/dist/pack.d.ts.map +1 -0
  54. package/dist/project.d.ts +12 -0
  55. package/dist/project.d.ts.map +1 -0
  56. package/dist/raw-event-flush.d.ts +43 -0
  57. package/dist/raw-event-flush.d.ts.map +1 -0
  58. package/dist/raw-event-sweeper.d.ts +92 -0
  59. package/dist/raw-event-sweeper.d.ts.map +1 -0
  60. package/dist/schema.d.ts +7368 -0
  61. package/dist/schema.d.ts.map +1 -0
  62. package/dist/search.d.ts +76 -0
  63. package/dist/search.d.ts.map +1 -0
  64. package/dist/store.d.ts +274 -0
  65. package/dist/store.d.ts.map +1 -0
  66. package/dist/sync-auth.d.ts +81 -0
  67. package/dist/sync-auth.d.ts.map +1 -0
  68. package/dist/sync-daemon.d.ts +50 -0
  69. package/dist/sync-daemon.d.ts.map +1 -0
  70. package/dist/sync-discovery.d.ts +93 -0
  71. package/dist/sync-discovery.d.ts.map +1 -0
  72. package/dist/sync-http-client.d.ts +26 -0
  73. package/dist/sync-http-client.d.ts.map +1 -0
  74. package/dist/sync-identity.d.ts +38 -0
  75. package/dist/sync-identity.d.ts.map +1 -0
  76. package/dist/sync-pass.d.ts +63 -0
  77. package/dist/sync-pass.d.ts.map +1 -0
  78. package/dist/sync-replication.d.ts +99 -0
  79. package/dist/sync-replication.d.ts.map +1 -0
  80. package/dist/test-utils.d.ts +27 -0
  81. package/dist/test-utils.d.ts.map +1 -0
  82. package/dist/types.d.ts +414 -0
  83. package/dist/types.d.ts.map +1 -0
  84. package/dist/vectors.d.ts +59 -0
  85. package/dist/vectors.d.ts.map +1 -0
  86. package/package.json +41 -1
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Device identity management for the codemem sync system.
3
+ *
4
+ * Handles Ed25519 keypair generation, fingerprinting, and optional
5
+ * keychain storage. Ported from codemem/sync_identity.py.
6
+ */
7
+ import type { Database } from "./db.js";
8
+ /** SHA-256 hex digest of a public key string. */
9
+ export declare function fingerprintPublicKey(publicKey: string): string;
10
+ /** Store a private key in the OS keychain. Returns true on success. */
11
+ export declare function storePrivateKeyKeychain(privateKey: Buffer, deviceId: string): boolean;
12
+ /** Load a private key from the OS keychain. Returns null if unavailable. */
13
+ export declare function loadPrivateKeyKeychain(deviceId: string): Buffer | null;
14
+ /** Resolve private and public key file paths. */
15
+ export declare function resolveKeyPaths(keysDir?: string): [string, string];
16
+ /** Read the public key from disk. Returns null if missing or empty. */
17
+ export declare function loadPublicKey(keysDir?: string): string | null;
18
+ /** Read the private key from disk (with keychain fallback). Returns null if unavailable. */
19
+ export declare function loadPrivateKey(keysDir?: string, dbPath?: string): Buffer | null;
20
+ /**
21
+ * Generate an Ed25519 keypair using Node's native crypto.
22
+ * Stores private key as PEM (PKCS8), public key as SSH format for compatibility.
23
+ */
24
+ export declare function generateKeypair(privatePath: string, publicPath: string): void;
25
+ /** Validate that an existing keypair is consistent. */
26
+ export declare function validateExistingKeypair(privatePath: string, publicPath: string): boolean;
27
+ export interface EnsureDeviceIdentityOptions {
28
+ keysDir?: string;
29
+ deviceId?: string;
30
+ }
31
+ /**
32
+ * Ensure this device has a keypair and a row in the sync_device table.
33
+ *
34
+ * Returns [deviceId, fingerprint]. Creates keys and DB row if missing,
35
+ * validates and repairs if existing.
36
+ */
37
+ export declare function ensureDeviceIdentity(db: Database, options?: EnsureDeviceIdentityOptions): [string, string];
38
+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C,MAAM,EAAE,MAAM,CAAC,CA2ElB"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Sync pass orchestrator: coordinates a single sync exchange with a peer device.
3
+ *
4
+ * Handles the pull→apply→push cycle for replication ops, with address
5
+ * fallback, fingerprint verification, and cursor tracking.
6
+ * Ported from codemem/sync/sync_pass.py.
7
+ */
8
+ import type { Database } from "./db.js";
9
+ export interface SyncResult {
10
+ ok: boolean;
11
+ error?: string;
12
+ address?: string;
13
+ opsIn: number;
14
+ opsOut: number;
15
+ addressErrors: Array<{
16
+ address: string;
17
+ error: string;
18
+ }>;
19
+ }
20
+ export interface SyncPassOptions {
21
+ limit?: number;
22
+ keysDir?: string;
23
+ }
24
+ /**
25
+ * Check if a cursor candidate advances beyond the current position.
26
+ *
27
+ * Cursors are `timestamp|op_id` strings that sort lexicographically.
28
+ */
29
+ export declare function cursorAdvances(current: string | null, candidate: string | null): boolean;
30
+ /**
31
+ * Compute a cursor string from a timestamp and op_id.
32
+ * Currently unused — will be needed when real apply logic advances the cursor.
33
+ */
34
+ export declare function computeCursor(createdAt: string, opId: string): string;
35
+ /**
36
+ * Placeholder for legacy migration + replication backfill.
37
+ *
38
+ * In the Python implementation this calls migrate_legacy_import_keys and
39
+ * backfill_replication_ops. Those are not yet ported to TS.
40
+ */
41
+ export declare function syncPassPreflight(_db: Database): void;
42
+ /**
43
+ * Execute a single sync exchange with a peer across the given addresses.
44
+ *
45
+ * Tries each address in order. On first success, returns immediately.
46
+ * On all failures, collects address-level errors and returns them.
47
+ */
48
+ export declare function syncOnce(db: Database, peerDeviceId: string, addresses: string[], options?: SyncPassOptions): Promise<SyncResult>;
49
+ /**
50
+ * Run a sync pass with a peer, resolving addresses from the database.
51
+ *
52
+ * Loads peer addresses from the sync_peers table and delegates to syncOnce.
53
+ */
54
+ export declare function runSyncPass(db: Database, peerDeviceId: string, options?: SyncPassOptions): Promise<SyncResult>;
55
+ /** Check if an error string indicates a network connectivity failure. */
56
+ export declare function isConnectivityError(error: string | null): boolean;
57
+ /** Count consecutive recent failures that are connectivity errors. */
58
+ export declare function consecutiveConnectivityFailures(db: Database, peerDeviceId: string, limit?: number): number;
59
+ /** Calculate backoff duration with jitter to avoid thundering herd. */
60
+ export declare function peerBackoffSeconds(consecutiveFailures: number): number;
61
+ /** Check if a peer should be skipped due to repeated connectivity failures. */
62
+ export declare function shouldSkipOfflinePeer(db: Database, peerDeviceId: string): boolean;
63
+ //# sourceMappingURL=sync-pass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-pass.d.ts","sourceRoot":"","sources":["../src/sync-pass.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAsBxC,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,eAAe;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAKxF;AAyJD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAErE;AA4DD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAErD;AAMD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC7B,EAAE,EAAE,QAAQ,EACZ,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,UAAU,CAAC,CA4IrB;AAMD;;;;GAIG;AACH,wBAAsB,WAAW,CAChC,EAAE,EAAE,QAAQ,EACZ,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,UAAU,CAAC,CAsBrB;AAuBD,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAIjE;AAED,sEAAsE;AACtE,wBAAgB,+BAA+B,CAC9C,EAAE,EAAE,QAAQ,EACZ,YAAY,EAAE,MAAM,EACpB,KAAK,SAAK,GACR,MAAM,CAoBR;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAMtE;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAwBjF"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Sync replication: cursor tracking, op chunking, and payload extraction.
3
+ *
4
+ * Uses Drizzle ORM for all SQL queries so that column mismatches are
5
+ * compile-time errors instead of silent data-loss bugs at runtime.
6
+ *
7
+ * Keeps replication functions decoupled from MemoryStore by accepting
8
+ * a raw Database handle. Ported from codemem/sync/replication.py.
9
+ */
10
+ import type { Database } from "./db.js";
11
+ import type { ReplicationOp } from "./types.js";
12
+ /**
13
+ * Split replication ops into batches that fit within a byte-size limit.
14
+ *
15
+ * Each batch is serialized as `{"ops": [...]}` and must not exceed maxBytes
16
+ * when UTF-8 encoded. Throws if a single op exceeds the limit.
17
+ */
18
+ export declare function chunkOpsBySize(ops: ReplicationOp[], maxBytes: number): ReplicationOp[][];
19
+ /**
20
+ * Read the replication cursor for a peer device.
21
+ *
22
+ * Returns `[lastApplied, lastAcked]` — both null when no cursor exists.
23
+ */
24
+ export declare function getReplicationCursor(db: Database, peerDeviceId: string): [lastApplied: string | null, lastAcked: string | null];
25
+ /**
26
+ * Insert or update the replication cursor for a peer device.
27
+ *
28
+ * Uses COALESCE on update so callers can set only one of the two cursors
29
+ * without clobbering the other.
30
+ */
31
+ export declare function setReplicationCursor(db: Database, peerDeviceId: string, options?: {
32
+ lastApplied?: string | null;
33
+ lastAcked?: string | null;
34
+ }): void;
35
+ /**
36
+ * Extract and validate replication ops from a parsed JSON payload.
37
+ *
38
+ * Returns an empty array if the payload is not an object or lacks an `ops` array.
39
+ * Silently filters out ops missing required fields to prevent garbage data
40
+ * from entering the replication pipeline.
41
+ */
42
+ export declare function extractReplicationOps(payload: unknown): ReplicationOp[];
43
+ /**
44
+ * Build a clock tuple from individual fields.
45
+ *
46
+ * Clock tuples enable lexicographic comparison for last-writer-wins
47
+ * conflict resolution: higher rev wins, tiebreak on updated_at, then device_id.
48
+ */
49
+ export declare function clockTuple(rev: number, updatedAt: string, deviceId: string): [number, string, string];
50
+ /**
51
+ * Return true if `candidate` clock is strictly newer than `existing`.
52
+ *
53
+ * Comparison order: rev (higher wins) → updated_at → device_id.
54
+ * Mirrors Python's `_is_newer_clock` which relies on tuple ordering.
55
+ */
56
+ export declare function isNewerClock(candidate: [number, string, string], existing: [number, string, string]): boolean;
57
+ /**
58
+ * Generate and INSERT a single replication op for a memory item.
59
+ *
60
+ * Reads the memory item's clock fields (rev, updated_at, metadata_json)
61
+ * from the DB, builds the op row, and inserts into `replication_ops`.
62
+ * Returns the generated op_id (UUID).
63
+ *
64
+ * Uses Drizzle's typed select so all memory_items columns are captured
65
+ * automatically — no hand-maintained column list to go out of sync.
66
+ */
67
+ export declare function recordReplicationOp(db: Database, opts: {
68
+ memoryId: number;
69
+ opType: "upsert" | "delete";
70
+ deviceId: string;
71
+ payload?: Record<string, unknown>;
72
+ }): string;
73
+ /**
74
+ * Load replication ops created after `cursor`, ordered by (created_at, op_id).
75
+ *
76
+ * Returns `[ops, nextCursor]` where nextCursor is the cursor for the last
77
+ * returned row (or null if no rows matched). The cursor format is
78
+ * `created_at|op_id`.
79
+ */
80
+ export declare function loadReplicationOpsSince(db: Database, cursor: string | null, limit?: number, deviceId?: string): [ReplicationOp[], string | null];
81
+ export interface ApplyResult {
82
+ applied: number;
83
+ skipped: number;
84
+ conflicts: number;
85
+ errors: string[];
86
+ }
87
+ /**
88
+ * Apply inbound replication ops from a remote peer.
89
+ *
90
+ * Runs all ops in a single transaction. For each op:
91
+ * - Skips if device_id matches localDeviceId (don't re-apply own ops)
92
+ * - Skips if op_id already exists (idempotent)
93
+ * - For upsert: finds existing memory by import_key; if existing has a newer
94
+ * clock, counts as conflict and skips; otherwise INSERT or UPDATE
95
+ * - For delete: soft-deletes (active=0, deleted_at) by import_key
96
+ * - Records the applied op in replication_ops
97
+ */
98
+ export declare function applyReplicationOps(db: Database, ops: ReplicationOp[], localDeviceId: string): ApplyResult;
99
+ //# sourceMappingURL=sync-replication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-replication.d.ts","sourceRoot":"","sources":["../src/sync-replication.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,EAAE,CAiCxF;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,QAAQ,EACZ,YAAY,EAAE,MAAM,GAClB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAaxD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,QAAQ,EACZ,YAAY,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;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAClC,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,aAAa,EAAE,EACpB,aAAa,EAAE,MAAM,GACnB,WAAW,CA4Mb"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Test utilities for the codemem TS backend.
3
+ *
4
+ * Schema DDL is derived from the canonical Python DDL in codemem/db.py
5
+ * but maintained here as a single string constant. When we complete the
6
+ * Drizzle query migration, Drizzle's `migrate()` or `push` will replace
7
+ * this — but the important thing is there's ONE place to update, not
8
+ * separate DDL in test-utils AND the Python file.
9
+ *
10
+ * The Drizzle schema in schema.ts defines types and query builders.
11
+ * This file defines the DDL that creates the tables those types target.
12
+ */
13
+ import type { Database } from "./db.js";
14
+ /**
15
+ * Create the full schema for test databases.
16
+ *
17
+ * This DDL matches the production schema from Python's codemem/db.py
18
+ * exactly — same column names, types, constraints, indexes, and triggers.
19
+ * Sets user_version to SCHEMA_VERSION so assertSchemaReady() passes.
20
+ */
21
+ export declare function initTestSchema(db: Database): void;
22
+ /**
23
+ * Insert a minimal test session and return its ID.
24
+ */
25
+ export declare function insertTestSession(db: Database): number;
26
+ export { MemoryStore } from "./store.js";
27
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AA2TxC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAQtD;AAGD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,414 @@
1
+ /**
2
+ * TypeScript type definitions for the codemem database schema.
3
+ *
4
+ * These match the Python schema defined in codemem/db.py and the
5
+ * data structures in codemem/store/types.py.
6
+ */
7
+ export interface Session {
8
+ id: number;
9
+ started_at: string;
10
+ ended_at: string | null;
11
+ cwd: string | null;
12
+ project: string | null;
13
+ git_remote: string | null;
14
+ git_branch: string | null;
15
+ user: string | null;
16
+ tool_version: string | null;
17
+ metadata_json: string | null;
18
+ import_key: string | null;
19
+ }
20
+ export interface MemoryItem {
21
+ id: number;
22
+ session_id: number;
23
+ kind: string;
24
+ title: string;
25
+ subtitle: string | null;
26
+ body_text: string;
27
+ confidence: number;
28
+ tags_text: string;
29
+ active: number;
30
+ created_at: string;
31
+ updated_at: string;
32
+ metadata_json: string | null;
33
+ actor_id: string | null;
34
+ actor_display_name: string | null;
35
+ visibility: string | null;
36
+ workspace_id: string | null;
37
+ workspace_kind: string | null;
38
+ origin_device_id: string | null;
39
+ origin_source: string | null;
40
+ trust_state: string | null;
41
+ facts: string | null;
42
+ narrative: string | null;
43
+ concepts: string | null;
44
+ files_read: string | null;
45
+ files_modified: string | null;
46
+ user_prompt_id: number | null;
47
+ prompt_number: number | null;
48
+ import_key: string | null;
49
+ deleted_at: string | null;
50
+ rev: number;
51
+ }
52
+ export interface Artifact {
53
+ id: number;
54
+ session_id: number;
55
+ kind: string;
56
+ path: string | null;
57
+ content_text: string | null;
58
+ content_hash: string | null;
59
+ content_encoding: string | null;
60
+ content_blob: Buffer | null;
61
+ created_at: string;
62
+ metadata_json: string | null;
63
+ }
64
+ export interface UsageEvent {
65
+ id: number;
66
+ session_id: number | null;
67
+ event: string;
68
+ tokens_read: number;
69
+ tokens_written: number;
70
+ tokens_saved: number;
71
+ created_at: string;
72
+ metadata_json: string | null;
73
+ }
74
+ export interface RawEvent {
75
+ id: number;
76
+ source: string;
77
+ stream_id: string;
78
+ opencode_session_id: string;
79
+ event_id: string | null;
80
+ event_seq: number;
81
+ event_type: string;
82
+ /** Wall-clock timestamp in ms. SQLite INTEGER. */
83
+ ts_wall_ms: number | null;
84
+ /** Monotonic timestamp in ms. SQLite REAL (may have fractional part). */
85
+ ts_mono_ms: number | null;
86
+ payload_json: string;
87
+ created_at: string;
88
+ }
89
+ export interface RawEventSession {
90
+ source: string;
91
+ stream_id: string;
92
+ opencode_session_id: string;
93
+ cwd: string | null;
94
+ project: string | null;
95
+ started_at: string | null;
96
+ last_seen_ts_wall_ms: number | null;
97
+ last_received_event_seq: number;
98
+ last_flushed_event_seq: number;
99
+ updated_at: string;
100
+ }
101
+ export interface RawEventFlushBatch {
102
+ id: number;
103
+ source: string;
104
+ stream_id: string;
105
+ opencode_session_id: string;
106
+ start_event_seq: number;
107
+ end_event_seq: number;
108
+ extractor_version: string;
109
+ status: string;
110
+ error_message: string | null;
111
+ error_type: string | null;
112
+ observer_provider: string | null;
113
+ observer_model: string | null;
114
+ observer_runtime: string | null;
115
+ attempt_count: number;
116
+ created_at: string;
117
+ updated_at: string;
118
+ }
119
+ export interface UserPrompt {
120
+ id: number;
121
+ session_id: number | null;
122
+ project: string | null;
123
+ prompt_text: string;
124
+ prompt_number: number | null;
125
+ created_at: string;
126
+ created_at_epoch: number;
127
+ metadata_json: string | null;
128
+ import_key: string | null;
129
+ }
130
+ export interface SessionSummary {
131
+ id: number;
132
+ session_id: number | null;
133
+ project: string | null;
134
+ request: string | null;
135
+ investigated: string | null;
136
+ learned: string | null;
137
+ completed: string | null;
138
+ next_steps: string | null;
139
+ notes: string | null;
140
+ files_read: string | null;
141
+ files_edited: string | null;
142
+ prompt_number: number | null;
143
+ created_at: string;
144
+ created_at_epoch: number;
145
+ metadata_json: string | null;
146
+ import_key: string | null;
147
+ }
148
+ export interface OpenCodeSession {
149
+ source: string;
150
+ stream_id: string;
151
+ opencode_session_id: string;
152
+ session_id: number | null;
153
+ created_at: string;
154
+ }
155
+ export interface RawEventIngestStats {
156
+ id: number;
157
+ inserted_events: number;
158
+ skipped_events: number;
159
+ skipped_invalid: number;
160
+ skipped_duplicate: number;
161
+ skipped_conflict: number;
162
+ updated_at: string;
163
+ }
164
+ export interface RawEventIngestSample {
165
+ id: number;
166
+ created_at: string;
167
+ inserted_events: number;
168
+ skipped_invalid: number;
169
+ skipped_duplicate: number;
170
+ skipped_conflict: number;
171
+ }
172
+ export interface ReplicationOp {
173
+ op_id: string;
174
+ entity_type: string;
175
+ entity_id: string;
176
+ op_type: string;
177
+ payload_json: string | null;
178
+ clock_rev: number;
179
+ clock_updated_at: string;
180
+ clock_device_id: string;
181
+ device_id: string;
182
+ created_at: string;
183
+ }
184
+ export interface ReplicationClock {
185
+ rev: number;
186
+ updated_at: string;
187
+ device_id: string;
188
+ }
189
+ export interface ReplicationCursor {
190
+ peer_device_id: string;
191
+ last_applied_cursor: string | null;
192
+ last_acked_cursor: string | null;
193
+ updated_at: string;
194
+ }
195
+ export interface SyncPeer {
196
+ peer_device_id: string;
197
+ name: string | null;
198
+ pinned_fingerprint: string | null;
199
+ public_key: string | null;
200
+ addresses_json: string | null;
201
+ claimed_local_actor: number;
202
+ actor_id: string | null;
203
+ projects_include_json: string | null;
204
+ projects_exclude_json: string | null;
205
+ created_at: string;
206
+ last_seen_at: string | null;
207
+ last_sync_at: string | null;
208
+ last_error: string | null;
209
+ }
210
+ export interface SyncNonce {
211
+ nonce: string;
212
+ device_id: string;
213
+ created_at: string;
214
+ }
215
+ export interface SyncDevice {
216
+ device_id: string;
217
+ public_key: string;
218
+ fingerprint: string;
219
+ created_at: string;
220
+ }
221
+ export interface SyncDaemonState {
222
+ id: number;
223
+ last_error: string | null;
224
+ last_traceback: string | null;
225
+ last_error_at: string | null;
226
+ last_ok_at: string | null;
227
+ }
228
+ export interface SyncAttempt {
229
+ id: number;
230
+ peer_device_id: string;
231
+ started_at: string;
232
+ finished_at: string | null;
233
+ ok: number;
234
+ ops_in: number;
235
+ ops_out: number;
236
+ error: string | null;
237
+ }
238
+ export interface Actor {
239
+ actor_id: string;
240
+ display_name: string;
241
+ is_local: number;
242
+ status: string;
243
+ merged_into_actor_id: string | null;
244
+ created_at: string;
245
+ updated_at: string;
246
+ }
247
+ /**
248
+ * MemoryItem with metadata_json parsed to an object.
249
+ * Returned by store.get(), store.recent(), updateMemoryVisibility(), etc.
250
+ */
251
+ export interface MemoryItemResponse extends Omit<MemoryItem, "metadata_json"> {
252
+ metadata_json: Record<string, unknown>;
253
+ }
254
+ /**
255
+ * MemoryItemResponse with linked_prompt for timeline results.
256
+ * linked_prompt will be populated once _attach_prompt_links is ported.
257
+ */
258
+ export interface TimelineItemResponse extends MemoryItemResponse {
259
+ linked_prompt: null;
260
+ }
261
+ /** Stats response from store.stats() */
262
+ export interface UsageEventRow {
263
+ event: string;
264
+ count: number;
265
+ tokens_read: number;
266
+ tokens_written: number;
267
+ tokens_saved: number;
268
+ }
269
+ export interface StoreStats {
270
+ identity: {
271
+ device_id: string;
272
+ actor_id: string;
273
+ actor_display_name: string;
274
+ };
275
+ database: {
276
+ path: string;
277
+ size_bytes: number;
278
+ sessions: number;
279
+ memory_items: number;
280
+ active_memory_items: number;
281
+ artifacts: number;
282
+ vector_rows: number;
283
+ vector_coverage: number;
284
+ tags_filled: number;
285
+ tags_coverage: number;
286
+ raw_events: number;
287
+ };
288
+ usage: {
289
+ events: UsageEventRow[];
290
+ totals: {
291
+ events: number;
292
+ tokens_read: number;
293
+ tokens_written: number;
294
+ tokens_saved: number;
295
+ };
296
+ };
297
+ }
298
+ /** Score breakdown in explain results */
299
+ export interface ExplainScoreComponents {
300
+ base: number | null;
301
+ recency: number;
302
+ kind_bonus: number;
303
+ personal_bias: number;
304
+ semantic_boost: number | null;
305
+ }
306
+ /** Single item in explain results */
307
+ export interface ExplainItem {
308
+ id: number;
309
+ kind: string;
310
+ title: string;
311
+ created_at: string;
312
+ project: string | null;
313
+ retrieval: {
314
+ source: string;
315
+ rank: number | null;
316
+ };
317
+ score: {
318
+ total: number | null;
319
+ components: ExplainScoreComponents;
320
+ };
321
+ matches: {
322
+ query_terms: string[];
323
+ project_match: boolean | null;
324
+ };
325
+ pack_context: string | null;
326
+ }
327
+ /** Explain response */
328
+ export interface ExplainResponse {
329
+ items: ExplainItem[];
330
+ missing_ids: number[];
331
+ errors: ExplainError[];
332
+ metadata: {
333
+ query: string | null;
334
+ project: string | null;
335
+ requested_ids_count: number;
336
+ returned_items_count: number;
337
+ include_pack_context: boolean;
338
+ };
339
+ }
340
+ export interface ExplainError {
341
+ code: string;
342
+ field: string;
343
+ message: string;
344
+ ids?: (string | number)[];
345
+ }
346
+ /** Single item in pack results */
347
+ export interface PackItem {
348
+ id: number;
349
+ kind: string;
350
+ title: string;
351
+ body: string;
352
+ confidence: number;
353
+ tags: string;
354
+ metadata: Record<string, unknown>;
355
+ /** Number of exact duplicates collapsed into this item. Only present when > 1. */
356
+ support_count?: number;
357
+ /** IDs of duplicates that were collapsed into this canonical item. Only present when non-empty. */
358
+ duplicate_ids?: number[];
359
+ }
360
+ /** Pack response from buildMemoryPack() */
361
+ export interface PackResponse {
362
+ context: string;
363
+ items: PackItem[];
364
+ item_ids: number[];
365
+ pack_text: string;
366
+ metrics: {
367
+ total_items: number;
368
+ pack_tokens: number;
369
+ fallback_used: boolean;
370
+ sources: {
371
+ fts: number;
372
+ semantic: number;
373
+ fuzzy: number;
374
+ };
375
+ };
376
+ }
377
+ export interface MemoryResult {
378
+ id: number;
379
+ kind: string;
380
+ title: string;
381
+ body_text: string;
382
+ confidence: number;
383
+ created_at: string;
384
+ updated_at: string;
385
+ tags_text: string;
386
+ score: number;
387
+ session_id: number;
388
+ metadata: Record<string, unknown>;
389
+ }
390
+ export interface MemoryFilters {
391
+ kind?: string;
392
+ session_id?: number;
393
+ since?: string;
394
+ /** Project scope — matches sessions.project. Triggers session JOIN. */
395
+ project?: string;
396
+ visibility?: string | string[];
397
+ include_visibility?: string[];
398
+ exclude_visibility?: string[];
399
+ include_workspace_ids?: string[];
400
+ exclude_workspace_ids?: string[];
401
+ include_workspace_kinds?: string[];
402
+ exclude_workspace_kinds?: string[];
403
+ include_actor_ids?: string[];
404
+ exclude_actor_ids?: string[];
405
+ include_trust_states?: string[];
406
+ exclude_trust_states?: string[];
407
+ ownership_scope?: "mine" | "theirs" | string;
408
+ personal_first?: boolean | string;
409
+ trust_bias?: "off" | "soft" | string;
410
+ widen_shared_when_weak?: boolean | string;
411
+ widen_shared_min_personal_results?: number;
412
+ widen_shared_min_personal_score?: number;
413
+ }
414
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,OAAO;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,QAAQ,EAAE,MAAM,GAAG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