paseo-plugin-zcode-provider 0.4.3 → 0.5.0

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 (56) hide show
  1. package/NOTICE.md +2 -2
  2. package/README.md +20 -13
  3. package/client/account.tsx +13 -22
  4. package/client/settings.tsx +5 -1
  5. package/client/timeline.tsx +78 -0
  6. package/index.server.ts +10 -4
  7. package/package.json +4 -4
  8. package/paseo-plugin.json +1 -1
  9. package/server/build-info.ts +1 -1
  10. package/server/diagnostics.ts +100 -0
  11. package/server/discovery/manifest.ts +2 -2
  12. package/server/errors.ts +8 -0
  13. package/server/host/bridge.ts +3 -0
  14. package/server/mapping.ts +23 -6
  15. package/server/presentation.ts +8 -2
  16. package/server/provider-status.ts +3 -3
  17. package/server/provider.ts +25 -2
  18. package/server/runtime/pins.ts +3 -3
  19. package/server/session.ts +96 -32
  20. package/server/timeline-settings.ts +50 -0
  21. package/server/turn-failure.ts +116 -0
  22. package/server/usage.ts +1 -3
  23. package/server/vendor/zcode/NOTICE.md +1 -1
  24. package/server/vendor/zcode/packages/rpc/src/channelClient.ts +18 -3
  25. package/server/vendor/zcode/packages/rpc/src/channelServer.ts +32 -12
  26. package/server/vendor/zcode/packages/rpc/src/channels.shared.ts +8 -1
  27. package/server/vendor/zcode/packages/rpc/src/serialization.ts +9 -3
  28. package/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts +2 -0
  29. package/server/vendor/zcode/packages/shared/src/browser-use/commands.ts +2 -0
  30. package/server/vendor/zcode/packages/shared/src/browser-use/result.ts +4 -0
  31. package/server/vendor/zcode/packages/shared/src/gen-ui/contract.ts +246 -0
  32. package/server/vendor/zcode/packages/shared/src/gen-ui/tweakProtocol.ts +143 -0
  33. package/server/vendor/zcode/packages/shared/src/{localTtft.ts → local-ttft/contract.ts} +56 -1
  34. package/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts +8 -0
  35. package/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts +8 -0
  36. package/server/vendor/zcode/packages/shared/src/protocol.ts +2 -0
  37. package/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts +9 -1
  38. package/server/vendor/zcode/packages/shared/src/runtimeEnv.ts +10 -0
  39. package/server/vendor/zcode/packages/shared/src/server-remote.ts +2 -0
  40. package/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts +11 -0
  41. package/server/vendor/zcode/packages/shared/src/source-server/contracts.ts +21 -1
  42. package/server/vendor/zcode/packages/shared/src/source-server/errorCodes.ts +27 -9
  43. package/server/vendor/zcode/packages/shared/src/subagent-profile.ts +5 -0
  44. package/server/vendor/zcode/packages/shared/src/validationAppSettings.ts +1 -0
  45. package/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts +164 -11
  46. package/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts +1 -0
  47. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts +4 -2
  48. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts +11 -7
  49. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts +2 -0
  50. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts +2 -0
  51. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts +19 -1
  52. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts +11 -0
  53. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts +20 -1
  54. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts +8 -0
  55. package/server/vendor/zcode/provenance.json +71 -63
  56. package/shared/timeline.ts +12 -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 組み立てと純粋な差分適用、および必要なスキーマ依存を含みます。第一者コードは [上流 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.8.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,18 +24,18 @@ 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
 
33
- Open **Settings → Plugins → zcode-provider → Settings**. The screen has two tabs: **Runtime** installs and removes the runtime, and **Account** signs in and manages model providers.
33
+ Open **Settings → Plugins → zcode-provider → Settings**. The screen has three tabs: **Runtime** installs and removes the runtime, **Account** signs in and manages model providers, and **Timeline** chooses what ZCode agents add to the timeline.
34
34
 
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,11 +55,15 @@ 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
+
60
+ ### Timeline
61
+
62
+ ZCode adds a line when a turn runs on a different model than the previous turn, such as `Model switched magpie/GLM-5.3-Flash → magpie/auto/glm-5.3-flash`. These lines are hidden by default; turn on **Show model changes** on the **Timeline** tab to show them. The setting is stored by Paseo on the daemon host. It decides each line when the line first arrives: lines already shown stay, and lines that arrived while it was off are not added later. A reopened agent shows its history with the current setting (ADR 24).
59
63
 
60
64
  ### Coding Plan usage
61
65
 
62
- 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.
63
67
 
64
68
  ### Using your own runtime
65
69
 
@@ -72,9 +76,9 @@ export PASEO_ZCODE_NODE=/absolute/path/to/node # ordinary Node.js 24.14.0
72
76
 
73
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.
74
78
 
75
- 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.
76
80
 
77
- 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.
78
82
 
79
83
  ## Behavior
80
84
 
@@ -82,12 +86,15 @@ The source baseline is `3c5b227649371507ddc4eb46ac5133afe6db1cab` (ZCode 3.16.2,
82
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.
83
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.
84
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`, `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).
85
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.
86
- - 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.
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)).
87
92
  - 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.”
