@codemem/core 0.0.0 → 0.20.0-alpha.3

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 +42 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAC;AACnD,MAAM,MAAM,UAAU,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAC;AAEtD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAerB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,YAAY,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG,OAAO,SAAS,CAAC,YAAY,CAAC;AAExD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;CAqBlB,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * FTS5 full-text search, timeline, and explain for memory items.
3
+ *
4
+ * FTS5 MATCH queries and BM25 scoring use raw SQL (Drizzle has no FTS5 support).
5
+ * Simple queries (anchor lookup, batch ID fetch, session projects) use Drizzle typed queries.
6
+ * Dynamic filter queries use raw SQL since the filter builder returns SQL strings.
7
+ */
8
+ import type { ExplainResponse, MemoryFilters, MemoryItem, MemoryItemResponse, MemoryResult, TimelineItemResponse } from "./types.js";
9
+ /** Structural type for the store parameter (avoids circular import). */
10
+ export interface StoreHandle {
11
+ readonly db: import("better-sqlite3").Database;
12
+ readonly actorId: string;
13
+ readonly deviceId: string;
14
+ get(memoryId: number): MemoryItemResponse | null;
15
+ memoryOwnedBySelf(item: MemoryItem | MemoryResult | Record<string, unknown>): boolean;
16
+ recent(limit?: number, filters?: MemoryFilters | null, offset?: number): MemoryItemResponse[];
17
+ recentByKinds(kinds: string[], limit?: number, filters?: MemoryFilters | null, offset?: number): MemoryItemResponse[];
18
+ }
19
+ /**
20
+ * Expand a user query string into an FTS5 MATCH expression.
21
+ *
22
+ * Extracts alphanumeric tokens, filters out FTS5 operators,
23
+ * and joins multiple tokens with OR for broader matching.
24
+ */
25
+ export declare function expandQuery(query: string): string;
26
+ /**
27
+ * Compute a recency score for a memory based on its creation timestamp.
28
+ *
29
+ * Returns a value in (0, 1] where 1.0 means "just created" and the
30
+ * score decays with a 7-day half-life: score = 1 / (1 + days_ago / 7).
31
+ */
32
+ export declare function recencyScore(createdAt: string, now?: Date): number;
33
+ /**
34
+ * Return a scoring bonus for a memory kind.
35
+ *
36
+ * Higher-signal kinds (decisions, features) get a larger bonus.
37
+ * Unknown or null kinds return 0.
38
+ */
39
+ export declare function kindBonus(kind: string | null): number;
40
+ /**
41
+ * Re-rank search results by combining BM25 score, recency, kind bonus,
42
+ * personal bias, and shared trust penalty.
43
+ */
44
+ export declare function rerankResults(store: StoreHandle, results: MemoryResult[], limit: number, filters?: MemoryFilters): MemoryResult[];
45
+ /**
46
+ * Execute an FTS5 full-text search against memory_items.
47
+ *
48
+ * Uses expandQuery to prepare the MATCH expression, applies filters
49
+ * via buildFilterClauses, and re-ranks results. Optionally widens to
50
+ * shared workspaces when personal results are weak.
51
+ */
52
+ export declare function search(store: StoreHandle, query: string, limit?: number, filters?: MemoryFilters): MemoryResult[];
53
+ /**
54
+ * Return a chronological window of memories around an anchor.
55
+ *
56
+ * Finds an anchor by memoryId or query, then fetches neighbors in the
57
+ * same session ordered by created_at.
58
+ */
59
+ export declare function timeline(store: StoreHandle, query?: string | null, memoryId?: number | null, depthBefore?: number, depthAfter?: number, filters?: MemoryFilters | null): TimelineItemResponse[];
60
+ /**
61
+ * Deduplicate an array of IDs, preserving order. Returns valid int IDs
62
+ * and a list of values that could not be parsed as integers.
63
+ */
64
+ export declare function dedupeOrderedIds(ids: unknown[]): {
65
+ ordered: number[];
66
+ invalid: string[];
67
+ };
68
+ /**
69
+ * Explain search results with scoring breakdown.
70
+ *
71
+ * Accepts a query and/or explicit IDs, merges results, and returns a
72
+ * detailed scoring payload for each item including retrieval source,
73
+ * score components, and term matches.
74
+ */
75
+ export declare function explain(store: StoreHandle, query?: string | null, ids?: unknown[] | null, limit?: number, filters?: MemoryFilters | null): ExplainResponse;
76
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH,OAAO,KAAK,EAGX,eAAe,EACf,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,MAAM,YAAY,CAAC;AAOpB,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,EAAE,EAAE,OAAO,gBAAgB,EAAE,QAAQ,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAA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C,EAAE,MAAM,GAAG,IAAI,EACxB,WAAW,SAAI,EACf,UAAU,SAAI,EACd,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,GAC5B,oBAAoB,EAAE,CAyBxB;AAgFD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAiBzF;AAsKD;;;;;;GAMG;AACH,wBAAgB,OAAO,CACtB,KAAK,EAAE,WAAW,EAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EACtB,KAAK,SAAK,EACV,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,GAC5B,eAAe,CA6IjB"}
@@ -0,0 +1,274 @@
1
+ /**
2
+ * MemoryStore — TypeScript port of codemem/store/_store.py (Phase 1 CRUD).
3
+ *
4
+ * During Phase 1, Python owns DDL/schema. This TS runtime reads and writes data
5
+ * but does NOT create or migrate tables. The assertSchemaReady() call verifies
6
+ * the schema was initialized by Python before any operations.
7
+ *
8
+ * Methods ported: get, remember, forget, recent, recentByKinds, stats,
9
+ * updateMemoryVisibility, close.
10
+ *
11
+ * NOT ported yet: pack, usage tracking, vectors, provenance resolution,
12
+ * memory_owned_by_self check.
13
+ */
14
+ import type { Database } from "./db.js";
15
+ import type { ExplainResponse, MemoryFilters, MemoryItem, MemoryItemResponse, MemoryResult, PackResponse, StoreStats, TimelineItemResponse } from "./types.js";
16
+ export declare class MemoryStore {
17
+ readonly db: Database;
18
+ readonly dbPath: string;
19
+ readonly deviceId: string;
20
+ readonly actorId: string;
21
+ readonly actorDisplayName: string;
22
+ /** Lazy Drizzle ORM wrapper — shares the same better-sqlite3 connection. */
23
+ private _drizzle;
24
+ private get d();
25
+ constructor(dbPath?: string);
26
+ /**
27
+ * Fetch a single memory item by ID.
28
+ * Returns null if not found (does not filter by active status).
29
+ */
30
+ get(memoryId: number): MemoryItemResponse | null;
31
+ /**
32
+ * Create a new session row. Returns the session ID.
33
+ * Matches Python's store.start_session().
34
+ */
35
+ startSession(opts: {
36
+ cwd?: string;
37
+ project?: string | null;
38
+ gitRemote?: string | null;
39
+ gitBranch?: string | null;
40
+ user?: string;
41
+ toolVersion?: string;
42
+ metadata?: Record<string, unknown>;
43
+ }): number;
44
+ /**
45
+ * End a session by recording ended_at.
46
+ * FIX: merges incoming metadata with existing instead of replacing.
47
+ * No-op if session doesn't exist.
48
+ */
49
+ endSession(sessionId: number, metadata?: Record<string, unknown>): void;
50
+ /**
51
+ * Create a new memory item. Returns the new memory ID.
52
+ *
53
+ * Validates and normalizes the kind. Resolves provenance fields (actor_id,
54
+ * visibility, workspace_id, trust_state) matching Python's
55
+ * _resolve_memory_provenance logic.
56
+ */
57
+ remember(sessionId: number, kind: string, title: string, bodyText: string, confidence?: number, tags?: string[], metadata?: Record<string, unknown>): number;
58
+ /**
59
+ * Resolve provenance fields for a new memory, matching Python's
60
+ * _resolve_memory_provenance. Uses metadata overrides when present,
61
+ * falls back to store-level defaults.
62
+ */
63
+ private resolveProvenance;
64
+ /**
65
+ * Check if a memory item is owned by this actor/device.
66
+ * Port of Python's memory_owned_by_self().
67
+ *
68
+ * Python checks:
69
+ * 1. actor_id == self.actor_id → owned
70
+ * 2. origin_device_id in claimed_same_actor_peers → owned
71
+ * 3. actor_id in legacy sync actor ids → owned
72
+ *
73
+ * Simplified: check actor_id first, then origin_device_id.
74
+ * Peer claim/legacy checks deferred until sync parity is needed.
75
+ */
76
+ memoryOwnedBySelf(item: MemoryItem | MemoryResult | Record<string, unknown>): boolean;
77
+ /**
78
+ * Soft-delete a memory item (set active = 0, record deleted_at).
79
+ * Updates metadata_json with clock_device_id for replication tracing.
80
+ * No-op if the memory doesn't exist.
81
+ */
82
+ forget(memoryId: number): void;
83
+ /**
84
+ * Return recent active memories, newest first.
85
+ * Supports optional filters via buildFilterClauses.
86
+ */
87
+ recent(limit?: number, filters?: MemoryFilters | null, offset?: number): MemoryItemResponse[];
88
+ /**
89
+ * Return recent active memories filtered to specific kinds, newest first.
90
+ */
91
+ recentByKinds(kinds: string[], limit?: number, filters?: MemoryFilters | null, offset?: number): MemoryItemResponse[];
92
+ /**
93
+ * Return database statistics matching the Python stats() output shape.
94
+ */
95
+ stats(): StoreStats;
96
+ /**
97
+ * Update the visibility of an active memory item.
98
+ * Throws if visibility is invalid, memory not found, memory is inactive,
99
+ * or memory is not owned by this device/actor.
100
+ */
101
+ updateMemoryVisibility(memoryId: number, visibility: string): MemoryItemResponse;
102
+ /**
103
+ * Full-text search for memories using FTS5.
104
+ *
105
+ * Delegates to search.ts to keep the search logic decoupled.
106
+ * Results are ranked by BM25 score, recency, and kind bonus.
107
+ */
108
+ search(query: string, limit?: number, filters?: MemoryFilters): MemoryResult[];
109
+ /**
110
+ * Return a chronological window of memories around an anchor.
111
+ *
112
+ * Finds an anchor by memoryId or query, then fetches neighbors
113
+ * in the same session. Delegates to search.ts.
114
+ */
115
+ timeline(query?: string | null, memoryId?: number | null, depthBefore?: number, depthAfter?: number, filters?: MemoryFilters | null): TimelineItemResponse[];
116
+ /**
117
+ * Explain search results with scoring breakdown.
118
+ *
119
+ * Returns detailed scoring components for each result, merging
120
+ * query-based and ID-based lookups. Delegates to search.ts.
121
+ */
122
+ explain(query?: string | null, ids?: unknown[] | null, limit?: number, filters?: MemoryFilters | null): ExplainResponse;
123
+ /**
124
+ * Build a formatted memory pack from search results.
125
+ *
126
+ * Categorizes memories into summary/timeline/observations sections,
127
+ * with optional token budgeting. Delegates to pack.ts.
128
+ */
129
+ buildMemoryPack(context: string, limit?: number, tokenBudget?: number | null, filters?: MemoryFilters): PackResponse;
130
+ /**
131
+ * Build a memory pack with semantic candidate merging.
132
+ *
133
+ * Async version that runs vector KNN search via sqlite-vec and merges
134
+ * semantic candidates with FTS results. Falls back to FTS-only when
135
+ * embeddings are disabled or unavailable.
136
+ */
137
+ buildMemoryPackAsync(context: string, limit?: number, tokenBudget?: number | null, filters?: MemoryFilters): Promise<PackResponse>;
138
+ /**
139
+ * Normalize source/streamId to match Python's _normalize_stream_identity().
140
+ * Trims whitespace, lowercases source, defaults to "opencode".
141
+ */
142
+ private normalizeStreamIdentity;
143
+ /**
144
+ * Find sessions that have unflushed events and have been idle long enough.
145
+ * Port of raw_event_sessions_pending_idle_flush().
146
+ */
147
+ rawEventSessionsPendingIdleFlush(idleBeforeTsWallMs: number, limit?: number): {
148
+ source: string;
149
+ streamId: string;
150
+ }[];
151
+ /**
152
+ * Find sessions that have pending/failed flush batches with unflushed events.
153
+ * Port of raw_event_sessions_with_pending_queue().
154
+ */
155
+ rawEventSessionsWithPendingQueue(limit?: number): {
156
+ source: string;
157
+ streamId: string;
158
+ }[];
159
+ /**
160
+ * Delete raw events older than max_age_ms. Returns count of deleted raw_events rows.
161
+ * Port of purge_raw_events() + purge_raw_events_before().
162
+ */
163
+ purgeRawEvents(maxAgeMs: number): number;
164
+ /**
165
+ * Mark stuck flush batches (started/running/pending/claimed) as failed.
166
+ * Port of mark_stuck_raw_event_batches_as_error().
167
+ */
168
+ markStuckRawEventBatchesAsError(olderThanIso: string, limit?: number): number;
169
+ /**
170
+ * Get session metadata (cwd, project, started_at, etc.) for a raw event stream.
171
+ * Port of raw_event_session_meta().
172
+ */
173
+ rawEventSessionMeta(opencodeSessionId: string, source?: string): Record<string, unknown>;
174
+ /**
175
+ * Get the last flushed event_seq for a session. Returns -1 if no state.
176
+ * Port of raw_event_flush_state().
177
+ */
178
+ rawEventFlushState(opencodeSessionId: string, source?: string): number;
179
+ /**
180
+ * Get raw events after a given event_seq, ordered by event_seq ASC.
181
+ * Returns enriched event objects with type, timestamps, event_seq, event_id.
182
+ * Port of raw_events_since_by_seq().
183
+ */
184
+ rawEventsSinceBySeq(opencodeSessionId: string, source?: string, afterEventSeq?: number, limit?: number | null): Record<string, unknown>[];
185
+ /**
186
+ * Get or create a flush batch record. Returns [batchId, status].
187
+ * Port of get_or_create_raw_event_flush_batch().
188
+ */
189
+ getOrCreateRawEventFlushBatch(opencodeSessionId: string, source: string, startEventSeq: number, endEventSeq: number, extractorVersion: string): {
190
+ batchId: number;
191
+ status: string;
192
+ };
193
+ /**
194
+ * Attempt to claim a flush batch for processing.
195
+ * Returns true if successfully claimed, false if already claimed/completed.
196
+ * Port of claim_raw_event_flush_batch().
197
+ */
198
+ claimRawEventFlushBatch(batchId: number): boolean;
199
+ /**
200
+ * Update the status of a flush batch.
201
+ * Port of update_raw_event_flush_batch_status().
202
+ */
203
+ updateRawEventFlushBatchStatus(batchId: number, status: string): void;
204
+ /**
205
+ * Record a flush batch failure with error details.
206
+ * Port of record_raw_event_flush_batch_failure().
207
+ */
208
+ recordRawEventFlushBatchFailure(batchId: number, opts: {
209
+ message: string;
210
+ errorType: string;
211
+ observerProvider?: string | null;
212
+ observerModel?: string | null;
213
+ observerRuntime?: string | null;
214
+ }): void;
215
+ /**
216
+ * Update the last flushed event_seq for a session.
217
+ * Port of update_raw_event_flush_state().
218
+ */
219
+ updateRawEventFlushState(opencodeSessionId: string, lastFlushed: number, source?: string): void;
220
+ /**
221
+ * Update ingest stats counters (sample + running totals).
222
+ * Port of _update_raw_event_ingest_stats().
223
+ */
224
+ private updateRawEventIngestStats;
225
+ /**
226
+ * Record a single raw event. Returns true if inserted, false if duplicate.
227
+ * Port of record_raw_event().
228
+ */
229
+ recordRawEvent(opts: {
230
+ opencodeSessionId: string;
231
+ source?: string;
232
+ eventId: string;
233
+ eventType: string;
234
+ payload: Record<string, unknown>;
235
+ tsWallMs?: number | null;
236
+ tsMonoMs?: number | null;
237
+ }): boolean;
238
+ /**
239
+ * Record a batch of raw events for a single session. Returns { inserted, skipped }.
240
+ * Port of record_raw_events_batch().
241
+ */
242
+ recordRawEventsBatch(opencodeSessionId: string, events: Record<string, unknown>[]): {
243
+ inserted: number;
244
+ skipped: number;
245
+ };
246
+ /**
247
+ * UPSERT session metadata (cwd, project, started_at, last_seen_ts_wall_ms).
248
+ * Port of update_raw_event_session_meta().
249
+ */
250
+ updateRawEventSessionMeta(opts: {
251
+ opencodeSessionId: string;
252
+ source?: string;
253
+ cwd?: string | null;
254
+ project?: string | null;
255
+ startedAt?: string | null;
256
+ lastSeenTsWallMs?: number | null;
257
+ }): void;
258
+ /**
259
+ * Get totals of pending (unflushed) raw events.
260
+ * Port of raw_event_backlog_totals().
261
+ */
262
+ rawEventBacklogTotals(): {
263
+ pending: number;
264
+ sessions: number;
265
+ };
266
+ /**
267
+ * Get the latest failed flush batch, or null if none.
268
+ * Port of latest_raw_event_flush_failure().
269
+ */
270
+ latestRawEventFlushFailure(source?: string | null): Record<string, unknown> | null;
271
+ /** Close the database connection. */
272
+ close(): void;
273
+ }
274
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAmBxC,OAAO,KAAK,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,MAAM,YAAY,CAAC;AAkDpB,qBAAa,WAAW;IACvB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAA2C;IAC3D,OAAO,KAAK,CAAC,GAGZ;gBAEW,MAAM,GAAE,MAAwB;IAkD5C;;;OAGG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,GAAG,IA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,EAAE,MAAM,CAAA;KAAE;IAqB9D;;;OAGG;IACH,0BAA0B,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAsBlF,qCAAqC;IACrC,KAAK,IAAI,IAAI;CAGb"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Sync authentication: request signing, verification, and nonce management.
3
+ *
4
+ * Uses Node's native Ed25519 crypto for sign/verify and SHA-256 canonical
5
+ * request hashing. No ssh-keygen shelling.
6
+ */
7
+ import type { Database } from "./db.js";
8
+ /**
9
+ * Signature version. v1 = SSHSIG format (ssh-keygen era), v2 = raw Ed25519.
10
+ *
11
+ * v2 is a breaking change: Python peers using `ssh-keygen -Y verify` cannot
12
+ * verify v2 signatures. Once all peers run the TS runtime, v1 support can
13
+ * be removed. During migration, the verifier accepts both versions.
14
+ */
15
+ export declare const SIGNATURE_VERSION = "v2";
16
+ export declare const DEFAULT_TIME_WINDOW_S = 300;
17
+ /**
18
+ * Build a canonical request buffer for signing/verification.
19
+ *
20
+ * SHA-256 hashes the body, then joins method/path/timestamp/nonce/bodyHash
21
+ * with newlines and returns the UTF-8 encoded result.
22
+ */
23
+ export declare function buildCanonicalRequest(method: string, pathWithQuery: string, timestamp: string, nonce: string, bodyBytes: Buffer): Buffer;
24
+ export interface SignRequestOptions {
25
+ method: string;
26
+ url: string;
27
+ bodyBytes: Buffer;
28
+ keysDir?: string;
29
+ timestamp?: string;
30
+ nonce?: string;
31
+ }
32
+ /**
33
+ * Sign an HTTP request and return the auth headers.
34
+ *
35
+ * Uses Node's native Ed25519 crypto.sign() — no ssh-keygen shelling.
36
+ * Returns X-Opencode-Timestamp, X-Opencode-Nonce, X-Opencode-Signature headers.
37
+ */
38
+ export declare function signRequest(options: SignRequestOptions): Record<string, string>;
39
+ export interface VerifySignatureOptions {
40
+ method: string;
41
+ pathWithQuery: string;
42
+ bodyBytes: Buffer;
43
+ timestamp: string;
44
+ nonce: string;
45
+ signature: string;
46
+ publicKey: string;
47
+ deviceId: string;
48
+ timeWindowS?: number;
49
+ }
50
+ /**
51
+ * Verify a signed request.
52
+ *
53
+ * Checks timestamp freshness, signature version prefix, then uses
54
+ * Node's native crypto.verify() with the sender's Ed25519 public key.
55
+ */
56
+ export declare function verifySignature(options: VerifySignatureOptions): boolean;
57
+ export interface BuildAuthHeadersOptions {
58
+ deviceId: string;
59
+ method: string;
60
+ url: string;
61
+ bodyBytes: Buffer;
62
+ keysDir?: string;
63
+ timestamp?: string;
64
+ nonce?: string;
65
+ }
66
+ /**
67
+ * Build full auth headers including device ID and request signature.
68
+ */
69
+ export declare function buildAuthHeaders(options: BuildAuthHeadersOptions): Record<string, string>;
70
+ /**
71
+ * Record a nonce to prevent replay attacks.
72
+ *
73
+ * Returns true on success, false if the nonce was already recorded
74
+ * (duplicate = potential replay).
75
+ */
76
+ export declare function recordNonce(db: Database, deviceId: string, nonce: string, createdAt: string): boolean;
77
+ /**
78
+ * Remove nonces older than the given cutoff timestamp.
79
+ */
80
+ export declare function cleanupNonces(db: Database, cutoff: string): void;
81
+ //# sourceMappingURL=sync-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-auth.d.ts","sourceRoot":"","sources":["../src/sync-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAQxC;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAMzC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GACf,MAAM,CAIR;AAMD,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,M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,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAGhE"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Sync daemon: periodic background sync with all configured peers.
3
+ *
4
+ * Uses AbortSignal for cancellation and setInterval for periodic ticks.
5
+ * Ported from codemem/sync/daemon.py — HTTP server portion is deferred
6
+ * to the viewer-server Hono routes.
7
+ */
8
+ import type { Database } from "./db.js";
9
+ export interface SyncDaemonOptions {
10
+ host?: string;
11
+ port?: number;
12
+ intervalS?: number;
13
+ dbPath?: string;
14
+ keysDir?: string;
15
+ signal?: AbortSignal;
16
+ }
17
+ export interface SyncTickResult {
18
+ ok: boolean;
19
+ skipped?: boolean;
20
+ reason?: string;
21
+ error?: string;
22
+ opsIn?: number;
23
+ opsOut?: number;
24
+ }
25
+ /**
26
+ * Record a successful daemon tick in sync_daemon_state.
27
+ */
28
+ export declare function setSyncDaemonOk(db: Database): void;
29
+ /**
30
+ * Record a daemon tick error in sync_daemon_state.
31
+ */
32
+ export declare function setSyncDaemonError(db: Database, error: string, traceback?: string): void;
33
+ /**
34
+ * Run one sync tick: iterate over all enabled peers and sync each.
35
+ *
36
+ * Returns per-peer results. Peers in backoff are skipped.
37
+ */
38
+ export declare function syncDaemonTick(db: Database, keysDir?: string): Promise<SyncTickResult[]>;
39
+ /**
40
+ * Run the sync daemon loop.
41
+ *
42
+ * 1. Ensures device identity
43
+ * 2. Starts mDNS advertising (if enabled)
44
+ * 3. Runs an initial sync tick
45
+ * 4. Sets up an interval timer for periodic sync
46
+ * 5. Waits for abort signal to stop
47
+ * 6. Cleans up on exit
48
+ */
49
+ export declare function runSyncDaemon(options?: SyncDaemonOptions): Promise<void>;
50
+ //# sourceMappingURL=sync-daemon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-daemon.d.ts","sourceRoot":"","sources":["../src/sync-daemon.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAWxC,MAAM,WAAW,iBAAiB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAUlD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAmBxF;AAMD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CA+B9F;AAMD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4D9E"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Peer discovery and address management for the codemem sync system.
3
+ *
4
+ * Handles address normalization, deduplication, peer address storage,
5
+ * and mDNS stubs. Ported from codemem/sync/discovery.py.
6
+ */
7
+ import type { Database } from "./db.js";
8
+ export { addressDedupeKey, mergeAddresses, normalizeAddress } from "./address-utils.js";
9
+ export declare const DEFAULT_SERVICE_TYPE = "_codemem._tcp.local.";
10
+ /**
11
+ * Select addresses to dial, preferring mDNS-discovered addresses.
12
+ *
13
+ * mDNS addresses come first, then stored addresses (deduplicated).
14
+ */
15
+ export declare function selectDialAddresses(options: {
16
+ stored: string[];
17
+ mdns: string[];
18
+ }): string[];
19
+ /**
20
+ * Load stored addresses for a peer from the sync_peers table.
21
+ */
22
+ export declare function loadPeerAddresses(db: Database, peerDeviceId: string): string[];
23
+ /**
24
+ * Update stored addresses for a peer, merging with existing.
25
+ *
26
+ * Creates the sync_peers row if it doesn't exist (upsert).
27
+ * Returns the merged address list.
28
+ */
29
+ export declare function updatePeerAddresses(db: Database, peerDeviceId: string, addresses: string[], options?: {
30
+ name?: string;
31
+ pinnedFingerprint?: string;
32
+ publicKey?: string;
33
+ }): string[];
34
+ /**
35
+ * Record a sync attempt in the sync_attempts table and update peer status.
36
+ */
37
+ export declare function recordSyncAttempt(db: Database, peerDeviceId: string, options: {
38
+ ok: boolean;
39
+ opsIn?: number;
40
+ opsOut?: number;
41
+ error?: string;
42
+ }): void;
43
+ /**
44
+ * Record a successful sync and promote the working address to the front.
45
+ *
46
+ * Returns the reordered address list.
47
+ */
48
+ export declare function recordPeerSuccess(db: Database, peerDeviceId: string, address: string | null): string[];
49
+ /**
50
+ * Set per-peer project include/exclude filters.
51
+ *
52
+ * Pass null for both to clear the override (inherit global config).
53
+ */
54
+ export declare function setPeerProjectFilter(db: Database, peerDeviceId: string, options: {
55
+ include: string[] | null;
56
+ exclude: string[] | null;
57
+ }): void;
58
+ /**
59
+ * Set the claimed_local_actor flag for a peer.
60
+ */
61
+ export declare function setPeerLocalActorClaim(db: Database, peerDeviceId: string, claimed: boolean): void;
62
+ export interface MdnsEntry {
63
+ name?: string;
64
+ host?: string;
65
+ port?: number;
66
+ address?: Uint8Array | string;
67
+ properties?: Record<string, string | Uint8Array>;
68
+ }
69
+ /**
70
+ * Check if mDNS discovery is enabled via the CODEMEM_SYNC_MDNS env var.
71
+ */
72
+ export declare function mdnsEnabled(): boolean;
73
+ /**
74
+ * Advertise this device via mDNS.
75
+ *
76
+ * Phase 1 stub: logs the intent and returns a no-op closer.
77
+ * Real implementation will use dns-sd (macOS) or bonjour-service (Linux).
78
+ */
79
+ export declare function advertiseMdns(_deviceId: string, _port: number): {
80
+ close(): void;
81
+ };
82
+ /**
83
+ * Discover peers via mDNS.
84
+ *
85
+ * Phase 1 stub: returns an empty array.
86
+ * Real implementation will use dns-sd (macOS) or bonjour-service (Linux).
87
+ */
88
+ export declare function discoverPeersViaMdns(): MdnsEntry[];
89
+ /**
90
+ * Extract addresses for a specific peer from mDNS discovery entries.
91
+ */
92
+ export declare function mdnsAddressesForPeer(peerDeviceId: string, entries: MdnsEntry[]): string[];
93
+ //# sourceMappingURL=sync-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-discovery.d.ts","sourceRoot":"","sources":["../src/sync-discovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMxF,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAM3D;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,MAAM,EAAE,CAK3F;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAe9E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,EAAE,EAAE,QAAQ,EACZ,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,CAAC,EAAE;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC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AAA;CAAE,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,EAAE,CAElD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CA2BzF"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Sync HTTP client: JSON request helper using Node.js built-in fetch.
3
+ *
4
+ * Async counterpart to the synchronous Python http.client implementation.
5
+ * Ported from codemem/sync/http_client.py.
6
+ */
7
+ /**
8
+ * Normalize a peer address into a base URL.
9
+ *
10
+ * Adds `http://` when no scheme is present, trims whitespace and trailing slashes.
11
+ */
12
+ export declare function buildBaseUrl(address: string): string;
13
+ export interface RequestJsonOptions {
14
+ headers?: Record<string, string>;
15
+ body?: Record<string, unknown>;
16
+ bodyBytes?: Uint8Array;
17
+ timeoutS?: number;
18
+ }
19
+ /**
20
+ * Send an HTTP request and parse the JSON response.
21
+ *
22
+ * Returns `[statusCode, parsedBody]`. The body is null when the response
23
+ * has no content. Non-JSON responses are returned as `{ error: "non_json_response: ..." }`.
24
+ */
25
+ export declare function requestJson(method: string, url: string, options?: RequestJsonOptions): Promise<[status: number, body: Record<string, unknown> | null]>;
26
+ //# sourceMappingURL=sync-http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-http-client.d.ts","sourceRoot":"","sources":["../src/sync-http-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMpD;AAMD,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAChC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,kBAAuB,GAC9B,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CA+CjE"}