@desplega.ai/agent-swarm 1.162.0 → 1.164.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 (240) hide show
  1. package/README.md +2 -1
  2. package/dist/{acp-adapter-74m73ae9.js → acp-adapter-8t22d18g.js} +2 -2
  3. package/dist/{actions-4sr14gnt.js → actions-49xrhww7.js} +32 -29
  4. package/dist/amp-adapter-p230tajt.js +34 -0
  5. package/dist/{anthropic-messages-8xxrzky9.js → anthropic-messages-hst62ws9.js} +3 -3
  6. package/dist/{app-pt68fbwp.js → app-tgzw3f3d.js} +11 -10
  7. package/dist/{assistant-cv3jytks.js → assistant-dgfjm07j.js} +33 -30
  8. package/dist/{azure-openai-responses-f5cqsyj8.js → azure-openai-responses-mh8tvf78.js} +9 -68
  9. package/dist/{boot-reembed-4ht4gqth.js → boot-reembed-0qzs614r.js} +13 -12
  10. package/dist/{boot-reembed-nxpcvpj9.js → boot-reembed-dgp6peyx.js} +12 -11
  11. package/dist/{boot-scrub-logs-k93kyw8k.js → boot-scrub-logs-fxnk021a.js} +10 -9
  12. package/dist/{boot-seeds-1skcrs0e.js → boot-seeds-xe7adjvm.js} +14 -13
  13. package/dist/{claude-adapter-r5g0tzge.js → claude-adapter-hx0n8a31.js} +22 -20
  14. package/dist/{claude-managed-adapter-yxkfxg8j.js → claude-managed-adapter-hskapeen.js} +3 -3
  15. package/dist/{claude-managed-setup-pkyrgshb.js → claude-managed-setup-p7mt6dfq.js} +1 -1
  16. package/dist/{claude-sdk-session-jxyxnrwd.js → claude-sdk-session-d61a9c8x.js} +22 -20
  17. package/dist/{cli-twrh04ap.js → cli-0y30kqz4.js} +3 -3
  18. package/dist/{cli-5xhpb3kv.js → cli-0z9dj97t.js} +9 -9
  19. package/dist/{cli-t845n9xk.js → cli-1nzb8ftr.js} +2 -2
  20. package/dist/{cli-kdkwd3yr.js → cli-1wd1n2ya.js} +38 -10
  21. package/dist/{cli-vxe6qa4h.js → cli-23az412e.js} +1 -1
  22. package/dist/{cli-bsky8g7w.js → cli-26x4d89j.js} +1 -1
  23. package/dist/{cli-swfmp1fx.js → cli-2ar0x7cz.js} +9 -9
  24. package/dist/cli-2ksgp01n.js +933 -0
  25. package/dist/{cli-rnyzn44p.js → cli-2zhhnz2h.js} +1 -1
  26. package/dist/{cli-vc9bp061.js → cli-3qaw32we.js} +5 -5
  27. package/dist/{cli-vy3ed88x.js → cli-402m8btc.js} +31 -3
  28. package/dist/{cli-5bcd7sfy.js → cli-43fh8fzw.js} +3 -3
  29. package/dist/{cli-5k6k8ta3.js → cli-4f7s6k3q.js} +13 -5
  30. package/dist/{cli-sqvfa090.js → cli-4ntg6tkp.js} +6 -5
  31. package/dist/{cli-kh04eqwe.js → cli-4y9bnpvy.js} +1 -1
  32. package/dist/{cli-qjjvzwzd.js → cli-5c2j5yvx.js} +1 -1
  33. package/dist/{cli-2zy95vhm.js → cli-6891ft0y.js} +2 -2
  34. package/dist/{cli-tre4bdgq.js → cli-6behs2bt.js} +1 -1
  35. package/dist/cli-7mm2r1kp.js +17 -0
  36. package/dist/cli-7xcgj20z.js +68 -0
  37. package/dist/{cli-4cwxn7gp.js → cli-812vt3ht.js} +2 -2
  38. package/dist/{cli-mbssg1xv.js → cli-8kt0bmgx.js} +1 -1
  39. package/dist/{cli-wjgs5wxe.js → cli-8rpq35c0.js} +7 -7
  40. package/dist/{cli-jxs2ygaw.js → cli-9m8fk2v7.js} +74 -29
  41. package/dist/{cli-pkd6s2wy.js → cli-9q3wt23f.js} +2 -2
  42. package/dist/{cli-s3hwpt9v.js → cli-9s6fsg07.js} +30 -10
  43. package/dist/{cli-xqpk3rp7.js → cli-9x3bwfd3.js} +28 -5
  44. package/dist/{cli-qrgt5bqf.js → cli-agamgm0p.js} +1 -1
  45. package/dist/{cli-13hw4z91.js → cli-b0f70z24.js} +1 -1
  46. package/dist/{cli-gpqpmns7.js → cli-cgrvsz2t.js} +2 -2
  47. package/dist/{cli-2hhfhfq5.js → cli-cn53e7vc.js} +8 -1
  48. package/dist/{cli-p0r8sxj5.js → cli-crjazzsg.js} +222 -4
  49. package/dist/{cli-tcen9p5w.js → cli-d37n8b7c.js} +5 -5
  50. package/dist/{cli-wxkkd0e0.js → cli-dgh781z9.js} +3 -3
  51. package/dist/cli-dsdg2wrk.js +516 -0
  52. package/dist/{cli-q24re23n.js → cli-e2xnc4m5.js} +4 -4
  53. package/dist/{cli-f7kvq46p.js → cli-erxeg64j.js} +20 -0
  54. package/dist/{cli-8ev9xqnx.js → cli-fajbc7sa.js} +17 -219
  55. package/dist/{cli-g739zqzt.js → cli-fj86xr3c.js} +2 -2
  56. package/dist/{cli-zvhd3f64.js → cli-fpbvcf55.js} +3 -3
  57. package/dist/{cli-kp42yek0.js → cli-fyra5y8k.js} +424 -71
  58. package/dist/{cli-jyy6pm2f.js → cli-g3qgrzck.js} +15 -3
  59. package/dist/{cli-eg0b3p0k.js → cli-g5erf0zt.js} +23 -14
  60. package/dist/{cli-cvatsam7.js → cli-gcvzvq3e.js} +4 -4
  61. package/dist/{cli-89s4ngw3.js → cli-gvcgmx69.js} +1 -1
  62. package/dist/{cli-7tre70zp.js → cli-j261c831.js} +138 -128
  63. package/dist/{cli-sptrj5f5.js → cli-j3me0jw2.js} +2 -2
  64. package/dist/{cli-zxqx25nz.js → cli-k6w44yvq.js} +6 -6
  65. package/dist/cli-ndx5yz5n.js +3299 -0
  66. package/dist/{cli-ykk5jaax.js → cli-nexwh8zg.js} +34 -29
  67. package/dist/{cli-rfjw9jw2.js → cli-ng97fjq7.js} +2 -2
  68. package/dist/{cli-4x0csdjq.js → cli-ngne1dng.js} +2 -2
  69. package/dist/{cli-4dcpaefp.js → cli-pfzrhb8n.js} +2 -2
  70. package/dist/{cli-hb5c2x5y.js → cli-q38n4bq0.js} +2 -2
  71. package/dist/{cli-cebmgwsc.js → cli-r109nq7n.js} +4 -4
  72. package/dist/{cli-nq7yqw7b.js → cli-t7g0vmtc.js} +4 -4
  73. package/dist/{cli-jf7wmv1r.js → cli-tsvj33y0.js} +58 -19
  74. package/dist/{cli-7af8yhav.js → cli-vbr859rz.js} +7 -4
  75. package/dist/{cli-nt8hecg9.js → cli-wk3v6h55.js} +67 -38
  76. package/dist/{cli-vyqs9ya8.js → cli-wwvk0tsy.js} +7 -7
  77. package/dist/{cli-rj0gqwwp.js → cli-y2de3bzp.js} +1 -1
  78. package/dist/{cli-hmsw1gpy.js → cli-y74170pb.js} +4 -4
  79. package/dist/cli-ydt3zkwv.js +70 -0
  80. package/dist/{cli-xk79303e.js → cli-yj790e19.js} +9 -1
  81. package/dist/cli-zt3w1cn1.js +137 -0
  82. package/dist/{cli-trc24wk2.js → cli-zxg80zs9.js} +1 -1
  83. package/dist/cli.js +23 -22
  84. package/dist/{cloudflare-workers-ai-system-one-k8ddqjkq.js → cloudflare-workers-ai-system-one-tt484t61.js} +2 -2
  85. package/dist/{codex-adapter-esvmnhn7.js → codex-adapter-e3pky8aj.js} +14 -13
  86. package/dist/{codex-hook-m73jmqgx.js → codex-hook-b1fb7c2k.js} +4 -3
  87. package/dist/{codex-session-runner-ban9excr.js → codex-session-runner-1gq27w2t.js} +14 -13
  88. package/dist/{commands-75413p2n.js → commands-q07ezjzn.js} +10 -9
  89. package/dist/cursor-adapter-50cz7yba.js +32 -0
  90. package/dist/{db-7f5pecwg.js → db-wwt0sq9q.js} +18 -9
  91. package/dist/{dispatcher-fh9at8nz.js → dispatcher-wrg35vdd.js} +31 -28
  92. package/dist/{dsh-adapter-wpze65d4.js → dsh-adapter-sa6rxfpc.js} +6 -6
  93. package/dist/{e2b-gjgdjp91.js → e2b-v5np73yj.js} +4 -4
  94. package/dist/{easter-egg-3d-3w5c2n4c.js → easter-egg-3d-h2hx9b64.js} +2 -2
  95. package/dist/{event-bus-sfx8dx3t.js → event-bus-vkbhzt4n.js} +1 -1
  96. package/dist/{execute-f50wg9nh.js → execute-6gczxy8v.js} +42 -13
  97. package/dist/{google-generative-ai-jxxpnegy.js → google-generative-ai-d6nphg3q.js} +3 -3
  98. package/dist/{google-vertex-x7q1angm.js → google-vertex-cpshkref.js} +3 -3
  99. package/dist/{handlers-w13787bb.js → handlers-rv3gxvsp.js} +34 -31
  100. package/dist/{hook-46g1jrvx.js → hook-bcf5m80y.js} +15 -13
  101. package/dist/{hook-4tpts2ry.js → hook-z8b1jm2d.js} +16 -14
  102. package/dist/{http-19pzbfrt.js → http-56f7yt97.js} +932 -134
  103. package/dist/{index-scptvdxg.js → index-0kncjnrm.js} +30 -23
  104. package/dist/{index-dqmp15bq.js → index-1e6cg96n.js} +31 -28
  105. package/dist/{index-qb4q1y3e.js → index-8xgdb3k8.js} +31 -28
  106. package/dist/index-adw4zr9j.js +1020 -0
  107. package/dist/{index-h5gs261z.js → index-etdrp7yp.js} +140 -140
  108. package/dist/{index-8fd4dm4h.js → index-f9zscmft.js} +32 -29
  109. package/dist/index-fdk1t4d6.js +91297 -0
  110. package/dist/{index-s75wc4wd.js → index-jvb37h77.js} +12 -11
  111. package/dist/{keepalive-xa5ts9cd.js → keepalive-rp8daj4s.js} +12 -11
  112. package/dist/{lead-qp4xkvjq.js → lead-dfp77erc.js} +45 -40
  113. package/dist/{maintenance-rm5885hm.js → maintenance-wtmw3jqv.js} +13 -12
  114. package/dist/{mistral-conversations-rw7fbt22.js → mistral-conversations-8445ddjn.js} +2 -2
  115. package/dist/{oauth-refresh-sweep-1csdfebf.js → oauth-refresh-sweep-yhzqt95v.js} +11 -10
  116. package/dist/{onboard-r6b78cs4.js → onboard-9z8rwbcy.js} +2 -2
  117. package/dist/{openai-codex-responses-efvrgrq3.js → openai-codex-responses-9ynm88zy.js} +3 -3
  118. package/dist/{openai-completions-bbbrrz4z.js → openai-completions-nhqwjmaw.js} +2 -2
  119. package/dist/{openai-responses-9jjyrcm1.js → openai-responses-xx1c4kgm.js} +3 -3
  120. package/dist/{opencode-adapter-kb3g6pkf.js → opencode-adapter-1nxb6555.js} +5 -5
  121. package/dist/{otel-impl-0y9knpky.js → otel-impl-b83gaxw2.js} +1 -1
  122. package/dist/{pi-mono-adapter-z6s1bme2.js → pi-mono-adapter-ddxz8pjp.js} +18 -17
  123. package/dist/{pricing-refresh-mth26tgp.js → pricing-refresh-tmjvazb6.js} +12 -11
  124. package/dist/{rbac-roles-kwntb23q.js → rbac-roles-pa0gzjws.js} +11 -10
  125. package/dist/{rbac-roles-vpk4ebm8.js → rbac-roles-rhexa9s2.js} +12 -11
  126. package/dist/{render-v2-hcm7h00y.js → render-v2-ask84n8y.js} +11 -10
  127. package/dist/{runtime-vfjsfsc5.js → runtime-ckjnj3vf.js} +4 -4
  128. package/dist/{setup-hbyzd65h.js → setup-5ga5gdsy.js} +2 -2
  129. package/dist/{typesafe-system-one-2ef30pec.js → typesafe-system-one-datfr82p.js} +2 -2
  130. package/dist/{virtual-modules-9bv7ry91.js → virtual-modules-bmp3zwjf.js} +12 -11
  131. package/dist/{work-objects-m09sxnhe.js → work-objects-snnh0t7j.js} +34 -31
  132. package/dist/{worker-0h35rvk4.js → worker-rxyymrhb.js} +45 -40
  133. package/openapi.json +997 -39
  134. package/package.json +6 -5
  135. package/src/be/db/active-sessions.ts +30 -0
  136. package/src/be/db/approvals.ts +54 -0
  137. package/src/be/db.ts +25 -4
  138. package/src/be/mcp-server-checked-update.ts +34 -0
  139. package/src/be/mcp-server-stdio-gate.ts +34 -0
  140. package/src/be/memory/key-browser.ts +304 -0
  141. package/src/be/memory/providers/sqlite-store.ts +16 -3
  142. package/src/be/migrations/194_memory_orphan_chunks.sql +15 -0
  143. package/src/be/migrations/195_approval_request_approvals.sql +6 -0
  144. package/src/be/model-validation.ts +12 -2
  145. package/src/be/multi-runtime.ts +4 -3
  146. package/src/be/pricing-normalize.ts +11 -0
  147. package/src/be/repo-checked-update.ts +37 -0
  148. package/src/be/repo-merge-policy.ts +15 -0
  149. package/src/be/seed-pricing.ts +48 -1
  150. package/src/be/swarm-config-guard.ts +1 -0
  151. package/src/commands/provider-credentials.ts +44 -2
  152. package/src/extensions/contract-types.generated.ts +1 -1
  153. package/src/extensions/contract.ts +100 -0
  154. package/src/extensions/dispatcher.ts +19 -0
  155. package/src/extensions/post-bridge.ts +191 -0
  156. package/src/github/handlers.ts +128 -2
  157. package/src/gitlab/workflow-action-name.ts +15 -0
  158. package/src/heartbeat/heartbeat.ts +4 -3
  159. package/src/http/active-sessions.ts +6 -5
  160. package/src/http/agents.ts +10 -1
  161. package/src/http/approval-requests.ts +271 -35
  162. package/src/http/index.ts +1 -1
  163. package/src/http/mcp-servers.ts +74 -50
  164. package/src/http/memory.ts +275 -6
  165. package/src/http/repos.ts +58 -18
  166. package/src/http/request-principal.ts +19 -0
  167. package/src/http/session-cost-recompute.ts +64 -0
  168. package/src/http/session-data.ts +11 -0
  169. package/src/http/tasks.ts +9 -1
  170. package/src/http/webhooks.ts +17 -5
  171. package/src/prompts/base-prompt.ts +9 -4
  172. package/src/prompts/resolver.ts +1 -1
  173. package/src/prompts/session-templates.ts +28 -0
  174. package/src/providers/amp-adapter.ts +1232 -0
  175. package/src/providers/cursor-adapter.ts +638 -0
  176. package/src/providers/index.ts +9 -1
  177. package/src/providers/pricing-sources.md +39 -0
  178. package/src/providers/reasoning-effort.ts +15 -1
  179. package/src/providers/types.ts +11 -1
  180. package/src/rbac/legacy-policy.ts +23 -8
  181. package/src/rbac/permissions.ts +27 -1
  182. package/src/scripts-runtime/types/swarm-extension.d.ts +119 -0
  183. package/src/tests/amp-adapter.test.ts +822 -0
  184. package/src/tests/amp-budget-export-failed.test.ts +133 -0
  185. package/src/tests/amp-pricing-helpers.ts +16 -0
  186. package/src/tests/amp-pricing.test.ts +218 -0
  187. package/src/tests/api-drain-worker-e2e.test.ts +18 -7
  188. package/src/tests/approval-respond-auth.test.ts +371 -0
  189. package/src/tests/base-prompt.test.ts +13 -0
  190. package/src/tests/claude-adapter-binary.test.ts +24 -0
  191. package/src/tests/claude-adapter.test.ts +8 -0
  192. package/src/tests/cursor-adapter.test.ts +690 -0
  193. package/src/tests/db-task-read-contract.test.ts +5 -0
  194. package/src/tests/db-task-write-contract.test.ts +5 -0
  195. package/src/tests/docs-index-footprint.test.js +3 -3
  196. package/src/tests/extensions-post-bridge.test.ts +669 -0
  197. package/src/tests/extensions-run-context.test.ts +61 -0
  198. package/src/tests/fixtures/fake-amp.ts +304 -0
  199. package/src/tests/github-handlers-inline-comments.test.ts +147 -1
  200. package/src/tests/gitlab-workflow-event-names.test.ts +136 -0
  201. package/src/tests/mcp-input-ergonomics.test.ts +15 -10
  202. package/src/tests/mcp-server-stdio-gate.test.ts +438 -0
  203. package/src/tests/memory-http-access.test.ts +221 -0
  204. package/src/tests/memory-keys-endpoint.test.ts +406 -0
  205. package/src/tests/memory-store.test.ts +166 -0
  206. package/src/tests/model-tier-resolution.test.ts +3 -3
  207. package/src/tests/pricing-refresh.test.ts +5 -4
  208. package/src/tests/prompt-template-session.test.ts +5 -3
  209. package/src/tests/provider-process-group.test.ts +41 -0
  210. package/src/tests/provider-registration.test.ts +3 -1
  211. package/src/tests/rbac-charact-misc-tools.test.ts +18 -3
  212. package/src/tests/rbac-engine.test.ts +15 -11
  213. package/src/tests/rbac-wire-e2e.test.ts +4 -9
  214. package/src/tests/repo-allow-merge-gate.test.ts +382 -0
  215. package/src/tests/script-connections.test.ts +4 -0
  216. package/src/tests/send-task-requester-gate.test.ts +260 -0
  217. package/src/tests/session-activity-liveness.test.ts +248 -0
  218. package/src/tests/session-costs-golden.test.ts +28 -0
  219. package/src/tests/webhooks-task-blocked.test.ts +4 -4
  220. package/src/tests/write-gate.ts +68 -0
  221. package/src/tests/x402-client.test.ts +124 -0
  222. package/src/tests/x402-spending-tracker.test.ts +66 -0
  223. package/src/tools/mcp-servers/mcp-server-create.ts +23 -1
  224. package/src/tools/mcp-servers/mcp-server-update.ts +46 -28
  225. package/src/tools/memory-delete.ts +3 -3
  226. package/src/tools/repos/update-repo.ts +26 -5
  227. package/src/tools/send-task.ts +24 -1
  228. package/src/tools/steer-task.ts +1 -1
  229. package/src/types.ts +37 -2
  230. package/src/utils/amp-models.ts +114 -0
  231. package/src/utils/credentials.ts +8 -0
  232. package/src/utils/process-group.ts +79 -0
  233. package/src/workflows/event-bus.ts +28 -0
  234. package/src/x402/client.ts +36 -14
  235. package/src/x402/spending-tracker.ts +64 -3
  236. package/templates/skills/agent-browser/SKILL.md +5 -0
  237. package/templates/skills/agent-browser/content.md +5 -0
  238. package/templates/skills/heartbeat-runbook/content.md +1 -0
  239. package/templates/skills/swarm-extensions/content.md +4 -0
  240. package/dist/cli-y89t4nca.js +0 -67
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  VisualLinePreview,
3
+ formatSize,
3
4
  formatToolCallWithArgs,
