zcode-app-cli 3.15.3-35 → 3.15.3-37
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/bin/zcode.js +6 -1
- package/docs/CONFIGURATION.md +14 -3
- package/docs/CONFIGURATION.zh-CN.md +11 -3
- package/docs/HOST_INTEGRATION.md +160 -0
- package/package.json +10 -7
- package/vendor/cli-config.cjs +52 -0
- package/vendor/extraction.json +6 -1
- package/vendor/node_modules/@zcode/tui/dist/index.js +184 -37
- package/vendor/node_modules/@zcode/tui/package.json +1 -1
- package/vendor/zcode.cjs +2 -2
|
@@ -5,7 +5,7 @@ import { constants as constants$1, homedir } from "node:os";
|
|
|
5
5
|
import { access, link, mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
6
6
|
import { basename, dirname, extname, isAbsolute, join, posix, resolve, sep, win32 } from "node:path";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
|
-
import { Box, CombinedAutocompleteProvider, Container, Editor, Image, Input, Markdown, ProcessTerminal, ScrollView, SelectList, Spacer, Text, TuiAltScreen, TuiMainScreen, VStack, decodeKittyPrintable, getKeybindings, isKeyRelease, isViewportTUI, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
8
|
+
import { Box, CombinedAutocompleteProvider, Container, Editor, Image, Input, Markdown, ProcessTerminal, ScrollView, SelectList, Spacer, Text, TuiAltScreen, TuiMainScreen, VStack, decodeKittyPrintable, getKeybindings, isKeyRelease, isViewportTUI, matchesKey, renderFakeCursor, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
9
9
|
import { AltScreenSearchComponent } from "@earendil-works/pi-tui/dist/alt-screen-search.js";
|
|
10
10
|
import { StringDecoder } from "node:string_decoder";
|
|
11
11
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -394,6 +394,80 @@ async function missingCodingPlanKey(options = {}) {
|
|
|
394
394
|
return message(providerId);
|
|
395
395
|
}
|
|
396
396
|
//#endregion
|
|
397
|
+
//#region packages/zcode-tui/src/stream-error-guard.ts
|
|
398
|
+
function watchStreamErrors(sources, onError) {
|
|
399
|
+
const uniqueSources = [...new Set(sources)];
|
|
400
|
+
for (const source of uniqueSources) source.on("error", onError);
|
|
401
|
+
let active = true;
|
|
402
|
+
return () => {
|
|
403
|
+
if (!active) return;
|
|
404
|
+
active = false;
|
|
405
|
+
for (const source of uniqueSources) source.off("error", onError);
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region packages/zcode-tui/src/startup.ts
|
|
410
|
+
async function loadTuiStartupOptions(options) {
|
|
411
|
+
const loadStartupOptions = options.loadStartupOptions;
|
|
412
|
+
if (!loadStartupOptions) return options;
|
|
413
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("ZCode TUI requires an interactive terminal.");
|
|
414
|
+
const ui = new TuiMainScreen(new ProcessTerminal(), true);
|
|
415
|
+
const chinese = options.locale?.startsWith("zh");
|
|
416
|
+
ui.addChild(new Text(chinese ? "正在启动 ZCode…" : "Starting ZCode…", 1, 0));
|
|
417
|
+
ui.addChild(new Text(chinese ? "按 Ctrl+C 取消" : "Press Ctrl+C to cancel", 1, 0));
|
|
418
|
+
let cancelled = false;
|
|
419
|
+
let resolveCancelled;
|
|
420
|
+
const cancellation = new Promise((resolve) => {
|
|
421
|
+
resolveCancelled = () => resolve(void 0);
|
|
422
|
+
});
|
|
423
|
+
const cancel = (exitCode) => {
|
|
424
|
+
if (cancelled) return;
|
|
425
|
+
cancelled = true;
|
|
426
|
+
process.exitCode = exitCode;
|
|
427
|
+
resolveCancelled();
|
|
428
|
+
};
|
|
429
|
+
const onSigint = () => cancel(128 + constants$1.signals.SIGINT);
|
|
430
|
+
const onSigterm = () => cancel(128 + constants$1.signals.SIGTERM);
|
|
431
|
+
const onSighup = () => cancel(128 + constants$1.signals.SIGHUP);
|
|
432
|
+
ui.addInputListener((data) => {
|
|
433
|
+
if (!isKeyRelease(data) && matchesKey(data, "ctrl+c")) onSigint();
|
|
434
|
+
return { consume: true };
|
|
435
|
+
});
|
|
436
|
+
const removeStreamErrorGuards = watchStreamErrors([process.stdout, process.stderr], () => cancel(1));
|
|
437
|
+
process.once("SIGINT", onSigint);
|
|
438
|
+
process.once("SIGTERM", onSigterm);
|
|
439
|
+
if (process.platform !== "win32") process.once("SIGHUP", onSighup);
|
|
440
|
+
try {
|
|
441
|
+
ui.start();
|
|
442
|
+
ui.renderNow();
|
|
443
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
444
|
+
if (cancelled) return void 0;
|
|
445
|
+
return await Promise.race([Promise.resolve().then(async () => {
|
|
446
|
+
if (cancelled) return void 0;
|
|
447
|
+
const startup = await loadStartupOptions();
|
|
448
|
+
return cancelled ? void 0 : {
|
|
449
|
+
...options,
|
|
450
|
+
...startup
|
|
451
|
+
};
|
|
452
|
+
}), cancellation]);
|
|
453
|
+
} finally {
|
|
454
|
+
process.off("SIGINT", onSigint);
|
|
455
|
+
process.off("SIGTERM", onSigterm);
|
|
456
|
+
if (process.platform !== "win32") process.off("SIGHUP", onSighup);
|
|
457
|
+
try {
|
|
458
|
+
ui.clear();
|
|
459
|
+
ui.renderNow();
|
|
460
|
+
} finally {
|
|
461
|
+
try {
|
|
462
|
+
ui.stop();
|
|
463
|
+
} finally {
|
|
464
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
465
|
+
removeStreamErrorGuards();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
//#endregion
|
|
397
471
|
//#region packages/zcode-tui/src/prompt-preflight.ts
|
|
398
472
|
/** Preserve rejected input without replacing a draft typed during validation. */
|
|
399
473
|
async function preflightSubmission(options) {
|
|
@@ -153807,13 +153881,12 @@ function removeLastGrapheme(value) {
|
|
|
153807
153881
|
return segments.join("");
|
|
153808
153882
|
}
|
|
153809
153883
|
/**
|
|
153810
|
-
* Drop
|
|
153811
|
-
*
|
|
153812
|
-
*
|
|
153813
|
-
* Input placeholders may add SGR (e.g. dim) inside the caret; retain it.
|
|
153884
|
+
* Drop pi-tui's fake-cursor APC markers before the renderer turns them into
|
|
153885
|
+
* reverse video. Retain the hardware cursor marker, text and placeholder styles.
|
|
153886
|
+
* Also accept the SGR caret form used by custom/legacy input components.
|
|
153814
153887
|
*/
|
|
153815
153888
|
function stripCaretHighlight(text) {
|
|
153816
|
-
return text.replace(/\x1b\[7m((?:\x1b\[(?!(?:0|27)m)[0-9;:]*m|[^\x1b])*)\x1b\[(?:0|27)m/gu, "$1");
|
|
153889
|
+
return text.replace(/\x1b_pi:\/?fc\x07/gu, "").replace(/\x1b\[7m((?:\x1b\[(?!(?:0|27)m)[0-9;:]*m|[^\x1b])*)\x1b\[(?:0|27)m/gu, "$1");
|
|
153817
153890
|
}
|
|
153818
153891
|
const maxHighlightCharacters = 1e5;
|
|
153819
153892
|
const plainLanguages = /* @__PURE__ */ new Set([
|
|
@@ -157041,6 +157114,7 @@ function toolScope(event) {
|
|
|
157041
157114
|
var BackgroundTaskEventStore = class {
|
|
157042
157115
|
activities = /* @__PURE__ */ new Map();
|
|
157043
157116
|
handoffTurns = /* @__PURE__ */ new Map();
|
|
157117
|
+
handoffTexts = /* @__PURE__ */ new Map();
|
|
157044
157118
|
pendingBackgroundTasks = /* @__PURE__ */ new Set();
|
|
157045
157119
|
pendingSubagentMessages = /* @__PURE__ */ new Set();
|
|
157046
157120
|
scopedTurnIds = /* @__PURE__ */ new Set();
|
|
@@ -157059,6 +157133,7 @@ var BackgroundTaskEventStore = class {
|
|
|
157059
157133
|
const notices = [];
|
|
157060
157134
|
let changed = false;
|
|
157061
157135
|
let handoffSettled = false;
|
|
157136
|
+
let settledTurnId;
|
|
157062
157137
|
const taskId = taskIdFor(event);
|
|
157063
157138
|
if (event.type === "background_task_completed" && taskId) {
|
|
157064
157139
|
this.pendingBackgroundTasks.add(taskId);
|
|
@@ -157119,6 +157194,7 @@ var BackgroundTaskEventStore = class {
|
|
|
157119
157194
|
if (handoff && (completed || failed)) {
|
|
157120
157195
|
this.handoffTurns.delete(event.turnId);
|
|
157121
157196
|
handoffSettled = true;
|
|
157197
|
+
settledTurnId = event.turnId;
|
|
157122
157198
|
if (failed) {
|
|
157123
157199
|
const detail = event.message ?? "The task finished, but ZCode could not process its result.";
|
|
157124
157200
|
for (const id of handoff.taskIds) this.record(id, "error", detail, event.turnId);
|
|
@@ -157134,9 +157210,20 @@ var BackgroundTaskEventStore = class {
|
|
|
157134
157210
|
return {
|
|
157135
157211
|
changed,
|
|
157136
157212
|
handoffSettled,
|
|
157137
|
-
notices
|
|
157213
|
+
notices,
|
|
157214
|
+
settledTurnId
|
|
157138
157215
|
};
|
|
157139
157216
|
}
|
|
157217
|
+
/**
|
|
157218
|
+
* The response text a background handoff turn produced for the conversation.
|
|
157219
|
+
* Handoff turns are task-scoped away from the main transcript while they
|
|
157220
|
+
* run, so the transcript render needs the accumulated text when they settle.
|
|
157221
|
+
*/
|
|
157222
|
+
takeHandoffText(turnId) {
|
|
157223
|
+
const text = this.handoffTexts.get(turnId);
|
|
157224
|
+
this.handoffTexts.delete(turnId);
|
|
157225
|
+
return text;
|
|
157226
|
+
}
|
|
157140
157227
|
entries(taskId) {
|
|
157141
157228
|
return this.activities.get(taskId) ?? [];
|
|
157142
157229
|
}
|
|
@@ -157146,6 +157233,7 @@ var BackgroundTaskEventStore = class {
|
|
|
157146
157233
|
settleActiveHandoffs() {
|
|
157147
157234
|
const count = this.handoffTurns.size;
|
|
157148
157235
|
this.handoffTurns.clear();
|
|
157236
|
+
this.handoffTexts.clear();
|
|
157149
157237
|
return count;
|
|
157150
157238
|
}
|
|
157151
157239
|
isTaskScoped(event) {
|
|
@@ -157163,6 +157251,12 @@ var BackgroundTaskEventStore = class {
|
|
|
157163
157251
|
this.record(taskId, failed ? "error" : "system", message);
|
|
157164
157252
|
}
|
|
157165
157253
|
appendHandoffDelta(taskId, turnId, delta) {
|
|
157254
|
+
const accumulated = bounded((this.handoffTexts.get(turnId) ?? "") + delta);
|
|
157255
|
+
this.handoffTexts.set(turnId, accumulated);
|
|
157256
|
+
if (this.handoffTexts.size > 32) {
|
|
157257
|
+
const oldest = this.handoffTexts.keys().next().value;
|
|
157258
|
+
if (oldest !== void 0 && oldest !== turnId) this.handoffTexts.delete(oldest);
|
|
157259
|
+
}
|
|
157166
157260
|
const entries = this.activities.get(taskId) ?? [];
|
|
157167
157261
|
const id = `handoff:${turnId}`;
|
|
157168
157262
|
const existing = entries.find((entry) => entry.id === id);
|
|
@@ -157258,6 +157352,24 @@ var BackgroundTaskEventStore = class {
|
|
|
157258
157352
|
}
|
|
157259
157353
|
};
|
|
157260
157354
|
//#endregion
|
|
157355
|
+
//#region packages/zcode-tui/src/background-task-notifications.ts
|
|
157356
|
+
const deliveredTaskIdPattern = /<task-id>([^<]{1,200})<\/task-id>/gu;
|
|
157357
|
+
/** Task ids whose terminal notification already exists in the conversation. */
|
|
157358
|
+
function deliveredBackgroundTaskIds(messages) {
|
|
157359
|
+
const delivered = /* @__PURE__ */ new Set();
|
|
157360
|
+
for (const message of messages) {
|
|
157361
|
+
if (message.role !== "user") continue;
|
|
157362
|
+
for (const part of message.parts ?? []) {
|
|
157363
|
+
if (typeof part.text !== "string") continue;
|
|
157364
|
+
for (const match of part.text.matchAll(deliveredTaskIdPattern)) {
|
|
157365
|
+
const taskId = match[1]?.trim();
|
|
157366
|
+
if (taskId) delivered.add(taskId);
|
|
157367
|
+
}
|
|
157368
|
+
}
|
|
157369
|
+
}
|
|
157370
|
+
return delivered;
|
|
157371
|
+
}
|
|
157372
|
+
//#endregion
|
|
157261
157373
|
//#region packages/zcode-tui/src/background-task-output.ts
|
|
157262
157374
|
const defaultMaximumBytes = 64 * 1024;
|
|
157263
157375
|
function readBackgroundTaskOutput(path, maximumBytes = defaultMaximumBytes) {
|
|
@@ -157883,7 +157995,8 @@ var PromptInput = class extends Input {
|
|
|
157883
157995
|
const lines = super.render(width);
|
|
157884
157996
|
if (!value && this.placeholderText && lines[0]) {
|
|
157885
157997
|
const placeholder = this.theme.muted(this.placeholderText);
|
|
157886
|
-
|
|
157998
|
+
const cursor = renderFakeCursor(" ");
|
|
157999
|
+
return [truncateToWidth(lines[0].replace(cursor, `${cursor}${placeholder}`), width, "", true)];
|
|
157887
158000
|
}
|
|
157888
158001
|
return lines;
|
|
157889
158002
|
}
|
|
@@ -157913,7 +158026,7 @@ var PromptEditor = class extends Editor {
|
|
|
157913
158026
|
renderEditor(width) {
|
|
157914
158027
|
const lines = super.render(width);
|
|
157915
158028
|
if (this.getText() || !this.placeholder) return lines;
|
|
157916
|
-
const cursor = "
|
|
158029
|
+
const cursor = renderFakeCursor(" ");
|
|
157917
158030
|
const cursorLine = lines.findIndex((line) => line.includes(cursor));
|
|
157918
158031
|
if (cursorLine >= 0) lines[cursorLine] = truncateToWidth(lines[cursorLine].replace(cursor, `${cursor}${this.promptTheme.muted(this.placeholder)}`), width, "", true);
|
|
157919
158032
|
return lines;
|
|
@@ -157957,6 +158070,20 @@ function promptText(ui, host, theme, options) {
|
|
|
157957
158070
|
function colorSchemeFromRgb(color) {
|
|
157958
158071
|
return (.2126 * color.r + .7152 * color.g + .0722 * color.b) / 255 > .5 ? "light" : "dark";
|
|
157959
158072
|
}
|
|
158073
|
+
/** Query pi-tui's combined palette, retaining the terminal scheme-report fallback. */
|
|
158074
|
+
async function queryTerminalColorScheme(ui, timeoutMs) {
|
|
158075
|
+
let reportedScheme;
|
|
158076
|
+
const unsubscribe = ui.onTerminalColorSchemeChange((scheme) => {
|
|
158077
|
+
reportedScheme = scheme;
|
|
158078
|
+
});
|
|
158079
|
+
try {
|
|
158080
|
+
ui.terminal.write("\x1B[?996n");
|
|
158081
|
+
const colors = await ui.queryTerminalColors({ timeoutMs });
|
|
158082
|
+
return colors.background ? colorSchemeFromRgb(colors.background) : reportedScheme;
|
|
158083
|
+
} finally {
|
|
158084
|
+
unsubscribe();
|
|
158085
|
+
}
|
|
158086
|
+
}
|
|
157960
158087
|
/**
|
|
157961
158088
|
* Best-effort synchronous fallback for terminals that expose COLORFGBG.
|
|
157962
158089
|
* The last ANSI color is the background; values outside the conventional
|
|
@@ -162361,18 +162488,6 @@ var TurnNotifier = class {
|
|
|
162361
162488
|
}
|
|
162362
162489
|
};
|
|
162363
162490
|
//#endregion
|
|
162364
|
-
//#region packages/zcode-tui/src/stream-error-guard.ts
|
|
162365
|
-
function watchStreamErrors(sources, onError) {
|
|
162366
|
-
const uniqueSources = [...new Set(sources)];
|
|
162367
|
-
for (const source of uniqueSources) source.on("error", onError);
|
|
162368
|
-
let active = true;
|
|
162369
|
-
return () => {
|
|
162370
|
-
if (!active) return;
|
|
162371
|
-
active = false;
|
|
162372
|
-
for (const source of uniqueSources) source.off("error", onError);
|
|
162373
|
-
};
|
|
162374
|
-
}
|
|
162375
|
-
//#endregion
|
|
162376
162491
|
//#region packages/zcode-tui/src/tui-mode.ts
|
|
162377
162492
|
function record$1(value) {
|
|
162378
162493
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
@@ -166335,7 +166450,7 @@ const exitUsageQueryTimeoutMs = 250;
|
|
|
166335
166450
|
const fullscreenWelcomeTransitionMs = 180;
|
|
166336
166451
|
const terminalFocusIn = "\x1B[I";
|
|
166337
166452
|
const updateAvailableBlockId = "update_available";
|
|
166338
|
-
const
|
|
166453
|
+
const modelStatusBlockIdPrefix = "model_status";
|
|
166339
166454
|
const questionBackValue = "__back__";
|
|
166340
166455
|
const questionOtherValue = "__other__";
|
|
166341
166456
|
const questionDoneValue = "__done__";
|
|
@@ -166498,9 +166613,8 @@ function suppressTuiAiSdkWarnings() {
|
|
|
166498
166613
|
}
|
|
166499
166614
|
suppressTuiAiSdkWarnings();
|
|
166500
166615
|
/**
|
|
166501
|
-
*
|
|
166502
|
-
*
|
|
166503
|
-
* so it needs the same priority as a modal overlay while it has focus.
|
|
166616
|
+
* Give the composer priority for page navigation and modified Home/End keys
|
|
166617
|
+
* while editing. Bare Home/End are already editor keys in pi-tui 1.x.
|
|
166504
166618
|
*/
|
|
166505
166619
|
var ZCodeAltScreen = class extends TuiAltScreen {
|
|
166506
166620
|
viewportInputDeferral;
|
|
@@ -166610,7 +166724,7 @@ var ZCodeTui = class {
|
|
|
166610
166724
|
activeTurnId;
|
|
166611
166725
|
turnEpoch = 0;
|
|
166612
166726
|
activeTurnEpoch;
|
|
166613
|
-
|
|
166727
|
+
modelStatusBlockId;
|
|
166614
166728
|
pendingSteerInterrupt;
|
|
166615
166729
|
recentSteerCommit;
|
|
166616
166730
|
currentThinking;
|
|
@@ -166646,6 +166760,8 @@ var ZCodeTui = class {
|
|
|
166646
166760
|
unsubscribeSession;
|
|
166647
166761
|
backgroundTaskEvents = new BackgroundTaskEventStore();
|
|
166648
166762
|
restoredNoticeSeen = /* @__PURE__ */ new Set();
|
|
166763
|
+
notifiedBackgroundTaskIds = /* @__PURE__ */ new Set();
|
|
166764
|
+
transcriptNotificationsReady = false;
|
|
166649
166765
|
turnWork = new TurnWorkTracker();
|
|
166650
166766
|
backgroundCoordinatorMessageIds = /* @__PURE__ */ new Set();
|
|
166651
166767
|
workflowPanel;
|
|
@@ -166884,8 +167000,7 @@ var ZCodeTui = class {
|
|
|
166884
167000
|
async resolveTerminalColorScheme() {
|
|
166885
167001
|
if (!this.colorsEnabled || this.themePreference !== "auto") return;
|
|
166886
167002
|
try {
|
|
166887
|
-
const
|
|
166888
|
-
const colorScheme = background ? colorSchemeFromRgb(background) : reportedScheme;
|
|
167003
|
+
const colorScheme = await queryTerminalColorScheme(this.ui, terminalThemeQueryTimeoutMs);
|
|
166889
167004
|
if (colorScheme) this.theme.setColorScheme(colorScheme);
|
|
166890
167005
|
} catch {}
|
|
166891
167006
|
}
|
|
@@ -168154,7 +168269,7 @@ var ZCodeTui = class {
|
|
|
168154
168269
|
title: event.type === "streamRecovery.updated" ? "Recovering model stream" : "Retrying model request",
|
|
168155
168270
|
summary: [retry, delay].filter(Boolean).join(" · "),
|
|
168156
168271
|
detail: event.message
|
|
168157
|
-
}, this.
|
|
168272
|
+
}, this.modelStatusBlockId);
|
|
168158
168273
|
} else if (event.type === "model_request_failed") {
|
|
168159
168274
|
if (!isModelCancellationEvent(event)) {
|
|
168160
168275
|
this.updateActivity(event.retryable === true ? "model request failed · waiting to retry…" : "model request failed…", false);
|
|
@@ -168162,7 +168277,7 @@ var ZCodeTui = class {
|
|
|
168162
168277
|
tone: "error",
|
|
168163
168278
|
title: "Model request failed",
|
|
168164
168279
|
detail: event.message
|
|
168165
|
-
});
|
|
168280
|
+
}, this.modelStatusBlockId);
|
|
168166
168281
|
}
|
|
168167
168282
|
} else if (event.type === "model_stream_stalled") {
|
|
168168
168283
|
this.updateActivity("model stream stalled · waiting to retry…", false);
|
|
@@ -168172,9 +168287,11 @@ var ZCodeTui = class {
|
|
|
168172
168287
|
title: "Model stream stalled",
|
|
168173
168288
|
summary: idle,
|
|
168174
168289
|
detail: event.message
|
|
168175
|
-
});
|
|
168176
|
-
} else if (event.type === "model_request_completed")
|
|
168177
|
-
|
|
168290
|
+
}, this.modelStatusBlockId);
|
|
168291
|
+
} else if (event.type === "model_request_completed") {
|
|
168292
|
+
this.updateActivity("processing model response…", false);
|
|
168293
|
+
this.clearModelStatus();
|
|
168294
|
+
} else if (event.type === "compact_boundary" || event.type === "session_compacted") this.addSystemEvent({
|
|
168178
168295
|
tone: "muted",
|
|
168179
168296
|
title: "Conversation compacted",
|
|
168180
168297
|
summary: "Earlier context remains in transcript history"
|
|
@@ -168356,9 +168473,23 @@ var ZCodeTui = class {
|
|
|
168356
168473
|
});
|
|
168357
168474
|
this.notifications.notify(notice.notification, notice.detail ?? `${notice.title} · ${notice.summary}`);
|
|
168358
168475
|
}
|
|
168359
|
-
if (update.handoffSettled)
|
|
168476
|
+
if (update.handoffSettled) {
|
|
168477
|
+
this.renderSettledHandoffResponse(update.settledTurnId);
|
|
168478
|
+
this.drainInputAfterBackgroundHandoff();
|
|
168479
|
+
}
|
|
168360
168480
|
if (update.changed || update.notices.length > 0) this.requestStreamRender();
|
|
168361
168481
|
}
|
|
168482
|
+
/**
|
|
168483
|
+
* Turns that a background task handed off to are task-scoped out of the
|
|
168484
|
+
* main transcript while they run, so without this the response to a
|
|
168485
|
+
* completed task is only reachable from /tasks and the assistant appears to
|
|
168486
|
+
* stay silent after "Background task completed".
|
|
168487
|
+
*/
|
|
168488
|
+
renderSettledHandoffResponse(turnId) {
|
|
168489
|
+
if (!turnId) return;
|
|
168490
|
+
const text = this.backgroundTaskEvents.takeHandoffText(turnId);
|
|
168491
|
+
if (text && text.trim()) this.addAssistantMessage(text);
|
|
168492
|
+
}
|
|
168362
168493
|
drainInputAfterBackgroundHandoff() {
|
|
168363
168494
|
if (this.backgroundDrainScheduled) return;
|
|
168364
168495
|
this.backgroundDrainScheduled = true;
|
|
@@ -168542,7 +168673,7 @@ var ZCodeTui = class {
|
|
|
168542
168673
|
beginTurn(prompt) {
|
|
168543
168674
|
this.completeThinking();
|
|
168544
168675
|
this.presentationRegistry.beginTurn();
|
|
168545
|
-
this.
|
|
168676
|
+
this.modelStatusBlockId = `${modelStatusBlockIdPrefix}_${this.turnEpoch}`;
|
|
168546
168677
|
this.currentThinking = void 0;
|
|
168547
168678
|
this.currentThinkingPartId = void 0;
|
|
168548
168679
|
this.currentToolGroup = void 0;
|
|
@@ -168666,6 +168797,14 @@ var ZCodeTui = class {
|
|
|
168666
168797
|
});
|
|
168667
168798
|
this.ui.requestRender();
|
|
168668
168799
|
}
|
|
168800
|
+
/**
|
|
168801
|
+
* The model status row reports the current attempt (stalled, failed, retrying).
|
|
168802
|
+
* A completed request proves the connection is back, so the row must not outlive it.
|
|
168803
|
+
*/
|
|
168804
|
+
clearModelStatus() {
|
|
168805
|
+
if (!this.modelStatusBlockId || !this.transcript.removeBlock(this.modelStatusBlockId)) return;
|
|
168806
|
+
this.ui.requestRender();
|
|
168807
|
+
}
|
|
168669
168808
|
addUpdateAvailable(currentVersion, latestVersion) {
|
|
168670
168809
|
this.transcript.addBlock(new UpdateAvailableView(this.theme, currentVersion, latestVersion), {
|
|
168671
168810
|
id: updateAvailableBlockId,
|
|
@@ -168999,6 +169138,8 @@ var ZCodeTui = class {
|
|
|
168999
169138
|
this.currentToolGroupBlockId = void 0;
|
|
169000
169139
|
this.currentToolGroupMessageId = void 0;
|
|
169001
169140
|
this.assistantStream.breakSegment();
|
|
169141
|
+
for (const taskId of deliveredBackgroundTaskIds(messages)) this.notifiedBackgroundTaskIds.add(taskId);
|
|
169142
|
+
this.transcriptNotificationsReady = true;
|
|
169002
169143
|
if (lastAssistantModel) this.model = lastAssistantModel;
|
|
169003
169144
|
}
|
|
169004
169145
|
restorePart(part, role, fallbackMessageId) {
|
|
@@ -170965,7 +171106,9 @@ var ZCodeTui = class {
|
|
|
170965
171106
|
} catch (error) {
|
|
170966
171107
|
const message = error instanceof Error ? error.message : String(error);
|
|
170967
171108
|
this.addNotice(`Unable to restore session transcript: ${message}`, "warning");
|
|
171109
|
+
this.transcriptNotificationsReady = true;
|
|
170968
171110
|
}
|
|
171111
|
+
else this.transcriptNotificationsReady = true;
|
|
170969
171112
|
await this.restoreSessionModel();
|
|
170970
171113
|
}
|
|
170971
171114
|
async restoreSessionModel() {
|
|
@@ -171161,7 +171304,10 @@ var ZCodeTui = class {
|
|
|
171161
171304
|
* model-facing task_status attachment alone does not reach the user.
|
|
171162
171305
|
*/
|
|
171163
171306
|
noticeRestoredBackgroundTasks(projection) {
|
|
171164
|
-
|
|
171307
|
+
if (!this.transcriptNotificationsReady) return;
|
|
171308
|
+
const jobs = projection.restoredBackgroundTasks ?? [];
|
|
171309
|
+
for (const job of jobs) {
|
|
171310
|
+
if (this.notifiedBackgroundTaskIds.has(job.taskId)) continue;
|
|
171165
171311
|
const seenKey = `${projection.sessionId ?? ""}/${job.taskId}`;
|
|
171166
171312
|
if (this.restoredNoticeSeen.has(seenKey)) continue;
|
|
171167
171313
|
this.restoredNoticeSeen.add(seenKey);
|
|
@@ -171393,7 +171539,8 @@ var ZCodeTui = class {
|
|
|
171393
171539
|
};
|
|
171394
171540
|
async function runTui(options) {
|
|
171395
171541
|
suppressTuiAiSdkWarnings();
|
|
171396
|
-
await
|
|
171542
|
+
const readyOptions = await loadTuiStartupOptions(options);
|
|
171543
|
+
if (readyOptions) await new ZCodeTui(readyOptions).run();
|
|
171397
171544
|
}
|
|
171398
171545
|
//#endregion
|
|
171399
171546
|
export { loginFailureDiagnostic, runTui, shouldSuspendForLoginCommand, shouldUseNoBrowserForLogin, suppressTuiAiSdkWarnings, suspendedZaiLoginCommand };
|