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.
- package/LICENSE +26 -667
- package/NOTICE +14 -33
- package/dist/activation.d.ts.map +1 -1
- package/dist/activation.js +1 -44
- package/dist/activation.js.map +1 -1
- package/dist/agent-daemon.js +4 -281
- package/dist/agent-loop.js +7 -332
- package/dist/analytics.js +13 -236
- package/dist/attribution.js +1 -49
- package/dist/audit.js +2 -457
- package/dist/auto-capture.js +3 -138
- package/dist/auto-orchestrator.js +1 -325
- package/dist/autoconfig.js +39 -840
- package/dist/buddy-runner.js +1 -109
- package/dist/buddy.js +14 -564
- package/dist/build-flags.js +1 -17
- package/dist/capabilities.js +3 -183
- package/dist/capture.js +1 -56
- package/dist/causality.js +6 -107
- package/dist/cli.js +20 -281
- package/dist/cloud/cli.js +5 -541
- package/dist/cloud/client.js +1 -221
- package/dist/cloud/crypto.js +1 -85
- package/dist/cloud/machine-id.js +2 -113
- package/dist/cloud/recovery.js +1 -60
- package/dist/cloud/sync-engine.js +7 -543
- package/dist/cloud-backup.js +5 -579
- package/dist/cloud-profile.js +1 -138
- package/dist/cloud-sync-entrypoint.js +1 -47
- package/dist/cloud-sync.js +2 -309
- package/dist/constellation.js +12 -168
- package/dist/context-build-budgeted.js +4 -144
- package/dist/context-ranking.js +1 -69
- package/dist/crypto.js +1 -179
- package/dist/daemon-write-endpoint.js +1 -290
- package/dist/daemon-writer.js +2 -406
- package/dist/database.js +43 -1110
- package/dist/deprecations.js +2 -162
- package/dist/design.js +13 -141
- package/dist/event-replication.js +1 -112
- package/dist/events-sse.js +7 -43
- package/dist/events.js +6 -238
- package/dist/failure-patterns.js +42 -659
- package/dist/federation.js +12 -236
- package/dist/goals.js +13 -101
- package/dist/golden.js +3 -355
- package/dist/handlers/agent.js +4 -165
- package/dist/handlers/alias-adapters.js +1 -129
- package/dist/handlers/aliases.js +1 -171
- package/dist/handlers/audit.js +1 -87
- package/dist/handlers/boundary.js +1 -221
- package/dist/handlers/capture.js +73 -1109
- package/dist/handlers/causality.js +7 -114
- package/dist/handlers/cloud.js +85 -382
- package/dist/handlers/companion.js +28 -459
- package/dist/handlers/datalake.js +7 -187
- package/dist/handlers/dispatch-context.js +0 -22
- package/dist/handlers/entity.js +25 -256
- package/dist/handlers/events.js +16 -335
- package/dist/handlers/failure.js +13 -340
- package/dist/handlers/goals.js +4 -296
- package/dist/handlers/intelligence.js +126 -674
- package/dist/handlers/invoicing.js +1 -70
- package/dist/handlers/mcpclient.js +6 -137
- package/dist/handlers/orchestration.js +40 -125
- package/dist/handlers/output-schemas.js +1 -24
- package/dist/handlers/presence.js +3 -99
- package/dist/handlers/project.js +28 -182
- package/dist/handlers/prompts.js +6 -157
- package/dist/handlers/quest.js +4 -224
- package/dist/handlers/recall.js +11 -218
- package/dist/handlers/registry.js +1 -167
- package/dist/handlers/resources.js +1 -288
- package/dist/handlers/review.js +11 -74
- package/dist/handlers/run.js +17 -487
- package/dist/handlers/search.js +15 -326
- package/dist/handlers/session.js +28 -615
- package/dist/handlers/share.js +8 -184
- package/dist/handlers/shims.js +1 -464
- package/dist/handlers/skill.js +67 -449
- package/dist/handlers/survivors.js +1 -120
- package/dist/handlers/symbols.js +8 -109
- package/dist/handlers/syncops.js +4 -302
- package/dist/handlers/types.js +1 -27
- package/dist/harvest.js +5 -191
- package/dist/hours.js +7 -156
- package/dist/http-auth.js +3 -321
- package/dist/http-fast.js +21 -1137
- package/dist/icons.js +1 -47
- package/dist/index.js +2 -924
- package/dist/indexer.js +4 -145
- package/dist/intelligence.js +31 -261
- package/dist/internal-dispatch.js +3 -212
- package/dist/keyset.js +1 -110
- package/dist/knowledge-graph.js +12 -176
- package/dist/license.d.ts +11 -0
- package/dist/license.d.ts.map +1 -1
- package/dist/license.js +2 -414
- package/dist/license.js.map +1 -1
- package/dist/logger.js +2 -199
- package/dist/maintenance.js +2 -148
- package/dist/mcp-client.js +6 -262
- package/dist/memory-artifacts.js +30 -449
- package/dist/migrate-prompt.js +2 -124
- package/dist/migrations.js +40 -655
- package/dist/performance.js +1 -228
- package/dist/presence.js +11 -140
- package/dist/priority-embed.js +5 -164
- package/dist/providers/embedding-provider.js +1 -196
- package/dist/readonly-gate.js +1 -29
- package/dist/rehydration.js +9 -157
- package/dist/reindex.js +1 -88
- package/dist/render-target.js +21 -514
- package/dist/render.js +4 -280
- package/dist/repl-guard.js +1 -173
- package/dist/replication-daemon-entrypoint.js +1 -31
- package/dist/replication-daemon.js +2 -262
- package/dist/resilience.js +1 -591
- package/dist/reverse-bridge.js +5 -360
- package/dist/security.js +1 -244
- package/dist/session-seen.js +3 -51
- package/dist/setup.js +1 -260
- package/dist/skill-author.js +5 -168
- package/dist/spec-kit.js +1 -191
- package/dist/sqlite-busy.js +1 -154
- package/dist/statusline.js +11 -315
- package/dist/sub-agent.js +13 -262
- package/dist/summarizer.js +13 -139
- package/dist/symbols.js +7 -283
- package/dist/sync.js +5 -359
- package/dist/tasks-dispatch.js +1 -84
- package/dist/tasks.js +1 -282
- package/dist/token-budget.js +1 -143
- package/dist/tool-analytics.js +7 -129
- package/dist/tool-annotations.js +1 -365
- package/dist/tool-manifest-v2.json +1 -1
- package/dist/tool-manifest.json +1 -1
- package/dist/tool-profiles.js +1 -75
- package/dist/trace-harvest.js +6 -244
- package/dist/types.js +1 -30
- package/dist/ui-dashboard.js +41 -50
- package/dist/ulid.js +1 -81
- package/dist/validate.js +1 -129
- package/dist/vault.js +1 -534
- package/dist/vectors.js +3 -184
- package/dist/version-check.js +4 -136
- package/dist/visibility.js +19 -155
- package/dist/wyrm-cli.js +98 -2451
- package/dist/wyrm-cli.js.map +1 -1
- package/dist/wyrm-guard.js +14 -424
- package/dist/wyrm-loop.js +3 -150
- package/dist/wyrm-manifest.json +1 -1
- package/dist/wyrm-statusline-daemon.js +1 -11
- package/dist/wyrm-statusline.js +4 -56
- package/dist/wyrm-ui.js +9 -77
- package/package.json +4 -2
package/dist/handlers/project.js
CHANGED
|
@@ -1,182 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const projects = db.scanForProjects(path, recursive !== false);
|
|
31
|
-
return {
|
|
32
|
-
content: [{
|
|
33
|
-
type: "text",
|
|
34
|
-
text: ` Scanned ${path}\n\nDiscovered ${projects.length} projects:\n${projects.map(p => `- ${p.name} (${p.stack || 'unknown'}) - ${p.branch || 'no branch'}`).join('\n')}${watch ? '\n\nAdded to watch list for future auto-scans.' : ''}`
|
|
35
|
-
}]
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "wyrm_list_projects",
|
|
41
|
-
description: "List all registered projects with their status",
|
|
42
|
-
inputSchema: {
|
|
43
|
-
type: "object",
|
|
44
|
-
properties: {
|
|
45
|
-
search: { type: "string", description: "Search query to filter projects" },
|
|
46
|
-
limit: { type: "number", description: "Max projects to return" },
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
annotations: TOOL_ANNOTATIONS["wyrm_list_projects"],
|
|
50
|
-
aliases: [],
|
|
51
|
-
handler: async (args, ctx) => {
|
|
52
|
-
const { cachedResponse, db } = ctx;
|
|
53
|
-
const cacheKey = currentReadCacheKey();
|
|
54
|
-
const { search, limit } = args;
|
|
55
|
-
const projects = search
|
|
56
|
-
? db.searchProjects(search)
|
|
57
|
-
: db.getAllProjects(limit || 50);
|
|
58
|
-
const projectList = projects.map(p => {
|
|
59
|
-
const stats = db.getProjectStats(p.id);
|
|
60
|
-
return `## ${p.name}\n` +
|
|
61
|
-
`- **Path:** ${p.path}\n` +
|
|
62
|
-
`- **Stack:** ${p.stack || 'unknown'}\n` +
|
|
63
|
-
`- **Branch:** ${p.branch || 'N/A'}\n` +
|
|
64
|
-
`- **Sessions:** ${stats.sessions} | **Quests:** ${stats.quests.pending}p/${stats.quests.completed}c\n` +
|
|
65
|
-
`- **Data:** ${stats.dataPoints}`;
|
|
66
|
-
}).join('\n\n');
|
|
67
|
-
const response = cachedResponse(` **${projects.length} Projects**\n\n${projectList}`);
|
|
68
|
-
if (cacheKey)
|
|
69
|
-
cache.set(cacheKey, response, 60000); // 60s TTL
|
|
70
|
-
return response;
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "wyrm_project_context",
|
|
75
|
-
description: "Get full context for a specific project including recent sessions, quests, and stored context",
|
|
76
|
-
inputSchema: {
|
|
77
|
-
type: "object",
|
|
78
|
-
properties: {
|
|
79
|
-
projectPath: { type: "string", description: "Project path" },
|
|
80
|
-
projectName: { type: "string", description: "Or project name" },
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
annotations: TOOL_ANNOTATIONS["wyrm_project_context"],
|
|
84
|
-
aliases: [],
|
|
85
|
-
handler: async (args, ctx) => {
|
|
86
|
-
const { cachedResponse, db } = ctx;
|
|
87
|
-
const cacheKey = currentReadCacheKey();
|
|
88
|
-
const { projectPath, projectName } = args;
|
|
89
|
-
let project = projectPath ? db.getProject(projectPath) : undefined;
|
|
90
|
-
if (!project && projectName) {
|
|
91
|
-
project = db.getProjectByName(projectName);
|
|
92
|
-
}
|
|
93
|
-
if (!project) {
|
|
94
|
-
return { content: [{ type: "text", text: "Project not found. Run wyrm_scan_projects first." }] };
|
|
95
|
-
}
|
|
96
|
-
// Gather data for context bundle
|
|
97
|
-
const recentSessions = db.getRecentSessions(project.id, 10);
|
|
98
|
-
const quests = db.getPendingQuests(project.id).map(q => ({ title: q.title, priority: q.priority }));
|
|
99
|
-
const currentContext = db.getAllContext(project.id);
|
|
100
|
-
const context = createContextBundle({ name: project.name, stack: project.stack }, currentContext, recentSessions, quests);
|
|
101
|
-
const response = cachedResponse(` **Context for ${project.name}**\n\n${context}`);
|
|
102
|
-
if (cacheKey)
|
|
103
|
-
cache.set(cacheKey, response, 30000); // 30s TTL — context changes more often
|
|
104
|
-
return response;
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "wyrm_global_context",
|
|
109
|
-
description: "Get overview of all projects, pending quests across projects, and global context",
|
|
110
|
-
inputSchema: {
|
|
111
|
-
type: "object",
|
|
112
|
-
properties: {
|
|
113
|
-
includeQuests: { type: "boolean", description: "Include all pending quests" },
|
|
114
|
-
maxProjects: { type: "number", description: "Max projects to include" },
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
annotations: TOOL_ANNOTATIONS["wyrm_global_context"],
|
|
118
|
-
aliases: [],
|
|
119
|
-
handler: async (args, ctx) => {
|
|
120
|
-
const { cachedResponse, db } = ctx;
|
|
121
|
-
const cacheKey = currentReadCacheKey();
|
|
122
|
-
const { includeQuests, maxProjects } = args;
|
|
123
|
-
const projects = db.getAllProjects(maxProjects || 20);
|
|
124
|
-
const globalContext = db.getAllGlobalContext();
|
|
125
|
-
let text = ` **Wyrm Global Overview**\n\n`;
|
|
126
|
-
// Global context
|
|
127
|
-
if (Object.keys(globalContext).length > 0) {
|
|
128
|
-
text += `## Global Context\n`;
|
|
129
|
-
for (const [key, value] of Object.entries(globalContext)) {
|
|
130
|
-
text += `- **${key}:** ${value.slice(0, 200)}${value.length > 200 ? '...' : ''}\n`;
|
|
131
|
-
}
|
|
132
|
-
text += '\n';
|
|
133
|
-
}
|
|
134
|
-
// Projects summary
|
|
135
|
-
text += `## Projects (${projects.length})\n`;
|
|
136
|
-
for (const p of projects) {
|
|
137
|
-
const stats = db.getProjectStats(p.id);
|
|
138
|
-
text += `- **${p.name}** (${p.stack || '?'}) - ${stats.quests.pending} quests, ${stats.sessions} sessions\n`;
|
|
139
|
-
}
|
|
140
|
-
text += '\n';
|
|
141
|
-
// All pending quests
|
|
142
|
-
if (includeQuests) {
|
|
143
|
-
const allQuests = db.getAllPendingQuests();
|
|
144
|
-
text += `## All Pending Quests (${allQuests.length})\n`;
|
|
145
|
-
for (const q of allQuests.slice(0, 20)) {
|
|
146
|
-
const emoji = { critical: '🔴', high: '🟠', medium: '🟡', low: '🟢' }[q.priority];
|
|
147
|
-
text += `- ${emoji} [${q.project_name}] ${q.title}\n`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
const response = cachedResponse(text);
|
|
151
|
-
if (cacheKey)
|
|
152
|
-
cache.set(cacheKey, response, 45000); // 45s TTL
|
|
153
|
-
return response;
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: "wyrm_set_global",
|
|
158
|
-
description: "Set global context that applies across all projects",
|
|
159
|
-
inputSchema: {
|
|
160
|
-
type: "object",
|
|
161
|
-
properties: {
|
|
162
|
-
key: { type: "string", description: "Context key" },
|
|
163
|
-
value: { type: "string", description: "Context value" },
|
|
164
|
-
},
|
|
165
|
-
required: ["key", "value"],
|
|
166
|
-
},
|
|
167
|
-
annotations: TOOL_ANNOTATIONS["wyrm_set_global"],
|
|
168
|
-
aliases: [],
|
|
169
|
-
handler: async (args, ctx) => {
|
|
170
|
-
const { db } = ctx;
|
|
171
|
-
const { key, value } = args;
|
|
172
|
-
db.setGlobalContext(key, value);
|
|
173
|
-
return {
|
|
174
|
-
content: [{
|
|
175
|
-
type: "text",
|
|
176
|
-
text: ` Global context set: ${key}`
|
|
177
|
-
}]
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
];
|
|
182
|
-
//# sourceMappingURL=project.js.map
|
|
1
|
+
import{TOOL_ANNOTATIONS as m}from"../tool-annotations.js";import{currentReadCacheKey as h}from"./boundary.js";import{cache as y}from"../performance.js";import{createContextBundle as g}from"../summarizer.js";const _=[{name:"wyrm_scan_projects",description:"Scan a directory for git projects and register them. Use this to auto-discover all projects.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Directory path to scan (e.g., /home/user/Git Projects)"},watch:{type:"boolean",description:"Add to watch list for future auto-scans"},recursive:{type:"boolean",description:"Scan subdirectories recursively"}},required:["path"]},annotations:m.wyrm_scan_projects,aliases:[],handler:async(p,l)=>{const{db:r}=l,{path:t,watch:o,recursive:a}=p;o&&r.addWatchDir(t,a!==!1);const d=r.scanForProjects(t,a!==!1);return{content:[{type:"text",text:`\u{F115D} Scanned ${t}
|
|
2
|
+
|
|
3
|
+
Discovered ${d.length} projects:
|
|
4
|
+
${d.map(e=>`- ${e.name} (${e.stack||"unknown"}) - ${e.branch||"no branch"}`).join(`
|
|
5
|
+
`)}${o?`
|
|
6
|
+
|
|
7
|
+
Added to watch list for future auto-scans.`:""}`}]}}},{name:"wyrm_list_projects",description:"List all registered projects with their status",inputSchema:{type:"object",properties:{search:{type:"string",description:"Search query to filter projects"},limit:{type:"number",description:"Max projects to return"}}},annotations:m.wyrm_list_projects,aliases:[],handler:async(p,l)=>{const{cachedResponse:r,db:t}=l,o=h(),{search:a,limit:d}=p,e=a?t.searchProjects(a):t.getAllProjects(d||50),u=e.map(i=>{const n=t.getProjectStats(i.id);return`## ${i.name}
|
|
8
|
+
- **Path:** ${i.path}
|
|
9
|
+
- **Stack:** ${i.stack||"unknown"}
|
|
10
|
+
- **Branch:** ${i.branch||"N/A"}
|
|
11
|
+
- **Sessions:** ${n.sessions} | **Quests:** ${n.quests.pending}p/${n.quests.completed}c
|
|
12
|
+
- **Data:** ${n.dataPoints}`}).join(`
|
|
13
|
+
|
|
14
|
+
`),s=r(`\u{F115D} **${e.length} Projects**
|
|
15
|
+
|
|
16
|
+
${u}`);return o&&y.set(o,s,6e4),s}},{name:"wyrm_project_context",description:"Get full context for a specific project including recent sessions, quests, and stored context",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},projectName:{type:"string",description:"Or project name"}}},annotations:m.wyrm_project_context,aliases:[],handler:async(p,l)=>{const{cachedResponse:r,db:t}=l,o=h(),{projectPath:a,projectName:d}=p;let e=a?t.getProject(a):void 0;if(!e&&d&&(e=t.getProjectByName(d)),!e)return{content:[{type:"text",text:"Project not found. Run wyrm_scan_projects first."}]};const u=t.getRecentSessions(e.id,10),s=t.getPendingQuests(e.id).map(j=>({title:j.title,priority:j.priority})),i=t.getAllContext(e.id),n=g({name:e.name,stack:e.stack},i,u,s),c=r(`\u{F115D} **Context for ${e.name}**
|
|
17
|
+
|
|
18
|
+
${n}`);return o&&y.set(o,c,3e4),c}},{name:"wyrm_global_context",description:"Get overview of all projects, pending quests across projects, and global context",inputSchema:{type:"object",properties:{includeQuests:{type:"boolean",description:"Include all pending quests"},maxProjects:{type:"number",description:"Max projects to include"}}},annotations:m.wyrm_global_context,aliases:[],handler:async(p,l)=>{const{cachedResponse:r,db:t}=l,o=h(),{includeQuests:a,maxProjects:d}=p,e=t.getAllProjects(d||20),u=t.getAllGlobalContext();let s=`\u{F115D} **Wyrm Global Overview**
|
|
19
|
+
|
|
20
|
+
`;if(Object.keys(u).length>0){s+=`## Global Context
|
|
21
|
+
`;for(const[n,c]of Object.entries(u))s+=`- **${n}:** ${c.slice(0,200)}${c.length>200?"...":""}
|
|
22
|
+
`;s+=`
|
|
23
|
+
`}s+=`## Projects (${e.length})
|
|
24
|
+
`;for(const n of e){const c=t.getProjectStats(n.id);s+=`- **${n.name}** (${n.stack||"?"}) - ${c.quests.pending} quests, ${c.sessions} sessions
|
|
25
|
+
`}if(s+=`
|
|
26
|
+
`,a){const n=t.getAllPendingQuests();s+=`## All Pending Quests (${n.length})
|
|
27
|
+
`;for(const c of n.slice(0,20)){const j={critical:"\u{1F534}",high:"\u{1F7E0}",medium:"\u{1F7E1}",low:"\u{1F7E2}"}[c.priority];s+=`- ${j} [${c.project_name}] ${c.title}
|
|
28
|
+
`}}const i=r(s);return o&&y.set(o,i,45e3),i}},{name:"wyrm_set_global",description:"Set global context that applies across all projects",inputSchema:{type:"object",properties:{key:{type:"string",description:"Context key"},value:{type:"string",description:"Context value"}},required:["key","value"]},annotations:m.wyrm_set_global,aliases:[],handler:async(p,l)=>{const{db:r}=l,{key:t,value:o}=p;return r.setGlobalContext(t,o),{content:[{type:"text",text:`\u{F115D} Global context set: ${t}`}]}}}];export{_ as projectToolSpecs};
|
package/dist/handlers/prompts.js
CHANGED
|
@@ -1,157 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* its prompt picker. No vendor file formats, no client-name sniffing — the
|
|
8
|
-
* MCP prompts surface IS the activation mechanism (Article V).
|
|
9
|
-
*
|
|
10
|
-
* NO SECOND IMPLEMENTATION: both prompts render through the SAME registry
|
|
11
|
-
* handlers the tools dispatch to —
|
|
12
|
-
* - `prime` executes handlerRegistry.get('wyrm_session_prime') (the T026
|
|
13
|
-
* session domain; fleet args ride through to the T028 byte-stable cached
|
|
14
|
-
* brief) and embeds its text channel verbatim under a consult-first
|
|
15
|
-
* preamble;
|
|
16
|
-
* - `debrief` embeds the live handlerRegistry.get('wyrm_run')
|
|
17
|
-
* action=status view (when run_id is given) under the end-of-session
|
|
18
|
-
* filing instructions; the filing itself stays a tool call (wyrm_run
|
|
19
|
-
* action=debrief needs the learnings only the agent can write).
|
|
20
|
-
* The prompt layer owns ONLY the framing text — never brief compilation,
|
|
21
|
-
* never run logic (source-locked by tests/prompts.test.ts).
|
|
22
|
-
*
|
|
23
|
-
* Argument values are STRINGS per the MCP GetPromptRequest schema; numeric
|
|
24
|
-
* coercion is the boundary validator's job (asInt already accepts numeric
|
|
25
|
-
* strings), so the handler sees the same validation the tool wire applies.
|
|
26
|
-
*
|
|
27
|
-
* @copyright 2026 Ghost Protocol (Pvt) Ltd.
|
|
28
|
-
* @license AGPL-3.0-or-later — dual-licensed; commercial terms: ghosts.lk@proton.me. See LICENSE.
|
|
29
|
-
*/
|
|
30
|
-
import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
31
|
-
import { ValidationError } from '../validate.js';
|
|
32
|
-
import { handlerRegistry } from './registry.js';
|
|
33
|
-
import { blockText } from './types.js';
|
|
34
|
-
/**
|
|
35
|
-
* The advertised prompt list — codepoint name order (the T018 byte-stability
|
|
36
|
-
* convention) and fully literal: no Date/random/env anywhere, so consecutive
|
|
37
|
-
* prompts/list responses are byte-identical.
|
|
38
|
-
*/
|
|
39
|
-
const WYRM_PROMPTS = [
|
|
40
|
-
{
|
|
41
|
-
name: 'debrief',
|
|
42
|
-
description: 'End-of-session memory debrief: how to file what was learned back into Wyrm '
|
|
43
|
-
+ '(wyrm_run action=debrief in a fleet run, wyrm_capture otherwise, '
|
|
44
|
-
+ 'wyrm_failure_record for failed approaches) -- plus the live run status when run_id is given.',
|
|
45
|
-
arguments: [
|
|
46
|
-
{ name: 'run_id', description: 'Fleet run to debrief (embeds live wyrm_run status)', required: false },
|
|
47
|
-
{ name: 'project', description: 'Project path the learnings file under', required: false },
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'prime',
|
|
52
|
-
description: 'Load Wyrm institutional memory FIRST -- ground truths, memory brief, reasoning scaffold, '
|
|
53
|
-
+ 'active quests -- rendered by the same wyrm_session_prime code path the tool uses. '
|
|
54
|
-
+ 'Use at session start, before planning or acting. Fleet agents pass run_id + role '
|
|
55
|
-
+ 'for the byte-stable cached brief.',
|
|
56
|
-
arguments: [
|
|
57
|
-
{ name: 'project', description: 'Project name (fuzzy; default: last active project)', required: false },
|
|
58
|
-
{ name: 'task', description: 'Drives scaffold + memory selection', required: false },
|
|
59
|
-
{ name: 'run_id', description: 'Fleet: brief cached per (run_id, role)', required: false },
|
|
60
|
-
{ name: 'role', description: 'Fleet role slice', required: false },
|
|
61
|
-
{ name: 'token_budget', description: 'Fleet brief token budget (default 1200)', required: false },
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
/** prompts/list body. */
|
|
66
|
-
export function wyrmPromptList() {
|
|
67
|
-
return WYRM_PROMPTS;
|
|
68
|
-
}
|
|
69
|
-
/** Run a registry tool handler, mapping boundary ValidationErrors onto the
|
|
70
|
-
* JSON-RPC invalid-params code (the prompt-surface analogue of the T020
|
|
71
|
-
* WYRM_VALIDATION body — prompts/get has no tool-result channel to carry it). */
|
|
72
|
-
async function runRegistryHandler(tool, args, ctx) {
|
|
73
|
-
const handler = handlerRegistry.get(tool);
|
|
74
|
-
if (!handler) {
|
|
75
|
-
// Structural invariant: both targets are registry-resident (T026/T027).
|
|
76
|
-
throw new McpError(ErrorCode.InternalError, `prompt target ${tool} is not registry-resident`);
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
return await handler(args, ctx);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
if (error instanceof ValidationError) {
|
|
83
|
-
throw new McpError(ErrorCode.InvalidParams, error.message);
|
|
84
|
-
}
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const PRIME_PREAMBLE = 'Wyrm is this workspace\'s persistent memory and your first priority. The brief below is '
|
|
89
|
-
+ 'institutional ground truth: consult it BEFORE planning, searching, or acting; treat its '
|
|
90
|
-
+ 'ground truths as authoritative over your own assumptions (surface conflicts, never silently '
|
|
91
|
-
+ 'override); check wyrm_failure_check before re-attempting anything it records as failed; and '
|
|
92
|
-
+ 'capture decisions, fixes, and outcomes back with wyrm_capture as you work.';
|
|
93
|
-
async function primePrompt(args, ctx) {
|
|
94
|
-
// String-typed prompt args adapt onto the tool's own argument names; the
|
|
95
|
-
// handler's boundary validation (sanitizeActorId on run_id, asInt on
|
|
96
|
-
// token_budget — numeric strings accepted) applies unchanged.
|
|
97
|
-
const toolArgs = {};
|
|
98
|
-
if (args.project !== undefined)
|
|
99
|
-
toolArgs.project_name = args.project;
|
|
100
|
-
if (args.task !== undefined)
|
|
101
|
-
toolArgs.task = args.task;
|
|
102
|
-
if (args.run_id !== undefined)
|
|
103
|
-
toolArgs.run_id = args.run_id;
|
|
104
|
-
if (args.role !== undefined)
|
|
105
|
-
toolArgs.role = args.role;
|
|
106
|
-
if (args.token_budget !== undefined)
|
|
107
|
-
toolArgs.token_budget = args.token_budget;
|
|
108
|
-
const result = await runRegistryHandler('wyrm_session_prime', toolArgs, ctx);
|
|
109
|
-
// Not-found advisories ride through too — "No projects found. Run
|
|
110
|
-
// wyrm_scan_projects first." is still the correct consult-first activation.
|
|
111
|
-
const text = `${PRIME_PREAMBLE}\n\n---\n\n${blockText(result.content[0])}`;
|
|
112
|
-
return {
|
|
113
|
-
description: 'Wyrm session prime — consult-memory-first brief',
|
|
114
|
-
messages: [{ role: 'user', content: { type: 'text', text } }],
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
async function debriefPrompt(args, ctx) {
|
|
118
|
-
const runId = args.run_id;
|
|
119
|
-
const projectPath = args.project;
|
|
120
|
-
const idRef = runId ?? '<run_id>';
|
|
121
|
-
const pathRef = projectPath ?? '<project path>';
|
|
122
|
-
const lines = [
|
|
123
|
-
'The session is ending. File what was learned back into Wyrm before you stop -- memory you do not write is memory the team loses.',
|
|
124
|
-
'',
|
|
125
|
-
'1. Summarize the durable learnings: decisions made, validated fixes, gotchas, and patterns worth reusing.',
|
|
126
|
-
'2. Record approaches that FAILED with wyrm_failure_record so no future agent repeats them.',
|
|
127
|
-
runId !== undefined
|
|
128
|
-
? `3. Submit the learnings via wyrm_run { action: 'debrief', run_id: '${idRef}', project_path: '${pathRef}', learnings: [{ agent_id?, text }] } -- they are extracted LOCALLY into a run-scoped review queue -- then close the run with wyrm_run { action: 'end', run_id: '${idRef}', agent_id: <your registered agent_id> } (end is member-only).`
|
|
129
|
-
: `3. In a fleet run, submit the learnings via wyrm_run { action: 'debrief', run_id: '${idRef}', project_path: '${pathRef}', learnings: [{ agent_id?, text }] }, then close the run with wyrm_run { action: 'end', run_id: '${idRef}', agent_id: <your registered agent_id> } (end is member-only). Outside a run, capture each learning directly with wyrm_capture.`,
|
|
130
|
-
// Survivor-first storefront (T032 findings pass): the default surface
|
|
131
|
-
// advertises wyrm_session, not the hidden wyrm_session_update alias — a
|
|
132
|
-
// harness that validates tool names against ListTools must be able to
|
|
133
|
-
// follow every instruction in this message.
|
|
134
|
-
"4. Update the session record with wyrm_session { action: 'update', completed, issues, commits }.",
|
|
135
|
-
];
|
|
136
|
-
if (runId !== undefined) {
|
|
137
|
-
// SAME code path as the tool: the live wyrm_run action=status view. An
|
|
138
|
-
// isError text (e.g. "Run not found: X") embeds too — it is the honest
|
|
139
|
-
// status and tells the agent the run_id is wrong before it files anything.
|
|
140
|
-
const status = await runRegistryHandler('wyrm_run', { action: 'status', run_id: runId }, ctx);
|
|
141
|
-
lines.push('', 'Current run status:', '', blockText(status.content[0]));
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
description: 'Wyrm end-of-session debrief — file learnings back into memory',
|
|
145
|
-
messages: [{ role: 'user', content: { type: 'text', text: lines.join('\n') } }],
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/** prompts/get dispatch. Unknown names are JSON-RPC invalid-params per the
|
|
149
|
-
* MCP spec convention. */
|
|
150
|
-
export async function getPromptResult(name, args, ctx) {
|
|
151
|
-
if (name === 'prime')
|
|
152
|
-
return primePrompt(args, ctx);
|
|
153
|
-
if (name === 'debrief')
|
|
154
|
-
return debriefPrompt(args, ctx);
|
|
155
|
-
throw new McpError(ErrorCode.InvalidParams, `Unknown prompt: ${name}`);
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=prompts.js.map
|
|
1
|
+
import{ErrorCode as o,McpError as s}from"@modelcontextprotocol/sdk/types.js";import{ValidationError as l}from"../validate.js";import{handlerRegistry as f}from"./registry.js";import{blockText as u}from"./types.js";const p=[{name:"debrief",description:"End-of-session memory debrief: how to file what was learned back into Wyrm (wyrm_run action=debrief in a fleet run, wyrm_capture otherwise, wyrm_failure_record for failed approaches) -- plus the live run status when run_id is given.",arguments:[{name:"run_id",description:"Fleet run to debrief (embeds live wyrm_run status)",required:!1},{name:"project",description:"Project path the learnings file under",required:!1}]},{name:"prime",description:"Load Wyrm institutional memory FIRST -- ground truths, memory brief, reasoning scaffold, active quests -- rendered by the same wyrm_session_prime code path the tool uses. Use at session start, before planning or acting. Fleet agents pass run_id + role for the byte-stable cached brief.",arguments:[{name:"project",description:"Project name (fuzzy; default: last active project)",required:!1},{name:"task",description:"Drives scaffold + memory selection",required:!1},{name:"run_id",description:"Fleet: brief cached per (run_id, role)",required:!1},{name:"role",description:"Fleet role slice",required:!1},{name:"token_budget",description:"Fleet brief token budget (default 1200)",required:!1}]}];function v(){return p}async function c(e,n,r){const i=f.get(e);if(!i)throw new s(o.InternalError,`prompt target ${e} is not registry-resident`);try{return await i(n,r)}catch(t){throw t instanceof l?new s(o.InvalidParams,t.message):t}}const h="Wyrm is this workspace's persistent memory and your first priority. The brief below is institutional ground truth: consult it BEFORE planning, searching, or acting; treat its ground truths as authoritative over your own assumptions (surface conflicts, never silently override); check wyrm_failure_check before re-attempting anything it records as failed; and capture decisions, fixes, and outcomes back with wyrm_capture as you work.";async function y(e,n){const r={};e.project!==void 0&&(r.project_name=e.project),e.task!==void 0&&(r.task=e.task),e.run_id!==void 0&&(r.run_id=e.run_id),e.role!==void 0&&(r.role=e.role),e.token_budget!==void 0&&(r.token_budget=e.token_budget);const i=await c("wyrm_session_prime",r,n);return{description:"Wyrm session prime \u2014 consult-memory-first brief",messages:[{role:"user",content:{type:"text",text:`${h}
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
${u(i.content[0])}`}}]}}async function _(e,n){const r=e.run_id,i=e.project,t=r??"<run_id>",a=i??"<project path>",d=["The session is ending. File what was learned back into Wyrm before you stop -- memory you do not write is memory the team loses.","","1. Summarize the durable learnings: decisions made, validated fixes, gotchas, and patterns worth reusing.","2. Record approaches that FAILED with wyrm_failure_record so no future agent repeats them.",r!==void 0?`3. Submit the learnings via wyrm_run { action: 'debrief', run_id: '${t}', project_path: '${a}', learnings: [{ agent_id?, text }] } -- they are extracted LOCALLY into a run-scoped review queue -- then close the run with wyrm_run { action: 'end', run_id: '${t}', agent_id: <your registered agent_id> } (end is member-only).`:`3. In a fleet run, submit the learnings via wyrm_run { action: 'debrief', run_id: '${t}', project_path: '${a}', learnings: [{ agent_id?, text }] }, then close the run with wyrm_run { action: 'end', run_id: '${t}', agent_id: <your registered agent_id> } (end is member-only). Outside a run, capture each learning directly with wyrm_capture.`,"4. Update the session record with wyrm_session { action: 'update', completed, issues, commits }."];if(r!==void 0){const m=await c("wyrm_run",{action:"status",run_id:r},n);d.push("","Current run status:","",u(m.content[0]))}return{description:"Wyrm end-of-session debrief \u2014 file learnings back into memory",messages:[{role:"user",content:{type:"text",text:d.join(`
|
|
6
|
+
`)}}]}}async function j(e,n,r){if(e==="prime")return y(n,r);if(e==="debrief")return _(n,r);throw new s(o.InvalidParams,`Unknown prompt: ${e}`)}export{j as getPromptResult,v as wyrmPromptList};
|
package/dist/handlers/quest.js
CHANGED
|
@@ -1,224 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* / wyrm_all_quests, moved VERBATIM from the index.ts dispatch switch +
|
|
6
|
-
* buildAllTools() (definitions byte-identical on the wire). The wyrm_quest
|
|
7
|
-
* noun shim (src/handlers/shims.ts) keeps routing action=add|complete|claim|
|
|
8
|
-
* release|list onto THESE names — the registry is checked before the switch,
|
|
9
|
-
* so the shim table needs zero changes (the T022 handoff design).
|
|
10
|
-
*
|
|
11
|
-
* T019 renderer: every success response is a renderResult(body, template) —
|
|
12
|
-
* structuredContent is canonical, text derives from it (plain ASCII default,
|
|
13
|
-
* brand glyphs behind WYRM_FANCY=1; the 6.x priority emoji moved off the
|
|
14
|
-
* default text per the goals-domain precedent, spec §6 "text persists but
|
|
15
|
-
* reformats"). Project/quest not-founds are isError (schema-exempt).
|
|
16
|
-
*
|
|
17
|
-
* @copyright 2026 Ghost Protocol (Pvt) Ltd.
|
|
18
|
-
* @license AGPL-3.0-or-later — dual-licensed; commercial terms: ghosts.lk@proton.me. See LICENSE.
|
|
19
|
-
*/
|
|
20
|
-
import { TOOL_ANNOTATIONS } from '../tool-annotations.js';
|
|
21
|
-
import { renderResult, withGlyph, cacheKeyFor } from '../render.js';
|
|
22
|
-
import { asEnum } from '../validate.js';
|
|
23
|
-
export const questToolSpecs = [
|
|
24
|
-
{
|
|
25
|
-
name: "wyrm_quest_add",
|
|
26
|
-
description: "Add a quest (task) to a project",
|
|
27
|
-
inputSchema: {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
projectPath: { type: "string", description: "Project path" },
|
|
31
|
-
title: { type: "string", description: "Quest title" },
|
|
32
|
-
description: { type: "string", description: "Quest description" },
|
|
33
|
-
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
34
|
-
tags: { type: "string", description: "Comma-separated tags" },
|
|
35
|
-
},
|
|
36
|
-
required: ["projectPath", "title"],
|
|
37
|
-
},
|
|
38
|
-
outputSchema: {
|
|
39
|
-
type: "object",
|
|
40
|
-
properties: {
|
|
41
|
-
id: { type: "integer" },
|
|
42
|
-
title: { type: "string" },
|
|
43
|
-
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
44
|
-
project: { type: "string" },
|
|
45
|
-
},
|
|
46
|
-
required: ["id", "title", "priority", "project"],
|
|
47
|
-
},
|
|
48
|
-
annotations: TOOL_ANNOTATIONS.wyrm_quest_add,
|
|
49
|
-
aliases: [],
|
|
50
|
-
handler: (args, { store, indexing }) => {
|
|
51
|
-
const { projectPath, title, description, priority, tags } = args;
|
|
52
|
-
// Closed enum enforced at the boundary (the MCP SDK treats
|
|
53
|
-
// inputSchema as advisory). quests.priority has NO schema CHECK, so
|
|
54
|
-
// without this gate a typo'd value would be SILENTLY STORED and skew
|
|
55
|
-
// priority-ordered queries — the boundary is the only enforcement
|
|
56
|
-
// point.
|
|
57
|
-
const safePriority = asEnum('priority', priority, ['critical', 'high', 'medium', 'low'], 'medium');
|
|
58
|
-
const project = store.getProject(projectPath);
|
|
59
|
-
if (!project) {
|
|
60
|
-
// T026: was a non-error "Project not found" text in 6.x — domain
|
|
61
|
-
// not-founds are isError per the goals precedent (schema-exempt).
|
|
62
|
-
return { content: [{ type: "text", text: "Project not found" }], isError: true };
|
|
63
|
-
}
|
|
64
|
-
const quest = store.addQuest(project.id, title, description, safePriority, tags);
|
|
65
|
-
indexing()?.enqueue('quest', quest.id, project.id);
|
|
66
|
-
return renderResult({ id: quest.id, title, priority: safePriority, project: project.name }, (b, g) => withGlyph(g.brand, `Quest #${b.id} added: ${b.title}`));
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "wyrm_quest_complete",
|
|
71
|
-
description: "Mark a quest as completed",
|
|
72
|
-
inputSchema: {
|
|
73
|
-
type: "object",
|
|
74
|
-
properties: {
|
|
75
|
-
questId: { type: "number", description: "Quest ID" },
|
|
76
|
-
},
|
|
77
|
-
required: ["questId"],
|
|
78
|
-
},
|
|
79
|
-
outputSchema: {
|
|
80
|
-
type: "object",
|
|
81
|
-
properties: {
|
|
82
|
-
id: { type: "integer" },
|
|
83
|
-
title: { type: "string" },
|
|
84
|
-
status: { type: "string", enum: ["completed"] },
|
|
85
|
-
},
|
|
86
|
-
required: ["id", "title", "status"],
|
|
87
|
-
},
|
|
88
|
-
annotations: TOOL_ANNOTATIONS.wyrm_quest_complete,
|
|
89
|
-
aliases: [],
|
|
90
|
-
handler: (args, { store }) => {
|
|
91
|
-
const { questId } = args;
|
|
92
|
-
const quest = store.updateQuest(questId, 'completed');
|
|
93
|
-
if (!quest) {
|
|
94
|
-
// T026: 6.x read `.title` off the undefined row and threw a
|
|
95
|
-
// TypeError into the generic error boundary — a clean isError
|
|
96
|
-
// not-found is the honest contract (recorded deviation).
|
|
97
|
-
return { content: [{ type: "text", text: `Quest #${questId} not found.` }], isError: true };
|
|
98
|
-
}
|
|
99
|
-
return renderResult({ id: questId, title: quest.title, status: 'completed' }, (b, g) => withGlyph(g.brand, `Quest #${b.id} completed: ${b.title}`));
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: "wyrm_all_quests",
|
|
104
|
-
description: "Get all pending quests across all projects",
|
|
105
|
-
inputSchema: {
|
|
106
|
-
type: "object",
|
|
107
|
-
properties: {
|
|
108
|
-
priority: { type: "string", enum: ["critical", "high", "medium", "low"], description: "Filter by priority" },
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
outputSchema: {
|
|
112
|
-
type: "object",
|
|
113
|
-
properties: {
|
|
114
|
-
count: { type: "integer" },
|
|
115
|
-
quests: {
|
|
116
|
-
type: "array",
|
|
117
|
-
items: {
|
|
118
|
-
type: "object",
|
|
119
|
-
properties: {
|
|
120
|
-
id: { type: "integer" },
|
|
121
|
-
title: { type: "string" },
|
|
122
|
-
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
123
|
-
project: { type: ["string", "null"] },
|
|
124
|
-
},
|
|
125
|
-
required: ["id", "title", "priority", "project"],
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
required: ["count", "quests"],
|
|
130
|
-
},
|
|
131
|
-
annotations: TOOL_ANNOTATIONS.wyrm_all_quests,
|
|
132
|
-
aliases: [],
|
|
133
|
-
handler: (args, { store, cache }) => {
|
|
134
|
-
const { priority } = args;
|
|
135
|
-
let quests = store.getAllPendingQuests();
|
|
136
|
-
if (priority) {
|
|
137
|
-
quests = quests.filter(q => q.priority === priority);
|
|
138
|
-
}
|
|
139
|
-
const body = {
|
|
140
|
-
count: quests.length,
|
|
141
|
-
quests: quests.map((q) => ({
|
|
142
|
-
id: q.id,
|
|
143
|
-
title: q.title,
|
|
144
|
-
priority: q.priority,
|
|
145
|
-
project: q.project_name ?? null,
|
|
146
|
-
})),
|
|
147
|
-
};
|
|
148
|
-
const response = renderResult(body, (b, g) => {
|
|
149
|
-
const lines = b.quests.map((q) => `${g.bullet} [${q.priority}]${q.project ? ` [${q.project}]` : ''} #${q.id}: ${q.title}`).join('\n');
|
|
150
|
-
return `${withGlyph(g.brand, `**${b.count} Pending Quests**`)}\n\n${lines}`;
|
|
151
|
-
});
|
|
152
|
-
// READ_ONLY_TOOLS cache publish — same key convention as the
|
|
153
|
-
// dispatcher's cache-hit lookup (resolved name + resolved args).
|
|
154
|
-
cache.set(cacheKeyFor('wyrm_all_quests', JSON.stringify(args)), response, 30000);
|
|
155
|
-
return response;
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
// T029: description rewritten for the orchestrator audience (T025 house style).
|
|
160
|
-
name: "wyrm_quest_claim",
|
|
161
|
-
description: "Use from a fleet subagent to take an exclusive TTL lease on a quest before working it, so no two agents double-work: atomic CAS on the (quest, agent) key - a losing claimer gets a visible already-claimed error, never a partial write. The claim row is stamped with the ambient run_id and the agent's run role for orchestrator audit (wyrm_run action=status counts claims per run). Stale leases are evicted inline at claim time and by wyrm_maintenance. Requires a prior wyrm_presence announce; release with wyrm_quest_release.",
|
|
162
|
-
inputSchema: {
|
|
163
|
-
type: "object",
|
|
164
|
-
properties: {
|
|
165
|
-
quest_id: { type: "number", description: "Quest to claim" },
|
|
166
|
-
agent_id: { type: "string", description: "Claiming agent ID (must be announced first)" },
|
|
167
|
-
ttl_seconds: { type: "number", description: "Claim TTL (default 1800 = 30 min)" },
|
|
168
|
-
},
|
|
169
|
-
required: ["quest_id", "agent_id"],
|
|
170
|
-
},
|
|
171
|
-
outputSchema: {
|
|
172
|
-
type: "object",
|
|
173
|
-
properties: {
|
|
174
|
-
quest_id: { type: "integer" },
|
|
175
|
-
agent_id: { type: "string" },
|
|
176
|
-
ttl_seconds: { type: "integer" },
|
|
177
|
-
},
|
|
178
|
-
required: ["quest_id", "agent_id", "ttl_seconds"],
|
|
179
|
-
},
|
|
180
|
-
annotations: TOOL_ANNOTATIONS.wyrm_quest_claim,
|
|
181
|
-
aliases: [],
|
|
182
|
-
handler: (args, { presence }) => {
|
|
183
|
-
const { quest_id, agent_id, ttl_seconds } = args;
|
|
184
|
-
const claim = presence.claimQuest(quest_id, agent_id, ttl_seconds);
|
|
185
|
-
if (!claim) {
|
|
186
|
-
const existing = presence.getClaim(quest_id);
|
|
187
|
-
return { content: [{ type: "text", text: `Quest #${quest_id} already claimed by ${existing?.agent_id ?? 'another agent'}.` }], isError: true };
|
|
188
|
-
}
|
|
189
|
-
return renderResult({ quest_id, agent_id, ttl_seconds: claim.claim_ttl_seconds }, (b, g) => withGlyph(g.ok, `${b.agent_id} claimed quest #${b.quest_id} for ${b.ttl_seconds}s.`));
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
// T029: description rewritten for the orchestrator audience (T025 house style).
|
|
194
|
-
name: "wyrm_quest_release",
|
|
195
|
-
description: "Use when a subagent finishes or abandons a claimed quest: drops the TTL lease (only if held by this agent) so the orchestrator can reassign the quest immediately instead of waiting for expiry; wyrm_run action=end bulk-releases a whole run's claims, and wyrm_maintenance reaps expired ones.",
|
|
196
|
-
inputSchema: {
|
|
197
|
-
type: "object",
|
|
198
|
-
properties: {
|
|
199
|
-
quest_id: { type: "number" },
|
|
200
|
-
agent_id: { type: "string" },
|
|
201
|
-
},
|
|
202
|
-
required: ["quest_id", "agent_id"],
|
|
203
|
-
},
|
|
204
|
-
outputSchema: {
|
|
205
|
-
type: "object",
|
|
206
|
-
properties: {
|
|
207
|
-
quest_id: { type: "integer" },
|
|
208
|
-
agent_id: { type: "string" },
|
|
209
|
-
released: { type: "boolean" },
|
|
210
|
-
},
|
|
211
|
-
required: ["quest_id", "agent_id", "released"],
|
|
212
|
-
},
|
|
213
|
-
annotations: TOOL_ANNOTATIONS.wyrm_quest_release,
|
|
214
|
-
aliases: [],
|
|
215
|
-
handler: (args, { presence }) => {
|
|
216
|
-
const { quest_id, agent_id } = args;
|
|
217
|
-
const ok = presence.releaseClaim(quest_id, agent_id);
|
|
218
|
-
return renderResult({ quest_id, agent_id, released: ok }, (b, g) => withGlyph(g.brand, b.released
|
|
219
|
-
? `Quest #${b.quest_id} released by ${b.agent_id}.`
|
|
220
|
-
: `No claim by ${b.agent_id} on quest #${b.quest_id}.`));
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
];
|
|
224
|
-
//# sourceMappingURL=quest.js.map
|
|
1
|
+
import{TOOL_ANNOTATIONS as c}from"../tool-annotations.js";import{renderResult as l,withGlyph as m,cacheKeyFor as _}from"../render.js";import{asEnum as q}from"../validate.js";const b=[{name:"wyrm_quest_add",description:"Add a quest (task) to a project",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},title:{type:"string",description:"Quest title"},description:{type:"string",description:"Quest description"},priority:{type:"string",enum:["critical","high","medium","low"]},tags:{type:"string",description:"Comma-separated tags"}},required:["projectPath","title"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},priority:{type:"string",enum:["critical","high","medium","low"]},project:{type:"string"}},required:["id","title","priority","project"]},annotations:c.wyrm_quest_add,aliases:[],handler:(a,{store:o,indexing:e})=>{const{projectPath:r,title:t,description:i,priority:n,tags:s}=a,u=q("priority",n,["critical","high","medium","low"],"medium"),d=o.getProject(r);if(!d)return{content:[{type:"text",text:"Project not found"}],isError:!0};const p=o.addQuest(d.id,t,i,u,s);return e()?.enqueue("quest",p.id,d.id),l({id:p.id,title:t,priority:u,project:d.name},(y,g)=>m(g.brand,`Quest #${y.id} added: ${y.title}`))}},{name:"wyrm_quest_complete",description:"Mark a quest as completed",inputSchema:{type:"object",properties:{questId:{type:"number",description:"Quest ID"}},required:["questId"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["completed"]}},required:["id","title","status"]},annotations:c.wyrm_quest_complete,aliases:[],handler:(a,{store:o})=>{const{questId:e}=a,r=o.updateQuest(e,"completed");return r?l({id:e,title:r.title,status:"completed"},(t,i)=>m(i.brand,`Quest #${t.id} completed: ${t.title}`)):{content:[{type:"text",text:`Quest #${e} not found.`}],isError:!0}}},{name:"wyrm_all_quests",description:"Get all pending quests across all projects",inputSchema:{type:"object",properties:{priority:{type:"string",enum:["critical","high","medium","low"],description:"Filter by priority"}}},outputSchema:{type:"object",properties:{count:{type:"integer"},quests:{type:"array",items:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},priority:{type:"string",enum:["critical","high","medium","low"]},project:{type:["string","null"]}},required:["id","title","priority","project"]}}},required:["count","quests"]},annotations:c.wyrm_all_quests,aliases:[],handler:(a,{store:o,cache:e})=>{const{priority:r}=a;let t=o.getAllPendingQuests();r&&(t=t.filter(s=>s.priority===r));const i={count:t.length,quests:t.map(s=>({id:s.id,title:s.title,priority:s.priority,project:s.project_name??null}))},n=l(i,(s,u)=>{const d=s.quests.map(p=>`${u.bullet} [${p.priority}]${p.project?` [${p.project}]`:""} #${p.id}: ${p.title}`).join(`
|
|
2
|
+
`);return`${m(u.brand,`**${s.count} Pending Quests**`)}
|
|
3
|
+
|
|
4
|
+
${d}`});return e.set(_("wyrm_all_quests",JSON.stringify(a)),n,3e4),n}},{name:"wyrm_quest_claim",description:"Use from a fleet subagent to take an exclusive TTL lease on a quest before working it, so no two agents double-work: atomic CAS on the (quest, agent) key - a losing claimer gets a visible already-claimed error, never a partial write. The claim row is stamped with the ambient run_id and the agent's run role for orchestrator audit (wyrm_run action=status counts claims per run). Stale leases are evicted inline at claim time and by wyrm_maintenance. Requires a prior wyrm_presence announce; release with wyrm_quest_release.",inputSchema:{type:"object",properties:{quest_id:{type:"number",description:"Quest to claim"},agent_id:{type:"string",description:"Claiming agent ID (must be announced first)"},ttl_seconds:{type:"number",description:"Claim TTL (default 1800 = 30 min)"}},required:["quest_id","agent_id"]},outputSchema:{type:"object",properties:{quest_id:{type:"integer"},agent_id:{type:"string"},ttl_seconds:{type:"integer"}},required:["quest_id","agent_id","ttl_seconds"]},annotations:c.wyrm_quest_claim,aliases:[],handler:(a,{presence:o})=>{const{quest_id:e,agent_id:r,ttl_seconds:t}=a,i=o.claimQuest(e,r,t);if(!i){const n=o.getClaim(e);return{content:[{type:"text",text:`Quest #${e} already claimed by ${n?.agent_id??"another agent"}.`}],isError:!0}}return l({quest_id:e,agent_id:r,ttl_seconds:i.claim_ttl_seconds},(n,s)=>m(s.ok,`${n.agent_id} claimed quest #${n.quest_id} for ${n.ttl_seconds}s.`))}},{name:"wyrm_quest_release",description:"Use when a subagent finishes or abandons a claimed quest: drops the TTL lease (only if held by this agent) so the orchestrator can reassign the quest immediately instead of waiting for expiry; wyrm_run action=end bulk-releases a whole run's claims, and wyrm_maintenance reaps expired ones.",inputSchema:{type:"object",properties:{quest_id:{type:"number"},agent_id:{type:"string"}},required:["quest_id","agent_id"]},outputSchema:{type:"object",properties:{quest_id:{type:"integer"},agent_id:{type:"string"},released:{type:"boolean"}},required:["quest_id","agent_id","released"]},annotations:c.wyrm_quest_release,aliases:[],handler:(a,{presence:o})=>{const{quest_id:e,agent_id:r}=a,t=o.releaseClaim(e,r);return l({quest_id:e,agent_id:r,released:t},(i,n)=>m(n.brand,i.released?`Quest #${i.quest_id} released by ${i.agent_id}.`:`No claim by ${i.agent_id} on quest #${i.quest_id}.`))}}];export{b as questToolSpecs};
|