@desplega.ai/agent-swarm 1.173.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{acp-adapter-ccm9xrep.js → acp-adapter-kr4abrsk.js} +17 -16
- package/dist/{actions-sgeyv08k.js → actions-eh4g6w2r.js} +39 -34
- package/dist/{amp-adapter-gpxp3kc9.js → amp-adapter-7h7wdt8q.js} +8 -7
- package/dist/{app-km9qnv2f.js → app-7k8s9w5p.js} +18 -14
- package/dist/{assistant-5r8tcvvd.js → assistant-wswt2y7p.js} +40 -35
- package/dist/{boot-reembed-16rv9843.js → boot-reembed-9apm9qw6.js} +10 -9
- package/dist/{boot-reembed-swwzdgd7.js → boot-reembed-whzbdthj.js} +10 -9
- package/dist/{boot-scrub-sweep-zkr6vkqb.js → boot-scrub-sweep-ndzmvmgt.js} +11 -10
- package/dist/{boot-seeds-d8sp49t2.js → boot-seeds-e9sta0yt.js} +16 -13
- package/dist/{claude-adapter-yzzzh8jp.js → claude-adapter-4mqd3r6r.js} +19 -18
- package/dist/{claude-managed-adapter-xgxhqrt2.js → claude-managed-adapter-9wswb52m.js} +7 -5
- package/dist/{claude-managed-setup-bnmjarjc.js → claude-managed-setup-tpe1effx.js} +6 -4
- package/dist/{claude-sdk-session-4whxere4.js → claude-sdk-session-q49ghmh9.js} +12402 -11850
- package/dist/{cli-ne7smj1b.js → cli-01xvj1rq.js} +10 -10
- package/dist/{cli-nwrdx840.js → cli-035vekcw.js} +3 -3
- package/dist/{cli-9xf7fdtp.js → cli-0pd8hzhc.js} +29 -6
- package/dist/{cli-tmhsxhb8.js → cli-0veb92a3.js} +28 -6
- package/dist/{cli-c3rk1v0x.js → cli-10jesr25.js} +3 -3
- package/dist/{cli-6thk4jz3.js → cli-1y7yywmj.js} +6 -6
- package/dist/{cli-6r2f7edk.js → cli-20krdhz5.js} +47 -19
- package/dist/{cli-rfs4vddv.js → cli-29rja109.js} +39 -20
- package/dist/cli-2m1ktfzz.js +17795 -0
- package/dist/{cli-na2pxe4f.js → cli-2pwa0q4d.js} +15 -4
- package/dist/{cli-7a93cv8c.js → cli-4mengw46.js} +441 -43
- package/dist/{cli-94b48jhk.js → cli-5twdke5x.js} +16 -14
- package/dist/{cli-7a0sde2x.js → cli-6cagzc96.js} +9 -0
- package/dist/cli-6cvfxs8r.js +47 -0
- package/dist/{cli-w1apjecb.js → cli-711vwbxn.js} +2 -2
- package/dist/{cli-r4fqfpwf.js → cli-78vv7446.js} +50 -27
- package/dist/{cli-srqq3gc5.js → cli-7n6s5man.js} +5 -5
- package/dist/{cli-m89t9jdf.js → cli-7x0g4sn1.js} +15416 -16024
- package/dist/{cli-2bw3w47j.js → cli-8wwxw8a3.js} +1 -1
- package/dist/{cli-yatxqynm.js → cli-9ha6hs2d.js} +1 -290
- package/dist/{cli-ywm1azg9.js → cli-9jzdj90z.js} +8 -4
- package/dist/cli-9traj3dn.js +638 -0
- package/dist/{cli-smcrrmhy.js → cli-agzebbd5.js} +9 -9
- package/dist/{cli-c5km5znr.js → cli-c8r3kzzb.js} +1 -1
- package/dist/cli-cvv9k0hh.js +10143 -0
- package/dist/{cli-anzdk0z4.js → cli-d9286m9h.js} +2 -2
- package/dist/cli-e3g5mbkz.js +776 -0
- package/dist/cli-f527ce74.js +781 -0
- package/dist/{cli-gmdajfw5.js → cli-gxzkg1de.js} +5020 -1729
- package/dist/{cli-451ks6aw.js → cli-h1arqn31.js} +1 -1
- package/dist/cli-hjwmhcg1.js +10622 -0
- package/dist/{cli-jpc4r224.js → cli-hqr88ew6.js} +19 -3
- package/dist/{cli-h7k0xtry.js → cli-hvqbtna4.js} +4 -1256
- package/dist/{cli-cd0hv9nh.js → cli-j67mh2vg.js} +2 -2
- package/dist/cli-jta2eyzc.js +619 -0
- package/dist/{cli-wd0hz6ah.js → cli-kbrt8gqa.js} +9 -91
- package/dist/cli-kceah1eh.js +92 -0
- package/dist/{cli-d603qf86.js → cli-ksphgh48.js} +10 -8
- package/dist/{cli-3nxdmjrc.js → cli-mgz4nbgg.js} +4 -4
- package/dist/{cli-saqyage0.js → cli-mz5as5ha.js} +179 -27
- package/dist/cli-n2wq4j7m.js +6985 -0
- package/dist/{cli-ppy4nnnh.js → cli-n8ndw8j7.js} +2 -2
- package/dist/{cli-1w0vj3gw.js → cli-naqzr17j.js} +7 -7
- package/dist/{cli-0a7mm3zp.js → cli-nm1p8jfr.js} +25 -21
- package/dist/{cli-wrh08zjd.js → cli-p3zbc1rw.js} +5 -18
- package/dist/{cli-hsem16hb.js → cli-pe05f8yk.js} +29 -6
- package/dist/{cli-5wpw4rab.js → cli-qmzsbkvy.js} +5 -5
- package/dist/{cli-bv2etw2y.js → cli-qnm4e9e4.js} +99 -590
- package/dist/{cli-1x7da0de.js → cli-qqy4q48b.js} +8 -8
- package/dist/{cli-r44t9wqc.js → cli-r106725k.js} +2 -2
- package/dist/{cli-5er5gjbm.js → cli-r35rw5de.js} +15 -15
- package/dist/{cli-v3zhnxsb.js → cli-r610p9bs.js} +2 -2
- package/dist/{cli-7jykv7ef.js → cli-rc6pf5kv.js} +1 -1
- package/dist/{cli-x119kdba.js → cli-rdxm77k3.js} +1 -1
- package/dist/cli-rhs9pz33.js +294 -0
- package/dist/{cli-0p3enk35.js → cli-s69nfyeh.js} +9 -1
- package/dist/{cli-0kxf81jj.js → cli-sawv63e8.js} +2 -2
- package/dist/{cli-e3pmyt39.js → cli-sg19gbf0.js} +1 -1
- package/dist/{cli-d161g69q.js → cli-shk7r5cs.js} +57 -6
- package/dist/{cli-7pz3b7x5.js → cli-sksetb2q.js} +36 -1
- package/dist/{cli-014vns2y.js → cli-stfs0k5s.js} +208 -525
- package/dist/{cli-db3m6zdt.js → cli-t02z59f2.js} +1 -1
- package/dist/{cli-b07hr3bt.js → cli-txqb9s38.js} +2 -2
- package/dist/{cli-s8z6x4b4.js → cli-v7g551te.js} +225 -113
- package/dist/{cli-rfz2ve55.js → cli-vgqzp4em.js} +3341 -955
- package/dist/{cli-7avy4v8w.js → cli-w1q7h2r2.js} +5 -3
- package/dist/{cli-rcp5aqdw.js → cli-w7m81tb7.js} +1 -1
- package/dist/cli-wfnemr1t.js +86 -0
- package/dist/cli-wmgrkscj.js +23254 -0
- package/dist/{cli-qm1448f9.js → cli-wms6x9db.js} +8 -8
- package/dist/{cli-tadfgd0t.js → cli-x1r545x8.js} +33 -4
- package/dist/{cli-xc7p7s3g.js → cli-xczsgshn.js} +6 -6
- package/dist/{cli-fmhj1ehj.js → cli-y3167wt1.js} +882 -271
- package/dist/{cli-r0byd61h.js → cli-yjmqpxt3.js} +17 -16
- package/dist/{cli-81r1wjyv.js → cli-z780ec7c.js} +1 -1
- package/dist/{cli-phcqp1b9.js → cli-zm9t2vde.js} +2 -2
- package/dist/cli.js +34 -49
- package/dist/{codex-adapter-r3dn4fp5.js → codex-adapter-4z16v9n0.js} +15 -14
- package/dist/{codex-login-841kv5fk.js → codex-login-pkepy2j1.js} +3 -2
- package/dist/{codex-session-runner-fwt793h4.js → codex-session-runner-rvms9y2x.js} +15 -14
- package/dist/{commands-z8fq9qna.js → commands-2a9rtyat.js} +11 -10
- package/dist/{controller-hq5ggpcp.js → controller-3k3madbn.js} +5 -4
- package/dist/{controllers-connect-3mf2btyj.js → controllers-connect-v9yn8zb9.js} +42 -37
- package/dist/{cursor-adapter-q8pgv5qa.js → cursor-adapter-98gbhyzn.js} +7 -6
- package/dist/{db-qfpq4bt7.js → db-eywwsnjw.js} +30 -9
- package/dist/{db-yyhqqrbf.js → db-ncypk9np.js} +12 -11
- package/dist/{devin-adapter-xgtj680j.js → devin-adapter-zeq8b9gz.js} +3 -2
- package/dist/{dispatcher-x0x7qfcq.js → dispatcher-w94kc575.js} +38 -33
- package/dist/{docker-f503k9p0.js → docker-b1e4cqab.js} +3 -2
- package/dist/{dsh-adapter-34etvb5m.js → dsh-adapter-47ztej36.js} +7 -6
- package/dist/{e2b-66xra4az.js → e2b-bbt8ey45.js} +4 -3
- package/dist/{e2b-xwhyj8cw.js → e2b-dp804sen.js} +4 -3
- package/dist/{event-bus-vjtv82gm.js → event-bus-j2jdg3qb.js} +3 -2
- package/dist/{external-channel-h1fjecwe.js → external-channel-zrkg8ar9.js} +11 -10
- package/dist/{google-generative-ai-szdxbpqg.js → google-generative-ai-g8db7x0f.js} +4 -2
- package/dist/{google-vertex-qzw3p36d.js → google-vertex-r2692q0r.js} +4 -2
- package/dist/{grok-adapter-e7mr287e.js → grok-adapter-s9ncp9vy.js} +18 -17
- package/dist/{handlers-znb9n7d4.js → handlers-kqftvjgw.js} +41 -36
- package/dist/{heartbeat-bm4qkn8d.js → heartbeat-9q96p8v9.js} +43 -38
- package/dist/{hook-254r4mza.js → hook-56qe10dp.js} +11 -23
- package/dist/{hook-xaa3q80s.js → hook-yy6rw42k.js} +12 -11
- package/dist/{http-3dgrgp8y.js → http-r2dnb8f8.js} +2411 -275
- package/dist/{index-fx3jqq1e.js → index-3gtmkhc6.js} +38 -33
- package/dist/{index-bdsqa799.js → index-3k5hkz7r.js} +43 -38
- package/dist/index-52j1aja4.js +3465 -0
- package/dist/{index-g2byveez.js → index-5e101240.js} +38 -33
- package/dist/{index-2ybk7khy.js → index-5wyfjc2c.js} +845 -683
- package/dist/index-9gw58n4k.js +193 -0
- package/dist/index-9j87mcm8.js +56305 -0
- package/dist/index-bsmcresk.js +79424 -0
- package/dist/index-mh85qhec.js +475 -0
- package/dist/{index-jd7sejm2.js → index-vxvhxxbn.js} +10 -9
- package/dist/index-we27kd31.js +12810 -0
- package/dist/{keepalive-6ywhpja1.js → keepalive-psj6j54c.js} +12 -11
- package/dist/{lead-cw45n21s.js → lead-hajz4688.js} +61 -56
- package/dist/{maintenance-ss1a1ge9.js → maintenance-ps02sb5m.js} +10 -9
- package/dist/{node-fkajaq96.js → node-mwb5r697.js} +2 -1
- package/dist/{oauth-refresh-sweep-3c6f8vyy.js → oauth-refresh-sweep-0284h93b.js} +11 -10
- package/dist/{onboard-8hzdhc1k.js → onboard-rbf6bg01.js} +11 -3
- package/dist/{opencode-adapter-qbchbcfz.js → opencode-adapter-13dcatgq.js} +18 -13
- package/dist/{otel-impl-e6mnvc4v.js → otel-impl-zvqcbhp7.js} +242 -868
- package/dist/{pi-mono-adapter-3c9g9snh.js → pi-mono-adapter-xxy47q4v.js} +244 -106
- package/dist/{pricing-refresh-gedkjdw0.js → pricing-refresh-kefx9v3t.js} +12 -11
- package/dist/{rbac-roles-dt4vh1yy.js → rbac-roles-3m36rxm2.js} +11 -10
- package/dist/{rbac-roles-eszdg6pm.js → rbac-roles-z76xv0hq.js} +12 -11
- package/dist/{render-v2-907cy6sa.js → render-v2-wz73bs25.js} +18 -14
- package/dist/{resume-42stcaz0.js → resume-k4wzge8w.js} +25 -21
- package/dist/{runtime-qfry88v2.js → runtime-sa2vr16g.js} +2 -2
- package/dist/{setup-adbc1c10.js → setup-2fp2pypp.js} +2 -2
- package/dist/{virtual-modules-rtmt494q.js → virtual-modules-9gkxqrap.js} +6 -5
- package/dist/{work-objects-wpj8ck95.js → work-objects-6k0ywz3m.js} +41 -36
- package/dist/{worker-bzdra9rf.js → worker-5v3rxsdh.js} +61 -56
- package/dist/{x-qfmygqqv.js → x-4mtdeym1.js} +3 -2
- package/openapi.json +1279 -329
- package/package.json +15 -15
- package/src/agentmail/handlers.ts +21 -11
- package/src/apps/definition.ts +16 -0
- package/src/azure-devops/api.ts +52 -2
- package/src/azure-devops/boards-sync.ts +50 -20
- package/src/azure-devops/index.ts +1 -0
- package/src/azure-devops/outbound.ts +95 -0
- package/src/be/boot-seeds.ts +11 -0
- package/src/be/config-refs.ts +60 -0
- package/src/be/db/model-profiles.ts +315 -0
- package/src/be/db/page-versions.ts +15 -0
- package/src/be/db/runtime.ts +35 -8
- package/src/be/db/skill-name-resolution.ts +36 -0
- package/src/be/db/tasks/read.ts +237 -0
- package/src/be/db/tasks/write.ts +7 -0
- package/src/be/db.ts +87 -36
- package/src/be/migrations/215_swarm_config_export_to_env.sql +34 -0
- package/src/be/migrations/216_task_resolved_effort.sql +5 -0
- package/src/be/migrations/217_chat_sdk_state.sql +104 -0
- package/src/be/migrations/219_relabel_pi_context_compactions.sql +22 -0
- package/src/be/migrations/220_model_profiles.sql +137 -0
- package/src/be/model-catalog-store.ts +5 -1
- package/src/be/model-tier-resolution.ts +155 -10
- package/src/be/model-validation.ts +12 -2
- package/src/be/models-catalog.ts +26 -1
- package/src/be/modelsdev-cache.json +198 -63
- package/src/be/modelsdev-cache.ts +9 -1
- package/src/be/script-credential-broker.ts +39 -2
- package/src/be/scripts/run-saved.ts +1 -0
- package/src/be/scripts/typecheck.ts +22 -8
- package/src/be/secret-registry.ts +6 -2
- package/src/be/seed/runner.ts +13 -1
- package/src/be/seed/state-db.ts +5 -0
- package/src/be/seed/types.ts +6 -0
- package/src/be/seed-model-profiles.ts +41 -0
- package/src/be/seed-pricing.ts +19 -2
- package/src/be/seed-scripts/catalog/heartbeat-jev-gate.ts +368 -0
- package/src/be/seed-scripts/catalog/ops-catalog-audit.inline.ts +1 -1
- package/src/be/seed-scripts/catalog/ops-catalog-audit.ts +1 -1
- package/src/be/seed-scripts/index.ts +9 -0
- package/src/be/seed-skills/bundled-files.generated.json +0 -18
- package/src/be/seed-skills/index.ts +104 -3
- package/src/be/swarm-config-guard.ts +53 -0
- package/src/cli.tsx +0 -16
- package/src/commands/onboard/non-interactive.ts +4 -2
- package/src/commands/provider-credentials.ts +52 -6
- package/src/commands/runner.ts +193 -71
- package/src/e2b/env.ts +5 -0
- package/src/extensions/catalog.generated.json +17 -0
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +45 -0
- package/src/extensions/dispatcher.ts +7 -0
- package/src/extensions/loader.ts +10 -5
- package/src/extensions/post-bridge.ts +40 -0
- package/src/github/handlers.ts +11 -4
- package/src/heartbeat/heartbeat.ts +2 -1
- package/src/heartbeat/templates.ts +8 -5
- package/src/hooks/hook.ts +0 -26
- package/src/http/agents.ts +49 -2
- package/src/http/all-routes.ts +1 -1
- package/src/http/apps.ts +30 -3
- package/src/http/config.ts +62 -19
- package/src/http/core.ts +8 -0
- package/src/http/index.ts +25 -3
- package/src/http/integrations.ts +88 -1
- package/src/http/mcp.ts +15 -5
- package/src/http/model-profiles.ts +303 -0
- package/src/http/page-proxy.ts +2 -4
- package/src/http/pages-public.ts +13 -7
- package/src/http/pages.ts +3 -13
- package/src/http/poll.ts +42 -71
- package/src/http/requested-by.ts +54 -0
- package/src/http/script-runs.ts +1 -1
- package/src/http/scripts.ts +26 -2
- package/src/http/stats.ts +1 -30
- package/src/http/tasks.ts +79 -5
- package/src/http/utils.ts +14 -0
- package/src/http/webhooks.ts +160 -3
- package/src/http/x.ts +1 -0
- package/src/integrations/chat-sdk/adapters.ts +129 -0
- package/src/integrations/chat-sdk/attachments.ts +232 -0
- package/src/integrations/chat-sdk/background.ts +36 -0
- package/src/integrations/chat-sdk/commands.ts +194 -0
- package/src/integrations/chat-sdk/config.ts +198 -0
- package/src/integrations/chat-sdk/discord-api.ts +63 -0
- package/src/integrations/chat-sdk/discord-gateway.ts +185 -0
- package/src/integrations/chat-sdk/handlers.ts +28 -0
- package/src/integrations/chat-sdk/inbound.ts +426 -0
- package/src/integrations/chat-sdk/limits.ts +48 -0
- package/src/integrations/chat-sdk/logger.ts +81 -0
- package/src/integrations/chat-sdk/outbound.ts +123 -0
- package/src/integrations/chat-sdk/relay.ts +172 -0
- package/src/integrations/chat-sdk/router.ts +169 -0
- package/src/integrations/chat-sdk/runtime.ts +351 -0
- package/src/integrations/chat-sdk/schema.ts +245 -0
- package/src/integrations/chat-sdk/state.ts +243 -0
- package/src/integrations/chat-sdk/status.ts +244 -0
- package/src/integrations/chat-sdk/steering.ts +58 -0
- package/src/integrations/chat-sdk/teams-origin.ts +77 -0
- package/src/integrations/chat-sdk/telegram-api.ts +56 -0
- package/src/integrations/chat-sdk/templates.ts +16 -0
- package/src/integrations/chat-sdk/test-hooks.ts +37 -0
- package/src/integrations/chat-sdk/thread-buffer.ts +100 -0
- package/src/integrations/chat-sdk/typing.ts +65 -0
- package/src/{artifact-sdk → pages}/feedback-overlay.ts +65 -6
- package/src/pages/version.ts +4 -5
- package/src/prompts/base-prompt.ts +111 -45
- package/src/providers/acp-target-catalog.ts +6 -0
- package/src/providers/acp-targets.ts +56 -3
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +1 -1
- package/src/providers/claude-flag-settings.ts +17 -5
- package/src/providers/claude-managed-adapter.ts +1 -1
- package/src/providers/claude-session-events.ts +6 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +243 -26
- package/src/providers/opencode-swarm-plugin.ts +31 -0
- package/src/providers/pi-mono-adapter.ts +398 -153
- package/src/providers/pi-mono-extension.ts +17 -3
- package/src/providers/pricing-sources.md +33 -2
- package/src/providers/reasoning-effort.ts +37 -0
- package/src/providers/types.ts +6 -2
- package/src/rbac/legacy-policy.ts +16 -2
- package/src/rbac/permissions.ts +26 -0
- package/src/scheduler/deferred-task-waits.ts +18 -5
- package/src/scheduler/scheduler.ts +11 -3
- package/src/scripts-runtime/executors/quickjs-prelude.ts +75 -6
- package/src/scripts-runtime/executors/quickjs-runner.ts +85 -8
- package/src/scripts-runtime/executors/quickjs-web-shims.ts +1041 -0
- package/src/scripts-runtime/extract-args-schema.ts +9 -8
- package/src/scripts-runtime/loader.ts +19 -7
- package/src/scripts-runtime/quickjs-compat.ts +464 -0
- package/src/scripts-runtime/sdk-allowlist.ts +12 -6
- package/src/scripts-runtime/swarm-sdk.ts +0 -11
- package/src/scripts-runtime/types/stdlib.d.ts +39 -15
- package/src/scripts-runtime/types/swarm-extension.d.ts +66 -1
- package/src/scripts-runtime/types/swarm-sdk.d.ts +39 -15
- package/src/server.ts +62 -19
- package/src/slack/blocks.ts +4 -2
- package/src/slack/event-dedup.ts +1 -1
- package/src/slack/reaction-shortcode.ts +14 -0
- package/src/slack/render-v2.ts +12 -7
- package/src/slack/responses.ts +5 -4
- package/src/slack/thread-buffer.ts +41 -22
- package/src/tasks/additive-buffer.ts +4 -2
- package/src/tasks/context-key.ts +60 -1
- package/src/tasks/model-pin.ts +67 -0
- package/src/tasks/worker-follow-up.ts +15 -33
- package/src/tests/acp-adapter.test.ts +42 -0
- package/src/tests/agentmail-filters.test.ts +47 -0
- package/src/tests/api-drain-worker-e2e.test.ts +1 -6
- package/src/tests/apps-spike2.test.ts +35 -0
- package/src/tests/azure-devops-outbound.test.ts +420 -0
- package/src/tests/base-prompt.test.ts +58 -54
- package/src/tests/chat-sdk-commands.test.ts +191 -0
- package/src/tests/chat-sdk-config.test.ts +334 -0
- package/src/tests/chat-sdk-discord-api.test.ts +68 -0
- package/src/tests/chat-sdk-discord-gateway.test.ts +252 -0
- package/src/tests/chat-sdk-discord-webhook.test.ts +126 -0
- package/src/tests/chat-sdk-fields-sync.test.ts +50 -0
- package/src/tests/chat-sdk-harness.ts +146 -0
- package/src/tests/chat-sdk-inbound.test.ts +363 -0
- package/src/tests/chat-sdk-relay.test.ts +470 -0
- package/src/tests/chat-sdk-reload.test.ts +128 -0
- package/src/tests/chat-sdk-shutdown.test.ts +220 -0
- package/src/tests/chat-sdk-slack.test.ts +268 -0
- package/src/tests/chat-sdk-state.test.ts +163 -0
- package/src/tests/chat-sdk-status-route.test.ts +382 -0
- package/src/tests/chat-sdk-teams.test.ts +277 -0
- package/src/tests/chat-sdk-tools.test.ts +520 -0
- package/src/tests/chat-sdk-typing.test.ts +120 -0
- package/src/tests/chat-sdk-webhook-telegram.test.ts +200 -0
- package/src/tests/claude-adapter-binary.test.ts +9 -4
- package/src/tests/claude-flag-settings.test.ts +11 -3
- package/src/tests/claude-managed-adapter.test.ts +1 -1
- package/src/tests/claude-sdk-lifecycle.test.ts +9 -3
- package/src/tests/claude-thinking-tokens.test.ts +57 -0
- package/src/tests/claude-worker-parity.test.ts +2 -7
- package/src/tests/config-env-export-chat-sdk.test.ts +11 -0
- package/src/tests/config-refs.test.ts +66 -0
- package/src/tests/context-key.test.ts +19 -0
- package/src/tests/cors-allowlist.test.ts +25 -0
- package/src/tests/create-page-tool.test.ts +18 -0
- package/src/tests/credential-check.test.ts +139 -0
- package/src/tests/credentials.test.ts +21 -0
- package/src/tests/db-runtime.test.ts +61 -0
- package/src/tests/db-task-read-contract.test.ts +22 -0
- package/src/tests/db-task-write-contract.test.ts +11 -0
- package/src/tests/deferred-task-wake.test.ts +78 -1
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/enabled-capabilities.test.ts +20 -0
- package/src/tests/entrypoint-api-readiness.test.ts +14 -8
- package/src/tests/entrypoint-config-env-export.test.ts +5 -2
- package/src/tests/entrypoint-export-to-env.test.ts +78 -0
- package/src/tests/env-flag.test.ts +1 -0
- package/src/tests/explicit-model-validation.test.ts +105 -1
- package/src/tests/extensions-catalog.test.ts +1 -0
- package/src/tests/extensions-example-comms-adherence-gate.test.ts +413 -0
- package/src/tests/extensions-example-route-chat-channel.test.ts +154 -0
- package/src/tests/extensions-loader.test.ts +15 -0
- package/src/tests/extensions-post-bridge.test.ts +51 -0
- package/src/tests/fetch-resolved-env.test.ts +128 -0
- package/src/tests/fixtures/chat-sdk/telegram-private-text.json +10 -0
- package/src/tests/fixtures/extensions/route-chat-channel-to-agent/hooks.ts +27 -0
- package/src/tests/fixtures/extensions/route-chat-channel-to-agent/manifest.json +9 -0
- package/src/tests/fixtures/openai-compatible-registry-extension.child.ts +146 -0
- package/src/tests/fixtures/runner-legacy-resume-prompt.ts +122 -0
- package/src/tests/github-handlers.test.ts +35 -0
- package/src/tests/harness-provider-resolution.test.ts +12 -0
- package/src/tests/heartbeat-checklist.test.ts +3 -2
- package/src/tests/heartbeat-jev-gate-credentials.test.ts +168 -0
- package/src/tests/heartbeat-jev-gate.test.ts +385 -0
- package/src/tests/hook-runtime-close.test.ts +0 -2
- package/src/tests/http-api-integration.test.ts +0 -25
- package/src/tests/migration-046-budgets.test.ts +17 -16
- package/src/tests/migration-217-chat-sdk-state.test.ts +113 -0
- package/src/tests/model-profile-backcompat.test.ts +327 -0
- package/src/tests/model-profile-providers.test.ts +302 -0
- package/src/tests/model-profile-runtime-secrets.test.ts +223 -0
- package/src/tests/model-profiles-api.test.ts +614 -0
- package/src/tests/model-tier-resolution.test.ts +93 -0
- package/src/tests/models-catalog.test.ts +42 -1
- package/src/tests/openai-compatible-providers.test.ts +134 -0
- package/src/tests/openai-compatible-registry-extension.test.ts +42 -0
- package/src/tests/opencode-adapter.test.ts +216 -2
- package/src/tests/opencode-helmcode-sdk.test.ts +201 -0
- package/src/tests/opencode-shell-env.test.ts +145 -0
- package/src/tests/openrouter-base-url.test.ts +101 -151
- package/src/tests/page-proxy.test.ts +1 -1
- package/src/tests/pages-browser-sdk.test.ts +76 -0
- package/src/tests/pages-feedback-keys.test.ts +121 -0
- package/src/tests/pages-feedback.test.ts +4 -1
- package/src/tests/paused-tasks-requested-by.test.ts +102 -0
- package/src/tests/pi-context-compaction.test.ts +193 -0
- package/src/tests/pi-custom-provider-fake-server.test.ts +442 -0
- package/src/tests/pi-mono-adapter.test.ts +385 -5
- package/src/tests/pi-shell-env.test.ts +170 -0
- package/src/tests/profile-claim.test.ts +269 -0
- package/src/tests/prompt-template-remaining.test.ts +35 -0
- package/src/tests/quickjs-compat.test.ts +213 -0
- package/src/tests/rbac-engine.test.ts +32 -3
- package/src/tests/runner-exit-after-tasks.test.ts +0 -4
- package/src/tests/runner-legacy-resume-prompt.test.ts +64 -0
- package/src/tests/script-connections.test.ts +6 -0
- package/src/tests/script-executor-conformance.test.ts +252 -1
- package/src/tests/script-executor-quickjs.test.ts +96 -0
- package/src/tests/script-runs-http.test.ts +89 -0
- package/src/tests/scripts-http.test.ts +217 -1
- package/src/tests/scripts-only-gating.test.ts +2 -3
- package/src/tests/scripts-runtime.test.ts +58 -40
- package/src/tests/secret-scrubber.test.ts +96 -0
- package/src/tests/seed-model-profiles.test.ts +174 -0
- package/src/tests/seed-scripts.test.ts +2 -2
- package/src/tests/seed-skills-bundled-files.test.ts +45 -53
- package/src/tests/seed-skills-retire.test.ts +182 -0
- package/src/tests/send-task-requester-gate.test.ts +58 -0
- package/src/tests/session-cost-recompute-unit.test.ts +46 -0
- package/src/tests/skill-get-name-resolution.test.ts +137 -0
- package/src/tests/skill-invocations.test.ts +4 -2
- package/src/tests/slack-blocks.test.ts +36 -0
- package/src/tests/slack-inline-output.test.ts +14 -0
- package/src/tests/slack-reaction-config.test.ts +20 -0
- package/src/tests/slack-render-v2.test.ts +37 -0
- package/src/tests/slack-thread-buffer.test.ts +98 -1
- package/src/tests/sonnet-5-5-registry.test.ts +9 -1
- package/src/tests/swarm-config-export-to-env.test.ts +267 -0
- package/src/tests/swarm-config-reserved-keys.test.ts +16 -0
- package/src/tests/swarm-diff.test.ts +1 -1
- package/src/tests/task-model-effort-rerun.test.ts +164 -0
- package/src/tests/task-session-prompts.test.ts +132 -0
- package/src/tests/task-tool-manifest.test.ts +14 -0
- package/src/tests/task-tools-ctx.test.ts +2 -0
- package/src/tests/tool-annotations.test.ts +6 -6
- package/src/tests/ui-logs-parser.test.ts +43 -0
- package/src/tests/used-by-route.test.ts +6 -0
- package/src/tests/vercel-ai-gateway.test.ts +149 -0
- package/src/tests/workflow-llm.test.ts +61 -0
- package/src/tests/workflow-swarm-script.test.ts +38 -0
- package/src/tests/workflow-wait-filter.test.ts +5 -3
- package/src/tools/chat-access.ts +41 -0
- package/src/tools/chat-open-dm.ts +59 -0
- package/src/tools/chat-post.ts +74 -0
- package/src/tools/chat-read-thread.ts +100 -0
- package/src/tools/chat-reply.ts +75 -0
- package/src/tools/create-page.ts +3 -13
- package/src/tools/model-catalog/index.ts +2 -1
- package/src/tools/model-profiles/list-model-profiles.ts +54 -0
- package/src/tools/register-chat-channel.ts +139 -0
- package/src/tools/request-human-input.ts +11 -3
- package/src/tools/script-apis.ts +5 -1
- package/src/tools/script-upsert.ts +4 -1
- package/src/tools/send-task.ts +48 -1
- package/src/tools/skills/skill-get.ts +17 -9
- package/src/tools/swarm-config/get-config.ts +2 -1
- package/src/tools/swarm-config/list-config.ts +2 -1
- package/src/tools/swarm-config/set-config.ts +16 -3
- package/src/tools/system-one-decide.ts +104 -0
- package/src/tools/task-action.ts +22 -1
- package/src/tools/tool-config.ts +14 -6
- package/src/types.ts +48 -3
- package/src/utils/config-env-export.ts +74 -0
- package/src/utils/credentials.test.ts +92 -0
- package/src/utils/credentials.ts +52 -4
- package/src/utils/harness-provider.ts +15 -6
- package/src/utils/runtime-model-catalog.ts +11 -1
- package/src/utils/secret-scrubber.ts +86 -10
- package/src/utils/task-tool-manifest.ts +19 -2
- package/src/utils/vcs-repo-match.ts +29 -0
- package/src/workflows/executors/raw-llm.ts +8 -3
- package/src/workflows/executors/swarm-script.ts +1 -0
- package/src/workflows/executors/system-one-decision.ts +21 -11
- package/src/workflows/executors/workflow-llm.ts +22 -0
- package/src/workflows/index.ts +21 -12
- package/templates/extensions/README.md +1 -0
- package/templates/extensions/comms-adherence-gate/README.md +88 -0
- package/templates/extensions/comms-adherence-gate/hooks.ts +489 -0
- package/templates/extensions/comms-adherence-gate/manifest.json +8 -0
- package/templates/skills/agent-browser/SKILL.md +1 -1
- package/templates/skills/agent-browser/content.md +1 -1
- package/templates/skills/apps/SKILL.md +8 -1
- package/templates/skills/apps/content.md +8 -1
- package/templates/skills/chat-sdk/config.json +14 -0
- package/templates/skills/chat-sdk/content.md +84 -0
- package/templates/skills/composio-gmail/content.md +7 -0
- package/templates/skills/composio-google-docs/content.md +1 -1
- package/templates/skills/email-domain-health/config.json +14 -0
- package/templates/skills/email-domain-health/content.md +131 -0
- package/templates/skills/kv-storage/content.md +2 -2
- package/templates/skills/pages/content.md +8 -10
- package/templates/skills/swarm-extensions/content.md +2 -0
- package/templates/skills/swarm-scripts/SKILL.md +4 -2
- package/templates/skills/swarm-scripts/config.json +1 -1
- package/templates/skills/swarm-scripts/content.md +4 -2
- package/templates/skills/workflow-iterate/content.md +38 -0
- package/dist/artifact-eczsknc3.js +0 -3843
- package/dist/cli-42qhyvwx.js +0 -33
- package/dist/cli-bd957dgb.js +0 -153
- package/dist/cli-q51yprfq.js +0 -1104
- package/dist/cli-t1ze64h3.js +0 -811
- package/dist/cli-tcc4wd5d.js +0 -56471
- package/dist/index-9ch1n761.js +0 -1102
- package/src/artifact-sdk/index.ts +0 -2
- package/src/artifact-sdk/localtunnel.d.ts +0 -20
- package/src/artifact-sdk/port.ts +0 -12
- package/src/artifact-sdk/server.ts +0 -183
- package/src/artifact-sdk/tunnel.ts +0 -19
- package/src/commands/artifact.ts +0 -249
- package/src/http/ecosystem.ts +0 -77
- package/src/tests/artifact-commands.test.ts +0 -92
- package/src/tests/artifact-sdk.test.ts +0 -793
- package/src/tests/register-service-security.test.ts +0 -194
- package/src/tools/list-services.ts +0 -107
- package/src/tools/register-service.ts +0 -177
- package/src/tools/unregister-service.ts +0 -73
- package/src/tools/update-service-status.ts +0 -96
- package/templates/skills/artifacts/config.json +0 -14
- package/templates/skills/artifacts/content.md +0 -344
- package/templates/skills/artifacts/files/examples/approval-flow.ts +0 -34
- package/templates/skills/artifacts/files/examples/hono-dashboard.ts +0 -31
- package/templates/skills/artifacts/files/examples/multi-artifact.ts +0 -20
- package/templates/skills/artifacts/files/examples/static-report.sh +0 -17
- /package/src/{artifact-sdk → pages}/browser-sdk.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ALL_TOOLS,
|
|
3
3
|
init_tool_config
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-9jzdj90z.js";
|
|
5
5
|
import {
|
|
6
6
|
AgentAvatarSchema,
|
|
7
7
|
CreateTaskOptionsSchema,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
normalizeAssetKey,
|
|
23
23
|
parseAssetKey,
|
|
24
24
|
parseModelTier
|
|
25
|
-
} from "./cli-
|
|
25
|
+
} from "./cli-pe05f8yk.js";
|
|
26
26
|
import {
|
|
27
27
|
IdentityFieldBudgetError,
|
|
28
28
|
checkIdentityFieldBudget,
|
|
@@ -36,22 +36,22 @@ import {
|
|
|
36
36
|
init_profile_sync,
|
|
37
37
|
matchesDefaultClaudeMd,
|
|
38
38
|
matchesDefaultIdentityMd
|
|
39
|
-
} from "./cli-
|
|
40
|
-
import {
|
|
41
|
-
init_steering_enabled,
|
|
42
|
-
isSteeringEnabled
|
|
43
|
-
} from "./cli-7mm2r1kp.js";
|
|
39
|
+
} from "./cli-78vv7446.js";
|
|
44
40
|
import {
|
|
45
41
|
init_config,
|
|
46
42
|
isSlackConfigured
|
|
47
43
|
} from "./cli-dmtrxqhg.js";
|
|
48
44
|
import {
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
init_steering_enabled,
|
|
46
|
+
isSteeringEnabled
|
|
47
|
+
} from "./cli-7mm2r1kp.js";
|
|
51
48
|
import {
|
|
52
49
|
deriveProviderFromKeyType,
|
|
53
50
|
init_credentials
|
|
54
|
-
} from "./cli-
|
|
51
|
+
} from "./cli-x1r545x8.js";
|
|
52
|
+
import {
|
|
53
|
+
init_templates
|
|
54
|
+
} from "./cli-mvzyxwg3.js";
|
|
55
55
|
import {
|
|
56
56
|
configureDbResolver,
|
|
57
57
|
getAllTemplateDefinitions,
|
|
@@ -75,13 +75,9 @@ import {
|
|
|
75
75
|
init_openrouter_base_url
|
|
76
76
|
} from "./cli-a35hzdve.js";
|
|
77
77
|
import {
|
|
78
|
-
harnessModelMismatch,
|
|
79
78
|
init_runtime_model_catalog,
|
|
80
|
-
init_src,
|
|
81
|
-
isAlias,
|
|
82
|
-
parseAlias,
|
|
83
79
|
runtimeHarnessSections
|
|
84
|
-
} from "./cli-
|
|
80
|
+
} from "./cli-stfs0k5s.js";
|
|
85
81
|
import {
|
|
86
82
|
init_zod
|
|
87
83
|
} from "./cli-sd0mxa3c.js";
|
|
@@ -101,7 +97,7 @@ import {
|
|
|
101
97
|
import {
|
|
102
98
|
init_package,
|
|
103
99
|
package_default
|
|
104
|
-
} from "./cli-
|
|
100
|
+
} from "./cli-r35rw5de.js";
|
|
105
101
|
import {
|
|
106
102
|
init_bus,
|
|
107
103
|
realtimeBus
|
|
@@ -116,7 +112,13 @@ import {
|
|
|
116
112
|
registerVolatileSecret,
|
|
117
113
|
scrubObject,
|
|
118
114
|
scrubSecrets
|
|
119
|
-
} from "./cli-
|
|
115
|
+
} from "./cli-shk7r5cs.js";
|
|
116
|
+
import {
|
|
117
|
+
harnessModelMismatch,
|
|
118
|
+
init_src,
|
|
119
|
+
isAlias,
|
|
120
|
+
parseAlias
|
|
121
|
+
} from "./cli-e3g5mbkz.js";
|
|
120
122
|
import {
|
|
121
123
|
__commonJS,
|
|
122
124
|
__esm,
|
|
@@ -8294,6 +8296,26 @@ function slackContextKey(input) {
|
|
|
8294
8296
|
const threadTs = assertSafePart(input.threadTs, "threadTs");
|
|
8295
8297
|
return ["task", "slack", channelId, threadTs].join(SEPARATOR);
|
|
8296
8298
|
}
|
|
8299
|
+
function chatSdkContextKey(threadId) {
|
|
8300
|
+
const raw = typeof threadId === "string" ? threadId : "";
|
|
8301
|
+
const separatorIndex = raw.indexOf(SEPARATOR);
|
|
8302
|
+
if (separatorIndex <= 0 || separatorIndex === raw.length - 1) {
|
|
8303
|
+
throw new Error(`context-key: chat-sdk thread id must be "<adapter>:<id>" (got ${JSON.stringify(threadId)})`);
|
|
8304
|
+
}
|
|
8305
|
+
const adapter = assertSafePart(raw.slice(0, separatorIndex), "adapter");
|
|
8306
|
+
const rest = encodeURIComponent(raw.slice(separatorIndex + 1));
|
|
8307
|
+
return ["task", "chat-sdk", adapter, rest].join(SEPARATOR);
|
|
8308
|
+
}
|
|
8309
|
+
function chatThreadOfContextKey(key) {
|
|
8310
|
+
if (!key)
|
|
8311
|
+
return null;
|
|
8312
|
+
try {
|
|
8313
|
+
const parsed = parseContextKey(key);
|
|
8314
|
+
return parsed.family === "chat-sdk" ? parsed.parts : null;
|
|
8315
|
+
} catch {
|
|
8316
|
+
return null;
|
|
8317
|
+
}
|
|
8318
|
+
}
|
|
8297
8319
|
function agentmailContextKey(input) {
|
|
8298
8320
|
const threadId = assertSafePart(input.threadId, "threadId");
|
|
8299
8321
|
return ["task", "agentmail", threadId].join(SEPARATOR);
|
|
@@ -8388,6 +8410,19 @@ function parseContextKey(key) {
|
|
|
8388
8410
|
}
|
|
8389
8411
|
return { family: "agentmail", parts: { threadId: parts[2] } };
|
|
8390
8412
|
}
|
|
8413
|
+
case "chat-sdk": {
|
|
8414
|
+
if (parts.length !== 4 || !parts[2] || !parts[3]) {
|
|
8415
|
+
throw new Error(`context-key: malformed chat-sdk key: ${JSON.stringify(key)}`);
|
|
8416
|
+
}
|
|
8417
|
+
const adapter = parts[2];
|
|
8418
|
+
let rest;
|
|
8419
|
+
try {
|
|
8420
|
+
rest = decodeURIComponent(parts[3]);
|
|
8421
|
+
} catch {
|
|
8422
|
+
throw new Error(`context-key: malformed chat-sdk key: ${JSON.stringify(key)}`);
|
|
8423
|
+
}
|
|
8424
|
+
return { family: "chat-sdk", parts: { adapter, threadId: `${adapter}:${rest}` } };
|
|
8425
|
+
}
|
|
8391
8426
|
case "schedule": {
|
|
8392
8427
|
if (parts.length !== 3) {
|
|
8393
8428
|
throw new Error(`context-key: malformed schedule key: ${JSON.stringify(key)}`);
|
|
@@ -12222,7 +12257,20 @@ function initDb(dbPath = "./agent-swarm-db.sqlite") {
|
|
|
12222
12257
|
}
|
|
12223
12258
|
db = new Database(dbPath, { create: true });
|
|
12224
12259
|
console.log(`Database initialized at ${dbPath}`);
|
|
12225
|
-
const
|
|
12260
|
+
const opened = db;
|
|
12261
|
+
try {
|
|
12262
|
+
return bootOpenedDb(opened, dbPath, resolvePromptTemplate, autoEncryptLegacyPlaintextSecrets);
|
|
12263
|
+
} catch (error2) {
|
|
12264
|
+
if (db === opened) {
|
|
12265
|
+
db = null;
|
|
12266
|
+
try {
|
|
12267
|
+
opened.close();
|
|
12268
|
+
} catch {}
|
|
12269
|
+
}
|
|
12270
|
+
throw error2;
|
|
12271
|
+
}
|
|
12272
|
+
}
|
|
12273
|
+
function bootOpenedDb(database, dbPath, resolvePromptTemplate, autoEncryptLegacyPlaintextSecrets) {
|
|
12226
12274
|
database.run("PRAGMA journal_mode = WAL;");
|
|
12227
12275
|
database.run("PRAGMA busy_timeout = 5000;");
|
|
12228
12276
|
database.run("PRAGMA foreign_keys = ON;");
|
|
@@ -12244,20 +12292,20 @@ function initDb(dbPath = "./agent-swarm-db.sqlite") {
|
|
|
12244
12292
|
}
|
|
12245
12293
|
ensureAgentProfileColumns(database);
|
|
12246
12294
|
try {
|
|
12247
|
-
const taskSchemaInfo =
|
|
12295
|
+
const taskSchemaInfo = database.prepare("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'agent_tasks'").get();
|
|
12248
12296
|
const schemaSql = taskSchemaInfo?.sql ?? "";
|
|
12249
12297
|
const hasStatusCheck = /status\s+TEXT\b[^,]*\bCHECK\s*\(\s*status\s+IN\s*\(/i.test(schemaSql);
|
|
12250
12298
|
const statusAllowsCancelled = /status\s+IN\s*\([^)]*'cancelled'/i.test(schemaSql);
|
|
12251
12299
|
const needsStatusMigration = hasStatusCheck && !statusAllowsCancelled;
|
|
12252
12300
|
if (needsStatusMigration) {
|
|
12253
12301
|
console.log("[Migration] Removing restrictive CHECK constraint on agent_tasks.status");
|
|
12254
|
-
|
|
12302
|
+
database.run("PRAGMA foreign_keys=off");
|
|
12255
12303
|
const rebuiltSchemaSql = schemaSql.replace(/^(CREATE TABLE\s+(?:IF NOT EXISTS\s+)?)(?:"agent_tasks"|agent_tasks)/i, "$1agent_tasks_new").replace(/\s+CHECK\s*\(\s*status\s+IN\s*\([^)]*\)\s*\)/i, "");
|
|
12256
12304
|
if (rebuiltSchemaSql === schemaSql || !/agent_tasks_new/i.test(rebuiltSchemaSql)) {
|
|
12257
12305
|
throw new Error("Could not derive agent_tasks schema without legacy status CHECK");
|
|
12258
12306
|
}
|
|
12259
|
-
const columns =
|
|
12260
|
-
const schemaObjects =
|
|
12307
|
+
const columns = database.prepare('PRAGMA table_info("agent_tasks")').all().map((column) => `"${column.name.replaceAll('"', '""')}"`).join(", ");
|
|
12308
|
+
const schemaObjects = database.prepare(`SELECT sql FROM sqlite_master
|
|
12261
12309
|
WHERE tbl_name = 'agent_tasks'
|
|
12262
12310
|
AND type IN ('index', 'trigger')
|
|
12263
12311
|
AND sql IS NOT NULL
|
|
@@ -12271,13 +12319,13 @@ function initDb(dbPath = "./agent-swarm-db.sqlite") {
|
|
|
12271
12319
|
for (const sql of schemaObjects)
|
|
12272
12320
|
database.run(sql);
|
|
12273
12321
|
})();
|
|
12274
|
-
|
|
12322
|
+
database.run("PRAGMA foreign_keys=on");
|
|
12275
12323
|
console.log("[Migration] Successfully removed CHECK constraint on agent_tasks.status");
|
|
12276
12324
|
}
|
|
12277
12325
|
} catch (e) {
|
|
12278
12326
|
console.error("[Migration] Failed to update agent_tasks CHECK constraint:", e);
|
|
12279
12327
|
try {
|
|
12280
|
-
|
|
12328
|
+
database.run("PRAGMA foreign_keys=on");
|
|
12281
12329
|
} catch (cleanupError) {
|
|
12282
12330
|
console.error("[Migration] Failed to re-enable SQLite foreign_keys pragma:", cleanupError);
|
|
12283
12331
|
}
|
|
@@ -12318,7 +12366,7 @@ function initDb(dbPath = "./agent-swarm-db.sqlite") {
|
|
|
12318
12366
|
console.error(`[credential-bindings] FATAL: failed to migrate legacy credential binding blob: ${err.message}`);
|
|
12319
12367
|
throw err;
|
|
12320
12368
|
}
|
|
12321
|
-
return
|
|
12369
|
+
return database;
|
|
12322
12370
|
}
|
|
12323
12371
|
function getDb(path3) {
|
|
12324
12372
|
if (!db) {
|
|
@@ -12394,7 +12442,7 @@ var init_runtime = __esm(() => {
|
|
|
12394
12442
|
// src/telemetry-identity.ts
|
|
12395
12443
|
async function loadUserRole(userId) {
|
|
12396
12444
|
try {
|
|
12397
|
-
const { getUserGrant } = await import("./rbac-roles-
|
|
12445
|
+
const { getUserGrant } = await import("./rbac-roles-z76xv0hq.js");
|
|
12398
12446
|
const grant = await getUserGrant(userId);
|
|
12399
12447
|
const role = grant.grantsAll ? "admin" : "member";
|
|
12400
12448
|
if (roleCache.size >= ROLE_CACHE_LIMIT) {
|
|
@@ -12554,6 +12602,47 @@ var init_codex_auth_failure = __esm(() => {
|
|
|
12554
12602
|
];
|
|
12555
12603
|
});
|
|
12556
12604
|
|
|
12605
|
+
// src/utils/config-env-export.ts
|
|
12606
|
+
function isEnvExportRestrictedKey(key) {
|
|
12607
|
+
return ENV_EXPORT_RESTRICTED_KEYS.has(key.toUpperCase()) || CONNECTION_SECRET_KEY.test(key);
|
|
12608
|
+
}
|
|
12609
|
+
function defaultExportToEnv(key) {
|
|
12610
|
+
const upper = key.toUpperCase();
|
|
12611
|
+
return !isEnvExportRestrictedKey(key) && !ENV_EXPORT_DEFAULT_OFF_KEYS.has(upper) && !ENV_EXPORT_DEFAULT_OFF_PREFIXES.some((prefix) => upper.startsWith(prefix));
|
|
12612
|
+
}
|
|
12613
|
+
function envExportRestrictedError(key) {
|
|
12614
|
+
return `Key '${key}' is read only by the API server and can never be exported to agent env; store it with exportToEnv: false.`;
|
|
12615
|
+
}
|
|
12616
|
+
function effectiveExportToEnv(key, stored) {
|
|
12617
|
+
return stored && !isEnvExportRestrictedKey(key);
|
|
12618
|
+
}
|
|
12619
|
+
var ENV_EXPORT_RESTRICTED_KEYS, ENV_EXPORT_DEFAULT_OFF_KEYS, CONNECTION_SECRET_KEY, ENV_EXPORT_DEFAULT_OFF_PREFIXES;
|
|
12620
|
+
var init_config_env_export = __esm(() => {
|
|
12621
|
+
ENV_EXPORT_RESTRICTED_KEYS = new Set([
|
|
12622
|
+
"SLACK_APP_TOKEN",
|
|
12623
|
+
"SLACK_SIGNING_SECRET",
|
|
12624
|
+
"GITHUB_APP_PRIVATE_KEY",
|
|
12625
|
+
"GITHUB_WEBHOOK_SECRET",
|
|
12626
|
+
"GITLAB_WEBHOOK_SECRET",
|
|
12627
|
+
"LINEAR_CLIENT_SECRET",
|
|
12628
|
+
"LINEAR_SIGNING_SECRET",
|
|
12629
|
+
"JIRA_CLIENT_SECRET",
|
|
12630
|
+
"JIRA_WEBHOOK_TOKEN",
|
|
12631
|
+
"AZURE_DEVOPS_WEBHOOK_SECRET",
|
|
12632
|
+
"AGENTMAIL_WEBHOOK_SECRET",
|
|
12633
|
+
"API_AGENT_FS_API_KEY"
|
|
12634
|
+
]);
|
|
12635
|
+
ENV_EXPORT_DEFAULT_OFF_KEYS = new Set([
|
|
12636
|
+
"KAPSO_WEBHOOK_HMAC_SECRET",
|
|
12637
|
+
"SENTRY_TEST_APP_WEBHOOK_SECRET",
|
|
12638
|
+
"TELEMETRY_CH_AUTH",
|
|
12639
|
+
"HACK_AGENT_FS_ADMIN_KEY",
|
|
12640
|
+
"X_CLIENT_SECRET"
|
|
12641
|
+
]);
|
|
12642
|
+
CONNECTION_SECRET_KEY = /^connection\..+\.secret$/;
|
|
12643
|
+
ENV_EXPORT_DEFAULT_OFF_PREFIXES = ["CHAT_SDK_"];
|
|
12644
|
+
});
|
|
12645
|
+
|
|
12557
12646
|
// src/utils/config-secrets.ts
|
|
12558
12647
|
var MASKED_SECRET_VALUE = "********";
|
|
12559
12648
|
var init_config_secrets = () => {};
|
|
@@ -13145,198 +13234,24 @@ var init_context_versions = __esm(() => {
|
|
|
13145
13234
|
init_runtime();
|
|
13146
13235
|
});
|
|
13147
13236
|
|
|
13148
|
-
// src/
|
|
13149
|
-
function
|
|
13150
|
-
return
|
|
13151
|
-
WHEN ${HUMAN_FREE_BASE_SQL} THEN 1
|
|
13152
|
-
WHEN ${parentFlag} = 1 AND ${UNATTRIBUTED_SQL} THEN 1
|
|
13153
|
-
ELSE 0
|
|
13154
|
-
END`;
|
|
13155
|
-
}
|
|
13156
|
-
function carriesHumanFreeTag(tagsJson) {
|
|
13157
|
-
const haystack = (tagsJson ?? "[]").toLowerCase();
|
|
13158
|
-
return HUMAN_FREE_TAGS.some((tag) => haystack.includes(`"${tag}"`));
|
|
13159
|
-
}
|
|
13160
|
-
function tagWriteChangesHumanFree(previousTagsJson, nextTagsJson) {
|
|
13161
|
-
return carriesHumanFreeTag(previousTagsJson) !== carriesHumanFreeTag(nextTagsJson);
|
|
13162
|
-
}
|
|
13163
|
-
async function classifyTaskHumanFree(input) {
|
|
13164
|
-
const row = await getDbClient().get(`WITH task(taskType, tags, source, requestedByUserId, requestedByUserIdInherited, parentTaskId, workflowRunId) AS (
|
|
13165
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
13166
|
-
)
|
|
13167
|
-
SELECT ${humanFreeCase("parent.isHumanFree")} AS humanFree
|
|
13168
|
-
FROM task
|
|
13169
|
-
LEFT JOIN agent_tasks parent ON parent.id = task.parentTaskId`, [
|
|
13170
|
-
input.taskType ?? null,
|
|
13171
|
-
input.tags ?? null,
|
|
13172
|
-
input.source ?? null,
|
|
13173
|
-
input.requestedByUserId ?? null,
|
|
13174
|
-
input.requestedByUserIdInherited ? 1 : 0,
|
|
13175
|
-
input.parentTaskId ?? null,
|
|
13176
|
-
input.workflowRunId ?? null
|
|
13177
|
-
]);
|
|
13178
|
-
return row?.humanFree === 1;
|
|
13179
|
-
}
|
|
13180
|
-
function setHumanFreeQueueListener(listener) {
|
|
13181
|
-
queueListener = listener;
|
|
13182
|
-
}
|
|
13183
|
-
async function enqueueHumanFreeWork(taskIds, scope, hops) {
|
|
13184
|
-
if (taskIds.length === 0)
|
|
13185
|
-
return;
|
|
13186
|
-
if (hops > HUMAN_FREE_MAX_CONTINUATION_HOPS) {
|
|
13187
|
-
console.error(`[human-free] dropping ${taskIds.length} ${scope} continuation(s) past ${HUMAN_FREE_MAX_CONTINUATION_HOPS} hops; the task graph likely has a parent cycle`);
|
|
13188
|
-
return;
|
|
13189
|
-
}
|
|
13190
|
-
await getDbClient().run(`INSERT INTO human_free_reclassify_queue (taskId, scope, afterRowid, hops)
|
|
13191
|
-
SELECT value, ?, 0, ? FROM json_each(?) WHERE true
|
|
13192
|
-
ON CONFLICT (taskId, scope) DO UPDATE SET
|
|
13193
|
-
afterRowid = 0,
|
|
13194
|
-
hops = MAX(hops, excluded.hops)`, [scope, hops, JSON.stringify(taskIds)]);
|
|
13195
|
-
getDbClient().afterCommit(() => queueListener?.());
|
|
13196
|
-
}
|
|
13197
|
-
async function reclassifyBatch(seedTaskIds, batchSize, hops) {
|
|
13198
|
-
const client = getDbClient();
|
|
13199
|
-
const affected = (await client.query(`WITH RECURSIVE affected(id) AS (
|
|
13200
|
-
SELECT value FROM json_each(?)
|
|
13201
|
-
|
|
13202
|
-
UNION
|
|
13203
|
-
|
|
13204
|
-
SELECT task.id
|
|
13205
|
-
FROM affected
|
|
13206
|
-
JOIN agent_tasks task ON task.parentTaskId = affected.id
|
|
13207
|
-
LIMIT ?
|
|
13208
|
-
)
|
|
13209
|
-
SELECT id FROM affected`, [JSON.stringify(seedTaskIds), batchSize])).map((row) => row.id);
|
|
13210
|
-
const result = await client.run(`WITH RECURSIVE affected(id) AS (
|
|
13211
|
-
SELECT value FROM json_each(?)
|
|
13212
|
-
),
|
|
13213
|
-
free(id) AS (
|
|
13214
|
-
SELECT task.id
|
|
13215
|
-
FROM agent_tasks task
|
|
13216
|
-
LEFT JOIN agent_tasks parent ON parent.id = task.parentTaskId
|
|
13217
|
-
WHERE task.id IN (SELECT id FROM affected)
|
|
13218
|
-
AND (
|
|
13219
|
-
${HUMAN_FREE_BASE_SQL}
|
|
13220
|
-
OR (
|
|
13221
|
-
parent.isHumanFree = 1
|
|
13222
|
-
AND parent.id NOT IN (SELECT id FROM affected)
|
|
13223
|
-
AND ${UNATTRIBUTED_SQL}
|
|
13224
|
-
)
|
|
13225
|
-
)
|
|
13226
|
-
|
|
13227
|
-
UNION
|
|
13228
|
-
|
|
13229
|
-
SELECT task.id
|
|
13230
|
-
FROM free
|
|
13231
|
-
JOIN agent_tasks task ON task.parentTaskId = free.id
|
|
13232
|
-
WHERE +task.id IN (SELECT id FROM affected)
|
|
13233
|
-
AND ${UNATTRIBUTED_SQL}
|
|
13234
|
-
)
|
|
13235
|
-
UPDATE agent_tasks
|
|
13236
|
-
SET isHumanFree = CASE WHEN id IN (SELECT id FROM free) THEN 1 ELSE 0 END
|
|
13237
|
-
WHERE id IN (SELECT id FROM affected)
|
|
13238
|
-
AND isHumanFree != CASE WHEN id IN (SELECT id FROM free) THEN 1 ELSE 0 END`, [JSON.stringify(affected)]);
|
|
13239
|
-
if (affected.length >= batchSize) {
|
|
13240
|
-
const unfinished = await client.query(`WITH batch(id) AS (
|
|
13241
|
-
SELECT value FROM json_each(?)
|
|
13242
|
-
)
|
|
13243
|
-
SELECT batch.id
|
|
13244
|
-
FROM batch
|
|
13245
|
-
WHERE EXISTS (
|
|
13246
|
-
SELECT 1
|
|
13247
|
-
FROM agent_tasks child
|
|
13248
|
-
WHERE child.parentTaskId = batch.id
|
|
13249
|
-
AND child.id NOT IN (SELECT id FROM batch)
|
|
13250
|
-
)`, [JSON.stringify(affected)]);
|
|
13251
|
-
await enqueueHumanFreeWork(unfinished.map((row) => row.id), "children", hops);
|
|
13252
|
-
}
|
|
13253
|
-
return result.changes;
|
|
13254
|
-
}
|
|
13255
|
-
async function reclassifyTaskHumanFree(seedTaskIds, options = {}) {
|
|
13256
|
-
const batchSize = options.batchSize ?? HUMAN_FREE_RECLASSIFY_BATCH;
|
|
13257
|
-
const seeds = [...new Set(seedTaskIds)];
|
|
13258
|
-
if (seeds.length === 0)
|
|
13259
|
-
return 0;
|
|
13260
|
-
await enqueueHumanFreeWork(seeds.slice(batchSize), "self", 1);
|
|
13261
|
-
return await reclassifyBatch(seeds.slice(0, batchSize), batchSize, 1);
|
|
13262
|
-
}
|
|
13263
|
-
async function drainOneBatch(batchSize) {
|
|
13264
|
-
return await getDbClient().transaction(async (tx) => {
|
|
13265
|
-
const head = await tx.get("SELECT * FROM human_free_reclassify_queue ORDER BY seq LIMIT 1");
|
|
13266
|
-
if (!head)
|
|
13267
|
-
return null;
|
|
13268
|
-
if (head.scope === "self") {
|
|
13269
|
-
const rows = await tx.query("SELECT * FROM human_free_reclassify_queue WHERE scope = 'self' ORDER BY seq LIMIT ?", [batchSize]);
|
|
13270
|
-
const seeds = rows.map((row) => row.taskId);
|
|
13271
|
-
const hops = Math.max(...rows.map((row) => row.hops)) + 1;
|
|
13272
|
-
await tx.run("DELETE FROM human_free_reclassify_queue WHERE seq IN (SELECT value FROM json_each(?))", [JSON.stringify(rows.map((row) => row.seq))]);
|
|
13273
|
-
return await reclassifyBatch(seeds, batchSize, hops);
|
|
13274
|
-
}
|
|
13275
|
-
const page = await tx.query(`SELECT id, rowid AS position
|
|
13276
|
-
FROM agent_tasks
|
|
13277
|
-
WHERE parentTaskId = ? AND rowid > ?
|
|
13278
|
-
ORDER BY rowid
|
|
13279
|
-
LIMIT ?`, [head.taskId, head.afterRowid, batchSize]);
|
|
13280
|
-
if (page.length < batchSize) {
|
|
13281
|
-
await tx.run("DELETE FROM human_free_reclassify_queue WHERE seq = ?", [head.seq]);
|
|
13282
|
-
} else {
|
|
13283
|
-
await tx.run("UPDATE human_free_reclassify_queue SET afterRowid = ? WHERE seq = ?", [
|
|
13284
|
-
page[page.length - 1]?.position ?? head.afterRowid,
|
|
13285
|
-
head.seq
|
|
13286
|
-
]);
|
|
13287
|
-
}
|
|
13288
|
-
if (page.length === 0)
|
|
13289
|
-
return 0;
|
|
13290
|
-
return await reclassifyBatch(page.map((row) => row.id), batchSize, head.hops + 1);
|
|
13291
|
-
});
|
|
13237
|
+
// src/utils/vcs-repo-match.ts
|
|
13238
|
+
function normalizeVcsRepo(vcsRepo) {
|
|
13239
|
+
return vcsRepo.trim().replace(/\/+$/, "").replace(/\.git$/, "");
|
|
13292
13240
|
}
|
|
13293
|
-
|
|
13294
|
-
const
|
|
13295
|
-
return
|
|
13241
|
+
function vcsRepoName(vcsRepo) {
|
|
13242
|
+
const requested = normalizeVcsRepo(vcsRepo);
|
|
13243
|
+
return requested.split("/").pop() || requested;
|
|
13296
13244
|
}
|
|
13297
|
-
|
|
13298
|
-
const
|
|
13299
|
-
const
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
break;
|
|
13306
|
-
batches += 1;
|
|
13307
|
-
changed += batchChanged;
|
|
13308
|
-
}
|
|
13309
|
-
return { batches, changed, remaining: await pendingHumanFreeReclassifications() };
|
|
13245
|
+
function vcsRepoUrlMatches(url, vcsRepo) {
|
|
13246
|
+
const requested = normalizeVcsRepo(vcsRepo);
|
|
13247
|
+
const normalized = normalizeVcsRepo(url);
|
|
13248
|
+
if (normalized === requested)
|
|
13249
|
+
return true;
|
|
13250
|
+
if (requested.includes(":"))
|
|
13251
|
+
return false;
|
|
13252
|
+
return normalized.endsWith(`/${requested}`) || normalized.endsWith(`:${requested}`);
|
|
13310
13253
|
}
|
|
13311
|
-
var
|
|
13312
|
-
var init_human_free = __esm(() => {
|
|
13313
|
-
init_runtime();
|
|
13314
|
-
HUMAN_FREE_TAGS = ["heartbeat"];
|
|
13315
|
-
HUMAN_FREE_TAG_SQL = HUMAN_FREE_TAGS.map((tag) => `COALESCE(task.tags, '[]') LIKE '%"${tag}"%'`).join(`
|
|
13316
|
-
OR `);
|
|
13317
|
-
HUMAN_FREE_BASE_SQL = `(
|
|
13318
|
-
COALESCE(task.taskType, '') IN ('heartbeat', 'heartbeat-checklist', 'boot-triage')
|
|
13319
|
-
OR ${HUMAN_FREE_TAG_SQL}
|
|
13320
|
-
OR (COALESCE(task.source, '') = 'schedule' AND task.requestedByUserId IS NULL)
|
|
13321
|
-
OR (
|
|
13322
|
-
task.parentTaskId IS NULL
|
|
13323
|
-
AND COALESCE(task.source, '') = 'workflow'
|
|
13324
|
-
AND task.requestedByUserId IS NULL
|
|
13325
|
-
AND EXISTS (
|
|
13326
|
-
SELECT 1
|
|
13327
|
-
FROM workflow_runs run
|
|
13328
|
-
WHERE run.id = task.workflowRunId
|
|
13329
|
-
AND run.triggerType = 'schedule'
|
|
13330
|
-
AND run.created_by IS NULL
|
|
13331
|
-
)
|
|
13332
|
-
)
|
|
13333
|
-
OR (
|
|
13334
|
-
COALESCE(task.source, '') = 'system'
|
|
13335
|
-
AND parent.id IS NOT NULL
|
|
13336
|
-
AND parent.requestedByUserId IS NULL
|
|
13337
|
-
)
|
|
13338
|
-
)`;
|
|
13339
|
-
});
|
|
13254
|
+
var init_vcs_repo_match = () => {};
|
|
13340
13255
|
|
|
13341
13256
|
// src/utils/provider-metadata.ts
|
|
13342
13257
|
function parseProviderMeta(rawProvider, rawMeta) {
|
|
@@ -13436,6 +13351,9 @@ function rowToAgentTask(row) {
|
|
|
13436
13351
|
modelSource: row.modelSource ?? undefined,
|
|
13437
13352
|
modelAlias: row.modelAlias ?? undefined,
|
|
13438
13353
|
effort: ReasoningEffortSchema.safeParse(row.effort).success ? row.effort : undefined,
|
|
13354
|
+
resolvedEffort: ReasoningEffortSchema.safeParse(row.resolvedEffort).success ? row.resolvedEffort : undefined,
|
|
13355
|
+
profile: row.profile ?? undefined,
|
|
13356
|
+
resolvedProfile: row.resolvedProfile ?? undefined,
|
|
13439
13357
|
scheduleId: row.scheduleId ?? undefined,
|
|
13440
13358
|
workflowRunId: row.workflowRunId ?? undefined,
|
|
13441
13359
|
workflowRunStepId: row.workflowRunStepId ?? undefined,
|
|
@@ -13492,6 +13410,7 @@ function rowToAgentTaskSummary(row) {
|
|
|
13492
13410
|
modelSource: row.modelSource ?? undefined,
|
|
13493
13411
|
modelAlias: row.modelAlias ?? undefined,
|
|
13494
13412
|
effort: ReasoningEffortSchema.safeParse(row.effort).success ? row.effort : undefined,
|
|
13413
|
+
resolvedEffort: ReasoningEffortSchema.safeParse(row.resolvedEffort).success ? row.resolvedEffort : undefined,
|
|
13495
13414
|
provider: row.provider ?? undefined,
|
|
13496
13415
|
requestedByUserId: row.requestedByUserId ?? undefined,
|
|
13497
13416
|
progress: row.progress ?? undefined,
|
|
@@ -13864,24 +13783,96 @@ async function markFinalizedSlackRelaysDelivered() {
|
|
|
13864
13783
|
)`, [now, now]);
|
|
13865
13784
|
return result.changes;
|
|
13866
13785
|
}
|
|
13867
|
-
async function
|
|
13868
|
-
|
|
13869
|
-
|
|
13870
|
-
|
|
13871
|
-
|
|
13872
|
-
|
|
13873
|
-
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
|
|
13879
|
-
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
|
|
13883
|
-
|
|
13884
|
-
|
|
13786
|
+
async function getPendingChatRelayTasks(now = Date.now(), limit2 = 200, adapters = []) {
|
|
13787
|
+
if (adapters.length === 0)
|
|
13788
|
+
return [];
|
|
13789
|
+
for (const adapter of adapters) {
|
|
13790
|
+
if (!/^[a-z]+$/.test(adapter))
|
|
13791
|
+
throw new Error(`invalid chat adapter name: ${adapter}`);
|
|
13792
|
+
}
|
|
13793
|
+
const adapterFilter = adapters.map(() => "task.contextKey GLOB ?").join(" OR ");
|
|
13794
|
+
const rows = await getDbClient().query(`SELECT task.*,
|
|
13795
|
+
obligation.created_at AS relay_created_at,
|
|
13796
|
+
obligation.last_error AS relay_last_error
|
|
13797
|
+
FROM chat_relay_obligations obligation
|
|
13798
|
+
JOIN agent_tasks task ON task.id = obligation.task_id
|
|
13799
|
+
WHERE obligation.delivered_at IS NULL
|
|
13800
|
+
AND obligation.given_up_at IS NULL
|
|
13801
|
+
AND task.status IN ('completed', 'failed', 'cancelled')
|
|
13802
|
+
AND (${adapterFilter})
|
|
13803
|
+
AND ${CHAT_RELAY_ELIGIBLE_SQL}
|
|
13804
|
+
ORDER BY obligation.last_attempt_at IS NOT NULL,
|
|
13805
|
+
obligation.last_attempt_at ASC,
|
|
13806
|
+
obligation.created_at ASC
|
|
13807
|
+
LIMIT ?`, [
|
|
13808
|
+
...adapters.map((adapter) => `task:chat-sdk:${adapter}:*`),
|
|
13809
|
+
new Date(now).toISOString(),
|
|
13810
|
+
limit2
|
|
13811
|
+
]);
|
|
13812
|
+
return rows.map((row) => ({
|
|
13813
|
+
task: rowToAgentTask(row),
|
|
13814
|
+
createdAt: row.relay_created_at,
|
|
13815
|
+
lastError: row.relay_last_error
|
|
13816
|
+
}));
|
|
13817
|
+
}
|
|
13818
|
+
async function giveUpStaleChatRelays(now, olderThanMs) {
|
|
13819
|
+
const at = new Date(now).toISOString();
|
|
13820
|
+
const cutoff = new Date(now - olderThanMs).toISOString();
|
|
13821
|
+
const result = await getDbClient().run(`UPDATE chat_relay_obligations
|
|
13822
|
+
SET given_up_at = ?, last_error = 'gave up: older than 24h', updated_at = ?
|
|
13823
|
+
WHERE delivered_at IS NULL AND given_up_at IS NULL AND created_at < ?`, [at, at, cutoff]);
|
|
13824
|
+
return result.changes;
|
|
13825
|
+
}
|
|
13826
|
+
async function markChatRelayAttempted(taskId, now = Date.now()) {
|
|
13827
|
+
const at = new Date(now).toISOString();
|
|
13828
|
+
const result = await getDbClient().run(`UPDATE chat_relay_obligations AS obligation
|
|
13829
|
+
SET attempt_count = attempt_count + 1,
|
|
13830
|
+
last_attempt_at = ?,
|
|
13831
|
+
updated_at = ?
|
|
13832
|
+
WHERE task_id = ?
|
|
13833
|
+
AND delivered_at IS NULL
|
|
13834
|
+
AND given_up_at IS NULL
|
|
13835
|
+
AND ${CHAT_RELAY_ELIGIBLE_SQL}`, [at, at, taskId, at]);
|
|
13836
|
+
return result.changes > 0;
|
|
13837
|
+
}
|
|
13838
|
+
async function recordChatRelayError(taskId, error2, now = Date.now()) {
|
|
13839
|
+
const result = await getDbClient().run(`UPDATE chat_relay_obligations
|
|
13840
|
+
SET last_error = ?, updated_at = ?
|
|
13841
|
+
WHERE task_id = ? AND delivered_at IS NULL`, [scrubSecrets(error2), new Date(now).toISOString(), taskId]);
|
|
13842
|
+
return result.changes > 0;
|
|
13843
|
+
}
|
|
13844
|
+
async function markChatRelayDelivered(taskId, now = Date.now()) {
|
|
13845
|
+
const at = new Date(now).toISOString();
|
|
13846
|
+
const result = await getDbClient().run(`UPDATE chat_relay_obligations
|
|
13847
|
+
SET delivered_at = ?, updated_at = ?
|
|
13848
|
+
WHERE task_id = ? AND delivered_at IS NULL`, [at, at, taskId]);
|
|
13849
|
+
return result.changes > 0;
|
|
13850
|
+
}
|
|
13851
|
+
async function markChatRelayGivenUp(taskId, error2, now = Date.now()) {
|
|
13852
|
+
const at = new Date(now).toISOString();
|
|
13853
|
+
const result = await getDbClient().run(`UPDATE chat_relay_obligations
|
|
13854
|
+
SET given_up_at = ?, last_error = ?, updated_at = ?
|
|
13855
|
+
WHERE task_id = ? AND delivered_at IS NULL AND given_up_at IS NULL`, [at, scrubSecrets(error2), at, taskId]);
|
|
13856
|
+
return result.changes > 0;
|
|
13857
|
+
}
|
|
13858
|
+
async function getRecentlyFinishedWorkerTasks() {
|
|
13859
|
+
const rows = await getDbClient().query(`SELECT t.* FROM agent_tasks t
|
|
13860
|
+
LEFT JOIN agents a ON t.agentId = a.id
|
|
13861
|
+
WHERE t.status IN ('completed', 'failed')
|
|
13862
|
+
AND t.finishedAt IS NOT NULL
|
|
13863
|
+
AND t.notifiedAt IS NULL
|
|
13864
|
+
AND (a.isLead = 0 OR a.isLead IS NULL)
|
|
13865
|
+
ORDER BY t.finishedAt DESC LIMIT 50`);
|
|
13866
|
+
return rows.map(rowToAgentTask);
|
|
13867
|
+
}
|
|
13868
|
+
async function markTasksNotified(taskIds) {
|
|
13869
|
+
if (taskIds.length === 0)
|
|
13870
|
+
return 0;
|
|
13871
|
+
const now = new Date().toISOString();
|
|
13872
|
+
const placeholders = taskIds.map(() => "?").join(",");
|
|
13873
|
+
const result = await getDbClient().run(`UPDATE agent_tasks SET notifiedAt = ?
|
|
13874
|
+
WHERE id IN (${placeholders}) AND notifiedAt IS NULL`, [now, ...taskIds]);
|
|
13875
|
+
return result.changes;
|
|
13885
13876
|
}
|
|
13886
13877
|
async function resetTasksNotified(taskIds) {
|
|
13887
13878
|
if (taskIds.length === 0)
|
|
@@ -14035,6 +14026,36 @@ async function getLatestLeadTaskInThread(channelId, threadTs) {
|
|
|
14035
14026
|
LIMIT 1`, [channelId, threadTs]);
|
|
14036
14027
|
return row ? rowToAgentTask(row) : null;
|
|
14037
14028
|
}
|
|
14029
|
+
async function getAgentWorkingOnContextKey(contextKey, source2) {
|
|
14030
|
+
const taskRow = await getDbClient().get(`SELECT agentId FROM agent_tasks
|
|
14031
|
+
WHERE contextKey = ?
|
|
14032
|
+
AND (? IS NULL OR source = ?)
|
|
14033
|
+
ORDER BY createdAt DESC, rowid DESC
|
|
14034
|
+
LIMIT 1`, [contextKey, source2 ?? null, source2 ?? null]);
|
|
14035
|
+
if (taskRow?.agentId)
|
|
14036
|
+
return getAgentById(taskRow.agentId);
|
|
14037
|
+
return null;
|
|
14038
|
+
}
|
|
14039
|
+
async function getLatestActiveTaskByContextKey(contextKey, source2) {
|
|
14040
|
+
const row = await getDbClient().get(`SELECT * FROM agent_tasks
|
|
14041
|
+
WHERE contextKey = ?
|
|
14042
|
+
AND (? IS NULL OR source = ?)
|
|
14043
|
+
AND status IN ('in_progress', 'pending')
|
|
14044
|
+
ORDER BY createdAt DESC, rowid DESC
|
|
14045
|
+
LIMIT 1`, [contextKey, source2 ?? null, source2 ?? null]);
|
|
14046
|
+
return row ? rowToAgentTask(row) : null;
|
|
14047
|
+
}
|
|
14048
|
+
async function getLatestLeadTaskByContextKey(contextKey, source2) {
|
|
14049
|
+
const row = await getDbClient().get(`SELECT t.*
|
|
14050
|
+
FROM agent_tasks t
|
|
14051
|
+
JOIN agents a ON a.id = t.agentId
|
|
14052
|
+
WHERE t.contextKey = ?
|
|
14053
|
+
AND (? IS NULL OR t.source = ?)
|
|
14054
|
+
AND a.isLead = 1
|
|
14055
|
+
ORDER BY t.createdAt DESC, t.rowid DESC
|
|
14056
|
+
LIMIT 1`, [contextKey, source2 ?? null, source2 ?? null]);
|
|
14057
|
+
return row ? rowToAgentTask(row) : null;
|
|
14058
|
+
}
|
|
14038
14059
|
async function getMostRecentTaskInThread(channelId, threadTs) {
|
|
14039
14060
|
const row = await getDbClient().get(`SELECT * FROM agent_tasks
|
|
14040
14061
|
WHERE slackChannelId = ?
|
|
@@ -14076,11 +14097,15 @@ async function findRecentCancelledTaskInThread(channelId, threadTs, windowMinute
|
|
|
14076
14097
|
LIMIT 1`, [channelId, threadTs, since]);
|
|
14077
14098
|
return row ? rowToAgentTask(row) : null;
|
|
14078
14099
|
}
|
|
14079
|
-
var dependencies2, TASK_PREVIEW_LENGTH = 300, TASK_PREVIEW_BYTES, TASK_PREVIEW_SQL, taskPreviewDecoder, LIST_COLUMNS, NEVER_STARTED_TASK_STATUSES, findTaskByGitHub,
|
|
14100
|
+
var dependencies2, TASK_PREVIEW_LENGTH = 300, TASK_PREVIEW_BYTES, TASK_PREVIEW_SQL, taskPreviewDecoder, LIST_COLUMNS, SUPERSEDED_RESUME_REPAIR_WINDOW_MS, NEVER_STARTED_TASK_STATUSES, findTaskByGitHub, CHAT_RELAY_ELIGIBLE_SQL = `(obligation.last_attempt_at IS NULL
|
|
14101
|
+
OR (julianday(?) - julianday(obligation.last_attempt_at)) * 86400000.0 >=
|
|
14102
|
+
CASE WHEN obligation.attempt_count >= 8 THEN 600000
|
|
14103
|
+
ELSE 3000 * (1 << obligation.attempt_count) END)`, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:";
|
|
14080
14104
|
var init_read = __esm(() => {
|
|
14081
14105
|
init_key();
|
|
14082
14106
|
init_types();
|
|
14083
14107
|
init_provider_metadata();
|
|
14108
|
+
init_secret_scrubber();
|
|
14084
14109
|
init_agents();
|
|
14085
14110
|
init_runtime();
|
|
14086
14111
|
TASK_PREVIEW_BYTES = 4 * (TASK_PREVIEW_LENGTH + 1);
|
|
@@ -14094,6 +14119,7 @@ var init_read = __esm(() => {
|
|
|
14094
14119
|
agent_tasks.offeredTo, agent_tasks.acceptedAt, agent_tasks.parentTaskId,
|
|
14095
14120
|
agent_tasks.scheduleId, agent_tasks.model, agent_tasks.modelTier,
|
|
14096
14121
|
agent_tasks.resolvedModel, agent_tasks.modelSource, agent_tasks.modelAlias, agent_tasks.effort,
|
|
14122
|
+
agent_tasks.resolvedEffort,
|
|
14097
14123
|
agent_tasks.provider, agent_tasks.requestedByUserId, agent_tasks.progress,
|
|
14098
14124
|
agent_tasks.createdAt, agent_tasks.lastUpdatedAt, agent_tasks.finishedAt,
|
|
14099
14125
|
agent_tasks.peakContextPercent`,
|
|
@@ -14101,6 +14127,7 @@ var init_read = __esm(() => {
|
|
|
14101
14127
|
agent_tasks.title, agent_tasks.status, agent_tasks.createdAt, agent_tasks.lastUpdatedAt,
|
|
14102
14128
|
agent_tasks.finishedAt, agent_tasks.peakContextTokens`
|
|
14103
14129
|
};
|
|
14130
|
+
SUPERSEDED_RESUME_REPAIR_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
14104
14131
|
NEVER_STARTED_TASK_STATUSES = [
|
|
14105
14132
|
"draft",
|
|
14106
14133
|
"backlog",
|
|
@@ -14112,6 +14139,355 @@ var init_read = __esm(() => {
|
|
|
14112
14139
|
findTaskByGitHub = findTaskByVcs;
|
|
14113
14140
|
});
|
|
14114
14141
|
|
|
14142
|
+
// src/be/db/model-profiles.ts
|
|
14143
|
+
function rowToModelProfile(row) {
|
|
14144
|
+
return {
|
|
14145
|
+
id: row.id,
|
|
14146
|
+
name: row.name,
|
|
14147
|
+
harness: ProviderNameSchema.parse(row.harness),
|
|
14148
|
+
model: row.model,
|
|
14149
|
+
effort: ReasoningEffortSchema.safeParse(row.effort).success ? row.effort : null,
|
|
14150
|
+
allowCustomModel: row.allowCustomModel === 1,
|
|
14151
|
+
description: row.description,
|
|
14152
|
+
seededFrom: row.seededFrom,
|
|
14153
|
+
createdAt: row.createdAt,
|
|
14154
|
+
lastUpdatedAt: row.lastUpdatedAt
|
|
14155
|
+
};
|
|
14156
|
+
}
|
|
14157
|
+
async function listModelProfiles(filter = {}) {
|
|
14158
|
+
const rows = filter.harness ? await getDbClient().query("SELECT * FROM model_profiles WHERE harness = ? ORDER BY harness, name", [filter.harness]) : await getDbClient().query("SELECT * FROM model_profiles ORDER BY harness, name");
|
|
14159
|
+
return rows.map(rowToModelProfile);
|
|
14160
|
+
}
|
|
14161
|
+
async function getModelProfileByName(name) {
|
|
14162
|
+
const row = await getDbClient().get("SELECT * FROM model_profiles WHERE name = ?", [name.trim()]);
|
|
14163
|
+
return row ? rowToModelProfile(row) : null;
|
|
14164
|
+
}
|
|
14165
|
+
async function createModelProfile(input, audit = {}) {
|
|
14166
|
+
const now = new Date().toISOString();
|
|
14167
|
+
const row = await getDbClient().get(`INSERT INTO model_profiles
|
|
14168
|
+
(id, name, harness, model, effort, allowCustomModel, description, seededFrom, createdAt, lastUpdatedAt, created_by, updated_by)
|
|
14169
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
14170
|
+
ON CONFLICT(name) DO NOTHING
|
|
14171
|
+
RETURNING *`, [
|
|
14172
|
+
crypto.randomUUID(),
|
|
14173
|
+
input.name,
|
|
14174
|
+
input.harness,
|
|
14175
|
+
input.model,
|
|
14176
|
+
input.effort ?? null,
|
|
14177
|
+
input.allowCustomModel ? 1 : 0,
|
|
14178
|
+
input.description ?? null,
|
|
14179
|
+
input.seededFrom ?? null,
|
|
14180
|
+
now,
|
|
14181
|
+
now,
|
|
14182
|
+
audit.userId ?? null,
|
|
14183
|
+
audit.userId ?? null
|
|
14184
|
+
]);
|
|
14185
|
+
return row ? rowToModelProfile(row) : null;
|
|
14186
|
+
}
|
|
14187
|
+
async function updateModelProfile(name, patch, audit = {}) {
|
|
14188
|
+
const sets = [];
|
|
14189
|
+
const params = [];
|
|
14190
|
+
if (patch.model !== undefined) {
|
|
14191
|
+
sets.push("model = ?");
|
|
14192
|
+
params.push(patch.model);
|
|
14193
|
+
}
|
|
14194
|
+
if (patch.effort !== undefined) {
|
|
14195
|
+
sets.push("effort = ?");
|
|
14196
|
+
params.push(patch.effort);
|
|
14197
|
+
}
|
|
14198
|
+
if (patch.allowCustomModel !== undefined) {
|
|
14199
|
+
sets.push("allowCustomModel = ?");
|
|
14200
|
+
params.push(patch.allowCustomModel ? 1 : 0);
|
|
14201
|
+
}
|
|
14202
|
+
if (patch.description !== undefined) {
|
|
14203
|
+
sets.push("description = ?");
|
|
14204
|
+
params.push(patch.description);
|
|
14205
|
+
}
|
|
14206
|
+
sets.push("lastUpdatedAt = ?", "updated_by = ?");
|
|
14207
|
+
params.push(new Date().toISOString(), audit.userId ?? null);
|
|
14208
|
+
const row = await getDbClient().get(`UPDATE model_profiles SET ${sets.join(", ")} WHERE name = ? RETURNING *`, [...params, name]);
|
|
14209
|
+
return row ? rowToModelProfile(row) : null;
|
|
14210
|
+
}
|
|
14211
|
+
function repairWindowStart() {
|
|
14212
|
+
return new Date(Date.now() - SUPERSEDED_RESUME_REPAIR_WINDOW_MS).toISOString();
|
|
14213
|
+
}
|
|
14214
|
+
async function modelProfileReferences(name) {
|
|
14215
|
+
const agents = await getDbClient().query("SELECT scopeId FROM swarm_config WHERE scope = 'agent' AND key = ? AND value = ?", [MODEL_PROFILE_CONFIG_KEY, name]);
|
|
14216
|
+
const tasks = await getDbClient().get(`SELECT COUNT(*) AS n FROM agent_tasks t WHERE t.profile = ? AND ${TASK_HOLDS_PROFILE_SQL}`, [name, repairWindowStart()]);
|
|
14217
|
+
return { agentIds: agents.map((a) => a.scopeId), openTaskCount: tasks?.n ?? 0 };
|
|
14218
|
+
}
|
|
14219
|
+
function modelProfileRefError(error2) {
|
|
14220
|
+
const message = error2 instanceof Error ? error2.message : "";
|
|
14221
|
+
return message.includes("model-profile-missing:") ? "missing" : null;
|
|
14222
|
+
}
|
|
14223
|
+
async function deleteModelProfile(name) {
|
|
14224
|
+
const row = await getDbClient().get(`DELETE FROM model_profiles
|
|
14225
|
+
WHERE name = ?
|
|
14226
|
+
AND NOT EXISTS (
|
|
14227
|
+
SELECT 1 FROM agent_tasks t
|
|
14228
|
+
WHERE t.profile = model_profiles.name AND ${TASK_HOLDS_PROFILE_SQL})
|
|
14229
|
+
AND NOT EXISTS (
|
|
14230
|
+
SELECT 1 FROM swarm_config
|
|
14231
|
+
WHERE scope = 'agent' AND key = ? AND trim(value) = model_profiles.name)
|
|
14232
|
+
RETURNING id`, [name, repairWindowStart(), MODEL_PROFILE_CONFIG_KEY]);
|
|
14233
|
+
if (row)
|
|
14234
|
+
return "deleted";
|
|
14235
|
+
return await getModelProfileByName(name) ? "in-use" : "missing";
|
|
14236
|
+
}
|
|
14237
|
+
async function getAgentDefaultProfileName(agentId) {
|
|
14238
|
+
const row = await getDbClient().get("SELECT value FROM swarm_config WHERE scope = 'agent' AND scopeId = ? AND key = ?", [agentId, MODEL_PROFILE_CONFIG_KEY]);
|
|
14239
|
+
return row?.value.trim() || null;
|
|
14240
|
+
}
|
|
14241
|
+
async function repoModelOverrideKeys(vcsRepo, { includeSecrets = true } = {}) {
|
|
14242
|
+
if (!vcsRepo?.trim())
|
|
14243
|
+
return new Set;
|
|
14244
|
+
const repos = await getDbClient().query("SELECT id, url FROM swarm_repos WHERE name = ? ORDER BY name ASC", [vcsRepoName(vcsRepo)]);
|
|
14245
|
+
const repo = repos.find((r) => vcsRepoUrlMatches(r.url, vcsRepo));
|
|
14246
|
+
if (!repo)
|
|
14247
|
+
return new Set;
|
|
14248
|
+
const rows = await getDbClient().query(`SELECT key FROM swarm_config
|
|
14249
|
+
WHERE scope = 'repo' AND scopeId = ? AND key IN ('MODEL_OVERRIDE', 'REASONING_EFFORT_OVERRIDE')
|
|
14250
|
+
${includeSecrets ? "" : "AND isSecret = 0"}`, [repo.id]);
|
|
14251
|
+
return new Set(rows.map((row) => row.key));
|
|
14252
|
+
}
|
|
14253
|
+
async function taskProfileError(check) {
|
|
14254
|
+
const name = check.profile?.trim();
|
|
14255
|
+
if (!name)
|
|
14256
|
+
return null;
|
|
14257
|
+
if (check.model?.trim() || check.modelTier?.trim()) {
|
|
14258
|
+
return "Pass `profile`, or `model`/`modelTier`, not both.";
|
|
14259
|
+
}
|
|
14260
|
+
const profile = await getModelProfileByName(name);
|
|
14261
|
+
if (!profile) {
|
|
14262
|
+
return `Unknown model profile "${name}". List profiles with list-model-profiles.`;
|
|
14263
|
+
}
|
|
14264
|
+
if (!check.agentId)
|
|
14265
|
+
return null;
|
|
14266
|
+
const agent = await getDbClient().get("SELECT COALESCE(harness_provider, provider) AS harness FROM agents WHERE id = ?", [check.agentId]);
|
|
14267
|
+
if (agent?.harness && agent.harness !== profile.harness) {
|
|
14268
|
+
return `Model profile "${name}" runs on the ${profile.harness} harness; the target agent runs ${agent.harness}.`;
|
|
14269
|
+
}
|
|
14270
|
+
return null;
|
|
14271
|
+
}
|
|
14272
|
+
function effectiveOverride(row) {
|
|
14273
|
+
if (!row)
|
|
14274
|
+
return null;
|
|
14275
|
+
return row.exportToEnv === 0 ? "\x00withheld" : row.value;
|
|
14276
|
+
}
|
|
14277
|
+
async function clearAgentModelProfileOnOverrideChange(agentId, key, before, after) {
|
|
14278
|
+
if (key !== "MODEL_OVERRIDE" && key !== "REASONING_EFFORT_OVERRIDE")
|
|
14279
|
+
return;
|
|
14280
|
+
if (effectiveOverride(before) === effectiveOverride(after))
|
|
14281
|
+
return;
|
|
14282
|
+
await getDbClient().run("DELETE FROM swarm_config WHERE scope = 'agent' AND scopeId = ? AND key = ?", [agentId, MODEL_PROFILE_CONFIG_KEY]);
|
|
14283
|
+
}
|
|
14284
|
+
var MODEL_PROFILE_CONFIG_KEY = "MODEL_PROFILE", TASK_HOLDS_PROFILE_SQL = `(
|
|
14285
|
+
t.status NOT IN ('completed', 'failed', 'cancelled', 'superseded')
|
|
14286
|
+
OR (t.status = 'superseded'
|
|
14287
|
+
AND t.workflowRunStepId IS NULL
|
|
14288
|
+
AND (t.finishedAt IS NULL OR t.finishedAt > ?)
|
|
14289
|
+
AND NOT EXISTS (
|
|
14290
|
+
SELECT 1 FROM agent_tasks c WHERE c.parentTaskId = t.id AND c.taskType = 'resume')))`;
|
|
14291
|
+
var init_model_profiles = __esm(() => {
|
|
14292
|
+
init_types();
|
|
14293
|
+
init_vcs_repo_match();
|
|
14294
|
+
init_runtime();
|
|
14295
|
+
init_read();
|
|
14296
|
+
});
|
|
14297
|
+
|
|
14298
|
+
// src/be/db/tasks/human-free.ts
|
|
14299
|
+
function humanFreeCase(parentFlag) {
|
|
14300
|
+
return `CASE
|
|
14301
|
+
WHEN ${HUMAN_FREE_BASE_SQL} THEN 1
|
|
14302
|
+
WHEN ${parentFlag} = 1 AND ${UNATTRIBUTED_SQL} THEN 1
|
|
14303
|
+
ELSE 0
|
|
14304
|
+
END`;
|
|
14305
|
+
}
|
|
14306
|
+
function carriesHumanFreeTag(tagsJson) {
|
|
14307
|
+
const haystack = (tagsJson ?? "[]").toLowerCase();
|
|
14308
|
+
return HUMAN_FREE_TAGS.some((tag) => haystack.includes(`"${tag}"`));
|
|
14309
|
+
}
|
|
14310
|
+
function tagWriteChangesHumanFree(previousTagsJson, nextTagsJson) {
|
|
14311
|
+
return carriesHumanFreeTag(previousTagsJson) !== carriesHumanFreeTag(nextTagsJson);
|
|
14312
|
+
}
|
|
14313
|
+
async function classifyTaskHumanFree(input) {
|
|
14314
|
+
const row = await getDbClient().get(`WITH task(taskType, tags, source, requestedByUserId, requestedByUserIdInherited, parentTaskId, workflowRunId) AS (
|
|
14315
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
14316
|
+
)
|
|
14317
|
+
SELECT ${humanFreeCase("parent.isHumanFree")} AS humanFree
|
|
14318
|
+
FROM task
|
|
14319
|
+
LEFT JOIN agent_tasks parent ON parent.id = task.parentTaskId`, [
|
|
14320
|
+
input.taskType ?? null,
|
|
14321
|
+
input.tags ?? null,
|
|
14322
|
+
input.source ?? null,
|
|
14323
|
+
input.requestedByUserId ?? null,
|
|
14324
|
+
input.requestedByUserIdInherited ? 1 : 0,
|
|
14325
|
+
input.parentTaskId ?? null,
|
|
14326
|
+
input.workflowRunId ?? null
|
|
14327
|
+
]);
|
|
14328
|
+
return row?.humanFree === 1;
|
|
14329
|
+
}
|
|
14330
|
+
function setHumanFreeQueueListener(listener) {
|
|
14331
|
+
queueListener = listener;
|
|
14332
|
+
}
|
|
14333
|
+
async function enqueueHumanFreeWork(taskIds, scope, hops) {
|
|
14334
|
+
if (taskIds.length === 0)
|
|
14335
|
+
return;
|
|
14336
|
+
if (hops > HUMAN_FREE_MAX_CONTINUATION_HOPS) {
|
|
14337
|
+
console.error(`[human-free] dropping ${taskIds.length} ${scope} continuation(s) past ${HUMAN_FREE_MAX_CONTINUATION_HOPS} hops; the task graph likely has a parent cycle`);
|
|
14338
|
+
return;
|
|
14339
|
+
}
|
|
14340
|
+
await getDbClient().run(`INSERT INTO human_free_reclassify_queue (taskId, scope, afterRowid, hops)
|
|
14341
|
+
SELECT value, ?, 0, ? FROM json_each(?) WHERE true
|
|
14342
|
+
ON CONFLICT (taskId, scope) DO UPDATE SET
|
|
14343
|
+
afterRowid = 0,
|
|
14344
|
+
hops = MAX(hops, excluded.hops)`, [scope, hops, JSON.stringify(taskIds)]);
|
|
14345
|
+
getDbClient().afterCommit(() => queueListener?.());
|
|
14346
|
+
}
|
|
14347
|
+
async function reclassifyBatch(seedTaskIds, batchSize, hops) {
|
|
14348
|
+
const client = getDbClient();
|
|
14349
|
+
const affected = (await client.query(`WITH RECURSIVE affected(id) AS (
|
|
14350
|
+
SELECT value FROM json_each(?)
|
|
14351
|
+
|
|
14352
|
+
UNION
|
|
14353
|
+
|
|
14354
|
+
SELECT task.id
|
|
14355
|
+
FROM affected
|
|
14356
|
+
JOIN agent_tasks task ON task.parentTaskId = affected.id
|
|
14357
|
+
LIMIT ?
|
|
14358
|
+
)
|
|
14359
|
+
SELECT id FROM affected`, [JSON.stringify(seedTaskIds), batchSize])).map((row) => row.id);
|
|
14360
|
+
const result = await client.run(`WITH RECURSIVE affected(id) AS (
|
|
14361
|
+
SELECT value FROM json_each(?)
|
|
14362
|
+
),
|
|
14363
|
+
free(id) AS (
|
|
14364
|
+
SELECT task.id
|
|
14365
|
+
FROM agent_tasks task
|
|
14366
|
+
LEFT JOIN agent_tasks parent ON parent.id = task.parentTaskId
|
|
14367
|
+
WHERE task.id IN (SELECT id FROM affected)
|
|
14368
|
+
AND (
|
|
14369
|
+
${HUMAN_FREE_BASE_SQL}
|
|
14370
|
+
OR (
|
|
14371
|
+
parent.isHumanFree = 1
|
|
14372
|
+
AND parent.id NOT IN (SELECT id FROM affected)
|
|
14373
|
+
AND ${UNATTRIBUTED_SQL}
|
|
14374
|
+
)
|
|
14375
|
+
)
|
|
14376
|
+
|
|
14377
|
+
UNION
|
|
14378
|
+
|
|
14379
|
+
SELECT task.id
|
|
14380
|
+
FROM free
|
|
14381
|
+
JOIN agent_tasks task ON task.parentTaskId = free.id
|
|
14382
|
+
WHERE +task.id IN (SELECT id FROM affected)
|
|
14383
|
+
AND ${UNATTRIBUTED_SQL}
|
|
14384
|
+
)
|
|
14385
|
+
UPDATE agent_tasks
|
|
14386
|
+
SET isHumanFree = CASE WHEN id IN (SELECT id FROM free) THEN 1 ELSE 0 END
|
|
14387
|
+
WHERE id IN (SELECT id FROM affected)
|
|
14388
|
+
AND isHumanFree != CASE WHEN id IN (SELECT id FROM free) THEN 1 ELSE 0 END`, [JSON.stringify(affected)]);
|
|
14389
|
+
if (affected.length >= batchSize) {
|
|
14390
|
+
const unfinished = await client.query(`WITH batch(id) AS (
|
|
14391
|
+
SELECT value FROM json_each(?)
|
|
14392
|
+
)
|
|
14393
|
+
SELECT batch.id
|
|
14394
|
+
FROM batch
|
|
14395
|
+
WHERE EXISTS (
|
|
14396
|
+
SELECT 1
|
|
14397
|
+
FROM agent_tasks child
|
|
14398
|
+
WHERE child.parentTaskId = batch.id
|
|
14399
|
+
AND child.id NOT IN (SELECT id FROM batch)
|
|
14400
|
+
)`, [JSON.stringify(affected)]);
|
|
14401
|
+
await enqueueHumanFreeWork(unfinished.map((row) => row.id), "children", hops);
|
|
14402
|
+
}
|
|
14403
|
+
return result.changes;
|
|
14404
|
+
}
|
|
14405
|
+
async function reclassifyTaskHumanFree(seedTaskIds, options = {}) {
|
|
14406
|
+
const batchSize = options.batchSize ?? HUMAN_FREE_RECLASSIFY_BATCH;
|
|
14407
|
+
const seeds = [...new Set(seedTaskIds)];
|
|
14408
|
+
if (seeds.length === 0)
|
|
14409
|
+
return 0;
|
|
14410
|
+
await enqueueHumanFreeWork(seeds.slice(batchSize), "self", 1);
|
|
14411
|
+
return await reclassifyBatch(seeds.slice(0, batchSize), batchSize, 1);
|
|
14412
|
+
}
|
|
14413
|
+
async function drainOneBatch(batchSize) {
|
|
14414
|
+
return await getDbClient().transaction(async (tx) => {
|
|
14415
|
+
const head = await tx.get("SELECT * FROM human_free_reclassify_queue ORDER BY seq LIMIT 1");
|
|
14416
|
+
if (!head)
|
|
14417
|
+
return null;
|
|
14418
|
+
if (head.scope === "self") {
|
|
14419
|
+
const rows = await tx.query("SELECT * FROM human_free_reclassify_queue WHERE scope = 'self' ORDER BY seq LIMIT ?", [batchSize]);
|
|
14420
|
+
const seeds = rows.map((row) => row.taskId);
|
|
14421
|
+
const hops = Math.max(...rows.map((row) => row.hops)) + 1;
|
|
14422
|
+
await tx.run("DELETE FROM human_free_reclassify_queue WHERE seq IN (SELECT value FROM json_each(?))", [JSON.stringify(rows.map((row) => row.seq))]);
|
|
14423
|
+
return await reclassifyBatch(seeds, batchSize, hops);
|
|
14424
|
+
}
|
|
14425
|
+
const page = await tx.query(`SELECT id, rowid AS position
|
|
14426
|
+
FROM agent_tasks
|
|
14427
|
+
WHERE parentTaskId = ? AND rowid > ?
|
|
14428
|
+
ORDER BY rowid
|
|
14429
|
+
LIMIT ?`, [head.taskId, head.afterRowid, batchSize]);
|
|
14430
|
+
if (page.length < batchSize) {
|
|
14431
|
+
await tx.run("DELETE FROM human_free_reclassify_queue WHERE seq = ?", [head.seq]);
|
|
14432
|
+
} else {
|
|
14433
|
+
await tx.run("UPDATE human_free_reclassify_queue SET afterRowid = ? WHERE seq = ?", [
|
|
14434
|
+
page[page.length - 1]?.position ?? head.afterRowid,
|
|
14435
|
+
head.seq
|
|
14436
|
+
]);
|
|
14437
|
+
}
|
|
14438
|
+
if (page.length === 0)
|
|
14439
|
+
return 0;
|
|
14440
|
+
return await reclassifyBatch(page.map((row) => row.id), batchSize, head.hops + 1);
|
|
14441
|
+
});
|
|
14442
|
+
}
|
|
14443
|
+
async function pendingHumanFreeReclassifications() {
|
|
14444
|
+
const row = await getDbClient().get("SELECT COUNT(*) AS count FROM human_free_reclassify_queue");
|
|
14445
|
+
return row?.count ?? 0;
|
|
14446
|
+
}
|
|
14447
|
+
async function drainHumanFreeReclassifyQueue(options = {}) {
|
|
14448
|
+
const batchSize = options.batchSize ?? HUMAN_FREE_RECLASSIFY_BATCH;
|
|
14449
|
+
const maxBatches = options.maxBatches ?? Number.POSITIVE_INFINITY;
|
|
14450
|
+
let batches = 0;
|
|
14451
|
+
let changed = 0;
|
|
14452
|
+
while (batches < maxBatches) {
|
|
14453
|
+
const batchChanged = await drainOneBatch(batchSize);
|
|
14454
|
+
if (batchChanged === null)
|
|
14455
|
+
break;
|
|
14456
|
+
batches += 1;
|
|
14457
|
+
changed += batchChanged;
|
|
14458
|
+
}
|
|
14459
|
+
return { batches, changed, remaining: await pendingHumanFreeReclassifications() };
|
|
14460
|
+
}
|
|
14461
|
+
var HUMAN_FREE_TAGS, HUMAN_FREE_TAG_SQL, HUMAN_FREE_BASE_SQL, UNATTRIBUTED_SQL = "(task.requestedByUserId IS NULL OR task.requestedByUserIdInherited = 1)", HUMAN_FREE_RECLASSIFY_BATCH = 500, HUMAN_FREE_MAX_CONTINUATION_HOPS = 1e4, queueListener;
|
|
14462
|
+
var init_human_free = __esm(() => {
|
|
14463
|
+
init_runtime();
|
|
14464
|
+
HUMAN_FREE_TAGS = ["heartbeat"];
|
|
14465
|
+
HUMAN_FREE_TAG_SQL = HUMAN_FREE_TAGS.map((tag) => `COALESCE(task.tags, '[]') LIKE '%"${tag}"%'`).join(`
|
|
14466
|
+
OR `);
|
|
14467
|
+
HUMAN_FREE_BASE_SQL = `(
|
|
14468
|
+
COALESCE(task.taskType, '') IN ('heartbeat', 'heartbeat-checklist', 'boot-triage')
|
|
14469
|
+
OR ${HUMAN_FREE_TAG_SQL}
|
|
14470
|
+
OR (COALESCE(task.source, '') = 'schedule' AND task.requestedByUserId IS NULL)
|
|
14471
|
+
OR (
|
|
14472
|
+
task.parentTaskId IS NULL
|
|
14473
|
+
AND COALESCE(task.source, '') = 'workflow'
|
|
14474
|
+
AND task.requestedByUserId IS NULL
|
|
14475
|
+
AND EXISTS (
|
|
14476
|
+
SELECT 1
|
|
14477
|
+
FROM workflow_runs run
|
|
14478
|
+
WHERE run.id = task.workflowRunId
|
|
14479
|
+
AND run.triggerType = 'schedule'
|
|
14480
|
+
AND run.created_by IS NULL
|
|
14481
|
+
)
|
|
14482
|
+
)
|
|
14483
|
+
OR (
|
|
14484
|
+
COALESCE(task.source, '') = 'system'
|
|
14485
|
+
AND parent.id IS NOT NULL
|
|
14486
|
+
AND parent.requestedByUserId IS NULL
|
|
14487
|
+
)
|
|
14488
|
+
)`;
|
|
14489
|
+
});
|
|
14490
|
+
|
|
14115
14491
|
// src/be/task-lifecycle-events.ts
|
|
14116
14492
|
function onTaskStarted(handler) {
|
|
14117
14493
|
taskStartedHandlers.push(handler);
|
|
@@ -14334,7 +14710,7 @@ async function startTask(taskId) {
|
|
|
14334
14710
|
}
|
|
14335
14711
|
return result;
|
|
14336
14712
|
}
|
|
14337
|
-
async function updateTaskClaudeSessionId(taskId, claudeSessionId, provider, providerMeta, model, harnessVariant, harnessVariantMeta) {
|
|
14713
|
+
async function updateTaskClaudeSessionId(taskId, claudeSessionId, provider, providerMeta, model, harnessVariant, harnessVariantMeta, resolvedEffort) {
|
|
14338
14714
|
const setClauses = ["claudeSessionId = ?", "lastUpdatedAt = ?"];
|
|
14339
14715
|
const params = [claudeSessionId, new Date().toISOString()];
|
|
14340
14716
|
if (provider !== undefined) {
|
|
@@ -14357,6 +14733,10 @@ async function updateTaskClaudeSessionId(taskId, claudeSessionId, provider, prov
|
|
|
14357
14733
|
setClauses.push("harnessVariantMeta = ?");
|
|
14358
14734
|
params.push(JSON.stringify(harnessVariantMeta));
|
|
14359
14735
|
}
|
|
14736
|
+
if (resolvedEffort !== undefined) {
|
|
14737
|
+
setClauses.push("resolvedEffort = ?");
|
|
14738
|
+
params.push(resolvedEffort);
|
|
14739
|
+
}
|
|
14360
14740
|
params.push(taskId);
|
|
14361
14741
|
const row = await getDbClient().get(`UPDATE agent_tasks SET ${setClauses.join(", ")} WHERE id = ? RETURNING *`, params);
|
|
14362
14742
|
return row ? rowToAgentTask(row) : null;
|
|
@@ -14430,7 +14810,7 @@ async function completeTask(id, output, options) {
|
|
|
14430
14810
|
});
|
|
14431
14811
|
} catch {}
|
|
14432
14812
|
getDbClient().afterCommit(() => {
|
|
14433
|
-
import("./event-bus-
|
|
14813
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => {
|
|
14434
14814
|
workflowEventBus.emit("task.completed", {
|
|
14435
14815
|
taskId: id,
|
|
14436
14816
|
output: scrubbedOutput,
|
|
@@ -14485,7 +14865,7 @@ async function failTask(id, reason, opts = {}) {
|
|
|
14485
14865
|
});
|
|
14486
14866
|
} catch {}
|
|
14487
14867
|
getDbClient().afterCommit(() => {
|
|
14488
|
-
import("./event-bus-
|
|
14868
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => {
|
|
14489
14869
|
workflowEventBus.emit("task.failed", {
|
|
14490
14870
|
taskId: id,
|
|
14491
14871
|
failureReason: scrubbedReason,
|
|
@@ -14567,7 +14947,7 @@ async function cancelTask(id, reason) {
|
|
|
14567
14947
|
});
|
|
14568
14948
|
} catch {}
|
|
14569
14949
|
getDbClient().afterCommit(() => {
|
|
14570
|
-
import("./event-bus-
|
|
14950
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => {
|
|
14571
14951
|
workflowEventBus.emit("task.cancelled", {
|
|
14572
14952
|
taskId: id,
|
|
14573
14953
|
agentId: row.agentId,
|
|
@@ -14624,7 +15004,7 @@ async function supersedeTask(id, args) {
|
|
|
14624
15004
|
});
|
|
14625
15005
|
} catch {}
|
|
14626
15006
|
getDbClient().afterCommit(() => {
|
|
14627
|
-
import("./event-bus-
|
|
15007
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => {
|
|
14628
15008
|
workflowEventBus.emit("task.superseded", {
|
|
14629
15009
|
taskId: id,
|
|
14630
15010
|
reason: args.reason,
|
|
@@ -14836,7 +15216,7 @@ async function updateTaskProgress(id, progress) {
|
|
|
14836
15216
|
});
|
|
14837
15217
|
} catch {}
|
|
14838
15218
|
getDbClient().afterCommit(() => {
|
|
14839
|
-
import("./event-bus-
|
|
15219
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => {
|
|
14840
15220
|
workflowEventBus.emit("task.progress", {
|
|
14841
15221
|
taskId: id,
|
|
14842
15222
|
progress: scrubbedProgress,
|
|
@@ -14907,7 +15287,7 @@ function emitChildRunFinished(childRunId, parentStepId, status) {
|
|
|
14907
15287
|
}
|
|
14908
15288
|
function emitAfterCommit(childRunId, parentStepId) {
|
|
14909
15289
|
getDbClient().afterCommit(() => {
|
|
14910
|
-
import("./event-bus-
|
|
15290
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => {
|
|
14911
15291
|
workflowEventBus.emit("workflow.child.finished", { childRunId, parentStepId });
|
|
14912
15292
|
}).catch((err) => console.error("[db] workflow.child.finished event not emitted:", scrubSecrets(err instanceof Error ? err.message : String(err))));
|
|
14913
15293
|
});
|
|
@@ -14924,6 +15304,164 @@ var init_workflow_runs = __esm(() => {
|
|
|
14924
15304
|
]);
|
|
14925
15305
|
});
|
|
14926
15306
|
|
|
15307
|
+
// src/integrations/chat-sdk/schema.ts
|
|
15308
|
+
function forbiddenKeyIssues(value, ctx) {
|
|
15309
|
+
for (const key of FORBIDDEN_ADAPTER_KEYS) {
|
|
15310
|
+
if (key in value) {
|
|
15311
|
+
ctx.addIssue({
|
|
15312
|
+
code: "custom",
|
|
15313
|
+
path: [key],
|
|
15314
|
+
message: `${key} is not allowed in CHAT_SDK_ADAPTERS`
|
|
15315
|
+
});
|
|
15316
|
+
}
|
|
15317
|
+
}
|
|
15318
|
+
}
|
|
15319
|
+
function adapterSchema(shape) {
|
|
15320
|
+
return exports_external.looseObject({ ...shape, ...COMMON_SHAPE }).superRefine(forbiddenKeyIssues);
|
|
15321
|
+
}
|
|
15322
|
+
function draftShape(shape) {
|
|
15323
|
+
return Object.fromEntries(Object.entries(shape).map(([key, field]) => [key, field.optional()]));
|
|
15324
|
+
}
|
|
15325
|
+
function discordPublicKeyIssue(value, ctx) {
|
|
15326
|
+
if (typeof value.publicKey === "string" && !DISCORD_PUBLIC_KEY_PATTERN.test(value.publicKey)) {
|
|
15327
|
+
ctx.addIssue({
|
|
15328
|
+
code: "custom",
|
|
15329
|
+
path: ["publicKey"],
|
|
15330
|
+
message: "publicKey must be 64 hex characters (the application's Ed25519 public key)"
|
|
15331
|
+
});
|
|
15332
|
+
}
|
|
15333
|
+
}
|
|
15334
|
+
function valueAt(input, path3) {
|
|
15335
|
+
let current = input;
|
|
15336
|
+
for (const key of path3) {
|
|
15337
|
+
if (current === null || typeof current !== "object")
|
|
15338
|
+
return;
|
|
15339
|
+
current = current[key];
|
|
15340
|
+
}
|
|
15341
|
+
return current;
|
|
15342
|
+
}
|
|
15343
|
+
function firstIssueText(error2, prefix = "CHAT_SDK_ADAPTERS", input) {
|
|
15344
|
+
const issue = error2.issues[0];
|
|
15345
|
+
if (!issue)
|
|
15346
|
+
return `${prefix} is invalid`;
|
|
15347
|
+
const path3 = issue.path.length > 0 ? issue.path.join(".") : "(root)";
|
|
15348
|
+
const missing = input !== undefined && issue.path.length > 0 && valueAt(input, issue.path) === undefined;
|
|
15349
|
+
return `${prefix}.${path3}: ${missing ? "required" : issue.message}`;
|
|
15350
|
+
}
|
|
15351
|
+
function formFields(shape) {
|
|
15352
|
+
return Object.keys(shape).filter((key) => key !== "enabled");
|
|
15353
|
+
}
|
|
15354
|
+
function isAdapterEntryEnabled(entry) {
|
|
15355
|
+
return entry !== undefined && entry.enabled !== false;
|
|
15356
|
+
}
|
|
15357
|
+
function validateChatSdkAdaptersValue(value) {
|
|
15358
|
+
if (typeof value !== "string")
|
|
15359
|
+
return "CHAT_SDK_ADAPTERS must be a JSON string";
|
|
15360
|
+
let parsed;
|
|
15361
|
+
try {
|
|
15362
|
+
parsed = JSON.parse(value);
|
|
15363
|
+
} catch (error2) {
|
|
15364
|
+
return `CHAT_SDK_ADAPTERS is not valid JSON: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
15365
|
+
}
|
|
15366
|
+
const result = ChatSdkAdaptersDraftSchema.safeParse(parsed);
|
|
15367
|
+
return result.success ? null : firstIssueText(result.error);
|
|
15368
|
+
}
|
|
15369
|
+
var CHAT_SDK_ADAPTER_NAMES, ConfigRefSchema, Str, FORBIDDEN_ADAPTER_KEYS, COMMON_SHAPE, TELEGRAM_SHAPE, SLACK_SHAPE, TelegramAdapterSchema, SlackAdapterSchema, DISCORD_PUBLIC_KEY_PATTERN, DISCORD_SHAPE, DiscordAdapterSchema, TEAMS_SHAPE, TeamsAdapterSchema, ChatSdkAdaptersSchema, CHAT_SDK_ADAPTER_SCHEMAS, ChatSdkAdaptersDraftSchema, CHAT_SDK_ADAPTER_FIELDS;
|
|
15370
|
+
var init_schema = __esm(() => {
|
|
15371
|
+
init_zod();
|
|
15372
|
+
CHAT_SDK_ADAPTER_NAMES = ["telegram", "slack", "discord", "teams"];
|
|
15373
|
+
ConfigRefSchema = exports_external.strictObject({ $config: exports_external.string().min(1) });
|
|
15374
|
+
Str = exports_external.union([exports_external.string().trim().min(1), ConfigRefSchema]);
|
|
15375
|
+
FORBIDDEN_ADAPTER_KEYS = [
|
|
15376
|
+
"apiUrl",
|
|
15377
|
+
"apiBaseUrl",
|
|
15378
|
+
"webhookVerifier",
|
|
15379
|
+
"allowUnverifiedWebhooks"
|
|
15380
|
+
];
|
|
15381
|
+
COMMON_SHAPE = {
|
|
15382
|
+
userName: exports_external.string().min(1).optional(),
|
|
15383
|
+
enabled: exports_external.boolean().optional()
|
|
15384
|
+
};
|
|
15385
|
+
TELEGRAM_SHAPE = {
|
|
15386
|
+
botToken: Str,
|
|
15387
|
+
secretToken: Str.optional(),
|
|
15388
|
+
mode: exports_external.enum(["webhook", "polling"]).default("webhook"),
|
|
15389
|
+
allowedUserIds: exports_external.array(exports_external.union([exports_external.string(), exports_external.number()])).optional()
|
|
15390
|
+
};
|
|
15391
|
+
SLACK_SHAPE = {
|
|
15392
|
+
botToken: Str,
|
|
15393
|
+
signingSecret: Str.optional(),
|
|
15394
|
+
appToken: Str.optional(),
|
|
15395
|
+
mode: exports_external.enum(["webhook", "socket"]).default("webhook")
|
|
15396
|
+
};
|
|
15397
|
+
TelegramAdapterSchema = adapterSchema(TELEGRAM_SHAPE);
|
|
15398
|
+
SlackAdapterSchema = adapterSchema(SLACK_SHAPE).superRefine((value, ctx) => {
|
|
15399
|
+
if (value.mode === "webhook" && value.signingSecret === undefined) {
|
|
15400
|
+
ctx.addIssue({
|
|
15401
|
+
code: "custom",
|
|
15402
|
+
path: ["signingSecret"],
|
|
15403
|
+
message: "signingSecret is required in webhook mode"
|
|
15404
|
+
});
|
|
15405
|
+
}
|
|
15406
|
+
if (value.mode === "socket" && value.appToken === undefined) {
|
|
15407
|
+
ctx.addIssue({
|
|
15408
|
+
code: "custom",
|
|
15409
|
+
path: ["appToken"],
|
|
15410
|
+
message: "appToken is required in socket mode"
|
|
15411
|
+
});
|
|
15412
|
+
}
|
|
15413
|
+
});
|
|
15414
|
+
DISCORD_PUBLIC_KEY_PATTERN = /^[0-9a-fA-F]{64}$/;
|
|
15415
|
+
DISCORD_SHAPE = {
|
|
15416
|
+
botToken: Str,
|
|
15417
|
+
publicKey: Str,
|
|
15418
|
+
applicationId: Str,
|
|
15419
|
+
respondToChannelIds: exports_external.array(exports_external.string()).optional(),
|
|
15420
|
+
respondToGlobalMentions: exports_external.boolean().optional(),
|
|
15421
|
+
mentionRoleIds: exports_external.array(exports_external.string()).optional()
|
|
15422
|
+
};
|
|
15423
|
+
DiscordAdapterSchema = adapterSchema(DISCORD_SHAPE).superRefine(discordPublicKeyIssue);
|
|
15424
|
+
TEAMS_SHAPE = {
|
|
15425
|
+
appId: Str,
|
|
15426
|
+
appPassword: Str,
|
|
15427
|
+
appTenantId: Str.optional(),
|
|
15428
|
+
appType: exports_external.enum(["MultiTenant", "SingleTenant"]).default("MultiTenant")
|
|
15429
|
+
};
|
|
15430
|
+
TeamsAdapterSchema = adapterSchema(TEAMS_SHAPE).superRefine((value, ctx) => {
|
|
15431
|
+
if (value.appType === "SingleTenant" && value.appTenantId === undefined) {
|
|
15432
|
+
ctx.addIssue({
|
|
15433
|
+
code: "custom",
|
|
15434
|
+
path: ["appTenantId"],
|
|
15435
|
+
message: "appTenantId is required for a SingleTenant app"
|
|
15436
|
+
});
|
|
15437
|
+
}
|
|
15438
|
+
});
|
|
15439
|
+
ChatSdkAdaptersSchema = exports_external.strictObject({
|
|
15440
|
+
telegram: TelegramAdapterSchema,
|
|
15441
|
+
slack: SlackAdapterSchema,
|
|
15442
|
+
discord: DiscordAdapterSchema,
|
|
15443
|
+
teams: TeamsAdapterSchema
|
|
15444
|
+
}).partial();
|
|
15445
|
+
CHAT_SDK_ADAPTER_SCHEMAS = {
|
|
15446
|
+
telegram: TelegramAdapterSchema,
|
|
15447
|
+
slack: SlackAdapterSchema,
|
|
15448
|
+
discord: DiscordAdapterSchema,
|
|
15449
|
+
teams: TeamsAdapterSchema
|
|
15450
|
+
};
|
|
15451
|
+
ChatSdkAdaptersDraftSchema = exports_external.strictObject({
|
|
15452
|
+
telegram: adapterSchema(draftShape(TELEGRAM_SHAPE)),
|
|
15453
|
+
slack: adapterSchema(draftShape(SLACK_SHAPE)),
|
|
15454
|
+
discord: adapterSchema(draftShape(DISCORD_SHAPE)).superRefine(discordPublicKeyIssue),
|
|
15455
|
+
teams: adapterSchema(draftShape(TEAMS_SHAPE))
|
|
15456
|
+
}).partial();
|
|
15457
|
+
CHAT_SDK_ADAPTER_FIELDS = {
|
|
15458
|
+
telegram: formFields(TelegramAdapterSchema.shape),
|
|
15459
|
+
slack: formFields(SlackAdapterSchema.shape),
|
|
15460
|
+
discord: formFields(DiscordAdapterSchema.shape),
|
|
15461
|
+
teams: formFields(TeamsAdapterSchema.shape)
|
|
15462
|
+
};
|
|
15463
|
+
});
|
|
15464
|
+
|
|
14927
15465
|
// src/scripts-runtime/executors/quickjs-pool-config.ts
|
|
14928
15466
|
function validateQuickJSPoolSize(value) {
|
|
14929
15467
|
const error2 = `Invalid SCRIPT_QUICKJS_POOL_SIZE (must be an integer between 1 and ${MAX_QUICKJS_POOL_SIZE})`;
|
|
@@ -14961,7 +15499,11 @@ function reactionName(event) {
|
|
|
14961
15499
|
const normalized = normalizeSlackReactionShortcode(raw);
|
|
14962
15500
|
return normalized ?? SLACK_REACTION_DEFAULTS[event];
|
|
14963
15501
|
}
|
|
14964
|
-
|
|
15502
|
+
function completedStatusIcon() {
|
|
15503
|
+
const normalized = normalizeSlackReactionShortcode(process.env[SLACK_STATUS_ICON_COMPLETED_KEY]);
|
|
15504
|
+
return normalized ? `:${normalized}:` : SLACK_STATUS_ICON_COMPLETED_DEFAULT;
|
|
15505
|
+
}
|
|
15506
|
+
var SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, SLACK_REACTION_SHORTCODE_PATTERN, SLACK_STATUS_ICON_COMPLETED_KEY = "SLACK_STATUS_ICON_COMPLETED", SLACK_STATUS_ICON_COMPLETED_DEFAULT = "✅";
|
|
14965
15507
|
var init_reaction_shortcode = __esm(() => {
|
|
14966
15508
|
SLACK_REACTION_DEFAULTS = {
|
|
14967
15509
|
accepted: "eyes",
|
|
@@ -15015,20 +15557,26 @@ var init_enabled_tools = () => {};
|
|
|
15015
15557
|
function parseTaskToolManifest(value) {
|
|
15016
15558
|
return taskToolManifestSchema.parse(JSON.parse(value));
|
|
15017
15559
|
}
|
|
15560
|
+
function isChatSdkTask(task) {
|
|
15561
|
+
return chatThreadOfContextKey(task.contextKey) !== null;
|
|
15562
|
+
}
|
|
15018
15563
|
function selectTaskTools(manifest, task) {
|
|
15019
15564
|
const fromSchedule = task.scheduleId && Object.hasOwn(manifest.schedules ?? {}, task.scheduleId) ? manifest.schedules?.[task.scheduleId] : undefined;
|
|
15020
15565
|
const fromType = task.taskType && Object.hasOwn(manifest.taskTypes ?? {}, task.taskType) ? manifest.taskTypes?.[task.taskType] : undefined;
|
|
15021
|
-
|
|
15566
|
+
const chatTask = isChatSdkTask(task);
|
|
15567
|
+
return [...new Set(fromSchedule ?? fromType ?? [])].filter((name) => (!name.startsWith("slack-") || Boolean(task.slackChannelId)) && (chatTask || !CHAT_TASK_ONLY_TOOLS.includes(name)));
|
|
15022
15568
|
}
|
|
15023
|
-
var toolNames, taskToolManifestSchema;
|
|
15569
|
+
var toolNames, taskToolManifestSchema, CHAT_TASK_ONLY_TOOLS;
|
|
15024
15570
|
var init_task_tool_manifest = __esm(() => {
|
|
15025
15571
|
init_zod();
|
|
15572
|
+
init_context_key();
|
|
15026
15573
|
init_tool_config();
|
|
15027
15574
|
toolNames = exports_external.array(exports_external.string().refine((name) => ALL_TOOLS.has(name), "Unknown swarm tool")).max(16);
|
|
15028
15575
|
taskToolManifestSchema = exports_external.strictObject({
|
|
15029
15576
|
taskTypes: exports_external.record(exports_external.string().min(1).max(50), toolNames).optional(),
|
|
15030
15577
|
schedules: exports_external.record(exports_external.uuid(), toolNames).optional()
|
|
15031
15578
|
});
|
|
15579
|
+
CHAT_TASK_ONLY_TOOLS = ["chat-reply"];
|
|
15032
15580
|
});
|
|
15033
15581
|
|
|
15034
15582
|
// src/be/model-tier-keys.ts
|
|
@@ -15068,6 +15616,12 @@ var init_model_tier_keys = __esm(() => {
|
|
|
15068
15616
|
});
|
|
15069
15617
|
|
|
15070
15618
|
// src/be/swarm-config-guard.ts
|
|
15619
|
+
function teamsSdkEnvKeysSql() {
|
|
15620
|
+
return TEAMS_SDK_ENV_KEYS.map((key) => `'${key}'`).join(", ");
|
|
15621
|
+
}
|
|
15622
|
+
function isApiOnlyConfigKey(key) {
|
|
15623
|
+
return API_ONLY_CONFIG_KEYS.has(key);
|
|
15624
|
+
}
|
|
15071
15625
|
function isInternalConfigKey(key) {
|
|
15072
15626
|
return INTERNAL_CONFIG_KEYS.has(key.toLowerCase());
|
|
15073
15627
|
}
|
|
@@ -15175,22 +15729,37 @@ function validateConfigValue(key, value) {
|
|
|
15175
15729
|
const validator = VALIDATED_KEYS[key.toUpperCase()];
|
|
15176
15730
|
return validator ? validator(value) : null;
|
|
15177
15731
|
}
|
|
15178
|
-
|
|
15732
|
+
function validateExportToEnv(key, exportToEnv) {
|
|
15733
|
+
return exportToEnv === true && isEnvExportRestrictedKey(key) ? envExportRestrictedError(key) : null;
|
|
15734
|
+
}
|
|
15735
|
+
var TEAMS_SDK_ENV_KEYS, RESERVED_KEYS, API_ONLY_CONFIG_KEYS, INTERNAL_CONFIG_KEYS, BOOLEAN_LITERALS, MAX_DB_RETENTION_DAYS = 1e6, DB_RETENTION_TUNING_BOUNDS, validateControllerTokenTtlDays, validateControllerGraceSec, VALIDATED_KEYS;
|
|
15179
15736
|
var init_swarm_config_guard = __esm(() => {
|
|
15737
|
+
init_schema();
|
|
15180
15738
|
init_quickjs_pool_config();
|
|
15181
15739
|
init_reaction_shortcode();
|
|
15182
15740
|
init_types();
|
|
15183
15741
|
init_api_drain();
|
|
15742
|
+
init_config_env_export();
|
|
15184
15743
|
init_enabled_tools();
|
|
15185
15744
|
init_org_website();
|
|
15186
15745
|
init_task_tool_manifest();
|
|
15187
15746
|
init_model_tier_keys();
|
|
15747
|
+
TEAMS_SDK_ENV_KEYS = [
|
|
15748
|
+
"SERVICE_URL",
|
|
15749
|
+
"TENANT_ID",
|
|
15750
|
+
"CLIENT_ID",
|
|
15751
|
+
"CLIENT_SECRET",
|
|
15752
|
+
"MANAGED_IDENTITY_CLIENT_ID",
|
|
15753
|
+
"CLOUD"
|
|
15754
|
+
];
|
|
15188
15755
|
RESERVED_KEYS = new Set([
|
|
15189
15756
|
"API_KEY",
|
|
15190
15757
|
"SECRETS_ENCRYPTION_KEY",
|
|
15191
15758
|
"CORS_ALLOW_ANY_ORIGIN",
|
|
15192
|
-
"EXTENSION_ALLOW_LEAD_ACTIVATION"
|
|
15759
|
+
"EXTENSION_ALLOW_LEAD_ACTIVATION",
|
|
15760
|
+
"CHAT_SDK_API_URL_OVERRIDES"
|
|
15193
15761
|
]);
|
|
15762
|
+
API_ONLY_CONFIG_KEYS = new Set(["API_AGENT_FS_API_KEY", "SLACK_SIGNING_SECRET"]);
|
|
15194
15763
|
INTERNAL_CONFIG_KEYS = new Set(["onboarding_state", "runtime_owner_id"]);
|
|
15195
15764
|
BOOLEAN_LITERALS = ["true", "false", "1", "0"];
|
|
15196
15765
|
DB_RETENTION_TUNING_BOUNDS = {
|
|
@@ -15222,6 +15791,7 @@ var init_swarm_config_guard = __esm(() => {
|
|
|
15222
15791
|
], 1),
|
|
15223
15792
|
...integerValidators(["RUNTIME_SOCKET_GRACE_SEC"], 0),
|
|
15224
15793
|
...integerValidators(["RUNTIME_WAKE_GRACE_SEC", "RUNTIME_WAKE_REROUTE_SEC", "RUNTIME_ROUTING_INTERVAL_MS"], 0),
|
|
15794
|
+
CHAT_SDK_ADAPTERS: validateChatSdkAdaptersValue,
|
|
15225
15795
|
TASK_TOOL_MANIFESTS: (value) => {
|
|
15226
15796
|
try {
|
|
15227
15797
|
if (typeof value !== "string")
|
|
@@ -15319,6 +15889,7 @@ var init_swarm_config_guard = __esm(() => {
|
|
|
15319
15889
|
"OPENROUTER_APP_ATTRIBUTION",
|
|
15320
15890
|
"CURSOR_NATIVE_SYSTEM_PROMPT",
|
|
15321
15891
|
"SLACK_DISABLE",
|
|
15892
|
+
"CHAT_SDK_ENABLED",
|
|
15322
15893
|
"SLACK_RENDER_V2",
|
|
15323
15894
|
"SLACK_RENDER_V2_DELEGATION",
|
|
15324
15895
|
"SLACK_BLOCK_EXTERNAL_CHANNELS",
|
|
@@ -15355,7 +15926,8 @@ var init_swarm_config_guard = __esm(() => {
|
|
|
15355
15926
|
"SLACK_REACTION_NOW",
|
|
15356
15927
|
"SLACK_REACTION_STEERED",
|
|
15357
15928
|
"SLACK_REACTION_COMPLETED",
|
|
15358
|
-
"SLACK_REACTION_FAILED"
|
|
15929
|
+
"SLACK_REACTION_FAILED",
|
|
15930
|
+
"SLACK_STATUS_ICON_COMPLETED"
|
|
15359
15931
|
]),
|
|
15360
15932
|
...integerValidators([
|
|
15361
15933
|
"HEARTBEAT_INTERVAL_MS",
|
|
@@ -15393,6 +15965,7 @@ var init_swarm_config_guard = __esm(() => {
|
|
|
15393
15965
|
...integerValidators(["MODEL_LATEST_SOAK_DAYS"], 0),
|
|
15394
15966
|
...integerValidators(["APPROVAL_REQUEST_AUTO_CANCELLATION_DAYS"], 0),
|
|
15395
15967
|
...boundedIntegerValidators(["API_DRAIN_MAX_MS"], 0, API_DRAIN_MAX_MS_LIMIT),
|
|
15968
|
+
...boundedIntegerValidators(["CHAT_SDK_BUFFER_MS"], 1, 600000),
|
|
15396
15969
|
...boundedIntegerValidators(["CONTEXT_PREAMBLE_MAX_TOKENS"], 100, 20000),
|
|
15397
15970
|
MEMORY_MIN_SIMILARITY: (value) => validateFloatRange("MEMORY_MIN_SIMILARITY", value, 0, 1, "between 0 and 1 inclusive"),
|
|
15398
15971
|
MEMORY_ACCESS_BOOST_MAX: (value) => validateFloatRange("MEMORY_ACCESS_BOOST_MAX", value, 1, Number.POSITIVE_INFINITY, "a number >= 1")
|
|
@@ -16564,9 +17137,13 @@ function encodedForms(value) {
|
|
|
16564
17137
|
function registerStoredSecret(value, name) {
|
|
16565
17138
|
if (!value)
|
|
16566
17139
|
return;
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
|
|
17140
|
+
for (const candidate of new Set([value, value.trim()])) {
|
|
17141
|
+
if (!candidate)
|
|
17142
|
+
continue;
|
|
17143
|
+
registerVolatileSecret(candidate, name);
|
|
17144
|
+
for (const form of encodedForms(candidate))
|
|
17145
|
+
registerVolatileSecret(form, name);
|
|
17146
|
+
}
|
|
16570
17147
|
}
|
|
16571
17148
|
async function loadSecretRegistry() {
|
|
16572
17149
|
const result = {
|
|
@@ -16605,7 +17182,7 @@ async function loadSecretRegistry() {
|
|
|
16605
17182
|
result.failed += 1;
|
|
16606
17183
|
}
|
|
16607
17184
|
try {
|
|
16608
|
-
const { loadRuntimeControllerSecrets } = await import("./db-
|
|
17185
|
+
const { loadRuntimeControllerSecrets } = await import("./db-ncypk9np.js");
|
|
16609
17186
|
const loaded = await loadRuntimeControllerSecrets();
|
|
16610
17187
|
result.runtimeController = loaded.count;
|
|
16611
17188
|
result.failed += loaded.failed;
|
|
@@ -16900,6 +17477,7 @@ __export(exports_db, {
|
|
|
16900
17477
|
ReservedAgentRoleError: () => ReservedAgentRoleError,
|
|
16901
17478
|
SESSION_ACTIVITY_REFRESH_MIN_INTERVAL_MS: () => SESSION_ACTIVITY_REFRESH_MIN_INTERVAL_MS,
|
|
16902
17479
|
SKILL_FILE_LIMITS: () => SKILL_FILE_LIMITS,
|
|
17480
|
+
SUPERSEDED_RESUME_REPAIR_WINDOW_MS: () => SUPERSEDED_RESUME_REPAIR_WINDOW_MS,
|
|
16903
17481
|
UNATTRIBUTED_USER_ID: () => UNATTRIBUTED_USER_ID,
|
|
16904
17482
|
__resetSqliteVecExtensionPathCacheForTests: () => __resetSqliteVecExtensionPathCacheForTests,
|
|
16905
17483
|
abandonSlackOutcomeDelivery: () => abandonSlackOutcomeDelivery,
|
|
@@ -17028,6 +17606,7 @@ __export(exports_db, {
|
|
|
17028
17606
|
getAgentSkills: () => getAgentSkills,
|
|
17029
17607
|
getAgentStatusCounts: () => getAgentStatusCounts,
|
|
17030
17608
|
getAgentWithTasks: () => getAgentWithTasks,
|
|
17609
|
+
getAgentWorkingOnContextKey: () => getAgentWorkingOnContextKey,
|
|
17031
17610
|
getAgentWorkingOnThread: () => getAgentWorkingOnThread,
|
|
17032
17611
|
getAllAgentMailInboxMappings: () => getAllAgentMailInboxMappings,
|
|
17033
17612
|
getAllAgents: () => getAllAgents,
|
|
@@ -17089,8 +17668,10 @@ __export(exports_db, {
|
|
|
17089
17668
|
getLastReadAt: () => getLastReadAt,
|
|
17090
17669
|
getLastRunStart: () => getLastRunStart,
|
|
17091
17670
|
getLastSuccessfulRun: () => getLastSuccessfulRun,
|
|
17671
|
+
getLatestActiveTaskByContextKey: () => getLatestActiveTaskByContextKey,
|
|
17092
17672
|
getLatestActiveTaskInThread: () => getLatestActiveTaskInThread,
|
|
17093
17673
|
getLatestContextVersion: () => getLatestContextVersion,
|
|
17674
|
+
getLatestLeadTaskByContextKey: () => getLatestLeadTaskByContextKey,
|
|
17094
17675
|
getLatestLeadTaskInThread: () => getLatestLeadTaskInThread,
|
|
17095
17676
|
getLatestPageBySlug: () => getLatestPageBySlug,
|
|
17096
17677
|
getLatestScriptRunStepTaskByContextKey: () => getLatestScriptRunStepTaskByContextKey,
|
|
@@ -17120,6 +17701,7 @@ __export(exports_db, {
|
|
|
17120
17701
|
getPageVersions: () => getPageVersions,
|
|
17121
17702
|
getPausedTasksForAgent: () => getPausedTasksForAgent,
|
|
17122
17703
|
getPendingApprovalVoteState: () => getPendingApprovalVoteState,
|
|
17704
|
+
getPendingChatRelayTasks: () => getPendingChatRelayTasks,
|
|
17123
17705
|
getPendingEventWaitNames: () => getPendingEventWaitNames,
|
|
17124
17706
|
getPendingSlackRelayTasks: () => getPendingSlackRelayTasks,
|
|
17125
17707
|
getPendingSteeringForAgent: () => getPendingSteeringForAgent,
|
|
@@ -17217,6 +17799,7 @@ __export(exports_db, {
|
|
|
17217
17799
|
getWorkflowVersion: () => getWorkflowVersion,
|
|
17218
17800
|
getWorkflowVersions: () => getWorkflowVersions,
|
|
17219
17801
|
getWorkflowsByScheduleId: () => getWorkflowsByScheduleId,
|
|
17802
|
+
giveUpStaleChatRelays: () => giveUpStaleChatRelays,
|
|
17220
17803
|
hasBudgetRefusalNotificationToday: () => hasBudgetRefusalNotificationToday,
|
|
17221
17804
|
hasCapacity: () => hasCapacity,
|
|
17222
17805
|
hasFirstCompletedTask: () => hasFirstCompletedTask,
|
|
@@ -17268,6 +17851,9 @@ __export(exports_db, {
|
|
|
17268
17851
|
listWorkflowRuns: () => listWorkflowRuns,
|
|
17269
17852
|
listWorkflowRunsPage: () => listWorkflowRunsPage,
|
|
17270
17853
|
listWorkflows: () => listWorkflows,
|
|
17854
|
+
markChatRelayAttempted: () => markChatRelayAttempted,
|
|
17855
|
+
markChatRelayDelivered: () => markChatRelayDelivered,
|
|
17856
|
+
markChatRelayGivenUp: () => markChatRelayGivenUp,
|
|
17271
17857
|
markFinalizedSlackRelaysDelivered: () => markFinalizedSlackRelaysDelivered,
|
|
17272
17858
|
markInboxMessageDelegated: () => markInboxMessageDelegated,
|
|
17273
17859
|
markInboxMessageRead: () => markInboxMessageRead,
|
|
@@ -17296,6 +17882,7 @@ __export(exports_db, {
|
|
|
17296
17882
|
reassociateSessionLogs: () => reassociateSessionLogs,
|
|
17297
17883
|
recordApprovalVotes: () => recordApprovalVotes,
|
|
17298
17884
|
recordBudgetRefusalNotification: () => recordBudgetRefusalNotification,
|
|
17885
|
+
recordChatRelayError: () => recordChatRelayError,
|
|
17299
17886
|
recordInlineScriptRun: () => recordInlineScriptRun,
|
|
17300
17887
|
recordKeyAuthFailure: () => recordKeyAuthFailure,
|
|
17301
17888
|
recordKeyRateLimitWindows: () => recordKeyRateLimitWindows,
|
|
@@ -18796,9 +19383,9 @@ async function createTaskExtended(task, options) {
|
|
|
18796
19383
|
vcsProvider, vcsRepo, vcsEventType, vcsNumber, vcsCommentId, vcsAuthor, vcsUrl,
|
|
18797
19384
|
vcsInstallationId, vcsNodeId,
|
|
18798
19385
|
agentmailInboxId, agentmailMessageId, agentmailThreadId,
|
|
18799
|
-
mentionMessageId, mentionChannelId, dir, parentTaskId, model, modelTier, effort, scheduleId,
|
|
19386
|
+
mentionMessageId, mentionChannelId, dir, parentTaskId, model, modelTier, effort, profile, scheduleId,
|
|
18800
19387
|
workflowRunId, workflowRunStepId, outputSchema, followUpConfig, requestedByUserId, requestedByUserIdInherited, contextKey, routingAffinity, swarmVersion, createdAt, lastUpdatedAt, created_by, updated_by, isHumanFree
|
|
18801
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`, [
|
|
19388
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`, [
|
|
18802
19389
|
id,
|
|
18803
19390
|
assetKey,
|
|
18804
19391
|
options?.agentId ?? null,
|
|
@@ -18838,6 +19425,7 @@ async function createTaskExtended(task, options) {
|
|
|
18838
19425
|
options?.model ?? null,
|
|
18839
19426
|
options?.modelTier ?? null,
|
|
18840
19427
|
options?.effort ?? null,
|
|
19428
|
+
options?.profile?.trim() || null,
|
|
18841
19429
|
options?.scheduleId ?? null,
|
|
18842
19430
|
options?.workflowRunId ?? null,
|
|
18843
19431
|
options?.workflowRunStepId ?? null,
|
|
@@ -18903,7 +19491,7 @@ async function createTaskExtended(task, options) {
|
|
|
18903
19491
|
priority: row.priority
|
|
18904
19492
|
}, (task2) => task2 !== null, row.requestedByUserId);
|
|
18905
19493
|
getDbClient().afterCommit(() => {
|
|
18906
|
-
import("./event-bus-
|
|
19494
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => {
|
|
18907
19495
|
workflowEventBus.emit("task.created", {
|
|
18908
19496
|
taskId: row.id,
|
|
18909
19497
|
task: row.task,
|
|
@@ -18985,7 +19573,7 @@ async function releaseTask(taskId, wakeSnapshot) {
|
|
|
18985
19573
|
} catch {}
|
|
18986
19574
|
if (isRuntimePoolsEnabled() && !wakeSnapshot)
|
|
18987
19575
|
getDbClient().afterCommit(() => {
|
|
18988
|
-
import("./event-bus-
|
|
19576
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => workflowEventBus.emit("task.unassigned", { taskId })).catch((error2) => console.error("[db] Routing event failed:", scrubSecrets(String(error2))));
|
|
18989
19577
|
});
|
|
18990
19578
|
}
|
|
18991
19579
|
return row ? rowToAgentTask(row) : null;
|
|
@@ -19055,7 +19643,7 @@ async function rejectTask(taskId, agentId, reason) {
|
|
|
19055
19643
|
} catch {}
|
|
19056
19644
|
if (isRuntimePoolsEnabled())
|
|
19057
19645
|
getDbClient().afterCommit(() => {
|
|
19058
|
-
import("./event-bus-
|
|
19646
|
+
import("./event-bus-j2jdg3qb.js").then(({ workflowEventBus }) => workflowEventBus.emit("task.unassigned", { taskId })).catch((error2) => console.error("[db] Routing event failed:", scrubSecrets(String(error2))));
|
|
19059
19647
|
});
|
|
19060
19648
|
}
|
|
19061
19649
|
return row ? rowToAgentTask(row) : null;
|
|
@@ -20733,7 +21321,8 @@ function rowToSwarmConfig(row) {
|
|
|
20733
21321
|
description: row.description ?? null,
|
|
20734
21322
|
createdAt: row.createdAt,
|
|
20735
21323
|
lastUpdatedAt: row.lastUpdatedAt,
|
|
20736
|
-
encrypted: isEncrypted
|
|
21324
|
+
encrypted: isEncrypted,
|
|
21325
|
+
exportToEnv: effectiveExportToEnv(row.key, row.exportToEnv !== 0)
|
|
20737
21326
|
};
|
|
20738
21327
|
}
|
|
20739
21328
|
let value = row.value;
|
|
@@ -20755,7 +21344,8 @@ function rowToSwarmConfig(row) {
|
|
|
20755
21344
|
description: row.description ?? null,
|
|
20756
21345
|
createdAt: row.createdAt,
|
|
20757
21346
|
lastUpdatedAt: row.lastUpdatedAt,
|
|
20758
|
-
encrypted: isEncrypted
|
|
21347
|
+
encrypted: isEncrypted,
|
|
21348
|
+
exportToEnv: effectiveExportToEnv(row.key, row.exportToEnv !== 0)
|
|
20759
21349
|
};
|
|
20760
21350
|
}
|
|
20761
21351
|
function autoEncryptLegacyPlaintextSecrets(database, dbPath, options = {}) {
|
|
@@ -20856,7 +21446,7 @@ async function getSwarmConfigs(filters) {
|
|
|
20856
21446
|
async function getInjectableGlobalConfigs() {
|
|
20857
21447
|
const rows = await getDbClient().query(`SELECT * FROM swarm_config
|
|
20858
21448
|
WHERE scope = 'global'
|
|
20859
|
-
AND UPPER(key) NOT IN ('API_KEY', 'SECRETS_ENCRYPTION_KEY', 'CORS_ALLOW_ANY_ORIGIN', 'EXTENSION_ALLOW_LEAD_ACTIVATION')
|
|
21449
|
+
AND UPPER(key) NOT IN ('API_KEY', 'SECRETS_ENCRYPTION_KEY', 'CORS_ALLOW_ANY_ORIGIN', 'EXTENSION_ALLOW_LEAD_ACTIVATION', 'CHAT_SDK_API_URL_OVERRIDES', ${teamsSdkEnvKeysSql()})
|
|
20860
21450
|
ORDER BY key ASC`);
|
|
20861
21451
|
return rows.filter((row) => !isInternalConfigKey(row.key)).map(rowToSwarmConfig);
|
|
20862
21452
|
}
|
|
@@ -20883,6 +21473,10 @@ async function upsertSwarmConfig(data) {
|
|
|
20883
21473
|
if (isReservedConfigKey(data.key)) {
|
|
20884
21474
|
throw reservedKeyError(data.key);
|
|
20885
21475
|
}
|
|
21476
|
+
if (data.exportToEnv === true && isEnvExportRestrictedKey(data.key)) {
|
|
21477
|
+
throw new Error(envExportRestrictedError(data.key));
|
|
21478
|
+
}
|
|
21479
|
+
const restricted = isEnvExportRestrictedKey(data.key);
|
|
20886
21480
|
const now = new Date().toISOString();
|
|
20887
21481
|
const scopeId = data.scope === "global" ? null : data.scopeId ?? null;
|
|
20888
21482
|
const isSecret = data.isSecret ? 1 : 0;
|
|
@@ -20891,15 +21485,22 @@ async function upsertSwarmConfig(data) {
|
|
|
20891
21485
|
const storedValue = data.isSecret ? encryptSecret(data.value, getEncryptionKey()) : data.value;
|
|
20892
21486
|
const encryptedFlag = data.isSecret ? 1 : 0;
|
|
20893
21487
|
const row = await getDbClient().transaction(async () => {
|
|
20894
|
-
const existing = scopeId === null ? await getDbClient().get("SELECT
|
|
20895
|
-
|
|
20896
|
-
|
|
20897
|
-
|
|
20898
|
-
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
|
|
20902
|
-
|
|
21488
|
+
const existing = scopeId === null ? await getDbClient().get("SELECT * FROM swarm_config WHERE scope = ? AND scopeId IS NULL AND key = ?", [data.scope, data.key]) : await getDbClient().get("SELECT * FROM swarm_config WHERE scope = ? AND scopeId = ? AND key = ?", [data.scope, scopeId, data.key]);
|
|
21489
|
+
const written = existing ? await getDbClient().get(`UPDATE swarm_config SET value = ?, isSecret = ?, envPath = ?, description = ?, encrypted = ?, lastUpdatedAt = ?,
|
|
21490
|
+
exportToEnv = CASE WHEN ? THEN 0 ELSE COALESCE(?, exportToEnv) END
|
|
21491
|
+
WHERE id = ? RETURNING *`, [
|
|
21492
|
+
storedValue,
|
|
21493
|
+
isSecret,
|
|
21494
|
+
envPath,
|
|
21495
|
+
description,
|
|
21496
|
+
encryptedFlag,
|
|
21497
|
+
now,
|
|
21498
|
+
restricted ? 1 : 0,
|
|
21499
|
+
data.exportToEnv === undefined ? null : data.exportToEnv ? 1 : 0,
|
|
21500
|
+
existing.id
|
|
21501
|
+
]) : await getDbClient().get(`INSERT INTO swarm_config (id, scope, scopeId, key, value, isSecret, envPath, description, createdAt, lastUpdatedAt, encrypted, exportToEnv)
|
|
21502
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *`, [
|
|
21503
|
+
crypto.randomUUID(),
|
|
20903
21504
|
data.scope,
|
|
20904
21505
|
scopeId,
|
|
20905
21506
|
data.key,
|
|
@@ -20909,8 +21510,13 @@ async function upsertSwarmConfig(data) {
|
|
|
20909
21510
|
description,
|
|
20910
21511
|
now,
|
|
20911
21512
|
now,
|
|
20912
|
-
encryptedFlag
|
|
21513
|
+
encryptedFlag,
|
|
21514
|
+
restricted ? 0 : data.exportToEnv ?? defaultExportToEnv(data.key) ? 1 : 0
|
|
20913
21515
|
]);
|
|
21516
|
+
if (data.scope === "agent" && scopeId) {
|
|
21517
|
+
await clearAgentModelProfileOnOverrideChange(scopeId, data.key, existing, written);
|
|
21518
|
+
}
|
|
21519
|
+
return written;
|
|
20914
21520
|
});
|
|
20915
21521
|
if (!row)
|
|
20916
21522
|
throw new Error("Failed to upsert swarm config");
|
|
@@ -20940,7 +21546,10 @@ async function emitBuiltInIntegrationConnectedOnce(provider) {
|
|
|
20940
21546
|
} catch {}
|
|
20941
21547
|
}
|
|
20942
21548
|
async function deleteSwarmConfig(id) {
|
|
20943
|
-
const row = await getDbClient().get("DELETE FROM swarm_config WHERE id = ? RETURNING
|
|
21549
|
+
const row = await getDbClient().get("DELETE FROM swarm_config WHERE id = ? RETURNING *", [id]);
|
|
21550
|
+
if (row?.scope === "agent" && row.scopeId) {
|
|
21551
|
+
await clearAgentModelProfileOnOverrideChange(row.scopeId, row.key, row, null);
|
|
21552
|
+
}
|
|
20944
21553
|
if (row)
|
|
20945
21554
|
getDbClient().afterCommit(() => publishWorkerConfigNudge(row.scope, row.scopeId));
|
|
20946
21555
|
return row !== null;
|
|
@@ -24982,6 +25591,7 @@ var init_db2 = __esm(() => {
|
|
|
24982
25591
|
init_telemetry_trigger();
|
|
24983
25592
|
init_types();
|
|
24984
25593
|
init_codex_auth_failure();
|
|
25594
|
+
init_config_env_export();
|
|
24985
25595
|
init_config_secrets();
|
|
24986
25596
|
init_credentials();
|
|
24987
25597
|
init_github_pull_request();
|
|
@@ -24998,6 +25608,7 @@ var init_db2 = __esm(() => {
|
|
|
24998
25608
|
init_agents();
|
|
24999
25609
|
init_approvals();
|
|
25000
25610
|
init_context_versions();
|
|
25611
|
+
init_model_profiles();
|
|
25001
25612
|
init_runtime();
|
|
25002
25613
|
init_human_free();
|
|
25003
25614
|
init_read();
|
|
@@ -26191,4 +26802,4 @@ function getMemoryStore() {
|
|
|
26191
26802
|
var embeddingProvider2 = null, memoryStore = null;
|
|
26192
26803
|
var init_memory = () => {};
|
|
26193
26804
|
|
|
26194
|
-
export { slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, azureDevOpsContextKey, azureDevOpsWorkItemContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, init_catalog, catalog_default, mapTriggerSurface, init_telemetry_context, TELEMETRY_PROXY_ORIGIN, normalizeOrgWebsite, orgLogoUrl, isFilledOrgLogoUrl, init_org_website, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, getCurrentRequestUserId, init_request_auth_context, setTelemetryIngestObserver, isTelemetryEnabled, _resolveIntegrationType, _resolveIntegrationProvider, initTelemetry, setTelemetryRoleResolver, isTelemetryReady, track, trackRelayed, telemetry, emitIntegrationConnected, init_telemetry, auditAssetKeys, init_asset_key_audit, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, isInTransaction, init_db_client, breaksJsonValidity, scrubJsonValue, init_scrub_json, sealJson, init_sealed_json, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, init_templates3 as init_templates1, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, init_runtime, cachedUserRole, configureOrgDomainPersistence, recomputeOrgDomain, scheduleOrgDomainRecompute, init_telemetry_identity, resolveTriggerSurface, emitTaskTelemetry, init_telemetry_trigger, CODEX_AUTH_WATCH_NAMESPACE, codexAuthBenchMarkerKey, isCodexAuthFailureReason, init_codex_auth_failure, MASKED_SECRET_VALUE, init_config_secrets, HeartbeatExpiryError, init_heartbeat_expiry, isRuntimePoolsEnabled, init_runtime_pools_flag, normalizeDate, normalizeDateRequired, init_date_utils, rowToAgent, updateAgentCredentialState, updateAgentCredentialMissing, createAgent, getAgentById, EXTENSION_AGENT_ROLE, NOT_EXTENSION_AGENT_SQL, isExtensionAgent, extensionAgentAssignmentError, ReservedAgentRoleError, reservedRoleViolation, ExtensionAgentAssignmentError, getAllAgents, getAgentStatusCounts, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, getAgentDailyTaskCounts, init_agents, listApprovalRequestSummaries, getPendingApprovalVoteState, recordApprovalVotes, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, setHumanFreeQueueListener, drainHumanFreeReclassifyQueue, init_human_free, rowToAgentTask, getTaskById, getChildTasks, hasNonTerminalResumeChild, getSupersededTasksWithoutResume, getSupersededTasksWithUnsettledDependents, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, isLinearTrackerContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, init_read, onTaskStarted, init_task_lifecycle_events, channelTopic, addWorkerSubscription, removeWorkerSubscription, listSubscribedWorkerAgents, init_channels, publishWorkerNudge, init_worker_nudges, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, recordTaskProviderIfUnset, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, settleSupersededTaskDependents, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, getChildWorkflowRunId, getWorkflowRunParent, getWorkflowRunLineage, getSettledChildRunParentSteps, init_workflow_runs, resolveQuickJSPoolSize, init_quickjs_pool_config, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, init_reaction_shortcode, API_DRAINING_HEADER, API_DRAIN_MAX_MS_LIMIT, isApiDrainingResponse, init_api_drain, parseEnabledTools, init_enabled_tools, parseTaskToolManifest, selectTaskTools, init_task_tool_manifest, tierConfigKey, init_model_tier_keys, isInternalConfigKey, internalConfigKeyError, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateRuntimeTokenTtlHours, validateControllerTokenTtlDays, validateControllerGraceSec, validateConfigValue, init_swarm_config_guard, getDefaultAuthorizationIdForProvider, getOAuthApp, getOAuthAppById, getOAuthAppIdByProvider, createOAuthApp, updateOAuthAppById, upsertOAuthApp, listAuthorizationsForApp, getAuthorizationById, upsertAuthorization, updateAuthorizationTokens, updateAuthorizationIdentity, deleteAuthorizationById, deleteAuthorizationsForApp, createOAuthPending, consumeOAuthPending, gcOAuthPending, markAuthorizationRefreshFailed, getOAuthTokens, listAuthorizationSweepRows, listKeepAliveAuthorizations, deleteOAuthTokens, acquireOAuthRefreshLock, releaseOAuthRefreshLock, init_oauth, OpenAI, init_openai, CANDIDATE_SET_MULTIPLIER, isGraphExpansionEnabled, EMBEDDING_DIMENSIONS, init_constants, LONGTERM_ROOT, MEMORY_KEY_PATTERN, MEMORY_KEY_PATTERN_MESSAGE, MEMORY_KEY_MAX_LENGTH, isLongtermKey, longtermKeyError, isConsolidatedKey, consolidatedKeyMessage, resolveStoreKey, init_key_paths, computeScore, rerank, init_reranker, rowToCandidate, init_sqlite_store, getEmbeddingProvider, resetEmbeddingProvider, getMemoryStore, init_memory, embeddingProvider, embedScript, searchScripts, reembedAllScripts, init_embeddings2 as init_embeddings, upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, touchScratchScriptLastUsed, restoreScratchScriptLastUsedIfUnchanged, createScriptApi, listScriptApisForScript, getScriptApiById, getScriptApiSecret, updateScriptApi, rotateScriptApiSecret, deleteScriptApi, recordScriptApiUsage, init_db, oauthSecretName, registerStoredSecret, loadSecretRegistry, init_secret_registry, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, getTaskSteeringFieldsForTasks, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, WorkflowReplayStateError, init_workflow_replay, SESSION_ACTIVITY_REFRESH_MIN_INTERVAL_MS, refreshActiveSessionOnActivity, recordKeySeatMismatch, getScriptRunExecutionArgs, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, isSettledSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getResolvableDeferralOutcomes, markSlackDeferralResolved, noteSlackOutcomeDeliveryFailure, abandonSlackOutcomeDelivery, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, listSlackThreadsAwaitingHuman, isSlackThreadAwaitingHuman, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, insertTaskAttachment, recordTaskPullRequestAttachments, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdAndEventType, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, refreshDraftTaskLease, promoteAbandonedDraftTasks, releaseStaleReviewingTasks, releaseStaleOfferedTasksForOfflineAgents, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getAttributionByPerson, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, emitBuiltInIntegrationConnectedOnce, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, getCurrentStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, cancelApprovalRequestById, cancelPendingApprovalRequestsForRun, listCancelledApprovalRequestsForRun, listCancelledApprovalRequestsForStep, claimApprovalCancellationNotification, completeApprovalCancellationNotificationClaim, releaseApprovalCancellationNotificationClaim, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, getStaleApprovalRequests, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, emitMcpServerConnectedTelemetry, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, setApiKeyPlan, markKeyRateLimited, recordKeyAuthFailure, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getReadyAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, claimKv, deleteKv, KvTypeCollisionError, incrKv, kvPrefixUpperBound, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db2 as init_db1 };
|
|
26805
|
+
export { slackContextKey, chatSdkContextKey, chatThreadOfContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, azureDevOpsContextKey, azureDevOpsWorkItemContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, init_catalog, catalog_default, mapTriggerSurface, init_telemetry_context, TELEMETRY_PROXY_ORIGIN, normalizeOrgWebsite, orgLogoUrl, isFilledOrgLogoUrl, init_org_website, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, getCurrentRequestUserId, init_request_auth_context, setTelemetryIngestObserver, isTelemetryEnabled, _resolveIntegrationType, _resolveIntegrationProvider, initTelemetry, setTelemetryRoleResolver, isTelemetryReady, track, trackRelayed, telemetry, emitIntegrationConnected, init_telemetry, auditAssetKeys, init_asset_key_audit, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, isInTransaction, init_db_client, breaksJsonValidity, scrubJsonValue, init_scrub_json, sealJson, init_sealed_json, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, init_templates3 as init_templates1, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, init_runtime, cachedUserRole, configureOrgDomainPersistence, recomputeOrgDomain, scheduleOrgDomainRecompute, init_telemetry_identity, resolveTriggerSurface, emitTaskTelemetry, init_telemetry_trigger, CODEX_AUTH_WATCH_NAMESPACE, codexAuthBenchMarkerKey, isCodexAuthFailureReason, init_codex_auth_failure, isEnvExportRestrictedKey, init_config_env_export, MASKED_SECRET_VALUE, init_config_secrets, HeartbeatExpiryError, init_heartbeat_expiry, isRuntimePoolsEnabled, init_runtime_pools_flag, normalizeDate, normalizeDateRequired, init_date_utils, rowToAgent, updateAgentCredentialState, updateAgentCredentialMissing, createAgent, getAgentById, EXTENSION_AGENT_ROLE, NOT_EXTENSION_AGENT_SQL, isExtensionAgent, extensionAgentAssignmentError, ReservedAgentRoleError, reservedRoleViolation, ExtensionAgentAssignmentError, getAllAgents, getAgentStatusCounts, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, getAgentDailyTaskCounts, init_agents, listApprovalRequestSummaries, getPendingApprovalVoteState, recordApprovalVotes, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, vcsRepoName, vcsRepoUrlMatches, init_vcs_repo_match, rowToAgentTask, getTaskById, getChildTasks, hasNonTerminalResumeChild, SUPERSEDED_RESUME_REPAIR_WINDOW_MS, getSupersededTasksWithoutResume, getSupersededTasksWithUnsettledDependents, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getPendingChatRelayTasks, giveUpStaleChatRelays, markChatRelayAttempted, recordChatRelayError, markChatRelayDelivered, markChatRelayGivenUp, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, isLinearTrackerContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getAgentWorkingOnContextKey, getLatestActiveTaskByContextKey, getLatestLeadTaskByContextKey, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, init_read, MODEL_PROFILE_CONFIG_KEY, listModelProfiles, getModelProfileByName, createModelProfile, updateModelProfile, modelProfileReferences, modelProfileRefError, deleteModelProfile, getAgentDefaultProfileName, repoModelOverrideKeys, taskProfileError, init_model_profiles, setHumanFreeQueueListener, drainHumanFreeReclassifyQueue, init_human_free, onTaskStarted, init_task_lifecycle_events, channelTopic, addWorkerSubscription, removeWorkerSubscription, listSubscribedWorkerAgents, init_channels, publishWorkerNudge, init_worker_nudges, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, recordTaskProviderIfUnset, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, settleSupersededTaskDependents, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, getChildWorkflowRunId, getWorkflowRunParent, getWorkflowRunLineage, getSettledChildRunParentSteps, init_workflow_runs, CHAT_SDK_ADAPTER_NAMES, CHAT_SDK_ADAPTER_SCHEMAS, ChatSdkAdaptersDraftSchema, firstIssueText, isAdapterEntryEnabled, init_schema, resolveQuickJSPoolSize, init_quickjs_pool_config, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, completedStatusIcon, init_reaction_shortcode, API_DRAINING_HEADER, API_DRAIN_MAX_MS_LIMIT, isApiDrainingResponse, init_api_drain, parseEnabledTools, init_enabled_tools, parseTaskToolManifest, CHAT_TASK_ONLY_TOOLS, isChatSdkTask, selectTaskTools, init_task_tool_manifest, tierConfigKey, init_model_tier_keys, isApiOnlyConfigKey, isInternalConfigKey, internalConfigKeyError, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateRuntimeTokenTtlHours, validateControllerTokenTtlDays, validateControllerGraceSec, validateConfigValue, validateExportToEnv, init_swarm_config_guard, getDefaultAuthorizationIdForProvider, getOAuthApp, getOAuthAppById, getOAuthAppIdByProvider, createOAuthApp, updateOAuthAppById, upsertOAuthApp, listAuthorizationsForApp, getAuthorizationById, upsertAuthorization, updateAuthorizationTokens, updateAuthorizationIdentity, deleteAuthorizationById, deleteAuthorizationsForApp, createOAuthPending, consumeOAuthPending, gcOAuthPending, markAuthorizationRefreshFailed, getOAuthTokens, listAuthorizationSweepRows, listKeepAliveAuthorizations, deleteOAuthTokens, acquireOAuthRefreshLock, releaseOAuthRefreshLock, init_oauth, OpenAI, init_openai, CANDIDATE_SET_MULTIPLIER, isGraphExpansionEnabled, EMBEDDING_DIMENSIONS, init_constants, LONGTERM_ROOT, MEMORY_KEY_PATTERN, MEMORY_KEY_PATTERN_MESSAGE, MEMORY_KEY_MAX_LENGTH, isLongtermKey, longtermKeyError, isConsolidatedKey, consolidatedKeyMessage, resolveStoreKey, init_key_paths, computeScore, rerank, init_reranker, rowToCandidate, init_sqlite_store, getEmbeddingProvider, resetEmbeddingProvider, getMemoryStore, init_memory, embeddingProvider, embedScript, searchScripts, reembedAllScripts, init_embeddings2 as init_embeddings, upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, touchScratchScriptLastUsed, restoreScratchScriptLastUsedIfUnchanged, createScriptApi, listScriptApisForScript, getScriptApiById, getScriptApiSecret, updateScriptApi, rotateScriptApiSecret, deleteScriptApi, recordScriptApiUsage, init_db, oauthSecretName, registerStoredSecret, loadSecretRegistry, init_secret_registry, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, getTaskSteeringFieldsForTasks, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, WorkflowReplayStateError, init_workflow_replay, SESSION_ACTIVITY_REFRESH_MIN_INTERVAL_MS, refreshActiveSessionOnActivity, recordKeySeatMismatch, getScriptRunExecutionArgs, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, isSettledSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getResolvableDeferralOutcomes, markSlackDeferralResolved, noteSlackOutcomeDeliveryFailure, abandonSlackOutcomeDelivery, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, listSlackThreadsAwaitingHuman, isSlackThreadAwaitingHuman, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, insertTaskAttachment, recordTaskPullRequestAttachments, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdAndEventType, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, refreshDraftTaskLease, promoteAbandonedDraftTasks, releaseStaleReviewingTasks, releaseStaleOfferedTasksForOfflineAgents, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getAttributionByPerson, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, emitBuiltInIntegrationConnectedOnce, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, getCurrentStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, cancelApprovalRequestById, cancelPendingApprovalRequestsForRun, listCancelledApprovalRequestsForRun, listCancelledApprovalRequestsForStep, claimApprovalCancellationNotification, completeApprovalCancellationNotificationClaim, releaseApprovalCancellationNotificationClaim, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, getStaleApprovalRequests, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, emitMcpServerConnectedTelemetry, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, setApiKeyPlan, markKeyRateLimited, recordKeyAuthFailure, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getReadyAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, claimKv, deleteKv, KvTypeCollisionError, incrKv, kvPrefixUpperBound, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db2 as init_db1 };
|