@desplega.ai/agent-swarm 2.13.0 → 2.13.2
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-x1qqgzwx.js +17 -0
- package/dist/{acp-targets-86f0sh6g.js → acp-targets-mz8c5dnt.js} +10 -10
- package/dist/{actions-zv8vcxvr.js → actions-5ft3qp5a.js} +27 -27
- package/dist/{agent-fs-provision-jqshb33y.js → agent-fs-provision-6fgz7wvz.js} +4 -4
- package/dist/{amp-adapter-gt503ywc.js → amp-adapter-nthn8ezm.js} +3 -3
- package/dist/{app-6t4k5rh1.js → app-535m78qw.js} +10 -10
- package/dist/{approval-notifications-fcfw063h.js → approval-notifications-dewbk403.js} +11 -11
- package/dist/{assistant-9dzybh12.js → assistant-39zyabv2.js} +28 -28
- package/dist/{boot-args-schema-xzfp2feg.js → boot-args-schema-bqv5bf77.js} +1 -1
- package/dist/{boot-reembed-3jz0p2jk.js → boot-reembed-157c0gcz.js} +1 -1
- package/dist/{boot-reembed-r88wngfg.js → boot-reembed-fas7z3zn.js} +1 -1
- package/dist/{boot-scrub-sweep-scrqhw48.js → boot-scrub-sweep-tmec0be2.js} +2 -2
- package/dist/{boot-seeds-vb2dcrrb.js → boot-seeds-32zm50x2.js} +4 -4
- package/dist/{boxd-68n75y1s.js → boxd-hr8rsxzq.js} +1 -1
- package/dist/{claude-adapter-h3mp9hgs.js → claude-adapter-gwq7x2nj.js} +9 -9
- package/dist/{claude-managed-adapter-kpbyj2vb.js → claude-managed-adapter-rkvw6fvq.js} +4 -4
- package/dist/{claude-managed-setup-0efr3wkg.js → claude-managed-setup-0vgz4d1j.js} +6 -6
- package/dist/{claude-sdk-session-03dw669q.js → claude-sdk-session-5wbwxy8c.js} +20967 -19390
- package/dist/{cli-z64t9pe6.js → cli-0f7n3td3.js} +1 -1
- package/dist/{cli-j53hpbsm.js → cli-0xwb7zpt.js} +2 -2
- package/dist/{cli-wxwv3t11.js → cli-1f48qdnb.js} +55 -13
- package/dist/{cli-gfcv679k.js → cli-1gevjrc1.js} +1 -1
- package/dist/{cli-0jkenasr.js → cli-2v4xxnx2.js} +1 -1
- package/dist/{cli-hc6e4tac.js → cli-2wde56gv.js} +6 -6
- package/dist/{cli-mh7pdxe0.js → cli-31vt7baf.js} +17 -17
- package/dist/{cli-ercwc8xn.js → cli-3mf04tkh.js} +1 -1
- package/dist/{cli-s6zk31gr.js → cli-43dsqhcp.js} +4 -4
- package/dist/{cli-1dbv9mj9.js → cli-4djg31jh.js} +1 -1
- package/dist/{cli-tn91wc6e.js → cli-50whymxq.js} +1 -1
- package/dist/{cli-js10kdk7.js → cli-5basv0e7.js} +19 -5
- package/dist/{cli-b2jh3dyb.js → cli-5k1hvycs.js} +4 -4
- package/dist/{cli-dkejt425.js → cli-62fjschk.js} +7 -7
- package/dist/{cli-zqmmy073.js → cli-69eq6gdk.js} +18 -18
- package/dist/{cli-qm3ntjqs.js → cli-6rmryz03.js} +13 -13
- package/dist/{cli-mz34pxbk.js → cli-7m6bbtab.js} +11 -11
- package/dist/{cli-wv20kbr3.js → cli-8a4qg44m.js} +5 -5
- package/dist/{cli-2m6yaq6b.js → cli-8fj8yfmk.js} +1 -1
- package/dist/{cli-9m9kyw77.js → cli-8qvte9hn.js} +2 -2
- package/dist/{cli-x05p2d05.js → cli-9tevdxyf.js} +1 -1
- package/dist/{cli-qec9bynj.js → cli-a6rzw649.js} +3 -3
- package/dist/{cli-ex1y88j3.js → cli-at67kvnp.js} +1 -1
- package/dist/{cli-yn4kt85g.js → cli-b0kqw55g.js} +1 -1
- package/dist/{cli-n3qe7tyr.js → cli-b0m3bg0f.js} +134 -3
- package/dist/{cli-xfjn2kyq.js → cli-bp2rt28p.js} +9 -9
- package/dist/{cli-2jk4s7z1.js → cli-c9bwawf9.js} +3 -3
- package/dist/{cli-wndegmns.js → cli-cmgdptmx.js} +3 -3
- package/dist/{cli-3p288654.js → cli-cpkxh68d.js} +2 -2
- package/dist/{cli-117g15t4.js → cli-cs26ed89.js} +8 -8
- package/dist/{cli-prf7kz78.js → cli-d0jb2qnt.js} +603 -78
- package/dist/{cli-8hp56wat.js → cli-d2epqm0y.js} +1 -1
- package/dist/{cli-wrhbym01.js → cli-d528acsw.js} +6 -6
- package/dist/{cli-tstj6e8e.js → cli-dnvmwsvc.js} +310 -88
- package/dist/{cli-9fsagra4.js → cli-e87fg3en.js} +1 -1
- package/dist/{cli-jj3c5nyb.js → cli-erh1rgh4.js} +116 -56
- package/dist/{cli-f1952kjy.js → cli-ewb028rs.js} +4 -4
- package/dist/{cli-ct8sz3np.js → cli-f1sdh8ca.js} +6 -6
- package/dist/{cli-0b655smz.js → cli-fcwrd7bh.js} +5 -5
- package/dist/{cli-eb279wn3.js → cli-fgm2mad9.js} +2 -2
- package/dist/{cli-bpje8n65.js → cli-fp65jdp2.js} +31 -6
- package/dist/{cli-dnh64e8e.js → cli-g0b3ma7r.js} +7 -7
- package/dist/{cli-avxh26pd.js → cli-gc7jkf4a.js} +4 -4
- package/dist/{cli-2skf1mdf.js → cli-gedf48yw.js} +4 -4
- package/dist/{cli-ajjvqhf3.js → cli-getrvmtx.js} +27 -6
- package/dist/{cli-c8v2yvej.js → cli-gq6qhmrr.js} +2 -2
- package/dist/{cli-mbwmqb5w.js → cli-h0ewec3d.js} +1 -1
- package/dist/{cli-tdk7jtka.js → cli-hv3820ez.js} +1 -1
- package/dist/{cli-avqkr20b.js → cli-j2ybkdk2.js} +2 -2
- package/dist/{cli-pqfecppn.js → cli-je587f74.js} +1 -1
- package/dist/{cli-hgsxnjyg.js → cli-jkkcm72j.js} +13 -13
- package/dist/{cli-g6j6ac3h.js → cli-ka13xx6b.js} +2 -2
- package/dist/{cli-t35hx078.js → cli-m1wddksc.js} +2 -2
- package/dist/{cli-50w82h6m.js → cli-mwxez0pz.js} +1 -0
- package/dist/{cli-nc6a8b5b.js → cli-n14r8h4n.js} +2 -2
- package/dist/{cli-y4a4458j.js → cli-n46d87mj.js} +3 -3
- package/dist/{cli-0dg7ytxm.js → cli-nkfv398a.js} +1096 -75
- package/dist/{cli-fhvk2nvp.js → cli-nvqq3232.js} +9 -9
- package/dist/{cli-bhgrhedp.js → cli-q8aq48v1.js} +1 -1
- package/dist/{cli-6a40p4kv.js → cli-qn79645p.js} +1 -1
- package/dist/{cli-hbq0kwxz.js → cli-r4fphq38.js} +4 -4
- package/dist/{cli-47hz21se.js → cli-r8ddn0hf.js} +4 -5
- package/dist/{cli-hpb9x72z.js → cli-rvhaahfv.js} +9 -9
- package/dist/{cli-qhhb30e8.js → cli-s08zsqva.js} +9 -9
- package/dist/{cli-sdh61g52.js → cli-s6fhqbz1.js} +2 -2
- package/dist/{cli-y518qkjg.js → cli-sjk85d7v.js} +13 -12
- package/dist/{cli-ytc7fpza.js → cli-t25rq8mg.js} +4 -4
- package/dist/{cli-sq913bh1.js → cli-t9nxq30h.js} +8 -8
- package/dist/{cli-49f5jyhh.js → cli-tbdw3f92.js} +3 -3
- package/dist/{cli-1v82d2w6.js → cli-tceqvv6h.js} +4 -4
- package/dist/{cli-fz9pcjsw.js → cli-tgmate57.js} +4 -4
- package/dist/{cli-rtmqzat7.js → cli-vdfngx2g.js} +2 -2
- package/dist/{cli-9w8712tq.js → cli-vr4eyq6p.js} +43 -14
- package/dist/{cli-z4f346g5.js → cli-vx9acp12.js} +1 -1
- package/dist/{cli-7dbhnsj9.js → cli-wdtqkqnq.js} +4 -4
- package/dist/{cli-kde4ky90.js → cli-x5yb8zc8.js} +2 -2
- package/dist/{cli-w14j2z4k.js → cli-x7aqhxj5.js} +2 -2
- package/dist/{cli-kspxjftk.js → cli-xerdrnqs.js} +15 -6
- package/dist/{cli-48nvk6sb.js → cli-xhkek467.js} +2 -2
- package/dist/{cli-dka73bak.js → cli-xysy1g8x.js} +152 -12
- package/dist/{cli-7wy8gbwb.js → cli-ya1cj689.js} +1 -1
- package/dist/{cli-n85m2wkq.js → cli-zkbz8m2q.js} +3 -2
- package/dist/{cli-0pazkmd4.js → cli-zm6bkx3e.js} +4 -4
- package/dist/{cli-6h88mn9q.js → cli-zqy28rwx.js} +4 -4
- package/dist/cli.js +30 -29
- package/dist/{codex-adapter-f3yp0kaj.js → codex-adapter-x25xfbnh.js} +8 -8
- package/dist/{codex-hook-262cekfp.js → codex-hook-c0nvm30r.js} +2 -2
- package/dist/{codex-login-1ven7yje.js → codex-login-ven5cz5j.js} +1 -1
- package/dist/{codex-session-runner-ns4mv70p.js → codex-session-runner-kn5xnrvp.js} +9 -9
- package/dist/{commands-5bzf2tfw.js → commands-8n59gxmy.js} +3 -3
- package/dist/{controller-5xt7kvfm.js → controller-wn3vd217.js} +3 -3
- package/dist/{controllers-connect-0gg13mzp.js → controllers-connect-09gvkrhc.js} +28 -28
- package/dist/core-2b8bv6ny.js +42 -0
- package/dist/{cursor-adapter-p0c5zv6r.js → cursor-adapter-w1681kp1.js} +2 -2
- package/dist/{db-2s68ycq7.js → db-e71keqxk.js} +3 -3
- package/dist/{db-q7q639k5.js → db-spg81qtr.js} +2 -2
- package/dist/{devin-adapter-t8d86q9x.js → devin-adapter-fs90ab4v.js} +1 -1
- package/dist/{dispatcher-j2y1q7ae.js → dispatcher-fr4vawwb.js} +25 -25
- package/dist/{docker-1b41eysj.js → docker-1h33jvh9.js} +2 -2
- package/dist/{dsh-adapter-pgnkf4st.js → dsh-adapter-g9yqv09y.js} +2 -2
- package/dist/{e2b-xm60c8ad.js → e2b-jnk0yeva.js} +2 -2
- package/dist/{e2b-ew8c5j5v.js → e2b-y7e5kmzf.js} +2 -2
- package/dist/{easter-egg-3d-0kea97jf.js → easter-egg-3d-ac9tv9a6.js} +1 -1
- package/dist/{embedding-space-3n6mhhmy.js → embedding-space-an77f45k.js} +6 -6
- package/dist/{embeddings-jfmj6yme.js → embeddings-jkrehejr.js} +1 -1
- package/dist/{event-bus-v4ywhc2p.js → event-bus-08t2b4y2.js} +1 -1
- package/dist/{execute-tjrej979.js → execute-3mys4nta.js} +1 -1
- package/dist/{external-channel-jy8w2gg3.js → external-channel-s6zxpts9.js} +2 -2
- package/dist/fx-adapter-4yet1c4f.js +20 -0
- package/dist/grok-adapter-8ge6tw7m.js +20 -0
- package/dist/handlers-0r9evrdj.js +41 -0
- package/dist/heartbeat-jjpb44e5.js +50 -0
- package/dist/{hook-fv1jwrv7.js → hook-68gbs87k.js} +6 -6
- package/dist/{hook-bpnncsec.js → hook-y6n23zzj.js} +8 -8
- package/dist/{http-bpa26czn.js → http-8c6y008s.js} +404 -146
- package/dist/{index-w216g9y9.js → index-0vthtbc2.js} +38 -22
- package/dist/index-1v23363p.js +39 -0
- package/dist/index-30qw6vyw.js +44 -0
- package/dist/index-6bm3w6cn.js +40 -0
- package/dist/{index-s8re7mvq.js → index-6h3r0vpe.js} +1 -1
- package/dist/{index-620y7jzq.js → index-7dgxveck.js} +3 -3
- package/dist/{index-4k7m5dgj.js → index-maddg9ys.js} +143 -103
- package/dist/{index-0h6qd4p1.js → index-mbpxhc4w.js} +3 -4
- package/dist/index-rz8ve510.js +569 -0
- package/dist/{index-mpj0z9e0.js → index-we3nd2t0.js} +1 -1
- package/dist/{index-pe3d8jfy.js → index-whysn1wf.js} +1 -1
- package/dist/{index-52tgbhrw.js → index-xcw7hjt5.js} +28 -28
- package/dist/{index-8p0j4h4j.js → index-ym9fgxad.js} +94 -89
- package/dist/{k8s-fy8hbhkg.js → k8s-8326q0rq.js} +2 -2
- package/dist/{keepalive-d6z12s04.js → keepalive-7e9r5dvp.js} +5 -4
- package/dist/lead-3jpc7kcr.js +79 -0
- package/dist/{maintenance-7kac6g2g.js → maintenance-d3erjvcg.js} +1 -1
- package/dist/{oauth-refresh-sweep-t1xjetbh.js → oauth-refresh-sweep-0qh70988.js} +4 -3
- package/dist/{object-webhooks-6rdagg0r.js → object-webhooks-ac7v2q5p.js} +7 -7
- package/dist/{onboard-32y1cfxy.js → onboard-5yphtken.js} +4 -4
- package/dist/{opencode-adapter-enp3v31n.js → opencode-adapter-0xvyba4m.js} +8 -8
- package/dist/{otel-impl-k0tm5ptj.js → otel-impl-svqp691q.js} +2 -2
- package/dist/{pending-24zebgvs.js → pending-bn4xe5br.js} +26 -26
- package/dist/{pi-mono-adapter-yj72xxxe.js → pi-mono-adapter-763s8a3w.js} +20 -18
- package/dist/{pricing-refresh-cf25x38j.js → pricing-refresh-kfc215mf.js} +2 -2
- package/dist/{rbac-roles-0wydd22m.js → rbac-roles-3bznvkpt.js} +3 -3
- package/dist/{rbac-roles-at6crb3r.js → rbac-roles-6r4h2ghj.js} +2 -2
- package/dist/{render-v2-nvcw0jd7.js → render-v2-f3qedbpy.js} +10 -10
- package/dist/{resume-y4w0k5v3.js → resume-vcag4ann.js} +13 -13
- package/dist/{runtime-vpe43hx0.js → runtime-x0s55z2t.js} +1 -1
- package/dist/{session-access-gkyvnfye.js → session-access-nwzve8q2.js} +5 -5
- package/dist/{session-source-backfill-3w2st4m2.js → session-source-backfill-jpqfzmgz.js} +2 -2
- package/dist/{setup-axxvqtys.js → setup-d2smwaem.js} +1 -1
- package/dist/thread-buffer-8fc703jc.js +42 -0
- package/dist/{tree-visibility-y4fqvab5.js → tree-visibility-dwzc8en0.js} +2 -2
- package/dist/{user-merge-jobs-kcmwvrc6.js → user-merge-jobs-4ce7kma2.js} +3 -3
- package/dist/{virtual-modules-7d92dct1.js → virtual-modules-78a6yw71.js} +3 -3
- package/dist/{work-objects-f708e069.js → work-objects-m0w1e7q8.js} +28 -28
- package/dist/worker-3p2vq107.js +79 -0
- package/dist/{worker-follow-up-0by8wztc.js → worker-follow-up-e3t6f895.js} +25 -25
- package/dist/{x-3dtaf2r9.js → x-asbrnafg.js} +2 -2
- package/openapi.json +1795 -1623
- package/package.json +13 -12
- package/src/apps/catalog.generated.json +726 -0
- package/src/apps/definition.ts +24 -7
- package/src/apps/page-validator.ts +225 -3
- package/src/be/db.ts +38 -10
- package/src/be/mcp-proxy.ts +5 -4
- package/src/be/migrations/340_api_key_spend_cap.sql +5 -0
- package/src/be/migrations/341_user_token_expiry.sql +4 -0
- package/src/be/schedules/validate.ts +26 -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/swarm-config-guard.ts +4 -0
- package/src/be/users.ts +48 -7
- package/src/commands/credential-outcome-report.ts +5 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/provider-credentials.ts +19 -0
- package/src/commands/provider-error-class.ts +4 -1
- package/src/commands/rate-limit-outcome.ts +48 -3
- package/src/commands/runner.ts +113 -55
- package/src/commands/worktree-reaper.ts +600 -0
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/http/agents.ts +4 -0
- package/src/http/api-keys.ts +27 -3
- package/src/http/pages-public.ts +40 -4
- package/src/http/pool-keys.ts +21 -2
- package/src/http/schedules.ts +28 -3
- package/src/http/script-connection-proxy.ts +18 -6
- package/src/http/script-connections.ts +12 -4
- package/src/http/script-runs.ts +12 -3
- package/src/http/scripts.ts +2 -11
- package/src/http/tasks.ts +6 -10
- 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/mcp-client/http-client.ts +3 -1
- package/src/oauth/identity-capture.ts +6 -1
- package/src/oauth/mcp-wrapper.ts +10 -3
- package/src/oauth/wrapper.ts +15 -3
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/pi-mono-adapter.ts +4 -2
- package/src/providers/runtime-dependencies.ts +1 -1
- package/src/rbac/legacy-policy.ts +3 -0
- package/src/rbac/permissions.ts +9 -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-extension.d.ts +7 -7
- package/src/scripts-runtime/types/swarm-sdk.d.ts +4 -4
- package/src/server-user.ts +98 -0
- package/src/slack/enrich.ts +14 -11
- package/src/tests/agents-list-model-display.test.ts +23 -0
- package/src/tests/apps-spike2.test.ts +35 -0
- package/src/tests/base-prompt.test.ts +1 -0
- 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/codex-app-server.test.ts +4 -6
- package/src/tests/deploy-guard.test.ts +24 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/ensure-token.test.ts +2 -2
- package/src/tests/entrypoint-repo-autoclone-args.test.ts +202 -0
- package/src/tests/fake-dns.ts +47 -0
- package/src/tests/fixtures/base-prompt-baseline.json +12 -12
- package/src/tests/latest-model-report.test.ts +138 -0
- package/src/tests/mcp-oauth-dcr-reuse.test.ts +5 -2
- package/src/tests/mcp-oauth-ensure-token.test.ts +3 -2
- package/src/tests/mcp-oauth-manual-client.test.ts +6 -1
- package/src/tests/mcp-oauth-wrapper.test.ts +20 -4
- package/src/tests/mcp-outbound-fetch-guard.test.ts +169 -0
- package/src/tests/mcp-server-ssrf.test.ts +2 -0
- package/src/tests/mcp-user-route.test.ts +10 -1
- package/src/tests/memory-search-stall.test.ts +5 -0
- package/src/tests/oauth-connection-fetch-guard.test.ts +162 -0
- package/src/tests/oauth-token-endpoint-fetch-guard.test.ts +121 -0
- package/src/tests/oauth-wrapper.test.ts +1 -2
- package/src/tests/pages-head-v2.test.ts +2 -1
- package/src/tests/script-connections-http.test.ts +8 -3
- 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 +4 -0
- package/src/tests/slack-thread-participants.test.ts +14 -3
- package/src/tests/spend-cap-credentials.test.ts +34 -0
- package/src/tests/spend-cap-outcome.test.ts +67 -0
- package/src/tests/subscription-first.test.ts +119 -0
- package/src/tests/worktree-reaper.test.ts +424 -0
- package/src/tools/get-task-details.ts +247 -5
- package/src/tools/schedules/patch-schedule.ts +26 -1
- package/src/tools/schedules/update-schedule.ts +28 -2
- 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/utils/credentials.ts +36 -1
- package/src/utils/egress-guard.ts +40 -10
- package/src/utils/error-tracker.ts +17 -0
- package/templates/skills/apps/SKILL.md +191 -2
- package/templates/skills/apps/content.md +191 -2
- package/templates/skills/boards-and-sheets/content.md +11 -0
- package/templates/skills/chat-sdk/content.md +2 -2
- package/templates/skills/pages/content.md +11 -0
- package/templates/skills/swarm-docs/content.md +4 -0
- package/templates/skills/swarm-scripts/SKILL.md +1 -0
- package/templates/skills/swarm-scripts/content.md +1 -0
- package/templates/workflows/ralph-loop/content.md +6 -6
- package/dist/acp-adapter-cn53011z.js +0 -17
- package/dist/cli-pr0eze3x.js +0 -149
- package/dist/core-0fqtbrxa.js +0 -42
- package/dist/fx-adapter-k6w3jvz9.js +0 -20
- package/dist/grok-adapter-4q5tssw0.js +0 -20
- package/dist/handlers-qxgfvvsf.js +0 -41
- package/dist/heartbeat-6tr2w2da.js +0 -50
- package/dist/index-0mcxjdsa.js +0 -44
- package/dist/index-dz4q23ag.js +0 -40
- package/dist/index-s175jckx.js +0 -39
- package/dist/lead-p3hx7h35.js +0 -79
- package/dist/thread-buffer-rwa7d4dx.js +0 -42
- package/dist/worker-8rg9gz74.js +0 -79
- /package/dist/{cli-m4ejz4nj.js → cli-cah298e5.js} +0 -0
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isTableNode2,
|
|
3
|
+
tableToAscii2,
|
|
4
|
+
parseMarkdown2,
|
|
5
|
+
stringifyMarkdown2,
|
|
6
|
+
walkAst2,
|
|
7
|
+
BaseFormatConverter2,
|
|
8
|
+
Message3,
|
|
9
|
+
ConsoleLogger2,
|
|
10
|
+
defaultEmojiResolver2,
|
|
11
|
+
init_dist8
|
|
12
|
+
} from "./cli-vr4eyq6p.js";
|
|
13
|
+
import {
|
|
14
|
+
AdapterRateLimitError,
|
|
15
|
+
AuthenticationError3,
|
|
16
|
+
ResourceNotFoundError,
|
|
17
|
+
PermissionError,
|
|
18
|
+
ValidationError,
|
|
19
|
+
NetworkError,
|
|
20
|
+
normalizeCodeFences,
|
|
21
|
+
init_dist7
|
|
22
|
+
} from "./cli-b0m3bg0f.js";
|
|
23
|
+
import {
|
|
24
|
+
__esm
|
|
25
|
+
} from "./cli-242037k3.js";
|
|
26
|
+
|
|
27
|
+
// src/integrations/chat-sdk/rocketchat/markdown.ts
|
|
28
|
+
function boundary(char) {
|
|
29
|
+
return char in INLINE_PAIRS ? " " : char;
|
|
30
|
+
}
|
|
31
|
+
function text(node, _parent, _state, info) {
|
|
32
|
+
const { before, after } = info;
|
|
33
|
+
const context = [boundary(before.slice(-1)), boundary(after.charAt(0))];
|
|
34
|
+
let value = node.value;
|
|
35
|
+
for (const [marker, pair] of Object.entries(INLINE_PAIRS)) {
|
|
36
|
+
const touchesMarker = value.startsWith(marker) && before.slice(-1) in INLINE_PAIRS || value.endsWith(marker) && after.charAt(0) in INLINE_PAIRS;
|
|
37
|
+
if (touchesMarker || value.includes(marker) && pair.test(`${context[0]}${value}${context[1]}`)) {
|
|
38
|
+
value = value.replaceAll(marker, `\\${marker}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return value.replace(BLOCK_START, (match, lead, symbol, digits, offset = 0) => {
|
|
42
|
+
if (offset === 0 && lead === "" && before !== `
|
|
43
|
+
`) {
|
|
44
|
+
return match;
|
|
45
|
+
}
|
|
46
|
+
return symbol ? `${lead}\\${symbol}` : `${lead}${digits}\\.`;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function strong(node, _parent, state, info) {
|
|
50
|
+
return `*${state.containerPhrasing(node, { ...info, before: "*", after: "*" })}*`;
|
|
51
|
+
}
|
|
52
|
+
function emphasis(node, _parent, state, info) {
|
|
53
|
+
return `_${state.containerPhrasing(node, { ...info, before: "_", after: "_" })}_`;
|
|
54
|
+
}
|
|
55
|
+
function strikethrough(node, _parent, state, info) {
|
|
56
|
+
return `~${state.containerPhrasing(node, { ...info, before: "~", after: "~" })}~`;
|
|
57
|
+
}
|
|
58
|
+
var INLINE_PAIRS, BLOCK_START, handlers, RocketChatFormatConverter;
|
|
59
|
+
var init_markdown = __esm(() => {
|
|
60
|
+
init_dist7();
|
|
61
|
+
init_dist8();
|
|
62
|
+
INLINE_PAIRS = {
|
|
63
|
+
"*": /(?:^|[^\p{L}\p{N}])\*(?=\S).*?\S\*(?![\p{L}\p{N}])/mu,
|
|
64
|
+
_: /(?:^|[^\p{L}\p{N}])_(?=\S).*?\S_(?![\p{L}\p{N}])/mu,
|
|
65
|
+
"~": /(?:^|[^\p{L}\p{N}])~(?=\S).*?\S~(?![\p{L}\p{N}])/mu,
|
|
66
|
+
"`": /(?:^|[^\p{L}\p{N}])`(?=\S).*?\S`(?![\p{L}\p{N}])/mu
|
|
67
|
+
};
|
|
68
|
+
BLOCK_START = /(^|\n)(?:([>*-])|(\d+)\.)(?= )/g;
|
|
69
|
+
strong.peek = () => "*";
|
|
70
|
+
emphasis.peek = () => "_";
|
|
71
|
+
strikethrough.peek = () => "~";
|
|
72
|
+
handlers = {
|
|
73
|
+
text,
|
|
74
|
+
strong,
|
|
75
|
+
emphasis,
|
|
76
|
+
delete: strikethrough,
|
|
77
|
+
break: () => `
|
|
78
|
+
`
|
|
79
|
+
};
|
|
80
|
+
RocketChatFormatConverter = class RocketChatFormatConverter extends BaseFormatConverter2 {
|
|
81
|
+
fromAst(ast) {
|
|
82
|
+
const transformed = walkAst2(structuredClone(ast), (node) => {
|
|
83
|
+
if (node.type === "heading") {
|
|
84
|
+
const heading = node;
|
|
85
|
+
const children = heading.children.flatMap((child) => child.type === "strong" ? child.children : [child]);
|
|
86
|
+
return {
|
|
87
|
+
type: "paragraph",
|
|
88
|
+
children: [{ type: "strong", children }]
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (node.type === "thematicBreak") {
|
|
92
|
+
return {
|
|
93
|
+
type: "paragraph",
|
|
94
|
+
children: [{ type: "text", value: "━━━" }]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (isTableNode2(node)) {
|
|
98
|
+
return {
|
|
99
|
+
type: "code",
|
|
100
|
+
value: tableToAscii2(node),
|
|
101
|
+
lang: undefined
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return node;
|
|
105
|
+
});
|
|
106
|
+
return stringifyMarkdown2(transformed, {
|
|
107
|
+
emphasis: "_",
|
|
108
|
+
bullet: "-",
|
|
109
|
+
handlers
|
|
110
|
+
}).trim();
|
|
111
|
+
}
|
|
112
|
+
toAst(markdown) {
|
|
113
|
+
return parseMarkdown2(this.toStandardMarkdown(markdown));
|
|
114
|
+
}
|
|
115
|
+
exceedsIncomingBudget(markdown) {
|
|
116
|
+
return markdown.length > this.maxIncomingParseLength || super.exceedsIncomingBudget(this.toStandardMarkdown(markdown));
|
|
117
|
+
}
|
|
118
|
+
toStandardMarkdown(markdown) {
|
|
119
|
+
return normalizeCodeFences(markdown, {
|
|
120
|
+
convertText: (text) => this.fromRocketChatFormat(text)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
renderPostable(message) {
|
|
124
|
+
if (typeof message === "string") {
|
|
125
|
+
return message;
|
|
126
|
+
}
|
|
127
|
+
if ("raw" in message) {
|
|
128
|
+
return message.raw;
|
|
129
|
+
}
|
|
130
|
+
if ("markdown" in message) {
|
|
131
|
+
return this.fromMarkdown(message.markdown);
|
|
132
|
+
}
|
|
133
|
+
if ("ast" in message) {
|
|
134
|
+
return this.fromAst(message.ast);
|
|
135
|
+
}
|
|
136
|
+
return super.renderPostable(message);
|
|
137
|
+
}
|
|
138
|
+
fromRocketChatFormat(text) {
|
|
139
|
+
let result = text.replace(/(?<!\*)\*(?!\*)([^\n*]+?)(?<!\*)\*(?!\*)/g, "**$1**");
|
|
140
|
+
result = result.replace(/(?<!~)~(?!~)([^\n~]+?)(?<!~)~(?!~)/g, "~~$1~~");
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// src/integrations/chat-sdk/rocketchat/index.ts
|
|
147
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
148
|
+
|
|
149
|
+
class RocketChatAdapter {
|
|
150
|
+
name = "rocketchat";
|
|
151
|
+
baseUrl;
|
|
152
|
+
token;
|
|
153
|
+
webhookToken;
|
|
154
|
+
logger;
|
|
155
|
+
formatConverter = new RocketChatFormatConverter;
|
|
156
|
+
chat = null;
|
|
157
|
+
_botUserId;
|
|
158
|
+
_userName;
|
|
159
|
+
get userName() {
|
|
160
|
+
return this._userName;
|
|
161
|
+
}
|
|
162
|
+
get botUserId() {
|
|
163
|
+
return this._botUserId;
|
|
164
|
+
}
|
|
165
|
+
constructor(config = {}) {
|
|
166
|
+
const baseUrl = config.baseUrl ?? process.env.ROCKETCHAT_URL;
|
|
167
|
+
if (!baseUrl) {
|
|
168
|
+
throw new ValidationError("rocketchat", "Server URL is required. Set ROCKETCHAT_URL or provide baseUrl in config.");
|
|
169
|
+
}
|
|
170
|
+
const token = config.token ?? process.env.ROCKETCHAT_TOKEN;
|
|
171
|
+
if (!token) {
|
|
172
|
+
throw new ValidationError("rocketchat", "Authentication is required. Set ROCKETCHAT_TOKEN or provide token in config.");
|
|
173
|
+
}
|
|
174
|
+
const botUserId = config.botUserId ?? process.env.ROCKETCHAT_USER_ID;
|
|
175
|
+
if (!botUserId) {
|
|
176
|
+
throw new ValidationError("rocketchat", "Bot user ID is required. Set ROCKETCHAT_USER_ID or provide botUserId in config.");
|
|
177
|
+
}
|
|
178
|
+
const webhookToken = config.webhookToken ?? process.env.ROCKETCHAT_WEBHOOK_TOKEN;
|
|
179
|
+
if (!webhookToken) {
|
|
180
|
+
throw new ValidationError("rocketchat", "Webhook verification is required. Set ROCKETCHAT_WEBHOOK_TOKEN or provide webhookToken in config.");
|
|
181
|
+
}
|
|
182
|
+
this.baseUrl = trimTrailingSlashes(baseUrl);
|
|
183
|
+
this.token = token;
|
|
184
|
+
this._botUserId = botUserId;
|
|
185
|
+
this.webhookToken = webhookToken;
|
|
186
|
+
this._userName = config.userName ?? process.env.ROCKETCHAT_BOT_USERNAME ?? DEFAULT_USER_NAME;
|
|
187
|
+
this.logger = config.logger ?? new ConsoleLogger2("info").child("rocketchat");
|
|
188
|
+
}
|
|
189
|
+
async initialize(chat) {
|
|
190
|
+
this.chat = chat;
|
|
191
|
+
}
|
|
192
|
+
isSelf(userId) {
|
|
193
|
+
return userId === this._botUserId;
|
|
194
|
+
}
|
|
195
|
+
async request(method, path, options = {}) {
|
|
196
|
+
const url = new URL(`${this.baseUrl}/api/v1${path}`);
|
|
197
|
+
for (const [key, value] of Object.entries(options.query ?? {})) {
|
|
198
|
+
if (value !== undefined) {
|
|
199
|
+
url.searchParams.set(key, String(value));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const headers = {
|
|
203
|
+
"x-auth-token": this.token,
|
|
204
|
+
"x-user-id": this._botUserId,
|
|
205
|
+
accept: "application/json"
|
|
206
|
+
};
|
|
207
|
+
let body;
|
|
208
|
+
if (options.body !== undefined) {
|
|
209
|
+
headers["content-type"] = "application/json";
|
|
210
|
+
body = JSON.stringify(options.body);
|
|
211
|
+
}
|
|
212
|
+
let response;
|
|
213
|
+
try {
|
|
214
|
+
response = await fetch(url, { method, headers, body, redirect: "error" });
|
|
215
|
+
} catch (error) {
|
|
216
|
+
throw new NetworkError("rocketchat", `Rocket.Chat API request failed: ${method} ${path}`, error instanceof Error ? error : undefined);
|
|
217
|
+
}
|
|
218
|
+
if (!response.ok) {
|
|
219
|
+
await this.throwApiError(response, method, path);
|
|
220
|
+
}
|
|
221
|
+
return await response.json();
|
|
222
|
+
}
|
|
223
|
+
async throwApiError(response, method, path) {
|
|
224
|
+
const detail = await response.text().catch(() => "");
|
|
225
|
+
this.logger.debug("Rocket.Chat API error", {
|
|
226
|
+
method,
|
|
227
|
+
path,
|
|
228
|
+
status: response.status,
|
|
229
|
+
detail
|
|
230
|
+
});
|
|
231
|
+
const parsed = parseRocketChatErrorMessage(detail);
|
|
232
|
+
switch (response.status) {
|
|
233
|
+
case 401:
|
|
234
|
+
throw new AuthenticationError3("rocketchat", "Rocket.Chat rejected the credentials. Check that ROCKETCHAT_TOKEN and ROCKETCHAT_USER_ID are valid.");
|
|
235
|
+
case 403:
|
|
236
|
+
throw new PermissionError("rocketchat", `${method} ${path}`, "api");
|
|
237
|
+
case 404:
|
|
238
|
+
throw new ResourceNotFoundError("rocketchat", "resource", path);
|
|
239
|
+
case 429: {
|
|
240
|
+
const retryAfter = Number.parseInt(response.headers.get("retry-after") ?? "", 10);
|
|
241
|
+
throw new AdapterRateLimitError("rocketchat", Number.isNaN(retryAfter) ? undefined : retryAfter);
|
|
242
|
+
}
|
|
243
|
+
case 400:
|
|
244
|
+
throw new ValidationError("rocketchat", parsed ?? `Invalid request: ${method} ${path}`);
|
|
245
|
+
default:
|
|
246
|
+
throw new NetworkError("rocketchat", `Rocket.Chat API error ${response.status}: ${parsed ?? detail}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async handleWebhook(request, options) {
|
|
250
|
+
const body = await request.text();
|
|
251
|
+
let payload;
|
|
252
|
+
try {
|
|
253
|
+
payload = JSON.parse(body);
|
|
254
|
+
} catch {
|
|
255
|
+
this.logger.error("Rocket.Chat webhook invalid JSON");
|
|
256
|
+
return new Response("Invalid JSON", { status: 400 });
|
|
257
|
+
}
|
|
258
|
+
if (typeof payload !== "object" || payload === null) {
|
|
259
|
+
return new Response("ok", { status: 200 });
|
|
260
|
+
}
|
|
261
|
+
if (!this.verifyToken(payload.token)) {
|
|
262
|
+
this.logger.debug("Rocket.Chat webhook token verification failed");
|
|
263
|
+
return new Response("Invalid token", { status: 401 });
|
|
264
|
+
}
|
|
265
|
+
if (!this.chat) {
|
|
266
|
+
this.logger.warn("Chat instance not initialized, ignoring message");
|
|
267
|
+
return new Response("ok", { status: 200 });
|
|
268
|
+
}
|
|
269
|
+
if (payload.bot || this.isSelf(payload.user_id)) {
|
|
270
|
+
this.logger.debug("Ignoring message from self", {
|
|
271
|
+
messageId: payload.message_id
|
|
272
|
+
});
|
|
273
|
+
return new Response("ok", { status: 200 });
|
|
274
|
+
}
|
|
275
|
+
const message = this.buildMessageFromWebhook(payload);
|
|
276
|
+
this.chat.processMessage(this, message.threadId, message, options);
|
|
277
|
+
return new Response("ok", { status: 200 });
|
|
278
|
+
}
|
|
279
|
+
verifyToken(token) {
|
|
280
|
+
if (!token) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
const expected = createHash("sha256").update(this.webhookToken).digest();
|
|
284
|
+
const received = createHash("sha256").update(token).digest();
|
|
285
|
+
return timingSafeEqual(expected, received);
|
|
286
|
+
}
|
|
287
|
+
buildMessageFromWebhook(payload) {
|
|
288
|
+
const message = {
|
|
289
|
+
_id: payload.message_id,
|
|
290
|
+
msg: payload.text,
|
|
291
|
+
rid: payload.channel_id,
|
|
292
|
+
ts: payload.timestamp,
|
|
293
|
+
u: {
|
|
294
|
+
_id: payload.user_id,
|
|
295
|
+
username: payload.user_name
|
|
296
|
+
},
|
|
297
|
+
...payload.tmid ? { tmid: payload.tmid } : {}
|
|
298
|
+
};
|
|
299
|
+
return this.buildMessage({ message, roomId: payload.channel_id });
|
|
300
|
+
}
|
|
301
|
+
parseMessage(raw) {
|
|
302
|
+
return this.buildMessage(raw);
|
|
303
|
+
}
|
|
304
|
+
buildMessage(raw) {
|
|
305
|
+
const { message } = raw;
|
|
306
|
+
const threadId = this.encodeThreadId({
|
|
307
|
+
roomId: raw.roomId,
|
|
308
|
+
...message.tmid ? { tmid: message.tmid } : {}
|
|
309
|
+
});
|
|
310
|
+
const { formatted, text } = this.formatConverter.parseIncoming(message.msg);
|
|
311
|
+
return new Message3({
|
|
312
|
+
id: message._id,
|
|
313
|
+
threadId,
|
|
314
|
+
text,
|
|
315
|
+
formatted,
|
|
316
|
+
raw,
|
|
317
|
+
author: this.parseAuthor(message.u),
|
|
318
|
+
isMention: mentionsUser(text, this._userName),
|
|
319
|
+
metadata: {
|
|
320
|
+
dateSent: parseRocketChatDate(message.ts),
|
|
321
|
+
edited: Boolean(message.editedAt),
|
|
322
|
+
...message.editedAt ? { editedAt: parseRocketChatDate(message.editedAt) } : {}
|
|
323
|
+
},
|
|
324
|
+
attachments: []
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
parseAuthor(user) {
|
|
328
|
+
return {
|
|
329
|
+
userId: user._id,
|
|
330
|
+
userName: user.username,
|
|
331
|
+
fullName: user.name || user.username,
|
|
332
|
+
isBot: "unknown",
|
|
333
|
+
isMe: this.isSelf(user._id)
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
renderBody(message) {
|
|
337
|
+
const body = this.formatConverter.renderPostable(message);
|
|
338
|
+
return convertRocketChatEmojiPlaceholders(body);
|
|
339
|
+
}
|
|
340
|
+
async postMessage(threadId, message) {
|
|
341
|
+
const thread = this.decodeThreadId(threadId);
|
|
342
|
+
const text = this.renderBody(message);
|
|
343
|
+
const response = await this.request("POST", "/chat.postMessage", {
|
|
344
|
+
body: {
|
|
345
|
+
roomId: thread.roomId,
|
|
346
|
+
text,
|
|
347
|
+
...thread.tmid ? { tmid: thread.tmid } : {}
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
return {
|
|
351
|
+
id: response.message._id,
|
|
352
|
+
threadId,
|
|
353
|
+
raw: { message: response.message, roomId: thread.roomId }
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
async editMessage(threadId, messageId, message) {
|
|
357
|
+
const thread = this.decodeThreadId(threadId);
|
|
358
|
+
const response = await this.request("POST", "/chat.update", {
|
|
359
|
+
body: {
|
|
360
|
+
roomId: thread.roomId,
|
|
361
|
+
msgId: messageId,
|
|
362
|
+
text: this.renderBody(message)
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
return {
|
|
366
|
+
id: response.message._id,
|
|
367
|
+
threadId,
|
|
368
|
+
raw: { message: response.message, roomId: thread.roomId }
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
async deleteMessage(threadId, messageId) {
|
|
372
|
+
const thread = this.decodeThreadId(threadId);
|
|
373
|
+
await this.request("POST", "/chat.delete", {
|
|
374
|
+
body: { roomId: thread.roomId, msgId: messageId }
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
async addReaction(_threadId, messageId, emoji) {
|
|
378
|
+
await this.request("POST", "/chat.react", {
|
|
379
|
+
body: {
|
|
380
|
+
messageId,
|
|
381
|
+
emoji: this.toRocketChatEmoji(emoji),
|
|
382
|
+
shouldReact: true
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
async removeReaction(_threadId, messageId, emoji) {
|
|
387
|
+
await this.request("POST", "/chat.react", {
|
|
388
|
+
body: {
|
|
389
|
+
messageId,
|
|
390
|
+
emoji: this.toRocketChatEmoji(emoji),
|
|
391
|
+
shouldReact: false
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
toRocketChatEmoji(emoji) {
|
|
396
|
+
const name = typeof emoji === "string" ? emoji : emoji.name;
|
|
397
|
+
return defaultEmojiResolver2.toSlack(name);
|
|
398
|
+
}
|
|
399
|
+
async startTyping(_threadId, _status) {}
|
|
400
|
+
async fetchMessages(threadId, options) {
|
|
401
|
+
const thread = this.decodeThreadId(threadId);
|
|
402
|
+
const limit = options?.limit ?? 50;
|
|
403
|
+
const direction = options?.direction ?? "backward";
|
|
404
|
+
if (thread.tmid) {
|
|
405
|
+
const response = await this.request("GET", "/chat.getThreadMessages", {
|
|
406
|
+
query: {
|
|
407
|
+
tmid: thread.tmid,
|
|
408
|
+
count: limit,
|
|
409
|
+
offset: options?.cursor && /^\d+$/.test(options.cursor) ? Number.parseInt(options.cursor, 10) : undefined,
|
|
410
|
+
sort: JSON.stringify({ ts: direction === "backward" ? -1 : 1 })
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
const messages = response.messages.map((message) => this.buildMessage({ message, roomId: thread.roomId })).sort((a, b) => a.metadata.dateSent.getTime() - b.metadata.dateSent.getTime());
|
|
414
|
+
const nextOffset = response.offset + response.count;
|
|
415
|
+
return {
|
|
416
|
+
messages,
|
|
417
|
+
nextCursor: nextOffset < response.total ? String(nextOffset) : undefined
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
const response = await this.request("GET", "/rooms.history", {
|
|
421
|
+
query: {
|
|
422
|
+
roomId: thread.roomId,
|
|
423
|
+
count: limit,
|
|
424
|
+
...direction === "backward" ? { previous: options?.cursor } : { next: options?.cursor }
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
const messages = [...response.messages].reverse().map((message) => this.buildMessage({ message, roomId: thread.roomId }));
|
|
428
|
+
const nextCursor = direction === "backward" ? response.cursor?.previous ?? undefined : response.cursor?.next ?? undefined;
|
|
429
|
+
return { messages, nextCursor };
|
|
430
|
+
}
|
|
431
|
+
async fetchMessage(threadId, messageId) {
|
|
432
|
+
const thread = this.decodeThreadId(threadId);
|
|
433
|
+
try {
|
|
434
|
+
const response = await this.request("GET", "/chat.getMessage", {
|
|
435
|
+
query: { msgId: messageId }
|
|
436
|
+
});
|
|
437
|
+
return this.buildMessage({
|
|
438
|
+
message: response.message,
|
|
439
|
+
roomId: thread.roomId
|
|
440
|
+
});
|
|
441
|
+
} catch (error) {
|
|
442
|
+
if (error instanceof ResourceNotFoundError) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
throw error;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
async fetchThread(threadId) {
|
|
449
|
+
const thread = this.decodeThreadId(threadId);
|
|
450
|
+
const response = await this.request("GET", "/rooms.info", {
|
|
451
|
+
query: { roomId: thread.roomId }
|
|
452
|
+
});
|
|
453
|
+
const { room } = response;
|
|
454
|
+
return {
|
|
455
|
+
id: threadId,
|
|
456
|
+
channelId: `rocketchat:${thread.roomId}`,
|
|
457
|
+
channelName: room.fname ?? room.name,
|
|
458
|
+
isDM: room.t === "d",
|
|
459
|
+
metadata: { roomId: thread.roomId, type: room.t, topic: room.topic }
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
async fetchChannelInfo(channelId) {
|
|
463
|
+
const roomId = this.decodeChannelId(channelId);
|
|
464
|
+
const response = await this.request("GET", "/rooms.info", {
|
|
465
|
+
query: { roomId }
|
|
466
|
+
});
|
|
467
|
+
const { room } = response;
|
|
468
|
+
return {
|
|
469
|
+
id: channelId,
|
|
470
|
+
name: room.fname ?? room.name ?? roomId,
|
|
471
|
+
isDM: room.t === "d",
|
|
472
|
+
metadata: { roomId, type: room.t, topic: room.topic }
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
renderFormatted(content) {
|
|
476
|
+
return this.formatConverter.fromAst(content);
|
|
477
|
+
}
|
|
478
|
+
async getUser(userId) {
|
|
479
|
+
try {
|
|
480
|
+
const response = await this.request("GET", "/users.info", {
|
|
481
|
+
query: { userId }
|
|
482
|
+
});
|
|
483
|
+
const { user } = response;
|
|
484
|
+
return {
|
|
485
|
+
fullName: user.name || user.username,
|
|
486
|
+
isBot: user.type === "bot" || user.type === "app",
|
|
487
|
+
userId: user._id,
|
|
488
|
+
userName: user.username,
|
|
489
|
+
...user.emails?.[0]?.address ? { email: user.emails[0].address } : {}
|
|
490
|
+
};
|
|
491
|
+
} catch (error) {
|
|
492
|
+
this.logger.debug("Failed to fetch user", { userId, error });
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
encodeThreadId(platformData) {
|
|
497
|
+
const { roomId, tmid } = platformData;
|
|
498
|
+
return tmid ? `rocketchat:${roomId}:${tmid}` : `rocketchat:${roomId}`;
|
|
499
|
+
}
|
|
500
|
+
decodeThreadId(threadId) {
|
|
501
|
+
const match = threadId.match(THREAD_ID_PATTERN);
|
|
502
|
+
const roomId = match?.[1];
|
|
503
|
+
if (!match || !roomId) {
|
|
504
|
+
throw new ValidationError("rocketchat", `Invalid Rocket.Chat thread ID: ${threadId}`);
|
|
505
|
+
}
|
|
506
|
+
return { roomId, ...match[2] ? { tmid: match[2] } : {} };
|
|
507
|
+
}
|
|
508
|
+
channelIdFromThreadId(threadId) {
|
|
509
|
+
return `rocketchat:${this.decodeThreadId(threadId).roomId}`;
|
|
510
|
+
}
|
|
511
|
+
decodeChannelId(channelId) {
|
|
512
|
+
const roomId = channelId.match(CHANNEL_ID_PATTERN)?.[1];
|
|
513
|
+
if (!roomId) {
|
|
514
|
+
throw new ValidationError("rocketchat", `Invalid Rocket.Chat channel ID: ${channelId}`);
|
|
515
|
+
}
|
|
516
|
+
return roomId;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function parseRocketChatErrorMessage(detail) {
|
|
520
|
+
let parsed;
|
|
521
|
+
try {
|
|
522
|
+
parsed = JSON.parse(detail);
|
|
523
|
+
} catch {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const { error } = parsed;
|
|
530
|
+
return typeof error === "string" ? error : undefined;
|
|
531
|
+
}
|
|
532
|
+
function trimTrailingSlashes(url) {
|
|
533
|
+
let end = url.length;
|
|
534
|
+
while (end > 0 && url[end - 1] === "/") {
|
|
535
|
+
end -= 1;
|
|
536
|
+
}
|
|
537
|
+
return url.slice(0, end);
|
|
538
|
+
}
|
|
539
|
+
function parseRocketChatDate(value) {
|
|
540
|
+
return /^\d+$/.test(value) ? new Date(Number.parseInt(value, 10)) : new Date(value);
|
|
541
|
+
}
|
|
542
|
+
function mentionsUser(text, userName) {
|
|
543
|
+
const pattern = new RegExp(`(?<!\\w)@${userName.replace(REGEX_SPECIAL_PATTERN, "\\$&")}(?![\\w-])`, "i");
|
|
544
|
+
return pattern.test(text);
|
|
545
|
+
}
|
|
546
|
+
function convertRocketChatEmojiPlaceholders(text) {
|
|
547
|
+
return text.replace(EMOJI_PLACEHOLDER_REGEX, (_, emojiName) => {
|
|
548
|
+
return `:${defaultEmojiResolver2.toSlack(emojiName)}:`;
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
function createRocketChatAdapter(config) {
|
|
552
|
+
return new RocketChatAdapter(config);
|
|
553
|
+
}
|
|
554
|
+
var DEFAULT_USER_NAME = "rocketchat-bot", THREAD_ID_PATTERN, CHANNEL_ID_PATTERN, REGEX_SPECIAL_PATTERN, EMOJI_PLACEHOLDER_REGEX;
|
|
555
|
+
var init_rocketchat = __esm(() => {
|
|
556
|
+
init_dist7();
|
|
557
|
+
init_dist8();
|
|
558
|
+
init_markdown();
|
|
559
|
+
init_markdown();
|
|
560
|
+
THREAD_ID_PATTERN = /^rocketchat:([^:]+)(?::([^:]+))?$/;
|
|
561
|
+
CHANNEL_ID_PATTERN = /^rocketchat:([^:]+)$/;
|
|
562
|
+
REGEX_SPECIAL_PATTERN = /[.*+?^${}()|[\]\\]/g;
|
|
563
|
+
EMOJI_PLACEHOLDER_REGEX = /\{\{emoji:([a-z0-9_]+)\}\}/gi;
|
|
564
|
+
});
|
|
565
|
+
init_rocketchat();
|
|
566
|
+
|
|
567
|
+
export {
|
|
568
|
+
createRocketChatAdapter
|
|
569
|
+
};
|
|
@@ -4,24 +4,24 @@ import {
|
|
|
4
4
|
SKILL_FILE_LIMITS2,
|
|
5
5
|
normalizeSkillFilePath2,
|
|
6
6
|
init_db4
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-erh1rgh4.js";
|
|
8
8
|
import {
|
|
9
9
|
runSeeder
|
|
10
|
-
} from "./cli-
|
|
11
|
-
import"./cli-
|
|
12
|
-
import"./cli-
|
|
13
|
-
import"./cli-
|
|
14
|
-
import"./cli-
|
|
15
|
-
import"./cli-
|
|
16
|
-
import"./cli-
|
|
17
|
-
import"./cli-
|
|
18
|
-
import"./cli-
|
|
19
|
-
import"./cli-
|
|
20
|
-
import"./cli-
|
|
21
|
-
import"./cli-
|
|
10
|
+
} from "./cli-1gevjrc1.js";
|
|
11
|
+
import"./cli-ka13xx6b.js";
|
|
12
|
+
import"./cli-e87fg3en.js";
|
|
13
|
+
import"./cli-vr4eyq6p.js";
|
|
14
|
+
import"./cli-r8ddn0hf.js";
|
|
15
|
+
import"./cli-vx9acp12.js";
|
|
16
|
+
import"./cli-69eq6gdk.js";
|
|
17
|
+
import"./cli-f1sdh8ca.js";
|
|
18
|
+
import"./cli-fcwrd7bh.js";
|
|
19
|
+
import"./cli-n14r8h4n.js";
|
|
20
|
+
import"./cli-8qvte9hn.js";
|
|
21
|
+
import"./cli-m1wddksc.js";
|
|
22
22
|
import"./cli-y260hgep.js";
|
|
23
|
-
import"./cli-
|
|
24
|
-
import"./cli-
|
|
23
|
+
import"./cli-tceqvv6h.js";
|
|
24
|
+
import"./cli-2wde56gv.js";
|
|
25
25
|
import {
|
|
26
26
|
getExecutorRegistry2,
|
|
27
27
|
init_workflows,
|
|
@@ -30,12 +30,12 @@ import {
|
|
|
30
30
|
skillSpecOf,
|
|
31
31
|
skillHash,
|
|
32
32
|
init_assets
|
|
33
|
-
} from "./cli-
|
|
33
|
+
} from "./cli-dnvmwsvc.js";
|
|
34
34
|
import {
|
|
35
35
|
installImportedSkills,
|
|
36
36
|
prepareSeeders,
|
|
37
37
|
init_seeders
|
|
38
|
-
} from "./cli-
|
|
38
|
+
} from "./cli-5k1hvycs.js";
|
|
39
39
|
import {
|
|
40
40
|
validateScriptImports,
|
|
41
41
|
init_import_allowlist,
|
|
@@ -47,23 +47,23 @@ import {
|
|
|
47
47
|
init_typecheck,
|
|
48
48
|
parseSkillContent,
|
|
49
49
|
init_skill_parser
|
|
50
|
-
} from "./cli-
|
|
51
|
-
import"./cli-
|
|
52
|
-
import"./cli-
|
|
53
|
-
import"./cli-
|
|
54
|
-
import"./cli-
|
|
50
|
+
} from "./cli-nkfv398a.js";
|
|
51
|
+
import"./cli-xerdrnqs.js";
|
|
52
|
+
import"./cli-wdtqkqnq.js";
|
|
53
|
+
import"./cli-j2ybkdk2.js";
|
|
54
|
+
import"./cli-4djg31jh.js";
|
|
55
55
|
import {
|
|
56
56
|
validateDefinition,
|
|
57
57
|
init_definition2
|
|
58
|
-
} from "./cli-
|
|
59
|
-
import"./cli-
|
|
60
|
-
import"./cli-
|
|
61
|
-
import"./cli-
|
|
62
|
-
import"./cli-
|
|
58
|
+
} from "./cli-jkkcm72j.js";
|
|
59
|
+
import"./cli-b0m3bg0f.js";
|
|
60
|
+
import"./cli-b0kqw55g.js";
|
|
61
|
+
import"./cli-xysy1g8x.js";
|
|
62
|
+
import"./cli-getrvmtx.js";
|
|
63
63
|
import {
|
|
64
64
|
IDENTITY_MD_MAX_CHARS,
|
|
65
65
|
init_identity_field_budget
|
|
66
|
-
} from "./cli-
|
|
66
|
+
} from "./cli-s6fhqbz1.js";
|
|
67
67
|
import {
|
|
68
68
|
isSafeBundlePath,
|
|
69
69
|
init_bundle_path,
|