@docyrus/docyrus 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/agent-loader.js +2640 -0
- package/agent-loader.js.map +7 -0
- package/main.js +74 -108
- package/main.js.map +2 -2
- package/package.json +5 -2
- package/resources/pi-agent/skills/docyrus-api-dev/references/data-source-query-guide.md +2 -2
- package/resources/pi-agent/skills/docyrus-api-dev/references/formula-design-guide-llm.md +1 -1
- package/resources/pi-agent/skills/docyrus-app-dev/references/data-source-query-guide.md +2 -2
- package/resources/pi-agent/skills/docyrus-app-dev/references/formula-design-guide-llm.md +1 -1
- package/resources/pi-agent/skills/docyrus-architect/references/data-source-query-guide.md +2 -2
- package/resources/pi-agent/skills/docyrus-architect/references/formula-design-guide-llm.md +1 -1
- package/resources/pi-agent/skills/docyrus-architect/references/formula-reference.md +2 -2
package/agent-loader.js
ADDED
|
@@ -0,0 +1,2640 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
36
|
+
var require_picocolors = __commonJS({
|
|
37
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
38
|
+
"use strict";
|
|
39
|
+
var p2 = process || {};
|
|
40
|
+
var argv = p2.argv || [];
|
|
41
|
+
var env = p2.env || {};
|
|
42
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
43
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
44
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
45
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
46
|
+
};
|
|
47
|
+
var replaceClose = (string, close, replace, index) => {
|
|
48
|
+
let result = "", cursor = 0;
|
|
49
|
+
do {
|
|
50
|
+
result += string.substring(cursor, index) + replace;
|
|
51
|
+
cursor = index + close.length;
|
|
52
|
+
index = string.indexOf(close, cursor);
|
|
53
|
+
} while (~index);
|
|
54
|
+
return result + string.substring(cursor);
|
|
55
|
+
};
|
|
56
|
+
var createColors = (enabled = isColorSupported) => {
|
|
57
|
+
let f = enabled ? formatter : () => String;
|
|
58
|
+
return {
|
|
59
|
+
isColorSupported: enabled,
|
|
60
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
61
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
62
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
63
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
64
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
65
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
66
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
67
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
68
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
69
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
70
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
71
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
72
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
73
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
74
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
75
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
76
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
77
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
78
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
79
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
80
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
81
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
82
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
83
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
84
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
85
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
86
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
87
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
88
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
89
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
90
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
91
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
92
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
93
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
94
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
95
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
96
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
97
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
98
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
99
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
100
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
module2.exports = createColors();
|
|
104
|
+
module2.exports.createColors = createColors;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
109
|
+
var require_src = __commonJS({
|
|
110
|
+
"../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) {
|
|
111
|
+
"use strict";
|
|
112
|
+
var ESC = "\x1B";
|
|
113
|
+
var CSI = `${ESC}[`;
|
|
114
|
+
var beep = "\x07";
|
|
115
|
+
var cursor = {
|
|
116
|
+
to(x3, y3) {
|
|
117
|
+
if (!y3) return `${CSI}${x3 + 1}G`;
|
|
118
|
+
return `${CSI}${y3 + 1};${x3 + 1}H`;
|
|
119
|
+
},
|
|
120
|
+
move(x3, y3) {
|
|
121
|
+
let ret = "";
|
|
122
|
+
if (x3 < 0) ret += `${CSI}${-x3}D`;
|
|
123
|
+
else if (x3 > 0) ret += `${CSI}${x3}C`;
|
|
124
|
+
if (y3 < 0) ret += `${CSI}${-y3}A`;
|
|
125
|
+
else if (y3 > 0) ret += `${CSI}${y3}B`;
|
|
126
|
+
return ret;
|
|
127
|
+
},
|
|
128
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
129
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
130
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
131
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
132
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
133
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
134
|
+
left: `${CSI}G`,
|
|
135
|
+
hide: `${CSI}?25l`,
|
|
136
|
+
show: `${CSI}?25h`,
|
|
137
|
+
save: `${ESC}7`,
|
|
138
|
+
restore: `${ESC}8`
|
|
139
|
+
};
|
|
140
|
+
var scroll = {
|
|
141
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
142
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
143
|
+
};
|
|
144
|
+
var erase = {
|
|
145
|
+
screen: `${CSI}2J`,
|
|
146
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
147
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
148
|
+
line: `${CSI}2K`,
|
|
149
|
+
lineEnd: `${CSI}K`,
|
|
150
|
+
lineStart: `${CSI}1K`,
|
|
151
|
+
lines(count) {
|
|
152
|
+
let clear = "";
|
|
153
|
+
for (let i = 0; i < count; i++)
|
|
154
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
155
|
+
if (count)
|
|
156
|
+
clear += cursor.left;
|
|
157
|
+
return clear;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
module2.exports = { cursor, scroll, erase, beep };
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// ../../node_modules/.pnpm/@clack+core@0.5.0/node_modules/@clack/core/dist/index.mjs
|
|
165
|
+
function DD({ onlyFirst: e2 = false } = {}) {
|
|
166
|
+
const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
167
|
+
return new RegExp(t, e2 ? void 0 : "g");
|
|
168
|
+
}
|
|
169
|
+
function P(e2) {
|
|
170
|
+
if (typeof e2 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e2}\``);
|
|
171
|
+
return e2.replace(uD, "");
|
|
172
|
+
}
|
|
173
|
+
function L(e2) {
|
|
174
|
+
return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
|
|
175
|
+
}
|
|
176
|
+
function p(e2, u2 = {}) {
|
|
177
|
+
if (typeof e2 != "string" || e2.length === 0 || (u2 = { ambiguousIsNarrow: true, ...u2 }, e2 = P(e2), e2.length === 0)) return 0;
|
|
178
|
+
e2 = e2.replace(sD(), " ");
|
|
179
|
+
const t = u2.ambiguousIsNarrow ? 1 : 2;
|
|
180
|
+
let F2 = 0;
|
|
181
|
+
for (const s of e2) {
|
|
182
|
+
const i = s.codePointAt(0);
|
|
183
|
+
if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
|
|
184
|
+
switch (eD.eastAsianWidth(s)) {
|
|
185
|
+
case "F":
|
|
186
|
+
case "W":
|
|
187
|
+
F2 += 2;
|
|
188
|
+
break;
|
|
189
|
+
case "A":
|
|
190
|
+
F2 += t;
|
|
191
|
+
break;
|
|
192
|
+
default:
|
|
193
|
+
F2 += 1;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return F2;
|
|
197
|
+
}
|
|
198
|
+
function rD() {
|
|
199
|
+
const e2 = /* @__PURE__ */ new Map();
|
|
200
|
+
for (const [u2, t] of Object.entries(r)) {
|
|
201
|
+
for (const [F2, s] of Object.entries(t)) r[F2] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, t[F2] = r[F2], e2.set(s[0], s[1]);
|
|
202
|
+
Object.defineProperty(r, u2, { value: t, enumerable: false });
|
|
203
|
+
}
|
|
204
|
+
return Object.defineProperty(r, "codes", { value: e2, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = N(), r.color.ansi256 = I(), r.color.ansi16m = R(), r.bgColor.ansi = N(w), r.bgColor.ansi256 = I(w), r.bgColor.ansi16m = R(w), Object.defineProperties(r, { rgbToAnsi256: { value: (u2, t, F2) => u2 === t && t === F2 ? u2 < 8 ? 16 : u2 > 248 ? 231 : Math.round((u2 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u2 / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F2 / 255 * 5), enumerable: false }, hexToRgb: { value: (u2) => {
|
|
205
|
+
const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u2.toString(16));
|
|
206
|
+
if (!t) return [0, 0, 0];
|
|
207
|
+
let [F2] = t;
|
|
208
|
+
F2.length === 3 && (F2 = [...F2].map((i) => i + i).join(""));
|
|
209
|
+
const s = Number.parseInt(F2, 16);
|
|
210
|
+
return [s >> 16 & 255, s >> 8 & 255, s & 255];
|
|
211
|
+
}, enumerable: false }, hexToAnsi256: { value: (u2) => r.rgbToAnsi256(...r.hexToRgb(u2)), enumerable: false }, ansi256ToAnsi: { value: (u2) => {
|
|
212
|
+
if (u2 < 8) return 30 + u2;
|
|
213
|
+
if (u2 < 16) return 90 + (u2 - 8);
|
|
214
|
+
let t, F2, s;
|
|
215
|
+
if (u2 >= 232) t = ((u2 - 232) * 10 + 8) / 255, F2 = t, s = t;
|
|
216
|
+
else {
|
|
217
|
+
u2 -= 16;
|
|
218
|
+
const C2 = u2 % 36;
|
|
219
|
+
t = Math.floor(u2 / 36) / 5, F2 = Math.floor(C2 / 6) / 5, s = C2 % 6 / 5;
|
|
220
|
+
}
|
|
221
|
+
const i = Math.max(t, F2, s) * 2;
|
|
222
|
+
if (i === 0) return 30;
|
|
223
|
+
let D2 = 30 + (Math.round(s) << 2 | Math.round(F2) << 1 | Math.round(t));
|
|
224
|
+
return i === 2 && (D2 += 60), D2;
|
|
225
|
+
}, enumerable: false }, rgbToAnsi: { value: (u2, t, F2) => r.ansi256ToAnsi(r.rgbToAnsi256(u2, t, F2)), enumerable: false }, hexToAnsi: { value: (u2) => r.ansi256ToAnsi(r.hexToAnsi256(u2)), enumerable: false } }), r;
|
|
226
|
+
}
|
|
227
|
+
function Y(e2, u2, t) {
|
|
228
|
+
return String(e2).normalize().replace(/\r\n/g, `
|
|
229
|
+
`).split(`
|
|
230
|
+
`).map((F2) => lD(F2, u2, t)).join(`
|
|
231
|
+
`);
|
|
232
|
+
}
|
|
233
|
+
function cD(e2) {
|
|
234
|
+
for (const u2 in e2) {
|
|
235
|
+
const t = u2;
|
|
236
|
+
if (!Object.hasOwn(e2, t)) continue;
|
|
237
|
+
const F2 = e2[t];
|
|
238
|
+
switch (t) {
|
|
239
|
+
case "aliases": {
|
|
240
|
+
for (const s in F2) Object.hasOwn(F2, s) && (B.aliases.has(s) || B.aliases.set(s, F2[s]));
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function $(e2, u2) {
|
|
247
|
+
if (typeof e2 == "string") return B.aliases.get(e2) === u2;
|
|
248
|
+
for (const t of e2) if (t !== void 0 && $(t, u2)) return true;
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
function BD(e2, u2) {
|
|
252
|
+
if (e2 === u2) return;
|
|
253
|
+
const t = e2.split(`
|
|
254
|
+
`), F2 = u2.split(`
|
|
255
|
+
`), s = [];
|
|
256
|
+
for (let i = 0; i < Math.max(t.length, F2.length); i++) t[i] !== F2[i] && s.push(i);
|
|
257
|
+
return s;
|
|
258
|
+
}
|
|
259
|
+
function pD(e2) {
|
|
260
|
+
return e2 === S;
|
|
261
|
+
}
|
|
262
|
+
function m(e2, u2) {
|
|
263
|
+
const t = e2;
|
|
264
|
+
t.isTTY && t.setRawMode(u2);
|
|
265
|
+
}
|
|
266
|
+
function fD({ input: e2 = import_node_process.stdin, output: u2 = import_node_process.stdout, overwrite: t = true, hideCursor: F2 = true } = {}) {
|
|
267
|
+
const s = g.createInterface({ input: e2, output: u2, prompt: "", tabSize: 1 });
|
|
268
|
+
g.emitKeypressEvents(e2, s), e2.isTTY && e2.setRawMode(true);
|
|
269
|
+
const i = (D2, { name: C2, sequence: n }) => {
|
|
270
|
+
const E = String(D2);
|
|
271
|
+
if ($([E, C2, n], "cancel")) {
|
|
272
|
+
F2 && u2.write(import_sisteransi.cursor.show), process.exit(0);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!t) return;
|
|
276
|
+
const a = C2 === "return" ? 0 : -1, o2 = C2 === "return" ? -1 : 0;
|
|
277
|
+
g.moveCursor(u2, a, o2, () => {
|
|
278
|
+
g.clearLine(u2, 1, () => {
|
|
279
|
+
e2.once("keypress", i);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
return F2 && u2.write(import_sisteransi.cursor.hide), e2.once("keypress", i), () => {
|
|
284
|
+
e2.off("keypress", i), F2 && u2.write(import_sisteransi.cursor.show), e2.isTTY && !AD && e2.setRawMode(false), s.terminal = false, s.close();
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
var import_sisteransi, import_node_process, g, import_node_readline, import_node_stream, import_picocolors, uD, W, tD, eD, FD, sD, w, N, I, R, r, iD, CD, ED, d, oD, y, V, nD, G, _, z, K, aD, k, hD, lD, xD, B, AD, S, gD, vD, h, x, dD, mD, bD, Z, q, T, wD, yD, A, _D, kD, $D, H, SD, TD, jD, U, MD, OD, PD, J, LD, WD, ND, Q, ID, RD;
|
|
288
|
+
var init_dist = __esm({
|
|
289
|
+
"../../node_modules/.pnpm/@clack+core@0.5.0/node_modules/@clack/core/dist/index.mjs"() {
|
|
290
|
+
"use strict";
|
|
291
|
+
import_sisteransi = __toESM(require_src(), 1);
|
|
292
|
+
import_node_process = require("node:process");
|
|
293
|
+
g = __toESM(require("node:readline"), 1);
|
|
294
|
+
import_node_readline = __toESM(require("node:readline"), 1);
|
|
295
|
+
import_node_stream = require("node:stream");
|
|
296
|
+
import_picocolors = __toESM(require_picocolors(), 1);
|
|
297
|
+
uD = DD();
|
|
298
|
+
W = { exports: {} };
|
|
299
|
+
(function(e2) {
|
|
300
|
+
var u2 = {};
|
|
301
|
+
e2.exports = u2, u2.eastAsianWidth = function(F2) {
|
|
302
|
+
var s = F2.charCodeAt(0), i = F2.length == 2 ? F2.charCodeAt(1) : 0, D2 = s;
|
|
303
|
+
return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D2 = s << 10 | i, D2 += 65536), D2 == 12288 || 65281 <= D2 && D2 <= 65376 || 65504 <= D2 && D2 <= 65510 ? "F" : D2 == 8361 || 65377 <= D2 && D2 <= 65470 || 65474 <= D2 && D2 <= 65479 || 65482 <= D2 && D2 <= 65487 || 65490 <= D2 && D2 <= 65495 || 65498 <= D2 && D2 <= 65500 || 65512 <= D2 && D2 <= 65518 ? "H" : 4352 <= D2 && D2 <= 4447 || 4515 <= D2 && D2 <= 4519 || 4602 <= D2 && D2 <= 4607 || 9001 <= D2 && D2 <= 9002 || 11904 <= D2 && D2 <= 11929 || 11931 <= D2 && D2 <= 12019 || 12032 <= D2 && D2 <= 12245 || 12272 <= D2 && D2 <= 12283 || 12289 <= D2 && D2 <= 12350 || 12353 <= D2 && D2 <= 12438 || 12441 <= D2 && D2 <= 12543 || 12549 <= D2 && D2 <= 12589 || 12593 <= D2 && D2 <= 12686 || 12688 <= D2 && D2 <= 12730 || 12736 <= D2 && D2 <= 12771 || 12784 <= D2 && D2 <= 12830 || 12832 <= D2 && D2 <= 12871 || 12880 <= D2 && D2 <= 13054 || 13056 <= D2 && D2 <= 19903 || 19968 <= D2 && D2 <= 42124 || 42128 <= D2 && D2 <= 42182 || 43360 <= D2 && D2 <= 43388 || 44032 <= D2 && D2 <= 55203 || 55216 <= D2 && D2 <= 55238 || 55243 <= D2 && D2 <= 55291 || 63744 <= D2 && D2 <= 64255 || 65040 <= D2 && D2 <= 65049 || 65072 <= D2 && D2 <= 65106 || 65108 <= D2 && D2 <= 65126 || 65128 <= D2 && D2 <= 65131 || 110592 <= D2 && D2 <= 110593 || 127488 <= D2 && D2 <= 127490 || 127504 <= D2 && D2 <= 127546 || 127552 <= D2 && D2 <= 127560 || 127568 <= D2 && D2 <= 127569 || 131072 <= D2 && D2 <= 194367 || 177984 <= D2 && D2 <= 196605 || 196608 <= D2 && D2 <= 262141 ? "W" : 32 <= D2 && D2 <= 126 || 162 <= D2 && D2 <= 163 || 165 <= D2 && D2 <= 166 || D2 == 172 || D2 == 175 || 10214 <= D2 && D2 <= 10221 || 10629 <= D2 && D2 <= 10630 ? "Na" : D2 == 161 || D2 == 164 || 167 <= D2 && D2 <= 168 || D2 == 170 || 173 <= D2 && D2 <= 174 || 176 <= D2 && D2 <= 180 || 182 <= D2 && D2 <= 186 || 188 <= D2 && D2 <= 191 || D2 == 198 || D2 == 208 || 215 <= D2 && D2 <= 216 || 222 <= D2 && D2 <= 225 || D2 == 230 || 232 <= D2 && D2 <= 234 || 236 <= D2 && D2 <= 237 || D2 == 240 || 242 <= D2 && D2 <= 243 || 247 <= D2 && D2 <= 250 || D2 == 252 || D2 == 254 || D2 == 257 || D2 == 273 || D2 == 275 || D2 == 283 || 294 <= D2 && D2 <= 295 || D2 == 299 || 305 <= D2 && D2 <= 307 || D2 == 312 || 319 <= D2 && D2 <= 322 || D2 == 324 || 328 <= D2 && D2 <= 331 || D2 == 333 || 338 <= D2 && D2 <= 339 || 358 <= D2 && D2 <= 359 || D2 == 363 || D2 == 462 || D2 == 464 || D2 == 466 || D2 == 468 || D2 == 470 || D2 == 472 || D2 == 474 || D2 == 476 || D2 == 593 || D2 == 609 || D2 == 708 || D2 == 711 || 713 <= D2 && D2 <= 715 || D2 == 717 || D2 == 720 || 728 <= D2 && D2 <= 731 || D2 == 733 || D2 == 735 || 768 <= D2 && D2 <= 879 || 913 <= D2 && D2 <= 929 || 931 <= D2 && D2 <= 937 || 945 <= D2 && D2 <= 961 || 963 <= D2 && D2 <= 969 || D2 == 1025 || 1040 <= D2 && D2 <= 1103 || D2 == 1105 || D2 == 8208 || 8211 <= D2 && D2 <= 8214 || 8216 <= D2 && D2 <= 8217 || 8220 <= D2 && D2 <= 8221 || 8224 <= D2 && D2 <= 8226 || 8228 <= D2 && D2 <= 8231 || D2 == 8240 || 8242 <= D2 && D2 <= 8243 || D2 == 8245 || D2 == 8251 || D2 == 8254 || D2 == 8308 || D2 == 8319 || 8321 <= D2 && D2 <= 8324 || D2 == 8364 || D2 == 8451 || D2 == 8453 || D2 == 8457 || D2 == 8467 || D2 == 8470 || 8481 <= D2 && D2 <= 8482 || D2 == 8486 || D2 == 8491 || 8531 <= D2 && D2 <= 8532 || 8539 <= D2 && D2 <= 8542 || 8544 <= D2 && D2 <= 8555 || 8560 <= D2 && D2 <= 8569 || D2 == 8585 || 8592 <= D2 && D2 <= 8601 || 8632 <= D2 && D2 <= 8633 || D2 == 8658 || D2 == 8660 || D2 == 8679 || D2 == 8704 || 8706 <= D2 && D2 <= 8707 || 8711 <= D2 && D2 <= 8712 || D2 == 8715 || D2 == 8719 || D2 == 8721 || D2 == 8725 || D2 == 8730 || 8733 <= D2 && D2 <= 8736 || D2 == 8739 || D2 == 8741 || 8743 <= D2 && D2 <= 8748 || D2 == 8750 || 8756 <= D2 && D2 <= 8759 || 8764 <= D2 && D2 <= 8765 || D2 == 8776 || D2 == 8780 || D2 == 8786 || 8800 <= D2 && D2 <= 8801 || 8804 <= D2 && D2 <= 8807 || 8810 <= D2 && D2 <= 8811 || 8814 <= D2 && D2 <= 8815 || 8834 <= D2 && D2 <= 8835 || 8838 <= D2 && D2 <= 8839 || D2 == 8853 || D2 == 8857 || D2 == 8869 || D2 == 8895 || D2 == 8978 || 9312 <= D2 && D2 <= 9449 || 9451 <= D2 && D2 <= 9547 || 9552 <= D2 && D2 <= 9587 || 9600 <= D2 && D2 <= 9615 || 9618 <= D2 && D2 <= 9621 || 9632 <= D2 && D2 <= 9633 || 9635 <= D2 && D2 <= 9641 || 9650 <= D2 && D2 <= 9651 || 9654 <= D2 && D2 <= 9655 || 9660 <= D2 && D2 <= 9661 || 9664 <= D2 && D2 <= 9665 || 9670 <= D2 && D2 <= 9672 || D2 == 9675 || 9678 <= D2 && D2 <= 9681 || 9698 <= D2 && D2 <= 9701 || D2 == 9711 || 9733 <= D2 && D2 <= 9734 || D2 == 9737 || 9742 <= D2 && D2 <= 9743 || 9748 <= D2 && D2 <= 9749 || D2 == 9756 || D2 == 9758 || D2 == 9792 || D2 == 9794 || 9824 <= D2 && D2 <= 9825 || 9827 <= D2 && D2 <= 9829 || 9831 <= D2 && D2 <= 9834 || 9836 <= D2 && D2 <= 9837 || D2 == 9839 || 9886 <= D2 && D2 <= 9887 || 9918 <= D2 && D2 <= 9919 || 9924 <= D2 && D2 <= 9933 || 9935 <= D2 && D2 <= 9953 || D2 == 9955 || 9960 <= D2 && D2 <= 9983 || D2 == 10045 || D2 == 10071 || 10102 <= D2 && D2 <= 10111 || 11093 <= D2 && D2 <= 11097 || 12872 <= D2 && D2 <= 12879 || 57344 <= D2 && D2 <= 63743 || 65024 <= D2 && D2 <= 65039 || D2 == 65533 || 127232 <= D2 && D2 <= 127242 || 127248 <= D2 && D2 <= 127277 || 127280 <= D2 && D2 <= 127337 || 127344 <= D2 && D2 <= 127386 || 917760 <= D2 && D2 <= 917999 || 983040 <= D2 && D2 <= 1048573 || 1048576 <= D2 && D2 <= 1114109 ? "A" : "N";
|
|
304
|
+
}, u2.characterLength = function(F2) {
|
|
305
|
+
var s = this.eastAsianWidth(F2);
|
|
306
|
+
return s == "F" || s == "W" || s == "A" ? 2 : 1;
|
|
307
|
+
};
|
|
308
|
+
function t(F2) {
|
|
309
|
+
return F2.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
|
|
310
|
+
}
|
|
311
|
+
u2.length = function(F2) {
|
|
312
|
+
for (var s = t(F2), i = 0, D2 = 0; D2 < s.length; D2++) i = i + this.characterLength(s[D2]);
|
|
313
|
+
return i;
|
|
314
|
+
}, u2.slice = function(F2, s, i) {
|
|
315
|
+
textLen = u2.length(F2), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
|
|
316
|
+
for (var D2 = "", C2 = 0, n = t(F2), E = 0; E < n.length; E++) {
|
|
317
|
+
var a = n[E], o2 = u2.length(a);
|
|
318
|
+
if (C2 >= s - (o2 == 2 ? 1 : 0)) if (C2 + o2 <= i) D2 += a;
|
|
319
|
+
else break;
|
|
320
|
+
C2 += o2;
|
|
321
|
+
}
|
|
322
|
+
return D2;
|
|
323
|
+
};
|
|
324
|
+
})(W);
|
|
325
|
+
tD = W.exports;
|
|
326
|
+
eD = L(tD);
|
|
327
|
+
FD = function() {
|
|
328
|
+
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
|
329
|
+
};
|
|
330
|
+
sD = L(FD);
|
|
331
|
+
w = 10;
|
|
332
|
+
N = (e2 = 0) => (u2) => `\x1B[${u2 + e2}m`;
|
|
333
|
+
I = (e2 = 0) => (u2) => `\x1B[${38 + e2};5;${u2}m`;
|
|
334
|
+
R = (e2 = 0) => (u2, t, F2) => `\x1B[${38 + e2};2;${u2};${t};${F2}m`;
|
|
335
|
+
r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
|
|
336
|
+
Object.keys(r.modifier);
|
|
337
|
+
iD = Object.keys(r.color);
|
|
338
|
+
CD = Object.keys(r.bgColor);
|
|
339
|
+
[...iD, ...CD];
|
|
340
|
+
ED = rD();
|
|
341
|
+
d = /* @__PURE__ */ new Set(["\x1B", "\x9B"]);
|
|
342
|
+
oD = 39;
|
|
343
|
+
y = "\x07";
|
|
344
|
+
V = "[";
|
|
345
|
+
nD = "]";
|
|
346
|
+
G = "m";
|
|
347
|
+
_ = `${nD}8;;`;
|
|
348
|
+
z = (e2) => `${d.values().next().value}${V}${e2}${G}`;
|
|
349
|
+
K = (e2) => `${d.values().next().value}${_}${e2}${y}`;
|
|
350
|
+
aD = (e2) => e2.split(" ").map((u2) => p(u2));
|
|
351
|
+
k = (e2, u2, t) => {
|
|
352
|
+
const F2 = [...u2];
|
|
353
|
+
let s = false, i = false, D2 = p(P(e2[e2.length - 1]));
|
|
354
|
+
for (const [C2, n] of F2.entries()) {
|
|
355
|
+
const E = p(n);
|
|
356
|
+
if (D2 + E <= t ? e2[e2.length - 1] += n : (e2.push(n), D2 = 0), d.has(n) && (s = true, i = F2.slice(C2 + 1).join("").startsWith(_)), s) {
|
|
357
|
+
i ? n === y && (s = false, i = false) : n === G && (s = false);
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
D2 += E, D2 === t && C2 < F2.length - 1 && (e2.push(""), D2 = 0);
|
|
361
|
+
}
|
|
362
|
+
!D2 && e2[e2.length - 1].length > 0 && e2.length > 1 && (e2[e2.length - 2] += e2.pop());
|
|
363
|
+
};
|
|
364
|
+
hD = (e2) => {
|
|
365
|
+
const u2 = e2.split(" ");
|
|
366
|
+
let t = u2.length;
|
|
367
|
+
for (; t > 0 && !(p(u2[t - 1]) > 0); ) t--;
|
|
368
|
+
return t === u2.length ? e2 : u2.slice(0, t).join(" ") + u2.slice(t).join("");
|
|
369
|
+
};
|
|
370
|
+
lD = (e2, u2, t = {}) => {
|
|
371
|
+
if (t.trim !== false && e2.trim() === "") return "";
|
|
372
|
+
let F2 = "", s, i;
|
|
373
|
+
const D2 = aD(e2);
|
|
374
|
+
let C2 = [""];
|
|
375
|
+
for (const [E, a] of e2.split(" ").entries()) {
|
|
376
|
+
t.trim !== false && (C2[C2.length - 1] = C2[C2.length - 1].trimStart());
|
|
377
|
+
let o2 = p(C2[C2.length - 1]);
|
|
378
|
+
if (E !== 0 && (o2 >= u2 && (t.wordWrap === false || t.trim === false) && (C2.push(""), o2 = 0), (o2 > 0 || t.trim === false) && (C2[C2.length - 1] += " ", o2++)), t.hard && D2[E] > u2) {
|
|
379
|
+
const c = u2 - o2, f = 1 + Math.floor((D2[E] - c - 1) / u2);
|
|
380
|
+
Math.floor((D2[E] - 1) / u2) < f && C2.push(""), k(C2, a, u2);
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (o2 + D2[E] > u2 && o2 > 0 && D2[E] > 0) {
|
|
384
|
+
if (t.wordWrap === false && o2 < u2) {
|
|
385
|
+
k(C2, a, u2);
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
C2.push("");
|
|
389
|
+
}
|
|
390
|
+
if (o2 + D2[E] > u2 && t.wordWrap === false) {
|
|
391
|
+
k(C2, a, u2);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
C2[C2.length - 1] += a;
|
|
395
|
+
}
|
|
396
|
+
t.trim !== false && (C2 = C2.map((E) => hD(E)));
|
|
397
|
+
const n = [...C2.join(`
|
|
398
|
+
`)];
|
|
399
|
+
for (const [E, a] of n.entries()) {
|
|
400
|
+
if (F2 += a, d.has(a)) {
|
|
401
|
+
const { groups: c } = new RegExp(`(?:\\${V}(?<code>\\d+)m|\\${_}(?<uri>.*)${y})`).exec(n.slice(E).join("")) || { groups: {} };
|
|
402
|
+
if (c.code !== void 0) {
|
|
403
|
+
const f = Number.parseFloat(c.code);
|
|
404
|
+
s = f === oD ? void 0 : f;
|
|
405
|
+
} else c.uri !== void 0 && (i = c.uri.length === 0 ? void 0 : c.uri);
|
|
406
|
+
}
|
|
407
|
+
const o2 = ED.codes.get(Number(s));
|
|
408
|
+
n[E + 1] === `
|
|
409
|
+
` ? (i && (F2 += K("")), s && o2 && (F2 += z(o2))) : a === `
|
|
410
|
+
` && (s && o2 && (F2 += z(s)), i && (F2 += K(i)));
|
|
411
|
+
}
|
|
412
|
+
return F2;
|
|
413
|
+
};
|
|
414
|
+
xD = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
415
|
+
B = { actions: new Set(xD), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]) };
|
|
416
|
+
AD = globalThis.process.platform.startsWith("win");
|
|
417
|
+
S = /* @__PURE__ */ Symbol("clack:cancel");
|
|
418
|
+
gD = Object.defineProperty;
|
|
419
|
+
vD = (e2, u2, t) => u2 in e2 ? gD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
|
|
420
|
+
h = (e2, u2, t) => (vD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
|
|
421
|
+
x = class {
|
|
422
|
+
constructor(u2, t = true) {
|
|
423
|
+
h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
|
|
424
|
+
const { input: F2 = import_node_process.stdin, output: s = import_node_process.stdout, render: i, signal: D2, ...C2 } = u2;
|
|
425
|
+
this.opts = C2, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = t, this._abortSignal = D2, this.input = F2, this.output = s;
|
|
426
|
+
}
|
|
427
|
+
unsubscribe() {
|
|
428
|
+
this._subscribers.clear();
|
|
429
|
+
}
|
|
430
|
+
setSubscriber(u2, t) {
|
|
431
|
+
const F2 = this._subscribers.get(u2) ?? [];
|
|
432
|
+
F2.push(t), this._subscribers.set(u2, F2);
|
|
433
|
+
}
|
|
434
|
+
on(u2, t) {
|
|
435
|
+
this.setSubscriber(u2, { cb: t });
|
|
436
|
+
}
|
|
437
|
+
once(u2, t) {
|
|
438
|
+
this.setSubscriber(u2, { cb: t, once: true });
|
|
439
|
+
}
|
|
440
|
+
emit(u2, ...t) {
|
|
441
|
+
const F2 = this._subscribers.get(u2) ?? [], s = [];
|
|
442
|
+
for (const i of F2) i.cb(...t), i.once && s.push(() => F2.splice(F2.indexOf(i), 1));
|
|
443
|
+
for (const i of s) i();
|
|
444
|
+
}
|
|
445
|
+
prompt() {
|
|
446
|
+
return new Promise((u2, t) => {
|
|
447
|
+
if (this._abortSignal) {
|
|
448
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u2(S);
|
|
449
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
450
|
+
this.state = "cancel", this.close();
|
|
451
|
+
}, { once: true });
|
|
452
|
+
}
|
|
453
|
+
const F2 = new import_node_stream.Writable();
|
|
454
|
+
F2._write = (s, i, D2) => {
|
|
455
|
+
this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D2();
|
|
456
|
+
}, this.input.pipe(F2), this.rl = import_node_readline.default.createInterface({ input: this.input, output: F2, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), import_node_readline.default.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== void 0 && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), m(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
457
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u2(this.value);
|
|
458
|
+
}), this.once("cancel", () => {
|
|
459
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), m(this.input, false), u2(S);
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
onKeypress(u2, t) {
|
|
464
|
+
if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.name)), u2 && (u2.toLowerCase() === "y" || u2.toLowerCase() === "n") && this.emit("confirm", u2.toLowerCase() === "y"), u2 === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u2 && this.emit("key", u2.toLowerCase()), t?.name === "return") {
|
|
465
|
+
if (this.opts.validate) {
|
|
466
|
+
const F2 = this.opts.validate(this.value);
|
|
467
|
+
F2 && (this.error = F2 instanceof Error ? F2.message : F2, this.state = "error", this.rl?.write(this.value));
|
|
468
|
+
}
|
|
469
|
+
this.state !== "error" && (this.state = "submit");
|
|
470
|
+
}
|
|
471
|
+
$([u2, t?.name, t?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
472
|
+
}
|
|
473
|
+
close() {
|
|
474
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
475
|
+
`), m(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
476
|
+
}
|
|
477
|
+
restoreCursor() {
|
|
478
|
+
const u2 = Y(this._prevFrame, process.stdout.columns, { hard: true }).split(`
|
|
479
|
+
`).length - 1;
|
|
480
|
+
this.output.write(import_sisteransi.cursor.move(-999, u2 * -1));
|
|
481
|
+
}
|
|
482
|
+
render() {
|
|
483
|
+
const u2 = Y(this._render(this) ?? "", process.stdout.columns, { hard: true });
|
|
484
|
+
if (u2 !== this._prevFrame) {
|
|
485
|
+
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
486
|
+
else {
|
|
487
|
+
const t = BD(this._prevFrame, u2);
|
|
488
|
+
if (this.restoreCursor(), t && t?.length === 1) {
|
|
489
|
+
const F2 = t[0];
|
|
490
|
+
this.output.write(import_sisteransi.cursor.move(0, F2)), this.output.write(import_sisteransi.erase.lines(1));
|
|
491
|
+
const s = u2.split(`
|
|
492
|
+
`);
|
|
493
|
+
this.output.write(s[F2]), this._prevFrame = u2, this.output.write(import_sisteransi.cursor.move(0, s.length - F2 - 1));
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (t && t?.length > 1) {
|
|
497
|
+
const F2 = t[0];
|
|
498
|
+
this.output.write(import_sisteransi.cursor.move(0, F2)), this.output.write(import_sisteransi.erase.down());
|
|
499
|
+
const s = u2.split(`
|
|
500
|
+
`).slice(F2);
|
|
501
|
+
this.output.write(s.join(`
|
|
502
|
+
`)), this._prevFrame = u2;
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
this.output.write(import_sisteransi.erase.down());
|
|
506
|
+
}
|
|
507
|
+
this.output.write(u2), this.state === "initial" && (this.state = "active"), this._prevFrame = u2;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
dD = class extends x {
|
|
512
|
+
get cursor() {
|
|
513
|
+
return this.value ? 0 : 1;
|
|
514
|
+
}
|
|
515
|
+
get _value() {
|
|
516
|
+
return this.cursor === 0;
|
|
517
|
+
}
|
|
518
|
+
constructor(u2) {
|
|
519
|
+
super(u2, false), this.value = !!u2.initialValue, this.on("value", () => {
|
|
520
|
+
this.value = this._value;
|
|
521
|
+
}), this.on("confirm", (t) => {
|
|
522
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
|
|
523
|
+
}), this.on("cursor", () => {
|
|
524
|
+
this.value = !this.value;
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
mD = Object.defineProperty;
|
|
529
|
+
bD = (e2, u2, t) => u2 in e2 ? mD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
|
|
530
|
+
Z = (e2, u2, t) => (bD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
|
|
531
|
+
q = (e2, u2, t) => {
|
|
532
|
+
if (!u2.has(e2)) throw TypeError("Cannot " + t);
|
|
533
|
+
};
|
|
534
|
+
T = (e2, u2, t) => (q(e2, u2, "read from private field"), t ? t.call(e2) : u2.get(e2));
|
|
535
|
+
wD = (e2, u2, t) => {
|
|
536
|
+
if (u2.has(e2)) throw TypeError("Cannot add the same private member more than once");
|
|
537
|
+
u2 instanceof WeakSet ? u2.add(e2) : u2.set(e2, t);
|
|
538
|
+
};
|
|
539
|
+
yD = (e2, u2, t, F2) => (q(e2, u2, "write to private field"), F2 ? F2.call(e2, t) : u2.set(e2, t), t);
|
|
540
|
+
_D = class extends x {
|
|
541
|
+
constructor(u2) {
|
|
542
|
+
super(u2, false), Z(this, "options"), Z(this, "cursor", 0), wD(this, A, void 0);
|
|
543
|
+
const { options: t } = u2;
|
|
544
|
+
yD(this, A, u2.selectableGroups !== false), this.options = Object.entries(t).flatMap(([F2, s]) => [{ value: F2, group: true, label: F2 }, ...s.map((i) => ({ ...i, group: F2 }))]), this.value = [...u2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F2 }) => F2 === u2.cursorAt), T(this, A) ? 0 : 1), this.on("cursor", (F2) => {
|
|
545
|
+
switch (F2) {
|
|
546
|
+
case "left":
|
|
547
|
+
case "up": {
|
|
548
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
549
|
+
const s = this.options[this.cursor]?.group === true;
|
|
550
|
+
!T(this, A) && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
case "down":
|
|
554
|
+
case "right": {
|
|
555
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
556
|
+
const s = this.options[this.cursor]?.group === true;
|
|
557
|
+
!T(this, A) && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
case "space":
|
|
561
|
+
this.toggleValue();
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
getGroupItems(u2) {
|
|
567
|
+
return this.options.filter((t) => t.group === u2);
|
|
568
|
+
}
|
|
569
|
+
isGroupSelected(u2) {
|
|
570
|
+
return this.getGroupItems(u2).every((t) => this.value.includes(t.value));
|
|
571
|
+
}
|
|
572
|
+
toggleValue() {
|
|
573
|
+
const u2 = this.options[this.cursor];
|
|
574
|
+
if (u2.group === true) {
|
|
575
|
+
const t = u2.value, F2 = this.getGroupItems(t);
|
|
576
|
+
this.isGroupSelected(t) ? this.value = this.value.filter((s) => F2.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...F2.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
577
|
+
} else {
|
|
578
|
+
const t = this.value.includes(u2.value);
|
|
579
|
+
this.value = t ? this.value.filter((F2) => F2 !== u2.value) : [...this.value, u2.value];
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
A = /* @__PURE__ */ new WeakMap();
|
|
584
|
+
kD = Object.defineProperty;
|
|
585
|
+
$D = (e2, u2, t) => u2 in e2 ? kD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
|
|
586
|
+
H = (e2, u2, t) => ($D(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
|
|
587
|
+
SD = class extends x {
|
|
588
|
+
constructor(u2) {
|
|
589
|
+
super(u2, false), H(this, "options"), H(this, "cursor", 0), this.options = u2.options, this.value = [...u2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u2.cursorAt), 0), this.on("key", (t) => {
|
|
590
|
+
t === "a" && this.toggleAll();
|
|
591
|
+
}), this.on("cursor", (t) => {
|
|
592
|
+
switch (t) {
|
|
593
|
+
case "left":
|
|
594
|
+
case "up":
|
|
595
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
596
|
+
break;
|
|
597
|
+
case "down":
|
|
598
|
+
case "right":
|
|
599
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
600
|
+
break;
|
|
601
|
+
case "space":
|
|
602
|
+
this.toggleValue();
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
get _value() {
|
|
608
|
+
return this.options[this.cursor].value;
|
|
609
|
+
}
|
|
610
|
+
toggleAll() {
|
|
611
|
+
const u2 = this.value.length === this.options.length;
|
|
612
|
+
this.value = u2 ? [] : this.options.map((t) => t.value);
|
|
613
|
+
}
|
|
614
|
+
toggleValue() {
|
|
615
|
+
const u2 = this.value.includes(this._value);
|
|
616
|
+
this.value = u2 ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
TD = Object.defineProperty;
|
|
620
|
+
jD = (e2, u2, t) => u2 in e2 ? TD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
|
|
621
|
+
U = (e2, u2, t) => (jD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
|
|
622
|
+
MD = class extends x {
|
|
623
|
+
constructor({ mask: u2, ...t }) {
|
|
624
|
+
super(t), U(this, "valueWithCursor", ""), U(this, "_mask", "\u2022"), this._mask = u2 ?? "\u2022", this.on("finalize", () => {
|
|
625
|
+
this.valueWithCursor = this.masked;
|
|
626
|
+
}), this.on("value", () => {
|
|
627
|
+
if (this.cursor >= this.value.length) this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
|
|
628
|
+
else {
|
|
629
|
+
const F2 = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
|
|
630
|
+
this.valueWithCursor = `${F2}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
get cursor() {
|
|
635
|
+
return this._cursor;
|
|
636
|
+
}
|
|
637
|
+
get masked() {
|
|
638
|
+
return this.value.replaceAll(/./g, this._mask);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
OD = Object.defineProperty;
|
|
642
|
+
PD = (e2, u2, t) => u2 in e2 ? OD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
|
|
643
|
+
J = (e2, u2, t) => (PD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
|
|
644
|
+
LD = class extends x {
|
|
645
|
+
constructor(u2) {
|
|
646
|
+
super(u2, false), J(this, "options"), J(this, "cursor", 0), this.options = u2.options, this.cursor = this.options.findIndex(({ value: t }) => t === u2.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
|
|
647
|
+
switch (t) {
|
|
648
|
+
case "left":
|
|
649
|
+
case "up":
|
|
650
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
651
|
+
break;
|
|
652
|
+
case "down":
|
|
653
|
+
case "right":
|
|
654
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
this.changeValue();
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
get _value() {
|
|
661
|
+
return this.options[this.cursor];
|
|
662
|
+
}
|
|
663
|
+
changeValue() {
|
|
664
|
+
this.value = this._value.value;
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
WD = Object.defineProperty;
|
|
668
|
+
ND = (e2, u2, t) => u2 in e2 ? WD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
|
|
669
|
+
Q = (e2, u2, t) => (ND(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
|
|
670
|
+
ID = class extends x {
|
|
671
|
+
constructor(u2) {
|
|
672
|
+
super(u2, false), Q(this, "options"), Q(this, "cursor", 0), this.options = u2.options;
|
|
673
|
+
const t = this.options.map(({ value: [F2] }) => F2?.toLowerCase());
|
|
674
|
+
this.cursor = Math.max(t.indexOf(u2.initialValue), 0), this.on("key", (F2) => {
|
|
675
|
+
if (!t.includes(F2)) return;
|
|
676
|
+
const s = this.options.find(({ value: [i] }) => i?.toLowerCase() === F2);
|
|
677
|
+
s && (this.value = s.value, this.state = "submit", this.emit("submit"));
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
RD = class extends x {
|
|
682
|
+
get valueWithCursor() {
|
|
683
|
+
if (this.state === "submit") return this.value;
|
|
684
|
+
if (this.cursor >= this.value.length) return `${this.value}\u2588`;
|
|
685
|
+
const u2 = this.value.slice(0, this.cursor), [t, ...F2] = this.value.slice(this.cursor);
|
|
686
|
+
return `${u2}${import_picocolors.default.inverse(t)}${F2.join("")}`;
|
|
687
|
+
}
|
|
688
|
+
get cursor() {
|
|
689
|
+
return this._cursor;
|
|
690
|
+
}
|
|
691
|
+
constructor(u2) {
|
|
692
|
+
super(u2), this.on("finalize", () => {
|
|
693
|
+
this.value || (this.value = u2.defaultValue);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
// ../../node_modules/.pnpm/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs
|
|
701
|
+
var dist_exports = {};
|
|
702
|
+
__export(dist_exports, {
|
|
703
|
+
cancel: () => xe,
|
|
704
|
+
confirm: () => ye,
|
|
705
|
+
group: () => Ce,
|
|
706
|
+
groupMultiselect: () => be,
|
|
707
|
+
intro: () => Ie,
|
|
708
|
+
isCancel: () => pD,
|
|
709
|
+
log: () => M2,
|
|
710
|
+
multiselect: () => fe,
|
|
711
|
+
note: () => Me,
|
|
712
|
+
outro: () => Se,
|
|
713
|
+
password: () => ge,
|
|
714
|
+
select: () => ve,
|
|
715
|
+
selectKey: () => we,
|
|
716
|
+
spinner: () => Y2,
|
|
717
|
+
stream: () => x2,
|
|
718
|
+
tasks: () => Te,
|
|
719
|
+
text: () => he,
|
|
720
|
+
updateSettings: () => cD
|
|
721
|
+
});
|
|
722
|
+
function ce() {
|
|
723
|
+
return import_node_process2.default.platform !== "win32" ? import_node_process2.default.env.TERM !== "linux" : !!import_node_process2.default.env.CI || !!import_node_process2.default.env.WT_SESSION || !!import_node_process2.default.env.TERMINUS_SUBLIME || import_node_process2.default.env.ConEmuTask === "{cmd::Cmder}" || import_node_process2.default.env.TERM_PROGRAM === "Terminus-Sublime" || import_node_process2.default.env.TERM_PROGRAM === "vscode" || import_node_process2.default.env.TERM === "xterm-256color" || import_node_process2.default.env.TERM === "alacritty" || import_node_process2.default.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
724
|
+
}
|
|
725
|
+
var import_node_util, import_node_process2, import_picocolors2, import_sisteransi2, V2, u, le, L2, W2, C, ue, o, d2, k2, P2, A2, T2, F, $e, _2, me, de, pe, q2, D, U2, K2, b2, G2, he, ge, ye, ve, we, fe, be, Me, xe, Ie, Se, M2, J2, x2, Y2, Ce, Te;
|
|
726
|
+
var init_dist2 = __esm({
|
|
727
|
+
"../../node_modules/.pnpm/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs"() {
|
|
728
|
+
"use strict";
|
|
729
|
+
import_node_util = require("node:util");
|
|
730
|
+
init_dist();
|
|
731
|
+
init_dist();
|
|
732
|
+
import_node_process2 = __toESM(require("node:process"), 1);
|
|
733
|
+
import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
734
|
+
import_sisteransi2 = __toESM(require_src(), 1);
|
|
735
|
+
V2 = ce();
|
|
736
|
+
u = (t, n) => V2 ? t : n;
|
|
737
|
+
le = u("\u25C6", "*");
|
|
738
|
+
L2 = u("\u25A0", "x");
|
|
739
|
+
W2 = u("\u25B2", "x");
|
|
740
|
+
C = u("\u25C7", "o");
|
|
741
|
+
ue = u("\u250C", "T");
|
|
742
|
+
o = u("\u2502", "|");
|
|
743
|
+
d2 = u("\u2514", "\u2014");
|
|
744
|
+
k2 = u("\u25CF", ">");
|
|
745
|
+
P2 = u("\u25CB", " ");
|
|
746
|
+
A2 = u("\u25FB", "[\u2022]");
|
|
747
|
+
T2 = u("\u25FC", "[+]");
|
|
748
|
+
F = u("\u25FB", "[ ]");
|
|
749
|
+
$e = u("\u25AA", "\u2022");
|
|
750
|
+
_2 = u("\u2500", "-");
|
|
751
|
+
me = u("\u256E", "+");
|
|
752
|
+
de = u("\u251C", "+");
|
|
753
|
+
pe = u("\u256F", "+");
|
|
754
|
+
q2 = u("\u25CF", "\u2022");
|
|
755
|
+
D = u("\u25C6", "*");
|
|
756
|
+
U2 = u("\u25B2", "!");
|
|
757
|
+
K2 = u("\u25A0", "x");
|
|
758
|
+
b2 = (t) => {
|
|
759
|
+
switch (t) {
|
|
760
|
+
case "initial":
|
|
761
|
+
case "active":
|
|
762
|
+
return import_picocolors2.default.cyan(le);
|
|
763
|
+
case "cancel":
|
|
764
|
+
return import_picocolors2.default.red(L2);
|
|
765
|
+
case "error":
|
|
766
|
+
return import_picocolors2.default.yellow(W2);
|
|
767
|
+
case "submit":
|
|
768
|
+
return import_picocolors2.default.green(C);
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
G2 = (t) => {
|
|
772
|
+
const { cursor: n, options: r2, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
|
|
773
|
+
let l2 = 0;
|
|
774
|
+
n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
|
|
775
|
+
const $2 = a < r2.length && l2 > 0, g2 = a < r2.length && l2 + a < r2.length;
|
|
776
|
+
return r2.slice(l2, l2 + a).map((p2, v2, f) => {
|
|
777
|
+
const j2 = v2 === 0 && $2, E = v2 === f.length - 1 && g2;
|
|
778
|
+
return j2 || E ? import_picocolors2.default.dim("...") : i(p2, v2 + l2 === n);
|
|
779
|
+
});
|
|
780
|
+
};
|
|
781
|
+
he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
|
|
782
|
+
const n = `${import_picocolors2.default.gray(o)}
|
|
783
|
+
${b2(this.state)} ${t.message}
|
|
784
|
+
`, r2 = 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("_")), i = this.value ? this.valueWithCursor : r2;
|
|
785
|
+
switch (this.state) {
|
|
786
|
+
case "error":
|
|
787
|
+
return `${n.trim()}
|
|
788
|
+
${import_picocolors2.default.yellow(o)} ${i}
|
|
789
|
+
${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
|
|
790
|
+
`;
|
|
791
|
+
case "submit":
|
|
792
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(this.value || t.placeholder)}`;
|
|
793
|
+
case "cancel":
|
|
794
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
795
|
+
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
796
|
+
default:
|
|
797
|
+
return `${n}${import_picocolors2.default.cyan(o)} ${i}
|
|
798
|
+
${import_picocolors2.default.cyan(d2)}
|
|
799
|
+
`;
|
|
800
|
+
}
|
|
801
|
+
} }).prompt();
|
|
802
|
+
ge = (t) => new MD({ validate: t.validate, mask: t.mask ?? $e, render() {
|
|
803
|
+
const n = `${import_picocolors2.default.gray(o)}
|
|
804
|
+
${b2(this.state)} ${t.message}
|
|
805
|
+
`, r2 = this.valueWithCursor, i = this.masked;
|
|
806
|
+
switch (this.state) {
|
|
807
|
+
case "error":
|
|
808
|
+
return `${n.trim()}
|
|
809
|
+
${import_picocolors2.default.yellow(o)} ${i}
|
|
810
|
+
${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
|
|
811
|
+
`;
|
|
812
|
+
case "submit":
|
|
813
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(i)}`;
|
|
814
|
+
case "cancel":
|
|
815
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(i ?? ""))}${i ? `
|
|
816
|
+
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
817
|
+
default:
|
|
818
|
+
return `${n}${import_picocolors2.default.cyan(o)} ${r2}
|
|
819
|
+
${import_picocolors2.default.cyan(d2)}
|
|
820
|
+
`;
|
|
821
|
+
}
|
|
822
|
+
} }).prompt();
|
|
823
|
+
ye = (t) => {
|
|
824
|
+
const n = t.active ?? "Yes", r2 = t.inactive ?? "No";
|
|
825
|
+
return new dD({ active: n, inactive: r2, initialValue: t.initialValue ?? true, render() {
|
|
826
|
+
const i = `${import_picocolors2.default.gray(o)}
|
|
827
|
+
${b2(this.state)} ${t.message}
|
|
828
|
+
`, s = this.value ? n : r2;
|
|
829
|
+
switch (this.state) {
|
|
830
|
+
case "submit":
|
|
831
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(s)}`;
|
|
832
|
+
case "cancel":
|
|
833
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
|
|
834
|
+
${import_picocolors2.default.gray(o)}`;
|
|
835
|
+
default:
|
|
836
|
+
return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(r2)}` : `${import_picocolors2.default.green(k2)} ${r2}`}
|
|
837
|
+
${import_picocolors2.default.cyan(d2)}
|
|
838
|
+
`;
|
|
839
|
+
}
|
|
840
|
+
} }).prompt();
|
|
841
|
+
};
|
|
842
|
+
ve = (t) => {
|
|
843
|
+
const n = (r2, i) => {
|
|
844
|
+
const s = r2.label ?? String(r2.value);
|
|
845
|
+
switch (i) {
|
|
846
|
+
case "selected":
|
|
847
|
+
return `${import_picocolors2.default.dim(s)}`;
|
|
848
|
+
case "active":
|
|
849
|
+
return `${import_picocolors2.default.green(k2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}`;
|
|
850
|
+
case "cancelled":
|
|
851
|
+
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
|
|
852
|
+
default:
|
|
853
|
+
return `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(s)}`;
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
857
|
+
const r2 = `${import_picocolors2.default.gray(o)}
|
|
858
|
+
${b2(this.state)} ${t.message}
|
|
859
|
+
`;
|
|
860
|
+
switch (this.state) {
|
|
861
|
+
case "submit":
|
|
862
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
863
|
+
case "cancel":
|
|
864
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
865
|
+
${import_picocolors2.default.gray(o)}`;
|
|
866
|
+
default:
|
|
867
|
+
return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
|
|
868
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
869
|
+
${import_picocolors2.default.cyan(d2)}
|
|
870
|
+
`;
|
|
871
|
+
}
|
|
872
|
+
} }).prompt();
|
|
873
|
+
};
|
|
874
|
+
we = (t) => {
|
|
875
|
+
const n = (r2, i = "inactive") => {
|
|
876
|
+
const s = r2.label ?? String(r2.value);
|
|
877
|
+
return i === "selected" ? `${import_picocolors2.default.dim(s)}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : i === "active" ? `${import_picocolors2.default.bgCyan(import_picocolors2.default.gray(` ${r2.value} `))} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : `${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(` ${r2.value} `)))} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}`;
|
|
878
|
+
};
|
|
879
|
+
return new ID({ options: t.options, initialValue: t.initialValue, render() {
|
|
880
|
+
const r2 = `${import_picocolors2.default.gray(o)}
|
|
881
|
+
${b2(this.state)} ${t.message}
|
|
882
|
+
`;
|
|
883
|
+
switch (this.state) {
|
|
884
|
+
case "submit":
|
|
885
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options.find((i) => i.value === this.value) ?? t.options[0], "selected")}`;
|
|
886
|
+
case "cancel":
|
|
887
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[0], "cancelled")}
|
|
888
|
+
${import_picocolors2.default.gray(o)}`;
|
|
889
|
+
default:
|
|
890
|
+
return `${r2}${import_picocolors2.default.cyan(o)} ${this.options.map((i, s) => n(i, s === this.cursor ? "active" : "inactive")).join(`
|
|
891
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
892
|
+
${import_picocolors2.default.cyan(d2)}
|
|
893
|
+
`;
|
|
894
|
+
}
|
|
895
|
+
} }).prompt();
|
|
896
|
+
};
|
|
897
|
+
fe = (t) => {
|
|
898
|
+
const n = (r2, i) => {
|
|
899
|
+
const s = r2.label ?? String(r2.value);
|
|
900
|
+
return i === "active" ? `${import_picocolors2.default.cyan(A2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "selected" ? `${import_picocolors2.default.green(T2)} ${import_picocolors2.default.dim(s)} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : i === "active-selected" ? `${import_picocolors2.default.green(T2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(F)} ${import_picocolors2.default.dim(s)}`;
|
|
901
|
+
};
|
|
902
|
+
return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r2) {
|
|
903
|
+
if (this.required && r2.length === 0) return `Please select at least one option.
|
|
904
|
+
${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
|
|
905
|
+
}, render() {
|
|
906
|
+
const r2 = `${import_picocolors2.default.gray(o)}
|
|
907
|
+
${b2(this.state)} ${t.message}
|
|
908
|
+
`, i = (s, c) => {
|
|
909
|
+
const a = this.value.includes(s.value);
|
|
910
|
+
return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
|
|
911
|
+
};
|
|
912
|
+
switch (this.state) {
|
|
913
|
+
case "submit":
|
|
914
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
|
|
915
|
+
case "cancel": {
|
|
916
|
+
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors2.default.dim(", "));
|
|
917
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
|
|
918
|
+
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
919
|
+
}
|
|
920
|
+
case "error": {
|
|
921
|
+
const s = this.error.split(`
|
|
922
|
+
`).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
|
|
923
|
+
`);
|
|
924
|
+
return `${r2 + import_picocolors2.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
925
|
+
${import_picocolors2.default.yellow(o)} `)}
|
|
926
|
+
${s}
|
|
927
|
+
`;
|
|
928
|
+
}
|
|
929
|
+
default:
|
|
930
|
+
return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
931
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
932
|
+
${import_picocolors2.default.cyan(d2)}
|
|
933
|
+
`;
|
|
934
|
+
}
|
|
935
|
+
} }).prompt();
|
|
936
|
+
};
|
|
937
|
+
be = (t) => {
|
|
938
|
+
const { selectableGroups: n = true } = t, r2 = (i, s, c = []) => {
|
|
939
|
+
const a = i.label ?? String(i.value), l2 = typeof i.group == "string", $2 = l2 && (c[c.indexOf(i) + 1] ?? { group: true }), g2 = l2 && $2.group === true, p2 = l2 ? n ? `${g2 ? d2 : o} ` : " " : "";
|
|
940
|
+
if (s === "active") return `${import_picocolors2.default.dim(p2)}${import_picocolors2.default.cyan(A2)} ${a} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}`;
|
|
941
|
+
if (s === "group-active") return `${p2}${import_picocolors2.default.cyan(A2)} ${import_picocolors2.default.dim(a)}`;
|
|
942
|
+
if (s === "group-active-selected") return `${p2}${import_picocolors2.default.green(T2)} ${import_picocolors2.default.dim(a)}`;
|
|
943
|
+
if (s === "selected") {
|
|
944
|
+
const f = l2 || n ? import_picocolors2.default.green(T2) : "";
|
|
945
|
+
return `${import_picocolors2.default.dim(p2)}${f} ${import_picocolors2.default.dim(a)} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}`;
|
|
946
|
+
}
|
|
947
|
+
if (s === "cancelled") return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(a))}`;
|
|
948
|
+
if (s === "active-selected") return `${import_picocolors2.default.dim(p2)}${import_picocolors2.default.green(T2)} ${a} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}`;
|
|
949
|
+
if (s === "submitted") return `${import_picocolors2.default.dim(a)}`;
|
|
950
|
+
const v2 = l2 || n ? import_picocolors2.default.dim(F) : "";
|
|
951
|
+
return `${import_picocolors2.default.dim(p2)}${v2} ${import_picocolors2.default.dim(a)}`;
|
|
952
|
+
};
|
|
953
|
+
return new _D({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, selectableGroups: n, validate(i) {
|
|
954
|
+
if (this.required && i.length === 0) return `Please select at least one option.
|
|
955
|
+
${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
|
|
956
|
+
}, render() {
|
|
957
|
+
const i = `${import_picocolors2.default.gray(o)}
|
|
958
|
+
${b2(this.state)} ${t.message}
|
|
959
|
+
`;
|
|
960
|
+
switch (this.state) {
|
|
961
|
+
case "submit":
|
|
962
|
+
return `${i}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r2(s, "submitted")).join(import_picocolors2.default.dim(", "))}`;
|
|
963
|
+
case "cancel": {
|
|
964
|
+
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r2(c, "cancelled")).join(import_picocolors2.default.dim(", "));
|
|
965
|
+
return `${i}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
|
|
966
|
+
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
967
|
+
}
|
|
968
|
+
case "error": {
|
|
969
|
+
const s = this.error.split(`
|
|
970
|
+
`).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
|
|
971
|
+
`);
|
|
972
|
+
return `${i}${import_picocolors2.default.yellow(o)} ${this.options.map((c, a, l2) => {
|
|
973
|
+
const $2 = this.value.includes(c.value) || c.group === true && this.isGroupSelected(`${c.value}`), g2 = a === this.cursor;
|
|
974
|
+
return !g2 && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r2(c, $2 ? "group-active-selected" : "group-active", l2) : g2 && $2 ? r2(c, "active-selected", l2) : $2 ? r2(c, "selected", l2) : r2(c, g2 ? "active" : "inactive", l2);
|
|
975
|
+
}).join(`
|
|
976
|
+
${import_picocolors2.default.yellow(o)} `)}
|
|
977
|
+
${s}
|
|
978
|
+
`;
|
|
979
|
+
}
|
|
980
|
+
default:
|
|
981
|
+
return `${i}${import_picocolors2.default.cyan(o)} ${this.options.map((s, c, a) => {
|
|
982
|
+
const l2 = this.value.includes(s.value) || s.group === true && this.isGroupSelected(`${s.value}`), $2 = c === this.cursor;
|
|
983
|
+
return !$2 && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r2(s, l2 ? "group-active-selected" : "group-active", a) : $2 && l2 ? r2(s, "active-selected", a) : l2 ? r2(s, "selected", a) : r2(s, $2 ? "active" : "inactive", a);
|
|
984
|
+
}).join(`
|
|
985
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
986
|
+
${import_picocolors2.default.cyan(d2)}
|
|
987
|
+
`;
|
|
988
|
+
}
|
|
989
|
+
} }).prompt();
|
|
990
|
+
};
|
|
991
|
+
Me = (t = "", n = "") => {
|
|
992
|
+
const r2 = `
|
|
993
|
+
${t}
|
|
994
|
+
`.split(`
|
|
995
|
+
`), i = (0, import_node_util.stripVTControlCharacters)(n).length, s = Math.max(r2.reduce((a, l2) => {
|
|
996
|
+
const $2 = (0, import_node_util.stripVTControlCharacters)(l2);
|
|
997
|
+
return $2.length > a ? $2.length : a;
|
|
998
|
+
}, 0), i) + 2, c = r2.map((a) => `${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(a)}${" ".repeat(s - (0, import_node_util.stripVTControlCharacters)(a).length)}${import_picocolors2.default.gray(o)}`).join(`
|
|
999
|
+
`);
|
|
1000
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
1001
|
+
${import_picocolors2.default.green(C)} ${import_picocolors2.default.reset(n)} ${import_picocolors2.default.gray(_2.repeat(Math.max(s - i - 1, 1)) + me)}
|
|
1002
|
+
${c}
|
|
1003
|
+
${import_picocolors2.default.gray(de + _2.repeat(s + 2) + pe)}
|
|
1004
|
+
`);
|
|
1005
|
+
};
|
|
1006
|
+
xe = (t = "") => {
|
|
1007
|
+
process.stdout.write(`${import_picocolors2.default.gray(d2)} ${import_picocolors2.default.red(t)}
|
|
1008
|
+
|
|
1009
|
+
`);
|
|
1010
|
+
};
|
|
1011
|
+
Ie = (t = "") => {
|
|
1012
|
+
process.stdout.write(`${import_picocolors2.default.gray(ue)} ${t}
|
|
1013
|
+
`);
|
|
1014
|
+
};
|
|
1015
|
+
Se = (t = "") => {
|
|
1016
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
1017
|
+
${import_picocolors2.default.gray(d2)} ${t}
|
|
1018
|
+
|
|
1019
|
+
`);
|
|
1020
|
+
};
|
|
1021
|
+
M2 = { message: (t = "", { symbol: n = import_picocolors2.default.gray(o) } = {}) => {
|
|
1022
|
+
const r2 = [`${import_picocolors2.default.gray(o)}`];
|
|
1023
|
+
if (t) {
|
|
1024
|
+
const [i, ...s] = t.split(`
|
|
1025
|
+
`);
|
|
1026
|
+
r2.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors2.default.gray(o)} ${c}`));
|
|
1027
|
+
}
|
|
1028
|
+
process.stdout.write(`${r2.join(`
|
|
1029
|
+
`)}
|
|
1030
|
+
`);
|
|
1031
|
+
}, info: (t) => {
|
|
1032
|
+
M2.message(t, { symbol: import_picocolors2.default.blue(q2) });
|
|
1033
|
+
}, success: (t) => {
|
|
1034
|
+
M2.message(t, { symbol: import_picocolors2.default.green(D) });
|
|
1035
|
+
}, step: (t) => {
|
|
1036
|
+
M2.message(t, { symbol: import_picocolors2.default.green(C) });
|
|
1037
|
+
}, warn: (t) => {
|
|
1038
|
+
M2.message(t, { symbol: import_picocolors2.default.yellow(U2) });
|
|
1039
|
+
}, warning: (t) => {
|
|
1040
|
+
M2.warn(t);
|
|
1041
|
+
}, error: (t) => {
|
|
1042
|
+
M2.message(t, { symbol: import_picocolors2.default.red(K2) });
|
|
1043
|
+
} };
|
|
1044
|
+
J2 = `${import_picocolors2.default.gray(o)} `;
|
|
1045
|
+
x2 = { message: async (t, { symbol: n = import_picocolors2.default.gray(o) } = {}) => {
|
|
1046
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
1047
|
+
${n} `);
|
|
1048
|
+
let r2 = 3;
|
|
1049
|
+
for await (let i of t) {
|
|
1050
|
+
i = i.replace(/\n/g, `
|
|
1051
|
+
${J2}`), i.includes(`
|
|
1052
|
+
`) && (r2 = 3 + (0, import_node_util.stripVTControlCharacters)(i.slice(i.lastIndexOf(`
|
|
1053
|
+
`))).length);
|
|
1054
|
+
const s = (0, import_node_util.stripVTControlCharacters)(i).length;
|
|
1055
|
+
r2 + s < process.stdout.columns ? (r2 += s, process.stdout.write(i)) : (process.stdout.write(`
|
|
1056
|
+
${J2}${i.trimStart()}`), r2 = 3 + (0, import_node_util.stripVTControlCharacters)(i.trimStart()).length);
|
|
1057
|
+
}
|
|
1058
|
+
process.stdout.write(`
|
|
1059
|
+
`);
|
|
1060
|
+
}, info: (t) => x2.message(t, { symbol: import_picocolors2.default.blue(q2) }), success: (t) => x2.message(t, { symbol: import_picocolors2.default.green(D) }), step: (t) => x2.message(t, { symbol: import_picocolors2.default.green(C) }), warn: (t) => x2.message(t, { symbol: import_picocolors2.default.yellow(U2) }), warning: (t) => x2.warn(t), error: (t) => x2.message(t, { symbol: import_picocolors2.default.red(K2) }) };
|
|
1061
|
+
Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
1062
|
+
const n = V2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], r2 = V2 ? 80 : 120, i = process.env.CI === "true";
|
|
1063
|
+
let s, c, a = false, l2 = "", $2, g2 = performance.now();
|
|
1064
|
+
const p2 = (m2) => {
|
|
1065
|
+
const h2 = m2 > 1 ? "Something went wrong" : "Canceled";
|
|
1066
|
+
a && N2(h2, m2);
|
|
1067
|
+
}, v2 = () => p2(2), f = () => p2(1), j2 = () => {
|
|
1068
|
+
process.on("uncaughtExceptionMonitor", v2), process.on("unhandledRejection", v2), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p2);
|
|
1069
|
+
}, E = () => {
|
|
1070
|
+
process.removeListener("uncaughtExceptionMonitor", v2), process.removeListener("unhandledRejection", v2), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p2);
|
|
1071
|
+
}, B2 = () => {
|
|
1072
|
+
if ($2 === void 0) return;
|
|
1073
|
+
i && process.stdout.write(`
|
|
1074
|
+
`);
|
|
1075
|
+
const m2 = $2.split(`
|
|
1076
|
+
`);
|
|
1077
|
+
process.stdout.write(import_sisteransi2.cursor.move(-999, m2.length - 1)), process.stdout.write(import_sisteransi2.erase.down(m2.length));
|
|
1078
|
+
}, R2 = (m2) => m2.replace(/\.+$/, ""), O2 = (m2) => {
|
|
1079
|
+
const h2 = (performance.now() - m2) / 1e3, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
|
|
1080
|
+
return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
|
|
1081
|
+
}, H2 = (m2 = "") => {
|
|
1082
|
+
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
1083
|
+
`);
|
|
1084
|
+
let h2 = 0, w2 = 0;
|
|
1085
|
+
j2(), c = setInterval(() => {
|
|
1086
|
+
if (i && l2 === $2) return;
|
|
1087
|
+
B2(), $2 = l2;
|
|
1088
|
+
const I2 = import_picocolors2.default.magenta(n[h2]);
|
|
1089
|
+
if (i) process.stdout.write(`${I2} ${l2}...`);
|
|
1090
|
+
else if (t === "timer") process.stdout.write(`${I2} ${l2} ${O2(g2)}`);
|
|
1091
|
+
else {
|
|
1092
|
+
const z2 = ".".repeat(Math.floor(w2)).slice(0, 3);
|
|
1093
|
+
process.stdout.write(`${I2} ${l2}${z2}`);
|
|
1094
|
+
}
|
|
1095
|
+
h2 = h2 + 1 < n.length ? h2 + 1 : 0, w2 = w2 < n.length ? w2 + 0.125 : 0;
|
|
1096
|
+
}, r2);
|
|
1097
|
+
}, N2 = (m2 = "", h2 = 0) => {
|
|
1098
|
+
a = false, clearInterval(c), B2();
|
|
1099
|
+
const w2 = h2 === 0 ? import_picocolors2.default.green(C) : h2 === 1 ? import_picocolors2.default.red(L2) : import_picocolors2.default.red(W2);
|
|
1100
|
+
l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
|
|
1101
|
+
`) : process.stdout.write(`${w2} ${l2}
|
|
1102
|
+
`), E(), s();
|
|
1103
|
+
};
|
|
1104
|
+
return { start: H2, stop: N2, message: (m2 = "") => {
|
|
1105
|
+
l2 = R2(m2 ?? l2);
|
|
1106
|
+
} };
|
|
1107
|
+
};
|
|
1108
|
+
Ce = async (t, n) => {
|
|
1109
|
+
const r2 = {}, i = Object.keys(t);
|
|
1110
|
+
for (const s of i) {
|
|
1111
|
+
const c = t[s], a = await c({ results: r2 })?.catch((l2) => {
|
|
1112
|
+
throw l2;
|
|
1113
|
+
});
|
|
1114
|
+
if (typeof n?.onCancel == "function" && pD(a)) {
|
|
1115
|
+
r2[s] = "canceled", n.onCancel({ results: r2 });
|
|
1116
|
+
continue;
|
|
1117
|
+
}
|
|
1118
|
+
r2[s] = a;
|
|
1119
|
+
}
|
|
1120
|
+
return r2;
|
|
1121
|
+
};
|
|
1122
|
+
Te = async (t) => {
|
|
1123
|
+
for (const n of t) {
|
|
1124
|
+
if (n.enabled === false) continue;
|
|
1125
|
+
const r2 = Y2();
|
|
1126
|
+
r2.start(n.title);
|
|
1127
|
+
const i = await n.task(r2.message);
|
|
1128
|
+
r2.stop(i || n.title);
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
// src/agent/loader.ts
|
|
1135
|
+
var import_node_fs = require("node:fs");
|
|
1136
|
+
var import_node_url = require("node:url");
|
|
1137
|
+
var import_node_path3 = require("node:path");
|
|
1138
|
+
var import_picocolors3 = __toESM(require_picocolors());
|
|
1139
|
+
|
|
1140
|
+
// src/agent/envStore.ts
|
|
1141
|
+
var import_promises = require("node:fs/promises");
|
|
1142
|
+
var import_node_path = require("node:path");
|
|
1143
|
+
function createDefaultState() {
|
|
1144
|
+
return {
|
|
1145
|
+
version: 1,
|
|
1146
|
+
values: {}
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
function normalizeState(state) {
|
|
1150
|
+
const values = {};
|
|
1151
|
+
for (const [key, value] of Object.entries(state.values || {})) {
|
|
1152
|
+
const normalizedKey = key.trim();
|
|
1153
|
+
const normalizedValue = value.trim();
|
|
1154
|
+
if (!normalizedKey || !normalizedValue) {
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
values[normalizedKey] = normalizedValue;
|
|
1158
|
+
}
|
|
1159
|
+
return {
|
|
1160
|
+
version: 1,
|
|
1161
|
+
values
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
var AgentEnvStore = class {
|
|
1165
|
+
constructor(filePath) {
|
|
1166
|
+
this.filePath = filePath;
|
|
1167
|
+
}
|
|
1168
|
+
getFilePath() {
|
|
1169
|
+
return this.filePath;
|
|
1170
|
+
}
|
|
1171
|
+
async readState() {
|
|
1172
|
+
try {
|
|
1173
|
+
const raw = await (0, import_promises.readFile)(this.filePath, "utf8");
|
|
1174
|
+
const parsed = JSON.parse(raw);
|
|
1175
|
+
if (!parsed || parsed.version !== 1 || typeof parsed.values !== "object" || parsed.values === null) {
|
|
1176
|
+
return createDefaultState();
|
|
1177
|
+
}
|
|
1178
|
+
return normalizeState(parsed);
|
|
1179
|
+
} catch (error) {
|
|
1180
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
1181
|
+
return createDefaultState();
|
|
1182
|
+
}
|
|
1183
|
+
return createDefaultState();
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
async writeState(state) {
|
|
1187
|
+
const normalized = normalizeState(state);
|
|
1188
|
+
const directory = (0, import_node_path.dirname)(this.filePath);
|
|
1189
|
+
await (0, import_promises.mkdir)(directory, {
|
|
1190
|
+
recursive: true,
|
|
1191
|
+
mode: 448
|
|
1192
|
+
});
|
|
1193
|
+
await (0, import_promises.writeFile)(this.filePath, `${JSON.stringify(normalized, null, 2)}
|
|
1194
|
+
`, {
|
|
1195
|
+
encoding: "utf8",
|
|
1196
|
+
mode: 384
|
|
1197
|
+
});
|
|
1198
|
+
await (0, import_promises.chmod)(this.filePath, 384);
|
|
1199
|
+
}
|
|
1200
|
+
async setMany(values) {
|
|
1201
|
+
const state = await this.readState();
|
|
1202
|
+
await this.writeState({
|
|
1203
|
+
version: 1,
|
|
1204
|
+
values: {
|
|
1205
|
+
...state.values,
|
|
1206
|
+
...Object.fromEntries(
|
|
1207
|
+
Object.entries(values).map(([key, value]) => [key.trim(), value.trim()]).filter(([key, value]) => key.length > 0 && value.length > 0)
|
|
1208
|
+
)
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
async removeMany(keys) {
|
|
1213
|
+
const state = await this.readState();
|
|
1214
|
+
const nextValues = { ...state.values };
|
|
1215
|
+
for (const key of keys) {
|
|
1216
|
+
delete nextValues[key];
|
|
1217
|
+
}
|
|
1218
|
+
await this.writeState({
|
|
1219
|
+
version: 1,
|
|
1220
|
+
values: nextValues
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
async hydrateProcessEnv(env = process.env) {
|
|
1224
|
+
const state = await this.readState();
|
|
1225
|
+
for (const [key, value] of Object.entries(state.values)) {
|
|
1226
|
+
if (!env[key]) {
|
|
1227
|
+
env[key] = value;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
return state.values;
|
|
1231
|
+
}
|
|
1232
|
+
async hasAny(keys) {
|
|
1233
|
+
const state = await this.readState();
|
|
1234
|
+
return keys.some((key) => Boolean(state.values[key] || process.env[key]));
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// src/agent/modelsConfig.ts
|
|
1239
|
+
var import_promises2 = require("node:fs/promises");
|
|
1240
|
+
var import_node_path2 = require("node:path");
|
|
1241
|
+
function createDefaultState2() {
|
|
1242
|
+
return {
|
|
1243
|
+
providers: {}
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
async function readModelsConfig(filePath) {
|
|
1247
|
+
try {
|
|
1248
|
+
const raw = await (0, import_promises2.readFile)(filePath, "utf8");
|
|
1249
|
+
const parsed = JSON.parse(raw);
|
|
1250
|
+
if (!parsed || typeof parsed !== "object" || typeof parsed.providers !== "object" || parsed.providers === null) {
|
|
1251
|
+
return createDefaultState2();
|
|
1252
|
+
}
|
|
1253
|
+
return {
|
|
1254
|
+
providers: { ...parsed.providers }
|
|
1255
|
+
};
|
|
1256
|
+
} catch (error) {
|
|
1257
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
1258
|
+
return createDefaultState2();
|
|
1259
|
+
}
|
|
1260
|
+
return createDefaultState2();
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
async function writeModelsConfig(filePath, state) {
|
|
1264
|
+
const directory = (0, import_node_path2.dirname)(filePath);
|
|
1265
|
+
await (0, import_promises2.mkdir)(directory, {
|
|
1266
|
+
recursive: true,
|
|
1267
|
+
mode: 448
|
|
1268
|
+
});
|
|
1269
|
+
await (0, import_promises2.writeFile)(filePath, `${JSON.stringify(state, null, 2)}
|
|
1270
|
+
`, {
|
|
1271
|
+
encoding: "utf8",
|
|
1272
|
+
mode: 384
|
|
1273
|
+
});
|
|
1274
|
+
await (0, import_promises2.chmod)(filePath, 384);
|
|
1275
|
+
}
|
|
1276
|
+
async function upsertModelsProvider(filePath, providerId, providerConfig) {
|
|
1277
|
+
const state = await readModelsConfig(filePath);
|
|
1278
|
+
await writeModelsConfig(filePath, {
|
|
1279
|
+
providers: {
|
|
1280
|
+
...state.providers,
|
|
1281
|
+
[providerId]: providerConfig
|
|
1282
|
+
}
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
async function removeModelsProvider(filePath, providerId) {
|
|
1286
|
+
const state = await readModelsConfig(filePath);
|
|
1287
|
+
const nextProviders = { ...state.providers };
|
|
1288
|
+
delete nextProviders[providerId];
|
|
1289
|
+
await writeModelsConfig(filePath, {
|
|
1290
|
+
providers: nextProviders
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
function createCustomOpenAiProviderConfig(params) {
|
|
1294
|
+
return {
|
|
1295
|
+
baseUrl: params.baseUrl,
|
|
1296
|
+
apiKey: "env:CUSTOM_OPENAI_API_KEY",
|
|
1297
|
+
api: "openai-completions",
|
|
1298
|
+
models: [
|
|
1299
|
+
{
|
|
1300
|
+
id: params.modelId,
|
|
1301
|
+
name: params.modelId,
|
|
1302
|
+
reasoning: false,
|
|
1303
|
+
input: ["text"],
|
|
1304
|
+
contextWindow: 128e3,
|
|
1305
|
+
maxTokens: 16384,
|
|
1306
|
+
cost: {
|
|
1307
|
+
input: 0,
|
|
1308
|
+
output: 0,
|
|
1309
|
+
cacheRead: 0,
|
|
1310
|
+
cacheWrite: 0
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
]
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
function createAzureProviderConfig(params) {
|
|
1317
|
+
const providerConfig = {
|
|
1318
|
+
baseUrl: params.baseUrl,
|
|
1319
|
+
apiKey: "env:AZURE_OPENAI_API_KEY"
|
|
1320
|
+
};
|
|
1321
|
+
if (params.useCustomModel) {
|
|
1322
|
+
providerConfig.api = "azure-openai-responses";
|
|
1323
|
+
providerConfig.models = [
|
|
1324
|
+
{
|
|
1325
|
+
id: params.modelId,
|
|
1326
|
+
name: params.modelId,
|
|
1327
|
+
reasoning: false,
|
|
1328
|
+
input: ["text"],
|
|
1329
|
+
contextWindow: 128e3,
|
|
1330
|
+
maxTokens: 16384,
|
|
1331
|
+
cost: {
|
|
1332
|
+
input: 0,
|
|
1333
|
+
output: 0,
|
|
1334
|
+
cacheRead: 0,
|
|
1335
|
+
cacheWrite: 0
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
];
|
|
1339
|
+
}
|
|
1340
|
+
return providerConfig;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/agent/authFlows.ts
|
|
1344
|
+
function trimOrUndefined(value) {
|
|
1345
|
+
const trimmed = value?.trim();
|
|
1346
|
+
return trimmed && trimmed.length > 0 ? trimmed : void 0;
|
|
1347
|
+
}
|
|
1348
|
+
async function saveGenericApiKey(params) {
|
|
1349
|
+
params.authStorage.set(params.providerId, {
|
|
1350
|
+
type: "api_key",
|
|
1351
|
+
key: params.apiKey.trim()
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
async function saveCustomOpenAiConfig(params) {
|
|
1355
|
+
params.authStorage.set("custom-openai", {
|
|
1356
|
+
type: "api_key",
|
|
1357
|
+
key: params.apiKey.trim()
|
|
1358
|
+
});
|
|
1359
|
+
await params.envStore.removeMany([
|
|
1360
|
+
"CUSTOM_OPENAI_API_KEY"
|
|
1361
|
+
]);
|
|
1362
|
+
await params.envStore.setMany({
|
|
1363
|
+
CUSTOM_OPENAI_API_KEY: params.apiKey.trim()
|
|
1364
|
+
});
|
|
1365
|
+
await upsertModelsProvider(params.modelsJsonPath, "custom-openai", createCustomOpenAiProviderConfig({
|
|
1366
|
+
baseUrl: params.baseUrl.trim(),
|
|
1367
|
+
modelId: params.modelId.trim()
|
|
1368
|
+
}));
|
|
1369
|
+
params.settingsManager.setDefaultModelAndProvider("custom-openai", params.modelId.trim());
|
|
1370
|
+
}
|
|
1371
|
+
async function saveAzureConfig(params) {
|
|
1372
|
+
const modelId = params.modelId.trim();
|
|
1373
|
+
const useCustomModel = params.useCustomModel ?? false;
|
|
1374
|
+
params.authStorage.set("azure-openai-responses", {
|
|
1375
|
+
type: "api_key",
|
|
1376
|
+
key: params.apiKey.trim()
|
|
1377
|
+
});
|
|
1378
|
+
await params.envStore.removeMany([
|
|
1379
|
+
"AZURE_OPENAI_API_KEY",
|
|
1380
|
+
"AZURE_OPENAI_API_VERSION",
|
|
1381
|
+
"AZURE_OPENAI_DEPLOYMENT_NAME_MAP"
|
|
1382
|
+
]);
|
|
1383
|
+
const envValues = {
|
|
1384
|
+
AZURE_OPENAI_API_KEY: params.apiKey.trim()
|
|
1385
|
+
};
|
|
1386
|
+
const trimmedApiVersion = trimOrUndefined(params.apiVersion);
|
|
1387
|
+
if (trimmedApiVersion) {
|
|
1388
|
+
envValues.AZURE_OPENAI_API_VERSION = trimmedApiVersion;
|
|
1389
|
+
}
|
|
1390
|
+
const trimmedDeploymentName = trimOrUndefined(params.deploymentName);
|
|
1391
|
+
if (trimmedDeploymentName && trimmedDeploymentName !== modelId) {
|
|
1392
|
+
envValues.AZURE_OPENAI_DEPLOYMENT_NAME_MAP = JSON.stringify({
|
|
1393
|
+
[modelId]: trimmedDeploymentName
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
await params.envStore.setMany(envValues);
|
|
1397
|
+
await upsertModelsProvider(params.modelsJsonPath, "azure-openai-responses", createAzureProviderConfig({
|
|
1398
|
+
baseUrl: params.baseUrl.trim(),
|
|
1399
|
+
modelId,
|
|
1400
|
+
useCustomModel
|
|
1401
|
+
}));
|
|
1402
|
+
params.settingsManager.setDefaultModelAndProvider("azure-openai-responses", modelId);
|
|
1403
|
+
}
|
|
1404
|
+
async function saveBedrockConfig(params) {
|
|
1405
|
+
params.authStorage.set("amazon-bedrock", {
|
|
1406
|
+
type: "api_key",
|
|
1407
|
+
key: "aws-configured"
|
|
1408
|
+
});
|
|
1409
|
+
await params.envStore.removeMany([
|
|
1410
|
+
"AWS_PROFILE",
|
|
1411
|
+
"AWS_ACCESS_KEY_ID",
|
|
1412
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
1413
|
+
"AWS_SESSION_TOKEN",
|
|
1414
|
+
"AWS_REGION",
|
|
1415
|
+
"AWS_DEFAULT_REGION",
|
|
1416
|
+
"AWS_BEARER_TOKEN_BEDROCK"
|
|
1417
|
+
]);
|
|
1418
|
+
const envValues = {
|
|
1419
|
+
AWS_REGION: params.region.trim(),
|
|
1420
|
+
AWS_DEFAULT_REGION: params.region.trim()
|
|
1421
|
+
};
|
|
1422
|
+
const profile = trimOrUndefined(params.profile);
|
|
1423
|
+
if (profile) {
|
|
1424
|
+
envValues.AWS_PROFILE = profile;
|
|
1425
|
+
}
|
|
1426
|
+
const accessKeyId = trimOrUndefined(params.accessKeyId);
|
|
1427
|
+
const secretAccessKey = trimOrUndefined(params.secretAccessKey);
|
|
1428
|
+
if (accessKeyId && secretAccessKey) {
|
|
1429
|
+
envValues.AWS_ACCESS_KEY_ID = accessKeyId;
|
|
1430
|
+
envValues.AWS_SECRET_ACCESS_KEY = secretAccessKey;
|
|
1431
|
+
}
|
|
1432
|
+
const sessionToken = trimOrUndefined(params.sessionToken);
|
|
1433
|
+
if (sessionToken) {
|
|
1434
|
+
envValues.AWS_SESSION_TOKEN = sessionToken;
|
|
1435
|
+
}
|
|
1436
|
+
await params.envStore.setMany(envValues);
|
|
1437
|
+
params.settingsManager.setDefaultModelAndProvider("amazon-bedrock", params.modelId.trim());
|
|
1438
|
+
}
|
|
1439
|
+
async function clearProviderConfig(params) {
|
|
1440
|
+
params.authStorage.remove(params.providerId);
|
|
1441
|
+
if (params.providerId === "custom-openai") {
|
|
1442
|
+
await params.envStore.removeMany([
|
|
1443
|
+
"CUSTOM_OPENAI_API_KEY"
|
|
1444
|
+
]);
|
|
1445
|
+
await removeModelsProvider(params.modelsJsonPath, "custom-openai");
|
|
1446
|
+
}
|
|
1447
|
+
if (params.providerId === "azure-openai-responses") {
|
|
1448
|
+
await params.envStore.removeMany([
|
|
1449
|
+
"AZURE_OPENAI_API_KEY",
|
|
1450
|
+
"AZURE_OPENAI_API_VERSION",
|
|
1451
|
+
"AZURE_OPENAI_DEPLOYMENT_NAME_MAP"
|
|
1452
|
+
]);
|
|
1453
|
+
await removeModelsProvider(params.modelsJsonPath, "azure-openai-responses");
|
|
1454
|
+
}
|
|
1455
|
+
if (params.providerId === "amazon-bedrock") {
|
|
1456
|
+
await params.envStore.removeMany([
|
|
1457
|
+
"AWS_PROFILE",
|
|
1458
|
+
"AWS_ACCESS_KEY_ID",
|
|
1459
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
1460
|
+
"AWS_SESSION_TOKEN",
|
|
1461
|
+
"AWS_REGION",
|
|
1462
|
+
"AWS_DEFAULT_REGION",
|
|
1463
|
+
"AWS_BEARER_TOKEN_BEDROCK"
|
|
1464
|
+
]);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/agent/logo.ts
|
|
1469
|
+
var DOCYRUS_LOGO = [
|
|
1470
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557",
|
|
1471
|
+
"\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D",
|
|
1472
|
+
"\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557",
|
|
1473
|
+
"\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2554\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551",
|
|
1474
|
+
"\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551",
|
|
1475
|
+
"\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"
|
|
1476
|
+
];
|
|
1477
|
+
var DOCYRUS_LOGO_PRIMARY_HEX = "#ef4444";
|
|
1478
|
+
function colorizeHex(text, hex) {
|
|
1479
|
+
const normalizedHex = hex.replace("#", "");
|
|
1480
|
+
const red = parseInt(normalizedHex.slice(0, 2), 16);
|
|
1481
|
+
const green = parseInt(normalizedHex.slice(2, 4), 16);
|
|
1482
|
+
const blue = parseInt(normalizedHex.slice(4, 6), 16);
|
|
1483
|
+
return `\x1B[38;2;${red};${green};${blue}m${text}\x1B[0m`;
|
|
1484
|
+
}
|
|
1485
|
+
function renderDocyrusLogo(color = (text) => colorizeHex(text, DOCYRUS_LOGO_PRIMARY_HEX)) {
|
|
1486
|
+
return `
|
|
1487
|
+
${DOCYRUS_LOGO.map(color).join("\n")}
|
|
1488
|
+
`;
|
|
1489
|
+
}
|
|
1490
|
+
function renderDocyrusLogoPrimary() {
|
|
1491
|
+
return renderDocyrusLogo();
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// src/agent/providerCatalog.ts
|
|
1495
|
+
var OAUTH_ONLY_PROVIDER_IDS = /* @__PURE__ */ new Set([
|
|
1496
|
+
"github-copilot",
|
|
1497
|
+
"openai-codex",
|
|
1498
|
+
"google-gemini-cli",
|
|
1499
|
+
"google-antigravity"
|
|
1500
|
+
]);
|
|
1501
|
+
var PROVIDER_LABELS = {
|
|
1502
|
+
anthropic: "Anthropic (Claude)",
|
|
1503
|
+
openai: "OpenAI",
|
|
1504
|
+
google: "Google (Gemini)",
|
|
1505
|
+
"google-vertex": "Google Vertex AI",
|
|
1506
|
+
"azure-openai-responses": "Azure OpenAI",
|
|
1507
|
+
"amazon-bedrock": "Amazon Bedrock",
|
|
1508
|
+
xai: "xAI (Grok)",
|
|
1509
|
+
groq: "Groq",
|
|
1510
|
+
cerebras: "Cerebras",
|
|
1511
|
+
openrouter: "OpenRouter",
|
|
1512
|
+
"vercel-ai-gateway": "Vercel AI Gateway",
|
|
1513
|
+
zai: "ZAI",
|
|
1514
|
+
mistral: "Mistral",
|
|
1515
|
+
minimax: "MiniMax",
|
|
1516
|
+
"minimax-cn": "MiniMax CN",
|
|
1517
|
+
huggingface: "Hugging Face",
|
|
1518
|
+
opencode: "OpenCode",
|
|
1519
|
+
"opencode-go": "OpenCode Go",
|
|
1520
|
+
"kimi-coding": "Kimi Coding",
|
|
1521
|
+
"custom-openai": "Custom OpenAI-Compatible",
|
|
1522
|
+
"google-gemini-cli": "Google Gemini CLI",
|
|
1523
|
+
"google-antigravity": "Google Antigravity",
|
|
1524
|
+
"openai-codex": "OpenAI Codex",
|
|
1525
|
+
"github-copilot": "GitHub Copilot"
|
|
1526
|
+
};
|
|
1527
|
+
var PROVIDER_HINTS = {
|
|
1528
|
+
anthropic: "recommended",
|
|
1529
|
+
"custom-openai": "custom base URL + API key",
|
|
1530
|
+
"azure-openai-responses": "API key + base URL/resource + deployment",
|
|
1531
|
+
"amazon-bedrock": "AWS profile or access key pair",
|
|
1532
|
+
"openai-codex": "browser auth",
|
|
1533
|
+
"github-copilot": "browser auth",
|
|
1534
|
+
"google-gemini-cli": "browser auth",
|
|
1535
|
+
"google-antigravity": "browser auth"
|
|
1536
|
+
};
|
|
1537
|
+
function humanizeProviderId(providerId) {
|
|
1538
|
+
return providerId.split("-").map((part) => {
|
|
1539
|
+
if (!part) {
|
|
1540
|
+
return part;
|
|
1541
|
+
}
|
|
1542
|
+
if (part.length <= 3) {
|
|
1543
|
+
return part.toUpperCase();
|
|
1544
|
+
}
|
|
1545
|
+
return part[0].toUpperCase() + part.slice(1);
|
|
1546
|
+
}).join(" ");
|
|
1547
|
+
}
|
|
1548
|
+
function toLabel(providerId) {
|
|
1549
|
+
return PROVIDER_LABELS[providerId] || humanizeProviderId(providerId);
|
|
1550
|
+
}
|
|
1551
|
+
function toHint(providerId) {
|
|
1552
|
+
return PROVIDER_HINTS[providerId];
|
|
1553
|
+
}
|
|
1554
|
+
function compareProviderOptions(a, b3) {
|
|
1555
|
+
return a.label.localeCompare(b3.label);
|
|
1556
|
+
}
|
|
1557
|
+
function getBrowserAuthProviderOptions(oauthProviders) {
|
|
1558
|
+
return oauthProviders.map((provider) => ({
|
|
1559
|
+
id: provider.id,
|
|
1560
|
+
label: provider.name || toLabel(provider.id),
|
|
1561
|
+
hint: toHint(provider.id),
|
|
1562
|
+
flow: "oauth"
|
|
1563
|
+
})).sort(compareProviderOptions);
|
|
1564
|
+
}
|
|
1565
|
+
function getApiKeyProviderOptions(providerIds) {
|
|
1566
|
+
const baseProviders = providerIds.filter((providerId) => !OAUTH_ONLY_PROVIDER_IDS.has(providerId)).map((providerId) => {
|
|
1567
|
+
let flow = "generic-api-key";
|
|
1568
|
+
if (providerId === "azure-openai-responses") {
|
|
1569
|
+
flow = "azure-openai-responses";
|
|
1570
|
+
} else if (providerId === "amazon-bedrock") {
|
|
1571
|
+
flow = "amazon-bedrock";
|
|
1572
|
+
}
|
|
1573
|
+
return {
|
|
1574
|
+
id: providerId,
|
|
1575
|
+
label: toLabel(providerId),
|
|
1576
|
+
hint: toHint(providerId),
|
|
1577
|
+
flow
|
|
1578
|
+
};
|
|
1579
|
+
});
|
|
1580
|
+
baseProviders.push({
|
|
1581
|
+
id: "custom-openai",
|
|
1582
|
+
label: toLabel("custom-openai"),
|
|
1583
|
+
hint: toHint("custom-openai"),
|
|
1584
|
+
flow: "custom-openai"
|
|
1585
|
+
});
|
|
1586
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
1587
|
+
for (const provider of baseProviders) {
|
|
1588
|
+
deduped.set(provider.id, provider);
|
|
1589
|
+
}
|
|
1590
|
+
return Array.from(deduped.values()).sort(compareProviderOptions);
|
|
1591
|
+
}
|
|
1592
|
+
async function findExistingConfiguredProvider(params) {
|
|
1593
|
+
for (const providerId of params.knownProviderIds) {
|
|
1594
|
+
if (params.authStorage.hasAuth(providerId)) {
|
|
1595
|
+
return providerId;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
const hasBedrock = await params.envStore.hasAny(["AWS_PROFILE", "AWS_ACCESS_KEY_ID", "AWS_BEARER_TOKEN_BEDROCK"]);
|
|
1599
|
+
if (hasBedrock) {
|
|
1600
|
+
return "amazon-bedrock";
|
|
1601
|
+
}
|
|
1602
|
+
return null;
|
|
1603
|
+
}
|
|
1604
|
+
function getProviderLabel(providerId) {
|
|
1605
|
+
return toLabel(providerId);
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
// src/agent/interactiveAuth.ts
|
|
1609
|
+
function modeAsAny(mode) {
|
|
1610
|
+
return mode;
|
|
1611
|
+
}
|
|
1612
|
+
function getConfiguredProviderIds(dependencies) {
|
|
1613
|
+
const ids = new Set(dependencies.authStorage.list());
|
|
1614
|
+
return Array.from(ids.values()).sort((left, right) => getProviderLabel(left).localeCompare(getProviderLabel(right)));
|
|
1615
|
+
}
|
|
1616
|
+
function buildBrandedTitle(title) {
|
|
1617
|
+
return `${renderDocyrusLogoPrimary().trim()}
|
|
1618
|
+
|
|
1619
|
+
${title}`;
|
|
1620
|
+
}
|
|
1621
|
+
async function showSelection(mode, title, options) {
|
|
1622
|
+
const modeAny = modeAsAny(mode);
|
|
1623
|
+
const displayToValue = /* @__PURE__ */ new Map();
|
|
1624
|
+
const displayOptions = options.map((option) => {
|
|
1625
|
+
const display = option.hint ? `${option.label} \u2014 ${option.hint}` : option.label;
|
|
1626
|
+
displayToValue.set(display, option.value);
|
|
1627
|
+
return display;
|
|
1628
|
+
});
|
|
1629
|
+
return await new Promise((resolve) => {
|
|
1630
|
+
modeAny.showSelector((done) => {
|
|
1631
|
+
const selector = new modeAny.__docyrusUiComponents.ExtensionSelectorComponent(
|
|
1632
|
+
buildBrandedTitle(title),
|
|
1633
|
+
displayOptions,
|
|
1634
|
+
(selected) => {
|
|
1635
|
+
done();
|
|
1636
|
+
resolve(displayToValue.get(selected));
|
|
1637
|
+
},
|
|
1638
|
+
() => {
|
|
1639
|
+
done();
|
|
1640
|
+
resolve(void 0);
|
|
1641
|
+
},
|
|
1642
|
+
{ tui: modeAny.ui }
|
|
1643
|
+
);
|
|
1644
|
+
return {
|
|
1645
|
+
component: selector,
|
|
1646
|
+
focus: selector
|
|
1647
|
+
};
|
|
1648
|
+
});
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
async function showInput(mode, title, placeholder) {
|
|
1652
|
+
const modeAny = modeAsAny(mode);
|
|
1653
|
+
return await new Promise((resolve) => {
|
|
1654
|
+
modeAny.showSelector((done) => {
|
|
1655
|
+
const input = new modeAny.__docyrusUiComponents.ExtensionInputComponent(
|
|
1656
|
+
buildBrandedTitle(title),
|
|
1657
|
+
placeholder,
|
|
1658
|
+
(value) => {
|
|
1659
|
+
done();
|
|
1660
|
+
resolve(value.trim() || void 0);
|
|
1661
|
+
},
|
|
1662
|
+
() => {
|
|
1663
|
+
done();
|
|
1664
|
+
resolve(void 0);
|
|
1665
|
+
},
|
|
1666
|
+
{ tui: modeAny.ui }
|
|
1667
|
+
);
|
|
1668
|
+
return {
|
|
1669
|
+
component: input,
|
|
1670
|
+
focus: input
|
|
1671
|
+
};
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
async function refreshAfterCredentialChange(mode, preferredProviderId, preferredModelId) {
|
|
1676
|
+
const modeAny = modeAsAny(mode);
|
|
1677
|
+
modeAny.session.modelRegistry.refresh();
|
|
1678
|
+
await modeAny.updateAvailableProviderCount?.();
|
|
1679
|
+
const availableModels = modeAny.session.modelRegistry.getAvailable();
|
|
1680
|
+
const preferredModel = preferredProviderId && preferredModelId ? availableModels.find((model) => model.provider === preferredProviderId && model.id === preferredModelId) : preferredProviderId ? availableModels.find((model) => model.provider === preferredProviderId) : void 0;
|
|
1681
|
+
const currentModel = modeAny.session.model;
|
|
1682
|
+
const currentModelStillAvailable = currentModel ? availableModels.some((model) => model.provider === currentModel.provider && model.id === currentModel.id) : false;
|
|
1683
|
+
if (currentModel && !currentModelStillAvailable) {
|
|
1684
|
+
if (preferredModel) {
|
|
1685
|
+
await modeAny.session.setModel(preferredModel);
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
if (availableModels[0]) {
|
|
1689
|
+
await modeAny.session.setModel(availableModels[0]);
|
|
1690
|
+
}
|
|
1691
|
+
return;
|
|
1692
|
+
}
|
|
1693
|
+
if (!currentModel && preferredModel) {
|
|
1694
|
+
await modeAny.session.setModel(preferredModel);
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
if (!currentModel && availableModels[0]) {
|
|
1698
|
+
await modeAny.session.setModel(availableModels[0]);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
async function runApiKeyProviderFlow(mode, dependencies, provider) {
|
|
1702
|
+
const modeAny = modeAsAny(mode);
|
|
1703
|
+
switch (provider.flow) {
|
|
1704
|
+
case "custom-openai": {
|
|
1705
|
+
const baseUrl = await showInput(mode, "Custom OpenAI base URL", "https://my-proxy.example.com/v1");
|
|
1706
|
+
if (!baseUrl) {
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
const apiKey = await showInput(mode, "Custom OpenAI API key");
|
|
1710
|
+
if (!apiKey) {
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
const modelId = await showInput(mode, "Model ID", "gpt-4o");
|
|
1714
|
+
if (!modelId) {
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
await saveCustomOpenAiConfig({
|
|
1718
|
+
...dependencies,
|
|
1719
|
+
baseUrl,
|
|
1720
|
+
apiKey,
|
|
1721
|
+
modelId
|
|
1722
|
+
});
|
|
1723
|
+
await refreshAfterCredentialChange(mode, "custom-openai", modelId);
|
|
1724
|
+
modeAny.showStatus(`Configured ${provider.label}`);
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
case "azure-openai-responses": {
|
|
1728
|
+
const apiKey = await showInput(mode, "Azure OpenAI API key");
|
|
1729
|
+
if (!apiKey) {
|
|
1730
|
+
return;
|
|
1731
|
+
}
|
|
1732
|
+
const configMode = await showSelection(mode, "Azure OpenAI configuration", [
|
|
1733
|
+
{ value: "base-url", label: "Use a base URL" },
|
|
1734
|
+
{ value: "resource-name", label: "Use an Azure resource name" }
|
|
1735
|
+
]);
|
|
1736
|
+
if (!configMode) {
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
let baseUrl;
|
|
1740
|
+
if (configMode === "base-url") {
|
|
1741
|
+
baseUrl = await showInput(mode, "Azure OpenAI base URL", "https://my-resource.openai.azure.com/openai/v1");
|
|
1742
|
+
} else {
|
|
1743
|
+
const resourceName = await showInput(mode, "Azure resource name", "my-resource");
|
|
1744
|
+
if (resourceName) {
|
|
1745
|
+
baseUrl = `https://${resourceName}.openai.azure.com/openai/v1`;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
if (!baseUrl) {
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
const modelId = await showInput(mode, "Model ID", dependencies.modelIdsByProvider["azure-openai-responses"]?.[0] || "gpt-4.1");
|
|
1752
|
+
if (!modelId) {
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
const deploymentName = await showInput(mode, "Deployment name (optional)", modelId);
|
|
1756
|
+
const apiVersion = await showInput(mode, "API version (optional)", "2025-03-01-preview");
|
|
1757
|
+
const builtInModelIds = new Set(dependencies.modelIdsByProvider["azure-openai-responses"] || []);
|
|
1758
|
+
await saveAzureConfig({
|
|
1759
|
+
...dependencies,
|
|
1760
|
+
apiKey,
|
|
1761
|
+
baseUrl,
|
|
1762
|
+
modelId,
|
|
1763
|
+
deploymentName,
|
|
1764
|
+
apiVersion,
|
|
1765
|
+
useCustomModel: !builtInModelIds.has(modelId)
|
|
1766
|
+
});
|
|
1767
|
+
await refreshAfterCredentialChange(mode, "azure-openai-responses", modelId);
|
|
1768
|
+
modeAny.showStatus(`Configured ${provider.label}`);
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
case "amazon-bedrock": {
|
|
1772
|
+
const authMode = await showSelection(mode, "Amazon Bedrock authentication", [
|
|
1773
|
+
{ value: "profile", label: "Use an AWS profile" },
|
|
1774
|
+
{ value: "access-keys", label: "Paste AWS access keys" }
|
|
1775
|
+
]);
|
|
1776
|
+
if (!authMode) {
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
let profile;
|
|
1780
|
+
let accessKeyId;
|
|
1781
|
+
let secretAccessKey;
|
|
1782
|
+
let sessionToken;
|
|
1783
|
+
if (authMode === "profile") {
|
|
1784
|
+
profile = await showInput(mode, "AWS profile name", "default");
|
|
1785
|
+
if (!profile) {
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
} else {
|
|
1789
|
+
accessKeyId = await showInput(mode, "AWS access key ID");
|
|
1790
|
+
if (!accessKeyId) {
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
secretAccessKey = await showInput(mode, "AWS secret access key");
|
|
1794
|
+
if (!secretAccessKey) {
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
sessionToken = await showInput(mode, "AWS session token (optional)");
|
|
1798
|
+
}
|
|
1799
|
+
const region = await showInput(mode, "AWS region", "us-east-1");
|
|
1800
|
+
if (!region) {
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
const modelId = await showInput(mode, "Bedrock model ID", dependencies.modelIdsByProvider["amazon-bedrock"]?.[0] || "anthropic.claude-3-7-sonnet-20250219-v1:0");
|
|
1804
|
+
if (!modelId) {
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1807
|
+
await saveBedrockConfig({
|
|
1808
|
+
...dependencies,
|
|
1809
|
+
region,
|
|
1810
|
+
modelId,
|
|
1811
|
+
profile,
|
|
1812
|
+
accessKeyId,
|
|
1813
|
+
secretAccessKey,
|
|
1814
|
+
sessionToken
|
|
1815
|
+
});
|
|
1816
|
+
await refreshAfterCredentialChange(mode, "amazon-bedrock", modelId);
|
|
1817
|
+
modeAny.showStatus(`Configured ${provider.label}`);
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
case "generic-api-key":
|
|
1821
|
+
default: {
|
|
1822
|
+
const apiKey = await showInput(mode, `${provider.label} API key`);
|
|
1823
|
+
if (!apiKey) {
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
await saveGenericApiKey({
|
|
1827
|
+
...dependencies,
|
|
1828
|
+
providerId: provider.id,
|
|
1829
|
+
apiKey
|
|
1830
|
+
});
|
|
1831
|
+
await refreshAfterCredentialChange(mode, provider.id);
|
|
1832
|
+
modeAny.showStatus(`Configured ${provider.label}`);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
async function handleInteractiveLogin(mode, dependencies) {
|
|
1837
|
+
const modeAny = modeAsAny(mode);
|
|
1838
|
+
const method = await showSelection(mode, "How do you want to sign in?", [
|
|
1839
|
+
{ value: "browser", label: "Sign in with your browser", hint: "OAuth-backed providers" },
|
|
1840
|
+
{ value: "api-key", label: "Paste an API key", hint: "provider dashboard" }
|
|
1841
|
+
]);
|
|
1842
|
+
if (!method) {
|
|
1843
|
+
modeAny.showStatus("Login cancelled");
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
if (method === "browser") {
|
|
1847
|
+
await modeAny.showOAuthSelector("login");
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
const providerId = await showSelection(mode, "Choose provider", getApiKeyProviderOptions(dependencies.apiKeyProviderIds).map((provider2) => ({
|
|
1851
|
+
value: provider2.id,
|
|
1852
|
+
label: provider2.label,
|
|
1853
|
+
hint: provider2.hint
|
|
1854
|
+
})));
|
|
1855
|
+
if (!providerId) {
|
|
1856
|
+
modeAny.showStatus("Login cancelled");
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
const provider = getApiKeyProviderOptions(dependencies.apiKeyProviderIds).find((item) => item.id === providerId);
|
|
1860
|
+
if (!provider) {
|
|
1861
|
+
modeAny.showError(`Unknown provider: ${providerId}`);
|
|
1862
|
+
return;
|
|
1863
|
+
}
|
|
1864
|
+
try {
|
|
1865
|
+
await runApiKeyProviderFlow(mode, dependencies, provider);
|
|
1866
|
+
} catch (error) {
|
|
1867
|
+
modeAny.showError(`Failed to login to ${provider.label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
async function handleInteractiveLogout(mode, dependencies) {
|
|
1871
|
+
const modeAny = modeAsAny(mode);
|
|
1872
|
+
const configuredProviderIds = getConfiguredProviderIds(dependencies);
|
|
1873
|
+
if (configuredProviderIds.length === 0) {
|
|
1874
|
+
modeAny.showStatus("No saved providers to remove.");
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
const providerId = await showSelection(mode, "Remove which saved provider?", configuredProviderIds.map((id) => ({
|
|
1878
|
+
value: id,
|
|
1879
|
+
label: getProviderLabel(id)
|
|
1880
|
+
})));
|
|
1881
|
+
if (!providerId) {
|
|
1882
|
+
modeAny.showStatus("Logout cancelled");
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
try {
|
|
1886
|
+
await clearProviderConfig({
|
|
1887
|
+
...dependencies,
|
|
1888
|
+
providerId
|
|
1889
|
+
});
|
|
1890
|
+
await refreshAfterCredentialChange(mode);
|
|
1891
|
+
modeAny.showStatus(`Removed ${getProviderLabel(providerId)}`);
|
|
1892
|
+
} catch (error) {
|
|
1893
|
+
modeAny.showError(`Failed to remove ${getProviderLabel(providerId)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
function installInteractiveAuthInterceptors(mode, dependencies) {
|
|
1897
|
+
const modeAny = modeAsAny(mode);
|
|
1898
|
+
modeAny.__docyrusUiComponents = dependencies.uiComponents;
|
|
1899
|
+
const defaultEditor = modeAny.defaultEditor;
|
|
1900
|
+
if (!defaultEditor || typeof defaultEditor.onSubmit !== "function") {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
const originalOnSubmit = defaultEditor.onSubmit.bind(defaultEditor);
|
|
1904
|
+
defaultEditor.onSubmit = async (text) => {
|
|
1905
|
+
const trimmed = text.trim();
|
|
1906
|
+
if (trimmed === "/login") {
|
|
1907
|
+
modeAny.editor.setText("");
|
|
1908
|
+
await handleInteractiveLogin(mode, dependencies);
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
if (trimmed === "/logout") {
|
|
1912
|
+
modeAny.editor.setText("");
|
|
1913
|
+
await handleInteractiveLogout(mode, dependencies);
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1916
|
+
await originalOnSubmit(text);
|
|
1917
|
+
};
|
|
1918
|
+
if (modeAny.editor === defaultEditor) {
|
|
1919
|
+
modeAny.editor.onSubmit = defaultEditor.onSubmit;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
// src/agent/onboarding.ts
|
|
1924
|
+
var import_node_child_process = require("node:child_process");
|
|
1925
|
+
var API_KEY_PREFIXES = {
|
|
1926
|
+
anthropic: ["sk-ant-"],
|
|
1927
|
+
openai: ["sk-"]
|
|
1928
|
+
};
|
|
1929
|
+
async function loadClack() {
|
|
1930
|
+
return await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
1931
|
+
}
|
|
1932
|
+
async function loadPico() {
|
|
1933
|
+
return await Promise.resolve().then(() => __toESM(require_picocolors()));
|
|
1934
|
+
}
|
|
1935
|
+
function isCancelError(clack, value) {
|
|
1936
|
+
return clack.isCancel(value);
|
|
1937
|
+
}
|
|
1938
|
+
function openBrowser(url) {
|
|
1939
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
1940
|
+
(0, import_node_child_process.exec)(`${command} "${url}"`, () => {
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
async function shouldRunOnboarding(params) {
|
|
1944
|
+
if (!params.isInteractive || params.isPrintMode) {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
if (params.settingsManager.getDefaultProvider()) {
|
|
1948
|
+
return false;
|
|
1949
|
+
}
|
|
1950
|
+
const existingProvider = await findExistingConfiguredProvider({
|
|
1951
|
+
authStorage: params.authStorage,
|
|
1952
|
+
envStore: params.envStore,
|
|
1953
|
+
knownProviderIds: [
|
|
1954
|
+
...params.browserProviders.map((provider) => provider.id),
|
|
1955
|
+
...params.apiKeyProviderIds,
|
|
1956
|
+
"custom-openai"
|
|
1957
|
+
]
|
|
1958
|
+
});
|
|
1959
|
+
return !existingProvider;
|
|
1960
|
+
}
|
|
1961
|
+
function cleanupOnboardingStdinState() {
|
|
1962
|
+
process.stdin.removeAllListeners("data");
|
|
1963
|
+
process.stdin.removeAllListeners("keypress");
|
|
1964
|
+
if (process.stdin.setRawMode) {
|
|
1965
|
+
process.stdin.setRawMode(false);
|
|
1966
|
+
}
|
|
1967
|
+
process.stdin.pause();
|
|
1968
|
+
}
|
|
1969
|
+
async function runOAuthFlow(clack, pico, dependencies, providerId) {
|
|
1970
|
+
const providerInfo = getBrowserAuthProviderOptions(dependencies.browserProviders).find((provider) => provider.id === providerId);
|
|
1971
|
+
const providerName = providerInfo?.label || getProviderLabel(providerId);
|
|
1972
|
+
const spinner = clack.spinner();
|
|
1973
|
+
spinner.start(`Authenticating with ${providerName}...`);
|
|
1974
|
+
try {
|
|
1975
|
+
await dependencies.authStorage.login(providerId, {
|
|
1976
|
+
onAuth: (info) => {
|
|
1977
|
+
spinner.stop(`Opening browser for ${providerName}`);
|
|
1978
|
+
openBrowser(info.url);
|
|
1979
|
+
clack.log.info(`${pico.dim("URL:")} ${pico.cyan(info.url)}`);
|
|
1980
|
+
if (info.instructions) {
|
|
1981
|
+
clack.log.info(pico.yellow(info.instructions));
|
|
1982
|
+
}
|
|
1983
|
+
},
|
|
1984
|
+
onPrompt: async (prompt) => {
|
|
1985
|
+
const result = await clack.text({
|
|
1986
|
+
message: prompt.message,
|
|
1987
|
+
placeholder: prompt.placeholder
|
|
1988
|
+
});
|
|
1989
|
+
if (clack.isCancel(result)) {
|
|
1990
|
+
return "";
|
|
1991
|
+
}
|
|
1992
|
+
return String(result);
|
|
1993
|
+
},
|
|
1994
|
+
onProgress: (message) => {
|
|
1995
|
+
clack.log.step(pico.dim(message));
|
|
1996
|
+
},
|
|
1997
|
+
onManualCodeInput: async () => {
|
|
1998
|
+
const result = await clack.text({
|
|
1999
|
+
message: "Paste the redirect URL from your browser:",
|
|
2000
|
+
placeholder: "http://localhost:..."
|
|
2001
|
+
});
|
|
2002
|
+
if (clack.isCancel(result)) {
|
|
2003
|
+
return "";
|
|
2004
|
+
}
|
|
2005
|
+
return String(result);
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
clack.log.success(`Authenticated with ${pico.green(providerName)}`);
|
|
2009
|
+
return true;
|
|
2010
|
+
} catch (error) {
|
|
2011
|
+
spinner.stop(`${providerName} authentication failed`);
|
|
2012
|
+
clack.log.warn(`OAuth error: ${error instanceof Error ? error.message : String(error)}`);
|
|
2013
|
+
return false;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
async function runGenericApiKeyFlow(clack, pico, dependencies, provider) {
|
|
2017
|
+
const apiKey = await clack.password({
|
|
2018
|
+
message: `Paste your ${provider.label} API key:`,
|
|
2019
|
+
mask: "\u25CF"
|
|
2020
|
+
});
|
|
2021
|
+
if (clack.isCancel(apiKey) || !apiKey) {
|
|
2022
|
+
return false;
|
|
2023
|
+
}
|
|
2024
|
+
const trimmed = String(apiKey).trim();
|
|
2025
|
+
if (!trimmed) {
|
|
2026
|
+
return false;
|
|
2027
|
+
}
|
|
2028
|
+
const expectedPrefixes = API_KEY_PREFIXES[provider.id];
|
|
2029
|
+
if (expectedPrefixes && !expectedPrefixes.some((prefix) => trimmed.startsWith(prefix))) {
|
|
2030
|
+
clack.log.warn(`Key doesn't start with expected prefix (${expectedPrefixes.join(" or ")}). Saving anyway.`);
|
|
2031
|
+
}
|
|
2032
|
+
await saveGenericApiKey({
|
|
2033
|
+
...dependencies,
|
|
2034
|
+
providerId: provider.id,
|
|
2035
|
+
apiKey: trimmed
|
|
2036
|
+
});
|
|
2037
|
+
clack.log.success(`API key saved for ${pico.green(provider.label)}`);
|
|
2038
|
+
return true;
|
|
2039
|
+
}
|
|
2040
|
+
async function runCustomOpenAiFlow(clack, pico, dependencies) {
|
|
2041
|
+
const baseUrl = await clack.text({
|
|
2042
|
+
message: "Base URL of your OpenAI-compatible endpoint:",
|
|
2043
|
+
placeholder: "https://my-proxy.example.com/v1",
|
|
2044
|
+
validate: (value) => {
|
|
2045
|
+
const trimmed = value?.trim();
|
|
2046
|
+
if (!trimmed) {
|
|
2047
|
+
return "Base URL is required";
|
|
2048
|
+
}
|
|
2049
|
+
try {
|
|
2050
|
+
new URL(trimmed);
|
|
2051
|
+
} catch {
|
|
2052
|
+
return "Must be a valid URL";
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
if (clack.isCancel(baseUrl) || !baseUrl) {
|
|
2057
|
+
return false;
|
|
2058
|
+
}
|
|
2059
|
+
const apiKey = await clack.password({
|
|
2060
|
+
message: "API key for this endpoint:",
|
|
2061
|
+
mask: "\u25CF"
|
|
2062
|
+
});
|
|
2063
|
+
if (clack.isCancel(apiKey) || !apiKey) {
|
|
2064
|
+
return false;
|
|
2065
|
+
}
|
|
2066
|
+
const modelId = await clack.text({
|
|
2067
|
+
message: "Model ID to use:",
|
|
2068
|
+
placeholder: "gpt-4o",
|
|
2069
|
+
validate: (value) => value?.trim() ? void 0 : "Model ID is required"
|
|
2070
|
+
});
|
|
2071
|
+
if (clack.isCancel(modelId) || !modelId) {
|
|
2072
|
+
return false;
|
|
2073
|
+
}
|
|
2074
|
+
await saveCustomOpenAiConfig({
|
|
2075
|
+
...dependencies,
|
|
2076
|
+
apiKey: String(apiKey).trim(),
|
|
2077
|
+
baseUrl: String(baseUrl).trim(),
|
|
2078
|
+
modelId: String(modelId).trim()
|
|
2079
|
+
});
|
|
2080
|
+
clack.log.success(`Custom endpoint saved: ${pico.green(String(baseUrl).trim())}`);
|
|
2081
|
+
clack.log.info(`Model: ${pico.cyan(String(modelId).trim())}`);
|
|
2082
|
+
return true;
|
|
2083
|
+
}
|
|
2084
|
+
async function runAzureFlow(clack, pico, dependencies) {
|
|
2085
|
+
const apiKey = await clack.password({
|
|
2086
|
+
message: "Paste your Azure OpenAI API key:",
|
|
2087
|
+
mask: "\u25CF"
|
|
2088
|
+
});
|
|
2089
|
+
if (clack.isCancel(apiKey) || !apiKey) {
|
|
2090
|
+
return false;
|
|
2091
|
+
}
|
|
2092
|
+
const configMode = await clack.select({
|
|
2093
|
+
message: "How do you want to configure Azure OpenAI?",
|
|
2094
|
+
options: [
|
|
2095
|
+
{ value: "base-url", label: "Use a base URL" },
|
|
2096
|
+
{ value: "resource-name", label: "Use an Azure resource name" }
|
|
2097
|
+
]
|
|
2098
|
+
});
|
|
2099
|
+
if (clack.isCancel(configMode) || !configMode) {
|
|
2100
|
+
return false;
|
|
2101
|
+
}
|
|
2102
|
+
let baseUrl = "";
|
|
2103
|
+
if (configMode === "base-url") {
|
|
2104
|
+
const baseUrlInput = await clack.text({
|
|
2105
|
+
message: "Azure OpenAI base URL:",
|
|
2106
|
+
placeholder: "https://my-resource.openai.azure.com/openai/v1",
|
|
2107
|
+
validate: (value) => value?.trim() ? void 0 : "Base URL is required"
|
|
2108
|
+
});
|
|
2109
|
+
if (clack.isCancel(baseUrlInput) || !baseUrlInput) {
|
|
2110
|
+
return false;
|
|
2111
|
+
}
|
|
2112
|
+
baseUrl = String(baseUrlInput).trim();
|
|
2113
|
+
} else {
|
|
2114
|
+
const resourceName = await clack.text({
|
|
2115
|
+
message: "Azure resource name:",
|
|
2116
|
+
placeholder: "my-resource",
|
|
2117
|
+
validate: (value) => value?.trim() ? void 0 : "Resource name is required"
|
|
2118
|
+
});
|
|
2119
|
+
if (clack.isCancel(resourceName) || !resourceName) {
|
|
2120
|
+
return false;
|
|
2121
|
+
}
|
|
2122
|
+
baseUrl = `https://${String(resourceName).trim()}.openai.azure.com/openai/v1`;
|
|
2123
|
+
}
|
|
2124
|
+
const modelId = await clack.text({
|
|
2125
|
+
message: "Model ID to use:",
|
|
2126
|
+
placeholder: dependencies.modelIdsByProvider["azure-openai-responses"]?.[0] || "gpt-4.1",
|
|
2127
|
+
validate: (value) => value?.trim() ? void 0 : "Model ID is required"
|
|
2128
|
+
});
|
|
2129
|
+
if (clack.isCancel(modelId) || !modelId) {
|
|
2130
|
+
return false;
|
|
2131
|
+
}
|
|
2132
|
+
const deploymentName = await clack.text({
|
|
2133
|
+
message: `Deployment name ${pico.dim("(leave blank to reuse the model id)")}:`,
|
|
2134
|
+
placeholder: String(modelId).trim()
|
|
2135
|
+
});
|
|
2136
|
+
if (clack.isCancel(deploymentName)) {
|
|
2137
|
+
return false;
|
|
2138
|
+
}
|
|
2139
|
+
const apiVersion = await clack.text({
|
|
2140
|
+
message: `API version ${pico.dim("(leave blank to use pi's default)")}:`,
|
|
2141
|
+
placeholder: "2025-03-01-preview"
|
|
2142
|
+
});
|
|
2143
|
+
if (clack.isCancel(apiVersion)) {
|
|
2144
|
+
return false;
|
|
2145
|
+
}
|
|
2146
|
+
const builtInModelIds = new Set(dependencies.modelIdsByProvider["azure-openai-responses"] || []);
|
|
2147
|
+
await saveAzureConfig({
|
|
2148
|
+
...dependencies,
|
|
2149
|
+
apiKey: String(apiKey).trim(),
|
|
2150
|
+
baseUrl,
|
|
2151
|
+
modelId: String(modelId).trim(),
|
|
2152
|
+
deploymentName: String(deploymentName || "").trim() || void 0,
|
|
2153
|
+
apiVersion: String(apiVersion || "").trim() || void 0,
|
|
2154
|
+
useCustomModel: !builtInModelIds.has(String(modelId).trim())
|
|
2155
|
+
});
|
|
2156
|
+
clack.log.success(`Azure OpenAI configured for ${pico.green(String(modelId).trim())}`);
|
|
2157
|
+
return true;
|
|
2158
|
+
}
|
|
2159
|
+
async function runBedrockFlow(clack, pico, dependencies) {
|
|
2160
|
+
const authMode = await clack.select({
|
|
2161
|
+
message: "How do you want to authenticate with Amazon Bedrock?",
|
|
2162
|
+
options: [
|
|
2163
|
+
{ value: "profile", label: "Use an AWS profile" },
|
|
2164
|
+
{ value: "access-keys", label: "Paste AWS access keys" }
|
|
2165
|
+
]
|
|
2166
|
+
});
|
|
2167
|
+
if (clack.isCancel(authMode) || !authMode) {
|
|
2168
|
+
return false;
|
|
2169
|
+
}
|
|
2170
|
+
let profile;
|
|
2171
|
+
let accessKeyId;
|
|
2172
|
+
let secretAccessKey;
|
|
2173
|
+
let sessionToken;
|
|
2174
|
+
if (authMode === "profile") {
|
|
2175
|
+
const profileInput = await clack.text({
|
|
2176
|
+
message: "AWS profile name:",
|
|
2177
|
+
placeholder: "default",
|
|
2178
|
+
validate: (value) => value?.trim() ? void 0 : "Profile name is required"
|
|
2179
|
+
});
|
|
2180
|
+
if (clack.isCancel(profileInput) || !profileInput) {
|
|
2181
|
+
return false;
|
|
2182
|
+
}
|
|
2183
|
+
profile = String(profileInput).trim();
|
|
2184
|
+
} else {
|
|
2185
|
+
const accessKeyInput = await clack.password({
|
|
2186
|
+
message: "AWS access key ID:",
|
|
2187
|
+
mask: "\u25CF"
|
|
2188
|
+
});
|
|
2189
|
+
if (clack.isCancel(accessKeyInput) || !accessKeyInput) {
|
|
2190
|
+
return false;
|
|
2191
|
+
}
|
|
2192
|
+
const secretKeyInput = await clack.password({
|
|
2193
|
+
message: "AWS secret access key:",
|
|
2194
|
+
mask: "\u25CF"
|
|
2195
|
+
});
|
|
2196
|
+
if (clack.isCancel(secretKeyInput) || !secretKeyInput) {
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
const sessionTokenInput = await clack.password({
|
|
2200
|
+
message: `AWS session token ${pico.dim("(optional)")}:`,
|
|
2201
|
+
mask: "\u25CF"
|
|
2202
|
+
});
|
|
2203
|
+
if (clack.isCancel(sessionTokenInput)) {
|
|
2204
|
+
return false;
|
|
2205
|
+
}
|
|
2206
|
+
accessKeyId = String(accessKeyInput).trim();
|
|
2207
|
+
secretAccessKey = String(secretKeyInput).trim();
|
|
2208
|
+
sessionToken = String(sessionTokenInput || "").trim() || void 0;
|
|
2209
|
+
}
|
|
2210
|
+
const region = await clack.text({
|
|
2211
|
+
message: "AWS region:",
|
|
2212
|
+
placeholder: "us-east-1",
|
|
2213
|
+
validate: (value) => value?.trim() ? void 0 : "Region is required"
|
|
2214
|
+
});
|
|
2215
|
+
if (clack.isCancel(region) || !region) {
|
|
2216
|
+
return false;
|
|
2217
|
+
}
|
|
2218
|
+
const modelId = await clack.text({
|
|
2219
|
+
message: "Bedrock model ID:",
|
|
2220
|
+
placeholder: dependencies.modelIdsByProvider["amazon-bedrock"]?.[0] || "anthropic.claude-3-7-sonnet-20250219-v1:0",
|
|
2221
|
+
validate: (value) => value?.trim() ? void 0 : "Model ID is required"
|
|
2222
|
+
});
|
|
2223
|
+
if (clack.isCancel(modelId) || !modelId) {
|
|
2224
|
+
return false;
|
|
2225
|
+
}
|
|
2226
|
+
await saveBedrockConfig({
|
|
2227
|
+
...dependencies,
|
|
2228
|
+
region: String(region).trim(),
|
|
2229
|
+
modelId: String(modelId).trim(),
|
|
2230
|
+
profile,
|
|
2231
|
+
accessKeyId,
|
|
2232
|
+
secretAccessKey,
|
|
2233
|
+
sessionToken
|
|
2234
|
+
});
|
|
2235
|
+
clack.log.success(`Amazon Bedrock configured for ${pico.green(String(modelId).trim())}`);
|
|
2236
|
+
return true;
|
|
2237
|
+
}
|
|
2238
|
+
async function runProviderFlow(clack, pico, dependencies, provider) {
|
|
2239
|
+
switch (provider.flow) {
|
|
2240
|
+
case "oauth":
|
|
2241
|
+
return await runOAuthFlow(clack, pico, dependencies, provider.id);
|
|
2242
|
+
case "custom-openai":
|
|
2243
|
+
return await runCustomOpenAiFlow(clack, pico, dependencies);
|
|
2244
|
+
case "azure-openai-responses":
|
|
2245
|
+
return await runAzureFlow(clack, pico, dependencies);
|
|
2246
|
+
case "amazon-bedrock":
|
|
2247
|
+
return await runBedrockFlow(clack, pico, dependencies);
|
|
2248
|
+
case "generic-api-key":
|
|
2249
|
+
default:
|
|
2250
|
+
return await runGenericApiKeyFlow(clack, pico, dependencies, provider);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
async function runLogoutFlow(clack, pico, dependencies, providerId) {
|
|
2254
|
+
await clearProviderConfig({
|
|
2255
|
+
...dependencies,
|
|
2256
|
+
providerId
|
|
2257
|
+
});
|
|
2258
|
+
clack.log.success(`Removed saved configuration for ${pico.green(getProviderLabel(providerId))}`);
|
|
2259
|
+
}
|
|
2260
|
+
async function runOnboarding(dependencies) {
|
|
2261
|
+
const [clack, pico] = await Promise.all([loadClack(), loadPico()]);
|
|
2262
|
+
process.stderr.write(renderDocyrusLogoPrimary());
|
|
2263
|
+
clack.intro(pico.bold("Welcome to DOCYRUS \u2014 let's get you set up"));
|
|
2264
|
+
const existingProvider = await findExistingConfiguredProvider({
|
|
2265
|
+
authStorage: dependencies.authStorage,
|
|
2266
|
+
envStore: dependencies.envStore,
|
|
2267
|
+
knownProviderIds: [
|
|
2268
|
+
...dependencies.browserProviders.map((provider) => provider.id),
|
|
2269
|
+
...dependencies.apiKeyProviderIds,
|
|
2270
|
+
"custom-openai"
|
|
2271
|
+
]
|
|
2272
|
+
});
|
|
2273
|
+
const authOptions = [];
|
|
2274
|
+
if (existingProvider) {
|
|
2275
|
+
authOptions.push({
|
|
2276
|
+
value: "keep",
|
|
2277
|
+
label: `Keep current (${getProviderLabel(existingProvider)})`,
|
|
2278
|
+
hint: "already configured",
|
|
2279
|
+
providerId: existingProvider
|
|
2280
|
+
});
|
|
2281
|
+
authOptions.push({
|
|
2282
|
+
value: "logout-current",
|
|
2283
|
+
label: `Remove current (${getProviderLabel(existingProvider)})`,
|
|
2284
|
+
hint: "clear saved auth and config",
|
|
2285
|
+
providerId: existingProvider
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
authOptions.push(
|
|
2289
|
+
{ value: "browser", label: "Sign in with your browser", hint: "recommended for OAuth-backed providers" },
|
|
2290
|
+
{ value: "api-key", label: "Paste an API key", hint: "from your provider dashboard" },
|
|
2291
|
+
{ value: "skip", label: "Skip for now", hint: "you can use /login inside DOCYRUS later" }
|
|
2292
|
+
);
|
|
2293
|
+
const authMethod = await clack.select({
|
|
2294
|
+
message: existingProvider ? `LLM provider: ${getProviderLabel(existingProvider)} \u2014 change it?` : "How do you want to sign in?",
|
|
2295
|
+
options: authOptions.map((option) => ({
|
|
2296
|
+
value: option.value,
|
|
2297
|
+
label: option.label,
|
|
2298
|
+
hint: option.hint
|
|
2299
|
+
}))
|
|
2300
|
+
});
|
|
2301
|
+
if (isCancelError(clack, authMethod) || authMethod === "skip") {
|
|
2302
|
+
clack.cancel("Setup skipped \u2014 you can run /login later inside DOCYRUS.");
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
if (authMethod === "keep") {
|
|
2306
|
+
clack.log.success(`Keeping ${pico.green(getProviderLabel(existingProvider || ""))}`);
|
|
2307
|
+
clack.outro("DOCYRUS setup complete.");
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
if (authMethod === "logout-current" && existingProvider) {
|
|
2311
|
+
await runLogoutFlow(clack, pico, dependencies, existingProvider);
|
|
2312
|
+
}
|
|
2313
|
+
let configuredProviderLabel = null;
|
|
2314
|
+
if (authMethod === "browser") {
|
|
2315
|
+
const provider = await clack.select({
|
|
2316
|
+
message: "Choose provider",
|
|
2317
|
+
options: getBrowserAuthProviderOptions(dependencies.browserProviders).map((providerOption) => ({
|
|
2318
|
+
value: providerOption.id,
|
|
2319
|
+
label: providerOption.label,
|
|
2320
|
+
hint: providerOption.hint
|
|
2321
|
+
}))
|
|
2322
|
+
});
|
|
2323
|
+
if (!isCancelError(clack, provider) && provider) {
|
|
2324
|
+
const selected = getBrowserAuthProviderOptions(dependencies.browserProviders).find((item) => item.id === provider);
|
|
2325
|
+
if (selected && await runProviderFlow(clack, pico, dependencies, selected)) {
|
|
2326
|
+
configuredProviderLabel = selected.label;
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
} else if (authMethod === "api-key") {
|
|
2330
|
+
const provider = await clack.select({
|
|
2331
|
+
message: "Choose provider",
|
|
2332
|
+
options: getApiKeyProviderOptions(dependencies.apiKeyProviderIds).map((providerOption) => ({
|
|
2333
|
+
value: providerOption.id,
|
|
2334
|
+
label: providerOption.label,
|
|
2335
|
+
hint: providerOption.hint
|
|
2336
|
+
}))
|
|
2337
|
+
});
|
|
2338
|
+
if (!isCancelError(clack, provider) && provider) {
|
|
2339
|
+
const selected = getApiKeyProviderOptions(dependencies.apiKeyProviderIds).find((item) => item.id === provider);
|
|
2340
|
+
if (selected && await runProviderFlow(clack, pico, dependencies, selected)) {
|
|
2341
|
+
configuredProviderLabel = selected.label;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
if (configuredProviderLabel) {
|
|
2346
|
+
clack.outro(`DOCYRUS is ready. Provider configured: ${pico.green(configuredProviderLabel)}`);
|
|
2347
|
+
} else {
|
|
2348
|
+
clack.outro("DOCYRUS setup ended without saving a provider.");
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
// src/agent/loader.ts
|
|
2353
|
+
function readRequiredEnv(name) {
|
|
2354
|
+
const value = process.env[name];
|
|
2355
|
+
if (!value || value.trim().length === 0) {
|
|
2356
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
2357
|
+
}
|
|
2358
|
+
return value;
|
|
2359
|
+
}
|
|
2360
|
+
function readLoaderRequest() {
|
|
2361
|
+
return JSON.parse(readRequiredEnv("DOCYRUS_PI_REQUEST"));
|
|
2362
|
+
}
|
|
2363
|
+
async function loadPiExports() {
|
|
2364
|
+
const piPackageDir = readRequiredEnv("PI_PACKAGE_DIR");
|
|
2365
|
+
const moduleUrl = (0, import_node_url.pathToFileURL)((0, import_node_path3.join)(piPackageDir, "dist", "index.js")).href;
|
|
2366
|
+
return await import(moduleUrl);
|
|
2367
|
+
}
|
|
2368
|
+
function resolvePackagedPiResourceRoot() {
|
|
2369
|
+
const candidates = [
|
|
2370
|
+
(0, import_node_path3.resolve)(process.cwd(), "apps/api-cli/resources/pi-agent"),
|
|
2371
|
+
(0, import_node_path3.resolve)(__dirname, "../resources/pi-agent"),
|
|
2372
|
+
(0, import_node_path3.resolve)(__dirname, "resources/pi-agent"),
|
|
2373
|
+
(0, import_node_path3.resolve)(process.cwd(), "dist/apps/api-cli/resources/pi-agent")
|
|
2374
|
+
];
|
|
2375
|
+
const resolved = candidates.find((candidate) => (0, import_node_fs.existsSync)(candidate));
|
|
2376
|
+
if (!resolved) {
|
|
2377
|
+
throw new Error(`Unable to locate pi agent resources. Checked: ${candidates.join(", ")}`);
|
|
2378
|
+
}
|
|
2379
|
+
return resolved;
|
|
2380
|
+
}
|
|
2381
|
+
async function readPipedStdin() {
|
|
2382
|
+
if (process.stdin.isTTY) {
|
|
2383
|
+
return void 0;
|
|
2384
|
+
}
|
|
2385
|
+
return await new Promise((resolve) => {
|
|
2386
|
+
let data = "";
|
|
2387
|
+
process.stdin.setEncoding("utf8");
|
|
2388
|
+
process.stdin.on("data", (chunk) => {
|
|
2389
|
+
data += chunk;
|
|
2390
|
+
});
|
|
2391
|
+
process.stdin.on("end", () => {
|
|
2392
|
+
resolve(data.trim() || void 0);
|
|
2393
|
+
});
|
|
2394
|
+
process.stdin.resume();
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
function buildTools(profile, cwd, pi) {
|
|
2398
|
+
if (profile === "agent") {
|
|
2399
|
+
return [
|
|
2400
|
+
pi.createReadTool(cwd),
|
|
2401
|
+
pi.createBashTool(cwd),
|
|
2402
|
+
pi.createGrepTool(cwd),
|
|
2403
|
+
pi.createFindTool(cwd),
|
|
2404
|
+
pi.createLsTool(cwd)
|
|
2405
|
+
];
|
|
2406
|
+
}
|
|
2407
|
+
return [
|
|
2408
|
+
pi.createReadTool(cwd),
|
|
2409
|
+
pi.createBashTool(cwd),
|
|
2410
|
+
pi.createEditTool(cwd),
|
|
2411
|
+
pi.createWriteTool(cwd),
|
|
2412
|
+
pi.createGrepTool(cwd),
|
|
2413
|
+
pi.createFindTool(cwd),
|
|
2414
|
+
pi.createLsTool(cwd)
|
|
2415
|
+
];
|
|
2416
|
+
}
|
|
2417
|
+
function resolveRequestedModel(params) {
|
|
2418
|
+
const { request, modelRegistry } = params;
|
|
2419
|
+
const requestedProvider = request.provider?.trim();
|
|
2420
|
+
const requestedModel = request.model?.trim();
|
|
2421
|
+
if (!requestedProvider && !requestedModel) {
|
|
2422
|
+
return void 0;
|
|
2423
|
+
}
|
|
2424
|
+
if (requestedProvider && requestedModel) {
|
|
2425
|
+
const normalizedModelId = requestedModel.startsWith(`${requestedProvider}/`) ? requestedModel.slice(requestedProvider.length + 1) : requestedModel;
|
|
2426
|
+
return modelRegistry.find(requestedProvider, normalizedModelId);
|
|
2427
|
+
}
|
|
2428
|
+
if (requestedModel && requestedModel.includes("/")) {
|
|
2429
|
+
const slashIndex = requestedModel.indexOf("/");
|
|
2430
|
+
return modelRegistry.find(requestedModel.slice(0, slashIndex).trim(), requestedModel.slice(slashIndex + 1).trim());
|
|
2431
|
+
}
|
|
2432
|
+
if (requestedModel) {
|
|
2433
|
+
const availableModels = modelRegistry.getAvailable();
|
|
2434
|
+
const exactMatches = availableModels.filter((model) => model.id === requestedModel);
|
|
2435
|
+
if (exactMatches.length === 1) {
|
|
2436
|
+
return exactMatches[0];
|
|
2437
|
+
}
|
|
2438
|
+
return availableModels.find((model) => model.id.includes(requestedModel));
|
|
2439
|
+
}
|
|
2440
|
+
return void 0;
|
|
2441
|
+
}
|
|
2442
|
+
function buildModelIdsByProvider(modelRegistry) {
|
|
2443
|
+
const values = {};
|
|
2444
|
+
for (const model of modelRegistry.getAll()) {
|
|
2445
|
+
if (!values[model.provider]) {
|
|
2446
|
+
values[model.provider] = [];
|
|
2447
|
+
}
|
|
2448
|
+
values[model.provider].push(model.id);
|
|
2449
|
+
}
|
|
2450
|
+
return values;
|
|
2451
|
+
}
|
|
2452
|
+
async function chooseResumeSession(params) {
|
|
2453
|
+
const sessions = await params.pi.SessionManager.list(params.cwd, params.request.sessionDir);
|
|
2454
|
+
if (sessions.length === 0) {
|
|
2455
|
+
return void 0;
|
|
2456
|
+
}
|
|
2457
|
+
const prompts = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
2458
|
+
const selected = await prompts.select({
|
|
2459
|
+
message: "Select a session to resume",
|
|
2460
|
+
options: sessions.slice(0, 20).map((session) => ({
|
|
2461
|
+
value: session.path,
|
|
2462
|
+
label: session.name || session.modified.toLocaleString(),
|
|
2463
|
+
hint: session.firstMessage.replace(/\n/g, " ").slice(0, 80) || "Empty session"
|
|
2464
|
+
}))
|
|
2465
|
+
});
|
|
2466
|
+
if (prompts.isCancel(selected) || !selected) {
|
|
2467
|
+
process.exit(0);
|
|
2468
|
+
}
|
|
2469
|
+
return String(selected);
|
|
2470
|
+
}
|
|
2471
|
+
async function createSessionManager(params) {
|
|
2472
|
+
if (params.request.session) {
|
|
2473
|
+
return params.pi.SessionManager.open(params.request.session, params.request.sessionDir);
|
|
2474
|
+
}
|
|
2475
|
+
if (params.request.resume) {
|
|
2476
|
+
if (!params.isInteractive) {
|
|
2477
|
+
return params.pi.SessionManager.continueRecent(params.cwd, params.request.sessionDir);
|
|
2478
|
+
}
|
|
2479
|
+
const selectedSessionPath = await chooseResumeSession(params);
|
|
2480
|
+
if (selectedSessionPath) {
|
|
2481
|
+
return params.pi.SessionManager.open(selectedSessionPath, params.request.sessionDir);
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
if (params.request.continue) {
|
|
2485
|
+
return params.pi.SessionManager.continueRecent(params.cwd, params.request.sessionDir);
|
|
2486
|
+
}
|
|
2487
|
+
return params.pi.SessionManager.create(params.cwd, params.request.sessionDir);
|
|
2488
|
+
}
|
|
2489
|
+
function renderStartupSplash(version) {
|
|
2490
|
+
process.stderr.write(
|
|
2491
|
+
renderDocyrusLogoPrimary() + `
|
|
2492
|
+
${import_picocolors3.default.bold("DOCYRUS")} ${import_picocolors3.default.dim(`v${version}`)}
|
|
2493
|
+
${import_picocolors3.default.green("Welcome.")} Preparing your agent workspace...
|
|
2494
|
+
|
|
2495
|
+
`
|
|
2496
|
+
);
|
|
2497
|
+
}
|
|
2498
|
+
async function main() {
|
|
2499
|
+
const request = readLoaderRequest();
|
|
2500
|
+
const pi = await loadPiExports();
|
|
2501
|
+
const cwd = process.cwd();
|
|
2502
|
+
const agentDir = readRequiredEnv("PI_CODING_AGENT_DIR");
|
|
2503
|
+
const version = process.env.DOCYRUS_PI_VERSION || "dev";
|
|
2504
|
+
const resourceRoot = resolvePackagedPiResourceRoot();
|
|
2505
|
+
const envStore = new AgentEnvStore((0, import_node_path3.join)(agentDir, "env.json"));
|
|
2506
|
+
await envStore.hydrateProcessEnv(process.env);
|
|
2507
|
+
const authStorage = pi.AuthStorage.create((0, import_node_path3.join)(agentDir, "auth.json"));
|
|
2508
|
+
const settingsManager = pi.SettingsManager.create(cwd, agentDir);
|
|
2509
|
+
const modelsJsonPath = (0, import_node_path3.join)(agentDir, "models.json");
|
|
2510
|
+
const initialModelRegistry = new pi.ModelRegistry(authStorage, modelsJsonPath);
|
|
2511
|
+
const isPrintMode = Boolean(request.print) || !process.stdin.isTTY;
|
|
2512
|
+
const isInteractive = process.stdin.isTTY && !isPrintMode;
|
|
2513
|
+
const quietStartup = !request.verbose;
|
|
2514
|
+
if (quietStartup) {
|
|
2515
|
+
process.env.PI_SKIP_VERSION_CHECK = "1";
|
|
2516
|
+
settingsManager.setQuietStartup(true);
|
|
2517
|
+
settingsManager.setCollapseChangelog(true);
|
|
2518
|
+
settingsManager.setLastChangelogVersion(version);
|
|
2519
|
+
}
|
|
2520
|
+
const browserProviders = authStorage.getOAuthProviders();
|
|
2521
|
+
const apiKeyProviderIds = Array.from(new Set(initialModelRegistry.getAll().map((model) => model.provider)));
|
|
2522
|
+
const modelIdsByProvider = buildModelIdsByProvider(initialModelRegistry);
|
|
2523
|
+
let usedClack = false;
|
|
2524
|
+
renderStartupSplash(version);
|
|
2525
|
+
if (await shouldRunOnboarding({
|
|
2526
|
+
authStorage,
|
|
2527
|
+
envStore,
|
|
2528
|
+
settingsManager,
|
|
2529
|
+
isInteractive,
|
|
2530
|
+
isPrintMode,
|
|
2531
|
+
browserProviders,
|
|
2532
|
+
apiKeyProviderIds,
|
|
2533
|
+
modelIdsByProvider
|
|
2534
|
+
})) {
|
|
2535
|
+
usedClack = true;
|
|
2536
|
+
await runOnboarding({
|
|
2537
|
+
authStorage,
|
|
2538
|
+
envStore,
|
|
2539
|
+
settingsManager,
|
|
2540
|
+
modelsJsonPath,
|
|
2541
|
+
browserProviders,
|
|
2542
|
+
apiKeyProviderIds,
|
|
2543
|
+
modelIdsByProvider
|
|
2544
|
+
});
|
|
2545
|
+
await envStore.hydrateProcessEnv(process.env);
|
|
2546
|
+
}
|
|
2547
|
+
const modelRegistry = new pi.ModelRegistry(authStorage, modelsJsonPath);
|
|
2548
|
+
const requestedModel = resolveRequestedModel({
|
|
2549
|
+
request,
|
|
2550
|
+
modelRegistry
|
|
2551
|
+
});
|
|
2552
|
+
if (request.apiKey) {
|
|
2553
|
+
const apiKeyProvider = request.provider?.trim() || requestedModel?.provider;
|
|
2554
|
+
if (!apiKeyProvider) {
|
|
2555
|
+
throw new Error("--api-key requires a provider or a resolvable model.");
|
|
2556
|
+
}
|
|
2557
|
+
authStorage.setRuntimeApiKey(apiKeyProvider, request.apiKey);
|
|
2558
|
+
}
|
|
2559
|
+
const sessionManager = await createSessionManager({
|
|
2560
|
+
pi,
|
|
2561
|
+
request,
|
|
2562
|
+
cwd,
|
|
2563
|
+
isInteractive
|
|
2564
|
+
});
|
|
2565
|
+
const resourceLoader = new pi.DefaultResourceLoader({
|
|
2566
|
+
cwd,
|
|
2567
|
+
agentDir,
|
|
2568
|
+
settingsManager,
|
|
2569
|
+
systemPrompt: request.profile === "agent" ? (0, import_node_path3.join)(resourceRoot, "prompts", "agent-system.md") : void 0,
|
|
2570
|
+
appendSystemPrompt: request.profile === "coder" ? (0, import_node_path3.join)(resourceRoot, "prompts", "coder-append-system.md") : void 0
|
|
2571
|
+
});
|
|
2572
|
+
await resourceLoader.reload();
|
|
2573
|
+
const { session, modelFallbackMessage } = await pi.createAgentSession({
|
|
2574
|
+
cwd,
|
|
2575
|
+
agentDir,
|
|
2576
|
+
authStorage,
|
|
2577
|
+
modelRegistry,
|
|
2578
|
+
resourceLoader,
|
|
2579
|
+
settingsManager,
|
|
2580
|
+
sessionManager,
|
|
2581
|
+
tools: buildTools(request.profile, cwd, pi),
|
|
2582
|
+
model: requestedModel,
|
|
2583
|
+
thinkingLevel: request.thinking
|
|
2584
|
+
});
|
|
2585
|
+
if (usedClack) {
|
|
2586
|
+
cleanupOnboardingStdinState();
|
|
2587
|
+
}
|
|
2588
|
+
const pipedStdin = await readPipedStdin();
|
|
2589
|
+
if (pipedStdin !== void 0 && !request.print) {
|
|
2590
|
+
request.print = true;
|
|
2591
|
+
}
|
|
2592
|
+
if (request.print || pipedStdin !== void 0) {
|
|
2593
|
+
if (!session.model) {
|
|
2594
|
+
throw new Error(`No models available.
|
|
2595
|
+
|
|
2596
|
+
Set an API key environment variable:
|
|
2597
|
+
ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, etc.
|
|
2598
|
+
|
|
2599
|
+
Or create ${modelsJsonPath}`);
|
|
2600
|
+
}
|
|
2601
|
+
const initialMessage = pipedStdin || request.prompt;
|
|
2602
|
+
const initialMessages = pipedStdin && request.prompt ? [request.prompt] : void 0;
|
|
2603
|
+
await pi.runPrintMode(session, {
|
|
2604
|
+
mode: request.mode || "text",
|
|
2605
|
+
initialMessage,
|
|
2606
|
+
messages: initialMessages
|
|
2607
|
+
});
|
|
2608
|
+
return;
|
|
2609
|
+
}
|
|
2610
|
+
const interactiveMode = new pi.InteractiveMode(session, {
|
|
2611
|
+
initialMessage: request.prompt,
|
|
2612
|
+
modelFallbackMessage,
|
|
2613
|
+
verbose: request.verbose
|
|
2614
|
+
});
|
|
2615
|
+
const originalInit = interactiveMode.init.bind(interactiveMode);
|
|
2616
|
+
interactiveMode.init = async () => {
|
|
2617
|
+
await originalInit();
|
|
2618
|
+
installInteractiveAuthInterceptors(interactiveMode, {
|
|
2619
|
+
authStorage,
|
|
2620
|
+
envStore,
|
|
2621
|
+
settingsManager,
|
|
2622
|
+
modelsJsonPath,
|
|
2623
|
+
browserProviders,
|
|
2624
|
+
apiKeyProviderIds: Array.from(new Set(modelRegistry.getAll().map((model) => model.provider))),
|
|
2625
|
+
modelIdsByProvider: buildModelIdsByProvider(modelRegistry),
|
|
2626
|
+
uiComponents: {
|
|
2627
|
+
ExtensionInputComponent: pi.ExtensionInputComponent,
|
|
2628
|
+
ExtensionSelectorComponent: pi.ExtensionSelectorComponent
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2631
|
+
};
|
|
2632
|
+
await interactiveMode.run();
|
|
2633
|
+
}
|
|
2634
|
+
void main().catch((error) => {
|
|
2635
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2636
|
+
process.stderr.write(`${message}
|
|
2637
|
+
`);
|
|
2638
|
+
process.exitCode = 1;
|
|
2639
|
+
});
|
|
2640
|
+
//# sourceMappingURL=agent-loader.js.map
|