@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
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rocket.Chat-specific format conversion using AST-based parsing.
|
|
3
|
+
*
|
|
4
|
+
* Rocket.Chat uses a markdown-like format with some differences from
|
|
5
|
+
* standard CommonMark:
|
|
6
|
+
* - Bold: *text* (single asterisk, not double)
|
|
7
|
+
* - Italic: _text_
|
|
8
|
+
* - Strikethrough: ~text~ (single tilde, not double)
|
|
9
|
+
* - Inline code / code fences: standard backtick syntax
|
|
10
|
+
*
|
|
11
|
+
* @see https://docs.rocket.chat/use-rocket.chat/user-guides/messages/markdown
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { normalizeCodeFences } from "@chat-adapter/shared";
|
|
15
|
+
import {
|
|
16
|
+
type AdapterPostableMessage,
|
|
17
|
+
BaseFormatConverter,
|
|
18
|
+
type Content,
|
|
19
|
+
type Delete,
|
|
20
|
+
type Emphasis,
|
|
21
|
+
isTableNode,
|
|
22
|
+
parseMarkdown,
|
|
23
|
+
type Root,
|
|
24
|
+
type Strong,
|
|
25
|
+
stringifyMarkdown,
|
|
26
|
+
type Text,
|
|
27
|
+
tableToAscii,
|
|
28
|
+
walkAst,
|
|
29
|
+
} from "chat";
|
|
30
|
+
|
|
31
|
+
type Handlers = NonNullable<NonNullable<Parameters<typeof stringifyMarkdown>[1]>["handlers"]>;
|
|
32
|
+
type HandleArgs = Parameters<NonNullable<Handlers["text"]>>;
|
|
33
|
+
type State = HandleArgs[2];
|
|
34
|
+
type Info = HandleArgs[3];
|
|
35
|
+
|
|
36
|
+
// Rocket.Chat has no escape syntax, so text stays literal unless it would
|
|
37
|
+
// otherwise turn into formatting.
|
|
38
|
+
const INLINE_PAIRS = {
|
|
39
|
+
"*": /(?:^|[^\p{L}\p{N}])\*(?=\S).*?\S\*(?![\p{L}\p{N}])/mu,
|
|
40
|
+
_: /(?:^|[^\p{L}\p{N}])_(?=\S).*?\S_(?![\p{L}\p{N}])/mu,
|
|
41
|
+
"~": /(?:^|[^\p{L}\p{N}])~(?=\S).*?\S~(?![\p{L}\p{N}])/mu,
|
|
42
|
+
"`": /(?:^|[^\p{L}\p{N}])`(?=\S).*?\S`(?![\p{L}\p{N}])/mu,
|
|
43
|
+
} as const;
|
|
44
|
+
const BLOCK_START = /(^|\n)(?:([>*-])|(\d+)\.)(?= )/g;
|
|
45
|
+
|
|
46
|
+
// Surrounding markers belong to formatting nodes, so they only bound the text.
|
|
47
|
+
function boundary(char: string) {
|
|
48
|
+
return char in INLINE_PAIRS ? " " : char;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function text(node: Text, _parent: unknown, _state: State, info: Info) {
|
|
52
|
+
const { before, after } = info;
|
|
53
|
+
const context = [boundary(before.slice(-1)), boundary(after.charAt(0))];
|
|
54
|
+
let value = node.value;
|
|
55
|
+
for (const [marker, pair] of Object.entries(INLINE_PAIRS)) {
|
|
56
|
+
const touchesMarker =
|
|
57
|
+
(value.startsWith(marker) && before.slice(-1) in INLINE_PAIRS) ||
|
|
58
|
+
(value.endsWith(marker) && after.charAt(0) in INLINE_PAIRS);
|
|
59
|
+
if (
|
|
60
|
+
touchesMarker ||
|
|
61
|
+
(value.includes(marker) && pair.test(`${context[0]}${value}${context[1]}`))
|
|
62
|
+
) {
|
|
63
|
+
value = value.replaceAll(marker, `\\${marker}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return value.replace(
|
|
67
|
+
BLOCK_START,
|
|
68
|
+
(match, lead: string, symbol?: string, digits?: string, offset = 0) => {
|
|
69
|
+
if (offset === 0 && lead === "" && before !== "\n") {
|
|
70
|
+
return match;
|
|
71
|
+
}
|
|
72
|
+
return symbol ? `${lead}\\${symbol}` : `${lead}${digits}\\.`;
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// `peek` keeps lookahead from serializing nested formatting a second time.
|
|
78
|
+
function strong(node: Strong, _parent: unknown, state: State, info: Info) {
|
|
79
|
+
return `*${state.containerPhrasing(node, { ...info, before: "*", after: "*" })}*`;
|
|
80
|
+
}
|
|
81
|
+
strong.peek = () => "*";
|
|
82
|
+
|
|
83
|
+
function emphasis(node: Emphasis, _parent: unknown, state: State, info: Info) {
|
|
84
|
+
return `_${state.containerPhrasing(node, { ...info, before: "_", after: "_" })}_`;
|
|
85
|
+
}
|
|
86
|
+
emphasis.peek = () => "_";
|
|
87
|
+
|
|
88
|
+
function strikethrough(node: Delete, _parent: unknown, state: State, info: Info) {
|
|
89
|
+
return `~${state.containerPhrasing(node, { ...info, before: "~", after: "~" })}~`;
|
|
90
|
+
}
|
|
91
|
+
strikethrough.peek = () => "~";
|
|
92
|
+
|
|
93
|
+
const handlers: Handlers = {
|
|
94
|
+
text,
|
|
95
|
+
strong,
|
|
96
|
+
emphasis,
|
|
97
|
+
delete: strikethrough,
|
|
98
|
+
break: () => "\n",
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export class RocketChatFormatConverter extends BaseFormatConverter {
|
|
102
|
+
/**
|
|
103
|
+
* Convert an AST to Rocket.Chat markdown format.
|
|
104
|
+
*
|
|
105
|
+
* Transforms unsupported nodes (headings, thematic breaks, tables) into
|
|
106
|
+
* Rocket.Chat-compatible equivalents and renders supported formatting
|
|
107
|
+
* directly in Rocket.Chat syntax.
|
|
108
|
+
*/
|
|
109
|
+
fromAst(ast: Root): string {
|
|
110
|
+
const transformed = walkAst(structuredClone(ast), (node: Content) => {
|
|
111
|
+
// Headings -> bold paragraph (flatten nested strong to avoid ***)
|
|
112
|
+
if (node.type === "heading") {
|
|
113
|
+
const heading = node as Content & { children: Content[] };
|
|
114
|
+
const children = heading.children.flatMap((child) =>
|
|
115
|
+
child.type === "strong" ? (child as Content & { children: Content[] }).children : [child],
|
|
116
|
+
);
|
|
117
|
+
return {
|
|
118
|
+
type: "paragraph",
|
|
119
|
+
children: [{ type: "strong", children }],
|
|
120
|
+
} as Content;
|
|
121
|
+
}
|
|
122
|
+
// Thematic breaks -> text separator
|
|
123
|
+
if (node.type === "thematicBreak") {
|
|
124
|
+
return {
|
|
125
|
+
type: "paragraph",
|
|
126
|
+
children: [{ type: "text", value: "━━━" }],
|
|
127
|
+
} as Content;
|
|
128
|
+
}
|
|
129
|
+
// Tables -> code blocks. Rocket.Chat markdown has no native table
|
|
130
|
+
// syntax, so render a fixed-width ASCII table in a code fence.
|
|
131
|
+
if (isTableNode(node)) {
|
|
132
|
+
return {
|
|
133
|
+
type: "code" as const,
|
|
134
|
+
value: tableToAscii(node),
|
|
135
|
+
lang: undefined,
|
|
136
|
+
} as Content;
|
|
137
|
+
}
|
|
138
|
+
return node;
|
|
139
|
+
});
|
|
140
|
+
return stringifyMarkdown(transformed, {
|
|
141
|
+
emphasis: "_",
|
|
142
|
+
bullet: "-",
|
|
143
|
+
handlers,
|
|
144
|
+
}).trim();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Parse Rocket.Chat markdown into an AST.
|
|
149
|
+
*
|
|
150
|
+
* Normalizes Rocket.Chat's ``` fences for CommonMark (the text after the
|
|
151
|
+
* opening fence is code, not an info string) and transforms
|
|
152
|
+
* Rocket.Chat-specific formatting to standard markdown outside the fences,
|
|
153
|
+
* then parses with the standard parser.
|
|
154
|
+
*/
|
|
155
|
+
toAst(markdown: string): Root {
|
|
156
|
+
return parseMarkdown(this.toStandardMarkdown(markdown));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Check the budget against the markdown that `toAst` parses, so the checks
|
|
161
|
+
* see the same code fences as the parser. The length limit still applies to
|
|
162
|
+
* the text as delivered.
|
|
163
|
+
*/
|
|
164
|
+
protected override exceedsIncomingBudget(markdown: string): boolean {
|
|
165
|
+
return (
|
|
166
|
+
markdown.length > this.maxIncomingParseLength ||
|
|
167
|
+
super.exceedsIncomingBudget(this.toStandardMarkdown(markdown))
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private toStandardMarkdown(markdown: string): string {
|
|
172
|
+
return normalizeCodeFences(markdown, {
|
|
173
|
+
convertText: (text) => this.fromRocketChatFormat(text),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Render a postable message to a Rocket.Chat-compatible string.
|
|
179
|
+
*/
|
|
180
|
+
override renderPostable(message: AdapterPostableMessage): string {
|
|
181
|
+
if (typeof message === "string") {
|
|
182
|
+
return message;
|
|
183
|
+
}
|
|
184
|
+
if ("raw" in message) {
|
|
185
|
+
return message.raw;
|
|
186
|
+
}
|
|
187
|
+
if ("markdown" in message) {
|
|
188
|
+
return this.fromMarkdown(message.markdown);
|
|
189
|
+
}
|
|
190
|
+
if ("ast" in message) {
|
|
191
|
+
return this.fromAst(message.ast);
|
|
192
|
+
}
|
|
193
|
+
return super.renderPostable(message);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Convert Rocket.Chat format to standard markdown.
|
|
198
|
+
* Converts single-asterisk bold to double-asterisk bold, and
|
|
199
|
+
* single-tilde strikethrough to double-tilde strikethrough.
|
|
200
|
+
*
|
|
201
|
+
* Careful not to convert _italic_ (which is the same in both formats).
|
|
202
|
+
*/
|
|
203
|
+
private fromRocketChatFormat(text: string): string {
|
|
204
|
+
// Convert *bold* to **bold** (single * not preceded/followed by *, no newlines)
|
|
205
|
+
let result = text.replace(/(?<!\*)\*(?!\*)([^\n*]+?)(?<!\*)\*(?!\*)/g, "**$1**");
|
|
206
|
+
// Convert ~strike~ to ~~strike~~ (single ~ not preceded/followed by ~, no newlines)
|
|
207
|
+
result = result.replace(/(?<!~)~(?!~)([^\n~]+?)(?<!~)~(?!~)/g, "~~$1~~");
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the Rocket.Chat adapter.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Logger } from "chat";
|
|
6
|
+
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Configuration
|
|
9
|
+
// =============================================================================
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the Rocket.Chat adapter.
|
|
13
|
+
*
|
|
14
|
+
* Every field is optional and falls back to an environment variable, so
|
|
15
|
+
* `createRocketChatAdapter()` works with no arguments when the environment
|
|
16
|
+
* is set.
|
|
17
|
+
*/
|
|
18
|
+
export interface RocketChatAdapterConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Rocket.Chat server base URL, without a trailing slash or `/api/v1`
|
|
21
|
+
* suffix (e.g. `https://chat.example.com`).
|
|
22
|
+
* Defaults to the `ROCKETCHAT_URL` env var.
|
|
23
|
+
*/
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* User ID of the bot account, used for the `X-User-Id` REST header and
|
|
27
|
+
* for ignoring the bot's own messages.
|
|
28
|
+
* Defaults to the `ROCKETCHAT_USER_ID` env var.
|
|
29
|
+
*/
|
|
30
|
+
botUserId?: string;
|
|
31
|
+
/** Logger instance for error reporting. Defaults to ConsoleLogger. */
|
|
32
|
+
logger?: Logger;
|
|
33
|
+
/**
|
|
34
|
+
* Personal access token (or login auth token) used for the
|
|
35
|
+
* `X-Auth-Token` REST header.
|
|
36
|
+
* Defaults to the `ROCKETCHAT_TOKEN` env var.
|
|
37
|
+
*/
|
|
38
|
+
token?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Bot username used for @-mention detection.
|
|
41
|
+
* Defaults to the `ROCKETCHAT_BOT_USERNAME` env var, then falls back to
|
|
42
|
+
* `"rocketchat-bot"`.
|
|
43
|
+
*/
|
|
44
|
+
userName?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Shared secret configured on the Outgoing Webhook integration, compared
|
|
47
|
+
* against the `token` field of each incoming webhook payload.
|
|
48
|
+
* Defaults to the `ROCKETCHAT_WEBHOOK_TOKEN` env var.
|
|
49
|
+
*/
|
|
50
|
+
webhookToken?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// =============================================================================
|
|
54
|
+
// Thread ID
|
|
55
|
+
// =============================================================================
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Decoded thread ID for Rocket.Chat.
|
|
59
|
+
*
|
|
60
|
+
* Thread ID formats:
|
|
61
|
+
* - Room-level: `rocketchat:{roomId}`
|
|
62
|
+
* - Thread reply: `rocketchat:{roomId}:{tmid}`
|
|
63
|
+
*/
|
|
64
|
+
export interface RocketChatThreadId {
|
|
65
|
+
/** Room (channel, private group, or DM) ID. */
|
|
66
|
+
roomId: string;
|
|
67
|
+
/** Parent message ID of the thread. Omit for the room-level thread. */
|
|
68
|
+
tmid?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// Rocket.Chat API objects
|
|
73
|
+
// =============================================================================
|
|
74
|
+
|
|
75
|
+
/** Minimal user reference embedded in messages (`u` field). */
|
|
76
|
+
export interface RocketChatMessageUser {
|
|
77
|
+
_id: string;
|
|
78
|
+
name?: string;
|
|
79
|
+
username: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Reaction map keyed by emoji shortcode, as returned on a message. */
|
|
83
|
+
export type RocketChatReactions = Record<string, { usernames: string[] }>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Message as returned by the REST API (`chat.postMessage`, `chat.update`,
|
|
87
|
+
* `chat.getMessage`, `chat.getThreadMessages`, `channels.history`,
|
|
88
|
+
* `rooms.history`, …).
|
|
89
|
+
*/
|
|
90
|
+
export interface RocketChatMessage {
|
|
91
|
+
_id: string;
|
|
92
|
+
_updatedAt?: string;
|
|
93
|
+
alias?: string;
|
|
94
|
+
attachments?: Record<string, unknown>[];
|
|
95
|
+
channels?: Record<string, unknown>[];
|
|
96
|
+
editedAt?: string;
|
|
97
|
+
editedBy?: RocketChatMessageUser;
|
|
98
|
+
groupable?: boolean;
|
|
99
|
+
md?: Record<string, unknown>[];
|
|
100
|
+
mentions?: Record<string, unknown>[];
|
|
101
|
+
msg: string;
|
|
102
|
+
reactions?: RocketChatReactions;
|
|
103
|
+
replies?: string[];
|
|
104
|
+
rid: string;
|
|
105
|
+
starred?: Record<string, unknown>[];
|
|
106
|
+
t?: string;
|
|
107
|
+
tcount?: number;
|
|
108
|
+
tlm?: string;
|
|
109
|
+
/** Present when the message is a reply in a thread. */
|
|
110
|
+
tmid?: string;
|
|
111
|
+
ts: string;
|
|
112
|
+
u: RocketChatMessageUser;
|
|
113
|
+
urls?: Record<string, unknown>[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* User as returned by `users.info` / `users.list`.
|
|
118
|
+
*
|
|
119
|
+
* @see https://developer.rocket.chat/apidocs/user-schema
|
|
120
|
+
*/
|
|
121
|
+
export interface RocketChatUser {
|
|
122
|
+
_id: string;
|
|
123
|
+
active?: boolean;
|
|
124
|
+
emails?: { address: string; verified: boolean }[];
|
|
125
|
+
name?: string;
|
|
126
|
+
/** `"user"`, `"bot"`, or `"app"`. Absent on older servers. */
|
|
127
|
+
type?: string;
|
|
128
|
+
username: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// =============================================================================
|
|
132
|
+
// Raw message
|
|
133
|
+
// =============================================================================
|
|
134
|
+
|
|
135
|
+
/** Platform-specific raw message stored on every `Message` from Rocket.Chat. */
|
|
136
|
+
export interface RocketChatRawMessage {
|
|
137
|
+
/** The message itself, in REST API shape. */
|
|
138
|
+
message: RocketChatMessage;
|
|
139
|
+
/** Room ID the message belongs to. */
|
|
140
|
+
roomId: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// =============================================================================
|
|
144
|
+
// REST API responses
|
|
145
|
+
// =============================================================================
|
|
146
|
+
|
|
147
|
+
/** Response of `POST chat.postMessage`. */
|
|
148
|
+
export interface RocketChatPostMessageResponse {
|
|
149
|
+
channel: string;
|
|
150
|
+
message: RocketChatMessage;
|
|
151
|
+
success: boolean;
|
|
152
|
+
ts: number | string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Response of `POST chat.update`. */
|
|
156
|
+
export interface RocketChatUpdateMessageResponse {
|
|
157
|
+
message: RocketChatMessage;
|
|
158
|
+
success: boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Response of `POST chat.delete`. */
|
|
162
|
+
export interface RocketChatDeleteMessageResponse {
|
|
163
|
+
_id: string;
|
|
164
|
+
message?: Partial<RocketChatMessage>;
|
|
165
|
+
success: boolean;
|
|
166
|
+
ts: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Response of `GET chat.getMessage`. */
|
|
170
|
+
export interface RocketChatGetMessageResponse {
|
|
171
|
+
message: RocketChatMessage;
|
|
172
|
+
success: boolean;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Response of `GET chat.getThreadMessages`. */
|
|
176
|
+
export interface RocketChatGetThreadMessagesResponse {
|
|
177
|
+
count: number;
|
|
178
|
+
messages: RocketChatMessage[];
|
|
179
|
+
offset: number;
|
|
180
|
+
success: boolean;
|
|
181
|
+
total: number;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Response of `GET rooms.history`. */
|
|
185
|
+
export interface RocketChatRoomsHistoryResponse {
|
|
186
|
+
cursor?: {
|
|
187
|
+
next: string | null;
|
|
188
|
+
previous: string | null;
|
|
189
|
+
};
|
|
190
|
+
messages: RocketChatMessage[];
|
|
191
|
+
success: boolean;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Room as returned by `rooms.info`. */
|
|
195
|
+
export interface RocketChatRoom {
|
|
196
|
+
_id: string;
|
|
197
|
+
fname?: string;
|
|
198
|
+
name?: string;
|
|
199
|
+
/** Room type: `c` (channel), `p` (private group), `d` (DM), `l` (livechat). */
|
|
200
|
+
t: string;
|
|
201
|
+
topic?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Response of `GET rooms.info`. */
|
|
205
|
+
export interface RocketChatRoomInfoResponse {
|
|
206
|
+
room: RocketChatRoom;
|
|
207
|
+
success: boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Response of `GET users.info`. */
|
|
211
|
+
export interface RocketChatUserInfoResponse {
|
|
212
|
+
success: boolean;
|
|
213
|
+
user: RocketChatUser;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Error envelope returned by the Rocket.Chat REST API on non-2xx responses. */
|
|
217
|
+
export interface RocketChatErrorResponse {
|
|
218
|
+
error?: string;
|
|
219
|
+
errorType?: string;
|
|
220
|
+
success: false;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// =============================================================================
|
|
224
|
+
// Outgoing webhook payload
|
|
225
|
+
// =============================================================================
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Body posted by a Rocket.Chat Outgoing Webhook integration when a message
|
|
229
|
+
* is sent in a room the integration is attached to.
|
|
230
|
+
*
|
|
231
|
+
* @see https://docs.rocket.chat/docs/outgoing-webhook-integrations
|
|
232
|
+
*/
|
|
233
|
+
export interface RocketChatWebhookPayload {
|
|
234
|
+
alias?: string;
|
|
235
|
+
/** `true` when the message author is a bot (including this adapter). */
|
|
236
|
+
bot?: boolean;
|
|
237
|
+
channel_id: string;
|
|
238
|
+
channel_name?: string;
|
|
239
|
+
message_id: string;
|
|
240
|
+
siteUrl?: string;
|
|
241
|
+
text: string;
|
|
242
|
+
/** Thread message ID, present when replying inside a thread. */
|
|
243
|
+
tmid?: string;
|
|
244
|
+
timestamp: string;
|
|
245
|
+
/** Shared secret configured on the integration, verified against `webhookToken`. */
|
|
246
|
+
token: string;
|
|
247
|
+
user_id: string;
|
|
248
|
+
user_name: string;
|
|
249
|
+
}
|
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import type { Chat } from "chat";
|
|
3
3
|
import { isEnvFlagEnabled } from "@/utils/env-flag";
|
|
4
4
|
import { registerVolatileSecret, scrubSecrets } from "@/utils/secret-scrubber";
|
|
5
|
-
import { loadAdapter, watchSocketConnection } from "./adapters";
|
|
5
|
+
import { DEFAULT_BOT_USER_NAME, loadAdapter, watchSocketConnection } from "./adapters";
|
|
6
6
|
import { drainBackground } from "./background";
|
|
7
7
|
import { registerTelegramCommands } from "./commands";
|
|
8
8
|
import {
|
|
@@ -57,15 +57,21 @@ export function isChatSdkStopping(): boolean {
|
|
|
57
57
|
return stopping;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const DEFAULT_CHAT_USER_NAME = "swarm";
|
|
61
|
-
|
|
62
60
|
/** Total wait for every step of `stopChatSdk`, inside the 15 s SIGTERM budget. */
|
|
63
61
|
const SHUTDOWN_BUDGET_MS = 10_000;
|
|
64
62
|
/** A config reload waits this long for the adapters to come back before it answers. */
|
|
65
63
|
const RELOAD_START_BUDGET_MS = 15_000;
|
|
66
64
|
|
|
67
65
|
/** Fields whose string value is a credential, registered with the scrubber. */
|
|
68
|
-
const SECRET_FIELDS = [
|
|
66
|
+
const SECRET_FIELDS = [
|
|
67
|
+
"botToken",
|
|
68
|
+
"secretToken",
|
|
69
|
+
"signingSecret",
|
|
70
|
+
"appToken",
|
|
71
|
+
"appPassword",
|
|
72
|
+
"token",
|
|
73
|
+
"webhookToken",
|
|
74
|
+
];
|
|
69
75
|
|
|
70
76
|
function setHealth(
|
|
71
77
|
name: ChatSdkAdapterName,
|
|
@@ -116,7 +122,7 @@ async function startAdapter(
|
|
|
116
122
|
state,
|
|
117
123
|
// Chat requires a userName. The adapter only gets one when the operator
|
|
118
124
|
// set it, so Telegram can still take the real bot name from getMe.
|
|
119
|
-
userName: typeof config.userName === "string" ? config.userName :
|
|
125
|
+
userName: typeof config.userName === "string" ? config.userName : DEFAULT_BOT_USER_NAME,
|
|
120
126
|
logger,
|
|
121
127
|
// The swarm buffers bursts itself (Phase 2). The SDK "queue" strategy
|
|
122
128
|
// would keep only the latest queued message and skip the rest.
|
|
@@ -6,7 +6,13 @@ import { z } from "zod";
|
|
|
6
6
|
* with it; `config.ts` adds the DB-backed resolution on top.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export const CHAT_SDK_ADAPTER_NAMES = [
|
|
9
|
+
export const CHAT_SDK_ADAPTER_NAMES = [
|
|
10
|
+
"telegram",
|
|
11
|
+
"slack",
|
|
12
|
+
"discord",
|
|
13
|
+
"teams",
|
|
14
|
+
"rocketchat",
|
|
15
|
+
] as const;
|
|
10
16
|
export type ChatSdkAdapterName = (typeof CHAT_SDK_ADAPTER_NAMES)[number];
|
|
11
17
|
|
|
12
18
|
export const ConfigRefSchema = z.strictObject({ $config: z.string().min(1) });
|
|
@@ -18,11 +24,14 @@ const Str = z.union([z.string().trim().min(1), ConfigRefSchema]);
|
|
|
18
24
|
* Keys an operator must never set. A base URL plus a `$config` ref would send
|
|
19
25
|
* the referenced secret to an arbitrary host. A verifier or an "unverified"
|
|
20
26
|
* switch bypasses the platform signature check on the public webhook.
|
|
21
|
-
*
|
|
27
|
+
* Base URLs come only from the env-only `CHAT_SDK_API_URL_OVERRIDES`, which
|
|
28
|
+
* is how a self-hosted Rocket.Chat instance URL is set too: the adapter reads
|
|
29
|
+
* it as `baseUrl`, so that name is forbidden here for the same reason.
|
|
22
30
|
*/
|
|
23
31
|
const FORBIDDEN_ADAPTER_KEYS = [
|
|
24
32
|
"apiUrl",
|
|
25
33
|
"apiBaseUrl",
|
|
34
|
+
"baseUrl",
|
|
26
35
|
"webhookVerifier",
|
|
27
36
|
"allowUnverifiedWebhooks",
|
|
28
37
|
] as const;
|
|
@@ -48,7 +57,8 @@ const COMMON_SHAPE = {
|
|
|
48
57
|
};
|
|
49
58
|
|
|
50
59
|
function adapterSchema<S extends AdapterShape>(shape: S) {
|
|
51
|
-
|
|
60
|
+
// The adapter's own shape wins: Rocket.Chat needs `userName` required.
|
|
61
|
+
return z.looseObject({ ...COMMON_SHAPE, ...shape }).superRefine(forbiddenKeyIssues);
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
/**
|
|
@@ -143,6 +153,26 @@ export const TeamsAdapterSchema = adapterSchema(TEAMS_SHAPE).superRefine((value,
|
|
|
143
153
|
}
|
|
144
154
|
});
|
|
145
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Rocket.Chat is self-hosted, so its instance URL is per deployment. It is
|
|
158
|
+
* not a field here: `baseUrl` is forbidden like every other base URL, and the
|
|
159
|
+
* instance comes from the env-only `CHAT_SDK_API_URL_OVERRIDES.rocketchat`.
|
|
160
|
+
* `botUserId` pairs with `token` on every REST call and identifies the bot's
|
|
161
|
+
* own messages; `webhookToken` is the Outgoing Webhook shared secret.
|
|
162
|
+
*/
|
|
163
|
+
// `userName` is required here, unlike the other adapters. Rocket.Chat detects
|
|
164
|
+
// a mention by matching `@<userName>` in the message text, and the REST API
|
|
165
|
+
// has no "who am I" call the adapter could use, so a wrong or defaulted name
|
|
166
|
+
// means the bot silently never sees a mention.
|
|
167
|
+
const ROCKETCHAT_SHAPE = {
|
|
168
|
+
token: Str,
|
|
169
|
+
botUserId: Str,
|
|
170
|
+
webhookToken: Str,
|
|
171
|
+
userName: Str,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const RocketchatAdapterSchema = adapterSchema(ROCKETCHAT_SHAPE);
|
|
175
|
+
|
|
146
176
|
// Strict: a typo'd adapter name must fail loudly, not silently disable it.
|
|
147
177
|
export const ChatSdkAdaptersSchema = z
|
|
148
178
|
.strictObject({
|
|
@@ -150,6 +180,7 @@ export const ChatSdkAdaptersSchema = z
|
|
|
150
180
|
slack: SlackAdapterSchema,
|
|
151
181
|
discord: DiscordAdapterSchema,
|
|
152
182
|
teams: TeamsAdapterSchema,
|
|
183
|
+
rocketchat: RocketchatAdapterSchema,
|
|
153
184
|
})
|
|
154
185
|
.partial();
|
|
155
186
|
|
|
@@ -161,6 +192,7 @@ export const CHAT_SDK_ADAPTER_SCHEMAS: Record<ChatSdkAdapterName, z.ZodType> = {
|
|
|
161
192
|
slack: SlackAdapterSchema,
|
|
162
193
|
discord: DiscordAdapterSchema,
|
|
163
194
|
teams: TeamsAdapterSchema,
|
|
195
|
+
rocketchat: RocketchatAdapterSchema,
|
|
164
196
|
};
|
|
165
197
|
|
|
166
198
|
/**
|
|
@@ -175,6 +207,7 @@ export const ChatSdkAdaptersDraftSchema = z
|
|
|
175
207
|
slack: adapterSchema(draftShape(SLACK_SHAPE)),
|
|
176
208
|
discord: adapterSchema(draftShape(DISCORD_SHAPE)).superRefine(discordPublicKeyIssue),
|
|
177
209
|
teams: adapterSchema(draftShape(TEAMS_SHAPE)),
|
|
210
|
+
rocketchat: adapterSchema(draftShape(ROCKETCHAT_SHAPE)),
|
|
178
211
|
})
|
|
179
212
|
.partial();
|
|
180
213
|
|
|
@@ -215,6 +248,7 @@ export const CHAT_SDK_ADAPTER_FIELDS: Record<ChatSdkAdapterName, readonly string
|
|
|
215
248
|
slack: formFields(SlackAdapterSchema.shape),
|
|
216
249
|
discord: formFields(DiscordAdapterSchema.shape),
|
|
217
250
|
teams: formFields(TeamsAdapterSchema.shape),
|
|
251
|
+
rocketchat: formFields(RocketchatAdapterSchema.shape),
|
|
218
252
|
};
|
|
219
253
|
|
|
220
254
|
/** `enabled` is the panel switch on the card, not a form field. */
|
|
@@ -55,6 +55,10 @@ const DEFAULT_MODES: Partial<Record<ChatSdkAdapterName, string>> = {
|
|
|
55
55
|
slack: "webhook",
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
/** Rocket.Chat only: set when the instance URL override is missing, which the adapter needs to start. */
|
|
59
|
+
const ROCKETCHAT_NO_INSTANCE_URL =
|
|
60
|
+
'No instance URL. Set CHAT_SDK_API_URL_OVERRIDES to {"rocketchat":"https://chat.example.com"} in the deployment environment and restart the API.';
|
|
61
|
+
|
|
58
62
|
const NOT_RUNNING =
|
|
59
63
|
"The adapter is starting, or the last configuration save is still applying. Refresh in a few seconds.";
|
|
60
64
|
|
|
@@ -160,6 +164,11 @@ export async function getChatSdkStatus(): Promise<ChatSdkStatus> {
|
|
|
160
164
|
} else if (config.enabled && configured) {
|
|
161
165
|
error = blockedCause ? `Not started: ${blockedCause}` : NOT_RUNNING;
|
|
162
166
|
}
|
|
167
|
+
// The instance URL is env-only, so a complete card can still not start.
|
|
168
|
+
// Say which env var is missing instead of the adapter's own error.
|
|
169
|
+
if (name === "rocketchat" && configured && enabled && resolveAdapterApiUrl(name) === "") {
|
|
170
|
+
error = ROCKETCHAT_NO_INSTANCE_URL;
|
|
171
|
+
}
|
|
163
172
|
return {
|
|
164
173
|
name,
|
|
165
174
|
configured,
|
|
@@ -84,7 +84,7 @@ const REPO_CLAUDE_MD_INLINE_PROVIDERS: ReadonlySet<string> = new Set(["opencode"
|
|
|
84
84
|
/**
|
|
85
85
|
* Template event for the tool-discovery line. Amp, Codex and OpenCode run MCP
|
|
86
86
|
* tools inside their own code sandbox (`code_exec`, `exec`, `execute`), each
|
|
87
|
-
* with its own call shape, and fx defers them behind `
|
|
87
|
+
* with its own call shape, and fx defers them behind `toolbox` (search, then run) under
|
|
88
88
|
* `mcp_<server>_<tool>` names, so the generic lines are wrong for them.
|
|
89
89
|
*/
|
|
90
90
|
function toolDiscoveryEvent(provider: string, hasToolSearch: boolean): string {
|
|
@@ -525,7 +525,7 @@ registerTemplate({
|
|
|
525
525
|
eventType: "system.agent.tool_discovery.fx",
|
|
526
526
|
header: "",
|
|
527
527
|
defaultBody:
|
|
528
|
-
"Most swarm tools are deferred behind `
|
|
528
|
+
"Most swarm tools are deferred behind `toolbox`. Each one is named `mcp_swarm_<tool>`, so `store-progress` is `mcp_swarm_store-progress`. Call a tool in your tool list directly. A deferred tool fails when called directly: find it with `toolbox` `search`, then call `toolbox` with `run` set to its name and `arguments` set to its arguments.",
|
|
529
529
|
variables: [],
|
|
530
530
|
category: "system",
|
|
531
531
|
});
|
|
@@ -427,7 +427,7 @@ const copilotTargetProfile: AcpTargetProfile = {
|
|
|
427
427
|
},
|
|
428
428
|
};
|
|
429
429
|
|
|
430
|
-
/** Qwen Code's `--auth-type` choices (0.27.
|
|
430
|
+
/** Qwen Code's `--auth-type` choices (0.27.4). `qwen-oauth` and `qwen-subscription` need an interactive sign-in, so they are left out. */
|
|
431
431
|
const QWEN_AUTH_TYPES = ["openai", "openai-responses", "anthropic", "gemini", "vertex-ai"] as const;
|
|
432
432
|
|
|
433
433
|
// Qwen Code is a Gemini CLI fork: QWEN_SYSTEM_MD replaces its built-in prompt
|
|
@@ -844,7 +844,7 @@ type FxToolCallMeta = { fx?: { toolCall?: { mcp?: { server?: unknown; tool?: unk
|
|
|
844
844
|
|
|
845
845
|
/**
|
|
846
846
|
* fx's display adjustments:
|
|
847
|
-
* - The `[context] …
|
|
847
|
+
* - The `[context] … toolbox` notice arrives as its own assistant
|
|
848
848
|
* chunk. It becomes an `fx_context_notice` custom event, so it never reaches
|
|
849
849
|
* the task output.
|
|
850
850
|
* - A `tool_call` titles the action ("Running", "Get the agent swarm") and
|
|
@@ -45,7 +45,7 @@ import type {
|
|
|
45
45
|
* default; the image installs exactly this version and the per-task settings
|
|
46
46
|
* set `amp.updates.mode: "disabled"`. Bump it deliberately, with a live run.
|
|
47
47
|
*/
|
|
48
|
-
export const AMP_PACKAGE = "@ampcode/cli@0.0.
|
|
48
|
+
export const AMP_PACKAGE = "@ampcode/cli@0.0.1794744038-ga74b43";
|
|
49
49
|
|
|
50
50
|
/** MCP server name. Amp exposes its tools as `agent_swarm` / `store_progress` (dashes become underscores). */
|
|
51
51
|
const AMP_MCP_SERVER_NAME = "agent-swarm";
|