@desplega.ai/agent-swarm 1.171.0 → 1.172.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 (183) hide show
  1. package/dist/{acp-adapter-1z9p3fvx.js → acp-adapter-fpecx1g1.js} +23 -5
  2. package/dist/{actions-rc2yjk8a.js → actions-pw87a1a8.js} +24 -25
  3. package/dist/{amp-adapter-ypyf5s1x.js → amp-adapter-8jem2bc0.js} +1 -1
  4. package/dist/{anthropic-messages-etkbxhhy.js → anthropic-messages-8ee2f22q.js} +55 -22
  5. package/dist/{app-04ab2s0z.js → app-wmf0m843.js} +7 -8
  6. package/dist/{assistant-vhmjd8wf.js → assistant-emp1e108.js} +26 -27
  7. package/dist/{azure-openai-responses-xap57x4b.js → azure-openai-responses-ap1gwxgr.js} +3 -3
  8. package/dist/{boot-reembed-3p0m259x.js → boot-reembed-1de4f4aj.js} +6 -7
  9. package/dist/{boot-reembed-wew3gwk8.js → boot-reembed-4ymn9atn.js} +6 -7
  10. package/dist/{boot-scrub-sweep-5ytwtq24.js → boot-scrub-sweep-adhk1s8c.js} +7 -8
  11. package/dist/{boot-seeds-s8p2xry8.js → boot-seeds-8q637aew.js} +9 -10
  12. package/dist/{claude-adapter-akrzg6jh.js → claude-adapter-t26cv8a4.js} +16 -17
  13. package/dist/{claude-managed-adapter-kqqqhp2q.js → claude-managed-adapter-xgxhqrt2.js} +2 -2
  14. package/dist/{claude-sdk-session-exq1jadx.js → claude-sdk-session-gsfsh662.js} +16 -17
  15. package/dist/{cli-n8ybnv1k.js → cli-04emfe2q.js} +1 -1
  16. package/dist/{cli-w0bwte75.js → cli-104zsxba.js} +2 -1
  17. package/dist/{cli-x6z90nq9.js → cli-19njxg5g.js} +2 -4
  18. package/dist/{cli-8mr695sb.js → cli-1hgat6pa.js} +5 -5
  19. package/dist/{cli-1qtgd1h1.js → cli-1m2xxxe2.js} +2 -2
  20. package/dist/{cli-231av4y6.js → cli-1x7da0de.js} +2 -4
  21. package/dist/{cli-x3fy2tgp.js → cli-388egyf6.js} +1 -1
  22. package/dist/{cli-j0w59p15.js → cli-4fnb6884.js} +4 -4
  23. package/dist/{cli-y1j1ggbf.js → cli-4nz8p1p5.js} +1372 -588
  24. package/dist/{cli-s88my3br.js → cli-5rv1j9ga.js} +6 -6
  25. package/dist/{cli-mn8qkd8v.js → cli-61625k3x.js} +1 -1
  26. package/dist/{cli-mzj3aqac.js → cli-6jb2rf77.js} +3 -3
  27. package/dist/{cli-ec7hrgqp.js → cli-8hzfb6xz.js} +8 -8
  28. package/dist/{cli-n805bb98.js → cli-8vs9trd4.js} +1 -1
  29. package/dist/{cli-xf713zz0.js → cli-9fxpr83v.js} +1 -1
  30. package/dist/{cli-q1vnz8wv.js → cli-9s17naqf.js} +1 -1
  31. package/dist/{cli-nkjwe4z7.js → cli-9xsmdpdt.js} +59 -54
  32. package/dist/{cli-6xxxb8qt.js → cli-aspcaef3.js} +5 -5
  33. package/dist/cli-bf7485pm.js +514 -0
  34. package/dist/{cli-s9y81s7j.js → cli-bt8k5h3s.js} +625 -150
  35. package/dist/{cli-jxsgrnmq.js → cli-c2pq2rjb.js} +2 -2
  36. package/dist/{cli-13xwcqvj.js → cli-c5km5znr.js} +2 -2
  37. package/dist/{cli-5y67yrt6.js → cli-cceskcvt.js} +112 -176
  38. package/dist/{cli-ph3145b7.js → cli-cf69s3ew.js} +4 -4
  39. package/dist/{cli-k2v5x13t.js → cli-d603qf86.js} +1 -1
  40. package/dist/{cli-r455yd58.js → cli-e0a9sk00.js} +1 -1
  41. package/dist/{cli-cgj4hc12.js → cli-eh1ytktb.js} +1872 -190
  42. package/dist/{cli-erbp6b4g.js → cli-esnpehf5.js} +7 -8
  43. package/dist/cli-ev91t6xp.js +148 -0
  44. package/dist/{cli-e2prcx5m.js → cli-fdvbjtbw.js} +235 -5
  45. package/dist/{cli-62bwwc2q.js → cli-g4f5pj26.js} +3 -3
  46. package/dist/{cli-tg8q0b5y.js → cli-g6t9texm.js} +5 -5
  47. package/dist/{cli-p2pjfq1r.js → cli-gj81e47t.js} +1 -1
  48. package/dist/{cli-srmej5tp.js → cli-gp1rtyvk.js} +2 -2
  49. package/dist/{cli-rb9m6rpe.js → cli-h6vtvt5c.js} +139 -1
  50. package/dist/cli-hd27d2md.js +1057 -0
  51. package/dist/{cli-hsk5gd15.js → cli-hwwvy36w.js} +3 -3
  52. package/dist/{cli-2rbt7at8.js → cli-hz99wfxp.js} +1 -1
  53. package/dist/cli-j1pmc07z.js +706 -0
  54. package/dist/{cli-01qndrvw.js → cli-j6kpj9az.js} +14 -8
  55. package/dist/{cli-2qbs2tvf.js → cli-k46r9hmk.js} +6 -6
  56. package/dist/{cli-wfvedq5w.js → cli-kb4ehzx5.js} +5 -5
  57. package/dist/{cli-agamgm0p.js → cli-mvzyxwg3.js} +1 -1
  58. package/dist/{cli-280gnz4v.js → cli-nv4zd0b9.js} +1 -1
  59. package/dist/{cli-rrbctenq.js → cli-nyhb1r6x.js} +3 -5
  60. package/dist/{cli-g7k7zbcz.js → cli-p7z6q2m6.js} +2 -1
  61. package/dist/{cli-yn0a417a.js → cli-phre6gz0.js} +22 -4
  62. package/dist/{cli-m4csbs67.js → cli-pj6x9qce.js} +1 -1
  63. package/dist/{cli-w0zx9ya1.js → cli-prrt9fa0.js} +4 -4
  64. package/dist/{cli-ctret352.js → cli-pstq9888.js} +33 -33
  65. package/dist/{cli-y195hv1a.js → cli-pxeeyc53.js} +1 -1
  66. package/dist/{cli-4bm25xtw.js → cli-qsztpfry.js} +1 -1
  67. package/dist/{cli-5t5my0h8.js → cli-qybkr9n3.js} +278 -1267
  68. package/dist/{cli-xezn9nkh.js → cli-r44t9wqc.js} +29 -472
  69. package/dist/{cli-x207g4w1.js → cli-r8smj8b8.js} +1 -1
  70. package/dist/{cli-bxqez1p0.js → cli-rcp5aqdw.js} +9 -39
  71. package/dist/{cli-vr5avem2.js → cli-smcrrmhy.js} +14 -18
  72. package/dist/{cli-0d2rqhvq.js → cli-tgpfnm6r.js} +15 -17
  73. package/dist/cli-vb8g5x02.js +549 -0
  74. package/dist/{cli-gt4hxb8p.js → cli-vv0qtfpx.js} +1 -2
  75. package/dist/{cli-95zs84qw.js → cli-wd0hz6ah.js} +671 -388
  76. package/dist/{cli-nkqjj42q.js → cli-x4m6feqt.js} +1 -1
  77. package/dist/{cli-x61srfpp.js → cli-xczpdp9e.js} +2 -2
  78. package/dist/cli-z1kd834t.js +36 -0
  79. package/dist/{cli-p8f7dqgt.js → cli-ztrv9y21.js} +48 -33
  80. package/dist/cli.js +24 -25
  81. package/dist/{cloudflare-workers-ai-system-one-sta45jf9.js → cloudflare-workers-ai-system-one-vnpyfr7e.js} +3 -3
  82. package/dist/{codex-adapter-9ag75whm.js → codex-adapter-m4tgdysy.js} +12 -12
  83. package/dist/{codex-hook-7ba15hjd.js → codex-hook-xch6z5wt.js} +2 -3
  84. package/dist/{codex-session-runner-9fp7y4cf.js → codex-session-runner-ymwzm6ea.js} +12 -12
  85. package/dist/{commands-d7eah0y9.js → commands-n0hshcvs.js} +6 -7
  86. package/dist/{controllers-connect-8t0k65x2.js → controllers-connect-y07cqcvy.js} +24 -25
  87. package/dist/{cursor-adapter-t4pr1m3c.js → cursor-adapter-q8pgv5qa.js} +2 -3
  88. package/dist/{db-sp39qv72.js → db-4w7tmt1g.js} +6 -7
  89. package/dist/{db-2rmd23wq.js → db-hkqvrdcb.js} +7 -8
  90. package/dist/{dispatcher-g7fsybsd.js → dispatcher-5sd69y14.js} +23 -24
  91. package/dist/{easter-egg-3d-66zxervv.js → easter-egg-3d-m8rvz40s.js} +4 -3
  92. package/dist/execute-107xtsp1.js +3745 -0
  93. package/dist/{google-generative-ai-pvhm0dq1.js → google-generative-ai-7pavrbv7.js} +3 -3
  94. package/dist/{google-vertex-tek9sqe2.js → google-vertex-3f1jk41f.js} +3 -3
  95. package/dist/{grok-adapter-1err1me7.js → grok-adapter-8m9yqzbq.js} +24 -6
  96. package/dist/{handlers-c7yggm37.js → handlers-s20xr10r.js} +26 -27
  97. package/dist/{heartbeat-dkm924fk.js → heartbeat-3k31q4g2.js} +25 -26
  98. package/dist/{hook-wgx4exw6.js → hook-gdn6a2fn.js} +13 -14
  99. package/dist/{hook-g8e7sfnf.js → hook-ygwerrdh.js} +14 -15
  100. package/dist/{http-1d23k928.js → http-jdteeg81.js} +53 -55
  101. package/dist/{index-y5vvczrs.js → index-6ksewd5y.js} +20 -18
  102. package/dist/{index-kkeftv5h.js → index-82rk11v7.js} +4 -4
  103. package/dist/{index-gm10tmye.js → index-e0snym4t.js} +23 -24
  104. package/dist/{index-vertaxs1.js → index-ffqzqgwb.js} +6 -7
  105. package/dist/{index-q7cj9bn2.js → index-tsszt7g9.js} +25 -26
  106. package/dist/{index-w097eg0x.js → index-vccv018g.js} +1 -1
  107. package/dist/{index-va4zbvzp.js → index-vm3bm9t7.js} +24 -25
  108. package/dist/{keepalive-1jc5e7ct.js → keepalive-jekc896t.js} +8 -9
  109. package/dist/{lead-yxw2f1sg.js → lead-4k9s9szx.js} +40 -41
  110. package/dist/{maintenance-h7w2m10y.js → maintenance-shazch4n.js} +6 -7
  111. package/dist/{mistral-conversations-rjxa9s1j.js → mistral-conversations-vjc1ggpd.js} +29 -15
  112. package/dist/{oauth-refresh-sweep-wh9ypd1b.js → oauth-refresh-sweep-5gb36kn8.js} +7 -8
  113. package/dist/{onboard-dfr9j762.js → onboard-ydrbnvww.js} +2 -2
  114. package/dist/{openai-codex-responses-pgvtddvv.js → openai-codex-responses-33qhkkdy.js} +7 -39
  115. package/dist/{openai-completions-44gb0zsk.js → openai-completions-s88xm3ns.js} +2 -2
  116. package/dist/{openai-decisions-vj9nkpf8.js → openai-decisions-fctnj8xd.js} +2 -2
  117. package/dist/{openai-responses-9dyzwzkr.js → openai-responses-7xd2f2e2.js} +3 -3
  118. package/dist/opencode-adapter-5zh0he20.js +55 -0
  119. package/dist/{otel-impl-and31m5s.js → otel-impl-6pf5cv86.js} +1 -1
  120. package/dist/{pi-mono-adapter-fx6k5wwh.js → pi-mono-adapter-ef9wwx9m.js} +25 -500
  121. package/dist/{pricing-refresh-23zr6j3w.js → pricing-refresh-s52nsa5q.js} +8 -9
  122. package/dist/{rbac-roles-wnx35x4x.js → rbac-roles-aq3msh4e.js} +6 -7
  123. package/dist/{rbac-roles-nc7k9d0t.js → rbac-roles-q5gb5e8v.js} +7 -8
  124. package/dist/{render-v2-81cg1y52.js → render-v2-pd1rg54q.js} +7 -8
  125. package/dist/{resume-d4b6j2n2.js → resume-gw4a2c6v.js} +14 -15
  126. package/dist/{runtime-h9ha1mq6.js → runtime-qfry88v2.js} +4 -7
  127. package/dist/{setup-g68r1w28.js → setup-jda1ksdh.js} +2 -2
  128. package/dist/{typesafe-system-one-e988vty7.js → typesafe-system-one-zzzcx4s3.js} +3 -3
  129. package/dist/{virtual-modules-rdjmcg7q.js → virtual-modules-b3ga2m65.js} +13 -12
  130. package/dist/{work-objects-0zzdnbt9.js → work-objects-tb7ycye8.js} +26 -27
  131. package/dist/{worker-p1g8qm6h.js → worker-njjccz5d.js} +40 -41
  132. package/openapi.json +1 -1
  133. package/package.json +7 -8
  134. package/src/be/scripts/extract-schema.ts +4 -0
  135. package/src/github/handlers.ts +61 -18
  136. package/src/github/types.ts +2 -1
  137. package/src/prompts/goal-reminder.ts +30 -0
  138. package/src/prompts/session-templates.ts +22 -0
  139. package/src/providers/acp-targets.ts +3 -4
  140. package/src/providers/amp-adapter.ts +1 -1
  141. package/src/providers/harness-version.ts +0 -1
  142. package/src/providers/opencode-adapter.ts +442 -723
  143. package/src/providers/opencode-swarm-plugin.ts +88 -0
  144. package/src/providers/pi-mono-extension.ts +58 -37
  145. package/src/scripts-runtime/executors/native.ts +6 -5
  146. package/src/scripts-runtime/executors/quickjs-bundle.ts +18 -11
  147. package/src/scripts-runtime/extract-args-schema.ts +22 -4
  148. package/src/scripts-runtime/import-allowlist.ts +1 -1
  149. package/src/scripts-runtime/zod-mini-bundle.ts +5 -0
  150. package/src/slack/render-v2.ts +2 -2
  151. package/src/tests/entrypoint-acp-target-binary.test.ts +19 -1
  152. package/src/tests/github-handlers-inline-comments.test.ts +131 -2
  153. package/src/tests/github-handlers-reactions.test.ts +9 -0
  154. package/src/tests/harness-version.test.ts +0 -20
  155. package/src/tests/opencode-adapter.test.ts +536 -1389
  156. package/src/tests/opencode-mcp-admission-sdk.test.ts +106 -0
  157. package/src/tests/opencode-swarm-plugin.test.ts +130 -0
  158. package/src/tests/pi-mono-extension.test.ts +59 -0
  159. package/src/tests/prompt-template-session.test.ts +4 -3
  160. package/src/tests/provider-registration.test.ts +3 -0
  161. package/src/tests/script-executor-quickjs.test.ts +17 -12
  162. package/src/tests/scripts-http.test.ts +24 -16
  163. package/src/tests/scripts-import-allowlist.test.ts +1 -1
  164. package/src/tests/scripts-runtime.test.ts +78 -40
  165. package/src/tests/seed-scripts.test.ts +13 -0
  166. package/src/tests/slack-render-v2.test.ts +4 -2
  167. package/src/tests/ui-logs-parser.test.ts +28 -0
  168. package/src/tools/script-upsert.ts +1 -1
  169. package/src/utils/memory-raters.ts +7 -3
  170. package/src/utils/openrouter-base-url.ts +0 -2
  171. package/templates/schedules/weekly-harness-upgrade-check/content.md +4 -6
  172. package/templates/skills/heartbeat-runbook/content.md +2 -0
  173. package/templates/skills/swarm-scripts/SKILL.md +1 -0
  174. package/templates/skills/swarm-scripts/content.md +1 -0
  175. package/dist/cli-5bfdm1ah.js +0 -462
  176. package/dist/cli-5c2j5yvx.js +0 -222
  177. package/dist/cli-rhy7z1rp.js +0 -532
  178. package/dist/cli-ywh2a87k.js +0 -2359
  179. package/dist/execute-h4jgevyw.js +0 -1387
  180. package/dist/opencode-adapter-f1zby94p.js +0 -34
  181. package/plugin/opencode-plugins/lib/memory-raters.ts +0 -7
  182. package/src/tests/opencode-plugin.test.ts +0 -580
  183. package/src/tests/providers/opencode-cost.test.ts +0 -74
