@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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { ToolCallEvent } from "../extensions/contract";
|
|
4
|
+
import { dispatchPost, dispatchPre } from "../extensions/dispatcher";
|
|
5
|
+
import type { RequestInfo } from "../tools/utils";
|
|
6
|
+
import { scrubObject } from "../utils/secret-scrubber";
|
|
7
|
+
import { route } from "./route-def";
|
|
8
|
+
import { jsonError } from "./utils";
|
|
9
|
+
|
|
10
|
+
const REDACTION_MARKER = "[REDACTED:";
|
|
11
|
+
|
|
12
|
+
const toolCallFields = {
|
|
13
|
+
harness: z.string().min(1).max(64).describe("Worker harness, such as `claude` or `pi`."),
|
|
14
|
+
tool: z.string().min(1).max(256).describe("Canonical tool name, such as `bash` or `edit`."),
|
|
15
|
+
nativeTool: z.string().min(1).max(256).optional().describe("The harness's own tool name."),
|
|
16
|
+
args: z.unknown().describe("Canonical tool arguments."),
|
|
17
|
+
rawArgs: z.unknown().optional().describe("The harness's own argument shape."),
|
|
18
|
+
toolCallId: z.string().max(256).optional(),
|
|
19
|
+
parentToolCallId: z.string().max(256).optional(),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const toolHookBody = z.discriminatedUnion("phase", [
|
|
23
|
+
z.object({ phase: z.literal("pre"), ...toolCallFields }),
|
|
24
|
+
z.object({
|
|
25
|
+
phase: z.literal("post"),
|
|
26
|
+
...toolCallFields,
|
|
27
|
+
result: z.unknown(),
|
|
28
|
+
isError: z.boolean().optional(),
|
|
29
|
+
durationMs: z.number().nonnegative(),
|
|
30
|
+
}),
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const toolHookDecision = z.discriminatedUnion("action", [
|
|
34
|
+
z.object({ action: z.literal("continue") }),
|
|
35
|
+
z.object({ action: z.literal("modify"), args: z.unknown() }),
|
|
36
|
+
z.object({ action: z.literal("block"), reason: z.string() }),
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const toolHookRoute = route({
|
|
40
|
+
method: "post",
|
|
41
|
+
path: "/api/tool-hooks",
|
|
42
|
+
pattern: ["api", "tool-hooks"],
|
|
43
|
+
summary: "Run extension tool hooks for a harness-native tool call",
|
|
44
|
+
description:
|
|
45
|
+
"A worker shim reports a harness built-in tool call (bash, read, write, edit). `phase: pre` " +
|
|
46
|
+
"runs `pre.tool.call` with `callOrigin: native` and returns the decision. `phase: post` runs " +
|
|
47
|
+
"`post.tool.call` observe-only and returns 202 at once. Only extensions whose manifest " +
|
|
48
|
+
'`toolSources` includes `"native"` receive these calls. The server runs the secret scrubber ' +
|
|
49
|
+
"over the body before any handler sees it, so handlers read `[REDACTED:<name>]` in place of " +
|
|
50
|
+
"a secret. A `modify` whose args still carry that marker is rejected and the call continues " +
|
|
51
|
+
"unchanged. Shims must also scrub worker-side before sending.",
|
|
52
|
+
tags: ["Extensions"],
|
|
53
|
+
auth: { apiKey: true, agentId: true },
|
|
54
|
+
body: toolHookBody,
|
|
55
|
+
maxBodyBytes: 2 * 1024 * 1024,
|
|
56
|
+
rbac: { ungated: "self-scoped: an agent reports its own harness tool calls" },
|
|
57
|
+
responses: {
|
|
58
|
+
200: { description: "Pre-call decision", schema: toolHookDecision },
|
|
59
|
+
202: {
|
|
60
|
+
description: "Post-call event accepted",
|
|
61
|
+
schema: z.object({ accepted: z.literal(true) }),
|
|
62
|
+
},
|
|
63
|
+
400: { description: "Invalid body or missing X-Agent-ID header" },
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function header(req: IncomingMessage, name: string): string | undefined {
|
|
68
|
+
const raw = req.headers[name];
|
|
69
|
+
return Array.isArray(raw) ? raw[0] : raw;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function handleToolHooks(
|
|
73
|
+
req: IncomingMessage,
|
|
74
|
+
res: ServerResponse,
|
|
75
|
+
pathSegments: string[],
|
|
76
|
+
queryParams: URLSearchParams,
|
|
77
|
+
myAgentId: string | undefined,
|
|
78
|
+
): Promise<boolean> {
|
|
79
|
+
if (!toolHookRoute.match(req.method, pathSegments)) return false;
|
|
80
|
+
if (!myAgentId) {
|
|
81
|
+
jsonError(res, "Missing X-Agent-ID header", 400);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
const parsed = await toolHookRoute.parse(req, res, pathSegments, queryParams);
|
|
85
|
+
if (!parsed) return true;
|
|
86
|
+
|
|
87
|
+
// Scrub at entry: handlers, extension_runs rows and logs only ever see the scrubbed body.
|
|
88
|
+
const body = scrubObject(parsed.body);
|
|
89
|
+
const requestInfo: RequestInfo = {
|
|
90
|
+
sessionId: undefined,
|
|
91
|
+
agentId: myAgentId,
|
|
92
|
+
runtimeInstanceId: header(req, "x-runtime-instance-id"),
|
|
93
|
+
sourceTaskId: header(req, "x-source-task-id"),
|
|
94
|
+
contextKey: header(req, "x-context-key"),
|
|
95
|
+
callOrigin: "native",
|
|
96
|
+
harness: body.harness,
|
|
97
|
+
};
|
|
98
|
+
const event: ToolCallEvent = {
|
|
99
|
+
tool: body.tool,
|
|
100
|
+
args: body.args,
|
|
101
|
+
requestInfo,
|
|
102
|
+
nativeTool: body.nativeTool,
|
|
103
|
+
rawArgs: body.rawArgs,
|
|
104
|
+
toolCallId: body.toolCallId,
|
|
105
|
+
parentToolCallId: body.parentToolCallId,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (body.phase === "post") {
|
|
109
|
+
toolHookRoute.respond(res, 202, { accepted: true });
|
|
110
|
+
void dispatchPost("post.tool.call", {
|
|
111
|
+
...event,
|
|
112
|
+
result: body.result,
|
|
113
|
+
isError: body.isError,
|
|
114
|
+
durationMs: body.durationMs,
|
|
115
|
+
});
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const result = await dispatchPre("pre.tool.call", event, {
|
|
120
|
+
// A marker in rewritten args is a placeholder, not the secret: executing it would break
|
|
121
|
+
// the call, so the rewrite is refused (an extension_runs error row) and the call continues.
|
|
122
|
+
validateModify: (data) =>
|
|
123
|
+
JSON.stringify(data.args ?? null).includes(REDACTION_MARKER)
|
|
124
|
+
? {
|
|
125
|
+
success: false,
|
|
126
|
+
error: new Error(
|
|
127
|
+
`Modified arguments for native tool "${body.tool}" contain a redaction marker`,
|
|
128
|
+
),
|
|
129
|
+
}
|
|
130
|
+
: { success: true, data },
|
|
131
|
+
});
|
|
132
|
+
if (result.action === "block") {
|
|
133
|
+
toolHookRoute.respond(res, 200, { action: "block", reason: result.reason });
|
|
134
|
+
} else if (result.action === "modify") {
|
|
135
|
+
toolHookRoute.respond(res, 200, { action: "modify", args: result.data.args });
|
|
136
|
+
} else {
|
|
137
|
+
toolHookRoute.respond(res, 200, { action: "continue" });
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
package/src/http/users.ts
CHANGED
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
* POST /api/connector/exchange (public: the code is the credential)
|
|
23
23
|
* POST /api/invites
|
|
24
24
|
* POST /api/invites/exchange (public: the code is the credential)
|
|
25
|
-
* POST /api/users/:id/merge
|
|
25
|
+
* POST /api/users/:id/merge (202: queues a user_merge_jobs row)
|
|
26
|
+
* GET /api/users/merge-jobs (must precede /:id)
|
|
27
|
+
* GET /api/users/merge-jobs/:jobId
|
|
26
28
|
* GET /api/users/:id/events
|
|
27
29
|
* POST /api/users/:id/identities
|
|
28
30
|
* DELETE /api/users/:id/identities/:kind/:externalId
|
|
@@ -43,7 +45,6 @@ import {
|
|
|
43
45
|
createUser,
|
|
44
46
|
deleteBudget,
|
|
45
47
|
deleteKv,
|
|
46
|
-
deleteUser,
|
|
47
48
|
getAllUsers,
|
|
48
49
|
getDbClient,
|
|
49
50
|
getUserById,
|
|
@@ -60,6 +61,15 @@ import {
|
|
|
60
61
|
OperatorGrantedTargetError,
|
|
61
62
|
setUserRoles,
|
|
62
63
|
} from "../be/rbac-roles";
|
|
64
|
+
import {
|
|
65
|
+
createUserMergeJob,
|
|
66
|
+
findActiveUserMergeJob,
|
|
67
|
+
findFailedUserMergeJob,
|
|
68
|
+
getUserMergeJob,
|
|
69
|
+
listUserMergeJobs,
|
|
70
|
+
requeueUserMergeJob,
|
|
71
|
+
runUserMergeJobs,
|
|
72
|
+
} from "../be/user-merge-jobs";
|
|
63
73
|
import {
|
|
64
74
|
findUserByEmail,
|
|
65
75
|
getUserIdentities,
|
|
@@ -70,11 +80,17 @@ import {
|
|
|
70
80
|
listUserTokens,
|
|
71
81
|
mintToken,
|
|
72
82
|
recordIdentityEvent,
|
|
83
|
+
revokeAllUserCredentials,
|
|
73
84
|
revokeToken,
|
|
74
85
|
unlinkIdentity,
|
|
75
86
|
} from "../be/users";
|
|
76
87
|
import { isRbacEnabled } from "../rbac";
|
|
77
|
-
import {
|
|
88
|
+
import {
|
|
89
|
+
UserCommsPrefsSchema,
|
|
90
|
+
UserMergeJobSchema,
|
|
91
|
+
UserMergeJobStatusSchema,
|
|
92
|
+
UserSchema,
|
|
93
|
+
} from "../types";
|
|
78
94
|
import { DEFAULT_APP_URL } from "../utils/constants";
|
|
79
95
|
import { assertUrlSafe } from "../utils/egress-guard";
|
|
80
96
|
import { authUser, getRequestAuth } from "../utils/request-auth-context";
|
|
@@ -600,14 +616,16 @@ const mergeUsersRoute = route({
|
|
|
600
616
|
method: "post",
|
|
601
617
|
path: "/api/users/{id}/merge",
|
|
602
618
|
pattern: ["api", "users", null, "merge"],
|
|
603
|
-
summary: "Merge another user into this one
|
|
619
|
+
summary: "Merge another user into this one: moves identities + email aliases, queues the rest",
|
|
620
|
+
description:
|
|
621
|
+
"Moves the source's identities and email aliases to the target, revokes the source's credentials and records a manual_merge event, all in one short transaction. The attribution rewrite across every table and the deletion of the source run as a background job; poll GET /api/users/merge-jobs/{jobId} until its status is done or failed. While the job runs, the source cannot authenticate and identity lookups resolve to the target.",
|
|
604
622
|
tags: ["Users"],
|
|
605
623
|
params: z.object({ id: z.string() }),
|
|
606
624
|
body: z.object({ sourceUserId: z.string().min(1) }),
|
|
607
625
|
responses: {
|
|
608
|
-
|
|
609
|
-
description: "
|
|
610
|
-
schema: z.object({
|
|
626
|
+
202: {
|
|
627
|
+
description: "The queued merge job",
|
|
628
|
+
schema: z.object({ job: UserMergeJobSchema }),
|
|
611
629
|
},
|
|
612
630
|
400: { description: "Validation error (e.g. target == source)" },
|
|
613
631
|
401: { description: "Unauthorized" },
|
|
@@ -616,7 +634,48 @@ const mergeUsersRoute = route({
|
|
|
616
634
|
"Target holds an operator-granted role (auditor) and the caller is not the operator key",
|
|
617
635
|
},
|
|
618
636
|
404: { description: "Target or source user not found" },
|
|
619
|
-
409: {
|
|
637
|
+
409: {
|
|
638
|
+
description:
|
|
639
|
+
"Source is the last active admin (last_admin), or a merge job for the source or target is still running (merge_in_progress)",
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
auth: { apiKey: true },
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
const listMergeJobsRoute = route({
|
|
646
|
+
method: "get",
|
|
647
|
+
path: "/api/users/merge-jobs",
|
|
648
|
+
pattern: ["api", "users", "merge-jobs"],
|
|
649
|
+
summary: "List background user merge jobs, newest first",
|
|
650
|
+
tags: ["Users"],
|
|
651
|
+
query: z.object({
|
|
652
|
+
status: UserMergeJobStatusSchema.optional(),
|
|
653
|
+
limit: z.coerce.number().int().min(1).max(200).optional(),
|
|
654
|
+
}),
|
|
655
|
+
responses: {
|
|
656
|
+
200: {
|
|
657
|
+
description: "Merge jobs",
|
|
658
|
+
schema: z.object({ jobs: z.array(UserMergeJobSchema) }),
|
|
659
|
+
},
|
|
660
|
+
401: { description: "Unauthorized" },
|
|
661
|
+
},
|
|
662
|
+
auth: { apiKey: true },
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
const getMergeJobRoute = route({
|
|
666
|
+
method: "get",
|
|
667
|
+
path: "/api/users/merge-jobs/{jobId}",
|
|
668
|
+
pattern: ["api", "users", "merge-jobs", null],
|
|
669
|
+
summary: "A background user merge job (poll until status is done or failed)",
|
|
670
|
+
tags: ["Users"],
|
|
671
|
+
params: z.object({ jobId: z.string() }),
|
|
672
|
+
responses: {
|
|
673
|
+
200: {
|
|
674
|
+
description: "The merge job",
|
|
675
|
+
schema: z.object({ job: UserMergeJobSchema }),
|
|
676
|
+
},
|
|
677
|
+
401: { description: "Unauthorized" },
|
|
678
|
+
404: { description: "Job not found" },
|
|
620
679
|
},
|
|
621
680
|
auth: { apiKey: true },
|
|
622
681
|
});
|
|
@@ -1394,6 +1453,31 @@ export async function handleUsers(
|
|
|
1394
1453
|
return true;
|
|
1395
1454
|
}
|
|
1396
1455
|
|
|
1456
|
+
// ─── GET /api/users/merge-jobs ─────────────────────────────────────────────
|
|
1457
|
+
if (listMergeJobsRoute.match(req.method, pathSegments)) {
|
|
1458
|
+
const parsed = await listMergeJobsRoute.parse(req, res, pathSegments, queryParams);
|
|
1459
|
+
if (!parsed) return true;
|
|
1460
|
+
const jobs = await listUserMergeJobs({
|
|
1461
|
+
status: parsed.query.status,
|
|
1462
|
+
limit: parsed.query.limit,
|
|
1463
|
+
});
|
|
1464
|
+
listMergeJobsRoute.respond(res, 200, { jobs });
|
|
1465
|
+
return true;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// ─── GET /api/users/merge-jobs/:jobId ──────────────────────────────────────
|
|
1469
|
+
if (getMergeJobRoute.match(req.method, pathSegments)) {
|
|
1470
|
+
const parsed = await getMergeJobRoute.parse(req, res, pathSegments, queryParams);
|
|
1471
|
+
if (!parsed) return true;
|
|
1472
|
+
const job = await getUserMergeJob(parsed.params.jobId);
|
|
1473
|
+
if (!job) {
|
|
1474
|
+
jsonError(res, "Merge job not found", 404);
|
|
1475
|
+
return true;
|
|
1476
|
+
}
|
|
1477
|
+
getMergeJobRoute.respond(res, 200, { job });
|
|
1478
|
+
return true;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1397
1481
|
// ─── POST /api/users/:id/merge ─────────────────────────────────────────────
|
|
1398
1482
|
if (mergeUsersRoute.match(req.method, pathSegments)) {
|
|
1399
1483
|
const parsed = await mergeUsersRoute.parse(req, res, pathSegments, queryParams);
|
|
@@ -1417,9 +1501,37 @@ export async function handleUsers(
|
|
|
1417
1501
|
jsonError(res, "Source user not found", 404);
|
|
1418
1502
|
return true;
|
|
1419
1503
|
}
|
|
1504
|
+
// A user still being merged (either way) cannot take part in another merge:
|
|
1505
|
+
// the running job would race the rewrite. A target that is itself a merge
|
|
1506
|
+
// source is on its way out and cannot receive anything.
|
|
1507
|
+
if (
|
|
1508
|
+
targetBefore.mergedIntoUserId ||
|
|
1509
|
+
(await findActiveUserMergeJob(sourceId)) ||
|
|
1510
|
+
(await findActiveUserMergeJob(targetId))
|
|
1511
|
+
) {
|
|
1512
|
+
jsonError(res, "merge_in_progress", 409);
|
|
1513
|
+
return true;
|
|
1514
|
+
}
|
|
1515
|
+
// A source marked by an earlier merge whose job failed for good: the same
|
|
1516
|
+
// pair re-queues that job (identities and aliases already moved); a new
|
|
1517
|
+
// target goes through the short phase again, so the mark moves with it.
|
|
1518
|
+
if (sourceBefore.mergedIntoUserId) {
|
|
1519
|
+
const failed = await findFailedUserMergeJob(sourceId, targetId);
|
|
1520
|
+
if (failed) {
|
|
1521
|
+
const requeued = await requeueUserMergeJob(failed.id);
|
|
1522
|
+
if (requeued) {
|
|
1523
|
+
void runUserMergeJobs();
|
|
1524
|
+
mergeUsersRoute.respond(res, 202, { job: requeued });
|
|
1525
|
+
return true;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1420
1529
|
try {
|
|
1421
|
-
|
|
1422
|
-
|
|
1530
|
+
// Phase A, one short transaction: the parts a reader must see at once.
|
|
1531
|
+
// The long attribution rewrite and the source row's deletion run as a
|
|
1532
|
+
// background job (src/be/user-merge-jobs.ts): on a large database
|
|
1533
|
+
// they held the event loop for minutes (incident 2026-11-09).
|
|
1534
|
+
const job = await getDbClient().transaction(async () => {
|
|
1423
1535
|
await assertMayActOnOperatorGrantedTarget(actor, targetId);
|
|
1424
1536
|
// Move every identity from source → target.
|
|
1425
1537
|
for (const ident of sourceBefore.identities) {
|
|
@@ -1457,13 +1569,17 @@ export async function handleUsers(
|
|
|
1457
1569
|
// The source's roles go with it; never leave the swarm without an admin.
|
|
1458
1570
|
await assertNotLastAdmin(sourceId);
|
|
1459
1571
|
|
|
1460
|
-
//
|
|
1461
|
-
//
|
|
1462
|
-
await
|
|
1572
|
+
// From here the source is the target for every lookup and can no
|
|
1573
|
+
// longer authenticate (auth.ts isActiveUser, users.ts lookups).
|
|
1574
|
+
await revokeAllUserCredentials(sourceId, actor);
|
|
1575
|
+
await getDbClient().run(
|
|
1576
|
+
"UPDATE users SET mergedIntoUserId = ?, lastUpdatedAt = ? WHERE id = ?",
|
|
1577
|
+
[targetId, new Date().toISOString(), sourceId],
|
|
1578
|
+
);
|
|
1463
1579
|
|
|
1464
1580
|
// Single manual_merge event on target capturing the before/after rows.
|
|
1465
|
-
// The source row is deleted
|
|
1466
|
-
// source user ({id, name, email}) inside the `after` payload under
|
|
1581
|
+
// The source row is deleted by the job, so carry a minimal snapshot of
|
|
1582
|
+
// the source user ({id, name, email}) inside the `after` payload under
|
|
1467
1583
|
// `source` — this lets the UI render "Merged manually from X → Y".
|
|
1468
1584
|
const targetAfter = await composeUser(targetId);
|
|
1469
1585
|
await recordIdentityEvent(targetId, "manual_merge", actor, targetBefore, {
|
|
@@ -1475,11 +1591,18 @@ export async function handleUsers(
|
|
|
1475
1591
|
},
|
|
1476
1592
|
});
|
|
1477
1593
|
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1594
|
+
const queued = await createUserMergeJob({
|
|
1595
|
+
sourceUserId: sourceId,
|
|
1596
|
+
targetUserId: targetId,
|
|
1597
|
+
createdBy: authUser(getRequestAuth(req))?.id ?? null,
|
|
1598
|
+
});
|
|
1599
|
+
// Start the runner once the job row is visible to it.
|
|
1600
|
+
getDbClient().afterCommit(() => {
|
|
1601
|
+
void runUserMergeJobs();
|
|
1602
|
+
});
|
|
1603
|
+
return queued;
|
|
1481
1604
|
});
|
|
1482
|
-
mergeUsersRoute.respond(res,
|
|
1605
|
+
mergeUsersRoute.respond(res, 202, { job });
|
|
1483
1606
|
} catch (err) {
|
|
1484
1607
|
if (respondOperatorGrantedRefusal(res, err)) return true;
|
|
1485
1608
|
if (err instanceof LastAdminError) {
|
package/src/http/workflows.ts
CHANGED
|
@@ -487,6 +487,15 @@ const webhookTriggerRoute = route({
|
|
|
487
487
|
params: z.object({ workflowId: z.string() }),
|
|
488
488
|
auth: { apiKey: false },
|
|
489
489
|
responses: {
|
|
490
|
+
200: {
|
|
491
|
+
description:
|
|
492
|
+
"Delivery skipped: its event is not in the trigger's `events` allowlist. No run was created.",
|
|
493
|
+
schema: z.object({
|
|
494
|
+
skipped: z.literal(true),
|
|
495
|
+
reason: z.literal("event-not-allowed"),
|
|
496
|
+
event: z.string().nullable(),
|
|
497
|
+
}),
|
|
498
|
+
},
|
|
490
499
|
201: { description: "Webhook processed", schema: z.object({ runId: z.string() }) },
|
|
491
500
|
401: { description: "Invalid signature" },
|
|
492
501
|
404: { description: "Workflow not found" },
|
|
@@ -585,7 +594,16 @@ export async function handleWorkflows(
|
|
|
585
594
|
// Egress stays OUTSIDE the try: `respond()` runtime-validates in dev/test
|
|
586
595
|
// and must fail loudly rather than be reported as a webhook failure for a
|
|
587
596
|
// run that already started.
|
|
588
|
-
|
|
597
|
+
if (result.skipped) {
|
|
598
|
+
// 2xx, not 4xx: GitHub and similar senders count non-2xx as a failed delivery.
|
|
599
|
+
webhookTriggerRoute.respond(res, 200, {
|
|
600
|
+
skipped: true,
|
|
601
|
+
reason: result.reason,
|
|
602
|
+
event: result.event,
|
|
603
|
+
});
|
|
604
|
+
} else {
|
|
605
|
+
webhookTriggerRoute.respond(res, 201, { runId: result.runId });
|
|
606
|
+
}
|
|
589
607
|
return true;
|
|
590
608
|
}
|
|
591
609
|
|
|
@@ -494,7 +494,7 @@ export async function flushChatThread(
|
|
|
494
494
|
try {
|
|
495
495
|
// The adapter verified the platform signature, and the workflow id comes
|
|
496
496
|
// from an operator mapping or an extension, never from the message.
|
|
497
|
-
const
|
|
497
|
+
const result = await handleWebhookTrigger(
|
|
498
498
|
target.workflowId,
|
|
499
499
|
{
|
|
500
500
|
adapter,
|
|
@@ -510,7 +510,13 @@ export async function flushChatThread(
|
|
|
510
510
|
getExecutorRegistry(),
|
|
511
511
|
{ alreadyAuthenticated: true },
|
|
512
512
|
);
|
|
513
|
-
|
|
513
|
+
if (result.skipped) {
|
|
514
|
+
// The workflow's webhook trigger sets an `events` allowlist; chat
|
|
515
|
+
// dispatch carries no event header, so the allowlist drops it.
|
|
516
|
+
console.warn(`[chat-sdk] ${threadId}: workflow webhook trigger skipped (${result.reason})`);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
console.log(`[chat-sdk] ${threadId}: started workflow run ${result.runId}`);
|
|
514
520
|
await subscribe(thread);
|
|
515
521
|
} catch (error) {
|
|
516
522
|
console.error(`[chat-sdk] ${threadId}: workflow dispatch failed: ${errorMessage(error)}`);
|
|
@@ -47,7 +47,8 @@ export const CHAT_FILES_PER_MESSAGE = 10;
|
|
|
47
47
|
* Split `text` into chunks of at most `limit` characters. A chunk ends at the
|
|
48
48
|
* last line break inside the window, else at the last space, else at the
|
|
49
49
|
* limit. Breaks in the first half of the window are ignored, so chunks never
|
|
50
|
-
* get very short.
|
|
50
|
+
* get very short. The break character stays with the chunk it ends, so
|
|
51
|
+
* joining the chunks reproduces `text` exactly.
|
|
51
52
|
*/
|
|
52
53
|
export function splitChatMessage(text: string, limit: number): string[] {
|
|
53
54
|
if (limit <= 0) throw new Error("splitChatMessage: limit must be positive");
|
|
@@ -68,9 +69,13 @@ export function splitChatMessage(text: string, limit: number): string[] {
|
|
|
68
69
|
// advances (cut would otherwise become 0 and loop forever).
|
|
69
70
|
cut = cut > 1 ? cut - 1 : cut + 1;
|
|
70
71
|
}
|
|
72
|
+
} else {
|
|
73
|
+
// Keep the break character in the chunk it ends: trimming it here or
|
|
74
|
+
// stripping it from `rest` would drop it from the delivered text (#2879).
|
|
75
|
+
cut += 1;
|
|
71
76
|
}
|
|
72
|
-
chunks.push(rest.slice(0, cut)
|
|
73
|
-
rest = rest.slice(cut)
|
|
77
|
+
chunks.push(rest.slice(0, cut));
|
|
78
|
+
rest = rest.slice(cut);
|
|
74
79
|
}
|
|
75
80
|
if (rest.length > 0 || chunks.length === 0) chunks.push(rest);
|
|
76
81
|
return chunks.filter((chunk, index) => chunk.length > 0 || index === 0);
|
|
@@ -427,7 +427,7 @@ const copilotTargetProfile: AcpTargetProfile = {
|
|
|
427
427
|
},
|
|
428
428
|
};
|
|
429
429
|
|
|
430
|
-
/** Qwen Code's `--auth-type` choices (0.27.
|
|
430
|
+
/** Qwen Code's `--auth-type` choices (0.27.1). `qwen-oauth` and `qwen-subscription` need an interactive sign-in, so they are left out. */
|
|
431
431
|
const QWEN_AUTH_TYPES = ["openai", "openai-responses", "anthropic", "gemini", "vertex-ai"] as const;
|
|
432
432
|
|
|
433
433
|
// Qwen Code is a Gemini CLI fork: QWEN_SYSTEM_MD replaces its built-in prompt
|
|
@@ -1002,7 +1002,7 @@ export const fxTargetProfile: AcpTargetProfile = {
|
|
|
1002
1002
|
};
|
|
1003
1003
|
|
|
1004
1004
|
export function resolveAcpTarget(config: ProviderSessionConfig): AcpTargetProfile {
|
|
1005
|
-
const target = readEnv(config, "ACP_TARGET")
|
|
1005
|
+
const target = readEnv(config, "ACP_TARGET")?.trim().toLowerCase() || "custom";
|
|
1006
1006
|
if (!isAcpTarget(target)) {
|
|
1007
1007
|
throw new AcpTargetResolutionError(
|
|
1008
1008
|
`Unsupported ACP target "${target}". Supported targets: ${ACP_TARGET_IDS.join(", ")}.`,
|
|
@@ -45,7 +45,7 @@ import type {
|
|
|
45
45
|
* default; the image installs exactly this version and the per-task settings
|
|
46
46
|
* set `amp.updates.mode: "disabled"`. Bump it deliberately, with a live run.
|
|
47
47
|
*/
|
|
48
|
-
export const AMP_PACKAGE = "@ampcode/cli@0.0.
|
|
48
|
+
export const AMP_PACKAGE = "@ampcode/cli@0.0.1794225648-g45053b";
|
|
49
49
|
|
|
50
50
|
/** MCP server name. Amp exposes its tools as `agent_swarm` / `store_progress` (dashes become underscores). */
|
|
51
51
|
const AMP_MCP_SERVER_NAME = "agent-swarm";
|
|
@@ -275,6 +275,15 @@ also appear in the UI picker or cold-start fallback, add it to
|
|
|
275
275
|
`src/be/modelsdev-cache.json`; otherwise add a manual override row via the
|
|
276
276
|
existing admin route `POST /api/pricing`.
|
|
277
277
|
|
|
278
|
+
## SystemOne decisions
|
|
279
|
+
|
|
280
|
+
`system-one-decide` records each decision made for a task as a `session_costs`
|
|
281
|
+
row with `kind='system-one'`. It looks up rates under provider `system-one`,
|
|
282
|
+
model `<host>/<model>` (for example `cloudflare/clef`), token classes `input`
|
|
283
|
+
and `output`. There is no seed for this provider: no public per-token rate
|
|
284
|
+
exists for every host, so rows stay `unpriced` at $0 with tokens kept until an
|
|
285
|
+
operator adds rates via `POST /api/pricing`.
|
|
286
|
+
|
|
278
287
|
## Session attribution and cache counters
|
|
279
288
|
|
|
280
289
|
Workers capture credential type, credential suffix, and harness at execution start.
|
|
@@ -328,6 +328,7 @@ export const LEGACY_POLICY = {
|
|
|
328
328
|
"models.catalog.write": leadOrOperator,
|
|
329
329
|
"models.harness-support.write": agentOrOperator,
|
|
330
330
|
"models.profiles.write": operatorOnly,
|
|
331
|
+
"models.groups.write": leadOrOperatorOrUser,
|
|
331
332
|
"skill.create.swarm": leadOnly,
|
|
332
333
|
"skill.install.any": leadOnly,
|
|
333
334
|
"skill.install.global": leadOnly,
|
package/src/rbac/permissions.ts
CHANGED
|
@@ -264,6 +264,11 @@ export const PERMISSIONS = {
|
|
|
264
264
|
"Create, update, or delete model profiles (named harness + model + effort). Operator (shared API key) only.",
|
|
265
265
|
namespace: "models",
|
|
266
266
|
},
|
|
267
|
+
"models.groups.write": {
|
|
268
|
+
description:
|
|
269
|
+
"Create, update, reorder, or delete model groups (named, ordered lists of model profiles). Lead, operator, or dashboard user.",
|
|
270
|
+
namespace: "models",
|
|
271
|
+
},
|
|
267
272
|
"config.read.secrets": {
|
|
268
273
|
description: "Read unmasked secret config values.",
|
|
269
274
|
namespace: "config",
|
|
@@ -3,7 +3,7 @@ import type { RuntimeProvider, RuntimeProviderKind, RuntimeTargetConfig } from "
|
|
|
3
3
|
export type * from "./types";
|
|
4
4
|
|
|
5
5
|
export function canProvisionKind(kind: RuntimeProviderKind): boolean {
|
|
6
|
-
return kind === "docker" || kind === "e2b" || kind === "boxd";
|
|
6
|
+
return kind === "docker" || kind === "e2b" || kind === "boxd" || kind === "k8s";
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -31,11 +31,13 @@ export async function createRuntimeProvider(
|
|
|
31
31
|
const { BoxdRuntimeProvider } = await import("./boxd");
|
|
32
32
|
return new BoxdRuntimeProvider();
|
|
33
33
|
}
|
|
34
|
-
case "k8s":
|
|
34
|
+
case "k8s": {
|
|
35
|
+
const { KubernetesRuntimeProvider } = await import("./k8s");
|
|
36
|
+
return new KubernetesRuntimeProvider();
|
|
37
|
+
}
|
|
38
|
+
default:
|
|
35
39
|
throw new Error(
|
|
36
|
-
|
|
40
|
+
`Unknown runtime provider: "${kind}". Supported: static, docker, e2b, boxd, k8s`,
|
|
37
41
|
);
|
|
38
|
-
default:
|
|
39
|
-
throw new Error(`Unknown runtime provider: "${kind}". Supported: static, docker, e2b, boxd`);
|
|
40
42
|
}
|
|
41
43
|
}
|