@maincode-ai/matilda-code 0.21.13 → 0.22.0

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 (252) hide show
  1. package/chunks/agent-IUINB66G.js +3 -0
  2. package/chunks/agent-headless-YA2RKYEZ.js +3 -0
  3. package/chunks/{askUserQuestion-BNSWGD26.js → askUserQuestion-RZYBOPLR.js} +3 -3
  4. package/chunks/ca-JKEHLTNL.js +23 -0
  5. package/chunks/chunk-225CZWD7.js +89 -0
  6. package/chunks/{chunk-MEV5XQI2.js → chunk-2XSB5XHX.js} +1 -1
  7. package/chunks/chunk-453BANK3.js +8 -0
  8. package/chunks/{chunk-6M5G5FBH.js → chunk-4UGPARBR.js} +1 -1
  9. package/chunks/{chunk-RNKDFE2S.js → chunk-5B2QERWR.js} +1 -1
  10. package/chunks/chunk-5ETLURI6.js +3 -0
  11. package/chunks/chunk-6NXVLJ3X.js +56 -0
  12. package/chunks/{chunk-QZI2ZGZY.js → chunk-7B65UIHB.js} +1 -1
  13. package/chunks/{chunk-27Q5KW3A.js → chunk-7E2YCGHS.js} +13 -13
  14. package/chunks/{chunk-DHDD5YJC.js → chunk-ARAB5QTM.js} +69 -69
  15. package/chunks/chunk-DUB7JMQV.js +13 -0
  16. package/chunks/chunk-G3F3ZCH2.js +9 -0
  17. package/chunks/chunk-GT6MSEK4.js +3 -0
  18. package/chunks/chunk-HEJO7OBH.js +3 -0
  19. package/chunks/{chunk-6T2GIM76.js → chunk-IHWAOFCQ.js} +1 -1
  20. package/chunks/chunk-ILHNCXBC.js +8 -0
  21. package/chunks/chunk-J3ZCE3TA.js +8 -0
  22. package/chunks/{chunk-AOOZREGV.js → chunk-LBQNFSZ2.js} +1 -1
  23. package/chunks/{chunk-5OHGYMKP.js → chunk-LM6OIN4B.js} +1 -1
  24. package/chunks/{chunk-EZDV7A76.js → chunk-LMZBADPW.js} +1 -1
  25. package/chunks/chunk-MGRXOZAG.js +8 -0
  26. package/chunks/chunk-NBLBE7PE.js +2609 -0
  27. package/chunks/chunk-POGNX7U3.js +31 -0
  28. package/chunks/chunk-PQZ6HKKW.js +80 -0
  29. package/chunks/chunk-QXSBPCBA.js +8 -0
  30. package/chunks/chunk-RHSUTILA.js +9 -0
  31. package/chunks/{chunk-P5TG5CON.js → chunk-RPXRN7E6.js} +1 -1
  32. package/chunks/chunk-TUKNB5CQ.js +33 -0
  33. package/chunks/chunk-UM6CLO7D.js +7 -0
  34. package/chunks/chunk-V2VUANFI.js +120 -0
  35. package/chunks/chunk-V4VILMIK.js +14 -0
  36. package/chunks/chunk-ZSGBDQXU.js +11 -0
  37. package/chunks/{computer-use-J4GAM4M6.js → computer-use-PBCWDTJR.js} +1 -1
  38. package/chunks/{cron-create-IDWSZENI.js → cron-create-PHQ43NYA.js} +1 -1
  39. package/chunks/cron-delete-7RCQIU2U.js +3 -0
  40. package/chunks/cron-list-KKNLLMNN.js +5 -0
  41. package/chunks/de-GMGNR5CZ.js +23 -0
  42. package/chunks/{devtools-XRQ4YJ5S.js → devtools-7YNCRYZV.js} +1 -1
  43. package/chunks/{chunk-OOEH6ZSV.js → dist-UWUWLWTO.js} +2 -2
  44. package/chunks/{edit-X2S2ZXRN.js → edit-ELHNQB5E.js} +1 -1
  45. package/chunks/en-3NQMLVKW.js +23 -0
  46. package/chunks/{enter-worktree-TUCGNCLO.js → enter-worktree-UZIBOBV3.js} +1 -1
  47. package/chunks/enterPlanMode-UHY3DZXE.js +18 -0
  48. package/chunks/{exit-worktree-7FLITFZI.js → exit-worktree-HLG4PDMX.js} +1 -1
  49. package/chunks/{exitPlanMode-O5UUJ3GM.js → exitPlanMode-V4HYNH3J.js} +2 -2
  50. package/chunks/fr-WS3EBB36.js +23 -0
  51. package/chunks/{getMachineId-bsd-ZYBNK2JG.js → getMachineId-bsd-ETKQTB6C.js} +1 -1
  52. package/chunks/{getMachineId-darwin-CM2MQGUI.js → getMachineId-darwin-AKNRWOWB.js} +1 -1
  53. package/chunks/{getMachineId-linux-SYE2KMCW.js → getMachineId-linux-2QSD7FTP.js} +1 -1
  54. package/chunks/{getMachineId-unsupported-6IHVG2XO.js → getMachineId-unsupported-UXSV7I24.js} +1 -1
  55. package/chunks/{getMachineId-win-S3J3JSUM.js → getMachineId-win-4MTFXGP3.js} +1 -1
  56. package/chunks/glob-C5CTWXLP.js +22 -0
  57. package/chunks/{goal-tools-YQOA6OKU.js → goal-tools-BGIWEJ3K.js} +3 -3
  58. package/chunks/{grep-VAB2VSXM.js → grep-BEFTGKHW.js} +1 -1
  59. package/chunks/ja-GBCDQ43R.js +23 -0
  60. package/chunks/keychain-token-storage-FEJZYJBB.js +3 -0
  61. package/chunks/ls-XH55NAD3.js +15 -0
  62. package/chunks/{lsp-NGLDRHZU.js → lsp-BKDCR37G.js} +1 -1
  63. package/chunks/mcp-client-GAQG7MCT.js +3 -0
  64. package/chunks/monitor-NSVUUKCM.js +32 -0
  65. package/chunks/{multipart-parser-JI75T2O5.js → multipart-parser-FKHYAVGR.js} +1 -1
  66. package/chunks/notebook-edit-AXKYC64C.js +17 -0
  67. package/chunks/openaiContentGenerator-66YY6CIM.js +47 -0
  68. package/chunks/pt-VID6J2CM.js +23 -0
  69. package/chunks/read-file-YFJMLS7V.js +3 -0
  70. package/chunks/ripGrep-BEHEB23R.js +3 -0
  71. package/chunks/ru-EB6V6EAN.js +23 -0
  72. package/chunks/scheduler-GKQOREMS.js +8 -0
  73. package/chunks/send-message-GJSEMAZB.js +8 -0
  74. package/chunks/shell-J5Q2UEXH.js +3 -0
  75. package/chunks/{skill-ETQM5NI3.js → skill-3RWNSUNE.js} +1 -1
  76. package/chunks/src-LZEU4AYF.js +5 -0
  77. package/chunks/symbol-search-4VM6J5Y4.js +19 -0
  78. package/chunks/{syntheticOutput-WZDPECYS.js → syntheticOutput-O7LEF3AM.js} +1 -1
  79. package/chunks/task-create-N4IRJBTF.js +3 -0
  80. package/chunks/{task-detach-TBAVUOTC.js → task-detach-RGNQUX3H.js} +1 -1
  81. package/chunks/task-list-Z7JUB4QK.js +9 -0
  82. package/chunks/{task-stop-HDSARSJ6.js → task-stop-L2OWK2PJ.js} +1 -1
  83. package/chunks/{task-update-MW2VT2XV.js → task-update-H5AXVXDS.js} +1 -1
  84. package/chunks/{team-create-VMYNLZCC.js → team-create-FWTIQ2FT.js} +2 -2
  85. package/chunks/team-delete-D45ALROH.js +8 -0
  86. package/chunks/todoWrite-LCQOQBI7.js +3 -0
  87. package/chunks/{tool-search-WX6FOE35.js → tool-search-X6UUCSPU.js} +1 -1
  88. package/chunks/{web-fetch-CKYBHGLF.js → web-fetch-244KUWSX.js} +17 -17
  89. package/chunks/web-search-YRZ3BZ3X.js +26 -0
  90. package/chunks/{workflow-WBSRQG3N.js → workflow-EP4AFR24.js} +2 -2
  91. package/chunks/write-file-EXWGRN4Q.js +15 -0
  92. package/cli.js +641 -678
  93. package/examples/starter/README.md +0 -3
  94. package/locales/ca.js +3 -87
  95. package/locales/de.js +3 -91
  96. package/locales/en.js +3 -91
  97. package/locales/fr.js +3 -88
  98. package/locales/ja.js +3 -92
  99. package/locales/pt.js +3 -92
  100. package/locales/ru.js +3 -91
  101. package/package.json +2 -2
  102. package/sandbox-macos-permissive-proxied.sb +1 -1
  103. package/sandbox-macos-restrictive-closed.sb +14 -1
  104. package/sandbox-macos-restrictive-open.sb +14 -1
  105. package/sandbox-macos-restrictive-proxied.sb +15 -2
  106. package/bundled/mainy/SKILL.md +0 -157
  107. package/bundled/mainy/docs/_meta.ts +0 -32
  108. package/bundled/mainy/docs/common-workflow.md +0 -571
  109. package/bundled/mainy/docs/configuration/_meta.ts +0 -7
  110. package/bundled/mainy/docs/configuration/auth.md +0 -82
  111. package/bundled/mainy/docs/configuration/matilda-ignore.md +0 -55
  112. package/bundled/mainy/docs/configuration/model-providers.md +0 -516
  113. package/bundled/mainy/docs/configuration/settings.md +0 -818
  114. package/bundled/mainy/docs/configuration/themes.md +0 -199
  115. package/bundled/mainy/docs/configuration/trusted-folders.md +0 -67
  116. package/bundled/mainy/docs/extension/_meta.ts +0 -9
  117. package/bundled/mainy/docs/extension/extension-releasing.md +0 -204
  118. package/bundled/mainy/docs/extension/getting-started-extensions.md +0 -299
  119. package/bundled/mainy/docs/extension/introduction.md +0 -338
  120. package/bundled/mainy/docs/features/_meta.ts +0 -27
  121. package/bundled/mainy/docs/features/approval-mode.md +0 -388
  122. package/bundled/mainy/docs/features/arena.md +0 -219
  123. package/bundled/mainy/docs/features/auto-mode.md +0 -308
  124. package/bundled/mainy/docs/features/channels/_meta.ts +0 -5
  125. package/bundled/mainy/docs/features/channels/overview.md +0 -328
  126. package/bundled/mainy/docs/features/channels/plugins.md +0 -87
  127. package/bundled/mainy/docs/features/channels/telegram.md +0 -120
  128. package/bundled/mainy/docs/features/code-review.md +0 -291
  129. package/bundled/mainy/docs/features/commands.md +0 -528
  130. package/bundled/mainy/docs/features/dual-output.md +0 -627
  131. package/bundled/mainy/docs/features/followup-suggestions.md +0 -109
  132. package/bundled/mainy/docs/features/headless.md +0 -448
  133. package/bundled/mainy/docs/features/hooks.md +0 -1308
  134. package/bundled/mainy/docs/features/language.md +0 -144
  135. package/bundled/mainy/docs/features/lsp.md +0 -496
  136. package/bundled/mainy/docs/features/markdown-rendering.md +0 -183
  137. package/bundled/mainy/docs/features/mcp.md +0 -423
  138. package/bundled/mainy/docs/features/memory.md +0 -185
  139. package/bundled/mainy/docs/features/sandbox.md +0 -249
  140. package/bundled/mainy/docs/features/scheduled-tasks.md +0 -139
  141. package/bundled/mainy/docs/features/skills.md +0 -347
  142. package/bundled/mainy/docs/features/status-line.md +0 -397
  143. package/bundled/mainy/docs/features/structured-output.md +0 -309
  144. package/bundled/mainy/docs/features/sub-agents.md +0 -737
  145. package/bundled/mainy/docs/features/tips.md +0 -54
  146. package/bundled/mainy/docs/features/token-caching.md +0 -29
  147. package/bundled/mainy/docs/features/tool-use-summaries.md +0 -178
  148. package/bundled/mainy/docs/features/worktree.md +0 -343
  149. package/bundled/mainy/docs/ide-integration/_meta.ts +0 -4
  150. package/bundled/mainy/docs/ide-integration/ide-companion-spec.md +0 -182
  151. package/bundled/mainy/docs/ide-integration/ide-integration.md +0 -144
  152. package/bundled/mainy/docs/integration-github-action.md +0 -241
  153. package/bundled/mainy/docs/integration-jetbrains.md +0 -81
  154. package/bundled/mainy/docs/integration-vscode.md +0 -39
  155. package/bundled/mainy/docs/integration-zed.md +0 -72
  156. package/bundled/mainy/docs/matilda-serve-deploy-local.md +0 -221
  157. package/bundled/mainy/docs/matilda-serve.md +0 -661
  158. package/bundled/mainy/docs/overview.md +0 -64
  159. package/bundled/mainy/docs/quickstart.md +0 -234
  160. package/bundled/mainy/docs/reference/_meta.ts +0 -3
  161. package/bundled/mainy/docs/reference/keyboard-shortcuts.md +0 -91
  162. package/bundled/mainy/docs/support/Uninstall.md +0 -65
  163. package/bundled/mainy/docs/support/_meta.ts +0 -6
  164. package/bundled/mainy/docs/support/tos-privacy.md +0 -94
  165. package/bundled/mainy/docs/support/troubleshooting.md +0 -127
  166. package/chunks/agent-SRAIVZEE.js +0 -3
  167. package/chunks/agent-headless-XRDOZESG.js +0 -3
  168. package/chunks/anthropicContentGenerator-LLDIKDMQ.js +0 -39
  169. package/chunks/ca-NPYL24ME.js +0 -25
  170. package/chunks/chunk-27HUYW23.js +0 -22
  171. package/chunks/chunk-2HTPVSGT.js +0 -3
  172. package/chunks/chunk-3B2HABK7.js +0 -30
  173. package/chunks/chunk-3MTZTNAU.js +0 -101
  174. package/chunks/chunk-3YLXGE6T.js +0 -8
  175. package/chunks/chunk-47XR7IMP.js +0 -8
  176. package/chunks/chunk-4F4DA5UI.js +0 -8
  177. package/chunks/chunk-4Q2SNBUH.js +0 -18
  178. package/chunks/chunk-6EQMZNIY.js +0 -8
  179. package/chunks/chunk-6I6VGTKD.js +0 -8
  180. package/chunks/chunk-DC7LAFZZ.js +0 -8
  181. package/chunks/chunk-DE3HKC2W.js +0 -9
  182. package/chunks/chunk-FWDMPRKU.js +0 -3
  183. package/chunks/chunk-G7R2XEEF.js +0 -7
  184. package/chunks/chunk-GOJCMVJJ.js +0 -8
  185. package/chunks/chunk-GTVCJCHR.js +0 -8
  186. package/chunks/chunk-IJEGHQ7Z.js +0 -32
  187. package/chunks/chunk-JCE3JAVC.js +0 -25
  188. package/chunks/chunk-KHHJYBR5.js +0 -9
  189. package/chunks/chunk-LUNDTQ3G.js +0 -8
  190. package/chunks/chunk-LWARA7JY.js +0 -37
  191. package/chunks/chunk-M53RP3YP.js +0 -31
  192. package/chunks/chunk-MTMU7JYZ.js +0 -11
  193. package/chunks/chunk-O44XK65C.js +0 -8
  194. package/chunks/chunk-OA56BXPD.js +0 -3
  195. package/chunks/chunk-PEKAUGYV.js +0 -2621
  196. package/chunks/chunk-PGUG43HG.js +0 -24
  197. package/chunks/chunk-PGXQZVLX.js +0 -8
  198. package/chunks/chunk-QKYGQLWC.js +0 -8
  199. package/chunks/chunk-QN6Y6NPA.js +0 -3
  200. package/chunks/chunk-RI54U73U.js +0 -56
  201. package/chunks/chunk-RPFSFS7Z.js +0 -39
  202. package/chunks/chunk-SDTWBD62.js +0 -8
  203. package/chunks/chunk-SOEIVSM5.js +0 -113
  204. package/chunks/chunk-SVSY6AWS.js +0 -59
  205. package/chunks/chunk-T2T2UEPY.js +0 -4
  206. package/chunks/chunk-TISQNFB5.js +0 -3
  207. package/chunks/chunk-TWJLOEAI.js +0 -31
  208. package/chunks/chunk-VI74YQQO.js +0 -8
  209. package/chunks/chunk-VYZOOSMP.js +0 -30
  210. package/chunks/chunk-W4QSMIWO.js +0 -9
  211. package/chunks/chunk-WC2VTVCE.js +0 -27
  212. package/chunks/chunk-YV3PUOBU.js +0 -65
  213. package/chunks/chunk-ZX34M2GF.js +0 -14
  214. package/chunks/contextCommand-5F5M7NA4.js +0 -3
  215. package/chunks/cron-delete-NQCDZDUI.js +0 -3
  216. package/chunks/cron-list-Z4XMC3TO.js +0 -5
  217. package/chunks/de-34YZHGC6.js +0 -25
  218. package/chunks/dist-7UYRLSLE.js +0 -3
  219. package/chunks/dist-PH6JW7XD.js +0 -42
  220. package/chunks/en-QLGMD6OS.js +0 -25
  221. package/chunks/enterPlanMode-SQEZAAIR.js +0 -18
  222. package/chunks/fileFromPath-7UCWPD4W.js +0 -3
  223. package/chunks/fr-EDNBQACJ.js +0 -25
  224. package/chunks/geminiContentGenerator-FIZFLPU3.js +0 -8
  225. package/chunks/glob-GSFTYAS2.js +0 -22
  226. package/chunks/ja-LV4RLM3M.js +0 -25
  227. package/chunks/keychain-token-storage-KQK6MNOJ.js +0 -3
  228. package/chunks/ls-IZJ3CKZY.js +0 -15
  229. package/chunks/matildaAgentContentGenerator-QQHPCFJ5.js +0 -8
  230. package/chunks/matildaContentGenerator-W7Z33ONU.js +0 -8
  231. package/chunks/matildaOAuth2-7COTQQR2.js +0 -3
  232. package/chunks/mcp-client-DXUNIEIB.js +0 -3
  233. package/chunks/monitor-4PFIGAGG.js +0 -32
  234. package/chunks/notebook-edit-MWJYAATJ.js +0 -17
  235. package/chunks/openaiContentGenerator-NDVJL6QL.js +0 -3
  236. package/chunks/pt-5SQ4DGL7.js +0 -25
  237. package/chunks/read-file-WPZKPXWA.js +0 -3
  238. package/chunks/ripGrep-7LZDZFTX.js +0 -3
  239. package/chunks/ru-7K24S53N.js +0 -25
  240. package/chunks/scheduler-DK2MVKXX.js +0 -8
  241. package/chunks/send-message-TCPX5UDU.js +0 -8
  242. package/chunks/serve-GSZPJI2O.js +0 -1026
  243. package/chunks/shell-PRS47PDP.js +0 -3
  244. package/chunks/src-UB7DZRYK.js +0 -3
  245. package/chunks/src-WZTRMETQ.js +0 -5
  246. package/chunks/symbol-search-HARHZ5AH.js +0 -19
  247. package/chunks/task-create-XRNIDT4T.js +0 -3
  248. package/chunks/task-list-Z6BDZZID.js +0 -9
  249. package/chunks/team-delete-F7QDC2TE.js +0 -8
  250. package/chunks/todoWrite-SCF5M24M.js +0 -3
  251. package/chunks/web-search-67DFNS5V.js +0 -26
  252. package/chunks/write-file-S5FAX4JJ.js +0 -15
