@openape/ape-agent 2.9.1 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge.mjs +86 -12
- package/dist/service-bridge-main.mjs +4140 -0
- package/package.json +6 -4
|
@@ -0,0 +1,4140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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
|
+
// ../../packages/apes/dist/chunk-OBF7IMQ2.js
|
|
36
|
+
import { homedir } from "os";
|
|
37
|
+
import { join } from "path";
|
|
38
|
+
var CONFIG_DIR, AUTH_FILE, CONFIG_FILE;
|
|
39
|
+
var init_chunk_OBF7IMQ2 = __esm({
|
|
40
|
+
"../../packages/apes/dist/chunk-OBF7IMQ2.js"() {
|
|
41
|
+
"use strict";
|
|
42
|
+
CONFIG_DIR = join(homedir(), ".config", "apes");
|
|
43
|
+
AUTH_FILE = join(CONFIG_DIR, "auth.json");
|
|
44
|
+
CONFIG_FILE = join(CONFIG_DIR, "config.toml");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/chunks/prompt.mjs
|
|
49
|
+
var prompt_exports = {};
|
|
50
|
+
__export(prompt_exports, {
|
|
51
|
+
kCancel: () => kCancel,
|
|
52
|
+
prompt: () => prompt
|
|
53
|
+
});
|
|
54
|
+
import "util";
|
|
55
|
+
import g, { stdin, stdout } from "process";
|
|
56
|
+
import f from "readline";
|
|
57
|
+
import { WriteStream } from "tty";
|
|
58
|
+
function getDefaultExportFromCjs(x2) {
|
|
59
|
+
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
60
|
+
}
|
|
61
|
+
function requireSrc() {
|
|
62
|
+
if (hasRequiredSrc) return src;
|
|
63
|
+
hasRequiredSrc = 1;
|
|
64
|
+
const ESC = "\x1B";
|
|
65
|
+
const CSI = `${ESC}[`;
|
|
66
|
+
const beep = "\x07";
|
|
67
|
+
const cursor = {
|
|
68
|
+
to(x2, y3) {
|
|
69
|
+
if (!y3) return `${CSI}${x2 + 1}G`;
|
|
70
|
+
return `${CSI}${y3 + 1};${x2 + 1}H`;
|
|
71
|
+
},
|
|
72
|
+
move(x2, y3) {
|
|
73
|
+
let ret = "";
|
|
74
|
+
if (x2 < 0) ret += `${CSI}${-x2}D`;
|
|
75
|
+
else if (x2 > 0) ret += `${CSI}${x2}C`;
|
|
76
|
+
if (y3 < 0) ret += `${CSI}${-y3}A`;
|
|
77
|
+
else if (y3 > 0) ret += `${CSI}${y3}B`;
|
|
78
|
+
return ret;
|
|
79
|
+
},
|
|
80
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
81
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
82
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
83
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
84
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
85
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
86
|
+
left: `${CSI}G`,
|
|
87
|
+
hide: `${CSI}?25l`,
|
|
88
|
+
show: `${CSI}?25h`,
|
|
89
|
+
save: `${ESC}7`,
|
|
90
|
+
restore: `${ESC}8`
|
|
91
|
+
};
|
|
92
|
+
const scroll = {
|
|
93
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
94
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
95
|
+
};
|
|
96
|
+
const erase = {
|
|
97
|
+
screen: `${CSI}2J`,
|
|
98
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
99
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
100
|
+
line: `${CSI}2K`,
|
|
101
|
+
lineEnd: `${CSI}K`,
|
|
102
|
+
lineStart: `${CSI}1K`,
|
|
103
|
+
lines(count) {
|
|
104
|
+
let clear = "";
|
|
105
|
+
for (let i2 = 0; i2 < count; i2++)
|
|
106
|
+
clear += this.line + (i2 < count - 1 ? cursor.up() : "");
|
|
107
|
+
if (count)
|
|
108
|
+
clear += cursor.left;
|
|
109
|
+
return clear;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
src = { cursor, scroll, erase, beep };
|
|
113
|
+
return src;
|
|
114
|
+
}
|
|
115
|
+
function requirePicocolors() {
|
|
116
|
+
if (hasRequiredPicocolors) return picocolors.exports;
|
|
117
|
+
hasRequiredPicocolors = 1;
|
|
118
|
+
let p = process || {}, argv2 = p.argv || [], env2 = p.env || {};
|
|
119
|
+
let isColorSupported2 = !(!!env2.NO_COLOR || argv2.includes("--no-color")) && (!!env2.FORCE_COLOR || argv2.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env2.TERM !== "dumb" || !!env2.CI);
|
|
120
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
121
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
122
|
+
return ~index ? open + replaceClose2(string, close, replace, index) + close : open + string + close;
|
|
123
|
+
};
|
|
124
|
+
let replaceClose2 = (string, close, replace, index) => {
|
|
125
|
+
let result = "", cursor = 0;
|
|
126
|
+
do {
|
|
127
|
+
result += string.substring(cursor, index) + replace;
|
|
128
|
+
cursor = index + close.length;
|
|
129
|
+
index = string.indexOf(close, cursor);
|
|
130
|
+
} while (~index);
|
|
131
|
+
return result + string.substring(cursor);
|
|
132
|
+
};
|
|
133
|
+
let createColors2 = (enabled = isColorSupported2) => {
|
|
134
|
+
let f3 = enabled ? formatter : () => String;
|
|
135
|
+
return {
|
|
136
|
+
isColorSupported: enabled,
|
|
137
|
+
reset: f3("\x1B[0m", "\x1B[0m"),
|
|
138
|
+
bold: f3("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
139
|
+
dim: f3("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
140
|
+
italic: f3("\x1B[3m", "\x1B[23m"),
|
|
141
|
+
underline: f3("\x1B[4m", "\x1B[24m"),
|
|
142
|
+
inverse: f3("\x1B[7m", "\x1B[27m"),
|
|
143
|
+
hidden: f3("\x1B[8m", "\x1B[28m"),
|
|
144
|
+
strikethrough: f3("\x1B[9m", "\x1B[29m"),
|
|
145
|
+
black: f3("\x1B[30m", "\x1B[39m"),
|
|
146
|
+
red: f3("\x1B[31m", "\x1B[39m"),
|
|
147
|
+
green: f3("\x1B[32m", "\x1B[39m"),
|
|
148
|
+
yellow: f3("\x1B[33m", "\x1B[39m"),
|
|
149
|
+
blue: f3("\x1B[34m", "\x1B[39m"),
|
|
150
|
+
magenta: f3("\x1B[35m", "\x1B[39m"),
|
|
151
|
+
cyan: f3("\x1B[36m", "\x1B[39m"),
|
|
152
|
+
white: f3("\x1B[37m", "\x1B[39m"),
|
|
153
|
+
gray: f3("\x1B[90m", "\x1B[39m"),
|
|
154
|
+
bgBlack: f3("\x1B[40m", "\x1B[49m"),
|
|
155
|
+
bgRed: f3("\x1B[41m", "\x1B[49m"),
|
|
156
|
+
bgGreen: f3("\x1B[42m", "\x1B[49m"),
|
|
157
|
+
bgYellow: f3("\x1B[43m", "\x1B[49m"),
|
|
158
|
+
bgBlue: f3("\x1B[44m", "\x1B[49m"),
|
|
159
|
+
bgMagenta: f3("\x1B[45m", "\x1B[49m"),
|
|
160
|
+
bgCyan: f3("\x1B[46m", "\x1B[49m"),
|
|
161
|
+
bgWhite: f3("\x1B[47m", "\x1B[49m"),
|
|
162
|
+
blackBright: f3("\x1B[90m", "\x1B[39m"),
|
|
163
|
+
redBright: f3("\x1B[91m", "\x1B[39m"),
|
|
164
|
+
greenBright: f3("\x1B[92m", "\x1B[39m"),
|
|
165
|
+
yellowBright: f3("\x1B[93m", "\x1B[39m"),
|
|
166
|
+
blueBright: f3("\x1B[94m", "\x1B[39m"),
|
|
167
|
+
magentaBright: f3("\x1B[95m", "\x1B[39m"),
|
|
168
|
+
cyanBright: f3("\x1B[96m", "\x1B[39m"),
|
|
169
|
+
whiteBright: f3("\x1B[97m", "\x1B[39m"),
|
|
170
|
+
bgBlackBright: f3("\x1B[100m", "\x1B[49m"),
|
|
171
|
+
bgRedBright: f3("\x1B[101m", "\x1B[49m"),
|
|
172
|
+
bgGreenBright: f3("\x1B[102m", "\x1B[49m"),
|
|
173
|
+
bgYellowBright: f3("\x1B[103m", "\x1B[49m"),
|
|
174
|
+
bgBlueBright: f3("\x1B[104m", "\x1B[49m"),
|
|
175
|
+
bgMagentaBright: f3("\x1B[105m", "\x1B[49m"),
|
|
176
|
+
bgCyanBright: f3("\x1B[106m", "\x1B[49m"),
|
|
177
|
+
bgWhiteBright: f3("\x1B[107m", "\x1B[49m")
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
picocolors.exports = createColors2();
|
|
181
|
+
picocolors.exports.createColors = createColors2;
|
|
182
|
+
return picocolors.exports;
|
|
183
|
+
}
|
|
184
|
+
function J({ onlyFirst: t2 = false } = {}) {
|
|
185
|
+
const F3 = ["[\\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("|");
|
|
186
|
+
return new RegExp(F3, t2 ? void 0 : "g");
|
|
187
|
+
}
|
|
188
|
+
function T$1(t2) {
|
|
189
|
+
if (typeof t2 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof t2}\``);
|
|
190
|
+
return t2.replace(Q, "");
|
|
191
|
+
}
|
|
192
|
+
function O(t2) {
|
|
193
|
+
return t2 && t2.__esModule && Object.prototype.hasOwnProperty.call(t2, "default") ? t2.default : t2;
|
|
194
|
+
}
|
|
195
|
+
function A$1(t2, u3 = {}) {
|
|
196
|
+
if (typeof t2 != "string" || t2.length === 0 || (u3 = { ambiguousIsNarrow: true, ...u3 }, t2 = T$1(t2), t2.length === 0)) return 0;
|
|
197
|
+
t2 = t2.replace(FD(), " ");
|
|
198
|
+
const F3 = u3.ambiguousIsNarrow ? 1 : 2;
|
|
199
|
+
let e2 = 0;
|
|
200
|
+
for (const s2 of t2) {
|
|
201
|
+
const i2 = s2.codePointAt(0);
|
|
202
|
+
if (i2 <= 31 || i2 >= 127 && i2 <= 159 || i2 >= 768 && i2 <= 879) continue;
|
|
203
|
+
switch (DD.eastAsianWidth(s2)) {
|
|
204
|
+
case "F":
|
|
205
|
+
case "W":
|
|
206
|
+
e2 += 2;
|
|
207
|
+
break;
|
|
208
|
+
case "A":
|
|
209
|
+
e2 += F3;
|
|
210
|
+
break;
|
|
211
|
+
default:
|
|
212
|
+
e2 += 1;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return e2;
|
|
216
|
+
}
|
|
217
|
+
function sD() {
|
|
218
|
+
const t2 = /* @__PURE__ */ new Map();
|
|
219
|
+
for (const [u3, F3] of Object.entries(r)) {
|
|
220
|
+
for (const [e2, s2] of Object.entries(F3)) r[e2] = { open: `\x1B[${s2[0]}m`, close: `\x1B[${s2[1]}m` }, F3[e2] = r[e2], t2.set(s2[0], s2[1]);
|
|
221
|
+
Object.defineProperty(r, u3, { value: F3, enumerable: false });
|
|
222
|
+
}
|
|
223
|
+
return Object.defineProperty(r, "codes", { value: t2, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = L$1(), r.color.ansi256 = N(), r.color.ansi16m = I(), r.bgColor.ansi = L$1(m), r.bgColor.ansi256 = N(m), r.bgColor.ansi16m = I(m), Object.defineProperties(r, { rgbToAnsi256: { value: (u3, F3, e2) => u3 === F3 && F3 === e2 ? u3 < 8 ? 16 : u3 > 248 ? 231 : Math.round((u3 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u3 / 255 * 5) + 6 * Math.round(F3 / 255 * 5) + Math.round(e2 / 255 * 5), enumerable: false }, hexToRgb: { value: (u3) => {
|
|
224
|
+
const F3 = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u3.toString(16));
|
|
225
|
+
if (!F3) return [0, 0, 0];
|
|
226
|
+
let [e2] = F3;
|
|
227
|
+
e2.length === 3 && (e2 = [...e2].map((i2) => i2 + i2).join(""));
|
|
228
|
+
const s2 = Number.parseInt(e2, 16);
|
|
229
|
+
return [s2 >> 16 & 255, s2 >> 8 & 255, s2 & 255];
|
|
230
|
+
}, enumerable: false }, hexToAnsi256: { value: (u3) => r.rgbToAnsi256(...r.hexToRgb(u3)), enumerable: false }, ansi256ToAnsi: { value: (u3) => {
|
|
231
|
+
if (u3 < 8) return 30 + u3;
|
|
232
|
+
if (u3 < 16) return 90 + (u3 - 8);
|
|
233
|
+
let F3, e2, s2;
|
|
234
|
+
if (u3 >= 232) F3 = ((u3 - 232) * 10 + 8) / 255, e2 = F3, s2 = F3;
|
|
235
|
+
else {
|
|
236
|
+
u3 -= 16;
|
|
237
|
+
const C3 = u3 % 36;
|
|
238
|
+
F3 = Math.floor(u3 / 36) / 5, e2 = Math.floor(C3 / 6) / 5, s2 = C3 % 6 / 5;
|
|
239
|
+
}
|
|
240
|
+
const i2 = Math.max(F3, e2, s2) * 2;
|
|
241
|
+
if (i2 === 0) return 30;
|
|
242
|
+
let D2 = 30 + (Math.round(s2) << 2 | Math.round(e2) << 1 | Math.round(F3));
|
|
243
|
+
return i2 === 2 && (D2 += 60), D2;
|
|
244
|
+
}, enumerable: false }, rgbToAnsi: { value: (u3, F3, e2) => r.ansi256ToAnsi(r.rgbToAnsi256(u3, F3, e2)), enumerable: false }, hexToAnsi: { value: (u3) => r.ansi256ToAnsi(r.hexToAnsi256(u3)), enumerable: false } }), r;
|
|
245
|
+
}
|
|
246
|
+
function G(t2, u3, F3) {
|
|
247
|
+
return String(t2).normalize().replace(/\r\n/g, `
|
|
248
|
+
`).split(`
|
|
249
|
+
`).map((e2) => oD(e2, u3, F3)).join(`
|
|
250
|
+
`);
|
|
251
|
+
}
|
|
252
|
+
function k$1(t2, u3) {
|
|
253
|
+
if (typeof t2 == "string") return c.aliases.get(t2) === u3;
|
|
254
|
+
for (const F3 of t2) if (F3 !== void 0 && k$1(F3, u3)) return true;
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
function lD(t2, u3) {
|
|
258
|
+
if (t2 === u3) return;
|
|
259
|
+
const F3 = t2.split(`
|
|
260
|
+
`), e2 = u3.split(`
|
|
261
|
+
`), s2 = [];
|
|
262
|
+
for (let i2 = 0; i2 < Math.max(F3.length, e2.length); i2++) F3[i2] !== e2[i2] && s2.push(i2);
|
|
263
|
+
return s2;
|
|
264
|
+
}
|
|
265
|
+
function d$1(t2, u3) {
|
|
266
|
+
const F3 = t2;
|
|
267
|
+
F3.isTTY && F3.setRawMode(u3);
|
|
268
|
+
}
|
|
269
|
+
function ce() {
|
|
270
|
+
return g.platform !== "win32" ? g.env.TERM !== "linux" : !!g.env.CI || !!g.env.WT_SESSION || !!g.env.TERMINUS_SUBLIME || g.env.ConEmuTask === "{cmd::Cmder}" || g.env.TERM_PROGRAM === "Terminus-Sublime" || g.env.TERM_PROGRAM === "vscode" || g.env.TERM === "xterm-256color" || g.env.TERM === "alacritty" || g.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
271
|
+
}
|
|
272
|
+
async function prompt(message, opts = {}) {
|
|
273
|
+
const handleCancel = (value) => {
|
|
274
|
+
if (typeof value !== "symbol" || value.toString() !== "Symbol(clack:cancel)") {
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
switch (opts.cancel) {
|
|
278
|
+
case "reject": {
|
|
279
|
+
const error = new Error("Prompt cancelled.");
|
|
280
|
+
error.name = "ConsolaPromptCancelledError";
|
|
281
|
+
if (Error.captureStackTrace) {
|
|
282
|
+
Error.captureStackTrace(error, prompt);
|
|
283
|
+
}
|
|
284
|
+
throw error;
|
|
285
|
+
}
|
|
286
|
+
case "undefined": {
|
|
287
|
+
return void 0;
|
|
288
|
+
}
|
|
289
|
+
case "null": {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
case "symbol": {
|
|
293
|
+
return kCancel;
|
|
294
|
+
}
|
|
295
|
+
default:
|
|
296
|
+
case "default": {
|
|
297
|
+
return opts.default ?? opts.initial;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
if (!opts.type || opts.type === "text") {
|
|
302
|
+
return await he({
|
|
303
|
+
message,
|
|
304
|
+
defaultValue: opts.default,
|
|
305
|
+
placeholder: opts.placeholder,
|
|
306
|
+
initialValue: opts.initial
|
|
307
|
+
}).then(handleCancel);
|
|
308
|
+
}
|
|
309
|
+
if (opts.type === "confirm") {
|
|
310
|
+
return await ye({
|
|
311
|
+
message,
|
|
312
|
+
initialValue: opts.initial
|
|
313
|
+
}).then(handleCancel);
|
|
314
|
+
}
|
|
315
|
+
if (opts.type === "select") {
|
|
316
|
+
return await ve({
|
|
317
|
+
message,
|
|
318
|
+
options: opts.options.map(
|
|
319
|
+
(o3) => typeof o3 === "string" ? { value: o3, label: o3 } : o3
|
|
320
|
+
),
|
|
321
|
+
initialValue: opts.initial
|
|
322
|
+
}).then(handleCancel);
|
|
323
|
+
}
|
|
324
|
+
if (opts.type === "multiselect") {
|
|
325
|
+
return await fe({
|
|
326
|
+
message,
|
|
327
|
+
options: opts.options.map(
|
|
328
|
+
(o3) => typeof o3 === "string" ? { value: o3, label: o3 } : o3
|
|
329
|
+
),
|
|
330
|
+
required: opts.required,
|
|
331
|
+
initialValues: opts.initial
|
|
332
|
+
}).then(handleCancel);
|
|
333
|
+
}
|
|
334
|
+
throw new Error(`Unknown prompt type: ${opts.type}`);
|
|
335
|
+
}
|
|
336
|
+
var src, hasRequiredSrc, srcExports, picocolors, hasRequiredPicocolors, picocolorsExports, e, Q, P$1, X, DD, uD, FD, m, L$1, N, I, r, tD, eD, iD, v, CD, w$1, W$1, rD, R, y, V$1, z, ED, _, nD, oD, aD, c, S, AD, pD, h, x, fD, bD, mD, Y, wD, SD, $D, q, jD, PD, V, u, le, L, W, C, o, d, k, P, A, T, F, w, B, he, ye, ve, fe, kCancel;
|
|
337
|
+
var init_prompt = __esm({
|
|
338
|
+
"../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/chunks/prompt.mjs"() {
|
|
339
|
+
"use strict";
|
|
340
|
+
srcExports = requireSrc();
|
|
341
|
+
picocolors = { exports: {} };
|
|
342
|
+
picocolorsExports = /* @__PURE__ */ requirePicocolors();
|
|
343
|
+
e = /* @__PURE__ */ getDefaultExportFromCjs(picocolorsExports);
|
|
344
|
+
Q = J();
|
|
345
|
+
P$1 = { exports: {} };
|
|
346
|
+
(function(t2) {
|
|
347
|
+
var u3 = {};
|
|
348
|
+
t2.exports = u3, u3.eastAsianWidth = function(e2) {
|
|
349
|
+
var s2 = e2.charCodeAt(0), i2 = e2.length == 2 ? e2.charCodeAt(1) : 0, D2 = s2;
|
|
350
|
+
return 55296 <= s2 && s2 <= 56319 && 56320 <= i2 && i2 <= 57343 && (s2 &= 1023, i2 &= 1023, D2 = s2 << 10 | i2, 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";
|
|
351
|
+
}, u3.characterLength = function(e2) {
|
|
352
|
+
var s2 = this.eastAsianWidth(e2);
|
|
353
|
+
return s2 == "F" || s2 == "W" || s2 == "A" ? 2 : 1;
|
|
354
|
+
};
|
|
355
|
+
function F3(e2) {
|
|
356
|
+
return e2.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
|
|
357
|
+
}
|
|
358
|
+
u3.length = function(e2) {
|
|
359
|
+
for (var s2 = F3(e2), i2 = 0, D2 = 0; D2 < s2.length; D2++) i2 = i2 + this.characterLength(s2[D2]);
|
|
360
|
+
return i2;
|
|
361
|
+
}, u3.slice = function(e2, s2, i2) {
|
|
362
|
+
textLen = u3.length(e2), s2 = s2 || 0, i2 = i2 || 1, s2 < 0 && (s2 = textLen + s2), i2 < 0 && (i2 = textLen + i2);
|
|
363
|
+
for (var D2 = "", C3 = 0, o3 = F3(e2), E = 0; E < o3.length; E++) {
|
|
364
|
+
var a2 = o3[E], n2 = u3.length(a2);
|
|
365
|
+
if (C3 >= s2 - (n2 == 2 ? 1 : 0)) if (C3 + n2 <= i2) D2 += a2;
|
|
366
|
+
else break;
|
|
367
|
+
C3 += n2;
|
|
368
|
+
}
|
|
369
|
+
return D2;
|
|
370
|
+
};
|
|
371
|
+
})(P$1);
|
|
372
|
+
X = P$1.exports;
|
|
373
|
+
DD = O(X);
|
|
374
|
+
uD = function() {
|
|
375
|
+
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;
|
|
376
|
+
};
|
|
377
|
+
FD = O(uD);
|
|
378
|
+
m = 10;
|
|
379
|
+
L$1 = (t2 = 0) => (u3) => `\x1B[${u3 + t2}m`;
|
|
380
|
+
N = (t2 = 0) => (u3) => `\x1B[${38 + t2};5;${u3}m`;
|
|
381
|
+
I = (t2 = 0) => (u3, F3, e2) => `\x1B[${38 + t2};2;${u3};${F3};${e2}m`;
|
|
382
|
+
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] } };
|
|
383
|
+
Object.keys(r.modifier);
|
|
384
|
+
tD = Object.keys(r.color);
|
|
385
|
+
eD = Object.keys(r.bgColor);
|
|
386
|
+
[...tD, ...eD];
|
|
387
|
+
iD = sD();
|
|
388
|
+
v = /* @__PURE__ */ new Set(["\x1B", "\x9B"]);
|
|
389
|
+
CD = 39;
|
|
390
|
+
w$1 = "\x07";
|
|
391
|
+
W$1 = "[";
|
|
392
|
+
rD = "]";
|
|
393
|
+
R = "m";
|
|
394
|
+
y = `${rD}8;;`;
|
|
395
|
+
V$1 = (t2) => `${v.values().next().value}${W$1}${t2}${R}`;
|
|
396
|
+
z = (t2) => `${v.values().next().value}${y}${t2}${w$1}`;
|
|
397
|
+
ED = (t2) => t2.split(" ").map((u3) => A$1(u3));
|
|
398
|
+
_ = (t2, u3, F3) => {
|
|
399
|
+
const e2 = [...u3];
|
|
400
|
+
let s2 = false, i2 = false, D2 = A$1(T$1(t2[t2.length - 1]));
|
|
401
|
+
for (const [C3, o3] of e2.entries()) {
|
|
402
|
+
const E = A$1(o3);
|
|
403
|
+
if (D2 + E <= F3 ? t2[t2.length - 1] += o3 : (t2.push(o3), D2 = 0), v.has(o3) && (s2 = true, i2 = e2.slice(C3 + 1).join("").startsWith(y)), s2) {
|
|
404
|
+
i2 ? o3 === w$1 && (s2 = false, i2 = false) : o3 === R && (s2 = false);
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
D2 += E, D2 === F3 && C3 < e2.length - 1 && (t2.push(""), D2 = 0);
|
|
408
|
+
}
|
|
409
|
+
!D2 && t2[t2.length - 1].length > 0 && t2.length > 1 && (t2[t2.length - 2] += t2.pop());
|
|
410
|
+
};
|
|
411
|
+
nD = (t2) => {
|
|
412
|
+
const u3 = t2.split(" ");
|
|
413
|
+
let F3 = u3.length;
|
|
414
|
+
for (; F3 > 0 && !(A$1(u3[F3 - 1]) > 0); ) F3--;
|
|
415
|
+
return F3 === u3.length ? t2 : u3.slice(0, F3).join(" ") + u3.slice(F3).join("");
|
|
416
|
+
};
|
|
417
|
+
oD = (t2, u3, F3 = {}) => {
|
|
418
|
+
if (F3.trim !== false && t2.trim() === "") return "";
|
|
419
|
+
let e2 = "", s2, i2;
|
|
420
|
+
const D2 = ED(t2);
|
|
421
|
+
let C3 = [""];
|
|
422
|
+
for (const [E, a2] of t2.split(" ").entries()) {
|
|
423
|
+
F3.trim !== false && (C3[C3.length - 1] = C3[C3.length - 1].trimStart());
|
|
424
|
+
let n2 = A$1(C3[C3.length - 1]);
|
|
425
|
+
if (E !== 0 && (n2 >= u3 && (F3.wordWrap === false || F3.trim === false) && (C3.push(""), n2 = 0), (n2 > 0 || F3.trim === false) && (C3[C3.length - 1] += " ", n2++)), F3.hard && D2[E] > u3) {
|
|
426
|
+
const B2 = u3 - n2, p = 1 + Math.floor((D2[E] - B2 - 1) / u3);
|
|
427
|
+
Math.floor((D2[E] - 1) / u3) < p && C3.push(""), _(C3, a2, u3);
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (n2 + D2[E] > u3 && n2 > 0 && D2[E] > 0) {
|
|
431
|
+
if (F3.wordWrap === false && n2 < u3) {
|
|
432
|
+
_(C3, a2, u3);
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
C3.push("");
|
|
436
|
+
}
|
|
437
|
+
if (n2 + D2[E] > u3 && F3.wordWrap === false) {
|
|
438
|
+
_(C3, a2, u3);
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
C3[C3.length - 1] += a2;
|
|
442
|
+
}
|
|
443
|
+
F3.trim !== false && (C3 = C3.map((E) => nD(E)));
|
|
444
|
+
const o3 = [...C3.join(`
|
|
445
|
+
`)];
|
|
446
|
+
for (const [E, a2] of o3.entries()) {
|
|
447
|
+
if (e2 += a2, v.has(a2)) {
|
|
448
|
+
const { groups: B2 } = new RegExp(`(?:\\${W$1}(?<code>\\d+)m|\\${y}(?<uri>.*)${w$1})`).exec(o3.slice(E).join("")) || { groups: {} };
|
|
449
|
+
if (B2.code !== void 0) {
|
|
450
|
+
const p = Number.parseFloat(B2.code);
|
|
451
|
+
s2 = p === CD ? void 0 : p;
|
|
452
|
+
} else B2.uri !== void 0 && (i2 = B2.uri.length === 0 ? void 0 : B2.uri);
|
|
453
|
+
}
|
|
454
|
+
const n2 = iD.codes.get(Number(s2));
|
|
455
|
+
o3[E + 1] === `
|
|
456
|
+
` ? (i2 && (e2 += z("")), s2 && n2 && (e2 += V$1(n2))) : a2 === `
|
|
457
|
+
` && (s2 && n2 && (e2 += V$1(s2)), i2 && (e2 += z(i2)));
|
|
458
|
+
}
|
|
459
|
+
return e2;
|
|
460
|
+
};
|
|
461
|
+
aD = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
462
|
+
c = { actions: new Set(aD), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]) };
|
|
463
|
+
globalThis.process.platform.startsWith("win");
|
|
464
|
+
S = /* @__PURE__ */ Symbol("clack:cancel");
|
|
465
|
+
AD = Object.defineProperty;
|
|
466
|
+
pD = (t2, u3, F3) => u3 in t2 ? AD(t2, u3, { enumerable: true, configurable: true, writable: true, value: F3 }) : t2[u3] = F3;
|
|
467
|
+
h = (t2, u3, F3) => (pD(t2, typeof u3 != "symbol" ? u3 + "" : u3, F3), F3);
|
|
468
|
+
x = class {
|
|
469
|
+
constructor(u3, F3 = true) {
|
|
470
|
+
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");
|
|
471
|
+
const { input: e2 = stdin, output: s2 = stdout, render: i2, signal: D2, ...C3 } = u3;
|
|
472
|
+
this.opts = C3, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i2.bind(this), this._track = F3, this._abortSignal = D2, this.input = e2, this.output = s2;
|
|
473
|
+
}
|
|
474
|
+
unsubscribe() {
|
|
475
|
+
this._subscribers.clear();
|
|
476
|
+
}
|
|
477
|
+
setSubscriber(u3, F3) {
|
|
478
|
+
const e2 = this._subscribers.get(u3) ?? [];
|
|
479
|
+
e2.push(F3), this._subscribers.set(u3, e2);
|
|
480
|
+
}
|
|
481
|
+
on(u3, F3) {
|
|
482
|
+
this.setSubscriber(u3, { cb: F3 });
|
|
483
|
+
}
|
|
484
|
+
once(u3, F3) {
|
|
485
|
+
this.setSubscriber(u3, { cb: F3, once: true });
|
|
486
|
+
}
|
|
487
|
+
emit(u3, ...F3) {
|
|
488
|
+
const e2 = this._subscribers.get(u3) ?? [], s2 = [];
|
|
489
|
+
for (const i2 of e2) i2.cb(...F3), i2.once && s2.push(() => e2.splice(e2.indexOf(i2), 1));
|
|
490
|
+
for (const i2 of s2) i2();
|
|
491
|
+
}
|
|
492
|
+
prompt() {
|
|
493
|
+
return new Promise((u3, F3) => {
|
|
494
|
+
if (this._abortSignal) {
|
|
495
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u3(S);
|
|
496
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
497
|
+
this.state = "cancel", this.close();
|
|
498
|
+
}, { once: true });
|
|
499
|
+
}
|
|
500
|
+
const e2 = new WriteStream(0);
|
|
501
|
+
e2._write = (s2, i2, D2) => {
|
|
502
|
+
this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D2();
|
|
503
|
+
}, this.input.pipe(e2), this.rl = f.createInterface({ input: this.input, output: e2, tabSize: 2, prompt: "", escapeCodeTimeout: 50 }), f.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), d$1(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
504
|
+
this.output.write(srcExports.cursor.show), this.output.off("resize", this.render), d$1(this.input, false), u3(this.value);
|
|
505
|
+
}), this.once("cancel", () => {
|
|
506
|
+
this.output.write(srcExports.cursor.show), this.output.off("resize", this.render), d$1(this.input, false), u3(S);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
onKeypress(u3, F3) {
|
|
511
|
+
if (this.state === "error" && (this.state = "active"), F3?.name && (!this._track && c.aliases.has(F3.name) && this.emit("cursor", c.aliases.get(F3.name)), c.actions.has(F3.name) && this.emit("cursor", F3.name)), u3 && (u3.toLowerCase() === "y" || u3.toLowerCase() === "n") && this.emit("confirm", u3.toLowerCase() === "y"), u3 === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u3 && this.emit("key", u3.toLowerCase()), F3?.name === "return") {
|
|
512
|
+
if (this.opts.validate) {
|
|
513
|
+
const e2 = this.opts.validate(this.value);
|
|
514
|
+
e2 && (this.error = e2 instanceof Error ? e2.message : e2, this.state = "error", this.rl?.write(this.value));
|
|
515
|
+
}
|
|
516
|
+
this.state !== "error" && (this.state = "submit");
|
|
517
|
+
}
|
|
518
|
+
k$1([u3, F3?.name, F3?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
519
|
+
}
|
|
520
|
+
close() {
|
|
521
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
522
|
+
`), d$1(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
523
|
+
}
|
|
524
|
+
restoreCursor() {
|
|
525
|
+
const u3 = G(this._prevFrame, process.stdout.columns, { hard: true }).split(`
|
|
526
|
+
`).length - 1;
|
|
527
|
+
this.output.write(srcExports.cursor.move(-999, u3 * -1));
|
|
528
|
+
}
|
|
529
|
+
render() {
|
|
530
|
+
const u3 = G(this._render(this) ?? "", process.stdout.columns, { hard: true });
|
|
531
|
+
if (u3 !== this._prevFrame) {
|
|
532
|
+
if (this.state === "initial") this.output.write(srcExports.cursor.hide);
|
|
533
|
+
else {
|
|
534
|
+
const F3 = lD(this._prevFrame, u3);
|
|
535
|
+
if (this.restoreCursor(), F3 && F3?.length === 1) {
|
|
536
|
+
const e2 = F3[0];
|
|
537
|
+
this.output.write(srcExports.cursor.move(0, e2)), this.output.write(srcExports.erase.lines(1));
|
|
538
|
+
const s2 = u3.split(`
|
|
539
|
+
`);
|
|
540
|
+
this.output.write(s2[e2]), this._prevFrame = u3, this.output.write(srcExports.cursor.move(0, s2.length - e2 - 1));
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (F3 && F3?.length > 1) {
|
|
544
|
+
const e2 = F3[0];
|
|
545
|
+
this.output.write(srcExports.cursor.move(0, e2)), this.output.write(srcExports.erase.down());
|
|
546
|
+
const s2 = u3.split(`
|
|
547
|
+
`).slice(e2);
|
|
548
|
+
this.output.write(s2.join(`
|
|
549
|
+
`)), this._prevFrame = u3;
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.output.write(srcExports.erase.down());
|
|
553
|
+
}
|
|
554
|
+
this.output.write(u3), this.state === "initial" && (this.state = "active"), this._prevFrame = u3;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
fD = class extends x {
|
|
559
|
+
get cursor() {
|
|
560
|
+
return this.value ? 0 : 1;
|
|
561
|
+
}
|
|
562
|
+
get _value() {
|
|
563
|
+
return this.cursor === 0;
|
|
564
|
+
}
|
|
565
|
+
constructor(u3) {
|
|
566
|
+
super(u3, false), this.value = !!u3.initialValue, this.on("value", () => {
|
|
567
|
+
this.value = this._value;
|
|
568
|
+
}), this.on("confirm", (F3) => {
|
|
569
|
+
this.output.write(srcExports.cursor.move(0, -1)), this.value = F3, this.state = "submit", this.close();
|
|
570
|
+
}), this.on("cursor", () => {
|
|
571
|
+
this.value = !this.value;
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
bD = Object.defineProperty;
|
|
576
|
+
mD = (t2, u3, F3) => u3 in t2 ? bD(t2, u3, { enumerable: true, configurable: true, writable: true, value: F3 }) : t2[u3] = F3;
|
|
577
|
+
Y = (t2, u3, F3) => (mD(t2, typeof u3 != "symbol" ? u3 + "" : u3, F3), F3);
|
|
578
|
+
wD = class extends x {
|
|
579
|
+
constructor(u3) {
|
|
580
|
+
super(u3, false), Y(this, "options"), Y(this, "cursor", 0), this.options = u3.options, this.value = [...u3.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F3 }) => F3 === u3.cursorAt), 0), this.on("key", (F3) => {
|
|
581
|
+
F3 === "a" && this.toggleAll();
|
|
582
|
+
}), this.on("cursor", (F3) => {
|
|
583
|
+
switch (F3) {
|
|
584
|
+
case "left":
|
|
585
|
+
case "up":
|
|
586
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
587
|
+
break;
|
|
588
|
+
case "down":
|
|
589
|
+
case "right":
|
|
590
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
591
|
+
break;
|
|
592
|
+
case "space":
|
|
593
|
+
this.toggleValue();
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
get _value() {
|
|
599
|
+
return this.options[this.cursor].value;
|
|
600
|
+
}
|
|
601
|
+
toggleAll() {
|
|
602
|
+
const u3 = this.value.length === this.options.length;
|
|
603
|
+
this.value = u3 ? [] : this.options.map((F3) => F3.value);
|
|
604
|
+
}
|
|
605
|
+
toggleValue() {
|
|
606
|
+
const u3 = this.value.includes(this._value);
|
|
607
|
+
this.value = u3 ? this.value.filter((F3) => F3 !== this._value) : [...this.value, this._value];
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
SD = Object.defineProperty;
|
|
611
|
+
$D = (t2, u3, F3) => u3 in t2 ? SD(t2, u3, { enumerable: true, configurable: true, writable: true, value: F3 }) : t2[u3] = F3;
|
|
612
|
+
q = (t2, u3, F3) => ($D(t2, typeof u3 != "symbol" ? u3 + "" : u3, F3), F3);
|
|
613
|
+
jD = class extends x {
|
|
614
|
+
constructor(u3) {
|
|
615
|
+
super(u3, false), q(this, "options"), q(this, "cursor", 0), this.options = u3.options, this.cursor = this.options.findIndex(({ value: F3 }) => F3 === u3.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F3) => {
|
|
616
|
+
switch (F3) {
|
|
617
|
+
case "left":
|
|
618
|
+
case "up":
|
|
619
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
620
|
+
break;
|
|
621
|
+
case "down":
|
|
622
|
+
case "right":
|
|
623
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
this.changeValue();
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
get _value() {
|
|
630
|
+
return this.options[this.cursor];
|
|
631
|
+
}
|
|
632
|
+
changeValue() {
|
|
633
|
+
this.value = this._value.value;
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
PD = class extends x {
|
|
637
|
+
get valueWithCursor() {
|
|
638
|
+
if (this.state === "submit") return this.value;
|
|
639
|
+
if (this.cursor >= this.value.length) return `${this.value}\u2588`;
|
|
640
|
+
const u3 = this.value.slice(0, this.cursor), [F3, ...e$1] = this.value.slice(this.cursor);
|
|
641
|
+
return `${u3}${e.inverse(F3)}${e$1.join("")}`;
|
|
642
|
+
}
|
|
643
|
+
get cursor() {
|
|
644
|
+
return this._cursor;
|
|
645
|
+
}
|
|
646
|
+
constructor(u3) {
|
|
647
|
+
super(u3), this.on("finalize", () => {
|
|
648
|
+
this.value || (this.value = u3.defaultValue);
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
V = ce();
|
|
653
|
+
u = (t2, n2) => V ? t2 : n2;
|
|
654
|
+
le = u("\u276F", ">");
|
|
655
|
+
L = u("\u25A0", "x");
|
|
656
|
+
W = u("\u25B2", "x");
|
|
657
|
+
C = u("\u2714", "\u221A");
|
|
658
|
+
o = u("");
|
|
659
|
+
d = u("");
|
|
660
|
+
k = u("\u25CF", ">");
|
|
661
|
+
P = u("\u25CB", " ");
|
|
662
|
+
A = u("\u25FB", "[\u2022]");
|
|
663
|
+
T = u("\u25FC", "[+]");
|
|
664
|
+
F = u("\u25FB", "[ ]");
|
|
665
|
+
w = (t2) => {
|
|
666
|
+
switch (t2) {
|
|
667
|
+
case "initial":
|
|
668
|
+
case "active":
|
|
669
|
+
return e.cyan(le);
|
|
670
|
+
case "cancel":
|
|
671
|
+
return e.red(L);
|
|
672
|
+
case "error":
|
|
673
|
+
return e.yellow(W);
|
|
674
|
+
case "submit":
|
|
675
|
+
return e.green(C);
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
B = (t2) => {
|
|
679
|
+
const { cursor: n2, options: s2, style: r3 } = t2, i2 = t2.maxItems ?? Number.POSITIVE_INFINITY, a2 = Math.max(process.stdout.rows - 4, 0), c3 = Math.min(a2, Math.max(i2, 5));
|
|
680
|
+
let l2 = 0;
|
|
681
|
+
n2 >= l2 + c3 - 3 ? l2 = Math.max(Math.min(n2 - c3 + 3, s2.length - c3), 0) : n2 < l2 + 2 && (l2 = Math.max(n2 - 2, 0));
|
|
682
|
+
const $ = c3 < s2.length && l2 > 0, p = c3 < s2.length && l2 + c3 < s2.length;
|
|
683
|
+
return s2.slice(l2, l2 + c3).map((M, v2, x2) => {
|
|
684
|
+
const j = v2 === 0 && $, E = v2 === x2.length - 1 && p;
|
|
685
|
+
return j || E ? e.dim("...") : r3(M, v2 + l2 === n2);
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
he = (t2) => new PD({ validate: t2.validate, placeholder: t2.placeholder, defaultValue: t2.defaultValue, initialValue: t2.initialValue, render() {
|
|
689
|
+
const n2 = `${e.gray(o)}
|
|
690
|
+
${w(this.state)} ${t2.message}
|
|
691
|
+
`, s2 = t2.placeholder ? e.inverse(t2.placeholder[0]) + e.dim(t2.placeholder.slice(1)) : e.inverse(e.hidden("_")), r3 = this.value ? this.valueWithCursor : s2;
|
|
692
|
+
switch (this.state) {
|
|
693
|
+
case "error":
|
|
694
|
+
return `${n2.trim()}
|
|
695
|
+
${e.yellow(o)} ${r3}
|
|
696
|
+
${e.yellow(d)} ${e.yellow(this.error)}
|
|
697
|
+
`;
|
|
698
|
+
case "submit":
|
|
699
|
+
return `${n2}${e.gray(o)} ${e.dim(this.value || t2.placeholder)}`;
|
|
700
|
+
case "cancel":
|
|
701
|
+
return `${n2}${e.gray(o)} ${e.strikethrough(e.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
702
|
+
${e.gray(o)}` : ""}`;
|
|
703
|
+
default:
|
|
704
|
+
return `${n2}${e.cyan(o)} ${r3}
|
|
705
|
+
${e.cyan(d)}
|
|
706
|
+
`;
|
|
707
|
+
}
|
|
708
|
+
} }).prompt();
|
|
709
|
+
ye = (t2) => {
|
|
710
|
+
const n2 = t2.active ?? "Yes", s2 = t2.inactive ?? "No";
|
|
711
|
+
return new fD({ active: n2, inactive: s2, initialValue: t2.initialValue ?? true, render() {
|
|
712
|
+
const r3 = `${e.gray(o)}
|
|
713
|
+
${w(this.state)} ${t2.message}
|
|
714
|
+
`, i2 = this.value ? n2 : s2;
|
|
715
|
+
switch (this.state) {
|
|
716
|
+
case "submit":
|
|
717
|
+
return `${r3}${e.gray(o)} ${e.dim(i2)}`;
|
|
718
|
+
case "cancel":
|
|
719
|
+
return `${r3}${e.gray(o)} ${e.strikethrough(e.dim(i2))}
|
|
720
|
+
${e.gray(o)}`;
|
|
721
|
+
default:
|
|
722
|
+
return `${r3}${e.cyan(o)} ${this.value ? `${e.green(k)} ${n2}` : `${e.dim(P)} ${e.dim(n2)}`} ${e.dim("/")} ${this.value ? `${e.dim(P)} ${e.dim(s2)}` : `${e.green(k)} ${s2}`}
|
|
723
|
+
${e.cyan(d)}
|
|
724
|
+
`;
|
|
725
|
+
}
|
|
726
|
+
} }).prompt();
|
|
727
|
+
};
|
|
728
|
+
ve = (t2) => {
|
|
729
|
+
const n2 = (s2, r3) => {
|
|
730
|
+
const i2 = s2.label ?? String(s2.value);
|
|
731
|
+
switch (r3) {
|
|
732
|
+
case "selected":
|
|
733
|
+
return `${e.dim(i2)}`;
|
|
734
|
+
case "active":
|
|
735
|
+
return `${e.green(k)} ${i2} ${s2.hint ? e.dim(`(${s2.hint})`) : ""}`;
|
|
736
|
+
case "cancelled":
|
|
737
|
+
return `${e.strikethrough(e.dim(i2))}`;
|
|
738
|
+
default:
|
|
739
|
+
return `${e.dim(P)} ${e.dim(i2)}`;
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
return new jD({ options: t2.options, initialValue: t2.initialValue, render() {
|
|
743
|
+
const s2 = `${e.gray(o)}
|
|
744
|
+
${w(this.state)} ${t2.message}
|
|
745
|
+
`;
|
|
746
|
+
switch (this.state) {
|
|
747
|
+
case "submit":
|
|
748
|
+
return `${s2}${e.gray(o)} ${n2(this.options[this.cursor], "selected")}`;
|
|
749
|
+
case "cancel":
|
|
750
|
+
return `${s2}${e.gray(o)} ${n2(this.options[this.cursor], "cancelled")}
|
|
751
|
+
${e.gray(o)}`;
|
|
752
|
+
default:
|
|
753
|
+
return `${s2}${e.cyan(o)} ${B({ cursor: this.cursor, options: this.options, maxItems: t2.maxItems, style: (r3, i2) => n2(r3, i2 ? "active" : "inactive") }).join(`
|
|
754
|
+
${e.cyan(o)} `)}
|
|
755
|
+
${e.cyan(d)}
|
|
756
|
+
`;
|
|
757
|
+
}
|
|
758
|
+
} }).prompt();
|
|
759
|
+
};
|
|
760
|
+
fe = (t2) => {
|
|
761
|
+
const n2 = (s2, r3) => {
|
|
762
|
+
const i2 = s2.label ?? String(s2.value);
|
|
763
|
+
return r3 === "active" ? `${e.cyan(A)} ${i2} ${s2.hint ? e.dim(`(${s2.hint})`) : ""}` : r3 === "selected" ? `${e.green(T)} ${e.dim(i2)}` : r3 === "cancelled" ? `${e.strikethrough(e.dim(i2))}` : r3 === "active-selected" ? `${e.green(T)} ${i2} ${s2.hint ? e.dim(`(${s2.hint})`) : ""}` : r3 === "submitted" ? `${e.dim(i2)}` : `${e.dim(F)} ${e.dim(i2)}`;
|
|
764
|
+
};
|
|
765
|
+
return new wD({ options: t2.options, initialValues: t2.initialValues, required: t2.required ?? true, cursorAt: t2.cursorAt, validate(s2) {
|
|
766
|
+
if (this.required && s2.length === 0) return `Please select at least one option.
|
|
767
|
+
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`;
|
|
768
|
+
}, render() {
|
|
769
|
+
const s2 = `${e.gray(o)}
|
|
770
|
+
${w(this.state)} ${t2.message}
|
|
771
|
+
`, r3 = (i2, a2) => {
|
|
772
|
+
const c3 = this.value.includes(i2.value);
|
|
773
|
+
return a2 && c3 ? n2(i2, "active-selected") : c3 ? n2(i2, "selected") : n2(i2, a2 ? "active" : "inactive");
|
|
774
|
+
};
|
|
775
|
+
switch (this.state) {
|
|
776
|
+
case "submit":
|
|
777
|
+
return `${s2}${e.gray(o)} ${this.options.filter(({ value: i2 }) => this.value.includes(i2)).map((i2) => n2(i2, "submitted")).join(e.dim(", ")) || e.dim("none")}`;
|
|
778
|
+
case "cancel": {
|
|
779
|
+
const i2 = this.options.filter(({ value: a2 }) => this.value.includes(a2)).map((a2) => n2(a2, "cancelled")).join(e.dim(", "));
|
|
780
|
+
return `${s2}${e.gray(o)} ${i2.trim() ? `${i2}
|
|
781
|
+
${e.gray(o)}` : ""}`;
|
|
782
|
+
}
|
|
783
|
+
case "error": {
|
|
784
|
+
const i2 = this.error.split(`
|
|
785
|
+
`).map((a2, c3) => c3 === 0 ? `${e.yellow(d)} ${e.yellow(a2)}` : ` ${a2}`).join(`
|
|
786
|
+
`);
|
|
787
|
+
return `${s2 + e.yellow(o)} ${B({ options: this.options, cursor: this.cursor, maxItems: t2.maxItems, style: r3 }).join(`
|
|
788
|
+
${e.yellow(o)} `)}
|
|
789
|
+
${i2}
|
|
790
|
+
`;
|
|
791
|
+
}
|
|
792
|
+
default:
|
|
793
|
+
return `${s2}${e.cyan(o)} ${B({ options: this.options, cursor: this.cursor, maxItems: t2.maxItems, style: r3 }).join(`
|
|
794
|
+
${e.cyan(o)} `)}
|
|
795
|
+
${e.cyan(d)}
|
|
796
|
+
`;
|
|
797
|
+
}
|
|
798
|
+
} }).prompt();
|
|
799
|
+
};
|
|
800
|
+
`${e.gray(o)} `;
|
|
801
|
+
kCancel = /* @__PURE__ */ Symbol.for("cancel");
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
// ../../node_modules/.pnpm/shell-quote@1.8.4/node_modules/shell-quote/quote.js
|
|
806
|
+
var require_quote = __commonJS({
|
|
807
|
+
"../../node_modules/.pnpm/shell-quote@1.8.4/node_modules/shell-quote/quote.js"(exports, module) {
|
|
808
|
+
"use strict";
|
|
809
|
+
var OPS = [
|
|
810
|
+
"||",
|
|
811
|
+
"&&",
|
|
812
|
+
";;",
|
|
813
|
+
"|&",
|
|
814
|
+
"<(",
|
|
815
|
+
"<<<",
|
|
816
|
+
">>",
|
|
817
|
+
">&",
|
|
818
|
+
"<&",
|
|
819
|
+
"&",
|
|
820
|
+
";",
|
|
821
|
+
"(",
|
|
822
|
+
")",
|
|
823
|
+
"|",
|
|
824
|
+
"<",
|
|
825
|
+
">"
|
|
826
|
+
];
|
|
827
|
+
var LINE_TERMINATORS = /[\n\r\u2028\u2029]/;
|
|
828
|
+
var GLOB_SHELL_SPECIAL = /[\s#!"$&'():;<=>@\\^`|]/g;
|
|
829
|
+
module.exports = function quote(xs) {
|
|
830
|
+
return xs.map(function(s2) {
|
|
831
|
+
if (s2 === "") {
|
|
832
|
+
return "''";
|
|
833
|
+
}
|
|
834
|
+
if (s2 && typeof s2 === "object") {
|
|
835
|
+
if (s2.op === "glob") {
|
|
836
|
+
if (typeof s2.pattern !== "string") {
|
|
837
|
+
throw new TypeError("glob token requires a string `pattern`");
|
|
838
|
+
}
|
|
839
|
+
if (LINE_TERMINATORS.test(s2.pattern)) {
|
|
840
|
+
throw new TypeError("glob `pattern` must not contain line terminators");
|
|
841
|
+
}
|
|
842
|
+
return s2.pattern.replace(GLOB_SHELL_SPECIAL, "\\$&");
|
|
843
|
+
}
|
|
844
|
+
if (typeof s2.op === "string") {
|
|
845
|
+
if (OPS.indexOf(s2.op) < 0) {
|
|
846
|
+
throw new TypeError("invalid `op` value: " + JSON.stringify(s2.op));
|
|
847
|
+
}
|
|
848
|
+
return s2.op.replace(/[\s\S]/g, "\\$&");
|
|
849
|
+
}
|
|
850
|
+
if (typeof s2.comment === "string") {
|
|
851
|
+
if (LINE_TERMINATORS.test(s2.comment)) {
|
|
852
|
+
throw new TypeError("`comment` must not contain line terminators");
|
|
853
|
+
}
|
|
854
|
+
return "#" + s2.comment;
|
|
855
|
+
}
|
|
856
|
+
throw new TypeError("unrecognized object token shape");
|
|
857
|
+
}
|
|
858
|
+
if (/["\s\\]/.test(s2) && !/'/.test(s2)) {
|
|
859
|
+
return "'" + s2.replace(/(['])/g, "\\$1") + "'";
|
|
860
|
+
}
|
|
861
|
+
if (/["'\s]/.test(s2)) {
|
|
862
|
+
return '"' + s2.replace(/(["\\$`!])/g, "\\$1") + '"';
|
|
863
|
+
}
|
|
864
|
+
return String(s2).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
|
|
865
|
+
}).join(" ");
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// ../../node_modules/.pnpm/shell-quote@1.8.4/node_modules/shell-quote/parse.js
|
|
871
|
+
var require_parse = __commonJS({
|
|
872
|
+
"../../node_modules/.pnpm/shell-quote@1.8.4/node_modules/shell-quote/parse.js"(exports, module) {
|
|
873
|
+
"use strict";
|
|
874
|
+
var CONTROL = "(?:" + [
|
|
875
|
+
"\\|\\|",
|
|
876
|
+
"\\&\\&",
|
|
877
|
+
";;",
|
|
878
|
+
"\\|\\&",
|
|
879
|
+
"\\<\\(",
|
|
880
|
+
"\\<\\<\\<",
|
|
881
|
+
">>",
|
|
882
|
+
">\\&",
|
|
883
|
+
"<\\&",
|
|
884
|
+
"[&;()|<>]"
|
|
885
|
+
].join("|") + ")";
|
|
886
|
+
var controlRE = new RegExp("^" + CONTROL + "$");
|
|
887
|
+
var META = "|&;()<> \\t";
|
|
888
|
+
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
|
|
889
|
+
var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'";
|
|
890
|
+
var hash = /^#$/;
|
|
891
|
+
var SQ = "'";
|
|
892
|
+
var DQ = '"';
|
|
893
|
+
var DS = "$";
|
|
894
|
+
var TOKEN = "";
|
|
895
|
+
var mult = 4294967296;
|
|
896
|
+
for (i2 = 0; i2 < 4; i2++) {
|
|
897
|
+
TOKEN += (mult * Math.random()).toString(16);
|
|
898
|
+
}
|
|
899
|
+
var i2;
|
|
900
|
+
var startsWithToken = new RegExp("^" + TOKEN);
|
|
901
|
+
function matchAll(s2, r3) {
|
|
902
|
+
var origIndex = r3.lastIndex;
|
|
903
|
+
var matches = [];
|
|
904
|
+
var matchObj;
|
|
905
|
+
while (matchObj = r3.exec(s2)) {
|
|
906
|
+
matches.push(matchObj);
|
|
907
|
+
if (r3.lastIndex === matchObj.index) {
|
|
908
|
+
r3.lastIndex += 1;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
r3.lastIndex = origIndex;
|
|
912
|
+
return matches;
|
|
913
|
+
}
|
|
914
|
+
function getVar(env2, pre, key) {
|
|
915
|
+
var r3 = typeof env2 === "function" ? env2(key) : env2[key];
|
|
916
|
+
if (typeof r3 === "undefined" && key != "") {
|
|
917
|
+
r3 = "";
|
|
918
|
+
} else if (typeof r3 === "undefined") {
|
|
919
|
+
r3 = "$";
|
|
920
|
+
}
|
|
921
|
+
if (typeof r3 === "object") {
|
|
922
|
+
return pre + TOKEN + JSON.stringify(r3) + TOKEN;
|
|
923
|
+
}
|
|
924
|
+
return pre + r3;
|
|
925
|
+
}
|
|
926
|
+
function parseInternal(string, env2, opts) {
|
|
927
|
+
if (!opts) {
|
|
928
|
+
opts = {};
|
|
929
|
+
}
|
|
930
|
+
var BS = opts.escape || "\\";
|
|
931
|
+
var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
|
|
932
|
+
var chunker = new RegExp([
|
|
933
|
+
"(" + CONTROL + ")",
|
|
934
|
+
// control chars
|
|
935
|
+
"(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+"
|
|
936
|
+
].join("|"), "g");
|
|
937
|
+
var matches = matchAll(string, chunker);
|
|
938
|
+
if (matches.length === 0) {
|
|
939
|
+
return [];
|
|
940
|
+
}
|
|
941
|
+
if (!env2) {
|
|
942
|
+
env2 = {};
|
|
943
|
+
}
|
|
944
|
+
var commented = false;
|
|
945
|
+
return matches.map(function(match) {
|
|
946
|
+
var s2 = match[0];
|
|
947
|
+
if (!s2 || commented) {
|
|
948
|
+
return void 0;
|
|
949
|
+
}
|
|
950
|
+
if (controlRE.test(s2)) {
|
|
951
|
+
return { op: s2 };
|
|
952
|
+
}
|
|
953
|
+
var quote = false;
|
|
954
|
+
var esc = false;
|
|
955
|
+
var out = "";
|
|
956
|
+
var isGlob = false;
|
|
957
|
+
var i3;
|
|
958
|
+
function parseEnvVar() {
|
|
959
|
+
i3 += 1;
|
|
960
|
+
var varend;
|
|
961
|
+
var varname;
|
|
962
|
+
var char = s2.charAt(i3);
|
|
963
|
+
if (char === "{") {
|
|
964
|
+
i3 += 1;
|
|
965
|
+
if (s2.charAt(i3) === "}") {
|
|
966
|
+
throw new Error("Bad substitution: " + s2.slice(i3 - 2, i3 + 1));
|
|
967
|
+
}
|
|
968
|
+
varend = s2.indexOf("}", i3);
|
|
969
|
+
if (varend < 0) {
|
|
970
|
+
throw new Error("Bad substitution: " + s2.slice(i3));
|
|
971
|
+
}
|
|
972
|
+
varname = s2.slice(i3, varend);
|
|
973
|
+
i3 = varend;
|
|
974
|
+
} else if (/[*@#?$!_-]/.test(char)) {
|
|
975
|
+
varname = char;
|
|
976
|
+
i3 += 1;
|
|
977
|
+
} else {
|
|
978
|
+
var slicedFromI = s2.slice(i3);
|
|
979
|
+
varend = slicedFromI.match(/[^\w\d_]/);
|
|
980
|
+
if (!varend) {
|
|
981
|
+
varname = slicedFromI;
|
|
982
|
+
i3 = s2.length;
|
|
983
|
+
} else {
|
|
984
|
+
varname = slicedFromI.slice(0, varend.index);
|
|
985
|
+
i3 += varend.index - 1;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
return getVar(env2, "", varname);
|
|
989
|
+
}
|
|
990
|
+
for (i3 = 0; i3 < s2.length; i3++) {
|
|
991
|
+
var c3 = s2.charAt(i3);
|
|
992
|
+
isGlob = isGlob || !quote && (c3 === "*" || c3 === "?");
|
|
993
|
+
if (esc) {
|
|
994
|
+
out += c3;
|
|
995
|
+
esc = false;
|
|
996
|
+
} else if (quote) {
|
|
997
|
+
if (c3 === quote) {
|
|
998
|
+
quote = false;
|
|
999
|
+
} else if (quote == SQ) {
|
|
1000
|
+
out += c3;
|
|
1001
|
+
} else {
|
|
1002
|
+
if (c3 === BS) {
|
|
1003
|
+
i3 += 1;
|
|
1004
|
+
c3 = s2.charAt(i3);
|
|
1005
|
+
if (c3 === DQ || c3 === BS || c3 === DS) {
|
|
1006
|
+
out += c3;
|
|
1007
|
+
} else {
|
|
1008
|
+
out += BS + c3;
|
|
1009
|
+
}
|
|
1010
|
+
} else if (c3 === DS) {
|
|
1011
|
+
out += parseEnvVar();
|
|
1012
|
+
} else {
|
|
1013
|
+
out += c3;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
} else if (c3 === DQ || c3 === SQ) {
|
|
1017
|
+
quote = c3;
|
|
1018
|
+
} else if (controlRE.test(c3)) {
|
|
1019
|
+
return { op: s2 };
|
|
1020
|
+
} else if (hash.test(c3)) {
|
|
1021
|
+
commented = true;
|
|
1022
|
+
var commentObj = { comment: string.slice(match.index + i3 + 1) };
|
|
1023
|
+
if (out.length) {
|
|
1024
|
+
return [out, commentObj];
|
|
1025
|
+
}
|
|
1026
|
+
return [commentObj];
|
|
1027
|
+
} else if (c3 === BS) {
|
|
1028
|
+
esc = true;
|
|
1029
|
+
} else if (c3 === DS) {
|
|
1030
|
+
out += parseEnvVar();
|
|
1031
|
+
} else {
|
|
1032
|
+
out += c3;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
if (isGlob) {
|
|
1036
|
+
return { op: "glob", pattern: out };
|
|
1037
|
+
}
|
|
1038
|
+
return out;
|
|
1039
|
+
}).reduce(function(prev, arg) {
|
|
1040
|
+
return typeof arg === "undefined" ? prev : prev.concat(arg);
|
|
1041
|
+
}, []);
|
|
1042
|
+
}
|
|
1043
|
+
module.exports = function parse(s2, env2, opts) {
|
|
1044
|
+
var mapped = parseInternal(s2, env2, opts);
|
|
1045
|
+
if (typeof env2 !== "function") {
|
|
1046
|
+
return mapped;
|
|
1047
|
+
}
|
|
1048
|
+
return mapped.reduce(function(acc, s3) {
|
|
1049
|
+
if (typeof s3 === "object") {
|
|
1050
|
+
return acc.concat(s3);
|
|
1051
|
+
}
|
|
1052
|
+
var xs = s3.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
|
|
1053
|
+
if (xs.length === 1) {
|
|
1054
|
+
return acc.concat(xs[0]);
|
|
1055
|
+
}
|
|
1056
|
+
return acc.concat(xs.filter(Boolean).map(function(x2) {
|
|
1057
|
+
if (startsWithToken.test(x2)) {
|
|
1058
|
+
return JSON.parse(x2.split(TOKEN)[1]);
|
|
1059
|
+
}
|
|
1060
|
+
return x2;
|
|
1061
|
+
}));
|
|
1062
|
+
}, []);
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
// ../../node_modules/.pnpm/shell-quote@1.8.4/node_modules/shell-quote/index.js
|
|
1068
|
+
var require_shell_quote = __commonJS({
|
|
1069
|
+
"../../node_modules/.pnpm/shell-quote@1.8.4/node_modules/shell-quote/index.js"(exports) {
|
|
1070
|
+
"use strict";
|
|
1071
|
+
exports.quote = require_quote();
|
|
1072
|
+
exports.parse = require_parse();
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
// src/service-bridge-main.ts
|
|
1077
|
+
import process4 from "process";
|
|
1078
|
+
|
|
1079
|
+
// src/service-bridge.ts
|
|
1080
|
+
import { randomUUID } from "crypto";
|
|
1081
|
+
import process3 from "process";
|
|
1082
|
+
|
|
1083
|
+
// ../../packages/apes/dist/chunk-BA2V3BBO.js
|
|
1084
|
+
init_chunk_OBF7IMQ2();
|
|
1085
|
+
|
|
1086
|
+
// ../../node_modules/.pnpm/citty@0.2.2/node_modules/citty/dist/index.mjs
|
|
1087
|
+
import { parseArgs as parseArgs$1 } from "util";
|
|
1088
|
+
function defineCommand(def) {
|
|
1089
|
+
return def;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// ../../packages/shapes/dist/index.js
|
|
1093
|
+
import { createHash } from "crypto";
|
|
1094
|
+
import { existsSync as existsSync2, readdirSync, readFileSync } from "fs";
|
|
1095
|
+
import { homedir as homedir2 } from "os";
|
|
1096
|
+
import { basename, join as join2 } from "path";
|
|
1097
|
+
|
|
1098
|
+
// ../../packages/core/dist/index.js
|
|
1099
|
+
import * as jose from "jose";
|
|
1100
|
+
import { lookup } from "dns/promises";
|
|
1101
|
+
import { isIP } from "net";
|
|
1102
|
+
var HKDF_INFO = new TextEncoder().encode("openape-sealed-box-v1");
|
|
1103
|
+
function isBlockedAddress(ip) {
|
|
1104
|
+
const fam = isIP(ip);
|
|
1105
|
+
if (fam === 4) {
|
|
1106
|
+
const o3 = ip.split(".");
|
|
1107
|
+
const a2 = Number(o3[0]);
|
|
1108
|
+
const b2 = Number(o3[1]);
|
|
1109
|
+
if (a2 === 0) return true;
|
|
1110
|
+
if (a2 === 127) return true;
|
|
1111
|
+
if (a2 === 10) return true;
|
|
1112
|
+
if (a2 === 172 && b2 >= 16 && b2 <= 31) return true;
|
|
1113
|
+
if (a2 === 192 && b2 === 168) return true;
|
|
1114
|
+
if (a2 === 169 && b2 === 254) return true;
|
|
1115
|
+
if (a2 === 100 && b2 >= 64 && b2 <= 127) return true;
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
const low = ip.toLowerCase().replace(/^\[|\]$/g, "");
|
|
1119
|
+
if (low === "::" || low === "::1") return true;
|
|
1120
|
+
if (low.startsWith("fe80")) return true;
|
|
1121
|
+
if (low.startsWith("fc") || low.startsWith("fd")) return true;
|
|
1122
|
+
const mapped = low.match(/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/);
|
|
1123
|
+
if (mapped) return isBlockedAddress(mapped[1]);
|
|
1124
|
+
return false;
|
|
1125
|
+
}
|
|
1126
|
+
async function assertPublicUrl(rawUrl, opts = {}) {
|
|
1127
|
+
let url;
|
|
1128
|
+
try {
|
|
1129
|
+
url = new URL(rawUrl);
|
|
1130
|
+
} catch {
|
|
1131
|
+
throw new Error(`Invalid URL: ${rawUrl}`);
|
|
1132
|
+
}
|
|
1133
|
+
const allowedSchemes = opts.allowHttp === true ? /* @__PURE__ */ new Set(["https:", "http:"]) : /* @__PURE__ */ new Set(["https:"]);
|
|
1134
|
+
if (!allowedSchemes.has(url.protocol)) {
|
|
1135
|
+
const expected = opts.allowHttp === true ? "http(s)" : "https";
|
|
1136
|
+
throw new Error(`URL must use ${expected}:// (got ${url.protocol}//) \u2014 ${rawUrl}`);
|
|
1137
|
+
}
|
|
1138
|
+
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
1139
|
+
const addresses = [];
|
|
1140
|
+
if (isIP(host)) {
|
|
1141
|
+
addresses.push(host);
|
|
1142
|
+
} else {
|
|
1143
|
+
const results = await lookup(host, { all: true });
|
|
1144
|
+
for (const r3 of results) addresses.push(r3.address);
|
|
1145
|
+
}
|
|
1146
|
+
if (addresses.length === 0) {
|
|
1147
|
+
throw new Error(`Host did not resolve: ${host}`);
|
|
1148
|
+
}
|
|
1149
|
+
for (const addr of addresses) {
|
|
1150
|
+
if (isBlockedAddress(addr)) {
|
|
1151
|
+
throw new Error(`Refusing to fetch a private/loopback address (${addr}) for ${rawUrl}`);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return url;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
// ../../packages/grants/dist/index.js
|
|
1158
|
+
function normalizeSelector(selector) {
|
|
1159
|
+
if (!selector)
|
|
1160
|
+
return void 0;
|
|
1161
|
+
const entries = Object.entries(selector).filter(([, value]) => value !== void 0 && value !== "").sort(([a2], [b2]) => a2.localeCompare(b2));
|
|
1162
|
+
if (entries.length === 0)
|
|
1163
|
+
return void 0;
|
|
1164
|
+
return Object.fromEntries(entries);
|
|
1165
|
+
}
|
|
1166
|
+
function selectorString(selector) {
|
|
1167
|
+
const normalized = normalizeSelector(selector);
|
|
1168
|
+
if (!normalized)
|
|
1169
|
+
return "*";
|
|
1170
|
+
return Object.entries(normalized).map(([key, value]) => `${key}=${value}`).join(",");
|
|
1171
|
+
}
|
|
1172
|
+
function canonicalizeCliPermission(detail) {
|
|
1173
|
+
const chain = detail.resource_chain.map((resource) => `${resource.resource}[${selectorString(resource.selector)}]`).join(".");
|
|
1174
|
+
return `${detail.cli_id}.${chain}#${detail.action}`;
|
|
1175
|
+
}
|
|
1176
|
+
async function computeArgvHash(argv2) {
|
|
1177
|
+
const encoder = new TextEncoder();
|
|
1178
|
+
const data = encoder.encode(JSON.stringify(argv2));
|
|
1179
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
1180
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
1181
|
+
const digest2 = Array.from(hashArray).map((b2) => b2.toString(16).padStart(2, "0")).join("");
|
|
1182
|
+
return `SHA-256:${digest2}`;
|
|
1183
|
+
}
|
|
1184
|
+
function parseOptionArgs(tokens, valueOptions) {
|
|
1185
|
+
const options = {};
|
|
1186
|
+
const positionals = [];
|
|
1187
|
+
const takesValue = new Set(valueOptions ?? []);
|
|
1188
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
1189
|
+
const token = tokens[index];
|
|
1190
|
+
if (token.startsWith("--")) {
|
|
1191
|
+
const stripped = token.slice(2);
|
|
1192
|
+
const eqIndex = stripped.indexOf("=");
|
|
1193
|
+
if (eqIndex >= 0) {
|
|
1194
|
+
options[stripped.slice(0, eqIndex)] = stripped.slice(eqIndex + 1);
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
const next = tokens[index + 1];
|
|
1198
|
+
if (next && !next.startsWith("-")) {
|
|
1199
|
+
options[stripped] = next;
|
|
1200
|
+
index += 1;
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
options[stripped] = "true";
|
|
1204
|
+
} else if (token.startsWith("-") && token.length > 1 && !/^-\d/.test(token)) {
|
|
1205
|
+
const key = token.slice(1);
|
|
1206
|
+
if (key.length === 1 && !takesValue.has(key)) {
|
|
1207
|
+
options[key] = "true";
|
|
1208
|
+
} else {
|
|
1209
|
+
const next = tokens[index + 1];
|
|
1210
|
+
if (next && !next.startsWith("-")) {
|
|
1211
|
+
options[key] = next;
|
|
1212
|
+
index += 1;
|
|
1213
|
+
} else {
|
|
1214
|
+
options[key] = "true";
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
} else {
|
|
1218
|
+
positionals.push(token);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
return { options, positionals };
|
|
1222
|
+
}
|
|
1223
|
+
function resolveBindingToken(binding, bindings) {
|
|
1224
|
+
const match = binding.match(/^\{([^}|]+)(?:\|([^}]+))?\}$/);
|
|
1225
|
+
if (!match) return binding;
|
|
1226
|
+
const [, name, transform] = match;
|
|
1227
|
+
const value = bindings[name];
|
|
1228
|
+
if (!value) throw new Error(`Missing binding: ${name}`);
|
|
1229
|
+
if (!transform) return value;
|
|
1230
|
+
if (transform === "owner" || transform === "name") {
|
|
1231
|
+
const [owner, repo] = value.split("/");
|
|
1232
|
+
if (!owner || !repo) throw new Error(`Binding ${name} must be in owner/name form`);
|
|
1233
|
+
return transform === "owner" ? owner : repo;
|
|
1234
|
+
}
|
|
1235
|
+
throw new Error(`Unsupported binding transform: ${transform}`);
|
|
1236
|
+
}
|
|
1237
|
+
function renderTemplate(template, bindings) {
|
|
1238
|
+
return template.replace(/\{([^}]+)\}/g, (_3, expression) => resolveBindingToken(`{${expression}}`, bindings));
|
|
1239
|
+
}
|
|
1240
|
+
function parseResourceChain(chain, bindings) {
|
|
1241
|
+
return chain.map((entry) => {
|
|
1242
|
+
const [resource, selectorSpec = "*"] = entry.split(":", 2);
|
|
1243
|
+
if (!resource) throw new Error(`Invalid resource chain entry: ${entry}`);
|
|
1244
|
+
if (selectorSpec === "*") return { resource };
|
|
1245
|
+
const selector = Object.fromEntries(
|
|
1246
|
+
selectorSpec.split(",").map((segment) => {
|
|
1247
|
+
const [key, rawValue] = segment.split("=", 2);
|
|
1248
|
+
if (!key || !rawValue) throw new Error(`Invalid selector segment: ${segment}`);
|
|
1249
|
+
return [key, renderTemplate(rawValue, bindings)];
|
|
1250
|
+
})
|
|
1251
|
+
);
|
|
1252
|
+
return { resource, selector };
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
function matchOperation(operation, argv2) {
|
|
1256
|
+
if (argv2.length < operation.command.length) return null;
|
|
1257
|
+
const prefix = argv2.slice(0, operation.command.length);
|
|
1258
|
+
if (prefix.join("\0") !== operation.command.join("\0")) return null;
|
|
1259
|
+
const remainder = argv2.slice(operation.command.length);
|
|
1260
|
+
const { options, positionals } = parseOptionArgs(remainder, operation.required_options);
|
|
1261
|
+
const expectedPositionals = operation.positionals ?? [];
|
|
1262
|
+
if (positionals.length !== expectedPositionals.length) return null;
|
|
1263
|
+
for (const option of operation.required_options ?? []) {
|
|
1264
|
+
if (!options[option]) return null;
|
|
1265
|
+
}
|
|
1266
|
+
const bindings = { ...options };
|
|
1267
|
+
for (let index = 0; index < expectedPositionals.length; index += 1) {
|
|
1268
|
+
const name = expectedPositionals[index];
|
|
1269
|
+
const value = positionals[index];
|
|
1270
|
+
if (name.startsWith("=")) {
|
|
1271
|
+
if (value !== name.slice(1)) return null;
|
|
1272
|
+
continue;
|
|
1273
|
+
}
|
|
1274
|
+
bindings[name] = value;
|
|
1275
|
+
}
|
|
1276
|
+
return bindings;
|
|
1277
|
+
}
|
|
1278
|
+
function expandCombinedFlags(argv2) {
|
|
1279
|
+
return argv2.flatMap((token) => {
|
|
1280
|
+
if (token.startsWith("-") && !token.startsWith("--") && token.length > 2 && /^-[a-z]+$/i.test(token)) {
|
|
1281
|
+
return Array.from(token.slice(1), (c3) => `-${c3}`);
|
|
1282
|
+
}
|
|
1283
|
+
return [token];
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
function tryMatch(operations, argv2) {
|
|
1287
|
+
return operations.flatMap((operation) => {
|
|
1288
|
+
try {
|
|
1289
|
+
const bindings = matchOperation(operation, argv2);
|
|
1290
|
+
return bindings ? [{ operation, bindings }] : [];
|
|
1291
|
+
} catch {
|
|
1292
|
+
return [];
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
function matchArgvToOperation(operations, commandArgv) {
|
|
1297
|
+
let matches = tryMatch(operations, commandArgv);
|
|
1298
|
+
if (matches.length === 0) {
|
|
1299
|
+
const expanded = expandCombinedFlags(commandArgv);
|
|
1300
|
+
if (expanded.length !== commandArgv.length) {
|
|
1301
|
+
matches = tryMatch(operations, expanded);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
if (matches.length === 0) return null;
|
|
1305
|
+
if (matches.length > 1) {
|
|
1306
|
+
matches.sort((a2, b2) => b2.operation.command.length - a2.operation.command.length);
|
|
1307
|
+
matches = [matches[0]];
|
|
1308
|
+
}
|
|
1309
|
+
return matches[0];
|
|
1310
|
+
}
|
|
1311
|
+
function buildCliAuthDetail(cliId, operation, bindings) {
|
|
1312
|
+
const resource_chain = parseResourceChain(operation.resource_chain, bindings);
|
|
1313
|
+
const detail = {
|
|
1314
|
+
type: "openape_cli",
|
|
1315
|
+
cli_id: cliId,
|
|
1316
|
+
operation_id: operation.id,
|
|
1317
|
+
resource_chain,
|
|
1318
|
+
action: operation.action,
|
|
1319
|
+
permission: "",
|
|
1320
|
+
display: renderTemplate(operation.display, bindings),
|
|
1321
|
+
risk: operation.risk,
|
|
1322
|
+
...operation.exact_command ? { constraints: { exact_command: true } } : {}
|
|
1323
|
+
};
|
|
1324
|
+
detail.permission = canonicalizeCliPermission(detail);
|
|
1325
|
+
return detail;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
|
|
1329
|
+
var LogLevels = {
|
|
1330
|
+
silent: Number.NEGATIVE_INFINITY,
|
|
1331
|
+
fatal: 0,
|
|
1332
|
+
error: 0,
|
|
1333
|
+
warn: 1,
|
|
1334
|
+
log: 2,
|
|
1335
|
+
info: 3,
|
|
1336
|
+
success: 3,
|
|
1337
|
+
fail: 3,
|
|
1338
|
+
ready: 3,
|
|
1339
|
+
start: 3,
|
|
1340
|
+
box: 3,
|
|
1341
|
+
debug: 4,
|
|
1342
|
+
trace: 5,
|
|
1343
|
+
verbose: Number.POSITIVE_INFINITY
|
|
1344
|
+
};
|
|
1345
|
+
var LogTypes = {
|
|
1346
|
+
// Silent
|
|
1347
|
+
silent: {
|
|
1348
|
+
level: -1
|
|
1349
|
+
},
|
|
1350
|
+
// Level 0
|
|
1351
|
+
fatal: {
|
|
1352
|
+
level: LogLevels.fatal
|
|
1353
|
+
},
|
|
1354
|
+
error: {
|
|
1355
|
+
level: LogLevels.error
|
|
1356
|
+
},
|
|
1357
|
+
// Level 1
|
|
1358
|
+
warn: {
|
|
1359
|
+
level: LogLevels.warn
|
|
1360
|
+
},
|
|
1361
|
+
// Level 2
|
|
1362
|
+
log: {
|
|
1363
|
+
level: LogLevels.log
|
|
1364
|
+
},
|
|
1365
|
+
// Level 3
|
|
1366
|
+
info: {
|
|
1367
|
+
level: LogLevels.info
|
|
1368
|
+
},
|
|
1369
|
+
success: {
|
|
1370
|
+
level: LogLevels.success
|
|
1371
|
+
},
|
|
1372
|
+
fail: {
|
|
1373
|
+
level: LogLevels.fail
|
|
1374
|
+
},
|
|
1375
|
+
ready: {
|
|
1376
|
+
level: LogLevels.info
|
|
1377
|
+
},
|
|
1378
|
+
start: {
|
|
1379
|
+
level: LogLevels.info
|
|
1380
|
+
},
|
|
1381
|
+
box: {
|
|
1382
|
+
level: LogLevels.info
|
|
1383
|
+
},
|
|
1384
|
+
// Level 4
|
|
1385
|
+
debug: {
|
|
1386
|
+
level: LogLevels.debug
|
|
1387
|
+
},
|
|
1388
|
+
// Level 5
|
|
1389
|
+
trace: {
|
|
1390
|
+
level: LogLevels.trace
|
|
1391
|
+
},
|
|
1392
|
+
// Verbose
|
|
1393
|
+
verbose: {
|
|
1394
|
+
level: LogLevels.verbose
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
function isPlainObject$1(value) {
|
|
1398
|
+
if (value === null || typeof value !== "object") {
|
|
1399
|
+
return false;
|
|
1400
|
+
}
|
|
1401
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1402
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
1403
|
+
return false;
|
|
1404
|
+
}
|
|
1405
|
+
if (Symbol.iterator in value) {
|
|
1406
|
+
return false;
|
|
1407
|
+
}
|
|
1408
|
+
if (Symbol.toStringTag in value) {
|
|
1409
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
1410
|
+
}
|
|
1411
|
+
return true;
|
|
1412
|
+
}
|
|
1413
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
1414
|
+
if (!isPlainObject$1(defaults)) {
|
|
1415
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
1416
|
+
}
|
|
1417
|
+
const object = Object.assign({}, defaults);
|
|
1418
|
+
for (const key in baseObject) {
|
|
1419
|
+
if (key === "__proto__" || key === "constructor") {
|
|
1420
|
+
continue;
|
|
1421
|
+
}
|
|
1422
|
+
const value = baseObject[key];
|
|
1423
|
+
if (value === null || value === void 0) {
|
|
1424
|
+
continue;
|
|
1425
|
+
}
|
|
1426
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
1427
|
+
continue;
|
|
1428
|
+
}
|
|
1429
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
1430
|
+
object[key] = [...value, ...object[key]];
|
|
1431
|
+
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
1432
|
+
object[key] = _defu(
|
|
1433
|
+
value,
|
|
1434
|
+
object[key],
|
|
1435
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
1436
|
+
merger
|
|
1437
|
+
);
|
|
1438
|
+
} else {
|
|
1439
|
+
object[key] = value;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
return object;
|
|
1443
|
+
}
|
|
1444
|
+
function createDefu(merger) {
|
|
1445
|
+
return (...arguments_) => (
|
|
1446
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
1447
|
+
arguments_.reduce((p, c3) => _defu(p, c3, "", merger), {})
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
var defu = createDefu();
|
|
1451
|
+
function isPlainObject(obj) {
|
|
1452
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
1453
|
+
}
|
|
1454
|
+
function isLogObj(arg) {
|
|
1455
|
+
if (!isPlainObject(arg)) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
if (!arg.message && !arg.args) {
|
|
1459
|
+
return false;
|
|
1460
|
+
}
|
|
1461
|
+
if (arg.stack) {
|
|
1462
|
+
return false;
|
|
1463
|
+
}
|
|
1464
|
+
return true;
|
|
1465
|
+
}
|
|
1466
|
+
var paused = false;
|
|
1467
|
+
var queue = [];
|
|
1468
|
+
var Consola = class _Consola {
|
|
1469
|
+
options;
|
|
1470
|
+
_lastLog;
|
|
1471
|
+
_mockFn;
|
|
1472
|
+
/**
|
|
1473
|
+
* Creates an instance of Consola with specified options or defaults.
|
|
1474
|
+
*
|
|
1475
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
1476
|
+
*/
|
|
1477
|
+
constructor(options = {}) {
|
|
1478
|
+
const types = options.types || LogTypes;
|
|
1479
|
+
this.options = defu(
|
|
1480
|
+
{
|
|
1481
|
+
...options,
|
|
1482
|
+
defaults: { ...options.defaults },
|
|
1483
|
+
level: _normalizeLogLevel(options.level, types),
|
|
1484
|
+
reporters: [...options.reporters || []]
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
types: LogTypes,
|
|
1488
|
+
throttle: 1e3,
|
|
1489
|
+
throttleMin: 5,
|
|
1490
|
+
formatOptions: {
|
|
1491
|
+
date: true,
|
|
1492
|
+
colors: false,
|
|
1493
|
+
compact: true
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
);
|
|
1497
|
+
for (const type in types) {
|
|
1498
|
+
const defaults = {
|
|
1499
|
+
type,
|
|
1500
|
+
...this.options.defaults,
|
|
1501
|
+
...types[type]
|
|
1502
|
+
};
|
|
1503
|
+
this[type] = this._wrapLogFn(defaults);
|
|
1504
|
+
this[type].raw = this._wrapLogFn(
|
|
1505
|
+
defaults,
|
|
1506
|
+
true
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
if (this.options.mockFn) {
|
|
1510
|
+
this.mockTypes();
|
|
1511
|
+
}
|
|
1512
|
+
this._lastLog = {};
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Gets the current log level of the Consola instance.
|
|
1516
|
+
*
|
|
1517
|
+
* @returns {number} The current log level.
|
|
1518
|
+
*/
|
|
1519
|
+
get level() {
|
|
1520
|
+
return this.options.level;
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Sets the minimum log level that will be output by the instance.
|
|
1524
|
+
*
|
|
1525
|
+
* @param {number} level - The new log level to set.
|
|
1526
|
+
*/
|
|
1527
|
+
set level(level) {
|
|
1528
|
+
this.options.level = _normalizeLogLevel(
|
|
1529
|
+
level,
|
|
1530
|
+
this.options.types,
|
|
1531
|
+
this.options.level
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Displays a prompt to the user and returns the response.
|
|
1536
|
+
* Throw an error if `prompt` is not supported by the current configuration.
|
|
1537
|
+
*
|
|
1538
|
+
* @template T
|
|
1539
|
+
* @param {string} message - The message to display in the prompt.
|
|
1540
|
+
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
1541
|
+
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
1542
|
+
*/
|
|
1543
|
+
prompt(message, opts) {
|
|
1544
|
+
if (!this.options.prompt) {
|
|
1545
|
+
throw new Error("prompt is not supported!");
|
|
1546
|
+
}
|
|
1547
|
+
return this.options.prompt(message, opts);
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
1551
|
+
*
|
|
1552
|
+
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
1553
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
1554
|
+
*/
|
|
1555
|
+
create(options) {
|
|
1556
|
+
const instance = new _Consola({
|
|
1557
|
+
...this.options,
|
|
1558
|
+
...options
|
|
1559
|
+
});
|
|
1560
|
+
if (this._mockFn) {
|
|
1561
|
+
instance.mockTypes(this._mockFn);
|
|
1562
|
+
}
|
|
1563
|
+
return instance;
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Creates a new Consola instance with the specified default log object properties.
|
|
1567
|
+
*
|
|
1568
|
+
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
1569
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
1570
|
+
*/
|
|
1571
|
+
withDefaults(defaults) {
|
|
1572
|
+
return this.create({
|
|
1573
|
+
...this.options,
|
|
1574
|
+
defaults: {
|
|
1575
|
+
...this.options.defaults,
|
|
1576
|
+
...defaults
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
1582
|
+
*
|
|
1583
|
+
* @param {string} tag - The tag to include in each log of the new instance.
|
|
1584
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
1585
|
+
*/
|
|
1586
|
+
withTag(tag) {
|
|
1587
|
+
return this.withDefaults({
|
|
1588
|
+
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Adds a custom reporter to the Consola instance.
|
|
1593
|
+
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
1594
|
+
*
|
|
1595
|
+
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
1596
|
+
* @returns {Consola} The current Consola instance.
|
|
1597
|
+
*/
|
|
1598
|
+
addReporter(reporter) {
|
|
1599
|
+
this.options.reporters.push(reporter);
|
|
1600
|
+
return this;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Removes a custom reporter from the Consola instance.
|
|
1604
|
+
* If no reporter is specified, all reporters will be removed.
|
|
1605
|
+
*
|
|
1606
|
+
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
1607
|
+
* @returns {Consola} The current Consola instance.
|
|
1608
|
+
*/
|
|
1609
|
+
removeReporter(reporter) {
|
|
1610
|
+
if (reporter) {
|
|
1611
|
+
const i2 = this.options.reporters.indexOf(reporter);
|
|
1612
|
+
if (i2 !== -1) {
|
|
1613
|
+
return this.options.reporters.splice(i2, 1);
|
|
1614
|
+
}
|
|
1615
|
+
} else {
|
|
1616
|
+
this.options.reporters.splice(0);
|
|
1617
|
+
}
|
|
1618
|
+
return this;
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
1622
|
+
*
|
|
1623
|
+
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
1624
|
+
* @returns {Consola} The current Consola instance.
|
|
1625
|
+
*/
|
|
1626
|
+
setReporters(reporters) {
|
|
1627
|
+
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
1628
|
+
return this;
|
|
1629
|
+
}
|
|
1630
|
+
wrapAll() {
|
|
1631
|
+
this.wrapConsole();
|
|
1632
|
+
this.wrapStd();
|
|
1633
|
+
}
|
|
1634
|
+
restoreAll() {
|
|
1635
|
+
this.restoreConsole();
|
|
1636
|
+
this.restoreStd();
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Overrides console methods with Consola logging methods for consistent logging.
|
|
1640
|
+
*/
|
|
1641
|
+
wrapConsole() {
|
|
1642
|
+
for (const type in this.options.types) {
|
|
1643
|
+
if (!console["__" + type]) {
|
|
1644
|
+
console["__" + type] = console[type];
|
|
1645
|
+
}
|
|
1646
|
+
console[type] = this[type].raw;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Restores the original console methods, removing Consola overrides.
|
|
1651
|
+
*/
|
|
1652
|
+
restoreConsole() {
|
|
1653
|
+
for (const type in this.options.types) {
|
|
1654
|
+
if (console["__" + type]) {
|
|
1655
|
+
console[type] = console["__" + type];
|
|
1656
|
+
delete console["__" + type];
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Overrides standard output and error streams to redirect them through Consola.
|
|
1662
|
+
*/
|
|
1663
|
+
wrapStd() {
|
|
1664
|
+
this._wrapStream(this.options.stdout, "log");
|
|
1665
|
+
this._wrapStream(this.options.stderr, "log");
|
|
1666
|
+
}
|
|
1667
|
+
_wrapStream(stream, type) {
|
|
1668
|
+
if (!stream) {
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
if (!stream.__write) {
|
|
1672
|
+
stream.__write = stream.write;
|
|
1673
|
+
}
|
|
1674
|
+
stream.write = (data) => {
|
|
1675
|
+
this[type].raw(String(data).trim());
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
1680
|
+
*/
|
|
1681
|
+
restoreStd() {
|
|
1682
|
+
this._restoreStream(this.options.stdout);
|
|
1683
|
+
this._restoreStream(this.options.stderr);
|
|
1684
|
+
}
|
|
1685
|
+
_restoreStream(stream) {
|
|
1686
|
+
if (!stream) {
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
if (stream.__write) {
|
|
1690
|
+
stream.write = stream.__write;
|
|
1691
|
+
delete stream.__write;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Pauses logging, queues incoming logs until resumed.
|
|
1696
|
+
*/
|
|
1697
|
+
pauseLogs() {
|
|
1698
|
+
paused = true;
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Resumes logging, processing any queued logs.
|
|
1702
|
+
*/
|
|
1703
|
+
resumeLogs() {
|
|
1704
|
+
paused = false;
|
|
1705
|
+
const _queue = queue.splice(0);
|
|
1706
|
+
for (const item of _queue) {
|
|
1707
|
+
item[0]._logFn(item[1], item[2]);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Replaces logging methods with mocks if a mock function is provided.
|
|
1712
|
+
*
|
|
1713
|
+
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
1714
|
+
*/
|
|
1715
|
+
mockTypes(mockFn) {
|
|
1716
|
+
const _mockFn = mockFn || this.options.mockFn;
|
|
1717
|
+
this._mockFn = _mockFn;
|
|
1718
|
+
if (typeof _mockFn !== "function") {
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
for (const type in this.options.types) {
|
|
1722
|
+
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
1723
|
+
this[type].raw = this[type];
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
_wrapLogFn(defaults, isRaw) {
|
|
1727
|
+
return (...args) => {
|
|
1728
|
+
if (paused) {
|
|
1729
|
+
queue.push([this, defaults, args, isRaw]);
|
|
1730
|
+
return;
|
|
1731
|
+
}
|
|
1732
|
+
return this._logFn(defaults, args, isRaw);
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
_logFn(defaults, args, isRaw) {
|
|
1736
|
+
if ((defaults.level || 0) > this.level) {
|
|
1737
|
+
return false;
|
|
1738
|
+
}
|
|
1739
|
+
const logObj = {
|
|
1740
|
+
date: /* @__PURE__ */ new Date(),
|
|
1741
|
+
args: [],
|
|
1742
|
+
...defaults,
|
|
1743
|
+
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
1744
|
+
};
|
|
1745
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
1746
|
+
Object.assign(logObj, args[0]);
|
|
1747
|
+
} else {
|
|
1748
|
+
logObj.args = [...args];
|
|
1749
|
+
}
|
|
1750
|
+
if (logObj.message) {
|
|
1751
|
+
logObj.args.unshift(logObj.message);
|
|
1752
|
+
delete logObj.message;
|
|
1753
|
+
}
|
|
1754
|
+
if (logObj.additional) {
|
|
1755
|
+
if (!Array.isArray(logObj.additional)) {
|
|
1756
|
+
logObj.additional = logObj.additional.split("\n");
|
|
1757
|
+
}
|
|
1758
|
+
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
1759
|
+
delete logObj.additional;
|
|
1760
|
+
}
|
|
1761
|
+
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
1762
|
+
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
1763
|
+
const resolveLog = (newLog = false) => {
|
|
1764
|
+
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
1765
|
+
if (this._lastLog.object && repeated > 0) {
|
|
1766
|
+
const args2 = [...this._lastLog.object.args];
|
|
1767
|
+
if (repeated > 1) {
|
|
1768
|
+
args2.push(`(repeated ${repeated} times)`);
|
|
1769
|
+
}
|
|
1770
|
+
this._log({ ...this._lastLog.object, args: args2 });
|
|
1771
|
+
this._lastLog.count = 1;
|
|
1772
|
+
}
|
|
1773
|
+
if (newLog) {
|
|
1774
|
+
this._lastLog.object = logObj;
|
|
1775
|
+
this._log(logObj);
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
clearTimeout(this._lastLog.timeout);
|
|
1779
|
+
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
1780
|
+
this._lastLog.time = logObj.date;
|
|
1781
|
+
if (diffTime < this.options.throttle) {
|
|
1782
|
+
try {
|
|
1783
|
+
const serializedLog = JSON.stringify([
|
|
1784
|
+
logObj.type,
|
|
1785
|
+
logObj.tag,
|
|
1786
|
+
logObj.args
|
|
1787
|
+
]);
|
|
1788
|
+
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
1789
|
+
this._lastLog.serialized = serializedLog;
|
|
1790
|
+
if (isSameLog) {
|
|
1791
|
+
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
1792
|
+
if (this._lastLog.count > this.options.throttleMin) {
|
|
1793
|
+
this._lastLog.timeout = setTimeout(
|
|
1794
|
+
resolveLog,
|
|
1795
|
+
this.options.throttle
|
|
1796
|
+
);
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
} catch {
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
resolveLog(true);
|
|
1804
|
+
}
|
|
1805
|
+
_log(logObj) {
|
|
1806
|
+
for (const reporter of this.options.reporters) {
|
|
1807
|
+
reporter.log(logObj, {
|
|
1808
|
+
options: this.options
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
1814
|
+
if (input === void 0) {
|
|
1815
|
+
return defaultLevel;
|
|
1816
|
+
}
|
|
1817
|
+
if (typeof input === "number") {
|
|
1818
|
+
return input;
|
|
1819
|
+
}
|
|
1820
|
+
if (types[input] && types[input].level !== void 0) {
|
|
1821
|
+
return types[input].level;
|
|
1822
|
+
}
|
|
1823
|
+
return defaultLevel;
|
|
1824
|
+
}
|
|
1825
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
1826
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
1827
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
1828
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
1829
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
1830
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
1831
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
1832
|
+
function createConsola(options = {}) {
|
|
1833
|
+
return new Consola(options);
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
// ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
|
|
1837
|
+
import { formatWithOptions } from "util";
|
|
1838
|
+
import { sep } from "path";
|
|
1839
|
+
function parseStack(stack, message) {
|
|
1840
|
+
const cwd = process.cwd() + sep;
|
|
1841
|
+
const lines = stack.split("\n").splice(message.split("\n").length).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
|
|
1842
|
+
return lines;
|
|
1843
|
+
}
|
|
1844
|
+
function writeStream(data, stream) {
|
|
1845
|
+
const write = stream.__write || stream.write;
|
|
1846
|
+
return write.call(stream, data);
|
|
1847
|
+
}
|
|
1848
|
+
var bracket = (x2) => x2 ? `[${x2}]` : "";
|
|
1849
|
+
var BasicReporter = class {
|
|
1850
|
+
formatStack(stack, message, opts) {
|
|
1851
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
1852
|
+
return indent + parseStack(stack, message).join(`
|
|
1853
|
+
${indent}`);
|
|
1854
|
+
}
|
|
1855
|
+
formatError(err, opts) {
|
|
1856
|
+
const message = err.message ?? formatWithOptions(opts, err);
|
|
1857
|
+
const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
|
|
1858
|
+
const level = opts?.errorLevel || 0;
|
|
1859
|
+
const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
|
|
1860
|
+
const causedError = err.cause ? "\n\n" + this.formatError(err.cause, { ...opts, errorLevel: level + 1 }) : "";
|
|
1861
|
+
return causedPrefix + message + "\n" + stack + causedError;
|
|
1862
|
+
}
|
|
1863
|
+
formatArgs(args, opts) {
|
|
1864
|
+
const _args = args.map((arg) => {
|
|
1865
|
+
if (arg && typeof arg.stack === "string") {
|
|
1866
|
+
return this.formatError(arg, opts);
|
|
1867
|
+
}
|
|
1868
|
+
return arg;
|
|
1869
|
+
});
|
|
1870
|
+
return formatWithOptions(opts, ..._args);
|
|
1871
|
+
}
|
|
1872
|
+
formatDate(date, opts) {
|
|
1873
|
+
return opts.date ? date.toLocaleTimeString() : "";
|
|
1874
|
+
}
|
|
1875
|
+
filterAndJoin(arr) {
|
|
1876
|
+
return arr.filter(Boolean).join(" ");
|
|
1877
|
+
}
|
|
1878
|
+
formatLogObj(logObj, opts) {
|
|
1879
|
+
const message = this.formatArgs(logObj.args, opts);
|
|
1880
|
+
if (logObj.type === "box") {
|
|
1881
|
+
return "\n" + [
|
|
1882
|
+
bracket(logObj.tag),
|
|
1883
|
+
logObj.title && logObj.title,
|
|
1884
|
+
...message.split("\n")
|
|
1885
|
+
].filter(Boolean).map((l2) => " > " + l2).join("\n") + "\n";
|
|
1886
|
+
}
|
|
1887
|
+
return this.filterAndJoin([
|
|
1888
|
+
bracket(logObj.type),
|
|
1889
|
+
bracket(logObj.tag),
|
|
1890
|
+
message
|
|
1891
|
+
]);
|
|
1892
|
+
}
|
|
1893
|
+
log(logObj, ctx) {
|
|
1894
|
+
const line = this.formatLogObj(logObj, {
|
|
1895
|
+
columns: ctx.options.stdout.columns || 0,
|
|
1896
|
+
...ctx.options.formatOptions
|
|
1897
|
+
});
|
|
1898
|
+
return writeStream(
|
|
1899
|
+
line + "\n",
|
|
1900
|
+
logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
|
|
1901
|
+
);
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
// ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
1906
|
+
import g$1 from "process";
|
|
1907
|
+
|
|
1908
|
+
// ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
|
|
1909
|
+
import * as tty from "tty";
|
|
1910
|
+
var {
|
|
1911
|
+
env = {},
|
|
1912
|
+
argv = [],
|
|
1913
|
+
platform = ""
|
|
1914
|
+
} = typeof process === "undefined" ? {} : process;
|
|
1915
|
+
var isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
1916
|
+
var isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
1917
|
+
var isWindows = platform === "win32";
|
|
1918
|
+
var isDumbTerminal = env.TERM === "dumb";
|
|
1919
|
+
var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
1920
|
+
var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
1921
|
+
var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
1922
|
+
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
|
1923
|
+
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
1924
|
+
}
|
|
1925
|
+
function clearBleed(index, string, open, close, replace) {
|
|
1926
|
+
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
1927
|
+
}
|
|
1928
|
+
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
|
1929
|
+
return (string) => string || !(string === "" || string === void 0) ? clearBleed(
|
|
1930
|
+
("" + string).indexOf(close, at),
|
|
1931
|
+
string,
|
|
1932
|
+
open,
|
|
1933
|
+
close,
|
|
1934
|
+
replace
|
|
1935
|
+
) : "";
|
|
1936
|
+
}
|
|
1937
|
+
function init(open, close, replace) {
|
|
1938
|
+
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
|
1939
|
+
}
|
|
1940
|
+
var colorDefs = {
|
|
1941
|
+
reset: init(0, 0),
|
|
1942
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
1943
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
1944
|
+
italic: init(3, 23),
|
|
1945
|
+
underline: init(4, 24),
|
|
1946
|
+
inverse: init(7, 27),
|
|
1947
|
+
hidden: init(8, 28),
|
|
1948
|
+
strikethrough: init(9, 29),
|
|
1949
|
+
black: init(30, 39),
|
|
1950
|
+
red: init(31, 39),
|
|
1951
|
+
green: init(32, 39),
|
|
1952
|
+
yellow: init(33, 39),
|
|
1953
|
+
blue: init(34, 39),
|
|
1954
|
+
magenta: init(35, 39),
|
|
1955
|
+
cyan: init(36, 39),
|
|
1956
|
+
white: init(37, 39),
|
|
1957
|
+
gray: init(90, 39),
|
|
1958
|
+
bgBlack: init(40, 49),
|
|
1959
|
+
bgRed: init(41, 49),
|
|
1960
|
+
bgGreen: init(42, 49),
|
|
1961
|
+
bgYellow: init(43, 49),
|
|
1962
|
+
bgBlue: init(44, 49),
|
|
1963
|
+
bgMagenta: init(45, 49),
|
|
1964
|
+
bgCyan: init(46, 49),
|
|
1965
|
+
bgWhite: init(47, 49),
|
|
1966
|
+
blackBright: init(90, 39),
|
|
1967
|
+
redBright: init(91, 39),
|
|
1968
|
+
greenBright: init(92, 39),
|
|
1969
|
+
yellowBright: init(93, 39),
|
|
1970
|
+
blueBright: init(94, 39),
|
|
1971
|
+
magentaBright: init(95, 39),
|
|
1972
|
+
cyanBright: init(96, 39),
|
|
1973
|
+
whiteBright: init(97, 39),
|
|
1974
|
+
bgBlackBright: init(100, 49),
|
|
1975
|
+
bgRedBright: init(101, 49),
|
|
1976
|
+
bgGreenBright: init(102, 49),
|
|
1977
|
+
bgYellowBright: init(103, 49),
|
|
1978
|
+
bgBlueBright: init(104, 49),
|
|
1979
|
+
bgMagentaBright: init(105, 49),
|
|
1980
|
+
bgCyanBright: init(106, 49),
|
|
1981
|
+
bgWhiteBright: init(107, 49)
|
|
1982
|
+
};
|
|
1983
|
+
function createColors(useColor = isColorSupported) {
|
|
1984
|
+
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
1985
|
+
}
|
|
1986
|
+
var colors = createColors();
|
|
1987
|
+
function getColor(color, fallback = "reset") {
|
|
1988
|
+
return colors[color] || colors[fallback];
|
|
1989
|
+
}
|
|
1990
|
+
var ansiRegex = [
|
|
1991
|
+
String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
|
|
1992
|
+
String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
|
|
1993
|
+
].join("|");
|
|
1994
|
+
function stripAnsi(text) {
|
|
1995
|
+
return text.replace(new RegExp(ansiRegex, "g"), "");
|
|
1996
|
+
}
|
|
1997
|
+
var boxStylePresets = {
|
|
1998
|
+
solid: {
|
|
1999
|
+
tl: "\u250C",
|
|
2000
|
+
tr: "\u2510",
|
|
2001
|
+
bl: "\u2514",
|
|
2002
|
+
br: "\u2518",
|
|
2003
|
+
h: "\u2500",
|
|
2004
|
+
v: "\u2502"
|
|
2005
|
+
},
|
|
2006
|
+
double: {
|
|
2007
|
+
tl: "\u2554",
|
|
2008
|
+
tr: "\u2557",
|
|
2009
|
+
bl: "\u255A",
|
|
2010
|
+
br: "\u255D",
|
|
2011
|
+
h: "\u2550",
|
|
2012
|
+
v: "\u2551"
|
|
2013
|
+
},
|
|
2014
|
+
doubleSingle: {
|
|
2015
|
+
tl: "\u2553",
|
|
2016
|
+
tr: "\u2556",
|
|
2017
|
+
bl: "\u2559",
|
|
2018
|
+
br: "\u255C",
|
|
2019
|
+
h: "\u2500",
|
|
2020
|
+
v: "\u2551"
|
|
2021
|
+
},
|
|
2022
|
+
doubleSingleRounded: {
|
|
2023
|
+
tl: "\u256D",
|
|
2024
|
+
tr: "\u256E",
|
|
2025
|
+
bl: "\u2570",
|
|
2026
|
+
br: "\u256F",
|
|
2027
|
+
h: "\u2500",
|
|
2028
|
+
v: "\u2551"
|
|
2029
|
+
},
|
|
2030
|
+
singleThick: {
|
|
2031
|
+
tl: "\u250F",
|
|
2032
|
+
tr: "\u2513",
|
|
2033
|
+
bl: "\u2517",
|
|
2034
|
+
br: "\u251B",
|
|
2035
|
+
h: "\u2501",
|
|
2036
|
+
v: "\u2503"
|
|
2037
|
+
},
|
|
2038
|
+
singleDouble: {
|
|
2039
|
+
tl: "\u2552",
|
|
2040
|
+
tr: "\u2555",
|
|
2041
|
+
bl: "\u2558",
|
|
2042
|
+
br: "\u255B",
|
|
2043
|
+
h: "\u2550",
|
|
2044
|
+
v: "\u2502"
|
|
2045
|
+
},
|
|
2046
|
+
singleDoubleRounded: {
|
|
2047
|
+
tl: "\u256D",
|
|
2048
|
+
tr: "\u256E",
|
|
2049
|
+
bl: "\u2570",
|
|
2050
|
+
br: "\u256F",
|
|
2051
|
+
h: "\u2550",
|
|
2052
|
+
v: "\u2502"
|
|
2053
|
+
},
|
|
2054
|
+
rounded: {
|
|
2055
|
+
tl: "\u256D",
|
|
2056
|
+
tr: "\u256E",
|
|
2057
|
+
bl: "\u2570",
|
|
2058
|
+
br: "\u256F",
|
|
2059
|
+
h: "\u2500",
|
|
2060
|
+
v: "\u2502"
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2063
|
+
var defaultStyle = {
|
|
2064
|
+
borderColor: "white",
|
|
2065
|
+
borderStyle: "rounded",
|
|
2066
|
+
valign: "center",
|
|
2067
|
+
padding: 2,
|
|
2068
|
+
marginLeft: 1,
|
|
2069
|
+
marginTop: 1,
|
|
2070
|
+
marginBottom: 1
|
|
2071
|
+
};
|
|
2072
|
+
function box(text, _opts = {}) {
|
|
2073
|
+
const opts = {
|
|
2074
|
+
..._opts,
|
|
2075
|
+
style: {
|
|
2076
|
+
...defaultStyle,
|
|
2077
|
+
..._opts.style
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
const textLines = text.split("\n");
|
|
2081
|
+
const boxLines = [];
|
|
2082
|
+
const _color = getColor(opts.style.borderColor);
|
|
2083
|
+
const borderStyle = {
|
|
2084
|
+
...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
|
|
2085
|
+
};
|
|
2086
|
+
if (_color) {
|
|
2087
|
+
for (const key in borderStyle) {
|
|
2088
|
+
borderStyle[key] = _color(
|
|
2089
|
+
borderStyle[key]
|
|
2090
|
+
);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
2094
|
+
const height = textLines.length + paddingOffset;
|
|
2095
|
+
const width = Math.max(
|
|
2096
|
+
...textLines.map((line) => stripAnsi(line).length),
|
|
2097
|
+
opts.title ? stripAnsi(opts.title).length : 0
|
|
2098
|
+
) + paddingOffset;
|
|
2099
|
+
const widthOffset = width + paddingOffset;
|
|
2100
|
+
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
2101
|
+
if (opts.style.marginTop > 0) {
|
|
2102
|
+
boxLines.push("".repeat(opts.style.marginTop));
|
|
2103
|
+
}
|
|
2104
|
+
if (opts.title) {
|
|
2105
|
+
const title = _color ? _color(opts.title) : opts.title;
|
|
2106
|
+
const left = borderStyle.h.repeat(
|
|
2107
|
+
Math.floor((width - stripAnsi(opts.title).length) / 2)
|
|
2108
|
+
);
|
|
2109
|
+
const right = borderStyle.h.repeat(
|
|
2110
|
+
width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
|
|
2111
|
+
);
|
|
2112
|
+
boxLines.push(
|
|
2113
|
+
`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`
|
|
2114
|
+
);
|
|
2115
|
+
} else {
|
|
2116
|
+
boxLines.push(
|
|
2117
|
+
`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
|
|
2118
|
+
);
|
|
2119
|
+
}
|
|
2120
|
+
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
2121
|
+
for (let i2 = 0; i2 < height; i2++) {
|
|
2122
|
+
if (i2 < valignOffset || i2 >= valignOffset + textLines.length) {
|
|
2123
|
+
boxLines.push(
|
|
2124
|
+
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
|
|
2125
|
+
);
|
|
2126
|
+
} else {
|
|
2127
|
+
const line = textLines[i2 - valignOffset];
|
|
2128
|
+
const left = " ".repeat(paddingOffset);
|
|
2129
|
+
const right = " ".repeat(width - stripAnsi(line).length);
|
|
2130
|
+
boxLines.push(
|
|
2131
|
+
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
boxLines.push(
|
|
2136
|
+
`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
|
|
2137
|
+
);
|
|
2138
|
+
if (opts.style.marginBottom > 0) {
|
|
2139
|
+
boxLines.push("".repeat(opts.style.marginBottom));
|
|
2140
|
+
}
|
|
2141
|
+
return boxLines.join("\n");
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
// ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
2145
|
+
import "util";
|
|
2146
|
+
import "path";
|
|
2147
|
+
import "tty";
|
|
2148
|
+
var r2 = /* @__PURE__ */ Object.create(null);
|
|
2149
|
+
var i = (e2) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e2 ? r2 : globalThis);
|
|
2150
|
+
var o2 = new Proxy(r2, { get(e2, s2) {
|
|
2151
|
+
return i()[s2] ?? r2[s2];
|
|
2152
|
+
}, has(e2, s2) {
|
|
2153
|
+
const E = i();
|
|
2154
|
+
return s2 in E || s2 in r2;
|
|
2155
|
+
}, set(e2, s2, E) {
|
|
2156
|
+
const B2 = i(true);
|
|
2157
|
+
return B2[s2] = E, true;
|
|
2158
|
+
}, deleteProperty(e2, s2) {
|
|
2159
|
+
if (!s2) return false;
|
|
2160
|
+
const E = i(true);
|
|
2161
|
+
return delete E[s2], true;
|
|
2162
|
+
}, ownKeys() {
|
|
2163
|
+
const e2 = i(true);
|
|
2164
|
+
return Object.keys(e2);
|
|
2165
|
+
} });
|
|
2166
|
+
var t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
|
|
2167
|
+
var f2 = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
|
|
2168
|
+
function b() {
|
|
2169
|
+
if (globalThis.process?.env) for (const e2 of f2) {
|
|
2170
|
+
const s2 = e2[1] || e2[0];
|
|
2171
|
+
if (globalThis.process?.env[s2]) return { name: e2[0].toLowerCase(), ...e2[2] };
|
|
2172
|
+
}
|
|
2173
|
+
return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
|
|
2174
|
+
}
|
|
2175
|
+
var l = b();
|
|
2176
|
+
l.name;
|
|
2177
|
+
function n(e2) {
|
|
2178
|
+
return e2 ? e2 !== "false" : false;
|
|
2179
|
+
}
|
|
2180
|
+
var I2 = globalThis.process?.platform || "";
|
|
2181
|
+
var T2 = n(o2.CI) || l.ci !== false;
|
|
2182
|
+
var a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
|
|
2183
|
+
var g2 = n(o2.DEBUG);
|
|
2184
|
+
var R2 = t === "test" || n(o2.TEST);
|
|
2185
|
+
n(o2.MINIMAL) || T2 || R2 || !a;
|
|
2186
|
+
var A2 = /^win/i.test(I2);
|
|
2187
|
+
!n(o2.NO_COLOR) && (n(o2.FORCE_COLOR) || (a || A2) && o2.TERM !== "dumb" || T2);
|
|
2188
|
+
var C2 = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
|
|
2189
|
+
Number(C2?.split(".")[0]) || null;
|
|
2190
|
+
var y2 = globalThis.process || /* @__PURE__ */ Object.create(null);
|
|
2191
|
+
var _2 = { versions: {} };
|
|
2192
|
+
new Proxy(y2, { get(e2, s2) {
|
|
2193
|
+
if (s2 === "env") return o2;
|
|
2194
|
+
if (s2 in e2) return e2[s2];
|
|
2195
|
+
if (s2 in _2) return _2[s2];
|
|
2196
|
+
} });
|
|
2197
|
+
var c2 = globalThis.process?.release?.name === "node";
|
|
2198
|
+
var O2 = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
|
|
2199
|
+
var D = !!globalThis.Deno;
|
|
2200
|
+
var L2 = !!globalThis.fastly;
|
|
2201
|
+
var S2 = !!globalThis.Netlify;
|
|
2202
|
+
var u2 = !!globalThis.EdgeRuntime;
|
|
2203
|
+
var N2 = globalThis.navigator?.userAgent === "Cloudflare-Workers";
|
|
2204
|
+
var F2 = [[S2, "netlify"], [u2, "edge-light"], [N2, "workerd"], [L2, "fastly"], [D, "deno"], [O2, "bun"], [c2, "node"]];
|
|
2205
|
+
function G2() {
|
|
2206
|
+
const e2 = F2.find((s2) => s2[0]);
|
|
2207
|
+
if (e2) return { name: e2[1] };
|
|
2208
|
+
}
|
|
2209
|
+
var P2 = G2();
|
|
2210
|
+
P2?.name || "";
|
|
2211
|
+
function ansiRegex2({ onlyFirst = false } = {}) {
|
|
2212
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
2213
|
+
const pattern = [
|
|
2214
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
2215
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
2216
|
+
].join("|");
|
|
2217
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
2218
|
+
}
|
|
2219
|
+
var regex = ansiRegex2();
|
|
2220
|
+
function stripAnsi2(string) {
|
|
2221
|
+
if (typeof string !== "string") {
|
|
2222
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
2223
|
+
}
|
|
2224
|
+
return string.replace(regex, "");
|
|
2225
|
+
}
|
|
2226
|
+
function isAmbiguous(x2) {
|
|
2227
|
+
return x2 === 161 || x2 === 164 || x2 === 167 || x2 === 168 || x2 === 170 || x2 === 173 || x2 === 174 || x2 >= 176 && x2 <= 180 || x2 >= 182 && x2 <= 186 || x2 >= 188 && x2 <= 191 || x2 === 198 || x2 === 208 || x2 === 215 || x2 === 216 || x2 >= 222 && x2 <= 225 || x2 === 230 || x2 >= 232 && x2 <= 234 || x2 === 236 || x2 === 237 || x2 === 240 || x2 === 242 || x2 === 243 || x2 >= 247 && x2 <= 250 || x2 === 252 || x2 === 254 || x2 === 257 || x2 === 273 || x2 === 275 || x2 === 283 || x2 === 294 || x2 === 295 || x2 === 299 || x2 >= 305 && x2 <= 307 || x2 === 312 || x2 >= 319 && x2 <= 322 || x2 === 324 || x2 >= 328 && x2 <= 331 || x2 === 333 || x2 === 338 || x2 === 339 || x2 === 358 || x2 === 359 || x2 === 363 || x2 === 462 || x2 === 464 || x2 === 466 || x2 === 468 || x2 === 470 || x2 === 472 || x2 === 474 || x2 === 476 || x2 === 593 || x2 === 609 || x2 === 708 || x2 === 711 || x2 >= 713 && x2 <= 715 || x2 === 717 || x2 === 720 || x2 >= 728 && x2 <= 731 || x2 === 733 || x2 === 735 || x2 >= 768 && x2 <= 879 || x2 >= 913 && x2 <= 929 || x2 >= 931 && x2 <= 937 || x2 >= 945 && x2 <= 961 || x2 >= 963 && x2 <= 969 || x2 === 1025 || x2 >= 1040 && x2 <= 1103 || x2 === 1105 || x2 === 8208 || x2 >= 8211 && x2 <= 8214 || x2 === 8216 || x2 === 8217 || x2 === 8220 || x2 === 8221 || x2 >= 8224 && x2 <= 8226 || x2 >= 8228 && x2 <= 8231 || x2 === 8240 || x2 === 8242 || x2 === 8243 || x2 === 8245 || x2 === 8251 || x2 === 8254 || x2 === 8308 || x2 === 8319 || x2 >= 8321 && x2 <= 8324 || x2 === 8364 || x2 === 8451 || x2 === 8453 || x2 === 8457 || x2 === 8467 || x2 === 8470 || x2 === 8481 || x2 === 8482 || x2 === 8486 || x2 === 8491 || x2 === 8531 || x2 === 8532 || x2 >= 8539 && x2 <= 8542 || x2 >= 8544 && x2 <= 8555 || x2 >= 8560 && x2 <= 8569 || x2 === 8585 || x2 >= 8592 && x2 <= 8601 || x2 === 8632 || x2 === 8633 || x2 === 8658 || x2 === 8660 || x2 === 8679 || x2 === 8704 || x2 === 8706 || x2 === 8707 || x2 === 8711 || x2 === 8712 || x2 === 8715 || x2 === 8719 || x2 === 8721 || x2 === 8725 || x2 === 8730 || x2 >= 8733 && x2 <= 8736 || x2 === 8739 || x2 === 8741 || x2 >= 8743 && x2 <= 8748 || x2 === 8750 || x2 >= 8756 && x2 <= 8759 || x2 === 8764 || x2 === 8765 || x2 === 8776 || x2 === 8780 || x2 === 8786 || x2 === 8800 || x2 === 8801 || x2 >= 8804 && x2 <= 8807 || x2 === 8810 || x2 === 8811 || x2 === 8814 || x2 === 8815 || x2 === 8834 || x2 === 8835 || x2 === 8838 || x2 === 8839 || x2 === 8853 || x2 === 8857 || x2 === 8869 || x2 === 8895 || x2 === 8978 || x2 >= 9312 && x2 <= 9449 || x2 >= 9451 && x2 <= 9547 || x2 >= 9552 && x2 <= 9587 || x2 >= 9600 && x2 <= 9615 || x2 >= 9618 && x2 <= 9621 || x2 === 9632 || x2 === 9633 || x2 >= 9635 && x2 <= 9641 || x2 === 9650 || x2 === 9651 || x2 === 9654 || x2 === 9655 || x2 === 9660 || x2 === 9661 || x2 === 9664 || x2 === 9665 || x2 >= 9670 && x2 <= 9672 || x2 === 9675 || x2 >= 9678 && x2 <= 9681 || x2 >= 9698 && x2 <= 9701 || x2 === 9711 || x2 === 9733 || x2 === 9734 || x2 === 9737 || x2 === 9742 || x2 === 9743 || x2 === 9756 || x2 === 9758 || x2 === 9792 || x2 === 9794 || x2 === 9824 || x2 === 9825 || x2 >= 9827 && x2 <= 9829 || x2 >= 9831 && x2 <= 9834 || x2 === 9836 || x2 === 9837 || x2 === 9839 || x2 === 9886 || x2 === 9887 || x2 === 9919 || x2 >= 9926 && x2 <= 9933 || x2 >= 9935 && x2 <= 9939 || x2 >= 9941 && x2 <= 9953 || x2 === 9955 || x2 === 9960 || x2 === 9961 || x2 >= 9963 && x2 <= 9969 || x2 === 9972 || x2 >= 9974 && x2 <= 9977 || x2 === 9979 || x2 === 9980 || x2 === 9982 || x2 === 9983 || x2 === 10045 || x2 >= 10102 && x2 <= 10111 || x2 >= 11094 && x2 <= 11097 || x2 >= 12872 && x2 <= 12879 || x2 >= 57344 && x2 <= 63743 || x2 >= 65024 && x2 <= 65039 || x2 === 65533 || x2 >= 127232 && x2 <= 127242 || x2 >= 127248 && x2 <= 127277 || x2 >= 127280 && x2 <= 127337 || x2 >= 127344 && x2 <= 127373 || x2 === 127375 || x2 === 127376 || x2 >= 127387 && x2 <= 127404 || x2 >= 917760 && x2 <= 917999 || x2 >= 983040 && x2 <= 1048573 || x2 >= 1048576 && x2 <= 1114109;
|
|
2228
|
+
}
|
|
2229
|
+
function isFullWidth(x2) {
|
|
2230
|
+
return x2 === 12288 || x2 >= 65281 && x2 <= 65376 || x2 >= 65504 && x2 <= 65510;
|
|
2231
|
+
}
|
|
2232
|
+
function isWide(x2) {
|
|
2233
|
+
return x2 >= 4352 && x2 <= 4447 || x2 === 8986 || x2 === 8987 || x2 === 9001 || x2 === 9002 || x2 >= 9193 && x2 <= 9196 || x2 === 9200 || x2 === 9203 || x2 === 9725 || x2 === 9726 || x2 === 9748 || x2 === 9749 || x2 >= 9776 && x2 <= 9783 || x2 >= 9800 && x2 <= 9811 || x2 === 9855 || x2 >= 9866 && x2 <= 9871 || x2 === 9875 || x2 === 9889 || x2 === 9898 || x2 === 9899 || x2 === 9917 || x2 === 9918 || x2 === 9924 || x2 === 9925 || x2 === 9934 || x2 === 9940 || x2 === 9962 || x2 === 9970 || x2 === 9971 || x2 === 9973 || x2 === 9978 || x2 === 9981 || x2 === 9989 || x2 === 9994 || x2 === 9995 || x2 === 10024 || x2 === 10060 || x2 === 10062 || x2 >= 10067 && x2 <= 10069 || x2 === 10071 || x2 >= 10133 && x2 <= 10135 || x2 === 10160 || x2 === 10175 || x2 === 11035 || x2 === 11036 || x2 === 11088 || x2 === 11093 || x2 >= 11904 && x2 <= 11929 || x2 >= 11931 && x2 <= 12019 || x2 >= 12032 && x2 <= 12245 || x2 >= 12272 && x2 <= 12287 || x2 >= 12289 && x2 <= 12350 || x2 >= 12353 && x2 <= 12438 || x2 >= 12441 && x2 <= 12543 || x2 >= 12549 && x2 <= 12591 || x2 >= 12593 && x2 <= 12686 || x2 >= 12688 && x2 <= 12773 || x2 >= 12783 && x2 <= 12830 || x2 >= 12832 && x2 <= 12871 || x2 >= 12880 && x2 <= 42124 || x2 >= 42128 && x2 <= 42182 || x2 >= 43360 && x2 <= 43388 || x2 >= 44032 && x2 <= 55203 || x2 >= 63744 && x2 <= 64255 || x2 >= 65040 && x2 <= 65049 || x2 >= 65072 && x2 <= 65106 || x2 >= 65108 && x2 <= 65126 || x2 >= 65128 && x2 <= 65131 || x2 >= 94176 && x2 <= 94180 || x2 === 94192 || x2 === 94193 || x2 >= 94208 && x2 <= 100343 || x2 >= 100352 && x2 <= 101589 || x2 >= 101631 && x2 <= 101640 || x2 >= 110576 && x2 <= 110579 || x2 >= 110581 && x2 <= 110587 || x2 === 110589 || x2 === 110590 || x2 >= 110592 && x2 <= 110882 || x2 === 110898 || x2 >= 110928 && x2 <= 110930 || x2 === 110933 || x2 >= 110948 && x2 <= 110951 || x2 >= 110960 && x2 <= 111355 || x2 >= 119552 && x2 <= 119638 || x2 >= 119648 && x2 <= 119670 || x2 === 126980 || x2 === 127183 || x2 === 127374 || x2 >= 127377 && x2 <= 127386 || x2 >= 127488 && x2 <= 127490 || x2 >= 127504 && x2 <= 127547 || x2 >= 127552 && x2 <= 127560 || x2 === 127568 || x2 === 127569 || x2 >= 127584 && x2 <= 127589 || x2 >= 127744 && x2 <= 127776 || x2 >= 127789 && x2 <= 127797 || x2 >= 127799 && x2 <= 127868 || x2 >= 127870 && x2 <= 127891 || x2 >= 127904 && x2 <= 127946 || x2 >= 127951 && x2 <= 127955 || x2 >= 127968 && x2 <= 127984 || x2 === 127988 || x2 >= 127992 && x2 <= 128062 || x2 === 128064 || x2 >= 128066 && x2 <= 128252 || x2 >= 128255 && x2 <= 128317 || x2 >= 128331 && x2 <= 128334 || x2 >= 128336 && x2 <= 128359 || x2 === 128378 || x2 === 128405 || x2 === 128406 || x2 === 128420 || x2 >= 128507 && x2 <= 128591 || x2 >= 128640 && x2 <= 128709 || x2 === 128716 || x2 >= 128720 && x2 <= 128722 || x2 >= 128725 && x2 <= 128727 || x2 >= 128732 && x2 <= 128735 || x2 === 128747 || x2 === 128748 || x2 >= 128756 && x2 <= 128764 || x2 >= 128992 && x2 <= 129003 || x2 === 129008 || x2 >= 129292 && x2 <= 129338 || x2 >= 129340 && x2 <= 129349 || x2 >= 129351 && x2 <= 129535 || x2 >= 129648 && x2 <= 129660 || x2 >= 129664 && x2 <= 129673 || x2 >= 129679 && x2 <= 129734 || x2 >= 129742 && x2 <= 129756 || x2 >= 129759 && x2 <= 129769 || x2 >= 129776 && x2 <= 129784 || x2 >= 131072 && x2 <= 196605 || x2 >= 196608 && x2 <= 262141;
|
|
2234
|
+
}
|
|
2235
|
+
function validate(codePoint) {
|
|
2236
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
2237
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
2241
|
+
validate(codePoint);
|
|
2242
|
+
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
2243
|
+
return 2;
|
|
2244
|
+
}
|
|
2245
|
+
return 1;
|
|
2246
|
+
}
|
|
2247
|
+
var emojiRegex = () => {
|
|
2248
|
+
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\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?|[\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](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\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-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
2249
|
+
};
|
|
2250
|
+
var segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
|
|
2251
|
+
var defaultIgnorableCodePointRegex = new RegExp("^\\p{Default_Ignorable_Code_Point}$", "u");
|
|
2252
|
+
function stringWidth$1(string, options = {}) {
|
|
2253
|
+
if (typeof string !== "string" || string.length === 0) {
|
|
2254
|
+
return 0;
|
|
2255
|
+
}
|
|
2256
|
+
const {
|
|
2257
|
+
ambiguousIsNarrow = true,
|
|
2258
|
+
countAnsiEscapeCodes = false
|
|
2259
|
+
} = options;
|
|
2260
|
+
if (!countAnsiEscapeCodes) {
|
|
2261
|
+
string = stripAnsi2(string);
|
|
2262
|
+
}
|
|
2263
|
+
if (string.length === 0) {
|
|
2264
|
+
return 0;
|
|
2265
|
+
}
|
|
2266
|
+
let width = 0;
|
|
2267
|
+
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
2268
|
+
for (const { segment: character } of segmenter.segment(string)) {
|
|
2269
|
+
const codePoint = character.codePointAt(0);
|
|
2270
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
2271
|
+
continue;
|
|
2272
|
+
}
|
|
2273
|
+
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
|
|
2274
|
+
continue;
|
|
2275
|
+
}
|
|
2276
|
+
if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
|
|
2277
|
+
continue;
|
|
2278
|
+
}
|
|
2279
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
2280
|
+
continue;
|
|
2281
|
+
}
|
|
2282
|
+
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
2283
|
+
continue;
|
|
2284
|
+
}
|
|
2285
|
+
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
2286
|
+
continue;
|
|
2287
|
+
}
|
|
2288
|
+
if (emojiRegex().test(character)) {
|
|
2289
|
+
width += 2;
|
|
2290
|
+
continue;
|
|
2291
|
+
}
|
|
2292
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
2293
|
+
}
|
|
2294
|
+
return width;
|
|
2295
|
+
}
|
|
2296
|
+
function isUnicodeSupported() {
|
|
2297
|
+
const { env: env2 } = g$1;
|
|
2298
|
+
const { TERM, TERM_PROGRAM } = env2;
|
|
2299
|
+
if (g$1.platform !== "win32") {
|
|
2300
|
+
return TERM !== "linux";
|
|
2301
|
+
}
|
|
2302
|
+
return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
2303
|
+
}
|
|
2304
|
+
var TYPE_COLOR_MAP = {
|
|
2305
|
+
info: "cyan",
|
|
2306
|
+
fail: "red",
|
|
2307
|
+
success: "green",
|
|
2308
|
+
ready: "green",
|
|
2309
|
+
start: "magenta"
|
|
2310
|
+
};
|
|
2311
|
+
var LEVEL_COLOR_MAP = {
|
|
2312
|
+
0: "red",
|
|
2313
|
+
1: "yellow"
|
|
2314
|
+
};
|
|
2315
|
+
var unicode = isUnicodeSupported();
|
|
2316
|
+
var s = (c3, fallback) => unicode ? c3 : fallback;
|
|
2317
|
+
var TYPE_ICONS = {
|
|
2318
|
+
error: s("\u2716", "\xD7"),
|
|
2319
|
+
fatal: s("\u2716", "\xD7"),
|
|
2320
|
+
ready: s("\u2714", "\u221A"),
|
|
2321
|
+
warn: s("\u26A0", "\u203C"),
|
|
2322
|
+
info: s("\u2139", "i"),
|
|
2323
|
+
success: s("\u2714", "\u221A"),
|
|
2324
|
+
debug: s("\u2699", "D"),
|
|
2325
|
+
trace: s("\u2192", "\u2192"),
|
|
2326
|
+
fail: s("\u2716", "\xD7"),
|
|
2327
|
+
start: s("\u25D0", "o"),
|
|
2328
|
+
log: ""
|
|
2329
|
+
};
|
|
2330
|
+
function stringWidth(str) {
|
|
2331
|
+
const hasICU = typeof Intl === "object";
|
|
2332
|
+
if (!hasICU || !Intl.Segmenter) {
|
|
2333
|
+
return stripAnsi(str).length;
|
|
2334
|
+
}
|
|
2335
|
+
return stringWidth$1(str);
|
|
2336
|
+
}
|
|
2337
|
+
var FancyReporter = class extends BasicReporter {
|
|
2338
|
+
formatStack(stack, message, opts) {
|
|
2339
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
2340
|
+
return `
|
|
2341
|
+
${indent}` + parseStack(stack, message).map(
|
|
2342
|
+
(line) => " " + line.replace(/^at +/, (m2) => colors.gray(m2)).replace(/\((.+)\)/, (_3, m2) => `(${colors.cyan(m2)})`)
|
|
2343
|
+
).join(`
|
|
2344
|
+
${indent}`);
|
|
2345
|
+
}
|
|
2346
|
+
formatType(logObj, isBadge, opts) {
|
|
2347
|
+
const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
|
|
2348
|
+
if (isBadge) {
|
|
2349
|
+
return getBgColor(typeColor)(
|
|
2350
|
+
colors.black(` ${logObj.type.toUpperCase()} `)
|
|
2351
|
+
);
|
|
2352
|
+
}
|
|
2353
|
+
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
2354
|
+
return _type ? getColor2(typeColor)(_type) : "";
|
|
2355
|
+
}
|
|
2356
|
+
formatLogObj(logObj, opts) {
|
|
2357
|
+
const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
|
|
2358
|
+
"\n"
|
|
2359
|
+
);
|
|
2360
|
+
if (logObj.type === "box") {
|
|
2361
|
+
return box(
|
|
2362
|
+
characterFormat(
|
|
2363
|
+
message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
|
|
2364
|
+
),
|
|
2365
|
+
{
|
|
2366
|
+
title: logObj.title ? characterFormat(logObj.title) : void 0,
|
|
2367
|
+
style: logObj.style
|
|
2368
|
+
}
|
|
2369
|
+
);
|
|
2370
|
+
}
|
|
2371
|
+
const date = this.formatDate(logObj.date, opts);
|
|
2372
|
+
const coloredDate = date && colors.gray(date);
|
|
2373
|
+
const isBadge = logObj.badge ?? logObj.level < 2;
|
|
2374
|
+
const type = this.formatType(logObj, isBadge, opts);
|
|
2375
|
+
const tag = logObj.tag ? colors.gray(logObj.tag) : "";
|
|
2376
|
+
let line;
|
|
2377
|
+
const left = this.filterAndJoin([type, characterFormat(message)]);
|
|
2378
|
+
const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
|
|
2379
|
+
const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
|
|
2380
|
+
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
|
|
2381
|
+
line += characterFormat(
|
|
2382
|
+
additional.length > 0 ? "\n" + additional.join("\n") : ""
|
|
2383
|
+
);
|
|
2384
|
+
if (logObj.type === "trace") {
|
|
2385
|
+
const _err = new Error("Trace: " + logObj.message);
|
|
2386
|
+
line += this.formatStack(_err.stack || "", _err.message);
|
|
2387
|
+
}
|
|
2388
|
+
return isBadge ? "\n" + line + "\n" : line;
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
function characterFormat(str) {
|
|
2392
|
+
return str.replace(/`([^`]+)`/gm, (_3, m2) => colors.cyan(m2)).replace(/\s+_([^_]+)_\s+/gm, (_3, m2) => ` ${colors.underline(m2)} `);
|
|
2393
|
+
}
|
|
2394
|
+
function getColor2(color = "white") {
|
|
2395
|
+
return colors[color] || colors.white;
|
|
2396
|
+
}
|
|
2397
|
+
function getBgColor(color = "bgWhite") {
|
|
2398
|
+
return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
|
|
2399
|
+
}
|
|
2400
|
+
function createConsola2(options = {}) {
|
|
2401
|
+
let level = _getDefaultLogLevel();
|
|
2402
|
+
if (process.env.CONSOLA_LEVEL) {
|
|
2403
|
+
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
2404
|
+
}
|
|
2405
|
+
const consola2 = createConsola({
|
|
2406
|
+
level,
|
|
2407
|
+
defaults: { level },
|
|
2408
|
+
stdout: process.stdout,
|
|
2409
|
+
stderr: process.stderr,
|
|
2410
|
+
prompt: (...args) => Promise.resolve().then(() => (init_prompt(), prompt_exports)).then((m2) => m2.prompt(...args)),
|
|
2411
|
+
reporters: options.reporters || [
|
|
2412
|
+
options.fancy ?? !(T2 || R2) ? new FancyReporter() : new BasicReporter()
|
|
2413
|
+
],
|
|
2414
|
+
...options
|
|
2415
|
+
});
|
|
2416
|
+
return consola2;
|
|
2417
|
+
}
|
|
2418
|
+
function _getDefaultLogLevel() {
|
|
2419
|
+
if (g2) {
|
|
2420
|
+
return LogLevels.debug;
|
|
2421
|
+
}
|
|
2422
|
+
if (R2) {
|
|
2423
|
+
return LogLevels.warn;
|
|
2424
|
+
}
|
|
2425
|
+
return LogLevels.info;
|
|
2426
|
+
}
|
|
2427
|
+
var consola = createConsola2();
|
|
2428
|
+
|
|
2429
|
+
// ../../packages/shapes/dist/index.js
|
|
2430
|
+
var import_shell_quote = __toESM(require_shell_quote(), 1);
|
|
2431
|
+
import { homedir as homedir5 } from "os";
|
|
2432
|
+
import { join as join5 } from "path";
|
|
2433
|
+
function parseKeyValue(line) {
|
|
2434
|
+
const eqIndex = line.indexOf("=");
|
|
2435
|
+
if (eqIndex === -1)
|
|
2436
|
+
return null;
|
|
2437
|
+
const key = line.slice(0, eqIndex).trim();
|
|
2438
|
+
const value = line.slice(eqIndex + 1).trim();
|
|
2439
|
+
if (!key || !value)
|
|
2440
|
+
return null;
|
|
2441
|
+
return { key, value };
|
|
2442
|
+
}
|
|
2443
|
+
function parseTomlValue(raw) {
|
|
2444
|
+
const trimmed = raw.trim();
|
|
2445
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"'))
|
|
2446
|
+
return trimmed.slice(1, -1);
|
|
2447
|
+
if (trimmed === "true")
|
|
2448
|
+
return true;
|
|
2449
|
+
if (trimmed === "false")
|
|
2450
|
+
return false;
|
|
2451
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
2452
|
+
const inner = trimmed.slice(1, -1).trim();
|
|
2453
|
+
if (!inner)
|
|
2454
|
+
return [];
|
|
2455
|
+
return inner.split(",").map((value) => value.trim().replace(/^"|"$/g, ""));
|
|
2456
|
+
}
|
|
2457
|
+
return trimmed;
|
|
2458
|
+
}
|
|
2459
|
+
function parseAdapterToml(content) {
|
|
2460
|
+
const result = {};
|
|
2461
|
+
const operations = [];
|
|
2462
|
+
let currentSection = "root";
|
|
2463
|
+
let currentEntry = {};
|
|
2464
|
+
const flushOperation = () => {
|
|
2465
|
+
if (currentSection === "operation" && Object.keys(currentEntry).length > 0) {
|
|
2466
|
+
operations.push(currentEntry);
|
|
2467
|
+
currentEntry = {};
|
|
2468
|
+
}
|
|
2469
|
+
};
|
|
2470
|
+
for (const rawLine of content.split("\n")) {
|
|
2471
|
+
const line = rawLine.trim();
|
|
2472
|
+
if (!line || line.startsWith("#"))
|
|
2473
|
+
continue;
|
|
2474
|
+
if (line === "[cli]") {
|
|
2475
|
+
flushOperation();
|
|
2476
|
+
currentSection = "cli";
|
|
2477
|
+
result.cli = {};
|
|
2478
|
+
continue;
|
|
2479
|
+
}
|
|
2480
|
+
if (line === "[[operation]]") {
|
|
2481
|
+
flushOperation();
|
|
2482
|
+
currentSection = "operation";
|
|
2483
|
+
currentEntry = {};
|
|
2484
|
+
continue;
|
|
2485
|
+
}
|
|
2486
|
+
const kv = parseKeyValue(line);
|
|
2487
|
+
if (!kv)
|
|
2488
|
+
continue;
|
|
2489
|
+
const value = parseTomlValue(kv.value);
|
|
2490
|
+
if (currentSection === "root") {
|
|
2491
|
+
;
|
|
2492
|
+
result[kv.key] = value;
|
|
2493
|
+
} else if (currentSection === "cli") {
|
|
2494
|
+
;
|
|
2495
|
+
result.cli[kv.key] = value;
|
|
2496
|
+
} else {
|
|
2497
|
+
currentEntry[kv.key] = value;
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
flushOperation();
|
|
2501
|
+
result.operation = operations;
|
|
2502
|
+
if (result.schema !== "openape-shapes/v1") {
|
|
2503
|
+
throw new Error(`Unsupported adapter schema: ${result.schema ?? "missing"}`);
|
|
2504
|
+
}
|
|
2505
|
+
if (!result.cli?.id || !result.cli.executable) {
|
|
2506
|
+
throw new Error("Adapter is missing cli.id or cli.executable");
|
|
2507
|
+
}
|
|
2508
|
+
if (!result.operation?.length) {
|
|
2509
|
+
throw new Error("Adapter must define at least one [[operation]] entry");
|
|
2510
|
+
}
|
|
2511
|
+
return {
|
|
2512
|
+
schema: result.schema,
|
|
2513
|
+
cli: {
|
|
2514
|
+
id: String(result.cli.id),
|
|
2515
|
+
executable: String(result.cli.executable),
|
|
2516
|
+
...result.cli.audience ? { audience: String(result.cli.audience) } : {},
|
|
2517
|
+
...result.cli.version ? { version: String(result.cli.version) } : {}
|
|
2518
|
+
},
|
|
2519
|
+
operations: result.operation.map((operation) => {
|
|
2520
|
+
if (!Array.isArray(operation.command) || operation.command.some((token) => typeof token !== "string")) {
|
|
2521
|
+
throw new Error(`Operation ${String(operation.id ?? "<unknown>")} is missing command[]`);
|
|
2522
|
+
}
|
|
2523
|
+
if (!Array.isArray(operation.resource_chain) || operation.resource_chain.some((token) => typeof token !== "string")) {
|
|
2524
|
+
throw new Error(`Operation ${String(operation.id ?? "<unknown>")} is missing resource_chain[]`);
|
|
2525
|
+
}
|
|
2526
|
+
if (typeof operation.id !== "string" || typeof operation.display !== "string" || typeof operation.action !== "string") {
|
|
2527
|
+
throw new TypeError("Operation must define id, display, and action");
|
|
2528
|
+
}
|
|
2529
|
+
return {
|
|
2530
|
+
id: operation.id,
|
|
2531
|
+
command: operation.command,
|
|
2532
|
+
...Array.isArray(operation.positionals) ? { positionals: operation.positionals } : {},
|
|
2533
|
+
...Array.isArray(operation.required_options) ? { required_options: operation.required_options } : {},
|
|
2534
|
+
display: operation.display,
|
|
2535
|
+
action: operation.action,
|
|
2536
|
+
risk: operation.risk || "low",
|
|
2537
|
+
resource_chain: operation.resource_chain,
|
|
2538
|
+
...operation.exact_command !== void 0 ? { exact_command: Boolean(operation.exact_command) } : {}
|
|
2539
|
+
};
|
|
2540
|
+
})
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
function digest(content) {
|
|
2544
|
+
return `SHA-256:${createHash("sha256").update(content).digest("hex")}`;
|
|
2545
|
+
}
|
|
2546
|
+
function adapterDirs() {
|
|
2547
|
+
return [
|
|
2548
|
+
join2(process.cwd(), ".openape", "shapes", "adapters"),
|
|
2549
|
+
join2(homedir2(), ".openape", "shapes", "adapters"),
|
|
2550
|
+
join2("/etc", "openape", "shapes", "adapters")
|
|
2551
|
+
];
|
|
2552
|
+
}
|
|
2553
|
+
function findByExecutable(executable) {
|
|
2554
|
+
for (const dir of adapterDirs()) {
|
|
2555
|
+
if (!existsSync2(dir))
|
|
2556
|
+
continue;
|
|
2557
|
+
try {
|
|
2558
|
+
const files = readdirSync(dir).filter((f3) => f3.endsWith(".toml"));
|
|
2559
|
+
for (const file of files) {
|
|
2560
|
+
const path = join2(dir, file);
|
|
2561
|
+
const content = readFileSync(path, "utf-8");
|
|
2562
|
+
const match = content.match(/^\s*executable\s*=\s*"([^"]+)"/m);
|
|
2563
|
+
if (match && match[1] === executable)
|
|
2564
|
+
return path;
|
|
2565
|
+
}
|
|
2566
|
+
} catch {
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
return void 0;
|
|
2570
|
+
}
|
|
2571
|
+
function resolveAdapterPath(cliId, explicitPath) {
|
|
2572
|
+
if (explicitPath) {
|
|
2573
|
+
if (existsSync2(explicitPath))
|
|
2574
|
+
return explicitPath;
|
|
2575
|
+
throw new Error(`Adapter file not found: ${explicitPath}`);
|
|
2576
|
+
}
|
|
2577
|
+
const candidates = adapterDirs().map((dir) => join2(dir, `${cliId}.toml`));
|
|
2578
|
+
const match = candidates.find((path) => existsSync2(path));
|
|
2579
|
+
if (match)
|
|
2580
|
+
return match;
|
|
2581
|
+
const byExec = findByExecutable(cliId);
|
|
2582
|
+
if (byExec)
|
|
2583
|
+
return byExec;
|
|
2584
|
+
throw new Error(`No adapter found for ${cliId}`);
|
|
2585
|
+
}
|
|
2586
|
+
function loadAdapter(cliId, explicitPath) {
|
|
2587
|
+
const source = resolveAdapterPath(cliId, explicitPath);
|
|
2588
|
+
const content = readFileSync(source, "utf-8");
|
|
2589
|
+
const adapter = parseAdapterToml(content);
|
|
2590
|
+
const idMatch = adapter.cli.id === cliId;
|
|
2591
|
+
const fileMatch = basename(source) === `${cliId}.toml`;
|
|
2592
|
+
const execMatch = adapter.cli.executable === cliId;
|
|
2593
|
+
if (!idMatch && !fileMatch && !execMatch)
|
|
2594
|
+
throw new Error(`Adapter ${source} does not match requested CLI ${cliId}`);
|
|
2595
|
+
return {
|
|
2596
|
+
adapter,
|
|
2597
|
+
source,
|
|
2598
|
+
digest: digest(content)
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
var REGISTRY_URL = process.env.SHAPES_REGISTRY_URL ?? "https://raw.githubusercontent.com/openape-ai/shapes-registry/main/registry.json";
|
|
2602
|
+
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
2603
|
+
async function resolveCommand(loaded, fullArgv) {
|
|
2604
|
+
const [executable, ...commandArgv] = fullArgv;
|
|
2605
|
+
if (!executable) {
|
|
2606
|
+
throw new Error("Missing wrapped command");
|
|
2607
|
+
}
|
|
2608
|
+
if (executable !== loaded.adapter.cli.executable) {
|
|
2609
|
+
throw new Error(`Adapter ${loaded.adapter.cli.id} expects executable ${loaded.adapter.cli.executable}, got ${executable}`);
|
|
2610
|
+
}
|
|
2611
|
+
const match = matchArgvToOperation(loaded.adapter.operations, commandArgv);
|
|
2612
|
+
if (!match) {
|
|
2613
|
+
throw new Error(`No adapter operation matched: ${fullArgv.join(" ")}`);
|
|
2614
|
+
}
|
|
2615
|
+
const { operation, bindings } = match;
|
|
2616
|
+
const detail = buildCliAuthDetail(loaded.adapter.cli.id, operation, bindings);
|
|
2617
|
+
return {
|
|
2618
|
+
adapter: loaded.adapter,
|
|
2619
|
+
source: loaded.source,
|
|
2620
|
+
digest: loaded.digest,
|
|
2621
|
+
executable,
|
|
2622
|
+
commandArgv,
|
|
2623
|
+
bindings,
|
|
2624
|
+
detail,
|
|
2625
|
+
executionContext: {
|
|
2626
|
+
argv: fullArgv,
|
|
2627
|
+
argv_hash: await computeArgvHash(fullArgv),
|
|
2628
|
+
adapter_id: loaded.adapter.cli.id,
|
|
2629
|
+
adapter_version: loaded.adapter.cli.version ?? loaded.adapter.schema,
|
|
2630
|
+
adapter_digest: loaded.digest,
|
|
2631
|
+
resolved_executable: executable,
|
|
2632
|
+
context_bindings: bindings
|
|
2633
|
+
},
|
|
2634
|
+
permission: detail.permission
|
|
2635
|
+
};
|
|
2636
|
+
}
|
|
2637
|
+
var AUTH_FILE2 = join5(homedir5(), ".config", "apes", "auth.json");
|
|
2638
|
+
|
|
2639
|
+
// ../../packages/apes/dist/chunk-BA2V3BBO.js
|
|
2640
|
+
var explainCommand = defineCommand({
|
|
2641
|
+
meta: {
|
|
2642
|
+
name: "explain",
|
|
2643
|
+
description: "Show what permission a wrapped command would need"
|
|
2644
|
+
},
|
|
2645
|
+
args: {
|
|
2646
|
+
adapter: {
|
|
2647
|
+
type: "string",
|
|
2648
|
+
description: "Explicit path to adapter TOML file"
|
|
2649
|
+
},
|
|
2650
|
+
_: {
|
|
2651
|
+
type: "positional",
|
|
2652
|
+
description: "Wrapped command (after --)",
|
|
2653
|
+
required: false
|
|
2654
|
+
}
|
|
2655
|
+
},
|
|
2656
|
+
async run({ rawArgs }) {
|
|
2657
|
+
const command = extractWrappedCommand(rawArgs ?? []);
|
|
2658
|
+
if (command.length === 0)
|
|
2659
|
+
throw new Error("Missing wrapped command. Usage: shapes explain [--adapter <file>] -- <cli> ...");
|
|
2660
|
+
const adapterOpt = extractOption(rawArgs ?? [], "adapter");
|
|
2661
|
+
const loaded = loadAdapter(command[0], adapterOpt);
|
|
2662
|
+
const resolved = await resolveCommand(loaded, command);
|
|
2663
|
+
process.stdout.write(`${JSON.stringify({
|
|
2664
|
+
adapter: resolved.adapter.cli.id,
|
|
2665
|
+
source: resolved.source,
|
|
2666
|
+
operation: resolved.detail.operation_id,
|
|
2667
|
+
display: resolved.detail.display,
|
|
2668
|
+
permission: resolved.permission,
|
|
2669
|
+
resource_chain: resolved.detail.resource_chain,
|
|
2670
|
+
exact_command: resolved.detail.constraints?.exact_command ?? false,
|
|
2671
|
+
adapter_digest: resolved.digest
|
|
2672
|
+
}, null, 2)}
|
|
2673
|
+
`);
|
|
2674
|
+
}
|
|
2675
|
+
});
|
|
2676
|
+
function extractWrappedCommand(args) {
|
|
2677
|
+
const delimiter = args.indexOf("--");
|
|
2678
|
+
return delimiter >= 0 ? args.slice(delimiter + 1) : [];
|
|
2679
|
+
}
|
|
2680
|
+
function extractOption(args, name) {
|
|
2681
|
+
const delimiter = args.indexOf("--");
|
|
2682
|
+
const optionArgs = delimiter >= 0 ? args.slice(0, delimiter) : args;
|
|
2683
|
+
const index = optionArgs.indexOf(`--${name}`);
|
|
2684
|
+
if (index >= 0 && index + 1 < optionArgs.length)
|
|
2685
|
+
return optionArgs[index + 1];
|
|
2686
|
+
return void 0;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
// ../../packages/apes/dist/chunk-MMBFV5WN.js
|
|
2690
|
+
init_chunk_OBF7IMQ2();
|
|
2691
|
+
var debug = process.argv.includes("--debug");
|
|
2692
|
+
|
|
2693
|
+
// ../../packages/apes/dist/index.js
|
|
2694
|
+
init_chunk_OBF7IMQ2();
|
|
2695
|
+
|
|
2696
|
+
// ../../packages/agent-runtime/dist/index.js
|
|
2697
|
+
import { spawn } from "child_process";
|
|
2698
|
+
import { mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
2699
|
+
import { homedir as homedir3 } from "os";
|
|
2700
|
+
import { dirname, normalize, resolve } from "path";
|
|
2701
|
+
import { homedir as homedir22 } from "os";
|
|
2702
|
+
import { resolve as resolve2 } from "path";
|
|
2703
|
+
import process2 from "process";
|
|
2704
|
+
import { execFileSync } from "child_process";
|
|
2705
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
2706
|
+
var DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2707
|
+
var MAX_STDIO_BYTES = 64 * 1024;
|
|
2708
|
+
var BIN = "ape-shell";
|
|
2709
|
+
function capStdio(s2) {
|
|
2710
|
+
const buf = Buffer.from(s2, "utf8");
|
|
2711
|
+
if (buf.byteLength <= MAX_STDIO_BYTES) return s2;
|
|
2712
|
+
return `${buf.subarray(0, MAX_STDIO_BYTES).toString("utf8")}
|
|
2713
|
+
[truncated to ${MAX_STDIO_BYTES} bytes]`;
|
|
2714
|
+
}
|
|
2715
|
+
function runApeShell(cmd, timeoutMs = DEFAULT_TIMEOUT_MS, cwd) {
|
|
2716
|
+
const bypass = process.env.OPENAPE_BYPASS_APE_SHELL === "1";
|
|
2717
|
+
const [execBin, execArgs] = bypass ? ["/bin/bash", ["-c", cmd]] : [BIN, ["-c", cmd]];
|
|
2718
|
+
return new Promise((resolveResult) => {
|
|
2719
|
+
const child = spawn(execBin, execArgs, {
|
|
2720
|
+
env: { ...process.env, APE_WAIT: "1" },
|
|
2721
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
2722
|
+
...cwd ? { cwd } : {}
|
|
2723
|
+
});
|
|
2724
|
+
let stdout2 = "";
|
|
2725
|
+
let stderr = "";
|
|
2726
|
+
let timedOut = false;
|
|
2727
|
+
let spawnError = null;
|
|
2728
|
+
child.stdout.on("data", (chunk) => {
|
|
2729
|
+
stdout2 += chunk.toString("utf8");
|
|
2730
|
+
});
|
|
2731
|
+
child.stderr.on("data", (chunk) => {
|
|
2732
|
+
stderr += chunk.toString("utf8");
|
|
2733
|
+
});
|
|
2734
|
+
child.on("error", (err) => {
|
|
2735
|
+
spawnError = err;
|
|
2736
|
+
});
|
|
2737
|
+
const timer = setTimeout(() => {
|
|
2738
|
+
timedOut = true;
|
|
2739
|
+
child.kill("SIGTERM");
|
|
2740
|
+
setTimeout(() => {
|
|
2741
|
+
try {
|
|
2742
|
+
child.kill("SIGKILL");
|
|
2743
|
+
} catch {
|
|
2744
|
+
}
|
|
2745
|
+
}, 5e3);
|
|
2746
|
+
}, timeoutMs);
|
|
2747
|
+
child.on("close", (code) => {
|
|
2748
|
+
clearTimeout(timer);
|
|
2749
|
+
if (spawnError) {
|
|
2750
|
+
resolveResult({
|
|
2751
|
+
stdout: "",
|
|
2752
|
+
stderr: "",
|
|
2753
|
+
exit_code: -1,
|
|
2754
|
+
error: spawnError.message,
|
|
2755
|
+
hint: `Could not exec '${execBin}'. The agent host needs @openape/apes installed globally so ape-shell is on PATH (or set OPENAPE_BYPASS_APE_SHELL=1 to skip the gated shell entirely \u2014 meant for the OpenApe pod where the container IS the sandbox).`
|
|
2756
|
+
});
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
resolveResult({
|
|
2760
|
+
stdout: capStdio(stdout2),
|
|
2761
|
+
stderr: capStdio(stderr),
|
|
2762
|
+
exit_code: code ?? -1,
|
|
2763
|
+
...timedOut ? { timed_out: true } : {}
|
|
2764
|
+
});
|
|
2765
|
+
});
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2768
|
+
var DEFAULTS = { DEFAULT_TIMEOUT_MS };
|
|
2769
|
+
var bashTools = [
|
|
2770
|
+
{
|
|
2771
|
+
name: "bash",
|
|
2772
|
+
description: "Run a shell command on the agent host. Every invocation goes through the OpenApe DDISA grant cycle \u2014 auto-approved if the owner has a matching YOLO scope, otherwise the owner gets a push notification to approve. Runs as the agent's macOS user, so file/network access is limited to what that user can see. Returns stdout, stderr, and exit code. For repeated command patterns ask the owner to set up a YOLO scope so approvals don't pile up.",
|
|
2773
|
+
parameters: {
|
|
2774
|
+
type: "object",
|
|
2775
|
+
properties: {
|
|
2776
|
+
cmd: {
|
|
2777
|
+
type: "string",
|
|
2778
|
+
description: "Shell command to run, e.g. `ls -la ~/Documents`, `git status`, `curl -fsSL https://example.com`. The whole string is passed to `bash -c`; quote internally as needed."
|
|
2779
|
+
},
|
|
2780
|
+
timeout_ms: {
|
|
2781
|
+
type: "number",
|
|
2782
|
+
description: "Wall-clock cap for the whole approval-and-run cycle in milliseconds. Default 300000 (5 min). Approval waits count against this budget."
|
|
2783
|
+
}
|
|
2784
|
+
},
|
|
2785
|
+
required: ["cmd"]
|
|
2786
|
+
},
|
|
2787
|
+
execute: async (args) => {
|
|
2788
|
+
const a2 = args;
|
|
2789
|
+
if (typeof a2.cmd !== "string" || a2.cmd.trim() === "") {
|
|
2790
|
+
throw new Error("cmd must be a non-empty string");
|
|
2791
|
+
}
|
|
2792
|
+
const timeout = typeof a2.timeout_ms === "number" && a2.timeout_ms > 0 ? a2.timeout_ms : DEFAULTS.DEFAULT_TIMEOUT_MS;
|
|
2793
|
+
return await runApeShell(a2.cmd, timeout);
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
];
|
|
2797
|
+
var MAX_BYTES = 1024 * 1024;
|
|
2798
|
+
function jailPath(input) {
|
|
2799
|
+
if (typeof input !== "string" || input === "") {
|
|
2800
|
+
throw new Error("path must be a non-empty string");
|
|
2801
|
+
}
|
|
2802
|
+
const home = homedir3();
|
|
2803
|
+
const candidate = input.startsWith("~/") ? resolve(home, input.slice(2)) : input.startsWith("/") ? normalize(input) : resolve(home, input);
|
|
2804
|
+
if (candidate !== home && !candidate.startsWith(`${home}/`)) {
|
|
2805
|
+
throw new Error(`path "${input}" resolves outside the agent's home`);
|
|
2806
|
+
}
|
|
2807
|
+
return candidate;
|
|
2808
|
+
}
|
|
2809
|
+
var fileTools = [
|
|
2810
|
+
{
|
|
2811
|
+
name: "file.read",
|
|
2812
|
+
description: "Read a UTF-8 file from the agent's home directory ($HOME). Capped at 1MB. Path traversal blocked.",
|
|
2813
|
+
parameters: {
|
|
2814
|
+
type: "object",
|
|
2815
|
+
properties: {
|
|
2816
|
+
path: { type: "string", description: "Path relative to $HOME (or absolute under $HOME). `..` segments are rejected." }
|
|
2817
|
+
},
|
|
2818
|
+
required: ["path"]
|
|
2819
|
+
},
|
|
2820
|
+
execute: async (args) => {
|
|
2821
|
+
const a2 = args;
|
|
2822
|
+
const p = jailPath(a2.path);
|
|
2823
|
+
const content = readFileSync2(p, "utf8");
|
|
2824
|
+
if (Buffer.byteLength(content, "utf8") > MAX_BYTES) {
|
|
2825
|
+
return { path: p, truncated: true, content: content.slice(0, MAX_BYTES) };
|
|
2826
|
+
}
|
|
2827
|
+
return { path: p, truncated: false, content };
|
|
2828
|
+
}
|
|
2829
|
+
},
|
|
2830
|
+
{
|
|
2831
|
+
name: "file.write",
|
|
2832
|
+
description: "Write a UTF-8 file under the agent's home directory. Creates parent dirs as needed. 1MB max.",
|
|
2833
|
+
parameters: {
|
|
2834
|
+
type: "object",
|
|
2835
|
+
properties: {
|
|
2836
|
+
path: { type: "string", description: "Path relative to $HOME (or absolute under $HOME)." },
|
|
2837
|
+
content: { type: "string", description: "File body. Existing files are overwritten." }
|
|
2838
|
+
},
|
|
2839
|
+
required: ["path", "content"]
|
|
2840
|
+
},
|
|
2841
|
+
execute: async (args) => {
|
|
2842
|
+
const a2 = args;
|
|
2843
|
+
if (typeof a2.content !== "string") throw new Error("content must be a string");
|
|
2844
|
+
if (Buffer.byteLength(a2.content, "utf8") > MAX_BYTES) {
|
|
2845
|
+
throw new Error(`content exceeds ${MAX_BYTES} byte cap`);
|
|
2846
|
+
}
|
|
2847
|
+
const p = jailPath(a2.path);
|
|
2848
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
2849
|
+
writeFileSync(p, a2.content, { encoding: "utf8" });
|
|
2850
|
+
return { path: p, bytes: Buffer.byteLength(a2.content, "utf8") };
|
|
2851
|
+
}
|
|
2852
|
+
},
|
|
2853
|
+
{
|
|
2854
|
+
name: "file.edit",
|
|
2855
|
+
description: "Replace an exact substring in a file under the agent's home directory. Prefer this over file.write for edits \u2014 it touches only the changed region instead of rewriting the whole file. `old_string` must appear exactly once unless `replace_all` is true. Path traversal blocked, 1MB max.",
|
|
2856
|
+
parameters: {
|
|
2857
|
+
type: "object",
|
|
2858
|
+
properties: {
|
|
2859
|
+
path: { type: "string", description: "Path relative to $HOME (or absolute under $HOME)." },
|
|
2860
|
+
old_string: { type: "string", description: "Exact text to replace. Include enough surrounding context to be unique unless replace_all is set." },
|
|
2861
|
+
new_string: { type: "string", description: "Replacement text. Must differ from old_string." },
|
|
2862
|
+
replace_all: { type: "boolean", description: "Replace every occurrence instead of requiring a unique match. Default false." }
|
|
2863
|
+
},
|
|
2864
|
+
required: ["path", "old_string", "new_string"]
|
|
2865
|
+
},
|
|
2866
|
+
execute: async (args) => {
|
|
2867
|
+
const a2 = args;
|
|
2868
|
+
if (typeof a2.old_string !== "string" || a2.old_string === "") {
|
|
2869
|
+
throw new Error("old_string must be a non-empty string");
|
|
2870
|
+
}
|
|
2871
|
+
if (typeof a2.new_string !== "string") {
|
|
2872
|
+
throw new TypeError("new_string must be a string");
|
|
2873
|
+
}
|
|
2874
|
+
if (a2.old_string === a2.new_string) {
|
|
2875
|
+
throw new Error("old_string and new_string are identical \u2014 nothing to change");
|
|
2876
|
+
}
|
|
2877
|
+
const replaceAll = a2.replace_all === true;
|
|
2878
|
+
const p = jailPath(a2.path);
|
|
2879
|
+
const before = readFileSync2(p, "utf8");
|
|
2880
|
+
const occurrences = before.split(a2.old_string).length - 1;
|
|
2881
|
+
if (occurrences === 0) {
|
|
2882
|
+
throw new Error("old_string not found in file");
|
|
2883
|
+
}
|
|
2884
|
+
if (occurrences > 1 && !replaceAll) {
|
|
2885
|
+
throw new Error(`old_string occurs ${occurrences} times \u2014 pass replace_all:true or add surrounding context to make it unique`);
|
|
2886
|
+
}
|
|
2887
|
+
const after = replaceAll ? before.split(a2.old_string).join(a2.new_string) : before.replace(a2.old_string, a2.new_string);
|
|
2888
|
+
if (Buffer.byteLength(after, "utf8") > MAX_BYTES) {
|
|
2889
|
+
throw new Error(`result exceeds ${MAX_BYTES} byte cap`);
|
|
2890
|
+
}
|
|
2891
|
+
writeFileSync(p, after, { encoding: "utf8" });
|
|
2892
|
+
return { path: p, replacements: replaceAll ? occurrences : 1 };
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
];
|
|
2896
|
+
var BRANCH_RE = /^[\w./-]{1,200}$/;
|
|
2897
|
+
var ID_RE = /^\d{1,12}$/;
|
|
2898
|
+
function shq(s2) {
|
|
2899
|
+
return `'${String(s2).replace(/'/g, "'\\''")}'`;
|
|
2900
|
+
}
|
|
2901
|
+
function assertBranch(v2) {
|
|
2902
|
+
if (typeof v2 !== "string" || !BRANCH_RE.test(v2)) {
|
|
2903
|
+
throw new Error("branch must match ^[A-Za-z0-9._/-]{1,200}$");
|
|
2904
|
+
}
|
|
2905
|
+
return v2;
|
|
2906
|
+
}
|
|
2907
|
+
function assertId(v2) {
|
|
2908
|
+
if (typeof v2 !== "string" && typeof v2 !== "number") throw new Error("id required");
|
|
2909
|
+
const s2 = String(v2);
|
|
2910
|
+
if (!ID_RE.test(s2)) throw new Error("id must be a number");
|
|
2911
|
+
return s2;
|
|
2912
|
+
}
|
|
2913
|
+
var githubAdapter = {
|
|
2914
|
+
id: "github",
|
|
2915
|
+
matchesRemote: (url) => /github\.com/i.test(url),
|
|
2916
|
+
prCreate: (i2) => {
|
|
2917
|
+
const head = assertBranch(i2.head);
|
|
2918
|
+
const parts = ["gh", "pr", "create", "--title", shq(i2.title), "--body", shq(i2.body), "--head", shq(head)];
|
|
2919
|
+
if (i2.base !== void 0) parts.push("--base", shq(assertBranch(i2.base)));
|
|
2920
|
+
return parts.join(" ");
|
|
2921
|
+
},
|
|
2922
|
+
prMerge: (i2) => {
|
|
2923
|
+
const ref = String(i2.ref);
|
|
2924
|
+
const refTok = ID_RE.test(ref) ? ref : assertBranch(ref);
|
|
2925
|
+
const parts = ["gh", "pr", "merge", shq(refTok)];
|
|
2926
|
+
if (i2.squash === true) parts.push("--squash");
|
|
2927
|
+
if (i2.auto) parts.push("--auto");
|
|
2928
|
+
if (i2.deleteBranch) parts.push("--delete-branch");
|
|
2929
|
+
return parts.join(" ");
|
|
2930
|
+
},
|
|
2931
|
+
prStatus: (ref) => {
|
|
2932
|
+
const r3 = String(ref);
|
|
2933
|
+
const refTok = ID_RE.test(r3) ? r3 : assertBranch(r3);
|
|
2934
|
+
return `gh pr view ${shq(refTok)} --json state,mergeStateStatus,statusCheckRollup,reviewDecision`;
|
|
2935
|
+
},
|
|
2936
|
+
issueGet: (ref, repo) => `gh issue view ${assertId(ref)}${repo ? ` --repo ${shq(repo)}` : ""} --json number,title,body,labels`
|
|
2937
|
+
};
|
|
2938
|
+
var azureAdapter = {
|
|
2939
|
+
id: "azure",
|
|
2940
|
+
matchesRemote: (url) => /dev\.azure\.com|visualstudio\.com/i.test(url),
|
|
2941
|
+
prCreate: (i2) => {
|
|
2942
|
+
const head = assertBranch(i2.head);
|
|
2943
|
+
const parts = ["az", "repos", "pr", "create", "--title", shq(i2.title), "--description", shq(i2.body), "--source-branch", shq(head)];
|
|
2944
|
+
if (i2.base !== void 0) parts.push("--target-branch", shq(assertBranch(i2.base)));
|
|
2945
|
+
return parts.join(" ");
|
|
2946
|
+
},
|
|
2947
|
+
prMerge: (i2) => {
|
|
2948
|
+
const id = assertId(i2.ref);
|
|
2949
|
+
const parts = ["az", "repos", "pr", "update", "--id", id];
|
|
2950
|
+
if (i2.auto) parts.push("--auto-complete", "true");
|
|
2951
|
+
else parts.push("--status", "completed");
|
|
2952
|
+
if (i2.squash === true) parts.push("--merge-commit-message-style", "squash");
|
|
2953
|
+
if (i2.deleteBranch) parts.push("--delete-source-branch", "true");
|
|
2954
|
+
return parts.join(" ");
|
|
2955
|
+
},
|
|
2956
|
+
prStatus: (ref) => `az repos pr show --id ${assertId(ref)}`,
|
|
2957
|
+
// Azure work items are org/project-scoped, not repo-scoped, so `repo`
|
|
2958
|
+
// doesn't apply here — the caller's `az` config (defaults.organization/
|
|
2959
|
+
// project) resolves it.
|
|
2960
|
+
issueGet: (ref, _repo) => `az boards work-item show --id ${assertId(ref)}`
|
|
2961
|
+
};
|
|
2962
|
+
var registry = /* @__PURE__ */ new Map([
|
|
2963
|
+
[githubAdapter.id, githubAdapter],
|
|
2964
|
+
[azureAdapter.id, azureAdapter]
|
|
2965
|
+
]);
|
|
2966
|
+
function listForges() {
|
|
2967
|
+
return [...registry.keys()];
|
|
2968
|
+
}
|
|
2969
|
+
function getForge(id) {
|
|
2970
|
+
const a2 = registry.get(id);
|
|
2971
|
+
if (!a2) {
|
|
2972
|
+
throw new Error(`unknown forge '${id}'. Registered: ${listForges().join(", ")}. Add one with registerForge().`);
|
|
2973
|
+
}
|
|
2974
|
+
return a2;
|
|
2975
|
+
}
|
|
2976
|
+
function detectForge(remoteUrl) {
|
|
2977
|
+
if (typeof remoteUrl !== "string" || remoteUrl === "") {
|
|
2978
|
+
throw new Error("remote URL required to detect forge");
|
|
2979
|
+
}
|
|
2980
|
+
for (const a2 of registry.values()) {
|
|
2981
|
+
if (a2.matchesRemote(remoteUrl)) return a2.id;
|
|
2982
|
+
}
|
|
2983
|
+
throw new Error(`no forge adapter matches remote: ${remoteUrl}. Registered: ${listForges().join(", ")}. Register one with registerForge() (e.g. GitLab/Bitbucket/Gitea).`);
|
|
2984
|
+
}
|
|
2985
|
+
function buildPrCreate(input) {
|
|
2986
|
+
return getForge(input.forge).prCreate(input);
|
|
2987
|
+
}
|
|
2988
|
+
function buildPrMerge(input) {
|
|
2989
|
+
return getForge(input.forge).prMerge(input);
|
|
2990
|
+
}
|
|
2991
|
+
function buildPrStatus(forge, ref) {
|
|
2992
|
+
return getForge(forge).prStatus(ref);
|
|
2993
|
+
}
|
|
2994
|
+
function buildIssueGet(forge, ref, repo) {
|
|
2995
|
+
return getForge(forge).issueGet(ref, repo);
|
|
2996
|
+
}
|
|
2997
|
+
function resolveForge(a2) {
|
|
2998
|
+
if (typeof a2.forge === "string" && a2.forge !== "") return a2.forge;
|
|
2999
|
+
if (typeof a2.remote === "string") return detectForge(a2.remote);
|
|
3000
|
+
throw new Error("provide a forge id (e.g. github, azure, or a registered adapter) or a remote URL to detect it");
|
|
3001
|
+
}
|
|
3002
|
+
var forgeParam = { type: "string", description: "Target forge id (github, azure, or a registered adapter). Omit to auto-detect from `remote`." };
|
|
3003
|
+
var remoteParam = { type: "string", description: "git remote URL \u2014 used to auto-detect the forge when `forge` is omitted." };
|
|
3004
|
+
var forgeTools = [
|
|
3005
|
+
{
|
|
3006
|
+
name: "forge.pr.create",
|
|
3007
|
+
description: "Open a pull request on GitHub (gh) or Azure DevOps (az). Gated via the DDISA grant cycle. Provider chosen by `forge` or auto-detected from `remote`.",
|
|
3008
|
+
parameters: {
|
|
3009
|
+
type: "object",
|
|
3010
|
+
properties: {
|
|
3011
|
+
forge: forgeParam,
|
|
3012
|
+
remote: remoteParam,
|
|
3013
|
+
title: { type: "string", description: "PR title." },
|
|
3014
|
+
body: { type: "string", description: "PR description / body." },
|
|
3015
|
+
head: { type: "string", description: "Source branch." },
|
|
3016
|
+
base: { type: "string", description: "Target branch. Omit for the repo default." }
|
|
3017
|
+
},
|
|
3018
|
+
required: ["title", "body", "head"]
|
|
3019
|
+
},
|
|
3020
|
+
execute: async (args) => {
|
|
3021
|
+
const a2 = args;
|
|
3022
|
+
const cmd = buildPrCreate({ forge: resolveForge(a2), title: a2.title, body: a2.body, head: a2.head, base: a2.base });
|
|
3023
|
+
return await runApeShell(cmd);
|
|
3024
|
+
}
|
|
3025
|
+
},
|
|
3026
|
+
{
|
|
3027
|
+
name: "forge.pr.merge",
|
|
3028
|
+
description: 'Merge a PR \u2014 or with auto=true, arm "merge when checks pass" (gh --auto / az auto-complete) so the platform merges only on green CI. Gated. Never bypasses required checks (branch protection is the server-side gate).',
|
|
3029
|
+
parameters: {
|
|
3030
|
+
type: "object",
|
|
3031
|
+
properties: {
|
|
3032
|
+
forge: forgeParam,
|
|
3033
|
+
remote: remoteParam,
|
|
3034
|
+
ref: { type: "string", description: "GitHub: PR number or branch. Azure: PR id." },
|
|
3035
|
+
auto: { type: "boolean", description: "Arm merge-when-green instead of immediate merge. Recommended." },
|
|
3036
|
+
squash: { type: "boolean", description: "Squash-merge. Default true." },
|
|
3037
|
+
delete_branch: { type: "boolean", description: "Delete the source branch after merge." }
|
|
3038
|
+
},
|
|
3039
|
+
required: ["ref"]
|
|
3040
|
+
},
|
|
3041
|
+
execute: async (args) => {
|
|
3042
|
+
const a2 = args;
|
|
3043
|
+
const cmd = buildPrMerge({ forge: resolveForge(a2), ref: a2.ref, auto: a2.auto, squash: a2.squash, deleteBranch: a2.delete_branch });
|
|
3044
|
+
return await runApeShell(cmd);
|
|
3045
|
+
}
|
|
3046
|
+
},
|
|
3047
|
+
{
|
|
3048
|
+
name: "forge.pr.status",
|
|
3049
|
+
description: "Fetch a PR's state + checks + review decision. Gated (read).",
|
|
3050
|
+
parameters: {
|
|
3051
|
+
type: "object",
|
|
3052
|
+
properties: { forge: forgeParam, remote: remoteParam, ref: { type: "string", description: "PR number/branch (GitHub) or id (Azure)." } },
|
|
3053
|
+
required: ["ref"]
|
|
3054
|
+
},
|
|
3055
|
+
execute: async (args) => {
|
|
3056
|
+
const a2 = args;
|
|
3057
|
+
return await runApeShell(buildPrStatus(resolveForge(a2), a2.ref));
|
|
3058
|
+
}
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
name: "forge.issue.get",
|
|
3062
|
+
description: "Fetch an issue (GitHub) or work-item (Azure) \u2014 title, body, labels. Gated (read). Use to turn an assigned task into a coding run.",
|
|
3063
|
+
parameters: {
|
|
3064
|
+
type: "object",
|
|
3065
|
+
properties: { forge: forgeParam, remote: remoteParam, ref: { type: "string", description: "Issue number (GitHub) or work-item id (Azure)." } },
|
|
3066
|
+
required: ["ref"]
|
|
3067
|
+
},
|
|
3068
|
+
execute: async (args) => {
|
|
3069
|
+
const a2 = args;
|
|
3070
|
+
const repo = typeof a2.remote === "string" ? a2.remote : void 0;
|
|
3071
|
+
return await runApeShell(buildIssueGet(resolveForge(a2), a2.ref, repo));
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
];
|
|
3075
|
+
function jailedRoot(envVar, fallbackName) {
|
|
3076
|
+
const home = homedir22();
|
|
3077
|
+
const raw = process2.env[envVar];
|
|
3078
|
+
const dir = raw ? resolve2(raw) : resolve2(home, fallbackName);
|
|
3079
|
+
if (dir !== home && !dir.startsWith(`${home}/`)) {
|
|
3080
|
+
throw new Error(`${envVar} (${dir}) must resolve inside the agent's home`);
|
|
3081
|
+
}
|
|
3082
|
+
return dir;
|
|
3083
|
+
}
|
|
3084
|
+
function workRoot() {
|
|
3085
|
+
return jailedRoot("OPENAPE_CODING_WORK_DIR", "work");
|
|
3086
|
+
}
|
|
3087
|
+
function reposRoot() {
|
|
3088
|
+
return jailedRoot("OPENAPE_CODING_REPOS_DIR", "repos");
|
|
3089
|
+
}
|
|
3090
|
+
var TASK_ID_RE = /^[\w.-]{1,64}$/;
|
|
3091
|
+
var BRANCH_RE2 = /^[\w./-]{1,128}$/;
|
|
3092
|
+
var URL_RE = /^(?:https:\/\/|git@)[\w@:/.-]{3,256}$/;
|
|
3093
|
+
function assertTaskId(v2) {
|
|
3094
|
+
if (typeof v2 !== "string" || !TASK_ID_RE.test(v2)) {
|
|
3095
|
+
throw new Error("task_id must match ^[a-zA-Z0-9._-]{1,64}$");
|
|
3096
|
+
}
|
|
3097
|
+
return v2;
|
|
3098
|
+
}
|
|
3099
|
+
function assertBranch2(v2) {
|
|
3100
|
+
if (typeof v2 !== "string" || !BRANCH_RE2.test(v2)) {
|
|
3101
|
+
throw new Error("branch must match ^[A-Za-z0-9._/-]{1,128}$");
|
|
3102
|
+
}
|
|
3103
|
+
return v2;
|
|
3104
|
+
}
|
|
3105
|
+
function resolveRepo(repo) {
|
|
3106
|
+
if (typeof repo !== "string" || repo === "") {
|
|
3107
|
+
throw new Error("repo must be a non-empty string (URL or path under $HOME)");
|
|
3108
|
+
}
|
|
3109
|
+
const home = homedir22();
|
|
3110
|
+
if (URL_RE.test(repo)) {
|
|
3111
|
+
const tail = repo.replace(/\.git$/, "").replace(/[/:]+$/, "");
|
|
3112
|
+
const parts = tail.split(/[/:]/).filter(Boolean).slice(-2);
|
|
3113
|
+
const base = parts.join("-").replace(/[^\w.-]/g, "");
|
|
3114
|
+
if (!base) throw new Error("could not derive a clone name from repo URL");
|
|
3115
|
+
return { source: repo, baseDir: resolve2(reposRoot(), base), isUrl: true };
|
|
3116
|
+
}
|
|
3117
|
+
const candidate = repo.startsWith("~/") ? resolve2(home, repo.slice(2)) : resolve2(home, repo);
|
|
3118
|
+
if (candidate !== home && !candidate.startsWith(`${home}/`)) {
|
|
3119
|
+
throw new Error(`repo path "${repo}" resolves outside the agent's home`);
|
|
3120
|
+
}
|
|
3121
|
+
return { source: candidate, baseDir: candidate, isUrl: false };
|
|
3122
|
+
}
|
|
3123
|
+
function worktreePathFor(taskId) {
|
|
3124
|
+
return resolve2(workRoot(), assertTaskId(taskId));
|
|
3125
|
+
}
|
|
3126
|
+
var q2 = (s2) => `'${s2}'`;
|
|
3127
|
+
function buildCreateCommand(repo, taskId, branch) {
|
|
3128
|
+
const id = assertTaskId(taskId);
|
|
3129
|
+
const br = assertBranch2(branch);
|
|
3130
|
+
const { source, baseDir, isUrl } = resolveRepo(repo);
|
|
3131
|
+
const wt = worktreePathFor(id);
|
|
3132
|
+
const clone = isUrl ? `if [ ! -d ${q2(baseDir)}/.git ]; then git clone ${q2(source)} ${q2(baseDir)}; fi` : `test -d ${q2(baseDir)}/.git`;
|
|
3133
|
+
const reset = [
|
|
3134
|
+
`git -C ${q2(baseDir)} worktree remove --force ${q2(wt)} 2>/dev/null || true`,
|
|
3135
|
+
`git -C ${q2(baseDir)} worktree prune 2>/dev/null || true`,
|
|
3136
|
+
`rm -rf ${q2(wt)} 2>/dev/null || true`
|
|
3137
|
+
].join("; ");
|
|
3138
|
+
const ghAuth = /github\.com/i.test(source) ? `git -C ${q2(baseDir)} config credential.helper '' && git -C ${q2(baseDir)} config --add credential.helper '!f() { echo username=x-access-token; echo "password=$GH_TOKEN"; }; f'` : "true";
|
|
3139
|
+
return [
|
|
3140
|
+
`mkdir -p ${q2(reposRoot())} ${q2(workRoot())}`,
|
|
3141
|
+
clone,
|
|
3142
|
+
ghAuth,
|
|
3143
|
+
`git -C ${q2(baseDir)} fetch --quiet || true`,
|
|
3144
|
+
`{ ${reset}; }`,
|
|
3145
|
+
`git -C ${q2(baseDir)} worktree add -B ${q2(br)} ${q2(wt)}`,
|
|
3146
|
+
`echo ${q2(wt)}`
|
|
3147
|
+
].join(" && ");
|
|
3148
|
+
}
|
|
3149
|
+
function buildRemoveCommand(repo, taskId) {
|
|
3150
|
+
const id = assertTaskId(taskId);
|
|
3151
|
+
const { baseDir } = resolveRepo(repo);
|
|
3152
|
+
const wt = worktreePathFor(id);
|
|
3153
|
+
return `git -C ${q2(baseDir)} worktree remove --force ${q2(wt)} && git -C ${q2(baseDir)} worktree prune`;
|
|
3154
|
+
}
|
|
3155
|
+
function buildListCommand() {
|
|
3156
|
+
return `ls -1 ${q2(workRoot())} 2>/dev/null || true`;
|
|
3157
|
+
}
|
|
3158
|
+
var gitWorktreeTools = [
|
|
3159
|
+
{
|
|
3160
|
+
name: "git.worktree",
|
|
3161
|
+
description: "Manage isolated git worktrees for coding tasks. action=create clones the repo (cached under ~/repos) and adds a fresh worktree under ~/work/<task_id> on a new branch. action=remove tears it down. action=list shows current task worktrees. Git operations go through the DDISA grant cycle (git-shape).",
|
|
3162
|
+
parameters: {
|
|
3163
|
+
type: "object",
|
|
3164
|
+
properties: {
|
|
3165
|
+
action: { type: "string", enum: ["create", "remove", "list"], description: "create | remove | list" },
|
|
3166
|
+
repo: { type: "string", description: "For create/remove: git remote URL (https/git@) or a path under $HOME to an existing clone." },
|
|
3167
|
+
task_id: { type: "string", description: "For create/remove: identifier for the worktree, ^[a-zA-Z0-9._-]{1,64}$. The worktree lands at ~/work/<task_id>." },
|
|
3168
|
+
branch: { type: "string", description: "For create: new branch name, ^[A-Za-z0-9._/-]{1,128}$." }
|
|
3169
|
+
},
|
|
3170
|
+
required: ["action"]
|
|
3171
|
+
},
|
|
3172
|
+
execute: async (args) => {
|
|
3173
|
+
const a2 = args;
|
|
3174
|
+
let cmd;
|
|
3175
|
+
if (a2.action === "create") {
|
|
3176
|
+
if (typeof a2.branch !== "string") throw new Error("branch is required for action=create");
|
|
3177
|
+
cmd = buildCreateCommand(a2.repo, assertTaskId(a2.task_id), a2.branch);
|
|
3178
|
+
} else if (a2.action === "remove") {
|
|
3179
|
+
cmd = buildRemoveCommand(a2.repo, assertTaskId(a2.task_id));
|
|
3180
|
+
} else if (a2.action === "list") {
|
|
3181
|
+
cmd = buildListCommand();
|
|
3182
|
+
} else {
|
|
3183
|
+
throw new Error("action must be one of: create, remove, list");
|
|
3184
|
+
}
|
|
3185
|
+
const res = await runApeShell(cmd);
|
|
3186
|
+
return {
|
|
3187
|
+
action: a2.action,
|
|
3188
|
+
...a2.action !== "list" ? { worktree: worktreePathFor(assertTaskId(a2.task_id)) } : {},
|
|
3189
|
+
stdout: res.stdout,
|
|
3190
|
+
stderr: res.stderr,
|
|
3191
|
+
exit_code: res.exit_code,
|
|
3192
|
+
...res.error ? { error: res.error, hint: res.hint } : {}
|
|
3193
|
+
};
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
];
|
|
3197
|
+
async function safeFetch(rawUrl, init2 = {}, maxRedirects = 5) {
|
|
3198
|
+
let current = rawUrl;
|
|
3199
|
+
for (let hop = 0; hop <= maxRedirects; hop += 1) {
|
|
3200
|
+
await assertPublicUrl(current, { allowHttp: true });
|
|
3201
|
+
const res = await fetch(current, { ...init2, redirect: "manual" });
|
|
3202
|
+
if (res.status >= 300 && res.status < 400) {
|
|
3203
|
+
const location = res.headers.get("location");
|
|
3204
|
+
if (!location) return res;
|
|
3205
|
+
current = new URL(location, current).toString();
|
|
3206
|
+
if (init2.body) init2 = { ...init2, body: void 0, method: "GET" };
|
|
3207
|
+
continue;
|
|
3208
|
+
}
|
|
3209
|
+
return res;
|
|
3210
|
+
}
|
|
3211
|
+
throw new Error(`Too many redirects (>${maxRedirects}) for ${rawUrl}`);
|
|
3212
|
+
}
|
|
3213
|
+
var MAX_BYTES2 = 1024 * 1024;
|
|
3214
|
+
var FORBIDDEN_HEADERS = /* @__PURE__ */ new Set([
|
|
3215
|
+
"host",
|
|
3216
|
+
"authorization",
|
|
3217
|
+
"cookie",
|
|
3218
|
+
"connection",
|
|
3219
|
+
"transfer-encoding",
|
|
3220
|
+
"upgrade",
|
|
3221
|
+
"proxy-authorization"
|
|
3222
|
+
]);
|
|
3223
|
+
function sanitizeHeaders(input) {
|
|
3224
|
+
if (!input || typeof input !== "object") return {};
|
|
3225
|
+
const out = {};
|
|
3226
|
+
for (const [k2, v2] of Object.entries(input)) {
|
|
3227
|
+
if (typeof v2 !== "string") continue;
|
|
3228
|
+
if (FORBIDDEN_HEADERS.has(k2.toLowerCase())) continue;
|
|
3229
|
+
out[k2] = v2;
|
|
3230
|
+
}
|
|
3231
|
+
return out;
|
|
3232
|
+
}
|
|
3233
|
+
async function readCappedBody(res) {
|
|
3234
|
+
const buf = new Uint8Array(MAX_BYTES2 + 1);
|
|
3235
|
+
let written = 0;
|
|
3236
|
+
const reader = res.body?.getReader();
|
|
3237
|
+
if (!reader) return await res.text();
|
|
3238
|
+
while (true) {
|
|
3239
|
+
const { value, done } = await reader.read();
|
|
3240
|
+
if (done) break;
|
|
3241
|
+
if (written + value.byteLength > MAX_BYTES2) {
|
|
3242
|
+
buf.set(value.subarray(0, MAX_BYTES2 - written), written);
|
|
3243
|
+
written = MAX_BYTES2;
|
|
3244
|
+
try {
|
|
3245
|
+
await reader.cancel();
|
|
3246
|
+
} catch {
|
|
3247
|
+
}
|
|
3248
|
+
break;
|
|
3249
|
+
}
|
|
3250
|
+
buf.set(value, written);
|
|
3251
|
+
written += value.byteLength;
|
|
3252
|
+
}
|
|
3253
|
+
return new TextDecoder().decode(buf.subarray(0, written));
|
|
3254
|
+
}
|
|
3255
|
+
var httpTools = [
|
|
3256
|
+
{
|
|
3257
|
+
name: "http.get",
|
|
3258
|
+
description: "GET an HTTPS URL and return the response body (capped at 1MB). Useful for reading public APIs, RSS feeds, web pages.",
|
|
3259
|
+
parameters: {
|
|
3260
|
+
type: "object",
|
|
3261
|
+
properties: {
|
|
3262
|
+
url: { type: "string", description: "Absolute HTTPS URL." },
|
|
3263
|
+
headers: { type: "object", description: "Optional headers (Host, Authorization, Cookie are stripped)." }
|
|
3264
|
+
},
|
|
3265
|
+
required: ["url"]
|
|
3266
|
+
},
|
|
3267
|
+
execute: async (args) => {
|
|
3268
|
+
const a2 = args;
|
|
3269
|
+
if (typeof a2.url !== "string") {
|
|
3270
|
+
throw new TypeError("url must be an http(s) URL");
|
|
3271
|
+
}
|
|
3272
|
+
const res = await safeFetch(a2.url, { method: "GET", headers: sanitizeHeaders(a2.headers) });
|
|
3273
|
+
const body = await readCappedBody(res);
|
|
3274
|
+
return { status: res.status, headers: Object.fromEntries(res.headers), body };
|
|
3275
|
+
}
|
|
3276
|
+
},
|
|
3277
|
+
{
|
|
3278
|
+
name: "http.post",
|
|
3279
|
+
description: "POST JSON to an HTTPS URL and return the response body (capped at 1MB).",
|
|
3280
|
+
parameters: {
|
|
3281
|
+
type: "object",
|
|
3282
|
+
properties: {
|
|
3283
|
+
url: { type: "string", description: "Absolute HTTPS URL." },
|
|
3284
|
+
body: { description: "JSON-serialisable payload." },
|
|
3285
|
+
headers: { type: "object", description: "Optional headers (Host, Authorization, Cookie are stripped)." }
|
|
3286
|
+
},
|
|
3287
|
+
required: ["url", "body"]
|
|
3288
|
+
},
|
|
3289
|
+
execute: async (args) => {
|
|
3290
|
+
const a2 = args;
|
|
3291
|
+
if (typeof a2.url !== "string") {
|
|
3292
|
+
throw new TypeError("url must be an http(s) URL");
|
|
3293
|
+
}
|
|
3294
|
+
const res = await safeFetch(a2.url, {
|
|
3295
|
+
method: "POST",
|
|
3296
|
+
headers: { "content-type": "application/json", ...sanitizeHeaders(a2.headers) },
|
|
3297
|
+
body: JSON.stringify(a2.body)
|
|
3298
|
+
});
|
|
3299
|
+
const body = await readCappedBody(res);
|
|
3300
|
+
return { status: res.status, headers: Object.fromEntries(res.headers), body };
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
];
|
|
3304
|
+
function o365(args) {
|
|
3305
|
+
try {
|
|
3306
|
+
return execFileSync("o365-cli", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
3307
|
+
} catch (err) {
|
|
3308
|
+
const e2 = err;
|
|
3309
|
+
if (e2.code === "ENOENT") {
|
|
3310
|
+
throw new Error("o365-cli is not installed on this agent host");
|
|
3311
|
+
}
|
|
3312
|
+
const stderr = typeof e2.stderr === "string" ? e2.stderr : e2.stderr?.toString("utf8");
|
|
3313
|
+
throw new Error(`o365-cli failed: ${stderr ?? e2.message ?? err}`);
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
var mailTools = [
|
|
3317
|
+
{
|
|
3318
|
+
name: "mail.list",
|
|
3319
|
+
description: "List recent inbox messages via o365-cli. Optional `unread_only` and `limit`.",
|
|
3320
|
+
parameters: {
|
|
3321
|
+
type: "object",
|
|
3322
|
+
properties: {
|
|
3323
|
+
limit: { type: "integer", minimum: 1, maximum: 100, default: 20 },
|
|
3324
|
+
unread_only: { type: "boolean", default: false }
|
|
3325
|
+
},
|
|
3326
|
+
required: []
|
|
3327
|
+
},
|
|
3328
|
+
execute: async (args) => {
|
|
3329
|
+
const a2 = args ?? {};
|
|
3330
|
+
const argv2 = ["mail", "list", "--json", "--limit", String(a2.limit ?? 20)];
|
|
3331
|
+
if (a2.unread_only) argv2.push("--unread");
|
|
3332
|
+
const out = o365(argv2);
|
|
3333
|
+
try {
|
|
3334
|
+
return JSON.parse(out);
|
|
3335
|
+
} catch {
|
|
3336
|
+
return { raw: out };
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
},
|
|
3340
|
+
{
|
|
3341
|
+
name: "mail.search",
|
|
3342
|
+
description: "Search the inbox via o365-cli using a free-form query string.",
|
|
3343
|
+
parameters: {
|
|
3344
|
+
type: "object",
|
|
3345
|
+
properties: {
|
|
3346
|
+
q: { type: "string" },
|
|
3347
|
+
limit: { type: "integer", minimum: 1, maximum: 100, default: 20 }
|
|
3348
|
+
},
|
|
3349
|
+
required: ["q"]
|
|
3350
|
+
},
|
|
3351
|
+
execute: async (args) => {
|
|
3352
|
+
const a2 = args;
|
|
3353
|
+
if (typeof a2.q !== "string" || a2.q.length === 0) throw new Error("q is required");
|
|
3354
|
+
const argv2 = ["mail", "search", a2.q, "--json", "--limit", String(a2.limit ?? 20)];
|
|
3355
|
+
const out = o365(argv2);
|
|
3356
|
+
try {
|
|
3357
|
+
return JSON.parse(out);
|
|
3358
|
+
} catch {
|
|
3359
|
+
return { raw: out };
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
}
|
|
3363
|
+
];
|
|
3364
|
+
function ape(args) {
|
|
3365
|
+
try {
|
|
3366
|
+
return execFileSync2("ape-tasks", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
3367
|
+
} catch (err) {
|
|
3368
|
+
const e2 = err;
|
|
3369
|
+
const stderr = typeof e2.stderr === "string" ? e2.stderr : e2.stderr?.toString("utf8");
|
|
3370
|
+
throw new Error(`ape-tasks failed: ${stderr ?? e2.message ?? err}`);
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
var tasksTools = [
|
|
3374
|
+
{
|
|
3375
|
+
name: "tasks.list",
|
|
3376
|
+
description: "List the owner's open ape-tasks (the user's personal task list at tasks.openape.ai).",
|
|
3377
|
+
parameters: {
|
|
3378
|
+
type: "object",
|
|
3379
|
+
properties: {
|
|
3380
|
+
status: { type: "string", enum: ["open", "doing", "done", "archived"] },
|
|
3381
|
+
team_id: { type: "string" }
|
|
3382
|
+
},
|
|
3383
|
+
required: []
|
|
3384
|
+
},
|
|
3385
|
+
execute: async (args) => {
|
|
3386
|
+
const a2 = args ?? {};
|
|
3387
|
+
const argv2 = ["list", "--json"];
|
|
3388
|
+
if (a2.status) argv2.push("--status", a2.status);
|
|
3389
|
+
if (a2.team_id) argv2.push("--team", a2.team_id);
|
|
3390
|
+
const out = ape(argv2);
|
|
3391
|
+
try {
|
|
3392
|
+
return JSON.parse(out);
|
|
3393
|
+
} catch {
|
|
3394
|
+
return { raw: out };
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
},
|
|
3398
|
+
{
|
|
3399
|
+
name: "tasks.create",
|
|
3400
|
+
description: "Create a new ape-task on the owner's task list at tasks.openape.ai.",
|
|
3401
|
+
parameters: {
|
|
3402
|
+
type: "object",
|
|
3403
|
+
properties: {
|
|
3404
|
+
title: { type: "string" },
|
|
3405
|
+
notes: { type: "string" },
|
|
3406
|
+
priority: { type: "string", enum: ["low", "med", "high"] },
|
|
3407
|
+
due_at: { type: "string", description: "ISO date or +Nh/+Nd shorthand." }
|
|
3408
|
+
},
|
|
3409
|
+
required: ["title"]
|
|
3410
|
+
},
|
|
3411
|
+
execute: async (args) => {
|
|
3412
|
+
const a2 = args;
|
|
3413
|
+
const argv2 = ["new", "--title", a2.title, "--json"];
|
|
3414
|
+
if (a2.notes) argv2.push("--notes", a2.notes);
|
|
3415
|
+
if (a2.priority) argv2.push("--priority", a2.priority);
|
|
3416
|
+
if (a2.due_at) argv2.push("--due", a2.due_at);
|
|
3417
|
+
const out = ape(argv2);
|
|
3418
|
+
try {
|
|
3419
|
+
return JSON.parse(out);
|
|
3420
|
+
} catch {
|
|
3421
|
+
return { raw: out };
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
];
|
|
3426
|
+
var timeTools = [
|
|
3427
|
+
{
|
|
3428
|
+
name: "time.now",
|
|
3429
|
+
description: "Returns the current UTC date and time as ISO 8601 plus epoch seconds. No inputs.",
|
|
3430
|
+
parameters: { type: "object", properties: {}, required: [] },
|
|
3431
|
+
execute: async () => {
|
|
3432
|
+
const now = /* @__PURE__ */ new Date();
|
|
3433
|
+
return {
|
|
3434
|
+
iso: now.toISOString(),
|
|
3435
|
+
epoch_seconds: Math.floor(now.getTime() / 1e3),
|
|
3436
|
+
timezone_offset_minutes: -now.getTimezoneOffset()
|
|
3437
|
+
};
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
];
|
|
3441
|
+
var CWD_RE = /^[\w./-]{1,256}$/;
|
|
3442
|
+
async function runVerify(cwd, command, timeoutMs) {
|
|
3443
|
+
if (typeof cwd !== "string" || !CWD_RE.test(cwd)) {
|
|
3444
|
+
throw new Error("cwd must match ^[A-Za-z0-9._/-]{1,256}$");
|
|
3445
|
+
}
|
|
3446
|
+
if (typeof command !== "string" || command.trim() === "") {
|
|
3447
|
+
throw new Error("verify command must be a non-empty string");
|
|
3448
|
+
}
|
|
3449
|
+
const res = await runApeShell(`cd '${cwd}' && ${command}`, timeoutMs);
|
|
3450
|
+
return {
|
|
3451
|
+
passed: res.exit_code === 0,
|
|
3452
|
+
exit_code: res.exit_code,
|
|
3453
|
+
stdout: res.stdout,
|
|
3454
|
+
stderr: res.stderr,
|
|
3455
|
+
...res.timed_out ? { timed_out: true } : {}
|
|
3456
|
+
};
|
|
3457
|
+
}
|
|
3458
|
+
var verifyTools = [
|
|
3459
|
+
{
|
|
3460
|
+
name: "verify",
|
|
3461
|
+
description: "Run the verification command (tests/build/lint) in a worktree and report pass/fail. The coding loop must NOT open or merge a PR when this fails. Runs through the DDISA grant cycle (same as bash). Returns { passed, exit_code, stdout, stderr }.",
|
|
3462
|
+
parameters: {
|
|
3463
|
+
type: "object",
|
|
3464
|
+
properties: {
|
|
3465
|
+
cwd: { type: "string", description: "Worktree path to run in (e.g. ~/work/issue-42)." },
|
|
3466
|
+
command: { type: "string", description: "Verification command, e.g. `pnpm test` or `npm run build && npm test`." },
|
|
3467
|
+
timeout_ms: { type: "number", description: "Wall-clock cap incl. approval wait. Default 300000." }
|
|
3468
|
+
},
|
|
3469
|
+
required: ["cwd", "command"]
|
|
3470
|
+
},
|
|
3471
|
+
execute: async (args) => {
|
|
3472
|
+
const a2 = args;
|
|
3473
|
+
const timeout = typeof a2.timeout_ms === "number" && a2.timeout_ms > 0 ? a2.timeout_ms : void 0;
|
|
3474
|
+
return await runVerify(a2.cwd, a2.command, timeout);
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
];
|
|
3478
|
+
var ALL_TOOLS = [
|
|
3479
|
+
...timeTools,
|
|
3480
|
+
...httpTools,
|
|
3481
|
+
...fileTools,
|
|
3482
|
+
...tasksTools,
|
|
3483
|
+
...mailTools,
|
|
3484
|
+
...bashTools,
|
|
3485
|
+
...gitWorktreeTools,
|
|
3486
|
+
...verifyTools,
|
|
3487
|
+
...forgeTools
|
|
3488
|
+
];
|
|
3489
|
+
var TOOLS = Object.fromEntries(
|
|
3490
|
+
ALL_TOOLS.map((t2) => [t2.name, t2])
|
|
3491
|
+
);
|
|
3492
|
+
function taskTools(names) {
|
|
3493
|
+
const out = [];
|
|
3494
|
+
const missing = [];
|
|
3495
|
+
for (const name of names) {
|
|
3496
|
+
const tool = TOOLS[name];
|
|
3497
|
+
if (!tool) missing.push(name);
|
|
3498
|
+
else out.push(tool);
|
|
3499
|
+
}
|
|
3500
|
+
if (missing.length > 0) {
|
|
3501
|
+
throw new Error(`unknown tool(s): ${missing.join(", ")}`);
|
|
3502
|
+
}
|
|
3503
|
+
return out;
|
|
3504
|
+
}
|
|
3505
|
+
function asOpenAiTools(tools) {
|
|
3506
|
+
return tools.map((t2) => ({
|
|
3507
|
+
type: "function",
|
|
3508
|
+
function: { name: wireToolName(t2.name), description: t2.description, parameters: t2.parameters }
|
|
3509
|
+
}));
|
|
3510
|
+
}
|
|
3511
|
+
function wireToolName(local) {
|
|
3512
|
+
return local.replace(/\./g, "_");
|
|
3513
|
+
}
|
|
3514
|
+
function localToolName(wire) {
|
|
3515
|
+
for (const t2 of Object.values(TOOLS)) {
|
|
3516
|
+
if (wireToolName(t2.name) === wire) return t2.name;
|
|
3517
|
+
}
|
|
3518
|
+
return wire;
|
|
3519
|
+
}
|
|
3520
|
+
function previewJson(value, max = 500) {
|
|
3521
|
+
let s2;
|
|
3522
|
+
try {
|
|
3523
|
+
s2 = JSON.stringify(value);
|
|
3524
|
+
} catch {
|
|
3525
|
+
s2 = String(value);
|
|
3526
|
+
}
|
|
3527
|
+
return s2.length > max ? `${s2.slice(0, max)}\u2026` : s2;
|
|
3528
|
+
}
|
|
3529
|
+
async function aggregateChatStream(res) {
|
|
3530
|
+
if (!res.body) throw new Error("LiteLLM streaming response had no body");
|
|
3531
|
+
const reader = res.body.getReader();
|
|
3532
|
+
const decoder = new TextDecoder();
|
|
3533
|
+
let buf = "";
|
|
3534
|
+
let content = "";
|
|
3535
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
3536
|
+
let finishReason;
|
|
3537
|
+
while (true) {
|
|
3538
|
+
const { value, done } = await reader.read();
|
|
3539
|
+
if (done) break;
|
|
3540
|
+
buf += decoder.decode(value, { stream: true });
|
|
3541
|
+
while (true) {
|
|
3542
|
+
const nl = buf.indexOf("\n");
|
|
3543
|
+
if (nl === -1) break;
|
|
3544
|
+
const line = buf.slice(0, nl).trim();
|
|
3545
|
+
buf = buf.slice(nl + 1);
|
|
3546
|
+
if (!line.startsWith("data:")) continue;
|
|
3547
|
+
const payload = line.slice(5).trim();
|
|
3548
|
+
if (!payload || payload === "[DONE]") continue;
|
|
3549
|
+
let chunk;
|
|
3550
|
+
try {
|
|
3551
|
+
chunk = JSON.parse(payload);
|
|
3552
|
+
} catch {
|
|
3553
|
+
continue;
|
|
3554
|
+
}
|
|
3555
|
+
const ch0 = chunk.choices?.[0];
|
|
3556
|
+
const delta = ch0?.delta;
|
|
3557
|
+
if (delta?.content) content += delta.content;
|
|
3558
|
+
if (delta?.tool_calls) {
|
|
3559
|
+
for (const tc of delta.tool_calls) {
|
|
3560
|
+
const idx = tc.index ?? 0;
|
|
3561
|
+
const existing = toolCalls.get(idx) ?? { id: "", type: "function", function: { name: "", arguments: "" } };
|
|
3562
|
+
if (tc.id) existing.id = tc.id;
|
|
3563
|
+
if (tc.function?.name) existing.function.name = tc.function.name;
|
|
3564
|
+
if (tc.function?.arguments) existing.function.arguments += tc.function.arguments;
|
|
3565
|
+
toolCalls.set(idx, existing);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
if (ch0?.finish_reason) finishReason = ch0.finish_reason;
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
const message = { role: "assistant", content: content || null };
|
|
3572
|
+
if (toolCalls.size > 0) message.tool_calls = Array.from(toolCalls.values());
|
|
3573
|
+
return { choices: [{ message, finish_reason: finishReason }] };
|
|
3574
|
+
}
|
|
3575
|
+
async function runLoop(opts) {
|
|
3576
|
+
const fetchFn = opts.fetchImpl ?? fetch;
|
|
3577
|
+
const trace = [];
|
|
3578
|
+
const messages = [
|
|
3579
|
+
{ role: "system", content: opts.systemPrompt },
|
|
3580
|
+
...opts.history ?? [],
|
|
3581
|
+
{ role: "user", content: opts.userMessage }
|
|
3582
|
+
];
|
|
3583
|
+
const tools = asOpenAiTools(opts.tools);
|
|
3584
|
+
for (let step = 1; step <= opts.maxSteps; step++) {
|
|
3585
|
+
const requestBody = {
|
|
3586
|
+
model: opts.config.model,
|
|
3587
|
+
messages,
|
|
3588
|
+
...tools.length > 0 ? { tools, tool_choice: "auto" } : {},
|
|
3589
|
+
...opts.streamAggregate ? { stream: true } : {}
|
|
3590
|
+
};
|
|
3591
|
+
const res = await fetchFn(`${opts.config.apiBase}/chat/completions`, {
|
|
3592
|
+
method: "POST",
|
|
3593
|
+
headers: {
|
|
3594
|
+
"authorization": `Bearer ${opts.config.apiKey}`,
|
|
3595
|
+
"content-type": "application/json"
|
|
3596
|
+
},
|
|
3597
|
+
body: JSON.stringify(requestBody)
|
|
3598
|
+
});
|
|
3599
|
+
if (!res.ok) {
|
|
3600
|
+
const text = await res.text().catch(() => "");
|
|
3601
|
+
throw new Error(`LiteLLM ${res.status}: ${text.slice(0, 500)}`);
|
|
3602
|
+
}
|
|
3603
|
+
const data = opts.streamAggregate ? await aggregateChatStream(res) : await res.json();
|
|
3604
|
+
const choice = data.choices?.[0];
|
|
3605
|
+
if (!choice) throw new Error("LiteLLM response had no choices");
|
|
3606
|
+
const assistant = choice.message;
|
|
3607
|
+
messages.push(assistant);
|
|
3608
|
+
if (assistant.content) opts.handlers?.onTextDelta?.(assistant.content);
|
|
3609
|
+
trace.push({
|
|
3610
|
+
step,
|
|
3611
|
+
type: "assistant",
|
|
3612
|
+
preview: previewJson({ content: assistant.content, tool_calls: assistant.tool_calls?.length ?? 0 })
|
|
3613
|
+
});
|
|
3614
|
+
if (!assistant.tool_calls || assistant.tool_calls.length === 0) {
|
|
3615
|
+
const result2 = {
|
|
3616
|
+
status: "ok",
|
|
3617
|
+
finalMessage: assistant.content,
|
|
3618
|
+
stepCount: step,
|
|
3619
|
+
trace
|
|
3620
|
+
};
|
|
3621
|
+
opts.handlers?.onDone?.(result2);
|
|
3622
|
+
return result2;
|
|
3623
|
+
}
|
|
3624
|
+
for (const call of assistant.tool_calls) {
|
|
3625
|
+
const wireName = call.function.name;
|
|
3626
|
+
const localName = localToolName(wireName);
|
|
3627
|
+
const tool = opts.tools.find((t2) => t2.name === localName);
|
|
3628
|
+
let parsedArgs;
|
|
3629
|
+
try {
|
|
3630
|
+
parsedArgs = JSON.parse(call.function.arguments);
|
|
3631
|
+
} catch {
|
|
3632
|
+
parsedArgs = {};
|
|
3633
|
+
}
|
|
3634
|
+
opts.handlers?.onToolCall?.({ name: localName, args: parsedArgs });
|
|
3635
|
+
trace.push({ step, type: "tool_call", tool: localName, preview: previewJson(parsedArgs) });
|
|
3636
|
+
let result2;
|
|
3637
|
+
let isError = false;
|
|
3638
|
+
if (!tool) {
|
|
3639
|
+
result2 = `unknown tool: ${localName}`;
|
|
3640
|
+
isError = true;
|
|
3641
|
+
} else {
|
|
3642
|
+
try {
|
|
3643
|
+
result2 = await tool.execute(parsedArgs);
|
|
3644
|
+
} catch (err) {
|
|
3645
|
+
result2 = err?.message ?? String(err);
|
|
3646
|
+
isError = true;
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
if (isError) {
|
|
3650
|
+
opts.handlers?.onToolError?.({ name: localName, error: String(result2) });
|
|
3651
|
+
trace.push({ step, type: "tool_error", tool: localName, preview: previewJson(result2) });
|
|
3652
|
+
} else {
|
|
3653
|
+
opts.handlers?.onToolResult?.({ name: localName, result: result2 });
|
|
3654
|
+
trace.push({ step, type: "tool_result", tool: localName, preview: previewJson(result2) });
|
|
3655
|
+
}
|
|
3656
|
+
messages.push({
|
|
3657
|
+
role: "tool",
|
|
3658
|
+
tool_call_id: call.id,
|
|
3659
|
+
name: wireToolName(localName),
|
|
3660
|
+
content: typeof result2 === "string" ? result2 : JSON.stringify(result2)
|
|
3661
|
+
});
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
const result = {
|
|
3665
|
+
status: "error",
|
|
3666
|
+
finalMessage: `max_steps (${opts.maxSteps}) reached without completion`,
|
|
3667
|
+
stepCount: opts.maxSteps,
|
|
3668
|
+
trace
|
|
3669
|
+
};
|
|
3670
|
+
opts.handlers?.onDone?.(result);
|
|
3671
|
+
return result;
|
|
3672
|
+
}
|
|
3673
|
+
var RPC_SESSION_TTL_MS = 60 * 60 * 1e3;
|
|
3674
|
+
var DEFAULT_INSTRUCTIONS = [
|
|
3675
|
+
"Work in the provided worktree. When done:",
|
|
3676
|
+
"- ensure the verification command passes (no PR on red)",
|
|
3677
|
+
"- open a PR that references this issue",
|
|
3678
|
+
"- leave risk-path / agent-judged-risky changes for human approval"
|
|
3679
|
+
].join("\n");
|
|
3680
|
+
var DIFF_CAP = 60 * 1024;
|
|
3681
|
+
var DIFF_CAP2 = 48 * 1024;
|
|
3682
|
+
var RISK_SYSTEM = [
|
|
3683
|
+
"You are a security/risk classifier for an autonomous coding agent.",
|
|
3684
|
+
"Given a diff + changed file paths, decide whether merging it WITHOUT a human is risky.",
|
|
3685
|
+
"Risky = touches authentication, authorization, secrets/credentials, payment, data migrations,",
|
|
3686
|
+
"deploy/release/CI config, cryptography, deletion of data, or anything whose failure is hard to",
|
|
3687
|
+
"reverse in production. Routine code/tests/docs/refactors are NOT risky.",
|
|
3688
|
+
'Respond ONLY as JSON: {"risky": boolean, "reason": string}.'
|
|
3689
|
+
].join(" ");
|
|
3690
|
+
var REVIEW_SYSTEM = [
|
|
3691
|
+
"You are a code reviewer for an autonomous coding agent.",
|
|
3692
|
+
"Given a PR diff, decide whether it is correct, safe, and complete enough to auto-merge.",
|
|
3693
|
+
"Approve only if you would be comfortable shipping it without further human review.",
|
|
3694
|
+
"Block if you see bugs, missing tests, security issues, or incomplete work.",
|
|
3695
|
+
'Respond ONLY as JSON: {"approved": boolean, "reason": string}.'
|
|
3696
|
+
].join(" ");
|
|
3697
|
+
|
|
3698
|
+
// ../../packages/cli-auth/dist/index.js
|
|
3699
|
+
import { ofetch } from "ofetch";
|
|
3700
|
+
import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync3, readdirSync as readdirSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
3701
|
+
import { homedir as homedir4 } from "os";
|
|
3702
|
+
import { join as join3 } from "path";
|
|
3703
|
+
import { ofetch as ofetch3 } from "ofetch";
|
|
3704
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
3705
|
+
import { sign } from "crypto";
|
|
3706
|
+
import { existsSync as existsSync22, readFileSync as readFileSync22 } from "fs";
|
|
3707
|
+
import { homedir as homedir23 } from "os";
|
|
3708
|
+
import { join as join22 } from "path";
|
|
3709
|
+
import { ofetch as ofetch2 } from "ofetch";
|
|
3710
|
+
import { Buffer as Buffer3 } from "buffer";
|
|
3711
|
+
import { createPrivateKey } from "crypto";
|
|
3712
|
+
import { ofetch as ofetch4 } from "ofetch";
|
|
3713
|
+
import { ofetch as ofetch5 } from "ofetch";
|
|
3714
|
+
function getConfigDir() {
|
|
3715
|
+
const override = process.env.OPENAPE_CLI_AUTH_HOME;
|
|
3716
|
+
if (override) return override;
|
|
3717
|
+
return join3(homedir4(), ".config", "apes");
|
|
3718
|
+
}
|
|
3719
|
+
function getAuthFile() {
|
|
3720
|
+
return join3(getConfigDir(), "auth.json");
|
|
3721
|
+
}
|
|
3722
|
+
function ensureConfigDir() {
|
|
3723
|
+
const dir = getConfigDir();
|
|
3724
|
+
if (!existsSync(dir)) {
|
|
3725
|
+
mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
function loadIdpAuth() {
|
|
3729
|
+
const file = getAuthFile();
|
|
3730
|
+
if (!existsSync(file)) return null;
|
|
3731
|
+
try {
|
|
3732
|
+
const raw = readFileSync3(file, "utf-8");
|
|
3733
|
+
if (!raw.trim()) return null;
|
|
3734
|
+
return JSON.parse(raw);
|
|
3735
|
+
} catch {
|
|
3736
|
+
return null;
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
function saveIdpAuth(auth) {
|
|
3740
|
+
ensureConfigDir();
|
|
3741
|
+
const file = getAuthFile();
|
|
3742
|
+
let extra = {};
|
|
3743
|
+
if (existsSync(file)) {
|
|
3744
|
+
try {
|
|
3745
|
+
const raw = readFileSync3(file, "utf-8");
|
|
3746
|
+
if (raw.trim()) {
|
|
3747
|
+
const prev = JSON.parse(raw);
|
|
3748
|
+
for (const key of Object.keys(prev)) {
|
|
3749
|
+
if (!(key in auth)) {
|
|
3750
|
+
extra[key] = prev[key];
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
} catch {
|
|
3755
|
+
extra = {};
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
const merged = { ...extra, ...auth };
|
|
3759
|
+
writeFileSync2(file, JSON.stringify(merged, null, 2), { mode: 384 });
|
|
3760
|
+
}
|
|
3761
|
+
var AuthError = class extends Error {
|
|
3762
|
+
status;
|
|
3763
|
+
hint;
|
|
3764
|
+
constructor(status, message, hint) {
|
|
3765
|
+
super(hint ? `${message}
|
|
3766
|
+
${hint}` : message);
|
|
3767
|
+
this.name = "AuthError";
|
|
3768
|
+
this.status = status;
|
|
3769
|
+
this.hint = hint;
|
|
3770
|
+
}
|
|
3771
|
+
};
|
|
3772
|
+
var NotLoggedInError = class extends AuthError {
|
|
3773
|
+
constructor(hint) {
|
|
3774
|
+
super(
|
|
3775
|
+
401,
|
|
3776
|
+
"Not logged in",
|
|
3777
|
+
hint ?? "Run `apes login <email>` once on this device to authenticate against the OpenApe IdP."
|
|
3778
|
+
);
|
|
3779
|
+
this.name = "NotLoggedInError";
|
|
3780
|
+
}
|
|
3781
|
+
};
|
|
3782
|
+
var OPENSSH_MAGIC = "openssh-key-v1\0";
|
|
3783
|
+
function loadEd25519PrivateKey(pem) {
|
|
3784
|
+
if (pem.includes("BEGIN OPENSSH PRIVATE KEY")) {
|
|
3785
|
+
return parseOpenSSHEd25519(pem);
|
|
3786
|
+
}
|
|
3787
|
+
return createPrivateKey(pem);
|
|
3788
|
+
}
|
|
3789
|
+
function parseOpenSSHEd25519(pem) {
|
|
3790
|
+
const b64 = pem.replace(/-----BEGIN OPENSSH PRIVATE KEY-----/, "").replace(/-----END OPENSSH PRIVATE KEY-----/, "").replace(/\s/g, "");
|
|
3791
|
+
const buf = Buffer3.from(b64, "base64");
|
|
3792
|
+
let offset = 0;
|
|
3793
|
+
const magic = buf.subarray(0, OPENSSH_MAGIC.length).toString("ascii");
|
|
3794
|
+
if (magic !== OPENSSH_MAGIC) {
|
|
3795
|
+
throw new Error("Not an OpenSSH private key");
|
|
3796
|
+
}
|
|
3797
|
+
offset += OPENSSH_MAGIC.length;
|
|
3798
|
+
const cipherLen = buf.readUInt32BE(offset);
|
|
3799
|
+
offset += 4;
|
|
3800
|
+
const cipher = buf.subarray(offset, offset + cipherLen).toString();
|
|
3801
|
+
offset += cipherLen;
|
|
3802
|
+
if (cipher !== "none") {
|
|
3803
|
+
throw new Error(`Encrypted keys not supported (cipher: ${cipher}). Decrypt first with: ssh-keygen -p -f <key>`);
|
|
3804
|
+
}
|
|
3805
|
+
const kdfLen = buf.readUInt32BE(offset);
|
|
3806
|
+
offset += 4;
|
|
3807
|
+
offset += kdfLen;
|
|
3808
|
+
const kdfOptsLen = buf.readUInt32BE(offset);
|
|
3809
|
+
offset += 4;
|
|
3810
|
+
offset += kdfOptsLen;
|
|
3811
|
+
const numKeys = buf.readUInt32BE(offset);
|
|
3812
|
+
offset += 4;
|
|
3813
|
+
if (numKeys !== 1) {
|
|
3814
|
+
throw new Error(`Expected 1 key, got ${numKeys}`);
|
|
3815
|
+
}
|
|
3816
|
+
const pubSectionLen = buf.readUInt32BE(offset);
|
|
3817
|
+
offset += 4;
|
|
3818
|
+
offset += pubSectionLen;
|
|
3819
|
+
const privSectionLen = buf.readUInt32BE(offset);
|
|
3820
|
+
offset += 4;
|
|
3821
|
+
const privSection = buf.subarray(offset, offset + privSectionLen);
|
|
3822
|
+
let pOffset = 0;
|
|
3823
|
+
const check1 = privSection.readUInt32BE(pOffset);
|
|
3824
|
+
pOffset += 4;
|
|
3825
|
+
const check2 = privSection.readUInt32BE(pOffset);
|
|
3826
|
+
pOffset += 4;
|
|
3827
|
+
if (check1 !== check2) {
|
|
3828
|
+
throw new Error("Check integers mismatch \u2014 key may be corrupted or encrypted");
|
|
3829
|
+
}
|
|
3830
|
+
const keyTypeLen = privSection.readUInt32BE(pOffset);
|
|
3831
|
+
pOffset += 4;
|
|
3832
|
+
const keyType = privSection.subarray(pOffset, pOffset + keyTypeLen).toString();
|
|
3833
|
+
pOffset += keyTypeLen;
|
|
3834
|
+
if (keyType !== "ssh-ed25519") {
|
|
3835
|
+
throw new Error(`Expected ssh-ed25519, got ${keyType}`);
|
|
3836
|
+
}
|
|
3837
|
+
const pubKeyLen = privSection.readUInt32BE(pOffset);
|
|
3838
|
+
pOffset += 4;
|
|
3839
|
+
const pubKey = privSection.subarray(pOffset, pOffset + pubKeyLen);
|
|
3840
|
+
pOffset += pubKeyLen;
|
|
3841
|
+
const privKeyLen = privSection.readUInt32BE(pOffset);
|
|
3842
|
+
pOffset += 4;
|
|
3843
|
+
const privKeyData = privSection.subarray(pOffset, pOffset + privKeyLen);
|
|
3844
|
+
const seed = privKeyData.subarray(0, 32);
|
|
3845
|
+
return createPrivateKey({
|
|
3846
|
+
key: { kty: "OKP", crv: "Ed25519", d: seed.toString("base64url"), x: pubKey.toString("base64url") },
|
|
3847
|
+
format: "jwk"
|
|
3848
|
+
});
|
|
3849
|
+
}
|
|
3850
|
+
async function getEndpoints(idp) {
|
|
3851
|
+
let disco = {};
|
|
3852
|
+
try {
|
|
3853
|
+
disco = await ofetch2(`${idp}/.well-known/openid-configuration`);
|
|
3854
|
+
} catch {
|
|
3855
|
+
}
|
|
3856
|
+
return {
|
|
3857
|
+
challenge: disco.ddisa_agent_challenge_endpoint ?? `${idp}/api/agent/challenge`,
|
|
3858
|
+
authenticate: disco.ddisa_agent_authenticate_endpoint ?? `${idp}/api/agent/authenticate`
|
|
3859
|
+
};
|
|
3860
|
+
}
|
|
3861
|
+
function resolveKeyPath(p) {
|
|
3862
|
+
if (p.startsWith("~")) return join22(homedir23(), p.slice(1));
|
|
3863
|
+
return p;
|
|
3864
|
+
}
|
|
3865
|
+
function findSigningKey(auth) {
|
|
3866
|
+
const candidates = [];
|
|
3867
|
+
if (auth.key_path) candidates.push(resolveKeyPath(auth.key_path));
|
|
3868
|
+
candidates.push(join22(homedir23(), ".ssh", "id_ed25519"));
|
|
3869
|
+
for (const p of candidates) {
|
|
3870
|
+
if (existsSync22(p)) {
|
|
3871
|
+
try {
|
|
3872
|
+
return { keyPath: p, keyContent: readFileSync22(p, "utf-8") };
|
|
3873
|
+
} catch {
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
return null;
|
|
3878
|
+
}
|
|
3879
|
+
async function refreshAgentToken(auth, now = Math.floor(Date.now() / 1e3)) {
|
|
3880
|
+
const key = findSigningKey(auth);
|
|
3881
|
+
if (!key) return null;
|
|
3882
|
+
let privateKey;
|
|
3883
|
+
try {
|
|
3884
|
+
privateKey = loadEd25519PrivateKey(key.keyContent);
|
|
3885
|
+
} catch {
|
|
3886
|
+
return null;
|
|
3887
|
+
}
|
|
3888
|
+
let endpoints;
|
|
3889
|
+
try {
|
|
3890
|
+
endpoints = await getEndpoints(auth.idp);
|
|
3891
|
+
} catch {
|
|
3892
|
+
return null;
|
|
3893
|
+
}
|
|
3894
|
+
let challenge;
|
|
3895
|
+
try {
|
|
3896
|
+
const resp = await ofetch2(endpoints.challenge, {
|
|
3897
|
+
method: "POST",
|
|
3898
|
+
headers: { "Content-Type": "application/json" },
|
|
3899
|
+
body: { agent_id: auth.email }
|
|
3900
|
+
});
|
|
3901
|
+
challenge = resp.challenge;
|
|
3902
|
+
} catch {
|
|
3903
|
+
return null;
|
|
3904
|
+
}
|
|
3905
|
+
let signature;
|
|
3906
|
+
try {
|
|
3907
|
+
signature = sign(null, Buffer2.from(challenge), privateKey).toString("base64");
|
|
3908
|
+
} catch {
|
|
3909
|
+
return null;
|
|
3910
|
+
}
|
|
3911
|
+
let authResp;
|
|
3912
|
+
try {
|
|
3913
|
+
authResp = await ofetch2(endpoints.authenticate, {
|
|
3914
|
+
method: "POST",
|
|
3915
|
+
headers: { "Content-Type": "application/json" },
|
|
3916
|
+
body: { agent_id: auth.email, challenge, signature }
|
|
3917
|
+
});
|
|
3918
|
+
} catch {
|
|
3919
|
+
return null;
|
|
3920
|
+
}
|
|
3921
|
+
return {
|
|
3922
|
+
...auth,
|
|
3923
|
+
access_token: authResp.token,
|
|
3924
|
+
expires_at: now + (authResp.expires_in || 3600),
|
|
3925
|
+
key_path: auth.key_path ?? key.keyPath
|
|
3926
|
+
};
|
|
3927
|
+
}
|
|
3928
|
+
var EXPIRY_SKEW_SECONDS = 30;
|
|
3929
|
+
async function getTokenEndpoint(idp) {
|
|
3930
|
+
try {
|
|
3931
|
+
const disco = await ofetch3(`${idp}/.well-known/openid-configuration`);
|
|
3932
|
+
if (disco.token_endpoint) return disco.token_endpoint;
|
|
3933
|
+
} catch {
|
|
3934
|
+
}
|
|
3935
|
+
return `${idp}/token`;
|
|
3936
|
+
}
|
|
3937
|
+
async function ensureFreshIdpAuth(now = Math.floor(Date.now() / 1e3)) {
|
|
3938
|
+
const auth = loadIdpAuth();
|
|
3939
|
+
if (!auth) {
|
|
3940
|
+
throw new NotLoggedInError();
|
|
3941
|
+
}
|
|
3942
|
+
if (auth.expires_at > now + EXPIRY_SKEW_SECONDS) {
|
|
3943
|
+
return auth;
|
|
3944
|
+
}
|
|
3945
|
+
if (!auth.refresh_token) {
|
|
3946
|
+
const refreshed = await refreshAgentToken(auth, now);
|
|
3947
|
+
if (refreshed) {
|
|
3948
|
+
saveIdpAuth(refreshed);
|
|
3949
|
+
return refreshed;
|
|
3950
|
+
}
|
|
3951
|
+
throw new NotLoggedInError(
|
|
3952
|
+
`IdP token expired at ${new Date(auth.expires_at * 1e3).toISOString()} and no refresh_token is stored. Run \`apes login\` again.`
|
|
3953
|
+
);
|
|
3954
|
+
}
|
|
3955
|
+
const tokenEndpoint = await getTokenEndpoint(auth.idp);
|
|
3956
|
+
const body = new URLSearchParams({
|
|
3957
|
+
grant_type: "refresh_token",
|
|
3958
|
+
refresh_token: auth.refresh_token
|
|
3959
|
+
});
|
|
3960
|
+
let response;
|
|
3961
|
+
try {
|
|
3962
|
+
response = await ofetch3(tokenEndpoint, {
|
|
3963
|
+
method: "POST",
|
|
3964
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
3965
|
+
body: body.toString()
|
|
3966
|
+
});
|
|
3967
|
+
} catch (err) {
|
|
3968
|
+
const status = err.status ?? err.statusCode ?? 0;
|
|
3969
|
+
if (status === 400 || status === 401) {
|
|
3970
|
+
saveIdpAuth({ ...auth, refresh_token: void 0 });
|
|
3971
|
+
throw new NotLoggedInError(
|
|
3972
|
+
`Refresh token rejected by ${auth.idp}. Run \`apes login\` again.`
|
|
3973
|
+
);
|
|
3974
|
+
}
|
|
3975
|
+
throw new AuthError(
|
|
3976
|
+
0,
|
|
3977
|
+
`Network error refreshing IdP token at ${tokenEndpoint}`,
|
|
3978
|
+
`Underlying: ${err.message ?? err}`
|
|
3979
|
+
);
|
|
3980
|
+
}
|
|
3981
|
+
if (!response.access_token) {
|
|
3982
|
+
throw new AuthError(0, `IdP refresh response missing access_token (endpoint: ${tokenEndpoint})`);
|
|
3983
|
+
}
|
|
3984
|
+
const next = {
|
|
3985
|
+
...auth,
|
|
3986
|
+
access_token: response.access_token,
|
|
3987
|
+
refresh_token: response.refresh_token ?? auth.refresh_token,
|
|
3988
|
+
expires_at: now + (response.expires_in ?? 3600)
|
|
3989
|
+
};
|
|
3990
|
+
saveIdpAuth(next);
|
|
3991
|
+
return next;
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
// src/identity.ts
|
|
3995
|
+
import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
|
|
3996
|
+
import { homedir as homedir6 } from "os";
|
|
3997
|
+
import { join as join4 } from "path";
|
|
3998
|
+
function authPath() {
|
|
3999
|
+
return join4(homedir6(), ".config", "apes", "auth.json");
|
|
4000
|
+
}
|
|
4001
|
+
function readAgentIdentity() {
|
|
4002
|
+
const path = authPath();
|
|
4003
|
+
if (!existsSync3(path)) {
|
|
4004
|
+
throw new Error(`agent identity not found at ${path}`);
|
|
4005
|
+
}
|
|
4006
|
+
const raw = readFileSync4(path, "utf8");
|
|
4007
|
+
const parsed = JSON.parse(raw);
|
|
4008
|
+
if (!parsed.email) throw new Error(`auth.json at ${path} missing 'email'`);
|
|
4009
|
+
if (!parsed.idp) throw new Error(`auth.json at ${path} missing 'idp'`);
|
|
4010
|
+
const ownerEmail = parsed.owner_email ?? process.env.OPENAPE_OWNER_EMAIL;
|
|
4011
|
+
if (!ownerEmail) {
|
|
4012
|
+
throw new Error(
|
|
4013
|
+
`auth.json at ${path} missing 'owner_email' and no OPENAPE_OWNER_EMAIL env var set \u2014 re-spawn the agent with @openape/apes >= 0.28 or set OPENAPE_OWNER_EMAIL in the container env`
|
|
4014
|
+
);
|
|
4015
|
+
}
|
|
4016
|
+
return { email: parsed.email, ownerEmail, idp: parsed.idp };
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
// src/service-bridge.ts
|
|
4020
|
+
function textArtifact(text) {
|
|
4021
|
+
return { artifactId: randomUUID(), parts: [{ kind: "text", text }] };
|
|
4022
|
+
}
|
|
4023
|
+
function parseTaskSpec(task) {
|
|
4024
|
+
const dataPart = task.history[0]?.parts.find((p) => p.kind === "data");
|
|
4025
|
+
const data = dataPart?.data;
|
|
4026
|
+
if (!data || typeof data.systemPrompt !== "string" || typeof data.userMessage !== "string")
|
|
4027
|
+
throw new Error("task payload missing systemPrompt/userMessage");
|
|
4028
|
+
return {
|
|
4029
|
+
systemPrompt: data.systemPrompt,
|
|
4030
|
+
userMessage: data.userMessage,
|
|
4031
|
+
tools: Array.isArray(data.tools) ? data.tools.filter((t2) => typeof t2 === "string") : void 0,
|
|
4032
|
+
model: typeof data.model === "string" ? data.model : void 0,
|
|
4033
|
+
maxSteps: typeof data.maxSteps === "number" ? data.maxSteps : void 0
|
|
4034
|
+
};
|
|
4035
|
+
}
|
|
4036
|
+
async function getNextTask(deps) {
|
|
4037
|
+
const res = await deps.fetchImpl(`${deps.spBaseUrl}/api/agent/tasks/next`, {
|
|
4038
|
+
method: "POST",
|
|
4039
|
+
headers: { "authorization": await deps.bearer(), "content-type": "application/json" }
|
|
4040
|
+
});
|
|
4041
|
+
if (!res.ok)
|
|
4042
|
+
throw new Error(`GetNextTask HTTP ${res.status}`);
|
|
4043
|
+
const body = await res.json();
|
|
4044
|
+
return body.task ?? null;
|
|
4045
|
+
}
|
|
4046
|
+
async function resolveTask(deps, id, state, artifact) {
|
|
4047
|
+
const res = await deps.fetchImpl(`${deps.spBaseUrl}/api/agent/tasks/resolve`, {
|
|
4048
|
+
method: "POST",
|
|
4049
|
+
headers: { "authorization": await deps.bearer(), "content-type": "application/json" },
|
|
4050
|
+
body: JSON.stringify({ id, state, artifact })
|
|
4051
|
+
});
|
|
4052
|
+
if (!res.ok)
|
|
4053
|
+
throw new Error(`ResolveTask HTTP ${res.status}`);
|
|
4054
|
+
}
|
|
4055
|
+
async function pollOnce(deps) {
|
|
4056
|
+
const task = await getNextTask(deps);
|
|
4057
|
+
if (!task)
|
|
4058
|
+
return "idle";
|
|
4059
|
+
let state;
|
|
4060
|
+
let artifact;
|
|
4061
|
+
try {
|
|
4062
|
+
const spec = parseTaskSpec(task);
|
|
4063
|
+
const result = await deps.runLoopImpl({
|
|
4064
|
+
config: spec.model ? { ...deps.config, model: spec.model } : deps.config,
|
|
4065
|
+
userMessage: spec.userMessage,
|
|
4066
|
+
systemPrompt: spec.systemPrompt,
|
|
4067
|
+
tools: taskTools(spec.tools ?? []),
|
|
4068
|
+
maxSteps: spec.maxSteps ?? deps.maxSteps
|
|
4069
|
+
});
|
|
4070
|
+
if (result.status === "error")
|
|
4071
|
+
throw new Error(result.finalMessage ?? "runLoop returned status error");
|
|
4072
|
+
state = "completed";
|
|
4073
|
+
artifact = textArtifact(result.finalMessage ?? "");
|
|
4074
|
+
} catch (err) {
|
|
4075
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4076
|
+
deps.log(`task ${task.id} failed: ${msg}`);
|
|
4077
|
+
state = "failed";
|
|
4078
|
+
artifact = textArtifact(msg);
|
|
4079
|
+
}
|
|
4080
|
+
await resolveTask(deps, task.id, state, artifact);
|
|
4081
|
+
return "task";
|
|
4082
|
+
}
|
|
4083
|
+
function readServiceConfig() {
|
|
4084
|
+
const spBaseUrl = process3.env.OPENAPE_SP_BASE_URL?.replace(/\/$/, "");
|
|
4085
|
+
if (!spBaseUrl)
|
|
4086
|
+
throw new Error("OPENAPE_SP_BASE_URL is not set \u2014 the SP backend this service-agent serves.");
|
|
4087
|
+
const apiKey = process3.env.LITELLM_API_KEY ?? process3.env.LITELLM_MASTER_KEY;
|
|
4088
|
+
if (!apiKey)
|
|
4089
|
+
throw new Error("LITELLM_API_KEY (or LITELLM_MASTER_KEY) must be set.");
|
|
4090
|
+
const model = process3.env.APE_SERVICE_MODEL;
|
|
4091
|
+
if (!model)
|
|
4092
|
+
throw new Error("APE_SERVICE_MODEL is not set (e.g. gpt-5.5).");
|
|
4093
|
+
const poll = process3.env.APE_SERVICE_POLL_MS ? Number.parseInt(process3.env.APE_SERVICE_POLL_MS, 10) : 2e3;
|
|
4094
|
+
const steps = process3.env.APE_SERVICE_MAX_STEPS ? Number.parseInt(process3.env.APE_SERVICE_MAX_STEPS, 10) : 10;
|
|
4095
|
+
return {
|
|
4096
|
+
spBaseUrl,
|
|
4097
|
+
apiBase: (process3.env.LITELLM_BASE_URL ?? "http://127.0.0.1:4001/v1").replace(/\/$/, ""),
|
|
4098
|
+
apiKey,
|
|
4099
|
+
model,
|
|
4100
|
+
pollIntervalMs: Number.isFinite(poll) && poll > 0 ? poll : 2e3,
|
|
4101
|
+
maxSteps: Number.isFinite(steps) && steps > 0 ? steps : 10
|
|
4102
|
+
};
|
|
4103
|
+
}
|
|
4104
|
+
function log(line) {
|
|
4105
|
+
process3.stderr.write(`${(/* @__PURE__ */ new Date()).toISOString()} [service] ${line}
|
|
4106
|
+
`);
|
|
4107
|
+
}
|
|
4108
|
+
function sleep(ms) {
|
|
4109
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
4110
|
+
}
|
|
4111
|
+
async function runService() {
|
|
4112
|
+
const cfg = readServiceConfig();
|
|
4113
|
+
const id = readAgentIdentity();
|
|
4114
|
+
const deps = {
|
|
4115
|
+
spBaseUrl: cfg.spBaseUrl,
|
|
4116
|
+
bearer: async () => `Bearer ${(await ensureFreshIdpAuth()).access_token}`,
|
|
4117
|
+
fetchImpl: fetch,
|
|
4118
|
+
runLoopImpl: runLoop,
|
|
4119
|
+
config: { apiBase: cfg.apiBase, apiKey: cfg.apiKey, model: cfg.model },
|
|
4120
|
+
maxSteps: cfg.maxSteps,
|
|
4121
|
+
log
|
|
4122
|
+
};
|
|
4123
|
+
log(`service-agent ${id.email} \u2192 SP ${cfg.spBaseUrl}, LLM ${cfg.apiBase}, model ${cfg.model}, poll ${cfg.pollIntervalMs}ms`);
|
|
4124
|
+
for (; ; ) {
|
|
4125
|
+
try {
|
|
4126
|
+
if (await pollOnce(deps) === "idle")
|
|
4127
|
+
await sleep(cfg.pollIntervalMs);
|
|
4128
|
+
} catch (err) {
|
|
4129
|
+
log(`poll error: ${err instanceof Error ? err.message : String(err)}`);
|
|
4130
|
+
await sleep(cfg.pollIntervalMs);
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4135
|
+
// src/service-bridge-main.ts
|
|
4136
|
+
runService().catch((err) => {
|
|
4137
|
+
process4.stderr.write(`fatal: ${err instanceof Error ? err.message : String(err)}
|
|
4138
|
+
`);
|
|
4139
|
+
process4.exit(1);
|
|
4140
|
+
});
|