93
+ - 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.
88
94
  - Each session owns its Server process and environment. Metadata requests use temporary Servers. Closing stdin gives ZCode time to clean up before process termination.
95
+ - 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)).
89
96
 
90
- 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)).
97
+ 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: `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)).
91
98
 
92
99
  ## Persistence
93
100
 
@@ -99,7 +106,7 @@ New conversations support listing, resume and paged V4 history. From ZCode 3.16,
99
106
 
100
107
  ## Diagnostics
101
108
 
102
- **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.
109
+ **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.
103
110
 
104
111
  ```bash
105
112
  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
@@ -3,10 +3,12 @@ import { Pressable, Text, View } from "react-native";
3
3
  import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
4
4
  import { AccountTab } from "./account";
5
5
  import { RuntimeTab } from "./runtime";
6
+ import { TimelineTab } from "./timeline";
6
7
 
7
8
  const TABS = [
8
9
  { id: "runtime", label: "Runtime" },
9
10
  { id: "account", label: "Account" },
11
+ { id: "timeline", label: "Timeline" },
10
12
  ] as const;
11
13
  type Tab = (typeof TABS)[number]["id"];
12
14
 
@@ -76,8 +78,10 @@ export function SettingsScreen(props: PluginSurfaceProps) {
76
78
  <Tabs value={tab} onChange={setTab} theme={props.theme} />
77
79
  {tab === "runtime" ? (
78
80
  <RuntimeTab {...props} />
79
- ) : (
81
+ ) : tab === "account" ? (
80
82
  <AccountTab {...props} onOpenRuntime={() => setTab("runtime")} />
83
+ ) : (
84
+ <TimelineTab {...props} />
81
85
  )}
82
86
  </View>
83
87
  );
@@ -0,0 +1,78 @@
1
+ import { useCallback } from "react";
2
+ import { type PluginSurfaceProps, useSettings } from "@getpaseo/plugin/client";
3
+ import {
4
+ SettingsAction,
5
+ SettingsCard,
6
+ SettingsRow,
7
+ SettingsSection,
8
+ SettingsSwitch,
9
+ } from "@getpaseo/plugin/client/ui";
10
+ import { zcodeTimelineSettings } from "../shared/timeline";
11
+ import { Value } from "./value";
12
+
13
+ const LABEL = "Show model changes";
14
+
15
+ export function TimelineTab({ theme, layout }: PluginSurfaceProps) {
16
+ const settings = useSettings(zcodeTimelineSettings);
17
+ const toggle = useCallback(
18
+ (showModelChanges: boolean) => {
19
+ if (settings.status === "ready")
20
+ void settings.save(
21
+ { ...settings.values, showModelChanges },
22
+ settings.revision,
23
+ );
24
+ },
25
+ [settings],
26
+ );
27
+
28
+ if (settings.status === "loading")
29
+ return (
30
+ <SettingsSection title="Timeline">
31
+ <SettingsCard>
32
+ <SettingsRow label={LABEL}>
33
+ <Value
34
+ color={theme.colors.foregroundMuted}
35
+ compact={layout.compact}
36
+ >
37
+ Loading…
38
+ </Value>
39
+ </SettingsRow>
40
+ </SettingsCard>
41
+ </SettingsSection>
42
+ );
43
+ if (settings.status !== "ready")
44
+ return (
45
+ <SettingsSection title="Timeline">
46
+ <SettingsCard>
47
+ <SettingsRow label={LABEL} error={settings.error} />
48
+ <SettingsAction
49
+ label="Try again"
50
+ actionLabel="Reload"
51
+ onPress={() => void settings.reload()}
52
+ />
53
+ {settings.status === "invalid" ? (
54
+ <SettingsAction
55
+ label="Restore the default"
56
+ actionLabel="Reset"
57
+ disabled={settings.saving}
58
+ onPress={() => void settings.reset()}
59
+ />
60
+ ) : null}
61
+ </SettingsCard>
62
+ </SettingsSection>
63
+ );
64
+ return (
65
+ <SettingsSection title="Timeline">
66
+ <SettingsCard>
67
+ <SettingsSwitch
68
+ label={LABEL}
69
+ hint="Adds a line when ZCode runs a turn on a different model than the previous turn. Applies to lines that arrive after the change; reopened agents show their history with the current setting."
70
+ value={settings.values.showModelChanges}
71
+ disabled={settings.saving}
72
+ error={settings.saveError}
73
+ onValueChange={toggle}
74
+ />
75
+ </SettingsCard>
76
+ </SettingsSection>
77
+ );
78
+ }
package/index.server.ts CHANGED
@@ -5,6 +5,7 @@ import { createHost, createZCodeProvider } from "./server/provider.js";
5
5
  import { ManagedRuntimeInstaller } from "./server/runtime/managed.js";
