wyrm-mcp 7.3.2 → 7.3.3

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 (184) hide show
  1. package/README.md +8 -14
  2. package/dist/activation.js +59 -1
  3. package/dist/agent-daemon.js +281 -4
  4. package/dist/agent-loop.js +332 -7
  5. package/dist/analytics.js +236 -13
  6. package/dist/attribution.js +49 -1
  7. package/dist/audit.js +457 -2
  8. package/dist/auto-capture.js +138 -3
  9. package/dist/auto-orchestrator.js +325 -1
  10. package/dist/autoconfig.d.ts +50 -0
  11. package/dist/autoconfig.d.ts.map +1 -1
  12. package/dist/autoconfig.js +1115 -39
  13. package/dist/autoconfig.js.map +1 -1
  14. package/dist/buddy-runner.js +109 -1
  15. package/dist/buddy.js +564 -14
  16. package/dist/build-flags.js +15 -1
  17. package/dist/capabilities.js +183 -3
  18. package/dist/capture.js +56 -1
  19. package/dist/causality.js +148 -8
  20. package/dist/cli.js +281 -20
  21. package/dist/cloud/cli.js +541 -5
  22. package/dist/cloud/client.js +221 -1
  23. package/dist/cloud/crypto.js +85 -1
  24. package/dist/cloud/machine-id.js +113 -2
  25. package/dist/cloud/recovery.js +60 -1
  26. package/dist/cloud/sync-engine.js +543 -7
  27. package/dist/cloud-backup.js +579 -5
  28. package/dist/cloud-profile.js +138 -1
  29. package/dist/cloud-sync-entrypoint.js +47 -1
  30. package/dist/cloud-sync.js +309 -2
  31. package/dist/connectors/bridge-source.d.ts +46 -0
  32. package/dist/connectors/bridge-source.d.ts.map +1 -0
  33. package/dist/connectors/bridge-source.js +77 -0
  34. package/dist/connectors/bridge-source.js.map +1 -0
  35. package/dist/connectors/index.d.ts +24 -0
  36. package/dist/connectors/index.d.ts.map +1 -0
  37. package/dist/connectors/index.js +69 -0
  38. package/dist/connectors/index.js.map +1 -0
  39. package/dist/connectors/ingest.d.ts +16 -0
  40. package/dist/connectors/ingest.d.ts.map +1 -0
  41. package/dist/connectors/ingest.js +116 -0
  42. package/dist/connectors/ingest.js.map +1 -0
  43. package/dist/connectors/types.d.ts +99 -0
  44. package/dist/connectors/types.d.ts.map +1 -0
  45. package/dist/connectors/types.js +17 -0
  46. package/dist/connectors/types.js.map +1 -0
  47. package/dist/constellation.js +168 -12
  48. package/dist/content-signature.js +45 -1
  49. package/dist/context-build-budgeted.js +144 -4
  50. package/dist/context-ranking.js +69 -1
  51. package/dist/crypto.js +179 -1
  52. package/dist/daemon-write-endpoint.js +290 -1
  53. package/dist/daemon-writer.js +406 -2
  54. package/dist/database.js +1278 -53
  55. package/dist/deprecations.js +162 -2
  56. package/dist/design.js +141 -13
  57. package/dist/event-replication.js +112 -1
  58. package/dist/events-sse.js +43 -7
  59. package/dist/events.js +238 -6
  60. package/dist/failure-patterns.d.ts +107 -0
  61. package/dist/failure-patterns.d.ts.map +1 -1
  62. package/dist/failure-patterns.js +924 -43
  63. package/dist/failure-patterns.js.map +1 -1
  64. package/dist/federation.js +236 -12
  65. package/dist/goals.js +101 -13
  66. package/dist/golden.js +355 -3
  67. package/dist/handlers/agent.js +165 -4
  68. package/dist/handlers/alias-adapters.js +129 -1
  69. package/dist/handlers/aliases.js +171 -1
  70. package/dist/handlers/audit.js +87 -1
  71. package/dist/handlers/boundary.js +221 -1
  72. package/dist/handlers/capture.js +1114 -73
  73. package/dist/handlers/causality.js +119 -9
  74. package/dist/handlers/cloud.js +382 -85
  75. package/dist/handlers/companion.js +459 -28
  76. package/dist/handlers/datalake.js +187 -7
  77. package/dist/handlers/dispatch-context.js +22 -0
  78. package/dist/handlers/entity.js +256 -25
  79. package/dist/handlers/events.js +335 -16
  80. package/dist/handlers/failure.d.ts.map +1 -1
  81. package/dist/handlers/failure.js +408 -13
  82. package/dist/handlers/failure.js.map +1 -1
  83. package/dist/handlers/goals.js +296 -4
  84. package/dist/handlers/intelligence.js +681 -126
  85. package/dist/handlers/invoicing.js +70 -1
  86. package/dist/handlers/mcpclient.js +137 -6
  87. package/dist/handlers/orchestration.js +125 -40
  88. package/dist/handlers/output-schemas.js +24 -1
  89. package/dist/handlers/presence.js +99 -3
  90. package/dist/handlers/project.js +182 -28
  91. package/dist/handlers/prompts.js +157 -6
  92. package/dist/handlers/quest.js +224 -4
  93. package/dist/handlers/recall.js +237 -13
  94. package/dist/handlers/registry.js +167 -1
  95. package/dist/handlers/resources.js +288 -1
  96. package/dist/handlers/review.js +74 -11
  97. package/dist/handlers/run.js +498 -16
  98. package/dist/handlers/search.js +338 -15
  99. package/dist/handlers/session.js +643 -31
  100. package/dist/handlers/share.js +184 -8
  101. package/dist/handlers/shims.js +464 -1
  102. package/dist/handlers/skill.js +449 -67
  103. package/dist/handlers/survivors.js +120 -1
  104. package/dist/handlers/symbols.js +109 -8
  105. package/dist/handlers/syncops.js +302 -4
  106. package/dist/handlers/types.js +27 -1
  107. package/dist/harvest.js +191 -5
  108. package/dist/hours.js +156 -7
  109. package/dist/http-auth.js +321 -3
  110. package/dist/http-fast.js +1302 -22
  111. package/dist/icons.js +47 -1
  112. package/dist/importers.js +268 -1
  113. package/dist/index.js +840 -2
  114. package/dist/indexer.js +145 -4
  115. package/dist/intelligence.js +261 -31
  116. package/dist/internal-dispatch.js +212 -3
  117. package/dist/keyset.js +110 -1
  118. package/dist/knowledge-graph.js +176 -12
  119. package/dist/license.js +441 -2
  120. package/dist/logger.js +199 -2
  121. package/dist/maintenance.js +148 -2
  122. package/dist/mcp-client.js +262 -6
  123. package/dist/memory-artifacts.js +596 -32
  124. package/dist/migrate-prompt.js +124 -2
  125. package/dist/migrations.d.ts.map +1 -1
  126. package/dist/migrations.js +799 -42
  127. package/dist/migrations.js.map +1 -1
  128. package/dist/performance.js +228 -1
  129. package/dist/presence.js +140 -11
  130. package/dist/priority-embed.js +164 -5
  131. package/dist/providers/embedding-provider.js +196 -1
  132. package/dist/readonly-gate.js +29 -1
  133. package/dist/receipt.js +43 -1
  134. package/dist/rehydration.js +157 -9
  135. package/dist/reindex.js +88 -1
  136. package/dist/render-target.js +544 -21
  137. package/dist/render.js +280 -4
  138. package/dist/repl-guard.js +173 -1
  139. package/dist/replication-daemon-entrypoint.js +31 -1
  140. package/dist/replication-daemon.js +262 -2
  141. package/dist/rerank.js +142 -1
  142. package/dist/resilience.js +591 -1
  143. package/dist/reverse-bridge.js +360 -5
  144. package/dist/security.js +244 -1
  145. package/dist/session-seen.js +51 -3
  146. package/dist/setup.js +260 -1
  147. package/dist/skill-author.js +168 -5
  148. package/dist/spec-kit.js +191 -1
  149. package/dist/sqlite-busy.js +154 -1
  150. package/dist/statusline.js +315 -11
  151. package/dist/sub-agent.js +262 -13
  152. package/dist/summarizer.js +139 -13
  153. package/dist/symbols.js +283 -7
  154. package/dist/sync.js +359 -5
  155. package/dist/tasks-dispatch.js +84 -1
  156. package/dist/tasks.js +282 -1
  157. package/dist/token-budget.js +143 -1
  158. package/dist/tool-analytics.js +129 -7
  159. package/dist/tool-annotations.js +365 -1
  160. package/dist/tool-manifest-v2.json +1 -1
  161. package/dist/tool-manifest.json +1 -1
  162. package/dist/tool-profiles.js +75 -1
  163. package/dist/trace-harvest.js +244 -6
  164. package/dist/types.js +30 -1
  165. package/dist/ui-dashboard.js +50 -41
  166. package/dist/ulid.js +81 -1
  167. package/dist/usage-tracker.js +66 -1
  168. package/dist/validate.js +129 -1
  169. package/dist/vault.js +534 -1
  170. package/dist/vector-init.js +67 -1
  171. package/dist/vectors.js +184 -3
  172. package/dist/version-check.js +136 -4
  173. package/dist/visibility.js +155 -19
  174. package/dist/wyrm-cli.js +2845 -101
  175. package/dist/wyrm-cli.js.map +1 -1
  176. package/dist/wyrm-guard.d.ts.map +1 -1
  177. package/dist/wyrm-guard.js +475 -14
  178. package/dist/wyrm-guard.js.map +1 -1
  179. package/dist/wyrm-loop.js +150 -3
  180. package/dist/wyrm-manifest.json +1 -1
  181. package/dist/wyrm-statusline-daemon.js +11 -1
  182. package/dist/wyrm-statusline.js +56 -4
  183. package/dist/wyrm-ui.js +77 -9
  184. package/package.json +1 -1
