@maincode-ai/matilda-code 0.22.2 → 0.22.3-nightly.20261110.cb1234773

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 (123) hide show
  1. package/README.md +1 -1
  2. package/chunks/agent-7LLN72GU.js +3 -0
  3. package/chunks/agent-headless-APBRBFN3.js +3 -0
  4. package/chunks/{askUserQuestion-DHYKAZWH.js → askUserQuestion-76LPP5ST.js} +1 -1
  5. package/chunks/{chunk-MZ73LBEY.js → chunk-3EQIOCSJ.js} +1 -1
  6. package/chunks/chunk-4SDFTVQW.js +62 -0
  7. package/chunks/chunk-B7BF33U4.js +31 -0
  8. package/chunks/chunk-BEP4F3GO.js +2556 -0
  9. package/chunks/chunk-DERMLVT6.js +68 -0
  10. package/chunks/{chunk-OWEBLTAN.js → chunk-EEPSTT7K.js} +1 -1
  11. package/chunks/{chunk-OF7ORAN6.js → chunk-GDRS4OWI.js} +71 -67
  12. package/chunks/chunk-HK3QQSM7.js +18 -0
  13. package/chunks/{chunk-PFXCFIHY.js → chunk-J6NYCXUR.js} +1 -1
  14. package/chunks/chunk-JVQHQDDE.js +10 -0
  15. package/chunks/chunk-JZMGEGR6.js +12 -0
  16. package/chunks/{chunk-HJK3NKAR.js → chunk-M5ABGGE7.js} +1 -1
  17. package/chunks/chunk-N3AQRPV5.js +207 -0
  18. package/chunks/{chunk-DZKI2CAC.js → chunk-NO6BFSGG.js} +1 -1
  19. package/chunks/chunk-QKAKC34Q.js +8 -0
  20. package/chunks/{chunk-VWM3GUBH.js → chunk-QUITDDTB.js} +1 -1
  21. package/chunks/{chunk-ZUQRP3N6.js → chunk-R373GBK6.js} +1 -1
  22. package/chunks/{chunk-BS7Q7KA6.js → chunk-T6MRYRLI.js} +1 -1
  23. package/chunks/{chunk-REUZDMLM.js → chunk-TVNM3PQ7.js} +25 -25
  24. package/chunks/chunk-VBZS7ARJ.js +8 -0
  25. package/chunks/{chunk-FY3LL4OC.js → chunk-VNSW4TSX.js} +1 -1
  26. package/chunks/{chunk-HRD7WD3P.js → chunk-WAZCC4SE.js} +1 -1
  27. package/chunks/chunk-YUCEPXGG.js +12 -0
  28. package/chunks/{computer-use-5T3ZH24D.js → computer-use-RIDTFLYZ.js} +5 -17
  29. package/chunks/cron-create-T5QOBRRU.js +38 -0
  30. package/chunks/cron-delete-JXDOHSJF.js +3 -0
  31. package/chunks/cron-list-ZQ76A2FW.js +5 -0
  32. package/chunks/{edit-Y7YSDGLT.js → edit-LDTYXEVU.js} +1 -1
  33. package/chunks/en-SCZAH2YB.js +23 -0
  34. package/chunks/{enter-worktree-5ZGIYDUE.js → enter-worktree-FOFQXTPW.js} +1 -1
  35. package/chunks/enterPlanMode-2GHHILQY.js +18 -0
  36. package/chunks/{exit-worktree-3F5UY76U.js → exit-worktree-OK7AD7DC.js} +1 -1
  37. package/chunks/{exitPlanMode-HWK5EUVS.js → exitPlanMode-EANVOWTX.js} +30 -27
  38. package/chunks/{glob-H7DNNPJ4.js → glob-VZD7TOML.js} +1 -1
  39. package/chunks/{goal-tools-CJINJJ3Y.js → goal-tools-REBEAKVP.js} +1 -1
  40. package/chunks/{grep-5MCMGW6A.js → grep-JPEHWEM3.js} +1 -1
  41. package/chunks/ls-EP4ZVFNW.js +15 -0
  42. package/chunks/{lsp-Y46R5DO5.js → lsp-ULZTGWC4.js} +1 -1
  43. package/chunks/monitor-5WDGSYNZ.js +33 -0
  44. package/chunks/notebook-edit-W42S562V.js +17 -0
  45. package/chunks/openaiContentGenerator-QLDLWN4P.js +52 -0
  46. package/chunks/read-file-4M76GCWT.js +3 -0
  47. package/chunks/ripGrep-LF2E2V6N.js +3 -0
  48. package/chunks/scheduler-G4LEIBL4.js +8 -0
  49. package/chunks/send-message-TDOMZHNJ.js +8 -0
  50. package/chunks/shell-NUMSSUOV.js +3 -0
  51. package/chunks/{skill-5EMGSWRM.js → skill-IVESDHGG.js} +1 -1
  52. package/chunks/symbol-search-BLJAKP7C.js +19 -0
  53. package/chunks/syntheticOutput-5SCRQCXN.js +3 -0
  54. package/chunks/task-create-T4DIVG5X.js +3 -0
  55. package/chunks/task-detach-ES3IMGJ4.js +9 -0
  56. package/chunks/task-list-LYK4TOBS.js +9 -0
  57. package/chunks/{task-stop-OEAEE5R7.js → task-stop-FETAYKFU.js} +1 -1
  58. package/chunks/{task-update-4ANRU74G.js → task-update-I6PVT46S.js} +1 -1
  59. package/chunks/{team-create-G4N2NCFN.js → team-create-QQD472XN.js} +1 -1
  60. package/chunks/team-delete-P5F32IYK.js +8 -0
  61. package/chunks/todoWrite-ADAGHJLI.js +3 -0
  62. package/chunks/tool-call-W6PAJOF6.js +3 -0
  63. package/chunks/tool-search-LGTQYGTC.js +26 -0
  64. package/chunks/{web-fetch-VA2BZ4VR.js → web-fetch-5X37JMDH.js} +1 -1
  65. package/chunks/{web-search-OVFXJQDS.js → web-search-62YZTP3D.js} +1 -1
  66. package/chunks/{workflow-6VMVM5BG.js → workflow-OT4I6TMY.js} +2 -2
  67. package/chunks/write-file-GMIHG7AP.js +15 -0
  68. package/cli.js +472 -486
  69. package/locales/en.js +45 -113
  70. package/npm-postinstall.js +2 -2
  71. package/package.json +2 -2
  72. package/chunks/agent-IJOGVY62.js +0 -3
  73. package/chunks/agent-headless-FZGKJCVK.js +0 -3
  74. package/chunks/ca-HHQCT6S2.js +0 -23
  75. package/chunks/chunk-225CZWD7.js +0 -89
  76. package/chunks/chunk-3BT7ZYAM.js +0 -121
  77. package/chunks/chunk-3IG6LNQ3.js +0 -2581
  78. package/chunks/chunk-46FFWNRO.js +0 -12
  79. package/chunks/chunk-55YW6EUC.js +0 -8
  80. package/chunks/chunk-BQDEPKIG.js +0 -46
  81. package/chunks/chunk-E2KMVG7F.js +0 -8
  82. package/chunks/chunk-FPGKJJJY.js +0 -13
  83. package/chunks/chunk-L2FKLLEC.js +0 -12
  84. package/chunks/chunk-N2BE647T.js +0 -10
  85. package/chunks/chunk-P24OL22U.js +0 -31
  86. package/chunks/chunk-VWE5BSHV.js +0 -56
  87. package/chunks/chunk-WL27X35X.js +0 -44
  88. package/chunks/cron-create-5RRFCP36.js +0 -38
  89. package/chunks/cron-delete-7DTRWCSV.js +0 -3
  90. package/chunks/cron-list-HY6XJD7D.js +0 -5
  91. package/chunks/de-MJBGC47E.js +0 -23
  92. package/chunks/en-JITX7JKV.js +0 -23
  93. package/chunks/enterPlanMode-TWD4MXCW.js +0 -18
  94. package/chunks/fr-WT3R2JCR.js +0 -23
  95. package/chunks/ja-OEXP6Z3S.js +0 -23
  96. package/chunks/keychain-token-storage-BCODB632.js +0 -3
  97. package/chunks/ls-JORGCXES.js +0 -15
  98. package/chunks/mcp-client-54J5M542.js +0 -3
  99. package/chunks/monitor-BRJR6PR3.js +0 -32
  100. package/chunks/notebook-edit-UCCVQ4JP.js +0 -17
  101. package/chunks/openaiContentGenerator-H6JOS3XU.js +0 -52
  102. package/chunks/pt-PCVIFK7H.js +0 -23
  103. package/chunks/read-file-LVMBCRCT.js +0 -3
  104. package/chunks/ripGrep-F6AJSDKU.js +0 -3
  105. package/chunks/ru-CB5SIZZM.js +0 -23
  106. package/chunks/scheduler-XAOD6LG6.js +0 -8
  107. package/chunks/send-message-VY4DP63A.js +0 -8
  108. package/chunks/shell-QUDC6MJK.js +0 -3
  109. package/chunks/symbol-search-YNGX4Z5T.js +0 -19
  110. package/chunks/syntheticOutput-4JANVS4D.js +0 -3
  111. package/chunks/task-create-NRBVXURQ.js +0 -3
  112. package/chunks/task-detach-VHDDAO2K.js +0 -9
  113. package/chunks/task-list-T2IET466.js +0 -9
  114. package/chunks/team-delete-M4ORNSTT.js +0 -8
  115. package/chunks/todoWrite-RN2OP46T.js +0 -3
  116. package/chunks/tool-search-WEUURHFZ.js +0 -28
  117. package/chunks/write-file-5ZAZVXBB.js +0 -15
  118. package/locales/ca.js +0 -1895
  119. package/locales/de.js +0 -1935
  120. package/locales/fr.js +0 -1936
  121. package/locales/ja.js +0 -1698
  122. package/locales/pt.js +0 -1921
  123. package/locales/ru.js +0 -1911
