diff --git a/AGENTS.md b/AGENTS.md
index dcb48b3..693cfb7 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -6,7 +6,7 @@ This plugin connects Paseo's public Provider API to the official stdio Services
- `index.server.ts` / `index.client.tsx`: Server and settings UI registration.
- `server/`: Provider, sessions, and persistence. `discovery/` locates installations; `runtime/` pins and installs the managed runtime; `host/` and `protocol/` handle startup, communication, and validation.
-- `client/`: React Native Settings (Runtime and Account tabs) and Diagnostics screens. `shared/` contains types and contracts shared by the server and client.
+- `client/`: React Native Settings (Runtime, Account and Timeline tabs) and Diagnostics screens. `shared/` contains types and contracts shared by the server and client.
- `test/`: Integration tests and `fake-host.ts`. Unit tests also live in `server/`.
- `scripts/`: Build, upstream integration, and runtime verification scripts. `docs/` contains development procedures, verification records, and ADRs. Images live in `images/` and `icon.svg`.
@@ -61,5 +61,6 @@ Identify the root cause and do not add ad hoc workarounds. Add backward compatib
- Account and provider settings go only through the official `oauth`, `setting` and `provider-settings` services of a plugin-owned Server, as Desktop does (ADR 17). Never read or write ZCode's credential or configuration files directly, store credentials in the plugin, or return API keys or native error messages to clients.
- On Paseo 0.11+, the provider's `status()` reports runtime discovery without starting a Server, and the `zcode` usage source reads Coding Plan quota only through `usage-stats.getEntitlementSnapshot` on the same Server (ADR 18). Register Paseo 0.11 APIs only when the daemon provides them, and import their types only from `@getpaseo/plugin/server`: older compilers reject `@getpaseo/plugin/server/usage`, even for types.
- Computer Use and Browser Use cannot run in the provider's standalone Server (ADR 19), and Visualize renders only in Desktop (ADR 21). `server/unsupported-capabilities.ts` defines what the bridge passes to every Server (`ZCODE_CUA_PRODUCT_HELPER=0` and `PASEO_ZCODE_SUPPRESSED_PLUGINS`) and the per-turn `toolDisallowlist`. Keep the official switches as well as the patch: `PASEO_ZCODE_RUNTIME` runtimes are unpatched.
+- Plugin preferences are Paseo host settings defined in `shared/` and followed on the server through the `registerSettings()` handle (ADR 24). Paseo 0.9.0 is the minimum because older daemons cannot read them. Model change markers are hidden by default; whether one is shown is decided when it is first seen.
- Persistence handles use version 3. Do not migrate old Paseo handles or introduce Plan restoration storage.
- The plugin is published to npm only through the Version Bump and Release workflows (ADR 16); see `docs/development.md`. npm installation omits development dependencies, so keep runtime libraries other than Paseo's host modules (`@getpaseo/plugin/*`, `zod`) in `dependencies`. The `build` commands in `paseo-plugin.json` prepare Git checkouts only; `prepack` removes them from the npm package.
diff --git a/README.md b/README.md
index 610d57f..f9d5a71 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ This is an unofficial plugin. It is not endorsed or maintained by ZCode or Z.ai.
| Setting | Requirement |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
-| Paseo | 0.8.0 or later; development SDK 0.12.0 |
+| Paseo | 0.9.0 or later; development SDK 0.12.0 |
| Plugin Node.js | 22.12.0 or later (the Paseo daemon's runtime) |
| Managed setup | darwin-arm64, linux-x64, linux-arm64, win-x64, win-arm64 |
| 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+ |
@@ -30,7 +30,7 @@ To follow the `main` branch instead, install the Git repository with `paseo plug
## Setup
-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.
+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.
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:
@@ -57,6 +57,10 @@ The **Account** tab uses ZCode's own account and provider services, the same one
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.
+### Timeline
+
+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).
+
### Coding Plan usage
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.
@@ -84,7 +88,7 @@ The source baseline is `3c5b227649371507ddc4eb46ac5133afe6db1cab` (ZCode 3.16.2,
- 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).
- 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).
- 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.
-- 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.
+- 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)).
- 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.”
- Each session owns its Server process and environment. Metadata requests use temporary Servers. Closing stdin gives ZCode time to clean up before process termination.
diff --git a/client/settings.tsx b/client/settings.tsx
index 5cc2690..2d804fd 100644
--- a/client/settings.tsx
+++ b/client/settings.tsx
@@ -3,10 +3,12 @@ import { Pressable, Text, View } from "react-native";
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
import { AccountTab } from "./account";
import { RuntimeTab } from "./runtime";
+import { TimelineTab } from "./timeline";
const TABS = [
{ id: "runtime", label: "Runtime" },
{ id: "account", label: "Account" },
+ { id: "timeline", label: "Timeline" },
] as const;
type Tab = (typeof TABS)[number]["id"];
@@ -76,8 +78,10 @@ export function SettingsScreen(props: PluginSurfaceProps) {
{tab === "runtime" ? (
- ) : (
+ ) : tab === "account" ? (
setTab("runtime")} />
+ ) : (
+
)}
);
diff --git a/client/timeline.tsx b/client/timeline.tsx
new file mode 100644
index 0000000..4fb58ef
--- /dev/null
+++ b/client/timeline.tsx
@@ -0,0 +1,78 @@
+import { useCallback } from "react";
+import { type PluginSurfaceProps, useSettings } from "@getpaseo/plugin/client";
+import {
+ SettingsAction,
+ SettingsCard,
+ SettingsRow,
+ SettingsSection,
+ SettingsSwitch,
+} from "@getpaseo/plugin/client/ui";
+import { zcodeTimelineSettings } from "../shared/timeline";
+import { Value } from "./value";
+
+const LABEL = "Show model changes";
+
+export function TimelineTab({ theme, layout }: PluginSurfaceProps) {
+ const settings = useSettings(zcodeTimelineSettings);
+ const toggle = useCallback(
+ (showModelChanges: boolean) => {
+ if (settings.status === "ready")
+ void settings.save(
+ { ...settings.values, showModelChanges },
+ settings.revision,
+ );
+ },
+ [settings],
+ );
+
+ if (settings.status === "loading")
+ return (
+
+
+
+
+ Loading…
+
+
+
+
+ );
+ if (settings.status !== "ready")
+ return (
+
+
+
+ void settings.reload()}
+ />
+ {settings.status === "invalid" ? (
+ void settings.reset()}
+ />
+ ) : null}
+
+
+ );
+ return (
+
+
+
+
+
+ );
+}
diff --git "a/docs/adr/0008-\350\250\255\345\256\232\347\224\273\351\235\242\343\201\257\350\252\255\343\201\277\345\217\226\343\202\212\345\260\202\347\224\250\343\201\256\350\250\272\346\226\255\343\201\253\351\231\220\345\256\232\343\201\227\343\203\233\343\202\271\343\203\210\347\212\266\346\205\213\343\202\222\345\260\202\347\224\250rpc\343\201\247\350\277\224\343\201\231.md" "b/docs/adr/0008-\350\250\255\345\256\232\347\224\273\351\235\242\343\201\257\350\252\255\343\201\277\345\217\226\343\202\212\345\260\202\347\224\250\343\201\256\350\250\272\346\226\255\343\201\253\351\231\220\345\256\232\343\201\227\343\203\233\343\202\271\343\203\210\347\212\266\346\205\213\343\202\222\345\260\202\347\224\250rpc\343\201\247\350\277\224\343\201\231.md"
index 6342f12..ec1f367 100644
--- "a/docs/adr/0008-\350\250\255\345\256\232\347\224\273\351\235\242\343\201\257\350\252\255\343\201\277\345\217\226\343\202\212\345\260\202\347\224\250\343\201\256\350\250\272\346\226\255\343\201\253\351\231\220\345\256\232\343\201\227\343\203\233\343\202\271\343\203\210\347\212\266\346\205\213\343\202\222\345\260\202\347\224\250rpc\343\201\247\350\277\224\343\201\231.md"
+++ "b/docs/adr/0008-\350\250\255\345\256\232\347\224\273\351\235\242\343\201\257\350\252\255\343\201\277\345\217\226\343\202\212\345\260\202\347\224\250\343\201\256\350\250\272\346\226\255\343\201\253\351\231\220\345\256\232\343\201\227\343\203\233\343\202\271\343\203\210\347\212\266\346\205\213\343\202\222\345\260\202\347\224\250rpc\343\201\247\350\277\224\343\201\231.md"
@@ -12,6 +12,8 @@ links:
kind: amendedby
- target: 18
kind: amendedby
+ - target: 24
+ kind: amendedby
---
# 設定画面は読み取り専用の診断に限定しホスト状態を専用RPCで返す
diff --git "a/docs/adr/0024-\343\203\242\343\203\207\343\203\253\345\210\207\343\202\212\346\233\277\343\201\210\343\201\256\350\241\250\347\244\272\343\202\222paseo\343\201\256\350\250\255\345\256\232api\343\201\247\351\201\270\343\201\271\343\202\213\343\202\210\343\201\206\343\201\253\343\201\227\346\234\200\344\275\216\350\246\201\344\273\266\343\202\2220-9-0\343\201\253\344\270\212\343\201\222\343\202\213.md" "b/docs/adr/0024-\343\203\242\343\203\207\343\203\253\345\210\207\343\202\212\346\233\277\343\201\210\343\201\256\350\241\250\347\244\272\343\202\222paseo\343\201\256\350\250\255\345\256\232api\343\201\247\351\201\270\343\201\271\343\202\213\343\202\210\343\201\206\343\201\253\343\201\227\346\234\200\344\275\216\350\246\201\344\273\266\343\202\2220-9-0\343\201\253\344\270\212\343\201\222\343\202\213.md"
new file mode 100644
index 0000000..2640dfd
--- /dev/null
+++ "b/docs/adr/0024-\343\203\242\343\203\207\343\203\253\345\210\207\343\202\212\346\233\277\343\201\210\343\201\256\350\241\250\347\244\272\343\202\222paseo\343\201\256\350\250\255\345\256\232api\343\201\247\351\201\270\343\201\271\343\202\213\343\202\210\343\201\206\343\201\253\343\201\227\346\234\200\344\275\216\350\246\201\344\273\266\343\202\2220-9-0\343\201\253\344\270\212\343\201\222\343\202\213.md"
@@ -0,0 +1,73 @@
+---
+number: 24
+title: モデル切り替えの表示をPaseoの設定APIで選べるようにし最低要件を0.9.0に上げる
+status: accepted
+date: 2026-11-09
+links:
+ - target: 8
+ kind: amends
+---
+
+# モデル切り替えの表示をPaseoの設定APIで選べるようにし最低要件を0.9.0に上げる
+
+## Context and Problem Statement
+
+ZCode は、ターンのプロバイダーとモデルが直前のターンと違うとき、そのターンの前に `modelChange` の `timelineMarker` 行を置く(3c5b227 の `apps/zcode-cli/packages/bootstrap/src/zcode-protocol-v4/product-projection.ts` の `onTurnStarted`)。プラグインはこれを Paseo の通知に変換していた。Issue #83 では、ターンのたびにこの行が二つずつ増えて会話が読みにくいと報告され、表示をやめるよう求められた。Paseo は受け取った通知を後から消せない。セッションで選んでいるモデルは Paseo のヘッダーに出る。
+
+ADR 8 は、Paseo 0.8.0 には daemon 側から保存値を読む API が無いので設定値を保存しないとし、その API が公開されたら見直すとした。Paseo 0.9.0 から `server.registerSettings()` が `read()` と `subscribe()` を持つハンドルを返す。プラグインの最低要件は 0.8.0 で、0.8.0 の `registerSettings()` は何も返さない。
+
+## Decision Drivers
+
+- 既定では会話にこの行を出さず、必要な人は出せるようにする。
+- 設定は Paseo の公式の保存と UI の仕組みで扱い、独自の保存先を作らない。
+- 画面で変えた設定が、対応するすべての Paseo で実際に効くようにする。
+- Paseo の会話で、行が後から末尾に並んだり、重なったりしないようにする。
+
+## Considered Options
+
+- マーカーを常に出さない。
+- Paseo の設定 API で表示を選べるようにし、最低要件を 0.9.0 に上げる。
+- Paseo の設定 API で表示を選べるようにし、最低要件は 0.8.0 のままにする。
+
+## Decision Outcome
+
+Chosen option: 「Paseo の設定 API で表示を選べるようにし、最低要件を 0.9.0 に上げる」。報告された不満を既定で解消しつつ、本当にモデルが変わったことを知りたい人の手段を残し、保存と画面を Paseo の仕組みだけで実現できるため。
+
+- `shared/timeline.ts` に `defineSettings` でホスト単位の文書 `timeline`(版 1、`showModelChanges` の既定は `false`)を定義する。サーバーは `registerSettings()` のハンドルの `read()` と `subscribe()` で現在の値を追う。最初の読み込みが終わるまでと、保存値が不正な間は既定値を使う。
+- 設定画面に Runtime・Account とは別の Timeline タブを置き、`useSettings` のスイッチで切り替える。不正な保存値は既定値に戻せる。
+- 表示するかどうかは、マーカーを最初に見た時点の設定で決める。出した行はそのまま残し、非表示の間に来た行は後から出さない。セッションを開き直したときは、その時点の設定で履歴を作る。
+- 行の文言は ZCode Desktop に合わせ、最初のモデルは `Using provider/model`、切り替えは `Model switched provider/model → provider/model` とする。推論レベルは出さない。
+- `paseo-plugin.json` の最低要件を `>=0.9.0` に上げる。
+
+### Consequences
+
+- Good, because 既定の会話から、毎ターン増える行が無くなる。
+- Good, because 設定の保存・不正値の扱い・クライアント間の同期を Paseo が担い、プラグインは保存先を持たない。
+- Bad, because Paseo 0.8 系では新しい版を導入できなくなる。
+- Bad, because 既定ではモデルが本当に切り替わったことも会話からは分からない。
+- Bad, because 設定を変えても、すでに会話にある行は変わらない。
+
+### Confirmation
+
+`test/provider.test.ts` で、最初に見た時点の設定で表示が決まることと、開き直したときの履歴がその時点の設定に従うことを確認する。`server/timeline-settings.test.ts` で、既定値、保存値の追従、不正値、最初の読み込みより新しい保存を確認する。`npm run test:upstream` は実際のコンパイラで設定の登録を確認する。
+
+## Pros and Cons of the Options
+
+### マーカーを常に出さない
+
+- Good, because 設定も画面も要らない。
+- Bad, because ZCode がモデルを切り替えたことを Paseo で知る手段が無くなる。
+
+### 設定 API で選べるようにし、最低要件を 0.9.0 に上げる
+
+- Good, because 画面のスイッチが、対応するすべての Paseo で効く。
+- Bad, because Paseo 0.8 系の利用者は更新できない。
+
+### 設定 API で選べるようにし、最低要件は 0.8.0 のままにする
+
+- Good, because Paseo 0.8 系でも新しい版を導入できる。
+- Bad, because 0.8 系では画面のスイッチが保存されるだけで効かない。画面からはそれを見分けられない。
+
+## More Information
+
+ADR 8 のうち、設定値を保存しないという部分を変える。診断画面の項目と秘匿方針はそのままとする。Paseo 側の根拠は `public-docs/plugins/reference.md` の Persisted values と、v0.8.0 と v0.9.0 の `packages/plugin/src/server/contracts.ts`。[Issue #83](https://github.com/supermomonga/paseo-plugin-zcode-provider/issues/83)。ZCode が `modelChange` を出す条件を変えたとき、または Paseo が受け取った行を後から消せるようになったときに見直す。
diff --git a/docs/adr/README.md b/docs/adr/README.md
index b05a882..57862e6 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -21,3 +21,4 @@
* [21. Desktop専用のvisualizeプラグインもADR 19の抑止対象に加える](0021-desktop専用のvisualizeプラグインもadr-19の抑止対象に加える.md)
* [22. Paseoが求めるときは受け付けたSteerが読まれるまで保留中の権限確認を拒否する](0022-paseoが求めるときは受け付けたsteerが読まれるまで保留中の権限確認を拒否する.md)
* [23. ターンの失敗はV4のlastErrorのattributionで分類したコードと固定の文言で伝える](0023-ターンの失敗はv4のlasterrorのattributionで分類したコードと固定の文言で伝える.md)
+* [24. モデル切り替えの表示をPaseoの設定APIで選べるようにし最低要件を0.9.0に上げる](0024-モデル切り替えの表示をpaseoの設定apiで選べるようにし最低要件を0-9-0に上げる.md)
diff --git a/docs/development.md b/docs/development.md
index 5d28679..0d87c76 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -12,7 +12,7 @@ npm run check:zcode-source -- ~/ghq/github.com/zai-org/ZCode
npm run test:upstream -- /absolute/path/to/paseo
```
-`test:upstream` uses Paseo's actual plugin compiler, Git preparation and Provider adapter. Use commit `cafe4b01c8522ff39560241c5deb01427dc8dc5b` (0.12.0), matching the installed development SDK. It checks clean npm preparation of a Git checkout both with `NODE_ENV` unset and `production`, installation of the `npm pack` tarball with Paseo's npm acquisition options, server/client registration and the provider icon of both, V4 timeline, guidance, attachment queue aggregation, a classified turn failure, stop, provider replacement, history and Plan configuration on resume. The adapter fixture uses the official V4 schemas and delta application; it does not prove native behavior.
+`test:upstream` uses Paseo's actual plugin compiler, Git preparation and Provider adapter. Use commit `cafe4b01c8522ff39560241c5deb01427dc8dc5b` (0.12.0), matching the installed development SDK. It checks clean npm preparation of a Git checkout both with `NODE_ENV` unset and `production`, installation of the `npm pack` tarball with Paseo's npm acquisition options, server/client registration (including the timeline settings document) and the provider icon of both, V4 timeline, guidance, attachment queue aggregation, a classified turn failure, stop, provider replacement, history and Plan configuration on resume. The adapter fixture uses the official V4 schemas and delta application; it does not prove native behavior.
## Source of truth
diff --git a/docs/verification.md b/docs/verification.md
index f2e2871..4f1e3a1 100644
--- a/docs/verification.md
+++ b/docs/verification.md
@@ -1,3 +1,23 @@
+# モデル切り替えの行を設定で出し分ける(2026-11-09)
+
+[Issue #83](https://github.com/supermomonga/paseo-plugin-zcode-provider/issues/83) で、ZCode のエージェントのタイムラインに `Model: GLM-5.3-Flash ()` と `Model: auto/glm-5.3-flash (max)` がターンごとに交互に増えると報告された。
+
+## 原因と変更
+
+- この行はプラグインが ZCode の `modelChange` マーカーから作っていた。括弧の中は推論レベルで、ZCode は選択に推論レベルが無いと空文字を入れる(3c5b227 の `product-projection.ts` の `onModelSelected`)。
+- ZCode がこのマーカーを出すのは、ターンのプロバイダーとモデルが直前のターンと違うときだけである(同 `onTurnStarted`)。
+- 行の文言を ZCode Desktop に合わせ、`Using provider/model` と `Model switched provider/model → provider/model` にした。推論レベルは出さない。
+- 設定画面に Timeline タブを加え、**Show model changes**(既定はオフ)で表示を選べるようにした。Paseo のホスト単位の設定文書 `timeline` に保存し、サーバーは `registerSettings()` のハンドルで追う。表示するかどうかはマーカーを最初に見た時点で決める。最低要件を Paseo 0.9.0 に上げた。判断は [ADR 24](adr/0024-モデル切り替えの表示をpaseoの設定apiで選べるようにし最低要件を0-9-0に上げる.md) に記録した。
+
+## 検証(Linux x64、Node.js 26.8.1、2026-11-09)
+
+- **再現の試み**:管理下ランタイム(ZCode 3.16.2)と、ローカルで固定の応答を返すモデルを使った。カスタムの API キープロバイダー(モデル ID `auto/glm-5.3-flash`、推論レベル low/high/max)で、ターンの前後にセッションを閉じて開き直す操作を 2 回行い、サブエージェントを呼ぶ場合も試した。マーカーは一度も出ず、モデルへのリクエストはすべて `auto/glm-5.3-flash` と `max` だった。ターンごとに交互に出る状態は再現していない。
+- **テスト**:追加したテストのうち、表示の判定を外すと `test/provider.test.ts` の 2 件が失敗することを確かめた。`npm run typecheck`、`npm test`(main の #91 をマージした後、24 ファイル、233 tests)、`npm run build`、`npm run format:check`、`git diff --check` が成功した。
+- **上流**:Paseo 0.12.0(`cafe4b01c8522ff39560241c5deb01427dc8dc5b`)に対する `npm run test:upstream` が成功した。設定 `timeline` の登録も確認している。ローカルでは `NODE_PATH` を外して実行した。
+- **実 UI**:`@getpaseo/cli@0.15.1` の一時 daemon(`--home` は一時ディレクトリ、loopback、relay と MCP は無効、Web UI と plugins は有効)にこの worktree を導入し、ヘッドレス Chrome で Settings → Plugins → zcode-provider → Settings → Timeline を開いた。スイッチは既定でオフで、切り替えると `plugin-settings/zcode-provider/timeline.json` に保存され、再読み込み後も値が残った。
+
+未検証:実 daemon でのエージェントの会話への反映(ZCode のセッションは作っていない)。最低要件 0.9.0 の実コンパイラでの `test:upstream`。報告者の環境でモデルが交互に切り替わる原因。
+
# ターンの失敗が原因を問わず `NATIVE_PROTOCOL_ERROR` になる(2026-11-09)
[Issue #86](https://github.com/supermomonga/paseo-plugin-zcode-provider/issues/86) の対応。ZCode のターンが失敗すると、原因が利用上限・認証・ネットワークのどれであっても、Paseo には `[System Error] ZCode turn failed` と `code: NATIVE_PROTOCOL_ERROR` だけが表示されていた。
diff --git a/index.server.ts b/index.server.ts
index b1564a7..00fe1aa 100644
--- a/index.server.ts
+++ b/index.server.ts
@@ -5,6 +5,7 @@ import { createHost, createZCodeProvider } from "./server/provider.js";
import { ManagedRuntimeInstaller } from "./server/runtime/managed.js";
import { createRuntimeSetupHandlers } from "./server/runtime-setup.js";
import { createDiagnosticsHandler } from "./server/status.js";
+import { followTimelineSettings } from "./server/timeline-settings.js";
import { createUsageSource } from "./server/usage.js";
import { zcodeAccountChange, zcodeAccountView } from "./shared/account.js";
import { zcodeDiagnostics } from "./shared/diagnostics.js";
@@ -13,9 +14,15 @@ import {
zcodeRuntimeRemove,
zcodeRuntimeStatus,
} from "./shared/runtime-setup.js";
+import { zcodeTimelineSettings } from "./shared/timeline.js";
export default function contribute(server: PluginServerContext): () => void {
- server.registerProvider(createZCodeProvider());
+ const timeline = followTimelineSettings(
+ server.registerSettings(zcodeTimelineSettings),
+ );
+ server.registerProvider(
+ createZCodeProvider(undefined, undefined, undefined, timeline.current),
+ );
server.handle(zcodeDiagnostics, createDiagnosticsHandler());
const setup = createRuntimeSetupHandlers(new ManagedRuntimeInstaller());
server.handle(zcodeRuntimeStatus, setup.status);
@@ -33,6 +40,7 @@ export default function contribute(server: PluginServerContext): () => void {
server.registerUsageSource(usage.source);
return () => {
usage.dispose();
+ timeline.dispose();
abort.abort();
void account.close();
};
diff --git a/paseo-plugin.json b/paseo-plugin.json
index 998c261..adccc97 100644
--- a/paseo-plugin.json
+++ b/paseo-plugin.json
@@ -1,5 +1,5 @@
{
"id": "zcode-provider",
- "requirements": { "paseo": ">=0.8.0" },
+ "requirements": { "paseo": ">=0.9.0" },
"build": [["npm", "ci", "--include=dev"]]
}
diff --git a/scripts/check-upstream.mjs b/scripts/check-upstream.mjs
index 0e95f2e..4fb1ac0 100644
--- a/scripts/check-upstream.mjs
+++ b/scripts/check-upstream.mjs
@@ -496,14 +496,30 @@ async function checkContributions({
const contribution = runInThisContext(serverBundle)((name) =>
name === "@getpaseo/plugin/server/provider" ? sdk : requireModule(name),
);
- // Paseo 0.8–0.10 offer no registerUsageSource; the plugin must still load.
+ // Paseo 0.9+ returns a settings handle; the plugin follows the timeline
+ // settings with it.
+ const settings = [];
+ const registerSettings = (definition) => {
+ settings.push(definition.id);
+ return {
+ read: async () => ({
+ status: "ready",
+ revision: "1",
+ values: definition.schema.parse({}),
+ }),
+ subscribe: () => () => {},
+ };
+ };
+ // Paseo 0.9–0.10 offer no registerUsageSource; the plugin must still load.
let registered;
const dispose = contribution.default({
registerProvider(provider) {
registered = provider;
},
+ registerSettings,
handle() {},
});
+ assert.deepEqual(settings, ["timeline"]);
assert.equal(registered.id, "zcode");
assert.equal(typeof registered.status, "function");
await readPluginProviderIcon(candidate, registered.icon);
@@ -516,6 +532,7 @@ async function checkContributions({
registerUsageSource(source) {
sources.push(source);
},
+ registerSettings,
handle() {},
});
assert.equal(sources.length, 1);
@@ -549,6 +566,7 @@ async function checkContributions({
return {
openExternalUrl: async () => {},
useRpc: () => async () => ({}),
+ useSettings: () => ({ status: "loading" }),
};
if (name === "@getpaseo/plugin/client/react-native")
return { copyText: async () => {} };
@@ -582,6 +600,7 @@ async function checkContributions({
compiledBytes: Buffer.byteLength(serverBundle),
clientCompiledBytes: Buffer.byteLength(clientBundle),
registration: "passed",
+ settingsRegistration: "passed",
usageSourceRegistration: "passed",
clientRegistration: "passed",
};
diff --git a/server/presentation.test.ts b/server/presentation.test.ts
index 7031269..9537852 100644
--- a/server/presentation.test.ts
+++ b/server/presentation.test.ts
@@ -257,3 +257,37 @@ it("reports context compaction only when it ends", () => {
message: "Context compaction: success",
});
});
+
+it("reports model changes with providers and without the reasoning level", () => {
+ const marker = (change: object) =>
+ ({
+ rowId: 9,
+ turnId: "p",
+ createdAt: 1,
+ createdAtSeq: 1,
+ kind: "timelineMarker",
+ marker: { type: "modelChange", ...change },
+ }) as any;
+ expect(
+ rowTimeline(
+ marker({ toProvider: "magpie", toModel: "GLM-5.3-Flash", toThought: "" }),
+ ),
+ ).toMatchObject({
+ type: "notification",
+ message: "Using magpie/GLM-5.3-Flash",
+ });
+ expect(
+ rowTimeline(
+ marker({
+ fromProvider: "magpie",
+ fromModel: "GLM-5.3-Flash",
+ toProvider: "magpie",
+ toModel: "auto/glm-5.3-flash",
+ toThought: "max",
+ }),
+ ),
+ ).toMatchObject({
+ type: "notification",
+ message: "Model switched magpie/GLM-5.3-Flash → magpie/auto/glm-5.3-flash",
+ });
+});
diff --git a/server/presentation.ts b/server/presentation.ts
index 90c261e..e29d0bc 100644
--- a/server/presentation.ts
+++ b/server/presentation.ts
@@ -458,8 +458,14 @@ function markerText(marker: TimelineMarkerPayload): string {
switch (marker.type) {
case "compact":
return `Context compaction: ${marker.status}`;
- case "modelChange":
- return `Model: ${marker.toModel} (${marker.toThought})`;
+ case "modelChange": {
+ // Worded as in ZCode Desktop, which also omits the reasoning level: it
+ // does not count as a model change and may be empty.
+ const to = `${marker.toProvider}/${marker.toModel}`;
+ return marker.fromProvider === undefined || marker.fromModel === undefined
+ ? `Using ${to}`
+ : `Model switched ${marker.fromProvider}/${marker.fromModel} → ${to}`;
+ }
case "forkNotice":
return "Conversation continued from a parent conversation.";
case "forkCreated":
diff --git a/server/provider.ts b/server/provider.ts
index ee4c56e..fa11a1a 100644
--- a/server/provider.ts
+++ b/server/provider.ts
@@ -52,6 +52,10 @@ import {
import { SessionSnapshotSchema, SessionListSchema } from "./host/schemas.js";
import { TimelineSnapshots } from "./timeline.js";
import type { NativeSessionEvent } from "./session-types.js";
+import {
+ defaultTimelinePreferences,
+ type TimelinePreferences,
+} from "../shared/timeline.js";
export const CAPABILITIES = [
"prompt.message",
@@ -117,6 +121,7 @@ export function createZCodeProvider(
bridgeFactory: BridgeFactory = createHost,
persistenceStore = new SessionPersistenceStore(),
status: ProviderRegistration["status"] = createRuntimeStatus(),
+ timeline: () => TimelinePreferences = () => defaultTimelinePreferences,
): ProviderRegistration {
return {
id: "zcode",
@@ -134,6 +139,7 @@ export function createZCodeProvider(
negotiateProviderCapabilities(request.capabilities, CAPABILITIES),
bridgeFactory,
persistenceStore,
+ timeline,
);
},
};
@@ -154,6 +160,7 @@ export class ZCodeConnection implements ProviderConnection {
readonly capabilities: readonly string[],
private readonly bridgeFactory: BridgeFactory,
private readonly persistenceStore: SessionPersistenceStore,
+ private readonly timeline: () => TimelinePreferences,
) {}
onEvent(listener: (event: ProviderEvent) => void): () => void {
@@ -559,6 +566,7 @@ export class ZCodeConnection implements ProviderConnection {
workspace: cwd,
snapshot,
modelCatalog: selection.models,
+ timeline: this.timeline,
onClose() {},
});
if (
diff --git a/server/session.ts b/server/session.ts
index a2477db..817d8b9 100644
--- a/server/session.ts
+++ b/server/session.ts
@@ -51,6 +51,7 @@ import type {
import { AdapterError } from "./errors.js";
import { diagnosticError, formatDiagnostic } from "./diagnostics.js";
import { turnFailure } from "./turn-failure.js";
+import type { TimelinePreferences } from "../shared/timeline.js";
interface Admission {
clientMessageId?: string;
accepted: boolean;
@@ -77,6 +78,7 @@ export class ZCodeSession {
private readonly seenTurns = new Set();
private readonly publicTurns = new Map();
private readonly presented = new Map();
+ private readonly omitted = new Set();
private readonly pending = new Map();
private readonly answering = new Set();
private readonly resolvedInteractions = new Set();
@@ -95,6 +97,7 @@ export class ZCodeSession {
private readonly workspace: string,
private readonly snapshot: SessionSnapshot,
private modelCatalog: readonly ModelOption[],
+ private readonly timeline: () => TimelinePreferences,
private readonly onClose: () => void,
) {
assertSnapshotWorkspace(snapshot, workspace);
@@ -109,6 +112,7 @@ export class ZCodeSession {
workspace: string;
snapshot: SessionSnapshot;
modelCatalog: readonly ModelOption[];
+ timeline: () => TimelinePreferences;
onClose: () => void;
}): Promise {
const session = new ZCodeSession(
@@ -117,6 +121,7 @@ export class ZCodeSession {
options.workspace,
options.snapshot,
options.modelCatalog,
+ options.timeline,
options.onClose,
);
session.unlistenFailure = options.bridge.onFailure((error) =>
@@ -134,7 +139,7 @@ export class ZCodeSession {
if (row.kind === "turnHeader")
session.seenTurns.add(session.productTurn(row));
const item = rowTimeline(row);
- if (item)
+ if (item && !session.omits(row, item.id))
session.presented.set(item.id, {
item,
timestamp: new Date(row.createdAt).toISOString(),
@@ -169,6 +174,22 @@ export class ZCodeSession {
);
return row.productTurnId;
}
+ // The setting decides when a marker is first seen. Paseo keeps the items it
+ // has received, and a marker shown after a later change would land at the
+ // end of the timeline.
+ private omits(row: ConversationRow, id: string): boolean {
+ if (
+ row.kind !== "timelineMarker" ||
+ row.marker.type !== "modelChange" ||
+ this.presented.has(id)
+ )
+ return false;
+ if (this.omitted.has(id) || !this.timeline().showModelChanges) {
+ this.omitted.add(id);
+ return true;
+ }
+ return false;
+ }
private newRun(): Run {
return {
id: randomUUID(),
@@ -224,7 +245,7 @@ export class ZCodeSession {
? this.admissions.get(row.sourceCommandId)?.clientMessageId
: undefined;
const item = rowTimeline(row, clientMessageId);
- if (!item) continue;
+ if (!item || this.omits(row, item.id)) continue;
const entry = { item, timestamp: new Date(row.createdAt).toISOString() };
if (isDeepStrictEqual(entry, this.presented.get(item.id))) continue;
this.presented.set(item.id, entry);
diff --git a/server/timeline-settings.test.ts b/server/timeline-settings.test.ts
new file mode 100644
index 0000000..2eb69c7
--- /dev/null
+++ b/server/timeline-settings.test.ts
@@ -0,0 +1,63 @@
+import { expect, it } from "vitest";
+import type { PluginSettingsState } from "@getpaseo/plugin/server";
+import { followTimelineSettings } from "./timeline-settings.js";
+import type { zcodeTimelineSettings } from "../shared/timeline.js";
+
+type State = PluginSettingsState<(typeof zcodeTimelineSettings)["schema"]>;
+
+function settings() {
+ let resolveRead!: (state: State) => void;
+ const listeners = new Set<(state: State) => void>();
+ return {
+ handle: {
+ read: () => new Promise((r) => (resolveRead = r)),
+ subscribe(listener: (state: State) => void) {
+ listeners.add(listener);
+ return () => void listeners.delete(listener);
+ },
+ },
+ read: async (state: State) => {
+ resolveRead(state);
+ await new Promise((r) => setTimeout(r));
+ },
+ notify: (state: State) => listeners.forEach((l) => l(state)),
+ listeners,
+ };
+}
+const ready = (showModelChanges: boolean, revision = "1"): State => ({
+ status: "ready",
+ revision,
+ values: { showModelChanges },
+});
+
+it("hides model changes until saved settings say otherwise", async () => {
+ const s = settings();
+ const timeline = followTimelineSettings(s.handle);
+ expect(timeline.current()).toEqual({ showModelChanges: false });
+ await s.read(ready(true));
+ expect(timeline.current()).toEqual({ showModelChanges: true });
+ s.notify(ready(false, "2"));
+ expect(timeline.current()).toEqual({ showModelChanges: false });
+});
+
+it("uses the defaults while the stored document is invalid", async () => {
+ const s = settings();
+ const timeline = followTimelineSettings(s.handle);
+ await s.read({ status: "invalid", revision: "1", error: "bad" });
+ expect(timeline.current()).toEqual({ showModelChanges: false });
+});
+
+it("keeps a save notified before the first read completes", async () => {
+ const s = settings();
+ const timeline = followTimelineSettings(s.handle);
+ s.notify(ready(true, "2"));
+ await s.read(ready(false, "1"));
+ expect(timeline.current()).toEqual({ showModelChanges: true });
+});
+
+it("stops following after disposal", () => {
+ const s = settings();
+ const timeline = followTimelineSettings(s.handle);
+ timeline.dispose();
+ expect(s.listeners.size).toBe(0);
+});
diff --git a/server/timeline-settings.ts b/server/timeline-settings.ts
new file mode 100644
index 0000000..9aaa32b
--- /dev/null
+++ b/server/timeline-settings.ts
@@ -0,0 +1,50 @@
+import type {
+ PluginSettings,
+ PluginSettingsState,
+} from "@getpaseo/plugin/server";
+import { logger } from "./logger.js";
+import {
+ defaultTimelinePreferences,
+ type TimelinePreferences,
+ type zcodeTimelineSettings,
+} from "../shared/timeline.js";
+
+type Schema = (typeof zcodeTimelineSettings)["schema"];
+
+/**
+ * Follows the saved timeline settings. The defaults apply until the first read
+ * completes and while the stored document is invalid.
+ */
+export function followTimelineSettings(settings: PluginSettings): {
+ current: () => TimelinePreferences;
+ dispose: () => void;
+} {
+ let current = defaultTimelinePreferences,
+ changed = false,
+ disposed = false;
+ const apply = (state: PluginSettingsState) => {
+ if (disposed) return;
+ if (state.status === "invalid")
+ logger.log("warn", "zcode.settings.timeline.invalid");
+ current =
+ state.status === "ready" ? state.values : defaultTimelinePreferences;
+ };
+ const unsubscribe = settings.subscribe((state) => {
+ changed = true;
+ apply(state);
+ });
+ settings.read().then(
+ (state) => {
+ // A save notified meanwhile is newer than this read.
+ if (!changed) apply(state);
+ },
+ (error: unknown) => logger.error("zcode.settings.timeline.failed", error),
+ );
+ return {
+ current: () => current,
+ dispose() {
+ disposed = true;
+ void unsubscribe();
+ },
+ };
+}
diff --git a/server/usage.ts b/server/usage.ts
index 17b8be1..88f1369 100644
--- a/server/usage.ts
+++ b/server/usage.ts
@@ -1,5 +1,5 @@
import { createHash } from "node:crypto";
-// Types only, from the module every supported Paseo resolves; Paseo 0.8–0.10
+// Types only, from the module every supported Paseo resolves; Paseo 0.9–0.10
// reject `@getpaseo/plugin/server/usage` even as a type import.
import type {
UsageReport,
diff --git a/shared/timeline.ts b/shared/timeline.ts
new file mode 100644
index 0000000..0101904
--- /dev/null
+++ b/shared/timeline.ts
@@ -0,0 +1,12 @@
+import { defineSettings } from "@getpaseo/plugin";
+import { z } from "zod";
+
+export const zcodeTimelineSettings = defineSettings({
+ id: "timeline",
+ scope: "host",
+ version: 1,
+ schema: z.object({ showModelChanges: z.boolean().default(false) }),
+});
+export type TimelinePreferences = z.output;
+export const defaultTimelinePreferences: TimelinePreferences =
+ zcodeTimelineSettings.schema.parse({});
diff --git a/test/provider-fixture.ts b/test/provider-fixture.ts
index 3e7aad6..a4b3fce 100644
--- a/test/provider-fixture.ts
+++ b/test/provider-fixture.ts
@@ -9,13 +9,17 @@ import type {
import { createZCodeProvider, CAPABILITIES } from "../server/provider.js";
import { SessionPersistenceStore } from "../server/persistence.js";
import { FakeBridge, snapshot } from "./fake-host.js";
-export async function providerFixture() {
+import type { TimelinePreferences } from "../shared/timeline.js";
+export async function providerFixture(timeline?: () => TimelinePreferences) {
const cwd = await realpath(await mkdtemp(join(tmpdir(), "zcode-v4-test-")));
const host = new FakeBridge(snapshot(cwd));
const store = new SessionPersistenceStore(join(cwd, "state"));
- const connection = await createZCodeProvider(async () => host, store).connect(
- { versions: [1], capabilities: CAPABILITIES },
- );
+ const connection = await createZCodeProvider(
+ async () => host,
+ store,
+ undefined,
+ timeline,
+ ).connect({ versions: [1], capabilities: CAPABILITIES });
const events: ProviderEvent[] = [];
connection.onEvent((e) => events.push(e));
const wait = async (predicate: (e: ProviderEvent) => boolean) => {
diff --git a/test/provider.test.ts b/test/provider.test.ts
index 7e2e94f..03b769a 100644
--- a/test/provider.test.ts
+++ b/test/provider.test.ts
@@ -6,8 +6,8 @@ const cleanups: Array<() => Promise> = [];
afterEach(async () => {
for (const close of cleanups.splice(0).reverse()) await close();
});
-async function fixture() {
- const f = await providerFixture();
+async function fixture(...args: Parameters) {
+ const f = await providerFixture(...args);
cleanups.push(f.close);
return f;
}
@@ -378,27 +378,94 @@ it("keeps the generic turn failure when ZCode reports no error", async () => {
error: { code: "NATIVE_TURN_FAILED", message: "ZCode turn failed." },
});
});
-it("renders configuration markers without inventing a product turn", async () => {
- const f = await fixture();
+it("shows model change markers only while the setting is on when first seen", async () => {
+ const preferences = { showModelChanges: false };
+ const f = await fixture(() => preferences);
await f.open();
- const { productTurnId, turnId, ...base } = f.host.rowBase();
+ const marker = async (toModel: string) => {
+ const { productTurnId, turnId, ...base } = f.host.rowBase();
+ await f.host.append({
+ ...base,
+ turnId: "",
+ kind: "timelineMarker",
+ marker: {
+ type: "modelChange",
+ toProvider: "provider",
+ toModel,
+ toThought: "high",
+ },
+ });
+ };
+ const shown = () =>
+ f.events.flatMap((e) =>
+ e.type === "timeline.item" && e.item.type === "notification"
+ ? [e.item.message]
+ : [],
+ );
+ await marker("hidden");
+ preferences.showModelChanges = true;
+ // A configuration marker does not invent a product turn.
+ await marker("shown");
+ await f.wait(
+ (e) => e.type === "timeline.item" && e.item.type === "notification",
+ );
+ preferences.showModelChanges = false;
+ await marker("hidden-again");
await f.host.append({
+ ...f.host.rowBase(),
+ kind: "timelineMarker",
+ marker: { type: "compact", origin: "auto", status: "success" },
+ });
+ await f.wait(
+ (e) =>
+ e.type === "timeline.item" &&
+ e.item.type === "notification" &&
+ e.item.message.startsWith("Context compaction"),
+ );
+ expect(shown()).toEqual([
+ "Using provider/shown",
+ "Context compaction: success",
+ ]);
+ expect(f.events.some((e) => e.type === "session.runtime_failed")).toBe(false);
+});
+it("replays model change markers with the setting current at reopening", async () => {
+ const preferences = { showModelChanges: false };
+ const f = await fixture(() => preferences);
+ const { productTurnId, turnId, ...base } = f.host.rowBase();
+ const marker = {
...base,
turnId: "",
- kind: "timelineMarker",
+ kind: "timelineMarker" as const,
marker: {
- type: "modelChange",
+ type: "modelChange" as const,
toProvider: "provider",
toModel: "model",
toThought: "high",
},
+ };
+ const id = `zcode:row:${marker.rowId}`;
+ await f.host.append(marker);
+ await f.open();
+ await f.prompt();
+ await completeTurn(f.host);
+ await f.wait((e) => e.type === "session.turn" && e.state === "completed");
+ expect(
+ f.events.some((e) => e.type === "timeline.item" && e.item.id === id),
+ ).toBe(false);
+ const persisted = f.events.find((e) => e.type === "session.opened");
+ if (persisted?.type !== "session.opened")
+ throw new Error("Missing persistence");
+ await f.send({
+ type: "session.close",
+ sessionId: "public",
+ requestId: "close",
});
- expect(f.events.some((e) => e.type === "session.runtime_failed")).toBe(false);
+ f.events.length = 0;
+ preferences.showModelChanges = true;
+ await f.open({}, persisted.persistence);
expect(
- f.events.some(
- (e) => e.type === "timeline.item" && e.item.type === "notification",
- ),
- ).toBe(true);
+ await f.wait((e) => e.type === "timeline.item" && e.item.id === id),
+ ).toMatchObject({ item: { message: "Using provider/model" } });
});
it("lists native sessions using the current handle version", async () => {
const f = await fixture();