zcode-app-cli 4.0.0-49 → 4.0.0-50
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 +6 -0
- package/bin/zcode.js +85 -26
- package/docs/CONFIGURATION.md +14 -5
- package/docs/CONFIGURATION.zh-CN.md +6 -0
- package/package.json +1 -1
- package/vendor/extraction.json +2 -13
- package/vendor/node_modules/@zcode/tui/dist/index.js +38 -3
package/README.md
CHANGED
|
@@ -450,6 +450,12 @@ for intentional non-interactive execution, `--json` for structured output and
|
|
|
450
450
|
`--scope user|workspace` to choose installation scope. Marketplace Git access
|
|
451
451
|
behind a proxy uses `ZCODE_HTTP_PROXY`.
|
|
452
452
|
|
|
453
|
+
Each launcher plugin request has a 60-second timeout. For slow marketplace or
|
|
454
|
+
plugin downloads, set `ZCODE_PLUGIN_REQUEST_TIMEOUT_MS` to a larger duration in
|
|
455
|
+
milliseconds. For marketplace addition/update and plugin installation,
|
|
456
|
+
cancellation asks the runtime to stop the operation and release its storage lock
|
|
457
|
+
before the launcher terminates an unresponsive app-server.
|
|
458
|
+
|
|
453
459
|
Plugins with configuration can load options from a JSON file without exposing
|
|
454
460
|
values in the process argument list:
|
|
455
461
|
|
package/bin/zcode.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execFile, spawn } from "node:child_process";
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
4
|
import { appendFileSync, chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeSync } from "node:fs";
|
|
4
5
|
import { constants, homedir } from "node:os";
|
|
5
6
|
import { basename, dirname, join, posix, resolve, win32 } from "node:path";
|
|
6
7
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
8
8
|
import { access, link, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
|
|
9
9
|
import { parseArgs, promisify } from "node:util";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -484,6 +484,7 @@ function classifyZaiOAuthInvocation(args) {
|
|
|
484
484
|
//#region src/app-server-client.ts
|
|
485
485
|
const maximumOutputBytes = 16 * 1024 * 1024;
|
|
486
486
|
const forceTerminationDelayMilliseconds = 500;
|
|
487
|
+
const cooperativeCancellationDelayMilliseconds = 3e3;
|
|
487
488
|
var AppServerRequestError = class extends Error {
|
|
488
489
|
code;
|
|
489
490
|
data;
|
|
@@ -510,6 +511,14 @@ var AppServerCancellationError = class extends Error {
|
|
|
510
511
|
this.name = "AbortError";
|
|
511
512
|
}
|
|
512
513
|
};
|
|
514
|
+
var AppServerTimeoutError = class extends Error {
|
|
515
|
+
timeoutMs;
|
|
516
|
+
constructor(timeoutMs) {
|
|
517
|
+
super(`App-server request timed out after ${timeoutMs}ms.`);
|
|
518
|
+
this.timeoutMs = timeoutMs;
|
|
519
|
+
this.name = "TimeoutError";
|
|
520
|
+
}
|
|
521
|
+
};
|
|
513
522
|
function signalExitCode$1(signal) {
|
|
514
523
|
if (!signal) return 1;
|
|
515
524
|
const number = constants.signals[signal];
|
|
@@ -560,6 +569,7 @@ function responseEnvelope(stdout) {
|
|
|
560
569
|
}
|
|
561
570
|
async function requestAppServer(request) {
|
|
562
571
|
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
572
|
+
if (request.timeoutMs !== void 0 && (!Number.isInteger(request.timeoutMs) || request.timeoutMs <= 0 || request.timeoutMs > 2147483647)) throw new Error("App-server timeoutMs must be an integer between 1 and 2147483647.");
|
|
563
573
|
const child = spawn(request.transport.command, request.transport.args, {
|
|
564
574
|
cwd: request.transport.cwd,
|
|
565
575
|
env: request.transport.env,
|
|
@@ -573,6 +583,9 @@ async function requestAppServer(request) {
|
|
|
573
583
|
let launchError;
|
|
574
584
|
let overflow = false;
|
|
575
585
|
let forceTerminationTimer;
|
|
586
|
+
let requestTimeoutTimer;
|
|
587
|
+
let timedOut = false;
|
|
588
|
+
let cancelling = false;
|
|
576
589
|
const exited = new Promise((resolve) => {
|
|
577
590
|
let settled = false;
|
|
578
591
|
const finish = (code) => {
|
|
@@ -590,7 +603,7 @@ async function requestAppServer(request) {
|
|
|
590
603
|
overflow = true;
|
|
591
604
|
child.kill("SIGKILL");
|
|
592
605
|
};
|
|
593
|
-
const
|
|
606
|
+
const terminate = () => {
|
|
594
607
|
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
595
608
|
child.kill(terminationSignal(request.signal));
|
|
596
609
|
forceTerminationTimer = setTimeout(() => {
|
|
@@ -598,8 +611,19 @@ async function requestAppServer(request) {
|
|
|
598
611
|
}, forceTerminationDelayMilliseconds);
|
|
599
612
|
forceTerminationTimer.unref();
|
|
600
613
|
};
|
|
601
|
-
|
|
602
|
-
|
|
614
|
+
const onAbort = () => {
|
|
615
|
+
if (cancelling || child.exitCode !== null || child.signalCode !== null) return;
|
|
616
|
+
cancelling = true;
|
|
617
|
+
if (requestTimeoutTimer) clearTimeout(requestTimeoutTimer);
|
|
618
|
+
if (request.cancellation && !child.stdin.writableEnded && !child.stdin.destroyed) {
|
|
619
|
+
child.stdin.end(`${JSON.stringify({
|
|
620
|
+
id: 2,
|
|
621
|
+
...request.cancellation
|
|
622
|
+
})}\n`);
|
|
623
|
+
forceTerminationTimer = setTimeout(terminate, cooperativeCancellationDelayMilliseconds);
|
|
624
|
+
forceTerminationTimer.unref();
|
|
625
|
+
} else terminate();
|
|
626
|
+
};
|
|
603
627
|
child.stdin.on("error", () => {});
|
|
604
628
|
const decoder = new StringDecoder("utf8");
|
|
605
629
|
let pending = "";
|
|
@@ -617,12 +641,22 @@ async function requestAppServer(request) {
|
|
|
617
641
|
method: request.method,
|
|
618
642
|
params: request.params
|
|
619
643
|
})}\n`);
|
|
644
|
+
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
645
|
+
if (request.signal?.aborted) onAbort();
|
|
646
|
+
else if (request.timeoutMs !== void 0) {
|
|
647
|
+
requestTimeoutTimer = setTimeout(() => {
|
|
648
|
+
timedOut = true;
|
|
649
|
+
onAbort();
|
|
650
|
+
}, request.timeoutMs);
|
|
651
|
+
requestTimeoutTimer.unref();
|
|
652
|
+
}
|
|
620
653
|
try {
|
|
621
654
|
const [code, stdout, stderr] = await Promise.all([
|
|
622
655
|
exited,
|
|
623
656
|
stdoutPromise,
|
|
624
657
|
readBounded(child.stderr, terminateForOverflow)
|
|
625
658
|
]);
|
|
659
|
+
if (timedOut) throw new AppServerTimeoutError(request.timeoutMs);
|
|
626
660
|
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
627
661
|
if (overflow) throw new Error(`App-server output exceeded ${maximumOutputBytes} bytes.`);
|
|
628
662
|
if (launchError) throw launchError;
|
|
@@ -633,6 +667,7 @@ async function requestAppServer(request) {
|
|
|
633
667
|
if (stderr) request.onStderr?.(stderr);
|
|
634
668
|
return envelope.result;
|
|
635
669
|
} finally {
|
|
670
|
+
if (requestTimeoutTimer) clearTimeout(requestTimeoutTimer);
|
|
636
671
|
if (forceTerminationTimer) clearTimeout(forceTerminationTimer);
|
|
637
672
|
request.signal?.removeEventListener("abort", onAbort);
|
|
638
673
|
}
|
|
@@ -986,6 +1021,7 @@ async function runPluginCommand(args, options) {
|
|
|
986
1021
|
success: "Marketplace validation succeeded."
|
|
987
1022
|
}, false);
|
|
988
1023
|
if (!command.yes && !await confirm(`Add marketplace from ${printable(value)}?`)) throw new Error("Marketplace addition cancelled. Use --yes for non-interactive use.");
|
|
1024
|
+
if (!command.json) stdout.write("Adding marketplace...\n");
|
|
989
1025
|
const result = await call(pluginProtocolMethods.marketplaceAdd, { source: value });
|
|
990
1026
|
print(result, () => renderMutation(stdout, result, {
|
|
991
1027
|
failure: "Marketplace addition failed.",
|
|
@@ -1319,13 +1355,16 @@ async function readCatalog(path, missingIsEmpty = false) {
|
|
|
1319
1355
|
}
|
|
1320
1356
|
}
|
|
1321
1357
|
/**
|
|
1322
|
-
* Reject a CLI override before the
|
|
1358
|
+
* Reject a CLI override before the runtime starts when both local
|
|
1323
1359
|
* registries are readable and conclusively show that the selection is absent.
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1360
|
+
* Account catalogs can add models and providers beyond the local registries,
|
|
1361
|
+
* so the runtime owns their validation. Also defer if either registry is unavailable.
|
|
1326
1362
|
*/
|
|
1327
1363
|
async function invalidConfiguredPromptModel(model, env = process.env) {
|
|
1328
1364
|
if (!model) return void 0;
|
|
1365
|
+
const separator = model.indexOf("/");
|
|
1366
|
+
const providerId = model.slice(0, separator);
|
|
1367
|
+
if (providerId.startsWith("account:")) return void 0;
|
|
1329
1368
|
let personal;
|
|
1330
1369
|
let builtin;
|
|
1331
1370
|
try {
|
|
@@ -1336,8 +1375,6 @@ async function invalidConfiguredPromptModel(model, env = process.env) {
|
|
|
1336
1375
|
return;
|
|
1337
1376
|
}
|
|
1338
1377
|
if (!personal || !builtin) return void 0;
|
|
1339
|
-
const separator = model.indexOf("/");
|
|
1340
|
-
const providerId = model.slice(0, separator);
|
|
1341
1378
|
const modelId = model.slice(separator + 1);
|
|
1342
1379
|
const personalModels = personal.get(providerId);
|
|
1343
1380
|
const builtinModels = builtin.get(providerId);
|
|
@@ -1388,6 +1425,17 @@ const versionArguments = /* @__PURE__ */ new Set([
|
|
|
1388
1425
|
"-v"
|
|
1389
1426
|
]);
|
|
1390
1427
|
const runtimeVariadicOptions = /* @__PURE__ */ new Set(["--disallowedTools", "--disallowed-tools"]);
|
|
1428
|
+
const cancellablePluginMethods = /* @__PURE__ */ new Set([
|
|
1429
|
+
pluginProtocolMethods.marketplaceAdd,
|
|
1430
|
+
pluginProtocolMethods.marketplaceUpdate,
|
|
1431
|
+
pluginProtocolMethods.install
|
|
1432
|
+
]);
|
|
1433
|
+
function pluginRequestTimeoutMs() {
|
|
1434
|
+
const value = process.env.ZCODE_PLUGIN_REQUEST_TIMEOUT_MS?.trim();
|
|
1435
|
+
const timeout = value ? Number(value) : 6e4;
|
|
1436
|
+
if (!Number.isInteger(timeout) || timeout <= 0 || timeout > 2147483647) throw new Error("ZCODE_PLUGIN_REQUEST_TIMEOUT_MS must be an integer between 1 and 2147483647.");
|
|
1437
|
+
return timeout;
|
|
1438
|
+
}
|
|
1391
1439
|
function resolveModelRetryMaxRetries(env) {
|
|
1392
1440
|
return env.ZCODE_MODEL_RETRY_MAX_RETRIES?.trim() || defaultModelRetryMaxRetries;
|
|
1393
1441
|
}
|
|
@@ -1772,24 +1820,35 @@ async function main(args) {
|
|
|
1772
1820
|
let pluginCommand;
|
|
1773
1821
|
try {
|
|
1774
1822
|
pluginCommand = await runPluginCommand(args, {
|
|
1775
|
-
request: async ({ method, params, signal, workingDirectory }) =>
|
|
1776
|
-
method
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1823
|
+
request: async ({ method, params, signal, workingDirectory }) => {
|
|
1824
|
+
const operationId = cancellablePluginMethods.has(method) ? randomUUID() : void 0;
|
|
1825
|
+
return await requestAppServer({
|
|
1826
|
+
method,
|
|
1827
|
+
params: operationId ? {
|
|
1828
|
+
...params,
|
|
1829
|
+
operationId
|
|
1830
|
+
} : params,
|
|
1831
|
+
...operationId ? { cancellation: {
|
|
1832
|
+
method: "plugins/cancelOperation",
|
|
1833
|
+
params: { operationId }
|
|
1834
|
+
} } : {},
|
|
1835
|
+
timeoutMs: pluginRequestTimeoutMs(),
|
|
1836
|
+
onStderr: (stderr) => {
|
|
1837
|
+
for (const line of stderr.split(/\r?\n/u)) {
|
|
1838
|
+
if (!line.startsWith("ZCode Built-in: ignoring unavailable ZCODE_BUILTIN_PROVIDER_CONFIG_FILE ") || builtinProviderWarnings.has(line)) continue;
|
|
1839
|
+
builtinProviderWarnings.add(line);
|
|
1840
|
+
process.stderr.write(`${line}\n`);
|
|
1841
|
+
}
|
|
1842
|
+
},
|
|
1843
|
+
signal: signal ?? pluginAbortController.signal,
|
|
1844
|
+
transport: {
|
|
1845
|
+
args: [runtimePath, "app-server"],
|
|
1846
|
+
command: node,
|
|
1847
|
+
cwd: workingDirectory,
|
|
1848
|
+
env: runtimeEnvironment()
|
|
1783
1849
|
}
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
transport: {
|
|
1787
|
-
args: [runtimePath, "app-server"],
|
|
1788
|
-
command: node,
|
|
1789
|
-
cwd: workingDirectory,
|
|
1790
|
-
env: runtimeEnvironment()
|
|
1791
|
-
}
|
|
1792
|
-
}),
|
|
1850
|
+
});
|
|
1851
|
+
},
|
|
1793
1852
|
signal: pluginAbortController.signal
|
|
1794
1853
|
});
|
|
1795
1854
|
} finally {
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -705,10 +705,19 @@ export ZCODE_TUI_NOTIFICATION_CONDITION=always # unfocused|always
|
|
|
705
705
|
zcode
|
|
706
706
|
```
|
|
707
707
|
|
|
708
|
+
## Plugin request timeout
|
|
709
|
+
|
|
710
|
+
Launcher plugin requests time out after 60 seconds. Set
|
|
711
|
+
`ZCODE_PLUGIN_REQUEST_TIMEOUT_MS` to a positive integer in milliseconds (up to
|
|
712
|
+
2147483647) to allow longer downloads. Marketplace addition/update and plugin
|
|
713
|
+
installation request runtime cleanup on timeout or cancellation before terminating
|
|
714
|
+
an unresponsive app-server.
|
|
715
|
+
|
|
708
716
|
## Official MCP Availability
|
|
709
717
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
718
|
+
Official HTTP MCP services that use ZCode's trusted-origin authentication
|
|
719
|
+
require the runtime host to provide its trusted-origin registry and auth-header
|
|
720
|
+
port. If those host capabilities are unavailable, the runtime fails that
|
|
721
|
+
service connection and reports that the official MCP trusted-origin registry is
|
|
722
|
+
unavailable. Other MCP services remain available. No user configuration is
|
|
723
|
+
rewritten, and certificate, origin, and permission checks remain enabled.
|
|
@@ -595,6 +595,12 @@ export ZCODE_TUI_NOTIFICATION_CONDITION=always # unfocused|always
|
|
|
595
595
|
zcode
|
|
596
596
|
```
|
|
597
597
|
|
|
598
|
+
## 插件请求超时
|
|
599
|
+
|
|
600
|
+
启动器的插件请求默认在 60 秒后超时。下载较慢时,可将
|
|
601
|
+
`ZCODE_PLUGIN_REQUEST_TIMEOUT_MS` 设置为更大的正整数毫秒值(最大 2147483647)。
|
|
602
|
+
添加或更新市场、安装插件时,超时或取消会先请求 runtime 清理操作,再终止无响应的 app-server。
|
|
603
|
+
|
|
598
604
|
## 官方 MCP 可用性
|
|
599
605
|
|
|
600
606
|
如果捆绑 runtime 没有官方 MCP 的可信来源 registry,官方 HTTP MCP 服务会显示为禁用,
|
package/package.json
CHANGED
package/vendor/extraction.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"appVersion": "4.0.0",
|
|
3
3
|
"cliVersion": "0.18.0",
|
|
4
|
-
"extractedAt": "2026-11-
|
|
4
|
+
"extractedAt": "2026-11-25T15:06:45.531Z",
|
|
5
5
|
"sha512": "rl0Q2ZO0W9gxf7oi7PjAgyBw+3ivnVYzXF9VdBWAs2Ie7KtzNLV6yv3wJkz/fvr35TWOFUr2wLodUS/PqxfhBA==",
|
|
6
6
|
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/4.0.0/linux-x64/ZCode-4.0.0-linux-x64.deb",
|
|
7
7
|
"runtimeCapabilities": {
|
|
@@ -164,12 +164,6 @@
|
|
|
164
164
|
"requirement": "required",
|
|
165
165
|
"status": "applied"
|
|
166
166
|
},
|
|
167
|
-
{
|
|
168
|
-
"id": "official-mcp-availability",
|
|
169
|
-
"requirement": "optional",
|
|
170
|
-
"status": "skipped",
|
|
171
|
-
"message": "ZCode runtime is incompatible with the official MCP availability patch."
|
|
172
|
-
},
|
|
173
167
|
{
|
|
174
168
|
"id": "resolved-context-window",
|
|
175
169
|
"requirement": "required",
|
|
@@ -261,7 +255,7 @@
|
|
|
261
255
|
"status": "applied"
|
|
262
256
|
},
|
|
263
257
|
{
|
|
264
|
-
"id": "
|
|
258
|
+
"id": "native-oauth-polling",
|
|
265
259
|
"requirement": "required",
|
|
266
260
|
"status": "already_present"
|
|
267
261
|
},
|
|
@@ -270,11 +264,6 @@
|
|
|
270
264
|
"requirement": "required",
|
|
271
265
|
"status": "applied"
|
|
272
266
|
},
|
|
273
|
-
{
|
|
274
|
-
"id": "desktop-oauth",
|
|
275
|
-
"requirement": "required",
|
|
276
|
-
"status": "already_present"
|
|
277
|
-
},
|
|
278
267
|
{
|
|
279
268
|
"id": "bigmodel-session-reuse",
|
|
280
269
|
"requirement": "optional",
|
|
@@ -162164,6 +162164,7 @@ function permissionRequestSignal(context) {
|
|
|
162164
162164
|
//#region src/app-server-client.ts
|
|
162165
162165
|
const maximumOutputBytes = 16 * 1024 * 1024;
|
|
162166
162166
|
const forceTerminationDelayMilliseconds = 500;
|
|
162167
|
+
const cooperativeCancellationDelayMilliseconds = 3e3;
|
|
162167
162168
|
var AppServerRequestError = class extends Error {
|
|
162168
162169
|
code;
|
|
162169
162170
|
data;
|
|
@@ -162190,6 +162191,14 @@ var AppServerCancellationError = class extends Error {
|
|
|
162190
162191
|
this.name = "AbortError";
|
|
162191
162192
|
}
|
|
162192
162193
|
};
|
|
162194
|
+
var AppServerTimeoutError = class extends Error {
|
|
162195
|
+
timeoutMs;
|
|
162196
|
+
constructor(timeoutMs) {
|
|
162197
|
+
super(`App-server request timed out after ${timeoutMs}ms.`);
|
|
162198
|
+
this.timeoutMs = timeoutMs;
|
|
162199
|
+
this.name = "TimeoutError";
|
|
162200
|
+
}
|
|
162201
|
+
};
|
|
162193
162202
|
function signalExitCode$1(signal) {
|
|
162194
162203
|
if (!signal) return 1;
|
|
162195
162204
|
const number = constants$1.signals[signal];
|
|
@@ -162240,6 +162249,7 @@ function responseEnvelope(stdout) {
|
|
|
162240
162249
|
}
|
|
162241
162250
|
async function requestAppServer(request) {
|
|
162242
162251
|
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
162252
|
+
if (request.timeoutMs !== void 0 && (!Number.isInteger(request.timeoutMs) || request.timeoutMs <= 0 || request.timeoutMs > 2147483647)) throw new Error("App-server timeoutMs must be an integer between 1 and 2147483647.");
|
|
162243
162253
|
const child = spawn(request.transport.command, request.transport.args, {
|
|
162244
162254
|
cwd: request.transport.cwd,
|
|
162245
162255
|
env: request.transport.env,
|
|
@@ -162253,6 +162263,9 @@ async function requestAppServer(request) {
|
|
|
162253
162263
|
let launchError;
|
|
162254
162264
|
let overflow = false;
|
|
162255
162265
|
let forceTerminationTimer;
|
|
162266
|
+
let requestTimeoutTimer;
|
|
162267
|
+
let timedOut = false;
|
|
162268
|
+
let cancelling = false;
|
|
162256
162269
|
const exited = new Promise((resolve) => {
|
|
162257
162270
|
let settled = false;
|
|
162258
162271
|
const finish = (code) => {
|
|
@@ -162270,7 +162283,7 @@ async function requestAppServer(request) {
|
|
|
162270
162283
|
overflow = true;
|
|
162271
162284
|
child.kill("SIGKILL");
|
|
162272
162285
|
};
|
|
162273
|
-
const
|
|
162286
|
+
const terminate = () => {
|
|
162274
162287
|
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
162275
162288
|
child.kill(terminationSignal(request.signal));
|
|
162276
162289
|
forceTerminationTimer = setTimeout(() => {
|
|
@@ -162278,8 +162291,19 @@ async function requestAppServer(request) {
|
|
|
162278
162291
|
}, forceTerminationDelayMilliseconds);
|
|
162279
162292
|
forceTerminationTimer.unref();
|
|
162280
162293
|
};
|
|
162281
|
-
|
|
162282
|
-
|
|
162294
|
+
const onAbort = () => {
|
|
162295
|
+
if (cancelling || child.exitCode !== null || child.signalCode !== null) return;
|
|
162296
|
+
cancelling = true;
|
|
162297
|
+
if (requestTimeoutTimer) clearTimeout(requestTimeoutTimer);
|
|
162298
|
+
if (request.cancellation && !child.stdin.writableEnded && !child.stdin.destroyed) {
|
|
162299
|
+
child.stdin.end(`${JSON.stringify({
|
|
162300
|
+
id: 2,
|
|
162301
|
+
...request.cancellation
|
|
162302
|
+
})}\n`);
|
|
162303
|
+
forceTerminationTimer = setTimeout(terminate, cooperativeCancellationDelayMilliseconds);
|
|
162304
|
+
forceTerminationTimer.unref();
|
|
162305
|
+
} else terminate();
|
|
162306
|
+
};
|
|
162283
162307
|
child.stdin.on("error", () => {});
|
|
162284
162308
|
const decoder = new StringDecoder("utf8");
|
|
162285
162309
|
let pending = "";
|
|
@@ -162297,12 +162321,22 @@ async function requestAppServer(request) {
|
|
|
162297
162321
|
method: request.method,
|
|
162298
162322
|
params: request.params
|
|
162299
162323
|
})}\n`);
|
|
162324
|
+
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
162325
|
+
if (request.signal?.aborted) onAbort();
|
|
162326
|
+
else if (request.timeoutMs !== void 0) {
|
|
162327
|
+
requestTimeoutTimer = setTimeout(() => {
|
|
162328
|
+
timedOut = true;
|
|
162329
|
+
onAbort();
|
|
162330
|
+
}, request.timeoutMs);
|
|
162331
|
+
requestTimeoutTimer.unref();
|
|
162332
|
+
}
|
|
162300
162333
|
try {
|
|
162301
162334
|
const [code, stdout, stderr] = await Promise.all([
|
|
162302
162335
|
exited,
|
|
162303
162336
|
stdoutPromise,
|
|
162304
162337
|
readBounded(child.stderr, terminateForOverflow)
|
|
162305
162338
|
]);
|
|
162339
|
+
if (timedOut) throw new AppServerTimeoutError(request.timeoutMs);
|
|
162306
162340
|
if (request.signal?.aborted) throw cancellationError(request.signal);
|
|
162307
162341
|
if (overflow) throw new Error(`App-server output exceeded ${maximumOutputBytes} bytes.`);
|
|
162308
162342
|
if (launchError) throw launchError;
|
|
@@ -162313,6 +162347,7 @@ async function requestAppServer(request) {
|
|
|
162313
162347
|
if (stderr) request.onStderr?.(stderr);
|
|
162314
162348
|
return envelope.result;
|
|
162315
162349
|
} finally {
|
|
162350
|
+
if (requestTimeoutTimer) clearTimeout(requestTimeoutTimer);
|
|
162316
162351
|
if (forceTerminationTimer) clearTimeout(forceTerminationTimer);
|
|
162317
162352
|
request.signal?.removeEventListener("abort", onAbort);
|
|
162318
162353
|
}
|