openmausbot 0.1.86 → 0.1.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/assets/{abnfDiagram-O67JEVCF-DpUZNnFD.js → abnfDiagram-O67JEVCF-BTiuL79F.js} +1 -1
- package/dist/assets/{arc-DW7mrI4p.js → arc-C88Blc2v.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-CyeZ5WLZ.js → architectureDiagram-NJMV4G6O-BZsJIZrb.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-CBVaNjO7.js → blockDiagram-BEXU5L5S-CVeMe9Ah.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-sf8d41uT.js → c4Diagram-YGBWAQC7-Cedk3Bhx.js} +1 -1
- package/dist/assets/channel-taCNRlUU.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-BOGvy7Y_.js → chunk-2Q5K7J3B-D-VRqzTB.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BiF9zyiz.js → chunk-3FUC2YCW-BChov01Y.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-EFuZ1SBZ.js → chunk-5VM5RSS4-C-TfwvHy.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-pJLNSAT7.js → chunk-GTNCS2PH-Db7CGj5Y.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-Cb-3_3IT.js → chunk-GWA4HPMP-CNvIfqKT.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-DAf5aogn.js → chunk-JWPE2WC7-C_bEp5tq.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-DR3kiwZz.js → chunk-NETBCI7D-Coi4BOls.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-BmU8PeyM.js → chunk-WEXAMYUT-CzylEuL3.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Buh8g8OT.js → chunk-XXDRQBXY-m7p7ztaD.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-BurfmMWM.js → classDiagram-v2-NBCMYWYE-BMy6o9x2.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-KkGZUEkU.js → cose-bilkent-JH36ORCC-BDQ__0_J.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-C3PpV96d.js → cynefin-OW5HDTMX-Djv4ghUb.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-Dt8JwJaI.js → cynefinDiagram-VND7K2PF-BULrlGYH.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-DkjN8266.js → dagre-6A5THRUB-D-jrT_hU.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DUAJS0JV.js → diagram-22UHCM2B-p2UhQmfL.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-Dw4KhF1a.js → diagram-3UASUU5V-DHvGWZ7q.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-Dd1gmQqf.js → diagram-ATOU4E4O-ChhKDot-.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-CjwGs0Yw.js → diagram-CDSNMT55-B-T7A43R.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-BL-69Zrq.js → diagram-MLGK6HIB-CJm8ENNY.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-5Zi2N7wo.js → diagram-MPIPVDR6-510tlza8.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-D9NekWUX.js → ebnfDiagram-ZINNZB2B-PkvRPHel.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-CkaSQjxw.js → elk-276RUBZZ-BVBVPoX3.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-CdAVBV8-.js → erDiagram-OPXOYQCR-BgYMVm7L.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-Bm_lWWH7.js → flowDiagram-KWPJA3E3-BGqsnc_3.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-FZ8ejYWJ.js → ganttDiagram-FUAMR5RP-D_-UeReH.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-Dlv9rizZ.js → gitGraphDiagram-X574FWY7-D0uooONx.js} +1 -1
- package/dist/assets/index-BwdMAQ6p.css +1 -0
- package/dist/assets/index-ByJennr7.js +581 -0
- package/dist/assets/{index-h9FFNwTu.js → index-zRsJERGJ.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-BdQ_gW5B.js → infoDiagram-VRGFBTTK-B9e1z77f.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-EwssEp2X.js → ishikawaDiagram-OU5B5YK6-BB4vNwvD.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-BX1G1vOd.js → journeyDiagram-ZHPQQLJL-DpkosOTB.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-BB4kAsyC.js → kanban-definition-PNTS6WVX-DbDP4kUu.js} +1 -1
- package/dist/assets/{linear-3su2TG93.js → linear-DBJGPmjT.js} +1 -1
- package/dist/assets/{mermaid.core-CDD1E0s9.js → mermaid.core-DWPRi-ue.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-Ba50MsNK.js → mindmap-definition-NLK3R4M7-nszBbJmx.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-DZLkkZlM.js → pegDiagram-GJSIUBJH-CWykJWu_.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DaTz77Uq.js → pieDiagram-5QR66LMP-g3Da-Vnv.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-CpaiidpR.js → quadrantDiagram-O4NWA36T-Wzrlpzgh.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-mN4JrMeI.js → railroadDiagram-XR7U4H2S-moHTFMC0.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-BSNDRpg7.js → requirementDiagram-PLB6GJNP-CwfXdFH8.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-FngzGNug.js → sankeyDiagram-IPEJSGJF-3ZROYvnq.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-CM4pCC3L.js → sequenceDiagram-PO4LG4MO-E1TBebP8.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-CRICHXkw.js → sizeCapture-INFHLROL-DHKEU5pu.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-oyTWpxH2.js → stateDiagram-v2-GCMORJYK-BguEj09D.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-D9h9mPBq.js → swimlanes-2SLR337P-C7IDYnhd.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BpEdoB2e.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-BJUlN9bW.js → timeline-definition-EJHVYXUP-DCW-F5PW.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-3uBNkbAb.js → usecaseDiagram-POWQR4AR-xBMFtWYV.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-D2odalzT.js → vennDiagram-UO4OBE2U-B5nIkuH8.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-DHgFaB9S.js → wardleyDiagram-VNRHLVJA-DYFAhdbr.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-w5GYM2h0.js → xychartDiagram-PMCCYNJV-DeXwX6Cz.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/browser-proxy.js +2 -1
- package/dist-server/container-mcp.js +1029 -164
- package/dist-server/drivers/agents-proxy.js +64 -10
- package/dist-server/drivers/phone-proxy.js +33 -2
- package/dist-server/index.js +14577 -9001
- package/dist-server/local-computer-proxy.js +3 -3
- package/dist-server/local-computer.js +53 -17
- package/dist-server/openmausbot.js +3981 -1165
- package/dist-server/pair-cli.js +3981 -1165
- package/dist-server/permission-proxy.js +29 -9
- package/dist-server/server/attachments.js +55 -0
- package/dist-server/server/auto-approve.js +4 -3
- package/dist-server/server/auto-vm-claims.js +1 -0
- package/dist-server/server/bot-package.js +18 -292
- package/dist-server/server/bot-profile.js +5 -17
- package/dist-server/server/box-create-idempotency.js +3 -3
- package/dist-server/server/box.js +57 -55
- package/dist-server/server/browser-proxy.js +3 -2
- package/dist-server/server/browser-runtime.js +37 -1
- package/dist-server/server/cli.js +2 -2
- package/dist-server/server/command-allowlist.js +154 -0
- package/dist-server/server/computer-wait.js +22 -9
- package/dist-server/server/config.js +59 -9
- package/dist-server/server/connector-verdict.js +141 -0
- package/dist-server/server/container-computer.js +1 -1
- package/dist-server/server/default-model-selection.js +9 -0
- package/dist-server/server/delegations.js +85 -34
- package/dist-server/server/drivers/acp/core.js +57 -15
- package/dist-server/server/drivers/agents-call.js +42 -3
- package/dist-server/server/drivers/agents-catalog.js +34 -4
- package/dist-server/server/drivers/boxagent.js +174 -36
- package/dist-server/server/drivers/builtIn.js +2 -0
- package/dist-server/server/drivers/chat-box-tools.js +90 -0
- package/dist-server/server/drivers/chat-images.js +54 -0
- package/dist-server/server/drivers/chat-mcp-tools.js +38 -8
- package/dist-server/server/drivers/chat-tool-approval.js +70 -18
- package/dist-server/server/drivers/claude.js +7 -2
- package/dist-server/server/drivers/codex-instructions.js +48 -6
- package/dist-server/server/drivers/codex-tool-surface.js +20 -0
- package/dist-server/server/drivers/codex.js +95 -30
- package/dist-server/server/drivers/mistral.js +115 -0
- package/dist-server/server/drivers/openai-chat.js +155 -32
- package/dist-server/server/drivers/openai-compat.js +1 -0
- package/dist-server/server/drivers/permission-command.js +35 -0
- package/dist-server/server/drivers/phone-proxy.js +47 -2
- package/dist-server/server/drivers/pi.js +75 -4
- package/dist-server/server/drivers/prompt-split.js +87 -0
- package/dist-server/server/fleet.js +1 -1
- package/dist-server/server/group-thread-usage.js +103 -0
- package/dist-server/server/harness/registry.js +1 -0
- package/dist-server/server/hosted-models.js +1 -1
- package/dist-server/server/index.js +1385 -322
- package/dist-server/server/local-computer.js +72 -23
- package/dist-server/server/managed-desktop.js +1 -1
- package/dist-server/server/mcp-bridge.js +6 -6
- package/dist-server/server/new-bot-defaults.js +115 -0
- package/dist-server/server/org-library.js +1051 -0
- package/dist-server/server/package-export.js +627 -39
- package/dist-server/server/package-import.js +458 -0
- package/dist-server/server/package-parts.js +87 -0
- package/dist-server/server/peer-approval.js +16 -7
- package/dist-server/server/peer-roster.js +10 -0
- package/dist-server/server/presets.js +492 -0
- package/dist-server/server/provider-key-check.js +3 -2
- package/dist-server/server/published-teams.js +80 -0
- package/dist-server/server/room-handoffs.js +19 -3
- package/dist-server/server/routes/bot-presets.js +25 -0
- package/dist-server/server/routine-requests.js +6 -3
- package/dist-server/server/routines.js +41 -1
- package/dist-server/server/section-context.js +10 -0
- package/dist-server/server/skills.js +34 -61
- package/dist-server/server/steer-queue.js +3 -2
- package/dist-server/server/store.js +259 -15
- package/dist-server/server/surface.js +10 -4
- package/dist-server/server/system-prompt.js +12 -4
- package/dist-server/server/team-backup.js +6 -2
- package/dist-server/server/team-computers.js +10 -0
- package/dist-server/server/team-library.js +6 -2
- package/dist-server/server/team-manifest.js +4 -3
- package/dist-server/server/team-setup-requests.js +16 -5
- package/dist-server/server/thread-events.js +17 -1
- package/dist-server/server/turn-context.js +2 -0
- package/dist-server/server/turn-watchdog.js +12 -3
- package/dist-server/server/usage-ledger.js +12 -1
- package/dist-server/server/vps-computer.js +139 -51
- package/dist-server/server/vps-container-mcp.js +7 -0
- package/dist-server/server/vps-ssh.js +36 -7
- package/dist-server/server/workspace-backup-policy.js +12 -0
- package/dist-server/server/workspace-backup.js +2 -2
- package/dist-server/server/workspace.js +1 -1
- package/dist-server/shared/approval-mode.js +1 -1
- package/dist-server/shared/ask-question.js +188 -12
- package/dist-server/shared/bot-profile.js +15 -0
- package/dist-server/shared/command-allowlist.js +1 -0
- package/dist-server/shared/credential-request.js +1 -1
- package/dist-server/shared/package-format.js +967 -0
- package/dist-server/shared/skill-md.js +64 -0
- package/dist-server/shared/team-backup.js +7 -0
- package/dist-server/shared/wire.js +4 -0
- package/dist-server/vps-container-mcp.js +1129 -170
- package/enterprise/README.md +1 -1
- package/package.json +1 -1
- package/dist/assets/channel-BXFkgus9.js +0 -1
- package/dist/assets/index-BGgqlWPJ.css +0 -1
- package/dist/assets/index-BtHo8ZKl.js +0 -577
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BWrvB2ak.js +0 -8
|
@@ -85,7 +85,7 @@ import { basename, delimiter, dirname, extname, join } from "node:path";
|
|
|
85
85
|
function nvmBinDirs() {
|
|
86
86
|
try {
|
|
87
87
|
const base = join(homedir(), ".nvm", "versions", "node");
|
|
88
|
-
return readdirSync(base).filter((
|
|
88
|
+
return readdirSync(base).filter((v2) => v2.startsWith("v")).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true })).map((v2) => join(base, v2, "bin"));
|
|
89
89
|
} catch {
|
|
90
90
|
return [];
|
|
91
91
|
}
|
|
@@ -175,10 +175,10 @@ function probeLoginShellPath() {
|
|
|
175
175
|
{ timeout: 5e3 },
|
|
176
176
|
(err, stdout) => {
|
|
177
177
|
if (err || !stdout) return;
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
-
loginShellPath =
|
|
181
|
-
cached = mergePaths([...(cached ?? "").split(delimiter), ...
|
|
178
|
+
const m2 = /__OMB_PATH__([^\n]*)/.exec(stdout);
|
|
179
|
+
if (!m2 || !m2[1]) return;
|
|
180
|
+
loginShellPath = m2[1];
|
|
181
|
+
cached = mergePaths([...(cached ?? "").split(delimiter), ...m2[1].split(delimiter)]);
|
|
182
182
|
}
|
|
183
183
|
);
|
|
184
184
|
}
|
|
@@ -266,25 +266,25 @@ function createToolListNormalizer() {
|
|
|
266
266
|
// server/mcp-bridge.ts
|
|
267
267
|
var BRIDGE_INACTIVITY_MS = 45e3;
|
|
268
268
|
var PROBE_TIMEOUT_MS = 1e4;
|
|
269
|
-
function runLivenessProbe(probe, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
270
|
-
return new Promise((
|
|
269
|
+
function runLivenessProbe(probe, timeoutMs = PROBE_TIMEOUT_MS, env) {
|
|
270
|
+
return new Promise((resolve3) => {
|
|
271
271
|
const child = spawn(probe.command, probe.args, {
|
|
272
272
|
shell: false,
|
|
273
|
-
env: { ...process.env, PATH: augmentedPath() },
|
|
273
|
+
env: env ?? { ...process.env, PATH: augmentedPath() },
|
|
274
274
|
stdio: ["ignore", "ignore", "ignore"]
|
|
275
275
|
});
|
|
276
276
|
const timer = setTimeout(() => {
|
|
277
277
|
child.kill("SIGKILL");
|
|
278
|
-
|
|
278
|
+
resolve3(false);
|
|
279
279
|
}, timeoutMs);
|
|
280
280
|
timer.unref?.();
|
|
281
281
|
child.on("error", () => {
|
|
282
282
|
clearTimeout(timer);
|
|
283
|
-
|
|
283
|
+
resolve3(false);
|
|
284
284
|
});
|
|
285
285
|
child.on("close", (code) => {
|
|
286
286
|
clearTimeout(timer);
|
|
287
|
-
|
|
287
|
+
resolve3(code === 0);
|
|
288
288
|
});
|
|
289
289
|
});
|
|
290
290
|
}
|
|
@@ -457,7 +457,7 @@ function runMcpBridge(options) {
|
|
|
457
457
|
const liveness = options.liveness;
|
|
458
458
|
watchdog = createInactivityWatchdog({
|
|
459
459
|
inactivityMs: BRIDGE_INACTIVITY_MS,
|
|
460
|
-
probe: () => runLivenessProbe(liveness),
|
|
460
|
+
probe: () => runLivenessProbe(liveness, PROBE_TIMEOUT_MS, options.env),
|
|
461
461
|
onDead: () => {
|
|
462
462
|
process.stderr.write(
|
|
463
463
|
`${options.label} transport went silent and stopped answering liveness probes; ending the bridge
|
|
@@ -1037,7 +1037,7 @@ function $constructor(name, initializer3, params) {
|
|
|
1037
1037
|
Object.defineProperty(inst, "_zod", {
|
|
1038
1038
|
value: {
|
|
1039
1039
|
def,
|
|
1040
|
-
constr:
|
|
1040
|
+
constr: _2,
|
|
1041
1041
|
traits: /* @__PURE__ */ new Set()
|
|
1042
1042
|
},
|
|
1043
1043
|
enumerable: false
|
|
@@ -1048,12 +1048,12 @@ function $constructor(name, initializer3, params) {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
inst._zod.traits.add(name);
|
|
1050
1050
|
initializer3(inst, def);
|
|
1051
|
-
const proto =
|
|
1051
|
+
const proto = _2.prototype;
|
|
1052
1052
|
const keys = Object.keys(proto);
|
|
1053
1053
|
for (let i = 0; i < keys.length; i++) {
|
|
1054
|
-
const
|
|
1055
|
-
if (!(
|
|
1056
|
-
inst[
|
|
1054
|
+
const k2 = keys[i];
|
|
1055
|
+
if (!(k2 in inst)) {
|
|
1056
|
+
inst[k2] = proto[k2].bind(inst);
|
|
1057
1057
|
}
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
@@ -1061,7 +1061,7 @@ function $constructor(name, initializer3, params) {
|
|
|
1061
1061
|
class Definition extends Parent {
|
|
1062
1062
|
}
|
|
1063
1063
|
Object.defineProperty(Definition, "name", { value: name });
|
|
1064
|
-
function
|
|
1064
|
+
function _2(def) {
|
|
1065
1065
|
var _a3;
|
|
1066
1066
|
const inst = params?.Parent ? new Definition() : this;
|
|
1067
1067
|
init(inst, def);
|
|
@@ -1071,16 +1071,16 @@ function $constructor(name, initializer3, params) {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
return inst;
|
|
1073
1073
|
}
|
|
1074
|
-
Object.defineProperty(
|
|
1075
|
-
Object.defineProperty(
|
|
1074
|
+
Object.defineProperty(_2, "init", { value: init });
|
|
1075
|
+
Object.defineProperty(_2, Symbol.hasInstance, {
|
|
1076
1076
|
value: (inst) => {
|
|
1077
1077
|
if (params?.Parent && inst instanceof params.Parent)
|
|
1078
1078
|
return true;
|
|
1079
1079
|
return inst?._zod?.traits?.has(name);
|
|
1080
1080
|
}
|
|
1081
1081
|
});
|
|
1082
|
-
Object.defineProperty(
|
|
1083
|
-
return
|
|
1082
|
+
Object.defineProperty(_2, "name", { value: name });
|
|
1083
|
+
return _2;
|
|
1084
1084
|
}
|
|
1085
1085
|
var $brand = /* @__PURE__ */ Symbol("zod_brand");
|
|
1086
1086
|
var $ZodAsyncError = class extends Error {
|
|
@@ -1180,17 +1180,17 @@ function assertIs(_arg) {
|
|
|
1180
1180
|
function assertNever(_x) {
|
|
1181
1181
|
throw new Error("Unexpected value in exhaustive check");
|
|
1182
1182
|
}
|
|
1183
|
-
function assert(
|
|
1183
|
+
function assert(_2) {
|
|
1184
1184
|
}
|
|
1185
1185
|
function getEnumValues(entries) {
|
|
1186
|
-
const numericValues = Object.values(entries).filter((
|
|
1187
|
-
const values = Object.entries(entries).filter(([
|
|
1186
|
+
const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
|
|
1187
|
+
const values = Object.entries(entries).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
|
|
1188
1188
|
return values;
|
|
1189
1189
|
}
|
|
1190
1190
|
function joinValues(array2, separator = "|") {
|
|
1191
1191
|
return array2.map((val) => stringifyPrimitive(val)).join(separator);
|
|
1192
1192
|
}
|
|
1193
|
-
function jsonStringifyReplacer(
|
|
1193
|
+
function jsonStringifyReplacer(_2, value) {
|
|
1194
1194
|
if (typeof value === "bigint")
|
|
1195
1195
|
return value.toString();
|
|
1196
1196
|
return value;
|
|
@@ -1238,9 +1238,9 @@ function defineLazy(object2, key, getter) {
|
|
|
1238
1238
|
}
|
|
1239
1239
|
return value;
|
|
1240
1240
|
},
|
|
1241
|
-
set(
|
|
1241
|
+
set(v2) {
|
|
1242
1242
|
Object.defineProperty(object2, key, {
|
|
1243
|
-
value:
|
|
1243
|
+
value: v2
|
|
1244
1244
|
// configurable: true,
|
|
1245
1245
|
});
|
|
1246
1246
|
},
|
|
@@ -1315,7 +1315,7 @@ var allowsEval = /* @__PURE__ */ cached2(() => {
|
|
|
1315
1315
|
const F = Function;
|
|
1316
1316
|
new F("");
|
|
1317
1317
|
return true;
|
|
1318
|
-
} catch (
|
|
1318
|
+
} catch (_2) {
|
|
1319
1319
|
return false;
|
|
1320
1320
|
}
|
|
1321
1321
|
});
|
|
@@ -1436,31 +1436,31 @@ function normalizeParams(_params) {
|
|
|
1436
1436
|
function createTransparentProxy(getter) {
|
|
1437
1437
|
let target;
|
|
1438
1438
|
return new Proxy({}, {
|
|
1439
|
-
get(
|
|
1439
|
+
get(_2, prop, receiver) {
|
|
1440
1440
|
target ?? (target = getter());
|
|
1441
1441
|
return Reflect.get(target, prop, receiver);
|
|
1442
1442
|
},
|
|
1443
|
-
set(
|
|
1443
|
+
set(_2, prop, value, receiver) {
|
|
1444
1444
|
target ?? (target = getter());
|
|
1445
1445
|
return Reflect.set(target, prop, value, receiver);
|
|
1446
1446
|
},
|
|
1447
|
-
has(
|
|
1447
|
+
has(_2, prop) {
|
|
1448
1448
|
target ?? (target = getter());
|
|
1449
1449
|
return Reflect.has(target, prop);
|
|
1450
1450
|
},
|
|
1451
|
-
deleteProperty(
|
|
1451
|
+
deleteProperty(_2, prop) {
|
|
1452
1452
|
target ?? (target = getter());
|
|
1453
1453
|
return Reflect.deleteProperty(target, prop);
|
|
1454
1454
|
},
|
|
1455
|
-
ownKeys(
|
|
1455
|
+
ownKeys(_2) {
|
|
1456
1456
|
target ?? (target = getter());
|
|
1457
1457
|
return Reflect.ownKeys(target);
|
|
1458
1458
|
},
|
|
1459
|
-
getOwnPropertyDescriptor(
|
|
1459
|
+
getOwnPropertyDescriptor(_2, prop) {
|
|
1460
1460
|
target ?? (target = getter());
|
|
1461
1461
|
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
1462
1462
|
},
|
|
1463
|
-
defineProperty(
|
|
1463
|
+
defineProperty(_2, prop, descriptor) {
|
|
1464
1464
|
target ?? (target = getter());
|
|
1465
1465
|
return Reflect.defineProperty(target, prop, descriptor);
|
|
1466
1466
|
}
|
|
@@ -1474,8 +1474,8 @@ function stringifyPrimitive(value) {
|
|
|
1474
1474
|
return `${value}`;
|
|
1475
1475
|
}
|
|
1476
1476
|
function optionalKeys(shape) {
|
|
1477
|
-
return Object.keys(shape).filter((
|
|
1478
|
-
return shape[
|
|
1477
|
+
return Object.keys(shape).filter((k2) => {
|
|
1478
|
+
return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
|
|
1479
1479
|
});
|
|
1480
1480
|
}
|
|
1481
1481
|
var NUMBER_FORMAT_RANGES = {
|
|
@@ -1575,20 +1575,20 @@ function safeExtend(schema, shape) {
|
|
|
1575
1575
|
});
|
|
1576
1576
|
return clone(schema, def);
|
|
1577
1577
|
}
|
|
1578
|
-
function merge(a,
|
|
1578
|
+
function merge(a, b2) {
|
|
1579
1579
|
if (a._zod.def.checks?.length) {
|
|
1580
1580
|
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
1581
1581
|
}
|
|
1582
1582
|
const def = mergeDefs(a._zod.def, {
|
|
1583
1583
|
get shape() {
|
|
1584
|
-
const _shape = { ...a._zod.def.shape, ...
|
|
1584
|
+
const _shape = { ...a._zod.def.shape, ...b2._zod.def.shape };
|
|
1585
1585
|
assignProp(this, "shape", _shape);
|
|
1586
1586
|
return _shape;
|
|
1587
1587
|
},
|
|
1588
1588
|
get catchall() {
|
|
1589
|
-
return
|
|
1589
|
+
return b2._zod.def.catchall;
|
|
1590
1590
|
},
|
|
1591
|
-
checks:
|
|
1591
|
+
checks: b2._zod.def.checks ?? []
|
|
1592
1592
|
});
|
|
1593
1593
|
return clone(a, def);
|
|
1594
1594
|
}
|
|
@@ -1661,21 +1661,21 @@ function required(Class2, schema, mask) {
|
|
|
1661
1661
|
});
|
|
1662
1662
|
return clone(schema, def);
|
|
1663
1663
|
}
|
|
1664
|
-
function aborted(
|
|
1665
|
-
if (
|
|
1664
|
+
function aborted(x2, startIndex = 0) {
|
|
1665
|
+
if (x2.aborted === true)
|
|
1666
1666
|
return true;
|
|
1667
|
-
for (let i = startIndex; i <
|
|
1668
|
-
if (
|
|
1667
|
+
for (let i = startIndex; i < x2.issues.length; i++) {
|
|
1668
|
+
if (x2.issues[i]?.continue !== true) {
|
|
1669
1669
|
return true;
|
|
1670
1670
|
}
|
|
1671
1671
|
}
|
|
1672
1672
|
return false;
|
|
1673
1673
|
}
|
|
1674
|
-
function explicitlyAborted(
|
|
1675
|
-
if (
|
|
1674
|
+
function explicitlyAborted(x2, startIndex = 0) {
|
|
1675
|
+
if (x2.aborted === true)
|
|
1676
1676
|
return true;
|
|
1677
|
-
for (let i = startIndex; i <
|
|
1678
|
-
if (
|
|
1677
|
+
for (let i = startIndex; i < x2.issues.length; i++) {
|
|
1678
|
+
if (x2.issues[i]?.continue === false) {
|
|
1679
1679
|
return true;
|
|
1680
1680
|
}
|
|
1681
1681
|
}
|
|
@@ -1752,8 +1752,8 @@ function issue(...args2) {
|
|
|
1752
1752
|
return { ...iss };
|
|
1753
1753
|
}
|
|
1754
1754
|
function cleanEnum(obj) {
|
|
1755
|
-
return Object.entries(obj).filter(([
|
|
1756
|
-
return Number.isNaN(Number.parseInt(
|
|
1755
|
+
return Object.entries(obj).filter(([k2, _2]) => {
|
|
1756
|
+
return Number.isNaN(Number.parseInt(k2, 10));
|
|
1757
1757
|
}).map((el) => el[1]);
|
|
1758
1758
|
}
|
|
1759
1759
|
function base64ToUint8Array(base643) {
|
|
@@ -1791,7 +1791,7 @@ function hexToUint8Array(hex3) {
|
|
|
1791
1791
|
return bytes;
|
|
1792
1792
|
}
|
|
1793
1793
|
function uint8ArrayToHex(bytes) {
|
|
1794
|
-
return Array.from(bytes).map((
|
|
1794
|
+
return Array.from(bytes).map((b2) => b2.toString(16).padStart(2, "0")).join("");
|
|
1795
1795
|
}
|
|
1796
1796
|
var Class = class {
|
|
1797
1797
|
constructor(..._args) {
|
|
@@ -1928,7 +1928,7 @@ function toDotPath(_path) {
|
|
|
1928
1928
|
}
|
|
1929
1929
|
function prettifyError(error51) {
|
|
1930
1930
|
const lines = [];
|
|
1931
|
-
const issues = [...error51.issues].sort((a,
|
|
1931
|
+
const issues = [...error51.issues].sort((a, b2) => (a.path ?? []).length - (b2.path ?? []).length);
|
|
1932
1932
|
for (const issue2 of issues) {
|
|
1933
1933
|
lines.push(`\u2716 ${issue2.message}`);
|
|
1934
1934
|
if (issue2.path?.length)
|
|
@@ -2117,8 +2117,8 @@ function emoji() {
|
|
|
2117
2117
|
}
|
|
2118
2118
|
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
2119
2119
|
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
2120
|
-
var mac = (
|
|
2121
|
-
const escapedDelim = escapeRegex(
|
|
2120
|
+
var mac = (delimiter3) => {
|
|
2121
|
+
const escapedDelim = escapeRegex(delimiter3 ?? ":");
|
|
2122
2122
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
2123
2123
|
};
|
|
2124
2124
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -2752,9 +2752,9 @@ var Doc = class {
|
|
|
2752
2752
|
return;
|
|
2753
2753
|
}
|
|
2754
2754
|
const content = arg;
|
|
2755
|
-
const lines = content.split("\n").filter((
|
|
2756
|
-
const minIndent = Math.min(...lines.map((
|
|
2757
|
-
const dedented = lines.map((
|
|
2755
|
+
const lines = content.split("\n").filter((x2) => x2);
|
|
2756
|
+
const minIndent = Math.min(...lines.map((x2) => x2.length - x2.trimStart().length));
|
|
2757
|
+
const dedented = lines.map((x2) => x2.slice(minIndent)).map((x2) => " ".repeat(this.indent * 2) + x2);
|
|
2758
2758
|
for (const line of dedented) {
|
|
2759
2759
|
this.content.push(line);
|
|
2760
2760
|
}
|
|
@@ -2763,7 +2763,7 @@ var Doc = class {
|
|
|
2763
2763
|
const F = Function;
|
|
2764
2764
|
const args2 = this?.args;
|
|
2765
2765
|
const content = this?.content ?? [``];
|
|
2766
|
-
const lines = [...content.map((
|
|
2766
|
+
const lines = [...content.map((x2) => ` ${x2}`)];
|
|
2767
2767
|
return new F(...args2, lines.join("\n"));
|
|
2768
2768
|
}
|
|
2769
2769
|
};
|
|
@@ -2811,13 +2811,13 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
2811
2811
|
continue;
|
|
2812
2812
|
}
|
|
2813
2813
|
const currLen = payload.issues.length;
|
|
2814
|
-
const
|
|
2815
|
-
if (
|
|
2814
|
+
const _2 = ch._zod.check(payload);
|
|
2815
|
+
if (_2 instanceof Promise && ctx?.async === false) {
|
|
2816
2816
|
throw new $ZodAsyncError();
|
|
2817
2817
|
}
|
|
2818
|
-
if (asyncResult ||
|
|
2818
|
+
if (asyncResult || _2 instanceof Promise) {
|
|
2819
2819
|
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
2820
|
-
await
|
|
2820
|
+
await _2;
|
|
2821
2821
|
const nextLen = payload.issues.length;
|
|
2822
2822
|
if (nextLen === currLen)
|
|
2823
2823
|
return;
|
|
@@ -2879,7 +2879,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
2879
2879
|
try {
|
|
2880
2880
|
const r = safeParse(inst, value);
|
|
2881
2881
|
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
2882
|
-
} catch (
|
|
2882
|
+
} catch (_2) {
|
|
2883
2883
|
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
2884
2884
|
}
|
|
2885
2885
|
},
|
|
@@ -2890,11 +2890,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
2890
2890
|
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
2891
2891
|
$ZodType.init(inst, def);
|
|
2892
2892
|
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
|
|
2893
|
-
inst._zod.parse = (payload,
|
|
2893
|
+
inst._zod.parse = (payload, _2) => {
|
|
2894
2894
|
if (def.coerce)
|
|
2895
2895
|
try {
|
|
2896
2896
|
payload.value = String(payload.value);
|
|
2897
|
-
} catch (
|
|
2897
|
+
} catch (_3) {
|
|
2898
2898
|
}
|
|
2899
2899
|
if (typeof payload.value === "string")
|
|
2900
2900
|
return payload;
|
|
@@ -2927,10 +2927,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
|
2927
2927
|
v7: 7,
|
|
2928
2928
|
v8: 8
|
|
2929
2929
|
};
|
|
2930
|
-
const
|
|
2931
|
-
if (
|
|
2930
|
+
const v2 = versionMap[def.version];
|
|
2931
|
+
if (v2 === void 0)
|
|
2932
2932
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
2933
|
-
def.pattern ?? (def.pattern = uuid(
|
|
2933
|
+
def.pattern ?? (def.pattern = uuid(v2));
|
|
2934
2934
|
} else
|
|
2935
2935
|
def.pattern ?? (def.pattern = uuid());
|
|
2936
2936
|
$ZodStringFormat.init(inst, def);
|
|
@@ -2992,7 +2992,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
2992
2992
|
payload.value = trimmed;
|
|
2993
2993
|
}
|
|
2994
2994
|
return;
|
|
2995
|
-
} catch (
|
|
2995
|
+
} catch (_2) {
|
|
2996
2996
|
payload.issues.push({
|
|
2997
2997
|
code: "invalid_format",
|
|
2998
2998
|
format: "url",
|
|
@@ -3219,7 +3219,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
3219
3219
|
if (def.coerce)
|
|
3220
3220
|
try {
|
|
3221
3221
|
payload.value = Number(payload.value);
|
|
3222
|
-
} catch (
|
|
3222
|
+
} catch (_2) {
|
|
3223
3223
|
}
|
|
3224
3224
|
const input = payload.value;
|
|
3225
3225
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
@@ -3247,7 +3247,7 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
3247
3247
|
if (def.coerce)
|
|
3248
3248
|
try {
|
|
3249
3249
|
payload.value = Boolean(payload.value);
|
|
3250
|
-
} catch (
|
|
3250
|
+
} catch (_2) {
|
|
3251
3251
|
}
|
|
3252
3252
|
const input = payload.value;
|
|
3253
3253
|
if (typeof input === "boolean")
|
|
@@ -3268,7 +3268,7 @@ var $ZodBigInt = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) => {
|
|
|
3268
3268
|
if (def.coerce)
|
|
3269
3269
|
try {
|
|
3270
3270
|
payload.value = BigInt(payload.value);
|
|
3271
|
-
} catch (
|
|
3271
|
+
} catch (_2) {
|
|
3272
3272
|
}
|
|
3273
3273
|
if (typeof payload.value === "bigint")
|
|
3274
3274
|
return payload;
|
|
@@ -3461,9 +3461,9 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
3461
3461
|
}
|
|
3462
3462
|
function normalizeDef(def) {
|
|
3463
3463
|
const keys = Object.keys(def.shape);
|
|
3464
|
-
for (const
|
|
3465
|
-
if (!def.shape?.[
|
|
3466
|
-
throw new Error(`Invalid element at key "${
|
|
3464
|
+
for (const k2 of keys) {
|
|
3465
|
+
if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
|
|
3466
|
+
throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
|
|
3467
3467
|
}
|
|
3468
3468
|
}
|
|
3469
3469
|
const okeys = optionalKeys(def.shape);
|
|
@@ -3535,8 +3535,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3535
3535
|
const field = shape[key]._zod;
|
|
3536
3536
|
if (field.values) {
|
|
3537
3537
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3538
|
-
for (const
|
|
3539
|
-
propValues[key].add(
|
|
3538
|
+
for (const v2 of field.values)
|
|
3539
|
+
propValues[key].add(v2);
|
|
3540
3540
|
}
|
|
3541
3541
|
}
|
|
3542
3542
|
return propValues;
|
|
@@ -3584,8 +3584,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3584
3584
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
3585
3585
|
const normalized = _normalized.value;
|
|
3586
3586
|
const parseStr = (key) => {
|
|
3587
|
-
const
|
|
3588
|
-
return `shape[${
|
|
3587
|
+
const k2 = esc(key);
|
|
3588
|
+
return `shape[${k2}]._zod.run({ value: input[${k2}], issues: [] }, ctx)`;
|
|
3589
3589
|
};
|
|
3590
3590
|
doc.write(`const input = payload.value;`);
|
|
3591
3591
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
@@ -3596,7 +3596,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3596
3596
|
doc.write(`const newResult = {};`);
|
|
3597
3597
|
for (const key of normalized.keys) {
|
|
3598
3598
|
const id = ids[key];
|
|
3599
|
-
const
|
|
3599
|
+
const k2 = esc(key);
|
|
3600
3600
|
const schema = shape[key];
|
|
3601
3601
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
3602
3602
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
@@ -3604,30 +3604,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3604
3604
|
if (isOptionalIn && isOptionalOut) {
|
|
3605
3605
|
doc.write(`
|
|
3606
3606
|
if (${id}.issues.length) {
|
|
3607
|
-
if (${
|
|
3607
|
+
if (${k2} in input) {
|
|
3608
3608
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
3609
3609
|
...iss,
|
|
3610
|
-
path: iss.path ? [${
|
|
3610
|
+
path: iss.path ? [${k2}, ...iss.path] : [${k2}]
|
|
3611
3611
|
})));
|
|
3612
3612
|
}
|
|
3613
3613
|
}
|
|
3614
3614
|
|
|
3615
3615
|
if (${id}.value === undefined) {
|
|
3616
|
-
if (${
|
|
3617
|
-
newResult[${
|
|
3616
|
+
if (${k2} in input) {
|
|
3617
|
+
newResult[${k2}] = undefined;
|
|
3618
3618
|
}
|
|
3619
3619
|
} else {
|
|
3620
|
-
newResult[${
|
|
3620
|
+
newResult[${k2}] = ${id}.value;
|
|
3621
3621
|
}
|
|
3622
3622
|
|
|
3623
3623
|
`);
|
|
3624
3624
|
} else if (!isOptionalIn) {
|
|
3625
3625
|
doc.write(`
|
|
3626
|
-
const ${id}_present = ${
|
|
3626
|
+
const ${id}_present = ${k2} in input;
|
|
3627
3627
|
if (${id}.issues.length) {
|
|
3628
3628
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
3629
3629
|
...iss,
|
|
3630
|
-
path: iss.path ? [${
|
|
3630
|
+
path: iss.path ? [${k2}, ...iss.path] : [${k2}]
|
|
3631
3631
|
})));
|
|
3632
3632
|
}
|
|
3633
3633
|
if (!${id}_present && !${id}.issues.length) {
|
|
@@ -3635,15 +3635,15 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3635
3635
|
code: "invalid_type",
|
|
3636
3636
|
expected: "nonoptional",
|
|
3637
3637
|
input: undefined,
|
|
3638
|
-
path: [${
|
|
3638
|
+
path: [${k2}]
|
|
3639
3639
|
});
|
|
3640
3640
|
}
|
|
3641
3641
|
|
|
3642
3642
|
if (${id}_present) {
|
|
3643
3643
|
if (${id}.value === undefined) {
|
|
3644
|
-
newResult[${
|
|
3644
|
+
newResult[${k2}] = undefined;
|
|
3645
3645
|
} else {
|
|
3646
|
-
newResult[${
|
|
3646
|
+
newResult[${k2}] = ${id}.value;
|
|
3647
3647
|
}
|
|
3648
3648
|
}
|
|
3649
3649
|
|
|
@@ -3653,16 +3653,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3653
3653
|
if (${id}.issues.length) {
|
|
3654
3654
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
3655
3655
|
...iss,
|
|
3656
|
-
path: iss.path ? [${
|
|
3656
|
+
path: iss.path ? [${k2}, ...iss.path] : [${k2}]
|
|
3657
3657
|
})));
|
|
3658
3658
|
}
|
|
3659
3659
|
|
|
3660
3660
|
if (${id}.value === undefined) {
|
|
3661
|
-
if (${
|
|
3662
|
-
newResult[${
|
|
3661
|
+
if (${k2} in input) {
|
|
3662
|
+
newResult[${k2}] = undefined;
|
|
3663
3663
|
}
|
|
3664
3664
|
} else {
|
|
3665
|
-
newResult[${
|
|
3665
|
+
newResult[${k2}] = ${id}.value;
|
|
3666
3666
|
}
|
|
3667
3667
|
|
|
3668
3668
|
`);
|
|
@@ -3736,7 +3736,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
3736
3736
|
defineLazy(inst._zod, "pattern", () => {
|
|
3737
3737
|
if (def.options.every((o) => o._zod.pattern)) {
|
|
3738
3738
|
const patterns = def.options.map((o) => o._zod.pattern);
|
|
3739
|
-
return new RegExp(`^(${patterns.map((
|
|
3739
|
+
return new RegExp(`^(${patterns.map((p2) => cleanRegex(p2.source)).join("|")})$`);
|
|
3740
3740
|
}
|
|
3741
3741
|
return void 0;
|
|
3742
3742
|
});
|
|
@@ -3831,11 +3831,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3831
3831
|
const pv = option._zod.propValues;
|
|
3832
3832
|
if (!pv || Object.keys(pv).length === 0)
|
|
3833
3833
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
3834
|
-
for (const [
|
|
3835
|
-
if (!propValues[
|
|
3836
|
-
propValues[
|
|
3837
|
-
for (const val of
|
|
3838
|
-
propValues[
|
|
3834
|
+
for (const [k2, v2] of Object.entries(pv)) {
|
|
3835
|
+
if (!propValues[k2])
|
|
3836
|
+
propValues[k2] = /* @__PURE__ */ new Set();
|
|
3837
|
+
for (const val of v2) {
|
|
3838
|
+
propValues[k2].add(val);
|
|
3839
3839
|
}
|
|
3840
3840
|
}
|
|
3841
3841
|
}
|
|
@@ -3848,11 +3848,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
3848
3848
|
const values = o._zod.propValues?.[def.discriminator];
|
|
3849
3849
|
if (!values || values.size === 0)
|
|
3850
3850
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
3851
|
-
for (const
|
|
3852
|
-
if (map2.has(
|
|
3853
|
-
throw new Error(`Duplicate discriminator value "${String(
|
|
3851
|
+
for (const v2 of values) {
|
|
3852
|
+
if (map2.has(v2)) {
|
|
3853
|
+
throw new Error(`Duplicate discriminator value "${String(v2)}"`);
|
|
3854
3854
|
}
|
|
3855
|
-
map2.set(
|
|
3855
|
+
map2.set(v2, o);
|
|
3856
3856
|
}
|
|
3857
3857
|
}
|
|
3858
3858
|
return map2;
|
|
@@ -3903,19 +3903,19 @@ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, d
|
|
|
3903
3903
|
return handleIntersectionResults(payload, left, right);
|
|
3904
3904
|
};
|
|
3905
3905
|
});
|
|
3906
|
-
function mergeValues(a,
|
|
3907
|
-
if (a ===
|
|
3906
|
+
function mergeValues(a, b2) {
|
|
3907
|
+
if (a === b2) {
|
|
3908
3908
|
return { valid: true, data: a };
|
|
3909
3909
|
}
|
|
3910
|
-
if (a instanceof Date &&
|
|
3910
|
+
if (a instanceof Date && b2 instanceof Date && +a === +b2) {
|
|
3911
3911
|
return { valid: true, data: a };
|
|
3912
3912
|
}
|
|
3913
|
-
if (isPlainObject(a) && isPlainObject(
|
|
3914
|
-
const bKeys = Object.keys(
|
|
3913
|
+
if (isPlainObject(a) && isPlainObject(b2)) {
|
|
3914
|
+
const bKeys = Object.keys(b2);
|
|
3915
3915
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
3916
|
-
const newObj = { ...a, ...
|
|
3916
|
+
const newObj = { ...a, ...b2 };
|
|
3917
3917
|
for (const key of sharedKeys) {
|
|
3918
|
-
const sharedValue = mergeValues(a[key],
|
|
3918
|
+
const sharedValue = mergeValues(a[key], b2[key]);
|
|
3919
3919
|
if (!sharedValue.valid) {
|
|
3920
3920
|
return {
|
|
3921
3921
|
valid: false,
|
|
@@ -3926,14 +3926,14 @@ function mergeValues(a, b) {
|
|
|
3926
3926
|
}
|
|
3927
3927
|
return { valid: true, data: newObj };
|
|
3928
3928
|
}
|
|
3929
|
-
if (Array.isArray(a) && Array.isArray(
|
|
3930
|
-
if (a.length !==
|
|
3929
|
+
if (Array.isArray(a) && Array.isArray(b2)) {
|
|
3930
|
+
if (a.length !== b2.length) {
|
|
3931
3931
|
return { valid: false, mergeErrorPath: [] };
|
|
3932
3932
|
}
|
|
3933
3933
|
const newArray = [];
|
|
3934
3934
|
for (let index = 0; index < a.length; index++) {
|
|
3935
3935
|
const itemA = a[index];
|
|
3936
|
-
const itemB =
|
|
3936
|
+
const itemB = b2[index];
|
|
3937
3937
|
const sharedValue = mergeValues(itemA, itemB);
|
|
3938
3938
|
if (!sharedValue.valid) {
|
|
3939
3939
|
return {
|
|
@@ -3953,10 +3953,10 @@ function handleIntersectionResults(result, left, right) {
|
|
|
3953
3953
|
for (const iss of left.issues) {
|
|
3954
3954
|
if (iss.code === "unrecognized_keys") {
|
|
3955
3955
|
unrecIssue ?? (unrecIssue = iss);
|
|
3956
|
-
for (const
|
|
3957
|
-
if (!unrecKeys.has(
|
|
3958
|
-
unrecKeys.set(
|
|
3959
|
-
unrecKeys.get(
|
|
3956
|
+
for (const k2 of iss.keys) {
|
|
3957
|
+
if (!unrecKeys.has(k2))
|
|
3958
|
+
unrecKeys.set(k2, {});
|
|
3959
|
+
unrecKeys.get(k2).l = true;
|
|
3960
3960
|
}
|
|
3961
3961
|
} else {
|
|
3962
3962
|
result.issues.push(iss);
|
|
@@ -3964,16 +3964,16 @@ function handleIntersectionResults(result, left, right) {
|
|
|
3964
3964
|
}
|
|
3965
3965
|
for (const iss of right.issues) {
|
|
3966
3966
|
if (iss.code === "unrecognized_keys") {
|
|
3967
|
-
for (const
|
|
3968
|
-
if (!unrecKeys.has(
|
|
3969
|
-
unrecKeys.set(
|
|
3970
|
-
unrecKeys.get(
|
|
3967
|
+
for (const k2 of iss.keys) {
|
|
3968
|
+
if (!unrecKeys.has(k2))
|
|
3969
|
+
unrecKeys.set(k2, {});
|
|
3970
|
+
unrecKeys.get(k2).r = true;
|
|
3971
3971
|
}
|
|
3972
3972
|
} else {
|
|
3973
3973
|
result.issues.push(iss);
|
|
3974
3974
|
}
|
|
3975
3975
|
}
|
|
3976
|
-
const bothKeys = [...unrecKeys].filter(([,
|
|
3976
|
+
const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k2]) => k2);
|
|
3977
3977
|
if (bothKeys.length && unrecIssue) {
|
|
3978
3978
|
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
3979
3979
|
}
|
|
@@ -4317,7 +4317,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
4317
4317
|
const values = getEnumValues(def.entries);
|
|
4318
4318
|
const valuesSet = new Set(values);
|
|
4319
4319
|
inst._zod.values = valuesSet;
|
|
4320
|
-
inst._zod.pattern = new RegExp(`^(${values.filter((
|
|
4320
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k2) => propertyKeyTypes.has(typeof k2)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
4321
4321
|
inst._zod.parse = (payload, _ctx) => {
|
|
4322
4322
|
const input = payload.value;
|
|
4323
4323
|
if (valuesSet.has(input)) {
|
|
@@ -4491,8 +4491,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
4491
4491
|
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
4492
4492
|
$ZodType.init(inst, def);
|
|
4493
4493
|
defineLazy(inst._zod, "values", () => {
|
|
4494
|
-
const
|
|
4495
|
-
return
|
|
4494
|
+
const v2 = def.innerType._zod.values;
|
|
4495
|
+
return v2 ? new Set([...v2].filter((x2) => x2 !== void 0)) : void 0;
|
|
4496
4496
|
});
|
|
4497
4497
|
inst._zod.parse = (payload, ctx) => {
|
|
4498
4498
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -4837,7 +4837,7 @@ var $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
|
|
|
4837
4837
|
var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
4838
4838
|
$ZodCheck.init(inst, def);
|
|
4839
4839
|
$ZodType.init(inst, def);
|
|
4840
|
-
inst._zod.parse = (payload,
|
|
4840
|
+
inst._zod.parse = (payload, _2) => {
|
|
4841
4841
|
return payload;
|
|
4842
4842
|
};
|
|
4843
4843
|
inst._zod.check = (payload) => {
|
|
@@ -6889,7 +6889,7 @@ var error17 = () => {
|
|
|
6889
6889
|
if (issue2.values.length === 1) {
|
|
6890
6890
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
|
|
6891
6891
|
}
|
|
6892
|
-
const stringified = issue2.values.map((
|
|
6892
|
+
const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
|
|
6893
6893
|
if (issue2.values.length === 2) {
|
|
6894
6894
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
|
|
6895
6895
|
}
|
|
@@ -10854,12 +10854,12 @@ var $ZodRegistry = class {
|
|
|
10854
10854
|
return this;
|
|
10855
10855
|
}
|
|
10856
10856
|
get(schema) {
|
|
10857
|
-
const
|
|
10858
|
-
if (
|
|
10859
|
-
const pm = { ...this.get(
|
|
10857
|
+
const p2 = schema._zod.parent;
|
|
10858
|
+
if (p2) {
|
|
10859
|
+
const pm = { ...this.get(p2) ?? {} };
|
|
10860
10860
|
delete pm.id;
|
|
10861
|
-
const
|
|
10862
|
-
return Object.keys(
|
|
10861
|
+
const f2 = { ...pm, ...this._map.get(schema) };
|
|
10862
|
+
return Object.keys(f2).length ? f2 : void 0;
|
|
10863
10863
|
}
|
|
10864
10864
|
return this._map.get(schema);
|
|
10865
10865
|
}
|
|
@@ -11644,7 +11644,7 @@ function _set(Class2, valueType, params) {
|
|
|
11644
11644
|
}
|
|
11645
11645
|
// @__NO_SIDE_EFFECTS__
|
|
11646
11646
|
function _enum(Class2, values, params) {
|
|
11647
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
11647
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
11648
11648
|
return new Class2({
|
|
11649
11649
|
type: "enum",
|
|
11650
11650
|
entries,
|
|
@@ -11849,8 +11849,8 @@ function _stringbool(Classes, _params) {
|
|
|
11849
11849
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
11850
11850
|
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
11851
11851
|
if (params.case !== "sensitive") {
|
|
11852
|
-
truthyArray = truthyArray.map((
|
|
11853
|
-
falsyArray = falsyArray.map((
|
|
11852
|
+
truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
11853
|
+
falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
11854
11854
|
}
|
|
11855
11855
|
const truthySet = new Set(truthyArray);
|
|
11856
11856
|
const falsySet = new Set(falsyArray);
|
|
@@ -12392,9 +12392,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
12392
12392
|
var enumProcessor = (schema, _ctx, json2, _params) => {
|
|
12393
12393
|
const def = schema._zod.def;
|
|
12394
12394
|
const values = getEnumValues(def.entries);
|
|
12395
|
-
if (values.every((
|
|
12395
|
+
if (values.every((v2) => typeof v2 === "number"))
|
|
12396
12396
|
json2.type = "number";
|
|
12397
|
-
if (values.every((
|
|
12397
|
+
if (values.every((v2) => typeof v2 === "string"))
|
|
12398
12398
|
json2.type = "string";
|
|
12399
12399
|
json2.enum = values;
|
|
12400
12400
|
};
|
|
@@ -12427,13 +12427,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
|
|
|
12427
12427
|
json2.const = val;
|
|
12428
12428
|
}
|
|
12429
12429
|
} else {
|
|
12430
|
-
if (vals.every((
|
|
12430
|
+
if (vals.every((v2) => typeof v2 === "number"))
|
|
12431
12431
|
json2.type = "number";
|
|
12432
|
-
if (vals.every((
|
|
12432
|
+
if (vals.every((v2) => typeof v2 === "string"))
|
|
12433
12433
|
json2.type = "string";
|
|
12434
|
-
if (vals.every((
|
|
12434
|
+
if (vals.every((v2) => typeof v2 === "boolean"))
|
|
12435
12435
|
json2.type = "boolean";
|
|
12436
|
-
if (vals.every((
|
|
12436
|
+
if (vals.every((v2) => v2 === null))
|
|
12437
12437
|
json2.type = "null";
|
|
12438
12438
|
json2.enum = vals;
|
|
12439
12439
|
}
|
|
@@ -12469,7 +12469,7 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
12469
12469
|
Object.assign(_json, file2);
|
|
12470
12470
|
} else {
|
|
12471
12471
|
Object.assign(_json, file2);
|
|
12472
|
-
_json.anyOf = mime.map((
|
|
12472
|
+
_json.anyOf = mime.map((m2) => ({ contentMediaType: m2 }));
|
|
12473
12473
|
}
|
|
12474
12474
|
} else {
|
|
12475
12475
|
Object.assign(_json, file2);
|
|
@@ -12531,11 +12531,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12531
12531
|
}
|
|
12532
12532
|
const allKeys = new Set(Object.keys(shape));
|
|
12533
12533
|
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
12534
|
-
const
|
|
12534
|
+
const v2 = def.shape[key]._zod;
|
|
12535
12535
|
if (ctx.io === "input") {
|
|
12536
|
-
return
|
|
12536
|
+
return v2.optin === void 0;
|
|
12537
12537
|
} else {
|
|
12538
|
-
return
|
|
12538
|
+
return v2.optout === void 0;
|
|
12539
12539
|
}
|
|
12540
12540
|
}));
|
|
12541
12541
|
if (requiredKeys.size > 0) {
|
|
@@ -12556,7 +12556,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12556
12556
|
var unionProcessor = (schema, ctx, json2, params) => {
|
|
12557
12557
|
const def = schema._zod.def;
|
|
12558
12558
|
const isExclusive = def.inclusive === false;
|
|
12559
|
-
const options = def.options.map((
|
|
12559
|
+
const options = def.options.map((x2, i) => process2(x2, ctx, {
|
|
12560
12560
|
...params,
|
|
12561
12561
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
12562
12562
|
}));
|
|
@@ -12572,14 +12572,14 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
|
12572
12572
|
...params,
|
|
12573
12573
|
path: [...params.path, "allOf", 0]
|
|
12574
12574
|
});
|
|
12575
|
-
const
|
|
12575
|
+
const b2 = process2(def.right, ctx, {
|
|
12576
12576
|
...params,
|
|
12577
12577
|
path: [...params.path, "allOf", 1]
|
|
12578
12578
|
});
|
|
12579
12579
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
12580
12580
|
const allOf = [
|
|
12581
12581
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
12582
|
-
...isSimpleIntersection(
|
|
12582
|
+
...isSimpleIntersection(b2) ? b2.allOf : [b2]
|
|
12583
12583
|
];
|
|
12584
12584
|
json2.allOf = allOf;
|
|
12585
12585
|
};
|
|
@@ -12589,7 +12589,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
12589
12589
|
json2.type = "array";
|
|
12590
12590
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
12591
12591
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
12592
|
-
const prefixItems = def.items.map((
|
|
12592
|
+
const prefixItems = def.items.map((x2, i) => process2(x2, ctx, {
|
|
12593
12593
|
...params,
|
|
12594
12594
|
path: [...params.path, prefixPath, i]
|
|
12595
12595
|
}));
|
|
@@ -12655,7 +12655,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12655
12655
|
}
|
|
12656
12656
|
const keyValues = keyType._zod.values;
|
|
12657
12657
|
if (keyValues) {
|
|
12658
|
-
const validKeyValues = [...keyValues].filter((
|
|
12658
|
+
const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
|
|
12659
12659
|
if (validKeyValues.length > 0) {
|
|
12660
12660
|
json2.required = validKeyValues;
|
|
12661
12661
|
}
|
|
@@ -12786,7 +12786,7 @@ function toJSONSchema(input, params) {
|
|
|
12786
12786
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
12787
12787
|
const defs = {};
|
|
12788
12788
|
for (const entry of registry2._idmap.entries()) {
|
|
12789
|
-
const [
|
|
12789
|
+
const [_2, schema] = entry;
|
|
12790
12790
|
process2(schema, ctx2);
|
|
12791
12791
|
}
|
|
12792
12792
|
const schemas = {};
|
|
@@ -12885,7 +12885,7 @@ var JSONSchemaGenerator = class {
|
|
|
12885
12885
|
}
|
|
12886
12886
|
extractDefs(this.ctx, schema);
|
|
12887
12887
|
const result = finalize(this.ctx, schema);
|
|
12888
|
-
const { "~standard":
|
|
12888
|
+
const { "~standard": _2, ...plainResult } = result;
|
|
12889
12889
|
return plainResult;
|
|
12890
12890
|
}
|
|
12891
12891
|
};
|
|
@@ -13220,12 +13220,12 @@ function _installLazyMethods(inst, group, methods) {
|
|
|
13220
13220
|
});
|
|
13221
13221
|
return bound;
|
|
13222
13222
|
},
|
|
13223
|
-
set(
|
|
13223
|
+
set(v2) {
|
|
13224
13224
|
Object.defineProperty(this, key, {
|
|
13225
13225
|
configurable: true,
|
|
13226
13226
|
writable: true,
|
|
13227
13227
|
enumerable: true,
|
|
13228
|
-
value:
|
|
13228
|
+
value: v2
|
|
13229
13229
|
});
|
|
13230
13230
|
}
|
|
13231
13231
|
});
|
|
@@ -14021,11 +14021,11 @@ function record(keyType, valueType, params) {
|
|
|
14021
14021
|
});
|
|
14022
14022
|
}
|
|
14023
14023
|
function partialRecord(keyType, valueType, params) {
|
|
14024
|
-
const
|
|
14025
|
-
|
|
14024
|
+
const k2 = clone(keyType);
|
|
14025
|
+
k2._zod.values = void 0;
|
|
14026
14026
|
return new ZodRecord({
|
|
14027
14027
|
type: "record",
|
|
14028
|
-
keyType:
|
|
14028
|
+
keyType: k2,
|
|
14029
14029
|
valueType,
|
|
14030
14030
|
...util_exports.normalizeParams(params)
|
|
14031
14031
|
});
|
|
@@ -14113,7 +14113,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
14113
14113
|
};
|
|
14114
14114
|
});
|
|
14115
14115
|
function _enum2(values, params) {
|
|
14116
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
14116
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
14117
14117
|
return new ZodEnum({
|
|
14118
14118
|
type: "enum",
|
|
14119
14119
|
entries,
|
|
@@ -14667,10 +14667,10 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14667
14667
|
if (enumValues.length === 1) {
|
|
14668
14668
|
return z.literal(enumValues[0]);
|
|
14669
14669
|
}
|
|
14670
|
-
if (enumValues.every((
|
|
14670
|
+
if (enumValues.every((v2) => typeof v2 === "string")) {
|
|
14671
14671
|
return z.enum(enumValues);
|
|
14672
14672
|
}
|
|
14673
|
-
const literalSchemas = enumValues.map((
|
|
14673
|
+
const literalSchemas = enumValues.map((v2) => z.literal(v2));
|
|
14674
14674
|
if (literalSchemas.length < 2) {
|
|
14675
14675
|
return literalSchemas[0];
|
|
14676
14676
|
}
|
|
@@ -14910,12 +14910,12 @@ function convertSchema(schema, ctx) {
|
|
|
14910
14910
|
let baseSchema = convertBaseSchema(schema, ctx);
|
|
14911
14911
|
const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
|
|
14912
14912
|
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
14913
|
-
const options = schema.anyOf.map((
|
|
14913
|
+
const options = schema.anyOf.map((s2) => convertSchema(s2, ctx));
|
|
14914
14914
|
const anyOfUnion = z.union(options);
|
|
14915
14915
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
14916
14916
|
}
|
|
14917
14917
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
14918
|
-
const options = schema.oneOf.map((
|
|
14918
|
+
const options = schema.oneOf.map((s2) => convertSchema(s2, ctx));
|
|
14919
14919
|
const oneOfUnion = z.xor(options);
|
|
14920
14920
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
14921
14921
|
}
|
|
@@ -15036,6 +15036,52 @@ function normalizeImageGenerationUrl(value) {
|
|
|
15036
15036
|
return url2.toString().replace(/\/+$/, "");
|
|
15037
15037
|
}
|
|
15038
15038
|
|
|
15039
|
+
// shared/bot-avatar.ts
|
|
15040
|
+
var BOT_AVATAR_CROPS = ["mascot", "circle", "rounded", "square"];
|
|
15041
|
+
var botAvatarCropSchema = external_exports.enum(BOT_AVATAR_CROPS);
|
|
15042
|
+
var botAvatarUrlSchema = external_exports.string().regex(
|
|
15043
|
+
/^\/api\/attachments\/[A-Za-z0-9-]+\.(?:png|jpg|gif|webp)$/,
|
|
15044
|
+
"must be a stored PNG, JPEG, GIF, or WebP attachment"
|
|
15045
|
+
);
|
|
15046
|
+
|
|
15047
|
+
// shared/bot-profile.ts
|
|
15048
|
+
var BOT_PROFILE_LIMITS = {
|
|
15049
|
+
name: 100,
|
|
15050
|
+
title: 200,
|
|
15051
|
+
description: 4e3,
|
|
15052
|
+
voice: 200,
|
|
15053
|
+
soul: 24e3
|
|
15054
|
+
};
|
|
15055
|
+
function fitsOnOneLine(value) {
|
|
15056
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
15057
|
+
const code = value.charCodeAt(i);
|
|
15058
|
+
if (code < 32 || code >= 127 && code <= 159 || code === 8232 || code === 8233) return false;
|
|
15059
|
+
}
|
|
15060
|
+
return true;
|
|
15061
|
+
}
|
|
15062
|
+
|
|
15063
|
+
// shared/mascot-bodies.ts
|
|
15064
|
+
var MASCOT_BODY_IDS = ["cursor", "blob", "circle", "squircle", "capsule", "drop", "shield", "hexagon", "diamond", "star"];
|
|
15065
|
+
var mascotBodySchema = external_exports.enum(MASCOT_BODY_IDS);
|
|
15066
|
+
|
|
15067
|
+
// server/bot-profile.ts
|
|
15068
|
+
var profilePatchSchema = external_exports.object({
|
|
15069
|
+
name: external_exports.string({ error: "name must be a string" }).max(BOT_PROFILE_LIMITS.name, { error: "name must be at most 100 characters" }).refine((value) => Boolean(value.trim()), { error: "name must not be empty" }).refine(fitsOnOneLine, { error: "name must fit on one line" }).optional(),
|
|
15070
|
+
title: external_exports.string({ error: "title must be a string" }).max(BOT_PROFILE_LIMITS.title, { error: "title must be at most 200 characters" }).refine(fitsOnOneLine, { error: "title must fit on one line" }).optional(),
|
|
15071
|
+
description: external_exports.string({ error: "description must be a string" }).max(BOT_PROFILE_LIMITS.description, { error: "description must be at most 4000 characters" }).optional(),
|
|
15072
|
+
soul: external_exports.string({ error: "soul must be a string" }).refine((value) => Buffer.byteLength(value, "utf8") <= BOT_PROFILE_LIMITS.soul, {
|
|
15073
|
+
error: "standing instructions must be at most 24000 bytes"
|
|
15074
|
+
}).optional(),
|
|
15075
|
+
notifications: external_exports.boolean({ error: "notifications must be true or false" }).optional(),
|
|
15076
|
+
avatarUrl: external_exports.union([botAvatarUrlSchema, external_exports.literal(""), external_exports.null()], {
|
|
15077
|
+
error: "avatarUrl must be a stored PNG, JPEG, GIF, or WebP attachment"
|
|
15078
|
+
}).optional(),
|
|
15079
|
+
avatarCrop: botAvatarCropSchema.optional(),
|
|
15080
|
+
mascotBody: mascotBodySchema.optional(),
|
|
15081
|
+
voice: external_exports.string({ error: "voice must be a string" }).max(BOT_PROFILE_LIMITS.voice, { error: "voice must be at most 200 characters" }).optional(),
|
|
15082
|
+
speakReplies: external_exports.boolean({ error: "speakReplies must be true or false" }).optional()
|
|
15083
|
+
});
|
|
15084
|
+
|
|
15039
15085
|
// shared/wire.ts
|
|
15040
15086
|
var EFFORT_LEVELS = ["none", "low", "medium", "high", "xhigh", "max"];
|
|
15041
15087
|
|
|
@@ -15044,6 +15090,815 @@ function isModelVariant(value) {
|
|
|
15044
15090
|
return typeof value === "string" && value.length > 0 && value.length <= 256 && value.trim() === value && !new RegExp("\\p{Cc}", "u").test(value);
|
|
15045
15091
|
}
|
|
15046
15092
|
|
|
15093
|
+
// node_modules/.pnpm/croner@10.0.1/node_modules/croner/dist/croner.js
|
|
15094
|
+
function T(s2) {
|
|
15095
|
+
return Date.UTC(s2.y, s2.m - 1, s2.d, s2.h, s2.i, s2.s);
|
|
15096
|
+
}
|
|
15097
|
+
function D(s2, e) {
|
|
15098
|
+
return s2.y === e.y && s2.m === e.m && s2.d === e.d && s2.h === e.h && s2.i === e.i && s2.s === e.s;
|
|
15099
|
+
}
|
|
15100
|
+
function A(s2, e) {
|
|
15101
|
+
let t = new Date(Date.parse(s2));
|
|
15102
|
+
if (isNaN(t)) throw new Error("Invalid ISO8601 passed to timezone parser.");
|
|
15103
|
+
let r = s2.substring(9);
|
|
15104
|
+
return r.includes("Z") || r.includes("+") || r.includes("-") ? b(t.getUTCFullYear(), t.getUTCMonth() + 1, t.getUTCDate(), t.getUTCHours(), t.getUTCMinutes(), t.getUTCSeconds(), "Etc/UTC") : b(t.getFullYear(), t.getMonth() + 1, t.getDate(), t.getHours(), t.getMinutes(), t.getSeconds(), e);
|
|
15105
|
+
}
|
|
15106
|
+
function v(s2, e, t) {
|
|
15107
|
+
return k(A(s2, e), t);
|
|
15108
|
+
}
|
|
15109
|
+
function k(s2, e) {
|
|
15110
|
+
let t = new Date(T(s2)), r = g(t, s2.tz), n = T(s2), i = T(r), a = n - i, o = new Date(t.getTime() + a), h = g(o, s2.tz);
|
|
15111
|
+
if (D(h, s2)) {
|
|
15112
|
+
let u = new Date(o.getTime() - 36e5), d = g(u, s2.tz);
|
|
15113
|
+
return D(d, s2) ? u : o;
|
|
15114
|
+
}
|
|
15115
|
+
let l = new Date(o.getTime() + T(s2) - T(h)), y = g(l, s2.tz);
|
|
15116
|
+
if (D(y, s2)) return l;
|
|
15117
|
+
if (e) throw new Error("Invalid date passed to fromTZ()");
|
|
15118
|
+
return o.getTime() > l.getTime() ? o : l;
|
|
15119
|
+
}
|
|
15120
|
+
function g(s2, e) {
|
|
15121
|
+
let t, r;
|
|
15122
|
+
try {
|
|
15123
|
+
t = new Intl.DateTimeFormat("en-US", { timeZone: e, year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric", hour12: false }), r = t.formatToParts(s2);
|
|
15124
|
+
} catch (i) {
|
|
15125
|
+
let a = i instanceof Error ? i.message : String(i);
|
|
15126
|
+
throw new RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${a}`);
|
|
15127
|
+
}
|
|
15128
|
+
let n = { year: 0, month: 0, day: 0, hour: 0, minute: 0, second: 0 };
|
|
15129
|
+
for (let i of r) (i.type === "year" || i.type === "month" || i.type === "day" || i.type === "hour" || i.type === "minute" || i.type === "second") && (n[i.type] = parseInt(i.value, 10));
|
|
15130
|
+
if (isNaN(n.year) || isNaN(n.month) || isNaN(n.day) || isNaN(n.hour) || isNaN(n.minute) || isNaN(n.second)) throw new Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(n)}`);
|
|
15131
|
+
return n.hour === 24 && (n.hour = 0), { y: n.year, m: n.month, d: n.day, h: n.hour, i: n.minute, s: n.second, tz: e };
|
|
15132
|
+
}
|
|
15133
|
+
function b(s2, e, t, r, n, i, a) {
|
|
15134
|
+
return { y: s2, m: e, d: t, h: r, i: n, s: i, tz: a };
|
|
15135
|
+
}
|
|
15136
|
+
var O = [1, 2, 4, 8, 16];
|
|
15137
|
+
var C = class {
|
|
15138
|
+
pattern;
|
|
15139
|
+
timezone;
|
|
15140
|
+
mode;
|
|
15141
|
+
alternativeWeekdays;
|
|
15142
|
+
sloppyRanges;
|
|
15143
|
+
second;
|
|
15144
|
+
minute;
|
|
15145
|
+
hour;
|
|
15146
|
+
day;
|
|
15147
|
+
month;
|
|
15148
|
+
dayOfWeek;
|
|
15149
|
+
year;
|
|
15150
|
+
lastDayOfMonth;
|
|
15151
|
+
lastWeekday;
|
|
15152
|
+
nearestWeekdays;
|
|
15153
|
+
starDOM;
|
|
15154
|
+
starDOW;
|
|
15155
|
+
starYear;
|
|
15156
|
+
useAndLogic;
|
|
15157
|
+
constructor(e, t, r) {
|
|
15158
|
+
this.pattern = e, this.timezone = t, this.mode = r?.mode ?? "auto", this.alternativeWeekdays = r?.alternativeWeekdays ?? false, this.sloppyRanges = r?.sloppyRanges ?? false, this.second = Array(60).fill(0), this.minute = Array(60).fill(0), this.hour = Array(24).fill(0), this.day = Array(31).fill(0), this.month = Array(12).fill(0), this.dayOfWeek = Array(7).fill(0), this.year = Array(1e4).fill(0), this.lastDayOfMonth = false, this.lastWeekday = false, this.nearestWeekdays = Array(31).fill(0), this.starDOM = false, this.starDOW = false, this.starYear = false, this.useAndLogic = false, this.parse();
|
|
15159
|
+
}
|
|
15160
|
+
parse() {
|
|
15161
|
+
if (!(typeof this.pattern == "string" || this.pattern instanceof String)) throw new TypeError("CronPattern: Pattern has to be of type string.");
|
|
15162
|
+
this.pattern.indexOf("@") >= 0 && (this.pattern = this.handleNicknames(this.pattern).trim());
|
|
15163
|
+
let e = this.pattern.match(/\S+/g) || [""], t = e.length;
|
|
15164
|
+
if (e.length < 5 || e.length > 7) throw new TypeError("CronPattern: invalid configuration format ('" + this.pattern + "'), exactly five, six, or seven space separated parts are required.");
|
|
15165
|
+
if (this.mode !== "auto") {
|
|
15166
|
+
let n;
|
|
15167
|
+
switch (this.mode) {
|
|
15168
|
+
case "5-part":
|
|
15169
|
+
n = 5;
|
|
15170
|
+
break;
|
|
15171
|
+
case "6-part":
|
|
15172
|
+
n = 6;
|
|
15173
|
+
break;
|
|
15174
|
+
case "7-part":
|
|
15175
|
+
n = 7;
|
|
15176
|
+
break;
|
|
15177
|
+
case "5-or-6-parts":
|
|
15178
|
+
n = [5, 6];
|
|
15179
|
+
break;
|
|
15180
|
+
case "6-or-7-parts":
|
|
15181
|
+
n = [6, 7];
|
|
15182
|
+
break;
|
|
15183
|
+
default:
|
|
15184
|
+
n = 0;
|
|
15185
|
+
}
|
|
15186
|
+
if (!(Array.isArray(n) ? n.includes(t) : t === n)) {
|
|
15187
|
+
let a = Array.isArray(n) ? n.join(" or ") : n.toString();
|
|
15188
|
+
throw new TypeError(`CronPattern: mode '${this.mode}' requires exactly ${a} parts, but pattern '${this.pattern}' has ${t} parts.`);
|
|
15189
|
+
}
|
|
15190
|
+
}
|
|
15191
|
+
if (e.length === 5 && e.unshift("0"), e.length === 6 && e.push("*"), e[3].toUpperCase() === "LW" ? (this.lastWeekday = true, e[3] = "") : e[3].toUpperCase().indexOf("L") >= 0 && (e[3] = e[3].replace(/L/gi, ""), this.lastDayOfMonth = true), e[3] == "*" && (this.starDOM = true), e[6] == "*" && (this.starYear = true), e[4].length >= 3 && (e[4] = this.replaceAlphaMonths(e[4])), e[5].length >= 3 && (e[5] = this.alternativeWeekdays ? this.replaceAlphaDaysQuartz(e[5]) : this.replaceAlphaDays(e[5])), e[5].startsWith("+") && (this.useAndLogic = true, e[5] = e[5].substring(1), e[5] === "")) throw new TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");
|
|
15192
|
+
switch (e[5] == "*" && (this.starDOW = true), this.pattern.indexOf("?") >= 0 && (e[0] = e[0].replace(/\?/g, "*"), e[1] = e[1].replace(/\?/g, "*"), e[2] = e[2].replace(/\?/g, "*"), e[3] = e[3].replace(/\?/g, "*"), e[4] = e[4].replace(/\?/g, "*"), e[5] = e[5].replace(/\?/g, "*"), e[6] && (e[6] = e[6].replace(/\?/g, "*"))), this.mode) {
|
|
15193
|
+
case "5-part":
|
|
15194
|
+
e[0] = "0", e[6] = "*";
|
|
15195
|
+
break;
|
|
15196
|
+
case "6-part":
|
|
15197
|
+
e[6] = "*";
|
|
15198
|
+
break;
|
|
15199
|
+
case "5-or-6-parts":
|
|
15200
|
+
e[6] = "*";
|
|
15201
|
+
break;
|
|
15202
|
+
case "6-or-7-parts":
|
|
15203
|
+
break;
|
|
15204
|
+
case "7-part":
|
|
15205
|
+
case "auto":
|
|
15206
|
+
break;
|
|
15207
|
+
}
|
|
15208
|
+
this.throwAtIllegalCharacters(e), this.partToArray("second", e[0], 0, 1), this.partToArray("minute", e[1], 0, 1), this.partToArray("hour", e[2], 0, 1), this.partToArray("day", e[3], -1, 1), this.partToArray("month", e[4], -1, 1);
|
|
15209
|
+
let r = this.alternativeWeekdays ? -1 : 0;
|
|
15210
|
+
this.partToArray("dayOfWeek", e[5], r, 63), this.partToArray("year", e[6], 0, 1), !this.alternativeWeekdays && this.dayOfWeek[7] && (this.dayOfWeek[0] = this.dayOfWeek[7]);
|
|
15211
|
+
}
|
|
15212
|
+
partToArray(e, t, r, n) {
|
|
15213
|
+
let i = this[e], a = e === "day" && this.lastDayOfMonth, o = e === "day" && this.lastWeekday;
|
|
15214
|
+
if (t === "" && !a && !o) throw new TypeError("CronPattern: configuration entry " + e + " (" + t + ") is empty, check for trailing spaces.");
|
|
15215
|
+
if (t === "*") return i.fill(n);
|
|
15216
|
+
let h = t.split(",");
|
|
15217
|
+
if (h.length > 1) for (let l = 0; l < h.length; l++) this.partToArray(e, h[l], r, n);
|
|
15218
|
+
else t.indexOf("-") !== -1 && t.indexOf("/") !== -1 ? this.handleRangeWithStepping(t, e, r, n) : t.indexOf("-") !== -1 ? this.handleRange(t, e, r, n) : t.indexOf("/") !== -1 ? this.handleStepping(t, e, r, n) : t !== "" && this.handleNumber(t, e, r, n);
|
|
15219
|
+
}
|
|
15220
|
+
throwAtIllegalCharacters(e) {
|
|
15221
|
+
for (let t = 0; t < e.length; t++) if ((t === 3 ? /[^/*0-9,\-WwLl]+/ : t === 5 ? /[^/*0-9,\-#Ll]+/ : /[^/*0-9,\-]+/).test(e[t])) throw new TypeError("CronPattern: configuration entry " + t + " (" + e[t] + ") contains illegal characters.");
|
|
15222
|
+
}
|
|
15223
|
+
handleNumber(e, t, r, n) {
|
|
15224
|
+
let i = this.extractNth(e, t), a = e.toUpperCase().includes("W");
|
|
15225
|
+
if (t !== "day" && a) throw new TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");
|
|
15226
|
+
a && (t = "nearestWeekdays");
|
|
15227
|
+
let o = parseInt(i[0], 10) + r;
|
|
15228
|
+
if (isNaN(o)) throw new TypeError("CronPattern: " + t + " is not a number: '" + e + "'");
|
|
15229
|
+
this.setPart(t, o, i[1] || n);
|
|
15230
|
+
}
|
|
15231
|
+
setPart(e, t, r) {
|
|
15232
|
+
if (!Object.prototype.hasOwnProperty.call(this, e)) throw new TypeError("CronPattern: Invalid part specified: " + e);
|
|
15233
|
+
if (e === "dayOfWeek") {
|
|
15234
|
+
if (t === 7 && (t = 0), t < 0 || t > 6) throw new RangeError("CronPattern: Invalid value for dayOfWeek: " + t);
|
|
15235
|
+
this.setNthWeekdayOfMonth(t, r);
|
|
15236
|
+
return;
|
|
15237
|
+
}
|
|
15238
|
+
if (e === "second" || e === "minute") {
|
|
15239
|
+
if (t < 0 || t >= 60) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
15240
|
+
} else if (e === "hour") {
|
|
15241
|
+
if (t < 0 || t >= 24) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
15242
|
+
} else if (e === "day" || e === "nearestWeekdays") {
|
|
15243
|
+
if (t < 0 || t >= 31) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
15244
|
+
} else if (e === "month") {
|
|
15245
|
+
if (t < 0 || t >= 12) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t);
|
|
15246
|
+
} else if (e === "year" && (t < 1 || t >= 1e4)) throw new RangeError("CronPattern: Invalid value for " + e + ": " + t + " (supported range: 1-9999)");
|
|
15247
|
+
this[e][t] = r;
|
|
15248
|
+
}
|
|
15249
|
+
validateNotNaN(e, t) {
|
|
15250
|
+
if (isNaN(e)) throw new TypeError(t);
|
|
15251
|
+
}
|
|
15252
|
+
validateRange(e, t, r, n, i) {
|
|
15253
|
+
if (e > t) throw new TypeError("CronPattern: From value is larger than to value: '" + i + "'");
|
|
15254
|
+
if (r !== void 0) {
|
|
15255
|
+
if (r === 0) throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");
|
|
15256
|
+
if (r > this[n].length) throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part (" + this[n].length + ")");
|
|
15257
|
+
}
|
|
15258
|
+
}
|
|
15259
|
+
handleRangeWithStepping(e, t, r, n) {
|
|
15260
|
+
if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");
|
|
15261
|
+
let i = this.extractNth(e, t), a = i[0].match(/^(\d+)-(\d+)\/(\d+)$/);
|
|
15262
|
+
if (a === null) throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '" + e + "'");
|
|
15263
|
+
let [, o, h, l] = a, y = parseInt(o, 10) + r, u = parseInt(h, 10) + r, d = parseInt(l, 10);
|
|
15264
|
+
this.validateNotNaN(y, "CronPattern: Syntax error, illegal lower range (NaN)"), this.validateNotNaN(u, "CronPattern: Syntax error, illegal upper range (NaN)"), this.validateNotNaN(d, "CronPattern: Syntax error, illegal stepping: (NaN)"), this.validateRange(y, u, d, t, e);
|
|
15265
|
+
for (let c = y; c <= u; c += d) this.setPart(t, c, i[1] || n);
|
|
15266
|
+
}
|
|
15267
|
+
extractNth(e, t) {
|
|
15268
|
+
let r = e, n;
|
|
15269
|
+
if (r.includes("#")) {
|
|
15270
|
+
if (t !== "dayOfWeek") throw new Error("CronPattern: nth (#) only allowed in day-of-week field");
|
|
15271
|
+
n = r.split("#")[1], r = r.split("#")[0];
|
|
15272
|
+
} else if (r.toUpperCase().endsWith("L")) {
|
|
15273
|
+
if (t !== "dayOfWeek") throw new Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");
|
|
15274
|
+
n = "L", r = r.slice(0, -1);
|
|
15275
|
+
}
|
|
15276
|
+
return [r, n];
|
|
15277
|
+
}
|
|
15278
|
+
handleRange(e, t, r, n) {
|
|
15279
|
+
if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in a range.");
|
|
15280
|
+
let i = this.extractNth(e, t), a = i[0].split("-");
|
|
15281
|
+
if (a.length !== 2) throw new TypeError("CronPattern: Syntax error, illegal range: '" + e + "'");
|
|
15282
|
+
let o = parseInt(a[0], 10) + r, h = parseInt(a[1], 10) + r;
|
|
15283
|
+
this.validateNotNaN(o, "CronPattern: Syntax error, illegal lower range (NaN)"), this.validateNotNaN(h, "CronPattern: Syntax error, illegal upper range (NaN)"), this.validateRange(o, h, void 0, t, e);
|
|
15284
|
+
for (let l = o; l <= h; l++) this.setPart(t, l, i[1] || n);
|
|
15285
|
+
}
|
|
15286
|
+
handleStepping(e, t, r, n) {
|
|
15287
|
+
if (e.toUpperCase().includes("W")) throw new TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");
|
|
15288
|
+
let i = this.extractNth(e, t), a = i[0].split("/");
|
|
15289
|
+
if (a.length !== 2) throw new TypeError("CronPattern: Syntax error, illegal stepping: '" + e + "'");
|
|
15290
|
+
if (this.sloppyRanges) a[0] === "" && (a[0] = "*");
|
|
15291
|
+
else {
|
|
15292
|
+
if (a[0] === "") throw new TypeError("CronPattern: Syntax error, stepping with missing prefix ('" + e + "') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");
|
|
15293
|
+
if (a[0] !== "*") throw new TypeError("CronPattern: Syntax error, stepping with numeric prefix ('" + e + "') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");
|
|
15294
|
+
}
|
|
15295
|
+
let o = 0;
|
|
15296
|
+
a[0] !== "*" && (o = parseInt(a[0], 10) + r);
|
|
15297
|
+
let h = parseInt(a[1], 10);
|
|
15298
|
+
this.validateNotNaN(h, "CronPattern: Syntax error, illegal stepping: (NaN)"), this.validateRange(0, this[t].length - 1, h, t, e);
|
|
15299
|
+
for (let l = o; l < this[t].length; l += h) this.setPart(t, l, i[1] || n);
|
|
15300
|
+
}
|
|
15301
|
+
replaceAlphaDays(e) {
|
|
15302
|
+
return e.replace(/-sun/gi, "-7").replace(/sun/gi, "0").replace(/mon/gi, "1").replace(/tue/gi, "2").replace(/wed/gi, "3").replace(/thu/gi, "4").replace(/fri/gi, "5").replace(/sat/gi, "6");
|
|
15303
|
+
}
|
|
15304
|
+
replaceAlphaDaysQuartz(e) {
|
|
15305
|
+
return e.replace(/sun/gi, "1").replace(/mon/gi, "2").replace(/tue/gi, "3").replace(/wed/gi, "4").replace(/thu/gi, "5").replace(/fri/gi, "6").replace(/sat/gi, "7");
|
|
15306
|
+
}
|
|
15307
|
+
replaceAlphaMonths(e) {
|
|
15308
|
+
return e.replace(/jan/gi, "1").replace(/feb/gi, "2").replace(/mar/gi, "3").replace(/apr/gi, "4").replace(/may/gi, "5").replace(/jun/gi, "6").replace(/jul/gi, "7").replace(/aug/gi, "8").replace(/sep/gi, "9").replace(/oct/gi, "10").replace(/nov/gi, "11").replace(/dec/gi, "12");
|
|
15309
|
+
}
|
|
15310
|
+
handleNicknames(e) {
|
|
15311
|
+
let t = e.trim().toLowerCase();
|
|
15312
|
+
if (t === "@yearly" || t === "@annually") return "0 0 1 1 *";
|
|
15313
|
+
if (t === "@monthly") return "0 0 1 * *";
|
|
15314
|
+
if (t === "@weekly") return "0 0 * * 0";
|
|
15315
|
+
if (t === "@daily" || t === "@midnight") return "0 0 * * *";
|
|
15316
|
+
if (t === "@hourly") return "0 * * * *";
|
|
15317
|
+
if (t === "@reboot") throw new TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");
|
|
15318
|
+
return e;
|
|
15319
|
+
}
|
|
15320
|
+
setNthWeekdayOfMonth(e, t) {
|
|
15321
|
+
if (typeof t != "number" && t.toUpperCase() === "L") this.dayOfWeek[e] = this.dayOfWeek[e] | 32;
|
|
15322
|
+
else if (t === 63) this.dayOfWeek[e] = 63;
|
|
15323
|
+
else if (t < 6 && t > 0) this.dayOfWeek[e] = this.dayOfWeek[e] | O[t - 1];
|
|
15324
|
+
else throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`);
|
|
15325
|
+
}
|
|
15326
|
+
};
|
|
15327
|
+
var P = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
15328
|
+
var f = [["month", "year", 0], ["day", "month", -1], ["hour", "day", 0], ["minute", "hour", 0], ["second", "minute", 0]];
|
|
15329
|
+
var m = class s {
|
|
15330
|
+
tz;
|
|
15331
|
+
ms;
|
|
15332
|
+
second;
|
|
15333
|
+
minute;
|
|
15334
|
+
hour;
|
|
15335
|
+
day;
|
|
15336
|
+
month;
|
|
15337
|
+
year;
|
|
15338
|
+
constructor(e, t) {
|
|
15339
|
+
if (this.tz = t, e && e instanceof Date) if (!isNaN(e)) this.fromDate(e);
|
|
15340
|
+
else throw new TypeError("CronDate: Invalid date passed to CronDate constructor");
|
|
15341
|
+
else if (e == null) this.fromDate(/* @__PURE__ */ new Date());
|
|
15342
|
+
else if (e && typeof e == "string") this.fromString(e);
|
|
15343
|
+
else if (e instanceof s) this.fromCronDate(e);
|
|
15344
|
+
else throw new TypeError("CronDate: Invalid type (" + typeof e + ") passed to CronDate constructor");
|
|
15345
|
+
}
|
|
15346
|
+
getLastDayOfMonth(e, t) {
|
|
15347
|
+
return t !== 1 ? P[t] : new Date(Date.UTC(e, t + 1, 0)).getUTCDate();
|
|
15348
|
+
}
|
|
15349
|
+
getLastWeekday(e, t) {
|
|
15350
|
+
let r = this.getLastDayOfMonth(e, t), i = new Date(Date.UTC(e, t, r)).getUTCDay();
|
|
15351
|
+
return i === 0 ? r - 2 : i === 6 ? r - 1 : r;
|
|
15352
|
+
}
|
|
15353
|
+
getNearestWeekday(e, t, r) {
|
|
15354
|
+
let n = this.getLastDayOfMonth(e, t);
|
|
15355
|
+
if (r > n) return -1;
|
|
15356
|
+
let a = new Date(Date.UTC(e, t, r)).getUTCDay();
|
|
15357
|
+
return a === 0 ? r === n ? r - 2 : r + 1 : a === 6 ? r === 1 ? r + 2 : r - 1 : r;
|
|
15358
|
+
}
|
|
15359
|
+
isNthWeekdayOfMonth(e, t, r, n) {
|
|
15360
|
+
let a = new Date(Date.UTC(e, t, r)).getUTCDay(), o = 0;
|
|
15361
|
+
for (let h = 1; h <= r; h++) new Date(Date.UTC(e, t, h)).getUTCDay() === a && o++;
|
|
15362
|
+
if (n & 63 && O[o - 1] & n) return true;
|
|
15363
|
+
if (n & 32) {
|
|
15364
|
+
let h = this.getLastDayOfMonth(e, t);
|
|
15365
|
+
for (let l = r + 1; l <= h; l++) if (new Date(Date.UTC(e, t, l)).getUTCDay() === a) return false;
|
|
15366
|
+
return true;
|
|
15367
|
+
}
|
|
15368
|
+
return false;
|
|
15369
|
+
}
|
|
15370
|
+
fromDate(e) {
|
|
15371
|
+
if (this.tz !== void 0) if (typeof this.tz == "number") this.ms = e.getUTCMilliseconds(), this.second = e.getUTCSeconds(), this.minute = e.getUTCMinutes() + this.tz, this.hour = e.getUTCHours(), this.day = e.getUTCDate(), this.month = e.getUTCMonth(), this.year = e.getUTCFullYear(), this.apply();
|
|
15372
|
+
else try {
|
|
15373
|
+
let t = g(e, this.tz);
|
|
15374
|
+
this.ms = e.getMilliseconds(), this.second = t.s, this.minute = t.i, this.hour = t.h, this.day = t.d, this.month = t.m - 1, this.year = t.y;
|
|
15375
|
+
} catch (t) {
|
|
15376
|
+
let r = t instanceof Error ? t.message : String(t);
|
|
15377
|
+
throw new TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${r}`);
|
|
15378
|
+
}
|
|
15379
|
+
else this.ms = e.getMilliseconds(), this.second = e.getSeconds(), this.minute = e.getMinutes(), this.hour = e.getHours(), this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear();
|
|
15380
|
+
}
|
|
15381
|
+
fromCronDate(e) {
|
|
15382
|
+
this.tz = e.tz, this.year = e.year, this.month = e.month, this.day = e.day, this.hour = e.hour, this.minute = e.minute, this.second = e.second, this.ms = e.ms;
|
|
15383
|
+
}
|
|
15384
|
+
apply() {
|
|
15385
|
+
if (this.month > 11 || this.month < 0 || this.day > P[this.month] || this.day < 1 || this.hour > 59 || this.minute > 59 || this.second > 59 || this.hour < 0 || this.minute < 0 || this.second < 0) {
|
|
15386
|
+
let e = new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms));
|
|
15387
|
+
return this.ms = e.getUTCMilliseconds(), this.second = e.getUTCSeconds(), this.minute = e.getUTCMinutes(), this.hour = e.getUTCHours(), this.day = e.getUTCDate(), this.month = e.getUTCMonth(), this.year = e.getUTCFullYear(), true;
|
|
15388
|
+
} else return false;
|
|
15389
|
+
}
|
|
15390
|
+
fromString(e) {
|
|
15391
|
+
if (typeof this.tz == "number") {
|
|
15392
|
+
let t = v(e);
|
|
15393
|
+
this.ms = t.getUTCMilliseconds(), this.second = t.getUTCSeconds(), this.minute = t.getUTCMinutes(), this.hour = t.getUTCHours(), this.day = t.getUTCDate(), this.month = t.getUTCMonth(), this.year = t.getUTCFullYear(), this.apply();
|
|
15394
|
+
} else return this.fromDate(v(e, this.tz));
|
|
15395
|
+
}
|
|
15396
|
+
findNext(e, t, r, n) {
|
|
15397
|
+
return this._findMatch(e, t, r, n, 1);
|
|
15398
|
+
}
|
|
15399
|
+
_findMatch(e, t, r, n, i) {
|
|
15400
|
+
let a = this[t], o;
|
|
15401
|
+
r.lastDayOfMonth && (o = this.getLastDayOfMonth(this.year, this.month));
|
|
15402
|
+
let h = !r.starDOW && t == "day" ? new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay() : void 0, l = this[t] + n, y = i === 1 ? (u) => u < r[t].length : (u) => u >= 0;
|
|
15403
|
+
for (let u = l; y(u); u += i) {
|
|
15404
|
+
let d = r[t][u];
|
|
15405
|
+
if (t === "day" && !d) {
|
|
15406
|
+
for (let c = 0; c < r.nearestWeekdays.length; c++) if (r.nearestWeekdays[c]) {
|
|
15407
|
+
let M = this.getNearestWeekday(this.year, this.month, c - n);
|
|
15408
|
+
if (M === -1) continue;
|
|
15409
|
+
if (M === u - n) {
|
|
15410
|
+
d = 1;
|
|
15411
|
+
break;
|
|
15412
|
+
}
|
|
15413
|
+
}
|
|
15414
|
+
}
|
|
15415
|
+
if (t === "day" && r.lastWeekday) {
|
|
15416
|
+
let c = this.getLastWeekday(this.year, this.month);
|
|
15417
|
+
u - n === c && (d = 1);
|
|
15418
|
+
}
|
|
15419
|
+
if (t === "day" && r.lastDayOfMonth && u - n == o && (d = 1), t === "day" && !r.starDOW) {
|
|
15420
|
+
let c = r.dayOfWeek[(h + (u - n - 1)) % 7];
|
|
15421
|
+
if (c && c & 63) c = this.isNthWeekdayOfMonth(this.year, this.month, u - n, c) ? 1 : 0;
|
|
15422
|
+
else if (c) throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${c}`);
|
|
15423
|
+
r.useAndLogic ? d = d && c : !e.domAndDow && !r.starDOM ? d = d || c : d = d && c;
|
|
15424
|
+
}
|
|
15425
|
+
if (d) return this[t] = u - n, a !== this[t] ? 2 : 1;
|
|
15426
|
+
}
|
|
15427
|
+
return 3;
|
|
15428
|
+
}
|
|
15429
|
+
recurse(e, t, r) {
|
|
15430
|
+
if (r === 0 && !e.starYear) {
|
|
15431
|
+
if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
|
|
15432
|
+
let i = -1;
|
|
15433
|
+
for (let a = this.year + 1; a < e.year.length && a < 1e4; a++) if (e.year[a] === 1) {
|
|
15434
|
+
i = a;
|
|
15435
|
+
break;
|
|
15436
|
+
}
|
|
15437
|
+
if (i === -1) return null;
|
|
15438
|
+
this.year = i, this.month = 0, this.day = 1, this.hour = 0, this.minute = 0, this.second = 0, this.ms = 0;
|
|
15439
|
+
}
|
|
15440
|
+
if (this.year >= 1e4) return null;
|
|
15441
|
+
}
|
|
15442
|
+
let n = this.findNext(t, f[r][0], e, f[r][2]);
|
|
15443
|
+
if (n > 1) {
|
|
15444
|
+
let i = r + 1;
|
|
15445
|
+
for (; i < f.length; ) this[f[i][0]] = -f[i][2], i++;
|
|
15446
|
+
if (n === 3) {
|
|
15447
|
+
if (this[f[r][1]]++, this[f[r][0]] = -f[r][2], this.apply(), r === 0 && !e.starYear) {
|
|
15448
|
+
for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0 && this.year < 1e4; ) this.year++;
|
|
15449
|
+
if (this.year >= 1e4 || this.year >= e.year.length) return null;
|
|
15450
|
+
}
|
|
15451
|
+
return this.recurse(e, t, 0);
|
|
15452
|
+
} else if (this.apply()) return this.recurse(e, t, r - 1);
|
|
15453
|
+
}
|
|
15454
|
+
return r += 1, r >= f.length ? this : (e.starYear ? this.year >= 3e3 : this.year >= 1e4) ? null : this.recurse(e, t, r);
|
|
15455
|
+
}
|
|
15456
|
+
increment(e, t, r) {
|
|
15457
|
+
return this.second += t.interval !== void 0 && t.interval > 1 && r ? t.interval : 1, this.ms = 0, this.apply(), this.recurse(e, t, 0);
|
|
15458
|
+
}
|
|
15459
|
+
decrement(e, t) {
|
|
15460
|
+
return this.second -= t.interval !== void 0 && t.interval > 1 ? t.interval : 1, this.ms = 0, this.apply(), this.recurseBackward(e, t, 0, 0);
|
|
15461
|
+
}
|
|
15462
|
+
recurseBackward(e, t, r, n = 0) {
|
|
15463
|
+
if (n > 1e4) return null;
|
|
15464
|
+
if (r === 0 && !e.starYear) {
|
|
15465
|
+
if (this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0) {
|
|
15466
|
+
let a = -1;
|
|
15467
|
+
for (let o = this.year - 1; o >= 0; o--) if (e.year[o] === 1) {
|
|
15468
|
+
a = o;
|
|
15469
|
+
break;
|
|
15470
|
+
}
|
|
15471
|
+
if (a === -1) return null;
|
|
15472
|
+
this.year = a, this.month = 11, this.day = 31, this.hour = 23, this.minute = 59, this.second = 59, this.ms = 0;
|
|
15473
|
+
}
|
|
15474
|
+
if (this.year < 0) return null;
|
|
15475
|
+
}
|
|
15476
|
+
let i = this.findPrevious(t, f[r][0], e, f[r][2]);
|
|
15477
|
+
if (i > 1) {
|
|
15478
|
+
let a = r + 1;
|
|
15479
|
+
for (; a < f.length; ) {
|
|
15480
|
+
let o = f[a][0], h = f[a][2], l = this.getMaxPatternValue(o, e, h);
|
|
15481
|
+
this[o] = l, a++;
|
|
15482
|
+
}
|
|
15483
|
+
if (i === 3) {
|
|
15484
|
+
if (this[f[r][1]]--, r === 0) {
|
|
15485
|
+
let y = this.getLastDayOfMonth(this.year, this.month);
|
|
15486
|
+
this.day > y && (this.day = y);
|
|
15487
|
+
}
|
|
15488
|
+
if (r === 1) if (this.day <= 0) this.day = 1;
|
|
15489
|
+
else {
|
|
15490
|
+
let y = this.year, u = this.month;
|
|
15491
|
+
for (; u < 0; ) u += 12, y--;
|
|
15492
|
+
for (; u > 11; ) u -= 12, y++;
|
|
15493
|
+
let d = u !== 1 ? P[u] : new Date(Date.UTC(y, u + 1, 0)).getUTCDate();
|
|
15494
|
+
this.day > d && (this.day = d);
|
|
15495
|
+
}
|
|
15496
|
+
this.apply();
|
|
15497
|
+
let o = f[r][0], h = f[r][2], l = this.getMaxPatternValue(o, e, h);
|
|
15498
|
+
if (o === "day") {
|
|
15499
|
+
let y = this.getLastDayOfMonth(this.year, this.month);
|
|
15500
|
+
this[o] = Math.min(l, y);
|
|
15501
|
+
} else this[o] = l;
|
|
15502
|
+
if (this.apply(), r === 0) {
|
|
15503
|
+
let y = f[1][2], u = this.getMaxPatternValue("day", e, y), d = this.getLastDayOfMonth(this.year, this.month), c = Math.min(u, d);
|
|
15504
|
+
c !== this.day && (this.day = c, this.hour = this.getMaxPatternValue("hour", e, f[2][2]), this.minute = this.getMaxPatternValue("minute", e, f[3][2]), this.second = this.getMaxPatternValue("second", e, f[4][2]));
|
|
15505
|
+
}
|
|
15506
|
+
if (r === 0 && !e.starYear) {
|
|
15507
|
+
for (; this.year >= 0 && this.year < e.year.length && e.year[this.year] === 0; ) this.year--;
|
|
15508
|
+
if (this.year < 0) return null;
|
|
15509
|
+
}
|
|
15510
|
+
return this.recurseBackward(e, t, 0, n + 1);
|
|
15511
|
+
} else if (this.apply()) return this.recurseBackward(e, t, r - 1, n + 1);
|
|
15512
|
+
}
|
|
15513
|
+
return r += 1, r >= f.length ? this : this.year < 0 ? null : this.recurseBackward(e, t, r, n + 1);
|
|
15514
|
+
}
|
|
15515
|
+
getMaxPatternValue(e, t, r) {
|
|
15516
|
+
if (e === "day" && t.lastDayOfMonth) return this.getLastDayOfMonth(this.year, this.month);
|
|
15517
|
+
if (e === "day" && !t.starDOW) return this.getLastDayOfMonth(this.year, this.month);
|
|
15518
|
+
for (let n = t[e].length - 1; n >= 0; n--) if (t[e][n]) return n - r;
|
|
15519
|
+
return t[e].length - 1 - r;
|
|
15520
|
+
}
|
|
15521
|
+
findPrevious(e, t, r, n) {
|
|
15522
|
+
return this._findMatch(e, t, r, n, -1);
|
|
15523
|
+
}
|
|
15524
|
+
getDate(e) {
|
|
15525
|
+
return e || this.tz === void 0 ? new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms) : typeof this.tz == "number" ? new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute - this.tz, this.second, this.ms)) : k(b(this.year, this.month + 1, this.day, this.hour, this.minute, this.second, this.tz), false);
|
|
15526
|
+
}
|
|
15527
|
+
getTime() {
|
|
15528
|
+
return this.getDate(false).getTime();
|
|
15529
|
+
}
|
|
15530
|
+
match(e, t) {
|
|
15531
|
+
if (!e.starYear && (this.year < 0 || this.year >= e.year.length || e.year[this.year] === 0)) return false;
|
|
15532
|
+
for (let r = 0; r < f.length; r++) {
|
|
15533
|
+
let n = f[r][0], i = f[r][2], a = this[n];
|
|
15534
|
+
if (a + i < 0 || a + i >= e[n].length) return false;
|
|
15535
|
+
let o = e[n][a + i];
|
|
15536
|
+
if (n === "day") {
|
|
15537
|
+
if (!o) {
|
|
15538
|
+
for (let h = 0; h < e.nearestWeekdays.length; h++) if (e.nearestWeekdays[h]) {
|
|
15539
|
+
let l = this.getNearestWeekday(this.year, this.month, h - i);
|
|
15540
|
+
if (l !== -1 && l === a) {
|
|
15541
|
+
o = 1;
|
|
15542
|
+
break;
|
|
15543
|
+
}
|
|
15544
|
+
}
|
|
15545
|
+
}
|
|
15546
|
+
if (e.lastWeekday) {
|
|
15547
|
+
let h = this.getLastWeekday(this.year, this.month);
|
|
15548
|
+
a === h && (o = 1);
|
|
15549
|
+
}
|
|
15550
|
+
if (e.lastDayOfMonth) {
|
|
15551
|
+
let h = this.getLastDayOfMonth(this.year, this.month);
|
|
15552
|
+
a === h && (o = 1);
|
|
15553
|
+
}
|
|
15554
|
+
if (!e.starDOW) {
|
|
15555
|
+
let h = new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay(), l = e.dayOfWeek[(h + (a - 1)) % 7];
|
|
15556
|
+
l && l & 63 && (l = this.isNthWeekdayOfMonth(this.year, this.month, a, l) ? 1 : 0), e.useAndLogic ? o = o && l : !t.domAndDow && !e.starDOM ? o = o || l : o = o && l;
|
|
15557
|
+
}
|
|
15558
|
+
}
|
|
15559
|
+
if (!o) return false;
|
|
15560
|
+
}
|
|
15561
|
+
return true;
|
|
15562
|
+
}
|
|
15563
|
+
};
|
|
15564
|
+
function R(s2) {
|
|
15565
|
+
if (s2 === void 0 && (s2 = {}), delete s2.name, s2.legacyMode !== void 0 && s2.domAndDow === void 0 ? s2.domAndDow = !s2.legacyMode : s2.domAndDow === void 0 && (s2.domAndDow = false), s2.legacyMode = !s2.domAndDow, s2.paused = s2.paused === void 0 ? false : s2.paused, s2.maxRuns = s2.maxRuns === void 0 ? 1 / 0 : s2.maxRuns, s2.catch = s2.catch === void 0 ? false : s2.catch, s2.interval = s2.interval === void 0 ? 0 : parseInt(s2.interval.toString(), 10), s2.utcOffset = s2.utcOffset === void 0 ? void 0 : parseInt(s2.utcOffset.toString(), 10), s2.dayOffset = s2.dayOffset === void 0 ? 0 : parseInt(s2.dayOffset.toString(), 10), s2.unref = s2.unref === void 0 ? false : s2.unref, s2.mode = s2.mode === void 0 ? "auto" : s2.mode, s2.alternativeWeekdays = s2.alternativeWeekdays === void 0 ? false : s2.alternativeWeekdays, s2.sloppyRanges = s2.sloppyRanges === void 0 ? false : s2.sloppyRanges, !["auto", "5-part", "6-part", "7-part", "5-or-6-parts", "6-or-7-parts"].includes(s2.mode)) throw new Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");
|
|
15566
|
+
if (s2.startAt && (s2.startAt = new m(s2.startAt, s2.timezone)), s2.stopAt && (s2.stopAt = new m(s2.stopAt, s2.timezone)), s2.interval !== null) {
|
|
15567
|
+
if (isNaN(s2.interval)) throw new Error("CronOptions: Supplied value for interval is not a number");
|
|
15568
|
+
if (s2.interval < 0) throw new Error("CronOptions: Supplied value for interval can not be negative");
|
|
15569
|
+
}
|
|
15570
|
+
if (s2.utcOffset !== void 0) {
|
|
15571
|
+
if (isNaN(s2.utcOffset)) throw new Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");
|
|
15572
|
+
if (s2.utcOffset < -870 || s2.utcOffset > 870) throw new Error("CronOptions: utcOffset out of bounds.");
|
|
15573
|
+
if (s2.utcOffset !== void 0 && s2.timezone) throw new Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.");
|
|
15574
|
+
}
|
|
15575
|
+
if (s2.unref !== true && s2.unref !== false) throw new Error("CronOptions: Unref should be either true, false or undefined(false).");
|
|
15576
|
+
if (s2.dayOffset !== void 0 && s2.dayOffset !== 0 && isNaN(s2.dayOffset)) throw new Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");
|
|
15577
|
+
return s2;
|
|
15578
|
+
}
|
|
15579
|
+
function p(s2) {
|
|
15580
|
+
return Object.prototype.toString.call(s2) === "[object Function]" || typeof s2 == "function" || s2 instanceof Function;
|
|
15581
|
+
}
|
|
15582
|
+
function _(s2) {
|
|
15583
|
+
return p(s2);
|
|
15584
|
+
}
|
|
15585
|
+
function x(s2) {
|
|
15586
|
+
typeof Deno < "u" && typeof Deno.unrefTimer < "u" ? Deno.unrefTimer(s2) : s2 && typeof s2.unref < "u" && s2.unref();
|
|
15587
|
+
}
|
|
15588
|
+
var W = 30 * 1e3;
|
|
15589
|
+
var w = [];
|
|
15590
|
+
var E = class {
|
|
15591
|
+
name;
|
|
15592
|
+
options;
|
|
15593
|
+
_states;
|
|
15594
|
+
fn;
|
|
15595
|
+
getTz() {
|
|
15596
|
+
return this.options.timezone || this.options.utcOffset;
|
|
15597
|
+
}
|
|
15598
|
+
applyDayOffset(e) {
|
|
15599
|
+
if (this.options.dayOffset !== void 0 && this.options.dayOffset !== 0) {
|
|
15600
|
+
let t = this.options.dayOffset * 24 * 60 * 60 * 1e3;
|
|
15601
|
+
return new Date(e.getTime() + t);
|
|
15602
|
+
}
|
|
15603
|
+
return e;
|
|
15604
|
+
}
|
|
15605
|
+
constructor(e, t, r) {
|
|
15606
|
+
let n, i;
|
|
15607
|
+
if (p(t)) i = t;
|
|
15608
|
+
else if (typeof t == "object") n = t;
|
|
15609
|
+
else if (t !== void 0) throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");
|
|
15610
|
+
if (p(r)) i = r;
|
|
15611
|
+
else if (typeof r == "object") n = r;
|
|
15612
|
+
else if (r !== void 0) throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");
|
|
15613
|
+
if (this.name = n?.name, this.options = R(n), this._states = { kill: false, blocking: false, previousRun: void 0, currentRun: void 0, once: void 0, currentTimeout: void 0, maxRuns: n ? n.maxRuns : void 0, paused: n ? n.paused : false, pattern: new C("* * * * *", void 0, { mode: "auto" }) }, e && (e instanceof Date || typeof e == "string" && e.indexOf(":") > 0) ? this._states.once = new m(e, this.getTz()) : this._states.pattern = new C(e, this.options.timezone, { mode: this.options.mode, alternativeWeekdays: this.options.alternativeWeekdays, sloppyRanges: this.options.sloppyRanges }), this.name) {
|
|
15614
|
+
if (w.find((o) => o.name === this.name)) throw new Error("Cron: Tried to initialize new named job '" + this.name + "', but name already taken.");
|
|
15615
|
+
w.push(this);
|
|
15616
|
+
}
|
|
15617
|
+
return i !== void 0 && _(i) && (this.fn = i, this.schedule()), this;
|
|
15618
|
+
}
|
|
15619
|
+
nextRun(e) {
|
|
15620
|
+
let t = this._next(e);
|
|
15621
|
+
return t ? this.applyDayOffset(t.getDate(false)) : null;
|
|
15622
|
+
}
|
|
15623
|
+
nextRuns(e, t) {
|
|
15624
|
+
this._states.maxRuns !== void 0 && e > this._states.maxRuns && (e = this._states.maxRuns);
|
|
15625
|
+
let r = t || this._states.currentRun || void 0;
|
|
15626
|
+
return this._enumerateRuns(e, r, "next");
|
|
15627
|
+
}
|
|
15628
|
+
previousRuns(e, t) {
|
|
15629
|
+
return this._enumerateRuns(e, t || void 0, "previous");
|
|
15630
|
+
}
|
|
15631
|
+
_enumerateRuns(e, t, r) {
|
|
15632
|
+
let n = [], i = t ? new m(t, this.getTz()) : null, a = r === "next" ? this._next : this._previous;
|
|
15633
|
+
for (; e--; ) {
|
|
15634
|
+
let o = a.call(this, i);
|
|
15635
|
+
if (!o) break;
|
|
15636
|
+
let h = o.getDate(false);
|
|
15637
|
+
n.push(this.applyDayOffset(h)), i = o;
|
|
15638
|
+
}
|
|
15639
|
+
return n;
|
|
15640
|
+
}
|
|
15641
|
+
match(e) {
|
|
15642
|
+
if (this._states.once) {
|
|
15643
|
+
let r = new m(e, this.getTz());
|
|
15644
|
+
r.ms = 0;
|
|
15645
|
+
let n = new m(this._states.once, this.getTz());
|
|
15646
|
+
return n.ms = 0, r.getTime() === n.getTime();
|
|
15647
|
+
}
|
|
15648
|
+
let t = new m(e, this.getTz());
|
|
15649
|
+
return t.ms = 0, t.match(this._states.pattern, this.options);
|
|
15650
|
+
}
|
|
15651
|
+
getPattern() {
|
|
15652
|
+
if (!this._states.once) return this._states.pattern ? this._states.pattern.pattern : void 0;
|
|
15653
|
+
}
|
|
15654
|
+
getOnce() {
|
|
15655
|
+
return this._states.once ? this._states.once.getDate() : null;
|
|
15656
|
+
}
|
|
15657
|
+
isRunning() {
|
|
15658
|
+
let e = this.nextRun(this._states.currentRun), t = !this._states.paused, r = this.fn !== void 0, n = !this._states.kill;
|
|
15659
|
+
return t && r && n && e !== null;
|
|
15660
|
+
}
|
|
15661
|
+
isStopped() {
|
|
15662
|
+
return this._states.kill;
|
|
15663
|
+
}
|
|
15664
|
+
isBusy() {
|
|
15665
|
+
return this._states.blocking;
|
|
15666
|
+
}
|
|
15667
|
+
currentRun() {
|
|
15668
|
+
return this._states.currentRun ? this._states.currentRun.getDate() : null;
|
|
15669
|
+
}
|
|
15670
|
+
previousRun() {
|
|
15671
|
+
return this._states.previousRun ? this._states.previousRun.getDate() : null;
|
|
15672
|
+
}
|
|
15673
|
+
msToNext(e) {
|
|
15674
|
+
let t = this._next(e);
|
|
15675
|
+
return t ? e instanceof m || e instanceof Date ? t.getTime() - e.getTime() : t.getTime() - new m(e).getTime() : null;
|
|
15676
|
+
}
|
|
15677
|
+
stop() {
|
|
15678
|
+
this._states.kill = true, this._states.currentTimeout && clearTimeout(this._states.currentTimeout);
|
|
15679
|
+
let e = w.indexOf(this);
|
|
15680
|
+
e >= 0 && w.splice(e, 1);
|
|
15681
|
+
}
|
|
15682
|
+
pause() {
|
|
15683
|
+
return this._states.paused = true, !this._states.kill;
|
|
15684
|
+
}
|
|
15685
|
+
resume() {
|
|
15686
|
+
return this._states.paused = false, !this._states.kill;
|
|
15687
|
+
}
|
|
15688
|
+
schedule(e) {
|
|
15689
|
+
if (e && this.fn) throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");
|
|
15690
|
+
e && (this.fn = e);
|
|
15691
|
+
let t = this.msToNext(), r = this.nextRun(this._states.currentRun);
|
|
15692
|
+
return t == null || isNaN(t) || r === null ? this : (t > W && (t = W), this._states.currentTimeout = setTimeout(() => this._checkTrigger(r), t), this._states.currentTimeout && this.options.unref && x(this._states.currentTimeout), this);
|
|
15693
|
+
}
|
|
15694
|
+
async _trigger(e) {
|
|
15695
|
+
this._states.blocking = true, this._states.currentRun = new m(void 0, this.getTz());
|
|
15696
|
+
try {
|
|
15697
|
+
if (this.options.catch) try {
|
|
15698
|
+
this.fn !== void 0 && await this.fn(this, this.options.context);
|
|
15699
|
+
} catch (t) {
|
|
15700
|
+
if (p(this.options.catch)) try {
|
|
15701
|
+
this.options.catch(t, this);
|
|
15702
|
+
} catch {
|
|
15703
|
+
}
|
|
15704
|
+
}
|
|
15705
|
+
else this.fn !== void 0 && await this.fn(this, this.options.context);
|
|
15706
|
+
} finally {
|
|
15707
|
+
this._states.previousRun = new m(e, this.getTz()), this._states.blocking = false;
|
|
15708
|
+
}
|
|
15709
|
+
}
|
|
15710
|
+
async trigger() {
|
|
15711
|
+
await this._trigger();
|
|
15712
|
+
}
|
|
15713
|
+
runsLeft() {
|
|
15714
|
+
return this._states.maxRuns;
|
|
15715
|
+
}
|
|
15716
|
+
_checkTrigger(e) {
|
|
15717
|
+
let t = /* @__PURE__ */ new Date(), r = !this._states.paused && t.getTime() >= e.getTime(), n = this._states.blocking && this.options.protect;
|
|
15718
|
+
r && !n ? (this._states.maxRuns !== void 0 && this._states.maxRuns--, this._trigger()) : r && n && p(this.options.protect) && setTimeout(() => this.options.protect(this), 0), this.schedule();
|
|
15719
|
+
}
|
|
15720
|
+
_next(e) {
|
|
15721
|
+
let t = !!(e || this._states.currentRun), r = false;
|
|
15722
|
+
!e && this.options.startAt && this.options.interval && ([e, t] = this._calculatePreviousRun(e, t), r = !e), e = new m(e, this.getTz()), this.options.startAt && e && e.getTime() < this.options.startAt.getTime() && (e = this.options.startAt);
|
|
15723
|
+
let n = this._states.once || new m(e, this.getTz());
|
|
15724
|
+
return !r && n !== this._states.once && (n = n.increment(this._states.pattern, this.options, t)), this._states.once && this._states.once.getTime() <= e.getTime() || n === null || this._states.maxRuns !== void 0 && this._states.maxRuns <= 0 || this._states.kill || this.options.stopAt && n.getTime() >= this.options.stopAt.getTime() ? null : n;
|
|
15725
|
+
}
|
|
15726
|
+
_previous(e) {
|
|
15727
|
+
let t = new m(e, this.getTz());
|
|
15728
|
+
this.options.stopAt && t.getTime() > this.options.stopAt.getTime() && (t = this.options.stopAt);
|
|
15729
|
+
let r = new m(t, this.getTz());
|
|
15730
|
+
return this._states.once ? this._states.once.getTime() < t.getTime() ? this._states.once : null : (r = r.decrement(this._states.pattern, this.options), r === null || this.options.startAt && r.getTime() < this.options.startAt.getTime() ? null : r);
|
|
15731
|
+
}
|
|
15732
|
+
_calculatePreviousRun(e, t) {
|
|
15733
|
+
let r = new m(void 0, this.getTz()), n = e;
|
|
15734
|
+
if (this.options.startAt.getTime() <= r.getTime()) {
|
|
15735
|
+
n = this.options.startAt;
|
|
15736
|
+
let i = n.getTime() + this.options.interval * 1e3;
|
|
15737
|
+
for (; i <= r.getTime(); ) n = new m(n, this.getTz()).increment(this._states.pattern, this.options, true), i = n.getTime() + this.options.interval * 1e3;
|
|
15738
|
+
t = true;
|
|
15739
|
+
}
|
|
15740
|
+
return n === null && (n = void 0), [n, t];
|
|
15741
|
+
}
|
|
15742
|
+
};
|
|
15743
|
+
|
|
15744
|
+
// shared/routine-schedule.ts
|
|
15745
|
+
var MAX_EXPRESSION_LENGTH = 256;
|
|
15746
|
+
function cronCalculator(value) {
|
|
15747
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Choose a valid cron schedule");
|
|
15748
|
+
const input = value;
|
|
15749
|
+
if (input.type !== "cron" || typeof input.expression !== "string") throw new Error("Choose a valid cron schedule");
|
|
15750
|
+
if (Object.keys(input).some((key) => !["type", "expression", "timeZone"].includes(key))) {
|
|
15751
|
+
throw new Error("Cron schedules accept only type, expression and timeZone; start/end dates and other restrictions are not supported");
|
|
15752
|
+
}
|
|
15753
|
+
const expression = input.expression.trim().replace(/\s+/g, " ");
|
|
15754
|
+
if (expression.length > MAX_EXPRESSION_LENGTH || expression.split(" ").length !== 5 || expression.includes("@")) {
|
|
15755
|
+
throw new Error("Cron must have five fields: minute hour day-of-month month weekday (no seconds, year, or macros)");
|
|
15756
|
+
}
|
|
15757
|
+
const timeZone = typeof input.timeZone === "string" ? input.timeZone.trim() : "";
|
|
15758
|
+
if (timeZone.length > 128 || !(timeZone === "UTC" || /^[A-Za-z][A-Za-z0-9_+-]*(?:\/[A-Za-z0-9_+-]+)+$/.test(timeZone))) {
|
|
15759
|
+
throw new Error("Choose an IANA timezone such as America/New_York, Asia/Kolkata, or UTC");
|
|
15760
|
+
}
|
|
15761
|
+
try {
|
|
15762
|
+
new Intl.DateTimeFormat("en-US", { timeZone }).format(0);
|
|
15763
|
+
} catch {
|
|
15764
|
+
throw new Error("Choose a valid IANA timezone such as America/New_York, Asia/Kolkata, or UTC");
|
|
15765
|
+
}
|
|
15766
|
+
try {
|
|
15767
|
+
const cron = new E(expression, { timezone: timeZone, mode: "5-part", paused: true });
|
|
15768
|
+
return { schedule: { type: "cron", expression, timeZone }, cron };
|
|
15769
|
+
} catch (error51) {
|
|
15770
|
+
throw new Error(`Invalid cron expression: ${error51.message}`);
|
|
15771
|
+
}
|
|
15772
|
+
}
|
|
15773
|
+
function calculationDate(after) {
|
|
15774
|
+
const date5 = new Date(after);
|
|
15775
|
+
if (!Number.isFinite(after) || !Number.isFinite(date5.getTime())) throw new Error("Choose a valid cron preview date");
|
|
15776
|
+
return date5;
|
|
15777
|
+
}
|
|
15778
|
+
function futureRuns(cron, after, count) {
|
|
15779
|
+
const from = calculationDate(after);
|
|
15780
|
+
const maximum = count + 1440;
|
|
15781
|
+
let requested = count;
|
|
15782
|
+
while (true) {
|
|
15783
|
+
const candidates = cron.nextRuns(requested, from);
|
|
15784
|
+
const runs = [];
|
|
15785
|
+
for (const date5 of candidates) {
|
|
15786
|
+
const at = date5.getTime();
|
|
15787
|
+
if (!Number.isFinite(at)) throw new Error("The cron schedule produced an invalid date");
|
|
15788
|
+
if (at > (runs.at(-1) ?? after)) runs.push(at);
|
|
15789
|
+
if (runs.length === count) return runs;
|
|
15790
|
+
}
|
|
15791
|
+
if (candidates.length < requested || requested === maximum) return runs;
|
|
15792
|
+
requested = Math.min(maximum, requested * 2);
|
|
15793
|
+
}
|
|
15794
|
+
}
|
|
15795
|
+
function normalizeCronSchedule(value, after = Date.now()) {
|
|
15796
|
+
const { schedule, cron } = cronCalculator(value);
|
|
15797
|
+
if (!futureRuns(cron, after, 1).length) throw new Error("This cron expression has no future runs. Choose dates that exist.");
|
|
15798
|
+
return schedule;
|
|
15799
|
+
}
|
|
15800
|
+
|
|
15801
|
+
// server/new-bot-defaults.ts
|
|
15802
|
+
var strings = (max, length) => external_exports.array(external_exports.string().max(length)).max(max);
|
|
15803
|
+
var clock = external_exports.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/);
|
|
15804
|
+
var weekdays = external_exports.array(external_exports.number().int().min(0).max(6)).min(1).max(7);
|
|
15805
|
+
var timestamp = external_exports.number().int().nonnegative().max(864e13);
|
|
15806
|
+
var botDefaultModelSchema = external_exports.object({
|
|
15807
|
+
instanceId: external_exports.string().trim().min(1).max(200),
|
|
15808
|
+
model: external_exports.string().trim().min(1).max(500),
|
|
15809
|
+
effort: external_exports.enum(EFFORT_LEVELS).optional(),
|
|
15810
|
+
variant: external_exports.string().refine(isModelVariant, "invalid model variant").optional()
|
|
15811
|
+
}).strict().refine(
|
|
15812
|
+
(value) => value.effort === void 0 || value.variant === void 0,
|
|
15813
|
+
"choose either a model variant or an effort level"
|
|
15814
|
+
);
|
|
15815
|
+
var botDefaultsProfileSchema = profilePatchSchema.extend({
|
|
15816
|
+
name: external_exports.string().max(100).refine(fitsOnOneLine, "name must fit on one line").optional(),
|
|
15817
|
+
section: external_exports.string().trim().max(60).optional(),
|
|
15818
|
+
color: external_exports.enum(["green", "blue", "red", "orange", "purple", "cyan", "pink", "yellow", "teal", "coral"]).optional(),
|
|
15819
|
+
mascotExpression: external_exports.string().max(60).nullable().optional(),
|
|
15820
|
+
modelSelection: botDefaultModelSchema.optional(),
|
|
15821
|
+
computer: external_exports.enum(["cloud", "vm", "local", "browser", "off"]).nullable().optional(),
|
|
15822
|
+
cloudBackend: external_exports.enum(["box", "vps"]).optional(),
|
|
15823
|
+
autoStartVps: external_exports.boolean().optional(),
|
|
15824
|
+
cwd: external_exports.string().max(4096).nullable().optional(),
|
|
15825
|
+
approvalMode: external_exports.enum(["ask", "auto", "full", "custom"]).optional(),
|
|
15826
|
+
alwaysAllow: strings(200, 500).optional(),
|
|
15827
|
+
chiefOfStaff: external_exports.boolean().optional(),
|
|
15828
|
+
managedSections: strings(100, 60).optional(),
|
|
15829
|
+
approvePeerComms: external_exports.boolean().optional(),
|
|
15830
|
+
peers: strings(1e3, 100).nullable().optional(),
|
|
15831
|
+
composio: external_exports.boolean().optional(),
|
|
15832
|
+
browser: external_exports.boolean().optional(),
|
|
15833
|
+
browserProfile: external_exports.string().max(100).nullable().optional(),
|
|
15834
|
+
mcpServers: strings(100, 100).nullable().optional(),
|
|
15835
|
+
parkDirectMessages: external_exports.boolean().optional()
|
|
15836
|
+
}).strict();
|
|
15837
|
+
var scheduleSchema = external_exports.discriminatedUnion("type", [
|
|
15838
|
+
external_exports.object({ type: external_exports.literal("once"), at: timestamp }).strict(),
|
|
15839
|
+
external_exports.object({ type: external_exports.literal("daily"), time: clock, weekdays }).strict(),
|
|
15840
|
+
external_exports.object({
|
|
15841
|
+
type: external_exports.literal("interval"),
|
|
15842
|
+
everyMinutes: external_exports.number().int().min(5).max(1440),
|
|
15843
|
+
anchorAt: timestamp,
|
|
15844
|
+
weekdays: weekdays.nullable().optional(),
|
|
15845
|
+
window: external_exports.object({ start: clock, end: clock }).strict().nullable().optional(),
|
|
15846
|
+
endsAt: timestamp.nullable().optional()
|
|
15847
|
+
}).strict(),
|
|
15848
|
+
external_exports.object({ type: external_exports.literal("cron"), expression: external_exports.string().max(256), timeZone: external_exports.string().max(128) }).strict()
|
|
15849
|
+
]).superRefine((value, ctx) => {
|
|
15850
|
+
if (value.type === "cron") {
|
|
15851
|
+
try {
|
|
15852
|
+
normalizeCronSchedule(value);
|
|
15853
|
+
} catch (error51) {
|
|
15854
|
+
ctx.addIssue({ code: "custom", message: String(error51) });
|
|
15855
|
+
}
|
|
15856
|
+
}
|
|
15857
|
+
if (value.type === "interval" && value.window) {
|
|
15858
|
+
const minutes = (time3) => Number(time3.slice(0, 2)) * 60 + Number(time3.slice(3));
|
|
15859
|
+
if (minutes(value.window.end) - minutes(value.window.start) < value.everyMinutes) {
|
|
15860
|
+
ctx.addIssue({ code: "custom", message: "The interval must fit inside its time window" });
|
|
15861
|
+
}
|
|
15862
|
+
}
|
|
15863
|
+
});
|
|
15864
|
+
var botRoutineTemplateSchema = external_exports.object({
|
|
15865
|
+
name: external_exports.string().trim().min(1).max(80),
|
|
15866
|
+
prompt: external_exports.string().trim().min(1).max(2e4),
|
|
15867
|
+
schedule: scheduleSchema,
|
|
15868
|
+
enabled: external_exports.boolean().optional(),
|
|
15869
|
+
runOn: external_exports.enum(["maus", "cloud"]).optional(),
|
|
15870
|
+
durationMinutes: external_exports.number().int().min(5).max(240).optional(),
|
|
15871
|
+
timeoutMinutes: external_exports.number().min(1).max(1440).nullable().optional(),
|
|
15872
|
+
overlap: external_exports.enum(["skip", "queue"]).optional(),
|
|
15873
|
+
attachments: external_exports.array(external_exports.object({
|
|
15874
|
+
id: external_exports.string().min(1).max(200),
|
|
15875
|
+
kind: external_exports.enum(["file", "image"]),
|
|
15876
|
+
name: external_exports.string().min(1).max(255),
|
|
15877
|
+
path: external_exports.string().min(1).max(4096),
|
|
15878
|
+
size: external_exports.number().nonnegative()
|
|
15879
|
+
}).strict()).max(50).optional()
|
|
15880
|
+
}).strict();
|
|
15881
|
+
var botSkillTemplateSchema = external_exports.object({
|
|
15882
|
+
name: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
|
|
15883
|
+
description: external_exports.string().max(1024),
|
|
15884
|
+
warnings: strings(100, 2e3).default([]),
|
|
15885
|
+
source: external_exports.string().min(1).max(2e3),
|
|
15886
|
+
text: external_exports.string().refine((value) => Buffer.byteLength(value, "utf8") <= 262144, "Skill exceeds 256 KiB"),
|
|
15887
|
+
enabled: external_exports.boolean()
|
|
15888
|
+
}).strict();
|
|
15889
|
+
var newBotDefaultsSchema = external_exports.object({
|
|
15890
|
+
profile: botDefaultsProfileSchema.default({}),
|
|
15891
|
+
memory: external_exports.record(
|
|
15892
|
+
external_exports.string().regex(/^(?:MEMORY\.md|memory\/[a-zA-Z0-9_-]+\.md)$/),
|
|
15893
|
+
external_exports.string().refine((value) => Buffer.byteLength(value, "utf8") <= 262144, "Memory file exceeds 256 KiB")
|
|
15894
|
+
).refine((value) => Object.keys(value).length <= 100, "At most 100 memory files").default({}),
|
|
15895
|
+
skills: external_exports.array(botSkillTemplateSchema).max(100).default([]),
|
|
15896
|
+
routines: external_exports.array(botRoutineTemplateSchema).max(100).default([])
|
|
15897
|
+
}).strict().refine(
|
|
15898
|
+
(value) => Buffer.byteLength(JSON.stringify(value), "utf8") <= 9e5,
|
|
15899
|
+
"Bot defaults must fit within 900 KB"
|
|
15900
|
+
);
|
|
15901
|
+
|
|
15047
15902
|
// shared/provider-icon.ts
|
|
15048
15903
|
var PROVIDER_ICON_PRESETS = [
|
|
15049
15904
|
"openai",
|
|
@@ -15364,8 +16219,8 @@ var instanceConfigSchema = external_exports.object({
|
|
|
15364
16219
|
});
|
|
15365
16220
|
var instanceConfigMapSchema = external_exports.record(external_exports.string(), instanceConfigSchema);
|
|
15366
16221
|
var defaultModelSelectionSchema = external_exports.object({
|
|
15367
|
-
instanceId: external_exports.string().trim().min(1),
|
|
15368
|
-
model: external_exports.string().trim().min(1),
|
|
16222
|
+
instanceId: external_exports.string().trim().min(1).max(200),
|
|
16223
|
+
model: external_exports.string().trim().min(1).max(500),
|
|
15369
16224
|
effort: external_exports.enum(EFFORT_LEVELS).optional(),
|
|
15370
16225
|
variant: external_exports.string().refine(isModelVariant, "invalid model variant").optional()
|
|
15371
16226
|
}).refine(
|
|
@@ -15381,6 +16236,13 @@ var threadsConfigSchema = external_exports.object({
|
|
|
15381
16236
|
* Absent keeps them forever. */
|
|
15382
16237
|
eventLogRetentionDays: external_exports.number().int().min(1).max(3650).optional()
|
|
15383
16238
|
}).strict();
|
|
16239
|
+
var newBotsConfigSchema = external_exports.object({
|
|
16240
|
+
/** Effort for a new bot whose model selection names none. */
|
|
16241
|
+
effort: external_exports.enum(EFFORT_LEVELS).optional()
|
|
16242
|
+
}).strict();
|
|
16243
|
+
var newBotsPatchSchema = external_exports.object({
|
|
16244
|
+
effort: newBotsConfigSchema.shape.effort.nullable()
|
|
16245
|
+
}).strict();
|
|
15384
16246
|
var threadsPatchSchema = threadsConfigSchema.extend({
|
|
15385
16247
|
maxConcurrentPerBot: threadsConfigSchema.shape.maxConcurrentPerBot.optional(),
|
|
15386
16248
|
eventLogMaxBytes: threadsConfigSchema.shape.eventLogMaxBytes.nullable(),
|
|
@@ -15393,12 +16255,15 @@ var appConfigSchema = external_exports.object({
|
|
|
15393
16255
|
* addresses or `@domain` entries; admins get every scope, members chat only. */
|
|
15394
16256
|
signIn: external_exports.object({ admins: external_exports.array(external_exports.string().max(320)).max(500).optional(), members: external_exports.array(external_exports.string().max(320)).max(5e3).optional() }).optional(),
|
|
15395
16257
|
defaultModelSelection: defaultModelSelectionSchema.optional(),
|
|
16258
|
+
newBotDefaults: newBotDefaultsSchema.optional(),
|
|
16259
|
+
newBots: newBotsConfigSchema.optional(),
|
|
15396
16260
|
/** CLI-only launch preferences. Never enable remote access implicitly. */
|
|
15397
16261
|
cliStartup: external_exports.object({
|
|
15398
16262
|
access: external_exports.enum(["local", "tunnel", "tailscale", "public-url"]),
|
|
15399
16263
|
publicUrl: external_exports.string().url().optional(),
|
|
15400
16264
|
phone: external_exports.enum(["ios", "android"]).optional()
|
|
15401
16265
|
}).optional(),
|
|
16266
|
+
mistral: external_exports.object({ key: optionalText }).optional(),
|
|
15402
16267
|
xai: external_exports.object({ key: optionalText, url: optionalText }).optional(),
|
|
15403
16268
|
/** Anthropic API key for Claude Code billed per token, handed only to
|
|
15404
16269
|
* Claude instances; `url` only for a proxy or a test double. Never a
|
|
@@ -15467,8 +16332,8 @@ var appConfigSchema = external_exports.object({
|
|
|
15467
16332
|
"Use a model ID without control characters"
|
|
15468
16333
|
).optional()
|
|
15469
16334
|
}).optional(),
|
|
15470
|
-
/** Non-secret profile details
|
|
15471
|
-
profile: external_exports.object({ name: optionalText, email: optionalText }).optional(),
|
|
16335
|
+
/** Non-secret profile details; aboutMe is shared with every bot. */
|
|
16336
|
+
profile: external_exports.object({ name: optionalText, email: optionalText, aboutMe: external_exports.string().max(24e3).optional() }).optional(),
|
|
15472
16337
|
/** UI language override (BCP-47, lowercase). Empty/absent = follow the
|
|
15473
16338
|
* system language. Unknown tags degrade to English in the renderer. */
|
|
15474
16339
|
language: optionalText,
|
|
@@ -15498,7 +16363,7 @@ var appConfigSchema = external_exports.object({
|
|
|
15498
16363
|
var storedAppConfigSchema = appConfigSchema.extend({
|
|
15499
16364
|
browserProfiles: storedBrowserProfilesSchema.optional()
|
|
15500
16365
|
});
|
|
15501
|
-
var appConfigPatchSchema = appConfigSchema.omit({ instances: true, mcpServers: true, cliStartup: true, customDomain: true }).extend({ threads: threadsPatchSchema.optional() });
|
|
16366
|
+
var appConfigPatchSchema = appConfigSchema.omit({ instances: true, mcpServers: true, cliStartup: true, customDomain: true }).extend({ threads: threadsPatchSchema.optional(), newBots: newBotsPatchSchema.optional() });
|
|
15502
16367
|
var jsonObjectSchema = external_exports.record(external_exports.string(), external_exports.json());
|
|
15503
16368
|
var DATA_DIR = process.env.OMB_DATA_DIR ?? join2(homedir2(), ".openmausbot");
|
|
15504
16369
|
var LEGACY_DATA_DIR = join2(homedir2(), ".opengrokbot");
|
|
@@ -15569,9 +16434,99 @@ function cuaExecArgs(args2, options = {}) {
|
|
|
15569
16434
|
}
|
|
15570
16435
|
var containerMcpPath = SPAWNED_PROXIES.containerMcp;
|
|
15571
16436
|
|
|
16437
|
+
// server/vps-ssh.ts
|
|
16438
|
+
import { createHash } from "node:crypto";
|
|
16439
|
+
import { chmodSync, existsSync as existsSync3, lstatSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
16440
|
+
import { homedir as homedir3 } from "node:os";
|
|
16441
|
+
import { delimiter as delimiter2, join as join5, resolve as resolve2 } from "node:path";
|
|
16442
|
+
var VPS_SSH_DIR = "ssh";
|
|
16443
|
+
function shellQuote(value) {
|
|
16444
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
16445
|
+
}
|
|
16446
|
+
function controlDirectory(sshDir) {
|
|
16447
|
+
if (Buffer.byteLength(join5(sshDir, `cm-${"0".repeat(40)}`)) <= 80) return sshDir;
|
|
16448
|
+
const uid = process.getuid();
|
|
16449
|
+
const id = createHash("sha256").update(resolve2(sshDir)).digest("hex").slice(0, 12);
|
|
16450
|
+
const dir = `/tmp/omb-ssh-${uid}-${id}`;
|
|
16451
|
+
try {
|
|
16452
|
+
mkdirSync(dir, { mode: 448 });
|
|
16453
|
+
} catch (error51) {
|
|
16454
|
+
if (error51.code !== "EEXIST") throw error51;
|
|
16455
|
+
}
|
|
16456
|
+
const stat = lstatSync(dir);
|
|
16457
|
+
if (!stat.isDirectory() || stat.uid !== uid) throw new Error("The VPS SSH control directory is not private to this user");
|
|
16458
|
+
chmodSync(dir, 448);
|
|
16459
|
+
return dir;
|
|
16460
|
+
}
|
|
16461
|
+
function findExecutable(name, pathValue, exclude) {
|
|
16462
|
+
for (const dir of pathValue.split(delimiter2)) {
|
|
16463
|
+
if (!dir || dir === exclude) continue;
|
|
16464
|
+
const candidate = join5(dir, name);
|
|
16465
|
+
try {
|
|
16466
|
+
const stat = statSync2(candidate);
|
|
16467
|
+
if (stat.isFile() && (stat.mode & 73) !== 0) return candidate;
|
|
16468
|
+
} catch {
|
|
16469
|
+
}
|
|
16470
|
+
}
|
|
16471
|
+
return null;
|
|
16472
|
+
}
|
|
16473
|
+
function writeIfChanged(path, content, mode) {
|
|
16474
|
+
try {
|
|
16475
|
+
if (readFileSync2(path, "utf8") === content) {
|
|
16476
|
+
chmodSync(path, mode);
|
|
16477
|
+
return;
|
|
16478
|
+
}
|
|
16479
|
+
} catch {
|
|
16480
|
+
}
|
|
16481
|
+
const temp = `${path}.${process.pid}.tmp`;
|
|
16482
|
+
writeFileSync(temp, content, { mode });
|
|
16483
|
+
renameSync(temp, path);
|
|
16484
|
+
}
|
|
16485
|
+
function vpsSshConfigText(sshDir, userConfig = join5(homedir3(), ".ssh", "config"), systemConfig = "/etc/ssh/ssh_config") {
|
|
16486
|
+
return [
|
|
16487
|
+
"# Written by OpenMausBot for its VPS computer connections. Do not edit;",
|
|
16488
|
+
"# it is regenerated. Your own ~/.ssh/config is included first and wins.",
|
|
16489
|
+
...existsSync3(userConfig) ? [`Include ${JSON.stringify(userConfig)}`] : [],
|
|
16490
|
+
"Host *",
|
|
16491
|
+
" ControlMaster auto",
|
|
16492
|
+
` ControlPath ${JSON.stringify(join5(sshDir.replace(/%/g, "%%"), "cm-%C"))}`,
|
|
16493
|
+
" ControlPersist 10m",
|
|
16494
|
+
" ServerAliveInterval 15",
|
|
16495
|
+
" ServerAliveCountMax 3",
|
|
16496
|
+
" ConnectTimeout 10",
|
|
16497
|
+
...existsSync3(systemConfig) ? [`Include ${JSON.stringify(systemConfig)}`] : [],
|
|
16498
|
+
""
|
|
16499
|
+
].join("\n");
|
|
16500
|
+
}
|
|
16501
|
+
function prepareVpsSsh(dataDir, pathValue, platform = process.platform) {
|
|
16502
|
+
if (platform === "win32") return { configPath: null, path: pathValue };
|
|
16503
|
+
const sshDir = join5(dataDir, VPS_SSH_DIR);
|
|
16504
|
+
const binDir = join5(sshDir, "bin");
|
|
16505
|
+
mkdirSync(binDir, { recursive: true, mode: 448 });
|
|
16506
|
+
chmodSync(sshDir, 448);
|
|
16507
|
+
const configPath = join5(sshDir, "config");
|
|
16508
|
+
writeIfChanged(configPath, vpsSshConfigText(controlDirectory(sshDir)), 384);
|
|
16509
|
+
const realSsh = findExecutable("ssh", pathValue, binDir);
|
|
16510
|
+
if (!realSsh) return { configPath, path: pathValue };
|
|
16511
|
+
const shim = [
|
|
16512
|
+
"#!/bin/sh",
|
|
16513
|
+
"# Written by OpenMausBot. docker's SSH transport finds this ssh first, so",
|
|
16514
|
+
"# every VPS command shares one connection whether or not the alias says so.",
|
|
16515
|
+
`exec ${shellQuote(realSsh)} -F ${shellQuote(configPath)} "$@"`,
|
|
16516
|
+
""
|
|
16517
|
+
].join("\n");
|
|
16518
|
+
writeIfChanged(join5(binDir, "ssh"), shim, 448);
|
|
16519
|
+
return { configPath, path: `${binDir}${delimiter2}${pathValue}` };
|
|
16520
|
+
}
|
|
16521
|
+
|
|
15572
16522
|
// server/vps-computer.ts
|
|
16523
|
+
var COMMAND_TIMEOUT_TERM_GRACE_MS = 5e3;
|
|
16524
|
+
var COMMAND_TIMEOUT_KILL_GRACE_MS = COMMAND_TIMEOUT_TERM_GRACE_MS + 1e3;
|
|
15573
16525
|
var CONTAINER_NAME = /^[a-zA-Z0-9][a-zA-Z0-9_.-]+$/;
|
|
15574
16526
|
var CONTAINER_ID = /^[a-f0-9]{12,64}$/i;
|
|
16527
|
+
var LOCK_ACQUIRE_TIMEOUT_MS = 5e3;
|
|
16528
|
+
var SCREENSHOT_BUDGET_MS = 45e3;
|
|
16529
|
+
var PREPARATION_LOCK_TIMEOUT_MS = SCREENSHOT_BUDGET_MS + LOCK_ACQUIRE_TIMEOUT_MS;
|
|
15575
16530
|
function vpsDockerArgs(alias2, args2) {
|
|
15576
16531
|
if (!isValidSshAlias(alias2)) {
|
|
15577
16532
|
throw new Error("invalid VPS SSH config alias");
|
|
@@ -15601,9 +16556,13 @@ try {
|
|
|
15601
16556
|
}
|
|
15602
16557
|
var controlUrl = process.env.OMB_CONTROL_URL ?? "";
|
|
15603
16558
|
var controlToken = process.env.OMB_CONTROL_TOKEN ?? "";
|
|
16559
|
+
var ssh = prepareVpsSsh(DATA_DIR, augmentedPath());
|
|
15604
16560
|
runMcpBridge({
|
|
15605
16561
|
command: "docker",
|
|
15606
16562
|
args,
|
|
16563
|
+
// Keep tool calls and the watchdog on the same bounded, shared transport
|
|
16564
|
+
// as startup and previews; otherwise only the panel gets the SSH defaults.
|
|
16565
|
+
env: { ...process.env, PATH: ssh.path },
|
|
15607
16566
|
label: "VPS Cua Driver",
|
|
15608
16567
|
// The probe checks the TRANSPORT (SSH + daemon), deliberately not the
|
|
15609
16568
|
// driver: a busy desktop mid-tool-call must never look dead, while an
|