@openclaw-china/dingtalk 0.1.32 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1826 -240
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,21 +4,177 @@ import * as path from 'path';
|
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { DWClient, TOPIC_ROBOT } from 'dingtalk-stream';
|
|
6
6
|
import * as fs3 from 'fs';
|
|
7
|
+
import { existsSync } from 'fs';
|
|
7
8
|
import { fileURLToPath } from 'url';
|
|
8
9
|
import * as fsPromises from 'fs/promises';
|
|
9
10
|
import 'crypto';
|
|
11
|
+
import N2, { stdout, stdin } from 'process';
|
|
12
|
+
import ot from 'readline';
|
|
13
|
+
import 'tty';
|
|
14
|
+
import 'util';
|
|
10
15
|
|
|
16
|
+
var __create = Object.create;
|
|
11
17
|
var __defProp = Object.defineProperty;
|
|
12
|
-
var
|
|
18
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
21
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
|
+
var __require = /* @__PURE__ */ ((x3) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x3, {
|
|
13
23
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
14
|
-
}) :
|
|
24
|
+
}) : x3)(function(x3) {
|
|
15
25
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
16
|
-
throw Error('Dynamic require of "' +
|
|
26
|
+
throw Error('Dynamic require of "' + x3 + '" is not supported');
|
|
17
27
|
});
|
|
28
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
29
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
30
|
+
};
|
|
18
31
|
var __export = (target, all) => {
|
|
19
32
|
for (var name in all)
|
|
20
33
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
34
|
};
|
|
35
|
+
var __copyProps = (to, from, except, desc) => {
|
|
36
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
37
|
+
for (let key of __getOwnPropNames(from))
|
|
38
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
39
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
40
|
+
}
|
|
41
|
+
return to;
|
|
42
|
+
};
|
|
43
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
44
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
45
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
46
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
47
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
48
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
49
|
+
mod
|
|
50
|
+
));
|
|
51
|
+
|
|
52
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
53
|
+
var require_picocolors = __commonJS({
|
|
54
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$1, module) {
|
|
55
|
+
var p = process || {};
|
|
56
|
+
var argv = p.argv || [];
|
|
57
|
+
var env = p.env || {};
|
|
58
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
59
|
+
var formatter = (open, close, replace = open) => (input2) => {
|
|
60
|
+
let string = "" + input2, index = string.indexOf(close, open.length);
|
|
61
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
62
|
+
};
|
|
63
|
+
var replaceClose = (string, close, replace, index) => {
|
|
64
|
+
let result = "", cursor = 0;
|
|
65
|
+
do {
|
|
66
|
+
result += string.substring(cursor, index) + replace;
|
|
67
|
+
cursor = index + close.length;
|
|
68
|
+
index = string.indexOf(close, cursor);
|
|
69
|
+
} while (~index);
|
|
70
|
+
return result + string.substring(cursor);
|
|
71
|
+
};
|
|
72
|
+
var createColors = (enabled = isColorSupported) => {
|
|
73
|
+
let f = enabled ? formatter : () => String;
|
|
74
|
+
return {
|
|
75
|
+
isColorSupported: enabled,
|
|
76
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
77
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
78
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
79
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
80
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
81
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
82
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
83
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
84
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
85
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
86
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
87
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
88
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
89
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
90
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
91
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
92
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
93
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
94
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
95
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
96
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
97
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
98
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
99
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
100
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
101
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
102
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
103
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
104
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
105
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
106
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
107
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
108
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
109
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
110
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
111
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
112
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
113
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
114
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
115
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
116
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
module.exports = createColors();
|
|
120
|
+
module.exports.createColors = createColors;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
125
|
+
var require_src = __commonJS({
|
|
126
|
+
"../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports$1, module) {
|
|
127
|
+
var ESC = "\x1B";
|
|
128
|
+
var CSI = `${ESC}[`;
|
|
129
|
+
var beep = "\x07";
|
|
130
|
+
var cursor = {
|
|
131
|
+
to(x3, y2) {
|
|
132
|
+
if (!y2) return `${CSI}${x3 + 1}G`;
|
|
133
|
+
return `${CSI}${y2 + 1};${x3 + 1}H`;
|
|
134
|
+
},
|
|
135
|
+
move(x3, y2) {
|
|
136
|
+
let ret = "";
|
|
137
|
+
if (x3 < 0) ret += `${CSI}${-x3}D`;
|
|
138
|
+
else if (x3 > 0) ret += `${CSI}${x3}C`;
|
|
139
|
+
if (y2 < 0) ret += `${CSI}${-y2}A`;
|
|
140
|
+
else if (y2 > 0) ret += `${CSI}${y2}B`;
|
|
141
|
+
return ret;
|
|
142
|
+
},
|
|
143
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
144
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
145
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
146
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
147
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
148
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
149
|
+
left: `${CSI}G`,
|
|
150
|
+
hide: `${CSI}?25l`,
|
|
151
|
+
show: `${CSI}?25h`,
|
|
152
|
+
save: `${ESC}7`,
|
|
153
|
+
restore: `${ESC}8`
|
|
154
|
+
};
|
|
155
|
+
var scroll = {
|
|
156
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
157
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
158
|
+
};
|
|
159
|
+
var erase = {
|
|
160
|
+
screen: `${CSI}2J`,
|
|
161
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
162
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
163
|
+
line: `${CSI}2K`,
|
|
164
|
+
lineEnd: `${CSI}K`,
|
|
165
|
+
lineStart: `${CSI}1K`,
|
|
166
|
+
lines(count) {
|
|
167
|
+
let clear = "";
|
|
168
|
+
for (let i = 0; i < count; i++)
|
|
169
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
170
|
+
if (count)
|
|
171
|
+
clear += cursor.left;
|
|
172
|
+
return clear;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
176
|
+
}
|
|
177
|
+
});
|
|
22
178
|
|
|
23
179
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
24
180
|
var external_exports = {};
|
|
@@ -135,7 +291,7 @@ __export(external_exports, {
|
|
|
135
291
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
|
|
136
292
|
var util;
|
|
137
293
|
(function(util2) {
|
|
138
|
-
util2.assertEqual = (
|
|
294
|
+
util2.assertEqual = (_2) => {
|
|
139
295
|
};
|
|
140
296
|
function assertIs(_arg) {
|
|
141
297
|
}
|
|
@@ -152,16 +308,16 @@ var util;
|
|
|
152
308
|
return obj;
|
|
153
309
|
};
|
|
154
310
|
util2.getValidEnumValues = (obj) => {
|
|
155
|
-
const validKeys = util2.objectKeys(obj).filter((
|
|
311
|
+
const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");
|
|
156
312
|
const filtered = {};
|
|
157
|
-
for (const
|
|
158
|
-
filtered[
|
|
313
|
+
for (const k2 of validKeys) {
|
|
314
|
+
filtered[k2] = obj[k2];
|
|
159
315
|
}
|
|
160
316
|
return util2.objectValues(filtered);
|
|
161
317
|
};
|
|
162
318
|
util2.objectValues = (obj) => {
|
|
163
|
-
return util2.objectKeys(obj).map(function(
|
|
164
|
-
return obj[
|
|
319
|
+
return util2.objectKeys(obj).map(function(e2) {
|
|
320
|
+
return obj[e2];
|
|
165
321
|
});
|
|
166
322
|
};
|
|
167
323
|
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
@@ -185,7 +341,7 @@ var util;
|
|
|
185
341
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
186
342
|
}
|
|
187
343
|
util2.joinValues = joinValues;
|
|
188
|
-
util2.jsonStringifyReplacer = (
|
|
344
|
+
util2.jsonStringifyReplacer = (_2, value) => {
|
|
189
345
|
if (typeof value === "bigint") {
|
|
190
346
|
return value.toString();
|
|
191
347
|
}
|
|
@@ -538,7 +694,7 @@ function addIssueToContext(ctx, issueData) {
|
|
|
538
694
|
// then global override map
|
|
539
695
|
overrideMap === en_default ? void 0 : en_default
|
|
540
696
|
// then global default map
|
|
541
|
-
].filter((
|
|
697
|
+
].filter((x3) => !!x3)
|
|
542
698
|
});
|
|
543
699
|
ctx.common.issues.push(issue);
|
|
544
700
|
}
|
|
@@ -601,10 +757,10 @@ var INVALID = Object.freeze({
|
|
|
601
757
|
});
|
|
602
758
|
var DIRTY = (value) => ({ status: "dirty", value });
|
|
603
759
|
var OK = (value) => ({ status: "valid", value });
|
|
604
|
-
var isAborted = (
|
|
605
|
-
var isDirty = (
|
|
606
|
-
var isValid = (
|
|
607
|
-
var isAsync = (
|
|
760
|
+
var isAborted = (x3) => x3.status === "aborted";
|
|
761
|
+
var isDirty = (x3) => x3.status === "dirty";
|
|
762
|
+
var isValid = (x3) => x3.status === "valid";
|
|
763
|
+
var isAsync = (x3) => typeof Promise !== "undefined" && x3 instanceof Promise;
|
|
608
764
|
|
|
609
765
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
|
|
610
766
|
var errorUtil;
|
|
@@ -679,41 +835,41 @@ var ZodType = class {
|
|
|
679
835
|
get description() {
|
|
680
836
|
return this._def.description;
|
|
681
837
|
}
|
|
682
|
-
_getType(
|
|
683
|
-
return getParsedType(
|
|
838
|
+
_getType(input2) {
|
|
839
|
+
return getParsedType(input2.data);
|
|
684
840
|
}
|
|
685
|
-
_getOrReturnCtx(
|
|
841
|
+
_getOrReturnCtx(input2, ctx) {
|
|
686
842
|
return ctx || {
|
|
687
|
-
common:
|
|
688
|
-
data:
|
|
689
|
-
parsedType: getParsedType(
|
|
843
|
+
common: input2.parent.common,
|
|
844
|
+
data: input2.data,
|
|
845
|
+
parsedType: getParsedType(input2.data),
|
|
690
846
|
schemaErrorMap: this._def.errorMap,
|
|
691
|
-
path:
|
|
692
|
-
parent:
|
|
847
|
+
path: input2.path,
|
|
848
|
+
parent: input2.parent
|
|
693
849
|
};
|
|
694
850
|
}
|
|
695
|
-
_processInputParams(
|
|
851
|
+
_processInputParams(input2) {
|
|
696
852
|
return {
|
|
697
853
|
status: new ParseStatus(),
|
|
698
854
|
ctx: {
|
|
699
|
-
common:
|
|
700
|
-
data:
|
|
701
|
-
parsedType: getParsedType(
|
|
855
|
+
common: input2.parent.common,
|
|
856
|
+
data: input2.data,
|
|
857
|
+
parsedType: getParsedType(input2.data),
|
|
702
858
|
schemaErrorMap: this._def.errorMap,
|
|
703
|
-
path:
|
|
704
|
-
parent:
|
|
859
|
+
path: input2.path,
|
|
860
|
+
parent: input2.parent
|
|
705
861
|
}
|
|
706
862
|
};
|
|
707
863
|
}
|
|
708
|
-
_parseSync(
|
|
709
|
-
const result = this._parse(
|
|
864
|
+
_parseSync(input2) {
|
|
865
|
+
const result = this._parse(input2);
|
|
710
866
|
if (isAsync(result)) {
|
|
711
867
|
throw new Error("Synchronous parse encountered promise.");
|
|
712
868
|
}
|
|
713
869
|
return result;
|
|
714
870
|
}
|
|
715
|
-
_parseAsync(
|
|
716
|
-
const result = this._parse(
|
|
871
|
+
_parseAsync(input2) {
|
|
872
|
+
const result = this._parse(input2);
|
|
717
873
|
return Promise.resolve(result);
|
|
718
874
|
}
|
|
719
875
|
parse(data, params) {
|
|
@@ -1039,13 +1195,13 @@ function isValidCidr(ip, version) {
|
|
|
1039
1195
|
return false;
|
|
1040
1196
|
}
|
|
1041
1197
|
var ZodString = class _ZodString extends ZodType {
|
|
1042
|
-
_parse(
|
|
1198
|
+
_parse(input2) {
|
|
1043
1199
|
if (this._def.coerce) {
|
|
1044
|
-
|
|
1200
|
+
input2.data = String(input2.data);
|
|
1045
1201
|
}
|
|
1046
|
-
const parsedType = this._getType(
|
|
1202
|
+
const parsedType = this._getType(input2);
|
|
1047
1203
|
if (parsedType !== ZodParsedType.string) {
|
|
1048
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1204
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1049
1205
|
addIssueToContext(ctx2, {
|
|
1050
1206
|
code: ZodIssueCode.invalid_type,
|
|
1051
1207
|
expected: ZodParsedType.string,
|
|
@@ -1057,8 +1213,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1057
1213
|
let ctx = void 0;
|
|
1058
1214
|
for (const check of this._def.checks) {
|
|
1059
1215
|
if (check.kind === "min") {
|
|
1060
|
-
if (
|
|
1061
|
-
ctx = this._getOrReturnCtx(
|
|
1216
|
+
if (input2.data.length < check.value) {
|
|
1217
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1062
1218
|
addIssueToContext(ctx, {
|
|
1063
1219
|
code: ZodIssueCode.too_small,
|
|
1064
1220
|
minimum: check.value,
|
|
@@ -1070,8 +1226,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1070
1226
|
status.dirty();
|
|
1071
1227
|
}
|
|
1072
1228
|
} else if (check.kind === "max") {
|
|
1073
|
-
if (
|
|
1074
|
-
ctx = this._getOrReturnCtx(
|
|
1229
|
+
if (input2.data.length > check.value) {
|
|
1230
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1075
1231
|
addIssueToContext(ctx, {
|
|
1076
1232
|
code: ZodIssueCode.too_big,
|
|
1077
1233
|
maximum: check.value,
|
|
@@ -1083,10 +1239,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1083
1239
|
status.dirty();
|
|
1084
1240
|
}
|
|
1085
1241
|
} else if (check.kind === "length") {
|
|
1086
|
-
const tooBig =
|
|
1087
|
-
const tooSmall =
|
|
1242
|
+
const tooBig = input2.data.length > check.value;
|
|
1243
|
+
const tooSmall = input2.data.length < check.value;
|
|
1088
1244
|
if (tooBig || tooSmall) {
|
|
1089
|
-
ctx = this._getOrReturnCtx(
|
|
1245
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1090
1246
|
if (tooBig) {
|
|
1091
1247
|
addIssueToContext(ctx, {
|
|
1092
1248
|
code: ZodIssueCode.too_big,
|
|
@@ -1109,8 +1265,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1109
1265
|
status.dirty();
|
|
1110
1266
|
}
|
|
1111
1267
|
} else if (check.kind === "email") {
|
|
1112
|
-
if (!emailRegex.test(
|
|
1113
|
-
ctx = this._getOrReturnCtx(
|
|
1268
|
+
if (!emailRegex.test(input2.data)) {
|
|
1269
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1114
1270
|
addIssueToContext(ctx, {
|
|
1115
1271
|
validation: "email",
|
|
1116
1272
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1122,8 +1278,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1122
1278
|
if (!emojiRegex) {
|
|
1123
1279
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1124
1280
|
}
|
|
1125
|
-
if (!emojiRegex.test(
|
|
1126
|
-
ctx = this._getOrReturnCtx(
|
|
1281
|
+
if (!emojiRegex.test(input2.data)) {
|
|
1282
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1127
1283
|
addIssueToContext(ctx, {
|
|
1128
1284
|
validation: "emoji",
|
|
1129
1285
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1132,8 +1288,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1132
1288
|
status.dirty();
|
|
1133
1289
|
}
|
|
1134
1290
|
} else if (check.kind === "uuid") {
|
|
1135
|
-
if (!uuidRegex.test(
|
|
1136
|
-
ctx = this._getOrReturnCtx(
|
|
1291
|
+
if (!uuidRegex.test(input2.data)) {
|
|
1292
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1137
1293
|
addIssueToContext(ctx, {
|
|
1138
1294
|
validation: "uuid",
|
|
1139
1295
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1142,8 +1298,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1142
1298
|
status.dirty();
|
|
1143
1299
|
}
|
|
1144
1300
|
} else if (check.kind === "nanoid") {
|
|
1145
|
-
if (!nanoidRegex.test(
|
|
1146
|
-
ctx = this._getOrReturnCtx(
|
|
1301
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
1302
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1147
1303
|
addIssueToContext(ctx, {
|
|
1148
1304
|
validation: "nanoid",
|
|
1149
1305
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1152,8 +1308,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1152
1308
|
status.dirty();
|
|
1153
1309
|
}
|
|
1154
1310
|
} else if (check.kind === "cuid") {
|
|
1155
|
-
if (!cuidRegex.test(
|
|
1156
|
-
ctx = this._getOrReturnCtx(
|
|
1311
|
+
if (!cuidRegex.test(input2.data)) {
|
|
1312
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1157
1313
|
addIssueToContext(ctx, {
|
|
1158
1314
|
validation: "cuid",
|
|
1159
1315
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1162,8 +1318,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1162
1318
|
status.dirty();
|
|
1163
1319
|
}
|
|
1164
1320
|
} else if (check.kind === "cuid2") {
|
|
1165
|
-
if (!cuid2Regex.test(
|
|
1166
|
-
ctx = this._getOrReturnCtx(
|
|
1321
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
1322
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1167
1323
|
addIssueToContext(ctx, {
|
|
1168
1324
|
validation: "cuid2",
|
|
1169
1325
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1172,8 +1328,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1172
1328
|
status.dirty();
|
|
1173
1329
|
}
|
|
1174
1330
|
} else if (check.kind === "ulid") {
|
|
1175
|
-
if (!ulidRegex.test(
|
|
1176
|
-
ctx = this._getOrReturnCtx(
|
|
1331
|
+
if (!ulidRegex.test(input2.data)) {
|
|
1332
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1177
1333
|
addIssueToContext(ctx, {
|
|
1178
1334
|
validation: "ulid",
|
|
1179
1335
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1183,9 +1339,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1183
1339
|
}
|
|
1184
1340
|
} else if (check.kind === "url") {
|
|
1185
1341
|
try {
|
|
1186
|
-
new URL(
|
|
1342
|
+
new URL(input2.data);
|
|
1187
1343
|
} catch {
|
|
1188
|
-
ctx = this._getOrReturnCtx(
|
|
1344
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1189
1345
|
addIssueToContext(ctx, {
|
|
1190
1346
|
validation: "url",
|
|
1191
1347
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1195,9 +1351,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1195
1351
|
}
|
|
1196
1352
|
} else if (check.kind === "regex") {
|
|
1197
1353
|
check.regex.lastIndex = 0;
|
|
1198
|
-
const testResult = check.regex.test(
|
|
1354
|
+
const testResult = check.regex.test(input2.data);
|
|
1199
1355
|
if (!testResult) {
|
|
1200
|
-
ctx = this._getOrReturnCtx(
|
|
1356
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1201
1357
|
addIssueToContext(ctx, {
|
|
1202
1358
|
validation: "regex",
|
|
1203
1359
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1206,10 +1362,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1206
1362
|
status.dirty();
|
|
1207
1363
|
}
|
|
1208
1364
|
} else if (check.kind === "trim") {
|
|
1209
|
-
|
|
1365
|
+
input2.data = input2.data.trim();
|
|
1210
1366
|
} else if (check.kind === "includes") {
|
|
1211
|
-
if (!
|
|
1212
|
-
ctx = this._getOrReturnCtx(
|
|
1367
|
+
if (!input2.data.includes(check.value, check.position)) {
|
|
1368
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1213
1369
|
addIssueToContext(ctx, {
|
|
1214
1370
|
code: ZodIssueCode.invalid_string,
|
|
1215
1371
|
validation: { includes: check.value, position: check.position },
|
|
@@ -1218,12 +1374,12 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1218
1374
|
status.dirty();
|
|
1219
1375
|
}
|
|
1220
1376
|
} else if (check.kind === "toLowerCase") {
|
|
1221
|
-
|
|
1377
|
+
input2.data = input2.data.toLowerCase();
|
|
1222
1378
|
} else if (check.kind === "toUpperCase") {
|
|
1223
|
-
|
|
1379
|
+
input2.data = input2.data.toUpperCase();
|
|
1224
1380
|
} else if (check.kind === "startsWith") {
|
|
1225
|
-
if (!
|
|
1226
|
-
ctx = this._getOrReturnCtx(
|
|
1381
|
+
if (!input2.data.startsWith(check.value)) {
|
|
1382
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1227
1383
|
addIssueToContext(ctx, {
|
|
1228
1384
|
code: ZodIssueCode.invalid_string,
|
|
1229
1385
|
validation: { startsWith: check.value },
|
|
@@ -1232,8 +1388,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1232
1388
|
status.dirty();
|
|
1233
1389
|
}
|
|
1234
1390
|
} else if (check.kind === "endsWith") {
|
|
1235
|
-
if (!
|
|
1236
|
-
ctx = this._getOrReturnCtx(
|
|
1391
|
+
if (!input2.data.endsWith(check.value)) {
|
|
1392
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1237
1393
|
addIssueToContext(ctx, {
|
|
1238
1394
|
code: ZodIssueCode.invalid_string,
|
|
1239
1395
|
validation: { endsWith: check.value },
|
|
@@ -1243,8 +1399,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1243
1399
|
}
|
|
1244
1400
|
} else if (check.kind === "datetime") {
|
|
1245
1401
|
const regex = datetimeRegex(check);
|
|
1246
|
-
if (!regex.test(
|
|
1247
|
-
ctx = this._getOrReturnCtx(
|
|
1402
|
+
if (!regex.test(input2.data)) {
|
|
1403
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1248
1404
|
addIssueToContext(ctx, {
|
|
1249
1405
|
code: ZodIssueCode.invalid_string,
|
|
1250
1406
|
validation: "datetime",
|
|
@@ -1254,8 +1410,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1254
1410
|
}
|
|
1255
1411
|
} else if (check.kind === "date") {
|
|
1256
1412
|
const regex = dateRegex;
|
|
1257
|
-
if (!regex.test(
|
|
1258
|
-
ctx = this._getOrReturnCtx(
|
|
1413
|
+
if (!regex.test(input2.data)) {
|
|
1414
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1259
1415
|
addIssueToContext(ctx, {
|
|
1260
1416
|
code: ZodIssueCode.invalid_string,
|
|
1261
1417
|
validation: "date",
|
|
@@ -1265,8 +1421,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1265
1421
|
}
|
|
1266
1422
|
} else if (check.kind === "time") {
|
|
1267
1423
|
const regex = timeRegex(check);
|
|
1268
|
-
if (!regex.test(
|
|
1269
|
-
ctx = this._getOrReturnCtx(
|
|
1424
|
+
if (!regex.test(input2.data)) {
|
|
1425
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1270
1426
|
addIssueToContext(ctx, {
|
|
1271
1427
|
code: ZodIssueCode.invalid_string,
|
|
1272
1428
|
validation: "time",
|
|
@@ -1275,8 +1431,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1275
1431
|
status.dirty();
|
|
1276
1432
|
}
|
|
1277
1433
|
} else if (check.kind === "duration") {
|
|
1278
|
-
if (!durationRegex.test(
|
|
1279
|
-
ctx = this._getOrReturnCtx(
|
|
1434
|
+
if (!durationRegex.test(input2.data)) {
|
|
1435
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1280
1436
|
addIssueToContext(ctx, {
|
|
1281
1437
|
validation: "duration",
|
|
1282
1438
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1285,8 +1441,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1285
1441
|
status.dirty();
|
|
1286
1442
|
}
|
|
1287
1443
|
} else if (check.kind === "ip") {
|
|
1288
|
-
if (!isValidIP(
|
|
1289
|
-
ctx = this._getOrReturnCtx(
|
|
1444
|
+
if (!isValidIP(input2.data, check.version)) {
|
|
1445
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1290
1446
|
addIssueToContext(ctx, {
|
|
1291
1447
|
validation: "ip",
|
|
1292
1448
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1295,8 +1451,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1295
1451
|
status.dirty();
|
|
1296
1452
|
}
|
|
1297
1453
|
} else if (check.kind === "jwt") {
|
|
1298
|
-
if (!isValidJWT(
|
|
1299
|
-
ctx = this._getOrReturnCtx(
|
|
1454
|
+
if (!isValidJWT(input2.data, check.alg)) {
|
|
1455
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1300
1456
|
addIssueToContext(ctx, {
|
|
1301
1457
|
validation: "jwt",
|
|
1302
1458
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1305,8 +1461,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1305
1461
|
status.dirty();
|
|
1306
1462
|
}
|
|
1307
1463
|
} else if (check.kind === "cidr") {
|
|
1308
|
-
if (!isValidCidr(
|
|
1309
|
-
ctx = this._getOrReturnCtx(
|
|
1464
|
+
if (!isValidCidr(input2.data, check.version)) {
|
|
1465
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1310
1466
|
addIssueToContext(ctx, {
|
|
1311
1467
|
validation: "cidr",
|
|
1312
1468
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1315,8 +1471,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1315
1471
|
status.dirty();
|
|
1316
1472
|
}
|
|
1317
1473
|
} else if (check.kind === "base64") {
|
|
1318
|
-
if (!base64Regex.test(
|
|
1319
|
-
ctx = this._getOrReturnCtx(
|
|
1474
|
+
if (!base64Regex.test(input2.data)) {
|
|
1475
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1320
1476
|
addIssueToContext(ctx, {
|
|
1321
1477
|
validation: "base64",
|
|
1322
1478
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1325,8 +1481,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1325
1481
|
status.dirty();
|
|
1326
1482
|
}
|
|
1327
1483
|
} else if (check.kind === "base64url") {
|
|
1328
|
-
if (!base64urlRegex.test(
|
|
1329
|
-
ctx = this._getOrReturnCtx(
|
|
1484
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
1485
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1330
1486
|
addIssueToContext(ctx, {
|
|
1331
1487
|
validation: "base64url",
|
|
1332
1488
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1338,7 +1494,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1338
1494
|
util.assertNever(check);
|
|
1339
1495
|
}
|
|
1340
1496
|
}
|
|
1341
|
-
return { status: status.value, value:
|
|
1497
|
+
return { status: status.value, value: input2.data };
|
|
1342
1498
|
}
|
|
1343
1499
|
_regex(regex, validation, message) {
|
|
1344
1500
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -1599,13 +1755,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1599
1755
|
this.max = this.lte;
|
|
1600
1756
|
this.step = this.multipleOf;
|
|
1601
1757
|
}
|
|
1602
|
-
_parse(
|
|
1758
|
+
_parse(input2) {
|
|
1603
1759
|
if (this._def.coerce) {
|
|
1604
|
-
|
|
1760
|
+
input2.data = Number(input2.data);
|
|
1605
1761
|
}
|
|
1606
|
-
const parsedType = this._getType(
|
|
1762
|
+
const parsedType = this._getType(input2);
|
|
1607
1763
|
if (parsedType !== ZodParsedType.number) {
|
|
1608
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1764
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1609
1765
|
addIssueToContext(ctx2, {
|
|
1610
1766
|
code: ZodIssueCode.invalid_type,
|
|
1611
1767
|
expected: ZodParsedType.number,
|
|
@@ -1617,8 +1773,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1617
1773
|
const status = new ParseStatus();
|
|
1618
1774
|
for (const check of this._def.checks) {
|
|
1619
1775
|
if (check.kind === "int") {
|
|
1620
|
-
if (!util.isInteger(
|
|
1621
|
-
ctx = this._getOrReturnCtx(
|
|
1776
|
+
if (!util.isInteger(input2.data)) {
|
|
1777
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1622
1778
|
addIssueToContext(ctx, {
|
|
1623
1779
|
code: ZodIssueCode.invalid_type,
|
|
1624
1780
|
expected: "integer",
|
|
@@ -1628,9 +1784,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1628
1784
|
status.dirty();
|
|
1629
1785
|
}
|
|
1630
1786
|
} else if (check.kind === "min") {
|
|
1631
|
-
const tooSmall = check.inclusive ?
|
|
1787
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1632
1788
|
if (tooSmall) {
|
|
1633
|
-
ctx = this._getOrReturnCtx(
|
|
1789
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1634
1790
|
addIssueToContext(ctx, {
|
|
1635
1791
|
code: ZodIssueCode.too_small,
|
|
1636
1792
|
minimum: check.value,
|
|
@@ -1642,9 +1798,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1642
1798
|
status.dirty();
|
|
1643
1799
|
}
|
|
1644
1800
|
} else if (check.kind === "max") {
|
|
1645
|
-
const tooBig = check.inclusive ?
|
|
1801
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1646
1802
|
if (tooBig) {
|
|
1647
|
-
ctx = this._getOrReturnCtx(
|
|
1803
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1648
1804
|
addIssueToContext(ctx, {
|
|
1649
1805
|
code: ZodIssueCode.too_big,
|
|
1650
1806
|
maximum: check.value,
|
|
@@ -1656,8 +1812,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1656
1812
|
status.dirty();
|
|
1657
1813
|
}
|
|
1658
1814
|
} else if (check.kind === "multipleOf") {
|
|
1659
|
-
if (floatSafeRemainder(
|
|
1660
|
-
ctx = this._getOrReturnCtx(
|
|
1815
|
+
if (floatSafeRemainder(input2.data, check.value) !== 0) {
|
|
1816
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1661
1817
|
addIssueToContext(ctx, {
|
|
1662
1818
|
code: ZodIssueCode.not_multiple_of,
|
|
1663
1819
|
multipleOf: check.value,
|
|
@@ -1666,8 +1822,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1666
1822
|
status.dirty();
|
|
1667
1823
|
}
|
|
1668
1824
|
} else if (check.kind === "finite") {
|
|
1669
|
-
if (!Number.isFinite(
|
|
1670
|
-
ctx = this._getOrReturnCtx(
|
|
1825
|
+
if (!Number.isFinite(input2.data)) {
|
|
1826
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1671
1827
|
addIssueToContext(ctx, {
|
|
1672
1828
|
code: ZodIssueCode.not_finite,
|
|
1673
1829
|
message: check.message
|
|
@@ -1678,7 +1834,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1678
1834
|
util.assertNever(check);
|
|
1679
1835
|
}
|
|
1680
1836
|
}
|
|
1681
|
-
return { status: status.value, value:
|
|
1837
|
+
return { status: status.value, value: input2.data };
|
|
1682
1838
|
}
|
|
1683
1839
|
gte(value, message) {
|
|
1684
1840
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -1830,25 +1986,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1830
1986
|
this.min = this.gte;
|
|
1831
1987
|
this.max = this.lte;
|
|
1832
1988
|
}
|
|
1833
|
-
_parse(
|
|
1989
|
+
_parse(input2) {
|
|
1834
1990
|
if (this._def.coerce) {
|
|
1835
1991
|
try {
|
|
1836
|
-
|
|
1992
|
+
input2.data = BigInt(input2.data);
|
|
1837
1993
|
} catch {
|
|
1838
|
-
return this._getInvalidInput(
|
|
1994
|
+
return this._getInvalidInput(input2);
|
|
1839
1995
|
}
|
|
1840
1996
|
}
|
|
1841
|
-
const parsedType = this._getType(
|
|
1997
|
+
const parsedType = this._getType(input2);
|
|
1842
1998
|
if (parsedType !== ZodParsedType.bigint) {
|
|
1843
|
-
return this._getInvalidInput(
|
|
1999
|
+
return this._getInvalidInput(input2);
|
|
1844
2000
|
}
|
|
1845
2001
|
let ctx = void 0;
|
|
1846
2002
|
const status = new ParseStatus();
|
|
1847
2003
|
for (const check of this._def.checks) {
|
|
1848
2004
|
if (check.kind === "min") {
|
|
1849
|
-
const tooSmall = check.inclusive ?
|
|
2005
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1850
2006
|
if (tooSmall) {
|
|
1851
|
-
ctx = this._getOrReturnCtx(
|
|
2007
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1852
2008
|
addIssueToContext(ctx, {
|
|
1853
2009
|
code: ZodIssueCode.too_small,
|
|
1854
2010
|
type: "bigint",
|
|
@@ -1859,9 +2015,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1859
2015
|
status.dirty();
|
|
1860
2016
|
}
|
|
1861
2017
|
} else if (check.kind === "max") {
|
|
1862
|
-
const tooBig = check.inclusive ?
|
|
2018
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1863
2019
|
if (tooBig) {
|
|
1864
|
-
ctx = this._getOrReturnCtx(
|
|
2020
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1865
2021
|
addIssueToContext(ctx, {
|
|
1866
2022
|
code: ZodIssueCode.too_big,
|
|
1867
2023
|
type: "bigint",
|
|
@@ -1872,8 +2028,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1872
2028
|
status.dirty();
|
|
1873
2029
|
}
|
|
1874
2030
|
} else if (check.kind === "multipleOf") {
|
|
1875
|
-
if (
|
|
1876
|
-
ctx = this._getOrReturnCtx(
|
|
2031
|
+
if (input2.data % check.value !== BigInt(0)) {
|
|
2032
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1877
2033
|
addIssueToContext(ctx, {
|
|
1878
2034
|
code: ZodIssueCode.not_multiple_of,
|
|
1879
2035
|
multipleOf: check.value,
|
|
@@ -1885,10 +2041,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1885
2041
|
util.assertNever(check);
|
|
1886
2042
|
}
|
|
1887
2043
|
}
|
|
1888
|
-
return { status: status.value, value:
|
|
2044
|
+
return { status: status.value, value: input2.data };
|
|
1889
2045
|
}
|
|
1890
|
-
_getInvalidInput(
|
|
1891
|
-
const ctx = this._getOrReturnCtx(
|
|
2046
|
+
_getInvalidInput(input2) {
|
|
2047
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
1892
2048
|
addIssueToContext(ctx, {
|
|
1893
2049
|
code: ZodIssueCode.invalid_type,
|
|
1894
2050
|
expected: ZodParsedType.bigint,
|
|
@@ -1997,13 +2153,13 @@ ZodBigInt.create = (params) => {
|
|
|
1997
2153
|
});
|
|
1998
2154
|
};
|
|
1999
2155
|
var ZodBoolean = class extends ZodType {
|
|
2000
|
-
_parse(
|
|
2156
|
+
_parse(input2) {
|
|
2001
2157
|
if (this._def.coerce) {
|
|
2002
|
-
|
|
2158
|
+
input2.data = Boolean(input2.data);
|
|
2003
2159
|
}
|
|
2004
|
-
const parsedType = this._getType(
|
|
2160
|
+
const parsedType = this._getType(input2);
|
|
2005
2161
|
if (parsedType !== ZodParsedType.boolean) {
|
|
2006
|
-
const ctx = this._getOrReturnCtx(
|
|
2162
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2007
2163
|
addIssueToContext(ctx, {
|
|
2008
2164
|
code: ZodIssueCode.invalid_type,
|
|
2009
2165
|
expected: ZodParsedType.boolean,
|
|
@@ -2011,7 +2167,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
2011
2167
|
});
|
|
2012
2168
|
return INVALID;
|
|
2013
2169
|
}
|
|
2014
|
-
return OK(
|
|
2170
|
+
return OK(input2.data);
|
|
2015
2171
|
}
|
|
2016
2172
|
};
|
|
2017
2173
|
ZodBoolean.create = (params) => {
|
|
@@ -2022,13 +2178,13 @@ ZodBoolean.create = (params) => {
|
|
|
2022
2178
|
});
|
|
2023
2179
|
};
|
|
2024
2180
|
var ZodDate = class _ZodDate extends ZodType {
|
|
2025
|
-
_parse(
|
|
2181
|
+
_parse(input2) {
|
|
2026
2182
|
if (this._def.coerce) {
|
|
2027
|
-
|
|
2183
|
+
input2.data = new Date(input2.data);
|
|
2028
2184
|
}
|
|
2029
|
-
const parsedType = this._getType(
|
|
2185
|
+
const parsedType = this._getType(input2);
|
|
2030
2186
|
if (parsedType !== ZodParsedType.date) {
|
|
2031
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2187
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2032
2188
|
addIssueToContext(ctx2, {
|
|
2033
2189
|
code: ZodIssueCode.invalid_type,
|
|
2034
2190
|
expected: ZodParsedType.date,
|
|
@@ -2036,8 +2192,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2036
2192
|
});
|
|
2037
2193
|
return INVALID;
|
|
2038
2194
|
}
|
|
2039
|
-
if (Number.isNaN(
|
|
2040
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2195
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
2196
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2041
2197
|
addIssueToContext(ctx2, {
|
|
2042
2198
|
code: ZodIssueCode.invalid_date
|
|
2043
2199
|
});
|
|
@@ -2047,8 +2203,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2047
2203
|
let ctx = void 0;
|
|
2048
2204
|
for (const check of this._def.checks) {
|
|
2049
2205
|
if (check.kind === "min") {
|
|
2050
|
-
if (
|
|
2051
|
-
ctx = this._getOrReturnCtx(
|
|
2206
|
+
if (input2.data.getTime() < check.value) {
|
|
2207
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2052
2208
|
addIssueToContext(ctx, {
|
|
2053
2209
|
code: ZodIssueCode.too_small,
|
|
2054
2210
|
message: check.message,
|
|
@@ -2060,8 +2216,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2060
2216
|
status.dirty();
|
|
2061
2217
|
}
|
|
2062
2218
|
} else if (check.kind === "max") {
|
|
2063
|
-
if (
|
|
2064
|
-
ctx = this._getOrReturnCtx(
|
|
2219
|
+
if (input2.data.getTime() > check.value) {
|
|
2220
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2065
2221
|
addIssueToContext(ctx, {
|
|
2066
2222
|
code: ZodIssueCode.too_big,
|
|
2067
2223
|
message: check.message,
|
|
@@ -2078,7 +2234,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2078
2234
|
}
|
|
2079
2235
|
return {
|
|
2080
2236
|
status: status.value,
|
|
2081
|
-
value: new Date(
|
|
2237
|
+
value: new Date(input2.data.getTime())
|
|
2082
2238
|
};
|
|
2083
2239
|
}
|
|
2084
2240
|
_addCheck(check) {
|
|
@@ -2131,10 +2287,10 @@ ZodDate.create = (params) => {
|
|
|
2131
2287
|
});
|
|
2132
2288
|
};
|
|
2133
2289
|
var ZodSymbol = class extends ZodType {
|
|
2134
|
-
_parse(
|
|
2135
|
-
const parsedType = this._getType(
|
|
2290
|
+
_parse(input2) {
|
|
2291
|
+
const parsedType = this._getType(input2);
|
|
2136
2292
|
if (parsedType !== ZodParsedType.symbol) {
|
|
2137
|
-
const ctx = this._getOrReturnCtx(
|
|
2293
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2138
2294
|
addIssueToContext(ctx, {
|
|
2139
2295
|
code: ZodIssueCode.invalid_type,
|
|
2140
2296
|
expected: ZodParsedType.symbol,
|
|
@@ -2142,7 +2298,7 @@ var ZodSymbol = class extends ZodType {
|
|
|
2142
2298
|
});
|
|
2143
2299
|
return INVALID;
|
|
2144
2300
|
}
|
|
2145
|
-
return OK(
|
|
2301
|
+
return OK(input2.data);
|
|
2146
2302
|
}
|
|
2147
2303
|
};
|
|
2148
2304
|
ZodSymbol.create = (params) => {
|
|
@@ -2152,10 +2308,10 @@ ZodSymbol.create = (params) => {
|
|
|
2152
2308
|
});
|
|
2153
2309
|
};
|
|
2154
2310
|
var ZodUndefined = class extends ZodType {
|
|
2155
|
-
_parse(
|
|
2156
|
-
const parsedType = this._getType(
|
|
2311
|
+
_parse(input2) {
|
|
2312
|
+
const parsedType = this._getType(input2);
|
|
2157
2313
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2158
|
-
const ctx = this._getOrReturnCtx(
|
|
2314
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2159
2315
|
addIssueToContext(ctx, {
|
|
2160
2316
|
code: ZodIssueCode.invalid_type,
|
|
2161
2317
|
expected: ZodParsedType.undefined,
|
|
@@ -2163,7 +2319,7 @@ var ZodUndefined = class extends ZodType {
|
|
|
2163
2319
|
});
|
|
2164
2320
|
return INVALID;
|
|
2165
2321
|
}
|
|
2166
|
-
return OK(
|
|
2322
|
+
return OK(input2.data);
|
|
2167
2323
|
}
|
|
2168
2324
|
};
|
|
2169
2325
|
ZodUndefined.create = (params) => {
|
|
@@ -2173,10 +2329,10 @@ ZodUndefined.create = (params) => {
|
|
|
2173
2329
|
});
|
|
2174
2330
|
};
|
|
2175
2331
|
var ZodNull = class extends ZodType {
|
|
2176
|
-
_parse(
|
|
2177
|
-
const parsedType = this._getType(
|
|
2332
|
+
_parse(input2) {
|
|
2333
|
+
const parsedType = this._getType(input2);
|
|
2178
2334
|
if (parsedType !== ZodParsedType.null) {
|
|
2179
|
-
const ctx = this._getOrReturnCtx(
|
|
2335
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2180
2336
|
addIssueToContext(ctx, {
|
|
2181
2337
|
code: ZodIssueCode.invalid_type,
|
|
2182
2338
|
expected: ZodParsedType.null,
|
|
@@ -2184,7 +2340,7 @@ var ZodNull = class extends ZodType {
|
|
|
2184
2340
|
});
|
|
2185
2341
|
return INVALID;
|
|
2186
2342
|
}
|
|
2187
|
-
return OK(
|
|
2343
|
+
return OK(input2.data);
|
|
2188
2344
|
}
|
|
2189
2345
|
};
|
|
2190
2346
|
ZodNull.create = (params) => {
|
|
@@ -2198,8 +2354,8 @@ var ZodAny = class extends ZodType {
|
|
|
2198
2354
|
super(...arguments);
|
|
2199
2355
|
this._any = true;
|
|
2200
2356
|
}
|
|
2201
|
-
_parse(
|
|
2202
|
-
return OK(
|
|
2357
|
+
_parse(input2) {
|
|
2358
|
+
return OK(input2.data);
|
|
2203
2359
|
}
|
|
2204
2360
|
};
|
|
2205
2361
|
ZodAny.create = (params) => {
|
|
@@ -2213,8 +2369,8 @@ var ZodUnknown = class extends ZodType {
|
|
|
2213
2369
|
super(...arguments);
|
|
2214
2370
|
this._unknown = true;
|
|
2215
2371
|
}
|
|
2216
|
-
_parse(
|
|
2217
|
-
return OK(
|
|
2372
|
+
_parse(input2) {
|
|
2373
|
+
return OK(input2.data);
|
|
2218
2374
|
}
|
|
2219
2375
|
};
|
|
2220
2376
|
ZodUnknown.create = (params) => {
|
|
@@ -2224,8 +2380,8 @@ ZodUnknown.create = (params) => {
|
|
|
2224
2380
|
});
|
|
2225
2381
|
};
|
|
2226
2382
|
var ZodNever = class extends ZodType {
|
|
2227
|
-
_parse(
|
|
2228
|
-
const ctx = this._getOrReturnCtx(
|
|
2383
|
+
_parse(input2) {
|
|
2384
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2229
2385
|
addIssueToContext(ctx, {
|
|
2230
2386
|
code: ZodIssueCode.invalid_type,
|
|
2231
2387
|
expected: ZodParsedType.never,
|
|
@@ -2241,10 +2397,10 @@ ZodNever.create = (params) => {
|
|
|
2241
2397
|
});
|
|
2242
2398
|
};
|
|
2243
2399
|
var ZodVoid = class extends ZodType {
|
|
2244
|
-
_parse(
|
|
2245
|
-
const parsedType = this._getType(
|
|
2400
|
+
_parse(input2) {
|
|
2401
|
+
const parsedType = this._getType(input2);
|
|
2246
2402
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2247
|
-
const ctx = this._getOrReturnCtx(
|
|
2403
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2248
2404
|
addIssueToContext(ctx, {
|
|
2249
2405
|
code: ZodIssueCode.invalid_type,
|
|
2250
2406
|
expected: ZodParsedType.void,
|
|
@@ -2252,7 +2408,7 @@ var ZodVoid = class extends ZodType {
|
|
|
2252
2408
|
});
|
|
2253
2409
|
return INVALID;
|
|
2254
2410
|
}
|
|
2255
|
-
return OK(
|
|
2411
|
+
return OK(input2.data);
|
|
2256
2412
|
}
|
|
2257
2413
|
};
|
|
2258
2414
|
ZodVoid.create = (params) => {
|
|
@@ -2262,8 +2418,8 @@ ZodVoid.create = (params) => {
|
|
|
2262
2418
|
});
|
|
2263
2419
|
};
|
|
2264
2420
|
var ZodArray = class _ZodArray extends ZodType {
|
|
2265
|
-
_parse(
|
|
2266
|
-
const { ctx, status } = this._processInputParams(
|
|
2421
|
+
_parse(input2) {
|
|
2422
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
2267
2423
|
const def = this._def;
|
|
2268
2424
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
2269
2425
|
addIssueToContext(ctx, {
|
|
@@ -2403,10 +2559,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2403
2559
|
this._cached = { shape, keys };
|
|
2404
2560
|
return this._cached;
|
|
2405
2561
|
}
|
|
2406
|
-
_parse(
|
|
2407
|
-
const parsedType = this._getType(
|
|
2562
|
+
_parse(input2) {
|
|
2563
|
+
const parsedType = this._getType(input2);
|
|
2408
2564
|
if (parsedType !== ZodParsedType.object) {
|
|
2409
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2565
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2410
2566
|
addIssueToContext(ctx2, {
|
|
2411
2567
|
code: ZodIssueCode.invalid_type,
|
|
2412
2568
|
expected: ZodParsedType.object,
|
|
@@ -2414,7 +2570,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2414
2570
|
});
|
|
2415
2571
|
return INVALID;
|
|
2416
2572
|
}
|
|
2417
|
-
const { status, ctx } = this._processInputParams(
|
|
2573
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2418
2574
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
2419
2575
|
const extraKeys = [];
|
|
2420
2576
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -2726,8 +2882,8 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
2726
2882
|
});
|
|
2727
2883
|
};
|
|
2728
2884
|
var ZodUnion = class extends ZodType {
|
|
2729
|
-
_parse(
|
|
2730
|
-
const { ctx } = this._processInputParams(
|
|
2885
|
+
_parse(input2) {
|
|
2886
|
+
const { ctx } = this._processInputParams(input2);
|
|
2731
2887
|
const options = this._def.options;
|
|
2732
2888
|
function handleResults(results) {
|
|
2733
2889
|
for (const result of results) {
|
|
@@ -2848,8 +3004,8 @@ var getDiscriminator = (type) => {
|
|
|
2848
3004
|
}
|
|
2849
3005
|
};
|
|
2850
3006
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
2851
|
-
_parse(
|
|
2852
|
-
const { ctx } = this._processInputParams(
|
|
3007
|
+
_parse(input2) {
|
|
3008
|
+
const { ctx } = this._processInputParams(input2);
|
|
2853
3009
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
2854
3010
|
addIssueToContext(ctx, {
|
|
2855
3011
|
code: ZodIssueCode.invalid_type,
|
|
@@ -2962,8 +3118,8 @@ function mergeValues(a, b) {
|
|
|
2962
3118
|
}
|
|
2963
3119
|
}
|
|
2964
3120
|
var ZodIntersection = class extends ZodType {
|
|
2965
|
-
_parse(
|
|
2966
|
-
const { status, ctx } = this._processInputParams(
|
|
3121
|
+
_parse(input2) {
|
|
3122
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2967
3123
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
2968
3124
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
2969
3125
|
return INVALID;
|
|
@@ -3015,8 +3171,8 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
3015
3171
|
});
|
|
3016
3172
|
};
|
|
3017
3173
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
3018
|
-
_parse(
|
|
3019
|
-
const { status, ctx } = this._processInputParams(
|
|
3174
|
+
_parse(input2) {
|
|
3175
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3020
3176
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
3021
3177
|
addIssueToContext(ctx, {
|
|
3022
3178
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3051,7 +3207,7 @@ var ZodTuple = class _ZodTuple extends ZodType {
|
|
|
3051
3207
|
if (!schema)
|
|
3052
3208
|
return null;
|
|
3053
3209
|
return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
|
3054
|
-
}).filter((
|
|
3210
|
+
}).filter((x3) => !!x3);
|
|
3055
3211
|
if (ctx.common.async) {
|
|
3056
3212
|
return Promise.all(items).then((results) => {
|
|
3057
3213
|
return ParseStatus.mergeArray(status, results);
|
|
@@ -3088,8 +3244,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3088
3244
|
get valueSchema() {
|
|
3089
3245
|
return this._def.valueType;
|
|
3090
3246
|
}
|
|
3091
|
-
_parse(
|
|
3092
|
-
const { status, ctx } = this._processInputParams(
|
|
3247
|
+
_parse(input2) {
|
|
3248
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3093
3249
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
3094
3250
|
addIssueToContext(ctx, {
|
|
3095
3251
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3141,8 +3297,8 @@ var ZodMap = class extends ZodType {
|
|
|
3141
3297
|
get valueSchema() {
|
|
3142
3298
|
return this._def.valueType;
|
|
3143
3299
|
}
|
|
3144
|
-
_parse(
|
|
3145
|
-
const { status, ctx } = this._processInputParams(
|
|
3300
|
+
_parse(input2) {
|
|
3301
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3146
3302
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
3147
3303
|
addIssueToContext(ctx, {
|
|
3148
3304
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3201,8 +3357,8 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
3201
3357
|
});
|
|
3202
3358
|
};
|
|
3203
3359
|
var ZodSet = class _ZodSet extends ZodType {
|
|
3204
|
-
_parse(
|
|
3205
|
-
const { status, ctx } = this._processInputParams(
|
|
3360
|
+
_parse(input2) {
|
|
3361
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3206
3362
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
3207
3363
|
addIssueToContext(ctx, {
|
|
3208
3364
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3290,8 +3446,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3290
3446
|
super(...arguments);
|
|
3291
3447
|
this.validate = this.implement;
|
|
3292
3448
|
}
|
|
3293
|
-
_parse(
|
|
3294
|
-
const { ctx } = this._processInputParams(
|
|
3449
|
+
_parse(input2) {
|
|
3450
|
+
const { ctx } = this._processInputParams(input2);
|
|
3295
3451
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
3296
3452
|
addIssueToContext(ctx, {
|
|
3297
3453
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3304,7 +3460,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3304
3460
|
return makeIssue({
|
|
3305
3461
|
data: args,
|
|
3306
3462
|
path: ctx.path,
|
|
3307
|
-
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((
|
|
3463
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x3) => !!x3),
|
|
3308
3464
|
issueData: {
|
|
3309
3465
|
code: ZodIssueCode.invalid_arguments,
|
|
3310
3466
|
argumentsError: error
|
|
@@ -3315,7 +3471,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3315
3471
|
return makeIssue({
|
|
3316
3472
|
data: returns,
|
|
3317
3473
|
path: ctx.path,
|
|
3318
|
-
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((
|
|
3474
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x3) => !!x3),
|
|
3319
3475
|
issueData: {
|
|
3320
3476
|
code: ZodIssueCode.invalid_return_type,
|
|
3321
3477
|
returnTypeError: error
|
|
@@ -3325,29 +3481,29 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3325
3481
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
3326
3482
|
const fn = ctx.data;
|
|
3327
3483
|
if (this._def.returns instanceof ZodPromise) {
|
|
3328
|
-
const
|
|
3484
|
+
const me2 = this;
|
|
3329
3485
|
return OK(async function(...args) {
|
|
3330
3486
|
const error = new ZodError([]);
|
|
3331
|
-
const parsedArgs = await
|
|
3332
|
-
error.addIssue(makeArgsIssue(args,
|
|
3487
|
+
const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e2) => {
|
|
3488
|
+
error.addIssue(makeArgsIssue(args, e2));
|
|
3333
3489
|
throw error;
|
|
3334
3490
|
});
|
|
3335
3491
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
3336
|
-
const parsedReturns = await
|
|
3337
|
-
error.addIssue(makeReturnsIssue(result,
|
|
3492
|
+
const parsedReturns = await me2._def.returns._def.type.parseAsync(result, params).catch((e2) => {
|
|
3493
|
+
error.addIssue(makeReturnsIssue(result, e2));
|
|
3338
3494
|
throw error;
|
|
3339
3495
|
});
|
|
3340
3496
|
return parsedReturns;
|
|
3341
3497
|
});
|
|
3342
3498
|
} else {
|
|
3343
|
-
const
|
|
3499
|
+
const me2 = this;
|
|
3344
3500
|
return OK(function(...args) {
|
|
3345
|
-
const parsedArgs =
|
|
3501
|
+
const parsedArgs = me2._def.args.safeParse(args, params);
|
|
3346
3502
|
if (!parsedArgs.success) {
|
|
3347
3503
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
3348
3504
|
}
|
|
3349
3505
|
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3350
|
-
const parsedReturns =
|
|
3506
|
+
const parsedReturns = me2._def.returns.safeParse(result, params);
|
|
3351
3507
|
if (!parsedReturns.success) {
|
|
3352
3508
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
3353
3509
|
}
|
|
@@ -3394,8 +3550,8 @@ var ZodLazy = class extends ZodType {
|
|
|
3394
3550
|
get schema() {
|
|
3395
3551
|
return this._def.getter();
|
|
3396
3552
|
}
|
|
3397
|
-
_parse(
|
|
3398
|
-
const { ctx } = this._processInputParams(
|
|
3553
|
+
_parse(input2) {
|
|
3554
|
+
const { ctx } = this._processInputParams(input2);
|
|
3399
3555
|
const lazySchema = this._def.getter();
|
|
3400
3556
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
3401
3557
|
}
|
|
@@ -3408,9 +3564,9 @@ ZodLazy.create = (getter, params) => {
|
|
|
3408
3564
|
});
|
|
3409
3565
|
};
|
|
3410
3566
|
var ZodLiteral = class extends ZodType {
|
|
3411
|
-
_parse(
|
|
3412
|
-
if (
|
|
3413
|
-
const ctx = this._getOrReturnCtx(
|
|
3567
|
+
_parse(input2) {
|
|
3568
|
+
if (input2.data !== this._def.value) {
|
|
3569
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3414
3570
|
addIssueToContext(ctx, {
|
|
3415
3571
|
received: ctx.data,
|
|
3416
3572
|
code: ZodIssueCode.invalid_literal,
|
|
@@ -3418,7 +3574,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
3418
3574
|
});
|
|
3419
3575
|
return INVALID;
|
|
3420
3576
|
}
|
|
3421
|
-
return { status: "valid", value:
|
|
3577
|
+
return { status: "valid", value: input2.data };
|
|
3422
3578
|
}
|
|
3423
3579
|
get value() {
|
|
3424
3580
|
return this._def.value;
|
|
@@ -3439,9 +3595,9 @@ function createZodEnum(values, params) {
|
|
|
3439
3595
|
});
|
|
3440
3596
|
}
|
|
3441
3597
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3442
|
-
_parse(
|
|
3443
|
-
if (typeof
|
|
3444
|
-
const ctx = this._getOrReturnCtx(
|
|
3598
|
+
_parse(input2) {
|
|
3599
|
+
if (typeof input2.data !== "string") {
|
|
3600
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3445
3601
|
const expectedValues = this._def.values;
|
|
3446
3602
|
addIssueToContext(ctx, {
|
|
3447
3603
|
expected: util.joinValues(expectedValues),
|
|
@@ -3453,8 +3609,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3453
3609
|
if (!this._cache) {
|
|
3454
3610
|
this._cache = new Set(this._def.values);
|
|
3455
3611
|
}
|
|
3456
|
-
if (!this._cache.has(
|
|
3457
|
-
const ctx = this._getOrReturnCtx(
|
|
3612
|
+
if (!this._cache.has(input2.data)) {
|
|
3613
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3458
3614
|
const expectedValues = this._def.values;
|
|
3459
3615
|
addIssueToContext(ctx, {
|
|
3460
3616
|
received: ctx.data,
|
|
@@ -3463,7 +3619,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3463
3619
|
});
|
|
3464
3620
|
return INVALID;
|
|
3465
3621
|
}
|
|
3466
|
-
return OK(
|
|
3622
|
+
return OK(input2.data);
|
|
3467
3623
|
}
|
|
3468
3624
|
get options() {
|
|
3469
3625
|
return this._def.values;
|
|
@@ -3504,9 +3660,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3504
3660
|
};
|
|
3505
3661
|
ZodEnum.create = createZodEnum;
|
|
3506
3662
|
var ZodNativeEnum = class extends ZodType {
|
|
3507
|
-
_parse(
|
|
3663
|
+
_parse(input2) {
|
|
3508
3664
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3509
|
-
const ctx = this._getOrReturnCtx(
|
|
3665
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3510
3666
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
3511
3667
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3512
3668
|
addIssueToContext(ctx, {
|
|
@@ -3519,7 +3675,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3519
3675
|
if (!this._cache) {
|
|
3520
3676
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
3521
3677
|
}
|
|
3522
|
-
if (!this._cache.has(
|
|
3678
|
+
if (!this._cache.has(input2.data)) {
|
|
3523
3679
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3524
3680
|
addIssueToContext(ctx, {
|
|
3525
3681
|
received: ctx.data,
|
|
@@ -3528,7 +3684,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3528
3684
|
});
|
|
3529
3685
|
return INVALID;
|
|
3530
3686
|
}
|
|
3531
|
-
return OK(
|
|
3687
|
+
return OK(input2.data);
|
|
3532
3688
|
}
|
|
3533
3689
|
get enum() {
|
|
3534
3690
|
return this._def.values;
|
|
@@ -3545,8 +3701,8 @@ var ZodPromise = class extends ZodType {
|
|
|
3545
3701
|
unwrap() {
|
|
3546
3702
|
return this._def.type;
|
|
3547
3703
|
}
|
|
3548
|
-
_parse(
|
|
3549
|
-
const { ctx } = this._processInputParams(
|
|
3704
|
+
_parse(input2) {
|
|
3705
|
+
const { ctx } = this._processInputParams(input2);
|
|
3550
3706
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
3551
3707
|
addIssueToContext(ctx, {
|
|
3552
3708
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3578,8 +3734,8 @@ var ZodEffects = class extends ZodType {
|
|
|
3578
3734
|
sourceType() {
|
|
3579
3735
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3580
3736
|
}
|
|
3581
|
-
_parse(
|
|
3582
|
-
const { status, ctx } = this._processInputParams(
|
|
3737
|
+
_parse(input2) {
|
|
3738
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3583
3739
|
const effect = this._def.effect || null;
|
|
3584
3740
|
const checkCtx = {
|
|
3585
3741
|
addIssue: (arg) => {
|
|
@@ -3711,12 +3867,12 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
|
3711
3867
|
});
|
|
3712
3868
|
};
|
|
3713
3869
|
var ZodOptional = class extends ZodType {
|
|
3714
|
-
_parse(
|
|
3715
|
-
const parsedType = this._getType(
|
|
3870
|
+
_parse(input2) {
|
|
3871
|
+
const parsedType = this._getType(input2);
|
|
3716
3872
|
if (parsedType === ZodParsedType.undefined) {
|
|
3717
3873
|
return OK(void 0);
|
|
3718
3874
|
}
|
|
3719
|
-
return this._def.innerType._parse(
|
|
3875
|
+
return this._def.innerType._parse(input2);
|
|
3720
3876
|
}
|
|
3721
3877
|
unwrap() {
|
|
3722
3878
|
return this._def.innerType;
|
|
@@ -3730,12 +3886,12 @@ ZodOptional.create = (type, params) => {
|
|
|
3730
3886
|
});
|
|
3731
3887
|
};
|
|
3732
3888
|
var ZodNullable = class extends ZodType {
|
|
3733
|
-
_parse(
|
|
3734
|
-
const parsedType = this._getType(
|
|
3889
|
+
_parse(input2) {
|
|
3890
|
+
const parsedType = this._getType(input2);
|
|
3735
3891
|
if (parsedType === ZodParsedType.null) {
|
|
3736
3892
|
return OK(null);
|
|
3737
3893
|
}
|
|
3738
|
-
return this._def.innerType._parse(
|
|
3894
|
+
return this._def.innerType._parse(input2);
|
|
3739
3895
|
}
|
|
3740
3896
|
unwrap() {
|
|
3741
3897
|
return this._def.innerType;
|
|
@@ -3749,8 +3905,8 @@ ZodNullable.create = (type, params) => {
|
|
|
3749
3905
|
});
|
|
3750
3906
|
};
|
|
3751
3907
|
var ZodDefault = class extends ZodType {
|
|
3752
|
-
_parse(
|
|
3753
|
-
const { ctx } = this._processInputParams(
|
|
3908
|
+
_parse(input2) {
|
|
3909
|
+
const { ctx } = this._processInputParams(input2);
|
|
3754
3910
|
let data = ctx.data;
|
|
3755
3911
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
3756
3912
|
data = this._def.defaultValue();
|
|
@@ -3774,8 +3930,8 @@ ZodDefault.create = (type, params) => {
|
|
|
3774
3930
|
});
|
|
3775
3931
|
};
|
|
3776
3932
|
var ZodCatch = class extends ZodType {
|
|
3777
|
-
_parse(
|
|
3778
|
-
const { ctx } = this._processInputParams(
|
|
3933
|
+
_parse(input2) {
|
|
3934
|
+
const { ctx } = this._processInputParams(input2);
|
|
3779
3935
|
const newCtx = {
|
|
3780
3936
|
...ctx,
|
|
3781
3937
|
common: {
|
|
@@ -3827,10 +3983,10 @@ ZodCatch.create = (type, params) => {
|
|
|
3827
3983
|
});
|
|
3828
3984
|
};
|
|
3829
3985
|
var ZodNaN = class extends ZodType {
|
|
3830
|
-
_parse(
|
|
3831
|
-
const parsedType = this._getType(
|
|
3986
|
+
_parse(input2) {
|
|
3987
|
+
const parsedType = this._getType(input2);
|
|
3832
3988
|
if (parsedType !== ZodParsedType.nan) {
|
|
3833
|
-
const ctx = this._getOrReturnCtx(
|
|
3989
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3834
3990
|
addIssueToContext(ctx, {
|
|
3835
3991
|
code: ZodIssueCode.invalid_type,
|
|
3836
3992
|
expected: ZodParsedType.nan,
|
|
@@ -3838,7 +3994,7 @@ var ZodNaN = class extends ZodType {
|
|
|
3838
3994
|
});
|
|
3839
3995
|
return INVALID;
|
|
3840
3996
|
}
|
|
3841
|
-
return { status: "valid", value:
|
|
3997
|
+
return { status: "valid", value: input2.data };
|
|
3842
3998
|
}
|
|
3843
3999
|
};
|
|
3844
4000
|
ZodNaN.create = (params) => {
|
|
@@ -3849,8 +4005,8 @@ ZodNaN.create = (params) => {
|
|
|
3849
4005
|
};
|
|
3850
4006
|
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
3851
4007
|
var ZodBranded = class extends ZodType {
|
|
3852
|
-
_parse(
|
|
3853
|
-
const { ctx } = this._processInputParams(
|
|
4008
|
+
_parse(input2) {
|
|
4009
|
+
const { ctx } = this._processInputParams(input2);
|
|
3854
4010
|
const data = ctx.data;
|
|
3855
4011
|
return this._def.type._parse({
|
|
3856
4012
|
data,
|
|
@@ -3863,8 +4019,8 @@ var ZodBranded = class extends ZodType {
|
|
|
3863
4019
|
}
|
|
3864
4020
|
};
|
|
3865
4021
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
3866
|
-
_parse(
|
|
3867
|
-
const { status, ctx } = this._processInputParams(
|
|
4022
|
+
_parse(input2) {
|
|
4023
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3868
4024
|
if (ctx.common.async) {
|
|
3869
4025
|
const handleAsync = async () => {
|
|
3870
4026
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -3918,8 +4074,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3918
4074
|
}
|
|
3919
4075
|
};
|
|
3920
4076
|
var ZodReadonly = class extends ZodType {
|
|
3921
|
-
_parse(
|
|
3922
|
-
const result = this._def.innerType._parse(
|
|
4077
|
+
_parse(input2) {
|
|
4078
|
+
const result = this._def.innerType._parse(input2);
|
|
3923
4079
|
const freeze = (data) => {
|
|
3924
4080
|
if (isValid(data)) {
|
|
3925
4081
|
data.value = Object.freeze(data.value);
|
|
@@ -4767,7 +4923,7 @@ function extractMediaFromText(text, options = {}) {
|
|
|
4767
4923
|
const {
|
|
4768
4924
|
removeFromText = true,
|
|
4769
4925
|
checkExists = false,
|
|
4770
|
-
existsSync:
|
|
4926
|
+
existsSync: existsSync5,
|
|
4771
4927
|
parseMediaLines = false,
|
|
4772
4928
|
parseMarkdownImages = true,
|
|
4773
4929
|
parseHtmlImages = true,
|
|
@@ -4782,7 +4938,7 @@ function extractMediaFromText(text, options = {}) {
|
|
|
4782
4938
|
const key = media.localPath || media.source;
|
|
4783
4939
|
if (seenSources.has(key)) return false;
|
|
4784
4940
|
if (checkExists && media.isLocal && media.localPath) {
|
|
4785
|
-
const exists =
|
|
4941
|
+
const exists = existsSync5 ? existsSync5(media.localPath) : fs3.existsSync(media.localPath);
|
|
4786
4942
|
if (!exists) return false;
|
|
4787
4943
|
}
|
|
4788
4944
|
seenSources.add(key);
|
|
@@ -5011,8 +5167,8 @@ function normalizeForCompare(value) {
|
|
|
5011
5167
|
}
|
|
5012
5168
|
function isPathUnderDir(filePath, dirPath) {
|
|
5013
5169
|
const f = normalizeForCompare(filePath);
|
|
5014
|
-
const
|
|
5015
|
-
return f ===
|
|
5170
|
+
const d2 = normalizeForCompare(dirPath).replace(/\/+$/, "");
|
|
5171
|
+
return f === d2 || f.startsWith(`${d2}/`);
|
|
5016
5172
|
}
|
|
5017
5173
|
function formatDateDir(date = /* @__PURE__ */ new Date()) {
|
|
5018
5174
|
const yyyy = date.getFullYear();
|
|
@@ -5268,6 +5424,1381 @@ function appendCronHiddenPrompt(text) {
|
|
|
5268
5424
|
|
|
5269
5425
|
${CRON_HIDDEN_PROMPT}`;
|
|
5270
5426
|
}
|
|
5427
|
+
|
|
5428
|
+
// ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
|
|
5429
|
+
var import_picocolors = __toESM(require_picocolors());
|
|
5430
|
+
var import_sisteransi = __toESM(require_src());
|
|
5431
|
+
function B(t, e2, s) {
|
|
5432
|
+
if (!s.some((u) => !u.disabled)) return t;
|
|
5433
|
+
const i = t + e2, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
5434
|
+
return s[n].disabled ? B(n, e2 < 0 ? -1 : 1, s) : n;
|
|
5435
|
+
}
|
|
5436
|
+
var at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
|
|
5437
|
+
var lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
|
|
5438
|
+
var ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
|
|
5439
|
+
var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
5440
|
+
var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
5441
|
+
var L = /\t{1,1000}/y;
|
|
5442
|
+
var P = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
5443
|
+
var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
5444
|
+
var ct = /\p{M}+/gu;
|
|
5445
|
+
var ft = { limit: 1 / 0, ellipsis: "" };
|
|
5446
|
+
var X = (t, e2 = {}, s = {}) => {
|
|
5447
|
+
const i = e2.limit ?? 1 / 0, r = e2.ellipsis ?? "", n = e2?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V2 = s.wideWidth ?? 2;
|
|
5448
|
+
let h = 0, o = 0, p = t.length, v = 0, F = false, d2 = p, b = Math.max(0, i - n), C2 = 0, w = 0, c = 0, f = 0;
|
|
5449
|
+
t: for (; ; ) {
|
|
5450
|
+
if (w > C2 || o >= p && o > h) {
|
|
5451
|
+
const ut2 = t.slice(C2, w) || t.slice(h, o);
|
|
5452
|
+
v = 0;
|
|
5453
|
+
for (const Y of ut2.replaceAll(ct, "")) {
|
|
5454
|
+
const $ = Y.codePointAt(0) || 0;
|
|
5455
|
+
if (lt($) ? f = m : ht($) ? f = V2 : E !== A && at($) ? f = E : f = A, c + f > b && (d2 = Math.min(d2, Math.max(C2, h) + v)), c + f > i) {
|
|
5456
|
+
F = true;
|
|
5457
|
+
break t;
|
|
5458
|
+
}
|
|
5459
|
+
v += Y.length, c += f;
|
|
5460
|
+
}
|
|
5461
|
+
C2 = w = 0;
|
|
5462
|
+
}
|
|
5463
|
+
if (o >= p) break;
|
|
5464
|
+
if (M.lastIndex = o, M.test(t)) {
|
|
5465
|
+
if (v = M.lastIndex - o, f = v * A, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / A))), c + f > i) {
|
|
5466
|
+
F = true;
|
|
5467
|
+
break;
|
|
5468
|
+
}
|
|
5469
|
+
c += f, C2 = h, w = o, o = h = M.lastIndex;
|
|
5470
|
+
continue;
|
|
5471
|
+
}
|
|
5472
|
+
if (O.lastIndex = o, O.test(t)) {
|
|
5473
|
+
if (c + u > b && (d2 = Math.min(d2, o)), c + u > i) {
|
|
5474
|
+
F = true;
|
|
5475
|
+
break;
|
|
5476
|
+
}
|
|
5477
|
+
c += u, C2 = h, w = o, o = h = O.lastIndex;
|
|
5478
|
+
continue;
|
|
5479
|
+
}
|
|
5480
|
+
if (y.lastIndex = o, y.test(t)) {
|
|
5481
|
+
if (v = y.lastIndex - o, f = v * a, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / a))), c + f > i) {
|
|
5482
|
+
F = true;
|
|
5483
|
+
break;
|
|
5484
|
+
}
|
|
5485
|
+
c += f, C2 = h, w = o, o = h = y.lastIndex;
|
|
5486
|
+
continue;
|
|
5487
|
+
}
|
|
5488
|
+
if (L.lastIndex = o, L.test(t)) {
|
|
5489
|
+
if (v = L.lastIndex - o, f = v * l, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / l))), c + f > i) {
|
|
5490
|
+
F = true;
|
|
5491
|
+
break;
|
|
5492
|
+
}
|
|
5493
|
+
c += f, C2 = h, w = o, o = h = L.lastIndex;
|
|
5494
|
+
continue;
|
|
5495
|
+
}
|
|
5496
|
+
if (P.lastIndex = o, P.test(t)) {
|
|
5497
|
+
if (c + g > b && (d2 = Math.min(d2, o)), c + g > i) {
|
|
5498
|
+
F = true;
|
|
5499
|
+
break;
|
|
5500
|
+
}
|
|
5501
|
+
c += g, C2 = h, w = o, o = h = P.lastIndex;
|
|
5502
|
+
continue;
|
|
5503
|
+
}
|
|
5504
|
+
o += 1;
|
|
5505
|
+
}
|
|
5506
|
+
return { width: F ? b : c, index: F ? d2 : p, truncated: F, ellipsed: F && i >= n };
|
|
5507
|
+
};
|
|
5508
|
+
var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
5509
|
+
var S = (t, e2 = {}) => X(t, pt, e2).width;
|
|
5510
|
+
var W = "\x1B";
|
|
5511
|
+
var Z = "\x9B";
|
|
5512
|
+
var Ft = 39;
|
|
5513
|
+
var j = "\x07";
|
|
5514
|
+
var Q = "[";
|
|
5515
|
+
var dt = "]";
|
|
5516
|
+
var tt = "m";
|
|
5517
|
+
var U = `${dt}8;;`;
|
|
5518
|
+
var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
|
|
5519
|
+
var mt = (t) => {
|
|
5520
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
5521
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
5522
|
+
if (t === 1 || t === 2) return 22;
|
|
5523
|
+
if (t === 3) return 23;
|
|
5524
|
+
if (t === 4) return 24;
|
|
5525
|
+
if (t === 7) return 27;
|
|
5526
|
+
if (t === 8) return 28;
|
|
5527
|
+
if (t === 9) return 29;
|
|
5528
|
+
if (t === 0) return 0;
|
|
5529
|
+
};
|
|
5530
|
+
var st = (t) => `${W}${Q}${t}${tt}`;
|
|
5531
|
+
var it = (t) => `${W}${U}${t}${j}`;
|
|
5532
|
+
var gt = (t) => t.map((e2) => S(e2));
|
|
5533
|
+
var G = (t, e2, s) => {
|
|
5534
|
+
const i = e2[Symbol.iterator]();
|
|
5535
|
+
let r = false, n = false, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
5536
|
+
for (; !l.done; ) {
|
|
5537
|
+
const m = l.value, A = S(m);
|
|
5538
|
+
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W || m === Z) && (r = true, n = e2.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
5539
|
+
}
|
|
5540
|
+
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
5541
|
+
};
|
|
5542
|
+
var vt = (t) => {
|
|
5543
|
+
const e2 = t.split(" ");
|
|
5544
|
+
let s = e2.length;
|
|
5545
|
+
for (; s > 0 && !(S(e2[s - 1]) > 0); ) s--;
|
|
5546
|
+
return s === e2.length ? t : e2.slice(0, s).join(" ") + e2.slice(s).join("");
|
|
5547
|
+
};
|
|
5548
|
+
var Et = (t, e2, s = {}) => {
|
|
5549
|
+
if (s.trim !== false && t.trim() === "") return "";
|
|
5550
|
+
let i = "", r, n;
|
|
5551
|
+
const u = t.split(" "), a = gt(u);
|
|
5552
|
+
let l = [""];
|
|
5553
|
+
for (const [h, o] of u.entries()) {
|
|
5554
|
+
s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
5555
|
+
let p = S(l.at(-1) ?? "");
|
|
5556
|
+
if (h !== 0 && (p >= e2 && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e2) {
|
|
5557
|
+
const v = e2 - p, F = 1 + Math.floor((a[h] - v - 1) / e2);
|
|
5558
|
+
Math.floor((a[h] - 1) / e2) < F && l.push(""), G(l, o, e2);
|
|
5559
|
+
continue;
|
|
5560
|
+
}
|
|
5561
|
+
if (p + a[h] > e2 && p > 0 && a[h] > 0) {
|
|
5562
|
+
if (s.wordWrap === false && p < e2) {
|
|
5563
|
+
G(l, o, e2);
|
|
5564
|
+
continue;
|
|
5565
|
+
}
|
|
5566
|
+
l.push("");
|
|
5567
|
+
}
|
|
5568
|
+
if (p + a[h] > e2 && s.wordWrap === false) {
|
|
5569
|
+
G(l, o, e2);
|
|
5570
|
+
continue;
|
|
5571
|
+
}
|
|
5572
|
+
l[l.length - 1] += o;
|
|
5573
|
+
}
|
|
5574
|
+
s.trim !== false && (l = l.map((h) => vt(h)));
|
|
5575
|
+
const E = l.join(`
|
|
5576
|
+
`), g = E[Symbol.iterator]();
|
|
5577
|
+
let m = g.next(), A = g.next(), V2 = 0;
|
|
5578
|
+
for (; !m.done; ) {
|
|
5579
|
+
const h = m.value, o = A.value;
|
|
5580
|
+
if (i += h, h === W || h === Z) {
|
|
5581
|
+
et.lastIndex = V2 + 1;
|
|
5582
|
+
const F = et.exec(E)?.groups;
|
|
5583
|
+
if (F?.code !== void 0) {
|
|
5584
|
+
const d2 = Number.parseFloat(F.code);
|
|
5585
|
+
r = d2 === Ft ? void 0 : d2;
|
|
5586
|
+
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
5587
|
+
}
|
|
5588
|
+
const p = r ? mt(r) : void 0;
|
|
5589
|
+
o === `
|
|
5590
|
+
` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
|
|
5591
|
+
` && (r && p && (i += st(r)), n && (i += it(n))), V2 += h.length, m = A, A = g.next();
|
|
5592
|
+
}
|
|
5593
|
+
return i;
|
|
5594
|
+
};
|
|
5595
|
+
function K(t, e2, s) {
|
|
5596
|
+
return String(t).normalize().replaceAll(`\r
|
|
5597
|
+
`, `
|
|
5598
|
+
`).split(`
|
|
5599
|
+
`).map((i) => Et(i, e2, s)).join(`
|
|
5600
|
+
`);
|
|
5601
|
+
}
|
|
5602
|
+
var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
5603
|
+
var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), withGuide: true };
|
|
5604
|
+
function H(t, e2) {
|
|
5605
|
+
if (typeof t == "string") return _.aliases.get(t) === e2;
|
|
5606
|
+
for (const s of t) if (s !== void 0 && H(s, e2)) return true;
|
|
5607
|
+
return false;
|
|
5608
|
+
}
|
|
5609
|
+
function _t(t, e2) {
|
|
5610
|
+
if (t === e2) return;
|
|
5611
|
+
const s = t.split(`
|
|
5612
|
+
`), i = e2.split(`
|
|
5613
|
+
`), r = Math.max(s.length, i.length), n = [];
|
|
5614
|
+
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
|
|
5615
|
+
return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
|
|
5616
|
+
}
|
|
5617
|
+
globalThis.process.platform.startsWith("win");
|
|
5618
|
+
var z = /* @__PURE__ */ Symbol("clack:cancel");
|
|
5619
|
+
function Ct(t) {
|
|
5620
|
+
return t === z;
|
|
5621
|
+
}
|
|
5622
|
+
function T(t, e2) {
|
|
5623
|
+
const s = t;
|
|
5624
|
+
s.isTTY && s.setRawMode(e2);
|
|
5625
|
+
}
|
|
5626
|
+
var rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80;
|
|
5627
|
+
var nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
|
|
5628
|
+
function xt(t, e2, s, i = s) {
|
|
5629
|
+
const r = rt(t ?? stdout);
|
|
5630
|
+
return K(e2, r - s.length, { hard: true, trim: false }).split(`
|
|
5631
|
+
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
|
|
5632
|
+
`);
|
|
5633
|
+
}
|
|
5634
|
+
var x = class {
|
|
5635
|
+
input;
|
|
5636
|
+
output;
|
|
5637
|
+
_abortSignal;
|
|
5638
|
+
rl;
|
|
5639
|
+
opts;
|
|
5640
|
+
_render;
|
|
5641
|
+
_track = false;
|
|
5642
|
+
_prevFrame = "";
|
|
5643
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
5644
|
+
_cursor = 0;
|
|
5645
|
+
state = "initial";
|
|
5646
|
+
error = "";
|
|
5647
|
+
value;
|
|
5648
|
+
userInput = "";
|
|
5649
|
+
constructor(e2, s = true) {
|
|
5650
|
+
const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e2;
|
|
5651
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
|
|
5652
|
+
}
|
|
5653
|
+
unsubscribe() {
|
|
5654
|
+
this._subscribers.clear();
|
|
5655
|
+
}
|
|
5656
|
+
setSubscriber(e2, s) {
|
|
5657
|
+
const i = this._subscribers.get(e2) ?? [];
|
|
5658
|
+
i.push(s), this._subscribers.set(e2, i);
|
|
5659
|
+
}
|
|
5660
|
+
on(e2, s) {
|
|
5661
|
+
this.setSubscriber(e2, { cb: s });
|
|
5662
|
+
}
|
|
5663
|
+
once(e2, s) {
|
|
5664
|
+
this.setSubscriber(e2, { cb: s, once: true });
|
|
5665
|
+
}
|
|
5666
|
+
emit(e2, ...s) {
|
|
5667
|
+
const i = this._subscribers.get(e2) ?? [], r = [];
|
|
5668
|
+
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
5669
|
+
for (const n of r) n();
|
|
5670
|
+
}
|
|
5671
|
+
prompt() {
|
|
5672
|
+
return new Promise((e2) => {
|
|
5673
|
+
if (this._abortSignal) {
|
|
5674
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e2(z);
|
|
5675
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
5676
|
+
this.state = "cancel", this.close();
|
|
5677
|
+
}, { once: true });
|
|
5678
|
+
}
|
|
5679
|
+
this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), T(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
5680
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(this.value);
|
|
5681
|
+
}), this.once("cancel", () => {
|
|
5682
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(z);
|
|
5683
|
+
});
|
|
5684
|
+
});
|
|
5685
|
+
}
|
|
5686
|
+
_isActionKey(e2, s) {
|
|
5687
|
+
return e2 === " ";
|
|
5688
|
+
}
|
|
5689
|
+
_setValue(e2) {
|
|
5690
|
+
this.value = e2, this.emit("value", this.value);
|
|
5691
|
+
}
|
|
5692
|
+
_setUserInput(e2, s) {
|
|
5693
|
+
this.userInput = e2 ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
5694
|
+
}
|
|
5695
|
+
_clearUserInput() {
|
|
5696
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
5697
|
+
}
|
|
5698
|
+
onKeypress(e2, s) {
|
|
5699
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e2, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e2 && (e2.toLowerCase() === "y" || e2.toLowerCase() === "n") && this.emit("confirm", e2.toLowerCase() === "y"), this.emit("key", e2?.toLowerCase(), s), s?.name === "return") {
|
|
5700
|
+
if (this.opts.validate) {
|
|
5701
|
+
const i = this.opts.validate(this.value);
|
|
5702
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
5703
|
+
}
|
|
5704
|
+
this.state !== "error" && (this.state = "submit");
|
|
5705
|
+
}
|
|
5706
|
+
H([e2, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
5707
|
+
}
|
|
5708
|
+
close() {
|
|
5709
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
5710
|
+
`), T(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
5711
|
+
}
|
|
5712
|
+
restoreCursor() {
|
|
5713
|
+
const e2 = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
5714
|
+
`).length - 1;
|
|
5715
|
+
this.output.write(import_sisteransi.cursor.move(-999, e2 * -1));
|
|
5716
|
+
}
|
|
5717
|
+
render() {
|
|
5718
|
+
const e2 = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
5719
|
+
if (e2 !== this._prevFrame) {
|
|
5720
|
+
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
5721
|
+
else {
|
|
5722
|
+
const s = _t(this._prevFrame, e2), i = nt(this.output);
|
|
5723
|
+
if (this.restoreCursor(), s) {
|
|
5724
|
+
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
|
|
5725
|
+
let u = s.lines.find((a) => a >= r);
|
|
5726
|
+
if (u === void 0) {
|
|
5727
|
+
this._prevFrame = e2;
|
|
5728
|
+
return;
|
|
5729
|
+
}
|
|
5730
|
+
if (s.lines.length === 1) {
|
|
5731
|
+
this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
5732
|
+
const a = e2.split(`
|
|
5733
|
+
`);
|
|
5734
|
+
this.output.write(a[u]), this._prevFrame = e2, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
|
|
5735
|
+
return;
|
|
5736
|
+
} else if (s.lines.length > 1) {
|
|
5737
|
+
if (r < n) u = r;
|
|
5738
|
+
else {
|
|
5739
|
+
const l = u - n;
|
|
5740
|
+
l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
|
|
5741
|
+
}
|
|
5742
|
+
this.output.write(import_sisteransi.erase.down());
|
|
5743
|
+
const a = e2.split(`
|
|
5744
|
+
`).slice(u);
|
|
5745
|
+
this.output.write(a.join(`
|
|
5746
|
+
`)), this._prevFrame = e2;
|
|
5747
|
+
return;
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
this.output.write(import_sisteransi.erase.down());
|
|
5751
|
+
}
|
|
5752
|
+
this.output.write(e2), this.state === "initial" && (this.state = "active"), this._prevFrame = e2;
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5755
|
+
};
|
|
5756
|
+
var kt = class extends x {
|
|
5757
|
+
get cursor() {
|
|
5758
|
+
return this.value ? 0 : 1;
|
|
5759
|
+
}
|
|
5760
|
+
get _value() {
|
|
5761
|
+
return this.cursor === 0;
|
|
5762
|
+
}
|
|
5763
|
+
constructor(e2) {
|
|
5764
|
+
super(e2, false), this.value = !!e2.initialValue, this.on("userInput", () => {
|
|
5765
|
+
this.value = this._value;
|
|
5766
|
+
}), this.on("confirm", (s) => {
|
|
5767
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
5768
|
+
}), this.on("cursor", () => {
|
|
5769
|
+
this.value = !this.value;
|
|
5770
|
+
});
|
|
5771
|
+
}
|
|
5772
|
+
};
|
|
5773
|
+
var Wt = class extends x {
|
|
5774
|
+
options;
|
|
5775
|
+
cursor = 0;
|
|
5776
|
+
get _selectedValue() {
|
|
5777
|
+
return this.options[this.cursor];
|
|
5778
|
+
}
|
|
5779
|
+
changeValue() {
|
|
5780
|
+
this.value = this._selectedValue.value;
|
|
5781
|
+
}
|
|
5782
|
+
constructor(e2) {
|
|
5783
|
+
super(e2, false), this.options = e2.options;
|
|
5784
|
+
const s = this.options.findIndex(({ value: r }) => r === e2.initialValue), i = s === -1 ? 0 : s;
|
|
5785
|
+
this.cursor = this.options[i].disabled ? B(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
|
|
5786
|
+
switch (r) {
|
|
5787
|
+
case "left":
|
|
5788
|
+
case "up":
|
|
5789
|
+
this.cursor = B(this.cursor, -1, this.options);
|
|
5790
|
+
break;
|
|
5791
|
+
case "down":
|
|
5792
|
+
case "right":
|
|
5793
|
+
this.cursor = B(this.cursor, 1, this.options);
|
|
5794
|
+
break;
|
|
5795
|
+
}
|
|
5796
|
+
this.changeValue();
|
|
5797
|
+
});
|
|
5798
|
+
}
|
|
5799
|
+
};
|
|
5800
|
+
var $t = class extends x {
|
|
5801
|
+
get userInputWithCursor() {
|
|
5802
|
+
if (this.state === "submit") return this.userInput;
|
|
5803
|
+
const e2 = this.userInput;
|
|
5804
|
+
if (this.cursor >= e2.length) return `${this.userInput}\u2588`;
|
|
5805
|
+
const s = e2.slice(0, this.cursor), [i, ...r] = e2.slice(this.cursor);
|
|
5806
|
+
return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
|
|
5807
|
+
}
|
|
5808
|
+
get cursor() {
|
|
5809
|
+
return this._cursor;
|
|
5810
|
+
}
|
|
5811
|
+
constructor(e2) {
|
|
5812
|
+
super({ ...e2, initialUserInput: e2.initialUserInput ?? e2.initialValue }), this.on("userInput", (s) => {
|
|
5813
|
+
this._setValue(s);
|
|
5814
|
+
}), this.on("finalize", () => {
|
|
5815
|
+
this.value || (this.value = e2.defaultValue), this.value === void 0 && (this.value = "");
|
|
5816
|
+
});
|
|
5817
|
+
}
|
|
5818
|
+
};
|
|
5819
|
+
|
|
5820
|
+
// ../../node_modules/.pnpm/@clack+prompts@1.0.1/node_modules/@clack/prompts/dist/index.mjs
|
|
5821
|
+
var import_picocolors2 = __toESM(require_picocolors());
|
|
5822
|
+
__toESM(require_src());
|
|
5823
|
+
function me() {
|
|
5824
|
+
return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
5825
|
+
}
|
|
5826
|
+
var et2 = me();
|
|
5827
|
+
var C = (t, r) => et2 ? t : r;
|
|
5828
|
+
var Rt = C("\u25C6", "*");
|
|
5829
|
+
var dt2 = C("\u25A0", "x");
|
|
5830
|
+
var $t2 = C("\u25B2", "x");
|
|
5831
|
+
var V = C("\u25C7", "o");
|
|
5832
|
+
var ht2 = C("\u250C", "T");
|
|
5833
|
+
var d = C("\u2502", "|");
|
|
5834
|
+
var x2 = C("\u2514", "\u2014");
|
|
5835
|
+
var Q2 = C("\u25CF", ">");
|
|
5836
|
+
var H2 = C("\u25CB", " ");
|
|
5837
|
+
var rt2 = C("\u2500", "-");
|
|
5838
|
+
var mt2 = C("\u256E", "+");
|
|
5839
|
+
var Wt2 = C("\u251C", "+");
|
|
5840
|
+
var pt2 = C("\u256F", "+");
|
|
5841
|
+
var W2 = (t) => {
|
|
5842
|
+
switch (t) {
|
|
5843
|
+
case "initial":
|
|
5844
|
+
case "active":
|
|
5845
|
+
return import_picocolors2.default.cyan(Rt);
|
|
5846
|
+
case "cancel":
|
|
5847
|
+
return import_picocolors2.default.red(dt2);
|
|
5848
|
+
case "error":
|
|
5849
|
+
return import_picocolors2.default.yellow($t2);
|
|
5850
|
+
case "submit":
|
|
5851
|
+
return import_picocolors2.default.green(V);
|
|
5852
|
+
}
|
|
5853
|
+
};
|
|
5854
|
+
var vt2 = (t) => {
|
|
5855
|
+
switch (t) {
|
|
5856
|
+
case "initial":
|
|
5857
|
+
case "active":
|
|
5858
|
+
return import_picocolors2.default.cyan(d);
|
|
5859
|
+
case "cancel":
|
|
5860
|
+
return import_picocolors2.default.red(d);
|
|
5861
|
+
case "error":
|
|
5862
|
+
return import_picocolors2.default.yellow(d);
|
|
5863
|
+
case "submit":
|
|
5864
|
+
return import_picocolors2.default.green(d);
|
|
5865
|
+
}
|
|
5866
|
+
};
|
|
5867
|
+
var pe = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
|
|
5868
|
+
var ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
|
|
5869
|
+
var fe = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
|
|
5870
|
+
var At2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
5871
|
+
var it2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
5872
|
+
var nt2 = /\t{1,1000}/y;
|
|
5873
|
+
var wt = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
5874
|
+
var at2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
5875
|
+
var Fe = /\p{M}+/gu;
|
|
5876
|
+
var ye = { limit: 1 / 0, ellipsis: "" };
|
|
5877
|
+
var jt = (t, r = {}, s = {}) => {
|
|
5878
|
+
const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
5879
|
+
let $ = 0, m = 0, h = t.length, y2 = 0, f = false, v = h, S2 = Math.max(0, i - o), I2 = 0, B2 = 0, A = 0, w = 0;
|
|
5880
|
+
t: for (; ; ) {
|
|
5881
|
+
if (B2 > I2 || m >= h && m > $) {
|
|
5882
|
+
const _2 = t.slice(I2, B2) || t.slice($, m);
|
|
5883
|
+
y2 = 0;
|
|
5884
|
+
for (const D2 of _2.replaceAll(Fe, "")) {
|
|
5885
|
+
const T2 = D2.codePointAt(0) || 0;
|
|
5886
|
+
if (ge(T2) ? w = F : fe(T2) ? w = E : c !== p && pe(T2) ? w = c : w = p, A + w > S2 && (v = Math.min(v, Math.max(I2, $) + y2)), A + w > i) {
|
|
5887
|
+
f = true;
|
|
5888
|
+
break t;
|
|
5889
|
+
}
|
|
5890
|
+
y2 += D2.length, A += w;
|
|
5891
|
+
}
|
|
5892
|
+
I2 = B2 = 0;
|
|
5893
|
+
}
|
|
5894
|
+
if (m >= h) break;
|
|
5895
|
+
if (at2.lastIndex = m, at2.test(t)) {
|
|
5896
|
+
if (y2 = at2.lastIndex - m, w = y2 * p, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / p))), A + w > i) {
|
|
5897
|
+
f = true;
|
|
5898
|
+
break;
|
|
5899
|
+
}
|
|
5900
|
+
A += w, I2 = $, B2 = m, m = $ = at2.lastIndex;
|
|
5901
|
+
continue;
|
|
5902
|
+
}
|
|
5903
|
+
if (At2.lastIndex = m, At2.test(t)) {
|
|
5904
|
+
if (A + u > S2 && (v = Math.min(v, m)), A + u > i) {
|
|
5905
|
+
f = true;
|
|
5906
|
+
break;
|
|
5907
|
+
}
|
|
5908
|
+
A += u, I2 = $, B2 = m, m = $ = At2.lastIndex;
|
|
5909
|
+
continue;
|
|
5910
|
+
}
|
|
5911
|
+
if (it2.lastIndex = m, it2.test(t)) {
|
|
5912
|
+
if (y2 = it2.lastIndex - m, w = y2 * l, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / l))), A + w > i) {
|
|
5913
|
+
f = true;
|
|
5914
|
+
break;
|
|
5915
|
+
}
|
|
5916
|
+
A += w, I2 = $, B2 = m, m = $ = it2.lastIndex;
|
|
5917
|
+
continue;
|
|
5918
|
+
}
|
|
5919
|
+
if (nt2.lastIndex = m, nt2.test(t)) {
|
|
5920
|
+
if (y2 = nt2.lastIndex - m, w = y2 * n, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / n))), A + w > i) {
|
|
5921
|
+
f = true;
|
|
5922
|
+
break;
|
|
5923
|
+
}
|
|
5924
|
+
A += w, I2 = $, B2 = m, m = $ = nt2.lastIndex;
|
|
5925
|
+
continue;
|
|
5926
|
+
}
|
|
5927
|
+
if (wt.lastIndex = m, wt.test(t)) {
|
|
5928
|
+
if (A + g > S2 && (v = Math.min(v, m)), A + g > i) {
|
|
5929
|
+
f = true;
|
|
5930
|
+
break;
|
|
5931
|
+
}
|
|
5932
|
+
A += g, I2 = $, B2 = m, m = $ = wt.lastIndex;
|
|
5933
|
+
continue;
|
|
5934
|
+
}
|
|
5935
|
+
m += 1;
|
|
5936
|
+
}
|
|
5937
|
+
return { width: f ? S2 : A, index: f ? v : h, truncated: f, ellipsed: f && i >= o };
|
|
5938
|
+
};
|
|
5939
|
+
var Ee = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
5940
|
+
var M2 = (t, r = {}) => jt(t, Ee, r).width;
|
|
5941
|
+
var ot2 = "\x1B";
|
|
5942
|
+
var Gt = "\x9B";
|
|
5943
|
+
var ve = 39;
|
|
5944
|
+
var Ct2 = "\x07";
|
|
5945
|
+
var kt2 = "[";
|
|
5946
|
+
var Ae = "]";
|
|
5947
|
+
var Vt2 = "m";
|
|
5948
|
+
var St = `${Ae}8;;`;
|
|
5949
|
+
var Ht = new RegExp(`(?:\\${kt2}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct2})`, "y");
|
|
5950
|
+
var we = (t) => {
|
|
5951
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
5952
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
5953
|
+
if (t === 1 || t === 2) return 22;
|
|
5954
|
+
if (t === 3) return 23;
|
|
5955
|
+
if (t === 4) return 24;
|
|
5956
|
+
if (t === 7) return 27;
|
|
5957
|
+
if (t === 8) return 28;
|
|
5958
|
+
if (t === 9) return 29;
|
|
5959
|
+
if (t === 0) return 0;
|
|
5960
|
+
};
|
|
5961
|
+
var Ut = (t) => `${ot2}${kt2}${t}${Vt2}`;
|
|
5962
|
+
var Kt = (t) => `${ot2}${St}${t}${Ct2}`;
|
|
5963
|
+
var Ce = (t) => t.map((r) => M2(r));
|
|
5964
|
+
var It2 = (t, r, s) => {
|
|
5965
|
+
const i = r[Symbol.iterator]();
|
|
5966
|
+
let a = false, o = false, u = t.at(-1), l = u === void 0 ? 0 : M2(u), n = i.next(), c = i.next(), g = 0;
|
|
5967
|
+
for (; !n.done; ) {
|
|
5968
|
+
const F = n.value, p = M2(F);
|
|
5969
|
+
l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot2 || F === Gt) && (a = true, o = r.startsWith(St, g + 1)), a ? o ? F === Ct2 && (a = false, o = false) : F === Vt2 && (a = false) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
|
|
5970
|
+
}
|
|
5971
|
+
u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
5972
|
+
};
|
|
5973
|
+
var Se = (t) => {
|
|
5974
|
+
const r = t.split(" ");
|
|
5975
|
+
let s = r.length;
|
|
5976
|
+
for (; s > 0 && !(M2(r[s - 1]) > 0); ) s--;
|
|
5977
|
+
return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
5978
|
+
};
|
|
5979
|
+
var Ie = (t, r, s = {}) => {
|
|
5980
|
+
if (s.trim !== false && t.trim() === "") return "";
|
|
5981
|
+
let i = "", a, o;
|
|
5982
|
+
const u = t.split(" "), l = Ce(u);
|
|
5983
|
+
let n = [""];
|
|
5984
|
+
for (const [$, m] of u.entries()) {
|
|
5985
|
+
s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
5986
|
+
let h = M2(n.at(-1) ?? "");
|
|
5987
|
+
if ($ !== 0 && (h >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), h = 0), (h > 0 || s.trim === false) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
|
|
5988
|
+
const y2 = r - h, f = 1 + Math.floor((l[$] - y2 - 1) / r);
|
|
5989
|
+
Math.floor((l[$] - 1) / r) < f && n.push(""), It2(n, m, r);
|
|
5990
|
+
continue;
|
|
5991
|
+
}
|
|
5992
|
+
if (h + l[$] > r && h > 0 && l[$] > 0) {
|
|
5993
|
+
if (s.wordWrap === false && h < r) {
|
|
5994
|
+
It2(n, m, r);
|
|
5995
|
+
continue;
|
|
5996
|
+
}
|
|
5997
|
+
n.push("");
|
|
5998
|
+
}
|
|
5999
|
+
if (h + l[$] > r && s.wordWrap === false) {
|
|
6000
|
+
It2(n, m, r);
|
|
6001
|
+
continue;
|
|
6002
|
+
}
|
|
6003
|
+
n[n.length - 1] += m;
|
|
6004
|
+
}
|
|
6005
|
+
s.trim !== false && (n = n.map(($) => Se($)));
|
|
6006
|
+
const c = n.join(`
|
|
6007
|
+
`), g = c[Symbol.iterator]();
|
|
6008
|
+
let F = g.next(), p = g.next(), E = 0;
|
|
6009
|
+
for (; !F.done; ) {
|
|
6010
|
+
const $ = F.value, m = p.value;
|
|
6011
|
+
if (i += $, $ === ot2 || $ === Gt) {
|
|
6012
|
+
Ht.lastIndex = E + 1;
|
|
6013
|
+
const f = Ht.exec(c)?.groups;
|
|
6014
|
+
if (f?.code !== void 0) {
|
|
6015
|
+
const v = Number.parseFloat(f.code);
|
|
6016
|
+
a = v === ve ? void 0 : v;
|
|
6017
|
+
} else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
|
|
6018
|
+
}
|
|
6019
|
+
const h = a ? we(a) : void 0;
|
|
6020
|
+
m === `
|
|
6021
|
+
` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
|
|
6022
|
+
` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
|
|
6023
|
+
}
|
|
6024
|
+
return i;
|
|
6025
|
+
};
|
|
6026
|
+
function J2(t, r, s) {
|
|
6027
|
+
return String(t).normalize().replaceAll(`\r
|
|
6028
|
+
`, `
|
|
6029
|
+
`).split(`
|
|
6030
|
+
`).map((i) => Ie(i, r, s)).join(`
|
|
6031
|
+
`);
|
|
6032
|
+
}
|
|
6033
|
+
var be = (t, r, s, i, a) => {
|
|
6034
|
+
let o = r, u = 0;
|
|
6035
|
+
for (let l = s; l < i; l++) {
|
|
6036
|
+
const n = t[l];
|
|
6037
|
+
if (o = o - n.length, u++, o <= a) break;
|
|
6038
|
+
}
|
|
6039
|
+
return { lineCount: o, removals: u };
|
|
6040
|
+
};
|
|
6041
|
+
var X2 = (t) => {
|
|
6042
|
+
const { cursor: r, options: s, style: i } = t, a = t.output ?? process.stdout, o = rt(a), u = t.columnPadding ?? 0, l = t.rowPadding ?? 4, n = o - u, c = nt(a), g = import_picocolors2.default.dim("..."), F = t.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(c - l, 0), E = Math.max(Math.min(F, p), 5);
|
|
6043
|
+
let $ = 0;
|
|
6044
|
+
r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
|
|
6045
|
+
let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
|
|
6046
|
+
const y2 = Math.min($ + E, s.length), f = [];
|
|
6047
|
+
let v = 0;
|
|
6048
|
+
m && v++, h && v++;
|
|
6049
|
+
const S2 = $ + (m ? 1 : 0), I2 = y2 - (h ? 1 : 0);
|
|
6050
|
+
for (let A = S2; A < I2; A++) {
|
|
6051
|
+
const w = J2(i(s[A], A === r), n, { hard: true, trim: false }).split(`
|
|
6052
|
+
`);
|
|
6053
|
+
f.push(w), v += w.length;
|
|
6054
|
+
}
|
|
6055
|
+
if (v > p) {
|
|
6056
|
+
let A = 0, w = 0, _2 = v;
|
|
6057
|
+
const D2 = r - S2, T2 = (Y, L2) => be(f, _2, Y, L2, p);
|
|
6058
|
+
m ? ({ lineCount: _2, removals: A } = T2(0, D2), _2 > p && ({ lineCount: _2, removals: w } = T2(D2 + 1, f.length))) : ({ lineCount: _2, removals: w } = T2(D2 + 1, f.length), _2 > p && ({ lineCount: _2, removals: A } = T2(0, D2))), A > 0 && (m = true, f.splice(0, A)), w > 0 && (h = true, f.splice(f.length - w, w));
|
|
6059
|
+
}
|
|
6060
|
+
const B2 = [];
|
|
6061
|
+
m && B2.push(g);
|
|
6062
|
+
for (const A of f) for (const w of A) B2.push(w);
|
|
6063
|
+
return h && B2.push(g), B2;
|
|
6064
|
+
};
|
|
6065
|
+
var Re = (t) => {
|
|
6066
|
+
const r = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
6067
|
+
return new kt({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
|
|
6068
|
+
const i = t.withGuide ?? _.withGuide, a = `${i ? `${import_picocolors2.default.gray(d)}
|
|
6069
|
+
` : ""}${W2(this.state)} ${t.message}
|
|
6070
|
+
`, o = this.value ? r : s;
|
|
6071
|
+
switch (this.state) {
|
|
6072
|
+
case "submit": {
|
|
6073
|
+
const u = i ? `${import_picocolors2.default.gray(d)} ` : "";
|
|
6074
|
+
return `${a}${u}${import_picocolors2.default.dim(o)}`;
|
|
6075
|
+
}
|
|
6076
|
+
case "cancel": {
|
|
6077
|
+
const u = i ? `${import_picocolors2.default.gray(d)} ` : "";
|
|
6078
|
+
return `${a}${u}${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o))}${i ? `
|
|
6079
|
+
${import_picocolors2.default.gray(d)}` : ""}`;
|
|
6080
|
+
}
|
|
6081
|
+
default: {
|
|
6082
|
+
const u = i ? `${import_picocolors2.default.cyan(d)} ` : "", l = i ? import_picocolors2.default.cyan(x2) : "";
|
|
6083
|
+
return `${a}${u}${this.value ? `${import_picocolors2.default.green(Q2)} ${r}` : `${import_picocolors2.default.dim(H2)} ${import_picocolors2.default.dim(r)}`}${t.vertical ? i ? `
|
|
6084
|
+
${import_picocolors2.default.cyan(d)} ` : `
|
|
6085
|
+
` : ` ${import_picocolors2.default.dim("/")} `}${this.value ? `${import_picocolors2.default.dim(H2)} ${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.green(Q2)} ${s}`}
|
|
6086
|
+
${l}
|
|
6087
|
+
`;
|
|
6088
|
+
}
|
|
6089
|
+
}
|
|
6090
|
+
} }).prompt();
|
|
6091
|
+
};
|
|
6092
|
+
var Ne = (t = "", r) => {
|
|
6093
|
+
(process.stdout).write(`${import_picocolors2.default.gray(x2)} ${import_picocolors2.default.red(t)}
|
|
6094
|
+
|
|
6095
|
+
`);
|
|
6096
|
+
};
|
|
6097
|
+
var We = (t = "", r) => {
|
|
6098
|
+
(process.stdout).write(`${import_picocolors2.default.gray(ht2)} ${t}
|
|
6099
|
+
`);
|
|
6100
|
+
};
|
|
6101
|
+
var Le = (t = "", r) => {
|
|
6102
|
+
(process.stdout).write(`${import_picocolors2.default.gray(d)}
|
|
6103
|
+
${import_picocolors2.default.gray(x2)} ${t}
|
|
6104
|
+
|
|
6105
|
+
`);
|
|
6106
|
+
};
|
|
6107
|
+
var Ge = (t) => import_picocolors2.default.dim(t);
|
|
6108
|
+
var ke = (t, r, s) => {
|
|
6109
|
+
const i = { hard: true, trim: false }, a = J2(t, r, i).split(`
|
|
6110
|
+
`), o = a.reduce((n, c) => Math.max(M2(c), n), 0), u = a.map(s).reduce((n, c) => Math.max(M2(c), n), 0), l = r - (u - o);
|
|
6111
|
+
return J2(t, l, i);
|
|
6112
|
+
};
|
|
6113
|
+
var Ve = (t = "", r = "", s) => {
|
|
6114
|
+
const i = N2.stdout, o = Ge, u = ["", ...ke(t, rt(i) - 6, o).split(`
|
|
6115
|
+
`).map(o), ""], l = M2(r), n = Math.max(u.reduce((p, E) => {
|
|
6116
|
+
const $ = M2(E);
|
|
6117
|
+
return $ > p ? $ : p;
|
|
6118
|
+
}, 0), l) + 2, c = u.map((p) => `${import_picocolors2.default.gray(d)} ${p}${" ".repeat(n - M2(p))}${import_picocolors2.default.gray(d)}`).join(`
|
|
6119
|
+
`), g = `${import_picocolors2.default.gray(d)}
|
|
6120
|
+
` , F = Wt2 ;
|
|
6121
|
+
i.write(`${g}${import_picocolors2.default.green(V)} ${import_picocolors2.default.reset(r)} ${import_picocolors2.default.gray(rt2.repeat(Math.max(n - l - 1, 1)) + mt2)}
|
|
6122
|
+
${c}
|
|
6123
|
+
${import_picocolors2.default.gray(F + rt2.repeat(n + 2) + pt2)}
|
|
6124
|
+
`);
|
|
6125
|
+
};
|
|
6126
|
+
import_picocolors2.default.magenta;
|
|
6127
|
+
var lt2 = (t, r) => t.includes(`
|
|
6128
|
+
`) ? t.split(`
|
|
6129
|
+
`).map((s) => r(s)).join(`
|
|
6130
|
+
`) : r(t);
|
|
6131
|
+
var Je = (t) => {
|
|
6132
|
+
const r = (s, i) => {
|
|
6133
|
+
const a = s.label ?? String(s.value);
|
|
6134
|
+
switch (i) {
|
|
6135
|
+
case "disabled":
|
|
6136
|
+
return `${import_picocolors2.default.gray(H2)} ${lt2(a, import_picocolors2.default.gray)}${s.hint ? ` ${import_picocolors2.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
6137
|
+
case "selected":
|
|
6138
|
+
return `${lt2(a, import_picocolors2.default.dim)}`;
|
|
6139
|
+
case "active":
|
|
6140
|
+
return `${import_picocolors2.default.green(Q2)} ${a}${s.hint ? ` ${import_picocolors2.default.dim(`(${s.hint})`)}` : ""}`;
|
|
6141
|
+
case "cancelled":
|
|
6142
|
+
return `${lt2(a, (o) => import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o)))}`;
|
|
6143
|
+
default:
|
|
6144
|
+
return `${import_picocolors2.default.dim(H2)} ${lt2(a, import_picocolors2.default.dim)}`;
|
|
6145
|
+
}
|
|
6146
|
+
};
|
|
6147
|
+
return new Wt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
6148
|
+
const s = t.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${vt2(this.state)} `, o = xt(t.output, t.message, a, i), u = `${s ? `${import_picocolors2.default.gray(d)}
|
|
6149
|
+
` : ""}${o}
|
|
6150
|
+
`;
|
|
6151
|
+
switch (this.state) {
|
|
6152
|
+
case "submit": {
|
|
6153
|
+
const l = s ? `${import_picocolors2.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "selected"), l);
|
|
6154
|
+
return `${u}${n}`;
|
|
6155
|
+
}
|
|
6156
|
+
case "cancel": {
|
|
6157
|
+
const l = s ? `${import_picocolors2.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "cancelled"), l);
|
|
6158
|
+
return `${u}${n}${s ? `
|
|
6159
|
+
${import_picocolors2.default.gray(d)}` : ""}`;
|
|
6160
|
+
}
|
|
6161
|
+
default: {
|
|
6162
|
+
const l = s ? `${import_picocolors2.default.cyan(d)} ` : "", n = s ? import_picocolors2.default.cyan(x2) : "", c = u.split(`
|
|
6163
|
+
`).length, g = s ? 2 : 1;
|
|
6164
|
+
return `${u}${l}${X2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: l.length, rowPadding: c + g, style: (F, p) => r(F, F.disabled ? "disabled" : p ? "active" : "inactive") }).join(`
|
|
6165
|
+
${l}`)}
|
|
6166
|
+
${n}
|
|
6167
|
+
`;
|
|
6168
|
+
}
|
|
6169
|
+
}
|
|
6170
|
+
} }).prompt();
|
|
6171
|
+
};
|
|
6172
|
+
`${import_picocolors2.default.gray(d)} `;
|
|
6173
|
+
var Ze = (t) => new $t({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
6174
|
+
const r = t?.withGuide ?? _.withGuide, s = `${`${r ? `${import_picocolors2.default.gray(d)}
|
|
6175
|
+
` : ""}${W2(this.state)} `}${t.message}
|
|
6176
|
+
`, i = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), a = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
|
|
6177
|
+
switch (this.state) {
|
|
6178
|
+
case "error": {
|
|
6179
|
+
const u = this.error ? ` ${import_picocolors2.default.yellow(this.error)}` : "", l = r ? `${import_picocolors2.default.yellow(d)} ` : "", n = r ? import_picocolors2.default.yellow(x2) : "";
|
|
6180
|
+
return `${s.trim()}
|
|
6181
|
+
${l}${a}
|
|
6182
|
+
${n}${u}
|
|
6183
|
+
`;
|
|
6184
|
+
}
|
|
6185
|
+
case "submit": {
|
|
6186
|
+
const u = o ? ` ${import_picocolors2.default.dim(o)}` : "", l = r ? import_picocolors2.default.gray(d) : "";
|
|
6187
|
+
return `${s}${l}${u}`;
|
|
6188
|
+
}
|
|
6189
|
+
case "cancel": {
|
|
6190
|
+
const u = o ? ` ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(o))}` : "", l = r ? import_picocolors2.default.gray(d) : "";
|
|
6191
|
+
return `${s}${l}${u}${o.trim() ? `
|
|
6192
|
+
${l}` : ""}`;
|
|
6193
|
+
}
|
|
6194
|
+
default: {
|
|
6195
|
+
const u = r ? `${import_picocolors2.default.cyan(d)} ` : "", l = r ? import_picocolors2.default.cyan(x2) : "";
|
|
6196
|
+
return `${s}${u}${a}
|
|
6197
|
+
${l}
|
|
6198
|
+
`;
|
|
6199
|
+
}
|
|
6200
|
+
}
|
|
6201
|
+
} }).prompt();
|
|
6202
|
+
var PROJECT_REPO = "https://github.com/BytePioneer-AI/moltbot-china";
|
|
6203
|
+
var GUIDES_BASE = "https://github.com/BytePioneer-AI/openclaw-china/tree/main/doc/guides";
|
|
6204
|
+
var OPENCLAW_HOME = join(homedir(), ".openclaw");
|
|
6205
|
+
var DEFAULT_PLUGIN_PATH = join(OPENCLAW_HOME, "extensions");
|
|
6206
|
+
var LEGACY_PLUGIN_PATH = join(OPENCLAW_HOME, "plugins");
|
|
6207
|
+
var CONFIG_FILE_PATH = join(OPENCLAW_HOME, "openclaw.json");
|
|
6208
|
+
var ANSI_RESET = "\x1B[0m";
|
|
6209
|
+
var ANSI_LINK = "\x1B[1;4;96m";
|
|
6210
|
+
var ANSI_BORDER = "\x1B[92m";
|
|
6211
|
+
var CHANNEL_ORDER = [
|
|
6212
|
+
"dingtalk",
|
|
6213
|
+
"qqbot",
|
|
6214
|
+
"wecom",
|
|
6215
|
+
"wecom-app",
|
|
6216
|
+
"feishu-china"
|
|
6217
|
+
];
|
|
6218
|
+
var CHANNEL_DISPLAY_LABELS = {
|
|
6219
|
+
dingtalk: "DingTalk\uFF08\u9489\u9489\uFF09",
|
|
6220
|
+
"feishu-china": "Feishu\uFF08\u98DE\u4E66\uFF09",
|
|
6221
|
+
wecom: "WeCom\uFF08\u4F01\u4E1A\u5FAE\u4FE1-\u667A\u80FD\u673A\u5668\u4EBA\uFF09",
|
|
6222
|
+
"wecom-app": "WeCom App\uFF08\u81EA\u5EFA\u5E94\u7528-\u53EF\u63A5\u5165\u5FAE\u4FE1\uFF09",
|
|
6223
|
+
qqbot: "QQBot\uFF08QQ \u673A\u5668\u4EBA\uFF09"
|
|
6224
|
+
};
|
|
6225
|
+
var CHANNEL_GUIDE_LINKS = {
|
|
6226
|
+
dingtalk: `${GUIDES_BASE}/dingtalk/configuration.md`,
|
|
6227
|
+
"feishu-china": "https://github.com/BytePioneer-AI/openclaw-china/blob/main/README.md",
|
|
6228
|
+
wecom: `${GUIDES_BASE}/wecom/configuration.md`,
|
|
6229
|
+
"wecom-app": `${GUIDES_BASE}/wecom-app/configuration.md`,
|
|
6230
|
+
qqbot: `${GUIDES_BASE}/qqbot/configuration.md`
|
|
6231
|
+
};
|
|
6232
|
+
var CHINA_CLI_STATE_KEY = /* @__PURE__ */ Symbol.for("@openclaw-china/china-cli-state");
|
|
6233
|
+
var PromptCancelledError = class extends Error {
|
|
6234
|
+
constructor() {
|
|
6235
|
+
super("prompt-cancelled");
|
|
6236
|
+
}
|
|
6237
|
+
};
|
|
6238
|
+
function isChannelId(value) {
|
|
6239
|
+
return typeof value === "string" && CHANNEL_ORDER.includes(value);
|
|
6240
|
+
}
|
|
6241
|
+
function getChinaCliState() {
|
|
6242
|
+
const root = globalThis;
|
|
6243
|
+
const cached = root[CHINA_CLI_STATE_KEY];
|
|
6244
|
+
if (isRecord(cached)) {
|
|
6245
|
+
const channels = cached.channels;
|
|
6246
|
+
const cliRegistered = cached.cliRegistered;
|
|
6247
|
+
if (channels instanceof Set && typeof cliRegistered === "boolean") {
|
|
6248
|
+
return {
|
|
6249
|
+
channels,
|
|
6250
|
+
cliRegistered
|
|
6251
|
+
};
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6254
|
+
const created = {
|
|
6255
|
+
channels: /* @__PURE__ */ new Set(),
|
|
6256
|
+
cliRegistered: false
|
|
6257
|
+
};
|
|
6258
|
+
root[CHINA_CLI_STATE_KEY] = created;
|
|
6259
|
+
return created;
|
|
6260
|
+
}
|
|
6261
|
+
function normalizeChannels(channels) {
|
|
6262
|
+
const selected = channels && channels.length > 0 ? channels : CHANNEL_ORDER;
|
|
6263
|
+
const unique = /* @__PURE__ */ new Set();
|
|
6264
|
+
for (const channelId of selected) {
|
|
6265
|
+
if (isChannelId(channelId)) {
|
|
6266
|
+
unique.add(channelId);
|
|
6267
|
+
}
|
|
6268
|
+
}
|
|
6269
|
+
return CHANNEL_ORDER.filter((channelId) => unique.has(channelId));
|
|
6270
|
+
}
|
|
6271
|
+
function getInstalledChannels(state) {
|
|
6272
|
+
return CHANNEL_ORDER.filter((channelId) => state.channels.has(channelId));
|
|
6273
|
+
}
|
|
6274
|
+
function guardCancel(value) {
|
|
6275
|
+
if (Ct(value)) {
|
|
6276
|
+
Ne("\u5DF2\u53D6\u6D88\u914D\u7F6E\u3002");
|
|
6277
|
+
throw new PromptCancelledError();
|
|
6278
|
+
}
|
|
6279
|
+
return value;
|
|
6280
|
+
}
|
|
6281
|
+
function warn(text) {
|
|
6282
|
+
stdout.write(`
|
|
6283
|
+
[warn] ${text}
|
|
6284
|
+
`);
|
|
6285
|
+
}
|
|
6286
|
+
function section(title) {
|
|
6287
|
+
stdout.write(`
|
|
6288
|
+
${title}
|
|
6289
|
+
`);
|
|
6290
|
+
}
|
|
6291
|
+
function resolvePluginPath() {
|
|
6292
|
+
if (existsSync(DEFAULT_PLUGIN_PATH)) {
|
|
6293
|
+
return DEFAULT_PLUGIN_PATH;
|
|
6294
|
+
}
|
|
6295
|
+
if (existsSync(LEGACY_PLUGIN_PATH)) {
|
|
6296
|
+
return LEGACY_PLUGIN_PATH;
|
|
6297
|
+
}
|
|
6298
|
+
return DEFAULT_PLUGIN_PATH;
|
|
6299
|
+
}
|
|
6300
|
+
function renderReadyMessage() {
|
|
6301
|
+
return [
|
|
6302
|
+
`${ANSI_BORDER}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${ANSI_RESET}`,
|
|
6303
|
+
" OpenClaw China Channels \u5DF2\u5C31\u7EEA!",
|
|
6304
|
+
`${ANSI_BORDER}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${ANSI_RESET}`,
|
|
6305
|
+
"",
|
|
6306
|
+
"\u63D2\u4EF6\u8DEF\u5F84:",
|
|
6307
|
+
` ${resolvePluginPath()}`,
|
|
6308
|
+
"",
|
|
6309
|
+
"\u914D\u7F6E\u6587\u4EF6:",
|
|
6310
|
+
` ${CONFIG_FILE_PATH}`,
|
|
6311
|
+
"",
|
|
6312
|
+
"\u66F4\u65B0\u63D2\u4EF6:",
|
|
6313
|
+
" openclaw plugins update <plugin-id>",
|
|
6314
|
+
"",
|
|
6315
|
+
"\u9879\u76EE\u4ED3\u5E93:",
|
|
6316
|
+
` ${ANSI_LINK}${PROJECT_REPO}${ANSI_RESET}`,
|
|
6317
|
+
"",
|
|
6318
|
+
"\u2B50 \u5982\u679C\u8FD9\u4E2A\u9879\u76EE\u5BF9\u4F60\u6709\u5E2E\u52A9\uFF0C\u8BF7\u7ED9\u6211\u4EEC\u4E00\u4E2A Star\uFF01\u2B50",
|
|
6319
|
+
"",
|
|
6320
|
+
"\u4E0B\u4E00\u6B65:",
|
|
6321
|
+
" openclaw gateway --port 18789 --verbose",
|
|
6322
|
+
""
|
|
6323
|
+
].join("\n");
|
|
6324
|
+
}
|
|
6325
|
+
function showReadyMessage() {
|
|
6326
|
+
stdout.write(`
|
|
6327
|
+
${renderReadyMessage()}
|
|
6328
|
+
`);
|
|
6329
|
+
}
|
|
6330
|
+
function showGuideLink(channelId) {
|
|
6331
|
+
const url = CHANNEL_GUIDE_LINKS[channelId];
|
|
6332
|
+
Ve(`\u914D\u7F6E\u6587\u6863\uFF1A${url}`, "Docs");
|
|
6333
|
+
}
|
|
6334
|
+
function isRecord(value) {
|
|
6335
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6336
|
+
}
|
|
6337
|
+
function resolveWriteConfig(runtime2) {
|
|
6338
|
+
if (!isRecord(runtime2)) {
|
|
6339
|
+
return void 0;
|
|
6340
|
+
}
|
|
6341
|
+
const config = runtime2.config;
|
|
6342
|
+
if (!isRecord(config)) {
|
|
6343
|
+
return void 0;
|
|
6344
|
+
}
|
|
6345
|
+
if (typeof config.writeConfigFile !== "function") {
|
|
6346
|
+
return void 0;
|
|
6347
|
+
}
|
|
6348
|
+
return config.writeConfigFile;
|
|
6349
|
+
}
|
|
6350
|
+
function isCommandLike(value) {
|
|
6351
|
+
if (!isRecord(value)) {
|
|
6352
|
+
return false;
|
|
6353
|
+
}
|
|
6354
|
+
return typeof value.command === "function" && typeof value.description === "function" && typeof value.action === "function";
|
|
6355
|
+
}
|
|
6356
|
+
function toTrimmedString(value) {
|
|
6357
|
+
if (typeof value !== "string") {
|
|
6358
|
+
return void 0;
|
|
6359
|
+
}
|
|
6360
|
+
const trimmed = value.trim();
|
|
6361
|
+
return trimmed || void 0;
|
|
6362
|
+
}
|
|
6363
|
+
function hasNonEmptyString(value) {
|
|
6364
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
6365
|
+
}
|
|
6366
|
+
function toBoolean(value, fallback) {
|
|
6367
|
+
return typeof value === "boolean" ? value : fallback;
|
|
6368
|
+
}
|
|
6369
|
+
function toNumber(value) {
|
|
6370
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
6371
|
+
}
|
|
6372
|
+
function cloneConfig(cfg) {
|
|
6373
|
+
try {
|
|
6374
|
+
return structuredClone(cfg);
|
|
6375
|
+
} catch {
|
|
6376
|
+
return JSON.parse(JSON.stringify(cfg));
|
|
6377
|
+
}
|
|
6378
|
+
}
|
|
6379
|
+
function getChannelConfig(cfg, channelId) {
|
|
6380
|
+
const channels = isRecord(cfg.channels) ? cfg.channels : {};
|
|
6381
|
+
const existing = channels[channelId];
|
|
6382
|
+
return isRecord(existing) ? existing : {};
|
|
6383
|
+
}
|
|
6384
|
+
function getPreferredAccountConfig(channelCfg) {
|
|
6385
|
+
const accounts = channelCfg.accounts;
|
|
6386
|
+
if (!isRecord(accounts)) {
|
|
6387
|
+
return void 0;
|
|
6388
|
+
}
|
|
6389
|
+
const defaultAccountId = toTrimmedString(channelCfg.defaultAccount);
|
|
6390
|
+
if (defaultAccountId) {
|
|
6391
|
+
const preferred = accounts[defaultAccountId];
|
|
6392
|
+
if (isRecord(preferred)) {
|
|
6393
|
+
return preferred;
|
|
6394
|
+
}
|
|
6395
|
+
}
|
|
6396
|
+
for (const value of Object.values(accounts)) {
|
|
6397
|
+
if (isRecord(value)) {
|
|
6398
|
+
return value;
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
return void 0;
|
|
6402
|
+
}
|
|
6403
|
+
function hasTokenPair(channelCfg) {
|
|
6404
|
+
if (hasNonEmptyString(channelCfg.token) && hasNonEmptyString(channelCfg.encodingAESKey)) {
|
|
6405
|
+
return true;
|
|
6406
|
+
}
|
|
6407
|
+
const accountCfg = getPreferredAccountConfig(channelCfg);
|
|
6408
|
+
return Boolean(
|
|
6409
|
+
accountCfg && hasNonEmptyString(accountCfg.token) && hasNonEmptyString(accountCfg.encodingAESKey)
|
|
6410
|
+
);
|
|
6411
|
+
}
|
|
6412
|
+
function isChannelConfigured(cfg, channelId) {
|
|
6413
|
+
const channelCfg = getChannelConfig(cfg, channelId);
|
|
6414
|
+
switch (channelId) {
|
|
6415
|
+
case "dingtalk":
|
|
6416
|
+
return hasNonEmptyString(channelCfg.clientId) && hasNonEmptyString(channelCfg.clientSecret);
|
|
6417
|
+
case "feishu-china":
|
|
6418
|
+
return hasNonEmptyString(channelCfg.appId) && hasNonEmptyString(channelCfg.appSecret);
|
|
6419
|
+
case "qqbot":
|
|
6420
|
+
return hasNonEmptyString(channelCfg.appId) && hasNonEmptyString(channelCfg.clientSecret);
|
|
6421
|
+
case "wecom":
|
|
6422
|
+
case "wecom-app":
|
|
6423
|
+
return hasTokenPair(channelCfg);
|
|
6424
|
+
default:
|
|
6425
|
+
return false;
|
|
6426
|
+
}
|
|
6427
|
+
}
|
|
6428
|
+
function withConfiguredSuffix(cfg, channelId) {
|
|
6429
|
+
const base = CHANNEL_DISPLAY_LABELS[channelId];
|
|
6430
|
+
return isChannelConfigured(cfg, channelId) ? `${base}\uFF08\u5DF2\u914D\u7F6E\uFF09` : base;
|
|
6431
|
+
}
|
|
6432
|
+
function mergeChannelConfig(cfg, channelId, patch) {
|
|
6433
|
+
const channels = isRecord(cfg.channels) ? { ...cfg.channels } : {};
|
|
6434
|
+
const existing = getChannelConfig(cfg, channelId);
|
|
6435
|
+
channels[channelId] = {
|
|
6436
|
+
...existing,
|
|
6437
|
+
...patch,
|
|
6438
|
+
enabled: true
|
|
6439
|
+
};
|
|
6440
|
+
return {
|
|
6441
|
+
...cfg,
|
|
6442
|
+
channels
|
|
6443
|
+
};
|
|
6444
|
+
}
|
|
6445
|
+
var SetupPrompter = class {
|
|
6446
|
+
async askText(params) {
|
|
6447
|
+
const { label, required = false, defaultValue } = params;
|
|
6448
|
+
while (true) {
|
|
6449
|
+
const value = String(
|
|
6450
|
+
guardCancel(
|
|
6451
|
+
await Ze({
|
|
6452
|
+
message: label,
|
|
6453
|
+
initialValue: defaultValue
|
|
6454
|
+
})
|
|
6455
|
+
)
|
|
6456
|
+
).trim();
|
|
6457
|
+
if (value) {
|
|
6458
|
+
return value;
|
|
6459
|
+
}
|
|
6460
|
+
if (defaultValue) {
|
|
6461
|
+
return defaultValue;
|
|
6462
|
+
}
|
|
6463
|
+
if (!required) {
|
|
6464
|
+
return "";
|
|
6465
|
+
}
|
|
6466
|
+
warn("\u8BE5\u5B57\u6BB5\u4E3A\u5FC5\u586B\u9879\u3002");
|
|
6467
|
+
}
|
|
6468
|
+
}
|
|
6469
|
+
async askSecret(params) {
|
|
6470
|
+
const { label, existingValue, required = true } = params;
|
|
6471
|
+
return this.askText({
|
|
6472
|
+
label,
|
|
6473
|
+
required,
|
|
6474
|
+
defaultValue: existingValue
|
|
6475
|
+
});
|
|
6476
|
+
}
|
|
6477
|
+
async askConfirm(label, defaultValue = true) {
|
|
6478
|
+
return Boolean(
|
|
6479
|
+
guardCancel(
|
|
6480
|
+
await Re({
|
|
6481
|
+
message: label,
|
|
6482
|
+
initialValue: defaultValue
|
|
6483
|
+
})
|
|
6484
|
+
)
|
|
6485
|
+
);
|
|
6486
|
+
}
|
|
6487
|
+
async askNumber(params) {
|
|
6488
|
+
const { label, min, defaultValue } = params;
|
|
6489
|
+
while (true) {
|
|
6490
|
+
const raw = String(
|
|
6491
|
+
guardCancel(
|
|
6492
|
+
await Ze({
|
|
6493
|
+
message: label,
|
|
6494
|
+
initialValue: defaultValue !== void 0 ? String(defaultValue) : void 0
|
|
6495
|
+
})
|
|
6496
|
+
)
|
|
6497
|
+
).trim();
|
|
6498
|
+
const parsed = Number.parseInt(raw, 10);
|
|
6499
|
+
if (Number.isFinite(parsed) && (min === void 0 || parsed >= min)) {
|
|
6500
|
+
return parsed;
|
|
6501
|
+
}
|
|
6502
|
+
warn(`\u8BF7\u8F93\u5165\u6709\u6548\u6574\u6570${min !== void 0 ? `\uFF08>= ${min}\uFF09` : ""}\u3002`);
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
async askSelect(message, options, defaultValue) {
|
|
6506
|
+
const initial = options.some((opt) => opt.value === defaultValue) ? defaultValue : options[0]?.value;
|
|
6507
|
+
const selectOptions = options.map((option) => ({
|
|
6508
|
+
value: option.value,
|
|
6509
|
+
label: option.label
|
|
6510
|
+
}));
|
|
6511
|
+
return guardCancel(
|
|
6512
|
+
await Je({
|
|
6513
|
+
message,
|
|
6514
|
+
options: selectOptions,
|
|
6515
|
+
initialValue: initial
|
|
6516
|
+
})
|
|
6517
|
+
);
|
|
6518
|
+
}
|
|
6519
|
+
};
|
|
6520
|
+
async function configureDingtalk(prompter, cfg) {
|
|
6521
|
+
section("\u914D\u7F6E DingTalk\uFF08\u9489\u9489\uFF09");
|
|
6522
|
+
showGuideLink("dingtalk");
|
|
6523
|
+
const existing = getChannelConfig(cfg, "dingtalk");
|
|
6524
|
+
const clientId = await prompter.askText({
|
|
6525
|
+
label: "DingTalk clientId\uFF08AppKey\uFF09",
|
|
6526
|
+
defaultValue: toTrimmedString(existing.clientId),
|
|
6527
|
+
required: true
|
|
6528
|
+
});
|
|
6529
|
+
const clientSecret = await prompter.askSecret({
|
|
6530
|
+
label: "DingTalk clientSecret\uFF08AppSecret\uFF09",
|
|
6531
|
+
existingValue: toTrimmedString(existing.clientSecret),
|
|
6532
|
+
required: true
|
|
6533
|
+
});
|
|
6534
|
+
const enableAICard = await prompter.askConfirm(
|
|
6535
|
+
"\u542F\u7528 AI Card \u6D41\u5F0F\u56DE\u590D\uFF08\u63A8\u8350\u5173\u95ED\uFF0C\u4F7F\u7528\u975E\u6D41\u5F0F\uFF09",
|
|
6536
|
+
toBoolean(existing.enableAICard, false)
|
|
6537
|
+
);
|
|
6538
|
+
return mergeChannelConfig(cfg, "dingtalk", {
|
|
6539
|
+
clientId,
|
|
6540
|
+
clientSecret,
|
|
6541
|
+
enableAICard
|
|
6542
|
+
});
|
|
6543
|
+
}
|
|
6544
|
+
async function configureFeishu(prompter, cfg) {
|
|
6545
|
+
section("\u914D\u7F6E Feishu\uFF08\u98DE\u4E66\uFF09");
|
|
6546
|
+
showGuideLink("feishu-china");
|
|
6547
|
+
const existing = getChannelConfig(cfg, "feishu-china");
|
|
6548
|
+
const appId = await prompter.askText({
|
|
6549
|
+
label: "Feishu appId",
|
|
6550
|
+
defaultValue: toTrimmedString(existing.appId),
|
|
6551
|
+
required: true
|
|
6552
|
+
});
|
|
6553
|
+
const appSecret = await prompter.askSecret({
|
|
6554
|
+
label: "Feishu appSecret",
|
|
6555
|
+
existingValue: toTrimmedString(existing.appSecret),
|
|
6556
|
+
required: true
|
|
6557
|
+
});
|
|
6558
|
+
const sendMarkdownAsCard = await prompter.askConfirm(
|
|
6559
|
+
"\u4EE5\u5361\u7247\u5F62\u5F0F\u53D1\u9001 Markdown",
|
|
6560
|
+
toBoolean(existing.sendMarkdownAsCard, true)
|
|
6561
|
+
);
|
|
6562
|
+
return mergeChannelConfig(cfg, "feishu-china", {
|
|
6563
|
+
appId,
|
|
6564
|
+
appSecret,
|
|
6565
|
+
sendMarkdownAsCard
|
|
6566
|
+
});
|
|
6567
|
+
}
|
|
6568
|
+
async function configureWecom(prompter, cfg) {
|
|
6569
|
+
section("\u914D\u7F6E WeCom\uFF08\u4F01\u4E1A\u5FAE\u4FE1-\u667A\u80FD\u673A\u5668\u4EBA\uFF09");
|
|
6570
|
+
showGuideLink("wecom");
|
|
6571
|
+
const existing = getChannelConfig(cfg, "wecom");
|
|
6572
|
+
const webhookPath = await prompter.askText({
|
|
6573
|
+
label: "Webhook \u8DEF\u5F84\uFF08\u9700\u4E0E\u4F01\u4E1A\u5FAE\u4FE1\u540E\u53F0\u914D\u7F6E\u4E00\u81F4\uFF0C\u9ED8\u8BA4 /wecom\uFF09",
|
|
6574
|
+
defaultValue: toTrimmedString(existing.webhookPath) ?? "/wecom",
|
|
6575
|
+
required: true
|
|
6576
|
+
});
|
|
6577
|
+
const token = await prompter.askSecret({
|
|
6578
|
+
label: "WeCom token",
|
|
6579
|
+
existingValue: toTrimmedString(existing.token),
|
|
6580
|
+
required: true
|
|
6581
|
+
});
|
|
6582
|
+
const encodingAESKey = await prompter.askSecret({
|
|
6583
|
+
label: "WeCom encodingAESKey",
|
|
6584
|
+
existingValue: toTrimmedString(existing.encodingAESKey),
|
|
6585
|
+
required: true
|
|
6586
|
+
});
|
|
6587
|
+
return mergeChannelConfig(cfg, "wecom", {
|
|
6588
|
+
webhookPath,
|
|
6589
|
+
token,
|
|
6590
|
+
encodingAESKey
|
|
6591
|
+
});
|
|
6592
|
+
}
|
|
6593
|
+
async function configureWecomApp(prompter, cfg) {
|
|
6594
|
+
section("\u914D\u7F6E WeCom App\uFF08\u81EA\u5EFA\u5E94\u7528-\u53EF\u63A5\u5165\u5FAE\u4FE1\uFF09");
|
|
6595
|
+
showGuideLink("wecom-app");
|
|
6596
|
+
const existing = getChannelConfig(cfg, "wecom-app");
|
|
6597
|
+
const webhookPath = await prompter.askText({
|
|
6598
|
+
label: "Webhook \u8DEF\u5F84\uFF08\u9700\u4E0E\u4F01\u4E1A\u5FAE\u4FE1\u540E\u53F0\u914D\u7F6E\u4E00\u81F4\uFF0C\u9ED8\u8BA4 /wecom-app\uFF09",
|
|
6599
|
+
defaultValue: toTrimmedString(existing.webhookPath) ?? "/wecom-app",
|
|
6600
|
+
required: true
|
|
6601
|
+
});
|
|
6602
|
+
const token = await prompter.askSecret({
|
|
6603
|
+
label: "WeCom App token",
|
|
6604
|
+
existingValue: toTrimmedString(existing.token),
|
|
6605
|
+
required: true
|
|
6606
|
+
});
|
|
6607
|
+
const encodingAESKey = await prompter.askSecret({
|
|
6608
|
+
label: "WeCom App encodingAESKey",
|
|
6609
|
+
existingValue: toTrimmedString(existing.encodingAESKey),
|
|
6610
|
+
required: true
|
|
6611
|
+
});
|
|
6612
|
+
const patch = {
|
|
6613
|
+
webhookPath,
|
|
6614
|
+
token,
|
|
6615
|
+
encodingAESKey
|
|
6616
|
+
};
|
|
6617
|
+
const corpId = await prompter.askText({
|
|
6618
|
+
label: "corpId",
|
|
6619
|
+
defaultValue: toTrimmedString(existing.corpId),
|
|
6620
|
+
required: true
|
|
6621
|
+
});
|
|
6622
|
+
const corpSecret = await prompter.askSecret({
|
|
6623
|
+
label: "corpSecret",
|
|
6624
|
+
existingValue: toTrimmedString(existing.corpSecret),
|
|
6625
|
+
required: true
|
|
6626
|
+
});
|
|
6627
|
+
const agentId = await prompter.askNumber({
|
|
6628
|
+
label: "agentId",
|
|
6629
|
+
min: 1,
|
|
6630
|
+
defaultValue: toNumber(existing.agentId)
|
|
6631
|
+
});
|
|
6632
|
+
patch.corpId = corpId;
|
|
6633
|
+
patch.corpSecret = corpSecret;
|
|
6634
|
+
patch.agentId = agentId;
|
|
6635
|
+
return mergeChannelConfig(cfg, "wecom-app", patch);
|
|
6636
|
+
}
|
|
6637
|
+
async function configureQQBot(prompter, cfg) {
|
|
6638
|
+
section("\u914D\u7F6E QQBot\uFF08QQ \u673A\u5668\u4EBA\uFF09");
|
|
6639
|
+
showGuideLink("qqbot");
|
|
6640
|
+
const existing = getChannelConfig(cfg, "qqbot");
|
|
6641
|
+
const appId = await prompter.askText({
|
|
6642
|
+
label: "QQBot appId",
|
|
6643
|
+
defaultValue: toTrimmedString(existing.appId),
|
|
6644
|
+
required: true
|
|
6645
|
+
});
|
|
6646
|
+
const clientSecret = await prompter.askSecret({
|
|
6647
|
+
label: "QQBot clientSecret",
|
|
6648
|
+
existingValue: toTrimmedString(existing.clientSecret),
|
|
6649
|
+
required: true
|
|
6650
|
+
});
|
|
6651
|
+
const markdownSupport = await prompter.askConfirm(
|
|
6652
|
+
"\u542F\u7528 Markdown \u652F\u6301",
|
|
6653
|
+
toBoolean(existing.markdownSupport, false)
|
|
6654
|
+
);
|
|
6655
|
+
const replyFinalOnly = await prompter.askConfirm(
|
|
6656
|
+
"\u4EC5\u53D1\u9001\u6700\u7EC8\u56DE\u590D\uFF08\u5173\u95ED\u6D41\u5F0F\u5206\u7247\uFF09",
|
|
6657
|
+
toBoolean(existing.replyFinalOnly, false)
|
|
6658
|
+
);
|
|
6659
|
+
return mergeChannelConfig(cfg, "qqbot", {
|
|
6660
|
+
appId,
|
|
6661
|
+
clientSecret,
|
|
6662
|
+
markdownSupport,
|
|
6663
|
+
replyFinalOnly
|
|
6664
|
+
});
|
|
6665
|
+
}
|
|
6666
|
+
async function configureSingleChannel(channel, prompter, cfg) {
|
|
6667
|
+
switch (channel) {
|
|
6668
|
+
case "dingtalk":
|
|
6669
|
+
return configureDingtalk(prompter, cfg);
|
|
6670
|
+
case "feishu-china":
|
|
6671
|
+
return configureFeishu(prompter, cfg);
|
|
6672
|
+
case "wecom":
|
|
6673
|
+
return configureWecom(prompter, cfg);
|
|
6674
|
+
case "wecom-app":
|
|
6675
|
+
return configureWecomApp(prompter, cfg);
|
|
6676
|
+
case "qqbot":
|
|
6677
|
+
return configureQQBot(prompter, cfg);
|
|
6678
|
+
default:
|
|
6679
|
+
return cfg;
|
|
6680
|
+
}
|
|
6681
|
+
}
|
|
6682
|
+
async function runChinaSetup(params) {
|
|
6683
|
+
if (!stdin.isTTY || !stdout.isTTY) {
|
|
6684
|
+
params.logger.error?.("\u4EA4\u4E92\u5F0F\u914D\u7F6E\u9700\u8981\u5728 TTY \u7EC8\u7AEF\u4E2D\u8FD0\u884C\u3002");
|
|
6685
|
+
return;
|
|
6686
|
+
}
|
|
6687
|
+
const prompter = new SetupPrompter();
|
|
6688
|
+
const touched = /* @__PURE__ */ new Set();
|
|
6689
|
+
let next = cloneConfig(params.initialConfig);
|
|
6690
|
+
try {
|
|
6691
|
+
We("OpenClaw China \u914D\u7F6E\u5411\u5BFC");
|
|
6692
|
+
Ve(
|
|
6693
|
+
[
|
|
6694
|
+
"\u4F7F\u7528\u65B9\u5411\u952E\u9009\u62E9\uFF0C\u6309 Enter \u786E\u8BA4\u3002",
|
|
6695
|
+
`\u9879\u76EE\u4ED3\u5E93\uFF1A${ANSI_LINK}${PROJECT_REPO}${ANSI_RESET}`
|
|
6696
|
+
].join("\n"),
|
|
6697
|
+
"\u6B22\u8FCE"
|
|
6698
|
+
);
|
|
6699
|
+
if (params.availableChannels.length === 0) {
|
|
6700
|
+
params.logger.error?.("\u672A\u68C0\u6D4B\u5230\u53EF\u914D\u7F6E\u7684 China \u6E20\u9053\u63D2\u4EF6\u3002");
|
|
6701
|
+
return;
|
|
6702
|
+
}
|
|
6703
|
+
const channelOptions = params.availableChannels.map((channelId, index) => ({
|
|
6704
|
+
key: index === 0 ? "recommended" : "",
|
|
6705
|
+
value: channelId,
|
|
6706
|
+
label: withConfiguredSuffix(next, channelId)
|
|
6707
|
+
}));
|
|
6708
|
+
const defaultChannel = channelOptions[0]?.value ?? "save";
|
|
6709
|
+
let continueLoop = true;
|
|
6710
|
+
while (continueLoop) {
|
|
6711
|
+
const selected = await prompter.askSelect(
|
|
6712
|
+
"\u8BF7\u9009\u62E9\u8981\u914D\u7F6E\u7684\u6E20\u9053",
|
|
6713
|
+
[
|
|
6714
|
+
...channelOptions,
|
|
6715
|
+
{ key: "", value: "save", label: "\u4FDD\u5B58\u5E76\u9000\u51FA" },
|
|
6716
|
+
{ key: "", value: "cancel", label: "\u4E0D\u4FDD\u5B58\u5E76\u9000\u51FA" }
|
|
6717
|
+
],
|
|
6718
|
+
defaultChannel
|
|
6719
|
+
);
|
|
6720
|
+
if (selected === "cancel") {
|
|
6721
|
+
Ne("\u5DF2\u53D6\u6D88\uFF0C\u672A\u5199\u5165\u4EFB\u4F55\u914D\u7F6E\u3002");
|
|
6722
|
+
return;
|
|
6723
|
+
}
|
|
6724
|
+
if (selected === "save") {
|
|
6725
|
+
break;
|
|
6726
|
+
}
|
|
6727
|
+
next = await configureSingleChannel(selected, prompter, next);
|
|
6728
|
+
touched.add(selected);
|
|
6729
|
+
Ve(`\u5DF2\u5B8C\u6210\uFF1A${CHANNEL_DISPLAY_LABELS[selected]}`, "\u5B8C\u6210");
|
|
6730
|
+
continueLoop = await prompter.askConfirm("\u7EE7\u7EED\u914D\u7F6E\u5176\u4ED6\u6E20\u9053", true);
|
|
6731
|
+
}
|
|
6732
|
+
if (touched.size === 0) {
|
|
6733
|
+
Ne("\u672A\u8FDB\u884C\u4EFB\u4F55\u4FEE\u6539\u3002");
|
|
6734
|
+
return;
|
|
6735
|
+
}
|
|
6736
|
+
Ve(
|
|
6737
|
+
`\u5DF2\u914D\u7F6E\u6E20\u9053\uFF1A${Array.from(touched).map((channelId) => CHANNEL_DISPLAY_LABELS[channelId]).join(", ")}`,
|
|
6738
|
+
"\u6458\u8981"
|
|
6739
|
+
);
|
|
6740
|
+
if (!params.writeConfig) {
|
|
6741
|
+
params.logger.error?.("\u65E0\u6CD5\u4FDD\u5B58\u914D\u7F6E\uFF1A\u5F53\u524D\u8FD0\u884C\u65F6\u672A\u63D0\u4F9B\u914D\u7F6E\u5199\u5165\u80FD\u529B\u3002");
|
|
6742
|
+
return;
|
|
6743
|
+
}
|
|
6744
|
+
await params.writeConfig(next);
|
|
6745
|
+
Le("\u914D\u7F6E\u5DF2\u4FDD\u5B58\u3002");
|
|
6746
|
+
showReadyMessage();
|
|
6747
|
+
} catch (err) {
|
|
6748
|
+
if (err instanceof PromptCancelledError) {
|
|
6749
|
+
return;
|
|
6750
|
+
}
|
|
6751
|
+
throw err;
|
|
6752
|
+
}
|
|
6753
|
+
}
|
|
6754
|
+
function registerChinaSetupCli(api, opts) {
|
|
6755
|
+
const state = getChinaCliState();
|
|
6756
|
+
for (const channelId of normalizeChannels(opts?.channels)) {
|
|
6757
|
+
state.channels.add(channelId);
|
|
6758
|
+
}
|
|
6759
|
+
if (state.cliRegistered || typeof api.registerCli !== "function") {
|
|
6760
|
+
return;
|
|
6761
|
+
}
|
|
6762
|
+
state.cliRegistered = true;
|
|
6763
|
+
const writeConfig = resolveWriteConfig(api.runtime);
|
|
6764
|
+
const fallbackLogger = {
|
|
6765
|
+
info: (message) => stdout.write(`${message}
|
|
6766
|
+
`),
|
|
6767
|
+
warn: (message) => warn(message),
|
|
6768
|
+
error: (message) => warn(message)
|
|
6769
|
+
};
|
|
6770
|
+
api.registerCli(
|
|
6771
|
+
(ctx) => {
|
|
6772
|
+
if (!isCommandLike(ctx.program)) {
|
|
6773
|
+
const logger = ctx.logger ?? api.logger ?? fallbackLogger;
|
|
6774
|
+
logger.error?.("\u65E0\u6CD5\u6CE8\u518C china \u547D\u4EE4\uFF1ACLI program \u5B9E\u4F8B\u65E0\u6548\u3002");
|
|
6775
|
+
return;
|
|
6776
|
+
}
|
|
6777
|
+
const root = ctx.program.command("china").description("OpenClaw China \u63D2\u4EF6\u547D\u4EE4");
|
|
6778
|
+
root.command("setup").description("\u4E2D\u56FD\u6E20\u9053\u4EA4\u4E92\u5F0F\u914D\u7F6E\u5411\u5BFC").action(async () => {
|
|
6779
|
+
const logger = ctx.logger ?? api.logger ?? fallbackLogger;
|
|
6780
|
+
const availableChannels = getInstalledChannels(state);
|
|
6781
|
+
await runChinaSetup({
|
|
6782
|
+
initialConfig: isRecord(ctx.config) ? ctx.config : {},
|
|
6783
|
+
writeConfig,
|
|
6784
|
+
logger,
|
|
6785
|
+
availableChannels
|
|
6786
|
+
});
|
|
6787
|
+
});
|
|
6788
|
+
root.command("about").description("\u663E\u793A\u9879\u76EE\u4FE1\u606F").action(() => {
|
|
6789
|
+
const installed = getInstalledChannels(state);
|
|
6790
|
+
We("OpenClaw China \u6E20\u9053\u63D2\u4EF6");
|
|
6791
|
+
Ve(
|
|
6792
|
+
installed.length > 0 ? `\u5F53\u524D\u5DF2\u5B89\u88C5\u6E20\u9053\uFF1A${installed.map((channelId) => CHANNEL_DISPLAY_LABELS[channelId]).join("\u3001")}` : "OpenClaw China \u6E20\u9053\u63D2\u4EF6",
|
|
6793
|
+
"\u5173\u4E8E"
|
|
6794
|
+
);
|
|
6795
|
+
Le(PROJECT_REPO);
|
|
6796
|
+
showReadyMessage();
|
|
6797
|
+
});
|
|
6798
|
+
},
|
|
6799
|
+
{ commands: ["china"] }
|
|
6800
|
+
);
|
|
6801
|
+
}
|
|
5271
6802
|
var FileSizeLimitError2 = class _FileSizeLimitError extends Error {
|
|
5272
6803
|
/** Actual file size in bytes */
|
|
5273
6804
|
actualSize;
|
|
@@ -6480,6 +8011,9 @@ function buildInboundContext(ctx, sessionKey, accountId) {
|
|
|
6480
8011
|
GroupSubject: isGroup ? ctx.conversationId : void 0,
|
|
6481
8012
|
SenderName: ctx.senderNick,
|
|
6482
8013
|
SenderId: ctx.senderId,
|
|
8014
|
+
UserId: ctx.senderId,
|
|
8015
|
+
ConversationId: ctx.conversationId,
|
|
8016
|
+
GroupId: isGroup ? ctx.conversationId : void 0,
|
|
6483
8017
|
Provider: "dingtalk",
|
|
6484
8018
|
MessageSid: ctx.messageId,
|
|
6485
8019
|
Timestamp: Date.now(),
|
|
@@ -6489,6 +8023,22 @@ function buildInboundContext(ctx, sessionKey, accountId) {
|
|
|
6489
8023
|
OriginatingTo: to
|
|
6490
8024
|
};
|
|
6491
8025
|
}
|
|
8026
|
+
function buildTargetMeta(ctx, inboundCtx) {
|
|
8027
|
+
const isGroup = ctx.chatType === "group";
|
|
8028
|
+
const from = isGroup ? `dingtalk:group:${ctx.conversationId}` : `dingtalk:${ctx.senderId}`;
|
|
8029
|
+
const to = isGroup ? `chat:${ctx.conversationId}` : `user:${ctx.senderId}`;
|
|
8030
|
+
return {
|
|
8031
|
+
chatType: ctx.chatType,
|
|
8032
|
+
senderId: ctx.senderId,
|
|
8033
|
+
userId: ctx.senderId,
|
|
8034
|
+
conversationId: ctx.conversationId,
|
|
8035
|
+
groupId: isGroup ? ctx.conversationId : void 0,
|
|
8036
|
+
targetId: isGroup ? ctx.conversationId : ctx.senderId,
|
|
8037
|
+
from: inboundCtx?.From ?? from,
|
|
8038
|
+
to: inboundCtx?.To ?? to,
|
|
8039
|
+
messageId: ctx.messageId
|
|
8040
|
+
};
|
|
8041
|
+
}
|
|
6492
8042
|
async function handleAICardStreaming(params) {
|
|
6493
8043
|
const { card, route, inboundCtx, dingtalkCfg, targetId, chatType, logger } = params;
|
|
6494
8044
|
let accumulated = "";
|
|
@@ -6665,6 +8215,14 @@ async function handleDingtalkMessage(params) {
|
|
|
6665
8215
|
const ctx = parseDingtalkMessage(raw);
|
|
6666
8216
|
const isGroup = ctx.chatType === "group";
|
|
6667
8217
|
const audioRecognition = resolveAudioRecognition(raw);
|
|
8218
|
+
const inboundTargetMeta = buildTargetMeta(ctx);
|
|
8219
|
+
logger.info(
|
|
8220
|
+
`[inbound] received=${JSON.stringify({
|
|
8221
|
+
...inboundTargetMeta,
|
|
8222
|
+
contentType: ctx.contentType,
|
|
8223
|
+
mentionedBot: ctx.mentionedBot
|
|
8224
|
+
})}`
|
|
8225
|
+
);
|
|
6668
8226
|
const dingtalkCfg = cfg?.channels;
|
|
6669
8227
|
const channelCfg = dingtalkCfg?.dingtalk;
|
|
6670
8228
|
const inboundMediaDir = resolveInboundMediaDir(channelCfg);
|
|
@@ -6691,7 +8249,12 @@ async function handleDingtalkMessage(params) {
|
|
|
6691
8249
|
mentionedBot: ctx.mentionedBot
|
|
6692
8250
|
});
|
|
6693
8251
|
if (!policyResult.allowed) {
|
|
6694
|
-
logger.debug(
|
|
8252
|
+
logger.debug(
|
|
8253
|
+
`[policy] rejected=${JSON.stringify({
|
|
8254
|
+
reason: policyResult.reason,
|
|
8255
|
+
...inboundTargetMeta
|
|
8256
|
+
})}`
|
|
8257
|
+
);
|
|
6695
8258
|
return;
|
|
6696
8259
|
}
|
|
6697
8260
|
} else {
|
|
@@ -6703,7 +8266,12 @@ async function handleDingtalkMessage(params) {
|
|
|
6703
8266
|
allowFrom
|
|
6704
8267
|
});
|
|
6705
8268
|
if (!policyResult.allowed) {
|
|
6706
|
-
logger.debug(
|
|
8269
|
+
logger.debug(
|
|
8270
|
+
`[policy] rejected=${JSON.stringify({
|
|
8271
|
+
reason: policyResult.reason,
|
|
8272
|
+
...inboundTargetMeta
|
|
8273
|
+
})}`
|
|
8274
|
+
);
|
|
6707
8275
|
return;
|
|
6708
8276
|
}
|
|
6709
8277
|
}
|
|
@@ -6867,6 +8435,8 @@ async function handleDingtalkMessage(params) {
|
|
|
6867
8435
|
}
|
|
6868
8436
|
const finalizeInboundContext = replyApi?.finalizeInboundContext;
|
|
6869
8437
|
const finalCtx = finalizeInboundContext ? finalizeInboundContext(inboundCtx) : inboundCtx;
|
|
8438
|
+
const resolvedTargetMeta = buildTargetMeta(ctx, finalCtx);
|
|
8439
|
+
logger.debug(`[inbound] context=${JSON.stringify(resolvedTargetMeta)}`);
|
|
6870
8440
|
let cronSource = "";
|
|
6871
8441
|
let cronBase = "";
|
|
6872
8442
|
if (typeof finalCtx.RawBody === "string" && finalCtx.RawBody) {
|
|
@@ -6956,6 +8526,7 @@ async function handleDingtalkMessage(params) {
|
|
|
6956
8526
|
const deliver = async (payload, info) => {
|
|
6957
8527
|
logger.debug(
|
|
6958
8528
|
`[reply] meta=${JSON.stringify({
|
|
8529
|
+
...resolvedTargetMeta,
|
|
6959
8530
|
kind: info?.kind ?? "unknown",
|
|
6960
8531
|
hasText: typeof payload.text === "string",
|
|
6961
8532
|
mediaCount: Array.isArray(payload.mediaUrls) ? payload.mediaUrls.length : payload.mediaUrl ? 1 : 0
|
|
@@ -6974,7 +8545,9 @@ async function handleDingtalkMessage(params) {
|
|
|
6974
8545
|
});
|
|
6975
8546
|
sent = true;
|
|
6976
8547
|
} catch (err) {
|
|
6977
|
-
logger.error(
|
|
8548
|
+
logger.error(
|
|
8549
|
+
`[reply] sendMediaDingtalk failed (target=${JSON.stringify(resolvedTargetMeta)}): ${String(err)}`
|
|
8550
|
+
);
|
|
6978
8551
|
const fallbackText = `\u{1F4CE} ${mediaUrl}`;
|
|
6979
8552
|
await sendMessageDingtalk({
|
|
6980
8553
|
cfg: dingtalkCfgResolved,
|
|
@@ -7040,7 +8613,12 @@ async function handleDingtalkMessage(params) {
|
|
|
7040
8613
|
const createDispatcher = replyApi?.createReplyDispatcher;
|
|
7041
8614
|
const dispatchReplyWithBufferedBlockDispatcher = replyApi?.dispatchReplyWithBufferedBlockDispatcher;
|
|
7042
8615
|
if (dispatchReplyWithBufferedBlockDispatcher) {
|
|
7043
|
-
logger.debug(
|
|
8616
|
+
logger.debug(
|
|
8617
|
+
`[dispatch] buffered=${JSON.stringify({
|
|
8618
|
+
sessionKey: route?.sessionKey,
|
|
8619
|
+
...resolvedTargetMeta
|
|
8620
|
+
})}`
|
|
8621
|
+
);
|
|
7044
8622
|
const deliveryState = { delivered: false, skippedNonSilent: 0 };
|
|
7045
8623
|
const result2 = await dispatchReplyWithBufferedBlockDispatcher({
|
|
7046
8624
|
ctx: finalCtx,
|
|
@@ -7107,7 +8685,12 @@ async function handleDingtalkMessage(params) {
|
|
|
7107
8685
|
logger.debug("dispatcher not available, skipping dispatch");
|
|
7108
8686
|
return;
|
|
7109
8687
|
}
|
|
7110
|
-
logger.debug(
|
|
8688
|
+
logger.debug(
|
|
8689
|
+
`[dispatch] standard=${JSON.stringify({
|
|
8690
|
+
sessionKey: route?.sessionKey,
|
|
8691
|
+
...resolvedTargetMeta
|
|
8692
|
+
})}`
|
|
8693
|
+
);
|
|
7111
8694
|
const dispatchReplyFromConfig = replyApi?.dispatchReplyFromConfig;
|
|
7112
8695
|
if (!dispatchReplyFromConfig) {
|
|
7113
8696
|
logger.debug("dispatchReplyFromConfig not available");
|
|
@@ -7127,7 +8710,9 @@ async function handleDingtalkMessage(params) {
|
|
|
7127
8710
|
`dispatch complete (queuedFinal=${typeof queuedFinal === "boolean" ? queuedFinal : "unknown"}, replies=${counts?.final ?? 0})`
|
|
7128
8711
|
);
|
|
7129
8712
|
} catch (err) {
|
|
7130
|
-
logger.error(
|
|
8713
|
+
logger.error(
|
|
8714
|
+
`failed to dispatch message (target=${JSON.stringify(inboundTargetMeta)}): ${String(err)}`
|
|
8715
|
+
);
|
|
7131
8716
|
} finally {
|
|
7132
8717
|
try {
|
|
7133
8718
|
await pruneInboundMediaDir({
|
|
@@ -8148,6 +9733,7 @@ var plugin = {
|
|
|
8148
9733
|
* Requirements: 1.1
|
|
8149
9734
|
*/
|
|
8150
9735
|
register(api) {
|
|
9736
|
+
registerChinaSetupCli(api, { channels: ["dingtalk"] });
|
|
8151
9737
|
if (api.runtime) {
|
|
8152
9738
|
setDingtalkRuntime(api.runtime);
|
|
8153
9739
|
}
|