@openclaw/clickclack 2026.10.10-beta.5 → 2026.11.5-beta.1
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/.setup/{channel-DRcZ_twH.mjs → channel-ByAANbh8.mjs} +382 -543
- package/dist/.setup/{resolve-Br3ylpSz.mjs → resolve-CRj6QjdF.mjs} +29 -46
- package/dist/.setup/{rolldown-runtime-B4FMCO8f.mjs → rolldown-runtime-782esTHO.mjs} +1 -3
- package/dist/.setup/{runtime-api-BrlvVAQJ.mjs → runtime-api-BsRK-sfA.mjs} +329 -383
- package/dist/.setup/{secret-contract-CF7TKtkU.mjs → secret-contract-Dj8nibUr.mjs} +1 -2
- package/dist/.setup/{secret-contract-api--45pFCg3.mjs → secret-contract-api-DS3Vv0Gu.mjs} +1 -1
- package/dist/.setup/{setup-claim-BPuQuMKW.mjs → setup-claim-BAKxfObl.mjs} +5 -11
- package/dist/.setup/{setup-plugin-api-Ccxm2ydn.mjs → setup-plugin-api-BTqE973B.mjs} +2 -3
- package/dist/.setup/setup-plugin-api-CfuhJJvK.mjs +1 -0
- package/dist/.setup/{setup-surface-BJ3jioqA.mjs → setup-surface-5wSYr6p2.mjs} +11 -17
- package/dist/.setup/{setup-verify-DGsYtVh9.mjs → setup-verify-IayKkFWq.mjs} +13 -26
- package/dist/.source-module-urls/aa673c321fe9be084b8926cbe5388ff5e2a41371389e19ca60a1983f2b634030.json +1 -1
- package/dist/api.js +3 -3
- package/dist/channel-plugin-api.js +1 -1
- package/dist/doctor-contract-api.js +6 -11
- package/dist/index.js +2 -3
- package/dist/runtime-api.js +4 -4
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -4
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +5 -7
- package/dist/.setup/setup-plugin-api-0RMVREuM.mjs +0 -1
- package/node_modules/ws/LICENSE +0 -20
- package/node_modules/ws/README.md +0 -548
- package/node_modules/ws/browser.js +0 -8
- package/node_modules/ws/index.js +0 -22
- package/node_modules/ws/lib/buffer-util.js +0 -131
- package/node_modules/ws/lib/constants.js +0 -19
- package/node_modules/ws/lib/event-target.js +0 -292
- package/node_modules/ws/lib/extension.js +0 -203
- package/node_modules/ws/lib/limiter.js +0 -55
- package/node_modules/ws/lib/permessage-deflate.js +0 -530
- package/node_modules/ws/lib/receiver.js +0 -743
- package/node_modules/ws/lib/sender.js +0 -607
- package/node_modules/ws/lib/stream.js +0 -161
- package/node_modules/ws/lib/subprotocol.js +0 -62
- package/node_modules/ws/lib/validation.js +0 -152
- package/node_modules/ws/lib/websocket-server.js +0 -562
- package/node_modules/ws/lib/websocket.js +0 -1421
- package/node_modules/ws/package.json +0 -74
- package/node_modules/ws/wrapper.mjs +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { collectConditionalChannelFieldAssignments, createChannelSecretContract, hasConfiguredSecretInputValue } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
3
|
-
|
|
3
|
+
// extensions/clickclack/src/secret-contract.ts
|
|
4
4
|
const channelSecrets = createChannelSecretContract({
|
|
5
5
|
channelKey: "clickclack",
|
|
6
6
|
account: ["token"],
|
|
@@ -22,5 +22,4 @@ const channelSecrets = createChannelSecretContract({
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
const { secretTargetRegistryEntries, collectRuntimeConfigAssignments } = channelSecrets;
|
|
25
|
-
//#endregion
|
|
26
25
|
export { collectRuntimeConfigAssignments as n, secretTargetRegistryEntries as r, channelSecrets as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { t as channelSecrets, n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-
|
|
1
|
+
export { t as channelSecrets, n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Dj8nibUr.mjs";
|
|
2
2
|
import "../secret-contract-api.js";
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { a as isClickClackSetupLoopbackHost, i as buildClickClackSetupClaimUrl, o as requireClickClackSetupApiBaseUrl } from "./setup-surface-
|
|
1
|
+
import { a as isClickClackSetupLoopbackHost, i as buildClickClackSetupClaimUrl, o as requireClickClackSetupApiBaseUrl } from "./setup-surface-5wSYr6p2.mjs";
|
|
2
2
|
import { withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
3
3
|
import { createProviderOperationDeadline, readProviderJsonResponse, readResponseTextLimited, resolveProviderOperationTimeoutMs } from "openclaw/plugin-sdk/provider-http";
|
|
4
|
+
import { isStringArray } from "openclaw/plugin-sdk/collection-input-runtime";
|
|
4
5
|
import { fetchWithSsrFGuard, resolvePinnedHostnameWithPolicy, ssrfPolicyFromHttpBaseUrlAllowedHostname } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
5
|
-
|
|
6
|
+
// extensions/clickclack/src/setup-claim.ts
|
|
6
7
|
const CLICKCLACK_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
7
8
|
const CLICKCLACK_SETUP_CODE_CLAIM_JSON_LIMIT_BYTES = 65536;
|
|
8
9
|
const CLICKCLACK_SETUP_CODE_CLAIM_TIMEOUT_MS = 3e4;
|
|
9
|
-
var ClickClackSetupCodeClaimError = class extends Error {
|
|
10
|
-
constructor(status, detail) {
|
|
11
|
-
super(`ClickClack setup code claim failed (${status}): ${detail}`);
|
|
12
|
-
this.status = status;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
10
|
function requireRecord(value, label) {
|
|
16
11
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`ClickClack setup code claim returned invalid ${label}`);
|
|
17
12
|
return value;
|
|
@@ -30,7 +25,7 @@ function parseClickClackSetupCodeClaim(value, expectedClaimUrl) {
|
|
|
30
25
|
const allowFrom = defaults.allowFrom;
|
|
31
26
|
const agentActivity = defaults.agentActivity;
|
|
32
27
|
if (defaultTo !== void 0 && typeof defaultTo !== "string") throw new Error("ClickClack setup code claim returned invalid defaults.defaultTo");
|
|
33
|
-
if (allowFrom !== void 0 &&
|
|
28
|
+
if (allowFrom !== void 0 && !isStringArray(allowFrom)) throw new Error("ClickClack setup code claim returned invalid defaults.allowFrom");
|
|
34
29
|
if (agentActivity !== void 0 && typeof agentActivity !== "boolean") throw new Error("ClickClack setup code claim returned invalid defaults.agentActivity");
|
|
35
30
|
const contractVersion = claim.contract_version;
|
|
36
31
|
const apiBaseUrlValue = claim.api_base_url;
|
|
@@ -120,12 +115,11 @@ async function claimClickClackSetupCode(params) {
|
|
|
120
115
|
try {
|
|
121
116
|
if (!response.ok) {
|
|
122
117
|
const detail = await readResponseTextLimited(response, CLICKCLACK_ERROR_BODY_LIMIT_BYTES);
|
|
123
|
-
throw new
|
|
118
|
+
throw Object.assign(/* @__PURE__ */ new Error(`ClickClack setup code claim failed (${response.status}): ${detail}`), { status: response.status });
|
|
124
119
|
}
|
|
125
120
|
return parseClickClackSetupCodeClaim(await readProviderJsonResponse(response, "ClickClack setup code claim", { maxBytes: CLICKCLACK_SETUP_CODE_CLAIM_JSON_LIMIT_BYTES }), params.expectedClaimUrl);
|
|
126
121
|
} finally {
|
|
127
122
|
await release();
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
|
-
//#endregion
|
|
131
125
|
export { claimClickClackSetupCode };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as clickClackConfigAdapter, n as clickClackSetupContract, s as clickClackConfigSchema, t as clickClackSetupWizard, u as clickClackMeta } from "./setup-surface-
|
|
2
|
-
|
|
1
|
+
import { l as clickClackConfigAdapter, n as clickClackSetupContract, s as clickClackConfigSchema, t as clickClackSetupWizard, u as clickClackMeta } from "./setup-surface-5wSYr6p2.mjs";
|
|
2
|
+
// extensions/clickclack/src/channel.setup.ts
|
|
3
3
|
const clickClackSetupPlugin = {
|
|
4
4
|
id: "clickclack",
|
|
5
5
|
meta: clickClackMeta,
|
|
@@ -14,5 +14,4 @@ const clickClackSetupPlugin = {
|
|
|
14
14
|
setupContract: clickClackSetupContract,
|
|
15
15
|
setupWizard: clickClackSetupWizard
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { clickClackSetupPlugin as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as clickClackSetupPlugin } from "./setup-plugin-api-BTqE973B.mjs";
|
|
@@ -15,7 +15,7 @@ import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
|
|
|
15
15
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, applyAccountNameToChannelSection, baseUrlTextInput, createSetupTranslator, createStandardChannelSetupStatus, defineTokenCredential, formatDocsLink, hasConfiguredSecretInput, moveSingleAccountChannelSectionToDefaultAccount, patchScopedAccountConfig, prepareScopedSetupConfig, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
|
|
16
16
|
import { createSetupInputPresenceValidator } from "openclaw/plugin-sdk/setup-runtime";
|
|
17
17
|
import net from "node:net";
|
|
18
|
-
|
|
18
|
+
// extensions/clickclack/src/accounts.ts
|
|
19
19
|
const DEFAULT_RECONNECT_MS = 1500;
|
|
20
20
|
const MIN_RECONNECT_MS = 100;
|
|
21
21
|
const MAX_RECONNECT_MS = 6e4;
|
|
@@ -209,8 +209,7 @@ function listEnabledClickClackAccounts(cfg) {
|
|
|
209
209
|
accountId
|
|
210
210
|
})).filter((account) => account.enabled);
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
//#region extensions/clickclack/src/channel-config.ts
|
|
212
|
+
// extensions/clickclack/src/channel-config.ts
|
|
214
213
|
const CLICKCLACK_CHANNEL_ID = "clickclack";
|
|
215
214
|
const clickClackMeta = { ...getChatChannelMeta(CLICKCLACK_CHANNEL_ID) };
|
|
216
215
|
const clickClackConfigAdapter = {
|
|
@@ -230,8 +229,7 @@ const clickClackConfigAdapter = {
|
|
|
230
229
|
accountId
|
|
231
230
|
}).defaultTo
|
|
232
231
|
};
|
|
233
|
-
|
|
234
|
-
//#region extensions/clickclack/src/config-schema.ts
|
|
232
|
+
// extensions/clickclack/src/config-schema.ts
|
|
235
233
|
const ClickClackAccountConfigSchema = z.object({
|
|
236
234
|
name: z.string().optional(),
|
|
237
235
|
enabled: z.boolean().optional(),
|
|
@@ -297,8 +295,7 @@ const clickClackConfigSchema = buildChannelConfigSchema(ClickClackConfigSchema,
|
|
|
297
295
|
help: "Override the account policy for threads rooted in this bot's messages in this channel."
|
|
298
296
|
}
|
|
299
297
|
} });
|
|
300
|
-
|
|
301
|
-
//#region extensions/clickclack/src/setup-contract.ts
|
|
298
|
+
// extensions/clickclack/src/setup-contract.ts
|
|
302
299
|
const CLICKCLACK_SETUP_CODE_CLAIM_PATH = "/api/bot-setup-codes/claim";
|
|
303
300
|
const LOOPBACK_ADDRESSES = new net.BlockList();
|
|
304
301
|
LOOPBACK_ADDRESSES.addSubnet("127.0.0.0", 8, "ipv4");
|
|
@@ -340,8 +337,7 @@ function requireClickClackSetupClaimUrl(value) {
|
|
|
340
337
|
function buildClickClackSetupClaimUrl(baseUrl) {
|
|
341
338
|
return baseUrl.replace(/\/+$/u, "") + CLICKCLACK_SETUP_CODE_CLAIM_PATH;
|
|
342
339
|
}
|
|
343
|
-
|
|
344
|
-
//#region extensions/clickclack/src/setup-core.ts
|
|
340
|
+
// extensions/clickclack/src/setup-core.ts
|
|
345
341
|
const channel$1 = "clickclack";
|
|
346
342
|
const SETUP_CODE_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
347
343
|
const SETUP_CODE_LENGTH = 12;
|
|
@@ -450,7 +446,7 @@ const clickClackSetupAdapter = {
|
|
|
450
446
|
const claimUrl = setup.exactClaimUrl && !privateApiBaseUrl ? setup.exactClaimUrl : buildClickClackSetupClaimUrl(privateApiBaseUrl ?? setup.baseUrl);
|
|
451
447
|
let claim;
|
|
452
448
|
try {
|
|
453
|
-
const { claimClickClackSetupCode } = await import("./setup-claim-
|
|
449
|
+
const { claimClickClackSetupCode } = await import("./setup-claim-BAKxfObl.mjs");
|
|
454
450
|
claim = await claimClickClackSetupCode({
|
|
455
451
|
claimUrl,
|
|
456
452
|
code: setup.code,
|
|
@@ -466,7 +462,7 @@ const clickClackSetupAdapter = {
|
|
|
466
462
|
token: claim.token,
|
|
467
463
|
workspace: claim.workspace.id,
|
|
468
464
|
...claim.defaults.defaultTo !== void 0 ? { defaultTo: claim.defaults.defaultTo } : {},
|
|
469
|
-
...claim.defaults.allowFrom !== void 0 ? { allowFrom:
|
|
465
|
+
...claim.defaults.allowFrom !== void 0 ? { allowFrom: claim.defaults.allowFrom } : {},
|
|
470
466
|
...claim.defaults.agentActivity !== void 0 ? { agentActivity: claim.defaults.agentActivity } : {}
|
|
471
467
|
};
|
|
472
468
|
},
|
|
@@ -519,7 +515,7 @@ const clickClackSetupAdapter = {
|
|
|
519
515
|
...baseUrl ? { baseUrl } : {},
|
|
520
516
|
...workspace ? { workspace } : {},
|
|
521
517
|
...setupInput.defaultTo?.trim() ? { defaultTo: setupInput.defaultTo.trim() } : {},
|
|
522
|
-
...setupInput.allowFrom ? { allowFrom:
|
|
518
|
+
...setupInput.allowFrom ? { allowFrom: setupInput.allowFrom } : {},
|
|
523
519
|
...setupInput.agentActivity !== void 0 ? { agentActivity: setupInput.agentActivity } : {}
|
|
524
520
|
}
|
|
525
521
|
}),
|
|
@@ -530,7 +526,7 @@ const clickClackSetupAdapter = {
|
|
|
530
526
|
});
|
|
531
527
|
},
|
|
532
528
|
afterAccountConfigWritten: async ({ cfg, accountId, runtime }) => {
|
|
533
|
-
const { verifyClickClackAccountAfterSetup } = await import("./setup-verify-
|
|
529
|
+
const { verifyClickClackAccountAfterSetup } = await import("./setup-verify-IayKkFWq.mjs");
|
|
534
530
|
await verifyClickClackAccountAfterSetup({
|
|
535
531
|
cfg,
|
|
536
532
|
accountId,
|
|
@@ -610,8 +606,7 @@ const clickClackSetupContract = defineChannelSetupContract({
|
|
|
610
606
|
},
|
|
611
607
|
legacyAdapter: clickClackSetupAdapter
|
|
612
608
|
});
|
|
613
|
-
|
|
614
|
-
//#region extensions/clickclack/src/setup-surface.ts
|
|
609
|
+
// extensions/clickclack/src/setup-surface.ts
|
|
615
610
|
const t = createSetupTranslator();
|
|
616
611
|
const channel = "clickclack";
|
|
617
612
|
function hasConfiguredClickClackCredential(account) {
|
|
@@ -712,7 +707,7 @@ const clickClackSetupWizard = {
|
|
|
712
707
|
})
|
|
713
708
|
}],
|
|
714
709
|
finalize: async ({ cfg, accountId, credentialValues, prompter }) => {
|
|
715
|
-
const { checkClickClackSetupConnection } = await import("./setup-verify-
|
|
710
|
+
const { checkClickClackSetupConnection } = await import("./setup-verify-IayKkFWq.mjs");
|
|
716
711
|
const result = await checkClickClackSetupConnection({
|
|
717
712
|
cfg,
|
|
718
713
|
accountId,
|
|
@@ -731,5 +726,4 @@ const clickClackSetupWizard = {
|
|
|
731
726
|
},
|
|
732
727
|
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
|
|
733
728
|
};
|
|
734
|
-
//#endregion
|
|
735
729
|
export { resolveDefaultClickClackAccountId as _, isClickClackSetupLoopbackHost as a, CLICKCLACK_CHANNEL_ID as c, DEFAULT_ACCOUNT_ID$2 as d, isClickClackAccountCurrent as f, resolveClickClackAccountConfig as g, resolveClickClackAccount as h, buildClickClackSetupClaimUrl as i, clickClackConfigAdapter as l, listEnabledClickClackAccounts as m, clickClackSetupContract as n, requireClickClackSetupApiBaseUrl as o, listClickClackAccountIds as p, CLICKCLACK_SETUP_CODE_CLAIM_PATH as r, clickClackConfigSchema as s, clickClackSetupWizard as t, clickClackMeta as u };
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import { h as resolveClickClackAccount } from "./setup-surface-
|
|
2
|
-
import { a as createClickClackClient, t as findClickClackWorkspace } from "./resolve-
|
|
1
|
+
import { h as resolveClickClackAccount } from "./setup-surface-5wSYr6p2.mjs";
|
|
2
|
+
import { a as createClickClackClient, i as ClickClackHttpError, t as findClickClackWorkspace } from "./resolve-CRj6QjdF.mjs";
|
|
3
3
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
4
4
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
5
5
|
import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/setup";
|
|
6
|
-
|
|
6
|
+
// extensions/clickclack/src/setup-verify.ts
|
|
7
7
|
const GATEWAY_RUNNING_MESSAGE = "OpenClaw is running — ClickClack will connect automatically.";
|
|
8
8
|
const GATEWAY_NOT_RUNNING_MESSAGE = "Start OpenClaw to connect: openclaw gateway";
|
|
9
9
|
const GATEWAY_UNKNOWN_MESSAGE = "If OpenClaw is running it connects automatically; otherwise start it with: openclaw gateway";
|
|
10
|
-
function isHttpStatus(error, status) {
|
|
11
|
-
return typeof error === "object" && error !== null && "status" in error && error.status === status;
|
|
12
|
-
}
|
|
13
|
-
function isWorkspaceNotFound(error) {
|
|
14
|
-
return error instanceof Error && error.message.startsWith("ClickClack workspace not found:");
|
|
15
|
-
}
|
|
16
10
|
function usesUnavailableImplicitEnvToken(account, tokenOverride) {
|
|
17
11
|
return account.accountId === DEFAULT_ACCOUNT_ID && Boolean(account.baseUrl && account.workspace) && !tokenOverride && !account.token && !hasConfiguredSecretInput(account.config.token) && !account.config.tokenFile?.trim();
|
|
18
12
|
}
|
|
19
13
|
async function checkClickClackSetupConnection(params) {
|
|
20
|
-
let workspaceInput = "";
|
|
21
14
|
try {
|
|
22
15
|
const account = resolveClickClackAccount({
|
|
23
16
|
cfg: params.cfg,
|
|
24
17
|
accountId: params.accountId
|
|
25
18
|
});
|
|
26
|
-
workspaceInput = account.workspace;
|
|
27
19
|
const token = params.token?.trim() || account.token;
|
|
28
20
|
if (usesUnavailableImplicitEnvToken(account, token)) return { status: "skipped-env-token" };
|
|
29
21
|
if (!account.baseUrl || !account.workspace || !token) return { status: "skipped-unconfigured" };
|
|
@@ -34,33 +26,28 @@ async function checkClickClackSetupConnection(params) {
|
|
|
34
26
|
const me = await client.me();
|
|
35
27
|
const workspaces = await client.workspaces();
|
|
36
28
|
const workspace = account.workspace.startsWith("wsp_") ? workspaces.find((candidate) => candidate.id === account.workspace) : findClickClackWorkspace(workspaces, account.workspace);
|
|
37
|
-
if (!workspace)
|
|
29
|
+
if (!workspace) return {
|
|
30
|
+
status: "workspace-not-found",
|
|
31
|
+
workspace: account.workspace
|
|
32
|
+
};
|
|
38
33
|
return {
|
|
39
34
|
status: "connected",
|
|
40
35
|
handle: me.handle,
|
|
41
36
|
workspaceName: workspace.name
|
|
42
37
|
};
|
|
43
38
|
} catch (error) {
|
|
44
|
-
if (
|
|
45
|
-
if (isWorkspaceNotFound(error)) return {
|
|
46
|
-
status: "workspace-not-found",
|
|
47
|
-
workspace: workspaceInput
|
|
48
|
-
};
|
|
39
|
+
if (error instanceof ClickClackHttpError && error.status === 401) return { status: "invalid-token" };
|
|
49
40
|
return {
|
|
50
41
|
status: "failed",
|
|
51
42
|
error: formatErrorMessage(error)
|
|
52
43
|
};
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
|
-
function isGatewayNotRunningError(error) {
|
|
56
|
-
if (typeof error === "object" && error !== null && "name" in error && "kind" in error && "code" in error && error.name === "GatewayTransportError" && error.kind === "closed" && error.code === 1006) return true;
|
|
57
|
-
const message = formatErrorMessage(error).toLowerCase();
|
|
58
|
-
return message.includes("econnrefused") || message.includes("connection refused");
|
|
59
|
-
}
|
|
60
46
|
async function probeClickClackGatewayStatus() {
|
|
47
|
+
let gateway;
|
|
61
48
|
try {
|
|
62
|
-
|
|
63
|
-
await callGatewayFromCli("health", {
|
|
49
|
+
gateway = await import("openclaw/plugin-sdk/gateway-runtime");
|
|
50
|
+
await gateway.callGatewayFromCli("health", {
|
|
64
51
|
timeout: "1000",
|
|
65
52
|
json: true
|
|
66
53
|
}, void 0, {
|
|
@@ -69,7 +56,8 @@ async function probeClickClackGatewayStatus() {
|
|
|
69
56
|
});
|
|
70
57
|
return GATEWAY_RUNNING_MESSAGE;
|
|
71
58
|
} catch (error) {
|
|
72
|
-
|
|
59
|
+
const message = formatErrorMessage(error).toLowerCase();
|
|
60
|
+
return gateway && gateway.isGatewayTransportError(error) && error.kind === "closed" && error.code === 1006 || message.includes("econnrefused") || message.includes("connection refused") ? GATEWAY_NOT_RUNNING_MESSAGE : GATEWAY_UNKNOWN_MESSAGE;
|
|
73
61
|
}
|
|
74
62
|
}
|
|
75
63
|
function formatClickClackConnectionLog(result) {
|
|
@@ -90,5 +78,4 @@ async function verifyClickClackAccountAfterSetup(params) {
|
|
|
90
78
|
if (message) params.runtime.log(message);
|
|
91
79
|
params.runtime.log(await probeClickClackGatewayStatus());
|
|
92
80
|
}
|
|
93
|
-
//#endregion
|
|
94
81
|
export { checkClickClackSetupConnection, verifyClickClackAccountAfterSetup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"entries":[{"output":"api.js","source":"extensions/clickclack/api.ts"},{"output":"channel-plugin-api.js","source":"extensions/clickclack/channel-plugin-api.ts"},{"output":"doctor-contract-api.js","source":"extensions/clickclack/doctor-contract-api.ts"},{"output":"index.js","source":"extensions/clickclack/index.ts"},{"output":"runtime-api.js","source":"extensions/clickclack/runtime-api.ts"},{"output":"secret-contract-api.js","source":"extensions/clickclack/secret-contract-api.ts"},{"output":"setup-entry.js","source":"extensions/clickclack/setup-entry.ts"},{"output":"setup-plugin-api.js","source":"extensions/clickclack/setup-plugin-api.ts"}],"chunks":[{"output":".setup/channel-
|
|
1
|
+
{"version":3,"entries":[{"output":"api.js","source":"extensions/clickclack/api.ts"},{"output":"channel-plugin-api.js","source":"extensions/clickclack/channel-plugin-api.ts"},{"output":"doctor-contract-api.js","source":"extensions/clickclack/doctor-contract-api.ts"},{"output":"index.js","source":"extensions/clickclack/index.ts"},{"output":"runtime-api.js","source":"extensions/clickclack/runtime-api.ts"},{"output":"secret-contract-api.js","source":"extensions/clickclack/secret-contract-api.ts"},{"output":"setup-entry.js","source":"extensions/clickclack/setup-entry.ts"},{"output":"setup-plugin-api.js","source":"extensions/clickclack/setup-plugin-api.ts"}],"chunks":[{"output":".setup/channel-ByAANbh8.mjs","sha256":"450c1c4f77efbc6a4fe7dfe184221b6f25da321f5144b8dc53c452fdff1f0a7c","facadeSource":null,"sources":["extensions/clickclack/src/access.ts","extensions/clickclack/src/activity.ts","extensions/clickclack/src/channel.ts","extensions/clickclack/src/discussions/binding-generation.ts","extensions/clickclack/src/discussions/binding-store.ts","extensions/clickclack/src/discussions/eligibility.ts","extensions/clickclack/src/discussions/naming.ts","extensions/clickclack/src/discussions/revoked-channel-store.ts","extensions/clickclack/src/discussions/routing.ts","extensions/clickclack/src/discussions/session-authority.ts","extensions/clickclack/src/gateway.ts","extensions/clickclack/src/group-policy.ts","extensions/clickclack/src/inbound.ts","extensions/clickclack/src/outbound.ts","extensions/clickclack/src/progress.ts","extensions/clickclack/src/runtime.ts","extensions/clickclack/src/target.ts","src/channels/mention-gating.ts"]},{"output":".setup/resolve-CRj6QjdF.mjs","sha256":"70188c223d195aaa2d36e4dcc5d7cf006e6568f9d06423a62e9453487f81bfa2","facadeSource":null,"sources":["extensions/clickclack/src/http-client.ts","extensions/clickclack/src/resolve.ts"]},{"output":".setup/rolldown-runtime-782esTHO.mjs","sha256":"5ee95aea427a7c3b63d18f4d901f7c824b836077e85aee06ae7d598c1974e2a6","facadeSource":null,"sources":[]},{"output":".setup/runtime-api-BsRK-sfA.mjs","sha256":"64dd234dd1bc81d34cd7ace25ce4f2e5787cbaa77693b428cd0f48493b66f4bd","facadeSource":null,"sources":["extensions/clickclack/src/discussions/binding-retention.ts","extensions/clickclack/src/discussions/control-session-url.ts","extensions/clickclack/src/discussions/installation.ts","extensions/clickclack/src/discussions/register.ts","extensions/clickclack/src/discussions/service-history.ts","extensions/clickclack/src/discussions/service-open.ts","extensions/clickclack/src/discussions/service.ts"]},{"output":".setup/secret-contract-api-DS3Vv0Gu.mjs","sha256":"1f4fbfb7031408f8896ccf43ddb8548914c3262c87011904190d9b28c40ebb80","facadeSource":"extensions/clickclack/secret-contract-api.ts","sources":[]},{"output":".setup/secret-contract-Dj8nibUr.mjs","sha256":"2c29e39e3a80ffa74c2141f7a8b2a0beb63b1094f030860bd26bda2319d04d9b","facadeSource":null,"sources":["extensions/clickclack/src/secret-contract.ts"]},{"output":".setup/setup-claim-BAKxfObl.mjs","sha256":"5338c71680bfaae4274e8af80ef35cd61dfb3e1881f8a7979b2d1ef5191f0d77","facadeSource":"extensions/clickclack/src/setup-claim.ts","sources":["extensions/clickclack/src/setup-claim.ts"]},{"output":".setup/setup-plugin-api-BTqE973B.mjs","sha256":"5740b952578d7242249506eb563c876aec52798c5225d54ad6fb4abb46e25659","facadeSource":null,"sources":["extensions/clickclack/src/channel.setup.ts"]},{"output":".setup/setup-plugin-api-CfuhJJvK.mjs","sha256":"743fa1f54c66ac71fb9f659b7ff47c47b379225bd14c7d87b374f9301518a610","facadeSource":"extensions/clickclack/setup-plugin-api.ts","sources":[]},{"output":".setup/setup-surface-5wSYr6p2.mjs","sha256":"e277541cd9c2e34678dc5464e347aa473e25cb307465a875a9c368e445a62071","facadeSource":null,"sources":["extensions/clickclack/src/accounts.ts","extensions/clickclack/src/channel-config.ts","extensions/clickclack/src/config-schema.ts","extensions/clickclack/src/setup-contract.ts","extensions/clickclack/src/setup-core.ts","extensions/clickclack/src/setup-surface.ts"]},{"output":".setup/setup-verify-IayKkFWq.mjs","sha256":"dcbb56ce503e43a6b54e0fd73a999fbbfe4b029afeb996e0a5dd5366c4814edd","facadeSource":"extensions/clickclack/src/setup-verify.ts","sources":["extensions/clickclack/src/setup-verify.ts"]},{"output":"api.js","sha256":"547bd75f58aacd4185112aa77faae24a51dbbe088b1a1c10257be78f5a21672a","facadeSource":"extensions/clickclack/api.ts","sources":[]},{"output":"channel-plugin-api.js","sha256":"dc60b1cf86c86ea358020490a24a821aabe924966500ba04360a0d2c156cd430","facadeSource":"extensions/clickclack/channel-plugin-api.ts","sources":[]},{"output":"doctor-contract-api.js","sha256":"90e35955fee235ef5fde4467214d6fc892a5eca1ec736c65a0f6295c3372daa0","facadeSource":"extensions/clickclack/doctor-contract-api.ts","sources":["extensions/clickclack/src/doctor-contract.ts","packages/normalization-core/src/record-coerce.ts","src/config/channel-config-normalization.ts","src/plugin-sdk/legacy-webhook-listener-migration.ts"]},{"output":"index.js","sha256":"22200462363615fc6e30194e2f1d82464856157dac0c0231daa81987af0ad877","facadeSource":"extensions/clickclack/index.ts","sources":["extensions/clickclack/index.ts"]},{"output":"runtime-api.js","sha256":"495e79c4025920ad6daa2afb3b35e06e5e15ca87b89d8d01e9fb4992c3b9baff","facadeSource":"extensions/clickclack/runtime-api.ts","sources":[]},{"output":"secret-contract-api.js","sha256":"cff9cd4ef5118483a955a1375f95db91532f9f9755b43e54e4b04561b9ee7810","facadeSource":"extensions/clickclack/secret-contract-api.ts","sources":[]},{"output":"setup-entry.js","sha256":"58b9cd63bfefea2acb45f8ba94ed64ad7911824d1ceadb2819d0b1434dce3500","facadeSource":"extensions/clickclack/setup-entry.ts","sources":["extensions/clickclack/setup-entry.ts"]},{"output":"setup-plugin-api.js","sha256":"33a5a0bd1cb00ee06b9125ab5db5dd78c62a6648cec7b78c954c0947b0048274","facadeSource":"extensions/clickclack/setup-plugin-api.ts","sources":[]}],"unrenderedSources":["extensions/clickclack/api.ts","extensions/clickclack/channel-plugin-api.ts","extensions/clickclack/config-doctor-api.ts","extensions/clickclack/doctor-contract-api.ts","extensions/clickclack/runtime-api.ts","extensions/clickclack/secret-contract-api.ts","extensions/clickclack/setup-plugin-api.ts"]}
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as resolveDefaultClickClackAccountId, d as DEFAULT_ACCOUNT_ID, h as resolveClickClackAccount, m as listEnabledClickClackAccounts, p as listClickClackAccountIds, s as clickClackConfigSchema } from "./.setup/setup-surface-
|
|
2
|
-
import { a as setClickClackRuntime, i as getClickClackRuntime, n as buildClickClackTarget, r as parseClickClackTarget, t as clickClackPlugin } from "./.setup/channel-
|
|
3
|
-
import { a as createClickClackClient } from "./.setup/resolve-
|
|
1
|
+
import { _ as resolveDefaultClickClackAccountId, d as DEFAULT_ACCOUNT_ID, h as resolveClickClackAccount, m as listEnabledClickClackAccounts, p as listClickClackAccountIds, s as clickClackConfigSchema } from "./.setup/setup-surface-5wSYr6p2.mjs";
|
|
2
|
+
import { a as setClickClackRuntime, i as getClickClackRuntime, n as buildClickClackTarget, r as parseClickClackTarget, t as clickClackPlugin } from "./.setup/channel-ByAANbh8.mjs";
|
|
3
|
+
import { a as createClickClackClient } from "./.setup/resolve-CRj6QjdF.mjs";
|
|
4
4
|
export { DEFAULT_ACCOUNT_ID, buildClickClackTarget, clickClackConfigSchema, clickClackPlugin, createClickClackClient, getClickClackRuntime, listClickClackAccountIds, listEnabledClickClackAccounts, parseClickClackTarget, resolveClickClackAccount, resolveDefaultClickClackAccountId, setClickClackRuntime };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as clickClackPlugin } from "./.setup/channel-
|
|
1
|
+
export { t as clickClackPlugin } from "./.setup/channel-ByAANbh8.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./.setup/rolldown-runtime-
|
|
2
|
-
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./.setup/rolldown-runtime-782esTHO.mjs";
|
|
2
|
+
// packages/normalization-core/src/record-coerce.ts
|
|
3
3
|
/** Type guard for non-array object records at browser-safe boundaries. */
|
|
4
4
|
function isRecord(value) {
|
|
5
5
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -8,8 +8,7 @@ function isRecord(value) {
|
|
|
8
8
|
function asNullableRecord(value) {
|
|
9
9
|
return isRecord(value) ? value : null;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
//#region src/config/channel-config-normalization.ts
|
|
11
|
+
// src/config/channel-config-normalization.ts
|
|
13
12
|
/** Applies one channel-specific doctor migration to every object-shaped account. */
|
|
14
13
|
function normalizeChannelAccounts(params) {
|
|
15
14
|
const rawAccounts = asNullableRecord(params.entry.accounts);
|
|
@@ -85,8 +84,7 @@ function normalizeChannelConfigEntries(params) {
|
|
|
85
84
|
changes
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
//#region src/plugin-sdk/legacy-webhook-listener-migration.ts
|
|
87
|
+
// src/plugin-sdk/legacy-webhook-listener-migration.ts
|
|
90
88
|
/** Preserve explicitly configured webhook listeners while moving ingress onto Gateway routes. */
|
|
91
89
|
function createLegacyWebhookListenerDoctorContract(params) {
|
|
92
90
|
const portKey = params.portKey ?? "webhookPort";
|
|
@@ -156,13 +154,11 @@ function createLegacyWebhookListenerDoctorContract(params) {
|
|
|
156
154
|
}
|
|
157
155
|
};
|
|
158
156
|
}
|
|
159
|
-
|
|
160
|
-
//#region \0openclaw:bundled-sdk:openclaw/plugin-sdk/runtime-doctor-migrations
|
|
157
|
+
// \0openclaw:bundled-sdk:openclaw/plugin-sdk/runtime-doctor-migrations
|
|
161
158
|
var runtime_doctor_migrations_exports = /* @__PURE__ */ __exportAll({ createLegacyWebhookListenerDoctorContract: () => createLegacyWebhookListenerDoctorContract });
|
|
162
159
|
import * as import_openclaw_plugin_sdk_runtime_doctor_migrations from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
163
160
|
__reExport(runtime_doctor_migrations_exports, import_openclaw_plugin_sdk_runtime_doctor_migrations);
|
|
164
|
-
|
|
165
|
-
//#region extensions/clickclack/src/doctor-contract.ts
|
|
161
|
+
// extensions/clickclack/src/doctor-contract.ts
|
|
166
162
|
function stripTimeoutSeconds(value) {
|
|
167
163
|
const record = (0, runtime_doctor_migrations_exports.asObjectRecord)(value);
|
|
168
164
|
if (!record) return {
|
|
@@ -207,5 +203,4 @@ function normalizeCompatibilityConfig({ cfg }) {
|
|
|
207
203
|
changes: ["Removed retired ClickClack timeout tuning knobs."]
|
|
208
204
|
};
|
|
209
205
|
}
|
|
210
|
-
//#endregion
|
|
211
206
|
export { normalizeCompatibilityConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-
|
|
1
|
+
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-BsRK-sfA.mjs";
|
|
2
2
|
import { defineBundledChannelEntry } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
3
|
-
|
|
3
|
+
// extensions/clickclack/index.ts
|
|
4
4
|
var clickclack_default = defineBundledChannelEntry({
|
|
5
5
|
id: "clickclack",
|
|
6
6
|
name: "ClickClack",
|
|
@@ -16,5 +16,4 @@ var clickclack_default = defineBundledChannelEntry({
|
|
|
16
16
|
},
|
|
17
17
|
registerFull: registerClickClackDiscussions
|
|
18
18
|
});
|
|
19
|
-
//#endregion
|
|
20
19
|
export { clickclack_default as default };
|
package/dist/runtime-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as resolveClickClackAccount } from "./.setup/setup-surface-
|
|
2
|
-
import { a as setClickClackRuntime, r as parseClickClackTarget } from "./.setup/channel-
|
|
3
|
-
import { a as createClickClackClient } from "./.setup/resolve-
|
|
4
|
-
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-
|
|
1
|
+
import { h as resolveClickClackAccount } from "./.setup/setup-surface-5wSYr6p2.mjs";
|
|
2
|
+
import { a as setClickClackRuntime, r as parseClickClackTarget } from "./.setup/channel-ByAANbh8.mjs";
|
|
3
|
+
import { a as createClickClackClient } from "./.setup/resolve-CRj6QjdF.mjs";
|
|
4
|
+
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-BsRK-sfA.mjs";
|
|
5
5
|
export { createClickClackClient, parseClickClackTarget, registerClickClackDiscussions, resolveClickClackAccount, setClickClackRuntime };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as channelSecrets, n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-
|
|
1
|
+
export { t as channelSecrets, n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-Dj8nibUr.mjs";
|
package/dist/setup-entry.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { defineBundledChannelSetupEntry } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
3
|
+
// extensions/clickclack/setup-entry.ts
|
|
4
4
|
var setup_entry_default = defineBundledChannelSetupEntry({
|
|
5
5
|
importMetaUrl: import.meta.url,
|
|
6
6
|
plugin: {
|
|
7
|
-
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-
|
|
7
|
+
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-CfuhJJvK.mjs", import.meta.url).href),
|
|
8
8
|
exportName: "clickClackSetupPlugin"
|
|
9
9
|
},
|
|
10
10
|
secrets: {
|
|
11
|
-
specifier: fileURLToPath(new URL(".setup/secret-contract-api
|
|
11
|
+
specifier: fileURLToPath(new URL(".setup/secret-contract-api-DS3Vv0Gu.mjs", import.meta.url).href),
|
|
12
12
|
exportName: "channelSecrets"
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
//#endregion
|
|
16
15
|
export { setup_entry_default as default };
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as clickClackSetupPlugin } from "./.setup/setup-plugin-api-
|
|
1
|
+
export { t as clickClackSetupPlugin } from "./.setup/setup-plugin-api-BTqE973B.mjs";
|
|
@@ -140,6 +140,33 @@ test("continue parsing despite array size error", () => {
|
|
|
140
140
|
`);
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
+
test("an upper size bound fails before any element is parsed", () => {
|
|
144
|
+
let parsed = 0;
|
|
145
|
+
const el = z.string().refine(() => ++parsed);
|
|
146
|
+
let refined = 0;
|
|
147
|
+
const schema = z
|
|
148
|
+
.array(el)
|
|
149
|
+
.max(2, "too many")
|
|
150
|
+
.refine(() => ++refined);
|
|
151
|
+
expect(schema.safeParse([1, 2, 3]).error!.issues).toMatchObject([{ code: "too_big", path: [], message: "too many" }]);
|
|
152
|
+
expect(z.array(el).length(2).safeParse(["a", "b", "c"]).error!.issues).toMatchObject([
|
|
153
|
+
{ code: "too_big", exact: true },
|
|
154
|
+
]);
|
|
155
|
+
expect(z.object({ a: z.array(el).max(1) }).safeParse({ a: [1, 2] }).error!.issues).toMatchObject([
|
|
156
|
+
{ code: "too_big", path: ["a"] },
|
|
157
|
+
]);
|
|
158
|
+
expect([parsed, refined]).toEqual([0, 0]);
|
|
159
|
+
|
|
160
|
+
// a check that may rewrite the value ends the gate
|
|
161
|
+
expect(
|
|
162
|
+
z
|
|
163
|
+
.array(z.number())
|
|
164
|
+
.overwrite((a) => a.slice(0, 2))
|
|
165
|
+
.max(2)
|
|
166
|
+
.parse([1, 2, 3])
|
|
167
|
+
).toEqual([1, 2]);
|
|
168
|
+
});
|
|
169
|
+
|
|
143
170
|
test("parse should fail given sparse array", () => {
|
|
144
171
|
const schema = z.array(z.string()).nonempty().min(1).max(3);
|
|
145
172
|
const result = schema.safeParse(new Array(3));
|
|
@@ -97,6 +97,13 @@ test("failing when map is bigger than max() ", () => {
|
|
|
97
97
|
expect(result.success).toEqual(false);
|
|
98
98
|
expect(result.error!.issues.length).toEqual(1);
|
|
99
99
|
expect(result.error!.issues[0].code).toEqual("too_big");
|
|
100
|
+
const bad = new Map([
|
|
101
|
+
[1, 1],
|
|
102
|
+
[2, 2],
|
|
103
|
+
]);
|
|
104
|
+
const capped = z.map(z.string(), z.string()).max(1);
|
|
105
|
+
expect(capped.safeParse(bad).error!.issues).toMatchObject([{ code: "too_big" }]);
|
|
106
|
+
expect(capped.safeParse(new Set([1, 2])).error!.issues[0]).toMatchObject({ code: "invalid_type", expected: "map" });
|
|
100
107
|
});
|
|
101
108
|
|
|
102
109
|
test("failing when map does not match size() ", () => {
|
|
@@ -83,6 +83,12 @@ test("failing when set is bigger than max() ", () => {
|
|
|
83
83
|
expect(result.success).toEqual(false);
|
|
84
84
|
expect(result.error!.issues.length).toEqual(1);
|
|
85
85
|
expect(result.error!.issues[0].code).toEqual("too_big");
|
|
86
|
+
expect(
|
|
87
|
+
z
|
|
88
|
+
.set(z.string())
|
|
89
|
+
.max(1)
|
|
90
|
+
.safeParse(new Set([1, 2])).error!.issues
|
|
91
|
+
).toMatchObject([{ code: "too_big" }]);
|
|
86
92
|
});
|
|
87
93
|
|
|
88
94
|
test("failing when set does not match size() ", () => {
|
|
@@ -1551,6 +1551,12 @@ function generateNullableCheck(
|
|
|
1551
1551
|
return outputVar;
|
|
1552
1552
|
}
|
|
1553
1553
|
|
|
1554
|
+
function generateSizeGate(doc: Doc, schema: SomeType, size: string): void {
|
|
1555
|
+
for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
|
|
1556
|
+
doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1554
1560
|
function generateArrayCheck(
|
|
1555
1561
|
doc: Doc,
|
|
1556
1562
|
ctx: CompileContext,
|
|
@@ -1560,6 +1566,7 @@ function generateArrayCheck(
|
|
|
1560
1566
|
): string | null {
|
|
1561
1567
|
const def = schema._zod.def as unknown as { element: SomeType };
|
|
1562
1568
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
1569
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
1563
1570
|
|
|
1564
1571
|
// Build a new array with validated/transformed elements.
|
|
1565
1572
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
@@ -2094,6 +2101,7 @@ function generateMapCheck(doc: Doc, ctx: CompileContext, schema: SomeType, acces
|
|
|
2094
2101
|
const def = schema._zod.def as unknown as { keyType: SomeType; valueType: SomeType };
|
|
2095
2102
|
|
|
2096
2103
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
2104
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
2097
2105
|
|
|
2098
2106
|
const outputVar = newVar(ctx);
|
|
2099
2107
|
const kVar = newVar(ctx);
|
|
@@ -2115,6 +2123,7 @@ function generateSetCheck(doc: Doc, ctx: CompileContext, schema: SomeType, acces
|
|
|
2115
2123
|
const def = schema._zod.def as unknown as { valueType: SomeType };
|
|
2116
2124
|
|
|
2117
2125
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
2126
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
2118
2127
|
|
|
2119
2128
|
const outputVar = newVar(ctx);
|
|
2120
2129
|
const valVar = newVar(ctx);
|
|
@@ -1844,6 +1844,34 @@ export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$Zod
|
|
|
1844
1844
|
|
|
1845
1845
|
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
|
|
1846
1846
|
|
|
1847
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
1848
|
+
function capSize(inst: $ZodType, size: (input: any) => number): void {
|
|
1849
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
1850
|
+
if (!caps.length) return;
|
|
1851
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
1852
|
+
const parse = inst._zod.parse;
|
|
1853
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1854
|
+
const n = size(payload.value);
|
|
1855
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
1856
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
1857
|
+
if (n > max && ch._zod.def.when!(payload)) {
|
|
1858
|
+
const start = payload.issues.length;
|
|
1859
|
+
ch._zod.check(payload as ParsePayload<never>);
|
|
1860
|
+
// the value is still the raw input, so no later check may read it
|
|
1861
|
+
(payload.issues[start] as { continue?: boolean }).continue = false;
|
|
1862
|
+
util.attachSchema(payload.issues, start, inst);
|
|
1863
|
+
return payload;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return parse(payload, ctx);
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
const arraySize = (input: unknown): number => (Array.isArray(input) ? input.length : -1);
|
|
1872
|
+
const mapSize = (input: unknown): number => (input instanceof Map ? input.size : -1);
|
|
1873
|
+
const setSize = (input: unknown): number => (input instanceof Set ? input.size : -1);
|
|
1874
|
+
|
|
1847
1875
|
function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
|
|
1848
1876
|
if (result.issues.length) {
|
|
1849
1877
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -1899,6 +1927,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1899
1927
|
|
|
1900
1928
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
1901
1929
|
};
|
|
1930
|
+
capSize(inst, arraySize);
|
|
1902
1931
|
});
|
|
1903
1932
|
|
|
1904
1933
|
//////////////////////////////////////////
|
|
@@ -3218,8 +3247,11 @@ export type $InferZodRecordInput<
|
|
|
3218
3247
|
: Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
|
3219
3248
|
|
|
3220
3249
|
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
|
|
3221
|
-
extends $ZodTypeInternals
|
|
3250
|
+
extends $ZodTypeInternals {
|
|
3222
3251
|
def: $ZodRecordDef<Key, Value>;
|
|
3252
|
+
// members rather than base type arguments, which TypeScript 7.1 reports as circular for `z.json()`
|
|
3253
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
3254
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
3223
3255
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
3224
3256
|
optin?: "optional" | undefined;
|
|
3225
3257
|
optout?: "optional" | undefined;
|
|
@@ -3480,6 +3512,7 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
|
|
|
3480
3512
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
3481
3513
|
return payload;
|
|
3482
3514
|
};
|
|
3515
|
+
capSize(inst, mapSize);
|
|
3483
3516
|
});
|
|
3484
3517
|
|
|
3485
3518
|
function handleMapResult(
|
|
@@ -3582,6 +3615,7 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
|
|
|
3582
3615
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
3583
3616
|
return payload;
|
|
3584
3617
|
};
|
|
3618
|
+
capSize(inst, setSize);
|
|
3585
3619
|
});
|
|
3586
3620
|
|
|
3587
3621
|
function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
|