paseo-plugin-zcode-provider 0.4.4 → 0.5.1

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.
Files changed (59) hide show
  1. package/NOTICE.md +2 -2
  2. package/README.md +18 -13
  3. package/client/account.tsx +13 -22
  4. package/client/goal-pills.ts +252 -0
  5. package/client/goal.tsx +203 -0
  6. package/index.client.tsx +4 -0
  7. package/index.server.ts +12 -4
  8. package/package.json +4 -4
  9. package/paseo-plugin.json +1 -1
  10. package/server/build-info.ts +1 -1
  11. package/server/diagnostics.ts +4 -1
  12. package/server/discovery/manifest.ts +2 -2
  13. package/server/errors.ts +1 -0
  14. package/server/goal-command.ts +32 -0
  15. package/server/goal.ts +58 -0
  16. package/server/host/bridge.ts +3 -0
  17. package/server/mapping.ts +23 -6
  18. package/server/presentation.ts +4 -1
  19. package/server/provider-status.ts +3 -3
  20. package/server/provider.ts +91 -21
  21. package/server/runtime/pins.ts +3 -3
  22. package/server/session.ts +278 -92
  23. package/server/turn-failure.ts +6 -1
  24. package/server/usage.ts +1 -3
  25. package/server/vendor/zcode/NOTICE.md +1 -1
  26. package/server/vendor/zcode/packages/rpc/src/channelClient.ts +18 -3
  27. package/server/vendor/zcode/packages/rpc/src/channelServer.ts +32 -12
  28. package/server/vendor/zcode/packages/rpc/src/channels.shared.ts +8 -1
  29. package/server/vendor/zcode/packages/rpc/src/serialization.ts +9 -3
  30. package/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts +2 -0
  31. package/server/vendor/zcode/packages/shared/src/browser-use/commands.ts +2 -0
  32. package/server/vendor/zcode/packages/shared/src/browser-use/result.ts +4 -0
  33. package/server/vendor/zcode/packages/shared/src/gen-ui/contract.ts +246 -0
  34. package/server/vendor/zcode/packages/shared/src/gen-ui/tweakProtocol.ts +143 -0
  35. package/server/vendor/zcode/packages/shared/src/{localTtft.ts → local-ttft/contract.ts} +56 -1
  36. package/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts +8 -0
  37. package/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts +8 -0
  38. package/server/vendor/zcode/packages/shared/src/protocol.ts +2 -0
  39. package/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts +9 -1
  40. package/server/vendor/zcode/packages/shared/src/runtimeEnv.ts +10 -0
  41. package/server/vendor/zcode/packages/shared/src/server-remote.ts +2 -0
  42. package/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts +11 -0
  43. package/server/vendor/zcode/packages/shared/src/source-server/contracts.ts +21 -1
  44. package/server/vendor/zcode/packages/shared/src/source-server/errorCodes.ts +27 -9
  45. package/server/vendor/zcode/packages/shared/src/subagent-profile.ts +5 -0
  46. package/server/vendor/zcode/packages/shared/src/validationAppSettings.ts +1 -0
  47. package/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts +164 -11
  48. package/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts +1 -0
  49. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts +4 -2
  50. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts +11 -7
  51. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts +2 -0
  52. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts +2 -0
  53. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts +19 -1
  54. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts +11 -0
  55. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts +20 -1
  56. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts +8 -0
  57. package/server/vendor/zcode/packages/ui/src/v4/conversationGoalSummaryModel.ts +88 -0
  58. package/server/vendor/zcode/provenance.json +78 -64
  59. package/shared/goal.ts +89 -0
