zcode-app-cli 3.14.1-27 → 3.14.3-28
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/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/README.md +40 -0
- package/LICENSES/ZCode-NOTICE.md +70 -0
- package/LICENSES/ZCode-THIRD-PARTY-NOTICES.md +50160 -0
- package/README.md +78 -14
- package/docs/THIRD_PARTY_CONTENT.md +102 -0
- package/package.json +7 -2
- package/vendor/cli-config.cjs +209 -0
- package/vendor/extraction.json +9 -4
- package/vendor/node_modules/@zcode/tui/dist/index.js +532 -29
- package/vendor/packages/bundled-skills/README.md +29 -0
- package/vendor/packages/{zcode-guide-plugin → bundled-skills}/skills/dynamic-workflows/SKILL.md +625 -147
- package/vendor/packages/{zcode-guide-plugin → bundled-skills}/skills/dynamic-workflows/examples.md +143 -3
- package/vendor/packages/node-repl-host/dist/mcp/server.js +1 -1
- package/vendor/packages/zcode-guide-plugin/.zcode-plugin/plugin.json +2 -3
- package/vendor/packages/zcode-guide-plugin/package.json +1 -1
- package/vendor/zcode.cjs +1072 -1054
- package/zcode-runtime.lock.json +3 -3
- package/vendor/packages/zcode-guide-plugin/commands/workflow.md +0 -14
- /package/vendor/packages/{zcode-guide-plugin → bundled-skills}/skills/dynamic-workflows/patterns.md +0 -0
package/README.md
CHANGED
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/zcode-app-cli)
|
|
5
5
|
[](./LICENSE)
|
|
6
6
|
|
|
7
|
-
Unofficial terminal client for the
|
|
7
|
+
Unofficial terminal client for the ZCode agent runtime.
|
|
8
8
|
|
|
9
|
-
The
|
|
10
|
-
|
|
9
|
+
The official ZCode source is available at
|
|
10
|
+
[zai-org/ZCode](https://github.com/zai-org/ZCode), with first-party source under
|
|
11
|
+
Apache-2.0 and separate terms for third-party content.
|
|
12
|
+
|
|
13
|
+
This community client packages the runtime from a pinned ZCode Desktop release,
|
|
14
|
+
applies compatibility patches, and supplies a terminal interface based on
|
|
11
15
|
[`@earendil-works/pi-tui`](https://github.com/earendil-works/pi/tree/main/packages/tui),
|
|
12
|
-
|
|
13
|
-
terminal.
|
|
16
|
+
running as a Node.js child process in your terminal. The npm package includes
|
|
17
|
+
the runtime; installing ZCode Desktop is not required for normal terminal use.
|
|
18
|
+
Local development can also extract the runtime from an installed Desktop app.
|
|
14
19
|
|
|
15
|
-
This project is not affiliated with or endorsed by Z.ai.
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
This project is not affiliated with or endorsed by Z.ai. Its own code is MIT;
|
|
21
|
+
bundled upstream content retains its respective licenses. See
|
|
22
|
+
[License and attribution](#license-and-attribution).
|
|
18
23
|
|
|
19
24
|

|
|
20
25
|
|
|
@@ -49,6 +54,7 @@ Node.js example, terminal/PTY requirements, and compatibility rules.
|
|
|
49
54
|
|
|
50
55
|
- [Quick start](#quick-start)
|
|
51
56
|
- [Host integration](#host-integration)
|
|
57
|
+
- [Relationship to the official project](#relationship-to-the-official-project)
|
|
52
58
|
- [Install and update](#install-and-update)
|
|
53
59
|
- [Architecture](#architecture)
|
|
54
60
|
- [Features](#features)
|
|
@@ -58,7 +64,25 @@ Node.js example, terminal/PTY requirements, and compatibility rules.
|
|
|
58
64
|
- [Configuration](#configuration)
|
|
59
65
|
- [Local development](#local-development)
|
|
60
66
|
- [Contributing](#contributing)
|
|
61
|
-
- [License](#license)
|
|
67
|
+
- [License and attribution](#license-and-attribution)
|
|
68
|
+
|
|
69
|
+
## Relationship to the official project
|
|
70
|
+
|
|
71
|
+
The [official repository](https://github.com/zai-org/ZCode) contains Desktop,
|
|
72
|
+
Web, backend services, and the Agent CLI/runtime in `apps/zcode-cli`. It also
|
|
73
|
+
contains an official TUI implemented with OpenTUI and React. Follow its README
|
|
74
|
+
for official build and installation instructions.
|
|
75
|
+
|
|
76
|
+
`zcode-app-cli` supplies its own pi-tui interface and npm packaging. Its release
|
|
77
|
+
pipeline still extracts compiled Desktop artifacts using
|
|
78
|
+
`zcode-runtime.lock.json`; it does not build the newly published source tree.
|
|
79
|
+
`vendor/extraction.json` records the artifact origin and local patches. The
|
|
80
|
+
public source revision and the extracted release are separate provenance records.
|
|
81
|
+
|
|
82
|
+
Provider configuration is shared with Desktop by default. Session storage and
|
|
83
|
+
feature compatibility depend on the runtime version and configured paths;
|
|
84
|
+
sharing providers does not guarantee that every client discovers the same
|
|
85
|
+
sessions. See [Configuration](./docs/CONFIGURATION.md).
|
|
62
86
|
|
|
63
87
|
## Install and update
|
|
64
88
|
|
|
@@ -91,6 +115,11 @@ Node.js npm launcher (config / login / version metadata)
|
|
|
91
115
|
└─ @earendil-works/pi-tui
|
|
92
116
|
```
|
|
93
117
|
|
|
118
|
+
`@zcode/tui` is the interface package loaded by the upstream runtime. During
|
|
119
|
+
synchronization this project installs its local implementation from
|
|
120
|
+
`packages/zcode-tui`, built on `@earendil-works/pi-tui`. This is separate from
|
|
121
|
+
the official OpenTUI implementation in `apps/zcode-cli/packages/tui`.
|
|
122
|
+
|
|
94
123
|
The official agent, model, session, tool, plugin, MCP, credential store and
|
|
95
124
|
provider-configuration logic remains in the extracted runtime. The local
|
|
96
125
|
package supplies the missing terminal interface and a narrow macOS callback
|
|
@@ -275,6 +304,11 @@ picker to return to input selection, then `Esc` again to close rewind.
|
|
|
275
304
|
/status inspect detailed runtime and session status
|
|
276
305
|
/rename <title> rename the current session
|
|
277
306
|
/activity inspect every active tool and open task
|
|
307
|
+
/queue reorder, delete or edit queued drafts
|
|
308
|
+
/queue pause|resume pause or resume automatic draft submission
|
|
309
|
+
/edit-message rewind to an earlier question and edit it
|
|
310
|
+
/retry rewind to an earlier question and send it again
|
|
311
|
+
/workflows inspect workflow progress, artifacts and recovery
|
|
278
312
|
/tasks inspect and manage background tasks
|
|
279
313
|
/tasks message <id> <text> send guidance to a running background agent
|
|
280
314
|
/tasks resume <id> [text] resume a stopped or failed background agent
|
|
@@ -291,6 +325,19 @@ picker to return to input selection, then `Esc` again to close rewind.
|
|
|
291
325
|
runtime's own `/clear` is an alias of `/new` and starts a fresh session, so it
|
|
292
326
|
is forwarded to the runtime unchanged.
|
|
293
327
|
|
|
328
|
+
`/queue` manages local next-turn drafts and pauses automatic sending while its
|
|
329
|
+
picker is open. Inputs already accepted by the runtime cannot be edited here.
|
|
330
|
+
`/queue pause` persists across turns until `/queue resume`. Moving a draft to
|
|
331
|
+
the editor preserves its original text; Tab queues the edited draft again.
|
|
332
|
+
|
|
333
|
+
`/edit-message` and `/retry` require an idle conversation and ask before removing
|
|
334
|
+
later turns. Both use conversation-only rewind and keep workspace files as they
|
|
335
|
+
are. Editing restores the selected question to the editor; retry sends it again
|
|
336
|
+
with the current model. Existing `/fork` remains available for checkpoint-based
|
|
337
|
+
branches that preserve the original conversation.
|
|
338
|
+
These actions restore question text only; original image attachments are not
|
|
339
|
+
resent. Use `/edit-message` and reattach images when they are needed.
|
|
340
|
+
|
|
294
341
|
The task center keeps autonomous task output out of the foreground transcript.
|
|
295
342
|
The main conversation receives only compact completion, reply and failure
|
|
296
343
|
notices; select the task to inspect its output and task-scoped activity. Agent
|
|
@@ -317,9 +364,9 @@ entire message at once. `Esc` leaves search or transcript navigation.
|
|
|
317
364
|
|
|
318
365
|
## Plugin management
|
|
319
366
|
|
|
320
|
-
Built-in Plugins such as Browser Use,
|
|
321
|
-
|
|
322
|
-
|
|
367
|
+
Built-in Plugins such as Browser Use, Image Search and Skill Creator are seeded
|
|
368
|
+
by the official runtime. Existing installed-plugin commands continue to use the
|
|
369
|
+
runtime directly:
|
|
323
370
|
|
|
324
371
|
```bash
|
|
325
372
|
zcode plugins list --json
|
|
@@ -328,6 +375,11 @@ zcode plugins disable <plugin-id>
|
|
|
328
375
|
zcode plugins uninstall <plugin-id> --force
|
|
329
376
|
```
|
|
330
377
|
|
|
378
|
+
The npm package includes the document, PDF, presentation and spreadsheet skill
|
|
379
|
+
Plugins with their original license files. Their bundled skills retain the
|
|
380
|
+
upstream personal, educational and non-commercial use terms.
|
|
381
|
+
See [Third-party content](./docs/THIRD_PARTY_CONTENT.md).
|
|
382
|
+
|
|
331
383
|
The npm launcher adds marketplace operations by calling the runtime's public
|
|
332
384
|
`app-server` protocol; it does not patch or reimplement the Plugin subsystem.
|
|
333
385
|
Run `zcode plugins --help` for the full command list. A typical third-party
|
|
@@ -460,6 +512,18 @@ Please open an issue first to discuss substantial changes. See
|
|
|
460
512
|
[Development](./docs/DEVELOPMENT.md) for the local setup and validation
|
|
461
513
|
commands, and [Releasing](./docs/RELEASING.md) for the release flow.
|
|
462
514
|
|
|
463
|
-
## License
|
|
515
|
+
## License and attribution
|
|
516
|
+
|
|
517
|
+
This project's launcher, local TUI and other original source are MIT — see
|
|
518
|
+
[LICENSE](./LICENSE). That license does not relicense bundled dependencies,
|
|
519
|
+
upstream code or plugin assets.
|
|
520
|
+
|
|
521
|
+
ZCode's public first-party source is Apache-2.0. The npm package includes
|
|
522
|
+
[the license text](./LICENSES/Apache-2.0.txt), copies of upstream notices, and
|
|
523
|
+
[their source revision](./LICENSES/README.md). The extracted runtime has a
|
|
524
|
+
modification notice; `vendor/extraction.json` records its compatibility patches.
|
|
464
525
|
|
|
465
|
-
|
|
526
|
+
Plugin manifests and embedded dependencies have their own license declarations.
|
|
527
|
+
The four document-related plugin packages are included in npm releases with
|
|
528
|
+
their original non-commercial skill licenses. See [Third-party content](./docs/THIRD_PARTY_CONTENT.md)
|
|
529
|
+
for the scope of these notices and the distribution policy.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Third-party content in the published package
|
|
2
|
+
|
|
3
|
+
This project's original launcher, TUI and supporting code use the
|
|
4
|
+
[MIT license](../LICENSE). The npm package also contains upstream code and
|
|
5
|
+
dependencies; the MIT declaration in `package.json` does not replace their terms.
|
|
6
|
+
|
|
7
|
+
## Source and release provenance
|
|
8
|
+
|
|
9
|
+
[zai-org/ZCode](https://github.com/zai-org/ZCode) publishes first-party source
|
|
10
|
+
under Apache-2.0. Its root notices explicitly preserve separate terms for
|
|
11
|
+
third-party code, dependencies, assets and native binaries.
|
|
12
|
+
|
|
13
|
+
This project extracts the compiled runtime from Desktop release artifacts,
|
|
14
|
+
rather than building that source tree. Release artifacts are pinned by URL and
|
|
15
|
+
SHA-512 in `zcode-runtime.lock.json`. Local development can instead use an
|
|
16
|
+
installed Desktop app. `vendor/extraction.json` records the source, version and
|
|
17
|
+
compatibility patches applied.
|
|
18
|
+
|
|
19
|
+
The [upstream notices shipped here](../LICENSES/README.md) come from a separately
|
|
20
|
+
pinned public source revision. That revision declares version 3.14.0; the current
|
|
21
|
+
runtime lock selects Desktop 3.14.1. The notices are a conservative upstream
|
|
22
|
+
inventory, not proof that the extracted binary was built from that exact commit
|
|
23
|
+
or that every listed component is included in this npm package. Review artifact
|
|
24
|
+
contents and applicable terms when updating the runtime.
|
|
25
|
+
|
|
26
|
+
## Included components
|
|
27
|
+
|
|
28
|
+
| Component | Package location | Attribution and terms |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| Extracted agent runtime | `vendor/zcode.cjs` | ZCode first-party source: Apache-2.0; embedded dependencies retain their own terms |
|
|
31
|
+
| Provider catalog | `vendor/provider/zcode-builtin.json` | Copied from the selected Desktop artifact; upstream first-party source: Apache-2.0 |
|
|
32
|
+
| Built-in plugin packages | `vendor/packages/*` | Per-package declarations and any nested license files; see below |
|
|
33
|
+
| Bundled npm dependencies | Inside runtime bundles and plugin `node_modules` | Original dependency licenses and notices |
|
|
34
|
+
| Local TUI adapter and configuration bridge | `vendor/node_modules/@zcode/tui`, `vendor/cli-config.cjs` | This project's MIT-licensed code and its dependencies |
|
|
35
|
+
| Public launcher | `bin/zcode.js` | This project's MIT-licensed code |
|
|
36
|
+
| Installed npm dependencies | `@earendil-works/pi-tui`, `playwright-core` and their dependencies | Their respective licenses, distributed with those packages |
|
|
37
|
+
|
|
38
|
+
The compiled runtime carries a notice identifying local modifications.
|
|
39
|
+
Synchronization retains the existing upstream content and adds compatibility
|
|
40
|
+
patches; the patch report is in `vendor/extraction.json`.
|
|
41
|
+
|
|
42
|
+
## Plugin declarations
|
|
43
|
+
|
|
44
|
+
These are the declarations observed in the Desktop 3.14.1 packages, not a
|
|
45
|
+
replacement for nested dependency or asset licenses:
|
|
46
|
+
|
|
47
|
+
| Package directory | Manifest declaration |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `browser-use-plugin` | MIT |
|
|
50
|
+
| `image-search-plugin` | Apache-2.0 |
|
|
51
|
+
| `node-repl-host` | No package-level license field; its public first-party source falls under the upstream root Apache-2.0 license |
|
|
52
|
+
| `skill-creator-plugin`, `plugin-creator-plugin`, `zcode-guide-plugin` | MIT |
|
|
53
|
+
| `zcode-cua-plugin`, `ios-simulator-plugin`, `android-emulator-plugin` | MIT |
|
|
54
|
+
| `restore-legacy-sessions-plugin` | MIT |
|
|
55
|
+
|
|
56
|
+
A package's manifest does not establish the license of every bundled asset.
|
|
57
|
+
For example, the public source repository describes Computer Use as a placeholder;
|
|
58
|
+
it must not be assumed identical to the implementation in a Desktop artifact.
|
|
59
|
+
Preserve the license and notice files distributed with dependencies.
|
|
60
|
+
|
|
61
|
+
## Document plugins
|
|
62
|
+
|
|
63
|
+
The following Desktop packages declare `SEE LICENSE IN skills/<name>/LICENSE.txt`.
|
|
64
|
+
Their skill licenses state:
|
|
65
|
+
|
|
66
|
+
> Copyright (c) 2026 Z.ai All rights reserved.
|
|
67
|
+
>
|
|
68
|
+
> Permission is granted for personal, educational, and non-commercial use only.
|
|
69
|
+
>
|
|
70
|
+
> Commercial use is strictly prohibited without prior written permission from the author.
|
|
71
|
+
|
|
72
|
+
| Package directory | License file within the package |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `documents-plugin` | `skills/docx/LICENSE.txt` |
|
|
75
|
+
| `pdf-plugin` | `skills/pdf/LICENSE.txt` |
|
|
76
|
+
| `presentations-plugin` | `skills/pptx/LICENSE.txt` |
|
|
77
|
+
| `spreadsheets-plugin` | `skills/xlsx/LICENSE.txt` |
|
|
78
|
+
|
|
79
|
+
This project includes these four packages in its non-commercial npm distribution
|
|
80
|
+
with their original skill license files. Their use restrictions remain in effect;
|
|
81
|
+
this project's MIT license does not replace those terms.
|
|
82
|
+
|
|
83
|
+
Synchronization copies these plugins from the selected Desktop source into
|
|
84
|
+
`vendor/packages/`, and `package.json` includes them in the npm package. The
|
|
85
|
+
installed-package smoke test verifies that all four plugins initialize and are
|
|
86
|
+
enabled. Package validation and installation checks also require their original
|
|
87
|
+
skill license files.
|
|
88
|
+
|
|
89
|
+
## Notices shipped with the package
|
|
90
|
+
|
|
91
|
+
- [Apache-2.0 license](../LICENSES/Apache-2.0.txt)
|
|
92
|
+
- [Upstream NOTICE](../LICENSES/ZCode-NOTICE.md)
|
|
93
|
+
- [Upstream third-party notices](../LICENSES/ZCode-THIRD-PARTY-NOTICES.md)
|
|
94
|
+
- [Notice provenance and scope](../LICENSES/README.md)
|
|
95
|
+
|
|
96
|
+
These copies retain the upstream text with LF line endings. Relative links inside
|
|
97
|
+
them refer to the upstream source tree, not this repository. Upstream behavioral descriptions
|
|
98
|
+
apply to the distributions they describe; this CLI's behavior is documented in
|
|
99
|
+
its own README and configuration guide.
|
|
100
|
+
|
|
101
|
+
ZCode and Z.ai names identify the upstream project. This community client is
|
|
102
|
+
not affiliated with or endorsed by Z.ai.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcode-app-cli",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.3-28",
|
|
4
4
|
"description": "Unofficial terminal client for the ZCode agent runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"docs/CONFIGURATION.zh-CN.md",
|
|
39
39
|
"docs/PROVIDER_CONFIG.md",
|
|
40
40
|
"docs/PROVIDER_CONFIG.zh-CN.md",
|
|
41
|
+
"docs/THIRD_PARTY_CONTENT.md",
|
|
42
|
+
"LICENSES/Apache-2.0.txt",
|
|
43
|
+
"LICENSES/README.md",
|
|
44
|
+
"LICENSES/ZCode-NOTICE.md",
|
|
45
|
+
"LICENSES/ZCode-THIRD-PARTY-NOTICES.md",
|
|
41
46
|
"zcode-runtime.lock.json",
|
|
42
47
|
"README.md",
|
|
43
48
|
"LICENSE"
|
|
@@ -65,7 +70,7 @@
|
|
|
65
70
|
"test:node": "node --test test/node/*.test.cjs",
|
|
66
71
|
"test:tui": "bun run test:tui:component && bun run test:tui:e2e",
|
|
67
72
|
"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",
|
|
68
|
-
"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/session-rename.test.ts test/tui/terminal-session.test.ts test/tui/write-and-diff.test.ts",
|
|
73
|
+
"test:tui:e2e": "bun test test/tui/allowlisted-shell.test.ts test/tui/dynamic-workflows.test.ts test/tui/http-mock.test.ts test/tui/input-actions.test.ts test/tui/model-resume.test.ts test/tui/permission-request-queue.test.ts test/tui/run-scenario.test.ts test/tui/runtime-refresh.test.ts test/tui/session-rename.test.ts test/tui/terminal-session.test.ts test/tui/write-and-diff.test.ts",
|
|
69
74
|
"test:tui:host": "bun test test/tui/scenario-mountx.test.ts",
|
|
70
75
|
"test:tui:manual": "bun scripts/tui-scenario.ts --manual",
|
|
71
76
|
"test:tui-scenario": "bun scripts/tui-scenario.ts",
|
package/vendor/cli-config.cjs
CHANGED
|
@@ -87,6 +87,212 @@ function assertSessionModelReady(options) {
|
|
|
87
87
|
if (state.issue) throw new Error(`${state.issue.message} Resume interactively with zcode --resume ${options.sessionId} and use /model to choose a replacement. No model request was sent.`);
|
|
88
88
|
}
|
|
89
89
|
//#endregion
|
|
90
|
+
//#region src/runtime-tui-bridge.ts
|
|
91
|
+
const maximumTaskMessageLength = 2e4;
|
|
92
|
+
const maximumTaskSummaryLength = 200;
|
|
93
|
+
function taskDetail(task) {
|
|
94
|
+
const running = task.status === "running";
|
|
95
|
+
const kind = task.taskType ?? task.type;
|
|
96
|
+
return {
|
|
97
|
+
taskId: task.taskId,
|
|
98
|
+
taskKind: kind,
|
|
99
|
+
agentId: task.agentId,
|
|
100
|
+
agentType: task.agentType,
|
|
101
|
+
childSessionId: task.childSessionId,
|
|
102
|
+
parentSessionId: task.parentSessionId,
|
|
103
|
+
parentToolCallId: task.parentToolCallId,
|
|
104
|
+
turnId: task.turnId,
|
|
105
|
+
prompt: task.prompt,
|
|
106
|
+
error: running ? null : task.error instanceof Error ? task.error.message : typeof task.error === "string" ? task.error : void 0,
|
|
107
|
+
outputPath: task.outputFile,
|
|
108
|
+
status: task.status,
|
|
109
|
+
description: task.description,
|
|
110
|
+
startedAt: task.startedAt,
|
|
111
|
+
completedAt: running ? null : task.completedAt,
|
|
112
|
+
cancelRequestedAt: running ? null : task.cancelRequestedAt,
|
|
113
|
+
blocked: running ? null : task.blocked,
|
|
114
|
+
blockedReason: running ? null : task.blockedReason,
|
|
115
|
+
cancellable: kind === "local_agent" ? running : task.cancellable
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function readTuiRuntimeProjection(app, bridge) {
|
|
119
|
+
const executionState = await app.readExecutionState();
|
|
120
|
+
await bridge.$zRestorePersistedBackgroundTasks?.(app);
|
|
121
|
+
const projection = await app.runtime?.getProjection?.();
|
|
122
|
+
if (!projection) return null;
|
|
123
|
+
const details = Object.values(app.runtime?.runtimeTaskRegistry?.all?.() ?? {}).filter((task) => task.isBackgrounded === true).map(taskDetail);
|
|
124
|
+
const tasks = Array.isArray(projection.backgroundTasks) ? projection.backgroundTasks.slice() : [];
|
|
125
|
+
for (const detail of details) {
|
|
126
|
+
const index = tasks.findIndex((existing) => existing.taskId === detail.taskId);
|
|
127
|
+
if (index < 0) tasks.push(detail);
|
|
128
|
+
else tasks[index] = {
|
|
129
|
+
...tasks[index],
|
|
130
|
+
...Object.fromEntries(Object.entries(detail).filter(([, value]) => value !== void 0))
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
...projection,
|
|
135
|
+
...executionState && typeof executionState === "object" ? executionState : {},
|
|
136
|
+
backgroundTasks: tasks,
|
|
137
|
+
backgroundTaskDetails: details,
|
|
138
|
+
restoredBackgroundTasks: Array.isArray(app.$zRestoredBackgroundTasksLog) ? app.$zRestoredBackgroundTasksLog : []
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async function sendTuiBackgroundTaskMessage(app, bridge, input) {
|
|
142
|
+
await bridge.$zRestorePersistedBackgroundTasks?.(app);
|
|
143
|
+
const runtime = app.runtime;
|
|
144
|
+
let task = runtime?.runtimeTaskRegistry?.get?.(input?.taskId);
|
|
145
|
+
if (!task && typeof app.sessionId === "string") {
|
|
146
|
+
app.$zRestoredBackgroundTasksSession = void 0;
|
|
147
|
+
await bridge.$zRestorePersistedBackgroundTasks?.(app);
|
|
148
|
+
task = runtime?.runtimeTaskRegistry?.get?.(input?.taskId);
|
|
149
|
+
}
|
|
150
|
+
if (!runtime?.subagentPort?.sendMessage) throw new Error("Background agent messaging is unavailable in this runtime.");
|
|
151
|
+
if (!task || (task.type ?? task.taskType) !== "local_agent") throw new Error("The selected task is not a local agent.");
|
|
152
|
+
if (typeof input?.message !== "string" || !input.message.trim()) throw new Error("Enter a message for the background agent.");
|
|
153
|
+
const message = input.message.trim().slice(0, maximumTaskMessageLength);
|
|
154
|
+
const summary = (typeof input.summary === "string" ? input.summary : message).replace(/\s+/g, " ").trim().slice(0, maximumTaskSummaryLength);
|
|
155
|
+
if (input.restart === true && task.status === "running") {
|
|
156
|
+
if (!runtime.subagentPort.stopTask) throw new Error("Background agent restart is unavailable in this runtime.");
|
|
157
|
+
await runtime.subagentPort.stopTask(input.taskId);
|
|
158
|
+
task = runtime.runtimeTaskRegistry?.get?.(input.taskId);
|
|
159
|
+
if (!task) throw new Error("The background agent stopped but could not be restored.");
|
|
160
|
+
}
|
|
161
|
+
return await runtime.subagentPort.sendMessage({
|
|
162
|
+
sessionId: task.parentSessionId ?? runtime.getSessionId?.(),
|
|
163
|
+
turnId: task.turnId ?? "tui-task-message",
|
|
164
|
+
parentToolCallId: task.parentToolCallId ?? "tui-task-message",
|
|
165
|
+
to: task.agentId ?? input.taskId,
|
|
166
|
+
summary,
|
|
167
|
+
message,
|
|
168
|
+
workingDirectory: task.workingDirectory ?? runtime.workingDirectory,
|
|
169
|
+
workspaceRoot: task.workspaceRoot ?? runtime.workingDirectory,
|
|
170
|
+
trace: task.traceContext ?? runtime.rootTraceContext
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/runtime-background-restore.ts
|
|
175
|
+
const maximumReminderLength = 4e3;
|
|
176
|
+
function record$1(value) {
|
|
177
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
178
|
+
}
|
|
179
|
+
function text(value) {
|
|
180
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
181
|
+
}
|
|
182
|
+
function parseSpawn(output, input) {
|
|
183
|
+
try {
|
|
184
|
+
const parsed = record$1(JSON.parse(output));
|
|
185
|
+
if (parsed) return parsed;
|
|
186
|
+
} catch {}
|
|
187
|
+
if (!output.includes("Async agent launched successfully.")) return void 0;
|
|
188
|
+
const agentId = /(?:^|\n)agentId:\s*([^\s(]+)/u.exec(output)?.[1];
|
|
189
|
+
if (!agentId) return void 0;
|
|
190
|
+
return {
|
|
191
|
+
status: "async_launched",
|
|
192
|
+
agentId,
|
|
193
|
+
agentType: text(input?.subagent_type) ?? text(input?.agentType),
|
|
194
|
+
childSessionId: `sess_subagent_${agentId}`,
|
|
195
|
+
description: text(input?.description),
|
|
196
|
+
prompt: text(input?.prompt),
|
|
197
|
+
outputFile: /(?:^|\n)output_file:\s*([^\r\n]+)/u.exec(output)?.[1]?.trim()
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
async function readMetadata(outputFile) {
|
|
201
|
+
if (!text(outputFile)) return void 0;
|
|
202
|
+
try {
|
|
203
|
+
return record$1(JSON.parse(await (0, node_fs_promises.readFile)((0, node_path.join)((0, node_path.dirname)(outputFile), "metadata.json"), "utf8")));
|
|
204
|
+
} catch {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function enrichSpawn(spawn, metadata, sessionId) {
|
|
209
|
+
if (!metadata || typeof metadata.agentId === "string" && metadata.agentId !== spawn.agentId || typeof metadata.parentSessionId === "string" && metadata.parentSessionId !== sessionId) return spawn;
|
|
210
|
+
return {
|
|
211
|
+
...spawn,
|
|
212
|
+
agentType: text(metadata.profileId) ?? spawn.agentType,
|
|
213
|
+
childSessionId: text(metadata.childSessionId) ?? spawn.childSessionId,
|
|
214
|
+
description: text(metadata.description) ?? spawn.description,
|
|
215
|
+
outputFile: text(metadata.outputFile) ?? spawn.outputFile,
|
|
216
|
+
prompt: text(metadata.prompt) ?? spawn.prompt,
|
|
217
|
+
error: text(metadata.error) ?? spawn.error
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async function restore(app) {
|
|
221
|
+
const runtime = app.runtime;
|
|
222
|
+
const registry = runtime?.runtimeTaskRegistry;
|
|
223
|
+
const sessionId = app.sessionId;
|
|
224
|
+
if (!registry?.register || typeof sessionId !== "string" || sessionId === app.$zRestoredBackgroundTasksSession) return;
|
|
225
|
+
app.$zRestoredBackgroundTasksSession = sessionId;
|
|
226
|
+
app.$zRestoredBackgroundTasksLog = [];
|
|
227
|
+
try {
|
|
228
|
+
const messages = await app.loadSessionTranscript?.() ?? [];
|
|
229
|
+
const restored = [];
|
|
230
|
+
for (const messageValue of messages) {
|
|
231
|
+
const parts = record$1(messageValue)?.parts;
|
|
232
|
+
if (!Array.isArray(parts)) continue;
|
|
233
|
+
for (const value of parts) {
|
|
234
|
+
const part = record$1(value);
|
|
235
|
+
if (part?.type !== "tool") continue;
|
|
236
|
+
const tool = (typeof part.toolName === "string" ? part.toolName : typeof part.tool === "string" ? part.tool : "").trim().toLowerCase();
|
|
237
|
+
if (![
|
|
238
|
+
"agent",
|
|
239
|
+
"subagent",
|
|
240
|
+
"task"
|
|
241
|
+
].includes(tool)) continue;
|
|
242
|
+
const state = record$1(part.state);
|
|
243
|
+
const output = typeof part.output === "string" ? part.output : state?.output;
|
|
244
|
+
if (typeof output !== "string" || !output.trim()) continue;
|
|
245
|
+
let spawn = parseSpawn(output, record$1(part.input ?? state?.input));
|
|
246
|
+
if (!spawn || !["async_launched", "backgrounded"].includes(String(spawn.status)) || !text(spawn.agentId)) continue;
|
|
247
|
+
const metadata = await readMetadata(spawn.outputFile);
|
|
248
|
+
spawn = enrichSpawn(spawn, metadata, sessionId);
|
|
249
|
+
const agentId = spawn.agentId;
|
|
250
|
+
if (registry.get?.(agentId)) continue;
|
|
251
|
+
const task = {
|
|
252
|
+
taskId: agentId,
|
|
253
|
+
agentId,
|
|
254
|
+
agentType: text(spawn.agentType) ?? "general-purpose",
|
|
255
|
+
childSessionId: text(spawn.childSessionId) ?? `sess_subagent_${agentId}`,
|
|
256
|
+
description: text(spawn.description),
|
|
257
|
+
error: text(spawn.error),
|
|
258
|
+
isBackgrounded: true,
|
|
259
|
+
outputFile: text(spawn.outputFile),
|
|
260
|
+
parentToolCallId: text(part.toolCallId) ?? text(part.callID),
|
|
261
|
+
parentSessionId: sessionId,
|
|
262
|
+
prompt: text(spawn.prompt),
|
|
263
|
+
startedAt: record$1(state?.time)?.start,
|
|
264
|
+
status: metadata?.status === "completed" ? "completed" : metadata?.status === "failed" ? "failed" : "stopped",
|
|
265
|
+
taskType: "local_agent",
|
|
266
|
+
type: "local_agent"
|
|
267
|
+
};
|
|
268
|
+
registry.register(task);
|
|
269
|
+
restored.push(task);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (restored.length === 0) return;
|
|
273
|
+
const taskIds = restored.slice(-32).map((task) => `- ${task.taskId} (${task.status})`).join("\n").slice(0, maximumReminderLength);
|
|
274
|
+
runtime?.messageHistory?.addAttachment?.("task_status", `Background agent tasks from this resumed session have been restored and are available again.
|
|
275
|
+
Earlier TaskOutput errors saying "No task found" occurred before restoration and are stale.
|
|
276
|
+
Use TaskOutput to collect results or SendMessage to continue a task. Do not assume these tasks were lost.
|
|
277
|
+
Restored task IDs:\n${taskIds}`);
|
|
278
|
+
app.$zRestoredBackgroundTasksLog = [...app.$zRestoredBackgroundTasksLog ?? [], ...restored].slice(-64);
|
|
279
|
+
} catch {
|
|
280
|
+
app.$zRestoredBackgroundTasksSession = void 0;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const pendingRestores = /* @__PURE__ */ new WeakMap();
|
|
284
|
+
async function restoreTuiBackgroundTasks(app) {
|
|
285
|
+
const pending = pendingRestores.get(app);
|
|
286
|
+
if (pending) return pending;
|
|
287
|
+
const operation = restore(app);
|
|
288
|
+
pendingRestores.set(app, operation);
|
|
289
|
+
try {
|
|
290
|
+
await operation;
|
|
291
|
+
} finally {
|
|
292
|
+
pendingRestores.delete(app);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
90
296
|
//#region src/runtime-config-bridge.ts
|
|
91
297
|
function record(value) {
|
|
92
298
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -208,3 +414,6 @@ exports.mergeDesktopSettings = mergeDesktopSettings;
|
|
|
208
414
|
exports.migrateLegacyProviders = migrateLegacyProviders;
|
|
209
415
|
exports.providerMigrationNeeded = providerMigrationNeeded;
|
|
210
416
|
exports.readSessionModelState = readSessionModelState;
|
|
417
|
+
exports.readTuiRuntimeProjection = readTuiRuntimeProjection;
|
|
418
|
+
exports.restoreTuiBackgroundTasks = restoreTuiBackgroundTasks;
|
|
419
|
+
exports.sendTuiBackgroundTaskMessage = sendTuiBackgroundTaskMessage;
|
package/vendor/extraction.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"appVersion": "3.14.
|
|
2
|
+
"appVersion": "3.14.3",
|
|
3
3
|
"cliVersion": "0.16.9",
|
|
4
|
-
"extractedAt": "2026-09-
|
|
5
|
-
"sha512": "
|
|
6
|
-
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.14.
|
|
4
|
+
"extractedAt": "2026-09-24T22:18:54.425Z",
|
|
5
|
+
"sha512": "VDYryL9bIYjM3uxRNJ8sRw5S5z9LBmRvvW1amQ9wEnhJBMc3Rlb2g8JvxWv04CPn0GgKHEJEZmWmLZuI6EYg1g==",
|
|
6
|
+
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.14.3/linux-x64/ZCode-3.14.3-linux-x64.deb",
|
|
7
7
|
"runtimeCapabilities": {
|
|
8
8
|
"schemaVersion": 1,
|
|
9
9
|
"cli": {
|
|
@@ -101,6 +101,11 @@
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
"runtimePatches": [
|
|
104
|
+
{
|
|
105
|
+
"id": "tui-workflow-reducer",
|
|
106
|
+
"requirement": "optional",
|
|
107
|
+
"status": "applied"
|
|
108
|
+
},
|
|
104
109
|
{
|
|
105
110
|
"id": "tui-execution-state",
|
|
106
111
|
"requirement": "required",
|