@desplega.ai/agent-swarm 2.13.1 → 2.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/acp-adapter-t2q6nsqv.js +17 -0
- package/dist/{acp-targets-n7vm5atw.js → acp-targets-k8xs4tj8.js} +7 -7
- package/dist/{actions-hq6wp9xv.js → actions-pg5fxjer.js} +25 -25
- package/dist/{agent-fs-provision-y0qc1rdd.js → agent-fs-provision-vbk3fppw.js} +4 -4
- package/dist/{amp-adapter-1qqs6h91.js → amp-adapter-adbhxsz9.js} +2 -2
- package/dist/{app-7m4z44rv.js → app-b267ggx1.js} +8 -8
- package/dist/{approval-notifications-8sr41gjx.js → approval-notifications-evc1a9z5.js} +9 -9
- package/dist/{assistant-hkczwfv6.js → assistant-wgz2ab84.js} +26 -26
- package/dist/{boot-args-schema-8025snev.js → boot-args-schema-6tpk28j4.js} +1 -1
- package/dist/{boot-reembed-15m87nr1.js → boot-reembed-ankp369c.js} +1 -1
- package/dist/{boot-reembed-4bbpxjh1.js → boot-reembed-r1zyvefv.js} +1 -1
- package/dist/{boot-scrub-sweep-eajr97e9.js → boot-scrub-sweep-cgb6r5bd.js} +2 -2
- package/dist/{boot-seeds-9cwy39jx.js → boot-seeds-bjceqg7b.js} +4 -4
- package/dist/{claude-adapter-g61wa4rt.js → claude-adapter-knztdnff.js} +9 -6
- package/dist/{claude-managed-adapter-znkk0prm.js → claude-managed-adapter-qwejzqkk.js} +3 -3
- package/dist/{claude-managed-setup-f1wndkr2.js → claude-managed-setup-0vgz4d1j.js} +4 -4
- package/dist/{claude-sdk-session-687xzf21.js → claude-sdk-session-c3g6dv0g.js} +11984 -11775
- package/dist/{cli-4mj5g29m.js → cli-0j4qmc80.js} +7 -7
- package/dist/{cli-fn8aj7gb.js → cli-1606qw3n.js} +98 -71
- package/dist/{cli-w41bvvms.js → cli-1gnf5c7x.js} +1 -1
- package/dist/{cli-aebswqmz.js → cli-1wew39p0.js} +15 -15
- package/dist/{cli-0fx95c06.js → cli-268b3dgn.js} +2 -2
- package/dist/cli-2ap1the6.js +11 -0
- package/dist/{cli-w6c6dj91.js → cli-4dyhzhpx.js} +1 -1
- package/dist/{cli-grcc2h2g.js → cli-55fqpd9q.js} +8 -8
- package/dist/{cli-p7g7wd9n.js → cli-61fzwtjk.js} +7 -7
- package/dist/{cli-zaate0rd.js → cli-61p7ty8d.js} +2 -2
- package/dist/{cli-cp0m07wb.js → cli-7fa6yv98.js} +2 -2
- package/dist/{cli-5v6b2am8.js → cli-7kv5d674.js} +7 -7
- package/dist/{cli-6r1dwegd.js → cli-80d5g0fa.js} +2 -2
- package/dist/{cli-0xwb7zpt.js → cli-88np9va3.js} +1 -1
- package/dist/{cli-1b5axkt1.js → cli-8m6gqnf1.js} +2 -2
- package/dist/{cli-0a336ze7.js → cli-8pnawt98.js} +3 -3
- package/dist/{cli-7ewre3dm.js → cli-8sayvj48.js} +2 -2
- package/dist/{cli-yeh3g1q6.js → cli-9gmkw6xn.js} +53 -32
- package/dist/{cli-h03j6je3.js → cli-a21cwm89.js} +2 -2
- package/dist/{cli-s6fhqbz1.js → cli-aytna2fm.js} +1 -1
- package/dist/{cli-84xtgbn6.js → cli-b0m3bg0f.js} +100 -2
- package/dist/{cli-mwxez0pz.js → cli-b768ek79.js} +1 -1
- package/dist/{cli-9xx36trj.js → cli-bh53ppqm.js} +2 -2
- package/dist/{cli-1carhg8g.js → cli-czeh7x13.js} +3 -3
- package/dist/{cli-cd9acnvd.js → cli-djwt4mtn.js} +71 -5
- package/dist/{cli-sfajkbd7.js → cli-dq30fq3q.js} +2 -2
- package/dist/{cli-a8ts6x1n.js → cli-dw43pnzp.js} +5 -5
- package/dist/{cli-h9bejmkf.js → cli-e4gx499y.js} +52 -29
- package/dist/{cli-t90k0phh.js → cli-ea367bdn.js} +32 -23
- package/dist/{cli-cmgdptmx.js → cli-ef590376.js} +29 -5
- package/dist/{cli-8rbkw18r.js → cli-fbmgpt72.js} +2 -2
- package/dist/{cli-tzzas8rb.js → cli-g4dhd3pr.js} +2 -2
- package/dist/{cli-snypfjgj.js → cli-gc715jrc.js} +1 -1
- package/dist/{cli-c0tyzt73.js → cli-gkjw33x5.js} +1 -1
- package/dist/{cli-z6m6xzxt.js → cli-grk77aen.js} +26 -5
- package/dist/{cli-hs3mqswp.js → cli-gxqwm3k3.js} +5 -5
- package/dist/{cli-4h90xaet.js → cli-h3drhntp.js} +1 -1
- package/dist/{cli-qn79645p.js → cli-h9d3sdnc.js} +1 -1
- package/dist/{cli-byxsctca.js → cli-hd2a204w.js} +6 -6
- package/dist/{cli-1dr5at77.js → cli-hhb8kbwd.js} +12 -12
- package/dist/{cli-zvpkrgsc.js → cli-hpxcfvdm.js} +3 -3
- package/dist/{cli-cqxwjb93.js → cli-hxj888w3.js} +1 -1
- package/dist/{cli-82j36f2m.js → cli-jjzxsk47.js} +9 -3
- package/dist/{cli-13t0smbk.js → cli-ka4tqjzd.js} +185 -58
- package/dist/{cli-jhtvt7gn.js → cli-kh973792.js} +3 -3
- package/dist/{cli-x5yb8zc8.js → cli-kwm1bek7.js} +1 -1
- package/dist/{cli-bjmq14k9.js → cli-mgr3gatr.js} +4 -4
- package/dist/{cli-c8kqmzzf.js → cli-nbawx3s0.js} +2 -2
- package/dist/{cli-04103ryh.js → cli-ppf9ap9n.js} +1 -1
- package/dist/{cli-dd57p1gd.js → cli-pzsedyb0.js} +4 -4
- package/dist/{cli-32xndx6b.js → cli-r6xnchva.js} +2 -2
- package/dist/{cli-4tbvndmm.js → cli-r8ddn0hf.js} +1 -1
- package/dist/{cli-y6qqbpwc.js → cli-snwz16eg.js} +1 -1
- package/dist/{cli-w24f3j49.js → cli-sy2ge2ye.js} +7 -6
- package/dist/{cli-3m8vqehw.js → cli-syqcny89.js} +3 -3
- package/dist/{cli-qx1dwrr5.js → cli-tjf1bh1v.js} +2 -2
- package/dist/{cli-xhkek467.js → cli-v1v49t36.js} +28 -2
- package/dist/{cli-cn6fpa1p.js → cli-v8rpjrnx.js} +1 -1
- package/dist/{cli-mmw2sjaf.js → cli-vgh5adn9.js} +5 -5
- package/dist/{cli-3zyme1wt.js → cli-w24741sm.js} +3 -3
- package/dist/{cli-gq6qhmrr.js → cli-wsnradtk.js} +3 -3
- package/dist/{cli-nk8swfpx.js → cli-wtffytm8.js} +3 -3
- package/dist/{cli-0m77n7ej.js → cli-xc8m5cjn.js} +54 -12
- package/dist/{cli-8cmjkbvj.js → cli-y0q92v4r.js} +2 -2
- package/dist/{cli-gedf48yw.js → cli-y754psdt.js} +4 -4
- package/dist/cli.js +19 -18
- package/dist/{codex-adapter-ysfg6ty3.js → codex-adapter-493vb8cv.js} +5 -5
- package/dist/{codex-hook-c0nvm30r.js → codex-hook-ej8hn6z5.js} +9 -2
- package/dist/{codex-session-runner-823scr6g.js → codex-session-runner-ps5m4z1g.js} +5 -5
- package/dist/{commands-5rbm07fz.js → commands-shktk0b8.js} +3 -3
- package/dist/{controllers-connect-34jzhfft.js → controllers-connect-yft057ws.js} +24 -24
- package/dist/core-nheayfgm.js +42 -0
- package/dist/{cursor-adapter-w1681kp1.js → cursor-adapter-8fpm4dng.js} +1 -1
- package/dist/{db-6bkgbfwk.js → db-0ezhdhz5.js} +3 -3
- package/dist/{db-hcj16x7z.js → db-84pz2w5c.js} +2 -2
- package/dist/{dispatcher-jgjqrfzv.js → dispatcher-h2rz69f6.js} +23 -23
- package/dist/{easter-egg-3d-w17nsny6.js → easter-egg-3d-m41ad78v.js} +1 -1
- package/dist/{embedding-space-v06fwy7b.js → embedding-space-yam9zwzj.js} +6 -6
- package/dist/{embeddings-g50dxea4.js → embeddings-g2be0y8q.js} +1 -1
- package/dist/{execute-1n36haw1.js → execute-hhdejgzf.js} +1 -1
- package/dist/{external-channel-43tv8pg6.js → external-channel-kjt2yzfj.js} +2 -2
- package/dist/fx-adapter-8g7xsp8q.js +20 -0
- package/dist/{grok-adapter-my5j8mdf.js → grok-adapter-ztk2zkz1.js} +9 -9
- package/dist/handlers-9ywssz71.js +41 -0
- package/dist/{heartbeat-sf3nk937.js → heartbeat-2e5jdexj.js} +25 -25
- package/dist/{hook-dqph1e05.js → hook-34s8cmgn.js} +9 -6
- package/dist/{hook-m1m9dm6w.js → hook-acg9saz7.js} +8 -5
- package/dist/{http-w0th1cz9.js → http-ra2zr2f8.js} +304 -111
- package/dist/{index-pb03vans.js → index-2z1z7qx6.js} +26 -26
- package/dist/{index-p2f5xg64.js → index-3j803vnb.js} +36259 -34299
- package/dist/index-6mgbdtv1.js +44 -0
- package/dist/{index-e8pz8qdg.js → index-7dgxveck.js} +2 -2
- package/dist/{index-gkpfgpg7.js → index-93bw5wds.js} +1 -1
- package/dist/{index-c0e8en64.js → index-9q42cr54.js} +1 -1
- package/dist/{index-ffba0z8q.js → index-9r4j0a60.js} +28 -18
- package/dist/index-hqdsn2t2.js +39 -0
- package/dist/{index-k8ajc0g0.js → index-maddg9ys.js} +1 -1
- package/dist/{index-y4vd4mhn.js → index-mbpxhc4w.js} +1 -1
- package/dist/index-rz8ve510.js +569 -0
- package/dist/index-st231bqv.js +40 -0
- package/dist/{index-ez823q84.js → index-ym9fgxad.js} +1 -1
- package/dist/{keepalive-2v06q2e8.js → keepalive-vjnnqbkm.js} +4 -4
- package/dist/lead-mk0xkth2.js +82 -0
- package/dist/{maintenance-vx7vjhhy.js → maintenance-px2g599e.js} +1 -1
- package/dist/{oauth-refresh-sweep-g06k4bza.js → oauth-refresh-sweep-nkykf09m.js} +3 -3
- package/dist/{object-webhooks-3dzdq4fm.js → object-webhooks-gt9xnq21.js} +7 -7
- package/dist/{onboard-232pazny.js → onboard-1f134p65.js} +3 -3
- package/dist/{opencode-adapter-t0paqbh8.js → opencode-adapter-94976yab.js} +6 -6
- package/dist/{otel-impl-kmpkyp4y.js → otel-impl-5d4p2fqs.js} +1 -1
- package/dist/{pending-x0z3vx1x.js → pending-vkk0vx6n.js} +24 -24
- package/dist/{pi-mono-adapter-7pmypn6d.js → pi-mono-adapter-cyzdv5er.js} +11 -11
- package/dist/{pricing-refresh-ytjmtyd7.js → pricing-refresh-jtmjwss9.js} +2 -2
- package/dist/{rbac-roles-xyaxekh3.js → rbac-roles-1fvmdyeb.js} +2 -2
- package/dist/{rbac-roles-fgm5mxr2.js → rbac-roles-yd1fgpsn.js} +3 -3
- package/dist/{render-v2-ws972g4r.js → render-v2-kb5s3vx4.js} +8 -8
- package/dist/{resume-m6mjzhkp.js → resume-z1vs44n5.js} +11 -11
- package/dist/{runtime-zzpc0c8a.js → runtime-gk6ct7r7.js} +1 -1
- package/dist/{session-access-vp35xs91.js → session-access-nz6nre4d.js} +5 -5
- package/dist/{session-source-backfill-p73e8zbe.js → session-source-backfill-wb60zjkd.js} +1 -1
- package/dist/{setup-r4kd7rxg.js → setup-2x8g8j4s.js} +1 -1
- package/dist/thread-buffer-d50rqpev.js +42 -0
- package/dist/{tree-visibility-07h2tbs2.js → tree-visibility-ts3z30kw.js} +2 -2
- package/dist/{user-merge-jobs-96vg9rpe.js → user-merge-jobs-zetg26e0.js} +3 -3
- package/dist/{virtual-modules-vgn3f2x4.js → virtual-modules-674fka8x.js} +3 -3
- package/dist/{work-objects-74hbcx3e.js → work-objects-w52yyjxm.js} +26 -26
- package/dist/worker-662x1vse.js +82 -0
- package/dist/{worker-follow-up-ezavwn5d.js → worker-follow-up-dyfxyjbj.js} +23 -23
- package/openapi.json +6 -2
- package/package.json +7 -6
- package/src/be/migrations/341_user_token_expiry.sql +4 -0
- package/src/be/scripts/run-credential.ts +55 -1
- package/src/be/scripts/typecheck.ts +4 -4
- package/src/be/scripts/user-code-mode.ts +160 -0
- package/src/be/users.ts +48 -7
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +62 -6
- package/src/hooks/codex-hook.ts +15 -4
- package/src/hooks/hook.ts +7 -0
- package/src/http/script-connection-proxy.ts +18 -6
- package/src/http/scripts.ts +2 -11
- package/src/http/session-cost-recompute.ts +3 -1
- package/src/http/session-data.ts +3 -0
- package/src/http/users.ts +1 -0
- package/src/integrations/chat-sdk/adapters.ts +29 -0
- package/src/integrations/chat-sdk/limits.ts +3 -0
- package/src/integrations/chat-sdk/rocketchat/README.md +8 -0
- package/src/integrations/chat-sdk/rocketchat/index.ts +790 -0
- package/src/integrations/chat-sdk/rocketchat/markdown.ts +210 -0
- package/src/integrations/chat-sdk/rocketchat/types.ts +249 -0
- package/src/integrations/chat-sdk/runtime.ts +11 -5
- package/src/integrations/chat-sdk/schema.ts +37 -3
- package/src/integrations/chat-sdk/status.ts +9 -0
- package/src/prompts/base-prompt.ts +1 -1
- package/src/prompts/session-templates.ts +1 -1
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +21 -1
- package/src/providers/claude-sdk-session.ts +22 -3
- package/src/providers/claude-session-events.ts +76 -1
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/providers/fx-adapter.ts +2 -2
- package/src/providers/pricing-sources.md +3 -0
- package/src/providers/types.ts +13 -0
- package/src/rbac/legacy-policy.ts +1 -0
- package/src/rbac/permissions.ts +4 -0
- package/src/scripts-runtime/executors/native.ts +225 -67
- package/src/scripts-runtime/mcp-client.ts +2 -1
- package/src/scripts-runtime/swarm-sdk.ts +2 -1
- package/src/scripts-runtime/types/stdlib.d.ts +4 -4
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -4
- package/src/server-user.ts +98 -0
- package/src/slack/render-v2.ts +27 -7
- package/src/tests/base-prompt.test.ts +6 -2
- package/src/tests/chat-sdk-rocketchat-vendored.test.ts +67 -0
- package/src/tests/chat-sdk-status-route.test.ts +13 -1
- package/src/tests/claude-adapter.test.ts +115 -0
- package/src/tests/codex-app-server.test.ts +4 -6
- package/src/tests/fixtures/fx/acp-updates-recorded.jsonl +1 -1
- package/src/tests/internal-ai/complete-structured.test.ts +105 -0
- package/src/tests/internal-ai/credentials.test.ts +149 -0
- package/src/tests/internal-ai/task-title.test.ts +78 -0
- package/src/tests/mcp-input-caps.test.ts +16 -11
- package/src/tests/mcp-user-route.test.ts +10 -1
- package/src/tests/runner-slot-reconcile.test.ts +102 -0
- package/src/tests/script-connections-mcp.test.ts +14 -10
- package/src/tests/script-connections-sql.test.ts +6 -2
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/slack-render-v2.test.ts +85 -0
- package/src/tools/script-common.ts +37 -22
- package/src/tools/script-query-types.ts +1 -1
- package/src/tools/script-run.ts +1 -1
- package/src/tools/script-search.ts +12 -10
- package/src/tools/utils.ts +7 -1
- package/src/types.ts +2 -1
- package/src/utils/internal-ai/complete-structured.ts +36 -5
- package/src/utils/internal-ai/credentials.ts +78 -2
- package/src/utils/internal-ai/models.ts +37 -1
- package/src/utils/internal-ai/task-title.ts +31 -1
- package/templates/skills/chat-sdk/content.md +2 -2
- package/templates/skills/swarm-docs/content.md +10 -0
- package/dist/acp-adapter-xtj40wd8.js +0 -17
- package/dist/core-kdehq26g.js +0 -42
- package/dist/fx-adapter-bvh05t4a.js +0 -20
- package/dist/handlers-wyymeeqh.js +0 -41
- package/dist/index-22khdtby.js +0 -44
- package/dist/index-np0582ac.js +0 -40
- package/dist/index-vgkrj1jt.js +0 -39
- package/dist/lead-55z813ng.js +0 -79
- package/dist/thread-buffer-cm2nzq6t.js +0 -42
- package/dist/worker-5pn2vzx6.js +0 -79
- /package/dist/{cli-m4ejz4nj.js → cli-cah298e5.js} +0 -0
|
@@ -847,25 +847,25 @@ declare module "swarm-sdk" {
|
|
|
847
847
|
// --- write: chat sdk ---
|
|
848
848
|
chat_reply(args: { text?: string; card?: unknown }): Promise<unknown>;
|
|
849
849
|
chat_post(args: {
|
|
850
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
850
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
851
851
|
threadId?: string;
|
|
852
852
|
channelId?: string;
|
|
853
853
|
text?: string;
|
|
854
854
|
card?: unknown;
|
|
855
855
|
}): Promise<unknown>;
|
|
856
856
|
chat_openDm(args: {
|
|
857
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
857
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
858
858
|
userId: string;
|
|
859
859
|
}): Promise<unknown>;
|
|
860
860
|
chat_registerChannel(args: {
|
|
861
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
861
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
862
862
|
channelId: string;
|
|
863
863
|
agentId?: string;
|
|
864
864
|
workflowId?: string;
|
|
865
865
|
name?: string;
|
|
866
866
|
}): Promise<unknown>;
|
|
867
867
|
chat_unregisterChannel(args: {
|
|
868
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
868
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
869
869
|
channelId: string;
|
|
870
870
|
}): Promise<unknown>;
|
|
871
871
|
|
|
@@ -805,25 +805,25 @@ declare module "swarm-sdk" {
|
|
|
805
805
|
// --- write: chat sdk ---
|
|
806
806
|
chat_reply(args: { text?: string; card?: unknown }): Promise<unknown>;
|
|
807
807
|
chat_post(args: {
|
|
808
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
808
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
809
809
|
threadId?: string;
|
|
810
810
|
channelId?: string;
|
|
811
811
|
text?: string;
|
|
812
812
|
card?: unknown;
|
|
813
813
|
}): Promise<unknown>;
|
|
814
814
|
chat_openDm(args: {
|
|
815
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
815
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
816
816
|
userId: string;
|
|
817
817
|
}): Promise<unknown>;
|
|
818
818
|
chat_registerChannel(args: {
|
|
819
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
819
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
820
820
|
channelId: string;
|
|
821
821
|
agentId?: string;
|
|
822
822
|
workflowId?: string;
|
|
823
823
|
name?: string;
|
|
824
824
|
}): Promise<unknown>;
|
|
825
825
|
chat_unregisterChannel(args: {
|
|
826
|
-
adapter: "telegram" | "slack" | "discord" | "teams";
|
|
826
|
+
adapter: "telegram" | "slack" | "discord" | "teams" | "rocketchat";
|
|
827
827
|
channelId: string;
|
|
828
828
|
}): Promise<unknown>;
|
|
829
829
|
|
package/src/server-user.ts
CHANGED
|
@@ -6,6 +6,12 @@ import { isMcpUserEventsEnabled } from "./be/mcp-events/catalog";
|
|
|
6
6
|
import { registerUserEvents } from "./be/mcp-events/protocol";
|
|
7
7
|
import { enqueueAdmissionRow } from "./be/rbac-audit";
|
|
8
8
|
import { getUserGrant } from "./be/rbac-roles";
|
|
9
|
+
import {
|
|
10
|
+
runScriptForUser,
|
|
11
|
+
scriptTypesForUser,
|
|
12
|
+
searchScriptsForUser,
|
|
13
|
+
type UserCodeModeResponse,
|
|
14
|
+
} from "./be/scripts/user-code-mode";
|
|
9
15
|
import { MCP_MAX_TOOL_INPUT_ELEMENTS } from "./mcp-limits";
|
|
10
16
|
import {
|
|
11
17
|
type AdmissionRbac,
|
|
@@ -24,6 +30,14 @@ import {
|
|
|
24
30
|
getTaskDetailsOutputSchema,
|
|
25
31
|
} from "./tools/get-task-details";
|
|
26
32
|
import { getTasksHandler, getTasksInputSchema, getTasksOutputSchema } from "./tools/get-tasks";
|
|
33
|
+
import {
|
|
34
|
+
scriptNameSchema,
|
|
35
|
+
scriptsApiToolResult,
|
|
36
|
+
scriptToolOutputSchema,
|
|
37
|
+
} from "./tools/script-common";
|
|
38
|
+
import { renderTypeBlobs } from "./tools/script-query-types";
|
|
39
|
+
import { renderRunOutput } from "./tools/script-run";
|
|
40
|
+
import { renderSearchResults, searchSuccessMessage } from "./tools/script-search";
|
|
27
41
|
import { checkOutputSchemaShape, sendTaskHandler, sendTaskOutputSchema } from "./tools/send-task";
|
|
28
42
|
import {
|
|
29
43
|
steerTaskHandler,
|
|
@@ -68,6 +82,17 @@ export const userSendTaskInputSchema = z
|
|
|
68
82
|
})
|
|
69
83
|
.superRefine((data, ctx) => checkOutputSchemaShape(data.outputSchema, ctx));
|
|
70
84
|
|
|
85
|
+
const USER_CODE_MODE_SCOPE =
|
|
86
|
+
"Runs as you: the script's swarm calls carry your permissions, no agent's credentials or connections, and no task is created. Only global scripts are visible.";
|
|
87
|
+
|
|
88
|
+
function codeModeResult(
|
|
89
|
+
response: UserCodeModeResponse,
|
|
90
|
+
rendering: Parameters<typeof scriptsApiToolResult>[2],
|
|
91
|
+
): SwarmToolResult {
|
|
92
|
+
const ok = response.status >= 200 && response.status < 300;
|
|
93
|
+
return scriptsApiToolResult(response.body, { ok, status: response.status }, rendering);
|
|
94
|
+
}
|
|
95
|
+
|
|
71
96
|
function permission(verb: PermissionVerb): AdmissionRbac {
|
|
72
97
|
return { permission: verb };
|
|
73
98
|
}
|
|
@@ -190,6 +215,79 @@ export function createUserServer(user: User, tokenId?: string): McpServer {
|
|
|
190
215
|
return cancelTaskHandler(userCtx(user, info.sessionId), args);
|
|
191
216
|
});
|
|
192
217
|
|
|
218
|
+
// Code mode: the agent-side script-search / script-query-types / script-run,
|
|
219
|
+
// scoped to the user (see src/be/scripts/user-code-mode.ts).
|
|
220
|
+
const scriptSearchConfig = {
|
|
221
|
+
title: "Script Search",
|
|
222
|
+
description: `Search the swarm's reusable TypeScript scripts by intent. ${USER_CODE_MODE_SCOPE}`,
|
|
223
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
224
|
+
rbac: permission("script.search"),
|
|
225
|
+
inputSchema: z.object({
|
|
226
|
+
query: z.string().default("").describe("What the script should do."),
|
|
227
|
+
limit: z.number().int().min(1).max(100).default(10).describe("Maximum results."),
|
|
228
|
+
}),
|
|
229
|
+
outputSchema: scriptToolOutputSchema,
|
|
230
|
+
};
|
|
231
|
+
registerTool("script-search", scriptSearchConfig, async (args) => {
|
|
232
|
+
const denied = await maybeDenyUserToolAdmission(user, "script-search", scriptSearchConfig);
|
|
233
|
+
if (denied) return denied;
|
|
234
|
+
return codeModeResult(await searchScriptsForUser(args), {
|
|
235
|
+
successMessage: searchSuccessMessage,
|
|
236
|
+
successDetails: renderSearchResults,
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Not `script-query-types`: this name is exempt from the result-size spill
|
|
241
|
+
// (CTX_CONTROL_EXEMPT_TOOLS), since a user has no kv to read a spill back from.
|
|
242
|
+
const scriptGetTypesConfig = {
|
|
243
|
+
title: "Script Get Types",
|
|
244
|
+
description: `Get the TypeScript declarations a script is written against: the \`swarm-sdk\` module (\`ScriptContext\`, \`ctx.swarm\`) and the \`stdlib\` module, about 12k tokens. Pass \`name\` to also get that script's signature and args schema. ${USER_CODE_MODE_SCOPE}`,
|
|
245
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
246
|
+
inputSchema: z.object({
|
|
247
|
+
name: scriptNameSchema.optional().describe("Optional global script name."),
|
|
248
|
+
}),
|
|
249
|
+
outputSchema: scriptToolOutputSchema,
|
|
250
|
+
};
|
|
251
|
+
registerTool("script-get-types", scriptGetTypesConfig, async ({ name }) => {
|
|
252
|
+
const denied = await maybeDenyUserToolAdmission(user, "script-get-types", scriptGetTypesConfig);
|
|
253
|
+
if (denied) return denied;
|
|
254
|
+
const response = await scriptTypesForUser(name);
|
|
255
|
+
const { stdlibTypes: _types, ...small } = response.body as Record<string, unknown>;
|
|
256
|
+
return codeModeResult(
|
|
257
|
+
// The declarations go out once, in details; data keeps only the small fields.
|
|
258
|
+
{ status: response.status, body: small },
|
|
259
|
+
{
|
|
260
|
+
successMessage: () =>
|
|
261
|
+
name
|
|
262
|
+
? `Type definitions for script \`${name}\` fetched.`
|
|
263
|
+
: "Script type definitions fetched.",
|
|
264
|
+
successDetails: () => renderTypeBlobs(response.body),
|
|
265
|
+
uncappedDetails: true,
|
|
266
|
+
},
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const scriptRunConfig = {
|
|
271
|
+
title: "Script Run",
|
|
272
|
+
description: `Run a global script by \`name\`, or inline TypeScript \`source\` that does \`export default async function (args, ctx)\`. Inline source is not typechecked or saved. ${USER_CODE_MODE_SCOPE}`,
|
|
273
|
+
annotations: { openWorldHint: true },
|
|
274
|
+
rbac: permission("script.run"),
|
|
275
|
+
inputSchema: z.object({
|
|
276
|
+
name: scriptNameSchema.optional().describe("Global script to run."),
|
|
277
|
+
source: z.string().min(1).optional().describe("Inline TypeScript source to run."),
|
|
278
|
+
args: z.unknown().optional().describe("JSON-serializable script arguments."),
|
|
279
|
+
}),
|
|
280
|
+
outputSchema: scriptToolOutputSchema,
|
|
281
|
+
};
|
|
282
|
+
registerTool("script-run", scriptRunConfig, async (args) => {
|
|
283
|
+
const denied = await maybeDenyUserToolAdmission(user, "script-run", scriptRunConfig);
|
|
284
|
+
if (denied) return denied;
|
|
285
|
+
return codeModeResult(await runScriptForUser({ userId: user.id, ...args }), {
|
|
286
|
+
successMessage: () => "Script run completed.",
|
|
287
|
+
successDetails: renderRunOutput,
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
193
291
|
if (isSteeringEnabled()) {
|
|
194
292
|
const steerTaskConfig = {
|
|
195
293
|
title: "Steer Task",
|
package/src/slack/render-v2.ts
CHANGED
|
@@ -342,9 +342,29 @@ async function clearAssistantStatus(
|
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
/**
|
|
346
|
+
* A Slack timing window from the environment, or `fallback` when the configured
|
|
347
|
+
* value is not a finite number greater than zero. `Number(raw) || fallback` is
|
|
348
|
+
* not enough: it lets a negative or `Infinity` value through, and
|
|
349
|
+
* `closureState` compares elapsed time straight against the window, so a
|
|
350
|
+
* negative one settles or times out a closure on its very first tick instead of
|
|
351
|
+
* waiting out the window.
|
|
352
|
+
*/
|
|
353
|
+
function positiveEnvNumber(raw: string | undefined, fallback: number): number {
|
|
354
|
+
const value = Number(raw);
|
|
355
|
+
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
356
|
+
}
|
|
357
|
+
|
|
345
358
|
function slackTreeStallMinutes(): number {
|
|
346
|
-
|
|
347
|
-
|
|
359
|
+
return positiveEnvNumber(process.env.SLACK_TREE_STALL_MIN, 15);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function slackConclusionSettleSeconds(): number {
|
|
363
|
+
return positiveEnvNumber(process.env.SLACK_CONCLUSION_SETTLE_SEC, 10);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function slackConclusionTimeoutMinutes(): number {
|
|
367
|
+
return positiveEnvNumber(process.env.SLACK_CONCLUSION_TIMEOUT_MIN, 240);
|
|
348
368
|
}
|
|
349
369
|
|
|
350
370
|
function isStalledMember(task: AgentTask, now: Date): boolean {
|
|
@@ -538,8 +558,8 @@ function normalizeV2Text(value: string): string {
|
|
|
538
558
|
* so "concluded" here means "the engine gave up waiting", not "nothing left".
|
|
539
559
|
*/
|
|
540
560
|
function threadHeaderText(tasks: AgentTask[], now: Date, duration: string): string {
|
|
541
|
-
const settleSec =
|
|
542
|
-
const timeoutMin =
|
|
561
|
+
const settleSec = slackConclusionSettleSeconds();
|
|
562
|
+
const timeoutMin = slackConclusionTimeoutMinutes();
|
|
543
563
|
const asks = tasks.filter((task) => task.source === "slack");
|
|
544
564
|
const timedOut = asks.some(
|
|
545
565
|
(ask) =>
|
|
@@ -1934,7 +1954,7 @@ type RenderPassContext = {
|
|
|
1934
1954
|
* window starts after that.
|
|
1935
1955
|
*/
|
|
1936
1956
|
function slackOutcomeWindow(delegationEnabled: boolean, now = Date.now()): SlackOutcomeWindow {
|
|
1937
|
-
const timeoutMs = (
|
|
1957
|
+
const timeoutMs = slackConclusionTimeoutMinutes() * 60_000;
|
|
1938
1958
|
const windowMs = Math.max(timeoutMs, 60 * 60_000);
|
|
1939
1959
|
return {
|
|
1940
1960
|
finishedAfter: new Date(now - windowMs).toISOString(),
|
|
@@ -1984,8 +2004,8 @@ async function processSlackThread(
|
|
|
1984
2004
|
) {
|
|
1985
2005
|
return "closed";
|
|
1986
2006
|
}
|
|
1987
|
-
const settleSec =
|
|
1988
|
-
const timeoutMin =
|
|
2007
|
+
const settleSec = slackConclusionSettleSeconds();
|
|
2008
|
+
const timeoutMin = slackConclusionTimeoutMinutes();
|
|
1989
2009
|
const closuresByAskId = new Map<string, AgentTask[]>();
|
|
1990
2010
|
const ownerAskId = new Map<string, string>();
|
|
1991
2011
|
if (delegationEnabled) {
|
|
@@ -1491,7 +1491,7 @@ describe("getBasePrompt: harness tool discovery", () => {
|
|
|
1491
1491
|
expect(result).toContain('import { store_progress } from "agent-swarm"');
|
|
1492
1492
|
});
|
|
1493
1493
|
|
|
1494
|
-
test("fx gets
|
|
1494
|
+
test("fx gets toolbox guidance with mcp_swarm_ tool names", async () => {
|
|
1495
1495
|
const result = await getBasePrompt({
|
|
1496
1496
|
...minimalArgs,
|
|
1497
1497
|
provider: "fx",
|
|
@@ -1499,7 +1499,11 @@ describe("getBasePrompt: harness tool discovery", () => {
|
|
|
1499
1499
|
});
|
|
1500
1500
|
expect(result).not.toContain(deferred);
|
|
1501
1501
|
expect(result).not.toContain("already in your tool list");
|
|
1502
|
-
|
|
1502
|
+
// fx 0.0.17 removed `capability_search` and rejects a direct call to a
|
|
1503
|
+
// deferred tool; it runs only through `toolbox` with `run` + `arguments`.
|
|
1504
|
+
expect(result).not.toContain("capability_search");
|
|
1505
|
+
expect(result).toContain("deferred behind `toolbox`");
|
|
1506
|
+
expect(result).toContain("call `toolbox` with `run` set to its name and `arguments`");
|
|
1503
1507
|
expect(result).toContain("`store-progress` is `mcp_swarm_store-progress`");
|
|
1504
1508
|
});
|
|
1505
1509
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { NetworkError } from "@chat-adapter/shared";
|
|
3
|
+
import { createRocketChatAdapter } from "../integrations/chat-sdk/rocketchat/index";
|
|
4
|
+
|
|
5
|
+
const WEBHOOK_TOKEN = "rc-outgoing-webhook-token";
|
|
6
|
+
|
|
7
|
+
function adapterFor(baseUrl: string) {
|
|
8
|
+
return createRocketChatAdapter({
|
|
9
|
+
baseUrl,
|
|
10
|
+
token: "rc-personal-access-token",
|
|
11
|
+
botUserId: "rc-bot-user-id",
|
|
12
|
+
webhookToken: WEBHOOK_TOKEN,
|
|
13
|
+
userName: "swarm",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function webhook(token: string | undefined): Request {
|
|
18
|
+
return new Request("http://localhost/webhook", {
|
|
19
|
+
method: "POST",
|
|
20
|
+
body: JSON.stringify({ token, message_id: "m1", channel_id: "room", user_id: "u1", text: "" }),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe("in-repo Rocket.Chat adapter", () => {
|
|
25
|
+
test("loads from the repo with no chat-adapter-rocketchat npm package", async () => {
|
|
26
|
+
expect(() => Bun.resolveSync("chat-adapter-rocketchat", import.meta.dir)).toThrow();
|
|
27
|
+
const pkg = await Bun.file(new URL("../../package.json", import.meta.url)).json();
|
|
28
|
+
expect(pkg.dependencies?.["chat-adapter-rocketchat"]).toBeUndefined();
|
|
29
|
+
expect(adapterFor("https://chat.example.com/").name).toBe("rocketchat");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("the webhook token check rejects a wrong, shorter, longer or missing token", async () => {
|
|
33
|
+
const adapter = adapterFor("https://chat.example.com");
|
|
34
|
+
// No Chat instance is attached, so a valid token answers 200 without processing.
|
|
35
|
+
expect((await adapter.handleWebhook(webhook(WEBHOOK_TOKEN))).status).toBe(200);
|
|
36
|
+
for (const token of ["x".repeat(WEBHOOK_TOKEN.length), "short", `${WEBHOOK_TOKEN}-x`, ""]) {
|
|
37
|
+
expect((await adapter.handleWebhook(webhook(token))).status).toBe(401);
|
|
38
|
+
}
|
|
39
|
+
expect((await adapter.handleWebhook(webhook(undefined))).status).toBe(401);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("the auth token never follows a redirect to another origin", async () => {
|
|
43
|
+
const seen: Array<string | null> = [];
|
|
44
|
+
const foreign = Bun.serve({
|
|
45
|
+
port: 0,
|
|
46
|
+
fetch(request) {
|
|
47
|
+
seen.push(request.headers.get("x-auth-token"));
|
|
48
|
+
return Response.json({ success: true, message: { _id: "m1" } });
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
const instance = Bun.serve({
|
|
52
|
+
port: 0,
|
|
53
|
+
fetch: () =>
|
|
54
|
+
Response.redirect(`http://127.0.0.1:${foreign.port}/api/v1/chat.postMessage`, 307),
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
const adapter = adapterFor(`http://localhost:${instance.port}`);
|
|
58
|
+
await expect(
|
|
59
|
+
adapter.postMessage("rocketchat:room", { markdown: "hi" }),
|
|
60
|
+
).rejects.toBeInstanceOf(NetworkError);
|
|
61
|
+
expect(seen).toEqual([]);
|
|
62
|
+
} finally {
|
|
63
|
+
instance.stop(true);
|
|
64
|
+
foreign.stop(true);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -175,7 +175,13 @@ describe("GET /api/integrations/chat/status", () => {
|
|
|
175
175
|
expect(body.enabled).toBe(true);
|
|
176
176
|
expect(body.slackClash).toBe(false);
|
|
177
177
|
const byName = Object.fromEntries(body.adapters.map((a) => [a.name, a]));
|
|
178
|
-
expect(Object.keys(byName).sort()).toEqual([
|
|
178
|
+
expect(Object.keys(byName).sort()).toEqual([
|
|
179
|
+
"discord",
|
|
180
|
+
"rocketchat",
|
|
181
|
+
"slack",
|
|
182
|
+
"teams",
|
|
183
|
+
"telegram",
|
|
184
|
+
]);
|
|
179
185
|
|
|
180
186
|
expect(byName.telegram).toMatchObject({
|
|
181
187
|
configured: true,
|
|
@@ -201,6 +207,12 @@ describe("GET /api/integrations/chat/status", () => {
|
|
|
201
207
|
webhookUrl: `${PUBLIC_URL}/api/integrations/chat/discord/webhook`,
|
|
202
208
|
});
|
|
203
209
|
expect(byName.teams).toMatchObject({ configured: false, health: "disabled", connected: false });
|
|
210
|
+
expect(byName.rocketchat).toMatchObject({
|
|
211
|
+
configured: false,
|
|
212
|
+
health: "disabled",
|
|
213
|
+
connected: false,
|
|
214
|
+
webhookUrl: `${PUBLIC_URL}/api/integrations/chat/rocketchat/webhook`,
|
|
215
|
+
});
|
|
204
216
|
});
|
|
205
217
|
|
|
206
218
|
test("flags the Slack clash when SLACK_DISABLE is not true", async () => {
|
|
@@ -426,6 +426,121 @@ describe("ClaudeSession processStreams — ProviderResult.output capture", () =>
|
|
|
426
426
|
expect(result.output).toBeUndefined();
|
|
427
427
|
});
|
|
428
428
|
|
|
429
|
+
test("a session that ends without a result reports per-message usage as an estimated cost", async () => {
|
|
430
|
+
const usageA = {
|
|
431
|
+
input_tokens: 10,
|
|
432
|
+
output_tokens: 5,
|
|
433
|
+
cache_read_input_tokens: 100,
|
|
434
|
+
cache_creation_input_tokens: 50,
|
|
435
|
+
cache_creation: { ephemeral_5m_input_tokens: 20, ephemeral_1h_input_tokens: 30 },
|
|
436
|
+
};
|
|
437
|
+
const lines = [
|
|
438
|
+
JSON.stringify({ type: "system", subtype: "init", session_id: "sess-1" }),
|
|
439
|
+
// One API message split over two lines: its usage counts once.
|
|
440
|
+
JSON.stringify({
|
|
441
|
+
type: "assistant",
|
|
442
|
+
message: { id: "msg-a", model: "claude-sonnet-5-5", content: [], usage: usageA },
|
|
443
|
+
}),
|
|
444
|
+
JSON.stringify({
|
|
445
|
+
type: "assistant",
|
|
446
|
+
message: { id: "msg-a", model: "claude-sonnet-5-5", content: [], usage: usageA },
|
|
447
|
+
}),
|
|
448
|
+
JSON.stringify({
|
|
449
|
+
type: "assistant",
|
|
450
|
+
message: {
|
|
451
|
+
id: "msg-b",
|
|
452
|
+
model: "claude-sonnet-5-5",
|
|
453
|
+
content: [],
|
|
454
|
+
usage: { input_tokens: 1, output_tokens: 7, cache_read_input_tokens: 200 },
|
|
455
|
+
},
|
|
456
|
+
}),
|
|
457
|
+
// A subagent on another model is billed too.
|
|
458
|
+
JSON.stringify({
|
|
459
|
+
type: "assistant",
|
|
460
|
+
parent_tool_use_id: "tool-1",
|
|
461
|
+
message: {
|
|
462
|
+
id: "msg-c",
|
|
463
|
+
model: "claude-haiku-4-5",
|
|
464
|
+
content: [],
|
|
465
|
+
usage: { input_tokens: 3, output_tokens: 4 },
|
|
466
|
+
},
|
|
467
|
+
}),
|
|
468
|
+
// Claude's local error message carries zero usage and is dropped.
|
|
469
|
+
JSON.stringify({
|
|
470
|
+
type: "assistant",
|
|
471
|
+
message: {
|
|
472
|
+
id: "msg-d",
|
|
473
|
+
model: "<synthetic>",
|
|
474
|
+
content: [],
|
|
475
|
+
usage: { input_tokens: 0, output_tokens: 0 },
|
|
476
|
+
},
|
|
477
|
+
}),
|
|
478
|
+
];
|
|
479
|
+
spawnSpy.mockImplementation((() => makeStreamingFakeProc(lines)) as typeof Bun.spawn);
|
|
480
|
+
|
|
481
|
+
const adapter = new ClaudeAdapter(async () => {});
|
|
482
|
+
const session = await adapter.createSession(makeConfig({ env: CLEAN_ENV }));
|
|
483
|
+
const result = await session.waitForCompletion();
|
|
484
|
+
|
|
485
|
+
expect(result.cost).toMatchObject({
|
|
486
|
+
totalCostUsd: 0,
|
|
487
|
+
estimated: true,
|
|
488
|
+
provider: "claude",
|
|
489
|
+
numTurns: null,
|
|
490
|
+
inputTokens: 14,
|
|
491
|
+
outputTokens: 16,
|
|
492
|
+
cacheReadTokens: 300,
|
|
493
|
+
cacheWriteTokens: 50,
|
|
494
|
+
cacheWrite5mTokens: 20,
|
|
495
|
+
cacheWrite1hTokens: 30,
|
|
496
|
+
models: [
|
|
497
|
+
{
|
|
498
|
+
model: "claude-sonnet-5-5",
|
|
499
|
+
inputTokens: 11,
|
|
500
|
+
outputTokens: 12,
|
|
501
|
+
cacheReadTokens: 300,
|
|
502
|
+
cacheWriteTokens: 50,
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
model: "claude-haiku-4-5",
|
|
506
|
+
inputTokens: 3,
|
|
507
|
+
outputTokens: 4,
|
|
508
|
+
cacheReadTokens: 0,
|
|
509
|
+
cacheWriteTokens: 0,
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
test("the result event's cost wins over the per-message estimate", async () => {
|
|
516
|
+
const lines = [
|
|
517
|
+
JSON.stringify({
|
|
518
|
+
type: "assistant",
|
|
519
|
+
message: { id: "msg-a", content: [], usage: { input_tokens: 10, output_tokens: 5 } },
|
|
520
|
+
}),
|
|
521
|
+
JSON.stringify({ type: "result", total_cost_usd: 0.01, duration_ms: 100, num_turns: 1 }),
|
|
522
|
+
];
|
|
523
|
+
spawnSpy.mockImplementation((() => makeStreamingFakeProc(lines)) as typeof Bun.spawn);
|
|
524
|
+
|
|
525
|
+
const adapter = new ClaudeAdapter(async () => {});
|
|
526
|
+
const session = await adapter.createSession(makeConfig({ env: CLEAN_ENV }));
|
|
527
|
+
const result = await session.waitForCompletion();
|
|
528
|
+
|
|
529
|
+
expect(result.cost?.totalCostUsd).toBe(0.01);
|
|
530
|
+
expect(result.cost?.estimated).toBeUndefined();
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
test("a session with no usage at all reports no cost", async () => {
|
|
534
|
+
const lines = [JSON.stringify({ type: "system", subtype: "init", session_id: "sess-1" })];
|
|
535
|
+
spawnSpy.mockImplementation((() => makeStreamingFakeProc(lines)) as typeof Bun.spawn);
|
|
536
|
+
|
|
537
|
+
const adapter = new ClaudeAdapter(async () => {});
|
|
538
|
+
const session = await adapter.createSession(makeConfig({ env: CLEAN_ENV }));
|
|
539
|
+
const result = await session.waitForCompletion();
|
|
540
|
+
|
|
541
|
+
expect(result.cost).toBeUndefined();
|
|
542
|
+
});
|
|
543
|
+
|
|
429
544
|
test("result cost includes Claude cache TTL split and complete per-model usage", async () => {
|
|
430
545
|
const lines = [
|
|
431
546
|
JSON.stringify({
|
|
@@ -226,7 +226,9 @@ describe("CodexAppServer", () => {
|
|
|
226
226
|
|
|
227
227
|
for (const { name, launchOnGateway } of [
|
|
228
228
|
{
|
|
229
|
-
|
|
229
|
+
// Codex <= 0.167 rejected this turn ("your current provider is openai").
|
|
230
|
+
// 0.168+ honors the thread-level provider, so both launches start the turn.
|
|
231
|
+
name: "pinned Codex accepts a gateway turn on an app-server launched without it",
|
|
230
232
|
launchOnGateway: false,
|
|
231
233
|
},
|
|
232
234
|
{
|
|
@@ -267,11 +269,7 @@ describe("CodexAppServer", () => {
|
|
|
267
269
|
threadId: started.thread.id,
|
|
268
270
|
input: [{ type: "text", text: "hi" }],
|
|
269
271
|
});
|
|
270
|
-
|
|
271
|
-
else
|
|
272
|
-
await expect(turn).rejects.toThrow(
|
|
273
|
-
"This chat uses swarm-gateway, but your current provider is openai",
|
|
274
|
-
);
|
|
272
|
+
await turn;
|
|
275
273
|
} finally {
|
|
276
274
|
await server.close();
|
|
277
275
|
await rm(home, { recursive: true, force: true });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{"sessionUpdate":"agent_message_chunk","messageId":"b86bad695b6f80234f85a6ae84770a00","content":{"type":"text","text":"[context] 114 always-loaded MCP tools exceeded the mcp_selected_schema_bytes budget and stay available through
|
|
1
|
+
{"sessionUpdate":"agent_message_chunk","messageId":"b86bad695b6f80234f85a6ae84770a00","content":{"type":"text","text":"[context] 114 always-loaded MCP tools exceeded the mcp_selected_schema_bytes budget and stay available through toolbox"}}
|
|
2
2
|
{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"**Following developer instructions**\n\nI need to ensure I follow the developer's instructions perfectly. First, I’ll send a brief update to the user about the goal and the next step. Then, I’ll call th…"}}
|
|
3
3
|
{"sessionUpdate":"agent_message_chunk","messageId":"e6788e35f07ecb7d4b22767ec6028538","content":{"type":"text","text":"Goal: fetch the swarm agent list with mcp_swarm_get-swarm as the next step, then run the sleep command. I'll call mcp_swarm_get-swarm now."}}
|
|
4
4
|
{"sessionUpdate":"tool_call","toolCallId":"call_kK1rqCaYaXn16uKH9e6fmb7v","name":"mcp_swarm_get-swarm","title":"Get the agent swarm","kind":"other","status":"pending","rawInput":{},"_meta":{"fx":{"toolCall":{"internal":false,"mcp":{"server":"swarm","tool":"get-swarm"}}}}}
|
|
@@ -623,3 +623,108 @@ describe("completeStructuredWithModel", () => {
|
|
|
623
623
|
expect(result).toEqual({ data: { summary: "cli", count: 1 }, model: "haiku" });
|
|
624
624
|
});
|
|
625
625
|
});
|
|
626
|
+
|
|
627
|
+
describe("credential kinds added for fireworks and amazon-bedrock", () => {
|
|
628
|
+
const baseOpts = {
|
|
629
|
+
zodSchema: ResultZodSchema,
|
|
630
|
+
toolSchema: ResultToolSchema,
|
|
631
|
+
toolName: "record_result",
|
|
632
|
+
toolDescription: "Record the result.",
|
|
633
|
+
systemPrompt: "sys",
|
|
634
|
+
userPrompt: "user",
|
|
635
|
+
};
|
|
636
|
+
const toolCallMsg = () =>
|
|
637
|
+
makeMsg([
|
|
638
|
+
{
|
|
639
|
+
type: "toolCall",
|
|
640
|
+
id: "call_1",
|
|
641
|
+
name: "record_result",
|
|
642
|
+
arguments: { summary: "ok", count: 1 },
|
|
643
|
+
},
|
|
644
|
+
]);
|
|
645
|
+
|
|
646
|
+
test("fireworks goes through the pi-ai path with its own key", async () => {
|
|
647
|
+
let seenApiKey: unknown;
|
|
648
|
+
const result = await completeStructuredWithModel({
|
|
649
|
+
...baseOpts,
|
|
650
|
+
_credentialOverride: {
|
|
651
|
+
kind: "fireworks",
|
|
652
|
+
apiKey: "fw-key",
|
|
653
|
+
modelDefault: "fireworks/accounts/fireworks/models/deepseek-v4p1-flash",
|
|
654
|
+
},
|
|
655
|
+
_complete: async (_model, _ctx, options) => {
|
|
656
|
+
seenApiKey = (options as { apiKey?: unknown })?.apiKey;
|
|
657
|
+
return toolCallMsg();
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
expect(result).toEqual({
|
|
661
|
+
data: { summary: "ok", count: 1 },
|
|
662
|
+
model: "fireworks/accounts/fireworks/models/deepseek-v4p1-flash",
|
|
663
|
+
});
|
|
664
|
+
expect(seenApiKey).toBe("fw-key");
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
test("bedrock sends the region, forces the tool, and never sends an apiKey", async () => {
|
|
668
|
+
let options: Record<string, unknown> | undefined;
|
|
669
|
+
let model: { api?: string; id?: string } | undefined;
|
|
670
|
+
const result = await completeStructuredWithModel({
|
|
671
|
+
...baseOpts,
|
|
672
|
+
_credentialOverride: {
|
|
673
|
+
kind: "amazon-bedrock",
|
|
674
|
+
modelDefault: "amazon-bedrock/global.anthropic.claude-haiku-5-5",
|
|
675
|
+
region: "eu-west-1",
|
|
676
|
+
},
|
|
677
|
+
_complete: async (m, _ctx, opts) => {
|
|
678
|
+
model = m as { api?: string; id?: string };
|
|
679
|
+
options = opts as Record<string, unknown>;
|
|
680
|
+
return toolCallMsg();
|
|
681
|
+
},
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
expect(result).toEqual({
|
|
685
|
+
data: { summary: "ok", count: 1 },
|
|
686
|
+
model: "amazon-bedrock/global.anthropic.claude-haiku-5-5",
|
|
687
|
+
});
|
|
688
|
+
// The catalog entry resolves, which is the whole reason the model default is
|
|
689
|
+
// written in pi-ai's own id form.
|
|
690
|
+
expect(model?.api).toBe("bedrock-converse-stream");
|
|
691
|
+
expect(model?.id).toBe("global.anthropic.claude-haiku-5-5");
|
|
692
|
+
expect(options?.apiKey).toBeUndefined();
|
|
693
|
+
// The resolver's region travels as the adapter's own option, which is what
|
|
694
|
+
// keeps the catalog's us-east-1 base URL from overriding it.
|
|
695
|
+
expect(options?.region).toBe("eu-west-1");
|
|
696
|
+
// The adapter needs the tool forced, same as the Anthropic adapter.
|
|
697
|
+
expect(options?.toolChoice).toEqual({ type: "tool", name: "record_result" });
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
test("non-bedrock kinds get no provider-specific options", async () => {
|
|
701
|
+
let options: Record<string, unknown> | undefined;
|
|
702
|
+
await completeStructuredWithModel({
|
|
703
|
+
...baseOpts,
|
|
704
|
+
_credentialOverride: {
|
|
705
|
+
kind: "fireworks",
|
|
706
|
+
apiKey: "fw-key",
|
|
707
|
+
modelDefault: "fireworks/accounts/fireworks/models/deepseek-v4p1-flash",
|
|
708
|
+
},
|
|
709
|
+
_complete: async (_m, _ctx, opts) => {
|
|
710
|
+
options = opts as Record<string, unknown>;
|
|
711
|
+
return toolCallMsg();
|
|
712
|
+
},
|
|
713
|
+
});
|
|
714
|
+
expect(options?.region).toBeUndefined();
|
|
715
|
+
expect(options?.env).toBeUndefined();
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
test("a bedrock catalog miss is a clean null, not a throw", async () => {
|
|
719
|
+
const result = await completeStructuredWithModel({
|
|
720
|
+
...baseOpts,
|
|
721
|
+
_credentialOverride: {
|
|
722
|
+
kind: "amazon-bedrock",
|
|
723
|
+
modelDefault: "amazon-bedrock/not-a-real-model",
|
|
724
|
+
region: "us-east-1",
|
|
725
|
+
},
|
|
726
|
+
_complete: async () => toolCallMsg(),
|
|
727
|
+
});
|
|
728
|
+
expect(result).toBeNull();
|
|
729
|
+
});
|
|
730
|
+
});
|