agentix-cli 0.137.2 → 0.138.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 (148) hide show
  1. package/dist/{App-TOAWET76.js → App-F42CYCKX.js} +2 -2
  2. package/dist/{ChatApp-4DRCRKFS.js → ChatApp-RPMQBKHV.js} +2 -2
  3. package/dist/{absorb-eval-OXNL5QGQ.js → absorb-eval-HRPEHJSO.js} +2 -2
  4. package/dist/{agent-GALMGMNJ.js → agent-L5CJF3GH.js} +2 -2
  5. package/dist/{board-dashboard-2A6VSQ7V.js → board-dashboard-33NGOGWC.js} +440 -285
  6. package/dist/board-dashboard-33NGOGWC.js.map +1 -0
  7. package/dist/{chunk-XZIKAHFU.js → chunk-375MXG3H.js} +2 -2
  8. package/dist/{chunk-5ADXRVYT.js → chunk-4HHHVWDB.js} +5 -5
  9. package/dist/{chunk-Q72TK3DO.js → chunk-5HLD66CW.js} +2 -2
  10. package/dist/{chunk-5RHCM3L7.js → chunk-6AUWEL6V.js} +2 -2
  11. package/dist/{chunk-635B6SXI.js → chunk-6VP2KMUM.js} +2 -2
  12. package/dist/{chunk-WCXXXAHV.js → chunk-7DYVNET6.js} +1 -1
  13. package/dist/chunk-7DYVNET6.js.map +1 -0
  14. package/dist/{chunk-3K3LRLZX.js → chunk-7V73QTQ7.js} +2 -2
  15. package/dist/{chunk-PNITKKDR.js → chunk-7YZL5MUL.js} +9 -9
  16. package/dist/{chunk-PNITKKDR.js.map → chunk-7YZL5MUL.js.map} +1 -1
  17. package/dist/chunk-A5GYG56I.js +2 -0
  18. package/dist/chunk-A5GYG56I.js.map +1 -0
  19. package/dist/{chunk-GIQKQD2B.js → chunk-AGQYUOZY.js} +2 -2
  20. package/dist/{chunk-2JKKGS77.js → chunk-AP4DADXG.js} +2 -2
  21. package/dist/{chunk-DIE6XXJF.js → chunk-CZZJEFUM.js} +2 -2
  22. package/dist/{chunk-23LWLYOK.js → chunk-DBJUGKX2.js} +2 -2
  23. package/dist/{chunk-B6PMIUVV.js → chunk-EGPCEQJN.js} +2 -2
  24. package/dist/{chunk-ZYUVKFX2.js → chunk-GAIXI26T.js} +2 -2
  25. package/dist/{chunk-KHYF6KTY.js → chunk-HJCFLGVT.js} +13 -13
  26. package/dist/chunk-HJCFLGVT.js.map +1 -0
  27. package/dist/{chunk-VDG6Y5L3.js → chunk-HQH44RGL.js} +2 -2
  28. package/dist/chunk-IS2IWRP7.js +4 -0
  29. package/dist/chunk-IS2IWRP7.js.map +1 -0
  30. package/dist/{chunk-BXXP6DTB.js → chunk-JIJDBCV7.js} +2 -2
  31. package/dist/{chunk-Z2QOQBUS.js → chunk-LA6P3TUK.js} +2 -2
  32. package/dist/{chunk-SQ37I2MD.js → chunk-MTDVAO5C.js} +2 -2
  33. package/dist/{chunk-7JUISIE7.js → chunk-QGSUENRK.js} +2 -2
  34. package/dist/{chunk-PNYBZPPB.js → chunk-SK47VJMQ.js} +3 -3
  35. package/dist/{chunk-RWMDDMYX.js → chunk-TFH6S7IT.js} +2 -2
  36. package/dist/{chunk-QY5YUHGW.js → chunk-TVW5ZKJY.js} +2 -2
  37. package/dist/{chunk-RTKSSFX2.js → chunk-UPNKRCFX.js} +7 -7
  38. package/dist/{chunk-IIFHX625.js → chunk-UPQTTOVQ.js} +2 -2
  39. package/dist/{chunk-E3AEOQMK.js → chunk-VVX4RXMV.js} +2 -2
  40. package/dist/{chunk-PLPDG6GE.js → chunk-XBARUCG5.js} +2 -2
  41. package/dist/{chunk-MXDWLBIA.js → chunk-XVYIPVSC.js} +2 -2
  42. package/dist/{chunk-JC5KLH2K.js → chunk-Y7IHOQC7.js} +2 -2
  43. package/dist/cli.js +1 -1
  44. package/dist/cli.js.map +1 -1
  45. package/dist/{client-PWE4BJH4.js → client-EB55Y6EJ.js} +2 -2
  46. package/dist/{config-E53FBZ47.js → config-7DRUA5R3.js} +2 -2
  47. package/dist/{config-mutate-ZEHN6JMZ.js → config-mutate-GGA7VXXH.js} +2 -2
  48. package/dist/config-mutator-POFVILXH.js +2 -0
  49. package/dist/{contributions-CLLCLS3O.js → contributions-TZ26MTML.js} +2 -2
  50. package/dist/{doctor-XKT5FWPO.js → doctor-GTRZ7GWF.js} +2 -2
  51. package/dist/{follow-up-tool-ZFRZUZLI.js → follow-up-tool-PNB7KMCY.js} +2 -2
  52. package/dist/{hub-N5ADP3LO.js → hub-QWJR4E6V.js} +2 -2
  53. package/dist/index.js +1 -1
  54. package/dist/net-family-X2P3OVDP.js +2 -0
  55. package/dist/ntfy-Q4YHFKWW.js +2 -0
  56. package/dist/{program-AMQ7JGHO.js → program-KMUCHLDU.js} +23 -23
  57. package/dist/{program-AMQ7JGHO.js.map → program-KMUCHLDU.js.map} +1 -1
  58. package/dist/{promote-M4UBD2R6.js → promote-HAPXWGYH.js} +2 -2
  59. package/dist/push-PRFZMCIK.js +2 -0
  60. package/dist/push-bridge-276ZLSUT.js +2 -0
  61. package/dist/{query-KMQHF5HW.js → query-ICLOVLZ3.js} +2 -2
  62. package/dist/{query-settings-PENAE4UG.js → query-settings-7AXUOHDL.js} +2 -2
  63. package/dist/{registry-GYKSYSDD.js → registry-IUNSHCOL.js} +2 -2
  64. package/dist/{request-planner-GBX6DHRQ.js → request-planner-TDCLF2CH.js} +2 -2
  65. package/dist/{review-candidates-SYMRJGI2.js → review-candidates-QCBXLWG6.js} +2 -2
  66. package/dist/{routing-S3L44JLL.js → routing-YUP3HHL5.js} +2 -2
  67. package/dist/schedule-tool-3C22NBMN.js +2 -0
  68. package/dist/{scheduler-AW4F5ZKS.js → scheduler-7NK2FH5V.js} +2 -2
  69. package/dist/{seat-QBBNCOFO.js → seat-PTPPQOTP.js} +2 -2
  70. package/dist/{select-ZCFIMYWS.js → select-2XSTWMBR.js} +2 -2
  71. package/dist/{set-enabled-4F27A3U2.js → set-enabled-SS5Q3OX7.js} +2 -2
  72. package/dist/{tool-M462KSMF.js → tool-QCMSXEDB.js} +2 -2
  73. package/dist/{tool-G6XTO24J.js → tool-RK4LDFFH.js} +2 -2
  74. package/dist/{wiki-JXVHIEZI.js → wiki-Q2E44YAE.js} +2 -2
  75. package/dist/wiki-enrich-6ULCDOTX.js +2 -0
  76. package/package.json +1 -1
  77. package/dist/board-dashboard-2A6VSQ7V.js.map +0 -1
  78. package/dist/chunk-GFKLKPPY.js +0 -4
  79. package/dist/chunk-GFKLKPPY.js.map +0 -1
  80. package/dist/chunk-KHYF6KTY.js.map +0 -1
  81. package/dist/chunk-PBP3D2BM.js +0 -2
  82. package/dist/chunk-PBP3D2BM.js.map +0 -1
  83. package/dist/chunk-WCXXXAHV.js.map +0 -1
  84. package/dist/config-mutator-AK775RTM.js +0 -2
  85. package/dist/net-family-OFHIZDHS.js +0 -2
  86. package/dist/ntfy-W56TUC5C.js +0 -2
  87. package/dist/push-B2GNI3VQ.js +0 -2
  88. package/dist/push-bridge-F4PCXWJF.js +0 -2
  89. package/dist/schedule-tool-FXUFRZHR.js +0 -2
  90. package/dist/wiki-enrich-6776OMUB.js +0 -2
  91. /package/dist/{App-TOAWET76.js.map → App-F42CYCKX.js.map} +0 -0
  92. /package/dist/{ChatApp-4DRCRKFS.js.map → ChatApp-RPMQBKHV.js.map} +0 -0
  93. /package/dist/{absorb-eval-OXNL5QGQ.js.map → absorb-eval-HRPEHJSO.js.map} +0 -0
  94. /package/dist/{agent-GALMGMNJ.js.map → agent-L5CJF3GH.js.map} +0 -0
  95. /package/dist/{chunk-XZIKAHFU.js.map → chunk-375MXG3H.js.map} +0 -0
  96. /package/dist/{chunk-5ADXRVYT.js.map → chunk-4HHHVWDB.js.map} +0 -0
  97. /package/dist/{chunk-Q72TK3DO.js.map → chunk-5HLD66CW.js.map} +0 -0
  98. /package/dist/{chunk-5RHCM3L7.js.map → chunk-6AUWEL6V.js.map} +0 -0
  99. /package/dist/{chunk-635B6SXI.js.map → chunk-6VP2KMUM.js.map} +0 -0
  100. /package/dist/{chunk-3K3LRLZX.js.map → chunk-7V73QTQ7.js.map} +0 -0
  101. /package/dist/{chunk-GIQKQD2B.js.map → chunk-AGQYUOZY.js.map} +0 -0
  102. /package/dist/{chunk-2JKKGS77.js.map → chunk-AP4DADXG.js.map} +0 -0
  103. /package/dist/{chunk-DIE6XXJF.js.map → chunk-CZZJEFUM.js.map} +0 -0
  104. /package/dist/{chunk-23LWLYOK.js.map → chunk-DBJUGKX2.js.map} +0 -0
  105. /package/dist/{chunk-B6PMIUVV.js.map → chunk-EGPCEQJN.js.map} +0 -0
  106. /package/dist/{chunk-ZYUVKFX2.js.map → chunk-GAIXI26T.js.map} +0 -0
  107. /package/dist/{chunk-VDG6Y5L3.js.map → chunk-HQH44RGL.js.map} +0 -0
  108. /package/dist/{chunk-BXXP6DTB.js.map → chunk-JIJDBCV7.js.map} +0 -0
  109. /package/dist/{chunk-Z2QOQBUS.js.map → chunk-LA6P3TUK.js.map} +0 -0
  110. /package/dist/{chunk-SQ37I2MD.js.map → chunk-MTDVAO5C.js.map} +0 -0
  111. /package/dist/{chunk-7JUISIE7.js.map → chunk-QGSUENRK.js.map} +0 -0
  112. /package/dist/{chunk-PNYBZPPB.js.map → chunk-SK47VJMQ.js.map} +0 -0
  113. /package/dist/{chunk-RWMDDMYX.js.map → chunk-TFH6S7IT.js.map} +0 -0
  114. /package/dist/{chunk-QY5YUHGW.js.map → chunk-TVW5ZKJY.js.map} +0 -0
  115. /package/dist/{chunk-RTKSSFX2.js.map → chunk-UPNKRCFX.js.map} +0 -0
  116. /package/dist/{chunk-IIFHX625.js.map → chunk-UPQTTOVQ.js.map} +0 -0
  117. /package/dist/{chunk-E3AEOQMK.js.map → chunk-VVX4RXMV.js.map} +0 -0
  118. /package/dist/{chunk-PLPDG6GE.js.map → chunk-XBARUCG5.js.map} +0 -0
  119. /package/dist/{chunk-MXDWLBIA.js.map → chunk-XVYIPVSC.js.map} +0 -0
  120. /package/dist/{chunk-JC5KLH2K.js.map → chunk-Y7IHOQC7.js.map} +0 -0
  121. /package/dist/{client-PWE4BJH4.js.map → client-EB55Y6EJ.js.map} +0 -0
  122. /package/dist/{config-E53FBZ47.js.map → config-7DRUA5R3.js.map} +0 -0
  123. /package/dist/{config-mutate-ZEHN6JMZ.js.map → config-mutate-GGA7VXXH.js.map} +0 -0
  124. /package/dist/{config-mutator-AK775RTM.js.map → config-mutator-POFVILXH.js.map} +0 -0
  125. /package/dist/{contributions-CLLCLS3O.js.map → contributions-TZ26MTML.js.map} +0 -0
  126. /package/dist/{doctor-XKT5FWPO.js.map → doctor-GTRZ7GWF.js.map} +0 -0
  127. /package/dist/{follow-up-tool-ZFRZUZLI.js.map → follow-up-tool-PNB7KMCY.js.map} +0 -0
  128. /package/dist/{hub-N5ADP3LO.js.map → hub-QWJR4E6V.js.map} +0 -0
  129. /package/dist/{net-family-OFHIZDHS.js.map → net-family-X2P3OVDP.js.map} +0 -0
  130. /package/dist/{ntfy-W56TUC5C.js.map → ntfy-Q4YHFKWW.js.map} +0 -0
  131. /package/dist/{promote-M4UBD2R6.js.map → promote-HAPXWGYH.js.map} +0 -0
  132. /package/dist/{push-B2GNI3VQ.js.map → push-PRFZMCIK.js.map} +0 -0
  133. /package/dist/{push-bridge-F4PCXWJF.js.map → push-bridge-276ZLSUT.js.map} +0 -0
  134. /package/dist/{query-KMQHF5HW.js.map → query-ICLOVLZ3.js.map} +0 -0
  135. /package/dist/{query-settings-PENAE4UG.js.map → query-settings-7AXUOHDL.js.map} +0 -0
  136. /package/dist/{registry-GYKSYSDD.js.map → registry-IUNSHCOL.js.map} +0 -0
  137. /package/dist/{request-planner-GBX6DHRQ.js.map → request-planner-TDCLF2CH.js.map} +0 -0
  138. /package/dist/{review-candidates-SYMRJGI2.js.map → review-candidates-QCBXLWG6.js.map} +0 -0
  139. /package/dist/{routing-S3L44JLL.js.map → routing-YUP3HHL5.js.map} +0 -0
  140. /package/dist/{schedule-tool-FXUFRZHR.js.map → schedule-tool-3C22NBMN.js.map} +0 -0
  141. /package/dist/{scheduler-AW4F5ZKS.js.map → scheduler-7NK2FH5V.js.map} +0 -0
  142. /package/dist/{seat-QBBNCOFO.js.map → seat-PTPPQOTP.js.map} +0 -0
  143. /package/dist/{select-ZCFIMYWS.js.map → select-2XSTWMBR.js.map} +0 -0
  144. /package/dist/{set-enabled-4F27A3U2.js.map → set-enabled-SS5Q3OX7.js.map} +0 -0
  145. /package/dist/{tool-M462KSMF.js.map → tool-QCMSXEDB.js.map} +0 -0
  146. /package/dist/{tool-G6XTO24J.js.map → tool-RK4LDFFH.js.map} +0 -0
  147. /package/dist/{wiki-JXVHIEZI.js.map → wiki-Q2E44YAE.js.map} +0 -0
  148. /package/dist/{wiki-enrich-6776OMUB.js.map → wiki-enrich-6ULCDOTX.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ import u from"node:net";import{existsSync as f,readFileSync as s}from"node:fs";import{resolve as i}from"node:path";function p(e){let t=u.getDefaultAutoSelectFamilyAttemptTimeout,n=u.setDefaultAutoSelectFamilyAttemptTimeout;if(typeof t!="function"||typeof n!="function")return;let o=t();return e>o&&n(e),t()}var c=5e3;function g(e=process.cwd(),t){let n=t?[i(e,t)]:[i(e,"agentx.json"),i(e,".agentx/config.json")];for(let o of n)if(f(o)){try{let r=JSON.parse(s(o,"utf-8"))?.node?.connectAttemptTimeoutMs;if(Number.isInteger(r)&&r>=250&&r<=6e4)return r}catch{}break}return c}function l(e){for(let t=0;t<e.length;t++){let n=e[t];if(n==="--")break;if(n.startsWith("--config="))return n.slice(9)||void 0;let o=e[t+1];if(n==="--config"&&o||n==="-c"&&o?.endsWith(".json"))return o}}export{p as a,c as b,g as c,l as d};
2
+ //# sourceMappingURL=chunk-A5GYG56I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/daemon/net-family.ts"],"sourcesContent":["import net from \"node:net\"\nimport { existsSync, readFileSync } from \"node:fs\"\nimport { resolve } from \"node:path\"\n\n// --- Connect attempt timeout for dual-stack hosts (#930) ---\n//\n// Node 20+ turns on `autoSelectFamily` (happy eyeballs) for every outbound\n// connection, fetch included, and gives each address only 250 ms to connect\n// before moving to the next. On a host that resolves both A and AAAA but has\n// no IPv6 route, the IPv6 attempt fails at once and the IPv4 attempt is then\n// abandoned after 250 ms. A slow uplink whose TCP connect takes longer fails\n// every request with ETIMEDOUT about 300 ms in, while curl from the same\n// host succeeds. Raising the per-attempt timeout keeps happy eyeballs and\n// lets a slow but working link connect.\n\n/**\n * Raise Node's per-address connect attempt timeout to `ms`. Never lowers a\n * larger value already set (for example with\n * `--network-family-autoselection-attempt-timeout`). Returns the value in\n * effect afterwards, or undefined when this Node has no such setting.\n */\nexport function applyConnectAttemptTimeout(ms: number): number | undefined {\n const get = (net as any).getDefaultAutoSelectFamilyAttemptTimeout as (() => number) | undefined\n const set = (net as any).setDefaultAutoSelectFamilyAttemptTimeout as ((v: number) => void) | undefined\n if (typeof get !== \"function\" || typeof set !== \"function\") return undefined\n const current = get()\n if (ms > current) set(ms)\n return get()\n}\n\nexport const DEFAULT_CONNECT_ATTEMPT_TIMEOUT_MS = 5000\n\n/**\n * `node.connectAttemptTimeoutMs` read straight from the config file, for CLI\n * commands that call out on their own and never load the full daemon config.\n * Falls back to the default when there is no file or no valid value.\n */\nexport function readConnectAttemptTimeout(cwd: string = process.cwd(), configPath?: string): number {\n const candidates = configPath\n ? [resolve(cwd, configPath)]\n : [resolve(cwd, \"agentx.json\"), resolve(cwd, \".agentx/config.json\")]\n for (const p of candidates) {\n if (!existsSync(p)) continue\n try {\n const v = JSON.parse(readFileSync(p, \"utf-8\"))?.node?.connectAttemptTimeoutMs\n if (Number.isInteger(v) && v >= 250 && v <= 60_000) return v\n } catch { /* an invalid file is reported by whatever loads it in full */ }\n break\n }\n return DEFAULT_CONNECT_ATTEMPT_TIMEOUT_MS\n}\n\n/**\n * The config path given on the command line (`--config <path>`,\n * `--config=<path>`, or `-c <path>` naming a `.json` file), read before\n * commander parses anything. `-c` alone also means `--cwd` for some\n * commands, which names a folder, hence the `.json` check.\n */\nexport function configPathFromArgv(argv: string[]): string | undefined {\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i]\n if (a === \"--\") break\n if (a.startsWith(\"--config=\")) return a.slice(\"--config=\".length) || undefined\n const next = argv[i + 1]\n if (a === \"--config\" && next) return next\n if (a === \"-c\" && next?.endsWith(\".json\")) return next\n }\n return undefined\n}\n"],"mappings":"AAAA,OAAOA,MAAS,WAChB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,UACzC,OAAS,WAAAC,MAAe,YAmBjB,SAASC,EAA2BC,EAAgC,CACzE,IAAMC,EAAON,EAAY,yCACnBO,EAAOP,EAAY,yCACzB,GAAI,OAAOM,GAAQ,YAAc,OAAOC,GAAQ,WAAY,OAC5D,IAAMC,EAAUF,EAAI,EACpB,OAAID,EAAKG,GAASD,EAAIF,CAAE,EACjBC,EAAI,CACb,CAEO,IAAMG,EAAqC,IAO3C,SAASC,EAA0BC,EAAc,QAAQ,IAAI,EAAGC,EAA6B,CAClG,IAAMC,EAAaD,EACf,CAACT,EAAQQ,EAAKC,CAAU,CAAC,EACzB,CAACT,EAAQQ,EAAK,aAAa,EAAGR,EAAQQ,EAAK,qBAAqB,CAAC,EACrE,QAAWG,KAAKD,EACd,GAAKZ,EAAWa,CAAC,EACjB,IAAI,CACF,IAAMC,EAAI,KAAK,MAAMb,EAAaY,EAAG,OAAO,CAAC,GAAG,MAAM,wBACtD,GAAI,OAAO,UAAUC,CAAC,GAAKA,GAAK,KAAOA,GAAK,IAAQ,OAAOA,CAC7D,MAAE,CAAuE,CACzE,MAEF,OAAON,CACT,CAQO,SAASO,EAAmBC,EAAoC,CACrE,QAASC,EAAI,EAAGA,EAAID,EAAK,OAAQC,IAAK,CACpC,IAAMC,EAAIF,EAAKC,CAAC,EAChB,GAAIC,IAAM,KAAM,MAChB,GAAIA,EAAE,WAAW,WAAW,EAAG,OAAOA,EAAE,MAAM,CAAkB,GAAK,OACrE,IAAMC,EAAOH,EAAKC,EAAI,CAAC,EAEvB,GADIC,IAAM,YAAcC,GACpBD,IAAM,MAAQC,GAAM,SAAS,OAAO,EAAG,OAAOA,EAGtD","names":["net","existsSync","readFileSync","resolve","applyConnectAttemptTimeout","ms","get","set","current","DEFAULT_CONNECT_ATTEMPT_TIMEOUT_MS","readConnectAttemptTimeout","cwd","configPath","candidates","p","v","configPathFromArgv","argv","i","a","next"]}
@@ -1,4 +1,4 @@
1
- import{Aa as m,sa as l}from"./chunk-KHYF6KTY.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
1
+ import{Aa as m,sa as l}from"./chunk-HJCFLGVT.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
2
2
  `,f=t+".tmp";a(f,c,"utf-8");try{JSON.parse(u(f,"utf-8"))}catch(d){throw new Error(`config did not round-trip cleanly: ${d.message}`)}let r;return n.skipBackup||(r=`${t}.bak.${Date.now()}`,y(t,r)),a(t,c,"utf-8"),n.skipReload||h().catch(()=>{}),{summary:s.summary,payload:s.payload,backupPath:r}}function S(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(g(t)&&!n.overwrite)throw new Error(`agentx.json already exists at ${t}. Pass overwrite=true to replace it.`);return a(t,JSON.stringify(e,null,2)+`
3
3
  `,"utf-8"),{file:t}}async function h(){try{let n=l().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${n}/reload`,{method:"POST"}).catch(()=>null)}catch{}}export{P as a,S as b};
