@desplega.ai/agent-swarm 1.158.0 → 1.160.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/README.md +1 -1
- package/dist/{acp-adapter-xaq4n6pc.js → acp-adapter-2mjwcsfh.js} +124 -27
- package/dist/{actions-p9hz5yat.js → actions-e43rxskr.js} +35 -30
- package/dist/{anthropic-messages-51pz26qe.js → anthropic-messages-5qx80j9k.js} +106 -16
- package/dist/{app-g26wdcz6.js → app-mc7xfagn.js} +12 -10
- package/dist/{assistant-wydfqkb3.js → assistant-sedkzv3b.js} +42 -31
- package/dist/{azure-openai-responses-8gksqtmz.js → azure-openai-responses-nfb21z9a.js} +13 -14
- package/dist/{boot-reembed-se8zmdcp.js → boot-reembed-cqz9swn5.js} +13 -12
- package/dist/{boot-reembed-g5ckg9yb.js → boot-reembed-m3656j2n.js} +14 -13
- package/dist/{boot-scrub-logs-wfxqan61.js → boot-scrub-logs-xbxf5d7w.js} +11 -9
- package/dist/boot-seeds-gsetbs5y.js +28 -0
- package/dist/{claude-adapter-tv2x4f36.js → claude-adapter-dc6289mc.js} +28 -23
- package/dist/{claude-managed-adapter-41b2s7fd.js → claude-managed-adapter-naaw51me.js} +4 -3
- package/dist/{claude-managed-setup-60g8aazx.js → claude-managed-setup-eacvchx0.js} +12 -3
- package/dist/claude-sdk-session-bqp2xvym.js +29722 -0
- package/dist/{cli-987hg0aa.js → cli-0jwe9034.js} +2 -2
- package/dist/{cli-vj6h9kc2.js → cli-0m7wct0d.js} +59 -1
- package/dist/{cli-c07r9a2m.js → cli-0q3avq3s.js} +12 -11
- package/dist/{cli-19jenss3.js → cli-0wgxmwf6.js} +31 -10
- package/dist/cli-0x01kwrd.js +491 -0
- package/dist/cli-0xqde53b.js +176 -0
- package/dist/cli-10nhj6xq.js +8355 -0
- package/dist/{cli-tt9k8r35.js → cli-12tszpk9.js} +479 -910
- package/dist/{cli-5b6b62tz.js → cli-13hw4z91.js} +1 -1
- package/dist/{cli-cqt19wg6.js → cli-1a2j50m0.js} +11 -2
- package/dist/{cli-xberxa1r.js → cli-25fcq4b4.js} +2 -2
- package/dist/{cli-npssxgaz.js → cli-2pdaysab.js} +52 -2
- package/dist/cli-3qhyh31j.js +166 -0
- package/dist/cli-447dt1h3.js +3828 -0
- package/dist/cli-4derpgyk.js +115 -0
- package/dist/{cli-00w2c66p.js → cli-523679eh.js} +13 -2
- package/dist/{cli-y95wp3tg.js → cli-58e8yr0d.js} +1 -1
- package/dist/{cli-24k806sc.js → cli-5nbmpy8w.js} +3 -3
- package/dist/{cli-53sz8gkz.js → cli-6cs6wzxt.js} +1 -1
- package/dist/cli-741yb0xx.js +1027 -0
- package/dist/cli-74h9hscv.js +69 -0
- package/dist/cli-7cxw8b60.js +14910 -0
- package/dist/{cli-xhaeg2nc.js → cli-7e398j1h.js} +1 -1
- package/dist/cli-7kyk9jr3.js +22 -0
- package/dist/cli-89s4ngw3.js +183 -0
- package/dist/{cli-9b13ggd1.js → cli-89v6kyq7.js} +1 -0
- package/dist/{cli-ftfvggzx.js → cli-9hsgwz4w.js} +1045 -581
- package/dist/{cli-rqz8qbw7.js → cli-a8dvhzrt.js} +59 -20
- package/dist/{cli-j57qkrpq.js → cli-azhgzetg.js} +395 -56
- package/dist/cli-br0qdrnp.js +2150 -0
- package/dist/{cli-rj19hc34.js → cli-btfv8y88.js} +1 -1
- package/dist/{cli-8qmme6vd.js → cli-c8a36vcc.js} +2 -2
- package/dist/cli-cpvsaqsw.js +333 -0
- package/dist/cli-d5czme6m.js +17805 -0
- package/dist/{cli-h38x0qhg.js → cli-et8m9xsv.js} +4 -3
- package/dist/{cli-x24pshtq.js → cli-evvtk35y.js} +6 -6
- package/dist/{cli-7s3syk22.js → cli-f8gy6r2r.js} +5 -5
- package/dist/{cli-zt1227k1.js → cli-fkqhbg8g.js} +5 -3
- package/dist/{cli-9httdpyq.js → cli-g2whhdrf.js} +1 -1
- package/dist/cli-gt4hxb8p.js +99 -0
- package/dist/{cli-s8eet254.js → cli-jajnsm8q.js} +37184 -53838
- package/dist/{cli-7gtvvpbh.js → cli-jayjpjmb.js} +21 -12
- package/dist/{cli-68w09sjw.js → cli-jyk0ynw2.js} +27 -89
- package/dist/{cli-aehm1rbq.js → cli-jz4w45qt.js} +1152 -61
- package/dist/cli-kmcpfwn2.js +333856 -0
- package/dist/{cli-4198qc9v.js → cli-ktmyrtpn.js} +19 -3
- package/dist/{cli-j55n64b6.js → cli-mfe5btp9.js} +505 -189
- package/dist/{cli-q67y4wzm.js → cli-phsaj4xq.js} +24 -2
- package/dist/{cli-1hkrch3k.js → cli-pm1rst0h.js} +46 -7
- package/dist/{cli-pw9rj5t9.js → cli-pqetb83f.js} +1 -176
- package/dist/{cli-ggm92wcn.js → cli-ptr8h7kp.js} +20 -1
- package/dist/{cli-s8s499xy.js → cli-qbksc292.js} +3 -2
- package/dist/{cli-47m6dkd3.js → cli-qydf22qq.js} +597 -346
- package/dist/{cli-3gmcwfyx.js → cli-r1mxd1xh.js} +13 -6
- package/dist/cli-rb9m6rpe.js +4980 -0
- package/dist/cli-rykfmgwg.js +102 -0
- package/dist/{cli-5d10vd2m.js → cli-shkxm1vn.js} +6 -5
- package/dist/{cli-eetrvv91.js → cli-t3p77qk1.js} +1 -1
- package/dist/cli-tfky2838.js +756 -0
- package/dist/{cli-g8djp6qe.js → cli-tmqt7dpj.js} +40 -0
- package/dist/{cli-fgqxwrpv.js → cli-tpq83z89.js} +1631 -127
- package/dist/cli-trc24wk2.js +143 -0
- package/dist/{cli-aky8tctm.js → cli-tzx2ke1v.js} +3 -3
- package/dist/cli-v7fn5gms.js +1425 -0
- package/dist/{cli-wscdvcqz.js → cli-vctdqs5h.js} +1 -1
- package/dist/{cli-cw9zck8j.js → cli-xjcywfsf.js} +8 -4
- package/dist/{cli-k0g1sjzm.js → cli-ybgv4kw2.js} +18 -11
- package/dist/{cli-rjehvrts.js → cli-ydmcgve1.js} +8 -8
- package/dist/{cli-vhjwh6cz.js → cli-ygwm91nt.js} +1 -1
- package/dist/{cli-mcnhgnn1.js → cli-ykk5jaax.js} +184 -26
- package/dist/{cli-de1396j2.js → cli-ywybs5as.js} +7 -1
- package/dist/cli-zpep9q5e.js +491 -0
- package/dist/cli.js +41 -32
- package/dist/cloudflare-workers-ai-system-one-k6fbxw9d.js +46 -0
- package/dist/{codex-adapter-cnm8wk11.js → codex-adapter-nmxcatww.js} +26 -17
- package/dist/{codex-hook-9hptmdhj.js → codex-hook-20me6byw.js} +2 -2
- package/dist/{codex-login-x3jk4etn.js → codex-login-w6fz4xbz.js} +50 -5
- package/dist/{codex-session-runner-gfg547zj.js → codex-session-runner-90aa80ev.js} +24 -17
- package/dist/{commands-e3bn0p75.js → commands-8wcq1kn7.js} +11 -9
- package/dist/{db-03v9kzr2.js → db-j40kc4se.js} +25 -11
- package/dist/{devin-adapter-8vgkwh29.js → devin-adapter-dpsv6hd9.js} +1 -1
- package/dist/{dispatcher-nrmg8yht.js → dispatcher-4zqy768d.js} +34 -29
- package/dist/{dsh-adapter-k03nfqa6.js → dsh-adapter-mpnzgztj.js} +3 -3
- package/dist/{e2b-93x1k0j5.js → e2b-ez07znam.js} +4 -3
- package/dist/execute-6e7qeyk4.js +1017 -0
- package/dist/{google-generative-ai-bxmv50nc.js → google-generative-ai-k6n5nbpp.js} +6 -5
- package/dist/{google-vertex-809af514.js → google-vertex-44xxtcvp.js} +6 -5
- package/dist/{handlers-aqcedbyb.js → handlers-kjdce1w5.js} +37 -32
- package/dist/{hook-ybvmrmhq.js → hook-czx13n12.js} +19 -15
- package/dist/{hook-7vkskkre.js → hook-r2t4bqfg.js} +18 -14
- package/dist/{http-2eqa8t24.js → http-3bbb19be.js} +900 -145
- package/dist/{index-f6cryxwe.js → index-4a5njnm1.js} +2 -59
- package/dist/{index-x71bvq0p.js → index-668me3f0.js} +35 -30
- package/dist/{index-c6zsv1bd.js → index-7aj368tw.js} +13 -12
- package/dist/{index-1yks3qcr.js → index-fg0dsp6c.js} +34 -29
- package/dist/{index-chgdkq36.js → index-kkv84jq9.js} +34 -29
- package/dist/{index-a3vn96n8.js → index-zg7vp46x.js} +198 -54
- package/dist/{keepalive-vtkf5n99.js → keepalive-yra8dy57.js} +13 -11
- package/dist/{lead-h3sp357x.js → lead-va0pad2c.js} +54 -49
- package/dist/llama-cpp-classify-tgj35k8d.js +335 -0
- package/dist/{maintenance-jzeqtk3q.js → maintenance-hqewtmyg.js} +14 -13
- package/dist/{mistral-conversations-zx0kn554.js → mistral-conversations-pc3ntnxt.js} +14 -17
- package/dist/{oauth-refresh-sweep-qp3dzmdp.js → oauth-refresh-sweep-7rdt1m9n.js} +12 -10
- package/dist/{onboard-tmsp0qbz.js → onboard-j6ms6d0x.js} +6 -5
- package/dist/{openai-codex-responses-4vjqzvjp.js → openai-codex-responses-bbancrr0.js} +21 -8
- package/dist/{openai-completions-9hjrqbw8.js → openai-completions-jpaj5g2b.js} +9 -12
- package/dist/{openai-responses-7b1pn0xt.js → openai-responses-200k1wx4.js} +23 -18
- package/dist/{opencode-adapter-x6x2da1z.js → opencode-adapter-89rabkw2.js} +8 -7
- package/dist/{openrouter-images-9f9ek4rw.js → openrouter-images-8yx3487g.js} +5 -7
- package/dist/{otel-impl-9mz73q65.js → otel-impl-a792rjz0.js} +1 -1
- package/dist/{pi-messages-txpjj39q.js → pi-messages-vxdt8v7j.js} +2 -1
- package/dist/{pi-mono-adapter-m6dvv0dz.js → pi-mono-adapter-g7qzvr3v.js} +295 -70
- package/dist/pricing-refresh-wx0tp7cb.js +39 -0
- package/dist/quickjs-r1pq2107.wasm +0 -0
- package/dist/{rbac-roles-c9wqz83x.js → rbac-roles-8tzawacv.js} +12 -10
- package/dist/{render-v2-gryrh9h8.js → render-v2-mm7zswb8.js} +12 -10
- package/dist/runtime-zyssgse0.js +24 -0
- package/dist/{setup-q9720bt6.js → setup-8y70ys6t.js} +6 -5
- package/dist/typesafe-system-one-2ef30pec.js +27 -0
- package/dist/{virtual-modules-3htpgn8x.js → virtual-modules-6nmk7h3n.js} +22 -13
- package/dist/{work-objects-b76x7deb.js → work-objects-fg6xkb0n.js} +37 -32
- package/dist/{worker-6vrxbv41.js → worker-wmwhxsph.js} +54 -49
- package/openapi.json +1314 -91
- package/package.json +12 -11
- package/src/be/db/agents.ts +20 -0
- package/src/be/db/api-keys.ts +70 -0
- package/src/be/db/tasks/human-free.ts +442 -0
- package/src/be/db/tasks/read.ts +56 -1
- package/src/be/db/tasks/write.ts +107 -11
- package/src/be/db.ts +274 -188
- package/src/be/harness-model-support.ts +182 -0
- package/src/be/human-free-drain.ts +67 -0
- package/src/be/memory/providers/sqlite-store.ts +51 -15
- package/src/be/migrations/182_task_human_free_flag.sql +63 -0
- package/src/be/migrations/183_human_free_reclassify_queue.sql +25 -0
- package/src/be/migrations/184_model_catalog.sql +120 -0
- package/src/be/migrations/185_api_key_auth_failures.sql +6 -0
- package/src/be/migrations/186_api_key_seat_mismatch.sql +8 -0
- package/src/be/model-catalog-store.ts +644 -0
- package/src/be/model-tier-keys.ts +46 -0
- package/src/be/model-tier-resolution.ts +534 -0
- package/src/be/model-validation.ts +188 -0
- package/src/be/models-catalog.ts +61 -7
- package/src/be/modelsdev-cache.json +82 -0
- package/src/be/modelsdev-cache.ts +2 -0
- package/src/be/pricing-refresh.ts +154 -12
- package/src/be/scripts/typecheck.ts +15 -0
- package/src/be/seed/runner.ts +18 -12
- package/src/be/seed/types.ts +1 -0
- package/src/be/seed-scripts/catalog/task-failure-audit.ts +61 -9
- package/src/be/swarm-config-guard.ts +8 -0
- package/src/cli.tsx +10 -0
- package/src/commands/claude-managed-setup.ts +3 -1
- package/src/commands/codex-login.ts +67 -0
- package/src/commands/credential-outcome-report.ts +191 -0
- package/src/commands/rate-limit-outcome.ts +34 -4
- package/src/commands/runner.ts +357 -186
- package/src/commands/seat-mismatch-report.ts +46 -0
- package/src/extensions/apply-task-create.ts +27 -1
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/heartbeat/heartbeat.ts +79 -17
- package/src/heartbeat/templates.ts +2 -2
- package/src/http/agents.ts +62 -1
- package/src/http/api-keys.ts +140 -2
- package/src/http/codex-oauth-keep-warm.ts +3 -5
- package/src/http/index.ts +8 -0
- package/src/http/memory.ts +12 -5
- package/src/http/models-catalog.ts +357 -8
- package/src/http/poll.ts +54 -3
- package/src/http/schedules.ts +51 -6
- package/src/http/script-runs.ts +12 -0
- package/src/http/session-data.ts +2 -5
- package/src/http/stats.ts +6 -8
- package/src/http/status.ts +15 -1
- package/src/http/tasks.ts +90 -7
- package/src/http/usage-cache.ts +56 -15
- package/src/http/workflows.ts +46 -8
- package/src/mcp-client/http-client.ts +5 -0
- package/src/memory/recall-query.ts +74 -0
- package/src/prompts/base-prompt.ts +15 -4
- package/src/prompts/session-templates.ts +23 -1
- package/src/providers/acp-adapter.ts +1 -0
- package/src/providers/claude-adapter.ts +14 -5
- package/src/providers/claude-managed-adapter.ts +1 -0
- package/src/providers/claude-managed-models.ts +47 -161
- package/src/providers/claude-sdk-session.ts +3 -1
- package/src/providers/codex-adapter.ts +14 -14
- package/src/providers/codex-models.ts +65 -198
- package/src/providers/devin-adapter.ts +1 -0
- package/src/providers/dsh-adapter.ts +2 -1
- package/src/providers/harness-version.ts +83 -7
- package/src/providers/opencode-adapter.ts +53 -1
- package/src/providers/pi-binary-root/src/extensions/codemode/worker.ts +11 -0
- package/src/providers/pi-codemode-runtime.ts +17 -0
- package/src/providers/pi-mono-adapter.ts +361 -83
- package/src/providers/pi-mono-extension.ts +16 -1
- package/src/providers/reasoning-effort.ts +44 -140
- package/src/providers/types.ts +8 -0
- package/src/rbac/legacy-policy.ts +43 -0
- package/src/rbac/permissions.ts +15 -0
- package/src/scripts-runtime/sdk-allowlist.ts +4 -0
- package/src/scripts-runtime/types/stdlib.d.ts +15 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +3 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +15 -0
- package/src/server.ts +6 -0
- package/src/slack/assistant.ts +13 -0
- package/src/slack/message-text.ts +56 -2
- package/src/slack/render-v2.ts +87 -37
- package/src/slack/session-status.ts +541 -0
- package/src/slack/thread-buffer.ts +10 -2
- package/src/tasks/sibling-awareness.ts +3 -2
- package/src/telemetry.ts +5 -4
- package/src/templates.d.ts +6 -0
- package/src/tests/agents-list-model-display.test.ts +4 -6
- package/src/tests/api-key-auth-failure-route.test.ts +142 -0
- package/src/tests/api-key-tracking.test.ts +368 -1
- package/src/tests/base-prompt.test.ts +43 -2
- package/src/tests/claude-adapter.test.ts +68 -0
- package/src/tests/claude-managed-adapter.test.ts +12 -18
- package/src/tests/codex-adapter.test.ts +2 -1
- package/src/tests/codex-auth-failure.test.ts +52 -0
- package/src/tests/codex-gpt6-release.test.ts +66 -5
- package/src/tests/codex-login.test.ts +116 -0
- package/src/tests/context-window.test.ts +7 -5
- package/src/tests/credential-exhaustion-policy.test.ts +118 -3
- package/src/tests/credential-outcome-report.test.ts +171 -0
- package/src/tests/credential-status-api.test.ts +103 -2
- package/src/tests/db-extraction-contract.test.ts +1 -0
- package/src/tests/db-task-read-contract.test.ts +10 -1
- package/src/tests/db-task-write-contract.test.ts +535 -2
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dokploy-deploy.test.ts +315 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/explicit-model-validation.test.ts +583 -0
- package/src/tests/extensions-pre-task.test.ts +73 -0
- package/src/tests/fetch-resolved-env.test.ts +46 -0
- package/src/tests/hang-watchdog-worker.ts +47 -0
- package/src/tests/hang-watchdog.test.ts +45 -0
- package/src/tests/hang-watchdog.ts +30 -0
- package/src/tests/harness-model-guard.test.ts +123 -0
- package/src/tests/harness-model-support.test.ts +374 -0
- package/src/tests/harness-version.test.ts +70 -3
- package/src/tests/heartbeat-checklist-config.test.ts +71 -0
- package/src/tests/heartbeat-checklist.test.ts +4 -2
- package/src/tests/heartbeat-orphan-resume.test.ts +48 -0
- package/src/tests/http-task-write-ownership.test.ts +172 -0
- package/src/tests/human-free-flag.test.ts +279 -0
- package/src/tests/human-free-oracle.ts +57 -0
- package/src/tests/human-free-reclassify.test.ts +669 -0
- package/src/tests/memory-fts-populate.test.ts +139 -0
- package/src/tests/memory-http-recall-gating.test.ts +125 -1
- package/src/tests/migration-046-budgets.test.ts +3 -3
- package/src/tests/model-catalog-migration.test.ts +134 -0
- package/src/tests/model-catalog-table.test.ts +249 -0
- package/src/tests/model-catalog-write-access.test.ts +387 -0
- package/src/tests/model-rate-limit-windows.test.ts +19 -0
- package/src/tests/model-tier-resolution.test.ts +611 -0
- package/src/tests/models-catalog.test.ts +1 -1
- package/src/tests/multi-runtime-enabled-stats.test.ts +65 -1
- package/src/tests/opencode-adapter.test.ts +157 -2
- package/src/tests/package-publish.test.ts +137 -36
- package/src/tests/pi-codemode.test.ts +246 -0
- package/src/tests/pi-mono-adapter.test.ts +3 -0
- package/src/tests/pi-native-mcp.test.ts +193 -0
- package/src/tests/pi-tool-exposure.test.ts +374 -0
- package/src/tests/preload.ts +3 -0
- package/src/tests/pricing-routes.test.ts +2 -2
- package/src/tests/prompt-template-session.test.ts +5 -3
- package/src/tests/rate-limit-event.test.ts +65 -0
- package/src/tests/rate-limit-outcome.test.ts +90 -0
- package/src/tests/rbac-engine.test.ts +77 -3
- package/src/tests/reasoning-effort.test.ts +109 -0
- package/src/tests/refresh-modelsdev-carryforward.test.ts +5 -5
- package/src/tests/runner-key-completion-outcome.test.ts +112 -0
- package/src/tests/runner-key-outcome-late-reset.test.ts +224 -0
- package/src/tests/runner-registration-retry.test.ts +149 -0
- package/src/tests/runtime-model-catalog.test.ts +86 -0
- package/src/tests/script-connections.test.ts +9 -0
- package/src/tests/seat-mismatch-report.test.ts +85 -0
- package/src/tests/seed-scripts.test.ts +138 -0
- package/src/tests/seed.test.ts +25 -0
- package/src/tests/session-costs.test.ts +14 -11
- package/src/tests/slack-message-text.test.ts +101 -0
- package/src/tests/slack-render-v2.test.ts +96 -0
- package/src/tests/slack-session-status.test.ts +626 -0
- package/src/tests/slack-thread-buffer-context.test.ts +93 -0
- package/src/tests/status.test.ts +29 -0
- package/src/tests/steering-promotion.test.ts +51 -0
- package/src/tests/store-progress-ownership.test.ts +136 -0
- package/src/tests/subscription-plans.test.ts +28 -0
- package/src/tests/task-cascade-fail.test.ts +148 -2
- package/src/tests/task-citations.test.ts +3 -2
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/usage-cache.test.ts +166 -0
- package/src/tests/workflow-agent-task.test.ts +30 -0
- package/src/tests/workflow-executors.test.ts +5 -2
- package/src/tests/workflow-system-one-decision-review.test.ts +1021 -0
- package/src/tests/workflow-system-one-decision-save-warnings.test.ts +365 -0
- package/src/tests/workflow-system-one-decision.test.ts +2063 -0
- package/src/tests/workflow-triggers-v2.test.ts +320 -0
- package/src/tools/model-catalog/index.ts +137 -0
- package/src/tools/schedules/create-schedule.ts +17 -2
- package/src/tools/schedules/patch-schedule.ts +31 -1
- package/src/tools/schedules/update-schedule.ts +31 -1
- package/src/tools/send-task.ts +18 -1
- package/src/tools/store-progress.ts +49 -4
- package/src/tools/task-action.ts +14 -1
- package/src/tools/tool-config.ts +3 -1
- package/src/tools/workflows/create-workflow.ts +17 -4
- package/src/tools/workflows/patch-workflow-node.ts +17 -7
- package/src/tools/workflows/patch-workflow.ts +9 -2
- package/src/tools/workflows/update-workflow.ts +17 -4
- package/src/types.ts +41 -1
- package/src/utils/codex-auth-failure.ts +34 -0
- package/src/utils/context-window.ts +47 -53
- package/src/utils/credentials.ts +72 -30
- package/src/utils/error-tracker.ts +80 -0
- package/src/utils/harness-cli-version.ts +115 -0
- package/src/utils/harness-model-error.ts +33 -0
- package/src/utils/model-rate-limit-windows.ts +12 -0
- package/src/utils/runtime-model-catalog.ts +152 -0
- package/src/utils/spawn-model-guard.ts +43 -0
- package/src/utils/subscription-plans.ts +22 -0
- package/src/workflows/approval-resolution.ts +39 -0
- package/src/workflows/definition.ts +7 -0
- package/src/workflows/engine.ts +69 -1
- package/src/workflows/executors/agent-task.ts +16 -6
- package/src/workflows/executors/base.ts +53 -0
- package/src/workflows/executors/human-in-the-loop.ts +8 -8
- package/src/workflows/executors/index.ts +1 -0
- package/src/workflows/executors/registry.ts +2 -0
- package/src/workflows/executors/system-one-decision.ts +1232 -0
- package/src/workflows/executors/system-one-providers.ts +301 -0
- package/src/workflows/executors/workflow-llm.ts +13 -1
- package/src/workflows/model-validation.ts +45 -0
- package/src/workflows/patch-definition.ts +5 -0
- package/src/workflows/readiness.ts +86 -0
- package/src/workflows/recovery.ts +12 -12
- package/src/workflows/resume.ts +23 -9
- package/src/workflows/triggers.ts +85 -0
- package/templates/schedules/daily-blocker-digest/content.md +4 -5
- package/templates/skills/agent-browser/SKILL.md +6 -5
- package/templates/skills/agent-browser/content.md +6 -5
- package/templates/skills/heartbeat-runbook/config.json +1 -1
- package/templates/skills/heartbeat-runbook/content.md +2 -2
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/templates/skills/workflow-iterate/content.md +82 -1
- package/templates/workflows/claude-code-changelog-watch/content.md +2 -0
- package/templates/workflows/pr-review-status-sweep/content.md +2 -0
- package/dist/boot-seeds-s3q01xj3.js +0 -26
- package/dist/claude-sdk-session-t442qz6f.js +0 -39108
- package/dist/cli-0xjkj1j7.js +0 -61
- package/dist/cli-20cj37vt.js +0 -335561
- package/dist/cli-2djtr51b.js +0 -48
- package/dist/cli-65hjmev5.js +0 -1141
- package/dist/cli-aw1jwp1r.js +0 -14075
- package/dist/cli-h967nb6r.js +0 -6603
- package/dist/cli-vapyk8sw.js +0 -20
- package/dist/cli-ws6rqycm.js +0 -247
- package/dist/pricing-refresh-v1cbr9te.js +0 -27
- package/src/providers/modelsdev-reasoning.json +0 -6453
- package/dist/{index-f24115ge.js → index-2wsdsnmm.js} +3 -3
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
renderSteeringDelivery
|
|
3
|
-
} from "./cli-y95wp3tg.js";
|
|
4
|
-
import {
|
|
5
|
-
checkDevinCredentials
|
|
6
|
-
} from "./cli-9b13ggd1.js";
|
|
7
|
-
import {
|
|
8
|
-
checkOpencodeCredentials
|
|
9
|
-
} from "./cli-1hkrch3k.js";
|
|
10
1
|
import {
|
|
11
2
|
checkDshCredentials
|
|
12
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-shkxm1vn.js";
|
|
4
|
+
import {
|
|
5
|
+
renderSteeringDelivery
|
|
6
|
+
} from "./cli-58e8yr0d.js";
|
|
13
7
|
import {
|
|
14
8
|
checkCodexCredentials,
|
|
15
9
|
codexUserHome
|
|
16
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-br0qdrnp.js";
|
|
17
11
|
import {
|
|
18
12
|
checkClaudeManagedCredentials
|
|
19
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-jyk0ynw2.js";
|
|
14
|
+
import {
|
|
15
|
+
checkDevinCredentials
|
|
16
|
+
} from "./cli-89v6kyq7.js";
|
|
17
|
+
import {
|
|
18
|
+
checkOpencodeCredentials
|
|
19
|
+
} from "./cli-pm1rst0h.js";
|
|
20
20
|
import {
|
|
21
|
+
isUnknownModelError,
|
|
21
22
|
renderMemoriesPrompt,
|
|
22
23
|
writeSkillsToFilesystem
|
|
23
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-phsaj4xq.js";
|
|
24
25
|
import {
|
|
25
26
|
checkClaudeCredentials
|
|
26
|
-
} from "./cli-
|
|
27
|
+
} from "./cli-jayjpjmb.js";
|
|
27
28
|
import {
|
|
28
29
|
getContextWindowSize
|
|
29
|
-
} from "./cli-
|
|
30
|
+
} from "./cli-74h9hscv.js";
|
|
30
31
|
import {
|
|
31
32
|
CODEX_CREDITS_EXHAUSTED_COOLDOWN_MS,
|
|
32
33
|
MAX_RATE_LIMIT_RESET_MS,
|
|
@@ -34,25 +35,25 @@ import {
|
|
|
34
35
|
isRateLimitMessage,
|
|
35
36
|
parseRateLimitResetTime,
|
|
36
37
|
resolveCodexCreditsExhaustedCooldownMs
|
|
37
|
-
} from "./cli-
|
|
38
|
+
} from "./cli-2pdaysab.js";
|
|
38
39
|
import {
|
|
39
40
|
resolveScriptsOnlyMode,
|
|
40
41
|
validateJsonSchema
|
|
41
|
-
} from "./cli-
|
|
42
|
+
} from "./cli-9hsgwz4w.js";
|
|
43
|
+
import {
|
|
44
|
+
terminateRegisteredProcessGroups
|
|
45
|
+
} from "./cli-y89t4nca.js";
|
|
46
|
+
import {
|
|
47
|
+
getApiKey
|
|
48
|
+
} from "./cli-f14fvzag.js";
|
|
42
49
|
import {
|
|
43
50
|
authJsonToCredentialSelection,
|
|
44
51
|
credentialsToAuthJson,
|
|
45
52
|
loadAllCodexOAuthSlots
|
|
46
|
-
} from "./cli-
|
|
53
|
+
} from "./cli-ygwm91nt.js";
|
|
47
54
|
import {
|
|
48
55
|
getOpenRouterBaseUrl
|
|
49
56
|
} from "./cli-3dpj7atn.js";
|
|
50
|
-
import {
|
|
51
|
-
terminateRegisteredProcessGroups
|
|
52
|
-
} from "./cli-y89t4nca.js";
|
|
53
|
-
import {
|
|
54
|
-
getApiKey
|
|
55
|
-
} from "./cli-f14fvzag.js";
|
|
56
57
|
import {
|
|
57
58
|
buildContextPreamble,
|
|
58
59
|
buildResumeContextPreamble,
|
|
@@ -65,7 +66,7 @@ import {
|
|
|
65
66
|
syncProfileFilesToServer,
|
|
66
67
|
writeIdentityBaselines,
|
|
67
68
|
writeProfileFileFromDb
|
|
68
|
-
} from "./cli-
|
|
69
|
+
} from "./cli-25fcq4b4.js";
|
|
69
70
|
import {
|
|
70
71
|
ensure,
|
|
71
72
|
initOtel,
|
|
@@ -75,21 +76,24 @@ import {
|
|
|
75
76
|
startSpan,
|
|
76
77
|
withSpan,
|
|
77
78
|
withSpanContext
|
|
78
|
-
} from "./cli-
|
|
79
|
+
} from "./cli-azhgzetg.js";
|
|
79
80
|
import {
|
|
80
81
|
init_task_attachment_links,
|
|
81
82
|
taskAttachmentFetchCommand
|
|
82
83
|
} from "./cli-2658f6at.js";
|
|
83
84
|
import {
|
|
84
85
|
initTelemetry,
|
|
86
|
+
init_codex_auth_failure,
|
|
85
87
|
init_telemetry,
|
|
88
|
+
isCodexAuthFailureReason,
|
|
86
89
|
telemetry
|
|
87
|
-
} from "./cli-
|
|
90
|
+
} from "./cli-qydf22qq.js";
|
|
88
91
|
import {
|
|
89
92
|
ProviderNameSchema,
|
|
90
93
|
init_types,
|
|
94
|
+
parseWorkerModelTierOverrides,
|
|
91
95
|
resolveTaskModelSelection
|
|
92
|
-
} from "./cli-
|
|
96
|
+
} from "./cli-ktmyrtpn.js";
|
|
93
97
|
import {
|
|
94
98
|
generateDefaultClaudeMd,
|
|
95
99
|
generateDefaultIdentityMd,
|
|
@@ -99,7 +103,7 @@ import {
|
|
|
99
103
|
init_base_prompt,
|
|
100
104
|
init_defaults,
|
|
101
105
|
init_templates
|
|
102
|
-
} from "./cli-
|
|
106
|
+
} from "./cli-r1mxd1xh.js";
|
|
103
107
|
import {
|
|
104
108
|
configureHttpResolver,
|
|
105
109
|
init_resolver,
|
|
@@ -108,21 +112,30 @@ import {
|
|
|
108
112
|
interpolate,
|
|
109
113
|
isSteeringEnabled,
|
|
110
114
|
resolveTemplateAsync
|
|
111
|
-
} from "./cli-
|
|
112
|
-
import {
|
|
113
|
-
ModelWindowExhaustedError,
|
|
114
|
-
init_credentials,
|
|
115
|
-
resolveCredentialPools
|
|
116
|
-
} from "./cli-19jenss3.js";
|
|
115
|
+
} from "./cli-ptr8h7kp.js";
|
|
117
116
|
import {
|
|
118
117
|
getMcpBaseUrl,
|
|
119
118
|
init_constants
|
|
120
119
|
} from "./cli-dv6cdjs2.js";
|
|
120
|
+
import {
|
|
121
|
+
ModelWindowExhaustedError,
|
|
122
|
+
init_credentials,
|
|
123
|
+
resolveCredentialPools
|
|
124
|
+
} from "./cli-0wgxmwf6.js";
|
|
121
125
|
import {
|
|
122
126
|
init_model_rate_limit_windows,
|
|
127
|
+
modelFamilyOf,
|
|
128
|
+
parseCreditsRequiredMessage,
|
|
123
129
|
parseModelLimitMessage,
|
|
124
130
|
windowForModelFamily
|
|
125
|
-
} from "./cli-
|
|
131
|
+
} from "./cli-ywybs5as.js";
|
|
132
|
+
import {
|
|
133
|
+
harnessModelMismatch,
|
|
134
|
+
init_runtime_model_catalog,
|
|
135
|
+
init_src,
|
|
136
|
+
refreshRuntimeModelCatalog,
|
|
137
|
+
runtimeHarnessSections
|
|
138
|
+
} from "./cli-kmcpfwn2.js";
|
|
126
139
|
import {
|
|
127
140
|
init_secret_scrubber,
|
|
128
141
|
scrubSecrets
|
|
@@ -163,35 +176,35 @@ async function materializeCodexAuthJson(_slot, creds, deps = {}) {
|
|
|
163
176
|
async function createProviderAdapter(provider) {
|
|
164
177
|
switch (provider) {
|
|
165
178
|
case "claude": {
|
|
166
|
-
const { ClaudeAdapter } = await import("./claude-adapter-
|
|
179
|
+
const { ClaudeAdapter } = await import("./claude-adapter-dc6289mc.js");
|
|
167
180
|
return new ClaudeAdapter;
|
|
168
181
|
}
|
|
169
182
|
case "pi": {
|
|
170
|
-
const { PiMonoAdapter } = await import("./pi-mono-adapter-
|
|
183
|
+
const { PiMonoAdapter } = await import("./pi-mono-adapter-g7qzvr3v.js");
|
|
171
184
|
return new PiMonoAdapter;
|
|
172
185
|
}
|
|
173
186
|
case "codex": {
|
|
174
|
-
const { CodexAdapter } = await import("./codex-adapter-
|
|
187
|
+
const { CodexAdapter } = await import("./codex-adapter-nmxcatww.js");
|
|
175
188
|
return new CodexAdapter;
|
|
176
189
|
}
|
|
177
190
|
case "claude-managed": {
|
|
178
|
-
const { ClaudeManagedAdapter } = await import("./claude-managed-adapter-
|
|
191
|
+
const { ClaudeManagedAdapter } = await import("./claude-managed-adapter-naaw51me.js");
|
|
179
192
|
return new ClaudeManagedAdapter;
|
|
180
193
|
}
|
|
181
194
|
case "devin": {
|
|
182
|
-
const { DevinAdapter } = await import("./devin-adapter-
|
|
195
|
+
const { DevinAdapter } = await import("./devin-adapter-dpsv6hd9.js");
|
|
183
196
|
return new DevinAdapter;
|
|
184
197
|
}
|
|
185
198
|
case "opencode": {
|
|
186
|
-
const { OpencodeAdapter } = await import("./opencode-adapter-
|
|
199
|
+
const { OpencodeAdapter } = await import("./opencode-adapter-89rabkw2.js");
|
|
187
200
|
return new OpencodeAdapter;
|
|
188
201
|
}
|
|
189
202
|
case "dsh": {
|
|
190
|
-
const { DshAdapter } = await import("./dsh-adapter-
|
|
203
|
+
const { DshAdapter } = await import("./dsh-adapter-mpnzgztj.js");
|
|
191
204
|
return new DshAdapter;
|
|
192
205
|
}
|
|
193
206
|
case "acp": {
|
|
194
|
-
const { ACPAdapter } = await import("./acp-adapter-
|
|
207
|
+
const { ACPAdapter } = await import("./acp-adapter-2mjwcsfh.js");
|
|
195
208
|
return new ACPAdapter;
|
|
196
209
|
}
|
|
197
210
|
default:
|
|
@@ -213,9 +226,86 @@ function computeBudgetBackoffMs(consecutiveRefusals, basePollMs) {
|
|
|
213
226
|
}
|
|
214
227
|
|
|
215
228
|
// src/commands/runner.ts
|
|
229
|
+
init_codex_auth_failure();
|
|
216
230
|
init_constants();
|
|
217
231
|
init_credentials();
|
|
218
232
|
|
|
233
|
+
// src/utils/harness-cli-version.ts
|
|
234
|
+
init_secret_scrubber();
|
|
235
|
+
var CLI_BINARY = { claude: "claude", codex: "codex" };
|
|
236
|
+
var PROBE_TIMEOUT_MS = 1e4;
|
|
237
|
+
var VERSION_RE = /\d+\.\d+\.\d+(?:[-+][\w.]+)?/;
|
|
238
|
+
var probed = new Map;
|
|
239
|
+
function parseCliVersion(output) {
|
|
240
|
+
return VERSION_RE.exec(output)?.[0] ?? null;
|
|
241
|
+
}
|
|
242
|
+
function probeHarnessCliVersion(harness) {
|
|
243
|
+
const binary = CLI_BINARY[harness];
|
|
244
|
+
if (!binary)
|
|
245
|
+
return Promise.resolve(null);
|
|
246
|
+
let pending = probed.get(harness);
|
|
247
|
+
if (!pending) {
|
|
248
|
+
pending = (async () => {
|
|
249
|
+
try {
|
|
250
|
+
const proc = Bun.spawn([binary, "--version"], {
|
|
251
|
+
stdin: "ignore",
|
|
252
|
+
stdout: "pipe",
|
|
253
|
+
stderr: "pipe",
|
|
254
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
255
|
+
killSignal: "SIGKILL"
|
|
256
|
+
});
|
|
257
|
+
const [stdout, exitCode] = await Promise.all([
|
|
258
|
+
new Response(proc.stdout).text(),
|
|
259
|
+
proc.exited
|
|
260
|
+
]);
|
|
261
|
+
return exitCode === 0 ? parseCliVersion(stdout) : null;
|
|
262
|
+
} catch {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
})();
|
|
266
|
+
probed.set(harness, pending);
|
|
267
|
+
}
|
|
268
|
+
return pending;
|
|
269
|
+
}
|
|
270
|
+
async function cachedHarnessCliVersion(harness) {
|
|
271
|
+
return await probed.get(harness) ?? null;
|
|
272
|
+
}
|
|
273
|
+
var reported = new Set;
|
|
274
|
+
async function reportHarnessModelOutcome(opts) {
|
|
275
|
+
if (!opts.model || !CLI_BINARY[opts.harness])
|
|
276
|
+
return;
|
|
277
|
+
const cliVersion = await cachedHarnessCliVersion(opts.harness);
|
|
278
|
+
if (!cliVersion)
|
|
279
|
+
return;
|
|
280
|
+
const status = opts.exitCode === 0 ? "ok" : isUnknownModelError(opts.failureReason, opts.model) ? "unsupported" : null;
|
|
281
|
+
if (!status)
|
|
282
|
+
return;
|
|
283
|
+
const key = `${opts.harness}|${cliVersion}|${opts.model}`;
|
|
284
|
+
if (status === "ok" && reported.has(key))
|
|
285
|
+
return;
|
|
286
|
+
try {
|
|
287
|
+
const headers = {
|
|
288
|
+
"Content-Type": "application/json",
|
|
289
|
+
"X-Agent-ID": opts.agentId
|
|
290
|
+
};
|
|
291
|
+
if (opts.apiKey)
|
|
292
|
+
headers.Authorization = `Bearer ${opts.apiKey}`;
|
|
293
|
+
const res = await (opts.fetchImpl ?? fetch)(`${opts.apiUrl}/api/models-catalog/harness-support`, {
|
|
294
|
+
method: "PUT",
|
|
295
|
+
headers,
|
|
296
|
+
body: JSON.stringify({
|
|
297
|
+
harness: opts.harness,
|
|
298
|
+
cliVersion,
|
|
299
|
+
modelId: opts.model,
|
|
300
|
+
status,
|
|
301
|
+
...status === "unsupported" && opts.failureReason ? { error: scrubSecrets(opts.failureReason).slice(0, 2000) } : {}
|
|
302
|
+
})
|
|
303
|
+
});
|
|
304
|
+
if (res.ok && status === "ok")
|
|
305
|
+
reported.add(key);
|
|
306
|
+
} catch {}
|
|
307
|
+
}
|
|
308
|
+
|
|
219
309
|
// src/utils/harness-provider.ts
|
|
220
310
|
init_types();
|
|
221
311
|
var SUPPORTED_PROVIDERS = ProviderNameSchema.options;
|
|
@@ -439,6 +529,7 @@ function prettyPrintStderr(text, role) {
|
|
|
439
529
|
}
|
|
440
530
|
|
|
441
531
|
// src/commands/runner.ts
|
|
532
|
+
init_runtime_model_catalog();
|
|
442
533
|
init_secret_scrubber();
|
|
443
534
|
|
|
444
535
|
// src/utils/skills-refresh.ts
|
|
@@ -546,6 +637,28 @@ async function refreshSkillsIfChanged(ctx, lastHashRef, homeOverride) {
|
|
|
546
637
|
return { changed: true, summary };
|
|
547
638
|
}
|
|
548
639
|
|
|
640
|
+
// src/utils/spawn-model-guard.ts
|
|
641
|
+
init_src();
|
|
642
|
+
init_runtime_model_catalog();
|
|
643
|
+
function spawnHarnessMismatchReason(model, harness) {
|
|
644
|
+
return `[model-harness-mismatch] Model "${model}" does not run on the ${harness} harness of this worker. The task pinned a model from another harness family. Re-create the task with modelTier or with a ${harness} model.`;
|
|
645
|
+
}
|
|
646
|
+
function guardSpawnModel(input) {
|
|
647
|
+
const { taskModel, configModel, harness, role } = input;
|
|
648
|
+
const sections = runtimeHarnessSections();
|
|
649
|
+
if (taskModel) {
|
|
650
|
+
return harnessModelMismatch(taskModel, harness, sections) ? { kind: "mismatch", reason: spawnHarnessMismatchReason(taskModel, harness) } : { kind: "ok", model: taskModel };
|
|
651
|
+
}
|
|
652
|
+
if (configModel && harnessModelMismatch(configModel, harness, sections)) {
|
|
653
|
+
return {
|
|
654
|
+
kind: "ok",
|
|
655
|
+
model: "",
|
|
656
|
+
warning: `[${role}] MODEL_OVERRIDE ${configModel} does not run on the ${harness} harness; using the adapter default`
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
return { kind: "ok", model: configModel };
|
|
660
|
+
}
|
|
661
|
+
|
|
549
662
|
// src/commands/runner.ts
|
|
550
663
|
init_steering_enabled();
|
|
551
664
|
init_template();
|
|
@@ -588,6 +701,183 @@ ${lines.join(`
|
|
|
588
701
|
// src/commands/runner.ts
|
|
589
702
|
init_context_preamble();
|
|
590
703
|
|
|
704
|
+
// src/commands/credential-outcome-report.ts
|
|
705
|
+
init_model_rate_limit_windows();
|
|
706
|
+
|
|
707
|
+
// src/commands/rate-limit-outcome.ts
|
|
708
|
+
init_model_rate_limit_windows();
|
|
709
|
+
function clampMs(candidateMs, nowMs) {
|
|
710
|
+
const minMs = nowMs + 60000;
|
|
711
|
+
const maxMs = nowMs + MAX_RATE_LIMIT_RESET_MS;
|
|
712
|
+
return Math.min(Math.max(candidateMs, minMs), maxMs);
|
|
713
|
+
}
|
|
714
|
+
function classifyRateLimitOutcome(result, failureReason, nowMs, codexCreditsExhaustedCooldownMs = CODEX_CREDITS_EXHAUSTED_COOLDOWN_MS, taskModelFamily) {
|
|
715
|
+
const keyRateLimitedUntil = result.rateLimitResetAt ? new Date(clampMs(new Date(result.rateLimitResetAt).getTime(), nowMs)).toISOString() : undefined;
|
|
716
|
+
const keyExtra = keyRateLimitedUntil ? { keyRateLimitedUntil } : {};
|
|
717
|
+
if (failureReason != null) {
|
|
718
|
+
const seatFamily = parseCreditsRequiredMessage(failureReason);
|
|
719
|
+
if (seatFamily)
|
|
720
|
+
return { kind: "seat", model: seatFamily, source: "text", ...keyExtra };
|
|
721
|
+
}
|
|
722
|
+
if (result.creditsRequired && taskModelFamily) {
|
|
723
|
+
return { kind: "seat", model: taskModelFamily, source: "event", ...keyExtra };
|
|
724
|
+
}
|
|
725
|
+
if (result.modelRateLimit) {
|
|
726
|
+
const resetsAtSec = Math.floor(new Date(result.modelRateLimit.resetAt).getTime() / 1000);
|
|
727
|
+
const { observedAt } = result.modelRateLimit;
|
|
728
|
+
return {
|
|
729
|
+
kind: "model",
|
|
730
|
+
model: result.modelRateLimit.model,
|
|
731
|
+
window: result.modelRateLimit.window,
|
|
732
|
+
resetsAtSec,
|
|
733
|
+
source: "event",
|
|
734
|
+
...observedAt ? { observedAt } : {},
|
|
735
|
+
...keyExtra
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
if (failureReason != null) {
|
|
739
|
+
const family = parseModelLimitMessage(failureReason);
|
|
740
|
+
const window = family ? windowForModelFamily(family) : undefined;
|
|
741
|
+
if (family && window) {
|
|
742
|
+
const sevenDay = result.rateLimitWindows?.seven_day;
|
|
743
|
+
const sevenDayResetsAtSec = sevenDay && typeof sevenDay.resetsAt === "number" && sevenDay.resetsAt * 1000 > nowMs ? sevenDay.resetsAt : undefined;
|
|
744
|
+
const fallbackResetsAtSec = Math.floor((nowMs + 24 * 60 * 60 * 1000) / 1000);
|
|
745
|
+
const maxResetsAtSec = Math.floor((nowMs + MAX_RATE_LIMIT_RESET_MS) / 1000);
|
|
746
|
+
const resetsAtSec = Math.min(sevenDayResetsAtSec ?? fallbackResetsAtSec, maxResetsAtSec);
|
|
747
|
+
return { kind: "model", model: family, window, resetsAtSec, source: "text", ...keyExtra };
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (result.rateLimitResetAt != null || failureReason != null && isRateLimitMessage(failureReason)) {
|
|
751
|
+
let rateLimitedUntil;
|
|
752
|
+
if (keyRateLimitedUntil) {
|
|
753
|
+
rateLimitedUntil = keyRateLimitedUntil;
|
|
754
|
+
} else if (failureReason != null) {
|
|
755
|
+
const parsedResetTime = parseRateLimitResetTime(failureReason);
|
|
756
|
+
if (parsedResetTime) {
|
|
757
|
+
rateLimitedUntil = new Date(clampMs(new Date(parsedResetTime).getTime(), nowMs)).toISOString();
|
|
758
|
+
} else if (isCodexCreditsExhaustedMessage(failureReason)) {
|
|
759
|
+
rateLimitedUntil = new Date(nowMs + codexCreditsExhaustedCooldownMs).toISOString();
|
|
760
|
+
} else {
|
|
761
|
+
rateLimitedUntil = new Date(nowMs + 5 * 60 * 1000).toISOString();
|
|
762
|
+
}
|
|
763
|
+
} else {
|
|
764
|
+
rateLimitedUntil = new Date(nowMs + 5 * 60 * 1000).toISOString();
|
|
765
|
+
}
|
|
766
|
+
return { kind: "key", rateLimitedUntil };
|
|
767
|
+
}
|
|
768
|
+
return { kind: "none" };
|
|
769
|
+
}
|
|
770
|
+
function buildFinalRateLimitWindows(sessionWindows, outcome, nowIso) {
|
|
771
|
+
if (outcome.kind !== "model")
|
|
772
|
+
return sessionWindows;
|
|
773
|
+
const sessionEntry = sessionWindows?.[outcome.window];
|
|
774
|
+
const sessionRejectedAt = sessionEntry?.status === "rejected" ? sessionEntry.lastSeenAt : undefined;
|
|
775
|
+
const lastSeenAt = outcome.source === "event" ? outcome.observedAt ?? sessionRejectedAt ?? nowIso : nowIso;
|
|
776
|
+
return {
|
|
777
|
+
...sessionWindows,
|
|
778
|
+
[outcome.window]: {
|
|
779
|
+
...sessionEntry?.status === "rejected" ? sessionEntry : {},
|
|
780
|
+
status: "rejected",
|
|
781
|
+
resetsAt: outcome.resetsAtSec,
|
|
782
|
+
lastSeenAt
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/commands/seat-mismatch-report.ts
|
|
788
|
+
async function reportSeatMismatchOutcome(apiUrl, apiKey, credential, model) {
|
|
789
|
+
const { keyType, keySuffix, keyIndex } = credential;
|
|
790
|
+
const modelLabel = model.charAt(0).toUpperCase() + model.slice(1);
|
|
791
|
+
console.log(`[credential] seat mismatch: key #${keyIndex} (...${keySuffix}) cannot run ${modelLabel}`);
|
|
792
|
+
try {
|
|
793
|
+
const response = await fetch(`${apiUrl}/api/keys/report-seat-mismatch`, {
|
|
794
|
+
method: "POST",
|
|
795
|
+
headers: {
|
|
796
|
+
"Content-Type": "application/json",
|
|
797
|
+
Authorization: `Bearer ${apiKey}`
|
|
798
|
+
},
|
|
799
|
+
body: JSON.stringify({ keyType, keySuffix, keyIndex, model })
|
|
800
|
+
});
|
|
801
|
+
if (!response.ok) {
|
|
802
|
+
throw new Error(`HTTP ${response.status}`);
|
|
803
|
+
}
|
|
804
|
+
} catch (err) {
|
|
805
|
+
console.warn(`[credential] Failed to report seat mismatch for key #${keyIndex}: ${err instanceof Error ? err.message : String(err)}`);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// src/commands/credential-outcome-report.ts
|
|
810
|
+
async function reportKeyRateLimit(apiUrl, apiKey, keyType, keySuffix, keyIndex, rateLimitedUntil) {
|
|
811
|
+
try {
|
|
812
|
+
await fetch(`${apiUrl}/api/keys/report-rate-limit`, {
|
|
813
|
+
method: "POST",
|
|
814
|
+
headers: {
|
|
815
|
+
"Content-Type": "application/json",
|
|
816
|
+
Authorization: `Bearer ${apiKey}`
|
|
817
|
+
},
|
|
818
|
+
body: JSON.stringify({
|
|
819
|
+
keyType,
|
|
820
|
+
keySuffix,
|
|
821
|
+
keyIndex,
|
|
822
|
+
rateLimitedUntil
|
|
823
|
+
})
|
|
824
|
+
});
|
|
825
|
+
console.log(`[credentials] Reported key ...${keySuffix} as rate-limited until ${rateLimitedUntil}`);
|
|
826
|
+
} catch {}
|
|
827
|
+
}
|
|
828
|
+
async function reportKeyRateLimitWindows(apiUrl, apiKey, keyType, keySuffix, keyIndex, windows, logKeySuffix = true) {
|
|
829
|
+
if (Object.keys(windows).length === 0)
|
|
830
|
+
return;
|
|
831
|
+
const response = await fetch(`${apiUrl}/api/keys/report-rate-limit-windows`, {
|
|
832
|
+
method: "POST",
|
|
833
|
+
headers: {
|
|
834
|
+
"Content-Type": "application/json",
|
|
835
|
+
Authorization: `Bearer ${apiKey}`
|
|
836
|
+
},
|
|
837
|
+
body: JSON.stringify({
|
|
838
|
+
keyType,
|
|
839
|
+
keySuffix,
|
|
840
|
+
keyIndex,
|
|
841
|
+
windows
|
|
842
|
+
})
|
|
843
|
+
});
|
|
844
|
+
if (!response.ok) {
|
|
845
|
+
throw new Error(`Failed to report rate-limit windows for key #${keyIndex}: HTTP ${response.status}`);
|
|
846
|
+
}
|
|
847
|
+
if (logKeySuffix) {
|
|
848
|
+
console.log(`[credentials] Reported rate-limit windows for key ...${keySuffix}`);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
async function reportCredentialOutcomeThenFinish(input, finish) {
|
|
852
|
+
const { apiUrl, apiKey, credentialInfo, result, failureReason, model } = input;
|
|
853
|
+
if (credentialInfo) {
|
|
854
|
+
const outcome = classifyRateLimitOutcome(result, failureReason, Date.now(), input.codexCreditsExhaustedCooldownMs, modelFamilyOf(model));
|
|
855
|
+
if (outcome.kind === "seat") {
|
|
856
|
+
await reportSeatMismatchOutcome(apiUrl, apiKey, credentialInfo, outcome.model);
|
|
857
|
+
}
|
|
858
|
+
const keyRateLimitedUntil = outcome.kind === "key" ? outcome.rateLimitedUntil : outcome.kind === "model" || outcome.kind === "seat" ? outcome.keyRateLimitedUntil : undefined;
|
|
859
|
+
if (keyRateLimitedUntil) {
|
|
860
|
+
console.log(`[credentials] Rate limit reset: ${keyRateLimitedUntil}`);
|
|
861
|
+
reportKeyRateLimit(apiUrl, apiKey, credentialInfo.keyType, credentialInfo.keySuffix, credentialInfo.keyIndex, keyRateLimitedUntil).catch(() => {});
|
|
862
|
+
}
|
|
863
|
+
if (outcome.kind === "model") {
|
|
864
|
+
const resetsAtIso = new Date(outcome.resetsAtSec * 1000).toISOString();
|
|
865
|
+
const blockKey = `${credentialInfo.keyType}:${credentialInfo.keyIndex}:${outcome.window}`;
|
|
866
|
+
input.modelWindowBlocks.set(blockKey, outcome.resetsAtSec * 1000);
|
|
867
|
+
console.log(`[credential] ${outcome.model} weekly window exhausted (${outcome.window}) on key #${credentialInfo.keyIndex} until ${resetsAtIso}`);
|
|
868
|
+
}
|
|
869
|
+
const finalWindows = buildFinalRateLimitWindows(result.rateLimitWindows, outcome, new Date().toISOString());
|
|
870
|
+
if (finalWindows) {
|
|
871
|
+
const report = reportKeyRateLimitWindows(apiUrl, apiKey, credentialInfo.keyType, credentialInfo.keySuffix, credentialInfo.keyIndex, finalWindows, outcome.kind !== "model").catch((err) => {
|
|
872
|
+
console.warn(`[credential] Failed to report rate-limit windows: ${err instanceof Error ? err.message : String(err)}`);
|
|
873
|
+
});
|
|
874
|
+
if (outcome.kind === "model")
|
|
875
|
+
await report;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
await finish();
|
|
879
|
+
}
|
|
880
|
+
|
|
591
881
|
// src/commands/provider-credentials.ts
|
|
592
882
|
init_secret_scrubber();
|
|
593
883
|
function isBedrockMode(env) {
|
|
@@ -605,7 +895,7 @@ var CREDENTIAL_PROVIDER_CHECKERS = {
|
|
|
605
895
|
devin: (env) => checkDevinCredentials(env),
|
|
606
896
|
opencode: (env, opts) => checkOpencodeCredentials(env, opts),
|
|
607
897
|
pi: async (env, opts) => {
|
|
608
|
-
const { checkPiMonoCredentials } = await import("./pi-mono-adapter-
|
|
898
|
+
const { checkPiMonoCredentials } = await import("./pi-mono-adapter-g7qzvr3v.js");
|
|
609
899
|
return checkPiMonoCredentials(env, opts);
|
|
610
900
|
},
|
|
611
901
|
acp: () => ({ ready: true, missing: [], satisfiedBy: "sdk-delegated" })
|
|
@@ -1118,78 +1408,6 @@ async function refreshIdentityIfChanged(ctx, cached) {
|
|
|
1118
1408
|
// src/commands/runner.ts
|
|
1119
1409
|
init_profile_sync();
|
|
1120
1410
|
|
|
1121
|
-
// src/commands/rate-limit-outcome.ts
|
|
1122
|
-
init_model_rate_limit_windows();
|
|
1123
|
-
function clampMs(candidateMs, nowMs) {
|
|
1124
|
-
const minMs = nowMs + 60000;
|
|
1125
|
-
const maxMs = nowMs + MAX_RATE_LIMIT_RESET_MS;
|
|
1126
|
-
return Math.min(Math.max(candidateMs, minMs), maxMs);
|
|
1127
|
-
}
|
|
1128
|
-
function classifyRateLimitOutcome(result, failureReason, nowMs, codexCreditsExhaustedCooldownMs = CODEX_CREDITS_EXHAUSTED_COOLDOWN_MS) {
|
|
1129
|
-
const keyRateLimitedUntil = result.rateLimitResetAt ? new Date(clampMs(new Date(result.rateLimitResetAt).getTime(), nowMs)).toISOString() : undefined;
|
|
1130
|
-
const keyExtra = keyRateLimitedUntil ? { keyRateLimitedUntil } : {};
|
|
1131
|
-
if (result.modelRateLimit) {
|
|
1132
|
-
const resetsAtSec = Math.floor(new Date(result.modelRateLimit.resetAt).getTime() / 1000);
|
|
1133
|
-
const { observedAt } = result.modelRateLimit;
|
|
1134
|
-
return {
|
|
1135
|
-
kind: "model",
|
|
1136
|
-
model: result.modelRateLimit.model,
|
|
1137
|
-
window: result.modelRateLimit.window,
|
|
1138
|
-
resetsAtSec,
|
|
1139
|
-
source: "event",
|
|
1140
|
-
...observedAt ? { observedAt } : {},
|
|
1141
|
-
...keyExtra
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
if (failureReason != null) {
|
|
1145
|
-
const family = parseModelLimitMessage(failureReason);
|
|
1146
|
-
const window = family ? windowForModelFamily(family) : undefined;
|
|
1147
|
-
if (family && window) {
|
|
1148
|
-
const sevenDay = result.rateLimitWindows?.seven_day;
|
|
1149
|
-
const sevenDayResetsAtSec = sevenDay && typeof sevenDay.resetsAt === "number" && sevenDay.resetsAt * 1000 > nowMs ? sevenDay.resetsAt : undefined;
|
|
1150
|
-
const fallbackResetsAtSec = Math.floor((nowMs + 24 * 60 * 60 * 1000) / 1000);
|
|
1151
|
-
const maxResetsAtSec = Math.floor((nowMs + MAX_RATE_LIMIT_RESET_MS) / 1000);
|
|
1152
|
-
const resetsAtSec = Math.min(sevenDayResetsAtSec ?? fallbackResetsAtSec, maxResetsAtSec);
|
|
1153
|
-
return { kind: "model", model: family, window, resetsAtSec, source: "text", ...keyExtra };
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
if (result.rateLimitResetAt != null || failureReason != null && isRateLimitMessage(failureReason)) {
|
|
1157
|
-
let rateLimitedUntil;
|
|
1158
|
-
if (keyRateLimitedUntil) {
|
|
1159
|
-
rateLimitedUntil = keyRateLimitedUntil;
|
|
1160
|
-
} else if (failureReason != null) {
|
|
1161
|
-
const parsedResetTime = parseRateLimitResetTime(failureReason);
|
|
1162
|
-
if (parsedResetTime) {
|
|
1163
|
-
rateLimitedUntil = new Date(clampMs(new Date(parsedResetTime).getTime(), nowMs)).toISOString();
|
|
1164
|
-
} else if (isCodexCreditsExhaustedMessage(failureReason)) {
|
|
1165
|
-
rateLimitedUntil = new Date(nowMs + codexCreditsExhaustedCooldownMs).toISOString();
|
|
1166
|
-
} else {
|
|
1167
|
-
rateLimitedUntil = new Date(nowMs + 5 * 60 * 1000).toISOString();
|
|
1168
|
-
}
|
|
1169
|
-
} else {
|
|
1170
|
-
rateLimitedUntil = new Date(nowMs + 5 * 60 * 1000).toISOString();
|
|
1171
|
-
}
|
|
1172
|
-
return { kind: "key", rateLimitedUntil };
|
|
1173
|
-
}
|
|
1174
|
-
return { kind: "none" };
|
|
1175
|
-
}
|
|
1176
|
-
function buildFinalRateLimitWindows(sessionWindows, outcome, nowIso) {
|
|
1177
|
-
if (outcome.kind !== "model")
|
|
1178
|
-
return sessionWindows;
|
|
1179
|
-
const sessionEntry = sessionWindows?.[outcome.window];
|
|
1180
|
-
const sessionRejectedAt = sessionEntry?.status === "rejected" ? sessionEntry.lastSeenAt : undefined;
|
|
1181
|
-
const lastSeenAt = outcome.source === "event" ? outcome.observedAt ?? sessionRejectedAt ?? nowIso : nowIso;
|
|
1182
|
-
return {
|
|
1183
|
-
...sessionWindows,
|
|
1184
|
-
[outcome.window]: {
|
|
1185
|
-
...sessionEntry?.status === "rejected" ? sessionEntry : {},
|
|
1186
|
-
status: "rejected",
|
|
1187
|
-
resetsAt: outcome.resetsAtSec,
|
|
1188
|
-
lastSeenAt
|
|
1189
|
-
}
|
|
1190
|
-
};
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
1411
|
// src/commands/resume-session.ts
|
|
1194
1412
|
var RESUME_DEPRECATED_REASON = "native resume deprecated — using context preamble";
|
|
1195
1413
|
function resolveResumeSession(_currentProvider, candidates) {
|
|
@@ -1556,6 +1774,7 @@ async function closeAgent(config, role) {
|
|
|
1556
1774
|
} catch {}
|
|
1557
1775
|
}
|
|
1558
1776
|
var deploymentMemoryRaters = process.env.MEMORY_RATERS;
|
|
1777
|
+
var rowOverriddenBootEnv = new Map;
|
|
1559
1778
|
async function fetchResolvedEnv(apiUrl, apiKey, agentId, baseEnv = process.env, taskModel, sessionContext) {
|
|
1560
1779
|
const env = { ...baseEnv };
|
|
1561
1780
|
const repoId = sessionContext?.repoId;
|
|
@@ -1572,6 +1791,10 @@ async function fetchResolvedEnv(apiUrl, apiKey, agentId, baseEnv = process.env,
|
|
|
1572
1791
|
} else {
|
|
1573
1792
|
const data = await response.json();
|
|
1574
1793
|
env.MEMORY_RATERS = baseEnv === process.env ? deploymentMemoryRaters : baseEnv.MEMORY_RATERS;
|
|
1794
|
+
if (baseEnv === process.env) {
|
|
1795
|
+
for (const [key, bootValue] of rowOverriddenBootEnv)
|
|
1796
|
+
env[key] = bootValue;
|
|
1797
|
+
}
|
|
1575
1798
|
if (data.configs?.length) {
|
|
1576
1799
|
scriptsOnlyConfigValue = data.configs.find((config) => config.key === "SCRIPTS_ONLY_MCP")?.value;
|
|
1577
1800
|
for (const config of data.configs) {
|
|
@@ -1665,7 +1888,9 @@ var RELOADABLE_ENV_KEYS = new Set([
|
|
|
1665
1888
|
"MEMORY_RATERS",
|
|
1666
1889
|
"TEMPLATE_REGISTRY_URL",
|
|
1667
1890
|
"SLACK_DISABLE",
|
|
1668
|
-
"SWARM_ORG_NAME"
|
|
1891
|
+
"SWARM_ORG_NAME",
|
|
1892
|
+
"PI_TOOL_DEFERRAL",
|
|
1893
|
+
"PI_CODEMODE"
|
|
1669
1894
|
]);
|
|
1670
1895
|
var BLANK_ROW_IS_STRAY_KEYS = new Set([
|
|
1671
1896
|
"MODEL_OVERRIDE",
|
|
@@ -1675,11 +1900,14 @@ function applyResolvedEnvToProcessEnv(freshEnv) {
|
|
|
1675
1900
|
const changed = [];
|
|
1676
1901
|
for (const key of RELOADABLE_ENV_KEYS) {
|
|
1677
1902
|
const next = freshEnv[key];
|
|
1678
|
-
if (
|
|
1903
|
+
if (next === undefined && process.env[key] !== undefined && (key === "MEMORY_RATERS" || rowOverriddenBootEnv.has(key))) {
|
|
1679
1904
|
delete process.env[key];
|
|
1680
1905
|
changed.push(key);
|
|
1681
1906
|
} else if (next !== undefined && next !== process.env[key]) {
|
|
1682
1907
|
const previous = process.env[key];
|
|
1908
|
+
if (key !== "MEMORY_RATERS" && !rowOverriddenBootEnv.has(key)) {
|
|
1909
|
+
rowOverriddenBootEnv.set(key, previous);
|
|
1910
|
+
}
|
|
1683
1911
|
process.env[key] = next;
|
|
1684
1912
|
changed.push(key);
|
|
1685
1913
|
if (previous && !next) {
|
|
@@ -1769,6 +1997,8 @@ var SWARM_TOOL_LABELS = {
|
|
|
1769
1997
|
"set-config": "⚙️ Setting config",
|
|
1770
1998
|
"list-config": "⚙️ Listing config",
|
|
1771
1999
|
"delete-config": "⚙️ Deleting config",
|
|
2000
|
+
"model-catalog-refresh": "\uD83E\uDDE0 Refreshing model catalog",
|
|
2001
|
+
"model-catalog-overlay-upsert": "\uD83E\uDDE0 Updating model catalog overlay",
|
|
1772
2002
|
"create-schedule": "\uD83D\uDCC5 Creating schedule",
|
|
1773
2003
|
"list-schedules": "\uD83D\uDCC5 Listing schedules",
|
|
1774
2004
|
"run-schedule-now": "\uD83D\uDCC5 Running schedule",
|
|
@@ -2088,11 +2318,13 @@ async function resolveCodexOAuthCredentialInfo(apiUrl, apiKey) {
|
|
|
2088
2318
|
const slots = await loadAllCodexOAuthSlots(apiUrl, apiKey);
|
|
2089
2319
|
if (slots.length > 0) {
|
|
2090
2320
|
let availableIndices;
|
|
2321
|
+
let authFailureFence;
|
|
2091
2322
|
try {
|
|
2092
2323
|
const resp = await fetch(`${apiUrl}/api/keys/available?keyType=CODEX_OAUTH&totalKeys=${slots.length}`, { headers: { Authorization: `Bearer ${apiKey}` } });
|
|
2093
2324
|
if (resp.ok) {
|
|
2094
2325
|
const data = await resp.json();
|
|
2095
2326
|
availableIndices = data.availableIndices;
|
|
2327
|
+
authFailureFence = data.authFailureFence;
|
|
2096
2328
|
if (availableIndices.length < slots.length) {
|
|
2097
2329
|
console.log(`[credentials] CODEX_OAUTH: ${availableIndices.length}/${slots.length} slots available (${slots.length - availableIndices.length} rate-limited)`);
|
|
2098
2330
|
}
|
|
@@ -2123,7 +2355,10 @@ async function resolveCodexOAuthCredentialInfo(apiUrl, apiKey) {
|
|
|
2123
2355
|
},
|
|
2124
2356
|
last_refresh: new Date(slotEntry.creds.expires).toISOString()
|
|
2125
2357
|
};
|
|
2126
|
-
const sel =
|
|
2358
|
+
const sel = {
|
|
2359
|
+
...authJsonToCredentialSelection(authJson, selectedSlot, slots.length),
|
|
2360
|
+
authFailureFence
|
|
2361
|
+
};
|
|
2127
2362
|
console.log(`[credentials] Selected CODEX_OAUTH slot ${selectedSlot + 1}/${slots.length} [...${sel.keySuffix}]`);
|
|
2128
2363
|
return { selection: sel, isPoolBacked: true };
|
|
2129
2364
|
}
|
|
@@ -2150,48 +2385,28 @@ async function resolveCodexOAuthCredentialInfo(apiUrl, apiKey) {
|
|
|
2150
2385
|
return null;
|
|
2151
2386
|
}
|
|
2152
2387
|
}
|
|
2153
|
-
|
|
2388
|
+
var KEY_OUTCOME_REPORT_TIMEOUT_MS = 5000;
|
|
2389
|
+
async function reportKeyAuthFailure(apiUrl, apiKey, keyType, keySuffix, keyIndex, taskId, timeoutMs = KEY_OUTCOME_REPORT_TIMEOUT_MS) {
|
|
2154
2390
|
try {
|
|
2155
|
-
await fetch(`${apiUrl}/api/keys/report-
|
|
2391
|
+
const resp = await fetch(`${apiUrl}/api/keys/report-auth-failure`, {
|
|
2156
2392
|
method: "POST",
|
|
2157
2393
|
headers: {
|
|
2158
2394
|
"Content-Type": "application/json",
|
|
2159
2395
|
Authorization: `Bearer ${apiKey}`
|
|
2160
2396
|
},
|
|
2161
|
-
body: JSON.stringify({
|
|
2162
|
-
|
|
2163
|
-
keySuffix,
|
|
2164
|
-
keyIndex,
|
|
2165
|
-
rateLimitedUntil
|
|
2166
|
-
})
|
|
2397
|
+
body: JSON.stringify({ keyType, keySuffix, keyIndex, taskId }),
|
|
2398
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
2167
2399
|
});
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
method: "POST",
|
|
2176
|
-
headers: {
|
|
2177
|
-
"Content-Type": "application/json",
|
|
2178
|
-
Authorization: `Bearer ${apiKey}`
|
|
2179
|
-
},
|
|
2180
|
-
body: JSON.stringify({
|
|
2181
|
-
keyType,
|
|
2182
|
-
keySuffix,
|
|
2183
|
-
keyIndex,
|
|
2184
|
-
windows
|
|
2185
|
-
})
|
|
2186
|
-
});
|
|
2187
|
-
if (!response.ok) {
|
|
2188
|
-
throw new Error(`Failed to report rate-limit windows for key #${keyIndex}: HTTP ${response.status}`);
|
|
2189
|
-
}
|
|
2190
|
-
if (logKeySuffix) {
|
|
2191
|
-
console.log(`[credentials] Reported rate-limit windows for key ...${keySuffix}`);
|
|
2400
|
+
if (!resp.ok)
|
|
2401
|
+
throw new Error(`HTTP ${resp.status}`);
|
|
2402
|
+
const data = await resp.json();
|
|
2403
|
+
console.log(`[credentials] Auth failure on ...${keySuffix}: ${data.consecutiveAuthFailures} in a row${data.benched ? `; benched until ${data.rateLimitedUntil}` : ""}`);
|
|
2404
|
+
} catch (err) {
|
|
2405
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2406
|
+
console.warn(scrubSecrets(`[credentials] Failed to report auth failure: ${message}`));
|
|
2192
2407
|
}
|
|
2193
2408
|
}
|
|
2194
|
-
async function reportKeyClearRateLimit(apiUrl, apiKey, keyType, keySuffix) {
|
|
2409
|
+
async function reportKeyClearRateLimit(apiUrl, apiKey, keyType, keySuffix, authFence, timeoutMs = KEY_OUTCOME_REPORT_TIMEOUT_MS) {
|
|
2195
2410
|
try {
|
|
2196
2411
|
const resp = await fetch(`${apiUrl}/api/keys/clear-rate-limit`, {
|
|
2197
2412
|
method: "POST",
|
|
@@ -2199,7 +2414,8 @@ async function reportKeyClearRateLimit(apiUrl, apiKey, keyType, keySuffix) {
|
|
|
2199
2414
|
"Content-Type": "application/json",
|
|
2200
2415
|
Authorization: `Bearer ${apiKey}`
|
|
2201
2416
|
},
|
|
2202
|
-
body: JSON.stringify({ keyType, keySuffix })
|
|
2417
|
+
body: JSON.stringify({ keyType, keySuffix, clearAuthBench: true, authFence }),
|
|
2418
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
2203
2419
|
});
|
|
2204
2420
|
if (resp.ok) {
|
|
2205
2421
|
const data = await resp.json();
|
|
@@ -2209,6 +2425,16 @@ async function reportKeyClearRateLimit(apiUrl, apiKey, keyType, keySuffix) {
|
|
|
2209
2425
|
}
|
|
2210
2426
|
} catch {}
|
|
2211
2427
|
}
|
|
2428
|
+
async function reportKeyCompletionOutcome(opts) {
|
|
2429
|
+
const { apiUrl, apiKey, credential, taskId, exitCode, failureReason, timeoutMs } = opts;
|
|
2430
|
+
if (exitCode === 0) {
|
|
2431
|
+
await reportKeyClearRateLimit(apiUrl, apiKey, credential.keyType, credential.keySuffix, credential.authFence, timeoutMs);
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
if (credential.keyType === "CODEX_OAUTH" && isCodexAuthFailureReason(failureReason)) {
|
|
2435
|
+
await reportKeyAuthFailure(apiUrl, apiKey, credential.keyType, credential.keySuffix, credential.keyIndex, taskId, timeoutMs);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2212
2438
|
async function supersedeTaskViaAPI(config, role, taskId, reason) {
|
|
2213
2439
|
const headers = {
|
|
2214
2440
|
"X-Agent-ID": config.agentId,
|
|
@@ -2705,6 +2931,9 @@ async function triggerHeartbeatSweep(config) {
|
|
|
2705
2931
|
return false;
|
|
2706
2932
|
}
|
|
2707
2933
|
}
|
|
2934
|
+
function workerModelTierOverrides(provider) {
|
|
2935
|
+
return parseWorkerModelTierOverrides(process.env, provider);
|
|
2936
|
+
}
|
|
2708
2937
|
async function buildRequesterProfilePrompt(requestedBy) {
|
|
2709
2938
|
const comms = requestedBy?.comms;
|
|
2710
2939
|
const commsParts = [
|
|
@@ -2728,6 +2957,51 @@ ${notes}` : "";
|
|
|
2728
2957
|
});
|
|
2729
2958
|
return result.skipped ? "" : result.text.trim();
|
|
2730
2959
|
}
|
|
2960
|
+
|
|
2961
|
+
class AgentRegistrationHttpError extends Error {
|
|
2962
|
+
status;
|
|
2963
|
+
body;
|
|
2964
|
+
constructor(status, body) {
|
|
2965
|
+
super(`Failed to register agent: ${status} ${body}`);
|
|
2966
|
+
this.name = "AgentRegistrationHttpError";
|
|
2967
|
+
this.status = status;
|
|
2968
|
+
this.body = body;
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
function isRetryableRegistrationError(err) {
|
|
2972
|
+
if (err instanceof AgentRegistrationHttpError) {
|
|
2973
|
+
return err.status >= 500 || err.status === 408 || err.status === 429 || /database is locked/i.test(err.body);
|
|
2974
|
+
}
|
|
2975
|
+
return true;
|
|
2976
|
+
}
|
|
2977
|
+
var REGISTRATION_RETRY_BUDGET_MS = 5 * 60000;
|
|
2978
|
+
var REGISTRATION_RETRY_BASE_DELAY_MS = 2000;
|
|
2979
|
+
var REGISTRATION_RETRY_MAX_DELAY_MS = 30000;
|
|
2980
|
+
async function registerAgentWithRetry(register, opts) {
|
|
2981
|
+
const budgetMs = opts.budgetMs ?? REGISTRATION_RETRY_BUDGET_MS;
|
|
2982
|
+
const baseDelayMs = opts.baseDelayMs ?? REGISTRATION_RETRY_BASE_DELAY_MS;
|
|
2983
|
+
const maxDelayMs = opts.maxDelayMs ?? REGISTRATION_RETRY_MAX_DELAY_MS;
|
|
2984
|
+
const sleep = opts.sleep ?? ((ms) => Bun.sleep(ms));
|
|
2985
|
+
const now = opts.now ?? Date.now;
|
|
2986
|
+
const startedAt = now();
|
|
2987
|
+
for (let attempt = 1;; attempt++) {
|
|
2988
|
+
try {
|
|
2989
|
+
return await register();
|
|
2990
|
+
} catch (err) {
|
|
2991
|
+
if (!isRetryableRegistrationError(err))
|
|
2992
|
+
throw err;
|
|
2993
|
+
const backoff = Math.min(maxDelayMs, baseDelayMs * 2 ** (attempt - 1));
|
|
2994
|
+
const delay = Math.round(backoff * (0.8 + Math.random() * 0.4));
|
|
2995
|
+
const elapsed = now() - startedAt;
|
|
2996
|
+
if (elapsed + delay > budgetMs) {
|
|
2997
|
+
console.error(`[${opts.label}] Registration still failing after ${attempt} attempts in ${Math.round(elapsed / 1000)}s; giving up`);
|
|
2998
|
+
throw err;
|
|
2999
|
+
}
|
|
3000
|
+
console.warn(`[${opts.label}] Registration attempt ${attempt} failed (${err}); retrying in ${Math.round(delay / 1000)}s`);
|
|
3001
|
+
await sleep(delay);
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
2731
3005
|
async function registerAgent(opts) {
|
|
2732
3006
|
const headers = {
|
|
2733
3007
|
"Content-Type": "application/json",
|
|
@@ -2749,12 +3023,14 @@ async function registerAgent(opts) {
|
|
|
2749
3023
|
maxTasks: opts.maxTasks,
|
|
2750
3024
|
provider,
|
|
2751
3025
|
harness_provider: harnessProvider,
|
|
2752
|
-
runtimeInstanceId: opts.runtimeInstanceId
|
|
3026
|
+
runtimeInstanceId: opts.runtimeInstanceId,
|
|
3027
|
+
modelTierOverrides: workerModelTierOverrides(harnessProvider),
|
|
3028
|
+
harnessCliVersion: await probeHarnessCliVersion(harnessProvider) ?? undefined
|
|
2753
3029
|
})
|
|
2754
3030
|
});
|
|
2755
3031
|
if (!response.ok) {
|
|
2756
3032
|
const error = await response.text();
|
|
2757
|
-
throw new
|
|
3033
|
+
throw new AgentRegistrationHttpError(response.status, error);
|
|
2758
3034
|
}
|
|
2759
3035
|
try {
|
|
2760
3036
|
const body = await response.json();
|
|
@@ -2781,6 +3057,11 @@ async function pollForTrigger(opts) {
|
|
|
2781
3057
|
}
|
|
2782
3058
|
async function pollForTriggerOnce(opts) {
|
|
2783
3059
|
const startTime = Date.now();
|
|
3060
|
+
refreshRuntimeModelCatalog({
|
|
3061
|
+
apiUrl: opts.apiUrl,
|
|
3062
|
+
apiKey: opts.apiKey,
|
|
3063
|
+
agentId: opts.agentId
|
|
3064
|
+
});
|
|
2784
3065
|
const headers = {
|
|
2785
3066
|
"X-Agent-ID": opts.agentId
|
|
2786
3067
|
};
|
|
@@ -2791,6 +3072,9 @@ async function pollForTriggerOnce(opts) {
|
|
|
2791
3072
|
headers.Authorization = `Bearer ${opts.apiKey}`;
|
|
2792
3073
|
}
|
|
2793
3074
|
injectTraceContext(headers);
|
|
3075
|
+
if (opts.harnessProvider) {
|
|
3076
|
+
headers["X-Model-Tier-Overrides"] = encodeURIComponent(JSON.stringify(workerModelTierOverrides(opts.harnessProvider)));
|
|
3077
|
+
}
|
|
2794
3078
|
while (Date.now() - startTime < opts.pollTimeout) {
|
|
2795
3079
|
try {
|
|
2796
3080
|
let url = `${opts.apiUrl}/api/poll`;
|
|
@@ -3133,7 +3417,7 @@ async function spawnProviderProcess(adapter, opts, logDir, isYolo) {
|
|
|
3133
3417
|
let freshEnv;
|
|
3134
3418
|
let credentialSelections;
|
|
3135
3419
|
try {
|
|
3136
|
-
({ env: freshEnv, credentialSelections } = await fetchResolvedEnv(opts.apiUrl, opts.apiKey, opts.agentId, process.env, opts.model, {
|
|
3420
|
+
({ env: freshEnv, credentialSelections } = await fetchResolvedEnv(opts.apiUrl, opts.apiKey, opts.agentId, process.env, opts.resolvedModel || opts.model, {
|
|
3137
3421
|
repoId: sessionRepo?.id,
|
|
3138
3422
|
provider: adapter.name,
|
|
3139
3423
|
modelTier: opts.modelTier,
|
|
@@ -3142,8 +3426,7 @@ async function spawnProviderProcess(adapter, opts, logDir, isYolo) {
|
|
|
3142
3426
|
}));
|
|
3143
3427
|
} catch (err) {
|
|
3144
3428
|
if (err instanceof ModelWindowExhaustedError && realTaskId) {
|
|
3145
|
-
const
|
|
3146
|
-
const reason = `No ${err.keyType} key has ${modelLabel} capacity until ${err.earliestResetAt ?? "unknown"}. Re-dispatch with another model or modelTier.`;
|
|
3429
|
+
const reason = err.message;
|
|
3147
3430
|
console.warn(`[${opts.role}] ${reason}`);
|
|
3148
3431
|
await ensureTaskFinished({ apiUrl: opts.apiUrl, apiKey: opts.apiKey, agentId: opts.agentId }, opts.role, realTaskId, 1, reason, undefined, opts.harnessProvider);
|
|
3149
3432
|
}
|
|
@@ -3166,8 +3449,26 @@ async function spawnProviderProcess(adapter, opts, logDir, isYolo) {
|
|
|
3166
3449
|
harnessProvider: opts.harnessProvider,
|
|
3167
3450
|
env: freshEnv
|
|
3168
3451
|
});
|
|
3169
|
-
|
|
3170
|
-
|
|
3452
|
+
if (opts.resolvedModel && taskModelSelection.model && taskModelSelection.model !== opts.resolvedModel) {
|
|
3453
|
+
console.log(`[${opts.role}] model resolution mismatch for task ${opts.taskId ?? "?"}: server=${opts.resolvedModel} (${opts.modelSource ?? "?"}) local=${taskModelSelection.model}; using server value`);
|
|
3454
|
+
}
|
|
3455
|
+
const taskModel = opts.resolvedModel || taskModelSelection.model || "";
|
|
3456
|
+
const spawnModel = guardSpawnModel({
|
|
3457
|
+
taskModel,
|
|
3458
|
+
configModel,
|
|
3459
|
+
harness: opts.harnessProvider,
|
|
3460
|
+
role: opts.role
|
|
3461
|
+
});
|
|
3462
|
+
if (spawnModel.kind === "mismatch") {
|
|
3463
|
+
console.warn(`[${opts.role}] ${spawnModel.reason}`);
|
|
3464
|
+
if (realTaskId) {
|
|
3465
|
+
await ensureTaskFinished({ apiUrl: opts.apiUrl, apiKey: opts.apiKey, agentId: opts.agentId }, opts.role, realTaskId, 1, spawnModel.reason, undefined, opts.harnessProvider);
|
|
3466
|
+
}
|
|
3467
|
+
throw new Error(spawnModel.reason);
|
|
3468
|
+
}
|
|
3469
|
+
if (spawnModel.warning)
|
|
3470
|
+
console.warn(spawnModel.warning);
|
|
3471
|
+
const model = spawnModel.model;
|
|
3171
3472
|
let oauthSelection;
|
|
3172
3473
|
let oauthIsPoolBacked = false;
|
|
3173
3474
|
if (adapter.name === "codex") {
|
|
@@ -3697,7 +3998,8 @@ async function spawnProviderProcess(adapter, opts, logDir, isYolo) {
|
|
|
3697
3998
|
const credentialInfo = primarySelection ? {
|
|
3698
3999
|
keyType: primarySelection.keyType,
|
|
3699
4000
|
keySuffix: primarySelection.keySuffix,
|
|
3700
|
-
keyIndex: primarySelection.index
|
|
4001
|
+
keyIndex: primarySelection.index,
|
|
4002
|
+
authFence: primarySelection.authFailureFence
|
|
3701
4003
|
} : undefined;
|
|
3702
4004
|
const runningTask = {
|
|
3703
4005
|
taskId: effectiveTaskId,
|
|
@@ -3777,27 +4079,24 @@ async function checkCompletedProcesses(state, role, apiConfig, cancelledSignaled
|
|
|
3777
4079
|
failureReason = result.failureReason;
|
|
3778
4080
|
console.log(`[${role}] Detected error for task ${taskId.slice(0, 8)}: ${failureReason}`);
|
|
3779
4081
|
}
|
|
4082
|
+
reportHarnessModelOutcome({
|
|
4083
|
+
apiUrl: apiConfig.apiUrl,
|
|
4084
|
+
apiKey: apiConfig.apiKey,
|
|
4085
|
+
agentId: apiConfig.agentId,
|
|
4086
|
+
harness: harnessProvider,
|
|
4087
|
+
model,
|
|
4088
|
+
exitCode: result.exitCode,
|
|
4089
|
+
failureReason
|
|
4090
|
+
});
|
|
3780
4091
|
if (credentialInfo) {
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
const blockKey = `${credentialInfo.keyType}:${credentialInfo.keyIndex}:${outcome.window}`;
|
|
3790
|
-
state.modelWindowBlocks.set(blockKey, outcome.resetsAtSec * 1000);
|
|
3791
|
-
console.log(`[credential] ${outcome.model} weekly window exhausted (${outcome.window}) on key #${credentialInfo.keyIndex} until ${resetsAtIso}`);
|
|
3792
|
-
}
|
|
3793
|
-
const finalWindows = buildFinalRateLimitWindows(result.rateLimitWindows, outcome, new Date().toISOString());
|
|
3794
|
-
if (finalWindows) {
|
|
3795
|
-
const report = reportKeyRateLimitWindows(apiConfig.apiUrl, apiConfig.apiKey, credentialInfo.keyType, credentialInfo.keySuffix, credentialInfo.keyIndex, finalWindows, outcome.kind !== "model").catch((err) => {
|
|
3796
|
-
console.warn(`[credential] Failed to report rate-limit windows: ${err instanceof Error ? err.message : String(err)}`);
|
|
3797
|
-
});
|
|
3798
|
-
if (outcome.kind === "model")
|
|
3799
|
-
await report;
|
|
3800
|
-
}
|
|
4092
|
+
await reportKeyCompletionOutcome({
|
|
4093
|
+
apiUrl: apiConfig.apiUrl,
|
|
4094
|
+
apiKey: apiConfig.apiKey,
|
|
4095
|
+
credential: credentialInfo,
|
|
4096
|
+
taskId,
|
|
4097
|
+
exitCode: result.exitCode,
|
|
4098
|
+
failureReason
|
|
4099
|
+
});
|
|
3801
4100
|
}
|
|
3802
4101
|
let bridgeDiagnostics;
|
|
3803
4102
|
if (result.exitCode !== 0 && harnessProvider === "claude" && workingDir) {
|
|
@@ -3811,7 +4110,16 @@ async function checkCompletedProcesses(state, role, apiConfig, cancelledSignaled
|
|
|
3811
4110
|
}
|
|
3812
4111
|
const bridgeFailureDiagnostics = bridgeDiagnostics?.paneTail != null ? `Claude bridge final tmux pane tail (${bridgeDiagnostics.artifactPath}):
|
|
3813
4112
|
${bridgeDiagnostics.paneTail}` : undefined;
|
|
3814
|
-
await
|
|
4113
|
+
await reportCredentialOutcomeThenFinish({
|
|
4114
|
+
apiUrl: apiConfig.apiUrl,
|
|
4115
|
+
apiKey: apiConfig.apiKey,
|
|
4116
|
+
credentialInfo,
|
|
4117
|
+
result,
|
|
4118
|
+
failureReason,
|
|
4119
|
+
model,
|
|
4120
|
+
codexCreditsExhaustedCooldownMs: state.codexCreditsExhaustedCooldownMs,
|
|
4121
|
+
modelWindowBlocks: state.modelWindowBlocks
|
|
4122
|
+
}, () => ensureTaskFinished(apiConfig, role, taskId, result.exitCode, failureReason, resolveProviderOutput(result, assistantText), harnessProvider, bridgeFailureDiagnostics));
|
|
3815
4123
|
telemetry.taskEvent("session_completed", {
|
|
3816
4124
|
taskId,
|
|
3817
4125
|
agentId: apiConfig.agentId,
|
|
@@ -3835,9 +4143,6 @@ ${bridgeDiagnostics.paneTail}` : undefined;
|
|
|
3835
4143
|
});
|
|
3836
4144
|
}
|
|
3837
4145
|
state.tasksProcessed += 1;
|
|
3838
|
-
if (result.exitCode === 0 && credentialInfo) {
|
|
3839
|
-
reportKeyClearRateLimit(apiConfig.apiUrl, apiConfig.apiKey, credentialInfo.keyType, credentialInfo.keySuffix).catch(() => {});
|
|
3840
|
-
}
|
|
3841
4146
|
ensure({
|
|
3842
4147
|
id: "worker_process_finished",
|
|
3843
4148
|
flow: "task",
|
|
@@ -4223,7 +4528,7 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4223
4528
|
}
|
|
4224
4529
|
};
|
|
4225
4530
|
try {
|
|
4226
|
-
const reg = await registerAgent({
|
|
4531
|
+
const reg = await registerAgentWithRetry(() => registerAgent({
|
|
4227
4532
|
apiUrl,
|
|
4228
4533
|
apiKey,
|
|
4229
4534
|
agentId,
|
|
@@ -4234,7 +4539,7 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4234
4539
|
maxTasks: maxConcurrent,
|
|
4235
4540
|
harnessProvider: bootProvider,
|
|
4236
4541
|
runtimeInstanceId
|
|
4237
|
-
});
|
|
4542
|
+
}), { label: role });
|
|
4238
4543
|
lastServerCapsRefreshAt = Date.now();
|
|
4239
4544
|
await applyServerCapabilities(reg.serverCapabilities);
|
|
4240
4545
|
console.log(`[${role}] Registered as "${agentName}" (ID: ${agentId})`);
|
|
@@ -4664,6 +4969,8 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4664
4969
|
taskId: task.id,
|
|
4665
4970
|
model: task.model,
|
|
4666
4971
|
modelTier: task.modelTier,
|
|
4972
|
+
resolvedModel: task.resolvedModel,
|
|
4973
|
+
modelSource: task.modelSource,
|
|
4667
4974
|
effort: task.effort,
|
|
4668
4975
|
harnessProvider: state.harnessProvider,
|
|
4669
4976
|
cwd: resumeCwd,
|
|
@@ -4782,7 +5089,8 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4782
5089
|
agentId,
|
|
4783
5090
|
pollInterval: PollIntervalMs,
|
|
4784
5091
|
runtimeInstanceId,
|
|
4785
|
-
pollTimeout: effectiveTimeout
|
|
5092
|
+
pollTimeout: effectiveTimeout,
|
|
5093
|
+
harnessProvider: state.harnessProvider
|
|
4786
5094
|
});
|
|
4787
5095
|
if (trigger) {
|
|
4788
5096
|
if (trigger.type === "budget_refused") {
|
|
@@ -4958,6 +5266,12 @@ Note: The task requested working directory "${taskDir}" but it does not exist. F
|
|
|
4958
5266
|
|
|
4959
5267
|
`);
|
|
4960
5268
|
const taskSystemPrompt = taskPromptParts + cwdWarning;
|
|
5269
|
+
const modelUnsupported = trigger.task?.modelUnsupported;
|
|
5270
|
+
if (trigger.taskId && modelUnsupported) {
|
|
5271
|
+
console.log(`[${role}] ${modelUnsupported}`);
|
|
5272
|
+
await ensureTaskFinished(apiConfig, role, trigger.taskId, 1, modelUnsupported);
|
|
5273
|
+
continue;
|
|
5274
|
+
}
|
|
4961
5275
|
iteration++;
|
|
4962
5276
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
4963
5277
|
const taskIdSlice = trigger.taskId?.slice(0, 8) || "notask";
|
|
@@ -5007,6 +5321,8 @@ Note: The task requested working directory "${taskDir}" but it does not exist. F
|
|
|
5007
5321
|
taskId: trigger.taskId,
|
|
5008
5322
|
model: taskModel,
|
|
5009
5323
|
modelTier: taskModelTier,
|
|
5324
|
+
resolvedModel: trigger.task?.resolvedModel,
|
|
5325
|
+
modelSource: trigger.task?.modelSource,
|
|
5010
5326
|
effort: taskEffort,
|
|
5011
5327
|
harnessProvider: state.harnessProvider,
|
|
5012
5328
|
cwd: effectiveCwd,
|