wyrm-mcp 7.2.0 → 7.2.2

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 (156) hide show
  1. package/LICENSE +26 -667
  2. package/NOTICE +14 -33
  3. package/dist/activation.d.ts.map +1 -1
  4. package/dist/activation.js +1 -44
  5. package/dist/activation.js.map +1 -1
  6. package/dist/agent-daemon.js +4 -281
  7. package/dist/agent-loop.js +7 -332
  8. package/dist/analytics.js +13 -236
  9. package/dist/attribution.js +1 -49
  10. package/dist/audit.js +2 -457
  11. package/dist/auto-capture.js +3 -138
  12. package/dist/auto-orchestrator.js +1 -325
  13. package/dist/autoconfig.js +39 -840
  14. package/dist/buddy-runner.js +1 -109
  15. package/dist/buddy.js +14 -564
  16. package/dist/build-flags.js +1 -17
  17. package/dist/capabilities.js +3 -183
  18. package/dist/capture.js +1 -56
  19. package/dist/causality.js +6 -107
  20. package/dist/cli.js +20 -281
  21. package/dist/cloud/cli.js +5 -541
  22. package/dist/cloud/client.js +1 -221
  23. package/dist/cloud/crypto.js +1 -85
  24. package/dist/cloud/machine-id.js +2 -113
  25. package/dist/cloud/recovery.js +1 -60
  26. package/dist/cloud/sync-engine.js +7 -543
  27. package/dist/cloud-backup.js +5 -579
  28. package/dist/cloud-profile.js +1 -138
  29. package/dist/cloud-sync-entrypoint.js +1 -47
  30. package/dist/cloud-sync.js +2 -309
  31. package/dist/constellation.js +12 -168
  32. package/dist/context-build-budgeted.js +4 -144
  33. package/dist/context-ranking.js +1 -69
  34. package/dist/crypto.js +1 -179
  35. package/dist/daemon-write-endpoint.js +1 -290
  36. package/dist/daemon-writer.js +2 -406
  37. package/dist/database.js +43 -1110
  38. package/dist/deprecations.js +2 -162
  39. package/dist/design.js +13 -141
  40. package/dist/event-replication.js +1 -112
  41. package/dist/events-sse.js +7 -43
  42. package/dist/events.js +6 -238
  43. package/dist/failure-patterns.js +42 -659
  44. package/dist/federation.js +12 -236
  45. package/dist/goals.js +13 -101
  46. package/dist/golden.js +3 -355
  47. package/dist/handlers/agent.js +4 -165
  48. package/dist/handlers/alias-adapters.js +1 -129
  49. package/dist/handlers/aliases.js +1 -171
  50. package/dist/handlers/audit.js +1 -87
  51. package/dist/handlers/boundary.js +1 -221
  52. package/dist/handlers/capture.js +73 -1109
  53. package/dist/handlers/causality.js +7 -114
  54. package/dist/handlers/cloud.js +85 -382
  55. package/dist/handlers/companion.js +28 -459
  56. package/dist/handlers/datalake.js +7 -187
  57. package/dist/handlers/dispatch-context.js +0 -22
  58. package/dist/handlers/entity.js +25 -256
  59. package/dist/handlers/events.js +16 -335
  60. package/dist/handlers/failure.js +13 -340
  61. package/dist/handlers/goals.js +4 -296
  62. package/dist/handlers/intelligence.js +126 -674
  63. package/dist/handlers/invoicing.js +1 -70
  64. package/dist/handlers/mcpclient.js +6 -137
  65. package/dist/handlers/orchestration.js +40 -125
  66. package/dist/handlers/output-schemas.js +1 -24
  67. package/dist/handlers/presence.js +3 -99
  68. package/dist/handlers/project.js +28 -182
  69. package/dist/handlers/prompts.js +6 -157
  70. package/dist/handlers/quest.js +4 -224
  71. package/dist/handlers/recall.js +11 -218
  72. package/dist/handlers/registry.js +1 -167
  73. package/dist/handlers/resources.js +1 -288
  74. package/dist/handlers/review.js +11 -74
  75. package/dist/handlers/run.js +17 -487
  76. package/dist/handlers/search.js +15 -326
  77. package/dist/handlers/session.js +28 -615
  78. package/dist/handlers/share.js +8 -184
  79. package/dist/handlers/shims.js +1 -464
  80. package/dist/handlers/skill.js +67 -449
  81. package/dist/handlers/survivors.js +1 -120
  82. package/dist/handlers/symbols.js +8 -109
  83. package/dist/handlers/syncops.js +4 -302
  84. package/dist/handlers/types.js +1 -27
  85. package/dist/harvest.js +5 -191
  86. package/dist/hours.js +7 -156
  87. package/dist/http-auth.js +3 -321
  88. package/dist/http-fast.js +21 -1137
  89. package/dist/icons.js +1 -47
  90. package/dist/index.js +2 -924
  91. package/dist/indexer.js +4 -145
  92. package/dist/intelligence.js +31 -261
  93. package/dist/internal-dispatch.js +3 -212
  94. package/dist/keyset.js +1 -110
  95. package/dist/knowledge-graph.js +12 -176
  96. package/dist/license.d.ts +11 -0
  97. package/dist/license.d.ts.map +1 -1
  98. package/dist/license.js +2 -414
  99. package/dist/license.js.map +1 -1
  100. package/dist/logger.js +2 -199
  101. package/dist/maintenance.js +2 -148
  102. package/dist/mcp-client.js +6 -262
  103. package/dist/memory-artifacts.js +30 -449
  104. package/dist/migrate-prompt.js +2 -124
  105. package/dist/migrations.js +40 -655
  106. package/dist/performance.js +1 -228
  107. package/dist/presence.js +11 -140
  108. package/dist/priority-embed.js +5 -164
  109. package/dist/providers/embedding-provider.js +1 -196
  110. package/dist/readonly-gate.js +1 -29
  111. package/dist/rehydration.js +9 -157
  112. package/dist/reindex.js +1 -88
  113. package/dist/render-target.js +21 -514
  114. package/dist/render.js +4 -280
  115. package/dist/repl-guard.js +1 -173
  116. package/dist/replication-daemon-entrypoint.js +1 -31
  117. package/dist/replication-daemon.js +2 -262
  118. package/dist/resilience.js +1 -591
  119. package/dist/reverse-bridge.js +5 -360
  120. package/dist/security.js +1 -244
  121. package/dist/session-seen.js +3 -51
  122. package/dist/setup.js +1 -260
  123. package/dist/skill-author.js +5 -168
  124. package/dist/spec-kit.js +1 -191
  125. package/dist/sqlite-busy.js +1 -154
  126. package/dist/statusline.js +11 -315
  127. package/dist/sub-agent.js +13 -262
  128. package/dist/summarizer.js +13 -139
  129. package/dist/symbols.js +7 -283
  130. package/dist/sync.js +5 -359
  131. package/dist/tasks-dispatch.js +1 -84
  132. package/dist/tasks.js +1 -282
  133. package/dist/token-budget.js +1 -143
  134. package/dist/tool-analytics.js +7 -129
  135. package/dist/tool-annotations.js +1 -365
  136. package/dist/tool-manifest-v2.json +1 -1
  137. package/dist/tool-manifest.json +1 -1
  138. package/dist/tool-profiles.js +1 -75
  139. package/dist/trace-harvest.js +6 -244
  140. package/dist/types.js +1 -30
  141. package/dist/ui-dashboard.js +41 -50
  142. package/dist/ulid.js +1 -81
  143. package/dist/validate.js +1 -129
  144. package/dist/vault.js +1 -534
  145. package/dist/vectors.js +3 -184
  146. package/dist/version-check.js +4 -136
  147. package/dist/visibility.js +19 -155
  148. package/dist/wyrm-cli.js +98 -2451
  149. package/dist/wyrm-cli.js.map +1 -1
  150. package/dist/wyrm-guard.js +14 -424
  151. package/dist/wyrm-loop.js +3 -150
  152. package/dist/wyrm-manifest.json +1 -1
  153. package/dist/wyrm-statusline-daemon.js +1 -11
  154. package/dist/wyrm-statusline.js +4 -56
  155. package/dist/wyrm-ui.js +9 -77
  156. package/package.json +4 -2