@@ -3,7 +3,10 @@ import {
3
3
  } from "./cli-ge593j7e.js";
4
4
  import {
5
5
  readPkgVersion
6
- } from "./cli-gt4hxb8p.js";
6
+ } from "./cli-vv0qtfpx.js";
7
+ import {
8
+ createSwarmHooksExtension
9
+ } from "./cli-bf7485pm.js";
7
10
  import {
8
11
  DefaultResourceLoader,
9
12
  ModelRuntime,
@@ -13,53 +16,44 @@ import {
13
16
  createCodemodeExtension,
14
17
  createMcpExtension,
15
18
  createToolSearchExtension
16
- } from "./cli-y1j1ggbf.js";
17
- import"./cli-s9y81s7j.js";
18
- import"./cli-13xwcqvj.js";
19
- import"./cli-xezn9nkh.js";
20
- import"./cli-rhy7z1rp.js";
21
- import"./cli-y195hv1a.js";
19
+ } from "./cli-4nz8p1p5.js";
20
+ import"./cli-bt8k5h3s.js";
21
+ import"./cli-c5km5znr.js";
22
+ import"./cli-r44t9wqc.js";
23
+ import"./cli-ev91t6xp.js";
24
+ import"./cli-pxeeyc53.js";
25
+ import"./cli-qybkr9n3.js";
26
+ import"./cli-vb8g5x02.js";
22
27
  import {
23
28
  getAgentDir,
24
29
  setEmbeddedQuickJSWasmPath
25
- } from "./cli-5t5my0h8.js";
26
- import"./cli-5bfdm1ah.js";
27
- import {
28
- summarizeSession
29
- } from "./cli-ph3145b7.js";
30
- import {
31
- checkToolLoop,
32
- clearToolHistory
33
- } from "./cli-hp1n6zq3.js";
30
+ } from "./cli-hd27d2md.js";
34
31
  import {
35
32
  fetchInstalledMcpServers
36
33
  } from "./cli-tng3131n.js";
