@desplega.ai/agent-swarm 1.166.0 → 1.168.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 (221) hide show
  1. package/dist/acp-adapter-zhejfecx.js +34 -0
  2. package/dist/{actions-qz3m692w.js → actions-7jg840nr.js} +25 -25
  3. package/dist/{amp-adapter-j1xbmsqz.js → amp-adapter-ye6rnetm.js} +4 -4
  4. package/dist/{anthropic-messages-hst62ws9.js → anthropic-messages-13yn502s.js} +4 -4
  5. package/dist/{app-43vrdmv8.js → app-ffes2kyf.js} +10 -9
  6. package/dist/{assistant-ertffmka.js → assistant-fhm5smyz.js} +26 -26
  7. package/dist/{azure-openai-responses-mh8tvf78.js → azure-openai-responses-9st34pfz.js} +5 -5
  8. package/dist/{boot-reembed-998jtpdg.js → boot-reembed-20q3nzvg.js} +9 -8
  9. package/dist/{boot-reembed-s7k7c6v2.js → boot-reembed-jvfadhsk.js} +9 -8
  10. package/dist/{boot-scrub-sweep-nepsk4t1.js → boot-scrub-sweep-jtfajzve.js} +10 -9
  11. package/dist/{boot-seeds-vvzs1zhk.js → boot-seeds-9qt0j8j2.js} +12 -11
  12. package/dist/{claude-adapter-2zvmekrp.js → claude-adapter-a8znhthz.js} +24 -22
  13. package/dist/{claude-managed-adapter-s49wbk8t.js → claude-managed-adapter-tzwxy803.js} +4 -4
  14. package/dist/{claude-managed-setup-cvhqq8qn.js → claude-managed-setup-nrhfx5b0.js} +3 -3
  15. package/dist/{claude-sdk-session-kkbxtw5q.js → claude-sdk-session-7x7chdrs.js} +7608 -7596
  16. package/dist/{cli-zsh093hk.js → cli-014vns2y.js} +63 -1
  17. package/dist/{cli-8kgvmkak.js → cli-0jngabtb.js} +1 -1
  18. package/dist/{cli-qvfk83fy.js → cli-13xwcqvj.js} +2 -2
  19. package/dist/{cli-0nhdwxd5.js → cli-43jg9xdw.js} +3 -3
  20. package/dist/{cli-cpfmqz3n.js → cli-47zfzshm.js} +5 -5
  21. package/dist/{cli-zy7vwsne.js → cli-5qkcdv8c.js} +16 -9
  22. package/dist/{cli-cwxhbf43.js → cli-5t5my0h8.js} +85 -2
  23. package/dist/{cli-y59h2pk9.js → cli-69egj654.js} +1 -1
  24. package/dist/{cli-68r1j4sg.js → cli-6bpvv8h4.js} +3 -3
  25. package/dist/{cli-yshaazs1.js → cli-74ez9b66.js} +63 -20
  26. package/dist/{cli-32bca7nr.js → cli-7avy4v8w.js} +1 -1
  27. package/dist/{cli-f2n17zhp.js → cli-7mhy3ths.js} +21 -18
  28. package/dist/{cli-q38n4bq0.js → cli-95zs84qw.js} +3 -3
  29. package/dist/{cli-fn697bnt.js → cli-9q0bh411.js} +21 -8
  30. package/dist/{cli-rggdq8wq.js → cli-9q24yyvs.js} +3 -3
  31. package/dist/cli-a35hzdve.js +33 -0
  32. package/dist/{cli-3qn4r334.js → cli-aj1e0h0d.js} +20 -14
  33. package/dist/{cli-rsy933yz.js → cli-bcspch6h.js} +30 -19
  34. package/dist/{cli-x3x0qwky.js → cli-bxqez1p0.js} +51 -23
  35. package/dist/{cli-ng97fjq7.js → cli-cmxkbzzs.js} +33 -7
  36. package/dist/{cli-df56tqdw.js → cli-ee0402n1.js} +198 -70
  37. package/dist/{cli-mwegs4af.js → cli-ew0c3a1j.js} +3 -3
  38. package/dist/{cli-ysnyhws9.js → cli-ewhwpyrb.js} +54 -51
  39. package/dist/{cli-j2jbr8af.js → cli-fhj4y16f.js} +1 -1
  40. package/dist/{cli-8t229cmr.js → cli-fqq06kkb.js} +30 -17
  41. package/dist/{cli-jvj6a0cv.js → cli-g6gx2dn1.js} +54 -19
  42. package/dist/{cli-nexwh8zg.js → cli-g7k7zbcz.js} +12 -5
  43. package/dist/{cli-ecknp7p1.js → cli-j05x7pnb.js} +10 -10
  44. package/dist/{cli-gt8azyet.js → cli-jb931ba2.js} +1 -1
  45. package/dist/{cli-nvvfd8bq.js → cli-jbzbr36n.js} +4091 -3793
  46. package/dist/{cli-3ddybbbx.js → cli-jvmtxqtc.js} +26 -14
  47. package/dist/{cli-pkke6geq.js → cli-km4x66j0.js} +83 -65
  48. package/dist/{cli-b0f70z24.js → cli-mn8qkd8v.js} +1 -1
  49. package/dist/{cli-0qjcsxgz.js → cli-nctfv2yy.js} +99 -9
  50. package/dist/{cli-4r1sjfc4.js → cli-ng1pmdx6.js} +10 -10
  51. package/dist/cli-nkqjj42q.js +104 -0
  52. package/dist/{cli-aqcey741.js → cli-p5jqk8fr.js} +1 -1
  53. package/dist/{cli-66zh26sp.js → cli-pgehz8e1.js} +57 -17
  54. package/dist/cli-q1vnz8wv.js +96 -0
  55. package/dist/{cli-fj86xr3c.js → cli-qd97v6z2.js} +2 -2
  56. package/dist/{cli-p4ztb80h.js → cli-r7eeddkq.js} +13 -8
  57. package/dist/{cli-8ssjez7e.js → cli-rhy7z1rp.js} +22 -11
  58. package/dist/{cli-vzc73wet.js → cli-rr5z1j4p.js} +87 -69
  59. package/dist/{cli-4mevd1hf.js → cli-s9y81s7j.js} +5 -5
  60. package/dist/{cli-dw2q9f7g.js → cli-svah6b6w.js} +4 -4
  61. package/dist/{cli-h3x613ze.js → cli-tc5zec7v.js} +6 -6
  62. package/dist/{cli-ttbsse3f.js → cli-tmhsxhb8.js} +1 -1
  63. package/dist/{cli-feh3dkah.js → cli-v1w7pbd8.js} +2 -1
  64. package/dist/{cli-10zmp1p7.js → cli-vr5avem2.js} +27 -32
  65. package/dist/{cli-bzr0ftht.js → cli-wnb9b2g3.js} +19 -0
  66. package/dist/{cli-krqm5f11.js → cli-xezn9nkh.js} +16 -13
  67. package/dist/{cli-8kt0bmgx.js → cli-xf713zz0.js} +2 -2
  68. package/dist/{cli-6zcfw0x7.js → cli-y195hv1a.js} +1 -1
  69. package/dist/{cli-x7kpr72a.js → cli-ytmmyj7f.js} +2 -2
  70. package/dist/{cli-v2a8x45d.js → cli-z48ggfyq.js} +11 -6
  71. package/dist/{cli-qbksc292.js → cli-zy39d433.js} +2 -0
  72. package/dist/cli.js +28 -28
  73. package/dist/{cloudflare-workers-ai-system-one-tt484t61.js → cloudflare-workers-ai-system-one-sta45jf9.js} +7 -5
  74. package/dist/{codex-adapter-dw1wxqt8.js → codex-adapter-n63k33d3.js} +18 -18
  75. package/dist/{codex-login-terbdsqq.js → codex-login-g1cyt5zm.js} +1 -1
  76. package/dist/{codex-session-runner-3cgb8y1g.js → codex-session-runner-xkxfd81a.js} +18 -18
  77. package/dist/{commands-mhxam6z2.js → commands-q4mfhn51.js} +9 -8
  78. package/dist/{cursor-adapter-2qda3st7.js → cursor-adapter-v8mm6bp5.js} +5 -5
  79. package/dist/{db-sjks418k.js → db-1t0bj3pc.js} +9 -8
  80. package/dist/{dispatcher-1es759rn.js → dispatcher-k1fhavcf.js} +24 -24
  81. package/dist/{dsh-adapter-bek4cyw9.js → dsh-adapter-5423p70m.js} +5 -5
  82. package/dist/{easter-egg-3d-mtpnw06s.js → easter-egg-3d-66zxervv.js} +2 -2
  83. package/dist/{execute-s4ccjq3n.js → execute-h4jgevyw.js} +61 -11
  84. package/dist/{google-generative-ai-d6nphg3q.js → google-generative-ai-b8zxrpax.js} +5 -5
  85. package/dist/{google-vertex-cpshkref.js → google-vertex-nrdd697t.js} +5 -5
  86. package/dist/{grok-adapter-ar9cw9jg.js → grok-adapter-phrndeb8.js} +18 -8
  87. package/dist/{handlers-1gkbhktr.js → handlers-59ywqwzh.js} +27 -27
  88. package/dist/{hook-vxa3tcsy.js → hook-atj0swc2.js} +14 -14
  89. package/dist/{hook-ds2zxq9v.js → hook-mew1chq9.js} +42 -31
  90. package/dist/{http-3h21z9md.js → http-ef2fnn9v.js} +953 -98
  91. package/dist/{index-n99fycq7.js → index-48pb9erw.js} +24 -24
  92. package/dist/{index-bn6cy8ps.js → index-9fc2h7ww.js} +24 -24
  93. package/dist/{index-9b65j1m5.js → index-gr69c43q.js} +9 -8
  94. package/dist/{index-f8xnqrye.js → index-h26wjcfy.js} +43 -24
  95. package/dist/{index-dkfxpkmm.js → index-w2yhye23.js} +25 -25
  96. package/dist/{keepalive-3xspa9jw.js → keepalive-qhcqz56v.js} +11 -10
  97. package/dist/{lead-6qphc124.js → lead-hpk5r3b1.js} +47 -47
  98. package/dist/{llama-cpp-classify-tgj35k8d.js → llama-cpp-classify-6erb7wwv.js} +3 -1
  99. package/dist/{maintenance-0teem1bb.js → maintenance-nvkyp2xe.js} +9 -8
  100. package/dist/{mistral-conversations-8445ddjn.js → mistral-conversations-059y51zt.js} +4 -4
  101. package/dist/{node-9sg7ajby.js → node-qm9eb6z0.js} +1 -1
  102. package/dist/{oauth-refresh-sweep-sh9q25xp.js → oauth-refresh-sweep-ngskthwh.js} +10 -9
  103. package/dist/{onboard-54qmnqxe.js → onboard-yfnkqhxc.js} +2 -2
  104. package/dist/{openai-codex-responses-9ynm88zy.js → openai-codex-responses-jzxkta9b.js} +8 -7
  105. package/dist/{openai-completions-nhqwjmaw.js → openai-completions-663yncfq.js} +4 -4
  106. package/dist/openai-decisions-vj9nkpf8.js +162 -0
  107. package/dist/{openai-responses-xx1c4kgm.js → openai-responses-m3g43rrt.js} +5 -5
  108. package/dist/{opencode-adapter-wjfa2wvd.js → opencode-adapter-yjyqynzf.js} +7 -7
  109. package/dist/{openrouter-images-8yx3487g.js → openrouter-images-kr60n6b9.js} +1 -1
  110. package/dist/{otel-impl-ycqzp2a1.js → otel-impl-hhm64r6m.js} +1 -1
  111. package/dist/{pi-messages-vxdt8v7j.js → pi-messages-xszk613n.js} +1 -1
  112. package/dist/{pi-mono-adapter-e77e9zst.js → pi-mono-adapter-0eg8kw2c.js} +68 -51
  113. package/dist/{pricing-refresh-atnkngqs.js → pricing-refresh-35f91nx2.js} +11 -10
  114. package/dist/{rbac-roles-j78wdksm.js → rbac-roles-97w370qj.js} +10 -9
  115. package/dist/{rbac-roles-9pjphh9q.js → rbac-roles-z6sje3gy.js} +9 -8
  116. package/dist/{render-v2-pxjs49fx.js → render-v2-n4v66bj3.js} +10 -9
  117. package/dist/{runtime-v2t1r79e.js → runtime-h9ha1mq6.js} +4 -4
  118. package/dist/{setup-ymej0xtx.js → setup-m3hhyv5f.js} +2 -2
  119. package/dist/{typesafe-system-one-datfr82p.js → typesafe-system-one-e988vty7.js} +7 -5
  120. package/dist/{virtual-modules-wm8mxdxx.js → virtual-modules-ftr9kwe8.js} +11 -11
  121. package/dist/{work-objects-3nh4ymzb.js → work-objects-mxf2c842.js} +27 -27
  122. package/dist/{worker-qa9fkz5s.js → worker-9t07z1gq.js} +47 -47
  123. package/openapi.json +72 -1
  124. package/package.json +10 -10
  125. package/src/be/memory/providers/openai-embedding.ts +7 -2
  126. package/src/be/memory/raters/llm-summarizer.ts +7 -2
  127. package/src/be/modelsdev-cache.json +61 -0
  128. package/src/be/script-connections.ts +40 -6
  129. package/src/be/seed-pricing.ts +84 -53
  130. package/src/be/swarm-config-guard.ts +14 -0
  131. package/src/commands/provider-credentials.ts +28 -5
  132. package/src/commands/runner.ts +7 -12
  133. package/src/extensions/catalog.generated.json +17 -0
  134. package/src/heartbeat/heartbeat.ts +91 -19
  135. package/src/hooks/hook.ts +72 -27
  136. package/src/http/mcp.ts +5 -0
  137. package/src/http/onboarding.ts +2 -0
  138. package/src/http/script-connections.ts +35 -0
  139. package/src/providers/acp-targets.ts +10 -5
  140. package/src/providers/amp-adapter.ts +1 -1
  141. package/src/providers/claude-adapter.ts +32 -0
  142. package/src/providers/claude-background-keepalive.ts +100 -0
  143. package/src/providers/claude-sdk-session.ts +6 -0
  144. package/src/providers/codex-adapter.ts +30 -3
  145. package/src/providers/codex-oauth/auth-json.ts +21 -4
  146. package/src/providers/codex-oauth/types.ts +2 -0
  147. package/src/providers/dsh-adapter.ts +11 -2
  148. package/src/providers/grok-adapter.ts +18 -2
  149. package/src/providers/opencode-adapter.ts +21 -5
  150. package/src/providers/pi-mono-extension.ts +56 -25
  151. package/src/providers/pricing-sources.md +2 -0
  152. package/src/scheduler/scheduler.ts +82 -13
  153. package/src/scripts-runtime/executors/registry.ts +1 -1
  154. package/src/server.ts +63 -3
  155. package/src/tests/acp-adapter.test.ts +152 -12
  156. package/src/tests/ci-unit-test-report.test.ts +73 -0
  157. package/src/tests/claude-background-keepalive-wiring.test.ts +220 -0
  158. package/src/tests/claude-background-keepalive.fixture.ts +162 -0
  159. package/src/tests/claude-background-keepalive.test.ts +139 -0
  160. package/src/tests/claude-default-route.test.ts +75 -0
  161. package/src/tests/claude-hook-output.test.ts +233 -0
  162. package/src/tests/codex-adapter-pool-auth-revalidate.test.ts +4 -2
  163. package/src/tests/codex-adapter.test.ts +166 -26
  164. package/src/tests/codex-oauth-auth-timestamps.test.ts +76 -0
  165. package/src/tests/codex-oauth.test.ts +4 -1
  166. package/src/tests/connection-embedded-auth.test.ts +51 -0
  167. package/src/tests/context-window.test.ts +2 -2
  168. package/src/tests/credential-check.test.ts +51 -1
  169. package/src/tests/docs-index-footprint.test.js +3 -3
  170. package/src/tests/dsh-adapter.test.ts +24 -2
  171. package/src/tests/enabled-tools.test.ts +269 -0
  172. package/src/tests/entrypoint-codex-oauth-seed.test.ts +12 -0
  173. package/src/tests/extensions-catalog.test.ts +1 -0
  174. package/src/tests/extensions-example-slack-reply-gate.test.ts +756 -0
  175. package/src/tests/grok-adapter.test.ts +13 -0
  176. package/src/tests/haiku-5-5-pricing.test.ts +38 -0
  177. package/src/tests/heartbeat-checklist.test.ts +158 -1
  178. package/src/tests/onboarding.test.ts +44 -0
  179. package/src/tests/opencode-adapter.test.ts +66 -3
  180. package/src/tests/opencode-plugin.test.ts +37 -0
  181. package/src/tests/openrouter-attribution-call-sites.test.ts +204 -0
  182. package/src/tests/openrouter-base-url.test.ts +30 -39
  183. package/src/tests/pi-mono-extension.test.ts +161 -2
  184. package/src/tests/pricing-refresh.test.ts +70 -1
  185. package/src/tests/reasoning-effort.test.ts +3 -1
  186. package/src/tests/schedule-target-type.test.ts +136 -0
  187. package/src/tests/script-connections-http.test.ts +45 -0
  188. package/src/tests/script-connections-mcp.test.ts +41 -0
  189. package/src/tests/script-executor-registry.test.ts +18 -0
  190. package/src/tests/send-task-self-send.test.ts +107 -0
  191. package/src/tests/telemetry-trigger.test.ts +12 -1
  192. package/src/tests/workflow-llm.test.ts +14 -0
  193. package/src/tests/workflow-system-one-decision-providers.test.ts +33 -0
  194. package/src/tools/request-human-input.ts +7 -2
  195. package/src/tools/script-connections/tool.ts +35 -3
  196. package/src/tools/send-task.ts +9 -1
  197. package/src/utils/enabled-tools.ts +27 -0
  198. package/src/utils/internal-ai/complete-structured.ts +11 -3
  199. package/src/utils/openrouter-base-url.ts +23 -0
  200. package/src/workflows/executors/raw-llm.ts +1 -0
  201. package/src/workflows/executors/system-one-decision.ts +2 -0
  202. package/src/workflows/executors/validate.ts +1 -0
  203. package/src/workflows/executors/workflow-llm.ts +9 -2
  204. package/templates/extensions/README.md +1 -0
  205. package/templates/extensions/slack-reply-gate/README.md +98 -0
  206. package/templates/extensions/slack-reply-gate/hooks.ts +582 -0
  207. package/templates/extensions/slack-reply-gate/manifest.json +8 -0
  208. package/templates/skills/agent-browser/SKILL.md +2 -0
  209. package/templates/skills/agent-browser/content.md +2 -0
  210. package/templates/skills/code-quality/content.md +1 -0
  211. package/templates/skills/heartbeat-runbook/content.md +1 -1
  212. package/templates/skills/swarm-scripts/SKILL.md +10 -0
  213. package/templates/skills/swarm-scripts/content.md +10 -0
  214. package/templates/skills/work-on-task/SKILL.md +4 -0
  215. package/templates/skills/work-on-task/content.md +4 -0
  216. package/templates/skills/workflow-iterate/content.md +9 -0
  217. package/dist/acp-adapter-yzfxn8vj.js +0 -23
  218. package/dist/cli-3dpj7atn.js +0 -11
  219. package/dist/cli-gvcgmx69.js +0 -183
  220. package/dist/{cli-jhm6hzjn.js → cli-mxvnnv5q.js} +7 -7
  221. package/dist/{codex-hook-d2rkvf39.js → codex-hook-15dgc4cb.js} +1 -1