@@ -0,0 +1,13 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{b as r}from"./chunk-GZPNIYVZ.js";r();r();var _="MATILDA_API_KEY";var d="matilda-code-1.0",f="Matilda",x="https://matilda.maincode.com/api/v1/code";var C={id:"matilda",label:"Matilda",description:"Connect to the Matilda Core code API endpoint",protocol:"openai",baseUrl:x,envKey:_,models:[{id:d,displayName:f,contextWindowSize:1048576,description:"Matilda Code model",generationConfig:{openAIRequestProfile:"matilda-code",timeout:6e5,samplingParams:{max_tokens:65536,chat_template_kwargs:{enable_thinking:!0}},schemaCompliance:"openapi_30",splitToolMedia:!0,customHeaders:{"User-Agent":"MatildaCode/0.1"}}}],modelNamePrefix:"",documentationUrl:"https://matilda.maincode.help/welcome/external-api",uiGroup:"third-party"};var b=d,k="text-embedding-v4";r();import{AsyncLocalStorage as y}from"node:async_hooks";import{randomUUID as O}from"node:crypto";r();import{AsyncLocalStorage as g}from"node:async_hooks";var l=new g;var R="x-matilda-reported-operation-id",A="x-matilda-reported-attempt-purpose",P=[R,A],D=new Set(P),I=["answer","tool_followup","continuation","retry","compaction","unknown"],h=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,M=new Set(I),c=new y,E=new WeakSet;function m(){return O()}function s(t,e){let o=Object.freeze({operationId:t,attemptPurpose:e});return E.add(o),o}function B(t){return D.has(t.toLowerCase())}function p(){let t=c.getStore();return t&&E.has(t)?t:void 0}var T=class{activeOperationId;begin(e){return this.activeOperationId=m(),s(this.activeOperationId,e)}continue(e){let o=p()?.operationId??this.activeOperationId??m();return this.activeOperationId=o,s(o,e)}};function i(t,e){return c.run(t,e)}function K(t){c.enterWith(t)}function q(t,e){let o=p();return o?i(s(o.operationId,t),e):e()}function w(t,e){let o={next:(...n)=>i(t,()=>e.next(...n)),return:n=>i(t,()=>e.return(n)),throw:n=>i(t,()=>e.throw(n)),[Symbol.asyncIterator]:()=>o},a=Symbol.asyncDispose,u=a&&e[a];return a&&typeof u=="function"&&(o[a]=()=>i(t,()=>u.call(e))),o}function z(t,e){let o=p();return o?w(s(o.operationId,t),e):e}function F(){let t=p();if(!t||!h.test(t.operationId))return{};let e=l.getStore()?.attempt,o=e!==void 0&&e>1?"retry":t.attemptPurpose;return M.has(o)?{[R]:t.operationId,[A]:o}:{}}export{l as a,R as b,A as c,P as d,B as e,p as f,T as g,i as h,K as i,q as j,w as k,z as l,F as m,_ as n,d as o,f as p,x as q,C as r,b as s,k as t};
4
+ /**
5
+ * @license
6
+ * Copyright 2026 Matilda Team
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */
9
+ /**
10
+ * @license
11
+ * Copyright 2025 Google LLC
12
+ * SPDX-License-Identifier: Apache-2.0
13
+ */
@@ -0,0 +1,9 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{c as p}from"./chunk-V4VILMIK.js";import{b as h}from"./chunk-7ZODGQO6.js";import{a as M}from"./chunk-GT6MSEK4.js";import{b as d}from"./chunk-J3ZCE3TA.js";import{V as b,b as f}from"./chunk-7E2YCGHS.js";import{b as u}from"./chunk-GZPNIYVZ.js";import{f as E}from"./chunk-OWGSC52X.js";u();var x=null;function D(){x=null}function _(e,r,t){return x?(x.enqueueApproval({teammateName:e,teammateColor:r,details:t}),!0):!1}function P(e,r,t,o){return{...e,title:`[${r}] ${e.title}`,onConfirm:async(i,s)=>{await t(i,s)}}}u();var C=E(h(),1);import*as a from"node:fs/promises";import*as c from"node:path";var w=b("AGENTS_TEAM_MAILBOX"),N={retries:{retries:10,minTimeout:5,maxTimeout:100,factor:2,randomize:!0},stale:5e3,onCompromised:e=>{w.debug("mailbox lock compromised:",e?.message??e)}},g=new Map;function O(e){let r=g.get(e);return r||(r=new M,g.set(e,r)),r}function I(e){let r=p(e),t=0;for(let o of g.keys())c.dirname(o)===r&&(g.delete(o),t++);return t}async function T(e,r){return O(e).runExclusive(async()=>{let t=await C.default.lock(e,N);try{return await r()}finally{await t()}})}function y(e,r){return c.join(p(e),`${r}.json`)}async function B(e,r){let t=y(e,r);try{let o=await a.readFile(t,"utf-8");return JSON.parse(o)}catch(o){if(f(o)&&o.code==="ENOENT")return[];throw o}}var L=5*60*1e3;async function A(e,r,t){let o=y(e,r);await v(o),await T(o,async()=>{let i=await k(o),s=Date.now()-L,l=i.filter(m=>{if(!m.read)return!0;let n=Date.parse(m.timestamp);return Number.isNaN(n)||n>=s});l.push(t),await d(o,l)})}async function W(e,r,t){let o=y(e,r);return await v(o),T(o,async()=>{let i=await k(o),s=n=>!n.read&&(t===void 0||n.type===t),l=i.filter(s);if(l.length===0)return[];let m=i.map(n=>s(n)?{...n,read:!0}:n);return await d(o,m),l})}async function X(e){let r=p(e);await a.rm(r,{recursive:!0,force:!0}),I(e)}async function z(e,r,t){await A(e,r,{from:t.from,text:t.text,timestamp:new Date().toISOString(),read:!1,type:t.type,color:t.color,summary:t.summary})}async function v(e){await a.mkdir(c.dirname(e),{recursive:!0});try{await a.writeFile(e,`[]
4
+ `,{flag:"wx"})}catch(r){if(!f(r)||r.code!=="EEXIST")throw r}}async function k(e){try{let r=await a.readFile(e,"utf-8");return JSON.parse(r)}catch(r){if(f(r)&&r.code==="ENOENT")return[];let t=r instanceof Error?r.message:String(r);w.warn(`Quarantining corrupt inbox at ${e}: ${t}`);try{await a.rename(e,`${e}.corrupt-${Date.now()}`)}catch(o){let i=o instanceof Error?o.message:String(o);throw w.warn(`Failed to quarantine ${e}: ${i}`),r instanceof Error?r:new Error(`Failed to read inbox at ${e}: ${t}`)}return[]}}export{D as a,_ as b,P as c,I as d,y as e,B as f,A as g,W as h,X as i,z as j};
5
+ /**
6
+ * @license
7
+ * Copyright 2025 Matilda
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
@@ -0,0 +1,3 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{b as f}from"./chunk-GZPNIYVZ.js";f();var q=new Error("timeout while waiting for mutex to become available"),k=new Error("mutex already locked"),v=new Error("request for lock canceled"),m=function(u,e,t,i){function o(n){return n instanceof t?n:new t(function(s){s(n)})}return new(t||(t=Promise))(function(n,s){function l(r){try{a(i.next(r))}catch(c){s(c)}}function h(r){try{a(i.throw(r))}catch(c){s(c)}}function a(r){r.done?n(r.value):o(r.value).then(l,h)}a((i=i.apply(u,e||[])).next())})},d=class{constructor(e,t=v){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((i,o)=>{let n={resolve:i,reject:o,weight:e,priority:t},s=w(this._queue,l=>t<=l.priority);s===-1&&e<=this._value?this._dispatchItem(n):this._queue.splice(s+1,0,n)})}runExclusive(e){return m(this,arguments,void 0,function*(t,i=1,o=0){let[n,s]=yield this.acquire(i,o);try{return yield t(n)}finally{s()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(i=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),p(this._weightedWaiters[e-1],{resolve:i,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(i=>i.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let i=this._weightedWaiters[t-1];if(!i)continue;let o=i.findIndex(n=>n.priority<=e);(o===-1?i:i.splice(0,o)).forEach(n=>n.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function p(u,e){let t=w(u,i=>e.priority<=i.priority);u.splice(t+1,0,e)}function w(u,e){for(let t=u.length-1;t>=0;t--)if(e(u[t]))return t;return-1}var E=function(u,e,t,i){function o(n){return n instanceof t?n:new t(function(s){s(n)})}return new(t||(t=Promise))(function(n,s){function l(r){try{a(i.next(r))}catch(c){s(c)}}function h(r){try{a(i.throw(r))}catch(c){s(c)}}function a(r){r.done?n(r.value):o(r.value).then(l,h)}a((i=i.apply(u,e||[])).next())})},_=class{constructor(e){this._semaphore=new d(1,e)}acquire(){return E(this,arguments,void 0,function*(e=0){let[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}};export{_ as a};
@@ -0,0 +1,3 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{b as i}from"./chunk-GZPNIYVZ.js";import{c as p,e as Vr}from"./chunk-OWGSC52X.js";function b(t){return Symbol.for(t)}var Br,V,O=p(()=>{i();Br=function(){function t(r){var e=this;e._currentContext=r?new Map(r):new Map,e.getValue=function(n){return e._currentContext.get(n)},e.setValue=function(n,a){var o=new t(e._currentContext);return o._currentContext.set(n,a),o},e.deleteValue=function(n){var a=new t(e._currentContext);return a._currentContext.delete(n),a}}return t}(),V=new Br});var Lr,Ur,Ct,St=p(()=>{i();O();Lr=function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),a,o=[],u;try{for(;(r===void 0||r-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(c){u={error:c}}finally{try{a&&!a.done&&(e=n.return)&&e.call(n)}finally{if(u)throw u.error}}return o},Ur=function(t,r,e){if(e||arguments.length===2)for(var n=0,a=r.length,o;n<a;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return t.concat(o||Array.prototype.slice.call(r))},Ct=function(){function t(){}return t.prototype.active=function(){return V},t.prototype.with=function(r,e,n){for(var a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return e.call.apply(e,Ur([n],Lr(a),!1))},t.prototype.bind=function(r,e){return e},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}()});var Rt,Mt=p(()=>{i();Rt=globalThis});var wt=p(()=>{i();Mt()});var Dt=p(()=>{i();wt()});var d,Z=p(()=>{i();d="1.9.0"});function jr(t){var r=new Set([t]),e=new Set,n=t.match(Gt);if(!n)return function(){return!1};var a={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(a.prerelease!=null)return function(f){return f===t};function o(c){return e.add(c),!1}function u(c){return r.add(c),!0}return function(f){if(r.has(f))return!0;if(e.has(f))return!1;var g=f.match(Gt);if(!g)return o(f);var m={major:+g[1],minor:+g[2],patch:+g[3],prerelease:g[4]};return m.prerelease!=null||a.major!==m.major?o(f):a.major===0?a.minor===m.minor&&a.patch<=m.patch?u(f):o(f):a.minor<=m.minor?u(f):o(f)}}var Gt,Vt,Bt=p(()=>{i();Z();Gt=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;Vt=jr(d)});function _(t,r,e,n){var a;n===void 0&&(n=!1);var o=C[P]=(a=C[P])!==null&&a!==void 0?a:{version:d};if(!n&&o[t]){var u=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return e.error(u.stack||u.message),!1}if(o.version!==d){var u=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+t+" does not match previously registered API v"+d);return e.error(u.stack||u.message),!1}return o[t]=r,e.debug("@opentelemetry/api: Registered a global for "+t+" v"+d+"."),!0}function v(t){var r,e,n=(r=C[P])===null||r===void 0?void 0:r.version;if(!(!n||!Vt(n)))return(e=C[P])===null||e===void 0?void 0:e[t]}function y(t,r){r.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+d+".");var e=C[P];e&&delete e[t]}var kr,P,C,E=p(()=>{i();Dt();Z();Bt();kr=d.split(".")[0],P=Symbol.for("opentelemetry.js.api."+kr),C=Rt});function S(t,r,e){var n=v("diag");if(n)return e.unshift(r),n[t].apply(n,Kr([],Xr(e),!1))}var Xr,Kr,Lt,Ut=p(()=>{i();E();Xr=function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),a,o=[],u;try{for(;(r===void 0||r-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(c){u={error:c}}finally{try{a&&!a.done&&(e=n.return)&&e.call(n)}finally{if(u)throw u.error}}return o},Kr=function(t,r,e){if(e||arguments.length===2)for(var n=0,a=r.length,o;n<a;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return t.concat(o||Array.prototype.slice.call(r))},Lt=function(){function t(r){this._namespace=r.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return S("debug",this._namespace,r)},t.prototype.error=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return S("error",this._namespace,r)},t.prototype.info=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return S("info",this._namespace,r)},t.prototype.warn=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return S("warn",this._namespace,r)},t.prototype.verbose=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return S("verbose",this._namespace,r)},t}()});var s,B=p(()=>{i();(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(s||(s={}))});function jt(t,r){t<s.NONE?t=s.NONE:t>s.ALL&&(t=s.ALL),r=r||{};function e(n,a){var o=r[n];return typeof o=="function"&&t>=a?o.bind(r):function(){}}return{error:e("error",s.ERROR),warn:e("warn",s.WARN),info:e("info",s.INFO),debug:e("debug",s.DEBUG),verbose:e("verbose",s.VERBOSE)}}var kt=p(()=>{i();B()});var Fr,Yr,zr,l,A=p(()=>{i();Ut();kt();B();E();Fr=function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),a,o=[],u;try{for(;(r===void 0||r-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(c){u={error:c}}finally{try{a&&!a.done&&(e=n.return)&&e.call(n)}finally{if(u)throw u.error}}return o},Yr=function(t,r,e){if(e||arguments.length===2)for(var n=0,a=r.length,o;n<a;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return t.concat(o||Array.prototype.slice.call(r))},zr="diag",l=function(){function t(){function r(a){return function(){for(var o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];var c=v("diag");if(c)return c[a].apply(c,Yr([],Fr(o),!1))}}var e=this,n=function(a,o){var u,c,f;if(o===void 0&&(o={logLevel:s.INFO}),a===e){var g=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return e.error((u=g.stack)!==null&&u!==void 0?u:g.message),!1}typeof o=="number"&&(o={logLevel:o});var m=v("diag"),Ot=jt((c=o.logLevel)!==null&&c!==void 0?c:s.INFO,a);if(m&&!o.suppressOverrideMessage){var Pt=(f=new Error().stack)!==null&&f!==void 0?f:"<failed to generate stacktrace>";m.warn("Current logger will be overwritten from "+Pt),Ot.warn("Current logger will overwrite one already registered from "+Pt)}return _("diag",Ot,e,!0)};e.setLogger=n,e.disable=function(){y(zr,e)},e.createComponentLogger=function(a){return new Lt(a)},e.verbose=r("verbose"),e.debug=r("debug"),e.info=r("info"),e.warn=r("warn"),e.error=r("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}()});var Wr,Hr,tt,$r,h,R=p(()=>{i();St();E();A();Wr=function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),a,o=[],u;try{for(;(r===void 0||r-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(c){u={error:c}}finally{try{a&&!a.done&&(e=n.return)&&e.call(n)}finally{if(u)throw u.error}}return o},Hr=function(t,r,e){if(e||arguments.length===2)for(var n=0,a=r.length,o;n<a;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return t.concat(o||Array.prototype.slice.call(r))},tt="context",$r=new Ct,h=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(r){return _(tt,r,l.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(r,e,n){for(var a,o=[],u=3;u<arguments.length;u++)o[u-3]=arguments[u];return(a=this._getContextManager()).with.apply(a,Hr([r,e,n],Wr(o),!1))},t.prototype.bind=function(r,e){return this._getContextManager().bind(r,e)},t.prototype._getContextManager=function(){return v(tt)||$r},t.prototype.disable=function(){this._getContextManager().disable(),y(tt,l.instance())},t}()});var rt,Xt=p(()=>{i();R();rt=h.getInstance()});var T,et=p(()=>{i();(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(T||(T={}))});var M,w,L,U=p(()=>{i();et();M="0000000000000000",w="00000000000000000000000000000000",L={traceId:w,spanId:M,traceFlags:T.NONE}});var x,j=p(()=>{i();U();x=function(){function t(r){r===void 0&&(r=L),this._spanContext=r}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(r,e){return this},t.prototype.setAttributes=function(r){return this},t.prototype.addEvent=function(r,e){return this},t.prototype.addLink=function(r){return this},t.prototype.addLinks=function(r){return this},t.prototype.setStatus=function(r){return this},t.prototype.updateName=function(r){return this},t.prototype.end=function(r){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(r,e){},t}()});function k(t){return t.getValue(nt)||void 0}function Kt(){return k(h.getInstance().active())}function D(t,r){return t.setValue(nt,r)}function Ft(t){return t.deleteValue(nt)}function Yt(t,r){return D(t,new x(r))}function X(t){var r;return(r=k(t))===null||r===void 0?void 0:r.spanContext()}var nt,ot=p(()=>{i();O();j();R();nt=b("OpenTelemetry Context Key SPAN")});function at(t){return Qr.test(t)&&t!==w}function it(t){return qr.test(t)&&t!==M}function I(t){return at(t.traceId)&&it(t.spanId)}function zt(t){return new x(t)}var Qr,qr,K=p(()=>{i();U();j();Qr=/^([0-9a-f]{32})$/i,qr=/^[0-9a-f]{16}$/i});function Jr(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var ut,F,pt=p(()=>{i();R();ot();j();K();ut=h.getInstance(),F=function(){function t(){}return t.prototype.startSpan=function(r,e,n){n===void 0&&(n=ut.active());var a=!!e?.root;if(a)return new x;var o=n&&X(n);return Jr(o)&&I(o)?new x(o):new x},t.prototype.startActiveSpan=function(r,e,n,a){var o,u,c;if(!(arguments.length<2)){arguments.length===2?c=e:arguments.length===3?(o=e,c=n):(o=e,u=n,c=a);var f=u??ut.active(),g=this.startSpan(r,o,f),m=D(f,g);return ut.with(m,c,void 0,g)}},t}()});var Zr,Y,ct=p(()=>{i();pt();Zr=new F,Y=function(){function t(r,e,n,a){this._provider=r,this.name=e,this.version=n,this.options=a}return t.prototype.startSpan=function(r,e,n){return this._getTracer().startSpan(r,e,n)},t.prototype.startActiveSpan=function(r,e,n,a){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var r=this._provider.getDelegateTracer(this.name,this.version,this.options);return r?(this._delegate=r,this._delegate):Zr},t}()});var Wt,Ht=p(()=>{i();pt();Wt=function(){function t(){}return t.prototype.getTracer=function(r,e,n){return new F},t}()});var te,G,ft=p(()=>{i();ct();Ht();te=new Wt,G=function(){function t(){}return t.prototype.getTracer=function(r,e,n){var a;return(a=this.getDelegateTracer(r,e,n))!==null&&a!==void 0?a:new Y(this,r,e,n)},t.prototype.getDelegate=function(){var r;return(r=this._delegate)!==null&&r!==void 0?r:te},t.prototype.setDelegate=function(r){this._delegate=r},t.prototype.getDelegateTracer=function(r,e,n){var a;return(a=this._delegate)===null||a===void 0?void 0:a.getTracer(r,e,n)},t}()});var st,$t,Qt=p(()=>{i();E();ft();K();ot();A();st="trace",$t=function(){function t(){this._proxyTracerProvider=new G,this.wrapSpanContext=zt,this.isSpanContextValid=I,this.deleteSpan=Ft,this.getSpan=k,this.getActiveSpan=Kt,this.getSpanContext=X,this.setSpan=D,this.setSpanContext=Yt}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(r){var e=_(st,this._proxyTracerProvider,l.instance());return e&&this._proxyTracerProvider.setDelegate(r),e},t.prototype.getTracerProvider=function(){return v(st)||this._proxyTracerProvider},t.prototype.getTracer=function(r,e){return this.getTracerProvider().getTracer(r,e)},t.prototype.disable=function(){y(st,l.instance()),this._proxyTracerProvider=new G},t}()});var lt,qt=p(()=>{i();Qt();lt=$t.getInstance()});var re,ee,Jt,Zt=p(()=>{i();re=function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),a,o=[],u;try{for(;(r===void 0||r-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(c){u={error:c}}finally{try{a&&!a.done&&(e=n.return)&&e.call(n)}finally{if(u)throw u.error}}return o},ee=function(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},Jt=function(){function t(r){this._entries=r?new Map(r):new Map}return t.prototype.getEntry=function(r){var e=this._entries.get(r);if(e)return Object.assign({},e)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(r){var e=re(r,2),n=e[0],a=e[1];return[n,a]})},t.prototype.setEntry=function(r,e){var n=new t(this._entries);return n._entries.set(r,e),n},t.prototype.removeEntry=function(r){var e=new t(this._entries);return e._entries.delete(r),e},t.prototype.removeEntries=function(){for(var r,e,n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];var o=new t(this._entries);try{for(var u=ee(n),c=u.next();!c.done;c=u.next()){var f=c.value;o._entries.delete(f)}}catch(g){r={error:g}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(r)throw r.error}}return o},t.prototype.clear=function(){return new t},t}()});var tr,rr=p(()=>{i();tr=Symbol("BaggageEntryMetadata")});function er(t){return t===void 0&&(t={}),new Jt(new Map(Object.entries(t)))}function nr(t){return typeof t!="string"&&(ne.error("Cannot create baggage metadata from unknown type: "+typeof t),t=""),{__TYPE__:tr,toString:function(){return t}}}var ne,gt=p(()=>{i();A();Zt();rr();ne=l.instance()});var vt,or,ar=p(()=>{i();vt=[{n:"error",c:"error"},{n:"warn",c:"warn"},{n:"info",c:"info"},{n:"debug",c:"debug"},{n:"verbose",c:"trace"}],or=function(){function t(){function r(n){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];if(console){var u=console[n];if(typeof u!="function"&&(u=console.log),typeof u=="function")return u.apply(console,a)}}}for(var e=0;e<vt.length;e++)this[vt[e].n]=r(vt[e].c)}return t}()});function ir(){return _t}var N,oe,z,ae,ie,ue,pe,mt,ce,fe,se,_t,le,ge,ve,me,_e,ye,de,yt=p(()=>{i();N=function(){var t=function(r,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,a){n.__proto__=a}||function(n,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(n[o]=a[o])},t(r,e)};return function(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");t(r,e);function n(){this.constructor=r}r.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}}(),oe=function(){function t(){}return t.prototype.createGauge=function(r,e){return ge},t.prototype.createHistogram=function(r,e){return ve},t.prototype.createCounter=function(r,e){return le},t.prototype.createUpDownCounter=function(r,e){return me},t.prototype.createObservableGauge=function(r,e){return ye},t.prototype.createObservableCounter=function(r,e){return _e},t.prototype.createObservableUpDownCounter=function(r,e){return de},t.prototype.addBatchObservableCallback=function(r,e){},t.prototype.removeBatchObservableCallback=function(r){},t}(),z=function(){function t(){}return t}(),ae=function(t){N(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r.prototype.add=function(e,n){},r}(z),ie=function(t){N(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r.prototype.add=function(e,n){},r}(z),ue=function(t){N(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r.prototype.record=function(e,n){},r}(z),pe=function(t){N(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r.prototype.record=function(e,n){},r}(z),mt=function(){function t(){}return t.prototype.addCallback=function(r){},t.prototype.removeCallback=function(r){},t}(),ce=function(t){N(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r}(mt),fe=function(t){N(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r}(mt),se=function(t){N(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r}(mt),_t=new oe,le=new ae,ge=new ue,ve=new pe,me=new ie,_e=new ce,ye=new fe,de=new se});var W,ur=p(()=>{i();(function(t){t[t.INT=0]="INT",t[t.DOUBLE=1]="DOUBLE"})(W||(W={}))});var H,$,dt=p(()=>{i();H={get:function(t,r){if(t!=null)return t[r]},keys:function(t){return t==null?[]:Object.keys(t)}},$={set:function(t,r,e){t!=null&&(t[r]=e)}}});var Q,pr=p(()=>{i();(function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(Q||(Q={}))});var q,cr=p(()=>{i();(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(q||(q={}))});var J,fr=p(()=>{i();(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(J||(J={}))});function sr(t){return Ee.test(t)}function lr(t){return Ae.test(t)&&!Ne.test(t)}var ht,he,xe,Ee,Ae,Ne,gr=p(()=>{i();ht="[_0-9a-z-*/]",he="[a-z]"+ht+"{0,255}",xe="[a-z0-9]"+ht+"{0,240}@[a-z]"+ht+"{0,13}",Ee=new RegExp("^(?:"+he+"|"+xe+")$"),Ae=/^[ -~]{0,255}[!-~]$/,Ne=/,|=/});var vr,be,mr,_r,yr,dr=p(()=>{i();gr();vr=32,be=512,mr=",",_r="=",yr=function(){function t(r){this._internalState=new Map,r&&this._parse(r)}return t.prototype.set=function(r,e){var n=this._clone();return n._internalState.has(r)&&n._internalState.delete(r),n._internalState.set(r,e),n},t.prototype.unset=function(r){var e=this._clone();return e._internalState.delete(r),e},t.prototype.get=function(r){return this._internalState.get(r)},t.prototype.serialize=function(){var r=this;return this._keys().reduce(function(e,n){return e.push(n+_r+r.get(n)),e},[]).join(mr)},t.prototype._parse=function(r){r.length>be||(this._internalState=r.split(mr).reverse().reduce(function(e,n){var a=n.trim(),o=a.indexOf(_r);if(o!==-1){var u=a.slice(0,o),c=a.slice(o+1,n.length);sr(u)&&lr(c)&&e.set(u,c)}return e},new Map),this._internalState.size>vr&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,vr))))},t.prototype._keys=function(){return Array.from(this._internalState.keys()).reverse()},t.prototype._clone=function(){var r=new t;return r._internalState=new Map(this._internalState),r},t}()});function hr(t){return new yr(t)}var xr=p(()=>{i();dr()});var xt,Er=p(()=>{i();A();xt=l.instance()});var Te,Ar,Nr=p(()=>{i();yt();Te=function(){function t(){}return t.prototype.getMeter=function(r,e,n){return _t},t}(),Ar=new Te});var Et,br,Tr=p(()=>{i();Nr();E();A();Et="metrics",br=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalMeterProvider=function(r){return _(Et,r,l.instance())},t.prototype.getMeterProvider=function(){return v(Et)||Ar},t.prototype.getMeter=function(r,e,n){return this.getMeterProvider().getMeter(r,e,n)},t.prototype.disable=function(){y(Et,l.instance())},t}()});var At,Ir=p(()=>{i();Tr();At=br.getInstance()});var Or,Pr=p(()=>{i();Or=function(){function t(){}return t.prototype.inject=function(r,e){},t.prototype.extract=function(r,e){return r},t.prototype.fields=function(){return[]},t}()});function bt(t){return t.getValue(Nt)||void 0}function Cr(){return bt(h.getInstance().active())}function Sr(t,r){return t.setValue(Nt,r)}function Rr(t){return t.deleteValue(Nt)}var Nt,Mr=p(()=>{i();R();O();Nt=b("OpenTelemetry Baggage Key")});var Tt,Ie,wr,Dr=p(()=>{i();E();Pr();dt();Mr();gt();A();Tt="propagation",Ie=new Or,wr=function(){function t(){this.createBaggage=er,this.getBaggage=bt,this.getActiveBaggage=Cr,this.setBaggage=Sr,this.deleteBaggage=Rr}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(r){return _(Tt,r,l.instance())},t.prototype.inject=function(r,e,n){return n===void 0&&(n=$),this._getGlobalPropagator().inject(r,e,n)},t.prototype.extract=function(r,e,n){return n===void 0&&(n=H),this._getGlobalPropagator().extract(r,e,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){y(Tt,l.instance())},t.prototype._getGlobalPropagator=function(){return v(Tt)||Ie},t}()});var It,Gr=p(()=>{i();Dr();It=wr.getInstance()});var Pe={};Vr(Pe,{DiagConsoleLogger:()=>or,DiagLogLevel:()=>s,INVALID_SPANID:()=>M,INVALID_SPAN_CONTEXT:()=>L,INVALID_TRACEID:()=>w,ProxyTracer:()=>Y,ProxyTracerProvider:()=>G,ROOT_CONTEXT:()=>V,SamplingDecision:()=>Q,SpanKind:()=>q,SpanStatusCode:()=>J,TraceFlags:()=>T,ValueType:()=>W,baggageEntryMetadataFromString:()=>nr,context:()=>rt,createContextKey:()=>b,createNoopMeter:()=>ir,createTraceState:()=>hr,default:()=>Oe,defaultTextMapGetter:()=>H,defaultTextMapSetter:()=>$,diag:()=>xt,isSpanContextValid:()=>I,isValidSpanId:()=>it,isValidTraceId:()=>at,metrics:()=>At,propagation:()=>It,trace:()=>lt});var Oe,Ce=p(()=>{i();gt();O();ar();B();yt();ur();dt();ct();ft();pr();cr();fr();et();xr();K();U();Xt();Er();Ir();Gr();qt();Oe={context:rt,diag:xt,metrics:At,propagation:It,trace:lt}});export{s as a,V as b,W as c,T as d,I as e,q as f,J as g,rt as h,xt as i,At as j,lt as k,Pe as l,Ce as m};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{w as i}from"./chunk-PGXQZVLX.js";import{b as o}from"./chunk-GZPNIYVZ.js";o();import l from"node:path";function d(t,n){if(t.getApprovalMode()!=="bogan")return null;let r=l.resolve(n),s=t.getProjectRoot?.()??t.getTargetDir();if(i(r,s))return null;let e=t.getWorkspaceContext?.();if(!e||(typeof e.isPathWithinWorkspaceFresh=="function"?e.isPathWithinWorkspaceFresh(r):e.isPathWithinWorkspace(r)))return null;let a=e.getDirectories?.()??[t.getTargetDir()],p=t.getChannel?.()==="desktop"?"Approve the folder from Matilda Desktop, then retry the write.":"Use --include-directories to add extra roots, or a non-BOGAN approval mode for intentional external writes.";return`Refusing out-of-workspace write in BOGAN mode: ${r}. Workspace root(s): ${a.join(", ")}. This blocks path typos (e.g. writing under $HOME when the project is elsewhere). `+p}export{d as a};
3
+ import{l as i}from"./chunk-ILHNCXBC.js";import{b as o}from"./chunk-GZPNIYVZ.js";o();import l from"node:path";function d(t,n){if(t.getApprovalMode()!=="bogan")return null;let r=l.resolve(n),s=t.getProjectRoot?.()??t.getTargetDir();if(i(r,s))return null;let e=t.getWorkspaceContext?.();if(!e||(typeof e.isPathWithinWorkspaceFresh=="function"?e.isPathWithinWorkspaceFresh(r):e.isPathWithinWorkspace(r)))return null;let a=e.getDirectories?.()??[t.getTargetDir()],p=t.getChannel?.()==="desktop"?"Approve the folder from Matilda Desktop, then retry the write.":"Use --include-directories to add extra roots, or a non-BOGAN approval mode for intentional external writes.";return`Refusing out-of-workspace write in BOGAN mode: ${r}. Workspace root(s): ${a.join(", ")}. This blocks path typos (e.g. writing under $HOME when the project is elsewhere). `+p}export{d as a};
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2025 Matilda Team
@@ -0,0 +1,8 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{E as h,H as g,L as l,w as m}from"./chunk-7E2YCGHS.js";import{b as p}from"./chunk-GZPNIYVZ.js";p();import*as s from"node:fs";import*as t from"node:path";var M="memory",f="MEMORY.md",d="meta.json",x="extract-cursor.json",R="consolidation.lock",O="memories";function T(r){let o=t.resolve(r);for(;;){let e=t.join(o,".git");if(s.existsSync(e))return o;let n=t.dirname(o);if(n===o)return null;o=n}}function D(r){let o=T(r);if(!o)return null;try{let e=s.readFileSync(t.join(o,".git"),"utf-8").trim();if(!e.startsWith("gitdir:"))return o;let n=t.resolve(o,e.slice(7).trim()),i=t.resolve(n,s.readFileSync(t.join(n,"commondir"),"utf-8").trim());return t.resolve(t.dirname(n))!==t.join(i,"worktrees")||s.realpathSync(s.readFileSync(t.join(n,"gitdir"),"utf-8").trim())!==t.join(s.realpathSync(o),".git")?o:t.basename(i)!==".git"?i.normalize("NFC"):t.dirname(i).normalize("NFC")}catch{return o}}function y(){return process.env.MATILDA_CODE_MEMORY_BASE_DIR?g(void 0,process.env.MATILDA_CODE_MEMORY_BASE_DIR):l.getRuntimeBaseDir()}var A=new Map;function u(r){let o=process.env.MATILDA_CODE_MEMORY_LOCAL==="1",e=o?"":y(),n=`${o?"local":e}\0${r}`,i=A.get(n);if(i!==void 0)return i;let a;if(o)a=t.join(r,m,M);else{let E=D(r)??t.resolve(r);a=t.join(e,"projects",h(E),M)}return A.set(n,a),a}function c(r){return t.dirname(u(r))}function j(r,o){let e=t.normalize(r),n=t.normalize(u(o)),i=t.relative(n,e);return i===""||!i.startsWith("..")&&!t.isAbsolute(i)}function L(r){return t.join(u(r),f)}function S(r){return t.join(c(r),d)}function v(r){return t.join(c(r),x)}function U(r){return t.join(c(r),R)}function _(){return t.join(y(),O)}function F(){return t.join(_(),f)}function I(r){let o=t.normalize(r),e=t.normalize(_()),n=t.relative(e,o);return n===""||!n.startsWith("..")&&!t.isAbsolute(n)}function N(r,o){return j(r,o)||I(r)}export{f as a,y as b,u as c,c as d,j as e,L as f,S as g,v as h,U as i,_ as j,F as k,N as l};
4
+ /**
5
+ * @license
6
+ * Copyright 2025 Google LLC
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */
@@ -0,0 +1,8 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{V as M,b as u}from"./chunk-7E2YCGHS.js";import{b as I}from"./chunk-GZPNIYVZ.js";I();import*as P from"node:crypto";import*as n from"node:fs";import*as f from"node:fs/promises";import*as O from"node:path";var C=M("ATOMIC_WRITE");async function L(t,o,e,i,w=f.rename){for(let a=0;a<=e;a++)try{await w(t,o);return}catch(c){if(!(u(c)&&(c.code==="EPERM"||c.code==="EACCES"))||a===e)throw c;await new Promise(v=>setTimeout(v,i*2**a))}}async function $(t){let e=t;for(let w=0;w<40;w++){let a;try{a=await f.lstat(e)}catch(l){if(u(l)&&l.code==="ENOENT")return e;throw l}if(!a.isSymbolicLink())return e;let c=await f.readlink(e);if(O.isAbsolute(c))e=c;else{let l=await f.realpath(O.dirname(e));e=O.resolve(l,c)}}let i=new Error(`ELOOP: too many levels of symbolic links, resolve '${t}'`);throw i.code="ELOOP",i}async function B(t,o,e,i){let w=e?.retries??3,a=e?.delayMs??50,c=e?.flush??!0,l=e?.encoding??"utf-8",v=i?.rename??f.rename,F=i?.writeFile??f.writeFile,x=i?.open??f.open,T=i?.chmod??f.chmod,A=i?.fchmod??((d,s)=>d.chmod(s)),b=i?.unlink??f.unlink,r=e?.noFollow?t:await $(t).catch(d=>{throw N(d,t)}),S;try{S=await f.stat(r)}catch(d){if(!u(d)||d.code!=="ENOENT")throw d}let W;(!e?.forceMode||e?.mode===void 0)&&(W=S!==void 0?S.mode&4095:void 0);let y=W??e?.mode,p={};typeof o=="string"&&(p.encoding=l),c&&(p.flush=!0),y!==void 0&&(p.mode=y);let k=async d=>{if(y!==void 0)try{await T(d,y)}catch(s){if(!u(s)||s.code!=="ENOSYS"&&s.code!=="ENOTSUP")throw s}},h=()=>{if(S===void 0||process.platform==="win32")return!1;let d=process.geteuid?.();return d===void 0?!1:S.uid!==d};if(S!==void 0&&S.isFile()&&h()){await f.writeFile(r,o,p),await k(r);return}let m=`${r}.${P.randomBytes(6).toString("hex")}.tmp`;try{await F(m,o,p),await k(m),await L(m,r,w,a,v)}catch(d){try{await b(m)}catch{}if(u(d)&&d.code==="EXDEV")try{if(e?.noFollow){try{await b(r)}catch(g){if(!u(g)||g.code!=="ENOENT")throw g}let s=await x(r,n.constants.O_WRONLY|n.constants.O_CREAT|n.constants.O_EXCL,y??438),E=!1;try{try{if(await s.writeFile(typeof o=="string"?Buffer.from(o,l):o),c&&await s.sync(),y!==void 0)try{await A(s,y)}catch(g){if(!u(g)||g.code!=="ENOSYS"&&g.code!=="ENOTSUP")throw g}E=!0}finally{await s.close()}}catch(g){if(!E)try{await b(r)}catch(R){C.debug(`orphan unlink failed for ${r}:`,R)}throw g}}else await F(r,o,p),await k(r);return}catch(s){throw N(s,r)}throw N(d,r)}}function N(t,o,e="atomicWriteFile"){return t instanceof Error&&!t.message.startsWith(`${e}(`)&&(t.message=`${e}(${JSON.stringify(o)}): ${t.message}`),t}async function X(t,o,e){await B(t,JSON.stringify(o,null,2),{encoding:"utf-8",...e})}function H(t){if(t<=0)return;let o=new SharedArrayBuffer(4),e=new Int32Array(o);Atomics.wait(e,0,0,t)}function Y(t,o,e,i,w=n.renameSync){for(let a=0;a<=e;a++)try{w(t,o);return}catch(c){if(!(u(c)&&(c.code==="EPERM"||c.code==="EACCES"))||a===e)throw c;H(i*2**a)}}function D(t){let e=t;for(let w=0;w<40;w++){let a;try{a=n.lstatSync(e)}catch(l){if(u(l)&&l.code==="ENOENT")return e;throw l}if(!a.isSymbolicLink())return e;let c=n.readlinkSync(e);if(O.isAbsolute(c))e=c;else{let l=n.realpathSync(O.dirname(e));e=O.resolve(l,c)}}let i=new Error(`ELOOP: too many levels of symbolic links, resolve '${t}'`);throw i.code="ELOOP",i}function V(t,o,e,i){let w=e?.retries??3,a=e?.delayMs??50,c=e?.flush??!0,l=e?.encoding??"utf-8",v=i?.rename??n.renameSync,F=i?.writeFile??n.writeFileSync,x=i?.open??n.openSync,T=i?.chmod??n.chmodSync,A=i?.fchmod??n.fchmodSync,b=i?.unlink??n.unlinkSync,r;if(e?.noFollow)r=t;else try{r=D(t)}catch(h){throw N(h,t,"atomicWriteFileSync")}let S=`${r}.${P.randomBytes(6).toString("hex")}.tmp`,W;if(!e?.forceMode||e?.mode===void 0)try{W=n.statSync(r).mode&4095}catch(h){if(!u(h)||h.code!=="ENOENT")throw h}let y=W??e?.mode,p={};typeof o=="string"&&(p.encoding=l),c&&(p.flush=!0),y!==void 0&&(p.mode=y);let k=h=>{if(y!==void 0)try{T(h,y)}catch(m){if(!u(m)||m.code!=="ENOSYS"&&m.code!=="ENOTSUP")throw m}};try{F(S,o,p),k(S),Y(S,r,w,a,v)}catch(h){try{b(S)}catch{}if(u(h)&&h.code==="EXDEV")try{if(e?.noFollow){try{b(r)}catch(s){if(!u(s)||s.code!=="ENOENT")throw s}let m=x(r,n.constants.O_WRONLY|n.constants.O_CREAT|n.constants.O_EXCL,y??438),d=!1;try{try{let s=typeof o=="string"?Buffer.from(o,l):o;if(n.writeFileSync(m,s),c&&n.fsyncSync(m),y!==void 0)try{A(m,y)}catch(E){if(!u(E)||E.code!=="ENOSYS"&&E.code!=="ENOTSUP")throw E}d=!0}finally{n.closeSync(m)}}catch(s){if(!d)try{b(r)}catch(E){C.debug(`orphan unlink failed for ${r}:`,E)}throw s}}else F(r,o,p),k(r);return}catch(m){throw N(m,r,"atomicWriteFileSync")}throw N(h,r,"atomicWriteFileSync")}}export{B as a,X as b,V as c};
4
+ /**
5
+ * @license
6
+ * Copyright 2025 Matilda Team
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */
@@ -6,4 +6,4 @@ import{b as d}from"./chunk-GZPNIYVZ.js";import{a as g,d as E,f as P}from"./chunk
6
6
  `+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
7
7
  `)+`\r
8
8
  \r
9
- `+s)}function F(t,e,s,r,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,F),t.emit("wsClientError",o,s,e)}else re(s,r,i,n)}});d();var mr=P(Ft(),1),pr=P(ue(),1),gr=P($(),1),yr=P(Ne(),1),xr=P(Re(),1),Sr=P(Ae(),1),Ht=P(pe(),1),Er=P(zt(),1);var Jr=Ht.default;export{Ht as a,Er as b,Jr as c};
9
+ `+s)}function F(t,e,s,r,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,F),t.emit("wsClientError",o,s,e)}else re(s,r,i,n)}});d();var mr=P(Ft(),1),pr=P(ue(),1),gr=P($(),1),yr=P(Ne(),1),xr=P(Re(),1),Sr=P(Ae(),1),Ht=P(pe(),1),Er=P(zt(),1);var Jr=Ht.default;export{Jr as a};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{g as o,i as a,p as u,q as n}from"./chunk-TWJLOEAI.js";import{b as s}from"./chunk-GZPNIYVZ.js";s();var i=`Submit your final answer as structured JSON that conforms to the provided schema.
3
+ import{f as o,g as a,m as u,n}from"./chunk-POGNX7U3.js";import{b as s}from"./chunk-GZPNIYVZ.js";s();var i=`Submit your final answer as structured JSON that conforms to the provided schema.
4
4
 
5
5
  CRITICAL: In structured-output mode, this is the ONLY way to deliver the final result. Call this tool to deliver the final result; the first call with valid arguments ends the session. Do not emit the final answer as plain text \u2014 it will be discarded. Use other tools (Read, Grep, etc.) to gather the information you need before calling this tool.
6
6
 
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as r}from"./chunk-V6UPUMP3.js";import{ba as g}from"./chunk-27Q5KW3A.js";import{b as f}from"./chunk-GZPNIYVZ.js";f();function h(n,o){return`Base directory for this skill: ${n}
3
+ import{a as r}from"./chunk-V6UPUMP3.js";import{V as g}from"./chunk-7E2YCGHS.js";import{b as f}from"./chunk-GZPNIYVZ.js";f();function h(n,o){return`Base directory for this skill: ${n}
4
4
  Important: ALWAYS resolve absolute paths from this base directory when working with skills.
5
5
 
6
6
  ${o}
@@ -0,0 +1,8 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{d as T}from"./chunk-V4VILMIK.js";import{b as W}from"./chunk-7ZODGQO6.js";import{a as P}from"./chunk-GT6MSEK4.js";import{b as g}from"./chunk-J3ZCE3TA.js";import{V as _,b as l}from"./chunk-7E2YCGHS.js";import{b as x}from"./chunk-GZPNIYVZ.js";import{f as U}from"./chunk-OWGSC52X.js";x();var F=U(W(),1);import*as d from"node:fs/promises";import{constants as B}from"node:fs";import*as b from"node:path";var f=_("AGENTS_TEAM_TASKS"),$=32768,v=16;function M(r){if(!r)return;let e=Buffer.byteLength(JSON.stringify(r),"utf-8");if(e>$)throw new Error(`Task metadata is too large (${e} bytes; max ${$}). Trim the payload or store the bulk content elsewhere.`)}var X={retries:{retries:30,minTimeout:5,maxTimeout:100,factor:2,randomize:!0},stale:5e3,onCompromised:r=>{f.warn("task lock compromised:",r?.message??r)}},A=new Map;function K(r){let e=A.get(r);return e||(e=new P,A.set(r,e)),e}async function h(r,e,t){return K(r).runExclusive(async()=>{let i;try{i=await F.default.lock(r,X)}catch(o){if(l(o)&&o.code==="ENOENT")return t();throw o}try{return await e()}finally{await i()}})}var q="__reciprocal__",j=new Map;function z(r){let e=j.get(r);return e||(e=new P,j.set(r,e)),e}function Y(r){if(!/^[1-9]\d*$/.test(r))throw new Error(`Invalid task ID "${r}". Task IDs must be positive integers.`)}function m(r,e){return Y(e),b.join(T(r),`${e}.json`)}var O=new Set;function ae(r){return O.add(r),()=>{O.delete(r)}}function k(r){for(let e of O)try{e(r)}catch(t){f.warn(`task update listener failed: ${t}`)}}async function ie(r,e){M(e.metadata);let t=T(r);await d.mkdir(t,{recursive:!0});let i=15;for(let o=0;o<i;o++){let c=await Z(t),s={id:c,subject:e.subject,description:e.description,activeForm:e.activeForm,owner:e.owner,status:"pending",blocks:[],blockedBy:[],metadata:e.metadata},n=b.join(t,`${c}.json`);try{await(await d.open(n,B.O_WRONLY|B.O_CREAT|B.O_EXCL)).close()}catch(a){if(l(a)&&a.code==="EEXIST")continue;throw a}try{await g(n,s)}catch(a){throw await d.unlink(n).catch(()=>{}),a}return k(r),s}throw new Error(`Failed to create task after ${i} attempts (ID contention).`)}async function oe(r,e){let t=m(r,e);try{let i=await d.readFile(t,"utf-8");return JSON.parse(i)}catch(i){if(l(i)&&i.code==="ENOENT")return;throw i}}var p=class extends Error{constructor(t,i,o){super(`Task #${t} is owned by "${o}". Only the leader or the owner can change status / owner / subject / description / blocks.`);this.taskId=t;this.callerName=i;this.actualOwner=o;this.name="TaskOwnershipError"}};async function ce(r,e,t,i){let o=m(r,e);return h(o,async()=>{let c;try{c=await d.readFile(o,"utf-8")}catch(n){if(l(n)&&n.code==="ENOENT")return;throw n}let s=JSON.parse(c);if(i?.callerName!==void 0&&i.callerName!==q&&(t.status!==void 0||t.owner!==void 0||t.subject!==void 0||t.description!==void 0||(t.addBlocks?.length??0)>0||(t.addBlockedBy?.length??0)>0)&&s.owner&&s.owner!==i.callerName)throw new p(e,i.callerName,s.owner);if(t.addBlocks?.length){let n=new Set(s.blocks);for(let a of t.addBlocks)n.add(a);s.blocks=Array.from(n)}if(t.addBlockedBy?.length){let n=new Set(s.blockedBy);for(let a of t.addBlockedBy)n.add(a);s.blockedBy=Array.from(n)}if(t.status!==void 0&&(s.status=t.status,t.status==="completed"&&s.blocks.length>0&&await Q(r,e,s.blocks)),t.owner!==void 0&&(s.owner=t.owner?t.owner:void 0),t.subject!==void 0&&(s.subject=t.subject),t.description!==void 0&&(s.description=t.description),t.activeForm!==void 0&&(s.activeForm=t.activeForm??void 0),t.metadata!==void 0){s.metadata=s.metadata??{};for(let[n,a]of Object.entries(t.metadata))n==="__proto__"||n==="constructor"||n==="prototype"||(a===null?delete s.metadata[n]:s.metadata[n]=a);Object.keys(s.metadata).length===0&&(s.metadata=void 0),M(s.metadata)}return await g(o,s),k(r),s},()=>{})}async function de(r,e,t){let i=m(r,e),o=await h(i,async()=>{let s;try{let a=await d.readFile(i,"utf-8");s=JSON.parse(a)}catch(a){if(l(a)&&a.code==="ENOENT")return null;throw a}if(t?.callerName!==void 0&&s.owner&&s.owner!==t.callerName)throw new p(e,t.callerName,s.owner);let n=new Set([...s.blocks,...s.blockedBy]);n.delete(e);try{await d.unlink(i)}catch(a){if(l(a)&&a.code==="ENOENT")return null;throw a}return n},()=>null);if(o===null)return!1;let c=await Promise.allSettled(Array.from(o).map(s=>G(r,s,e)));for(let s of c)s.status==="rejected"&&f.warn(`deleteTask(${e}): edge cleanup failed: ${s.reason}`);return k(r),!0}async function G(r,e,t){let i=m(r,e);await h(i,async()=>{try{let o=await d.readFile(i,"utf-8"),c=JSON.parse(o),s=c.blocks.length,n=c.blockedBy.length;if(c.blocks=c.blocks.filter(a=>a!==t),c.blockedBy=c.blockedBy.filter(a=>a!==t),c.blocks.length===s&&c.blockedBy.length===n)return;await g(i,c)}catch(o){if(l(o)&&o.code==="ENOENT")return;throw o}},()=>{})}async function R(r,e){let t=T(r),i;try{i=await d.readdir(t)}catch(n){if(l(n)&&n.code==="ENOENT")return[];let a=n instanceof Error?n.message:String(n);throw f.warn(`Failed to list tasks dir ${t}: ${a}`),n instanceof Error?n:new Error(a)}let o=i.filter(n=>n.endsWith(".json")),c=[];for(let n=0;n<o.length;n+=v){let a=o.slice(n,n+v),w=await Promise.all(a.map(async C=>{let y=b.join(t,C),S;try{S=await d.readFile(y,"utf-8")}catch(u){if(l(u)&&u.code==="ENOENT")return;let E=u instanceof Error?u.message:String(u);f.warn(`Failed to read task file ${y}: ${E}`);return}if(S.trim()!=="")try{return JSON.parse(S)}catch(u){let E=u instanceof Error?u.message:String(u);f.warn(`Quarantining corrupt task file ${y}: ${E}`);let D=`${y}.corrupt-${Date.now()}`;try{await d.rename(y,D)}catch(N){let J=N instanceof Error?N.message:String(N);f.warn(`Failed to quarantine ${y}: ${J}`)}return}}));c.push(...w)}let s=c.filter(n=>n!==void 0);return s.sort((n,a)=>Number(n.id)-Number(a.id)),e?s.filter(n=>!(e.status!==void 0&&n.status!==e.status||e.owner!==void 0&&n.owner!==e.owner||e.blockedBy!==void 0&&!n.blockedBy.includes(e.blockedBy))):s}async function le(r){let e=T(r);await d.rm(e,{recursive:!0,force:!0}),k(r)}async function Q(r,e,t){let i=await Promise.allSettled(t.map(async o=>{let c=m(r,o);await h(c,async()=>{let s;try{s=await d.readFile(c,"utf-8")}catch(w){if(l(w)&&w.code==="ENOENT")return;throw w}let n=JSON.parse(s),a=n.blockedBy.length;n.blockedBy=n.blockedBy.filter(w=>w!==e),n.blockedBy.length!==a&&await g(c,n)},()=>{})}));for(let o of i)o.status==="rejected"&&f.warn(`unblockDependents(${e}): ${o.reason}`);k(r)}async function ue(r,e,t,i){return i?.checkAgentBusy?z(t).runExclusive(()=>L(r,e,t,i,!0)):L(r,e,t,i,!1)}async function L(r,e,t,i,o){if(o&&await V(r,t))return;let c=m(r,e);return h(c,async()=>{let s;try{s=await d.readFile(c,"utf-8")}catch(a){if(l(a)&&a.code==="ENOENT")return;throw a}let n=JSON.parse(s);if(n.status==="pending"&&!n.owner)return n.owner=i?.ownerName??t,n.status="in_progress",await g(c,n),k(r),n},()=>{})}async function V(r,e){let t=await R(r,{status:"in_progress"}),i=e.split("@")[0];return t.some(o=>o.owner===e||o.owner===i)}async function H(r,e,t){let i=m(r,e);return h(i,async()=>{let o;try{o=await d.readFile(i,"utf-8")}catch(s){if(l(s)&&s.code==="ENOENT")return!1;throw s}let c=JSON.parse(o);return c.status!=="in_progress"||c.owner!==t?!1:(c.owner=void 0,c.status="pending",await g(i,c),!0)},()=>!1)}async function fe(r,e){let t=e.split("@")[0],o=(await R(r,{status:"in_progress"})).filter(a=>a.owner===e||a.owner===t),c=await Promise.allSettled(o.map(a=>H(r,a.id,a.owner))),s=c.filter(a=>a.status==="rejected");s.length>0&&f.warn(`unassignTeammateTasks: ${s.length}/${o.length} task(s) failed to unassign for ${e}`);let n=c.filter(a=>a.status==="fulfilled"&&a.value===!0).length;return n>0&&k(r),n}async function Z(r){let e;try{e=await d.readdir(r)}catch{return"1"}let t=0;for(let i of e){if(!i.endsWith(".json"))continue;let o=parseInt(i.replace(".json",""),10);!isNaN(o)&&o>t&&(t=o)}return String(t+1)}export{q as a,Y as b,ae as c,ie as d,oe as e,p as f,ce as g,de as h,R as i,le as j,ue as k,fe as l};
4
+ /**
5
+ * @license
6
+ * Copyright 2025 Matilda
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */