@maincode-ai/matilda-code 0.22.1-preview.0 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunks/agent-IJOGVY62.js +3 -0
- package/chunks/agent-headless-FZGKJCVK.js +3 -0
- package/chunks/{askUserQuestion-A46IDHKS.js → askUserQuestion-DHYKAZWH.js} +1 -1
- package/chunks/ca-HHQCT6S2.js +23 -0
- package/chunks/chunk-3BT7ZYAM.js +121 -0
- package/chunks/chunk-3IG6LNQ3.js +2581 -0
- package/chunks/{chunk-6RK6IJY5.js → chunk-46FFWNRO.js} +1 -1
- package/chunks/chunk-55YW6EUC.js +8 -0
- package/chunks/chunk-BQDEPKIG.js +46 -0
- package/chunks/{chunk-LONWTJOE.js → chunk-BS7Q7KA6.js} +8 -8
- package/chunks/chunk-DZKI2CAC.js +3 -0
- package/chunks/{chunk-TDFF4ZGY.js → chunk-E2KMVG7F.js} +1 -1
- package/chunks/chunk-FY3LL4OC.js +8 -0
- package/chunks/chunk-HJK3NKAR.js +8 -0
- package/chunks/{chunk-ZABAV4XA.js → chunk-HRD7WD3P.js} +3 -3
- package/chunks/{chunk-YY64FVJG.js → chunk-L2FKLLEC.js} +1 -1
- package/chunks/chunk-MZ73LBEY.js +9 -0
- package/chunks/chunk-N2BE647T.js +10 -0
- package/chunks/{chunk-6T25BBKH.js → chunk-OF7ORAN6.js} +53 -53
- package/chunks/{chunk-UICLGQTV.js → chunk-OWEBLTAN.js} +1 -1
- package/chunks/{chunk-KYNP66YS.js → chunk-P24OL22U.js} +8 -8
- package/chunks/chunk-PFXCFIHY.js +8 -0
- package/chunks/chunk-REUZDMLM.js +80 -0
- package/chunks/chunk-VWE5BSHV.js +56 -0
- package/chunks/{chunk-FI2FSW7J.js → chunk-VWM3GUBH.js} +1 -1
- package/chunks/chunk-WL27X35X.js +44 -0
- package/chunks/chunk-ZUQRP3N6.js +9 -0
- package/chunks/{computer-use-2YIT7SIT.js → computer-use-5T3ZH24D.js} +7 -7
- package/chunks/{cron-create-JINCFLKY.js → cron-create-5RRFCP36.js} +1 -1
- package/chunks/{cron-delete-RF6JLUAV.js → cron-delete-7DTRWCSV.js} +1 -1
- package/chunks/{cron-list-VXLBAXZ3.js → cron-list-HY6XJD7D.js} +1 -1
- package/chunks/de-MJBGC47E.js +23 -0
- package/chunks/{edit-6S3DRURW.js → edit-Y7YSDGLT.js} +17 -17
- package/chunks/en-JITX7JKV.js +23 -0
- package/chunks/{enter-worktree-57EOUOC4.js → enter-worktree-5ZGIYDUE.js} +1 -1
- package/chunks/{enterPlanMode-EWO2LZ5G.js → enterPlanMode-TWD4MXCW.js} +1 -1
- package/chunks/{exit-worktree-T7IHIQX5.js → exit-worktree-3F5UY76U.js} +1 -1
- package/chunks/{exitPlanMode-YW7MKP6A.js → exitPlanMode-HWK5EUVS.js} +1 -1
- package/chunks/fr-WT3R2JCR.js +23 -0
- package/chunks/{glob-EYNPF6KD.js → glob-H7DNNPJ4.js} +1 -1
- package/chunks/{goal-tools-F2V2CXAF.js → goal-tools-CJINJJ3Y.js} +1 -1
- package/chunks/grep-5MCMGW6A.js +22 -0
- package/chunks/ja-OEXP6Z3S.js +23 -0
- package/chunks/{keychain-token-storage-UTWIIKCK.js → keychain-token-storage-BCODB632.js} +1 -1
- package/chunks/ls-JORGCXES.js +15 -0
- package/chunks/{lsp-H4EXPHFD.js → lsp-Y46R5DO5.js} +1 -1
- package/chunks/mcp-client-54J5M542.js +3 -0
- package/chunks/monitor-BRJR6PR3.js +32 -0
- package/chunks/notebook-edit-UCCVQ4JP.js +17 -0
- package/chunks/openaiContentGenerator-H6JOS3XU.js +52 -0
- package/chunks/pt-PCVIFK7H.js +23 -0
- package/chunks/read-file-LVMBCRCT.js +3 -0
- package/chunks/ripGrep-F6AJSDKU.js +3 -0
- package/chunks/ru-CB5SIZZM.js +23 -0
- package/chunks/scheduler-XAOD6LG6.js +8 -0
- package/chunks/{send-message-5XHDGHSN.js → send-message-VY4DP63A.js} +1 -1
- package/chunks/shell-QUDC6MJK.js +3 -0
- package/chunks/{skill-AR3SRFYF.js → skill-5EMGSWRM.js} +4 -4
- package/chunks/symbol-search-YNGX4Z5T.js +19 -0
- package/chunks/{syntheticOutput-OIPRFBVD.js → syntheticOutput-4JANVS4D.js} +1 -1
- package/chunks/{task-create-QP44DKH4.js → task-create-NRBVXURQ.js} +1 -1
- package/chunks/{task-detach-AUTU6C4G.js → task-detach-VHDDAO2K.js} +1 -1
- package/chunks/{task-list-U2WAGMM7.js → task-list-T2IET466.js} +1 -1
- package/chunks/{task-stop-GN5WZ3IA.js → task-stop-OEAEE5R7.js} +1 -1
- package/chunks/{task-update-26N2AUQT.js → task-update-4ANRU74G.js} +1 -1
- package/chunks/{team-create-RPZE626O.js → team-create-G4N2NCFN.js} +1 -1
- package/chunks/team-delete-M4ORNSTT.js +8 -0
- package/chunks/{todoWrite-JN3ZV5O2.js → todoWrite-RN2OP46T.js} +1 -1
- package/chunks/{tool-search-RDU7B45X.js → tool-search-WEUURHFZ.js} +1 -1
- package/chunks/{web-fetch-6RRSCIUU.js → web-fetch-VA2BZ4VR.js} +1 -1
- package/chunks/{web-search-3IXDQD7D.js → web-search-OVFXJQDS.js} +3 -5
- package/chunks/{workflow-P6YL6ZHY.js → workflow-6VMVM5BG.js} +2 -2
- package/chunks/write-file-5ZAZVXBB.js +15 -0
- package/cli.js +471 -455
- package/locales/ca.js +6 -2
- package/locales/de.js +6 -2
- package/locales/en.js +35 -2
- package/locales/fr.js +6 -2
- package/locales/ja.js +6 -2
- package/locales/pt.js +6 -2
- package/locales/ru.js +6 -2
- package/package.json +2 -2
- package/chunks/agent-BXVCIBXW.js +0 -3
- package/chunks/agent-headless-64NUELGA.js +0 -3
- package/chunks/ca-JKEHLTNL.js +0 -23
- package/chunks/chunk-5JCW6FH6.js +0 -8
- package/chunks/chunk-7AEOFDY3.js +0 -8
- package/chunks/chunk-7YEKK577.js +0 -2602
- package/chunks/chunk-A5QKQKJW.js +0 -56
- package/chunks/chunk-AEYNMLMW.js +0 -36
- package/chunks/chunk-BSSOFLAZ.js +0 -80
- package/chunks/chunk-DEN6RR3B.js +0 -3
- package/chunks/chunk-HRCRNKY2.js +0 -8
- package/chunks/chunk-IV6PS6DB.js +0 -8
- package/chunks/chunk-RH3AEZWO.js +0 -9
- package/chunks/chunk-S6SR7XG2.js +0 -121
- package/chunks/chunk-SMTY6M3W.js +0 -10
- package/chunks/chunk-TKEFJ3O3.js +0 -9
- package/chunks/chunk-ZSGBDQXU.js +0 -11
- package/chunks/de-GMGNR5CZ.js +0 -23
- package/chunks/en-3NQMLVKW.js +0 -23
- package/chunks/fr-WS3EBB36.js +0 -23
- package/chunks/grep-CDC2COXY.js +0 -22
- package/chunks/ja-GBCDQ43R.js +0 -23
- package/chunks/ls-3EEHZY4W.js +0 -15
- package/chunks/mcp-client-3GTPI6IS.js +0 -3
- package/chunks/monitor-AHLS4MYF.js +0 -32
- package/chunks/notebook-edit-6HEQYPZ3.js +0 -17
- package/chunks/openaiContentGenerator-CQQ7EBHB.js +0 -47
- package/chunks/pt-VID6J2CM.js +0 -23
- package/chunks/read-file-EWNDGS3Y.js +0 -3
- package/chunks/ripGrep-6BXNDTIT.js +0 -3
- package/chunks/ru-EB6V6EAN.js +0 -23
- package/chunks/scheduler-FLVTLJFY.js +0 -8
- package/chunks/shell-FVBBSL2E.js +0 -3
- package/chunks/symbol-search-ZM3HFCUV.js +0 -19
- package/chunks/team-delete-XCKD5FBZ.js +0 -8
- package/chunks/write-file-BYAPFQ5P.js +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{h as P,r as R}from"./chunk-MZ73LBEY.js";import{a as C}from"./chunk-PFXCFIHY.js";import{f as O,g as S,m as A,n as W}from"./chunk-P24OL22U.js";import{P as T,ea as I}from"./chunk-WL27X35X.js";import{b as E}from"./chunk-GZPNIYVZ.js";E();import*as h from"fs/promises";import*as f from"fs";import*as u from"path";var D=I("TODO_WRITE");function U(o){return new P(o.finalOutput).isBlockingDecision()}var q={name:"todo_write",description:"Creates and manages a structured task list for your current coding session. This helps track progress, organize complex tasks, and demonstrate thoroughness.",parametersJsonSchema:{type:"object",properties:{todos:{type:"array",items:{type:"object",properties:{content:{type:"string",minLength:1},status:{type:"string",enum:["pending","in_progress","completed"]},id:{type:"string"}},required:["content","status","id"],additionalProperties:!1},description:"The updated todo list"}},required:["todos"],$schema:"http://json-schema.org/draft-07/schema#"}},H=`
|
|
4
4
|
Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
5
5
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
6
6
|
|
|
@@ -182,15 +182,15 @@ When new information changes your understanding of the task, update the todo str
|
|
|
182
182
|
- Use clear, descriptive task names
|
|
183
183
|
|
|
184
184
|
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
|
|
185
|
-
`,
|
|
185
|
+
`,L="todos";function y(o){let t=u.join(T.getRuntimeBaseDir(),L),e=`${o||"default"}.json`;return u.join(t,e)}async function $(o){try{let t=y(o),e=await h.readFile(t,"utf-8"),r=JSON.parse(e);return Array.isArray(r.todos)?r.todos:[]}catch(t){let e=t;if(!(e instanceof Error)||e.code!=="ENOENT")throw t;return[]}}async function B(o,t){let e=y(t),r=u.dirname(e);await h.mkdir(r,{recursive:!0}),await C(e,JSON.stringify({todos:o,sessionId:t||"default"},null,2),{encoding:"utf-8"})}function N(o,t){return{llmContent:`${o}
|
|
186
186
|
|
|
187
187
|
<system-reminder>
|
|
188
188
|
${t}
|
|
189
|
-
</system-reminder>`,returnDisplay:
|
|
189
|
+
</system-reminder>`,returnDisplay:o}}var w=class extends O{constructor(e,r,l="update"){super(r);this.config=e;this.operationType=l}operationType;getDescription(){return this.operationType==="create"?"Create todos":"Update todos"}async execute(e){let{todos:r,modified_by_user:l,modified_content:i}=this.params,b=this.config.getSessionId();try{let m=await $(b),n;if(l&&i!==void 0){let s=JSON.parse(i);n=Array.isArray(s.todos)?s.todos:[]}else n=r;let d=R(m,n),v=new Map(m.map(s=>[s.id,s])),c=this.config.getHookSystem();if(c&&d.created.length>0){let p=(await Promise.all(d.created.map(a=>c.fireTodoCreatedEvent(a.id,a.content,a.status,n,"validation",e)))).find(U);if(p?.finalOutput){let a=p.finalOutput.reason||"Hook blocked todo creation";return N(`Todo creation blocked: ${a}`,`Todo list was not modified because a TodoCreated hook blocked the operation: ${a}`)}}if(c&&d.completed.length>0){let p=(await Promise.all(d.completed.map(a=>{let z=v.get(a.id)?.status??"pending";return c.fireTodoCompletedEvent(a.id,a.content,z,n,"validation",e)}))).find(U);if(p?.finalOutput){let a=p.finalOutput.reason||"Hook blocked todo completion";return N(`Todo completion blocked: ${a}`,`Todo list was not modified because a TodoCompleted hook blocked the operation: ${a}`)}}await B(n,b);let g;try{c&&d.created.length>0&&await Promise.all(d.created.map(s=>c.fireTodoCreatedEvent(s.id,s.content,s.status,n,"postWrite",e))),c&&d.completed.length>0&&await Promise.all(d.completed.map(s=>{let a=v.get(s.id)?.status??"pending";return c.fireTodoCompletedEvent(s.id,s.content,a,n,"postWrite",e)}))}catch(s){g=s instanceof Error?s:new Error(String(s)),D.error(`[TodoWriteTool] Post-write hooks failed after todos were persisted: ${g.message}`)}let _={type:"todo_list",todos:n,changes:d},j=JSON.stringify(n),k,x=g?`
|
|
190
190
|
|
|
191
191
|
<system-reminder>
|
|
192
192
|
Todos were persisted successfully, but post-write hooks failed with error: ${g.message}. Do not tell the user the write failed; only handle any follow-up hook issues if needed.
|
|
193
|
-
</system-reminder>`:"";return
|
|
193
|
+
</system-reminder>`:"";return n.length===0?k=`Todo list has been cleared.
|
|
194
194
|
|
|
195
195
|
<system-reminder>
|
|
196
196
|
Your todo list is now empty. DO NOT mention this explicitly to the user. You have no pending tasks in your todo list.
|
|
@@ -199,12 +199,12 @@ Your todo list is now empty. DO NOT mention this explicitly to the user. You hav
|
|
|
199
199
|
<system-reminder>
|
|
200
200
|
Your todo list has changed. DO NOT mention this explicitly to the user. Here are the latest contents of your todo list:
|
|
201
201
|
|
|
202
|
-
${
|
|
203
|
-
</system-reminder>${x}`,{llmContent:k,returnDisplay:
|
|
202
|
+
${j}. Continue on with the tasks at hand if applicable.
|
|
203
|
+
</system-reminder>${x}`,{llmContent:k,returnDisplay:_}}catch(m){let n=m instanceof Error?m.message:String(m);return D.error(`[TodoWriteTool] Error executing todo_write: ${n}`),{llmContent:`Failed to modify todos. An error occurred during the operation.
|
|
204
204
|
|
|
205
205
|
<system-reminder>
|
|
206
|
-
Todo list modification failed with error: ${
|
|
207
|
-
</system-reminder>`,returnDisplay:`Error writing todos: ${
|
|
206
|
+
Todo list modification failed with error: ${n}. You may need to retry or handle this error appropriately.
|
|
207
|
+
</system-reminder>`,returnDisplay:`Error writing todos: ${n}`}}}};function ee(o){try{let t=JSON.parse(f.readFileSync(y(o),"utf-8"));return Array.isArray(t.todos)?t.todos:[]}catch(t){let e=t;if(!(e instanceof Error)||e.code!=="ENOENT")throw t;return[]}}async function te(){try{let o=u.join(T.getRuntimeBaseDir(),L);return(await h.readdir(o)).filter(e=>e.endsWith(".json")).map(e=>e.replace(".json",""))}catch(o){let t=o;if(!(t instanceof Error)||t.code!=="ENOENT")throw o;return[]}}var F=class o extends S{constructor(e){super(o.Name,W.TODO_WRITE,H,"think",q.parametersJsonSchema);this.config=e}static Name=A.TODO_WRITE;validateToolParams(e){if(!Array.isArray(e.todos))return'Parameter "todos" must be an array.';for(let i of e.todos){if(!i.id||typeof i.id!="string"||i.id.trim()==="")return'Each todo must have a non-empty "id" string.';if(!i.content||typeof i.content!="string"||i.content.trim()==="")return'Each todo must have a non-empty "content" string.';if(!["pending","in_progress","completed"].includes(i.status))return'Each todo must have a valid "status" (pending, in_progress, completed).'}let r=e.todos.map(i=>i.id),l=new Set(r);return r.length!==l.size?"Todo IDs must be unique within the array.":null}createInvocation(e){let r=this.config.getSessionId(),l=y(r),i=f.existsSync(l)?"update":"create";return new w(this.config,e,i)}};export{ee as a,te as b,F as c};
|
|
208
208
|
/**
|
|
209
209
|
* @license
|
|
210
210
|
* Copyright 2025 Google LLC
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{a as f}from"./chunk-GT6MSEK4.js";import{b as g}from"./chunk-PFXCFIHY.js";import{H as d,P as m,ea as p}from"./chunk-WL27X35X.js";import{b as u}from"./chunk-GZPNIYVZ.js";u();import*as a from"node:fs/promises";import*as s from"node:path";var x=p("CRON_TASKS_FILE"),T="scheduled_tasks.json",L=`~/.matilda/tmp/<project-hash>/${T}`,E=15,w=2e3,b=3e3,P=0,h=new Map;function C(e){let t=h.get(e);return t||(t=new f,h.set(e,t)),t}function c(e){return s.join(m.getGlobalTempDir(),d(e),T)}async function k(e){let t=c(e),i;try{i=await a.readFile(t,"utf-8")}catch(o){if(o.code==="ENOENT")return[];throw o}let r;try{r=JSON.parse(i)}catch{throw new Error(`Malformed JSON in ${t} \u2014 fix or delete the file; refusing to treat it as an empty schedule.`)}if(!Array.isArray(r))throw new Error(`Expected a JSON array in ${t} \u2014 fix or delete the file; refusing to treat it as an empty schedule.`);let n=r.filter(A);return n.length!==r.length&&x.warn(`Dropped ${r.length-n.length} invalid task entr${r.length-n.length===1?"y":"ies"} from ${t}; a later write will persist without ${r.length-n.length===1?"it":"them"}.`),n}async function D(e,t){let i=c(e);await a.mkdir(s.dirname(i),{recursive:!0}),await g(i,t,{noFollow:!0})}async function _(e){let t=`${e}.lock`;await a.mkdir(s.dirname(t),{recursive:!0});let i=Date.now()+b;for(;;){if(Date.now()>i)throw new Error(`Timed out waiting for scheduled-tasks lock (${t})`);try{return await a.writeFile(t,String(process.pid),{flag:"wx"}),async()=>{await a.unlink(t).catch(()=>{})}}catch(r){if(r.code!=="EEXIST")throw r}try{let r=await a.stat(t);if(Date.now()-r.mtimeMs>w){let n=`${t}.stale.${process.pid}.${P++}`;try{await a.rename(t,n)}catch{continue}let o=await a.stat(n).catch(()=>null);o&&Date.now()-o.mtimeMs<=w&&await a.link(n,t).catch(()=>{}),await a.unlink(n).catch(()=>{});continue}}catch{continue}await new Promise(r=>setTimeout(r,E))}}async function y(e,t){let i=c(e);return C(i).runExclusive(async()=>{let r=await _(i);try{let n=await k(e),o=t(n);o!==n&&await D(e,o)}finally{await r()}})}async function F(e,t){await y(e,i=>[...i,t])}async function J(e,t){let i=new Set(t);if(!(await k(e)).some(o=>i.has(o.id)))return 0;let n=0;return await y(e,o=>{let l=o.filter(S=>!i.has(S.id));return n=o.length-l.length,n===0?o:l}),n}function A(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id=="string"&&typeof t.cron=="string"&&typeof t.prompt=="string"&&typeof t.recurring=="boolean"&&typeof t.createdAt=="number"&&(t.lastFiredAt===null||typeof t.lastFiredAt=="number")}export{L as a,c as b,k as c,y as d,F as e,J as f};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{l as i}from"./chunk-
|
|
3
|
+
import{l as i}from"./chunk-HJK3NKAR.js";import{b as o}from"./chunk-GZPNIYVZ.js";o();import l from"node:path";function d(t,n){if(t.getApprovalMode()!=="bogan")return null;let r=l.resolve(n),s=t.getProjectRoot?.()??t.getTargetDir();if(i(r,s))return null;let e=t.getWorkspaceContext?.();if(!e||(typeof e.isPathWithinWorkspaceFresh=="function"?e.isPathWithinWorkspaceFresh(r):e.isPathWithinWorkspace(r)))return null;let a=e.getDirectories?.()??[t.getTargetDir()],p=t.getChannel?.()==="desktop"?"Approve the folder from Matilda Desktop, then retry the write.":"Use --include-directories to add extra roots, or a non-BOGAN approval mode for intentional external writes.";return`Refusing out-of-workspace write in BOGAN mode: ${r}. Workspace root(s): ${a.join(", ")}. This blocks path typos (e.g. writing under $HOME when the project is elsewhere). `+p}export{d as a};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2025 Matilda Team
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{d as T}from"./chunk-OWEBLTAN.js";import{b as W}from"./chunk-7ZODGQO6.js";import{a as P}from"./chunk-GT6MSEK4.js";import{b as g}from"./chunk-PFXCFIHY.js";import{c as l,ea as _}from"./chunk-WL27X35X.js";import{b as x}from"./chunk-GZPNIYVZ.js";import{f as U}from"./chunk-OWGSC52X.js";x();var F=U(W(),1);import*as d from"node:fs/promises";import{constants as B}from"node:fs";import*as b from"node:path";var f=_("AGENTS_TEAM_TASKS"),$=32768,v=16;function M(r){if(!r)return;let e=Buffer.byteLength(JSON.stringify(r),"utf-8");if(e>$)throw new Error(`Task metadata is too large (${e} bytes; max ${$}). Trim the payload or store the bulk content elsewhere.`)}var X={retries:{retries:30,minTimeout:5,maxTimeout:100,factor:2,randomize:!0},stale:5e3,onCompromised:r=>{f.warn("task lock compromised:",r?.message??r)}},A=new Map;function K(r){let e=A.get(r);return e||(e=new P,A.set(r,e)),e}async function h(r,e,t){return K(r).runExclusive(async()=>{let i;try{i=await F.default.lock(r,X)}catch(o){if(l(o)&&o.code==="ENOENT")return t();throw o}try{return await e()}finally{await i()}})}var q="__reciprocal__",j=new Map;function z(r){let e=j.get(r);return e||(e=new P,j.set(r,e)),e}function Y(r){if(!/^[1-9]\d*$/.test(r))throw new Error(`Invalid task ID "${r}". Task IDs must be positive integers.`)}function m(r,e){return Y(e),b.join(T(r),`${e}.json`)}var O=new Set;function ae(r){return O.add(r),()=>{O.delete(r)}}function k(r){for(let e of O)try{e(r)}catch(t){f.warn(`task update listener failed: ${t}`)}}async function ie(r,e){M(e.metadata);let t=T(r);await d.mkdir(t,{recursive:!0});let i=15;for(let o=0;o<i;o++){let c=await Z(t),s={id:c,subject:e.subject,description:e.description,activeForm:e.activeForm,owner:e.owner,status:"pending",blocks:[],blockedBy:[],metadata:e.metadata},n=b.join(t,`${c}.json`);try{await(await d.open(n,B.O_WRONLY|B.O_CREAT|B.O_EXCL)).close()}catch(a){if(l(a)&&a.code==="EEXIST")continue;throw a}try{await g(n,s)}catch(a){throw await d.unlink(n).catch(()=>{}),a}return k(r),s}throw new Error(`Failed to create task after ${i} attempts (ID contention).`)}async function oe(r,e){let t=m(r,e);try{let i=await d.readFile(t,"utf-8");return JSON.parse(i)}catch(i){if(l(i)&&i.code==="ENOENT")return;throw i}}var p=class extends Error{constructor(t,i,o){super(`Task #${t} is owned by "${o}". Only the leader or the owner can change status / owner / subject / description / blocks.`);this.taskId=t;this.callerName=i;this.actualOwner=o;this.name="TaskOwnershipError"}};async function ce(r,e,t,i){let o=m(r,e);return h(o,async()=>{let c;try{c=await d.readFile(o,"utf-8")}catch(n){if(l(n)&&n.code==="ENOENT")return;throw n}let s=JSON.parse(c);if(i?.callerName!==void 0&&i.callerName!==q&&(t.status!==void 0||t.owner!==void 0||t.subject!==void 0||t.description!==void 0||(t.addBlocks?.length??0)>0||(t.addBlockedBy?.length??0)>0)&&s.owner&&s.owner!==i.callerName)throw new p(e,i.callerName,s.owner);if(t.addBlocks?.length){let n=new Set(s.blocks);for(let a of t.addBlocks)n.add(a);s.blocks=Array.from(n)}if(t.addBlockedBy?.length){let n=new Set(s.blockedBy);for(let a of t.addBlockedBy)n.add(a);s.blockedBy=Array.from(n)}if(t.status!==void 0&&(s.status=t.status,t.status==="completed"&&s.blocks.length>0&&await Q(r,e,s.blocks)),t.owner!==void 0&&(s.owner=t.owner?t.owner:void 0),t.subject!==void 0&&(s.subject=t.subject),t.description!==void 0&&(s.description=t.description),t.activeForm!==void 0&&(s.activeForm=t.activeForm??void 0),t.metadata!==void 0){s.metadata=s.metadata??{};for(let[n,a]of Object.entries(t.metadata))n==="__proto__"||n==="constructor"||n==="prototype"||(a===null?delete s.metadata[n]:s.metadata[n]=a);Object.keys(s.metadata).length===0&&(s.metadata=void 0),M(s.metadata)}return await g(o,s),k(r),s},()=>{})}async function de(r,e,t){let i=m(r,e),o=await h(i,async()=>{let s;try{let a=await d.readFile(i,"utf-8");s=JSON.parse(a)}catch(a){if(l(a)&&a.code==="ENOENT")return null;throw a}if(t?.callerName!==void 0&&s.owner&&s.owner!==t.callerName)throw new p(e,t.callerName,s.owner);let n=new Set([...s.blocks,...s.blockedBy]);n.delete(e);try{await d.unlink(i)}catch(a){if(l(a)&&a.code==="ENOENT")return null;throw a}return n},()=>null);if(o===null)return!1;let c=await Promise.allSettled(Array.from(o).map(s=>G(r,s,e)));for(let s of c)s.status==="rejected"&&f.warn(`deleteTask(${e}): edge cleanup failed: ${s.reason}`);return k(r),!0}async function G(r,e,t){let i=m(r,e);await h(i,async()=>{try{let o=await d.readFile(i,"utf-8"),c=JSON.parse(o),s=c.blocks.length,n=c.blockedBy.length;if(c.blocks=c.blocks.filter(a=>a!==t),c.blockedBy=c.blockedBy.filter(a=>a!==t),c.blocks.length===s&&c.blockedBy.length===n)return;await g(i,c)}catch(o){if(l(o)&&o.code==="ENOENT")return;throw o}},()=>{})}async function R(r,e){let t=T(r),i;try{i=await d.readdir(t)}catch(n){if(l(n)&&n.code==="ENOENT")return[];let a=n instanceof Error?n.message:String(n);throw f.warn(`Failed to list tasks dir ${t}: ${a}`),n instanceof Error?n:new Error(a)}let o=i.filter(n=>n.endsWith(".json")),c=[];for(let n=0;n<o.length;n+=v){let a=o.slice(n,n+v),w=await Promise.all(a.map(async C=>{let y=b.join(t,C),S;try{S=await d.readFile(y,"utf-8")}catch(u){if(l(u)&&u.code==="ENOENT")return;let E=u instanceof Error?u.message:String(u);f.warn(`Failed to read task file ${y}: ${E}`);return}if(S.trim()!=="")try{return JSON.parse(S)}catch(u){let E=u instanceof Error?u.message:String(u);f.warn(`Quarantining corrupt task file ${y}: ${E}`);let D=`${y}.corrupt-${Date.now()}`;try{await d.rename(y,D)}catch(N){let J=N instanceof Error?N.message:String(N);f.warn(`Failed to quarantine ${y}: ${J}`)}return}}));c.push(...w)}let s=c.filter(n=>n!==void 0);return s.sort((n,a)=>Number(n.id)-Number(a.id)),e?s.filter(n=>!(e.status!==void 0&&n.status!==e.status||e.owner!==void 0&&n.owner!==e.owner||e.blockedBy!==void 0&&!n.blockedBy.includes(e.blockedBy))):s}async function le(r){let e=T(r);await d.rm(e,{recursive:!0,force:!0}),k(r)}async function Q(r,e,t){let i=await Promise.allSettled(t.map(async o=>{let c=m(r,o);await h(c,async()=>{let s;try{s=await d.readFile(c,"utf-8")}catch(w){if(l(w)&&w.code==="ENOENT")return;throw w}let n=JSON.parse(s),a=n.blockedBy.length;n.blockedBy=n.blockedBy.filter(w=>w!==e),n.blockedBy.length!==a&&await g(c,n)},()=>{})}));for(let o of i)o.status==="rejected"&&f.warn(`unblockDependents(${e}): ${o.reason}`);k(r)}async function ue(r,e,t,i){return i?.checkAgentBusy?z(t).runExclusive(()=>L(r,e,t,i,!0)):L(r,e,t,i,!1)}async function L(r,e,t,i,o){if(o&&await V(r,t))return;let c=m(r,e);return h(c,async()=>{let s;try{s=await d.readFile(c,"utf-8")}catch(a){if(l(a)&&a.code==="ENOENT")return;throw a}let n=JSON.parse(s);if(n.status==="pending"&&!n.owner)return n.owner=i?.ownerName??t,n.status="in_progress",await g(c,n),k(r),n},()=>{})}async function V(r,e){let t=await R(r,{status:"in_progress"}),i=e.split("@")[0];return t.some(o=>o.owner===e||o.owner===i)}async function H(r,e,t){let i=m(r,e);return h(i,async()=>{let o;try{o=await d.readFile(i,"utf-8")}catch(s){if(l(s)&&s.code==="ENOENT")return!1;throw s}let c=JSON.parse(o);return c.status!=="in_progress"||c.owner!==t?!1:(c.owner=void 0,c.status="pending",await g(i,c),!0)},()=>!1)}async function fe(r,e){let t=e.split("@")[0],o=(await R(r,{status:"in_progress"})).filter(a=>a.owner===e||a.owner===t),c=await Promise.allSettled(o.map(a=>H(r,a.id,a.owner))),s=c.filter(a=>a.status==="rejected");s.length>0&&f.warn(`unassignTeammateTasks: ${s.length}/${o.length} task(s) failed to unassign for ${e}`);let n=c.filter(a=>a.status==="fulfilled"&&a.value===!0).length;return n>0&&k(r),n}async function Z(r){let e;try{e=await d.readdir(r)}catch{return"1"}let t=0;for(let i of e){if(!i.endsWith(".json"))continue;let o=parseInt(i.replace(".json",""),10);!isNaN(o)&&o>t&&(t=o)}return String(t+1)}export{q as a,Y as b,ae as c,ie as d,oe as e,p as f,ce as g,de as h,R as i,le as j,ue as k,fe as l};
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2025 Matilda
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{A as m,I as g,L as h,P as l,W as M}from"./chunk-WL27X35X.js";import{b as p}from"./chunk-GZPNIYVZ.js";p();import*as s from"node:fs";import*as t from"node:path";var A="memory",y="MEMORY.md",x="meta.json",R="extract-cursor.json",O="consolidation.lock",T="memories";function D(r){let e=t.resolve(r);for(;;){let n=t.join(e,".git");if(s.existsSync(n))return e;let o=t.dirname(e);if(o===e)return null;e=o}}function j(r){let e=D(r);if(!e)return null;try{let n=s.readFileSync(t.join(e,".git"),"utf-8").trim();if(!n.startsWith("gitdir:"))return e;let o=t.resolve(e,n.slice(7).trim()),i=t.resolve(o,s.readFileSync(t.join(o,"commondir"),"utf-8").trim());return t.resolve(t.dirname(o))!==t.join(i,"worktrees")||s.realpathSync(s.readFileSync(t.join(o,"gitdir"),"utf-8").trim())!==t.join(s.realpathSync(e),".git")?e:t.basename(i)!==".git"?i.normalize("NFC"):t.dirname(i).normalize("NFC")}catch{return e}}function E(){return process.env.MATILDA_CODE_MEMORY_BASE_DIR?h(void 0,process.env.MATILDA_CODE_MEMORY_BASE_DIR):l.getRuntimeBaseDir()}var f=new Map;function c(r){let e=process.env.MATILDA_CODE_MEMORY_LOCAL==="1",n=e?"":E(),o=`${e?"local":n}\0${r}`,i=f.get(o);if(i!==void 0)return i;let a;if(e)a=t.join(r,m,A);else{let d=j(r)??t.resolve(r);a=t.join(n,"projects",g(d),A)}return f.set(o,a),a}function u(r){return t.dirname(c(r))}function C(r,e){let n=t.normalize(r),o=t.normalize(c(e)),i=t.relative(o,n);return i===""||!i.startsWith("..")&&!t.isAbsolute(i)}function N(r){return t.join(c(r),y)}function U(r){return t.join(u(r),x)}function F(r){return t.join(u(r),R)}function Y(r){return t.join(u(r),O)}function _(){return t.join(E(),T)}function k(){return t.join(_(),y)}function I(r){let e=t.normalize(r),n=t.normalize(_()),o=t.relative(n,e);return o===""||!o.startsWith("..")&&!t.isAbsolute(o)}function S(r,e){return C(r,e)||I(r)}var z="A secret in this text was stored as ***REDACTED***, as a memory should keep none.";function b(r,e,n){return S(t.resolve(r),e)?M(n):n}export{y as a,E as b,c,u as d,C as e,N as f,U as g,F as h,Y as i,_ as j,k,S as l,z as m,b as n};
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2025 Google LLC
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as r}from"./chunk-V6UPUMP3.js";import{
|
|
3
|
+
import{a as r}from"./chunk-V6UPUMP3.js";import{ea as g}from"./chunk-WL27X35X.js";import{b as f}from"./chunk-GZPNIYVZ.js";f();function C(n,o){return`Base directory for this skill: ${n}
|
|
4
4
|
Important: ALWAYS resolve absolute paths from this base directory when working with skills.
|
|
5
5
|
|
|
6
6
|
${o}
|
|
7
|
-
`}async function
|
|
7
|
+
`}async function h(n,o){let i=await n.listSkills(),l=o.getDisabledSkillNames(),t=e=>l.has(e.toLowerCase()),s=i.filter(e=>!e.disableModelInvocation&&n.isSkillActive(e)&&!t(e.name)),m=new Set(i.filter(e=>!e.disableModelInvocation&&e.paths&&e.paths.length>0&&!n.isSkillActive(e)&&!t(e.name)).map(e=>e.name)),a=o.getModelInvocableCommandsProvider(),c=a?a():[],k=new Set(i.filter(e=>!e.disableModelInvocation&&!t(e.name)).map(e=>e.name)),d=c.filter(e=>!k.has(e.name)),S=[...s.map(e=>({name:e.name,description:e.description,whenToUse:e.whenToUse,level:e.level})),...d.map(e=>({name:e.name,description:e.description}))];return{availableSkills:s,pendingConditionalSkillNames:m,modelInvocableCommands:d,entries:S}}function u(n,o){let i=n.level!==void 0?0:1,l=o.level!==void 0?0:1;return i!==l?i-l:n.name.localeCompare(o.name)}function H(n){return[...n].sort(u).map(o=>{if(o.level!==void 0){let i=`${r(o.description)}${o.whenToUse?` \u2014 ${r(o.whenToUse)}`:""} (${o.level})`;return`<skill>
|
|
8
8
|
<name>
|
|
9
9
|
${r(o.name)}
|
|
10
10
|
</name>
|
|
@@ -22,7 +22,7 @@ ${r(o.name)}
|
|
|
22
22
|
${r(o.description)}
|
|
23
23
|
</description>
|
|
24
24
|
</skill>`}).join(`
|
|
25
|
-
`)}function y(n,o){if(!(!n||!o?.length))for(let i of o)n.addSessionAllowRule(i)}f();var p=g("SKILL_HOOKS");function M(n,o,i){if(!i.hooks)return p.debug(`Skill '${i.name}' has no hooks to register`),0;let l=i.hooks,t=0;for(let s of Object.keys(l)){let m=l[s];if(m)for(let a of m){let c=a.matcher||"";for(let k of a.hooks){if(k.type==="function"){p.debug("Skipping function hook from skill (not supported in frontmatter)");continue}let d=v(k,i.skillRoot);n.addSessionHook(o,s,c,d,{skillRoot:i.skillRoot}),t++,p.debug(`Registered hook for ${s}
|
|
25
|
+
`)}function y(n,o){if(!(!n||!o?.length))for(let i of o)n.addSessionAllowRule(i)}f();var p=g("SKILL_HOOKS");function M(n,o,i){if(!i.hooks)return p.debug(`Skill '${i.name}' has no hooks to register`),0;let l=i.hooks,t=0;for(let s of Object.keys(l)){let m=l[s];if(m)for(let a of m){let c=a.matcher||"";for(let k of a.hooks){if(k.type==="function"){p.debug("Skipping function hook from skill (not supported in frontmatter)");continue}let d=v(k,i.skillRoot);n.addSessionHook(o,s,c,d,{skillRoot:i.skillRoot}),t++,p.debug(`Registered hook for ${s} from skill '${i.name}', matcher:`,c)}}}return t>0&&p.info(`Registered ${t} hooks from skill '${i.name}'`),t}function v(n,o){return n.type==="command"&&o?{...n,env:{...n.env,MATILDA_SKILL_ROOT:o}}:n}export{C as a,h as b,H as c,y as d,M as e};
|
|
26
26
|
/**
|
|
27
27
|
* @license
|
|
28
28
|
* Copyright 2025 Matilda
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{j as i,s as c}from"./chunk-FPGKJJJY.js";import{d as l}from"./chunk-
|
|
3
|
+
import{j as i,s as c}from"./chunk-FPGKJJJY.js";import{d as l}from"./chunk-P24OL22U.js";import{b as g}from"./chunk-GZPNIYVZ.js";g();import{readFile as y}from"node:fs/promises";function S(t){return t?`side-query:${t}`:"side-query"}function T(t,e){return e??t.getFastModel?.()??t.getModel()??c}function x(t){let e=t?.thinkingConfig;return{...t??{},thinkingConfig:e?{includeThoughts:!1,...e}:{includeThoughts:!1}}}async function h(t){let e=t.getOutputLanguageFilePath?.();if(e)try{let n=(await y(e,"utf8")).trim();return n?["Follow the user-visible output language preference below for this side query.",n].join(`
|
|
4
4
|
|
|
5
5
|
`):void 0}catch{return}}function C(t,e){return e?t===void 0?e:typeof t=="string"?`${t}
|
|
6
6
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{d as b}from"./chunk-XPVKH5TC.js";import{ea as P}from"./chunk-WL27X35X.js";import{b as S}from"./chunk-GZPNIYVZ.js";S();var H=P("TRUSTED_HOOKS");var C=(n=>(n.PreToolUse="PreToolUse",n.PostToolUse="PostToolUse",n.PostToolUseFailure="PostToolUseFailure",n.PostToolBatch="PostToolBatch",n.Notification="Notification",n.UserPromptSubmit="UserPromptSubmit",n.UserPromptExpansion="UserPromptExpansion",n.SessionStart="SessionStart",n.Stop="Stop",n.SubagentStart="SubagentStart",n.SubagentStop="SubagentStop",n.PreCompact="PreCompact",n.PostCompact="PostCompact",n.SessionEnd="SessionEnd",n.PermissionRequest="PermissionRequest",n.PermissionDenied="PermissionDenied",n.StopFailure="StopFailure",n.TodoCreated="TodoCreated",n.TodoCompleted="TodoCompleted",n.InstructionsLoaded="InstructionsLoaded",n))(C||{});var N=["enabled","disabled","notifications"];function M(t){let e=t.name??"";switch(t.type){case"command":return e?`${e}:${t.command}`:t.command;case"http":return e?`${e}:${t.url}`:t.url;case"function":return e?`${e}:${t.id??"function"}`:t.id??"function";case"prompt":return e?`${e}:${t.prompt}`:t.prompt;default:return e||"unknown"}}function y(t){switch(t.type){case"command":return typeof t.command=="string"&&t.command!=="";case"http":return typeof t.url=="string"&&t.url!=="";case"prompt":return typeof t.prompt=="string"&&t.prompt!=="";case"function":return typeof t.callback=="function";default:return!1}}function B(t){if(typeof t!="object"||t===null||!y(t))return;if(t.name===void 0||typeof t.name=="string")return t;let e={...t};return delete e.name,e}var I=["ask","block","deny","approve","allow"],T=1e4;function R(t){return b(t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),0,T).replace(/&(?:a(?:mp?)?|lt?|gt?)?$/,"")}var c=t=>typeof t=="string",f=t=>typeof t=="boolean";function d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var w=[["decision",t=>I.includes(t)],["continue",f],["hookSpecificOutput",d],["reason",c],["stopReason",c],["systemMessage",c],["suppressOutput",f],["terminalSequence",c]],D=[["message",c],["updatedInput",d],["updatedPermissions",Array.isArray],["interrupt",f]];function E(t){if(!d(t))return!1;let{behavior:e,updatedInput:i}=t;return e==="deny"?!0:e==="allow"&&(i==null||d(i))}function v(t){return[["permissionDecision",e=>t==="PreToolUse"&&(e==="allow"||e==="deny"||e==="ask")],["decision",e=>t==="PermissionRequest"&&E(e)],["permissionDecisionReason",c],["additionalContext",c],["tool_input",d]]}function m(t,e,i,s){let o={...t};for(let[r,p]of e){let a=o[r];a===void 0||a!==null&&p(a)||(a!==null&&s.push(`${i}${r}`),delete o[r])}return o}var q=t=>d(t.hookSpecificOutput);function L(t,e){switch(t){case"PreToolUse":return new l(e);case"PostToolUse":return new k(e);case"PostToolUseFailure":return new x(e);case"UserPromptExpansion":return new h(e);case"PostToolBatch":return new O(e);case"Stop":case"SubagentStop":return new _(e);case"PermissionRequest":return new g(e);default:return new u(e)}}var u=class{continue;stopReason;suppressOutput;systemMessage;terminalSequence;decision;reason;hookSpecificOutput;constructor(e={}){this.continue=e.continue,this.stopReason=e.stopReason,this.suppressOutput=e.suppressOutput,this.systemMessage=e.systemMessage,this.terminalSequence=e.terminalSequence,this.decision=e.decision,this.reason=e.reason,this.hookSpecificOutput=e.hookSpecificOutput}isBlockingDecision(){return this.decision==="block"||this.decision==="deny"}shouldStopExecution(){return this.continue===!1}getEffectiveReason(){return this.stopReason||this.reason||"No reason provided"}getRawAdditionalContext(){if(this.hookSpecificOutput&&"additionalContext"in this.hookSpecificOutput){let e=this.hookSpecificOutput.additionalContext;return typeof e=="string"?e:void 0}}getAdditionalContext(){let e=this.getRawAdditionalContext();if(e!==void 0)return e.replace(/</g,"<").replace(/>/g,">")}getBlockingError(){return this.isBlockingDecision()?{blocked:!0,reason:this.getEffectiveReason()}:{blocked:!1,reason:""}}shouldClearContext(){return!1}},l=class extends u{getPermissionDecision(){if(this.hookSpecificOutput&&"permissionDecision"in this.hookSpecificOutput){let e=this.hookSpecificOutput.permissionDecision;if(e==="allow"||e==="deny"||e==="ask")return e}if(this.decision==="allow"||this.decision==="approve")return"allow";if(this.decision==="deny"||this.decision==="block")return"deny";if(this.decision==="ask")return"ask"}getPermissionDecisionReason(){if(this.hookSpecificOutput&&"permissionDecisionReason"in this.hookSpecificOutput){let e=this.hookSpecificOutput.permissionDecisionReason;if(typeof e=="string")return e}return this.reason}isDenied(){return this.getPermissionDecision()==="deny"}isAsk(){return this.getPermissionDecision()==="ask"}isAllowed(){return this.getPermissionDecision()==="allow"}},k=class extends u{decision;reason;constructor(e={}){super(e),this.decision=e.decision??"allow",this.reason=e.reason??"No reason provided",e.decision===void 0&&H.debug('PostToolUseHookOutput: No explicit decision set, defaulting to "allow"'),e.reason===void 0&&H.debug('PostToolUseHookOutput: No explicit reason set, defaulting to "No reason provided"')}},x=class extends u{getAdditionalContext(){return super.getAdditionalContext()}},h=class extends u{getAdditionalContext(){let e=this.getRawAdditionalContext();if(e!==void 0)return R(e)}},O=class extends u{shouldStopExecution(){return super.shouldStopExecution()||this.isBlockingDecision()}},_=class extends u{stopReason;constructor(e={}){super(e),this.stopReason=e.stopReason}getStopReason(){if(this.stopReason)return`Stop hook feedback:
|
|
4
|
+
${this.stopReason}`}},g=class extends u{getPermissionDecision(){if(this.hookSpecificOutput&&"decision"in this.hookSpecificOutput){let e=this.hookSpecificOutput.decision;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let{behavior:i}=e;if(i==="allow"||i==="deny")return e}}return this.isBlockingDecision()?{behavior:"deny",message:this.reason}:void 0}isPermissionDenied(){return this.getPermissionDecision()?.behavior==="deny"}getDenyMessage(){return this.getPermissionDecision()?.message}shouldInterrupt(){return this.getPermissionDecision()?.interrupt===!0}getUpdatedToolInput(){return this.getPermissionDecision()?.updatedInput}getUpdatedPermissions(){return this.getPermissionDecision()?.updatedPermissions}};function $(t,e,i){let s=U(t,e??{}).output,o=s.reason||i,r={...s,decision:"deny",reason:o};if(t==="PreToolUse"){let p=new l(s);r.hookSpecificOutput={...s.hookSpecificOutput,permissionDecision:"deny",permissionDecisionReason:p.isDenied()&&p.getPermissionDecisionReason()||o}}if(t==="PermissionRequest"){let p=new g(s).getPermissionDecision(),a=p?.behavior==="deny"?p:void 0;r.hookSpecificOutput={...s.hookSpecificOutput,decision:{...a,behavior:"deny",message:a?.message||o}}}return r}function U(t,e){let i=[],s=m(e,w,"",i);if(s.hookSpecificOutput){let o=m(s.hookSpecificOutput,v(t),"hookSpecificOutput.",i);d(o.decision)&&(o.decision=m(o.decision,D,"hookSpecificOutput.decision.",i)),s.hookSpecificOutput=o}return{output:s,...i.length>0&&{unusableField:i[0]}}}function j(t,e){let i=new Map(t.map(o=>[o.id,o])),s={created:[],completed:[]};for(let o of e){let r=i.get(o.id);r?r.status!=="completed"&&o.status==="completed"&&s.completed.push(o):s.created.push(o)}return s}export{C as a,N as b,M as c,B as d,R as e,q as f,L as g,u as h,l as i,k as j,x as k,h as l,O as m,_ as n,g as o,$ as p,U as q,j as r};
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Matilda Team
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{a as c}from"./chunk-V6UPUMP3.js";import{m as u}from"./chunk-P24OL22U.js";import{b as m}from"./chunk-GZPNIYVZ.js";m();import{AsyncLocalStorage as k}from"node:async_hooks";var a=new k,r=new WeakMap,p={turns:"max_turn_requests",session_turns:"max_turn_requests",loop_detected:"max_turn_requests",continuations:"max_turn_requests",session_tokens:"max_tokens"},h=class{jobs=new Map;joinsJobs;wake;closed=!1;keepsFinished=!1;revision=0;task;lastResponse;stop;ended;finished;constructor(e={}){this.joinsJobs=e.joinsJobs??!0}begin(e,t,s=e){this.task||(this.task={startUuid:e,rootUuid:s,recorder:t},this.ended&&this.finish(this.ended).catch(()=>{}))}get taskStartUuid(){return this.task?.startUuid}get taskRef(){return this.task?{startUuid:this.task.startUuid,rootUuid:this.task.rootUuid}:void 0}noteResponse(e){this.lastResponse=e}noteStop(e){this.stop=e}finish(e){let t=this.task;return t?(this.finished??=this.recordOutcome(t,e),this.finished):(this.ended??=e,Promise.resolve(void 0))}async recordOutcome(e,t){let s=this.stop&&(t.outcome==="completed"||t.outcome==="error")?p[this.stop]:t.outcome,i=s==="completed"&&this.lastResponse?.finalAnswer?this.lastResponse:void 0,n=t.limitKind??(s==="max_tokens"||s==="max_turn_requests"?this.stop:void 0);return await e.recorder.recordTaskOutcome({taskStartUuid:e.startUuid,outcome:s,...n?{limitKind:n}:{},...s==="completed"?{finalAnswerUuid:i?i.recordId??i.id:null}:{}}),{outcome:s,...i&&{finalAnswerId:i.id}}}static get current(){return a.getStore()}run(e){return a.run(this,e)}static detached(e){return a.run(void 0,e)}static register(e,t,s){let i=a.getStore();e.originTask??=s?.originTask??i?.taskRef;let n=s?.status==="running"?r.get(s):void 0,o=n??(i?.joinsJobs?i:void 0);if(o){if(n&&s&&n.consume(s),e.completion==="detached"||!n&&e.status!=="running"){o.changed();return}if(r.set(e,o),o.closed){t();return}o.jobs.set(e,t),o.changed()}}static changed(e){e&&r.get(e)?.changed()}static abandoned(e){return r.get(e)?.closed===!0}static detach(e){let t=r.get(e);return!t||t.closed||!t.owns(e)||e.status!=="running"?!1:(e.completion="detached",t.consume(e),t.changed(),!0)}owns(e){return this.jobs.has(e)}consume(e){r.delete(e),this.jobs.delete(e)}get pending(){return this.jobs.size>0}get position(){return this.revision}get paused(){return[...this.jobs.keys()].some(e=>e.status==="paused")}get running(){return[...this.jobs.keys()].filter(e=>e.status==="running")}changed(){this.revision++,this.wake?.()}async wait(e,t,s){this.closed||t.aborted||e!==this.revision||await new Promise(i=>{let n,o=()=>{clearTimeout(n),t.removeEventListener("abort",o),this.wake=void 0,i()};this.wake=o,t.addEventListener("abort",o,{once:!0}),s!==void 0&&(n=setTimeout(o,s))})}keepFinishedJobs(){this.keepsFinished=!0}close(){this.closed=!0;for(let[e,t]of this.jobs)e.status==="running"?t():this.keepsFinished&&e.status!=="paused"&&this.consume(e);this.changed()}};function g(d,e){let t=s=>{let i=s.description.replace(/[\p{Cc}\s]+/gu," ").trim(),n=Math.max(1,Math.round((e-s.startTime)/6e4));return`background ${s.kind} "${i.length>80?`${i.slice(0,77)}...`:i}" (running ${n} min)`};return{displayText:`Still waiting on ${d.map(t).join(", ")}.`,modelText:d.map(s=>["<task-notification>",`<task-id>${c(s.id)}</task-id>`,`<kind>${s.kind}</kind>`,"<status>running</status>",`<summary>${c(`The ${t(s)} is still running, and this request cannot finish until it does. If the request needs its result, keep waiting. If it should keep running after the request, such as a server or watcher, call ${u.TASK_DETACH}. If it is no longer needed, call ${u.TASK_STOP}.`)}</summary>`,"</task-notification>"].join(`
|
|
4
|
+
`)).join(`
|
|
5
|
+
`)}}export{h as a,g as b};
|
|
6
|
+
/**
|
|
7
|
+
* @license
|
|
8
|
+
* Copyright 2026 Matilda
|
|
9
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
*/
|