34
+ import"./cli-cf69s3ew.js";
35
+ import"./cli-hp1n6zq3.js";
37
36
  import {
38
37
  applyReasoningEffort
39
38
  } from "./cli-tmhsxhb8.js";
40
39
  import"./cli-0m7wct0d.js";
41
40
  import"./cli-7nxes1hs.js";
42
- import {
43
- buildRatingsFromLlm,
44
- fetchRetrievalsForTask,
45
- getMemoryRaterNames,
46
- postRatings
47
- } from "./cli-w0bwte75.js";
41
+ import"./cli-104zsxba.js";
48
42
  import {
49
43
  swarmRuntimeInstanceId
50
44
  } from "./cli-re8z5p8p.js";
51
45
  import {
52
46
  McpHttpClient
53
47
  } from "./cli-epan13p1.js";
54
- import"./cli-x61srfpp.js";
48
+ import"./cli-xczpdp9e.js";
55
49
  import"./cli-7jykv7ef.js";
56
50
  import {
57
51
  getBuiltinModel,
58
52
  getBuiltinModels
59
- } from "./cli-5y67yrt6.js";
53
+ } from "./cli-cceskcvt.js";
60
54
  import {
61
55
  exports_typebox
62
- } from "./cli-rb9m6rpe.js";
56
+ } from "./cli-h6vtvt5c.js";
63
57
  import"./cli-2x0e561b.js";
