@desplega.ai/agent-swarm 2.7.10 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-pdy3qsvg.js +15 -0
- package/dist/{actions-b8aqhrsg.js → actions-pwjpn0j6.js} +19 -20
- package/dist/{amp-adapter-4c165vgn.js → amp-adapter-cq9jgj6x.js} +2 -3
- package/dist/{app-m9khefrh.js → app-cnfffgwg.js} +3 -3
- package/dist/{assistant-rh4v3ntz.js → assistant-kpn317y1.js} +21 -22
- package/dist/{boot-args-schema-hwkc8bzv.js → boot-args-schema-pbbnhmc3.js} +1 -1
- package/dist/{boot-reembed-fdyk55h4.js → boot-reembed-9m0ysxma.js} +1 -1
- package/dist/{boot-reembed-5y6yw9sj.js → boot-reembed-majbn53m.js} +1 -1
- package/dist/{boot-scrub-sweep-r5r8kqsn.js → boot-scrub-sweep-app8g8ym.js} +3 -3
- package/dist/{boot-seeds-8f9zt5cm.js → boot-seeds-pbtmvcjm.js} +4 -5
- package/dist/{claude-adapter-s5df247c.js → claude-adapter-wn1g3qp5.js} +7 -8
- package/dist/{claude-managed-adapter-h74d06yz.js → claude-managed-adapter-jh6c523j.js} +3 -3
- package/dist/{claude-managed-setup-9gsmwzyx.js → claude-managed-setup-pd47nzch.js} +6 -6
- package/dist/{claude-sdk-session-dq1j4nz9.js → claude-sdk-session-3a2a6589.js} +9066 -8818
- package/dist/{cli-n5yexkdg.js → cli-0b4zam62.js} +1 -0
- package/dist/{cli-5wfz00be.js → cli-0jzra9ad.js} +2 -2
- package/dist/{cli-zjphdj1a.js → cli-0ntbxyaa.js} +40 -18
- package/dist/{cli-yz7v0sh4.js → cli-1xh9a7hn.js} +4 -6
- package/dist/{cli-eqtfgfr6.js → cli-2gxeg5gr.js} +1 -1
- package/dist/{cli-hfkwwy1h.js → cli-2zp0et3v.js} +21 -2
- package/dist/{cli-6m6b4bep.js → cli-3rkdne1h.js} +2 -2
- package/dist/{cli-mr97t7cc.js → cli-4r05hnqa.js} +263 -14
- package/dist/{cli-jc1g9ndz.js → cli-5j88qqa8.js} +10 -5
- package/dist/{cli-xfjrc279.js → cli-5mrq3ake.js} +48 -14
- package/dist/{cli-an1knn2k.js → cli-6mma83xa.js} +5 -5
- package/dist/{cli-tph5wt3y.js → cli-6wj7p986.js} +1 -1
- package/dist/{cli-t73cas91.js → cli-7349va39.js} +8100 -7620
- package/dist/{cli-5xcb8gxq.js → cli-7b8sbmag.js} +8 -8
- package/dist/{cli-3xj33nrx.js → cli-7cp6aa1q.js} +10 -3
- package/dist/{cli-mp9aa8g5.js → cli-7p1kvkck.js} +6 -6
- package/dist/{cli-j7d73g1y.js → cli-7w69ne2f.js} +3035 -354
- package/dist/{cli-cr14kftt.js → cli-89cqnasv.js} +3 -3
- package/dist/{cli-w3bk0dgv.js → cli-8aes17e4.js} +2 -2
- package/dist/{cli-7wz05bx3.js → cli-93k32c37.js} +468 -745
- package/dist/{cli-eqk5p56g.js → cli-9vhebtjz.js} +9 -9
- package/dist/{cli-td33w98c.js → cli-9wngrawf.js} +10 -10
- package/dist/cli-a3b239vq.js +242 -0
- package/dist/{cli-kx4c8j05.js → cli-b085njxz.js} +63 -19
- package/dist/{cli-8ewkreqd.js → cli-b5rs97a6.js} +7 -9
- package/dist/{cli-bxz823sz.js → cli-b8e9nb04.js} +1 -1
- package/dist/{cli-nj3x45rw.js → cli-bb431xey.js} +52 -43
- package/dist/{cli-36wdfzgn.js → cli-bsywb58a.js} +8 -8
- package/dist/{cli-18qt3few.js → cli-cyhbbd1z.js} +1 -1
- package/dist/{cli-eb2azq8n.js → cli-d3p5vwbk.js} +9 -9
- package/dist/{cli-2tsfpc70.js → cli-dy32zecz.js} +1 -1
- package/dist/{cli-rjyghzg4.js → cli-g70vxtjh.js} +2 -2
- package/dist/{cli-55bkx8hh.js → cli-gax7fk3t.js} +1 -1
- package/dist/{cli-jg24scat.js → cli-jcpr5smb.js} +3 -3
- package/dist/{cli-n07eecjs.js → cli-jywyhqws.js} +3 -3
- package/dist/{cli-38yww4e9.js → cli-k0615eh8.js} +8 -8
- package/dist/{cli-3xddv0rk.js → cli-k26bkr9t.js} +5 -7
- package/dist/{cli-xd5ebp64.js → cli-k93bq1wq.js} +3 -3
- package/dist/{cli-f2zenhja.js → cli-kc7v1nfv.js} +1 -1
- package/dist/{cli-x9exydey.js → cli-m4dqmnbp.js} +1 -1
- package/dist/{cli-gpwhbgx0.js → cli-m9s2qff2.js} +57 -25
- package/dist/{cli-ybjdc978.js → cli-mrt48bx7.js} +7 -4
- package/dist/{cli-ttbqe3q4.js → cli-p1w18yhx.js} +1 -1
- package/dist/{cli-h49ejvmc.js → cli-pcad4cb1.js} +1 -1
- package/dist/{cli-tmft5dz2.js → cli-qmqk2yc2.js} +1 -1
- package/dist/{cli-g1px1g2e.js → cli-re4raaj0.js} +1 -1
- package/dist/{cli-xbtq4d6s.js → cli-sn7rtnj4.js} +12 -8
- package/dist/{cli-n9abj89w.js → cli-syybb0p1.js} +8 -8
- package/dist/{cli-v2fwbnsk.js → cli-tacge1w0.js} +6 -6
- package/dist/{cli-pyrxt9gw.js → cli-tk7cjj8h.js} +1 -1
- package/dist/{cli-xvymtmv4.js → cli-tqegb8eq.js} +3 -3
- package/dist/{cli-kf3pxxdg.js → cli-v1dv1r37.js} +1 -1
- package/dist/{cli-z9cs5m0w.js → cli-vbh10fqa.js} +12 -12
- package/dist/{cli-3xcwp3z8.js → cli-vj75tyaw.js} +3 -3
- package/dist/{cli-xncjscpm.js → cli-vqptjbr7.js} +50 -24
- package/dist/{cli-q581b386.js → cli-wk18cm92.js} +5 -5
- package/dist/{cli-4vwxp550.js → cli-x1wa213s.js} +1 -1
- package/dist/{cli-n9ftpys4.js → cli-x6t50dmw.js} +7 -7
- package/dist/{cli-jrp1dt73.js → cli-xzm9vcfg.js} +1 -1
- package/dist/{cli-16phend6.js → cli-yn2bbre9.js} +1 -1
- package/dist/{cli-rt0ag4x1.js → cli-yncmerje.js} +5 -5
- package/dist/{cli-0m7rtm11.js → cli-zcsw143p.js} +1 -1
- package/dist/cli.js +18 -18
- package/dist/{codex-adapter-yr60sme6.js → codex-adapter-nha71q3n.js} +5 -6
- package/dist/{codex-hook-fac6175r.js → codex-hook-h3vk6xzr.js} +1 -1
- package/dist/{codex-session-runner-pch8x584.js → codex-session-runner-ak9x1k1h.js} +5 -6
- package/dist/{commands-phjfbkv0.js → commands-f587qpq8.js} +3 -3
- package/dist/{controller-jkx994pz.js → controller-hxx8wwy1.js} +2 -2
- package/dist/{controllers-connect-c4448kwa.js → controllers-connect-k5sg9m9h.js} +20 -21
- package/dist/{cursor-adapter-ndebqnm8.js → cursor-adapter-n5nc3mfe.js} +1 -2
- package/dist/{db-ef32tbfc.js → db-amm8w15a.js} +10 -2
- package/dist/{db-ez6egt6v.js → db-nzf8zb5z.js} +3 -3
- package/dist/{devin-adapter-z46ep5ph.js → devin-adapter-xedz98zv.js} +1 -1
- package/dist/{dispatcher-g3tt9hs9.js → dispatcher-89zrts8f.js} +18 -19
- package/dist/{dsh-adapter-tcyn3099.js → dsh-adapter-nrhbrjz8.js} +1 -2
- package/dist/{easter-egg-3d-e36hk5td.js → easter-egg-3d-533knw22.js} +1 -1
- package/dist/{embedding-space-4kyh5qqj.js → embedding-space-ezwenjmj.js} +6 -6
- package/dist/{embeddings-6a8v4a6t.js → embeddings-np74ht6g.js} +1 -1
- package/dist/{execute-3cbg0twf.js → execute-b3mrb1mv.js} +1 -1
- package/dist/{external-channel-se646snz.js → external-channel-z46yx9d7.js} +2 -2
- package/dist/{fx-adapter-yw795hqq.js → fx-adapter-3q12snn6.js} +7 -8
- package/dist/{grok-adapter-ttmcss2j.js → grok-adapter-ahb1w033.js} +7 -8
- package/dist/handlers-vbww69re.js +32 -0
- package/dist/heartbeat-dt9qw9c8.js +43 -0
- package/dist/{hook-hq93y5ej.js → hook-8k6fbz9b.js} +5 -5
- package/dist/{hook-g3nhexsy.js → hook-jgcgygex.js} +6 -6
- package/dist/{http-5a9p4h6y.js → http-haw4r8ne.js} +284 -142
- package/dist/{index-0eny15vj.js → index-2skqtd76.js} +2 -2
- package/dist/{index-6haqt3v5.js → index-4a0670yh.js} +8917 -8476
- package/dist/index-4xwaf5th.js +32 -0
- package/dist/{index-3c5pxbge.js → index-5gk12my8.js} +1 -1
- package/dist/{index-w7em4ktq.js → index-d6wkh8ar.js} +2 -2
- package/dist/index-f0hcrs8e.js +33 -0
- package/dist/{index-rvccek1w.js → index-gjwaqaq8.js} +5 -5
- package/dist/{index-e5pfbsys.js → index-hjhfk3ra.js} +3 -3
- package/dist/{index-1qw6f2dc.js → index-khe3gp0k.js} +4 -4
- package/dist/index-s4ewdma4.js +37 -0
- package/dist/{index-hgn3c961.js → index-tez78qj3.js} +979 -36
- package/dist/{index-s72rqgsx.js → index-tvfafeyy.js} +1 -1
- package/dist/{keepalive-1j4n4dmk.js → keepalive-xn6s7rmg.js} +3 -3
- package/dist/lead-6ygbfhbh.js +70 -0
- package/dist/{maintenance-dmghacy5.js → maintenance-vdts800b.js} +1 -1
- package/dist/{node-je82wjet.js → node-4c5jqxr3.js} +1 -1
- package/dist/{oauth-refresh-sweep-yy06c03c.js → oauth-refresh-sweep-094c8wfk.js} +2 -2
- package/dist/{onboard-52f9t5dm.js → onboard-v99eh56m.js} +3 -3
- package/dist/{opencode-adapter-krnh9jkn.js → opencode-adapter-dsagkhtw.js} +5 -6
- package/dist/{otel-impl-xjqz6wjj.js → otel-impl-q7yr9yp0.js} +1 -1
- package/dist/{pi-mono-adapter-dbxyp0qv.js → pi-mono-adapter-546cd1cc.js} +9 -9
- package/dist/{pricing-refresh-ctdr74pd.js → pricing-refresh-7dh2yase.js} +2 -3
- package/dist/{rbac-roles-ehv8s10n.js → rbac-roles-mdmc96p4.js} +3 -3
- package/dist/{rbac-roles-q0gr8eyj.js → rbac-roles-npbmdh77.js} +4 -6
- package/dist/{registry-hpjfmcfz.js → registry-32b1mft6.js} +1 -1
- package/dist/{render-v2-5b6chvcq.js → render-v2-twhhwmms.js} +3 -3
- package/dist/{resume-5a5d2845.js → resume-5gsrjd5e.js} +6 -6
- package/dist/{runtime-khxszyfp.js → runtime-1hv06jsn.js} +1 -1
- package/dist/{session-access-gj0bjhqg.js → session-access-m191x30x.js} +4 -4
- package/dist/{session-source-backfill-2sy0krfk.js → session-source-backfill-nt923ask.js} +2 -2
- package/dist/{setup-7ssfakk1.js → setup-wv467afy.js} +1 -1
- package/dist/{virtual-modules-pjj0knwf.js → virtual-modules-gazyapte.js} +3 -3
- package/dist/{work-objects-bf3syvhq.js → work-objects-8zkrpy13.js} +21 -22
- package/dist/{worker-follow-up-38xevga6.js → worker-follow-up-cecqszem.js} +18 -19
- package/dist/worker-mz5z7kj0.js +70 -0
- package/openapi.json +334 -7
- package/package.json +5 -5
- package/src/apps/definition.ts +11 -0
- package/src/apps/store.ts +28 -8
- package/src/be/db/model-profiles.ts +147 -38
- package/src/be/db/tasks/read.ts +5 -1
- package/src/be/db/workflow-run-definitions.ts +117 -0
- package/src/be/db.ts +24 -3
- package/src/be/memory/constants.ts +14 -1
- package/src/be/memory/key-paths.ts +8 -0
- package/src/be/memory/providers/sqlite-store.ts +160 -10
- package/src/be/memory/task-learning.ts +79 -14
- package/src/be/memory/types.ts +24 -1
- package/src/be/migrations/279_backfill_learning_expiry.sql +15 -0
- package/src/be/migrations/281_model_profiles_pr2.sql +28 -0
- package/src/be/migrations/283_workflow_run_definitions.sql +14 -0
- package/src/be/model-profile-check.ts +284 -0
- package/src/be/model-tier-resolution.ts +112 -12
- package/src/be/multi-runtime.ts +27 -0
- package/src/be/runtime-pools/routing.ts +52 -4
- package/src/be/scripts/typecheck.ts +1 -0
- package/src/be/seed-scripts/catalog/dreaming-learnings.ts +552 -0
- package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +389 -14
- package/src/be/seed-scripts/catalog/dreaming-memtax.ts +6 -3
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/steering.ts +8 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +32 -1
- package/src/fs/provider.ts +17 -3
- package/src/heartbeat/heartbeat.ts +12 -1
- package/src/heartbeat/index.ts +1 -0
- package/src/http/agents.ts +56 -4
- package/src/http/apps.ts +3 -1
- package/src/http/config.ts +2 -6
- package/src/http/index.ts +2 -3
- package/src/http/model-profiles.ts +58 -10
- package/src/http/poll.ts +36 -3
- package/src/http/schedules.ts +42 -3
- package/src/http/tasks.ts +37 -12
- package/src/http/workflows.ts +15 -2
- package/src/prompts/session-templates.ts +1 -1
- package/src/providers/acp-targets.ts +11 -6
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-sdk-session.ts +132 -23
- package/src/providers/codex-skill-resolver.ts +10 -4
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/devin-skill-resolver.ts +5 -5
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/scheduler/schedule-task.ts +1 -0
- package/src/scripts-runtime/eval-harness.ts +14 -1
- package/src/scripts-runtime/executors/types.ts +3 -0
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/swarm-sdk.ts +18 -1
- package/src/scripts-runtime/types/stdlib.d.ts +1 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
- package/src/server.ts +2 -0
- package/src/slack/app.ts +93 -0
- package/src/slack/inbound-dispatch.ts +18 -1
- package/src/slack/workspace-guard.ts +345 -0
- package/src/tasks/task-terminal-effects.ts +4 -0
- package/src/tasks/worker-follow-up.ts +102 -2
- package/src/tests/acp-adapter.test.ts +82 -0
- package/src/tests/apps-icon.test.ts +120 -0
- package/src/tests/chained-task-follow-up.test.ts +248 -0
- package/src/tests/check-pr-body.test.ts +40 -0
- package/src/tests/claude-sdk-lifecycle.test.ts +216 -1
- package/src/tests/claude-sdk-process.fixture.ts +57 -0
- package/src/tests/codex-skill-resolver.test.ts +31 -0
- package/src/tests/credentials-allowlist.test.ts +470 -0
- package/src/tests/db-task-read-contract.test.ts +5 -0
- package/src/tests/db-task-write-contract.test.ts +5 -0
- package/src/tests/deferred-wake-follow-up.test.ts +47 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dreaming-learnings.test.ts +1395 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/explicit-model-validation.test.ts +2 -0
- package/src/tests/fs-provider.test.ts +42 -0
- package/src/tests/heartbeat.test.ts +28 -1
- package/src/tests/human-free-reclassify.test.ts +5 -1
- package/src/tests/list-endpoint-slimming.test.ts +17 -0
- package/src/tests/mcp-tools.test.ts +1 -1
- package/src/tests/migration-283-workflow-run-definitions.test.ts +69 -0
- package/src/tests/model-profile-check.test.ts +387 -0
- package/src/tests/model-profiles-api.test.ts +528 -1
- package/src/tests/profile-claim.test.ts +415 -3
- package/src/tests/profile-tier-alias.test.ts +382 -0
- package/src/tests/schedule-profile.test.ts +359 -0
- package/src/tests/script-connections.test.ts +6 -0
- package/src/tests/script-native-unawaited-drain.test.ts +167 -0
- package/src/tests/script-per-script-executor.test.ts +1 -0
- package/src/tests/scripts-sdk-bridge-tool-failure.test.ts +141 -0
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/slack-inbound-receipts.test.ts +22 -2
- package/src/tests/slack-socket-ack.test.ts +16 -1
- package/src/tests/slack-workspace-guard.test.ts +905 -0
- package/src/tests/steering-core.test.ts +40 -0
- package/src/tests/store-progress-learning.test.ts +605 -20
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/workflow-convergence.test.ts +46 -40
- package/src/tests/workflow-definition-pinning-recovery.test.ts +552 -0
- package/src/tests/workflow-definition-pinning.test.ts +645 -0
- package/src/tests/workflow-executors.test.ts +16 -7
- package/src/tests/workflow-foreach.test.ts +43 -20
- package/src/tests/workflow-notify-slack-ready.test.ts +161 -0
- package/src/tests/workflow-profile.test.ts +328 -0
- package/src/tools/app-upsert.ts +1 -1
- package/src/tools/memory-edit.ts +2 -1
- package/src/tools/model-profiles/check-model-profile.ts +63 -0
- package/src/tools/schedules/create-schedule.ts +45 -4
- package/src/tools/schedules/patch-schedule.ts +50 -4
- package/src/tools/schedules/update-schedule.ts +50 -4
- package/src/tools/script-run.ts +1 -1
- package/src/tools/send-task.ts +17 -2
- package/src/tools/store-progress.ts +15 -3
- package/src/tools/task-action.ts +9 -1
- package/src/tools/templates.ts +13 -0
- package/src/tools/tool-config.ts +2 -1
- package/src/tools/utils.ts +61 -4
- package/src/tools/workflows/create-workflow.ts +1 -1
- package/src/tools/workflows/retry-workflow-run.ts +1 -1
- package/src/tools/workflows/update-workflow.ts +10 -1
- package/src/types.ts +56 -1
- package/src/utils/credentials.ts +89 -12
- package/src/workflows/engine.ts +10 -1
- package/src/workflows/executors/agent-task.ts +21 -2
- package/src/workflows/executors/foreach.ts +4 -1
- package/src/workflows/executors/notify.ts +62 -6
- package/src/workflows/executors/sub-workflow.ts +1 -1
- package/src/workflows/executors/swarm-script.ts +4 -1
- package/src/workflows/foreach-driver.ts +8 -5
- package/src/workflows/limits.ts +2 -1
- package/src/workflows/model-validation.ts +27 -2
- package/src/workflows/patch-definition.ts +3 -1
- package/src/workflows/recovery.ts +6 -6
- package/src/workflows/resume.ts +9 -9
- package/src/workflows/retry-poller.ts +2 -2
- package/templates/skills/apps/SKILL.md +2 -0
- package/templates/skills/apps/content.md +2 -0
- package/templates/skills/code-quality/content.md +12 -0
- package/templates/skills/memory/content.md +8 -0
- package/templates/skills/scheduling/config.json +1 -1
- package/templates/skills/scheduling/content.md +2 -2
- package/templates/skills/swarm-docs/content.md +4 -0
- package/templates/skills/swarm-extensions/content.md +1 -1
- package/templates/skills/swarm-scripts/SKILL.md +2 -2
- package/templates/skills/swarm-scripts/content.md +2 -2
- package/templates/skills/work-on-task/SKILL.md +2 -0
- package/templates/skills/work-on-task/content.md +2 -0
- package/templates/workflows/dreaming/content.md +174 -7
- package/dist/acp-adapter-srfhs1s9.js +0 -16
- package/dist/cli-bzvs88tv.js +0 -339
- package/dist/cli-cyn9v8zr.js +0 -748
- package/dist/cli-ed6yqpf1.js +0 -779
- package/dist/handlers-17wha3ze.js +0 -33
- package/dist/heartbeat-gwewgdms.js +0 -42
- package/dist/index-8arwq8mw.js +0 -34
- package/dist/index-tpw054az.js +0 -38
- package/dist/index-waq75j2j.js +0 -31
- package/dist/lead-re73kdgc.js +0 -72
- package/dist/worker-r8mz7a65.js +0 -72
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
// A model profile's credential allowlist: the worker picks pooled keys only
|
|
2
|
+
// from the allowlisted suffixes (`resolveCredentialPools` → `selectCredential`),
|
|
3
|
+
// fails fast when none match, and behaves exactly as before without one. The
|
|
4
|
+
// last block drives the real `/api/poll` handler to check the claim trigger
|
|
5
|
+
// carries the allowlist.
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
afterAll,
|
|
9
|
+
afterEach,
|
|
10
|
+
beforeAll,
|
|
11
|
+
beforeEach,
|
|
12
|
+
describe,
|
|
13
|
+
expect,
|
|
14
|
+
spyOn,
|
|
15
|
+
test,
|
|
16
|
+
} from "bun:test";
|
|
17
|
+
import { unlink } from "node:fs/promises";
|
|
18
|
+
import { closeDb, createAgent, createTaskExtended, getDbClient, initDb, pauseTask } from "../be/db";
|
|
19
|
+
import { createModelProfile } from "../be/db/model-profiles";
|
|
20
|
+
import { fetchResolvedEnv, getPausedTasksFromAPI } from "../commands/runner";
|
|
21
|
+
import { handlePoll } from "../http/poll";
|
|
22
|
+
import { handleTasks } from "../http/tasks";
|
|
23
|
+
import {
|
|
24
|
+
type AvailabilityInfo,
|
|
25
|
+
CredentialAllowlistError,
|
|
26
|
+
keySuffix,
|
|
27
|
+
ModelWindowExhaustedError,
|
|
28
|
+
resolveCredentialPools,
|
|
29
|
+
selectCredential,
|
|
30
|
+
} from "../utils/credentials";
|
|
31
|
+
|
|
32
|
+
const VAR = "CLAUDE_CODE_OAUTH_TOKEN";
|
|
33
|
+
// Positions 0..3; the allowlist below names positions 1 and 3.
|
|
34
|
+
const POOL = ["tok-aaaaa", "tok-bbbbb", "tok-ccccc", "tok-ddddd"];
|
|
35
|
+
const ALLOWED = ["bbbbb", "ddddd"];
|
|
36
|
+
const ALLOWED_IDX = [1, 3];
|
|
37
|
+
|
|
38
|
+
async function pick(
|
|
39
|
+
info: AvailabilityInfo | undefined,
|
|
40
|
+
opts: {
|
|
41
|
+
allow?: Record<string, string[]>;
|
|
42
|
+
model?: string;
|
|
43
|
+
enforceModelCapacity?: boolean;
|
|
44
|
+
localBlocks?: Map<string, number>;
|
|
45
|
+
} = {},
|
|
46
|
+
) {
|
|
47
|
+
const env: Record<string, string | undefined> = { [VAR]: POOL.join(",") };
|
|
48
|
+
const selections = await resolveCredentialPools(env, {
|
|
49
|
+
provider: "claude",
|
|
50
|
+
model: opts.model ?? "sonnet",
|
|
51
|
+
availableIndicesMap: info ? { [VAR]: info } : {},
|
|
52
|
+
enforceModelCapacity: opts.enforceModelCapacity,
|
|
53
|
+
localBlocks: opts.localBlocks,
|
|
54
|
+
allowedKeySuffixes: "allow" in opts ? opts.allow : { [VAR]: ALLOWED },
|
|
55
|
+
allowlistProfile: "claude-pinned",
|
|
56
|
+
});
|
|
57
|
+
expect(selections).toHaveLength(1);
|
|
58
|
+
const selection = selections[0]!;
|
|
59
|
+
expect(env[VAR]).toBe(selection.selected);
|
|
60
|
+
return selection;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function indicesOver(draws: number, run: () => ReturnType<typeof pick>) {
|
|
64
|
+
const seen = new Set<number>();
|
|
65
|
+
for (let i = 0; i < draws; i++) seen.add((await run()).index);
|
|
66
|
+
return seen;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let logSpy: ReturnType<typeof spyOn>;
|
|
70
|
+
beforeEach(() => {
|
|
71
|
+
logSpy = spyOn(console, "log").mockImplementation(() => {});
|
|
72
|
+
});
|
|
73
|
+
afterEach(() => {
|
|
74
|
+
logSpy.mockRestore();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("keySuffix", () => {
|
|
78
|
+
test("is the last five characters, the same suffix a task record stamps", () => {
|
|
79
|
+
expect(keySuffix("sk-ant-oat01-xyz12345")).toBe("12345");
|
|
80
|
+
expect(selectCredential("a-11111,b-22222", [1]).keySuffix).toBe(keySuffix("b-22222"));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("resolveCredentialPools with an allowlist", () => {
|
|
85
|
+
test("maps allowlisted suffixes to their positions in the full 4-key pool", async () => {
|
|
86
|
+
const seen = await indicesOver(200, () => pick(undefined));
|
|
87
|
+
expect([...seen].sort()).toEqual(ALLOWED_IDX);
|
|
88
|
+
const selection = await pick(undefined);
|
|
89
|
+
// Indices stay positions in the full pool: reportKeyUsage and keyIndex are unaffected.
|
|
90
|
+
expect(selection.total).toBe(4);
|
|
91
|
+
expect(selection.selected).toBe(POOL[selection.index]);
|
|
92
|
+
expect(ALLOWED).toContain(selection.keySuffix);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("intersects the server's available indices with the allowlist", async () => {
|
|
96
|
+
const seen = await indicesOver(200, () => pick({ availableIndices: [0, 1, 2] }));
|
|
97
|
+
expect([...seen]).toEqual([1]);
|
|
98
|
+
expect((await pick({ availableIndices: [0, 1, 2] })).isRateLimitFallback).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("all rate-limited: 1,000 draws never leave the allowlist", async () => {
|
|
102
|
+
const seen = new Set<number>();
|
|
103
|
+
for (let i = 0; i < 1000; i++) {
|
|
104
|
+
const selection = await pick({ availableIndices: [] });
|
|
105
|
+
expect(selection.isRateLimitFallback).toBe(true);
|
|
106
|
+
seen.add(selection.index);
|
|
107
|
+
}
|
|
108
|
+
expect([...seen].sort()).toEqual(ALLOWED_IDX);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("only non-allowlisted keys available: picks within the allowlist as a rate-limit fallback", async () => {
|
|
112
|
+
const seen = new Set<number>();
|
|
113
|
+
for (let i = 0; i < 200; i++) {
|
|
114
|
+
const selection = await pick({ availableIndices: [0, 2] });
|
|
115
|
+
expect(selection.isRateLimitFallback).toBe(true);
|
|
116
|
+
seen.add(selection.index);
|
|
117
|
+
}
|
|
118
|
+
expect([...seen].sort()).toEqual(ALLOWED_IDX);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("the seat fallback is restricted to the allowlist", async () => {
|
|
122
|
+
// Key 1 is on a seat without the model; keys 0 and 2 are fine but not allowlisted.
|
|
123
|
+
const info = { availableIndices: [], modelBlockedIndices: [], seatBlockedIndices: [1] };
|
|
124
|
+
const seen = await indicesOver(200, () =>
|
|
125
|
+
pick(info, { model: "opus", enforceModelCapacity: true }),
|
|
126
|
+
);
|
|
127
|
+
expect([...seen]).toEqual([3]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("every allowlisted key seat-blocked fails fast, though other keys could run it", async () => {
|
|
131
|
+
const info = { availableIndices: [], modelBlockedIndices: [], seatBlockedIndices: [1, 3] };
|
|
132
|
+
const error = await pick(info, { model: "opus", enforceModelCapacity: true }).catch((e) => e);
|
|
133
|
+
expect(error).toBeInstanceOf(ModelWindowExhaustedError);
|
|
134
|
+
expect((error as ModelWindowExhaustedError).seatBlockedCount).toBe(2);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("window exhaustion is counted over the allowlist only", async () => {
|
|
138
|
+
// Keys 0 and 2 have Opus capacity, but both allowlisted keys are window-blocked.
|
|
139
|
+
const exhausted = {
|
|
140
|
+
availableIndices: [0, 2],
|
|
141
|
+
modelBlockedIndices: [1, 3],
|
|
142
|
+
earliestModelResetAt: "2026-10-20T00:00:00.000Z",
|
|
143
|
+
};
|
|
144
|
+
const error = await pick(exhausted, { model: "opus", enforceModelCapacity: true }).catch(
|
|
145
|
+
(e) => e,
|
|
146
|
+
);
|
|
147
|
+
expect(error).toBeInstanceOf(ModelWindowExhaustedError);
|
|
148
|
+
expect((error as ModelWindowExhaustedError).modelBlockedCount).toBe(2);
|
|
149
|
+
|
|
150
|
+
// A window block on a key outside the allowlist does not count: the allowlisted keys
|
|
151
|
+
// are only key-wide rate-limited, so the pick goes ahead within the allowlist.
|
|
152
|
+
const outside = { availableIndices: [2], modelBlockedIndices: [0] };
|
|
153
|
+
const selection = await pick(outside, { model: "opus", enforceModelCapacity: true });
|
|
154
|
+
expect(ALLOWED_IDX).toContain(selection.index);
|
|
155
|
+
expect(selection.isRateLimitFallback).toBe(true);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("a local window block on an allowlisted key is counted too", async () => {
|
|
159
|
+
const localBlocks = new Map([[`${VAR}:1:seven_day_opus`, Date.now() + 60_000]]);
|
|
160
|
+
const error = await pick(
|
|
161
|
+
{ availableIndices: [0, 1, 2], modelBlockedIndices: [3] },
|
|
162
|
+
{ model: "opus", enforceModelCapacity: true, localBlocks },
|
|
163
|
+
).catch((e) => e);
|
|
164
|
+
expect(error).toBeInstanceOf(ModelWindowExhaustedError);
|
|
165
|
+
expect((error as ModelWindowExhaustedError).modelBlockedCount).toBe(2);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("zero matches throws CredentialAllowlistError naming the profile and both suffixes", async () => {
|
|
169
|
+
const error = await pick(undefined, { allow: { [VAR]: ["a1b2c", "x9y8z"] } }).catch((e) => e);
|
|
170
|
+
expect(error).toBeInstanceOf(CredentialAllowlistError);
|
|
171
|
+
expect((error as Error).message).toBe(
|
|
172
|
+
`credential allowlist for claude-pinned matches no ${VAR} key (wanted a1b2c, x9y8z)`,
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("a single-key pool that is not allowlisted throws too", async () => {
|
|
177
|
+
const env = { [VAR]: "tok-only1" };
|
|
178
|
+
await expect(
|
|
179
|
+
resolveCredentialPools(env, {
|
|
180
|
+
provider: "claude",
|
|
181
|
+
allowedKeySuffixes: { [VAR]: ["abcde"] },
|
|
182
|
+
}),
|
|
183
|
+
).rejects.toBeInstanceOf(CredentialAllowlistError);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("a var without an entry keeps its whole pool", async () => {
|
|
187
|
+
const seen = await indicesOver(300, () =>
|
|
188
|
+
pick(undefined, { allow: { ANTHROPIC_API_KEY: ["zzzzz"] } }),
|
|
189
|
+
);
|
|
190
|
+
expect([...seen].sort()).toEqual([0, 1, 2, 3]);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe("selectCredential allowedIndices", () => {
|
|
195
|
+
test("bounds the pick-anyway branches", () => {
|
|
196
|
+
const value = POOL.join(",");
|
|
197
|
+
for (let i = 0; i < 500; i++) {
|
|
198
|
+
expect(ALLOWED_IDX).toContain(selectCredential(value, [], VAR, ALLOWED_IDX).index);
|
|
199
|
+
expect(ALLOWED_IDX).toContain(selectCredential(value, [7, 9], VAR, ALLOWED_IDX).index);
|
|
200
|
+
expect(ALLOWED_IDX).toContain(selectCredential(value, undefined, VAR, ALLOWED_IDX).index);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe("no allowlist is byte-identical to today", () => {
|
|
206
|
+
/** A fixed pseudo-random sequence, restarted per run. */
|
|
207
|
+
function seeded(seed: number) {
|
|
208
|
+
let state = seed;
|
|
209
|
+
return () => {
|
|
210
|
+
state = (state * 1103515245 + 12345) % 2147483648;
|
|
211
|
+
return state / 2147483648;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function runSeeded(
|
|
216
|
+
seed: number,
|
|
217
|
+
info: AvailabilityInfo | undefined,
|
|
218
|
+
allow: Record<string, string[]> | undefined,
|
|
219
|
+
) {
|
|
220
|
+
const rand = seeded(seed);
|
|
221
|
+
const spy = spyOn(Math, "random").mockImplementation(rand);
|
|
222
|
+
try {
|
|
223
|
+
const out: Array<[number, boolean | undefined]> = [];
|
|
224
|
+
for (let i = 0; i < 50; i++) {
|
|
225
|
+
const s = await pick(info, { allow });
|
|
226
|
+
out.push([s.index, s.isRateLimitFallback]);
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
} finally {
|
|
230
|
+
spy.mockRestore();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The pre-allowlist picker, inlined: random over all keys, or over the available ones. */
|
|
235
|
+
function legacy(seed: number, available: number[] | undefined) {
|
|
236
|
+
const rand = seeded(seed);
|
|
237
|
+
const out: Array<[number, boolean | undefined]> = [];
|
|
238
|
+
for (let i = 0; i < 50; i++) {
|
|
239
|
+
if (available && available.length > 0) {
|
|
240
|
+
out.push([available[Math.floor(rand() * available.length)]!, false]);
|
|
241
|
+
} else {
|
|
242
|
+
out.push([Math.floor(rand() * POOL.length), available !== undefined]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
for (const [label, available] of [
|
|
249
|
+
["no availability info", undefined],
|
|
250
|
+
["some keys available", [0, 2, 3]],
|
|
251
|
+
["all rate-limited", []],
|
|
252
|
+
] as const) {
|
|
253
|
+
test(`same seed, same pick: ${label}`, async () => {
|
|
254
|
+
const info = available ? { availableIndices: [...available] } : undefined;
|
|
255
|
+
const expected = legacy(42, available ? [...available] : undefined);
|
|
256
|
+
expect(await runSeeded(42, info, undefined)).toEqual(expected);
|
|
257
|
+
// An allowlist that covers the whole pool draws the same keys too.
|
|
258
|
+
const all = POOL.map(keySuffix);
|
|
259
|
+
expect(await runSeeded(42, info, { [VAR]: all })).toEqual(expected);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe("fetchResolvedEnv forwards the trigger allowlist", () => {
|
|
265
|
+
let server: ReturnType<typeof Bun.serve>;
|
|
266
|
+
let apiUrl: string;
|
|
267
|
+
|
|
268
|
+
beforeAll(() => {
|
|
269
|
+
server = Bun.serve({
|
|
270
|
+
port: 0,
|
|
271
|
+
fetch(req) {
|
|
272
|
+
const url = new URL(req.url);
|
|
273
|
+
if (url.pathname === "/api/config/resolved") {
|
|
274
|
+
return Response.json({
|
|
275
|
+
configs: [
|
|
276
|
+
{ key: VAR, value: POOL.join(",") },
|
|
277
|
+
{ key: "HARNESS_PROVIDER", value: "claude" },
|
|
278
|
+
],
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
if (url.pathname === "/api/keys/available") {
|
|
282
|
+
// Every key rate-limited: the pick-anyway branch must still respect the allowlist.
|
|
283
|
+
return Response.json({ success: true, availableIndices: [], totalKeys: 4 });
|
|
284
|
+
}
|
|
285
|
+
return new Response("Not found", { status: 404 });
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
apiUrl = server.url.toString().replace(/\/$/, "");
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
afterAll(() => {
|
|
292
|
+
server.stop(true);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test("picks only allowlisted keys", async () => {
|
|
296
|
+
for (let i = 0; i < 20; i++) {
|
|
297
|
+
const { env } = await fetchResolvedEnv(apiUrl, "key", "agent-allowlist", {}, "sonnet", {
|
|
298
|
+
provider: "claude",
|
|
299
|
+
enforceModelCapacity: true,
|
|
300
|
+
credentialAllowlist: { [VAR]: ALLOWED },
|
|
301
|
+
resolvedProfile: "claude-pinned",
|
|
302
|
+
});
|
|
303
|
+
expect(ALLOWED).toContain(keySuffix(env[VAR] ?? ""));
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test("throws CredentialAllowlistError when nothing matches", async () => {
|
|
308
|
+
await expect(
|
|
309
|
+
fetchResolvedEnv(apiUrl, "key", "agent-allowlist", {}, "sonnet", {
|
|
310
|
+
provider: "claude",
|
|
311
|
+
enforceModelCapacity: true,
|
|
312
|
+
credentialAllowlist: { [VAR]: ["nomat"] },
|
|
313
|
+
resolvedProfile: "claude-pinned",
|
|
314
|
+
}),
|
|
315
|
+
).rejects.toThrow(
|
|
316
|
+
"credential allowlist for claude-pinned matches no CLAUDE_CODE_OAUTH_TOKEN key",
|
|
317
|
+
);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
describe("the claim trigger carries the profile's allowlist", () => {
|
|
322
|
+
const TEST_DB_PATH = "./test-credentials-allowlist.sqlite";
|
|
323
|
+
|
|
324
|
+
async function removeDbFiles(path: string): Promise<void> {
|
|
325
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
326
|
+
try {
|
|
327
|
+
await unlink(path + suffix);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async function callPoll(agentId: string): Promise<{ task: Record<string, unknown> } | null> {
|
|
335
|
+
let bodyStr = "";
|
|
336
|
+
const req = {
|
|
337
|
+
method: "GET",
|
|
338
|
+
url: "/api/poll",
|
|
339
|
+
headers: { "x-agent-id": agentId },
|
|
340
|
+
} as unknown as Parameters<typeof handlePoll>[0];
|
|
341
|
+
const res = {
|
|
342
|
+
setHeader() {},
|
|
343
|
+
writeHead() {},
|
|
344
|
+
end(body?: string) {
|
|
345
|
+
bodyStr = body ?? "";
|
|
346
|
+
},
|
|
347
|
+
} as unknown as Parameters<typeof handlePoll>[1];
|
|
348
|
+
await handlePoll(req, res, ["api", "poll"], new URLSearchParams(), agentId);
|
|
349
|
+
return (JSON.parse(bodyStr) as { trigger: { task: Record<string, unknown> } | null }).trigger;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
beforeAll(async () => {
|
|
353
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
354
|
+
initDb(TEST_DB_PATH);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
afterAll(async () => {
|
|
358
|
+
closeDb();
|
|
359
|
+
await removeDbFiles(TEST_DB_PATH);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
beforeEach(async () => {
|
|
363
|
+
const client = getDbClient();
|
|
364
|
+
await client.run("DELETE FROM agent_tasks");
|
|
365
|
+
await client.run("DELETE FROM agents");
|
|
366
|
+
await client.run("DELETE FROM model_profiles");
|
|
367
|
+
await createModelProfile({
|
|
368
|
+
name: "claude-pinned",
|
|
369
|
+
harness: "claude",
|
|
370
|
+
model: "opus",
|
|
371
|
+
credentials: { [VAR]: ALLOWED },
|
|
372
|
+
});
|
|
373
|
+
await createModelProfile({ name: "claude-open", harness: "claude", model: "sonnet" });
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
async function claim(profile: string | undefined) {
|
|
377
|
+
const w = await createAgent({
|
|
378
|
+
name: `w-${profile ?? "none"}`,
|
|
379
|
+
isLead: false,
|
|
380
|
+
status: "idle",
|
|
381
|
+
maxTasks: 1,
|
|
382
|
+
harnessProvider: "claude",
|
|
383
|
+
});
|
|
384
|
+
await createTaskExtended("work", { agentId: w.id, ...(profile ? { profile } : {}) });
|
|
385
|
+
return (await callPoll(w.id))?.task;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
test("a profile with an allowlist puts it on the trigger", async () => {
|
|
389
|
+
const task = await claim("claude-pinned");
|
|
390
|
+
expect(task).toMatchObject({
|
|
391
|
+
resolvedProfile: "claude-pinned",
|
|
392
|
+
credentialAllowlist: { [VAR]: ALLOWED },
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
test("a profile without one, or no profile, leaves it off", async () => {
|
|
397
|
+
expect(await claim("claude-open")).not.toHaveProperty("credentialAllowlist");
|
|
398
|
+
expect(await claim(undefined)).not.toHaveProperty("credentialAllowlist");
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
// Paused-task recovery spawns from `GET /api/paused-tasks`, not a claim
|
|
402
|
+
// trigger. Drives the runner's real fetch and key pick over that response.
|
|
403
|
+
test("a paused task resumes on an allowlisted key", async () => {
|
|
404
|
+
const w = await createAgent({
|
|
405
|
+
name: "w-paused",
|
|
406
|
+
isLead: false,
|
|
407
|
+
status: "idle",
|
|
408
|
+
maxTasks: 1,
|
|
409
|
+
harnessProvider: "claude",
|
|
410
|
+
});
|
|
411
|
+
const created = await createTaskExtended("work", { agentId: w.id, profile: "claude-pinned" });
|
|
412
|
+
expect((await callPoll(w.id))?.task.credentialAllowlist).toEqual({ [VAR]: ALLOWED });
|
|
413
|
+
expect(await pauseTask(created.id)).not.toBeNull();
|
|
414
|
+
|
|
415
|
+
const server = Bun.serve({
|
|
416
|
+
port: 0,
|
|
417
|
+
async fetch(req) {
|
|
418
|
+
const url = new URL(req.url);
|
|
419
|
+
if (url.pathname === "/api/paused-tasks") {
|
|
420
|
+
let body = "";
|
|
421
|
+
const fakeReq = {
|
|
422
|
+
method: "GET",
|
|
423
|
+
url: "/api/paused-tasks",
|
|
424
|
+
headers: { "x-agent-id": w.id },
|
|
425
|
+
} as unknown as Parameters<typeof handleTasks>[0];
|
|
426
|
+
const fakeRes = {
|
|
427
|
+
setHeader() {},
|
|
428
|
+
writeHead() {},
|
|
429
|
+
end(chunk?: string) {
|
|
430
|
+
body = chunk ?? "";
|
|
431
|
+
},
|
|
432
|
+
} as unknown as Parameters<typeof handleTasks>[1];
|
|
433
|
+
await handleTasks(fakeReq, fakeRes, ["api", "paused-tasks"], url.searchParams, w.id);
|
|
434
|
+
return new Response(body, { headers: { "content-type": "application/json" } });
|
|
435
|
+
}
|
|
436
|
+
if (url.pathname === "/api/config/resolved") {
|
|
437
|
+
return Response.json({
|
|
438
|
+
configs: [
|
|
439
|
+
{ key: VAR, value: POOL.join(",") },
|
|
440
|
+
{ key: "HARNESS_PROVIDER", value: "claude" },
|
|
441
|
+
],
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
if (url.pathname === "/api/keys/available") {
|
|
445
|
+
return Response.json({ success: true, availableIndices: [0, 1, 2, 3], totalKeys: 4 });
|
|
446
|
+
}
|
|
447
|
+
return new Response("Not found", { status: 404 });
|
|
448
|
+
},
|
|
449
|
+
});
|
|
450
|
+
const apiUrl = server.url.toString().replace(/\/$/, "");
|
|
451
|
+
try {
|
|
452
|
+
const [paused] = await getPausedTasksFromAPI({ apiUrl, apiKey: "key", agentId: w.id });
|
|
453
|
+
expect(paused?.id).toBe(created.id);
|
|
454
|
+
const seen = new Set<string>();
|
|
455
|
+
for (let i = 0; i < 40; i++) {
|
|
456
|
+
const { env } = await fetchResolvedEnv(apiUrl, "key", w.id, {}, "opus", {
|
|
457
|
+
provider: "claude",
|
|
458
|
+
taskId: paused!.id,
|
|
459
|
+
enforceModelCapacity: true,
|
|
460
|
+
resolvedProfile: paused!.resolvedProfile,
|
|
461
|
+
credentialAllowlist: paused!.credentialAllowlist,
|
|
462
|
+
});
|
|
463
|
+
seen.add(keySuffix(env[VAR] ?? ""));
|
|
464
|
+
}
|
|
465
|
+
expect([...seen].filter((suffix) => !ALLOWED.includes(suffix))).toEqual([]);
|
|
466
|
+
} finally {
|
|
467
|
+
server.stop(true);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
});
|
|
@@ -73,6 +73,7 @@ type:McpServerInsert
|
|
|
73
73
|
type:MentionPreview
|
|
74
74
|
type:PageListOptions
|
|
75
75
|
type:PendingChatRelay
|
|
76
|
+
type:PinnedWorkflowDefinition
|
|
76
77
|
type:PlanSource
|
|
77
78
|
type:RecordBudgetRefusalNotificationInput
|
|
78
79
|
type:ScheduledTaskFilters
|
|
@@ -108,6 +109,7 @@ value:ExtensionAgentAssignmentError
|
|
|
108
109
|
value:KvTypeCollisionError
|
|
109
110
|
value:MAX_EMPTY_POLLS
|
|
110
111
|
value:NOT_EXTENSION_AGENT_SQL
|
|
112
|
+
value:PINNED_WORKFLOW_KEYS
|
|
111
113
|
value:ReservedAgentRoleError
|
|
112
114
|
value:SESSION_ACTIVITY_REFRESH_MIN_INTERVAL_MS
|
|
113
115
|
value:SKILL_FILE_LIMITS
|
|
@@ -365,6 +367,7 @@ value:getResolvableDeferralOutcomes
|
|
|
365
367
|
value:getResolvedConfig
|
|
366
368
|
value:getRetryableSteps
|
|
367
369
|
value:getRootTaskChain
|
|
370
|
+
value:getRunWorkflow
|
|
368
371
|
value:getRunningScriptRuns
|
|
369
372
|
value:getScheduledTaskById
|
|
370
373
|
value:getScheduledTaskByName
|
|
@@ -522,6 +525,7 @@ value:normalizeSkillFilePath
|
|
|
522
525
|
value:noteSlackOutcomeDeliveryFailure
|
|
523
526
|
value:overwriteTerminalTaskResultText
|
|
524
527
|
value:pauseTask
|
|
528
|
+
value:pinWorkflowDefinition
|
|
525
529
|
value:postMessage
|
|
526
530
|
value:promoteAbandonedDraftTasks
|
|
527
531
|
value:promoteDraftTask
|
|
@@ -577,6 +581,7 @@ value:startTask
|
|
|
577
581
|
value:supersedeTask
|
|
578
582
|
value:sweepExpiredKv
|
|
579
583
|
value:sweepExpiredKvPrefix
|
|
584
|
+
value:toPinnedDefinition
|
|
580
585
|
value:toggleAgentSkill
|
|
581
586
|
value:uninstallMcpServer
|
|
582
587
|
value:uninstallSkill
|
|
@@ -96,6 +96,7 @@ type:McpServerInsert
|
|
|
96
96
|
type:MentionPreview
|
|
97
97
|
type:PageListOptions
|
|
98
98
|
type:PendingChatRelay
|
|
99
|
+
type:PinnedWorkflowDefinition
|
|
99
100
|
type:PlanSource
|
|
100
101
|
type:RecordBudgetRefusalNotificationInput
|
|
101
102
|
type:ScheduledTaskFilters
|
|
@@ -131,6 +132,7 @@ value:ExtensionAgentAssignmentError
|
|
|
131
132
|
value:KvTypeCollisionError
|
|
132
133
|
value:MAX_EMPTY_POLLS
|
|
133
134
|
value:NOT_EXTENSION_AGENT_SQL
|
|
135
|
+
value:PINNED_WORKFLOW_KEYS
|
|
134
136
|
value:ReservedAgentRoleError
|
|
135
137
|
value:SESSION_ACTIVITY_REFRESH_MIN_INTERVAL_MS
|
|
136
138
|
value:SKILL_FILE_LIMITS
|
|
@@ -388,6 +390,7 @@ value:getResolvableDeferralOutcomes
|
|
|
388
390
|
value:getResolvedConfig
|
|
389
391
|
value:getRetryableSteps
|
|
390
392
|
value:getRootTaskChain
|
|
393
|
+
value:getRunWorkflow
|
|
391
394
|
value:getRunningScriptRuns
|
|
392
395
|
value:getScheduledTaskById
|
|
393
396
|
value:getScheduledTaskByName
|
|
@@ -545,6 +548,7 @@ value:normalizeSkillFilePath
|
|
|
545
548
|
value:noteSlackOutcomeDeliveryFailure
|
|
546
549
|
value:overwriteTerminalTaskResultText
|
|
547
550
|
value:pauseTask
|
|
551
|
+
value:pinWorkflowDefinition
|
|
548
552
|
value:postMessage
|
|
549
553
|
value:promoteAbandonedDraftTasks
|
|
550
554
|
value:promoteDraftTask
|
|
@@ -600,6 +604,7 @@ value:startTask
|
|
|
600
604
|
value:supersedeTask
|
|
601
605
|
value:sweepExpiredKv
|
|
602
606
|
value:sweepExpiredKvPrefix
|
|
607
|
+
value:toPinnedDefinition
|
|
603
608
|
value:toggleAgentSkill
|
|
604
609
|
value:uninstallMcpServer
|
|
605
610
|
value:uninstallSkill
|
|
@@ -397,4 +397,51 @@ describe("worker follow-up vs. deferred wake", () => {
|
|
|
397
397
|
await reconcileDeferredTaskWaits(producer.id);
|
|
398
398
|
expect(await wakeChildren(scheduleId)).toHaveLength(1);
|
|
399
399
|
});
|
|
400
|
+
|
|
401
|
+
test("a rejected chainedTaskId keeps the follow-up and names the rejection", async () => {
|
|
402
|
+
const producer = await activeTask(workerId);
|
|
403
|
+
const { scheduleId } = await deferOn([producer], "any");
|
|
404
|
+
const missing = crypto.randomUUID();
|
|
405
|
+
|
|
406
|
+
const settled = await completeTask(producer.id, "the result");
|
|
407
|
+
const followUp = await createWorkerTaskFollowUp({
|
|
408
|
+
task: settled!,
|
|
409
|
+
status: "completed",
|
|
410
|
+
output: "the result",
|
|
411
|
+
chainedTaskId: missing,
|
|
412
|
+
completingAgentId: workerId,
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
expect(followUp?.agentId).toBe(leadId);
|
|
416
|
+
expect(followUp?.task).toContain(`chainedTaskId ${missing}`);
|
|
417
|
+
expect(followUp?.task).toContain("no task has this id");
|
|
418
|
+
expect(await suppressions(producer.id)).toHaveLength(0);
|
|
419
|
+
// The waiter still wakes; both run.
|
|
420
|
+
await reconcileDeferredTaskWaits(producer.id);
|
|
421
|
+
expect(await wakeChildren(scheduleId)).toHaveLength(1);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
test("a live chainedTaskId suppresses the follow-up and the waiter still wakes", async () => {
|
|
425
|
+
const producer = await activeTask(workerId);
|
|
426
|
+
const { scheduleId } = await deferOn([producer], "any");
|
|
427
|
+
const child = await createTaskExtended("chained work", {
|
|
428
|
+
agentId: otherWorkerId,
|
|
429
|
+
creatorAgentId: workerId,
|
|
430
|
+
parentTaskId: producer.id,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
const settled = await completeTask(producer.id, "the result");
|
|
434
|
+
const followUp = await createWorkerTaskFollowUp({
|
|
435
|
+
task: settled!,
|
|
436
|
+
status: "completed",
|
|
437
|
+
output: "the result",
|
|
438
|
+
chainedTaskId: child.id,
|
|
439
|
+
completingAgentId: workerId,
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
expect(followUp).toBeNull();
|
|
443
|
+
expect((await suppressions(producer.id)).map((s) => s.reason)).toEqual(["chained_task_live"]);
|
|
444
|
+
await reconcileDeferredTaskWaits(producer.id);
|
|
445
|
+
expect(await wakeChildren(scheduleId)).toHaveLength(1);
|
|
446
|
+
});
|
|
400
447
|
});
|
|
@@ -78,7 +78,7 @@ describe("docs API index footprint", () => {
|
|
|
78
78
|
expect(tasks).toContain('"path":"/api/task-templates","method":"get"');
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
test("OpenAPI and generated pages keep all
|
|
81
|
+
test("OpenAPI and generated pages keep all 472 operations", async () => {
|
|
82
82
|
const spec = await Bun.file(resolve(repoRoot, "openapi.json")).json();
|
|
83
83
|
const operationKeys = [];
|
|
84
84
|
const tags = new Set();
|
|
@@ -103,8 +103,8 @@ describe("docs API index footprint", () => {
|
|
|
103
103
|
expect(spec.paths["/api/agents/{id}/runtime"]?.get).toBeDefined();
|
|
104
104
|
|
|
105
105
|
const generatedKeys = await generatedOperationKeys();
|
|
106
|
-
expect(operationKeys).toHaveLength(
|
|
107
|
-
expect(generatedKeys).toHaveLength(
|
|
106
|
+
expect(operationKeys).toHaveLength(472);
|
|
107
|
+
expect(generatedKeys).toHaveLength(472);
|
|
108
108
|
expect(new Set(generatedKeys)).toEqual(new Set(operationKeys));
|
|
109
109
|
});
|
|
110
110
|
|