6
6
  import { createRuntimeSetupHandlers } from "./server/runtime-setup.js";
7
7
  import { createDiagnosticsHandler } from "./server/status.js";
8
+ import { followTimelineSettings } from "./server/timeline-settings.js";
8
9
  import { createUsageSource } from "./server/usage.js";
9
10
  import { zcodeAccountChange, zcodeAccountView } from "./shared/account.js";
10
11
  import { zcodeDiagnostics } from "./shared/diagnostics.js";
@@ -13,9 +14,15 @@ import {
13
14
  zcodeRuntimeRemove,
14
15
  zcodeRuntimeStatus,
15
16
  } from "./shared/runtime-setup.js";
17
+ import { zcodeTimelineSettings } from "./shared/timeline.js";
16
18
 
17
19
  export default function contribute(server: PluginServerContext): () => void {
18
- server.registerProvider(createZCodeProvider());
20
+ const timeline = followTimelineSettings(
21
+ server.registerSettings(zcodeTimelineSettings),
22
+ );
23
+ server.registerProvider(
24
+ createZCodeProvider(undefined, undefined, undefined, timeline.current),
25
+ );
19
26
  server.handle(zcodeDiagnostics, createDiagnosticsHandler());
20
27
  const setup = createRuntimeSetupHandlers(new ManagedRuntimeInstaller());
21
28
  server.handle(zcodeRuntimeStatus, setup.status);
@@ -27,12 +34,11 @@ export default function contribute(server: PluginServerContext): () => void {
27
34
  );
28
35
  server.handle(zcodeAccountView, () => account.view());
29
36
  server.handle(zcodeAccountChange, (input) => account.change(input));
30
- // Usage sources arrived in Paseo 0.11; older daemons do not offer them.
31
37
  const usage = createUsageSource(account);
32
- if (typeof server.registerUsageSource === "function")
33
- server.registerUsageSource(usage.source);
38
+ server.registerUsageSource(usage.source);
34
39
  return () => {
35
40
  usage.dispose();
41
+ timeline.dispose();
36
42
  abort.abort();
37
43
  void account.close();
38
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-plugin-zcode-provider",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Unofficial Paseo provider plugin for ZCode, using the official stdio Services Server of the integrated ZCode CLI.",
5
5
  "keywords": [
6
6
  "paseo",
@@ -60,9 +60,9 @@
60
60
  "semver": "7.8.5"
61
61
  },
62
62
  "devDependencies": {
63
- "@getpaseo/client": "0.12.0",
64
- "@getpaseo/plugin": "0.12.0",
65
- "@getpaseo/protocol": "0.12.0",
63
+ "@getpaseo/client": "0.15.3",
64
+ "@getpaseo/plugin": "0.15.3",
65
+ "@getpaseo/protocol": "0.15.3",
66
66
  "@types/node": "22.18.3",
67
67
  "@types/react": "~19.2.0",
68
68
  "@types/semver": "7.8.0",
package/paseo-plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "zcode-provider",
3
3
  "requirements": {
4
- "paseo": ">=0.8.0"
4
+ "paseo": ">=0.15.0"
5
5
  }
6
6
  }
@@ -1,2 +1,2 @@
1
1
  // Generated from package.json by npm prepare / prebuild.
2
- export const PROVIDER_VERSION = "0.4.3";
2
+ export const PROVIDER_VERSION = "0.5.0";
@@ -15,6 +15,53 @@ const stages = [
15
15
  "notification",
16
16
  "transport",
17
17
  "session",
18
+ "turn",
19
+ ] as const;
20
+ // ZCode's ModelFailureReason (apps/zcode-cli/packages/contracts/src/model/index.ts at
21
+ // a9fe401), plus content_filter, which 3.17 sets outside that list for a reply
22
+ // the provider's content filter blocked (core/src/runtime/helpers/model-errors.ts).
23
+ export const modelFailureReasons = [
24
+ "content_filter",
25
+ "rate_limited",
26
+ "provider_overloaded",
27
+ "server_error",
28
+ "network_error",
29
+ "timeout",
30
+ "stream_idle_timeout",
31
+ "stale_connection",
32
+ "auth_refresh",
33
+ "reasoning_signature_repair",
34
+ "offpeak_queued",
35
+ "auth_failed",
36
+ "cancelled",
37
+ "context_exceeded",
38
+ "invalid_request",
39
+ "provider_not_configured",
40
+ "proxy_error",
41
+ "tls_error",
42
+ "unknown",
43
+ ] as const;
44
+ export type ModelFailureReason = (typeof modelFailureReasons)[number];
45
+ // V4 errorAttributionSchema enums.
46
+ const failureSources = ["provider", "runtime", "tool", "network"] as const;
47
+ const errorPhases = [
48
+ "prepare",
49
+ "configuration",
50
+ "connect",
51
+ "response",
52
+ "stream",
53
+ "parse",
54
+ "validation",
55
+ "unhandled",
56
+ ] as const;
57
+ const exceptionKinds = [
58
+ "api_call",
59
+ "generic",
60
+ "protocol",
61
+ "provider_business",
62
+ "transport",
63
+ "type_error",
64
+ "validation",
18
65
  ] as const;
19
66
  const checks = [
20
67
  "bundle-metadata",
@@ -146,6 +193,44 @@ export interface RuntimeDiagnostic {
146
193
  readonly nativeCode?: number;
147
194
  readonly exitCode?: number;
148
195
  readonly validation?: readonly { path: string; code: string }[];
196
+ readonly failure?: TurnFailureDiagnostic;
197
+ }
198
+
199
+ /** Attribution of a failed turn from V4 `control.lastError`; never its message. */
200
+ export interface TurnFailureDiagnostic {
201
+ readonly source?: string;
202
+ readonly reason?: string;
203
+ readonly errorPhase?: string;
204
+ readonly exceptionKind?: string;
205
+ readonly statusCode?: number;
206
+ readonly providerErrorCode?: string;
207
+ readonly retryable?: boolean;
208
+ }
209
+
210
+ export function reportableStatusCode(
211
+ value: number | undefined,
212
+ ): number | undefined {
213
+ return Number.isInteger(value) && value! >= 100 && value! <= 599
214
+ ? value
215
+ : undefined;
216
+ }
217
+
218
+ /** Provider error codes are free text. Only numeric or word codes such as `1310` or `insufficient_quota` are reported. */
219
+ export function reportableProviderErrorCode(
220
+ value: string | undefined,
221
+ ): string | undefined {
222
+ return value &&
223
+ value.length <= 64 &&
224
+ /^(?:\d+|[A-Za-z]+(?:[_.][A-Za-z]+)*)$/u.test(value)
225
+ ? value
226
+ : undefined;
227
+ }
228
+
229
+ function allowed(
230
+ values: readonly string[],
231
+ value: string | undefined,
232
+ ): string | undefined {
233
+ return value !== undefined && values.includes(value) ? value : undefined;
149
234
  }
150
235
 
151
236
  export function runtimeDiagnostic(
@@ -222,6 +307,21 @@ export function formatDiagnostic(error: unknown): string {
222
307
  for (const key of ["nativeCode", "exitCode"] as const) {
223
308
  if (Number.isSafeInteger(context[key])) result[key] = context[key];
224
309
  }
310
+ if (context.failure) {
311
+ const f = context.failure;
312
+ const failure = Object.fromEntries(
313
+ Object.entries({
314
+ source: allowed(failureSources, f.source),
315
+ reason: allowed(modelFailureReasons, f.reason),
316
+ errorPhase: allowed(errorPhases, f.errorPhase),
317
+ exceptionKind: allowed(exceptionKinds, f.exceptionKind),
318
+ statusCode: reportableStatusCode(f.statusCode),
319
+ providerErrorCode: reportableProviderErrorCode(f.providerErrorCode),
320
+ retryable: typeof f.retryable === "boolean" ? f.retryable : undefined,
321
+ }).filter(([, value]) => value !== undefined),
322
+ );
323
+ if (Object.keys(failure).length) result.failure = failure;
324
+ }
225
325
  if (context.validation)
226
326
  result.validation = context.validation.slice(0, 10).map((issue) => ({
227
327
  path: issue.path
@@ -1,7 +1,7 @@
1
1
  import { gte, parse } from "semver";
2
2
  import type { RuntimeIdentity } from "./types.js";
3
3
 
4
- export const ZCODE_SOURCE_COMMIT = "3c5b227649371507ddc4eb46ac5133afe6db1cab";
4
+ export const ZCODE_SOURCE_COMMIT = "a9fe401eede6e6e5e01be9048679c206fe6f02d9";
5
5
  export const MINIMUM_ZCODE_VERSION = { app: "3.14.0", cli: "0.16.9" } as const;
6
6
  export const MINIMUM_NODE_VERSION = "24.14.0";
7
7
 
@@ -33,4 +33,4 @@ export function assessCompatibility(identity: RuntimeIdentity): {
33
33
  }
34
34
 
35
35
  // Last reviewed public changelog release; source versions are not releases.
36
- export const LAST_REVIEWED_ZCODE_RELEASE = "3.16.2";
36
+ export const LAST_REVIEWED_ZCODE_RELEASE = "3.17.2";
package/server/errors.ts CHANGED
@@ -14,6 +14,14 @@ export type ZCodeErrorCode =
14
14
  | "NATIVE_INPUT_REJECTED"
15
15
  | "NATIVE_TIMEOUT"
16
16
  | "NATIVE_EXITED"
17
+ | "NATIVE_TURN_FAILED"
18
+ | "MODEL_RATE_LIMITED"
19
+ | "MODEL_AUTH_FAILED"
20
+ | "MODEL_CONTEXT_EXCEEDED"
21
+ | "MODEL_NETWORK_ERROR"
22
+ | "MODEL_PROVIDER_ERROR"
23
+ | "MODEL_CONTENT_FILTERED"
24
+ | "MODEL_REQUEST_FAILED"
17
25
  | "AUTH_REQUIRED"
18
26
  | "UNSUPPORTED_CONTENT"
19
27
  | "SESSION_NOT_FOUND"
@@ -144,6 +144,9 @@ export class ZCodeHostBridge implements HostBridge {
144
144
  env: {
145
145
  ...runtimeEnvironment(environment),
146
146
  ...UNSUPPORTED_CAPABILITY_ENVIRONMENT,
147
+ // The Agent inherits this and reports it in model request headers, or
148
+ // its CLI version without it. Desktop and the remote Core set it too.
149
+ ZCODE_APP_VERSION: runtime.identity.appVersion,
147
150
  ZCODE_SERVICE_AUTHORITY_MODE: "standalone-server",
148
151
  ZCODE_AGENT_SERVER_COMMAND: runtime.paths.executable,
149
152
  ZCODE_AGENT_SERVER_ARGS_JSON: JSON.stringify([
package/server/mapping.ts CHANGED
@@ -38,13 +38,22 @@ export const ZCODE_MODES: ProviderMode[] = [
38
38
  // ZCode 3.15.1 added guarded ("Autonomous mode"); older Servers reject it.
39
39
  const GUARDED_MINIMUM_APP_VERSION = "3.15.1";
40
40
 
41
- // The modes the runtime with this Server version supports.
42
- export function zcodeModes(appVersion: string | undefined): ProviderMode[] {
43
- const guarded =
41
+ // ZCode 3.17.1 added the MCP server `scope`; older Servers reject it.
42
+ const MCP_SCOPE_MINIMUM_APP_VERSION = "3.17.1";
43
+
44
+ function atLeast(appVersion: string | undefined, minimum: string): boolean {
45
+ return (
44
46
  appVersion !== undefined &&
45
47
  valid(appVersion) !== null &&
46
- gte(appVersion, GUARDED_MINIMUM_APP_VERSION);
47
- return guarded ? ZCODE_MODES : ZCODE_MODES.filter((m) => m.id !== "guarded");
48
+ gte(appVersion, minimum)
49
+ );
50
+ }
51
+
52
+ // The modes the runtime with this Server version supports.
53
+ export function zcodeModes(appVersion: string | undefined): ProviderMode[] {
54
+ return atLeast(appVersion, GUARDED_MINIMUM_APP_VERSION)
55
+ ? ZCODE_MODES
56
+ : ZCODE_MODES.filter((m) => m.id !== "guarded");
48
57
  }
49
58
 
50
59
  export function requireConfigurableMode(
@@ -151,7 +160,14 @@ export function catalogModels(
151
160
 
152
161
  export function mapMcpServers(
153
162
  servers: Record<string, ProviderMcpServerConfig> | undefined,
163
+ appVersion: string | undefined,
154
164
  ): Array<Record<string, unknown>> {
165
+ // Paseo's servers are not project declarations. Without a scope, ZCode
166
+ // treats them as such when the project declares the same name or its
167
+ // configuration is unreadable, and blocks them until the project is trusted.
168
+ const scope = atLeast(appVersion, MCP_SCOPE_MINIMUM_APP_VERSION)
169
+ ? { scope: "user" }
170
+ : {};
155
171
  return Object.entries(servers ?? {}).map(([name, server]) => {
156
172
  if (name.trim() === "") {
157
173
  throw new AdapterError(
@@ -174,6 +190,7 @@ export function mapMcpServers(
174
190
  }
175
191
  return {
176
192
  name,
193
+ ...scope,
177
194
  command: server.command,
178
195
  args: server.args ?? [],
179
196
  env: Object.entries(server.env ?? {}).map(([key, value]) => ({
@@ -189,7 +206,7 @@ export function mapMcpServers(
189
206
  }),
190
207
  );
191
208
  if (server.type === "http" || server.type === "sse") {
192
- return { type: server.type, name, url: server.url, headers };
209
+ return { type: server.type, name, ...scope, url: server.url, headers };
193
210
  }
194
211
  throw new AdapterError(
195
212
  "INVALID_CONFIGURATION",
@@ -458,8 +458,14 @@ function markerText(marker: TimelineMarkerPayload): string {
458
458
  switch (marker.type) {
459
459
  case "compact":
460
460
  return `Context compaction: ${marker.status}`;
461
- case "modelChange":
462
- return `Model: ${marker.toModel} (${marker.toThought})`;
461
+ case "modelChange": {
462
+ // Worded as in ZCode Desktop, which also omits the reasoning level: it
463
+ // does not count as a model change and may be empty.
464
+ const to = `${marker.toProvider}/${marker.toModel}`;
465
+ return marker.fromProvider === undefined || marker.fromModel === undefined
466
+ ? `Using ${to}`
467
+ : `Model switched ${marker.fromProvider}/${marker.fromModel} → ${to}`;
468
+ }
463
469
  case "forkNotice":
464
470
  return "Conversation continued from a parent conversation.";
465
471
  case "forkCreated":
@@ -62,9 +62,9 @@ async function check(
62
62
  }
63
63
 
64
64
  /**
65
- * Availability for Paseo's provider snapshot and diagnostics (Paseo 0.11+;
66
- * older daemons ignore it). It inspects the runtime without starting a Server,
67
- * so sign-in problems still surface when a session opens.
65
+ * Availability for Paseo's provider snapshot and diagnostics. It inspects the
66
+ * runtime without starting a Server, so sign-in problems still surface when a
67
+ * session opens.
68
68
  */
69
69
  export function createRuntimeStatus(options: RuntimeStatusOptions = {}) {
70
70
  const environment = options.environment ?? process.env;