@@ -13,4 +13,8 @@ When the task names a skill (`researching`, `planning`, `implementing`), use it.
13
13
 
14
14
  Finish the task with one of the four endings in your operating contract: `completed`, `defer-task`, `request-human-input`, or `failed`. Then stop.
15
15
 
16
+ Resuming (a resume task, or work cut by a graceful shutdown): read the parent's last progress line, then re-read live state once (PR state and head SHA, branch, `git status`) before new work. Re-run controls only if the head moved. Never redo a pushed commit or open a second PR for the same branch. Store a progress line with branch, PR number and head SHA each time you push.
17
+
18
+ Write times in replies, outputs and defer notes in the requester's timezone when the Requester Profile names one, never raw UTC.
19
+
16
20
  If the user interrupts, follow their instructions. To resume, call `/work-on-task <taskId>` again.
@@ -8,4 +8,8 @@ When the task names a skill (`researching`, `planning`, `implementing`), use it.
8
8
 
9
9
  Finish the task with one of the four endings in your operating contract: `completed`, `defer-task`, `request-human-input`, or `failed`. Then stop.
10
10
 
11
+ Resuming (a resume task, or work cut by a graceful shutdown): read the parent's last progress line, then re-read live state once (PR state and head SHA, branch, `git status`) before new work. Re-run controls only if the head moved. Never redo a pushed commit or open a second PR for the same branch. Store a progress line with branch, PR number and head SHA each time you push.
12
+
13
+ Write times in replies, outputs and defer notes in the requester's timezone when the Requester Profile names one, never raw UTC.
14
+
11
15
  If the user interrupts, follow their instructions. To resume, call `/work-on-task <taskId>` again.