package/NOTICE.md CHANGED
@@ -16,11 +16,11 @@ ZCode は統合 CLI を配布していないため、このリポジトリは `z
16
16
 
17
17
  Node.js は利用者のマシンが nodejs.org の公式成果物を直接取得します。このリポジトリは Node.js を再配布しません。
18
18
 
19
- `server/vendor/zcode` は [zai-org/ZCode](https://github.com/zai-org/ZCode/tree/3c5b227649371507ddc4eb46ac5133afe6db1cab) の RPC、V4 契約、wire 組み立てと純粋な差分適用、および必要なスキーマ依存を含みます。第一者コードは [上流 LICENSE](server/vendor/zcode/LICENSE) の Apache-2.0、RPC と wire codec の VS Code 由来部分は [MIT の通知](server/vendor/zcode/THIRD-PARTY-NOTICES.md) の条件を保持します。[上流 NOTICE](server/vendor/zcode/NOTICE.md) は全文を保持しており、上流製品全体の説明です。そこに記載された全機能・依存がプラグインへ同梱されることを意味しません。
19
+ `server/vendor/zcode` は [zai-org/ZCode](https://github.com/zai-org/ZCode/tree/a9fe401eede6e6e5e01be9048679c206fe6f02d9) の RPC、V4 契約、wire 組み立てと純粋な差分適用、Desktop の Goal 欄の行と経過時間を求める純粋関数(`packages/ui/src/v4/conversationGoalSummaryModel.ts`、ADR 27)、および必要なスキーマ依存を含みます。第一者コードは [上流 LICENSE](server/vendor/zcode/LICENSE) の Apache-2.0、RPC と wire codec の VS Code 由来部分は [MIT の通知](server/vendor/zcode/THIRD-PARTY-NOTICES.md) の条件を保持します。[上流 NOTICE](server/vendor/zcode/NOTICE.md) は全文を保持しており、上流製品全体の説明です。そこに記載された全機能・依存がプラグインへ同梱されることを意味しません。
20
20
 
21
21
  ファイルごとの出典・SHA-256、private workspace import の変更、第三者通知の抽出範囲を [provenance.json](server/vendor/zcode/provenance.json) に記録しています。取得・照合は `scripts/sync-zcode-source.mjs` で行います。`npm run build` はこれらのライセンス・通知を `dist/licenses/zcode` にも配置します。
22
22
 
23
- 開発 SDK は `@getpaseo/plugin@0.12.0` です。ビルドは `@getpaseo/plugin/server/provider` と `zod` を外部モジュールとして維持し、Paseo に解決させます。
23
+ 開発 SDK は `@getpaseo/plugin@0.15.3` です。ビルドは `@getpaseo/plugin/server/provider` と `zod` を外部モジュールとして維持し、Paseo に解決させます。
24
24
 
25
25
  `icon.svg` は [Paseo main c424f829 の glm-acp-agent.svg](https://github.com/getpaseo/paseo/blob/c424f82922fcd36aa9cc9e473644bca04417b420/packages/app/src/assets/acp-provider-icons/glm-acp-agent.svg) のコピーです。この SVG は [ACP Registry の glm-acp-agent/icon.svg](https://github.com/agentclientprotocol/registry/blob/f3826ddd6e35951ea9b7fd0cf43c35a30c3c64cd/glm-acp-agent/icon.svg) とバイト単位で一致します。ACP Registry は Apache-2.0 で配布されており、その [LICENSE](vendor/acp-registry/LICENSE) を保持しています。アイコンは変更していません。商標への権利や公式の承認を示すものではありません。
26
26
 
package/README.md CHANGED
@@ -10,10 +10,10 @@ This is an unofficial plugin. It is not endorsed or maintained by ZCode or Z.ai.
10
10
 
11
11
  | Setting | Requirement |
12
12
  | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
13
- | Paseo | 0.9.0 or later; development SDK 0.12.0 |
13
+ | Paseo | 0.15.0 or later; development SDK 0.15.3 |
14
14
  | Plugin Node.js | 22.12.0 or later (the Paseo daemon's runtime) |
15
15
  | Managed setup | darwin-arm64, linux-x64, linux-arm64, win-x64, win-arm64 |
16
- | ZCode | Managed: 3.16.2 (release `3.16.2-paseo.1`) with Node.js 24.21.0. Overrides: stable Server 3.14.0+ / Agent 0.16.9+ with Node.js 24.14.0+ |
16
+ | ZCode | Managed: 3.17.2 (release `3.17.2-paseo.1`) with Node.js 24.21.0. Overrides: stable Server 3.14.0+ / Agent 0.16.9+ with Node.js 24.14.0+ |
17
17
 
18
18
  ## Installation
19
19
 
@@ -24,9 +24,9 @@ paseo plugin add npm:paseo-plugin-zcode-provider
24
24
  paseo plugin ls
25
25
  ```
26
26
 
27
- You can also paste `npm:paseo-plugin-zcode-provider` into **Settings → Plugins → Plugin source**. npm packages require Paseo 0.9.0 or later and npm on the daemon host. Paseo installs the released version and compiles the plugin. Update with `paseo plugin update zcode-provider`. Plugins execute with the daemon user's permissions.
27
+ You can also paste `npm:paseo-plugin-zcode-provider` into **Settings → Plugins → Plugin source**. npm packages require npm on the daemon host. Paseo installs the released version and compiles the plugin. Update with `paseo plugin update zcode-provider`. Plugins execute with the daemon user's permissions.
28
28
 
29
- To follow the `main` branch instead, install the Git repository with `paseo plugin add github:supermomonga/paseo-plugin-zcode-provider` (Paseo 0.9.0 or later). Since Paseo 0.11.0, the form without `github:` looks the plugin up in Paseo's plugin registry, which does not list it. Paseo prepares the checkout with `npm ci`.
29
+ To follow the `main` branch instead, install the Git repository with `paseo plugin add github:supermomonga/paseo-plugin-zcode-provider`. The form without `github:` looks the plugin up in Paseo's plugin registry, which does not list it. Paseo prepares the checkout with `npm ci`.
30
30
 
31
31
  ## Setup
32
32
 
@@ -35,7 +35,7 @@ Open **Settings → Plugins → zcode-provider → Settings**. The screen has th
35
35
  On the **Runtime** tab, choose **Download and install**. The screen lists every download, its SHA-256, size and license before you start. Setup runs on the machine hosting the daemon:
36
36
 
37
37
  - Node.js 24.21.0 from nodejs.org.
38
- - The ZCode runtime 3.16.2 from this repository's [releases](https://github.com/supermomonga/paseo-plugin-zcode-provider/releases/tag/zcode-runtime-v3.16.2-paseo.1) (`3.16.2-paseo.1`). ZCode does not publish its integrated CLI, so this is an **unofficial build** of the public source with the patches in [patches/zcode](patches/zcode) applied (ADR 19), made and verified by CI. The patches hide Computer Use, Browser Use and Visualize, which cannot run or render here. It is not endorsed or maintained by ZCode or Z.ai.
38
+ - The ZCode runtime 3.17.2 from this repository's [releases](https://github.com/supermomonga/paseo-plugin-zcode-provider/releases/tag/zcode-runtime-v3.17.2-paseo.1) (`3.17.2-paseo.1`). ZCode does not publish its integrated CLI, so this is an **unofficial build** of the public source with the patches in [patches/zcode](patches/zcode) applied (ADR 19), made and verified by CI. The patches hide Computer Use, Browser Use and Visualize, which cannot run or render here. It is not endorsed or maintained by ZCode or Z.ai.
39
39
 
40
40
  Both archives are verified against SHA-256 values pinned in the plugin and extracted to the daemon user's data directory:
41
41
 
