@rubytech/create-realagent 1.0.806 → 1.0.807

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-realagent",
3
- "version": "1.0.806",
3
+ "version": "1.0.807",
4
4
  "description": "Install Real Agent — Built for agents. By agents.",
5
5
  "bin": {
6
6
  "create-realagent": "./dist/index.js"
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Migration 004 — Project the admin agent into the graph and clean up
3
+ * Conversation channel data (Task 864). Numbered 004 because the 003
4
+ * slot is held by `003-person-name-eradicate.cypher` (boot-time apply).
5
+ *
6
+ * Three idempotent passes:
7
+ *
8
+ * 1. For every account directory under data/accounts/<accountId>/agents/admin/
9
+ * that carries a config.json, call projectAgent(accountId, accountDir,
10
+ * 'admin'). The projector is the same function migration 002 uses for
11
+ * public agents and is content-agnostic — it reads config.json plus any
12
+ * IDENTITY/SOUL/KNOWLEDGE/KNOWLEDGE-SUMMARY files present and MERGEs the
13
+ * :Agent node + four owned :KnowledgeDocument projections. Re-running
14
+ * this migration produces no duplicate nodes or edges.
15
+ *
16
+ * Migration 002 explicitly SKIPS admin (line 60: `if (entry.name ===
17
+ * "admin") continue`); doing the projection here keeps that skip valid
18
+ * and isolates admin-specific concerns to one file.
19
+ *
20
+ * 2. For every existing :AdminConversation that does NOT yet have a
21
+ * :HANDLED_BY edge, MATCH the freshly-projected admin :Agent and MERGE
22
+ * the edge. Guarded with `WHERE NOT EXISTS((c)-[:HANDLED_BY]->(:Agent))`
23
+ * so re-runs short-circuit per conversation.
24
+ *
25
+ * 3. Backfill `c.channel = 'webchat'` for every Conversation node where
26
+ * channel IS NULL. Pre-Task-863 conversations were written without the
27
+ * property; channel='webchat' is the correct default — only WhatsApp
28
+ * and Telegram sessions ever set non-webchat values, and those have
29
+ * always come through sessionKeys prefixed `whatsapp:` or `telegram:`
30
+ * (see neo4j-store.ts:171). Idempotent: subsequent runs no-op because
31
+ * the WHERE clause matches zero rows.
32
+ *
33
+ * Run via the platform/ui standalone runtime so it picks up the same
34
+ * NEO4J_URI / accounts-directory resolution as the server:
35
+ *
36
+ * cd platform/ui && \
37
+ * NEO4J_URI=bolt://… NEO4J_PASSWORD=… \
38
+ * npx tsx ../neo4j/migrations/004-project-admin-agent.ts
39
+ *
40
+ * Output: structured `[admin-agent-graph-backfill]` lines per account + a
41
+ * final totals line. Non-zero exit code on any per-account agent-projection
42
+ * failure surfaces to the operator; subsequent accounts are still attempted.
43
+ */
44
+
45
+ import { existsSync, readdirSync } from "node:fs";
46
+ import { resolve } from "node:path";
47
+ import { projectAgent, getSession } from "../../ui/app/lib/neo4j-store";
48
+ import { ACCOUNTS_DIR } from "../../ui/app/lib/claude-agent/account";
49
+
50
+ interface PerAccountStats {
51
+ accountId: string;
52
+ projected: 0 | 1;
53
+ failed: 0 | 1;
54
+ handledByCandidates: number;
55
+ handledByEdges: number;
56
+ channelBackfilled: number;
57
+ }
58
+
59
+ async function projectAccountAdmin(
60
+ accountId: string,
61
+ accountDir: string,
62
+ ): Promise<{ projected: 0 | 1; failed: 0 | 1 }> {
63
+ const adminDir = resolve(accountDir, "agents", "admin");
64
+ const configPath = resolve(adminDir, "config.json");
65
+ if (!existsSync(adminDir) || !existsSync(configPath)) {
66
+ return { projected: 0, failed: 0 };
67
+ }
68
+ try {
69
+ await projectAgent(accountId, accountDir, "admin");
70
+ return { projected: 1, failed: 0 };
71
+ } catch (err) {
72
+ const msg = err instanceof Error ? err.message : String(err);
73
+ console.error(
74
+ `[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} project FAILED error="${msg}"`,
75
+ );
76
+ return { projected: 0, failed: 1 };
77
+ }
78
+ }
79
+
80
+ interface HandledByStats {
81
+ candidates: number;
82
+ edges: number;
83
+ }
84
+
85
+ /**
86
+ * Backfill HANDLED_BY edges from AdminConversation nodes to the admin Agent
87
+ * node. Guarded with NOT EXISTS so re-runs of this migration don't redo work
88
+ * — and so AdminConversations that already gained a HANDLED_BY edge through
89
+ * the forward path are skipped.
90
+ *
91
+ * `candidates` counts AdminConversations that LACK a HANDLED_BY edge; `edges`
92
+ * counts edges newly created. The admin :Agent must already exist (created
93
+ * by pass 1); if it doesn't, the OPTIONAL MATCH falls through and zero edges
94
+ * are written — surfaced through `candidates - edges`.
95
+ */
96
+ async function backfillAdminHandledBy(
97
+ accountId: string,
98
+ ): Promise<HandledByStats> {
99
+ const session = getSession();
100
+ try {
101
+ const result = await session.run(
102
+ `MATCH (c:AdminConversation {accountId: $accountId})
103
+ WHERE NOT EXISTS((c)-[:HANDLED_BY]->(:Agent))
104
+ OPTIONAL MATCH (a:Agent {accountId: $accountId, slug: 'admin'})
105
+ FOREACH (_ IN CASE WHEN a IS NULL THEN [] ELSE [1] END | MERGE (c)-[:HANDLED_BY]->(a))
106
+ RETURN
107
+ count(c) AS candidates,
108
+ sum(CASE WHEN a IS NULL THEN 0 ELSE 1 END) AS edges`,
109
+ { accountId },
110
+ );
111
+ const toNum = (v: unknown): number => {
112
+ if (typeof v === "number") return v;
113
+ if (v && typeof (v as { toNumber: () => number }).toNumber === "function") {
114
+ return (v as { toNumber: () => number }).toNumber();
115
+ }
116
+ return 0;
117
+ };
118
+ return {
119
+ candidates: toNum(result.records[0]?.get("candidates")),
120
+ edges: toNum(result.records[0]?.get("edges")),
121
+ };
122
+ } finally {
123
+ await session.close();
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Backfill `c.channel = 'webchat'` on Conversation nodes that lack the
129
+ * property. Hits both AdminConversation and PublicConversation — the
130
+ * predicate is `c.channel IS NULL`, label-agnostic.
131
+ *
132
+ * Why default to 'webchat': new writes set channel from sessionKey prefix
133
+ * (neo4j-store.ts:171). Only `whatsapp:` and `telegram:` prefixes produce
134
+ * non-webchat values, and those prefixes have always existed. So a NULL
135
+ * channel can only mean "Conversation written before Task 863 added the
136
+ * SET clause" — which by definition was a webchat session.
137
+ *
138
+ * Idempotent: WHERE clause matches zero rows on re-run.
139
+ */
140
+ async function backfillChannel(accountId: string): Promise<number> {
141
+ const session = getSession();
142
+ try {
143
+ const result = await session.run(
144
+ `MATCH (c:Conversation {accountId: $accountId})
145
+ WHERE c.channel IS NULL
146
+ SET c.channel = 'webchat'
147
+ RETURN count(c) AS backfilled`,
148
+ { accountId },
149
+ );
150
+ const raw = result.records[0]?.get("backfilled");
151
+ if (typeof raw === "number") return raw;
152
+ if (raw && typeof (raw as { toNumber: () => number }).toNumber === "function") {
153
+ return (raw as { toNumber: () => number }).toNumber();
154
+ }
155
+ return 0;
156
+ } finally {
157
+ await session.close();
158
+ }
159
+ }
160
+
161
+ async function main(): Promise<void> {
162
+ const start = Date.now();
163
+
164
+ if (!existsSync(ACCOUNTS_DIR)) {
165
+ console.error(
166
+ `[admin-agent-graph-backfill] ACCOUNTS_DIR missing at ${ACCOUNTS_DIR} — nothing to do`,
167
+ );
168
+ process.exit(0);
169
+ }
170
+
171
+ const accountEntries = readdirSync(ACCOUNTS_DIR, { withFileTypes: true })
172
+ .filter((e) => e.isDirectory());
173
+
174
+ console.error(
175
+ `[admin-agent-graph-backfill] start accounts=${accountEntries.length}`,
176
+ );
177
+
178
+ let totalProjected = 0;
179
+ let totalFailed = 0;
180
+ let totalHandledByCandidates = 0;
181
+ let totalHandledByEdges = 0;
182
+ let totalChannelBackfilled = 0;
183
+ const perAccount: PerAccountStats[] = [];
184
+
185
+ for (const entry of accountEntries) {
186
+ const accountDir = resolve(ACCOUNTS_DIR, entry.name);
187
+ const accountId = entry.name;
188
+ const accountStart = Date.now();
189
+
190
+ const { projected, failed } = await projectAccountAdmin(
191
+ accountId,
192
+ accountDir,
193
+ );
194
+ totalProjected += projected;
195
+ totalFailed += failed;
196
+
197
+ let handledByStats: HandledByStats = { candidates: 0, edges: 0 };
198
+ let channelBackfilled = 0;
199
+
200
+ try {
201
+ handledByStats = await backfillAdminHandledBy(accountId);
202
+ totalHandledByCandidates += handledByStats.candidates;
203
+ totalHandledByEdges += handledByStats.edges;
204
+ } catch (err) {
205
+ const msg = err instanceof Error ? err.message : String(err);
206
+ console.error(
207
+ `[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} handled-by-backfill FAILED error="${msg}"`,
208
+ );
209
+ }
210
+
211
+ try {
212
+ channelBackfilled = await backfillChannel(accountId);
213
+ totalChannelBackfilled += channelBackfilled;
214
+ } catch (err) {
215
+ const msg = err instanceof Error ? err.message : String(err);
216
+ console.error(
217
+ `[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} channel-backfill FAILED error="${msg}"`,
218
+ );
219
+ }
220
+
221
+ perAccount.push({
222
+ accountId,
223
+ projected,
224
+ failed,
225
+ handledByCandidates: handledByStats.candidates,
226
+ handledByEdges: handledByStats.edges,
227
+ channelBackfilled,
228
+ });
229
+ const ms = Date.now() - accountStart;
230
+ console.error(
231
+ `[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} projected=${projected} failed=${failed} handled-by-candidates=${handledByStats.candidates} handled-by-edges=${handledByStats.edges} channel-backfilled=${channelBackfilled} ms=${ms}`,
232
+ );
233
+ }
234
+
235
+ const ms = Date.now() - start;
236
+ console.error(
237
+ `[admin-agent-graph-backfill] done totals: projected=${totalProjected} failed=${totalFailed} handled-by-candidates=${totalHandledByCandidates} handled-by-edges=${totalHandledByEdges} channel-backfilled=${totalChannelBackfilled} ms=${ms}`,
238
+ );
239
+
240
+ process.exit(totalFailed > 0 ? 1 : 0);
241
+ }
242
+
243
+ main().catch((err) => {
244
+ const msg = err instanceof Error ? err.message : String(err);
245
+ console.error(`[admin-agent-graph-backfill] fatal error="${msg}"`);
246
+ process.exit(2);
247
+ });
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Migration 004 — Prune alien-account nodes (Task 847).
3
+ *
4
+ * Deletes every node whose `accountId` is not present on disk under
5
+ * `${DATA_ROOT}/accounts/<uuid>/account.json`. Idempotent — silent when
6
+ * the graph is already clean.
7
+ *
8
+ * Why a backstop, not a writer fix: the leaked nodes were written by the
9
+ * `review-digest-compose` writer, which has since been removed in favour
10
+ * of a coming gbrain rewrite. With no live writer to fix, this is the
11
+ * surface that catches future writer drift before the next gbrain ships.
12
+ *
13
+ * Hard guard: refuses to run when the on-disk account set is empty
14
+ * (corrupt-install scenario). Refusing to wipe the graph is louder than
15
+ * silently wiping it.
16
+ *
17
+ * Doctrine in `.docs/neo4j.md` "Account isolation invariant" requires
18
+ * any writer that stamps `n.accountId` to verify the value against
19
+ * `${DATA_ROOT}/accounts/<id>/account.json` before write. This migration
20
+ * is a backstop, not a license.
21
+ */
22
+
23
+ import { readFileSync, readdirSync } from "node:fs";
24
+ import { resolve } from "node:path";
25
+
26
+ const UUID_RE =
27
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
28
+
29
+ /**
30
+ * Structural alias for the `Driver` instance the runner passes in. We type
31
+ * structurally rather than importing `Driver` from `neo4j-driver` because
32
+ * this file lives outside `platform/ui/` — depending on the workspace's
33
+ * dedupe state, `neo4j-driver` resolves to a different node_modules copy
34
+ * here than at the runner site, and TS treats two same-shape types from
35
+ * different paths as nominally distinct. Structural typing sidesteps that.
36
+ */
37
+ type Neo4jDriverLike = {
38
+ session(): {
39
+ run(
40
+ cypher: string,
41
+ params?: Record<string, unknown>,
42
+ ): Promise<{ records: Array<{ get(key: string): unknown }> }>;
43
+ close(): Promise<void>;
44
+ };
45
+ };
46
+
47
+ export async function pruneAlienAccounts(
48
+ driver: Neo4jDriverLike,
49
+ platformRoot: string,
50
+ ): Promise<void> {
51
+ const accountsDir = resolve(platformRoot, "..", "data", "accounts");
52
+ const validIds = enumerateValidAccountIds(accountsDir);
53
+
54
+ if (validIds.size === 0) {
55
+ throw new Error(
56
+ `refusing to prune: no valid accounts found under ${accountsDir} — corrupt install? not deleting anything to avoid wiping the entire graph.`,
57
+ );
58
+ }
59
+
60
+ const valid = Array.from(validIds);
61
+ const session = driver.session();
62
+ try {
63
+ // Two-step: first query collects the alien accountIds for the log
64
+ // line, second query deletes. Two cheap queries beat a single query
65
+ // that loses either the count or the id list under DELETE semantics.
66
+ const peek = await session.run(
67
+ `MATCH (n)
68
+ WHERE n.accountId IS NOT NULL AND NOT n.accountId IN $valid
69
+ RETURN DISTINCT n.accountId AS aid`,
70
+ { valid },
71
+ );
72
+ const alienIds: string[] = [];
73
+ for (const record of peek.records) {
74
+ const aid: unknown = record.get("aid");
75
+ if (typeof aid === "string") alienIds.push(aid);
76
+ }
77
+
78
+ if (alienIds.length === 0) return;
79
+
80
+ const result = await session.run(
81
+ `MATCH (n)
82
+ WHERE n.accountId IS NOT NULL AND NOT n.accountId IN $valid
83
+ DETACH DELETE n
84
+ RETURN count(n) AS pruned`,
85
+ { valid },
86
+ );
87
+ const prunedRaw = result.records[0]?.get("pruned");
88
+ const pruned =
89
+ typeof prunedRaw === "number"
90
+ ? prunedRaw
91
+ : (prunedRaw as { toNumber?: () => number })?.toNumber?.() ?? 0;
92
+ console.error(
93
+ `[graph-invariant] alien-accounts pruned=${pruned} accountIds=${alienIds.join(",")}`,
94
+ );
95
+ } finally {
96
+ await session.close();
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Enumerate accountIds with a parseable `account.json`. Directory name IS
102
+ * the canonical accountId (matches the UUID_RE.test(name) predicate at
103
+ * `platform/ui/server/routes/admin/files.ts`'s account-name resolver).
104
+ *
105
+ * Corruption discipline: a present-but-unparseable account.json is
106
+ * EXCLUDED from the valid set and emits a skip log line. Better to
107
+ * over-prune one suspect account than under-prune the leak it might
108
+ * be hiding.
109
+ */
110
+ function enumerateValidAccountIds(accountsDir: string): Set<string> {
111
+ const valid = new Set<string>();
112
+ let names: string[];
113
+ try {
114
+ names = readdirSync(accountsDir);
115
+ } catch (err) {
116
+ if ((err as NodeJS.ErrnoException).code === "ENOENT") return valid;
117
+ throw err;
118
+ }
119
+ for (const name of names) {
120
+ if (!UUID_RE.test(name)) continue;
121
+ const configPath = resolve(accountsDir, name, "account.json");
122
+ try {
123
+ JSON.parse(readFileSync(configPath, "utf-8"));
124
+ valid.add(name);
125
+ } catch (err) {
126
+ const code = (err as NodeJS.ErrnoException).code ?? "parse-error";
127
+ if (code === "ENOENT") continue;
128
+ console.error(
129
+ `[graph-invariant] account-json-skip uuid=${name} reason=${code}`,
130
+ );
131
+ }
132
+ }
133
+ return valid;
134
+ }
@@ -70,6 +70,48 @@ border, with their zoom-tier labels intact. The `N msgs` count excludes
70
70
  trashed Messages, so the detailed-tier label reflects only live turns in the
71
71
  conversation.
72
72
 
73
+ ## Filtering by channel and message kind
74
+
75
+ When you select **AdminConversation** or **PublicConversation** in the
76
+ filter popover, two extra rows appear underneath the chip list:
77
+
78
+ - **Channel** — Web / WhatsApp. Select one to scope the canvas to
79
+ conversations that came in over that channel only. Selecting both is
80
+ the same as selecting neither (all channels). After the migration that
81
+ ships with this release, every conversation carries an explicit
82
+ channel value — pre-existing conversations are backfilled to "Web"
83
+ because only the WhatsApp and Telegram intake paths ever set non-Web
84
+ values.
85
+ - **Message** — User / Assistant / WhatsApp. When you've also pivoted
86
+ into a conversation neighbourhood (or your search hits messages
87
+ directly), this row scopes the messages on canvas to the chosen kind.
88
+ WhatsApp messages persist with their own sublabel so you can isolate
89
+ the live-channel cohort from the agent-path cohort within the same
90
+ conversation.
91
+
92
+ These sub-facets compose with the chip selection. Searching with the
93
+ AdminConversation chip selected now also reaches the body text of every
94
+ admin message — typing a rare word like "ATM" returns every conversation
95
+ that mentions it, not just conversations with that word in the title.
96
+
97
+ ## Sidebar conversations list
98
+
99
+ The Recents list above the chat sidebar carries a per-row marker:
100
+ WhatsApp conversations show a small WhatsApp glyph next to the
101
+ conversation name. The dropdown above the list filters Recents to a
102
+ specific channel — flipping it to **WhatsApp** hides web-chat
103
+ conversations and vice versa.
104
+
105
+ ## Agents in the graph
106
+
107
+ Both admin and public agents appear as `:Agent` nodes in the graph. Open
108
+ the **Agents** entry from the sidebar to see them all. Each agent
109
+ carries a `:HANDLED_BY` edge from every conversation it has handled, so
110
+ you can pivot from an agent to the conversations it ran. The admin
111
+ agent's IDENTITY, SOUL, KNOWLEDGE, and KNOWLEDGE-SUMMARY documents
112
+ appear as :KnowledgeDocument nodes connected via `HAS_*` edges, the same
113
+ projection shape used for public agents.
114
+
73
115
  ## Agent-execution telemetry
74
116
 
75
117
  `ToolCall`, `StepResult`, `WorkflowStep`, and `WorkflowRun` nodes are
@@ -140,6 +140,8 @@ WHERE node.accountId = $accountId
140
140
 
141
141
  Multi-tenancy boundary. Every query is scoped to the requesting account. The `ACCOUNT_ID` environment variable is set at MCP server startup — it is not a tool parameter and cannot be overridden by the agent.
142
142
 
143
+ The read filter alone is not sufficient — it correctly *hides* alien-account nodes from every UI but does not prevent them existing. A writer that misresolves `accountId` (literal, undefined, or inferred-from-the-wrong-context) leaks nodes into the graph with no downstream symptom; the read filter then keeps them invisible indefinitely. The write-side doctrine is documented in `.docs/neo4j.md` "Account isolation invariant" — every writer that stamps `n.accountId` must verify the value against `${DATA_ROOT}/accounts/<id>/account.json` before write, and migration `004-prune-alien-accounts.ts` runs at every server boot as a backstop, deleting any node whose accountId is not on disk. Hard guard: refuses to prune when the on-disk account set is empty (corrupt-install scenario), surfaced as `[migration] failed prune-alien-accounts error="refusing to prune: …"`. Boot does not block on the failure.
144
+
143
145
  ---
144
146
 
145
147
  ## Query Classification
@@ -313,7 +315,7 @@ This tool is read-only and available to both public and admin agents.
313
315
 
314
316
  ### When conversations are created
315
317
 
316
- `:Conversation` nodes on webchat (admin login, "New conversation" in the burger, a new public visitor) are created lazily. Opening the chat or logging in does not write anything to the graph — {{productName}} only records the conversation once the user sends a second message. This keeps `conversation-search` and the Conversations modal free of one-turn abandoned threads. WhatsApp and Telegram take the opposite posture: a first inbound DM is a committed interaction, so the graph node is created eagerly on message one. See `.docs/web-chat.md` "Deferred conversation persistence (Task 650)" for the full contract.
318
+ `:Conversation` nodes on webchat (admin login, "New conversation" in the burger, a new public visitor) are created lazily. Opening the chat or logging in does not write anything to the graph — {{productName}} only records the conversation once the user sends a second message. This keeps `conversation-search` and the Conversations modal free of one-turn abandoned threads. WhatsApp and Telegram take the opposite posture: every inbound DM or group, allowed or activation-off, agent-invoked or gated — MERGEs the `:Conversation` and writes a forensic `:Message:WhatsAppMessage` row before any access-control decision (Task 863). The graph is the durable record of every message the device received, not just the ones the agent replied to. See `.docs/web-chat.md` "Deferred conversation persistence (Task 650)" and `.docs/whatsapp.md` "Session continuity" for the full contract.
317
319
 
318
320
  Each row in the Conversations modal exposes a `View logs` row-action that opens a popover with three links — **Stream**, **Errors**, **SSE** — each of which targets `/api/admin/logs?type={stream|error|sse}&conversationId={full-id}` in a new tab. The row's 8-char id chip is click-to-copy; hover reveals the full `conversationId` as a tooltip. See `.docs/web-chat.md` "In-chat retrieval" for the route contract and `console.debug` observability (Task 686).
319
321
 
@@ -108,12 +108,14 @@ Load `plugins/cloudflare/skills/setup-tunnel/SKILL.md` via `plugin-read` on the
108
108
 
109
109
  ## Questions
110
110
 
111
- Operationalises the CONCISE prerogative for clarification. Two rules:
111
+ Operationalises the CONCISE prerogative for clarification. Three rules:
112
112
 
113
113
  1. **One-sided questions only.** Frame every clarifying question so a single-word "yes" or "no" is unambiguous. Never pose two opposing framings joined by "or" — "Should I proceed, or stop?", "Want me to do X, or not?", "Shall I run this, or do you want to?". "Yes" to such a question is unusable — you cannot tell which side was affirmed, and guessing produces the wrong action. Pick one side, ask it plainly: "Proceed?" or "Stop?" — not both.
114
114
 
115
115
  2. **No choice-fork when the signal is deterministic.** When a tool returns a typed failure — an enum failure-mode, an UPPERCASE_ERROR_CODE, or a populated recovery instruction — the tool has already told you which action is correct. Relay that action to the owner and take it. Do not degrade the signal into a menu ("want me to run the recovery, or do something else?"). The menu invites the wrong branch. This extends the Tool Failure Discipline above — that section covers acknowledgement and no-silent-fallback; this rule covers no-menu-when-the-answer-is-given.
116
116
 
117
+ 3. **One question, last sentence.** Every response contains at most one question, and that question is the final sentence. Describe the situation, context, trade-offs, and any alternatives in declarative sentences first; close with the single question that asks for the owner's decision. Never open with the question and append caveats, never scatter mini-questions through the body, never end with two questions. The only exception is when the *intent* of the response is to offer enumerated choices — in that case, present the options as a numbered list, then close with one question ("Which would you like?"). A response that informs but does not require a decision ends without a question at all. *Failure symptoms:* a question in the first paragraph, a question followed by further explanation, two question marks in one response, "Would you like X, or shall I Y?" framings.
118
+
117
119
  ## Tool Routing
118
120
 
119
121
  Plugins provide domain-specific tools that query their own data stores directly. `memory-search` is a general-purpose semantic search across the entire knowledge graph — it finds nodes by vector similarity, which means results are ranked by semantic closeness to the query, not by domain relevance. A query containing the word "email" will surface product documentation *about* email features before it surfaces actual Email nodes whose content is unrelated to the query wording.