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.
- package/dist/activation.js +1 -1
- package/dist/agent-loop.js +2 -2
- package/dist/audit.js +2 -2
- package/dist/autoconfig.js +6 -6
- package/dist/backup-cli.js +6 -0
- package/dist/backup.js +1 -0
- package/dist/bridge.js +1 -1
- package/dist/buddy-runner.js +1 -1
- package/dist/buddy.js +4 -4
- package/dist/capabilities.js +1 -1
- package/dist/causality.js +3 -3
- package/dist/cloud/cli.js +3 -3
- package/dist/cloud/sync-daemon-entrypoint.js +1 -1
- package/dist/cloud/sync-engine.js +8 -7
- package/dist/cloud-backup.js +4 -4
- package/dist/cloud-sync-entrypoint.js +1 -1
- package/dist/cloud-sync.js +1 -1
- package/dist/connectors/ingest.js +2 -2
- package/dist/constellation.js +1 -1
- package/dist/context-build-budgeted.js +4 -4
- package/dist/context-ranking.js +1 -1
- package/dist/daemon-writer.js +1 -1
- package/dist/database.js +41 -23
- package/dist/design.js +1 -1
- package/dist/erasure-cli.js +3 -0
- package/dist/erasure-log.js +8 -0
- package/dist/erasure.js +1 -0
- package/dist/event-replication.js +1 -1
- package/dist/events.js +11 -11
- package/dist/failure-patterns.js +67 -44
- package/dist/federation.js +11 -10
- package/dist/governance.js +1 -0
- package/dist/handlers/agent.js +4 -4
- package/dist/handlers/alias-adapters.js +1 -1
- package/dist/handlers/audit.js +1 -1
- package/dist/handlers/boundary.js +1 -1
- package/dist/handlers/capture.js +54 -52
- package/dist/handlers/causality.js +2 -2
- package/dist/handlers/cloud.js +9 -9
- package/dist/handlers/companion.js +4 -4
- package/dist/handlers/entity.js +6 -6
- package/dist/handlers/events.js +4 -4
- package/dist/handlers/failure.js +15 -12
- package/dist/handlers/goals.js +2 -2
- package/dist/handlers/intelligence.js +81 -74
- package/dist/handlers/mcpclient.js +3 -3
- package/dist/handlers/presence.js +1 -1
- package/dist/handlers/prompts.js +2 -2
- package/dist/handlers/quest.js +11 -4
- package/dist/handlers/recall.js +10 -10
- package/dist/handlers/resources.js +1 -1
- package/dist/handlers/review.js +3 -3
- package/dist/handlers/run.js +3 -3
- package/dist/handlers/search.js +1 -1
- package/dist/handlers/session.js +27 -25
- package/dist/handlers/share.js +3 -3
- package/dist/handlers/skill.js +2 -2
- package/dist/handlers/symbols.js +5 -5
- package/dist/handlers/syncops.js +2 -2
- package/dist/harvest.js +5 -5
- package/dist/hours.js +1 -1
- package/dist/http-auth.js +2 -2
- package/dist/http-fast.js +17 -17
- package/dist/http-projects.js +4 -0
- package/dist/http-rate-limit.js +1 -0
- package/dist/index-health.js +52 -0
- package/dist/index.js +2 -2
- package/dist/indexer.js +4 -4
- package/dist/intelligence.js +36 -29
- package/dist/lane-provenance.js +39 -0
- package/dist/license.js +1 -1
- package/dist/lineage.js +15 -0
- package/dist/live-embedding-state.js +2 -2
- package/dist/maintenance.js +2 -2
- package/dist/mcp-integrity.js +2 -2
- package/dist/memory-artifacts.js +39 -37
- package/dist/metabolize.js +9 -7
- package/dist/metrics.js +1 -1
- package/dist/migrate-prompt.js +1 -1
- package/dist/migrations.js +236 -45
- package/dist/priority-embed.js +1 -1
- package/dist/providers/embedding-provider.js +1 -1
- package/dist/readonly-gate.js +1 -1
- package/dist/redact-backfill.js +1 -0
- package/dist/rehydration.js +30 -20
- package/dist/reindex.js +1 -1
- package/dist/render-target.js +6 -6
- package/dist/repl-guard.js +1 -1
- package/dist/replication-daemon-entrypoint.js +1 -1
- package/dist/replication-daemon.js +1 -1
- package/dist/retention.js +1 -0
- package/dist/reverse-bridge.js +6 -6
- package/dist/review-sample.js +31 -0
- package/dist/security.js +1 -1
- package/dist/self-maintenance.js +4 -4
- package/dist/served-records.js +8 -2
- package/dist/setup-wizard.js +1 -1
- package/dist/setup.js +1 -1
- package/dist/skill-author.js +2 -2
- package/dist/store-open.js +1 -0
- package/dist/store-readonly.js +1 -0
- package/dist/sub-agent.js +2 -2
- package/dist/tool-manifest-v2.json +1 -1
- package/dist/tool-manifest.json +1 -1
- package/dist/truth-freshness.js +8 -0
- package/dist/ui-dashboard.js +4 -4
- package/dist/vault.js +1 -1
- package/dist/vector-init.js +1 -1
- package/dist/vectors.js +4 -3
- package/dist/visibility.js +12 -12
- package/dist/write-guard.js +1 -0
- package/dist/wyrm-cli.js +108 -92
- package/dist/wyrm-guard.js +13 -12
- package/dist/wyrm-loop.js +3 -3
- package/dist/wyrm-manifest.json +1 -1
- package/dist/wyrm-memo.js +5 -5
- package/package.json +1 -1
- package/scripts/hooks/wyrm-session-capture.mjs +3 -0
package/dist/wyrm-guard.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{openDatabase as
|
|
3
|
-
`,{mode:384})}catch{}}function
|
|
4
|
-
`){a.push(o),o="";continue}o+=s}a.push(o);for(const
|
|
5
|
-
`}function
|
|
2
|
+
import{openDatabase as P}from"./storage/index.js";import{openStoreForWrite as U}from"./store-open.js";import{readFileSync as Y,realpathSync as z,appendFileSync as F,statSync as j,unlinkSync as q}from"node:fs";import{homedir as k}from"node:os";import{basename as B,dirname as V,isAbsolute as v,join as R,relative as H,resolve as C,sep as Z}from"node:path";import{fileURLToPath as J}from"node:url";import{FailurePatterns as N,normalizeIdentity as x,canonicalizeCommand as T,STALE_ANCHOR_FLAG as K}from"./failure-patterns.js";import{LEGACY_ENVELOPE as X,runWithActor as Q,sanitizeActorId as W}from"./handlers/boundary.js";import{resolveProjectForPath as tt}from"./project-resolve.js";const w={exitCode:0,stdout:"",stderr:""},et=Number(process.env.WYRM_GUARD_SLOW_MS??1500),nt=64*1024;function rt(t,n,i){if(!(!Number.isFinite(t)||t<et)&&(i.WYRM_GUARD_TRACE??"")!=="0")try{const a=R(k(),".wyrm"),o=R(a,"guard-slow.log");try{j(o).size>nt&&q(o)}catch{}F(o,`${new Date().toISOString()} ${Math.round(t)}ms ${n}
|
|
3
|
+
`,{mode:384})}catch{}}function I(t){const n=[],i=c=>{const s=c.trim();s&&s.length<=1e3&&!n.includes(s)&&n.push(s)},a=[];let o="",r=null;for(let c=0;c<t.length;c++){const s=t[c];if(r){o+=s,s===r&&t[c-1]!=="\\"&&(r=null);continue}if(s==="'"||s==='"'){r=s,o+=s;continue}const h=t.slice(c,c+2);if(h==="&&"||h==="||"){a.push(o),o="",c++;continue}if(s===";"||s==="|"||s===`
|
|
4
|
+
`){a.push(o),o="";continue}o+=s}a.push(o);for(const c of a){i(c);let s=c.trim(),h=!1;for(let u=0;u<8;u++){const f=s.match(/^(?:sudo(?:\s+-[A-Za-z]+)*|doas|time|nohup|exec|command|stdbuf(?:\s+-\S+)*|env|[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|\S*))\s+/);if(!f)break;s=s.slice(f[0].length).trim(),h=!0}h&&i(s);const p=s.match(/^(?:ba|z|k)?sh\s+-c\s+(['"])([\s\S]*)\1\s*$/);if(p)for(const u of I(p[2]))i(u)}return n}const ot=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),st=3;function g(t){return typeof t=="string"&&t.length>0?t:null}function _(t,n){return t?t.replace(/[\x00-\x1f\x7f]/g," ").replace(/\s+/g," ").trim().slice(0,n):""}function it(t){const n=t.hook_event_name;if(n!==void 0&&n!=="PreToolUse")return null;const i=t.tool_name,a=t.tool_input;if(typeof i!="string"||typeof a!="object"||a===null)return null;const o=a,r=g(t.cwd);if(i==="Bash"){const c=g(o.command)?.trim();if(!c)return null;const s=c.slice(0,1e3);return{scopes:["command"],probeTarget:s,identity:I(c),display:_(s,80),startDir:r,absPath:null}}if(ot.has(i)){const c=g(o.file_path)??g(o.notebook_path);if(!c)return null;const s=o.edits,h=g(o.new_string)??g(o.content)??g(o.new_source)??(Array.isArray(s)?s.map(u=>g(u?.new_string)??"").join(" "):""),p=v(c)?C(c):r&&v(r)?C(r,c):null;return{scopes:["file","edit"],probeTarget:B(c).slice(0,200),identity:G([c,...p?[p]:[]]),display:_(c,80),startDir:p?V(p):r,absPath:p,content:h}}return null}function G(t){const n=new Set,i=[];for(const a of t){const o=x(a);o.length===0||n.has(o)||(n.add(o),i.push(a))}return i}function ct(t){if(t.recorded_by_agent==="legacy"&&t.run_id===null)return"";const n=t.run_id?` (run ${_(t.run_id,32)}${t.quarantine_scope==="run"?", run-quarantined":""})`:"";return` recorded by: ${_(t.recorded_by_agent,64)}${n}
|
|
5
|
+
`}function at(t,n,i){const a=t.description?` description: ${_(t.description,200)}
|
|
6
6
|
`:"",o=t.why_failed?` failed because: ${_(t.why_failed,300)}
|
|
7
|
-
`:"";return`wyrm-guard: BLOCKED
|
|
7
|
+
`:"";return`wyrm-guard: BLOCKED because ${n==="exact"?"this exact action is a recorded unresolved failure":n==="content"?"this edit re-introduces the code of a recorded unresolved failure":n==="canonical"?"this command is equivalent (flags reordered / =-normalized) to a recorded unresolved failure":"this exact target previously failed and the failure is unresolved"} (deterministic ${n} match).
|
|
8
8
|
failure #${t.id} [${t.severity}/${t.scope}] seen ${t.occurrences}x, last ${_(t.last_seen,32)}
|
|
9
9
|
target: ${_(t.target,120)}
|
|
10
|
-
`+a+o+ct(t)+`Do NOT retry the same action
|
|
10
|
+
`+a+o+ct(t)+`Do NOT retry the same action; pick a different approach. If the underlying
|
|
11
11
|
issue is truly fixed, resolve the failure first (wyrm_failure_resolve id=${t.id})
|
|
12
12
|
and then retry.
|
|
13
|
-
`+(
|
|
14
|
-
`:"")}function
|
|
15
|
-
stale_anchor: ${r.stale_anchor}`:"")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
`+(i>0?`(+${i} more recorded match${i===1?"":"es"} via wyrm_failure_list)
|
|
14
|
+
`:"")}function dt(t,n){const i=t.slice(0,st),a=i.map(r=>{const c=r.why_failed??r.description;return`- #${r.id} [${r.severity}/${r.scope}] ${_(r.target,80)} (seen ${r.occurrences}x, confidence ${r.confidence}): ${_(c,160)}`+(r.stale_anchor?`
|
|
15
|
+
stale_anchor: ${r.stale_anchor}`:"")+(r.quiet_downgrade?`
|
|
16
|
+
quiet_downgrade: ${r.quiet_downgrade}`:"")}),o=t.length-i.length;return["<wyrm-memory>",`wyrm-guard: ${t.length} recorded unresolved failure(s) look similar to \`${n}\`; check before proceeding:`,...a,...o>0?[`(+${o} more via wyrm_failure_list)`]:[],"If one applies, do not repeat it; adjust the approach or resolve it first (wyrm_failure_resolve).","</wyrm-memory>"].join(`
|
|
17
|
+
`)}function lt(t,n){const i={hookSpecificOutput:{hookEventName:"PreToolUse",additionalContext:dt(t,n)}};return{exitCode:0,stdout:JSON.stringify(i)+`
|
|
18
|
+
`,stderr:""}}function ut(t,n=process.env){const i=Date.now(),a=ft(t,n);return rt(Date.now()-i,a.exitCode===2?"blocked":"allowed",n),a}function ft(t,n=process.env){let i=null;try{const a=(n.WYRM_GUARD_MODE??"block").toLowerCase();if(a==="off"||!t||!t.trim())return w;const o=JSON.parse(t);if(typeof o!="object"||o===null)return w;const r=it(o);if(!r)return w;const c=n.WYRM_DB_PATH??R(k(),".wyrm","wyrm.db");i=P(c,{readonly:!0,fileMustExist:!0}),i.pragma("busy_timeout = 100");const{id:s,root:h}=tt(i,r.startDir),p=[...r.identity];h&&r.absPath&&r.absPath.startsWith(h+Z)&&p.push(H(h,r.absPath));const u=W(n.WYRM_RUN_ID)??null,f=new N(i),m=new Set,y=[],b=G(p);for(const e of r.scopes)try{const d=f.checkVerdict(e,r.probeTarget,"",s,{callerRunId:u});for(const l of d.matches)m.has(l.id)||(m.add(l.id),y.push(l))}catch{}for(const e of r.scopes)for(const d of b)try{for(const l of f.targetIdentityMatches(e,d,s,{callerRunId:u}))m.has(l.id)||(m.add(l.id),y.push(f.toVerdictMatch(l,"target")))}catch{}if(!/^(0|false|no|off)$/i.test(n.WYRM_GUARD_CANONICAL??""))for(const e of r.scopes)for(const d of b)try{for(const l of f.canonicalMatches(e,d,s,{callerRunId:u}))m.has(l.id)||(m.add(l.id),y.push(f.toVerdictMatch(l,"canonical")))}catch{}if(!/^(0|false|no|off)$/i.test(n.WYRM_GUARD_RELATED??""))for(const e of r.scopes)for(const d of b)try{for(const l of f.commandHeadFamily(e,d,s,{callerRunId:u}))m.has(l.id)||(m.add(l.id),y.push(f.toVerdictMatch(l,"related")))}catch{}let S=null;if(r.content&&r.scopes.includes("edit")&&/^(1|true|yes|on)$/i.test(n.WYRM_GUARD_CONTENT??""))try{const e=f.contentMatch(r.content,"edit",s);e&&!m.has(e.id)&&(m.add(e.id),S=f.toVerdictMatch(e,"target"))}catch{}if(y.length===0&&!S)return w;const L=new Set(b.map(e=>x(e))),O=new Set(r.scopes.includes("command")?b.map(e=>T(e)).filter(e=>e.length>0):[]),D={exact:0,target:1,canonical:2,content:3},A=[...y.map(e=>({m:e,reason:e.match==="exact"?"exact":e.match==="target"||L.has(x(e.target))?"target":e.match==="canonical"||e.scope==="command"&&e.match!=="related"&&O.has(T(e.target))?"canonical":null})).filter(e=>e.reason!==null),...S?[{m:S,reason:"content"}]:[]].sort((e,d)=>D[e.reason]-D[d.reason]);let $=A,E=y;if(A.length>0)try{const e=f.staleAnchorIds(A.filter(d=>d.reason!=="content").map(d=>d.m),h);e.size>0&&($=A.filter(d=>!e.has(d.m.id)),E=y.map(d=>e.has(d.id)?{...d,stale_anchor:K}:d))}catch{}if($=$.filter(e=>!e.m.quiet_downgrade),$.length>0&&a!=="warn"){const e=$[0];try{const d=U(c,{fileMustExist:!0},n);try{d.pragma("busy_timeout = 50");const l=W(n.WYRM_AGENT_ID);Q(l!==null||u!==null?{agent_id:l,run_id:u,source:"env"}:X,()=>new N(d).recordBlock({blocked:!0,matches:[e.m],recorded_by_agent:e.m.recorded_by_agent,run_id:e.m.run_id,confidence:e.m.confidence},s))}finally{d.close()}}catch{}return{exitCode:2,stdout:"",stderr:at(e.m,e.reason,y.length-1)}}return lt(E,r.display)}catch(a){if(n.WYRM_GUARD_DEBUG==="1"){const o=a instanceof Error?a.message:String(a);return{exitCode:0,stdout:"",stderr:`wyrm-guard: internal error (fail-open): ${_(o,200)}
|
|
19
|
+
`}}return w}finally{try{i?.close()}catch{}}}const ht=J(import.meta.url);let M=!1;try{M=typeof process.argv[1]=="string"&&z(process.argv[1])===ht}catch{M=!1}if(M){let t="";try{t=Y(0,"utf-8")}catch{t=""}const n=ut(t);n.stdout&&process.stdout.write(n.stdout),n.stderr&&process.stderr.write(n.stderr),process.exit(n.exitCode)}export{I as commandSegments,ut as runGuard};
|
package/dist/wyrm-loop.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{WyrmDB as
|
|
3
|
-
wyrm-loop
|
|
2
|
+
import{WyrmDB as d}from"./database.js";import{Goals as h}from"./goals.js";import{AgentLoop as w}from"./agent-loop.js";import{OutboundMcpClient as g}from"./mcp-client.js";import{makeInternalDispatch as v}from"./internal-dispatch.js";import{FailurePatterns as y}from"./failure-patterns.js";import{SymbolGraph as S}from"./symbols.js";import{Rehydration as x}from"./rehydration.js";import{Causality as $}from"./causality.js";import{AgentPresence as b}from"./presence.js";import{Federation as D}from"./federation.js";import{MemoryArtifacts as I}from"./memory-artifacts.js";import{GroundTruths as P}from"./intelligence.js";import{wireTruthAutoCascade as O}from"./truth-cascade.js";import{scheduleMaintenanceSweep as M}from"./self-maintenance.js";import{createVectorStore as j}from"./vectors.js";import{resolveEmbeddingState as A}from"./providers/embedding-provider.js";function R(e){const t={interval:600,once:!1,maxSteps:3,verbose:process.env.WYRM_LOOP_LOG==="1"};for(let n=0;n<e.length;n++){const r=e[n];r==="--interval"?t.interval=Math.max(10,parseInt(e[++n],10)||600):r==="--once"?t.once=!0:r==="--goal"?t.goalId=parseInt(e[++n],10):r==="--max-steps"?t.maxSteps=Math.max(1,Math.min(20,parseInt(e[++n],10)||3)):r==="--project"?t.projectPath=e[++n]:r==="--verbose"||r==="-v"?t.verbose=!0:(r==="--help"||r==="-h")&&(console.log(T),process.exit(0))}return t}const T=`
|
|
3
|
+
wyrm-loop: autonomous OODA scheduler
|
|
4
4
|
|
|
5
5
|
wyrm-loop [options]
|
|
6
6
|
|
|
@@ -12,4 +12,4 @@ Options
|
|
|
12
12
|
--project PATH Scope to a project root
|
|
13
13
|
--verbose, -v Log every tick to stderr
|
|
14
14
|
--help, -h Show this help
|
|
15
|
-
`;function a(e,t){e.verbose&&console.error(`[wyrm-loop ${new Date().toISOString()}] ${t}`)}async function
|
|
15
|
+
`;function a(e,t){e.verbose&&console.error(`[wyrm-loop ${new Date().toISOString()}] ${t}`)}async function k(e,t,n,r){let o=e.goalId;if(!o){let u;if(e.projectPath){const m=t.getProject(e.projectPath);if(!m)return a(e,`project '${e.projectPath}' not registered; idle`),!1;u=m.id}const p=n.nextToPursue(u);if(!p)return a(e,"no active goals; idle"),!1;o=p.id}const c=n.get(o);if(!c||c.status!=="active")return a(e,`goal #${o} not active; skipping`),!1;a(e,`pursuing goal #${o}: ${c.title.slice(0,80)}`);const i=await r.pursue(o,{max_steps:e.maxSteps});if(i.length===0)return a(e,`goal #${o} returned no iterations`),!1;const l=i[i.length-1];return a(e,`goal #${o} ran ${i.length} iteration(s); last outcome=${l.outcome} (${l.latency_ms}ms, model=${l.model}${l.degraded?" DEGRADED":""})`),!0}async function E(){const e=R(process.argv.slice(2)),t=new d(process.env.WYRM_DB_PATH),n=new h(t.getDatabase()),r=new g(t.getDatabase()),o=t.getDatabase(),c=new P(o),i=new $(o);O(c,i);const l=v({db:t,failures:new y(o),symbols:new S(o),rehydration:new x(o),causality:i,presence:new b(o),federation:new D(o),memory:new I(o),groundTruths:c}),u=new w(o,r,l);let p=!1;const m=()=>{p||(p=!0,a(e,"shutting down\u2026"),r.shutdown().finally(()=>{try{t.close()}catch{}process.exit(0)}))};if(process.on("SIGINT",m),process.on("SIGTERM",m),!e.once){let s;M(t,process.env,{vectors:()=>{if(s===void 0){s=null;try{const f=process.env.WYRM_VECTOR_PROVIDER||"auto";A(f).resolved!=="none"&&(s=j({provider:f},o))}catch{s=null}}return s}})}for(e.verbose&&console.error(`wyrm-loop starting \xB7 interval=${e.interval}s \xB7 once=${e.once} \xB7 max-steps=${e.maxSteps}`);!p;){try{await k(e,t,n,u)}catch(s){console.error(`wyrm-loop tick error: ${s.message}`)}if(e.once){m();return}await new Promise(s=>{setTimeout(s,e.interval*1e3)})}}E().catch(e=>{console.error(`wyrm-loop fatal: ${e.message}`),process.exit(1)});
|
package/dist/wyrm-manifest.json
CHANGED
package/dist/wyrm-memo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as _,realpathSync as U,statSync as D}from"node:fs";import{homedir as O}from"node:os";import{dirname as
|
|
3
|
-
`)}function
|
|
4
|
-
`).length,x=
|
|
5
|
-
`,stderr:""}}catch(
|
|
6
|
-
`}:e}finally{try{
|
|
2
|
+
import{readFileSync as _,realpathSync as U,statSync as D}from"node:fs";import{homedir as O}from"node:os";import{dirname as A,join as F}from"node:path";import{fileURLToPath as L}from"node:url";import{openDatabase as N}from"./storage/index.js";import{openStoreForWrite as g}from"./store-open.js";import{logSavings as R}from"./statusline.js";import{resolveProjectForPath as C}from"./project-resolve.js";import{ReadMemos as h,distill as I,estimateTokens as E,isExpired as W,isProbablyText as v,readTarget as B,sha256Hex as T}from"./read-memo.js";const e={exitCode:0,stdout:"",stderr:""},j=6e3,k=7,z=2e6;function y(o,t,i){const r=Number(o[t]);return Number.isFinite(r)&&r>=0?r:i}function H(o,t){return["<wyrm-memory>",`wyrm-memo: you already read this exact file in full (unchanged since ${o} UTC). Its map:`,t,"</wyrm-memory>"].join(`
|
|
3
|
+
`)}function J(o,t=process.env){let i=null,r=null;try{const n=(t.WYRM_MEMO_MODE??"observe").toLowerCase();if(n==="off"||!o||!o.trim())return e;const l=JSON.parse(o);if(typeof l!="object"||l===null)return e;const m=l,u=m.hook_event_name;if(u!=="PreToolUse"&&u!=="PostToolUse")return e;const s=B(m);if(!s)return e;const c=D(s.absPath);if(!c.isFile()||c.size>y(t,"WYRM_MEMO_MAX_BYTES",z))return e;const f=t.WYRM_DB_PATH??F(O(),".wyrm","wyrm.db"),P=typeof m.session_id=="string"?m.session_id.slice(0,64):null;if(u==="PostToolUse"){const d=_(s.absPath);if(!v(d))return e;const p=d.toString("utf8"),w=p.length===0?0:p.split(`
|
|
4
|
+
`).length,x=I(p,s.absPath);r=g(f,{fileMustExist:!0},t),r.pragma("busy_timeout = 50");const{id:Y}=C(r,A(s.absPath));return new h(r).upsert({path:s.absPath,sha256:T(d),bytes:c.size,lines:w,distilled:x,tool:s.tool,projectId:Y,sessionId:P}),e}if(c.size<y(t,"WYRM_MEMO_MIN_BYTES",j))return e;i=N(f,{readonly:!0,fileMustExist:!0}),i.pragma("busy_timeout = 100");const a=new h(i).get(s.absPath);if(!a||W(a.last_seen,y(t,"WYRM_MEMO_TTL_DAYS",k))||T(_(s.absPath))!==a.sha256)return e;const b=Math.max(0,E(c.size)-E(a.distilled.length));try{r=g(f,{fileMustExist:!0},t),r.pragma("busy_timeout = 50"),new h(r).recordHit(s.absPath,b),R(r,"wyrm-memo","cached_preamble",b,void 0,"conservative")}catch{}if(n!=="warn")return e;const S={hookSpecificOutput:{hookEventName:"PreToolUse",additionalContext:H(a.last_seen,a.distilled)}};return{exitCode:0,stdout:JSON.stringify(S)+`
|
|
5
|
+
`,stderr:""}}catch(n){return t.WYRM_MEMO_DEBUG==="1"?{exitCode:0,stdout:"",stderr:`wyrm-memo: internal error (fail-open): ${(n instanceof Error?n.message:String(n)).slice(0,200)}
|
|
6
|
+
`}:e}finally{try{i?.close()}catch{}try{r?.close()}catch{}}}const X=L(import.meta.url);let M=!1;try{M=typeof process.argv[1]=="string"&&U(process.argv[1])===X}catch{M=!1}if(M){let o="";try{o=_(0,"utf-8")}catch{o=""}const t=J(o);t.stdout&&process.stdout.write(t.stdout),t.stderr&&process.stderr.write(t.stderr),process.exit(t.exitCode)}export{J as runMemo};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wyrm-mcp",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.3",
|
|
4
4
|
"mcpName": "lk.ghosts/wyrm",
|
|
5
5
|
"description": "Local-first persistent memory for AI agents over MCP. Ground truths, a failure firewall that blocks repeated mistakes (negative learning), and hybrid recall, stored in SQLite on your machine. No cloud or LLM required. Proprietary license.",
|
|
6
6
|
"type": "module",
|
|
@@ -133,6 +133,9 @@ try {
|
|
|
133
133
|
runWyrm(['capture', content, '--project', project, '--mode', 'memory'], {
|
|
134
134
|
timeout: 25000,
|
|
135
135
|
stdio: 'ignore',
|
|
136
|
+
// Quest #1154: the capture is attributable. WYRM_AGENT_ID, when the
|
|
137
|
+
// harness exports one, still wins inside the CLI; this is the fallback.
|
|
138
|
+
env: { ...process.env, WYRM_WRITER_ID: process.env.WYRM_WRITER_ID || 'hook:session-capture' },
|
|
136
139
|
});
|
|
137
140
|
} catch { /* wyrm not on PATH or capture failed — never break the session */ }
|
|
138
141
|
|