@maincode-ai/matilda-code 0.21.10-preview.0 → 0.21.10-preview.1

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 (106) hide show
  1. package/bundled/mainy/docs/configuration/settings.md +9 -0
  2. package/chunks/agent-XXSEYARS.js +3 -0
  3. package/chunks/agent-headless-YBWTAFUH.js +3 -0
  4. package/chunks/{anthropicContentGenerator-SFJGSZHT.js → anthropicContentGenerator-IYZILRDW.js} +1 -1
  5. package/chunks/{askUserQuestion-G2H4VCRY.js → askUserQuestion-XWHJY3DM.js} +1 -1
  6. package/chunks/{chunk-INAZKGGR.js → chunk-2HQMJ2IU.js} +1 -1
  7. package/chunks/chunk-2W6MZZHZ.js +39 -0
  8. package/chunks/{todoWrite-3XJNFIBR.js → chunk-4CSSDBOS.js} +2 -2
  9. package/chunks/{chunk-5PMMY47S.js → chunk-4FVBPNTZ.js} +1 -1
  10. package/chunks/{chunk-TFWOXSAP.js → chunk-4TQ7ABLG.js} +14 -14
  11. package/chunks/{chunk-X6BEBYGX.js → chunk-66NIIU2R.js} +9 -9
  12. package/chunks/{chunk-32PTAACU.js → chunk-ELH4YHJR.js} +1 -1
  13. package/chunks/{chunk-FWIVFCKF.js → chunk-FFFZ2QMG.js} +1 -1
  14. package/chunks/{chunk-KSNBNXBC.js → chunk-FRRBNNEB.js} +48 -48
  15. package/chunks/{chunk-EQEQPZLQ.js → chunk-GO2GA2GY.js} +1 -1
  16. package/chunks/{chunk-QHA3ZBRO.js → chunk-GUFIMKF5.js} +1 -1
  17. package/chunks/{chunk-H6WMNUW2.js → chunk-HOCFKXNJ.js} +1 -1
  18. package/chunks/{chunk-VWWEEU4V.js → chunk-JXUDKX6D.js} +1 -1
  19. package/chunks/{chunk-VLYRNOD3.js → chunk-MH2P4YXC.js} +10 -10
  20. package/chunks/{chunk-6Q6PMGBD.js → chunk-MKFQMX37.js} +1 -1
  21. package/chunks/{chunk-VYTYYCBR.js → chunk-NYEWHSBL.js} +1 -1
  22. package/chunks/{chunk-LIWYWWOK.js → chunk-ODZOYHIC.js} +1 -1
  23. package/chunks/{chunk-Q2I3ARPJ.js → chunk-QH7736R5.js} +1 -1
  24. package/chunks/chunk-QN6WSWMM.js +9 -0
  25. package/chunks/{chunk-RJX7DK4Y.js → chunk-S4UT3QLV.js} +1 -1
  26. package/chunks/chunk-SNLH42QJ.js +10 -0
  27. package/chunks/{chunk-SE3XDSIJ.js → chunk-SPW5DXX4.js} +1 -1
  28. package/chunks/{chunk-S7G6QPEP.js → chunk-SUH3UUWZ.js} +1 -1
  29. package/chunks/{chunk-PIFQEMZZ.js → chunk-T4P4KEDW.js} +8 -8
  30. package/chunks/chunk-TO3ID3JW.js +35 -0
  31. package/chunks/{chunk-6ZMDAPGZ.js → chunk-VVIJGBQK.js} +566 -545
  32. package/chunks/{chunk-DCQKJTAX.js → chunk-W5CGKUM4.js} +8 -3
  33. package/chunks/{chunk-2PPJ3MJT.js → chunk-WHG6N5X2.js} +1 -1
  34. package/chunks/{chunk-GWGQRU36.js → chunk-WJO3QSBJ.js} +1 -1
  35. package/chunks/{chunk-XCJYORZX.js → chunk-XCFLI3OC.js} +1 -1
  36. package/chunks/{chunk-IJUI5A6G.js → chunk-YMIF2DMT.js} +1 -1
  37. package/chunks/chunk-YSIECQIZ.js +113 -0
  38. package/chunks/{computer-use-QN46FSNK.js → computer-use-HX2LYMYD.js} +7 -7
  39. package/chunks/contextCommand-W7DBC37U.js +3 -0
  40. package/chunks/{cron-create-MILWOYF6.js → cron-create-2UI4AT4Q.js} +1 -1
  41. package/chunks/{cron-delete-IEOPMRWP.js → cron-delete-ZB6BOTFF.js} +1 -1
  42. package/chunks/{cron-list-GGBUA7S7.js → cron-list-YYAXNHB6.js} +1 -1
  43. package/chunks/{edit-7AZARQPL.js → edit-HFUF2RN3.js} +1 -1
  44. package/chunks/{enter-worktree-GKYG5CD2.js → enter-worktree-LFCL64PJ.js} +1 -1
  45. package/chunks/{enterPlanMode-ICTG6ULZ.js → enterPlanMode-TREN7ULJ.js} +1 -1
  46. package/chunks/{exit-worktree-ZWYXIEIC.js → exit-worktree-MH2J4P42.js} +1 -1
  47. package/chunks/{exitPlanMode-5BQ4MY5I.js → exitPlanMode-PQO3EFFT.js} +1 -1
  48. package/chunks/{geminiContentGenerator-APSI54U5.js → geminiContentGenerator-FE5UVAOZ.js} +1 -1
  49. package/chunks/glob-VZAYMEQA.js +22 -0
  50. package/chunks/goal-tools-JN27F5BA.js +12 -0
  51. package/chunks/grep-2VT5TSRU.js +22 -0
  52. package/chunks/{keychain-token-storage-HAFQQIXL.js → keychain-token-storage-54BNK6VH.js} +1 -1
  53. package/chunks/{ls-FQYKJYAK.js → ls-YWZU3FYL.js} +1 -1
  54. package/chunks/{lsp-FGMC4KSB.js → lsp-4CJDKEEC.js} +1 -1
  55. package/chunks/{matildaAgentContentGenerator-HVIGLQJZ.js → matildaAgentContentGenerator-EYETUHCZ.js} +1 -1
  56. package/chunks/matildaContentGenerator-IWKH3YC4.js +8 -0
  57. package/chunks/{matildaOAuth2-W2DQO2NK.js → matildaOAuth2-GRS5K3D4.js} +1 -1
  58. package/chunks/monitor-AMIVJKDL.js +32 -0
  59. package/chunks/notebook-edit-BQUXXNEO.js +17 -0
  60. package/chunks/{openaiContentGenerator-X6TFPZGL.js → openaiContentGenerator-4M7WBW3G.js} +1 -1
  61. package/chunks/read-file-FNJZCMIZ.js +3 -0
  62. package/chunks/ripGrep-UOEUWYVF.js +3 -0
  63. package/chunks/scheduler-ASQLD6BW.js +8 -0
  64. package/chunks/{send-message-5PJPE34J.js → send-message-OO2HAKCC.js} +1 -1
  65. package/chunks/{serve-24HVCLFM.js → serve-FIDAAJAB.js} +1 -1
  66. package/chunks/shell-S732E2W4.js +3 -0
  67. package/chunks/{skill-HWDNN7P7.js → skill-VXNOQCSI.js} +1 -1
  68. package/chunks/src-QZENX46P.js +3 -0
  69. package/chunks/{symbol-search-BSE3FWJX.js → symbol-search-ALYOX5JN.js} +1 -1
  70. package/chunks/{syntheticOutput-DX4NN34N.js → syntheticOutput-UASKABJH.js} +1 -1
  71. package/chunks/task-create-EBJD55TB.js +3 -0
  72. package/chunks/{task-detach-TGM25ZIU.js → task-detach-I67ZE5MX.js} +1 -1
  73. package/chunks/{task-list-AZLBAQVL.js → task-list-5BGX4G5N.js} +1 -1
  74. package/chunks/{task-stop-B5PTXVMO.js → task-stop-ERI5X4AO.js} +1 -1
  75. package/chunks/{task-update-ARPBRTC5.js → task-update-CD3W556L.js} +1 -1
  76. package/chunks/{team-create-D4N2QVBX.js → team-create-CXY3MRCE.js} +1 -1
  77. package/chunks/{team-delete-AGYMEW6E.js → team-delete-5U3GBFKJ.js} +1 -1
  78. package/chunks/todoWrite-YGG6AZ3A.js +3 -0
  79. package/chunks/{tool-search-LRVN3W5W.js → tool-search-AJ57WSJC.js} +1 -1
  80. package/chunks/{web-fetch-Y64RF72K.js → web-fetch-63M6GZQL.js} +1 -1
  81. package/chunks/{web-search-I3D4EN5B.js → web-search-OX2DPEVN.js} +1 -1
  82. package/chunks/{workflow-BSK53DUN.js → workflow-55OAJ6XH.js} +2 -2
  83. package/chunks/write-file-2TWXQRDB.js +15 -0
  84. package/cli.js +459 -462
  85. package/package.json +2 -2
  86. package/chunks/agent-U43GELHB.js +0 -3
  87. package/chunks/agent-headless-7STBERN4.js +0 -3
  88. package/chunks/chunk-2NBII5ND.js +0 -34
  89. package/chunks/chunk-BN2CPSZ5.js +0 -34
  90. package/chunks/chunk-HMZOLFRP.js +0 -10
  91. package/chunks/chunk-ROETRE5J.js +0 -9
  92. package/chunks/chunk-XJYPRCV7.js +0 -108
  93. package/chunks/contextCommand-7G5FHBBE.js +0 -3
  94. package/chunks/glob-NPEYXTA6.js +0 -22
  95. package/chunks/grep-4NQTKAN6.js +0 -22
  96. package/chunks/matildaContentGenerator-5VOBYNAJ.js +0 -8
  97. package/chunks/monitor-RMKMKOUY.js +0 -32
  98. package/chunks/notebook-edit-H3ZFKBLR.js +0 -17
  99. package/chunks/read-file-3J3ZMBI2.js +0 -3
  100. package/chunks/ripGrep-WDYTLRCE.js +0 -3
  101. package/chunks/scheduler-TKK5QECI.js +0 -8
  102. package/chunks/shell-YPEMRDRO.js +0 -3
  103. package/chunks/src-W5VAKS5Y.js +0 -3
  104. package/chunks/task-create-3PW7T36X.js +0 -3
  105. package/chunks/update-goal-KLUMJFUA.js +0 -16
  106. package/chunks/write-file-GDKSQBMU.js +0 -15
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Af as X,Cf as H,Pi as K}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{i as S}from"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as B,i as G}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as ye}from"node:os";d();import{join as I}from"node:path";import{homedir as R}from"node:os";var l="0.5.2",ue="https://matilda.maincode.com/assets/computer-use",me="https://github.com/trycua/cua/releases/download";function E(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 U(e,t=process.env,o=l){let r=[],i=t.MATILDA_COMPUTER_USE_DOWNLOAD_HOST;return i&&r.push(`${ge(i)}/cua-driver-rs/v${o}/${e}`),r.push(`${ue}/cua-driver-rs/v${o}/${e}`),r.push(`${me}/cua-driver-rs-v${o}/${e}`),r}function J(e=process.env,t=l){return U("checksums.txt",e,t)}var he="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function V(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 Y(e,t=process.env){let o=V(t[he]);return o!==void 0?o:V(e)}function fe(e=R()){return I(e,".matilda","computer-use")}function N(e=R(),t=l){return I(fe(e),`cua-driver-rs-${t}`)}function u(e=R(),t=process.platform,o=process.arch,r=l){let i=E(t,o,r);return I(N(e,r),i.extractDir,i.binaryRelPath)}function h(e=l){return`cua-driver-rs@${e}`}function ge(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(ye())})),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 H({command:this.binary,args:["mcp"],env:{...process.env}}),i=new X({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(!Q(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(!Q(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 Q(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 M=["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{Af as H,Cf as K,Ne as x,Oi as V}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{i as S}from"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as G,i as X}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as we}from"node:os";d();import{join as R}from"node:path";import{homedir as E}from"node:os";var l="0.5.2",me="https://matilda.maincode.com/assets/computer-use",he="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(`${ye(i)}/cua-driver-rs/v${o}/${e}`),r.push(`${me}/cua-driver-rs/v${o}/${e}`),r.push(`${he}/cua-driver-rs-v${o}/${e}`),r}function Y(e=process.env,t=l){return N("checksums.txt",e,t)}var fe="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function J(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 Q(e,t=process.env){let o=J(t[fe]);return o!==void 0?o:J(e)}function ge(e=E()){return R(e,".matilda","computer-use")}function M(e=E(),t=l){return R(ge(e),`cua-driver-rs-${t}`)}function u(e=E(),t=process.platform,o=process.arch,r=l){let i=U(t,o,r);return R(M(e,r),i.extractDir,i.binaryRelPath)}function h(e=l){return`cua-driver-rs@${e}`}function ye(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(we())})),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: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(!Z(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(!Z(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 Z(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.
4
4
 
