@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.
- package/LICENSE +21 -0
- package/dist/address-utils.d.ts +24 -0
- package/dist/address-utils.d.ts.map +1 -0
- package/dist/api-types.d.ts +580 -0
- package/dist/api-types.d.ts.map +1 -0
- package/dist/claude-hooks.d.ts +62 -0
- package/dist/claude-hooks.d.ts.map +1 -0
- package/dist/coordinator-api.d.ts +11 -0
- package/dist/coordinator-api.d.ts.map +1 -0
- package/dist/coordinator-invites.d.ts +28 -0
- package/dist/coordinator-invites.d.ts.map +1 -0
- package/dist/coordinator-store.d.ts +67 -0
- package/dist/coordinator-store.d.ts.map +1 -0
- package/dist/db.d.ts +97 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/embeddings.d.ts +39 -0
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/export-import.d.ts +48 -0
- package/dist/export-import.d.ts.map +1 -0
- package/dist/filters.d.ts +34 -0
- package/dist/filters.d.ts.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7287 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest-events.d.ts +34 -0
- package/dist/ingest-events.d.ts.map +1 -0
- package/dist/ingest-filters.d.ts +16 -0
- package/dist/ingest-filters.d.ts.map +1 -0
- package/dist/ingest-pipeline.d.ts +56 -0
- package/dist/ingest-pipeline.d.ts.map +1 -0
- package/dist/ingest-prompts.d.ts +22 -0
- package/dist/ingest-prompts.d.ts.map +1 -0
- package/dist/ingest-sanitize.d.ts +18 -0
- package/dist/ingest-sanitize.d.ts.map +1 -0
- package/dist/ingest-transcript.d.ts +41 -0
- package/dist/ingest-transcript.d.ts.map +1 -0
- package/dist/ingest-types.d.ts +70 -0
- package/dist/ingest-types.d.ts.map +1 -0
- package/dist/ingest-xml-parser.d.ts +20 -0
- package/dist/ingest-xml-parser.d.ts.map +1 -0
- package/dist/integers.d.ts +13 -0
- package/dist/integers.d.ts.map +1 -0
- package/dist/maintenance.d.ts +71 -0
- package/dist/maintenance.d.ts.map +1 -0
- package/dist/observer-auth.d.ts +65 -0
- package/dist/observer-auth.d.ts.map +1 -0
- package/dist/observer-client.d.ts +104 -0
- package/dist/observer-client.d.ts.map +1 -0
- package/dist/observer-config.d.ts +57 -0
- package/dist/observer-config.d.ts.map +1 -0
- package/dist/pack.d.ts +36 -0
- package/dist/pack.d.ts.map +1 -0
- package/dist/project.d.ts +12 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/raw-event-flush.d.ts +43 -0
- package/dist/raw-event-flush.d.ts.map +1 -0
- package/dist/raw-event-sweeper.d.ts +92 -0
- package/dist/raw-event-sweeper.d.ts.map +1 -0
- package/dist/schema.d.ts +7368 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/search.d.ts +76 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/store.d.ts +274 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/sync-auth.d.ts +81 -0
- package/dist/sync-auth.d.ts.map +1 -0
- package/dist/sync-daemon.d.ts +50 -0
- package/dist/sync-daemon.d.ts.map +1 -0
- package/dist/sync-discovery.d.ts +93 -0
- package/dist/sync-discovery.d.ts.map +1 -0
- package/dist/sync-http-client.d.ts +26 -0
- package/dist/sync-http-client.d.ts.map +1 -0
- package/dist/sync-identity.d.ts +38 -0
- package/dist/sync-identity.d.ts.map +1 -0
- package/dist/sync-pass.d.ts +63 -0
- package/dist/sync-pass.d.ts.map +1 -0
- package/dist/sync-replication.d.ts +99 -0
- package/dist/sync-replication.d.ts.map +1 -0
- package/dist/test-utils.d.ts +27 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/types.d.ts +414 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vectors.d.ts +59 -0
- package/dist/vectors.d.ts.map +1 -0
- package/package.json +41 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude hook payload mapping.
|
|
3
|
+
*
|
|
4
|
+
* Ports codemem/claude_hooks.py — normalizes raw Claude Code hook payloads
|
|
5
|
+
* (PreToolUse, PostToolUse, Stop, etc.) into raw event envelopes suitable
|
|
6
|
+
* for the raw event sweeper pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Entry points:
|
|
9
|
+
* mapClaudeHookPayload(payload) → adapter event or null
|
|
10
|
+
* buildRawEventEnvelopeFromHook(payload) → raw event envelope or null
|
|
11
|
+
* buildIngestPayloadFromHook(payload) → ingest payload or null
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAPPABLE_CLAUDE_HOOK_EVENTS: Set<string>;
|
|
14
|
+
/** Normalize a raw label value to a plain project name (basename if path). */
|
|
15
|
+
export declare function normalizeProjectLabel(value: unknown): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the project for a hook payload.
|
|
18
|
+
* Priority: CODEMEM_PROJECT env → cwd git root → payload project label.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveHookProject(cwd: string | null, payloadProject: unknown): string | null;
|
|
21
|
+
export interface ClaudeHookAdapterEvent {
|
|
22
|
+
schema_version: "1.0";
|
|
23
|
+
source: "claude";
|
|
24
|
+
session_id: string;
|
|
25
|
+
event_id: string;
|
|
26
|
+
event_type: string;
|
|
27
|
+
ts: string;
|
|
28
|
+
ordering_confidence: "low";
|
|
29
|
+
cwd: string | null;
|
|
30
|
+
payload: Record<string, unknown>;
|
|
31
|
+
meta: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Map a raw Claude Code hook payload to a normalized adapter event.
|
|
35
|
+
* Returns null if the event type is unsupported or required fields are missing.
|
|
36
|
+
*/
|
|
37
|
+
export declare function mapClaudeHookPayload(payload: Record<string, unknown>): ClaudeHookAdapterEvent | null;
|
|
38
|
+
export interface ClaudeHookRawEventEnvelope {
|
|
39
|
+
session_stream_id: string;
|
|
40
|
+
session_id: string;
|
|
41
|
+
opencode_session_id: string;
|
|
42
|
+
source: string;
|
|
43
|
+
event_id: string;
|
|
44
|
+
event_type: "claude.hook";
|
|
45
|
+
payload: Record<string, unknown>;
|
|
46
|
+
ts_wall_ms: number;
|
|
47
|
+
cwd: string | null;
|
|
48
|
+
project: string | null;
|
|
49
|
+
started_at: string | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build a raw event envelope from a Claude Code hook payload.
|
|
53
|
+
* Returns null if the payload is unsupported or missing required fields.
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildRawEventEnvelopeFromHook(hookPayload: Record<string, unknown>): ClaudeHookRawEventEnvelope | null;
|
|
56
|
+
/**
|
|
57
|
+
* Build an ingest pipeline payload from a Claude Code hook payload.
|
|
58
|
+
* Used by the direct-ingest path (non-raw-event path).
|
|
59
|
+
* Returns null if the payload is unsupported.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildIngestPayloadFromHook(hookPayload: Record<string, unknown>): Record<string, unknown> | null;
|
|
62
|
+
//# sourceMappingURL=claude-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-hooks.d.ts","sourceRoot":"","sources":["../src/claude-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoBH,eAAO,MAAM,2BAA2B,aAQtC,CAAC;AA4EH,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAiBnE;AA2ED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAa7F;AAuLD,MAAM,WAAW,sBAAsB;IACtC,cAAc,EAAE,KAAK,CAAC;IACtB,MAAM,EAAE,QAAQ,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,EAAE,KAAK,CAAC;IAC3B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,sBAAsB,GAAG,IAAI,CAuL/B;AAgBD,MAAM,WAAW,0BAA0B;IAC1C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC5C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,0BAA0B,GAAG,IAAI,CAoCnC;AAMD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAsBhC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinator API — Hono-based HTTP server for the coordinator relay.
|
|
3
|
+
*
|
|
4
|
+
* Manages device enrollment, presence, invites, and join requests.
|
|
5
|
+
* Ported from codemem/coordinator_api.py.
|
|
6
|
+
*/
|
|
7
|
+
import { Hono } from "hono";
|
|
8
|
+
export declare function createCoordinatorApp(opts?: {
|
|
9
|
+
dbPath?: string;
|
|
10
|
+
}): InstanceType<typeof Hono>;
|
|
11
|
+
//# sourceMappingURL=coordinator-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator-api.d.ts","sourceRoot":"","sources":["../src/coordinator-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAyH5B,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAAC,OAAO,IAAI,CAAC,CAyf1F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invite link encoding/decoding for the coordinator join flow.
|
|
3
|
+
*
|
|
4
|
+
* Ported from codemem/coordinator_invites.py.
|
|
5
|
+
*/
|
|
6
|
+
export interface InvitePayload {
|
|
7
|
+
v: number;
|
|
8
|
+
kind: string;
|
|
9
|
+
coordinator_url: string;
|
|
10
|
+
group_id: string;
|
|
11
|
+
policy: string;
|
|
12
|
+
token: string;
|
|
13
|
+
expires_at: string;
|
|
14
|
+
team_name: string | null;
|
|
15
|
+
}
|
|
16
|
+
/** Encode an invite payload as a compact base64url string (no padding). */
|
|
17
|
+
export declare function encodeInvitePayload(payload: InvitePayload): string;
|
|
18
|
+
/** Decode a base64url invite payload string back to an InvitePayload. */
|
|
19
|
+
export declare function decodeInvitePayload(value: string): InvitePayload;
|
|
20
|
+
/** Build a `codemem://join?invite=...` link from an encoded payload. */
|
|
21
|
+
export declare function inviteLink(encodedPayload: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Extract the raw encoded payload from either a `codemem://` link or a raw value.
|
|
24
|
+
*
|
|
25
|
+
* Throws if a `codemem://` link is provided but has no `invite` query parameter.
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractInvitePayload(value: string): string;
|
|
28
|
+
//# sourceMappingURL=coordinator-invites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator-invites.d.ts","sourceRoot":"","sources":["../src/coordinator-invites.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,aAAa;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAMlE;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAShE;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW1D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoordinatorStore — SQLite-backed state for the coordinator relay server.
|
|
3
|
+
*
|
|
4
|
+
* The coordinator is a cloud relay that manages group membership, device
|
|
5
|
+
* enrollment, presence, invites, and join requests for sync between devices.
|
|
6
|
+
*
|
|
7
|
+
* This store uses its OWN database (separate from the main codemem DB) and
|
|
8
|
+
* owns its own schema — the TS side creates tables directly.
|
|
9
|
+
*
|
|
10
|
+
* Ported from codemem/coordinator_store.py.
|
|
11
|
+
*/
|
|
12
|
+
import type { Database as DatabaseType } from "better-sqlite3";
|
|
13
|
+
export declare const DEFAULT_COORDINATOR_DB_PATH: string;
|
|
14
|
+
export declare function connectCoordinator(path?: string): DatabaseType;
|
|
15
|
+
export declare class CoordinatorStore {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly db: DatabaseType;
|
|
18
|
+
constructor(path?: string);
|
|
19
|
+
close(): void;
|
|
20
|
+
createGroup(groupId: string, displayName?: string | null): void;
|
|
21
|
+
getGroup(groupId: string): Record<string, unknown> | null;
|
|
22
|
+
listGroups(): Record<string, unknown>[];
|
|
23
|
+
enrollDevice(groupId: string, opts: {
|
|
24
|
+
deviceId: string;
|
|
25
|
+
fingerprint: string;
|
|
26
|
+
publicKey: string;
|
|
27
|
+
displayName?: string | null;
|
|
28
|
+
}): void;
|
|
29
|
+
listEnrolledDevices(groupId: string, includeDisabled?: boolean): Record<string, unknown>[];
|
|
30
|
+
getEnrollment(groupId: string, deviceId: string): Record<string, unknown> | null;
|
|
31
|
+
renameDevice(groupId: string, deviceId: string, displayName: string): boolean;
|
|
32
|
+
setDeviceEnabled(groupId: string, deviceId: string, enabled: boolean): boolean;
|
|
33
|
+
removeDevice(groupId: string, deviceId: string): boolean;
|
|
34
|
+
createInvite(opts: {
|
|
35
|
+
groupId: string;
|
|
36
|
+
policy: string;
|
|
37
|
+
expiresAt: string;
|
|
38
|
+
createdBy?: string | null;
|
|
39
|
+
}): Record<string, unknown>;
|
|
40
|
+
getInviteByToken(token: string): Record<string, unknown> | null;
|
|
41
|
+
listInvites(groupId: string): Record<string, unknown>[];
|
|
42
|
+
createJoinRequest(opts: {
|
|
43
|
+
groupId: string;
|
|
44
|
+
deviceId: string;
|
|
45
|
+
publicKey: string;
|
|
46
|
+
fingerprint: string;
|
|
47
|
+
displayName?: string | null;
|
|
48
|
+
token: string;
|
|
49
|
+
}): Record<string, unknown>;
|
|
50
|
+
listJoinRequests(groupId: string, status?: string): Record<string, unknown>[];
|
|
51
|
+
reviewJoinRequest(opts: {
|
|
52
|
+
requestId: string;
|
|
53
|
+
approved: boolean;
|
|
54
|
+
reviewedBy?: string | null;
|
|
55
|
+
}): (Record<string, unknown> & {
|
|
56
|
+
_no_transition?: boolean;
|
|
57
|
+
}) | null;
|
|
58
|
+
upsertPresence(opts: {
|
|
59
|
+
groupId: string;
|
|
60
|
+
deviceId: string;
|
|
61
|
+
addresses: string[];
|
|
62
|
+
ttlS: number;
|
|
63
|
+
capabilities?: Record<string, unknown> | null;
|
|
64
|
+
}): Record<string, unknown>;
|
|
65
|
+
listGroupPeers(groupId: string, requestingDeviceId: string): Record<string, unknown>[];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=coordinator-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator-store.d.ts","sourceRoot":"","sources":["../src/coordinator-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG/D,eAAO,MAAM,2BAA2B,QAAoD,CAAC;AAoJ7F,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,CAU9D;AAMD,qBAAa,gBAAgB;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;gBAEd,IAAI,CAAC,EAAE,MAAM;IAKzB,KAAK,IAAI,IAAI;IAMb,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM/D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAOzD,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IASvC,YAAY,CACX,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,SAA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,CAAC,MAAM,EAAE,OAAO,CAAC;IA8B3B,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAYhF,iBAAiB,CAAC,IAAI,EAAE;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI;IAgDnE,cAAc,CAAC,IAAI,EAAE;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;KAC9C,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgC3B,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;CA0CtF"}
|
package/dist/db.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database connection and schema initialization for the codemem TS backend.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors codemem/db.py — same pragmas, same WAL mode, same sqlite-vec loading.
|
|
5
|
+
* During Phase 1 of the migration, Python owns DDL (schema migrations).
|
|
6
|
+
* The TS runtime validates the schema version but does NOT run migrations.
|
|
7
|
+
*/
|
|
8
|
+
import type { Database as DatabaseType } from "better-sqlite3";
|
|
9
|
+
export type { DatabaseType as Database };
|
|
10
|
+
/** Current schema version this TS runtime was built against. */
|
|
11
|
+
export declare const SCHEMA_VERSION = 6;
|
|
12
|
+
/**
|
|
13
|
+
* Minimum schema version the TS runtime can operate with.
|
|
14
|
+
* Per the coexistence contract (docs/plans/2026-03-15-db-coexistence-contract.md),
|
|
15
|
+
* TS must tolerate additive newer schemas. It only hard-fails if the schema is
|
|
16
|
+
* too old to have the tables/columns it needs.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MIN_COMPATIBLE_SCHEMA = 6;
|
|
19
|
+
/** Default database path — matches Python's DEFAULT_DB_PATH. */
|
|
20
|
+
export declare const DEFAULT_DB_PATH: string;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the database path from explicit arg → CODEMEM_DB env → default.
|
|
23
|
+
* All TS entry points should use this instead of hardcoding fallback logic.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveDbPath(explicit?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Migrate legacy database paths to the current default location.
|
|
28
|
+
*
|
|
29
|
+
* Only runs when dbPath is the DEFAULT_DB_PATH and doesn't already exist.
|
|
30
|
+
* Matches Python's migrate_legacy_default_db in db.py.
|
|
31
|
+
*/
|
|
32
|
+
export declare function migrateLegacyDbPath(dbPath: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Open a better-sqlite3 connection with the standard codemem pragmas.
|
|
35
|
+
*
|
|
36
|
+
* Migrates legacy DB paths if needed, creates parent directories,
|
|
37
|
+
* sets WAL mode, busy timeout, foreign keys.
|
|
38
|
+
* Does NOT initialize or migrate the schema — during Phase 1, Python owns DDL.
|
|
39
|
+
*/
|
|
40
|
+
export declare function connect(dbPath?: string): DatabaseType;
|
|
41
|
+
/**
|
|
42
|
+
* Load the sqlite-vec extension into an open database connection.
|
|
43
|
+
*
|
|
44
|
+
* Call this after connect() when vector operations are needed.
|
|
45
|
+
* Skipped when CODEMEM_EMBEDDING_DISABLED=1.
|
|
46
|
+
*/
|
|
47
|
+
export declare function loadSqliteVec(db: DatabaseType): void;
|
|
48
|
+
/** Check if embeddings are disabled via environment variable. */
|
|
49
|
+
export declare function isEmbeddingDisabled(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Read the schema user_version from the database.
|
|
52
|
+
*
|
|
53
|
+
* During Phase 1, the TS runtime uses this to verify the schema is initialized
|
|
54
|
+
* (by Python) before operating. It does NOT set or bump the version.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getSchemaVersion(db: DatabaseType): number;
|
|
57
|
+
/**
|
|
58
|
+
* Create a timestamped backup of the database on first TS access.
|
|
59
|
+
*
|
|
60
|
+
* The backup file is named `mem.sqlite.pre-ts-YYYYMMDDTHHMMSS.bak` and placed
|
|
61
|
+
* next to the original. A marker file prevents repeated backups. This ensures
|
|
62
|
+
* users can recover if the TS runtime introduces bugs that corrupt the DB
|
|
63
|
+
* during the migration period.
|
|
64
|
+
*/
|
|
65
|
+
export declare function backupOnFirstAccess(dbPath: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Verify the database schema is initialized and compatible.
|
|
68
|
+
*
|
|
69
|
+
* Per the coexistence contract: TS tolerates additive newer schemas (Python may
|
|
70
|
+
* have run migrations that add tables/columns the TS runtime doesn't know about).
|
|
71
|
+
* TS only hard-fails if:
|
|
72
|
+
* - Schema is uninitialized (version 0)
|
|
73
|
+
* - Schema is too old (below MIN_COMPATIBLE_SCHEMA)
|
|
74
|
+
* - Required tables are missing
|
|
75
|
+
* - FTS5 index is missing (needed for search)
|
|
76
|
+
*
|
|
77
|
+
* Warns (but continues) if schema is newer than SCHEMA_VERSION — the additive
|
|
78
|
+
* changes are assumed safe per the coexistence contract.
|
|
79
|
+
*/
|
|
80
|
+
export declare function assertSchemaReady(db: DatabaseType): void;
|
|
81
|
+
/** Check if a table exists in the database. */
|
|
82
|
+
export declare function tableExists(db: DatabaseType, table: string): boolean;
|
|
83
|
+
/** Safely parse a JSON string, returning {} on failure. */
|
|
84
|
+
export declare function fromJson(text: string | null | undefined): Record<string, unknown>;
|
|
85
|
+
/** Serialize a value to JSON, defaulting null/undefined to "{}". */
|
|
86
|
+
export declare function toJson(data: unknown): string;
|
|
87
|
+
/**
|
|
88
|
+
* Serialize a value to JSON, preserving null as SQL NULL.
|
|
89
|
+
*
|
|
90
|
+
* Use this for columns that store JSON arrays (facts, concepts, files_read,
|
|
91
|
+
* files_modified) where NULL means "no data" and "{}" would be corruption.
|
|
92
|
+
* Also normalizes empty objects ({}) to null — Python's from_json returns {}
|
|
93
|
+
* for empty DB values, so imported exports carry {} instead of null.
|
|
94
|
+
* Use `toJson` for metadata_json where "{}" is the correct empty default.
|
|
95
|
+
*/
|
|
96
|
+
export declare function toJsonNullable(data: unknown): string | null;
|
|
97
|
+
//# sourceMappingURL=db.d.ts.map
|
package/dist/db.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM/D,YAAY,EAAE,YAAY,IAAI,QAAQ,EAAE,CAAC;AAEzC,gEAAgE;AAChE,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAevC,gEAAgE;AAChE,eAAO,MAAM,eAAe,QAA4C,CAAC;AAEzE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvD;AA2CD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CASxD;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,MAAM,GAAE,MAAwB,GAAG,YAAY,CAmBtE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAWpD;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,IAAI,OAAO,CAG7C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,MAAM,CAGzD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiDxD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAqCxD;AAED,+CAA+C;AAC/C,wBAAgB,WAAW,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAKpE;AAED,2DAA2D;AAC3D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYjF;AAED,oEAAoE;AACpE,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAG5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAW3D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding primitives for semantic search.
|
|
3
|
+
*
|
|
4
|
+
* Ports codemem/semantic.py — text chunking, hashing, and embedding via a
|
|
5
|
+
* pluggable client interface. The default client uses `@xenova/transformers`
|
|
6
|
+
* (same BAAI/bge-small-en-v1.5 model as Python's fastembed). When the
|
|
7
|
+
* embedding runtime is unavailable the helpers return empty arrays and callers
|
|
8
|
+
* fall back to FTS-only retrieval.
|
|
9
|
+
*
|
|
10
|
+
* Embeddings are always disabled when CODEMEM_EMBEDDING_DISABLED=1.
|
|
11
|
+
*/
|
|
12
|
+
/** Minimal interface a concrete embedding backend must satisfy. */
|
|
13
|
+
export interface EmbeddingClient {
|
|
14
|
+
readonly model: string;
|
|
15
|
+
readonly dimensions: number;
|
|
16
|
+
embed(texts: string[]): Promise<Float32Array[]>;
|
|
17
|
+
}
|
|
18
|
+
/** SHA-256 hex digest of UTF-8 encoded text. */
|
|
19
|
+
export declare function hashText(text: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Split long text into ≤ `maxChars` chunks, preferring paragraph then
|
|
22
|
+
* sentence boundaries. Matches Python's `chunk_text()`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function chunkText(text: string, maxChars?: number): string[];
|
|
25
|
+
/** Reset the singleton (for tests). */
|
|
26
|
+
export declare function _resetEmbeddingClient(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get the shared embedding client, creating it lazily on first call.
|
|
29
|
+
* Returns null when embeddings are disabled or the runtime is unavailable.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getEmbeddingClient(): Promise<EmbeddingClient | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Embed texts using the shared client.
|
|
34
|
+
* Returns an empty array when embeddings are unavailable.
|
|
35
|
+
*/
|
|
36
|
+
export declare function embedTexts(texts: string[]): Promise<Float32Array[]>;
|
|
37
|
+
/** Serialize a Float32Array to a little-endian Buffer for sqlite-vec. */
|
|
38
|
+
export declare function serializeFloat32(vector: Float32Array): Buffer;
|
|
39
|
+
//# sourceMappingURL=embeddings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../src/embeddings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;CAChD;AAMD,gDAAgD;AAChD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAO,GAAG,MAAM,EAAE,CA8DjE;AAQD,uCAAuC;AACvC,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAa1E;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAIzE;AAoCD,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAM7D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
type JsonObject = Record<string, unknown>;
|
|
2
|
+
export interface ExportOptions {
|
|
3
|
+
dbPath?: string;
|
|
4
|
+
project?: string | null;
|
|
5
|
+
allProjects?: boolean;
|
|
6
|
+
includeInactive?: boolean;
|
|
7
|
+
since?: string | null;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ImportOptions {
|
|
11
|
+
dbPath?: string;
|
|
12
|
+
remapProject?: string | null;
|
|
13
|
+
dryRun?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ExportPayload {
|
|
16
|
+
version: "1.0";
|
|
17
|
+
exported_at: string;
|
|
18
|
+
export_metadata: {
|
|
19
|
+
tool_version: "codemem";
|
|
20
|
+
projects: string[];
|
|
21
|
+
total_memories: number;
|
|
22
|
+
total_sessions: number;
|
|
23
|
+
include_inactive: boolean;
|
|
24
|
+
filters: JsonObject;
|
|
25
|
+
};
|
|
26
|
+
sessions: JsonObject[];
|
|
27
|
+
memory_items: JsonObject[];
|
|
28
|
+
session_summaries: JsonObject[];
|
|
29
|
+
user_prompts: JsonObject[];
|
|
30
|
+
}
|
|
31
|
+
export interface ImportResult {
|
|
32
|
+
sessions: number;
|
|
33
|
+
user_prompts: number;
|
|
34
|
+
memory_items: number;
|
|
35
|
+
session_summaries: number;
|
|
36
|
+
dryRun: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function buildImportKey(source: string, recordType: string, originalId: unknown, parts?: {
|
|
39
|
+
project?: string | null;
|
|
40
|
+
createdAt?: string | null;
|
|
41
|
+
sourceDb?: string | null;
|
|
42
|
+
}): string;
|
|
43
|
+
export declare function mergeSummaryMetadata(metadata: JsonObject, importMetadata: unknown): JsonObject;
|
|
44
|
+
export declare function exportMemories(opts?: ExportOptions): ExportPayload;
|
|
45
|
+
export declare function readImportPayload(inputFile: string): ExportPayload;
|
|
46
|
+
export declare function importMemories(payload: ExportPayload, opts?: ImportOptions): ImportResult;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=export-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-import.d.ts","sourceRoot":"","sources":["../src/export-import.ts"],"names":[],"mappings":"AAeA,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,MAAM,WAAW,aAAa;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE;QAChB,YAAY,EAAE,SAAS,CAAC;QACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,OAAO,EAAE,UAAU,CAAC;KACpB,CAAC;IACF,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,iBAAiB,EAAE,UAAU,EAAE,CAAC;IAChC,YAAY,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;CAChB;AA2DD,wBAAgB,cAAc,CAC7B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,OAAO,EACnB,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACtF,MAAM,CAMR;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,GAAG,UAAU,CAuB9F;AAqDD,wBAAgB,cAAc,CAAC,IAAI,GAAE,aAAkB,GAAG,aAAa,CAsEtE;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAclE;AAgID,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,GAAE,aAAkB,GAAG,YAAY,CAgM7F"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter builder for memory_items queries.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors Python's _extend_memory_filter_clauses in codemem/store/search.py.
|
|
5
|
+
* Builds WHERE clause fragments and parameter arrays from a MemoryFilters object.
|
|
6
|
+
*/
|
|
7
|
+
import type { MemoryFilters } from "./types.js";
|
|
8
|
+
export interface OwnershipFilterContext {
|
|
9
|
+
actorId: string;
|
|
10
|
+
deviceId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface FilterResult {
|
|
13
|
+
clauses: string[];
|
|
14
|
+
params: unknown[];
|
|
15
|
+
joinSessions: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Normalize a filter value that may be a single string or an array of strings
|
|
19
|
+
* into a clean, non-empty array of trimmed strings.
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeFilterStrings(value: string | string[] | undefined | null): string[];
|
|
22
|
+
export declare function normalizeWorkspaceKinds(value: string | string[] | undefined | null): string[];
|
|
23
|
+
export declare function normalizeVisibilityValues(value: string | string[] | undefined | null): string[];
|
|
24
|
+
export declare function normalizeTrustStates(value: string | string[] | undefined | null): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Build WHERE clause fragments from a MemoryFilters object.
|
|
27
|
+
*
|
|
28
|
+
* Returns clauses, params, and whether the sessions table must be joined.
|
|
29
|
+
* The caller is responsible for prepending `memory_items.active = 1` or
|
|
30
|
+
* similar base conditions — this function only appends filter-specific clauses.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildFilterClauses(filters: MemoryFilters | undefined | null): FilterResult;
|
|
33
|
+
export declare function buildFilterClausesWithContext(filters: MemoryFilters | undefined | null, ownership?: OwnershipFilterContext): FilterResult;
|
|
34
|
+
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../src/filters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CAY5F;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CAM7F;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CAI/F;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CAQ1F;AAyBD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,GAAG,YAAY,CAE1F;AAED,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,EACzC,SAAS,CAAC,EAAE,sBAAsB,GAChC,YAAY,CAyFd"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @codemem/core — store, embeddings, and shared types.
|
|
3
|
+
*
|
|
4
|
+
* This package owns the SQLite store, embedding worker interface,
|
|
5
|
+
* and type definitions shared across the codemem TS backend.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VERSION = "0.20.0-alpha.2";
|
|
8
|
+
export * as Api from "./api-types.js";
|
|
9
|
+
export type { ClaudeHookAdapterEvent, ClaudeHookRawEventEnvelope } from "./claude-hooks.js";
|
|
10
|
+
export { buildIngestPayloadFromHook, buildRawEventEnvelopeFromHook, MAPPABLE_CLAUDE_HOOK_EVENTS, mapClaudeHookPayload, normalizeProjectLabel, resolveHookProject, } from "./claude-hooks.js";
|
|
11
|
+
export { createCoordinatorApp } from "./coordinator-api.js";
|
|
12
|
+
export type { InvitePayload } from "./coordinator-invites.js";
|
|
13
|
+
export { decodeInvitePayload, encodeInvitePayload, extractInvitePayload, inviteLink, } from "./coordinator-invites.js";
|
|
14
|
+
export { CoordinatorStore, connectCoordinator, DEFAULT_COORDINATOR_DB_PATH, } from "./coordinator-store.js";
|
|
15
|
+
export type { Database } from "./db.js";
|
|
16
|
+
export { assertSchemaReady, backupOnFirstAccess, connect, DEFAULT_DB_PATH, fromJson, getSchemaVersion, isEmbeddingDisabled, loadSqliteVec, MIN_COMPATIBLE_SCHEMA, migrateLegacyDbPath, resolveDbPath, SCHEMA_VERSION, tableExists, toJson, toJsonNullable, } from "./db.js";
|
|
17
|
+
export type { EmbeddingClient } from "./embeddings.js";
|
|
18
|
+
export { _resetEmbeddingClient, chunkText, embedTexts, getEmbeddingClient, hashText, serializeFloat32, } from "./embeddings.js";
|
|
19
|
+
export type { ExportOptions, ExportPayload, ImportOptions, ImportResult } from "./export-import.js";
|
|
20
|
+
export { buildImportKey, exportMemories, importMemories, mergeSummaryMetadata, readImportPayload, } from "./export-import.js";
|
|
21
|
+
export { buildFilterClauses } from "./filters.js";
|
|
22
|
+
export { budgetToolEvents, eventToToolEvent, extractAdapterEvent, extractToolEvents, isInternalMemoryTool, LOW_SIGNAL_TOOLS, normalizeToolName, projectAdapterToolEvent, } from "./ingest-events.js";
|
|
23
|
+
export { isLowSignalObservation, normalizeObservation } from "./ingest-filters.js";
|
|
24
|
+
export type { IngestOptions } from "./ingest-pipeline.js";
|
|
25
|
+
export { cleanOrphanSessions, ingest, main as ingestMain } from "./ingest-pipeline.js";
|
|
26
|
+
export { buildObserverPrompt } from "./ingest-prompts.js";
|
|
27
|
+
export { isSensitiveFieldName, sanitizePayload, sanitizeToolOutput, stripPrivate, stripPrivateObj, } from "./ingest-sanitize.js";
|
|
28
|
+
export { buildTranscript, deriveRequest, extractAssistantMessages, extractAssistantUsage, extractPrompts, firstSentence, isTrivialRequest, normalizeAdapterEvents, normalizeRequestText, TRIVIAL_REQUESTS, } from "./ingest-transcript.js";
|
|
29
|
+
export type { IngestPayload, ObserverContext, ParsedObservation, ParsedOutput, ParsedSummary, SessionContext, ToolEvent, } from "./ingest-types.js";
|
|
30
|
+
export { hasMeaningfulObservation, parseObserverResponse } from "./ingest-xml-parser.js";
|
|
31
|
+
export { parsePositiveMemoryId, parseStrictInteger } from "./integers.js";
|
|
32
|
+
export type { GateResult, RawEventStatusItem, RawEventStatusResult, ReliabilityMetrics, } from "./maintenance.js";
|
|
33
|
+
export { getRawEventStatus, getReliabilityMetrics, initDatabase, rawEventsGate, retryRawEventFailures, vacuumDatabase, } from "./maintenance.js";
|
|
34
|
+
export type { ObserverAuthMaterial } from "./observer-auth.js";
|
|
35
|
+
export { buildCodexHeaders, extractOAuthAccess, extractOAuthAccountId, extractOAuthExpires, loadOpenCodeOAuthCache, ObserverAuthAdapter, readAuthFile, redactText, renderObserverHeaders, resolveOAuthProvider, runAuthCommand, } from "./observer-auth.js";
|
|
36
|
+
export type { ObserverConfig, ObserverResponse, ObserverStatus } from "./observer-client.js";
|
|
37
|
+
export { loadObserverConfig, ObserverAuthError, ObserverClient } from "./observer-client.js";
|
|
38
|
+
export { CODEMEM_CONFIG_ENV_OVERRIDES, getCodememConfigPath, getCodememEnvOverrides, getOpenCodeProviderConfig, getProviderApiKey, getProviderBaseUrl, getProviderHeaders, getProviderOptions, listCustomProviders, loadOpenCodeConfig, readCodememConfigFile, resolveCustomProviderDefaultModel, resolveCustomProviderFromModel, resolveCustomProviderModel, resolvePlaceholder, stripJsonComments, stripTrailingCommas, writeCodememConfigFile, } from "./observer-config.js";
|
|
39
|
+
export { buildMemoryPack, buildMemoryPackAsync, estimateTokens } from "./pack.js";
|
|
40
|
+
export { projectBasename, projectClause, projectColumnClause, projectMatchesFilter, resolveProject, } from "./project.js";
|
|
41
|
+
export type { FlushRawEventsOptions } from "./raw-event-flush.js";
|
|
42
|
+
export { buildSessionContext, flushRawEvents } from "./raw-event-flush.js";
|
|
43
|
+
export { RawEventSweeper } from "./raw-event-sweeper.js";
|
|
44
|
+
export * as schema from "./schema.js";
|
|
45
|
+
export type { StoreHandle } from "./search.js";
|
|
46
|
+
export { dedupeOrderedIds, expandQuery, explain, kindBonus, recencyScore, rerankResults, search, timeline, } from "./search.js";
|
|
47
|
+
export { MemoryStore } from "./store.js";
|
|
48
|
+
export type { BuildAuthHeadersOptions, SignRequestOptions, VerifySignatureOptions, } from "./sync-auth.js";
|
|
49
|
+
export { buildAuthHeaders, buildCanonicalRequest, cleanupNonces, DEFAULT_TIME_WINDOW_S, recordNonce, SIGNATURE_VERSION, signRequest, verifySignature, } from "./sync-auth.js";
|
|
50
|
+
export type { SyncDaemonOptions, SyncTickResult } from "./sync-daemon.js";
|
|
51
|
+
export { runSyncDaemon, setSyncDaemonError, setSyncDaemonOk, syncDaemonTick, } from "./sync-daemon.js";
|
|
52
|
+
export type { MdnsEntry } from "./sync-discovery.js";
|
|
53
|
+
export { addressDedupeKey, advertiseMdns, DEFAULT_SERVICE_TYPE, discoverPeersViaMdns, loadPeerAddresses, mdnsAddressesForPeer, mdnsEnabled, mergeAddresses, normalizeAddress, recordPeerSuccess, recordSyncAttempt, selectDialAddresses, setPeerLocalActorClaim, setPeerProjectFilter, updatePeerAddresses, } from "./sync-discovery.js";
|
|
54
|
+
export type { RequestJsonOptions } from "./sync-http-client.js";
|
|
55
|
+
export { buildBaseUrl, requestJson } from "./sync-http-client.js";
|
|
56
|
+
export type { EnsureDeviceIdentityOptions } from "./sync-identity.js";
|
|
57
|
+
export { ensureDeviceIdentity, fingerprintPublicKey, generateKeypair, loadPrivateKey, loadPrivateKeyKeychain, loadPublicKey, resolveKeyPaths, storePrivateKeyKeychain, validateExistingKeypair, } from "./sync-identity.js";
|
|
58
|
+
export type { SyncPassOptions, SyncResult } from "./sync-pass.js";
|
|
59
|
+
export { consecutiveConnectivityFailures, cursorAdvances, isConnectivityError, peerBackoffSeconds, runSyncPass, shouldSkipOfflinePeer, syncOnce, syncPassPreflight, } from "./sync-pass.js";
|
|
60
|
+
export type { ApplyResult } from "./sync-replication.js";
|
|
61
|
+
export { applyReplicationOps, chunkOpsBySize, clockTuple, extractReplicationOps, getReplicationCursor, isNewerClock, loadReplicationOpsSince, recordReplicationOp, setReplicationCursor, } from "./sync-replication.js";
|
|
62
|
+
export { initTestSchema, insertTestSession } from "./test-utils.js";
|
|
63
|
+
export type { Actor, Artifact, ExplainError, ExplainItem, ExplainResponse, ExplainScoreComponents, MemoryFilters, MemoryItem, MemoryItemResponse, MemoryResult, OpenCodeSession, PackItem, PackResponse, RawEvent, RawEventFlushBatch, RawEventIngestSample, RawEventIngestStats, RawEventSession, ReplicationClock, ReplicationCursor, ReplicationOp, Session, SessionSummary, StoreStats, SyncAttempt, SyncDaemonState, SyncDevice, SyncNonce, SyncPeer, TimelineItemResponse, UsageEvent, UserPrompt, } from "./types.js";
|
|
64
|
+
export type { BackfillVectorsOptions, BackfillVectorsResult, SemanticSearchResult, } from "./vectors.js";
|
|
65
|
+
export { backfillVectors, semanticSearch, storeVectors } from "./vectors.js";
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,mBAAmB,CAAC;AAExC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EACN,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,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