64
58
  import"./cli-bsakbbkm.js";
65
59
  import"./cli-zxg80zs9.js";
@@ -67,10 +61,10 @@ import"./cli-ydt3zkwv.js";
67
61
  import"./cli-3er6gcsn.js";
68
62
  import"./cli-0xqde53b.js";
69
63
  import"./cli-pqetb83f.js";
70
- import"./cli-mn8qkd8v.js";
64
+ import"./cli-61625k3x.js";
71
65
  import"./cli-btbzvq95.js";
72
66
  import"./cli-1m2e086m.js";
73
- import"./cli-g7k7zbcz.js";
67
+ import"./cli-p7z6q2m6.js";
74
68
  import"./cli-wnb9b2g3.js";
75
69
  import {
76
70
  CORE_TOOLS,
@@ -78,16 +72,15 @@ import {
78
72
  } from "./cli-ywm1azg9.js";
79
73
  import {
80
74
  init_templates
81
- } from "./cli-agamgm0p.js";
75
+ } from "./cli-mvzyxwg3.js";
82
76
  import {
83
77
  init_resolver,
84
78
  resolveTemplateAsync
85
- } from "./cli-5c2j5yvx.js";
86
- import"./cli-1a2j50m0.js";
79
+ } from "./cli-fdvbjtbw.js";
87
80
  import"./cli-f9w1semm.js";
81
+ import"./cli-1a2j50m0.js";
88
82
  import {
89
83
  DEFAULT_OPENROUTER_BASE_URL,
90
- getOpenRouterAttributionHeaders,
91
84
  getOpenRouterBaseUrl,
92
85
  init_openrouter_base_url
93
86
  } from "./cli-a35hzdve.js";
