@desplega.ai/agent-swarm 2.9.1 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-bht22g3k.js +16 -0
- package/dist/{acp-targets-ny75x1qy.js → acp-targets-arrwv4f0.js} +6 -6
- package/dist/{actions-b9qgrmeq.js → actions-y0d2n1c2.js} +49 -28
- package/dist/{agent-fs-provision-b5dhdsbd.js → agent-fs-provision-tpj7sktd.js} +4 -4
- package/dist/{amp-adapter-vtax2c9s.js → amp-adapter-vmmnmw8d.js} +1 -1
- package/dist/{anthropic-messages-r5xf5hqw.js → anthropic-messages-zdca3gv1.js} +13 -13
- package/dist/{app-g2z15hax.js → app-wb7w45dq.js} +3 -3
- package/dist/{approval-notifications-yt13wp8r.js → approval-notifications-7mqr6vbd.js} +5 -5
- package/dist/{assistant-2cgfxsgk.js → assistant-gf60454p.js} +19 -19
- package/dist/{boot-args-schema-3gwy0f60.js → boot-args-schema-qxmd59sr.js} +1 -1
- package/dist/{boot-reembed-mywmyp4s.js → boot-reembed-5tmeskj2.js} +1 -1
- package/dist/{boot-reembed-92g7s5zp.js → boot-reembed-wb44vc3s.js} +1 -1
- package/dist/boot-scrub-sweep-25bxhnw4.js +9 -0
- package/dist/{boot-seeds-ce7rvgq1.js → boot-seeds-nj9za0vk.js} +4 -4
- package/dist/{claude-adapter-3m4q7735.js → claude-adapter-d3krpdyb.js} +5 -5
- package/dist/{claude-managed-setup-c217draw.js → claude-managed-setup-7y4pwd81.js} +1 -1
- package/dist/{claude-sdk-session-7fbqm51z.js → claude-sdk-session-d138zy0e.js} +5 -5
- package/dist/{cli-tvc4jag9.js → cli-01k6wpr9.js} +3 -3
- package/dist/{cli-2xs8tsf7.js → cli-124ntmf0.js} +42 -36
- package/dist/{cli-jm0hvmz2.js → cli-2rnd5j3t.js} +1 -1
- package/dist/{cli-32djehja.js → cli-2spnz7ye.js} +8 -8
- package/dist/{cli-2dq9yv8p.js → cli-2v2zdm0a.js} +1 -1
- package/dist/{cli-fkef327x.js → cli-3caf7pmg.js} +2 -2
- package/dist/{cli-mw620q3n.js → cli-3et6fmfe.js} +1 -1
- package/dist/{cli-h9yqfzx9.js → cli-3f8zbtqa.js} +3 -3
- package/dist/{cli-mhapr559.js → cli-43evxwj4.js} +1 -1
- package/dist/{cli-pyjn0qhk.js → cli-539h29es.js} +138 -21
- package/dist/{cli-bnqncekd.js → cli-5qhfv9rw.js} +2 -2
- package/dist/{cli-p4kckx1z.js → cli-6037prsx.js} +6 -6
- package/dist/{cli-zr6qy15y.js → cli-6cwr32fe.js} +17 -17
- package/dist/{cli-1jykg0py.js → cli-7r162fxe.js} +22 -15
- package/dist/{cli-sn650d7x.js → cli-8st34zhr.js} +20 -10
- package/dist/{cli-rq5rpv6k.js → cli-91pkxres.js} +1 -1
- package/dist/{cli-m7zvgt57.js → cli-9fjr27ez.js} +10 -10
- package/dist/{cli-f8x9drqr.js → cli-aw83sr40.js} +19 -5
- package/dist/{cli-jkw6ptfw.js → cli-cc93xzes.js} +5 -5
- package/dist/{cli-gfy38pvt.js → cli-fcfbct2j.js} +5 -5
- package/dist/{cli-nafvvsp8.js → cli-fq2rr3jb.js} +5 -5
- package/dist/{boot-scrub-sweep-7dkdzqxx.js → cli-had1p04a.js} +8 -9
- package/dist/{cli-bg63qmsx.js → cli-j6te8keb.js} +4 -4
- package/dist/{cli-br0924pw.js → cli-jrbq4djp.js} +1 -1
- package/dist/{cli-kxx4k2jw.js → cli-k3q2va86.js} +2 -2
- package/dist/{cli-jaw5v1sy.js → cli-k5yewqgd.js} +3 -3
- package/dist/cli-kbtzfrxj.js +404 -0
- package/dist/{cli-td9tb872.js → cli-m9cvf7vs.js} +7 -7
- package/dist/{cli-f3jyzq4g.js → cli-md50mj0r.js} +2 -2
- package/dist/{cli-xag7btpe.js → cli-mk7c5ac4.js} +1 -1
- package/dist/cli-mys27d03.js +321 -0
- package/dist/{cli-nbt14he0.js → cli-nstkanmx.js} +5 -5
- package/dist/{cli-wn13hhdt.js → cli-nv4xsvmk.js} +4 -4
- package/dist/{cli-vyff45ve.js → cli-p0c3vtch.js} +2 -2
- package/dist/{cli-2czxfnvj.js → cli-p0n7b5rz.js} +662 -93
- package/dist/{cli-j7svy295.js → cli-q5srsxq2.js} +12 -12
- package/dist/{cli-vt89089n.js → cli-qrta34nb.js} +4 -4
- package/dist/{cli-ysvspf5e.js → cli-qx4f057j.js} +2 -2
- package/dist/{cli-zh0e5x7p.js → cli-s1khw52h.js} +11 -11
- package/dist/{cli-mkwkwq81.js → cli-s1zqk1aj.js} +18 -11
- package/dist/{cli-f9gz2vyj.js → cli-sb4426be.js} +7 -7
- package/dist/{cli-dgs10ttj.js → cli-th1dkc2v.js} +1 -1
- package/dist/{cli-3j873zxq.js → cli-tr27kwyg.js} +2 -2
- package/dist/{cli-6945ywhr.js → cli-tvgqesec.js} +6 -4
- package/dist/{cli-fjggej24.js → cli-v46zsvqk.js} +1 -1
- package/dist/{cli-67mwzr35.js → cli-v8z0yga9.js} +4 -4
- package/dist/{cli-pb2ay3sh.js → cli-vfqvrd82.js} +5 -5
- package/dist/{cli-fh97xn30.js → cli-vq2eg24x.js} +2 -2
- package/dist/{cli-v57d7fmm.js → cli-vsw91x06.js} +23 -22
- package/dist/{cli-2yjj3e31.js → cli-w1q68d8x.js} +9 -7
- package/dist/{cli-y2ewxhth.js → cli-wafmk3fn.js} +10 -10
- package/dist/{cli-ctx0b85j.js → cli-wwp1bd3n.js} +257 -101
- package/dist/{cli-bkjdknnp.js → cli-y4ccxtz5.js} +37 -5
- package/dist/{cli-w4n323t3.js → cli-y8p78ekx.js} +7 -7
- package/dist/{cli-8zh9nrew.js → cli-z0m452jr.js} +1 -1
- package/dist/{cli-mjw0yf82.js → cli-zeh2mhkg.js} +1 -1
- package/dist/{cli-jwampxxq.js → cli-zk7v5s89.js} +2 -2
- package/dist/cli.js +16 -16
- package/dist/{cloudflare-workers-ai-system-one-9y1zx3pt.js → cloudflare-workers-ai-system-one-4aysy6rh.js} +2 -2
- package/dist/{codex-adapter-n656pvb8.js → codex-adapter-exfdbj73.js} +4 -4
- package/dist/{codex-session-runner-p0fbv5y9.js → codex-session-runner-xhznc4g3.js} +4 -4
- package/dist/{commands-gwea8z5p.js → commands-d8g349v4.js} +3 -3
- package/dist/{controller-t67c3grh.js → controller-mwgdmb8y.js} +3 -3
- package/dist/{controllers-connect-ks155r0h.js → controllers-connect-5v7qx04j.js} +19 -19
- package/dist/core-sxy4epp2.js +38 -0
- package/dist/{cursor-adapter-ygwrtmkv.js → cursor-adapter-p2q5h35d.js} +1 -1
- package/dist/{db-rb2xqdb1.js → db-qpganbeb.js} +3 -3
- package/dist/{db-kpmx06s9.js → db-wcw0b2j8.js} +2 -2
- package/dist/{dispatcher-31sm0ej2.js → dispatcher-8d8s49yz.js} +17 -17
- package/dist/{dsh-adapter-qyxh0w31.js → dsh-adapter-me0twn13.js} +1 -1
- package/dist/{easter-egg-3d-00wjscn6.js → easter-egg-3d-wv7w5ty6.js} +1 -1
- package/dist/{embedding-space-qhw4g68n.js → embedding-space-e48xchqa.js} +6 -6
- package/dist/{embeddings-zdv9ke6x.js → embeddings-tgq2afbq.js} +1 -1
- package/dist/{execute-zna8wwr7.js → execute-8rhwrk7f.js} +1 -1
- package/dist/{external-channel-1ac6t56s.js → external-channel-8bt3j2pm.js} +2 -2
- package/dist/{fx-adapter-sk7n0fzc.js → fx-adapter-adtdb3jb.js} +8 -8
- package/dist/{grok-adapter-sjbcm5ew.js → grok-adapter-accnn9km.js} +8 -8
- package/dist/handlers-1x77561e.js +35 -0
- package/dist/{heartbeat-2f6z4kdx.js → heartbeat-x0056ra5.js} +20 -20
- package/dist/{hook-w1skzaqc.js → hook-a7vmn2st.js} +4 -4
- package/dist/{hook-8y0gvtp1.js → hook-mrd2ayxv.js} +5 -5
- package/dist/{http-wghxvpef.js → http-ym9c5svp.js} +676 -273
- package/dist/{index-s71ez27v.js → index-01ns1pkw.js} +1 -1
- package/dist/index-48qzcqzj.js +35 -0
- package/dist/{index-9zkchs9t.js → index-ny60jcat.js} +186 -14
- package/dist/{index-rv89fvzf.js → index-p46tvwtx.js} +21 -21
- package/dist/index-rkvaambe.js +36 -0
- package/dist/{index-8zn8nxn5.js → index-x6azjwm8.js} +1 -1
- package/dist/{index-25pvya7q.js → index-xj1mq27m.js} +17 -17
- package/dist/k8s-m56sw868.js +217 -0
- package/dist/{keepalive-sh02349h.js → keepalive-7yxg8z4c.js} +3 -3
- package/dist/lead-enzn86bz.js +74 -0
- package/dist/{maintenance-yj0dcjja.js → maintenance-6tefxmk1.js} +1 -1
- package/dist/{oauth-refresh-sweep-d9xedk66.js → oauth-refresh-sweep-70cavc3a.js} +2 -2
- package/dist/{onboard-dpgjn03r.js → onboard-fja65z08.js} +5 -5
- package/dist/{openai-decisions-q3hh60wr.js → openai-decisions-ytp6w6xh.js} +1 -1
- package/dist/{opencode-adapter-2d31cpjc.js → opencode-adapter-hakkm7yh.js} +5 -5
- package/dist/{otel-impl-1skarpfq.js → otel-impl-7zhnt6gj.js} +1 -1
- package/dist/{pending-bfmxtx0g.js → pending-h01yzpx4.js} +18 -18
- package/dist/{pi-mono-adapter-gvppnasy.js → pi-mono-adapter-f52hz743.js} +6 -6
- package/dist/{pricing-refresh-c6b325mk.js → pricing-refresh-fzxvk2zf.js} +2 -2
- package/dist/{rbac-roles-h80qbdbs.js → rbac-roles-9v6vhgbs.js} +3 -3
- package/dist/{rbac-roles-zfcx68tx.js → rbac-roles-hfgh8sba.js} +2 -2
- package/dist/{render-v2-nx20t3rb.js → render-v2-1rgspxzf.js} +3 -3
- package/dist/{resume-5ep8agan.js → resume-tqy61x24.js} +7 -7
- package/dist/{runtime-r3pj4mce.js → runtime-exkxyx5f.js} +1 -1
- package/dist/{session-access-n7p3m15b.js → session-access-3act7vt4.js} +4 -4
- package/dist/{session-source-backfill-v8mt0zwn.js → session-source-backfill-82qe7fqq.js} +2 -2
- package/dist/{setup-z1psaqhe.js → setup-ry1vfdef.js} +1 -1
- package/dist/thread-buffer-3x93yexa.js +38 -0
- package/dist/{typesafe-system-one-f2en2knd.js → typesafe-system-one-vcfj2ak8.js} +2 -2
- package/dist/user-merge-jobs-bx6bf7db.js +22 -0
- package/dist/{virtual-modules-rrbjdpxn.js → virtual-modules-s0rjzcqq.js} +3 -3
- package/dist/{work-objects-4aghh73z.js → work-objects-z2e5tv03.js} +20 -20
- package/dist/{worker-follow-up-166zmex1.js → worker-follow-up-y3xeg89w.js} +17 -17
- package/dist/worker-zfcv2wbf.js +74 -0
- package/openapi.json +1630 -388
- package/package.json +3 -3
- package/src/be/boot-seeds.ts +7 -1
- package/src/be/db/model-groups.ts +238 -0
- package/src/be/db/model-profiles.ts +26 -8
- package/src/be/db/session-costs.ts +8 -2
- package/src/be/db/tasks/read.ts +3 -2
- package/src/be/db/tasks/write.ts +2 -1
- package/src/be/db/user-references.ts +75 -0
- package/src/be/db/users/references.ts +185 -0
- package/src/be/db-client.ts +70 -19
- package/src/be/db.ts +32 -57
- package/src/be/key-window-usage.ts +1 -0
- package/src/be/memory/demotion-evidence.ts +34 -0
- package/src/be/memory/reranker.ts +34 -12
- package/src/be/memory/review-recall-filter.ts +83 -0
- package/src/be/memory/search-candidates.ts +19 -6
- package/src/be/memory/types.ts +11 -0
- package/src/be/migrations/312_task_ui_action_runs_repeatable.sql +6 -0
- package/src/be/migrations/314_model_groups.sql +85 -0
- package/src/be/migrations/318_superseded_workflow_cut_backfill.sql +22 -0
- package/src/be/migrations/319_user_fk_indexes.sql +153 -0
- package/src/be/migrations/320_session_costs_kind.sql +4 -0
- package/src/be/migrations/321_user_merge_jobs.sql +52 -0
- package/src/be/pricing-normalize.ts +2 -0
- package/src/be/rbac-roles.ts +6 -4
- package/src/be/runtime-pools/db.ts +20 -5
- package/src/be/runtime-pools/supervisor.ts +15 -1
- package/src/be/scripts/db.ts +11 -0
- package/src/be/scripts/typecheck.ts +2 -0
- package/src/be/seed-model-groups.ts +86 -0
- package/src/be/seed-model-profiles.ts +20 -13
- package/src/be/seed-scripts/catalog/dreaming-gather.ts +165 -1
- package/src/be/swarm-config-guard.ts +34 -0
- package/src/be/task-ui-spec.ts +102 -1
- package/src/be/user-merge-jobs.ts +564 -0
- package/src/be/users.ts +41 -23
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +1 -1
- package/src/commands/onboard/env-generator.ts +1 -1
- package/src/commands/provider-credentials.ts +1 -1
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +15 -0
- package/src/extensions/dispatcher.ts +14 -4
- package/src/github/handlers.ts +57 -0
- package/src/github/types.ts +4 -0
- package/src/http/all-routes.ts +2 -0
- package/src/http/approval-requests.ts +5 -1
- package/src/http/auth.ts +3 -1
- package/src/http/config.ts +34 -1
- package/src/http/index.ts +13 -0
- package/src/http/memory.ts +19 -6
- package/src/http/model-groups.ts +277 -0
- package/src/http/model-profiles.ts +30 -13
- package/src/http/tasks.ts +41 -6
- package/src/http/tool-hooks.ts +140 -0
- package/src/http/users.ts +142 -19
- package/src/http/workflows.ts +19 -1
- package/src/integrations/chat-sdk/inbound.ts +8 -2
- package/src/integrations/chat-sdk/limits.ts +8 -3
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/pricing-sources.md +9 -0
- package/src/rbac/legacy-policy.ts +1 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/runtime-providers/index.ts +7 -5
- package/src/runtime-providers/k8s.ts +250 -0
- package/src/scripts-runtime/types/stdlib.d.ts +2 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +16 -1
- package/src/scripts-runtime/types/swarm-sdk.d.ts +2 -0
- package/src/slack/actions.ts +33 -10
- package/src/slack/blocks.ts +23 -2
- package/src/slack/render-v2.ts +47 -0
- package/src/tests/acp-adapter.test.ts +26 -0
- package/src/tests/chat-sdk-relay.test.ts +21 -1
- package/src/tests/check-pr-body.test.ts +43 -0
- package/src/tests/credential-check.test.ts +14 -6
- package/src/tests/db-client.test.ts +146 -0
- package/src/tests/deploy-guard.test.ts +7 -7
- package/src/tests/deploy-select.test.ts +83 -0
- package/src/tests/dreaming-gather-corrections.test.ts +467 -0
- package/src/tests/event-loop-lag.test.ts +9 -7
- package/src/tests/fixtures/extensions/native-tool-recorder/hooks.ts +26 -0
- package/src/tests/fixtures/extensions/native-tool-recorder/manifest.json +10 -0
- package/src/tests/fixtures/onboard/content.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/content.env.txt +1 -1
- package/src/tests/fixtures/onboard/dev.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/dev.env.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.env.txt +1 -1
- package/src/tests/fixtures/onboard/full.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full.env.txt +1 -1
- package/src/tests/fixtures/onboard/research.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/research.env.txt +1 -1
- package/src/tests/fixtures/onboard/solo.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/solo.env.txt +1 -1
- package/src/tests/github-event-filter.test.ts +8 -0
- package/src/tests/github-handlers-inline-comments.test.ts +2 -0
- package/src/tests/github-handlers-reactions.test.ts +4 -0
- package/src/tests/github-handlers.test.ts +3 -0
- package/src/tests/github-sender-trust.test.ts +223 -0
- package/src/tests/http-users.test.ts +142 -41
- package/src/tests/k8s-pool-smoke.test.ts +190 -0
- package/src/tests/key-window-usage.test.ts +15 -0
- package/src/tests/memory-rater-store.test.ts +35 -1
- package/src/tests/memory-reranker.test.ts +39 -4
- package/src/tests/memory-review-recall-filter.test.ts +205 -0
- package/src/tests/migration-318-superseded-workflow-cut-backfill.test.ts +74 -0
- package/src/tests/model-groups-api.test.ts +415 -0
- package/src/tests/model-profiles-api.test.ts +1 -0
- package/src/tests/operator-granted-credentials.test.ts +7 -2
- package/src/tests/operator-granted-role-wire.test.ts +2 -1
- package/src/tests/rbac-engine.test.ts +1 -0
- package/src/tests/runtime-k8s-pools.test.ts +142 -0
- package/src/tests/runtime-pools-db.test.ts +42 -2
- package/src/tests/runtime-pools-http.test.ts +47 -2
- package/src/tests/runtime-provider-registration.test.ts +5 -14
- package/src/tests/runtime-providers-k8s.test.ts +303 -0
- package/src/tests/script-connections.test.ts +13 -1
- package/src/tests/short-id.test.ts +23 -0
- package/src/tests/slack-blocks.test.ts +69 -0
- package/src/tests/slack-render-v2.test.ts +54 -0
- package/src/tests/spec-base-url.test.ts +13 -1
- package/src/tests/system-one-decide-session-cost.test.ts +196 -0
- package/src/tests/task-ui-action-route.test.ts +59 -1
- package/src/tests/task-ui-script-actions.test.ts +517 -0
- package/src/tests/tool-hooks-http.test.ts +187 -0
- package/src/tests/ui-spec-script-actions-config.test.ts +196 -0
- package/src/tests/user-delete-perf.test.ts +321 -0
- package/src/tests/user-merge-jobs.test.ts +680 -0
- package/src/tests/vcs-provider.test.ts +25 -5
- package/src/tests/vendored-openapi.test.ts +13 -1
- package/src/tests/workflow-agent-task-retry.test.ts +62 -0
- package/src/tests/workflow-foreach-supersede-retry.test.ts +10 -0
- package/src/tests/workflow-http-v2.test.ts +27 -0
- package/src/tests/workflow-replay.test.ts +10 -1
- package/src/tests/workflow-triggers-v2.test.ts +128 -0
- package/src/tests/workflow-wait-event.test.ts +109 -1
- package/src/tools/memory-search.ts +14 -3
- package/src/tools/store-progress.ts +26 -26
- package/src/tools/swarm-config/delete-config.ts +12 -1
- package/src/tools/swarm-config/set-config.ts +8 -0
- package/src/tools/system-one-decide.ts +113 -3
- package/src/tools/utils.ts +4 -1
- package/src/tools/workflows/create-workflow.ts +2 -0
- package/src/tools/workflows/update-workflow.ts +3 -1
- package/src/types.ts +86 -2
- package/src/ui-spec/actions.ts +30 -4
- package/src/ui-spec/schema.ts +38 -0
- package/src/ui-spec/script-actions.ts +340 -0
- package/src/ui-spec/script-allowlist.ts +48 -0
- package/src/utils/short-id.ts +20 -14
- package/src/utils/task-ui-spec.ts +16 -4
- package/src/vcs/index.ts +12 -2
- package/src/workflows/executors/system-one-decision.ts +2 -2
- package/src/workflows/resume.ts +3 -2
- package/src/workflows/task-step-routing.ts +30 -10
- package/src/workflows/triggers.ts +35 -3
- package/templates/extensions/manifest.schema.json +13 -0
- package/templates/skills/swarm-docs/content.md +2 -0
- package/templates/skills/ui-spec/content.md +7 -1
- package/templates/workflows/dreaming/content.md +1 -1
- package/dist/acp-adapter-g909b5hw.js +0 -16
- package/dist/cli-b91nz213.js +0 -93
- package/dist/handlers-yzy0c87x.js +0 -35
- package/dist/index-2t4859r5.js +0 -35
- package/dist/index-cxca2t8y.js +0 -36
- package/dist/lead-gk4h5eg7.js +0 -74
- package/dist/thread-buffer-a1re2r9r.js +0 -38
- package/dist/worker-3dyyb8ev.js +0 -74
- package/dist/{azure-openai-responses-590s1eea.js → azure-openai-responses-b3y7fz36.js} +8 -8
- package/dist/{cli-m7c2380k.js → cli-3aaeb78m.js} +4 -4
- package/dist/{cli-g0vv9dg4.js → cli-8y43jx2r.js} +8 -8
- package/dist/{cli-m0cy2vyf.js → cli-k6nejceb.js} +4 -4
- package/dist/{google-generative-ai-maq6c9bf.js → google-generative-ai-bh0djqjp.js} +4 -4
- package/dist/{google-vertex-2jgsw2nb.js → google-vertex-prjbw8dj.js} +8 -8
- package/dist/{mistral-conversations-0c30em7t.js → mistral-conversations-tm2vd4gc.js} +8 -8
- package/dist/{node-dqm4xgxw.js → node-2wfcey7d.js} +0 -0
- package/dist/{openai-codex-responses-bkcd8pjj.js → openai-codex-responses-sxjv60xx.js} +4 -4
- package/dist/{openai-completions-f3n69rep.js → openai-completions-0c7qnhsx.js} +20 -20
- package/dist/{openai-responses-gbh0wfqe.js → openai-responses-a7h29chp.js} +15 -15
- package/dist/{pi-messages-zebyt7gb.js → pi-messages-2j0fpqwq.js} +5 -5
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getPoolForAgent,
|
|
21
21
|
getRuntimeController,
|
|
22
22
|
getRuntimeControllerSecrets,
|
|
23
|
+
getRuntimeControllerTarget,
|
|
23
24
|
getRuntimePool,
|
|
24
25
|
listAgentsForPool,
|
|
25
26
|
listRuntimeControllers,
|
|
@@ -52,6 +53,24 @@ beforeEach(async () => {
|
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
describe("runtime pools persistence", () => {
|
|
56
|
+
test("Kubernetes deployment detection ignores controller overrides from existing rows", async () => {
|
|
57
|
+
const controller = await createRuntimeController({
|
|
58
|
+
name: "cluster-auth",
|
|
59
|
+
kind: "k8s",
|
|
60
|
+
placement: "builtin",
|
|
61
|
+
});
|
|
62
|
+
await getDbClient().run("UPDATE runtime_controllers SET config = ? WHERE id = ?", [
|
|
63
|
+
JSON.stringify({ KUBERNETES_SERVICE_HOST: "controller-host" }),
|
|
64
|
+
controller.id,
|
|
65
|
+
]);
|
|
66
|
+
const stored = (await getRuntimeController(controller.id))!;
|
|
67
|
+
expect((await getRuntimeControllerTarget(stored, {})).KUBERNETES_SERVICE_HOST).toBeUndefined();
|
|
68
|
+
expect(
|
|
69
|
+
(await getRuntimeControllerTarget(stored, { KUBERNETES_SERVICE_HOST: "deployment-host" }))
|
|
70
|
+
.KUBERNETES_SERVICE_HOST,
|
|
71
|
+
).toBe("deployment-host");
|
|
72
|
+
});
|
|
73
|
+
|
|
55
74
|
test("pool caches default off, persist across edits, and can be disabled explicitly", async () => {
|
|
56
75
|
const controller = await createRuntimeController({ name: "cache-controller", kind: "docker" });
|
|
57
76
|
const base = {
|
|
@@ -288,10 +307,10 @@ describe("runtime pools persistence", () => {
|
|
|
288
307
|
"Pool kind must equal controller kind",
|
|
289
308
|
);
|
|
290
309
|
await expect(createRuntimePool({ ...input, kind: "k8s" })).rejects.toThrow(
|
|
291
|
-
"
|
|
310
|
+
"Pool kind must equal controller kind",
|
|
292
311
|
);
|
|
293
312
|
await expect(createRuntimeController({ name: "k8s", kind: "k8s" })).rejects.toThrow(
|
|
294
|
-
"
|
|
313
|
+
"Kubernetes controllers require builtin placement",
|
|
295
314
|
);
|
|
296
315
|
const pool = await createRuntimePool({ ...input, maxRuntimes: 3, minRuntimes: 2 });
|
|
297
316
|
await expect(updateRuntimePool(pool.id, { maxRuntimes: 1 })).rejects.toMatchObject({
|
|
@@ -312,6 +331,27 @@ describe("runtime pools persistence", () => {
|
|
|
312
331
|
});
|
|
313
332
|
expect(await getRuntimePool(pool.id)).toEqual(updated);
|
|
314
333
|
});
|
|
334
|
+
test("creates builtin Kubernetes controllers and pools", async () => {
|
|
335
|
+
const controller = await createRuntimeController({
|
|
336
|
+
name: "kubernetes",
|
|
337
|
+
kind: "k8s",
|
|
338
|
+
placement: "builtin",
|
|
339
|
+
config: { K8S_API_URL: "https://cluster.test", K8S_NAMESPACE: "workers" },
|
|
340
|
+
secretConfig: { K8S_TOKEN: crypto.randomUUID() },
|
|
341
|
+
});
|
|
342
|
+
expect(controller.secretConfigKeys).toEqual(["K8S_TOKEN"]);
|
|
343
|
+
expect(JSON.stringify(controller)).not.toContain('"K8S_TOKEN":');
|
|
344
|
+
const pool = await createRuntimePool({
|
|
345
|
+
name: "kubernetes",
|
|
346
|
+
kind: "k8s",
|
|
347
|
+
placements: [controller.id],
|
|
348
|
+
image: "worker:test",
|
|
349
|
+
});
|
|
350
|
+
expect(pool.kind).toBe("k8s");
|
|
351
|
+
await expect(updateRuntimeController(controller.id, { placement: "remote" })).rejects.toThrow(
|
|
352
|
+
"Kubernetes controllers require builtin placement",
|
|
353
|
+
);
|
|
354
|
+
});
|
|
315
355
|
test("encrypts secrets, merges and removes keys, and restores scrubbing after a restart", async () => {
|
|
316
356
|
const secret = crypto.randomUUID() + crypto.randomUUID();
|
|
317
357
|
const controller = await createRuntimeController({
|
|
@@ -274,7 +274,7 @@ describe("runtime pools HTTP", () => {
|
|
|
274
274
|
"builtin-docker",
|
|
275
275
|
]);
|
|
276
276
|
});
|
|
277
|
-
test("rejects kind mismatches, k8s, invalid bounds, missing placements and missing images", async () => {
|
|
277
|
+
test("rejects kind mismatches, remote k8s, invalid bounds, missing placements and missing images", async () => {
|
|
278
278
|
for (const input of [
|
|
279
279
|
{ ...poolInput, kind: "e2b" },
|
|
280
280
|
{ ...poolInput, kind: "k8s" },
|
|
@@ -288,7 +288,52 @@ describe("runtime pools HTTP", () => {
|
|
|
288
288
|
}
|
|
289
289
|
const k8s = await dispatch("/api/runtime-controllers", "POST", { name: "k8s", kind: "k8s" });
|
|
290
290
|
expect(k8s.status).toBe(400);
|
|
291
|
-
expect(k8s.data.error).toBe("
|
|
291
|
+
expect(k8s.data.error).toBe("Kubernetes controllers require builtin placement");
|
|
292
|
+
});
|
|
293
|
+
test("creates a builtin Kubernetes controller and its pool through HTTP", async () => {
|
|
294
|
+
const created = await dispatch("/api/runtime-controllers", "POST", {
|
|
295
|
+
name: "k8s-builtin",
|
|
296
|
+
kind: "k8s",
|
|
297
|
+
placement: "builtin",
|
|
298
|
+
config: { K8S_API_URL: "https://cluster.test", K8S_NAMESPACE: "workers" },
|
|
299
|
+
secretConfig: { K8S_TOKEN: crypto.randomUUID() },
|
|
300
|
+
});
|
|
301
|
+
expect(created.status).toBe(200);
|
|
302
|
+
expect(created.data.controller.secretConfigKeys).toEqual(["K8S_TOKEN"]);
|
|
303
|
+
expect(created.data.controller.secretConfig).toBeUndefined();
|
|
304
|
+
const pool = await dispatch("/api/runtime-pools", "POST", {
|
|
305
|
+
...poolInput,
|
|
306
|
+
name: "k8s-pool",
|
|
307
|
+
kind: "k8s",
|
|
308
|
+
placements: [created.data.controller.id],
|
|
309
|
+
});
|
|
310
|
+
expect(pool.status).toBe(200);
|
|
311
|
+
expect(pool.data.pool.kind).toBe("k8s");
|
|
312
|
+
});
|
|
313
|
+
test("user controller writers cannot configure Kubernetes host files or deployment detection", async () => {
|
|
314
|
+
const input = { name: "k8s-files", kind: "k8s", placement: "builtin" };
|
|
315
|
+
const created = await dispatch("/api/runtime-controllers", "POST", input, "user");
|
|
316
|
+
expect(created.status).toBe(200);
|
|
317
|
+
const id = created.data.controller.id;
|
|
318
|
+
for (const key of ["K8S_TOKEN_FILE", "K8S_CA_FILE", "KUBERNETES_SERVICE_HOST"]) {
|
|
319
|
+
for (const field of ["config", "secretConfig"]) {
|
|
320
|
+
const patch = { [field]: { [key]: "/var/run/secrets/kubernetes.io/serviceaccount/token" } };
|
|
321
|
+
const rejected = await dispatch(
|
|
322
|
+
"/api/runtime-controllers",
|
|
323
|
+
"POST",
|
|
324
|
+
{ ...input, ...patch, name: `k8s-files-${key}-${field}` },
|
|
325
|
+
"user",
|
|
326
|
+
);
|
|
327
|
+
expect(rejected.status).toBe(400);
|
|
328
|
+
expect(rejected.data.error).toContain("not supported");
|
|
329
|
+
expect(
|
|
330
|
+
(await dispatch(`/api/runtime-controllers/${id}`, "PATCH", patch, "user")).status,
|
|
331
|
+
).toBe(400);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const unchanged = await dispatch(`/api/runtime-controllers/${id}`, "GET", undefined, "user");
|
|
335
|
+
expect(unchanged.data.controller.config).toEqual({});
|
|
336
|
+
expect(unchanged.data.controller.secretConfigKeys).toEqual([]);
|
|
292
337
|
});
|
|
293
338
|
test("pool writes permit operators and users only; leads may only bind", async () => {
|
|
294
339
|
expect((await dispatch("/api/runtime-pools", "POST", poolInput, "worker")).status).toBe(403);
|
|
@@ -5,7 +5,6 @@ import { type RuntimeProviderKind, RuntimeProviderKindSchema } from "../types";
|
|
|
5
5
|
|
|
6
6
|
const repoRoot = join(import.meta.dir, "..", "..");
|
|
7
7
|
const kinds = RuntimeProviderKindSchema.options;
|
|
8
|
-
const notImplemented = { k8s: "adapter not implemented" };
|
|
9
8
|
|
|
10
9
|
interface TouchPoint {
|
|
11
10
|
file: string;
|
|
@@ -26,7 +25,7 @@ const TOUCH_POINTS: TouchPoint[] = [
|
|
|
26
25
|
}
|
|
27
26
|
throw new Error("Factory accepted an unregistered runtime provider.");
|
|
28
27
|
},
|
|
29
|
-
exempt:
|
|
28
|
+
exempt: {},
|
|
30
29
|
},
|
|
31
30
|
{
|
|
32
31
|
file: "src/runtime-providers/<kind>.ts",
|
|
@@ -39,7 +38,7 @@ const TOUCH_POINTS: TouchPoint[] = [
|
|
|
39
38
|
}
|
|
40
39
|
return present;
|
|
41
40
|
},
|
|
42
|
-
exempt:
|
|
41
|
+
exempt: {},
|
|
43
42
|
},
|
|
44
43
|
{
|
|
45
44
|
file: "runbooks/runtime-providers.md",
|
|
@@ -47,7 +46,7 @@ const TOUCH_POINTS: TouchPoint[] = [
|
|
|
47
46
|
const source = await Bun.file(join(repoRoot, "runbooks/runtime-providers.md")).text();
|
|
48
47
|
return kinds.filter((kind) => new RegExp(`^#{2,3} ${kind}\\s*$`, "m").test(source));
|
|
49
48
|
},
|
|
50
|
-
exempt:
|
|
49
|
+
exempt: {},
|
|
51
50
|
},
|
|
52
51
|
{
|
|
53
52
|
file: "apps/ui/src/lib/runtime-pools.ts (RUNTIME_PROVIDER_KINDS)",
|
|
@@ -60,7 +59,6 @@ const TOUCH_POINTS: TouchPoint[] = [
|
|
|
60
59
|
if (!match?.[1]) throw new Error("Cannot find RUNTIME_PROVIDER_KINDS in runtime-pools.ts.");
|
|
61
60
|
return [...match[1].matchAll(/["']([^"']+)["']/g)].map((match) => match[1] as string);
|
|
62
61
|
},
|
|
63
|
-
// The UI lists k8s too (disabled, "coming soon"), so no kind is exempt.
|
|
64
62
|
exempt: {},
|
|
65
63
|
},
|
|
66
64
|
];
|
|
@@ -88,23 +86,16 @@ describe("runtime provider registration", () => {
|
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
test("static provisioning lookup matches adapter traits", async () => {
|
|
91
|
-
|
|
92
|
-
for (const kind of kinds.filter((kind) => kind !== "k8s"))
|
|
89
|
+
for (const kind of kinds)
|
|
93
90
|
expect(canProvisionKind(kind)).toBe((await createRuntimeProvider(kind)).traits.canProvision);
|
|
94
91
|
});
|
|
95
92
|
|
|
96
|
-
for (const kind of kinds
|
|
93
|
+
for (const kind of kinds) {
|
|
97
94
|
test(`factory creates ${kind}`, async () => {
|
|
98
95
|
expect((await createRuntimeProvider(kind)).kind).toBe(kind);
|
|
99
96
|
});
|
|
100
97
|
}
|
|
101
98
|
|
|
102
|
-
test("k8s explicitly rejects provisioning support", async () => {
|
|
103
|
-
await expect(createRuntimeProvider("k8s")).rejects.toThrow(
|
|
104
|
-
'Unknown runtime provider: "k8s" (not implemented). Supported: static, docker, e2b, boxd',
|
|
105
|
-
);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
99
|
test("static workers remain operator-managed", async () => {
|
|
109
100
|
const provider = await createRuntimeProvider("static");
|
|
110
101
|
const handle = { kind: "static" as const, externalId: "operator-worker" };
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
|
|
2
|
+
import { KubernetesRuntimeProvider } from "../runtime-providers/k8s";
|
|
3
|
+
import {
|
|
4
|
+
type ProvisionRequest,
|
|
5
|
+
RUNTIME_LABELS,
|
|
6
|
+
type RuntimeTargetConfig,
|
|
7
|
+
} from "../runtime-providers/types";
|
|
8
|
+
|
|
9
|
+
const provider = new KubernetesRuntimeProvider();
|
|
10
|
+
const request: ProvisionRequest = {
|
|
11
|
+
runtimeId: crypto.randomUUID(),
|
|
12
|
+
agentId: crypto.randomUUID(),
|
|
13
|
+
poolId: "pool-1",
|
|
14
|
+
ownerId: "owner-1",
|
|
15
|
+
image: "worker:test",
|
|
16
|
+
env: { API_KEY: `worker-${crypto.randomUUID()}`, MULTILINE: "a\nb" },
|
|
17
|
+
resources: { cpu: 0.5, memoryMb: 128 },
|
|
18
|
+
ttlSec: 60,
|
|
19
|
+
labels: { custom: "value", [RUNTIME_LABELS.owner]: "spoofed" },
|
|
20
|
+
};
|
|
21
|
+
const labels = {
|
|
22
|
+
custom: "value",
|
|
23
|
+
[RUNTIME_LABELS.owner]: request.ownerId,
|
|
24
|
+
[RUNTIME_LABELS.runtimeId]: request.runtimeId,
|
|
25
|
+
[RUNTIME_LABELS.agentId]: request.agentId,
|
|
26
|
+
[RUNTIME_LABELS.poolId]: request.poolId,
|
|
27
|
+
};
|
|
28
|
+
const metadata = {
|
|
29
|
+
name: `swarm-rt-${request.runtimeId}`,
|
|
30
|
+
namespace: "workers",
|
|
31
|
+
uid: crypto.randomUUID(),
|
|
32
|
+
labels,
|
|
33
|
+
creationTimestamp: "2026-11-09T10:00:00Z",
|
|
34
|
+
};
|
|
35
|
+
const handle = {
|
|
36
|
+
kind: "k8s" as const,
|
|
37
|
+
externalId: metadata.name,
|
|
38
|
+
createdAt: metadata.creationTimestamp,
|
|
39
|
+
meta: { ...labels, "k8s.namespace": metadata.namespace, "k8s.uid": metadata.uid },
|
|
40
|
+
};
|
|
41
|
+
let server: Bun.Server<undefined>;
|
|
42
|
+
let target: RuntimeTargetConfig;
|
|
43
|
+
let handler: (req: Request) => Response | Promise<Response>;
|
|
44
|
+
let calls: Array<{ url: string; method: string; headers: Headers }>;
|
|
45
|
+
const files: string[] = [];
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
calls = [];
|
|
49
|
+
handler = () => Response.json({ metadata });
|
|
50
|
+
server = Bun.serve({
|
|
51
|
+
hostname: "127.0.0.1",
|
|
52
|
+
port: 0,
|
|
53
|
+
fetch(req) {
|
|
54
|
+
calls.push({ url: req.url, method: req.method, headers: new Headers(req.headers) });
|
|
55
|
+
return handler(req);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
target = {
|
|
59
|
+
K8S_API_URL: server.url.origin,
|
|
60
|
+
K8S_NAMESPACE: "workers",
|
|
61
|
+
K8S_TOKEN: crypto.randomUUID(),
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
afterEach(async () => {
|
|
65
|
+
await server.stop(true);
|
|
66
|
+
for (const path of files.splice(0)) await Bun.file(path).delete();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("Kubernetes runtime provider", () => {
|
|
70
|
+
test("validates configuration without accepting remote plaintext or URL credentials", () => {
|
|
71
|
+
expect(provider.checkConfig(target).ready).toBe(true);
|
|
72
|
+
expect(provider.checkConfig({}).ready).toBe(false);
|
|
73
|
+
expect(provider.checkConfig({ K8S_API_URL: "https://cluster.test" }).ready).toBe(false);
|
|
74
|
+
expect(provider.checkConfig({ KUBERNETES_SERVICE_HOST: "10.0.0.1" }).ready).toBe(true);
|
|
75
|
+
for (const url of [
|
|
76
|
+
"http://cluster.test",
|
|
77
|
+
"ftp://cluster.test",
|
|
78
|
+
"https://user:pass@cluster.test",
|
|
79
|
+
"https://cluster.test/path",
|
|
80
|
+
"https://cluster.test?token=secret",
|
|
81
|
+
]) {
|
|
82
|
+
expect(provider.checkConfig({ ...target, K8S_API_URL: url }).ready).toBe(false);
|
|
83
|
+
}
|
|
84
|
+
for (const namespace of ["../other", "UPPER", "a.b", "a".repeat(64)])
|
|
85
|
+
expect(provider.checkConfig({ ...target, K8S_NAMESPACE: namespace }).ready).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("creates a worker pod with authoritative labels, resources, env, and no cluster token", async () => {
|
|
89
|
+
let body: Record<string, unknown> = {};
|
|
90
|
+
handler = async (req) => {
|
|
91
|
+
body = (await req.json()) as typeof body;
|
|
92
|
+
return Response.json({ metadata });
|
|
93
|
+
};
|
|
94
|
+
expect(
|
|
95
|
+
await provider.provision(
|
|
96
|
+
{ ...target, K8S_SERVICE_ACCOUNT: "worker", K8S_IMAGE_PULL_SECRETS: "registry, secondary" },
|
|
97
|
+
request,
|
|
98
|
+
),
|
|
99
|
+
).toEqual(handle);
|
|
100
|
+
expect(calls[0]?.method).toBe("POST");
|
|
101
|
+
expect(new URL(calls[0]!.url).pathname).toBe("/api/v1/namespaces/workers/pods");
|
|
102
|
+
expect(calls[0]?.headers.get("Authorization")).toBe(`Bearer ${target.K8S_TOKEN}`);
|
|
103
|
+
expect(body).toEqual({
|
|
104
|
+
apiVersion: "v1",
|
|
105
|
+
kind: "Pod",
|
|
106
|
+
metadata: { name: metadata.name, namespace: "workers", labels },
|
|
107
|
+
spec: {
|
|
108
|
+
restartPolicy: "Never",
|
|
109
|
+
automountServiceAccountToken: false,
|
|
110
|
+
serviceAccountName: "worker",
|
|
111
|
+
imagePullSecrets: [{ name: "registry" }, { name: "secondary" }],
|
|
112
|
+
activeDeadlineSeconds: 60,
|
|
113
|
+
containers: [
|
|
114
|
+
{
|
|
115
|
+
name: "worker",
|
|
116
|
+
image: request.image,
|
|
117
|
+
env: Object.entries(request.env).map(([name, value]) => ({ name, value })),
|
|
118
|
+
resources: {
|
|
119
|
+
requests: { cpu: "0.5", memory: "128Mi" },
|
|
120
|
+
limits: { cpu: "0.5", memory: "128Mi" },
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
expect(JSON.stringify(body)).not.toContain(target.K8S_TOKEN!);
|
|
127
|
+
expect(JSON.stringify(handle)).not.toContain(request.env.API_KEY!);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("reads fixed service account files again after token rotation", async () => {
|
|
131
|
+
const first = crypto.randomUUID();
|
|
132
|
+
const second = crypto.randomUUID();
|
|
133
|
+
let current = first;
|
|
134
|
+
const originalFile = Bun.file;
|
|
135
|
+
const read = spyOn(Bun, "file").mockImplementation((path, options) => {
|
|
136
|
+
if (path === "/var/run/secrets/kubernetes.io/serviceaccount/token")
|
|
137
|
+
return { text: async () => current } as ReturnType<typeof Bun.file>;
|
|
138
|
+
if (path === "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
|
|
139
|
+
return { text: async () => "cluster-ca" } as ReturnType<typeof Bun.file>;
|
|
140
|
+
return originalFile(path, options);
|
|
141
|
+
});
|
|
142
|
+
const send = spyOn(globalThis, "fetch")
|
|
143
|
+
.mockResolvedValueOnce(Response.json({ metadata }))
|
|
144
|
+
.mockResolvedValueOnce(Response.json({ metadata }));
|
|
145
|
+
try {
|
|
146
|
+
const config = { KUBERNETES_SERVICE_HOST: "10.0.0.1", K8S_NAMESPACE: "workers" };
|
|
147
|
+
await provider.provision(config, request);
|
|
148
|
+
current = second;
|
|
149
|
+
await provider.provision(config, { ...request, runtimeId: crypto.randomUUID() });
|
|
150
|
+
expect(send.mock.calls.map(([url]) => String(url))).toEqual([
|
|
151
|
+
"https://kubernetes.default.svc/api/v1/namespaces/workers/pods",
|
|
152
|
+
"https://kubernetes.default.svc/api/v1/namespaces/workers/pods",
|
|
153
|
+
]);
|
|
154
|
+
expect(
|
|
155
|
+
send.mock.calls.map(([, options]) => new Headers(options?.headers).get("authorization")),
|
|
156
|
+
).toEqual([`Bearer ${first}`, `Bearer ${second}`]);
|
|
157
|
+
for (const [, options] of send.mock.calls)
|
|
158
|
+
expect(options).toMatchObject({ tls: { ca: "cluster-ca" } });
|
|
159
|
+
expect(read.mock.calls.map(([path]) => path)).toEqual([
|
|
160
|
+
"/var/run/secrets/kubernetes.io/serviceaccount/token",
|
|
161
|
+
"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt",
|
|
162
|
+
"/var/run/secrets/kubernetes.io/serviceaccount/token",
|
|
163
|
+
"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt",
|
|
164
|
+
]);
|
|
165
|
+
} finally {
|
|
166
|
+
read.mockRestore();
|
|
167
|
+
send.mockRestore();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("external endpoints never inherit mounted service account credentials", async () => {
|
|
172
|
+
const config = { K8S_API_URL: server.url.origin, KUBERNETES_SERVICE_HOST: "10.0.0.1" };
|
|
173
|
+
const read = spyOn(Bun, "file");
|
|
174
|
+
try {
|
|
175
|
+
expect(provider.checkConfig(config).ready).toBe(false);
|
|
176
|
+
await expect(provider.provision(config, request)).rejects.toThrow("Set K8S_TOKEN");
|
|
177
|
+
expect(read).not.toHaveBeenCalled();
|
|
178
|
+
expect(calls).toHaveLength(0);
|
|
179
|
+
} finally {
|
|
180
|
+
read.mockRestore();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("rejects controller file paths before reading or forwarding host secrets", async () => {
|
|
185
|
+
const path = `/tmp/k8s-review-secret-${crypto.randomUUID()}`;
|
|
186
|
+
files.push(path);
|
|
187
|
+
await Bun.write(path, crypto.randomUUID());
|
|
188
|
+
const read = spyOn(Bun, "file");
|
|
189
|
+
try {
|
|
190
|
+
for (const key of ["K8S_TOKEN_FILE", "K8S_CA_FILE"]) {
|
|
191
|
+
const config = { ...target, [key]: path };
|
|
192
|
+
if (key === "K8S_TOKEN_FILE") delete config.K8S_TOKEN;
|
|
193
|
+
expect(provider.checkConfig(config).ready).toBe(false);
|
|
194
|
+
await expect(provider.provision(config, request)).rejects.toThrow("not supported");
|
|
195
|
+
await expect(provider.list(config, request.ownerId)).rejects.toThrow("not supported");
|
|
196
|
+
await expect(provider.terminate(config, handle)).rejects.toThrow("not supported");
|
|
197
|
+
expect(await provider.status(config, handle)).toBe("unknown");
|
|
198
|
+
}
|
|
199
|
+
expect(read).not.toHaveBeenCalled();
|
|
200
|
+
expect(calls).toHaveLength(0);
|
|
201
|
+
} finally {
|
|
202
|
+
read.mockRestore();
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test("keeps worker and cluster credentials out of Kubernetes failure messages", async () => {
|
|
207
|
+
handler = () =>
|
|
208
|
+
Response.json(
|
|
209
|
+
{ message: JSON.stringify({ token: target.K8S_TOKEN, env: request.env }) },
|
|
210
|
+
{ status: 422 },
|
|
211
|
+
);
|
|
212
|
+
await expect(provider.provision(target, request)).rejects.toThrow(
|
|
213
|
+
"Kubernetes POST pods failed (422)",
|
|
214
|
+
);
|
|
215
|
+
handler = () => Response.json({}, { status: 403 });
|
|
216
|
+
await expect(provider.list(target, request.ownerId)).rejects.toThrow(
|
|
217
|
+
"Kubernetes GET pods failed (403)",
|
|
218
|
+
);
|
|
219
|
+
await expect(provider.terminate(target, handle)).rejects.toThrow(
|
|
220
|
+
"Kubernetes DELETE pods failed (403)",
|
|
221
|
+
);
|
|
222
|
+
expect(await provider.status(target, handle)).toBe("unknown");
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("lists only this owner's runtimes and follows continuation tokens", async () => {
|
|
226
|
+
handler = (req) => {
|
|
227
|
+
const query = new URL(req.url).searchParams;
|
|
228
|
+
expect(query.get("labelSelector")).toBe(`swarm.owner=${request.ownerId},swarm.runtime-id`);
|
|
229
|
+
return query.has("continue")
|
|
230
|
+
? Response.json({ items: [{ metadata: { ...metadata, name: "second" } }], metadata: {} })
|
|
231
|
+
: Response.json({
|
|
232
|
+
items: [
|
|
233
|
+
{ metadata },
|
|
234
|
+
{
|
|
235
|
+
metadata: { ...metadata, labels: { ...labels, [RUNTIME_LABELS.owner]: "foreign" } },
|
|
236
|
+
},
|
|
237
|
+
{ metadata: { ...metadata, labels: { [RUNTIME_LABELS.owner]: request.ownerId } } },
|
|
238
|
+
],
|
|
239
|
+
metadata: { continue: "next+page/=" },
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
expect(await provider.list(target, request.ownerId)).toEqual([
|
|
243
|
+
handle,
|
|
244
|
+
{ ...handle, externalId: "second" },
|
|
245
|
+
]);
|
|
246
|
+
expect(new URL(calls[1]!.url).searchParams.get("continue")).toBe("next+page/=");
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("maps pod phases and detects replaced pods", async () => {
|
|
250
|
+
for (const [phase, status] of [
|
|
251
|
+
["Pending", "starting"],
|
|
252
|
+
["Running", "running"],
|
|
253
|
+
["Succeeded", "exited"],
|
|
254
|
+
["Failed", "failed"],
|
|
255
|
+
["Unknown", "unknown"],
|
|
256
|
+
]) {
|
|
257
|
+
handler = () => Response.json({ metadata, status: { phase } });
|
|
258
|
+
expect(await provider.status(target, handle)).toBe(status);
|
|
259
|
+
}
|
|
260
|
+
handler = () =>
|
|
261
|
+
Response.json({
|
|
262
|
+
metadata: { ...metadata, uid: "replacement" },
|
|
263
|
+
status: { phase: "Running" },
|
|
264
|
+
});
|
|
265
|
+
expect(await provider.status(target, handle)).toBe("exited");
|
|
266
|
+
handler = () => Response.json({}, { status: 404 });
|
|
267
|
+
expect(await provider.status(target, handle)).toBe("exited");
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("deletes with a UID precondition and preserves missing or replaced pods", async () => {
|
|
271
|
+
let body: unknown;
|
|
272
|
+
handler = async (req) => {
|
|
273
|
+
body = await req.json();
|
|
274
|
+
return Response.json({});
|
|
275
|
+
};
|
|
276
|
+
await provider.terminate(target, handle);
|
|
277
|
+
expect(calls[0]?.method).toBe("DELETE");
|
|
278
|
+
expect(body).toEqual({
|
|
279
|
+
apiVersion: "v1",
|
|
280
|
+
kind: "DeleteOptions",
|
|
281
|
+
preconditions: { uid: metadata.uid },
|
|
282
|
+
});
|
|
283
|
+
for (const status of [404, 409]) {
|
|
284
|
+
handler = () => Response.json({}, { status });
|
|
285
|
+
await provider.terminate(target, handle);
|
|
286
|
+
}
|
|
287
|
+
const count = calls.length;
|
|
288
|
+
await expect(provider.terminate({ ...target, K8S_NAMESPACE: "other" }, handle)).rejects.toThrow(
|
|
289
|
+
"configured namespace",
|
|
290
|
+
);
|
|
291
|
+
await expect(provider.terminate(target, { ...handle, meta: undefined })).rejects.toThrow(
|
|
292
|
+
"pod UID",
|
|
293
|
+
);
|
|
294
|
+
expect(calls).toHaveLength(count);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
test("rejects persistent cache before making an infrastructure request", async () => {
|
|
298
|
+
await expect(
|
|
299
|
+
provider.provision(target, { ...request, cache: { key: "cache", mountPath: "/cache" } }),
|
|
300
|
+
).rejects.toThrow("do not support persistent caches");
|
|
301
|
+
expect(calls).toHaveLength(0);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
@@ -702,6 +702,16 @@ describe("script connections", () => {
|
|
|
702
702
|
markMigrationApplied(database, "307_session_cost_credential_attribution.sql");
|
|
703
703
|
// This one alters session_logs, which this fixture lacks.
|
|
704
704
|
markMigrationApplied(database, "310_session_logs_reasoning.sql");
|
|
705
|
+
// 314 references model_profiles (made by the skipped 220) and alters
|
|
706
|
+
// scheduled_tasks, which this fixture does not create.
|
|
707
|
+
markMigrationApplied(database, "314_model_groups.sql");
|
|
708
|
+
// 318 updates agent_tasks.status, which this fixture's id-only
|
|
709
|
+
// agent_tasks lacks.
|
|
710
|
+
markMigrationApplied(database, "318_superseded_workflow_cut_backfill.sql");
|
|
711
|
+
// 319 indexes user FK columns on tables this fixture does not create.
|
|
712
|
+
markMigrationApplied(database, "319_user_fk_indexes.sql");
|
|
713
|
+
// 320 alters session_costs, which this fixture lacks.
|
|
714
|
+
markMigrationApplied(database, "320_session_costs_kind.sql");
|
|
705
715
|
|
|
706
716
|
const id = crypto.randomUUID();
|
|
707
717
|
const now = new Date().toISOString();
|
|
@@ -837,7 +847,9 @@ describe("script connections", () => {
|
|
|
837
847
|
);
|
|
838
848
|
// 213 rebuilds script_connections with the post-117 columns; skip it with 117.
|
|
839
849
|
markMigrationApplied(database, "213_script_connections_sql.sql");
|
|
840
|
-
|
|
850
|
+
// 319 indexes the oauth tables that 117 creates; skip it with 117.
|
|
851
|
+
markMigrationApplied(database, "319_user_fk_indexes.sql");
|
|
852
|
+
runMigrations(database); // applies every migration except 117, 213 and 319
|
|
841
853
|
|
|
842
854
|
const now = new Date().toISOString();
|
|
843
855
|
// A user-created STANDALONE binding: source='user', arbitrary config_key
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { generateBearerToken, generateShortId, randomChars } from "../utils/short-id";
|
|
3
|
+
|
|
4
|
+
const BASE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
5
|
+
|
|
6
|
+
describe("short-id", () => {
|
|
7
|
+
test("generateBearerToken is xsk_ plus 24 base62 chars", () => {
|
|
8
|
+
for (let i = 0; i < 50; i++) expect(generateBearerToken()).toMatch(/^xsk_[0-9a-zA-Z]{24}$/);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("generateShortId is 12 letters by default", () => {
|
|
12
|
+
expect(generateShortId()).toMatch(/^[a-zA-Z]{12}$/);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("randomChars rejects bytes at or above the largest multiple of 62", () => {
|
|
16
|
+
// 248 = 62 * 4: 247 is the last accepted byte, 248..255 are rejected.
|
|
17
|
+
const bytes = [248, 255, 247, 0, 61, 62];
|
|
18
|
+
const source = (size: number) => Uint8Array.from(bytes.splice(0, size));
|
|
19
|
+
expect(randomChars(BASE62, 4, source)).toBe(
|
|
20
|
+
BASE62[247 % 62] + BASE62[0] + BASE62[61] + BASE62[0],
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -45,9 +45,78 @@ describe("markdownToSlack", () => {
|
|
|
45
45
|
expect(markdownToSlack("## Header")).toBe("*Header*");
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
test("preserves the referrer heading inside a fenced code block", () => {
|
|
49
|
+
const code = "```\n# Referrer Views Uniq Share vs 7d ago\n```";
|
|
50
|
+
expect(markdownToSlack(code)).toBe(code);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("converts a heading outside a fenced code block", () => {
|
|
54
|
+
expect(markdownToSlack("# Heading")).toBe("*Heading*");
|
|
55
|
+
expect(markdownToSlack("# Heading\n```\n# code\n```")).toBe("*Heading*\n```\n# code\n```");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("preserves bold markers inside inline code", () => {
|
|
59
|
+
expect(markdownToSlack("Use `**x**` and **bold**")).toBe("Use `**x**` and *bold*");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("preserves formatting and whitespace inside code", () => {
|
|
63
|
+
const code =
|
|
64
|
+
"```ts\r\n**bold** __bold__ *italic* ~~strike~~\r\n- [link](https://example.com)\r\n\n\n\n\n`inline`\n```";
|
|
65
|
+
expect(markdownToSlack(code)).toBe(code);
|
|
66
|
+
expect(markdownToSlack("``a ` **x** [link](url)``")).toBe("``a ` **x** [link](url)``");
|
|
67
|
+
expect(markdownToSlack("`**x**\n# code`")).toBe("`**x**\n# code`");
|
|
68
|
+
expect(markdownToSlack("```\n# unfinished\n**x**")).toBe("```\n# unfinished\n**x**");
|
|
69
|
+
});
|
|
70
|
+
|
|
48
71
|
test("collapses excessive blank lines", () => {
|
|
49
72
|
expect(markdownToSlack("a\n\n\n\nb")).toBe("a\n\nb");
|
|
50
73
|
});
|
|
74
|
+
|
|
75
|
+
test("keeps literal code placeholders distinct from protected code", () => {
|
|
76
|
+
const literal = "\uE0020\uE0021\uE0020\uE003 \uE00200\uE0020\uE003";
|
|
77
|
+
const code = "`**code** \uE0022\uE0020\uE003`";
|
|
78
|
+
expect(markdownToSlack(`${literal} ${code} **bold**`)).toBe(`${literal} ${code} *bold*`);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// A generous budget catches quadratic marker selection; retry for a loaded CI host.
|
|
82
|
+
test(
|
|
83
|
+
"converts long marker runs without stalling",
|
|
84
|
+
() => {
|
|
85
|
+
const literal = "\uE002".repeat(80_000);
|
|
86
|
+
const code = "`**code**`";
|
|
87
|
+
const started = performance.now();
|
|
88
|
+
const converted = markdownToSlack(`${literal} ${code} **bold**`);
|
|
89
|
+
const elapsed = performance.now() - started;
|
|
90
|
+
expect(converted).toBe(`${literal} ${code} *bold*`);
|
|
91
|
+
expect(elapsed).toBeLessThan(1_000);
|
|
92
|
+
},
|
|
93
|
+
{ retry: 2 },
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
test.each([
|
|
97
|
+
"\n\n",
|
|
98
|
+
"\n \t\n",
|
|
99
|
+
"\r\n\r\n",
|
|
100
|
+
])("does not pair stray backticks across paragraph boundaries (%j)", (separator) => {
|
|
101
|
+
const text = `\`${separator}# Heading${separator}Use \`**code**\` and **bold**`;
|
|
102
|
+
expect(markdownToSlack(text)).toBe(
|
|
103
|
+
`\`${separator}*Heading*${separator}Use \`**code**\` and *bold*`,
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("does not start inline code at an escaped backtick", () => {
|
|
108
|
+
expect(markdownToSlack("\\`**bold**\\` and `**code**`")).toBe("\\`*bold*\\` and `**code**`");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("does not pair partial or unmatched backtick runs", () => {
|
|
112
|
+
expect(markdownToSlack("``**bold**` and **outside**")).toBe("``*bold*` and *outside*");
|
|
113
|
+
expect(markdownToSlack("`**bold**`` and **outside**")).toBe("`*bold*`` and *outside*");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("preserves inline code after an escaped backslash and before an escaped backtick", () => {
|
|
117
|
+
expect(markdownToSlack("\\\\`**code**` and **bold**")).toBe("\\\\`**code**` and *bold*");
|
|
118
|
+
expect(markdownToSlack("`**code**\\` and **bold**")).toBe("`**code**\\` and *bold*");
|
|
119
|
+
});
|
|
51
120
|
});
|
|
52
121
|
|
|
53
122
|
describe("getTaskLink", () => {
|