@wormw/zcode-cli 4.0.0-mirror.1 → 4.0.0-mirror.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/agent/node_modules/@zcode/tui/dist/index.js +5 -52248
- package/agent/node_modules/@zcode/tui/dist/index.upstream.js +52249 -0
- package/agent/node_modules/@zcode/tui/dist/osc7501-tui-wrapper.mjs +391 -0
- package/agent/zcode.cjs +23 -23
- package/bin/zcode.mjs +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
// 为 @zcode/tui 的 runTui 包装一层 OSC 7501(Program Status Protocol)状态上报,
|
|
2
|
+
// 让 herdr-core / 支持 OSC 7501 的终端在不修改上游源码的前提下感知 Agent 生命周期状态。
|
|
3
|
+
|
|
4
|
+
const OSC_7501_PREFIX = "\x1b]7501;";
|
|
5
|
+
const OSC_7501_ST = "\x1b\\";
|
|
6
|
+
const DEFAULT_APP_NAME = "zcode";
|
|
7
|
+
const MAX_APP_BYTES = 32;
|
|
8
|
+
const MAX_MSG_BYTES = 180;
|
|
9
|
+
const MAX_REMEMBERED_EVENT_IDS = 2048;
|
|
10
|
+
|
|
11
|
+
const AUTO_BYPASSED_APPROVAL_TOOLS = new Set(["CreateWorkflow", "AmendWorkflow"]);
|
|
12
|
+
const TOOL_EVENTS = new Set([
|
|
13
|
+
"tool_call_scheduled",
|
|
14
|
+
"tool_call_started",
|
|
15
|
+
"tool_call_progress",
|
|
16
|
+
"tool_call_result",
|
|
17
|
+
"tool_call_error",
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
function isOsc7501Disabled(env) {
|
|
21
|
+
const raw = env?.ZCODE_OSC7501;
|
|
22
|
+
if (typeof raw !== "string") return false;
|
|
23
|
+
const normalized = raw.trim().toLowerCase();
|
|
24
|
+
return normalized === "0" || normalized === "false" || normalized === "off";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function sanitizeAppName(raw) {
|
|
28
|
+
if (typeof raw !== "string") return DEFAULT_APP_NAME;
|
|
29
|
+
const cleaned = raw.trim().replace(/[^A-Za-z0-9_.+-]/g, "");
|
|
30
|
+
if (!cleaned) return DEFAULT_APP_NAME;
|
|
31
|
+
return cleaned.slice(0, MAX_APP_BYTES);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function encodeMessageBase64(text) {
|
|
35
|
+
if (typeof text !== "string") return undefined;
|
|
36
|
+
const normalized = text.replace(/\s+/g, " ").trim();
|
|
37
|
+
if (!normalized) return undefined;
|
|
38
|
+
let bytes = Buffer.from(normalized, "utf8");
|
|
39
|
+
if (bytes.byteLength > MAX_MSG_BYTES) {
|
|
40
|
+
// 按字符逐步截断,避免把多字节 UTF-8 字符从中间切碎。
|
|
41
|
+
let truncated = "";
|
|
42
|
+
for (const ch of normalized) {
|
|
43
|
+
const next = truncated + ch;
|
|
44
|
+
if (Buffer.byteLength(next, "utf8") > MAX_MSG_BYTES - 1) break;
|
|
45
|
+
truncated = next;
|
|
46
|
+
}
|
|
47
|
+
bytes = Buffer.from(`${truncated}…`, "utf8");
|
|
48
|
+
}
|
|
49
|
+
return bytes.toString("base64");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function formatOsc7501({ state, app = DEFAULT_APP_NAME, kind, msg } = {}) {
|
|
53
|
+
if (state === "clear") {
|
|
54
|
+
return `${OSC_7501_PREFIX}state=clear${OSC_7501_ST}`;
|
|
55
|
+
}
|
|
56
|
+
const fields = [`state=${state}`];
|
|
57
|
+
if (state === "blocked" && (kind === "permission" || kind === "question" || kind === "auth")) {
|
|
58
|
+
fields.push(`kind=${kind}`);
|
|
59
|
+
}
|
|
60
|
+
fields.push(`app=${sanitizeAppName(app)}`);
|
|
61
|
+
const encodedMsg = encodeMessageBase64(msg);
|
|
62
|
+
if (encodedMsg) {
|
|
63
|
+
fields.push(`msg=${encodedMsg}`);
|
|
64
|
+
}
|
|
65
|
+
return `${OSC_7501_PREFIX}${fields.join(":")}${OSC_7501_ST}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function asRecord(value) {
|
|
69
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function stringField(record, key) {
|
|
73
|
+
const value = record?.[key];
|
|
74
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function formatBlockedMessage(request, kind) {
|
|
78
|
+
const req = asRecord(request);
|
|
79
|
+
const input = asRecord(req?.input);
|
|
80
|
+
if (kind === "question") {
|
|
81
|
+
const questions = Array.isArray(input?.questions) ? input.questions : undefined;
|
|
82
|
+
const first = asRecord(questions?.[0]);
|
|
83
|
+
return stringField(first, "question") ?? stringField(first, "header") ?? "Clarification needed";
|
|
84
|
+
}
|
|
85
|
+
const toolName = stringField(req, "toolName") ?? "tool";
|
|
86
|
+
const detail =
|
|
87
|
+
stringField(input, "command") ??
|
|
88
|
+
stringField(input, "file_path") ??
|
|
89
|
+
stringField(input, "path") ??
|
|
90
|
+
stringField(input, "url") ??
|
|
91
|
+
stringField(req, "reason");
|
|
92
|
+
return detail ? `${toolName}: ${detail}` : toolName;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function formatErrorMessage(payload) {
|
|
96
|
+
const rec = asRecord(payload);
|
|
97
|
+
const err = asRecord(rec?.error);
|
|
98
|
+
return (
|
|
99
|
+
stringField(err, "message") ??
|
|
100
|
+
stringField(rec, "message") ??
|
|
101
|
+
stringField(rec, "reason") ??
|
|
102
|
+
(typeof rec?.error === "string" && rec.error.trim() ? rec.error.trim() : undefined)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function isAbortError(error) {
|
|
107
|
+
if (!error || typeof error !== "object") return false;
|
|
108
|
+
return error.name === "AbortError" || error.code === "ABORT_ERR";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isMainSessionEvent(event, mainSessionId) {
|
|
112
|
+
const payload = asRecord(event?.payload);
|
|
113
|
+
if (TOOL_EVENTS.has(event?.type) && payload?.source === "subagent") {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (!mainSessionId) return true;
|
|
117
|
+
const eventSessionId = typeof event?.sessionId === "string" ? event.sessionId : undefined;
|
|
118
|
+
if (eventSessionId === undefined) return true;
|
|
119
|
+
return eventSessionId === mainSessionId;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function rememberEventId(seen, event) {
|
|
123
|
+
const id = typeof event?.id === "string" && event.id.length > 0 ? event.id : undefined;
|
|
124
|
+
if (id === undefined) return true;
|
|
125
|
+
if (seen.has(id)) return false;
|
|
126
|
+
seen.add(id);
|
|
127
|
+
if (seen.size > MAX_REMEMBERED_EVENT_IDS) {
|
|
128
|
+
const excess = seen.size - MAX_REMEMBERED_EVENT_IDS;
|
|
129
|
+
let removed = 0;
|
|
130
|
+
for (const oldId of seen) {
|
|
131
|
+
seen.delete(oldId);
|
|
132
|
+
removed += 1;
|
|
133
|
+
if (removed >= excess) break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function wrapRunTuiWithOsc7501(upstreamRunTui, { env = process.env, proc = process } = {}) {
|
|
140
|
+
return async function runTuiWithOsc7501(options) {
|
|
141
|
+
const stdout = options?.stdout;
|
|
142
|
+
if (
|
|
143
|
+
isOsc7501Disabled(env) ||
|
|
144
|
+
!stdout ||
|
|
145
|
+
!stdout.isTTY ||
|
|
146
|
+
typeof stdout.write !== "function"
|
|
147
|
+
) {
|
|
148
|
+
return await upstreamRunTui(options);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const app = sanitizeAppName(env?.ZCODE_OSC7501_APP);
|
|
152
|
+
let closed = false;
|
|
153
|
+
let cleared = false;
|
|
154
|
+
let turnActive = false;
|
|
155
|
+
let compacting = false;
|
|
156
|
+
let authBlocked = Boolean(options.loginRequired);
|
|
157
|
+
let lastSequence;
|
|
158
|
+
const pendingApprovals = [];
|
|
159
|
+
const seenEventIds = new Set();
|
|
160
|
+
|
|
161
|
+
const writeSequence = (sequence) => {
|
|
162
|
+
if (sequence === lastSequence) return;
|
|
163
|
+
lastSequence = sequence;
|
|
164
|
+
try {
|
|
165
|
+
stdout.write(sequence);
|
|
166
|
+
} catch {
|
|
167
|
+
// 终端流在异常关闭阶段可能已不可写;状态上报绝不能影响主流程退出。
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const syncStatus = (idleState = "idle", idleMsg) => {
|
|
172
|
+
if (closed) return;
|
|
173
|
+
if (pendingApprovals.length > 0) {
|
|
174
|
+
const current = pendingApprovals[0];
|
|
175
|
+
writeSequence(
|
|
176
|
+
formatOsc7501({
|
|
177
|
+
state: "blocked",
|
|
178
|
+
kind: current.kind,
|
|
179
|
+
app,
|
|
180
|
+
msg: current.msg,
|
|
181
|
+
}),
|
|
182
|
+
);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (turnActive || compacting) {
|
|
186
|
+
writeSequence(formatOsc7501({ state: "working", app }));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (authBlocked) {
|
|
190
|
+
writeSequence(formatOsc7501({ state: "blocked", kind: "auth", app }));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
writeSequence(formatOsc7501({ state: idleState, app, msg: idleMsg }));
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const emitClearOnce = () => {
|
|
197
|
+
if (cleared) return;
|
|
198
|
+
cleared = true;
|
|
199
|
+
closed = true;
|
|
200
|
+
lastSequence = undefined;
|
|
201
|
+
writeSequence(formatOsc7501({ state: "clear", app }));
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const handleSessionEvent = (event) => {
|
|
205
|
+
if (closed || !event || typeof event !== "object") return;
|
|
206
|
+
if (!isMainSessionEvent(event, options.getMainSessionId?.())) return;
|
|
207
|
+
if (!rememberEventId(seenEventIds, event)) return;
|
|
208
|
+
|
|
209
|
+
const payload = asRecord(event.payload);
|
|
210
|
+
switch (event.type) {
|
|
211
|
+
case "turn_started":
|
|
212
|
+
turnActive = true;
|
|
213
|
+
syncStatus();
|
|
214
|
+
break;
|
|
215
|
+
case "turn_complete":
|
|
216
|
+
turnActive = false;
|
|
217
|
+
syncStatus("done");
|
|
218
|
+
break;
|
|
219
|
+
case "turn_error":
|
|
220
|
+
case "model_error":
|
|
221
|
+
if (stringField(payload, "turnPhase") === "compact") {
|
|
222
|
+
compacting = false;
|
|
223
|
+
syncStatus(turnActive ? undefined : "error", formatErrorMessage(payload));
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
turnActive = false;
|
|
227
|
+
syncStatus("error", formatErrorMessage(payload));
|
|
228
|
+
break;
|
|
229
|
+
case "compact_started":
|
|
230
|
+
compacting = true;
|
|
231
|
+
syncStatus();
|
|
232
|
+
break;
|
|
233
|
+
case "compact_completed":
|
|
234
|
+
compacting = false;
|
|
235
|
+
syncStatus("idle");
|
|
236
|
+
break;
|
|
237
|
+
case "compact_failed":
|
|
238
|
+
compacting = false;
|
|
239
|
+
syncStatus("error", formatErrorMessage(payload));
|
|
240
|
+
break;
|
|
241
|
+
case "session_created":
|
|
242
|
+
case "session_resumed":
|
|
243
|
+
case "session_forked":
|
|
244
|
+
if (!turnActive && !compacting) {
|
|
245
|
+
syncStatus("idle");
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
default:
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const reconcileLoginFlag = (result) => {
|
|
254
|
+
if (!result || typeof result !== "object" || typeof result.loginRequired !== "boolean") {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const nextAuthBlocked = result.loginRequired;
|
|
258
|
+
if (nextAuthBlocked === authBlocked) return;
|
|
259
|
+
authBlocked = nextAuthBlocked;
|
|
260
|
+
if (!turnActive && !compacting && pendingApprovals.length === 0) {
|
|
261
|
+
syncStatus("idle");
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const wrapPerTurnOptions = (callOptions) => {
|
|
266
|
+
if (!callOptions || typeof callOptions !== "object") return callOptions;
|
|
267
|
+
const upstreamOnEvent = callOptions.onEvent;
|
|
268
|
+
return {
|
|
269
|
+
...callOptions,
|
|
270
|
+
onEvent: (event) => {
|
|
271
|
+
handleSessionEvent(event);
|
|
272
|
+
return upstreamOnEvent?.(event);
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const wrappedOptions = {
|
|
278
|
+
...options,
|
|
279
|
+
...(options.loadStartupOptions
|
|
280
|
+
? {
|
|
281
|
+
loadStartupOptions: async () => {
|
|
282
|
+
const startup = await options.loadStartupOptions();
|
|
283
|
+
authBlocked = Boolean(startup?.loginRequired);
|
|
284
|
+
syncStatus("idle");
|
|
285
|
+
return startup;
|
|
286
|
+
},
|
|
287
|
+
}
|
|
288
|
+
: {}),
|
|
289
|
+
...(options.subscribeSessionEvents
|
|
290
|
+
? {
|
|
291
|
+
subscribeSessionEvents: (sink) =>
|
|
292
|
+
options.subscribeSessionEvents((event) => {
|
|
293
|
+
handleSessionEvent(event);
|
|
294
|
+
sink(event);
|
|
295
|
+
}),
|
|
296
|
+
}
|
|
297
|
+
: {}),
|
|
298
|
+
...(options.registerPermissionRequester
|
|
299
|
+
? {
|
|
300
|
+
registerPermissionRequester: (requestPermission) =>
|
|
301
|
+
options.registerPermissionRequester(async (request, requestOptions) => {
|
|
302
|
+
if (requestOptions?.signal?.aborted) {
|
|
303
|
+
return await requestPermission(request, requestOptions);
|
|
304
|
+
}
|
|
305
|
+
const toolName = typeof request?.toolName === "string" ? request.toolName : "";
|
|
306
|
+
if (AUTO_BYPASSED_APPROVAL_TOOLS.has(toolName)) {
|
|
307
|
+
return await requestPermission(request, requestOptions);
|
|
308
|
+
}
|
|
309
|
+
const kind = toolName === "AskUserQuestion" ? "question" : "permission";
|
|
310
|
+
const entry = { kind, msg: formatBlockedMessage(request, kind) };
|
|
311
|
+
pendingApprovals.push(entry);
|
|
312
|
+
syncStatus();
|
|
313
|
+
try {
|
|
314
|
+
return await requestPermission(request, requestOptions);
|
|
315
|
+
} finally {
|
|
316
|
+
const index = pendingApprovals.indexOf(entry);
|
|
317
|
+
if (index !== -1) pendingApprovals.splice(index, 1);
|
|
318
|
+
syncStatus();
|
|
319
|
+
}
|
|
320
|
+
}),
|
|
321
|
+
}
|
|
322
|
+
: {}),
|
|
323
|
+
...(typeof options.submitPrompt === "function"
|
|
324
|
+
? {
|
|
325
|
+
submitPrompt: async (prompt, callOptions) => {
|
|
326
|
+
try {
|
|
327
|
+
const result = await options.submitPrompt(prompt, wrapPerTurnOptions(callOptions));
|
|
328
|
+
if (turnActive) {
|
|
329
|
+
turnActive = false;
|
|
330
|
+
syncStatus("done");
|
|
331
|
+
}
|
|
332
|
+
reconcileLoginFlag(result);
|
|
333
|
+
return result;
|
|
334
|
+
} catch (error) {
|
|
335
|
+
if (turnActive) {
|
|
336
|
+
turnActive = false;
|
|
337
|
+
if (isAbortError(error) || callOptions?.abortSignal?.aborted) {
|
|
338
|
+
syncStatus("idle");
|
|
339
|
+
} else {
|
|
340
|
+
syncStatus("error", error instanceof Error ? error.message : String(error));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
}
|
|
347
|
+
: {}),
|
|
348
|
+
...(typeof options.sendInput === "function"
|
|
349
|
+
? {
|
|
350
|
+
sendInput: async (input, callOptions) => {
|
|
351
|
+
try {
|
|
352
|
+
const result = await options.sendInput(input, wrapPerTurnOptions(callOptions));
|
|
353
|
+
if (result && typeof result === "object" && result.kind === "started_turn") {
|
|
354
|
+
if (turnActive) {
|
|
355
|
+
turnActive = false;
|
|
356
|
+
syncStatus("done");
|
|
357
|
+
}
|
|
358
|
+
reconcileLoginFlag(result.result);
|
|
359
|
+
} else if (
|
|
360
|
+
result &&
|
|
361
|
+
typeof result === "object" &&
|
|
362
|
+
result.kind === "command_result"
|
|
363
|
+
) {
|
|
364
|
+
reconcileLoginFlag(result.result);
|
|
365
|
+
}
|
|
366
|
+
return result;
|
|
367
|
+
} catch (error) {
|
|
368
|
+
if (turnActive && (isAbortError(error) || callOptions?.abortSignal?.aborted)) {
|
|
369
|
+
turnActive = false;
|
|
370
|
+
syncStatus("idle");
|
|
371
|
+
}
|
|
372
|
+
throw error;
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
}
|
|
376
|
+
: {}),
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
if (!options.loadStartupOptions) {
|
|
380
|
+
syncStatus("idle");
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
proc.once("exit", emitClearOnce);
|
|
384
|
+
try {
|
|
385
|
+
return await upstreamRunTui(wrappedOptions);
|
|
386
|
+
} finally {
|
|
387
|
+
proc.off("exit", emitClearOnce);
|
|
388
|
+
emitClearOnce();
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
}
|
package/agent/zcode.cjs
CHANGED
|
@@ -131063,10 +131063,10 @@ var init_esm7 = __esm({
|
|
|
131063
131063
|
}
|
|
131064
131064
|
});
|
|
131065
131065
|
|
|
131066
|
-
// node_modules/@jimp/plugin-
|
|
131066
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/util.js
|
|
131067
131067
|
var util, objectUtil, ZodParsedType, getParsedType2;
|
|
131068
131068
|
var init_util3 = __esm({
|
|
131069
|
-
"node_modules/@jimp/plugin-
|
|
131069
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/util.js"() {
|
|
131070
131070
|
(function(util3) {
|
|
131071
131071
|
util3.assertEqual = (_2) => {
|
|
131072
131072
|
};
|
|
@@ -131200,10 +131200,10 @@ var init_util3 = __esm({
|
|
|
131200
131200
|
}
|
|
131201
131201
|
});
|
|
131202
131202
|
|
|
131203
|
-
// node_modules/@jimp/plugin-
|
|
131203
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/ZodError.js
|
|
131204
131204
|
var ZodIssueCode2, quotelessJson, ZodError2;
|
|
131205
131205
|
var init_ZodError = __esm({
|
|
131206
|
-
"node_modules/@jimp/plugin-
|
|
131206
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/ZodError.js"() {
|
|
131207
131207
|
init_util3();
|
|
131208
131208
|
ZodIssueCode2 = util.arrayToEnum([
|
|
131209
131209
|
"invalid_type",
|
|
@@ -131324,10 +131324,10 @@ var init_ZodError = __esm({
|
|
|
131324
131324
|
}
|
|
131325
131325
|
});
|
|
131326
131326
|
|
|
131327
|
-
// node_modules/@jimp/plugin-
|
|
131327
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/locales/en.js
|
|
131328
131328
|
var errorMap, en_default2;
|
|
131329
131329
|
var init_en2 = __esm({
|
|
131330
|
-
"node_modules/@jimp/plugin-
|
|
131330
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/locales/en.js"() {
|
|
131331
131331
|
init_ZodError();
|
|
131332
131332
|
init_util3();
|
|
131333
131333
|
errorMap = (issue3, _ctx) => {
|
|
@@ -131434,7 +131434,7 @@ var init_en2 = __esm({
|
|
|
131434
131434
|
}
|
|
131435
131435
|
});
|
|
131436
131436
|
|
|
131437
|
-
// node_modules/@jimp/plugin-
|
|
131437
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/errors.js
|
|
131438
131438
|
function setErrorMap2(map2) {
|
|
131439
131439
|
overrideErrorMap = map2;
|
|
131440
131440
|
}
|
|
@@ -131443,13 +131443,13 @@ function getErrorMap2() {
|
|
|
131443
131443
|
}
|
|
131444
131444
|
var overrideErrorMap;
|
|
131445
131445
|
var init_errors6 = __esm({
|
|
131446
|
-
"node_modules/@jimp/plugin-
|
|
131446
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/errors.js"() {
|
|
131447
131447
|
init_en2();
|
|
131448
131448
|
overrideErrorMap = en_default2;
|
|
131449
131449
|
}
|
|
131450
131450
|
});
|
|
131451
131451
|
|
|
131452
|
-
// node_modules/@jimp/plugin-
|
|
131452
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/parseUtil.js
|
|
131453
131453
|
function addIssueToContext(ctx, issueData) {
|
|
131454
131454
|
const overrideMap = getErrorMap2();
|
|
131455
131455
|
const issue3 = makeIssue({
|
|
@@ -131471,7 +131471,7 @@ function addIssueToContext(ctx, issueData) {
|
|
|
131471
131471
|
}
|
|
131472
131472
|
var makeIssue, EMPTY_PATH, ParseStatus, INVALID2, DIRTY, OK, isAborted, isDirty, isValid2, isAsync;
|
|
131473
131473
|
var init_parseUtil = __esm({
|
|
131474
|
-
"node_modules/@jimp/plugin-
|
|
131474
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/parseUtil.js"() {
|
|
131475
131475
|
init_errors6();
|
|
131476
131476
|
init_en2();
|
|
131477
131477
|
makeIssue = (params) => {
|
|
@@ -131566,16 +131566,16 @@ var init_parseUtil = __esm({
|
|
|
131566
131566
|
}
|
|
131567
131567
|
});
|
|
131568
131568
|
|
|
131569
|
-
// node_modules/@jimp/plugin-
|
|
131569
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/typeAliases.js
|
|
131570
131570
|
var init_typeAliases = __esm({
|
|
131571
|
-
"node_modules/@jimp/plugin-
|
|
131571
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/typeAliases.js"() {
|
|
131572
131572
|
}
|
|
131573
131573
|
});
|
|
131574
131574
|
|
|
131575
|
-
// node_modules/@jimp/plugin-
|
|
131575
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/errorUtil.js
|
|
131576
131576
|
var errorUtil;
|
|
131577
131577
|
var init_errorUtil = __esm({
|
|
131578
|
-
"node_modules/@jimp/plugin-
|
|
131578
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/helpers/errorUtil.js"() {
|
|
131579
131579
|
(function(errorUtil3) {
|
|
131580
131580
|
errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
131581
131581
|
errorUtil3.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
@@ -131583,7 +131583,7 @@ var init_errorUtil = __esm({
|
|
|
131583
131583
|
}
|
|
131584
131584
|
});
|
|
131585
131585
|
|
|
131586
|
-
// node_modules/@jimp/plugin-
|
|
131586
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/types.js
|
|
131587
131587
|
function processCreateParams(params) {
|
|
131588
131588
|
if (!params)
|
|
131589
131589
|
return {};
|
|
@@ -131777,7 +131777,7 @@ function custom2(check3, _params = {}, fatal) {
|
|
|
131777
131777
|
}
|
|
131778
131778
|
var ParseInputLazyPath, handleResult, ZodType2, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, jwtRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv4CidrRegex, ipv6Regex, ipv6CidrRegex, base64Regex, base64urlRegex, dateRegexSource, dateRegex, ZodString2, ZodNumber2, ZodBigInt2, ZodBoolean2, ZodDate2, ZodSymbol2, ZodUndefined2, ZodNull2, ZodAny2, ZodUnknown2, ZodNever2, ZodVoid2, ZodArray2, ZodObject2, ZodUnion2, getDiscriminator, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum, ZodPromise2, ZodEffects, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND, ZodBranded, ZodPipeline, ZodReadonly2, late, ZodFirstPartyTypeKind2, instanceOfType, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType, ostring, onumber, oboolean, coerce, NEVER2;
|
|
131779
131779
|
var init_types3 = __esm({
|
|
131780
|
-
"node_modules/@jimp/plugin-
|
|
131780
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/types.js"() {
|
|
131781
131781
|
init_ZodError();
|
|
131782
131782
|
init_errors6();
|
|
131783
131783
|
init_errorUtil();
|
|
@@ -135039,7 +135039,7 @@ var init_types3 = __esm({
|
|
|
135039
135039
|
}
|
|
135040
135040
|
});
|
|
135041
135041
|
|
|
135042
|
-
// node_modules/@jimp/plugin-
|
|
135042
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/v3/external.js
|
|
135043
135043
|
var external_exports2 = {};
|
|
135044
135044
|
__export(external_exports2, {
|
|
135045
135045
|
BRAND: () => BRAND,
|
|
@@ -135151,7 +135151,7 @@ __export(external_exports2, {
|
|
|
135151
135151
|
void: () => voidType
|
|
135152
135152
|
});
|
|
135153
135153
|
var init_external2 = __esm({
|
|
135154
|
-
"node_modules/@jimp/plugin-
|
|
135154
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/v3/external.js"() {
|
|
135155
135155
|
init_errors6();
|
|
135156
135156
|
init_parseUtil();
|
|
135157
135157
|
init_typeAliases();
|
|
@@ -135161,10 +135161,10 @@ var init_external2 = __esm({
|
|
|
135161
135161
|
}
|
|
135162
135162
|
});
|
|
135163
135163
|
|
|
135164
|
-
// node_modules/@jimp/plugin-
|
|
135164
|
+
// node_modules/@jimp/plugin-color/node_modules/zod/index.js
|
|
135165
135165
|
var zod_default;
|
|
135166
135166
|
var init_zod2 = __esm({
|
|
135167
|
-
"node_modules/@jimp/plugin-
|
|
135167
|
+
"node_modules/@jimp/plugin-color/node_modules/zod/index.js"() {
|
|
135168
135168
|
init_external2();
|
|
135169
135169
|
init_external2();
|
|
135170
135170
|
zod_default = external_exports2;
|
|
@@ -653365,7 +653365,7 @@ async function ensureSeaPlaywrightRuntime(sea) {
|
|
|
653365
653365
|
const manifest = readManifest3(sea);
|
|
653366
653366
|
const cacheDirectory = (0, import_node_path174.join)(
|
|
653367
653367
|
cacheBaseDirectory(),
|
|
653368
|
-
"4.0.0-mirror.
|
|
653368
|
+
"4.0.0-mirror.3",
|
|
653369
653369
|
manifest.target,
|
|
653370
653370
|
`playwright-${manifest.packageVersion}-${manifest.hash}`
|
|
653371
653371
|
);
|
|
@@ -655997,7 +655997,7 @@ var init_tui_runtime_loader = __esm({
|
|
|
655997
655997
|
const manifest = readManifest4(sea);
|
|
655998
655998
|
const cacheDirectory = (0, import_node_path177.join)(
|
|
655999
655999
|
cacheBaseDirectory2(),
|
|
656000
|
-
"4.0.0-mirror.
|
|
656000
|
+
"4.0.0-mirror.3",
|
|
656001
656001
|
manifest.target,
|
|
656002
656002
|
manifest.hash
|
|
656003
656003
|
);
|
|
@@ -656515,7 +656515,7 @@ var init_run = __esm({
|
|
|
656515
656515
|
init_tui_command();
|
|
656516
656516
|
init_browser_state_option();
|
|
656517
656517
|
init_workflow_mode();
|
|
656518
|
-
version3 = true ? "4.0.0-mirror.
|
|
656518
|
+
version3 = true ? "4.0.0-mirror.3" : "0.0.0";
|
|
656519
656519
|
EMPTY_TARGET_ERROR = "--target requires non-empty text.";
|
|
656520
656520
|
DEFAULT_HEADLESS_PROMPT_MODE = "yolo";
|
|
656521
656521
|
FORCE_MCS_SCOPE_ERROR = "--force-mcs can only be used with --prompt, --target, or tui.";
|
package/bin/zcode.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import Module from "node:module";
|
|
3
4
|
import { dirname, resolve } from "node:path";
|
|
4
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
6
|
|
|
@@ -11,6 +12,35 @@ const args = process.argv.slice(2);
|
|
|
11
12
|
if (args.length === 1 && ["--version", "-v"].includes(args[0])) {
|
|
12
13
|
console.log(version);
|
|
13
14
|
} else {
|
|
15
|
+
// Node 26 默认内置实验性 node:ffi,但 @mbears/opentui-core 的 node:ffi 后端尚不支持 usize;
|
|
16
|
+
// 屏蔽 node:ffi 使其自动回落到已打包的 koffi 后端,需要时可用 ZCODE_ALLOW_NODE_FFI=1 放开。
|
|
17
|
+
if (
|
|
18
|
+
process.env.ZCODE_ALLOW_NODE_FFI !== "1" &&
|
|
19
|
+
(Module.builtinModules.includes("node:ffi") || Module.builtinModules.includes("ffi"))
|
|
20
|
+
) {
|
|
21
|
+
if (typeof Module.registerHooks === "function") {
|
|
22
|
+
Module.registerHooks({
|
|
23
|
+
resolve(specifier, context, nextResolve) {
|
|
24
|
+
if (specifier === "node:ffi" || specifier === "ffi") {
|
|
25
|
+
const err = new Error(`Disabled experimental ${specifier} for OpenTUI koffi fallback`);
|
|
26
|
+
err.code = "ERR_UNKNOWN_BUILTIN_MODULE";
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
return nextResolve(specifier, context);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
} else if (typeof Module._load === "function") {
|
|
33
|
+
const originalLoad = Module._load;
|
|
34
|
+
Module._load = function (request, parent, isMain) {
|
|
35
|
+
if (request === "node:ffi" || request === "ffi") {
|
|
36
|
+
const err = new Error(`Disabled experimental ${request} for OpenTUI koffi fallback`);
|
|
37
|
+
err.code = "ERR_UNKNOWN_BUILTIN_MODULE";
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
return originalLoad.call(this, request, parent, isMain);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
14
44
|
// CLI 自启动子进程依赖真实 Agent 路径;其他参数(包括 --web)不由镜像 launcher 解释。
|
|
15
45
|
process.argv[1] = agentEntry;
|
|
16
46
|
await import(pathToFileURL(agentEntry).href);
|