@desplega.ai/agent-swarm 1.165.0 → 1.167.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.
- package/dist/acp-adapter-zpvy6321.js +34 -0
- package/dist/{actions-jna0b3wm.js → actions-fq2zrwtf.js} +30 -34
- package/dist/{amp-adapter-0eve81pz.js → amp-adapter-5gbk7501.js} +7 -7
- package/dist/{anthropic-messages-hst62ws9.js → anthropic-messages-13yn502s.js} +4 -4
- package/dist/{app-75hm5cfa.js → app-nctetn1e.js} +11 -11
- package/dist/{assistant-yzd51j33.js → assistant-0aq8gjvj.js} +31 -35
- package/dist/{azure-openai-responses-mh8tvf78.js → azure-openai-responses-9st34pfz.js} +5 -5
- package/dist/{boot-reembed-z158xq32.js → boot-reembed-1ze5853n.js} +14 -16
- package/dist/{boot-reembed-2ex2mcsh.js → boot-reembed-fmp5ww69.js} +15 -16
- package/dist/boot-scrub-sweep-cbp8xd4e.js +212 -0
- package/dist/{boot-seeds-2bmnh18p.js → boot-seeds-22tx8a53.js} +13 -12
- package/dist/{claude-adapter-jbj1mycz.js → claude-adapter-0jhgeh1d.js} +25 -25
- package/dist/{claude-managed-adapter-17ggz09t.js → claude-managed-adapter-tzwxy803.js} +5 -5
- package/dist/{claude-managed-setup-ptm1nzm2.js → claude-managed-setup-nrhfx5b0.js} +5 -5
- package/dist/{claude-sdk-session-9re1g7r2.js → claude-sdk-session-wh77rh83.js} +2632 -2614
- package/dist/{cli-zsh093hk.js → cli-014vns2y.js} +63 -1
- package/dist/{cli-qvfk83fy.js → cli-13xwcqvj.js} +2 -2
- package/dist/{cli-8gpbwy09.js → cli-1yrcfa5s.js} +5 -5
- package/dist/{cli-xtgtyafv.js → cli-577bxkf6.js} +212 -451
- package/dist/{cli-ma3zvh39.js → cli-5qkcdv8c.js} +6118 -5874
- package/dist/{cli-cwxhbf43.js → cli-5t5my0h8.js} +85 -2
- package/dist/{cli-zvckv750.js → cli-69egj654.js} +2 -2
- package/dist/{cli-9xb89xca.js → cli-6bpvv8h4.js} +9 -9
- package/dist/{cli-90v942q1.js → cli-6qxmjpem.js} +8 -8
- package/dist/{cli-9866bd07.js → cli-6vfz44sr.js} +1 -1
- package/dist/{cli-32bca7nr.js → cli-7avy4v8w.js} +1 -1
- package/dist/{cli-xb3c6aat.js → cli-7mhy3ths.js} +21 -18
- package/dist/{cli-q38n4bq0.js → cli-95zs84qw.js} +3 -3
- package/dist/cli-a35hzdve.js +33 -0
- package/dist/{cli-x3x0qwky.js → cli-bxqez1p0.js} +51 -23
- package/dist/{cli-prt9emct.js → cli-c2tpw9ck.js} +3 -3
- package/dist/{cli-0n4fasz0.js → cli-c8r99akr.js} +16 -16
- package/dist/{cli-5anb0ev3.js → cli-cexctgn5.js} +89 -26
- package/dist/{cli-bns5c8k9.js → cli-cf2vgn9d.js} +105 -91
- package/dist/{cli-ng97fjq7.js → cli-cmxkbzzs.js} +33 -7
- package/dist/{cli-nexwh8zg.js → cli-g7k7zbcz.js} +12 -5
- package/dist/{cli-mmzwwptd.js → cli-hf5s9pgf.js} +1 -1
- package/dist/{cli-nvvfd8bq.js → cli-jbzbr36n.js} +4091 -3793
- package/dist/{cli-zn2v3t8v.js → cli-jvmtxqtc.js} +27 -15
- package/dist/{cli-pkke6geq.js → cli-km4x66j0.js} +83 -65
- package/dist/cli-kw0jcfje.js +516 -0
- package/dist/{cli-28smfvbn.js → cli-m7vmeepg.js} +32 -19
- package/dist/{cli-hpryr6em.js → cli-mb75wpxf.js} +1 -1
- package/dist/{cli-qdv8kgz7.js → cli-mkdsy1nq.js} +14018 -3333
- package/dist/{cli-b0f70z24.js → cli-mn8qkd8v.js} +1 -1
- package/dist/{cli-420bdgw0.js → cli-mv2520nm.js} +1 -1
- package/dist/{cli-n9ehc28t.js → cli-mxry91sa.js} +31 -10
- package/dist/{cli-wfajtmf7.js → cli-mxvnnv5q.js} +596 -13
- package/dist/cli-nkqjj42q.js +104 -0
- package/dist/{cli-e7t4snpa.js → cli-p8rt8spp.js} +5 -5
- package/dist/{cli-gh5yqzpe.js → cli-pkj1w46r.js} +12 -7
- package/dist/cli-q1vnz8wv.js +96 -0
- package/dist/{cli-fj86xr3c.js → cli-qd97v6z2.js} +2 -2
- package/dist/{cli-ba66wyhy.js → cli-qzmzwegq.js} +60 -20
- package/dist/{cli-5b2fjjzh.js → cli-r7eeddkq.js} +14 -9
- package/dist/{cli-8ssjez7e.js → cli-rhy7z1rp.js} +22 -11
- package/dist/{cli-4mevd1hf.js → cli-s9y81s7j.js} +5 -5
- package/dist/{cli-59jn5twa.js → cli-tc5zec7v.js} +7 -7
- package/dist/{cli-ttbsse3f.js → cli-tmhsxhb8.js} +1 -1
- package/dist/{cli-k6xx3pve.js → cli-tx2zvn23.js} +4 -4
- package/dist/{cli-pjxnr1jn.js → cli-ty4bzkqr.js} +5 -5
- package/dist/{cli-nfygw434.js → cli-v1pwxreq.js} +55 -52
- package/dist/{cli-ftry7975.js → cli-v1w7pbd8.js} +3 -2
- package/dist/{cli-10zmp1p7.js → cli-vr5avem2.js} +27 -32
- package/dist/{cli-bzr0ftht.js → cli-wnb9b2g3.js} +19 -0
- package/dist/cli-wt7ccy4r.js +2654 -0
- package/dist/{cli-50eg13rj.js → cli-wydz3feg.js} +549 -321
- package/dist/{cli-krqm5f11.js → cli-xezn9nkh.js} +16 -13
- package/dist/{cli-8kt0bmgx.js → cli-xf713zz0.js} +2 -2
- package/dist/{cli-x7afk5wm.js → cli-xvc3q9br.js} +1 -1
- package/dist/{cli-9s3h836g.js → cli-xvdgasgy.js} +1 -1
- package/dist/{cli-j0pdrmwg.js → cli-y0kjpfm9.js} +3 -3
- package/dist/{cli-6zcfw0x7.js → cli-y195hv1a.js} +1 -1
- package/dist/{cli-amwhs8h2.js → cli-ykt8f7va.js} +22 -9
- package/dist/{cli-1kzfvd1z.js → cli-ymmc1zxg.js} +15 -11
- package/dist/{cli-xnzrzets.js → cli-ypgba1a8.js} +2 -2
- package/dist/{cli-bdv39kgj.js → cli-z1dqhc9y.js} +31 -20
- package/dist/{cli-fw6vdcq5.js → cli-zp67qg5x.js} +34 -1
- package/dist/{cli-qbksc292.js → cli-zy39d433.js} +2 -0
- package/dist/cli.js +36 -32
- package/dist/{cloudflare-workers-ai-system-one-tt484t61.js → cloudflare-workers-ai-system-one-sta45jf9.js} +7 -5
- package/dist/{codex-adapter-3qnxshje.js → codex-adapter-cgesnjkr.js} +20 -20
- package/dist/{codex-login-brkxhhdg.js → codex-login-g1cyt5zm.js} +2 -2
- package/dist/{codex-session-runner-612wnapp.js → codex-session-runner-8kd7ddhr.js} +20 -20
- package/dist/{commands-2ybfcxkj.js → commands-h6zaaxym.js} +11 -10
- package/dist/{cursor-adapter-p3jgdehv.js → cursor-adapter-v8mm6bp5.js} +7 -7
- package/dist/{db-f4ans0jj.js → db-qg3myn53.js} +13 -10
- package/dist/{devin-adapter-dhzt01ff.js → devin-adapter-bffjj5n4.js} +2 -2
- package/dist/{dispatcher-pk182apd.js → dispatcher-7vnwj9qw.js} +28 -32
- package/dist/{dsh-adapter-7twaeps1.js → dsh-adapter-tz6hfp5r.js} +7 -7
- package/dist/{e2b-y8t3jzyz.js → e2b-nd50eccg.js} +1 -1
- package/dist/{easter-egg-3d-mtpnw06s.js → easter-egg-3d-66zxervv.js} +2 -2
- package/dist/{event-bus-w7ac4n3c.js → event-bus-vnfthafg.js} +2 -2
- package/dist/{execute-s4ccjq3n.js → execute-h4jgevyw.js} +61 -11
- package/dist/{google-generative-ai-d6nphg3q.js → google-generative-ai-b8zxrpax.js} +5 -5
- package/dist/{google-vertex-cpshkref.js → google-vertex-nrdd697t.js} +5 -5
- package/dist/grok-adapter-jdt2dz2s.js +39 -0
- package/dist/{handlers-g2wnr4t9.js → handlers-2qtkpncr.js} +31 -35
- package/dist/{hook-f7jt9vnm.js → hook-51yfcgsv.js} +48 -39
- package/dist/{hook-bbdpnkb4.js → hook-qnbdgwvd.js} +15 -17
- package/dist/{http-w40q4w94.js → http-jsmtag08.js} +536 -231
- package/dist/{index-056j5kzn.js → index-2t9kesn1.js} +13 -12
- package/dist/{index-cj1r9q83.js → index-bt8wkv1w.js} +29 -33
- package/dist/{index-7n70jwbb.js → index-cx1sb9bq.js} +42 -35
- package/dist/{index-9bfssf54.js → index-ekywyv2v.js} +28 -32
- package/dist/{index-fdk1t4d6.js → index-n0rxa4ca.js} +11962 -9900
- package/dist/{index-k8xc083e.js → index-t4g06w93.js} +28 -32
- package/dist/{keepalive-1tj10tf4.js → keepalive-4aezx4bj.js} +16 -12
- package/dist/{lead-st0bg7v4.js → lead-r44bkpm5.js} +52 -56
- package/dist/{llama-cpp-classify-tgj35k8d.js → llama-cpp-classify-6erb7wwv.js} +3 -1
- package/dist/{maintenance-nz71zats.js → maintenance-grz5jrzh.js} +12 -13
- package/dist/{mistral-conversations-8445ddjn.js → mistral-conversations-059y51zt.js} +4 -4
- package/dist/{node-f0ykebbv.js → node-qm9eb6z0.js} +25 -7
- package/dist/{oauth-refresh-sweep-aefzwvvq.js → oauth-refresh-sweep-wm4ctjfj.js} +15 -11
- package/dist/{onboard-kgpr9mbn.js → onboard-v60zgqf0.js} +2 -2
- package/dist/{openai-codex-responses-9ynm88zy.js → openai-codex-responses-jzxkta9b.js} +8 -7
- package/dist/{openai-completions-nhqwjmaw.js → openai-completions-663yncfq.js} +4 -4
- package/dist/openai-decisions-vj9nkpf8.js +162 -0
- package/dist/{openai-responses-xx1c4kgm.js → openai-responses-m3g43rrt.js} +5 -5
- package/dist/{opencode-adapter-0c8e70dk.js → opencode-adapter-yjyqynzf.js} +8 -8
- package/dist/{openrouter-images-8yx3487g.js → openrouter-images-kr60n6b9.js} +1 -1
- package/dist/{otel-impl-x8zp4y5a.js → otel-impl-ghh4dyf8.js} +2 -2
- package/dist/{pi-messages-vxdt8v7j.js → pi-messages-xszk613n.js} +1 -1
- package/dist/{pi-mono-adapter-t280ah5c.js → pi-mono-adapter-0eg8kw2c.js} +69 -52
- package/dist/{pricing-refresh-9e0q7cwk.js → pricing-refresh-mjrqvnvw.js} +12 -11
- package/dist/{rbac-roles-790j3ga8.js → rbac-roles-axv4d74x.js} +11 -10
- package/dist/{rbac-roles-kcp6zge2.js → rbac-roles-fd5tskj9.js} +11 -10
- package/dist/{render-v2-tch4nefj.js → render-v2-k50j33qd.js} +11 -11
- package/dist/{runtime-v2t1r79e.js → runtime-h9ha1mq6.js} +4 -4
- package/dist/{setup-rcm303ns.js → setup-4syh0pd2.js} +2 -2
- package/dist/{typesafe-system-one-datfr82p.js → typesafe-system-one-e988vty7.js} +7 -5
- package/dist/{virtual-modules-wm8mxdxx.js → virtual-modules-ftr9kwe8.js} +11 -11
- package/dist/{work-objects-ctg7t70w.js → work-objects-jcdbg8rr.js} +32 -36
- package/dist/{worker-5dp0xm55.js → worker-x8j8c9sx.js} +52 -56
- package/dist/{x-v3yw66zs.js → x-ma4gnfgy.js} +2 -2
- package/openapi.json +5 -2
- package/package.json +15 -11
- package/src/be/automation-preflight.ts +9 -4
- package/src/be/boot-scrub-sweep.ts +302 -0
- package/src/be/crypto/key-bootstrap.ts +1 -1
- package/src/be/db/approvals.ts +15 -1
- package/src/be/db/codex-oauth-device-flows.ts +40 -0
- package/src/be/db/config-secrets.ts +31 -0
- package/src/be/db/runtime.ts +4 -0
- package/src/be/db/script-runs.ts +15 -0
- package/src/be/db/tasks/write.ts +1 -1
- package/src/be/db-queries/mcp-oauth.ts +5 -0
- package/src/be/db-queries/oauth.ts +77 -0
- package/src/be/db.ts +162 -59
- package/src/be/events.ts +17 -1
- package/src/be/memory/index-content.ts +2 -2
- package/src/be/memory/providers/openai-embedding.ts +7 -2
- package/src/be/memory/providers/sqlite-store.ts +63 -11
- package/src/be/memory/raters/llm-summarizer.ts +7 -2
- package/src/be/memory/types.ts +14 -0
- package/src/be/migrations/201_workflow_replay_columns.sql +10 -0
- package/src/be/migrations/202_codex_oauth_device_flows.sql +24 -0
- package/src/be/modelsdev-cache.json +61 -0
- package/src/be/scripts/db.ts +28 -4
- package/src/be/scripts/source-secrets.ts +37 -0
- package/src/be/scrub-json.ts +32 -0
- package/src/be/sealed-json.ts +59 -0
- package/src/be/secret-registry.ts +131 -0
- package/src/be/seed-pricing.ts +84 -53
- package/src/be/swarm-config-guard.ts +13 -0
- package/src/be/workflow-replay.ts +77 -0
- package/src/commands/provider-credentials.ts +28 -5
- package/src/commands/runner.ts +7 -12
- package/src/heartbeat/heartbeat.ts +91 -19
- package/src/hooks/hook.ts +72 -27
- package/src/http/codex-oauth-device.ts +8 -10
- package/src/http/db-query-bounded.ts +3 -0
- package/src/http/db-query-shared.ts +107 -15
- package/src/http/db-query.ts +10 -2
- package/src/http/index.ts +23 -6
- package/src/http/mcp.ts +5 -0
- package/src/http/onboarding.ts +2 -0
- package/src/http/script-runs.ts +9 -1
- package/src/http/scripts.ts +15 -0
- package/src/http/workflows.ts +3 -2
- package/src/oauth/mcp-wrapper.ts +1 -1
- package/src/providers/acp-adapter.ts +25 -11
- package/src/providers/acp-target-catalog.ts +35 -1
- package/src/providers/acp-targets.ts +78 -7
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +26 -0
- package/src/providers/codex-adapter.ts +30 -3
- package/src/providers/codex-oauth/auth-json.ts +21 -4
- package/src/providers/codex-oauth/types.ts +2 -0
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +10 -1
- package/src/providers/grok-adapter.ts +18 -2
- package/src/providers/opencode-adapter.ts +21 -5
- package/src/providers/pi-mono-extension.ts +56 -25
- package/src/providers/pricing-sources.md +2 -0
- package/src/script-workflows/supervisor.ts +11 -2
- package/src/scripts-runtime/eval-harness.ts +2 -12
- package/src/scripts-runtime/executors/quickjs-bundle.ts +152 -0
- package/src/scripts-runtime/executors/quickjs-prelude.ts +285 -0
- package/src/scripts-runtime/executors/quickjs-runner.ts +580 -0
- package/src/scripts-runtime/executors/quickjs-worker.ts +81 -0
- package/src/scripts-runtime/executors/quickjs.ts +196 -0
- package/src/scripts-runtime/executors/registry.ts +2 -0
- package/src/scripts-runtime/executors/sourcemap.ts +79 -0
- package/src/scripts-runtime/script-error-hints.ts +14 -0
- package/src/server.ts +66 -4
- package/src/tests/acp-adapter.test.ts +277 -12
- package/src/tests/boot-scrub-sweep.test.ts +390 -0
- package/src/tests/check-text-columns.test.ts +145 -0
- package/src/tests/ci-unit-test-report.test.ts +73 -0
- package/src/tests/claude-default-route.test.ts +75 -0
- package/src/tests/claude-hook-output.test.ts +233 -0
- package/src/tests/claude-sdk-process.fixture.ts +13 -2
- package/src/tests/codex-adapter-pool-auth-revalidate.test.ts +4 -2
- package/src/tests/codex-adapter.test.ts +166 -26
- package/src/tests/codex-oauth-auth-timestamps.test.ts +76 -0
- package/src/tests/codex-oauth-device.test.ts +23 -37
- package/src/tests/codex-oauth.test.ts +4 -1
- package/src/tests/context-window.test.ts +2 -2
- package/src/tests/credential-check.test.ts +51 -1
- package/src/tests/db-query-denylist.test.ts +202 -0
- package/src/tests/db-task-read-contract.test.ts +1 -0
- package/src/tests/db-task-write-contract.test.ts +1 -0
- package/src/tests/dsh-adapter.test.ts +23 -1
- package/src/tests/enabled-tools.test.ts +269 -0
- package/src/tests/entrypoint-acp-target-binary.test.ts +31 -1
- package/src/tests/entrypoint-codex-oauth-seed.test.ts +12 -0
- package/src/tests/events-scrub.test.ts +88 -0
- package/src/tests/fixtures/secret-corpus.ts +320 -0
- package/src/tests/grok-adapter.test.ts +13 -0
- package/src/tests/haiku-5-5-pricing.test.ts +38 -0
- package/src/tests/heartbeat-checklist.test.ts +158 -1
- package/src/tests/onboarding.test.ts +44 -0
- package/src/tests/opencode-adapter.test.ts +66 -3
- package/src/tests/opencode-plugin.test.ts +37 -0
- package/src/tests/openrouter-attribution-call-sites.test.ts +204 -0
- package/src/tests/openrouter-base-url.test.ts +30 -39
- package/src/tests/pi-mono-extension.test.ts +161 -2
- package/src/tests/pricing-refresh.test.ts +70 -1
- package/src/tests/reasoning-effort.test.ts +3 -1
- package/src/tests/script-connections.test.ts +5 -0
- package/src/tests/script-executor-conformance.test.ts +3 -0
- package/src/tests/script-executor-quickjs.test.ts +442 -0
- package/src/tests/script-executor-registry.test.ts +6 -1
- package/src/tests/script-runs-http.test.ts +88 -1
- package/src/tests/script-runs-scrub.test.ts +275 -0
- package/src/tests/scripts-http.test.ts +82 -1
- package/src/tests/scrubbed-text-12e.test.ts +289 -0
- package/src/tests/sealed-key-guard.test.ts +166 -0
- package/src/tests/secret-canary-sweep.test.ts +958 -0
- package/src/tests/secret-registry.test.ts +355 -0
- package/src/tests/secret-rules.test.ts +230 -0
- package/src/tests/secret-scrubber.test.ts +3 -2
- package/src/tests/telemetry-trigger.test.ts +12 -1
- package/src/tests/workflow-llm.test.ts +14 -0
- package/src/tests/workflow-replay.test.ts +518 -0
- package/src/tests/workflow-scrub.test.ts +242 -0
- package/src/tests/workflow-system-one-decision-providers.test.ts +33 -0
- package/src/tools/db-query.ts +1 -1
- package/src/tools/inject-learning.ts +1 -1
- package/src/tools/request-human-input.ts +7 -2
- package/src/tools/workflows/get-workflow-run.ts +3 -2
- package/src/types.ts +1 -1
- package/src/utils/enabled-tools.ts +27 -0
- package/src/utils/internal-ai/complete-structured.ts +11 -3
- package/src/utils/openrouter-base-url.ts +23 -0
- package/src/utils/secret-rules.generated.ts +2055 -0
- package/src/utils/secret-scrubber.ts +363 -29
- package/src/workflows/engine.ts +39 -4
- package/src/workflows/executors/raw-llm.ts +1 -0
- package/src/workflows/executors/system-one-decision.ts +2 -0
- package/src/workflows/executors/validate.ts +1 -0
- package/src/workflows/executors/workflow-llm.ts +9 -2
- package/src/workflows/recovery.ts +10 -1
- package/src/workflows/resume.ts +62 -3
- package/src/workflows/retry-poller.ts +3 -0
- package/templates/skills/agent-browser/SKILL.md +2 -0
- package/templates/skills/agent-browser/content.md +2 -0
- package/templates/skills/code-quality/content.md +1 -0
- package/templates/skills/heartbeat-runbook/content.md +1 -1
- package/templates/skills/work-on-task/SKILL.md +4 -0
- package/templates/skills/work-on-task/content.md +4 -0
- package/templates/skills/workflow-iterate/content.md +9 -0
- package/dist/acp-adapter-w6zws6me.js +0 -23
- package/dist/boot-scrub-logs-246yn076.js +0 -99
- package/dist/cli-3a4m1aws.js +0 -572
- package/dist/cli-3dpj7atn.js +0 -11
- package/dist/cli-a87b04k8.js +0 -951
- package/dist/cli-cvk6yzw5.js +0 -40
- package/dist/cli-gvcgmx69.js +0 -183
- package/dist/cli-h1spv8v4.js +0 -427
- package/dist/cli-jqt9hrnz.js +0 -168
- package/dist/cli-yhmwmv0g.js +0 -9281
- package/dist/grok-adapter-yt9pab3k.js +0 -29
- package/src/be/boot-scrub-logs.ts +0 -132
- package/dist/{codex-hook-d2rkvf39.js → codex-hook-15dgc4cb.js} +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRecord,
|
|
3
|
+
parseClassifierUsage,
|
|
4
|
+
postClassifierRequest,
|
|
5
|
+
requiredNumber
|
|
6
|
+
} from "./cli-q1vnz8wv.js";
|
|
7
|
+
import {
|
|
8
|
+
formatProviderError,
|
|
9
|
+
normalizeProviderError
|
|
10
|
+
} from "./cli-6map995v.js";
|
|
11
|
+
|
|
12
|
+
// node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js
|
|
13
|
+
function probabilities(label, value, id) {
|
|
14
|
+
if (!isRecord(value))
|
|
15
|
+
throw new Error(`${label} returned invalid probabilities for ${id}`);
|
|
16
|
+
return Object.fromEntries(Object.entries(value).map(([key, probability]) => [
|
|
17
|
+
key,
|
|
18
|
+
requiredNumber(label, probability, `probability for ${id}.${key}`)
|
|
19
|
+
]));
|
|
20
|
+
}
|
|
21
|
+
function parseAnswers(label, value, context) {
|
|
22
|
+
if (!isRecord(value))
|
|
23
|
+
throw new Error(`${label} returned an unexpected response`);
|
|
24
|
+
const answers = [];
|
|
25
|
+
for (const [id, question] of Object.entries(context.questions)) {
|
|
26
|
+
const answer = value[id];
|
|
27
|
+
if (!isRecord(answer))
|
|
28
|
+
throw new Error(`${label} did not return an answer for ${id}`);
|
|
29
|
+
if (question.type === "choice") {
|
|
30
|
+
if (answer.type !== "choice" || typeof answer.choice !== "string") {
|
|
31
|
+
throw new Error(`${label} did not return a choice answer for ${id}`);
|
|
32
|
+
}
|
|
33
|
+
answers.push([
|
|
34
|
+
id,
|
|
35
|
+
{
|
|
36
|
+
type: "choice",
|
|
37
|
+
choice: answer.choice,
|
|
38
|
+
probabilities: probabilities(label, answer.probabilities, id),
|
|
39
|
+
confidence: requiredNumber(label, answer.confidence, `confidence for ${id}`)
|
|
40
|
+
}
|
|
41
|
+
]);
|
|
42
|
+
} else if (question.type === "score") {
|
|
43
|
+
if (answer.type !== "score")
|
|
44
|
+
throw new Error(`${label} did not return a score answer for ${id}`);
|
|
45
|
+
answers.push([
|
|
46
|
+
id,
|
|
47
|
+
{
|
|
48
|
+
type: "score",
|
|
49
|
+
score: requiredNumber(label, answer.score, `score for ${id}`),
|
|
50
|
+
confidence: requiredNumber(label, answer.confidence, `confidence for ${id}`)
|
|
51
|
+
}
|
|
52
|
+
]);
|
|
53
|
+
} else {
|
|
54
|
+
if (answer.type !== "noul")
|
|
55
|
+
throw new Error(`${label} did not return a bool answer for ${id}`);
|
|
56
|
+
answers.push([
|
|
57
|
+
id,
|
|
58
|
+
{
|
|
59
|
+
type: "bool",
|
|
60
|
+
probability: requiredNumber(label, answer.noul, `probability for ${id}`)
|
|
61
|
+
}
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return Object.fromEntries(answers);
|
|
66
|
+
}
|
|
67
|
+
function wireRequest(context) {
|
|
68
|
+
return {
|
|
69
|
+
state: context.state,
|
|
70
|
+
questions: Object.fromEntries(Object.entries(context.questions).map(([id, question]) => [
|
|
71
|
+
id,
|
|
72
|
+
question.type === "bool" ? { ...question, type: "noul" } : question
|
|
73
|
+
]))
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function classifySystemOne(transport, model, context, options) {
|
|
77
|
+
const output = {
|
|
78
|
+
api: model.api,
|
|
79
|
+
provider: model.provider,
|
|
80
|
+
model: model.id,
|
|
81
|
+
answers: {},
|
|
82
|
+
stopReason: "stop",
|
|
83
|
+
timestamp: Date.now()
|
|
84
|
+
};
|
|
85
|
+
try {
|
|
86
|
+
if (model.api !== transport.api)
|
|
87
|
+
throw new Error(`Unsupported classifier API: ${model.api}`);
|
|
88
|
+
if (context.images?.length)
|
|
89
|
+
throw new Error(`${transport.label} does not support image input`);
|
|
90
|
+
const body = await postClassifierRequest(transport.label, transport.url(model), model, transport.payload(model, wireRequest(context)), options);
|
|
91
|
+
const result = transport.output(body);
|
|
92
|
+
const usage = parseClassifierUsage(result.usage, model);
|
|
93
|
+
if (usage)
|
|
94
|
+
output.usage = usage;
|
|
95
|
+
output.answers = parseAnswers(transport.label, result.answers, context);
|
|
96
|
+
return output;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
99
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error), `${transport.label} error`);
|
|
100
|
+
return output;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { classifySystemOne };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildModelsDevSeedRows,
|
|
3
3
|
loadModelsDevCache
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-v1pwxreq.js";
|
|
5
5
|
import {
|
|
6
6
|
createLogEntry,
|
|
7
7
|
getActivePricingRow,
|
|
8
8
|
getDbClient,
|
|
9
|
-
init_db,
|
|
9
|
+
init_db1 as init_db,
|
|
10
10
|
insertPricingRow
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-mkdsy1nq.js";
|
|
12
12
|
import {
|
|
13
13
|
init_runtime_model_catalog,
|
|
14
14
|
setRuntimeModelCatalog
|
|
15
|
-
} from "./cli-
|
|
15
|
+
} from "./cli-014vns2y.js";
|
|
16
16
|
import {
|
|
17
17
|
init_secret_scrubber,
|
|
18
18
|
scrubSecrets
|
|
19
|
-
} from "./cli-
|
|
19
|
+
} from "./cli-wt7ccy4r.js";
|
|
20
20
|
|
|
21
21
|
// src/be/pricing-refresh.ts
|
|
22
22
|
init_secret_scrubber();
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
CONTEXT_FORMULA,
|
|
6
6
|
clampContextPercent,
|
|
7
7
|
getContextWindowSize
|
|
8
|
-
} from "./cli-
|
|
8
|
+
} from "./cli-7avy4v8w.js";
|
|
9
9
|
import {
|
|
10
10
|
applyReasoningEffort,
|
|
11
11
|
reasoningCapability
|
|
12
|
-
} from "./cli-
|
|
12
|
+
} from "./cli-tmhsxhb8.js";
|
|
13
13
|
import {
|
|
14
14
|
swarmRuntimeInstanceId
|
|
15
15
|
} from "./cli-re8z5p8p.js";
|
|
@@ -18,18 +18,20 @@ import {
|
|
|
18
18
|
registerProcessGroup,
|
|
19
19
|
terminateProcessGroup
|
|
20
20
|
} from "./cli-zt3w1cn1.js";
|
|
21
|
-
import {
|
|
22
|
-
getOpenRouterBaseUrl
|
|
23
|
-
} from "./cli-3dpj7atn.js";
|
|
24
21
|
import {
|
|
25
22
|
DEFAULT_MODEL_TIER_MAP,
|
|
26
23
|
init_types
|
|
27
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-xvdgasgy.js";
|
|
25
|
+
import {
|
|
26
|
+
getOpenRouterAttributionHeaders,
|
|
27
|
+
getOpenRouterBaseUrl,
|
|
28
|
+
init_openrouter_base_url
|
|
29
|
+
} from "./cli-a35hzdve.js";
|
|
28
30
|
import {
|
|
29
31
|
init_secret_scrubber,
|
|
30
32
|
registerVolatileSecret,
|
|
31
33
|
scrubSecrets
|
|
32
|
-
} from "./cli-
|
|
34
|
+
} from "./cli-wt7ccy4r.js";
|
|
33
35
|
|
|
34
36
|
// src/providers/dsh-adapter.ts
|
|
35
37
|
init_types();
|
|
@@ -62,6 +64,7 @@ function addDshStepUsage(acc, step) {
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
// src/providers/dsh-adapter.ts
|
|
67
|
+
init_openrouter_base_url();
|
|
65
68
|
init_secret_scrubber();
|
|
66
69
|
var DSH_PACKAGE = "@deepseek-ai/dsh@0.2.1-alpha.1";
|
|
67
70
|
function checkDshCredentials(env) {
|
|
@@ -323,6 +326,7 @@ class DshAdapter {
|
|
|
323
326
|
const directory = await mkdtemp(join(tmpdir(), "swarm-dsh-"));
|
|
324
327
|
try {
|
|
325
328
|
const patchPath = join(directory, "patch.json");
|
|
329
|
+
const openRouterHeaders = openrouter ? getOpenRouterAttributionHeaders(getOpenRouterBaseUrl(env), env) : {};
|
|
326
330
|
const runtimeInstanceId = swarmRuntimeInstanceId();
|
|
327
331
|
await writeFile(patchPath, JSON.stringify([
|
|
328
332
|
{
|
|
@@ -341,6 +345,7 @@ class DshAdapter {
|
|
|
341
345
|
openrouter: {
|
|
342
346
|
apiKeyEnv: keyEnv,
|
|
343
347
|
baseURL: getOpenRouterBaseUrl(env),
|
|
348
|
+
...Object.keys(openRouterHeaders).length > 0 ? { headers: openRouterHeaders } : {},
|
|
344
349
|
api: "openai-completions",
|
|
345
350
|
models: [
|
|
346
351
|
reasoningEffort ? { id: modelId, reasoningEfforts: openRouterEfforts(model) } : { id: modelId }
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
retryProviderRequest
|
|
3
|
+
} from "./cli-zy39d433.js";
|
|
4
|
+
import {
|
|
5
|
+
headersToRecord,
|
|
6
|
+
providerHeadersToRecord
|
|
7
|
+
} from "./cli-7kyk9jr3.js";
|
|
8
|
+
import {
|
|
9
|
+
calculateCost
|
|
10
|
+
} from "./cli-g7k7zbcz.js";
|
|
11
|
+
|
|
12
|
+
// node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.js
|
|
13
|
+
function httpError(label, response, body) {
|
|
14
|
+
const error = new Error(`${label} returned ${response.status}`);
|
|
15
|
+
error.status = response.status;
|
|
16
|
+
error.headers = response.headers;
|
|
17
|
+
error.body = body;
|
|
18
|
+
return error;
|
|
19
|
+
}
|
|
20
|
+
function timeoutError(timeoutMs) {
|
|
21
|
+
const error = new Error(`Request timed out after ${timeoutMs}ms`);
|
|
22
|
+
error.name = "TimeoutError";
|
|
23
|
+
error.status = undefined;
|
|
24
|
+
error.headers = undefined;
|
|
25
|
+
error.body = "";
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
function isRecord(value) {
|
|
29
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
function requiredNumber(label, value, field) {
|
|
32
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
33
|
+
throw new Error(`${label} returned an invalid ${field}`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function requestHeaders(model, apiKey, optionsHeaders) {
|
|
38
|
+
return providerHeadersToRecord({ authorization: `Bearer ${apiKey}`, "content-type": "application/json" }, model.headers, optionsHeaders) ?? {};
|
|
39
|
+
}
|
|
40
|
+
async function postClassifierRequest(label, url, model, body, options, noRetryStatuses) {
|
|
41
|
+
if (!options?.apiKey)
|
|
42
|
+
throw new Error(`No API key for provider: ${model.provider}`);
|
|
43
|
+
const apiKey = options.apiKey;
|
|
44
|
+
let payload = body;
|
|
45
|
+
const transformed = await options.onPayload?.(payload, model);
|
|
46
|
+
if (transformed !== undefined)
|
|
47
|
+
payload = transformed;
|
|
48
|
+
const requestFetch = options.fetch ?? globalThis.fetch;
|
|
49
|
+
const { response, json } = await retryProviderRequest(async () => {
|
|
50
|
+
const timeoutSignal = options.timeoutMs !== undefined ? AbortSignal.timeout(options.timeoutMs) : undefined;
|
|
51
|
+
const signal = options.signal && timeoutSignal ? AbortSignal.any([options.signal, timeoutSignal]) : options.signal ?? timeoutSignal;
|
|
52
|
+
try {
|
|
53
|
+
const next = await requestFetch(url, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: requestHeaders(model, apiKey, options.headers),
|
|
56
|
+
body: JSON.stringify(payload),
|
|
57
|
+
signal
|
|
58
|
+
});
|
|
59
|
+
if (!next.ok)
|
|
60
|
+
throw httpError(label, next, await next.text());
|
|
61
|
+
return { response: next, json: await next.json() };
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (timeoutSignal?.aborted && !options.signal?.aborted)
|
|
64
|
+
throw timeoutError(options.timeoutMs);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
maxRetries: options.maxRetries ?? 2,
|
|
69
|
+
maxRetryDelayMs: options.maxRetryDelayMs,
|
|
70
|
+
signal: options.signal,
|
|
71
|
+
noRetryStatuses
|
|
72
|
+
});
|
|
73
|
+
await options.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
|
|
74
|
+
return json;
|
|
75
|
+
}
|
|
76
|
+
function tokenCount(value) {
|
|
77
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
78
|
+
}
|
|
79
|
+
function parseClassifierUsage(value, model) {
|
|
80
|
+
if (!isRecord(value) || value.input_tokens === undefined && value.output_tokens === undefined)
|
|
81
|
+
return;
|
|
82
|
+
const input = tokenCount(value.input_tokens);
|
|
83
|
+
const output = tokenCount(value.output_tokens);
|
|
84
|
+
const usage = {
|
|
85
|
+
input,
|
|
86
|
+
output,
|
|
87
|
+
cacheRead: 0,
|
|
88
|
+
cacheWrite: 0,
|
|
89
|
+
totalTokens: input + output,
|
|
90
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
91
|
+
};
|
|
92
|
+
calculateCost(model, usage);
|
|
93
|
+
return usage;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { isRecord, requiredNumber, postClassifierRequest, parseClassifierUsage };
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
resolveGrammarConstrainedSampling,
|
|
9
9
|
resolveJsonSchemaStrictSampling,
|
|
10
10
|
transformMessages
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-xf713zz0.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-
|
|
21
|
+
} from "./cli-g7k7zbcz.js";
|
|
22
22
|
import {
|
|
23
23
|
parseStreamingJson
|
|
24
24
|
} from "./cli-1m2e086m.js";
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
recoverIncompleteRuns,
|
|
19
19
|
repointTrackerSyncBySwarmId,
|
|
20
20
|
resolveLeadOnlyRecoveryAssignment
|
|
21
|
-
} from "./cli-
|
|
21
|
+
} from "./cli-wydz3feg.js";
|
|
22
22
|
import {
|
|
23
23
|
isMultiRuntimeEnabled
|
|
24
24
|
} from "./cli-re8z5p8p.js";
|
|
25
25
|
import {
|
|
26
26
|
createApprovalFollowUpTask
|
|
27
|
-
} from "./cli-
|
|
27
|
+
} from "./cli-577bxkf6.js";
|
|
28
28
|
import {
|
|
29
29
|
MAX_EMPTY_POLLS,
|
|
30
30
|
assignUnassignedTaskPending,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
getUnassignedPoolTasks,
|
|
62
62
|
hasNonTerminalResumeChild,
|
|
63
63
|
hasPendingSteering,
|
|
64
|
-
init_db,
|
|
64
|
+
init_db1 as init_db,
|
|
65
65
|
init_steering,
|
|
66
66
|
isAgentEligibleForTask,
|
|
67
67
|
isPoolAffinityEnforcementEnabled,
|
|
@@ -75,11 +75,11 @@ import {
|
|
|
75
75
|
settleSupersededTaskDependents,
|
|
76
76
|
supersedeTask,
|
|
77
77
|
updateAgentStatus
|
|
78
|
-
} from "./cli-
|
|
78
|
+
} from "./cli-mkdsy1nq.js";
|
|
79
79
|
import {
|
|
80
80
|
TERMINAL_TASK_STATUSES,
|
|
81
81
|
init_types
|
|
82
|
-
} from "./cli-
|
|
82
|
+
} from "./cli-xvdgasgy.js";
|
|
83
83
|
import {
|
|
84
84
|
init_registry,
|
|
85
85
|
init_resolver,
|
|
@@ -90,10 +90,17 @@ import {
|
|
|
90
90
|
init_env_flag,
|
|
91
91
|
isEnvFlagEnabled
|
|
92
92
|
} from "./cli-ej6gbxfb.js";
|
|
93
|
+
import {
|
|
94
|
+
init_package,
|
|
95
|
+
package_default
|
|
96
|
+
} from "./cli-ymmc1zxg.js";
|
|
93
97
|
import {
|
|
94
98
|
init_secret_scrubber,
|
|
95
99
|
scrubSecrets
|
|
96
|
-
} from "./cli-
|
|
100
|
+
} from "./cli-wt7ccy4r.js";
|
|
101
|
+
|
|
102
|
+
// src/heartbeat/heartbeat.ts
|
|
103
|
+
init_package();
|
|
97
104
|
|
|
98
105
|
// src/be/approval-sweeps.ts
|
|
99
106
|
init_db();
|
|
@@ -356,6 +363,9 @@ function heartbeatChecklistIntervalMs() {
|
|
|
356
363
|
function isHeartbeatChecklistDisabled() {
|
|
357
364
|
return isEnvFlagEnabled("HEARTBEAT_CHECKLIST_DISABLE", false);
|
|
358
365
|
}
|
|
366
|
+
function isBootTriageAlways() {
|
|
367
|
+
return isEnvFlagEnabled("HEARTBEAT_BOOT_TRIAGE_ALWAYS", false);
|
|
368
|
+
}
|
|
359
369
|
var heartbeatInterval = null;
|
|
360
370
|
var checklistInterval = null;
|
|
361
371
|
var bootTriageTimeout = null;
|
|
@@ -1130,19 +1140,7 @@ async function gatherSystemStatus(options) {
|
|
|
1130
1140
|
sections.push("- If the retry failed or the work is no longer needed, cancel it");
|
|
1131
1141
|
sections.push("- Do NOT mark this boot triage as complete until all items are triaged");
|
|
1132
1142
|
}
|
|
1133
|
-
const orphanedTasks =
|
|
1134
|
-
for (const status of ["pending", "offered"]) {
|
|
1135
|
-
const tasks = await getTasksByStatus(status);
|
|
1136
|
-
for (const task of tasks) {
|
|
1137
|
-
const holderId = status === "offered" ? task.offeredTo : task.agentId;
|
|
1138
|
-
if (!holderId)
|
|
1139
|
-
continue;
|
|
1140
|
-
const agent = agents.find((a) => a.id === holderId);
|
|
1141
|
-
if (!agent || agent.status === "offline") {
|
|
1142
|
-
orphanedTasks.push(task);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1143
|
+
const orphanedTasks = await getOrphanedPendingOrOfferedTasks(agents);
|
|
1146
1144
|
if (orphanedTasks.length > 0) {
|
|
1147
1145
|
sections.push("");
|
|
1148
1146
|
sections.push("## Orphaned Tasks [auto-generated, NEEDS ATTENTION]");
|
|
@@ -1160,6 +1158,32 @@ async function gatherSystemStatus(options) {
|
|
|
1160
1158
|
return sections.join(`
|
|
1161
1159
|
`);
|
|
1162
1160
|
}
|
|
1161
|
+
async function getOrphanedPendingOrOfferedTasks(agents) {
|
|
1162
|
+
const orphanedTasks = [];
|
|
1163
|
+
for (const status of ["pending", "offered"]) {
|
|
1164
|
+
const tasks = await getTasksByStatus(status);
|
|
1165
|
+
for (const task of tasks) {
|
|
1166
|
+
const holderId = status === "offered" ? task.offeredTo : task.agentId;
|
|
1167
|
+
if (!holderId)
|
|
1168
|
+
continue;
|
|
1169
|
+
const agent = agents.find((a) => a.id === holderId);
|
|
1170
|
+
if (!agent || agent.status === "offline") {
|
|
1171
|
+
orphanedTasks.push(task);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
return orphanedTasks;
|
|
1176
|
+
}
|
|
1177
|
+
async function getBootTriageFindings() {
|
|
1178
|
+
const now = Date.now();
|
|
1179
|
+
const agents = await getAllAgents();
|
|
1180
|
+
return {
|
|
1181
|
+
rebootInterrupted: getRebootAffectedTasks().length,
|
|
1182
|
+
stalled: (await getStalledInProgressTasks(stallThresholdMinutes())).length,
|
|
1183
|
+
orphaned: (await getOrphanedPendingOrOfferedTasks(agents)).length,
|
|
1184
|
+
supersededWithoutResume: (await getSupersededTasksWithoutResume(new Date(now - ORPHAN_SUPERSEDE_MIN_AGE_MS).toISOString(), new Date(now - ORPHAN_SUPERSEDE_MAX_AGE_MS).toISOString())).length
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1163
1187
|
async function checkHeartbeatChecklist() {
|
|
1164
1188
|
const lead = await getLeadAgent();
|
|
1165
1189
|
if (!lead)
|
|
@@ -1323,7 +1347,23 @@ async function createBootTriageTask() {
|
|
|
1323
1347
|
LIMIT 1`, [lead.id, ...TERMINAL_TASK_STATUSES]);
|
|
1324
1348
|
if (existing)
|
|
1325
1349
|
return;
|
|
1326
|
-
|
|
1350
|
+
if (!isBootTriageAlways()) {
|
|
1351
|
+
const findings = await getBootTriageFindings().catch((err) => {
|
|
1352
|
+
console.error("[Heartbeat] Boot triage findings failed, creating Lead task:", scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
1353
|
+
return null;
|
|
1354
|
+
});
|
|
1355
|
+
if (findings && Object.values(findings).every((count) => count === 0)) {
|
|
1356
|
+
console.log(`[Heartbeat] Clean boot (v${package_default.version}): 0 interrupted, stalled, orphaned, or resume-less superseded tasks; no boot-triage task for lead ${lead.name}`);
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
const systemStatus = await gatherSystemStatus({ isBootTriage: true }).catch((err) => {
|
|
1361
|
+
const reason = scrubSecrets(err instanceof Error ? err.message : String(err));
|
|
1362
|
+
console.error("[Heartbeat] Boot triage status gathering failed:", reason);
|
|
1363
|
+
return `## System status unavailable
|
|
1364
|
+
|
|
1365
|
+
Status gathering failed after this boot (${reason}). Investigate the task, agent, and DB state directly.`;
|
|
1366
|
+
});
|
|
1327
1367
|
const result = resolveTemplate("heartbeat.boot-triage", {
|
|
1328
1368
|
system_status: systemStatus,
|
|
1329
1369
|
heartbeat_content: isEffectivelyEmpty(heartbeatMd) ? "_No standing orders configured._" : heartbeatMd
|
|
@@ -6,18 +6,20 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
parseModelStr,
|
|
8
8
|
resolveCredential
|
|
9
|
-
} from "./cli-
|
|
10
|
-
import {
|
|
11
|
-
DEFAULT_OPENROUTER_BASE_URL,
|
|
12
|
-
getOpenRouterBaseUrl
|
|
13
|
-
} from "./cli-3dpj7atn.js";
|
|
9
|
+
} from "./cli-7mhy3ths.js";
|
|
14
10
|
import {
|
|
15
11
|
complete,
|
|
16
12
|
getBuiltinModel
|
|
17
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-km4x66j0.js";
|
|
18
14
|
import {
|
|
19
15
|
exports_typebox
|
|
20
16
|
} from "./cli-rb9m6rpe.js";
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_OPENROUTER_BASE_URL,
|
|
19
|
+
getOpenRouterAttributionHeaders,
|
|
20
|
+
getOpenRouterBaseUrl,
|
|
21
|
+
init_openrouter_base_url
|
|
22
|
+
} from "./cli-a35hzdve.js";
|
|
21
23
|
import {
|
|
22
24
|
init_zod
|
|
23
25
|
} from "./cli-sd0mxa3c.js";
|
|
@@ -27,10 +29,11 @@ import {
|
|
|
27
29
|
import {
|
|
28
30
|
init_secret_scrubber,
|
|
29
31
|
scrubSecrets
|
|
30
|
-
} from "./cli-
|
|
32
|
+
} from "./cli-wt7ccy4r.js";
|
|
31
33
|
|
|
32
34
|
// src/utils/internal-ai/complete-structured.ts
|
|
33
35
|
init_zod();
|
|
36
|
+
init_openrouter_base_url();
|
|
34
37
|
init_secret_scrubber();
|
|
35
38
|
var CLAUDE_CLI_TIMEOUT_MS = 30000;
|
|
36
39
|
function stripJsonFences(raw) {
|
|
@@ -169,10 +172,12 @@ ${claudeUserPrompt}`, cred.modelDefault, opts.signal, jsonSchema);
|
|
|
169
172
|
console.error(scrubSecrets(`internal-ai: unknown model ${provider}/${modelId} (callerTag=${callerTag})`));
|
|
170
173
|
return null;
|
|
171
174
|
}
|
|
172
|
-
const
|
|
175
|
+
const env = opts.env ?? process.env;
|
|
176
|
+
const openRouterBaseUrl = getOpenRouterBaseUrl(env);
|
|
173
177
|
if (provider === "openrouter" && openRouterBaseUrl !== DEFAULT_OPENROUTER_BASE_URL) {
|
|
174
178
|
model = { ...model, baseUrl: openRouterBaseUrl };
|
|
175
179
|
}
|
|
180
|
+
const headers = provider === "openrouter" ? getOpenRouterAttributionHeaders(model.baseUrl, env) : {};
|
|
176
181
|
const completeFn = opts._complete ?? complete;
|
|
177
182
|
const toolChoice = model.api === "anthropic-messages" ? { type: "tool", name: opts.toolName } : "required";
|
|
178
183
|
let userPrompt = opts.userPrompt;
|
|
@@ -189,7 +194,7 @@ ${claudeUserPrompt}`, cred.modelDefault, opts.signal, jsonSchema);
|
|
|
189
194
|
parameters: opts.toolSchema
|
|
190
195
|
}
|
|
191
196
|
]
|
|
192
|
-
}, { apiKey: cred.apiKey, signal: opts.signal, toolChoice });
|
|
197
|
+
}, { apiKey: cred.apiKey, signal: opts.signal, toolChoice, headers });
|
|
193
198
|
const toolCall = msg.content.find((c) => c.type === "toolCall" && c.name === opts.toolName);
|
|
194
199
|
if (!toolCall) {
|
|
195
200
|
const assistantText = msg.content.filter((content) => content.type === "text").map((content) => content.text).join(`
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
imageFallback,
|
|
8
8
|
resolvePath,
|
|
9
9
|
truncateToWidth
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-5t5my0h8.js";
|
|
11
11
|
|
|
12
12
|
// node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.js
|
|
13
13
|
import { randomBytes } from "node:crypto";
|
|
@@ -414,14 +414,25 @@ class VisualLinePreview {
|
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
// node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.js
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
417
|
+
var ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
418
|
+
var OSC_START = "\\u001B\\]";
|
|
419
|
+
var CSI_START = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?";
|
|
420
|
+
var CSI_FINAL = "[\\dA-PR-TZcf-nq-uy=><~]";
|
|
421
|
+
var ansiRegex = new RegExp(`(?:${OSC_START}[\\s\\S]*?${ST})|${CSI_START}${CSI_FINAL}`, "g");
|
|
422
|
+
var unfinishedAnsiAtEndRegex = new RegExp(`(?:${OSC_START}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${CSI_START})$`);
|
|
423
|
+
var MAX_PENDING_ANSI_LENGTH = 256;
|
|
424
|
+
function splitIncompleteAnsiSuffix(value) {
|
|
425
|
+
if (!value.includes("\x1B") && !value.includes("")) {
|
|
426
|
+
return { complete: value, pending: "" };
|
|
427
|
+
}
|
|
428
|
+
const windowStart = Math.max(0, value.length - MAX_PENDING_ANSI_LENGTH);
|
|
429
|
+
const match = unfinishedAnsiAtEndRegex.exec(value.slice(windowStart));
|
|
430
|
+
if (!match) {
|
|
431
|
+
return { complete: value, pending: "" };
|
|
432
|
+
}
|
|
433
|
+
const splitAt = windowStart + match.index;
|
|
434
|
+
return { complete: value.slice(0, splitAt), pending: value.slice(splitAt) };
|
|
435
|
+
}
|
|
425
436
|
function stripAnsi(value) {
|
|
426
437
|
if (typeof value !== "string") {
|
|
427
438
|
throw new TypeError(`Expected a \`string\`, got \`${typeof value}\``);
|
|
@@ -429,7 +440,7 @@ function stripAnsi(value) {
|
|
|
429
440
|
if (!value.includes("\x1B") && !value.includes("")) {
|
|
430
441
|
return value;
|
|
431
442
|
}
|
|
432
|
-
return value.replace(
|
|
443
|
+
return value.replace(ansiRegex, "");
|
|
433
444
|
}
|
|
434
445
|
|
|
435
446
|
// node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.js
|
|
@@ -518,4 +529,4 @@ function renderToolPath(rawPath, theme, cwd, options) {
|
|
|
518
529
|
return linkPath(theme.fg("accent", shortenPath(value)), value, cwd);
|
|
519
530
|
}
|
|
520
531
|
|
|
521
|
-
export { stripAnsi, writeOutputFile, createOutputFileStream, getShellConfig, getPowerShellConfig, getShellEnv, sanitizeBinaryOutput, trackDetachedChildPid, untrackDetachedChildPid, killTrackedDetachedChildren, killProcessTree, DEFAULT_MAX_LINES, DEFAULT_MAX_BYTES, GREP_MAX_LINE_LENGTH, formatSize, truncateHead, truncateTail, truncateLine, truncateMiddle, truncateToVisualLines, VisualLinePreview, shortenPath, str, replaceTabs, normalizeDisplayText, getTextOutput, formatToolCallWithArgs, invalidArgText, renderToolPath };
|
|
532
|
+
export { splitIncompleteAnsiSuffix, stripAnsi, writeOutputFile, createOutputFileStream, getShellConfig, getPowerShellConfig, getShellEnv, sanitizeBinaryOutput, trackDetachedChildPid, untrackDetachedChildPid, killTrackedDetachedChildren, killProcessTree, DEFAULT_MAX_LINES, DEFAULT_MAX_BYTES, GREP_MAX_LINE_LENGTH, formatSize, truncateHead, truncateTail, truncateLine, truncateMiddle, truncateToVisualLines, VisualLinePreview, shortenPath, str, replaceTabs, normalizeDisplayText, getTextOutput, formatToolCallWithArgs, invalidArgText, renderToolPath };
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getTextOutput,
|
|
4
4
|
replaceTabs,
|
|
5
5
|
str
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-rhy7z1rp.js";
|
|
7
7
|
import {
|
|
8
8
|
Container,
|
|
9
9
|
Spacer,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getDocsPath,
|
|
12
12
|
highlightCode,
|
|
13
13
|
keyHint
|
|
14
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-5t5my0h8.js";
|
|
15
15
|
import {
|
|
16
16
|
exports_typebox
|
|
17
17
|
} from "./cli-rb9m6rpe.js";
|
|
@@ -613,7 +613,7 @@ function createToolDefinitionFromAgentTool(tool) {
|
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
// node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.lazy.js
|
|
616
|
-
var loadCodemodeExecutor = () => import("./execute-
|
|
616
|
+
var loadCodemodeExecutor = () => import("./execute-h4jgevyw.js");
|
|
617
617
|
|
|
618
618
|
// node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.js
|
|
619
619
|
var CODE_PREVIEW_LINES = 10;
|
|
@@ -755,9 +755,9 @@ var DESCRIPTION_INTRO = `Run JavaScript that calls other tools. The input is raw
|
|
|
755
755
|
function describeGlobals(models) {
|
|
756
756
|
const lines = [
|
|
757
757
|
"Globals:",
|
|
758
|
-
"- `text(value)`, `image(dataUrlOrImageBlock)`, `console.log(...)`, and top-level `return` add output; `exit()` ends the script. `image()` also saves the image to a temp file and the result names its path.",
|
|
758
|
+
"- `text(value)`, `image(dataUrlOrImageBlock)`, `console.log(...)`, and top-level `return` add output; `exit()` ends the script. With several text items, each starts with a `==> text N/M <==` line, and `console` lines follow the other output in one `<console_output>` block. `image()` also saves the image to a temp file and the result names its path.",
|
|
759
759
|
"- `store(key, value)` and `load(key)` keep JSON values across codemode calls.",
|
|
760
|
-
"- `ALL_TOOLS`, `searchTools(query, { limit?, namespace? })`, `describeTool(name)`, `describeNamespace(name)`: find unlisted tools, such as MCP tools."
|
|
760
|
+
"- `ALL_TOOLS`, `await searchTools(query, { limit?, namespace? })`, `await describeTool(name)`, `await describeNamespace(name)`: find unlisted tools, such as MCP tools."
|
|
761
761
|
];
|
|
762
762
|
if (models) {
|
|
763
763
|
lines.push(`- \`models\`: classifiers and image generation. Read ${CODEMODE_DOCS_PATH} first.`);
|
|
@@ -4,27 +4,27 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
readPkgVersion
|
|
6
6
|
} from "./cli-gt4hxb8p.js";
|
|
7
|
+
import {
|
|
8
|
+
checkToolLoop
|
|
9
|
+
} from "./cli-hp1n6zq3.js";
|
|
7
10
|
import {
|
|
8
11
|
CONTEXT_FORMULA,
|
|
9
12
|
clampContextPercent,
|
|
10
13
|
computeContextUsedUnified,
|
|
11
14
|
getContextWindowSize
|
|
12
|
-
} from "./cli-
|
|
13
|
-
import {
|
|
14
|
-
checkToolLoop
|
|
15
|
-
} from "./cli-hp1n6zq3.js";
|
|
15
|
+
} from "./cli-7avy4v8w.js";
|
|
16
16
|
import {
|
|
17
17
|
Anthropic
|
|
18
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-5qkcdv8c.js";
|
|
19
19
|
import {
|
|
20
20
|
init_runtime_model_catalog,
|
|
21
21
|
init_src,
|
|
22
22
|
runtimeCatalogModel
|
|
23
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-014vns2y.js";
|
|
24
24
|
import {
|
|
25
25
|
init_secret_scrubber,
|
|
26
26
|
scrubSecrets
|
|
27
|
-
} from "./cli-
|
|
27
|
+
} from "./cli-wt7ccy4r.js";
|
|
28
28
|
|
|
29
29
|
// src/providers/claude-managed-adapter.ts
|
|
30
30
|
init_secret_scrubber();
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
seedPricingFromModelsDev
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-v1pwxreq.js";
|
|
4
4
|
import {
|
|
5
5
|
ensureRbacSeedsSynced,
|
|
6
6
|
init_rbac_roles
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-ypgba1a8.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb,
|
|
10
|
-
init_db
|
|
11
|
-
} from "./cli-
|
|
10
|
+
init_db1 as init_db
|
|
11
|
+
} from "./cli-mkdsy1nq.js";
|
|
12
12
|
|
|
13
13
|
// src/be/boot-seeds.ts
|
|
14
14
|
init_db();
|