@@ -55,7 +55,7 @@ The **Account** tab uses ZCode's own account and provider services, the same one
55
55
  - **Sign in**: choose Z.ai (international) or BigModel (China) and press **Sign in**. The sign-in page opens in your browser; the link is also shown, so you can finish on any device. The daemon receives the result, then selects the account's Coding Plan unless a plan is already chosen. The **Plans** section shows which of the account's plans (Coding Plan, Start Plan) are available. ZCode allows one signed-in account at a time.
56
56
  - **Model providers**: add any number of providers that use an API key, from a ZCode template (Z.ai, BigModel, Kimi, MiniMax, DeepSeek, Alibaba Cloud, OpenAI, Anthropic, xAI, OpenRouter and others) or a custom endpoint with its base URL, API format and model IDs. Providers and models can be turned off, edited and deleted.
57
57
 
58
- API keys are sent to ZCode, which stores them as Desktop does, and are never shown again. The plugin itself stores no credentials. Afterwards, choose **ZCode** when creating an agent; the model list is refreshed after each change on Paseo 0.9 or later.
58
+ API keys are sent to ZCode, which stores them as Desktop does, and are never shown again. The plugin itself stores no credentials. Afterwards, choose **ZCode** when creating an agent; the model list is refreshed after each change.
59
59
 
60
60
  ### Timeline
61
61
 
@@ -63,7 +63,7 @@ ZCode adds a line when a turn runs on a different model than the previous turn,
63
63
 
64
64
  ### Coding Plan usage
65
65
 
66
- On Paseo 0.11 and later, Paseo's **Usage** screen and sidebar usage summary show a **ZCode** card for the signed-in account's Individual Coding Plan (Z.ai or BigModel). It lists the 5-hour, weekly, monthly tool-call and ZCode MCP quotas with their reset times, as ZCode Desktop does. The plugin asks ZCode's official usage service for this plan only, on the same ZCode Server as the Account tab. The service never uses an API key from the environment. Team Plan and Start Plan are not shown. Paseo 0.12.0 does not yet show usage in a ZCode agent's popover.
66
+ Paseo's **Usage** screen and sidebar usage summary show a **ZCode** card for the signed-in account's Individual Coding Plan (Z.ai or BigModel). It lists the 5-hour, weekly, monthly tool-call and ZCode MCP quotas with their reset times, as ZCode Desktop does. The plugin asks ZCode's official usage service for this plan only, on the same ZCode Server as the Account tab. The service never uses an API key from the environment. Team Plan and Start Plan are not shown. Nothing is requested while **Check usage** is off for the host. Paseo 0.15.3 does not yet show usage in a ZCode agent's popover.
67
67
 
68
68
  ### Using your own runtime
69
69
 
@@ -76,9 +76,9 @@ export PASEO_ZCODE_NODE=/absolute/path/to/node # ordinary Node.js 24.14.0
76
76
 
77
77
  `PASEO_ZCODE_RUNTIME` must contain `server/remote/zcode-server.cjs`, `agent/zcode.cjs`, its provider configuration, and `package.json`. Setting only one variable is an error. Newer stable versions are allowed, including major versions; passing the minimum check does not certify compatibility. A terminal export does not change an already running Desktop application. Electron, `process.execPath` and Desktop discovery are never used.
78
78
 
79
- Session environment variables are forwarded, subject to ZCode's own proxy, certificate and runtime environment handling.
79
+ Session environment variables are forwarded, subject to ZCode's own proxy, certificate and runtime environment handling. As Desktop does, the plugin sets `ZCODE_APP_VERSION` to the runtime's ZCode version, so model requests report it instead of the CLI's version.
80
80
 
81
- The source baseline is `3c5b227649371507ddc4eb46ac5133afe6db1cab` (ZCode 3.16.2, an untagged upstream `main` commit; see ADR 20). The managed runtime passed the stdio runtime contract on all five managed platforms in CI. See the [verification record](docs/verification.md) for exact coverage.
81
+ The source baseline is `a9fe401eede6e6e5e01be9048679c206fe6f02d9` (ZCode 3.17.2, upstream tag `v3.17.2`). The managed runtime passed the stdio runtime contract on all five managed platforms in CI. See the [verification record](docs/verification.md) for exact coverage.
82
82
 
83
83
  ## Behavior
84
84
 
