@cleocode/brain 2026.6.14 → 2026.6.17
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/dist/src/adapters/agent-registry.d.ts +35 -0
- package/dist/src/adapters/agent-registry.d.ts.map +1 -0
- package/dist/src/adapters/agent-registry.js +96 -0
- package/dist/src/adapters/agent-registry.js.map +1 -0
- package/dist/src/adapters/brain.d.ts +35 -0
- package/dist/src/adapters/brain.d.ts.map +1 -0
- package/dist/src/adapters/brain.js +303 -0
- package/dist/src/adapters/brain.js.map +1 -0
- package/dist/src/adapters/conduit.d.ts +25 -0
- package/dist/src/adapters/conduit.d.ts.map +1 -0
- package/dist/src/adapters/conduit.js +94 -0
- package/dist/src/adapters/conduit.js.map +1 -0
- package/dist/src/adapters/index.d.ts +32 -0
- package/dist/src/adapters/index.d.ts.map +1 -0
- package/dist/src/adapters/index.js +194 -0
- package/dist/src/adapters/index.js.map +1 -0
- package/dist/src/adapters/nexus.d.ts +24 -0
- package/dist/src/adapters/nexus.d.ts.map +1 -0
- package/dist/src/adapters/nexus.js +83 -0
- package/dist/src/adapters/nexus.js.map +1 -0
- package/dist/src/adapters/tasks.d.ts +23 -0
- package/dist/src/adapters/tasks.d.ts.map +1 -0
- package/dist/src/adapters/tasks.js +143 -0
- package/dist/src/adapters/tasks.js.map +1 -0
- package/dist/src/cleo-home.d.ts +47 -0
- package/dist/src/cleo-home.d.ts.map +1 -0
- package/dist/src/cleo-home.js +73 -0
- package/dist/src/cleo-home.js.map +1 -0
- package/dist/src/db-connections.d.ts +143 -0
- package/dist/src/db-connections.d.ts.map +1 -0
- package/dist/src/db-connections.js +215 -0
- package/dist/src/db-connections.js.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/project-context.d.ts +47 -0
- package/dist/src/project-context.d.ts.map +1 -0
- package/dist/src/project-context.js +52 -0
- package/dist/src/project-context.js.map +1 -0
- package/dist/src/types.d.ts +22 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +22 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only SQLite connection helpers for the Living Brain substrate adapters.
|
|
3
|
+
*
|
|
4
|
+
* Uses node:sqlite (Node.js built-in).
|
|
5
|
+
*
|
|
6
|
+
* Global databases (nexus.db, signaldock.db) are shared across all projects
|
|
7
|
+
* and use module-level caches — their path is fixed per machine and never
|
|
8
|
+
* changes between requests.
|
|
9
|
+
*
|
|
10
|
+
* Per-project databases (brain.db, tasks.db, conduit.db) are resolved from
|
|
11
|
+
* the active {@link ProjectContext} passed by the caller. No cross-request
|
|
12
|
+
* caching is performed: opening SQLite with `node:sqlite` is sub-millisecond,
|
|
13
|
+
* and caching across different ProjectContexts is the precise bug this
|
|
14
|
+
* module's Studio counterpart was rewritten to avoid.
|
|
15
|
+
*
|
|
16
|
+
* This file is a trimmed mirror of
|
|
17
|
+
* `packages/studio/src/lib/server/db/connections.ts`, containing only the
|
|
18
|
+
* getters required by the substrate adapters.
|
|
19
|
+
*
|
|
20
|
+
* ## E4-T5 transition (T11516 · SG-DB-SUBSTRATE-V2)
|
|
21
|
+
*
|
|
22
|
+
* This module now depends on `@cleocode/core` and delegates to
|
|
23
|
+
* {@link openDualScopeDb} for new consolidated `cleo.db` access. The legacy
|
|
24
|
+
* per-domain DB getters ({@link getNexusDb}, {@link getBrainDb}, etc.) still
|
|
25
|
+
* open the old per-domain files via per-line-allowed raw opens because the
|
|
26
|
+
* substrate adapters in this package still target those legacy table schemas.
|
|
27
|
+
* The full exodus to the consolidated `cleo.db` schema happens in E6 (T11249),
|
|
28
|
+
* at which point the per-line `// db-open-allowed` markers and the legacy
|
|
29
|
+
* getters are removed.
|
|
30
|
+
*
|
|
31
|
+
* @task T969
|
|
32
|
+
* @task T11516 (E4-T5)
|
|
33
|
+
*/
|
|
34
|
+
import type { DatabaseSync as _DatabaseSyncType } from 'node:sqlite';
|
|
35
|
+
import type { ProjectContext } from './project-context.js';
|
|
36
|
+
/**
|
|
37
|
+
* Re-export of the dual-scope `cleo.db` chokepoint.
|
|
38
|
+
*
|
|
39
|
+
* Callers that target the new consolidated schema (E4+) should use
|
|
40
|
+
* `openDualScopeDb` directly rather than the legacy per-domain getters below.
|
|
41
|
+
*
|
|
42
|
+
* @see packages/core/src/store/dual-scope-db.ts
|
|
43
|
+
*/
|
|
44
|
+
export { openDualScopeDb } from '@cleocode/core/db';
|
|
45
|
+
type DatabaseSync = _DatabaseSyncType;
|
|
46
|
+
declare const DatabaseSync: new (path: import("fs").PathLike, options?: import("node:sqlite").DatabaseSyncOptions | undefined) => DatabaseSync;
|
|
47
|
+
/**
|
|
48
|
+
* Minimal structural view of a `node:sqlite` prepared statement.
|
|
49
|
+
*
|
|
50
|
+
* `node:sqlite` returns rows as `Record<string, SQLOutputValue>[]` — a generic
|
|
51
|
+
* shape that's not directly assignable to the row interfaces defined by each
|
|
52
|
+
* substrate adapter. This type captures just the subset of `StatementSync`
|
|
53
|
+
* used by the typed-row helper below.
|
|
54
|
+
*/
|
|
55
|
+
interface PreparedStatementLike {
|
|
56
|
+
all(...params: unknown[]): unknown[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Executes a prepared statement and returns rows typed as `T[]`.
|
|
60
|
+
*
|
|
61
|
+
* This helper consolidates the SQL-to-TypeScript boundary into a single,
|
|
62
|
+
* auditable location. Each adapter specifies the expected row shape via the
|
|
63
|
+
* type parameter; the unknown→T conversion happens exactly once per call
|
|
64
|
+
* site rather than being scattered across every query site.
|
|
65
|
+
*
|
|
66
|
+
* Callers remain responsible for validating that the SQL projection matches
|
|
67
|
+
* the declared type `T`.
|
|
68
|
+
*
|
|
69
|
+
* @param stmt - A prepared `node:sqlite` StatementSync.
|
|
70
|
+
* @param params - Anonymous parameter bindings for the statement.
|
|
71
|
+
* @returns Rows materialised as `T[]`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function allTyped<T>(stmt: PreparedStatementLike, ...params: unknown[]): T[];
|
|
74
|
+
/**
|
|
75
|
+
* Returns a read-only connection to the global nexus.db.
|
|
76
|
+
* Returns null when the file does not exist on disk.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
80
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
81
|
+
* adapters still target legacy nexus.db table names. Full exodus in E6 (T11249).
|
|
82
|
+
*/
|
|
83
|
+
export declare function getNexusDb(): DatabaseSync | null;
|
|
84
|
+
/**
|
|
85
|
+
* Returns a read-only connection to the global signaldock.db.
|
|
86
|
+
* Returns null when the file does not exist on disk.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
90
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
91
|
+
* adapters still target legacy signaldock.db table names. Full exodus in E6 (T11249).
|
|
92
|
+
*/
|
|
93
|
+
export declare function getAgentRegistryDb(): DatabaseSync | null;
|
|
94
|
+
/**
|
|
95
|
+
* Opens a connection to brain.db for the given project context.
|
|
96
|
+
*
|
|
97
|
+
* Each call opens a fresh DatabaseSync against the path stored in `ctx`.
|
|
98
|
+
* Returns null when brain.db does not exist for the project OR when the
|
|
99
|
+
* file is detected as malformed (T10303). Reader-side malformation is
|
|
100
|
+
* handled by returning null — recovery is owned by the writer side in
|
|
101
|
+
* `@cleocode/core/store/memory-sqlite.ts:getBrainDb`, which runs the
|
|
102
|
+
* `recoverMalformedBrainDb()` pipeline before the next process re-opens.
|
|
103
|
+
*
|
|
104
|
+
* @param ctx - The active project context.
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
108
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
109
|
+
* adapters still target legacy brain.db table names. Full exodus in E6 (T11249).
|
|
110
|
+
*/
|
|
111
|
+
export declare function getBrainDb(ctx: ProjectContext): DatabaseSync | null;
|
|
112
|
+
/**
|
|
113
|
+
* Opens a connection to tasks.db for the given project context.
|
|
114
|
+
*
|
|
115
|
+
* Each call opens a fresh DatabaseSync against the path stored in `ctx`.
|
|
116
|
+
* Returns null when tasks.db does not exist for the project.
|
|
117
|
+
*
|
|
118
|
+
* @param ctx - The active project context.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
122
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
123
|
+
* adapters still target legacy tasks.db table names. Full exodus in E6 (T11249).
|
|
124
|
+
*/
|
|
125
|
+
export declare function getTasksDb(ctx: ProjectContext): DatabaseSync | null;
|
|
126
|
+
/**
|
|
127
|
+
* Opens a connection to conduit.db for the given project context.
|
|
128
|
+
*
|
|
129
|
+
* conduit.db lives alongside brain.db in the project's `.cleo/` directory.
|
|
130
|
+
* Its path is derived from the brain.db path since `ProjectContext` does not
|
|
131
|
+
* carry a dedicated `conduitDbPath` field.
|
|
132
|
+
*
|
|
133
|
+
* Returns null when conduit.db does not exist for the project.
|
|
134
|
+
*
|
|
135
|
+
* @param ctx - The active project context.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
139
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
140
|
+
* adapters still target legacy conduit.db table names. Full exodus in E6 (T11249).
|
|
141
|
+
*/
|
|
142
|
+
export declare function getConduitDb(ctx: ProjectContext): DatabaseSync | null;
|
|
143
|
+
//# sourceMappingURL=db-connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-connections.d.ts","sourceRoot":"","sources":["../../src/db-connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAKH,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,KAAK,YAAY,GAAG,iBAAiB,CAAC;AACtC,QAAA,MAAQ,YAAY,wGAC8D,YACjF,CAAC;AAMF;;;;;;;GAOG;AACH,UAAU,qBAAqB;IAC7B,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAElF;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,IAAI,YAAY,GAAG,IAAI,CAOhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,GAAG,IAAI,CAOxD;AAwBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAWnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAMnE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAMrE"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only SQLite connection helpers for the Living Brain substrate adapters.
|
|
3
|
+
*
|
|
4
|
+
* Uses node:sqlite (Node.js built-in).
|
|
5
|
+
*
|
|
6
|
+
* Global databases (nexus.db, signaldock.db) are shared across all projects
|
|
7
|
+
* and use module-level caches — their path is fixed per machine and never
|
|
8
|
+
* changes between requests.
|
|
9
|
+
*
|
|
10
|
+
* Per-project databases (brain.db, tasks.db, conduit.db) are resolved from
|
|
11
|
+
* the active {@link ProjectContext} passed by the caller. No cross-request
|
|
12
|
+
* caching is performed: opening SQLite with `node:sqlite` is sub-millisecond,
|
|
13
|
+
* and caching across different ProjectContexts is the precise bug this
|
|
14
|
+
* module's Studio counterpart was rewritten to avoid.
|
|
15
|
+
*
|
|
16
|
+
* This file is a trimmed mirror of
|
|
17
|
+
* `packages/studio/src/lib/server/db/connections.ts`, containing only the
|
|
18
|
+
* getters required by the substrate adapters.
|
|
19
|
+
*
|
|
20
|
+
* ## E4-T5 transition (T11516 · SG-DB-SUBSTRATE-V2)
|
|
21
|
+
*
|
|
22
|
+
* This module now depends on `@cleocode/core` and delegates to
|
|
23
|
+
* {@link openDualScopeDb} for new consolidated `cleo.db` access. The legacy
|
|
24
|
+
* per-domain DB getters ({@link getNexusDb}, {@link getBrainDb}, etc.) still
|
|
25
|
+
* open the old per-domain files via per-line-allowed raw opens because the
|
|
26
|
+
* substrate adapters in this package still target those legacy table schemas.
|
|
27
|
+
* The full exodus to the consolidated `cleo.db` schema happens in E6 (T11249),
|
|
28
|
+
* at which point the per-line `// db-open-allowed` markers and the legacy
|
|
29
|
+
* getters are removed.
|
|
30
|
+
*
|
|
31
|
+
* @task T969
|
|
32
|
+
* @task T11516 (E4-T5)
|
|
33
|
+
*/
|
|
34
|
+
import { existsSync } from 'node:fs';
|
|
35
|
+
import { createRequire } from 'node:module';
|
|
36
|
+
import { dirname, join } from 'node:path';
|
|
37
|
+
import { applyPerfPragmas } from '@cleocode/core/store/sqlite-pragmas.js';
|
|
38
|
+
import { dbExists, getAgentRegistryDbPath, getNexusDbPath } from './cleo-home.js';
|
|
39
|
+
/**
|
|
40
|
+
* Re-export of the dual-scope `cleo.db` chokepoint.
|
|
41
|
+
*
|
|
42
|
+
* Callers that target the new consolidated schema (E4+) should use
|
|
43
|
+
* `openDualScopeDb` directly rather than the legacy per-domain getters below.
|
|
44
|
+
*
|
|
45
|
+
* @see packages/core/src/store/dual-scope-db.ts
|
|
46
|
+
*/
|
|
47
|
+
export { openDualScopeDb } from '@cleocode/core/db';
|
|
48
|
+
const _require = createRequire(import.meta.url);
|
|
49
|
+
const { DatabaseSync } = _require('node:sqlite');
|
|
50
|
+
/**
|
|
51
|
+
* Executes a prepared statement and returns rows typed as `T[]`.
|
|
52
|
+
*
|
|
53
|
+
* This helper consolidates the SQL-to-TypeScript boundary into a single,
|
|
54
|
+
* auditable location. Each adapter specifies the expected row shape via the
|
|
55
|
+
* type parameter; the unknown→T conversion happens exactly once per call
|
|
56
|
+
* site rather than being scattered across every query site.
|
|
57
|
+
*
|
|
58
|
+
* Callers remain responsible for validating that the SQL projection matches
|
|
59
|
+
* the declared type `T`.
|
|
60
|
+
*
|
|
61
|
+
* @param stmt - A prepared `node:sqlite` StatementSync.
|
|
62
|
+
* @param params - Anonymous parameter bindings for the statement.
|
|
63
|
+
* @returns Rows materialised as `T[]`.
|
|
64
|
+
*/
|
|
65
|
+
export function allTyped(stmt, ...params) {
|
|
66
|
+
return stmt.all(...params);
|
|
67
|
+
}
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Global singleton caches (path never changes per process)
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
/** Cached nexus.db connection — global, path is machine-scoped. */
|
|
72
|
+
let nexusDb = null;
|
|
73
|
+
/** Cached signaldock.db connection — global, path is machine-scoped. */
|
|
74
|
+
let signaldockDb = null;
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Global DB getters (cached per process)
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
/**
|
|
79
|
+
* Returns a read-only connection to the global nexus.db.
|
|
80
|
+
* Returns null when the file does not exist on disk.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
84
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
85
|
+
* adapters still target legacy nexus.db table names. Full exodus in E6 (T11249).
|
|
86
|
+
*/
|
|
87
|
+
export function getNexusDb() {
|
|
88
|
+
if (nexusDb)
|
|
89
|
+
return nexusDb;
|
|
90
|
+
const path = getNexusDbPath();
|
|
91
|
+
if (!dbExists(path))
|
|
92
|
+
return null;
|
|
93
|
+
nexusDb = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence — adapters target legacy nexus.db schema; full exodus in E6 (T11249)
|
|
94
|
+
applyPerfPragmas(nexusDb);
|
|
95
|
+
return nexusDb;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns a read-only connection to the global signaldock.db.
|
|
99
|
+
* Returns null when the file does not exist on disk.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
103
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
104
|
+
* adapters still target legacy signaldock.db table names. Full exodus in E6 (T11249).
|
|
105
|
+
*/
|
|
106
|
+
export function getAgentRegistryDb() {
|
|
107
|
+
if (signaldockDb)
|
|
108
|
+
return signaldockDb;
|
|
109
|
+
const path = getAgentRegistryDbPath();
|
|
110
|
+
if (!dbExists(path))
|
|
111
|
+
return null;
|
|
112
|
+
signaldockDb = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence — adapters target legacy signaldock.db schema; full exodus in E6 (T11249)
|
|
113
|
+
applyPerfPragmas(signaldockDb);
|
|
114
|
+
return signaldockDb;
|
|
115
|
+
}
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Per-project DB getters (NOT cached — resolved from ProjectContext)
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
/**
|
|
120
|
+
* Detect the brain.db malformation signature (T10303) without taking a
|
|
121
|
+
* dependency on `@cleocode/core`. The reader side does NOT auto-recover —
|
|
122
|
+
* recovery is owned by the writer side in `@cleocode/core/store/memory-sqlite.ts`.
|
|
123
|
+
* Reader-side detection returns `null` so substrate adapters degrade
|
|
124
|
+
* gracefully (matches the existing "DB doesn't exist" semantics).
|
|
125
|
+
*
|
|
126
|
+
* @internal — brain-package-local.
|
|
127
|
+
* @task T10303
|
|
128
|
+
*/
|
|
129
|
+
function isMalformationError(err) {
|
|
130
|
+
if (!(err instanceof Error))
|
|
131
|
+
return false;
|
|
132
|
+
const code = err.code;
|
|
133
|
+
const errcode = err.errcode;
|
|
134
|
+
if (code === 'ERR_SQLITE_ERROR' && errcode === 11)
|
|
135
|
+
return true;
|
|
136
|
+
return /malformed/i.test(err.message ?? '');
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Opens a connection to brain.db for the given project context.
|
|
140
|
+
*
|
|
141
|
+
* Each call opens a fresh DatabaseSync against the path stored in `ctx`.
|
|
142
|
+
* Returns null when brain.db does not exist for the project OR when the
|
|
143
|
+
* file is detected as malformed (T10303). Reader-side malformation is
|
|
144
|
+
* handled by returning null — recovery is owned by the writer side in
|
|
145
|
+
* `@cleocode/core/store/memory-sqlite.ts:getBrainDb`, which runs the
|
|
146
|
+
* `recoverMalformedBrainDb()` pipeline before the next process re-opens.
|
|
147
|
+
*
|
|
148
|
+
* @param ctx - The active project context.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
152
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
153
|
+
* adapters still target legacy brain.db table names. Full exodus in E6 (T11249).
|
|
154
|
+
*/
|
|
155
|
+
export function getBrainDb(ctx) {
|
|
156
|
+
const path = ctx.brainDbPath;
|
|
157
|
+
if (!existsSync(path))
|
|
158
|
+
return null;
|
|
159
|
+
try {
|
|
160
|
+
const __db = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence — adapters target legacy brain.db schema; full exodus in E6 (T11249)
|
|
161
|
+
applyPerfPragmas(__db);
|
|
162
|
+
return __db;
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
if (isMalformationError(err))
|
|
166
|
+
return null;
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Opens a connection to tasks.db for the given project context.
|
|
172
|
+
*
|
|
173
|
+
* Each call opens a fresh DatabaseSync against the path stored in `ctx`.
|
|
174
|
+
* Returns null when tasks.db does not exist for the project.
|
|
175
|
+
*
|
|
176
|
+
* @param ctx - The active project context.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
180
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
181
|
+
* adapters still target legacy tasks.db table names. Full exodus in E6 (T11249).
|
|
182
|
+
*/
|
|
183
|
+
export function getTasksDb(ctx) {
|
|
184
|
+
const path = ctx.tasksDbPath;
|
|
185
|
+
if (!existsSync(path))
|
|
186
|
+
return null;
|
|
187
|
+
const __db = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence — adapters target legacy tasks.db schema; full exodus in E6 (T11249)
|
|
188
|
+
applyPerfPragmas(__db);
|
|
189
|
+
return __db;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Opens a connection to conduit.db for the given project context.
|
|
193
|
+
*
|
|
194
|
+
* conduit.db lives alongside brain.db in the project's `.cleo/` directory.
|
|
195
|
+
* Its path is derived from the brain.db path since `ProjectContext` does not
|
|
196
|
+
* carry a dedicated `conduitDbPath` field.
|
|
197
|
+
*
|
|
198
|
+
* Returns null when conduit.db does not exist for the project.
|
|
199
|
+
*
|
|
200
|
+
* @param ctx - The active project context.
|
|
201
|
+
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
|
|
204
|
+
* The raw open is per-line-allowed during the E4 → E6 transition; substrate
|
|
205
|
+
* adapters still target legacy conduit.db table names. Full exodus in E6 (T11249).
|
|
206
|
+
*/
|
|
207
|
+
export function getConduitDb(ctx) {
|
|
208
|
+
const path = join(dirname(ctx.brainDbPath), 'conduit.db');
|
|
209
|
+
if (!existsSync(path))
|
|
210
|
+
return null;
|
|
211
|
+
const __db = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence — adapters target legacy conduit.db schema; full exodus in E6 (T11249)
|
|
212
|
+
applyPerfPragmas(__db);
|
|
213
|
+
return __db;
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=db-connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-connections.js","sourceRoot":"","sources":["../../src/db-connections.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for `@cleocode/brain` — the unified-graph substrate for CLEO.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - Wire-format types (BrainNode, BrainEdge, BrainGraph, BrainQueryOptions, BrainStreamEvent, BrainConnectionStatus, BrainNodeKind, BrainSubstrate)
|
|
6
|
+
* - Unified query function (`getAllSubstrates`)
|
|
7
|
+
* - Individual substrate adapters (`getBrainSubstrate`, `getNexusSubstrate`, `getTasksSubstrate`, `getConduitSubstrate`, `getAgentRegistrySubstrate`)
|
|
8
|
+
* - Project context helpers (`ProjectContext`, `resolveDefaultProjectContext`)
|
|
9
|
+
* - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getBrainDbPath`, etc.)
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* T973 renamed the `LB*` prefix to `Brain*` to align the runtime naming with
|
|
13
|
+
* the `@cleocode/contracts/operations/brain` wire format and the operator's
|
|
14
|
+
* BRAIN super-graph mental model. The runtime shapes (fields, unions) remain
|
|
15
|
+
* intentionally distinct from the contracts shapes — these are the types
|
|
16
|
+
* produced by the substrate adapters in this package.
|
|
17
|
+
*
|
|
18
|
+
* @task T969 (original extraction) · T973 (LB* → Brain* rename)
|
|
19
|
+
*/
|
|
20
|
+
export { getAgentRegistrySubstrate, getAllSubstrates, getBrainSubstrate, getConduitSubstrate, getNexusSubstrate, getTasksSubstrate, } from './adapters/index.js';
|
|
21
|
+
export { dbExists, getAgentRegistryDbPath, getBrainDbPath, getCleoHome, getCleoProjectDir, getConduitDbPath, getNexusDbPath, getTasksDbPath, } from './cleo-home.js';
|
|
22
|
+
export { getAgentRegistryDb, getBrainDb, getConduitDb, getNexusDb, getTasksDb, } from './db-connections.js';
|
|
23
|
+
export type { ProjectContext } from './project-context.js';
|
|
24
|
+
export { resolveDefaultProjectContext } from './project-context.js';
|
|
25
|
+
export type { BrainConnectionStatus, BrainEdge, BrainGraph, BrainNode, BrainNodeKind, BrainProjectContext, BrainQueryOptions, BrainStreamEvent, BrainSubstrate, } from './types.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,YAAY,EACV,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for `@cleocode/brain` — the unified-graph substrate for CLEO.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - Wire-format types (BrainNode, BrainEdge, BrainGraph, BrainQueryOptions, BrainStreamEvent, BrainConnectionStatus, BrainNodeKind, BrainSubstrate)
|
|
6
|
+
* - Unified query function (`getAllSubstrates`)
|
|
7
|
+
* - Individual substrate adapters (`getBrainSubstrate`, `getNexusSubstrate`, `getTasksSubstrate`, `getConduitSubstrate`, `getAgentRegistrySubstrate`)
|
|
8
|
+
* - Project context helpers (`ProjectContext`, `resolveDefaultProjectContext`)
|
|
9
|
+
* - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getBrainDbPath`, etc.)
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* T973 renamed the `LB*` prefix to `Brain*` to align the runtime naming with
|
|
13
|
+
* the `@cleocode/contracts/operations/brain` wire format and the operator's
|
|
14
|
+
* BRAIN super-graph mental model. The runtime shapes (fields, unions) remain
|
|
15
|
+
* intentionally distinct from the contracts shapes — these are the types
|
|
16
|
+
* produced by the substrate adapters in this package.
|
|
17
|
+
*
|
|
18
|
+
* @task T969 (original extraction) · T973 (LB* → Brain* rename)
|
|
19
|
+
*/
|
|
20
|
+
// Substrate adapters and unified query
|
|
21
|
+
export { getAgentRegistrySubstrate, getAllSubstrates, getBrainSubstrate, getConduitSubstrate, getNexusSubstrate, getTasksSubstrate, } from './adapters/index.js';
|
|
22
|
+
// Path helpers (re-exported for downstream consumers that need to resolve
|
|
23
|
+
// DB paths without importing the connection helpers directly)
|
|
24
|
+
export { dbExists, getAgentRegistryDbPath, getBrainDbPath, getCleoHome, getCleoProjectDir, getConduitDbPath, getNexusDbPath, getTasksDbPath, } from './cleo-home.js';
|
|
25
|
+
// Low-level connection getters (for advanced consumers; studio typically uses
|
|
26
|
+
// its own connection helpers and passes ProjectContext to the adapters instead)
|
|
27
|
+
export { getAgentRegistryDb, getBrainDb, getConduitDb, getNexusDb, getTasksDb, } from './db-connections.js';
|
|
28
|
+
export { resolveDefaultProjectContext } from './project-context.js';
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uCAAuC;AACvC,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,0EAA0E;AAC1E,8DAA8D;AAC9D,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,8EAA8E;AAC9E,gFAAgF;AAChF,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project context resolution for the Living Brain substrate.
|
|
3
|
+
*
|
|
4
|
+
* `ProjectContext` carries the resolved absolute paths for the per-project
|
|
5
|
+
* databases (brain.db, tasks.db) so substrate adapters can route queries to
|
|
6
|
+
* the correct project without depending on SvelteKit request locals.
|
|
7
|
+
*
|
|
8
|
+
* The `ProjectContext` shape defined here is structurally compatible with
|
|
9
|
+
* (i.e. a subtype of) the studio's richer `ProjectContext` in
|
|
10
|
+
* `packages/studio/src/lib/server/project-context.ts`. Studio callers may
|
|
11
|
+
* pass their full context directly; it will satisfy this interface via
|
|
12
|
+
* structural typing.
|
|
13
|
+
*
|
|
14
|
+
* `resolveDefaultProjectContext` derives a fallback context from
|
|
15
|
+
* `CLEO_ROOT` / `process.cwd()` when no explicit context is supplied.
|
|
16
|
+
*
|
|
17
|
+
* @task T969
|
|
18
|
+
* @task T11040 (verified 2026-05-27: resolveProjectByCwd used for projectPath; 72/72 tests pass)
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Resolved paths for the active project context.
|
|
22
|
+
*
|
|
23
|
+
* Studio's `ProjectContext` type carries additional fields (projectId, name,
|
|
24
|
+
* brainDbExists, tasksDbExists). TypeScript structural typing allows Studio to
|
|
25
|
+
* pass its richer type wherever this interface is expected.
|
|
26
|
+
*/
|
|
27
|
+
export interface ProjectContext {
|
|
28
|
+
/** Absolute path to the project root. */
|
|
29
|
+
projectPath: string;
|
|
30
|
+
/** Absolute path to brain.db for this project. */
|
|
31
|
+
brainDbPath: string;
|
|
32
|
+
/** Absolute path to tasks.db for this project. */
|
|
33
|
+
tasksDbPath: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolve the default project context using projectId-based resolution.
|
|
37
|
+
*
|
|
38
|
+
* Derives `projectPath` from {@link resolveProjectByCwd} (canonical project
|
|
39
|
+
* root), falling back to the `.cleo`-relative path for non-project contexts.
|
|
40
|
+
* DB paths flow through {@link getCleoProjectDir}, which now uses
|
|
41
|
+
* projectId→nexus.db resolution instead of CWD-walk-up (T11040).
|
|
42
|
+
*
|
|
43
|
+
* @returns A context whose paths derive from projectId resolution where possible.
|
|
44
|
+
* @task T11040 — migrate from CWD-walk-up to projectId-based resolution
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveDefaultProjectContext(): ProjectContext;
|
|
47
|
+
//# sourceMappingURL=project-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-context.d.ts","sourceRoot":"","sources":["../../src/project-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,IAAI,cAAc,CAgB7D"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project context resolution for the Living Brain substrate.
|
|
3
|
+
*
|
|
4
|
+
* `ProjectContext` carries the resolved absolute paths for the per-project
|
|
5
|
+
* databases (brain.db, tasks.db) so substrate adapters can route queries to
|
|
6
|
+
* the correct project without depending on SvelteKit request locals.
|
|
7
|
+
*
|
|
8
|
+
* The `ProjectContext` shape defined here is structurally compatible with
|
|
9
|
+
* (i.e. a subtype of) the studio's richer `ProjectContext` in
|
|
10
|
+
* `packages/studio/src/lib/server/project-context.ts`. Studio callers may
|
|
11
|
+
* pass their full context directly; it will satisfy this interface via
|
|
12
|
+
* structural typing.
|
|
13
|
+
*
|
|
14
|
+
* `resolveDefaultProjectContext` derives a fallback context from
|
|
15
|
+
* `CLEO_ROOT` / `process.cwd()` when no explicit context is supplied.
|
|
16
|
+
*
|
|
17
|
+
* @task T969
|
|
18
|
+
* @task T11040 (verified 2026-05-27: resolveProjectByCwd used for projectPath; 72/72 tests pass)
|
|
19
|
+
*/
|
|
20
|
+
import { existsSync } from 'node:fs';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
import { resolveProjectByCwd } from '@cleocode/paths';
|
|
23
|
+
import { getCleoProjectDir } from './cleo-home.js';
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the default project context using projectId-based resolution.
|
|
26
|
+
*
|
|
27
|
+
* Derives `projectPath` from {@link resolveProjectByCwd} (canonical project
|
|
28
|
+
* root), falling back to the `.cleo`-relative path for non-project contexts.
|
|
29
|
+
* DB paths flow through {@link getCleoProjectDir}, which now uses
|
|
30
|
+
* projectId→nexus.db resolution instead of CWD-walk-up (T11040).
|
|
31
|
+
*
|
|
32
|
+
* @returns A context whose paths derive from projectId resolution where possible.
|
|
33
|
+
* @task T11040 — migrate from CWD-walk-up to projectId-based resolution
|
|
34
|
+
*/
|
|
35
|
+
export function resolveDefaultProjectContext() {
|
|
36
|
+
const project = resolveProjectByCwd();
|
|
37
|
+
const projectDir = getCleoProjectDir();
|
|
38
|
+
// Use canonical project root from projectId resolution when available;
|
|
39
|
+
// fall back to regex-stripping .cleo/ for non-project contexts.
|
|
40
|
+
const projectPath = project !== null ? project.projectRoot : projectDir.replace(/\/.cleo$/, '');
|
|
41
|
+
const brainDbPath = join(projectDir, 'brain.db');
|
|
42
|
+
const tasksDbPath = join(projectDir, 'tasks.db');
|
|
43
|
+
// existsSync is referenced to match the studio surface, and documents intent;
|
|
44
|
+
// adapters re-check existence before opening to avoid stale races.
|
|
45
|
+
void existsSync;
|
|
46
|
+
return {
|
|
47
|
+
projectPath,
|
|
48
|
+
brainDbPath,
|
|
49
|
+
tasksDbPath,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=project-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-context.js","sourceRoot":"","sources":["../../src/project-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAkBnD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,4BAA4B;IAC1C,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;IACvC,uEAAuE;IACvE,gEAAgE;IAChE,MAAM,WAAW,GAAG,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAChG,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACjD,8EAA8E;IAC9E,mEAAmE;IACnE,KAAK,UAAU,CAAC;IAChB,OAAO;QACL,WAAW;QACX,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brain unified-graph runtime types — re-exported from `@cleocode/contracts`.
|
|
3
|
+
*
|
|
4
|
+
* The canonical definitions live in
|
|
5
|
+
* `packages/contracts/src/brain-graph.ts`. This file re-exports them so
|
|
6
|
+
* existing imports of `'../types.js'` within `@cleocode/brain` continue to
|
|
7
|
+
* resolve without change, and external consumers that `import from
|
|
8
|
+
* '@cleocode/brain'` also receive the same canonical shapes.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* T989 unified the three duplicate copies of BrainNode/BrainEdge/BrainGraph:
|
|
12
|
+
* - `packages/brain/src/types.ts` (this file — was the runtime definition)
|
|
13
|
+
* - `packages/contracts/src/operations/brain.ts` (wire-format, now renamed)
|
|
14
|
+
* - `packages/studio/src/routes/api/memory/graph/+server.ts` (raw-DB types, renamed)
|
|
15
|
+
*
|
|
16
|
+
* @task T989 — Unify BrainNode / BrainEdge types (single canonical shape)
|
|
17
|
+
* @task T973 — LB* → Brain* rename
|
|
18
|
+
* @task T969 — `@cleocode/brain` package extraction
|
|
19
|
+
* @see packages/contracts/src/brain-graph.ts (canonical source)
|
|
20
|
+
*/
|
|
21
|
+
export type { BrainConnectionStatus, BrainEdge, BrainGraph, BrainNode, BrainNodeKind, BrainProjectContext, BrainQueryOptions, BrainStreamEvent, BrainSubstrate, } from '@cleocode/contracts';
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,YAAY,EACV,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brain unified-graph runtime types — re-exported from `@cleocode/contracts`.
|
|
3
|
+
*
|
|
4
|
+
* The canonical definitions live in
|
|
5
|
+
* `packages/contracts/src/brain-graph.ts`. This file re-exports them so
|
|
6
|
+
* existing imports of `'../types.js'` within `@cleocode/brain` continue to
|
|
7
|
+
* resolve without change, and external consumers that `import from
|
|
8
|
+
* '@cleocode/brain'` also receive the same canonical shapes.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* T989 unified the three duplicate copies of BrainNode/BrainEdge/BrainGraph:
|
|
12
|
+
* - `packages/brain/src/types.ts` (this file — was the runtime definition)
|
|
13
|
+
* - `packages/contracts/src/operations/brain.ts` (wire-format, now renamed)
|
|
14
|
+
* - `packages/studio/src/routes/api/memory/graph/+server.ts` (raw-DB types, renamed)
|
|
15
|
+
*
|
|
16
|
+
* @task T989 — Unify BrainNode / BrainEdge types (single canonical shape)
|
|
17
|
+
* @task T973 — LB* → Brain* rename
|
|
18
|
+
* @task T969 — `@cleocode/brain` package extraction
|
|
19
|
+
* @see packages/contracts/src/brain-graph.ts (canonical source)
|
|
20
|
+
*/
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
|