@@ -178,474 +171,6 @@ function classifyAwsSdkError(text) {
178
171
  init_env_flag();
179
172
  init_openrouter_base_url();
180
173
  init_secret_scrubber();
181
-
182
- // src/providers/pi-mono-extension.ts
183
- init_openrouter_base_url();
184
- init_secret_scrubber();
185
- function apiHeaders(config) {
186
- return {
187
- "Content-Type": "application/json",
188
- ...config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {},
189
- "X-Agent-ID": config.agentId
190
- };
191
- }
192
- function fireAndForget(url, init) {
193
- fetch(url, init).catch(() => {});
194
- }
195
- async function isTaskCancelled(config) {
196
- try {
197
- const resp = await fetch(`${config.apiUrl}/cancelled-tasks?taskId=${encodeURIComponent(config.taskId)}`, { method: "GET", headers: apiHeaders(config) });
198
- if (!resp.ok)
199
- return { cancelled: false };
200
- const data = await resp.json();
201
- const match = data.cancelled?.find((t) => t.id === config.taskId);
202
- return match ? { cancelled: true, reason: match.failureReason } : { cancelled: false };
203
- } catch {
204
- return { cancelled: false };
205
- }
206
- }
207
- async function checkShouldBlockPolling(config) {
208
- try {
209
- const resp = await fetch(`${config.apiUrl}/me`, {
210
- method: "GET",
211
- headers: apiHeaders(config)
212
- });
213
- if (!resp.ok)
214
- return false;
215
- const data = await resp.json();
216
- return data.shouldBlockPolling === true;
217
- } catch {
218
- return false;
219
- }
220
- }
221
- async function fetchTaskDetails(config) {
222
- try {
223
- const resp = await fetch(`${config.apiUrl}/api/tasks/${config.taskId}`, {
224
- method: "GET",
225
- headers: apiHeaders(config)
226
- });
227
- if (!resp.ok)
228
- return null;
229
- return await resp.json();
230
- } catch {
231
- return null;
232
- }
233
- }
234
- async function syncIdentityFilesToServer(config, changeSource = "session_sync") {
235
- const updates = {};
236
- const paths = {
237
- soulMd: "/workspace/SOUL.md",
238
- identityMd: "/workspace/IDENTITY.md",
239
- toolsMd: "/workspace/TOOLS.md"
240
- };
241
- for (const [key, path] of Object.entries(paths)) {
242
- try {
243
- const file = Bun.file(path);
244
- if (await file.exists()) {
245
- const content = await file.text();
246
- if (content.trim() && content.length <= 65536) {
247
- updates[key] = content;
248
- }
249
- }
250
- } catch {}
251
- }
252
- if (Object.keys(updates).length === 0)
253
- return;
254
- try {
255
- await fetch(`${config.apiUrl}/api/agents/${config.agentId}/profile`, {
256
- method: "PUT",
257
- headers: apiHeaders(config),
258
- body: JSON.stringify({ ...updates, changeSource })
259
- });
260
- } catch {}
261
- }
262
- async function syncSetupScriptToServer(config, changeSource = "session_sync") {
263
- try {
264
- const file = Bun.file("/workspace/start-up.sh");
265
- if (!await file.exists())
266
- return;
267
- const raw = await file.text();
268
- if (!raw.trim())
269
- return;
270
- const markerStart = "# === Agent-managed setup (from DB) ===";
271
- const markerEnd = "# === End agent-managed setup ===";
272
- const startIdx = raw.indexOf(markerStart);
273
- const endIdx = raw.indexOf(markerEnd);
274
- let content;
275
- if (startIdx !== -1 && endIdx !== -1) {
276
- content = raw.substring(startIdx + markerStart.length, endIdx).trim();
277
- } else {
278
- content = raw.replace(/^#!\/bin\/bash\n/, "").trim();
279
- }
280
- if (!content || content.length > 65536)
281
- return;
282
- await fetch(`${config.apiUrl}/api/agents/${config.agentId}/profile`, {
283
- method: "PUT",
284
- headers: apiHeaders(config),
285
- body: JSON.stringify({ setupScript: content, changeSource })
286
- });
287
- } catch {}
288
- }
289
- async function autoIndexMemoryFile(config, editedPath) {
290
- try {
291
- const fileContent = await Bun.file(editedPath).text();
292
- const isShared = editedPath.startsWith("/workspace/shared/");
293
- const fileName = editedPath.split("/").pop() ?? "unnamed";
294
- await fetch(`${config.apiUrl}/api/memory/index`, {
295
- method: "POST",
296
- headers: apiHeaders(config),
297
- body: JSON.stringify({
298
- agentId: config.agentId,
299
- content: fileContent,
300
- name: fileName.replace(/\.\w+$/, ""),
301
- scope: isShared ? "swarm" : "agent",
302
- source: "file_index",
303
- sourcePath: editedPath
304
- })
305
- });
306
- } catch {}
307
- }
308
- async function fetchConcurrentContext(config) {
309
- try {
310
- const resp = await fetch(`${config.apiUrl}/api/concurrent-context`, {
311
- method: "GET",
312
- headers: apiHeaders(config)
313
- });
314
- if (!resp.ok)
315
- return null;
316
- const data = await resp.json();
317
- const lines = [];
318
- if (data.processingInboxMessages.length > 0) {
319
- lines.push("=== CONCURRENT SESSION AWARENESS ===");
320
- lines.push("");
321
- lines.push("**Other sessions are currently processing these inbox messages:**");
322
- for (const msg of data.processingInboxMessages) {
323
- const preview = msg.content.length > 120 ? `${msg.content.slice(0, 120)}...` : msg.content;
324
- lines.push(`- [${msg.source}] "${preview}" (received ${msg.createdAt})`);
325
- }
326
- }
327
- if (data.recentTaskDelegations.length > 0) {
328
- if (lines.length === 0)
329
- lines.push("=== CONCURRENT SESSION AWARENESS ===");
330
- lines.push("");
331
- lines.push("**Recent task delegations (last 5 min):**");
332
- for (const task of data.recentTaskDelegations) {
333
- const preview = task.task.length > 120 ? `${task.task.slice(0, 120)}...` : task.task;
334
- lines.push(`- "${preview}" → ${task.agentName ?? "unassigned"} [${task.status}]`);
335
- }
336
- }
337
- if (data.activeSwarmTasks.length > 0) {
338
- if (lines.length === 0)
339
- lines.push("=== CONCURRENT SESSION AWARENESS ===");
340
- lines.push("");
341
- lines.push("**Currently active tasks across the swarm:**");
342
- for (const task of data.activeSwarmTasks) {
343
- const preview = task.task.length > 100 ? `${task.task.slice(0, 100)}...` : task.task;
344
- lines.push(`- ${task.agentName ?? "unassigned"}: "${preview}" [${task.status}]`);
345
- }
346
- }
347
- if (lines.length > 0) {
348
- lines.push("");
349
- lines.push("IMPORTANT: Avoid duplicating work that is already being handled by other sessions or agents.");
350
- lines.push("=== END CONCURRENT SESSION AWARENESS ===");
351
- return lines.join(`
352
- `);
353
- }
354
- return null;
355
- } catch {
356
- return null;
357
- }
358
- }
359
- async function summarizeSessionForPi(config, sessionFile, deps = {}) {
360
- if (!sessionFile) {
361
- console.warn("session_summary skipped (pi): session transcript file unavailable");
362
- return;
363
- }
364
- const _runSummarize = deps.runSummarize ?? summarizeSession;
365
- const _fetchRetrievals = deps.fetchRetrievalsForTask ?? fetchRetrievalsForTask;
366
- const _postRatings = deps.postRatings ?? postRatings;
367
- const _buildRatings = deps.buildRatingsFromLlm ?? buildRatingsFromLlm;
368
- try {
369
- let transcript = "";
370
- try {
371
- const fullTranscript = await Bun.file(sessionFile).text();
372
- transcript = fullTranscript.length > 20000 ? fullTranscript.slice(-20000) : fullTranscript;
373
- } catch (err) {
374
- console.warn(scrubSecrets(`session_summary skipped (pi): cannot read ${sessionFile}: ${String(err)}`));
375
- return;
376
- }
377
- if (transcript.length <= 100) {
378
- console.warn(`session_summary skipped (pi): transcript too short (${transcript.length} chars)`);
379
- return;
380
- }
381
- const sourceTaskId = config.taskId;
382
- const agentId = config.agentId;
383
- if (!sourceTaskId || !agentId) {
384
- console.warn(`session_summary skipped (pi): ${!sourceTaskId ? "task id unavailable" : "agent id unavailable"}`);
385
- return;
386
- }
387
- const taskDetails = await fetchTaskDetails(config).catch(() => null);
388
- const wantRatings = getMemoryRaterNames().includes("llm");
389
- const retrievals = wantRatings ? await _fetchRetrievals({
390
- apiUrl: config.apiUrl,
391
- apiKey: config.apiKey,
392
- agentId,
393
- taskId: sourceTaskId
394
- }).catch(() => []) : [];
395
- const result = await _runSummarize({
396
- harness: "pi",
397
- transcript,
398
- retrievals,
399
- taskContext: {
400
- sourceTaskId,
401
- agentId,
402
- prompt: taskDetails?.task
403
- },
404
- apiUrl: config.apiUrl,
405
- apiKey: config.apiKey,
406
- env: config.env
407
- });
408
- if (!result) {
409
- console.warn("session_summary skipped (pi): summarizer returned no result");
410
- return;
411
- }
412
- const summary = result.summary.trim();
413
- if (summary.length <= 20 || summary.toLowerCase().includes("no significant learnings")) {
414
- console.debug(`session_summary skipped (pi): summary failed quality gate (${summary.length} chars)`);
415
- return;
416
- }
417
- const indexResp = await fetch(`${config.apiUrl}/api/memory/index`, {
418
- method: "POST",
419
- headers: apiHeaders(config),
420
- body: JSON.stringify({
421
- scope: "agent",
422
- source: "session_summary",
423
- sourceTaskId,
424
- content: summary,
425
- name: "session-summary",
426
- agentId
427
- })
428
- });
429
- if (!indexResp.ok) {
430
- const text = await indexResp.text().catch(() => "");
431
- console.error("session_summary: /api/memory/index POST failed (pi):", indexResp.status, text);
432
- return;
433
- }
434
- if (wantRatings && result.ratings && result.ratings.length > 0) {
435
- const ratingEvents = _buildRatings(result.ratings, retrievals, result.model);
436
- if (ratingEvents.length > 0) {
437
- await _postRatings({
438
- apiUrl: config.apiUrl,
439
- apiKey: config.apiKey,
440
- agentId,
441
- taskId: sourceTaskId,
442
- events: ratingEvents
443
- }).catch((err) => console.error("session_summary: postRatings failed (pi):", err));
444
- }
445
- }
446
- } catch (err) {
447
- console.error("session_summary failed (pi):", err);
448
- }
449
- }
450
- var SWARM_NUDGE_CUSTOM_TYPE = "swarm-nudge";
451
- function sendNudge(pi, text) {
452
- pi.sendMessage({
453
- customType: SWARM_NUDGE_CUSTOM_TYPE,
454
- content: [{ type: "text", text }],
455
- display: false
456
- });
457
- }
458
- function createSwarmHooksExtension(config) {
459
- return (pi) => {
460
- let lastContextPostTime = 0;
461
- pi.on("before_provider_headers", (event, ctx) => {
462
- Object.assign(event.headers, getOpenRouterAttributionHeaders(ctx.model?.baseUrl ?? "", config.env));
463
- });
464
- pi.on("session_start", async (_event, _ctx) => {
465
- for (const [name, server] of Object.entries(config.mcpServers ?? {})) {
466
- try {
467
- pi.registerMcpServer(name, server);
468
- } catch (err) {
469
- console.warn(`[pi] Failed to register MCP server "${name}": ${err}`);
470
- }
471
- }
472
- fireAndForget(`${config.apiUrl}/ping`, {
473
- method: "POST",
474
- headers: apiHeaders(config)
475
- });
476
- if (config.taskId) {
477
- await clearToolHistory(config.taskId);
478
- }
479
- if (config.isLead) {
480
- const ctx = await fetchConcurrentContext(config);
481
- if (ctx) {
482
- sendNudge(pi, ctx);
483
- }
484
- }
485
- });
486
- pi.on("tool_call", async (event, _ctx) => {
487
- if (!config.isLead && config.taskId) {
488
- const { cancelled, reason } = await isTaskCancelled(config);
489
- if (cancelled) {
490
- const cancelReason = reason || "Task cancelled by lead or creator";
491
- return {
492
- block: true,
493
- reason: `\uD83D\uDED1 TASK CANCELLED: Your current task (${config.taskId.slice(0, 8)}) has been cancelled. Reason: "${cancelReason}". ` + `Stop working on this task immediately. Do NOT continue making tool calls. ` + `Use store-progress to acknowledge the cancellation and mark the task as failed, then wait for new tasks.`
494
- };
495
- }
496
- }
497
- if (!config.isLead && config.taskId) {
498
- const toolName = event.toolName;
499
- const toolInput = "input" in event ? event.input : {};
500
- const loopResult = await checkToolLoop(config.taskId, toolName, toolInput);
501
- if (loopResult.blocked) {
502
- return {
503
- block: true,
504
- reason: `LOOP DETECTED: ${loopResult.reason} ` + "Stop repeating this action and try a fundamentally different approach. " + "If you're truly stuck, use store-progress to report the blocker."
505
- };
506
- }
507
- if (loopResult.severity === "warning" && loopResult.reason) {
508
- sendNudge(pi, `Warning: ${loopResult.reason}`);
509
- }
510
- }
511
- if (event.toolName?.endsWith("poll-task")) {
512
- const shouldBlock = await checkShouldBlockPolling(config);
513
- if (shouldBlock) {
514
- return {
515
- block: true,
516
- reason: "\uD83D\uDED1 POLLING LIMIT REACHED: You have exceeded the maximum empty poll attempts. " + "EXIT NOW - do not make any more tool calls."
517
- };
518
- }
519
- }
520
- return;
521
- });
522
- pi.on("tool_result", async (event, ctx) => {
523
- if (!config.isLead && config.taskId) {
524
- fireAndForget(`${config.apiUrl}/api/active-sessions/heartbeat/${config.taskId}`, {
525
- method: "PUT",
526
- headers: apiHeaders(config)
527
- });
528
- }
529
- fireAndForget(`${config.apiUrl}/api/agents/${config.agentId}/activity`, {
530
- method: "PUT",
531
- headers: apiHeaders(config)
532
- });
533
- const usage = ctx.getContextUsage?.();
534
- if (config.taskId && usage?.tokens != null) {
535
- const now = Date.now();
536
- if (now - lastContextPostTime >= 30000) {
537
- lastContextPostTime = now;
538
- fireAndForget(`${config.apiUrl}/api/tasks/${config.taskId}/context`, {
539
- method: "POST",
540
- headers: apiHeaders(config),
541
- body: JSON.stringify({
542
- eventType: "progress",
543
- sessionId: `pi-${config.taskId}`,
544
- contextUsedTokens: usage.tokens,
545
- contextTotalTokens: usage.contextWindow,
546
- contextPercent: usage.percent
547
- })
548
- });
549
- }
550
- }
551
- const toolName = event.toolName;
552
- const input = event.input;
553
- const editedPath = input?.file_path || input?.path;
554
- if ((toolName === "write" || toolName === "edit") && editedPath) {
555
- if (editedPath === "/workspace/SOUL.md" || editedPath === "/workspace/IDENTITY.md" || editedPath === "/workspace/TOOLS.md") {
556
- syncIdentityFilesToServer(config, "self_edit");
557
- }
558
- if (editedPath.startsWith("/workspace/start-up")) {
559
- syncSetupScriptToServer(config, "self_edit");
560
- }
561
- if (editedPath.startsWith("/workspace/personal/memory/") || editedPath.startsWith("/workspace/shared/memory/")) {
562
- autoIndexMemoryFile(config, editedPath);
563
- }
564
- }
565
- if (config.isLead && event.toolName?.endsWith("send-task")) {
566
- sendNudge(pi, "Task sent successfully. Monitor progress using the get-task-details tool periodically.");
567
- }
568
- return;
569
- });
570
- pi.on("session_compact", async () => {
571
- if (!config.taskId)
572
- return;
573
- const taskDetails = await fetchTaskDetails(config);
574
- if (taskDetails) {
575
- const reminder = [
576
- "=== GOAL REMINDER (injected before context compaction) ===",
577
- `Task ID: ${taskDetails.id}`,
578
- `Task: ${taskDetails.task}`
579
- ];
580
- if (taskDetails.progress) {
581
- reminder.push(`Current Progress: ${taskDetails.progress}`);
582
- }
583
- reminder.push("=== Continue working on this task after compaction ===");
584
- sendNudge(pi, reminder.join(`
585
- `));
586
- }
587
- });
588
- pi.on("context", async (_event, ctx) => {
589
- if (!config.taskId)
590
- return;
591
- const usage = ctx.getContextUsage?.();
592
- if (usage) {
593
- fireAndForget(`${config.apiUrl}/api/tasks/${config.taskId}/context`, {
594
- method: "POST",
595
- headers: apiHeaders(config),
596
- body: JSON.stringify({
597
- eventType: "compaction",
598
- sessionId: `pi-${config.taskId}`,
599
- contextUsedTokens: usage.tokens ?? undefined,
600
- contextTotalTokens: usage.contextWindow,
601
- contextPercent: usage.percent ?? undefined
602
- })
603
- });
604
- }
605
- return;
606
- });
607
- pi.on("input", async (_event, _ctx) => {
608
- if (!config.isLead && config.taskId) {
609
- const { cancelled, reason } = await isTaskCancelled(config);
610
- if (cancelled) {
611
- const cancelReason = reason || "Task cancelled by lead or creator";
612
- sendNudge(pi, `\uD83D\uDED1 TASK CANCELLED: ${cancelReason}. Stop working and use store-progress to acknowledge.`);
613
- return { action: "handled" };
614
- }
615
- }
616
- return;
617
- });
618
- pi.on("session_shutdown", async (_event, ctx) => {
619
- const usage = ctx.getContextUsage?.();
620
- if (config.taskId && usage) {
621
- await fetch(`${config.apiUrl}/api/tasks/${config.taskId}/context`, {
622
- method: "POST",
623
- headers: apiHeaders(config),
624
- body: JSON.stringify({
625
- eventType: "completion",
626
- sessionId: `pi-${config.taskId}`,
627
- contextTotalTokens: usage.contextWindow,
628
- contextPercent: usage.percent ?? undefined,
629
- contextUsedTokens: usage.tokens ?? undefined
630
- })
631
- }).catch(() => {});
632
- }
633
- await syncIdentityFilesToServer(config);
634
- await syncSetupScriptToServer(config);
635
- const sessionFile = ctx.sessionManager.getSessionFile?.();
636
- if (!process.env.SKIP_SESSION_SUMMARY) {
637
- await summarizeSessionForPi(config, sessionFile);
638
- } else {
639
- console.debug("session_summary skipped (pi): SKIP_SESSION_SUMMARY is set");
640
- }
641
- fireAndForget(`${config.apiUrl}/close`, {
642
- method: "POST",
643
- headers: apiHeaders(config)
644
- });
645
- });
646
- };
647
- }
648
- // src/providers/pi-mono-adapter.ts
649
174
  function modelToCredKeys(modelStr) {
650
175
  if (!modelStr)
651
176
  return null;
@@ -674,7 +199,7 @@ function getHarnessDrivableBedrockModels() {
674
199
  }
675
200
  }
676
201
  async function runBedrockSdkProbeAndEnumerate(region) {
677
- const { BedrockClient, ListFoundationModelsCommand, ListInferenceProfilesCommand } = await import("./index-kkeftv5h.js").then((m)=>__toESM(m.default,1));
202
+ const { BedrockClient, ListFoundationModelsCommand, ListInferenceProfilesCommand } = await import("./index-82rk11v7.js").then((m)=>__toESM(m.default,1));
678
203
  const client = new BedrockClient({ region });
679
204
  const invocable = new Set;
680
205
  const fmResponse = await client.send(new ListFoundationModelsCommand({ byInferenceType: "ON_DEMAND", byOutputModality: "TEXT" }));
@@ -7,26 +7,25 @@ import {
7
7
  requestModelCatalogRefresh,
8
8
  resetModelCatalogRefreshGuardForTests,
9
9
  startPricingRefreshLoop
10
- } from "./cli-srmej5tp.js";
11
- import"./cli-x207g4w1.js";
12
- import"./cli-0d2rqhvq.js";
10
+ } from "./cli-gp1rtyvk.js";
11
+ import"./cli-r8smj8b8.js";
12
+ import"./cli-tgpfnm6r.js";
13
13
  import"./cli-ywm1azg9.js";
14
14
  import"./cli-hsem16hb.js";
15
- import"./cli-rrbctenq.js";
15
+ import"./cli-nyhb1r6x.js";
16
16
  import"./cli-7mm2r1kp.js";
17
- import"./cli-e2prcx5m.js";
18
17
  import"./cli-dmtrxqhg.js";
19
- import"./cli-agamgm0p.js";
20
- import"./cli-5c2j5yvx.js";
21
- import"./cli-1a2j50m0.js";
18
+ import"./cli-mvzyxwg3.js";
22
19
  import"./cli-tadfgd0t.js";
20
+ import"./cli-fdvbjtbw.js";
23
21
  import"./cli-ywybs5as.js";
24
22
  import"./cli-f9w1semm.js";
23
+ import"./cli-1a2j50m0.js";
25
24
  import"./cli-a35hzdve.js";
26
25
  import"./cli-014vns2y.js";
27
26
  import"./cli-sd0mxa3c.js";
28
27
  import"./cli-w5e1d1vv.js";
29
- import"./cli-erbp6b4g.js";
28
+ import"./cli-esnpehf5.js";
30
29
  import"./cli-zf8jjwex.js";
31
30
  import"./cli-gd4favx9.js";
32
31
  import"./cli-ej6gbxfb.js";
@@ -6,24 +6,23 @@ import {
6
6
  getDb,
7
7
  getDbClient,
8
8
  init_db1 as init_db
9
- } from "./cli-0d2rqhvq.js";
9
+ } from "./cli-tgpfnm6r.js";
10
10
  import"./cli-ywm1azg9.js";
11
11
  import"./cli-hsem16hb.js";
12
- import"./cli-rrbctenq.js";
12
+ import"./cli-nyhb1r6x.js";
13
13
  import"./cli-7mm2r1kp.js";
14
- import"./cli-e2prcx5m.js";
15
14
  import"./cli-dmtrxqhg.js";
16
- import"./cli-agamgm0p.js";
17
- import"./cli-5c2j5yvx.js";
18
- import"./cli-1a2j50m0.js";
15
+ import"./cli-mvzyxwg3.js";
19
16
  import"./cli-tadfgd0t.js";
17
+ import"./cli-fdvbjtbw.js";
20
18
  import"./cli-ywybs5as.js";
21
19
  import"./cli-f9w1semm.js";
20
+ import"./cli-1a2j50m0.js";
22
21
  import"./cli-a35hzdve.js";
23
22
  import"./cli-014vns2y.js";
24
23
  import"./cli-sd0mxa3c.js";
25
24
  import"./cli-w5e1d1vv.js";
26
- import"./cli-erbp6b4g.js";
25
+ import"./cli-esnpehf5.js";
27
26
  import"./cli-zf8jjwex.js";
28
27
  import"./cli-gd4favx9.js";
29
28
  import {
@@ -8,26 +8,25 @@ import {
8
8
  init_rbac_roles,
9
9
  listUserRoles,
10
10
  runRbacCliCommand
11
- } from "./cli-4bm25xtw.js";
11
+ } from "./cli-qsztpfry.js";
12
12
  import"./cli-7pz3b7x5.js";
13
- import"./cli-0d2rqhvq.js";
13
+ import"./cli-tgpfnm6r.js";
14
14
  import"./cli-ywm1azg9.js";
15
15
  import"./cli-hsem16hb.js";
16
- import"./cli-rrbctenq.js";
16
+ import"./cli-nyhb1r6x.js";
17
17
  import"./cli-7mm2r1kp.js";
18
- import"./cli-e2prcx5m.js";
19
18
  import"./cli-dmtrxqhg.js";
20
- import"./cli-agamgm0p.js";
21
- import"./cli-5c2j5yvx.js";
22
- import"./cli-1a2j50m0.js";
19
+ import"./cli-mvzyxwg3.js";
23
20
  import"./cli-tadfgd0t.js";
21
+ import"./cli-fdvbjtbw.js";
24
22
  import"./cli-ywybs5as.js";
25
23
  import"./cli-f9w1semm.js";
24
+ import"./cli-1a2j50m0.js";
26
25
  import"./cli-a35hzdve.js";
27
26
  import"./cli-014vns2y.js";
28
27
  import"./cli-sd0mxa3c.js";
29
28
  import"./cli-w5e1d1vv.js";
30
- import"./cli-erbp6b4g.js";
29
+ import"./cli-esnpehf5.js";
31
30
  import"./cli-zf8jjwex.js";
32
31
  import"./cli-gd4favx9.js";
33
32
  import"./cli-ej6gbxfb.js";