agentopology 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +69 -3
  2. package/dist/bindings/claude-code.d.ts.map +1 -1
  3. package/dist/bindings/claude-code.js +100 -2
  4. package/dist/bindings/claude-code.js.map +1 -1
  5. package/dist/cli/index.js +195 -2
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/parser/__tests__/parser.test.js +170 -0
  8. package/dist/parser/__tests__/parser.test.js.map +1 -1
  9. package/dist/parser/ast.d.ts +39 -0
  10. package/dist/parser/ast.d.ts.map +1 -1
  11. package/dist/parser/index.d.ts.map +1 -1
  12. package/dist/parser/index.js +58 -2
  13. package/dist/parser/index.js.map +1 -1
  14. package/dist/parser/validator.d.ts.map +1 -1
  15. package/dist/parser/validator.js +66 -3
  16. package/dist/parser/validator.js.map +1 -1
  17. package/dist/visualizer/__tests__/brain.test.d.ts +2 -0
  18. package/dist/visualizer/__tests__/brain.test.d.ts.map +1 -0
  19. package/dist/visualizer/__tests__/brain.test.js +138 -0
  20. package/dist/visualizer/__tests__/brain.test.js.map +1 -0
  21. package/dist/visualizer/__tests__/topology-brain-link.test.d.ts +2 -0
  22. package/dist/visualizer/__tests__/topology-brain-link.test.d.ts.map +1 -0
  23. package/dist/visualizer/__tests__/topology-brain-link.test.js +41 -0
  24. package/dist/visualizer/__tests__/topology-brain-link.test.js.map +1 -0
  25. package/dist/visualizer/brain.d.ts +97 -0
  26. package/dist/visualizer/brain.d.ts.map +1 -0
  27. package/dist/visualizer/brain.js +473 -0
  28. package/dist/visualizer/brain.js.map +1 -0
  29. package/dist/visualizer/index.d.ts +19 -1
  30. package/dist/visualizer/index.d.ts.map +1 -1
  31. package/dist/visualizer/index.js +26 -11
  32. package/dist/visualizer/index.js.map +1 -1
  33. package/examples/company-brain-team.at +241 -0
  34. package/examples/company-brain.at +104 -0
  35. package/examples/logos/gmail.svg +1 -0
  36. package/examples/logos/slack.svg +1 -0
  37. package/package.json +1 -1
  38. package/spec/grammar.md +30 -2