@@ -0,0 +1,8 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{pa as n}from"./chunk-BEP4F3GO.js";import{l as i}from"./chunk-M5ABGGE7.js";import{b as r}from"./chunk-GZPNIYVZ.js";r();import c from"node:path";function g(t,s){if((n()??t.getApprovalMode())!=="bogan")return null;let o=c.resolve(s),a=t.getProjectRoot?.()??t.getTargetDir();if(i(o,a))return null;let e=t.getWorkspaceContext?.();if(!e||(typeof e.isPathWithinWorkspaceFresh=="function"?e.isPathWithinWorkspaceFresh(o):e.isPathWithinWorkspace(o)))return null;let p=e.getDirectories?.()??[t.getTargetDir()],l=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: ${o}. Workspace root(s): ${p.join(", ")}. This blocks path typos (e.g. writing under $HOME when the project is elsewhere). `+l}export{g as a};
4
+ /**
5
+ * @license
6
+ * Copyright 2025 Matilda Team
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
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};
3
+ import{d as T}from"./chunk-EEPSTT7K.js";import{b as W}from"./chunk-7ZODGQO6.js";import{a as P}from"./chunk-GT6MSEK4.js";import{b as g}from"./chunk-J6NYCXUR.js";import{c as l,ea as _}from"./chunk-4SDFTVQW.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
4
  /**
5
5
  * @license
6
6
  * Copyright 2025 Matilda
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
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}
3
+ import{a as r}from"./chunk-V6UPUMP3.js";import{ea as g}from"./chunk-4SDFTVQW.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}
@@ -0,0 +1,12 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{ka as n,la as u,ra as e,sa as a}from"./chunk-4SDFTVQW.js";import{b as o}from"./chunk-GZPNIYVZ.js";o();var d=`Submit your final answer as structured JSON that conforms to the provided schema.
4
+
5
+ CRITICAL: In structured-output mode, this is the ONLY way to deliver the final result. Call this tool to deliver the final result; the first call with valid arguments ends the session. Do not emit the final answer as plain text \u2014 it will be discarded. Use other tools (Read, Grep, etc.) to gather the information you need before calling this tool.
6
+
7
+ The arguments you pass MUST validate against the tool's parameter schema. If validation fails you will receive the error and may retry with corrected fields.`,i={__redacted:"structured_output payload (see stdout result)"};function p(t){return t.name===e.STRUCTURED_OUTPUT?{...i}:t.name===e.TOOL_CALL&&t.args?.name===e.STRUCTURED_OUTPUT?{name:e.STRUCTURED_OUTPUT,arguments:{...i}}:void 0}var l=class t extends u{static Name=e.STRUCTURED_OUTPUT;constructor(r){super(t.Name,a.STRUCTURED_OUTPUT,d,"think",r,!1,!1,!1,!0,"structured output json schema final result submit")}createInvocation(r){return new s(r)}},s=class extends n{getDescription(){return"Submit structured result"}async execute(r){return{llmContent:"Structured output accepted. The session will end now \u2014 do not send further content.",returnDisplay:"Structured output accepted."}}};export{i as a,p as b,l as c};
8
+ /**
9
+ * @license
10
+ * Copyright 2025 Matilda
11
+ * SPDX-License-Identifier: Apache-2.0
12
+ */
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Uc as J,b as H}from"./chunk-3IG6LNQ3.js";import"./chunk-FY3LL4OC.js";import{ka as K,ta as x,va as V}from"./chunk-BQDEPKIG.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DZKI2CAC.js";import"./chunk-ZUQRP3N6.js";import"./chunk-OWEBLTAN.js";import"./chunk-VWE5BSHV.js";import"./chunk-L2FKLLEC.js";import"./chunk-N2BE647T.js";import"./chunk-QXSBPCBA.js";import"./chunk-HRD7WD3P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-55YW6EUC.js";import"./chunk-REUZDMLM.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-3BT7ZYAM.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import{a as S}from"./chunk-OF7ORAN6.js";import"./chunk-HJK3NKAR.js";import"./chunk-46FFWNRO.js";import"./chunk-BS7Q7KA6.js";import"./chunk-MZ73LBEY.js";import"./chunk-PFXCFIHY.js";import"./chunk-XPVKH5TC.js";import{f as G,g as X}from"./chunk-P24OL22U.js";import"./chunk-WL27X35X.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as _e}from"node:os";d();import{join as I}from"node:path";import{homedir as R}from"node:os";var l="0.5.2",he="https://matilda.maincode.com/assets/computer-use",fe="https://github.com/trycua/cua/releases/download";function U(e=process.platform,t=process.arch,o=l){let r=o;if(e==="darwin"){let n=`cua-driver-rs-${r}-${t==="arm64"?"darwin-arm64":"darwin-x86_64"}`;return{asset:`${n}.tar.gz`,extractDir:n,binaryRelPath:"CuaDriver.app/Contents/MacOS/cua-driver",hasApp:!0}}if(e==="linux"){if(t!=="x64")throw new Error(`Computer Use: unsupported Linux arch '${t}' (only x64).`);return{asset:`cua-driver-rs-${r}-linux-x86_64-binary.tar.gz`,extractDir:".",binaryRelPath:"cua-driver",hasApp:!1}}if(e==="win32"){let n=`cua-driver-rs-${r}-${t==="arm64"?"windows-arm64":"windows-x86_64"}`;return{asset:`${n}.zip`,extractDir:n,binaryRelPath:"cua-driver.exe",hasApp:!1}}throw new Error(`Computer Use: unsupported platform '${e}'.`)}function N(e,t=process.env,o=l){let r=[],i=t.MATILDA_COMPUTER_USE_DOWNLOAD_HOST;return i&&r.push(`${we(i)}/cua-driver-rs/v${o}/${e}`),r.push(`${he}/cua-driver-rs/v${o}/${e}`),r.push(`${fe}/cua-driver-rs-v${o}/${e}`),r}function Q(e=process.env,t=l){return N("checksums.txt",e,t)}var ge="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function Y(e){if(e===void 0||typeof e=="string"&&e.trim()==="")return;let t=typeof e=="number"?e:Number(e);if(!(!Number.isInteger(t)||t<0))return t}function Z(e,t=process.env){let o=Y(t[ge]);return o!==void 0?o:Y(e)}function ye(e=R()){return I(e,".matilda","computer-use")}function M(e=R(),t=l){return I(ye(e),`cua-driver-rs-${t}`)}function u(e=R(),t=process.platform,o=process.arch,r=l){let i=U(t,o,r);return I(M(e,r),i.extractDir,i.binaryRelPath)}function h(e=l){return`cua-driver-rs@${e}`}function we(e){return e.endsWith("/")?e.slice(0,-1):e}var f=class e{static singleton;binary;onProgress;maxImageDimension;client;startPromise;constructor(t){this.binary=t.binary,this.onProgress=t.onProgress??(()=>{}),this.maxImageDimension=t.maxImageDimension}setMaxImageDimension(t){this.maxImageDimension=t}static shared(){return e.singleton||(e.singleton=new e({binary:u(_e())})),e.singleton}static setSharedForTest(t){e.singleton=t}isStarted(){return this.client!==void 0}async start(t){if(!this.client)return this.startPromise?this.startPromise:(this.startPromise=this.doStart(t).finally(()=>{this.startPromise=void 0}),this.startPromise)}async doStart(t){let o=t??this.onProgress;o("Starting Computer Use driver...");let r=new K({command:this.binary,args:["mcp"],env:V(x())}),i=new H({name:"matilda-code-computer-use",version:"1.0.0"},{capabilities:{}});await i.connect(r),this.client=i,await this.applyRuntimeConfig(i,o)}async applyRuntimeConfig(t,o){if(this.maxImageDimension!==void 0)try{await t.callTool({name:"set_config",arguments:{max_image_dimension:this.maxImageDimension}})}catch(r){let i=r instanceof Error?r.message:String(r);o(`Computer Use: could not apply max_image_dimension=${this.maxImageDimension} (${i}); using driver default.`)}}async listTools(){if(!this.client)throw new Error("ComputerUseClient not started");return this.client.listTools()}async callTool(t,o){if(!this.client)throw new Error("ComputerUseClient not started");try{return await this.client.callTool({name:t,arguments:o})}catch(r){if(!ee(r))throw r;let i=r;for(let n=0;n<3;n++){if(await this.stop(),await this.start(),!this.client)throw new Error("ComputerUseClient reconnect failed");try{return await this.client.callTool({name:t,arguments:o})}catch(s){if(!ee(s))throw s;i=s,await new Promise(a=>setTimeout(a,1e3))}}throw i}}async stop(){let t=this.client;if(this.client=void 0,t)try{await t.close()}catch{}}};function ee(e){let t=e instanceof Error?e.message:String(e);return/connection closed|not connected|connection refused|daemon transport error|os error 61/i.test(t)}d();var j=["bring_to_front","check_for_update","check_permissions","click","double_click","drag","end_session","get_accessibility_tree","get_agent_cursor_state","get_config","get_cursor_position","get_recording_state","get_screen_size","get_window_state","hotkey","kill_app","launch_app","list_apps","list_windows","move_cursor","page","press_key","replay_trajectory","right_click","scroll","set_agent_cursor_enabled","set_agent_cursor_motion","set_agent_cursor_style","set_config","set_value","start_recording","start_session","stop_recording","type_text","zoom"],g={bring_to_front:{description:'Activate a window so subsequent input tools with `dispatch:"foreground"` land on it without a per-call SetForegroundWindow flash. **Windows-only:** on macOS this tool returns an error pointing to the platform-native `NSRunningApplication.activate` (which the macOS input tools don\'t need because CGEvent.postToPid reaches backgrounded windows). On Linux this tool also stubs out; use `wmctrl -a` or `xdotool windowactivate` if you need explicit activation.',parameterSchema:{additionalProperties:!1,properties:{pid:{type:"integer"},window_id:{type:"integer"}},required:["pid"],type:"object"}},check_for_update:{description:"Check whether a newer cua-driver-rs release is available on GitHub. Returns the current and latest versions, an `update_available` boolean, the install one-liner, and the release notes URL. Read-only \u2014 never installs. Mirror of `cua-driver check-update --json`.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},check_permissions:{description:"Report TCC permission status for Accessibility and Screen Recording. By default also raises the system permission dialogs for any missing grants \u2014 Apple's request APIs are no-ops when the grant is already active, so this is safe to call repeatedly. Pass {\"prompt\": false} for a purely read-only status check.\n\nReturns: `accessibility` + `screen_recording` (booleans from the TCC preflight APIs), `screen_recording_capturable` (a live ScreenCaptureKit probe \u2014 if it disagrees with `screen_recording`, the preflight grant belongs to a different process), and `source` (which TCC identity the booleans reflect: the CuaDriver daemon vs the launching terminal/IDE). macOS attributes grants to the responsible process, so a standalone call from a terminal reports the terminal's grants, not the driver's.",parameterSchema:{additionalProperties:!1,properties:{prompt:{description:"Raise the system permission prompts for missing grants. Default true.",type:"boolean"}},type:"object"}},click:{description:`Left-click against a target pid. **Prefer \`element_index\` over pixel coordinates** \u2014 element_index works on backgrounded / minimized / hidden / off-Space windows, surfaces a stable handle that survives rebuilds, and tells you what you're clicking via the cached element's role + label. Reach for \`x, y\` only when the target is a canvas / video / WebGL / custom-drawn surface that doesn't appear in the AX tree.
3
+ import{Bb as D}from"./chunk-BEP4F3GO.js";import{d as k,m as g,o as T}from"./chunk-HK3QQSM7.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NO6BFSGG.js";import"./chunk-R373GBK6.js";import"./chunk-VNSW4TSX.js";import"./chunk-EEPSTT7K.js";import"./chunk-DERMLVT6.js";import"./chunk-JZMGEGR6.js";import"./chunk-JVQHQDDE.js";import"./chunk-QXSBPCBA.js";import"./chunk-WAZCC4SE.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-TVNM3PQ7.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-N3AQRPV5.js";import"./chunk-LBQNFSZ2.js";import{a as f}from"./chunk-GDRS4OWI.js";import"./chunk-B7BF33U4.js";import"./chunk-M5ABGGE7.js";import"./chunk-QKAKC34Q.js";import"./chunk-T6MRYRLI.js";import"./chunk-3EQIOCSJ.js";import"./chunk-XPVKH5TC.js";import"./chunk-J6NYCXUR.js";import"./chunk-UM6CLO7D.js";import"./chunk-YUCEPXGG.js";import{ka as C,la as P}from"./chunk-4SDFTVQW.js";import"./chunk-HEJO7OBH.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as F}from"node:os";d();import{join as y}from"node:path";import{homedir as w}from"node:os";var _="0.5.2";function M(t=process.platform,e=process.arch,i=_){let r=i;if(t==="darwin")return{extractDir:`cua-driver-rs-${r}-${e==="arm64"?"darwin-arm64":"darwin-x86_64"}`,binaryRelPath:"CuaDriver.app/Contents/MacOS/cua-driver",hasApp:!0};if(t==="linux"){if(e!=="x64")throw new Error(`Computer Use: unsupported Linux arch '${e}' (only x64).`);return{extractDir:".",binaryRelPath:"cua-driver",hasApp:!1}}if(t==="win32")return{extractDir:`cua-driver-rs-${r}-${e==="arm64"?"windows-arm64":"windows-x86_64"}`,binaryRelPath:"cua-driver.exe",hasApp:!1};throw new Error(`Computer Use: unsupported platform '${t}'.`)}var j="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function R(t){if(t===void 0||typeof t=="string"&&t.trim()==="")return;let e=typeof t=="number"?t:Number(t);if(!(!Number.isInteger(e)||e<0))return e}function O(t,e=process.env){let i=R(e[j]);return i!==void 0?i:R(t)}function W(t=w()){return y(t,".matilda","computer-use")}function q(t=w(),e=_){return y(W(t),`cua-driver-rs-${e}`)}function l(t=w(),e=process.platform,i=process.arch,r=_){let o=M(e,i,r);return y(q(t,r),o.extractDir,o.binaryRelPath)}var u=class t{static singleton;binary;onProgress;maxImageDimension;client;startPromise;constructor(e){this.binary=e.binary,this.onProgress=e.onProgress??(()=>{}),this.maxImageDimension=e.maxImageDimension}setMaxImageDimension(e){this.maxImageDimension=e}static shared(){return t.singleton||(t.singleton=new t({binary:l(F())})),t.singleton}static setSharedForTest(e){t.singleton=e}isStarted(){return this.client!==void 0}async start(e){if(!this.client)return this.startPromise?this.startPromise:(this.startPromise=this.doStart(e).finally(()=>{this.startPromise=void 0}),this.startPromise)}async doStart(e){let i=e??this.onProgress;i("Starting Computer Use driver...");let r=new k({command:this.binary,args:["mcp"],env:T(g())}),o=new D({name:"matilda-code-computer-use",version:"1.0.0"},{capabilities:{}});await o.connect(r),this.client=o,await this.applyRuntimeConfig(o,i)}async applyRuntimeConfig(e,i){if(this.maxImageDimension!==void 0)try{await e.callTool({name:"set_config",arguments:{max_image_dimension:this.maxImageDimension}})}catch(r){let o=r instanceof Error?r.message:String(r);i(`Computer Use: could not apply max_image_dimension=${this.maxImageDimension} (${o}); using driver default.`)}}async listTools(){if(!this.client)throw new Error("ComputerUseClient not started");return this.client.listTools()}async callTool(e,i){if(!this.client)throw new Error("ComputerUseClient not started");try{return await this.client.callTool({name:e,arguments:i})}catch(r){if(!A(r))throw r;let o=r;for(let s=0;s<3;s++){if(await this.stop(),await this.start(),!this.client)throw new Error("ComputerUseClient reconnect failed");try{return await this.client.callTool({name:e,arguments:i})}catch(n){if(!A(n))throw n;o=n,await new Promise(p=>setTimeout(p,1e3))}}throw o}}async stop(){let e=this.client;if(this.client=void 0,e)try{await e.close()}catch{}}};function A(t){let e=t instanceof Error?t.message:String(t);return/connection closed|not connected|connection refused|daemon transport error|os error 61/i.test(e)}d();var b=["bring_to_front","check_for_update","check_permissions","click","double_click","drag","end_session","get_accessibility_tree","get_agent_cursor_state","get_config","get_cursor_position","get_recording_state","get_screen_size","get_window_state","hotkey","kill_app","launch_app","list_apps","list_windows","move_cursor","page","press_key","replay_trajectory","right_click","scroll","set_agent_cursor_enabled","set_agent_cursor_motion","set_agent_cursor_style","set_config","set_value","start_recording","start_session","stop_recording","type_text","zoom"],m={bring_to_front:{description:'Activate a window so subsequent input tools with `dispatch:"foreground"` land on it without a per-call SetForegroundWindow flash. **Windows-only:** on macOS this tool returns an error pointing to the platform-native `NSRunningApplication.activate` (which the macOS input tools don\'t need because CGEvent.postToPid reaches backgrounded windows). On Linux this tool also stubs out; use `wmctrl -a` or `xdotool windowactivate` if you need explicit activation.',parameterSchema:{additionalProperties:!1,properties:{pid:{type:"integer"},window_id:{type:"integer"}},required:["pid"],type:"object"}},check_for_update:{description:"Check whether a newer cua-driver-rs release is available on GitHub. Returns the current and latest versions, an `update_available` boolean, the install one-liner, and the release notes URL. Read-only \u2014 never installs. Mirror of `cua-driver check-update --json`.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},check_permissions:{description:"Report TCC permission status for Accessibility and Screen Recording. By default also raises the system permission dialogs for any missing grants \u2014 Apple's request APIs are no-ops when the grant is already active, so this is safe to call repeatedly. Pass {\"prompt\": false} for a purely read-only status check.\n\nReturns: `accessibility` + `screen_recording` (booleans from the TCC preflight APIs), `screen_recording_capturable` (a live ScreenCaptureKit probe \u2014 if it disagrees with `screen_recording`, the preflight grant belongs to a different process), and `source` (which TCC identity the booleans reflect: the CuaDriver daemon vs the launching terminal/IDE). macOS attributes grants to the responsible process, so a standalone call from a terminal reports the terminal's grants, not the driver's.",parameterSchema:{additionalProperties:!1,properties:{prompt:{description:"Raise the system permission prompts for missing grants. Default true.",type:"boolean"}},type:"object"}},click:{description:`Left-click against a target pid. **Prefer \`element_index\` over pixel coordinates** \u2014 element_index works on backgrounded / minimized / hidden / off-Space windows, surfaces a stable handle that survives rebuilds, and tells you what you're clicking via the cached element's role + label. Reach for \`x, y\` only when the target is a canvas / video / WebGL / custom-drawn surface that doesn't appear in the AX tree.
4
4
 
5
5
  Two addressing modes:
6
6
 
@@ -87,25 +87,13 @@ All parameters are optional; omit any you do not want to change.`,parameterSchem
87
87
 
88
88
  - **All other elements**: writes AXValue directly (sliders, steppers, date pickers, native text fields that expose settable AXValue).
89
89
 
90
- For free-form text entry into web inputs, prefer \`type_text_chars\` which synthesises key events \u2014 AXValue writes are ignored by WebKit.`,parameterSchema:{additionalProperties:!1,properties:{element_index:{type:"integer"},pid:{type:"integer"},session:{description:"Optional session id: declares/uses the agent cursor and per-session state for this run. The same id works over MCP, the CLI, or the raw socket, and follows the run across apps/windows. Omit to run cursor-less.",type:"string"},value:{description:"New value. AX will coerce to the element's native type.",type:"string"},window_id:{description:"CGWindowID for the window whose get_window_state produced the element_index.",type:"integer"}},required:["pid","window_id","element_index","value"],type:"object"}},start_recording:{description:"Start trajectory recording. Every subsequent action-tool invocation (click, right_click, scroll, type_text, press_key, hotkey, set_value) writes a turn folder under `output_dir`:\n\n- `app_state.json` \u2014 post-action AX/UIA snapshot for the target pid.\n- `screenshot.png` \u2014 post-action per-window screenshot of the target's frontmost on-screen window.\n- `action.json` \u2014 tool name, full input arguments, result summary, pid, click point (when applicable), ISO-8601 timestamp.\n- `click.png` \u2014 for click-family actions only, `screenshot.png` with a red dot drawn at the click point.\n\nTurn folders are named `turn-00001/`, `turn-00002/`, etc. Turn numbering restarts at 1 each time recording is (re-)started.\n\n**Video is off by default.** Pass `record_video: true` to also capture the main display to `<output_dir>/recording.mp4` (H.264 / 30 fps) for the lifetime of the session. The recording is torn down automatically when the MCP client disconnects.\n\n**macOS uses native ScreenCaptureKit** (in-process SCStream + SCRecordingOutput) so video inherits Cua Driver's own Screen Recording grant \u2014 no extra TCC prompt, no ffmpeg subprocess. Requires macOS 15.0+.\n\n**Windows + Linux use an ffmpeg subprocess** (`gdigrab` / `x11grab` + libx264). Requires ffmpeg on PATH (winget install Gyan.FFmpeg / apt install ffmpeg); when ffmpeg is missing or fails on startup the per-turn capture (screenshots + action.json) still runs and the session's `last_error` field carries the diagnostic.\n\nState persists for the life of the daemon / MCP session; a restart resets to disabled with no on-disk state. Call `stop_recording` to disable + finalize the mp4.",parameterSchema:{additionalProperties:!1,properties:{output_dir:{description:"Absolute or ~-rooted directory where turn folders and (when enabled) the video file are written.",type:"string"},record_video:{description:"Capture the main display to <output_dir>/recording.mp4. Default: false. Set to true to also capture the main display to recording.mp4 (otherwise only the per-turn screenshots + JSON are recorded). On macOS this uses native ScreenCaptureKit (no extra TCC prompt, macOS 15.0+); on Windows + Linux it requires ffmpeg on PATH.",type:"boolean"}},required:["output_dir"],type:"object"}},start_session:{description:"Declare a session \u2014 a named, color-coded identity for THIS agent run. Pass a stable `session` id; the agent cursor, per-session config, and recording all key on it, and it follows the run across any apps/windows. The cursor's color is derived from the id, so distinct runs are visually distinct. A cursor is shown only for a declared session \u2014 call this (or pass `session` on your first action) to opt in. Idempotent: re-calling with the same id just refreshes its idle-TTL. End it with `end_session` (or let the idle-TTL reclaim it). Concurrent runs/subagents each pass their own `session` to get their own cursor.",parameterSchema:{additionalProperties:!0,properties:{session:{description:'Stable session id for this run (e.g. "research-run-1").',type:"string"}},required:["session"],type:"object"}},stop_recording:{description:"Stop trajectory recording. Disables further per-turn capture and, when video was enabled, gracefully terminates the ffmpeg subprocess so the mp4's moov atom is finalized (the file is playable). Calling stop on an already-stopped session is a no-op. The response carries `last_video_path` pointing at the finalized mp4 (when video was on).\n\nA manual `stop_recording` is **unconditional** \u2014 it stops whatever recording is active regardless of which session started it. Ownership-scoped teardown (so one MCP client disconnecting can't stop a recording a later client started) is handled by the daemon's `session_end` lifecycle signal, not by this tool.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},type_text:{description:"Insert text into the target pid via `AXSetAttribute(kAXSelectedText)`. Works for standard Cocoa text fields and text views. No keystrokes are synthesized \u2014 special keys (Return / Escape / arrows) go through `press_key` / `hotkey`. For Chromium / Electron inputs that don't implement `kAXSelectedText`, the tool falls back to CGEvent character synthesis automatically.\n\nOptional `element_index` + `window_id` (from the last `get_window_state` snapshot) directs the write to a specific field. Without `element_index`, the write goes to the pid's currently focused element.",parameterSchema:{additionalProperties:!1,properties:{delay_ms:{description:"Milliseconds between characters in the CGEvent fallback path. Default 30. Ignored when the AX path succeeds.",maximum:200,minimum:0,type:"integer"},element_index:{description:"Element index from last get_window_state. Directs the write to a specific field. Requires window_id.",type:"integer"},pid:{description:"Target process ID.",type:"integer"},session:{description:"Optional session id: declares/uses the agent cursor and per-session state for this run. The same id works over MCP, the CLI, or the raw socket, and follows the run across apps/windows. Omit to run cursor-less.",type:"string"},text:{description:"Text to insert at the target's cursor.",type:"string"},window_id:{description:"CGWindowID. Required when element_index is used.",type:"integer"}},required:["pid","text"],type:"object"}},zoom:{description:"Capture a cropped JPEG of a window region (x1,y1)\u2013(x2,y2) in screenshot pixel coordinates, with 20% padding added on each side. The output image is at most 500 px wide.\n\nAfter a zoom, pass `from_zoom=true` to click/type_text to auto-translate coordinates back to full-window space.",parameterSchema:{additionalProperties:!1,properties:{pid:{description:"Target pid \u2014 required for from_zoom click/type translation.",type:"integer"},window_id:{description:"CGWindowID from list_windows.",type:"integer"},x1:{description:"Left edge of region in screenshot pixels.",type:"number"},x2:{description:"Right edge of region in screenshot pixels.",type:"number"},y1:{description:"Top edge of region in screenshot pixels.",type:"number"},y2:{description:"Bottom edge of region in screenshot pixels.",type:"number"}},required:["window_id","x1","y1","x2","y2"],type:"object"}}};d();import{execFile as qe,spawnSync as $}from"node:child_process";import{promisify as ze}from"node:util";import{rmSync as Be}from"node:fs";import{homedir as W}from"node:os";import{join as Ge}from"node:path";d();import{readFile as ve,writeFile as be,mkdir as Se}from"node:fs/promises";import{homedir as C}from"node:os";import{join as xe,dirname as Ce}from"node:path";function te(e=C()){return xe(e,".matilda","computer-use","installed.json")}async function Pe(e=C()){try{let t=await ve(te(e),"utf8"),o=JSON.parse(t);return typeof o?.approvedPackageSpec!="string"||typeof o?.approvedAtIso!="string"?void 0:o}catch(t){return t?.code==="ENOENT",void 0}}async function P(e=C(),t){let o=te(e);await Se(Ce(o),{recursive:!0}),await be(o,JSON.stringify(t,null,2),"utf8")}async function k(e=C(),t){return(await Pe(e))?.approvedPackageSpec===t}d();import{createHash as ke}from"node:crypto";import{createWriteStream as Te}from"node:fs";import{mkdir as re,rm as T,stat as De,chmod as Ae,rename as Oe}from"node:fs/promises";import{join as D}from"node:path";import{tmpdir as Ee}from"node:os";import{pipeline as Ie}from"node:stream/promises";import{Readable as Re}from"node:stream";function Ue(e){let t=new Map;for(let o of e.split(`
91
- `)){let r=o.trim().match(/^([0-9a-f]{64})\s+\*?(.+)$/i);r&&t.set(r[2].trim(),r[1].toLowerCase())}return t}async function Ne(e,t=process.platform,o=process.arch,r=l){let i=u(e,t,o,r);try{if((await De(i)).isFile())return i}catch{}}async function oe(e,t,o){let r;for(let i of e)try{let n=new AbortController,s=setTimeout(()=>{n.abort(new Error(`headers timeout after 30s for ${i}`))},3e4);try{let a=await t(i,{redirect:"follow",signal:n.signal});if(a.ok&&a.body)return{url:i,res:a};await a.body?.cancel(),r=new Error(`HTTP ${a.status} for ${i}`)}finally{clearTimeout(s)}}catch(n){r=n,o?.("Source unreachable, trying fallback\u2026")}throw new Error(`Computer Use: all download sources failed. Last error: ${r instanceof Error?r.message:String(r)}`)}async function ne(e){let t=e.platform??process.platform,o=e.arch??process.arch,r=e.version??l,i=e.env??process.env,n=e.fetchImpl??fetch,s=e.onProgress,a=await Ne(e.home,t,o,r);if(a)return a;let p=U(t,o,r);s?.("Downloading Computer Use driver (~20MB, one time)...");let{res:c}=await oe(Q(i,r),n),A=Ue(await c.text()).get(p.asset);if(!A)throw new Error(`Computer Use: ${p.asset} missing from checksums.txt.`);let{res:ue}=await oe(N(p.asset,i,r),n,s);await re(ie(e.home),{recursive:!0});let w=D(ie(e.home),p.asset),L=ke("sha256"),O=Re.fromWeb(ue.body),E,q=()=>{clearTimeout(E),E=setTimeout(()=>{O.destroy(new Error("download stalled: no data for 60s"))},6e4)};O.on("data",b=>{L.update(b),q()}),q();try{await Ie(O,Te(w))}finally{clearTimeout(E)}let z=L.digest("hex");if(z!==A)throw await T(w,{force:!0}),new Error(`Computer Use: checksum mismatch for ${p.asset} (expected ${A.slice(0,12)}\u2026, got ${z.slice(0,12)}\u2026).`);let _=M(e.home,r),v=`${_}.staging`;await T(v,{recursive:!0,force:!0}),await re(v,{recursive:!0}),await We(w,v,p.asset,e.unzipImpl),await T(w,{force:!0}),await T(_,{recursive:!0,force:!0}),await Oe(v,_);let B=u(e.home,t,o,r);if(t!=="win32"&&await Ae(B,493),t==="darwin"&&p.hasApp){let b=D(_,p.extractDir),me=D(b,"CuaDriver.app");await $e(b),await je(me)}return s?.("Computer Use driver ready."),B}var Me="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister";async function je(e){try{let{execFile:t}=await import("node:child_process"),{promisify:o}=await import("node:util");await o(t)(Me,["-f",e],{timeout:15e3})}catch{}}function ie(e){return D(Ee(),"matilda-computer-use-dl",Buffer.from(e).toString("hex").slice(0,8))}async function $e(e){try{let{execFile:t}=await import("node:child_process"),{promisify:o}=await import("node:util");await o(t)("xattr",["-dr","com.apple.quarantine",e],{timeout:1e4})}catch{}}async function We(e,t,o,r){o.endsWith(".zip")?await(r??Fe)(e,t):await J({file:e,cwd:t})}async function Fe(e,t){let{execFile:o}=await import("node:child_process"),{promisify:r}=await import("node:util"),i=r(o),n=`Expand-Archive -LiteralPath ${se(e)} -DestinationPath ${se(t)} -Force`,s=[{cmd:"tar",args:["-xf",e,"-C",t]},{cmd:"tar",args:["--force-local","-xf",e,"-C",t]},{cmd:"powershell",args:["-NoProfile","-NonInteractive","-Command",n]}],a=[];for(let{cmd:p,args:c}of s)try{await i(p,c,{timeout:18e4});return}catch(m){a.push(`${p} ${c[0]}: ${Le(m)}`)}throw new Error(`Computer Use: failed to unzip ${e} on Windows (${a.join("; ")}).`)}function se(e){return`'${e.replace(/'/g,"''")}'`}function Le(e){return e instanceof Error?e.message:String(e)}var Xe=ze(qe);function He(e){try{let t=JSON.parse(e);return typeof t.accessibility!="boolean"?"unknown":t.accessibility?t.screen_recording?"ok":"screenRecording":"accessibility"}catch{return"unknown"}}var Ke=()=>Ge(W(),"Library","Caches","cua-driver","cua-driver.sock");function ae(){try{$("pkill",["-f","CuaDriver.app/Contents/MacOS/cua-driver serve"],{stdio:"ignore"})}catch{}try{Be(Ke(),{force:!0})}catch{}}async function Ve(){try{let{stdout:e}=await Xe(u(W()),["permissions","status","--json"],{timeout:1e4,env:x()});return He(e)}catch{return"unknown"}}function Je(){ae();try{$("open",["-n","-g","-a","CuaDriver","--args","serve","--no-permissions-gate"],{stdio:"ignore"})}catch{}return{kill:ae}}function Ye(e){let t=e==="accessibility"?"Privacy_Accessibility":"Privacy_ScreenCapture";try{$("open",[`x-apple.systempreferences:com.apple.preference.security?${t}`],{stdio:"ignore"})}catch{}}function Qe(){let e=W();return{homeDir:e,approvalKey:h(),platform:process.platform,promptInstallApproval:async t=>(process.stderr.write(`
92
- [Computer Use] First-time setup
93
- Driver: ${t}
94
- This downloads a ~20MB signed + notarized binary into ~/.matilda/computer-use/.
95
- Computer Use can click, type, and read your desktop apps in the background.
96
- On macOS you'll be guided through Accessibility and Screen Recording permissions next.
97
- Set MATILDA_COMPUTER_USE_AUTO_APPROVE=1 to skip this prompt.
98
- `),process.env.MATILDA_COMPUTER_USE_AUTO_APPROVE==="1"),install:t=>ne({home:e,onProgress:t}),startStatusDaemon:Je,probePermissions:Ve,openPermissionPane:Ye}}async function pe(e,t,o){let r={...Qe(),...o},i=r.pollIntervalMs??5e3,n=r.pollTimeoutMs??10*6e4;if(e.isStarted())return;if(!await k(r.homeDir,r.approvalKey)){if(t.autoApproveInstall)t.updateOutput?.("Computer Use install auto-approved (approval mode).");else if(t.updateOutput?.("Computer Use needs a one-time driver download (first use)."),!await r.promptInstallApproval(r.approvalKey))throw new Error("Computer Use install declined by user. Re-invoke the tool to be prompted again.");await P(r.homeDir,{approvedPackageSpec:r.approvalKey,approvedAtIso:new Date().toISOString()})}await r.install(t.updateOutput),r.platform==="darwin"&&await Ze(r,t,i,n),await e.start(t.updateOutput)}async function Ze(e,t,o,r){let i=e.startStatusDaemon(),n=!1,s=!1;try{let a=Date.now();for(;;){if(t.signal.aborted)throw new Error("Computer Use bootstrap aborted.");if(Date.now()-a>r)throw new Error(`Computer Use permission grant timed out after ${Math.round(r/1e3)}s. Re-invoke the tool to retry.`);await et(o);let p=await e.probePermissions();if(p==="ok")return;if(p==="unknown"){i.kill(),i=e.startStatusDaemon();let c=Math.round((Date.now()-a)/1e3);t.updateOutput?.(`Bringing up Computer Use permissions check\u2026 (${c}s)`);continue}if(p==="accessibility"){if(!n)n=!0,e.openPermissionPane("accessibility"),t.updateOutput?.("Step 1/2 \u2014 In the System Settings window that opened (Privacy & Security \u2192 Accessibility), turn ON CuaDriver. This continues automatically.");else{let c=Math.round((Date.now()-a)/1e3);t.updateOutput?.(`Waiting for Accessibility\u2026 (${c}s) \u2014 enable CuaDriver in System Settings.`)}continue}if(!s)s=!0,e.openPermissionPane("screenRecording"),t.updateOutput?.("Step 2/2 \u2014 Accessibility granted. Now in System Settings (Privacy & Security \u2192 Screen & System Audio Recording), turn ON CuaDriver. macOS will ask to restart CuaDriver \u2014 allow it; that is expected. This continues automatically.");else{let c=Math.round((Date.now()-a)/1e3);t.updateOutput?.(`Waiting for Screen Recording\u2026 (${c}s) \u2014 enable CuaDriver in System Settings.`)}}}finally{i.kill()}}var et=e=>new Promise(t=>setTimeout(t,e));import{homedir as ce}from"node:os";var tt="This downloads the Computer Use driver (~20MB, signed + notarized) into ~/.matilda/computer-use/ the first time. Computer Use can click, type, and read your desktop apps in the background. On macOS you'll be guided through Accessibility / Screen Recording permissions next.",le=new Set(["kill_app","launch_app","start_recording","set_config","replay_trajectory"]),rt=new Set(["execute_javascript","enable_javascript_apple_events"]);for(let e of le)if(!(e in g))throw new Error(`HIGH_RISK_TOOLS contains unknown tool: ${e}`);function ot(e,t){return le.has(e)?!0:e==="page"&&rt.has(t.action)}var F=class extends G{constructor(o,r,i){super(r);this.upstreamName=o;this.config=i}getDescription(){return S(this.params)}async getDefaultPermission(){return"ask"}async getConfirmationDetails(o){let r=[`computer_use__${this.upstreamName}`],i=await k(ce(),h()),n=async(p,c)=>{p!=="cancel"&&await P(ce(),{approvedPackageSpec:h(),approvedAtIso:new Date().toISOString()})};if(ot(this.upstreamName,this.params))return{type:"mcp",title:i?`Allow high-risk Computer Use (${this.upstreamName})`:`Allow high-risk Computer Use (${this.upstreamName}) \u2014 first use also downloads the driver`,serverName:"cua-driver",toolName:this.upstreamName,toolDisplayName:`computer_use__${this.upstreamName}`,permissionRules:r,onConfirm:n};let s=S(this.params),a=i?`Tool: computer_use__${this.upstreamName}
90
+ For free-form text entry into web inputs, prefer \`type_text_chars\` which synthesises key events \u2014 AXValue writes are ignored by WebKit.`,parameterSchema:{additionalProperties:!1,properties:{element_index:{type:"integer"},pid:{type:"integer"},session:{description:"Optional session id: declares/uses the agent cursor and per-session state for this run. The same id works over MCP, the CLI, or the raw socket, and follows the run across apps/windows. Omit to run cursor-less.",type:"string"},value:{description:"New value. AX will coerce to the element's native type.",type:"string"},window_id:{description:"CGWindowID for the window whose get_window_state produced the element_index.",type:"integer"}},required:["pid","window_id","element_index","value"],type:"object"}},start_recording:{description:"Start trajectory recording. Every subsequent action-tool invocation (click, right_click, scroll, type_text, press_key, hotkey, set_value) writes a turn folder under `output_dir`:\n\n- `app_state.json` \u2014 post-action AX/UIA snapshot for the target pid.\n- `screenshot.png` \u2014 post-action per-window screenshot of the target's frontmost on-screen window.\n- `action.json` \u2014 tool name, full input arguments, result summary, pid, click point (when applicable), ISO-8601 timestamp.\n- `click.png` \u2014 for click-family actions only, `screenshot.png` with a red dot drawn at the click point.\n\nTurn folders are named `turn-00001/`, `turn-00002/`, etc. Turn numbering restarts at 1 each time recording is (re-)started.\n\n**Video is off by default.** Pass `record_video: true` to also capture the main display to `<output_dir>/recording.mp4` (H.264 / 30 fps) for the lifetime of the session. The recording is torn down automatically when the MCP client disconnects.\n\n**macOS uses native ScreenCaptureKit** (in-process SCStream + SCRecordingOutput) so video inherits Cua Driver's own Screen Recording grant \u2014 no extra TCC prompt, no ffmpeg subprocess. Requires macOS 15.0+.\n\n**Windows + Linux use an ffmpeg subprocess** (`gdigrab` / `x11grab` + libx264). Requires ffmpeg on PATH (winget install Gyan.FFmpeg / apt install ffmpeg); when ffmpeg is missing or fails on startup the per-turn capture (screenshots + action.json) still runs and the session's `last_error` field carries the diagnostic.\n\nState persists for the life of the daemon / MCP session; a restart resets to disabled with no on-disk state. Call `stop_recording` to disable + finalize the mp4.",parameterSchema:{additionalProperties:!1,properties:{output_dir:{description:"Absolute or ~-rooted directory where turn folders and (when enabled) the video file are written.",type:"string"},record_video:{description:"Capture the main display to <output_dir>/recording.mp4. Default: false. Set to true to also capture the main display to recording.mp4 (otherwise only the per-turn screenshots + JSON are recorded). On macOS this uses native ScreenCaptureKit (no extra TCC prompt, macOS 15.0+); on Windows + Linux it requires ffmpeg on PATH.",type:"boolean"}},required:["output_dir"],type:"object"}},start_session:{description:"Declare a session \u2014 a named, color-coded identity for THIS agent run. Pass a stable `session` id; the agent cursor, per-session config, and recording all key on it, and it follows the run across any apps/windows. The cursor's color is derived from the id, so distinct runs are visually distinct. A cursor is shown only for a declared session \u2014 call this (or pass `session` on your first action) to opt in. Idempotent: re-calling with the same id just refreshes its idle-TTL. End it with `end_session` (or let the idle-TTL reclaim it). Concurrent runs/subagents each pass their own `session` to get their own cursor.",parameterSchema:{additionalProperties:!0,properties:{session:{description:'Stable session id for this run (e.g. "research-run-1").',type:"string"}},required:["session"],type:"object"}},stop_recording:{description:"Stop trajectory recording. Disables further per-turn capture and, when video was enabled, gracefully terminates the ffmpeg subprocess so the mp4's moov atom is finalized (the file is playable). Calling stop on an already-stopped session is a no-op. The response carries `last_video_path` pointing at the finalized mp4 (when video was on).\n\nA manual `stop_recording` is **unconditional** \u2014 it stops whatever recording is active regardless of which session started it. Ownership-scoped teardown (so one MCP client disconnecting can't stop a recording a later client started) is handled by the daemon's `session_end` lifecycle signal, not by this tool.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},type_text:{description:"Insert text into the target pid via `AXSetAttribute(kAXSelectedText)`. Works for standard Cocoa text fields and text views. No keystrokes are synthesized \u2014 special keys (Return / Escape / arrows) go through `press_key` / `hotkey`. For Chromium / Electron inputs that don't implement `kAXSelectedText`, the tool falls back to CGEvent character synthesis automatically.\n\nOptional `element_index` + `window_id` (from the last `get_window_state` snapshot) directs the write to a specific field. Without `element_index`, the write goes to the pid's currently focused element.",parameterSchema:{additionalProperties:!1,properties:{delay_ms:{description:"Milliseconds between characters in the CGEvent fallback path. Default 30. Ignored when the AX path succeeds.",maximum:200,minimum:0,type:"integer"},element_index:{description:"Element index from last get_window_state. Directs the write to a specific field. Requires window_id.",type:"integer"},pid:{description:"Target process ID.",type:"integer"},session:{description:"Optional session id: declares/uses the agent cursor and per-session state for this run. The same id works over MCP, the CLI, or the raw socket, and follows the run across apps/windows. Omit to run cursor-less.",type:"string"},text:{description:"Text to insert at the target's cursor.",type:"string"},window_id:{description:"CGWindowID. Required when element_index is used.",type:"integer"}},required:["pid","text"],type:"object"}},zoom:{description:"Capture a cropped JPEG of a window region (x1,y1)\u2013(x2,y2) in screenshot pixel coordinates, with 20% padding added on each side. The output image is at most 500 px wide.\n\nAfter a zoom, pass `from_zoom=true` to click/type_text to auto-translate coordinates back to full-window space.",parameterSchema:{additionalProperties:!1,properties:{pid:{description:"Target pid \u2014 required for from_zoom click/type translation.",type:"integer"},window_id:{description:"CGWindowID from list_windows.",type:"integer"},x1:{description:"Left edge of region in screenshot pixels.",type:"number"},x2:{description:"Right edge of region in screenshot pixels.",type:"number"},y1:{description:"Top edge of region in screenshot pixels.",type:"number"},y2:{description:"Bottom edge of region in screenshot pixels.",type:"number"}},required:["window_id","x1","y1","x2","y2"],type:"object"}}};d();import{execFile as L,spawnSync as v}from"node:child_process";import{promisify as z}from"node:util";import{rmSync as X,statSync as G}from"node:fs";import{homedir as x}from"node:os";import{join as $}from"node:path";var B=z(L),H="Computer Use isn't available in this release: its driver doesn't come with Matilda Code yet.";function V(t){try{let e=JSON.parse(t);return typeof e.accessibility!="boolean"?"unknown":e.accessibility?e.screen_recording?"ok":"screenRecording":"accessibility"}catch{return"unknown"}}var K=()=>$(x(),"Library","Caches","cua-driver","cua-driver.sock");function E(){try{v("pkill",["-f","CuaDriver.app/Contents/MacOS/cua-driver serve"],{stdio:"ignore"})}catch{}try{X(K(),{force:!0})}catch{}}async function J(){try{let{stdout:t}=await B(l(x()),["permissions","status","--json"],{timeout:1e4,env:g()});return V(t)}catch{return"unknown"}}function Y(){E();try{v("open",["-n","-g","-a","CuaDriver","--args","serve","--no-permissions-gate"],{stdio:"ignore"})}catch{}return{kill:E}}function Z(t){let e=t==="accessibility"?"Privacy_Accessibility":"Privacy_ScreenCapture";try{v("open",[`x-apple.systempreferences:com.apple.preference.security?${e}`],{stdio:"ignore"})}catch{}}function Q(){return{platform:process.platform,driverInstalled:()=>ee(l(x())),startStatusDaemon:Y,probePermissions:J,openPermissionPane:Z}}function ee(t){try{return G(t).isFile()}catch{return!1}}async function I(t,e,i){let r={...Q(),...i},o=r.pollIntervalMs??5e3,s=r.pollTimeoutMs??10*6e4;if(!t.isStarted()){if(!r.driverInstalled())throw new Error(H);r.platform==="darwin"&&await te(r,e,o,s),await t.start(e.updateOutput)}}async function te(t,e,i,r){let o=t.startStatusDaemon(),s=!1,n=!1;try{let p=Date.now();for(;;){if(e.signal.aborted)throw new Error("Computer Use bootstrap aborted.");if(Date.now()-p>r)throw new Error(`Computer Use permission grant timed out after ${Math.round(r/1e3)}s. Re-invoke the tool to retry.`);await re(i);let a=await t.probePermissions();if(a==="ok")return;if(a==="unknown"){o.kill(),o=t.startStatusDaemon();let c=Math.round((Date.now()-p)/1e3);e.updateOutput?.(`Bringing up Computer Use permissions check\u2026 (${c}s)`);continue}if(a==="accessibility"){if(!s)s=!0,t.openPermissionPane("accessibility"),e.updateOutput?.("Step 1/2 \u2014 In the System Settings window that opened (Privacy & Security \u2192 Accessibility), turn ON CuaDriver. This continues automatically.");else{let c=Math.round((Date.now()-p)/1e3);e.updateOutput?.(`Waiting for Accessibility\u2026 (${c}s) \u2014 enable CuaDriver in System Settings.`)}continue}if(!n)n=!0,t.openPermissionPane("screenRecording"),e.updateOutput?.("Step 2/2 \u2014 Accessibility granted. Now in System Settings (Privacy & Security \u2192 Screen & System Audio Recording), turn ON CuaDriver. macOS will ask to restart CuaDriver \u2014 allow it; that is expected. This continues automatically.");else{let c=Math.round((Date.now()-p)/1e3);e.updateOutput?.(`Waiting for Screen Recording\u2026 (${c}s) \u2014 enable CuaDriver in System Settings.`)}}}finally{o.kill()}}var re=t=>new Promise(e=>setTimeout(e,t));var N=new Set(["kill_app","launch_app","start_recording","set_config","replay_trajectory"]),ie=new Set(["execute_javascript","enable_javascript_apple_events"]);for(let t of N)if(!(t in m))throw new Error(`HIGH_RISK_TOOLS contains unknown tool: ${t}`);function oe(t,e){return N.has(t)?!0:t==="page"&&ie.has(e.action)}var S=class extends C{constructor(i,r,o){super(r);this.upstreamName=i;this.config=o}getDescription(){return f(this.params)}async getDefaultPermission(){return"ask"}async getConfirmationDetails(i){let r=[`computer_use__${this.upstreamName}`],o=async()=>{};if(oe(this.upstreamName,this.params))return{type:"mcp",title:`Allow high-risk Computer Use (${this.upstreamName})`,serverName:"cua-driver",toolName:this.upstreamName,toolDisplayName:`computer_use__${this.upstreamName}`,permissionRules:r,onConfirm:o};let s=f(this.params),n=`Tool: computer_use__${this.upstreamName}
99
91
 
100
92
  Args: ${s}
101
93
 
102
- This will act on your desktop via the Computer Use binary.`:`Tool: computer_use__${this.upstreamName}
103
-
104
- Args: ${s}
105
-
106
- ${tt}`;return{type:"info",title:`Allow Computer Use (${this.upstreamName})`,prompt:a,permissionRules:r,onConfirm:n}}async execute(o,r){let i=f.shared();i.setMaxImageDimension(Z(this.config?.getComputerUseMaxImageDimension()));let n=!!this.config;await pe(i,{signal:o,updateOutput:r,autoApproveInstall:n});let s;try{s=await i.callTool(this.upstreamName,this.params)}catch(c){let m=c instanceof Error?c.message:String(c);return{llmContent:`Computer Use tool '${this.upstreamName}' failed: ${m}`,returnDisplay:`Error: ${m}`,error:{message:m}}}let a=it(s.content,this.upstreamName,s.structuredContent),p=st(s.content);if(s.isError){let c=p||`Tool '${this.upstreamName}' returned isError=true`;return{llmContent:a||c,returnDisplay:c,error:{message:c}}}return{llmContent:a,returnDisplay:p}}},y=class extends X{constructor(o,r,i){let n=`computer_use__${o}`;super(n,n,r.description,"other",r.parameterSchema,!0,!0,!0,!1,"computer use desktop click type screenshot mouse keyboard scroll drag automation gui app native");this.upstreamName=o;this.config=i}validateToolParams(o){let r=de(o,this.parameterSchema);return super.validateToolParams(r)}build(o){let r=de(o,this.parameterSchema);return super.build(r)}createInvocation(o){return new F(this.upstreamName,o,this.config)}};function de(e,t){let o=t.properties;if(!o)return e;let r={...e};for(let[i,n]of Object.entries(r)){let s=o[i]?.type;if((s==="integer"||s==="number")&&typeof n=="string"){let a=n.trim();if(/^-?\d+(\.\d+)?$/.test(a)){let p=s==="integer"?parseInt(a,10):parseFloat(a);Number.isFinite(p)&&(r[i]=p)}}else s==="string"&&typeof n=="number"&&(r[i]=String(n))}return r}function it(e,t,o){let r=[];for(let s of e)s.type==="text"&&s.text?r.push({text:s.text}):(s.type==="image"||s.type==="audio")&&s.mimeType&&s.data&&(r.push({text:`[Tool '${t}' provided the following ${s.type} data with mime-type: ${s.mimeType}]`}),r.push({inlineData:{mimeType:s.mimeType,data:s.data}}));let i=nt(o);return i&&r.push({text:`Structured result: ${i}`}),r.some(s=>s.inlineData!==void 0)?r:r.map(s=>s.text??"").filter(Boolean).join(`
107
- `)}function st(e){return e.map(t=>t.type==="text"?t.text??"":"").filter(Boolean).join(`
108
- `)}function nt(e){if(!e||typeof e!="object")return;let t={};for(let[o,r]of Object.entries(e))o!=="tree_markdown"&&(t[o]=r);if(Object.keys(t).length!==0)return S(t)}async function pr(e,t){for(let o of j){let r=g[o],i=`computer_use__${o}`;await e(i,async()=>new y(o,r,t))}}export{g as COMPUTER_USE_SCHEMAS,j as COMPUTER_USE_TOOL_NAMES,f as ComputerUseClient,y as ComputerUseTool,pr as registerComputerUseTools};
94
+ This will act on your desktop via the Computer Use binary.`;return{type:"info",title:`Allow Computer Use (${this.upstreamName})`,prompt:n,permissionRules:r,onConfirm:o}}async execute(i,r){let o=u.shared();o.setMaxImageDimension(O(this.config?.getComputerUseMaxImageDimension())),await I(o,{signal:i,updateOutput:r});let s;try{s=await o.callTool(this.upstreamName,this.params)}catch(a){let c=a instanceof Error?a.message:String(a);return{llmContent:`Computer Use tool '${this.upstreamName}' failed: ${c}`,returnDisplay:`Error: ${c}`,error:{message:c}}}let n=ne(s.content,this.upstreamName,s.structuredContent),p=se(s.content);if(s.isError){let a=p||`Tool '${this.upstreamName}' returned isError=true`;return{llmContent:n||a,returnDisplay:a,error:{message:a}}}return{llmContent:n,returnDisplay:p}}},h=class extends P{constructor(i,r,o){let s=`computer_use__${i}`;super(s,s,r.description,"other",r.parameterSchema,!0,!0,!0,!1,"computer use desktop click type screenshot mouse keyboard scroll drag automation gui app native");this.upstreamName=i;this.config=o}validateToolParams(i){let r=U(i,this.parameterSchema);return super.validateToolParams(r)}build(i){let r=U(i,this.parameterSchema);return super.build(r)}createInvocation(i){return new S(this.upstreamName,i,this.config)}};function U(t,e){let i=e.properties;if(!i)return t;let r={...t};for(let[o,s]of Object.entries(r)){let n=i[o]?.type;if((n==="integer"||n==="number")&&typeof s=="string"){let p=s.trim();if(/^-?\d+(\.\d+)?$/.test(p)){let a=n==="integer"?parseInt(p,10):parseFloat(p);Number.isFinite(a)&&(r[o]=a)}}else n==="string"&&typeof s=="number"&&(r[o]=String(s))}return r}function ne(t,e,i){let r=[];for(let n of t)n.type==="text"&&n.text?r.push({text:n.text}):(n.type==="image"||n.type==="audio")&&n.mimeType&&n.data&&(r.push({text:`[Tool '${e}' provided the following ${n.type} data with mime-type: ${n.mimeType}]`}),r.push({inlineData:{mimeType:n.mimeType,data:n.data}}));let o=ae(i);return o&&r.push({text:`Structured result: ${o}`}),r.some(n=>n.inlineData!==void 0)?r:r.map(n=>n.text??"").filter(Boolean).join(`
95
+ `)}function se(t){return t.map(e=>e.type==="text"?e.text??"":"").filter(Boolean).join(`
96
+ `)}function ae(t){if(!t||typeof t!="object")return;let e={};for(let[i,r]of Object.entries(t))i!=="tree_markdown"&&(e[i]=r);if(Object.keys(e).length!==0)return f(e)}async function ze(t,e){for(let i of b){let r=m[i],o=`computer_use__${i}`;await t(o,async()=>new h(i,r,e))}}export{m as COMPUTER_USE_SCHEMAS,b as COMPUTER_USE_TOOL_NAMES,u as ComputerUseClient,h as ComputerUseTool,ze as registerComputerUseTools};
109
97
  /**
110
98
  * @license
111
99
  * Copyright 2025 Matilda Team
@@ -0,0 +1,38 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{a as p,c as f}from"./chunk-TXMXCR7D.js";import{a as y}from"./chunk-YULUB745.js";import{a as s}from"./chunk-NO6BFSGG.js";import"./chunk-GT6MSEK4.js";import"./chunk-J6NYCXUR.js";import{ka as c,la as d,ra as n,sa as h}from"./chunk-4SDFTVQW.js";import"./chunk-HEJO7OBH.js";import{b as m}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";m();var a=class extends c{constructor(e,t){super(t);this.config=e}getDescription(){return`${this.params.cron}: ${this.params.prompt}`}async getDefaultPermission(){return"ask"}async execute(){let e=this.config.getCronScheduler(),t=this.params.recurring!==!1,i=this.params.durable===!0;try{p(this.params.cron),f(this.params.cron,new Date);let r=i?await e.createDurable(this.params.cron,this.params.prompt,t):e.create(this.params.cron,this.params.prompt,t),o=y(r.cronExpr),w=`Scheduled ${r.id} (${o})${i?" [durable]":""}`,u=i?`Persisted to ${s}`:"Session-only (not written to disk, dies when Matilda exits)";return{llmContent:t?`Scheduled recurring job ${r.id} (${r.cronExpr}). ${u}. Auto-expires after 7 days. Use ${n.CRON_DELETE} to cancel sooner.`:`Scheduled one-shot task ${r.id} (${r.cronExpr}). ${u}. It will fire once then auto-delete.`,returnDisplay:w}}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error creating cron job: ${o}`,returnDisplay:o,error:{message:o}}}}},g=class l extends d{constructor(e){super(l.Name,h.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
4
+
5
+ Uses standard 5-field cron in the user's local timezone: minute hour day-of-month month day-of-week. "0 9 * * *" means 9am local \u2014 no timezone conversion needed.
6
+
7
+ ## One-shot tasks (recurring: false)
8
+
9
+ For "remind me at X" or "at <time>, do Y" requests \u2014 fire once then auto-delete.
10
+ Pin minute/hour/day-of-month/month to specific values:
11
+ "remind me at 2:30pm today to check the deploy" \u2192 cron: "30 14 <today_dom> <today_month> *", recurring: false
12
+ "tomorrow morning, run the smoke test" \u2192 cron: "57 8 <tomorrow_dom> <tomorrow_month> *", recurring: false
13
+
14
+ ## Recurring jobs (recurring: true, the default)
15
+
16
+ For "every N minutes" / "every hour" / "weekdays at 9am" requests:
17
+ "*/5 * * * *" (every 5 min), "0 * * * *" (hourly), "0 9 * * 1-5" (weekdays at 9am local)
18
+
19
+ ## Avoid the :00 and :30 minute marks when the task allows it
20
+
21
+ Every user who asks for "9am" gets \`0 9\`, and every user who asks for "hourly" gets \`0 *\` \u2014 which means requests from across the planet land on the API at the same instant. When the user's request is approximate, pick a minute that is NOT 0 or 30:
22
+ "every morning around 9" \u2192 "57 8 * * *" or "3 9 * * *" (not "0 9 * * *")
23
+ "hourly" \u2192 "7 * * * *" (not "0 * * * *")
24
+ "in an hour or so, remind me to..." \u2192 pick whatever minute you land on, don't round
25
+
26
+ Only use minute 0 or 30 when the user names that exact time and clearly means it ("at 9:00 sharp", "at half past", coordinating with a meeting). When in doubt, nudge a few minutes early or late \u2014 the user will not notice, and the fleet will.
27
+
28
+ ## Durability
29
+
30
+ By default (durable: false) the job lives only in this Matilda session \u2014 nothing is written to disk, and the job is gone when Matilda exits. Pass durable: true to write to ${s} so the job survives restarts. Only use durable: true when the user explicitly asks for persistence ("keep doing this every day", "set this up permanently"). Most "remind me in 5 minutes" requests should stay session-only.
31
+
32
+ ## Runtime behavior
33
+
34
+ Jobs only fire while the REPL is idle (not mid-query). The scheduler adds a small deterministic jitter on top of whatever you pick: recurring tasks fire up to 10% of their period late (max 15 min); one-shot tasks landing on :00 or :30 fire up to 90 s early. Picking an off-minute is still the bigger lever.
35
+
36
+ Recurring tasks auto-expire after 7 days \u2014 they fire one final time, then are deleted. This bounds how long a forgotten schedule keeps firing. Tell the user about the 7-day limit when scheduling recurring jobs.
37
+
38
+ Returns a job ID you can pass to ${n.CRON_DELETE}.`,"other",{type:"object",properties:{cron:{type:"string",description:'Standard 5-field cron expression in local time: "M H DoM Mon DoW" (e.g. "*/5 * * * *" = every 5 minutes, "30 14 28 2 *" = Feb 28 at 2:30pm local once).'},prompt:{type:"string",description:"The prompt to enqueue at each fire time."},recurring:{type:"boolean",description:'true (default) = fire on every cron match until deleted or auto-expired after 7 days. false = fire once at the next match, then auto-delete. Use false for "remind me at X" one-shot requests with pinned minute/hour/dom/month.'},durable:{type:"boolean",description:`true = persist to ${s} and survive restarts. false (default) = in-memory only, dies when Matilda exits. Use true only when the user asks the task to survive across sessions.`}},required:["cron","prompt"],additionalProperties:!1},!0,!1,!0,!1,"cron schedule reminder recurring timer");this.config=e}static Name=n.CRON_CREATE;createInvocation(e){return new a(this.config,e)}toAutoClassifierInput(e){return{cron:e.cron,prompt:e.prompt,recurring:e.recurring??!0,durable:e.durable??!1}}};export{g as CronCreateTool};
@@ -0,0 +1,3 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{a as d,f as u}from"./chunk-NO6BFSGG.js";import"./chunk-GT6MSEK4.js";import"./chunk-J6NYCXUR.js";import{e as n,ka as l,la as c,ra as m,sa as p}from"./chunk-4SDFTVQW.js";import"./chunk-HEJO7OBH.js";import{b as i}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";i();var s=class extends l{constructor(r,o){super(o);this.config=r}getDescription(){return this.params.id}async execute(){let r=this.config.getCronScheduler(),o;try{o=await r.delete(this.params.id),o||(o=await u(this.config.getProjectRoot(),[this.params.id])>0)}catch(e){let t=`Failed to cancel job ${this.params.id}: ${n(e)}`;return{llmContent:t,returnDisplay:t,error:{message:t}}}if(o){let e=`Cancelled job ${this.params.id}.`,t=`Cancelled ${this.params.id}`;return{llmContent:e,returnDisplay:t}}else{let e=`Job ${this.params.id} not found.`;return{llmContent:e,returnDisplay:e,error:{message:e}}}}},f=class a extends c{constructor(r){super(a.Name,p.CRON_DELETE,`Cancel a cron job previously scheduled with CronCreate. Removes it from the in-memory session store or from ${d} (durable jobs).`,"other",{type:"object",properties:{id:{type:"string",description:"Job ID returned by CronCreate."}},required:["id"],additionalProperties:!1},!0,!1,!0,!1,"cron delete cancel remove");this.config=r}static Name=m.CRON_DELETE;createInvocation(r){return new s(this.config,r)}};export{f as CronDeleteTool};
@@ -0,0 +1,5 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{a as m}from"./chunk-YULUB745.js";import{a as d,c as g}from"./chunk-NO6BFSGG.js";import"./chunk-GT6MSEK4.js";import"./chunk-J6NYCXUR.js";import{ka as l,la as c,ra as p,sa as u}from"./chunk-4SDFTVQW.js";import"./chunk-HEJO7OBH.js";import{b as a}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";a();var s=class extends l{constructor(e,t){super(t);this.config=e}getDescription(){return""}async execute(){let e=this.config.getCronScheduler(),t;try{t=await g(this.config.getProjectRoot())}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error listing cron jobs: ${o}`,returnDisplay:o,error:{message:o}}}let n=[...t.map(r=>({id:r.id,cron:r.cron,prompt:r.prompt,recurring:r.recurring,durable:!0})),...e.list().filter(r=>!r.durable).map(r=>({id:r.id,cron:r.cronExpr,prompt:r.prompt,recurring:r.recurring,durable:!1}))];if(n.length===0){let r="No active cron jobs.";return{llmContent:r,returnDisplay:r}}let y=n.map(r=>{let o=r.recurring?"recurring":"one-shot",h=r.durable?"durable":"session-only";return`${r.id} \u2014 ${r.cron} (${o}) [${h}]: ${r.prompt}`}).join(`
4
+ `),T=n.map(r=>`${r.id} ${m(r.cron)} [${r.durable?"durable":"session-only"}]`).join(`
5
+ `);return{llmContent:y,returnDisplay:T}}},f=class i extends c{constructor(e){super(i.Name,u.CRON_LIST,`List all cron jobs scheduled via CronCreate, both session-only and durable (${d}).`,"other",{type:"object",properties:{},additionalProperties:!1},!0,!1,!0,!1,"cron list scheduled jobs");this.config=e}static Name=p.CRON_LIST;createInvocation(e){return new s(this.config,e)}};export{f as CronListTool};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as T}from"./chunk-E2KMVG7F.js";import{Cb as L,Db as Q,Nb as M,Ob as S,Sb as Y,Tb as J,Ub as Z,Va as V,Vb as ee,ja as R}from"./chunk-3IG6LNQ3.js";import"./chunk-FY3LL4OC.js";import"./chunk-BQDEPKIG.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DZKI2CAC.js";import"./chunk-ZUQRP3N6.js";import"./chunk-OWEBLTAN.js";import"./chunk-VWE5BSHV.js";import"./chunk-L2FKLLEC.js";import"./chunk-N2BE647T.js";import"./chunk-QXSBPCBA.js";import"./chunk-HRD7WD3P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-55YW6EUC.js";import"./chunk-REUZDMLM.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-3BT7ZYAM.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import{C as A,Db as K,H as j,db as D,xa as z,z as H}from"./chunk-OF7ORAN6.js";import{l as B,m as X,n as q}from"./chunk-HJK3NKAR.js";import"./chunk-46FFWNRO.js";import"./chunk-BS7Q7KA6.js";import"./chunk-MZ73LBEY.js";import"./chunk-PFXCFIHY.js";import{a as G}from"./chunk-XPVKH5TC.js";import{g as W,m as F,n as U}from"./chunk-P24OL22U.js";import{D as y,E as P,G as $,c as x,ea as k}from"./chunk-WL27X35X.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";b();import*as _ from"node:fs";import*as p from"node:path";b();var le={"\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\u2014":"-","\u2015":"-","\u2212":"-","\u2018":"'","\u2019":"'","\u201A":"'","\u201B":"'","\u201C":'"',"\u201D":'"',"\u201E":'"',"\u201F":'"',"\xA0":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2007":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u202F":" ","\u205F":" ","\u3000":" "},me=new RegExp(`[${Object.keys(le).join("")}]`,"g");function E(n){return n.replace(me,t=>le[t])}var _e=[n=>n,n=>n.trimEnd()];function Ee(n){return E(n).trimEnd()}function te(n,t,i){if(t.length===0)return 0;if(t.length>n.length)return null;e:for(let e=0;e<=n.length-t.length;e++){for(let r=0;r<t.length;r++)if(i(n[e+r])!==i(t[r]))continue e;return e}return null}function we(n){let t=n.split(`
3
+ import{a as T}from"./chunk-VBZS7ARJ.js";import{$a as Q,Y as V,_a as L,jb as M,kb as S,m as R,ob as Y,pb as J,qb as Z,rb as ee}from"./chunk-BEP4F3GO.js";import"./chunk-HK3QQSM7.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NO6BFSGG.js";import"./chunk-R373GBK6.js";import"./chunk-VNSW4TSX.js";import"./chunk-EEPSTT7K.js";import"./chunk-DERMLVT6.js";import"./chunk-JZMGEGR6.js";import"./chunk-JVQHQDDE.js";import"./chunk-QXSBPCBA.js";import"./chunk-WAZCC4SE.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-TVNM3PQ7.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-N3AQRPV5.js";import"./chunk-LBQNFSZ2.js";import{C as A,H as j,Pb as K,db as D,xa as z,z as H}from"./chunk-GDRS4OWI.js";import"./chunk-B7BF33U4.js";import{l as B,m as X,n as q}from"./chunk-M5ABGGE7.js";import"./chunk-QKAKC34Q.js";import"./chunk-T6MRYRLI.js";import"./chunk-3EQIOCSJ.js";import{a as G}from"./chunk-XPVKH5TC.js";import"./chunk-J6NYCXUR.js";import"./chunk-UM6CLO7D.js";import"./chunk-YUCEPXGG.js";import{D as y,E as P,G as $,c as x,ea as k,la as W,ra as F,sa as U}from"./chunk-4SDFTVQW.js";import"./chunk-HEJO7OBH.js";import{b}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";b();import*as _ from"node:fs";import*as p from"node:path";b();var le={"\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\u2014":"-","\u2015":"-","\u2212":"-","\u2018":"'","\u2019":"'","\u201A":"'","\u201B":"'","\u201C":'"',"\u201D":'"',"\u201E":'"',"\u201F":'"',"\xA0":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2007":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u202F":" ","\u205F":" ","\u3000":" "},me=new RegExp(`[${Object.keys(le).join("")}]`,"g");function E(n){return n.replace(me,t=>le[t])}var _e=[n=>n,n=>n.trimEnd()];function Ee(n){return E(n).trimEnd()}function te(n,t,i){if(t.length===0)return 0;if(t.length>n.length)return null;e:for(let e=0;e<=n.length-t.length;e++){for(let r=0;r<t.length;r++)if(i(n[e+r])!==i(t[r]))continue e;return e}return null}function we(n){let t=n.split(`
4
4
  `),i=new Array(t.length+1),e=0;for(let r=0;r<t.length;r++)i[r]=e,e+=t[r].length,r<t.length-1&&(e+=1);return i[t.length]=n.length,{lines:t,offsets:i}}function ne(n,t,i,e,r,o){if(r===0)return o?`
5
5
  `:"";let l=t[e]??0,s=e+r-1,f=(t[s]??0)+(i[s]?.length??0);if(o){let g=t[e+r];g!==void 0?f=g:n.endsWith(`
6
6
  `)&&(f=n.length)}return n.slice(l,f)}function ye(n,t){let{lines:i,offsets:e}=we(n),r=t.split(`