zcode-app-cli 3.14.4-33 → 3.15.3-35
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 +18 -4
- package/bin/zcode.js +4 -0
- package/docs/CONFIGURATION.md +68 -6
- package/docs/CONFIGURATION.zh-CN.md +52 -4
- package/docs/PROVIDER_CONFIG.md +25 -0
- package/docs/PROVIDER_CONFIG.zh-CN.md +20 -0
- package/package.json +4 -2
- package/vendor/cli-config.cjs +159 -0
- package/vendor/extraction.json +38 -5
- package/vendor/node_modules/@zcode/tui/dist/index.js +474 -85
- package/vendor/packages/browser-use-plugin/README.md +1 -1
- package/vendor/packages/browser-use-plugin/docs/api.json +1 -1
- package/vendor/packages/browser-use-plugin/docs/overview.md +6 -6
- package/vendor/packages/browser-use-plugin/docs/playwright.md +3 -3
- package/vendor/packages/browser-use-plugin/docs/workflow.md +2 -2
- package/vendor/packages/browser-use-plugin/scripts/browser-client.mjs +5 -7
- package/vendor/packages/browser-use-plugin/scripts/build.mjs +0 -1
- package/vendor/packages/browser-use-plugin/skills/control-browser/SKILL.md +9 -9
- package/vendor/packages/bundled-skills/skills/dynamic-workflows/SKILL.md +760 -687
- package/vendor/packages/bundled-skills/skills/dynamic-workflows/examples.md +310 -1
- package/vendor/packages/bundled-skills/skills/dynamic-workflows/patterns.md +336 -4
- package/vendor/packages/documents-plugin/.zcode-plugin/plugin.json +2 -2
- package/vendor/packages/documents-plugin/package.json +2 -2
- package/vendor/packages/documents-plugin/skills/docx/LICENSE.txt +10 -10
- package/vendor/packages/node-repl-host/.zcode-plugin/plugin.json +1 -1
- package/vendor/packages/node-repl-host/dist/mcp/server.js +116 -48
- package/vendor/packages/node-repl-host/package.json +1 -1
- package/vendor/packages/node-repl-host/scripts/build.mjs +4 -4
- package/vendor/packages/pdf-plugin/.zcode-plugin/plugin.json +2 -2
- package/vendor/packages/pdf-plugin/package.json +2 -2
- package/vendor/packages/pdf-plugin/skills/pdf/LICENSE.txt +10 -10
- package/vendor/packages/pdf-plugin/skills/pdf/references/resume-altacv.tex +1 -1
- package/vendor/packages/plugin-creator-plugin/skills/plugin-creator/SKILL.md +1 -1
- package/vendor/packages/plugin-creator-plugin/skills/plugin-creator/references/plugin-json-spec.md +1 -1
- package/vendor/packages/presentations-plugin/.zcode-plugin/plugin.json +2 -2
- package/vendor/packages/presentations-plugin/package.json +2 -2
- package/vendor/packages/presentations-plugin/skills/pptx/LICENSE.txt +10 -10
- package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/SKILL.md +1 -1
- package/vendor/packages/spreadsheets-plugin/.zcode-plugin/plugin.json +2 -2
- package/vendor/packages/spreadsheets-plugin/package.json +2 -2
- package/vendor/packages/spreadsheets-plugin/skills/xlsx/LICENSE.txt +10 -10
- package/vendor/packages/visualize-plugin/.zcode-plugin/plugin.json +10 -0
- package/vendor/packages/visualize-plugin/package.json +8 -0
- package/vendor/packages/visualize-plugin/skills/visualize/LICENSE.md +5 -0
- package/vendor/packages/visualize-plugin/skills/visualize/SKILL.md +277 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/calendar.js +273 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/runtime-manifest.json +16 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/standalone-host-bridge.js +256 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/standalone-shell.js +183 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/d3-7.9.0.min.js +2 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/d3-7.9.0.min.js.LICENSE +13 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/floating-ui-core-1.7.3.min.js +1 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/floating-ui-core-1.7.3.min.js.LICENSE +20 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/floating-ui-dom-1.7.4.min.js +1 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/floating-ui-dom-1.7.4.min.js.LICENSE +20 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/lucide-1.17.0.js +19521 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/lucide-1.17.0.js.LICENSE +43 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/vendor/manifest.json +57 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/visualize.css +1222 -0
- package/vendor/packages/visualize-plugin/skills/visualize/assets/visualize.html +517 -0
- package/vendor/packages/visualize-plugin/skills/visualize/examples/calendar.html +10 -0
- package/vendor/packages/visualize-plugin/skills/visualize/references/api.md +128 -0
- package/vendor/packages/visualize-plugin/skills/visualize/references/styles.md +3 -0
- package/vendor/packages/visualize-plugin/skills/visualize/scripts/render.py +248 -0
- package/vendor/packages/visualize-plugin/skills/visualize/scripts/vendor.py +56 -0
- package/vendor/packages/visualize-plugin/skills/visualize/tweak.md +62 -0
- package/vendor/packages/visualize-plugin/skills/visualize/widgets/calendar.md +90 -0
- package/vendor/packages/zcode-cua-plugin/.zcode-plugin/plugin.json +1 -1
- package/vendor/packages/zcode-cua-plugin/docs/computer-use.md +1 -1
- package/vendor/packages/zcode-cua-plugin/package.json +1 -1
- package/vendor/packages/zcode-cua-plugin/scripts/computer-use-client.mjs +35 -41
- package/vendor/packages/zcode-guide-plugin/skills/zcode-configuration-guide/SKILL.md +2 -2
- package/vendor/provider/zcode-builtin.json +96 -1
- package/vendor/zcode.cjs +1622 -1425
- package/zcode-runtime.lock.json +3 -3
|
@@ -6,6 +6,7 @@ import { access, link, mkdir, open, readFile, rename, rm, stat, writeFile } from
|
|
|
6
6
|
import { basename, dirname, extname, isAbsolute, join, posix, resolve, sep, win32 } from "node:path";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
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";
|
|
9
|
+
import { AltScreenSearchComponent } from "@earendil-works/pi-tui/dist/alt-screen-search.js";
|
|
9
10
|
import { StringDecoder } from "node:string_decoder";
|
|
10
11
|
import { isDeepStrictEqual } from "node:util";
|
|
11
12
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
@@ -153805,6 +153806,15 @@ function removeLastGrapheme(value) {
|
|
|
153805
153806
|
segments.pop();
|
|
153806
153807
|
return segments.join("");
|
|
153807
153808
|
}
|
|
153809
|
+
/**
|
|
153810
|
+
* Drop the reverse-video SGR pair the editor and input components draw
|
|
153811
|
+
* around the caret grapheme (Editor resets with 0, Input with 27). Cell
|
|
153812
|
+
* contents and visible widths are unchanged; only the highlight goes away.
|
|
153813
|
+
* Input placeholders may add SGR (e.g. dim) inside the caret; retain it.
|
|
153814
|
+
*/
|
|
153815
|
+
function stripCaretHighlight(text) {
|
|
153816
|
+
return text.replace(/\x1b\[7m((?:\x1b\[(?!(?:0|27)m)[0-9;:]*m|[^\x1b])*)\x1b\[(?:0|27)m/gu, "$1");
|
|
153817
|
+
}
|
|
153808
153818
|
const maxHighlightCharacters = 1e5;
|
|
153809
153819
|
const plainLanguages = /* @__PURE__ */ new Set([
|
|
153810
153820
|
"",
|
|
@@ -157848,6 +157858,8 @@ var PromptInput = class extends Input {
|
|
|
157848
157858
|
mask;
|
|
157849
157859
|
placeholderText;
|
|
157850
157860
|
theme;
|
|
157861
|
+
/** Read at render time so terminal focus changes need no state plumbing. */
|
|
157862
|
+
isTerminalFocused = () => true;
|
|
157851
157863
|
constructor(mask, placeholderText, theme) {
|
|
157852
157864
|
super();
|
|
157853
157865
|
this.mask = mask;
|
|
@@ -157855,6 +157867,10 @@ var PromptInput = class extends Input {
|
|
|
157855
157867
|
this.theme = theme;
|
|
157856
157868
|
}
|
|
157857
157869
|
render(width) {
|
|
157870
|
+
const lines = this.renderInput(width);
|
|
157871
|
+
return this.isTerminalFocused() ? lines : lines.map(stripCaretHighlight);
|
|
157872
|
+
}
|
|
157873
|
+
renderInput(width) {
|
|
157858
157874
|
const value = this.getValue();
|
|
157859
157875
|
if (this.mask && value) {
|
|
157860
157876
|
this.setValue("*".repeat(value.length));
|
|
@@ -157876,6 +157892,8 @@ var PromptEditor = class extends Editor {
|
|
|
157876
157892
|
placeholder;
|
|
157877
157893
|
promptTheme;
|
|
157878
157894
|
onEscape;
|
|
157895
|
+
/** Read at render time so terminal focus changes need no state plumbing. */
|
|
157896
|
+
isTerminalFocused = () => true;
|
|
157879
157897
|
constructor(ui, placeholder, promptTheme) {
|
|
157880
157898
|
super(ui, promptTheme.editor, { paddingX: 1 });
|
|
157881
157899
|
this.placeholder = placeholder;
|
|
@@ -157889,6 +157907,10 @@ var PromptEditor = class extends Editor {
|
|
|
157889
157907
|
super.handleInput(data);
|
|
157890
157908
|
}
|
|
157891
157909
|
render(width) {
|
|
157910
|
+
const lines = this.renderEditor(width);
|
|
157911
|
+
return this.isTerminalFocused() ? lines : lines.map(stripCaretHighlight);
|
|
157912
|
+
}
|
|
157913
|
+
renderEditor(width) {
|
|
157892
157914
|
const lines = super.render(width);
|
|
157893
157915
|
if (this.getText() || !this.placeholder) return lines;
|
|
157894
157916
|
const cursor = "\x1B[7m \x1B[0m";
|
|
@@ -157900,7 +157922,9 @@ var PromptEditor = class extends Editor {
|
|
|
157900
157922
|
function promptText(ui, host, theme, options) {
|
|
157901
157923
|
return new Promise((resolve) => {
|
|
157902
157924
|
const placeholder = options.placeholder ? sanitizeTerminalText(options.placeholder, { preserveSgr: false }) : void 0;
|
|
157925
|
+
const isTerminalFocused = options.isTerminalFocused ?? (() => true);
|
|
157903
157926
|
const input = options.mask === true ? new PromptInput(true, placeholder, theme) : new PromptEditor(ui, placeholder, theme);
|
|
157927
|
+
input.isTerminalFocused = isTerminalFocused;
|
|
157904
157928
|
if (options.initialValue) if (input instanceof PromptEditor) input.setText(options.initialValue);
|
|
157905
157929
|
else input.setValue(options.initialValue);
|
|
157906
157930
|
const dialog = new TextPromptDialog(sanitizeTerminalText(options.title, { preserveSgr: false }), sanitizeTerminalText(options.prompt, { preserveSgr: false }), input, theme, sanitizeTerminalText(options.help ?? "Enter confirm · Esc cancel", { preserveSgr: false }));
|
|
@@ -158418,8 +158442,11 @@ var PlanEditor = class extends Editor {
|
|
|
158418
158442
|
planColor = (text) => text;
|
|
158419
158443
|
planHint = "Research and plan before making changes";
|
|
158420
158444
|
hintColor = (text) => text;
|
|
158445
|
+
/** Read at render time so terminal focus changes need no state plumbing. */
|
|
158446
|
+
isTerminalFocused = () => true;
|
|
158421
158447
|
render(width) {
|
|
158422
|
-
|
|
158448
|
+
let lines = super.render(width);
|
|
158449
|
+
if (!this.isTerminalFocused()) lines = lines.map(stripCaretHighlight);
|
|
158423
158450
|
if (!this.planEnabled || width < 4 || !lines[0]) return lines;
|
|
158424
158451
|
const label = width >= 10 ? " Plan ──" : "Plan";
|
|
158425
158452
|
const prefixWidth = width - visibleWidth(label);
|
|
@@ -160673,9 +160700,9 @@ function permissionRuleContent(input) {
|
|
|
160673
160700
|
if (value) return value;
|
|
160674
160701
|
}
|
|
160675
160702
|
}
|
|
160676
|
-
function defaultPermissionChoices(toolName, input) {
|
|
160703
|
+
function defaultPermissionChoices(toolName, input, approvalMode) {
|
|
160677
160704
|
const ruleContent = permissionRuleContent(input);
|
|
160678
|
-
|
|
160705
|
+
const choices = [
|
|
160679
160706
|
{
|
|
160680
160707
|
value: "allow_once",
|
|
160681
160708
|
label: "Allow once",
|
|
@@ -160717,6 +160744,7 @@ function defaultPermissionChoices(toolName, input) {
|
|
|
160717
160744
|
}
|
|
160718
160745
|
}
|
|
160719
160746
|
];
|
|
160747
|
+
return approvalMode === "user-once" ? choices.filter((choice) => choice.value === "allow_once" || choice.value === "deny") : choices;
|
|
160720
160748
|
}
|
|
160721
160749
|
function planText$1(input) {
|
|
160722
160750
|
if (typeof input === "string") return input.trim() || void 0;
|
|
@@ -161760,6 +161788,7 @@ async function requestAppServer(request) {
|
|
|
161760
161788
|
if (envelope?.error) throw new AppServerRequestError(envelope.error.message?.trim() || "App-server request failed.", envelope.error.code, envelope.error.data);
|
|
161761
161789
|
if (code !== 0) throw processError(stderr.trim() || `App-server exited with status ${code}.`, code);
|
|
161762
161790
|
if (!envelope || !("result" in envelope)) throw new Error(stderr.trim() || "App-server did not return a response envelope.");
|
|
161791
|
+
if (stderr) request.onStderr?.(stderr);
|
|
161763
161792
|
return envelope.result;
|
|
161764
161793
|
} finally {
|
|
161765
161794
|
if (forceTerminationTimer) clearTimeout(forceTerminationTimer);
|
|
@@ -162227,7 +162256,6 @@ var TurnNotifier = class {
|
|
|
162227
162256
|
settings;
|
|
162228
162257
|
active = false;
|
|
162229
162258
|
focusReporting = false;
|
|
162230
|
-
focusReportingRequired;
|
|
162231
162259
|
terminalFocus = "unknown";
|
|
162232
162260
|
terminalUnavailable = false;
|
|
162233
162261
|
constructor(options) {
|
|
@@ -162236,7 +162264,6 @@ var TurnNotifier = class {
|
|
|
162236
162264
|
this.platform = options.platform ?? process.platform;
|
|
162237
162265
|
this.nativeNotify = options.nativeNotify ?? ((platform, title, body) => sendNativeNotification(platform, title, body, this.env));
|
|
162238
162266
|
this.settings = options.settings ?? notificationSettings(this.env);
|
|
162239
|
-
this.focusReportingRequired = options.focusReportingRequired === true;
|
|
162240
162267
|
}
|
|
162241
162268
|
start() {
|
|
162242
162269
|
this.active = true;
|
|
@@ -162259,26 +162286,25 @@ var TurnNotifier = class {
|
|
|
162259
162286
|
};
|
|
162260
162287
|
}
|
|
162261
162288
|
setSettings(settings) {
|
|
162262
|
-
if (this.settings.condition !== settings.condition) this.terminalFocus = "unknown";
|
|
162263
162289
|
this.settings = { ...settings };
|
|
162264
162290
|
this.syncFocusReporting();
|
|
162265
162291
|
}
|
|
162266
|
-
setFocusReportingRequired(required) {
|
|
162267
|
-
if (this.focusReportingRequired === required) return;
|
|
162268
|
-
this.focusReportingRequired = required;
|
|
162269
|
-
this.syncFocusReporting();
|
|
162270
|
-
}
|
|
162271
162292
|
handleInput(data) {
|
|
162272
162293
|
if (data === focusIn) {
|
|
162273
|
-
this.
|
|
162294
|
+
this.setFocusState("focused");
|
|
162274
162295
|
return true;
|
|
162275
162296
|
}
|
|
162276
162297
|
if (data === focusOut) {
|
|
162277
|
-
this.
|
|
162298
|
+
this.setFocusState("unfocused");
|
|
162278
162299
|
return true;
|
|
162279
162300
|
}
|
|
162280
162301
|
return false;
|
|
162281
162302
|
}
|
|
162303
|
+
setFocusState(state) {
|
|
162304
|
+
if (this.terminalFocus === state) return;
|
|
162305
|
+
this.terminalFocus = state;
|
|
162306
|
+
this.options.onFocusChange?.(state);
|
|
162307
|
+
}
|
|
162282
162308
|
async notify(kind, detail = "") {
|
|
162283
162309
|
if (this.settings.method === "off" || this.settings.condition === "unfocused" && this.terminalFocus === "focused") return false;
|
|
162284
162310
|
const fallback = kind === "completed" ? "Agent turn complete" : "Agent turn failed";
|
|
@@ -162321,7 +162347,7 @@ var TurnNotifier = class {
|
|
|
162321
162347
|
}
|
|
162322
162348
|
}
|
|
162323
162349
|
syncFocusReporting() {
|
|
162324
|
-
if (!this.active
|
|
162350
|
+
if (!this.active) {
|
|
162325
162351
|
this.disableFocusReporting();
|
|
162326
162352
|
return;
|
|
162327
162353
|
}
|
|
@@ -162428,6 +162454,49 @@ function emitSessionTerminalTitle(stream, title) {
|
|
|
162428
162454
|
stream.write(safeTitle ? `\x1b]0;${SESSION_TITLE_PREFIX}${safeTitle}\x07` : "\x1B]0;\x07");
|
|
162429
162455
|
}
|
|
162430
162456
|
//#endregion
|
|
162457
|
+
//#region packages/zcode-tui/src/shortcuts.ts
|
|
162458
|
+
const modes = [
|
|
162459
|
+
"build",
|
|
162460
|
+
"edit",
|
|
162461
|
+
"guarded",
|
|
162462
|
+
"yolo"
|
|
162463
|
+
];
|
|
162464
|
+
function normalizedMode(mode, fallback = "build") {
|
|
162465
|
+
const candidate = mode;
|
|
162466
|
+
return modes.includes(candidate) ? candidate : fallback;
|
|
162467
|
+
}
|
|
162468
|
+
function nextMode(currentMode) {
|
|
162469
|
+
const currentIndex = modes.indexOf(currentMode);
|
|
162470
|
+
return modes[(currentIndex + 1) % modes.length] ?? modes[0];
|
|
162471
|
+
}
|
|
162472
|
+
function settingTargetForCommand(input) {
|
|
162473
|
+
const command = /^\/([^\s]+)/u.exec(input.trim())?.[1]?.toLowerCase();
|
|
162474
|
+
if (command === "mode") return "mode";
|
|
162475
|
+
if (command === "model") return "model";
|
|
162476
|
+
if (command === "effort" || command === "variant") return "effort";
|
|
162477
|
+
}
|
|
162478
|
+
function appliesToSetting(target, field) {
|
|
162479
|
+
return target === void 0 || target === field;
|
|
162480
|
+
}
|
|
162481
|
+
function nextPickerCommand(picker, currentValue) {
|
|
162482
|
+
if (picker.items.length < 2) return void 0;
|
|
162483
|
+
const currentIndex = picker.items.findIndex((item) => item.value === currentValue);
|
|
162484
|
+
const nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % picker.items.length;
|
|
162485
|
+
return picker.items[nextIndex]?.command;
|
|
162486
|
+
}
|
|
162487
|
+
/** Like nextPickerCommand but returns the item value (model id) directly. */
|
|
162488
|
+
function nextPickerValue(picker, currentValue) {
|
|
162489
|
+
if (picker.items.length < 2) return void 0;
|
|
162490
|
+
const currentIndex = picker.items.findIndex((item) => item.value === currentValue);
|
|
162491
|
+
const nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % picker.items.length;
|
|
162492
|
+
return picker.items[nextIndex]?.value;
|
|
162493
|
+
}
|
|
162494
|
+
function transcriptPageDirection(data) {
|
|
162495
|
+
if (isKeyRelease(data)) return void 0;
|
|
162496
|
+
if (matchesKey(data, "pageUp") || matchesKey(data, "left")) return -1;
|
|
162497
|
+
if (matchesKey(data, "pageDown") || matchesKey(data, "right")) return 1;
|
|
162498
|
+
}
|
|
162499
|
+
//#endregion
|
|
162431
162500
|
//#region packages/zcode-tui/src/selectors.ts
|
|
162432
162501
|
function pickerRequest(input, commands) {
|
|
162433
162502
|
const match = /^\/([^\s]+)(?:\s+(.*))?$/u.exec(input.trim());
|
|
@@ -162442,18 +162511,10 @@ function isModePickerRequest(input) {
|
|
|
162442
162511
|
return pickerRequest(input, /* @__PURE__ */ new Set(["mode"]));
|
|
162443
162512
|
}
|
|
162444
162513
|
function modePicker(currentMode, availableModes) {
|
|
162445
|
-
const items = (availableModes?.length ? availableModes :
|
|
162446
|
-
"build",
|
|
162447
|
-
"edit",
|
|
162448
|
-
"yolo"
|
|
162449
|
-
]).filter((mode) => [
|
|
162450
|
-
"build",
|
|
162451
|
-
"edit",
|
|
162452
|
-
"yolo"
|
|
162453
|
-
].includes(mode)).map((mode) => ({
|
|
162514
|
+
const items = (availableModes?.length ? availableModes : modes).filter((mode) => modes.includes(mode)).map((mode) => ({
|
|
162454
162515
|
value: mode,
|
|
162455
162516
|
label: mode.charAt(0).toUpperCase() + mode.slice(1),
|
|
162456
|
-
description: [mode === "build" ? "Ask before changes" : mode === "edit" ? "Edit automatically" : "Full access", mode === currentMode ? "current" : void 0].filter(Boolean).join(" · "),
|
|
162517
|
+
description: [mode === "build" ? "Ask before changes" : mode === "edit" ? "Edit automatically" : mode === "guarded" ? "Autonomous · ask before risky commands" : "Full access", mode === currentMode ? "current" : void 0].filter(Boolean).join(" · "),
|
|
162457
162518
|
command: `/mode ${mode}`
|
|
162458
162519
|
}));
|
|
162459
162520
|
const currentIndex = items.findIndex((item) => item.value === currentMode);
|
|
@@ -163473,7 +163534,7 @@ var DynamicWorkflows = class {
|
|
|
163473
163534
|
return operation;
|
|
163474
163535
|
}
|
|
163475
163536
|
};
|
|
163476
|
-
function safe(value) {
|
|
163537
|
+
function safe$1(value) {
|
|
163477
163538
|
return sanitizeTerminalText(typeof value === "string" ? value : "", { preserveSgr: false }).slice(0, 2e3);
|
|
163478
163539
|
}
|
|
163479
163540
|
function workflowRunDetail(run) {
|
|
@@ -163481,18 +163542,290 @@ function workflowRunDetail(run) {
|
|
|
163481
163542
|
const actors = Array.isArray(run.actors) ? run.actors.filter(isRecord) : [];
|
|
163482
163543
|
const artifacts = Array.isArray(run.artifacts) ? run.artifacts.filter(isRecord) : [];
|
|
163483
163544
|
const usage = isRecord(run.usage) ? run.usage : void 0;
|
|
163484
|
-
const lines = [safe(run.label) || safe(run.runId), `Status: ${safe(run.status) || "unknown"}${run.stopReason ? ` · ${safe(run.stopReason)}` : ""}`];
|
|
163545
|
+
const lines = [safe$1(run.label) || safe$1(run.runId), `Status: ${safe$1(run.status) || "unknown"}${run.stopReason ? ` · ${safe$1(run.stopReason)}` : ""}`];
|
|
163485
163546
|
if (run.progressIncomplete === true) lines.push("Progress is incomplete. Use /dwf list for runtime status.");
|
|
163486
163547
|
if (nodes) lines.push(`Steps: ${nodes.filter((node) => node.phase === "settled").length}/${nodes.length} observed steps settled`);
|
|
163487
163548
|
if (typeof usage?.spentTokens === "number") lines.push(`Tokens: ${usage.spentTokens.toLocaleString()}`);
|
|
163488
163549
|
if (run.resumable === true) lines.push("This run can be resumed.");
|
|
163489
|
-
|
|
163490
|
-
if (
|
|
163491
|
-
if (
|
|
163492
|
-
if (
|
|
163550
|
+
const concurrency = isRecord(run.concurrency) ? run.concurrency : void 0;
|
|
163551
|
+
if (concurrency) lines.push(`Concurrency: ${concurrency.cap} shared · ${concurrency.limit ?? concurrency.ceiling} run limit`);
|
|
163552
|
+
else if (typeof run.concurrencyCeiling === "number") lines.push(`Concurrency: default ${run.concurrencyCeiling}`);
|
|
163553
|
+
if (typeof run.subagentModel === "string") lines.push(`Subagent default model: ${safe$1(run.subagentModel)}`);
|
|
163554
|
+
if (actors.length) lines.push("", "Agents", ...actors.slice(0, 12).map((actor) => [
|
|
163555
|
+
safe$1(actor.name) || safe$1(actor.sessionId) || "Agent",
|
|
163556
|
+
safe$1(actor.status),
|
|
163557
|
+
safe$1(actor.model) || safe$1(run.subagentModel) || "session model"
|
|
163558
|
+
].filter(Boolean).join(" · ")));
|
|
163559
|
+
if (artifacts.length) lines.push("", "Artifacts", ...artifacts.slice(0, 12).map((artifact) => safe$1(artifact.title) || safe$1(artifact.artifactId) || safe$1(artifact.id)));
|
|
163560
|
+
if (asString(run.error)) lines.push("", `Error: ${safe$1(run.error)}`);
|
|
163561
|
+
if (asString(run.resultPreview)) lines.push("", safe$1(run.resultPreview));
|
|
163493
163562
|
return lines.join("\n");
|
|
163494
163563
|
}
|
|
163495
163564
|
//#endregion
|
|
163565
|
+
//#region packages/zcode-tui/src/workflow-management.ts
|
|
163566
|
+
function safe(value) {
|
|
163567
|
+
return sanitizeTerminalText(asString(value) ?? "", { preserveSgr: false }).slice(0, 2e3);
|
|
163568
|
+
}
|
|
163569
|
+
function workflowAdjustableSettings(toolName, input) {
|
|
163570
|
+
if (toolName !== "CreateWorkflow" && toolName !== "AmendWorkflow") return void 0;
|
|
163571
|
+
if (!isRecord(input) || !isRecord(input.adjustable_settings)) return void 0;
|
|
163572
|
+
return typeof input.adjustable_settings.subagent_model === "boolean" ? input.adjustable_settings : void 0;
|
|
163573
|
+
}
|
|
163574
|
+
function workflowSettingsSummary(input, adjustment = {}) {
|
|
163575
|
+
const settings = isRecord(input.adjustable_settings) ? input.adjustable_settings : {};
|
|
163576
|
+
const concurrency = adjustment.max_concurrency !== void 0 ? adjustment.max_concurrency : input.max_concurrency;
|
|
163577
|
+
const model = adjustment.subagent_model !== void 0 ? adjustment.subagent_model : input.subagent_model;
|
|
163578
|
+
const defaultConcurrency = typeof settings.concurrency_ceiling === "number" ? ` (${settings.concurrency_ceiling})` : "";
|
|
163579
|
+
return [
|
|
163580
|
+
`Concurrency: ${typeof concurrency === "number" ? concurrency : `default${defaultConcurrency}`}`,
|
|
163581
|
+
`Subagent default model: ${safe(model) || "session model"}`,
|
|
163582
|
+
...isRecord(input.model_bindings) && Object.keys(input.model_bindings).length ? ["Models explicitly named in the script remain unchanged.", ...Object.entries(input.model_bindings).slice(0, 12).map(([name, reference]) => `${safe(name)} → ${safe(reference)}`)] : []
|
|
163583
|
+
].join("\n");
|
|
163584
|
+
}
|
|
163585
|
+
async function promptWorkflowConcurrency(dialogs, signal) {
|
|
163586
|
+
while (!signal?.aborted && dialogs.isCurrent()) {
|
|
163587
|
+
const value = await dialogs.prompt({
|
|
163588
|
+
title: "Workflow concurrency",
|
|
163589
|
+
prompt: "Enter a positive integer, or default to restore the runtime default.",
|
|
163590
|
+
signal
|
|
163591
|
+
});
|
|
163592
|
+
if (value === null || signal?.aborted || !dialogs.isCurrent()) return void 0;
|
|
163593
|
+
const trimmed = value.trim();
|
|
163594
|
+
if (trimmed.toLowerCase() === "default") return null;
|
|
163595
|
+
const concurrency = Number(trimmed);
|
|
163596
|
+
if (/^[0-9]+$/u.test(trimmed) && Number.isSafeInteger(concurrency) && concurrency > 0) return concurrency;
|
|
163597
|
+
dialogs.notice("Enter a positive whole number, or default.", "warning");
|
|
163598
|
+
}
|
|
163599
|
+
}
|
|
163600
|
+
async function requestWorkflowApproval(request, dialogs, preview, signal) {
|
|
163601
|
+
const input = isRecord(request.input) ? request.input : {};
|
|
163602
|
+
const settings = workflowAdjustableSettings(String(request.toolName), input);
|
|
163603
|
+
const adjustment = {};
|
|
163604
|
+
while (!signal?.aborted && dialogs.isCurrent()) {
|
|
163605
|
+
const content = new Container();
|
|
163606
|
+
content.addChild(new Text(workflowSettingsSummary(input, adjustment), 0, 0));
|
|
163607
|
+
if (preview) content.addChild(preview);
|
|
163608
|
+
const choice = await dialogs.choose({
|
|
163609
|
+
title: `Approve ${safe(request.toolName)}`,
|
|
163610
|
+
prompt: "Review settings before allowing this workflow.",
|
|
163611
|
+
content,
|
|
163612
|
+
signal,
|
|
163613
|
+
numberShortcuts: true,
|
|
163614
|
+
filterMode: "substring",
|
|
163615
|
+
items: [
|
|
163616
|
+
{
|
|
163617
|
+
value: "allow",
|
|
163618
|
+
label: "Allow once",
|
|
163619
|
+
description: "Apply these settings to this workflow only"
|
|
163620
|
+
},
|
|
163621
|
+
{
|
|
163622
|
+
value: "deny",
|
|
163623
|
+
label: "Deny"
|
|
163624
|
+
},
|
|
163625
|
+
{
|
|
163626
|
+
value: "concurrency",
|
|
163627
|
+
label: "Change concurrency"
|
|
163628
|
+
},
|
|
163629
|
+
...settings?.subagent_model === true ? [{
|
|
163630
|
+
value: "model",
|
|
163631
|
+
label: "Change default model"
|
|
163632
|
+
}] : []
|
|
163633
|
+
]
|
|
163634
|
+
});
|
|
163635
|
+
if (!choice || choice.value === "deny" || signal?.aborted || !dialogs.isCurrent()) break;
|
|
163636
|
+
if (choice.value === "allow") return {
|
|
163637
|
+
decision: "allow",
|
|
163638
|
+
...Object.keys(adjustment).length ? { inputAdjustments: adjustment } : {}
|
|
163639
|
+
};
|
|
163640
|
+
if (choice.value === "concurrency") {
|
|
163641
|
+
const value = await promptWorkflowConcurrency(dialogs, signal);
|
|
163642
|
+
if (value !== void 0) adjustment.max_concurrency = value;
|
|
163643
|
+
} else if (choice.value === "model") {
|
|
163644
|
+
const models = (await dialogs.models()).filter((model) => !isRecord(model) || !model.disabledReason);
|
|
163645
|
+
if (signal?.aborted || !dialogs.isCurrent()) break;
|
|
163646
|
+
const selected = await dialogs.choose({
|
|
163647
|
+
title: "Workflow default model",
|
|
163648
|
+
prompt: "Explicit per-agent models in the script are not overridden.",
|
|
163649
|
+
signal,
|
|
163650
|
+
filterMode: "substring",
|
|
163651
|
+
items: [{
|
|
163652
|
+
value: "default",
|
|
163653
|
+
label: "Session model",
|
|
163654
|
+
payload: null
|
|
163655
|
+
}, ...modelPicker(models).items.map((item) => ({
|
|
163656
|
+
...item,
|
|
163657
|
+
payload: item.value
|
|
163658
|
+
}))]
|
|
163659
|
+
});
|
|
163660
|
+
if (selected && !signal?.aborted && dialogs.isCurrent()) adjustment.subagent_model = typeof selected.payload === "string" ? selected.payload : null;
|
|
163661
|
+
}
|
|
163662
|
+
}
|
|
163663
|
+
return {
|
|
163664
|
+
decision: "deny",
|
|
163665
|
+
reason: "Workflow approval cancelled"
|
|
163666
|
+
};
|
|
163667
|
+
}
|
|
163668
|
+
function workflowActionMessage(result, success) {
|
|
163669
|
+
if (!isRecord(result)) return "Workflow operation returned an invalid result.";
|
|
163670
|
+
if (result.ok === true) return `${success}${result.runId ? ` · ${safe(result.runId)}` : ""}${result.path ? ` · ${safe(result.path)}` : ""}${result.shadowing ? ` · ${safe(result.shadowing)}` : ""}`;
|
|
163671
|
+
return `Workflow operation rejected: ${safe(result.reason) || "unknown"}${result.message || result.detail ? ` · ${safe(result.message ?? result.detail)}` : ""}`;
|
|
163672
|
+
}
|
|
163673
|
+
async function retuneWorkflow(runId, adapter, dialogs) {
|
|
163674
|
+
const value = await promptWorkflowConcurrency(dialogs);
|
|
163675
|
+
if (value === void 0 || !dialogs.isCurrent() || !adapter.retuneWorkflowConcurrency) return;
|
|
163676
|
+
if ((await dialogs.choose({
|
|
163677
|
+
title: "Apply concurrency",
|
|
163678
|
+
prompt: "Changes only the live run. It will not stop, restart, or replace the workflow.",
|
|
163679
|
+
items: [{
|
|
163680
|
+
value: "apply",
|
|
163681
|
+
label: `Apply ${value === null ? "default concurrency" : `concurrency ${value}`}`
|
|
163682
|
+
}, {
|
|
163683
|
+
value: "cancel",
|
|
163684
|
+
label: "Cancel"
|
|
163685
|
+
}]
|
|
163686
|
+
}))?.value !== "apply" || !dialogs.isCurrent()) return;
|
|
163687
|
+
const result = await adapter.retuneWorkflowConcurrency({
|
|
163688
|
+
runId,
|
|
163689
|
+
maxConcurrency: value
|
|
163690
|
+
});
|
|
163691
|
+
if (dialogs.isCurrent()) dialogs.notice(workflowActionMessage(result, "Workflow concurrency updated"), isRecord(result) && result.ok === true ? "muted" : "warning");
|
|
163692
|
+
}
|
|
163693
|
+
async function saveWorkflow(run, adapter, dialogs) {
|
|
163694
|
+
if (!adapter.saveWorkflowRun) return;
|
|
163695
|
+
const name = await dialogs.prompt({
|
|
163696
|
+
title: "Save workflow",
|
|
163697
|
+
prompt: "Name: up to 64 letters, digits, dots, underscores or hyphens; no .."
|
|
163698
|
+
});
|
|
163699
|
+
if (name === null || !dialogs.isCurrent()) return;
|
|
163700
|
+
const trimmed = name.trim();
|
|
163701
|
+
if (!/^[A-Za-z0-9_.-]{1,64}$/u.test(trimmed) || trimmed.includes("..")) {
|
|
163702
|
+
dialogs.notice("Invalid workflow name. Nothing was saved.", "warning");
|
|
163703
|
+
return;
|
|
163704
|
+
}
|
|
163705
|
+
const scope = await dialogs.choose({
|
|
163706
|
+
title: "Save workflow scope",
|
|
163707
|
+
prompt: "Choose where this reusable definition is stored.",
|
|
163708
|
+
items: [{
|
|
163709
|
+
value: "project",
|
|
163710
|
+
label: "This project",
|
|
163711
|
+
description: ".zcode/workflows"
|
|
163712
|
+
}, {
|
|
163713
|
+
value: "global",
|
|
163714
|
+
label: "All projects",
|
|
163715
|
+
description: "~/.zcode/workflows"
|
|
163716
|
+
}]
|
|
163717
|
+
});
|
|
163718
|
+
if (!scope || !dialogs.isCurrent()) return;
|
|
163719
|
+
const description = await dialogs.prompt({
|
|
163720
|
+
title: "Workflow description",
|
|
163721
|
+
prompt: "Describe what this workflow does.",
|
|
163722
|
+
initialValue: safe(run.label)
|
|
163723
|
+
});
|
|
163724
|
+
if (!description?.trim() || !dialogs.isCurrent()) return;
|
|
163725
|
+
const input = {
|
|
163726
|
+
runId: String(run.runId),
|
|
163727
|
+
name: trimmed,
|
|
163728
|
+
scope: scope.value,
|
|
163729
|
+
description: description.trim()
|
|
163730
|
+
};
|
|
163731
|
+
let result = await adapter.saveWorkflowRun(input);
|
|
163732
|
+
if (!dialogs.isCurrent()) return;
|
|
163733
|
+
if (isRecord(result) && result.reason === "target_exists") {
|
|
163734
|
+
if ((await dialogs.choose({
|
|
163735
|
+
title: "Replace saved workflow?",
|
|
163736
|
+
prompt: safe(result.path),
|
|
163737
|
+
items: [{
|
|
163738
|
+
value: "cancel",
|
|
163739
|
+
label: "Keep existing definition"
|
|
163740
|
+
}, {
|
|
163741
|
+
value: "overwrite",
|
|
163742
|
+
label: "Replace definition",
|
|
163743
|
+
description: "Overwrite the existing saved script"
|
|
163744
|
+
}]
|
|
163745
|
+
}))?.value !== "overwrite" || !dialogs.isCurrent()) return;
|
|
163746
|
+
result = await adapter.saveWorkflowRun({
|
|
163747
|
+
...input,
|
|
163748
|
+
overwrite: true
|
|
163749
|
+
});
|
|
163750
|
+
}
|
|
163751
|
+
if (dialogs.isCurrent()) dialogs.notice(workflowActionMessage(result, "Workflow saved"), isRecord(result) && result.ok === true ? "muted" : "warning");
|
|
163752
|
+
}
|
|
163753
|
+
async function showSavedWorkflows(adapter, dialogs) {
|
|
163754
|
+
if (!adapter.listSavedWorkflows || !adapter.readSavedWorkflow || !adapter.startSavedWorkflow) {
|
|
163755
|
+
dialogs.notice("Saved workflows are unavailable in this runtime.", "warning");
|
|
163756
|
+
return;
|
|
163757
|
+
}
|
|
163758
|
+
const listed = await adapter.listSavedWorkflows();
|
|
163759
|
+
if (!dialogs.isCurrent()) return;
|
|
163760
|
+
if (!isRecord(listed) || !Array.isArray(listed.workflows)) throw new Error("Saved workflow list is invalid.");
|
|
163761
|
+
const workflows = listed.workflows.filter(isRecord).filter((item) => typeof item.name === "string" && (item.scope === "project" || item.scope === "global"));
|
|
163762
|
+
if (Array.isArray(listed.invalid) && listed.invalid.length) dialogs.notice(`${listed.invalid.length} saved definitions could not be loaded. Fix their source files and retry.`, "warning");
|
|
163763
|
+
if (!workflows.length) {
|
|
163764
|
+
dialogs.notice("No saved workflows. Use /workflows to save a run first.", "muted");
|
|
163765
|
+
return;
|
|
163766
|
+
}
|
|
163767
|
+
const choice = await dialogs.choose({
|
|
163768
|
+
title: "Saved workflows",
|
|
163769
|
+
prompt: "Choose a definition to run again. This starts a new run, not a progress replay.",
|
|
163770
|
+
items: workflows.map((item, index) => ({
|
|
163771
|
+
value: String(index),
|
|
163772
|
+
label: `${safe(item.name)} · ${item.scope}`,
|
|
163773
|
+
description: safe(item.description),
|
|
163774
|
+
payload: item
|
|
163775
|
+
}))
|
|
163776
|
+
});
|
|
163777
|
+
if (!choice || !isRecord(choice.payload) || !dialogs.isCurrent()) return;
|
|
163778
|
+
const input = {
|
|
163779
|
+
name: String(choice.payload.name),
|
|
163780
|
+
scope: choice.payload.scope
|
|
163781
|
+
};
|
|
163782
|
+
const definition = await adapter.readSavedWorkflow(input);
|
|
163783
|
+
if (!dialogs.isCurrent()) return;
|
|
163784
|
+
if (!isRecord(definition) || definition.ok !== true) {
|
|
163785
|
+
dialogs.notice(workflowActionMessage(definition, ""), "warning");
|
|
163786
|
+
return;
|
|
163787
|
+
}
|
|
163788
|
+
const meta = isRecord(definition.meta) ? definition.meta : {};
|
|
163789
|
+
const declarations = isRecord(meta.args) ? meta.args : {};
|
|
163790
|
+
const parameterHelp = Object.entries(declarations).slice(0, 32).map(([name, declaration]) => {
|
|
163791
|
+
const details = isRecord(declaration) ? declaration : {};
|
|
163792
|
+
return `${safe(name)}: ${safe(details.type)}${details.required === true ? " (required)" : ""}${details.description ? ` · ${safe(details.description)}` : ""}`;
|
|
163793
|
+
}).join("\n");
|
|
163794
|
+
let args;
|
|
163795
|
+
if (Object.keys(declarations).length) while (dialogs.isCurrent()) {
|
|
163796
|
+
const text = await dialogs.prompt({
|
|
163797
|
+
title: "Workflow arguments",
|
|
163798
|
+
prompt: `${parameterHelp}\nEnter a JSON object. {} uses declared defaults.`,
|
|
163799
|
+
initialValue: "{}"
|
|
163800
|
+
});
|
|
163801
|
+
if (text === null || !dialogs.isCurrent()) return;
|
|
163802
|
+
try {
|
|
163803
|
+
const value = JSON.parse(text);
|
|
163804
|
+
if (!isRecord(value)) throw new Error("Arguments must be a JSON object.");
|
|
163805
|
+
args = value;
|
|
163806
|
+
break;
|
|
163807
|
+
} catch {
|
|
163808
|
+
dialogs.notice("Enter a valid JSON object, such as {}.", "warning");
|
|
163809
|
+
}
|
|
163810
|
+
}
|
|
163811
|
+
if ((await dialogs.choose({
|
|
163812
|
+
title: "Run saved workflow",
|
|
163813
|
+
prompt: `${safe(input.name)} · ${input.scope}\nStarts a new run and may consume model credits. Runtime validates parameters and models before execution.`,
|
|
163814
|
+
items: [{
|
|
163815
|
+
value: "cancel",
|
|
163816
|
+
label: "Cancel"
|
|
163817
|
+
}, {
|
|
163818
|
+
value: "run",
|
|
163819
|
+
label: "Run workflow"
|
|
163820
|
+
}]
|
|
163821
|
+
}))?.value !== "run" || !dialogs.isCurrent()) return;
|
|
163822
|
+
const result = await adapter.startSavedWorkflow({
|
|
163823
|
+
...input,
|
|
163824
|
+
...args ? { args } : {}
|
|
163825
|
+
});
|
|
163826
|
+
if (dialogs.isCurrent()) dialogs.notice(workflowActionMessage(result, "Saved workflow started"), isRecord(result) && result.ok === true ? "muted" : "warning");
|
|
163827
|
+
}
|
|
163828
|
+
//#endregion
|
|
163496
163829
|
//#region packages/zcode-tui/src/runtime-context-cache.ts
|
|
163497
163830
|
/** A session-scoped, invalidatable summary of persisted request usage. */
|
|
163498
163831
|
var RuntimeContextCache = class {
|
|
@@ -163768,48 +164101,6 @@ function skillDescription(candidate) {
|
|
|
163768
164101
|
return description ? truncateGraphemes(description, skillDescriptionLimit) : void 0;
|
|
163769
164102
|
}
|
|
163770
164103
|
//#endregion
|
|
163771
|
-
//#region packages/zcode-tui/src/shortcuts.ts
|
|
163772
|
-
const modes = [
|
|
163773
|
-
"build",
|
|
163774
|
-
"edit",
|
|
163775
|
-
"yolo"
|
|
163776
|
-
];
|
|
163777
|
-
function normalizedMode(mode, fallback = "build") {
|
|
163778
|
-
const candidate = mode;
|
|
163779
|
-
return modes.includes(candidate) ? candidate : fallback;
|
|
163780
|
-
}
|
|
163781
|
-
function nextMode(currentMode) {
|
|
163782
|
-
const currentIndex = modes.indexOf(currentMode);
|
|
163783
|
-
return modes[(currentIndex + 1) % modes.length] ?? modes[0];
|
|
163784
|
-
}
|
|
163785
|
-
function settingTargetForCommand(input) {
|
|
163786
|
-
const command = /^\/([^\s]+)/u.exec(input.trim())?.[1]?.toLowerCase();
|
|
163787
|
-
if (command === "mode") return "mode";
|
|
163788
|
-
if (command === "model") return "model";
|
|
163789
|
-
if (command === "effort" || command === "variant") return "effort";
|
|
163790
|
-
}
|
|
163791
|
-
function appliesToSetting(target, field) {
|
|
163792
|
-
return target === void 0 || target === field;
|
|
163793
|
-
}
|
|
163794
|
-
function nextPickerCommand(picker, currentValue) {
|
|
163795
|
-
if (picker.items.length < 2) return void 0;
|
|
163796
|
-
const currentIndex = picker.items.findIndex((item) => item.value === currentValue);
|
|
163797
|
-
const nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % picker.items.length;
|
|
163798
|
-
return picker.items[nextIndex]?.command;
|
|
163799
|
-
}
|
|
163800
|
-
/** Like nextPickerCommand but returns the item value (model id) directly. */
|
|
163801
|
-
function nextPickerValue(picker, currentValue) {
|
|
163802
|
-
if (picker.items.length < 2) return void 0;
|
|
163803
|
-
const currentIndex = picker.items.findIndex((item) => item.value === currentValue);
|
|
163804
|
-
const nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % picker.items.length;
|
|
163805
|
-
return picker.items[nextIndex]?.value;
|
|
163806
|
-
}
|
|
163807
|
-
function transcriptPageDirection(data) {
|
|
163808
|
-
if (isKeyRelease(data)) return void 0;
|
|
163809
|
-
if (matchesKey(data, "pageUp") || matchesKey(data, "left")) return -1;
|
|
163810
|
-
if (matchesKey(data, "pageDown") || matchesKey(data, "right")) return 1;
|
|
163811
|
-
}
|
|
163812
|
-
//#endregion
|
|
163813
164104
|
//#region packages/zcode-tui/src/status-line.ts
|
|
163814
164105
|
var StatusLine = class {
|
|
163815
164106
|
fields = [];
|
|
@@ -166220,6 +166511,16 @@ var ZCodeAltScreen = class extends TuiAltScreen {
|
|
|
166220
166511
|
setCurrentInput(data) {
|
|
166221
166512
|
this.currentInput = data;
|
|
166222
166513
|
}
|
|
166514
|
+
showOverlay(component, options) {
|
|
166515
|
+
if (component instanceof AltScreenSearchComponent) {
|
|
166516
|
+
const render = component.render.bind(component);
|
|
166517
|
+
component.render = (width) => {
|
|
166518
|
+
const lines = render(width);
|
|
166519
|
+
return this.getShowHardwareCursor() ? lines : lines.map(stripCaretHighlight);
|
|
166520
|
+
};
|
|
166521
|
+
}
|
|
166522
|
+
return super.showOverlay(component, options);
|
|
166523
|
+
}
|
|
166223
166524
|
/**
|
|
166224
166525
|
* The terminal can lose visible rows while this process is unfocused even
|
|
166225
166526
|
* though pi-tui's logical frame remains unchanged. Invalidate its
|
|
@@ -166334,6 +166635,7 @@ var ZCodeTui = class {
|
|
|
166334
166635
|
executionStateRevision = 0;
|
|
166335
166636
|
model;
|
|
166336
166637
|
tuiMode;
|
|
166638
|
+
terminalFocus = "unknown";
|
|
166337
166639
|
copyOnSelect = true;
|
|
166338
166640
|
thoughtLevel;
|
|
166339
166641
|
modelOptions;
|
|
@@ -166429,7 +166731,10 @@ var ZCodeTui = class {
|
|
|
166429
166731
|
this.ui = this.createTui(this.tuiMode);
|
|
166430
166732
|
this.notifications = new TurnNotifier({
|
|
166431
166733
|
writeTerminal: (data) => this.ui.terminal.write(data),
|
|
166432
|
-
|
|
166734
|
+
onFocusChange: (state) => {
|
|
166735
|
+
this.terminalFocus = state;
|
|
166736
|
+
this.applyTerminalFocus();
|
|
166737
|
+
}
|
|
166433
166738
|
});
|
|
166434
166739
|
this.status = new StatusLine();
|
|
166435
166740
|
this.turnStatus = new FooterBar();
|
|
@@ -166484,7 +166789,6 @@ var ZCodeTui = class {
|
|
|
166484
166789
|
if (effective !== this.tuiMode) {
|
|
166485
166790
|
this.ui = this.createTui(effective);
|
|
166486
166791
|
this.tuiMode = effective;
|
|
166487
|
-
this.notifications.setFocusReportingRequired(effective === "fullscreen");
|
|
166488
166792
|
this.editor = this.createEditor(this.ui);
|
|
166489
166793
|
}
|
|
166490
166794
|
} catch {}
|
|
@@ -166593,6 +166897,17 @@ var ZCodeTui = class {
|
|
|
166593
166897
|
this.copyOnSelect = enabled;
|
|
166594
166898
|
this.fullscreenAltScreen?.setCopyOnSelect(enabled);
|
|
166595
166899
|
}
|
|
166900
|
+
/**
|
|
166901
|
+
* Mirror terminal focus onto the hardware cursor so multiplexer panes
|
|
166902
|
+
* (tmux/windows-style splits) only show a live cursor in the focused pane;
|
|
166903
|
+
* the state flip also schedules the render that re-evaluates the drawn
|
|
166904
|
+
* carets (editor and prompt inputs read isTerminalFocused at render time).
|
|
166905
|
+
* "unknown" keeps the cursor visible; terminals without focus reports
|
|
166906
|
+
* (mode 1004) never report focus loss in the first place.
|
|
166907
|
+
*/
|
|
166908
|
+
applyTerminalFocus() {
|
|
166909
|
+
this.ui.setShowHardwareCursor(this.terminalFocus !== "unfocused");
|
|
166910
|
+
}
|
|
166596
166911
|
createTui(mode) {
|
|
166597
166912
|
let fullscreenTui;
|
|
166598
166913
|
const terminal = new NotifyingProcessTerminal((data) => {
|
|
@@ -166755,6 +167070,7 @@ var ZCodeTui = class {
|
|
|
166755
167070
|
editor.planEnabled = this.planEnabled;
|
|
166756
167071
|
editor.planColor = this.theme.accent;
|
|
166757
167072
|
editor.hintColor = this.theme.muted;
|
|
167073
|
+
editor.isTerminalFocused = () => this.terminalFocus !== "unfocused";
|
|
166758
167074
|
if (this.options.locale?.startsWith("zh")) editor.planHint = "先调研与规划,再开始修改";
|
|
166759
167075
|
for (const input of [...this.editorHistory].reverse()) editor.addToHistory(input);
|
|
166760
167076
|
const commands = this.autocompleteCommands();
|
|
@@ -166791,7 +167107,6 @@ var ZCodeTui = class {
|
|
|
166791
167107
|
this.ui.stop({ preserveScreen: true });
|
|
166792
167108
|
this.ui = this.createTui(next);
|
|
166793
167109
|
this.tuiMode = next;
|
|
166794
|
-
this.notifications.setFocusReportingRequired(next === "fullscreen");
|
|
166795
167110
|
this.sessionHasContent = hadSessionContent;
|
|
166796
167111
|
this.fullscreenWelcomeVisible = !hadSessionContent;
|
|
166797
167112
|
this.fullscreenHeader.setPhase(hadSessionContent ? "rail" : "welcome");
|
|
@@ -166805,6 +167120,7 @@ var ZCodeTui = class {
|
|
|
166805
167120
|
if (savedDraft) this.editor.setText(savedDraft);
|
|
166806
167121
|
this.ui.requestRender(true);
|
|
166807
167122
|
this.notifications.start();
|
|
167123
|
+
this.applyTerminalFocus();
|
|
166808
167124
|
try {
|
|
166809
167125
|
await writeTuiMode(next);
|
|
166810
167126
|
} catch (error) {
|
|
@@ -166817,7 +167133,6 @@ var ZCodeTui = class {
|
|
|
166817
167133
|
} catch {}
|
|
166818
167134
|
this.ui = previousUi;
|
|
166819
167135
|
this.tuiMode = previousMode;
|
|
166820
|
-
this.notifications.setFocusReportingRequired(previousMode === "fullscreen");
|
|
166821
167136
|
this.sessionHasContent = hadSessionContent;
|
|
166822
167137
|
this.fullscreenWelcomeVisible = previousMode === "fullscreen" ? !hadSessionContent : true;
|
|
166823
167138
|
this.fullscreenHeader.setPhase(hadSessionContent ? "rail" : "welcome");
|
|
@@ -166831,6 +167146,7 @@ var ZCodeTui = class {
|
|
|
166831
167146
|
this.bindInput();
|
|
166832
167147
|
this.focusEditor();
|
|
166833
167148
|
this.notifications.start();
|
|
167149
|
+
this.applyTerminalFocus();
|
|
166834
167150
|
this.ui.requestRender(true);
|
|
166835
167151
|
} catch {}
|
|
166836
167152
|
}
|
|
@@ -166915,6 +167231,7 @@ var ZCodeTui = class {
|
|
|
166915
167231
|
if (!this.stopped) {
|
|
166916
167232
|
this.ui.start();
|
|
166917
167233
|
this.notifications.start();
|
|
167234
|
+
this.applyTerminalFocus();
|
|
166918
167235
|
this.focusEditor();
|
|
166919
167236
|
this.ui.requestRender(true);
|
|
166920
167237
|
}
|
|
@@ -166924,6 +167241,7 @@ var ZCodeTui = class {
|
|
|
166924
167241
|
this.model = access.model;
|
|
166925
167242
|
this.setLoginRequired(false);
|
|
166926
167243
|
this.addNotice(`Model access configured via ${access.configPath}.`, "muted");
|
|
167244
|
+
await this.adoptLoginModel();
|
|
166927
167245
|
} else if (failure) this.addNotice(`Login command failed: ${failure}`, "error");
|
|
166928
167246
|
else if (code !== 0) {
|
|
166929
167247
|
const diagnostic = loginFailureDiagnostic(childStdout, childStderr);
|
|
@@ -166987,7 +167305,8 @@ var ZCodeTui = class {
|
|
|
166987
167305
|
},
|
|
166988
167306
|
{
|
|
166989
167307
|
name: "workflows",
|
|
166990
|
-
description: "Inspect
|
|
167308
|
+
description: "Inspect, tune and save workflow runs",
|
|
167309
|
+
argumentHint: "[list|saved]"
|
|
166991
167310
|
},
|
|
166992
167311
|
{
|
|
166993
167312
|
name: "tasks",
|
|
@@ -167256,6 +167575,16 @@ var ZCodeTui = class {
|
|
|
167256
167575
|
await this.showDynamicWorkflows();
|
|
167257
167576
|
return;
|
|
167258
167577
|
}
|
|
167578
|
+
if (input === "/workflows saved") {
|
|
167579
|
+
try {
|
|
167580
|
+
await showSavedWorkflows(this.options, this.workflowDialogs());
|
|
167581
|
+
await this.dynamicWorkflows.hydrate();
|
|
167582
|
+
this.renderDynamicWorkflow();
|
|
167583
|
+
} catch (error) {
|
|
167584
|
+
this.addNotice(error instanceof Error ? error.message : String(error), "error");
|
|
167585
|
+
}
|
|
167586
|
+
return;
|
|
167587
|
+
}
|
|
167259
167588
|
if (input === "/tasks" || input === "/tasks list") {
|
|
167260
167589
|
await this.showBackgroundTasks();
|
|
167261
167590
|
return;
|
|
@@ -167306,7 +167635,7 @@ var ZCodeTui = class {
|
|
|
167306
167635
|
if (isModePickerRequest(input) && await this.showModePicker()) return;
|
|
167307
167636
|
if (/^\/mode(?:\s|$)/iu.test(input)) {
|
|
167308
167637
|
const mode = input.slice(5).trim().toLowerCase();
|
|
167309
|
-
if (!modes.includes(mode)) this.addNotice("Choose /mode build, edit or yolo. Use /plan on or /plan off for planning.", "warning");
|
|
167638
|
+
if (!modes.includes(mode)) this.addNotice("Choose /mode build, edit, guarded or yolo. Use /plan on or /plan off for planning.", "warning");
|
|
167310
167639
|
else await this.applyModeShortcut(mode, true);
|
|
167311
167640
|
return;
|
|
167312
167641
|
}
|
|
@@ -167424,6 +167753,7 @@ var ZCodeTui = class {
|
|
|
167424
167753
|
if (input.startsWith("/") || !this.options.sendInput) {
|
|
167425
167754
|
const result = await this.options.submitPrompt(input.startsWith("/") ? input : promptInput(runtimeInput, attachments), callOptions);
|
|
167426
167755
|
await this.handleResult(result, true, settingTargetForCommand(input));
|
|
167756
|
+
if (/^\/login\s+\S/iu.test(input) && isRecord(result) && result.loginRequired === false) await this.adoptLoginModel();
|
|
167427
167757
|
accepted = true;
|
|
167428
167758
|
} else {
|
|
167429
167759
|
const preparedInput = promptInput(runtimeInput, attachments);
|
|
@@ -167885,11 +168215,13 @@ var ZCodeTui = class {
|
|
|
167885
168215
|
this.addNotice("Workflow inspection is unavailable in this runtime.", "warning");
|
|
167886
168216
|
return;
|
|
167887
168217
|
}
|
|
168218
|
+
const dialogs = this.workflowDialogs();
|
|
167888
168219
|
await this.dynamicWorkflows.hydrate();
|
|
167889
168220
|
if (this.dynamicWorkflows.error) this.addNotice(this.dynamicWorkflows.error, "warning");
|
|
167890
168221
|
const runs = this.dynamicWorkflows.runs();
|
|
167891
168222
|
if (runs.length === 0) {
|
|
167892
168223
|
this.addNotice("No workflow runs in this session.", "muted");
|
|
168224
|
+
if (this.options.listSavedWorkflows) await showSavedWorkflows(this.options, dialogs);
|
|
167893
168225
|
return;
|
|
167894
168226
|
}
|
|
167895
168227
|
const choice = await this.showChoice({
|
|
@@ -167899,9 +168231,18 @@ var ZCodeTui = class {
|
|
|
167899
168231
|
value: String(run.runId),
|
|
167900
168232
|
label: asString(run.label) || String(run.runId),
|
|
167901
168233
|
description: [run.status, run.resumable === true ? "resumable" : void 0].filter(Boolean).join(" · ")
|
|
167902
|
-
}))
|
|
168234
|
+
})).concat(this.options.listSavedWorkflows ? [{
|
|
168235
|
+
value: "$saved",
|
|
168236
|
+
label: "Saved workflows",
|
|
168237
|
+
description: "Run a reusable definition"
|
|
168238
|
+
}] : [])
|
|
167903
168239
|
});
|
|
167904
|
-
if (!choice) return;
|
|
168240
|
+
if (!choice || !dialogs.isCurrent()) return;
|
|
168241
|
+
if (choice.value === "$saved") {
|
|
168242
|
+
await showSavedWorkflows(this.options, dialogs);
|
|
168243
|
+
await this.dynamicWorkflows.hydrate();
|
|
168244
|
+
return;
|
|
168245
|
+
}
|
|
167905
168246
|
this.selectedDynamicWorkflow = choice.value;
|
|
167906
168247
|
const run = this.dynamicWorkflows.runs().find((run) => run.runId === choice.value);
|
|
167907
168248
|
if (!run) {
|
|
@@ -167914,6 +168255,7 @@ var ZCodeTui = class {
|
|
|
167914
168255
|
const action = await this.showChoice({
|
|
167915
168256
|
title: "Workflow actions",
|
|
167916
168257
|
prompt: "Progress remains visible in the transcript.",
|
|
168258
|
+
filterMode: "substring",
|
|
167917
168259
|
items: [
|
|
167918
168260
|
{
|
|
167919
168261
|
value: "close",
|
|
@@ -167926,15 +168268,30 @@ var ZCodeTui = class {
|
|
|
167926
168268
|
...run.resumable === true ? [{
|
|
167927
168269
|
value: "resume",
|
|
167928
168270
|
label: "Resume workflow"
|
|
168271
|
+
}] : [],
|
|
168272
|
+
...this.options.retuneWorkflowConcurrency && ["pending", "running"].includes(String(run.status)) ? [{
|
|
168273
|
+
value: "concurrency",
|
|
168274
|
+
label: "Adjust concurrency"
|
|
168275
|
+
}] : [],
|
|
168276
|
+
...this.options.saveWorkflowRun ? [{
|
|
168277
|
+
value: "save",
|
|
168278
|
+
label: "Save workflow"
|
|
167929
168279
|
}] : []
|
|
167930
168280
|
]
|
|
167931
168281
|
});
|
|
167932
|
-
if (!action || action.value === "close") return;
|
|
168282
|
+
if (!action || action.value === "close" || !dialogs.isCurrent()) return;
|
|
167933
168283
|
if (!/^[A-Za-z0-9_.:-]+$/u.test(choice.value)) {
|
|
167934
168284
|
this.addNotice("This workflow ID cannot be passed to the runtime command.", "error");
|
|
167935
168285
|
return;
|
|
167936
168286
|
}
|
|
167937
168287
|
try {
|
|
168288
|
+
if (action.value === "concurrency" || action.value === "save") {
|
|
168289
|
+
if (action.value === "concurrency") await retuneWorkflow(choice.value, this.options, dialogs);
|
|
168290
|
+
else await saveWorkflow(run, this.options, dialogs);
|
|
168291
|
+
await this.dynamicWorkflows.hydrate();
|
|
168292
|
+
this.renderDynamicWorkflow();
|
|
168293
|
+
return;
|
|
168294
|
+
}
|
|
167938
168295
|
const result = await this.options.submitPrompt(`/dwf ${action.value} ${choice.value}`, {});
|
|
167939
168296
|
await this.handleResult(result);
|
|
167940
168297
|
await this.dynamicWorkflows.hydrate();
|
|
@@ -168914,6 +169271,7 @@ var ZCodeTui = class {
|
|
|
168914
169271
|
let response;
|
|
168915
169272
|
if (asksUserQuestion) response = await this.requestUserQuestions(request.input, signal);
|
|
168916
169273
|
else if (isExitPlanModeTool(toolName)) response = await this.requestPlanApproval(request.input, signal);
|
|
169274
|
+
else if (workflowAdjustableSettings(toolName, request.input)) response = await requestWorkflowApproval(request, this.workflowDialogs(), this.permissionPreview(toolName, request.input), signal);
|
|
168917
169275
|
else response = await this.requestToolPermission(request, toolName, signal);
|
|
168918
169276
|
const settledElsewhere = signal?.aborted === true && this.turnAbortController?.signal.aborted !== true;
|
|
168919
169277
|
if (tool && !settledElsewhere) {
|
|
@@ -168928,8 +169286,18 @@ var ZCodeTui = class {
|
|
|
168928
169286
|
}
|
|
168929
169287
|
return response;
|
|
168930
169288
|
}
|
|
169289
|
+
workflowDialogs() {
|
|
169290
|
+
const sessionId = this.options.getMainSessionId?.();
|
|
169291
|
+
return {
|
|
169292
|
+
choose: (options) => this.showChoice(options),
|
|
169293
|
+
prompt: (options) => this.showTextPrompt(options),
|
|
169294
|
+
notice: (message, tone) => this.addNotice(message, tone),
|
|
169295
|
+
models: async () => this.options.listModelOptions ? await this.options.listModelOptions() : this.modelOptions,
|
|
169296
|
+
isCurrent: () => sessionId === this.options.getMainSessionId?.()
|
|
169297
|
+
};
|
|
169298
|
+
}
|
|
168931
169299
|
async requestToolPermission(request, toolName, signal) {
|
|
168932
|
-
const items = (Array.isArray(request.options) ? request.options : []).flatMap((option, index) => {
|
|
169300
|
+
const items = (request.approvalMode !== "user-once" && Array.isArray(request.options) ? request.options : []).flatMap((option, index) => {
|
|
168933
169301
|
if (!isRecord(option)) return [];
|
|
168934
169302
|
const response = isRecord(option.response) ? option.response : void 0;
|
|
168935
169303
|
const value = asString(option.optionId) ?? asString(option.kind) ?? String(index);
|
|
@@ -168940,7 +169308,7 @@ var ZCodeTui = class {
|
|
|
168940
169308
|
payload: response
|
|
168941
169309
|
}];
|
|
168942
169310
|
});
|
|
168943
|
-
if (items.length === 0) items.push(...defaultPermissionChoices(toolName, request.input).map((choice) => ({
|
|
169311
|
+
if (items.length === 0) items.push(...defaultPermissionChoices(toolName, request.input, request.approvalMode).map((choice) => ({
|
|
168944
169312
|
value: choice.value,
|
|
168945
169313
|
label: choice.label,
|
|
168946
169314
|
description: choice.description,
|
|
@@ -169266,6 +169634,21 @@ var ZCodeTui = class {
|
|
|
169266
169634
|
await this.applyModeShortcut(normalizedMode(mode));
|
|
169267
169635
|
return true;
|
|
169268
169636
|
}
|
|
169637
|
+
/**
|
|
169638
|
+
* Login writes credentials and the default model behind the running provider
|
|
169639
|
+
* registry, which only re-reads them on refresh. Reload it and move this
|
|
169640
|
+
* session onto the new default, or the next turn starts without a model.
|
|
169641
|
+
*/
|
|
169642
|
+
async adoptLoginModel() {
|
|
169643
|
+
await this.refreshModelOptions();
|
|
169644
|
+
const access = await readConfiguredModelAccess().catch(() => null);
|
|
169645
|
+
if (!access || !this.options.setTransientModel) return;
|
|
169646
|
+
try {
|
|
169647
|
+
await this.handleResult(await this.options.setTransientModel(access.model), false);
|
|
169648
|
+
} catch (error) {
|
|
169649
|
+
this.addNotice(`Could not switch this session to ${access.model}: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
169650
|
+
}
|
|
169651
|
+
}
|
|
169269
169652
|
/** All model selectors re-read the catalog, including after first-run login. */
|
|
169270
169653
|
async refreshModelOptions() {
|
|
169271
169654
|
const load = this.options.reloadModelOptions;
|
|
@@ -170518,7 +170901,10 @@ var ZCodeTui = class {
|
|
|
170518
170901
|
async showTextPrompt(options) {
|
|
170519
170902
|
this.choiceDepth += 1;
|
|
170520
170903
|
try {
|
|
170521
|
-
return await promptText(this.ui, this.choiceHost, this.theme,
|
|
170904
|
+
return await promptText(this.ui, this.choiceHost, this.theme, {
|
|
170905
|
+
...options,
|
|
170906
|
+
isTerminalFocused: () => this.terminalFocus !== "unfocused"
|
|
170907
|
+
});
|
|
170522
170908
|
} finally {
|
|
170523
170909
|
this.choiceDepth = Math.max(0, this.choiceDepth - 1);
|
|
170524
170910
|
if (this.choiceDepth === 0) this.focusEditor();
|
|
@@ -170586,7 +170972,10 @@ var ZCodeTui = class {
|
|
|
170586
170972
|
this.sessionModelIssue = void 0;
|
|
170587
170973
|
try {
|
|
170588
170974
|
const saved = await this.options.readSessionModel?.();
|
|
170589
|
-
if (!isRecord(saved))
|
|
170975
|
+
if (!isRecord(saved)) {
|
|
170976
|
+
if (this.model === "default") this.model = await this.options.readDefaultModel?.() ?? this.model;
|
|
170977
|
+
return;
|
|
170978
|
+
}
|
|
170590
170979
|
if (typeof saved.model === "string") this.model = saved.model;
|
|
170591
170980
|
this.thoughtLevel = asString(saved.thoughtLevel);
|
|
170592
170981
|
if (Array.isArray(saved.effortOptions)) this.effortOptions = saved.effortOptions;
|