@gaodefa/daocore 2026.5.29 → 2026.5.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abort-DI3P6TIb.js +277 -0
- package/dist/abort.runtime-B6Z7lDEa.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/account-inspect-BFz7X0TX.js +173 -0
- package/dist/accounts-BoYYrY7x.js +107 -0
- package/dist/accounts-Busq29zW.js +107 -0
- package/dist/accounts-CuvH2tuN.js +119 -0
- package/dist/accounts-DkIcqvf7.js +2 -0
- package/dist/acp-runtime-BA8lzXzf.js +26 -0
- package/dist/acp-spawn-DPz2aX3A.js +2 -0
- package/dist/acp-spawn-DvVCsWYV.js +1275 -0
- package/dist/acp-stateful-target-driver-DcC76aZW.js +89 -0
- package/dist/action-kill-D-dVisIX.js +33 -0
- package/dist/action-runtime-BEiqwxDD.js +469 -0
- package/dist/action-runtime-api-1LzcGjcX.js +2 -0
- package/dist/action-send-c3CnDuPg.js +39 -0
- package/dist/action-spawn-Dj4kwpWs.js +47 -0
- package/dist/actions-qLccmQBc.js +161 -0
- package/dist/actions.runtime-B5vYAgNi.js +5 -0
- package/dist/agent-command-D6Ds198G.js +1367 -0
- package/dist/agent-components.runtime-xquK0B3L.js +10 -0
- package/dist/agent-components.runtime.js +1 -1
- package/dist/agent-harness-runtime-Dq1fCBOM.js +180 -0
- package/dist/agent-harness-task-runtime-DvSEqFkD.js +140 -0
- package/dist/agent-lm5ZYOFy.js +3 -0
- package/dist/agent-runner-execution-Dbh2pDhQ.js +1713 -0
- package/dist/agent-runner-utils-Di3r2T1T.js +266 -0
- package/dist/agent-runner.runtime-BW90EcGW.js +3455 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-BgIT5Ytc.js +229 -0
- package/dist/agent-via-gateway-DMMS8-hK.js +463 -0
- package/dist/agent-ylolD8-V.js +2 -0
- package/dist/api-BB4vXLtW.js +2 -0
- package/dist/api-CUhM3KNB.js +134 -0
- package/dist/api-CewRHSbT.js +6 -0
- package/dist/api-CfKjNJlW.js +2 -0
- package/dist/api-Rsnqui1u.js +3 -0
- package/dist/api-k7AvxwHr.js +639 -0
- package/dist/apply-DQ4TQNMA.js +54 -0
- package/dist/apply-S_75Py4Y.js +41 -0
- package/dist/approval-handler.runtime-Cthxrstu.js +130 -0
- package/dist/assistant-Cp9pGaBw.js +291 -0
- package/dist/attachment-normalize-5R0bLLOj.js +225 -0
- package/dist/attempt-execution-DuyyZYsU.js +558 -0
- package/dist/attempt-execution.runtime-DF2GPgNh.js +3 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt-execution.shared-CwdukA3t.js +38 -0
- package/dist/attempt.prompt-helpers-CUqKtIa5.js +475 -0
- package/dist/attempt.tool-run-context-BbN4_BYO.js +2094 -0
- package/dist/binding-routing-C6Ex2Blu.js +113 -0
- package/dist/binding-targets-BqREncSL.js +121 -0
- package/dist/bot-DGMEkaIJ.js +7894 -0
- package/dist/bot-deps-BltYjeMX.js +2 -0
- package/dist/bot-deps-XvGCor9f.js +747 -0
- package/dist/bot-message-context.runtime-kK-xvLV7.js +7 -0
- package/dist/bot-message-context.runtime.js +1 -1
- package/dist/bot-message-context.session.runtime-DpOIJUae.js +12 -0
- package/dist/bot-message-context.session.runtime.js +1 -1
- package/dist/bot-native-commands.delivery.runtime-D49p5Lc1.js +4 -0
- package/dist/bot-native-commands.delivery.runtime.js +1 -1
- package/dist/bot-native-commands.runtime-8XBdSpkQ.js +13 -0
- package/dist/bot-native-commands.runtime.js +1 -1
- package/dist/bridge-server-y_XGduPx.js +113 -0
- package/dist/browser-cli-B2jmmTT3.js +230 -0
- package/dist/browser-cli-actions-input-JQt5ZQcn.js +473 -0
- package/dist/browser-cli-actions-observe-CrfKh6AX.js +81 -0
- package/dist/browser-cli-debug-DQACWlvC.js +137 -0
- package/dist/browser-cli-inspect-DDnxx0Xw.js +104 -0
- package/dist/browser-cli-lEuOnZzs.js +2 -0
- package/dist/browser-cli-manage-DogmwtYt.js +443 -0
- package/dist/browser-cli-resize-BHuV71VZ.js +26 -0
- package/dist/browser-cli-shared-CidShgoF.js +50 -0
- package/dist/browser-cli-state-i8cCGbiQ.js +337 -0
- package/dist/browser-control-auth-CKfXdXWj.js +2 -0
- package/dist/browser-profiles-ATBTvUGh.js +2 -0
- package/dist/browser-runtime-KmCT6FuL.js +384 -0
- package/dist/build-DOOT6f62.js +257 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capability-cli-DwvrwB-g.js +1782 -0
- package/dist/channel-B-wgK1bK.js +481 -0
- package/dist/channel-B1e_k1P0.js +867 -0
- package/dist/channel-BRDfa5tc.js +1777 -0
- package/dist/channel-BVEO1O4p.js +376 -0
- package/dist/channel-BYlO5l1d.js +508 -0
- package/dist/channel-Bl0sPoNx.js +653 -0
- package/dist/channel-C84xtDBy.js +1134 -0
- package/dist/channel-CLgKq4Ds.js +1556 -0
- package/dist/channel-CZT0qxLh.js +1249 -0
- package/dist/channel-CffBHWkb.js +955 -0
- package/dist/channel-D34ZJvVB.js +2126 -0
- package/dist/channel-DcdXLo_W.js +238 -0
- package/dist/channel-DnK5TrXV.js +362 -0
- package/dist/channel-Dzj4RHY2.js +740 -0
- package/dist/channel-OhZzLZCj.js +562 -0
- package/dist/channel-actions.runtime-Cdvhqc9s.js +265 -0
- package/dist/channel-actions.runtime.js +1 -1
- package/dist/channel-core-Dz9I_R4j.js +5 -0
- package/dist/channel-inbound-COGoV_aS.js +80 -0
- package/dist/channel-mP6HCIMr.js +1496 -0
- package/dist/channel-plugin-runtime-C0R46KeG.js +998 -0
- package/dist/channel-quGdgWel.js +808 -0
- package/dist/channel-runtime-FvPQoIF9.js +408 -0
- package/dist/channel.runtime-2vUz3gij.js +109 -0
- package/dist/channel.runtime-BZLDSNuQ.js +254 -0
- package/dist/channel.runtime-Bo5jO0Hj.js +4 -0
- package/dist/channel.runtime-CDgvrjM2.js +652 -0
- package/dist/channel.runtime-COf8SDFn.js +88 -0
- package/dist/channel.runtime-C_C1f8lu.js +733 -0
- package/dist/channel.runtime-CqPbsg8t.js +2528 -0
- package/dist/channel.runtime-DtV85Khx.js +1008 -0
- package/dist/channel.runtime-Spt1ukGW.js +21009 -0
- package/dist/channel.setup-Bc0LUQS1.js +1098 -0
- package/dist/channel.setup-ChTkj2hq.js +343 -0
- package/dist/channel.setup-CpMD9F8i.js +10 -0
- package/dist/chat-mUsjD5YN.js +2666 -0
- package/dist/chrome-u314zcbM.js +1503 -0
- package/dist/cli/run-main.js +5 -5
- package/dist/cli-CJMoqXrc.js +1341 -0
- package/dist/cli-compaction-qGYB7suI.js +347 -0
- package/dist/cli-metadata-BBJFpNU9.js +22 -0
- package/dist/cli-runner-C0kcts0I.js +540 -0
- package/dist/cli-runner-CTm8K6s8.js +2 -0
- package/dist/cli-runner.runtime-C8deL5FL.js +3 -0
- package/dist/cli-runner.runtime-DDAg1D0L.js +4 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-startup-metadata.json +8 -8
- package/dist/client-CPxpgs4m.js +650 -0
- package/dist/client-adapter-CLlqOqfu.js +897 -0
- package/dist/client-factory-R7Rr2jwn.js +9 -0
- package/dist/command-auth-CkQP1buP.js +135 -0
- package/dist/command-handlers-CJEjFyMk.js +1609 -0
- package/dist/command-registry-BDgyOqDw.js +4 -0
- package/dist/command-registry-BVi5Jn1S.js +9 -0
- package/dist/command-registry-core-JCfsVRtz.js +110 -0
- package/dist/command-status.runtime-CM1JLzi6.js +90 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands-acp-C1-I78U6.js +74 -0
- package/dist/commands-compact.runtime-DOsNavwp.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-handlers.runtime-BD1n2WGw.js +6154 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-status-DU_UTQz1.js +16 -0
- package/dist/commands-status-DejfTakp.js +3 -0
- package/dist/commands-status.runtime-DejfTakp.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-D7vo_2Y_.js +3 -0
- package/dist/commands-subagents-control.runtime-DGybTjJ6.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-BEBXAMea.js +2 -0
- package/dist/commands-system-prompt-gj3oQpQO.js +162 -0
- package/dist/commands.runtime-CgXX70IN.js +176 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/commitments/runtime.js +1 -1
- package/dist/compact-C41XxMDt.js +480 -0
- package/dist/compact-DUVAF9EC.js +1141 -0
- package/dist/compact.runtime-COMRg6s3.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-CmEYoB9a.js +315 -0
- package/dist/computer-use-BwJHu1QF.js +367 -0
- package/dist/config-ATBTvUGh.js +2 -0
- package/dist/config-DlNgjF8W.js +373 -0
- package/dist/config-mutations-tl_OqI6d.js +159 -0
- package/dist/context-engine-host-compat-BNPAIK9F.js +288 -0
- package/dist/context-engine-host-compat-C69CK7zS.js +2 -0
- package/dist/context-engine-lifecycle-iQ8f5a_-.js +1274 -0
- package/dist/control-auth-vVxyGKxY.js +114 -0
- package/dist/control-service-73nj79EW.js +145 -0
- package/dist/control-ui/assets/agents-DdWIz8Vk.js +1008 -0
- package/dist/control-ui/assets/channel-config-extras-C7ELhuDi.js +2 -0
- package/dist/control-ui/assets/channels-Bsoj-9BS.js +367 -0
- package/dist/control-ui/assets/cron-BRTEw1tT.js +1013 -0
- package/dist/control-ui/assets/debug-EKl_F8_L.js +97 -0
- package/dist/control-ui/assets/index-DSbSO7ys.js +7370 -0
- package/dist/control-ui/assets/instances-B1AoYwI5.js +57 -0
- package/dist/control-ui/assets/logs-BChOznzh.js +74 -0
- package/dist/control-ui/assets/nodes-5yebKh9k.js +436 -0
- package/dist/control-ui/assets/sessions-BlDYNThc.js +399 -0
- package/dist/control-ui/assets/skills-shared-CNFnf7KU.js +11 -0
- package/dist/control-ui/assets/skills-uxTDRmLx.js +314 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/sw.js +1 -1
- package/dist/conversation-binding-runtime-CmoTKcY1.js +4 -0
- package/dist/conversation-runtime-BxOHxuin.js +31 -0
- package/dist/core-D0Y2H55f.js +282 -0
- package/dist/core-api-BKlJUtDt.js +5 -0
- package/dist/core-api-_fiftUHn.js +2 -0
- package/dist/crestodian/crestodian.js +1 -1
- package/dist/crestodian/rescue-message.js +1 -1
- package/dist/crestodian-BJifoQiR.js +55 -0
- package/dist/daocore-tools-BMdF8RwK.js +11727 -0
- package/dist/delivery-e2ci_bcX.js +1002 -0
- package/dist/dialogue-BXayGhnz.js +37 -0
- package/dist/dir-fetch-tool-Cara5mZh.js +565 -0
- package/dist/dir-list-tool-CQ8Bo5Ez.js +100 -0
- package/dist/direct-dm-CPk6Qm9D.js +64 -0
- package/dist/directive-handling.fast-lane-BQ9aXqk8.js +68 -0
- package/dist/directive-handling.impl--a5AGurq.js +818 -0
- package/dist/directive-handling.impl-C4JqMwle.js +2 -0
- package/dist/directive-handling.model-selection-pyTYMIXn.js +122 -0
- package/dist/directive-handling.persist.runtime-B7vWT1r9.js +263 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/dispatch-3Ru_eGq1.js +1640 -0
- package/dist/dispatch-acp-transcript.runtime-CYMP-5oE.js +40 -0
- package/dist/dispatch-acp-transcript.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-BVCiklXk.js +18 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/doctor-B8mR3Sgr.js +2 -0
- package/dist/doctor-BJ6DuerV.js +6 -0
- package/dist/doctor-config-flow-BdOGs_zn.js +1741 -0
- package/dist/doctor-core-checks-CDf0stz-.js +2 -0
- package/dist/doctor-core-checks-Cpdnu2XI.js +573 -0
- package/dist/doctor-health-0qv_acBu.js +65 -0
- package/dist/doctor-health-contributions-Db1FQgFw.js +696 -0
- package/dist/doctor-lint-C1g4Llgl.js +94 -0
- package/dist/doctor-state-integrity-C8iXFLJ7.js +1231 -0
- package/dist/doctor-update-CsPu6p3d.js +58 -0
- package/dist/dynamic-tools-YQ0z0YKH.js +486 -0
- package/dist/embedded-backend-S0cahIZw.js +579 -0
- package/dist/embedded-gateway-stub.runtime-Cjw12ALm.js +12 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/exec-approvals-ArHHjoE-.js +149 -0
- package/dist/extensionAPI.js +1 -1
- package/dist/extensions/active-memory/index.js +1 -1
- package/dist/extensions/admin-http-rpc/index.js +1 -1
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-config.js +4 -4
- package/dist/extensions/browser/browser-control-auth.js +2 -2
- package/dist/extensions/browser/browser-doctor.js +2 -2
- package/dist/extensions/browser/browser-maintenance.js +1 -1
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +11 -11
- package/dist/extensions/browser/cli-metadata.js +1 -1
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.js +4 -4
- package/dist/extensions/browser/runtime-api.js +13 -13
- package/dist/extensions/canvas/index.js +1 -1
- package/dist/extensions/clickclack/api.js +2 -2
- package/dist/extensions/clickclack/channel-plugin-api.js +1 -1
- package/dist/extensions/clickclack/runtime-api.js +2 -2
- package/dist/extensions/device-pair/api.js +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/file-transfer/index.js +4 -4
- package/dist/extensions/imessage/api.js +2 -2
- package/dist/extensions/imessage/channel-plugin-api.js +1 -1
- package/dist/extensions/imessage/message-tool-api.d.ts +1 -1
- package/dist/extensions/imessage/runtime-api.js +3 -3
- package/dist/extensions/irc/api.js +2 -2
- package/dist/extensions/irc/channel-plugin-api.js +1 -1
- package/dist/extensions/llm-task/index.js +1 -1
- package/dist/extensions/mattermost/api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-runtime.js +1 -1
- package/dist/extensions/mattermost/policy-api.js +1 -1
- package/dist/extensions/mattermost/runtime-api.js +2 -2
- package/dist/extensions/mattermost/slash-route-api.js +1 -1
- package/dist/extensions/memory-core/cli-metadata.js +1 -1
- package/dist/extensions/migrate-claude/apply.js +1 -1
- package/dist/extensions/migrate-claude/index.js +1 -1
- package/dist/extensions/migrate-claude/plan.js +1 -1
- package/dist/extensions/migrate-claude/provider.js +1 -1
- package/dist/extensions/migrate-claude/targets.js +1 -1
- package/dist/extensions/migrate-hermes/apply.js +1 -1
- package/dist/extensions/migrate-hermes/index.js +1 -1
- package/dist/extensions/migrate-hermes/model.js +1 -1
- package/dist/extensions/migrate-hermes/plan.js +1 -1
- package/dist/extensions/migrate-hermes/provider.js +1 -1
- package/dist/extensions/migrate-hermes/secrets.js +1 -1
- package/dist/extensions/migrate-hermes/targets.js +1 -1
- package/dist/extensions/policy/api.js +1 -1
- package/dist/extensions/policy/index.js +2 -2
- package/dist/extensions/signal/api.js +6 -6
- package/dist/extensions/signal/channel-plugin-api.js +1 -1
- package/dist/extensions/signal/reaction-runtime-api.js +1 -1
- package/dist/extensions/signal/runtime-api.js +7 -7
- package/dist/extensions/skill-workshop/api.js +1 -1
- package/dist/extensions/skill-workshop/index.js +2 -2
- package/dist/extensions/telegram/account-inspect-api.js +1 -1
- package/dist/extensions/telegram/api.js +11 -11
- package/dist/extensions/telegram/channel-plugin-api.js +2 -2
- package/dist/extensions/telegram/contract-api.js +3 -3
- package/dist/extensions/telegram/runtime-api.js +7 -7
- package/dist/extensions/telegram/security-audit-contract-api.js +1 -1
- package/dist/extensions/telegram/setup-plugin-api.js +1 -1
- package/dist/extensions/telegram/test-api.js +2 -2
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.js +1 -1
- package/dist/extensions/xai/index.js +4 -4
- package/dist/extensions/xai/realtime-transcription-provider.js +1 -1
- package/dist/extensions/xai/speech-provider.js +1 -1
- package/dist/extensions/xai/test-api.js +1 -1
- package/dist/extensions/xai/tts.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/xai-oauth.js +1 -1
- package/dist/file-fetch-tool-DQpAtjX4.js +124 -0
- package/dist/file-write-tool-CkB0oYwe.js +127 -0
- package/dist/format-DUJUpMFQ.js +1145 -0
- package/dist/gateway-cli-CQo_E4Ka.js +435 -0
- package/dist/gateway-method-runtime-1QPgVJH7.js +21 -0
- package/dist/get-reply-DfUcsC-O.js +4689 -0
- package/dist/get-reply-from-config.runtime-C95MG73O.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/graph-users-DPJe0fPs.js +1419 -0
- package/dist/group-access-DefaNJ6L.js +112 -0
- package/dist/handle-action.guild-admin-C1sy1kGJ.js +288 -0
- package/dist/harness-BgPRdmNK.js +61 -0
- package/dist/health-DFR9A1YV.js +4 -0
- package/dist/heartbeat-runner-BiYVPs25.js +5 -0
- package/dist/heartbeat-runner.runtime-Bmaq8WUA.js +4 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/hooks-CNJDuJUm.js +534 -0
- package/dist/inbound-direct-dm-runtime-DFt58p71.js +2 -0
- package/dist/inbound-reply-dispatch-kgSDM8ax.js +148 -0
- package/dist/index.js +1 -1
- package/dist/init-B0zO_U4r.js +59 -0
- package/dist/inline-buttons-B6zgQW3J.js +40 -0
- package/dist/internal-events-C3Q5t6hg.js +90 -0
- package/dist/isolated-agent-CaSU5GCJ.js +2 -0
- package/dist/isolated-agent-CnsD2TmP.js +1118 -0
- package/dist/lifecycle-i3WZDaIn.js +571 -0
- package/dist/list.probe-g0rUiVXW.js +449 -0
- package/dist/list.status-command-DG3PrmeO.js +789 -0
- package/dist/llm-slug-generator-CHlf69FU.js +78 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/local-dispatch.runtime-CDeHUp_A.js +9 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/manager.runtime-BlLMPUTq.js +2714 -0
- package/dist/manager.runtime.js +1 -1
- package/dist/markdown-to-line-r_mBHMdy.js +811 -0
- package/dist/mcp-http-C5UPIJGR.js +555 -0
- package/dist/mcp-http-CTy9gpfA.js +2 -0
- package/dist/media-understanding-provider-BT6TOuVa.js +339 -0
- package/dist/message-actions-BdcjjwFt.js +145 -0
- package/dist/message-handler-B29Tj2p2.js +1715 -0
- package/dist/message-handler-BhHb1FHI.js +384 -0
- package/dist/message-handler.preflight-ouZ_-3o8.js +1125 -0
- package/dist/message-handler.process-CrYiBx_F.js +1484 -0
- package/dist/model-CLbtocQX.js +74 -0
- package/dist/model-selection-BG_vU9Kl.js +272 -0
- package/dist/models-4KERn3ya.js +104 -0
- package/dist/models-BCa-ipxi.js +2 -0
- package/dist/models-cli-DtpGXEsf.js +256 -0
- package/dist/monitor-B-egsvmI.js +1657 -0
- package/dist/monitor-BJX9Yv7k.js +2 -0
- package/dist/monitor-BPrIy3pV.js +715 -0
- package/dist/monitor-BWknZZ7N.js +4377 -0
- package/dist/monitor-C3y_PtI1.js +60 -0
- package/dist/monitor-DCzfdqE4.js +1370 -0
- package/dist/monitor-P24epSwE.js +2788 -0
- package/dist/monitor-auth-CEG_xldE.js +179 -0
- package/dist/monitor-jEePJbbS.js +834 -0
- package/dist/monitor-polling.runtime-BzlHK11u.js +883 -0
- package/dist/monitor-polling.runtime.js +1 -1
- package/dist/monitor-webhook.runtime-vFEhk_Zj.js +387 -0
- package/dist/monitor-webhook.runtime.js +1 -1
- package/dist/monitor.account-BUIfgWXg.js +5233 -0
- package/dist/monitor.runtime-Cp7W4fhb.js +2 -0
- package/dist/monitor.runtime.js +1 -1
- package/dist/monitor.webhook-DzrbeR4T.js +180 -0
- package/dist/node-cli-sessions-CLbI14UA.js +1228 -0
- package/dist/openai-http-BM9BIA_g.js +824 -0
- package/dist/openresponses-http-CNoW9kk8.js +1173 -0
- package/dist/operations-DT4bsxV6.js +805 -0
- package/dist/outbound-adapter-CZRUOgY0.js +543 -0
- package/dist/outbound-session-route-DneMsGNx.js +45 -0
- package/dist/outbound.runtime-CHuoKJJI.js +2 -0
- package/dist/outbound.runtime.js +1 -1
- package/dist/pi-embedded-1-rsueO_.js +3796 -0
- package/dist/pi-embedded-BRfDncVO.js +4 -0
- package/dist/pi-embedded.runtime-DEYoa6bW.js +4 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-tools-C0P3NgP5.js +2413 -0
- package/dist/plan-BQUkjBMY.js +81 -0
- package/dist/plan-CRO9_2_k.js +112 -0
- package/dist/plugin-BJCmWhnh.js +12396 -0
- package/dist/plugin-app-cache-key-CXAg0F7A.js +46 -0
- package/dist/plugin-enabled-D93Z9LSo.js +233 -0
- package/dist/plugin-registration-BBrTcZnf.js +88 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +2 -2
- package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
- package/dist/plugin-sdk/agent-harness-task-runtime.js +1 -1
- package/dist/plugin-sdk/agent-harness.js +7 -7
- package/dist/plugin-sdk/agent-runtime.js +2 -2
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +2 -2
- package/dist/plugin-sdk/channel-test-helpers.js +1 -1
- package/dist/plugin-sdk/command-auth.js +1 -1
- package/dist/plugin-sdk/command-status-runtime.js +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/conversation-binding-runtime.js +2 -2
- package/dist/plugin-sdk/conversation-runtime.js +3 -3
- package/dist/plugin-sdk/core.js +2 -2
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/health.js +2 -2
- package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/mattermost.js +1 -1
- package/dist/plugin-sdk/plugin-test-contracts.js +2 -2
- package/dist/plugin-sdk/provider-test-contracts.js +4 -4
- package/dist/plugin-sdk/reply-runtime.js +4 -4
- package/dist/plugin-sdk/testing.js +2 -2
- package/dist/plugin-sdk/zalouser.js +1 -1
- package/dist/plugin-service-DnZEPBEA.js +1229 -0
- package/dist/plugins/runtime/index.js +4 -4
- package/dist/policy-CMv5QMPG.js +138 -0
- package/dist/policy-CeoP4t9J.js +680 -0
- package/dist/prepare.runtime-DZ55JiTt.js +732 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/preview-warnings-O08PZRxu.js +392 -0
- package/dist/probe-C6w3bP8X.js +682 -0
- package/dist/probe-Cs1_X1NA.js +47 -0
- package/dist/probe-Cuee_jyM.js +2204 -0
- package/dist/probe-DZxCnDzn.js +2 -0
- package/dist/program-C2dT8VHB.js +131 -0
- package/dist/provider-C2_vSzYh.js +32 -0
- package/dist/provider-DSfTDQbj.js +152 -0
- package/dist/provider-U8hrm9h-.js +32 -0
- package/dist/provider-_v910H8y.js +8735 -0
- package/dist/provider-dispatcher-C3kmmIEC.js +22 -0
- package/dist/provider-dispatcher.runtime.js +1 -1
- package/dist/provider-session.runtime-Mg0fx5hH.js +9 -0
- package/dist/provider-session.runtime.js +1 -1
- package/dist/provider.runtime-pSTXuHrq.js +2 -0
- package/dist/provider.runtime.js +1 -1
- package/dist/public-surface-loader-09t4TTue.js +114 -0
- package/dist/pw-ai-DjNqHV3_.js +3029 -0
- package/dist/pw-role-snapshot-DoGefdv7.js +333 -0
- package/dist/reaction-level-C8Mqxizo.js +19 -0
- package/dist/reaction-runtime-api-DOP6xOsm.js +116 -0
- package/dist/realtime-transcription-provider-BTGEXXna.js +205 -0
- package/dist/register-CbZPpqI3.js +2178 -0
- package/dist/register.agent-DrBFuPKh.js +156 -0
- package/dist/register.crestodian-DwTbmaK8.js +24 -0
- package/dist/register.maintenance-BIeoYBub.js +83 -0
- package/dist/register.runtime-B5V9_Dwz.js +54 -0
- package/dist/register.subclis-CJE9ISZY.js +31 -0
- package/dist/register.subclis-YQsKas8N.js +3 -0
- package/dist/register.subclis-core-CjwdGeGU.js +273 -0
- package/dist/repair-sequencing-C0jrL5pw.js +640 -0
- package/dist/reply-delivery-B28mTIpb.js +196 -0
- package/dist/reply-runtime-BqQX7HHw.js +11 -0
- package/dist/reply.runtime-C95MG73O.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/request-BqoMvXxH.js +54 -0
- package/dist/resolve-allowlist-hbKKd_kq.js +220 -0
- package/dist/result-fallback-classifier-BrORPoxj.js +79 -0
- package/dist/route-HHRgSzVy.js +469 -0
- package/dist/route-resolution-C7bafjVc.js +274 -0
- package/dist/routes-86XGeo7a.js +2 -0
- package/dist/routes-BhVGr9ie.js +3602 -0
- package/dist/run-Bb5QP5JV.js +1162 -0
- package/dist/run-attempt-CLi0wV7j.js +7704 -0
- package/dist/run-command-Be6GAxiW.js +2 -0
- package/dist/run-command-Ds4hr3iU.js +23 -0
- package/dist/run-embedded.runtime-wX9ORojX.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-BmNZVB2N.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-subagent-registry.runtime-Uq5sjftu.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/runtime-BktLQ75j.js +1287 -0
- package/dist/runtime-C9XdR62_.js +438 -0
- package/dist/runtime-CTvWDPx9.js +6179 -0
- package/dist/runtime-api-BojB3MUw.js +21 -0
- package/dist/runtime-api-C92MlAwp.js +13 -0
- package/dist/runtime-api-CFNZE9Xt.js +13 -0
- package/dist/runtime-api-Cimpgm5_.js +3 -0
- package/dist/runtime-api-D8qG_lUm.js +17 -0
- package/dist/runtime-api-DMDMnQEG.js +4 -0
- package/dist/runtime-api-DupQdIlE.js +24 -0
- package/dist/runtime-api.actions-B8i3elqu.js +3 -0
- package/dist/runtime-api.monitor-BntFzf_M.js +6 -0
- package/dist/runtime-api.send-CPlmi1jc.js +4 -0
- package/dist/runtime-api.threads-D-H_r_Nl.js +2 -0
- package/dist/runtime-channel-BGhTxnXZ.js +150 -0
- package/dist/runtime-channel-CPFxNapZ.js +2 -0
- package/dist/runtime-embedded-pi.runtime-BjnMTurB.js +2 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/sanitize-outbound-BMUv1NeS.js +127 -0
- package/dist/sdk-setup-tools-Do3DkQi_.js +8 -0
- package/dist/secrets-B8YVPHhk.js +113 -0
- package/dist/security-audit-7Gg_nL4o.js +122 -0
- package/dist/security-audit-Bk3CREj-.js +118 -0
- package/dist/security-audit.runtime-BmSJrdeq.js +2 -0
- package/dist/security-audit.runtime.js +1 -1
- package/dist/selection-BFGde9-_.js +3 -0
- package/dist/selection-DrLFlbgG.js +16157 -0
- package/dist/send-4dLa-BQo.js +1631 -0
- package/dist/send-CV6gCwYP.js +192 -0
- package/dist/send-aGiK3Efu.js +143 -0
- package/dist/send-dB3CehAN.js +2 -0
- package/dist/send.components-BcG9BlkC.js +2 -0
- package/dist/send.components-rLjDlfYU.js +500 -0
- package/dist/send.runtime-D20k2MSr.js +2 -0
- package/dist/send.runtime.js +1 -1
- package/dist/server-BTRx_U1s.js +73 -0
- package/dist/server-CY0ymhBg.js +24 -0
- package/dist/server-close.runtime.js +1 -1
- package/dist/server-context-BxGT8wbK.js +955 -0
- package/dist/server-context-DYlbhAaT.js +2 -0
- package/dist/server-cron-BB_15lcP.js +2 -0
- package/dist/server-cron-CfyJX_a4.js +2989 -0
- package/dist/server-methods-Ck2ab6TC.js +16494 -0
- package/dist/server-node-events-BdRizF-5.js +596 -0
- package/dist/server-plugin-bootstrap-CPUr8NFE.js +70 -0
- package/dist/server-plugins-__5AxjzH.js +432 -0
- package/dist/server-reload-handlers-BMl9Fx9b.js +714 -0
- package/dist/server-restart-sentinel-D11M_ZsH.js +747 -0
- package/dist/server-restart-sentinel-DGptQ27c.js +2 -0
- package/dist/server-runtime-services-BwtLs-8I.js +2 -0
- package/dist/server-runtime-services-aJydixRu.js +267 -0
- package/dist/server-startup-plugins-m_P3gY4m.js +113 -0
- package/dist/server-startup-post-attach-DuXQ1AXL.js +716 -0
- package/dist/server-ws-runtime-mXmxB1W8.js +349 -0
- package/dist/server.impl-fuV8aKSP.js +2586 -0
- package/dist/service-a8cTFka4.js +1446 -0
- package/dist/session-binding-BIycxo9u.js +2 -0
- package/dist/session-binding-xHwQr9vM.js +219 -0
- package/dist/session-kill-http-DiUZhcoN.js +121 -0
- package/dist/session-reset-service-DkepDoob.js +625 -0
- package/dist/session-route-Ba5u7ecb.js +93 -0
- package/dist/session-status.runtime-Cb1X69Rl.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-rbqmto4G.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-DSKOoJta.js +521 -0
- package/dist/sessions-history-http-CWP88I_C.js +430 -0
- package/dist/sessions.runtime-1q1OwLn3.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-api-DtrOOYeP.js +29 -0
- package/dist/setup-core-DMrJS6LP.js +174 -0
- package/dist/setup-surface-BFPNu1qA.js +405 -0
- package/dist/setup-surface-CedShqhO.js +288 -0
- package/dist/setup-surface-DLOBH1Vf.js +320 -0
- package/dist/setup-surface-MhCeEWSj.js +221 -0
- package/dist/shared-DamL-e8D.js +121 -0
- package/dist/shared-client-B48JoAsz.js +2 -0
- package/dist/shared-client-BoSiDnUo.js +629 -0
- package/dist/side-question-DQoQ_ETb.js +683 -0
- package/dist/skill-tool-dispatch.runtime-CWLloYA8.js +143 -0
- package/dist/skill-tool-dispatch.runtime.js +1 -1
- package/dist/slash-state-DrrWJQfv.js +2166 -0
- package/dist/speech-provider-8Hx1uw41.js +184 -0
- package/dist/src-BbUYOPwU.js +4256 -0
- package/dist/startup-context-opAJAamX.js +313 -0
- package/dist/status-subagents.runtime-DSo7ZK_Z.js +18 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-AyPuDzrO.js +296 -0
- package/dist/sticker-cache-91Tp8mLP.js +206 -0
- package/dist/sticker-vision.runtime-DjleFXi5.js +17 -0
- package/dist/sticker-vision.runtime.js +1 -1
- package/dist/subagent-announce-delivery-DS_2W9oZ.js +958 -0
- package/dist/subagent-announce-hatA_PZ2.js +354 -0
- package/dist/subagent-control-IyFIvc7T.js +508 -0
- package/dist/subagent-hooks-BCj5eB0Z.js +2 -0
- package/dist/subagent-hooks-BWjTBkox.js +146 -0
- package/dist/subagent-hooks-CdGLK9_3.js +230 -0
- package/dist/subagent-hooks-EH0tBkw9.js +2 -0
- package/dist/subagent-hooks-api-BhYaXQJV.js +23 -0
- package/dist/subagent-hooks-api-uGsV8Xn5.js +22 -0
- package/dist/subagent-hooks-api-wfJFKIPx.js +23 -0
- package/dist/subagent-hooks-l8Xd94dt.js +2 -0
- package/dist/subagent-hooks-m2eHUO_d.js +116 -0
- package/dist/subagent-orphan-recovery-Bq9zvX3L.js +352 -0
- package/dist/subagent-registry-Bcb3zy6b.js +3 -0
- package/dist/subagent-registry-CoZNTFx-.js +2351 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-session-cleanup--00EjDLe.js +525 -0
- package/dist/subagent-spawn-ClJJkz3D.js +1164 -0
- package/dist/target-id-BsZLiF3x.js +107 -0
- package/dist/targets-CQMe4AZP.js +44 -0
- package/dist/targets-SmL1AU-H.js +19 -0
- package/dist/targets-Y-roiA47.js +19 -0
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/telegram/token.js +1 -1
- package/dist/testing-B5hNJDuF.js +267 -0
- package/dist/thread-bindings-BD3eE0kK.js +232 -0
- package/dist/thread-bindings-C9NNiv8K.js +571 -0
- package/dist/thread-bindings-Dl4PN1vZ.js +228 -0
- package/dist/thread-bindings-uK1LLAwy.js +8 -0
- package/dist/thread-bindings.discord-api-BHNEUbnk.js +187 -0
- package/dist/thread-bindings.manager-B0LXiH3F.js +2 -0
- package/dist/thread-bindings.manager-BTlH4XMG.js +536 -0
- package/dist/thread-lifecycle-DG8uyPHd.js +1614 -0
- package/dist/token-BbGCANnE.js +134 -0
- package/dist/tool-actions.runtime-oUUrD8HB.js +534 -0
- package/dist/tool-actions.runtime.js +1 -1
- package/dist/tool-bqg-_vYv.js +139 -0
- package/dist/tool-resolution-CSZsa3kP.js +149 -0
- package/dist/tools-effective-inventory-0CqFp-vq.js +204 -0
- package/dist/tools-invoke-http-DhYHY0Yh.js +67 -0
- package/dist/tools-invoke-shared-CbVJJUj7.js +200 -0
- package/dist/tts-C2qD-ad6.js +66 -0
- package/dist/tui-CzGY254f.js +4709 -0
- package/dist/tui-backend-fzoeoSN0.js +256 -0
- package/dist/tui-cli-B2RWb2gM.js +37 -0
- package/dist/tui-dgS8hdXU.js +2 -0
- package/dist/update-cli-BmiBDf3c.js +3664 -0
- package/dist/update-runner-CM7QVX6u.js +2379 -0
- package/dist/vision-tools-BzoBZnIc.js +1409 -0
- package/dist/web-search-DmfOd66S.js +62 -0
- package/dist/web-search-provider.runtime-3C5-pODD.js +328 -0
- package/dist/web-search-provider.runtime-Doh-Z9We.js +2 -0
- package/dist/web-search-provider.runtime.js +1 -1
- package/dist/xai-oauth-BLvQ43hx.js +479 -0
- package/dist/xai-user-agent-BdMQ_0_O.js +32 -0
- package/package.json +1 -1
- package/dist/abort-DeEb_wKd.js +0 -277
- package/dist/abort.runtime-CoYXQGPK.js +0 -2
- package/dist/account-inspect-D_06-CYS.js +0 -173
- package/dist/accounts-BCTqtj4Y.js +0 -107
- package/dist/accounts-BudLl8P2.js +0 -107
- package/dist/accounts-CUReBDA0.js +0 -2
- package/dist/accounts-PCioSzzr.js +0 -119
- package/dist/acp-runtime-B2t9_BHD.js +0 -26
- package/dist/acp-spawn-0x4Iiu1o.js +0 -2
- package/dist/acp-spawn-B2Ghe0jJ.js +0 -1275
- package/dist/acp-stateful-target-driver-C4VgcSyz.js +0 -89
- package/dist/action-kill-ClYsXEz7.js +0 -33
- package/dist/action-runtime-DrLPkNvU.js +0 -469
- package/dist/action-runtime-api-BqSflr9q.js +0 -2
- package/dist/action-send-CIy9cziD.js +0 -39
- package/dist/action-spawn-BjV6lFnX.js +0 -47
- package/dist/actions-D-QH7wq5.js +0 -161
- package/dist/actions.runtime-hzDtXQGU.js +0 -5
- package/dist/agent-Bb1DTBgv.js +0 -3
- package/dist/agent-Cnqj258q.js +0 -2
- package/dist/agent-command-BRx6ZNgJ.js +0 -1367
- package/dist/agent-components.runtime-D-g6xXJ0.js +0 -10
- package/dist/agent-harness-runtime-dKUQFuOc.js +0 -180
- package/dist/agent-harness-task-runtime-v2crUm3i.js +0 -140
- package/dist/agent-runner-execution-AOzdxvWR.js +0 -1713
- package/dist/agent-runner-utils-Byv50B4Z.js +0 -266
- package/dist/agent-runner.runtime-hhgRE0Z-.js +0 -3455
- package/dist/agent-runtime-BHmh3i0o.js +0 -229
- package/dist/agent-via-gateway-DnCqaK4a.js +0 -463
- package/dist/api-Bzyb8sFU.js +0 -3
- package/dist/api-CIEDFXZs.js +0 -2
- package/dist/api-D_dTQAu8.js +0 -2
- package/dist/api-DilBjZ9Q.js +0 -6
- package/dist/api-E5zoQMmh.js +0 -134
- package/dist/api-OJZug8gQ.js +0 -639
- package/dist/apply-C0eV5T0O.js +0 -41
- package/dist/apply-alsYvxLE.js +0 -54
- package/dist/approval-handler.runtime-C6jqZXSN.js +0 -130
- package/dist/assistant-DDXnAAB5.js +0 -291
- package/dist/attachment-normalize-Cv-_4DWU.js +0 -225
- package/dist/attempt-execution-DECEU59r.js +0 -558
- package/dist/attempt-execution.runtime-kasMxuER.js +0 -3
- package/dist/attempt-execution.shared-ClUxk52p.js +0 -38
- package/dist/attempt.prompt-helpers-Bxlv9VSu.js +0 -475
- package/dist/attempt.tool-run-context-CplQWX6g.js +0 -2094
- package/dist/binding-routing-0Obpp-Ij.js +0 -113
- package/dist/binding-targets-CZHQaZL4.js +0 -121
- package/dist/bot-BPbQ0840.js +0 -7894
- package/dist/bot-deps-Cs1M9USs.js +0 -2
- package/dist/bot-deps-xAcaOtTZ.js +0 -747
- package/dist/bot-message-context.runtime-Bji78Cbn.js +0 -7
- package/dist/bot-message-context.session.runtime-C3dyOIYH.js +0 -12
- package/dist/bot-native-commands.delivery.runtime-WshH99fy.js +0 -4
- package/dist/bot-native-commands.runtime-C1L364gU.js +0 -13
- package/dist/bridge-server-DPlM8_Lk.js +0 -113
- package/dist/browser-cli-DFNQE98N.js +0 -230
- package/dist/browser-cli-Drb5E5--.js +0 -2
- package/dist/browser-cli-actions-input-Dx-1OXmE.js +0 -473
- package/dist/browser-cli-actions-observe-BMDfE7xU.js +0 -81
- package/dist/browser-cli-debug-nu7Ih09g.js +0 -137
- package/dist/browser-cli-inspect-D5X2wohg.js +0 -104
- package/dist/browser-cli-manage-DkzYwph4.js +0 -443
- package/dist/browser-cli-resize-B30Avedl.js +0 -26
- package/dist/browser-cli-shared-cMgQoQzF.js +0 -50
- package/dist/browser-cli-state-CQLDvDy7.js +0 -337
- package/dist/browser-control-auth-D7ArmHUt.js +0 -2
- package/dist/browser-profiles-B39SIZNb.js +0 -2
- package/dist/browser-runtime-DUbSAOOS.js +0 -384
- package/dist/build-D25KqC92.js +0 -257
- package/dist/capability-cli-CuyXrlAB.js +0 -1782
- package/dist/channel-0N3YGMGg.js +0 -1496
- package/dist/channel-1UyKoLyp.js +0 -481
- package/dist/channel-BG87pSEW.js +0 -740
- package/dist/channel-BPGSaZW7.js +0 -1249
- package/dist/channel-BQMPh1J_.js +0 -376
- package/dist/channel-Bd_8V6zn.js +0 -1134
- package/dist/channel-BtBjh_ij.js +0 -362
- package/dist/channel-CpFBlVH6.js +0 -562
- package/dist/channel-CwuTrIrF.js +0 -508
- package/dist/channel-Cxl4sJA-.js +0 -1777
- package/dist/channel-D-VfU4Z2.js +0 -2126
- package/dist/channel-D9q8aYrN.js +0 -867
- package/dist/channel-DKSvVvZh.js +0 -238
- package/dist/channel-DvoFfWLx.js +0 -808
- package/dist/channel-GktTcGHm.js +0 -955
- package/dist/channel-actions.runtime-CKcRA0GW.js +0 -265
- package/dist/channel-core-nm8s1qFZ.js +0 -5
- package/dist/channel-d3t2ESlE.js +0 -653
- package/dist/channel-inbound-DKz40dq-.js +0 -80
- package/dist/channel-plugin-runtime-DKIGZWfW.js +0 -998
- package/dist/channel-runtime-Bh8_GY12.js +0 -408
- package/dist/channel-yQ8jCOb9.js +0 -1556
- package/dist/channel.runtime-BG4mM5cQ.js +0 -652
- package/dist/channel.runtime-BS6PyFFa.js +0 -1008
- package/dist/channel.runtime-CE_xECqN.js +0 -88
- package/dist/channel.runtime-Cd1Sw8U4.js +0 -254
- package/dist/channel.runtime-DIq3XOEe.js +0 -733
- package/dist/channel.runtime-Dy1cx35I.js +0 -21009
- package/dist/channel.runtime-NyIMjLnP.js +0 -109
- package/dist/channel.runtime-Zx5mfE2V.js +0 -4
- package/dist/channel.runtime-rJRibGfN.js +0 -2528
- package/dist/channel.setup--4ACadmF.js +0 -10
- package/dist/channel.setup-DzwqIlo3.js +0 -1098
- package/dist/channel.setup-FKYSJwXR.js +0 -343
- package/dist/chat-CKxSm7r1.js +0 -2666
- package/dist/chrome-rMubJwRG.js +0 -1503
- package/dist/cli-CbTod55I.js +0 -1341
- package/dist/cli-compaction-BbHgjJyW.js +0 -347
- package/dist/cli-metadata-DkOWLC_p.js +0 -22
- package/dist/cli-runner-Cwzv_RKf.js +0 -540
- package/dist/cli-runner-DdnUsgPl.js +0 -2
- package/dist/cli-runner.runtime-BlrSgbEW.js +0 -3
- package/dist/cli-runner.runtime-D8kVfvFH.js +0 -4
- package/dist/client-ClvxsWgL.js +0 -650
- package/dist/client-adapter-CsrIIjK1.js +0 -897
- package/dist/client-factory-DAYClhwm.js +0 -9
- package/dist/command-auth-CCha2ofd.js +0 -135
- package/dist/command-handlers-DCWJzHyB.js +0 -1609
- package/dist/command-registry-BIf61QNz.js +0 -9
- package/dist/command-registry-DJROBy4h.js +0 -4
- package/dist/command-registry-core-BQOWqi6S.js +0 -110
- package/dist/command-status.runtime-D88CUglL.js +0 -90
- package/dist/commands-acp-B-8dHX4Z.js +0 -74
- package/dist/commands-compact.runtime-ComX5mUk.js +0 -10
- package/dist/commands-handlers.runtime-DR3wjXHX.js +0 -6154
- package/dist/commands-status-CDyGrwsI.js +0 -3
- package/dist/commands-status-DV-i_ZIK.js +0 -16
- package/dist/commands-status.runtime-CDyGrwsI.js +0 -3
- package/dist/commands-subagents-control.runtime-B029cXAS.js +0 -3
- package/dist/commands-subagents-control.runtime-DR8Qspe0.js +0 -2
- package/dist/commands-system-prompt-C10ctsG3.js +0 -162
- package/dist/commands-system-prompt-DQlRWwnk.js +0 -2
- package/dist/commands.runtime-BYmIAuN0.js +0 -176
- package/dist/compact-14Ljaaeu.js +0 -480
- package/dist/compact-B--ovdkx.js +0 -1141
- package/dist/compact.runtime-E0Idf2Dq.js +0 -12
- package/dist/completion-cli-DMvvQGSk.js +0 -315
- package/dist/computer-use-CcLwX5SR.js +0 -367
- package/dist/config-B39SIZNb.js +0 -2
- package/dist/config-D4rsGOyV.js +0 -373
- package/dist/config-mutations-CsI3YJu7.js +0 -159
- package/dist/context-engine-host-compat-BZpDFiMJ.js +0 -2
- package/dist/context-engine-host-compat-runUdES5.js +0 -288
- package/dist/context-engine-lifecycle-D6odtNrn.js +0 -1274
- package/dist/control-auth-BPGpPtfz.js +0 -114
- package/dist/control-service-C-OmdPCe.js +0 -145
- package/dist/control-ui/assets/agents-GeyOHPuW.js +0 -1008
- package/dist/control-ui/assets/channel-config-extras-D7en6iUg.js +0 -2
- package/dist/control-ui/assets/channels-DkEyr1w5.js +0 -367
- package/dist/control-ui/assets/cron-C-wThQ1Q.js +0 -1013
- package/dist/control-ui/assets/debug-83AFRtIX.js +0 -97
- package/dist/control-ui/assets/index-CiGEhMOA.js +0 -7370
- package/dist/control-ui/assets/instances-CVl0t-1h.js +0 -57
- package/dist/control-ui/assets/logs-eybVEXxg.js +0 -74
- package/dist/control-ui/assets/nodes-C_A7eoU2.js +0 -436
- package/dist/control-ui/assets/sessions-Cq4Nc69u.js +0 -399
- package/dist/control-ui/assets/skills-ZN6hroIh.js +0 -314
- package/dist/control-ui/assets/skills-shared-DIWGwmdC.js +0 -11
- package/dist/conversation-binding-runtime-C2U1JElL.js +0 -4
- package/dist/conversation-runtime-NmIUd3Zu.js +0 -31
- package/dist/core-DGKJP1dm.js +0 -282
- package/dist/core-api-1fA4sNeC.js +0 -5
- package/dist/core-api-BY822Quq.js +0 -2
- package/dist/crestodian-Bp-NXiBC.js +0 -55
- package/dist/daocore-tools-Defpam0j.js +0 -11727
- package/dist/delivery-CEdVAUGB.js +0 -1002
- package/dist/dialogue-CZ69INPq.js +0 -37
- package/dist/dir-fetch-tool-BCicHhQE.js +0 -565
- package/dist/dir-list-tool-Cv_WktsJ.js +0 -100
- package/dist/direct-dm-Bz89rM8x.js +0 -64
- package/dist/directive-handling.fast-lane-DDnbcc5S.js +0 -68
- package/dist/directive-handling.impl-B0H52Ymr.js +0 -818
- package/dist/directive-handling.impl-CgKpwEW-.js +0 -2
- package/dist/directive-handling.model-selection-_cXAr0vt.js +0 -122
- package/dist/directive-handling.persist.runtime-Dw0mfzXT.js +0 -263
- package/dist/dispatch-C3AeYvyP.js +0 -1640
- package/dist/dispatch-acp-transcript.runtime-CP8pqBwS.js +0 -40
- package/dist/dispatch-acp.runtime-Cdap-AZI.js +0 -18
- package/dist/doctor-BZwVH97p.js +0 -2
- package/dist/doctor-BfkGBii1.js +0 -6
- package/dist/doctor-config-flow-D3JASGDt.js +0 -1741
- package/dist/doctor-core-checks-DH5AIT0Q.js +0 -573
- package/dist/doctor-core-checks-DiNu7VSh.js +0 -2
- package/dist/doctor-health-BDIJ-Nro.js +0 -65
- package/dist/doctor-health-contributions-BgmF7w8X.js +0 -696
- package/dist/doctor-lint-uIxkMUSO.js +0 -94
- package/dist/doctor-state-integrity-ws1b_BGk.js +0 -1231
- package/dist/doctor-update-Cx4CqxaX.js +0 -58
- package/dist/dynamic-tools-DiqOxhJh.js +0 -486
- package/dist/embedded-backend-C634irMl.js +0 -579
- package/dist/embedded-gateway-stub.runtime-CCfrTOeN.js +0 -12
- package/dist/exec-approvals-D85KThSg.js +0 -149
- package/dist/file-fetch-tool-BERaGYCT.js +0 -124
- package/dist/file-write-tool-BjHrMyfe.js +0 -127
- package/dist/format-DE9PuPg1.js +0 -1145
- package/dist/gateway-cli-B5hjhbUy.js +0 -435
- package/dist/gateway-method-runtime-Bu0E9Eki.js +0 -21
- package/dist/get-reply-6PtPz9hv.js +0 -4689
- package/dist/get-reply-from-config.runtime-CwprvhoR.js +0 -2
- package/dist/graph-users-DUp1kgnS.js +0 -1419
- package/dist/group-access-D5GBQ3w6.js +0 -112
- package/dist/handle-action.guild-admin-CA0Y-buD.js +0 -288
- package/dist/harness-B5nOFVfm.js +0 -61
- package/dist/health-D5heIDj3.js +0 -4
- package/dist/heartbeat-runner-BzFkIFHh.js +0 -5
- package/dist/heartbeat-runner.runtime-p6H1_xMV.js +0 -4
- package/dist/hooks-BvTyQ14X.js +0 -534
- package/dist/inbound-direct-dm-runtime-DwiDXi8L.js +0 -2
- package/dist/inbound-reply-dispatch-YoDUOC6C.js +0 -148
- package/dist/init-CPtcV5Xu.js +0 -59
- package/dist/inline-buttons-DeD5d42c.js +0 -40
- package/dist/internal-events-DEb50Sw3.js +0 -90
- package/dist/isolated-agent-CcxFFZ-Z.js +0 -1118
- package/dist/isolated-agent-CpHzq5qr.js +0 -2
- package/dist/lifecycle-DNel-oMe.js +0 -571
- package/dist/list.probe-DCa3N25d.js +0 -449
- package/dist/list.status-command-CyeAJmZW.js +0 -789
- package/dist/llm-slug-generator-CyqTY37Z.js +0 -78
- package/dist/local-dispatch.runtime-nE39kFIP.js +0 -9
- package/dist/manager.runtime-CpAPB8D5.js +0 -2714
- package/dist/markdown-to-line-Ci6TRmoZ.js +0 -811
- package/dist/mcp-http-BR0vmxFL.js +0 -2
- package/dist/mcp-http-C0oniA8h.js +0 -555
- package/dist/media-understanding-provider-BwA0XqC3.js +0 -339
- package/dist/message-actions-C9C_Ngkd.js +0 -145
- package/dist/message-handler-CUUKPC5n.js +0 -384
- package/dist/message-handler-xRTfIXWV.js +0 -1715
- package/dist/message-handler.preflight-Ch2Q7V3M.js +0 -1125
- package/dist/message-handler.process-HM3mK93q.js +0 -1484
- package/dist/model-CB8Ex5xS.js +0 -74
- package/dist/model-selection-2s0Dinux.js +0 -272
- package/dist/models-Cn-6DJ41.js +0 -2
- package/dist/models-CzszJD__.js +0 -104
- package/dist/models-cli-CbhElnA5.js +0 -256
- package/dist/monitor-7aprTsMV.js +0 -715
- package/dist/monitor-BuVhqwDS.js +0 -1370
- package/dist/monitor-C4H_YkgY.js +0 -2
- package/dist/monitor-CPQsMxgv.js +0 -1657
- package/dist/monitor-Ce0V1PiR.js +0 -4377
- package/dist/monitor-D0bcGJWI.js +0 -60
- package/dist/monitor-DEjlJqzh.js +0 -834
- package/dist/monitor-auth-DjJZsjgV.js +0 -179
- package/dist/monitor-ikSYagv3.js +0 -2788
- package/dist/monitor-polling.runtime-D7yEflMM.js +0 -883
- package/dist/monitor-webhook.runtime-CIZt-biI.js +0 -387
- package/dist/monitor.account-C2sMOBCS.js +0 -5233
- package/dist/monitor.runtime-BAi6zmcn.js +0 -2
- package/dist/monitor.webhook-BcjpfRCX.js +0 -180
- package/dist/node-cli-sessions-CIhkJRU4.js +0 -1228
- package/dist/openai-http-Dj21RwSj.js +0 -824
- package/dist/openresponses-http-COnnr1ox.js +0 -1173
- package/dist/operations-H3vUh0lM.js +0 -805
- package/dist/outbound-adapter-WLtWE7wv.js +0 -543
- package/dist/outbound-session-route-CZtd64EH.js +0 -45
- package/dist/outbound.runtime-D98P0sN1.js +0 -2
- package/dist/pi-embedded-BWJzd4mK.js +0 -4
- package/dist/pi-embedded-DeNsSqQQ.js +0 -3796
- package/dist/pi-embedded.runtime-CZnNwFpc.js +0 -4
- package/dist/pi-tools-CNHSpjBa.js +0 -2413
- package/dist/plan-B0reFFlM.js +0 -81
- package/dist/plan-CrfF-TH8.js +0 -112
- package/dist/plugin-DI_8eYOe.js +0 -12396
- package/dist/plugin-app-cache-key-WaTUD3e-.js +0 -46
- package/dist/plugin-enabled-aWLXgGGi.js +0 -233
- package/dist/plugin-registration-ByjRIVJm.js +0 -88
- package/dist/plugin-service-VQm_241d.js +0 -1229
- package/dist/policy-BmJH-swe.js +0 -680
- package/dist/policy-DE-bO1zn.js +0 -138
- package/dist/prepare.runtime-bSj3-res.js +0 -732
- package/dist/preview-warnings-CbuGYsF9.js +0 -392
- package/dist/probe-C_rWg7_m.js +0 -682
- package/dist/probe-CagOFfx6.js +0 -2
- package/dist/probe-thX1HqOh.js +0 -2204
- package/dist/probe-zU6B6gFt.js +0 -47
- package/dist/program-BtVdH743.js +0 -131
- package/dist/provider-CDoD7tO0.js +0 -8735
- package/dist/provider-CK1gMdJ2.js +0 -32
- package/dist/provider-DJqr9djy.js +0 -32
- package/dist/provider-DsOJp5bK.js +0 -152
- package/dist/provider-dispatcher-UNQ-LSx9.js +0 -22
- package/dist/provider-session.runtime-DMrkMb4x.js +0 -9
- package/dist/provider.runtime-C2-t3zm8.js +0 -2
- package/dist/public-surface-loader-hTeyyHcd.js +0 -114
- package/dist/pw-ai-BaL3eVYx.js +0 -3029
- package/dist/pw-role-snapshot-DKeBqhN1.js +0 -333
- package/dist/reaction-level-BV2potsD.js +0 -19
- package/dist/reaction-runtime-api-CCBxgM10.js +0 -116
- package/dist/realtime-transcription-provider-CHYtIXZm.js +0 -205
- package/dist/register-BJf28G9B.js +0 -2178
- package/dist/register.agent-oXAHwNQv.js +0 -156
- package/dist/register.crestodian-CQ0sqdV2.js +0 -24
- package/dist/register.maintenance-CylVRs5M.js +0 -83
- package/dist/register.runtime-CcDgwy0X.js +0 -54
- package/dist/register.subclis-CpBYNw2X.js +0 -3
- package/dist/register.subclis-N2CvieOL.js +0 -31
- package/dist/register.subclis-core-BHaGvbzg.js +0 -273
- package/dist/repair-sequencing-EBBnBdIB.js +0 -640
- package/dist/reply-delivery-BLoPALlI.js +0 -196
- package/dist/reply-runtime-D4asNTSa.js +0 -11
- package/dist/reply.runtime-CwprvhoR.js +0 -2
- package/dist/request-DlWPRUDt.js +0 -54
- package/dist/resolve-allowlist-BukQf58x.js +0 -220
- package/dist/result-fallback-classifier-DyHFnqfV.js +0 -79
- package/dist/route-BMf4keN5.js +0 -469
- package/dist/route-resolution-DWNi1QAu.js +0 -274
- package/dist/routes-C20LC8c4.js +0 -3602
- package/dist/routes-CkK7Vv_m.js +0 -2
- package/dist/run-KDF_AEza.js +0 -1162
- package/dist/run-attempt-JHYCfonU.js +0 -7704
- package/dist/run-command-3PVihYIy.js +0 -2
- package/dist/run-command-QHAXnyKY.js +0 -23
- package/dist/run-embedded.runtime-BJw-2vss.js +0 -4
- package/dist/run-execution-cli.runtime-GHClMn2g.js +0 -4
- package/dist/run-subagent-registry.runtime-BLLMrhtE.js +0 -2
- package/dist/runtime-C2u-dC1r.js +0 -1287
- package/dist/runtime-ClyfkDWT.js +0 -6179
- package/dist/runtime-WXCarlPc.js +0 -438
- package/dist/runtime-api-3QhGLpZf.js +0 -13
- package/dist/runtime-api-DRAu3mjv.js +0 -4
- package/dist/runtime-api-JE07pOem.js +0 -13
- package/dist/runtime-api-JuKylHvw.js +0 -24
- package/dist/runtime-api-bcbk4yax.js +0 -21
- package/dist/runtime-api-dDe9U2_V.js +0 -17
- package/dist/runtime-api-uMexLqGS.js +0 -3
- package/dist/runtime-api.actions-Bo7TLDFl.js +0 -3
- package/dist/runtime-api.monitor-7q78L1Em.js +0 -6
- package/dist/runtime-api.send-Bf9RR4nV.js +0 -4
- package/dist/runtime-api.threads-Dj2QuhHj.js +0 -2
- package/dist/runtime-channel-k1C0Satl.js +0 -2
- package/dist/runtime-channel-qt9t0J-J.js +0 -150
- package/dist/runtime-embedded-pi.runtime-BPB9NlTS.js +0 -2
- package/dist/sanitize-outbound-BLH_SQvg.js +0 -127
- package/dist/sdk-setup-tools-BshlBPau.js +0 -8
- package/dist/secrets-CsHXv7d3.js +0 -113
- package/dist/security-audit-CUXBQXNX.js +0 -122
- package/dist/security-audit-CzdXbRma.js +0 -118
- package/dist/security-audit.runtime-Ca0FMFJG.js +0 -2
- package/dist/selection-BmvQJlSD.js +0 -3
- package/dist/selection-BplDXc9w.js +0 -16157
- package/dist/send--qFg8a9v.js +0 -1631
- package/dist/send-BPdryPPA.js +0 -192
- package/dist/send-Bl4YaRkS.js +0 -143
- package/dist/send-Ccm7RMXC.js +0 -2
- package/dist/send.components-c3OUPSmR.js +0 -2
- package/dist/send.components-rhQJYoXs.js +0 -500
- package/dist/send.runtime-dfUkAp5d.js +0 -2
- package/dist/server-DRhyTMLe.js +0 -73
- package/dist/server-Dv4BzjGn.js +0 -24
- package/dist/server-context-4HRJy2vp.js +0 -955
- package/dist/server-context-DlxYb1G5.js +0 -2
- package/dist/server-cron-Bt8Pkc3i.js +0 -2989
- package/dist/server-cron-CtNWsa4Z.js +0 -2
- package/dist/server-methods-rye_okUW.js +0 -16494
- package/dist/server-node-events-C1yZ5a1u.js +0 -596
- package/dist/server-plugin-bootstrap-DUMyVtlP.js +0 -70
- package/dist/server-plugins-B5ZWWkRE.js +0 -432
- package/dist/server-reload-handlers-CTnMXNjT.js +0 -714
- package/dist/server-restart-sentinel-CAYxtwmY.js +0 -747
- package/dist/server-restart-sentinel-DqrtSIvy.js +0 -2
- package/dist/server-runtime-services-CuptQTe5.js +0 -2
- package/dist/server-runtime-services-aaS2IiW3.js +0 -267
- package/dist/server-startup-plugins-D0ymJgQT.js +0 -113
- package/dist/server-startup-post-attach-DlrN2uyt.js +0 -716
- package/dist/server-ws-runtime-CdpLbv4o.js +0 -349
- package/dist/server.impl-Cb4qcMTg.js +0 -2586
- package/dist/service-qxvDlMQE.js +0 -1446
- package/dist/session-binding-6bLobLHL.js +0 -219
- package/dist/session-binding-Bm6fCpoY.js +0 -2
- package/dist/session-kill-http-B6WjVo8V.js +0 -121
- package/dist/session-reset-service-GUVIhxp4.js +0 -625
- package/dist/session-route-BcRDnvzG.js +0 -93
- package/dist/session-status.runtime-BcjOunV4.js +0 -2
- package/dist/session-subagent-reactivation.runtime-BSmk_KYn.js +0 -2
- package/dist/session-tab-registry-BBYzbSOu.js +0 -521
- package/dist/sessions-history-http-bLJJfgLm.js +0 -430
- package/dist/sessions.runtime-DNRtQzCk.js +0 -2
- package/dist/setup-api-CcolVVJs.js +0 -29
- package/dist/setup-core-eJD18F3B.js +0 -174
- package/dist/setup-surface-B75C2Qtz.js +0 -221
- package/dist/setup-surface-CFuPfVHp.js +0 -405
- package/dist/setup-surface-Dyy-Mzyz.js +0 -288
- package/dist/setup-surface-ZsVF_g8W.js +0 -320
- package/dist/shared-BkCNrcLX.js +0 -121
- package/dist/shared-client-B7zqC9p2.js +0 -2
- package/dist/shared-client-yXjKgZBz.js +0 -629
- package/dist/side-question-DU3gESCb.js +0 -683
- package/dist/skill-tool-dispatch.runtime-CPBuqyvk.js +0 -143
- package/dist/slash-state-Do3bAahA.js +0 -2166
- package/dist/speech-provider-Bg9los3C.js +0 -184
- package/dist/src-D7LzUctH.js +0 -4256
- package/dist/startup-context-CCF2gIOl.js +0 -313
- package/dist/status-subagents.runtime-DX5FTymp.js +0 -18
- package/dist/status-text-B-1u5dSV.js +0 -296
- package/dist/sticker-cache-DwpU_9RJ.js +0 -206
- package/dist/sticker-vision.runtime-Bbldi_YL.js +0 -17
- package/dist/subagent-announce-BCo0VHVL.js +0 -354
- package/dist/subagent-announce-delivery-JcnuDN_N.js +0 -958
- package/dist/subagent-control-BzbA3Suz.js +0 -508
- package/dist/subagent-hooks-BIGZQWrG.js +0 -2
- package/dist/subagent-hooks-Bj4qYZfv.js +0 -230
- package/dist/subagent-hooks-C-rvhVBv.js +0 -2
- package/dist/subagent-hooks-P01_AFl5.js +0 -116
- package/dist/subagent-hooks-VEfak8nl.js +0 -2
- package/dist/subagent-hooks-api-BPnSxxN4.js +0 -23
- package/dist/subagent-hooks-api-DwIAvMoS.js +0 -22
- package/dist/subagent-hooks-api-kgyR9FOb.js +0 -23
- package/dist/subagent-hooks-oED56wqq.js +0 -146
- package/dist/subagent-orphan-recovery-D79ZzwKN.js +0 -352
- package/dist/subagent-registry-D0soBT5j.js +0 -2351
- package/dist/subagent-registry-DRJDkmty.js +0 -3
- package/dist/subagent-session-cleanup-9eAO1aJe.js +0 -525
- package/dist/subagent-spawn-D80vbogm.js +0 -1164
- package/dist/target-id-COLv5LsJ.js +0 -107
- package/dist/targets-CDW5IQ6a.js +0 -44
- package/dist/targets-Ci6O1ZdP.js +0 -19
- package/dist/targets-CsaWFBg1.js +0 -19
- package/dist/testing-BoJit-h1.js +0 -267
- package/dist/thread-bindings-CGCvw0KT.js +0 -571
- package/dist/thread-bindings-ClCTNacX.js +0 -228
- package/dist/thread-bindings-DRb7BMZ6.js +0 -8
- package/dist/thread-bindings-Xc6smav0.js +0 -232
- package/dist/thread-bindings.discord-api-DC467oeF.js +0 -187
- package/dist/thread-bindings.manager-C_mpTDIZ.js +0 -536
- package/dist/thread-bindings.manager-DkCRs612.js +0 -2
- package/dist/thread-lifecycle-DpqCXlx9.js +0 -1614
- package/dist/token-CI6HjbTA.js +0 -134
- package/dist/tool-BMe7hjBK.js +0 -139
- package/dist/tool-actions.runtime-D-h5PI_m.js +0 -534
- package/dist/tool-resolution-CnLx0CHe.js +0 -149
- package/dist/tools-effective-inventory-BR6MUMtE.js +0 -204
- package/dist/tools-invoke-http-CTTs2yMT.js +0 -67
- package/dist/tools-invoke-shared-9B1EjXWf.js +0 -200
- package/dist/tts-eGOviZ5c.js +0 -66
- package/dist/tui-Bw0HqKd7.js +0 -4709
- package/dist/tui-CIZJnPzj.js +0 -2
- package/dist/tui-backend-BJ_r7tcF.js +0 -256
- package/dist/tui-cli-BaSMBpuA.js +0 -37
- package/dist/update-cli-zuCybGNR.js +0 -3664
- package/dist/update-runner-Dek2BHmQ.js +0 -2379
- package/dist/vision-tools-1ps0BEE5.js +0 -1409
- package/dist/web-search-B7EziZXE.js +0 -62
- package/dist/web-search-provider.runtime-DGTCvGch.js +0 -328
- package/dist/web-search-provider.runtime-DWL5t39M.js +0 -2
- package/dist/xai-oauth-CRtsj2Gs.js +0 -479
- package/dist/xai-user-agent-Dndwzw2S.js +0 -32
- /package/dist/{acp-runtime-backend-DSDBcyh9.js → acp-runtime-backend-Cxo7eBHf.js} +0 -0
- /package/dist/{channel-actions-FV66JqtI.js → channel-actions-UDeVjgGz.js} +0 -0
- /package/dist/{command-status-runtime-BRWKSoG7.js → command-status-runtime-CoHd4Fws.js} +0 -0
- /package/dist/{delegate-DGqKhwB4.js → delegate-B-2xZ77o.js} +0 -0
- /package/dist/{dispatch-acp-Ceoxja_Z.js → dispatch-acp-DLPkmK7K.js} +0 -0
- /package/dist/{heartbeat-runner-CJHvr5pG.js → heartbeat-runner-D2j6JwOI.js} +0 -0
- /package/dist/{library-Bq3aDek_.js → library-DBT0cIPP.js} +0 -0
- /package/dist/{run-executor.runtime-DNJhGPbA.js → run-executor.runtime-DE4J7f4M.js} +0 -0
- /package/dist/{shared-CYxmRpq1.js → shared-xeo8Yh5n.js} +0 -0
|
@@ -1,2166 +0,0 @@
|
|
|
1
|
-
import { a as normalizeLowercaseStringOrEmpty, c as normalizeOptionalString, d as normalizeStringifiedOptionalString } from "./string-coerce-DyL154ka.js";
|
|
2
|
-
import { r as normalizeProviderId } from "./provider-id-zTW9Rdln.js";
|
|
3
|
-
import { t as safeEqualSecret } from "./secret-equal-DDhtiQsP.js";
|
|
4
|
-
import { c as isTrustedProxyAddress, f as resolveClientIp } from "./net-DCUMtgJy.js";
|
|
5
|
-
import { u as resolveStorePath } from "./paths-8MFrTNIB.js";
|
|
6
|
-
import { i as deliverTextOrMediaReply, m as resolveSendableOutboundReplyParts, u as isReasoningReplyPayload } from "./reply-payload-DMPQsrQC.js";
|
|
7
|
-
import { r as getAgentScopedMediaLocalRoots } from "./local-roots-CcT8yBYy.js";
|
|
8
|
-
import { t as createMessageReceiptFromOutboundResults } from "./receipt-vrVTwZtS.js";
|
|
9
|
-
import { n as resolveStoredModelOverride } from "./stored-model-override-ChNFxCZO.js";
|
|
10
|
-
import "./string-coerce-runtime-DcopKqDR.js";
|
|
11
|
-
import "./provider-model-shared-H18UrK7h.js";
|
|
12
|
-
import { t as createChannelReplyPipeline } from "./reply-pipeline-CbGLcDzV.js";
|
|
13
|
-
import { t as resolveMarkdownTableMode } from "./markdown-tables-BEjHxS3n.js";
|
|
14
|
-
import { t as convertMarkdownTables } from "./tables-BROr40GK.js";
|
|
15
|
-
import { t as requireRuntimeConfig } from "./plugin-config-runtime-BhkqZ7bA.js";
|
|
16
|
-
import { t as loadOutboundMediaFromUrl } from "./outbound-media-CaqyBwi1.js";
|
|
17
|
-
import { a as isRequestBodyLimitError, s as readRequestBodyWithLimit } from "./http-body-DdsI5-HA.js";
|
|
18
|
-
import { o as isPrivateNetworkOptInEnabled } from "./ssrf-policy-DsqKLgib.js";
|
|
19
|
-
import "./ssrf-runtime-Gwgbj2qf.js";
|
|
20
|
-
import "./media-runtime-CPXTkSQr.js";
|
|
21
|
-
import "./text-chunking-ObhJDe8L.js";
|
|
22
|
-
import "./security-runtime-Q5KQBgu1.js";
|
|
23
|
-
import "./markdown-table-runtime-CGhR5c0i.js";
|
|
24
|
-
import { t as buildModelsProviderData } from "./commands-models-DJy73Scp.js";
|
|
25
|
-
import "./command-auth-native-BxFgw91F.js";
|
|
26
|
-
import { r as logTypingFailure } from "./logging-Dr3f0mtP.js";
|
|
27
|
-
import "./channel-message-YAmKOwAT.js";
|
|
28
|
-
import { t as loadSessionStore } from "./session-store-runtime-BZIAo9w7.js";
|
|
29
|
-
import { i as normalizeMattermostAllowList, t as authorizeMattermostCommandInvocation } from "./monitor-auth-DjJZsjgV.js";
|
|
30
|
-
import { b as uploadMattermostFile, c as createMattermostPost, d as fetchMattermostChannelByName, f as fetchMattermostMe, g as normalizeMattermostBaseUrl, h as fetchMattermostUserTeams, m as fetchMattermostUserByUsername, o as createMattermostClient, p as fetchMattermostUser, r as resolveMattermostAccount, s as createMattermostDirectChannelWithRetry, u as fetchMattermostChannel, v as sendMattermostTyping, y as updateMattermostPost } from "./accounts-DoryUQ_b.js";
|
|
31
|
-
import { t as getMattermostRuntime } from "./runtime-BzvboXwU.js";
|
|
32
|
-
import { createHash, createHmac } from "node:crypto";
|
|
33
|
-
import { Readable } from "node:stream";
|
|
34
|
-
/**
|
|
35
|
-
* Built-in DaoCore commands to register as native slash commands.
|
|
36
|
-
* These mirror the text-based commands already handled by the gateway.
|
|
37
|
-
*/
|
|
38
|
-
const DEFAULT_COMMAND_SPECS = [
|
|
39
|
-
{
|
|
40
|
-
trigger: "oc_status",
|
|
41
|
-
originalName: "status",
|
|
42
|
-
description: "Show session status (model, usage, uptime)",
|
|
43
|
-
autoComplete: true
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
trigger: "oc_model",
|
|
47
|
-
originalName: "model",
|
|
48
|
-
description: "View or change the current model",
|
|
49
|
-
autoComplete: true,
|
|
50
|
-
autoCompleteHint: "[model-name] [--runtime runtime]"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
trigger: "oc_models",
|
|
54
|
-
originalName: "models",
|
|
55
|
-
description: "Browse available models",
|
|
56
|
-
autoComplete: true,
|
|
57
|
-
autoCompleteHint: "[provider]"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
trigger: "oc_new",
|
|
61
|
-
originalName: "new",
|
|
62
|
-
description: "Start a new conversation session",
|
|
63
|
-
autoComplete: true
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
trigger: "oc_help",
|
|
67
|
-
originalName: "help",
|
|
68
|
-
description: "Show available commands",
|
|
69
|
-
autoComplete: true
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
trigger: "oc_think",
|
|
73
|
-
originalName: "think",
|
|
74
|
-
description: "Set thinking/reasoning level",
|
|
75
|
-
autoComplete: true,
|
|
76
|
-
autoCompleteHint: "[off|low|medium|high]"
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
trigger: "oc_reasoning",
|
|
80
|
-
originalName: "reasoning",
|
|
81
|
-
description: "Toggle reasoning mode",
|
|
82
|
-
autoComplete: true,
|
|
83
|
-
autoCompleteHint: "[on|off]"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
trigger: "oc_verbose",
|
|
87
|
-
originalName: "verbose",
|
|
88
|
-
description: "Toggle verbose mode",
|
|
89
|
-
autoComplete: true,
|
|
90
|
-
autoCompleteHint: "[on|off]"
|
|
91
|
-
}
|
|
92
|
-
];
|
|
93
|
-
/**
|
|
94
|
-
* List existing custom slash commands for a team.
|
|
95
|
-
*/
|
|
96
|
-
async function listMattermostCommands(client, teamId, init) {
|
|
97
|
-
return await client.request(`/commands?team_id=${encodeURIComponent(teamId)}&custom_only=true`, init);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get a custom slash command by id.
|
|
101
|
-
*/
|
|
102
|
-
async function getMattermostCommand(client, commandId, init) {
|
|
103
|
-
return await client.request(`/commands/${encodeURIComponent(commandId)}`, init);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Create a custom slash command on a Mattermost team.
|
|
107
|
-
*/
|
|
108
|
-
async function createMattermostCommand(client, params) {
|
|
109
|
-
return await client.request("/commands", {
|
|
110
|
-
method: "POST",
|
|
111
|
-
body: JSON.stringify(params)
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Delete a custom slash command.
|
|
116
|
-
*/
|
|
117
|
-
async function deleteMattermostCommand(client, commandId) {
|
|
118
|
-
await client.request(`/commands/${encodeURIComponent(commandId)}`, { method: "DELETE" });
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Update an existing custom slash command.
|
|
122
|
-
*/
|
|
123
|
-
async function updateMattermostCommand(client, params) {
|
|
124
|
-
return await client.request(`/commands/${encodeURIComponent(params.id)}`, {
|
|
125
|
-
method: "PUT",
|
|
126
|
-
body: JSON.stringify(params)
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Register all DaoCore slash commands for a given team.
|
|
131
|
-
* Skips commands that are already registered with the same trigger + callback URL.
|
|
132
|
-
* Returns the list of newly created command IDs.
|
|
133
|
-
*/
|
|
134
|
-
async function registerSlashCommands(params) {
|
|
135
|
-
const { client, teamId, creatorUserId, callbackUrl, commands, log } = params;
|
|
136
|
-
const normalizedCreatorUserId = creatorUserId.trim();
|
|
137
|
-
if (!normalizedCreatorUserId) throw new Error("creatorUserId is required for slash command reconciliation");
|
|
138
|
-
let existing = [];
|
|
139
|
-
try {
|
|
140
|
-
existing = await listMattermostCommands(client, teamId);
|
|
141
|
-
} catch (err) {
|
|
142
|
-
log?.(`mattermost: failed to list existing commands: ${String(err)}`);
|
|
143
|
-
throw err;
|
|
144
|
-
}
|
|
145
|
-
const existingByTrigger = /* @__PURE__ */ new Map();
|
|
146
|
-
for (const cmd of existing) {
|
|
147
|
-
const list = existingByTrigger.get(cmd.trigger) ?? [];
|
|
148
|
-
list.push(cmd);
|
|
149
|
-
existingByTrigger.set(cmd.trigger, list);
|
|
150
|
-
}
|
|
151
|
-
const registered = [];
|
|
152
|
-
for (const spec of commands) {
|
|
153
|
-
const existingForTrigger = existingByTrigger.get(spec.trigger) ?? [];
|
|
154
|
-
const ownedCommands = existingForTrigger.filter((cmd) => cmd.creator_id?.trim() === normalizedCreatorUserId);
|
|
155
|
-
const foreignCommands = existingForTrigger.filter((cmd) => cmd.creator_id?.trim() !== normalizedCreatorUserId);
|
|
156
|
-
if (ownedCommands.length === 0 && foreignCommands.length > 0) {
|
|
157
|
-
log?.(`mattermost: trigger /${spec.trigger} already used by non-DaoCore command(s); skipping to avoid mutating external integrations`);
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if (ownedCommands.length > 1) log?.(`mattermost: multiple owned commands found for /${spec.trigger}; using the first and leaving extras untouched`);
|
|
161
|
-
const existingCmd = ownedCommands[0];
|
|
162
|
-
const existingNeedsUpdate = existingCmd ? existingCmd.url !== callbackUrl || existingCmd.method !== "P" : false;
|
|
163
|
-
if (existingCmd && !existingNeedsUpdate) {
|
|
164
|
-
log?.(`mattermost: command /${spec.trigger} already registered (id=${existingCmd.id})`);
|
|
165
|
-
registered.push({
|
|
166
|
-
id: existingCmd.id,
|
|
167
|
-
trigger: spec.trigger,
|
|
168
|
-
teamId,
|
|
169
|
-
token: existingCmd.token,
|
|
170
|
-
url: callbackUrl,
|
|
171
|
-
managed: false
|
|
172
|
-
});
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (existingCmd && existingNeedsUpdate) {
|
|
176
|
-
log?.(`mattermost: command /${spec.trigger} exists with different callback settings; updating (id=${existingCmd.id})`);
|
|
177
|
-
try {
|
|
178
|
-
const updated = await updateMattermostCommand(client, {
|
|
179
|
-
id: existingCmd.id,
|
|
180
|
-
team_id: teamId,
|
|
181
|
-
trigger: spec.trigger,
|
|
182
|
-
method: "P",
|
|
183
|
-
url: callbackUrl,
|
|
184
|
-
description: spec.description,
|
|
185
|
-
auto_complete: spec.autoComplete,
|
|
186
|
-
auto_complete_desc: spec.description,
|
|
187
|
-
auto_complete_hint: spec.autoCompleteHint
|
|
188
|
-
});
|
|
189
|
-
registered.push({
|
|
190
|
-
id: updated.id,
|
|
191
|
-
trigger: spec.trigger,
|
|
192
|
-
teamId,
|
|
193
|
-
token: updated.token,
|
|
194
|
-
url: callbackUrl,
|
|
195
|
-
managed: false
|
|
196
|
-
});
|
|
197
|
-
continue;
|
|
198
|
-
} catch (err) {
|
|
199
|
-
log?.(`mattermost: failed to update command /${spec.trigger} (id=${existingCmd.id}): ${String(err)}`);
|
|
200
|
-
try {
|
|
201
|
-
await deleteMattermostCommand(client, existingCmd.id);
|
|
202
|
-
log?.(`mattermost: deleted stale command /${spec.trigger} (id=${existingCmd.id})`);
|
|
203
|
-
} catch (deleteErr) {
|
|
204
|
-
log?.(`mattermost: failed to delete stale command /${spec.trigger} (id=${existingCmd.id}): ${String(deleteErr)}`);
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
const created = await createMattermostCommand(client, {
|
|
211
|
-
team_id: teamId,
|
|
212
|
-
trigger: spec.trigger,
|
|
213
|
-
method: "P",
|
|
214
|
-
url: callbackUrl,
|
|
215
|
-
description: spec.description,
|
|
216
|
-
auto_complete: spec.autoComplete,
|
|
217
|
-
auto_complete_desc: spec.description,
|
|
218
|
-
auto_complete_hint: spec.autoCompleteHint
|
|
219
|
-
});
|
|
220
|
-
log?.(`mattermost: registered command /${spec.trigger} (id=${created.id})`);
|
|
221
|
-
registered.push({
|
|
222
|
-
id: created.id,
|
|
223
|
-
trigger: spec.trigger,
|
|
224
|
-
teamId,
|
|
225
|
-
token: created.token,
|
|
226
|
-
url: callbackUrl,
|
|
227
|
-
managed: true
|
|
228
|
-
});
|
|
229
|
-
} catch (err) {
|
|
230
|
-
log?.(`mattermost: failed to register command /${spec.trigger}: ${String(err)}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return registered;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Clean up all registered slash commands.
|
|
237
|
-
*/
|
|
238
|
-
async function cleanupSlashCommands(params) {
|
|
239
|
-
const { client, commands, log } = params;
|
|
240
|
-
for (const cmd of commands) {
|
|
241
|
-
if (!cmd.managed) continue;
|
|
242
|
-
try {
|
|
243
|
-
await deleteMattermostCommand(client, cmd.id);
|
|
244
|
-
log?.(`mattermost: deleted command /${cmd.trigger} (id=${cmd.id})`);
|
|
245
|
-
} catch (err) {
|
|
246
|
-
log?.(`mattermost: failed to delete command /${cmd.trigger}: ${String(err)}`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Parse a Mattermost slash command callback payload from a URL-encoded or JSON body.
|
|
252
|
-
*/
|
|
253
|
-
function parseSlashCommandPayload(body, contentType) {
|
|
254
|
-
if (!body) return null;
|
|
255
|
-
try {
|
|
256
|
-
if (contentType?.includes("application/json")) {
|
|
257
|
-
const parsed = JSON.parse(body);
|
|
258
|
-
const token = typeof parsed.token === "string" ? parsed.token : "";
|
|
259
|
-
const teamId = typeof parsed.team_id === "string" ? parsed.team_id : "";
|
|
260
|
-
const channelId = typeof parsed.channel_id === "string" ? parsed.channel_id : "";
|
|
261
|
-
const userId = typeof parsed.user_id === "string" ? parsed.user_id : "";
|
|
262
|
-
const command = typeof parsed.command === "string" ? parsed.command : "";
|
|
263
|
-
if (!token || !teamId || !channelId || !userId || !command) return null;
|
|
264
|
-
return {
|
|
265
|
-
token,
|
|
266
|
-
team_id: teamId,
|
|
267
|
-
team_domain: typeof parsed.team_domain === "string" ? parsed.team_domain : void 0,
|
|
268
|
-
channel_id: channelId,
|
|
269
|
-
channel_name: typeof parsed.channel_name === "string" ? parsed.channel_name : void 0,
|
|
270
|
-
user_id: userId,
|
|
271
|
-
user_name: typeof parsed.user_name === "string" ? parsed.user_name : void 0,
|
|
272
|
-
command,
|
|
273
|
-
text: typeof parsed.text === "string" ? parsed.text : "",
|
|
274
|
-
trigger_id: typeof parsed.trigger_id === "string" ? parsed.trigger_id : void 0,
|
|
275
|
-
response_url: typeof parsed.response_url === "string" ? parsed.response_url : void 0
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
const params = new URLSearchParams(body);
|
|
279
|
-
const token = params.get("token");
|
|
280
|
-
const teamId = params.get("team_id");
|
|
281
|
-
const channelId = params.get("channel_id");
|
|
282
|
-
const userId = params.get("user_id");
|
|
283
|
-
const command = params.get("command");
|
|
284
|
-
if (!token || !teamId || !channelId || !userId || !command) return null;
|
|
285
|
-
return {
|
|
286
|
-
token,
|
|
287
|
-
team_id: teamId,
|
|
288
|
-
team_domain: params.get("team_domain") ?? void 0,
|
|
289
|
-
channel_id: channelId,
|
|
290
|
-
channel_name: params.get("channel_name") ?? void 0,
|
|
291
|
-
user_id: userId,
|
|
292
|
-
user_name: params.get("user_name") ?? void 0,
|
|
293
|
-
command,
|
|
294
|
-
text: params.get("text") ?? "",
|
|
295
|
-
trigger_id: params.get("trigger_id") ?? void 0,
|
|
296
|
-
response_url: params.get("response_url") ?? void 0
|
|
297
|
-
};
|
|
298
|
-
} catch {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Map the trigger word back to the original DaoCore command name.
|
|
304
|
-
* e.g. "oc_status" -> "/status", "oc_model" -> "/model"
|
|
305
|
-
*/
|
|
306
|
-
function resolveCommandText(trigger, text, triggerMap) {
|
|
307
|
-
const commandName = triggerMap?.get(trigger) ?? (trigger.startsWith("oc_") ? trigger.slice(3) : trigger);
|
|
308
|
-
const args = text.trim();
|
|
309
|
-
return args ? `/${commandName} ${args}` : `/${commandName}`;
|
|
310
|
-
}
|
|
311
|
-
function normalizeSlashCommandTrigger(command) {
|
|
312
|
-
return command.replace(/^\//, "").trim();
|
|
313
|
-
}
|
|
314
|
-
const DEFAULT_CALLBACK_PATH = "/api/channels/mattermost/command";
|
|
315
|
-
/**
|
|
316
|
-
* Ensure the callback path starts with a leading `/` to prevent
|
|
317
|
-
* malformed URLs like `http://host:portapi/...`.
|
|
318
|
-
*/
|
|
319
|
-
function normalizeCallbackPath(path) {
|
|
320
|
-
const trimmed = path.trim();
|
|
321
|
-
if (!trimmed) return DEFAULT_CALLBACK_PATH;
|
|
322
|
-
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
323
|
-
}
|
|
324
|
-
function resolveSlashCommandConfig(raw) {
|
|
325
|
-
return {
|
|
326
|
-
native: raw?.native ?? "auto",
|
|
327
|
-
nativeSkills: raw?.nativeSkills ?? "auto",
|
|
328
|
-
callbackPath: normalizeCallbackPath(raw?.callbackPath ?? DEFAULT_CALLBACK_PATH),
|
|
329
|
-
callbackUrl: normalizeOptionalString(raw?.callbackUrl)
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
function isSlashCommandsEnabled(config) {
|
|
333
|
-
if (config.native === true) return true;
|
|
334
|
-
if (config.native === false) return false;
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Build the callback URL that Mattermost will POST to when a command is invoked.
|
|
339
|
-
*/
|
|
340
|
-
function resolveCallbackUrl(params) {
|
|
341
|
-
if (params.config.callbackUrl) return params.config.callbackUrl;
|
|
342
|
-
const isWildcardBindHost = (rawHost) => {
|
|
343
|
-
const trimmed = rawHost.trim();
|
|
344
|
-
if (!trimmed) return false;
|
|
345
|
-
const host = trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : trimmed;
|
|
346
|
-
return host === "0.0.0.0" || host === "::" || host === "0:0:0:0:0:0:0:0" || host === "::0";
|
|
347
|
-
};
|
|
348
|
-
let host = params.gatewayHost && !isWildcardBindHost(params.gatewayHost) ? params.gatewayHost : "localhost";
|
|
349
|
-
const path = normalizeCallbackPath(params.config.callbackPath);
|
|
350
|
-
if (host.includes(":") && !(host.startsWith("[") && host.endsWith("]"))) host = `[${host}]`;
|
|
351
|
-
return `http://${host}:${params.gatewayPort}${path}`;
|
|
352
|
-
}
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region extensions/mattermost/src/mattermost/model-picker.ts
|
|
355
|
-
const MATTERMOST_MODEL_PICKER_CONTEXT_KEY = "oc_model_picker";
|
|
356
|
-
const MODELS_PAGE_SIZE = 8;
|
|
357
|
-
const ACTION_IDS = {
|
|
358
|
-
providers: "mdlprov",
|
|
359
|
-
list: "mdllist",
|
|
360
|
-
select: "mdlsel",
|
|
361
|
-
back: "mdlback"
|
|
362
|
-
};
|
|
363
|
-
function splitModelRef(modelRef) {
|
|
364
|
-
const match = normalizeOptionalString(modelRef)?.match(/^([^/]+)\/(.+)$/u);
|
|
365
|
-
if (!match) return null;
|
|
366
|
-
const provider = normalizeProviderId(match[1]);
|
|
367
|
-
const model = normalizeOptionalString(match[2]);
|
|
368
|
-
if (!provider || !model) return null;
|
|
369
|
-
return {
|
|
370
|
-
provider,
|
|
371
|
-
model
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
function readContextString(context, key, fallback = "") {
|
|
375
|
-
const value = context[key];
|
|
376
|
-
return typeof value === "string" ? value : fallback;
|
|
377
|
-
}
|
|
378
|
-
function readContextNumber(context, key) {
|
|
379
|
-
const value = context[key];
|
|
380
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
381
|
-
if (typeof value === "string") {
|
|
382
|
-
const parsed = Number.parseInt(value.trim(), 10);
|
|
383
|
-
if (Number.isFinite(parsed)) return parsed;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
function normalizePage(value) {
|
|
387
|
-
if (!Number.isFinite(value)) return 1;
|
|
388
|
-
return Math.max(1, Math.floor(value));
|
|
389
|
-
}
|
|
390
|
-
function paginateItems(items, page, pageSize = MODELS_PAGE_SIZE) {
|
|
391
|
-
const totalPages = Math.max(1, Math.ceil(items.length / pageSize));
|
|
392
|
-
const safePage = Math.max(1, Math.min(normalizePage(page), totalPages));
|
|
393
|
-
const start = (safePage - 1) * pageSize;
|
|
394
|
-
return {
|
|
395
|
-
items: items.slice(start, start + pageSize),
|
|
396
|
-
page: safePage,
|
|
397
|
-
totalPages,
|
|
398
|
-
hasPrev: safePage > 1,
|
|
399
|
-
hasNext: safePage < totalPages,
|
|
400
|
-
totalItems: items.length
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
function buildContext(state) {
|
|
404
|
-
return {
|
|
405
|
-
[MATTERMOST_MODEL_PICKER_CONTEXT_KEY]: true,
|
|
406
|
-
...state
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
function buildButtonId(state) {
|
|
410
|
-
const digest = createHash("sha256").update(JSON.stringify(state)).digest("hex").slice(0, 12);
|
|
411
|
-
return `${ACTION_IDS[state.action]}${digest}`;
|
|
412
|
-
}
|
|
413
|
-
function buildButton(params) {
|
|
414
|
-
const baseState = params.action === "providers" || params.action === "back" ? {
|
|
415
|
-
action: params.action,
|
|
416
|
-
ownerUserId: params.ownerUserId
|
|
417
|
-
} : params.action === "list" ? {
|
|
418
|
-
action: "list",
|
|
419
|
-
ownerUserId: params.ownerUserId,
|
|
420
|
-
provider: normalizeProviderId(params.provider ?? ""),
|
|
421
|
-
page: normalizePage(params.page)
|
|
422
|
-
} : {
|
|
423
|
-
action: "select",
|
|
424
|
-
ownerUserId: params.ownerUserId,
|
|
425
|
-
provider: normalizeProviderId(params.provider ?? ""),
|
|
426
|
-
page: normalizePage(params.page),
|
|
427
|
-
model: normalizeStringifiedOptionalString(params.model) ?? ""
|
|
428
|
-
};
|
|
429
|
-
return {
|
|
430
|
-
id: buildButtonId(baseState),
|
|
431
|
-
text: params.text,
|
|
432
|
-
...params.style ? { style: params.style } : {},
|
|
433
|
-
context: buildContext(baseState)
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
function getProviderModels(data, provider) {
|
|
437
|
-
return [...data.byProvider.get(normalizeProviderId(provider)) ?? /* @__PURE__ */ new Set()].toSorted();
|
|
438
|
-
}
|
|
439
|
-
function formatCurrentModelLine(currentModel) {
|
|
440
|
-
const parsed = splitModelRef(currentModel);
|
|
441
|
-
if (!parsed) return "Current: default";
|
|
442
|
-
return `Current: ${parsed.provider}/${parsed.model}`;
|
|
443
|
-
}
|
|
444
|
-
function resolveMattermostModelPickerEntry(commandText) {
|
|
445
|
-
const normalized = commandText.trim().replace(/\s+/g, " ");
|
|
446
|
-
if (/^\/model$/i.test(normalized)) return { kind: "summary" };
|
|
447
|
-
if (/^\/models$/i.test(normalized)) return { kind: "providers" };
|
|
448
|
-
const providerMatch = normalized.match(/^\/models\s+(\S+)$/i);
|
|
449
|
-
if (!providerMatch?.[1]) return null;
|
|
450
|
-
return {
|
|
451
|
-
kind: "models",
|
|
452
|
-
provider: normalizeProviderId(providerMatch[1])
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
function parseMattermostModelPickerContext(context) {
|
|
456
|
-
if (!context || context[MATTERMOST_MODEL_PICKER_CONTEXT_KEY] !== true) return null;
|
|
457
|
-
const ownerUserId = normalizeOptionalString(readContextString(context, "ownerUserId")) ?? "";
|
|
458
|
-
const action = normalizeOptionalString(readContextString(context, "action")) ?? "";
|
|
459
|
-
if (!ownerUserId) return null;
|
|
460
|
-
if (action === "providers" || action === "back") return {
|
|
461
|
-
action,
|
|
462
|
-
ownerUserId
|
|
463
|
-
};
|
|
464
|
-
const provider = normalizeProviderId(readContextString(context, "provider"));
|
|
465
|
-
const page = readContextNumber(context, "page");
|
|
466
|
-
if (!provider) return null;
|
|
467
|
-
if (action === "list") return {
|
|
468
|
-
action,
|
|
469
|
-
ownerUserId,
|
|
470
|
-
provider,
|
|
471
|
-
page: normalizePage(page)
|
|
472
|
-
};
|
|
473
|
-
if (action === "select") {
|
|
474
|
-
const model = normalizeOptionalString(readContextString(context, "model")) ?? "";
|
|
475
|
-
if (!model) return null;
|
|
476
|
-
return {
|
|
477
|
-
action,
|
|
478
|
-
ownerUserId,
|
|
479
|
-
provider,
|
|
480
|
-
page: normalizePage(page),
|
|
481
|
-
model
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
return null;
|
|
485
|
-
}
|
|
486
|
-
function buildMattermostAllowedModelRefs(data) {
|
|
487
|
-
const refs = /* @__PURE__ */ new Set();
|
|
488
|
-
for (const provider of data.providers) for (const model of data.byProvider.get(provider) ?? []) refs.add(`${provider}/${model}`);
|
|
489
|
-
return refs;
|
|
490
|
-
}
|
|
491
|
-
function resolveMattermostModelPickerCurrentModel(params) {
|
|
492
|
-
const fallback = `${params.data.resolvedDefault.provider}/${params.data.resolvedDefault.model}`;
|
|
493
|
-
try {
|
|
494
|
-
const storePath = resolveStorePath(params.cfg.session?.store, { agentId: params.route.agentId });
|
|
495
|
-
const sessionStore = params.skipCache ? loadSessionStore(storePath, { skipCache: true }) : loadSessionStore(storePath);
|
|
496
|
-
const sessionEntry = sessionStore[params.route.sessionKey];
|
|
497
|
-
const override = resolveStoredModelOverride({
|
|
498
|
-
sessionEntry,
|
|
499
|
-
sessionStore,
|
|
500
|
-
sessionKey: params.route.sessionKey,
|
|
501
|
-
defaultProvider: params.data.resolvedDefault.provider
|
|
502
|
-
});
|
|
503
|
-
if (!override?.model) return fallback;
|
|
504
|
-
const provider = (override.provider || params.data.resolvedDefault.provider).trim();
|
|
505
|
-
return provider ? `${provider}/${override.model}` : fallback;
|
|
506
|
-
} catch {
|
|
507
|
-
return fallback;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
function renderMattermostModelSummaryView(params) {
|
|
511
|
-
return {
|
|
512
|
-
text: [
|
|
513
|
-
formatCurrentModelLine(params.currentModel),
|
|
514
|
-
"",
|
|
515
|
-
"Tap below to browse models, or use:",
|
|
516
|
-
"/oc_model <provider/model> to switch",
|
|
517
|
-
"Browse keeps the current runtime; use /oc_model <provider/model> --runtime <runtime> to switch runtime too",
|
|
518
|
-
"/oc_model status for details"
|
|
519
|
-
].join("\n"),
|
|
520
|
-
buttons: [[buildButton({
|
|
521
|
-
action: "providers",
|
|
522
|
-
ownerUserId: params.ownerUserId,
|
|
523
|
-
text: "Browse providers",
|
|
524
|
-
style: "primary"
|
|
525
|
-
})]]
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
function renderMattermostProviderPickerView(params) {
|
|
529
|
-
const currentProvider = splitModelRef(params.currentModel)?.provider;
|
|
530
|
-
const rows = params.data.providers.map((provider) => [buildButton({
|
|
531
|
-
action: "list",
|
|
532
|
-
ownerUserId: params.ownerUserId,
|
|
533
|
-
text: `${provider} (${params.data.byProvider.get(provider)?.size ?? 0})`,
|
|
534
|
-
provider,
|
|
535
|
-
page: 1,
|
|
536
|
-
style: provider === currentProvider ? "primary" : "default"
|
|
537
|
-
})]);
|
|
538
|
-
return {
|
|
539
|
-
text: [
|
|
540
|
-
formatCurrentModelLine(params.currentModel),
|
|
541
|
-
"",
|
|
542
|
-
"Select a provider:"
|
|
543
|
-
].join("\n"),
|
|
544
|
-
buttons: rows
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
function renderMattermostModelsPickerView(params) {
|
|
548
|
-
const provider = normalizeProviderId(params.provider);
|
|
549
|
-
const models = getProviderModels(params.data, provider);
|
|
550
|
-
const current = splitModelRef(params.currentModel);
|
|
551
|
-
if (models.length === 0) return {
|
|
552
|
-
text: [
|
|
553
|
-
formatCurrentModelLine(params.currentModel),
|
|
554
|
-
"",
|
|
555
|
-
`Unknown provider: ${provider}`
|
|
556
|
-
].join("\n"),
|
|
557
|
-
buttons: [[buildButton({
|
|
558
|
-
action: "back",
|
|
559
|
-
ownerUserId: params.ownerUserId,
|
|
560
|
-
text: "Back to providers"
|
|
561
|
-
})]]
|
|
562
|
-
};
|
|
563
|
-
const page = paginateItems(models, params.page);
|
|
564
|
-
const rows = page.items.map((model) => {
|
|
565
|
-
const isCurrent = current?.provider === provider && current.model === model;
|
|
566
|
-
return [buildButton({
|
|
567
|
-
action: "select",
|
|
568
|
-
ownerUserId: params.ownerUserId,
|
|
569
|
-
text: isCurrent ? `${model} [current]` : model,
|
|
570
|
-
provider,
|
|
571
|
-
model,
|
|
572
|
-
page: page.page,
|
|
573
|
-
style: isCurrent ? "primary" : "default"
|
|
574
|
-
})];
|
|
575
|
-
});
|
|
576
|
-
const navRow = [];
|
|
577
|
-
if (page.hasPrev) navRow.push(buildButton({
|
|
578
|
-
action: "list",
|
|
579
|
-
ownerUserId: params.ownerUserId,
|
|
580
|
-
text: "Prev",
|
|
581
|
-
provider,
|
|
582
|
-
page: page.page - 1
|
|
583
|
-
}));
|
|
584
|
-
if (page.hasNext) navRow.push(buildButton({
|
|
585
|
-
action: "list",
|
|
586
|
-
ownerUserId: params.ownerUserId,
|
|
587
|
-
text: "Next",
|
|
588
|
-
provider,
|
|
589
|
-
page: page.page + 1
|
|
590
|
-
}));
|
|
591
|
-
if (navRow.length > 0) rows.push(navRow);
|
|
592
|
-
rows.push([buildButton({
|
|
593
|
-
action: "back",
|
|
594
|
-
ownerUserId: params.ownerUserId,
|
|
595
|
-
text: "Back to providers"
|
|
596
|
-
})]);
|
|
597
|
-
return {
|
|
598
|
-
text: [
|
|
599
|
-
`Models (${provider}) - ${page.totalItems} available`,
|
|
600
|
-
formatCurrentModelLine(params.currentModel),
|
|
601
|
-
`Page ${page.page}/${page.totalPages}`,
|
|
602
|
-
"Select a model to switch immediately."
|
|
603
|
-
].join("\n"),
|
|
604
|
-
buttons: rows
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
//#endregion
|
|
608
|
-
//#region extensions/mattermost/src/mattermost/reply-delivery.ts
|
|
609
|
-
async function deliverMattermostReplyPayload(params) {
|
|
610
|
-
if (isReasoningReplyPayload(params.payload)) return "reasoning_skipped";
|
|
611
|
-
const reply = resolveSendableOutboundReplyParts(params.payload, { text: params.core.channel.text.convertMarkdownTables(params.payload.text ?? "", params.tableMode) });
|
|
612
|
-
const mediaLocalRoots = getAgentScopedMediaLocalRoots(params.cfg, params.agentId);
|
|
613
|
-
const chunkMode = params.core.channel.text.resolveChunkMode(params.cfg, "mattermost", params.accountId);
|
|
614
|
-
return await deliverTextOrMediaReply({
|
|
615
|
-
payload: params.payload,
|
|
616
|
-
text: reply.text,
|
|
617
|
-
chunkText: (value) => params.core.channel.text.chunkMarkdownTextWithMode(value, params.textLimit, chunkMode),
|
|
618
|
-
sendText: async (chunk) => {
|
|
619
|
-
await params.sendMessage(params.to, chunk, {
|
|
620
|
-
cfg: params.cfg,
|
|
621
|
-
accountId: params.accountId,
|
|
622
|
-
replyToId: params.replyToId
|
|
623
|
-
});
|
|
624
|
-
},
|
|
625
|
-
sendMedia: async ({ mediaUrl, caption }) => {
|
|
626
|
-
await params.sendMessage(params.to, caption ?? "", {
|
|
627
|
-
cfg: params.cfg,
|
|
628
|
-
accountId: params.accountId,
|
|
629
|
-
mediaUrl,
|
|
630
|
-
mediaLocalRoots,
|
|
631
|
-
replyToId: params.replyToId
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region extensions/mattermost/src/mattermost/interactions.ts
|
|
638
|
-
const INTERACTION_MAX_BODY_BYTES = 64 * 1024;
|
|
639
|
-
const INTERACTION_BODY_TIMEOUT_MS = 1e4;
|
|
640
|
-
const SIGNED_CHANNEL_ID_CONTEXT_KEY = "__daocore_channel_id";
|
|
641
|
-
const callbackUrls = /* @__PURE__ */ new Map();
|
|
642
|
-
function setInteractionCallbackUrl(accountId, url) {
|
|
643
|
-
callbackUrls.set(accountId, url);
|
|
644
|
-
}
|
|
645
|
-
function resolveInteractionCallbackPath(accountId) {
|
|
646
|
-
return `/mattermost/interactions/${accountId}`;
|
|
647
|
-
}
|
|
648
|
-
function isWildcardBindHost(rawHost) {
|
|
649
|
-
const trimmed = rawHost.trim();
|
|
650
|
-
if (!trimmed) return false;
|
|
651
|
-
const host = trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : trimmed;
|
|
652
|
-
return host === "0.0.0.0" || host === "::" || host === "0:0:0:0:0:0:0:0" || host === "::0";
|
|
653
|
-
}
|
|
654
|
-
function normalizeCallbackBaseUrl(baseUrl) {
|
|
655
|
-
return baseUrl.trim().replace(/\/+$/, "");
|
|
656
|
-
}
|
|
657
|
-
function headerValue(value) {
|
|
658
|
-
if (Array.isArray(value)) return normalizeOptionalString(value[0]);
|
|
659
|
-
return normalizeOptionalString(value);
|
|
660
|
-
}
|
|
661
|
-
function isAllowedInteractionSource(params) {
|
|
662
|
-
const { allowedSourceIps } = params;
|
|
663
|
-
if (!allowedSourceIps?.length) return true;
|
|
664
|
-
return isTrustedProxyAddress(resolveClientIp({
|
|
665
|
-
remoteAddr: params.req.socket?.remoteAddress,
|
|
666
|
-
forwardedFor: headerValue(params.req.headers["x-forwarded-for"]),
|
|
667
|
-
realIp: headerValue(params.req.headers["x-real-ip"]),
|
|
668
|
-
trustedProxies: params.trustedProxies,
|
|
669
|
-
allowRealIpFallback: params.allowRealIpFallback
|
|
670
|
-
}), allowedSourceIps);
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Resolve the interaction callback URL for an account.
|
|
674
|
-
* Falls back to computing it from interactions.callbackBaseUrl or gateway host config.
|
|
675
|
-
*/
|
|
676
|
-
function computeInteractionCallbackUrl(accountId, cfg) {
|
|
677
|
-
const path = resolveInteractionCallbackPath(accountId);
|
|
678
|
-
const callbackBaseUrl = normalizeOptionalString(cfg?.interactions?.callbackBaseUrl) ?? normalizeOptionalString(cfg?.channels?.mattermost?.interactions?.callbackBaseUrl);
|
|
679
|
-
if (callbackBaseUrl) return `${normalizeCallbackBaseUrl(callbackBaseUrl)}${path}`;
|
|
680
|
-
const port = typeof cfg?.gateway?.port === "number" ? cfg.gateway.port : 18789;
|
|
681
|
-
let host = cfg?.gateway?.customBindHost && !isWildcardBindHost(cfg.gateway.customBindHost) ? cfg.gateway.customBindHost.trim() : "localhost";
|
|
682
|
-
if (host.includes(":") && !(host.startsWith("[") && host.endsWith("]"))) host = `[${host}]`;
|
|
683
|
-
return `http://${host}:${port}${path}`;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Resolve the interaction callback URL for an account.
|
|
687
|
-
* Prefers the in-memory registered URL (set by the gateway monitor) so callers outside the
|
|
688
|
-
* monitor lifecycle can reuse the runtime-validated callback destination.
|
|
689
|
-
*/
|
|
690
|
-
function resolveInteractionCallbackUrl(accountId, cfg) {
|
|
691
|
-
const cached = callbackUrls.get(accountId);
|
|
692
|
-
if (cached) return cached;
|
|
693
|
-
return computeInteractionCallbackUrl(accountId, cfg);
|
|
694
|
-
}
|
|
695
|
-
const interactionSecrets = /* @__PURE__ */ new Map();
|
|
696
|
-
let defaultInteractionSecret;
|
|
697
|
-
function deriveInteractionSecret(botToken) {
|
|
698
|
-
return createHmac("sha256", "daocore-mattermost-interactions").update(botToken).digest("hex");
|
|
699
|
-
}
|
|
700
|
-
function setInteractionSecret(accountIdOrBotToken, botToken) {
|
|
701
|
-
if (typeof botToken === "string") {
|
|
702
|
-
interactionSecrets.set(accountIdOrBotToken, deriveInteractionSecret(botToken));
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
defaultInteractionSecret = deriveInteractionSecret(accountIdOrBotToken);
|
|
706
|
-
}
|
|
707
|
-
function getInteractionSecret(accountId) {
|
|
708
|
-
const scoped = accountId ? interactionSecrets.get(accountId) : void 0;
|
|
709
|
-
if (scoped) return scoped;
|
|
710
|
-
if (defaultInteractionSecret) return defaultInteractionSecret;
|
|
711
|
-
if (interactionSecrets.size === 1) {
|
|
712
|
-
const first = interactionSecrets.values().next().value;
|
|
713
|
-
if (typeof first === "string") return first;
|
|
714
|
-
}
|
|
715
|
-
throw new Error("Interaction secret not initialized — call setInteractionSecret(accountId, botToken) first");
|
|
716
|
-
}
|
|
717
|
-
function canonicalizeInteractionContext(value) {
|
|
718
|
-
if (Array.isArray(value)) return value.map((item) => canonicalizeInteractionContext(item));
|
|
719
|
-
if (value && typeof value === "object") {
|
|
720
|
-
const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, entryValue]) => [key, canonicalizeInteractionContext(entryValue)]);
|
|
721
|
-
return Object.fromEntries(entries);
|
|
722
|
-
}
|
|
723
|
-
return value;
|
|
724
|
-
}
|
|
725
|
-
function generateInteractionToken(context, accountId) {
|
|
726
|
-
const secret = getInteractionSecret(accountId);
|
|
727
|
-
const payload = JSON.stringify(canonicalizeInteractionContext(context));
|
|
728
|
-
return createHmac("sha256", secret).update(payload).digest("hex");
|
|
729
|
-
}
|
|
730
|
-
function verifyInteractionToken(context, token, accountId) {
|
|
731
|
-
return safeEqualSecret(generateInteractionToken(context, accountId), token);
|
|
732
|
-
}
|
|
733
|
-
/**
|
|
734
|
-
* Build Mattermost `props.attachments` with interactive buttons.
|
|
735
|
-
*
|
|
736
|
-
* Each button includes an HMAC token in its integration context so the
|
|
737
|
-
* callback handler can verify the request originated from a legitimate
|
|
738
|
-
* button click (Mattermost's recommended security pattern).
|
|
739
|
-
*/
|
|
740
|
-
/**
|
|
741
|
-
* Sanitize a button ID so Mattermost's action router can match it.
|
|
742
|
-
* Mattermost uses the action ID in the URL path `/api/v4/posts/{id}/actions/{actionId}`
|
|
743
|
-
* and IDs containing hyphens or underscores break the server-side routing.
|
|
744
|
-
* See: https://github.com/mattermost/mattermost/issues/25747
|
|
745
|
-
*/
|
|
746
|
-
function sanitizeActionId(id) {
|
|
747
|
-
return id.replace(/[-_]/g, "");
|
|
748
|
-
}
|
|
749
|
-
function buildButtonAttachments(params) {
|
|
750
|
-
const actions = params.buttons.map((btn) => {
|
|
751
|
-
const safeId = sanitizeActionId(btn.id);
|
|
752
|
-
const context = {
|
|
753
|
-
action_id: safeId,
|
|
754
|
-
...btn.context
|
|
755
|
-
};
|
|
756
|
-
const token = generateInteractionToken(context, params.accountId);
|
|
757
|
-
return {
|
|
758
|
-
id: safeId,
|
|
759
|
-
type: "button",
|
|
760
|
-
name: btn.name,
|
|
761
|
-
style: btn.style,
|
|
762
|
-
integration: {
|
|
763
|
-
url: params.callbackUrl,
|
|
764
|
-
context: {
|
|
765
|
-
...context,
|
|
766
|
-
_token: token
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
});
|
|
771
|
-
return [{
|
|
772
|
-
text: params.text ?? "",
|
|
773
|
-
actions
|
|
774
|
-
}];
|
|
775
|
-
}
|
|
776
|
-
function buildButtonProps(params) {
|
|
777
|
-
const buttons = params.buttons.flatMap((item) => Array.isArray(item) ? item : [item]).map((btn) => ({
|
|
778
|
-
id: normalizeStringifiedOptionalString(btn.id ?? btn.callback_data) ?? "",
|
|
779
|
-
name: normalizeStringifiedOptionalString(btn.text ?? btn.name ?? btn.label) ?? "",
|
|
780
|
-
style: btn.style ?? "default",
|
|
781
|
-
context: typeof btn.context === "object" && btn.context !== null ? {
|
|
782
|
-
...btn.context,
|
|
783
|
-
[SIGNED_CHANNEL_ID_CONTEXT_KEY]: params.channelId
|
|
784
|
-
} : { [SIGNED_CHANNEL_ID_CONTEXT_KEY]: params.channelId }
|
|
785
|
-
})).filter((btn) => btn.id && btn.name);
|
|
786
|
-
if (buttons.length === 0) return;
|
|
787
|
-
return { attachments: buildButtonAttachments({
|
|
788
|
-
callbackUrl: params.callbackUrl,
|
|
789
|
-
accountId: params.accountId,
|
|
790
|
-
buttons,
|
|
791
|
-
text: params.text
|
|
792
|
-
}) };
|
|
793
|
-
}
|
|
794
|
-
function readInteractionBody(req) {
|
|
795
|
-
return readRequestBodyWithLimit(req, {
|
|
796
|
-
maxBytes: INTERACTION_MAX_BODY_BYTES,
|
|
797
|
-
timeoutMs: INTERACTION_BODY_TIMEOUT_MS
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
function createMattermostInteractionHandler(params) {
|
|
801
|
-
const { client, accountId, log } = params;
|
|
802
|
-
const core = getMattermostRuntime();
|
|
803
|
-
function parseInteractionPayload(raw) {
|
|
804
|
-
try {
|
|
805
|
-
return JSON.parse(raw);
|
|
806
|
-
} catch {
|
|
807
|
-
throw new Error("Mattermost interaction body was malformed JSON");
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
return async (req, res) => {
|
|
811
|
-
if (req.method !== "POST") {
|
|
812
|
-
res.statusCode = 405;
|
|
813
|
-
res.setHeader("Allow", "POST");
|
|
814
|
-
res.setHeader("Content-Type", "application/json");
|
|
815
|
-
res.end(JSON.stringify({ error: "Method Not Allowed" }));
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
if (!isAllowedInteractionSource({
|
|
819
|
-
req,
|
|
820
|
-
allowedSourceIps: params.allowedSourceIps,
|
|
821
|
-
trustedProxies: params.trustedProxies,
|
|
822
|
-
allowRealIpFallback: params.allowRealIpFallback
|
|
823
|
-
})) {
|
|
824
|
-
log?.(`mattermost interaction: rejected callback source remote=${req.socket?.remoteAddress ?? "?"}`);
|
|
825
|
-
res.statusCode = 403;
|
|
826
|
-
res.setHeader("Content-Type", "application/json");
|
|
827
|
-
res.end(JSON.stringify({ error: "Forbidden origin" }));
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
let payload;
|
|
831
|
-
try {
|
|
832
|
-
payload = parseInteractionPayload(await readInteractionBody(req));
|
|
833
|
-
} catch (err) {
|
|
834
|
-
log?.(`mattermost interaction: failed to parse body: ${String(err)}`);
|
|
835
|
-
res.statusCode = 400;
|
|
836
|
-
res.setHeader("Content-Type", "application/json");
|
|
837
|
-
res.end(JSON.stringify({ error: "Invalid request body" }));
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
const context = payload.context;
|
|
841
|
-
if (!context) {
|
|
842
|
-
res.statusCode = 400;
|
|
843
|
-
res.setHeader("Content-Type", "application/json");
|
|
844
|
-
res.end(JSON.stringify({ error: "Missing context" }));
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
const token = context["_token"];
|
|
848
|
-
if (typeof token !== "string") {
|
|
849
|
-
log?.("mattermost interaction: missing _token in context");
|
|
850
|
-
res.statusCode = 403;
|
|
851
|
-
res.setHeader("Content-Type", "application/json");
|
|
852
|
-
res.end(JSON.stringify({ error: "Missing token" }));
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
|
-
const { _token, ...contextWithoutToken } = context;
|
|
856
|
-
if (!verifyInteractionToken(contextWithoutToken, token, accountId)) {
|
|
857
|
-
log?.("mattermost interaction: invalid _token");
|
|
858
|
-
res.statusCode = 403;
|
|
859
|
-
res.setHeader("Content-Type", "application/json");
|
|
860
|
-
res.end(JSON.stringify({ error: "Invalid token" }));
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
const actionId = context.action_id;
|
|
864
|
-
if (typeof actionId !== "string") {
|
|
865
|
-
res.statusCode = 400;
|
|
866
|
-
res.setHeader("Content-Type", "application/json");
|
|
867
|
-
res.end(JSON.stringify({ error: "Missing action_id in context" }));
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
const signedChannelId = typeof contextWithoutToken[SIGNED_CHANNEL_ID_CONTEXT_KEY] === "string" ? contextWithoutToken[SIGNED_CHANNEL_ID_CONTEXT_KEY].trim() : "";
|
|
871
|
-
if (signedChannelId && signedChannelId !== payload.channel_id) {
|
|
872
|
-
log?.(`mattermost interaction: signed channel mismatch payload=${payload.channel_id} signed=${signedChannelId}`);
|
|
873
|
-
res.statusCode = 403;
|
|
874
|
-
res.setHeader("Content-Type", "application/json");
|
|
875
|
-
res.end(JSON.stringify({ error: "Channel mismatch" }));
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
const userName = payload.user_name ?? payload.user_id;
|
|
879
|
-
let originalMessage = "";
|
|
880
|
-
let originalPost = null;
|
|
881
|
-
let clickedButtonName = null;
|
|
882
|
-
try {
|
|
883
|
-
originalPost = await client.request(`/posts/${payload.post_id}`);
|
|
884
|
-
const postChannelId = originalPost.channel_id?.trim();
|
|
885
|
-
if (!postChannelId || postChannelId !== payload.channel_id) {
|
|
886
|
-
log?.(`mattermost interaction: post channel mismatch payload=${payload.channel_id} post=${postChannelId ?? "<missing>"}`);
|
|
887
|
-
res.statusCode = 403;
|
|
888
|
-
res.setHeader("Content-Type", "application/json");
|
|
889
|
-
res.end(JSON.stringify({ error: "Post/channel mismatch" }));
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
originalMessage = originalPost.message ?? "";
|
|
893
|
-
const postAttachments = Array.isArray(originalPost?.props?.attachments) ? originalPost.props.attachments : [];
|
|
894
|
-
for (const att of postAttachments) {
|
|
895
|
-
const match = att.actions?.find((a) => a.id === actionId);
|
|
896
|
-
if (match?.name) {
|
|
897
|
-
clickedButtonName = match.name;
|
|
898
|
-
break;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
if (clickedButtonName === null) {
|
|
902
|
-
log?.(`mattermost interaction: action ${actionId} not found in post ${payload.post_id}`);
|
|
903
|
-
res.statusCode = 403;
|
|
904
|
-
res.setHeader("Content-Type", "application/json");
|
|
905
|
-
res.end(JSON.stringify({ error: "Unknown action" }));
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
} catch (err) {
|
|
909
|
-
log?.(`mattermost interaction: failed to validate post ${payload.post_id}: ${String(err)}`);
|
|
910
|
-
res.statusCode = 500;
|
|
911
|
-
res.setHeader("Content-Type", "application/json");
|
|
912
|
-
res.end(JSON.stringify({ error: "Failed to validate interaction" }));
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
|
-
if (!originalPost) {
|
|
916
|
-
log?.(`mattermost interaction: missing fetched post ${payload.post_id}`);
|
|
917
|
-
res.statusCode = 500;
|
|
918
|
-
res.setHeader("Content-Type", "application/json");
|
|
919
|
-
res.end(JSON.stringify({ error: "Failed to load interaction post" }));
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
log?.(`mattermost interaction: action=${actionId} user=${payload.user_name ?? payload.user_id} post=${payload.post_id} channel=${payload.channel_id}`);
|
|
923
|
-
if (params.authorizeButtonClick) try {
|
|
924
|
-
const authorization = await params.authorizeButtonClick({
|
|
925
|
-
payload,
|
|
926
|
-
post: originalPost
|
|
927
|
-
});
|
|
928
|
-
if (!authorization.ok) {
|
|
929
|
-
res.statusCode = authorization.statusCode ?? 200;
|
|
930
|
-
res.setHeader("Content-Type", "application/json");
|
|
931
|
-
res.end(JSON.stringify(authorization.response ?? { ephemeral_text: "You are not allowed to use this action here." }));
|
|
932
|
-
return;
|
|
933
|
-
}
|
|
934
|
-
} catch (err) {
|
|
935
|
-
log?.(`mattermost interaction: authorization failed: ${String(err)}`);
|
|
936
|
-
res.statusCode = 500;
|
|
937
|
-
res.setHeader("Content-Type", "application/json");
|
|
938
|
-
res.end(JSON.stringify({ error: "Interaction authorization failed" }));
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
if (params.handleInteraction) try {
|
|
942
|
-
const response = await params.handleInteraction({
|
|
943
|
-
payload,
|
|
944
|
-
userName,
|
|
945
|
-
actionId,
|
|
946
|
-
actionName: clickedButtonName,
|
|
947
|
-
originalMessage,
|
|
948
|
-
context: contextWithoutToken,
|
|
949
|
-
post: originalPost
|
|
950
|
-
});
|
|
951
|
-
if (response !== null) {
|
|
952
|
-
res.statusCode = 200;
|
|
953
|
-
res.setHeader("Content-Type", "application/json");
|
|
954
|
-
res.end(JSON.stringify(response));
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
} catch (err) {
|
|
958
|
-
log?.(`mattermost interaction: custom handler failed: ${String(err)}`);
|
|
959
|
-
res.statusCode = 500;
|
|
960
|
-
res.setHeader("Content-Type", "application/json");
|
|
961
|
-
res.end(JSON.stringify({ error: "Interaction handler failed" }));
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
|
-
try {
|
|
965
|
-
const eventLabel = `Mattermost button click: action="${actionId}" by ${payload.user_name ?? payload.user_id} in channel ${payload.channel_id}`;
|
|
966
|
-
const sessionKey = params.resolveSessionKey ? await params.resolveSessionKey({
|
|
967
|
-
channelId: payload.channel_id,
|
|
968
|
-
userId: payload.user_id,
|
|
969
|
-
post: originalPost
|
|
970
|
-
}) : `agent:main:mattermost:${accountId}:${payload.channel_id}`;
|
|
971
|
-
core.system.enqueueSystemEvent(eventLabel, {
|
|
972
|
-
sessionKey,
|
|
973
|
-
contextKey: `mattermost:interaction:${payload.post_id}:${actionId}`
|
|
974
|
-
});
|
|
975
|
-
} catch (err) {
|
|
976
|
-
log?.(`mattermost interaction: system event dispatch failed: ${String(err)}`);
|
|
977
|
-
}
|
|
978
|
-
try {
|
|
979
|
-
await updateMattermostPost(client, payload.post_id, {
|
|
980
|
-
message: originalMessage,
|
|
981
|
-
props: { attachments: [{ text: `✓ **${clickedButtonName}** selected by @${userName}` }] }
|
|
982
|
-
});
|
|
983
|
-
} catch (err) {
|
|
984
|
-
log?.(`mattermost interaction: failed to update post ${payload.post_id}: ${String(err)}`);
|
|
985
|
-
}
|
|
986
|
-
res.statusCode = 200;
|
|
987
|
-
res.setHeader("Content-Type", "application/json");
|
|
988
|
-
res.end("{}");
|
|
989
|
-
if (params.dispatchButtonClick) try {
|
|
990
|
-
await params.dispatchButtonClick({
|
|
991
|
-
channelId: payload.channel_id,
|
|
992
|
-
userId: payload.user_id,
|
|
993
|
-
userName,
|
|
994
|
-
actionId,
|
|
995
|
-
actionName: clickedButtonName,
|
|
996
|
-
postId: payload.post_id,
|
|
997
|
-
post: originalPost
|
|
998
|
-
});
|
|
999
|
-
} catch (err) {
|
|
1000
|
-
log?.(`mattermost interaction: dispatchButtonClick failed: ${String(err)}`);
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
}
|
|
1004
|
-
//#endregion
|
|
1005
|
-
//#region extensions/mattermost/src/mattermost/target-resolution.ts
|
|
1006
|
-
const mattermostOpaqueTargetCache = /* @__PURE__ */ new Map();
|
|
1007
|
-
function cacheKey$1(baseUrl, token, id) {
|
|
1008
|
-
return `${baseUrl}::${token}::${id}`;
|
|
1009
|
-
}
|
|
1010
|
-
/** Mattermost IDs are 26-character lowercase alphanumeric strings. */
|
|
1011
|
-
function isMattermostId(value) {
|
|
1012
|
-
return /^[a-z0-9]{26}$/.test(value);
|
|
1013
|
-
}
|
|
1014
|
-
function isExplicitMattermostTarget(raw) {
|
|
1015
|
-
const trimmed = raw.trim();
|
|
1016
|
-
if (!trimmed) return false;
|
|
1017
|
-
return /^(channel|user|mattermost):/i.test(trimmed) || trimmed.startsWith("@") || trimmed.startsWith("#");
|
|
1018
|
-
}
|
|
1019
|
-
function parseMattermostApiStatus(err) {
|
|
1020
|
-
if (!err || typeof err !== "object") return;
|
|
1021
|
-
const msg = "message" in err && typeof err.message === "string" ? err.message : "";
|
|
1022
|
-
const match = /Mattermost API (\d{3})\b/.exec(msg);
|
|
1023
|
-
if (!match) return;
|
|
1024
|
-
const code = Number(match[1]);
|
|
1025
|
-
return Number.isFinite(code) ? code : void 0;
|
|
1026
|
-
}
|
|
1027
|
-
async function resolveMattermostOpaqueTarget(params) {
|
|
1028
|
-
const input = params.input.trim();
|
|
1029
|
-
if (!input || isExplicitMattermostTarget(input) || !isMattermostId(input)) return null;
|
|
1030
|
-
const account = params.cfg && (!params.token || !params.baseUrl) ? resolveMattermostAccount({
|
|
1031
|
-
cfg: params.cfg,
|
|
1032
|
-
accountId: params.accountId
|
|
1033
|
-
}) : null;
|
|
1034
|
-
const token = normalizeOptionalString(params.token) ?? normalizeOptionalString(account?.botToken);
|
|
1035
|
-
const baseUrl = normalizeMattermostBaseUrl(params.baseUrl ?? account?.baseUrl);
|
|
1036
|
-
if (!token || !baseUrl) return null;
|
|
1037
|
-
const key = cacheKey$1(baseUrl, token, input);
|
|
1038
|
-
const cached = mattermostOpaqueTargetCache.get(key);
|
|
1039
|
-
if (cached === true) return {
|
|
1040
|
-
kind: "user",
|
|
1041
|
-
id: input,
|
|
1042
|
-
to: `user:${input}`
|
|
1043
|
-
};
|
|
1044
|
-
if (cached === false) return {
|
|
1045
|
-
kind: "channel",
|
|
1046
|
-
id: input,
|
|
1047
|
-
to: `channel:${input}`
|
|
1048
|
-
};
|
|
1049
|
-
const client = createMattermostClient({
|
|
1050
|
-
baseUrl,
|
|
1051
|
-
botToken: token,
|
|
1052
|
-
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account?.config)
|
|
1053
|
-
});
|
|
1054
|
-
try {
|
|
1055
|
-
await fetchMattermostUser(client, input);
|
|
1056
|
-
mattermostOpaqueTargetCache.set(key, true);
|
|
1057
|
-
return {
|
|
1058
|
-
kind: "user",
|
|
1059
|
-
id: input,
|
|
1060
|
-
to: `user:${input}`
|
|
1061
|
-
};
|
|
1062
|
-
} catch (err) {
|
|
1063
|
-
if (parseMattermostApiStatus(err) === 404) mattermostOpaqueTargetCache.set(key, false);
|
|
1064
|
-
return {
|
|
1065
|
-
kind: "channel",
|
|
1066
|
-
id: input,
|
|
1067
|
-
to: `channel:${input}`
|
|
1068
|
-
};
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
//#endregion
|
|
1072
|
-
//#region extensions/mattermost/src/mattermost/send.ts
|
|
1073
|
-
const botUserCache = /* @__PURE__ */ new Map();
|
|
1074
|
-
const userByNameCache = /* @__PURE__ */ new Map();
|
|
1075
|
-
const channelByNameCache = /* @__PURE__ */ new Map();
|
|
1076
|
-
const dmChannelCache = /* @__PURE__ */ new Map();
|
|
1077
|
-
const getCore = () => getMattermostRuntime();
|
|
1078
|
-
function createMattermostSendReceipt(params) {
|
|
1079
|
-
const messageIds = params.messageId.trim() && params.messageId !== "unknown" ? [params.messageId] : [];
|
|
1080
|
-
return createMessageReceiptFromOutboundResults({
|
|
1081
|
-
kind: params.kind,
|
|
1082
|
-
...params.replyToId ? { replyToId: params.replyToId } : {},
|
|
1083
|
-
results: messageIds.map((messageId) => ({
|
|
1084
|
-
channel: "mattermost",
|
|
1085
|
-
messageId,
|
|
1086
|
-
channelId: params.channelId
|
|
1087
|
-
}))
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
function resolveMattermostReceiptKind(params) {
|
|
1091
|
-
if (params.fileIds?.length) return "media";
|
|
1092
|
-
if (params.buttons?.length || params.props) return "card";
|
|
1093
|
-
return "text";
|
|
1094
|
-
}
|
|
1095
|
-
function recordMattermostOutboundActivity(accountId) {
|
|
1096
|
-
try {
|
|
1097
|
-
getCore().channel.activity.record({
|
|
1098
|
-
channel: "mattermost",
|
|
1099
|
-
accountId,
|
|
1100
|
-
direction: "outbound"
|
|
1101
|
-
});
|
|
1102
|
-
} catch (error) {
|
|
1103
|
-
if (!(error instanceof Error) || error.message !== "Mattermost runtime not initialized") throw error;
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
function cacheKey(baseUrl, token) {
|
|
1107
|
-
return `${baseUrl}::${token}`;
|
|
1108
|
-
}
|
|
1109
|
-
function normalizeMessage(text, mediaUrl) {
|
|
1110
|
-
return [normalizeOptionalString(text) ?? "", normalizeOptionalString(mediaUrl)].filter(Boolean).join("\n");
|
|
1111
|
-
}
|
|
1112
|
-
function isHttpUrl(value) {
|
|
1113
|
-
return /^https?:\/\//i.test(value);
|
|
1114
|
-
}
|
|
1115
|
-
function parseMattermostTarget(raw) {
|
|
1116
|
-
const trimmed = raw.trim();
|
|
1117
|
-
if (!trimmed) throw new Error("Recipient is required for Mattermost sends");
|
|
1118
|
-
const lower = normalizeLowercaseStringOrEmpty(trimmed);
|
|
1119
|
-
if (lower.startsWith("channel:")) {
|
|
1120
|
-
const id = trimmed.slice(8).trim();
|
|
1121
|
-
if (!id) throw new Error("Channel id is required for Mattermost sends");
|
|
1122
|
-
if (id.startsWith("#")) {
|
|
1123
|
-
const name = id.slice(1).trim();
|
|
1124
|
-
if (!name) throw new Error("Channel name is required for Mattermost sends");
|
|
1125
|
-
return {
|
|
1126
|
-
kind: "channel-name",
|
|
1127
|
-
name
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
if (!isMattermostId(id)) return {
|
|
1131
|
-
kind: "channel-name",
|
|
1132
|
-
name: id
|
|
1133
|
-
};
|
|
1134
|
-
return {
|
|
1135
|
-
kind: "channel",
|
|
1136
|
-
id
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
if (lower.startsWith("user:")) {
|
|
1140
|
-
const id = trimmed.slice(5).trim();
|
|
1141
|
-
if (!id) throw new Error("User id is required for Mattermost sends");
|
|
1142
|
-
return {
|
|
1143
|
-
kind: "user",
|
|
1144
|
-
id
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
if (lower.startsWith("mattermost:")) {
|
|
1148
|
-
const id = trimmed.slice(11).trim();
|
|
1149
|
-
if (!id) throw new Error("User id is required for Mattermost sends");
|
|
1150
|
-
return {
|
|
1151
|
-
kind: "user",
|
|
1152
|
-
id
|
|
1153
|
-
};
|
|
1154
|
-
}
|
|
1155
|
-
if (trimmed.startsWith("@")) {
|
|
1156
|
-
const username = trimmed.slice(1).trim();
|
|
1157
|
-
if (!username) throw new Error("Username is required for Mattermost sends");
|
|
1158
|
-
return {
|
|
1159
|
-
kind: "user",
|
|
1160
|
-
username
|
|
1161
|
-
};
|
|
1162
|
-
}
|
|
1163
|
-
if (trimmed.startsWith("#")) {
|
|
1164
|
-
const name = trimmed.slice(1).trim();
|
|
1165
|
-
if (!name) throw new Error("Channel name is required for Mattermost sends");
|
|
1166
|
-
return {
|
|
1167
|
-
kind: "channel-name",
|
|
1168
|
-
name
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
if (!isMattermostId(trimmed)) return {
|
|
1172
|
-
kind: "channel-name",
|
|
1173
|
-
name: trimmed
|
|
1174
|
-
};
|
|
1175
|
-
return {
|
|
1176
|
-
kind: "channel",
|
|
1177
|
-
id: trimmed
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
async function resolveBotUser(baseUrl, token, allowPrivateNetwork) {
|
|
1181
|
-
const key = cacheKey(baseUrl, token);
|
|
1182
|
-
const cached = botUserCache.get(key);
|
|
1183
|
-
if (cached) return cached;
|
|
1184
|
-
const user = await fetchMattermostMe(createMattermostClient({
|
|
1185
|
-
baseUrl,
|
|
1186
|
-
botToken: token,
|
|
1187
|
-
allowPrivateNetwork
|
|
1188
|
-
}));
|
|
1189
|
-
botUserCache.set(key, user);
|
|
1190
|
-
return user;
|
|
1191
|
-
}
|
|
1192
|
-
async function resolveUserIdByUsername(params) {
|
|
1193
|
-
const { baseUrl, token, username } = params;
|
|
1194
|
-
const key = `${cacheKey(baseUrl, token)}::${normalizeLowercaseStringOrEmpty(username)}`;
|
|
1195
|
-
const cached = userByNameCache.get(key);
|
|
1196
|
-
if (cached?.id) return cached.id;
|
|
1197
|
-
const user = await fetchMattermostUserByUsername(createMattermostClient({
|
|
1198
|
-
baseUrl,
|
|
1199
|
-
botToken: token,
|
|
1200
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
1201
|
-
}), username);
|
|
1202
|
-
userByNameCache.set(key, user);
|
|
1203
|
-
return user.id;
|
|
1204
|
-
}
|
|
1205
|
-
async function resolveChannelIdByName(params) {
|
|
1206
|
-
const { baseUrl, token, name } = params;
|
|
1207
|
-
const key = `${cacheKey(baseUrl, token)}::channel::${normalizeLowercaseStringOrEmpty(name)}`;
|
|
1208
|
-
const cached = channelByNameCache.get(key);
|
|
1209
|
-
if (cached) return cached;
|
|
1210
|
-
const client = createMattermostClient({
|
|
1211
|
-
baseUrl,
|
|
1212
|
-
botToken: token,
|
|
1213
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
1214
|
-
});
|
|
1215
|
-
const teams = await fetchMattermostUserTeams(client, (await fetchMattermostMe(client)).id);
|
|
1216
|
-
for (const team of teams) try {
|
|
1217
|
-
const channel = await fetchMattermostChannelByName(client, team.id, name);
|
|
1218
|
-
if (channel?.id) {
|
|
1219
|
-
channelByNameCache.set(key, channel.id);
|
|
1220
|
-
return channel.id;
|
|
1221
|
-
}
|
|
1222
|
-
} catch {}
|
|
1223
|
-
throw new Error(`Mattermost channel "#${name}" not found in any team the bot belongs to`);
|
|
1224
|
-
}
|
|
1225
|
-
function mergeDmRetryOptions(base, override) {
|
|
1226
|
-
const merged = {
|
|
1227
|
-
maxRetries: override?.maxRetries ?? base?.maxRetries,
|
|
1228
|
-
initialDelayMs: override?.initialDelayMs ?? base?.initialDelayMs,
|
|
1229
|
-
maxDelayMs: override?.maxDelayMs ?? base?.maxDelayMs,
|
|
1230
|
-
timeoutMs: override?.timeoutMs ?? base?.timeoutMs,
|
|
1231
|
-
onRetry: override?.onRetry
|
|
1232
|
-
};
|
|
1233
|
-
if (merged.maxRetries === void 0 && merged.initialDelayMs === void 0 && merged.maxDelayMs === void 0 && merged.timeoutMs === void 0 && merged.onRetry === void 0) return;
|
|
1234
|
-
return merged;
|
|
1235
|
-
}
|
|
1236
|
-
async function resolveTargetChannelId(params) {
|
|
1237
|
-
if (params.target.kind === "channel") return params.target.id;
|
|
1238
|
-
if (params.target.kind === "channel-name") return await resolveChannelIdByName({
|
|
1239
|
-
baseUrl: params.baseUrl,
|
|
1240
|
-
token: params.token,
|
|
1241
|
-
name: params.target.name,
|
|
1242
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
1243
|
-
});
|
|
1244
|
-
const userId = params.target.id ? params.target.id : await resolveUserIdByUsername({
|
|
1245
|
-
baseUrl: params.baseUrl,
|
|
1246
|
-
token: params.token,
|
|
1247
|
-
username: params.target.username ?? "",
|
|
1248
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
1249
|
-
});
|
|
1250
|
-
const dmKey = `${cacheKey(params.baseUrl, params.token)}::dm::${userId}`;
|
|
1251
|
-
const cachedDm = dmChannelCache.get(dmKey);
|
|
1252
|
-
if (cachedDm) return cachedDm;
|
|
1253
|
-
const botUser = await resolveBotUser(params.baseUrl, params.token, params.allowPrivateNetwork);
|
|
1254
|
-
const channel = await createMattermostDirectChannelWithRetry(createMattermostClient({
|
|
1255
|
-
baseUrl: params.baseUrl,
|
|
1256
|
-
botToken: params.token,
|
|
1257
|
-
allowPrivateNetwork: params.allowPrivateNetwork
|
|
1258
|
-
}), [botUser.id, userId], {
|
|
1259
|
-
...params.dmRetryOptions,
|
|
1260
|
-
onRetry: (attempt, delayMs, error) => {
|
|
1261
|
-
params.dmRetryOptions?.onRetry?.(attempt, delayMs, error);
|
|
1262
|
-
if (params.logger) params.logger.warn?.(`DM channel creation retry ${attempt} after ${delayMs}ms: ${error.message}`);
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1265
|
-
dmChannelCache.set(dmKey, channel.id);
|
|
1266
|
-
return channel.id;
|
|
1267
|
-
}
|
|
1268
|
-
async function resolveMattermostSendContext(to, opts) {
|
|
1269
|
-
const core = getCore();
|
|
1270
|
-
const logger = core.logging.getChildLogger({ module: "mattermost" });
|
|
1271
|
-
if (!opts?.cfg) throw new Error("Mattermost send requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.");
|
|
1272
|
-
const cfg = requireRuntimeConfig(opts.cfg, "Mattermost send");
|
|
1273
|
-
const account = resolveMattermostAccount({
|
|
1274
|
-
cfg,
|
|
1275
|
-
accountId: opts.accountId
|
|
1276
|
-
});
|
|
1277
|
-
const token = normalizeOptionalString(opts.botToken) ?? normalizeOptionalString(account.botToken);
|
|
1278
|
-
if (!token) throw new Error(`Mattermost bot token missing for account "${account.accountId}" (set channels.mattermost.accounts.${account.accountId}.botToken or MATTERMOST_BOT_TOKEN for default).`);
|
|
1279
|
-
const baseUrl = normalizeMattermostBaseUrl(opts.baseUrl ?? account.baseUrl);
|
|
1280
|
-
if (!baseUrl) throw new Error(`Mattermost baseUrl missing for account "${account.accountId}" (set channels.mattermost.accounts.${account.accountId}.baseUrl or MATTERMOST_URL for default).`);
|
|
1281
|
-
const trimmedTo = normalizeOptionalString(to) ?? "";
|
|
1282
|
-
const opaqueTarget = await resolveMattermostOpaqueTarget({
|
|
1283
|
-
input: trimmedTo,
|
|
1284
|
-
token,
|
|
1285
|
-
baseUrl
|
|
1286
|
-
});
|
|
1287
|
-
const target = opaqueTarget?.kind === "user" ? {
|
|
1288
|
-
kind: "user",
|
|
1289
|
-
id: opaqueTarget.id
|
|
1290
|
-
} : opaqueTarget?.kind === "channel" ? {
|
|
1291
|
-
kind: "channel",
|
|
1292
|
-
id: opaqueTarget.id
|
|
1293
|
-
} : parseMattermostTarget(trimmedTo);
|
|
1294
|
-
const dmRetryOptions = mergeDmRetryOptions(account.config.dmChannelRetry ? {
|
|
1295
|
-
maxRetries: account.config.dmChannelRetry.maxRetries,
|
|
1296
|
-
initialDelayMs: account.config.dmChannelRetry.initialDelayMs,
|
|
1297
|
-
maxDelayMs: account.config.dmChannelRetry.maxDelayMs,
|
|
1298
|
-
timeoutMs: account.config.dmChannelRetry.timeoutMs
|
|
1299
|
-
} : void 0, opts.dmRetryOptions);
|
|
1300
|
-
const allowPrivateNetwork = isPrivateNetworkOptInEnabled(account.config);
|
|
1301
|
-
const channelId = await resolveTargetChannelId({
|
|
1302
|
-
target,
|
|
1303
|
-
baseUrl,
|
|
1304
|
-
token,
|
|
1305
|
-
allowPrivateNetwork,
|
|
1306
|
-
dmRetryOptions,
|
|
1307
|
-
logger: core.logging.shouldLogVerbose() ? logger : void 0
|
|
1308
|
-
});
|
|
1309
|
-
return {
|
|
1310
|
-
cfg,
|
|
1311
|
-
accountId: account.accountId,
|
|
1312
|
-
token,
|
|
1313
|
-
baseUrl,
|
|
1314
|
-
channelId,
|
|
1315
|
-
allowPrivateNetwork
|
|
1316
|
-
};
|
|
1317
|
-
}
|
|
1318
|
-
async function sendMessageMattermost(to, text, opts) {
|
|
1319
|
-
const core = getCore();
|
|
1320
|
-
const logger = core.logging.getChildLogger({ module: "mattermost" });
|
|
1321
|
-
const { cfg, accountId, token, baseUrl, channelId, allowPrivateNetwork } = await resolveMattermostSendContext(to, opts);
|
|
1322
|
-
const client = createMattermostClient({
|
|
1323
|
-
baseUrl,
|
|
1324
|
-
botToken: token,
|
|
1325
|
-
allowPrivateNetwork
|
|
1326
|
-
});
|
|
1327
|
-
let props = opts.props;
|
|
1328
|
-
if (!props && Array.isArray(opts.buttons) && opts.buttons.length > 0) {
|
|
1329
|
-
setInteractionSecret(accountId, token);
|
|
1330
|
-
props = buildButtonProps({
|
|
1331
|
-
callbackUrl: resolveInteractionCallbackUrl(accountId, {
|
|
1332
|
-
gateway: cfg.gateway,
|
|
1333
|
-
interactions: resolveMattermostAccount({
|
|
1334
|
-
cfg,
|
|
1335
|
-
accountId
|
|
1336
|
-
}).config?.interactions
|
|
1337
|
-
}),
|
|
1338
|
-
accountId,
|
|
1339
|
-
channelId,
|
|
1340
|
-
buttons: opts.buttons,
|
|
1341
|
-
text: opts.attachmentText
|
|
1342
|
-
});
|
|
1343
|
-
}
|
|
1344
|
-
let message = normalizeOptionalString(text) ?? "";
|
|
1345
|
-
let fileIds;
|
|
1346
|
-
let uploadError;
|
|
1347
|
-
const mediaUrl = opts.mediaUrl?.trim();
|
|
1348
|
-
if (mediaUrl) try {
|
|
1349
|
-
const media = await loadOutboundMediaFromUrl(mediaUrl, {
|
|
1350
|
-
mediaLocalRoots: opts.mediaLocalRoots,
|
|
1351
|
-
mediaReadFile: opts.mediaReadFile
|
|
1352
|
-
});
|
|
1353
|
-
fileIds = [(await uploadMattermostFile(client, {
|
|
1354
|
-
channelId,
|
|
1355
|
-
buffer: media.buffer,
|
|
1356
|
-
fileName: media.fileName ?? "upload",
|
|
1357
|
-
contentType: media.contentType ?? void 0
|
|
1358
|
-
})).id];
|
|
1359
|
-
} catch (err) {
|
|
1360
|
-
uploadError = err instanceof Error ? err : new Error(String(err));
|
|
1361
|
-
if (core.logging.shouldLogVerbose()) logger.debug?.(`mattermost send: media upload failed, falling back to URL text: ${String(err)}`);
|
|
1362
|
-
message = normalizeMessage(message, isHttpUrl(mediaUrl) ? mediaUrl : "");
|
|
1363
|
-
}
|
|
1364
|
-
if (message) {
|
|
1365
|
-
const tableMode = resolveMarkdownTableMode({
|
|
1366
|
-
cfg,
|
|
1367
|
-
channel: "mattermost",
|
|
1368
|
-
accountId
|
|
1369
|
-
});
|
|
1370
|
-
message = convertMarkdownTables(message, tableMode);
|
|
1371
|
-
}
|
|
1372
|
-
if (!message && (!fileIds || fileIds.length === 0)) {
|
|
1373
|
-
if (uploadError) throw new Error(`Mattermost media upload failed: ${uploadError.message}`);
|
|
1374
|
-
throw new Error("Mattermost message is empty");
|
|
1375
|
-
}
|
|
1376
|
-
const post = await createMattermostPost(client, {
|
|
1377
|
-
channelId,
|
|
1378
|
-
message,
|
|
1379
|
-
rootId: opts.replyToId,
|
|
1380
|
-
fileIds,
|
|
1381
|
-
props
|
|
1382
|
-
});
|
|
1383
|
-
recordMattermostOutboundActivity(accountId);
|
|
1384
|
-
const messageId = post.id ?? "unknown";
|
|
1385
|
-
return {
|
|
1386
|
-
messageId,
|
|
1387
|
-
channelId,
|
|
1388
|
-
receipt: createMattermostSendReceipt({
|
|
1389
|
-
messageId,
|
|
1390
|
-
channelId,
|
|
1391
|
-
kind: resolveMattermostReceiptKind({
|
|
1392
|
-
fileIds,
|
|
1393
|
-
buttons: opts.buttons,
|
|
1394
|
-
props
|
|
1395
|
-
}),
|
|
1396
|
-
replyToId: opts.replyToId
|
|
1397
|
-
})
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
//#endregion
|
|
1401
|
-
//#region extensions/mattermost/src/mattermost/slash-http.ts
|
|
1402
|
-
const MAX_BODY_BYTES = 64 * 1024;
|
|
1403
|
-
const BODY_READ_TIMEOUT_MS = 5e3;
|
|
1404
|
-
const COMMAND_LOOKUP_TIMEOUT_MS = 1e3;
|
|
1405
|
-
const COMMAND_VALIDATION_FAILURE_CACHE_MS = 5e3;
|
|
1406
|
-
const COMMAND_VALIDATION_FAILURE_CACHE_MAX_KEYS = 2e3;
|
|
1407
|
-
const COMMAND_VALIDATION_LOOKUP_BURST = 20;
|
|
1408
|
-
const COMMAND_VALIDATION_LOOKUP_REFILL_MS = 500;
|
|
1409
|
-
const COMMAND_VALIDATION_LOOKUP_LIMIT_LOG_MS = 5e3;
|
|
1410
|
-
const COMMAND_VALIDATION_LOOKUP_RATE_LIMIT_MAX_KEYS = 2e3;
|
|
1411
|
-
const commandLookupInflight = /* @__PURE__ */ new Map();
|
|
1412
|
-
const commandValidationFailureCache = /* @__PURE__ */ new Map();
|
|
1413
|
-
const commandValidationLookupRateLimit = /* @__PURE__ */ new Map();
|
|
1414
|
-
const SECRET_LOG_KEYS = new Set([
|
|
1415
|
-
"access_token",
|
|
1416
|
-
"authorization",
|
|
1417
|
-
"bottoken",
|
|
1418
|
-
"client_secret",
|
|
1419
|
-
"refresh_token",
|
|
1420
|
-
"token"
|
|
1421
|
-
]);
|
|
1422
|
-
/**
|
|
1423
|
-
* Read the full request body as a string.
|
|
1424
|
-
*/
|
|
1425
|
-
function readBody(req, maxBytes, timeoutMs = BODY_READ_TIMEOUT_MS) {
|
|
1426
|
-
return readRequestBodyWithLimit(req, {
|
|
1427
|
-
maxBytes,
|
|
1428
|
-
timeoutMs
|
|
1429
|
-
});
|
|
1430
|
-
}
|
|
1431
|
-
function sendJsonResponse(res, status, body) {
|
|
1432
|
-
res.statusCode = status;
|
|
1433
|
-
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
1434
|
-
res.end(JSON.stringify(body));
|
|
1435
|
-
}
|
|
1436
|
-
function findRegisteredCommandForPayload(params) {
|
|
1437
|
-
const trigger = normalizeSlashCommandTrigger(params.payload.command);
|
|
1438
|
-
return params.registeredCommands.find((cmd) => cmd.teamId === params.payload.team_id && cmd.trigger === trigger);
|
|
1439
|
-
}
|
|
1440
|
-
function isDeletedMattermostCommand(command) {
|
|
1441
|
-
return typeof command.delete_at === "number" && command.delete_at > 0;
|
|
1442
|
-
}
|
|
1443
|
-
function sanitizeCommandLookupError(error) {
|
|
1444
|
-
return (error instanceof Error ? error.message : String(error)).replace(/[\r\n\t]/gu, " ").replace(/https?:\/\/[^\s)\]}]+/giu, (urlText) => {
|
|
1445
|
-
try {
|
|
1446
|
-
const url = new URL(urlText);
|
|
1447
|
-
if (url.username || url.password) {
|
|
1448
|
-
url.username = "redacted";
|
|
1449
|
-
url.password = "redacted";
|
|
1450
|
-
}
|
|
1451
|
-
for (const key of url.searchParams.keys()) if (SECRET_LOG_KEYS.has(key.toLowerCase())) url.searchParams.set(key, "redacted");
|
|
1452
|
-
return url.toString();
|
|
1453
|
-
} catch {
|
|
1454
|
-
return urlText;
|
|
1455
|
-
}
|
|
1456
|
-
}).replace(/(^|[^\w-])(Bearer|Token)\s+[A-Za-z0-9._~+/=-]+/giu, "$1$2 [redacted]").replace(/\b(token|authorization|access_token|refresh_token|client_secret|botToken)\b(\s*["']?\s*(?:=|:)\s*["']?)[^"',\s;}]+/giu, "$1$2[redacted]").slice(0, 300);
|
|
1457
|
-
}
|
|
1458
|
-
function sanitizeMattermostLogValue(value) {
|
|
1459
|
-
return value.replace(/[\r\n\t]/gu, " ").slice(0, 200);
|
|
1460
|
-
}
|
|
1461
|
-
async function withCommandLookupTimeout(task) {
|
|
1462
|
-
const controller = new AbortController();
|
|
1463
|
-
const timeout = setTimeout(() => controller.abort(), COMMAND_LOOKUP_TIMEOUT_MS);
|
|
1464
|
-
try {
|
|
1465
|
-
return await task(controller.signal);
|
|
1466
|
-
} finally {
|
|
1467
|
-
clearTimeout(timeout);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
function commandLookupKey(client, registered, accountId) {
|
|
1471
|
-
return `${client.apiBaseUrl}:${accountId}:${registered.teamId}:${registered.id}`;
|
|
1472
|
-
}
|
|
1473
|
-
function clearMattermostSlashCommandValidationCacheForAccount(accountId) {
|
|
1474
|
-
for (const [key, entry] of commandValidationFailureCache) if (entry.accountId === accountId) commandValidationFailureCache.delete(key);
|
|
1475
|
-
for (const [key, entry] of commandLookupInflight) if (entry.accountId === accountId) commandLookupInflight.delete(key);
|
|
1476
|
-
for (const [key, entry] of commandValidationLookupRateLimit) if (entry.accountId === accountId) commandValidationLookupRateLimit.delete(key);
|
|
1477
|
-
}
|
|
1478
|
-
function sweepCommandValidationFailureCache(now = Date.now()) {
|
|
1479
|
-
for (const [key, entry] of commandValidationFailureCache) if (entry.expiresAt <= now) commandValidationFailureCache.delete(key);
|
|
1480
|
-
while (commandValidationFailureCache.size > COMMAND_VALIDATION_FAILURE_CACHE_MAX_KEYS) {
|
|
1481
|
-
const oldestKey = commandValidationFailureCache.keys().next().value;
|
|
1482
|
-
if (!oldestKey) break;
|
|
1483
|
-
commandValidationFailureCache.delete(oldestKey);
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
function hasCachedCommandValidationFailure(key, now = Date.now()) {
|
|
1487
|
-
sweepCommandValidationFailureCache(now);
|
|
1488
|
-
const cached = commandValidationFailureCache.get(key);
|
|
1489
|
-
if (!cached) return false;
|
|
1490
|
-
if (cached.expiresAt > now) return true;
|
|
1491
|
-
commandValidationFailureCache.delete(key);
|
|
1492
|
-
return false;
|
|
1493
|
-
}
|
|
1494
|
-
function cacheCommandValidationFailure(key, accountId) {
|
|
1495
|
-
sweepCommandValidationFailureCache();
|
|
1496
|
-
commandValidationFailureCache.set(key, {
|
|
1497
|
-
accountId,
|
|
1498
|
-
expiresAt: Date.now() + COMMAND_VALIDATION_FAILURE_CACHE_MS
|
|
1499
|
-
});
|
|
1500
|
-
}
|
|
1501
|
-
function sweepCommandValidationLookupRateLimit(now = Date.now()) {
|
|
1502
|
-
const staleAfterMs = COMMAND_VALIDATION_LOOKUP_REFILL_MS * COMMAND_VALIDATION_LOOKUP_BURST * 2;
|
|
1503
|
-
for (const [key, entry] of commandValidationLookupRateLimit) if (now - entry.updatedAt > staleAfterMs) commandValidationLookupRateLimit.delete(key);
|
|
1504
|
-
while (commandValidationLookupRateLimit.size > COMMAND_VALIDATION_LOOKUP_RATE_LIMIT_MAX_KEYS) {
|
|
1505
|
-
const oldestKey = commandValidationLookupRateLimit.keys().next().value;
|
|
1506
|
-
if (!oldestKey) break;
|
|
1507
|
-
commandValidationLookupRateLimit.delete(oldestKey);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
function reserveCommandValidationLookup(params) {
|
|
1511
|
-
const now = params.now ?? Date.now();
|
|
1512
|
-
sweepCommandValidationLookupRateLimit(now);
|
|
1513
|
-
const existing = commandValidationLookupRateLimit.get(params.key);
|
|
1514
|
-
if (!existing) {
|
|
1515
|
-
commandValidationLookupRateLimit.set(params.key, {
|
|
1516
|
-
accountId: params.accountId,
|
|
1517
|
-
tokens: COMMAND_VALIDATION_LOOKUP_BURST - 1,
|
|
1518
|
-
updatedAt: now,
|
|
1519
|
-
lastLimitedLogAt: 0
|
|
1520
|
-
});
|
|
1521
|
-
return { allowed: true };
|
|
1522
|
-
}
|
|
1523
|
-
const refill = Math.floor((now - existing.updatedAt) / COMMAND_VALIDATION_LOOKUP_REFILL_MS);
|
|
1524
|
-
if (refill > 0) {
|
|
1525
|
-
existing.tokens = Math.min(COMMAND_VALIDATION_LOOKUP_BURST, existing.tokens + refill);
|
|
1526
|
-
existing.updatedAt += refill * COMMAND_VALIDATION_LOOKUP_REFILL_MS;
|
|
1527
|
-
}
|
|
1528
|
-
if (existing.tokens <= 0) {
|
|
1529
|
-
const shouldLog = now - existing.lastLimitedLogAt >= COMMAND_VALIDATION_LOOKUP_LIMIT_LOG_MS;
|
|
1530
|
-
if (shouldLog) existing.lastLimitedLogAt = now;
|
|
1531
|
-
return {
|
|
1532
|
-
allowed: false,
|
|
1533
|
-
shouldLog
|
|
1534
|
-
};
|
|
1535
|
-
}
|
|
1536
|
-
existing.tokens -= 1;
|
|
1537
|
-
return { allowed: true };
|
|
1538
|
-
}
|
|
1539
|
-
async function fetchCurrentMattermostCommandUncached(params) {
|
|
1540
|
-
let commandLookupResult = null;
|
|
1541
|
-
let commandLookupError;
|
|
1542
|
-
let commandLookupFallbackDetail;
|
|
1543
|
-
try {
|
|
1544
|
-
commandLookupResult = await withCommandLookupTimeout((signal) => getMattermostCommand(params.client, params.registered.id, { signal }));
|
|
1545
|
-
if (!isDeletedMattermostCommand(commandLookupResult)) return commandLookupResult;
|
|
1546
|
-
commandLookupFallbackDetail = `command lookup by id returned deleted command ${sanitizeMattermostLogValue(commandLookupResult.id)}`;
|
|
1547
|
-
} catch (err) {
|
|
1548
|
-
commandLookupError = err;
|
|
1549
|
-
}
|
|
1550
|
-
try {
|
|
1551
|
-
const currentCommands = await withCommandLookupTimeout((signal) => listMattermostCommands(params.client, params.registered.teamId, { signal }));
|
|
1552
|
-
if (commandLookupError) params.log?.(`mattermost: slash command lookup by id failed for /${sanitizeMattermostLogValue(params.registered.trigger)}; using team list fallback: ${sanitizeCommandLookupError(commandLookupError)}`);
|
|
1553
|
-
else if (commandLookupFallbackDetail) params.log?.(`mattermost: slash ${commandLookupFallbackDetail} for /${sanitizeMattermostLogValue(params.registered.trigger)}; using team list fallback`);
|
|
1554
|
-
return currentCommands.find((cmd) => cmd.id === params.registered.id) ?? commandLookupResult;
|
|
1555
|
-
} catch (err) {
|
|
1556
|
-
const primaryDetail = commandLookupError ? `; command lookup: ${sanitizeCommandLookupError(commandLookupError)}` : commandLookupFallbackDetail ? `; command lookup: ${commandLookupFallbackDetail}` : "";
|
|
1557
|
-
params.log?.(`mattermost: slash command registration check failed for /${sanitizeMattermostLogValue(params.registered.trigger)}: ${sanitizeCommandLookupError(err)}${primaryDetail}`);
|
|
1558
|
-
return null;
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
async function fetchCurrentMattermostCommand(params) {
|
|
1562
|
-
const key = commandLookupKey(params.client, params.registered, params.accountId);
|
|
1563
|
-
const existing = commandLookupInflight.get(key);
|
|
1564
|
-
if (existing) return await existing.promise;
|
|
1565
|
-
const lookup = fetchCurrentMattermostCommandUncached(params).finally(() => {
|
|
1566
|
-
commandLookupInflight.delete(key);
|
|
1567
|
-
});
|
|
1568
|
-
commandLookupInflight.set(key, {
|
|
1569
|
-
accountId: params.accountId,
|
|
1570
|
-
promise: lookup
|
|
1571
|
-
});
|
|
1572
|
-
return await lookup;
|
|
1573
|
-
}
|
|
1574
|
-
async function validateMattermostSlashCommandToken(params) {
|
|
1575
|
-
const lookupKey = commandLookupKey(params.client, params.registeredCommand, params.accountId);
|
|
1576
|
-
if (hasCachedCommandValidationFailure(lookupKey)) return false;
|
|
1577
|
-
if (!commandLookupInflight.has(lookupKey)) {
|
|
1578
|
-
const reservation = reserveCommandValidationLookup({
|
|
1579
|
-
key: lookupKey,
|
|
1580
|
-
accountId: params.accountId
|
|
1581
|
-
});
|
|
1582
|
-
if (!reservation.allowed) {
|
|
1583
|
-
if (reservation.shouldLog) params.log?.(`mattermost: slash command validation lookup rate-limited for /${sanitizeMattermostLogValue(params.registeredCommand.trigger)}`);
|
|
1584
|
-
return false;
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
const current = await fetchCurrentMattermostCommand({
|
|
1588
|
-
accountId: params.accountId,
|
|
1589
|
-
client: params.client,
|
|
1590
|
-
registered: params.registeredCommand,
|
|
1591
|
-
log: params.log
|
|
1592
|
-
});
|
|
1593
|
-
if (!current || isDeletedMattermostCommand(current)) {
|
|
1594
|
-
cacheCommandValidationFailure(lookupKey, params.accountId);
|
|
1595
|
-
return false;
|
|
1596
|
-
}
|
|
1597
|
-
if (current.id !== params.registeredCommand.id || current.team_id !== params.registeredCommand.teamId || current.trigger !== params.registeredCommand.trigger || current.method !== "P" || current.url !== params.registeredCommand.url) {
|
|
1598
|
-
cacheCommandValidationFailure(lookupKey, params.accountId);
|
|
1599
|
-
return false;
|
|
1600
|
-
}
|
|
1601
|
-
if (!current.token || !safeEqualSecret(params.payload.token, current.token)) {
|
|
1602
|
-
cacheCommandValidationFailure(lookupKey, params.accountId);
|
|
1603
|
-
return false;
|
|
1604
|
-
}
|
|
1605
|
-
commandValidationFailureCache.delete(lookupKey);
|
|
1606
|
-
return true;
|
|
1607
|
-
}
|
|
1608
|
-
async function authorizeSlashInvocation(params) {
|
|
1609
|
-
const { account, cfg, client, commandText, channelId, senderId, senderName, log } = params;
|
|
1610
|
-
const core = getMattermostRuntime();
|
|
1611
|
-
let channelInfo = null;
|
|
1612
|
-
try {
|
|
1613
|
-
channelInfo = await fetchMattermostChannel(client, channelId);
|
|
1614
|
-
} catch (err) {
|
|
1615
|
-
log?.(`mattermost: slash channel lookup failed for ${sanitizeMattermostLogValue(channelId)}: ${sanitizeCommandLookupError(err)}`);
|
|
1616
|
-
}
|
|
1617
|
-
if (!channelInfo) return {
|
|
1618
|
-
ok: false,
|
|
1619
|
-
denyResponse: {
|
|
1620
|
-
response_type: "ephemeral",
|
|
1621
|
-
text: "Temporary error: unable to determine channel type. Please try again."
|
|
1622
|
-
},
|
|
1623
|
-
commandAuthorized: false,
|
|
1624
|
-
channelInfo: null,
|
|
1625
|
-
kind: "channel",
|
|
1626
|
-
chatType: "channel",
|
|
1627
|
-
channelName: "",
|
|
1628
|
-
channelDisplay: "",
|
|
1629
|
-
roomLabel: `#${channelId}`
|
|
1630
|
-
};
|
|
1631
|
-
const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
|
|
1632
|
-
cfg,
|
|
1633
|
-
surface: "mattermost"
|
|
1634
|
-
});
|
|
1635
|
-
const hasControlCommand = core.channel.text.hasControlCommand(commandText, cfg);
|
|
1636
|
-
const storeAllowFrom = normalizeMattermostAllowList(await core.channel.pairing.readAllowFromStore({
|
|
1637
|
-
channel: "mattermost",
|
|
1638
|
-
accountId: account.accountId
|
|
1639
|
-
}).catch(() => []));
|
|
1640
|
-
const decision = await authorizeMattermostCommandInvocation({
|
|
1641
|
-
account,
|
|
1642
|
-
cfg,
|
|
1643
|
-
senderId,
|
|
1644
|
-
senderName,
|
|
1645
|
-
channelId,
|
|
1646
|
-
channelInfo,
|
|
1647
|
-
storeAllowFrom,
|
|
1648
|
-
allowTextCommands,
|
|
1649
|
-
hasControlCommand
|
|
1650
|
-
});
|
|
1651
|
-
if (!decision.ok) {
|
|
1652
|
-
if (decision.denyReason === "dm-pairing") {
|
|
1653
|
-
const { code } = await core.channel.pairing.upsertPairingRequest({
|
|
1654
|
-
channel: "mattermost",
|
|
1655
|
-
accountId: account.accountId,
|
|
1656
|
-
id: senderId,
|
|
1657
|
-
meta: { name: senderName }
|
|
1658
|
-
});
|
|
1659
|
-
return {
|
|
1660
|
-
...decision,
|
|
1661
|
-
denyResponse: {
|
|
1662
|
-
response_type: "ephemeral",
|
|
1663
|
-
text: core.channel.pairing.buildPairingReply({
|
|
1664
|
-
channel: "mattermost",
|
|
1665
|
-
idLine: `Your Mattermost user id: ${senderId}`,
|
|
1666
|
-
code
|
|
1667
|
-
})
|
|
1668
|
-
}
|
|
1669
|
-
};
|
|
1670
|
-
}
|
|
1671
|
-
const denyText = decision.denyReason === "unknown-channel" ? "Temporary error: unable to determine channel type. Please try again." : decision.denyReason === "dm-disabled" ? "This bot is not accepting direct messages." : decision.denyReason === "channels-disabled" ? "Slash commands are disabled in channels." : decision.denyReason === "channel-no-allowlist" ? "Slash commands are not configured for this channel (no allowlist)." : "Unauthorized.";
|
|
1672
|
-
return {
|
|
1673
|
-
...decision,
|
|
1674
|
-
denyResponse: {
|
|
1675
|
-
response_type: "ephemeral",
|
|
1676
|
-
text: denyText
|
|
1677
|
-
}
|
|
1678
|
-
};
|
|
1679
|
-
}
|
|
1680
|
-
return {
|
|
1681
|
-
...decision,
|
|
1682
|
-
denyResponse: void 0
|
|
1683
|
-
};
|
|
1684
|
-
}
|
|
1685
|
-
/**
|
|
1686
|
-
* Create the HTTP request handler for Mattermost slash command callbacks.
|
|
1687
|
-
*
|
|
1688
|
-
* This handler is registered as a plugin HTTP route and receives POSTs
|
|
1689
|
-
* from the Mattermost server when a user invokes a registered slash command.
|
|
1690
|
-
*/
|
|
1691
|
-
function createSlashCommandHttpHandler(params) {
|
|
1692
|
-
const { account, cfg, runtime, registeredCommands, triggerMap, log, bodyTimeoutMs } = params;
|
|
1693
|
-
return async (req, res) => {
|
|
1694
|
-
if (req.method !== "POST") {
|
|
1695
|
-
res.statusCode = 405;
|
|
1696
|
-
res.setHeader("Allow", "POST");
|
|
1697
|
-
res.end("Method Not Allowed");
|
|
1698
|
-
return;
|
|
1699
|
-
}
|
|
1700
|
-
let body;
|
|
1701
|
-
try {
|
|
1702
|
-
body = await readBody(req, MAX_BODY_BYTES, bodyTimeoutMs);
|
|
1703
|
-
} catch (error) {
|
|
1704
|
-
if (isRequestBodyLimitError(error, "REQUEST_BODY_TIMEOUT")) {
|
|
1705
|
-
res.statusCode = 408;
|
|
1706
|
-
res.end("Request body timeout");
|
|
1707
|
-
return;
|
|
1708
|
-
}
|
|
1709
|
-
res.statusCode = 413;
|
|
1710
|
-
res.end("Payload Too Large");
|
|
1711
|
-
return;
|
|
1712
|
-
}
|
|
1713
|
-
const contentType = req.headers["content-type"] ?? "";
|
|
1714
|
-
const payload = parseSlashCommandPayload(body, contentType);
|
|
1715
|
-
if (!payload) {
|
|
1716
|
-
sendJsonResponse(res, 400, {
|
|
1717
|
-
response_type: "ephemeral",
|
|
1718
|
-
text: "Invalid slash command payload."
|
|
1719
|
-
});
|
|
1720
|
-
return;
|
|
1721
|
-
}
|
|
1722
|
-
const registeredCommand = findRegisteredCommandForPayload({
|
|
1723
|
-
registeredCommands,
|
|
1724
|
-
payload
|
|
1725
|
-
});
|
|
1726
|
-
if (registeredCommands.length === 0 || !registeredCommand || !safeEqualSecret(payload.token, registeredCommand.token)) {
|
|
1727
|
-
sendJsonResponse(res, 401, {
|
|
1728
|
-
response_type: "ephemeral",
|
|
1729
|
-
text: "Unauthorized: invalid command token."
|
|
1730
|
-
});
|
|
1731
|
-
return;
|
|
1732
|
-
}
|
|
1733
|
-
const client = createMattermostClient({
|
|
1734
|
-
baseUrl: account.baseUrl ?? "",
|
|
1735
|
-
botToken: account.botToken ?? "",
|
|
1736
|
-
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account.config)
|
|
1737
|
-
});
|
|
1738
|
-
if (!await validateMattermostSlashCommandToken({
|
|
1739
|
-
accountId: account.accountId,
|
|
1740
|
-
client,
|
|
1741
|
-
registeredCommand,
|
|
1742
|
-
payload,
|
|
1743
|
-
log
|
|
1744
|
-
})) {
|
|
1745
|
-
sendJsonResponse(res, 401, {
|
|
1746
|
-
response_type: "ephemeral",
|
|
1747
|
-
text: "Unauthorized: invalid command token."
|
|
1748
|
-
});
|
|
1749
|
-
return;
|
|
1750
|
-
}
|
|
1751
|
-
const trigger = normalizeSlashCommandTrigger(payload.command);
|
|
1752
|
-
const commandText = resolveCommandText(trigger, payload.text, triggerMap);
|
|
1753
|
-
const channelId = payload.channel_id;
|
|
1754
|
-
const senderId = payload.user_id;
|
|
1755
|
-
const senderName = payload.user_name ?? senderId;
|
|
1756
|
-
const auth = await authorizeSlashInvocation({
|
|
1757
|
-
account,
|
|
1758
|
-
cfg,
|
|
1759
|
-
client,
|
|
1760
|
-
commandText,
|
|
1761
|
-
channelId,
|
|
1762
|
-
senderId,
|
|
1763
|
-
senderName,
|
|
1764
|
-
log
|
|
1765
|
-
});
|
|
1766
|
-
if (!auth.ok) {
|
|
1767
|
-
sendJsonResponse(res, 200, auth.denyResponse ?? {
|
|
1768
|
-
response_type: "ephemeral",
|
|
1769
|
-
text: "Unauthorized."
|
|
1770
|
-
});
|
|
1771
|
-
return;
|
|
1772
|
-
}
|
|
1773
|
-
log?.(`mattermost: slash command /${sanitizeMattermostLogValue(trigger)} from ${sanitizeMattermostLogValue(senderName)} in ${sanitizeMattermostLogValue(channelId)}`);
|
|
1774
|
-
sendJsonResponse(res, 200, {
|
|
1775
|
-
response_type: "ephemeral",
|
|
1776
|
-
text: "Processing..."
|
|
1777
|
-
});
|
|
1778
|
-
try {
|
|
1779
|
-
await handleSlashCommandAsync({
|
|
1780
|
-
account,
|
|
1781
|
-
cfg,
|
|
1782
|
-
runtime,
|
|
1783
|
-
client,
|
|
1784
|
-
commandText,
|
|
1785
|
-
channelId,
|
|
1786
|
-
senderId,
|
|
1787
|
-
senderName,
|
|
1788
|
-
teamId: payload.team_id,
|
|
1789
|
-
triggerId: payload.trigger_id,
|
|
1790
|
-
kind: auth.kind,
|
|
1791
|
-
chatType: auth.chatType,
|
|
1792
|
-
channelName: auth.channelName,
|
|
1793
|
-
channelDisplay: auth.channelDisplay,
|
|
1794
|
-
roomLabel: auth.roomLabel,
|
|
1795
|
-
commandAuthorized: auth.commandAuthorized,
|
|
1796
|
-
log
|
|
1797
|
-
});
|
|
1798
|
-
} catch (err) {
|
|
1799
|
-
log?.(`mattermost: slash command handler error: ${sanitizeCommandLookupError(err)}`);
|
|
1800
|
-
try {
|
|
1801
|
-
await sendMessageMattermost(`channel:${channelId}`, "Sorry, something went wrong processing that command.", {
|
|
1802
|
-
cfg,
|
|
1803
|
-
accountId: account.accountId
|
|
1804
|
-
});
|
|
1805
|
-
} catch {}
|
|
1806
|
-
}
|
|
1807
|
-
};
|
|
1808
|
-
}
|
|
1809
|
-
async function handleSlashCommandAsync(params) {
|
|
1810
|
-
const { account, cfg, runtime, client, commandText, channelId, senderId, senderName, teamId, kind, chatType, channelName: _channelName, channelDisplay, roomLabel, commandAuthorized, triggerId, log } = params;
|
|
1811
|
-
const core = getMattermostRuntime();
|
|
1812
|
-
const route = core.channel.routing.resolveAgentRoute({
|
|
1813
|
-
cfg,
|
|
1814
|
-
channel: "mattermost",
|
|
1815
|
-
accountId: account.accountId,
|
|
1816
|
-
teamId,
|
|
1817
|
-
peer: {
|
|
1818
|
-
kind,
|
|
1819
|
-
id: kind === "direct" ? senderId : channelId
|
|
1820
|
-
}
|
|
1821
|
-
});
|
|
1822
|
-
const fromLabel = kind === "direct" ? `Mattermost DM from ${senderName}` : `Mattermost message in ${roomLabel} from ${senderName}`;
|
|
1823
|
-
const to = kind === "direct" ? `user:${senderId}` : `channel:${channelId}`;
|
|
1824
|
-
const pickerEntry = resolveMattermostModelPickerEntry(commandText);
|
|
1825
|
-
if (pickerEntry) {
|
|
1826
|
-
const data = await buildModelsProviderData(cfg, route.agentId);
|
|
1827
|
-
if (data.providers.length === 0) {
|
|
1828
|
-
await sendMessageMattermost(to, "No models available.", {
|
|
1829
|
-
cfg,
|
|
1830
|
-
accountId: account.accountId
|
|
1831
|
-
});
|
|
1832
|
-
return;
|
|
1833
|
-
}
|
|
1834
|
-
const currentModel = resolveMattermostModelPickerCurrentModel({
|
|
1835
|
-
cfg,
|
|
1836
|
-
route,
|
|
1837
|
-
data
|
|
1838
|
-
});
|
|
1839
|
-
const view = pickerEntry.kind === "summary" ? renderMattermostModelSummaryView({
|
|
1840
|
-
ownerUserId: senderId,
|
|
1841
|
-
currentModel
|
|
1842
|
-
}) : pickerEntry.kind === "providers" ? renderMattermostProviderPickerView({
|
|
1843
|
-
ownerUserId: senderId,
|
|
1844
|
-
data,
|
|
1845
|
-
currentModel
|
|
1846
|
-
}) : renderMattermostModelsPickerView({
|
|
1847
|
-
ownerUserId: senderId,
|
|
1848
|
-
data,
|
|
1849
|
-
provider: pickerEntry.provider,
|
|
1850
|
-
page: 1,
|
|
1851
|
-
currentModel
|
|
1852
|
-
});
|
|
1853
|
-
await sendMessageMattermost(to, view.text, {
|
|
1854
|
-
cfg,
|
|
1855
|
-
accountId: account.accountId,
|
|
1856
|
-
buttons: view.buttons
|
|
1857
|
-
});
|
|
1858
|
-
runtime.log?.(`delivered model picker to ${to}`);
|
|
1859
|
-
return;
|
|
1860
|
-
}
|
|
1861
|
-
const ctxPayload = core.channel.reply.finalizeInboundContext({
|
|
1862
|
-
Body: commandText,
|
|
1863
|
-
BodyForAgent: commandText,
|
|
1864
|
-
RawBody: commandText,
|
|
1865
|
-
CommandBody: commandText,
|
|
1866
|
-
From: kind === "direct" ? `mattermost:${senderId}` : kind === "group" ? `mattermost:group:${channelId}` : `mattermost:channel:${channelId}`,
|
|
1867
|
-
To: to,
|
|
1868
|
-
SessionKey: route.sessionKey,
|
|
1869
|
-
AccountId: route.accountId,
|
|
1870
|
-
ChatType: chatType,
|
|
1871
|
-
ConversationLabel: fromLabel,
|
|
1872
|
-
GroupSubject: kind !== "direct" ? channelDisplay || roomLabel : void 0,
|
|
1873
|
-
SenderName: senderName,
|
|
1874
|
-
SenderId: senderId,
|
|
1875
|
-
Provider: "mattermost",
|
|
1876
|
-
Surface: "mattermost",
|
|
1877
|
-
MessageSid: triggerId ?? `slash-${Date.now()}`,
|
|
1878
|
-
Timestamp: Date.now(),
|
|
1879
|
-
WasMentioned: true,
|
|
1880
|
-
CommandAuthorized: commandAuthorized,
|
|
1881
|
-
CommandSource: "native",
|
|
1882
|
-
OriginatingChannel: "mattermost",
|
|
1883
|
-
OriginatingTo: to
|
|
1884
|
-
});
|
|
1885
|
-
const textLimit = core.channel.text.resolveTextChunkLimit(cfg, "mattermost", account.accountId, { fallbackLimit: account.textChunkLimit ?? 4e3 });
|
|
1886
|
-
const tableMode = core.channel.text.resolveMarkdownTableMode({
|
|
1887
|
-
cfg,
|
|
1888
|
-
channel: "mattermost",
|
|
1889
|
-
accountId: account.accountId
|
|
1890
|
-
});
|
|
1891
|
-
const { onModelSelected, typingCallbacks, ...replyPipeline } = createChannelReplyPipeline({
|
|
1892
|
-
cfg,
|
|
1893
|
-
agentId: route.agentId,
|
|
1894
|
-
channel: "mattermost",
|
|
1895
|
-
accountId: account.accountId,
|
|
1896
|
-
typing: {
|
|
1897
|
-
start: () => sendMattermostTyping(client, { channelId }),
|
|
1898
|
-
onStartError: (err) => {
|
|
1899
|
-
logTypingFailure({
|
|
1900
|
-
log: (message) => log?.(message),
|
|
1901
|
-
channel: "mattermost",
|
|
1902
|
-
target: channelId,
|
|
1903
|
-
error: err
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
});
|
|
1908
|
-
const humanDelay = core.channel.reply.resolveHumanDelayConfig(cfg, route.agentId);
|
|
1909
|
-
const { dispatcher, replyOptions, markDispatchIdle } = core.channel.reply.createReplyDispatcherWithTyping({
|
|
1910
|
-
...replyPipeline,
|
|
1911
|
-
humanDelay,
|
|
1912
|
-
deliver: async (payload) => {
|
|
1913
|
-
await deliverMattermostReplyPayload({
|
|
1914
|
-
core,
|
|
1915
|
-
cfg,
|
|
1916
|
-
payload,
|
|
1917
|
-
to,
|
|
1918
|
-
accountId: account.accountId,
|
|
1919
|
-
agentId: route.agentId,
|
|
1920
|
-
textLimit,
|
|
1921
|
-
tableMode,
|
|
1922
|
-
sendMessage: sendMessageMattermost
|
|
1923
|
-
});
|
|
1924
|
-
runtime.log?.(`delivered slash reply to ${to}`);
|
|
1925
|
-
},
|
|
1926
|
-
onError: (err, info) => {
|
|
1927
|
-
runtime.error?.(`mattermost slash ${info.kind} reply failed: ${sanitizeCommandLookupError(err)}`);
|
|
1928
|
-
},
|
|
1929
|
-
onReplyStart: typingCallbacks?.onReplyStart
|
|
1930
|
-
});
|
|
1931
|
-
await core.channel.reply.withReplyDispatcher({
|
|
1932
|
-
dispatcher,
|
|
1933
|
-
onSettled: () => {
|
|
1934
|
-
markDispatchIdle();
|
|
1935
|
-
},
|
|
1936
|
-
run: () => core.channel.reply.dispatchReplyFromConfig({
|
|
1937
|
-
ctx: ctxPayload,
|
|
1938
|
-
cfg,
|
|
1939
|
-
dispatcher,
|
|
1940
|
-
replyOptions: {
|
|
1941
|
-
...replyOptions,
|
|
1942
|
-
disableBlockStreaming: typeof account.blockStreaming === "boolean" ? !account.blockStreaming : void 0,
|
|
1943
|
-
onModelSelected
|
|
1944
|
-
}
|
|
1945
|
-
})
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
//#endregion
|
|
1949
|
-
//#region extensions/mattermost/src/mattermost/slash-state.ts
|
|
1950
|
-
const MULTI_ACCOUNT_BODY_MAX_BYTES = 64 * 1024;
|
|
1951
|
-
const MULTI_ACCOUNT_BODY_TIMEOUT_MS = 5e3;
|
|
1952
|
-
/** Map from accountId → per-account slash command state. */
|
|
1953
|
-
const accountStates = /* @__PURE__ */ new Map();
|
|
1954
|
-
function resolveSlashHandlerForToken(token) {
|
|
1955
|
-
const matches = [];
|
|
1956
|
-
for (const [accountId, state] of accountStates) if (state.commandTokens.has(token) && state.handler) matches.push({
|
|
1957
|
-
accountId,
|
|
1958
|
-
handler: state.handler
|
|
1959
|
-
});
|
|
1960
|
-
if (matches.length === 0) return { kind: "none" };
|
|
1961
|
-
if (matches.length === 1) return {
|
|
1962
|
-
kind: "single",
|
|
1963
|
-
source: "token",
|
|
1964
|
-
handler: matches[0].handler,
|
|
1965
|
-
accountIds: [matches[0].accountId]
|
|
1966
|
-
};
|
|
1967
|
-
return {
|
|
1968
|
-
kind: "ambiguous",
|
|
1969
|
-
source: "token",
|
|
1970
|
-
accountIds: matches.map((entry) => entry.accountId)
|
|
1971
|
-
};
|
|
1972
|
-
}
|
|
1973
|
-
function resolveSlashHandlerForCommand(params) {
|
|
1974
|
-
const trigger = normalizeSlashCommandTrigger(params.command);
|
|
1975
|
-
if (!trigger) return { kind: "none" };
|
|
1976
|
-
const matches = [];
|
|
1977
|
-
for (const [accountId, state] of accountStates) if (state.handler && state.registeredCommands.some((cmd) => cmd.teamId === params.teamId && cmd.trigger === trigger)) matches.push({
|
|
1978
|
-
accountId,
|
|
1979
|
-
handler: state.handler
|
|
1980
|
-
});
|
|
1981
|
-
if (matches.length === 0) return { kind: "none" };
|
|
1982
|
-
if (matches.length === 1) return {
|
|
1983
|
-
kind: "single",
|
|
1984
|
-
source: "command",
|
|
1985
|
-
handler: matches[0].handler,
|
|
1986
|
-
accountIds: [matches[0].accountId]
|
|
1987
|
-
};
|
|
1988
|
-
return {
|
|
1989
|
-
kind: "ambiguous",
|
|
1990
|
-
source: "command",
|
|
1991
|
-
accountIds: matches.map((entry) => entry.accountId)
|
|
1992
|
-
};
|
|
1993
|
-
}
|
|
1994
|
-
/**
|
|
1995
|
-
* Get the slash command state for a specific account, or null if not activated.
|
|
1996
|
-
*/
|
|
1997
|
-
function getSlashCommandState(accountId) {
|
|
1998
|
-
return accountStates.get(accountId) ?? null;
|
|
1999
|
-
}
|
|
2000
|
-
/**
|
|
2001
|
-
* Activate slash commands for a specific account.
|
|
2002
|
-
* Called from the monitor after bot connects.
|
|
2003
|
-
*/
|
|
2004
|
-
function activateSlashCommands(params) {
|
|
2005
|
-
const { account, commandTokens, registeredCommands, triggerMap, api, log } = params;
|
|
2006
|
-
const accountId = account.accountId;
|
|
2007
|
-
const tokenSet = new Set(commandTokens);
|
|
2008
|
-
const handler = createSlashCommandHttpHandler({
|
|
2009
|
-
account,
|
|
2010
|
-
cfg: api.cfg,
|
|
2011
|
-
runtime: api.runtime,
|
|
2012
|
-
registeredCommands,
|
|
2013
|
-
triggerMap,
|
|
2014
|
-
log
|
|
2015
|
-
});
|
|
2016
|
-
accountStates.set(accountId, {
|
|
2017
|
-
commandTokens: tokenSet,
|
|
2018
|
-
registeredCommands,
|
|
2019
|
-
handler,
|
|
2020
|
-
account,
|
|
2021
|
-
triggerMap: triggerMap ?? /* @__PURE__ */ new Map()
|
|
2022
|
-
});
|
|
2023
|
-
log?.(`mattermost: slash commands activated for account ${accountId} (${registeredCommands.length} commands)`);
|
|
2024
|
-
}
|
|
2025
|
-
/**
|
|
2026
|
-
* Deactivate slash commands for a specific account (on shutdown/disconnect).
|
|
2027
|
-
*/
|
|
2028
|
-
function deactivateSlashCommands(accountId) {
|
|
2029
|
-
if (accountId) {
|
|
2030
|
-
const state = accountStates.get(accountId);
|
|
2031
|
-
if (state) {
|
|
2032
|
-
state.commandTokens.clear();
|
|
2033
|
-
state.registeredCommands = [];
|
|
2034
|
-
state.handler = null;
|
|
2035
|
-
clearMattermostSlashCommandValidationCacheForAccount(accountId);
|
|
2036
|
-
accountStates.delete(accountId);
|
|
2037
|
-
}
|
|
2038
|
-
} else {
|
|
2039
|
-
for (const [stateAccountId, state] of accountStates) {
|
|
2040
|
-
state.commandTokens.clear();
|
|
2041
|
-
state.registeredCommands = [];
|
|
2042
|
-
state.handler = null;
|
|
2043
|
-
clearMattermostSlashCommandValidationCacheForAccount(stateAccountId);
|
|
2044
|
-
}
|
|
2045
|
-
accountStates.clear();
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
/**
|
|
2049
|
-
* Register the HTTP route for slash command callbacks.
|
|
2050
|
-
* Called during plugin registration.
|
|
2051
|
-
*
|
|
2052
|
-
* The single HTTP route dispatches to the correct per-account handler by
|
|
2053
|
-
* matching the inbound token against each account's known tokens, falling back
|
|
2054
|
-
* to registered team/trigger ownership so upstream validation can accept a
|
|
2055
|
-
* rotated Mattermost token.
|
|
2056
|
-
*/
|
|
2057
|
-
function registerSlashCommandRoute(api) {
|
|
2058
|
-
const mmConfig = api.config.channels?.mattermost;
|
|
2059
|
-
const callbackPaths = /* @__PURE__ */ new Set();
|
|
2060
|
-
const addCallbackPaths = (raw) => {
|
|
2061
|
-
const resolved = resolveSlashCommandConfig(raw);
|
|
2062
|
-
callbackPaths.add(resolved.callbackPath);
|
|
2063
|
-
if (resolved.callbackUrl) try {
|
|
2064
|
-
const urlPath = new URL(resolved.callbackUrl).pathname;
|
|
2065
|
-
if (urlPath && urlPath !== resolved.callbackPath) callbackPaths.add(urlPath);
|
|
2066
|
-
} catch {}
|
|
2067
|
-
};
|
|
2068
|
-
const commandsRaw = mmConfig?.commands;
|
|
2069
|
-
addCallbackPaths(commandsRaw);
|
|
2070
|
-
const accountsRaw = mmConfig?.accounts ?? {};
|
|
2071
|
-
for (const accountId of Object.keys(accountsRaw)) {
|
|
2072
|
-
const accountCommandsRaw = accountsRaw[accountId]?.commands;
|
|
2073
|
-
addCallbackPaths(accountCommandsRaw);
|
|
2074
|
-
}
|
|
2075
|
-
const routeHandler = async (req, res) => {
|
|
2076
|
-
if (accountStates.size === 0) {
|
|
2077
|
-
res.statusCode = 503;
|
|
2078
|
-
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
2079
|
-
res.end(JSON.stringify({
|
|
2080
|
-
response_type: "ephemeral",
|
|
2081
|
-
text: "Slash commands are not yet initialized. Please try again in a moment."
|
|
2082
|
-
}));
|
|
2083
|
-
return;
|
|
2084
|
-
}
|
|
2085
|
-
if (accountStates.size === 1) {
|
|
2086
|
-
const [, state] = [...accountStates.entries()][0];
|
|
2087
|
-
if (!state.handler) {
|
|
2088
|
-
res.statusCode = 503;
|
|
2089
|
-
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
2090
|
-
res.end(JSON.stringify({
|
|
2091
|
-
response_type: "ephemeral",
|
|
2092
|
-
text: "Slash commands are not yet initialized. Please try again in a moment."
|
|
2093
|
-
}));
|
|
2094
|
-
return;
|
|
2095
|
-
}
|
|
2096
|
-
await state.handler(req, res);
|
|
2097
|
-
return;
|
|
2098
|
-
}
|
|
2099
|
-
let bodyStr;
|
|
2100
|
-
try {
|
|
2101
|
-
bodyStr = await readRequestBodyWithLimit(req, {
|
|
2102
|
-
maxBytes: MULTI_ACCOUNT_BODY_MAX_BYTES,
|
|
2103
|
-
timeoutMs: MULTI_ACCOUNT_BODY_TIMEOUT_MS
|
|
2104
|
-
});
|
|
2105
|
-
} catch (error) {
|
|
2106
|
-
if (isRequestBodyLimitError(error, "REQUEST_BODY_TIMEOUT")) {
|
|
2107
|
-
res.statusCode = 408;
|
|
2108
|
-
res.end("Request body timeout");
|
|
2109
|
-
return;
|
|
2110
|
-
}
|
|
2111
|
-
res.statusCode = 413;
|
|
2112
|
-
res.end("Payload Too Large");
|
|
2113
|
-
return;
|
|
2114
|
-
}
|
|
2115
|
-
let token = null;
|
|
2116
|
-
const ct = req.headers["content-type"] ?? "";
|
|
2117
|
-
try {
|
|
2118
|
-
if (ct.includes("application/json")) token = JSON.parse(bodyStr).token ?? null;
|
|
2119
|
-
else token = new URLSearchParams(bodyStr).get("token");
|
|
2120
|
-
} catch {}
|
|
2121
|
-
let match = token ? resolveSlashHandlerForToken(token) : { kind: "none" };
|
|
2122
|
-
if (match.kind === "none") {
|
|
2123
|
-
const payload = parseSlashCommandPayload(bodyStr, ct);
|
|
2124
|
-
if (payload) match = resolveSlashHandlerForCommand({
|
|
2125
|
-
teamId: payload.team_id,
|
|
2126
|
-
command: payload.command
|
|
2127
|
-
});
|
|
2128
|
-
}
|
|
2129
|
-
if (match.kind === "none") {
|
|
2130
|
-
res.statusCode = 401;
|
|
2131
|
-
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
2132
|
-
res.end(JSON.stringify({
|
|
2133
|
-
response_type: "ephemeral",
|
|
2134
|
-
text: "Unauthorized: invalid command token."
|
|
2135
|
-
}));
|
|
2136
|
-
return;
|
|
2137
|
-
}
|
|
2138
|
-
if (match.kind === "ambiguous") {
|
|
2139
|
-
api.logger.warn?.(`mattermost: slash callback matched multiple accounts via ${match.source} (${match.accountIds.join(", ")})`);
|
|
2140
|
-
const conflictText = match.source === "token" ? "Conflict: command token is not unique across accounts." : "Conflict: slash command is not unique across accounts.";
|
|
2141
|
-
res.statusCode = 409;
|
|
2142
|
-
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
2143
|
-
res.end(JSON.stringify({
|
|
2144
|
-
response_type: "ephemeral",
|
|
2145
|
-
text: conflictText
|
|
2146
|
-
}));
|
|
2147
|
-
return;
|
|
2148
|
-
}
|
|
2149
|
-
const matchedHandler = match.handler;
|
|
2150
|
-
const syntheticReq = new Readable({ read() {
|
|
2151
|
-
this.push(Buffer.from(bodyStr, "utf8"));
|
|
2152
|
-
this.push(null);
|
|
2153
|
-
} });
|
|
2154
|
-
syntheticReq.method = req.method;
|
|
2155
|
-
syntheticReq.url = req.url;
|
|
2156
|
-
syntheticReq.headers = req.headers;
|
|
2157
|
-
await matchedHandler(syntheticReq, res);
|
|
2158
|
-
};
|
|
2159
|
-
for (const callbackPath of callbackPaths) api.registerHttpRoute({
|
|
2160
|
-
path: callbackPath,
|
|
2161
|
-
auth: "plugin",
|
|
2162
|
-
handler: routeHandler
|
|
2163
|
-
});
|
|
2164
|
-
}
|
|
2165
|
-
//#endregion
|
|
2166
|
-
export { resolveCallbackUrl as C, registerSlashCommands as S, renderMattermostProviderPickerView as _, sendMessageMattermost as a, cleanupSlashCommands as b, computeInteractionCallbackUrl as c, setInteractionCallbackUrl as d, setInteractionSecret as f, renderMattermostModelsPickerView as g, parseMattermostModelPickerContext as h, registerSlashCommandRoute as i, createMattermostInteractionHandler as l, buildMattermostAllowedModelRefs as m, deactivateSlashCommands as n, resolveMattermostOpaqueTarget as o, deliverMattermostReplyPayload as p, getSlashCommandState as r, buildButtonProps as s, activateSlashCommands as t, resolveInteractionCallbackPath as u, resolveMattermostModelPickerCurrentModel as v, resolveSlashCommandConfig as w, isSlashCommandsEnabled as x, DEFAULT_COMMAND_SPECS as y };
|