@@ -1,13 +1,237 @@
1
- import{TOOL_ANNOTATIONS as E}from"../tool-annotations.js";import{renderResult as R,withGlyph as d}from"../render.js";import{memoryUri as P,resourceLink as D}from"./resources.js";import{buildDeterminismReceipt as L,attestation as S}from"../receipt.js";import{rerankConfigured as T}from"../rerank.js";const F=[{name:"wyrm_recall",description:"Use before starting any non-trivial task - what do we know about this? Pull up relevant lessons learned, proven patterns, anti-patterns, and reasoning traces from past work. Hybrid lexical+semantic retrieval, fully local, no LLM. Mark what you recalled as useful (or not) with wyrm_feedback.",inputSchema:{type:"object",properties:{projectPath:{type:"string"},query:{type:"string",description:"The task or problem"},kind:{type:"string",enum:["reasoning_trace","lesson","pattern","anti_pattern","heuristic"]},limit:{type:"number",description:"Default 10"},minConfidence:{type:"number",description:"0-1 (default 0)"},detail:{type:"string",enum:["full","link"],description:"Default full"}},required:["projectPath","query"]},outputSchema:{type:"object",properties:{query:{type:"string"},count:{type:"integer"},results:{type:"array",items:{type:"object",properties:{id:{type:"integer"},kind:{type:"string"},relevance:{type:"number"},problem:{type:"string"},validated_fix:{type:["string","null"]},confidence:{type:"number"},reuse_count:{type:"integer"}},required:["id","kind","relevance","problem","confidence","reuse_count"]}}},required:["query","count","results"]},annotations:E.wyrm_recall,aliases:[],handler:async(w,{store:h,raw:v,memory:p,vectors:b,clientSupportsResources:$})=>{const{projectPath:m,query:s,kind:g,limit:x,minConfidence:M,detail:f}=w,c=h.getProject(m);if(!c)return{content:[{type:"text",text:`Project not found: ${m}`}],isError:!0};const a=!!b(),y=a&&T()&&/^(1|true|yes|on)$/i.test(process.env.WYRM_RERANK??""),_={kind:g,limit:x??10,minConfidence:M,rerank:y},i=a?await p.recallHybrid(c.id,s,_):p.recall(c.id,s,_),j=L({vectorsAvailable:a,rerankActive:y,embedModel:process.env.WYRM_EMBED_MODEL||"nomic-embed-text",rerankModel:process.env.WYRM_RERANK_MODEL||null});if(i.length>0){const n=i.map(r=>r.artifact.id),e=n.map(()=>"?").join(",");v().prepare(`UPDATE memory_artifacts SET last_accessed_at = datetime('now'), access_count = access_count + 1 WHERE id IN (${e})`).run(...n)}const k=n=>Math.round(n*1e4)/1e4,l={query:s,count:i.length,results:i.map(n=>{const e=n.artifact,r={id:e.id,kind:e.kind,relevance:k(n.relevance_score),problem:e.problem,outcome:e.outcome,confidence:e.confidence==null?e.confidence:k(e.confidence),reuse_count:e.reuse_count,reuse_success_count:e.reuse_success_count};return e.constraints!=null&&(r.constraints=e.constraints),e.validated_fix!=null&&(r.validated_fix=e.validated_fix),e.why_it_worked!=null&&(r.why_it_worked=e.why_it_worked),r}),receipt:j},u=R(l,(n,e)=>{const r=`
2
-
3
- _${S(n.receipt)}_`;if(n.count===0)return d(e.brand,`No relevant memory found for: "${n.query}"`)+"\n\nUse `wyrm_remember` to store knowledge as you work."+r;let o=d(e.brand,`**Memory Recall** -- "${n.query}" (${n.count} found)`)+`
4
-
5
- `;for(const t of n.results){o+=`### ${t.kind} (ID: ${t.id}) -- relevance ${(t.relevance*100).toFixed(0)}%
6
- `,o+=`**Problem:** ${t.problem}
7
- `,t.constraints&&(o+=`**Constraints:** ${t.constraints}
8
- `),t.validated_fix&&(o+=`**Solution:** ${t.validated_fix}
9
- `),t.why_it_worked&&(o+=`**Why:** ${t.why_it_worked}
10
- `),t.outcome==="negative"&&(o+=d(e.warn,"_This approach failed -- see solution for what to do instead_")+`
11
- `);const q=t.confidence==null?"unknown":`${(t.confidence*100).toFixed(0)}%`;o+=`_Confidence: ${q} | Used ${t.reuse_count}x | Success rate: ${t.reuse_count>0?(t.reuse_success_count/t.reuse_count*100).toFixed(0)+"%":"not yet used"}_
12
-
13
- `}return o+="_Use `wyrm_feedback` to record whether these were helpful._",o+r},{exemptStructured:!0});if((f==="link"||f!=="full"&&!!$?.())&&l.count>0){const n=l.results.map(e=>D(P(e.id),`memory #${e.id} (${e.kind})`,{description:e.problem.slice(0,120),mimeType:"application/json"}));return{...u,content:[...u.content,...n]}}return u}}];export{F as recallToolSpecs};
1
+ /**
2
+ * Recall domain — ToolSpec contract v2 (v7 F3 T026, hot-path extraction).
3
+ *
4
+ * wyrm_recall, moved VERBATIM from the index.ts dispatch switch +
5
+ * buildAllTools(). Hybrid (FTS ⊕ vectors, RRF) when a vector store is
6
+ * configured, lexical otherwise — exactly the 6.x routing. The access-decay
7
+ * UPDATE moved with the handler (the ctx.raw() verbatim-SQL seam).
8
+ *
9
+ * T019 renderer: the result list is the canonical structured body; the 6.x
10
+ * prose derives from it (ASCII default the kind emoji moved off the default
11
+ * text, spec §6 reformat).
12
+ *
13
+ * @copyright 2026 Ghost Protocol (Pvt) Ltd.
14
+ * @license Proprietary — (c) 2026 Ghost Protocol (Pvt) Ltd. All rights reserved. See LICENSE.
15
+ */
16
+ import { TOOL_ANNOTATIONS } from '../tool-annotations.js';
17
+ import { renderResult, withGlyph } from '../render.js';
18
+ import { memoryUri, resourceLink } from './resources.js';
19
+ import { buildDeterminismReceipt, attestation } from '../receipt.js';
20
+ import { rerankConfigured } from '../rerank.js';
21
+ export const recallToolSpecs = [
22
+ {
23
+ name: "wyrm_recall",
24
+ description: "Use before starting any non-trivial task - what do we know about this? Pull up relevant lessons learned, proven patterns, anti-patterns, and reasoning traces from past work. Hybrid lexical+semantic retrieval, fully local, no LLM. Mark what you recalled as useful (or not) with wyrm_feedback.",
25
+ inputSchema: {
26
+ type: "object",
27
+ properties: {
28
+ // v7 F3 (T026): property prose compressed to fund the hot-path
29
+ // outputSchemas under the 8K default-surface pin (T022/T025 trade).
30
+ projectPath: { type: "string" },
31
+ query: { type: "string", description: "The task or problem" },
32
+ kind: {
33
+ type: "string",
34
+ enum: ["reasoning_trace", "lesson", "pattern", "anti_pattern", "heuristic"],
35
+ },
36
+ limit: { type: "number", description: "Default 10" },
37
+ minConfidence: { type: "number", description: "0-1 (default 0)" },
38
+ // v7 F4 (T034): 'full' (default) inlines the complete result bodies;
39
+ // 'link' ALSO appends a wyrm://memory/{id} resource_link per result for
40
+ // resource-capable clients. Either way the full body rides — the link
41
+ // is additive, never a substitution (no data loss).
42
+ detail: { type: "string", enum: ["full", "link"], description: "Default full" },
43
+ },
44
+ required: ["projectPath", "query"],
45
+ },
46
+ outputSchema: {
47
+ type: "object",
48
+ properties: {
49
+ query: { type: "string" },
50
+ count: { type: "integer" },
51
+ results: {
52
+ type: "array",
53
+ items: {
54
+ type: "object",
55
+ properties: {
56
+ id: { type: "integer" },
57
+ kind: { type: "string" },
58
+ relevance: { type: "number" },
59
+ problem: { type: "string" },
60
+ // FEATHERWEIGHT review (major): constraints/why_it_worked/outcome/
61
+ // reuse_success_count carry the fix rationale + the negative-
62
+ // learning signal. They ride the body undeclared (declaring them
63
+ // here would push the default ListTools surface OVER the §7.1 8K
64
+ // pin). Losslessness under WYRM_CHANNEL=structured is instead
65
+ // guaranteed by recall being exemptStructured (handler below): its
66
+ // FULL per-result prose always rides the text channel, so the
67
+ // rationale never depends on a consumer preserving undeclared
68
+ // structured fields.
69
+ validated_fix: { type: ["string", "null"] },
70
+ confidence: { type: "number" },
71
+ reuse_count: { type: "integer" },
72
+ },
73
+ required: ["id", "kind", "relevance", "problem", "confidence", "reuse_count"],
74
+ },
75
+ },
76
+ },
77
+ required: ["query", "count", "results"],
78
+ },
79
+ annotations: TOOL_ANNOTATIONS.wyrm_recall,
80
+ aliases: [],
81
+ handler: async (args, { store, raw, memory, vectors, clientSupportsResources }) => {
82
+ const { projectPath: rcPath, query: rcQuery, kind: rcKind, limit: rcLimit, minConfidence: rcMinConf, detail: rcDetail } = args;
83
+ const rcProject = store.getProject(rcPath);
84
+ if (!rcProject)
85
+ return { content: [{ type: "text", text: `Project not found: ${rcPath}` }], isError: true };
86
+ // Hybrid (FTS ⊕ vectors, RRF) when a vector store is available; lexical otherwise.
87
+ const vectorsOn = !!vectors();
88
+ // WYRM_RERANK=1 engages the opt-in, env-configured cross-encoder rerank
89
+ // stage on the hybrid path (only meaningful when WYRM_RERANK_MODEL is set;
90
+ // rerank.ts degrades to the fusion order on any failure — never throws).
91
+ const rerankActive = vectorsOn && rerankConfigured() && /^(1|true|yes|on)$/i.test(process.env.WYRM_RERANK ?? '');
92
+ const rcOpts = { kind: rcKind, limit: rcLimit ?? 10, minConfidence: rcMinConf, rerank: rerankActive };
93
+ const results = vectorsOn
94
+ ? await memory.recallHybrid(rcProject.id, rcQuery, rcOpts)
95
+ : memory.recall(rcProject.id, rcQuery, rcOpts);
96
+ // Determinism Receipt — proof THIS recall ran locally with no generative
97
+ // LLM and no data egress; reflects the path that actually executed.
98
+ const receipt = buildDeterminismReceipt({
99
+ vectorsAvailable: vectorsOn,
100
+ rerankActive,
101
+ embedModel: process.env.WYRM_EMBED_MODEL || 'nomic-embed-text',
102
+ rerankModel: process.env.WYRM_RERANK_MODEL || null,
103
+ });
104
+ // Track access for memory decay
105
+ if (results.length > 0) {
106
+ const ids = results.map(r => r.artifact.id);
107
+ const placeholders = ids.map(() => '?').join(',');
108
+ raw().prepare(`UPDATE memory_artifacts SET last_accessed_at = datetime('now'), access_count = access_count + 1 WHERE id IN (${placeholders})`).run(...ids);
109
+ }
110
+ // FEATHERWEIGHT #5 — number & null hygiene (default, lossless):
111
+ // (a) `relevance` is an internal RRF/FTS ranking score in [0,1] the
112
+ // consumer only ever reads as an ORDER and renders as an integer %
113
+ // (text channel: `(relevance*100).toFixed(0)`). Its raw form carries
114
+ // up to 17 significant digits of float noise (0.9992261132463348)
115
+ // that no consumer compares on. Rounding to 4 dp (0.0001 resolution —
116
+ // 100× finer than the integer-% display and far below any tie the
117
+ // sort could surface) drops only excess precision, never a value a
118
+ // consumer distinguishes. `confidence` is rounded the same way (it is
119
+ // stored ≤2 dp; the round is a no-op on clean rows and a safety clamp
120
+ // on any future sub-percent float).
121
+ // (b) `constraints`/`validated_fix`/`why_it_worked` are `string | null`.
122
+ // A null is the ABSENCE of that rationale — it carries no information,
123
+ // and the text derivation already guards each with a truthy check
124
+ // (`if (a.validated_fix) …`), so an absent key reads identically to a
125
+ // null one for every consumer. Omitting the key when null is lossless
126
+ // null-elision (a present non-null value is ALWAYS kept). `outcome`,
127
+ // `reuse_count`, `reuse_success_count` are non-null by construction
128
+ // (enum default 'neutral' / integer counters) and ride unchanged.
129
+ const round4 = (n) => Math.round(n * 10000) / 10000;
130
+ const body = {
131
+ query: rcQuery,
132
+ count: results.length,
133
+ results: results.map((r) => {
134
+ const a = r.artifact;
135
+ const result = {
136
+ id: a.id,
137
+ kind: a.kind,
138
+ relevance: round4(r.relevance_score),
139
+ problem: a.problem,
140
+ outcome: a.outcome,
141
+ // round4(null) === 0 in JS, which would present an UNKNOWN
142
+ // confidence as a meaningful 0%. The `confidence` column is `REAL
143
+ // DEFAULT 1.0` but NOT NULL-constrained (migrations.ts), so a
144
+ // synced/foreign row can carry null; preserve it rather than
145
+ // coerce. round4 only ever drops excess float precision (lossless).
146
+ confidence: a.confidence == null ? a.confidence : round4(a.confidence),
147
+ reuse_count: a.reuse_count,
148
+ reuse_success_count: a.reuse_success_count,
149
+ };
150
+ // Lossless null-elision: include the rationale fields only when they
151
+ // carry a value (a null = no rationale = nothing to transmit; the text
152
+ // derivation already guards each with a truthy check, so an absent key
153
+ // reads identically to a null one for every consumer).
154
+ if (a.constraints != null)
155
+ result.constraints = a.constraints;
156
+ if (a.validated_fix != null)
157
+ result.validated_fix = a.validated_fix;
158
+ if (a.why_it_worked != null)
159
+ result.why_it_worked = a.why_it_worked;
160
+ return result;
161
+ }),
162
+ receipt,
163
+ };
164
+ const rendered = renderResult(body, (b, g) => {
165
+ // The determinism receipt rides the text channel too (ASCII, lossless
166
+ // under exemptStructured) — the proof a schema-trimming consumer keeps.
167
+ const attest = `\n\n_${attestation(b.receipt)}_`;
168
+ if (b.count === 0) {
169
+ return withGlyph(g.brand, `No relevant memory found for: "${b.query}"`) +
170
+ `\n\nUse \`wyrm_remember\` to store knowledge as you work.` + attest;
171
+ }
172
+ let text = withGlyph(g.brand, `**Memory Recall** -- "${b.query}" (${b.count} found)`) + '\n\n';
173
+ for (const a of b.results) {
174
+ text += `### ${a.kind} (ID: ${a.id}) -- relevance ${(a.relevance * 100).toFixed(0)}%\n`;
175
+ text += `**Problem:** ${a.problem}\n`;
176
+ if (a.constraints)
177
+ text += `**Constraints:** ${a.constraints}\n`;
178
+ if (a.validated_fix)
179
+ text += `**Solution:** ${a.validated_fix}\n`;
180
+ if (a.why_it_worked)
181
+ text += `**Why:** ${a.why_it_worked}\n`;
182
+ if (a.outcome === 'negative')
183
+ text += withGlyph(g.warn, `_This approach failed -- see solution for what to do instead_`) + '\n';
184
+ // Mirror the structured-body null guard (FW follow-up second-round):
185
+ // a synced/foreign row can carry a null confidence (`REAL DEFAULT 1.0`
186
+ // but NOT NULL-constrained in migrations.ts). null * 100 === 0 in JS
187
+ // would render an UNKNOWN confidence as a meaningful "0%" on the text
188
+ // channel — the SAME invented-value bug the minors commit fixed in the
189
+ // structured body, but on recall's dominant (exemptStructured) channel.
190
+ // Render "unknown" so unknown ≠ 0%.
191
+ const confStr = a.confidence == null ? 'unknown' : `${(a.confidence * 100).toFixed(0)}%`;
192
+ text += `_Confidence: ${confStr} | Used ${a.reuse_count}x | Success rate: ${a.reuse_count > 0 ? ((a.reuse_success_count / a.reuse_count) * 100).toFixed(0) + '%' : 'not yet used'}_\n\n`;
193
+ }
194
+ text += `_Use \`wyrm_feedback\` to record whether these were helpful._`;
195
+ return text + attest;
196
+ }, {
197
+ // FEATHERWEIGHT review (major): recall's per-result rationale lives in
198
+ // body fields NOT declared in outputSchema (declaring them would push
199
+ // the default ListTools surface over the §7.1 8K pin). A strict harness
200
+ // that trims structuredContent to declared properties under
201
+ // WYRM_CHANNEL=structured would therefore drop the fix rationale + the
202
+ // negative-learning signal — UNLESS the text channel keeps carrying the
203
+ // full prose. So recall is exemptStructured: its complete per-result
204
+ // detail (problem/constraints/validated_fix/why_it_worked/outcome) rides
205
+ // the text channel on EVERY channel policy, never collapsing to a one-
206
+ // line header. Losslessness is then independent of consumer schema-
207
+ // trimming — the hard-gate-5 contract.
208
+ exemptStructured: true,
209
+ });
210
+ // v7 F4 (T034): resourceLink affordance. The full result bodies ALWAYS
211
+ // ride above (the detail=full FALLBACK is the default and is never
212
+ // dropped — no data loss for any client). ADDITIONALLY, append one
213
+ // wyrm://memory/{id} resource_link per result so a resource-capable client
214
+ // can re-fetch the canonical artifact on demand without re-running recall.
215
+ // The gate is EITHER honest signal that the client can resolve a link:
216
+ // • the caller explicitly asked (detail='link') — an explicit request IS
217
+ // the client telling us it understands wyrm:// links; OR
218
+ // • the client advertised experimental.resources at initialize.
219
+ // detail='full' (the default) NEVER appends links — it is the resource-less
220
+ // fallback, the full inline body and nothing dangling. Either way the body
221
+ // is unchanged; the link is purely additive, so no client loses data and a
222
+ // resource-less client (no opt-in, no advertised capability) gets no link
223
+ // it cannot resolve. The links append to content[] AFTER the text block, so
224
+ // content[0].text + structuredContent are byte-identical to the base return.
225
+ const wantsLinks = rcDetail === 'link' || (rcDetail !== 'full' && !!clientSupportsResources?.());
226
+ if (wantsLinks && body.count > 0) {
227
+ const links = body.results.map((r) => resourceLink(memoryUri(r.id), `memory #${r.id} (${r.kind})`, {
228
+ description: r.problem.slice(0, 120),
229
+ mimeType: 'application/json',
230
+ }));
231
+ return { ...rendered, content: [...rendered.content, ...links] };
232
+ }
233
+ return rendered;
234
+ },
235
+ },
236
+ ];
237
+ //# sourceMappingURL=recall.js.map
@@ -1 +1,167 @@
1
- import{goalToolSpecs as n}from"./goals.js";import{captureToolSpecs as s}from"./capture.js";import{recallToolSpecs as l}from"./recall.js";import{searchToolSpecs as a}from"./search.js";import{failureToolSpecs as f}from"./failure.js";import{questToolSpecs as u}from"./quest.js";import{sessionToolSpecs as S}from"./session.js";import{reviewToolSpecs as T}from"./review.js";import{runToolSpecs as d}from"./run.js";import{declaredOutputSchemas as h}from"./output-schemas.js";import{projectToolSpecs as y}from"./project.js";import{eventsToolSpecs as g}from"./events.js";import{skillToolSpecs as O}from"./skill.js";import{datalakeToolSpecs as x}from"./datalake.js";import{entityToolSpecs as k}from"./entity.js";import{intelligenceToolSpecs as b}from"./intelligence.js";import{orchestrationToolSpecs as v}from"./orchestration.js";import{cloudToolSpecs as L}from"./cloud.js";import{companionToolSpecs as j}from"./companion.js";import{syncopsToolSpecs as w}from"./syncops.js";import{presenceToolSpecs as A}from"./presence.js";import{causalityToolSpecs as C}from"./causality.js";import{symbolsToolSpecs as D}from"./symbols.js";import{invoicingToolSpecs as N}from"./invoicing.js";import{auditToolSpecs as _}from"./audit.js";import{shareToolSpecs as q}from"./share.js";import{agentToolSpecs as E}from"./agent.js";import{mcpclientToolSpecs as I}from"./mcpclient.js";const p=[...n,...s,...l,...a,...f,...u,...S,...T,...d,...y,...g,...O,...x,...k,...b,...v,...L,...j,...w,...A,...C,...D,...N,..._,...q,...E,...I],lo=new Map(p.map(o=>[o.name,o.handler]));function ao(){return p.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema,...o.outputSchema!==void 0?{outputSchema:o.outputSchema}:{}}))}function fo(o){return o.map(t=>{const e=h[t.name];return!e||t.outputSchema!==void 0?t:{...t,outputSchema:e}})}const c=["name","description","inputSchema","outputSchema","annotations"];function uo(o){return[...o].sort((t,e)=>t.name<e.name?-1:t.name>e.name?1:0).map(t=>{const e=t,m={};for(const r of c)r in e&&e[r]!==void 0&&(m[r]=e[r]);const i=Object.keys(e).filter(r=>!c.includes(r)&&e[r]!==void 0).sort();for(const r of i)m[r]=e[r];return m})}export{fo as applyDeclaredOutputSchemas,uo as buildStableToolList,lo as handlerRegistry,ao as registryToolDefs,p as toolSpecs};
1
+ /**
2
+ * Tool-handler registry (v7 A2; upgraded to the ToolSpec contract v2 in
3
+ * v7 F3 T018). Domain modules export `ToolSpec[]` — ONE object per tool
4
+ * carrying {name, description, inputSchema, outputSchema, annotations,
5
+ * examples, aliases, handler} — and this registry derives from those specs:
6
+ *
7
+ * (a) the DISPATCH map (`handlerRegistry`): the CallTool dispatcher consults
8
+ * it BEFORE the legacy `switch (name)` in index.ts, so an extracted tool
9
+ * is served from here while every tool still in the switch keeps its
10
+ * exact original path. Domains migrate in, one green-suite commit at a
11
+ * time, until the switch is empty (T036).
12
+ *
13
+ * (b) the ADVERTISED wire entries (`registryToolDefs`): merged with
14
+ * buildAllTools() in the ListTools handler, then canonicalized by
15
+ * `buildStableToolList` — a byte-stable, deterministically ordered list
16
+ * (stable tool order, stable key order, no Date/random anywhere in the
17
+ * serialization; locked by tests/listtools-byte-stability.test.ts).
18
+ *
19
+ * @copyright 2026 Ghost Protocol (Pvt) Ltd.
20
+ * @license Proprietary — (c) 2026 Ghost Protocol (Pvt) Ltd. All rights reserved. See LICENSE.
21
+ */
22
+ import { goalToolSpecs } from './goals.js';
23
+ import { captureToolSpecs } from './capture.js';
24
+ import { recallToolSpecs } from './recall.js';
25
+ import { searchToolSpecs } from './search.js';
26
+ import { failureToolSpecs } from './failure.js';
27
+ import { questToolSpecs } from './quest.js';
28
+ import { sessionToolSpecs } from './session.js';
29
+ import { reviewToolSpecs } from './review.js';
30
+ import { runToolSpecs } from './run.js';
31
+ import { declaredOutputSchemas } from './output-schemas.js';
32
+ // v7 F4 (T036): the drained non-hot domains — every formerly switch-resident
33
+ // tool, lifted VERBATIM into per-domain ToolSpec modules behind the broad
34
+ // DispatcherContext slice. These complete the monolith drain (quest #80):
35
+ // buildAllTools() + the 142-case switch are deleted; index.ts ≤1,000 lines.
36
+ import { projectToolSpecs } from './project.js';
37
+ import { eventsToolSpecs } from './events.js';
38
+ import { skillToolSpecs } from './skill.js';
39
+ import { datalakeToolSpecs } from './datalake.js';
40
+ import { entityToolSpecs } from './entity.js';
41
+ import { intelligenceToolSpecs } from './intelligence.js';
42
+ import { orchestrationToolSpecs } from './orchestration.js';
43
+ import { cloudToolSpecs } from './cloud.js';
44
+ import { companionToolSpecs } from './companion.js';
45
+ import { syncopsToolSpecs } from './syncops.js';
46
+ import { presenceToolSpecs } from './presence.js';
47
+ import { causalityToolSpecs } from './causality.js';
48
+ import { symbolsToolSpecs } from './symbols.js';
49
+ import { invoicingToolSpecs } from './invoicing.js';
50
+ import { auditToolSpecs } from './audit.js';
51
+ import { shareToolSpecs } from './share.js';
52
+ import { agentToolSpecs } from './agent.js';
53
+ import { mcpclientToolSpecs } from './mcpclient.js';
54
+ /**
55
+ * Every ToolSpec from every migrated domain. A domain's specs are typed
56
+ * against its narrow context slice; they widen to ToolSpec<HandlerContext>
57
+ * here by structural contravariance (HandlerContext implements every slice).
58
+ * v7 F3 (T026): + the seven hot-path domains (capture write funnel, recall,
59
+ * search incl. constellation, failure, quest, session+prime, review).
60
+ */
61
+ export const toolSpecs = [
62
+ ...goalToolSpecs,
63
+ ...captureToolSpecs,
64
+ ...recallToolSpecs,
65
+ ...searchToolSpecs,
66
+ ...failureToolSpecs,
67
+ ...questToolSpecs,
68
+ ...sessionToolSpecs,
69
+ ...reviewToolSpecs,
70
+ // v7 F3 (T027): the run loop — wyrm_run is a NEW first-class tool (the
71
+ // 32nd survivor), not an extraction; see handlers/run.ts + survivors.ts.
72
+ ...runToolSpecs,
73
+ // v7 F4 (T036): the drained non-hot domains (quest #80). Typed against the
74
+ // broad DispatcherContext slice; they widen to ToolSpec<HandlerContext> here
75
+ // by the same structural contravariance (DispatcherContext extends
76
+ // HandlerContext). index.ts wires `dispatcherCtx` once and the registry
77
+ // dispatches every name from this list — the switch is gone.
78
+ ...projectToolSpecs,
79
+ ...eventsToolSpecs,
80
+ ...skillToolSpecs,
81
+ ...datalakeToolSpecs,
82
+ ...entityToolSpecs,
83
+ ...intelligenceToolSpecs,
84
+ ...orchestrationToolSpecs,
85
+ ...cloudToolSpecs,
86
+ ...companionToolSpecs,
87
+ ...syncopsToolSpecs,
88
+ ...presenceToolSpecs,
89
+ ...causalityToolSpecs,
90
+ ...symbolsToolSpecs,
91
+ ...invoicingToolSpecs,
92
+ ...auditToolSpecs,
93
+ ...shareToolSpecs,
94
+ ...agentToolSpecs,
95
+ ...mcpclientToolSpecs,
96
+ ];
97
+ /** Tool-name → handler, derived from the specs (never built by hand). */
98
+ export const handlerRegistry = new Map(toolSpecs.map((spec) => [spec.name, spec.handler]));
99
+ /**
100
+ * Advertised ListTools entries for every registry-resident tool, derived from
101
+ * the SAME ToolSpec objects that carry the handlers — surface and behavior
102
+ * cannot drift. Annotations are deliberately NOT emitted here: the ListTools
103
+ * pipeline merges them centrally via annotateTools() (tool-annotations.ts)
104
+ * for switch- and registry-resident tools alike, and each ToolSpec.annotations
105
+ * is locked to be the same registry entry by tests/toolspec-registry.test.ts.
106
+ */
107
+ export function registryToolDefs() {
108
+ return toolSpecs.map((spec) => ({
109
+ name: spec.name,
110
+ description: spec.description,
111
+ inputSchema: spec.inputSchema,
112
+ ...(spec.outputSchema !== undefined ? { outputSchema: spec.outputSchema } : {}),
113
+ }));
114
+ }
115
+ /**
116
+ * Attach declared outputSchemas (handlers/output-schemas.ts) to
117
+ * switch-resident tools that already return structuredContent — T014's
118
+ * wyrm_failure_check verdict is the first. Non-mutating; a tool that already
119
+ * carries an outputSchema (a ToolSpec one) is left untouched.
120
+ */
121
+ export function applyDeclaredOutputSchemas(tools) {
122
+ return tools.map((tool) => {
123
+ const schema = declaredOutputSchemas[tool.name];
124
+ if (!schema || tool.outputSchema !== undefined)
125
+ return tool;
126
+ return { ...tool, outputSchema: schema };
127
+ });
128
+ }
129
+ // ── Byte-stable ListTools canonicalization (T018) ───────────────────────────
130
+ /** Canonical top-level key order for one advertised tool entry. */
131
+ const CANONICAL_TOOL_KEYS = ['name', 'description', 'inputSchema', 'outputSchema', 'annotations'];
132
+ /**
133
+ * Canonicalize the final advertised tool list so consecutive ListTools
134
+ * serializations are BYTE-IDENTICAL (spec §7.1):
135
+ *
136
+ * - stable TOOL order: sorted by name via codepoint comparison (never
137
+ * localeCompare — locale-dependent collation would make the bytes depend
138
+ * on the host environment);
139
+ * - stable KEY order per entry: the canonical keys above first, then any
140
+ * remaining keys in codepoint order (future-proof against new fields);
141
+ * - values are passed through UNTOUCHED: schemas/annotations are static
142
+ * literals whose insertion order is fixed at author time, and nothing in
143
+ * the pipeline derives from Date/random. (Deep key-sorting is deliberately
144
+ * avoided — it would rewrite inputSchema property order and break the
145
+ * golden-fixture schema_sha256 drift guards for zero stability gain.)
146
+ *
147
+ * Pure and non-mutating: same input ⇒ same output, fresh objects.
148
+ */
149
+ export function buildStableToolList(tools) {
150
+ return [...tools]
151
+ .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
152
+ .map((tool) => {
153
+ const source = tool;
154
+ const out = {};
155
+ for (const key of CANONICAL_TOOL_KEYS) {
156
+ if (key in source && source[key] !== undefined)
157
+ out[key] = source[key];
158
+ }
159
+ const rest = Object.keys(source)
160
+ .filter((k) => !CANONICAL_TOOL_KEYS.includes(k) && source[k] !== undefined)
161
+ .sort();
162
+ for (const key of rest)
163
+ out[key] = source[key];
164
+ return out;
165
+ });
166
+ }
167
+ //# sourceMappingURL=registry.js.map