squidclaw 3.3.2 → 3.3.6
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/build-info.json +3 -3
- package/dist/canvas-host/a2ui/a2ui.bundle.js +1 -1
- package/dist/{command-registry-DU59Zys9.js → command-registry-D-1yrjO5.js} +4 -4
- package/dist/{completion-cli-B58zTxLB.js → completion-cli-DDG6rQHB.js} +2 -2
- package/dist/{completion-cli-BLY0f3DS.js → completion-cli-YquOT8ke.js} +1 -1
- package/dist/control-ui/assets/{index-BqxuPQOl.js → index-Bb5MB8jH.js} +358 -358
- package/dist/control-ui/assets/index-Bb5MB8jH.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/daemon-cli.js +6 -6
- package/dist/{doctor-completion-DRCOGhwS.js → doctor-completion-B63lREru.js} +1 -1
- package/dist/{doctor-completion-kjDYgxZk.js → doctor-completion-CoKUBmAB.js} +1 -1
- package/dist/entry.js +2 -2
- package/dist/{gateway-cli-DvWNtJxy.js → gateway-cli-BP1USKKw.js} +1 -1
- package/dist/{gateway-cli-lvhI_G2p.js → gateway-cli-CIhENRqY.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{onboard-BP7rTtCO.js → onboard-BYwFqDe-.js} +1 -1
- package/dist/{onboard-BwVAkxW0.js → onboard-gmbrf0mc.js} +1 -1
- package/dist/{onboarding-LbGi6oDz.js → onboarding-C7eyvBep.js} +1 -1
- package/dist/{onboarding-D_ImwR9D.js → onboarding-OrcdwciM.js} +1 -1
- package/dist/{onboarding.finalize-ClTc_ghC.js → onboarding.finalize-Bf3EExjS.js} +56 -13
- package/dist/{onboarding.finalize-CWcaxeIO.js → onboarding.finalize-DZBXbwYe.js} +55 -12
- package/dist/plugin-sdk/accounts-B9RVtSwn.js +35 -0
- package/dist/plugin-sdk/{accounts-BhCAa-05.js → accounts-BLOLIF6Q.js} +2 -2
- package/dist/plugin-sdk/{accounts-DKXGC2Vu.js → accounts-BvzvDHNx.js} +3 -3
- package/dist/plugin-sdk/{accounts-BChIl5as.js → accounts-ByCKM_Y3.js} +2 -2
- package/dist/plugin-sdk/accounts-Cnpikxly.js +288 -0
- package/dist/plugin-sdk/accounts-ZkT4ovw_.js +46 -0
- package/dist/plugin-sdk/{active-listener-TTbK9PGk.js → active-listener-CKD9GljM.js} +2 -2
- package/dist/plugin-sdk/active-listener-Ccj2fSCa.js +50 -0
- package/dist/plugin-sdk/{api-key-rotation-BqhYVBBK.js → api-key-rotation--boE2y8I.js} +2 -2
- package/dist/plugin-sdk/api-key-rotation-0Xm0okk5.js +181 -0
- package/dist/plugin-sdk/{audio-preflight-DAf0ptAM.js → audio-preflight-B_pcDw8d.js} +26 -26
- package/dist/plugin-sdk/audio-preflight-DQZ2WSG4.js +69 -0
- package/dist/plugin-sdk/audio-transcription-runner-C4aP5aYG.js +2176 -0
- package/dist/plugin-sdk/{audio-transcription-runner-CBASOlbc.js → audio-transcription-runner-u6tijzUS.js} +11 -11
- package/dist/plugin-sdk/{audit-membership-runtime-Xl20kCBe.js → audit-membership-runtime-DHQDvH4u.js} +2 -2
- package/dist/plugin-sdk/audit-membership-runtime-DPTwvWpd.js +58 -0
- package/dist/plugin-sdk/{channel-activity-95JVLzNY.js → channel-activity-BVUdxSNs.js} +3 -3
- package/dist/plugin-sdk/channel-activity-DAX5uVAX.js +94 -0
- package/dist/plugin-sdk/{channel-web-DCkC6Ydu.js → channel-web-BX2s-JXF.js} +18 -18
- package/dist/plugin-sdk/channel-web-CgS5ek7s.js +2256 -0
- package/dist/plugin-sdk/{chrome-BlXpNOQu.js → chrome-6EkqVcyR.js} +6 -6
- package/dist/plugin-sdk/chrome-BHzykCQ9.js +2415 -0
- package/dist/plugin-sdk/{commands-registry-C9y_w3eW.js → commands-registry-CDHo6SSs.js} +4 -4
- package/dist/plugin-sdk/commands-registry-CRVdcP1W.js +1125 -0
- package/dist/plugin-sdk/{common-CEwMUbms.js → common-Emz6EPQM.js} +2 -2
- package/dist/plugin-sdk/compat.js +50 -50
- package/dist/plugin-sdk/{config-sMifxgre.js → config-CMjn_DSB.js} +7 -7
- package/dist/plugin-sdk/config-DMdJidZc.js +17912 -0
- package/dist/plugin-sdk/{deliver-2zt3NeFA.js → deliver-Cz6GluMN.js} +10 -10
- package/dist/plugin-sdk/deliver-DMb_cOF7.js +1694 -0
- package/dist/plugin-sdk/deliver-runtime-CjCJkoFM.js +32 -0
- package/dist/plugin-sdk/deliver-runtime-D0qfBG05.js +32 -0
- package/dist/plugin-sdk/deps-send-discord.runtime-9igTHMx2.js +23 -0
- package/dist/plugin-sdk/deps-send-discord.runtime-C4AEwjGl.js +23 -0
- package/dist/plugin-sdk/deps-send-imessage.runtime-BFpdfthT.js +22 -0
- package/dist/plugin-sdk/deps-send-imessage.runtime-DCdEe-_E.js +22 -0
- package/dist/plugin-sdk/deps-send-signal.runtime-BNO6SPmR.js +21 -0
- package/dist/plugin-sdk/deps-send-signal.runtime-BqB_Ilh-.js +21 -0
- package/dist/plugin-sdk/deps-send-slack.runtime-BChVBURL.js +19 -0
- package/dist/plugin-sdk/deps-send-slack.runtime-o7IR7Ynh.js +19 -0
- package/dist/plugin-sdk/deps-send-telegram.runtime-7Xdhax8B.js +24 -0
- package/dist/plugin-sdk/deps-send-telegram.runtime-DyCorUw2.js +24 -0
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-D6gMTFom.js +57 -0
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-DoOYrpKa.js +57 -0
- package/dist/plugin-sdk/diagnostic-BidLPPBm.js +319 -0
- package/dist/plugin-sdk/{diagnostic-CU_mni6m.js → diagnostic-DhO2TqL_.js} +2 -2
- package/dist/plugin-sdk/{errors-CgRPdp3o.js → errors-9oVz7reJ.js} +1 -1
- package/dist/plugin-sdk/errors-s9jrwzSl.js +54 -0
- package/dist/plugin-sdk/fetch-guard-CEd4HUIR.js +156 -0
- package/dist/plugin-sdk/{fetch-guard-BxMLJbqt.js → fetch-guard-CGQ35-A_.js} +2 -2
- package/dist/plugin-sdk/{fs-safe-5aQcM_qM.js → fs-safe-B26UxJny.js} +3 -3
- package/dist/plugin-sdk/fs-safe-CZ2NvCjz.js +352 -0
- package/dist/plugin-sdk/image-BKaDODzM.js +2310 -0
- package/dist/plugin-sdk/{image-BJXV9IMV.js → image-DPgEp54d.js} +6 -6
- package/dist/plugin-sdk/{image-ops-DovJMvdf.js → image-ops-CbKrfi-N.js} +2 -2
- package/dist/plugin-sdk/image-ops-D0YKZqPy.js +584 -0
- package/dist/plugin-sdk/image-runtime-DN6PHT8G.js +25 -0
- package/dist/plugin-sdk/image-runtime-DxJgD-YS.js +25 -0
- package/dist/plugin-sdk/{ir-DE2ewdq5.js → ir-4JdLS2Hz.js} +7 -7
- package/dist/plugin-sdk/ir-D9fxXkgD.js +1296 -0
- package/dist/plugin-sdk/local-roots-HL9eBLUg.js +186 -0
- package/dist/plugin-sdk/{local-roots-CIwDgpY2.js → local-roots-T6lXDGzr.js} +4 -4
- package/dist/plugin-sdk/{logger-DIb2cGHp.js → logger-Bg4vIUJn.js} +2 -2
- package/dist/plugin-sdk/logger-D0ST0Irn.js +1163 -0
- package/dist/plugin-sdk/{login-CLIcsAVy.js → login-BNCjks0C.js} +4 -4
- package/dist/plugin-sdk/login-CUdm5Ct-.js +57 -0
- package/dist/plugin-sdk/login-qr-34QcLRte.js +320 -0
- package/dist/plugin-sdk/{login-qr-BlxjA0vQ.js → login-qr-CTjNgxhl.js} +5 -5
- package/dist/plugin-sdk/manager-DZ9Hn0Fe.js +3917 -0
- package/dist/plugin-sdk/{manager-CpAGPHeX.js → manager-D__CoDGL.js} +8 -8
- package/dist/plugin-sdk/manager-runtime-B9aBGLrF.js +15 -0
- package/dist/plugin-sdk/manager-runtime-DMEBebYo.js +15 -0
- package/dist/plugin-sdk/mattermost.js +3 -3
- package/dist/plugin-sdk/{outbound-DDpRevO_.js → outbound-DTQ-9Cjw.js} +5 -5
- package/dist/plugin-sdk/outbound-DTndjh8O.js +212 -0
- package/dist/plugin-sdk/outbound-attachment-BNMQOIcP.js +19 -0
- package/dist/plugin-sdk/{outbound-attachment-CVavq5II.js → outbound-attachment-CdHX9v0q.js} +2 -2
- package/dist/plugin-sdk/{path-alias-guards-BfpU4lAT.js → path-alias-guards-DSCFtpsd.js} +1 -1
- package/dist/plugin-sdk/path-alias-guards-DUn7Q6iW.js +43 -0
- package/dist/plugin-sdk/paths-6WIn8_si.js +166 -0
- package/dist/plugin-sdk/{paths-CK3lTJYw.js → paths-BQHqKGA8.js} +1 -1
- package/dist/plugin-sdk/{pi-embedded-helpers-Cb_h9zSJ.js → pi-embedded-helpers-B7nmCbf7.js} +16 -16
- package/dist/plugin-sdk/pi-embedded-helpers-BMA7JWLb.js +9627 -0
- package/dist/plugin-sdk/pi-model-discovery-B6gpdlWb.js +134 -0
- package/dist/plugin-sdk/{pi-model-discovery-B3B3R7L9.js → pi-model-discovery-DyDwYiK3.js} +1 -1
- package/dist/plugin-sdk/pi-model-discovery-runtime-CN6ZaL0W.js +8 -0
- package/dist/plugin-sdk/pi-model-discovery-runtime-Q6toTOMZ.js +8 -0
- package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-CP4hHLJk.js +354 -0
- package/dist/plugin-sdk/{pi-tools.before-tool-call.runtime-DivpBAM0.js → pi-tools.before-tool-call.runtime-D_f6TDo7.js} +4 -4
- package/dist/plugin-sdk/{plugins-BlTrm4bw.js → plugins-BSPvol4w.js} +4 -4
- package/dist/plugin-sdk/plugins-CWIlxjXW.js +864 -0
- package/dist/plugin-sdk/{proxy-env-Cdh-OQYk.js → proxy-env-D-iVYTBk.js} +1 -1
- package/dist/plugin-sdk/{proxy-fetch-Dt5BedH8.js → proxy-fetch-Cf3IUSDw.js} +1 -1
- package/dist/plugin-sdk/proxy-fetch-tPMv_1eB.js +38 -0
- package/dist/plugin-sdk/{pw-ai-DEDRpMlY.js → pw-ai-BO445UDA.js} +9 -9
- package/dist/plugin-sdk/pw-ai-BSMHQrVM.js +1938 -0
- package/dist/plugin-sdk/{qmd-manager-Ct9rtJjd.js → qmd-manager-81ezWnIN.js} +7 -7
- package/dist/plugin-sdk/qmd-manager-DnMoZBC7.js +1448 -0
- package/dist/plugin-sdk/{query-expansion-OdwWuN1S.js → query-expansion-BCOK4OTO.js} +5 -5
- package/dist/plugin-sdk/query-expansion-DxTmIU4K.js +1011 -0
- package/dist/plugin-sdk/{redact-9WsNyb7S.js → redact-Bns9Du30.js} +1 -1
- package/dist/plugin-sdk/redact-DfACyt0X.js +319 -0
- package/dist/plugin-sdk/reply-C-WT0k-v.js +98763 -0
- package/dist/plugin-sdk/{reply-wZhosbPd.js → reply-DJ3rbbnv.js} +73 -73
- package/dist/plugin-sdk/resolve-outbound-target-C6GLRc_O.js +40 -0
- package/dist/plugin-sdk/{resolve-outbound-target-BJmCIkW_.js → resolve-outbound-target-DtQd8TzZ.js} +2 -2
- package/dist/plugin-sdk/run-with-concurrency-Baa7LYZD.js +2023 -0
- package/dist/plugin-sdk/{run-with-concurrency-EUEKeAa8.js → run-with-concurrency-CYcPpb5E.js} +1 -1
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-CUr_hlGk.js +10 -0
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-ai8hcGi_.js +10 -0
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-ByDLfLF3.js +19 -0
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-BzvoaI1G.js +19 -0
- package/dist/plugin-sdk/send-7do64QqA.js +2587 -0
- package/dist/plugin-sdk/{send-Drs4JqVD.js → send-B9GVkvTk.js} +5 -5
- package/dist/plugin-sdk/{send-BMWyVUhm.js → send-BPEn9L0o.js} +13 -13
- package/dist/plugin-sdk/send-Bjh-MMdN.js +503 -0
- package/dist/plugin-sdk/send-C9jI56cY.js +3135 -0
- package/dist/plugin-sdk/{send-0C4KdD-T.js → send-CGjI0pJn.js} +7 -7
- package/dist/plugin-sdk/send-CTsZjmvQ.js +540 -0
- package/dist/plugin-sdk/{send-oo6mQbab.js → send-CZ6HDwDu.js} +8 -8
- package/dist/plugin-sdk/{send-BGWGV_mz.js → send-D6nUI0S3.js} +6 -6
- package/dist/plugin-sdk/send-DiuYhmpi.js +414 -0
- package/dist/plugin-sdk/{session-CXVARKFK.js → session-Bwjlseuf.js} +3 -3
- package/dist/plugin-sdk/session-CiEv9qvh.js +169 -0
- package/dist/plugin-sdk/signal.js +2 -2
- package/dist/plugin-sdk/{skill-commands-CoqGFLfM.js → skill-commands-BpB2Oe8e.js} +4 -4
- package/dist/plugin-sdk/skill-commands-Cuzs_Puw.js +342 -0
- package/dist/plugin-sdk/{skills-di-5uS9y.js → skills-CaQpr1kx.js} +6 -6
- package/dist/plugin-sdk/skills-RHzhTtJf.js +1428 -0
- package/dist/plugin-sdk/slash-commands.runtime-BH06o3dH.js +13 -0
- package/dist/plugin-sdk/slash-commands.runtime-Dqev3QWp.js +13 -0
- package/dist/plugin-sdk/slash-dispatch.runtime-BotYesgY.js +52 -0
- package/dist/plugin-sdk/slash-dispatch.runtime-C_reWfLU.js +52 -0
- package/dist/plugin-sdk/slash-skill-commands.runtime-Cl5Y6y_v.js +16 -0
- package/dist/plugin-sdk/slash-skill-commands.runtime-CzPvxiUD.js +16 -0
- package/dist/plugin-sdk/ssrf-dGOzgEI_.js +202 -0
- package/dist/plugin-sdk/store-DQ2KuNGv.js +81 -0
- package/dist/plugin-sdk/{store-Dn_E3uaN.js → store-K6C7eOpg.js} +2 -2
- package/dist/plugin-sdk/subagent-registry-runtime-BbcgUYOO.js +52 -0
- package/dist/plugin-sdk/subagent-registry-runtime-Dhtf2h8u.js +52 -0
- package/dist/plugin-sdk/tables-B3jPS9G8.js +55 -0
- package/dist/plugin-sdk/{tables-_e9wMygc.js → tables-CeWt6UjS.js} +1 -1
- package/dist/plugin-sdk/target-errors-vzf_mLjC.js +195 -0
- package/dist/plugin-sdk/thinking-R15Mehif.js +1206 -0
- package/dist/plugin-sdk/{thinking-Cih_nxDY.js → thinking-gpcjIDQZ.js} +7 -7
- package/dist/plugin-sdk/{tokens-CLE20fRI.js → tokens-C-B2SvJW.js} +1 -1
- package/dist/plugin-sdk/tokens-DAL_5WHL.js +52 -0
- package/dist/plugin-sdk/{tool-images-D6a1Ua4p.js → tool-images-9Hn0F1o_.js} +2 -2
- package/dist/plugin-sdk/tool-images-l3TE_qXt.js +274 -0
- package/dist/plugin-sdk/web-C4irM2fl.js +56 -0
- package/dist/plugin-sdk/web-DZ7nBzZy.js +56 -0
- package/dist/plugin-sdk/{whatsapp-actions-UAnHjKbE.js → whatsapp-actions-CbzdjX4B.js} +17 -17
- package/dist/plugin-sdk/whatsapp-actions-DZHLwaea.js +80 -0
- package/dist/plugin-sdk/whatsapp.js +50 -50
- package/dist/plugin-sdk/zalo.js +2 -2
- package/dist/{program-B5Vn_UD_.js → program-D5HYdN0q.js} +2 -2
- package/dist/{program-context-Cc5-MG37.js → program-context-CWU-LWnL.js} +6 -6
- package/dist/{prompt-select-styled-DTnRirU4.js → prompt-select-styled-C_C2Ae8a.js} +1 -1
- package/dist/{prompt-select-styled-BmJHQFIe.js → prompt-select-styled-CjkK2AWX.js} +1 -1
- package/dist/{register.maintenance-Di-_iCcy.js → register.maintenance-BnT8sF7e.js} +4 -4
- package/dist/{register.maintenance-dpQRuXYm.js → register.maintenance-CVWvM_w8.js} +5 -5
- package/dist/{register.onboard-D8V8BiRf.js → register.onboard-B68iwPcU.js} +2 -2
- package/dist/{register.onboard-CI1dr2mE.js → register.onboard-Bx2xxYE0.js} +2 -2
- package/dist/{register.setup-Dsl5n4Uf.js → register.setup-BgRFFdoH.js} +2 -2
- package/dist/{register.setup-CuD_ucSh.js → register.setup-DkztcYGa.js} +2 -2
- package/dist/{register.subclis-C4twva8y.js → register.subclis-Bb6WLUhM.js} +3 -3
- package/dist/{run-main-6tdntESl.js → run-main-CApmG6CS.js} +3 -3
- package/dist/{update-cli-XGRmAcuW.js → update-cli-DoKsKvCz.js} +4 -4
- package/dist/{update-cli-CKvgxhEz.js → update-cli-VQSBFHlu.js} +5 -5
- package/extensions/acpx/node_modules/.bin/acpx +2 -2
- package/extensions/diffs/node_modules/.bin/playwright-core +2 -2
- package/extensions/googlechat/node_modules/.bin/squidclaw +4 -4
- package/extensions/matrix/node_modules/.bin/markdown-it +2 -2
- package/extensions/memory-core/node_modules/.bin/squidclaw +4 -4
- package/extensions/memory-lancedb/node_modules/.bin/openai +2 -2
- package/extensions/tlon/node_modules/.bin/tlon +2 -2
- package/package.json +1 -1
- package/dist/control-ui/assets/index-BqxuPQOl.js.map +0 -1
- package/dist/plugin-sdk/deliver-runtime-Dx0Sg-lg.js +0 -32
- package/dist/plugin-sdk/deps-send-discord.runtime-bKwjojX0.js +0 -23
- package/dist/plugin-sdk/deps-send-imessage.runtime-DcxfdKGE.js +0 -22
- package/dist/plugin-sdk/deps-send-signal.runtime-79rGat6V.js +0 -21
- package/dist/plugin-sdk/deps-send-slack.runtime-DfMO701H.js +0 -19
- package/dist/plugin-sdk/deps-send-telegram.runtime-Bnjwm6SU.js +0 -24
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-CS50_Jgh.js +0 -57
- package/dist/plugin-sdk/image-runtime-f-WKB3Bx.js +0 -25
- package/dist/plugin-sdk/manager-runtime-DAKJEbuY.js +0 -15
- package/dist/plugin-sdk/pi-model-discovery-runtime-Bm4bHwpO.js +0 -8
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-D74eZbH7.js +0 -10
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-BidSddX5.js +0 -19
- package/dist/plugin-sdk/slash-commands.runtime-CseiMacz.js +0 -13
- package/dist/plugin-sdk/slash-dispatch.runtime-88gX6CLk.js +0 -52
- package/dist/plugin-sdk/slash-skill-commands.runtime-BNrQNIZ7.js +0 -16
- package/dist/plugin-sdk/subagent-registry-runtime-Cv8RHTjT.js +0 -52
- package/dist/plugin-sdk/web-C4tTN9Xu.js +0 -56
- package/docs/reference/templates/IDENTITY.md +0 -14
- package/docs/reference/templates/USER.md +0 -9
- package/extensions/diagnostics-otel/node_modules/.bin/acorn +0 -21
- package/extensions/memory-lancedb/node_modules/.bin/arrow2csv +0 -21
- package/extensions/nostr/node_modules/.bin/tsc +0 -21
- package/extensions/nostr/node_modules/.bin/tsserver +0 -21
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { c as detectMime } from "./image-ops-D0YKZqPy.js";
|
|
2
|
+
import { r as sanitizeToolResultImages } from "./tool-images-9Hn0F1o_.js";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
|
|
5
|
+
//#region src/agents/tools/common.ts
|
|
6
|
+
var ToolInputError = class extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.status = 400;
|
|
10
|
+
this.name = "ToolInputError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var ToolAuthorizationError = class extends ToolInputError {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.status = 403;
|
|
17
|
+
this.name = "ToolAuthorizationError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function createActionGate(actions) {
|
|
21
|
+
return (key, defaultValue = true) => {
|
|
22
|
+
const value = actions?.[key];
|
|
23
|
+
if (value === void 0) return defaultValue;
|
|
24
|
+
return value !== false;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function toSnakeCaseKey(key) {
|
|
28
|
+
return key.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
|
|
29
|
+
}
|
|
30
|
+
function readParamRaw(params, key) {
|
|
31
|
+
if (Object.hasOwn(params, key)) return params[key];
|
|
32
|
+
const snakeKey = toSnakeCaseKey(key);
|
|
33
|
+
if (snakeKey !== key && Object.hasOwn(params, snakeKey)) return params[snakeKey];
|
|
34
|
+
}
|
|
35
|
+
function readStringParam(params, key, options = {}) {
|
|
36
|
+
const { required = false, trim = true, label = key, allowEmpty = false } = options;
|
|
37
|
+
const raw = readParamRaw(params, key);
|
|
38
|
+
if (typeof raw !== "string") {
|
|
39
|
+
if (required) throw new ToolInputError(`${label} required`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const value = trim ? raw.trim() : raw;
|
|
43
|
+
if (!value && !allowEmpty) {
|
|
44
|
+
if (required) throw new ToolInputError(`${label} required`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
function readStringOrNumberParam(params, key, options = {}) {
|
|
50
|
+
const { required = false, label = key } = options;
|
|
51
|
+
const raw = readParamRaw(params, key);
|
|
52
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
53
|
+
if (typeof raw === "string") {
|
|
54
|
+
const value = raw.trim();
|
|
55
|
+
if (value) return value;
|
|
56
|
+
}
|
|
57
|
+
if (required) throw new ToolInputError(`${label} required`);
|
|
58
|
+
}
|
|
59
|
+
function readNumberParam(params, key, options = {}) {
|
|
60
|
+
const { required = false, label = key, integer = false } = options;
|
|
61
|
+
const raw = readParamRaw(params, key);
|
|
62
|
+
let value;
|
|
63
|
+
if (typeof raw === "number" && Number.isFinite(raw)) value = raw;
|
|
64
|
+
else if (typeof raw === "string") {
|
|
65
|
+
const trimmed = raw.trim();
|
|
66
|
+
if (trimmed) {
|
|
67
|
+
const parsed = Number.parseFloat(trimmed);
|
|
68
|
+
if (Number.isFinite(parsed)) value = parsed;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (value === void 0) {
|
|
72
|
+
if (required) throw new ToolInputError(`${label} required`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
return integer ? Math.trunc(value) : value;
|
|
76
|
+
}
|
|
77
|
+
function readStringArrayParam(params, key, options = {}) {
|
|
78
|
+
const { required = false, label = key } = options;
|
|
79
|
+
const raw = readParamRaw(params, key);
|
|
80
|
+
if (Array.isArray(raw)) {
|
|
81
|
+
const values = raw.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean);
|
|
82
|
+
if (values.length === 0) {
|
|
83
|
+
if (required) throw new ToolInputError(`${label} required`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
return values;
|
|
87
|
+
}
|
|
88
|
+
if (typeof raw === "string") {
|
|
89
|
+
const value = raw.trim();
|
|
90
|
+
if (!value) {
|
|
91
|
+
if (required) throw new ToolInputError(`${label} required`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
return [value];
|
|
95
|
+
}
|
|
96
|
+
if (required) throw new ToolInputError(`${label} required`);
|
|
97
|
+
}
|
|
98
|
+
function readReactionParams(params, options) {
|
|
99
|
+
const emojiKey = options.emojiKey ?? "emoji";
|
|
100
|
+
const removeKey = options.removeKey ?? "remove";
|
|
101
|
+
const remove = typeof params[removeKey] === "boolean" ? params[removeKey] : false;
|
|
102
|
+
const emoji = readStringParam(params, emojiKey, {
|
|
103
|
+
required: true,
|
|
104
|
+
allowEmpty: true
|
|
105
|
+
});
|
|
106
|
+
if (remove && !emoji) throw new ToolInputError(options.removeErrorMessage);
|
|
107
|
+
return {
|
|
108
|
+
emoji,
|
|
109
|
+
remove,
|
|
110
|
+
isEmpty: !emoji
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function jsonResult(payload) {
|
|
114
|
+
return {
|
|
115
|
+
content: [{
|
|
116
|
+
type: "text",
|
|
117
|
+
text: JSON.stringify(payload, null, 2)
|
|
118
|
+
}],
|
|
119
|
+
details: payload
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async function imageResult(params) {
|
|
123
|
+
return await sanitizeToolResultImages({
|
|
124
|
+
content: [{
|
|
125
|
+
type: "text",
|
|
126
|
+
text: params.extraText ?? `MEDIA:${params.path}`
|
|
127
|
+
}, {
|
|
128
|
+
type: "image",
|
|
129
|
+
data: params.base64,
|
|
130
|
+
mimeType: params.mimeType
|
|
131
|
+
}],
|
|
132
|
+
details: {
|
|
133
|
+
path: params.path,
|
|
134
|
+
...params.details
|
|
135
|
+
}
|
|
136
|
+
}, params.label, params.imageSanitization);
|
|
137
|
+
}
|
|
138
|
+
async function imageResultFromFile(params) {
|
|
139
|
+
const buf = await fs.readFile(params.path);
|
|
140
|
+
const mimeType = await detectMime({ buffer: buf.slice(0, 256) }) ?? "image/png";
|
|
141
|
+
return await imageResult({
|
|
142
|
+
label: params.label,
|
|
143
|
+
path: params.path,
|
|
144
|
+
base64: buf.toString("base64"),
|
|
145
|
+
mimeType,
|
|
146
|
+
extraText: params.extraText,
|
|
147
|
+
details: params.details,
|
|
148
|
+
imageSanitization: params.imageSanitization
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Validate and parse an `availableTags` parameter from untrusted input.
|
|
153
|
+
* Returns `undefined` when the value is missing or not an array.
|
|
154
|
+
* Entries that lack a string `name` are silently dropped.
|
|
155
|
+
*/
|
|
156
|
+
function parseAvailableTags(raw) {
|
|
157
|
+
if (raw === void 0 || raw === null) return;
|
|
158
|
+
if (!Array.isArray(raw)) return;
|
|
159
|
+
const result = raw.filter((t) => typeof t === "object" && t !== null && typeof t.name === "string").map((t) => ({
|
|
160
|
+
...t.id !== void 0 && typeof t.id === "string" ? { id: t.id } : {},
|
|
161
|
+
name: t.name,
|
|
162
|
+
...typeof t.moderated === "boolean" ? { moderated: t.moderated } : {},
|
|
163
|
+
...t.emoji_id === null || typeof t.emoji_id === "string" ? { emoji_id: t.emoji_id } : {},
|
|
164
|
+
...t.emoji_name === null || typeof t.emoji_name === "string" ? { emoji_name: t.emoji_name } : {}
|
|
165
|
+
}));
|
|
166
|
+
return result.length ? result : void 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/infra/outbound/target-errors.ts
|
|
171
|
+
function missingTargetMessage(provider, hint) {
|
|
172
|
+
return `Delivering to ${provider} requires target${formatTargetHint(hint)}`;
|
|
173
|
+
}
|
|
174
|
+
function missingTargetError(provider, hint) {
|
|
175
|
+
return new Error(missingTargetMessage(provider, hint));
|
|
176
|
+
}
|
|
177
|
+
function ambiguousTargetMessage(provider, raw, hint) {
|
|
178
|
+
return `Ambiguous target "${raw}" for ${provider}. Provide a unique name or an explicit id.${formatTargetHint(hint, true)}`;
|
|
179
|
+
}
|
|
180
|
+
function ambiguousTargetError(provider, raw, hint) {
|
|
181
|
+
return new Error(ambiguousTargetMessage(provider, raw, hint));
|
|
182
|
+
}
|
|
183
|
+
function unknownTargetMessage(provider, raw, hint) {
|
|
184
|
+
return `Unknown target "${raw}" for ${provider}.${formatTargetHint(hint, true)}`;
|
|
185
|
+
}
|
|
186
|
+
function unknownTargetError(provider, raw, hint) {
|
|
187
|
+
return new Error(unknownTargetMessage(provider, raw, hint));
|
|
188
|
+
}
|
|
189
|
+
function formatTargetHint(hint, withLabel = false) {
|
|
190
|
+
if (!hint) return "";
|
|
191
|
+
return withLabel ? ` Hint: ${hint}` : ` ${hint}`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
export { ToolInputError as a, imageResultFromFile as c, readNumberParam as d, readReactionParams as f, readStringParam as h, ToolAuthorizationError as i, jsonResult as l, readStringOrNumberParam as m, missingTargetError as n, createActionGate as o, readStringArrayParam as p, unknownTargetError as r, imageResult as s, ambiguousTargetError as t, parseAvailableTags as u };
|