@@ -86,13 +86,18 @@ The source baseline is `3c5b227649371507ddc4eb46ac5133afe6db1cab` (ZCode 3.16.2,
86
86
  - Text, thoughts, tools, subagent progress, usage and history use V4 snapshots and deltas. Tool output is marked when ZCode truncates it. Usage is cumulative; repeated snapshots do not add it again.
87
87
  - Text submitted during generation uses native guidance. Attachments use the native queue. Paseo reports one run across these native turns and completes it only after all accepted input has been consumed and foreground work has ended.
88
88
  - Paseo sends every message typed in the app during a run as a steer that asks to clear pending permissions. The plugin queues it first, then declines pending permissions, questions and Plan approvals with their deny action until ZCode reads the message, including requests opened in the meantime. Requests that appear after it is read are left to the user. Declining a Plan approval in Plan mode ends ZCode's turn; the message then starts the next native turn in the same Paseo run (ADR 22).
89
- - A failed turn reports a code classified from the attribution of ZCode's error: `MODEL_RATE_LIMITED`, `MODEL_AUTH_FAILED`, `MODEL_CONTEXT_EXCEEDED`, `MODEL_NETWORK_ERROR`, `MODEL_PROVIDER_ERROR` or `MODEL_REQUEST_FAILED` when the model provider or network failed, and `NATIVE_TURN_FAILED` otherwise. The message is the plugin's own text with the HTTP status and the provider's error code when known. The provider's own message, which can include a quota reset time, is not shown; Coding Plan reset times appear on Paseo 0.11's Usage screen (ADR 23).
89
+ - A failed turn reports a code classified from the attribution of ZCode's error: `MODEL_RATE_LIMITED`, `MODEL_AUTH_FAILED`, `MODEL_CONTEXT_EXCEEDED`, `MODEL_NETWORK_ERROR`, `MODEL_PROVIDER_ERROR`, `MODEL_CONTENT_FILTERED` or `MODEL_REQUEST_FAILED` when the model provider or network failed, and `NATIVE_TURN_FAILED` otherwise. The message is the plugin's own text with the HTTP status and the provider's error code when known. The provider's own message, which can include a quota reset time, is not shown; Coding Plan reset times appear on Paseo's Usage screen (ADR 23).
90
90
  - Acceptance is reported once, after the native acknowledgement. Unknown delivery results are never automatically resent. Stop identifies the current native execution, disables automatic queue execution and removes pending input. A new explicit run enables the queue again.
91
- - As in ZCode Desktop, successful hooks are not shown. A finished hook invocation appears once, as a notification, only when a hook was blocked, failed, timed out or was cancelled; context compaction also appears once, when it ends. Paseo appends every notification it receives, so progress is not reported. Model changes appear only when turned on (see [Timeline](#timeline)).
91
+ - `/compact [instructions]` compacts the conversation in a turn of its own; the instructions go to the summary request. ZCode adds no user message for that turn, so the plugin ties it to the command by the ID on the turn itself. Stop cancels a compaction in progress, although ZCode names no execution for it then (ADR 28).
92
+ - As in ZCode Desktop, successful hooks are not shown. A finished hook invocation appears once, as a notification, only when a hook was blocked, failed, timed out or was cancelled; context compaction and a goal verification also appear once, when they end. Paseo appends every notification it receives, so progress is not reported. Model changes appear only when turned on (see [Timeline](#timeline)).
92
93
  - Native permission IDs, option values, questions and Plan approval retain their meanings. Question auto-resolution is disabled for each owned Server. Workspace hook trust is reviewed through the official CLI; it is not represented as “allow once.”
94
+ - From ZCode 3.17, a project's own MCP servers start only after they are trusted in ZCode Desktop (Settings → MCP Servers); ZCode has no CLI command for it. A session that uses the project's MCP configuration shows a warning while any of them awaits trust. MCP servers that Paseo passes to a session replace ZCode's MCP configuration, as before, and are marked as the user's, so the project's trust review does not block them.
93
95
  - Each session owns its Server process and environment. Metadata requests use temporary Servers. Closing stdin gives ZCode time to clean up before process termination.
96
+ - `/goal <objective>` sets a ZCode goal, as in ZCode Desktop: ZCode works toward it in turns it starts itself, verifies the result after each one and continues until the verifier passes it. `/goal replace <objective>` (or a new `/goal <objective>`) replaces the goal, stopping the turn pauses it, `/goal resume` continues it, and `/goal pause` pauses a goal that is active without a turn. Goal commands need an idle agent and Plan mode off; ZCode does not run a goal in Plan mode. ZCode's Server has no command for `/goal clear` or `/goal show`, so the plugin refuses them with an explanation, and `/goal` with an attachment (ADR 27).
97
+ - An agent with a goal shows a **Goal** pill above the composer, next to Paseo's Tasks, with the time spent and an icon for the state. Its popover lists one row per iteration with the count of that iteration's tasks, as ZCode Desktop's status panel does. The pill follows the goal within about 10 seconds while it is in progress. It appears only while the agent's session is open: after Paseo released an idle agent or the daemon restarted, it returns with the next message.
98
+ - With **Release idle agents** (Host settings → Agents, on by default), Paseo closes an agent's session after an hour of inactivity and reopens it on the next message. The plugin keeps the session while ZCode still has a foreground turn, queued input, a pending question or approval, a running background command, subagent or workflow, or a goal that is active or being verified (ADR 25). A finished background command's result that ZCode has not yet delivered is not distinguishable and does not keep it. **Resume agents after restart** reopens agents interrupted by a host restart and sends the resume prompt. Both reopen the saved conversation with Paseo's saved mode and Plan settings ([ADR 14](docs/adr/0014-paseoの保存設定を再適用する復元を保証範囲とする.md)).
94
99
 
95
- The plugin uses ZCode's own skills, MCP configuration and tools. Browser Use and Computer Use cannot run in the plugin's ZCode, even when ZCode Desktop has them enabled: the Computer Use helper accepts only the signed Desktop app, and only Desktop provides browsers. ZCode's Visualize (interactive views in the conversation) renders only in Desktop. The plugin therefore hides all three from the model (ADR 19, ADR 21); Desktop is not affected. Generic rewind, independent Paseo child agents, hook-review UI and Goal/Workflow controls are outside this migration. `prompt.output_schema`, custom system prompts and `persist:false` are unsupported. A system prompt makes session creation fail with `INVALID_CONFIGURATION` and a message explaining why, including one appended by Paseo's Orchestration → System prompt setting or by another plugin that adds one to new agents. MCP `alwaysLoad` is unsupported; stdio MCP commands must be absolute paths. Provider options are unsupported: in Paseo 0.11 and later, `agents.providers.zcode.options` in Paseo's `config.json` makes sessions fail with `INVALID_CONFIGURATION`, and the `command` and `env` overrides there are not applied. Paseo does not show context usage reported before the first turn, and the plugin adds no substitute display; Coding Plan quota appears in Paseo 0.11's Usage screen (see [Coding Plan usage](#coding-plan-usage)).
100
+ The plugin uses ZCode's own skills, MCP configuration and tools. Browser Use and Computer Use cannot run in the plugin's ZCode, even when ZCode Desktop has them enabled: the Computer Use helper accepts only the signed Desktop app, and only Desktop provides browsers. ZCode's Visualize (interactive views in the conversation) renders only in Desktop. The plugin therefore hides all three from the model (ADR 19, ADR 21); Desktop is not affected. Generic rewind, independent Paseo child agents, hook-review UI, Workflow controls and buttons for the goal (use the `/goal` commands) are outside this migration. `prompt.output_schema`, custom system prompts and `persist:false` are unsupported. A system prompt makes session creation fail with `INVALID_CONFIGURATION` and a message explaining why, including one appended by Paseo's Orchestration → System prompt setting or by another plugin that adds one to new agents. MCP `alwaysLoad` is unsupported; stdio MCP commands must be absolute paths. Provider options are unsupported: `agents.providers.zcode.options` in Paseo's `config.json` makes sessions fail with `INVALID_CONFIGURATION`, and the `command` and `env` overrides there are not applied. Paseo does not show context usage reported before the first turn, and the plugin adds no substitute display; Coding Plan quota appears in Paseo's Usage screen (see [Coding Plan usage](#coding-plan-usage)).
96
101
 
97
102
  ## Persistence
98
103
 
@@ -104,7 +109,7 @@ New conversations support listing, resume and paged V4 history. From ZCode 3.16,
104
109
 
105
110
  ## Diagnostics
106
111
 
107
- **Settings → Plugins → zcode-provider → Diagnostics** shows whether the managed runtime or the environment override is in use, the runtime and Node.js paths and versions, Server/Agent versions and hashes, minimum-version assessment and mapping location. The screen is read-only. Its optional version check does not prove that authentication or a model call succeeds. On Paseo 0.11 and later, **Settings → Providers** also shows ZCode as not installed until the runtime is set up and supported. Its diagnostic lists the runtime source, Server, Agent and Node.js versions and platform, or the reason the runtime cannot be used. This check reuses its result for 30 seconds and does not start ZCode, so sign-in problems still appear when a session starts.
112
+ **Settings → Plugins → zcode-provider → Diagnostics** shows whether the managed runtime or the environment override is in use, the runtime and Node.js paths and versions, Server/Agent versions and hashes, minimum-version assessment and mapping location. The screen is read-only. Its optional version check does not prove that authentication or a model call succeeds. **Settings → Providers** also shows ZCode as not installed until the runtime is set up and supported. Its diagnostic lists the runtime source, Server, Agent and Node.js versions and platform, or the reason the runtime cannot be used. This check reuses its result for 30 seconds and does not start ZCode, so sign-in problems still appear when a session starts.
108
113
 
109
114
  ```bash
110
115
  paseo plugin logs zcode-provider
@@ -1,13 +1,13 @@
1
1
  import { useCallback, useEffect, useRef, useState } from "react";
2
- import { Linking, Platform, Text, View } from "react-native";
2
+ import { Platform, Text, View } from "react-native";
3
3
  import {
4
4
  getPaseoClient,
5
5
  openExternalUrl,
6
6
  type PluginSurfaceProps,
7
7
  useRpc,
8
8
  } from "@getpaseo/plugin/client";
9
- import { copyText } from "@getpaseo/plugin/client/react-native";
10
9
  import {
10
+ copyText,
11
11
  SettingsAction,
12
12
  SettingsCard,
13
13
  SettingsInput,
@@ -56,18 +56,9 @@ const CUSTOM = "custom";
56
56
  const failure = (cause: unknown) =>
57
57
  cause instanceof Error ? cause.message : "The account request failed.";
58
58
 
59
- // openExternalUrl, copyText and getPaseoClient arrived in Paseo 0.9; 0.8
60
- // hosts omit them.
61
- async function openUrl(url: string): Promise<void> {
62
- if (typeof openExternalUrl === "function") await openExternalUrl(url);
63
- else await Linking.openURL(url);
64
- }
65
- const canCopy = typeof copyText === "function";
66
-
67
59
  // Paseo caches provider catalogs, so new models would otherwise appear only
68
60
  // after a manual refresh.
69
61
  function refreshCatalog(serverId: string): void {
70
- if (typeof getPaseoClient !== "function") return;
71
62
  getPaseoClient(serverId)
72
63
  .providers.refresh({ providers: ["zcode"] })
73
64
  .catch(() => {});
@@ -152,7 +143,7 @@ function Account({
152
143
  const { account, signIn } = view;
153
144
  const open = (url: string) => {
154
145
  setOpenError(null);
155
- openUrl(url).catch(() =>
146
+ openExternalUrl(url).catch(() =>
156
147
  setOpenError("The browser could not be opened. Copy the link instead."),
157
148
  );
158
149
  };
@@ -216,14 +207,12 @@ function Account({
216
207
  actionLabel="Open"
217
208
  onPress={() => open(signIn.authorizeUrl)}
218
209
  />,
219
- canCopy ? (
220
- <SettingsAction
221
- key="copy"
222
- label="Sign-in link"
223
- actionLabel="Copy"
224
- onPress={() => void copyText(signIn.authorizeUrl)}
225
- />
226
- ) : null,
210
+ <SettingsAction
211
+ key="copy"
212
+ label="Sign-in link"
213
+ actionLabel="Copy"
214
+ onPress={() => void copyText(signIn.authorizeUrl)}
215
+ />,
227
216
  <SettingsAction
228
217
  key="cancel"
229
218
  label="Cancel sign-in"
@@ -415,7 +404,7 @@ function NewProvider({
415
404
  label="Get an API key"
416
405
  hint={template.apiKeyManagementUrl}
417
406
  actionLabel="Open"
418
- onPress={() => void openUrl(template.apiKeyManagementUrl!)}
407
+ onPress={() => void openExternalUrl(template.apiKeyManagementUrl!)}
419
408
  />
420
409
  ) : null}
421
410
  <SettingsAction
@@ -554,7 +543,9 @@ function ProviderEditor({
554
543
  label="Get an API key"
555
544
  hint={provider.apiKeyManagementUrl}
556
545
  actionLabel="Open"
557
- onPress={() => void openUrl(provider.apiKeyManagementUrl!)}
546
+ onPress={() =>
547
+ void openExternalUrl(provider.apiKeyManagementUrl!)
548
+ }
558
549
  />
559
550
  ) : null}
560
551
  <SettingsAction
@@ -0,0 +1,252 @@
1
+ import type { ComponentType } from "react";
2
+ import type {
3
+ PluginButtonContentProps,
4
+ PluginButtonRegistration,
5
+ PluginClientContext,
6
+ } from "@getpaseo/plugin/client";
7
+ import {
8
+ formatGoalElapsed,
9
+ goalInProgress,
10
+ goalStatusLabel,
11
+ zcodeGoals,
12
+ type GoalView,
13
+ } from "../shared/goal";
14
+
15
+ /** The provider ID the agents of this plugin carry. */
16
+ const PROVIDER = "zcode";
17
+ /** The least time between two reads of the goals. */
18
+ const READ_SPACING_MS = 1_000;
19
+ /**
20
+ * A goal in progress changes without its agent changing in Paseo, as when
21
+ * ZCode titles it, and Paseo 0.15 gives the daemon no way to tell a client.
22
+ */
23
+ const IN_PROGRESS_READ_MS = 10_000;
24
+
25
+ export type GoalPillHost = Pick<
26
+ PluginClientContext,
27
+ "addComposerPill" | "rpc" | "paseo"
28
+ >;
29
+
30
+ type Timer = ReturnType<typeof setTimeout>;
31
+ // React Native's clearTimeout takes no undefined.
32
+ function cancel(timer: Timer | undefined): void {
33
+ if (timer !== undefined) clearTimeout(timer);
34
+ }
35
+
36
+ interface Pill {
37
+ workspaceId: string;
38
+ registration: PluginButtonRegistration;
39
+ goal: GoalView;
40
+ /** This client's clock when the daemon answered. */
41
+ readAt: number;
42
+ shown: { title: string; icon: string; label: string };
43
+ }
44
+
45
+ /** The seconds spent on the goal now, by this client's clock. */
46
+ export function goalElapsedSeconds(
47
+ goal: GoalView,
48
+ readAt: number,
49
+ now: number,
50
+ ): number {
51
+ return (
52
+ goal.elapsedSeconds +
53
+ (goal.running ? Math.max(0, Math.floor((now - readAt) / 1000)) : 0)
54
+ );
55
+ }
56
+
57
+ function goalIcon(status: GoalView["status"]): string {
58
+ switch (status) {
59
+ case "active":
60
+ case "notSatisfied":
61
+ return "Goal";
62
+ case "verifying":
63
+ return "ScanSearch";
64
+ case "paused":
65
+ return "CirclePause";
66
+ case "verified":
67
+ return "CircleCheckBig";
68
+ case "failed":
69
+ return "CircleAlert";
70
+ }
71
+ }
72
+
73
+ function present(goal: GoalView, readAt: number, now: number): Pill["shown"] {
74
+ return {
75
+ title: `Goal: ${goalStatusLabel(goal.status)}`,
76
+ icon: goalIcon(goal.status),
77
+ label: `Goal ${formatGoalElapsed(goalElapsedSeconds(goal, readAt, now), {
78
+ seconds: false,
79
+ })}`,
80
+ };
81
+ }
82
+
83
+ /**
84
+ * Shows a pill above the composer of every ZCode agent that has a goal, next
85
+ * to Paseo's Tasks (ADR 27). Returns the cleanup.
86
+ */
87
+ export function followGoals(
88
+ client: GoalPillHost,
89
+ Content: ComponentType<PluginButtonContentProps>,
90
+ ): () => void {
91
+ /** The ZCode agents this client knows, with their workspaces. */
92
+ const agents = new Map<string, string>();
93
+ const pills = new Map<string, Pill>();
94
+ const lifetime = new AbortController();
95
+ let stopped = false,
96
+ reading = false,
97
+ again = false,
98
+ lastRead = Number.NEGATIVE_INFINITY;
99
+ let readTimer: Timer | undefined, labelTimer: Timer | undefined;
100
+
101
+ const hide = (agentId: string) => {
102
+ pills.get(agentId)?.registration.remove();
103
+ pills.delete(agentId);
104
+ };
105
+
106
+ const show = (goal: GoalView, workspaceId: string, readAt: number) => {
107
+ const shown = present(goal, readAt, readAt);
108
+ let pill = pills.get(goal.agentId);
109
+ if (pill && pill.workspaceId !== workspaceId) {
110
+ hide(goal.agentId);
111
+ pill = undefined;
112
+ }
113
+ if (!pill) {
114
+ pills.set(goal.agentId, {
115
+ workspaceId,
116
+ goal,
117
+ readAt,
118
+ shown,
119
+ registration: client.addComposerPill({
120
+ id: "goal",
121
+ workspaceId,
122
+ agentId: goal.agentId,
123
+ button: { ...shown, behavior: { kind: "popover", Content } },
124
+ }),
125
+ });
126
+ return;
127
+ }
128
+ pill.goal = goal;
129
+ pill.readAt = readAt;
130
+ relabel(pill, shown);
131
+ };
132
+
133
+ // An update of the behavior would close an open popover.
134
+ const relabel = (pill: Pill, next: Pill["shown"]) => {
135
+ const patch = Object.fromEntries(
136
+ Object.entries(next).filter(
137
+ ([key, value]) => pill.shown[key as keyof Pill["shown"]] !== value,
138
+ ),
139
+ );
140
+ pill.shown = next;
141
+ if (Object.keys(patch).length) pill.registration.update(patch);
142
+ };
143
+
144
+ /** The label counts minutes; the next change is at the next full minute. */
145
+ const scheduleLabels = () => {
146
+ cancel(labelTimer);
147
+ labelTimer = undefined;
148
+ const now = Date.now();
149
+ let next = Number.POSITIVE_INFINITY;
150
+ for (const pill of pills.values()) {
151
+ if (!pill.goal.running) continue;
152
+ relabel(pill, present(pill.goal, pill.readAt, now));
153
+ const elapsed = goalElapsedSeconds(pill.goal, pill.readAt, now);
154
+ next = Math.min(next, 60 - (elapsed % 60));
155
+ }
156
+ if (Number.isFinite(next))
157
+ labelTimer = setTimeout(scheduleLabels, next * 1000);
158
+ };
159
+
160
+ const apply = (goals: readonly GoalView[]) => {
161
+ const readAt = Date.now();
162
+ const current = new Set<string>();
163
+ for (const goal of goals) {
164
+ const workspaceId = agents.get(goal.agentId);
165
+ if (workspaceId === undefined) continue;
166
+ current.add(goal.agentId);
167
+ show(goal, workspaceId, readAt);
168
+ }
169
+ for (const agentId of [...pills.keys()])
170
+ if (!current.has(agentId)) hide(agentId);
171
+ scheduleLabels();
172
+ };
173
+
174
+ const read = async () => {
175
+ reading = true;
176
+ lastRead = Date.now();
177
+ try {
178
+ const { goals } = await client.rpc(zcodeGoals, {});
179
+ if (!stopped) apply(goals);
180
+ } catch (error) {
181
+ // The pills keep what they show; the next read replaces it.
182
+ if (!stopped) console.error("Reading ZCode goals failed", error);
183
+ } finally {
184
+ reading = false;
185
+ if (!stopped) {
186
+ if (again) refresh();
187
+ else if ([...pills.values()].some((p) => goalInProgress(p.goal)))
188
+ readTimer = setTimeout(refresh, IN_PROGRESS_READ_MS);
189
+ }
190
+ }
191
+ };
192
+
193
+ /** Reads the goals now, or as soon as the spacing allows. */
194
+ function refresh() {
195
+ if (stopped) return;
196
+ if (reading) {
197
+ again = true;
198
+ return;
199
+ }
200
+ again = false;
201
+ cancel(readTimer);
202
+ readTimer = undefined;
203
+ const wait = lastRead + READ_SPACING_MS - Date.now();
204
+ if (wait > 0) readTimer = setTimeout(refresh, wait);
205
+ else void read();
206
+ }
207
+
208
+ const track = (agent: {
209
+ id: string;
210
+ provider: string;
211
+ workspaceId?: string | null;
212
+ }): boolean => {
213
+ if (agent.provider !== PROVIDER) return false;
214
+ if (agent.workspaceId) agents.set(agent.id, agent.workspaceId);
215
+ else agents.delete(agent.id);
216
+ return true;
217
+ };
218
+
219
+ void client.paseo.agents
220
+ .list({ subscribe: {}, signal: lifetime.signal })
221
+ .then(({ subscription }) => {
222
+ subscription.subscribe({
223
+ // Also delivered after a reconnect: it replaces what is known.
224
+ snapshot: ({ entries }) => {
225
+ agents.clear();
226
+ for (const { agent } of entries) track(agent);
227
+ refresh();
228
+ },
229
+ update: (message) => {
230
+ if (message.type !== "agent_update") return;
231
+ const update = message.payload;
232
+ if (update.kind === "remove") {
233
+ agents.delete(update.agentId);
234
+ hide(update.agentId);
235
+ } else if (track(update.agent)) refresh();
236
+ },
237
+ });
238
+ return undefined;
239
+ })
240
+ .catch((error: unknown) => {
241
+ if (!stopped) console.error("Observing Paseo agents failed", error);
242
+ });
243
+
244
+ return () => {
245
+ stopped = true;
246
+ lifetime.abort();
247
+ cancel(readTimer);
248
+ cancel(labelTimer);
249
+ for (const pill of pills.values()) pill.registration.remove();
250
+ pills.clear();
251
+ };
252
+ }
@@ -0,0 +1,203 @@
1
+ import { useEffect, useState } from "react";
2
+ import { Text, View } from "react-native";
3
+ import { type PluginButtonContentProps, useRpc } from "@getpaseo/plugin/client";
4
+ import { Icon } from "@getpaseo/plugin/client/ui";
5
+ import {
6
+ formatGoalElapsed,
7
+ goalInProgress,
8
+ goalStatusLabel,
9
+ zcodeGoals,
10
+ type GoalView,
11
+ } from "../shared/goal";
12
+ import { goalElapsedSeconds } from "./goal-pills";
13
+
14
+ type Theme = PluginButtonContentProps["theme"];
15
+
16
+ /** How often the open popover reads a goal that is in progress. */
17
+ const READ_MS = 3_000;
18
+
19
+ function statusColor(status: GoalView["status"], theme: Theme): string {
20
+ switch (status) {
21
+ case "verified":
22
+ return theme.colors.statusSuccess;
23
+ case "failed":
24
+ return theme.colors.statusDanger;
25
+ case "paused":
26
+ return theme.colors.statusWarning;
27
+ default:
28
+ return theme.colors.foreground;
29
+ }
30
+ }
31
+
32
+ function hint(goal: GoalView): string | undefined {
33
+ if (goal.status === "paused") return "Send /goal resume to continue.";
34
+ if (goalInProgress(goal)) return "Stopping the turn pauses the goal.";
35
+ return undefined;
36
+ }
37
+
38
+ // One row per iteration, as in ZCode Desktop's status panel: a finished
39
+ // iteration carries its number, and the count is of its task list.
40
+ function Iteration({
41
+ row,
42
+ theme,
43
+ }: {
44
+ row: GoalView["iterations"][number];
45
+ theme: Theme;
46
+ }) {
47
+ return (
48
+ <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8 }}>
49
+ <View
50
+ style={{
51
+ width: 18,
52
+ height: 20,
53
+ alignItems: "center",
54
+ justifyContent: "center",
55
+ }}
56
+ >
57
+ {row.completed ? (
58
+ <View
59
+ style={{
60
+ width: 16,
61
+ height: 16,
62
+ borderRadius: 8,
63
+ borderWidth: 1,
64
+ borderColor: theme.colors.statusSuccess,
65
+ alignItems: "center",
66
+ justifyContent: "center",
67
+ }}
68
+ >
69
+ <Text
70
+ style={{
71
+ color: theme.colors.statusSuccess,
72
+ fontSize: 10,
73
+ lineHeight: 12,
74
+ }}
75
+ >
76
+ {row.iteration}
77
+ </Text>
78
+ </View>
79
+ ) : (
80
+ <Icon name="Goal" size={16} color={theme.colors.foregroundMuted} />
81
+ )}
82
+ </View>
83
+ <Text
84
+ numberOfLines={3}
85
+ style={{
86
+ flex: 1,
87
+ minWidth: 0,
88
+ color: theme.colors.foreground,
89
+ fontSize: 14,
90
+ lineHeight: 20,
91
+ }}
92
+ >
93
+ {row.title ?? `Iteration ${row.iteration}`}
94
+ </Text>
95
+ {row.totalCount > 0 ? (
96
+ <Text
97
+ style={{
98
+ color: theme.colors.foregroundMuted,
99
+ fontSize: 13,
100
+ lineHeight: 20,
101
+ fontVariant: ["tabular-nums"],
102
+ }}
103
+ >
104
+ {row.completedCount}/{row.totalCount}
105
+ </Text>
106
+ ) : null}
107
+ </View>
108
+ );
109
+ }
110
+
111
+ /** The body of the Goal pill's popover (ADR 27). */
112
+ export function GoalPopover(props: PluginButtonContentProps) {
113
+ const { theme, layout } = props;
114
+ const agentId = props.context === "agent" ? props.agentId : undefined;
115
+ const fetchGoals = useRpc(zcodeGoals);
116
+ const [read, setRead] = useState<
117
+ { goal: GoalView | null; readAt: number } | "failed" | undefined
118
+ >();
119
+ const [now, setNow] = useState(() => Date.now());
120
+
121
+ useEffect(() => {
122
+ let open = true;
123
+ let timer: ReturnType<typeof setTimeout> | undefined;
124
+ const load = async () => {
125
+ try {
126
+ const { goals } = await fetchGoals({});
127
+ if (!open) return;
128
+ const goal = goals.find((g) => g.agentId === agentId) ?? null;
129
+ setRead({ goal, readAt: Date.now() });
130
+ if (goal && goalInProgress(goal)) timer = setTimeout(load, READ_MS);
131
+ } catch {
132
+ if (open) setRead("failed");
133
+ }
134
+ };
135
+ void load();
136
+ return () => {
137
+ open = false;
138
+ if (timer !== undefined) clearTimeout(timer);
139
+ };
140
+ }, [fetchGoals, agentId]);
141
+
142
+ const goal = typeof read === "object" ? read.goal : null;
143
+ const running = goal?.running === true;
144
+ useEffect(() => {
145
+ if (!running) return;
146
+ setNow(Date.now());
147
+ const timer = setInterval(() => setNow(Date.now()), 1000);
148
+ return () => clearInterval(timer);
149
+ }, [running]);
150
+
151
+ const muted = {
152
+ color: theme.colors.foregroundMuted,
153
+ fontSize: 13,
154
+ lineHeight: 20,
155
+ };
156
+ const frame = {
157
+ gap: 12,
158
+ ...(layout.compact ? {} : { width: 320 }),
159
+ };
160
+ if (typeof read !== "object" || !goal)
161
+ return (
162
+ <View style={frame}>
163
+ <Text style={muted}>
164
+ {read === undefined
165
+ ? "Loading…"
166
+ : read === "failed"
167
+ ? "The goal could not be read."
168
+ : "This agent has no goal."}
169
+ </Text>
170
+ </View>
171
+ );
172
+
173
+ const note = hint(goal);
174
+ return (
175
+ <View style={frame}>
176
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
177
+ <Text
178
+ style={{
179
+ flex: 1,
180
+ color: statusColor(goal.status, theme),
181
+ fontSize: 14,
182
+ lineHeight: 20,
183
+ fontWeight: "600",
184
+ }}
185
+ >
186
+ {goalStatusLabel(goal.status)}
187
+ </Text>
188
+ <Text style={{ ...muted, fontVariant: ["tabular-nums"] }}>
189
+ {formatGoalElapsed(
190
+ goalElapsedSeconds(goal, read.readAt, Math.max(now, read.readAt)),
191
+ { seconds: true },
192
+ )}
193
+ </Text>
194
+ </View>
195
+ <View style={{ gap: 8 }}>
196
+ {goal.iterations.map((row) => (
197
+ <Iteration key={row.iteration} row={row} theme={theme} />
198
+ ))}
199
+ </View>
200
+ {note ? <Text style={muted}>{note}</Text> : null}
201
+ </View>
202
+ );
203
+ }