@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
package/src/be/db/tasks/read.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
RoutingReason,
|
|
15
15
|
RoutingSource,
|
|
16
16
|
TaskSlackParticipants,
|
|
17
|
+
TaskStatusKind,
|
|
17
18
|
} from "../../../types";
|
|
18
19
|
import {
|
|
19
20
|
FallbackHopSchema,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
RoutingAffinitySchema,
|
|
24
25
|
SUPERSEDED_WORKFLOW_TASK_REASON,
|
|
25
26
|
TaskSlackParticipantsSchema,
|
|
27
|
+
TaskStatusKindSchema,
|
|
26
28
|
TERMINAL_TASK_STATUSES,
|
|
27
29
|
} from "../../../types";
|
|
28
30
|
import { normalizeOutputSchema } from "../../../utils/output-schema";
|
|
@@ -116,6 +118,7 @@ export type AgentTaskRow = {
|
|
|
116
118
|
finishedAt: string | null;
|
|
117
119
|
notifiedAt: string | null;
|
|
118
120
|
failureReason: string | null;
|
|
121
|
+
statusKind: string | null;
|
|
119
122
|
output: string | null;
|
|
120
123
|
progress: string | null;
|
|
121
124
|
compactionCount: number | null;
|
|
@@ -178,6 +181,7 @@ type AgentTaskSummaryRow = Pick<
|
|
|
178
181
|
| "createdAt"
|
|
179
182
|
| "lastUpdatedAt"
|
|
180
183
|
| "finishedAt"
|
|
184
|
+
| "statusKind"
|
|
181
185
|
| "peakContextPercent"
|
|
182
186
|
| "totalCostUsd"
|
|
183
187
|
>;
|
|
@@ -255,7 +259,7 @@ const LIST_COLUMNS = {
|
|
|
255
259
|
agent_tasks.resolvedEffort, agent_tasks.profile, agent_tasks.resolvedProfile,
|
|
256
260
|
agent_tasks.provider, agent_tasks.requestedByUserId, agent_tasks.progress,
|
|
257
261
|
agent_tasks.createdAt, agent_tasks.lastUpdatedAt, agent_tasks.finishedAt,
|
|
258
|
-
agent_tasks.peakContextPercent`,
|
|
262
|
+
agent_tasks.statusKind, agent_tasks.peakContextPercent`,
|
|
259
263
|
timeline: `agent_tasks.id, agent_tasks.agentId, agent_tasks.parentTaskId, ${TASK_PREVIEW_SQL},
|
|
260
264
|
agent_tasks.title, agent_tasks.status, agent_tasks.createdAt, agent_tasks.lastUpdatedAt,
|
|
261
265
|
agent_tasks.finishedAt, agent_tasks.peakContextTokens`,
|
|
@@ -263,6 +267,12 @@ const LIST_COLUMNS = {
|
|
|
263
267
|
|
|
264
268
|
type TaskListFields = keyof typeof LIST_COLUMNS;
|
|
265
269
|
|
|
270
|
+
/** A kind this build does not know (written by a newer one) reads as unknown. */
|
|
271
|
+
function parseStatusKind(value: string | null | undefined): TaskStatusKind | undefined {
|
|
272
|
+
const parsed = TaskStatusKindSchema.safeParse(value);
|
|
273
|
+
return parsed.success ? parsed.data : undefined;
|
|
274
|
+
}
|
|
275
|
+
|
|
266
276
|
/** The stored hop list; entries that do not parse are dropped, none reads as unset. */
|
|
267
277
|
function parseFallbackHops(value: string | null | undefined): FallbackHop[] | undefined {
|
|
268
278
|
if (!value) return undefined;
|
|
@@ -418,6 +428,7 @@ export function rowToAgentTask(row: AgentTaskRow): AgentTask {
|
|
|
418
428
|
finishedAt: row.finishedAt ?? undefined,
|
|
419
429
|
notifiedAt: row.notifiedAt ?? undefined,
|
|
420
430
|
failureReason: row.failureReason ?? undefined,
|
|
431
|
+
statusKind: parseStatusKind(row.statusKind),
|
|
421
432
|
output: row.output ?? undefined,
|
|
422
433
|
progress: row.progress ?? undefined,
|
|
423
434
|
wasPaused: !!row.was_paused,
|
|
@@ -480,6 +491,7 @@ export function rowToAgentTaskSummary(row: AgentTaskSummaryRow): AgentTaskSummar
|
|
|
480
491
|
createdAt: row.createdAt,
|
|
481
492
|
lastUpdatedAt: row.lastUpdatedAt,
|
|
482
493
|
finishedAt: row.finishedAt ?? undefined,
|
|
494
|
+
statusKind: parseStatusKind(row.statusKind),
|
|
483
495
|
peakContextPercent: row.peakContextPercent ?? undefined,
|
|
484
496
|
totalCostUsd: row.totalCostUsd ?? undefined,
|
|
485
497
|
};
|
|
@@ -868,6 +880,8 @@ export const findTaskByGitHub = findTaskByVcs;
|
|
|
868
880
|
export interface TaskFilters {
|
|
869
881
|
/** Single status (back-compat) OR array of statuses (multi-status filter). */
|
|
870
882
|
status?: AgentTaskStatus | AgentTaskStatus[];
|
|
883
|
+
/** Why the task ended (e.g. `error`); combine with `status` to tell `failed` kinds apart. */
|
|
884
|
+
statusKind?: TaskStatusKind;
|
|
871
885
|
agentId?: string;
|
|
872
886
|
search?: string;
|
|
873
887
|
// New filters
|
|
@@ -1020,6 +1034,11 @@ export async function getAllTasks(
|
|
|
1020
1034
|
}
|
|
1021
1035
|
}
|
|
1022
1036
|
|
|
1037
|
+
if (filters?.statusKind) {
|
|
1038
|
+
conditions.push("statusKind = ?");
|
|
1039
|
+
params.push(filters.statusKind);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1023
1042
|
if (filters?.agentId) {
|
|
1024
1043
|
conditions.push("agentId = ?");
|
|
1025
1044
|
params.push(filters.agentId);
|
|
@@ -1203,6 +1222,11 @@ export async function getTasksCount(
|
|
|
1203
1222
|
}
|
|
1204
1223
|
}
|
|
1205
1224
|
|
|
1225
|
+
if (filters?.statusKind) {
|
|
1226
|
+
conditions.push("statusKind = ?");
|
|
1227
|
+
params.push(filters.statusKind);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1206
1230
|
if (filters?.agentId) {
|
|
1207
1231
|
conditions.push("agentId = ?");
|
|
1208
1232
|
params.push(filters.agentId);
|
package/src/be/db/tasks/write.ts
CHANGED
|
@@ -12,8 +12,13 @@ import type {
|
|
|
12
12
|
ReasoningEffort,
|
|
13
13
|
RuntimePool,
|
|
14
14
|
TaskAttachment,
|
|
15
|
+
TaskStatusKindFor,
|
|
16
|
+
} from "../../../types";
|
|
17
|
+
import {
|
|
18
|
+
isTaskStatusKindFor,
|
|
19
|
+
isTerminalTaskStatus,
|
|
20
|
+
SUPERSEDED_WORKFLOW_TASK_REASON,
|
|
15
21
|
} from "../../../types";
|
|
16
|
-
import { isTerminalTaskStatus, SUPERSEDED_WORKFLOW_TASK_REASON } from "../../../types";
|
|
17
22
|
import { scrubSecrets } from "../../../utils/secret-scrubber";
|
|
18
23
|
import { emitTaskStarted } from "../../task-lifecycle-events";
|
|
19
24
|
import { publishWorkerNudge } from "../../worker-nudges";
|
|
@@ -462,7 +467,12 @@ export async function setTaskTitleIfUnset(
|
|
|
462
467
|
export async function completeTask(
|
|
463
468
|
id: string,
|
|
464
469
|
output?: string,
|
|
465
|
-
options?: {
|
|
470
|
+
options?: {
|
|
471
|
+
addTags?: string[];
|
|
472
|
+
deferredAt?: string;
|
|
473
|
+
/** Why it completed; see TASK_STATUS_KINDS. Omitted stores NULL (unknown). */
|
|
474
|
+
statusKind?: TaskStatusKindFor<"completed">;
|
|
475
|
+
},
|
|
466
476
|
): Promise<AgentTask | null> {
|
|
467
477
|
const oldTask = await getTaskById(id);
|
|
468
478
|
if (!oldTask) return null;
|
|
@@ -482,9 +492,9 @@ export async function completeTask(
|
|
|
482
492
|
// await between the guard read above and this write lets a racing
|
|
483
493
|
// terminal transition (e.g. heartbeat failTask) land first.
|
|
484
494
|
let completed = await getDbClient().get<AgentTaskRow>(
|
|
485
|
-
`UPDATE agent_tasks SET status = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
495
|
+
`UPDATE agent_tasks SET status = ?, statusKind = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
486
496
|
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded', 'skipped') RETURNING *`,
|
|
487
|
-
["completed", finishedAt, id],
|
|
497
|
+
["completed", options?.statusKind ?? null, finishedAt, id],
|
|
488
498
|
);
|
|
489
499
|
if (!completed) return null;
|
|
490
500
|
|
|
@@ -598,6 +608,12 @@ export async function failTask(
|
|
|
598
608
|
* then cascades whatever is left.
|
|
599
609
|
*/
|
|
600
610
|
cascadeDependents?: boolean;
|
|
611
|
+
/**
|
|
612
|
+
* Why it failed: `agent` when the agent chose to, `error` when the system
|
|
613
|
+
* gave up on the run, `cascade` / `external` otherwise. See
|
|
614
|
+
* TASK_STATUS_KINDS. Omitted stores NULL (unknown).
|
|
615
|
+
*/
|
|
616
|
+
statusKind?: TaskStatusKindFor<"failed">;
|
|
601
617
|
} = {},
|
|
602
618
|
): Promise<AgentTask | null> {
|
|
603
619
|
const oldTask = await getTaskById(id);
|
|
@@ -615,10 +631,11 @@ export async function failTask(
|
|
|
615
631
|
// Status predicate re-checks the idempotency guard atomically (a racing
|
|
616
632
|
// terminal transition can land during the await above).
|
|
617
633
|
const row = await getDbClient().get<AgentTaskRow>(
|
|
618
|
-
`UPDATE agent_tasks SET status = 'failed', failureReason = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
634
|
+
`UPDATE agent_tasks SET status = 'failed', statusKind = ?, failureReason = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
619
635
|
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded', 'skipped')
|
|
620
636
|
AND (? IS NULL OR lastUpdatedAt = ?) RETURNING *`,
|
|
621
637
|
[
|
|
638
|
+
opts.statusKind ?? null,
|
|
622
639
|
scrubbedReason,
|
|
623
640
|
finishedAt,
|
|
624
641
|
id,
|
|
@@ -737,7 +754,11 @@ export async function overwriteTerminalTaskResultText(
|
|
|
737
754
|
export async function cancelTask(
|
|
738
755
|
id: string,
|
|
739
756
|
reason?: string,
|
|
740
|
-
options: {
|
|
757
|
+
options: {
|
|
758
|
+
cascadeDependents?: boolean;
|
|
759
|
+
/** Who cancelled it; see TASK_STATUS_KINDS. Omitted stores NULL (unknown). */
|
|
760
|
+
statusKind?: TaskStatusKindFor<"cancelled">;
|
|
761
|
+
} = {},
|
|
741
762
|
): Promise<AgentTask | null> {
|
|
742
763
|
const oldTask = await getTaskById(id);
|
|
743
764
|
if (!oldTask) return null;
|
|
@@ -752,9 +773,9 @@ export async function cancelTask(
|
|
|
752
773
|
// Status predicate re-checks the idempotency guard atomically (a racing
|
|
753
774
|
// terminal transition can land during the await above).
|
|
754
775
|
const row = await getDbClient().get<AgentTaskRow>(
|
|
755
|
-
`UPDATE agent_tasks SET status = 'cancelled', failureReason = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
776
|
+
`UPDATE agent_tasks SET status = 'cancelled', statusKind = ?, failureReason = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
756
777
|
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded', 'skipped') RETURNING *`,
|
|
757
|
-
[cancelReason, finishedAt, id],
|
|
778
|
+
[options.statusKind ?? null, cancelReason, finishedAt, id],
|
|
758
779
|
);
|
|
759
780
|
|
|
760
781
|
if (row && oldTask) {
|
|
@@ -860,7 +881,11 @@ export async function cancelTask(
|
|
|
860
881
|
* `task.skipped`, which defer-task waits and workflow resume listen for; the
|
|
861
882
|
* Slack, chat, Jira and Linear outbound paths do not, so a skip notifies no one.
|
|
862
883
|
*/
|
|
863
|
-
export async function skipTask(
|
|
884
|
+
export async function skipTask(
|
|
885
|
+
id: string,
|
|
886
|
+
reason: string,
|
|
887
|
+
opts: { statusKind?: TaskStatusKindFor<"skipped"> } = {},
|
|
888
|
+
): Promise<AgentTask | null> {
|
|
864
889
|
const oldTask = await getTaskById(id);
|
|
865
890
|
if (!oldTask) return null;
|
|
866
891
|
if (isTerminalTaskStatus(oldTask.status)) return null;
|
|
@@ -870,9 +895,9 @@ export async function skipTask(id: string, reason: string): Promise<AgentTask |
|
|
|
870
895
|
// Status predicate re-checks the idempotency guard atomically (a racing
|
|
871
896
|
// terminal transition can land during the await above).
|
|
872
897
|
const row = await getDbClient().get<AgentTaskRow>(
|
|
873
|
-
`UPDATE agent_tasks SET status = 'skipped', failureReason = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
898
|
+
`UPDATE agent_tasks SET status = 'skipped', statusKind = ?, failureReason = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
874
899
|
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded', 'skipped') RETURNING *`,
|
|
875
|
-
[skipReason, finishedAt, id],
|
|
900
|
+
[opts.statusKind ?? null, skipReason, finishedAt, id],
|
|
876
901
|
);
|
|
877
902
|
if (!row) return null;
|
|
878
903
|
|
|
@@ -937,6 +962,8 @@ export async function supersedeTask(
|
|
|
937
962
|
resumeTaskId: string | null;
|
|
938
963
|
/** Compare-and-swap on the observed `lastUpdatedAt`; see `failTask`. */
|
|
939
964
|
expectedLastUpdatedAt?: string;
|
|
965
|
+
/** Defaults to `reason` when it is a resume reason; a free-form reason stores NULL. */
|
|
966
|
+
statusKind?: TaskStatusKindFor<"superseded">;
|
|
940
967
|
},
|
|
941
968
|
): Promise<AgentTask | null> {
|
|
942
969
|
const oldTask = await getTaskById(id);
|
|
@@ -951,12 +978,19 @@ export async function supersedeTask(
|
|
|
951
978
|
const row = await getDbClient().get<AgentTaskRow>(
|
|
952
979
|
`UPDATE agent_tasks
|
|
953
980
|
SET status = 'superseded',
|
|
981
|
+
statusKind = ?,
|
|
954
982
|
finishedAt = ?,
|
|
955
983
|
lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
956
984
|
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded', 'skipped')
|
|
957
985
|
AND (? IS NULL OR lastUpdatedAt = ?)
|
|
958
986
|
RETURNING *`,
|
|
959
|
-
[
|
|
987
|
+
[
|
|
988
|
+
args.statusKind ?? (isTaskStatusKindFor("superseded", args.reason) ? args.reason : null),
|
|
989
|
+
finishedAt,
|
|
990
|
+
id,
|
|
991
|
+
args.expectedLastUpdatedAt ?? null,
|
|
992
|
+
args.expectedLastUpdatedAt ?? null,
|
|
993
|
+
],
|
|
960
994
|
);
|
|
961
995
|
|
|
962
996
|
if (row && oldTask) {
|
|
@@ -1030,6 +1064,7 @@ export async function markWorkflowStepTaskSuperseded(id: string): Promise<boolea
|
|
|
1030
1064
|
const row = await getDbClient().get<AgentTaskRow>(
|
|
1031
1065
|
`UPDATE agent_tasks
|
|
1032
1066
|
SET status = 'superseded',
|
|
1067
|
+
statusKind = 'workflow_retry',
|
|
1033
1068
|
lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
1034
1069
|
WHERE id = ? AND status = 'failed' AND failureReason = ?
|
|
1035
1070
|
RETURNING *`,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type UserAvatar, UserAvatarSchema } from "../../../types";
|
|
2
|
+
|
|
3
|
+
/** Malformed avatar JSON reads as "no avatar", like `parseAgentAvatar`. */
|
|
4
|
+
export function parseUserAvatar(raw: string | null): UserAvatar | null {
|
|
5
|
+
if (!raw) return null;
|
|
6
|
+
try {
|
|
7
|
+
const parsed = UserAvatarSchema.safeParse(JSON.parse(raw));
|
|
8
|
+
return parsed.success ? parsed.data : null;
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/be/db.ts
CHANGED
|
@@ -145,6 +145,7 @@ import {
|
|
|
145
145
|
OPEN_TASK_STATUSES,
|
|
146
146
|
parseModelTier,
|
|
147
147
|
SERVER_GENERATED_ATTACHMENT_CAPABILITY,
|
|
148
|
+
type UserAvatar,
|
|
148
149
|
} from "../types";
|
|
149
150
|
import {
|
|
150
151
|
CODEX_AUTH_FAILURE_BENCH_MS,
|
|
@@ -169,6 +170,7 @@ import {
|
|
|
169
170
|
checkIdentityFieldBudget,
|
|
170
171
|
IdentityFieldBudgetError,
|
|
171
172
|
} from "../utils/identity-field-budget";
|
|
173
|
+
import { keyPaceFromWindows, keyUsageFromWindows } from "../utils/key-usage";
|
|
172
174
|
import { activeModelBlock, type ModelFamily } from "../utils/model-rate-limit-windows";
|
|
173
175
|
import { isEffectiveOutputSchema } from "../utils/output-schema";
|
|
174
176
|
import {
|
|
@@ -265,6 +267,7 @@ import {
|
|
|
265
267
|
WORKFLOW_CONTEXT_SET_REQUESTER_SQL,
|
|
266
268
|
WORKFLOW_SEALED_CONTEXT_BY_REQUESTER_SQL,
|
|
267
269
|
} from "./db/user-references";
|
|
270
|
+
import { parseUserAvatar } from "./db/users/avatar";
|
|
268
271
|
import { tombstoneWorkflowIdempotencyKeys } from "./db/workflow-idempotency";
|
|
269
272
|
import { deleteOrphanedRunDefinitions } from "./db/workflow-run-definitions";
|
|
270
273
|
import {
|
|
@@ -3790,7 +3793,7 @@ export async function cascadeFailDependents(
|
|
|
3790
3793
|
if (seen.has(dep.id)) continue;
|
|
3791
3794
|
|
|
3792
3795
|
const reason = `Blocked dependency ${parentId.slice(0, 8)} was ${parentStatus}`;
|
|
3793
|
-
const failed = await failTask(dep.id, reason);
|
|
3796
|
+
const failed = await failTask(dep.id, reason, { statusKind: "cascade" });
|
|
3794
3797
|
if (failed) {
|
|
3795
3798
|
results.push({
|
|
3796
3799
|
taskId: failed.id,
|
|
@@ -7487,9 +7490,10 @@ export async function failPendingResumeIfUnclaimed(
|
|
|
7487
7490
|
const now = new Date().toISOString();
|
|
7488
7491
|
const scrubbedReason = scrubSecrets(failureReason);
|
|
7489
7492
|
const row = await getDbClient().get<AgentTaskRow>(
|
|
7490
|
-
`UPDATE agent_tasks SET status = ?, failureReason = ?, finishedAt = ?, lastUpdatedAt = ?
|
|
7493
|
+
`UPDATE agent_tasks SET status = ?, statusKind = ?, failureReason = ?, finishedAt = ?, lastUpdatedAt = ?
|
|
7491
7494
|
WHERE id = ? AND status = 'pending' RETURNING *`,
|
|
7492
|
-
|
|
7495
|
+
// The resume budget ran out (failed) or the reaper escalated the pin (cancelled).
|
|
7496
|
+
[status, status === "failed" ? "error" : "system", scrubbedReason, now, now, taskId],
|
|
7493
7497
|
);
|
|
7494
7498
|
|
|
7495
7499
|
if (row) {
|
|
@@ -11955,6 +11959,23 @@ export interface AvailableKeyIndicesResult {
|
|
|
11955
11959
|
/** Rate-limited indices whose limit is a provider spend cap: no retry helps before it resets. */
|
|
11956
11960
|
spendCappedIndices: number[];
|
|
11957
11961
|
authFailureFence: number; // highest `authFailureSeq` among these rows
|
|
11962
|
+
/**
|
|
11963
|
+
* Usage per pool position (`keyUsageFromWindows`: max of the live 5h and 7d
|
|
11964
|
+
* utilization, 0 when unobserved or reset). Ranks admissible keys only.
|
|
11965
|
+
*/
|
|
11966
|
+
keyUsage: number[];
|
|
11967
|
+
/**
|
|
11968
|
+
* Pace delta per pool position (`keyPaceFromWindows`: max of used minus elapsed
|
|
11969
|
+
* share over the live 5h, 7d and `modelFamily` weekly windows, 0 when none).
|
|
11970
|
+
* Ranks admissible keys under the `pace` strategy only.
|
|
11971
|
+
*/
|
|
11972
|
+
keyPace: number[];
|
|
11973
|
+
/**
|
|
11974
|
+
* `in_progress` tasks per pool position whose `credentialKeyType` is this key
|
|
11975
|
+
* type and whose `credentialKeySuffix` is the position's suffix. Breaks ties
|
|
11976
|
+
* within the usage band; it never excludes a key.
|
|
11977
|
+
*/
|
|
11978
|
+
activeSessions: number[];
|
|
11958
11979
|
}
|
|
11959
11980
|
|
|
11960
11981
|
/**
|
|
@@ -12087,6 +12108,44 @@ export async function getAvailableKeyIndices(
|
|
|
12087
12108
|
availableIndices.push(i);
|
|
12088
12109
|
}
|
|
12089
12110
|
|
|
12111
|
+
// A position several rows apply to (one key pooled in several scopes) takes the highest reading.
|
|
12112
|
+
const keyUsage = new Array<number>(totalKeys).fill(0);
|
|
12113
|
+
// The most over-pace reading wins; a position with no live window reads 0.
|
|
12114
|
+
const keyPace = new Array<number | undefined>(totalKeys).fill(undefined);
|
|
12115
|
+
for (const row of rows) {
|
|
12116
|
+
const windows = parseRateLimitWindowsJson(row.rateLimitWindows);
|
|
12117
|
+
const usage = keyUsageFromWindows(windows, nowMs);
|
|
12118
|
+
const pace = keyPaceFromWindows(windows, nowMs, modelFamily);
|
|
12119
|
+
for (const i of positionsOf(row)) {
|
|
12120
|
+
if (i < 0 || i >= totalKeys) continue;
|
|
12121
|
+
keyUsage[i] = Math.max(keyUsage[i]!, usage);
|
|
12122
|
+
if (pace !== undefined) keyPace[i] = Math.max(keyPace[i] ?? Number.NEGATIVE_INFINITY, pace);
|
|
12123
|
+
}
|
|
12124
|
+
}
|
|
12125
|
+
|
|
12126
|
+
// Running sessions per position. A task stamps its key suffix at session start
|
|
12127
|
+
// (`recordKeyUsage`), so this moves within seconds, before any usage report.
|
|
12128
|
+
// Without `keySuffixes`, a position takes the suffix of its stored row in scope.
|
|
12129
|
+
const suffixAt = (i: number): string | undefined =>
|
|
12130
|
+
suffixes
|
|
12131
|
+
? suffixes[i]
|
|
12132
|
+
: rows.find((r) => r.keyIndex === i && r.scope === scope && r.scopeId === effectiveScopeId)
|
|
12133
|
+
?.keySuffix;
|
|
12134
|
+
const positionSuffixes = Array.from({ length: totalKeys }, (_, i) => suffixAt(i));
|
|
12135
|
+
const distinctSuffixes = [...new Set(positionSuffixes.filter((s): s is string => !!s))];
|
|
12136
|
+
const sessionsBySuffix = new Map<string, number>();
|
|
12137
|
+
if (distinctSuffixes.length > 0) {
|
|
12138
|
+
const counts = await client.query<{ suffix: string; n: number }>(
|
|
12139
|
+
`SELECT credentialKeySuffix AS suffix, COUNT(*) AS n FROM agent_tasks
|
|
12140
|
+
WHERE status = 'in_progress' AND credentialKeyType = ?
|
|
12141
|
+
AND credentialKeySuffix IN (${distinctSuffixes.map(() => "?").join(", ")})
|
|
12142
|
+
GROUP BY credentialKeySuffix`,
|
|
12143
|
+
[keyType, ...distinctSuffixes],
|
|
12144
|
+
);
|
|
12145
|
+
for (const { suffix, n } of counts) sessionsBySuffix.set(suffix, n);
|
|
12146
|
+
}
|
|
12147
|
+
const activeSessions = positionSuffixes.map((s) => (s ? (sessionsBySuffix.get(s) ?? 0) : 0));
|
|
12148
|
+
|
|
12090
12149
|
return {
|
|
12091
12150
|
availableIndices,
|
|
12092
12151
|
rejectedIndices,
|
|
@@ -12098,6 +12157,9 @@ export async function getAvailableKeyIndices(
|
|
|
12098
12157
|
? new Date(earliestModelResetsAtSec * 1000).toISOString()
|
|
12099
12158
|
: null,
|
|
12100
12159
|
authFailureFence: Math.max(0, ...rows.map((r) => r.authFailureSeq)),
|
|
12160
|
+
keyUsage,
|
|
12161
|
+
keyPace: keyPace.map((pace) => pace ?? 0),
|
|
12162
|
+
activeSessions,
|
|
12101
12163
|
};
|
|
12102
12164
|
}
|
|
12103
12165
|
|
|
@@ -12537,6 +12599,8 @@ type UserRow = {
|
|
|
12537
12599
|
dailyBudgetUsd: number | null;
|
|
12538
12600
|
status: string;
|
|
12539
12601
|
mergedIntoUserId: string | null;
|
|
12602
|
+
// Migration 344: JSON of UserAvatar. NULL = initials.
|
|
12603
|
+
avatar: string | null;
|
|
12540
12604
|
createdAt: string;
|
|
12541
12605
|
lastUpdatedAt: string;
|
|
12542
12606
|
};
|
|
@@ -12555,6 +12619,7 @@ function rowToUser(row: UserRow): User {
|
|
|
12555
12619
|
dailyBudgetUsd: row.dailyBudgetUsd ?? null,
|
|
12556
12620
|
status: (row.status as "invited" | "active" | "suspended") ?? "active",
|
|
12557
12621
|
...(row.mergedIntoUserId ? { mergedIntoUserId: row.mergedIntoUserId } : {}),
|
|
12622
|
+
avatar: parseUserAvatar(row.avatar),
|
|
12558
12623
|
createdAt: row.createdAt,
|
|
12559
12624
|
lastUpdatedAt: row.lastUpdatedAt,
|
|
12560
12625
|
};
|
|
@@ -12581,12 +12646,13 @@ export async function createUser(data: {
|
|
|
12581
12646
|
metadata?: Record<string, unknown>;
|
|
12582
12647
|
dailyBudgetUsd?: number | null;
|
|
12583
12648
|
status?: "invited" | "active" | "suspended";
|
|
12649
|
+
avatar?: UserAvatar | null;
|
|
12584
12650
|
}): Promise<User> {
|
|
12585
12651
|
const id = crypto.randomUUID().replace(/-/g, "");
|
|
12586
12652
|
const now = new Date().toISOString();
|
|
12587
12653
|
const row = await getDbClient().get<UserRow>(
|
|
12588
|
-
`INSERT INTO users (id, name, email, role, notes, emailAliases, preferredChannel, timezone, metadata, dailyBudgetUsd, status, createdAt, lastUpdatedAt)
|
|
12589
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`,
|
|
12654
|
+
`INSERT INTO users (id, name, email, role, notes, emailAliases, preferredChannel, timezone, metadata, dailyBudgetUsd, status, avatar, createdAt, lastUpdatedAt)
|
|
12655
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`,
|
|
12590
12656
|
[
|
|
12591
12657
|
id,
|
|
12592
12658
|
data.name,
|
|
@@ -12599,6 +12665,7 @@ export async function createUser(data: {
|
|
|
12599
12665
|
data.metadata !== undefined ? JSON.stringify(data.metadata) : null,
|
|
12600
12666
|
data.dailyBudgetUsd ?? null,
|
|
12601
12667
|
data.status ?? "active",
|
|
12668
|
+
data.avatar ? JSON.stringify(data.avatar) : null,
|
|
12602
12669
|
now,
|
|
12603
12670
|
now,
|
|
12604
12671
|
],
|
|
@@ -12622,6 +12689,8 @@ export async function updateUser(
|
|
|
12622
12689
|
metadata: Record<string, unknown> | null;
|
|
12623
12690
|
dailyBudgetUsd: number | null;
|
|
12624
12691
|
status: "invited" | "active" | "suspended";
|
|
12692
|
+
// null resets to initials.
|
|
12693
|
+
avatar: UserAvatar | null;
|
|
12625
12694
|
}>,
|
|
12626
12695
|
): Promise<User | null> {
|
|
12627
12696
|
const sets: string[] = [];
|
|
@@ -12667,6 +12736,10 @@ export async function updateUser(
|
|
|
12667
12736
|
sets.push("status = ?");
|
|
12668
12737
|
params.push(data.status);
|
|
12669
12738
|
}
|
|
12739
|
+
if (data.avatar !== undefined) {
|
|
12740
|
+
sets.push("avatar = ?");
|
|
12741
|
+
params.push(data.avatar === null ? null : JSON.stringify(data.avatar));
|
|
12742
|
+
}
|
|
12670
12743
|
|
|
12671
12744
|
if (sets.length === 0) return getUserById(id);
|
|
12672
12745
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- Adds a JSON-in-TEXT `avatar` column to `users`, the same shape as
|
|
2
|
+
-- `agents.avatar` (migration 119): a lucide glyph, an https image link, or an
|
|
3
|
+
-- agent-fs image. NULL means "no custom avatar"; the UI falls back to initials.
|
|
4
|
+
ALTER TABLE users ADD COLUMN avatar TEXT;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- Why a task reached its terminal status (e.g. failed + agent vs failed + error).
|
|
2
|
+
-- Refines `status` and never replaces it. NULL means unknown: rows finished
|
|
3
|
+
-- before this column existed are not backfilled. No CHECK constraint: the
|
|
4
|
+
-- valid kinds per status live in TASK_STATUS_KINDS (src/types.ts), so a new
|
|
5
|
+
-- kind needs no migration.
|
|
6
|
+
ALTER TABLE agent_tasks ADD COLUMN statusKind TEXT;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FilesError } from "@/fs/provider";
|
|
2
|
-
import {
|
|
2
|
+
import { buildAgentFsFileLink } from "@/utils/constants";
|
|
3
3
|
import { agentFsClientFor } from "../agent-fs-identity";
|
|
4
4
|
import { getDbClient, getSwarmConfigs } from "../db";
|
|
5
5
|
import { parseScene } from "./boards/elements";
|
|
@@ -73,7 +73,7 @@ async function open(id: string) {
|
|
|
73
73
|
return { row, owner: row.ownerAgentId, provider: client.provider, scope };
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const withLink = (row: Row): PrimitiveObject => ({ ...row, link:
|
|
76
|
+
const withLink = (row: Row): PrimitiveObject => ({ ...row, link: buildAgentFsFileLink(row) });
|
|
77
77
|
|
|
78
78
|
/** agent-fs keeps this drive's rows fresh through `file.changed` (object-webhooks.ts). */
|
|
79
79
|
async function driveWatched(orgId: string, driveId: string): Promise<boolean> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FileScope, FilesError, normalizeStoredKey } from "@/fs/provider";
|
|
2
|
-
import {
|
|
2
|
+
import { buildAgentFsFileLink } from "@/utils/constants";
|
|
3
3
|
import { scrubSecrets } from "@/utils/secret-scrubber";
|
|
4
4
|
import { agentFsClientFor } from "../agent-fs-identity";
|
|
5
5
|
import { getDbClient } from "../db";
|
|
@@ -107,7 +107,7 @@ const REINDEX_LIMITS: ReindexLimits = {
|
|
|
107
107
|
// shortcut: in-process only; two API replicas can still reindex one drive at once (each pass is safe, just duplicated work).
|
|
108
108
|
const reindexing = new Set<string>();
|
|
109
109
|
|
|
110
|
-
const withLink = (row: ObjectRow): PrimitiveObject => ({ ...row, link:
|
|
110
|
+
const withLink = (row: ObjectRow): PrimitiveObject => ({ ...row, link: buildAgentFsFileLink(row) });
|
|
111
111
|
|
|
112
112
|
export async function clientFor(agentId: string | undefined) {
|
|
113
113
|
const client = agentId ? await agentFsClientFor(agentId) : undefined;
|
|
@@ -419,7 +419,7 @@ export interface SwarmSdk {
|
|
|
419
419
|
// --- memory ---
|
|
420
420
|
memory_search(args: { query: string; intent: string; scope?: "all" | "agent" | "swarm"; limit?: number; source?: string; keyPrefix?: string }): Promise<unknown>;
|
|
421
421
|
memory_get(args: { memoryId?: string; id?: string; intent: string }): Promise<unknown>;
|
|
422
|
-
memory_rate(args: { id
|
|
422
|
+
memory_rate(args: { id?: string; memoryId?: string; useful: boolean; note?: string; taskId?: string; referencesSource?: string }): Promise<unknown>;
|
|
423
423
|
// --- tasks ---
|
|
424
424
|
task_list(args?: Record<string, unknown>): Promise<unknown>;
|
|
425
425
|
task_get(args: { taskId: string }): Promise<unknown>;
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
parseFollowUpGateScheduleIds,
|
|
22
22
|
} from "../utils/follow-up-gate-schedule-ids";
|
|
23
23
|
import { kindForModelString } from "../utils/internal-ai/models";
|
|
24
|
+
import { CREDENTIAL_SELECTION_STRATEGIES } from "../utils/key-usage";
|
|
24
25
|
import { normalizeOrgWebsite } from "../utils/org-website";
|
|
25
26
|
import { parseTaskToolManifest } from "../utils/task-tool-manifest";
|
|
26
27
|
import { isTierConfigKey, validateTierConfigValue } from "./model-tier-keys";
|
|
@@ -82,6 +83,8 @@ const RESERVED_KEYS = new Set([
|
|
|
82
83
|
"GITHUB_API_URL",
|
|
83
84
|
// Picks which App installation workers get tokens for; a config writer must not choose it.
|
|
84
85
|
"GITHUB_APP_INSTALLATION_ID",
|
|
86
|
+
// Owners whose repos get a token for their own installation; same reason.
|
|
87
|
+
"GITHUB_APP_REPO_OWNERS",
|
|
85
88
|
]);
|
|
86
89
|
|
|
87
90
|
// Config keys the API server owns for its own use and must NEVER hand out over
|
|
@@ -561,6 +564,7 @@ const VALIDATED_KEYS: Record<string, ConfigValidator> = {
|
|
|
561
564
|
// fail: worker fails a task fast when every key has exhausted the task
|
|
562
565
|
// model's weekly window (Fable/Opus/Sonnet). fallback: legacy random pick.
|
|
563
566
|
...enumValidator("MODEL_WINDOW_EXHAUSTED_POLICY", ["fail", "fallback"]),
|
|
567
|
+
...enumValidator("CREDENTIAL_SELECTION_STRATEGY", [...CREDENTIAL_SELECTION_STRATEGIES]),
|
|
564
568
|
...enumValidator("HEARTBEAT_CHECKLIST_GATE_MODE", ["shadow", "enforce"]),
|
|
565
569
|
// `enforce` is deliberately absent: the follow-up gate only records decisions.
|
|
566
570
|
...enumValidator("FOLLOW_UP_GATE_MODE", ["off", "shadow"]),
|
|
@@ -430,7 +430,7 @@ export async function handlePullRequestClosed(
|
|
|
430
430
|
const reason = outcome === "merged" ? "PR was merged" : "PR was declined";
|
|
431
431
|
for (const task of await findActiveTasksByVcs(repository.full_name, pr.id, "bitbucket")) {
|
|
432
432
|
console.log(`[Bitbucket] Cancelling task ${task.id} — ${reason}`);
|
|
433
|
-
await failTask(task.id, reason);
|
|
433
|
+
await failTask(task.id, reason, { statusKind: "external" });
|
|
434
434
|
}
|
|
435
435
|
return { created: false };
|
|
436
436
|
}
|
|
@@ -103,6 +103,102 @@ export async function reportKeyRateLimitWindows(
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/** Server terminal statuses whose finished session still reports its window telemetry. */
|
|
107
|
+
const TELEMETRY_TERMINAL_STATUSES = new Set(["completed", "failed"]);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Reports the window snapshot of a session whose task the server already
|
|
111
|
+
* holds as `completed` or `failed` (the agent finished the task before its
|
|
112
|
+
* session ended). The server result stands, so no outcome and no `finish`:
|
|
113
|
+
* only the provider usage the session observed. Fire-and-forget; returns the
|
|
114
|
+
* settled report so a test can await it. Never throws.
|
|
115
|
+
*/
|
|
116
|
+
export function reportTerminalSessionWindows(input: {
|
|
117
|
+
apiUrl: string;
|
|
118
|
+
apiKey: string;
|
|
119
|
+
credentialInfo?: { keyType: string; keySuffix: string; keyIndex: number };
|
|
120
|
+
serverTerminalStatus: string;
|
|
121
|
+
rateLimitWindows?: RateLimitWindowTelemetry;
|
|
122
|
+
}): Promise<void> {
|
|
123
|
+
const { credentialInfo, rateLimitWindows } = input;
|
|
124
|
+
if (
|
|
125
|
+
!credentialInfo ||
|
|
126
|
+
!TELEMETRY_TERMINAL_STATUSES.has(input.serverTerminalStatus) ||
|
|
127
|
+
!rateLimitWindows ||
|
|
128
|
+
Object.keys(rateLimitWindows).length === 0
|
|
129
|
+
) {
|
|
130
|
+
return Promise.resolve();
|
|
131
|
+
}
|
|
132
|
+
return reportKeyRateLimitWindows(
|
|
133
|
+
input.apiUrl,
|
|
134
|
+
input.apiKey,
|
|
135
|
+
credentialInfo.keyType,
|
|
136
|
+
credentialInfo.keySuffix,
|
|
137
|
+
credentialInfo.keyIndex,
|
|
138
|
+
rateLimitWindows,
|
|
139
|
+
).catch((err) => {
|
|
140
|
+
console.warn(
|
|
141
|
+
`[credential] Failed to report rate-limit windows: ${err instanceof Error ? err.message : String(err)}`,
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Throttles mid-session window reports. A snapshot goes out when it carries a
|
|
148
|
+
* window the last report did not, when any window's utilization moved by
|
|
149
|
+
* `minDeltaPoints` percentage points or more, or when `minIntervalMs` passed.
|
|
150
|
+
* `post` is fire-and-forget: a rejection is logged, never thrown, and a
|
|
151
|
+
* failed report does not count as sent.
|
|
152
|
+
*/
|
|
153
|
+
export function createWindowStreamReporter(opts: {
|
|
154
|
+
post: (windows: RateLimitWindowTelemetry) => Promise<void>;
|
|
155
|
+
minDeltaPoints?: number;
|
|
156
|
+
minIntervalMs?: number;
|
|
157
|
+
now?: () => number;
|
|
158
|
+
}): (windows: RateLimitWindowTelemetry) => void {
|
|
159
|
+
const minDelta = (opts.minDeltaPoints ?? 5) / 100;
|
|
160
|
+
const minIntervalMs = opts.minIntervalMs ?? 60_000;
|
|
161
|
+
const now = opts.now ?? Date.now;
|
|
162
|
+
let lastSentAt: number | undefined;
|
|
163
|
+
let lastSent: Record<string, number | undefined> = {};
|
|
164
|
+
|
|
165
|
+
const due = (windows: RateLimitWindowTelemetry, at: number): boolean => {
|
|
166
|
+
if (lastSentAt === undefined || at - lastSentAt >= minIntervalMs) return true;
|
|
167
|
+
return Object.entries(windows).some(([key, window]) => {
|
|
168
|
+
if (!(key in lastSent)) return true;
|
|
169
|
+
const before = lastSent[key];
|
|
170
|
+
const after = window.utilization;
|
|
171
|
+
if (before === undefined || after === undefined) return before !== after;
|
|
172
|
+
return Math.abs(after - before) >= minDelta - 1e-9;
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
return (windows) => {
|
|
177
|
+
if (Object.keys(windows).length === 0) return;
|
|
178
|
+
const at = now();
|
|
179
|
+
if (!due(windows, at)) return;
|
|
180
|
+
const previous = { sentAt: lastSentAt, sent: lastSent };
|
|
181
|
+
lastSentAt = at;
|
|
182
|
+
lastSent = Object.fromEntries(Object.entries(windows).map(([k, w]) => [k, w.utilization]));
|
|
183
|
+
let report: Promise<void>;
|
|
184
|
+
try {
|
|
185
|
+
report = opts.post(windows);
|
|
186
|
+
} catch (err) {
|
|
187
|
+
report = Promise.reject(err);
|
|
188
|
+
}
|
|
189
|
+
report.catch((err) => {
|
|
190
|
+
// Retry on the next event rather than wait out the interval.
|
|
191
|
+
if (lastSentAt === at) {
|
|
192
|
+
lastSentAt = previous.sentAt;
|
|
193
|
+
lastSent = previous.sent;
|
|
194
|
+
}
|
|
195
|
+
console.warn(
|
|
196
|
+
`[credential] Failed to stream rate-limit windows: ${err instanceof Error ? err.message : String(err)}`,
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
106
202
|
export interface CredentialOutcomeInput {
|
|
107
203
|
apiUrl: string;
|
|
108
204
|
apiKey: string;
|