4
5
  getShellConfig,
5
6
  getTextOutput,
6
- replaceTabs
7
- } from "./cli-p0r8sxj5.js";
7
+ replaceTabs,
8
+ truncateMiddle,
9
+ writeOutputFile
10
+ } from "./cli-crjazzsg.js";
8
11
  import {
9
12
  Container,
10
13
  Spacer,
@@ -14,7 +17,7 @@ import {
14
17
  keyHint,
15
18
  normalizePath,
16
19
  stripBom
17
- } from "./cli-s3hwpt9v.js";
20
+ } from "./cli-9s6fsg07.js";
18
21
  import {
19
22
  require_cross_spawn
20
23
  } from "./cli-5bfdm1ah.js";
@@ -548,8 +551,8 @@ GFS4: `);
548
551
  }
549
552
  }
550
553
  var fs$writeFile = fs2.writeFile;
551
- fs2.writeFile = writeFile2;
552
- function writeFile2(path, data, options, cb) {
554
+ fs2.writeFile = writeFile;
555
+ function writeFile(path, data, options, cb) {
553
556
  if (typeof options === "function")
554
557
  cb = options, options = null;
555
558
  return go$writeFile(path, data, options, cb);
@@ -2945,210 +2948,7 @@ function toLlmContent(result) {
2945
2948
  return content;
2946
2949
  }
2947
2950
  // node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.js
2948
- import { createHash, randomBytes } from "node:crypto";
2949
- import { writeFile } from "node:fs/promises";
2950
- import { tmpdir } from "node:os";
2951
- import { join } from "node:path";
2952
-
2953
- // node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js
2954
- var DEFAULT_MAX_LINES = 2000;
2955
- var DEFAULT_MAX_BYTES = 50 * 1024;
2956
- var GREP_MAX_LINE_LENGTH = 500;
2957
- function splitLinesForCounting(content) {
2958
- if (content.length === 0) {
2959
- return [];
2960
- }
2961
- const lines = content.split(`
2962
- `);
2963
- if (content.endsWith(`
2964
- `)) {
2965
- lines.pop();
2966
- }
2967
- return lines;
2968
- }
2969
- function formatSize(bytes) {
2970
- if (bytes < 1024) {
2971
- return `${bytes}B`;
2972
- } else if (bytes < 1024 * 1024) {
2973
- return `${(bytes / 1024).toFixed(1)}KB`;
2974
- } else {
2975
- return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
2976
- }
2977
- }
2978
- function truncateHead(content, options = {}) {
2979
- const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
2980
- const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
2981
- const totalBytes = Buffer.byteLength(content, "utf-8");
2982
- const lines = splitLinesForCounting(content);
2983
- const totalLines = lines.length;
2984
- if (totalLines <= maxLines && totalBytes <= maxBytes) {
2985
- return {
2986
- content,
2987
- truncated: false,
2988
- truncatedBy: null,
2989
- totalLines,
2990
- totalBytes,
2991
- outputLines: totalLines,
2992
- outputBytes: totalBytes,
2993
- lastLinePartial: false,
2994
- firstLineExceedsLimit: false,
2995
- maxLines,
2996
- maxBytes
2997
- };
2998
- }
2999
- const firstLineBytes = Buffer.byteLength(lines[0], "utf-8");
3000
- if (firstLineBytes > maxBytes) {
3001
- return {
3002
- content: "",
3003
- truncated: true,
3004
- truncatedBy: "bytes",
3005
- totalLines,
3006
- totalBytes,
3007
- outputLines: 0,
3008
- outputBytes: 0,
3009
- lastLinePartial: false,
3010
- firstLineExceedsLimit: true,
3011
- maxLines,
3012
- maxBytes
3013
- };
3014
- }
3015
- const outputLinesArr = [];
3016
- let outputBytesCount = 0;
3017
- let truncatedBy = "lines";
3018
- for (let i = 0;i < lines.length && i < maxLines; i++) {
3019
- const line = lines[i];
3020
- const lineBytes = Buffer.byteLength(line, "utf-8") + (i > 0 ? 1 : 0);
3021
- if (outputBytesCount + lineBytes > maxBytes) {
3022
- truncatedBy = "bytes";
3023
- break;
3024
- }
3025
- outputLinesArr.push(line);
3026
- outputBytesCount += lineBytes;
3027
- }
3028
- if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
3029
- truncatedBy = "lines";
3030
- }
3031
- const outputContent = outputLinesArr.join(`
3032
- `);
3033
- const finalOutputBytes = Buffer.byteLength(outputContent, "utf-8");
3034
- return {
3035
- content: outputContent,
3036
- truncated: true,
3037
- truncatedBy,
3038
- totalLines,
3039
- totalBytes,
3040
- outputLines: outputLinesArr.length,
3041
- outputBytes: finalOutputBytes,
3042
- lastLinePartial: false,
3043
- firstLineExceedsLimit: false,
3044
- maxLines,
3045
- maxBytes
3046
- };
3047
- }
3048
- function truncateTail(content, options = {}) {
3049
- const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
3050
- const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
3051
- const totalBytes = Buffer.byteLength(content, "utf-8");
3052
- const lines = splitLinesForCounting(content);
3053
- const totalLines = lines.length;
3054
- if (totalLines <= maxLines && totalBytes <= maxBytes) {
3055
- return {
3056
- content,
3057
- truncated: false,
3058
- truncatedBy: null,
3059
- totalLines,
3060
- totalBytes,
3061
- outputLines: totalLines,
3062
- outputBytes: totalBytes,
3063
- lastLinePartial: false,
3064
- firstLineExceedsLimit: false,
3065
- maxLines,
3066
- maxBytes
3067
- };
3068
- }
3069
- const outputLinesArr = [];
3070
- let outputBytesCount = 0;
3071
- let truncatedBy = "lines";
3072
- let lastLinePartial = false;
3073
- for (let i = lines.length - 1;i >= 0 && outputLinesArr.length < maxLines; i--) {
3074
- const line = lines[i];
3075
- const lineBytes = Buffer.byteLength(line, "utf-8") + (outputLinesArr.length > 0 ? 1 : 0);
3076
- if (outputBytesCount + lineBytes > maxBytes) {
3077
- truncatedBy = "bytes";
3078
- if (outputLinesArr.length === 0) {
3079
- const truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);
3080
- outputLinesArr.unshift(truncatedLine);
3081
- outputBytesCount = Buffer.byteLength(truncatedLine, "utf-8");
3082
- lastLinePartial = true;
3083
- }
3084
- break;
3085
- }
3086
- outputLinesArr.unshift(line);
3087
- outputBytesCount += lineBytes;
3088
- }
3089
- if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
3090
- truncatedBy = "lines";
3091
- }
3092
- const outputContent = outputLinesArr.join(`
3093
- `);
3094
- const finalOutputBytes = Buffer.byteLength(outputContent, "utf-8");
3095
- return {
3096
- content: outputContent,
3097
- truncated: true,
3098
- truncatedBy,
3099
- totalLines,
3100
- totalBytes,
3101
- outputLines: outputLinesArr.length,
3102
- outputBytes: finalOutputBytes,
3103
- lastLinePartial,
3104
- firstLineExceedsLimit: false,
3105
- maxLines,
3106
- maxBytes
3107
- };
3108
- }
3109
- function truncateStringToBytesFromEnd(str, maxBytes) {
3110
- const buf = Buffer.from(str, "utf-8");
3111
- if (buf.length <= maxBytes) {
3112
- return str;
3113
- }
3114
- let start = buf.length - maxBytes;
3115
- while (start < buf.length && (buf[start] & 192) === 128) {
3116
- start++;
3117
- }
3118
- return buf.slice(start).toString("utf-8");
3119
- }
3120
- function truncateLine(line, maxChars = GREP_MAX_LINE_LENGTH) {
3121
- if (line.length <= maxChars) {
3122
- return { text: line, wasTruncated: false };
3123
- }
3124
- return { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };
3125
- }
3126
- function truncateMiddle(content, maxBytes) {
3127
- const buf = Buffer.from(content, "utf-8");
3128
- const totalLines = splitLinesForCounting(content).length;
3129
- if (buf.length <= maxBytes) {
3130
- return { content, truncated: false, removedChars: 0, totalBytes: buf.length, totalLines };
3131
- }
3132
- const isBoundary = (index) => index >= buf.length || (buf[index] & 192) !== 128;
3133
- let headEnd = Math.floor(maxBytes / 2);
3134
- while (headEnd > 0 && !isBoundary(headEnd))
3135
- headEnd--;
3136
- let tailStart = buf.length - (maxBytes - Math.floor(maxBytes / 2));
3137
- while (tailStart < buf.length && !isBoundary(tailStart))
3138
- tailStart++;
3139
- const head = buf.subarray(0, headEnd).toString("utf-8");
3140
- const tail = buf.subarray(tailStart).toString("utf-8");
3141
- const removedChars = Array.from(buf.subarray(headEnd, tailStart).toString("utf-8")).length;
3142
- return {
3143
- content: `${head}…${removedChars} chars truncated…${tail}`,
3144
- truncated: true,
3145
- removedChars,
3146
- totalBytes: buf.length,
3147
- totalLines
3148
- };
3149
- }
3150
-
3151
- // node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.js
2951
+ import { createHash } from "node:crypto";
3152
2952
  function toToolExposure(exposure) {
3153
2953
  return exposure === "codemode" ? "deferred" : exposure;
3154
2954
  }
@@ -3156,10 +2956,8 @@ var MAX_TOOL_NAME_LENGTH = 64;
3156
2956
  var MCP_OUTPUT_MAX_BYTES = 20 * 1024;
3157
2957
  var OUTPUT_PREVIEW_LINES = 5;
3158
2958
  var READ_MCP_RESOURCE_TOOL = "read_mcp_resource";
3159
- async function saveToTempFile(data, extension) {
3160
- const path = join(tmpdir(), `pi-mcp-${randomBytes(8).toString("hex")}${extension}`);
3161
- await writeFile(path, data, { mode: 384 });
3162
- return path;
2959
+ function saveToTempFile(data, extension) {
2960
+ return writeOutputFile("pi-mcp", extension, data);
3163
2961
  }
3164
2962
  function createMcpToolName(server, tool, isTaken = () => false) {
3165
2963
  const name = `mcp__${server}__${tool}`.replace(/[^A-Za-z0-9_]/g, "_");
@@ -3640,14 +3438,14 @@ function raceWithAbortSignal(operation, signal) {
3640
3438
  // node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js
3641
3439
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
3642
3440
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
3643
- import { dirname, join as join2 } from "path";
3441
+ import { dirname, join } from "path";
3644
3442
  import { setTimeout as sleep } from "timers/promises";
3645
3443
  var AUTH_FILE_WRITE_OPTIONS = { encoding: "utf-8", mode: 384 };
3646
3444
  var sharedAuthFileReadState;
3647
3445
 
3648
3446
  class FileAuthStorageBackend {
3649
3447
  authPath;
3650
- constructor(authPath = join2(getAgentDir(), "auth.json")) {
3448
+ constructor(authPath = join(getAgentDir(), "auth.json")) {
3651
3449
  this.authPath = normalizePath(authPath);
3652
3450
  }
3653
3451
  ensureParentDir() {
@@ -3776,7 +3574,7 @@ class FileAuthStorageBackend {
3776
3574
  class ReadOnlyAuthStorage {
3777
3575
  authPath;
3778
3576
  data;
3779
- constructor(authPath = join2(getAgentDir(), "auth.json")) {
3577
+ constructor(authPath = join(getAgentDir(), "auth.json")) {
3780
3578
  this.authPath = normalizePath(authPath);
3781
3579
  }
3782
3580
  load() {
@@ -3886,7 +3684,7 @@ class AuthStorage {
3886
3684
  }
3887
3685
  this.reload();
3888
3686
  }
3889
- static create(authPath = join2(getAgentDir(), "auth.json")) {
3687
+ static create(authPath = join(getAgentDir(), "auth.json")) {
3890
3688
  const normalizedAuthPath = normalizePath(authPath);
3891
3689
  return new AuthStorage(new FileAuthStorageBackend(normalizedAuthPath), normalizedAuthPath);
3892
3690
  }
@@ -4009,7 +3807,7 @@ class AuthStorage {
4009
3807
  return entries.map(([providerId, credential]) => ({ providerId, type: credential.type }));
4010
3808
  }
4011
3809
  }
4012
- function readStoredCredential(providerId, authPath = join2(getAgentDir(), "auth.json")) {
3810
+ function readStoredCredential(providerId, authPath = join(getAgentDir(), "auth.json")) {
4013
3811
  try {
4014
3812
  const data = JSON.parse(stripBom(readFileSync(normalizePath(authPath), "utf-8")));
4015
3813
  return data[providerId];
@@ -4018,4 +3816,4 @@ function readStoredCredential(providerId, authPath = join2(getAgentDir(), "auth.
4018
3816
  }
4019
3817
  }
4020
3818
 
4021
- export { DEFAULT_MAX_LINES, DEFAULT_MAX_BYTES, GREP_MAX_LINE_LENGTH, formatSize, truncateHead, truncateTail, truncateLine, mcpNamespace, getMcpToolExposure, validateMcpServerConfig, McpServerRegistry, getConfigValueEnvVarNames, isCommandConfigValue, isConfigValueConfigured, resolveConfigValueOrThrow, resolveHeadersOrThrow, require_proper_lockfile, operationSignal, raceWithAbortSignal, FileAuthStorageBackend, ReadOnlyAuthStorage, AuthStorage, readStoredCredential, JSON_RPC_ERROR_CODES, McpError, isObject, LATEST_PROTOCOL_VERSION, McpClient, StdioTransport, McpHttpError, McpAuthRequiredError, McpSessionExpiredError, StreamableHttpTransport, READ_MCP_RESOURCE_TOOL, createMcpToolName, createMcpToolDefinition, createMcpToolRenderers, LIST_MCP_RESOURCES_TOOL, LIST_MCP_RESOURCE_TEMPLATES_TOOL, isMcpAppResource, createMcpResourceToolDefinitions };
3819
+ export { mcpNamespace, getMcpToolExposure, validateMcpServerConfig, McpServerRegistry, getConfigValueEnvVarNames, isCommandConfigValue, isConfigValueConfigured, resolveConfigValueOrThrow, resolveHeadersOrThrow, require_proper_lockfile, operationSignal, raceWithAbortSignal, FileAuthStorageBackend, ReadOnlyAuthStorage, AuthStorage, readStoredCredential, JSON_RPC_ERROR_CODES, McpError, isObject, LATEST_PROTOCOL_VERSION, McpClient, StdioTransport, McpHttpError, McpAuthRequiredError, McpSessionExpiredError, StreamableHttpTransport, READ_MCP_RESOURCE_TOOL, createMcpToolName, createMcpToolDefinition, createMcpToolRenderers, LIST_MCP_RESOURCES_TOOL, LIST_MCP_RESOURCE_TEMPLATES_TOOL, isMcpAppResource, createMcpResourceToolDefinitions };
@@ -8,7 +8,7 @@ import {
8
8
  resolveGrammarConstrainedSampling,
9
9
  resolveJsonSchemaStrictSampling,
10
10
  transformMessages
11
- } from "./cli-mbssg1xv.js";
11
+ } from "./cli-8kt0bmgx.js";
12
12
  import {
13
13
  sanitizeSurrogates
14
14
  } from "./cli-y2apkfe2.js";
@@ -18,7 +18,7 @@ import {
18
18
  renderSystemMessageUpdate,
19
19
  resolveTranscript,
20
20
  resolveTranscriptTools
21
- } from "./cli-ykk5jaax.js";
21
+ } from "./cli-nexwh8zg.js";
22
22
  import {
23
23
  parseStreamingJson
24
24
  } from "./cli-1m2e086m.js";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  buildModelsDevSeedRows,
3
3
  loadModelsDevCache
4
- } from "./cli-vy3ed88x.js";
4
+ } from "./cli-402m8btc.js";
5
5
  import {
6
6
  createLogEntry,
7
7
  getActivePricingRow,
8
8
  getDbClient,
9
9
  init_db,
10
10
  insertPricingRow
11
- } from "./cli-jf7wmv1r.js";
11
+ } from "./cli-tsvj33y0.js";
12
12
  import {
13
13
  init_runtime_model_catalog,
14
14
  setRuntimeModelCatalog
15
- } from "./cli-jyy6pm2f.js";
15
+ } from "./cli-g3qgrzck.js";
16
16
  import {
17
17
  init_secret_scrubber,
18
18
  scrubSecrets