@desplega.ai/agent-swarm 2.13.4 → 2.13.5
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-tbt61zkm.js +17 -0
- package/dist/{acp-targets-zrk9k0n7.js → acp-targets-w8dbs4nr.js} +7 -7
- package/dist/{actions-acqqj9jn.js → actions-8zrcbjrx.js} +26 -26
- package/dist/{agent-fs-provision-zmaykqnd.js → agent-fs-provision-cbt2ttds.js} +4 -4
- package/dist/{amp-adapter-a7ts8tmw.js → amp-adapter-8x6zp8w4.js} +2 -2
- package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
- package/dist/{app-tmwa442h.js → app-zfa9dwjw.js} +6 -6
- package/dist/{approval-notifications-6psaaaye.js → approval-notifications-rv92zmza.js} +7 -7
- package/dist/{assistant-564v6emv.js → assistant-q7s7rm1q.js} +24 -24
- package/dist/{boot-args-schema-n099e0f2.js → boot-args-schema-g27kpzr1.js} +1 -1
- package/dist/{boot-reembed-epvg4fp9.js → boot-reembed-1mjs52nt.js} +1 -1
- package/dist/{boot-reembed-chx66qfk.js → boot-reembed-m62dpdkg.js} +1 -1
- package/dist/{boot-scrub-sweep-dhkfp0a7.js → boot-scrub-sweep-ss1vcamw.js} +2 -2
- package/dist/{boot-seeds-m74fc07r.js → boot-seeds-hwnvgbb3.js} +4 -4
- package/dist/{boxd-451q55ys.js → boxd-y0szhp0g.js} +1 -1
- package/dist/{claude-adapter-hw63yj3j.js → claude-adapter-0rjmbhjk.js} +7 -7
- package/dist/{claude-managed-adapter-z5s7fx6p.js → claude-managed-adapter-6k032agg.js} +3 -3
- package/dist/{claude-managed-setup-wee1762m.js → claude-managed-setup-6czvve8q.js} +4 -4
- package/dist/{claude-sdk-session-cktyqkpk.js → claude-sdk-session-pr0znb81.js} +12667 -11881
- package/dist/{cli-0fgvnb0x.js → cli-0qt3epg4.js} +3 -3
- package/dist/{cli-ka48vpev.js → cli-19d6v8er.js} +3 -3
- package/dist/{cli-zexwhj3f.js → cli-1jq2em7b.js} +3 -3
- package/dist/{cli-5rgm8p39.js → cli-2wzkvfgm.js} +2 -2
- package/dist/{cli-x2cem5vy.js → cli-34fygf87.js} +2 -2
- package/dist/{cli-tsc3pdfd.js → cli-3860pmrq.js} +3 -3
- package/dist/{cli-hhtbandk.js → cli-3vw6dd4g.js} +2 -2
- package/dist/{cli-qzz6tz8s.js → cli-4gaf3tx5.js} +1 -1
- package/dist/{cli-9ah37a8a.js → cli-55h8m1x3.js} +8 -5
- package/dist/{cli-7gbff32z.js → cli-5n9w2xzx.js} +1 -1
- package/dist/{cli-p436yrzp.js → cli-5tq15aa7.js} +1 -1
- package/dist/{cli-jyhbvdga.js → cli-5web09sb.js} +2 -2
- package/dist/{cli-3zrwrnz7.js → cli-69zzpjgh.js} +1 -1
- package/dist/{cli-7g3fg4gf.js → cli-6msnpj1z.js} +6 -6
- package/dist/{cli-azj9t1f9.js → cli-7r9tvk8v.js} +41 -3
- package/dist/{cli-4fpa0zns.js → cli-7ypg8hka.js} +3 -3
- package/dist/{cli-8cas2xvp.js → cli-887vhew6.js} +2 -2
- package/dist/{cli-t0jmkcah.js → cli-8pd1t17c.js} +7 -7
- package/dist/{cli-h9d3sdnc.js → cli-94mxerrp.js} +1 -1
- package/dist/{cli-bv4vvnmg.js → cli-9n6g14vs.js} +2 -2
- package/dist/{cli-5ashycw3.js → cli-abby987g.js} +2 -2
- package/dist/{cli-kj84fqxz.js → cli-avax5mp9.js} +1 -1
- package/dist/{cli-ea7nz50q.js → cli-b42yfn17.js} +11 -11
- package/dist/{cli-ysv0k1we.js → cli-b9ygp1kz.js} +1 -1
- package/dist/{cli-3bxrrh53.js → cli-bvamr9g0.js} +2 -2
- package/dist/{cli-gse7bp3z.js → cli-ced4azn1.js} +10 -9
- package/dist/{cli-7by7vp6m.js → cli-cmbb2t8a.js} +2 -2
- package/dist/{cli-0p76my9q.js → cli-cp163xga.js} +10 -10
- package/dist/{cli-jzerrzgc.js → cli-ebpq3c5z.js} +8 -8
- package/dist/{cli-p3knvk62.js → cli-ehg90jd1.js} +113 -39
- package/dist/{cli-jg5txpm6.js → cli-emdfd8fh.js} +75 -1
- package/dist/{cli-d5pc8ep0.js → cli-evy3egte.js} +7 -7
- package/dist/{cli-60dwk8tx.js → cli-ewk3sg68.js} +2 -2
- package/dist/{cli-nc4pbwmp.js → cli-f7b9nyvk.js} +4 -4
- package/dist/{cli-29h5239w.js → cli-f9xw9pr4.js} +4 -4
- package/dist/{cli-3tzmh38q.js → cli-ffn0a515.js} +7 -7
- package/dist/{cli-dqgnbnxs.js → cli-grbngev5.js} +6 -1
- package/dist/{cli-cq4am6vg.js → cli-hd5bm1e1.js} +4 -4
- package/dist/{cli-akm6y2a8.js → cli-htb5bpz2.js} +1 -1
- package/dist/{cli-tr19nyn9.js → cli-j69pzrrz.js} +6 -6
- package/dist/{cli-hdhpdrka.js → cli-jdq3jmny.js} +3 -3
- package/dist/{cli-ja450998.js → cli-ks06cd0n.js} +1 -1
- package/dist/{cli-pz1dp12c.js → cli-kwj3131p.js} +1 -1
- package/dist/{cli-1vmhnncj.js → cli-m8f4379k.js} +3 -3
- package/dist/{cli-jbrc98qb.js → cli-n79j1vxc.js} +2 -2
- package/dist/{cli-b768ek79.js → cli-nrt048ys.js} +1 -0
- package/dist/{cli-93n305hm.js → cli-pedm2kht.js} +1 -1
- package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
- package/dist/{cli-n1kjs58m.js → cli-prz1p3ft.js} +3 -3
- package/dist/{cli-pz1nq5xm.js → cli-q1h041y8.js} +3 -3
- package/dist/{cli-cah298e5.js → cli-q41qar56.js} +104 -119
- package/dist/{cli-4pbwg7sn.js → cli-qmx8bnt4.js} +1 -1
- package/dist/{cli-944w9wb4.js → cli-qrvk9nka.js} +18 -13
- package/dist/{cli-gtj12v95.js → cli-r3dxpmyt.js} +1 -1
- package/dist/{cli-phdzn699.js → cli-ryem5cfq.js} +7 -7
- package/dist/{cli-49aq3cyn.js → cli-s8dhq7rj.js} +4 -4
- package/dist/{cli-fkpnx3vf.js → cli-sejvnjvw.js} +3 -2
- package/dist/{cli-m1sns1da.js → cli-srre41gb.js} +2 -2
- package/dist/{cli-5rxsb3wq.js → cli-t0n9svkb.js} +3 -3
- package/dist/{cli-tzw1jr2t.js → cli-t879ww0y.js} +2 -2
- package/dist/{cli-xwsm6xkr.js → cli-tgc1kgg3.js} +1 -1
- package/dist/{cli-404am6f3.js → cli-tt7dkwjj.js} +6 -6
- package/dist/{cli-zjdhrzm0.js → cli-tvyt8w6n.js} +2 -2
- package/dist/{cli-hyqksecw.js → cli-v09eza21.js} +9 -9
- package/dist/{cli-rv3y60bt.js → cli-vbge4rsp.js} +4 -4
- package/dist/{cli-bzcwwebm.js → cli-vcpyttcw.js} +1 -1
- package/dist/{cli-904wk98s.js → cli-wzecestt.js} +338 -98
- package/dist/{cli-gkv0r2hq.js → cli-x2adbg4j.js} +70 -8
- package/dist/{cli-4q2c8rxw.js → cli-z3x7h79n.js} +12 -6
- package/dist/{cli-s33bzmk0.js → cli-z40t85ms.js} +1 -1
- package/dist/{cli-rmgvwcmy.js → cli-zbbtp02a.js} +98 -21
- package/dist/{cli-3xqad83h.js → cli-zntvmqmm.js} +1 -1
- package/dist/{cli-zhwjdhjr.js → cli-zxa1vmx7.js} +1 -1
- package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
- package/dist/{cli-ts5yv7dn.js → cli-zzq96q57.js} +123 -33
- package/dist/cli.js +18 -18
- package/dist/{codex-adapter-2fs2c0n6.js → codex-adapter-bn7eaxk5.js} +6 -6
- package/dist/{codex-hook-jxjv6dy5.js → codex-hook-nnmezjg9.js} +2 -2
- package/dist/{codex-session-runner-r55tmx4c.js → codex-session-runner-j1e9hffc.js} +6 -6
- package/dist/{commands-0mxdy9x8.js → commands-amhpafrr.js} +3 -3
- package/dist/{controller-g3vkfhr4.js → controller-tw7g10j2.js} +3 -3
- package/dist/{controllers-connect-4wdmncqt.js → controllers-connect-2ssqz7f4.js} +23 -23
- package/dist/{core-gsvj5f3z.js → core-bwp98v4w.js} +21 -21
- package/dist/{cursor-adapter-t9qb96q2.js → cursor-adapter-d6knjmwa.js} +1 -1
- package/dist/{db-487vvyv9.js → db-fd6xxm77.js} +3 -3
- package/dist/{db-76p7w3gr.js → db-sc59379z.js} +2 -2
- package/dist/{dispatcher-64rp6w67.js → dispatcher-a2gdqz8c.js} +21 -21
- package/dist/{dsh-adapter-8abzqk5c.js → dsh-adapter-43ygwqn7.js} +1 -1
- package/dist/{e2b-dc8f6ctq.js → e2b-cn7cvjqy.js} +1 -1
- package/dist/{e2b-3ykbe805.js → e2b-qnxyfea6.js} +1 -1
- package/dist/{easter-egg-3d-jrrwyf55.js → easter-egg-3d-a0pphy71.js} +1 -1
- package/dist/{embedding-space-001hhhpk.js → embedding-space-qepzrach.js} +6 -6
- package/dist/{embeddings-esj19cnw.js → embeddings-d7vr881x.js} +1 -1
- package/dist/{execute-301hkxqg.js → execute-6afts2bn.js} +1 -1
- package/dist/{external-channel-w10e2j05.js → external-channel-881zq1x4.js} +2 -2
- package/dist/fx-adapter-cr2hq17y.js +20 -0
- package/dist/{grok-adapter-3a0ezfee.js → grok-adapter-ayddnbsc.js} +9 -9
- package/dist/handlers-7ghs84x2.js +41 -0
- package/dist/{heartbeat-tbrj7vhq.js → heartbeat-4c022m6a.js} +24 -24
- package/dist/{hook-3am1sq68.js → hook-4k84x499.js} +5 -5
- package/dist/{hook-tx917rqw.js → hook-a7eh6zty.js} +7 -7
- package/dist/{http-3rmemtqy.js → http-6aw5wanc.js} +180 -94
- package/dist/index-dtt0d634.js +44 -0
- package/dist/index-hmszyqkk.js +42 -0
- package/dist/index-j6rm1rtn.js +39 -0
- package/dist/{index-aetfyx6p.js → index-rwwhsmjg.js} +1 -1
- package/dist/{index-s7xtvc0f.js → index-xhad0n8m.js} +1 -1
- package/dist/{index-2jw11t8s.js → index-yq9hhhhy.js} +25 -25
- package/dist/{index-gfnq66t1.js → index-z2g9469g.js} +202 -17
- package/dist/{keepalive-9px3t7qj.js → keepalive-zhbmztqw.js} +4 -4
- package/dist/lead-g2j4q39z.js +83 -0
- package/dist/{maintenance-vwqjwst6.js → maintenance-rsp0591h.js} +1 -1
- package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
- package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
- package/dist/{node-z67yjre7.js → node-rxte5hc6.js} +290 -70
- package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
- package/dist/{oauth-refresh-sweep-yqry3wn4.js → oauth-refresh-sweep-w3cqmxq7.js} +3 -3
- package/dist/{object-webhooks-8s1wtths.js → object-webhooks-331hay92.js} +7 -7
- package/dist/{onboard-hb8czx0p.js → onboard-n2w80m2n.js} +3 -3
- package/dist/{opencode-adapter-djd6m6dk.js → opencode-adapter-z98127cz.js} +6 -6
- package/dist/{otel-impl-2ymwyczz.js → otel-impl-xsk35tvf.js} +1 -1
- package/dist/{pending-nxavtvx7.js → pending-2e6trkxd.js} +22 -22
- package/dist/{pi-mono-adapter-d2cpmcy4.js → pi-mono-adapter-wh6yndtm.js} +8 -8
- package/dist/{pricing-refresh-1yz8jkqv.js → pricing-refresh-9355dj1t.js} +2 -2
- package/dist/{rbac-roles-dbpx0x9v.js → rbac-roles-58y3m912.js} +3 -3
- package/dist/{rbac-roles-7s6m31xw.js → rbac-roles-8eajw4s6.js} +2 -2
- package/dist/{render-v2-7y20rjrn.js → render-v2-7gskkmd4.js} +6 -6
- package/dist/{resume-wz546x47.js → resume-0drnmpja.js} +9 -9
- package/dist/{runtime-cb5bd9tz.js → runtime-d2tcmqte.js} +1 -1
- package/dist/{session-access-4vcft8kq.js → session-access-0ztys6bd.js} +5 -5
- package/dist/{session-source-backfill-57b50tpw.js → session-source-backfill-cdm5s046.js} +2 -2
- package/dist/{setup-e1tevjyj.js → setup-pqwb9tcc.js} +1 -1
- package/dist/thread-buffer-epx3san4.js +42 -0
- package/dist/{tree-visibility-07wf1nct.js → tree-visibility-rwz67mje.js} +2 -2
- package/dist/{user-merge-jobs-n20qpv6s.js → user-merge-jobs-mxrhamwt.js} +3 -3
- package/dist/{virtual-modules-6fxmn1yv.js → virtual-modules-71y1gsmg.js} +3 -3
- package/dist/{work-objects-eg7y48pe.js → work-objects-3k4ykt9j.js} +24 -24
- package/dist/worker-09gqn9xy.js +83 -0
- package/dist/{worker-follow-up-jnvnnf2b.js → worker-follow-up-y0h64xpr.js} +21 -21
- package/openapi.json +387 -6
- package/package.json +4 -4
- package/src/apps/sync.ts +20 -5
- package/src/azure-devops/boards-sync.ts +1 -1
- package/src/be/db/slack-trees.ts +12 -1
- package/src/be/db/tasks/read.ts +25 -1
- package/src/be/db/tasks/write.ts +47 -12
- package/src/be/db/users/avatar.ts +12 -0
- package/src/be/db.ts +78 -5
- package/src/be/migrations/344_user_avatar.sql +4 -0
- package/src/be/migrations/345_task_status_kind.sql +6 -0
- package/src/be/primitives/object-embed.ts +2 -2
- package/src/be/primitives/objects.ts +2 -2
- package/src/be/runtime-pools/supervisor.ts +1 -0
- package/src/be/scripts/typecheck.ts +1 -1
- package/src/be/swarm-config-guard.ts +4 -0
- package/src/bitbucket/handlers.ts +1 -1
- package/src/commands/credential-outcome-report.ts +96 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +49 -3
- package/src/event-waits/github.ts +39 -6
- package/src/event-waits/index.ts +4 -2
- package/src/event-waits/types.ts +10 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/github/app.ts +177 -13
- package/src/github/handlers.ts +7 -2
- package/src/github/pull-request-state.ts +100 -11
- package/src/gitlab/handlers.ts +2 -2
- package/src/heartbeat/heartbeat.ts +6 -1
- package/src/http/api-keys.ts +26 -0
- package/src/http/asset-key-write.ts +45 -0
- package/src/http/assets.ts +4 -3
- package/src/http/github-token.ts +27 -6
- package/src/http/pages.ts +4 -10
- package/src/http/schedules.ts +6 -6
- package/src/http/sessions.ts +7 -2
- package/src/http/tasks.ts +23 -5
- package/src/http/users.ts +5 -0
- package/src/http/webhooks.ts +19 -1
- package/src/http/workflows.ts +5 -10
- package/src/integrations/chat-sdk/commands.ts +3 -1
- package/src/jira/sync.ts +1 -1
- package/src/linear/sync.ts +5 -3
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +5 -0
- package/src/providers/claude-sdk-session.ts +5 -0
- package/src/providers/runtime-dependencies.ts +1 -1
- package/src/scheduler/deferred-task-waits.ts +74 -13
- package/src/scripts-runtime/swarm-sdk.ts +8 -1
- package/src/scripts-runtime/types/stdlib.d.ts +8 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +19 -2
- package/src/scripts-runtime/types/swarm-sdk.d.ts +8 -1
- package/src/slack/actions.ts +1 -1
- package/src/slack/render-v2.ts +148 -7
- package/src/tests/api-drain-worker-e2e.test.ts +0 -2
- package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
- package/src/tests/approval-card-resolution.test.ts +2 -17
- package/src/tests/approval-requests-notifications.test.ts +41 -27
- package/src/tests/approval-requests.test.ts +137 -369
- package/src/tests/apps-sync-engine.test.ts +5 -3
- package/src/tests/apps-table-filters-migration.test.ts +44 -25
- package/src/tests/bitbucket-handlers.test.ts +2 -0
- package/src/tests/chat-sdk-commands.test.ts +1 -0
- package/src/tests/claude-adapter.test.ts +35 -0
- package/src/tests/codex-adapter.test.ts +3 -92
- package/src/tests/codex-gpt6-release.test.ts +0 -9
- package/src/tests/codex-oauth-credential-info.test.ts +35 -18
- package/src/tests/codex-oauth.test.ts +0 -6
- package/src/tests/codex-pool.test.ts +5 -214
- package/src/tests/codex-rate-limit-parse.test.ts +0 -7
- package/src/tests/codex-swarm-events.test.ts +11 -54
- package/src/tests/db-client-busy-retry.test.ts +49 -16
- package/src/tests/defer-task.test.ts +1 -0
- package/src/tests/e2e-shards.test.ts +9 -9
- package/src/tests/enabled-tools.test.ts +0 -2
- package/src/tests/fixtures/base-prompt-baseline.json +6 -6
- package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
- package/src/tests/gitlab-handlers.test.ts +2 -0
- package/src/tests/heartbeat-jev-gate.test.ts +9 -241
- package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
- package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
- package/src/tests/heartbeat.test.ts +1 -0
- package/src/tests/key-usage-selection.test.ts +302 -0
- package/src/tests/memory-e2e.test.ts +34 -103
- package/src/tests/memory-key-paths.test.ts +5 -0
- package/src/tests/memory-rater-llm.test.ts +33 -149
- package/src/tests/memory-store.test.ts +24 -125
- package/src/tests/memory.test.ts +31 -100
- package/src/tests/merge-gate-detect-changes.test.ts +108 -2
- package/src/tests/otel-service-name.test.ts +0 -9
- package/src/tests/otel-session-cost-metrics.test.ts +1 -38
- package/src/tests/pool-session-logs.test.ts +8 -42
- package/src/tests/pre-push-affected-tests.test.ts +106 -0
- package/src/tests/prompt-template-session.test.ts +3 -0
- package/src/tests/runner-api-drain.test.ts +2 -17
- package/src/tests/runner-terminal-window-report.test.ts +132 -0
- package/src/tests/runtime-supervisor-failures.test.ts +1 -0
- package/src/tests/sandboxed-process.test.ts +26 -21
- package/src/tests/schedule-http-triage-tools.test.ts +12 -9
- package/src/tests/scheduled-tasks.test.ts +14 -51
- package/src/tests/script-executor-conformance.test.ts +4 -48
- package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
- package/src/tests/script-native-startup.test.ts +21 -25
- package/src/tests/secret-rules.test.ts +4 -2
- package/src/tests/session-logs.test.ts +1 -260
- package/src/tests/slack-render-v2.test.ts +5 -148
- package/src/tests/task-cascade-fail.test.ts +1 -0
- package/src/tests/task-supersede-resume.test.ts +1 -0
- package/src/tests/test-proc.ts +5 -2
- package/src/tests/window-stream-reporter.test.ts +122 -0
- package/src/tests/workflow-agent-task-retry.test.ts +1 -3
- package/src/tests/workflow-cascade-cancel.test.ts +1 -0
- package/src/tests/workflow-retry-v2.test.ts +34 -43
- package/src/tests/workflow-retry-validation.test.ts +8 -48
- package/src/tests/worktree-reaper.test.ts +2 -2
- package/src/tools/cancel-task.ts +2 -2
- package/src/tools/defer-task.ts +7 -2
- package/src/tools/get-task-details.ts +8 -4
- package/src/tools/get-tasks.ts +13 -2
- package/src/tools/manage-user.ts +9 -0
- package/src/tools/store-progress.ts +5 -3
- package/src/types.ts +93 -0
- package/src/utils/constants.ts +12 -0
- package/src/utils/credentials.ts +42 -5
- package/src/utils/error-tracker.ts +6 -0
- package/src/utils/key-usage.ts +114 -0
- package/src/utils/sandboxed-process.ts +1 -0
- package/src/workflows/resume.ts +5 -2
- package/templates/skills/apps/SKILL.md +2 -0
- package/templates/skills/apps/content.md +2 -0
- package/templates/skills/boards-and-sheets/content.md +4 -2
- package/templates/skills/pages/content.md +7 -0
- package/templates/skills/swarm-docs/content.md +1 -0
- package/templates/skills/swarm-scripts/SKILL.md +1 -0
- package/templates/skills/swarm-scripts/content.md +1 -0
- package/dist/acp-adapter-mr4temec.js +0 -17
- package/dist/fx-adapter-4sjrbdne.js +0 -20
- package/dist/handlers-ef3k11hb.js +0 -41
- package/dist/index-e6bq0exk.js +0 -42
- package/dist/index-hf2k1vge.js +0 -39
- package/dist/index-taxmejj3.js +0 -44
- package/dist/lead-5vt6f174.js +0 -83
- package/dist/thread-buffer-686pa1p1.js +0 -42
- package/dist/worker-4vp616ms.js +0 -83
- package/src/tests/apps-table-selection-migration.test.ts +0 -95
- package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
- package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { githubApiUrl } from "../utils/github-host";
|
|
2
2
|
import { getWorkerInstallationToken } from "./app";
|
|
3
3
|
|
|
4
|
-
export type PullRequestState = {
|
|
4
|
+
export type PullRequestState = {
|
|
5
|
+
merged: boolean;
|
|
6
|
+
state: "open" | "closed";
|
|
7
|
+
headSha: string;
|
|
8
|
+
baseRef: string;
|
|
9
|
+
};
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
* an agent confirm here first. Sends the App installation token when one is
|
|
12
|
+
* GET one GitHub REST path. Sends the App installation token when one is
|
|
9
13
|
* configured, otherwise reads unauthenticated (enough for a public repo).
|
|
10
14
|
* Throws on any non-2xx so a failed read never counts as an answer.
|
|
11
15
|
*/
|
|
12
|
-
|
|
13
|
-
repo: string,
|
|
14
|
-
number: number,
|
|
15
|
-
): Promise<PullRequestState> {
|
|
16
|
+
async function githubGet<T>(path: string, what: string): Promise<T> {
|
|
16
17
|
const auth = await getWorkerInstallationToken();
|
|
17
|
-
const response = await fetch(githubApiUrl(
|
|
18
|
+
const response = await fetch(githubApiUrl(path), {
|
|
18
19
|
headers: {
|
|
19
20
|
Accept: "application/vnd.github+json",
|
|
20
21
|
"X-GitHub-Api-Version": "2022-11-28",
|
|
@@ -22,13 +23,101 @@ export async function fetchPullRequestState(
|
|
|
22
23
|
},
|
|
23
24
|
signal: AbortSignal.timeout(10_000),
|
|
24
25
|
});
|
|
25
|
-
if (!response.ok) throw new Error(`GitHub returned ${response.status} for ${
|
|
26
|
-
|
|
26
|
+
if (!response.ok) throw new Error(`GitHub returned ${response.status} for ${what}`);
|
|
27
|
+
return (await response.json()) as T;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Read one PR from GitHub. A webhook only names a candidate; callers that wake an agent confirm here first. */
|
|
31
|
+
export async function fetchPullRequestState(
|
|
32
|
+
repo: string,
|
|
33
|
+
number: number,
|
|
34
|
+
): Promise<PullRequestState> {
|
|
35
|
+
const pr = await githubGet<{
|
|
27
36
|
merged?: boolean;
|
|
28
37
|
state?: string;
|
|
29
|
-
|
|
38
|
+
head?: { sha?: string };
|
|
39
|
+
base?: { ref?: string };
|
|
40
|
+
}>(`/repos/${repo}/pulls/${number}`, `${repo}#${number}`);
|
|
30
41
|
return {
|
|
31
42
|
merged: pr.merged === true,
|
|
32
43
|
state: pr.state === "open" ? "open" : "closed",
|
|
44
|
+
headSha: pr.head?.sha ?? "",
|
|
45
|
+
baseRef: pr.base?.ref ?? "",
|
|
33
46
|
};
|
|
34
47
|
}
|
|
48
|
+
|
|
49
|
+
export type RequiredCheckState = {
|
|
50
|
+
name: string;
|
|
51
|
+
/** False while the check is queued, running, or has not reported on the SHA yet. */
|
|
52
|
+
complete: boolean;
|
|
53
|
+
conclusion: string | null;
|
|
54
|
+
completedAt: string | null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The required status checks the base branch's rulesets name, each read on `sha`.
|
|
59
|
+
* A check counts as complete on any conclusion; a required check that has not
|
|
60
|
+
* reported yet is incomplete. Throws when the branch has no required checks:
|
|
61
|
+
* "all required checks are done" would then be vacuously true.
|
|
62
|
+
*/
|
|
63
|
+
export async function fetchRequiredCheckStates(
|
|
64
|
+
repo: string,
|
|
65
|
+
baseRef: string,
|
|
66
|
+
sha: string,
|
|
67
|
+
): Promise<RequiredCheckState[]> {
|
|
68
|
+
const rules = await githubGet<
|
|
69
|
+
Array<{
|
|
70
|
+
type?: string;
|
|
71
|
+
parameters?: { required_status_checks?: Array<{ context: string; integration_id?: number }> };
|
|
72
|
+
}>
|
|
73
|
+
>(`/repos/${repo}/rules/branches/${encodeURIComponent(baseRef)}`, `${repo} rules on ${baseRef}`);
|
|
74
|
+
const required = new Map<string, number | undefined>();
|
|
75
|
+
for (const rule of rules) {
|
|
76
|
+
if (rule.type !== "required_status_checks") continue;
|
|
77
|
+
for (const check of rule.parameters?.required_status_checks ?? [])
|
|
78
|
+
required.set(check.context, check.integration_id);
|
|
79
|
+
}
|
|
80
|
+
if (!required.size) throw new Error(`${repo} has no required status checks on ${baseRef}`);
|
|
81
|
+
|
|
82
|
+
let statuses: Array<{ context: string; state: string; updated_at: string }> | undefined;
|
|
83
|
+
const states: RequiredCheckState[] = [];
|
|
84
|
+
for (const [name, appId] of required) {
|
|
85
|
+
const runs = await githubGet<{
|
|
86
|
+
check_runs?: Array<{
|
|
87
|
+
status?: string;
|
|
88
|
+
conclusion?: string | null;
|
|
89
|
+
completed_at?: string | null;
|
|
90
|
+
app?: { id?: number };
|
|
91
|
+
}>;
|
|
92
|
+
}>(
|
|
93
|
+
`/repos/${repo}/commits/${sha}/check-runs?check_name=${encodeURIComponent(name)}&filter=latest&per_page=100`,
|
|
94
|
+
`${repo} check runs on ${sha}`,
|
|
95
|
+
);
|
|
96
|
+
const run = (runs.check_runs ?? []).find((r) => appId === undefined || r.app?.id === appId);
|
|
97
|
+
if (run) {
|
|
98
|
+
states.push({
|
|
99
|
+
name,
|
|
100
|
+
complete: run.status === "completed",
|
|
101
|
+
conclusion: run.conclusion ?? null,
|
|
102
|
+
completedAt: run.completed_at ?? null,
|
|
103
|
+
});
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// A required check can also be a commit status (context), not a check run.
|
|
107
|
+
statuses ??=
|
|
108
|
+
(
|
|
109
|
+
await githubGet<{
|
|
110
|
+
statuses?: Array<{ context: string; state: string; updated_at: string }>;
|
|
111
|
+
}>(`/repos/${repo}/commits/${sha}/status?per_page=100`, `${repo} statuses on ${sha}`)
|
|
112
|
+
).statuses ?? [];
|
|
113
|
+
const status = statuses.find((s) => s.context === name);
|
|
114
|
+
const complete = status !== undefined && status.state !== "pending";
|
|
115
|
+
states.push({
|
|
116
|
+
name,
|
|
117
|
+
complete,
|
|
118
|
+
conclusion: complete ? status.state : null,
|
|
119
|
+
completedAt: complete ? status.updated_at : null,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return states;
|
|
123
|
+
}
|
package/src/gitlab/handlers.ts
CHANGED
|
@@ -256,7 +256,7 @@ export async function handleMergeRequest(
|
|
|
256
256
|
const tasks = await findActiveTasksByVcs(repo, mr.iid, "gitlab");
|
|
257
257
|
for (const task of tasks.filter((t) => isScopedTask(t, "mr", mrContextKey))) {
|
|
258
258
|
console.log(`[GitLab] Cancelling task ${task.id} — ${reason}`);
|
|
259
|
-
await failTask(task.id, reason);
|
|
259
|
+
await failTask(task.id, reason, { statusKind: "external" });
|
|
260
260
|
}
|
|
261
261
|
return { created: false };
|
|
262
262
|
}
|
|
@@ -374,7 +374,7 @@ export async function handleIssue(
|
|
|
374
374
|
);
|
|
375
375
|
if (existingTask) {
|
|
376
376
|
console.log(`[GitLab] Cancelling task ${existingTask.id} — issue closed`);
|
|
377
|
-
await failTask(existingTask.id, "Issue was closed");
|
|
377
|
+
await failTask(existingTask.id, "Issue was closed", { statusKind: "external" });
|
|
378
378
|
}
|
|
379
379
|
return { created: false };
|
|
380
380
|
}
|
|
@@ -812,6 +812,7 @@ async function remediateCrashedWorkerTask(
|
|
|
812
812
|
// CAS on the lastUpdatedAt this sweep read: progress since then wins.
|
|
813
813
|
const failed = await failTask(task.id, decision.reason, {
|
|
814
814
|
expectedLastUpdatedAt: task.lastUpdatedAt,
|
|
815
|
+
statusKind: "error",
|
|
815
816
|
});
|
|
816
817
|
if (failed) {
|
|
817
818
|
await opts.onRemediated?.();
|
|
@@ -834,6 +835,7 @@ async function remediateCrashedWorkerTask(
|
|
|
834
835
|
|
|
835
836
|
const superseded = await supersedeTask(task.id, {
|
|
836
837
|
reason: decision.reason,
|
|
838
|
+
statusKind: "crash_recovery",
|
|
837
839
|
resumeTaskId: null,
|
|
838
840
|
// CAS on the lastUpdatedAt this sweep read: progress since then wins.
|
|
839
841
|
expectedLastUpdatedAt: task.lastUpdatedAt,
|
|
@@ -1010,7 +1012,10 @@ export async function runRebootSweep(): Promise<void> {
|
|
|
1010
1012
|
// Auto-fail the task. Its dependents are settled in the `finally` below
|
|
1011
1013
|
// (re-pointed to the retry child, or cascade-failed when there is none)
|
|
1012
1014
|
// instead of by failTask's unconditional cascade.
|
|
1013
|
-
const failed = await failTask(task.id, reason, {
|
|
1015
|
+
const failed = await failTask(task.id, reason, {
|
|
1016
|
+
cascadeDependents: false,
|
|
1017
|
+
statusKind: "error",
|
|
1018
|
+
});
|
|
1014
1019
|
if (!failed) continue;
|
|
1015
1020
|
|
|
1016
1021
|
let retryTaskId: string | null = null;
|
package/src/http/api-keys.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
MAX_SPEND_CAP_HOLD_MS,
|
|
26
26
|
type RateLimitWindowTelemetry,
|
|
27
27
|
} from "../utils/error-tracker";
|
|
28
|
+
import { CREDENTIAL_SELECTION_STRATEGIES, credentialSelectionStrategy } from "../utils/key-usage";
|
|
28
29
|
import {
|
|
29
30
|
activeModelBlocks,
|
|
30
31
|
isModelScopedWindow,
|
|
@@ -422,6 +423,27 @@ const getAvailable = route({
|
|
|
422
423
|
* `authFence` on `clear-rate-limit`: failures recorded after it survive the clear.
|
|
423
424
|
*/
|
|
424
425
|
authFailureFence: z.number().int(),
|
|
426
|
+
/**
|
|
427
|
+
* Usage per pool position: max utilization (fraction, can exceed 1) of the key's
|
|
428
|
+
* live `five_hour` and `seven_day` windows; 0 when unobserved or reset. Under the
|
|
429
|
+
* `usage` strategy the worker picks the lowest among `availableIndices`.
|
|
430
|
+
*/
|
|
431
|
+
keyUsage: z.array(z.number()),
|
|
432
|
+
/**
|
|
433
|
+
* Pace delta per pool position: used minus the elapsed share of the window, the max
|
|
434
|
+
* over the live `five_hour`, `seven_day` and (with `model`) that family's weekly
|
|
435
|
+
* window; 0 when none is live. Under the `pace` strategy the worker picks the lowest
|
|
436
|
+
* (most under even use) among `availableIndices`. It never excludes a key.
|
|
437
|
+
*/
|
|
438
|
+
keyPace: z.array(z.number()),
|
|
439
|
+
/** How the worker ranks keys: `CREDENTIAL_SELECTION_STRATEGY` (default `usage`). */
|
|
440
|
+
selectionStrategy: z.enum(CREDENTIAL_SELECTION_STRATEGIES),
|
|
441
|
+
/**
|
|
442
|
+
* Running sessions per pool position: `in_progress` tasks whose credential is this
|
|
443
|
+
* key type and the position's key suffix. The worker picks the fewest among the
|
|
444
|
+
* keys within 0.10 of the lowest ranking score. It never excludes a key.
|
|
445
|
+
*/
|
|
446
|
+
activeSessions: z.array(z.number().int().min(0)),
|
|
425
447
|
}),
|
|
426
448
|
},
|
|
427
449
|
400: { description: "Validation error" },
|
|
@@ -912,6 +934,10 @@ export async function handleApiKeys(
|
|
|
912
934
|
spendCappedIndices: result.spendCappedIndices,
|
|
913
935
|
totalKeys,
|
|
914
936
|
authFailureFence: result.authFailureFence,
|
|
937
|
+
keyUsage: result.keyUsage,
|
|
938
|
+
keyPace: result.keyPace,
|
|
939
|
+
selectionStrategy: credentialSelectionStrategy(process.env.CREDENTIAL_SELECTION_STRATEGY),
|
|
940
|
+
activeSessions: result.activeSessions,
|
|
915
941
|
...(model !== undefined
|
|
916
942
|
? {
|
|
917
943
|
modelBlockedIndices: result.modelBlockedIndices,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { IncomingMessage } from "node:http";
|
|
2
|
+
import { authorizeAssetKeyWrite } from "../be/asset-key-auth";
|
|
3
|
+
import { resolveHttpRequesterUserId } from "../be/audit-user";
|
|
4
|
+
import { findUserById } from "../be/users";
|
|
5
|
+
import { getRequestAuth, isOperatorAuth } from "../utils/request-auth-context";
|
|
6
|
+
import { dashboardUserIdHeader } from "./favorite-owner";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The active user an operator-key dashboard request names in `X-Swarm-User-Id`.
|
|
10
|
+
* The operator key is fully trusted, so the header needs no further proof (same
|
|
11
|
+
* rule as favorites and session access). Agents, page sessions, user tokens and
|
|
12
|
+
* unauthenticated callers never pick a user.
|
|
13
|
+
*/
|
|
14
|
+
export async function resolveDashboardUserId(
|
|
15
|
+
req: IncomingMessage,
|
|
16
|
+
callerAgentId: string | undefined,
|
|
17
|
+
): Promise<string | null> {
|
|
18
|
+
const auth = getRequestAuth(req);
|
|
19
|
+
if (!isOperatorAuth(auth) || auth.page || callerAgentId || req.headers["x-agent-id"]) return null;
|
|
20
|
+
const picked = dashboardUserIdHeader(req);
|
|
21
|
+
const user = picked ? await findUserById(picked) : null;
|
|
22
|
+
return user?.status === "active" ? user.id : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* {@link authorizeAssetKeyWrite} for an HTTP request. The trusted user is the
|
|
27
|
+
* request's requester (pass `trustedUserId` when already resolved), else the
|
|
28
|
+
* dashboard's picked user, so an operator-key dashboard can write to its own
|
|
29
|
+
* user's `personal/<user>/` keys and no one else's.
|
|
30
|
+
*/
|
|
31
|
+
export async function authorizeHttpAssetKeyWrite(
|
|
32
|
+
req: IncomingMessage,
|
|
33
|
+
callerAgentId: string | undefined,
|
|
34
|
+
key: string,
|
|
35
|
+
trustedUserId?: string | null,
|
|
36
|
+
): Promise<string> {
|
|
37
|
+
const requester =
|
|
38
|
+
trustedUserId === undefined
|
|
39
|
+
? await resolveHttpRequesterUserId(req, callerAgentId)
|
|
40
|
+
: trustedUserId;
|
|
41
|
+
return authorizeAssetKeyWrite(
|
|
42
|
+
key,
|
|
43
|
+
requester ?? (await resolveDashboardUserId(req, callerAgentId)),
|
|
44
|
+
);
|
|
45
|
+
}
|
package/src/http/assets.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { getApp } from "../apps/store";
|
|
|
4
4
|
import { normalizeAssetKey } from "../assets/key";
|
|
5
5
|
import { sourceMoveError, sourceOfKey } from "../assets/source-key";
|
|
6
6
|
import { auditAssetKeys } from "../be/asset-key-audit";
|
|
7
|
-
import { AssetKeyAuthorizationError
|
|
7
|
+
import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
|
|
8
8
|
import { resolveHttpRequesterUserId } from "../be/audit-user";
|
|
9
9
|
import {
|
|
10
10
|
AssetKeyMovesBlockedError,
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
AssetKeySchema,
|
|
27
27
|
AssetSummarySchema,
|
|
28
28
|
} from "../types";
|
|
29
|
+
import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
|
|
29
30
|
import { requestPrincipal, requireAuthKind } from "./request-principal";
|
|
30
31
|
import { route } from "./route-def";
|
|
31
32
|
import { canReadSession, hasSessionWrite, SESSION_READ_DENIED } from "./session-access";
|
|
@@ -283,7 +284,7 @@ export async function handleAssets(
|
|
|
283
284
|
try {
|
|
284
285
|
const actor = await resolveHttpRequesterUserId(req, myAgentId);
|
|
285
286
|
const key = parsed.body.key
|
|
286
|
-
? await
|
|
287
|
+
? await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key, actor)
|
|
287
288
|
: undefined;
|
|
288
289
|
const mapping = await upsertAssetKeyMapping({
|
|
289
290
|
providerId: parsed.body.providerId,
|
|
@@ -382,7 +383,7 @@ export async function handleAssets(
|
|
|
382
383
|
|
|
383
384
|
try {
|
|
384
385
|
const actor = await resolveHttpRequesterUserId(req, myAgentId);
|
|
385
|
-
const key = await
|
|
386
|
+
const key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key, actor);
|
|
386
387
|
const moved = await moveAssetKey({
|
|
387
388
|
entityType: parsed.params.entityType,
|
|
388
389
|
id: parsed.params.id,
|
package/src/http/github-token.ts
CHANGED
|
@@ -12,22 +12,39 @@ const installationTokenRoute = route({
|
|
|
12
12
|
pattern: ["api", "github", "installation-token"],
|
|
13
13
|
summary: "Mint a GitHub App installation token for worker git and gh",
|
|
14
14
|
description:
|
|
15
|
-
"Internal worker endpoint. Returns a short-lived installation token for
|
|
15
|
+
"Internal worker endpoint. Returns a short-lived installation token for worker `git` and `gh`. With a `repo` (`owner/name`) whose owner is listed in the deployment env `GITHUB_APP_REPO_OWNERS`, the API resolves that repository's App installation with the App JWT and mints for it; the repository must also be registered in `swarm_repos` on the configured GitHub host (403 otherwise). Any other call mints for the installation in `GITHUB_APP_INSTALLATION_ID`, so single-installation deployments are unchanged and a caller never picks an installation the operator did not list. Only a registered agent (swarm API key plus X-Agent-ID, or an agent or runtime token) may call it; user, guest and ACP task tokens are refused. 404 when the App is not configured, so workers fall back to `GITHUB_TOKEN`.",
|
|
16
16
|
tags: ["GitHub"],
|
|
17
|
-
body: z
|
|
17
|
+
body: z
|
|
18
|
+
.object({
|
|
19
|
+
repo: z
|
|
20
|
+
.string()
|
|
21
|
+
.max(200)
|
|
22
|
+
.regex(
|
|
23
|
+
/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,
|
|
24
|
+
"repo must be `owner/name` (letters, digits, dot, dash, underscore)",
|
|
25
|
+
)
|
|
26
|
+
.optional(),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
18
29
|
responses: {
|
|
19
30
|
200: {
|
|
20
31
|
description: "Installation token and its expiry (ISO 8601)",
|
|
21
32
|
schema: z.object({ token: z.string(), expiresAt: z.string() }),
|
|
22
33
|
},
|
|
23
|
-
403: {
|
|
34
|
+
403: {
|
|
35
|
+
description:
|
|
36
|
+
"Caller is not a registered agent, or the repo of a listed owner is not registered in the swarm",
|
|
37
|
+
},
|
|
24
38
|
404: { description: "GitHub App worker auth is not configured" },
|
|
25
|
-
502: {
|
|
39
|
+
502: {
|
|
40
|
+
description:
|
|
41
|
+
"GitHub refused or failed to mint the token, or the repo has no App installation",
|
|
42
|
+
},
|
|
26
43
|
},
|
|
27
44
|
auth: { apiKey: true, agentId: true },
|
|
28
45
|
rbac: {
|
|
29
46
|
ungated:
|
|
30
|
-
"the handler admits only registered agent principals and mints for
|
|
47
|
+
"the handler admits only registered agent principals and mints only for the fixed installation or the installation of a registered repo whose owner the deployment env lists",
|
|
31
48
|
},
|
|
32
49
|
});
|
|
33
50
|
|
|
@@ -51,11 +68,15 @@ export async function handleGitHubToken(
|
|
|
51
68
|
jsonError(res, "Only a registered agent may mint a GitHub installation token", 403);
|
|
52
69
|
return true;
|
|
53
70
|
}
|
|
54
|
-
const result = await getWorkerInstallationToken();
|
|
71
|
+
const result = await getWorkerInstallationToken(parsed.body?.repo);
|
|
55
72
|
if (result.status === "unconfigured") {
|
|
56
73
|
jsonError(res, "GitHub App worker auth is not configured", 404);
|
|
57
74
|
return true;
|
|
58
75
|
}
|
|
76
|
+
if (result.status === "forbidden") {
|
|
77
|
+
jsonError(res, "The repo is not registered in the swarm", 403);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
59
80
|
if (result.status === "error") {
|
|
60
81
|
jsonError(res, "GitHub did not mint an installation token", 502);
|
|
61
82
|
return true;
|
package/src/http/pages.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { AssetKeyAuthorizationError
|
|
5
|
-
import { resolveHttpRequesterUserId } from "../be/audit-user";
|
|
4
|
+
import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
|
|
6
5
|
import {
|
|
7
6
|
countAllPages,
|
|
8
7
|
countPagesByAgent,
|
|
@@ -22,6 +21,7 @@ import {
|
|
|
22
21
|
import { getPageEditCounter } from "../be/db/page-versions";
|
|
23
22
|
import { snapshotPage } from "../pages/version";
|
|
24
23
|
import { resolveTemplate } from "../prompts/resolver";
|
|
24
|
+
import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
|
|
25
25
|
// Side-effect import: registers `task.page.feedback`.
|
|
26
26
|
import "../prompts/session-templates";
|
|
27
27
|
import { can } from "../rbac";
|
|
@@ -633,10 +633,7 @@ export async function handlePages(
|
|
|
633
633
|
|
|
634
634
|
try {
|
|
635
635
|
const key = parsed.body.key
|
|
636
|
-
? await
|
|
637
|
-
parsed.body.key,
|
|
638
|
-
await resolveHttpRequesterUserId(req, myAgentId),
|
|
639
|
-
)
|
|
636
|
+
? await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key)
|
|
640
637
|
: undefined;
|
|
641
638
|
const page = await createPage({
|
|
642
639
|
key,
|
|
@@ -880,10 +877,7 @@ export async function handlePages(
|
|
|
880
877
|
let key: string | undefined;
|
|
881
878
|
if (parsed.body.key !== undefined) {
|
|
882
879
|
try {
|
|
883
|
-
key = await
|
|
884
|
-
parsed.body.key,
|
|
885
|
-
await resolveHttpRequesterUserId(req, myAgentId),
|
|
886
|
-
);
|
|
880
|
+
key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
|
|
887
881
|
} catch (error) {
|
|
888
882
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
889
883
|
jsonError(res, error.message, error.statusCode);
|
package/src/http/schedules.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { CronExpressionParser } from "cron-parser";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { AssetKeyAuthorizationError
|
|
4
|
+
import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
|
|
5
5
|
import { resolveHttpAuditUserId, resolveHttpRequesterUserId } from "../be/audit-user";
|
|
6
6
|
import {
|
|
7
7
|
createScheduledTask,
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
ScheduledTaskTargetTypeSchema,
|
|
40
40
|
splitLegacyModelAlias,
|
|
41
41
|
} from "../types";
|
|
42
|
+
import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
|
|
42
43
|
import { resolveHttpFavoriteOwner } from "./favorite-owner";
|
|
43
44
|
import { agentFirstPrincipal } from "./request-principal";
|
|
44
45
|
import { route } from "./route-def";
|
|
@@ -439,7 +440,9 @@ export async function handleSchedules(
|
|
|
439
440
|
const trustedUserId = await resolveHttpRequesterUserId(req, myAgentId);
|
|
440
441
|
let key: string | undefined;
|
|
441
442
|
try {
|
|
442
|
-
key = body.key
|
|
443
|
+
key = body.key
|
|
444
|
+
? await authorizeHttpAssetKeyWrite(req, myAgentId, body.key, trustedUserId)
|
|
445
|
+
: undefined;
|
|
443
446
|
} catch (error) {
|
|
444
447
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
445
448
|
jsonError(res, error.message, error.statusCode);
|
|
@@ -577,10 +580,7 @@ export async function handleSchedules(
|
|
|
577
580
|
const body = parsed.body as Record<string, unknown>;
|
|
578
581
|
if (parsed.body.key !== undefined) {
|
|
579
582
|
try {
|
|
580
|
-
body.key = await
|
|
581
|
-
parsed.body.key,
|
|
582
|
-
await resolveHttpRequesterUserId(req, myAgentId),
|
|
583
|
-
);
|
|
583
|
+
body.key = await authorizeHttpAssetKeyWrite(req, myAgentId, parsed.body.key);
|
|
584
584
|
} catch (error) {
|
|
585
585
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
586
586
|
jsonError(res, error.message, error.statusCode);
|
package/src/http/sessions.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
RESOURCE_GROUPS_READ_ONLY,
|
|
10
10
|
} from "../assets/key";
|
|
11
11
|
import { SOURCE_GROUPS_READ_ONLY, sourceMoveError, sourceOfKey } from "../assets/source-key";
|
|
12
|
-
import { AssetKeyAuthorizationError
|
|
12
|
+
import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
|
|
13
13
|
import { resolveHttpRequesterUserId } from "../be/audit-user";
|
|
14
14
|
import {
|
|
15
15
|
AgentDeletedError,
|
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
} from "../types";
|
|
83
83
|
import { getRequestAuth } from "../utils/request-auth-context";
|
|
84
84
|
import { isRuntimePoolsEnabled } from "../utils/runtime-pools-flag";
|
|
85
|
+
import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
|
|
85
86
|
import { canMutateTaskNamespace } from "./assets";
|
|
86
87
|
import { resolveHttpFavoriteOwner } from "./favorite-owner";
|
|
87
88
|
import { createListTotalCache } from "./list-total-cache";
|
|
@@ -133,6 +134,7 @@ const AgentTaskSummarySchema = AgentTaskSchema.pick({
|
|
|
133
134
|
createdAt: true,
|
|
134
135
|
lastUpdatedAt: true,
|
|
135
136
|
finishedAt: true,
|
|
137
|
+
statusKind: true,
|
|
136
138
|
peakContextPercent: true,
|
|
137
139
|
totalCostUsd: true,
|
|
138
140
|
});
|
|
@@ -772,7 +774,10 @@ async function withSessionMove(
|
|
|
772
774
|
try {
|
|
773
775
|
const changedBy = await resolveHttpRequesterUserId(req, myAgentId);
|
|
774
776
|
const actor = await resolveSessionActor(req, myAgentId);
|
|
775
|
-
const key =
|
|
777
|
+
const key =
|
|
778
|
+
destination === null
|
|
779
|
+
? null
|
|
780
|
+
: await authorizeHttpAssetKeyWrite(req, myAgentId, destination, changedBy);
|
|
776
781
|
await assertAssetKeyMovesAllowed();
|
|
777
782
|
await run({ actor, changedBy: changedBy ?? undefined, key });
|
|
778
783
|
} catch (error) {
|
package/src/http/tasks.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { AssetKeyAuthorizationError
|
|
3
|
+
import { AssetKeyAuthorizationError } from "../be/asset-key-auth";
|
|
4
4
|
import { resolveHttpRequesterUserId } from "../be/audit-user";
|
|
5
5
|
import {
|
|
6
6
|
backfillSupersedeTaskResumeTaskId,
|
|
@@ -97,12 +97,14 @@ import {
|
|
|
97
97
|
SUPERSEDED_WORKFLOW_TASK_REASON,
|
|
98
98
|
splitLegacyModelAlias,
|
|
99
99
|
TaskAttachmentSchema,
|
|
100
|
+
TaskStatusKindSchema,
|
|
100
101
|
} from "../types";
|
|
101
102
|
import { runTaskUiAction } from "../ui-spec/actions";
|
|
102
103
|
import { ensure } from "../utils/business-use";
|
|
103
104
|
import { getRequestAuth } from "../utils/request-auth-context";
|
|
104
105
|
import { scrubSecrets } from "../utils/secret-scrubber";
|
|
105
106
|
import { normalizeVcsRepo, vcsRepoUrlMatches } from "../utils/vcs-repo-match";
|
|
107
|
+
import { authorizeHttpAssetKeyWrite } from "./asset-key-write";
|
|
106
108
|
import { readsRepoSecrets } from "./config";
|
|
107
109
|
import { createListTotalCache, LIST_TOTAL_TTL_MS } from "./list-total-cache";
|
|
108
110
|
import {
|
|
@@ -172,6 +174,7 @@ const AgentTaskSummarySchema = AgentTaskSchema.pick({
|
|
|
172
174
|
createdAt: true,
|
|
173
175
|
lastUpdatedAt: true,
|
|
174
176
|
finishedAt: true,
|
|
177
|
+
statusKind: true,
|
|
175
178
|
peakContextPercent: true,
|
|
176
179
|
totalCostUsd: true,
|
|
177
180
|
});
|
|
@@ -270,6 +273,9 @@ const listTasks = route({
|
|
|
270
273
|
query: z.object({
|
|
271
274
|
/** Single status, or comma-separated list (e.g. "failed,cancelled"). */
|
|
272
275
|
status: z.string().optional(),
|
|
276
|
+
statusKind: TaskStatusKindSchema.optional().describe(
|
|
277
|
+
"Why the task ended, e.g. `status=failed&statusKind=error` (crash, rate limit, exit code) vs `statusKind=agent` (the agent chose to fail). Valid kinds per status: TASK_STATUS_KINDS in src/types.ts.",
|
|
278
|
+
),
|
|
273
279
|
agentId: z.string().optional(),
|
|
274
280
|
scheduleId: z.string().optional(),
|
|
275
281
|
/** Only tasks of this workflow run (indexed; independent of fleet size). */
|
|
@@ -1095,6 +1101,7 @@ export async function handleTasks(
|
|
|
1095
1101
|
});
|
|
1096
1102
|
const filters = {
|
|
1097
1103
|
status,
|
|
1104
|
+
statusKind: parsed.query.statusKind,
|
|
1098
1105
|
agentId: parsed.query.agentId || undefined,
|
|
1099
1106
|
scheduleId: parsed.query.scheduleId || undefined,
|
|
1100
1107
|
workflowRunId: parsed.query.workflowRunId,
|
|
@@ -1240,7 +1247,7 @@ export async function handleTasks(
|
|
|
1240
1247
|
const inheritedKey = parentTask?.key;
|
|
1241
1248
|
const requestedKey = parsed.body.key ?? inheritedKey;
|
|
1242
1249
|
assetKey = requestedKey
|
|
1243
|
-
? await
|
|
1250
|
+
? await authorizeHttpAssetKeyWrite(req, myAgentId, requestedKey, trustedUserId)
|
|
1244
1251
|
: undefined;
|
|
1245
1252
|
} catch (error) {
|
|
1246
1253
|
if (error instanceof AssetKeyAuthorizationError) {
|
|
@@ -1466,7 +1473,12 @@ export async function handleTasks(
|
|
|
1466
1473
|
}
|
|
1467
1474
|
}
|
|
1468
1475
|
|
|
1469
|
-
|
|
1476
|
+
// Who cancelled comes from the resolved principal, never the body: an agent
|
|
1477
|
+
// (X-Agent-ID, including ctx.swarm.task_cancel) records `agent`, as MCP
|
|
1478
|
+
// cancel-task does; the dashboard and operator record `user`.
|
|
1479
|
+
const cancelledTask = await cancelTask(parsed.params.id, reason, {
|
|
1480
|
+
statusKind: principal.kind === "agent" ? "agent" : "user",
|
|
1481
|
+
});
|
|
1470
1482
|
if (!cancelledTask) {
|
|
1471
1483
|
jsonError(res, "Failed to cancel task", 500);
|
|
1472
1484
|
return true;
|
|
@@ -1957,21 +1969,25 @@ export async function handleTasks(
|
|
|
1957
1969
|
const result = await completeTask(
|
|
1958
1970
|
parsed.params.id,
|
|
1959
1971
|
parsed.body.output || "Completed by runner wrapper (no explicit output)",
|
|
1972
|
+
{ statusKind: "runner" },
|
|
1960
1973
|
);
|
|
1961
1974
|
if (!result) {
|
|
1962
1975
|
return { error: "Failed to complete task", status: 500 };
|
|
1963
1976
|
}
|
|
1964
1977
|
updatedTask = result;
|
|
1965
1978
|
} else if (parsed.body.status === "skipped") {
|
|
1966
|
-
const result = await skipTask(parsed.params.id, skipReason
|
|
1979
|
+
const result = await skipTask(parsed.params.id, skipReason!, { statusKind: "runner" });
|
|
1967
1980
|
if (!result) {
|
|
1968
1981
|
return { error: "Failed to mark task as skipped", status: 500 };
|
|
1969
1982
|
}
|
|
1970
1983
|
updatedTask = result;
|
|
1971
1984
|
} else {
|
|
1985
|
+
// The runner posts `failed` for a crash, a non-zero exit, a provider
|
|
1986
|
+
// error or an output-schema parse failure: none is the agent's call.
|
|
1972
1987
|
const result = await failTask(
|
|
1973
1988
|
parsed.params.id,
|
|
1974
1989
|
parsed.body.failureReason || "Process exited without explicit completion",
|
|
1990
|
+
{ statusKind: "error" },
|
|
1975
1991
|
);
|
|
1976
1992
|
if (!result) {
|
|
1977
1993
|
return { error: "Failed to mark task as failed", status: 500 };
|
|
@@ -2402,7 +2418,9 @@ export async function handleTasks(
|
|
|
2402
2418
|
// `task.failed`. Once it queues the step's retry it moves the task to
|
|
2403
2419
|
// `superseded` itself (`scheduleTaskStepRetry`).
|
|
2404
2420
|
if (task.workflowRunStepId != null) {
|
|
2405
|
-
const failed = await failTask(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON
|
|
2421
|
+
const failed = await failTask(parsed.params.id, SUPERSEDED_WORKFLOW_TASK_REASON, {
|
|
2422
|
+
statusKind: "error",
|
|
2423
|
+
});
|
|
2406
2424
|
if (task.agentId) {
|
|
2407
2425
|
await updateAgentStatusFromCapacity(task.agentId);
|
|
2408
2426
|
}
|
package/src/http/users.ts
CHANGED
|
@@ -94,6 +94,7 @@ import {
|
|
|
94
94
|
} from "../be/users";
|
|
95
95
|
import { isRbacEnabled } from "../rbac";
|
|
96
96
|
import {
|
|
97
|
+
UserAvatarSchema,
|
|
97
98
|
UserCommsPrefsSchema,
|
|
98
99
|
UserMergeJobSchema,
|
|
99
100
|
UserMergeJobStatusSchema,
|
|
@@ -285,6 +286,7 @@ const createUserRoute = route({
|
|
|
285
286
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
286
287
|
dailyBudgetUsd: z.number().nullable().optional(),
|
|
287
288
|
status: z.enum(["invited", "active", "suspended"]).optional(),
|
|
289
|
+
avatar: UserAvatarSchema.nullable().optional(),
|
|
288
290
|
identities: z
|
|
289
291
|
.array(z.object({ kind: z.string().min(1), externalId: z.string().min(1) }))
|
|
290
292
|
.optional(),
|
|
@@ -445,6 +447,8 @@ const updateUserRoute = route({
|
|
|
445
447
|
),
|
|
446
448
|
dailyBudgetUsd: z.number().nullable().optional(),
|
|
447
449
|
status: z.enum(["invited", "active", "suspended"]).optional(),
|
|
450
|
+
// null resets to the initials avatar.
|
|
451
|
+
avatar: UserAvatarSchema.nullable().optional(),
|
|
448
452
|
// Complete-list diff: passing this replaces the user's identity set,
|
|
449
453
|
// emitting `identity_added` / `identity_removed` for each delta.
|
|
450
454
|
identities: z
|
|
@@ -1865,6 +1869,7 @@ export async function handleUsers(
|
|
|
1865
1869
|
"preferredChannel",
|
|
1866
1870
|
"notes",
|
|
1867
1871
|
"metadata",
|
|
1872
|
+
"avatar",
|
|
1868
1873
|
] as const;
|
|
1869
1874
|
for (const field of PROFILE_FIELDS) {
|
|
1870
1875
|
if (parsed.body[field] === undefined) continue;
|