@@ -173,6 +173,15 @@ Afterwards, a `warnings` entry on `create-workflow` or a patch tool means the ke
173
173
  - Do not set `retry` or `validation.retry` on a `system-one-decision` node. It retries connection errors, 408, 429, and 5xx itself (`config.maxRetries`, 0 to 3, default 2) inside `config.timeoutMs` (default 30000). A 401, a 422, or an answer that fails validation ends after one attempt.
174
174
  - The node reads its provider's key (`TYPESAFE_API_KEY`, `OPENROUTER_API_KEY`, `LAYA_API_KEY`, `OPENAI_DECISIONS_API_KEY`, or `CLOUDFLARE_API_TOKEN`, plus `LAYA_URL` for `laya` and `CLOUDFLARE_ACCOUNT_ID` for `cloudflare`) server-side. The key never appears in the definition, the step output, or an error. A run whose key or `LAYA_URL` is missing fails before any node executes, and a 401 or 403 fails the step as `<KEY> was rejected`. An unresolved `{{token}}` fails the step before any request.
175
175
 
176
+ ### `human-in-the-loop` (how approvals render)
177
+
178
+ The same rules apply to a standalone `request-human-input` call.
179
+
180
+ - **Dashboard card.** `title` is plain text. Each question's `label` is its heading and renders as markdown. `description` renders as full markdown and is the only field that shows images, so put drafts, diffs, and logs there.
181
+ - **Code.** Fence code, logs, and JSON with a language (```` ```json ````): the block keeps its lines and scrolls. Fence a prose draft with no language: it wraps. A single newline outside a fence becomes a paragraph break.
182
+ - **Images.** Put an `http(s)` URL ending in `.png`, `.jpg`, `.jpeg`, `.gif`, or `.webp` alone on its own line in `description`, or use `![alt](url)`. The link must outlive the request: an expired presigned URL shows an "image unavailable" note.
183
+ - **Slack.** A node's `notifications` post the title, the question labels (each collapsed to one line, capped at 3000 characters in total), a Review button, and the timeout. Descriptions, options, code, and images are not shown, so the title and labels must make sense alone. `request-human-input` posts nothing to Slack: share the returned URL yourself.
184
+
176
185
  ### `swarm-script`
177
186
 
178
187
  ```json
@@ -1,23 +0,0 @@
1
- import {
2
- ACPAdapter,
3
- applyConfiguredOptions,
4
- sanitizeAcpConfigOptions,
5
- toAcpMcpServers
6
- } from "./cli-3qn4r334.js";
7
- import"./cli-32bca7nr.js";
8
- import"./cli-tng3131n.js";
9
- import"./cli-zp67qg5x.js";
10
- import"./cli-ttbsse3f.js";
11
- import"./cli-dpvkp2et.js";
12
- import"./cli-zt3w1cn1.js";
13
- import"./cli-zsh093hk.js";
14
- import"./cli-w5e1d1vv.js";
15
- import"./cli-4r1sjfc4.js";
16
- import"./cli-wt7ccy4r.js";
17
- import"./cli-bc05qbss.js";
18
- export {
19
- ACPAdapter,
20
- applyConfiguredOptions,
21
- sanitizeAcpConfigOptions,
22
- toAcpMcpServers
23
- };
@@ -1,11 +0,0 @@
1
- // src/utils/openrouter-base-url.ts
2
- var DEFAULT_OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
3
- function getOpenRouterBaseUrl(env = process.env) {
4
- const raw = env.OPENROUTER_BASE_URL;
5
- if (typeof raw === "string" && raw.trim().length > 0) {
6
- return raw.trim().replace(/\/+$/, "");
7
- }
8
- return DEFAULT_OPENROUTER_BASE_URL;
9
- }
10
-
11
- export { DEFAULT_OPENROUTER_BASE_URL, getOpenRouterBaseUrl };
@@ -1,183 +0,0 @@
1
- import {
2
- retryProviderRequest
3
- } from "./cli-qbksc292.js";
4
- import {
5
- formatProviderError,
6
- normalizeProviderError
7
- } from "./cli-6map995v.js";
8
- import {
9
- headersToRecord,
10
- providerHeadersToRecord
11
- } from "./cli-7kyk9jr3.js";
12
- import {
13
- calculateCost
14
- } from "./cli-nexwh8zg.js";
15
-
16
- // node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js
17
- function httpError(label, response, body) {
18
- const error = new Error(`${label} returned ${response.status}`);
19
- error.status = response.status;
20
- error.headers = response.headers;
21
- error.body = body;
22
- return error;
23
- }
24
- function timeoutError(timeoutMs) {
25
- const error = new Error(`Request timed out after ${timeoutMs}ms`);
26
- error.name = "TimeoutError";
27
- error.status = undefined;
28
- error.headers = undefined;
29
- error.body = "";
30
- return error;
31
- }
32
- function isRecord(value) {
33
- return typeof value === "object" && value !== null && !Array.isArray(value);
34
- }
35
- function requiredNumber(label, value, field) {
36
- if (typeof value !== "number" || !Number.isFinite(value)) {
37
- throw new Error(`${label} returned an invalid ${field}`);
38
- }
39
- return value;
40
- }
41
- function probabilities(label, value, id) {
42
- if (!isRecord(value))
43
- throw new Error(`${label} returned invalid probabilities for ${id}`);
44
- return Object.fromEntries(Object.entries(value).map(([key, probability]) => [
45
- key,
46
- requiredNumber(label, probability, `probability for ${id}.${key}`)
47
- ]));
48
- }
49
- function parseAnswers(label, value, context) {
50
- if (!isRecord(value))
51
- throw new Error(`${label} returned an unexpected response`);
52
- const answers = [];
53
- for (const [id, question] of Object.entries(context.questions)) {
54
- const answer = value[id];
55
- if (!isRecord(answer))
56
- throw new Error(`${label} did not return an answer for ${id}`);
57
- if (question.type === "choice") {
58
- if (answer.type !== "choice" || typeof answer.choice !== "string") {
59
- throw new Error(`${label} did not return a choice answer for ${id}`);
60
- }
61
- answers.push([
62
- id,
63
- {
64
- type: "choice",
65
- choice: answer.choice,
66
- probabilities: probabilities(label, answer.probabilities, id),
67
- confidence: requiredNumber(label, answer.confidence, `confidence for ${id}`)
68
- }
69
- ]);
70
- } else if (question.type === "score") {
71
- if (answer.type !== "score")
72
- throw new Error(`${label} did not return a score answer for ${id}`);
73
- answers.push([
74
- id,
75
- {
76
- type: "score",
77
- score: requiredNumber(label, answer.score, `score for ${id}`),
78
- confidence: requiredNumber(label, answer.confidence, `confidence for ${id}`)
79
- }
80
- ]);
81
- } else {
82
- if (answer.type !== "noul")
83
- throw new Error(`${label} did not return a bool answer for ${id}`);
84
- answers.push([
85
- id,
86
- {
87
- type: "bool",
88
- probability: requiredNumber(label, answer.noul, `probability for ${id}`)
89
- }
90
- ]);
91
- }
92
- }
93
- return Object.fromEntries(answers);
94
- }
95
- function tokenCount(value) {
96
- return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
97
- }
98
- function parseUsage(value, model) {
99
- if (!isRecord(value) || value.input_tokens === undefined && value.output_tokens === undefined)
100
- return;
101
- const input = tokenCount(value.input_tokens);
102
- const output = tokenCount(value.output_tokens);
103
- const usage = {
104
- input,
105
- output,
106
- cacheRead: 0,
107
- cacheWrite: 0,
108
- totalTokens: input + output,
109
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
110
- };
111
- calculateCost(model, usage);
112
- return usage;
113
- }
114
- function wireRequest(context) {
115
- return {
116
- state: context.state,
117
- questions: Object.fromEntries(Object.entries(context.questions).map(([id, question]) => [
118
- id,
119
- question.type === "bool" ? { ...question, type: "noul" } : question
120
- ]))
121
- };
122
- }
123
- function requestHeaders(model, apiKey, optionsHeaders) {
124
- return providerHeadersToRecord({ authorization: `Bearer ${apiKey}`, "content-type": "application/json" }, model.headers, optionsHeaders) ?? {};
125
- }
126
- async function classifySystemOne(transport, model, context, options) {
127
- const output = {
128
- api: model.api,
129
- provider: model.provider,
130
- model: model.id,
131
- answers: {},
132
- stopReason: "stop",
133
- timestamp: Date.now()
134
- };
135
- try {
136
- if (model.api !== transport.api)
137
- throw new Error(`Unsupported classifier API: ${model.api}`);
138
- if (!options?.apiKey)
139
- throw new Error(`No API key for provider: ${model.provider}`);
140
- const apiKey = options.apiKey;
141
- let payload = transport.payload(model, wireRequest(context));
142
- const transformed = await options.onPayload?.(payload, model);
143
- if (transformed !== undefined)
144
- payload = transformed;
145
- const requestFetch = options.fetch ?? globalThis.fetch;
146
- const { response, body } = await retryProviderRequest(async () => {
147
- const timeoutSignal = options.timeoutMs !== undefined ? AbortSignal.timeout(options.timeoutMs) : undefined;
148
- const signal = options.signal && timeoutSignal ? AbortSignal.any([options.signal, timeoutSignal]) : options.signal ?? timeoutSignal;
149
- try {
150
- const next = await requestFetch(transport.url(model), {
151
- method: "POST",
152
- headers: requestHeaders(model, apiKey, options.headers),
153
- body: JSON.stringify(payload),
154
- signal
155
- });
156
- if (!next.ok)
157
- throw httpError(transport.label, next, await next.text());
158
- return { response: next, body: await next.json() };
159
- } catch (error) {
160
- if (timeoutSignal?.aborted && !options.signal?.aborted)
161
- throw timeoutError(options.timeoutMs);
162
- throw error;
163
- }
164
- }, {
165
- maxRetries: options.maxRetries ?? 2,
166
- maxRetryDelayMs: options.maxRetryDelayMs,
167
- signal: options.signal
168
- });
169
- await options.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
170
- const result = transport.output(body);
171
- const usage = parseUsage(result.usage, model);
172
- if (usage)
173
- output.usage = usage;
174
- output.answers = parseAnswers(transport.label, result.answers, context);
175
- return output;
176
- } catch (error) {
177
- output.stopReason = options?.signal?.aborted ? "aborted" : "error";
178
- output.errorMessage = formatProviderError(normalizeProviderError(error), `${transport.label} error`);
179
- return output;
180
- }
181
- }
182
-
183
- export { isRecord, classifySystemOne };
@@ -9,13 +9,6 @@ import {
9
9
  getSlackConfiguration,
10
10
  init_config
11
11
  } from "./cli-dmtrxqhg.js";
12
- import {
13
- MAX_PROFILE_FILE_LENGTH,
14
- buildAgentFsLiveUrl,
15
- buildCombFileUrl,
16
- getAppUrl,
17
- init_constants
18
- } from "./cli-gd4favx9.js";
19
12
  import {
20
13
  init_templates
21
14
  } from "./cli-agamgm0p.js";
@@ -23,6 +16,13 @@ import {
23
16
  init_resolver,
24
17
  resolveTemplateAsync
25
18
  } from "./cli-5c2j5yvx.js";
19
+ import {
20
+ MAX_PROFILE_FILE_LENGTH,
21
+ buildAgentFsLiveUrl,
22
+ buildCombFileUrl,
23
+ getAppUrl,
24
+ init_constants
25
+ } from "./cli-gd4favx9.js";
26
26
  import {
27
27
  init_secret_scrubber,
28
28
  scrubSecrets
@@ -13,11 +13,11 @@ import {
13
13
  isSteeringEnabled
14
14
  } from "./cli-7mm2r1kp.js";
15
15
  import"./cli-g5erf0zt.js";
16
+ import"./cli-5c2j5yvx.js";
16
17
  import {
17
18
  getMcpBaseUrl,
18
19
  init_constants
19
20
  } from "./cli-gd4favx9.js";
20
- import"./cli-5c2j5yvx.js";
21
21
  import"./cli-ej6gbxfb.js";
22
22
  import"./cli-bc05qbss.js";
23
23