@@ -0,0 +1,241 @@
1
+ # company-brain-team.at — A team of agents that build & maintain a company brain
2
+ #
3
+ # The flagship "company brain" topology. A folder of Obsidian-format markdown,
4
+ # fed and maintained by a TEAM — not one librarian:
5
+ #
6
+ # 📧 gmail-ingester ─┐
7
+ # 💬 slack-ingester ─┼─► drop raw notes into brain/ ─► 👤 librarian wires them
8
+ # 📅 calendar-ingester ─┘ (each owns ONE source) (links, tags, hubs)
9
+ # ─► 🔍 auditor heals the graph
10
+ #
11
+ # - Ingesters are scheduled — they pull from their source and write raw markdown.
12
+ # - The librarian is custodian-of the brain: it wires dropped notes into the graph.
13
+ # - The auditor is custodian-of the brain too: it heals broken links, surfaces
14
+ # ghost nodes, and flags duplicates.
15
+ # - A researcher reads the brain to answer questions.
16
+ #
17
+ # This is the whitespace: declarative + multi-agent team + Obsidian-portable +
18
+ # agents own memory layers. Demonstrates `brain` + `custodian-of` + ingestion.
19
+
20
+ topology company-brain-team : [brain, event-driven, human-gate] {
21
+
22
+ meta {
23
+ version: "0.1.0"
24
+ description: "A team of agents that ingest, wire, and maintain a company brain"
25
+ }
26
+
27
+ # --- The brain: one Obsidian-format markdown vault, no database ---
28
+
29
+ memory {
30
+ store brain {
31
+ type: brain
32
+ description: "The company brain — fed by ingesters, wired by the librarian"
33
+ path: "brain/"
34
+ format: obsidian
35
+ scope: org
36
+
37
+ # Presentation only — colors/icons for the graph view, by provenance.
38
+ # A note's `source:` frontmatter (stamped by its ingester) maps to a look.
39
+ # Cosmetic: bindings ignore this; delete it and the brain works the same.
40
+ sources {
41
+ gmail {
42
+ color: "#EA4335"
43
+ icon: "./logos/gmail.svg"
44
+ }
45
+ slack {
46
+ color: "#4A154B"
47
+ icon: "./logos/slack.svg"
48
+ }
49
+ calendar {
50
+ color: "#4285F4"
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ # --- Ingesters: each owns ONE external source, writes raw notes ---
57
+
58
+ agent gmail-ingester {
59
+ model: sonnet
60
+ description: "Pulls notable emails and writes them as raw notes into the brain"
61
+ tools: [Read, Write, Grep, Glob]
62
+ mcp-servers: [gmail]
63
+ writes: ["brain/"]
64
+
65
+ prompt {
66
+ You ingest email into the brain. On each run:
67
+ - Pull recent notable threads (decisions, deals, intros, commitments).
68
+ - For each, write ONE raw markdown note into `brain/` with a clear title
69
+ and YAML frontmatter (date, source: gmail, participants).
70
+ - Do NOT wire links or tags — that is the librarian's job. Just capture
71
+ the content faithfully. Skip noise (newsletters, automated mail).
72
+ }
73
+ }
74
+
75
+ agent slack-ingester {
76
+ model: sonnet
77
+ description: "Captures key Slack decisions and threads as raw notes"
78
+ tools: [Read, Write, Grep, Glob]
79
+ mcp-servers: [slack]
80
+ writes: ["brain/"]
81
+
82
+ prompt {
83
+ You ingest Slack into the brain. On each run, capture threads where a
84
+ decision was made, a commitment given, or knowledge shared. Write each
85
+ as ONE raw markdown note in `brain/` with frontmatter (date, source:
86
+ slack, channel). Leave linking and tagging to the librarian.
87
+ }
88
+ }
89
+
90
+ agent calendar-ingester {
91
+ model: sonnet
92
+ description: "Turns meetings into raw notes (attendees, outcomes)"
93
+ tools: [Read, Write, Grep, Glob]
94
+ mcp-servers: [calendar]
95
+ writes: ["brain/"]
96
+
97
+ prompt {
98
+ You ingest calendar events into the brain. For meetings that mattered,
99
+ write ONE raw markdown note in `brain/` with frontmatter (date, source:
100
+ calendar, attendees) and any outcomes/notes you can infer. No linking —
101
+ that is the librarian's job.
102
+ }
103
+ }
104
+
105
+ # --- Librarian: custodian that WIRES dropped notes into the graph ---
106
+
107
+ agent librarian {
108
+ model: sonnet
109
+ description: "Wires raw notes into the brain graph — links, tags, hubs"
110
+ tools: [Read, Write, Edit, Grep, Glob]
111
+
112
+ custodian-of: [brain] {
113
+ does: [link, tag, index, dedupe]
114
+ }
115
+
116
+ prompt {
117
+ You are the brain's librarian. Raw notes arrive from the ingesters and
118
+ from humans. You never invent content — you wire what is dropped in.
119
+ Resolve mentions into [[wikilinks]], assign #nested/tags, keep the hub
120
+ notes current, and flag duplicates. Leave ghost links to mark gaps.
121
+ }
122
+ }
123
+
124
+ # --- Auditor: custodian that keeps the whole graph HEALTHY ---
125
+
126
+ agent auditor {
127
+ model: opus
128
+ description: "Heals the brain — broken links, ghost nodes, orphans, dupes"
129
+ tools: [Read, Edit, Grep, Glob]
130
+
131
+ custodian-of: [brain] {
132
+ does: [heal, dedupe, index]
133
+ }
134
+
135
+ prompt {
136
+ You audit the brain's health. Find and repair broken [[links]] after
137
+ renames, surface ghost nodes (links to notes that don't exist), flag
138
+ orphan notes (nothing links to them), and propose merges for duplicates.
139
+ Conservative: repair links and report issues — never delete a human's note.
140
+ }
141
+ }
142
+
143
+ # --- Researcher: READS the brain to answer questions ---
144
+
145
+ agent researcher {
146
+ model: sonnet
147
+ description: "Answers questions by traversing the brain"
148
+ tools: [Read, Grep, Glob]
149
+ memory: [brain]
150
+
151
+ prompt {
152
+ Answer questions using only the brain in `brain/`. Grep for relevant
153
+ notes, follow their [[wikilinks]] and #tags, and cite notes by filename.
154
+ }
155
+ }
156
+
157
+ # --- Actions (flow entry/exit points) ---
158
+
159
+ action wire-in {
160
+ kind: inline
161
+ description: "Fold a dropped or freshly-ingested note into the brain"
162
+ }
163
+
164
+ action audit {
165
+ kind: report
166
+ description: "Report the brain's health: ghosts, orphans, broken links, dupes"
167
+ }
168
+
169
+ action query {
170
+ kind: inline
171
+ description: "Ask the brain a question"
172
+ }
173
+
174
+ # --- Flow: ingesters feed the librarian; auditor runs after; researcher reads ---
175
+
176
+ flow {
177
+ gmail-ingester -> wire-in
178
+ slack-ingester -> wire-in
179
+ calendar-ingester -> wire-in
180
+ wire-in -> librarian
181
+ librarian -> auditor
182
+ auditor -> audit
183
+ query -> researcher
184
+ }
185
+
186
+ # --- Schedule: ingesters and the auditor run on their own cadence ---
187
+
188
+ schedule {
189
+ job pull-email {
190
+ cron: "0 */2 * * *"
191
+ agent: gmail-ingester
192
+ }
193
+ job pull-slack {
194
+ cron: "0 */2 * * *"
195
+ agent: slack-ingester
196
+ }
197
+ job pull-calendar {
198
+ cron: "0 8 * * *"
199
+ agent: calendar-ingester
200
+ }
201
+ job nightly-audit {
202
+ cron: "0 3 * * *"
203
+ agent: auditor
204
+ }
205
+ }
206
+
207
+ # --- Triggers: humans can wire a file or ask the brain anytime ---
208
+
209
+ triggers {
210
+ command wire-in {
211
+ pattern: "/wire-in <FILE>"
212
+ argument: FILE
213
+ description: "Fold a dropped markdown file into the brain"
214
+ }
215
+ command query {
216
+ pattern: "/ask <QUESTION>"
217
+ argument: QUESTION
218
+ description: "Ask the brain a question"
219
+ }
220
+ }
221
+
222
+ # --- External sources the ingesters connect to ---
223
+
224
+ mcp-servers {
225
+ gmail {
226
+ type: stdio
227
+ command: "npx"
228
+ args: ["-y", "gmail-mcp-server"]
229
+ }
230
+ slack {
231
+ type: stdio
232
+ command: "npx"
233
+ args: ["-y", "slack-mcp-server"]
234
+ }
235
+ calendar {
236
+ type: stdio
237
+ command: "npx"
238
+ args: ["-y", "calendar-mcp-server"]
239
+ }
240
+ }
241
+ }
@@ -0,0 +1,104 @@
1
+ # company-brain.at — A plug-and-play company brain
2
+ #
3
+ # A folder of Obsidian-format markdown, maintained by agents, not by hand.
4
+ # - Humans drop a new note and run /wire-in. The librarian links & tags it.
5
+ # - The researcher traverses the [[link]] graph (with grep) to answer questions.
6
+ # - No vector DB, no MCP server. The brain is a folder you can git clone and
7
+ # open in Obsidian for the graph view.
8
+ #
9
+ # Demonstrates the `brain` PATTERN + the `custodian-of` PRIMITIVE.
10
+
11
+ topology company-brain : [brain, human-gate] {
12
+
13
+ meta {
14
+ version: "0.1.0"
15
+ description: "An agent-maintained, Obsidian-portable company brain"
16
+ }
17
+
18
+ # --- The brain itself: one markdown store, no backend ---
19
+
20
+ memory {
21
+ store brain {
22
+ type: brain # NEW store type — no DB, just files
23
+ description: "The company brain — a folder of linked markdown"
24
+ path: "brain/" # this folder IS a valid Obsidian vault
25
+ format: obsidian # [[wikilinks]], #nested/tags, YAML frontmatter
26
+ scope: org
27
+ }
28
+ }
29
+
30
+ # --- The librarian: KEEPER of the brain (the new primitive) ---
31
+
32
+ agent librarian {
33
+ model: sonnet
34
+ description: "Maintains the brain — wires new notes into the graph"
35
+ tools: [Read, Write, Edit, Grep, Glob]
36
+
37
+ custodian-of: [brain] { # owns upkeep, not just read access
38
+ does: [link, tag, index, dedupe] # OPTIONAL verbs — visible strategy
39
+ }
40
+
41
+ prompt {
42
+ You are the brain's librarian. The brain lives in `brain/` as Obsidian
43
+ markdown. You never invent content — you wire what's dropped in.
44
+
45
+ When a note is added or changed:
46
+ - link: find mentions of existing notes and turn them into [[wikilinks]]
47
+ - tag: add #nested/tags consistent with the existing tag hierarchy
48
+ - index: update the relevant hub note (a Map-of-Content that [[links]]
49
+ the cluster) so the new note is reachable
50
+ - dedupe: flag near-duplicate notes for human review; never auto-delete
51
+
52
+ Backlinks are computed from the [[links]] you write — never author them
53
+ by hand. If a note links to something that doesn't exist yet, leave the
54
+ ghost link; it marks a gap to fill later.
55
+ }
56
+ }
57
+
58
+ # --- The researcher: READS the brain to answer questions ---
59
+
60
+ agent researcher {
61
+ model: sonnet
62
+ description: "Answers questions by traversing the brain"
63
+ tools: [Read, Grep, Glob]
64
+ memory: [brain] # read access — the ordinary wiring
65
+
66
+ prompt {
67
+ Answer questions using only the brain in `brain/`. Start by grepping for
68
+ relevant notes, then follow their [[wikilinks]] and #tags to gather the
69
+ full picture. Cite the notes you used by filename.
70
+ }
71
+ }
72
+
73
+ # --- What the human can do (actions are the flow entry points) ---
74
+
75
+ action wire-in {
76
+ kind: inline
77
+ description: "Fold a dropped markdown file into the brain"
78
+ }
79
+
80
+ action query {
81
+ kind: inline
82
+ description: "Ask the brain a question"
83
+ }
84
+
85
+ triggers {
86
+ command wire-in {
87
+ pattern: "/wire-in <FILE>"
88
+ argument: FILE
89
+ description: "Fold a dropped markdown file into the brain"
90
+ }
91
+ command query {
92
+ pattern: "/ask <QUESTION>"
93
+ argument: QUESTION
94
+ description: "Ask the brain a question"
95
+ }
96
+ }
97
+
98
+ # --- Flow ---
99
+
100
+ flow {
101
+ wire-in -> librarian # human drops a file → librarian wires it
102
+ query -> researcher # human asks → researcher traverses & answers
103
+ }
104
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path fill="#fff" d="M6 12h36v26H6z"/><path fill="#EA4335" d="M6 14v3l18 12L42 17v-3l-18 12z"/><path fill="#FBBC04" d="M6 14v22h6V18l12 8 12-8v18h6V14l-18 12z" opacity=".9"/><path fill="#34A853" d="M6 36h6V18l-6-4z"/><path fill="#4285F4" d="M42 36h-6V18l6-4z"/><path fill="#C5221F" d="M6 14l18 12L42 14v-2H6z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path fill="#36C5F0" d="M18 6a4 4 0 100 8h4V10a4 4 0 00-4-4z"/><path fill="#2EB67D" d="M42 18a4 4 0 10-8 0v4h4a4 4 0 004-4z"/><path fill="#ECB22E" d="M30 42a4 4 0 100-8h-4v4a4 4 0 004 4z"/><path fill="#E01E5A" d="M6 30a4 4 0 108 0v-4h-4a4 4 0 00-4 4z"/><path fill="#36C5F0" d="M18 18h8v8h-8z" opacity=".7"/></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentopology",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "The declarative language for multi-agent systems. Write once, scaffold for any platform.",
5
5
  "author": "Nadav Naveh",
6
6
  "license": "Apache-2.0",
package/spec/grammar.md CHANGED
@@ -207,6 +207,7 @@ perm-enum = perm-identifier
207
207
  | `fan-out` | Parallel slices |
208
208
  | `event-driven` | Pub-sub |
209
209
  | `human-gate` | Human approval points |
210
+ | `brain` | Agent-maintained, Obsidian-portable markdown knowledge graph |
210
211
 
211
212
  ---
212
213
 
@@ -360,6 +361,7 @@ scale-field = 'mode' ':' ('auto' | 'fixed' | 'config')
360
361
  | `behavior` | `advisory` / `blocking` | no | `blocking` | Advisory never blocks flow |
361
362
  | `memory` | name-list | no | `[]` | Store IDs this agent can access (V35) |
362
363
  | `retrieval` | identifier | no | -- | Retrieval strategy ID for memory queries (V35) |
364
+ | `custodian-of` | name-list `{ does: name-list }?` | no | -- | Store IDs this agent **maintains** (not just reads). The primitive behind the `brain` pattern. Optional `does:` declares maintenance verbs (e.g. `link, tag, index, dedupe`). Refs validated by V88. |
363
365
  | `skills` | name-list | no | `[]` | Skills to preload |
364
366
  | `mcp-servers` | name-list | no | `[]` | MCP servers available |
365
367
  | `background` | boolean | no | `false` | Run in background |
@@ -531,7 +533,7 @@ store-field = 'type' ':' store-type
531
533
  | lifecycle-block
532
534
  | backend-config-block
533
535
  store-type = 'semantic' | 'episodic' | 'procedural' | 'entity'
534
- | 'graph' | 'user' | 'session' | 'temporal'
536
+ | 'graph' | 'user' | 'session' | 'temporal' | 'brain'
535
537
  scope-enum = 'agent' | 'user' | 'session' | 'org' | 'global'
536
538
  isolation-enum = 'strict' | 'soft' | 'none'
537
539
  backend-enum = 'lancedb' | 'sqlite-vec' | 'chroma' | 'kuzu' | 'falkordb'
@@ -639,10 +641,12 @@ memory {
639
641
  | `description` | string | no | -- | Human-readable purpose |
640
642
  | `scope` | scope-enum | no | -- | Access scope (V32 warning if omitted) |
641
643
  | `isolation` | isolation-enum | no | -- | Isolation level between scopes |
642
- | `backend` | backend-enum | yes | -- | Storage backend (V30 enum check) |
644
+ | `backend` | backend-enum | yes | -- | Storage backend (V30 enum check). For `type: brain`, defaults to `files` and is exempt from the enum check (V81). |
643
645
  | `path` | string | no | -- | File system path for local backends |
644
646
  | `connection` | secret-string | no | -- | Connection URI for remote backends (V34) |
645
647
  | `extraction` | extraction-enum | no | -- | Entity/fact extraction method |
648
+ | `format` | string | no | -- | File format/convention for file-native stores. For `brain`, typically `obsidian` ([[wikilinks]], #tags, YAML frontmatter) — a promise the store round-trips as a real Obsidian vault. |
649
+ | `sources` | sources-block | no | -- | **Presentation only** — provenance styling for the brain graph view. Maps a note's `source:` frontmatter to a color/icon. Visualizer-only; bindings ignore it. See below. |
646
650
  | `embedding` | embedding-block | no | -- | Embedding configuration (V31 warning if omitted for semantic/episodic/procedural) |
647
651
  | `index` | index-block | no | -- | Index/collection configuration |
648
652
  | `ingestion` | ingestion-block | no | -- | Data ingestion configuration |
@@ -654,6 +658,30 @@ memory {
654
658
 
655
659
  **`backend-config`:** A passthrough block for backend-specific key-value pairs not covered by the standard fields. Stored as `Record<string, unknown>` on the AST. Same pattern as `ProviderDef.extra`.
656
660
 
661
+ **The `brain` store type (file-native).** A `brain` store is the file-native memory primitive behind the `brain` pattern: a folder of Obsidian-format markdown where the graph is a *projection* of the files, not a separate database. It is deliberately backend-less — its `backend` defaults to `files` and is exempt from the backend-enum check (V81), it needs no embedding (V82), and it compiles to direct file access (no MCP server). Edges come from inline `[[wikilinks]]` and `#tags`; backlinks are computed. Because the format is Obsidian, a `brain` store round-trips as a real Obsidian vault — agents build it, a human opens it in Obsidian for the graph view, and an existing vault becomes an agent-readable brain with zero migration. Heavyweight stores (`semantic`, `graph`, `entity`) remain available as an opt-in power-up alongside a brain. See `docs/company-brain-design.md`.
662
+
663
+ **Custody (`custodian-of`).** Custody is the one new primitive the brain pattern needs. `memory:` grants an agent *read* access to a store; `custodian-of:` makes the agent *responsible for the store's upkeep* — wiring dropped files into the graph (resolving mentions into `[[wikilinks]]`, assigning `#tags`, updating index/hub notes, flagging ghost nodes and duplicates). The optional `does:` sub-list declares the maintenance verbs as visible architecture (like an optional type annotation); omitting it lets the agent infer its duties from its prompt. The verb *names* are language vocabulary; *how* each verb is performed well is an implementation/skill concern, not part of the spec. V88 validates that every `custodian-of` reference resolves to a declared store and warns when custody targets a non-brain store.
664
+
665
+ **Provenance styling (`sources`).** A presentation-only sub-block on a brain store that colors the graph view by where each note came from. Each named entry maps a source key (matching a note's `source:` frontmatter, stamped by its ingester) to a `color` (hex) and/or `icon` (a file path):
666
+
667
+ ```
668
+ store brain {
669
+ type: brain
670
+ path: "brain/"
671
+ sources {
672
+ gmail {
673
+ color: "#EA4335"
674
+ icon: "./logos/gmail.svg"
675
+ }
676
+ slack {
677
+ color: "#4A154B"
678
+ }
679
+ }
680
+ }
681
+ ```
682
+
683
+ This is **strictly cosmetic and affects only the `visualize-brain` rendering** — it never touches ingestion, agents, files, or binding output. Bindings emit nothing for it; delete it and the brain behaves identically (the graph just falls back to category coloring). The language stores **no image bytes** — only the path string; the visualizer reads the icon file at generate-time and inlines it as a `data:` URI, keeping the output a single self-contained HTML file. When a node's `source` matches a `sources` key, it is colored/iconed accordingly; otherwise it falls back to category-based coloring (person/org/topic inferred from tag namespaces).
684
+
657
685
  **Local vs remote backends:** Backends `lancedb`, `sqlite-vec`, `sqlite`, `kuzu`, and `chroma` are local-first (use `path`). Backends `pinecone`, `qdrant`, `pgvector`, `neo4j`, `mongodb`, and `falkordb` are remote (require `connection`, V34).
658
686
 
659
687
  ##### `embedding` sub-block