wyrm-mcp 9.2.2 → 9.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/activation.js +1 -1
  2. package/dist/agent-loop.js +2 -2
  3. package/dist/audit.js +2 -2
  4. package/dist/autoconfig.js +6 -6
  5. package/dist/backup-cli.js +6 -0
  6. package/dist/backup.js +1 -0
  7. package/dist/bridge.js +1 -1
  8. package/dist/buddy-runner.js +1 -1
  9. package/dist/buddy.js +4 -4
  10. package/dist/capabilities.js +1 -1
  11. package/dist/causality.js +3 -3
  12. package/dist/cloud/cli.js +3 -3
  13. package/dist/cloud/sync-daemon-entrypoint.js +1 -1
  14. package/dist/cloud/sync-engine.js +8 -7
  15. package/dist/cloud-backup.js +4 -4
  16. package/dist/cloud-sync-entrypoint.js +1 -1
  17. package/dist/cloud-sync.js +1 -1
  18. package/dist/connectors/ingest.js +2 -2
  19. package/dist/constellation.js +1 -1
  20. package/dist/context-build-budgeted.js +4 -4
  21. package/dist/context-ranking.js +1 -1
  22. package/dist/daemon-writer.js +1 -1
  23. package/dist/database.js +41 -23
  24. package/dist/design.js +1 -1
  25. package/dist/erasure-cli.js +3 -0
  26. package/dist/erasure-log.js +8 -0
  27. package/dist/erasure.js +1 -0
  28. package/dist/event-replication.js +1 -1
  29. package/dist/events.js +11 -11
  30. package/dist/failure-patterns.js +67 -44
  31. package/dist/federation.js +11 -10
  32. package/dist/governance.js +1 -0
  33. package/dist/handlers/agent.js +4 -4
  34. package/dist/handlers/alias-adapters.js +1 -1
  35. package/dist/handlers/audit.js +1 -1
  36. package/dist/handlers/boundary.js +1 -1
  37. package/dist/handlers/capture.js +54 -52
  38. package/dist/handlers/causality.js +2 -2
  39. package/dist/handlers/cloud.js +9 -9
  40. package/dist/handlers/companion.js +4 -4
  41. package/dist/handlers/entity.js +6 -6
  42. package/dist/handlers/events.js +4 -4
  43. package/dist/handlers/failure.js +15 -12
  44. package/dist/handlers/goals.js +2 -2
  45. package/dist/handlers/intelligence.js +81 -74
  46. package/dist/handlers/mcpclient.js +3 -3
  47. package/dist/handlers/presence.js +1 -1
  48. package/dist/handlers/prompts.js +2 -2
  49. package/dist/handlers/quest.js +11 -4
  50. package/dist/handlers/recall.js +10 -10
  51. package/dist/handlers/resources.js +1 -1
  52. package/dist/handlers/review.js +3 -3
  53. package/dist/handlers/run.js +3 -3
  54. package/dist/handlers/search.js +1 -1
  55. package/dist/handlers/session.js +27 -25
  56. package/dist/handlers/share.js +3 -3
  57. package/dist/handlers/skill.js +2 -2
  58. package/dist/handlers/symbols.js +5 -5
  59. package/dist/handlers/syncops.js +2 -2
  60. package/dist/harvest.js +5 -5
  61. package/dist/hours.js +1 -1
  62. package/dist/http-auth.js +2 -2
  63. package/dist/http-fast.js +17 -17
  64. package/dist/http-projects.js +4 -0
  65. package/dist/http-rate-limit.js +1 -0
  66. package/dist/index-health.js +52 -0
  67. package/dist/index.js +2 -2
  68. package/dist/indexer.js +4 -4
  69. package/dist/intelligence.js +36 -29
  70. package/dist/lane-provenance.js +39 -0
  71. package/dist/license.js +1 -1
  72. package/dist/lineage.js +15 -0
  73. package/dist/live-embedding-state.js +2 -2
  74. package/dist/maintenance.js +2 -2
  75. package/dist/mcp-integrity.js +2 -2
  76. package/dist/memory-artifacts.js +39 -37
  77. package/dist/metabolize.js +9 -7
  78. package/dist/metrics.js +1 -1
  79. package/dist/migrate-prompt.js +1 -1
  80. package/dist/migrations.js +236 -45
  81. package/dist/priority-embed.js +1 -1
  82. package/dist/providers/embedding-provider.js +1 -1
  83. package/dist/readonly-gate.js +1 -1
  84. package/dist/redact-backfill.js +1 -0
  85. package/dist/rehydration.js +30 -20
  86. package/dist/reindex.js +1 -1
  87. package/dist/render-target.js +6 -6
  88. package/dist/repl-guard.js +1 -1
  89. package/dist/replication-daemon-entrypoint.js +1 -1
  90. package/dist/replication-daemon.js +1 -1
  91. package/dist/retention.js +1 -0
  92. package/dist/reverse-bridge.js +6 -6
  93. package/dist/review-sample.js +31 -0
  94. package/dist/security.js +1 -1
  95. package/dist/self-maintenance.js +4 -4
  96. package/dist/served-records.js +8 -2
  97. package/dist/setup-wizard.js +1 -1
  98. package/dist/setup.js +1 -1
  99. package/dist/skill-author.js +2 -2
  100. package/dist/store-open.js +1 -0
  101. package/dist/store-readonly.js +1 -0
  102. package/dist/sub-agent.js +2 -2
  103. package/dist/tool-manifest-v2.json +1 -1
  104. package/dist/tool-manifest.json +1 -1
  105. package/dist/truth-freshness.js +8 -0
  106. package/dist/ui-dashboard.js +4 -4
  107. package/dist/vault.js +1 -1
  108. package/dist/vector-init.js +1 -1
  109. package/dist/vectors.js +4 -3
  110. package/dist/visibility.js +12 -12
  111. package/dist/write-guard.js +1 -0
  112. package/dist/wyrm-cli.js +108 -92
  113. package/dist/wyrm-guard.js +13 -12
  114. package/dist/wyrm-loop.js +3 -3
  115. package/dist/wyrm-manifest.json +1 -1
  116. package/dist/wyrm-memo.js +5 -5
  117. package/package.json +1 -1
  118. package/scripts/hooks/wyrm-session-capture.mjs +3 -0