4
- //# sourceMappingURL=chunk-GIQKQD2B.js.map
4
+ //# sourceMappingURL=chunk-AGQYUOZY.js.map
@@ -1,8 +1,8 @@
1
- import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-5RHCM3L7.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-BXXP6DTB.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function S(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",f=[`- ${n} [${h}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&f.push(` notify: ${e.notify.channel} ${e.notify.chatId}${e.deliverResult===!1?" (failures only)":" (results and failures)"}`),e.command?f.push(` command: ${S(String(e.command))}`):e.prompt&&f.push(` prompt: ${S(String(e.prompt))}`),f.join(`
1
+ import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-6AUWEL6V.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-JIJDBCV7.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function S(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",f=[`- ${n} [${h}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&f.push(` notify: ${e.notify.channel} ${e.notify.chatId}${e.deliverResult===!1?" (failures only)":" (results and failures)"}`),e.command?f.push(` command: ${S(String(e.command))}`):e.prompt&&f.push(` prompt: ${S(String(e.prompt))}`),f.join(`
2
2
  `)}async function b(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(d){return`Could not notify the operator (${d?.message??d}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),d=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let f=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(f).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,p])=>Q(i,p,d)).join(`
3
3
  `):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${q}.`;let p=s(n.agent)||e.agentId;if(!h.agents?.[p])return`Error: agent "${p}" not found on this node.`;let g=s(n.timezone)||R;if(!B(g))return`Error: unknown timezone "${g}".`;let u=o||_(i.matched,p);if(!O(u))return`Error: invalid id "${u}" (letters, digits, "-" and "_" only).`;if(f[u])return`Error: a schedule "${u}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:d.toISOString()},L=k({parsed:i,agent:p,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),A=await m(U=>I(U,`crons.${u}`,L));if(!A.success)return`Error: ${A.error}`;let N=w(E(i.cron,g,d),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${u}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${p}`,$?`Results and failures go to: ${$.channel} ${$.chatId}${$.channel==="voice"?" (as a push notification)":""}`:"Results go to: run log only (no chat)",`Prompt: ${S(l,400)}`,"",`Approve: agentx schedule approve ${u}`,`Reject: agentx schedule reject ${u}`].join(`
