wyrm-mcp 7.2.1 → 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 (150) hide show
  1. package/LICENSE +26 -667
  2. package/NOTICE +14 -33
  3. package/dist/activation.js +1 -60
  4. package/dist/agent-daemon.js +4 -281
  5. package/dist/agent-loop.js +7 -332
  6. package/dist/analytics.js +13 -236
  7. package/dist/attribution.js +1 -49
  8. package/dist/audit.js +2 -457
  9. package/dist/auto-capture.js +3 -138
  10. package/dist/auto-orchestrator.js +1 -325
  11. package/dist/autoconfig.js +39 -840
  12. package/dist/buddy-runner.js +1 -109
  13. package/dist/buddy.js +14 -564
  14. package/dist/build-flags.js +1 -17
  15. package/dist/capabilities.js +3 -183
  16. package/dist/capture.js +1 -56
  17. package/dist/causality.js +6 -107
  18. package/dist/cli.js +20 -281
  19. package/dist/cloud/cli.js +5 -541
  20. package/dist/cloud/client.js +1 -221
  21. package/dist/cloud/crypto.js +1 -85
  22. package/dist/cloud/machine-id.js +2 -113
  23. package/dist/cloud/recovery.js +1 -60
  24. package/dist/cloud/sync-engine.js +7 -543
  25. package/dist/cloud-backup.js +5 -579
  26. package/dist/cloud-profile.js +1 -138
  27. package/dist/cloud-sync-entrypoint.js +1 -47
  28. package/dist/cloud-sync.js +2 -309
  29. package/dist/constellation.js +12 -168
  30. package/dist/context-build-budgeted.js +4 -144
  31. package/dist/context-ranking.js +1 -69
  32. package/dist/crypto.js +1 -179
  33. package/dist/daemon-write-endpoint.js +1 -290
  34. package/dist/daemon-writer.js +2 -406
  35. package/dist/database.js +43 -1110
  36. package/dist/deprecations.js +2 -162
  37. package/dist/design.js +13 -141
  38. package/dist/event-replication.js +1 -112
  39. package/dist/events-sse.js +7 -43
  40. package/dist/events.js +6 -238
  41. package/dist/failure-patterns.js +42 -659
  42. package/dist/federation.js +12 -236
  43. package/dist/goals.js +13 -101
  44. package/dist/golden.js +3 -355
  45. package/dist/handlers/agent.js +4 -165
  46. package/dist/handlers/alias-adapters.js +1 -129
  47. package/dist/handlers/aliases.js +1 -171
  48. package/dist/handlers/audit.js +1 -87
  49. package/dist/handlers/boundary.js +1 -221
  50. package/dist/handlers/capture.js +73 -1109
  51. package/dist/handlers/causality.js +7 -114
  52. package/dist/handlers/cloud.js +85 -382
  53. package/dist/handlers/companion.js +28 -459
  54. package/dist/handlers/datalake.js +7 -187
  55. package/dist/handlers/dispatch-context.js +0 -22
  56. package/dist/handlers/entity.js +25 -256
  57. package/dist/handlers/events.js +16 -335
  58. package/dist/handlers/failure.js +13 -340
  59. package/dist/handlers/goals.js +4 -296
  60. package/dist/handlers/intelligence.js +126 -674
  61. package/dist/handlers/invoicing.js +1 -70
  62. package/dist/handlers/mcpclient.js +6 -137
  63. package/dist/handlers/orchestration.js +40 -125
  64. package/dist/handlers/output-schemas.js +1 -24
  65. package/dist/handlers/presence.js +3 -99
  66. package/dist/handlers/project.js +28 -182
  67. package/dist/handlers/prompts.js +6 -157
  68. package/dist/handlers/quest.js +4 -224
  69. package/dist/handlers/recall.js +11 -218
  70. package/dist/handlers/registry.js +1 -167
  71. package/dist/handlers/resources.js +1 -288
  72. package/dist/handlers/review.js +11 -74
  73. package/dist/handlers/run.js +17 -487
  74. package/dist/handlers/search.js +15 -326
  75. package/dist/handlers/session.js +28 -615
  76. package/dist/handlers/share.js +8 -184
  77. package/dist/handlers/shims.js +1 -464
  78. package/dist/handlers/skill.js +67 -449
  79. package/dist/handlers/survivors.js +1 -120
  80. package/dist/handlers/symbols.js +8 -109
  81. package/dist/handlers/syncops.js +4 -302
  82. package/dist/handlers/types.js +1 -27
  83. package/dist/harvest.js +5 -191
  84. package/dist/hours.js +7 -156
  85. package/dist/http-auth.js +3 -321
  86. package/dist/http-fast.js +21 -1137
  87. package/dist/icons.js +1 -47
  88. package/dist/index.js +2 -924
  89. package/dist/indexer.js +4 -145
  90. package/dist/intelligence.js +31 -261
  91. package/dist/internal-dispatch.js +3 -212
  92. package/dist/keyset.js +1 -110
  93. package/dist/knowledge-graph.js +12 -176
  94. package/dist/license.js +2 -441
  95. package/dist/logger.js +2 -199
  96. package/dist/maintenance.js +2 -148
  97. package/dist/mcp-client.js +6 -262
  98. package/dist/memory-artifacts.js +30 -449
  99. package/dist/migrate-prompt.js +2 -124
  100. package/dist/migrations.js +40 -655
  101. package/dist/performance.js +1 -228
  102. package/dist/presence.js +11 -140
  103. package/dist/priority-embed.js +5 -164
  104. package/dist/providers/embedding-provider.js +1 -196
  105. package/dist/readonly-gate.js +1 -29
  106. package/dist/rehydration.js +9 -157
  107. package/dist/reindex.js +1 -88
  108. package/dist/render-target.js +21 -514
  109. package/dist/render.js +4 -280
  110. package/dist/repl-guard.js +1 -173
  111. package/dist/replication-daemon-entrypoint.js +1 -31
  112. package/dist/replication-daemon.js +2 -262
  113. package/dist/resilience.js +1 -591
  114. package/dist/reverse-bridge.js +5 -360
  115. package/dist/security.js +1 -244
  116. package/dist/session-seen.js +3 -51
  117. package/dist/setup.js +1 -260
  118. package/dist/skill-author.js +5 -168
  119. package/dist/spec-kit.js +1 -191
  120. package/dist/sqlite-busy.js +1 -154
  121. package/dist/statusline.js +11 -315
  122. package/dist/sub-agent.js +13 -262
  123. package/dist/summarizer.js +13 -139
  124. package/dist/symbols.js +7 -283
  125. package/dist/sync.js +5 -359
  126. package/dist/tasks-dispatch.js +1 -84
  127. package/dist/tasks.js +1 -282
  128. package/dist/token-budget.js +1 -143
  129. package/dist/tool-analytics.js +7 -129
  130. package/dist/tool-annotations.js +1 -365
  131. package/dist/tool-manifest-v2.json +1 -1
  132. package/dist/tool-manifest.json +1 -1
  133. package/dist/tool-profiles.js +1 -75
  134. package/dist/trace-harvest.js +6 -244
  135. package/dist/types.js +1 -30
  136. package/dist/ui-dashboard.js +41 -50
  137. package/dist/ulid.js +1 -81
  138. package/dist/validate.js +1 -129
  139. package/dist/vault.js +1 -534
  140. package/dist/vectors.js +3 -184
  141. package/dist/version-check.js +4 -136
  142. package/dist/visibility.js +19 -155
  143. package/dist/wyrm-cli.js +98 -2464
  144. package/dist/wyrm-guard.js +14 -424
  145. package/dist/wyrm-loop.js +3 -150
  146. package/dist/wyrm-manifest.json +1 -1
  147. package/dist/wyrm-statusline-daemon.js +1 -11
  148. package/dist/wyrm-statusline.js +4 -56
  149. package/dist/wyrm-ui.js +9 -77
  150. 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};