5
5
  Two addressing modes:
6
6
 
@@ -87,15 +87,15 @@ 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 Fe,spawnSync as j}from"node:child_process";import{promisify as Le}from"node:util";import{rmSync as qe}from"node:fs";import{homedir as $}from"node:os";import{join as ze}from"node:path";d();import{readFile as we,writeFile as _e,mkdir as ve}from"node:fs/promises";import{homedir as x}from"node:os";import{join as be,dirname as Se}from"node:path";function Z(e=x()){return be(e,".matilda","computer-use","installed.json")}async function xe(e=x()){try{let t=await we(Z(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 C(e=x(),t){let o=Z(e);await ve(Se(o),{recursive:!0}),await _e(o,JSON.stringify(t,null,2),"utf8")}async function P(e=x(),t){return(await xe(e))?.approvedPackageSpec===t}d();import{createHash as Ce}from"node:crypto";import{createWriteStream as Pe}from"node:fs";import{mkdir as ee,rm as k,stat as ke,chmod as Te,rename as De}from"node:fs/promises";import{join as T}from"node:path";import{tmpdir as Ae}from"node:os";import{pipeline as Oe}from"node:stream/promises";import{Readable as Ie}from"node:stream";function Re(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 Ee(e,t=process.platform,o=process.arch,r=l){let i=u(e,t,o,r);try{if((await ke(i)).isFile())return i}catch{}}async function te(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 ie(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 Ee(e.home,t,o,r);if(a)return a;let p=E(t,o,r);s?.("Downloading Computer Use driver (~20MB, one time)...");let{res:c}=await te(J(i,r),n),D=Re(await c.text()).get(p.asset);if(!D)throw new Error(`Computer Use: ${p.asset} missing from checksums.txt.`);let{res:de}=await te(U(p.asset,i,r),n,s);await ee(re(e.home),{recursive:!0});let w=T(re(e.home),p.asset),F=Ce("sha256"),A=Ie.fromWeb(de.body),O,L=()=>{clearTimeout(O),O=setTimeout(()=>{A.destroy(new Error("download stalled: no data for 60s"))},6e4)};A.on("data",b=>{F.update(b),L()}),L();try{await Oe(A,Pe(w))}finally{clearTimeout(O)}let q=F.digest("hex");if(q!==D)throw await k(w,{force:!0}),new Error(`Computer Use: checksum mismatch for ${p.asset} (expected ${D.slice(0,12)}\u2026, got ${q.slice(0,12)}\u2026).`);let _=N(e.home,r),v=`${_}.staging`;await k(v,{recursive:!0,force:!0}),await ee(v,{recursive:!0}),await je(w,v,p.asset,e.unzipImpl),await k(w,{force:!0}),await k(_,{recursive:!0,force:!0}),await De(v,_);let z=u(e.home,t,o,r);if(t!=="win32"&&await Te(z,493),t==="darwin"&&p.hasApp){let b=T(_,p.extractDir),le=T(b,"CuaDriver.app");await Me(b),await Ne(le)}return s?.("Computer Use driver ready."),z}var Ue="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister";async function Ne(e){try{let{execFile:t}=await import("node:child_process"),{promisify:o}=await import("node:util");await o(t)(Ue,["-f",e],{timeout:15e3})}catch{}}function re(e){return T(Ae(),"matilda-computer-use-dl",Buffer.from(e).toString("hex").slice(0,8))}async function Me(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 je(e,t,o,r){o.endsWith(".zip")?await(r??$e)(e,t):await K({file:e,cwd:t})}async function $e(e,t){let{execFile:o}=await import("node:child_process"),{promisify:r}=await import("node:util"),i=r(o),n=`Expand-Archive -LiteralPath ${oe(e)} -DestinationPath ${oe(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]}: ${We(m)}`)}throw new Error(`Computer Use: failed to unzip ${e} on Windows (${a.join("; ")}).`)}function oe(e){return`'${e.replace(/'/g,"''")}'`}function We(e){return e instanceof Error?e.message:String(e)}var Be=Le(Fe);function Ge(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 Xe=()=>ze($(),"Library","Caches","cua-driver","cua-driver.sock");function se(){try{j("pkill",["-f","CuaDriver.app/Contents/MacOS/cua-driver serve"],{stdio:"ignore"})}catch{}try{qe(Xe(),{force:!0})}catch{}}async function He(){try{let{stdout:e}=await Be(u($()),["permissions","status","--json"],{timeout:1e4,env:process.env});return Ge(e)}catch{return"unknown"}}function Ke(){se();try{j("open",["-n","-g","-a","CuaDriver","--args","serve","--no-permissions-gate"],{stdio:"ignore"})}catch{}return{kill:se}}function Ve(e){let t=e==="accessibility"?"Privacy_Accessibility":"Privacy_ScreenCapture";try{j("open",[`x-apple.systempreferences:com.apple.preference.security?${t}`],{stdio:"ignore"})}catch{}}function Je(){let e=$();return{homeDir:e,approvalKey:h(),platform:process.platform,promptInstallApproval:async t=>(process.stderr.write(`
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 Le,spawnSync as $}from"node:child_process";import{promisify as qe}from"node:util";import{rmSync as ze}from"node:fs";import{homedir as W}from"node:os";import{join as Be}from"node:path";d();import{readFile as _e,writeFile as ve,mkdir as be}from"node:fs/promises";import{homedir as C}from"node:os";import{join as Se,dirname as xe}from"node:path";function ee(e=C()){return Se(e,".matilda","computer-use","installed.json")}async function Ce(e=C()){try{let t=await _e(ee(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=ee(e);await be(xe(o),{recursive:!0}),await ve(o,JSON.stringify(t,null,2),"utf8")}async function k(e=C(),t){return(await Ce(e))?.approvedPackageSpec===t}d();import{createHash as Pe}from"node:crypto";import{createWriteStream as ke}from"node:fs";import{mkdir as te,rm as T,stat as Te,chmod as De,rename as Ae}from"node:fs/promises";import{join as D}from"node:path";import{tmpdir as Oe}from"node:os";import{pipeline as Ie}from"node:stream/promises";import{Readable as Re}from"node:stream";function Ee(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 Ue(e,t=process.platform,o=process.arch,r=l){let i=u(e,t,o,r);try{if((await Te(i)).isFile())return i}catch{}}async function re(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 se(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 Ue(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 re(Y(i,r),n),A=Ee(await c.text()).get(p.asset);if(!A)throw new Error(`Computer Use: ${p.asset} missing from checksums.txt.`);let{res:le}=await re(N(p.asset,i,r),n,s);await te(oe(e.home),{recursive:!0});let w=D(oe(e.home),p.asset),L=Pe("sha256"),O=Re.fromWeb(le.body),I,q=()=>{clearTimeout(I),I=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,ke(w))}finally{clearTimeout(I)}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 te(v,{recursive:!0}),await $e(w,v,p.asset,e.unzipImpl),await T(w,{force:!0}),await T(_,{recursive:!0,force:!0}),await Ae(v,_);let B=u(e.home,t,o,r);if(t!=="win32"&&await De(B,493),t==="darwin"&&p.hasApp){let b=D(_,p.extractDir),ue=D(b,"CuaDriver.app");await je(b),await Me(ue)}return s?.("Computer Use driver ready."),B}var Ne="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister";async function Me(e){try{let{execFile:t}=await import("node:child_process"),{promisify:o}=await import("node:util");await o(t)(Ne,["-f",e],{timeout:15e3})}catch{}}function oe(e){return D(Oe(),"matilda-computer-use-dl",Buffer.from(e).toString("hex").slice(0,8))}async function je(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 $e(e,t,o,r){o.endsWith(".zip")?await(r??We)(e,t):await V({file:e,cwd:t})}async function We(e,t){let{execFile:o}=await import("node:child_process"),{promisify:r}=await import("node:util"),i=r(o),n=`Expand-Archive -LiteralPath ${ie(e)} -DestinationPath ${ie(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]}: ${Fe(m)}`)}throw new Error(`Computer Use: failed to unzip ${e} on Windows (${a.join("; ")}).`)}function ie(e){return`'${e.replace(/'/g,"''")}'`}function Fe(e){return e instanceof Error?e.message:String(e)}var Ge=qe(Le);function Xe(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 He=()=>Be(W(),"Library","Caches","cua-driver","cua-driver.sock");function ne(){try{$("pkill",["-f","CuaDriver.app/Contents/MacOS/cua-driver serve"],{stdio:"ignore"})}catch{}try{ze(He(),{force:!0})}catch{}}async function Ke(){try{let{stdout:e}=await Ge(u(W()),["permissions","status","--json"],{timeout:1e4,env:x()});return Xe(e)}catch{return"unknown"}}function Ve(){ne();try{$("open",["-n","-g","-a","CuaDriver","--args","serve","--no-permissions-gate"],{stdio:"ignore"})}catch{}return{kill:ne}}function Je(e){let t=e==="accessibility"?"Privacy_Accessibility":"Privacy_ScreenCapture";try{$("open",[`x-apple.systempreferences:com.apple.preference.security?${t}`],{stdio:"ignore"})}catch{}}function Ye(){let e=W();return{homeDir:e,approvalKey:h(),platform:process.platform,promptInstallApproval:async t=>(process.stderr.write(`
92
92
  [Computer Use] First-time setup
93
93
  Driver: ${t}
94
94
  This downloads a ~20MB signed + notarized binary into ~/.matilda/computer-use/.
95
95
  Computer Use can click, type, and read your desktop apps in the background.
96
96
  On macOS you'll be guided through Accessibility and Screen Recording permissions next.
97
97
  Set MATILDA_COMPUTER_USE_AUTO_APPROVE=1 to skip this prompt.
98
- `),process.env.MATILDA_COMPUTER_USE_AUTO_APPROVE==="1"),install:t=>ie({home:e,onProgress:t}),startStatusDaemon:Ke,probePermissions:He,openPermissionPane:Ve}}async function ne(e,t,o){let r={...Je(),...o},i=r.pollIntervalMs??5e3,n=r.pollTimeoutMs??10*6e4;if(e.isStarted())return;if(!await P(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 C(r.homeDir,{approvedPackageSpec:r.approvalKey,approvedAtIso:new Date().toISOString()})}await r.install(t.updateOutput),r.platform==="darwin"&&await Ye(r,t,i,n),await e.start(t.updateOutput)}async function Ye(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 Qe(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 Qe=e=>new Promise(t=>setTimeout(t,e));import{homedir as ae}from"node:os";var Ze="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.",ce=new Set(["kill_app","launch_app","start_recording","set_config","replay_trajectory"]),et=new Set(["execute_javascript","enable_javascript_apple_events"]);for(let e of ce)if(!(e in g))throw new Error(`HIGH_RISK_TOOLS contains unknown tool: ${e}`);function tt(e,t){return ce.has(e)?!0:e==="page"&&et.has(t.action)}var W=class extends B{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 P(ae(),h()),n=async(p,c)=>{p!=="cancel"&&await C(ae(),{approvedPackageSpec:h(),approvedAtIso:new Date().toISOString()})};if(tt(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}
98
+ `),process.env.MATILDA_COMPUTER_USE_AUTO_APPROVE==="1"),install:t=>se({home:e,onProgress:t}),startStatusDaemon:Ve,probePermissions:Ke,openPermissionPane:Je}}async function ae(e,t,o){let r={...Ye(),...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 Qe(r,t,i,n),await e.start(t.updateOutput)}async function Qe(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 Ze(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 Ze=e=>new Promise(t=>setTimeout(t,e));import{homedir as pe}from"node:os";var et="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.",de=new Set(["kill_app","launch_app","start_recording","set_config","replay_trajectory"]),tt=new Set(["execute_javascript","enable_javascript_apple_events"]);for(let e of de)if(!(e in g))throw new Error(`HIGH_RISK_TOOLS contains unknown tool: ${e}`);function rt(e,t){return de.has(e)?!0:e==="page"&&tt.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(pe(),h()),n=async(p,c)=>{p!=="cancel"&&await P(pe(),{approvedPackageSpec:h(),approvedAtIso:new Date().toISOString()})};if(rt(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}
99
99
 
100
100
  Args: ${s}
101
101
 
@@ -103,9 +103,9 @@ This will act on your desktop via the Computer Use binary.`:`Tool: computer_use_
103
103
 
104
104
  Args: ${s}
105
105
 
106
- ${Ze}`;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(Y(this.config?.getComputerUseMaxImageDimension()));let n=!!this.config;await ne(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=rt(s.content,this.upstreamName,s.structuredContent),p=ot(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 G{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=pe(o,this.parameterSchema);return super.validateToolParams(r)}build(o){let r=pe(o,this.parameterSchema);return super.build(r)}createInvocation(o){return new W(this.upstreamName,o,this.config)}};function pe(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 rt(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=it(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 ot(e){return e.map(t=>t.type==="text"?t.text??"":"").filter(Boolean).join(`
108
- `)}function it(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 ir(e,t){for(let o of M){let r=g[o],i=`computer_use__${o}`;await e(i,async()=>new y(o,r,t))}}export{g as COMPUTER_USE_SCHEMAS,M as COMPUTER_USE_TOOL_NAMES,f as ComputerUseClient,y as ComputerUseTool,ir as registerComputerUseTools};
106
+ ${et}`;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(Q(this.config?.getComputerUseMaxImageDimension()));let n=!!this.config;await ae(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=ot(s.content,this.upstreamName,s.structuredContent),p=it(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=ce(o,this.parameterSchema);return super.validateToolParams(r)}build(o){let r=ce(o,this.parameterSchema);return super.build(r)}createInvocation(o){return new F(this.upstreamName,o,this.config)}};function ce(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 ot(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=st(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 it(e){return e.map(t=>t.type==="text"?t.text??"":"").filter(Boolean).join(`
108
+ `)}function st(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 ar(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,ar as registerComputerUseTools};
109
109
  /**
110
110
  * @license
111
111
  * Copyright 2025 Matilda Team
@@ -0,0 +1,3 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{c as a,d as b,e as c}from"./chunk-HOCFKXNJ.js";import"./chunk-WJO3QSBJ.js";import"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as collectContextData,c as contextCommand,b as formatContextUsageText};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
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 n}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as m,i as c,p as d,q as h}from"./chunk-PIFQEMZZ.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();var i=class extends m{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,s=this.params.durable===!0;try{p(this.params.cron),f(this.params.cron,new Date);let r=s?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})${s?" [durable]":""}`,l=s?`Persisted to ${n}`:"Session-only (not written to disk, dies when Matilda exits)";return{llmContent:t?`Scheduled recurring job ${r.id} (${r.cronExpr}). ${l}. Auto-expires after 7 days. Use CronDelete to cancel sooner.`:`Scheduled one-shot task ${r.id} (${r.cronExpr}). ${l}. 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 a extends c{constructor(e){super(a.Name,h.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
3
+ import{a as p,c as f}from"./chunk-TXMXCR7D.js";import{a as y}from"./chunk-YULUB745.js";import{a as n}from"./chunk-NYEWHSBL.js";import"./chunk-TISQNFB5.js";import{g as m,i as c,p as d,q as h}from"./chunk-T4P4KEDW.js";import"./chunk-GO2GA2GY.js";import"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();var i=class extends m{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,s=this.params.durable===!0;try{p(this.params.cron),f(this.params.cron,new Date);let r=s?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})${s?" [durable]":""}`,l=s?`Persisted to ${n}`:"Session-only (not written to disk, dies when Matilda exits)";return{llmContent:t?`Scheduled recurring job ${r.id} (${r.cronExpr}). ${l}. Auto-expires after 7 days. Use CronDelete to cancel sooner.`:`Scheduled one-shot task ${r.id} (${r.cronExpr}). ${l}. 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 a extends c{constructor(e){super(a.Name,h.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
4
4
 
5
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
6
 
@@ -1,3 +1,3 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as d,f as u}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p as m,q as p}from"./chunk-PIFQEMZZ.js";import"./chunk-EQEQPZLQ.js";import{d as n}from"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.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};
3
+ import{a as d,f as u}from"./chunk-NYEWHSBL.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p as m,q as p}from"./chunk-T4P4KEDW.js";import"./chunk-GO2GA2GY.js";import{d as n}from"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.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};
@@ -1,5 +1,5 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as m}from"./chunk-YULUB745.js";import{a as d,c as g}from"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p,q as u}from"./chunk-PIFQEMZZ.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.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(`
3
+ import{a as m}from"./chunk-YULUB745.js";import{a as d,c as g}from"./chunk-NYEWHSBL.js";import"./chunk-TISQNFB5.js";import{g as l,i as c,p,q as u}from"./chunk-T4P4KEDW.js";import"./chunk-GO2GA2GY.js";import"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.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
4
  `),T=n.map(r=>`${r.id} ${m(r.cron)} [${r.durable?"durable":"session-only"}]`).join(`
5
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 y}from"./chunk-5PMMY47S.js";import{$e as Q,Ce as K,Qe as R,Re as x,Xe as X,Ye as V,cf as Y,ka as I,ue as A,ve as G,xc as q}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{Lb as z,Oa as j,_c as H,ca as U,ha as N,wc as D}from"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as B}from"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{i as k,p as P,q as W}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{D as w,E as S,G as M,aa as $,b as C}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as T}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";T();import*as m from"node:fs";import*as u from"node:path";T();var se={"\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":" "};function L(n){if(n==="")return n;let t="";for(let i of n)t+=se[i]??i;return t}var ae=[n=>n,n=>n.trimEnd()];function ce(n){return L(n).trimEnd()}function J(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 fe(n){let t=n.split(`
3
+ import{a as y}from"./chunk-4FVBPNTZ.js";import{$e as Q,Ae as K,Qe as R,Re as x,Xe as X,Ye as V,cf as Y,ga as I,se as A,te as G,uc as q}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{Lb as z,Oa as j,_c as H,ca as U,ha as N,wc as D}from"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as B}from"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{i as k,p as P,q as W}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{D as w,E as S,G as M,b as C,ba as $}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as T}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";T();import*as m from"node:fs";import*as u from"node:path";T();var se={"\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":" "};function L(n){if(n==="")return n;let t="";for(let i of n)t+=se[i]??i;return t}var ae=[n=>n,n=>n.trimEnd()];function ce(n){return L(n).trimEnd()}function J(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 fe(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 Z(n,t,i,e,r,o){if(r===0)return o?`
5
5
  `:"";let f=t[e]??0,l=e+r-1,c=(t[l]??0)+(i[l]?.length??0);if(o){let g=t[e+r];g!==void 0?c=g:n.endsWith(`
6
6
  `)&&(c=n.length)}return n.slice(f,c)}function de(n,t){let{lines:i,offsets:e}=fe(n),r=t.split(`
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Wj as T,Yf as W,eg as s}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as $,i as E,p as m,q as R}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();var o=b("ENTER_WORKTREE"),P=`Creates an isolated git worktree at \`<projectRoot>/.matilda/worktrees/<slug>\` and returns its absolute path so subsequent file edits, shell commands, and other tools can operate inside it.
3
+ import{Yf as W,Yj as T,eg as s}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as $,i as E,p as m,q as R}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{ba as b}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();var o=b("ENTER_WORKTREE"),P=`Creates an isolated git worktree at \`<projectRoot>/.matilda/worktrees/<slug>\` and returns its absolute path so subsequent file edits, shell commands, and other tools can operate inside it.
4
4
 
5
5
  ## When to Use
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{dh as r}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as m,i as u,p as d,q as c}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as p}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as l}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";l();var y=p("ENTER_PLAN_MODE"),g=`Use this tool to lower into plan mode before doing uncertain or complex work. Entering plan mode is a privilege reduction, so it does not require user confirmation.
3
+ import{si as r}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as m,i as u,p as d,q as c}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{ba as p}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as l}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";l();var y=p("ENTER_PLAN_MODE"),g=`Use this tool to lower into plan mode before doing uncertain or complex work. Entering plan mode is a privilege reduction, so it does not require user confirmation.
4
4
 
5
5
  ## When to Use This Tool
6
6
  Use this tool when the task is not yet clear enough to safely execute, for example when it requires multi-file changes, design choices, investigation before a plan can be summarized, or when requirements are ambiguous. While investigating, if complexity rises or you find yourself repeatedly needing to ask the user, enter plan mode and consolidate a plan.
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Vj as C,Wf as k,Xj as x,Zf as W,eg as l}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as E,i as R,p as c,q as T}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b,b as $}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();import*as S from"node:fs/promises";var h=b("EXIT_WORKTREE"),O=`Exits a worktree previously created by ${c.ENTER_WORKTREE}.
3
+ import{Wf as k,Xj as C,Zf as W,Zj as x,eg as l}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as E,i as R,p as c,q as T}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{b as $,ba as b}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();import*as S from"node:fs/promises";var h=b("EXIT_WORKTREE"),O=`Exits a worktree previously created by ${c.ENTER_WORKTREE}.
4
4
 
5
5
  ## Behavior
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as k}from"./chunk-ILBTI4K5.js";import{Mf as E,dh as w,pg as M}from"./chunk-6ZMDAPGZ.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-TISQNFB5.js";import"./chunk-6Q6PMGBD.js";import"./chunk-MTMU7JYZ.js";import"./chunk-RNKDFE2S.js";import"./chunk-BN2CPSZ5.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-HMZOLFRP.js";import"./chunk-QKYGQLWC.js";import"./chunk-SE3XDSIJ.js";import"./chunk-VWWEEU4V.js";import"./chunk-HYVP4472.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-X6BEBYGX.js";import"./chunk-QHA3ZBRO.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import{g as G,i as R,p as T,q as _}from"./chunk-PIFQEMZZ.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as h}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as f}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";f();f();f();var $=h("GATE_REVIEW_AGENTS");function L(n){return`You are a Plan Design Reviewer for the Plan Approval Gate. Review the plan across three dimensions:
3
+ import{a as k}from"./chunk-ILBTI4K5.js";import{Mf as E,pg as M,si as w}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as G,i as R,p as T,q as _}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{ba as h}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as f}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";f();f();f();var $=h("GATE_REVIEW_AGENTS");function L(n){return`You are a Plan Design Reviewer for the Plan Approval Gate. Review the plan across three dimensions:
4
4
 
5
5
  1. **Request Fit** \u2014 Does the plan fulfill every part of the user's original request and respect all explicit constraints? Does it do anything the user explicitly asked NOT to do?
6
6
  2. **System Fit** \u2014 Does the plan align with the codebase structure, file paths, function names, permission model, and integration boundaries found during investigation?
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as g}from"./chunk-Q2I3ARPJ.js";import{g as u}from"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{f as d}from"./chunk-SDTWBD62.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as m}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";m();m();var p=class{googleGenAI;contentGeneratorConfig;constructor(e,t){let r=t?.customHeaders,n=r?(()=>{let i=e.httpOptions,s=i?.headers??{},l=Object.fromEntries(Object.entries(r).filter(([a])=>!d(a)));return{...e,httpOptions:{...i??{},headers:{...s,...l}}}})():e;this.googleGenAI=new u(n),this.contentGeneratorConfig=t}buildGenerateContentConfig(e){let t=this.contentGeneratorConfig?.samplingParams,r=e.config||{},n=(i,s,l)=>{let a=r[s];return i!==void 0?i:a!==void 0?a:l};return{...r,temperature:n(t?.temperature,"temperature",1),topP:n(t?.top_p,"topP",.95),topK:n(t?.top_k,"topK",64),maxOutputTokens:n(t?.max_tokens,"maxOutputTokens"),presencePenalty:n(t?.presence_penalty,"presencePenalty"),frequencyPenalty:n(t?.frequency_penalty,"frequencyPenalty"),thinkingConfig:n(this.buildThinkingConfig(),"thinkingConfig",{includeThoughts:!0,thinkingLevel:"THINKING_LEVEL_UNSPECIFIED"})}}buildThinkingConfig(){let e=this.contentGeneratorConfig?.reasoning;if(e===!1)return{includeThoughts:!1};if(e)return{includeThoughts:!0,thinkingLevel:e.effort==="low"?"LOW":e.effort==="high"||e.effort==="max"?"HIGH":"THINKING_LEVEL_UNSPECIFIED"}}async generateContent(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContent(r)}async generateContentStream(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContentStream(r)}stripUnsupportedFields(e){return!e||typeof e=="string"?e:Array.isArray(e)?e.map(t=>this.stripContentFields(t)):this.stripContentFields(e)}stripContentFields(e){if(typeof e=="string")return e;if(!("role"in e)&&!("parts"in e))return this.stripPartFields(e);let t=e;return t.parts?{...t,parts:t.parts.map(r=>this.stripPartFields(r))}:t}stripPartFields(e){if(typeof e=="string")return e;let t={...e};if(t.inlineData){let{displayName:r,...n}=t.inlineData;t.inlineData=n}if(t.fileData){let{displayName:r,...n}=t.fileData;t.fileData=n}if(t.functionResponse?.parts){let r=t.functionResponse.parts.map(n=>{let i=this.convertUnsupportedMediaToText(n);return this.stripPartFields(i)});t.functionResponse={...t.functionResponse,parts:r}}return t}convertUnsupportedMediaToText(e){if(typeof e=="string")return e;let t=e.inlineData?.mimeType||"",r=e.fileData?.mimeType||"";if(t.startsWith("audio/")||t.startsWith("video/")){let n=e.inlineData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${t}${i}.`}}if(r.startsWith("audio/")||r.startsWith("video/")){let n=e.fileData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${r}${i}.`}}return e}async countTokens(e){return this.googleGenAI.models.countTokens(e)}async embedContent(e){return this.googleGenAI.models.embedContent(e)}useSummarizedThinking(){return!0}};function T(o,e){let i={...{"User-Agent":o.userAgent||`MatildaCode/0.21.10-preview.0 (${process.platform}; ${process.arch})`}};if(e?.getUsageStatisticsEnabled()){let f=new g().getInstallationId();i={...i,"x-gemini-api-privileged-user-id":`${f}`}}let s=o.baseUrl?{headers:i,baseUrl:o.baseUrl}:{headers:i};return new p({apiKey:o.apiKey===""?void 0:o.apiKey,vertexai:o.vertexai,httpOptions:s},o)}export{p as GeminiContentGenerator,T as createGeminiContentGenerator};
3
+ import{a as g}from"./chunk-QH7736R5.js";import{g as u}from"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{f as d}from"./chunk-SDTWBD62.js";import"./chunk-GO2GA2GY.js";import"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.js";import{b as m}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";m();m();var p=class{googleGenAI;contentGeneratorConfig;constructor(e,t){let r=t?.customHeaders,n=r?(()=>{let i=e.httpOptions,s=i?.headers??{},l=Object.fromEntries(Object.entries(r).filter(([a])=>!d(a)));return{...e,httpOptions:{...i??{},headers:{...s,...l}}}})():e;this.googleGenAI=new u(n),this.contentGeneratorConfig=t}buildGenerateContentConfig(e){let t=this.contentGeneratorConfig?.samplingParams,r=e.config||{},n=(i,s,l)=>{let a=r[s];return i!==void 0?i:a!==void 0?a:l};return{...r,temperature:n(t?.temperature,"temperature",1),topP:n(t?.top_p,"topP",.95),topK:n(t?.top_k,"topK",64),maxOutputTokens:n(t?.max_tokens,"maxOutputTokens"),presencePenalty:n(t?.presence_penalty,"presencePenalty"),frequencyPenalty:n(t?.frequency_penalty,"frequencyPenalty"),thinkingConfig:n(this.buildThinkingConfig(),"thinkingConfig",{includeThoughts:!0,thinkingLevel:"THINKING_LEVEL_UNSPECIFIED"})}}buildThinkingConfig(){let e=this.contentGeneratorConfig?.reasoning;if(e===!1)return{includeThoughts:!1};if(e)return{includeThoughts:!0,thinkingLevel:e.effort==="low"?"LOW":e.effort==="high"||e.effort==="max"?"HIGH":"THINKING_LEVEL_UNSPECIFIED"}}async generateContent(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContent(r)}async generateContentStream(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContentStream(r)}stripUnsupportedFields(e){return!e||typeof e=="string"?e:Array.isArray(e)?e.map(t=>this.stripContentFields(t)):this.stripContentFields(e)}stripContentFields(e){if(typeof e=="string")return e;if(!("role"in e)&&!("parts"in e))return this.stripPartFields(e);let t=e;return t.parts?{...t,parts:t.parts.map(r=>this.stripPartFields(r))}:t}stripPartFields(e){if(typeof e=="string")return e;let t={...e};if(t.inlineData){let{displayName:r,...n}=t.inlineData;t.inlineData=n}if(t.fileData){let{displayName:r,...n}=t.fileData;t.fileData=n}if(t.functionResponse?.parts){let r=t.functionResponse.parts.map(n=>{let i=this.convertUnsupportedMediaToText(n);return this.stripPartFields(i)});t.functionResponse={...t.functionResponse,parts:r}}return t}convertUnsupportedMediaToText(e){if(typeof e=="string")return e;let t=e.inlineData?.mimeType||"",r=e.fileData?.mimeType||"";if(t.startsWith("audio/")||t.startsWith("video/")){let n=e.inlineData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${t}${i}.`}}if(r.startsWith("audio/")||r.startsWith("video/")){let n=e.fileData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${r}${i}.`}}return e}async countTokens(e){return this.googleGenAI.models.countTokens(e)}async embedContent(e){return this.googleGenAI.models.embedContent(e)}useSummarizedThinking(){return!0}};function T(o,e){let i={...{"User-Agent":o.userAgent||`MatildaCode/0.21.10-preview.1 (${process.platform}; ${process.arch})`}};if(e?.getUsageStatisticsEnabled()){let f=new g().getInstallationId();i={...i,"x-gemini-api-privileged-user-id":`${f}`}}let s=o.baseUrl?{headers:i,baseUrl:o.baseUrl}:{headers:i};return new p({apiKey:o.apiKey===""?void 0:o.apiKey,vertexai:o.vertexai,httpOptions:s},o)}export{p as GeminiContentGenerator,T as createGeminiContentGenerator};
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2025 Google LLC
@@ -0,0 +1,22 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{Ue as _,Ve as j}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import{b as D}from"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{g as k}from"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as M,i as C,p as N,q as A}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{G as $,J as O,O as v,ba as R,d as x}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as L}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";L();import z from"node:fs";import T from"node:path";var V=R("GLOB"),Y=100,B=2e4,W=15e3,q=500;function K(u,g,t){let e=[...u];return e.sort((r,s)=>{let c=r.mtimeMs??0,a=s.mtimeMs??0,o=g-c<t,l=g-a<t;return o&&l?a-c:o?-1:l?1:r.fullpath().localeCompare(s.fullpath())}),e}var S=class extends M{constructor(t,e){super(e);this.config=t;this.fileService=t.getFileService()}fileService;getDescription(){let t=`'${this.params.pattern}'`;return this.params.path&&(t+=` in path '${this.params.path}'`),t}async getDefaultPermission(){if(!this.params.path)return"allow";let t=this.config.getWorkspaceContext(),e=T.resolve(this.config.getTargetDir(),this.params.path);return t.isPathWithinWorkspace(e)||O(k(),e)?"allow":"ask"}async globInDirectory(t,e,r){let s=e,c=T.join(t,s);z.existsSync(c)&&(s=_(s));let a=j(s,{cwd:t,withFileTypes:!0,nodir:!0,stat:!0,nocase:!0,dot:!0,ignore:this.config.getFileExclusions().getGlobExcludes(),follow:!1,signal:r}),o=[],l=Date.now(),p=null;for await(let n of a){if(o.push(n),o.length>=B){p="count";break}if(Date.now()-l>W){p="time";break}o.length%q===0&&await new Promise(b=>setImmediate(b))}p&&a.destroy?.();let d=this.config.getTargetDir(),P=o.map(n=>T.relative(d,n.fullpath())),{filteredPaths:m}=this.fileService.filterFilesWithReport(P,this.getFileFilteringOptions()),h=n=>process.platform==="win32"||process.platform==="darwin"?n.toLowerCase():n,f=new Set(m.map(n=>h(T.resolve(d,n))));return{entries:o.filter(n=>f.has(h(n.fullpath()))),limited:p}}async execute(t){try{let e=[],r;if(this.params.path){let i=v(this.config,this.params.path,{allowExternalPaths:!0});e.push(i),r=`within ${i}`}else{let i=this.config.getWorkspaceContext().getDirectories();e.push(...i),r=i.length>1?`across ${i.length} workspace directories`:"in the workspace directory"}let s=this.params.pattern,c=[],a=new Set,o=null;for(let i of e){let{entries:F,limited:E}=await this.globInDirectory(i,s,t);E&&(o=E);for(let G of F){let I=G.fullpath();a.has(I)||(a.add(I),c.push(G))}}let l=c,p=o==="time"?`
4
+
5
+ [Search stopped after ${W/1e3}s before scanning the whole tree. Results may be incomplete \u2014 narrow the search by passing a more specific 'path' or pattern.]`:o==="count"?`
6
+
7
+ [Search stopped after scanning ${B} entries. Results may be incomplete \u2014 narrow the search by passing a more specific 'path' or pattern.]`:"";if(!l||l.length===0)return{llmContent:`No files found matching pattern "${this.params.pattern}" ${r}${p}`,returnDisplay:o?"No files found (search truncated)":"No files found"};let d=24*60*60*1e3,P=new Date().getTime(),m=K(l,P,d),h=m.length,f=Math.min(Y,this.config.getTruncateToolOutputLines()),y=h>f,b=(y?m.slice(0,f):m).map(i=>i.fullpath()),X=b.join(`
8
+ `),w=`Found ${h} file(s) matching "${this.params.pattern}" ${r}`;if(w+=`, sorted by modification time (newest first):
9
+ ---
10
+ ${X}`,y){let i=h-f;w+=`
11
+ ---
12
+ [${i} ${i===1?"file":"files"} truncated] ...`}return w+=p,{llmContent:w,returnDisplay:`Found ${h} matching file(s)${y?" (truncated)":""}`,resultFilePaths:b}}catch(e){let r=e instanceof Error?e.message:String(e);V.error(`GlobLogic execute Error: ${r}`,e);let s=`Error during glob search operation: ${r}`;return{llmContent:s,returnDisplay:`Error: ${r||"An unexpected error occurred."}`,error:{message:s,type:"glob_execution_error"}}}}getFileFilteringOptions(){let t=this.config.getFileFilteringOptions?.();return{respectGitIgnore:t?.respectGitIgnore??D.respectGitIgnore,respectMatildaIgnore:t?.respectMatildaIgnore??D.respectMatildaIgnore}}},U=class u extends C{constructor(t){super(u.Name,A.GLOB,`Fast file pattern matching tool that works with any codebase size
13
+ - Supports glob patterns like "**/*.js" or "src/**/*.ts"
14
+ - Returns matching file paths sorted by modification time
15
+ - Use this tool when you need to find files by name patterns
16
+ - When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead
17
+ - You have the capability to call multiple tools in a single response. It is always better to speculatively perform multiple searches as a batch that are potentially useful.`,"search",{properties:{pattern:{description:"The glob pattern to match files against",type:"string"},path:{description:'The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Must be a valid directory path if provided.',type:"string"}},required:["pattern"],type:"object"});this.config=t}static Name=N.GLOB;validateToolParamValues(t){if(!t.pattern||typeof t.pattern!="string"||t.pattern.trim()==="")return"The 'pattern' parameter cannot be empty.";if(t.path){t.path=$(t.path.trim());try{v(this.config,t.path,{allowExternalPaths:!0})}catch(e){return x(e)}}return null}createInvocation(t){return new S(this.config,t)}};export{U as GlobTool,B as MAX_SCAN_ENTRIES,W as MAX_SCAN_MS,K as sortFileEntries};
18
+ /**
19
+ * @license
20
+ * Copyright 2025 Google LLC
21
+ * SPDX-License-Identifier: Apache-2.0
22
+ */
@@ -0,0 +1,12 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{S as k,T as f,a as h,f as b,x as w}from"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-4F4DA5UI.js";import"./chunk-SDTWBD62.js";import{g as c,i as d,p as m,q as p}from"./chunk-T4P4KEDW.js";import"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.js";import{b as P}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";P();function l(o,a){return typeof o!="object"||o===null||!a.some(e=>e in o)?o:Object.fromEntries(Object.entries(o).filter(([e])=>!a.includes(e)))}var G=class extends c{constructor(e,t,r,i){super(e);this.runtime=t;this.permit=r;this.lastGoal=i}getDescription(){return"Read the current goal"}async execute(e){if(!this.runtime||!this.permit)return E(this.lastGoal);let t=await x(this.runtime,this.permit,e);e.throwIfAborted();let r=y(this.runtime,this.permit);if(t.goalId!==this.permit.goalId||t.revision!==this.permit.revision)throw u();let i=C(t,r);return{llmContent:JSON.stringify(i),returnDisplay:`Active goal \xB7 revision ${t.revision}`}}},R=class o extends d{constructor(e){super(o.Name,p.GET_GOAL,`Read the current Goal: its objective, status, budget figures, and any verifier feedback. Read-only; never changes Goal state.
4
+
5
+ Outside a Goal turn it returns "active": false with "lastGoal", a summary of the session's most recent Goal. Use the result silently; do not mention the retrieval to the user.`,"read",{type:"object",properties:{},additionalProperties:!1},!0,!1,!1);this.config=e}static Name=m.GET_GOAL;build(e){return super.build(l(e,["view"]))}validateToolParams(e){return super.validateToolParams(l(e,["view"]))}createInvocation(e){let t=h.getStore(),r=t?structuredClone(t):void 0,i=r?this.config.getGoalRuntime():void 0;return new G(e,i,r,r?void 0:this.lastGoal())}lastGoal(){let e;try{e=this.config.getGoalRuntime()}catch{return}if(typeof e?.getSnapshot!="function")return;let t=e.getSnapshot().goal;if(t)return{goalId:t.goalId,revision:t.revision,status:t.status,turnCount:t.turnCount,activeTimeMs:t.activeTimeMs,tokensUsed:t.tokensUsed,...t.tokenBudget===void 0?{}:{tokenBudget:t.tokenBudget},...t.turnBudget===void 0?{}:{turnBudget:t.turnBudget},...t.activeTimeBudgetMs===void 0?{}:{activeTimeBudgetMs:t.activeTimeBudgetMs},...t.lastReason===void 0?{}:{lastReason:t.lastReason}}}};function E(o){return o?{llmContent:JSON.stringify({active:!1,lastGoal:o}),returnDisplay:`No Goal turn is permitted \xB7 last Goal ${o.status} after ${o.turnCount} ${o.turnCount===1?"turn":"turns"}`}:{llmContent:JSON.stringify({active:!1}),returnDisplay:"No active Goal is available for this turn."}}var v=class extends c{constructor(e,t,r){super(e);this.runtime=t;this.permit=r}getDescription(){return`Propose that the Goal is ${this.params.status} for this permitted turn`}async execute(e){if(!this.runtime||!this.permit)throw new Error("No active Goal is available for this turn");let t=this.permit,r=await x(this.runtime,t,e);if(e.throwIfAborted(),y(this.runtime,t),r.goalId!==this.permit.goalId||r.revision!==this.permit.revision)throw u();let i={status:this.params.status,reason:this.params.reason.trim(),...this.params.blockerKind?{blockerKind:this.params.blockerKind}:{}};e.throwIfAborted();let n=F(this.runtime,this.permit,i),T=y(this.runtime,this.permit),A={proposalRecorded:n.recorded,readyForVerification:n.readyForVerification,goalLifecycleChanged:!1,nextAction:n.readyForVerification?"End this turn without user-facing text. Do not claim the Goal is complete or blocked. The Goal status card will report the independent verification result.":"Continue this turn without claiming the Goal is complete or blocked. A repeated-blocker audit requires the same blocker mode and exact same reason text across three consecutive Goal turns, each of which must show the blocker in its own tool results."},s;return n.recorded?n.readyForVerification&&T.goal?.status==="active"?s="Proposal queued for independent verification at the turn boundary; no terminal lifecycle change was committed.":T.goal?.status==="paused"?s="Proposal recorded while the Goal is paused; no terminal lifecycle change was committed.":s="Proposal recorded for blocker audit; it is not yet ready for independent verification and no terminal lifecycle change was committed.":s="A Goal proposal is already recorded for this turn; no terminal lifecycle change was committed.",{llmContent:JSON.stringify(A),returnDisplay:s}}},S=class o extends d{constructor(e){super(o.Name,p.UPDATE_GOAL,`Propose that the current Goal is complete or blocked; an independent verifier decides and this tool never changes the Goal's status.
6
+
7
+ The verifier reads only the most recent records of this Goal's transcript (your visible output, tool results, the user's messages), so run the checks that prove every objective condition immediately before calling. If completion depends on content delivered in this turn, emit only what the objective requires first, with no progress or completion commentary. For blocked, set blockerKind: authority (a user or maintainer decision or permission is required), external (an evidenced external resource or capability is unavailable), or infeasible (a tool result, not your own text, shows the objective cannot be satisfied as written: it contradicts itself, names a target that verifiably does not exist, or needs an action no tool can perform; never for difficulty, uncertainty, information you could still obtain, or wanting to ask; the reason must state what was checked and why no in-scope work could satisfy the objective). The verifier may accept those three on the first turn they are proposed; a rejected proposal leaves the Goal running. Omit blockerKind, or set repeated, for the same blocker with the exact same reason text across three consecutive Goal turns, which is only sent to the verifier on the third. Never tell the user the Goal is complete or blocked: when the result reports readyForVerification, end the turn with no further text; otherwise keep working. The Goal status card reports the verdict.`,"think",{type:"object",properties:{status:{type:"string",enum:["complete","blocked"]},reason:{type:"string",minLength:1,maxLength:8e3},blockerKind:{type:"string",enum:["authority","external","repeated","infeasible"],description:"Which blocker a blocked proposal reports; the tool description says when each applies."}},required:["status","reason"],additionalProperties:!1},!0,!1,!1);this.config=e}static Name=m.UPDATE_GOAL;build(e){return super.build(l(e,["evidenceRefs"]))}validateToolParams(e){return super.validateToolParams(l(e,["evidenceRefs"]))}validateToolParamValues(e){return w(e.reason)}createInvocation(e){let t=h.getStore(),r=t?structuredClone(t):void 0,i=r?this.config.getGoalRuntime():void 0;return new v(e,i,r)}};function y(o,a){let e=o.getSnapshotForPermit;if(typeof e!="function")throw u();try{return e.call(o,a)}catch(t){g(t)}}async function x(o,a,e){e.throwIfAborted();let t;try{let r=new Promise((i,n)=>{t=()=>n(e.reason),e.addEventListener("abort",t,{once:!0}),e.aborted&&t()});return await Promise.race([o.getGoalForWorker(a),r])}catch(r){return g(r)}finally{t&&e.removeEventListener("abort",t)}}function F(o,a,e){try{return o.recordTerminalProposal(a,e)}catch(t){g(t)}}function g(o){throw o instanceof Error&&(o.message===k||o.message===f)?u():o}function u(){return new Error(f)}function C(o,a){return{active:!0,snapshot:structuredClone(a),...o.verifierFeedback?{verifierFeedback:o.verifierFeedback}:{}}}export{R as GetGoalTool,S as UpdateGoalTool};
8
+ /**
9
+ * @license
10
+ * Copyright 2026 Qwen Team
11
+ * SPDX-License-Identifier: Apache-2.0
12
+ */
@@ -0,0 +1,22 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{N as Y,Qj as Z,Rj as tt,Sj as et,Tj as rt,Uj as st,Ve as Q,fd as k}from"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{g as X}from"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as J,i as q,p as z,q as K}from"./chunk-T4P4KEDW.js";import"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{G as _,J as H,N as U,O as N,b as j,ba as V,d as w}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as W}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";W();import it from"node:fs/promises";import E from"node:path";import{EOL as lt}from"node:os";import{spawn as nt}from"node:child_process";var L=V("GREP"),D=class extends J{constructor(s,i){super(i);this.config=s;this.fileExclusions=s.getFileExclusions()}fileExclusions;async getDefaultPermission(){if(!this.params.path)return"allow";let s=this.config.getWorkspaceContext(),i=E.resolve(this.config.getTargetDir(),this.params.path);return s.isPathWithinWorkspace(i)||H(X(),i)||U(this.config,i)?"allow":"ask"}async execute(s){try{let i=[],o;if(this.params.path){let t=N(this.config,this.params.path,{allowFiles:!0,allowExternalPaths:!0});i.push(t),o=`in path "${this.params.path}"`}else{let t=this.config.getWorkspaceContext().getDirectories();i.push(...t),o=t.length>1?`across ${t.length} workspace directories`:"in the workspace directory"}let a=[];for(let t of i){let e=await this.performGrepSearch({pattern:this.params.pattern,path:t,glob:this.params.glob,signal:s});if(i.length>1)for(let n of e)E.isAbsolute(n.filePath)||(n.filePath=E.resolve(t,n.filePath));a.push(...e)}if(i.length>1){let t=new Set;a=a.filter(e=>{let n=`${e.filePath}:${e.lineNumber}`;return t.has(n)?!1:(t.add(n),!0)})}let c=this.params.glob?` (filter: "${this.params.glob}")`:"";if(a.length===0)return{llmContent:`No matches found for pattern "${this.params.pattern}" ${o}${c}.`,returnDisplay:"No matches found"};let p=this.config.getTruncateToolOutputThreshold(),u=Math.min(this.config.getTruncateToolOutputLines(),this.params.limit??Number.POSITIVE_INFINITY),x=!1,h=a;a.length>u&&(h=a.slice(0,u),x=!0);let $=a.length,G=$===1?"match":"matches",v=`Found ${$} ${G} for pattern "${this.params.pattern}" ${o}${c}:
4
+ ---
5
+ `,T=h.reduce((t,e)=>{let n=e.filePath;return t[n]||(t[n]=[]),t[n].push(e),t[n].sort((y,F)=>y.lineNumber-F.lineNumber),t},{}),P="",M=[],C=!1,g=(t,e)=>Number.isFinite(p)&&P.length+t.length>p?(P+=t.slice(0,Math.max(p-P.length,0)),P+="...",e&&M.push(e),C=!0,!1):(P+=t,e&&M.push(e),!0);for(let t in T){if(!g(`File: ${t}
6
+ `))break;let e=!1;for(let n of T[t]){let y=n.line.length>et?n.range??st(n.line,this.params.pattern):void 0,F=rt(n.line,y?.[0]??0,y?.[1]??0).trim();if(!g(`L${n.lineNumber}: ${F}
7
+ `,n)){e=!0;break}}if(e||!g(`---
8
+ `))break}let m=P.split(`
9
+ `).filter(t=>t.trim()&&!t.startsWith("File:")&&!t.startsWith("---")).length,l=v+P;if(x||C){let t=$-m;l+=` [${t} ${t===1?"line":"lines"} truncated] ...`}let r=`Found ${$} ${G}`;(x||C)&&(r+=" (truncated)");let d=Array.from(new Set(M.map(t=>t.absoluteFilePath).filter(t=>t!=="")));return await Z(this.config,d),{llmContent:l.trim(),returnDisplay:r,resultFilePaths:d}}catch(i){L.error(`Error during GrepLogic execution: ${i}`);let o=w(i);return{llmContent:`Error during grep search operation: ${o}`,returnDisplay:`Error: ${o}`,error:{message:o,type:"grep_execution_error"}}}}parseGrepOutput(s,i){let o=[];if(!s)return o;let a=s.split(lt);for(let c of a){if(!c.trim())continue;let p=c.indexOf(":");if(p===-1)continue;let u=c.indexOf(":",p+1);if(u===-1)continue;let x=c.substring(0,p),h=c.substring(p+1,u),$=c.substring(u+1),G=parseInt(h,10);if(!isNaN(G)){let v=E.resolve(i,x),T=E.relative(i,v);o.push({filePath:T||E.basename(v),absoluteFilePath:v,lineNumber:G,line:$.replace(/\r$/,"")})}}return o}getDescription(){let s=`'${this.params.pattern}' in path '${this.params.path||"./"}'`;return this.params.glob&&(s+=` (filter: '${this.params.glob}')`),s}async performGrepSearch(s){let{pattern:i,path:o,glob:a}=s,c="none",p=await it.stat(o).then(h=>h.isFile()).catch(()=>!1),u=p?E.dirname(o):o,x=p?E.basename(o):".";try{if(!p&&Y(u)&&k("git").available){c="git grep";let g=["grep","--untracked","-n","-E","--ignore-case","-e",i];a&&g.push("--",a);try{let f=await new Promise((m,l)=>{let r=nt("git",g,{cwd:u,windowsHide:!0}),d=[],t=[];r.stdout.on("data",e=>d.push(e)),r.stderr.on("data",e=>t.push(e)),r.on("error",e=>l(new Error(`Failed to start git grep: ${e.message}`))),r.on("close",e=>{let n=Buffer.concat(d).toString("utf8"),y=Buffer.concat(t).toString("utf8");e===0?m(n):e===1?m(""):l(new Error(`git grep exited with code ${e}: ${y}`))})});return this.parseGrepOutput(f,u)}catch(f){L.debug(`GrepLogic: git grep failed: ${w(f)}. Falling back...`)}}let{available:G}=k("grep");if(G){c="system grep";let g=["-r","-n","-H","-E"];this.fileExclusions.getGlobExcludes().map(l=>{let r=l;return r.startsWith("**/")&&(r=r.substring(3)),r.endsWith("/**")?r=r.slice(0,-3):r.endsWith("/")&&(r=r.slice(0,-1)),r&&!r.includes("/")&&!r.includes("*")?r:null}).filter(l=>!!l).forEach(l=>g.push(`--exclude-dir=${l}`)),a&&!p&&g.push(`--include=${a}`),g.push("-e",i,"--",x);try{let l=await new Promise((r,d)=>{let t=nt("grep",g,{cwd:u,windowsHide:!0}),e=[],n=[],y=b=>e.push(b),F=b=>{let S=b.toString();!S.includes("Permission denied")&&!/grep:.*: Is a directory/i.test(S)&&n.push(b)},A=b=>{I(),d(new Error(`Failed to start system grep: ${b.message}`))},B=b=>{let S=Buffer.concat(e).toString("utf8"),O=Buffer.concat(n).toString("utf8").trim();I(),b===0?r(S):b===1?r(""):O?d(new Error(`System grep exited with code ${b}: ${O}`)):r("")},I=()=>{t.stdout.removeListener("data",y),t.stderr.removeListener("data",F),t.removeListener("error",A),t.removeListener("close",B),t.connected&&t.disconnect()};t.stdout.on("data",y),t.stderr.on("data",F),t.on("error",A),t.on("close",B)});return this.parseGrepOutput(l,u)}catch(l){L.debug(`GrepLogic: System grep failed: ${w(l)}. Falling back...`)}}L.debug("GrepLogic: Falling back to JavaScript grep implementation."),c="javascript fallback";let v=a||"**/*",T=this.fileExclusions.getGlobExcludes(),P=p?[o]:Q(v,{cwd:u,dot:!0,ignore:T,absolute:!0,nodir:!0,signal:s.signal}),M=new RegExp(i,"i"),C=[];for await(let g of P){let f=g;try{(await it.readFile(f,"utf8")).split(/\r?\n/).forEach((r,d)=>{let t=M.exec(r);t&&C.push({filePath:E.relative(u,f)||E.basename(f),absoluteFilePath:f,lineNumber:d+1,line:r,range:[t.index,t.index+t[0].length]})})}catch(m){(!j(m)||m.code!=="ENOENT")&&L.debug(`GrepLogic: Could not read/process ${f}: ${w(m)}`)}}return C}catch(h){throw L.error(`GrepLogic: Error in performGrepSearch (Strategy: ${c}): ${w(h)}`),h}}},ot=class R extends q{constructor(s){super(R.Name,K.GREP,`A powerful search tool for finding patterns in files
10
+
11
+ Usage:
12
+ - ALWAYS use Grep for search tasks. NEVER invoke \`grep\` or \`rg\` as a Bash command. The Grep tool has been optimized for correct permissions and access.
13
+ - JavaScript regex (not PCRE): e.g. "log.*Error", "function\\s+\\w+". Do not use (?i) \u2014 search is case-insensitive by default.
14
+ - Filter files with glob parameter (e.g., "*.js", "**/*.tsx")
15
+ - Case-insensitive by default
16
+ - Use Agent tool for open-ended searches requiring multiple rounds
17
+ `,"search",{properties:{pattern:{type:"string",description:"JavaScript regular expression (not PCRE). Case-insensitive by default \u2014 do not use (?i)."},glob:{type:"string",description:'Glob pattern to filter files (e.g. "*.js", "*.{ts,tsx}")'},path:{type:"string",description:"File or directory to search in. Defaults to current working directory."},limit:{type:"number",description:"Limit output to first N matching lines. Optional - shows all matches if not specified."}},required:["pattern"],type:"object"});this.config=s}static Name=z.GREP;get maxOutputChars(){return 2e4}validateToolParamValues(s){s.pattern=tt(s.pattern);try{new RegExp(s.pattern)}catch(i){return`Invalid regular expression pattern: ${s.pattern}. Error: ${w(i)}`}if(s.path){s.path=_(s.path.trim());try{N(this.config,s.path,{allowFiles:!0,allowExternalPaths:!0})}catch(i){return w(i)}}return null}createInvocation(s){return new D(this.config,s)}};export{ot as GrepTool};
18
+ /**
19
+ * @license
20
+ * Copyright 2025 Google LLC
21
+ * SPDX-License-Identifier: Apache-2.0
22
+ */
@@ -1,3 +1,3 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{b as a}from"./chunk-FWIVFCKF.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as KeychainTokenStorage};
3
+ import{b as a}from"./chunk-FFFZ2QMG.js";import"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as KeychainTokenStorage};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{b as d}from"./chunk-RNKDFE2S.js";import{g as N}from"./chunk-32PTAACU.js";import{g as C,i as x,p as w,q as F}from"./chunk-PIFQEMZZ.js";import{D as E,E as I,G as S,J as u,K as L,P as R,aa as O}from"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();import y from"node:fs/promises";import s from"node:path";var A=O("LS"),U=100,T=class extends C{constructor(t,e){super(e);this.config=t}shouldIgnore(t,e){if(!e||e.length===0)return!1;for(let i of e){let a=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");if(new RegExp(`^${a}$`).test(t))return!0}return!1}getDescription(){let t=I(this.params.path,this.config.getTargetDir());return E(t)}async getDefaultPermission(){let t=s.resolve(this.params.path),e=this.config.getWorkspaceContext(),i=this.config.storage.getUserSkillsDirs(),a=R.getUserExtensionsDir();return e.isPathWithinWorkspace(t)||L(i,t)||u(a,t)||u(N(),t)?"allow":"ask"}errorResult(t,e,i){return{llmContent:t,returnDisplay:`Error: ${e}`,error:{message:t,type:i}}}async execute(t){try{let e=await y.stat(this.params.path);if(!e)return this.errorResult(`Error: Directory not found or inaccessible: ${this.params.path}`,"Directory not found or inaccessible.","file_not_found");if(!e.isDirectory())return this.errorResult(`Error: Path is not a directory: ${this.params.path}`,"Path is not a directory.","path_is_not_a_directory");let i=await y.readdir(this.params.path);if(i.length===0)return{llmContent:`Directory ${this.params.path} is empty.`,returnDisplay:"Directory is empty."};let a=i.map(r=>s.relative(this.config.getTargetDir(),s.join(this.params.path,r))),_=this.config.getFileService(),{filteredPaths:k,gitIgnoredCount:P,matildaIgnoredCount:b}=_.filterFilesWithReport(a,{respectGitIgnore:this.params.file_filtering_options?.respect_git_ignore??this.config.getFileFilteringOptions().respectGitIgnore??d.respectGitIgnore,respectMatildaIgnore:this.params.file_filtering_options?.respect_matilda_ignore??this.config.getFileFilteringOptions().respectMatildaIgnore??d.respectMatildaIgnore}),l=[];for(let r of k){let o=s.resolve(this.config.getTargetDir(),r);if(!this.shouldIgnore(s.basename(o),this.params.ignore))try{let c=await y.stat(o),$=c.isDirectory();l.push({name:s.basename(o),path:o,isDirectory:$,size:$?0:c.size,modifiedTime:c.mtime})}catch(c){A.warn(`Error accessing ${o}: ${c}`)}}l.sort((r,o)=>r.isDirectory&&!o.isDirectory?-1:!r.isDirectory&&o.isDirectory?1:r.name.localeCompare(o.name));let p=l.length,g=Math.min(U,this.config.getTruncateToolOutputLines()),m=p>g,W=(m?l.slice(0,g):l).map(r=>`${r.isDirectory?"[DIR] ":""}${r.name}`).join(`
3
+ import{b as d}from"./chunk-RNKDFE2S.js";import{g as N}from"./chunk-ELH4YHJR.js";import{g as C,i as x,p as w,q as F}from"./chunk-T4P4KEDW.js";import{D as E,E as I,G as S,J as u,K as L,Q as R,ba as O}from"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();import y from"node:fs/promises";import s from"node:path";var A=O("LS"),U=100,T=class extends C{constructor(t,e){super(e);this.config=t}shouldIgnore(t,e){if(!e||e.length===0)return!1;for(let i of e){let a=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");if(new RegExp(`^${a}$`).test(t))return!0}return!1}getDescription(){let t=I(this.params.path,this.config.getTargetDir());return E(t)}async getDefaultPermission(){let t=s.resolve(this.params.path),e=this.config.getWorkspaceContext(),i=this.config.storage.getUserSkillsDirs(),a=R.getUserExtensionsDir();return e.isPathWithinWorkspace(t)||L(i,t)||u(a,t)||u(N(),t)?"allow":"ask"}errorResult(t,e,i){return{llmContent:t,returnDisplay:`Error: ${e}`,error:{message:t,type:i}}}async execute(t){try{let e=await y.stat(this.params.path);if(!e)return this.errorResult(`Error: Directory not found or inaccessible: ${this.params.path}`,"Directory not found or inaccessible.","file_not_found");if(!e.isDirectory())return this.errorResult(`Error: Path is not a directory: ${this.params.path}`,"Path is not a directory.","path_is_not_a_directory");let i=await y.readdir(this.params.path);if(i.length===0)return{llmContent:`Directory ${this.params.path} is empty.`,returnDisplay:"Directory is empty."};let a=i.map(r=>s.relative(this.config.getTargetDir(),s.join(this.params.path,r))),_=this.config.getFileService(),{filteredPaths:k,gitIgnoredCount:P,matildaIgnoredCount:b}=_.filterFilesWithReport(a,{respectGitIgnore:this.params.file_filtering_options?.respect_git_ignore??this.config.getFileFilteringOptions().respectGitIgnore??d.respectGitIgnore,respectMatildaIgnore:this.params.file_filtering_options?.respect_matilda_ignore??this.config.getFileFilteringOptions().respectMatildaIgnore??d.respectMatildaIgnore}),l=[];for(let r of k){let o=s.resolve(this.config.getTargetDir(),r);if(!this.shouldIgnore(s.basename(o),this.params.ignore))try{let c=await y.stat(o),$=c.isDirectory();l.push({name:s.basename(o),path:o,isDirectory:$,size:$?0:c.size,modifiedTime:c.mtime})}catch(c){A.warn(`Error accessing ${o}: ${c}`)}}l.sort((r,o)=>r.isDirectory&&!o.isDirectory?-1:!r.isDirectory&&o.isDirectory?1:r.name.localeCompare(o.name));let p=l.length,g=Math.min(U,this.config.getTruncateToolOutputLines()),m=p>g,W=(m?l.slice(0,g):l).map(r=>`${r.isDirectory?"[DIR] ":""}${r.name}`).join(`
4
4
  `),h=`Listed ${p} item(s) in ${this.params.path}:
5
5
  ---
6
6
  ${W}`;if(m){let r=p-g;h+=`
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{g as b,i as D,p as R,q as N}from"./chunk-PIFQEMZZ.js";import{G as P}from"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as S}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";S();import $ from"node:path";import{fileURLToPath as L,pathToFileURL as q}from"node:url";var O=new Set(["goToDefinition","findReferences","hover","goToImplementation","prepareCallHierarchy"]),A=new Set(["documentSymbol","diagnostics"]),E=new Set(["workspaceSymbol"]),U=new Set(["incomingCalls","outgoingCalls"]),W=new Set(["codeActions"]),C=class extends b{constructor(t,e){super(e);this.config=t}getDescription(){let t=this.getOperationLabel();return this.params.operation==="workspaceSymbol"?`LSP ${t} for "${this.params.query??""}"`:this.params.operation==="documentSymbol"?this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`:this.params.operation==="incomingCalls"||this.params.operation==="outgoingCalls"?`LSP ${t} for ${this.describeCallHierarchyItemShort()}`:this.params.filePath&&this.params.line!==void 0?`LSP ${t} at ${this.params.filePath}:${this.params.line}:${this.params.character??1}`:this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`}async execute(t){let e=this.config.getLspClient();if(!e||!this.config.isLspEnabled()){let r=`LSP ${this.getOperationLabel()} is unavailable (LSP disabled or not initialized).`;return{llmContent:r,returnDisplay:r}}switch(this.params.operation){case"goToDefinition":return this.executeDefinitions(e);case"findReferences":return this.executeReferences(e);case"hover":return this.executeHover(e);case"documentSymbol":return this.executeDocumentSymbols(e);case"workspaceSymbol":return this.executeWorkspaceSymbols(e);case"goToImplementation":return this.executeImplementations(e);case"prepareCallHierarchy":return this.executePrepareCallHierarchy(e);case"incomingCalls":return this.executeIncomingCalls(e);case"outgoingCalls":return this.executeOutgoingCalls(e);case"diagnostics":return this.executeDiagnostics(e);case"workspaceDiagnostics":return this.executeWorkspaceDiagnostics(e);case"codeActions":return this.executeCodeActions(e);default:{let r=`Unsupported LSP operation: ${this.params.operation}`;return{llmContent:r,returnDisplay:r}}}}async executeDefinitions(t){let e=this.resolveLocationTarget();if("error"in e)return{llmContent:e.error,returnDisplay:e.error};let r=this.params.limit??20,i=[];try{i=await t.definitions(e.location,this.params.serverName,r)}catch(n){let c=`LSP go-to-definition failed: ${n?.message||String(n)}`;return{llmContent:c,returnDisplay:c}}if(!i.length){let n=`No definitions found for ${e.description}.`;return{llmContent:n,returnDisplay:n}}let s=this.config.getProjectRoot(),a=i.slice(0,r).map((n,c)=>`${c+1}. ${this.formatLocationWithServer(n,s)}`);return{llmContent:[`Definitions for ${e.description}:`,...a].join(`
3
+ import{g as b,i as D,p as R,q as N}from"./chunk-T4P4KEDW.js";import{G as P}from"./chunk-MH2P4YXC.js";import"./chunk-FWDMPRKU.js";import{b as S}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";S();import $ from"node:path";import{fileURLToPath as L,pathToFileURL as q}from"node:url";var O=new Set(["goToDefinition","findReferences","hover","goToImplementation","prepareCallHierarchy"]),A=new Set(["documentSymbol","diagnostics"]),E=new Set(["workspaceSymbol"]),U=new Set(["incomingCalls","outgoingCalls"]),W=new Set(["codeActions"]),C=class extends b{constructor(t,e){super(e);this.config=t}getDescription(){let t=this.getOperationLabel();return this.params.operation==="workspaceSymbol"?`LSP ${t} for "${this.params.query??""}"`:this.params.operation==="documentSymbol"?this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`:this.params.operation==="incomingCalls"||this.params.operation==="outgoingCalls"?`LSP ${t} for ${this.describeCallHierarchyItemShort()}`:this.params.filePath&&this.params.line!==void 0?`LSP ${t} at ${this.params.filePath}:${this.params.line}:${this.params.character??1}`:this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`}async execute(t){let e=this.config.getLspClient();if(!e||!this.config.isLspEnabled()){let r=`LSP ${this.getOperationLabel()} is unavailable (LSP disabled or not initialized).`;return{llmContent:r,returnDisplay:r}}switch(this.params.operation){case"goToDefinition":return this.executeDefinitions(e);case"findReferences":return this.executeReferences(e);case"hover":return this.executeHover(e);case"documentSymbol":return this.executeDocumentSymbols(e);case"workspaceSymbol":return this.executeWorkspaceSymbols(e);case"goToImplementation":return this.executeImplementations(e);case"prepareCallHierarchy":return this.executePrepareCallHierarchy(e);case"incomingCalls":return this.executeIncomingCalls(e);case"outgoingCalls":return this.executeOutgoingCalls(e);case"diagnostics":return this.executeDiagnostics(e);case"workspaceDiagnostics":return this.executeWorkspaceDiagnostics(e);case"codeActions":return this.executeCodeActions(e);default:{let r=`Unsupported LSP operation: ${this.params.operation}`;return{llmContent:r,returnDisplay:r}}}}async executeDefinitions(t){let e=this.resolveLocationTarget();if("error"in e)return{llmContent:e.error,returnDisplay:e.error};let r=this.params.limit??20,i=[];try{i=await t.definitions(e.location,this.params.serverName,r)}catch(n){let c=`LSP go-to-definition failed: ${n?.message||String(n)}`;return{llmContent:c,returnDisplay:c}}if(!i.length){let n=`No definitions found for ${e.description}.`;return{llmContent:n,returnDisplay:n}}let s=this.config.getProjectRoot(),a=i.slice(0,r).map((n,c)=>`${c+1}. ${this.formatLocationWithServer(n,s)}`);return{llmContent:[`Definitions for ${e.description}:`,...a].join(`
4
4
  `),returnDisplay:a.join(`
5
5
  `)}}async executeImplementations(t){let e=this.resolveLocationTarget();if("error"in e)return{llmContent:e.error,returnDisplay:e.error};let r=this.params.limit??20,i=[];try{i=await t.implementations(e.location,this.params.serverName,r)}catch(n){let c=`LSP go-to-implementation failed: ${n?.message||String(n)}`;return{llmContent:c,returnDisplay:c}}if(!i.length){let n=`No implementations found for ${e.description}.`;return{llmContent:n,returnDisplay:n}}let s=this.config.getProjectRoot(),a=i.slice(0,r).map((n,c)=>`${c+1}. ${this.formatLocationWithServer(n,s)}`);return{llmContent:[`Implementations for ${e.description}:`,...a].join(`
6
6
  `),returnDisplay:a.join(`
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{b as t}from"./chunk-X6BEBYGX.js";import"./chunk-XJYPRCV7.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-KSNBNXBC.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-2PPJ3MJT.js";import"./chunk-PIFQEMZZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as n}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";n();function a(e,o){return new t(e,o)}export{t as MatildaAgentContentGenerator,a as createMatildaAgentContentGenerator};
3
+ import{b as t}from"./chunk-66NIIU2R.js";import"./chunk-YSIECQIZ.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import"./chunk-T4P4KEDW.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as n}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";n();function a(e,o){return new t(e,o)}export{t as MatildaAgentContentGenerator,a as createMatildaAgentContentGenerator};
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2026 Matilda Team
@@ -0,0 +1,8 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{a as l,i as p}from"./chunk-2W6MZZHZ.js";import"./chunk-ODZOYHIC.js";import"./chunk-VVIJGBQK.js";import"./chunk-TZIDSCTF.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-TO3ID3JW.js";import"./chunk-MKFQMX37.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-66NIIU2R.js";import"./chunk-GUFIMKF5.js";import"./chunk-YSIECQIZ.js";import{d as u}from"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{k as c}from"./chunk-SDTWBD62.js";import"./chunk-FRRBNNEB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import"./chunk-T4P4KEDW.js";import{c as h}from"./chunk-S4UT3QLV.js";import"./chunk-XCFLI3OC.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{ba as d,s as i,t as a}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as s}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";s();var m=class extends p{debugLogger=d("MATILDA");matildaClient;sharedManager;currentToken;constructor(e,t,n){let r=new l(t,n);super(t,n,r),this.matildaClient=e,this.sharedManager=h.getInstance(),t?.baseUrl&&t?.apiKey&&(this.pipeline.client.baseURL=t?.baseUrl,this.pipeline.client.apiKey=t?.apiKey)}getCurrentEndpoint(e){let t=e||u,n="/v1",r=t.startsWith("http")?t:`https://${t}`;return r.endsWith(n)||r.endsWith("/api/v1")||r.endsWith("/api/v1/code")?r:`${r}${n}`}shouldSuppressErrorLogging(e,t){return this.isAuthError(e)}async getValidToken(){try{let e=await this.sharedManager.getValidCredentials(this.matildaClient);if(!e.access_token)throw new Error("No access token available");return{token:e.access_token,endpoint:this.getCurrentEndpoint(e.resource_url)}}catch(e){throw this.isAuthError(e)?e:(this.debugLogger.warn("Failed to get token from shared manager:",e),new Error("Failed to obtain a valid legacy OAuth access token. Please re-authenticate with Matilda."))}}async executeWithCredentialManagement(e){let t=async()=>{let{token:n,endpoint:r}=await this.getValidToken();this.pipeline.client.apiKey=n,this.pipeline.client.baseURL=r;try{return await e()}catch(o){throw a(o)?new i:o}};try{return await t()}catch(n){if(this.isAuthError(n))return await this.sharedManager.getValidCredentials(this.matildaClient,!0),await c("retry",t);throw n}}async generateContent(e,t){return this.executeWithCredentialManagement(()=>super.generateContent(e,t))}async generateContentStream(e,t){let n=await this.executeWithCredentialManagement(()=>super.generateContentStream(e,t));return async function*(){try{yield*n}catch(r){throw a(r)?new i:r}}()}async countTokens(e){return super.countTokens(e)}async embedContent(e){return this.executeWithCredentialManagement(()=>super.embedContent(e))}isAuthError(e){if(!e||a(e))return!1;let t=e instanceof Error?e.message.toLowerCase():String(e).toLowerCase(),n=e,r=n?.status||n?.code;return Number(r)===403?!1:r===401||r==="401"||t.includes("unauthorized")||t.includes("invalid api key")||t.includes("invalid access token")||t.includes("token expired")||t.includes("authentication")||t.includes("token")&&t.includes("expired")}getCurrentToken(){return this.currentToken?this.currentToken:this.sharedManager.getCurrentCredentials()?.access_token||null}clearToken(){this.currentToken=void 0,this.sharedManager.clearCache()}};export{m as MatildaContentGenerator};
4
+ /**
5
+ * @license
6
+ * Copyright 2025 Matilda
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */