@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
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates an EXPLICIT model id (a task, schedule, workflow node or agent
|
|
3
|
+
* runtime `model`) against the model catalog, so a typo fails at the call that
|
|
4
|
+
* made it instead of running as an unknown string ("claude-nonexistent-9").
|
|
5
|
+
*
|
|
6
|
+
* Known:
|
|
7
|
+
* - a `latest:<provider>/<family>` alias that is valid grammar and resolves to a catalog model;
|
|
8
|
+
* - a catalog id, bare (`claude-opus-5-5`, `gpt-5.6-sol`) or provider-qualified
|
|
9
|
+
* (`openrouter/deepseek/deepseek-v4.1-flash`, `amazon-bedrock/...`);
|
|
10
|
+
* - a Claude CLI shortname (`opus`, `sonnet`, ...), which the CLI resolves itself.
|
|
11
|
+
*
|
|
12
|
+
* Escape hatch: `allowCustomModel: true` on the call (tools, REST bodies, workflow node
|
|
13
|
+
* config, the agent runtime PATCH). Custom ids skip the check and are stored as given, for
|
|
14
|
+
* models the catalog cannot list yet (a fresh launch not in models.dev, a private
|
|
15
|
+
* deployment, an ACP-only model). Harnesses whose model namespace the catalog does not
|
|
16
|
+
* describe (`acp`, `devin`, `dsh`) skip the check when the caller names the harness.
|
|
17
|
+
*
|
|
18
|
+
* Harness compatibility: when the harness is known, a concrete id or `latest:` alias must
|
|
19
|
+
* belong to the catalog section that harness's CLI talks to (`harnessModelError`). The
|
|
20
|
+
* escape hatch does not bypass this for an id the catalog files under another section:
|
|
21
|
+
* the flag means "the catalog does not know this id yet", not "run an Anthropic id in
|
|
22
|
+
* Codex". Claim time re-checks the harness (see `resolveTaskModel`).
|
|
23
|
+
*/
|
|
24
|
+
import {
|
|
25
|
+
buildClaudeShortnameMap,
|
|
26
|
+
type HarnessCatalogSections,
|
|
27
|
+
harnessModelMismatch,
|
|
28
|
+
isAlias,
|
|
29
|
+
type ModelsDevCatalog,
|
|
30
|
+
parseAlias,
|
|
31
|
+
} from "@desplega/model-catalog";
|
|
32
|
+
import { getAgentById, getAllAgents } from "./db";
|
|
33
|
+
import { loadModelsCatalog } from "./model-catalog-store";
|
|
34
|
+
import { resolveLatestAlias } from "./model-tier-resolution";
|
|
35
|
+
|
|
36
|
+
/** Harnesses whose model ids the catalog does not describe. */
|
|
37
|
+
const FREE_FORM_HARNESSES = new Set(["acp", "devin", "dsh"]);
|
|
38
|
+
|
|
39
|
+
/** Claude CLI context-window suffix (`sonnet[1m]`): the CLI reads it, the catalog does not list it. */
|
|
40
|
+
const CONTEXT_SUFFIX_RE = /\[1m\]$/i;
|
|
41
|
+
/** Bedrock cross-region inference profile prefix (`us.anthropic.claude-...`). */
|
|
42
|
+
const BEDROCK_REGION_PREFIX_RE = /^(?:us|eu|apac|global|us-gov)\./;
|
|
43
|
+
|
|
44
|
+
type CatalogSections = Record<string, { models?: Record<string, unknown> } | undefined>;
|
|
45
|
+
|
|
46
|
+
function hasModel(catalog: CatalogSections, provider: string, modelId: string): boolean {
|
|
47
|
+
const models = catalog[provider]?.models;
|
|
48
|
+
return Boolean(models && Object.hasOwn(models, modelId));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Whether `model` names something in the catalog (see the module doc). Pure. */
|
|
52
|
+
export function isKnownCatalogModel(model: string, catalog: CatalogSections): boolean {
|
|
53
|
+
const id = model.trim().replace(CONTEXT_SUFFIX_RE, "");
|
|
54
|
+
if (!id) return false;
|
|
55
|
+
const slash = id.indexOf("/");
|
|
56
|
+
if (slash > 0) {
|
|
57
|
+
const provider = id.slice(0, slash);
|
|
58
|
+
const rest = id.slice(slash + 1);
|
|
59
|
+
if (hasModel(catalog, provider, rest)) return true;
|
|
60
|
+
if (provider === "amazon-bedrock") {
|
|
61
|
+
return hasModel(catalog, provider, rest.replace(BEDROCK_REGION_PREFIX_RE, ""));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const provider of Object.keys(catalog)) {
|
|
65
|
+
if (hasModel(catalog, provider, id)) return true;
|
|
66
|
+
}
|
|
67
|
+
const anthropic = catalog.anthropic?.models as ModelsDevCatalog[string]["models"] | undefined;
|
|
68
|
+
return Object.hasOwn(buildClaudeShortnameMap(anthropic), id);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ExplicitModelCheck {
|
|
72
|
+
/** The model the caller named. Empty or absent values pass: there is nothing to check. */
|
|
73
|
+
model: string | null | undefined;
|
|
74
|
+
/** Skip the check: the caller vouches for a custom id. */
|
|
75
|
+
allowCustomModel?: boolean;
|
|
76
|
+
/** The harness the model is for, when known (the assignee or the agent being configured). */
|
|
77
|
+
harnessProvider?: string | null;
|
|
78
|
+
/** The assignee, when known: named in the harness mismatch message. */
|
|
79
|
+
agentId?: string | null;
|
|
80
|
+
agentName?: string | null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Null when `model` runs on `harness`, else the reason. Pure; only judges claude, claude-managed, codex. */
|
|
84
|
+
export const harnessModelError = harnessModelMismatch;
|
|
85
|
+
|
|
86
|
+
/** `harnessModelError` against the current catalog, for callers with no agent row (claim path). */
|
|
87
|
+
export async function harnessModelErrorFor(
|
|
88
|
+
model: string,
|
|
89
|
+
harness: string | null | undefined,
|
|
90
|
+
): Promise<string | null> {
|
|
91
|
+
const { providers } = await loadModelsCatalog();
|
|
92
|
+
return harnessModelMismatch(model, harness, providers as HarnessCatalogSections, {});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Pool claim filter: false when an unassigned task pins a `model` that `harness` cannot
|
|
97
|
+
* run, so an incompatible worker skips it and a compatible one takes it. `isAgentEligibleForTask`
|
|
98
|
+
* stays sync and catalog-free; this runs next to it.
|
|
99
|
+
*/
|
|
100
|
+
export async function poolTaskRunsOnHarness(
|
|
101
|
+
task: { model?: string | null } | null | undefined,
|
|
102
|
+
harness: string | null | undefined,
|
|
103
|
+
): Promise<boolean> {
|
|
104
|
+
const model = task?.model?.trim();
|
|
105
|
+
if (!model) return true;
|
|
106
|
+
return (await harnessModelErrorFor(model, harness)) === null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The error message for an unknown explicit model, or null when it is fine.
|
|
111
|
+
* An empty catalog (nothing to judge against) passes.
|
|
112
|
+
*/
|
|
113
|
+
export async function explicitModelError(check: ExplicitModelCheck): Promise<string | null> {
|
|
114
|
+
const model = check.model?.trim();
|
|
115
|
+
if (!model) return null;
|
|
116
|
+
if (check.harnessProvider && FREE_FORM_HARNESSES.has(check.harnessProvider)) return null;
|
|
117
|
+
|
|
118
|
+
const { providers } = await loadModelsCatalog();
|
|
119
|
+
const catalog = providers as CatalogSections;
|
|
120
|
+
if (check.harnessProvider) {
|
|
121
|
+
const mismatch = harnessModelMismatch(
|
|
122
|
+
model,
|
|
123
|
+
check.harnessProvider,
|
|
124
|
+
catalog as HarnessCatalogSections,
|
|
125
|
+
{ agentId: check.agentId, agentName: check.agentName },
|
|
126
|
+
);
|
|
127
|
+
if (mismatch) return mismatch;
|
|
128
|
+
}
|
|
129
|
+
if (check.allowCustomModel) return null;
|
|
130
|
+
|
|
131
|
+
if (isAlias(model)) {
|
|
132
|
+
if (!parseAlias(model)) {
|
|
133
|
+
return `Invalid model alias "${model}". Use latest:<provider>/<family>[@stable|@any], e.g. latest:anthropic/opus.`;
|
|
134
|
+
}
|
|
135
|
+
const resolved = await resolveLatestAlias(model, new Date(), { record: false });
|
|
136
|
+
return resolved
|
|
137
|
+
? null
|
|
138
|
+
: `Model alias "${model}" matches no model in the catalog. Check the provider and family, or use a concrete model id.`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (Object.keys(catalog).length === 0) return null;
|
|
142
|
+
if (isKnownCatalogModel(model, catalog)) return null;
|
|
143
|
+
return `Unknown model "${model}": it is not in the model catalog. Use a catalog model id, a Claude CLI shortname (opus, sonnet, haiku, fable), a latest:<provider>/<family> alias, or modelTier. To run a custom model id anyway, set allowCustomModel: true (allow_custom_model on the agent runtime).`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* `explicitModelError` for a model that will run on `agentId` (or on whichever
|
|
148
|
+
* worker claims it when there is none): the assignee's harness decides whether
|
|
149
|
+
* the catalog describes its models, and whether the model runs on it.
|
|
150
|
+
*
|
|
151
|
+
* Pool task (no agent): a concrete model must run on the harness of at least one
|
|
152
|
+
* registered agent, else no claim can ever succeed. With no agents registered
|
|
153
|
+
* there is nothing to judge against, and the check passes.
|
|
154
|
+
*/
|
|
155
|
+
export async function explicitModelErrorForAgent(
|
|
156
|
+
check: Omit<ExplicitModelCheck, "harnessProvider" | "agentName">,
|
|
157
|
+
): Promise<string | null> {
|
|
158
|
+
const model = check.model?.trim();
|
|
159
|
+
if (!model) return null;
|
|
160
|
+
const agent = check.agentId ? await getAgentById(check.agentId) : null;
|
|
161
|
+
if (agent) {
|
|
162
|
+
return explicitModelError({
|
|
163
|
+
...check,
|
|
164
|
+
agentId: agent.id,
|
|
165
|
+
agentName: agent.name,
|
|
166
|
+
harnessProvider: agent.harnessProvider ?? agent.provider ?? null,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (!check.agentId && !isAlias(model)) {
|
|
170
|
+
const poolError = await poolHarnessModelError(model);
|
|
171
|
+
if (poolError) return poolError;
|
|
172
|
+
}
|
|
173
|
+
return explicitModelError({ ...check, harnessProvider: null });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function poolHarnessModelError(model: string): Promise<string | null> {
|
|
177
|
+
const agents = await getAllAgents({ slim: true });
|
|
178
|
+
if (agents.length === 0) return null;
|
|
179
|
+
const { providers } = await loadModelsCatalog();
|
|
180
|
+
const sections = providers as HarnessCatalogSections;
|
|
181
|
+
const harnesses = new Set<string>();
|
|
182
|
+
for (const agent of agents) {
|
|
183
|
+
const harness = agent.harnessProvider ?? agent.provider ?? null;
|
|
184
|
+
if (!harnessModelMismatch(model, harness, sections)) return null;
|
|
185
|
+
if (harness) harnesses.add(harness);
|
|
186
|
+
}
|
|
187
|
+
return `Model "${model}" does not run on any registered agent harness (${[...harnesses].sort().join(", ")}). Use modelTier (smol, regular, smart, ultra) for portable intent, or omit model and let the claiming agent resolve it.`;
|
|
188
|
+
}
|
package/src/be/models-catalog.ts
CHANGED
|
@@ -60,8 +60,12 @@ export interface CatalogReasoningOption {
|
|
|
60
60
|
export interface CatalogModel {
|
|
61
61
|
id: string;
|
|
62
62
|
name?: string;
|
|
63
|
-
cost?: { input?: number; output?: number };
|
|
63
|
+
cost?: { input?: number; output?: number; cache_read?: number; cache_write?: number };
|
|
64
64
|
limit?: { context?: number };
|
|
65
|
+
/** models.dev `release_date` (ISO date). Drives newest-first ordering in harness lists. */
|
|
66
|
+
release_date?: string;
|
|
67
|
+
/** models.dev `status` (e.g. "deprecated"). Deprecated models drop out of harness lists. */
|
|
68
|
+
status?: string;
|
|
65
69
|
reasoning?: boolean;
|
|
66
70
|
reasoning_options?: CatalogReasoningOption[];
|
|
67
71
|
}
|
|
@@ -94,9 +98,20 @@ function slimModel(modelKey: string, model: ModelsDevModel): CatalogModel {
|
|
|
94
98
|
id: model.id ?? modelKey,
|
|
95
99
|
...(model.name !== undefined ? { name: model.name } : {}),
|
|
96
100
|
...(model.cost !== undefined
|
|
97
|
-
? {
|
|
101
|
+
? {
|
|
102
|
+
cost: {
|
|
103
|
+
input: model.cost.input,
|
|
104
|
+
output: model.cost.output,
|
|
105
|
+
...(model.cost.cache_read !== undefined ? { cache_read: model.cost.cache_read } : {}),
|
|
106
|
+
...(model.cost.cache_write !== undefined
|
|
107
|
+
? { cache_write: model.cost.cache_write }
|
|
108
|
+
: {}),
|
|
109
|
+
},
|
|
110
|
+
}
|
|
98
111
|
: {}),
|
|
99
112
|
...(model.limit?.context !== undefined ? { limit: { context: model.limit.context } } : {}),
|
|
113
|
+
...(typeof model.release_date === "string" ? { release_date: model.release_date } : {}),
|
|
114
|
+
...(typeof model.status === "string" ? { status: model.status } : {}),
|
|
100
115
|
...(model.reasoning !== undefined ? { reasoning: model.reasoning } : {}),
|
|
101
116
|
...(reasoningOptions.length > 0 ? { reasoning_options: reasoningOptions } : {}),
|
|
102
117
|
};
|
|
@@ -148,22 +163,61 @@ function mergePinnedEntries(catalog: ModelsCatalog): void {
|
|
|
148
163
|
}
|
|
149
164
|
}
|
|
150
165
|
|
|
151
|
-
/**
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Install a freshly built live catalog (already merged with the persistent
|
|
168
|
+
* table + overlay by `src/be/model-catalog-store.ts`). Pinned snapshot entries
|
|
169
|
+
* are re-merged so they never drop out of the picker.
|
|
170
|
+
*/
|
|
171
|
+
export function setLiveModelsCatalog(catalog: ModelsCatalog, updatedAt: number | null): void {
|
|
154
172
|
mergePinnedEntries(catalog);
|
|
155
173
|
liveCatalog = catalog;
|
|
156
|
-
liveUpdatedAt =
|
|
174
|
+
liveUpdatedAt = updatedAt;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Legacy in-memory update from a raw models.dev payload. The refresh path now
|
|
179
|
+
* persists to `model_catalog` and reloads via `reloadModelsCatalog()`; this
|
|
180
|
+
* stays for callers/tests that only have a payload in hand.
|
|
181
|
+
*/
|
|
182
|
+
export function updateLiveModelsCatalog(cache: ModelsDevCache, now = Date.now()): void {
|
|
183
|
+
setLiveModelsCatalog(buildModelsCatalog(cache), now);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Drop the in-memory catalog so the next async read rebuilds it from the DB. */
|
|
187
|
+
export function invalidateModelsCatalog(): void {
|
|
188
|
+
liveCatalog = null;
|
|
189
|
+
liveUpdatedAt = null;
|
|
190
|
+
snapshotOverride = null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function isModelsCatalogLoaded(): boolean {
|
|
194
|
+
return liveCatalog !== null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Deep copy of the slimmed vendored snapshot (safe to mutate). */
|
|
198
|
+
export function snapshotModelsCatalog(): ModelsCatalog {
|
|
199
|
+
return structuredClone(bundledSnapshotCatalog());
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Snapshot with overlay rows layered on; served while the table is empty. */
|
|
203
|
+
let snapshotOverride: ModelsCatalog | null = null;
|
|
204
|
+
export function setSnapshotOverlayCatalog(catalog: ModelsCatalog | null): void {
|
|
205
|
+
snapshotOverride = catalog;
|
|
157
206
|
}
|
|
158
207
|
|
|
159
208
|
export function getModelsCatalog(): ModelsCatalogResult {
|
|
160
209
|
if (liveCatalog) {
|
|
161
210
|
return { source: "live", updatedAt: liveUpdatedAt, providers: liveCatalog };
|
|
162
211
|
}
|
|
163
|
-
return {
|
|
212
|
+
return {
|
|
213
|
+
source: "snapshot",
|
|
214
|
+
updatedAt: null,
|
|
215
|
+
providers: snapshotOverride ?? bundledSnapshotCatalog(),
|
|
216
|
+
};
|
|
164
217
|
}
|
|
165
218
|
|
|
166
219
|
export function resetModelsCatalogForTests(): void {
|
|
167
220
|
liveCatalog = null;
|
|
168
221
|
liveUpdatedAt = null;
|
|
222
|
+
snapshotOverride = null;
|
|
169
223
|
}
|
|
@@ -287104,6 +287104,88 @@
|
|
|
287104
287104
|
"cache_read": 2.5
|
|
287105
287105
|
}
|
|
287106
287106
|
},
|
|
287107
|
+
"gpt-6.1-sol": {
|
|
287108
|
+
"id": "gpt-6.1-sol",
|
|
287109
|
+
"name": "GPT-6.1 Sol",
|
|
287110
|
+
"description": "Near-Astra performance for complex work at a lower cost",
|
|
287111
|
+
"family": "gpt-sol",
|
|
287112
|
+
"attachment": true,
|
|
287113
|
+
"reasoning": true,
|
|
287114
|
+
"reasoning_options": [
|
|
287115
|
+
{
|
|
287116
|
+
"type": "effort",
|
|
287117
|
+
"values": [
|
|
287118
|
+
"low",
|
|
287119
|
+
"medium",
|
|
287120
|
+
"high",
|
|
287121
|
+
"xhigh",
|
|
287122
|
+
"max"
|
|
287123
|
+
]
|
|
287124
|
+
}
|
|
287125
|
+
],
|
|
287126
|
+
"tool_call": true,
|
|
287127
|
+
"structured_output": true,
|
|
287128
|
+
"temperature": false,
|
|
287129
|
+
"knowledge": "2026-04-30",
|
|
287130
|
+
"release_date": "2026-09-29",
|
|
287131
|
+
"last_updated": "2026-09-29",
|
|
287132
|
+
"modalities": {
|
|
287133
|
+
"input": [
|
|
287134
|
+
"text",
|
|
287135
|
+
"image"
|
|
287136
|
+
],
|
|
287137
|
+
"output": [
|
|
287138
|
+
"text"
|
|
287139
|
+
]
|
|
287140
|
+
},
|
|
287141
|
+
"open_weights": false,
|
|
287142
|
+
"limit": {
|
|
287143
|
+
"context": 1050000,
|
|
287144
|
+
"input": 922000,
|
|
287145
|
+
"output": 128000
|
|
287146
|
+
},
|
|
287147
|
+
"experimental": {
|
|
287148
|
+
"modes": {
|
|
287149
|
+
"fast": {
|
|
287150
|
+
"cost": {
|
|
287151
|
+
"input": 4,
|
|
287152
|
+
"output": 20,
|
|
287153
|
+
"cache_read": 0.2,
|
|
287154
|
+
"cache_write": 5
|
|
287155
|
+
},
|
|
287156
|
+
"provider": {
|
|
287157
|
+
"body": {
|
|
287158
|
+
"service_tier": "priority"
|
|
287159
|
+
}
|
|
287160
|
+
}
|
|
287161
|
+
}
|
|
287162
|
+
}
|
|
287163
|
+
},
|
|
287164
|
+
"cost": {
|
|
287165
|
+
"input": 2,
|
|
287166
|
+
"output": 10,
|
|
287167
|
+
"cache_read": 0.1,
|
|
287168
|
+
"cache_write": 2.5,
|
|
287169
|
+
"tiers": [
|
|
287170
|
+
{
|
|
287171
|
+
"input": 4,
|
|
287172
|
+
"output": 15,
|
|
287173
|
+
"cache_read": 0.2,
|
|
287174
|
+
"cache_write": 5,
|
|
287175
|
+
"tier": {
|
|
287176
|
+
"type": "context",
|
|
287177
|
+
"size": 272000
|
|
287178
|
+
}
|
|
287179
|
+
}
|
|
287180
|
+
],
|
|
287181
|
+
"context_over_200k": {
|
|
287182
|
+
"input": 4,
|
|
287183
|
+
"output": 15,
|
|
287184
|
+
"cache_read": 0.2,
|
|
287185
|
+
"cache_write": 5
|
|
287186
|
+
}
|
|
287187
|
+
}
|
|
287188
|
+
},
|
|
287107
287189
|
"gpt-6-sol": {
|
|
287108
287190
|
"id": "gpt-6-sol",
|
|
287109
287191
|
"name": "GPT-6 Sol",
|
|
@@ -6,14 +6,25 @@ import {
|
|
|
6
6
|
type InsertPricingRowInput,
|
|
7
7
|
insertPricingRow,
|
|
8
8
|
} from "./db";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
applyOverlayPricingRows,
|
|
11
|
+
buildCatalogEntries,
|
|
12
|
+
countModelCatalog,
|
|
13
|
+
expireMatchedOverlays,
|
|
14
|
+
getModelCatalogMeta,
|
|
15
|
+
reloadModelsCatalog,
|
|
16
|
+
replaceModelCatalog,
|
|
17
|
+
touchModelCatalogCheckedAt,
|
|
18
|
+
updateModelCatalogMeta,
|
|
19
|
+
} from "./model-catalog-store";
|
|
10
20
|
import type { ModelsDevCache } from "./modelsdev-cache";
|
|
11
21
|
import { buildModelsDevSeedRows, type PricingSeedRow } from "./seed-pricing";
|
|
12
22
|
|
|
13
23
|
const MODELSDEV_API_URL = "https://models.dev/api.json";
|
|
14
24
|
export const PRICING_REFRESH_INTERVAL_MS = 12 * 60 * 60 * 1000;
|
|
25
|
+
/** Unforced `refreshModelCatalog()` calls skip the network when the last models.dev check (200 or 304) is younger than this. */
|
|
26
|
+
export const MODEL_CATALOG_FRESH_MS = 4 * 60 * 60 * 1000;
|
|
15
27
|
|
|
16
|
-
let lastETag: string | null = null;
|
|
17
28
|
let refreshLoopStarted = false;
|
|
18
29
|
|
|
19
30
|
interface RefreshPricingOptions {
|
|
@@ -28,6 +39,11 @@ export interface PricingRefreshResult {
|
|
|
28
39
|
unchanged: number;
|
|
29
40
|
pruned: number;
|
|
30
41
|
etag?: string;
|
|
42
|
+
/** Catalog keys ("provider/modelId") new since the previous fetch. */
|
|
43
|
+
added?: string[];
|
|
44
|
+
/** Overlay rows auto-expired because upstream now matches. */
|
|
45
|
+
expiredOverlays?: string[];
|
|
46
|
+
catalogModels?: number;
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
function logPricingRefresh(message: string): void {
|
|
@@ -129,17 +145,29 @@ export async function refreshPricingFromModelsDev(
|
|
|
129
145
|
): Promise<PricingRefreshResult> {
|
|
130
146
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
131
147
|
const now = opts.now ?? Date.now();
|
|
132
|
-
const
|
|
148
|
+
const meta = await getModelCatalogMeta();
|
|
149
|
+
// Only send validators when the table is populated — a 304 against an empty
|
|
150
|
+
// table (fresh DB, same ETag) would leave the catalog empty.
|
|
151
|
+
const catalogCount = await countModelCatalog();
|
|
152
|
+
const headers: Record<string, string> = {};
|
|
153
|
+
if (catalogCount > 0 && meta.etag) headers["If-None-Match"] = meta.etag;
|
|
154
|
+
if (catalogCount > 0 && meta.lastModified) headers["If-Modified-Since"] = meta.lastModified;
|
|
133
155
|
|
|
134
156
|
const response = await fetchImpl(MODELSDEV_API_URL, { headers });
|
|
135
157
|
if (response.status === 304) {
|
|
158
|
+
await touchModelCatalogCheckedAt(now);
|
|
159
|
+
await updateModelCatalogMeta({ lastCheckedAt: now });
|
|
160
|
+
await reloadModelsCatalog();
|
|
136
161
|
const result: PricingRefreshResult = {
|
|
137
162
|
status: "not_modified",
|
|
138
163
|
candidateRows: 0,
|
|
139
164
|
inserted: 0,
|
|
140
165
|
unchanged: 0,
|
|
141
166
|
pruned: 0,
|
|
142
|
-
etag:
|
|
167
|
+
etag: meta.etag ?? undefined,
|
|
168
|
+
added: [],
|
|
169
|
+
expiredOverlays: [],
|
|
170
|
+
catalogModels: catalogCount,
|
|
143
171
|
};
|
|
144
172
|
await auditPricingRefresh(result);
|
|
145
173
|
logPricingRefresh("models.dev returned 304; pricing rows unchanged");
|
|
@@ -151,36 +179,150 @@ export async function refreshPricingFromModelsDev(
|
|
|
151
179
|
|
|
152
180
|
const cache = (await response.json()) as ModelsDevCache;
|
|
153
181
|
const etag = response.headers.get("etag");
|
|
154
|
-
|
|
182
|
+
const lastModified = response.headers.get("last-modified");
|
|
183
|
+
const entries = buildCatalogEntries(cache, now);
|
|
184
|
+
const added = await replaceModelCatalog(entries);
|
|
155
185
|
const rows = buildModelsDevSeedRows(cache);
|
|
156
186
|
const { inserted, unchanged } = await insertChangedPricingRows(rows, now);
|
|
187
|
+
const expiredOverlays = await expireMatchedOverlays();
|
|
188
|
+
// Overlay prices only fill (provider, model, tokenClass) gaps upstream left.
|
|
189
|
+
const overlayInserted = await applyOverlayPricingRows(now);
|
|
157
190
|
const pruned = await prunePricingHistory(2);
|
|
158
|
-
|
|
191
|
+
await updateModelCatalogMeta({ etag, lastModified, lastFetchAt: now, lastCheckedAt: now });
|
|
192
|
+
await reloadModelsCatalog();
|
|
159
193
|
|
|
160
194
|
const result: PricingRefreshResult = {
|
|
161
195
|
status: "refreshed",
|
|
162
196
|
candidateRows: rows.length,
|
|
163
|
-
inserted,
|
|
197
|
+
inserted: inserted + overlayInserted,
|
|
164
198
|
unchanged,
|
|
165
199
|
pruned,
|
|
166
|
-
etag:
|
|
200
|
+
etag: etag ?? undefined,
|
|
201
|
+
added,
|
|
202
|
+
expiredOverlays,
|
|
203
|
+
catalogModels: entries.length,
|
|
167
204
|
};
|
|
168
205
|
await auditPricingRefresh(result);
|
|
169
206
|
logPricingRefresh(
|
|
170
|
-
`refreshed ${rows.length} candidate row(s); inserted=${inserted}; unchanged=${unchanged}; pruned=${pruned}`,
|
|
207
|
+
`refreshed ${rows.length} candidate row(s); inserted=${inserted}; unchanged=${unchanged}; pruned=${pruned}; catalog=${entries.length}; added=${added.length}; expiredOverlays=${expiredOverlays.length}`,
|
|
171
208
|
);
|
|
172
209
|
return result;
|
|
173
210
|
}
|
|
174
211
|
|
|
175
|
-
|
|
212
|
+
export interface ModelCatalogRefreshResult {
|
|
213
|
+
status: "updated" | "not-modified" | "skipped-fresh" | "skipped-cooldown" | "error";
|
|
214
|
+
models: number;
|
|
215
|
+
added: string[];
|
|
216
|
+
checkedAt: number | null;
|
|
217
|
+
/** Set with `skipped-cooldown`: milliseconds until a forced refresh is accepted again. */
|
|
218
|
+
retryAfterMs?: number;
|
|
219
|
+
error?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Minimum gap between forced refreshes accepted from callers (HTTP route, MCP tool). */
|
|
223
|
+
export const MODEL_CATALOG_FORCE_COOLDOWN_MS = 60 * 1000;
|
|
224
|
+
|
|
225
|
+
let refreshInFlight: Promise<ModelCatalogRefreshResult> | null = null;
|
|
226
|
+
let lastForcedRefreshAt: number | null = null;
|
|
227
|
+
|
|
228
|
+
/** Test-only: forget the in-flight refresh and the forced-refresh cooldown. */
|
|
229
|
+
export function resetModelCatalogRefreshGuardForTests(): void {
|
|
230
|
+
refreshInFlight = null;
|
|
231
|
+
lastForcedRefreshAt = null;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* `pi update --models` for the swarm. Unforced calls skip the network when the
|
|
236
|
+
* last fetch is younger than MODEL_CATALOG_FRESH_MS; `force` always fetches
|
|
237
|
+
* (still conditional on the stored ETag). Never throws — failures come back as
|
|
238
|
+
* `status: "error"` and the catalog keeps serving the last good table (or the
|
|
239
|
+
* vendored snapshot).
|
|
240
|
+
*/
|
|
241
|
+
export function refreshModelCatalog(
|
|
242
|
+
opts: { force?: boolean } & RefreshPricingOptions = {},
|
|
243
|
+
): Promise<ModelCatalogRefreshResult> {
|
|
244
|
+
// Single flight: a refresh that is already running serves every concurrent caller, so a burst of
|
|
245
|
+
// requests (or the boot loop racing a forced call) costs one models.dev fetch.
|
|
246
|
+
if (refreshInFlight) return refreshInFlight;
|
|
247
|
+
const run = runModelCatalogRefresh(opts).finally(() => {
|
|
248
|
+
if (refreshInFlight === run) refreshInFlight = null;
|
|
249
|
+
});
|
|
250
|
+
refreshInFlight = run;
|
|
251
|
+
return run;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Caller-facing entry for the HTTP route and the MCP tool: `refreshModelCatalog` plus a cooldown
|
|
256
|
+
* on `force`. A forced call within MODEL_CATALOG_FORCE_COOLDOWN_MS of the previous one does not
|
|
257
|
+
* fetch; it reports `skipped-cooldown` and how long to wait. Unforced calls pass straight through
|
|
258
|
+
* (they already skip the network while the table is fresh).
|
|
259
|
+
*/
|
|
260
|
+
export async function requestModelCatalogRefresh(
|
|
261
|
+
opts: { force?: boolean } & RefreshPricingOptions = {},
|
|
262
|
+
): Promise<ModelCatalogRefreshResult> {
|
|
263
|
+
const now = opts.now ?? Date.now();
|
|
264
|
+
if (opts.force) {
|
|
265
|
+
const waitMs =
|
|
266
|
+
lastForcedRefreshAt === null
|
|
267
|
+
? 0
|
|
268
|
+
: lastForcedRefreshAt + MODEL_CATALOG_FORCE_COOLDOWN_MS - now;
|
|
269
|
+
if (waitMs > 0) {
|
|
270
|
+
const meta = await getModelCatalogMeta().catch(() => null);
|
|
271
|
+
return {
|
|
272
|
+
status: "skipped-cooldown",
|
|
273
|
+
models: await countModelCatalog().catch(() => 0),
|
|
274
|
+
added: [],
|
|
275
|
+
checkedAt: meta?.lastCheckedAt ?? null,
|
|
276
|
+
retryAfterMs: waitMs,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
lastForcedRefreshAt = now;
|
|
280
|
+
}
|
|
281
|
+
return refreshModelCatalog({ ...opts, now });
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async function runModelCatalogRefresh(
|
|
285
|
+
opts: { force?: boolean } & RefreshPricingOptions = {},
|
|
286
|
+
): Promise<ModelCatalogRefreshResult> {
|
|
287
|
+
const now = opts.now ?? Date.now();
|
|
176
288
|
try {
|
|
177
|
-
await
|
|
289
|
+
const meta = await getModelCatalogMeta();
|
|
290
|
+
const count = await countModelCatalog();
|
|
291
|
+
if (
|
|
292
|
+
!opts.force &&
|
|
293
|
+
count > 0 &&
|
|
294
|
+
meta.lastCheckedAt !== null &&
|
|
295
|
+
now - meta.lastCheckedAt < MODEL_CATALOG_FRESH_MS
|
|
296
|
+
) {
|
|
297
|
+
await reloadModelsCatalog();
|
|
298
|
+
return { status: "skipped-fresh", models: count, added: [], checkedAt: meta.lastCheckedAt };
|
|
299
|
+
}
|
|
300
|
+
const result = await refreshPricingFromModelsDev({ fetchImpl: opts.fetchImpl, now });
|
|
301
|
+
return {
|
|
302
|
+
status: result.status === "refreshed" ? "updated" : "not-modified",
|
|
303
|
+
models: result.catalogModels ?? (await countModelCatalog()),
|
|
304
|
+
added: result.added ?? [],
|
|
305
|
+
checkedAt: now,
|
|
306
|
+
};
|
|
178
307
|
} catch (err) {
|
|
179
|
-
logPricingRefreshError("refresh failed", err);
|
|
308
|
+
logPricingRefreshError("model catalog refresh failed", err);
|
|
180
309
|
await auditPricingRefreshFailure(err);
|
|
310
|
+
const meta = await getModelCatalogMeta().catch(() => null);
|
|
311
|
+
return {
|
|
312
|
+
status: "error",
|
|
313
|
+
models: await countModelCatalog().catch(() => 0),
|
|
314
|
+
added: [],
|
|
315
|
+
checkedAt: meta?.lastCheckedAt ?? null,
|
|
316
|
+
error: scrubSecrets(err instanceof Error ? err.message : String(err)),
|
|
317
|
+
};
|
|
181
318
|
}
|
|
182
319
|
}
|
|
183
320
|
|
|
321
|
+
async function runPricingRefreshSafely(): Promise<void> {
|
|
322
|
+
// refreshModelCatalog never throws; errors are logged + audited inside.
|
|
323
|
+
await refreshModelCatalog();
|
|
324
|
+
}
|
|
325
|
+
|
|
184
326
|
export function startPricingRefreshLoop(): void {
|
|
185
327
|
if (refreshLoopStarted) return;
|
|
186
328
|
refreshLoopStarted = true;
|
|
@@ -262,6 +262,21 @@ export interface SwarmSdk {
|
|
|
262
262
|
config_set(args: { key: string; value: unknown; scope?: "global" | "agent" | "repo"; scopeId?: string; isSecret?: boolean }): Promise<unknown>;
|
|
263
263
|
config_delete(args: { id: string }): Promise<unknown>;
|
|
264
264
|
|
|
265
|
+
// --- write: model catalog ---
|
|
266
|
+
modelCatalog_refresh(args?: { force?: boolean }): Promise<unknown>;
|
|
267
|
+
modelCatalog_overlayUpsert(args: {
|
|
268
|
+
provider: string;
|
|
269
|
+
modelId: string;
|
|
270
|
+
name?: string;
|
|
271
|
+
releaseDate?: string;
|
|
272
|
+
contextWindow?: number;
|
|
273
|
+
maxOutput?: number;
|
|
274
|
+
reasoningOptions?: Array<{ type: string; values?: string[] }>;
|
|
275
|
+
pricing?: { input?: number; output?: number; cache_read?: number; cache_write?: number };
|
|
276
|
+
reason: string;
|
|
277
|
+
verifiedBy?: string;
|
|
278
|
+
}): Promise<unknown>;
|
|
279
|
+
|
|
265
280
|
// --- write: slack ---
|
|
266
281
|
slack_post(args: { channelId: string; message: string; blocks?: unknown }): Promise<unknown>;
|
|
267
282
|
slack_reply(args: { channelId?: string; threadTs?: string; message: string; taskId?: string; blocks?: unknown }): Promise<unknown>;
|