@desplega.ai/agent-swarm 2.13.4 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-99n6z9ky.js +17 -0
- package/dist/{acp-targets-zrk9k0n7.js → acp-targets-23exz4z4.js} +10 -10
- package/dist/{actions-acqqj9jn.js → actions-zcr25x27.js} +61 -40
- package/dist/{agent-fs-provision-zmaykqnd.js → agent-fs-provision-7fa9e12e.js} +4 -4
- package/dist/{amp-adapter-a7ts8tmw.js → amp-adapter-s7ytmv6b.js} +3 -3
- package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
- package/dist/{app-tmwa442h.js → app-5d3sz1hy.js} +7 -7
- package/dist/{approval-notifications-6psaaaye.js → approval-notifications-7qgkzkzx.js} +8 -8
- package/dist/{assistant-564v6emv.js → assistant-p2yvhc3j.js} +37 -32
- package/dist/{boot-args-schema-n099e0f2.js → boot-args-schema-ry6cb0p7.js} +1 -1
- package/dist/{boot-reembed-epvg4fp9.js → boot-reembed-2hkm3vz2.js} +1 -1
- package/dist/{boot-reembed-chx66qfk.js → boot-reembed-c9643ms3.js} +1 -1
- package/dist/{boot-scrub-sweep-dhkfp0a7.js → boot-scrub-sweep-3ycxr51t.js} +2 -2
- package/dist/{boot-seeds-m74fc07r.js → boot-seeds-2hzvvzg0.js} +4 -4
- package/dist/{boxd-451q55ys.js → boxd-9py3x0jb.js} +2 -2
- package/dist/{claude-adapter-hw63yj3j.js → claude-adapter-dnkww93e.js} +9 -9
- package/dist/{claude-managed-adapter-z5s7fx6p.js → claude-managed-adapter-yk0cr5x6.js} +4 -4
- package/dist/{claude-managed-setup-wee1762m.js → claude-managed-setup-4byxpp47.js} +5 -5
- package/dist/{claude-sdk-session-cktyqkpk.js → claude-sdk-session-4wf3dbvs.js} +13163 -12195
- package/dist/{cli-5rxsb3wq.js → cli-096aftq6.js} +12 -7
- package/dist/{cli-5rgm8p39.js → cli-0e914dp9.js} +3 -3
- package/dist/{cli-bzcwwebm.js → cli-0h6m6z5g.js} +1 -1
- package/dist/{cli-cah298e5.js → cli-0k7ppk9k.js} +231 -124
- package/dist/{cli-ja450998.js → cli-1nfabrt4.js} +8 -8
- package/dist/{cli-jzerrzgc.js → cli-2414h5r9.js} +8 -8
- package/dist/{cli-b768ek79.js → cli-24wervhz.js} +38 -0
- package/dist/{cli-93n305hm.js → cli-2ayk9gn8.js} +2 -2
- package/dist/{cli-kr0jpw9c.js → cli-2ckwgs7q.js} +1 -1
- package/dist/{cli-d5pc8ep0.js → cli-2savn6mm.js} +11 -100
- package/dist/{cli-jbrc98qb.js → cli-2zjxake1.js} +4 -4
- package/dist/{cli-4q2c8rxw.js → cli-37p61fcg.js} +15 -9
- package/dist/{cli-2vp0z049.js → cli-39t9d248.js} +1 -1
- package/dist/{cli-sa02jsqt.js → cli-3mhdmcd4.js} +1 -1
- package/dist/{cli-x2cem5vy.js → cli-3wsabyt0.js} +2 -2
- package/dist/{cli-dqgnbnxs.js → cli-466jjrwe.js} +16 -2
- package/dist/{cli-zhwjdhjr.js → cli-6ajyhxh7.js} +2 -2
- package/dist/{cli-3bxrrh53.js → cli-6yy4fepf.js} +4 -4
- package/dist/{cli-hhtbandk.js → cli-73rmgm45.js} +2 -2
- package/dist/{cli-8b4rpnwj.js → cli-7ca8hczj.js} +1 -1
- package/dist/{cli-0h8skzss.js → cli-7g5qj2ca.js} +4 -3
- package/dist/{cli-m1sns1da.js → cli-7w1fs01q.js} +2 -2
- package/dist/{cli-xwsm6xkr.js → cli-84wxwt3z.js} +1 -1
- package/dist/{cli-qzz6tz8s.js → cli-84xn7bgz.js} +1 -1
- package/dist/{cli-49aq3cyn.js → cli-879txsac.js} +5 -5
- package/dist/{cli-bv4vvnmg.js → cli-8vbxjzk0.js} +3 -3
- package/dist/{cli-7by7vp6m.js → cli-91amj3md.js} +3 -3
- package/dist/{cli-60dwk8tx.js → cli-930zbczq.js} +3 -3
- package/dist/{cli-7g3fg4gf.js → cli-9fwznq4p.js} +10 -10
- package/dist/{cli-4pbwg7sn.js → cli-9j1t3kf6.js} +2 -2
- package/dist/{cli-tzw1jr2t.js → cli-9j47sgzy.js} +2 -2
- package/dist/{cli-0fgvnb0x.js → cli-ad00h1st.js} +7 -7
- package/dist/{cli-kj84fqxz.js → cli-adzmmcvf.js} +19 -7
- package/dist/{cli-3tzmh38q.js → cli-ayxxkk3p.js} +68 -25
- package/dist/{cli-4vynxtrb.js → cli-bqfx72e6.js} +10 -3
- package/dist/{cli-8cas2xvp.js → cli-cbg0j1yt.js} +2716 -2643
- package/dist/{cli-fw67mnyc.js → cli-cg1q8ymp.js} +1 -1
- package/dist/{cli-he5nxaa8.js → cli-dw9rtjm3.js} +1 -1
- package/dist/{cli-jg5txpm6.js → cli-dy754erz.js} +83 -1
- package/dist/{cli-tsc3pdfd.js → cli-edxfzgah.js} +4 -4
- package/dist/{cli-hyqksecw.js → cli-ejnhs815.js} +15 -15
- package/dist/{cli-k0nebh10.js → cli-enavhq6r.js} +1 -1
- package/dist/{cli-ea7nz50q.js → cli-f2rwt43y.js} +14 -14
- package/dist/{cli-zjdhrzm0.js → cli-f9g96z28.js} +8 -8
- package/dist/{cli-rmgvwcmy.js → cli-fww016hh.js} +534 -70
- package/dist/{cli-rv3y60bt.js → cli-g6a696c0.js} +4 -4
- package/dist/{cli-z1vam71h.js → cli-gc6b94tj.js} +2 -2
- package/dist/{cli-p436yrzp.js → cli-gcyws2bp.js} +2 -2
- package/dist/{cli-srktrbby.js → cli-hzhv7yac.js} +1 -1
- package/dist/{cli-0p76my9q.js → cli-jcnc5ret.js} +44 -32
- package/dist/{cli-tr19nyn9.js → cli-jgq9xptq.js} +7 -7
- package/dist/{cli-pz1dp12c.js → cli-jwnac23b.js} +1 -1
- package/dist/{cli-904wk98s.js → cli-kc7vd07m.js} +917 -350
- package/dist/{cli-t0jmkcah.js → cli-kg63yp1r.js} +14 -14
- package/dist/{cli-ts5yv7dn.js → cli-krk8y8c7.js} +835 -157
- package/dist/{cli-jyhbvdga.js → cli-m0ea8ggd.js} +8 -10
- package/dist/{cli-944w9wb4.js → cli-md4tn21h.js} +20 -15
- package/dist/{cli-zexwhj3f.js → cli-mv8ft7b0.js} +10 -9
- package/dist/{cli-phdzn699.js → cli-mw1tmn3x.js} +217 -27
- package/dist/{cli-5ashycw3.js → cli-njvpngc6.js} +3 -3
- package/dist/{cli-9ah37a8a.js → cli-phe2vcw5.js} +10 -7
- package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
- package/dist/{cli-n1kjs58m.js → cli-pq0kv31y.js} +5 -5
- package/dist/{cli-pz1nq5xm.js → cli-q457ga28.js} +6 -6
- package/dist/{cli-s33bzmk0.js → cli-q5n3deaf.js} +1 -1
- package/dist/{cli-4fpa0zns.js → cli-qkbevqer.js} +3 -3
- package/dist/{cli-29h5239w.js → cli-qrwjk4xy.js} +5 -5
- package/dist/{cli-kezzteka.js → cli-r04ve9xw.js} +1 -1
- package/dist/{cli-3xqad83h.js → cli-r495stwd.js} +2 -2
- package/dist/{cli-1kvcsd2f.js → cli-r9d2tya0.js} +71 -3
- package/dist/{cli-ybte1fqc.js → cli-rp1n2xpd.js} +1 -1
- package/dist/{cli-fkpnx3vf.js → cli-rs1rzwp4.js} +3 -2
- package/dist/{cli-h9d3sdnc.js → cli-rzbsh6bw.js} +1 -1
- package/dist/{cli-94gx6ze9.js → cli-s4pccby1.js} +1 -1
- package/dist/{cli-cq4am6vg.js → cli-shyhb4t5.js} +10 -10
- package/dist/{cli-gtj12v95.js → cli-srq69pn1.js} +1 -1
- package/dist/{cli-azj9t1f9.js → cli-tc165vrb.js} +48 -5
- package/dist/{cli-gse7bp3z.js → cli-v4z5v3jd.js} +300 -81
- package/dist/{cli-p3knvk62.js → cli-vxmmttmt.js} +132 -53
- package/dist/{cli-404am6f3.js → cli-w4bvtxet.js} +7 -7
- package/dist/{cli-gkv0r2hq.js → cli-wd7b5hgc.js} +71 -9
- package/dist/{cli-akm6y2a8.js → cli-wvbaq052.js} +1 -1
- package/dist/{cli-ywy8yz6t.js → cli-wvgg7r4j.js} +2 -2
- package/dist/{cli-ka48vpev.js → cli-wym6rxgt.js} +165 -6
- package/dist/{cli-nc4pbwmp.js → cli-yd7e590v.js} +12 -12
- package/dist/{cli-3zrwrnz7.js → cli-yjb3cddd.js} +1 -1
- package/dist/{cli-7gbff32z.js → cli-z8t4485r.js} +2 -2
- package/dist/{cli-hdhpdrka.js → cli-ze1ndjs4.js} +4 -6
- package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
- package/dist/cli.js +28 -28
- package/dist/{codex-adapter-2fs2c0n6.js → codex-adapter-eq61radw.js} +8 -8
- package/dist/{codex-hook-jxjv6dy5.js → codex-hook-8nmepvz6.js} +3 -3
- package/dist/{codex-login-ktfg1cxk.js → codex-login-vbd9707w.js} +1 -1
- package/dist/{codex-session-runner-r55tmx4c.js → codex-session-runner-rfx355h4.js} +9 -9
- package/dist/{commands-0mxdy9x8.js → commands-d1z0sx62.js} +3 -3
- package/dist/{controller-g3vkfhr4.js → controller-9hz6d8x3.js} +4 -4
- package/dist/{controllers-connect-4wdmncqt.js → controllers-connect-tz07d2xr.js} +24 -25
- package/dist/core-dynsv289.js +41 -0
- package/dist/{cursor-adapter-t9qb96q2.js → cursor-adapter-ef22ze3j.js} +2 -2
- package/dist/{db-487vvyv9.js → db-gd81d68c.js} +3 -3
- package/dist/{db-76p7w3gr.js → db-vrckks6q.js} +4 -2
- package/dist/{devin-adapter-3bp6rape.js → devin-adapter-kdt6a2bh.js} +1 -1
- package/dist/{dispatcher-64rp6w67.js → dispatcher-76as8w2t.js} +21 -22
- package/dist/{docker-a59g3ebm.js → docker-51ta7jsh.js} +2 -2
- package/dist/dsh-adapter-ypfvcdyz.js +11 -0
- package/dist/{e2b-dc8f6ctq.js → e2b-05kn3kpq.js} +16 -5
- package/dist/{e2b-3ykbe805.js → e2b-dm9r8hpy.js} +3 -3
- package/dist/{easter-egg-3d-jrrwyf55.js → easter-egg-3d-sg21j15g.js} +1 -1
- package/dist/{embedding-space-001hhhpk.js → embedding-space-zsdw37bb.js} +13 -23
- package/dist/{embeddings-esj19cnw.js → embeddings-p4e3e1m6.js} +1 -1
- package/dist/{event-bus-7gbsr0g4.js → event-bus-tvf2grf4.js} +1 -1
- package/dist/{execute-301hkxqg.js → execute-nztd0af0.js} +1 -1
- package/dist/{external-channel-w10e2j05.js → external-channel-717yzn4d.js} +2 -2
- package/dist/fx-adapter-9k0hptnz.js +20 -0
- package/dist/grok-adapter-skdj2pce.js +20 -0
- package/dist/handlers-5btjqkz6.js +39 -0
- package/dist/{heartbeat-tbrj7vhq.js → heartbeat-vfb1gy84.js} +24 -25
- package/dist/{hook-tx917rqw.js → hook-ctz0xmp3.js} +11 -11
- package/dist/{hook-3am1sq68.js → hook-eh52p7yd.js} +6 -6
- package/dist/{http-3rmemtqy.js → http-zregegrx.js} +902 -198
- package/dist/{index-s7xtvc0f.js → index-5kx15d19.js} +1 -1
- package/dist/index-7w8p6em0.js +41 -0
- package/dist/index-evay0xyk.js +17 -0
- package/dist/{index-2jw11t8s.js → index-fdym6ryb.js} +25 -26
- package/dist/{index-3j803vnb.js → index-mtnbhe12.js} +20533 -19786
- package/dist/index-vz4semsx.js +38 -0
- package/dist/{index-gfnq66t1.js → index-x9qf8dg7.js} +294 -29
- package/dist/index-y3s0xp2v.js +43 -0
- package/dist/{k8s-36gfn847.js → k8s-ejkk0aw7.js} +2 -2
- package/dist/{keepalive-9px3t7qj.js → keepalive-zdqay870.js} +4 -5
- package/dist/lead-6cscw8a5.js +82 -0
- package/dist/{maintenance-vwqjwst6.js → maintenance-t5ndg11m.js} +1 -1
- package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
- package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
- package/dist/{node-z67yjre7.js → node-jkdd5w7m.js} +290 -70
- package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
- package/dist/{oauth-refresh-sweep-yqry3wn4.js → oauth-refresh-sweep-y9zyd7t6.js} +3 -4
- package/dist/{object-webhooks-8s1wtths.js → object-webhooks-mkca91s0.js} +7 -7
- package/dist/{onboard-hb8czx0p.js → onboard-ss995244.js} +11 -9
- package/dist/{opencode-adapter-djd6m6dk.js → opencode-adapter-mwpz0278.js} +8 -8
- package/dist/{otel-impl-2ymwyczz.js → otel-impl-6n6vva3x.js} +2 -2
- package/dist/{pending-nxavtvx7.js → pending-2sxh1t6j.js} +22 -23
- package/dist/{pi-mono-adapter-d2cpmcy4.js → pi-mono-adapter-sfb7zy43.js} +13 -13
- package/dist/{pricing-refresh-1yz8jkqv.js → pricing-refresh-h79bg4cf.js} +2 -2
- package/dist/{rbac-roles-7s6m31xw.js → rbac-roles-ckq0czp4.js} +2 -2
- package/dist/{rbac-roles-dbpx0x9v.js → rbac-roles-jg2e260w.js} +3 -3
- package/dist/{render-v2-7y20rjrn.js → render-v2-ymbshmn0.js} +7 -7
- package/dist/{resume-wz546x47.js → resume-jdhnt4jk.js} +10 -10
- package/dist/{runtime-cb5bd9tz.js → runtime-y28jhhnf.js} +1 -1
- package/dist/{session-access-4vcft8kq.js → session-access-k4ta5hvp.js} +5 -5
- package/dist/{session-source-backfill-57b50tpw.js → session-source-backfill-528j4s8j.js} +3 -3
- package/dist/{setup-e1tevjyj.js → setup-d6pj82fr.js} +15 -6
- package/dist/thread-buffer-9w6x5zec.js +40 -0
- package/dist/{tree-visibility-07wf1nct.js → tree-visibility-kjxv3nxk.js} +2 -2
- package/dist/{user-merge-jobs-n20qpv6s.js → user-merge-jobs-rabbncf6.js} +3 -3
- package/dist/{virtual-modules-6fxmn1yv.js → virtual-modules-22k51txd.js} +3 -3
- package/dist/{work-objects-eg7y48pe.js → work-objects-xtjbar3r.js} +26 -30
- package/dist/{worker-follow-up-jnvnnf2b.js → worker-follow-up-fg48vk6d.js} +21 -22
- package/dist/worker-g4aj93dt.js +82 -0
- package/dist/{x-d27jj7z7.js → x-vfsqypht.js} +2 -2
- package/openapi.json +633 -25
- package/package.json +10 -10
- package/src/apps/definition.ts +76 -24
- package/src/apps/row-store.ts +67 -0
- package/src/apps/script-types.ts +131 -21
- package/src/apps/store.ts +4 -1
- package/src/apps/sync.ts +20 -5
- package/src/azure-devops/boards-sync.ts +1 -1
- package/src/be/db/script-runs.ts +33 -0
- package/src/be/db/slack-card-groups.ts +147 -0
- package/src/be/db/slack-trees.ts +38 -1
- package/src/be/db/task-idempotency.ts +63 -0
- package/src/be/db/tasks/read.ts +27 -1
- package/src/be/db/tasks/write.ts +51 -14
- package/src/be/db/users/avatar.ts +12 -0
- package/src/be/db/workflow-idempotency.ts +6 -1
- package/src/be/db/workflows/read.ts +79 -0
- package/src/be/db.ts +129 -152
- package/src/be/improvements.ts +24 -2
- package/src/be/mcp-proxy.ts +45 -11
- package/src/be/memory/embedding-space.ts +10 -20
- package/src/be/memory/index.ts +35 -0
- package/src/be/memory/providers/openai-embedding.ts +10 -0
- package/src/be/migrations/344_user_avatar.sql +4 -0
- package/src/be/migrations/345_task_status_kind.sql +6 -0
- package/src/be/migrations/348_task_deferred_until.sql +4 -0
- package/src/be/migrations/354_durable_objects.sql +9 -0
- package/src/be/migrations/356_slack_outcome_card_groups.sql +14 -0
- package/src/be/migrations/357_task_idempotency_keys.sql +27 -0
- package/src/be/migrations/362_favorites_app.sql +36 -0
- package/src/be/primitives/object-embed.ts +2 -2
- package/src/be/primitives/objects.ts +2 -2
- package/src/be/repo-checked-update.ts +58 -5
- package/src/be/requester-timezone.ts +10 -0
- package/src/be/runtime-pools/supervisor.ts +1 -0
- package/src/be/script-connections.ts +5 -1
- package/src/be/script-credential-broker.ts +29 -2
- package/src/be/scripts/durable.ts +204 -0
- package/src/be/scripts/extract-schema.ts +29 -4
- package/src/be/scripts/run-credential.ts +1 -8
- package/src/be/scripts/typecheck.ts +33 -8
- package/src/be/seed-scripts/catalog/memory-eval.ts +11 -2
- package/src/be/seed-scripts/catalog/tool-usage.ts +27 -8
- package/src/be/swarm-config-guard.ts +91 -7
- package/src/be/users.ts +33 -12
- package/src/bitbucket/handlers.ts +1 -1
- package/src/comb/review-batch.ts +16 -5
- package/src/commands/context-preamble.ts +237 -0
- package/src/commands/credential-outcome-report.ts +96 -0
- package/src/commands/e2b.ts +14 -0
- package/src/commands/entrypoint-mcp-config.ts +231 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +2 -1
- package/src/commands/onboard/env-generator.ts +16 -7
- package/src/commands/runner.ts +72 -10
- package/src/commands/setup.tsx +17 -3
- package/src/event-waits/github.ts +39 -6
- package/src/event-waits/index.ts +4 -2
- package/src/event-waits/types.ts +10 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/github/app.ts +177 -13
- package/src/github/handlers.ts +7 -2
- package/src/github/pull-request-state.ts +100 -11
- package/src/gitlab/handlers.ts +2 -2
- package/src/heartbeat/heartbeat.ts +6 -1
- package/src/hooks/hook.ts +8 -2
- package/src/hooks/native-tool-hooks.ts +4 -2
- package/src/http/api-keys.ts +26 -0
- package/src/http/apps.ts +82 -42
- package/src/http/asset-key-write.ts +45 -0
- package/src/http/assets.ts +4 -3
- package/src/http/comb.ts +21 -5
- package/src/http/config.ts +8 -4
- package/src/http/github-token.ts +27 -6
- package/src/http/heartbeat.ts +5 -0
- package/src/http/index.ts +12 -6
- package/src/http/kv.ts +7 -5
- package/src/http/mcp-oauth.ts +16 -0
- package/src/http/mcp-servers.ts +43 -3
- package/src/http/memory.ts +28 -1
- package/src/http/metrics.ts +11 -4
- package/src/http/onboarding.ts +12 -1
- package/src/http/pages.ts +4 -10
- package/src/http/repos.ts +27 -11
- package/src/http/request-principal.ts +27 -1
- package/src/http/schedules.ts +42 -14
- package/src/http/script-connection-proxy.ts +3 -1
- package/src/http/script-runs.ts +21 -10
- package/src/http/scripts.ts +177 -26
- package/src/http/session-cost-recompute.ts +9 -4
- package/src/http/sessions.ts +7 -2
- package/src/http/skills.ts +70 -0
- package/src/http/status.ts +2 -0
- package/src/http/tasks.ts +115 -19
- package/src/http/trackers/jira.ts +18 -3
- package/src/http/trackers/linear.ts +3 -0
- package/src/http/users.ts +5 -0
- package/src/http/webhooks.ts +19 -1
- package/src/http/workflows.ts +5 -10
- package/src/integrations/chat-sdk/commands.ts +3 -1
- package/src/jira/sync.ts +1 -1
- package/src/kv-limits.ts +2 -0
- package/src/kv-reserved-namespaces.ts +25 -2
- package/src/linear/sync.ts +5 -3
- package/src/prompts/session-templates.ts +50 -0
- package/src/prompts/session-turns.ts +30 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +5 -0
- package/src/providers/claude-managed-adapter.ts +14 -0
- package/src/providers/claude-sdk-session.ts +19 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +3 -5
- package/src/providers/runtime-dependencies.ts +11 -8
- package/src/rbac/legacy-policy.ts +7 -0
- package/src/rbac/permissions.ts +27 -0
- package/src/scheduler/deferred-task-waits.ts +74 -13
- package/src/scheduler/scheduler.ts +36 -18
- package/src/script-workflows/executor.ts +37 -8
- package/src/script-workflows/supervisor.ts +14 -0
- package/src/scripts-runtime/ctx.ts +5 -1
- package/src/scripts-runtime/durable-object-base.ts +19 -0
- package/src/scripts-runtime/eval-harness.ts +46 -1
- package/src/scripts-runtime/executors/native.ts +13 -1
- package/src/scripts-runtime/executors/quickjs-bundle.ts +20 -1
- package/src/scripts-runtime/executors/quickjs-prelude.ts +40 -1
- package/src/scripts-runtime/executors/quickjs-runner.ts +26 -3
- package/src/scripts-runtime/executors/quickjs-worker.ts +2 -1
- package/src/scripts-runtime/executors/types.ts +26 -0
- package/src/scripts-runtime/extract-signature.ts +96 -1
- package/src/scripts-runtime/loader.ts +11 -5
- package/src/scripts-runtime/mcp-client.ts +1 -1
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/swarm-config.ts +7 -0
- package/src/scripts-runtime/swarm-sdk.ts +12 -2
- package/src/scripts-runtime/types/stdlib.d.ts +27 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +20 -2
- package/src/scripts-runtime/types/swarm-sdk.d.ts +27 -1
- package/src/slack/actions.ts +25 -1
- package/src/slack/assistant.ts +8 -0
- package/src/slack/blocks.ts +35 -0
- package/src/slack/channel-activity.ts +7 -0
- package/src/slack/enrich.ts +46 -54
- package/src/slack/files.ts +173 -23
- package/src/slack/handlers.test.ts +17 -19
- package/src/slack/handlers.ts +15 -14
- package/src/slack/render-v2.ts +403 -17
- package/src/slack/responses.ts +61 -5
- package/src/slack/session-mirror.ts +10 -5
- package/src/slack/task-output.ts +25 -14
- package/src/slack/templates.ts +9 -0
- package/src/slack/thread-participants.ts +64 -24
- package/src/slack/watcher.ts +4 -4
- package/src/slack/work-objects.ts +1 -1
- package/src/stdio.ts +5 -0
- package/src/tests/agents-list-model-display.test.ts +4 -0
- package/src/tests/api-drain-worker-e2e.test.ts +0 -2
- package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
- package/src/tests/approval-card-resolution.test.ts +2 -17
- package/src/tests/approval-requests-notifications.test.ts +41 -27
- package/src/tests/approval-requests.test.ts +137 -369
- package/src/tests/apps-script-types.test.ts +63 -16
- package/src/tests/apps-sort-order.test.ts +87 -0
- package/src/tests/apps-sync-engine.test.ts +5 -3
- package/src/tests/apps-table-filters-migration.test.ts +44 -25
- package/src/tests/bedrock-model-groups.test.ts +4 -0
- package/src/tests/bitbucket-handlers.test.ts +2 -0
- package/src/tests/channel-activity.test.ts +9 -0
- package/src/tests/chat-sdk-commands.test.ts +1 -0
- package/src/tests/chatgpt-subscription-model-groups.test.ts +4 -0
- package/src/tests/claude-adapter.test.ts +35 -0
- package/src/tests/claude-hook-output.test.ts +2 -0
- package/src/tests/claude-managed-adapter.test.ts +15 -3
- package/src/tests/claude-sdk-stderr.test.ts +28 -0
- package/src/tests/codex-adapter.test.ts +3 -92
- package/src/tests/codex-gpt6-release.test.ts +4 -9
- package/src/tests/codex-oauth-credential-info.test.ts +35 -18
- package/src/tests/codex-oauth.test.ts +0 -6
- package/src/tests/codex-pool.test.ts +5 -214
- package/src/tests/codex-rate-limit-parse.test.ts +0 -7
- package/src/tests/codex-swarm-events.test.ts +11 -54
- package/src/tests/comb-review-batch.test.ts +17 -4
- package/src/tests/comb-status.test.ts +1 -0
- package/src/tests/db-client-busy-retry.test.ts +49 -16
- package/src/tests/db-client.test.ts +11 -5
- package/src/tests/db-task-read-contract.test.ts +1 -0
- package/src/tests/db-task-write-contract.test.ts +2 -2
- package/src/tests/defer-task.test.ts +24 -1
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/e2b-dispatch.test.ts +13 -1
- package/src/tests/e2e-shards.test.ts +9 -9
- package/src/tests/enabled-tools.test.ts +0 -2
- package/src/tests/entrypoint-mcp-config.test.ts +642 -0
- package/src/tests/fixtures/base-prompt-baseline.json +6 -6
- package/src/tests/fixtures/onboard/content.env.txt +2 -2
- package/src/tests/fixtures/onboard/dev.env.txt +2 -2
- package/src/tests/fixtures/onboard/full-all.env.txt +2 -2
- package/src/tests/fixtures/onboard/full.env.txt +2 -2
- package/src/tests/fixtures/onboard/research.env.txt +2 -2
- package/src/tests/fixtures/onboard/solo.env.txt +2 -2
- package/src/tests/fixtures/runner-missing-dependency.ts +2 -1
- package/src/tests/fx-adapter.test.ts +4 -5
- package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
- package/src/tests/gitlab-handlers.test.ts +2 -0
- package/src/tests/heartbeat-jev-gate.test.ts +9 -241
- package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
- package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
- package/src/tests/heartbeat.test.ts +1 -0
- package/src/tests/hook-mcp-config-precedence.test.ts +59 -0
- package/src/tests/hook-ping-me-order.test.ts +1 -0
- package/src/tests/hook-runtime-close.test.ts +1 -0
- package/src/tests/improvements-payload.test.ts +2 -2
- package/src/tests/key-usage-selection.test.ts +302 -0
- package/src/tests/memory-e2e.test.ts +34 -103
- package/src/tests/memory-key-paths.test.ts +5 -0
- package/src/tests/memory-rater-llm.test.ts +33 -149
- package/src/tests/memory-store.test.ts +24 -125
- package/src/tests/memory.test.ts +31 -100
- package/src/tests/merge-gate-detect-changes.test.ts +108 -2
- package/src/tests/model-groups-live-catalog.test.ts +4 -0
- package/src/tests/oauth-credential-bindings.test.ts +8 -3
- package/src/tests/oauth-refresh-failure.test.ts +15 -3
- package/src/tests/onboard-env.test.ts +1 -1
- package/src/tests/openai-compatible-providers.test.ts +5 -0
- package/src/tests/openapi-route-headers.test.ts +2 -1
- package/src/tests/opus-5-5-registry.test.ts +4 -0
- package/src/tests/otel-service-name.test.ts +0 -9
- package/src/tests/otel-session-cost-metrics.test.ts +1 -38
- package/src/tests/pool-session-logs.test.ts +8 -42
- package/src/tests/pre-push-affected-tests.test.ts +106 -0
- package/src/tests/prompt-template-session.test.ts +3 -0
- package/src/tests/provider-runtime-dependencies.test.ts +26 -15
- package/src/tests/routing-affinity-inventory.test.ts +11 -0
- package/src/tests/runner-api-drain.test.ts +2 -17
- package/src/tests/runner-context-preamble.test.ts +202 -0
- package/src/tests/runner-repo-clone-args.test.ts +116 -0
- package/src/tests/runner-terminal-window-report.test.ts +132 -0
- package/src/tests/runtime-supervisor-failures.test.ts +1 -0
- package/src/tests/sandboxed-process.test.ts +26 -21
- package/src/tests/schedule-http-triage-tools.test.ts +12 -9
- package/src/tests/scheduled-tasks.test.ts +14 -51
- package/src/tests/scheduler-occurrence.test.ts +60 -9
- package/src/tests/script-connections-mcp.test.ts +6 -3
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/script-executor-conformance.test.ts +4 -48
- package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
- package/src/tests/script-native-startup.test.ts +21 -25
- package/src/tests/scripts-namespaces.test.ts +3 -1
- package/src/tests/secret-rules.test.ts +4 -2
- package/src/tests/secret-scrubber.test.ts +8 -2
- package/src/tests/session-cost-recompute-unit.test.ts +39 -0
- package/src/tests/session-costs-recompute-all-providers.test.ts +6 -3
- package/src/tests/session-logs.test.ts +1 -260
- package/src/tests/session-route-posture.test.ts +7 -1
- package/src/tests/slack-file-tools-attachments.test.ts +14 -9
- package/src/tests/slack-identity-resolution.test.ts +10 -3
- package/src/tests/slack-inline-output.test.ts +10 -8
- package/src/tests/slack-render-v2.test.ts +14 -152
- package/src/tests/slack-steering.test.ts +8 -2
- package/src/tests/slack-thread-participants.test.ts +11 -1
- package/src/tests/sonnet-5-5-registry.test.ts +4 -0
- package/src/tests/swarm-config-encryption.test.ts +5 -8
- package/src/tests/task-cascade-fail.test.ts +1 -0
- package/src/tests/task-supersede-resume.test.ts +1 -0
- package/src/tests/test-proc.ts +5 -2
- package/src/tests/ui-spec-script-actions-config.test.ts +7 -3
- package/src/tests/window-stream-reporter.test.ts +122 -0
- package/src/tests/workflow-agent-task-retry.test.ts +1 -3
- package/src/tests/workflow-cascade-cancel.test.ts +1 -0
- package/src/tests/workflow-retry-v2.test.ts +34 -43
- package/src/tests/workflow-retry-validation.test.ts +8 -48
- package/src/tests/workflow-triggers-v2.test.ts +35 -11
- package/src/tests/worktree-reaper.test.ts +2 -2
- package/src/tools/app-patch.ts +6 -2
- package/src/tools/app-upsert.ts +8 -4
- package/src/tools/cancel-task.ts +2 -2
- package/src/tools/defer-task.ts +24 -79
- package/src/tools/get-task-details.ts +8 -4
- package/src/tools/get-tasks.ts +13 -2
- package/src/tools/kv/kv-get.ts +2 -0
- package/src/tools/kv/kv-list.ts +11 -5
- package/src/tools/kv/kv-set.ts +1 -3
- package/src/tools/manage-user.ts +9 -0
- package/src/tools/repos/update-repo.ts +37 -19
- package/src/tools/schedules/run-schedule-now.ts +21 -1
- package/src/tools/script-apis.ts +9 -4
- package/src/tools/script-common.ts +2 -2
- package/src/tools/script-run.ts +8 -0
- package/src/tools/script-upsert.ts +1 -1
- package/src/tools/slack-download-file.ts +15 -12
- package/src/tools/slack-post.ts +7 -1
- package/src/tools/slack-read.ts +3 -1
- package/src/tools/slack-reply.ts +16 -0
- package/src/tools/slack-start-thread.ts +8 -1
- package/src/tools/slack-upload-file.ts +99 -96
- package/src/tools/store-progress.ts +5 -3
- package/src/tools/swarm-config/set-config.ts +3 -1
- package/src/tools/swarm-x.ts +0 -2
- package/src/tools/utils.ts +3 -0
- package/src/types.ts +101 -2
- package/src/utils/constants.ts +32 -0
- package/src/utils/credentials.ts +42 -5
- package/src/utils/deferral-time.ts +61 -0
- package/src/utils/error-tracker.ts +6 -0
- package/src/utils/key-usage.ts +114 -0
- package/src/utils/request-auth-context.ts +15 -16
- package/src/utils/sandboxed-process.ts +1 -0
- package/src/utils/secret-scrubber.ts +1 -1
- package/src/workflows/engine.ts +6 -11
- package/src/workflows/executors/swarm-script.ts +0 -2
- package/src/workflows/foreach-driver.ts +6 -12
- package/src/workflows/input.ts +24 -1
- package/src/workflows/node-timeout.ts +18 -0
- package/src/workflows/resume.ts +5 -2
- package/src/workflows/retry-poller.ts +2 -1
- package/src/workflows/triggers.ts +21 -11
- package/src/x/composio.ts +10 -1
- package/templates/skills/apps/SKILL.md +6 -2
- package/templates/skills/apps/content.md +6 -2
- package/templates/skills/boards-and-sheets/content.md +4 -2
- package/templates/skills/code-quality/content.md +4 -4
- package/templates/skills/pages/content.md +7 -0
- package/templates/skills/scheduled-task-resilience/SKILL.md +2 -0
- package/templates/skills/scheduled-task-resilience/content.md +2 -0
- package/templates/skills/swarm-docs/content.md +8 -0
- package/templates/skills/swarm-scripts/SKILL.md +45 -0
- package/templates/skills/swarm-scripts/content.md +45 -0
- package/dist/acp-adapter-mr4temec.js +0 -17
- package/dist/cli-1vmhnncj.js +0 -173
- package/dist/cli-kj0hyr43.js +0 -51
- package/dist/cli-ysv0k1we.js +0 -459
- package/dist/core-gsvj5f3z.js +0 -42
- package/dist/dsh-adapter-8abzqk5c.js +0 -9
- package/dist/fx-adapter-4sjrbdne.js +0 -20
- package/dist/grok-adapter-3a0ezfee.js +0 -20
- package/dist/handlers-ef3k11hb.js +0 -41
- package/dist/index-aetfyx6p.js +0 -13
- package/dist/index-e6bq0exk.js +0 -42
- package/dist/index-hf2k1vge.js +0 -39
- package/dist/index-taxmejj3.js +0 -44
- package/dist/lead-5vt6f174.js +0 -83
- package/dist/thread-buffer-686pa1p1.js +0 -42
- package/dist/worker-4vp616ms.js +0 -83
- package/src/tests/apps-table-selection-migration.test.ts +0 -95
- package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
- package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
CredentialBindingSchema,
|
|
3
3
|
placeholderForConfigKey,
|
|
4
4
|
assertUrlSafe,
|
|
5
|
+
createSsrfGuardedFetch,
|
|
6
|
+
init_egress_guard,
|
|
5
7
|
init_credential_broker,
|
|
6
8
|
withLoopPath,
|
|
7
9
|
bindLoopPath,
|
|
@@ -73,6 +75,8 @@ import {
|
|
|
73
75
|
init_script_allowlist,
|
|
74
76
|
API_DRAIN_MAX_MS_LIMIT,
|
|
75
77
|
init_api_drain2,
|
|
78
|
+
formatDeferralDateTime,
|
|
79
|
+
init_deferral_time,
|
|
76
80
|
parseEnabledTools,
|
|
77
81
|
init_enabled_tools,
|
|
78
82
|
parseFollowUpGateScheduleIds,
|
|
@@ -121,6 +125,8 @@ import {
|
|
|
121
125
|
getRunningSubWorkflowSteps,
|
|
122
126
|
getSettledChildRunParentSteps,
|
|
123
127
|
init_workflow_runs,
|
|
128
|
+
publicEndpointSsrfOptions,
|
|
129
|
+
init_mcp_wrapper,
|
|
124
130
|
LEARNING_TTL_DAYS,
|
|
125
131
|
LEARNING_DUPLICATE_MIN_SIMILARITY,
|
|
126
132
|
CANDIDATE_SET_MULTIPLIER,
|
|
@@ -180,6 +186,7 @@ import {
|
|
|
180
186
|
init_model_catalog_store,
|
|
181
187
|
explicitModelErrorForAgent,
|
|
182
188
|
init_model_validation2,
|
|
189
|
+
vcsRepoId,
|
|
183
190
|
configPools,
|
|
184
191
|
checkProfileForAgent,
|
|
185
192
|
init_model_profile_check,
|
|
@@ -249,6 +256,7 @@ import {
|
|
|
249
256
|
recordAcceptedWorkflowOperation,
|
|
250
257
|
init_workflow_idempotency,
|
|
251
258
|
getRunWorkflow2,
|
|
259
|
+
getWorkflowsByEventName2,
|
|
252
260
|
recordSlackMessage2,
|
|
253
261
|
getSlackTreeMessageByThread2,
|
|
254
262
|
markTaskSlackReplySent2,
|
|
@@ -386,6 +394,7 @@ import {
|
|
|
386
394
|
createUser2,
|
|
387
395
|
updateUser2,
|
|
388
396
|
deleteUser2,
|
|
397
|
+
withFavoriteFlags2,
|
|
389
398
|
getRootTaskChain2,
|
|
390
399
|
getBudget2,
|
|
391
400
|
getActivePricingRow2,
|
|
@@ -407,27 +416,27 @@ import {
|
|
|
407
416
|
recordInlineScriptRun2,
|
|
408
417
|
exports_db,
|
|
409
418
|
init_db4
|
|
410
|
-
} from "./cli-
|
|
419
|
+
} from "./cli-krk8y8c7.js";
|
|
411
420
|
import {
|
|
412
421
|
assertMayActOnOperatorGrantedTarget2,
|
|
413
422
|
getUserGrant2,
|
|
414
423
|
init_rbac_roles
|
|
415
|
-
} from "./cli-
|
|
424
|
+
} from "./cli-3wsabyt0.js";
|
|
416
425
|
import {
|
|
417
426
|
ensurePricingSeeded2,
|
|
418
427
|
ensureRbacSeeded2,
|
|
419
428
|
ensureModelProfilesSeeded2,
|
|
420
429
|
init_boot_seeds
|
|
421
|
-
} from "./cli-
|
|
430
|
+
} from "./cli-qkbevqer.js";
|
|
422
431
|
import {
|
|
423
432
|
requestModelCatalogRefresh2,
|
|
424
433
|
startPricingRefreshLoop2,
|
|
425
434
|
init_pricing_refresh
|
|
426
|
-
} from "./cli-
|
|
435
|
+
} from "./cli-2ayk9gn8.js";
|
|
427
436
|
import {
|
|
428
437
|
workflowEventBus2,
|
|
429
438
|
init_event_bus
|
|
430
|
-
} from "./cli-
|
|
439
|
+
} from "./cli-rp1n2xpd.js";
|
|
431
440
|
import {
|
|
432
441
|
slackCode,
|
|
433
442
|
slackMissingScopeMessage,
|
|
@@ -436,7 +445,7 @@ import {
|
|
|
436
445
|
externalChannelToolError2,
|
|
437
446
|
getChannelBlockReason2,
|
|
438
447
|
init_external_channel
|
|
439
|
-
} from "./cli-
|
|
448
|
+
} from "./cli-z8t4485r.js";
|
|
440
449
|
import {
|
|
441
450
|
tableToAscii2,
|
|
442
451
|
init_dist8
|
|
@@ -450,11 +459,20 @@ import {
|
|
|
450
459
|
init_reaction_events,
|
|
451
460
|
withSpan2,
|
|
452
461
|
init_otel,
|
|
462
|
+
resolveRequesterTimezone,
|
|
463
|
+
init_requester_timezone,
|
|
453
464
|
finalizeTerminalSlackReactions,
|
|
454
465
|
init_ack,
|
|
466
|
+
UI_SPEC_MAX_ACTIONS,
|
|
467
|
+
TASK_UI_SPEC_UPDATED_EVENT,
|
|
468
|
+
UI_SPEC_ACTION_ID,
|
|
469
|
+
UI_SPEC_CARD_LIMITS,
|
|
470
|
+
UI_SPEC_SCRIPT_ARGS_MAX_BYTES,
|
|
471
|
+
init_task_ui_spec,
|
|
455
472
|
getTaskLink,
|
|
456
473
|
getTaskUrl,
|
|
457
474
|
markdownToSlack,
|
|
475
|
+
findReservedActionId,
|
|
458
476
|
buildMrkdwnSectionBlocks,
|
|
459
477
|
buildCaptionBlock,
|
|
460
478
|
init_blocks,
|
|
@@ -475,17 +493,11 @@ import {
|
|
|
475
493
|
acquireTaskUiScriptActionRun,
|
|
476
494
|
finishTaskUiScriptActionRun,
|
|
477
495
|
hasTaskUiSpecCheckRefusal,
|
|
478
|
-
|
|
496
|
+
init_task_ui_spec2,
|
|
479
497
|
standardComponentDefinitions,
|
|
480
498
|
CardSpecError,
|
|
481
499
|
toCard,
|
|
482
500
|
init_dist5,
|
|
483
|
-
UI_SPEC_MAX_ACTIONS,
|
|
484
|
-
TASK_UI_SPEC_UPDATED_EVENT,
|
|
485
|
-
UI_SPEC_ACTION_ID,
|
|
486
|
-
UI_SPEC_CARD_LIMITS,
|
|
487
|
-
UI_SPEC_SCRIPT_ARGS_MAX_BYTES,
|
|
488
|
-
init_task_ui_spec2,
|
|
489
501
|
validateTaskUiSpec,
|
|
490
502
|
init_validate2,
|
|
491
503
|
ensure,
|
|
@@ -499,7 +511,7 @@ import {
|
|
|
499
511
|
startSlackApp2,
|
|
500
512
|
stopSlackAppUnderLifecycleLock2,
|
|
501
513
|
init_app4
|
|
502
|
-
} from "./cli-
|
|
514
|
+
} from "./cli-fww016hh.js";
|
|
503
515
|
import {
|
|
504
516
|
AGENT_MAX_TASKS_CONFIG_KEY,
|
|
505
517
|
resetAgentMaxTasksMirror,
|
|
@@ -520,7 +532,7 @@ import {
|
|
|
520
532
|
postApprovalCancellationUpdates2,
|
|
521
533
|
createApprovalFollowUpTask2,
|
|
522
534
|
init_approval_notifications
|
|
523
|
-
} from "./cli-
|
|
535
|
+
} from "./cli-2savn6mm.js";
|
|
524
536
|
import {
|
|
525
537
|
shapeApprovalResolution,
|
|
526
538
|
init_approval_resolution,
|
|
@@ -544,7 +556,7 @@ import {
|
|
|
544
556
|
resumeFromChildRun2,
|
|
545
557
|
initWaitBusSubscriptions2,
|
|
546
558
|
init_resume
|
|
547
|
-
} from "./cli-
|
|
559
|
+
} from "./cli-phe2vcw5.js";
|
|
548
560
|
import {
|
|
549
561
|
getFileStorageProvider2,
|
|
550
562
|
init_registry2
|
|
@@ -552,7 +564,7 @@ import {
|
|
|
552
564
|
import {
|
|
553
565
|
getRuntimePool2,
|
|
554
566
|
init_db2
|
|
555
|
-
} from "./cli-
|
|
567
|
+
} from "./cli-qrwjk4xy.js";
|
|
556
568
|
import {
|
|
557
569
|
duplicateGuardedQueryKey,
|
|
558
570
|
parseQueryParams,
|
|
@@ -585,13 +597,13 @@ import {
|
|
|
585
597
|
findRoute,
|
|
586
598
|
route,
|
|
587
599
|
init_route_def
|
|
588
|
-
} from "./cli-
|
|
600
|
+
} from "./cli-w4bvtxet.js";
|
|
589
601
|
import {
|
|
590
602
|
COMPOSIO_HTTP_METHODS,
|
|
591
603
|
executeComposioRequest,
|
|
592
604
|
composioArgsFromParts,
|
|
593
605
|
init_composio
|
|
594
|
-
} from "./cli-
|
|
606
|
+
} from "./cli-bqfx72e6.js";
|
|
595
607
|
import {
|
|
596
608
|
object,
|
|
597
609
|
init_v4_mini
|
|
@@ -650,6 +662,8 @@ import {
|
|
|
650
662
|
init_run_credential,
|
|
651
663
|
seededWorkflowState,
|
|
652
664
|
init_workflows_seeder,
|
|
665
|
+
DURABLE_OBJECT_BASE_JS,
|
|
666
|
+
init_durable_object_base,
|
|
653
667
|
extractScriptSignature,
|
|
654
668
|
init_extract_signature,
|
|
655
669
|
extractArgsJsonSchema,
|
|
@@ -683,11 +697,13 @@ import {
|
|
|
683
697
|
updateApp,
|
|
684
698
|
deleteApp,
|
|
685
699
|
init_store2,
|
|
700
|
+
appWriteTypesWarnings,
|
|
701
|
+
init_script_types,
|
|
686
702
|
typecheckScript,
|
|
687
703
|
init_typecheck,
|
|
688
704
|
parseSkillContent,
|
|
689
705
|
init_skill_parser
|
|
690
|
-
} from "./cli-
|
|
706
|
+
} from "./cli-v4z5v3jd.js";
|
|
691
707
|
import {
|
|
692
708
|
detachedProcessGroup,
|
|
693
709
|
registerProcessGroup,
|
|
@@ -702,7 +718,7 @@ import {
|
|
|
702
718
|
ensureToken,
|
|
703
719
|
ensureTokenOrThrow,
|
|
704
720
|
init_ensure_token
|
|
705
|
-
} from "./cli-
|
|
721
|
+
} from "./cli-m0ea8ggd.js";
|
|
706
722
|
import {
|
|
707
723
|
A1Error,
|
|
708
724
|
colName,
|
|
@@ -737,11 +753,11 @@ import {
|
|
|
737
753
|
listObjects,
|
|
738
754
|
reindexObjects,
|
|
739
755
|
init_objects
|
|
740
|
-
} from "./cli-
|
|
756
|
+
} from "./cli-jgq9xptq.js";
|
|
741
757
|
import {
|
|
742
758
|
agentFsClientFor,
|
|
743
759
|
init_agent_fs_identity
|
|
744
|
-
} from "./cli-
|
|
760
|
+
} from "./cli-6ajyhxh7.js";
|
|
745
761
|
import {
|
|
746
762
|
FilesError,
|
|
747
763
|
providerPath,
|
|
@@ -755,7 +771,7 @@ import {
|
|
|
755
771
|
isSlackLeaveThreadDisabled,
|
|
756
772
|
leaveSlackThread,
|
|
757
773
|
init_left_threads
|
|
758
|
-
} from "./cli-
|
|
774
|
+
} from "./cli-srq69pn1.js";
|
|
759
775
|
import {
|
|
760
776
|
require_fast_deep_equal
|
|
761
777
|
} from "./cli-bhp11egn.js";
|
|
@@ -802,6 +818,8 @@ import {
|
|
|
802
818
|
validateJsonSchema,
|
|
803
819
|
findJsonSchemaShapeErrors,
|
|
804
820
|
init_json_schema_validator,
|
|
821
|
+
runWithNodeDeadline,
|
|
822
|
+
init_node_timeout,
|
|
805
823
|
workflowSaveWarnings,
|
|
806
824
|
withSaveWarnings,
|
|
807
825
|
init_readiness,
|
|
@@ -840,7 +858,7 @@ import {
|
|
|
840
858
|
validateDefinition,
|
|
841
859
|
applyDefinitionPatch,
|
|
842
860
|
init_definition2
|
|
843
|
-
} from "./cli-
|
|
861
|
+
} from "./cli-jcnc5ret.js";
|
|
844
862
|
import {
|
|
845
863
|
isMultiRuntimeEnabled,
|
|
846
864
|
init_multi_runtime2
|
|
@@ -863,16 +881,12 @@ import {
|
|
|
863
881
|
import {
|
|
864
882
|
canProvisionKind,
|
|
865
883
|
init_runtime_providers
|
|
866
|
-
} from "./cli-
|
|
884
|
+
} from "./cli-2zjxake1.js";
|
|
867
885
|
import {
|
|
868
886
|
getSessionRoot,
|
|
869
887
|
sessionAccessForRoot,
|
|
870
888
|
init_session_shares
|
|
871
|
-
} from "./cli-
|
|
872
|
-
import {
|
|
873
|
-
publicEndpointSsrfOptions,
|
|
874
|
-
init_mcp_wrapper
|
|
875
|
-
} from "./cli-ysv0k1we.js";
|
|
889
|
+
} from "./cli-jwnac23b.js";
|
|
876
890
|
import {
|
|
877
891
|
findUserById,
|
|
878
892
|
findUserByExternalId,
|
|
@@ -887,13 +901,13 @@ import {
|
|
|
887
901
|
resolveSessionToken,
|
|
888
902
|
fingerprintApiKey,
|
|
889
903
|
init_users
|
|
890
|
-
} from "./cli-
|
|
904
|
+
} from "./cli-adzmmcvf.js";
|
|
891
905
|
import {
|
|
892
906
|
AMP_ESTIMATE_MODELS,
|
|
893
907
|
ampBillsCacheWrites,
|
|
894
908
|
resolveAmpModel,
|
|
895
909
|
init_amp_models
|
|
896
|
-
} from "./cli-
|
|
910
|
+
} from "./cli-wvbaq052.js";
|
|
897
911
|
import {
|
|
898
912
|
resolveGitHubHost,
|
|
899
913
|
getGitHubLinkConfig,
|
|
@@ -911,7 +925,7 @@ import {
|
|
|
911
925
|
init_task_attachment_links,
|
|
912
926
|
contentSha256,
|
|
913
927
|
init_profile_sync
|
|
914
|
-
} from "./cli-
|
|
928
|
+
} from "./cli-wym6rxgt.js";
|
|
915
929
|
import {
|
|
916
930
|
getSlackConfiguration,
|
|
917
931
|
isSlackConfigured,
|
|
@@ -929,7 +943,7 @@ import {
|
|
|
929
943
|
splitCredentialPool,
|
|
930
944
|
selectCredential,
|
|
931
945
|
init_credentials2
|
|
932
|
-
} from "./cli-
|
|
946
|
+
} from "./cli-wd7b5hgc.js";
|
|
933
947
|
import {
|
|
934
948
|
findInterpolationTokens,
|
|
935
949
|
interpolate,
|
|
@@ -939,7 +953,7 @@ import {
|
|
|
939
953
|
init_registry3,
|
|
940
954
|
resolveTemplate,
|
|
941
955
|
init_resolver
|
|
942
|
-
} from "./cli-
|
|
956
|
+
} from "./cli-24wervhz.js";
|
|
943
957
|
import {
|
|
944
958
|
normalizeAssetKey,
|
|
945
959
|
defaultAssetKey,
|
|
@@ -968,6 +982,7 @@ import {
|
|
|
968
982
|
splitLegacyModelAlias,
|
|
969
983
|
AgentTaskStatusSchema,
|
|
970
984
|
isTerminalTaskStatus,
|
|
985
|
+
TaskStatusKindSchema,
|
|
971
986
|
RoutingReasonSchema,
|
|
972
987
|
ProviderNameSchema,
|
|
973
988
|
SteerModeSchema,
|
|
@@ -978,6 +993,7 @@ import {
|
|
|
978
993
|
AttachmentInputSchema,
|
|
979
994
|
AgentStatusSchema,
|
|
980
995
|
AgentAvatarSchema,
|
|
996
|
+
UserAvatarSchema,
|
|
981
997
|
AppIconSchema,
|
|
982
998
|
AgentSlackIconSchema,
|
|
983
999
|
ChannelTypeSchema,
|
|
@@ -1016,7 +1032,7 @@ import {
|
|
|
1016
1032
|
KvNamespaceSchema,
|
|
1017
1033
|
KvKeySchema,
|
|
1018
1034
|
init_types5
|
|
1019
|
-
} from "./cli-
|
|
1035
|
+
} from "./cli-tc165vrb.js";
|
|
1020
1036
|
import {
|
|
1021
1037
|
init_zod
|
|
1022
1038
|
} from "./cli-96234j5w.js";
|
|
@@ -1053,6 +1069,7 @@ import {
|
|
|
1053
1069
|
getConfiguredAppUrls,
|
|
1054
1070
|
getAppUrl,
|
|
1055
1071
|
getMcpBaseUrl,
|
|
1072
|
+
getScriptApiBaseUrl,
|
|
1056
1073
|
getPublicMcpBaseUrl,
|
|
1057
1074
|
getAgentFsLiveUrl,
|
|
1058
1075
|
getAgentFsDefaultOrgId,
|
|
@@ -1061,7 +1078,7 @@ import {
|
|
|
1061
1078
|
getCombState,
|
|
1062
1079
|
isAgentFsProxyEnabled,
|
|
1063
1080
|
init_constants3
|
|
1064
|
-
} from "./cli-
|
|
1081
|
+
} from "./cli-466jjrwe.js";
|
|
1065
1082
|
import {
|
|
1066
1083
|
parseEnvFlag,
|
|
1067
1084
|
isEnvFlagEnabled,
|
|
@@ -1070,7 +1087,7 @@ import {
|
|
|
1070
1087
|
import {
|
|
1071
1088
|
init_package,
|
|
1072
1089
|
package_default
|
|
1073
|
-
} from "./cli-
|
|
1090
|
+
} from "./cli-shyhb4t5.js";
|
|
1074
1091
|
import {
|
|
1075
1092
|
getNodeEnv,
|
|
1076
1093
|
isDevOrTestNodeEnv,
|
|
@@ -1090,7 +1107,7 @@ import {
|
|
|
1090
1107
|
registerVolatileSecret,
|
|
1091
1108
|
registerSensitiveKeyName,
|
|
1092
1109
|
init_secret_scrubber
|
|
1093
|
-
} from "./cli-
|
|
1110
|
+
} from "./cli-r9d2tya0.js";
|
|
1094
1111
|
import {
|
|
1095
1112
|
__toESM,
|
|
1096
1113
|
__commonJS,
|
|
@@ -12260,6 +12277,7 @@ function resetGitHub() {
|
|
|
12260
12277
|
appId = null;
|
|
12261
12278
|
privateKey = null;
|
|
12262
12279
|
tokenCache.clear();
|
|
12280
|
+
installationCache.clear();
|
|
12263
12281
|
}
|
|
12264
12282
|
function initGitHub() {
|
|
12265
12283
|
if (initialized) {
|
|
@@ -12396,27 +12414,130 @@ async function mintInstallationToken(installationId, creds, minValidityMs) {
|
|
|
12396
12414
|
return null;
|
|
12397
12415
|
}
|
|
12398
12416
|
}
|
|
12399
|
-
|
|
12417
|
+
function normalizeRepo(repo) {
|
|
12418
|
+
const trimmed = repo.trim().replace(/\/+$/, "");
|
|
12419
|
+
const lastTwo = trimmed.replace(/\.git$/i, "").match(/([^/:]+\/[^/:]+)$/);
|
|
12420
|
+
if (!lastTwo)
|
|
12421
|
+
return trimmed.toLowerCase();
|
|
12422
|
+
const [owner, name] = lastTwo[1].split("/");
|
|
12423
|
+
if (owner === "." || owner === ".." || name === "." || name === "..")
|
|
12424
|
+
return "";
|
|
12425
|
+
return lastTwo[1].toLowerCase();
|
|
12426
|
+
}
|
|
12427
|
+
function allowedRepoOwners() {
|
|
12428
|
+
return new Set((process.env.GITHUB_APP_REPO_OWNERS ?? "").split(",").map((owner) => owner.trim().toLowerCase()).filter(Boolean));
|
|
12429
|
+
}
|
|
12430
|
+
function registeredSlugOnHost(url, host) {
|
|
12431
|
+
const trimmed = url.trim().replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
12432
|
+
let urlHost = null;
|
|
12433
|
+
let path;
|
|
12434
|
+
const scp = trimmed.match(/^[^@/:]+@([^:/]+):(.+)$/);
|
|
12435
|
+
if (scp) {
|
|
12436
|
+
urlHost = scp[1].toLowerCase();
|
|
12437
|
+
path = scp[2];
|
|
12438
|
+
} else if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) {
|
|
12439
|
+
try {
|
|
12440
|
+
const parsed = new URL(trimmed);
|
|
12441
|
+
urlHost = parsed.host.toLowerCase();
|
|
12442
|
+
path = parsed.pathname;
|
|
12443
|
+
} catch {
|
|
12444
|
+
return null;
|
|
12445
|
+
}
|
|
12446
|
+
} else {
|
|
12447
|
+
path = trimmed;
|
|
12448
|
+
}
|
|
12449
|
+
if (urlHost !== null && urlHost !== host && !(host === "github.com" && urlHost === "www.github.com")) {
|
|
12450
|
+
return null;
|
|
12451
|
+
}
|
|
12452
|
+
const segments = path.replace(/^\/+/, "").split("/");
|
|
12453
|
+
if (segments.length !== 2)
|
|
12454
|
+
return null;
|
|
12455
|
+
const slug = normalizeRepo(segments.join("/"));
|
|
12456
|
+
return slug || null;
|
|
12457
|
+
}
|
|
12458
|
+
async function resolveInstallationId(repo, creds, owners) {
|
|
12459
|
+
const cached = installationCache.get(repo);
|
|
12460
|
+
if (cached && cached.expiresAt > Date.now())
|
|
12461
|
+
return cached.id;
|
|
12462
|
+
const jwt = await generateAppJWT(creds);
|
|
12463
|
+
if (!jwt)
|
|
12464
|
+
return null;
|
|
12465
|
+
const refuse = () => {
|
|
12466
|
+
installationCache.set(repo, { id: null, expiresAt: Date.now() + NO_INSTALLATION_CACHE_TTL_MS });
|
|
12467
|
+
return null;
|
|
12468
|
+
};
|
|
12469
|
+
try {
|
|
12470
|
+
const response = await fetch(githubApiUrl(`/repos/${repo}/installation`), {
|
|
12471
|
+
headers: {
|
|
12472
|
+
Accept: "application/vnd.github+json",
|
|
12473
|
+
Authorization: `Bearer ${jwt}`,
|
|
12474
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
12475
|
+
}
|
|
12476
|
+
});
|
|
12477
|
+
if (response.status !== 200) {
|
|
12478
|
+
console.log(`[GitHub] No installation for ${repo}: ${response.status}`);
|
|
12479
|
+
return refuse();
|
|
12480
|
+
}
|
|
12481
|
+
const data = await response.json();
|
|
12482
|
+
if (typeof data.id !== "number")
|
|
12483
|
+
return refuse();
|
|
12484
|
+
const account = typeof data.account?.login === "string" ? data.account.login.toLowerCase() : "";
|
|
12485
|
+
if (!owners.has(account)) {
|
|
12486
|
+
console.log(`[GitHub] Installation for ${repo} belongs to an owner that is not allowed`);
|
|
12487
|
+
return refuse();
|
|
12488
|
+
}
|
|
12489
|
+
installationCache.set(repo, {
|
|
12490
|
+
id: data.id,
|
|
12491
|
+
expiresAt: Date.now() + INSTALLATION_CACHE_TTL_MS
|
|
12492
|
+
});
|
|
12493
|
+
return data.id;
|
|
12494
|
+
} catch (error) {
|
|
12495
|
+
console.error("[GitHub] Error resolving the repo installation:", error);
|
|
12496
|
+
return null;
|
|
12497
|
+
}
|
|
12498
|
+
}
|
|
12499
|
+
async function getWorkerInstallationToken(repo) {
|
|
12400
12500
|
if (isEnvFlagEnabled("GITHUB_DISABLE", false))
|
|
12401
12501
|
return { status: "unconfigured" };
|
|
12402
12502
|
const workerAppId = process.env.GITHUB_APP_ID?.trim();
|
|
12403
12503
|
const rawKey = process.env.GITHUB_APP_PRIVATE_KEY?.trim();
|
|
12404
|
-
|
|
12405
|
-
if (!workerAppId || !rawKey || !/^[1-9][0-9]{0,15}$/.test(rawInstallation)) {
|
|
12504
|
+
if (!workerAppId || !rawKey)
|
|
12406
12505
|
return { status: "unconfigured" };
|
|
12407
|
-
|
|
12408
|
-
if (!
|
|
12506
|
+
const host = resolveGitHubHost();
|
|
12507
|
+
if (!host.ok)
|
|
12409
12508
|
return { status: "error" };
|
|
12410
|
-
const
|
|
12509
|
+
const creds = { appId: workerAppId, privateKey: decodePrivateKey(rawKey) };
|
|
12510
|
+
const owners = allowedRepoOwners();
|
|
12511
|
+
const target = repo ? normalizeRepo(repo) : "";
|
|
12512
|
+
const owner = target.split("/")[0] ?? "";
|
|
12513
|
+
let installationId;
|
|
12514
|
+
if (target && owners.has(owner)) {
|
|
12515
|
+
const registered = (await getSwarmRepos2()).some((r) => registeredSlugOnHost(r.url, host.config.host) === target);
|
|
12516
|
+
if (!registered)
|
|
12517
|
+
return { status: "forbidden" };
|
|
12518
|
+
const resolved = await resolveInstallationId(target, creds, owners);
|
|
12519
|
+
if (resolved === null)
|
|
12520
|
+
return { status: "error" };
|
|
12521
|
+
installationId = resolved;
|
|
12522
|
+
} else {
|
|
12523
|
+
const rawInstallation = process.env.GITHUB_APP_INSTALLATION_ID?.trim() ?? "";
|
|
12524
|
+
if (!/^[1-9][0-9]{0,15}$/.test(rawInstallation))
|
|
12525
|
+
return { status: "unconfigured" };
|
|
12526
|
+
installationId = Number(rawInstallation);
|
|
12527
|
+
}
|
|
12528
|
+
const minted = await mintInstallationToken(installationId, creds, 600000);
|
|
12411
12529
|
if (!minted)
|
|
12412
12530
|
return { status: "error" };
|
|
12413
12531
|
return { status: "ok", token: minted.token, expiresAt: new Date(minted.expiresAt).toISOString() };
|
|
12414
12532
|
}
|
|
12415
|
-
var initialized = false, webhookSecret = null, appId = null, privateKey = null, tokenCache;
|
|
12533
|
+
var initialized = false, webhookSecret = null, appId = null, privateKey = null, tokenCache, INSTALLATION_CACHE_TTL_MS, NO_INSTALLATION_CACHE_TTL_MS = 60000, installationCache;
|
|
12416
12534
|
var init_app = __esm(() => {
|
|
12535
|
+
init_db4();
|
|
12417
12536
|
init_env_flag();
|
|
12418
12537
|
init_github_host();
|
|
12419
12538
|
tokenCache = new Map;
|
|
12539
|
+
INSTALLATION_CACHE_TTL_MS = 10 * 60000;
|
|
12540
|
+
installationCache = new Map;
|
|
12420
12541
|
});
|
|
12421
12542
|
|
|
12422
12543
|
// src/github/reactions.ts
|
|
@@ -20444,7 +20565,7 @@ function startRetryPoller(registry, intervalMs = 5000) {
|
|
|
20444
20565
|
inputCtx
|
|
20445
20566
|
};
|
|
20446
20567
|
try {
|
|
20447
|
-
const result = await executor
|
|
20568
|
+
const result = await runWithNodeDeadline(node, executor, {
|
|
20448
20569
|
config: interpolatedConfig,
|
|
20449
20570
|
context: ctx,
|
|
20450
20571
|
meta
|
|
@@ -20472,7 +20593,7 @@ function startRetryPoller(registry, intervalMs = 5000) {
|
|
|
20472
20593
|
if (!waiting)
|
|
20473
20594
|
continue;
|
|
20474
20595
|
if (result.waitFor === "workflow.child.finished") {
|
|
20475
|
-
const { resumeFromChildRun } = await import("./resume-
|
|
20596
|
+
const { resumeFromChildRun } = await import("./resume-jdhnt4jk.js");
|
|
20476
20597
|
await resumeFromChildRun(step.id, registry);
|
|
20477
20598
|
}
|
|
20478
20599
|
} else {
|
|
@@ -20592,6 +20713,7 @@ var init_retry_poller = __esm(() => {
|
|
|
20592
20713
|
init_engine();
|
|
20593
20714
|
init_foreach_driver();
|
|
20594
20715
|
init_foreach_join();
|
|
20716
|
+
init_node_timeout();
|
|
20595
20717
|
init_step_input();
|
|
20596
20718
|
init_successor_routing();
|
|
20597
20719
|
init_validation();
|
|
@@ -20867,13 +20989,17 @@ async function logOpenWebhookTriggers() {
|
|
|
20867
20989
|
}
|
|
20868
20990
|
}
|
|
20869
20991
|
async function handleEventTrigger(eventName, payload, registry) {
|
|
20870
|
-
const workflows =
|
|
20992
|
+
const workflows = await getWorkflowsByEventName2(eventName);
|
|
20871
20993
|
const runIds = [];
|
|
20872
20994
|
for (const workflow of workflows) {
|
|
20873
|
-
|
|
20874
|
-
|
|
20875
|
-
|
|
20876
|
-
|
|
20995
|
+
try {
|
|
20996
|
+
const runId = await startWorkflowExecution2(workflow, payload, registry, {
|
|
20997
|
+
triggerType: "event"
|
|
20998
|
+
});
|
|
20999
|
+
runIds.push(runId);
|
|
21000
|
+
} catch (err) {
|
|
21001
|
+
console.error(`[workflows] Failed to start workflow ${workflow.id} for ${eventName} event trigger:`, scrubSecrets(err instanceof Error ? err.message : String(err)));
|
|
21002
|
+
}
|
|
20877
21003
|
}
|
|
20878
21004
|
return runIds;
|
|
20879
21005
|
}
|
|
@@ -20993,6 +21119,7 @@ function timingSafeEqualHex(providedHex, expected) {
|
|
|
20993
21119
|
var DEFAULT_HMAC_HEADER = "X-Hub-Signature-256", FALLBACK_HMAC_HEADERS, STANDARD_WEBHOOK_SECRET_PREFIX = "whsec_", WebhookError;
|
|
20994
21120
|
var init_triggers = __esm(() => {
|
|
20995
21121
|
init_db4();
|
|
21122
|
+
init_secret_scrubber();
|
|
20996
21123
|
init_engine();
|
|
20997
21124
|
init_input();
|
|
20998
21125
|
init_webhook_filter();
|
|
@@ -21360,7 +21487,7 @@ var init_notify = __esm(() => {
|
|
|
21360
21487
|
}
|
|
21361
21488
|
}
|
|
21362
21489
|
case "slack": {
|
|
21363
|
-
const { getSlackApp } = await import("./app-
|
|
21490
|
+
const { getSlackApp } = await import("./app-5d3sz1hy.js");
|
|
21364
21491
|
let app = getSlackApp();
|
|
21365
21492
|
if (!app) {
|
|
21366
21493
|
if (!isSlackConfigured()) {
|
|
@@ -21846,7 +21973,6 @@ var init_swarm_script = __esm(() => {
|
|
|
21846
21973
|
init_db3();
|
|
21847
21974
|
init_run_credential();
|
|
21848
21975
|
init_types3();
|
|
21849
|
-
init_constants3();
|
|
21850
21976
|
init_template2();
|
|
21851
21977
|
init_base();
|
|
21852
21978
|
SWARM_SCRIPT_DEFAULT_TIMEOUT_MS = DEFAULT_SCRIPT_RESOURCES.wallClockMs;
|
|
@@ -21911,7 +22037,6 @@ var init_swarm_script = __esm(() => {
|
|
|
21911
22037
|
fsMode: "none",
|
|
21912
22038
|
executor: resolved.script.executor,
|
|
21913
22039
|
agentId: agentId ?? "workflow",
|
|
21914
|
-
mcpBaseUrl: getMcpBaseUrl(),
|
|
21915
22040
|
egressSecrets: credentials.egressSecrets,
|
|
21916
22041
|
failedBindings: credentials.failedBindings,
|
|
21917
22042
|
userConfig: credentials.userConfig,
|
|
@@ -22309,9 +22434,9 @@ var init_workflows = __esm(() => {
|
|
|
22309
22434
|
});
|
|
22310
22435
|
|
|
22311
22436
|
// src/github/pull-request-state.ts
|
|
22312
|
-
async function
|
|
22437
|
+
async function githubGet(path, what) {
|
|
22313
22438
|
const auth = await getWorkerInstallationToken();
|
|
22314
|
-
const response = await fetch(githubApiUrl(
|
|
22439
|
+
const response = await fetch(githubApiUrl(path), {
|
|
22315
22440
|
headers: {
|
|
22316
22441
|
Accept: "application/vnd.github+json",
|
|
22317
22442
|
"X-GitHub-Api-Version": "2022-11-28",
|
|
@@ -22320,13 +22445,55 @@ async function fetchPullRequestState(repo, number) {
|
|
|
22320
22445
|
signal: AbortSignal.timeout(1e4)
|
|
22321
22446
|
});
|
|
22322
22447
|
if (!response.ok)
|
|
22323
|
-
throw new Error(`GitHub returned ${response.status} for ${
|
|
22324
|
-
|
|
22448
|
+
throw new Error(`GitHub returned ${response.status} for ${what}`);
|
|
22449
|
+
return await response.json();
|
|
22450
|
+
}
|
|
22451
|
+
async function fetchPullRequestState(repo, number) {
|
|
22452
|
+
const pr = await githubGet(`/repos/${repo}/pulls/${number}`, `${repo}#${number}`);
|
|
22325
22453
|
return {
|
|
22326
22454
|
merged: pr.merged === true,
|
|
22327
|
-
state: pr.state === "open" ? "open" : "closed"
|
|
22455
|
+
state: pr.state === "open" ? "open" : "closed",
|
|
22456
|
+
headSha: pr.head?.sha ?? "",
|
|
22457
|
+
baseRef: pr.base?.ref ?? ""
|
|
22328
22458
|
};
|
|
22329
22459
|
}
|
|
22460
|
+
async function fetchRequiredCheckStates(repo, baseRef, sha) {
|
|
22461
|
+
const rules = await githubGet(`/repos/${repo}/rules/branches/${encodeURIComponent(baseRef)}`, `${repo} rules on ${baseRef}`);
|
|
22462
|
+
const required = new Map;
|
|
22463
|
+
for (const rule of rules) {
|
|
22464
|
+
if (rule.type !== "required_status_checks")
|
|
22465
|
+
continue;
|
|
22466
|
+
for (const check of rule.parameters?.required_status_checks ?? [])
|
|
22467
|
+
required.set(check.context, check.integration_id);
|
|
22468
|
+
}
|
|
22469
|
+
if (!required.size)
|
|
22470
|
+
throw new Error(`${repo} has no required status checks on ${baseRef}`);
|
|
22471
|
+
let statuses;
|
|
22472
|
+
const states = [];
|
|
22473
|
+
for (const [name, appId] of required) {
|
|
22474
|
+
const runs = await githubGet(`/repos/${repo}/commits/${sha}/check-runs?check_name=${encodeURIComponent(name)}&filter=latest&per_page=100`, `${repo} check runs on ${sha}`);
|
|
22475
|
+
const run = (runs.check_runs ?? []).find((r) => appId === undefined || r.app?.id === appId);
|
|
22476
|
+
if (run) {
|
|
22477
|
+
states.push({
|
|
22478
|
+
name,
|
|
22479
|
+
complete: run.status === "completed",
|
|
22480
|
+
conclusion: run.conclusion ?? null,
|
|
22481
|
+
completedAt: run.completed_at ?? null
|
|
22482
|
+
});
|
|
22483
|
+
continue;
|
|
22484
|
+
}
|
|
22485
|
+
statuses ??= (await githubGet(`/repos/${repo}/commits/${sha}/status?per_page=100`, `${repo} statuses on ${sha}`)).statuses ?? [];
|
|
22486
|
+
const status = statuses.find((s) => s.context === name);
|
|
22487
|
+
const complete = status !== undefined && status.state !== "pending";
|
|
22488
|
+
states.push({
|
|
22489
|
+
name,
|
|
22490
|
+
complete,
|
|
22491
|
+
conclusion: complete ? status.state : null,
|
|
22492
|
+
completedAt: complete ? status.updated_at : null
|
|
22493
|
+
});
|
|
22494
|
+
}
|
|
22495
|
+
return states;
|
|
22496
|
+
}
|
|
22330
22497
|
var init_pull_request_state = __esm(() => {
|
|
22331
22498
|
init_github_host();
|
|
22332
22499
|
init_app();
|
|
@@ -22336,6 +22503,17 @@ var init_pull_request_state = __esm(() => {
|
|
|
22336
22503
|
function prMatch(repo, number) {
|
|
22337
22504
|
return { repo: repo.toLowerCase(), number };
|
|
22338
22505
|
}
|
|
22506
|
+
async function confirmChecksDone(repo, number) {
|
|
22507
|
+
const pr = await fetchPullRequestState(repo, number);
|
|
22508
|
+
if (!pr.headSha || !pr.baseRef)
|
|
22509
|
+
throw new Error(`GitHub returned no head or base for ${repo}#${number}`);
|
|
22510
|
+
const checks = await fetchRequiredCheckStates(repo, pr.baseRef, pr.headSha);
|
|
22511
|
+
const done = checks.every((check) => check.complete);
|
|
22512
|
+
return {
|
|
22513
|
+
happened: done,
|
|
22514
|
+
detail: done ? `head ${pr.headSha.slice(0, 12)}, ${checks.map((check) => `${check.name}=${check.conclusion} (completed ${check.completedAt})`).join(", ")}` : undefined
|
|
22515
|
+
};
|
|
22516
|
+
}
|
|
22339
22517
|
var PrMatch, githubAdapter;
|
|
22340
22518
|
var init_github2 = __esm(() => {
|
|
22341
22519
|
init_zod();
|
|
@@ -22344,9 +22522,9 @@ var init_github2 = __esm(() => {
|
|
|
22344
22522
|
PrMatch = object2({ repo: string2().regex(/^[\w.-]+\/[\w.-]+$/), number: number2().int().positive() }).strict();
|
|
22345
22523
|
githubAdapter = {
|
|
22346
22524
|
source: "github",
|
|
22347
|
-
events: ["vcs.pr.merged"],
|
|
22525
|
+
events: ["vcs.pr.merged", "vcs.pr.checks_done"],
|
|
22348
22526
|
matchHint: "repo (owner/name), number",
|
|
22349
|
-
|
|
22527
|
+
busPrefixes: ["github.pull_request.", "github.check_run."],
|
|
22350
22528
|
readsWithServerCredentials: true,
|
|
22351
22529
|
isEnabled: isGitHubEnabled,
|
|
22352
22530
|
parseMatch(_event, match) {
|
|
@@ -22357,13 +22535,24 @@ var init_github2 = __esm(() => {
|
|
|
22357
22535
|
return prMatch(parsed.data.repo, parsed.data.number);
|
|
22358
22536
|
},
|
|
22359
22537
|
fromBusEvent(busEvent, payload) {
|
|
22538
|
+
if (busEvent === "github.check_run.completed") {
|
|
22539
|
+
const run = payload;
|
|
22540
|
+
if (typeof run?.repo !== "string" || !Array.isArray(run.pullRequests))
|
|
22541
|
+
return [];
|
|
22542
|
+
const repo = run.repo;
|
|
22543
|
+
return run.pullRequests.filter((n) => typeof n === "number").map((n) => ({ event: "vcs.pr.checks_done", match: prMatch(repo, n) }));
|
|
22544
|
+
}
|
|
22360
22545
|
const pr = payload;
|
|
22361
22546
|
if (busEvent !== "github.pull_request.closed" || pr?.merged !== true || typeof pr.repo !== "string" || typeof pr.number !== "number")
|
|
22362
22547
|
return [];
|
|
22363
22548
|
return [{ event: "vcs.pr.merged", match: prMatch(pr.repo, pr.number) }];
|
|
22364
22549
|
},
|
|
22365
|
-
async confirm(
|
|
22366
|
-
|
|
22550
|
+
async confirm(event, match) {
|
|
22551
|
+
const repo = String(match.repo);
|
|
22552
|
+
const number = Number(match.number);
|
|
22553
|
+
if (event === "vcs.pr.checks_done")
|
|
22554
|
+
return await confirmChecksDone(repo, number);
|
|
22555
|
+
return (await fetchPullRequestState(repo, number)).merged;
|
|
22367
22556
|
}
|
|
22368
22557
|
};
|
|
22369
22558
|
});
|
|
@@ -22376,6 +22565,9 @@ function describeEventWait(source, event, match) {
|
|
|
22376
22565
|
const target = Object.entries(match).map(([key, value]) => `${key}=${value}`).join(", ");
|
|
22377
22566
|
return `${event} on ${source} (${target})`;
|
|
22378
22567
|
}
|
|
22568
|
+
function toConfirmResult(result) {
|
|
22569
|
+
return typeof result === "boolean" ? { happened: result } : result;
|
|
22570
|
+
}
|
|
22379
22571
|
var init_types4 = () => {};
|
|
22380
22572
|
|
|
22381
22573
|
// src/event-waits/index.ts
|
|
@@ -22383,9 +22575,9 @@ function getExternalEventAdapter(source) {
|
|
|
22383
22575
|
return EXTERNAL_EVENT_ADAPTERS.find((adapter) => adapter.source === source);
|
|
22384
22576
|
}
|
|
22385
22577
|
function isReservedProviderEvent(name) {
|
|
22386
|
-
return EXTERNAL_EVENT_ADAPTERS.some((adapter) => name.startsWith(
|
|
22578
|
+
return EXTERNAL_EVENT_ADAPTERS.some((adapter) => adapter.busPrefixes.some((prefix) => name.startsWith(prefix)));
|
|
22387
22579
|
}
|
|
22388
|
-
var EXTERNAL_EVENT_ADAPTERS, EXTERNAL_EVENT_NAMES, EXTERNAL_EVENTS_DOC = 'vcs.pr.merged with source "github" and match {repo (owner/name), number}';
|
|
22580
|
+
var EXTERNAL_EVENT_ADAPTERS, EXTERNAL_EVENT_NAMES, EXTERNAL_EVENTS_DOC = 'vcs.pr.merged or vcs.pr.checks_done (every required check of the base branch ruleset finished on the PR head, any conclusion) with source "github" and match {repo (owner/name), number}';
|
|
22389
22581
|
var init_event_waits = __esm(() => {
|
|
22390
22582
|
init_github2();
|
|
22391
22583
|
init_types4();
|
|
@@ -22464,7 +22656,7 @@ var init_schedule_task = __esm(() => {
|
|
|
22464
22656
|
function externalWakeReason(source, event) {
|
|
22465
22657
|
return `external:${source}:${event}`;
|
|
22466
22658
|
}
|
|
22467
|
-
async function resolveWaitCause(scheduleId, reason) {
|
|
22659
|
+
async function resolveWaitCause(scheduleId, reason, causeDetail) {
|
|
22468
22660
|
const client = getDbClient2();
|
|
22469
22661
|
const wait = await client.get("SELECT * FROM deferred_task_waits WHERE scheduleId = ?", [scheduleId]);
|
|
22470
22662
|
if (!wait) {
|
|
@@ -22477,7 +22669,7 @@ async function resolveWaitCause(scheduleId, reason) {
|
|
|
22477
22669
|
return;
|
|
22478
22670
|
return {
|
|
22479
22671
|
table: "deferred_event_waits",
|
|
22480
|
-
cause: describeEventWait(eventWait.source, eventWait.event, JSON.parse(eventWait.matchJson))
|
|
22672
|
+
cause: `${describeEventWait(eventWait.source, eventWait.event, JSON.parse(eventWait.matchJson))}${causeDetail ? `: ${causeDetail}` : ""}`,
|
|
22481
22673
|
matchedTaskIds: []
|
|
22482
22674
|
};
|
|
22483
22675
|
}
|
|
@@ -22514,8 +22706,8 @@ function wakeSchedule(schedule, cause) {
|
|
|
22514
22706
|
|
|
22515
22707
|
Wake-up cause: ${cause}.` };
|
|
22516
22708
|
}
|
|
22517
|
-
async function prepareDeferredWakeTask(scheduleId, reason, extraTags) {
|
|
22518
|
-
const resolved = await resolveWaitCause(scheduleId, reason);
|
|
22709
|
+
async function prepareDeferredWakeTask(scheduleId, reason, extraTags, causeDetail) {
|
|
22710
|
+
const resolved = await resolveWaitCause(scheduleId, reason, causeDetail);
|
|
22519
22711
|
if (!resolved)
|
|
22520
22712
|
return;
|
|
22521
22713
|
let schedule = await getScheduledTaskById2(scheduleId);
|
|
@@ -22528,15 +22720,15 @@ async function prepareDeferredWakeTask(scheduleId, reason, extraTags) {
|
|
|
22528
22720
|
throw new Error(`Schedule "${schedule.name}" has no taskTemplate`);
|
|
22529
22721
|
return await prepareStandaloneScheduleTask(wakeSchedule(schedule, resolved.cause), extraTags);
|
|
22530
22722
|
}
|
|
22531
|
-
async function prepareDeferredTaskWait(scheduleId, reason, extraTags = []) {
|
|
22723
|
+
async function prepareDeferredTaskWait(scheduleId, reason, extraTags = [], causeDetail) {
|
|
22532
22724
|
const client = getDbClient2();
|
|
22533
22725
|
if (!await client.get(`SELECT 1 AS found FROM deferred_task_waits WHERE scheduleId = ?
|
|
22534
22726
|
UNION ALL SELECT 1 FROM deferred_event_waits WHERE scheduleId = ?`, [scheduleId, scheduleId]))
|
|
22535
22727
|
return;
|
|
22536
|
-
return { task: await prepareDeferredWakeTask(scheduleId, reason, extraTags) };
|
|
22728
|
+
return { task: await prepareDeferredWakeTask(scheduleId, reason, extraTags, causeDetail) };
|
|
22537
22729
|
}
|
|
22538
|
-
async function dispatchDeferredTaskWait(scheduleId, reason, extraTags = [], triggerTaskId, prepared) {
|
|
22539
|
-
const preparation = prepared ?? await prepareDeferredTaskWait(scheduleId, reason, extraTags);
|
|
22730
|
+
async function dispatchDeferredTaskWait(scheduleId, reason, extraTags = [], triggerTaskId, prepared, causeDetail) {
|
|
22731
|
+
const preparation = prepared ?? await prepareDeferredTaskWait(scheduleId, reason, extraTags, causeDetail);
|
|
22540
22732
|
if (!preparation)
|
|
22541
22733
|
return;
|
|
22542
22734
|
const preparedForWait = preparation.task;
|
|
@@ -22544,7 +22736,7 @@ async function dispatchDeferredTaskWait(scheduleId, reason, extraTags = [], trig
|
|
|
22544
22736
|
return {};
|
|
22545
22737
|
const client = getDbClient2();
|
|
22546
22738
|
return client.transaction(async () => {
|
|
22547
|
-
const resolved = await resolveWaitCause(scheduleId, reason);
|
|
22739
|
+
const resolved = await resolveWaitCause(scheduleId, reason, causeDetail);
|
|
22548
22740
|
if (!resolved)
|
|
22549
22741
|
return {};
|
|
22550
22742
|
let schedule = await getScheduledTaskById2(scheduleId);
|
|
@@ -22648,6 +22840,26 @@ async function reapSpentDeferredSchedules(now = new Date) {
|
|
|
22648
22840
|
)`, [cutoff]);
|
|
22649
22841
|
return result.changes;
|
|
22650
22842
|
}
|
|
22843
|
+
function confirmFresh(key, read) {
|
|
22844
|
+
const previous = confirmFlights.get(key);
|
|
22845
|
+
if (previous && !previous.started)
|
|
22846
|
+
return previous.result;
|
|
22847
|
+
const flight = { started: false, result: Promise.resolve({ happened: false }) };
|
|
22848
|
+
const after = previous ? previous.result.then(noop, noop) : Promise.resolve();
|
|
22849
|
+
flight.result = after.then(() => {
|
|
22850
|
+
flight.started = true;
|
|
22851
|
+
return read();
|
|
22852
|
+
}).then(toConfirmResult).finally(() => {
|
|
22853
|
+
if (confirmFlights.get(key) === flight)
|
|
22854
|
+
confirmFlights.delete(key);
|
|
22855
|
+
});
|
|
22856
|
+
confirmFlights.set(key, flight);
|
|
22857
|
+
return flight.result;
|
|
22858
|
+
}
|
|
22859
|
+
function noop() {}
|
|
22860
|
+
async function hasPendingEventWait(source, event) {
|
|
22861
|
+
return !!await getDbClient2().get("SELECT 1 AS found FROM deferred_event_waits WHERE status = 'pending' AND source = ? AND event = ? LIMIT 1", [source, event]);
|
|
22862
|
+
}
|
|
22651
22863
|
async function reconcileDeferredEventWaits(only, trustEvent = false) {
|
|
22652
22864
|
const waits = await getDbClient2().query(`SELECT w.scheduleId, w.source, w.event, w.matchKey, w.matchJson FROM deferred_event_waits w
|
|
22653
22865
|
JOIN scheduled_tasks s ON s.id = w.scheduleId
|
|
@@ -22661,9 +22873,10 @@ async function reconcileDeferredEventWaits(only, trustEvent = false) {
|
|
|
22661
22873
|
const key = `${wait.source}|${wait.event}|${wait.matchKey}`;
|
|
22662
22874
|
try {
|
|
22663
22875
|
if (!satisfied.has(key))
|
|
22664
|
-
satisfied.set(key, adapter.confirm ? await adapter.confirm(wait.event, JSON.parse(wait.matchJson)) : true);
|
|
22665
|
-
|
|
22666
|
-
|
|
22876
|
+
satisfied.set(key, adapter.confirm ? await confirmFresh(key, () => adapter.confirm(wait.event, JSON.parse(wait.matchJson))) : { happened: true });
|
|
22877
|
+
const result = satisfied.get(key);
|
|
22878
|
+
if (result.happened)
|
|
22879
|
+
await dispatchDeferredTaskWait(wait.scheduleId, externalWakeReason(wait.source, wait.event), [], undefined, undefined, result.detail);
|
|
22667
22880
|
} catch (err) {
|
|
22668
22881
|
console.error(`[Scheduler] External event wake failed for ${wait.scheduleId}:`, err);
|
|
22669
22882
|
}
|
|
@@ -22703,7 +22916,8 @@ async function initDeferredTaskWaits() {
|
|
|
22703
22916
|
for (const adapter of EXTERNAL_EVENT_ADAPTERS) {
|
|
22704
22917
|
const listener = externalEventListener(adapter);
|
|
22705
22918
|
externalEventListeners.set(adapter, listener);
|
|
22706
|
-
|
|
22919
|
+
for (const prefix of adapter.busPrefixes)
|
|
22920
|
+
workflowEventBus2.onPrefix(prefix, listener);
|
|
22707
22921
|
}
|
|
22708
22922
|
await reconcileDeferredTaskWaits();
|
|
22709
22923
|
reconcileDeferredEventWaits().catch((err) => {
|
|
@@ -22718,11 +22932,12 @@ function stopDeferredTaskWaits() {
|
|
|
22718
22932
|
workflowEventBus2.off("task.superseded", onTaskEvent);
|
|
22719
22933
|
workflowEventBus2.off("task.created", onTaskEvent);
|
|
22720
22934
|
for (const [adapter, listener] of externalEventListeners) {
|
|
22721
|
-
|
|
22935
|
+
for (const prefix of adapter.busPrefixes)
|
|
22936
|
+
workflowEventBus2.offPrefix(prefix, listener);
|
|
22722
22937
|
}
|
|
22723
22938
|
externalEventListeners.clear();
|
|
22724
22939
|
}
|
|
22725
|
-
var MAX_PENDING_EVENT_WAITS_PER_AGENT = 20, WAIT_MEMBER_STATUS_SQL, DEFERRED_WAIT_WOKE_EVENT = "task_deferred_wait_woke", SPENT_DEFERRED_SCHEDULE_RETENTION_MS, externalEventListeners;
|
|
22940
|
+
var MAX_PENDING_EVENT_WAITS_PER_AGENT = 20, WAIT_MEMBER_STATUS_SQL, DEFERRED_WAIT_WOKE_EVENT = "task_deferred_wait_woke", SPENT_DEFERRED_SCHEDULE_RETENTION_MS, confirmFlights, externalEventListeners;
|
|
22726
22941
|
var init_deferred_task_waits = __esm(() => {
|
|
22727
22942
|
init_db4();
|
|
22728
22943
|
init_event_waits();
|
|
@@ -22733,6 +22948,7 @@ var init_deferred_task_waits = __esm(() => {
|
|
|
22733
22948
|
WHEN t.status = 'superseded' AND t.failureReason = '${SUPERSEDED_WORKFLOW_TASK_REASON}' THEN 'failed'
|
|
22734
22949
|
ELSE t.status END`;
|
|
22735
22950
|
SPENT_DEFERRED_SCHEDULE_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
22951
|
+
confirmFlights = new Map;
|
|
22736
22952
|
externalEventListeners = new Map;
|
|
22737
22953
|
});
|
|
22738
22954
|
|
|
@@ -22923,11 +23139,15 @@ async function throwIfWorkflowNeedsSetup(scheduleId, runIds) {
|
|
|
22923
23139
|
throw new AutomationNeedsSetupError(run.error);
|
|
22924
23140
|
}
|
|
22925
23141
|
}
|
|
22926
|
-
async function claimScheduleOccurrence(snapshot, extraTags) {
|
|
23142
|
+
async function claimScheduleOccurrence(snapshot, extraTags, signal) {
|
|
23143
|
+
if (signal?.aborted)
|
|
23144
|
+
return null;
|
|
22927
23145
|
const preparedWait = await prepareDeferredTaskWait(snapshot.id, "ceiling", extraTags);
|
|
23146
|
+
if (signal?.aborted)
|
|
23147
|
+
return null;
|
|
22928
23148
|
return getDbClient2().transaction(async () => {
|
|
22929
23149
|
const current = await getScheduledTaskById2(snapshot.id);
|
|
22930
|
-
if (!current?.enabled || !current.nextRunAt || current.nextRunAt !== snapshot.nextRunAt) {
|
|
23150
|
+
if (signal?.aborted || !current?.enabled || !current.nextRunAt || current.nextRunAt !== snapshot.nextRunAt) {
|
|
22931
23151
|
return null;
|
|
22932
23152
|
}
|
|
22933
23153
|
const schedule = renderScheduledTaskParams(current);
|
|
@@ -22957,17 +23177,19 @@ async function updateClaimedSchedule(claimed, updates) {
|
|
|
22957
23177
|
await updateScheduledTask2(claimed.id, updates);
|
|
22958
23178
|
});
|
|
22959
23179
|
}
|
|
22960
|
-
async function recoverMissedSchedules() {
|
|
23180
|
+
async function recoverMissedSchedules(signal) {
|
|
22961
23181
|
const now = Date.now();
|
|
22962
23182
|
const dueSchedules = await getDueScheduledTasks2();
|
|
22963
23183
|
for (const schedule of dueSchedules) {
|
|
23184
|
+
if (signal.aborted)
|
|
23185
|
+
return;
|
|
22964
23186
|
if (!schedule.nextRunAt)
|
|
22965
23187
|
continue;
|
|
22966
23188
|
const missedBy = now - new Date(schedule.nextRunAt).getTime();
|
|
22967
23189
|
if (missedBy < 15000)
|
|
22968
23190
|
continue;
|
|
22969
23191
|
console.log(`[Scheduler] Recovering missed schedule "${schedule.name}" ` + `(was due ${Math.round(missedBy / 1000)}s ago)`);
|
|
22970
|
-
await executeSchedule(schedule, ["recovered"]);
|
|
23192
|
+
await executeSchedule(schedule, ["recovered"], signal);
|
|
22971
23193
|
}
|
|
22972
23194
|
}
|
|
22973
23195
|
function calculateNextRun2(schedule, fromTime = new Date) {
|
|
@@ -22992,12 +23214,12 @@ function getBackoffMs(consecutiveErrors) {
|
|
|
22992
23214
|
const idx = Math.min(consecutiveErrors - 1, ERROR_BACKOFF_MS.length - 1);
|
|
22993
23215
|
return ERROR_BACKOFF_MS[Math.max(0, idx)] ?? ERROR_BACKOFF_MS[0];
|
|
22994
23216
|
}
|
|
22995
|
-
async function executeSchedule(schedule, extraTags = []) {
|
|
22996
|
-
let claimed
|
|
23217
|
+
async function executeSchedule(schedule, extraTags = [], signal) {
|
|
23218
|
+
let claimed;
|
|
22997
23219
|
let triggeredWorkflows = false;
|
|
22998
23220
|
const wasRecovered = extraTags.includes("recovered");
|
|
22999
23221
|
try {
|
|
23000
|
-
const occurrence = await claimScheduleOccurrence(schedule, extraTags);
|
|
23222
|
+
const occurrence = await claimScheduleOccurrence(schedule, extraTags, signal);
|
|
23001
23223
|
if (!occurrence)
|
|
23002
23224
|
return;
|
|
23003
23225
|
({ schedule, claimed } = occurrence);
|
|
@@ -23014,6 +23236,8 @@ async function executeSchedule(schedule, extraTags = []) {
|
|
|
23014
23236
|
wasRecovered
|
|
23015
23237
|
});
|
|
23016
23238
|
} catch (err) {
|
|
23239
|
+
if (signal?.aborted && !claimed)
|
|
23240
|
+
return;
|
|
23017
23241
|
if (err instanceof AutomationNeedsSetupError) {
|
|
23018
23242
|
telemetry.schedule("error", {
|
|
23019
23243
|
scheduleType: schedule.scheduleType,
|
|
@@ -23044,7 +23268,7 @@ async function executeSchedule(schedule, extraTags = []) {
|
|
|
23044
23268
|
updates.nextRunAt = new Date(now.getTime() + backoff).toISOString();
|
|
23045
23269
|
console.log(`[Scheduler] Backing off "${schedule.name}" for ${backoff / 1000}s`);
|
|
23046
23270
|
}
|
|
23047
|
-
await updateClaimedSchedule(claimed, updates);
|
|
23271
|
+
await updateClaimedSchedule(claimed ?? schedule, updates);
|
|
23048
23272
|
telemetry.schedule("error", {
|
|
23049
23273
|
scheduleType: schedule.scheduleType,
|
|
23050
23274
|
triggeredWorkflows,
|
|
@@ -23063,17 +23287,18 @@ function startScheduler2(registry, intervalMs = DEFAULT_SCHEDULER_INTERVAL_MS, o
|
|
|
23063
23287
|
console.log("[Scheduler] Already running");
|
|
23064
23288
|
return;
|
|
23065
23289
|
}
|
|
23066
|
-
const run =
|
|
23290
|
+
const run = new AbortController;
|
|
23067
23291
|
schedulerRun = run;
|
|
23292
|
+
const { signal } = run;
|
|
23068
23293
|
executorRegistry = registry;
|
|
23069
23294
|
console.log(`[Scheduler] Starting with ${intervalMs}ms polling interval`);
|
|
23070
|
-
initDeferredTaskWaits().then(() =>
|
|
23071
|
-
if (
|
|
23295
|
+
initDeferredTaskWaits().then(() => signal.aborted ? undefined : recoverMissedSchedules(signal)).catch((err) => console.error("[Scheduler] Recovery failed:", err)).then(async () => {
|
|
23296
|
+
if (signal.aborted)
|
|
23072
23297
|
return;
|
|
23073
23298
|
schedulerInterval = setInterval(() => {
|
|
23074
|
-
withLoopPath("scheduler.poll", () => processSchedules()).catch((err) => console.error("[Scheduler] Poll failed:", err));
|
|
23299
|
+
withLoopPath("scheduler.poll", () => processSchedules(signal)).catch((err) => console.error("[Scheduler] Poll failed:", err));
|
|
23075
23300
|
}, intervalMs);
|
|
23076
|
-
await processSchedules();
|
|
23301
|
+
await processSchedules(signal);
|
|
23077
23302
|
}).catch((err) => console.error("[Scheduler] Poll failed:", err));
|
|
23078
23303
|
ensure({
|
|
23079
23304
|
id: "scheduler_started",
|
|
@@ -23092,21 +23317,25 @@ function startScheduler2(registry, intervalMs = DEFAULT_SCHEDULER_INTERVAL_MS, o
|
|
|
23092
23317
|
conditions: [{ timeout_ms: 1e4 }]
|
|
23093
23318
|
});
|
|
23094
23319
|
}
|
|
23095
|
-
async function processSchedules() {
|
|
23096
|
-
if (isProcessing)
|
|
23320
|
+
async function processSchedules(signal) {
|
|
23321
|
+
if (signal.aborted || isProcessing)
|
|
23097
23322
|
return;
|
|
23098
23323
|
isProcessing = true;
|
|
23099
23324
|
try {
|
|
23100
23325
|
await reconcileDeferredTaskWaits();
|
|
23326
|
+
if (signal.aborted)
|
|
23327
|
+
return;
|
|
23101
23328
|
const dueSchedules = await getDueScheduledTasks2();
|
|
23102
23329
|
for (const schedule of dueSchedules) {
|
|
23330
|
+
if (signal.aborted)
|
|
23331
|
+
return;
|
|
23103
23332
|
try {
|
|
23104
|
-
await executeSchedule(schedule);
|
|
23333
|
+
await executeSchedule(schedule, [], signal);
|
|
23105
23334
|
} catch (err) {
|
|
23106
23335
|
console.error(`[Scheduler] Error executing "${schedule.name}":`, err);
|
|
23107
23336
|
}
|
|
23108
23337
|
}
|
|
23109
|
-
if (Date.now() - lastDeferredReapAt >= DEFERRED_REAP_INTERVAL_MS) {
|
|
23338
|
+
if (!signal.aborted && Date.now() - lastDeferredReapAt >= DEFERRED_REAP_INTERVAL_MS) {
|
|
23110
23339
|
lastDeferredReapAt = Date.now();
|
|
23111
23340
|
try {
|
|
23112
23341
|
const reaped = await reapSpentDeferredSchedules();
|
|
@@ -23121,6 +23350,7 @@ async function processSchedules() {
|
|
|
23121
23350
|
}
|
|
23122
23351
|
}
|
|
23123
23352
|
function stopScheduler2() {
|
|
23353
|
+
schedulerRun?.abort();
|
|
23124
23354
|
schedulerRun = null;
|
|
23125
23355
|
stopDeferredTaskWaits();
|
|
23126
23356
|
if (schedulerInterval) {
|
|
@@ -25005,7 +25235,7 @@ function setPreloadedTools(server, names) {
|
|
|
25005
25235
|
async function applyPreToolCall(name, args, requestInfo, inputSchema) {
|
|
25006
25236
|
if (requestInfo.callOrigin !== "mcp")
|
|
25007
25237
|
return { args };
|
|
25008
|
-
const dispatcher = await import("./dispatcher-
|
|
25238
|
+
const dispatcher = await import("./dispatcher-76as8w2t.js");
|
|
25009
25239
|
const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
|
|
25010
25240
|
validateModify: async (data) => {
|
|
25011
25241
|
const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
|
|
@@ -25099,6 +25329,9 @@ var scriptSdkRequestOrigins, extensionRequestOrigins, getRequestInfo = (req) =>
|
|
|
25099
25329
|
};
|
|
25100
25330
|
}, PREVIEW_LIMIT = 500, toolOk = (message, extras = {}) => ({ ok: true, message, ...extras }), toolErr = (message, extras = {}) => ({ ok: false, message, ...extras }), swarmToolTruncationSchema, swarmToolEnvelopeShape, swarmToolOutputSchema = (dataShape) => looseObject({ ...swarmToolEnvelopeShape, ...dataShape ?? {} }), SCRIPT_AUTHORING_NUDGE = "Scripts must `export default async function (args, ctx)` — args FIRST, ctx second; run script-query-types (no name) for the full ctx/SDK type surface, and see the `swarm-scripts` skill for authoring patterns.", SCRIPT_RUN_TIMEOUT_NUDGE = "This one-off script timed out; use `launch-script-run` with bounded journaled steps for a durable run instead.", WORKFLOW_LONG_SCRIPT_TIMEOUT_NUDGE = "This workflow keeps a script node blocking for over two minutes; use `launch-script-run` with bounded journaled steps for durable one-off work instead.", scriptAuthoringNudge = (r) => !r.ok && /Typecheck failed:|Script run .*failed/.test(r.message) ? SCRIPT_AUTHORING_NUDGE : undefined, scriptRunNudge = (r) => {
|
|
25101
25331
|
const body = r.data?.data;
|
|
25332
|
+
if (!r.ok && body?.error === "object busy") {
|
|
25333
|
+
return "object busy: retry the call later, do not loop.";
|
|
25334
|
+
}
|
|
25102
25335
|
return !r.ok && body?.error === "timeout" ? SCRIPT_RUN_TIMEOUT_NUDGE : scriptAuthoringNudge(r);
|
|
25103
25336
|
}, SLACK_API_DISK_NUDGE = "That path is on the API server's disk, not in your container — call this from a task you own (or pass its taskId) to get the file as a task attachment with a fetchCommand.", slackDownloadFileNudge = (r) => r.ok && r.data?.savedPath ? SLACK_API_DISK_NUDGE : undefined, slackReadNudge = (r) => {
|
|
25104
25337
|
if (!r.ok)
|
|
@@ -25540,6 +25773,7 @@ class SwarmConfig {
|
|
|
25540
25773
|
apiKey;
|
|
25541
25774
|
agentId;
|
|
25542
25775
|
mcpBaseUrl;
|
|
25776
|
+
sdkBaseUrl;
|
|
25543
25777
|
runtimeInstanceId;
|
|
25544
25778
|
auditSourceTaskId;
|
|
25545
25779
|
extensionToken;
|
|
@@ -25557,6 +25791,11 @@ class SwarmConfig {
|
|
|
25557
25791
|
type: "system",
|
|
25558
25792
|
isSecret: payload.system.mcpBaseUrl.isSecret
|
|
25559
25793
|
});
|
|
25794
|
+
const sdkBaseUrl = payload.system.sdkBaseUrl ?? payload.system.mcpBaseUrl;
|
|
25795
|
+
this.sdkBaseUrl = Redacted.make(sdkBaseUrl.value, {
|
|
25796
|
+
type: "system",
|
|
25797
|
+
isSecret: sdkBaseUrl.isSecret
|
|
25798
|
+
});
|
|
25560
25799
|
this.runtimeInstanceId = payload.system.runtimeInstanceId ? Redacted.make(payload.system.runtimeInstanceId.value, {
|
|
25561
25800
|
type: "system",
|
|
25562
25801
|
isSecret: payload.system.runtimeInstanceId.isSecret
|
|
@@ -25793,8 +26032,15 @@ function bridgeRequestFor(name, args) {
|
|
|
25793
26032
|
};
|
|
25794
26033
|
}
|
|
25795
26034
|
case "memory_rate": {
|
|
26035
|
+
if (body.id && body.memoryId && body.id !== body.memoryId) {
|
|
26036
|
+
throw new Error("id and memoryId must identify the same memory; supply only one.");
|
|
26037
|
+
}
|
|
26038
|
+
const memoryId = body.id ?? body.memoryId;
|
|
26039
|
+
if (typeof memoryId !== "string" || !memoryId) {
|
|
26040
|
+
throw new Error("Supply id (or its alias memoryId) from memory-search.");
|
|
26041
|
+
}
|
|
25796
26042
|
const event = {
|
|
25797
|
-
memoryId
|
|
26043
|
+
memoryId,
|
|
25798
26044
|
signal: body.useful === false ? -1 : 1,
|
|
25799
26045
|
weight: 1,
|
|
25800
26046
|
source: "explicit-self",
|
|
@@ -26229,7 +26475,7 @@ async function bridgeFetch(url, init, { repeatSafe, readOnly }, signal) {
|
|
|
26229
26475
|
}
|
|
26230
26476
|
}
|
|
26231
26477
|
async function callBridgeApi(name, args, config, options = {}) {
|
|
26232
|
-
const baseUrl = Redacted.value(config.
|
|
26478
|
+
const baseUrl = Redacted.value(config.sdkBaseUrl).replace(/\/$/, "");
|
|
26233
26479
|
const request = bridgeRequestFor(name, args);
|
|
26234
26480
|
if (!request) {
|
|
26235
26481
|
const mcpToolName = mcpToolNameForSdkMethod(name);
|
|
@@ -26312,13 +26558,15 @@ function createSwarmSdk(config, options = {}) {
|
|
|
26312
26558
|
}
|
|
26313
26559
|
});
|
|
26314
26560
|
}
|
|
26315
|
-
var BRIDGE_MAX_RETRIES = 3, BRIDGE_MIN_DELAY_MS = 250, BRIDGE_MAX_DELAY_MS = 2000, BRIDGE_RETRY_BUDGET_MS = 5000, READ_RETRY_STATUSES, READ_TOOL_PATTERN, READ_TOOLS, NON_READ_GET_METHODS;
|
|
26561
|
+
var DurableObject, BRIDGE_MAX_RETRIES = 3, BRIDGE_MIN_DELAY_MS = 250, BRIDGE_MAX_DELAY_MS = 2000, BRIDGE_RETRY_BUDGET_MS = 5000, READ_RETRY_STATUSES, READ_TOOL_PATTERN, READ_TOOLS, NON_READ_GET_METHODS;
|
|
26316
26562
|
var init_swarm_sdk = __esm(() => {
|
|
26317
26563
|
init_secret_scrubber();
|
|
26564
|
+
init_durable_object_base();
|
|
26318
26565
|
init_redacted();
|
|
26319
26566
|
init_response_limit();
|
|
26320
26567
|
init_sdk_allowlist();
|
|
26321
26568
|
init_retry();
|
|
26569
|
+
DurableObject = new Function(`${DURABLE_OBJECT_BASE_JS}; return DurableObject;`)();
|
|
26322
26570
|
READ_RETRY_STATUSES = new Set([502, 503, 504]);
|
|
26323
26571
|
READ_TOOL_PATTERN = /^(get|list)-|-(get|list|search)$/;
|
|
26324
26572
|
READ_TOOLS = new Set([
|
|
@@ -29729,7 +29977,7 @@ async function handleWorkItemDeleted(event) {
|
|
|
29729
29977
|
return { created: false };
|
|
29730
29978
|
const task = sync.swarmId && !sync.swarmId.startsWith("pending:") ? await getTaskById2(sync.swarmId) : null;
|
|
29731
29979
|
if (task && !isTerminalTaskStatus(task.status)) {
|
|
29732
|
-
await cancelTask2(task.id, DELETED_REASON);
|
|
29980
|
+
await cancelTask2(task.id, DELETED_REASON, { statusKind: "external" });
|
|
29733
29981
|
console.log(`[AzureDevOps] Cancelled task ${task.id} (work item #${item.id} deleted)`);
|
|
29734
29982
|
}
|
|
29735
29983
|
await markTrackerDelivery(PROVIDER, "task", externalId, event.id);
|
|
@@ -30600,7 +30848,7 @@ async function handlePullRequestClosed(body, outcome) {
|
|
|
30600
30848
|
const reason = outcome === "merged" ? "PR was merged" : "PR was declined";
|
|
30601
30849
|
for (const task of await findActiveTasksByVcs2(repository.full_name, pr.id, "bitbucket")) {
|
|
30602
30850
|
console.log(`[Bitbucket] Cancelling task ${task.id} — ${reason}`);
|
|
30603
|
-
await failTask2(task.id, reason);
|
|
30851
|
+
await failTask2(task.id, reason, { statusKind: "external" });
|
|
30604
30852
|
}
|
|
30605
30853
|
return { created: false };
|
|
30606
30854
|
}
|
|
@@ -31261,7 +31509,9 @@ async function handlePullRequest(event) {
|
|
|
31261
31509
|
console.log(`[GitHub] No active task found for PR #${pr.number} to cancel`);
|
|
31262
31510
|
return { created: false };
|
|
31263
31511
|
}
|
|
31264
|
-
const cancelledTask = await failTask2(task.id, `Unassigned from GitHub PR #${pr.number}
|
|
31512
|
+
const cancelledTask = await failTask2(task.id, `Unassigned from GitHub PR #${pr.number}`, {
|
|
31513
|
+
statusKind: "external"
|
|
31514
|
+
});
|
|
31265
31515
|
if (cancelledTask) {
|
|
31266
31516
|
console.log(`[GitHub] Cancelled task ${task.id} for PR #${pr.number} (unassigned)`);
|
|
31267
31517
|
return { created: false, taskId: task.id };
|
|
@@ -31333,7 +31583,7 @@ async function handlePullRequest(event) {
|
|
|
31333
31583
|
console.log(`[GitHub] No active task found for PR #${pr.number} to cancel`);
|
|
31334
31584
|
return { created: false };
|
|
31335
31585
|
}
|
|
31336
|
-
const cancelledTask = await failTask2(task.id, `Review request removed from GitHub PR #${pr.number}
|
|
31586
|
+
const cancelledTask = await failTask2(task.id, `Review request removed from GitHub PR #${pr.number}`, { statusKind: "external" });
|
|
31337
31587
|
if (cancelledTask) {
|
|
31338
31588
|
console.log(`[GitHub] Cancelled task ${task.id} for PR #${pr.number} (review request removed)`);
|
|
31339
31589
|
return { created: false, taskId: task.id };
|
|
@@ -31511,7 +31761,9 @@ async function handleIssue(event) {
|
|
|
31511
31761
|
console.log(`[GitHub] No active task found for issue #${issue.number} to cancel`);
|
|
31512
31762
|
return { created: false };
|
|
31513
31763
|
}
|
|
31514
|
-
const cancelledTask = await failTask2(task.id, `Unassigned from GitHub issue #${issue.number}
|
|
31764
|
+
const cancelledTask = await failTask2(task.id, `Unassigned from GitHub issue #${issue.number}`, {
|
|
31765
|
+
statusKind: "external"
|
|
31766
|
+
});
|
|
31515
31767
|
if (cancelledTask) {
|
|
31516
31768
|
console.log(`[GitHub] Cancelled task ${task.id} for issue #${issue.number} (unassigned)`);
|
|
31517
31769
|
return { created: false, taskId: task.id };
|
|
@@ -32344,7 +32596,7 @@ async function handleMergeRequest(event) {
|
|
|
32344
32596
|
const tasks = await findActiveTasksByVcs2(repo, mr.iid, "gitlab");
|
|
32345
32597
|
for (const task of tasks.filter((t) => isScopedTask(t, "mr", mrContextKey))) {
|
|
32346
32598
|
console.log(`[GitLab] Cancelling task ${task.id} — ${reason}`);
|
|
32347
|
-
await failTask2(task.id, reason);
|
|
32599
|
+
await failTask2(task.id, reason, { statusKind: "external" });
|
|
32348
32600
|
}
|
|
32349
32601
|
return { created: false };
|
|
32350
32602
|
}
|
|
@@ -32431,7 +32683,7 @@ async function handleIssue2(event) {
|
|
|
32431
32683
|
const existingTask = (await findActiveTasksByVcs2(repo, issue.iid, "gitlab")).find((t) => isScopedTask(t, "issue", issueContextKey));
|
|
32432
32684
|
if (existingTask) {
|
|
32433
32685
|
console.log(`[GitLab] Cancelling task ${existingTask.id} — issue closed`);
|
|
32434
|
-
await failTask2(existingTask.id, "Issue was closed");
|
|
32686
|
+
await failTask2(existingTask.id, "Issue was closed", { statusKind: "external" });
|
|
32435
32687
|
}
|
|
32436
32688
|
return { created: false };
|
|
32437
32689
|
}
|
|
@@ -33519,7 +33771,9 @@ async function cancelActiveTasks(target, requestedBy) {
|
|
|
33519
33771
|
const active = await getLatestActiveTaskByContextKey2(contextKey, "chat", target.owner);
|
|
33520
33772
|
if (!active)
|
|
33521
33773
|
break;
|
|
33522
|
-
const task = await cancelTask2(active.id, `Cancelled from chat by ${requestedBy}
|
|
33774
|
+
const task = await cancelTask2(active.id, `Cancelled from chat by ${requestedBy}`, {
|
|
33775
|
+
statusKind: "user"
|
|
33776
|
+
});
|
|
33523
33777
|
if (!task)
|
|
33524
33778
|
break;
|
|
33525
33779
|
if (task.agentId)
|
|
@@ -35857,12 +36111,12 @@ var RELAY_GIVE_UP_AFTER_MS, SWEEP_EVERY_N_TICKS = 20, EARLY_TICK_DEBOUNCE_MS = 2
|
|
|
35857
36111
|
var init_relay = __esm(() => {
|
|
35858
36112
|
init_dist5();
|
|
35859
36113
|
init_db4();
|
|
35860
|
-
|
|
36114
|
+
init_task_ui_spec2();
|
|
35861
36115
|
init_reaction_events();
|
|
35862
36116
|
init_context_key();
|
|
35863
36117
|
init_env_flag();
|
|
35864
36118
|
init_secret_scrubber();
|
|
35865
|
-
|
|
36119
|
+
init_task_ui_spec();
|
|
35866
36120
|
init_event_bus();
|
|
35867
36121
|
init_commands();
|
|
35868
36122
|
init_limits();
|
|
@@ -36786,7 +37040,7 @@ async function handleIssueDeleteEvent(event) {
|
|
|
36786
37040
|
return;
|
|
36787
37041
|
const task = sync.swarmId ? await getTaskById2(sync.swarmId) : null;
|
|
36788
37042
|
if (task && !isTerminalTaskStatus(task.status)) {
|
|
36789
|
-
await cancelTask2(sync.swarmId, "Jira issue deleted");
|
|
37043
|
+
await cancelTask2(sync.swarmId, "Jira issue deleted", { statusKind: "external" });
|
|
36790
37044
|
console.log(`[Jira Sync] Cancelled task ${sync.swarmId} (Jira issue ${issue.key ?? issue.id} deleted)`);
|
|
36791
37045
|
}
|
|
36792
37046
|
}
|
|
@@ -36896,7 +37150,7 @@ async function notifySlack(text) {
|
|
|
36896
37150
|
return;
|
|
36897
37151
|
}
|
|
36898
37152
|
try {
|
|
36899
|
-
const { getSlackApp } = await import("./app-
|
|
37153
|
+
const { getSlackApp } = await import("./app-5d3sz1hy.js");
|
|
36900
37154
|
const app = getSlackApp();
|
|
36901
37155
|
if (!app) {
|
|
36902
37156
|
console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
|
|
@@ -36967,7 +37221,7 @@ async function deleteJiraWebhook(webhookId) {
|
|
|
36967
37221
|
console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
|
|
36968
37222
|
}
|
|
36969
37223
|
async function overwriteWebhookIds(next) {
|
|
36970
|
-
const { getDbClient } = await import("./db-
|
|
37224
|
+
const { getDbClient } = await import("./db-vrckks6q.js");
|
|
36971
37225
|
await getDbClient().transaction(async (tx) => {
|
|
36972
37226
|
const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
|
|
36973
37227
|
if (!row) {
|
|
@@ -109278,7 +109532,7 @@ async function handleIssueUpdate(event, deliveryId) {
|
|
|
109278
109532
|
if (swarmStatus === "cancelled") {
|
|
109279
109533
|
const task = await getTaskById2(sync.swarmId);
|
|
109280
109534
|
if (task && !isTerminalTaskStatus(task.status)) {
|
|
109281
|
-
await cancelTask2(sync.swarmId, `Linear issue cancelled
|
|
109535
|
+
await cancelTask2(sync.swarmId, `Linear issue cancelled`, { statusKind: "external" });
|
|
109282
109536
|
console.log(`[Linear Sync] Cancelled task ${sync.swarmId} (Linear issue ${data.identifier ?? issueId} cancelled)`);
|
|
109283
109537
|
}
|
|
109284
109538
|
return;
|
|
@@ -109301,7 +109555,7 @@ async function handleIssueDelete(event) {
|
|
|
109301
109555
|
return;
|
|
109302
109556
|
const task = await getTaskById2(sync.swarmId);
|
|
109303
109557
|
if (task && !isTerminalTaskStatus(task.status)) {
|
|
109304
|
-
await cancelTask2(sync.swarmId, "Linear issue deleted");
|
|
109558
|
+
await cancelTask2(sync.swarmId, "Linear issue deleted", { statusKind: "external" });
|
|
109305
109559
|
console.log(`[Linear Sync] Cancelled task ${sync.swarmId} (Linear issue ${issueId} deleted)`);
|
|
109306
109560
|
}
|
|
109307
109561
|
}
|
|
@@ -109330,7 +109584,9 @@ async function handleAgentSessionPrompted(event) {
|
|
|
109330
109584
|
if (existing) {
|
|
109331
109585
|
const existingTask = await getTaskById2(existing.swarmId);
|
|
109332
109586
|
if (existingTask && !isTerminalTaskStatus(existingTask.status)) {
|
|
109333
|
-
await cancelTask2(existing.swarmId, "Stopped by user from Linear"
|
|
109587
|
+
await cancelTask2(existing.swarmId, "Stopped by user from Linear", {
|
|
109588
|
+
statusKind: "user"
|
|
109589
|
+
});
|
|
109334
109590
|
console.log(`[Linear Sync] Cancelled task ${existing.swarmId} (stop signal from Linear)`);
|
|
109335
109591
|
}
|
|
109336
109592
|
}
|
|
@@ -109768,9 +110024,9 @@ var init_linear = __esm(() => {
|
|
|
109768
110024
|
});
|
|
109769
110025
|
|
|
109770
110026
|
// src/slack/files.ts
|
|
109771
|
-
import {
|
|
109772
|
-
import { mkdir } from "node:fs/promises";
|
|
109773
|
-
import { dirname as dirname2 } from "node:path";
|
|
110027
|
+
import { constants } from "node:fs";
|
|
110028
|
+
import { lstat, mkdir, open, realpath, stat } from "node:fs/promises";
|
|
110029
|
+
import { basename, dirname as dirname2, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
109774
110030
|
async function uploadFile(client, options) {
|
|
109775
110031
|
const { file, filename, channelId, threadTs, initialComment, title } = options;
|
|
109776
110032
|
try {
|
|
@@ -109825,8 +110081,88 @@ async function uploadFile(client, options) {
|
|
|
109825
110081
|
};
|
|
109826
110082
|
}
|
|
109827
110083
|
}
|
|
110084
|
+
async function openFileInside(path, roots) {
|
|
110085
|
+
const outside = {
|
|
110086
|
+
success: false,
|
|
110087
|
+
notFound: false,
|
|
110088
|
+
error: `${path} must be a regular file inside ${roots.join(" or ")}.`
|
|
110089
|
+
};
|
|
110090
|
+
const inRoots = (real) => realRoots.some((root) => isInside(root, real));
|
|
110091
|
+
const realRoots = [];
|
|
110092
|
+
for (const root of roots) {
|
|
110093
|
+
const real = await realpath(root).catch(() => {
|
|
110094
|
+
return;
|
|
110095
|
+
});
|
|
110096
|
+
if (real && real !== "/")
|
|
110097
|
+
realRoots.push(real);
|
|
110098
|
+
}
|
|
110099
|
+
const real = await realpath(path).catch(() => {
|
|
110100
|
+
return;
|
|
110101
|
+
});
|
|
110102
|
+
if (!real)
|
|
110103
|
+
return { success: false, notFound: true, error: `File not found: ${path}` };
|
|
110104
|
+
if (!inRoots(real))
|
|
110105
|
+
return outside;
|
|
110106
|
+
let handle;
|
|
110107
|
+
try {
|
|
110108
|
+
handle = await open(real, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
110109
|
+
} catch {
|
|
110110
|
+
return { success: false, notFound: false, error: `Cannot read file: ${path}` };
|
|
110111
|
+
}
|
|
110112
|
+
try {
|
|
110113
|
+
const info = await handle.stat();
|
|
110114
|
+
const again = await realpath(real).catch(() => {
|
|
110115
|
+
return;
|
|
110116
|
+
});
|
|
110117
|
+
const now = again ? await stat(again).catch(() => {
|
|
110118
|
+
return;
|
|
110119
|
+
}) : undefined;
|
|
110120
|
+
if (!info.isFile() || !again || !inRoots(again) || now?.dev !== info.dev || now?.ino !== info.ino) {
|
|
110121
|
+
await handle.close();
|
|
110122
|
+
return outside;
|
|
110123
|
+
}
|
|
110124
|
+
if (info.size > MAX_FILE_SIZE) {
|
|
110125
|
+
await handle.close();
|
|
110126
|
+
const sizeMB = Math.round(info.size / 1024 / 1024);
|
|
110127
|
+
return {
|
|
110128
|
+
success: false,
|
|
110129
|
+
notFound: false,
|
|
110130
|
+
error: `File too large: ${sizeMB} MB. Maximum is 1 GB.`
|
|
110131
|
+
};
|
|
110132
|
+
}
|
|
110133
|
+
return { success: true, file: { handle, size: info.size } };
|
|
110134
|
+
} catch (error) {
|
|
110135
|
+
await handle.close();
|
|
110136
|
+
throw error;
|
|
110137
|
+
}
|
|
110138
|
+
}
|
|
110139
|
+
async function uploadOpenFile(client, file, options) {
|
|
110140
|
+
const { filename, channelId, threadTs, initialComment, title } = options;
|
|
110141
|
+
try {
|
|
110142
|
+
const ticket = await client.files.getUploadURLExternal({ filename, length: file.size });
|
|
110143
|
+
if (!ticket.upload_url || !ticket.file_id) {
|
|
110144
|
+
return { success: false, error: "Slack returned no upload URL" };
|
|
110145
|
+
}
|
|
110146
|
+
const sent = await fetch(ticket.upload_url, {
|
|
110147
|
+
method: "POST",
|
|
110148
|
+
body: Bun.file(file.handle.fd).slice(0, file.size)
|
|
110149
|
+
});
|
|
110150
|
+
if (!sent.ok) {
|
|
110151
|
+
return { success: false, error: `Upload failed with HTTP ${sent.status}` };
|
|
110152
|
+
}
|
|
110153
|
+
await client.files.completeUploadExternal({
|
|
110154
|
+
files: [{ id: ticket.file_id, title: title || filename }],
|
|
110155
|
+
channel_id: channelId,
|
|
110156
|
+
...threadTs ? { thread_ts: threadTs } : {},
|
|
110157
|
+
...initialComment ? { initial_comment: initialComment } : {}
|
|
110158
|
+
});
|
|
110159
|
+
return { success: true, fileId: ticket.file_id };
|
|
110160
|
+
} catch (error) {
|
|
110161
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
110162
|
+
}
|
|
110163
|
+
}
|
|
109828
110164
|
async function downloadFile(options) {
|
|
109829
|
-
const { file, savePath, token } = options;
|
|
110165
|
+
const { file, savePath, token, root } = options;
|
|
109830
110166
|
try {
|
|
109831
110167
|
const downloadUrl = typeof file === "string" ? file : file.url_private_download;
|
|
109832
110168
|
if (!downloadUrl) {
|
|
@@ -109835,11 +110171,26 @@ async function downloadFile(options) {
|
|
|
109835
110171
|
error: "No download URL available for this file"
|
|
109836
110172
|
};
|
|
109837
110173
|
}
|
|
110174
|
+
if (!isSlackFileUrl(downloadUrl)) {
|
|
110175
|
+
return { success: false, error: "The download URL is not a Slack file URL" };
|
|
110176
|
+
}
|
|
109838
110177
|
let finalPath = savePath;
|
|
109839
110178
|
if (typeof file !== "string" && (savePath.endsWith("/") || !savePath.includes("."))) {
|
|
109840
|
-
|
|
110179
|
+
const name = basename(file.name);
|
|
110180
|
+
finalPath = savePath.endsWith("/") ? `${savePath}${name}` : `${savePath}/${name}`;
|
|
110181
|
+
}
|
|
110182
|
+
finalPath = resolve2(root, finalPath);
|
|
110183
|
+
if (!isInside(resolve2(root), finalPath)) {
|
|
110184
|
+
return { success: false, error: `The save path must be inside ${root}` };
|
|
110185
|
+
}
|
|
110186
|
+
await mkdir(root, { recursive: true });
|
|
110187
|
+
if ((await lstat(root)).isSymbolicLink()) {
|
|
110188
|
+
return { success: false, error: `${root} must not be a symlink` };
|
|
109841
110189
|
}
|
|
109842
110190
|
await mkdir(dirname2(finalPath), { recursive: true });
|
|
110191
|
+
if (!isInside(await realpath(root), await realpath(dirname2(finalPath)))) {
|
|
110192
|
+
return { success: false, error: `The save path must be inside ${root}` };
|
|
110193
|
+
}
|
|
109843
110194
|
const response = await fetch(downloadUrl, {
|
|
109844
110195
|
headers: {
|
|
109845
110196
|
Authorization: `Bearer ${token}`
|
|
@@ -109858,23 +110209,14 @@ async function downloadFile(options) {
|
|
|
109858
110209
|
error: "No response body"
|
|
109859
110210
|
};
|
|
109860
110211
|
}
|
|
109861
|
-
const
|
|
109862
|
-
const reader = body.getReader();
|
|
110212
|
+
const handle = await open(finalPath, constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC | constants.O_NOFOLLOW);
|
|
109863
110213
|
try {
|
|
109864
|
-
|
|
109865
|
-
|
|
109866
|
-
if (done)
|
|
109867
|
-
break;
|
|
109868
|
-
writer.write(value);
|
|
110214
|
+
for await (const chunk of body) {
|
|
110215
|
+
await handle.write(chunk);
|
|
109869
110216
|
}
|
|
109870
|
-
writer.end();
|
|
109871
110217
|
} finally {
|
|
109872
|
-
|
|
110218
|
+
await handle.close();
|
|
109873
110219
|
}
|
|
109874
|
-
await new Promise((resolve, reject) => {
|
|
109875
|
-
writer.on("finish", resolve);
|
|
109876
|
-
writer.on("error", reject);
|
|
109877
|
-
});
|
|
109878
110220
|
return {
|
|
109879
110221
|
success: true,
|
|
109880
110222
|
savedPath: finalPath
|
|
@@ -109887,6 +110229,25 @@ async function downloadFile(options) {
|
|
|
109887
110229
|
};
|
|
109888
110230
|
}
|
|
109889
110231
|
}
|
|
110232
|
+
function isInside(parent, child) {
|
|
110233
|
+
const rel = relative2(parent, child);
|
|
110234
|
+
return rel !== ".." && !rel.startsWith(`..${sep2}`) && !isAbsolute2(rel);
|
|
110235
|
+
}
|
|
110236
|
+
function isSlackFileUrl(url) {
|
|
110237
|
+
let parsed;
|
|
110238
|
+
try {
|
|
110239
|
+
parsed = new URL(url);
|
|
110240
|
+
} catch {
|
|
110241
|
+
return false;
|
|
110242
|
+
}
|
|
110243
|
+
const apiUrl = process.env.SLACK_API_URL;
|
|
110244
|
+
if (apiUrl && URL.canParse(apiUrl) && new URL(apiUrl).origin === parsed.origin)
|
|
110245
|
+
return true;
|
|
110246
|
+
if (parsed.protocol !== "https:")
|
|
110247
|
+
return false;
|
|
110248
|
+
const host = parsed.hostname;
|
|
110249
|
+
return ["slack.com", "slack-gov.com"].some((domain) => host === domain || host.endsWith(`.${domain}`));
|
|
110250
|
+
}
|
|
109890
110251
|
async function getFileInfo(client, fileId) {
|
|
109891
110252
|
try {
|
|
109892
110253
|
const result = await client.files.info({ file: fileId });
|
|
@@ -109915,9 +110276,9 @@ async function getFileInfo(client, fileId) {
|
|
|
109915
110276
|
return null;
|
|
109916
110277
|
}
|
|
109917
110278
|
}
|
|
109918
|
-
var MAX_FILE_SIZE = 1073741824, DEFAULT_DOWNLOAD_DIR;
|
|
110279
|
+
var MAX_FILE_SIZE = 1073741824, DOWNLOAD_ROOT = "/workspace/shared/downloads", DEFAULT_DOWNLOAD_DIR;
|
|
109919
110280
|
var init_files = __esm(() => {
|
|
109920
|
-
DEFAULT_DOWNLOAD_DIR =
|
|
110281
|
+
DEFAULT_DOWNLOAD_DIR = `${DOWNLOAD_ROOT}/${process.env.AGENT_ID || "default"}/slack`;
|
|
109921
110282
|
});
|
|
109922
110283
|
|
|
109923
110284
|
// src/slack/router.ts
|
|
@@ -110461,7 +110822,7 @@ async function loadGlobalConfigsIntoEnv2(override = false) {
|
|
|
110461
110822
|
if (updated.length > 0) {
|
|
110462
110823
|
refreshSecretScrubberCache();
|
|
110463
110824
|
}
|
|
110464
|
-
const { syncSlackTreeVisibility } = await import("./tree-visibility-
|
|
110825
|
+
const { syncSlackTreeVisibility } = await import("./tree-visibility-kjxv3nxk.js");
|
|
110465
110826
|
await syncSlackTreeVisibility();
|
|
110466
110827
|
return updated;
|
|
110467
110828
|
}
|
|
@@ -110469,7 +110830,7 @@ async function reloadGlobalConfigsAndIntegrations2() {
|
|
|
110469
110830
|
return runWithoutRequestAuth(() => runSlackLifecycleExclusive(() => reloadGlobalConfigsAndIntegrationsInner()));
|
|
110470
110831
|
}
|
|
110471
110832
|
async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
110472
|
-
const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-
|
|
110833
|
+
const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-evay0xyk.js");
|
|
110473
110834
|
const wasEmbeddingsConfigured = getEmbeddingProvider().isConfigured();
|
|
110474
110835
|
const updated = await loadGlobalConfigsIntoEnv2(true);
|
|
110475
110836
|
await syncTelemetryEnabled("settings").catch((err) => {
|
|
@@ -110485,7 +110846,7 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
|
110485
110846
|
integrations.push("embeddings");
|
|
110486
110847
|
}
|
|
110487
110848
|
if (isEmbeddingsConfigured) {
|
|
110488
|
-
import("./embedding-space-
|
|
110849
|
+
import("./embedding-space-zsdw37bb.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: !wasEmbeddingsConfigured })).catch((err) => {
|
|
110489
110850
|
console.error("[config-reload] embedding maintenance failed (non-fatal):", err);
|
|
110490
110851
|
});
|
|
110491
110852
|
}
|
|
@@ -111271,9 +111632,55 @@ async function getAppRow(appId, model, rowId) {
|
|
|
111271
111632
|
}
|
|
111272
111633
|
return entry.value;
|
|
111273
111634
|
}
|
|
111274
|
-
async function
|
|
111635
|
+
async function indexedRowIds(namespace, model, columns, equals) {
|
|
111636
|
+
let best = null;
|
|
111637
|
+
for (const { column, value } of equals) {
|
|
111638
|
+
if (typeof value === "number" || column.includes("/"))
|
|
111639
|
+
continue;
|
|
111640
|
+
const definition = Object.hasOwn(columns, column) ? columns[column] : undefined;
|
|
111641
|
+
if (!definition || !isIndexed(definition))
|
|
111642
|
+
continue;
|
|
111643
|
+
const prefix = appIndexKey(model, column, value, "");
|
|
111644
|
+
const keys = await getDbClient2().query(`SELECT key FROM kv_entries
|
|
111645
|
+
WHERE namespace = ? AND key >= ? AND key < ?
|
|
111646
|
+
AND (expires_at IS NULL OR expires_at > ?)
|
|
111647
|
+
ORDER BY key
|
|
111648
|
+
LIMIT ?`, [namespace, prefix, kvPrefixUpperBound2(prefix), Date.now(), INDEX_LIST_MAX_KEYS + 1]);
|
|
111649
|
+
if (keys.length > INDEX_LIST_MAX_KEYS)
|
|
111650
|
+
continue;
|
|
111651
|
+
if (best === null || keys.length < best.length) {
|
|
111652
|
+
best = keys.map((entry) => entry.key.slice(entry.key.lastIndexOf("/") + 1));
|
|
111653
|
+
}
|
|
111654
|
+
}
|
|
111655
|
+
return best;
|
|
111656
|
+
}
|
|
111657
|
+
async function listAppRows(appId, model, equals = [], columns) {
|
|
111275
111658
|
const namespace = appsNamespace(appId);
|
|
111276
111659
|
const prefix = `${model}/row/`;
|
|
111660
|
+
const ids = columns ? await indexedRowIds(namespace, model, columns, equals) : null;
|
|
111661
|
+
if (ids) {
|
|
111662
|
+
const rows = [];
|
|
111663
|
+
for (let start = 0;start < ids.length; start += INDEX_FETCH_BATCH) {
|
|
111664
|
+
const batch = ids.slice(start, start + INDEX_FETCH_BATCH);
|
|
111665
|
+
const entries = await getDbClient2().query(`SELECT value, value_type FROM kv_entries
|
|
111666
|
+
WHERE namespace = ? AND key IN (${batch.map(() => "?").join(",")})
|
|
111667
|
+
AND (expires_at IS NULL OR expires_at > ?)
|
|
111668
|
+
ORDER BY key`, [namespace, ...batch.map((id) => rowKey(model, id)), Date.now()]);
|
|
111669
|
+
for (const entry of entries) {
|
|
111670
|
+
if (entry.value_type !== "json")
|
|
111671
|
+
continue;
|
|
111672
|
+
try {
|
|
111673
|
+
const value = JSON.parse(entry.value);
|
|
111674
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
111675
|
+
rows.push(value);
|
|
111676
|
+
}
|
|
111677
|
+
} catch {}
|
|
111678
|
+
}
|
|
111679
|
+
if (!isInTransaction())
|
|
111680
|
+
await yieldToEventLoop();
|
|
111681
|
+
}
|
|
111682
|
+
return rows;
|
|
111683
|
+
}
|
|
111277
111684
|
const upper = kvPrefixUpperBound2(prefix);
|
|
111278
111685
|
const jsonFieldEquals = equals.filter((filter) => !/["\\]/.test(filter.column)).map((filter) => ({ field: filter.column, value: filter.value }));
|
|
111279
111686
|
const rows = [];
|
|
@@ -111452,7 +111859,7 @@ function purgeAppRows(appId, models, afterPurge) {
|
|
|
111452
111859
|
};
|
|
111453
111860
|
return acquire(0);
|
|
111454
111861
|
}
|
|
111455
|
-
var AppRowValidationError, AppRowAppNotFoundError, mutationChains, lastCreatedAtMs = 0, LIST_SCAN_WINDOW = 2000, LIST_ROW_CAP = 1e5, MIGRATION_KV_BATCH_SIZE = 1000, PURGE_BATCH_SIZE = 1000;
|
|
111862
|
+
var AppRowValidationError, AppRowAppNotFoundError, mutationChains, lastCreatedAtMs = 0, LIST_SCAN_WINDOW = 2000, LIST_ROW_CAP = 1e5, INDEX_LIST_MAX_KEYS = 20000, INDEX_FETCH_BATCH = 500, MIGRATION_KV_BATCH_SIZE = 1000, PURGE_BATCH_SIZE = 1000;
|
|
111456
111863
|
var init_row_store = __esm(() => {
|
|
111457
111864
|
init_db4();
|
|
111458
111865
|
init_kv_windows();
|
|
@@ -112014,13 +112421,22 @@ async function runAppSync(input) {
|
|
|
112014
112421
|
if (pairs.length === 0) {
|
|
112015
112422
|
return { ok: false, passes: [], issues: [noPairIssue(input)] };
|
|
112016
112423
|
}
|
|
112017
|
-
const passes =
|
|
112018
|
-
|
|
112019
|
-
|
|
112020
|
-
|
|
112424
|
+
const passes = new Array(pairs.length);
|
|
112425
|
+
let next = 0;
|
|
112426
|
+
const worker = async () => {
|
|
112427
|
+
while (next < pairs.length) {
|
|
112428
|
+
const i = next++;
|
|
112429
|
+
passes[i] = await runPass({
|
|
112430
|
+
appId: app.id,
|
|
112431
|
+
...pairs[i],
|
|
112432
|
+
invokedBy: input.invokedBy
|
|
112433
|
+
});
|
|
112434
|
+
}
|
|
112435
|
+
};
|
|
112436
|
+
await Promise.all(Array.from({ length: Math.min(SYNC_PASS_CONCURRENCY, pairs.length) }, worker));
|
|
112021
112437
|
return { ok: passes.every((pass) => pass.error === undefined), passes };
|
|
112022
112438
|
}
|
|
112023
|
-
var MAX_PULL_RECORDS = 500, MAX_PASS_WARNINGS = 20, MAX_TASK_LIMIT = 200, DEFAULT_TASK_LIMIT = 100, MAX_TASK_PROMPT_CHARS = 1000, MAX_ERROR_DETAIL_CHARS = 500, SyncPassError, TransformError, SourceRecordSchema, PullPayloadSchema, TASK_CONFIG_KEYS, RECONCILE_CHUNK_SIZE = 200, inFlight3;
|
|
112439
|
+
var MAX_PULL_RECORDS = 500, MAX_PASS_WARNINGS = 20, MAX_TASK_LIMIT = 200, DEFAULT_TASK_LIMIT = 100, MAX_TASK_PROMPT_CHARS = 1000, MAX_ERROR_DETAIL_CHARS = 500, SyncPassError, TransformError, SourceRecordSchema, PullPayloadSchema, TASK_CONFIG_KEYS, RECONCILE_CHUNK_SIZE = 200, inFlight3, SYNC_PASS_CONCURRENCY = 3;
|
|
112024
112440
|
var init_sync3 = __esm(() => {
|
|
112025
112441
|
init_zod();
|
|
112026
112442
|
init_db4();
|
|
@@ -113421,8 +113837,25 @@ function rejectGuest(req, res) {
|
|
|
113421
113837
|
jsonError(res, "Forbidden", 403);
|
|
113422
113838
|
return true;
|
|
113423
113839
|
}
|
|
113840
|
+
async function refuseAgentTokenWithout(req, res, verb, resource = { kind: "none" }) {
|
|
113841
|
+
const auth = getRequestAuth(req);
|
|
113842
|
+
if (auth?.kind !== "agent")
|
|
113843
|
+
return false;
|
|
113844
|
+
const agent = await getAgentById2(auth.agentId);
|
|
113845
|
+
const decision = can({
|
|
113846
|
+
principal: { kind: "agent", agentId: auth.agentId, isLead: agent?.isLead === true },
|
|
113847
|
+
verb,
|
|
113848
|
+
resource,
|
|
113849
|
+
source: "http"
|
|
113850
|
+
});
|
|
113851
|
+
if (decision.allow)
|
|
113852
|
+
return false;
|
|
113853
|
+
jsonError(res, `Forbidden: ${decision.reason}`, 403);
|
|
113854
|
+
return true;
|
|
113855
|
+
}
|
|
113424
113856
|
var init_request_principal = __esm(() => {
|
|
113425
113857
|
init_db4();
|
|
113858
|
+
init_rbac();
|
|
113426
113859
|
init_request_auth_context();
|
|
113427
113860
|
init_utils2();
|
|
113428
113861
|
});
|
|
@@ -113642,7 +114075,7 @@ function filtersFromQuery(queryParams, model) {
|
|
|
113642
114075
|
}
|
|
113643
114076
|
return { filters, issues };
|
|
113644
114077
|
}
|
|
113645
|
-
function compareValues(left, right, direction
|
|
114078
|
+
function compareValues(left, right, direction) {
|
|
113646
114079
|
if (left === right)
|
|
113647
114080
|
return 0;
|
|
113648
114081
|
if (left === undefined || left === null)
|
|
@@ -113650,9 +114083,7 @@ function compareValues(left, right, direction, dateValues = false) {
|
|
|
113650
114083
|
if (right === undefined || right === null)
|
|
113651
114084
|
return -1;
|
|
113652
114085
|
let result;
|
|
113653
|
-
if (
|
|
113654
|
-
result = Date.parse(left) - Date.parse(right);
|
|
113655
|
-
} else if (typeof left === "number" && typeof right === "number") {
|
|
114086
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
113656
114087
|
result = left - right;
|
|
113657
114088
|
} else if (typeof left === "boolean" && typeof right === "boolean") {
|
|
113658
114089
|
result = Number(left) - Number(right);
|
|
@@ -113664,6 +114095,22 @@ function compareValues(left, right, direction, dateValues = false) {
|
|
|
113664
114095
|
function rowValue(row, column) {
|
|
113665
114096
|
return Object.hasOwn(row, column) ? row[column] : undefined;
|
|
113666
114097
|
}
|
|
114098
|
+
function sortRowsByColumn(rows, column, dir, dateValues) {
|
|
114099
|
+
const keyed = rows.map((row) => {
|
|
114100
|
+
const value = rowValue(row, column);
|
|
114101
|
+
return { row, value, ts: dateValues && typeof value === "string" ? Date.parse(value) : 0 };
|
|
114102
|
+
});
|
|
114103
|
+
keyed.sort((a, b) => {
|
|
114104
|
+
if (dateValues && typeof a.value === "string" && typeof b.value === "string") {
|
|
114105
|
+
if (a.value === b.value)
|
|
114106
|
+
return 0;
|
|
114107
|
+
const result = a.ts - b.ts;
|
|
114108
|
+
return dir === "asc" ? result : -result;
|
|
114109
|
+
}
|
|
114110
|
+
return compareValues(a.value, b.value, dir);
|
|
114111
|
+
});
|
|
114112
|
+
return keyed.map((k) => k.row);
|
|
114113
|
+
}
|
|
113667
114114
|
function rowMatchesFilters(row, filters) {
|
|
113668
114115
|
return filters.every((filter) => rowValue(row, filter.column) === filter.value);
|
|
113669
114116
|
}
|
|
@@ -113672,10 +114119,7 @@ function applyQuery(rows, query, model, params = {}, queryName = "<unnamed>") {
|
|
|
113672
114119
|
let selected = rows.filter((row) => filters.every(([column, value]) => rowValue(row, column) === value));
|
|
113673
114120
|
const sort = query.sort;
|
|
113674
114121
|
if (sort) {
|
|
113675
|
-
selected =
|
|
113676
|
-
const result = compareValues(rowValue(a, sort.column), rowValue(b, sort.column), sort.dir, SORTABLE_SYSTEM_DATE_COLUMNS.has(sort.column) || Object.hasOwn(model.columns, sort.column) && model.columns[sort.column].kind === "date");
|
|
113677
|
-
return result;
|
|
113678
|
-
});
|
|
114122
|
+
selected = sortRowsByColumn(selected, sort.column, sort.dir, SORTABLE_SYSTEM_DATE_COLUMNS.has(sort.column) || Object.hasOwn(model.columns, sort.column) && model.columns[sort.column].kind === "date");
|
|
113679
114123
|
}
|
|
113680
114124
|
return selected.slice(0, query.limit ?? 200);
|
|
113681
114125
|
}
|
|
@@ -113683,7 +114127,7 @@ async function selectAppRows(appId, modelName, model, filters, sortRaw, limit =
|
|
|
113683
114127
|
const jsonFilterIssues = filters.flatMap((filter) => Object.hasOwn(model.columns, filter.column) && model.columns[filter.column].kind === "json" ? [{ path: `filter.${filter.column}`, message: "json columns cannot be filtered" }] : []);
|
|
113684
114128
|
if (jsonFilterIssues.length > 0)
|
|
113685
114129
|
throw new AppRowValidationError(jsonFilterIssues);
|
|
113686
|
-
|
|
114130
|
+
let rows = (await listAppRows(appId, modelName, filters.flatMap((filter) => typeof filter.value === "string" || typeof filter.value === "number" || typeof filter.value === "boolean" ? [{ column: filter.column, value: filter.value }] : []), model.columns)).filter((row) => rowMatchesFilters(row, filters));
|
|
113687
114131
|
if (sortRaw) {
|
|
113688
114132
|
const [column, dir, extra] = sortRaw.split(":");
|
|
113689
114133
|
if (extra !== undefined || !column || dir !== "asc" && dir !== "desc" || !SORTABLE_SYSTEM_DATE_COLUMNS.has(column) && !(systemColumns && Object.hasOwn(SYSTEM_COLUMN_KINDS, column)) && (!Object.hasOwn(model.columns, column) || model.columns[column].hidden === true)) {
|
|
@@ -113694,10 +114138,7 @@ async function selectAppRows(appId, modelName, model, filters, sortRaw, limit =
|
|
|
113694
114138
|
if (model.columns[column]?.kind === "json") {
|
|
113695
114139
|
throw new AppRowValidationError([{ path: "sort", message: "json columns cannot be sorted" }]);
|
|
113696
114140
|
}
|
|
113697
|
-
rows.
|
|
113698
|
-
const result = compareValues(rowValue(a, column), rowValue(b, column), dir, SORTABLE_SYSTEM_DATE_COLUMNS.has(column) || Object.hasOwn(model.columns, column) && model.columns[column].kind === "date");
|
|
113699
|
-
return result;
|
|
113700
|
-
});
|
|
114141
|
+
rows = sortRowsByColumn(rows, column, dir, SORTABLE_SYSTEM_DATE_COLUMNS.has(column) || Object.hasOwn(model.columns, column) && model.columns[column].kind === "date");
|
|
113701
114142
|
}
|
|
113702
114143
|
const total = rows.length;
|
|
113703
114144
|
return { rows: rows.slice(0, limit), total };
|
|
@@ -113724,13 +114165,17 @@ async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
113724
114165
|
invalidDefinition(res, definition.issues);
|
|
113725
114166
|
return true;
|
|
113726
114167
|
}
|
|
113727
|
-
const
|
|
114168
|
+
const app = await createApp({
|
|
114169
|
+
name: parsed.body.name,
|
|
114170
|
+
description: parsed.body.description,
|
|
114171
|
+
definition: definition.definition
|
|
114172
|
+
});
|
|
114173
|
+
const warnings = [
|
|
114174
|
+
...await scriptCompatWarnings(definition.definition),
|
|
114175
|
+
...await appWriteTypesWarnings(app.id)
|
|
114176
|
+
];
|
|
113728
114177
|
createAppRoute.respond(res, 201, {
|
|
113729
|
-
app
|
|
113730
|
-
name: parsed.body.name,
|
|
113731
|
-
description: parsed.body.description,
|
|
113732
|
-
definition: definition.definition
|
|
113733
|
-
}),
|
|
114178
|
+
app,
|
|
113734
114179
|
...warnings.length > 0 ? { warnings } : {}
|
|
113735
114180
|
});
|
|
113736
114181
|
return true;
|
|
@@ -113739,8 +114184,9 @@ async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
113739
114184
|
const parsed = await listAppsRoute.parse(req, res, pathSegments, queryParams);
|
|
113740
114185
|
if (!parsed)
|
|
113741
114186
|
return true;
|
|
114187
|
+
const favoriteScope = (await resolveHttpFavoriteOwner(req, myAgentId))?.scope;
|
|
113742
114188
|
listAppsRoute.respond(res, 200, {
|
|
113743
|
-
apps: await listApps({ q: parsed.query.q, limit: parsed.query.limit })
|
|
114189
|
+
apps: await withFavoriteFlags2(await listApps({ q: parsed.query.q, limit: parsed.query.limit }), { favoriteScope, itemType: "app" })
|
|
113744
114190
|
});
|
|
113745
114191
|
return true;
|
|
113746
114192
|
}
|
|
@@ -114158,7 +114604,10 @@ async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
114158
114604
|
jsonError(res, "app not found", 404);
|
|
114159
114605
|
return true;
|
|
114160
114606
|
}
|
|
114161
|
-
const warnings = writtenDefinition === undefined ? [] :
|
|
114607
|
+
const warnings = writtenDefinition === undefined ? [] : [
|
|
114608
|
+
...await scriptCompatWarnings(writtenDefinition),
|
|
114609
|
+
...await appWriteTypesWarnings(parsed.params.id)
|
|
114610
|
+
];
|
|
114162
114611
|
patchAppRoute.respond(res, 200, {
|
|
114163
114612
|
app,
|
|
114164
114613
|
migration,
|
|
@@ -114251,7 +114700,10 @@ async function handleApps(req, res, pathSegments, queryParams, myAgentId) {
|
|
|
114251
114700
|
jsonError(res, "app not found", 404);
|
|
114252
114701
|
return true;
|
|
114253
114702
|
}
|
|
114254
|
-
const warnings = writtenDefinition === undefined ? [] :
|
|
114703
|
+
const warnings = writtenDefinition === undefined ? [] : [
|
|
114704
|
+
...await scriptCompatWarnings(writtenDefinition),
|
|
114705
|
+
...await appWriteTypesWarnings(parsed.params.id)
|
|
114706
|
+
];
|
|
114255
114707
|
updateAppRoute.respond(res, 200, {
|
|
114256
114708
|
app,
|
|
114257
114709
|
migration,
|
|
@@ -114371,6 +114823,7 @@ var init_apps = __esm(() => {
|
|
|
114371
114823
|
init_definition();
|
|
114372
114824
|
init_row_store();
|
|
114373
114825
|
init_schema_migrate();
|
|
114826
|
+
init_script_types();
|
|
114374
114827
|
init_store2();
|
|
114375
114828
|
init_sync3();
|
|
114376
114829
|
init_user_config();
|
|
@@ -114429,7 +114882,8 @@ var init_apps = __esm(() => {
|
|
|
114429
114882
|
description: string2().optional(),
|
|
114430
114883
|
icon: AppIconSchema.optional(),
|
|
114431
114884
|
createdAt: string2(),
|
|
114432
|
-
updatedAt: string2()
|
|
114885
|
+
updatedAt: string2(),
|
|
114886
|
+
favorite: boolean()
|
|
114433
114887
|
});
|
|
114434
114888
|
AppVersionSchema = object2({
|
|
114435
114889
|
id: string2(),
|
|
@@ -114482,7 +114936,7 @@ var init_apps = __esm(() => {
|
|
|
114482
114936
|
label: string2().optional()
|
|
114483
114937
|
});
|
|
114484
114938
|
AppUserConfigSchema = record2(AppNameSchema, AppUserConfigFieldSchema);
|
|
114485
|
-
compatWarningsSchema = array2(string2()).optional().describe("Advisory quickjs-executor compatibility
|
|
114939
|
+
compatWarningsSchema = array2(string2()).optional().describe("Advisory findings: quickjs-executor compatibility of the app's scripts, and whether the app lost its generated script types to the type budget.");
|
|
114486
114940
|
appWriteResponseSchema = object2({
|
|
114487
114941
|
app: AppRecordSchema,
|
|
114488
114942
|
migration: AppMigrationReportSchema,
|
|
@@ -115150,6 +115604,7 @@ var registerAppPatchTool = (server) => {
|
|
|
115150
115604
|
url: string2().optional(),
|
|
115151
115605
|
app: unknown().optional(),
|
|
115152
115606
|
migration: AppMigrationReportOutputSchema.optional(),
|
|
115607
|
+
warnings: array2(string2()).optional(),
|
|
115153
115608
|
issues: array2(looseObject({ path: string2().optional(), message: string2().optional() })).optional()
|
|
115154
115609
|
})
|
|
115155
115610
|
}, async (input, requestInfo) => {
|
|
@@ -115242,9 +115697,11 @@ var registerAppPatchTool = (server) => {
|
|
|
115242
115697
|
if (!app)
|
|
115243
115698
|
return toolErr(`App ${input.appId} not found.`);
|
|
115244
115699
|
const url = `/apps/${app.id}`;
|
|
115700
|
+
const warnings = await appWriteTypesWarnings(app.id);
|
|
115701
|
+
const extra = warnings.length > 0 ? { warnings } : {};
|
|
115245
115702
|
return toolOk(`App "${app.name}" patched.`, {
|
|
115246
|
-
details: JSON.stringify({ appId: app.id, url, app, migration }, null, 2),
|
|
115247
|
-
data: { appId: app.id, url, app, migration }
|
|
115703
|
+
details: JSON.stringify({ appId: app.id, url, app, migration, ...extra }, null, 2),
|
|
115704
|
+
data: { appId: app.id, url, app, migration, ...extra }
|
|
115248
115705
|
});
|
|
115249
115706
|
});
|
|
115250
115707
|
});
|
|
@@ -115253,6 +115710,7 @@ var init_app_patch = __esm(() => {
|
|
|
115253
115710
|
init_zod();
|
|
115254
115711
|
init_definition();
|
|
115255
115712
|
init_schema_migrate();
|
|
115713
|
+
init_script_types();
|
|
115256
115714
|
init_store2();
|
|
115257
115715
|
init_version4();
|
|
115258
115716
|
init_db4();
|
|
@@ -115600,6 +116058,7 @@ var registerAppUpsertTool = (server) => {
|
|
|
115600
116058
|
appId: string2().optional(),
|
|
115601
116059
|
url: string2().optional(),
|
|
115602
116060
|
migration: AppMigrationReportOutputSchema.optional(),
|
|
116061
|
+
warnings: array2(string2()).optional(),
|
|
115603
116062
|
issues: array2(looseObject({ path: string2().optional(), message: string2().optional() })).optional()
|
|
115604
116063
|
})
|
|
115605
116064
|
}, async (input, requestInfo) => {
|
|
@@ -115688,9 +116147,11 @@ var registerAppUpsertTool = (server) => {
|
|
|
115688
116147
|
if (!app)
|
|
115689
116148
|
return toolErr("Failed to save app.");
|
|
115690
116149
|
const url = `/apps/${app.id}`;
|
|
116150
|
+
const warnings = await appWriteTypesWarnings(app.id);
|
|
115691
116151
|
return toolOk(`App "${app.name}" saved.`, {
|
|
115692
|
-
details: `App: ${url}`,
|
|
115693
|
-
|
|
116152
|
+
details: [`App: ${url}`, ...warnings].join(`
|
|
116153
|
+
`),
|
|
116154
|
+
data: { appId: app.id, url, migration, ...warnings.length > 0 ? { warnings } : {} }
|
|
115694
116155
|
});
|
|
115695
116156
|
});
|
|
115696
116157
|
}
|
|
@@ -115716,9 +116177,11 @@ var registerAppUpsertTool = (server) => {
|
|
|
115716
116177
|
if (!app)
|
|
115717
116178
|
return toolErr("Failed to save app.");
|
|
115718
116179
|
const url = `/apps/${app.id}`;
|
|
116180
|
+
const warnings = await appWriteTypesWarnings(app.id);
|
|
115719
116181
|
return toolOk(`App "${app.name}" saved.`, {
|
|
115720
|
-
details: `App: ${url}`,
|
|
115721
|
-
|
|
116182
|
+
details: [`App: ${url}`, ...warnings].join(`
|
|
116183
|
+
`),
|
|
116184
|
+
data: { appId: app.id, url, ...warnings.length > 0 ? { warnings } : {} }
|
|
115722
116185
|
});
|
|
115723
116186
|
});
|
|
115724
116187
|
};
|
|
@@ -115726,6 +116189,7 @@ var init_app_upsert = __esm(() => {
|
|
|
115726
116189
|
init_zod();
|
|
115727
116190
|
init_definition();
|
|
115728
116191
|
init_schema_migrate();
|
|
116192
|
+
init_script_types();
|
|
115729
116193
|
init_store2();
|
|
115730
116194
|
init_version4();
|
|
115731
116195
|
init_db4();
|
|
@@ -117841,7 +118305,7 @@ async function getTaskDetailsHandler(ctx, { taskId, include }) {
|
|
|
117841
118305
|
const data = origin === "script-sdk" || origin === "extension" ? full : fitToBudget(full, new Set(include ?? []));
|
|
117842
118306
|
const reducedParts = data.fitted?.include ?? [];
|
|
117843
118307
|
const fitNote = reducedParts.length ? ` Fitted to the size budget; include ${JSON.stringify(reducedParts)} for the rest.` : "";
|
|
117844
|
-
return toolOk(`Task "${taskId}" (${task.status}) details retrieved.${fitNote}`, {
|
|
118308
|
+
return toolOk(`Task "${taskId}" (${task.status}${task.statusKind ? `, ${task.statusKind}` : ""}) details retrieved.${fitNote}`, {
|
|
117845
118309
|
details: JSON.stringify(data),
|
|
117846
118310
|
data
|
|
117847
118311
|
});
|
|
@@ -117900,6 +118364,7 @@ var init_get_task_details = __esm(() => {
|
|
|
117900
118364
|
lastUpdatedAt: string2().optional(),
|
|
117901
118365
|
finishedAt: string2().optional(),
|
|
117902
118366
|
notifiedAt: string2().optional(),
|
|
118367
|
+
statusKind: string2().optional(),
|
|
117903
118368
|
failureReason: string2().optional(),
|
|
117904
118369
|
output: string2().optional(),
|
|
117905
118370
|
progress: string2().optional(),
|
|
@@ -118065,7 +118530,7 @@ async function cancelTaskHandler(ctx, { taskId, reason }) {
|
|
|
118065
118530
|
message: "Only the lead or task creator can cancel tasks."
|
|
118066
118531
|
};
|
|
118067
118532
|
}
|
|
118068
|
-
const cancelled = await cancelTask2(taskId, reason);
|
|
118533
|
+
const cancelled = await cancelTask2(taskId, reason, { statusKind: "agent" });
|
|
118069
118534
|
if (!cancelled) {
|
|
118070
118535
|
return {
|
|
118071
118536
|
success: false,
|
|
@@ -118091,7 +118556,7 @@ async function cancelTaskHandler(ctx, { taskId, reason }) {
|
|
|
118091
118556
|
const ownershipError = assertOwnsTask(ctx, existingTask, "task.cancel.own");
|
|
118092
118557
|
if (ownershipError)
|
|
118093
118558
|
return ownershipError;
|
|
118094
|
-
const cancelled = await cancelTask2(taskId, reason);
|
|
118559
|
+
const cancelled = await cancelTask2(taskId, reason, { statusKind: "user" });
|
|
118095
118560
|
if (!cancelled) {
|
|
118096
118561
|
return {
|
|
118097
118562
|
success: false,
|
|
@@ -123698,8 +124163,11 @@ async function admitExternalWait(event, source, rawMatch) {
|
|
|
123698
124163
|
}
|
|
123699
124164
|
if (adapter.confirm) {
|
|
123700
124165
|
try {
|
|
123701
|
-
|
|
123702
|
-
|
|
124166
|
+
const already = toConfirmResult(await adapter.confirm(event, match));
|
|
124167
|
+
if (already.happened) {
|
|
124168
|
+
return {
|
|
124169
|
+
error: `${target} already happened${already.detail ? ` (${already.detail})` : ""}; read its result instead of deferring.`
|
|
124170
|
+
};
|
|
123703
124171
|
}
|
|
123704
124172
|
} catch (error) {
|
|
123705
124173
|
return {
|
|
@@ -123718,63 +124186,17 @@ Checks:
|
|
|
123718
124186
|
${checks.map((c) => `- ${c}`).join(`
|
|
123719
124187
|
`)}`;
|
|
123720
124188
|
}
|
|
123721
|
-
function partsInTz(date, tz) {
|
|
123722
|
-
const fmt = new Intl.DateTimeFormat("en-US", {
|
|
123723
|
-
timeZone: tz,
|
|
123724
|
-
year: "numeric",
|
|
123725
|
-
month: "2-digit",
|
|
123726
|
-
day: "2-digit",
|
|
123727
|
-
hour: "2-digit",
|
|
123728
|
-
minute: "2-digit",
|
|
123729
|
-
second: "2-digit",
|
|
123730
|
-
hour12: false
|
|
123731
|
-
});
|
|
123732
|
-
const parts = Object.fromEntries(fmt.formatToParts(date).map((p) => [p.type, p.value]));
|
|
123733
|
-
const hour = parts.hour === "24" ? "00" : parts.hour;
|
|
123734
|
-
return {
|
|
123735
|
-
year: parts.year,
|
|
123736
|
-
month: parts.month,
|
|
123737
|
-
day: parts.day,
|
|
123738
|
-
hour,
|
|
123739
|
-
minute: parts.minute,
|
|
123740
|
-
second: parts.second
|
|
123741
|
-
};
|
|
123742
|
-
}
|
|
123743
|
-
function formatDeferralDateTime(target, now, tz) {
|
|
123744
|
-
let zone = tz;
|
|
123745
|
-
try {
|
|
123746
|
-
Intl.DateTimeFormat("en-US", { timeZone: zone });
|
|
123747
|
-
} catch {
|
|
123748
|
-
zone = "UTC";
|
|
123749
|
-
}
|
|
123750
|
-
const t = partsInTz(target, zone);
|
|
123751
|
-
const time = `${t.hour}:${t.minute}`;
|
|
123752
|
-
const n = partsInTz(now, zone);
|
|
123753
|
-
if (t.year === n.year && t.month === n.month && t.day === n.day)
|
|
123754
|
-
return { date: "today", time };
|
|
123755
|
-
const tm = partsInTz(new Date(now.getTime() + 86400000), zone);
|
|
123756
|
-
if (t.year === tm.year && t.month === tm.month && t.day === tm.day) {
|
|
123757
|
-
return { date: "tomorrow", time };
|
|
123758
|
-
}
|
|
123759
|
-
return { date: `${t.month}-${t.day}`, time };
|
|
123760
|
-
}
|
|
123761
|
-
async function resolveRequesterTimezone(requestedByUserId) {
|
|
123762
|
-
if (requestedByUserId) {
|
|
123763
|
-
const user = await getUserById2(requestedByUserId);
|
|
123764
|
-
if (user?.timezone)
|
|
123765
|
-
return { tz: user.timezone, isFallback: false };
|
|
123766
|
-
}
|
|
123767
|
-
return { tz: "UTC", isFallback: true };
|
|
123768
|
-
}
|
|
123769
124189
|
function joinNames(names) {
|
|
123770
124190
|
if (names.length < 2)
|
|
123771
124191
|
return names[0] ?? "";
|
|
123772
124192
|
return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
123773
124193
|
}
|
|
123774
|
-
function renderWaitingOn(agentNames, watchedCount) {
|
|
124194
|
+
function renderWaitingOn(agentNames, watchedCount, titles = []) {
|
|
123775
124195
|
const named = joinNames([...new Set(agentNames.filter((name) => name.trim()))]);
|
|
123776
124196
|
if (named)
|
|
123777
124197
|
return named;
|
|
124198
|
+
if (watchedCount === 1 && titles[0]?.trim())
|
|
124199
|
+
return titles[0].trim();
|
|
123778
124200
|
return `${watchedCount} task${watchedCount === 1 ? "" : "s"}`;
|
|
123779
124201
|
}
|
|
123780
124202
|
function renderWhen(nextRunAt, tz, isFallbackTz) {
|
|
@@ -123898,6 +124320,7 @@ var isExternalEvent = (event) => EXTERNAL_EVENT_NAMES.includes(event), DeferAbor
|
|
|
123898
124320
|
}
|
|
123899
124321
|
}
|
|
123900
124322
|
const watchedAgentNames = [];
|
|
124323
|
+
const watchedTitles = [];
|
|
123901
124324
|
for (const watchedId of watchedTaskIds) {
|
|
123902
124325
|
if (watchedId === taskId)
|
|
123903
124326
|
throw new DeferAbortedError("Cannot wake on the task being deferred.");
|
|
@@ -123909,6 +124332,8 @@ var isExternalEvent = (event) => EXTERNAL_EVENT_NAMES.includes(event), DeferAbor
|
|
|
123909
124332
|
const watchedAgent = watched.agentId ? await getAgentById2(watched.agentId) : null;
|
|
123910
124333
|
if (watchedAgent?.name)
|
|
123911
124334
|
watchedAgentNames.push(watchedAgent.name);
|
|
124335
|
+
if (watched.title)
|
|
124336
|
+
watchedTitles.push(watched.title);
|
|
123912
124337
|
}
|
|
123913
124338
|
const schedule = await createScheduledTask2({
|
|
123914
124339
|
name: `deferred-${taskId.slice(0, 8)}-${Date.now()}-${crypto.randomUUID()}`,
|
|
@@ -123962,10 +124387,12 @@ var isExternalEvent = (event) => EXTERNAL_EVENT_NAMES.includes(event), DeferAbor
|
|
|
123962
124387
|
const deferralDetails = `${summary}
|
|
123963
124388
|
|
|
123964
124389
|
Deferred until ${nextRunAt} (schedule ${schedule.id}). Pending: ${note}${checksBlock}`;
|
|
123965
|
-
const terminalOutput = task.outputSchema ? output : renderHumanFacingDeferral(nextRunAt, requesterTz, isFallbackTz, admitted && eventWait ? describeEventWait(admitted.adapter.source, eventWait.event, admitted.match) : wakeOn ? renderWaitingOn(watchedAgentNames, watchedTaskIds.length) : undefined);
|
|
124390
|
+
const terminalOutput = task.outputSchema ? output : renderHumanFacingDeferral(nextRunAt, requesterTz, isFallbackTz, admitted && eventWait ? describeEventWait(admitted.adapter.source, eventWait.event, admitted.match) : wakeOn ? renderWaitingOn(watchedAgentNames, watchedTaskIds.length, watchedTitles) : undefined);
|
|
123966
124391
|
const completed = await completeTask2(taskId, terminalOutput, {
|
|
123967
124392
|
addTags: ["deferred"],
|
|
123968
|
-
deferredAt: new Date().toISOString()
|
|
124393
|
+
deferredAt: new Date().toISOString(),
|
|
124394
|
+
deferredUntil: nextRunAt,
|
|
124395
|
+
statusKind: "deferred"
|
|
123969
124396
|
});
|
|
123970
124397
|
if (!completed) {
|
|
123971
124398
|
throw new DeferAbortedError(`Task ${taskId} reached a terminal state before this deferral committed.`);
|
|
@@ -124024,6 +124451,7 @@ var init_defer_task = __esm(() => {
|
|
|
124024
124451
|
init_zod();
|
|
124025
124452
|
init_audit_user();
|
|
124026
124453
|
init_db4();
|
|
124454
|
+
init_requester_timezone();
|
|
124027
124455
|
init_event_waits();
|
|
124028
124456
|
init_deferred_task_waits();
|
|
124029
124457
|
init_task_terminal_effects();
|
|
@@ -124031,6 +124459,7 @@ var init_defer_task = __esm(() => {
|
|
|
124031
124459
|
init_task_tool_ctx();
|
|
124032
124460
|
init_utils();
|
|
124033
124461
|
init_types5();
|
|
124462
|
+
init_deferral_time();
|
|
124034
124463
|
init_business_use();
|
|
124035
124464
|
init_request_auth_context();
|
|
124036
124465
|
DeferAbortedError = class DeferAbortedError extends Error {
|
|
@@ -124291,7 +124720,7 @@ function isRecord(value) {
|
|
|
124291
124720
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
124292
124721
|
}
|
|
124293
124722
|
function apiBaseUrl() {
|
|
124294
|
-
return
|
|
124723
|
+
return getScriptApiBaseUrl();
|
|
124295
124724
|
}
|
|
124296
124725
|
function renderIssue(issue) {
|
|
124297
124726
|
if (typeof issue === "string")
|
|
@@ -124878,7 +125307,7 @@ function renderTaskSummaries(tasks) {
|
|
|
124878
125307
|
const rows = tasks.map((task) => {
|
|
124879
125308
|
const cells = [
|
|
124880
125309
|
task.id,
|
|
124881
|
-
task.status,
|
|
125310
|
+
task.statusKind ? `${task.status} (${task.statusKind})` : task.status,
|
|
124882
125311
|
task.priority,
|
|
124883
125312
|
task.agentId,
|
|
124884
125313
|
task.taskPreview ?? task.task
|
|
@@ -124890,6 +125319,7 @@ function renderTaskSummaries(tasks) {
|
|
|
124890
125319
|
}
|
|
124891
125320
|
async function getTasksHandler(ctx, {
|
|
124892
125321
|
status,
|
|
125322
|
+
statusKind,
|
|
124893
125323
|
mineOnly,
|
|
124894
125324
|
unassigned,
|
|
124895
125325
|
offeredToMe,
|
|
@@ -124908,6 +125338,7 @@ async function getTasksHandler(ctx, {
|
|
|
124908
125338
|
const agentId = ctx.kind === "owner" ? ctx.agentId : undefined;
|
|
124909
125339
|
const taskFilters = {
|
|
124910
125340
|
status,
|
|
125341
|
+
statusKind,
|
|
124911
125342
|
agentId: ctx.kind === "owner" && mineOnly ? agentId ?? undefined : undefined,
|
|
124912
125343
|
unassigned: ctx.kind === "owner" ? unassigned : undefined,
|
|
124913
125344
|
offeredTo: ctx.kind === "owner" && offeredToMe ? agentId ?? undefined : undefined,
|
|
@@ -124930,6 +125361,7 @@ async function getTasksHandler(ctx, {
|
|
|
124930
125361
|
agentId: t.agentId,
|
|
124931
125362
|
...includeFull ? { task: t.task } : { taskPreview: t.task },
|
|
124932
125363
|
status: t.status,
|
|
125364
|
+
statusKind: t.statusKind,
|
|
124933
125365
|
taskType: t.taskType,
|
|
124934
125366
|
tags: t.tags,
|
|
124935
125367
|
priority: t.priority,
|
|
@@ -124943,6 +125375,8 @@ async function getTasksHandler(ctx, {
|
|
|
124943
125375
|
const filters = [];
|
|
124944
125376
|
if (status)
|
|
124945
125377
|
filters.push(`status='${status}'`);
|
|
125378
|
+
if (statusKind)
|
|
125379
|
+
filters.push(`statusKind='${statusKind}'`);
|
|
124946
125380
|
if (ctx.kind === "owner" && mineOnly)
|
|
124947
125381
|
filters.push("mine only");
|
|
124948
125382
|
if (ctx.kind === "owner" && unassigned)
|
|
@@ -124997,6 +125431,7 @@ var init_get_tasks = __esm(() => {
|
|
|
124997
125431
|
task: string2().optional(),
|
|
124998
125432
|
taskPreview: string2().optional(),
|
|
124999
125433
|
status: AgentTaskStatusSchema.optional(),
|
|
125434
|
+
statusKind: string2().optional(),
|
|
125000
125435
|
taskType: string2().optional(),
|
|
125001
125436
|
tags: array2(string2()).optional(),
|
|
125002
125437
|
priority: number2().optional(),
|
|
@@ -125009,6 +125444,7 @@ var init_get_tasks = __esm(() => {
|
|
|
125009
125444
|
});
|
|
125010
125445
|
getTasksInputSchema = object2({
|
|
125011
125446
|
status: AgentTaskStatusSchema.optional().describe("Filter by task status (unassigned, offered, pending, in_progress, completed, failed)."),
|
|
125447
|
+
statusKind: TaskStatusKindSchema.optional().describe("Filter by why the task ended. Pair with status, e.g. status 'failed' + statusKind 'error' (crash, rate limit, exit code) vs 'agent' (the agent chose to fail)."),
|
|
125012
125448
|
mineOnly: boolean().optional().describe("Only return tasks assigned to you."),
|
|
125013
125449
|
unassigned: boolean().optional().describe("Only return unassigned tasks in the pool."),
|
|
125014
125450
|
offeredToMe: boolean().optional().describe("Only return tasks offered to you (awaiting accept/reject)."),
|
|
@@ -125220,7 +125656,11 @@ function requiresLeadToWrite(namespace) {
|
|
|
125220
125656
|
return LEAD_ONLY_FAMILIES.has(namespace.split(":", 1)[0] ?? "");
|
|
125221
125657
|
}
|
|
125222
125658
|
function reservedNamespaceError(namespace) {
|
|
125223
|
-
|
|
125659
|
+
for (const [family, error] of RESERVED_FAMILIES) {
|
|
125660
|
+
if (namespace === family || namespace.startsWith(`${family}:`))
|
|
125661
|
+
return error;
|
|
125662
|
+
}
|
|
125663
|
+
return null;
|
|
125224
125664
|
}
|
|
125225
125665
|
function privateNamespaceError(namespace) {
|
|
125226
125666
|
return PRIVATE_FAMILIES.has(namespace.split(":", 1)[0] ?? "") ? reservedNamespaceError(namespace) : null;
|
|
@@ -125228,9 +125668,14 @@ function privateNamespaceError(namespace) {
|
|
|
125228
125668
|
function reservedRoomKeyError(key) {
|
|
125229
125669
|
return key.startsWith("_room/") ? "room snapshot keys are reserved; use the room endpoints" : null;
|
|
125230
125670
|
}
|
|
125671
|
+
function scrubReservedRead(namespace, value) {
|
|
125672
|
+
return namespace.split(":", 1)[0] === "durable" ? scrubObject(value) : value;
|
|
125673
|
+
}
|
|
125231
125674
|
var RESERVED_FAMILIES, PRIVATE_FAMILIES, LEAD_ONLY_FAMILIES;
|
|
125232
125675
|
var init_kv_reserved_namespaces = __esm(() => {
|
|
125676
|
+
init_secret_scrubber();
|
|
125233
125677
|
RESERVED_FAMILIES = new Map([
|
|
125678
|
+
["durable", "namespace holds durable object state; it is written only by object calls"],
|
|
125234
125679
|
["apps", "namespace is reserved for swarm apps; use the app row endpoints"],
|
|
125235
125680
|
["comb", "namespace is reserved for Comb; use POST /api/comb/review-batches"],
|
|
125236
125681
|
[
|
|
@@ -125245,6 +125690,14 @@ var init_kv_reserved_namespaces = __esm(() => {
|
|
|
125245
125690
|
[
|
|
125246
125691
|
"session-labels",
|
|
125247
125692
|
"namespace is reserved for session source labels; GET /api/session-tree returns them"
|
|
125693
|
+
],
|
|
125694
|
+
[
|
|
125695
|
+
"integration:user-enrichment",
|
|
125696
|
+
"namespace is reserved for integration profile enrichment; the API writes it from the provider"
|
|
125697
|
+
],
|
|
125698
|
+
[
|
|
125699
|
+
"integrations:kapso",
|
|
125700
|
+
"namespace is reserved for Kapso routing; use register-kapso-number or unregister-kapso-number"
|
|
125248
125701
|
]
|
|
125249
125702
|
]);
|
|
125250
125703
|
PRIVATE_FAMILIES = new Set(["session-labels", "slack-thread-buffer"]);
|
|
@@ -125472,6 +125925,8 @@ var kvEntryOutputSchema, kvViewOutputSchema, registerKvGetTool = (server) => {
|
|
|
125472
125925
|
});
|
|
125473
125926
|
}
|
|
125474
125927
|
const entry = await getKv2(resolved.namespace, key);
|
|
125928
|
+
if (entry)
|
|
125929
|
+
entry.value = scrubReservedRead(resolved.namespace, entry.value);
|
|
125475
125930
|
if (entry && hasKvViewArgs({ path, offset, limit })) {
|
|
125476
125931
|
return boundedView(entry, requestInfo.agentId, { path, offset, limit });
|
|
125477
125932
|
}
|
|
@@ -125488,6 +125943,7 @@ var kvEntryOutputSchema, kvViewOutputSchema, registerKvGetTool = (server) => {
|
|
|
125488
125943
|
var init_kv_get = __esm(() => {
|
|
125489
125944
|
init_zod();
|
|
125490
125945
|
init_db4();
|
|
125946
|
+
init_kv_reserved_namespaces();
|
|
125491
125947
|
init_kv_view();
|
|
125492
125948
|
init_utils();
|
|
125493
125949
|
init_types5();
|
|
@@ -125615,11 +126071,14 @@ var MAX_KV_LIST_LIMIT = 1000, kvEntryOutputSchema3, registerKvListTool = (server
|
|
|
125615
126071
|
}
|
|
125616
126072
|
const effectiveLimit = Math.min(limit ?? 100, MAX_KV_LIST_LIMIT);
|
|
125617
126073
|
const effectivePrefix = prefix && prefix.length > 0 ? prefix : undefined;
|
|
125618
|
-
const entries = await listKv2(resolved.namespace, {
|
|
126074
|
+
const entries = (await listKv2(resolved.namespace, {
|
|
125619
126075
|
prefix: effectivePrefix,
|
|
125620
126076
|
limit: effectiveLimit,
|
|
125621
126077
|
offset: offset ?? 0
|
|
125622
|
-
})
|
|
126078
|
+
})).map((entry) => ({
|
|
126079
|
+
...entry,
|
|
126080
|
+
value: scrubReservedRead(resolved.namespace, entry.value)
|
|
126081
|
+
}));
|
|
125623
126082
|
const total = await countKv2(resolved.namespace, { prefix: effectivePrefix });
|
|
125624
126083
|
return toolOk(entries.length === 0 ? `No entries in "${resolved.namespace}".` : `Found ${entries.length} of ${total} entries in "${resolved.namespace}".`, {
|
|
125625
126084
|
details: renderKvEntries(entries),
|
|
@@ -125635,6 +126094,7 @@ var MAX_KV_LIST_LIMIT = 1000, kvEntryOutputSchema3, registerKvListTool = (server
|
|
|
125635
126094
|
var init_kv_list = __esm(() => {
|
|
125636
126095
|
init_zod();
|
|
125637
126096
|
init_db4();
|
|
126097
|
+
init_kv_reserved_namespaces();
|
|
125638
126098
|
init_utils();
|
|
125639
126099
|
init_types5();
|
|
125640
126100
|
init_kv_read_auth();
|
|
@@ -125650,8 +126110,14 @@ var init_kv_list = __esm(() => {
|
|
|
125650
126110
|
});
|
|
125651
126111
|
});
|
|
125652
126112
|
|
|
126113
|
+
// src/kv-limits.ts
|
|
126114
|
+
var MAX_KV_BODY_BYTES;
|
|
126115
|
+
var init_kv_limits = __esm(() => {
|
|
126116
|
+
MAX_KV_BODY_BYTES = 2 * 1024 * 1024;
|
|
126117
|
+
});
|
|
126118
|
+
|
|
125653
126119
|
// src/tools/kv/kv-set.ts
|
|
125654
|
-
var
|
|
126120
|
+
var kvEntryOutputSchema4, registerKvSetTool = (server) => {
|
|
125655
126121
|
createToolRegistrar(server)("kv-set", {
|
|
125656
126122
|
title: "KV Set",
|
|
125657
126123
|
description: "Write a key in the swarm KV store. Each replacement is atomic but unconditional: there is no compare-and-swap, so concurrent read-modify-write callers can lose updates. Namespace defaults to your current context. Use `expiresInSec` for opt-in TTL (default: never expires). 2 MiB body cap.",
|
|
@@ -125741,11 +126207,11 @@ var MAX_KV_BODY_BYTES, kvEntryOutputSchema4, registerKvSetTool = (server) => {
|
|
|
125741
126207
|
var init_kv_set = __esm(() => {
|
|
125742
126208
|
init_zod();
|
|
125743
126209
|
init_db4();
|
|
126210
|
+
init_kv_limits();
|
|
125744
126211
|
init_utils();
|
|
125745
126212
|
init_types5();
|
|
125746
126213
|
init_kv_write_auth();
|
|
125747
126214
|
init_resolve_namespace();
|
|
125748
|
-
MAX_KV_BODY_BYTES = 2 * 1024 * 1024;
|
|
125749
126215
|
kvEntryOutputSchema4 = looseObject({
|
|
125750
126216
|
namespace: string2().optional(),
|
|
125751
126217
|
key: string2().optional(),
|
|
@@ -125899,6 +126365,7 @@ var userOutputShape, IdentityEntry, InputSchema, registerManageUserTool = (serve
|
|
|
125899
126365
|
timezone: input.timezone,
|
|
125900
126366
|
dailyBudgetUsd: input.dailyBudgetUsd ?? undefined,
|
|
125901
126367
|
status: input.status,
|
|
126368
|
+
avatar: input.avatar,
|
|
125902
126369
|
metadata
|
|
125903
126370
|
});
|
|
125904
126371
|
for (const ident of input.identities ?? []) {
|
|
@@ -125941,6 +126408,7 @@ var userOutputShape, IdentityEntry, InputSchema, registerManageUserTool = (serve
|
|
|
125941
126408
|
timezone: input.timezone,
|
|
125942
126409
|
dailyBudgetUsd: input.dailyBudgetUsd,
|
|
125943
126410
|
status: input.status,
|
|
126411
|
+
avatar: input.avatar,
|
|
125944
126412
|
metadata
|
|
125945
126413
|
});
|
|
125946
126414
|
if (!updated)
|
|
@@ -126004,6 +126472,7 @@ var init_manage_user = __esm(() => {
|
|
|
126004
126472
|
init_users();
|
|
126005
126473
|
init_rbac();
|
|
126006
126474
|
init_utils();
|
|
126475
|
+
init_types5();
|
|
126007
126476
|
userOutputShape = looseObject({
|
|
126008
126477
|
id: string2().optional(),
|
|
126009
126478
|
name: string2().optional(),
|
|
@@ -126016,6 +126485,7 @@ var init_manage_user = __esm(() => {
|
|
|
126016
126485
|
metadata: record2(string2(), unknown()).optional(),
|
|
126017
126486
|
dailyBudgetUsd: number2().nullable().optional(),
|
|
126018
126487
|
status: _enum2(["invited", "active", "suspended"]).optional(),
|
|
126488
|
+
avatar: looseObject({}).nullable().optional(),
|
|
126019
126489
|
createdAt: string2().optional(),
|
|
126020
126490
|
lastUpdatedAt: string2().optional()
|
|
126021
126491
|
});
|
|
@@ -126037,6 +126507,7 @@ var init_manage_user = __esm(() => {
|
|
|
126037
126507
|
dailyBudgetUsd: number2().nullable().optional().describe("Daily budget in USD (null clears the cap)"),
|
|
126038
126508
|
status: _enum2(["invited", "active", "suspended"]).optional().describe("User status — invited / active / suspended"),
|
|
126039
126509
|
metadata: record2(string2(), unknown()).nullable().optional().describe("Free-form JSON metadata (null clears the field)"),
|
|
126510
|
+
avatar: UserAvatarSchema.nullable().optional().describe("Custom avatar, one of: { type: 'lucide', icon: '<kebab-case-lucide-name>', color?: '#RRGGBB' }; { type: 'url', url: 'https://…' } (https image, no credentials); { type: 'agent-fs', path: '/users/<id>/avatar.png', orgId?, driveId? } (an image in agent-fs; pass both IDs or neither for the swarm drive). Pass null to reset to initials."),
|
|
126040
126511
|
comms: object2({
|
|
126041
126512
|
tone: string2().nullable().optional(),
|
|
126042
126513
|
language: string2().nullable().optional(),
|
|
@@ -129188,21 +129659,48 @@ var init_repo_merge_policy = __esm(() => {
|
|
|
129188
129659
|
});
|
|
129189
129660
|
|
|
129190
129661
|
// src/be/repo-checked-update.ts
|
|
129191
|
-
|
|
129662
|
+
function changesExecConfig(existing, updates) {
|
|
129663
|
+
return updates.url !== undefined && updates.url !== existing.url || updates.clonePath !== undefined && updates.clonePath !== existing.clonePath || updates.hooks !== undefined && updates.hooks?.enabled === true !== (existing.hooks?.enabled === true);
|
|
129664
|
+
}
|
|
129665
|
+
async function execConfigRefusal(auth, source) {
|
|
129666
|
+
if (auth?.page) {
|
|
129667
|
+
return "Forbidden: a page session cannot change a repo's url, clonePath or hooks.";
|
|
129668
|
+
}
|
|
129669
|
+
if (auth?.kind !== "agent")
|
|
129670
|
+
return null;
|
|
129671
|
+
const agent = await getAgentById2(auth.agentId);
|
|
129672
|
+
const decision = can({
|
|
129673
|
+
principal: { kind: "agent", agentId: auth.agentId, isLead: agent?.isLead === true },
|
|
129674
|
+
verb: "repo.exec-config.write",
|
|
129675
|
+
resource: { kind: "none" },
|
|
129676
|
+
source
|
|
129677
|
+
});
|
|
129678
|
+
if (decision.allow)
|
|
129679
|
+
return null;
|
|
129680
|
+
return `Forbidden: ${decision.reason}. Only the lead, the operator or a user can change a repo's url, clonePath or hooks.`;
|
|
129681
|
+
}
|
|
129682
|
+
async function updateSwarmRepoChecked(id, updates, authorize, authorizeExecConfig) {
|
|
129192
129683
|
return await getDbClient2().transaction(async () => {
|
|
129193
|
-
|
|
129684
|
+
const touchesExecConfig = updates.url !== undefined || updates.clonePath !== undefined || updates.hooks !== undefined;
|
|
129685
|
+
if (updates.guidelines !== undefined || touchesExecConfig) {
|
|
129194
129686
|
const existing = await getSwarmRepoById2(id);
|
|
129195
129687
|
if (existing && changesMergePolicy(existing.guidelines, updates.guidelines)) {
|
|
129196
129688
|
const refusal = await authorize(existing);
|
|
129197
129689
|
if (refusal !== null)
|
|
129198
129690
|
return { kind: "refused", refusal };
|
|
129199
129691
|
}
|
|
129692
|
+
if (existing && changesExecConfig(existing, updates)) {
|
|
129693
|
+
const refusal = await authorizeExecConfig(existing);
|
|
129694
|
+
if (refusal !== null)
|
|
129695
|
+
return { kind: "refused", refusal };
|
|
129696
|
+
}
|
|
129200
129697
|
}
|
|
129201
129698
|
const repo = await updateSwarmRepo2(id, updates);
|
|
129202
129699
|
return repo ? { kind: "updated", repo } : { kind: "not-found" };
|
|
129203
129700
|
});
|
|
129204
129701
|
}
|
|
129205
129702
|
var init_repo_checked_update = __esm(() => {
|
|
129703
|
+
init_rbac();
|
|
129206
129704
|
init_db4();
|
|
129207
129705
|
init_repo_merge_policy();
|
|
129208
129706
|
});
|
|
@@ -129211,14 +129709,14 @@ var init_repo_checked_update = __esm(() => {
|
|
|
129211
129709
|
var swarmRepoOutputShape2, registerUpdateRepoTool = (server) => {
|
|
129212
129710
|
createToolRegistrar(server)("update-repo", {
|
|
129213
129711
|
title: "Update Repo",
|
|
129214
|
-
description: "Update a repo's configuration including guidelines (PR checks, merge policy, review guidance). The lead uses this to set guidelines after asking the user. Pass null for guidelines to clear them. Only the lead can change allowMerge or mergePolicy: resend their current values to edit other guidelines.",
|
|
129712
|
+
description: "Update a repo's configuration including guidelines (PR checks, merge policy, review guidance). The lead uses this to set guidelines after asking the user. Pass null for guidelines to clear them. Only the lead can change allowMerge or mergePolicy: resend their current values to edit other guidelines. An agent session token also needs the lead role to change url, clonePath or hooks.",
|
|
129215
129713
|
annotations: { readOnlyHint: false },
|
|
129216
129714
|
inputSchema: object2({
|
|
129217
129715
|
id: string2().uuid().describe("The repo ID to update."),
|
|
129218
|
-
url: string2().optional().describe("New repo URL."),
|
|
129716
|
+
url: string2().refine((value) => !value.startsWith("-"), 'url must not start with "-"').optional().describe("New repo URL."),
|
|
129219
129717
|
name: string2().optional().describe("New repo name."),
|
|
129220
|
-
clonePath: string2().optional().describe("New clone path."),
|
|
129221
|
-
defaultBranch: string2().optional().describe("New default branch."),
|
|
129718
|
+
clonePath: string2().refine((value) => !value.startsWith("-"), 'clonePath must not start with "-"').optional().describe("New clone path."),
|
|
129719
|
+
defaultBranch: string2().refine((value) => !value.startsWith("-"), 'defaultBranch must not start with "-"').optional().describe("New default branch."),
|
|
129222
129720
|
autoClone: boolean().optional().describe("Whether to auto-clone."),
|
|
129223
129721
|
hooks: RepoHooksSchema.nullable().optional().describe("Repository hook install config. Best-effort worker hook installation is enabled by default for new repos. Disable it with { enabled: false } (or null), or turn it back on with { enabled: true }."),
|
|
129224
129722
|
guidelines: RepoGuidelinesInputSchema.nullable().optional().describe("Repository guidelines: prChecks (commands before PR), mergeChecks (conditions before merge), allowMerge (default false), review (guidance for reviewers), mergePolicy (per-repo merge policy record: autoMerge, agentsMayMerge, notify). Pass null to clear.")
|
|
@@ -129239,7 +129737,7 @@ var swarmRepoOutputShape2, registerUpdateRepoTool = (server) => {
|
|
|
129239
129737
|
return null;
|
|
129240
129738
|
const current = agentsMayMerge(existing.guidelines);
|
|
129241
129739
|
return `Only lead agents can change allowMerge or mergePolicy (agents may merge: ${current}). Resend the current allowMerge and mergePolicy to keep them while you edit the other guidelines.`;
|
|
129242
|
-
});
|
|
129740
|
+
}, () => execConfigRefusal(getCurrentRequestAuth(), "mcp"));
|
|
129243
129741
|
if (result.kind === "refused") {
|
|
129244
129742
|
return toolErr(result.refusal, { data: { repo: null } });
|
|
129245
129743
|
}
|
|
@@ -129260,6 +129758,7 @@ var init_update_repo = __esm(() => {
|
|
|
129260
129758
|
init_rbac();
|
|
129261
129759
|
init_utils();
|
|
129262
129760
|
init_types5();
|
|
129761
|
+
init_request_auth_context();
|
|
129263
129762
|
swarmRepoOutputShape2 = looseObject({
|
|
129264
129763
|
id: string2().optional(),
|
|
129265
129764
|
url: string2().optional(),
|
|
@@ -135707,7 +136206,7 @@ var init_rooms = __esm(() => {
|
|
|
135707
136206
|
});
|
|
135708
136207
|
|
|
135709
136208
|
// src/tools/rooms.ts
|
|
135710
|
-
async function
|
|
136209
|
+
async function resolve3(namespace, requestInfo, write) {
|
|
135711
136210
|
const resolved = await resolveRoomNamespace(namespace, requestInfo);
|
|
135712
136211
|
if ("error" in resolved)
|
|
135713
136212
|
return resolved;
|
|
@@ -135725,7 +136224,7 @@ var roomInput, roomOutput, decodedRoomOutput, registerRoomGetTool = (server) =>
|
|
|
135725
136224
|
yourAgentId: string2().optional()
|
|
135726
136225
|
})
|
|
135727
136226
|
}, async ({ name, namespace, schemaVersion }, requestInfo) => {
|
|
135728
|
-
const resolved = await
|
|
136227
|
+
const resolved = await resolve3(namespace, requestInfo, false);
|
|
135729
136228
|
if ("error" in resolved)
|
|
135730
136229
|
return toolErr(resolved.error, { data: { yourAgentId: requestInfo.agentId } });
|
|
135731
136230
|
try {
|
|
@@ -135752,7 +136251,7 @@ var roomInput, roomOutput, decodedRoomOutput, registerRoomGetTool = (server) =>
|
|
|
135752
136251
|
}),
|
|
135753
136252
|
rbac: { permission: "kv.write.any" }
|
|
135754
136253
|
}, async ({ name, namespace, schemaVersion, operations }, requestInfo) => {
|
|
135755
|
-
const resolved = await
|
|
136254
|
+
const resolved = await resolve3(namespace, requestInfo, true);
|
|
135756
136255
|
if ("error" in resolved)
|
|
135757
136256
|
return toolErr(resolved.error, { data: { yourAgentId: requestInfo.agentId } });
|
|
135758
136257
|
try {
|
|
@@ -135778,7 +136277,7 @@ var roomInput, roomOutput, decodedRoomOutput, registerRoomGetTool = (server) =>
|
|
|
135778
136277
|
}),
|
|
135779
136278
|
rbac: { permission: "kv.write.any" }
|
|
135780
136279
|
}, async ({ name, namespace, schemaVersion, state }, requestInfo) => {
|
|
135781
|
-
const resolved = await
|
|
136280
|
+
const resolved = await resolve3(namespace, requestInfo, true);
|
|
135782
136281
|
if ("error" in resolved)
|
|
135783
136282
|
return toolErr(resolved.error, { data: { yourAgentId: requestInfo.agentId } });
|
|
135784
136283
|
try {
|
|
@@ -137256,6 +137755,19 @@ var registerRunScheduleNowTool = (server) => {
|
|
|
137256
137755
|
if (!schedule) {
|
|
137257
137756
|
return toolErr("Schedule not found.");
|
|
137258
137757
|
}
|
|
137758
|
+
const auth = getCurrentRequestAuth();
|
|
137759
|
+
if (auth?.kind === "agent") {
|
|
137760
|
+
const caller = await getAgentById2(auth.agentId);
|
|
137761
|
+
const decision = can({
|
|
137762
|
+
principal: { kind: "agent", agentId: auth.agentId, isLead: caller?.isLead === true },
|
|
137763
|
+
verb: "schedule.run.any",
|
|
137764
|
+
resource: { kind: "owned", ownerAgentId: schedule.createdByAgentId },
|
|
137765
|
+
source: "mcp"
|
|
137766
|
+
});
|
|
137767
|
+
if (!decision.allow) {
|
|
137768
|
+
return toolErr(`Schedule "${schedule.name}" runs as the agent that created it. Only that agent or a lead can run it.`);
|
|
137769
|
+
}
|
|
137770
|
+
}
|
|
137259
137771
|
if (!schedule.enabled) {
|
|
137260
137772
|
return toolErr(`Schedule "${schedule.name}" is disabled.`, {
|
|
137261
137773
|
details: "Enable it first or use it as a template."
|
|
@@ -137286,8 +137798,10 @@ var registerRunScheduleNowTool = (server) => {
|
|
|
137286
137798
|
var init_run_schedule_now = __esm(() => {
|
|
137287
137799
|
init_zod();
|
|
137288
137800
|
init_db4();
|
|
137801
|
+
init_rbac();
|
|
137289
137802
|
init_scheduler2();
|
|
137290
137803
|
init_utils();
|
|
137804
|
+
init_request_auth_context();
|
|
137291
137805
|
});
|
|
137292
137806
|
|
|
137293
137807
|
// src/tools/schedules/update-schedule.ts
|
|
@@ -137732,7 +138246,7 @@ ${warnings.join(`
|
|
|
137732
138246
|
return denied;
|
|
137733
138247
|
const result = await proxyScriptsApi({
|
|
137734
138248
|
method: "POST",
|
|
137735
|
-
path: `/api/scripts/${args.scriptId}/apis/${args.endpointId}/rotate`,
|
|
138249
|
+
path: `/api/scripts/${args.scriptId}/apis/${encodeURIComponent(args.endpointId)}/rotate`,
|
|
137736
138250
|
requestInfo,
|
|
137737
138251
|
successMessage: () => "Token rotated.",
|
|
137738
138252
|
successDetails: (data) => {
|
|
@@ -137756,7 +138270,7 @@ ${warnings.join(`
|
|
|
137756
138270
|
return denied;
|
|
137757
138271
|
return proxyScriptsApi({
|
|
137758
138272
|
method: "PATCH",
|
|
137759
|
-
path: `/api/scripts/${args.scriptId}/apis/${args.endpointId}`,
|
|
138273
|
+
path: `/api/scripts/${args.scriptId}/apis/${encodeURIComponent(args.endpointId)}`,
|
|
137760
138274
|
body: { enabled: args.enabled, label: args.label },
|
|
137761
138275
|
requestInfo,
|
|
137762
138276
|
successMessage: () => "Endpoint updated."
|
|
@@ -137770,7 +138284,7 @@ ${warnings.join(`
|
|
|
137770
138284
|
return denied;
|
|
137771
138285
|
return proxyScriptsApi({
|
|
137772
138286
|
method: "DELETE",
|
|
137773
|
-
path: `/api/scripts/${args.scriptId}/apis/${args.endpointId}`,
|
|
138287
|
+
path: `/api/scripts/${args.scriptId}/apis/${encodeURIComponent(args.endpointId)}`,
|
|
137774
138288
|
requestInfo,
|
|
137775
138289
|
successMessage: () => "Endpoint deleted."
|
|
137776
138290
|
});
|
|
@@ -137788,7 +138302,7 @@ var init_script_apis = __esm(() => {
|
|
|
137788
138302
|
scriptApisInputSchema = object2({
|
|
137789
138303
|
action: _enum2(["list", "create", "update", "rotate", "delete"]).describe("list: endpoints for a script, tokens masked unless includeSecrets=true. create: expose the script as a new endpoint (returns the plaintext token once). update: enable/disable or relabel an endpoint. rotate: issue a new token (returns it once). delete: remove an endpoint."),
|
|
137790
138304
|
scriptId: string2().uuid().describe("The script the endpoint(s) belong to."),
|
|
137791
|
-
endpointId: string2().optional().describe("Required for update, rotate, and delete."),
|
|
138305
|
+
endpointId: string2().regex(/^[A-Za-z0-9_-]+$/, "endpointId must be an endpoint id").optional().describe("Required for update, rotate, and delete."),
|
|
137792
138306
|
authMode: _enum2(["none", "bearer"]).optional().describe("For create: 'bearer' (default, auto-generated token) or 'none' (no auth)."),
|
|
137793
138307
|
label: string2().max(200).nullable().optional().describe("For create/update."),
|
|
137794
138308
|
agentId: string2().optional().describe("For create: the agent the endpoint runs as (its egress secrets + API connections apply). Defaults to the script's owning agent; required if the script has none."),
|
|
@@ -138167,6 +138681,9 @@ ${body.stdout.trim()}`);
|
|
|
138167
138681
|
const notes = [];
|
|
138168
138682
|
if (typeof body.durationMs === "number")
|
|
138169
138683
|
notes.push(`${body.durationMs}ms`);
|
|
138684
|
+
if (typeof body.object?.stateVersion === "number") {
|
|
138685
|
+
notes.push(`object.stateVersion: ${body.object.stateVersion}`);
|
|
138686
|
+
}
|
|
138170
138687
|
if (body.truncated?.stdout || body.truncated?.stderr) {
|
|
138171
138688
|
notes.push("output truncated by the runtime");
|
|
138172
138689
|
}
|
|
@@ -138188,6 +138705,7 @@ var SCRIPT_RUN_DESCRIPTION = "Run a named swarm-shared script (callable across a
|
|
|
138188
138705
|
annotations: { openWorldHint: true },
|
|
138189
138706
|
inputSchema: object2({
|
|
138190
138707
|
name: scriptNameSchema.optional().describe("Name of a reusable script to run."),
|
|
138708
|
+
object: object2({ id: string2().min(1).max(256), method: string2().min(1).max(128) }).optional().describe("Call this object ID and method on the named global DurableObject script."),
|
|
138191
138709
|
source: string2().min(1).optional().describe('Inline TypeScript source to run without a compile-time typecheck. Must `export default async function (args, ctx)` — args FIRST, ctx second. Import `ScriptContext` from "swarm-sdk" for promotion-safe typing.'),
|
|
138192
138710
|
args: unknown().optional().describe("JSON-serializable script arguments."),
|
|
138193
138711
|
intent: string2().default("").describe("Why this script is being run."),
|
|
@@ -138401,7 +138919,7 @@ var SCRIPT_UPSERT_DESCRIPTION = 'Typecheck and persist a TypeScript script to th
|
|
|
138401
138919
|
annotations: { openWorldHint: false },
|
|
138402
138920
|
inputSchema: object2({
|
|
138403
138921
|
name: scriptNameSchema.describe("Stable script name within the selected scope."),
|
|
138404
|
-
source: string2().min(1).describe('TypeScript source, typechecked before saving. Must `export default async function (args, ctx)` — args FIRST, ctx second. Import `ScriptContext` from "swarm-sdk" to type `ctx`. Schemas can import "zod" or "zod/mini"; Mini uses functional forms such as z.optional(z.string()).'),
|
|
138922
|
+
source: string2().min(1).describe('TypeScript source, typechecked before saving. Must `export default async function (args, ctx)` — args FIRST, ctx second. Import `ScriptContext` from "swarm-sdk" to type `ctx`. Schemas can import "zod" or "zod/mini"; Mini uses functional forms such as z.optional(z.string()). A global script can instead `export default class X extends DurableObject<State>` (import `DurableObject` from "swarm-sdk").'),
|
|
138405
138923
|
description: string2().default("").describe("Human-readable script description."),
|
|
138406
138924
|
intent: string2().default("").describe("Why this script exists."),
|
|
138407
138925
|
scope: scriptScopeSchema.default("agent").describe("Persist under agent or global scope."),
|
|
@@ -141636,6 +142154,13 @@ var init_templates = __esm(() => {
|
|
|
141636
142154
|
variables: [],
|
|
141637
142155
|
category: "system"
|
|
141638
142156
|
});
|
|
142157
|
+
registerTemplate({
|
|
142158
|
+
eventType: "slack.message.thread_context_other_bot",
|
|
142159
|
+
header: "",
|
|
142160
|
+
defaultBody: "[Bot {{bot_id}}] (untrusted)",
|
|
142161
|
+
variables: [{ name: "bot_id", description: "Slack bot ID of the bot or app that posted" }],
|
|
142162
|
+
category: "system"
|
|
142163
|
+
});
|
|
141639
142164
|
});
|
|
141640
142165
|
|
|
141641
142166
|
// src/slack/inbound-files.ts
|
|
@@ -141941,19 +142466,20 @@ var init_inbound_files = __esm(() => {
|
|
|
141941
142466
|
});
|
|
141942
142467
|
|
|
141943
142468
|
// src/tools/slack-download-file.ts
|
|
142469
|
+
import { basename as basename2 } from "node:path";
|
|
141944
142470
|
function fileIdFromUrl(url) {
|
|
141945
142471
|
return /\/files-pri\/[A-Z0-9]+-([A-Z0-9]+)\//.exec(url)?.[1];
|
|
141946
142472
|
}
|
|
141947
142473
|
var registerSlackDownloadFileTool = (server) => {
|
|
141948
142474
|
createToolRegistrar(server)("slack-download-file", {
|
|
141949
142475
|
title: "Download file from Slack",
|
|
141950
|
-
description: "Download a file from Slack by file ID or URL. From a task, the file is stored as an attachment of that task and the result carries a ready-to-run `fetchCommand` to get the bytes into your container. Without a task, the file is saved on the API server's disk, which your container usually can't read.",
|
|
142476
|
+
description: "Download a file from Slack by file ID or Slack file URL. From a task, the file is stored as an attachment of that task and the result carries a ready-to-run `fetchCommand` to get the bytes into your container. Without a task, the file is saved under /workspace/shared/downloads/ on the API server's disk, which your container usually can't read.",
|
|
141951
142477
|
annotations: { readOnlyHint: false, openWorldHint: true },
|
|
141952
142478
|
inputSchema: object2({
|
|
141953
142479
|
fileId: string2().optional().describe("The Slack file ID to download (e.g., 'F0RDC39U1')."),
|
|
141954
|
-
url: string2().url().optional().describe("
|
|
142480
|
+
url: string2().url().optional().describe("Slack file URL (url_private_download or url_private from a file object). The file ID in it is looked up in Slack."),
|
|
141955
142481
|
taskId: uuid().optional().describe("Task to attach the file to. Defaults to the task you are working on; must be a task you own or created."),
|
|
141956
|
-
savePath: string2().optional().describe("Only without a task: where to save the file on the API server (directory or full path). Defaults to /workspace/shared/downloads/{agentId}/slack/."),
|
|
142482
|
+
savePath: string2().optional().describe("Only without a task: where to save the file on the API server (directory or full path). Must be inside /workspace/shared/downloads/; a relative path resolves from there. Defaults to /workspace/shared/downloads/{agentId}/slack/."),
|
|
141957
142483
|
filename: string2().optional().describe("Filename to use when saving. Only used if savePath is a directory.")
|
|
141958
142484
|
}),
|
|
141959
142485
|
outputSchema: swarmToolOutputSchema({
|
|
@@ -141997,11 +142523,11 @@ var registerSlackDownloadFileTool = (server) => {
|
|
|
141997
142523
|
if (fileId && !info) {
|
|
141998
142524
|
return toolErr(`File not found: ${fileId}`);
|
|
141999
142525
|
}
|
|
142000
|
-
|
|
142526
|
+
if (!info) {
|
|
142527
|
+
return toolErr("Could not identify the Slack file in that URL; pass fileId instead.");
|
|
142528
|
+
}
|
|
142529
|
+
const fileInfo = { id: info.id, name: info.name, mimetype: info.mimetype, size: info.size };
|
|
142001
142530
|
if (task) {
|
|
142002
|
-
if (!info) {
|
|
142003
|
-
return toolErr("Could not identify the Slack file in that URL; pass fileId instead.");
|
|
142004
|
-
}
|
|
142005
142531
|
const outcome = (await attachSlackFilesForAgent(app.client, task, [info], agent.id)).get(info.id);
|
|
142006
142532
|
if (!outcome || "reason" in outcome) {
|
|
142007
142533
|
return toolErr(`Failed to attach file: ${outcome?.reason ?? "unknown error"}`);
|
|
@@ -142013,18 +142539,19 @@ ${fetchCommand}`,
|
|
|
142013
142539
|
data: { taskId: task.id, attachmentId: attachment.id, fetchCommand, fileInfo }
|
|
142014
142540
|
});
|
|
142015
142541
|
}
|
|
142016
|
-
const downloadUrl = info
|
|
142542
|
+
const downloadUrl = info.url_private_download;
|
|
142017
142543
|
if (!downloadUrl) {
|
|
142018
142544
|
return toolErr("No download URL available.");
|
|
142019
142545
|
}
|
|
142020
142546
|
let finalSavePath = savePath || DEFAULT_DOWNLOAD_DIR;
|
|
142021
142547
|
if (finalSavePath.endsWith("/") || !finalSavePath.includes(".")) {
|
|
142022
|
-
const actualFilename = filename ||
|
|
142548
|
+
const actualFilename = basename2(filename || info.name || `file_${Date.now()}`);
|
|
142023
142549
|
finalSavePath = finalSavePath.endsWith("/") ? `${finalSavePath}${actualFilename}` : `${finalSavePath}/${actualFilename}`;
|
|
142024
142550
|
}
|
|
142025
142551
|
const result = await downloadFile({
|
|
142026
142552
|
file: downloadUrl,
|
|
142027
142553
|
savePath: finalSavePath,
|
|
142554
|
+
root: DOWNLOAD_ROOT,
|
|
142028
142555
|
token
|
|
142029
142556
|
});
|
|
142030
142557
|
if (!result.success) {
|
|
@@ -142315,6 +142842,10 @@ var registerSlackPostTool = (server) => {
|
|
|
142315
142842
|
}
|
|
142316
142843
|
if (blocks && card)
|
|
142317
142844
|
return toolErr("Provide either blocks or card, not both.");
|
|
142845
|
+
const reservedActionId = findReservedActionId(blocks);
|
|
142846
|
+
if (reservedActionId) {
|
|
142847
|
+
return toolErr(`blocks use the action_id "${reservedActionId}", which the swarm reserves for its own buttons. Use another action_id.`);
|
|
142848
|
+
}
|
|
142318
142849
|
if (!message && !card)
|
|
142319
142850
|
return toolErr("Provide a message or a card.");
|
|
142320
142851
|
let cardSlack;
|
|
@@ -142413,6 +142944,7 @@ var init_slack_post = __esm(() => {
|
|
|
142413
142944
|
});
|
|
142414
142945
|
|
|
142415
142946
|
// src/tools/slack-read.ts
|
|
142947
|
+
import { basename as basename3 } from "node:path";
|
|
142416
142948
|
var AUTO_DOWNLOAD_DIR = "/app/shared/downloads/slack", USERS_INFO_CONCURRENCY = 4, SlackFileSchema, SlackMessageSchema, registerSlackReadTool = (server) => {
|
|
142417
142949
|
createToolRegistrar(server)("slack-read", {
|
|
142418
142950
|
title: "Read Slack thread/channel history",
|
|
@@ -142573,11 +143105,12 @@ var AUTO_DOWNLOAD_DIR = "/app/shared/downloads/slack", USERS_INFO_CONCURRENCY =
|
|
|
142573
143105
|
if (attachTo) {
|
|
142574
143106
|
toAttach.push({ raw: f, info: fileInfo });
|
|
142575
143107
|
} else if (token && f.url_private_download) {
|
|
142576
|
-
const savePath = `${AUTO_DOWNLOAD_DIR}/${f.id}_${f.name}`;
|
|
142577
143108
|
try {
|
|
143109
|
+
const savePath = `${AUTO_DOWNLOAD_DIR}/${f.id}_${basename3(f.name)}`;
|
|
142578
143110
|
const downloadResult = await downloadFile({
|
|
142579
143111
|
file: f.url_private_download,
|
|
142580
143112
|
savePath,
|
|
143113
|
+
root: AUTO_DOWNLOAD_DIR,
|
|
142581
143114
|
token
|
|
142582
143115
|
});
|
|
142583
143116
|
if (downloadResult.success && downloadResult.savedPath) {
|
|
@@ -142817,6 +143350,14 @@ ${JSON.stringify(cardSlack.blocks)}` : blocks ? JSON.stringify(blocks) : message
|
|
|
142817
143350
|
await markTaskSlackReplySent2(taskId);
|
|
142818
143351
|
console.log(`[Slack] Marked slackReplySent=1 for task ${taskId}`);
|
|
142819
143352
|
}
|
|
143353
|
+
const sourceTaskId = requestInfo.sourceTaskId;
|
|
143354
|
+
if (sourceTaskId && sourceTaskId !== taskId) {
|
|
143355
|
+
const sourceTask = await getTaskById2(sourceTaskId);
|
|
143356
|
+
if (sourceTask?.agentId === agent.id && sourceTask.slackChannelId === slackChannelId && sourceTask.slackThreadTs === slackThreadTs) {
|
|
143357
|
+
await markTaskSlackReplySent2(sourceTaskId);
|
|
143358
|
+
console.log(`[Slack] Marked slackReplySent=1 for source task ${sourceTaskId}`);
|
|
143359
|
+
}
|
|
143360
|
+
}
|
|
142820
143361
|
return toolOk("Reply sent successfully.", {
|
|
142821
143362
|
details: messageTs ? `Message timestamp: ${messageTs}` : undefined,
|
|
142822
143363
|
data: { messageTs }
|
|
@@ -142873,6 +143414,10 @@ var registerSlackStartThreadTool = (server) => {
|
|
|
142873
143414
|
if (!decision.allow) {
|
|
142874
143415
|
return toolErr("Posting to Slack channels requires lead privileges.");
|
|
142875
143416
|
}
|
|
143417
|
+
const reservedActionId = findReservedActionId(blocks);
|
|
143418
|
+
if (reservedActionId) {
|
|
143419
|
+
return toolErr(`blocks use the action_id "${reservedActionId}", which the swarm reserves for its own buttons. Use another action_id.`);
|
|
143420
|
+
}
|
|
142876
143421
|
const app = getSlackApp2();
|
|
142877
143422
|
if (!app) {
|
|
142878
143423
|
return toolErr("Slack not configured.");
|
|
@@ -143041,46 +143586,50 @@ function resolveTaskUploadThreadTs(task) {
|
|
|
143041
143586
|
}
|
|
143042
143587
|
return task.slackThreadTs;
|
|
143043
143588
|
}
|
|
143044
|
-
async function
|
|
143045
|
-
const
|
|
143046
|
-
const
|
|
143047
|
-
|
|
143048
|
-
|
|
143049
|
-
|
|
143050
|
-
|
|
143051
|
-
|
|
143052
|
-
|
|
143053
|
-
|
|
143054
|
-
|
|
143055
|
-
|
|
143056
|
-
|
|
143057
|
-
|
|
143058
|
-
|
|
143059
|
-
|
|
143060
|
-
|
|
143061
|
-
|
|
143062
|
-
|
|
143063
|
-
|
|
143064
|
-
|
|
143065
|
-
|
|
143066
|
-
|
|
143067
|
-
|
|
143068
|
-
|
|
143069
|
-
|
|
143070
|
-
|
|
143071
|
-
|
|
143072
|
-
|
|
143073
|
-
triedPaths
|
|
143074
|
-
if (await fileExists(workspacePath)) {
|
|
143075
|
-
return { success: true, resolvedPath: workspacePath };
|
|
143076
|
-
}
|
|
143077
|
-
}
|
|
143589
|
+
async function uploadRoots(agentId, taskIds) {
|
|
143590
|
+
const roots = [WORKSPACE_DIR];
|
|
143591
|
+
for (const id of new Set(taskIds.filter((t) => !!t))) {
|
|
143592
|
+
const task = await getTaskById2(id);
|
|
143593
|
+
if (!task || task.agentId !== agentId && task.creatorAgentId !== agentId)
|
|
143594
|
+
continue;
|
|
143595
|
+
if (task.dir)
|
|
143596
|
+
roots.push(task.dir);
|
|
143597
|
+
const repoId = await vcsRepoId(task.vcsRepo);
|
|
143598
|
+
const repo = repoId ? await getSwarmRepoById2(repoId) : null;
|
|
143599
|
+
if (repo)
|
|
143600
|
+
roots.push(repo.clonePath);
|
|
143601
|
+
}
|
|
143602
|
+
return roots;
|
|
143603
|
+
}
|
|
143604
|
+
async function openUploadFile(filePath, roots) {
|
|
143605
|
+
const triedPaths = filePath.startsWith("/") ? [
|
|
143606
|
+
filePath,
|
|
143607
|
+
...filePath.startsWith(`${WORKSPACE_DIR}/`) ? [] : [`${WORKSPACE_DIR}${filePath}`]
|
|
143608
|
+
] : [`${WORKSPACE_DIR}/${filePath}`];
|
|
143609
|
+
let refusal;
|
|
143610
|
+
for (const candidate of triedPaths) {
|
|
143611
|
+
const opened = await openFileInside(candidate, roots);
|
|
143612
|
+
if (opened.success)
|
|
143613
|
+
return { success: true, file: opened.file, resolvedPath: candidate };
|
|
143614
|
+
if (!opened.notFound)
|
|
143615
|
+
refusal ??= opened.error;
|
|
143616
|
+
}
|
|
143617
|
+
if (refusal)
|
|
143618
|
+
return { success: false, notFound: false, error: refusal, triedPaths };
|
|
143078
143619
|
return {
|
|
143079
143620
|
success: false,
|
|
143080
|
-
|
|
143621
|
+
notFound: true,
|
|
143622
|
+
error: filePath.startsWith("/") ? "File not found at any of the attempted locations." : `File not found. Relative paths are resolved from ${WORKSPACE_DIR}.`,
|
|
143081
143623
|
triedPaths
|
|
143082
143624
|
};
|
|
143083
143625
|
}
|
|
143626
|
+
function uploadResult(result) {
|
|
143627
|
+
if (!result.success) {
|
|
143628
|
+
return toolErr(`Failed to upload file: ${result.error}`);
|
|
143629
|
+
}
|
|
143630
|
+
const successMsg = `File uploaded successfully${result.fileId ? ` (ID: ${result.fileId})` : ""}.`;
|
|
143631
|
+
return toolOk(successMsg, { data: { fileId: result.fileId } });
|
|
143632
|
+
}
|
|
143084
143633
|
var WORKSPACE_DIR = "/workspace", registerSlackUploadFileTool = (server) => {
|
|
143085
143634
|
createToolRegistrar(server)("slack-upload-file", {
|
|
143086
143635
|
title: "Upload file to Slack",
|
|
@@ -143091,7 +143640,7 @@ var WORKSPACE_DIR = "/workspace", registerSlackUploadFileTool = (server) => {
|
|
|
143091
143640
|
taskId: uuid().optional().describe("The task ID with Slack context (for task-related threads)."),
|
|
143092
143641
|
channelId: string2().optional().describe("Direct channel ID to upload to (requires lead privileges)."),
|
|
143093
143642
|
threadTs: string2().optional().describe("Thread timestamp to upload as a thread reply (used with channelId)."),
|
|
143094
|
-
filePath: string2().min(1).optional().describe("Path to the file to upload. Either filePath OR content must be provided. " + "IMPORTANT: the file is read on the API server's filesystem (where this tool runs), NOT on the caller's. " + "Worker/lead containers do NOT share /tmp or /workspace/personal/ with the API server — the only shared volume is /workspace/shared/. " + "Use /workspace/shared/<agent-id>/file.png (or a relative path like 'shared/<agent-id>/file.png'). " + "For files that only live on the caller (e.g. /tmp), pass them inline via `content` (base64) instead."),
|
|
143643
|
+
filePath: string2().min(1).optional().describe("Path to the file to upload. Either filePath OR content must be provided. " + "IMPORTANT: the file is read on the API server's filesystem (where this tool runs), NOT on the caller's. " + "Worker/lead containers do NOT share /tmp or /workspace/personal/ with the API server — the only shared volume is /workspace/shared/. " + "The file must be a regular file inside /workspace or the working directory of your current task. " + "Use /workspace/shared/<agent-id>/file.png (or a relative path like 'shared/<agent-id>/file.png'). " + "For files that only live on the caller (e.g. /tmp), pass them inline via `content` (base64) instead."),
|
|
143095
143644
|
content: string2().optional().describe("Base64-encoded file content. Use this when the file lives on the caller's filesystem and isn't reachable by the API server " + "(e.g. anything under /tmp on a worker/lead container). Either filePath OR content must be provided."),
|
|
143096
143645
|
filename: string2().optional().describe("Name to give the file in Slack. Required when using content, defaults to original filename when using filePath."),
|
|
143097
143646
|
initialComment: string2().max(4000).optional().describe("Optional message to post with the file.")
|
|
@@ -143164,11 +143713,12 @@ var WORKSPACE_DIR = "/workspace", registerSlackUploadFileTool = (server) => {
|
|
|
143164
143713
|
if (content && !filename) {
|
|
143165
143714
|
return toolErr("filename is required when using base64 content upload.");
|
|
143166
143715
|
}
|
|
143167
|
-
let fileToUpload;
|
|
143168
|
-
let actualFilename;
|
|
143169
143716
|
if (filePath) {
|
|
143170
|
-
const
|
|
143717
|
+
const roots = await uploadRoots(agent.id, [taskId, requestInfo.sourceTaskId]);
|
|
143718
|
+
const pathResult = await openUploadFile(filePath, roots);
|
|
143171
143719
|
if (!pathResult.success) {
|
|
143720
|
+
if (!pathResult.notFound)
|
|
143721
|
+
return toolErr(pathResult.error);
|
|
143172
143722
|
const triedPathsList = pathResult.triedPaths.map((p) => ` - ${p}`).join(`
|
|
143173
143723
|
`);
|
|
143174
143724
|
const errorMsg = `${pathResult.error}
|
|
@@ -143183,40 +143733,35 @@ ${triedPathsList}
|
|
|
143183
143733
|
` + `- Or pass the file inline via the \`content\` arg as base64 (with \`filename\`) so no shared-mount round-trip is needed.`;
|
|
143184
143734
|
return toolErr(errorMsg);
|
|
143185
143735
|
}
|
|
143186
|
-
const resolvedPath = pathResult.resolvedPath;
|
|
143187
|
-
const bunFile = Bun.file(resolvedPath);
|
|
143188
|
-
const fileSize = bunFile.size;
|
|
143189
|
-
if (fileSize > MAX_FILE_SIZE) {
|
|
143190
|
-
const sizeMB = Math.round(fileSize / 1024 / 1024);
|
|
143191
|
-
return toolErr(`File too large: ${sizeMB} MB. Maximum is 1 GB.`);
|
|
143192
|
-
}
|
|
143193
|
-
fileToUpload = resolvedPath;
|
|
143194
|
-
actualFilename = filename || resolvedPath.split("/").pop() || "file";
|
|
143195
|
-
} else {
|
|
143196
143736
|
try {
|
|
143197
|
-
|
|
143198
|
-
|
|
143199
|
-
|
|
143200
|
-
|
|
143201
|
-
|
|
143202
|
-
|
|
143203
|
-
|
|
143737
|
+
return uploadResult(await uploadOpenFile(app.client, pathResult.file, {
|
|
143738
|
+
filename: filename || pathResult.resolvedPath.split("/").pop() || "file",
|
|
143739
|
+
channelId: slackChannelId,
|
|
143740
|
+
threadTs: slackThreadTs,
|
|
143741
|
+
initialComment
|
|
143742
|
+
}));
|
|
143743
|
+
} finally {
|
|
143744
|
+
await pathResult.file.handle.close();
|
|
143204
143745
|
}
|
|
143205
|
-
|
|
143746
|
+
}
|
|
143747
|
+
let fileToUpload;
|
|
143748
|
+
try {
|
|
143749
|
+
fileToUpload = Buffer.from(content, "base64");
|
|
143750
|
+
} catch {
|
|
143751
|
+
return toolErr("Invalid base64 content.");
|
|
143752
|
+
}
|
|
143753
|
+
if (fileToUpload.length > MAX_FILE_SIZE) {
|
|
143754
|
+
const sizeMB = Math.round(fileToUpload.length / 1024 / 1024);
|
|
143755
|
+
return toolErr(`File too large: ${sizeMB} MB. Maximum is 1 GB.`);
|
|
143206
143756
|
}
|
|
143207
143757
|
try {
|
|
143208
|
-
|
|
143758
|
+
return uploadResult(await uploadFile(app.client, {
|
|
143209
143759
|
file: fileToUpload,
|
|
143210
|
-
filename
|
|
143760
|
+
filename,
|
|
143211
143761
|
channelId: slackChannelId,
|
|
143212
143762
|
threadTs: slackThreadTs,
|
|
143213
143763
|
initialComment
|
|
143214
|
-
});
|
|
143215
|
-
if (!result.success) {
|
|
143216
|
-
return toolErr(`Failed to upload file: ${result.error}`);
|
|
143217
|
-
}
|
|
143218
|
-
const successMsg = `File uploaded successfully${result.fileId ? ` (ID: ${result.fileId})` : ""}.`;
|
|
143219
|
-
return toolOk(successMsg, { data: { fileId: result.fileId } });
|
|
143764
|
+
}));
|
|
143220
143765
|
} catch (error) {
|
|
143221
143766
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
143222
143767
|
return toolErr(`Failed to upload file: ${errorMsg}`);
|
|
@@ -143226,6 +143771,7 @@ ${triedPathsList}
|
|
|
143226
143771
|
var init_slack_upload_file = __esm(() => {
|
|
143227
143772
|
init_zod();
|
|
143228
143773
|
init_db4();
|
|
143774
|
+
init_model_profile_check();
|
|
143229
143775
|
init_rbac();
|
|
143230
143776
|
init_app4();
|
|
143231
143777
|
init_external_channel();
|
|
@@ -143522,7 +144068,7 @@ var init_task_skip = __esm(() => {
|
|
|
143522
144068
|
var TaskUiSpecActionInputSchema, TaskUiSpecInputSchema;
|
|
143523
144069
|
var init_schema2 = __esm(() => {
|
|
143524
144070
|
init_zod();
|
|
143525
|
-
|
|
144071
|
+
init_task_ui_spec();
|
|
143526
144072
|
TaskUiSpecActionInputSchema = discriminatedUnion("kind", [
|
|
143527
144073
|
object2({ kind: literal2("follow_up"), prompt: string2().min(1).max(4000) }),
|
|
143528
144074
|
object2({
|
|
@@ -143548,7 +144094,7 @@ async function readScriptActionAllowlist() {
|
|
|
143548
144094
|
const [row] = await getSwarmConfigs2({ scope: "global", key: UI_SPEC_SCRIPT_ACTIONS_KEY });
|
|
143549
144095
|
if (row)
|
|
143550
144096
|
return row.value;
|
|
143551
|
-
const { getDeploymentEnvValue } = await import("./core-
|
|
144097
|
+
const { getDeploymentEnvValue } = await import("./core-dynsv289.js");
|
|
143552
144098
|
return getDeploymentEnvValue(UI_SPEC_SCRIPT_ACTIONS_KEY);
|
|
143553
144099
|
}
|
|
143554
144100
|
async function loadScriptActionLookups() {
|
|
@@ -143759,10 +144305,10 @@ var init_script_actions = __esm(() => {
|
|
|
143759
144305
|
init_db4();
|
|
143760
144306
|
init_db3();
|
|
143761
144307
|
init_run_saved();
|
|
143762
|
-
|
|
144308
|
+
init_task_ui_spec2();
|
|
143763
144309
|
init_env_flag();
|
|
143764
144310
|
init_secret_scrubber();
|
|
143765
|
-
|
|
144311
|
+
init_task_ui_spec();
|
|
143766
144312
|
init_event_bus();
|
|
143767
144313
|
init_json_schema_validator();
|
|
143768
144314
|
init_schema2();
|
|
@@ -144104,7 +144650,7 @@ This check refuses once per task; the next completion is accepted without the sp
|
|
|
144104
144650
|
}
|
|
144105
144651
|
}
|
|
144106
144652
|
if (status === "completed") {
|
|
144107
|
-
const result = await completeTask2(taskId, output);
|
|
144653
|
+
const result = await completeTask2(taskId, output, { statusKind: "agent" });
|
|
144108
144654
|
if (result && uiSpecToStore)
|
|
144109
144655
|
await upsertTaskUiSpec(taskId, uiSpecToStore);
|
|
144110
144656
|
if (result) {
|
|
@@ -144131,7 +144677,9 @@ This check refuses once per task; the next completion is accepted without the sp
|
|
|
144131
144677
|
}
|
|
144132
144678
|
}
|
|
144133
144679
|
} else if (status === "failed") {
|
|
144134
|
-
const result = await failTask2(taskId, failureReason ?? "Unknown failure"
|
|
144680
|
+
const result = await failTask2(taskId, failureReason ?? "Unknown failure", {
|
|
144681
|
+
statusKind: "agent"
|
|
144682
|
+
});
|
|
144135
144683
|
if (result) {
|
|
144136
144684
|
updatedTask = result;
|
|
144137
144685
|
getDbClient2().afterCommit(() => {
|
|
@@ -144156,7 +144704,7 @@ This check refuses once per task; the next completion is accepted without the sp
|
|
|
144156
144704
|
}
|
|
144157
144705
|
}
|
|
144158
144706
|
} else if (status === "skipped") {
|
|
144159
|
-
const result = await skipTask2(taskId, skipReason);
|
|
144707
|
+
const result = await skipTask2(taskId, skipReason, { statusKind: "agent" });
|
|
144160
144708
|
if (result) {
|
|
144161
144709
|
updatedTask = result;
|
|
144162
144710
|
if (existingTask.agentId) {
|
|
@@ -144221,7 +144769,7 @@ var init_store_progress = __esm(() => {
|
|
|
144221
144769
|
init_constants2();
|
|
144222
144770
|
init_task_learning();
|
|
144223
144771
|
init_task_citations2();
|
|
144224
|
-
|
|
144772
|
+
init_task_ui_spec2();
|
|
144225
144773
|
init_agent_fs_provider();
|
|
144226
144774
|
init_rbac();
|
|
144227
144775
|
init_task_skip();
|
|
@@ -144384,14 +144932,14 @@ async function approveAndSend(id, approval) {
|
|
|
144384
144932
|
let proxyId = null;
|
|
144385
144933
|
let proxyError = null;
|
|
144386
144934
|
try {
|
|
144387
|
-
const response = await
|
|
144935
|
+
const response = await createSsrfGuardedFetch(publicEndpointSsrfOptions())(approval.endpoint, {
|
|
144388
144936
|
method: "POST",
|
|
144389
144937
|
headers: { "Content-Type": "application/json" },
|
|
144390
144938
|
body: JSON.stringify(payload),
|
|
144391
144939
|
signal: AbortSignal.timeout(SEND_TIMEOUT_MS)
|
|
144392
144940
|
});
|
|
144393
144941
|
proxyStatus = response.status;
|
|
144394
|
-
const body = await response
|
|
144942
|
+
const body = await readBodyPrefix(response, PROXY_ERROR_MAX).catch(() => "");
|
|
144395
144943
|
if (response.ok) {
|
|
144396
144944
|
try {
|
|
144397
144945
|
const parsed = JSON.parse(body);
|
|
@@ -144423,6 +144971,25 @@ async function approveAndSend(id, approval) {
|
|
|
144423
144971
|
throw new Error(`Improvement ${id} vanished after send`);
|
|
144424
144972
|
return finished;
|
|
144425
144973
|
}
|
|
144974
|
+
async function readBodyPrefix(response, maxBytes) {
|
|
144975
|
+
const reader = response.body?.getReader();
|
|
144976
|
+
if (!reader)
|
|
144977
|
+
return "";
|
|
144978
|
+
const chunks = [];
|
|
144979
|
+
let size = 0;
|
|
144980
|
+
try {
|
|
144981
|
+
while (size < maxBytes) {
|
|
144982
|
+
const { done, value } = await reader.read();
|
|
144983
|
+
if (done)
|
|
144984
|
+
break;
|
|
144985
|
+
chunks.push(value);
|
|
144986
|
+
size += value.byteLength;
|
|
144987
|
+
}
|
|
144988
|
+
} finally {
|
|
144989
|
+
await reader.cancel().catch(() => {});
|
|
144990
|
+
}
|
|
144991
|
+
return new TextDecoder().decode(Buffer.concat(chunks).subarray(0, maxBytes));
|
|
144992
|
+
}
|
|
144426
144993
|
async function discardImprovement(id, options) {
|
|
144427
144994
|
await assertEnabled();
|
|
144428
144995
|
const now = new Date().toISOString();
|
|
@@ -144496,6 +145063,8 @@ async function improvementLeakHints(text) {
|
|
|
144496
145063
|
}
|
|
144497
145064
|
var IMPROVEMENTS_ENABLED_KEY = "IMPROVEMENTS_ENABLED", IMPROVEMENT_TEXT_MAX = 4000, SEND_TIMEOUT_MS = 1e4, PROXY_ERROR_MAX = 1024, LEAK_HINTS_MAX = 50, INSTALL_ID_KEY = "telemetry_installation_id", EMAIL_MAX = 320, VALID_EMAIL_RE, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, URL_RE, EMAIL_RE;
|
|
144498
145065
|
var init_improvements = __esm(() => {
|
|
145066
|
+
init_mcp_wrapper();
|
|
145067
|
+
init_egress_guard();
|
|
144499
145068
|
init_env_flag();
|
|
144500
145069
|
init_secret_scrubber();
|
|
144501
145070
|
init_db4();
|
|
@@ -144859,7 +145428,7 @@ var configEntryShape3, registerSetConfigTool = (server) => {
|
|
|
144859
145428
|
key: string2().min(1).max(255).describe("Configuration key (e.g., 'AGENTMAIL_WEBHOOK_SECRET')."),
|
|
144860
145429
|
value: string2().describe("Configuration value."),
|
|
144861
145430
|
isSecret: boolean().optional().describe("If true, value is masked in API responses (default: false)."),
|
|
144862
|
-
envPath: string2().optional().describe("Optional:
|
|
145431
|
+
envPath: string2().optional().describe("Optional: a path stored with the row as metadata. The server does not write files."),
|
|
144863
145432
|
description: string2().optional().describe("Optional human-readable description of this config entry."),
|
|
144864
145433
|
exportToEnv: boolean().optional().describe("Export this row into agent process env (default true on create, false for a few server-side secrets; omitted on update keeps the stored flag). Rejected as true for keys only the API server reads.")
|
|
144865
145434
|
}),
|
|
@@ -144984,7 +145553,6 @@ var primitiveQueryValueSchema, registerSwarmXTool = (server) => {
|
|
|
144984
145553
|
body: unknown().optional().describe("Optional JSON request body."),
|
|
144985
145554
|
query: record2(string2(), primitiveQueryValueSchema).optional().describe("Optional query parameters appended to the Composio path."),
|
|
144986
145555
|
headers: record2(string2(), string2()).optional().describe("Optional extra headers. Auth headers are injected by the server."),
|
|
144987
|
-
baseUrl: string2().url().optional().describe("Optional Composio API base URL override."),
|
|
144988
145556
|
useOrgKey: boolean().default(false).describe("Use COMPOSIO_ORG_API_KEY/x-org-api-key instead of COMPOSIO_API_KEY/x-api-key."),
|
|
144989
145557
|
raw: boolean().default(false).describe("Return raw text instead of JSON-pretty output text.")
|
|
144990
145558
|
}),
|
|
@@ -145002,7 +145570,6 @@ var primitiveQueryValueSchema, registerSwarmXTool = (server) => {
|
|
|
145002
145570
|
let result;
|
|
145003
145571
|
try {
|
|
145004
145572
|
result = await executeComposioRequest(composioArgsFromParts({
|
|
145005
|
-
baseUrl: input.baseUrl,
|
|
145006
145573
|
body: input.body,
|
|
145007
145574
|
endpoint: input.path,
|
|
145008
145575
|
headers: input.headers,
|
|
@@ -145067,7 +145634,7 @@ async function priceModel(provider, usage, split, atEpochMs, lookupRate) {
|
|
|
145067
145634
|
if (inputRate == null || outputRate == null)
|
|
145068
145635
|
return null;
|
|
145069
145636
|
const cacheReadRate = await lookupRate(provider, lookupModel, "cached_input", atEpochMs) ?? 0;
|
|
145070
|
-
const uncachedInputTokens = INCLUSIVE_INPUT_PROVIDERS.has(provider) ? Math.max(0, usage.inputTokens - usage.cacheReadTokens) : usage.inputTokens;
|
|
145637
|
+
const uncachedInputTokens = INCLUSIVE_INPUT_PROVIDERS.has(provider) ? Math.max(0, usage.inputTokens - usage.cacheReadTokens - usage.cacheWriteTokens) : usage.inputTokens;
|
|
145071
145638
|
let cacheWriteCostUnits = 0;
|
|
145072
145639
|
if (split) {
|
|
145073
145640
|
const fiveMinuteTokens = usage.cacheWriteTokens * split.fiveMinuteRatio;
|
|
@@ -145435,7 +146002,7 @@ async function emitBudgetRefusalSideEffects(ctx, inserted) {
|
|
|
145435
146002
|
console.warn(`[budget-refusal-notify] Failed to create follow-up task for budget refusal (task=${ctx.task.id.slice(0, 8)}): ${err}`);
|
|
145436
146003
|
}
|
|
145437
146004
|
}
|
|
145438
|
-
import("./event-bus-
|
|
146005
|
+
import("./event-bus-tvf2grf4.js").then(({ workflowEventBus }) => {
|
|
145439
146006
|
workflowEventBus.emit("task.budget_refused", {
|
|
145440
146007
|
taskId: ctx.task.id,
|
|
145441
146008
|
agentId: ctx.agentId,
|
|
@@ -148034,4 +148601,4 @@ var init_server = __esm(() => {
|
|
|
148034
148601
|
loggedToolAllowlistWarnings = new Set;
|
|
148035
148602
|
});
|
|
148036
148603
|
|
|
148037
|
-
export { safeParse, getObjectShape, getLiteralValue, init_zod_compat, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, isInitializeRequest, InitializeResultSchema, CreateTaskResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, ListPromptsResultSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ListToolsResultSchema, CallToolResultSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitRequestSchema, ElicitResultSchema, CompleteResultSchema, McpError, init_types, Protocol, mergeCapabilities, init_protocol, AjvJsonSchemaValidator, init_ajv_provider, assertToolsCallTaskCapability, assertClientRequestTaskCapability, init_helpers, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, decodeStandardWebhookSecret, verifyStandardWebhookSignature, verifyTokenEquality, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, isGitHubEnabled, initGitHub, verifyWebhookSignature, getWorkerInstallationToken, init_app, isReservedProviderEvent, init_event_waits, stripSiblingBlock, init_sibling_block, createTaskWithSiblingAwareness, init_sibling_awareness, dispatchScheduleTarget, calculateNextRun2, parseSchedulerIntervalMs2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, hasNativeToolHandlers2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, dismissedNamespace, dismissUnmappedIdentity, restoreUnmappedIdentity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, repointTrackerSyncBySwarmId, init_tracker, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config2, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app2, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app3, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue2, loadGlobalConfigsIntoEnv2, reloadGlobalConfigsAndIntegrations2, scheduleIntegrationsReload2, handleCore2, init_core, runTaskUiScriptAction, init_script_actions, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, init_request_principal, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveTaskRequester, init_task_requester, handleApps, init_apps, parseScene, init_elements, MAX_OBJECT_BYTES, init_write_object, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, DesignSystemError, buildDesignSystem, init_design_system, getDesignSystem, getActiveDesignSystem, saveDesignSystem, init_design_system2, snapshotPage, init_version3, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, scriptNameSchema, scriptToolOutputSchema, scriptsApiToolResult, init_script_common, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, init_kv_reserved_namespaces, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, attachDemotionEvidence, init_demotion_evidence, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config3, changesMergePolicy, init_repo_merge_policy, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config4, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, changesScheduleTarget, init_validate, renderTypeBlobs, init_script_query_types, renderRunOutput, init_script_run, renderSearchResults, searchSuccessMessage, init_script_search, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, setSheetRange, appendSheetRows, clearSheetRange, init_service, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, recomputeSessionCost, init_session_cost_recompute, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };
|
|
148604
|
+
export { safeParse, getObjectShape, getLiteralValue, init_zod_compat, LATEST_PROTOCOL_VERSION, DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, ErrorCode, isJSONRPCErrorResponse, JSONRPCMessageSchema, EmptyResultSchema, isInitializeRequest, InitializeResultSchema, CreateTaskResultSchema, ListResourcesResultSchema, ListResourceTemplatesResultSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, ListPromptsResultSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ListToolsResultSchema, CallToolResultSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, ElicitRequestSchema, ElicitResultSchema, CompleteResultSchema, McpError, init_types, Protocol, mergeCapabilities, init_protocol, AjvJsonSchemaValidator, init_ajv_provider, assertToolsCallTaskCapability, assertClientRequestTaskCapability, init_helpers, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, decodeStandardWebhookSecret, verifyStandardWebhookSignature, verifyTokenEquality, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, isGitHubEnabled, initGitHub, verifyWebhookSignature, getWorkerInstallationToken, init_app, isReservedProviderEvent, init_event_waits, stripSiblingBlock, init_sibling_block, prepareTaskWithSiblingAwareness, createTaskWithSiblingAwareness, init_sibling_awareness, hasPendingEventWait, init_deferred_task_waits, dispatchScheduleTarget, calculateNextRun2, parseSchedulerIntervalMs2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, hasNativeToolHandlers2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, dismissedNamespace, dismissUnmappedIdentity, restoreUnmappedIdentity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, repointTrackerSyncBySwarmId, init_tracker, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config2, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app2, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app3, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue2, loadGlobalConfigsIntoEnv2, reloadGlobalConfigsAndIntegrations2, scheduleIntegrationsReload2, handleCore2, init_core, runTaskUiScriptAction, init_script_actions, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, refuseAgentTokenWithout, init_request_principal, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveTaskRequester, init_task_requester, handleApps, init_apps, parseScene, init_elements, MAX_OBJECT_BYTES, init_write_object, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, DesignSystemError, buildDesignSystem, init_design_system, getDesignSystem, getActiveDesignSystem, saveDesignSystem, init_design_system2, snapshotPage, init_version3, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, scriptNameSchema, scriptToolOutputSchema, scriptsApiToolResult, init_script_common, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, scrubReservedRead, init_kv_reserved_namespaces, MAX_KV_BODY_BYTES, init_kv_limits, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, attachDemotionEvidence, init_demotion_evidence, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config3, changesMergePolicy, init_repo_merge_policy, execConfigRefusal, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config4, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, changesScheduleTarget, init_validate, renderTypeBlobs, init_script_query_types, renderRunOutput, init_script_run, renderSearchResults, searchSuccessMessage, init_script_search, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, setSheetRange, appendSheetRows, clearSheetRange, init_service, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, recomputeSessionCost, init_session_cost_recompute, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, IDEMPOTENT_REPLAYED_HEADER, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };
|