4
4
  `),H=await b(h,t,G);return[`Requested schedule "${u}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
5
5
  `)}if(!o)return`Error: ${r} needs \`id\`.`;let c=f[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let u=await m($=>P($,`crons.${o}`));return u.success?`Withdrew the pending request "${o}".`:`Error: ${u.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:d.toISOString()},l=await m(u=>{if(!x(u,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(u,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",p=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${v(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,d),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
6
6
  `),g=await b(h,t,p);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
7
7
  `)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),d=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),f=s(n.accountId);return{agentId:t,channel:d,chatId:h,...f?{accountId:f}:{}}}export{re as a,oe as b};
8
- //# sourceMappingURL=chunk-2JKKGS77.js.map
8
+ //# sourceMappingURL=chunk-AP4DADXG.js.map
@@ -1,2 +1,2 @@
1
- import{c as d,g}from"./chunk-WCXXXAHV.js";import{a as f}from"./chunk-Q72TK3DO.js";var k=/^[A-Za-z0-9._-]{1,64}$/,m=/^[A-Za-z0-9_-]{1,64}$/,A=100,w=1e3,E=6e4,P=15*6e4;function p(r){return(r.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"node").slice(0,64)}function _(r,t,n){let i=/^bearer /i.test(r)?r.slice(7).trim():"",e="Phones paired with another computer need that computer's own peer token: give it a token in mesh.peers on both computers.";if(!i||n&&i===n)return{error:e};let a=new Set(t.filter(s=>s.token===i).map(s=>p(s.name)));if(a.size===0)return{error:e};if(a.size>1)return{error:`Several mesh.peers entries share this token (${[...a].join(", ")}). Give each computer its own token.`};let[o]=a,u=t.filter(s=>s.token!==i&&p(s.name)===o).map(s=>s.name);return u.length?{error:`mesh.peers names ${u.map(s=>`"${s}"`).join(", ")} too close to this computer's name: rename one so they differ in letters or digits.`}:{origin:o}}function C(r,t){let n=r.indexOf(":");return n<0?{ok:!0}:"error"in t?{error:t.error}:r.slice(0,n)!==t.origin?{error:`${r} is a phone paired with another computer; only that computer can send to it.`}:{ok:!0}}function x(r,t,n){let i=r.toLowerCase(),e=t.find(a=>a.name.toLowerCase()===i);return e?e.token?n&&e.token===n?`mesh.peers "${e.name}" uses the shared MESH_TOKEN, so phones paired here can't turn notifications on. Give this pair a token of its own on both computers.`:null:`mesh.peers "${e.name}" has no token, so phones paired here can't turn notifications on. Give it a token of its own on both computers.`:null}function O(r){return new Set(r.map(t=>p(t.name)))}function j(r,t,n,i){let e=r&&typeof r=="object"?r:{};if("error"in t)return{status:403,body:{error:t.error}};let a=t.origin;if(!k.test(a))return{status:403,body:{error:"this peer's name can't be used as a notification origin"}};if(!n)return{status:503,body:{error:i??"Notifications are not set up on the computer that sends them."}};if(e.op==="roster"){if(!Array.isArray(e.active)||e.active.length>w||!e.active.every(l=>typeof l=="string"&&m.test(l)))return{status:400,body:{error:"active must be a list of device ids"}};let h=n.store();return h?{status:200,body:{ok:!0,removed:h.pruneOrigin(a,e.active)}}:{status:503,body:{error:n.reason??"the database is unavailable"}}}if(e.op!=="app")return{status:400,body:{error:"op must be app or roster"}};let o=e.call&&typeof e.call=="object"?e.call:{},u=o.device&&typeof o.device=="object"?o.device:{},s=typeof o.path=="string"?o.path:"",c=o.method==="GET"||o.method==="POST"?o.method:"";if(!d(s)||!c)return{status:404,body:{error:"not found"}};if(typeof u.id!="string"||!m.test(u.id))return{status:400,body:{error:"device.id is required"}};let b=typeof u.name=="string"&&u.name.trim()?u.name.trim():u.id,v=o.body&&typeof o.body=="object"&&!Array.isArray(o.body)?o.body:{};return g({path:s,method:c,body:v,device:{id:f(a,u.id),name:S(`${b} (${a})`,A)}},n)}var y=class{constructor(t){this.deps=t}lastKey=null;lastSentAt=0;failing=!1;async tick(){let t=(this.deps.now??Date.now)(),n;try{n=[...new Set(this.deps.active())].sort()}catch(e){return this.deps.log?.(`push: phone list not read, not sent this time: ${e?.message??e}`),!1}let i=n.join(",");if(i===this.lastKey&&t-this.lastSentAt<P)return!1;try{let e=await this.deps.send(n);if(e&&typeof e=="object"&&typeof e.status=="number"&&e.status!==200)throw new Error(`${e.status} ${typeof e.body?.error=="string"?e.body.error:"refused"}`);return this.lastKey=i,this.lastSentAt=t,this.failing&&this.deps.log?.("push: phone list sent to the push host again"),this.failing=!1,!0}catch(e){return this.failing||this.deps.log?.(`push: phone list not sent to the push host, retrying every minute: ${e?.message??e}`),this.failing=!0,!1}}};function S(r,t){let n=[...r];return n.length>t?n.slice(0,t-1).join("")+"\u2026":r}export{E as a,P as b,p as c,_ as d,C as e,x as f,O as g,j as h,y as i};
2
- //# sourceMappingURL=chunk-DIE6XXJF.js.map
1
+ import{c as d,g}from"./chunk-7DYVNET6.js";import{a as f}from"./chunk-5HLD66CW.js";var k=/^[A-Za-z0-9._-]{1,64}$/,m=/^[A-Za-z0-9_-]{1,64}$/,A=100,w=1e3,E=6e4,P=15*6e4;function p(r){return(r.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"node").slice(0,64)}function _(r,t,n){let i=/^bearer /i.test(r)?r.slice(7).trim():"",e="Phones paired with another computer need that computer's own peer token: give it a token in mesh.peers on both computers.";if(!i||n&&i===n)return{error:e};let a=new Set(t.filter(s=>s.token===i).map(s=>p(s.name)));if(a.size===0)return{error:e};if(a.size>1)return{error:`Several mesh.peers entries share this token (${[...a].join(", ")}). Give each computer its own token.`};let[o]=a,u=t.filter(s=>s.token!==i&&p(s.name)===o).map(s=>s.name);return u.length?{error:`mesh.peers names ${u.map(s=>`"${s}"`).join(", ")} too close to this computer's name: rename one so they differ in letters or digits.`}:{origin:o}}function C(r,t){let n=r.indexOf(":");return n<0?{ok:!0}:"error"in t?{error:t.error}:r.slice(0,n)!==t.origin?{error:`${r} is a phone paired with another computer; only that computer can send to it.`}:{ok:!0}}function x(r,t,n){let i=r.toLowerCase(),e=t.find(a=>a.name.toLowerCase()===i);return e?e.token?n&&e.token===n?`mesh.peers "${e.name}" uses the shared MESH_TOKEN, so phones paired here can't turn notifications on. Give this pair a token of its own on both computers.`:null:`mesh.peers "${e.name}" has no token, so phones paired here can't turn notifications on. Give it a token of its own on both computers.`:null}function O(r){return new Set(r.map(t=>p(t.name)))}function j(r,t,n,i){let e=r&&typeof r=="object"?r:{};if("error"in t)return{status:403,body:{error:t.error}};let a=t.origin;if(!k.test(a))return{status:403,body:{error:"this peer's name can't be used as a notification origin"}};if(!n)return{status:503,body:{error:i??"Notifications are not set up on the computer that sends them."}};if(e.op==="roster"){if(!Array.isArray(e.active)||e.active.length>w||!e.active.every(l=>typeof l=="string"&&m.test(l)))return{status:400,body:{error:"active must be a list of device ids"}};let h=n.store();return h?{status:200,body:{ok:!0,removed:h.pruneOrigin(a,e.active)}}:{status:503,body:{error:n.reason??"the database is unavailable"}}}if(e.op!=="app")return{status:400,body:{error:"op must be app or roster"}};let o=e.call&&typeof e.call=="object"?e.call:{},u=o.device&&typeof o.device=="object"?o.device:{},s=typeof o.path=="string"?o.path:"",c=o.method==="GET"||o.method==="POST"?o.method:"";if(!d(s)||!c)return{status:404,body:{error:"not found"}};if(typeof u.id!="string"||!m.test(u.id))return{status:400,body:{error:"device.id is required"}};let b=typeof u.name=="string"&&u.name.trim()?u.name.trim():u.id,v=o.body&&typeof o.body=="object"&&!Array.isArray(o.body)?o.body:{};return g({path:s,method:c,body:v,device:{id:f(a,u.id),name:S(`${b} (${a})`,A)}},n)}var y=class{constructor(t){this.deps=t}lastKey=null;lastSentAt=0;failing=!1;async tick(){let t=(this.deps.now??Date.now)(),n;try{n=[...new Set(this.deps.active())].sort()}catch(e){return this.deps.log?.(`push: phone list not read, not sent this time: ${e?.message??e}`),!1}let i=n.join(",");if(i===this.lastKey&&t-this.lastSentAt<P)return!1;try{let e=await this.deps.send(n);if(e&&typeof e=="object"&&typeof e.status=="number"&&e.status!==200)throw new Error(`${e.status} ${typeof e.body?.error=="string"?e.body.error:"refused"}`);return this.lastKey=i,this.lastSentAt=t,this.failing&&this.deps.log?.("push: phone list sent to the push host again"),this.failing=!1,!0}catch(e){return this.failing||this.deps.log?.(`push: phone list not sent to the push host, retrying every minute: ${e?.message??e}`),this.failing=!0,!1}}};function S(r,t){let n=[...r];return n.length>t?n.slice(0,t-1).join("")+"\u2026":r}export{E as a,P as b,p as c,_ as d,C as e,x as f,O as g,j as h,y as i};
2
+ //# sourceMappingURL=chunk-CZZJEFUM.js.map
@@ -1,4 +1,4 @@
1
- import{b as S,c as O}from"./chunk-BXXP6DTB.js";import{h as B,j as J}from"./chunk-3UOTLMXD.js";import{a as I,b as P}from"./chunk-FCPTN6NF.js";import{a as X,b as ue}from"./chunk-7I7IEX4S.js";import{d as F}from"./chunk-QIJLFPWE.js";import{execFile as Ae}from"child_process";import{writeFileSync as ie,mkdirSync as x,existsSync as b,readFileSync as ke}from"fs";import{resolve as v}from"path";var le=["off","shadow","authoritative"],ge={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},me="INTENT_LEDGER_MODE";function G(i,e=process.env){let t=U(e[ge[i]]);if(t)return t;let n=U(e[me]);return n||"off"}function U(i){if(typeof i!="string")return null;let e=i.trim().toLowerCase();return le.includes(e)?e:null}P();import he from"better-sqlite3";import{existsSync as Ue,mkdirSync as fe}from"fs";import{dirname as pe,resolve as Ee}from"path";var T=class{db;path;constructor(e={}){this.path=Ee(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),fe(pe(this.path),{recursive:!0}),this.db=new he(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),ye(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let n=this.findEventBySourceId(e.source,e.sourceEventId);if(n)return n}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
1
+ import{b as S,c as O}from"./chunk-JIJDBCV7.js";import{h as B,j as J}from"./chunk-3UOTLMXD.js";import{a as I,b as P}from"./chunk-FCPTN6NF.js";import{a as X,b as ue}from"./chunk-7I7IEX4S.js";import{d as F}from"./chunk-QIJLFPWE.js";import{execFile as Ae}from"child_process";import{writeFileSync as ie,mkdirSync as x,existsSync as b,readFileSync as ke}from"fs";import{resolve as v}from"path";var le=["off","shadow","authoritative"],ge={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},me="INTENT_LEDGER_MODE";function G(i,e=process.env){let t=U(e[ge[i]]);if(t)return t;let n=U(e[me]);return n||"off"}function U(i){if(typeof i!="string")return null;let e=i.trim().toLowerCase();return le.includes(e)?e:null}P();import he from"better-sqlite3";import{existsSync as Ue,mkdirSync as fe}from"fs";import{dirname as pe,resolve as Ee}from"path";var T=class{db;path;constructor(e={}){this.path=Ee(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),fe(pe(this.path),{recursive:!0}),this.db=new he(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),ye(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let n=this.findEventBySourceId(e.source,e.sourceEventId);if(n)return n}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
2
2
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(t.id,t.ts,t.source,t.sourceEventId,t.project,t.subject,t.intent,t.rawJson),t}findEventBySourceId(e,t){let n=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
3
3
  FROM intent_events WHERE source = ? AND source_event_id = ?`).get(e,t);return n?Y(n):null}getEventById(e){let t=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
4
4
  FROM intent_events WHERE id = ?`).get(e);return t?Y(t):null}recordDecision(e){this.db.prepare(`INSERT INTO intent_decisions (event_id, decided_at, decided_by, agent_id, outcome, reason)
@@ -125,4 +125,4 @@ ${se(o.block,r.prompt)}`,r.maxOutputTokens),agentId:r.agent,autonomy:r.autonomy,
125
125
  `);return t.length<=e?t.join(`
126
126
  `):t.slice(-e).join(`
127
127
  `)}function Xe(i,e,t){return new Promise((n,r)=>{Ae("/bin/sh",["-c",i],{timeout:e,maxBuffer:8*1024*1024,...t?{env:t}:{}},(s,a,o)=>{if(s&&s.killed){r(new Error(`command timed out after ${Math.round(e/1e3)}s`));return}n({stdout:String(a??""),stderr:String(o??""),code:s?typeof s.code=="number"?s.code:1:0})})})}export{T as a,V as b,ot as c,we as d,at as e,ct as f,$ as g,ee as h,G as i,We as j,z as k,Q as l,lt as m,Ce as n,oe as o,ae as p,ce as q,C as r,M as s};
128
- //# sourceMappingURL=chunk-23LWLYOK.js.map
128
+ //# sourceMappingURL=chunk-DBJUGKX2.js.map
@@ -1,4 +1,4 @@
1
- import{c as w}from"./chunk-XZIKAHFU.js";function T(t){let r=1779033703^t.length;for(let s=0;s<t.length;s++)r=Math.imul(r^t.charCodeAt(s),3432918353),r=r<<13|r>>>19;let o=r>>>0;return()=>{o=o+1831565813>>>0;let s=o;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}function _(t,r,o){let s=T(o),i=[...t].sort((e,u)=>e.path.localeCompare(u.path));for(let e=i.length-1;e>0;e--){let u=Math.floor(s()*(e+1));[i[e],i[u]]=[i[u],i[e]]}return i.slice(0,Math.max(0,r)).sort((e,u)=>e.path.localeCompare(u.path))}var R=new Set("about after again also because been before being between could does doing during each from have having here into just more most only other over same should some such than that their them then there these they this those through under until very were what when where which while will with would your yours user assistant agent message entry please thanks".split(" "));function k(t){let r=new Set;for(let o of t.toLowerCase().matchAll(/[\p{L}\p{N}][\p{L}\p{N}_-]{3,}/gu))R.has(o[0])||r.add(o[0]);return r}function E(t,r){let o=k(t);if(o.size===0)return 1;let s=k(r),i=0;for(let e of o)s.has(e)&&i++;return i/o.size}var W=.15;function $(t){let r=w(t);return{commits:r.commits,urls:r.urls,numbers:r.numbers}}function j(t,r,o){return t.includes(r)||o.some(s=>s.startsWith(r)||r.startsWith(s))}var y=t=>t.toLowerCase().replace(/\/+$/,"");function N(t,r,o){let s=t.sources.map(a=>r.get(a)).filter(a=>!!a),i=t.sources.filter(a=>!r.has(a)),e=s.filter(a=>k(a.content).size>=5&&E(a.content,t.content)<W).map(a=>a.id),u=[...s.map(a=>`${a.date??""}
1
+ import{c as w}from"./chunk-375MXG3H.js";function T(t){let r=1779033703^t.length;for(let s=0;s<t.length;s++)r=Math.imul(r^t.charCodeAt(s),3432918353),r=r<<13|r>>>19;let o=r>>>0;return()=>{o=o+1831565813>>>0;let s=o;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}function _(t,r,o){let s=T(o),i=[...t].sort((e,u)=>e.path.localeCompare(u.path));for(let e=i.length-1;e>0;e--){let u=Math.floor(s()*(e+1));[i[e],i[u]]=[i[u],i[e]]}return i.slice(0,Math.max(0,r)).sort((e,u)=>e.path.localeCompare(u.path))}var R=new Set("about after again also because been before being between could does doing during each from have having here into just more most only other over same should some such than that their them then there these they this those through under until very were what when where which while will with would your yours user assistant agent message entry please thanks".split(" "));function k(t){let r=new Set;for(let o of t.toLowerCase().matchAll(/[\p{L}\p{N}][\p{L}\p{N}_-]{3,}/gu))R.has(o[0])||r.add(o[0]);return r}function E(t,r){let o=k(t);if(o.size===0)return 1;let s=k(r),i=0;for(let e of o)s.has(e)&&i++;return i/o.size}var W=.15;function $(t){let r=w(t);return{commits:r.commits,urls:r.urls,numbers:r.numbers}}function j(t,r,o){return t.includes(r)||o.some(s=>s.startsWith(r)||r.startsWith(s))}var y=t=>t.toLowerCase().replace(/\/+$/,"");function N(t,r,o){let s=t.sources.map(a=>r.get(a)).filter(a=>!!a),i=t.sources.filter(a=>!r.has(a)),e=s.filter(a=>k(a.content).size>=5&&E(a.content,t.content)<W).map(a=>a.id),u=[...s.map(a=>`${a.date??""}
2
2
  ${a.content}`),t.previous??""].join(`
3
3
  `),l=u.toLowerCase(),d=$(u),p=new Set(d.urls.map(y)),g=new Set(d.numbers),n=$(t.content),c=[];for(let a of n.commits)j(l,a,d.commits)||c.push(`commit ${a}`);for(let a of n.urls)!p.has(y(a))&&!l.includes(y(a))&&c.push(`link ${a}`);for(let a of n.numbers)/^\d{1,2}$/.test(a)||!g.has(a)&&!l.includes(a)&&c.push(`number ${a}`);let h=[];for(let a of s){let m=$(a.content);if(m.commits.length===0&&m.urls.length===0)continue;let v=o(a.id),S=(v.length>0?v:[t.content]).join(`
4
4
  `).toLowerCase(),x=$(S);for(let b of m.commits)j(S,b,x.commits)||h.push({entry:a.id,fact:`commit ${b}`});for(let b of m.urls)S.includes(y(b))||h.push({entry:a.id,fact:`link ${b}`})}return{path:t.path,title:t.title,type:t.type,sources:t.sources.length,missingSources:i,weakSources:e,ungrounded:c,lost:h}}function U(t,r){let o=r.toLowerCase(),s=w(r).commits,i=[];for(let e of t){let u=w(e.content),l=[...u.commits.filter(d=>!j(o,d,s)).map(d=>`commit ${d}`),...u.urls.filter(d=>!o.includes(y(d))).map(d=>`link ${d}`)];l.length>0&&i.push({entry:e.id,facts:l})}return i}var P=new Set("the and for with from into of on in at to by an a".split(" "));function L(t){return new Set((t||"").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(r=>(r.length>1||/\d/.test(r))&&!P.has(r)&&!R.has(r)))}function M(t,r){if(t.size===0||r.size===0)return 0;let o=0;for(let s of t)r.has(s)&&o++;return o/(t.size+r.size-o)}function D(t,r,o={}){let s=o.titleMin??.75,i=o.sourcesMin??.5,e=t.map(l=>({...l,tt:L(l.title),ss:new Set(l.sources??[])})),u=[];for(let l=0;l<e.length;l++)for(let d=l+1;d<e.length;d++){let p=e[l],g=e[d];if(r&&!r.has(p.path)&&!r.has(g.path))continue;let n=(p.type??"")===(g.type??"")?M(p.tt,g.tt):0;if(n>=s){u.push({a:p.path,b:g.path,reason:"title",score:n});continue}if(p.ss.size>=2&&g.ss.size>=2){let c=M(p.ss,g.ss);c>=i&&u.push({a:p.path,b:g.path,reason:"sources",score:c})}}return u.sort((l,d)=>d.score-l.score||l.a.localeCompare(d.a))}var A=4e3;function J(t,r){let o=r.map(i=>{let e=i.content.length>A?`${i.content.slice(0,A)}
@@ -33,4 +33,4 @@ Reply with JSON only, no fencing:
33
33
  {"claims": 0, "supported": 0, "unsupported": [], "contradicted": [], "off_subject": [], "missing": [], "verdict": "good"}`}function z(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let r=t,o=l=>Array.isArray(l)?l.map(d=>String(d)):[],s=l=>typeof l=="number"&&Number.isFinite(l)&&l>=0?Math.round(l):NaN,i=s(r.claims);if(Number.isNaN(i))return null;let e=Math.min(i,Number.isNaN(s(r.supported))?i-o(r.unsupported).length:s(r.supported)),u=r.verdict==="good"||r.verdict==="minor"||r.verdict==="major"?r.verdict:null;return u?{claims:i,supported:Math.max(0,e),unsupported:o(r.unsupported),contradicted:o(r.contradicted),offSubject:o(r.off_subject??r.offSubject),missing:o(r.missing),verdict:u}:null}function I(t,r,o,s=[],i=5,e){let u={};for(let n of t)u[n.type??"untyped"]=(u[n.type??"untyped"]??0)+1;let l=new Set,d=new Set;for(let n of t)for(let c of n.lost)l.add(c.entry),d.add(`${c.entry}|${c.fact}`);let p=new Set(r.flatMap(n=>[n.a,n.b]).filter(n=>t.some(c=>c.path===n))),g={sample:{articles:t.length,seed:o.seed,since:o.since,byType:u},citations:{withSources:t.filter(n=>n.sources>0).length,missingSources:t.reduce((n,c)=>n+c.missingSources.length,0),weakSources:t.reduce((n,c)=>n+c.weakSources.length,0),articlesWithWeak:t.filter(n=>n.weakSources.length>0).length},grounding:{articlesWithUngrounded:t.filter(n=>n.ungrounded.length>0).length,ungroundedFacts:t.reduce((n,c)=>n+c.ungrounded.length,0)},lost:{entriesWithLostFacts:l.size,lostFacts:d.size},duplicates:{pairs:r.length,articlesInPair:p.size},...e?{uncited:{entries:e.entries,withLostFacts:e.lost.length}}:{},examples:{ungrounded:t.filter(n=>n.ungrounded.length>0).slice(0,i).map(n=>({path:n.path,facts:n.ungrounded.slice(0,6)})),lost:t.flatMap(n=>n.lost.map(c=>({path:n.path,...c}))).slice(0,i),weak:t.filter(n=>n.weakSources.length>0).slice(0,i).map(n=>({path:n.path,entries:n.weakSources})),duplicates:r.slice(0,i),uncited:(e?.lost??[]).slice(0,i).map(n=>({entry:n.entry,facts:n.facts.slice(0,4)})),judged:s.filter(n=>n.verdict.verdict!=="good").slice(0,i).map(n=>({path:n.path,verdict:n.verdict.verdict,unsupported:n.verdict.unsupported.slice(0,4),contradicted:n.verdict.contradicted.slice(0,4),offSubject:n.verdict.offSubject,missing:n.verdict.missing.slice(0,4)}))}};if(s.length>0){let n=s.map(a=>a.verdict),c=n.reduce((a,m)=>a+m.claims,0),h=n.reduce((a,m)=>a+m.supported,0);g.judge={judged:n.length,claims:c,supported:h,supportRate:c>0?h/c:1,unsupported:n.reduce((a,m)=>a+m.unsupported.length,0),contradicted:n.reduce((a,m)=>a+m.contradicted.length,0),articlesWithWrongMerge:n.filter(a=>a.offSubject.length>0).length,missingFacts:n.reduce((a,m)=>a+m.missing.length,0),verdicts:{good:n.filter(a=>a.verdict==="good").length,minor:n.filter(a=>a.verdict==="minor").length,major:n.filter(a=>a.verdict==="major").length}}}return g}var f=(t,r)=>r>0?`${Math.round(t/r*100)}%`:"\u2013";function O(t){let r=t.sample.articles,o=["# Wiki absorb scorecard","",`Sample: ${r} articles (seed \`${t.sample.seed}\`${t.sample.since?`, changed since ${t.sample.since}`:""}). Types: ${Object.entries(t.sample.byType).map(([e,u])=>`${e} ${u}`).join(", ")||"\u2013"}.`,"","| Check | Result | Lower is better? |","|---|---|---|",`| Articles citing at least one entry | ${t.citations.withSources}/${r} (${f(t.citations.withSources,r)}) | no |`,`| Cited ids with no entry | ${t.citations.missingSources} | yes |`,`| Articles with a weak citation (entry shares <${Math.round(W*100)}% of its words) | ${t.citations.articlesWithWeak}/${r} (${f(t.citations.articlesWithWeak,r)}) | yes |`,`| Articles with an ungrounded commit, link or number | ${t.grounding.articlesWithUngrounded}/${r} (${f(t.grounding.articlesWithUngrounded,r)}) | yes |`,`| Ungrounded facts | ${t.grounding.ungroundedFacts} | yes |`,`| Commits or links lost from cited entries | ${t.lost.lostFacts} across ${t.lost.entriesWithLostFacts} entries | yes |`,`| Sampled articles in a likely duplicate pair | ${t.duplicates.articlesInPair}/${r} (${f(t.duplicates.articlesInPair,r)}) | yes |`];if(t.uncited&&o.push(`| Entries read in the window but cited by no article | ${t.uncited.entries} | \u2013 |`,`| \u2026of which carry a commit or link no article has | ${t.uncited.withLostFacts} | yes |`),t.judge){let e=t.judge;o.push(`| Judge: claims supported by the cited entries | ${e.supported}/${e.claims} (${f(e.supported,e.claims)}) | no |`,`| Judge: unsupported / contradicted claims | ${e.unsupported} / ${e.contradicted} | yes |`,`| Judge: articles with an off-subject source (wrong merge) | ${e.articlesWithWrongMerge}/${e.judged} (${f(e.articlesWithWrongMerge,e.judged)}) | yes |`,`| Judge: facts missing from the article | ${e.missingFacts} | yes |`,`| Judge verdicts good / minor / major | ${e.verdicts.good} / ${e.verdicts.minor} / ${e.verdicts.major} | \u2013 |`)}let s=t.examples,i=(e,u)=>{u.length!==0&&o.push("",`## ${e}`,"",...u)};return i("Examples: ungrounded facts",s.ungrounded.map(e=>`- \`${e.path}\`: ${e.facts.join("; ")}`)),i("Examples: lost facts",s.lost.map(e=>`- \`${e.path}\` \u2190 entry \`${e.entry}\`: ${e.fact}`)),i("Examples: weak citations",s.weak.map(e=>`- \`${e.path}\`: ${e.entries.map(u=>`\`${u}\``).join(", ")}`)),i("Examples: uncited entries with facts no article has",s.uncited.map(e=>`- \`${e.entry}\`: ${e.facts.join("; ")}`)),i("Examples: likely duplicates",s.duplicates.map(e=>`- \`${e.a}\` \u2194 \`${e.b}\` (${e.reason}, ${e.score.toFixed(2)})`)),i("Examples: judge findings",s.judged.map(e=>{let u=[e.unsupported.length?`unsupported: ${e.unsupported.join(" | ")}`:"",e.contradicted.length?`contradicted: ${e.contradicted.join(" | ")}`:"",e.offSubject.length?`off-subject: ${e.offSubject.join(", ")}`:"",e.missing.length?`missing: ${e.missing.join(" | ")}`:""].filter(Boolean);return`- \`${e.path}\` (${e.verdict}): ${u.join("; ")}`})),o.push("","## Method","","- The sample is drawn with a seeded shuffle from the articles changed in the window, so the same seed and window give the same articles.","- Ungrounded: a commit hash, link or number (three digits or more, or a date) in the article that no cited entry and no earlier version of the article contains.","- Lost: a commit hash or link in a cited entry that no article citing that entry contains.","- Uncited: entries the absorb ledger marks as read in the window that no article cites; those carrying a commit or link that no article on the node has are counted as lost, since absorb will not offer them again.","- Weak citation: a cited entry sharing fewer than 15% of its distinctive words with the article.","- Duplicate: two articles of the same type whose titles share at least 75% of their words, or which share at least half their sources.","- Judge (optional): one model call per article reads the article and its cited entries and lists unsupported, contradicted, off-subject and missing items."),o.join(`
34
34
  `)+`
35
35
  `}function V(t){if(!t||typeof t!="object")return{};let r=t,o=r.usage??{},s=i=>typeof i=="number"&&Number.isFinite(i)?i:void 0;return{costUsd:s(r.total_cost_usd)??s(r.cost_usd),apiMs:s(r.duration_api_ms),inputTokens:s(o.input_tokens),outputTokens:s(o.output_tokens),cacheReadTokens:s(o.cache_read_input_tokens),cacheWriteTokens:s(o.cache_creation_input_tokens)}}function C(t,r){return t.length===0?0:t[Math.min(t.length-1,Math.floor(r*t.length))]}function Y(t){let r=new Map,o=i=>{let e=i||"(none)",u=r.get(e);return u||r.set(e,u={calls:[],runs:[]}),u};for(let i of t)i.kind==="call"?o(i.label).calls.push(i):i.kind==="run"&&o(i.label).runs.push(i);let s=[];for(let[i,{calls:e,runs:u}]of r){if(e.length===0)continue;let l=e.map(n=>n.wallMs).sort((n,c)=>n-c),d;if(u.length>0)d=u.reduce((n,c)=>n+(Date.parse(c.endedAt)-Date.parse(c.startedAt)),0);else{let n=e.map(h=>Date.parse(h.at)-h.wallMs),c=e.map(h=>Date.parse(h.at));d=Math.max(...c)-Math.min(...n)}let p=e.reduce((n,c)=>n+c.entries,0),g=e.reduce((n,c)=>n+(c.costUsd??0),0);s.push({label:i,calls:e.length,failed:e.filter(n=>n.failed).length,entries:p,articles:e.reduce((n,c)=>n+c.articles,0),refused:e.reduce((n,c)=>n+c.refused,0),heldCited:e.reduce((n,c)=>n+(c.heldCited??0),0),wallMs:d,callMsP50:C(l,.5),callMsP95:C(l,.95),prepMs:e.reduce((n,c)=>n+(c.prepMs??0),0),costUsd:g,costPerEntry:p>0?g/p:0,entriesPerMinute:d>0?p/d*6e4:0,promptChars:e.reduce((n,c)=>n+c.promptChars,0)})}return s.sort((i,e)=>i.label.localeCompare(e.label))}export{T as a,_ as b,k as c,E as d,W as e,N as f,U as g,D as h,A as i,J as j,z as k,I as l,O as m,V as n,Y as o};
36
- //# sourceMappingURL=chunk-B6PMIUVV.js.map
36
+ //# sourceMappingURL=chunk-EGPCEQJN.js.map
@@ -48,7 +48,7 @@ The "modified" field is optional and can contain updated values to pass forward.
48
48
  ... (output truncated)`:i;return s.exitCode!==0?{tool_use_id:e.id,content:`Command exited with code ${s.exitCode}:
49
49
  ${c}`,is_error:!0}:{tool_use_id:e.id,content:c||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,n=ge.resolve(this.cwd,t);if(!o||o.length===0)return{tool_use_id:e.id,content:"No edits provided.",is_error:!0};let s=await W.checkFileWrite(t);if(s==="deny")return{tool_use_id:e.id,content:`File write blocked by permissions: ${t}`,is_error:!0};if(s==="skip")return{tool_use_id:e.id,content:`File write skipped (plan mode): ${t}`};if(f.has("pre:file-write")){let a=await f.execute("pre:file-write",{event:"pre:file-write",file:n,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`File edit blocked by pre:file-write hook: ${t}`,is_error:!0}}let i=await re.readFile(n,"utf8"),c=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),c.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):c.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await re.writeFile(n,i,"utf8"),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:n,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
50
50
  ${c.join(`
51
- `)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-GYKSYSDD.js"),c=i();if(!c)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(c).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
51
+ `)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-IUNSHCOL.js"),c=i();if(!c)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(c).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
52
52
 
53
53
  ${p.content}`}:{tool_use_id:e.id,content:`Sub-agent "${t}" failed: ${p.error}`,is_error:!0}}catch(s){return{tool_use_id:e.id,content:`Failed to spawn sub-agent: ${s.message}`,is_error:!0}}}async askUser(e){let t=String(e.input.question||""),o=e.input.options,n=t;return o?.length&&(n+=`
54
54
  Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:n}}};async function Ae(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,cwd:s,maxIterations:i=20,enabledTools:c,interactive:a=!0,overwrite:p=!1,dryRun:l=!1,onProgress:d,abortSignal:u}=r,m=u?{...n,abortSignal:u}:n;if(!e.generateRaw)return dt(r);let I=new se(s,{interactive:a,overwrite:p,dryRun:l,acmeContext:r.acmeContext,abortSignal:u}),D=be(c);if(r.acmeContext)for(let g of at)D.push({name:g.name,description:g.description,input_schema:g.input_schema});let E=new Set;if(r.mcpTools?.length)for(let g of r.mcpTools)D.push({name:g.name,description:g.description,input_schema:g.input_schema}),E.add(g.name);let C=o.filter(g=>g.role!=="system").map(g=>({role:g.role,content:g.content})),B=[],G=0,F=0,A=0,O="",j,_=0;for(;_<i;){if(_++,u?.aborted)throw new Error("cancelled");d?.({type:"iteration_start",iteration:_}),b.step(_,`Agentic loop iteration (${D.length} tools available)`);let g,M=!!e.generateRawStream&&!!d;try{if(M){let T=null,U=null,v="";for await(let x of e.generateRawStream(C,t,D,m))x.type==="text_delta"?(v+=x.text,d?.({type:"text_delta",text:x.text})):x.type==="thinking_delta"?d?.({type:"thinking_delta",text:x.text}):x.type==="raw_result"?T=x.result:x.type==="error"&&(U=x.error);if(U&&!T)throw new Error(U);if(!T)throw new Error("generateRawStream returned no raw_result event");g=T,g._streamedText=v}else g=await e.generateRaw(C,t,D,m)}catch(T){if(T.message?.includes("not available"))return dt(r);throw T}G+=g.usage.input_tokens+g.usage.output_tokens,F+=g.usage.input_tokens,A+=g.usage.output_tokens;let P=g._streamedText;for(let T of g.content)T.type==="text"&&(O+=T.text,P===void 0&&d?.({type:"text_delta",text:T.text}));if(P!==void 0&&delete g._streamedText,g.stop_reason==="end_turn"||g.stop_reason==="max_tokens")break;if(g.stop_reason==="tool_use"){let T=g.content.filter(v=>v.type==="tool_use");if(T.length===0)break;C.push({role:"assistant",content:g.content});let U=[];for(let v of T){d?.({type:"tool_call",name:v.name,id:v.id,input:v.input}),b.step(_,`Tool call: ${v.name}`);let x;if(E.has(v.name)&&r.mcpDispatch){let h=await r.mcpDispatch(v.name,v.input);x={tool_use_id:v.id,content:h.content,is_error:h.isError}}else x=await I.execute({name:v.name,id:v.id,input:v.input});d?.({type:"tool_result",name:v.name,id:v.id,content:x.content.slice(0,200),is_error:x.is_error}),x.files?.length&&(B.push(...x.files),d?.({type:"files_created",files:x.files})),x.followUp&&(j=x.followUp),U.push({type:"tool_result",tool_use_id:x.tool_use_id,content:x.content,is_error:x.is_error})}if(C.push({role:"user",content:U}),j)break;continue}break}return d?.({type:"complete",iterations:_,totalTokens:G}),{files:B,content:O,followUp:j,tokensUsed:G,inputTokens:F||void 0,outputTokens:A||void 0,iterations:_}}async function dt(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,maxIterations:s=5}=r,c=[{role:"system",content:t+`
@@ -123,4 +123,4 @@ ${r.projectInstructions}`),r.memoryContext&&o.push(r.memoryContext),o.push(`# Ou
123
123
  Generate output appropriate for: ${e}. Use the \`create_files\` tool to output all files.`),o.join(`
124
124
 
125
125
  `)}export{qe as a,Vt as b,Yt as c,We as d,ze as e,Ve as f,Ye as g,Pe as h,ee as i,Re as j,le as k,te as l,Tt as m,oe as n,Mt as o,f as p,et as q,tt as r,Me as s,de as t,W as u,ne as v,it as w,Ee as x,$e as y,se as z,mt as A,Zn as B,er as C};
126
- //# sourceMappingURL=chunk-ZYUVKFX2.js.map
126
+ //# sourceMappingURL=chunk-GAIXI26T.js.map