zcode-app-cli 3.11.2-23 → 3.11.2-25
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 +13 -0
- package/bin/zcode.js +71 -22
- package/package.json +17 -2
- package/vendor/extraction.json +1 -1
- package/vendor/node_modules/@zcode/tui/dist/index.js +81 -16
- package/vendor/zcode.cjs +2 -2
package/README.md
CHANGED
|
@@ -33,9 +33,22 @@ ZCode desktop app is installed it can import the desktop provider settings
|
|
|
33
33
|
(credentials stay behind a fresh sign-in, like a browser profile import).
|
|
34
34
|
Reopen it anytime with `/setup`; press Esc to skip.
|
|
35
35
|
|
|
36
|
+
## Host integration
|
|
37
|
+
|
|
38
|
+
`zcode-app-cli` is designed to run as a normal child process of a terminal host
|
|
39
|
+
or agent orchestrator. Hosts such as Herdr and Orca can launch the same
|
|
40
|
+
published `zcode` command without depending on private runtime files. The
|
|
41
|
+
launcher uses the host terminal without inserting a second PTY, forwards
|
|
42
|
+
cancellation signals, preserves the runtime exit status, and exposes a small
|
|
43
|
+
set of environment overrides.
|
|
44
|
+
|
|
45
|
+
See [Host integration](./docs/HOST_INTEGRATION.md) for the versioned contract,
|
|
46
|
+
Node.js example, terminal/PTY requirements, and compatibility rules.
|
|
47
|
+
|
|
36
48
|
## Table of contents
|
|
37
49
|
|
|
38
50
|
- [Quick start](#quick-start)
|
|
51
|
+
- [Host integration](#host-integration)
|
|
39
52
|
- [Install and update](#install-and-update)
|
|
40
53
|
- [Architecture](#architecture)
|
|
41
54
|
- [Features](#features)
|
package/bin/zcode.js
CHANGED
|
@@ -690,10 +690,41 @@ var AppServerRequestError = class extends Error {
|
|
|
690
690
|
this.name = "AppServerRequestError";
|
|
691
691
|
}
|
|
692
692
|
};
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
693
|
+
var AppServerProcessError = class extends Error {
|
|
694
|
+
exitCode;
|
|
695
|
+
constructor(message, exitCode) {
|
|
696
|
+
super(message);
|
|
697
|
+
this.exitCode = exitCode;
|
|
698
|
+
this.name = "AppServerProcessError";
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
var AppServerCancellationError = class extends Error {
|
|
702
|
+
exitCode;
|
|
703
|
+
constructor(exitCode) {
|
|
704
|
+
super("App-server request cancelled.");
|
|
705
|
+
this.exitCode = exitCode;
|
|
706
|
+
this.name = "AbortError";
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
function signalExitCode$1(signal) {
|
|
710
|
+
if (!signal) return 1;
|
|
711
|
+
const number = constants.signals[signal];
|
|
712
|
+
return typeof number === "number" ? 128 + number : 1;
|
|
713
|
+
}
|
|
714
|
+
function abortSignalName$1(signal) {
|
|
715
|
+
const reason = signal?.reason;
|
|
716
|
+
return reason === "SIGINT" || reason === "SIGTERM" || reason === "SIGHUP" ? reason : void 0;
|
|
717
|
+
}
|
|
718
|
+
function cancellationError(signal) {
|
|
719
|
+
const signalName = abortSignalName$1(signal);
|
|
720
|
+
if (signalName) return new AppServerCancellationError(signalExitCode$1(signalName));
|
|
721
|
+
return new AppServerCancellationError(130);
|
|
722
|
+
}
|
|
723
|
+
function terminationSignal(signal) {
|
|
724
|
+
return abortSignalName$1(signal) ?? "SIGTERM";
|
|
725
|
+
}
|
|
726
|
+
function processError(message, code) {
|
|
727
|
+
return new AppServerProcessError(message, code);
|
|
697
728
|
}
|
|
698
729
|
async function readBounded(stream, onOverflow) {
|
|
699
730
|
if (!stream) return "";
|
|
@@ -723,7 +754,7 @@ function responseEnvelope(stdout) {
|
|
|
723
754
|
}
|
|
724
755
|
}
|
|
725
756
|
async function requestAppServer(request) {
|
|
726
|
-
if (request.signal?.aborted) throw cancellationError();
|
|
757
|
+
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
727
758
|
const child = spawn(request.transport.command, request.transport.args, {
|
|
728
759
|
cwd: request.transport.cwd,
|
|
729
760
|
env: request.transport.env,
|
|
@@ -748,7 +779,7 @@ async function requestAppServer(request) {
|
|
|
748
779
|
launchError = error;
|
|
749
780
|
finish(1);
|
|
750
781
|
});
|
|
751
|
-
child.once("close", (code) => finish(code ?? 1));
|
|
782
|
+
child.once("close", (code, signal) => finish(code ?? signalExitCode$1(signal)));
|
|
752
783
|
});
|
|
753
784
|
const terminateForOverflow = () => {
|
|
754
785
|
overflow = true;
|
|
@@ -756,7 +787,7 @@ async function requestAppServer(request) {
|
|
|
756
787
|
};
|
|
757
788
|
const onAbort = () => {
|
|
758
789
|
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
759
|
-
child.kill(
|
|
790
|
+
child.kill(terminationSignal(request.signal));
|
|
760
791
|
forceTerminationTimer = setTimeout(() => {
|
|
761
792
|
if (child.exitCode === null && child.signalCode === null) child.kill("SIGKILL");
|
|
762
793
|
}, forceTerminationDelayMilliseconds);
|
|
@@ -776,12 +807,12 @@ async function requestAppServer(request) {
|
|
|
776
807
|
readBounded(child.stdout, terminateForOverflow),
|
|
777
808
|
readBounded(child.stderr, terminateForOverflow)
|
|
778
809
|
]);
|
|
779
|
-
if (request.signal?.aborted) throw cancellationError();
|
|
810
|
+
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
780
811
|
if (overflow) throw new Error(`App-server output exceeded ${maximumOutputBytes} bytes.`);
|
|
781
812
|
if (launchError) throw launchError;
|
|
782
813
|
const envelope = responseEnvelope(stdout);
|
|
783
814
|
if (envelope?.error) throw new AppServerRequestError(envelope.error.message?.trim() || "App-server request failed.", envelope.error.code, envelope.error.data);
|
|
784
|
-
if (code !== 0) throw
|
|
815
|
+
if (code !== 0) throw processError(stderr.trim() || `App-server exited with status ${code}.`, code);
|
|
785
816
|
if (!envelope || !("result" in envelope)) throw new Error(stderr.trim() || "App-server did not return a response envelope.");
|
|
786
817
|
return envelope.result;
|
|
787
818
|
} finally {
|
|
@@ -1284,6 +1315,7 @@ async function runPluginCommand(args, options) {
|
|
|
1284
1315
|
throw new Error(pluginUsage);
|
|
1285
1316
|
} catch (error) {
|
|
1286
1317
|
stderr.write(`Error: ${printableError(error)}\n`);
|
|
1318
|
+
if (error instanceof AppServerCancellationError || error instanceof AppServerProcessError) return error.exitCode;
|
|
1287
1319
|
return error instanceof Error && error.name === "AbortError" ? 130 : 1;
|
|
1288
1320
|
}
|
|
1289
1321
|
}
|
|
@@ -1593,6 +1625,13 @@ function signalExitCode(signal) {
|
|
|
1593
1625
|
const number = constants.signals[signal];
|
|
1594
1626
|
return typeof number === "number" ? 128 + number : 1;
|
|
1595
1627
|
}
|
|
1628
|
+
function abortSignalName(signal) {
|
|
1629
|
+
const reason = signal.reason;
|
|
1630
|
+
return reason === "SIGINT" || reason === "SIGTERM" || reason === "SIGHUP" ? reason : void 0;
|
|
1631
|
+
}
|
|
1632
|
+
function abortSignalExitCode(signal) {
|
|
1633
|
+
return signalExitCode(abortSignalName(signal) ?? "SIGINT");
|
|
1634
|
+
}
|
|
1596
1635
|
async function waitForChild(child, onError = (error) => console.error("Error: " + error.message)) {
|
|
1597
1636
|
return await new Promise((resolveExit) => {
|
|
1598
1637
|
let settled = false;
|
|
@@ -1681,7 +1720,7 @@ async function runRuntime(node, args, extraEnv = {}) {
|
|
|
1681
1720
|
}
|
|
1682
1721
|
}
|
|
1683
1722
|
async function completeOfficialZaiLogin(node, payload, runtimeArgs, abortSignal) {
|
|
1684
|
-
if (abortSignal.aborted) return
|
|
1723
|
+
if (abortSignal.aborted) return abortSignalExitCode(abortSignal);
|
|
1685
1724
|
const child = spawn(node, [runtimePath, ...runtimeArgs], {
|
|
1686
1725
|
cwd: process.cwd(),
|
|
1687
1726
|
env: runtimeEnvironment({ ZCODE_CLI_OAUTH_CALLBACK_STDIN: "1" }),
|
|
@@ -1691,7 +1730,7 @@ async function completeOfficialZaiLogin(node, payload, runtimeArgs, abortSignal)
|
|
|
1691
1730
|
"inherit"
|
|
1692
1731
|
]
|
|
1693
1732
|
});
|
|
1694
|
-
const onAbort = () => child.kill("SIGINT");
|
|
1733
|
+
const onAbort = () => child.kill(abortSignalName(abortSignal) ?? "SIGINT");
|
|
1695
1734
|
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
1696
1735
|
try {
|
|
1697
1736
|
child.stdin?.end(JSON.stringify(payload));
|
|
@@ -1727,9 +1766,13 @@ async function main(args) {
|
|
|
1727
1766
|
}
|
|
1728
1767
|
const node = resolveNodeExecutable();
|
|
1729
1768
|
const pluginAbortController = new AbortController();
|
|
1730
|
-
const cancelPluginCommand = () => pluginAbortController.abort();
|
|
1731
|
-
|
|
1732
|
-
|
|
1769
|
+
const cancelPluginCommand = (signal) => () => pluginAbortController.abort(signal);
|
|
1770
|
+
const onPluginSigint = cancelPluginCommand("SIGINT");
|
|
1771
|
+
const onPluginSigterm = cancelPluginCommand("SIGTERM");
|
|
1772
|
+
const onPluginSighup = cancelPluginCommand("SIGHUP");
|
|
1773
|
+
process.once("SIGINT", onPluginSigint);
|
|
1774
|
+
process.once("SIGTERM", onPluginSigterm);
|
|
1775
|
+
if (process.platform !== "win32") process.once("SIGHUP", onPluginSighup);
|
|
1733
1776
|
let pluginCommand;
|
|
1734
1777
|
try {
|
|
1735
1778
|
pluginCommand = await runPluginCommand(args, {
|
|
@@ -1747,8 +1790,9 @@ async function main(args) {
|
|
|
1747
1790
|
signal: pluginAbortController.signal
|
|
1748
1791
|
});
|
|
1749
1792
|
} finally {
|
|
1750
|
-
process.off("SIGINT",
|
|
1751
|
-
process.off("SIGTERM",
|
|
1793
|
+
process.off("SIGINT", onPluginSigint);
|
|
1794
|
+
process.off("SIGTERM", onPluginSigterm);
|
|
1795
|
+
if (process.platform !== "win32") process.off("SIGHUP", onPluginSighup);
|
|
1752
1796
|
}
|
|
1753
1797
|
if (pluginCommand !== void 0) return pluginCommand;
|
|
1754
1798
|
const login = normalizeLoginArgs(args);
|
|
@@ -1762,9 +1806,13 @@ async function main(args) {
|
|
|
1762
1806
|
}
|
|
1763
1807
|
if (zaiOAuth) {
|
|
1764
1808
|
const abortController = new AbortController();
|
|
1765
|
-
const cancel = () => abortController.abort(
|
|
1766
|
-
|
|
1767
|
-
|
|
1809
|
+
const cancel = (signal) => () => abortController.abort(signal);
|
|
1810
|
+
const onSigint = cancel("SIGINT");
|
|
1811
|
+
const onSigterm = cancel("SIGTERM");
|
|
1812
|
+
const onSighup = cancel("SIGHUP");
|
|
1813
|
+
process.once("SIGINT", onSigint);
|
|
1814
|
+
process.once("SIGTERM", onSigterm);
|
|
1815
|
+
if (process.platform !== "win32") process.once("SIGHUP", onSighup);
|
|
1768
1816
|
try {
|
|
1769
1817
|
const code = await runZaiOAuthLogin({
|
|
1770
1818
|
abortSignal: abortController.signal,
|
|
@@ -1776,10 +1824,11 @@ async function main(args) {
|
|
|
1776
1824
|
return code;
|
|
1777
1825
|
} catch (error) {
|
|
1778
1826
|
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1779
|
-
return abortController.signal.aborted ?
|
|
1827
|
+
return abortController.signal.aborted ? abortSignalExitCode(abortController.signal) : 1;
|
|
1780
1828
|
} finally {
|
|
1781
|
-
process.off("SIGINT",
|
|
1782
|
-
process.off("SIGTERM",
|
|
1829
|
+
process.off("SIGINT", onSigint);
|
|
1830
|
+
process.off("SIGTERM", onSigterm);
|
|
1831
|
+
if (process.platform !== "win32") process.off("SIGHUP", onSighup);
|
|
1783
1832
|
}
|
|
1784
1833
|
}
|
|
1785
1834
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcode-app-cli",
|
|
3
|
-
"version": "3.11.2-
|
|
3
|
+
"version": "3.11.2-25",
|
|
4
4
|
"description": "Unofficial terminal client for the ZCode agent runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -51,7 +51,18 @@
|
|
|
51
51
|
"check": "bun run build && bun scripts/check-runtime.ts",
|
|
52
52
|
"check:oauth-callback": "bun scripts/smoke-oauth-callback.ts",
|
|
53
53
|
"check:tui": "bun scripts/smoke-tui.ts && bun scripts/smoke-tui-features.ts && bun scripts/smoke-tui-clear.ts && bun scripts/smoke-tui-session-title.ts && bun scripts/smoke-tui-pressure.ts && bun scripts/smoke-tui-widths.ts && bun scripts/smoke-tui-fullscreen.ts && bun scripts/smoke-tui-fullscreen-switch.ts && bun scripts/smoke-tui-fullscreen-layout.ts",
|
|
54
|
-
"
|
|
54
|
+
"check:tui-scenarios": "bun run test:tui",
|
|
55
|
+
"test": "bun run test:unit",
|
|
56
|
+
"test:all": "bun run test:unit && bun run test:tui && bun run test:runtime",
|
|
57
|
+
"test:unit": "bun test test/*.test.ts",
|
|
58
|
+
"test:fast": "bun run test:unit",
|
|
59
|
+
"test:runtime": "bun test test/runtime/*.test.ts",
|
|
60
|
+
"test:tui": "bun run test:tui:component && bun run test:tui:e2e",
|
|
61
|
+
"test:tui:component": "bun test test/tui/scenario-http.test.ts test/tui/scenario-runtime.test.ts test/tui/scenario-shell.test.ts test/tui/scenario-workspace.test.ts test/tui/terminal-screen.test.ts",
|
|
62
|
+
"test:tui:e2e": "bun test test/tui/allowlisted-shell.test.ts test/tui/http-mock.test.ts test/tui/model-resume.test.ts test/tui/permission-request-queue.test.ts test/tui/run-scenario.test.ts test/tui/terminal-session.test.ts test/tui/write-and-diff.test.ts",
|
|
63
|
+
"test:tui:host": "bun test test/tui/scenario-mountx.test.ts",
|
|
64
|
+
"test:tui:manual": "bun scripts/tui-scenario.ts --manual",
|
|
65
|
+
"test:tui-scenario": "bun scripts/tui-scenario.ts",
|
|
55
66
|
"typecheck": "tsc --noEmit",
|
|
56
67
|
"verify:tui-perf": "bun scripts/verify-tui-perf.ts",
|
|
57
68
|
"version:build": "bun scripts/bump-build.ts",
|
|
@@ -73,10 +84,14 @@
|
|
|
73
84
|
"playwright-core": "1.59.1"
|
|
74
85
|
},
|
|
75
86
|
"devDependencies": {
|
|
87
|
+
"@xterm/headless": "6.0.0",
|
|
76
88
|
"beautiful-mermaid": "^1.1.3",
|
|
77
89
|
"bun-types": "^1.3.14",
|
|
78
90
|
"cli-highlight": "^2.1.11",
|
|
79
91
|
"diff": "^9.0.0",
|
|
92
|
+
"just-bash": "^3.4.2",
|
|
93
|
+
"mountx": "^0.0.2",
|
|
94
|
+
"msw": "^2.15.0",
|
|
80
95
|
"tsdown": "^0.22.7",
|
|
81
96
|
"typescript": "^7.0.2",
|
|
82
97
|
"yaml": "^2.8.1"
|
package/vendor/extraction.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"appVersion": "3.11.2",
|
|
3
3
|
"cliVersion": "0.16.5",
|
|
4
|
-
"extractedAt": "2026-09-
|
|
4
|
+
"extractedAt": "2026-09-15T01:28:23.429Z",
|
|
5
5
|
"sha512": "4UAMZSP9ZWBrnb8wGaP39rb5dB5ikPx4aYPXKXGea1Vmd6L6vGma3rXwRxKbhBxgsCIE9jv6tmrdSL60RrzGcA==",
|
|
6
6
|
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.11.2/linux-x64/ZCode-3.11.2-linux-x64.deb",
|
|
7
7
|
"runtimeCapabilities": {
|
|
@@ -158875,6 +158875,10 @@ function restoredMessages(value) {
|
|
|
158875
158875
|
const rawRole = asString(item.role) ?? (info && asString(info.role));
|
|
158876
158876
|
const role = rawRole === "user" ? "user" : rawRole === "assistant" || rawRole === "agent" ? "assistant" : "system";
|
|
158877
158877
|
const direct = asString(item.text) ?? asString(item.content);
|
|
158878
|
+
const model = modelReference(item.model) ?? modelReference({
|
|
158879
|
+
providerId: item.providerId ?? item.providerID ?? (info && (info.providerId ?? info.providerID)),
|
|
158880
|
+
modelId: item.modelId ?? item.modelID ?? (info && (info.modelId ?? info.modelID))
|
|
158881
|
+
});
|
|
158878
158882
|
const structured = Array.isArray(item.parts) ? item.parts.map(normalizeRestoredPart).filter((part) => Boolean(part)) : [];
|
|
158879
158883
|
const hasTextPart = structured.some((part) => part.type === "text");
|
|
158880
158884
|
const parts = direct && !hasTextPart ? [{
|
|
@@ -158883,6 +158887,7 @@ function restoredMessages(value) {
|
|
|
158883
158887
|
}, ...structured] : structured;
|
|
158884
158888
|
if (parts.length > 0) messages.push({
|
|
158885
158889
|
messageId: asString(item.messageId) ?? asString(item.messageID) ?? (info && (asString(info.messageId) ?? asString(info.id))),
|
|
158890
|
+
...model ? { model } : {},
|
|
158886
158891
|
role,
|
|
158887
158892
|
parts
|
|
158888
158893
|
});
|
|
@@ -162117,6 +162122,17 @@ var PermissionPreview = class {
|
|
|
162117
162122
|
}
|
|
162118
162123
|
};
|
|
162119
162124
|
//#endregion
|
|
162125
|
+
//#region packages/zcode-tui/src/permission-request-queue.ts
|
|
162126
|
+
/** Runs complete permission interactions in FIFO order so their dialogs never overlap. */
|
|
162127
|
+
var PermissionRequestQueue = class {
|
|
162128
|
+
tail = Promise.resolve();
|
|
162129
|
+
run(request) {
|
|
162130
|
+
const result = this.tail.then(request);
|
|
162131
|
+
this.tail = result.then(() => void 0, () => void 0);
|
|
162132
|
+
return result;
|
|
162133
|
+
}
|
|
162134
|
+
};
|
|
162135
|
+
//#endregion
|
|
162120
162136
|
//#region src/app-server-client.ts
|
|
162121
162137
|
const maximumOutputBytes = 16 * 1024 * 1024;
|
|
162122
162138
|
const forceTerminationDelayMilliseconds = 500;
|
|
@@ -162130,10 +162146,41 @@ var AppServerRequestError = class extends Error {
|
|
|
162130
162146
|
this.name = "AppServerRequestError";
|
|
162131
162147
|
}
|
|
162132
162148
|
};
|
|
162133
|
-
|
|
162134
|
-
|
|
162135
|
-
|
|
162136
|
-
|
|
162149
|
+
var AppServerProcessError = class extends Error {
|
|
162150
|
+
exitCode;
|
|
162151
|
+
constructor(message, exitCode) {
|
|
162152
|
+
super(message);
|
|
162153
|
+
this.exitCode = exitCode;
|
|
162154
|
+
this.name = "AppServerProcessError";
|
|
162155
|
+
}
|
|
162156
|
+
};
|
|
162157
|
+
var AppServerCancellationError = class extends Error {
|
|
162158
|
+
exitCode;
|
|
162159
|
+
constructor(exitCode) {
|
|
162160
|
+
super("App-server request cancelled.");
|
|
162161
|
+
this.exitCode = exitCode;
|
|
162162
|
+
this.name = "AbortError";
|
|
162163
|
+
}
|
|
162164
|
+
};
|
|
162165
|
+
function signalExitCode$1(signal) {
|
|
162166
|
+
if (!signal) return 1;
|
|
162167
|
+
const number = constants$1.signals[signal];
|
|
162168
|
+
return typeof number === "number" ? 128 + number : 1;
|
|
162169
|
+
}
|
|
162170
|
+
function abortSignalName(signal) {
|
|
162171
|
+
const reason = signal?.reason;
|
|
162172
|
+
return reason === "SIGINT" || reason === "SIGTERM" || reason === "SIGHUP" ? reason : void 0;
|
|
162173
|
+
}
|
|
162174
|
+
function cancellationError(signal) {
|
|
162175
|
+
const signalName = abortSignalName(signal);
|
|
162176
|
+
if (signalName) return new AppServerCancellationError(signalExitCode$1(signalName));
|
|
162177
|
+
return new AppServerCancellationError(130);
|
|
162178
|
+
}
|
|
162179
|
+
function terminationSignal(signal) {
|
|
162180
|
+
return abortSignalName(signal) ?? "SIGTERM";
|
|
162181
|
+
}
|
|
162182
|
+
function processError(message, code) {
|
|
162183
|
+
return new AppServerProcessError(message, code);
|
|
162137
162184
|
}
|
|
162138
162185
|
async function readBounded(stream, onOverflow) {
|
|
162139
162186
|
if (!stream) return "";
|
|
@@ -162163,7 +162210,7 @@ function responseEnvelope(stdout) {
|
|
|
162163
162210
|
}
|
|
162164
162211
|
}
|
|
162165
162212
|
async function requestAppServer(request) {
|
|
162166
|
-
if (request.signal?.aborted) throw cancellationError();
|
|
162213
|
+
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
162167
162214
|
const child = spawn(request.transport.command, request.transport.args, {
|
|
162168
162215
|
cwd: request.transport.cwd,
|
|
162169
162216
|
env: request.transport.env,
|
|
@@ -162188,7 +162235,7 @@ async function requestAppServer(request) {
|
|
|
162188
162235
|
launchError = error;
|
|
162189
162236
|
finish(1);
|
|
162190
162237
|
});
|
|
162191
|
-
child.once("close", (code) => finish(code ?? 1));
|
|
162238
|
+
child.once("close", (code, signal) => finish(code ?? signalExitCode$1(signal)));
|
|
162192
162239
|
});
|
|
162193
162240
|
const terminateForOverflow = () => {
|
|
162194
162241
|
overflow = true;
|
|
@@ -162196,7 +162243,7 @@ async function requestAppServer(request) {
|
|
|
162196
162243
|
};
|
|
162197
162244
|
const onAbort = () => {
|
|
162198
162245
|
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
162199
|
-
child.kill(
|
|
162246
|
+
child.kill(terminationSignal(request.signal));
|
|
162200
162247
|
forceTerminationTimer = setTimeout(() => {
|
|
162201
162248
|
if (child.exitCode === null && child.signalCode === null) child.kill("SIGKILL");
|
|
162202
162249
|
}, forceTerminationDelayMilliseconds);
|
|
@@ -162216,12 +162263,12 @@ async function requestAppServer(request) {
|
|
|
162216
162263
|
readBounded(child.stdout, terminateForOverflow),
|
|
162217
162264
|
readBounded(child.stderr, terminateForOverflow)
|
|
162218
162265
|
]);
|
|
162219
|
-
if (request.signal?.aborted) throw cancellationError();
|
|
162266
|
+
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
162220
162267
|
if (overflow) throw new Error(`App-server output exceeded ${maximumOutputBytes} bytes.`);
|
|
162221
162268
|
if (launchError) throw launchError;
|
|
162222
162269
|
const envelope = responseEnvelope(stdout);
|
|
162223
162270
|
if (envelope?.error) throw new AppServerRequestError(envelope.error.message?.trim() || "App-server request failed.", envelope.error.code, envelope.error.data);
|
|
162224
|
-
if (code !== 0) throw
|
|
162271
|
+
if (code !== 0) throw processError(stderr.trim() || `App-server exited with status ${code}.`, code);
|
|
162225
162272
|
if (!envelope || !("result" in envelope)) throw new Error(stderr.trim() || "App-server did not return a response envelope.");
|
|
162226
162273
|
return envelope.result;
|
|
162227
162274
|
} finally {
|
|
@@ -166627,6 +166674,7 @@ var ZCodeTui = class {
|
|
|
166627
166674
|
workflowPanel;
|
|
166628
166675
|
workflowView;
|
|
166629
166676
|
workflowRefreshInFlight = false;
|
|
166677
|
+
permissionRequests = new PermissionRequestQueue();
|
|
166630
166678
|
choiceDepth = 0;
|
|
166631
166679
|
settingSwitchInFlight = false;
|
|
166632
166680
|
fullscreenWelcomeVisible = true;
|
|
@@ -167872,7 +167920,7 @@ var ZCodeTui = class {
|
|
|
167872
167920
|
this.recordAssistantText(this.assistantStream.reconcile(response));
|
|
167873
167921
|
}
|
|
167874
167922
|
if (appliesToSetting(settingTarget, "mode") && typeof result.mode === "string") this.mode = normalizedMode(result.mode, this.mode);
|
|
167875
|
-
if (appliesToSetting(settingTarget, "model") && result.model !== void 0) this.model = modelLabel$1(result.model);
|
|
167923
|
+
if (appliesToSetting(settingTarget, "model") && result.model !== void 0 && result.resetSessionProjection !== true) this.model = modelLabel$1(result.model);
|
|
167876
167924
|
if (typeof result.loginRequired === "boolean") {
|
|
167877
167925
|
this.setLoginRequired(result.loginRequired);
|
|
167878
167926
|
if (!result.loginRequired && result.model === void 0 && appliesToSetting(settingTarget, "model")) {
|
|
@@ -167891,6 +167939,14 @@ var ZCodeTui = class {
|
|
|
167891
167939
|
this.ui.requestRender();
|
|
167892
167940
|
if (isRecord(result.workflowPanel)) await this.showWorkflowPanel(result.workflowPanel);
|
|
167893
167941
|
if (isRecord(result.selection)) await this.showSelection(result.selection);
|
|
167942
|
+
if (result.resetSessionProjection === true) {
|
|
167943
|
+
try {
|
|
167944
|
+
const persistedModel = await this.options.readSessionModel?.();
|
|
167945
|
+
if (typeof persistedModel === "string" && persistedModel.trim()) this.model = persistedModel.trim();
|
|
167946
|
+
} catch {}
|
|
167947
|
+
this.updateMetadata();
|
|
167948
|
+
this.ui.requestRender();
|
|
167949
|
+
}
|
|
167894
167950
|
}
|
|
167895
167951
|
onEvent(value, turnEpoch) {
|
|
167896
167952
|
this.debugEvent("session", value);
|
|
@@ -168706,6 +168762,7 @@ var ZCodeTui = class {
|
|
|
168706
168762
|
}
|
|
168707
168763
|
restoreTranscript(messages) {
|
|
168708
168764
|
let firstUserMessageText;
|
|
168765
|
+
let lastAssistantModel;
|
|
168709
168766
|
for (const message of messages) {
|
|
168710
168767
|
this.currentToolGroup = void 0;
|
|
168711
168768
|
this.currentToolGroupBlockId = void 0;
|
|
@@ -168719,6 +168776,7 @@ var ZCodeTui = class {
|
|
|
168719
168776
|
}
|
|
168720
168777
|
continue;
|
|
168721
168778
|
}
|
|
168779
|
+
if (message.role === "assistant" && message.model) lastAssistantModel = message.model;
|
|
168722
168780
|
const hiddenToolIds = message.role === "assistant" ? backgroundToolPartIds(message.parts) : /* @__PURE__ */ new Set();
|
|
168723
168781
|
const coordinatesBackgroundAgents = message.parts.some(backgroundAgentPart);
|
|
168724
168782
|
for (const part of message.parts) {
|
|
@@ -168742,6 +168800,7 @@ var ZCodeTui = class {
|
|
|
168742
168800
|
this.currentToolGroupBlockId = void 0;
|
|
168743
168801
|
this.currentToolGroupMessageId = void 0;
|
|
168744
168802
|
this.assistantStream.breakSegment();
|
|
168803
|
+
if (lastAssistantModel) this.model = lastAssistantModel;
|
|
168745
168804
|
}
|
|
168746
168805
|
restorePart(part, role, fallbackMessageId) {
|
|
168747
168806
|
const messageId = part.messageId ?? fallbackMessageId;
|
|
@@ -168858,10 +168917,13 @@ var ZCodeTui = class {
|
|
|
168858
168917
|
if (wasActive && !this.attachmentBar.isActive()) this.focusEditor();
|
|
168859
168918
|
this.ui.requestRender();
|
|
168860
168919
|
}
|
|
168861
|
-
|
|
168862
|
-
const request = isRecord(requestValue) ? requestValue : {};
|
|
168920
|
+
requestPermission(requestValue, context) {
|
|
168863
168921
|
const contextRecord = isRecord(context) ? context : void 0;
|
|
168864
168922
|
const signal = contextRecord?.abortSignal instanceof AbortSignal ? contextRecord.abortSignal : this.turnAbortController?.signal;
|
|
168923
|
+
return this.permissionRequests.run(() => this.requestPermissionUnqueued(requestValue, signal));
|
|
168924
|
+
}
|
|
168925
|
+
async requestPermissionUnqueued(requestValue, signal) {
|
|
168926
|
+
const request = isRecord(requestValue) ? requestValue : {};
|
|
168865
168927
|
const toolName = asString(request.toolName) ?? "tool";
|
|
168866
168928
|
const asksUserQuestion = isAskUserQuestionTool(toolName);
|
|
168867
168929
|
const toolCallId = asString(request.toolCallId) ?? asString(request.toolUseId) ?? asString(request.callId);
|
|
@@ -170524,7 +170586,7 @@ var ZCodeTui = class {
|
|
|
170524
170586
|
return await choose(this.ui, this.choiceHost, this.theme, options);
|
|
170525
170587
|
} finally {
|
|
170526
170588
|
this.choiceDepth = Math.max(0, this.choiceDepth - 1);
|
|
170527
|
-
this.focusEditor();
|
|
170589
|
+
if (this.choiceDepth === 0) this.focusEditor();
|
|
170528
170590
|
this.ui.requestRender();
|
|
170529
170591
|
}
|
|
170530
170592
|
}
|
|
@@ -170534,7 +170596,7 @@ var ZCodeTui = class {
|
|
|
170534
170596
|
return await promptText(this.ui, this.choiceHost, this.theme, options);
|
|
170535
170597
|
} finally {
|
|
170536
170598
|
this.choiceDepth = Math.max(0, this.choiceDepth - 1);
|
|
170537
|
-
this.focusEditor();
|
|
170599
|
+
if (this.choiceDepth === 0) this.focusEditor();
|
|
170538
170600
|
this.ui.requestRender();
|
|
170539
170601
|
}
|
|
170540
170602
|
}
|
|
@@ -170576,13 +170638,16 @@ var ZCodeTui = class {
|
|
|
170576
170638
|
}
|
|
170577
170639
|
}
|
|
170578
170640
|
async restoreInitialTranscript() {
|
|
170579
|
-
if (
|
|
170580
|
-
try {
|
|
170641
|
+
if (this.options.loadSessionTranscript) try {
|
|
170581
170642
|
this.restoreTranscript(restoredMessages(await this.options.loadSessionTranscript()));
|
|
170582
170643
|
} catch (error) {
|
|
170583
170644
|
const message = error instanceof Error ? error.message : String(error);
|
|
170584
170645
|
this.addNotice(`Unable to restore session transcript: ${message}`, "warning");
|
|
170585
170646
|
}
|
|
170647
|
+
try {
|
|
170648
|
+
const persistedModel = await this.options.readSessionModel?.();
|
|
170649
|
+
if (typeof persistedModel === "string" && persistedModel.trim()) this.model = persistedModel.trim();
|
|
170650
|
+
} catch {}
|
|
170586
170651
|
}
|
|
170587
170652
|
updateMetadata() {
|
|
170588
170653
|
const fields = [{
|