@@ -1,335 +1,16 @@
1
- /**
2
- * @copyright 2026 Ghost Protocol (Pvt) Ltd.
3
- * @license AGPL-3.0-or-later
4
- */
5
- import { TOOL_ANNOTATIONS } from "../tool-annotations.js";
6
- import { installClaudeCodeHooks, installClaudeStatusline } from "../autoconfig.js";
7
- import { replicateOnce } from "../event-replication.js";
8
- import { embedAll, removeAll, statusAll } from "../priority-embed.js";
9
- import { ReplicationDaemon, addPeer, listPeers, removePeer } from "../replication-daemon.js";
10
- export const eventsToolSpecs = [
11
- {
12
- name: "wyrm_events_subscribe",
13
- description: "Use to START consuming a project's Live Memory event stream: returns the current head cursor plus a recent chronological window of events in one read-only call. Nothing persists server-side — poll wyrm_events_since with the returned cursor for new events. Returns disabled:true if WYRM_LIVE_MEMORY is off. Keywords: events, live memory, event stream, cursor, tail events, watch project, replication feed.",
14
- inputSchema: {
15
- type: "object",
16
- properties: {
17
- projectPath: { type: "string", description: "Project path" },
18
- window: { type: "number", description: "How many recent events to return (1-200, default 20)" },
19
- },
20
- required: ["projectPath"],
21
- },
22
- annotations: TOOL_ANNOTATIONS["wyrm_events_subscribe"],
23
- aliases: [],
24
- handler: async (args, ctx) => {
25
- const { db } = ctx;
26
- const a = args || {};
27
- const requireArgs = (fields) => {
28
- const missing = fields.filter(f => !a[f] && a[f] !== 0 && a[f] !== false);
29
- if (missing.length > 0) {
30
- return { content: [{ type: "text", text: `Missing required arguments: ${missing.join(', ')}` }], isError: true };
31
- }
32
- return null;
33
- };
34
- const argErr = requireArgs(['projectPath']);
35
- if (argErr)
36
- return argErr;
37
- const { projectPath, window } = args;
38
- if (!db.liveMemoryEnabled()) {
39
- return { content: [{ type: "text", text: JSON.stringify({ disabled: true, hint: "Set WYRM_LIVE_MEMORY=1 to enable the event log." }) }] };
40
- }
41
- const project = db.getProject(projectPath);
42
- if (!project)
43
- return { content: [{ type: "text", text: "Project not found" }] };
44
- const sub = db.subscribeEvents(project.id, window);
45
- return { content: [{ type: "text", text: JSON.stringify({ project: project.name, cursor: sub.cursor, count: sub.recent.length, events: sub.recent }) }] };
46
- },
47
- },
48
- {
49
- name: "wyrm_events_since",
50
- description: "Live Memory: pull events newer than a cursor for a project, in chronological order. Idempotent — safe to re-poll. Returns the events and the new head cursor to pass next time.",
51
- inputSchema: {
52
- type: "object",
53
- properties: {
54
- projectPath: { type: "string", description: "Project path" },
55
- cursor: { type: "number", description: "Return events with cursor greater than this (default 0 = from start)" },
56
- limit: { type: "number", description: "Max events to return (1-1000, default 100)" },
57
- },
58
- required: ["projectPath"],
59
- },
60
- annotations: TOOL_ANNOTATIONS["wyrm_events_since"],
61
- aliases: [],
62
- handler: async (args, ctx) => {
63
- const { db } = ctx;
64
- const a = args || {};
65
- const requireArgs = (fields) => {
66
- const missing = fields.filter(f => !a[f] && a[f] !== 0 && a[f] !== false);
67
- if (missing.length > 0) {
68
- return { content: [{ type: "text", text: `Missing required arguments: ${missing.join(', ')}` }], isError: true };
69
- }
70
- return null;
71
- };
72
- const argErr = requireArgs(['projectPath']);
73
- if (argErr)
74
- return argErr;
75
- const { projectPath, cursor, limit } = args;
76
- if (!db.liveMemoryEnabled()) {
77
- return { content: [{ type: "text", text: JSON.stringify({ disabled: true, hint: "Set WYRM_LIVE_MEMORY=1 to enable the event log." }) }] };
78
- }
79
- const project = db.getProject(projectPath);
80
- if (!project)
81
- return { content: [{ type: "text", text: "Project not found" }] };
82
- const events = db.eventsSince(project.id, cursor || 0, limit || 100);
83
- const head = events.length ? events[events.length - 1].cursor : (cursor || 0);
84
- return { content: [{ type: "text", text: JSON.stringify({ project: project.name, cursor: head, count: events.length, events }) }] };
85
- },
86
- },
87
- {
88
- name: "wyrm_events_publish",
89
- description: "Live Memory: manually publish an event onto a project's stream (e.g. a tool_call or presence marker). Failure-isolated — never throws. Payload is stored only when isShared is true (reference-only otherwise).",
90
- inputSchema: {
91
- type: "object",
92
- properties: {
93
- projectPath: { type: "string", description: "Project path" },
94
- kind: { type: "string", enum: ["capture", "session_update", "quest", "truth", "presence", "tool_call"], description: "Event kind" },
95
- refTable: { type: "string", description: "Canonical table this event refers to (optional)" },
96
- refId: { type: "string", description: "Canonical row id this event refers to (optional)" },
97
- actor: { type: "string", description: "Who/what produced the event (optional)" },
98
- isShared: { type: "boolean", description: "If true, the payload is denormalized into the event (default false = reference-only)" },
99
- payload: { type: "object", description: "Denormalized snapshot, stored only when isShared is true" },
100
- },
101
- required: ["projectPath", "kind"],
102
- },
103
- annotations: TOOL_ANNOTATIONS["wyrm_events_publish"],
104
- aliases: [],
105
- handler: async (args, ctx) => {
106
- const { db, presence } = ctx;
107
- const a = args || {};
108
- const requireArgs = (fields) => {
109
- const missing = fields.filter(f => !a[f] && a[f] !== 0 && a[f] !== false);
110
- if (missing.length > 0) {
111
- return { content: [{ type: "text", text: `Missing required arguments: ${missing.join(', ')}` }], isError: true };
112
- }
113
- return null;
114
- };
115
- const argErr = requireArgs(['projectPath', 'kind']);
116
- if (argErr)
117
- return argErr;
118
- const { projectPath, kind, refTable, refId, actor, isShared, payload } = args;
119
- if (!db.liveMemoryEnabled()) {
120
- return { content: [{ type: "text", text: JSON.stringify({ disabled: true, hint: "Set WYRM_LIVE_MEMORY=1 to enable the event log." }) }] };
121
- }
122
- const project = db.getProject(projectPath);
123
- if (!project)
124
- return { content: [{ type: "text", text: "Project not found" }] };
125
- db.publishEvent({ projectId: project.id, kind, refTable, refId, actor, isShared, payload });
126
- return { content: [{ type: "text", text: `󱅝 Event published to ${project.name} stream (${kind})` }] };
127
- },
128
- },
129
- {
130
- name: "wyrm_events_replicate",
131
- description: "Live Memory (Phase 3): one-shot cross-device replication with a peer Wyrm node — pulls the peer's shared events and pushes ours over the peer's HTTP surface. Privacy-gated (only is_shared events leave the box; reference-only rows carry no payload), with automatic dedup + echo-suppression. Watermarks persist, so repeat calls are incremental. Returns pulled/pushed/duplicate counts.",
132
- inputSchema: {
133
- type: "object",
134
- properties: {
135
- projectPath: { type: "string", description: "Local project path" },
136
- // v7 T033: wyrm-http was deleted — the peer surface is `wyrm serve` (http-fast).
137
- peerUrl: { type: "string", description: "Peer Wyrm HTTP (wyrm serve) base URL, e.g. http://other-host:3333" },
138
- token: { type: "string", description: "Bearer token for the peer (optional if the peer runs open / dev mode)" },
139
- remoteProject: { type: "string", description: "Project path or name on the peer (defaults to this project's name)" },
140
- },
141
- required: ["projectPath", "peerUrl"],
142
- },
143
- annotations: TOOL_ANNOTATIONS["wyrm_events_replicate"],
144
- aliases: [],
145
- handler: async (args, ctx) => {
146
- const { db } = ctx;
147
- const a = args || {};
148
- const requireArgs = (fields) => {
149
- const missing = fields.filter(f => !a[f] && a[f] !== 0 && a[f] !== false);
150
- if (missing.length > 0) {
151
- return { content: [{ type: "text", text: `Missing required arguments: ${missing.join(', ')}` }], isError: true };
152
- }
153
- return null;
154
- };
155
- const argErr = requireArgs(['projectPath', 'peerUrl']);
156
- if (argErr)
157
- return argErr;
158
- if (!db.liveMemoryEnabled()) {
159
- return { content: [{ type: "text", text: JSON.stringify({ disabled: true, hint: "Set WYRM_LIVE_MEMORY=1 to enable replication." }) }] };
160
- }
161
- const { projectPath, peerUrl, token, remoteProject } = args;
162
- const project = db.getProject(projectPath);
163
- if (!project)
164
- return { content: [{ type: "text", text: "Project not found" }] };
165
- const peer = {
166
- baseUrl: String(peerUrl).replace(/\/+$/, ''),
167
- token,
168
- localProjectId: project.id,
169
- remoteProject: remoteProject || project.name,
170
- };
171
- const r = await replicateOnce(db, peer, fetch);
172
- const summary = `󱅝 Replicated ${project.name} ↔ ${peer.baseUrl}: pulled ${r.pulled}, pushed ${r.pushed}, dup ${r.duplicates}, echo ${r.echoes}` +
173
- (r.errors.length ? `\n⚠️ ${r.errors.join('; ')}` : '');
174
- return { content: [{ type: "text", text: summary }] };
175
- },
176
- },
177
- {
178
- name: "wyrm_replication",
179
- description: "Use to sync memory between machines and watch the live event mesh - action=start|stop|status|tick (daemon + peers; tokens via tokenEnv), conflicts (did the last sync leave conflicts to resolve?), resolve, publish, since, subscribe (watch a project's live activity feed for changes from other agents), replicate (one-shot: sync my memory over to another machine or peer). Back up the memory database off this machine, encrypted: wyrm cloud backup (CLI).",
180
- // v7 F3 (T022, spec FR-4): wyrm_replication absorbs sync_conflicts/
181
- // sync_resolve (action=conflicts|resolve) and the events quartet
182
- // (action=publish|since|subscribe|replicate — the Live-Memory event
183
- // mesh IS the replication domain); resolveShimCall translates each
184
- // onto the original dispatcher case. Existing actions unchanged.
185
- inputSchema: {
186
- type: "object",
187
- properties: {
188
- // v7 F3 (T026): property prose compressed to fund the hot-path
189
- // outputSchemas under the 8K default-surface pin (the T022/T025
190
- // schema-chars trade; BM25 ranks name+description only).
191
- action: { type: "string", enum: ["start", "stop", "status", "tick", "peer_add", "peer_remove", "peer_list", "conflicts", "resolve", "publish", "since", "subscribe", "replicate"] },
192
- interval_minutes: { type: "number", description: "start (default 1)" },
193
- baseUrl: { type: "string", description: "peer_add/peer_remove" },
194
- projectPath: { type: "string" },
195
- remoteProject: { type: "string", description: "peer_add/replicate" },
196
- tokenEnv: { type: "string", description: "peer_add: env var NAME with the peer token" },
197
- limit: { type: "number", description: "conflicts/since" },
198
- conflict_id: { type: "number", description: "resolve" },
199
- mode: { type: "string", description: "resolve: kept_local|kept_remote|merged" },
200
- // T027 budget trim: merged_payload/isShared/window pass through
201
- // undeclared (T022 lean-union rule).
202
- kind: { type: "string", description: "publish" },
203
- payload: { type: "object", description: "publish" },
204
- cursor: { type: "number", description: "since" },
205
- peerUrl: { type: "string", description: "replicate" },
206
- token: { type: "string", description: "replicate: bearer" },
207
- },
208
- required: ["action"],
209
- },
210
- annotations: TOOL_ANNOTATIONS["wyrm_replication"],
211
- aliases: [],
212
- handler: async (args, ctx) => {
213
- const { db, replicationManager } = ctx;
214
- const a = args || {};
215
- const requireArgs = (fields) => {
216
- const missing = fields.filter(f => !a[f] && a[f] !== 0 && a[f] !== false);
217
- if (missing.length > 0) {
218
- return { content: [{ type: "text", text: `Missing required arguments: ${missing.join(', ')}` }], isError: true };
219
- }
220
- return null;
221
- };
222
- const argErr = requireArgs(['action']);
223
- if (argErr)
224
- return argErr;
225
- const { action, interval_minutes, baseUrl, projectPath, remoteProject, tokenEnv } = args;
226
- switch (action) {
227
- case 'start': {
228
- if (!db.liveMemoryEnabled())
229
- return { content: [{ type: "text", text: "Live Memory is off (WYRM_LIVE_MEMORY=0) — daemon not started." }] };
230
- const res = replicationManager.start({ interval_minutes });
231
- return { content: [{ type: "text", text: res.ok ? `󱅝 Replication daemon started (pid ${res.pid})` : `Not started: ${res.reason}` }] };
232
- }
233
- case 'stop': {
234
- const res = replicationManager.stop();
235
- return { content: [{ type: "text", text: res.ok ? "󱅝 Replication daemon stopping" : `Not stopped: ${res.reason}` }] };
236
- }
237
- case 'status': {
238
- const st = replicationManager.status();
239
- const peers = listPeers(db);
240
- return { content: [{ type: "text", text: JSON.stringify({ running: st.running, pid: st.pid, peers }) }] };
241
- }
242
- case 'tick': {
243
- const daemon = new ReplicationDaemon(db);
244
- const results = await daemon.tick(fetch);
245
- return { content: [{ type: "text", text: JSON.stringify({ peers: results.length, results }) }] };
246
- }
247
- case 'peer_add': {
248
- if (!baseUrl || !projectPath)
249
- return { content: [{ type: "text", text: "peer_add requires baseUrl and projectPath" }] };
250
- const project = db.getProject(projectPath);
251
- if (!project)
252
- return { content: [{ type: "text", text: "Project not found" }] };
253
- try {
254
- const peers = addPeer(db, { baseUrl, projectPath, remoteProject, tokenEnv });
255
- return { content: [{ type: "text", text: `󱅝 Peer added. Registry now has ${peers.length} peer(s).` }] };
256
- }
257
- catch (e) {
258
- return { content: [{ type: "text", text: `Peer rejected: ${e instanceof Error ? e.message : String(e)}` }] };
259
- }
260
- }
261
- case 'peer_remove': {
262
- if (!baseUrl || !projectPath)
263
- return { content: [{ type: "text", text: "peer_remove requires baseUrl and projectPath" }] };
264
- const peers = removePeer(db, baseUrl, projectPath);
265
- return { content: [{ type: "text", text: `󱅝 Peer removed. Registry now has ${peers.length} peer(s).` }] };
266
- }
267
- case 'peer_list': {
268
- return { content: [{ type: "text", text: JSON.stringify({ peers: listPeers(db) }) }] };
269
- }
270
- default:
271
- return { content: [{ type: "text", text: `Unknown action: ${action}` }] };
272
- }
273
- },
274
- },
275
- {
276
- name: "wyrm_embed",
277
- description: "Make Wyrm FIRST-PRIORITY, always-loaded memory across Claude Code and other CLIs — so it isn't ignored and is consulted proactively, not just when called. Prepends a managed 'Wyrm is your memory — consult it FIRST' directive to the TOP of each client's always-loaded instruction file (~/.claude/CLAUDE.md globally; project CLAUDE.md/AGENTS.md, and with allClients also .cursorrules/.windsurfrules/.github/copilot-instructions.md). install also installs the proactive SessionStart/predictive hooks. Idempotent + fully reversible. action=install|status|remove.",
278
- inputSchema: {
279
- type: "object",
280
- properties: {
281
- action: { type: "string", enum: ["install", "status", "remove"], description: "Operation to perform" },
282
- projectPath: { type: "string", description: "Also embed into this project's instruction files (CLAUDE.md + AGENTS.md)" },
283
- allClients: { type: "boolean", description: "With projectPath: also write Cursor/.cursorrules, Windsurf/.windsurfrules, and GitHub Copilot instructions (default false)" },
284
- },
285
- required: ["action"],
286
- },
287
- annotations: TOOL_ANNOTATIONS["wyrm_embed"],
288
- aliases: [],
289
- handler: async (args, ctx) => {
290
- const { memory } = ctx;
291
- const a = args || {};
292
- const requireArgs = (fields) => {
293
- const missing = fields.filter(f => !a[f] && a[f] !== 0 && a[f] !== false);
294
- if (missing.length > 0) {
295
- return { content: [{ type: "text", text: `Missing required arguments: ${missing.join(', ')}` }], isError: true };
296
- }
297
- return null;
298
- };
299
- const argErr = requireArgs(['action']);
300
- if (argErr)
301
- return argErr;
302
- const { action, projectPath, allClients } = args;
303
- const opts = { projectDir: projectPath, allClients };
304
- const fmt = (rows) => rows.map(r => ` ${String(r.result ?? r.status).padEnd(9)} [${r.scope}] ${r.file}`).join('\n');
305
- if (action === 'status') {
306
- return { content: [{ type: "text", text: `󱅝 Wyrm priority embedding status:\n${fmt(statusAll(opts))}` }] };
307
- }
308
- if (action === 'remove') {
309
- return { content: [{ type: "text", text: `󱅝 Removed Wyrm priority embedding:\n${fmt(removeAll(opts))}` }] };
310
- }
311
- // install — all three: priority blocks + proactive hooks + persistent buddy statusline
312
- const embedded = embedAll(opts);
313
- let hookNote = '';
314
- try {
315
- const hooks = installClaudeCodeHooks();
316
- hookNote = hooks ? `\n\n✅ Proactive hooks installed (${hooks.message ?? 'SessionStart rehydrate + capture + trace'}).` : '\n\n(Claude Code not detected — skipped hook install.)';
317
- }
318
- catch (e) {
319
- hookNote = `\n\n(Hook install skipped: ${e instanceof Error ? e.message : String(e)})`;
320
- }
321
- let slNote = '';
322
- try {
323
- const sl = installClaudeStatusline();
324
- if (sl)
325
- slNote = `\n✅ Buddy statusline: ${sl.message}`;
326
- }
327
- catch (e) {
328
- slNote = `\n(Statusline skipped: ${e instanceof Error ? e.message : String(e)})`;
329
- }
330
- return { content: [{ type: "text", text: `󱅝 Wyrm is now FIRST-PRIORITY memory:\n${fmt(embedded)}${hookNote}${slNote}\n\n` +
331
- `Wyrm will now be read at the top of every session, primed proactively, and shown in the TUI at all times — not waiting to be called.` }] };
332
- },
333
- },
334
- ];
335
- //# sourceMappingURL=events.js.map
1
+ import{TOOL_ANNOTATIONS as f}from"../tool-annotations.js";import{installClaudeCodeHooks as j,installClaudeStatusline as x}from"../autoconfig.js";import{replicateOnce as w}from"../event-replication.js";import{embedAll as P,removeAll as _,statusAll as E}from"../priority-embed.js";import{ReplicationDaemon as S,addPeer as k,listPeers as b,removePeer as M}from"../replication-daemon.js";const O=[{name:"wyrm_events_subscribe",description:"Use to START consuming a project's Live Memory event stream: returns the current head cursor plus a recent chronological window of events in one read-only call. Nothing persists server-side \u2014 poll wyrm_events_since with the returned cursor for new events. Returns disabled:true if WYRM_LIVE_MEMORY is off. Keywords: events, live memory, event stream, cursor, tail events, watch project, replication feed.",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},window:{type:"number",description:"How many recent events to return (1-200, default 20)"}},required:["projectPath"]},annotations:f.wyrm_events_subscribe,aliases:[],handler:async(a,y)=>{const{db:t}=y,o=a||{},d=(r=>{const m=r.filter(i=>!o[i]&&o[i]!==0&&o[i]!==!1);return m.length>0?{content:[{type:"text",text:`Missing required arguments: ${m.join(", ")}`}],isError:!0}:null})(["projectPath"]);if(d)return d;const{projectPath:p,window:u}=a;if(!t.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const l=t.getProject(p);if(!l)return{content:[{type:"text",text:"Project not found"}]};const s=t.subscribeEvents(l.id,u);return{content:[{type:"text",text:JSON.stringify({project:l.name,cursor:s.cursor,count:s.recent.length,events:s.recent})}]}}},{name:"wyrm_events_since",description:"Live Memory: pull events newer than a cursor for a project, in chronological order. Idempotent \u2014 safe to re-poll. Returns the events and the new head cursor to pass next time.",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},cursor:{type:"number",description:"Return events with cursor greater than this (default 0 = from start)"},limit:{type:"number",description:"Max events to return (1-1000, default 100)"}},required:["projectPath"]},annotations:f.wyrm_events_since,aliases:[],handler:async(a,y)=>{const{db:t}=y,o=a||{},d=(i=>{const n=i.filter(e=>!o[e]&&o[e]!==0&&o[e]!==!1);return n.length>0?{content:[{type:"text",text:`Missing required arguments: ${n.join(", ")}`}],isError:!0}:null})(["projectPath"]);if(d)return d;const{projectPath:p,cursor:u,limit:l}=a;if(!t.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const s=t.getProject(p);if(!s)return{content:[{type:"text",text:"Project not found"}]};const r=t.eventsSince(s.id,u||0,l||100),m=r.length?r[r.length-1].cursor:u||0;return{content:[{type:"text",text:JSON.stringify({project:s.name,cursor:m,count:r.length,events:r})}]}}},{name:"wyrm_events_publish",description:"Live Memory: manually publish an event onto a project's stream (e.g. a tool_call or presence marker). Failure-isolated \u2014 never throws. Payload is stored only when isShared is true (reference-only otherwise).",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},kind:{type:"string",enum:["capture","session_update","quest","truth","presence","tool_call"],description:"Event kind"},refTable:{type:"string",description:"Canonical table this event refers to (optional)"},refId:{type:"string",description:"Canonical row id this event refers to (optional)"},actor:{type:"string",description:"Who/what produced the event (optional)"},isShared:{type:"boolean",description:"If true, the payload is denormalized into the event (default false = reference-only)"},payload:{type:"object",description:"Denormalized snapshot, stored only when isShared is true"}},required:["projectPath","kind"]},annotations:f.wyrm_events_publish,aliases:[],handler:async(a,y)=>{const{db:t,presence:o}=y,h=a||{},p=(c=>{const g=c.filter(v=>!h[v]&&h[v]!==0&&h[v]!==!1);return g.length>0?{content:[{type:"text",text:`Missing required arguments: ${g.join(", ")}`}],isError:!0}:null})(["projectPath","kind"]);if(p)return p;const{projectPath:u,kind:l,refTable:s,refId:r,actor:m,isShared:i,payload:n}=a;if(!t.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const e=t.getProject(u);return e?(t.publishEvent({projectId:e.id,kind:l,refTable:s,refId:r,actor:m,isShared:i,payload:n}),{content:[{type:"text",text:`\u{F115D} Event published to ${e.name} stream (${l})`}]}):{content:[{type:"text",text:"Project not found"}]}}},{name:"wyrm_events_replicate",description:"Live Memory (Phase 3): one-shot cross-device replication with a peer Wyrm node \u2014 pulls the peer's shared events and pushes ours over the peer's HTTP surface. Privacy-gated (only is_shared events leave the box; reference-only rows carry no payload), with automatic dedup + echo-suppression. Watermarks persist, so repeat calls are incremental. Returns pulled/pushed/duplicate counts.",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Local project path"},peerUrl:{type:"string",description:"Peer Wyrm HTTP (wyrm serve) base URL, e.g. http://other-host:3333"},token:{type:"string",description:"Bearer token for the peer (optional if the peer runs open / dev mode)"},remoteProject:{type:"string",description:"Project path or name on the peer (defaults to this project's name)"}},required:["projectPath","peerUrl"]},annotations:f.wyrm_events_replicate,aliases:[],handler:async(a,y)=>{const{db:t}=y,o=a||{},d=(e=>{const c=e.filter(g=>!o[g]&&o[g]!==0&&o[g]!==!1);return c.length>0?{content:[{type:"text",text:`Missing required arguments: ${c.join(", ")}`}],isError:!0}:null})(["projectPath","peerUrl"]);if(d)return d;if(!t.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable replication."})}]};const{projectPath:p,peerUrl:u,token:l,remoteProject:s}=a,r=t.getProject(p);if(!r)return{content:[{type:"text",text:"Project not found"}]};const m={baseUrl:String(u).replace(/\/+$/,""),token:l,localProjectId:r.id,remoteProject:s||r.name},i=await w(t,m,fetch);return{content:[{type:"text",text:`\u{F115D} Replicated ${r.name} \u2194 ${m.baseUrl}: pulled ${i.pulled}, pushed ${i.pushed}, dup ${i.duplicates}, echo ${i.echoes}`+(i.errors.length?`
2
+ \u26A0\uFE0F ${i.errors.join("; ")}`:"")}]}}},{name:"wyrm_replication",description:"Use to sync memory between machines and watch the live event mesh - action=start|stop|status|tick (daemon + peers; tokens via tokenEnv), conflicts (did the last sync leave conflicts to resolve?), resolve, publish, since, subscribe (watch a project's live activity feed for changes from other agents), replicate (one-shot: sync my memory over to another machine or peer). Back up the memory database off this machine, encrypted: wyrm cloud backup (CLI).",inputSchema:{type:"object",properties:{action:{type:"string",enum:["start","stop","status","tick","peer_add","peer_remove","peer_list","conflicts","resolve","publish","since","subscribe","replicate"]},interval_minutes:{type:"number",description:"start (default 1)"},baseUrl:{type:"string",description:"peer_add/peer_remove"},projectPath:{type:"string"},remoteProject:{type:"string",description:"peer_add/replicate"},tokenEnv:{type:"string",description:"peer_add: env var NAME with the peer token"},limit:{type:"number",description:"conflicts/since"},conflict_id:{type:"number",description:"resolve"},mode:{type:"string",description:"resolve: kept_local|kept_remote|merged"},kind:{type:"string",description:"publish"},payload:{type:"object",description:"publish"},cursor:{type:"number",description:"since"},peerUrl:{type:"string",description:"replicate"},token:{type:"string",description:"replicate: bearer"}},required:["action"]},annotations:f.wyrm_replication,aliases:[],handler:async(a,y)=>{const{db:t,replicationManager:o}=y,h=a||{},p=(n=>{const e=n.filter(c=>!h[c]&&h[c]!==0&&h[c]!==!1);return e.length>0?{content:[{type:"text",text:`Missing required arguments: ${e.join(", ")}`}],isError:!0}:null})(["action"]);if(p)return p;const{action:u,interval_minutes:l,baseUrl:s,projectPath:r,remoteProject:m,tokenEnv:i}=a;switch(u){case"start":{if(!t.liveMemoryEnabled())return{content:[{type:"text",text:"Live Memory is off (WYRM_LIVE_MEMORY=0) \u2014 daemon not started."}]};const n=o.start({interval_minutes:l});return{content:[{type:"text",text:n.ok?`\u{F115D} Replication daemon started (pid ${n.pid})`:`Not started: ${n.reason}`}]}}case"stop":{const n=o.stop();return{content:[{type:"text",text:n.ok?"\u{F115D} Replication daemon stopping":`Not stopped: ${n.reason}`}]}}case"status":{const n=o.status(),e=b(t);return{content:[{type:"text",text:JSON.stringify({running:n.running,pid:n.pid,peers:e})}]}}case"tick":{const e=await new S(t).tick(fetch);return{content:[{type:"text",text:JSON.stringify({peers:e.length,results:e})}]}}case"peer_add":{if(!s||!r)return{content:[{type:"text",text:"peer_add requires baseUrl and projectPath"}]};if(!t.getProject(r))return{content:[{type:"text",text:"Project not found"}]};try{return{content:[{type:"text",text:`\u{F115D} Peer added. Registry now has ${k(t,{baseUrl:s,projectPath:r,remoteProject:m,tokenEnv:i}).length} peer(s).`}]}}catch(e){return{content:[{type:"text",text:`Peer rejected: ${e instanceof Error?e.message:String(e)}`}]}}}case"peer_remove":return!s||!r?{content:[{type:"text",text:"peer_remove requires baseUrl and projectPath"}]}:{content:[{type:"text",text:`\u{F115D} Peer removed. Registry now has ${M(t,s,r).length} peer(s).`}]};case"peer_list":return{content:[{type:"text",text:JSON.stringify({peers:b(t)})}]};default:return{content:[{type:"text",text:`Unknown action: ${u}`}]}}}},{name:"wyrm_embed",description:"Make Wyrm FIRST-PRIORITY, always-loaded memory across Claude Code and other CLIs \u2014 so it isn't ignored and is consulted proactively, not just when called. Prepends a managed 'Wyrm is your memory \u2014 consult it FIRST' directive to the TOP of each client's always-loaded instruction file (~/.claude/CLAUDE.md globally; project CLAUDE.md/AGENTS.md, and with allClients also .cursorrules/.windsurfrules/.github/copilot-instructions.md). install also installs the proactive SessionStart/predictive hooks. Idempotent + fully reversible. action=install|status|remove.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["install","status","remove"],description:"Operation to perform"},projectPath:{type:"string",description:"Also embed into this project's instruction files (CLAUDE.md + AGENTS.md)"},allClients:{type:"boolean",description:"With projectPath: also write Cursor/.cursorrules, Windsurf/.windsurfrules, and GitHub Copilot instructions (default false)"}},required:["action"]},annotations:f.wyrm_embed,aliases:[],handler:async(a,y)=>{const{memory:t}=y,o=a||{},d=(e=>{const c=e.filter(g=>!o[g]&&o[g]!==0&&o[g]!==!1);return c.length>0?{content:[{type:"text",text:`Missing required arguments: ${c.join(", ")}`}],isError:!0}:null})(["action"]);if(d)return d;const{action:p,projectPath:u,allClients:l}=a,s={projectDir:u,allClients:l},r=e=>e.map(c=>` ${String(c.result??c.status).padEnd(9)} [${c.scope}] ${c.file}`).join(`
3
+ `);if(p==="status")return{content:[{type:"text",text:`\u{F115D} Wyrm priority embedding status:
4
+ ${r(E(s))}`}]};if(p==="remove")return{content:[{type:"text",text:`\u{F115D} Removed Wyrm priority embedding:
5
+ ${r(_(s))}`}]};const m=P(s);let i="";try{const e=j();i=e?`
6
+
7
+ \u2705 Proactive hooks installed (${e.message??"SessionStart rehydrate + capture + trace"}).`:`
8
+
9
+ (Claude Code not detected \u2014 skipped hook install.)`}catch(e){i=`
10
+
11
+ (Hook install skipped: ${e instanceof Error?e.message:String(e)})`}let n="";try{const e=x();e&&(n=`
12
+ \u2705 Buddy statusline: ${e.message}`)}catch(e){n=`
13
+ (Statusline skipped: ${e instanceof Error?e.message:String(e)})`}return{content:[{type:"text",text:`\u{F115D} Wyrm is now FIRST-PRIORITY memory:
14
+ ${r(m)}${i}${n}
15
+
16
+ Wyrm will now be read at the top of every session, primed proactively, and shown in the TUI at all times \u2014 not waiting to be called.`}]}}}];export{O as eventsToolSpecs};