@cleocode/brain 2026.11.16 → 2026.11.17-rc.ci.734
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/README.md +31 -21
- package/dist/src/adapters/agent-registry.d.ts +12 -9
- package/dist/src/adapters/agent-registry.d.ts.map +1 -1
- package/dist/src/adapters/agent-registry.js +40 -65
- package/dist/src/adapters/agent-registry.js.map +1 -1
- package/dist/src/adapters/brain.d.ts +3 -2
- package/dist/src/adapters/brain.d.ts.map +1 -1
- package/dist/src/adapters/brain.js +172 -172
- package/dist/src/adapters/brain.js.map +1 -1
- package/dist/src/adapters/conduit.d.ts +5 -4
- package/dist/src/adapters/conduit.d.ts.map +1 -1
- package/dist/src/adapters/conduit.js +53 -64
- package/dist/src/adapters/conduit.js.map +1 -1
- package/dist/src/adapters/index.d.ts +2 -2
- package/dist/src/adapters/index.d.ts.map +1 -1
- package/dist/src/adapters/index.js +11 -10
- package/dist/src/adapters/index.js.map +1 -1
- package/dist/src/adapters/nexus.d.ts +5 -3
- package/dist/src/adapters/nexus.d.ts.map +1 -1
- package/dist/src/adapters/nexus.js +47 -44
- package/dist/src/adapters/nexus.js.map +1 -1
- package/dist/src/adapters/tasks.d.ts +4 -2
- package/dist/src/adapters/tasks.d.ts.map +1 -1
- package/dist/src/adapters/tasks.js +93 -92
- package/dist/src/adapters/tasks.js.map +1 -1
- package/dist/src/cleo-home.d.ts +22 -12
- package/dist/src/cleo-home.d.ts.map +1 -1
- package/dist/src/cleo-home.js +24 -20
- package/dist/src/cleo-home.js.map +1 -1
- package/dist/src/db-connections.d.ts +23 -101
- package/dist/src/db-connections.d.ts.map +1 -1
- package/dist/src/db-connections.js +43 -169
- package/dist/src/db-connections.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/project-context.d.ts +15 -7
- package/dist/src/project-context.d.ts.map +1 -1
- package/dist/src/project-context.js +10 -15
- package/dist/src/project-context.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -7,28 +7,37 @@ from five substrates: **brain** (memory), **nexus** (code graph), **tasks**,
|
|
|
7
7
|
**conduit** (legacy messages) and **agent-registry** (agents). CLEO Studio
|
|
8
8
|
(`packages/studio`) is its consumer.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
## Store
|
|
11
|
+
|
|
12
|
+
The adapters read the consolidated store, one `cleo.db` per scope, with
|
|
13
|
+
prefixed table names:
|
|
14
|
+
|
|
15
|
+
- **Project** `<project>/.cleo/cleo.db`: `tasks_*`, `brain_*`, `conduit_*` and
|
|
16
|
+
the `nexus_*` code graph (project-resident per ADR-090).
|
|
17
|
+
- **Global** `<cleoHome>/cleo.db`: `agent_registry_*`.
|
|
18
|
+
|
|
19
|
+
Each read opens a read-only snapshot through the core store chokepoint
|
|
20
|
+
(`openCleoDbSnapshot` in `@cleocode/core/store/open-cleo-db`): no migrations,
|
|
21
|
+
no cached handle, closed after the read. The legacy per-domain files
|
|
22
|
+
(`brain.db`, `tasks.db`, `conduit.db`, `nexus.db`, `signaldock.db`) are never
|
|
23
|
+
read (T12095, T14583). A missing or unreadable store makes its substrates
|
|
24
|
+
return no nodes.
|
|
19
25
|
|
|
20
26
|
## Substrates
|
|
21
27
|
|
|
22
28
|
Every node carries a substrate-prefixed ID so cross-substrate edges can
|
|
23
29
|
reference nodes unambiguously, e.g. `brain:O-abc` vs `nexus:sym-123`.
|
|
24
30
|
|
|
25
|
-
| Substrate |
|
|
26
|
-
|
|
27
|
-
| `brain` | `
|
|
28
|
-
| `nexus` | `
|
|
29
|
-
| `tasks` | `
|
|
30
|
-
| `conduit` | `
|
|
31
|
-
| `agent-registry` | `
|
|
31
|
+
| Substrate | Store | Tables | Node kinds |
|
|
32
|
+
|------------------|----------|-----------------------------------------------------------------|------------------------------------------|
|
|
33
|
+
| `brain` | project | `brain_observations`, `_decisions`, `_patterns`, `_learnings`, `_page_edges`, `_memory_links` | observation, decision, pattern, learning |
|
|
34
|
+
| `nexus` | project | `nexus_nodes`, `nexus_relations` | symbol, file |
|
|
35
|
+
| `tasks` | project | `tasks_tasks`, `tasks_sessions`, `tasks_task_relations`, `tasks_task_dependencies` | task, session |
|
|
36
|
+
| `conduit` | project | `conduit_messages` | message |
|
|
37
|
+
| `agent-registry` | global | `agent_registry_agents` | agent |
|
|
38
|
+
|
|
39
|
+
The agent registry has no agent-to-agent connection table, so agent→agent
|
|
40
|
+
edges come only from conduit message pairs.
|
|
32
41
|
|
|
33
42
|
Conduit is legacy (T13933); agent messaging now runs on AgentMBX.
|
|
34
43
|
|
|
@@ -42,7 +51,8 @@ console.log(`${graph.nodes.length} nodes across ${Object.keys(graph.counts.nodes
|
|
|
42
51
|
```
|
|
43
52
|
|
|
44
53
|
`BrainQueryOptions` also takes `substrates` (query a subset) and `projectCtx`
|
|
45
|
-
(the project
|
|
54
|
+
(the project to read; its `tasksDbPath` names the project `cleo.db`, and
|
|
55
|
+
`brainDbPath` is the same file). After loading, `getAllSubstrates` fetches a stub
|
|
46
56
|
node (`meta.isStub: true`) for any edge target not already loaded, so
|
|
47
57
|
cross-substrate edges are kept.
|
|
48
58
|
|
|
@@ -58,10 +68,10 @@ import {
|
|
|
58
68
|
} from '@cleocode/brain/adapters';
|
|
59
69
|
```
|
|
60
70
|
|
|
61
|
-
The root entry point also exports the path helpers (`
|
|
62
|
-
`
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
The root entry point also exports the path helpers (`getProjectStorePath`,
|
|
72
|
+
`getGlobalStorePath`, `getCleoProjectDir`, `getCleoHome`), the snapshot
|
|
73
|
+
readers (`readProjectStore`, `readGlobalStore`) and
|
|
74
|
+
`resolveDefaultProjectContext`.
|
|
65
75
|
|
|
66
76
|
## Wire Format
|
|
67
77
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AGENT-REGISTRY substrate adapter for the Living Brain API.
|
|
3
3
|
*
|
|
4
|
-
* Read-only visualization path. Queries
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Read-only visualization path. Queries `agent_registry_agents` in the global
|
|
5
|
+
* `cleo.db` and returns one BrainNode per active agent. The retired standalone
|
|
6
|
+
* `signaldock.db` is never read (T14583).
|
|
7
|
+
*
|
|
8
|
+
* The consolidated store has no declared agent-to-agent social graph
|
|
9
|
+
* (`agent_registry_agent_connections` records transport connections, not
|
|
10
|
+
* pairs), so this adapter emits no edges; agent→agent edges come from the
|
|
11
|
+
* CONDUIT substrate's message pairs.
|
|
10
12
|
*
|
|
11
13
|
* The substrate identifier + node-id prefix were renamed `signaldock` →
|
|
12
14
|
* `agent-registry` under T11622 (display identifiers, decoupled from the physical
|
|
@@ -17,16 +19,17 @@
|
|
|
17
19
|
* (assignee), CONDUIT (from/to), and BRAIN (source agent).
|
|
18
20
|
*
|
|
19
21
|
* @task T11622 (Signaldock → Agent Registry rename; folds T11578 AC2)
|
|
22
|
+
* @task T14583 (read the global cleo.db)
|
|
20
23
|
*/
|
|
21
24
|
import type { BrainEdge, BrainNode, BrainQueryOptions } from '../types.js';
|
|
22
25
|
/**
|
|
23
26
|
* Returns all BrainNodes and BrainEdges sourced from the Agent Registry.
|
|
24
27
|
*
|
|
25
|
-
* Fetches
|
|
26
|
-
*
|
|
28
|
+
* Fetches the most recently registered active agents. Agent nodes serve as
|
|
29
|
+
* the cross-substrate identity anchors.
|
|
27
30
|
*
|
|
28
31
|
* @param options - Query options (limit).
|
|
29
|
-
* @returns Nodes and edges from the AGENT-REGISTRY substrate.
|
|
32
|
+
* @returns Nodes (and no edges) from the AGENT-REGISTRY substrate.
|
|
30
33
|
*/
|
|
31
34
|
export declare function getAgentRegistrySubstrate(options?: BrainQueryOptions): {
|
|
32
35
|
nodes: BrainNode[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-registry.d.ts","sourceRoot":"","sources":["../../../src/adapters/agent-registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent-registry.d.ts","sourceRoot":"","sources":["../../../src/adapters/agent-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAW3E;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,iBAAsB,GAAG;IAC1E,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CA4CA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AGENT-REGISTRY substrate adapter for the Living Brain API.
|
|
3
3
|
*
|
|
4
|
-
* Read-only visualization path. Queries
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Read-only visualization path. Queries `agent_registry_agents` in the global
|
|
5
|
+
* `cleo.db` and returns one BrainNode per active agent. The retired standalone
|
|
6
|
+
* `signaldock.db` is never read (T14583).
|
|
7
|
+
*
|
|
8
|
+
* The consolidated store has no declared agent-to-agent social graph
|
|
9
|
+
* (`agent_registry_agent_connections` records transport connections, not
|
|
10
|
+
* pairs), so this adapter emits no edges; agent→agent edges come from the
|
|
11
|
+
* CONDUIT substrate's message pairs.
|
|
10
12
|
*
|
|
11
13
|
* The substrate identifier + node-id prefix were renamed `signaldock` →
|
|
12
14
|
* `agent-registry` under T11622 (display identifiers, decoupled from the physical
|
|
@@ -17,80 +19,53 @@
|
|
|
17
19
|
* (assignee), CONDUIT (from/to), and BRAIN (source agent).
|
|
18
20
|
*
|
|
19
21
|
* @task T11622 (Signaldock → Agent Registry rename; folds T11578 AC2)
|
|
22
|
+
* @task T14583 (read the global cleo.db)
|
|
20
23
|
*/
|
|
21
|
-
import { allTyped,
|
|
22
|
-
/**
|
|
23
|
-
* Converts a UNIX epoch seconds value to an ISO-8601 string.
|
|
24
|
-
* Returns null when the value is not a finite positive number.
|
|
25
|
-
*
|
|
26
|
-
* @param epoch - UNIX timestamp in seconds, or null.
|
|
27
|
-
* @returns ISO-8601 string or null.
|
|
28
|
-
*/
|
|
29
|
-
function epochToIso(epoch) {
|
|
30
|
-
if (epoch === null || !Number.isFinite(epoch) || epoch <= 0)
|
|
31
|
-
return null;
|
|
32
|
-
return new Date(epoch * 1000).toISOString();
|
|
33
|
-
}
|
|
24
|
+
import { allTyped, readGlobalStore } from '../db-connections.js';
|
|
34
25
|
/**
|
|
35
26
|
* Returns all BrainNodes and BrainEdges sourced from the Agent Registry.
|
|
36
27
|
*
|
|
37
|
-
* Fetches
|
|
38
|
-
*
|
|
28
|
+
* Fetches the most recently registered active agents. Agent nodes serve as
|
|
29
|
+
* the cross-substrate identity anchors.
|
|
39
30
|
*
|
|
40
31
|
* @param options - Query options (limit).
|
|
41
|
-
* @returns Nodes and edges from the AGENT-REGISTRY substrate.
|
|
32
|
+
* @returns Nodes (and no edges) from the AGENT-REGISTRY substrate.
|
|
42
33
|
*/
|
|
43
34
|
export function getAgentRegistrySubstrate(options = {}) {
|
|
44
|
-
const db = getAgentRegistryDb();
|
|
45
|
-
if (!db)
|
|
46
|
-
return { nodes: [], edges: [] };
|
|
47
35
|
const perSubstrateLimit = Math.ceil((options.limit ?? 500) / 5);
|
|
48
36
|
const nodes = [];
|
|
49
37
|
const edges = [];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
createdAt: epochToIso(row.created_at),
|
|
67
|
-
meta: {
|
|
68
|
-
status: row.status,
|
|
69
|
-
created_at: row.created_at,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
// Agent connections (declared social graph)
|
|
74
|
-
if (agentIds.size > 0) {
|
|
75
|
-
const placeholders = [...agentIds].map(() => '?').join(',');
|
|
76
|
-
const connRows = allTyped(db.prepare(`SELECT from_agent_id, to_agent_id, connection_type, strength
|
|
77
|
-
FROM agent_connections
|
|
78
|
-
WHERE from_agent_id IN (${placeholders})
|
|
79
|
-
AND to_agent_id IN (${placeholders})`), ...agentIds, ...agentIds);
|
|
80
|
-
for (const row of connRows) {
|
|
81
|
-
edges.push({
|
|
82
|
-
source: `agent-registry:${row.from_agent_id}`,
|
|
83
|
-
target: `agent-registry:${row.to_agent_id}`,
|
|
84
|
-
type: row.connection_type,
|
|
85
|
-
weight: row.strength ?? 0.5,
|
|
38
|
+
readGlobalStore((db) => {
|
|
39
|
+
try {
|
|
40
|
+
// created_at is ISO text; a legacy epoch-seconds integer is converted too.
|
|
41
|
+
const agentRows = allTyped(db.prepare(`SELECT agent_id, name, status,
|
|
42
|
+
CASE WHEN typeof(created_at) = 'integer'
|
|
43
|
+
THEN strftime('%Y-%m-%dT%H:%M:%S', created_at, 'unixepoch')
|
|
44
|
+
ELSE strftime('%Y-%m-%dT%H:%M:%S', created_at)
|
|
45
|
+
END AS created_at
|
|
46
|
+
FROM main.agent_registry_agents
|
|
47
|
+
WHERE is_active = 1
|
|
48
|
+
ORDER BY created_at DESC
|
|
49
|
+
LIMIT ?`), perSubstrateLimit);
|
|
50
|
+
for (const row of agentRows) {
|
|
51
|
+
nodes.push({
|
|
52
|
+
id: `agent-registry:${row.agent_id}`,
|
|
53
|
+
kind: 'agent',
|
|
86
54
|
substrate: 'agent-registry',
|
|
55
|
+
label: row.name,
|
|
56
|
+
weight: row.status === 'online' ? 1.0 : 0.5,
|
|
57
|
+
createdAt: row.created_at,
|
|
58
|
+
meta: {
|
|
59
|
+
status: row.status,
|
|
60
|
+
created_at: row.created_at,
|
|
61
|
+
},
|
|
87
62
|
});
|
|
88
63
|
}
|
|
89
64
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
65
|
+
catch {
|
|
66
|
+
// Return partial results on error
|
|
67
|
+
}
|
|
68
|
+
});
|
|
94
69
|
return { nodes, edges };
|
|
95
70
|
}
|
|
96
71
|
//# sourceMappingURL=agent-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-registry.js","sourceRoot":"","sources":["../../../src/adapters/agent-registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent-registry.js","sourceRoot":"","sources":["../../../src/adapters/agent-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAYjE;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,UAA6B,EAAE;IAIvE,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhE,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,2EAA2E;YAC3E,MAAM,SAAS,GAAG,QAAQ,CACxB,EAAE,CAAC,OAAO,CACR;;;;;;;;mBAQS,CACV,EACD,iBAAiB,CAClB,CAAC;YAEF,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;gBAC5B,KAAK,CAAC,IAAI,CAAC;oBACT,EAAE,EAAE,kBAAkB,GAAG,CAAC,QAAQ,EAAE;oBACpC,IAAI,EAAE,OAAO;oBACb,SAAS,EAAE,gBAAgB;oBAC3B,KAAK,EAAE,GAAG,CAAC,IAAI;oBACf,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;oBAC3C,SAAS,EAAE,GAAG,CAAC,UAAU;oBACzB,IAAI,EAAE;wBACJ,MAAM,EAAE,GAAG,CAAC,MAAM;wBAClB,UAAU,EAAE,GAAG,CAAC,UAAU;qBAC3B;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BRAIN substrate adapter for the Living Brain API.
|
|
3
3
|
*
|
|
4
|
-
* Queries
|
|
4
|
+
* Queries the project `cleo.db` and returns BrainNodes/BrainEdges for all typed
|
|
5
|
+
* memory tables:
|
|
5
6
|
* observations, decisions, patterns, learnings, plus the graph layer
|
|
6
7
|
* (brain_page_nodes / brain_page_edges).
|
|
7
8
|
*
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
*/
|
|
16
17
|
import type { BrainEdge, BrainNode, BrainQueryOptions } from '../types.js';
|
|
17
18
|
/**
|
|
18
|
-
* Returns all BrainNodes and BrainEdges sourced from
|
|
19
|
+
* Returns all BrainNodes and BrainEdges sourced from the project `cleo.db`.
|
|
19
20
|
*
|
|
20
21
|
* Pulls from all four typed memory tables plus brain_page_edges.
|
|
21
22
|
* Emits intra-brain edges between loaded nodes, cross-substrate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/adapters/brain.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/adapters/brain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAyH3E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG;IAClE,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAuPA"}
|