@@ -1,25 +1,25 @@
1
- import{TOOL_ANNOTATIONS as _}from"../tool-annotations.js";import{currentReadCacheKey as P}from"./boundary.js";import{cache as m}from"../performance.js";const S=[{name:"wyrm_entity_add",description:"Add an entity to the knowledge graph (person, concept, tool, etc.)",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project to add entity to"},name:{type:"string",description:"Entity name"},type:{type:"string",description:"Entity type (e.g., person, concept, tool, framework, service)"},metadata:{type:"string",description:"JSON metadata about the entity"},aliases:{type:"array",items:{type:"string"},description:"Alternative names for the entity"}},required:["projectPath","name","type"]},annotations:_.wyrm_entity_add,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,name:n,type:e,metadata:o,aliases:i}=g,a=u.getProject(s);if(!a)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const p=t.findEntity(a.id,n,e);if(p)return{content:[{type:"text",text:`\u{F115D} Entity already exists: **${n}** (${e}) \u2014 id ${p.id}`}]};const r=t.addEntity(a.id,n,e,o);if(i?.length)for(const c of i)t.addAlias(r.id,c);m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats");let d=`\u{F115D} **Entity Added**
1
+ import{TOOL_ANNOTATIONS as _}from"../tool-annotations.js";import{currentReadCacheKey as P}from"./boundary.js";import{cache as m}from"../performance.js";const S=[{name:"wyrm_entity_add",description:"Add an entity to the knowledge graph (person, concept, tool, etc.)",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project to add entity to"},name:{type:"string",description:"Entity name"},type:{type:"string",description:"Entity type (e.g., person, concept, tool, framework, service)"},metadata:{type:"string",description:"JSON metadata about the entity"},aliases:{type:"array",items:{type:"string"},description:"Alternative names for the entity"}},required:["projectPath","name","type"]},annotations:_.wyrm_entity_add,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,name:n,type:e,metadata:o,aliases:i}=g,a=u.getProject(s);if(!a)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const p=t.findEntity(a.id,n,e);if(p)return{content:[{type:"text",text:`\u{F115D} Entity already exists: **${n}** (${e}), id ${p.id}`}]};const r=t.addEntity(a.id,n,e,o);if(i?.length)for(const c of i)t.addAlias(r.id,c);m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats");let d=`\u{F115D} **Entity Added**
2
2
 
3
3
  - **${r.name}** _(${r.type})_
4
4
  - ID: ${r.id}
5
5
  `;return i?.length&&(d+=`- Aliases: ${i.join(", ")}
6
6
  `),{content:[{type:"text",text:d}]}}},{name:"wyrm_entity_link",description:"Create a relationship between two entities in the knowledge graph",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entities"},source:{type:"string",description:"Source entity name"},target:{type:"string",description:"Target entity name"},relationship:{type:"string",description:"Relationship type (e.g., uses, depends_on, created_by, extends)"},weight:{type:"number",description:"Relationship weight 0-1 (default: 1.0)"},confidence:{type:"number",description:"Confidence score 0-1 (default: 1.0)"},sourceMemory:{type:"string",description:"Source of this knowledge (e.g., session:42, quest:7)"}},required:["projectPath","source","target","relationship"]},annotations:_.wyrm_entity_link,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,source:n,target:e,relationship:o,weight:i,confidence:a,sourceMemory:p}=g,r=u.getProject(s);if(!r)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const d=t.findEntity(r.id,n)??t.findByAlias(r.id,n),c=t.findEntity(r.id,e)??t.findByAlias(r.id,e);if(!d)return{content:[{type:"text",text:`Entity not found: "${n}". Add it first (wyrm_entity action=add).`}],isError:!0};if(!c)return{content:[{type:"text",text:`Entity not found: "${e}". Add it first (wyrm_entity action=add).`}],isError:!0};const h=t.addRelationship(r.id,d.id,c.id,o,{weight:i??1,confidence:a??1,sourceMemory:p});return m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats"),{content:[{type:"text",text:`\u{F115D} **Relationship Created**
7
7
 
8
- **${n}** \u2014[${o}]\u2192 **${e}**
8
+ **${n}** [${o}]\u2192 **${e}**
9
9
  - ID: ${h.id}${p?`
10
10
  - Source: ${p}`:""}`}]}}},{name:"wyrm_entity_search",description:"Search for entities in the knowledge graph",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project to search in"},query:{type:"string",description:"Search query for entity names"},type:{type:"string",description:"Filter by entity type"},limit:{type:"number",description:"Max results (default: 20)"}},required:["projectPath","query"]},annotations:_.wyrm_entity_search,aliases:[],handler:async(g,l)=>{const{cachedResponse:u,db:t,graph:s}=l,n=P(),{projectPath:e,query:o,type:i,limit:a}=g,p=t.getProject(e);if(!p)return{content:[{type:"text",text:`Project not found: ${e}`}],isError:!0};const r=s.searchEntities(p.id,o,a??20),d=i?r.filter(f=>f.type===i):r;if(d.length===0)return{content:[{type:"text",text:`\u{F115D} No entities found matching "${o}"`}]};let c=`\u{F115D} **Entities matching "${o}"** (${d.length})
11
11
 
12
- `;for(const f of d){const y=s.getRelationships(f.id,"both"),$=s.getAliases(f.id);c+=`- **${f.name}** _(${f.type})_ \u2014 ${y.length} connection${y.length!==1?"s":""}`,$.length&&(c+=` | also: ${$.join(", ")}`),c+=`
13
- `}const h=u(c);return n&&m.set(n,h,15e3),h}},{name:"wyrm_entity_graph",description:"Get the neighborhood graph around an entity \u2014 all connected nodes within N hops",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entity"},entity:{type:"string",description:"Entity name to center on"},depth:{type:"number",description:"Max hops from center (1-5, default: 2)"}},required:["projectPath","entity"]},annotations:_.wyrm_entity_graph,aliases:[],handler:async(g,l)=>{const{cachedResponse:u,db:t,graph:s}=l,n=g||{},e=P(),{projectPath:o,entity:i,depth:a}=g,p=t.getProject(o);if(!p)return{content:[{type:"text",text:`Project not found: ${o}`}],isError:!0};const r=s.findEntity(p.id,i)??s.findByAlias(p.id,i);if(!r)return{content:[{type:"text",text:`Entity not found: "${i}". Use wyrm_entity_search to find entities.`}],isError:!0};const d=s.getNeighborhood(r.id,Math.min(a??2,5));let c=`\u{F115D} **Graph: ${r.name}** _(depth: ${a??2})_
12
+ `;for(const f of d){const y=s.getRelationships(f.id,"both"),$=s.getAliases(f.id);c+=`- **${f.name}** _(${f.type})_: ${y.length} connection${y.length!==1?"s":""}`,$.length&&(c+=` | also: ${$.join(", ")}`),c+=`
13
+ `}const h=u(c);return n&&m.set(n,h,15e3),h}},{name:"wyrm_entity_graph",description:"Get the neighborhood graph around an entity: all connected nodes within N hops",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entity"},entity:{type:"string",description:"Entity name to center on"},depth:{type:"number",description:"Max hops from center (1-5, default: 2)"}},required:["projectPath","entity"]},annotations:_.wyrm_entity_graph,aliases:[],handler:async(g,l)=>{const{cachedResponse:u,db:t,graph:s}=l,n=g||{},e=P(),{projectPath:o,entity:i,depth:a}=g,p=t.getProject(o);if(!p)return{content:[{type:"text",text:`Project not found: ${o}`}],isError:!0};const r=s.findEntity(p.id,i)??s.findByAlias(p.id,i);if(!r)return{content:[{type:"text",text:`Entity not found: "${i}". Use wyrm_entity_search to find entities.`}],isError:!0};const d=s.getNeighborhood(r.id,Math.min(a??2,5));let c=`\u{F115D} **Graph: ${r.name}** _(depth: ${a??2})_
14
14
 
15
15
  `;c+=`**${d.nodes.length} nodes, ${d.edges.length} edges**
16
16
 
17
17
  `;const h={};for(const y of d.nodes)h[y.depth]||(h[y.depth]=[]),h[y.depth].push(y);for(const[y,$]of Object.entries(h).sort((x,j)=>Number(x[0])-Number(j[0]))){const x=y==="0"?"\u{1F3AF} Center":`Hop ${y}`;c+=`**${x}:** ${$.map(j=>`${j.name} (${j.type})`).join(", ")}
18
18
  `}if(d.edges.length>0){c+=`
19
19
  **Connections:**
20
- `;for(const y of d.edges.slice(0,20))c+=`- ${y.source_name} \u2014[${y.relationship_type}]\u2192 ${y.target_name}
20
+ `;for(const y of d.edges.slice(0,20))c+=`- ${y.source_name} [${y.relationship_type}]\u2192 ${y.target_name}
21
21
  `}const f=u(c);return e&&m.set(e,f,15e3),f}},{name:"wyrm_entity_path",description:"Find the shortest path between two entities in the knowledge graph",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entities"},source:{type:"string",description:"Source entity name"},target:{type:"string",description:"Target entity name"},maxDepth:{type:"number",description:"Max path length (1-5, default: 5)"}},required:["projectPath","source","target"]},annotations:_.wyrm_entity_path,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,source:n,target:e,maxDepth:o}=g,i=u.getProject(s);if(!i)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const a=t.findEntity(i.id,n)??t.findByAlias(i.id,n),p=t.findEntity(i.id,e)??t.findByAlias(i.id,e);if(!a)return{content:[{type:"text",text:`Entity not found: "${n}"`}],isError:!0};if(!p)return{content:[{type:"text",text:`Entity not found: "${e}"`}],isError:!0};const r=t.findPath(a.id,p.id,Math.min(o??5,5));if(!r)return{content:[{type:"text",text:`\u{F115D} No path found between **${n}** and **${e}** within ${o??5} hops.`}]};const c=r.map(h=>t.getEntity(h)).filter(Boolean).map(h=>h.name).join(" \u2192 ");return{content:[{type:"text",text:`\u{F115D} **Path Found** (${r.length-1} hops)
22
22
 
23
- ${c}`}]}}},{name:"wyrm_entity_merge",description:"Merge two entities \u2014 combines aliases, redirects relationships, deletes the source",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entities"},source:{type:"string",description:"Entity name to merge FROM (will be deleted)"},target:{type:"string",description:"Entity name to merge INTO (will be kept)"}},required:["projectPath","source","target"]},annotations:_.wyrm_entity_merge,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,source:n,target:e}=g,o=u.getProject(s);if(!o)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const i=t.findEntity(o.id,n)??t.findByAlias(o.id,n),a=t.findEntity(o.id,e)??t.findByAlias(o.id,e);return i?a?i.id===a.id?{content:[{type:"text",text:"Cannot merge entity with itself."}],isError:!0}:(t.mergeEntities(i.id,a.id),m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats"),{content:[{type:"text",text:`\u{F115D} **Merged** "${n}" \u2192 "${e}"
23
+ ${c}`}]}}},{name:"wyrm_entity_merge",description:"Merge two entities: combines aliases, redirects relationships, deletes the source",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entities"},source:{type:"string",description:"Entity name to merge FROM (will be deleted)"},target:{type:"string",description:"Entity name to merge INTO (will be kept)"}},required:["projectPath","source","target"]},annotations:_.wyrm_entity_merge,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,source:n,target:e}=g,o=u.getProject(s);if(!o)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const i=t.findEntity(o.id,n)??t.findByAlias(o.id,n),a=t.findEntity(o.id,e)??t.findByAlias(o.id,e);return i?a?i.id===a.id?{content:[{type:"text",text:"Cannot merge entity with itself."}],isError:!0}:(t.mergeEntities(i.id,a.id),m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats"),{content:[{type:"text",text:`\u{F115D} **Merged** "${n}" \u2192 "${e}"
24
24
 
25
25
  "${n}" is now an alias of "${e}". All relationships redirected.`}]}):{content:[{type:"text",text:`Entity not found: "${e}"`}],isError:!0}:{content:[{type:"text",text:`Entity not found: "${n}"`}],isError:!0}}}];export{S as entityToolSpecs};
@@ -1,16 +1,16 @@
1
- import{TOOL_ANNOTATIONS as f}from"../tool-annotations.js";import{installClaudeCodeHooks as x,installClaudeStatusline as w}from"../autoconfig.js";import{replicateOnce as _}from"../event-replication.js";import{embedAll as P,removeAll as E,statusAll as S}from"../priority-embed.js";import{ReplicationDaemon as k,addPeer as M,listPeers as b,removePeer as $}from"../replication-daemon.js";import{ValidationError as j,asEnum as R}from"../validate.js";const N=[{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,m)=>{const{db:r}=m,o=a||{},c=(s=>{const n=s.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(c)return c;const{projectPath:d,window:l}=a;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const i=r.getProject(d);if(!i)return{content:[{type:"text",text:"Project not found"}]};const p=r.subscribeEvents(i.id,l);return{content:[{type:"text",text:JSON.stringify({project:i.name,cursor:p.cursor,count:p.recent.length,events:p.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,m)=>{const{db:r}=m,o=a||{},c=(e=>{const g=e.filter(t=>!o[t]&&o[t]!==0&&o[t]!==!1);return g.length>0?{content:[{type:"text",text:`Missing required arguments: ${g.join(", ")}`}],isError:!0}:null})(["projectPath"]);if(c)return c;const{projectPath:d,cursor:l,limit:i}=a;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const p=r.getProject(d);if(!p)return{content:[{type:"text",text:"Project not found"}]};const s=r.eventsSince(p.id,l||0,i||100),n=s.length?s[s.length-1].cursor:l||0;return{content:[{type:"text",text:JSON.stringify({project:p.name,cursor:n,count:s.length,events:s})}]}}},{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,m)=>{const{db:r,presence:o}=m,h=a||{},d=(u=>{const y=u.filter(v=>!h[v]&&h[v]!==0&&h[v]!==!1);return y.length>0?{content:[{type:"text",text:`Missing required arguments: ${y.join(", ")}`}],isError:!0}:null})(["projectPath","kind"]);if(d)return d;const{projectPath:l,kind:i,refTable:p,refId:s,actor:n,isShared:e,payload:g}=a;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const t=r.getProject(l);return t?(r.publishEvent({projectId:t.id,kind:i,refTable:p,refId:s,actor:n,isShared:e,payload:g}),{content:[{type:"text",text:`\u{F115D} Event published to ${t.name} stream (${i})`}]}):{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,m)=>{const{db:r}=m,o=a||{},c=(t=>{const u=t.filter(y=>!o[y]&&o[y]!==0&&o[y]!==!1);return u.length>0?{content:[{type:"text",text:`Missing required arguments: ${u.join(", ")}`}],isError:!0}:null})(["projectPath","peerUrl"]);if(c)return c;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable replication."})}]};const{projectPath:d,peerUrl:l,token:i,remoteProject:p}=a,s=r.getProject(d);if(!s)return{content:[{type:"text",text:"Project not found"}]};const n={baseUrl:String(l).replace(/\/+$/,""),token:i,localProjectId:s.id,remoteProject:p||s.name},e=await _(r,n,fetch);return{content:[{type:"text",text:`\u{F115D} Replicated ${s.name} \u2194 ${n.baseUrl}: pulled ${e.pulled}, pushed ${e.pushed}, dup ${e.duplicates}, echo ${e.echoes}`+(e.errors.length?`
2
- \u26A0\uFE0F ${e.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), unshare (kind + id: make a record private again so it does not leave this machine). 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","unshare"]},interval_minutes:{type:"number",description:"start"},baseUrl:{type:"string",description:"peer_add/remove"},projectPath:{type:"string"},remoteProject:{type:"string",description:"peer_add/replicate"},tokenEnv:{type:"string",description:"peer_add: env var name"},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",enum:["capture","session_update","quest","truth","presence","tool_call","session","artifact","edge"]},id:{type:"number"},payload:{type:"object",description:"publish"},cursor:{type:"number",description:"since"},peerUrl:{type:"string",description:"replicate"},token:{type:"string",description:"replicate"}},required:["action"]},annotations:f.wyrm_replication,aliases:[],handler:async(a,m)=>{const{db:r,replicationManager:o}=m,h=["start","stop","status","tick","peer_add","peer_remove","peer_list","conflicts","resolve","publish","since","subscribe","replicate","unshare"],c=R("action",a.action,h);if(c===void 0)throw new j("action",`is required (one of: ${h.join(", ")})`);const{interval_minutes:d,baseUrl:l,projectPath:i,remoteProject:p,tokenEnv:s}=a;switch(c){case"start":{if(!r.liveMemoryEnabled())return{content:[{type:"text",text:"Live Memory is off (WYRM_LIVE_MEMORY=0) \u2014 daemon not started."}]};const n=o.start({interval_minutes:d});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(r);return{content:[{type:"text",text:JSON.stringify({running:n.running,pid:n.pid,peers:e})}]}}case"tick":{const e=await new k(r).tick(fetch);return{content:[{type:"text",text:JSON.stringify({peers:e.length,results:e})}]}}case"peer_add":{if(!l||!i)return{content:[{type:"text",text:"peer_add requires baseUrl and projectPath"}]};if(!r.getProject(i))return{content:[{type:"text",text:"Project not found"}]};try{return{content:[{type:"text",text:`\u{F115D} Peer added. Registry now has ${M(r,{baseUrl:l,projectPath:i,remoteProject:p,tokenEnv:s}).length} peer(s).`}]}}catch(e){return{content:[{type:"text",text:`Peer rejected: ${e instanceof Error?e.message:String(e)}`}]}}}case"peer_remove":return!l||!i?{content:[{type:"text",text:"peer_remove requires baseUrl and projectPath"}]}:{content:[{type:"text",text:`\u{F115D} Peer removed. Registry now has ${$(r,l,i).length} peer(s).`}]};case"peer_list":return{content:[{type:"text",text:JSON.stringify({peers:b(r)})}]};default:throw new j("action",`'${c}' is routed by the wyrm_replication tool; call wyrm_replication with action=${c}`)}}},{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,m)=>{const{memory:r}=m,o=a||{},c=(t=>{const u=t.filter(y=>!o[y]&&o[y]!==0&&o[y]!==!1);return u.length>0?{content:[{type:"text",text:`Missing required arguments: ${u.join(", ")}`}],isError:!0}:null})(["action"]);if(c)return c;const{action:d,projectPath:l,allClients:i}=a,p={projectDir:l,allClients:i},s=t=>t.map(u=>` ${String(u.result??u.status).padEnd(9)} [${u.scope}] ${u.file}`).join(`
1
+ import{TOOL_ANNOTATIONS as f}from"../tool-annotations.js";import{installClaudeCodeHooks as x,installClaudeStatusline as w}from"../autoconfig.js";import{replicateOnce as _}from"../event-replication.js";import{embedAll as P,removeAll as E,statusAll as S}from"../priority-embed.js";import{ReplicationDaemon as k,addPeer as M,listPeers as b,removePeer as $}from"../replication-daemon.js";import{ValidationError as j,asEnum as R}from"../validate.js";const N=[{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; 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,m)=>{const{db:r}=m,o=a||{},c=(s=>{const n=s.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(c)return c;const{projectPath:d,window:l}=a;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const i=r.getProject(d);if(!i)return{content:[{type:"text",text:"Project not found"}]};const p=r.subscribeEvents(i.id,l);return{content:[{type:"text",text:JSON.stringify({project:i.name,cursor:p.cursor,count:p.recent.length,events:p.recent})}]}}},{name:"wyrm_events_since",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.",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,m)=>{const{db:r}=m,o=a||{},c=(e=>{const g=e.filter(t=>!o[t]&&o[t]!==0&&o[t]!==!1);return g.length>0?{content:[{type:"text",text:`Missing required arguments: ${g.join(", ")}`}],isError:!0}:null})(["projectPath"]);if(c)return c;const{projectPath:d,cursor:l,limit:i}=a;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const p=r.getProject(d);if(!p)return{content:[{type:"text",text:"Project not found"}]};const s=r.eventsSince(p.id,l||0,i||100),n=s.length?s[s.length-1].cursor:l||0;return{content:[{type:"text",text:JSON.stringify({project:p.name,cursor:n,count:s.length,events:s})}]}}},{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: 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,m)=>{const{db:r,presence:o}=m,h=a||{},d=(u=>{const y=u.filter(v=>!h[v]&&h[v]!==0&&h[v]!==!1);return y.length>0?{content:[{type:"text",text:`Missing required arguments: ${y.join(", ")}`}],isError:!0}:null})(["projectPath","kind"]);if(d)return d;const{projectPath:l,kind:i,refTable:p,refId:s,actor:n,isShared:e,payload:g}=a;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable the event log."})}]};const t=r.getProject(l);return t?(r.publishEvent({projectId:t.id,kind:i,refTable:p,refId:s,actor:n,isShared:e,payload:g}),{content:[{type:"text",text:`\u{F115D} Event published to ${t.name} stream (${i})`}]}):{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: 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,m)=>{const{db:r}=m,o=a||{},c=(t=>{const u=t.filter(y=>!o[y]&&o[y]!==0&&o[y]!==!1);return u.length>0?{content:[{type:"text",text:`Missing required arguments: ${u.join(", ")}`}],isError:!0}:null})(["projectPath","peerUrl"]);if(c)return c;if(!r.liveMemoryEnabled())return{content:[{type:"text",text:JSON.stringify({disabled:!0,hint:"Set WYRM_LIVE_MEMORY=1 to enable replication."})}]};const{projectPath:d,peerUrl:l,token:i,remoteProject:p}=a,s=r.getProject(d);if(!s)return{content:[{type:"text",text:"Project not found"}]};const n={baseUrl:String(l).replace(/\/+$/,""),token:i,localProjectId:s.id,remoteProject:p||s.name},e=await _(r,n,fetch);return{content:[{type:"text",text:`\u{F115D} Replicated ${s.name} \u2194 ${n.baseUrl}: pulled ${e.pulled}, pushed ${e.pushed}, dup ${e.duplicates}, echo ${e.echoes}`+(e.errors.length?`
2
+ \u26A0\uFE0F ${e.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), unshare (kind + id: make a record private again so it does not leave this machine). 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","unshare"]},interval_minutes:{type:"number",description:"start"},baseUrl:{type:"string",description:"peer_add/remove"},projectPath:{type:"string"},remoteProject:{type:"string",description:"peer_add/replicate"},tokenEnv:{type:"string",description:"peer_add: env var name"},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",enum:["capture","session_update","quest","truth","presence","tool_call","session","artifact","edge"]},id:{type:"number"},payload:{type:"object",description:"publish"},cursor:{type:"number",description:"since"},peerUrl:{type:"string",description:"replicate"},token:{type:"string",description:"replicate"}},required:["action"]},annotations:f.wyrm_replication,aliases:[],handler:async(a,m)=>{const{db:r,replicationManager:o}=m,h=["start","stop","status","tick","peer_add","peer_remove","peer_list","conflicts","resolve","publish","since","subscribe","replicate","unshare"],c=R("action",a.action,h);if(c===void 0)throw new j("action",`is required (one of: ${h.join(", ")})`);const{interval_minutes:d,baseUrl:l,projectPath:i,remoteProject:p,tokenEnv:s}=a;switch(c){case"start":{if(!r.liveMemoryEnabled())return{content:[{type:"text",text:"Live Memory is off (WYRM_LIVE_MEMORY=0); daemon not started."}]};const n=o.start({interval_minutes:d});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(r);return{content:[{type:"text",text:JSON.stringify({running:n.running,pid:n.pid,peers:e})}]}}case"tick":{const e=await new k(r).tick(fetch);return{content:[{type:"text",text:JSON.stringify({peers:e.length,results:e})}]}}case"peer_add":{if(!l||!i)return{content:[{type:"text",text:"peer_add requires baseUrl and projectPath"}]};if(!r.getProject(i))return{content:[{type:"text",text:"Project not found"}]};try{return{content:[{type:"text",text:`\u{F115D} Peer added. Registry now has ${M(r,{baseUrl:l,projectPath:i,remoteProject:p,tokenEnv:s}).length} peer(s).`}]}}catch(e){return{content:[{type:"text",text:`Peer rejected: ${e instanceof Error?e.message:String(e)}`}]}}}case"peer_remove":return!l||!i?{content:[{type:"text",text:"peer_remove requires baseUrl and projectPath"}]}:{content:[{type:"text",text:`\u{F115D} Peer removed. Registry now has ${$(r,l,i).length} peer(s).`}]};case"peer_list":return{content:[{type:"text",text:JSON.stringify({peers:b(r)})}]};default:throw new j("action",`'${c}' is routed by the wyrm_replication tool; call wyrm_replication with action=${c}`)}}},{name:"wyrm_embed",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.",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,m)=>{const{memory:r}=m,o=a||{},c=(t=>{const u=t.filter(y=>!o[y]&&o[y]!==0&&o[y]!==!1);return u.length>0?{content:[{type:"text",text:`Missing required arguments: ${u.join(", ")}`}],isError:!0}:null})(["action"]);if(c)return c;const{action:d,projectPath:l,allClients:i}=a,p={projectDir:l,allClients:i},s=t=>t.map(u=>` ${String(u.result??u.status).padEnd(9)} [${u.scope}] ${u.file}`).join(`
3
3
  `);if(d==="status")return{content:[{type:"text",text:`\u{F115D} Wyrm priority embedding status:
4
4
  ${s(S(p))}`}]};if(d==="remove")return{content:[{type:"text",text:`\u{F115D} Removed Wyrm priority embedding:
5
5
  ${s(E(p))}`}]};const n=P(p);let e="";try{const t=x();e=t?`
6
6
 
7
7
  \u2705 Proactive hooks installed (${t.message??"SessionStart rehydrate + capture + trace"}).`:`
8
8
 
9
- (Claude Code not detected \u2014 skipped hook install.)`}catch(t){e=`
9
+ (Claude Code not detected; skipped hook install.)`}catch(t){e=`
10
10
 
11
11
  (Hook install skipped: ${t instanceof Error?t.message:String(t)})`}let g="";try{const t=w();t&&(g=`
12
12
  \u2705 Buddy statusline: ${t.message}`)}catch(t){g=`
13
13
  (Statusline skipped: ${t instanceof Error?t.message:String(t)})`}return{content:[{type:"text",text:`\u{F115D} Wyrm is now FIRST-PRIORITY memory:
14
14
  ${s(n)}${e}${g}
15
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{N as eventsToolSpecs};
16
+ 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.`}]}}}];export{N as eventsToolSpecs};
@@ -1,18 +1,21 @@
1
- import{readFileSync as P}from"fs";import{homedir as C}from"os";import{join as D,dirname as M}from"node:path";import{STALE_ANCHOR_FLAG as F}from"../failure-patterns.js";import{TOOL_ANNOTATIONS as j}from"../tool-annotations.js";import{renderResult as q,withGlyph as _}from"../render.js";import{asEnum as E,ValidationError as w}from"../validate.js";import{daemonOr as L}from"../daemon-writer.js";import{resolveTargetFile as U}from"../project-resolve.js";import{projectFromArg as z}from"./project-arg.js";const k=["file","symbol","command","prompt","edit"];let $=null;function oe(){$=null}function G(){const s=process.env.CLAUDE_SETTINGS??D(C(),".claude","settings.json");try{const l=JSON.parse(P(s,"utf-8"));for(const r of Object.values(l.hooks??{}))if(Array.isArray(r)){for(const m of r)for(const y of m?.hooks??[])if(y?.command&&/wyrm-guard/.test(y.command))return!0}}catch{}return!1}function W(){const s=Date.now();if($&&s-$.at<6e4)return $.line;const l=(process.env.WYRM_GUARD_MODE??"block").toLowerCase(),r=G()&&l==="block"?`
1
+ import{readFileSync as P}from"fs";import{homedir as C}from"os";import{join as D,dirname as M}from"node:path";import{STALE_ANCHOR_FLAG as F}from"../failure-patterns.js";import{TOOL_ANNOTATIONS as E}from"../tool-annotations.js";import{renderResult as k,withGlyph as f}from"../render.js";import{asEnum as S,ValidationError as w}from"../validate.js";import{daemonOr as L}from"../daemon-writer.js";import{resolveTargetFile as U}from"../project-resolve.js";import{projectFromArg as z}from"./project-arg.js";const A=["file","symbol","command","prompt","edit"];let $=null;function oe(){$=null}function G(){const a=process.env.CLAUDE_SETTINGS??D(C(),".claude","settings.json");try{const u=JSON.parse(P(a,"utf-8"));for(const o of Object.values(u.hooks??{}))if(Array.isArray(o)){for(const m of o)for(const h of m?.hooks??[])if(h?.command&&/wyrm-guard/.test(h.command))return!0}}catch{}return!1}function W(){const a=Date.now();if($&&a-$.at<6e4)return $.line;const u=(process.env.WYRM_GUARD_MODE??"block").toLowerCase(),o=G()&&u==="block"?`
2
2
 
3
- Enforcement: wyrm-guard hook ACTIVE -- identity-matching repeats of these are hard-blocked at the harness (PreToolUse).`:"\n\nEnforcement: ADVISORY ONLY on this machine -- the wyrm-guard PreToolUse hook is not enforcing (not installed, or WYRM_GUARD_MODE=warn/off). Treat this as a hard stop; run `wyrm guard` to enforce it.";return $={at:s,line:r},r}const Y={type:"object",properties:{blocked:{type:"boolean"},matches:{type:"array",items:{type:"object",properties:{id:{type:"integer"},pattern:{type:"string"},scope:{type:"string"},quarantine_scope:{type:"string"},target:{type:"string"},description:{type:"string"},why_failed:{type:["string","null"]},severity:{type:"string"},occurrences:{type:"integer"},last_seen:{type:"string"},recorded_by_agent:{type:"string"},run_id:{type:["string","null"]},match:{type:"string",enum:["exact","fuzzy","target"]},confidence:{type:"number",minimum:0,maximum:1}},required:["id","pattern","scope","quarantine_scope","target","description","why_failed","severity","occurrences","last_seen","recorded_by_agent","run_id","match","confidence"]}},recorded_by_agent:{type:["string","null"]},run_id:{type:["string","null"]},confidence:{type:"number",minimum:0,maximum:1}},required:["blocked","matches","recorded_by_agent","run_id","confidence"]},O={type:["object","null"],properties:{requested:{type:"string"},authorized:{type:"boolean"},changed:{type:"boolean"}},required:["requested","authorized","changed"]};function H(s,l){return s?s.authorized?s.changed?"":` - promote:'${s.requested}' was a no-op (already ${l}-scoped)`:` - promote:'${s.requested}' IGNORED -- caller carries no explicit identity (pass actor/run_id, _meta['wyrm/actor'], or WYRM_AGENT_ID/WYRM_RUN_ID)`:""}const ne=[{name:"wyrm_failure_record",description:"Use when an approach failed or something broke - log the dead end so nobody tries it again. Identical (scope, target, description) coalesces with occurrences++; when the root cause is fixed, stop flagging it with `wyrm failure resolve <id>` (CLI). Run-scoped failures quarantine until confirmed.",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Global if omitted"},scope:{type:"string",enum:["file","symbol","command","prompt","edit"]},target:{type:"string",description:"File, symbol, command, or prompt"},description:{type:"string",description:"What was tried"},why_failed:{type:"string",description:"Diagnosis if known"},severity:{type:"string",enum:["low","medium","high","critical"]},promote:{type:"string",enum:["project","global"],description:"Widen the tier (explicitly attributed callers only)"}},required:["scope","target","description"]},outputSchema:{type:"object",properties:{id:{type:"integer"},occurrences:{type:"integer"},scope:{type:"string"},target:{type:"string"},quarantine_scope:{type:"string"},run_id:{type:["string","null"]},promote:O},required:["id","occurrences","scope","target","quarantine_scope","run_id","promote"]},annotations:j.wyrm_failure_record,aliases:[],handler:async(s,{store:l,failures:r})=>{const{projectPath:m,scope:y,target:u,description:h,why_failed:f,severity:p,promote:e,files:a}=s,g=E("scope",y,k);if(!g)throw new w("scope","is required (one of: file, symbol, command, prompt, edit)");if(typeof u!="string"||!u)throw new w("target","is required (the action/command/code that failed)");if(typeof h!="string"||!h)throw new w("description","is required (what went wrong)");const o=E("severity",p,["low","medium","high","critical"]),b=m?l.getProject(m):null,v=g==="file"||g==="symbol"||g==="edit",c=v?U(u,b?.path??null):null,d=c?l.getProjectForPath(M(c))??null:v?null:b??null;let t=await L("failure_record",d?.id??null,{scope:g,target:u,description:h,why_failed:f,severity:o},()=>r.record({project_id:d?.id??null,scope:g,target:u,description:h,why_failed:f,severity:o})),i=0;const S=Array.isArray(a)?a.filter(n=>typeof n=="string"):[],A=S.length>0?S:c?[c]:[];A.length>0&&d?.path&&(i=r.recordAnchors(t.id,d.path,A,t.occurrences===1));let x=null;if(e==="project"||e==="global"){const n=r.promote(t.id,e);n.authorized&&(t=n.row??t),x={requested:e,authorized:n.authorized,changed:n.changed,quarantine_scope:n.row?.quarantine_scope??t.quarantine_scope??null}}const R={id:t.id,occurrences:t.occurrences,scope:g,target:u,quarantine_scope:t.quarantine_scope,run_id:t.run_id??null,promote:x,...i>0?{anchors:i}:{}};return q(R,(n,T)=>{const I=n.run_id?` - ${n.quarantine_scope}-scoped (run ${n.run_id})`:` - ${n.quarantine_scope}-scoped`,N=n.anchors?` - anchored to ${n.anchors} file(s)`:"";return _(T.brand,`Failure #${n.id} recorded (x${n.occurrences}) -- ${n.scope}:${n.target}${I}${N}`+H(n.promote,n.quarantine_scope))})}},{name:"wyrm_failure_check",description:"Use before proposing or executing any fix, command, or approach - did this fail before? Is it a known landmine? Counter-pattern memory: returns unresolved matching failures (empty = safe to proceed); show the mistakes already made on a project with `wyrm failure list` (CLI). Subagents: check before retrying anything flagged.",inputSchema:{type:"object",properties:{projectPath:{type:"string"},scope:{type:"string",enum:["file","symbol","command","prompt","edit"]},target:{type:"string"},description:{type:"string"},run_scope:{type:"string",enum:["run","project","global"],description:"Quarantine tier filter (run = same-run only)"}},required:["scope","target","description"]},outputSchema:Y,annotations:j.wyrm_failure_check,aliases:[],handler:async(s,{store:l,raw:r,failures:m})=>{const{projectPath:y,scope:u,target:h,description:f,run_scope:p}=s,e=E("scope",u===""?void 0:u,k);if(e===void 0)throw new w("scope",`is required (one of: ${k.join(", ")})`);if(typeof h!="string"||!h)throw new w("target","is required (the action/command/code about to run)");if(typeof f!="string"||!f)throw new w("description","is required (what the action does)");const a=z(l,r(),y),g=E("run_scope",p,["run","project","global"])??"any";let o=m.checkVerdict(e,h,f,a?.id??null,{runScope:g});const b=m.staleAnchorIds(o.matches,a?.path??null);if(b.size>0){const c=o.matches.map(t=>b.has(t.id)?{...t,stale_anchor:F}:t),d=c.find(t=>!t.stale_anchor);o={...o,blocked:c.some(t=>!t.stale_anchor),matches:c,...d?{recorded_by_agent:d.recorded_by_agent,run_id:d.run_id}:{}}}const v=o.blocked?W():"";if(o.blocked){m.recordBlock(o,a?.id??null);try{const{logSavings:c}=await import("../statusline.js"),d=r(),t=a?d.prepare("SELECT id FROM sessions WHERE project_id = ? ORDER BY created_at DESC LIMIT 1").get(a.id):void 0;c(d,"wyrm_failure_check","blocked_retry",1500*o.matches.length,t?.id)}catch{}}return q(o,(c,d)=>{if(!c.blocked&&c.matches.length===0)return _(d.ok,"No matching failures -- safe to proceed.");const t=c.matches.map(i=>`${_(d.fail,`#${i.id} ${i.scope}:${i.target}`)} -- tried ${i.occurrences}x (${i.severity}); last ${i.last_seen}
4
- ${i.description}`+(i.why_failed?`
5
- Why: ${i.why_failed}`:"")+(i.run_id?`
6
- Recorded by ${i.recorded_by_agent} in run ${i.run_id} (${i.quarantine_scope}-scoped)`:"")+(i.stale_anchor?`
7
- STALE ANCHOR: ${i.stale_anchor}`:"")).join(`
3
+ Enforcement: wyrm-guard hook ACTIVE -- identity-matching repeats of these are hard-blocked at the harness (PreToolUse).`:"\n\nEnforcement: ADVISORY ONLY on this machine -- the wyrm-guard PreToolUse hook is not enforcing (not installed, or WYRM_GUARD_MODE=warn/off). Treat this as a hard stop; run `wyrm guard` to enforce it.";return $={at:a,line:o},o}const Y={type:"object",properties:{blocked:{type:"boolean"},matches:{type:"array",items:{type:"object",properties:{id:{type:"integer"},pattern:{type:"string"},scope:{type:"string"},quarantine_scope:{type:"string"},target:{type:"string"},description:{type:"string"},why_failed:{type:["string","null"]},severity:{type:"string"},occurrences:{type:"integer"},last_seen:{type:"string"},recorded_by_agent:{type:"string"},run_id:{type:["string","null"]},match:{type:"string",enum:["exact","fuzzy","target"]},confidence:{type:"number",minimum:0,maximum:1}},required:["id","pattern","scope","quarantine_scope","target","description","why_failed","severity","occurrences","last_seen","recorded_by_agent","run_id","match","confidence"]}},recorded_by_agent:{type:["string","null"]},run_id:{type:["string","null"]},confidence:{type:"number",minimum:0,maximum:1}},required:["blocked","matches","recorded_by_agent","run_id","confidence"]},O={type:["object","null"],properties:{requested:{type:"string"},authorized:{type:"boolean"},changed:{type:"boolean"}},required:["requested","authorized","changed"]};function H(a,u){return a?a.authorized?a.changed?"":` - promote:'${a.requested}' was a no-op (already ${u}-scoped)`:` - promote:'${a.requested}' IGNORED -- caller carries no explicit identity (pass actor/run_id, _meta['wyrm/actor'], or WYRM_AGENT_ID/WYRM_RUN_ID)`:""}const ne=[{name:"wyrm_failure_record",description:"Use when an approach failed or something broke - log the dead end so nobody tries it again. Identical (scope, target, description) coalesces with occurrences++; when the root cause is fixed, stop flagging it with `wyrm failure resolve <id>` (CLI). Run-scoped failures quarantine until confirmed.",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Global if omitted"},scope:{type:"string",enum:["file","symbol","command","prompt","edit"]},target:{type:"string",description:"File, symbol, command, or prompt"},description:{type:"string",description:"What was tried"},why_failed:{type:"string",description:"Diagnosis if known"},severity:{type:"string",enum:["low","medium","high","critical"]},promote:{type:"string",enum:["project","global"],description:"Widen the tier (explicitly attributed callers only)"}},required:["scope","target","description"]},outputSchema:{type:"object",properties:{id:{type:"integer"},occurrences:{type:"integer"},scope:{type:"string"},target:{type:"string"},quarantine_scope:{type:"string"},run_id:{type:["string","null"]},promote:O},required:["id","occurrences","scope","target","quarantine_scope","run_id","promote"]},annotations:E.wyrm_failure_record,aliases:[],handler:async(a,{store:u,failures:o})=>{const{projectPath:m,scope:h,target:l,description:y,why_failed:_,severity:p,promote:t,files:c}=a,g=S("scope",h,A);if(!g)throw new w("scope","is required (one of: file, symbol, command, prompt, edit)");if(typeof l!="string"||!l)throw new w("target","is required (the action/command/code that failed)");if(typeof y!="string"||!y)throw new w("description","is required (what went wrong)");const n=S("severity",p,["low","medium","high","critical"]),b=m?u.getProject(m):null,q=g==="file"||g==="symbol"||g==="edit",i=q?U(l,b?.path??null):null,d=i?u.getProjectForPath(M(i))??null:q?null:b??null;let e=await L("failure_record",d?.id??null,{scope:g,target:l,description:y,why_failed:_,severity:n},()=>o.record({project_id:d?.id??null,scope:g,target:l,description:y,why_failed:_,severity:n})),r=0;const v=Array.isArray(c)?c.filter(s=>typeof s=="string"):[],j=v.length>0?v:i?[i]:[];j.length>0&&d?.path&&(r=o.recordAnchors(e.id,d.path,j,e.occurrences===1));let x=null;if(t==="project"||t==="global"){const s=o.promote(e.id,t);s.authorized&&(e=s.row??e),x={requested:t,authorized:s.authorized,changed:s.changed,quarantine_scope:s.row?.quarantine_scope??e.quarantine_scope??null}}const R={id:e.id,occurrences:e.occurrences,scope:g,target:l,quarantine_scope:e.quarantine_scope,run_id:e.run_id??null,promote:x,...r>0?{anchors:r}:{}};return k(R,(s,T)=>{const I=s.run_id?` - ${s.quarantine_scope}-scoped (run ${s.run_id})`:` - ${s.quarantine_scope}-scoped`,N=s.anchors?` - anchored to ${s.anchors} file(s)`:"";return f(T.brand,`Failure #${s.id} recorded (x${s.occurrences}) -- ${s.scope}:${s.target}${I}${N}`+H(s.promote,s.quarantine_scope))})}},{name:"wyrm_failure_check",description:"Use before proposing or executing any fix, command, or approach - did this fail before? Is it a known landmine? Counter-pattern memory: returns unresolved matching failures (empty = safe to proceed); show the mistakes already made on a project with `wyrm failure list` (CLI). Subagents: check before retrying anything flagged.",inputSchema:{type:"object",properties:{projectPath:{type:"string"},scope:{type:"string",enum:["file","symbol","command","prompt","edit"]},target:{type:"string"},description:{type:"string"},run_scope:{type:"string",enum:["run","project","global"],description:"Quarantine tier filter (run = same-run only)"}},required:["scope","target","description"]},outputSchema:Y,annotations:E.wyrm_failure_check,aliases:[],handler:async(a,{store:u,raw:o,failures:m})=>{const{projectPath:h,scope:l,target:y,description:_,run_scope:p}=a,t=S("scope",l===""?void 0:l,A);if(t===void 0)throw new w("scope",`is required (one of: ${A.join(", ")})`);if(typeof y!="string"||!y)throw new w("target","is required (the action/command/code about to run)");if(typeof _!="string"||!_)throw new w("description","is required (what the action does)");const c=z(u,o(),h),g=S("run_scope",p,["run","project","global"])??"any";let n=m.checkVerdict(t,y,_,c?.id??null,{runScope:g});const b=m.staleAnchorIds(n.matches,c?.path??null);if(b.size>0){const i=n.matches.map(e=>b.has(e.id)?{...e,stale_anchor:F}:e),d=i.find(e=>!e.stale_anchor&&!e.quiet_downgrade);n={...n,blocked:i.some(e=>!e.stale_anchor&&!e.quiet_downgrade),matches:i,...d?{recorded_by_agent:d.recorded_by_agent,run_id:d.run_id}:{}}}const q=n.blocked?W():"";if(n.blocked){m.recordBlock(n,c?.id??null);try{const{logSavings:i}=await import("../statusline.js"),d=o(),e=c?d.prepare("SELECT id FROM sessions WHERE project_id = ? ORDER BY created_at DESC LIMIT 1").get(c.id):void 0;i(d,"wyrm_failure_check","blocked_retry",1500*n.matches.length,e?.id)}catch{}}return k(n,(i,d)=>{if(!i.blocked&&i.matches.length===0)return f(d.ok,"No matching failures -- safe to proceed.");const e=i.matches.map(r=>`${f(d.fail,`#${r.id} ${r.scope}:${r.target}`)} -- tried ${r.occurrences}x (${r.severity}); last ${r.last_seen}
4
+ ${r.description}`+(r.why_failed?`
5
+ Why: ${r.why_failed}`:"")+(r.run_id?`
6
+ Recorded by ${r.recorded_by_agent} in run ${r.run_id} (${r.quarantine_scope}-scoped)`:"")+(r.stale_anchor?`
7
+ STALE ANCHOR: ${r.stale_anchor}`:"")+(r.quiet_downgrade?`
8
+ QUIET: ${r.quiet_downgrade}`:"")).join(`
8
9
 
9
- `);return c.blocked?`${_(d.brand,`${c.matches.length} failure(s) match this action:`)}
10
+ `);if(!i.blocked){const r=i.matches.filter(j=>j.quiet_downgrade).length;if(r===0)return`${f(d.warn,`${i.matches.length} recorded failure(s) match, but their anchored source changed since -- advisory only, re-verify before trusting or dismissing them:`)}
10
11
 
11
- ${t}${v}`:`${_(d.warn,`${c.matches.length} recorded failure(s) match, but their anchored source changed since -- advisory only, re-verify before trusting or dismissing them:`)}
12
+ ${e}`;const v=r===i.matches.length?"none has been hit in the quiet period, so they warn instead of block":"each is downgraded (anchored source changed, or no hits in the quiet period)";return`${f(d.warn,`${i.matches.length} recorded failure(s) match, but ${v} -- advisory only, re-verify before retrying:`)}
12
13
 
13
- ${t}`})}},{name:"wyrm_failure_list",description:"List unresolved failures for a project (or globally), most-recent-first.",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path (omit for global)"},limit:{type:"number",description:"Max rows (default 20, max 200)"}}},outputSchema:{type:"object",properties:{count:{type:"integer"},failures:{type:"array",items:{type:"object",properties:{id:{type:"integer"},severity:{type:"string",enum:["low","medium","high","critical"]},scope:{type:"string"},target:{type:"string"},occurrences:{type:"integer"},last_seen:{type:"string"},description:{type:"string"}},required:["id","severity","scope","target","occurrences","last_seen","description"]}}},required:["count","failures"]},annotations:j.wyrm_failure_list,aliases:[],handler:(s,{store:l,failures:r})=>{const{projectPath:m,limit:y}=s,u=m?l.getProject(m):null,h=Math.min(Math.max(1,y??20),200),f=r.list(u?.id??null,h),p={count:f.length,failures:f.map(e=>({id:e.id,severity:e.severity,scope:e.scope,target:e.target,occurrences:e.occurrences,last_seen:e.last_seen,description:e.description}))};return q(p,(e,a)=>{if(e.count===0)return _(a.brand,"No unresolved failures.");const g=e.failures.map(o=>`#${o.id} [${o.severity}] ${o.scope}:${o.target} x${o.occurrences} (last ${o.last_seen})
14
- ${o.description}`).join(`
14
+ ${e}`}return`${f(d.brand,`${i.matches.length} failure(s) match this action:`)}
15
15
 
16
- `);return`${_(a.brand,`${e.count} unresolved failure(s):`)}
16
+ ${e}${q}`})}},{name:"wyrm_failure_list",description:"List unresolved failures for a project (or globally), most-recent-first.",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path (omit for global)"},limit:{type:"number",description:"Max rows (default 20, max 200)"}}},outputSchema:{type:"object",properties:{count:{type:"integer"},failures:{type:"array",items:{type:"object",properties:{id:{type:"integer"},severity:{type:"string",enum:["low","medium","high","critical"]},scope:{type:"string"},target:{type:"string"},occurrences:{type:"integer"},last_seen:{type:"string"},description:{type:"string"}},required:["id","severity","scope","target","occurrences","last_seen","description"]}}},required:["count","failures"]},annotations:E.wyrm_failure_list,aliases:[],handler:(a,{store:u,failures:o})=>{const{projectPath:m,limit:h}=a,l=m?u.getProject(m):null,y=Math.min(Math.max(1,h??20),200),_=o.list(l?.id??null,y),p={count:_.length,failures:_.map(t=>({id:t.id,severity:t.severity,scope:t.scope,target:t.target,occurrences:t.occurrences,last_seen:t.last_seen,description:t.description}))};return k(p,(t,c)=>{if(t.count===0)return f(c.brand,"No unresolved failures.");const g=t.failures.map(n=>`#${n.id} [${n.severity}] ${n.scope}:${n.target} x${n.occurrences} (last ${n.last_seen})
17
+ ${n.description}`).join(`
17
18
 
18
- ${g}`},{summary:(e,a)=>e.count===0?_(a.brand,"No unresolved failures."):_(a.brand,`${e.count} unresolved failure(s):`)})}},{name:"wyrm_failure_resolve",description:"Mark a failure as resolved (the underlying issue was fixed). Keeps history but excludes from check() results.",inputSchema:{type:"object",properties:{id:{type:"number",description:"Failure pattern ID"},note:{type:"string",description:"How it was resolved"},promote:{type:"string",enum:["project","global"],description:"Widen the tier before resolving (same authority rule as wyrm_failure_record)."}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},resolved:{type:"boolean",enum:[!0]},promote:O},required:["id","resolved","promote"]},annotations:j.wyrm_failure_resolve,aliases:[],handler:(s,{failures:l})=>{const{id:r,note:m,promote:y}=s;let u=null;if(y==="project"||y==="global"){const p=l.promote(r,y);u={requested:y,authorized:p.authorized,changed:p.changed,quarantine_scope:p.row?.quarantine_scope??null}}const h=l.resolve(r,m);return h.row?h.authorized?q({id:r,resolved:!0,promote:u},(p,e)=>{let a="";return p.promote&&!p.promote.authorized?a=` promote:'${p.promote.requested}' IGNORED -- caller carries no explicit identity.`:p.promote?.changed&&(a=` Promoted to ${p.promote.quarantine_scope}-scoped.`),_(e.ok,`Failure #${p.id} resolved.${a}`)}):{content:[{type:"text",text:`Failure #${r} NOT resolved: this caller carries no explicit identity. Resolving a failure disarms the firewall for every agent sharing this memory, so it requires an attributed actor. To become one, set WYRM_AGENT_ID (and WYRM_RUN_ID when you are part of a run) on this process, or pass an actor via the request's _meta envelope. This is deterministic -- retrying unchanged will fail identically.`}],isError:!0}:{content:[{type:"text",text:`Failure #${r} not found.`}],isError:!0}}}];export{Y as FAILURE_CHECK_OUTPUT_SCHEMA,oe as _resetGuardEnforcementCache,ne as failureToolSpecs};
19
+ `);return`${f(c.brand,`${t.count} unresolved failure(s):`)}
20
+
21
+ ${g}`},{summary:(t,c)=>t.count===0?f(c.brand,"No unresolved failures."):f(c.brand,`${t.count} unresolved failure(s):`)})}},{name:"wyrm_failure_resolve",description:"Mark a failure as resolved (the underlying issue was fixed). Keeps history but excludes from check() results.",inputSchema:{type:"object",properties:{id:{type:"number",description:"Failure pattern ID"},note:{type:"string",description:"How it was resolved"},promote:{type:"string",enum:["project","global"],description:"Widen the tier before resolving (same authority rule as wyrm_failure_record)."}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},resolved:{type:"boolean",enum:[!0]},promote:O},required:["id","resolved","promote"]},annotations:E.wyrm_failure_resolve,aliases:[],handler:(a,{failures:u})=>{const{id:o,note:m,promote:h}=a;let l=null;if(h==="project"||h==="global"){const p=u.promote(o,h);l={requested:h,authorized:p.authorized,changed:p.changed,quarantine_scope:p.row?.quarantine_scope??null}}const y=u.resolve(o,m);return y.row?y.authorized?k({id:o,resolved:!0,promote:l},(p,t)=>{let c="";return p.promote&&!p.promote.authorized?c=` promote:'${p.promote.requested}' IGNORED -- caller carries no explicit identity.`:p.promote?.changed&&(c=` Promoted to ${p.promote.quarantine_scope}-scoped.`),f(t.ok,`Failure #${p.id} resolved.${c}`)}):{content:[{type:"text",text:`Failure #${o} NOT resolved: this caller carries no explicit identity. Resolving a failure disarms the firewall for every agent sharing this memory, so it requires an attributed actor. To become one, set WYRM_AGENT_ID (and WYRM_RUN_ID when you are part of a run) on this process, or pass an actor via the request's _meta envelope. This is deterministic -- retrying unchanged will fail identically.`}],isError:!0}:{content:[{type:"text",text:`Failure #${o} not found.`}],isError:!0}}}];export{Y as FAILURE_CHECK_OUTPUT_SCHEMA,oe as _resetGuardEnforcementCache,ne as failureToolSpecs};
@@ -1,4 +1,4 @@
1
- import{TOOL_ANNOTATIONS as l}from"../tool-annotations.js";import{renderResult as u,withGlyph as p}from"../render.js";import{ValidationError as g,asId as _,asInt as h}from"../validate.js";function c(r){const o=_("id",r.id??r.goal_id,"goal");if(o===void 0)throw new g("id","is required (id or goal_id)");return o}const f=[{name:"wyrm_goal_set",description:"Set a persistent goal Wyrm will pursue across sessions. Goals carry title, success_criteria, deadline, priority, and a max_iterations cap. The wyrm-loop daemon picks the highest-priority active goal each tick.",inputSchema:{type:"object",properties:{title:{type:"string",description:"Short, action-oriented title"},description:{type:"string",description:"Longer context"},success_criteria:{type:"string",description:"How Wyrm knows when the goal is done \u2014 checked each iteration"},deadline:{type:"string",description:"Optional ISO timestamp (YYYY-MM-DD or full)"},priority:{type:"string",enum:["critical","high","medium","low"],description:"Default: medium"},max_iterations:{type:"number",description:"Cap on OODA iterations (default 20, max 200) \u2014 guard against infinite spinning"},projectPath:{type:"string",description:"Scope to a project (optional)"}},required:["title"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},priority:{type:"string",enum:["critical","high","medium","low"]},status:{type:"string",enum:["active","paused","completed","abandoned"]},project_id:{type:["integer","null"]}},required:["id","title","priority","status","project_id"]},annotations:l.wyrm_goal_set,aliases:[],handler:(r,{projects:o,goals:i})=>{const t=r,a=t.projectPath?o.getProject(t.projectPath):null,e=i.set({project_id:a?.id??null,title:t.title,description:t.description,success_criteria:t.success_criteria,deadline:t.deadline,priority:t.priority,max_iterations:t.max_iterations});return u({id:e.id,title:e.title,priority:e.priority,status:e.status,project_id:e.project_id},(d,n)=>p(n.brand,`Goal #${d.id} set [${d.priority}]: ${d.title}`))}},{name:"wyrm_goal_list",description:"List goals, optionally filtered by status / project. Default: active goals, prioritized.",inputSchema:{type:"object",properties:{status:{type:"string",enum:["active","paused","completed","abandoned"]},projectPath:{type:"string"},limit:{type:"number"}}},outputSchema:{type:"object",properties:{count:{type:"integer"},goals:{type:"array",items:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},priority:{type:"string",enum:["critical","high","medium","low"]},status:{type:"string",enum:["active","paused","completed","abandoned"]},iterations_count:{type:"integer"},max_iterations:{type:"integer"},progress_pct:{type:"integer",minimum:0},last_outcome:{type:["string","null"]}},required:["id","title","priority","status","iterations_count","max_iterations","progress_pct","last_outcome"]}}},required:["count","goals"]},annotations:l.wyrm_goal_list,aliases:[],handler:(r,{projects:o,goals:i})=>{const t=r,a=t.projectPath?o.getProject(t.projectPath):null,e=i.list({status:t.status,project_id:a?.id,limit:t.limit}),d={count:e.length,goals:e.map(n=>({id:n.id,title:n.title,priority:n.priority,status:n.status,iterations_count:n.iterations_count,max_iterations:n.max_iterations,progress_pct:Math.round(100*n.iterations_count/Math.max(1,n.max_iterations)),last_outcome:n.last_outcome}))};return u(d,(n,m)=>{if(n.count===0)return p(m.brand,"No goals.");const y=n.goals.map(s=>`${m.bullet} #${s.id} [${s.priority}/${s.status}] ${s.title} -- ${s.iterations_count}/${s.max_iterations} iter (${s.progress_pct}%)`+(s.last_outcome?` last:${s.last_outcome}`:""));return`${p(m.brand,`${n.count} goal(s):`)}
1
+ import{TOOL_ANNOTATIONS as l}from"../tool-annotations.js";import{renderResult as u,withGlyph as p}from"../render.js";import{ValidationError as g,asId as _,asInt as h}from"../validate.js";function c(r){const o=_("id",r.id??r.goal_id,"goal");if(o===void 0)throw new g("id","is required (id or goal_id)");return o}const f=[{name:"wyrm_goal_set",description:"Set a persistent goal Wyrm will pursue across sessions. Goals carry title, success_criteria, deadline, priority, and a max_iterations cap. The wyrm-loop daemon picks the highest-priority active goal each tick.",inputSchema:{type:"object",properties:{title:{type:"string",description:"Short, action-oriented title"},description:{type:"string",description:"Longer context"},success_criteria:{type:"string",description:"How Wyrm knows when the goal is done, checked each iteration"},deadline:{type:"string",description:"Optional ISO timestamp (YYYY-MM-DD or full)"},priority:{type:"string",enum:["critical","high","medium","low"],description:"Default: medium"},max_iterations:{type:"number",description:"Cap on OODA iterations (default 20, max 200); a guard against infinite spinning"},projectPath:{type:"string",description:"Scope to a project (optional)"}},required:["title"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},priority:{type:"string",enum:["critical","high","medium","low"]},status:{type:"string",enum:["active","paused","completed","abandoned"]},project_id:{type:["integer","null"]}},required:["id","title","priority","status","project_id"]},annotations:l.wyrm_goal_set,aliases:[],handler:(r,{projects:o,goals:i})=>{const t=r,a=t.projectPath?o.getProject(t.projectPath):null,e=i.set({project_id:a?.id??null,title:t.title,description:t.description,success_criteria:t.success_criteria,deadline:t.deadline,priority:t.priority,max_iterations:t.max_iterations});return u({id:e.id,title:e.title,priority:e.priority,status:e.status,project_id:e.project_id},(d,n)=>p(n.brand,`Goal #${d.id} set [${d.priority}]: ${d.title}`))}},{name:"wyrm_goal_list",description:"List goals, optionally filtered by status / project. Default: active goals, prioritized.",inputSchema:{type:"object",properties:{status:{type:"string",enum:["active","paused","completed","abandoned"]},projectPath:{type:"string"},limit:{type:"number"}}},outputSchema:{type:"object",properties:{count:{type:"integer"},goals:{type:"array",items:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},priority:{type:"string",enum:["critical","high","medium","low"]},status:{type:"string",enum:["active","paused","completed","abandoned"]},iterations_count:{type:"integer"},max_iterations:{type:"integer"},progress_pct:{type:"integer",minimum:0},last_outcome:{type:["string","null"]}},required:["id","title","priority","status","iterations_count","max_iterations","progress_pct","last_outcome"]}}},required:["count","goals"]},annotations:l.wyrm_goal_list,aliases:[],handler:(r,{projects:o,goals:i})=>{const t=r,a=t.projectPath?o.getProject(t.projectPath):null,e=i.list({status:t.status,project_id:a?.id,limit:t.limit}),d={count:e.length,goals:e.map(n=>({id:n.id,title:n.title,priority:n.priority,status:n.status,iterations_count:n.iterations_count,max_iterations:n.max_iterations,progress_pct:Math.round(100*n.iterations_count/Math.max(1,n.max_iterations)),last_outcome:n.last_outcome}))};return u(d,(n,m)=>{if(n.count===0)return p(m.brand,"No goals.");const y=n.goals.map(s=>`${m.bullet} #${s.id} [${s.priority}/${s.status}] ${s.title} -- ${s.iterations_count}/${s.max_iterations} iter (${s.progress_pct}%)`+(s.last_outcome?` last:${s.last_outcome}`:""));return`${p(m.brand,`${n.count} goal(s):`)}
2
2
  ${y.join(`
3
- `)}`})}},{name:"wyrm_goal_complete",description:"Manually mark a goal completed (e.g. when the agent reports done or the operator finishes it).",inputSchema:{type:"object",properties:{id:{type:"number"},note:{type:"string",description:"Final outcome note"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["completed"]}},required:["id","title","status"]},annotations:l.wyrm_goal_complete,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r),note:r.note},t=o.complete(i.id,i.note);return t?u({id:t.id,title:t.title,status:"completed"},(a,e)=>p(e.ok,`Goal #${a.id} completed.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_pause",description:"Pause a goal \u2014 wyrm-loop will skip it until resumed.",inputSchema:{type:"object",properties:{id:{type:"number"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["paused"]}},required:["id","title","status"]},annotations:l.wyrm_goal_pause,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r)},t=o.pause(i.id);return t?u({id:t.id,title:t.title,status:"paused"},(a,e)=>p(e.paused,`Goal #${a.id} paused.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_resume",description:"Resume a paused goal.",inputSchema:{type:"object",properties:{id:{type:"number"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["active"]}},required:["id","title","status"]},annotations:l.wyrm_goal_resume,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r)},t=o.resume(i.id);return t?u({id:t.id,title:t.title,status:"active"},(a,e)=>p(e.resumed,`Goal #${a.id} resumed.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_abandon",description:"Abandon a goal (won't be auto-pursued; record kept for audit).",inputSchema:{type:"object",properties:{id:{type:"number"},reason:{type:"string"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["abandoned"]}},required:["id","title","status"]},annotations:l.wyrm_goal_abandon,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r),reason:r.reason},t=o.abandon(i.id,i.reason);return t?u({id:t.id,title:t.title,status:"abandoned"},(a,e)=>p(e.brand,`Goal #${a.id} abandoned.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_iterations",description:"List the OODA iterations Wyrm has run for a goal \u2014 what it observed, decided, and resulted.",inputSchema:{type:"object",properties:{goal_id:{type:"number"},limit:{type:"number"}},required:["goal_id"]},outputSchema:{type:"object",properties:{goal_id:{type:"integer"},count:{type:"integer"},iterations:{type:"array",items:{type:"object",properties:{id:{type:"integer"},iteration_num:{type:"integer"},observe_summary:{type:["string","null"]},decided_action:{type:["string","null"]},action_result:{type:["string","null"]},outcome:{type:"string",enum:["progressed","blocked","done","error"]},ran_at:{type:"string"}},required:["id","iteration_num","outcome","ran_at"]}}},required:["goal_id","count","iterations"]},annotations:l.wyrm_goal_iterations,aliases:[],handler:(r,{goals:o})=>{const i={goal_id:c(r),limit:h("limit",r.limit,{min:1})},t=o.iterationsFor(i.goal_id,Math.min(100,i.limit??20)),a={goal_id:i.goal_id,count:t.length,iterations:t};return u(a,(e,d)=>e.count===0?p(d.brand,`Goal #${e.goal_id} has no iterations yet.`):`${p(d.brand,`${e.count} iteration(s) for goal #${e.goal_id}:`)}
3
+ `)}`})}},{name:"wyrm_goal_complete",description:"Manually mark a goal completed (e.g. when the agent reports done or the operator finishes it).",inputSchema:{type:"object",properties:{id:{type:"number"},note:{type:"string",description:"Final outcome note"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["completed"]}},required:["id","title","status"]},annotations:l.wyrm_goal_complete,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r),note:r.note},t=o.complete(i.id,i.note);return t?u({id:t.id,title:t.title,status:"completed"},(a,e)=>p(e.ok,`Goal #${a.id} completed.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_pause",description:"Pause a goal; wyrm-loop will skip it until resumed.",inputSchema:{type:"object",properties:{id:{type:"number"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["paused"]}},required:["id","title","status"]},annotations:l.wyrm_goal_pause,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r)},t=o.pause(i.id);return t?u({id:t.id,title:t.title,status:"paused"},(a,e)=>p(e.paused,`Goal #${a.id} paused.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_resume",description:"Resume a paused goal.",inputSchema:{type:"object",properties:{id:{type:"number"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["active"]}},required:["id","title","status"]},annotations:l.wyrm_goal_resume,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r)},t=o.resume(i.id);return t?u({id:t.id,title:t.title,status:"active"},(a,e)=>p(e.resumed,`Goal #${a.id} resumed.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_abandon",description:"Abandon a goal (won't be auto-pursued; record kept for audit).",inputSchema:{type:"object",properties:{id:{type:"number"},reason:{type:"string"}},required:["id"]},outputSchema:{type:"object",properties:{id:{type:"integer"},title:{type:"string"},status:{type:"string",enum:["abandoned"]}},required:["id","title","status"]},annotations:l.wyrm_goal_abandon,aliases:[],handler:(r,{goals:o})=>{const i={id:c(r),reason:r.reason},t=o.abandon(i.id,i.reason);return t?u({id:t.id,title:t.title,status:"abandoned"},(a,e)=>p(e.brand,`Goal #${a.id} abandoned.`)):{content:[{type:"text",text:`Goal #${i.id} not found.`}],isError:!0}}},{name:"wyrm_goal_iterations",description:"List the OODA iterations Wyrm has run for a goal: what it observed, decided, and resulted.",inputSchema:{type:"object",properties:{goal_id:{type:"number"},limit:{type:"number"}},required:["goal_id"]},outputSchema:{type:"object",properties:{goal_id:{type:"integer"},count:{type:"integer"},iterations:{type:"array",items:{type:"object",properties:{id:{type:"integer"},iteration_num:{type:"integer"},observe_summary:{type:["string","null"]},decided_action:{type:["string","null"]},action_result:{type:["string","null"]},outcome:{type:"string",enum:["progressed","blocked","done","error"]},ran_at:{type:"string"}},required:["id","iteration_num","outcome","ran_at"]}}},required:["goal_id","count","iterations"]},annotations:l.wyrm_goal_iterations,aliases:[],handler:(r,{goals:o})=>{const i={goal_id:c(r),limit:h("limit",r.limit,{min:1})},t=o.iterationsFor(i.goal_id,Math.min(100,i.limit??20)),a={goal_id:i.goal_id,count:t.length,iterations:t};return u(a,(e,d)=>e.count===0?p(d.brand,`Goal #${e.goal_id} has no iterations yet.`):`${p(d.brand,`${e.count} iteration(s) for goal #${e.goal_id}:`)}
4
4
  ${JSON.stringify(e.iterations,null,2)}`)}}];export{f as goalToolSpecs};