diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 625def4..8c0330f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: uses: actions/checkout@v6 with: repository: zai-org/ZCode - ref: 3c5b227649371507ddc4eb46ac5133afe6db1cab # 3.16.2 (untagged main) + ref: a9fe401eede6e6e5e01be9048679c206fe6f02d9 # v3.17.2 path: zcode-source persist-credentials: false - name: Install dependencies and generate build metadata diff --git a/AGENTS.md b/AGENTS.md index de02ff9..6f62bcb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -53,7 +53,7 @@ Identify the root cause and do not add ad hoc workarounds. Add backward compatib - Limit implementations and proposed solutions to this Paseo plugin. Do not modify Paseo or ZCode itself, or require a fork. The only exception is the managed runtime's build-time patches in `patches/zcode/` (ADR 19): plain unified diffs against the pinned TypeScript source, applied with `git apply` (no fuzz) by the release workflow, and limited to hiding capabilities the provider cannot support. They must not change model requests, authentication or credentials, storage formats, the protocol or network endpoints. Each patch states its purpose, target and removal condition, and is removed once ZCode offers an official equivalent. Never patch installed files or alter behavior at launch. Building official ZCode from source is allowed for verification. - Use `~/ghq/github.com/zai-org/ZCode` as the implementation reference. Record commit SHA and source paths; do not extract Electron/deb bundles for source investigation. -- Current source baseline: `3c5b227649371507ddc4eb46ac5133afe6db1cab` (3.16.2, an untagged upstream `main` sync commit; ADR 20). Verify vendored RPC/V4 source with `npm run check:zcode-source` and the runtime patches with `npm run check:zcode-patches -- /absolute/ZCode`. Keep `server/vendor/zcode` unformatted and retain its license/provenance. +- Current source baseline: `a9fe401eede6e6e5e01be9048679c206fe6f02d9` (3.17.2, upstream tag `v3.17.2`). Verify vendored RPC/V4 source with `npm run check:zcode-source` and the runtime patches with `npm run check:zcode-patches -- /absolute/ZCode`. Keep `server/vendor/zcode` unformatted and retain its license/provenance. - The managed runtime is the default (ADR 15): Node.js from nodejs.org and the `zcode-runtime-v-paseo.` release of this repository, both pinned by SHA-256 in `server/runtime/pins.ts` and installed only when the user starts setup. Runtime setup RPCs never accept URLs, paths or versions from clients. `PASEO_ZCODE_RUNTIME` plus ordinary Node.js 24.14.0+ via `PASEO_ZCODE_NODE` override it; one variable alone is an error. Never fall back to Desktop/Electron. - To ship a new ZCode version, update the source baseline (a tag, or an untagged `main` commit whose root `package.json` version equals the changelog release, per ADR 20), make every patch in `patches/zcode/` apply again (regenerate a rejected one against the new source and review it), push a `zcode-runtime-v-paseo.` tag so `.github/workflows/zcode-runtime-release.yml` builds, verifies on all managed platforms and publishes the archive, then pin the published SHA-256 and size. Never replace an existing release asset. - `npm run test:stdio-runtime` uses the real runtime (override pair or managed runtime under `XDG_DATA_HOME`) with isolated data and a local model fixture. Resume guarantees require both Paseo's saved `mode` and `settings.plan_mode`; failures of this supported contract block release. Keep source SHA, distribution hashes, runtime versions and actual OS coverage separate. diff --git a/NOTICE.md b/NOTICE.md index 8952926..1ff5597 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -16,7 +16,7 @@ ZCode は統合 CLI を配布していないため、このリポジトリは `z Node.js は利用者のマシンが nodejs.org の公式成果物を直接取得します。このリポジトリは Node.js を再配布しません。 -`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) は全文を保持しており、上流製品全体の説明です。そこに記載された全機能・依存がプラグインへ同梱されることを意味しません。 +`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) は全文を保持しており、上流製品全体の説明です。そこに記載された全機能・依存がプラグインへ同梱されることを意味しません。 ファイルごとの出典・SHA-256、private workspace import の変更、第三者通知の抽出範囲を [provenance.json](server/vendor/zcode/provenance.json) に記録しています。取得・照合は `scripts/sync-zcode-source.mjs` で行います。`npm run build` はこれらのライセンス・通知を `dist/licenses/zcode` にも配置します。 diff --git a/README.md b/README.md index ef8fe01..451822a 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This is an unofficial plugin. It is not endorsed or maintained by ZCode or Z.ai. | Paseo | 0.15.0 or later; development SDK 0.15.3 | | 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+ | +| 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+ | ## Installation @@ -35,7 +35,7 @@ Open **Settings → Plugins → zcode-provider → Settings**. The screen has th 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: - Node.js 24.21.0 from nodejs.org. -- 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. +- 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. Both archives are verified against SHA-256 values pinned in the plugin and extracted to the daemon user's data directory: @@ -76,9 +76,9 @@ export PASEO_ZCODE_NODE=/absolute/path/to/node # ordinary Node.js 24.14.0 `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. -Session environment variables are forwarded, subject to ZCode's own proxy, certificate and runtime environment handling. +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. -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. +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. ## Behavior @@ -86,10 +86,11 @@ The source baseline is `3c5b227649371507ddc4eb46ac5133afe6db1cab` (ZCode 3.16.2, - 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. - 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. - 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's Usage screen (ADR 23). +- 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). - 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. 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.” +- 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. - Each session owns its Server process and environment. Metadata requests use temporary Servers. Closing stdin gives ZCode time to clean up before process termination. - 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)). diff --git "a/docs/adr/0020-\343\202\277\343\202\260\343\201\256\347\204\241\343\201\204\344\270\212\346\265\201\343\201\256\345\220\214\346\234\237\343\202\263\343\203\237\343\203\203\343\203\210\343\202\222package-version\343\201\247\347\211\271\345\256\232\343\201\227\343\201\246zcode\343\201\256\343\202\275\343\203\274\343\202\271\345\237\272\346\272\226\343\201\253\343\201\231\343\202\213.md" "b/docs/adr/0020-\343\202\277\343\202\260\343\201\256\347\204\241\343\201\204\344\270\212\346\265\201\343\201\256\345\220\214\346\234\237\343\202\263\343\203\237\343\203\203\343\203\210\343\202\222package-version\343\201\247\347\211\271\345\256\232\343\201\227\343\201\246zcode\343\201\256\343\202\275\343\203\274\343\202\271\345\237\272\346\272\226\343\201\253\343\201\231\343\202\213.md" index 897e233..d5ff54e 100644 --- "a/docs/adr/0020-\343\202\277\343\202\260\343\201\256\347\204\241\343\201\204\344\270\212\346\265\201\343\201\256\345\220\214\346\234\237\343\202\263\343\203\237\343\203\203\343\203\210\343\202\222package-version\343\201\247\347\211\271\345\256\232\343\201\227\343\201\246zcode\343\201\256\343\202\275\343\203\274\343\202\271\345\237\272\346\272\226\343\201\253\343\201\231\343\202\213.md" +++ "b/docs/adr/0020-\343\202\277\343\202\260\343\201\256\347\204\241\343\201\204\344\270\212\346\265\201\343\201\256\345\220\214\346\234\237\343\202\263\343\203\237\343\203\203\343\203\210\343\202\222package-version\343\201\247\347\211\271\345\256\232\343\201\227\343\201\246zcode\343\201\256\343\202\275\343\203\274\343\202\271\345\237\272\346\272\226\343\201\253\343\201\231\343\202\213.md" @@ -74,3 +74,5 @@ Chosen option: "公開 `main` 上の同期コミットのうち、ルート `pac ## More Information 2026-10-21 の確認:`git ls-remote` で `main` = `3c5b227`、タグは `v3.14.3`(`29628c9`)と `v3.15.1`(`aac4755`)だけ。`3c5b227` の親 `0a1fc56` が 3.16.1、その親 `aac4755` が 3.15.1。3.14.4、3.14.5、3.15.3 に対応するソースは公開されていない。上流が再びタグや GitHub Release を付けるようになったら、タグを基準とする運用に戻すかを見直す。詳細は[検証記録](../verification.md)を参照する。 + +2026-11-09 の見直し:上流は `v3.17.1`(`a60ba6a`)と `v3.17.2`(`a9fe401`)にタグと GitHub Release を付けた。どちらも、ルート `package.json` の版がタグの版と一致する。3.17.2 の基準はタグとし、ADR 15 の条件をそのまま満たす。版が一致するタグがあればタグを使う。タグの無い同期コミットを採る手順は、3.16.1 と 3.16.2 のようにタグが付かない版のために残す。変更履歴の 3.16.3 に対応するソースは無い。 diff --git "a/docs/adr/0023-\343\202\277\343\203\274\343\203\263\343\201\256\345\244\261\346\225\227\343\201\257v4\343\201\256lasterror\343\201\256attribution\343\201\247\345\210\206\351\241\236\343\201\227\343\201\237\343\202\263\343\203\274\343\203\211\343\201\250\345\233\272\345\256\232\343\201\256\346\226\207\350\250\200\343\201\247\344\274\235\343\201\210\343\202\213.md" "b/docs/adr/0023-\343\202\277\343\203\274\343\203\263\343\201\256\345\244\261\346\225\227\343\201\257v4\343\201\256lasterror\343\201\256attribution\343\201\247\345\210\206\351\241\236\343\201\227\343\201\237\343\202\263\343\203\274\343\203\211\343\201\250\345\233\272\345\256\232\343\201\256\346\226\207\350\250\200\343\201\247\344\274\235\343\201\210\343\202\213.md" index 756ee2c..1b95917 100644 --- "a/docs/adr/0023-\343\202\277\343\203\274\343\203\263\343\201\256\345\244\261\346\225\227\343\201\257v4\343\201\256lasterror\343\201\256attribution\343\201\247\345\210\206\351\241\236\343\201\227\343\201\237\343\202\263\343\203\274\343\203\211\343\201\250\345\233\272\345\256\232\343\201\256\346\226\207\350\250\200\343\201\247\344\274\235\343\201\210\343\202\213.md" +++ "b/docs/adr/0023-\343\202\277\343\203\274\343\203\263\343\201\256\345\244\261\346\225\227\343\201\257v4\343\201\256lasterror\343\201\256attribution\343\201\247\345\210\206\351\241\236\343\201\227\343\201\237\343\202\263\343\203\274\343\203\211\343\201\250\345\233\272\345\256\232\343\201\256\346\226\207\350\250\200\343\201\247\344\274\235\343\201\210\343\202\213.md" @@ -37,7 +37,7 @@ ADR 7 は、ネイティブのエラーメッセージを ProviderError.diagnost Chosen option: 「`lastError.attribution` で分類したコードと、プラグインの固定の文言を返す」。ADR 7 を変えずに、失敗の種類と対処を伝えられるため。 - ターンが失敗したら、そのフレームの `control.lastError` を読む。分類には `attribution.source`(無ければ `lastError.source`)と `attribution.reason` だけを使う。`lastError.code` にはプロバイダー固有のコードがそのまま入ることがあるので使わない。 -- `source` が `provider` か `network` のとき、`reason`(ZCode の `ModelFailureReason`)を次のコードに対応付ける。`MODEL_RATE_LIMITED`(`rate_limited`、`offpeak_queued`)、`MODEL_AUTH_FAILED`(`auth_failed`、`auth_refresh`、`provider_not_configured`)、`MODEL_CONTEXT_EXCEEDED`(`context_exceeded`)、`MODEL_NETWORK_ERROR`(`network_error`、`timeout`、`stream_idle_timeout`、`stale_connection`、`proxy_error`、`tls_error`)、`MODEL_PROVIDER_ERROR`(`server_error`、`provider_overloaded`)。それ以外の `reason` は、`network` なら `MODEL_NETWORK_ERROR`、`provider` なら `MODEL_REQUEST_FAILED` とする。 +- `source` が `provider` か `network` のとき、`reason`(ZCode の `ModelFailureReason`)を次のコードに対応付ける。`MODEL_RATE_LIMITED`(`rate_limited`、`offpeak_queued`)、`MODEL_AUTH_FAILED`(`auth_failed`、`auth_refresh`、`provider_not_configured`)、`MODEL_CONTEXT_EXCEEDED`(`context_exceeded`)、`MODEL_NETWORK_ERROR`(`network_error`、`timeout`、`stream_idle_timeout`、`stale_connection`、`proxy_error`、`tls_error`)、`MODEL_PROVIDER_ERROR`(`server_error`、`provider_overloaded`)、`MODEL_CONTENT_FILTERED`(`content_filter`)。`content_filter` は `ModelFailureReason` の外の値で、3.17.1 から、プロバイダーの内容フィルターが止めた空の応答に付く。それ以外の `reason` は、`network` なら `MODEL_NETWORK_ERROR`、`provider` なら `MODEL_REQUEST_FAILED` とする。 - `runtime`・`tool` の失敗と、`lastError` が無い失敗は `NATIVE_TURN_FAILED`(`ZCode turn failed.`)とする。ターンの失敗に `NATIVE_PROTOCOL_ERROR` は使わない。 - 文言はプラグインの固定の英文とし、HTTP ステータスと、数字だけか英字の語だけからなるプロバイダーのエラーコードを添える。利用上限では、Coding Plan のリセット時刻を Paseo 0.11 以降の Usage 画面で確認できると案内する(ADR 18)。 - ProviderError.diagnostic に `stage: "turn"` と `failure` を加える。`failure` には、許可リストに一致した `source`・`reason`・`errorPhase`・`exceptionKind`、100〜599 の `statusCode`、上記の条件を満たす `providerErrorCode`、`retryable` だけを入れる。`providerId`・`modelId` は利用者が付けた名前を含みうるので入れない。 @@ -51,7 +51,7 @@ Chosen option: 「`lastError.attribution` で分類したコードと、プラ ### Confirmation -`server/turn-failure.test.ts` で、各 `reason` と `source` の分類、ネイティブの文字列が文言と診断に入らないこと、報告できないプロバイダーのエラーコードを落とすことを確認する。`test/provider.test.ts` で、3.16.2 の 429 と同じ形の `lastError` が分類されて Paseo の `session.turn` に届くことと、`lastError` が無いときの汎用の失敗を確認する。`npm run test:stdio-runtime` は、ローカルのモデルが 429(1310)を返したときに `MODEL_RATE_LIMITED` が届き、原文が含まれず、次のプロンプトが完了することを実ランタイムで確認する。 +`server/turn-failure.test.ts` で、各 `reason` と `source` の分類、ネイティブの文字列が文言と診断に入らないこと、報告できないプロバイダーのエラーコードを落とすことを確認する。`test/provider.test.ts` で、3.16.2 の 429 と同じ形の `lastError` が分類されて Paseo の `session.turn` に届くことと、`lastError` が無いときの汎用の失敗を確認する。`npm run test:stdio-runtime` は、ローカルのモデルが 429(1310)を返したときに `MODEL_RATE_LIMITED` が届き、原文が含まれず、次のプロンプトが完了することを実ランタイムで確認する。3.17.1 以降のランタイムでは、ローカルのモデルが GLM と同じ `sensitive` で応答を止めたときに、再試行されずに `MODEL_CONTENT_FILTERED` が届くことも確認する。 ## Pros and Cons of the Options @@ -73,3 +73,5 @@ Chosen option: 「`lastError.attribution` で分類したコードと、プラ ## More Information ADR 7 の診断の方針を補う。ZCode 側の根拠は 3c5b227 の `apps/zcode-cli/packages/bootstrap/src/zcode-protocol-v4/product-projection.ts`(TurnError の投影と、ターン開始時の消去)、`packages/shared/src/zcode-protocol-v4/snapshot.ts`(`sessionErrorInfoSchema`、`errorAttributionSchema`)、`apps/zcode-cli/packages/contracts/src/model/index.ts`(`ModelFailureReason`)、`apps/zcode-cli/packages/adapters/src/model/failure-provider-business-codes.ts`、`packages/ui/src/ChatErrorBanner.tsx`。Paseo 側は `packages/server/src/server/agent/agent-manager.ts` の `formatTurnFailedMessage`。ZCode が `lastError` にリセット時刻などを構造化して加えたとき、または Paseo がエラーコードに応じた表示を持ったときに見直す。 + +2026-11-09 の追記(ZCode 3.17.2、a9fe401):3.17.1 から、本文もツール呼び出しも無く、終了理由が `content-filter`・`content_filter`・`sensitive` の応答は、再試行されずにすぐ失敗する(`apps/zcode-cli/packages/core/src/runtime/helpers/model-errors.ts` の `createContentFilteredModelResultError`)。3.16.2 までは、疑わしい空の応答として再試行されていた。`attribution` は `source: "provider"`、`reason: "content_filter"` になる。これまでの分類では `MODEL_REQUEST_FAILED` に落ち、診断の許可リストにも無かったので、`MODEL_CONTENT_FILTERED` を加えた。 diff --git a/docs/development.md b/docs/development.md index fb03f03..42017b6 100644 --- a/docs/development.md +++ b/docs/development.md @@ -16,13 +16,13 @@ npm run test:upstream -- /absolute/path/to/paseo ## Source of truth -Inspect `~/ghq/github.com/zai-org/ZCode`, not extracted Electron/deb bundles. The current baseline is `3c5b227649371507ddc4eb46ac5133afe6db1cab` (3.16.2). Record that SHA and source paths in investigations. Source version, release version and artifact identity are separate facts. +Inspect `~/ghq/github.com/zai-org/ZCode`, not extracted Electron/deb bundles. The current baseline is `a9fe401eede6e6e5e01be9048679c206fe6f02d9` (3.17.2, tag `v3.17.2`). Record that SHA and source paths in investigations. Source version, release version and artifact identity are separate facts. `server/vendor/zcode` contains the needed official RPC modules, V4 contracts, wire assembler and pure delta application with their transitive schema dependencies. It contains no Agent engine, authentication implementation, tools or storage engine. Paseo's compiler requires executable plugin modules to live under `server/`, `client/` or `shared/`, hence this location. `provenance.json` records entrypoints, original/modified hashes and the only import rewrites (the private `@zcode/model-option-map` workspace alias and `packages/shared`'s `#src/*` subpath imports, both to their relative sources). The upstream Apache-2.0 LICENSE and full NOTICE are retained, along with the relevant Visual Studio Code MIT notice extracted from THIRD-PARTY-NOTICES.md. The extraction and full original file hash are recorded. `npm run build` also copies these notices to `dist/licenses/zcode`. -Verify the files with `npm run check:zcode-source`. To deliberately resynchronize the fixed SHA, run `node scripts/sync-zcode-source.mjs /absolute/ZCode --write`; changing the SHA requires reviewing contract changes, the minimum versions and runtime evidence together. The sync script reads `git show :`, not possibly modified checkout files. Do not format vendored source. Unexpected vendored files fail verification. +Verify the files with `npm run check:zcode-source`. To deliberately resynchronize the fixed SHA, run `node scripts/sync-zcode-source.mjs /absolute/ZCode --write`; changing the SHA requires reviewing contract changes, the minimum versions and runtime evidence together. The sync script reads `git show :`, not possibly modified checkout files. Do not format vendored source. Unexpected vendored files fail verification; `--write` deletes the ones the new baseline no longer needs. -`download:zcodecjs` and deb extraction tests have been removed. Release monitoring uses the official changelog and its separately recorded last reviewed release (3.16.2). A changelog release without identifiable public source is reviewed from its notes but is not a baseline; 3.14.4, 3.14.5 and 3.15.3 have none. Upstream tagged v3.14.3 and v3.15.1 and has since pushed untagged `chore: sync ZCode source` commits to `main`. Per ADR 20, such a commit becomes a baseline only when it is reachable from upstream `main` and its root `package.json` version exactly equals the changelog release, and only one commit on `main` has that version. Record the SHA, the `git ls-remote` result and the neighbouring sync commits in the verification record; never infer a SHA from a version string. The current baseline `3c5b227` is the only commit with version 3.16.2 (its parent `0a1fc56` is 3.16.1). A source tag published later for an already reviewed release does not open an Issue, so check the upstream tags at each release review; if it points to a different commit, review the difference and publish a new `-paseo.`. Do not create an Issue for every main commit. See [the verification record](verification.md). +`download:zcodecjs` and deb extraction tests have been removed. Release monitoring uses the official changelog and its separately recorded last reviewed release (3.17.2). A changelog release without identifiable public source is reviewed from its notes but is not a baseline; 3.14.4, 3.14.5, 3.15.3 and 3.16.3 have none. Upstream tagged v3.14.3 and v3.15.1, then pushed untagged `chore: sync ZCode source` commits to `main` for 3.16.1 and 3.16.2, and tagged v3.17.1 and v3.17.2 again, with GitHub Releases. Prefer a tag whose root `package.json` version equals the changelog release. Per ADR 20, an untagged commit becomes a baseline only when it is reachable from upstream `main` and its root `package.json` version exactly equals the changelog release, and only one commit on `main` has that version. Record the SHA, the `git ls-remote` result and the neighbouring sync commits in the verification record; never infer a SHA from a version string. The current baseline is the tag `v3.17.2` (`a9fe401`); its parent `a60ba6a` is the tag `v3.17.1`. A source tag published later for an already reviewed release does not open an Issue, so check the upstream tags at each release review; if it points to a different commit, review the difference and publish a new `-paseo.`. Do not create an Issue for every main commit. See [the verification record](verification.md). ## Managed runtime and its releases diff --git a/docs/todo.md b/docs/todo.md index 2dc12f9..a48bfa7 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -20,6 +20,8 @@ Paseo・ZCode 本体の改変は禁止。対応範囲はこの Provider に限 - native の長い会話・世代変更・子エージェントからの権限要求。background continuation は、`run_in_background` の Bash の結果が届くまでを契約試験で確認した。現在の契約試験の結果と実行確認を混同しない。 - アイドル時の解放(ADR 25)で、完了したがまだ届いていないバックグラウンドの結果が失われるか。固定ソースの V4 の状態は、届けた後も `resultPending` を残すので区別できない。ZCode が届けた項目を消すようになったら、扱いを見直す。 - Desktop でアーカイブした会話。ZCode 3.16 の `session/list` はアーカイブを除かなくなり、Paseo の一覧にも出る。アーカイブはサービス側のタスク索引(`zcodeTaskService`)にあるので、公式サービスで除外できるか確認する。 +- プロジェクトの MCP の信頼(ZCode 3.17)。Desktop の Settings → MCP Servers で付けた信頼が、プラグインの Server のセッションにも効くか。保存先は共有の `~/.zcode/security/workspace-mcp-trust-v1.json` で、ローカルのワークスペースは解決済みのパスで識別される(ソースからの推定)。シンボリックリンク経由のフォルダーでは一致しない可能性がある。 +- ZCode Sites(3.17.2 の公式プラグイン `zcode-site`)でのデプロイ。CLI は Bash から `node` で動き、認証は Server の公式の経路を使うので、プラグインからも使えるとみて隠していない。サインインした実ランタイムで `zcode-site list` を試していない。 - 統合 CLI の remote terminal 用 node-pty 配置。Provider はその terminal API を呼ばず、Agent Bash は検証済みだが、upstream 配布の問題として追跡する。 ## 今回追加しない機能 diff --git a/docs/verification.md b/docs/verification.md index 05cd6a7..77cb367 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -1,3 +1,65 @@ +# ZCode 3.17.2 への追従(2026-11-09) + +[Issue #70](https://github.com/supermomonga/paseo-plugin-zcode-provider/issues/70)(3.16.3)と [Issue #84](https://github.com/supermomonga/paseo-plugin-zcode-provider/issues/84)(3.17.2)の対応。ソース基準をタグ `v3.17.2`(`a9fe401eede6e6e5e01be9048679c206fe6f02d9`)に進め、パッチ済みランタイム `3.17.2-paseo.1` を公開して固定する。 + +## 上流のソース + +- `git ls-remote https://github.com/zai-org/ZCode.git`:`main` = `a9fe401`、`feat/ui-plugin` = `662c30b`。タグは `v3.14.3`(`29628c9`)、`v3.15.1`(`aac4755`)、`v3.17.1`(`a60ba6a`)、`v3.17.2`(`a9fe401`)。GitHub Release は `v3.14.3`、`v3.17.1`、`v3.17.2`(latest)。 +- `main` の履歴は `3c5b227`(3.16.2)→ `a60ba6a`(3.17.1、`chore: sync ZCode source`、2026-10-30)→ `a9fe401`(3.17.2、`chore: sync ZCode source v3.17.2`、2026-11-03)。各コミットのルート `package.json` の版を `git show` で確かめた。 +- 公式変更履歴で 3.16.2 より新しい版は 3.16.3 と 3.17.2 だけである。3.16.3 に対応するソースもタグも無いので、変更履歴だけを確認した。3.17.1 はタグだけがあり、変更履歴に載っていない。その差分は 3.16.2 から 3.17.2 への差分に含めて確認した。 +- 上流がタグを付け直したので、タグを基準にした(ADR 20 に追記)。 + +## 変更履歴とこのプロバイダ + +`3c5b227` と `a9fe401` の差分(5,315 ファイル)のうち、Server・Agent・V4・サービス・公式プラグイン・ビルドを読んだ。 + +- **モデル要求のアプリの版(修正)**:Agent はモデル要求の `User-Agent` と `X-ZCode-App-Version` に `ZCODE_APP_VERSION` を使い、無ければ CLI の版を使う(`apps/zcode-cli/packages/bootstrap/src/model-config.ts`)。Desktop は Server の環境にこれを入れる(`packages/desktop/src/main/desktopRuntimeEnv.ts`、3.16.2 から同じ)。3.17.2 は、版でクライアントを拒むゲートウェイがあるとして、リモート Core にも入れた(`packages/zcode-server-cli/src/server-core/core.ts`)。プラグインの stdio Server の入口は入れないので、プラグインのモデル要求は `ZCode/0.17.1` を名乗っていた。ZCode Sites の CLI も同じ値を使う。Desktop と同じく、ランタイムの版を Server の環境に入れた(`server/host/bridge.ts`)。 +- **内容フィルターで止まった応答(3.17.1)**:本文もツール呼び出しも無く、終了理由が `content-filter`・`content_filter`・`sensitive` の応答は、再試行されずにすぐ失敗する(`core/src/runtime/helpers/model-errors.ts`)。`attribution` は `source: "provider"`、`reason: "content_filter"` になる。この値は `ModelFailureReason` に無いので、プラグインは `MODEL_REQUEST_FAILED` を返し、診断の `reason` も落としていた。`MODEL_CONTENT_FILTERED` を加えた(ADR 23 に追記)。 +- **プロジェクトの MCP の信頼(3.17.1)**:プロジェクトが宣言した MCP サーバーは、信頼が記録されるまで接続されない(`bootstrap/src/workspace-mcp-trust/index.ts`)。対話は出ず、V4 の `workspaceMcpAdmission` に保留の件数が入るだけである。CLI のコマンドは無く、Desktop の Settings → MCP Servers で信頼する。 + - 保留の件数は、セッションが実際に使う設定ではなく、プロジェクトの宣言から数える。プラグインが MCP サーバーを渡すと、その一覧が ZCode の設定ファイルを置き換える(`bootstrap/src/app/runtime-config.ts`、従来どおり)。警告は、Paseo が MCP サーバーを渡さないセッションにだけ出す。 + - `source` の無いサーバーは、プロジェクトが同じ名前を宣言しているとき、または設定にエラーがあるときに、信頼の確認の対象になって止まる。プロトコルの MCP サーバーに `scope`(3.17.1 から、`user` か `workspace`)が加わり、`source.kind` に写される。Desktop はユーザー設定の MCP に `user` を付ける。Paseo が渡すサーバーに、3.17.1 以降の Server でだけ `scope: "user"` を付ける。それより古い Server は、strict なスキーマでこの項目を拒む。 +- **ZCode Sites(3.17.2、`zcode-site@zcode-plugins-official` 0.4.2、既定で有効)**:統合 CLI には含まれず、Desktop が共有の `~/.zcode` のキャッシュに置くと見える。モデルが使うのは `site-deploy` スキルと `/site-*` コマンドで、Bash から `node scripts/zcode-site.mjs` を実行する。認証は Agent ごとのローカルの経路が Server に身元のヘッダーを求める仕組みで、stdio Server でも組み立てられる(`services/src/node.ts` の `createLocalServices`)。Desktop 専用なのはパネルだけで、そのツールは `_meta.ui.visibility: ["app"]` によりモデルから外れる。動く見込みがあるので隠していない。実際のデプロイは試していない([todo](todo.md))。 +- **Plan モードの権限(3.17.2)**:Plan は基本のモードを厳しくするだけになった。破壊的でない MCP ツールも Plan では確認を求め、guarded の危険コマンドの確認は Plan が ON でも働く。サブエージェントは親のモード・Plan・権限を引き継ぎ、確認は親の `pendingInteractions` に出る。新しい対話の種類や選択肢は無い。build と Plan の組み合わせでは確認が増える。 +- **カスタムコマンドのスクリプト**:`!` のブロックは通常の Bash 呼び出しに書き換えられ、通常の確認を通る。 +- **利用上限で止まったワークフローの再開**:run は `stopped(provider)` のまま残り、リセット時刻の後に自動で再開する。ZCode 自身が、止まった run はセッションの回収を妨げないとしており、回収された後は次に開いたときに再開する(`bootstrap/src/app/dynamic-workflow-quota-resume.ts`)。ADR 25 の拒否の条件は変えない。 +- **バックグラウンドの作業**:`backgroundWorks` の `resultPending` は届けた後も消えない(変更なし)。ADR 25 のとおりである。 +- **ガイダンス**:待っているガイダンスは一つの区切りでまとめて読まれ、`toolDisallowlist` も合わせて適用される。各ガイダンスの `userInput` 行と `sourceCommandId` は従来どおりなので、受付と ADR 22 の扱いは変わらない。 +- **アカウントと利用量**:`oauth`、`setting`(CAS を含む)、`provider-settings`、`usage-stats.getEntitlementSnapshot` のうち、プラグインが使う範囲に変更は無い。`provider-settings` のビューに `logo` が加わった。組み込みのプロバイダー設定は revision 33 から 43 になり、Kimi・MiniMax M3.1 Flash などのテンプレートが加わった。3.16.3 の「ログインのリンクをコピーできる」は Desktop の画面の変更で、Account タブはすでにリンクを表示している。「壊れた設定ファイルを上書きしない」は `~/.zcode/cli/config.json` が対象で、`setting.json` の扱いは変わっていない。 +- **V4 と RPC**:V4 の追加はすべて任意の項目(`sendText.genUiContext`、`inputOrigin`、`compact.modelSelection`、`workspaceMcpAdmission`、キューの `automationId`、`originMeta.subagentResult`)と問い合わせのメソッドである。RPC に購読の失敗を伝える `EventError`(205)が加わった。stdio の hello / hello-ack は変わらず、起動時の移行は小さい。 +- **その他**:Desktop に登録されていないワークスペースは一つの共有の Agent に送られるが、プラグインはセッションごとに Server を起動するので影響しない。Computer Use の複数カーソルは Helper の中の変更で、`ZCODE_CUA_PRODUCT_HELPER` と `mcp__node_repl__js` は変わらない。Node なしで MCP を起動する仕組みは Electron で動く Agent だけのもので、プラグインは通常の Node を使う。 + +## ビルドと vendored ソース + +- 同期は 126 ファイル(追加 3、削除 1、変更 28)。`gen-ui/contract.ts`・`gen-ui/tweakProtocol.ts`・`local-ttft/contract.ts` が加わり、`localTtft.ts` が無くなった。`scripts/sync-zcode-source.mjs` は不要になったファイルで失敗していたので、`--write` のときは削除するようにした。型エラーは無かった。 +- パッチの対象ファイルは 3.16.2 と同じ(blob `0a9b571`)で、無修正で当たる。ヘッダーの対象コミットを書き換えたので、SHA-256 は `6f670f8edf863e020a9bc9a3cfd0550f172b9cb539141a42c10dbd9a0ade9985` になった。 +- `scripts/build-zcode.mjs`、`scripts/builtin-provider-config.mjs`、アーカイブの構成、Node.js 24.14.0 以上と pnpm 10.33.2 の要件は変わっていない。 + +## 検証(macOS arm64、2026-11-09) + +- **自動試験(Node.js 26.9.0)**:`npm run typecheck`、`npm test`(24 ファイル、238 tests)、`npm run build`、`npm run format:check`、`npm run check:zcode-source`(126 ファイル)、`npm run check:zcode-patches`(`v3.17.2` の別の checkout)が成功した。追加したテストのうち、ブリッジの版のテストは修正前に失敗し、MCP の警告のテストは条件を外しても常に出しても失敗することを確かめた。 +- **上流**:`git clone --shared` で作った別の clone を Paseo v0.15.3(`d91ae138`)にし、`NODE_PATH` を外して `npm run test:upstream` を実行し、全項目が成功した。 +- **ローカルビルド**:別の作業ディレクトリに `v3.17.2` を取得し、パッチを当て、Node.js 24.21.0、pnpm 10.33.2、`ZCODE_ENV=production` で公式手順どおりにビルドした。公式アーカイブ `68721ac9eda21d137e7c6b50db99adffa36c83ef9e9169045775d7ea848f0af6`。`package-zcode-runtime.mjs` で `3.17.2-paseo.0`(`8f18ab6b13abf99e7d167d12b912a8e2d0f97f5b046c6ebe6b1e6a28fa9ad092`、87,228,975 bytes)を作った。この成果物は公開しない。Server 3.17.2、Agent 0.17.1。 +- **`test:stdio-runtime`**:このローカルビルド(override)で全項目が成功した。加えた確認は三つある。モデル要求の `X-ZCode-App-Version` がランタイムの版であること(修正前は `0.17.1` で失敗)。ローカルのモデルが `sensitive` で止めた応答が、再試行されずに `MODEL_CONTENT_FILTERED` で届くこと(3.17.1 以降)。プロジェクトが同じ名前を宣言していても、Paseo の MCP サーバーのツールがモデルに届くこと(`scope` を外すと 3.17.2 で失敗)。新しいコードで、固定中の 3.16.2-paseo.1(一時 `XDG_DATA_HOME` に導入)も全項目が成功した。 +- **`test:native-restore`**:3.17.2 でも失敗した(期待 `edit` + Plan ON に対し、`yolo` + Plan OFF)。保証範囲外の上流の不具合は残る(ADR 14)。 +- **`test:e2e`**:`GLM_API_KEY` と隔離したデータで、このローカルビルドに対して実行した。モデルと推論レベル、独立した Plan と承認・拒否、Plan とモデルの復元、ガイダンス、添付キュー、単一完了、停止と再開が passed だった。 +- **`test:usage-runtime`**:実行していない。この端末の Desktop は 3.16.3 で、3.17.2 の Server を実データで起動すると、共有データを Desktop より先に移行するおそれがある。 + +## 公開と固定 + +| 項目 | 実測値 | +| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| リリース | [`zcode-runtime-v3.17.2-paseo.1`](https://github.com/supermomonga/paseo-plugin-zcode-provider/releases/tag/zcode-runtime-v3.17.2-paseo.1)(PR #95 の `f0dd526`)、`zcode-runtime-3.17.2-paseo.1.tar.gz`、83,086,942 bytes | +| 成果物 SHA-256 | `24e3a9b03260d7b800958ccba4cfdc8233eee67936170636da79d440245bd15d`。`gh attestation verify` で、タグ `zcode-runtime-v3.17.2-paseo.1` のリリース用ワークフローによる署名(ソース `f0dd526`)を確認 | +| `BUILD-INFO.json` | `release: 3.17.2-paseo.1`、ソース `a9fe401`(3.17.2)、`modified: true`、パッチ `6f670f8…`。同梱のパッチはリポジトリのものとバイト単位で一致。`agent/provider/zcode-builtin.json` は本番用ファイルと一致 | +| 公式ビルドの成果物 | `7d70a382c7fa030a48ddecff08670d8f0b9995f6f9ef878d06bf52c976375570`(Node.js 24.21.0、[run 42576870272](https://github.com/supermomonga/paseo-plugin-zcode-provider/actions/runs/42576870272)) | + +- **PR #95 の CI**:[run 42575658183](https://github.com/supermomonga/paseo-plugin-zcode-provider/actions/runs/42575658183) で、test(`test:upstream` を含む)、固定前の 3.16.2-paseo.1 での 5 プラットフォームの契約試験、実モデル E2E が成功した。リリース用ワークフローは PR 上でパッチ済み 3.17.2 を作り([run 42575657986](https://github.com/supermomonga/paseo-plugin-zcode-provider/actions/runs/42575657986)、未公開)、5 プラットフォームで、追加した三つの確認と「隠れる」側の ADR 19 を含む契約試験が通った。 +- **タグのリリース**:run 42576870272 で、ビルド、5 プラットフォームの検証、署名、公開(latest ではない)が成功した。 +- **導入**:`pins.ts` を更新した状態で、一時 `XDG_DATA_HOME` の `npm run setup:managed-runtime` が公開版を取得・検証して導入した。その管理下ランタイムで `test:stdio-runtime` が全項目を通った(`source: managed`、Server 3.17.2、Agent 0.17.1)。 +- **固定後の CI**:[run 42578515911](https://github.com/supermomonga/paseo-plugin-zcode-provider/actions/runs/42578515911) で、5 プラットフォームの管理下ランタイム契約試験が公開版(`source: managed`、Server 3.17.2)で、追加した三つの確認と「隠れる」側を含めて通った。実モデル E2E も公開版(`zcode-3.17.2-24e3a9b03260`)で passed だった。同じコミットの PR 上のリリース用ワークフロー([run 42578515834](https://github.com/supermomonga/paseo-plugin-zcode-provider/actions/runs/42578515834))は、ビルドの `pnpm install` が `ERR_PNPM_ENOENT`(`node_modules/tsup/node_modules/esbuild` への改名)で 2 回失敗し、3 回目で通った。ランナーのイメージは成功した回と同じで、同じソースのビルドはそれまでに 2 回成功している。上流の `node-linker=hoisted` での pnpm の競合とみられる。 + +未検証:Account タブでの実際のサインインと Coding Plan の利用量(3.17.2)、ZCode Sites のデプロイ、Desktop で付けた MCP の信頼がプラグインのセッションに効くこと、Desktop 3.16.3 と管理下ランタイム 3.17.2 が共有データを使う場合。既存の利用者は、固定値が変わるので Runtime タブから導入し直す。 + # Paseo 0.15.3 への追従(2026-11-09) Issue #69、#75〜#82、#85、#87〜#89 の対応。Paseo 0.13.0-beta.1 から 0.15.3 までの変更履歴を読んだ。あわせて v0.12.0 と v0.15.3(`d91ae138cb931447635e94296023414a58bedcc5`)の差分を確認した。対象は `packages/plugin`、`plugin-provider.ts`、`agent-manager.ts`、アイドル時の解放、プラグインのコンパイラと準備処理である。判断は [ADR 25](adr/0025-paseo-0-15を最低要件にしzcodeの作業が残る間はアイドル時のランタイム解放を拒否する.md) に記録した。 diff --git a/patches/zcode/0001-hide-suppressed-official-plugins.patch b/patches/zcode/0001-hide-suppressed-official-plugins.patch index cf336b9..e06a5f8 100644 --- a/patches/zcode/0001-hide-suppressed-official-plugins.patch +++ b/patches/zcode/0001-hide-suppressed-official-plugins.patch @@ -9,7 +9,7 @@ the same way it skips suppressedBuiltins, without writing any configuration. Target: NodePluginAdapter.discoverPluginsSync in apps/zcode-cli/packages/adapters/src/plugins/index.ts, which every plugin -discovery path uses (ZCode 3c5b227649371507ddc4eb46ac5133afe6db1cab). +discovery path uses (ZCode a9fe401eede6e6e5e01be9048679c206fe6f02d9). Remove when: ZCode offers an official per-process way to hide official plugins, for example when ZCODE_CUA_PRODUCT_HELPER=0 hides cached diff --git a/scripts/check-stdio-runtime.mjs b/scripts/check-stdio-runtime.mjs index 8370af5..5935ef4 100644 --- a/scripts/check-stdio-runtime.mjs +++ b/scripts/check-stdio-runtime.mjs @@ -52,6 +52,29 @@ let connection, modelCalls = 0; const responses = new Set(); const modelRequests = []; +// A stdio MCP server with one tool, as Paseo would pass to a session. +const MCP_FIXTURE = `import { createInterface } from "node:readline"; +const send = (message) => + process.stdout.write(JSON.stringify({ jsonrpc: "2.0", ...message }) + "\\n"); +for await (const line of createInterface({ input: process.stdin })) { + const { id, method, params } = JSON.parse(line); + if (id === undefined) continue; + if (method === "initialize") + send({ id, result: { + protocolVersion: params.protocolVersion, + capabilities: { tools: {} }, + serverInfo: { name: "paseofixture", version: "1.0.0" }, + } }); + else if (method === "tools/list") + send({ id, result: { tools: [{ + name: "probe", + description: "Paseo fixture tool", + inputSchema: { type: "object", properties: {} }, + }] } }); + else if (method === "ping") send({ id, result: {} }); + else send({ id, error: { code: -32601, message: "Method not found" } }); +} +`; // GLM's weekly or monthly quota response (business code 1310). const QUOTA_MESSAGE = "您已达到每周/每月使用上限,您的限额将在 2026-11-07 16:34:13 重置。"; @@ -63,6 +86,7 @@ const modelServer = createServer(async (req, res) => { modelRequests.push({ tools: (input.tools ?? []).map((t) => t.function.name), messages: JSON.stringify(input.messages ?? []), + appVersion: req.headers["x-zcode-app-version"], }); if (scenario === "quota") { res.writeHead(429, { "content-type": "application/json" }); @@ -141,6 +165,12 @@ const modelServer = createServer(async (req, res) => { choices: [{ index: 0, delta, finish_reason }], usage: { prompt_tokens: 10, completion_tokens: 4, total_tokens: 14 }, }); + if (scenario === "filtered") { + // GLM ends a reply that its output safety review blocked with "sensitive". + res.write(`data: ${JSON.stringify(chunk({}, "sensitive"))}\n\n`); + res.end("data: [DONE]\n\n"); + return; + } res.write(`data: ${JSON.stringify(chunk(delta, null))}\n\n`); res.write( `data: ${JSON.stringify(chunk({}, useTool ? "tool_calls" : "stop"))}\n\n`, @@ -382,6 +412,7 @@ try { assert.ok(catalog.models.length); // Guarded ("Autonomous mode") exists from ZCode 3.15.1. const guarded = gte(identity.appVersion, "3.15.1"); + const contentFilter = gte(identity.appVersion, "3.17.1"); assert.equal( catalog.modes.some((m) => m.id === "guarded"), guarded, @@ -414,6 +445,11 @@ try { // that the fixture caches are discovered at all. const turnRequest = modelRequests.find((r) => r.tools.includes("Bash")); assert.ok(turnRequest, "The Bash turn must reach the model"); + assert.equal( + turnRequest.appVersion, + identity.appVersion, + "Model requests must report the ZCode app version, as Desktop's do", + ); assert.ok( !turnRequest.tools.includes("mcp__node_repl__js"), "The shared Browser and Computer Use tool must be hidden from every turn", @@ -595,6 +631,18 @@ try { "rate_limited", ); assert.ok(!JSON.stringify(quota).includes(QUOTA_MESSAGE)); + if (contentFilter) { + // Since 3.17.1 ZCode fails a blocked reply at once instead of retrying it. + await prompt("filtered"); + const filtered = await terminal(); + assert.equal(filtered.state, "failed"); + assert.equal(filtered.error.code, "MODEL_CONTENT_FILTERED"); + assert.equal( + JSON.parse(filtered.error.diagnostic).failure.reason, + "content_filter", + ); + assert.equal(modelCalls, 1, "ZCode must not retry a blocked reply"); + } await prompt("bash"); assert.equal((await terminal()).state, "completed"); assert.equal(await canStopRuntime(), true); @@ -666,6 +714,40 @@ try { await open(saved, { mode: "yolo", settings: { plan_mode: false } }); await prompt("bash", "Resume working."); assert.equal((await terminal()).state, "completed"); + // Paseo's MCP servers reach the model even when the project declares one of + // the same name, which ZCode 3.17 keeps until the project is trusted. + await send({ type: "session.close", requestId: "close-mcp" }); + await wait((e) => e.type === "session.closed"); + await connection.close(); + await connect(); + const mcpWorkspace = join(directory, "mcp-workspace"); + await mkdir(join(mcpWorkspace, ".agents"), { recursive: true }); + await writeFile( + join(mcpWorkspace, ".agents/mcp.json"), + JSON.stringify({ + mcpServers: { paseofixture: { command: process.execPath, args: [] } }, + }), + ); + await writeFile(join(directory, "mcp-fixture.mjs"), MCP_FIXTURE); + await open(undefined, { + cwd: mcpWorkspace, + mode: "yolo", + mcpServers: { + paseofixture: { + type: "stdio", + command: process.execPath, + args: [join(directory, "mcp-fixture.mjs")], + }, + }, + }); + await prompt("bash"); + assert.equal((await terminal()).state, "completed"); + // Title generation for the new session also reaches the model, without tools. + const mcpTurn = modelRequests.findLast((r) => r.tools.includes("Bash")); + assert.ok( + mcpTurn.tools.includes("mcp__paseofixture__probe"), + `Paseo's MCP server must reach the model: ${mcpTurn.tools}`, + ); console.log( JSON.stringify( { @@ -679,6 +761,7 @@ try { "catalog", "draft", "Bash", + "app version in model requests", "single ACK/completion", "cold resume with Paseo mode and Plan settings", "history replay", @@ -688,6 +771,7 @@ try { "targeted stop", "restart after stop", "provider quota failure", + ...(contentFilter ? ["content-filtered reply"] : []), "restart after failure", "idle runtime kept for background Bash", "slash command completion", @@ -695,6 +779,7 @@ try { "EOF cleanup", "Agent cleanup after Server SIGKILL", "resume after Server SIGKILL", + "Paseo's MCP server beside a project declaration", patched ? "unsupported plugins and tool hidden (patched runtime)" : "unsupported tool hidden, plugins visible (unpatched runtime)", diff --git a/scripts/sync-zcode-source.mjs b/scripts/sync-zcode-source.mjs index 5706cbd..49c5bba 100644 --- a/scripts/sync-zcode-source.mjs +++ b/scripts/sync-zcode-source.mjs @@ -1,10 +1,10 @@ import { execFileSync } from "node:child_process"; import { createHash } from "node:crypto"; -import { mkdir, readFile, readdir, writeFile } from "node:fs/promises"; +import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises"; import { dirname, join, posix, resolve } from "node:path"; import ts from "typescript"; -export const ZCODE_SOURCE_COMMIT = "3c5b227649371507ddc4eb46ac5133afe6db1cab"; +export const ZCODE_SOURCE_COMMIT = "a9fe401eede6e6e5e01be9048679c206fe6f02d9"; const checkout = resolve( process.argv.slice(2).find((arg) => arg !== "--write") ?? `${process.env.HOME}/ghq/github.com/zai-org/ZCode`, @@ -142,14 +142,20 @@ const actual = await readdir(destination, { recursive: true, withFileTypes: true, }); +const removed = []; for (const entry of actual) if (entry.isFile()) { const path = posix.join( entry.parentPath.slice(destination.length + 1).replaceAll("\\", "/"), entry.name, ); - if (!files.has(path)) throw new Error(`Unexpected vendored file: ${path}`); + if (files.has(path)) continue; + // A new baseline can drop a dependency; only --write deletes it. + if (!write) throw new Error(`Unexpected vendored file: ${path}`); + await rm(join(destination, path)); + removed.push(path); } +for (const path of removed) console.log(`Removed ${path}`); for (const [path, { content }] of files) { const output = join(destination, path); if (write) { diff --git a/server/diagnostics.ts b/server/diagnostics.ts index 5d46aa9..85c2ee5 100644 --- a/server/diagnostics.ts +++ b/server/diagnostics.ts @@ -17,8 +17,11 @@ const stages = [ "session", "turn", ] as const; -// ZCode's ModelFailureReason (apps/zcode-cli/packages/contracts/src/model/index.ts at 3c5b227). +// ZCode's ModelFailureReason (apps/zcode-cli/packages/contracts/src/model/index.ts at +// a9fe401), plus content_filter, which 3.17 sets outside that list for a reply +// the provider's content filter blocked (core/src/runtime/helpers/model-errors.ts). export const modelFailureReasons = [ + "content_filter", "rate_limited", "provider_overloaded", "server_error", diff --git a/server/discovery/manifest.ts b/server/discovery/manifest.ts index 9b06483..a095d05 100644 --- a/server/discovery/manifest.ts +++ b/server/discovery/manifest.ts @@ -1,7 +1,7 @@ import { gte, parse } from "semver"; import type { RuntimeIdentity } from "./types.js"; -export const ZCODE_SOURCE_COMMIT = "3c5b227649371507ddc4eb46ac5133afe6db1cab"; +export const ZCODE_SOURCE_COMMIT = "a9fe401eede6e6e5e01be9048679c206fe6f02d9"; export const MINIMUM_ZCODE_VERSION = { app: "3.14.0", cli: "0.16.9" } as const; export const MINIMUM_NODE_VERSION = "24.14.0"; @@ -33,4 +33,4 @@ export function assessCompatibility(identity: RuntimeIdentity): { } // Last reviewed public changelog release; source versions are not releases. -export const LAST_REVIEWED_ZCODE_RELEASE = "3.16.2"; +export const LAST_REVIEWED_ZCODE_RELEASE = "3.17.2"; diff --git a/server/errors.ts b/server/errors.ts index fd94b5b..4bf18f0 100644 --- a/server/errors.ts +++ b/server/errors.ts @@ -20,6 +20,7 @@ export type ZCodeErrorCode = | "MODEL_CONTEXT_EXCEEDED" | "MODEL_NETWORK_ERROR" | "MODEL_PROVIDER_ERROR" + | "MODEL_CONTENT_FILTERED" | "MODEL_REQUEST_FAILED" | "AUTH_REQUIRED" | "UNSUPPORTED_CONTENT" diff --git a/server/host-bridge.test.ts b/server/host-bridge.test.ts index c1866b7..980e45b 100644 --- a/server/host-bridge.test.ts +++ b/server/host-bridge.test.ts @@ -77,6 +77,23 @@ it("starts the Server without unsupported capabilities, whatever the caller sets await bridge.close(); } }); +it("gives the Server the runtime's app version, as Desktop does", async () => { + const bridge = ZCodeHostBridge.start(runtime, logger, { + ...process.env, + ZCODE_APP_VERSION: "0.0.1", + }); + try { + expect( + await bridge.request( + "readEnvironment", + ["ZCODE_APP_VERSION"], + z.unknown(), + ), + ).toEqual({ ZCODE_APP_VERSION: "3.14.0" }); + } finally { + await bridge.close(); + } +}); it.each(["bad-hello", "bad-v4"])( "rejects %s and collects the process", async (scenario) => { diff --git a/server/host/bridge.ts b/server/host/bridge.ts index 2b58174..b8de68d 100644 --- a/server/host/bridge.ts +++ b/server/host/bridge.ts @@ -144,6 +144,9 @@ export class ZCodeHostBridge implements HostBridge { env: { ...runtimeEnvironment(environment), ...UNSUPPORTED_CAPABILITY_ENVIRONMENT, + // The Agent inherits this and reports it in model request headers, or + // its CLI version without it. Desktop and the remote Core set it too. + ZCODE_APP_VERSION: runtime.identity.appVersion, ZCODE_SERVICE_AUTHORITY_MODE: "standalone-server", ZCODE_AGENT_SERVER_COMMAND: runtime.paths.executable, ZCODE_AGENT_SERVER_ARGS_JSON: JSON.stringify([ diff --git a/server/mapping.test.ts b/server/mapping.test.ts index 40133b1..a97df2e 100644 --- a/server/mapping.test.ts +++ b/server/mapping.test.ts @@ -178,19 +178,22 @@ describe("ZCode prompt and MCP mapping", () => { it("losslessly maps supported MCP transports and rejects unsupported fields", () => { expect( - mapMcpServers({ - local: { - type: "stdio", - command: "/usr/bin/env", - args: ["node"], - env: { A: "B" }, - }, - remote: { - type: "http", - url: "https://example.test/mcp", - headers: { Authorization: "placeholder" }, + mapMcpServers( + { + local: { + type: "stdio", + command: "/usr/bin/env", + args: ["node"], + env: { A: "B" }, + }, + remote: { + type: "http", + url: "https://example.test/mcp", + headers: { Authorization: "placeholder" }, + }, }, - }), + "3.16.2", + ), ).toEqual([ { name: "local", @@ -206,15 +209,32 @@ describe("ZCode prompt and MCP mapping", () => { }, ]); expect(() => - mapMcpServers({ - unsupported: { - type: "stdio", - command: "/bin/echo", - alwaysLoad: true, + mapMcpServers( + { + unsupported: { + type: "stdio", + command: "/bin/echo", + alwaysLoad: true, + }, }, - }), + "3.16.2", + ), ).toThrow(/alwaysLoad/u); }); + + it("marks Paseo's MCP servers as user servers where ZCode accepts a scope", () => { + const servers = { + local: { type: "stdio" as const, command: "/usr/bin/env" }, + remote: { type: "sse" as const, url: "https://example.test/mcp" }, + }; + const scopes = (appVersion: string | undefined) => + mapMcpServers(servers, appVersion).map((server) => server.scope); + expect(scopes("3.17.2")).toEqual(["user", "user"]); + expect(scopes("3.17.1")).toEqual(["user", "user"]); + // Older Servers reject the field, and an unknown version is not assumed new. + expect(scopes("3.16.2")).toEqual([undefined, undefined]); + expect(scopes(undefined)).toEqual([undefined, undefined]); + }); }); it("rejects variant IDs instead of converting them to reasoning levels", () => { diff --git a/server/mapping.ts b/server/mapping.ts index cde9fff..b314c4a 100644 --- a/server/mapping.ts +++ b/server/mapping.ts @@ -38,13 +38,22 @@ export const ZCODE_MODES: ProviderMode[] = [ // ZCode 3.15.1 added guarded ("Autonomous mode"); older Servers reject it. const GUARDED_MINIMUM_APP_VERSION = "3.15.1"; -// The modes the runtime with this Server version supports. -export function zcodeModes(appVersion: string | undefined): ProviderMode[] { - const guarded = +// ZCode 3.17.1 added the MCP server `scope`; older Servers reject it. +const MCP_SCOPE_MINIMUM_APP_VERSION = "3.17.1"; + +function atLeast(appVersion: string | undefined, minimum: string): boolean { + return ( appVersion !== undefined && valid(appVersion) !== null && - gte(appVersion, GUARDED_MINIMUM_APP_VERSION); - return guarded ? ZCODE_MODES : ZCODE_MODES.filter((m) => m.id !== "guarded"); + gte(appVersion, minimum) + ); +} + +// The modes the runtime with this Server version supports. +export function zcodeModes(appVersion: string | undefined): ProviderMode[] { + return atLeast(appVersion, GUARDED_MINIMUM_APP_VERSION) + ? ZCODE_MODES + : ZCODE_MODES.filter((m) => m.id !== "guarded"); } export function requireConfigurableMode( @@ -151,7 +160,14 @@ export function catalogModels( export function mapMcpServers( servers: Record | undefined, + appVersion: string | undefined, ): Array> { + // Paseo's servers are not project declarations. Without a scope, ZCode + // treats them as such when the project declares the same name or its + // configuration is unreadable, and blocks them until the project is trusted. + const scope = atLeast(appVersion, MCP_SCOPE_MINIMUM_APP_VERSION) + ? { scope: "user" } + : {}; return Object.entries(servers ?? {}).map(([name, server]) => { if (name.trim() === "") { throw new AdapterError( @@ -174,6 +190,7 @@ export function mapMcpServers( } return { name, + ...scope, command: server.command, args: server.args ?? [], env: Object.entries(server.env ?? {}).map(([key, value]) => ({ @@ -189,7 +206,7 @@ export function mapMcpServers( }), ); if (server.type === "http" || server.type === "sse") { - return { type: server.type, name, url: server.url, headers }; + return { type: server.type, name, ...scope, url: server.url, headers }; } throw new AdapterError( "INVALID_CONFIGURATION", diff --git a/server/provider.ts b/server/provider.ts index 8a25ff8..65f95e7 100644 --- a/server/provider.ts +++ b/server/provider.ts @@ -563,7 +563,10 @@ export class ZCodeConnection implements ProviderConnection { } : {}), }), - mcpServers: mapMcpServers(config.mcpServers), + mcpServers: mapMcpServers( + config.mcpServers, + host.diagnostic.appVersion, + ), }, SessionSnapshotSchema, 60000, @@ -578,6 +581,8 @@ export class ZCodeConnection implements ProviderConnection { modelCatalog: selection.models, timeline: this.timeline, onClose() {}, + // A non-empty list replaces ZCode's MCP configuration files. + projectMcpServers: Object.keys(config.mcpServers ?? {}).length === 0, }); if ( initialModel && diff --git a/server/runtime/pins.ts b/server/runtime/pins.ts index a518deb..8620719 100644 --- a/server/runtime/pins.ts +++ b/server/runtime/pins.ts @@ -55,12 +55,12 @@ export const MANAGED_NODE_ARCHIVES: Readonly< // Published by .github/workflows/zcode-runtime-release.yml from the pinned // source with patches/zcode applied (ADR 19). The same archive serves every // managed platform. -export const MANAGED_ZCODE_VERSION = "3.16.2"; +export const MANAGED_ZCODE_VERSION = "3.17.2"; const MANAGED_ZCODE_RELEASE = `${MANAGED_ZCODE_VERSION}-paseo.1`; export const MANAGED_ZCODE_ARCHIVE: PinnedArchive = { url: `https://github.com/supermomonga/paseo-plugin-zcode-provider/releases/download/zcode-runtime-v${MANAGED_ZCODE_RELEASE}/zcode-runtime-${MANAGED_ZCODE_RELEASE}.tar.gz`, - sha256: "01f3ee802f4c0b24c4023e366485120416a6acc92ec899a9edf7f2fc76eaa17d", - size: 82_516_181, + sha256: "24e3a9b03260d7b800958ccba4cfdc8233eee67936170636da79d440245bd15d", + size: 83_086_942, }; export function managedPlatform( diff --git a/server/session.ts b/server/session.ts index fab8e26..493f48f 100644 --- a/server/session.ts +++ b/server/session.ts @@ -99,6 +99,8 @@ export class ZCodeSession { private modelCatalog: readonly ModelOption[], private readonly timeline: () => TimelinePreferences, private readonly onClose: () => void, + /** False when Paseo's MCP servers replace the project's configuration. */ + private readonly projectMcpServers: boolean, ) { assertSnapshotWorkspace(snapshot, workspace); this.id = snapshot.session.sessionId; @@ -114,6 +116,7 @@ export class ZCodeSession { modelCatalog: readonly ModelOption[]; timeline: () => TimelinePreferences; onClose: () => void; + projectMcpServers: boolean; }): Promise { const session = new ZCodeSession( options.bridge, @@ -123,6 +126,7 @@ export class ZCodeSession { options.modelCatalog, options.timeline, options.onClose, + options.projectMcpServers, ); session.unlistenFailure = options.bridge.onFailure((error) => session.runtimeFailed(error), @@ -316,19 +320,18 @@ export class ZCodeSession { this.state.pendingInteractions.some( (i) => i.kind === "workspaceHookReview", ) - ) { - const item: ProviderTimelineItem = { - id: "zcode:hook-trust", - type: "notification", - level: "warning", - message: - "ZCode workspace hooks require trust review. Review them with the official zcode hooks trust command.", - }; - if (!this.presented.has(item.id)) { - this.presented.set(item.id, { item }); - this.runEvent({ type: "timeline", item }); - } - } + ) + this.warnOnce( + "zcode:hook-trust", + "ZCode workspace hooks require trust review. Review them with the official zcode hooks trust command.", + ); + // ZCode 3.17 counts the project's declarations even when Paseo's servers + // replace them, so the warning only applies to the project's configuration. + if (this.projectMcpServers && this.state.workspaceMcpAdmission) + this.warnOnce( + "zcode:mcp-trust", + "ZCode has not started this project's MCP servers because they are not trusted. Trust them in ZCode Desktop under Settings → MCP Servers, then start a new session.", + ); this.changed(); const run = this.active; if ( @@ -371,6 +374,17 @@ export class ZCodeSession { ); } } + private warnOnce(id: string, message: string): void { + if (this.presented.has(id)) return; + const item: ProviderTimelineItem = { + id, + type: "notification", + level: "warning", + message, + }; + this.presented.set(id, { item }); + this.runEvent({ type: "timeline", item }); + } private maybeComplete(): void { const run = this.active; if ( diff --git a/server/turn-failure.test.ts b/server/turn-failure.test.ts index 273ef5a..d98eaf6 100644 --- a/server/turn-failure.test.ts +++ b/server/turn-failure.test.ts @@ -29,6 +29,7 @@ test.each([ ["tls_error", "MODEL_NETWORK_ERROR"], ["server_error", "MODEL_PROVIDER_ERROR"], ["provider_overloaded", "MODEL_PROVIDER_ERROR"], + ["content_filter", "MODEL_CONTENT_FILTERED"], ["invalid_request", "MODEL_REQUEST_FAILED"], ["unknown", "MODEL_REQUEST_FAILED"], ["secret-reason", "MODEL_REQUEST_FAILED"], diff --git a/server/turn-failure.ts b/server/turn-failure.ts index df0b3d2..fd6a269 100644 --- a/server/turn-failure.ts +++ b/server/turn-failure.ts @@ -29,6 +29,7 @@ const reasonCodes: Partial> = { tls_error: "MODEL_NETWORK_ERROR", server_error: "MODEL_PROVIDER_ERROR", provider_overloaded: "MODEL_PROVIDER_ERROR", + content_filter: "MODEL_CONTENT_FILTERED", }; const messages: Record< @@ -56,6 +57,10 @@ const messages: Record< "The model provider returned a server error or is overloaded", "Try again later.", ], + MODEL_CONTENT_FILTERED: [ + "The model provider's content filter blocked the reply", + "Rephrase the request or switch models.", + ], MODEL_REQUEST_FAILED: ["The model provider rejected the request"], }; diff --git a/server/vendor/zcode/NOTICE.md b/server/vendor/zcode/NOTICE.md index 9d608c5..5245cd7 100644 --- a/server/vendor/zcode/NOTICE.md +++ b/server/vendor/zcode/NOTICE.md @@ -49,7 +49,7 @@ AI 生成的代码、命令、解释、文件和建议可能存在错误、遗 | 手机远程控制 | 启用远程控制并完成配对后,桌面与手机网页经外部 relay 交换会话内容、输入、任务状态、权限请求与附件预览等协议消息;relay 负责鉴权、配对、心跳与消息透传,不运行任务。配对与连接会发送设备、窗口与会话标识。relay 地址随发行配置确定,可由 `ZCODE_WEB_REMOTE_CONTROL_RELAY_WS_URL` 覆盖。 | | Bots 第三方聊天接入 | 配置 Bot 后,所选第三方聊天平台(如 Telegram、飞书/Lark)的消息可驱动任务;Bot 按回复模式把助手回复、工具调用、文件变更摘要及权限请求发送到该平台,平台方可获得这些内容。Bot 凭据保存在本地凭据服务,配置文件只保存引用。 | | 营销触达与奖励中心 | 登录后可从业务服务获取营销 Banner/弹窗配置及资源包并展示;点击、关闭等操作会上报确认/取消事件,领取类操作会调用套餐领取接口。奖励中心以内嵌网页打开,桥接接口向该页面提供主题、语言和登录状态。 | -| 安装、插件获取、远端部署与更新 | 安装、发现、认证、部署和更新会访问仓库、包服务、插件市场、CDN 或更新服务器;统一 CLI 安装脚本会从配置的分发源读取版本清单并下载发行包。桌面自动更新受发行形态和运行条件控制,启用后可在启动及周期检查时请求更新清单,携带平台、渠道、设备等信息;平台取值可区分架构,版本信息还会影响更新选择。开源构建默认不启用自动更新(构建期可选能力);启用时,开发构建与打包版都接受 `ZCODE_UPDATE_FEED_URL` 环境变量及 `--zcode-update-feed-url` 启动参数覆盖更新源,用于诊断与应急。下载的代码可能随后被安装或执行,远端部署还可能将本地已有或下载的组件上传/复制到目标环境。下载检查、实际安装及运行组件的控制条件不同,不能统一描述成每步都先弹出确认。 | +| 安装、插件获取、远端部署与更新 | 安装、发现、认证、部署和更新会访问仓库、包服务、插件市场、CDN 或更新服务器;统一 CLI 安装脚本会从配置的分发源读取版本清单并下载发行包。桌面自动更新受发行形态和运行条件控制,启用后可在启动及周期检查时请求更新清单,携带平台、渠道、设备等信息;平台取值可区分架构,版本信息还会影响更新选择。开源构建默认不启用自动更新(构建期可选能力);启用时,仅未打包开发态接受 `ZCODE_UPDATE_FEED_URL` 环境变量及 `--zcode-update-feed-url` 启动参数覆盖更新源,用于诊断;打包应用忽略这两个入口,继续使用既有服务端 manifest 入口。下载的代码可能随后被安装或执行,远端部署还可能将本地已有或下载的组件上传/复制到目标环境。下载检查、实际安装及运行组件的控制条件不同,不能统一描述成每步都先弹出确认。 | | 工具、Hook、工作流与自动任务的交付或发布 | Shell、终端、Git、Node REPL、浏览器、插件、MCP 或工作流可以读取任务涉及的数据、向相应目标服务上传文件或生成物,并改变外部服务状态;生命周期 Hook 和已配置的定时/后台任务也可触发程序。权限规则、模式、插件配置及系统账号决定执行范围,不能保证每份外发内容都由用户逐项选择或每次外发都有独立确认。发布、发送、购买或部署完成后,本地取消或撤销不一定能恢复外部状态;权限边界见第二节。 | | 开发测试、调试与请求录制 | 显式运行相关开发工具时,可向配置的真实模型或工具服务发送测试提示、样例资料及认证头;配置为真实上游的录制代理可转发请求,不能因名称含测试/录制就认为完全离线。请求轨迹和调试文件还可能在本地保存模型内容;这些工具的触发入口与普通产品运行不同。 | | 构建、签名与维护者发布 | 显式运行安装、构建或发布脚本时,可下载依赖、原生二进制和运行时,将构建材料复制到发布共享目录、推送 Git,或交给签名工具、Apple 公证服务处理。外部签名工具及另行配置的 CI、存储和分发服务具有自己的网络行为;本仓未展开的流程不能仅凭脚本名称推定已核验。相关调用具有不同的启动入口、环境和凭据要求。CLI SEA 共享目录发布与上传会先校验第三方声明材料,校验失败会阻断该发布流程。当前 native-search 准备步骤按目标平台校验并解包仓库内置归档,本步骤不下载这些归档;Node 等其他组件有各自的下载链路。 | diff --git a/server/vendor/zcode/packages/rpc/src/channelClient.ts b/server/vendor/zcode/packages/rpc/src/channelClient.ts index 0f90f96..ea4b56a 100644 --- a/server/vendor/zcode/packages/rpc/src/channelClient.ts +++ b/server/vendor/zcode/packages/rpc/src/channelClient.ts @@ -99,6 +99,7 @@ export class ChannelClient implements IChannelClient, IDisposable { "taskId", "traceId", "retryable", + "profileId", ] as const; for (const key of passthroughKeys) { const value = response.data[key]; @@ -170,7 +171,18 @@ export class ChannelClient implements IChannelClient, IDisposable { }); this.handlers.set(id, (response) => { - emitter.fire((response as { data: any }).data); + if (response.type === ResponseType.EventFire) { + emitter.fire(response.data); + } else if (response.type === ResponseType.EventError) { + // 订阅失败必须结束其监听器,不能把错误对象写入终端等正常事件流,也不能继续保留旧请求。 + this.handlers.delete(id); + this.activeRequests.delete(emitter); + emitter.dispose(); + const error = new Error(response.data.message); + error.name = response.data.name; + if (response.data.stack) error.stack = response.data.stack.join("\n"); + console.error(`RPC event subscription failed: ${channelName}.${name}`, error); + } }); return emitter.event; @@ -208,9 +220,11 @@ export class ChannelClient implements IChannelClient, IDisposable { } private onBuffer(message: VSBuffer): void { + // 修复原因:同一 protocol 上还有反向 ChannelServer(host ↔ 远端 WebSocket 两端都是),对方发来的 + // 请求也会到这里。原来先解码消息体再判断类型,每条请求都被完整解码两次,大请求(例如数据同步的 + // 归档)白白多花一倍 CPU。修法:先读消息头,只解码属于本端的响应体。 const reader = new BufferReader(message); const header = deserialize(reader); - const body = deserialize(reader); const type = header[0] as ResponseType; switch (type) { @@ -220,11 +234,12 @@ export class ChannelClient implements IChannelClient, IDisposable { case ResponseType.PromiseSuccess: case ResponseType.PromiseError: case ResponseType.EventFire: + case ResponseType.EventError: case ResponseType.PromiseErrorObj: this.onResponse({ type, id: header[1], - data: body, + data: deserialize(reader), } as IRawResponse); return; } diff --git a/server/vendor/zcode/packages/rpc/src/channelServer.ts b/server/vendor/zcode/packages/rpc/src/channelServer.ts index 2f25fb3..47534bb 100644 --- a/server/vendor/zcode/packages/rpc/src/channelServer.ts +++ b/server/vendor/zcode/packages/rpc/src/channelServer.ts @@ -48,6 +48,7 @@ export class ChannelServer implements IChannelServer implements IChannelServer implements IChannelServer implements IChannelServer implements IChannelServer implements IChannelServer implements IChannelServer { + try { + const disposable = channel.listen( + this.ctx, + request.name, + request.arg, + )((data) => { + this.sendResponse({ + id: request.id, + data, + type: ResponseType.EventFire, + }); + }); + this.activeRequests.set(request.id, disposable); + } catch (error) { + // 已结束的终端等资源会拒绝迟到订阅;该拒绝属于本次请求,不能逃逸并退出整个 Host。 + // 独立失败帧不会被旧客户端当作业务事件,也不会建立无法释放的活动订阅。 this.sendResponse({ id: request.id, - data, - type: ResponseType.EventFire, + type: ResponseType.EventError, + data: { + name: error instanceof Error ? error.name : "Error", + message: error instanceof Error ? error.message : String(error), + ...(error instanceof Error && error.stack ? { stack: error.stack.split("\n") } : {}), + }, }); - }); - this.activeRequests.set(request.id, disposable); + } } private disposeActiveRequest(id: number): void { diff --git a/server/vendor/zcode/packages/rpc/src/channels.shared.ts b/server/vendor/zcode/packages/rpc/src/channels.shared.ts index d11f8a2..979dcc0 100644 --- a/server/vendor/zcode/packages/rpc/src/channels.shared.ts +++ b/server/vendor/zcode/packages/rpc/src/channels.shared.ts @@ -28,6 +28,7 @@ export const enum ResponseType { PromiseError = 202, PromiseErrorObj = 203, EventFire = 204, + EventError = 205, } export type IRawResponse = @@ -50,10 +51,16 @@ export type IRawResponse = taskId?: unknown; traceId?: unknown; retryable?: unknown; + profileId?: unknown; }; } | { type: ResponseType.PromiseErrorObj; id: number; data: any } - | { type: ResponseType.EventFire; id: number; data: any }; + | { type: ResponseType.EventFire; id: number; data: any } + | { + type: ResponseType.EventError; + id: number; + data: { name: string; message: string; stack?: string[] }; + }; export type IHandler = (response: IRawResponse) => void; diff --git a/server/vendor/zcode/packages/rpc/src/serialization.ts b/server/vendor/zcode/packages/rpc/src/serialization.ts index 9bc722d..84b9a8d 100644 --- a/server/vendor/zcode/packages/rpc/src/serialization.ts +++ b/server/vendor/zcode/packages/rpc/src/serialization.ts @@ -217,11 +217,17 @@ export function deserialize(reader: IReader): any { } } -function encodeRpcJsonValue(_key: string, value: unknown): unknown { - if (value instanceof Uint8Array) { +function encodeRpcJsonValue(this: unknown, key: string, value: unknown): unknown { + // Bug 根因:JSON.stringify 先调用 toJSON 再调用 replacer。Node Buffer(Uint8Array 子类,技能 / 插件 + // 归档都是 gzip 产出的 Buffer)到这里已被展开成 {type:"Buffer",data:[...]},不进 base64 标记:体积约 3.6 倍, + // 每一跳解码 1500 万个数字的数组(15MB 归档单跳十几秒,渲染进程卡住),约 28MB 以上的插件还超出远端 + // WebSocket 单条消息 100MiB 上限;接收端拿到的是普通对象,归档大小检查读不到 byteLength。 + // 修法:按 holder 上的原值判断是否为二进制。 + const original = (this as Record)[key]; + if (original instanceof Uint8Array) { return { [RPC_NESTED_UINT8_ARRAY_MARKER]: true, - [RPC_NESTED_UINT8_ARRAY_BASE64_KEY]: bytesToBase64(value), + [RPC_NESTED_UINT8_ARRAY_BASE64_KEY]: bytesToBase64(original), }; } return value; diff --git a/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts b/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts index 68be13b..c4b2e64 100644 --- a/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts +++ b/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts @@ -114,6 +114,8 @@ export const browserCommandMethodSchema = z.enum([ "markDeliverable", "markHandoff", "nameSession", + "openScope", + "releaseScope", "turnEnded", "closeSession", "cancelRequest", diff --git a/server/vendor/zcode/packages/shared/src/browser-use/commands.ts b/server/vendor/zcode/packages/shared/src/browser-use/commands.ts index 313aba1..5de1ba8 100644 --- a/server/vendor/zcode/packages/shared/src/browser-use/commands.ts +++ b/server/vendor/zcode/packages/shared/src/browser-use/commands.ts @@ -577,6 +577,8 @@ export const browserCommandSchema = z.discriminatedUnion("method", [ deliverable: z.boolean().optional(), }) .strict(), + z.object({ method: z.literal("openScope") }).strict(), + z.object({ method: z.literal("releaseScope"), closeTabs: z.boolean().optional() }).strict(), z.object({ method: z.literal("turnEnded"), turnId: z.string().min(1).optional() }).strict(), // closeTabs:连同该 session 名下的 tab 一起关(含已释放回该 session 的)。只给永不回来认领的 // session 用——dwf 子代理(docs/browser-use/2026-07-14-browser-tab-conversation-isolation-spec.md §2.3)。 diff --git a/server/vendor/zcode/packages/shared/src/browser-use/result.ts b/server/vendor/zcode/packages/shared/src/browser-use/result.ts index 7130fb7..b68d88b 100644 --- a/server/vendor/zcode/packages/shared/src/browser-use/result.ts +++ b/server/vendor/zcode/packages/shared/src/browser-use/result.ts @@ -95,6 +95,10 @@ export type BrowserRecordingJob = z.infer; export const browserCommandResultSchema = z .object({ ok: z.boolean(), + scope: z + .object({ id: z.string().min(1), state: z.enum(["open", "released", "absent", "rejected"]) }) + .strict() + .optional(), state: browserPageStateSchema.optional(), snapshot: browserSnapshotSchema.optional(), image: z diff --git a/server/vendor/zcode/packages/shared/src/gen-ui/contract.ts b/server/vendor/zcode/packages/shared/src/gen-ui/contract.ts new file mode 100644 index 0000000..c2cb80c --- /dev/null +++ b/server/vendor/zcode/packages/shared/src/gen-ui/contract.ts @@ -0,0 +1,246 @@ +import { z } from "zod"; +export * from "./tweakProtocol.js"; + +export const GEN_UI_HTML_MAX_BYTES = 5_000_000; +export const GEN_UI_STATE_MAX_BYTES = 16 * 1024; +export const GEN_UI_STATE_MAX_ENTRIES = 100; +export const GEN_UI_CONTEXT_MAX_BYTES = 64 * 1024; +export const GEN_UI_GLOBALS_EVENT = "zcode:set_globals"; +export const GEN_UI_STATE_CONTEXT_KEY = "zcode/genUiState"; +export const GEN_UI_TWEAK_CONTEXT_KEY = "zcode/genUiTweaks"; +export const GEN_UI_STYLE_CONTEXT_KEY = "zcode/genUiStyles"; +export const genUiStyleVariablesSchema = z.record( + z.string().regex(/^--gen-ui-[a-z-]+$/), + z.string(), +); +export const GEN_UI_STATE_METHOD = "zcode/gen-ui/state"; +export const GEN_UI_FOLLOW_UP_METHOD = "zcode/gen-ui/follow-up"; +export const GEN_UI_TWEAK_METHOD = "zcode/gen-ui/tweak"; +export const GEN_UI_PRESENTATION_METHOD = "zcode/gen-ui/presentation"; +export const GEN_UI_STATIC_DOMAINS = [ + "cdnjs.cloudflare.com", + "esm.sh", + "cdn.jsdelivr.net", + "unpkg.com", + "fonts.googleapis.com", + "fonts.gstatic.com", + "fonts.bunny.net", + // 自有 CDN:visualize/gen-ui 页面引用 zcode.z.ai 上的图片等静态资源(与上面公共 CDN 同走 resourceDomains, + // 会同时进 img/script/style/media/font 五类 src,可控性高于公共 CDN) + "zcode.z.ai", +] as const; + +/** This is a wire-format check. The executor owns normalization and filesystem authorization. */ +export const genUiPathSchema = z + .string() + .min(1) + .max(4096) + .refine((path) => { + if (path.includes("\0") || /[\r\n]/u.test(path)) return false; + const segments = path.split(/[\\/]/u); + return ( + /^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(path) && + !segments.includes("..") && + /^[a-z0-9]+(?:-[a-z0-9]+)*\.html$/u.test(segments.at(-1) ?? "") + ); + }, "Expected an absolute executor path to a lowercase-hyphenated HTML file"); +export const genUiReferenceSchema = z + .object({ + path: genUiPathSchema, + title: z.string().max(250).optional(), + mode: z.enum(["wide"]).optional(), + }) + .strict(); +export type GenUiReference = z.infer; + +export const genUiScopeSchema = z + .object({ + workspacePath: z.string().min(1).max(4096), + workspaceIdentity: z.string().max(4096).optional(), + sessionId: z.string().min(1).max(512), + }) + .strict(); +export type GenUiScope = z.infer; +export const genUiStateTargetSchema = genUiScopeSchema.extend({ path: genUiPathSchema }); +export type GenUiStateTarget = z.infer; + +function serializeJson(value: unknown): string { + return JSON.stringify(value, (_key, item: unknown) => { + if ( + typeof item === "undefined" || + typeof item === "function" || + typeof item === "symbol" || + typeof item === "bigint" || + (typeof item === "number" && !Number.isFinite(item)) + ) { + throw new Error("Widget state must contain JSON values only"); + } + return item; + }); +} +export const genUiWidgetStateSchema = z + .object({ + modelContent: z.unknown().default(null), + privateContent: z.unknown().default(null), + }) + .strict() + .transform((state, context) => { + try { + const serialized = serializeJson(state); + if (new TextEncoder().encode(serialized).byteLength > GEN_UI_STATE_MAX_BYTES) { + throw new Error("Widget state exceeds 16 KiB"); + } + return JSON.parse(serialized) as { modelContent: unknown; privateContent: unknown }; + } catch (error) { + context.addIssue({ + code: "custom", + message: error instanceof Error ? error.message : "Invalid widget state", + }); + return z.NEVER; + } + }); +export type GenUiWidgetState = z.infer; +export const genUiFollowUpSchema = z + .object({ + prompt: z + .string() + .trim() + .min(1) + .max(64 * 1024), + title: z.string().max(250).optional(), + }) + .strict(); + +export interface GenUiDocument { + path: string; + html: string; +} +const controlBase = { + id: z.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/), + label: z.string().min(1).max(120), + reference: z + .string() + .regex(/^[\w./:@$#-]{1,160}$/u) + .optional(), +}; +export const genUiTweakControlSchema = z.discriminatedUnion("type", [ + z + .object({ + ...controlBase, + type: z.literal("slider"), + value: z.number().finite(), + min: z.number().finite(), + max: z.number().finite(), + step: z.number().positive().optional(), + unit: z.string().max(24).optional(), + }) + .strict(), + z + .object({ + ...controlBase, + type: z.literal("color"), + value: z.string().regex(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i), + }) + .strict(), + z.object({ ...controlBase, type: z.literal("toggle"), value: z.boolean() }).strict(), + z + .object({ + ...controlBase, + type: z.literal("select"), + value: z.string().max(120), + options: z + .array( + z.union([ + z.string().min(1).max(120), + z.object({ label: z.string().min(1).max(120), value: z.string().max(120) }).strict(), + ]), + ) + .min(1) + .max(12), + }) + .strict(), +]); +export const genUiTweakSchema = z + .object({ + title: z.string().min(1).max(120), + controls: z.array(genUiTweakControlSchema).min(1).max(12), + }) + .strict() + .superRefine((input, ctx) => { + const ids = new Set(); + for (const control of input.controls) { + if ( + ids.has(control.id) || + (control.type === "slider" && + (control.min >= control.max || + control.value < control.min || + control.value > control.max)) || + (control.type === "select" && + !control.options.some( + (option) => (typeof option === "string" ? option : option.value) === control.value, + )) + ) + ctx.addIssue({ code: "custom", message: "Invalid or duplicate tweak control" }); + ids.add(control.id); + } + }); +export type GenUiTweak = z.infer; +export type GenUiTweakValues = Record; +export interface GenUiStateEntry { + path: string; + state: GenUiWidgetState; +} +export interface GenUiStateChange { + target: GenUiStateTarget; + state: GenUiWidgetState | null; +} +export function buildGenUiScopeKey(scope: GenUiScope): string { + return JSON.stringify([scope.workspaceIdentity?.trim() || scope.workspacePath, scope.sessionId]); +} +export function buildGenUiStateKey(target: GenUiStateTarget): string { + return JSON.stringify([buildGenUiScopeKey(target), target.path]); +} +export function selectGenUiModelContext(entries: readonly GenUiStateEntry[]): GenUiModelContext { + const selected: GenUiModelContext = []; + for (const entry of [...entries] + .sort((a, b) => a.path.localeCompare(b.path)) + .slice(0, GEN_UI_STATE_MAX_ENTRIES)) { + const parsed = genUiWidgetStateSchema.safeParse(entry.state); + if (!parsed.success || parsed.data.modelContent === null) continue; + const next = { path: entry.path, state: parsed.data.modelContent }; + if ( + new TextEncoder().encode(JSON.stringify([...selected, next])).length > + GEN_UI_CONTEXT_MAX_BYTES + ) + break; + selected.push(next); + } + return genUiModelContextSchema.parse(selected); +} + +export const genUiModelContextSchema = z + .array(z.object({ path: genUiPathSchema, state: z.unknown() }).strict()) + .max(GEN_UI_STATE_MAX_ENTRIES) + .transform((entries, context) => { + try { + const serialized = serializeJson(entries); + if ( + new TextEncoder().encode(serialized).byteLength > GEN_UI_CONTEXT_MAX_BYTES || + entries.some( + (entry) => + new TextEncoder().encode(serializeJson(entry.state)).byteLength > + GEN_UI_STATE_MAX_BYTES, + ) + ) { + throw new Error("Gen UI model context exceeds its size limit"); + } + return JSON.parse(serialized) as Array<{ path: string; state: unknown }>; + } catch (error) { + context.addIssue({ + code: "custom", + message: error instanceof Error ? error.message : "Invalid Gen UI model context", + }); + return z.NEVER; + } + }); +export type GenUiModelContext = z.infer; diff --git a/server/vendor/zcode/packages/shared/src/gen-ui/tweakProtocol.ts b/server/vendor/zcode/packages/shared/src/gen-ui/tweakProtocol.ts new file mode 100644 index 0000000..176bec0 --- /dev/null +++ b/server/vendor/zcode/packages/shared/src/gen-ui/tweakProtocol.ts @@ -0,0 +1,143 @@ +import { z } from "zod"; + +const value = z.union([z.string(), z.number().finite(), z.boolean()]); +const base = { + callback: z.string().min(1).max(128), + label: z.string().min(1).max(120), + reference: z.string().max(160).optional(), +}; +export const genUiAnnotationControlSchema = z.discriminatedUnion("type", [ + z + .object({ + ...base, + type: z.literal("range"), + currentValue: z.number().finite(), + min: z.number().finite(), + max: z.number().finite(), + step: z.number().positive(), + }) + .strict(), + z + .object({ + ...base, + type: z.literal("color"), + currentValue: z.string().regex(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i), + }) + .strict(), + z.object({ ...base, type: z.literal("toggle"), currentValue: z.boolean() }).strict(), + z + .object({ + ...base, + type: z.literal("select"), + currentValue: z.string().max(120), + options: z + .array(z.object({ label: z.string().min(1).max(120), value: z.string().max(120) }).strict()) + .min(1) + .max(12), + }) + .strict(), +]); +export type GenUiAnnotationControl = z.infer; +export function isGenUiAnnotationValue( + control: GenUiAnnotationControl, + candidate: unknown, +): candidate is string | number | boolean { + switch (control.type) { + case "range": + return ( + typeof candidate === "number" && + Number.isFinite(candidate) && + candidate >= control.min && + candidate <= control.max + ); + case "color": + return ( + typeof candidate === "string" && + /^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i.test(candidate) + ); + case "toggle": + return typeof candidate === "boolean"; + case "select": + return ( + typeof candidate === "string" && + control.options.some((option) => option.value === candidate) + ); + } +} +const annotationControls = z + .object({ + controlsMode: z.literal("replace"), + controls: z.array(genUiAnnotationControlSchema).min(1).max(12), + }) + .strict() + .superRefine((input, ctx) => { + const callbacks = new Set(input.controls.map((control) => control.callback)); + if ( + callbacks.size !== input.controls.length || + input.controls.some((control) => !isGenUiAnnotationValue(control, control.currentValue)) || + JSON.stringify(input).length > 16384 + ) { + ctx.addIssue({ code: "custom", message: "Invalid annotation controls" }); + } + }); +const target = z + .object({ + id: z.string().min(1).max(128), + label: z.string().min(1).max(80), + selector: z.string().max(1024), + tagName: z.string().min(1).max(120), + rect: z + .object({ + x: z.number().finite(), + y: z.number().finite(), + width: z.number().nonnegative(), + height: z.number().nonnegative(), + }) + .strict(), + }) + .strict(); +const registration = { + registrationId: z.string().min(1).max(128), + annotationControls, + targets: z.array(target).length(1), +}; +export const genUiTweakMessageSchema = z.discriminatedUnion("type", [ + z.object({ type: z.literal("register"), ...registration }).strict(), + z.object({ type: z.literal("update"), ...registration }).strict(), + z.object({ type: z.literal("dispose"), registrationId: registration.registrationId }).strict(), + z + .object({ + type: z.literal("select"), + registrationId: registration.registrationId, + targetId: target.shape.id, + }) + .strict(), + z.object({ type: z.literal("escape") }).strict(), +]); +export type GenUiTweakMessage = z.infer; +export const genUiTweakResultSchema = z + .object({ annotationControls: annotationControls.optional() }) + .strict(); +export type GenUiTweakResult = z.infer; +export const genUiTweakAnnotationSchema = z + .object({ + active: z.boolean(), + selection: z + .object({ registrationId: registration.registrationId, targetId: target.shape.id }) + .nullable(), + changes: z + .array( + z + .object({ + registrationId: registration.registrationId, + targetId: target.shape.id, + annotationControlChanges: z + .array(z.object({ callback: base.callback, previousValue: value, value }).strict()) + .max(12), + }) + .strict(), + ) + .max(64), + }) + .strict(); +export type GenUiTweakAnnotation = z.infer; diff --git a/server/vendor/zcode/packages/shared/src/localTtft.ts b/server/vendor/zcode/packages/shared/src/local-ttft/contract.ts similarity index 80% rename from server/vendor/zcode/packages/shared/src/localTtft.ts rename to server/vendor/zcode/packages/shared/src/local-ttft/contract.ts index 27d7065..36047dc 100644 --- a/server/vendor/zcode/packages/shared/src/localTtft.ts +++ b/server/vendor/zcode/packages/shared/src/local-ttft/contract.ts @@ -44,7 +44,12 @@ export const LOCAL_TTFT_CLOCK_TTL_MS = 60_000; const time = z.number().finite().nonnegative(); const identifier = z.string().min(1).max(128); export const localTtftContextSchema = z - .object({ version: z.literal(1), observationId: z.string().uuid() }) + .object({ + version: z.literal(1), + observationId: z.string().uuid(), + // 本地默认采集不能顺带开启云端;在一次发送开始时冻结出口选择。 + localOnly: z.literal(true).optional(), + }) .strict(); export type LocalTtftContext = z.infer; export const localTtftClockSchema = z @@ -123,6 +128,7 @@ export const localTtftRecordSchema = z .object({ version: z.literal(1), observationId: z.string().uuid(), + localOnly: z.literal(true).optional(), commandId: identifier.optional(), sessionId: identifier.optional(), turnId: identifier.optional(), @@ -190,3 +196,52 @@ export type LocalTtftBatch = z.infer; export function localTtftNow(): number { return performance.timeOrigin + performance.now(); } + +/** 有界异步诊断队列;文件 I/O 由宿主 adapter 注入,不参与业务等待。 */ +export function createLocalTtftLogQueue( + write: (entries: readonly { path: string; line: string }[], dropped: number) => Promise, + maxChars = 262_144, +) { + let entries: { path: string; line: string }[] = []; + let chars = 0; + let dropped = 0; + let draining: Promise | undefined; + const drain = async () => { + while (entries.length) { + const batch = entries; + entries = []; + chars = 0; + try { + await write(batch, dropped); + } catch { + dropped += batch.length; + } + } + }; + const schedule = () => { + draining ??= Promise.resolve() + .then(drain) + .finally(() => { + draining = undefined; + // drain 的 Promise 收口前仍可能有新记录进入,不能让它等下一次业务日志才落盘。 + if (entries.length) schedule(); + }); + }; + return { + enqueue(entry: { path: string; line: string }): void { + if (chars + entry.line.length > maxChars) { + dropped++; + return; + } + entries.push(entry); + chars += entry.line.length; + schedule(); + }, + async flush(): Promise { + while (draining) await draining; + }, + get dropped(): number { + return dropped; + }, + }; +} diff --git a/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts b/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts index a432f8f..0a6910b 100644 --- a/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts +++ b/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts @@ -98,6 +98,8 @@ export interface McpAppResourceMeta { heightHint?: number; minFrameHeight?: number; showInline?: boolean; + /** 资源级显式后台保留申请;缺省不保留,实际回收由宿主裁决。 */ + backgroundRetention?: boolean; } /** 随沙箱句柄回到 renderer 的资源级呈现信息;CSP 与放宽只在 main 生效,不回传。 */ export type PluginSandboxResourceMeta = Omit; @@ -152,6 +154,11 @@ export { export const MCP_APPS_WIDGET_STATE_EXPERIMENTAL_KEY = "zcode/widgetState"; export const MCP_APPS_RESOURCE_SUBSCRIBE_EXPERIMENTAL_KEY = "zcode/resourceSubscribe"; export const MCP_APPS_SURFACE_EXPERIMENTAL_KEY = "zcode/surface"; +/** + * 宿主允许插件文档内部创建子 frame(srcdoc / about:blank 预览、声明的 frameDomains)而不把它当作页面重载撤销实例。 + * 旧宿主会在子 frame 导航时停止页面;需要嵌套预览的插件据此键降级,而不是创建 frame 后被释放。 + */ +export const MCP_APPS_NESTED_FRAMES_EXPERIMENTAL_KEY = "zcode/nestedFrames"; /** * ZCode 扩展方法 `ui/set-widget-state { widgetState }`(MCP Apps 无 widgetState):页面把界面状态交给宿主 * renderer 内存保存(不持久化,会话内重挂载可恢复);初值经 hostContext 的 `zcode/widgetState` 键随握手下发。 @@ -245,6 +252,7 @@ export interface PluginSandboxRegisterRequestPayload { minFrameHeight?: number; /** 资源级强制常驻标记,随句柄 resourceMeta 回 renderer。 */ showInline?: boolean; + backgroundRetention?: boolean; } /** host 内部使用的登记输入:去掉传输层 requestId。 */ export type PluginSandboxRegisterInput = Omit; diff --git a/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts b/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts index e8b8904..2a542e9 100644 --- a/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts +++ b/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts @@ -93,6 +93,14 @@ export const OFFICIAL_MCP_AUTH_PORT_FAILURE_REASONS = [ export type OfficialMcpAuthPortFailureReason = (typeof OFFICIAL_MCP_AUTH_PORT_FAILURE_REASONS)[number]; +/** + * 身份头的消费方类型。`mcp-server` 是官方 MCP(缺省,旧版 agent 不带该字段); + * `plugin-command` 是官方插件的命令进程,经 agent 侧代理端点访问 zcode-server(技术方案 5.8)。 + */ +export const OFFICIAL_AUTH_CONSUMER_KINDS = ["mcp-server", "plugin-command"] as const; + +export type OfficialAuthConsumerKind = (typeof OFFICIAL_AUTH_CONSUMER_KINDS)[number]; + /** MCP adapter 侧的完整失败分类,包含网络层结果。仅用于 record status 与日志。 */ export type OfficialMcpAuthFailureKind = | OfficialMcpAuthFailureReason diff --git a/server/vendor/zcode/packages/shared/src/protocol.ts b/server/vendor/zcode/packages/shared/src/protocol.ts index 79057e7..ffcf4bd 100644 --- a/server/vendor/zcode/packages/shared/src/protocol.ts +++ b/server/vendor/zcode/packages/shared/src/protocol.ts @@ -194,6 +194,8 @@ export interface RemoteWorkspaceSessionSnapshot { lastConnectionStatus: "connected" | "failed"; /** 最近一次失败原因;成功后清空 */ lastConnectionError?: string; + /** 最近一次失败的错误码,与 lastConnectionError 同写同清;等待点也写成失败,只看文案分不清两类 */ + lastConnectionErrorCode?: string; } export interface LocalWorkspaceSessionEntry { diff --git a/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts b/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts index 0c11622..3269cad 100644 --- a/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts +++ b/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts @@ -11,6 +11,11 @@ export function readRequestVerificationConfig( ): RequestVerificationConfig | null { return null; } +export function readValidatedRequestVerificationConfig( + _configs: RequestVerificationClientConfig | null | undefined, +): RequestVerificationConfig | null { + return null; +} export function requestVerificationClaimHeaders( _proof: RequestVerificationProof, ): Record { @@ -26,7 +31,10 @@ export function allowRequestVerificationHeaders( ): Record { return {}; } -export function requiresRequestVerification(_access: { mode: string } | undefined): boolean { +export function requiresRequestVerification( + _access: { mode: string } | undefined, + _config?: RequestVerificationConfig | null, +): boolean { return false; } export function isRequestVerificationMessage(_message: string): boolean { diff --git a/server/vendor/zcode/packages/shared/src/runtimeEnv.ts b/server/vendor/zcode/packages/shared/src/runtimeEnv.ts index c7a919f..52cb68a 100644 --- a/server/vendor/zcode/packages/shared/src/runtimeEnv.ts +++ b/server/vendor/zcode/packages/shared/src/runtimeEnv.ts @@ -12,6 +12,10 @@ export const ZCODE_TOOL_ENV_PASSTHROUGH_ENV_KEY = "ZCODE_TOOL_ENV_PASSTHROUGH_JS export const ZCODE_DESKTOP_CONTEXT_PROMPT_ENABLED_ENV = "ZCODE_DESKTOP_CONTEXT_PROMPT_ENABLED"; export const ZCODE_CUA_PRODUCT_HELPER_ENV_KEY = "ZCODE_CUA_PRODUCT_HELPER"; export const ZCODE_CUA_BROKER_SOCKET_ENV_KEY = "ZCODE_CUA_PERMISSION_BROKER_SOCKET"; +// 官方命令端点(agent 侧代理,技术方案 5.8):地址与 session token 只由 agent 按 session 注入 +// Bash/tool 子进程,不随 agent 全局 env 继承。 +export const ZCODE_OFFICIAL_ENDPOINT_ENV_KEY = "ZCODE_OFFICIAL_ENDPOINT"; +export const ZCODE_OFFICIAL_ENDPOINT_TOKEN_ENV_KEY = "ZCODE_OFFICIAL_ENDPOINT_TOKEN"; /** Shared node_repl host marker; unlike the broker bearer values it is not a secret. */ export const ZCODE_CUA_NODE_REPL_HOST_ENV_KEY = "ZCODE_CUA_NODE_REPL_HOST"; // One-knob local-development bundle. Setting ZCODE_CUA_DEV_MODE implies the internal feature @@ -70,6 +74,10 @@ const SANITIZED_RUNTIME_ENV_KEYS = [ "ZCODE_CUA_PERMISSION_BROKER_TOKEN", "ZCODE_CUA_PERMISSION_BROKER_REFRESH_MARKER", "ZCODE_CUA_PLUGIN_AUTHORITY", + // 官方命令端点的地址与 token 属于某一个 session,由 agent 定向注入;从父进程继承来的 + // 值(例如嵌套运行的 agent)一律剔除,避免一个 session 拿着另一个 session 的 token。 + ZCODE_OFFICIAL_ENDPOINT_ENV_KEY, + ZCODE_OFFICIAL_ENDPOINT_TOKEN_ENV_KEY, // Agent OTLP Endpoint/Auth/Identity 只属于 CLI telemetry bootstrap,不能继续泄漏给 // Bash、MCP 或模型工具子进程。sanitize 前会捕获到本进程私有 Map,供 Agent 启动边界读取。 "OTEL_EXPORTER_OTLP_ENDPOINT", @@ -101,6 +109,8 @@ const NON_TOOL_PASSTHROUGH_RUNTIME_ENV_KEYS = [ ZCODE_CUA_BROKER_SOCKET_ENV_KEY, "ZCODE_CUA_PERMISSION_BROKER_REFRESH_MARKER", "ZCODE_CUA_PLUGIN_AUTHORITY", + ZCODE_OFFICIAL_ENDPOINT_ENV_KEY, + ZCODE_OFFICIAL_ENDPOINT_TOKEN_ENV_KEY, ZCODE_REMOTE_RUNTIME_NETWORK_AUTHORITY_ENV_KEY, ZCODE_REMOTE_HTTP_PROXY_ENV_KEY, ZCODE_REMOTE_NO_PROXY_ENV_KEY, diff --git a/server/vendor/zcode/packages/shared/src/server-remote.ts b/server/vendor/zcode/packages/shared/src/server-remote.ts index 214834c..b762d5f 100644 --- a/server/vendor/zcode/packages/shared/src/server-remote.ts +++ b/server/vendor/zcode/packages/shared/src/server-remote.ts @@ -42,6 +42,7 @@ export const serverRemoteInfoSchema = z.object({ virtualProjects: z.literal(true).optional(), // 旧 Server 缺少新增 dynamic event,必须先声明能力再订阅,避免异常打进对端读循环。 processResourceTelemetry: z.boolean().optional(), + remoteConversationTelemetry: z.boolean().optional(), }), }); @@ -65,6 +66,7 @@ export const serverRemoteInfoOutputSchema = z virtualProjects: z.literal(true).optional(), // 输入和严格输出保持同一能力合同,否则新 Server 会在监听前被自身 schema 拒绝。 processResourceTelemetry: z.boolean().optional(), + remoteConversationTelemetry: z.boolean().optional(), }) .strict(), }) diff --git a/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts b/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts index 7408cd6..dd3d796 100644 --- a/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts +++ b/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts @@ -8,6 +8,17 @@ export const ZCODE_MIN_COMPATIBLE_VERSION = ? __ZCODE_MIN_COMPATIBLE_VERSION__ : ZCODE_VERSION; +/** + * 远端服务支持设备卡停止 / 重启合同(`zcode stop --wait` 等,RDLC-01)的首个版本,桌面端据此做版本门禁。 + * 取首个包含本合同的正式版 3.17.0。不提升最低兼容版本。 + * + * Bug 原因:曾先后取 3.16.2(根版本占位)和 3.16.3(假设下一次发版包含本合同)。实际 v3.16.3 从 release 分支发布、 + * 不含本合同,两次都等于已发布、不支持本合同的版本:旧 CLI 把 `stop --wait` 当成 ack 型 stop、把 `restart` 当成只换 Core, + * 桌面端收不到最终状态而报失败,但远端已执行停止或换 Core。 + * 只看版本号区分不开开发中与已发布的同号版本,因此取实际首发版本;根版本升到 3.17.0 前开发构建也会显示禁用。 + */ +export const SOURCE_SERVER_LIFECYCLE_CONTROL_MIN_VERSION = "3.17.0"; + export const compatibilityManifestSchema = z .object({ schemaVersion: z.literal(1), diff --git a/server/vendor/zcode/packages/shared/src/source-server/contracts.ts b/server/vendor/zcode/packages/shared/src/source-server/contracts.ts index c54ee61..317f907 100644 --- a/server/vendor/zcode/packages/shared/src/source-server/contracts.ts +++ b/server/vendor/zcode/packages/shared/src/source-server/contracts.ts @@ -127,11 +127,19 @@ export const sourceServerUpdateRequestSchema = z .object({ profileId: nonEmptyStringSchema, force: z.boolean().optional(), + /** 用户已确认把较新的远端切换到本机 Desktop 版本;方向由远端 CLI 判定。 */ + allowDowngrade: z.boolean().optional(), expectedTarget: sourceServerUpdateTargetSchema.optional(), }) .strict(); export type SourceServerUpdateRequest = z.input; +/** + * 设备级生命周期操作(停止、重启远端服务,RDLC-01)只接收设备身份;具体走哪条连接由 Host 路由, + * Renderer 不传 profileId。 + */ +export const sourceServerLifecycleSourceIdSchema = z.string().uuid(); + const connectionProfileBaseShape = { profileId: z.string().uuid(), sourceServerId: z.string().uuid().optional(), @@ -302,6 +310,16 @@ export const sourceServerRunningTaskSchema = z export type SourceServerRunningTask = z.infer; export const sourceServerRunningTasksSchema = z.array(sourceServerRunningTaskSchema); +/** + * 停止 / 重启远端服务确认前按设备读取的运行中任务(RDLC-01)。`available: false` 表示设备没有提供 + * 可信清单(远端输出 null、命令失败或输出不符 schema),不能当作“没有任务”;空数组才是没有任务。 + */ +export const sourceServerRunningTasksResultSchema = z.discriminatedUnion("available", [ + z.object({ available: z.literal(true), tasks: sourceServerRunningTasksSchema }).strict(), + z.object({ available: z.literal(false) }).strict(), +]); +export type SourceServerRunningTasksResult = z.infer; + /** 只读安装预览;sizeBytes 是安装包实际大小,不代表解压后的磁盘占用。 */ export const sourceServerInstallPreviewSchema = z .object({ @@ -323,6 +341,8 @@ export const sourceServerConnectionStateSnapshotSchema = z availableVersion: nonEmptyStringSchema.optional(), minimumVersion: nonEmptyStringSchema.optional(), upgradeTarget: z.enum(["controller", "server"]).optional(), + /** 远端当前 release 由显式降级安装时,被替换的版本;向导据此不自动升级。 */ + downgradedFrom: nonEmptyStringSchema.optional(), errorCode: publicZCodeErrorCodeSchema.optional(), retryable: z.boolean().optional(), installPreview: sourceServerInstallPreviewSchema.optional(), @@ -413,7 +433,7 @@ export type SourceServerInstallProgress = z.infer(PUBLIC_ZCODE_ERROR_CODES); -export function isPublicZCodeErrorCode( - value: unknown, -): value is PublicZCodeErrorCode { +export function isPublicZCodeErrorCode(value: unknown): value is PublicZCodeErrorCode { return typeof value === "string" && publicZCodeErrorCodeSet.has(value); } diff --git a/server/vendor/zcode/packages/shared/src/subagent-profile.ts b/server/vendor/zcode/packages/shared/src/subagent-profile.ts index a9bd6f3..a8c1c2d 100644 --- a/server/vendor/zcode/packages/shared/src/subagent-profile.ts +++ b/server/vendor/zcode/packages/shared/src/subagent-profile.ts @@ -18,6 +18,11 @@ export interface AgentProfile { name: string; path?: string; permissionMode?: AgentPermissionMode; + /** + * permissionMode 只能收紧父会话模式。插件 loader 在 CLI 进程内设置; + * 不进入下方跨进程 schema,若被跨边界发送,strict schema 会直接拒绝。 + */ + permissionModeRestrictOnly?: boolean; skills?: readonly string[]; source: AgentProfileSource; systemPrompt: string; diff --git a/server/vendor/zcode/packages/shared/src/validationAppSettings.ts b/server/vendor/zcode/packages/shared/src/validationAppSettings.ts index e35baf7..bf607c3 100644 --- a/server/vendor/zcode/packages/shared/src/validationAppSettings.ts +++ b/server/vendor/zcode/packages/shared/src/validationAppSettings.ts @@ -141,6 +141,7 @@ const appWorkspaceSessionEntrySchema = z.discriminatedUnion("kind", [ lastOpenedAt: z.number().int().nonnegative(), lastConnectionStatus: z.enum(["connected", "failed"]), lastConnectionError: z.string().optional(), + lastConnectionErrorCode: z.string().optional(), }), ]); diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts index 6030987..2ff6cb2 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts @@ -148,6 +148,7 @@ export const zcodeSessionGoalVerificationTimelineSchema = z export const zcodeSessionInfoSchema = z .object({ sessionId: nonEmptyString, + directorySessionId: nonEmptyString.optional(), workspace: zcodeWorkspaceRefSchema, parentSessionId: nonEmptyString.optional(), traceId: nonEmptyString.optional(), diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts index 66ace3b..2cf3a6d 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts @@ -85,7 +85,9 @@ export function applyConversationDelta( }, }; case "row.upserted": { - const index = snapshot.rows.window.findIndex( + // 窗口内 rowId 唯一(rows.ts:session 内单调、永不复用),从尾部查找与从头查找结果相同。 + // upsert/delta 的目标几乎总是尾部的流式行;从头 findIndex 会让每条 delta 都扫描整段历史。 + const index = snapshot.rows.window.findLastIndex( (row) => row.rowId === delta.row.rowId, ); // §4.3:未加载 rowId = no-op(被逐出的行只能经 rows/range 取回)。 @@ -117,7 +119,7 @@ export function applyConversationDelta( }; } case "row.delta": { - const index = snapshot.rows.window.findIndex( + const index = snapshot.rows.window.findLastIndex( (row) => row.rowId === delta.rowId, ); const target = snapshot.rows.window[index]; diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts index 64f91aa..39ac848 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts @@ -1,5 +1,6 @@ +import { genUiModelContextSchema } from "../gen-ui/contract.js"; import { createSessionRequestedConfigSchema } from "./create-session-config.js"; -import { localTtftContextSchema, localTtftClockSchema } from "../localTtft.js"; +import { localTtftContextSchema, localTtftClockSchema } from "../local-ttft/contract.js"; import { conversationQuotesSchema } from "../conversationSelection.js"; // Command 层:信封 / ACK / 命令全集 payload。 // conversation rewind 无独立命令(裁决:= editUserQuery 的 UI 入口); @@ -99,6 +100,7 @@ export const commandPayloadSchemas = { // Desktop Cmd/Ctrl+Enter 只覆盖本次 busy input,不改 session followupMode。 // startNow 由 CLI 原子抢占当前 turn,不经过 queue admission。 requestedDelivery: z.enum(["startNow", "queue", "guide"]).optional(), + genUiContext: genUiModelContextSchema.optional(), browserAmbientContext: zcodeBrowserAmbientContextSchema.optional(), // Share handover 只允许当前 session 的一个已导入上下文;完整正文由 runtime 从 // 持久化 provenance 解析,不能随 command 从 renderer 传入。 @@ -164,23 +166,23 @@ export const commandPayloadSchemas = { }), // compact 是输入型维护命令:idle 时立即执行,busy/held 时进入 FIFO。 // 因为 admission 与当前 revision 无关,不走 CAS;sourceCommandId 提供幂等边界。 - compact: z.object({}), + compact: z.object({ modelSelection: modelSelectionSchema.optional() }), // running 时对稳定 assistant row 可用。 forkAssistant: z.object({ target: conversationRowTargetSchema }), applyFileRewind: z.object({ target: conversationRowTargetSchema }), editUserQuery: z .object({ - target: conversationRowTargetSchema, - newText: z.string(), + target: conversationRowTargetSchema, + newText: z.string(), conversationQuotes: conversationQuotesSchema.optional(), - attachments: z.array(attachmentRefSchema).optional(), + attachments: z.array(attachmentRefSchema).optional(), // 编辑重发按新的主动发送处理:只接受本次重新 prepare 得到的卡与执行材料, // 不从被 rewind 的历史消息复用旧凭据。 modelSelection: modelSelectionSchema.optional(), modelExecution: modelExecutionSchema.optional(), highspeedMeta: highspeedMessageMetaSchema.optional(), - // 缺省 preserve:仅切 conversation branch;rewind 会先安全恢复该轮文件。 - workspaceMode: z.enum(["preserve", "rewind"]).optional(), + // 缺省 preserve:仅切 conversation branch;rewind 会先安全恢复该轮文件。 + workspaceMode: z.enum(["preserve", "rewind"]).optional(), }) .superRefine(requireModelSelectionForExecution), retryTurn: z.object({ target: conversationRowTargetSchema }), @@ -341,6 +343,8 @@ export const ROW_TARGETING_COMMANDS: ReadonlySet = new Set([ // ── 信封 ── export const commandEnvelopeSchema = z.object({ + /** Host 可信 attachment 注入;CLI 保留到原 input intent。 */ + inputOrigin: z.enum(["desktop", "mobile"]).optional(), ttft: localTtftContextSchema.optional(), // uuid v7,客户端生成,重试不变。 commandId: z.string(), diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts index 6856a36..9a775fb 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts @@ -28,6 +28,7 @@ import { sessionUsageStateSchema, subagentProjectionStateSchema, workspaceHookAdmissionStateSchema, + workspaceMcpAdmissionStateSchema, } from "./snapshot.js"; import { WORKFLOW_RUNS_LIMITS, @@ -61,6 +62,7 @@ export const statePatchSchema = z.object({ plan: planStateSchema.nullable().optional(), // 软门禁:null = pending 清零(提示条消失);对象 = 待审核状态更新。 workspaceHookAdmission: workspaceHookAdmissionStateSchema.nullable().optional(), + workspaceMcpAdmission: workspaceMcpAdmissionStateSchema.nullable().optional(), }); export type StatePatch = z.infer; diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts index d3c4945..fc05106 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts @@ -1,3 +1,4 @@ +import { genUiModelContextSchema } from "../gen-ui/contract.js"; import { conversationQuotesSchema } from "../conversationSelection.js"; import { botGroupInputSourceSchema } from "../bots.js"; // CLI admission 后的自包含输入事实。 @@ -78,6 +79,7 @@ export const conversationInputIntentSchema = z modelSelection: modelSelectionSchema.optional(), mode: submissionModeSchema.optional(), planEnabled: z.boolean().optional(), + genUiContext: genUiModelContextSchema.optional(), sharedContextRefs: z.array(sharedContextRefSchema).max(1).optional(), delivery: conversationInputDeliverySchema, order: conversationInputOrderSchema, diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts index 1839ae0..580afd8 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts @@ -43,6 +43,7 @@ export type RowActions = NonNullable>; // workflow 轮的行级元数据拆到了 workflow-row-meta.ts(max-lines);名字在此原样再导出。 export { backgroundResultOriginMetaSchema, + subagentResultMetaSchema, workflowBlockedMetaSchema, workflowLaunchMetaSchema, workflowNotificationMetaSchema, @@ -95,7 +96,7 @@ export const turnHeaderRowSchema = z.object({ modelDurationMs: z.number().nonnegative().optional(), toolDurationMs: z.number().nonnegative().optional(), otherDurationMs: z.number().nonnegative().optional(), - // guide 不切 product turn,但每条 accepted guide 都开启独立视觉工作段。 + // guide 不切 product turn;一个 drain 边界按 FIFO 取出全部已等待的 guide,它们共用首条开启的视觉工作段。 // 普通 turn 缺省以保持旧 snapshot 兼容;一旦出现 guide,CLI 负责完整投影首段与后续段。 workSegments: z.array(turnWorkSegmentSchema).optional(), originMeta: backgroundResultOriginMetaSchema.optional(), @@ -445,3 +446,20 @@ export const conversationRowSchema = z.discriminatedUnion("kind", [ ]); export type ConversationRow = z.infer; export type ConversationRowKind = ConversationRow["kind"]; + +/** + * rows.window 的「冻结历史 + 尾轮」分区(spec:docs/ui/chat-virtual-scroll.md「每帧派生成本」)。 + * + * 只是行数组的视图类型,不上 wire,没有 schema;构造与缓存在 renderer 的 conversationProjectionStore。 + * 放在这里是为了让插件 UI 等 domain 层只依赖协议类型,不依赖 v4 store。 + * history 与 tail 拼接后逐项等于 rows。 + */ +export interface ConversationRowsPartition { + /** tail 之前的行;只在历史段变化时更换引用。 */ + readonly history: readonly ConversationRow[]; + /** + * window 的后缀:包含最后一行所在轮的全部行,可能包含多轮(旧轮追加了行、或尾轮内部截断后), + * 与 history 的轮次不相交。消费方不能假设 tail 只有一轮。 + */ + readonly tail: readonly ConversationRow[]; +} diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts index 6d5c071..d39c360 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts @@ -215,6 +215,8 @@ export const queueItemSchema = conversationInputIntentSchema.extend({ dispatch: conversationInputDispatchSchema.extend({ state: z.enum(["queued", "reserved", "promoting"]), }), + /** Host 准入注入的可信 automation 身份;只允许队列提升原样回放。 */ + automationId: z.string().min(1).optional(), toolDisallowlist: z.array(z.string().min(1)).optional(), }); export type QueueItem = z.infer; @@ -472,6 +474,13 @@ export const workspaceHookAdmissionStateSchema = z.object({ }); export type WorkspaceHookAdmissionSnapshotState = z.infer; +export const workspaceMcpAdmissionStateSchema = z.object({ + pendingCount: z.number().int().nonnegative(), + bundleDigest: z.string().regex(/^[a-f0-9]{64}$/u), + workspaceIdentity: z.string().min(1).optional(), +}); +export type WorkspaceMcpAdmissionSnapshotState = z.infer; + // 冷历史可读不代表 runtime 已可执行;缺席兼容旧发送端。 export const runtimeInitializationSchema = z.discriminatedUnion("status", [ z.object({ status: z.literal("initializing"), attemptId: z.string().min(1) }), @@ -522,6 +531,8 @@ export const conversationSnapshotSchema = z.object({ // 旧快照/旧发送端不携带此字段 → 解析得 null,不破坏兼容性(遵守冻结规则)。 // pendingCount === 0 时投影层置 null(提示条消失)。 workspaceHookAdmission: workspaceHookAdmissionStateSchema.nullable().default(null), + // 旧发送端可缺席;null 或缺席均无 MCP 待审核提示。 + workspaceMcpAdmission: workspaceMcpAdmissionStateSchema.nullable().optional(), // (2026-09-12):原 additive 字段 pluginUiSurfaces 已删除,插件面板 widgetState 只留在 // 宿主 renderer 内存。 // B 区 diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts index 3ea350a..ec7b88f 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts @@ -1,4 +1,4 @@ -import { localTtftFactsSchema } from "../localTtft.js"; +import { localTtftFactsSchema } from "../local-ttft/contract.js"; /* eslint-disable max-lines -- 三个 topic 的 logical/physical/candidate schema 必须共享同一通用传输声明,避免跨文件分叉。 */ // 传输外壳:连接握手 / 订阅 / 帧信封。 // 阶段为类型占位(后半接通道层时启用),数据形状已按规范定稿。 @@ -29,6 +29,7 @@ export const hostCapabilitiesSchema = z.object({ // Wire-compatible:旧 Host 缺失等价于 false;调用方必须用 === true 判断。 workspaceHookReview: z.boolean().optional(), independentPlanState: z.boolean().optional(), + genUiContext: z.boolean().optional(), /** * 本 Host 会发 `workflowRun.*` 键级增量(delta.ts 的两条 op),因而 `workflowRuns` 的 * actors / nodes 可以到 1024 而不是旧界的 256。没有这个位的消费者收到的仍是整键 @@ -36,6 +37,13 @@ export const hostCapabilitiesSchema = z.object({ */ workflowRunDeltas: z.boolean().optional(), historyFirst: z.boolean().optional(), + /** + * 本 Host 开启并转发 `v4/conversation/inputPrediction`。旧 Host 缺失等价于 false, + * 手机必须用 === true 判断,否则不发预测请求。 + */ + inputPrediction: z.boolean().optional(), + /** 本 Host 支持 rowsRange 的 `residency: "resident-only"`;缺失等价于 false,手机不得预加载。 */ + residentRowsRange: z.boolean().optional(), }); export type HostCapabilities = z.infer; @@ -345,6 +353,8 @@ export const V4_METHODS = { conversationUnsubscribe: "v4/conversation/unsubscribe", // 行分页 query(rows/range):只读、无状态、超时重发安全。 conversationRowsRange: "v4/conversation/rowsRange", + // 手机输入预测(input-prediction.ts):只读查询;旧 CLI 不认识时手机静默无 hint。 + conversationInputPrediction: "v4/conversation/inputPrediction", // 当前有效分支的终态 ExitPlanMode 目录;只读、无状态、超时重发安全。 conversationPlans: "v4/conversation/plans", conversationFileChanges: "v4/conversation/fileChanges", @@ -372,6 +382,10 @@ export const V4_METHODS = { // 故收敛为 v4 query 而非 host 直连;旧词 usage/stats、session/usage 就此消费清零。 usageStats: "v4/usage/stats", conversationUsage: "v4/conversation/usage", + // 项目数据彻底删除(schema 在 session-data.ts):measure 只读;purge 幂等,已不存在的会话按 0 字节成功。 + // 新方法偏斜安全:旧 CLI 返回 method-not-found,Host 据此不显示「删除数据」选项。 + sessionDataMeasure: "v4/storage/sessionData/measure", + sessionDataPurge: "v4/storage/sessionData/purge", // 附件事务:禁止 full-data RPC。每个 chunk 的 decoded bytes <=512KiB, // renderer->host Channel 与 host->CLI NDJSON 都必须逐 request 证明 <=1MiB。 attachmentBegin: "v4/attachment/begin", @@ -526,6 +540,11 @@ export const v4ConversationRowsRangeParamsSchema = z.object({ // 取 rowId < beforeRowId 的行;缺省 = 从当前尾部向前。 beforeRowId: z.number().optional(), limit: z.number().min(1).max(PROTOCOL_V4_LIMITS.rowsRangeMaxLimit), + /** + * 手机预加载只读热会话:会话不在内存就报 proto.sessionNotResident,不冷恢复、不重建投影; + * Host 同时只复用已运行的工作区 CLI,不为它拉起进程。缺省 = 现有行为(按需冷恢复)。 + */ + residency: z.literal("resident-only").optional(), }); export type V4ConversationRowsRangeParams = z.infer; diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts index c0d4b40..879ac72 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts @@ -106,6 +106,12 @@ export const workflowBlockedMetaSchema = z.object({ }); export type WorkflowBlockedMeta = z.infer; +// 后台 Agent 的终态与失败原文(contracts 的 SubagentResultMeta);产品状态读它,不解析通知文本。 +export const subagentResultMetaSchema = z.object({ + status: z.enum(["completed", "failed", "killed"]), + error: z.string().optional(), +}); + export const backgroundResultOriginMetaSchema = z.object({ // 三个取值与 contracts 的 BackgroundResultOriginMeta 保持同步。 // "workflow" 是 dynamic-workflow run(workId ≡ runId),复用整条后台通知管线。 @@ -118,6 +124,8 @@ export const backgroundResultOriginMetaSchema = z.object({ // 提醒载荷,与 workflowNotification 至多在场一个。`.catch(undefined)`:将来它的形状变了,认识这个 // 键的客户端把它当作缺席(裸标题行),而不是丢掉整帧。 workflowBlocked: workflowBlockedMetaSchema.optional().catch(undefined), + // 只在 subagent 的单条通知轮上在场;形状不认识时当作缺席,界面退回通知文本。 + subagentResult: subagentResultMetaSchema.optional().catch(undefined), }); export type BackgroundResultOriginMeta = z.infer; diff --git a/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts b/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts index e606fa5..2d3c860 100644 --- a/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts +++ b/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts @@ -85,7 +85,10 @@ import { browserCommandResultSchema } from "../browser-use/result.js"; import { appToolSearchModeSchema } from "../app-runtime-preferences.js"; import { integratedTerminalShellSelectionSchema } from "../validationAppSettings.js"; import { zcodeTaskModeSchema } from "../zcode-task-mode-schema.js"; -import { OFFICIAL_MCP_AUTH_PORT_FAILURE_REASONS } from "../official-mcp-auth.js"; +import { + OFFICIAL_AUTH_CONSUMER_KINDS, + OFFICIAL_MCP_AUTH_PORT_FAILURE_REASONS, +} from "../official-mcp-auth.js"; import { zcodeSyntheticUserMessageSourceSchema as legacyZcodeSyntheticUserMessageSourceSchema, zcodeDeliveryKindSchema, @@ -110,7 +113,7 @@ import { zcodeWorkspaceRefSchema, } from "../zcode-protocol-legacy-types.js"; -export * from "../localTtft.js"; +export * from "../local-ttft/contract.js"; export { hookExecutionProjectionSchema, hookInvocationRowSchema, @@ -130,9 +133,26 @@ export const ZCODE_PROTOCOL_VERSION = 1 as const; // V4 wire 与 legacy 主协议并存;禁止为了 V4 physical framing 改写 legacy 版本。 export const ZCODE_PROTOCOL_V4_WIRE_VERSION = 3 as const; export const zcodeRuntimeCapabilitiesSchema = z.object({ + sessionLifecycleWorkspace: z.boolean().optional(), + sessionDirectorySource: z.boolean().optional(), + sessionWorkspaceRouting: z.boolean().optional(), + genUiContext: z.boolean().optional(), historyFirst: z.boolean().optional(), independentPlanState: z.boolean().optional(), + /** CLI 认识 rowsRange 的 residency 参数;旧 CLI 会剥掉它并冷恢复,Host 据此拒绝转发。 */ + residentRowsRange: z.boolean().optional(), }); +export const zcodeRuntimeCapabilitiesParamsSchema = z + .object({ + hostCapabilities: z + .object({ + sessionDirectorySource: z.boolean().optional(), + sessionWorkspaceRouting: z.boolean().optional(), + }) + .strict() + .optional(), + }) + .strict(); export const zcodeProtocolErrorCodes = { sessionUnavailable: -32004, } as const; @@ -753,7 +773,9 @@ export const zcodeProtocolMcpServerSchema = z.union([ z .object({ name: nonEmptyString, + scope: z.enum(["user", "workspace"]).optional(), command: nonEmptyString, + cwd: nonEmptyString.optional(), args: z.array(z.string()), env: z.array(zcodeProtocolMcpEntrySchema), isolation: z.enum(["session", "workspace"]).optional(), @@ -765,6 +787,7 @@ export const zcodeProtocolMcpServerSchema = z.union([ z .object({ name: nonEmptyString, + scope: z.enum(["user", "workspace"]).optional(), type: z.enum(["http", "sse"]), url: nonEmptyString, headers: z.array(zcodeProtocolMcpEntrySchema), @@ -809,9 +832,38 @@ export const MCP_SERVER_FAILURE_KINDS = [ ] as const; export const mcpServerFailureKindSchema = z.enum(MCP_SERVER_FAILURE_KINDS); export type McpServerFailureKind = z.infer; +export const workspaceMcpTrustReviewSchema = z + .object({ + declarationDigest: z.string().regex(/^[a-f0-9]{64}$/u), + sourcePaths: z.array(nonEmptyString), + display: z.string(), + trusted: z.boolean(), + configuredEnabled: z.boolean(), + transport: z.enum(["stdio", "http", "sse"]), + }) + .strict(); +export type WorkspaceMcpTrustReview = z.infer; +export const zcodeWorkspaceMcpTrustParamsSchema = z + .object({ + workspace: zcodeWorkspaceRefSchema, + serverName: nonEmptyString, + declarationDigest: z.string().regex(/^[a-f0-9]{64}$/u), + trusted: z.boolean(), + }) + .strict(); +export const zcodeWorkspaceMcpTrustResultSchema = z + .object({ + accepted: z.boolean(), + reasonCode: z + .enum(["workspace_mcp_declaration_changed", "workspace_mcp_trust_unavailable"]) + .optional(), + }) + .strict(); +export type ZCodeWorkspaceMcpTrustResult = z.infer; export const zcodeMcpServerStatusSnapshotSchema = z .object({ status: zcodeMcpServerStatusKindSchema, + workspaceTrust: workspaceMcpTrustReviewSchema.optional(), transport: z.enum(["stdio", "http", "sse"]), toolCount: z.number().int().nonnegative(), updatedAt: nonEmptyString, @@ -1532,6 +1584,11 @@ export const zcodeTurnStartedEventPayloadSchema = z input: z.string(), inputId: nonEmptyString.optional(), queryId: nonEmptyString.optional(), + // Bugfix:CLI 会把 Host 准入的后台执行归因写入 turn.started。这里漏声明时, + // strict 校验会丢弃整条开始事件,复用中的 Bot 私聊订阅就无法切换到新轮次。 + automationId: nonEmptyString.optional(), + offPeakTaskId: nonEmptyString.optional(), + offPeakRunType: z.enum(["init", "resume"]).optional(), inputSource: zcodeTurnInputSourceSchema.optional(), inputVisibility: zcodeMessageVisibilitySchema.optional(), executionKind: z.enum(["agent", "controlOnly"]).optional(), @@ -2059,7 +2116,7 @@ export { type SubagentRuntimeConfig, } from "../subagent-runtime-config.js"; export const zcodeSubagentsReadRuntimeConfigParamsSchema = z - .object({ sessionId: nonEmptyString }) + .object({ sessionId: nonEmptyString, workspace: zcodeWorkspaceRefSchema.optional() }) .strict(); export const ZCODE_SESSION_RUNTIME_PREFERENCES_REQUEST_TIMEOUT_MS = 15_000; @@ -2068,6 +2125,9 @@ export const zcodeSessionRequestRuntimePreferencesParamsSchema = z .object({ sessionId: nonEmptyString, scope: zcodeSessionRuntimePreferencesScopeSchema, + workspace: zcodeWorkspaceRefSchema.optional(), + // CLI 依据持久化父链给出目录来源;目标 sessionId 仍保留 child 身份。 + directorySessionId: nonEmptyString.optional(), }) .strict(); export type ZCodeSessionRequestRuntimePreferencesParams = z.infer< @@ -2716,6 +2776,7 @@ export type ZCodeBrowserListResult = z.infer; +// 标准 JSON-RPC error 保留旧版 schema 兼容,不向严格校验的 response 增加字段。 +export const ZCODE_PROVIDER_CONFIG_NETWORK_ERROR = -32032; + +export const zcodeProviderRuntimeHeadersErrorCode = { + configNetwork: "request_verification_config_network", + configInvalid: "request_verification_config_invalid", +} as const; + export const zcodeProviderRuntimeHeadersResponseSchema = z.discriminatedUnion("headersApplied", [ z .object({ @@ -2851,15 +2920,37 @@ export type ZCodeProviderRuntimeHeadersResponse = z.infer< // Agent 进程不是用户身份权威:它把 (pluginId, mcpKey, targetOrigin) 报给 host,由 host // 解析当前 Coding Plan 凭证并回传本次请求的身份头。请求侧不含任何秘密。 // 与 interaction/requestProviderRuntimeHeaders 同类:Agent 发起、host 自动响应、零 UI。 +// +// `consumer` 缺省为 `mcp-server`(旧版 agent 不带该字段),此时必须带 `mcpKey`; +// `plugin-command` 是官方插件命令进程经 agent 代理端点发起的请求,没有 MCP,不带 `mcpKey`, +// host 按「套餐可选」解析:没有套餐时只给 ZCode 登录身份(技术方案 5.8)。 export const zcodeOfficialMcpAuthHeadersRequestParamsSchema = z .object({ requestId: nonEmptyString, workspace: zcodeWorkspaceRefSchema, pluginId: nonEmptyString, - mcpKey: nonEmptyString, + consumer: z.enum(OFFICIAL_AUTH_CONSUMER_KINDS).optional(), + mcpKey: nonEmptyString.optional(), targetOrigin: nonEmptyString, }) - .strict(); + .strict() + .superRefine((params, ctx) => { + const isCommand = params.consumer === "plugin-command"; + if (isCommand && params.mcpKey !== undefined) { + ctx.addIssue({ + code: "custom", + message: "plugin-command must not carry mcpKey", + path: ["mcpKey"], + }); + } + if (!isCommand && params.mcpKey === undefined) { + ctx.addIssue({ + code: "custom", + message: "mcpKey is required for mcp-server", + path: ["mcpKey"], + }); + } + }); export type ZCodeOfficialMcpAuthHeadersRequestParams = z.infer< typeof zcodeOfficialMcpAuthHeadersRequestParamsSchema >; @@ -3911,6 +4002,7 @@ export type ZCodeAutomationProtocol = z.infer; -export const zcodeAutomationListParamsSchema = z.object({}).strict(); +export const zcodeAutomationListParamsSchema = z + .object({ workspace: zcodeWorkspaceRefSchema.optional() }) + .strict(); export type ZCodeAutomationListProtocolParams = z.infer; export const zcodeAutomationListResultSchema = z .object({ automations: z.array(zcodeAutomationProtocolSchema) }) @@ -4017,7 +4112,7 @@ export const zcodeAutomationListResultSchema = z export type ZCodeAutomationListProtocolResult = z.infer; export const zcodeAutomationCheckTaskBindingParamsSchema = z - .object({ targetTaskId: nonEmptyString }) + .object({ workspace: zcodeWorkspaceRefSchema.optional(), targetTaskId: nonEmptyString }) .strict(); export type ZCodeAutomationCheckTaskBindingProtocolParams = z.infer< typeof zcodeAutomationCheckTaskBindingParamsSchema @@ -4030,15 +4125,24 @@ export type ZCodeAutomationCheckTaskBindingProtocolResult = z.infer< >; export const zcodeAutomationDeleteParamsSchema = z - .object({ automationId: nonEmptyString }) + .object({ workspace: zcodeWorkspaceRefSchema.optional(), automationId: nonEmptyString }) .strict(); export type ZCodeAutomationDeleteProtocolParams = z.infer; export const zcodeAutomationDeleteResultSchema = z.object({ deleted: z.boolean() }).strict(); export type ZCodeAutomationDeleteProtocolResult = z.infer; +// 执行轮自暂停(CronPauseSelf):automationId 来自 CLI loop state,Host 只在当前 workspace +// 内做条件暂停(active 且 enabled 才转 paused)并回报是否生效。 +export const zcodeAutomationPauseParamsSchema = z + .object({ workspace: zcodeWorkspaceRefSchema.optional(), automationId: nonEmptyString }) + .strict(); +export type ZCodeAutomationPauseProtocolParams = z.infer; +export const zcodeAutomationPauseResultSchema = z.object({ paused: z.boolean() }).strict(); +export type ZCodeAutomationPauseProtocolResult = z.infer; + // ---- Off-Peak(闲时任务)会话内创建协议---- // 与 automation 兄弟并列(独立域,禁止互相复用标记/表)。workspace 由 host 端从 -// 当前 session 注入,不进协议参数(对称 automation/create)。permissionMode 只开放产品 +// 当前 session 的已协商 workspace 注入。permissionMode 只开放产品 // 四档词表(D29-4);缺省解析在 host 端(D49-4:yolo / allowed_models 末位 / 最高推理档)。 export const zcodeOffPeakPermissionModeSchema = z.enum([ "build", @@ -4051,6 +4155,7 @@ export type ZCodeOffPeakProtocolPermissionMode = z.infer; -export const zcodeOffPeakListParamsSchema = z.object({}).strict(); +export const zcodeOffPeakListParamsSchema = z + .object({ workspace: zcodeWorkspaceRefSchema.optional() }) + .strict(); export type ZCodeOffPeakListProtocolParams = z.infer; export const zcodeOffPeakListResultSchema = z .object({ tasks: z.array(zcodeOffPeakTaskSnapshotSchema) }) .strict(); export type ZCodeOffPeakListProtocolResult = z.infer; +// Session 运行实例生命周期;不同于 session/stop(停止生成)。 +export const sessionLifecycleParamsSchema = z.object({ sessionId: z.string().min(1) }).strict(); +export const sessionLifecycleActivationParamsSchema = sessionLifecycleParamsSchema.extend({ + workspace: zcodeWorkspaceRefSchema.optional(), +}); +export const sessionLifecycleStateSchema = z.enum([ + "unloaded", + "starting", + "ready", + "stopping", + "faulted", +]); +export const sessionLifecycleOperationSchema = z.enum(["ensureReady", "stop", "restart"]); +export const sessionLifecycleFailureSchema = z + .object({ + operation: sessionLifecycleOperationSchema, + code: z.string(), + message: z.string(), + }) + .strict(); +export const sessionLifecycleSnapshotSchema = z + .object({ + sessionId: z.string().min(1), + state: sessionLifecycleStateSchema, + generation: z.number().int().nonnegative().default(0), + revision: z.number().int().nonnegative().default(0), + lastError: sessionLifecycleFailureSchema.nullable(), + }) + .strict(); +export const sessionLifecycleResultSchema = z.object({ completed: z.literal(true) }).strict(); +export type SessionLifecycleState = z.infer; +export type SessionLifecycleOperation = z.infer; +export type SessionLifecycleFailure = z.infer; +export type SessionLifecycleSnapshot = z.infer; + export const zcodeProtocolMethods = { + sessionLifecycleChanged: "session/lifecycle/changed", + sessionLifecycleGetState: "session/lifecycle/getState", + sessionLifecycleEnsureReady: "session/lifecycle/ensureReady", + sessionLifecycleStop: "session/lifecycle/stop", + sessionLifecycleRestart: "session/lifecycle/restart", runtimeCapabilities: "runtime/capabilities", computerUseOperationEvent: "computer-use/operation-event", sessionCreate: "session/create", @@ -4162,6 +4309,7 @@ export const zcodeProtocolMethods = { workspaceCancelGenerateText: "workspace/cancelGenerateText", providerTestModelConnectivity: "provider/testModelConnectivity", mcpList: "mcp/list", + workspaceMcpTrust: "workspace/mcp/trust", mcpReadResource: "mcp/readResource", mcpUiOpenInstance: "mcp/uiOpenInstance", mcpUiCloseInstance: "mcp/uiCloseInstance", @@ -4220,6 +4368,7 @@ export const zcodeProtocolMethods = { automationCheckTaskBinding: "automation/checkTaskBinding", automationList: "automation/list", automationDelete: "automation/delete", + automationPause: "automation/pause", // Off-Peak 会话内创建:与 automation 兄弟并列的独立方法族。 offPeakCreate: "offPeak/create", offPeakList: "offPeak/list", @@ -4264,6 +4413,10 @@ export const zcodeProtocolSessionMethodContracts = { params: zcodeWorkspaceHookTrustGrantParamsSchema, result: zcodeWorkspaceHookTrustGrantResultSchema, }, + [zcodeProtocolMethods.workspaceMcpTrust]: { + params: zcodeWorkspaceMcpTrustParamsSchema, + result: zcodeWorkspaceMcpTrustResultSchema, + }, [zcodeProtocolMethods.mcpList]: { params: zcodeMcpListParamsSchema, result: zcodeMcpListResultSchema, @@ -4365,7 +4518,7 @@ export const zcodeStoragePathReadySchema = z .strict(); // 桌面本地 TTFT 的严格事实合同;检查点不能替代实际内容帧。 -export { localTtftFactsSchema } from "../localTtft.js"; +export { localTtftFactsSchema } from "../local-ttft/contract.js"; // 群来源由可信 Host 注入,V4 命令与持久化输入使用相同运行时校验。 export { botIdentitySchema, diff --git a/server/vendor/zcode/provenance.json b/server/vendor/zcode/provenance.json index 57c202c..e7199d0 100644 --- a/server/vendor/zcode/provenance.json +++ b/server/vendor/zcode/provenance.json @@ -1,6 +1,6 @@ { "repository": "https://github.com/zai-org/ZCode", - "commit": "3c5b227649371507ddc4eb46ac5133afe6db1cab", + "commit": "a9fe401eede6e6e5e01be9048679c206fe6f02d9", "entries": [ "packages/rpc/src/channelClient.ts", "packages/rpc/src/channelServer.ts", @@ -23,11 +23,11 @@ "vendoredSha256": "606c36baf38b973227273df12a74930e4b4137280eea835c5cd623aa4553c13b" }, "NOTICE.md": { - "sourceSha256": "6bd5e85b48a192ce100a9e5e0636e3a90d3f6e1ac1c4fe74369e13bd79bb4c45", - "vendoredSha256": "6bd5e85b48a192ce100a9e5e0636e3a90d3f6e1ac1c4fe74369e13bd79bb4c45" + "sourceSha256": "c946abfb46cf3920fefeb756c526620201a3ce29bf84953b540763605b33d9ea", + "vendoredSha256": "c946abfb46cf3920fefeb756c526620201a3ce29bf84953b540763605b33d9ea" }, "THIRD-PARTY-NOTICES.md": { - "sourceSha256": "a762a71f8de6eeb35aacf87f03ee0c903b2871ad87d4ce85e53e8f7f82825d34", + "sourceSha256": "b6dfeabf703ec1370203f0661ed1e3bd849bd43b1e972e59958e02e2dcd0b977", "vendoredSha256": "bd07816c2c5caee244214cd296a94a2d94b98bcb876468998720f3b04648d225" }, "packages/model-option-map/src/compiler.ts": { @@ -67,16 +67,16 @@ "vendoredSha256": "6bc6a44e6abd088f72d57616d9556d78ce078b6f3813bf75402dde386781492c" }, "packages/rpc/src/channelClient.ts": { - "sourceSha256": "9c5c99acfa173a2986c39619966955ddebe123c3a3882aaea3d835a73bb59068", - "vendoredSha256": "9c5c99acfa173a2986c39619966955ddebe123c3a3882aaea3d835a73bb59068" + "sourceSha256": "3eceb8bfdbed80343d3fab8940e44895d82760f6e13d0dd3adf2a146750e5d7a", + "vendoredSha256": "3eceb8bfdbed80343d3fab8940e44895d82760f6e13d0dd3adf2a146750e5d7a" }, "packages/rpc/src/channelServer.ts": { - "sourceSha256": "e93d30ddd347d2558960072219b5667cc940f39e2955440f4ae3db6a96a726e1", - "vendoredSha256": "e93d30ddd347d2558960072219b5667cc940f39e2955440f4ae3db6a96a726e1" + "sourceSha256": "327e33d11ce3276eae892e7050446287b9a25cc1948363d918da5b5df1ecf529", + "vendoredSha256": "327e33d11ce3276eae892e7050446287b9a25cc1948363d918da5b5df1ecf529" }, "packages/rpc/src/channels.shared.ts": { - "sourceSha256": "d7faaf2affcb028355501e44b0c9bcbc673f7ad4f5c812cbf012d33260517586", - "vendoredSha256": "d7faaf2affcb028355501e44b0c9bcbc673f7ad4f5c812cbf012d33260517586" + "sourceSha256": "b258b76cf9bd792b117b0dc4c1ef7a4ee1e7245ab878c5c7ffe07b33a07c3bf6", + "vendoredSha256": "b258b76cf9bd792b117b0dc4c1ef7a4ee1e7245ab878c5c7ffe07b33a07c3bf6" }, "packages/rpc/src/channels.ts": { "sourceSha256": "afaba1724055a3d2e6b8b379553569489b71ac6eb252f636ab91649657485209", @@ -99,8 +99,8 @@ "vendoredSha256": "ec5b43e6a3a622a88a8aaa6af9cb37dbfe517932ee7f4a337019ec138bb2d513" }, "packages/rpc/src/serialization.ts": { - "sourceSha256": "e949418e1cd17cc863c147fc8d1ff15237e1b5f0cb8e3344fd2a9ccfae9d54e7", - "vendoredSha256": "e949418e1cd17cc863c147fc8d1ff15237e1b5f0cb8e3344fd2a9ccfae9d54e7" + "sourceSha256": "fd41df3ba2c5e88a52c6b8045b9e0a663b8ee27b54c0f1e146f10d03f6f773bd", + "vendoredSha256": "fd41df3ba2c5e88a52c6b8045b9e0a663b8ee27b54c0f1e146f10d03f6f773bd" }, "packages/shared/src/account-provider-state.ts": { "sourceSha256": "c81ac7579c053458c7fef4cd72b287be016ac43e30e2e107a7e29c22bf67a6ff", @@ -135,16 +135,16 @@ "vendoredSha256": "8e205855dbef21727292730172dfda34deee0b8bdcd2937534f7aeb8b3cbaba7" }, "packages/shared/src/browser-use/command-metadata.ts": { - "sourceSha256": "37eb04347f44f01d1315811be00e131880eb6d1685399f68aab29239bbb7594f", - "vendoredSha256": "37eb04347f44f01d1315811be00e131880eb6d1685399f68aab29239bbb7594f" + "sourceSha256": "6d5c4f248c1204b949175a260b54cf76d13064a7d5a796cadc0fc7a4546e096d", + "vendoredSha256": "6d5c4f248c1204b949175a260b54cf76d13064a7d5a796cadc0fc7a4546e096d" }, "packages/shared/src/browser-use/commands.ts": { - "sourceSha256": "05608884b185005fa81bdc3a1036c923f92ee586e46bce18f8add7d0187e3599", - "vendoredSha256": "05608884b185005fa81bdc3a1036c923f92ee586e46bce18f8add7d0187e3599" + "sourceSha256": "85eeb5c7c7619b77d3602a376a09c29149ab41d811b3c7aa24126c9552400b3f", + "vendoredSha256": "85eeb5c7c7619b77d3602a376a09c29149ab41d811b3c7aa24126c9552400b3f" }, "packages/shared/src/browser-use/result.ts": { - "sourceSha256": "b1fd3bda2e8787c12ab6090c923dd8ac67b8f42b00d84d28e4f5db1e54374599", - "vendoredSha256": "b1fd3bda2e8787c12ab6090c923dd8ac67b8f42b00d84d28e4f5db1e54374599" + "sourceSha256": "8e7d5c35d503323eb8124e1d358abdacc5ee822681a76a49ce15b8326f0a679b", + "vendoredSha256": "8e7d5c35d503323eb8124e1d358abdacc5ee822681a76a49ce15b8326f0a679b" }, "packages/shared/src/browser-use/snapshot.ts": { "sourceSha256": "b11568e155d1aabf9771d4a9e9df98dbd692add80b3adb4d193fb92fd1568168", @@ -186,21 +186,29 @@ "sourceSha256": "49baa10419388ea695d87458f2c0fa614bdd7cfeb57543cc7f0437403b753282", "vendoredSha256": "49baa10419388ea695d87458f2c0fa614bdd7cfeb57543cc7f0437403b753282" }, + "packages/shared/src/gen-ui/contract.ts": { + "sourceSha256": "4157b360b2ad8bed8ca81781da0a7a1d0de10dfebce49328f7090d1dc5606dd9", + "vendoredSha256": "4157b360b2ad8bed8ca81781da0a7a1d0de10dfebce49328f7090d1dc5606dd9" + }, + "packages/shared/src/gen-ui/tweakProtocol.ts": { + "sourceSha256": "474b7bc47a6c4d6fca8620834ac5c09b056c81e8cd938a585d8565200d1cd05a", + "vendoredSha256": "474b7bc47a6c4d6fca8620834ac5c09b056c81e8cd938a585d8565200d1cd05a" + }, "packages/shared/src/highspeed.ts": { "sourceSha256": "2609459989da196ccbeea37c0b931a0957146c62a1d42a1b69c8e46302e0a11d", "vendoredSha256": "2609459989da196ccbeea37c0b931a0957146c62a1d42a1b69c8e46302e0a11d" }, - "packages/shared/src/localTtft.ts": { - "sourceSha256": "b6f6963535fddb455bf6adcf1c82e08dd609fb2f8bf7b6398c16cd164b3b3597", - "vendoredSha256": "b6f6963535fddb455bf6adcf1c82e08dd609fb2f8bf7b6398c16cd164b3b3597" + "packages/shared/src/local-ttft/contract.ts": { + "sourceSha256": "e82222d26ca0ae1b7eac479ee80516d682cfa9faec4188c9bfbb7c0f5b78e793", + "vendoredSha256": "e82222d26ca0ae1b7eac479ee80516d682cfa9faec4188c9bfbb7c0f5b78e793" }, "packages/shared/src/mcp-apps/appTools.ts": { "sourceSha256": "56e79ed990a404269084450bb4eec4297df07b43de5a5b0399123c56342483b4", "vendoredSha256": "56e79ed990a404269084450bb4eec4297df07b43de5a5b0399123c56342483b4" }, "packages/shared/src/mcp-apps/contract.ts": { - "sourceSha256": "cff9fc58409e44847caca49b132405343293f37844e487c329ffb39c67d5da99", - "vendoredSha256": "cff9fc58409e44847caca49b132405343293f37844e487c329ffb39c67d5da99" + "sourceSha256": "68dc3bdc9da3ab1b5059a4b4fc5ff42fe8b75e28ee464a143503792edcaebf11", + "vendoredSha256": "68dc3bdc9da3ab1b5059a4b4fc5ff42fe8b75e28ee464a143503792edcaebf11" }, "packages/shared/src/mcp-apps/instance.ts": { "sourceSha256": "3488a275435494df1bfd3e271086353712e11971f64aa74f54695aef02ea2612", @@ -247,8 +255,8 @@ "vendoredSha256": "0a1d76699b5d3e74f48a609c6aff8aa76c34a98bc284d18af79364d6c0df83a8" }, "packages/shared/src/official-mcp-auth.ts": { - "sourceSha256": "b54f40f504fd2ba89e34953d93592d66712cff1e16ea5d7cb8c04f5bf6f94ae8", - "vendoredSha256": "b54f40f504fd2ba89e34953d93592d66712cff1e16ea5d7cb8c04f5bf6f94ae8" + "sourceSha256": "5321d0453dd35e479112e2812194ec21c5f30839220bc62f6bae7b24bd2653dd", + "vendoredSha256": "5321d0453dd35e479112e2812194ec21c5f30839220bc62f6bae7b24bd2653dd" }, "packages/shared/src/official-mcp-tool-error.ts": { "sourceSha256": "74f966961b89565e035b50b93523cd643c9fe4f61cca4fab70e8c8759ef3fcc8", @@ -259,8 +267,8 @@ "vendoredSha256": "e6889f1d4d6c9829019dc07053872d15ae0af2a1d25aeb97d143dc857fc13c29" }, "packages/shared/src/protocol.ts": { - "sourceSha256": "e3027a8167865cae5cec16e9aa033bbcb4fd960739e4d9d47bfb2e7de220d639", - "vendoredSha256": "e3027a8167865cae5cec16e9aa033bbcb4fd960739e4d9d47bfb2e7de220d639" + "sourceSha256": "276788a10e788fd47b240912dd88e0f8659f600e4ea91f25e7bfee3462d7911e", + "vendoredSha256": "276788a10e788fd47b240912dd88e0f8659f600e4ea91f25e7bfee3462d7911e" }, "packages/shared/src/provider-family-connection-selection.ts": { "sourceSha256": "6476dca87ec40391ba3545dae56c920f6d4785e08e28d49528458ebd46ad4600", @@ -279,40 +287,40 @@ "vendoredSha256": "a269a81caa49d292f257c98b538533cf9ba630978611b550614d766d4999a504" }, "packages/shared/src/request-security-edition/verification-policy.ts": { - "sourceSha256": "8cc61deede90d2456e1bd077b885ac600692efa8e62baf6beaa984f76f59d7b5", - "vendoredSha256": "8cc61deede90d2456e1bd077b885ac600692efa8e62baf6beaa984f76f59d7b5" + "sourceSha256": "8e3f05756f1171703aa70d86fdc9a3d2229fa4735702ead5db7fab207ebe7f0b", + "vendoredSha256": "8e3f05756f1171703aa70d86fdc9a3d2229fa4735702ead5db7fab207ebe7f0b" }, "packages/shared/src/runtimeEnv.ts": { - "sourceSha256": "3e74414915d475ebf90ee68d2d2b25f0470aeb8692277e9555ed60d596a0f650", - "vendoredSha256": "3e74414915d475ebf90ee68d2d2b25f0470aeb8692277e9555ed60d596a0f650" + "sourceSha256": "2fce0f407600a8a07d73be3701efadfe28680025a9e239435afc6459f5278d9f", + "vendoredSha256": "2fce0f407600a8a07d73be3701efadfe28680025a9e239435afc6459f5278d9f" }, "packages/shared/src/server-remote.ts": { - "sourceSha256": "3964763479e5eae5b78d4ce708c24dfbd6a171e82605542e64b6eb200835e576", - "vendoredSha256": "3964763479e5eae5b78d4ce708c24dfbd6a171e82605542e64b6eb200835e576" + "sourceSha256": "c8066b73fe48dc099406be29ceb705e1697ae1ad8669820af905fa3f50d0a9af", + "vendoredSha256": "c8066b73fe48dc099406be29ceb705e1697ae1ad8669820af905fa3f50d0a9af" }, "packages/shared/src/settings-source.ts": { "sourceSha256": "2599bf5f47df27072065d08e4a0ae0eb57ed7c32873b1e60feaaaf39f5b8466e", "vendoredSha256": "2599bf5f47df27072065d08e4a0ae0eb57ed7c32873b1e60feaaaf39f5b8466e" }, "packages/shared/src/source-server/compatibility.ts": { - "sourceSha256": "760e5a54357c72ede3980690accee056eb15563913790bbce109b3b22a1b06e8", - "vendoredSha256": "760e5a54357c72ede3980690accee056eb15563913790bbce109b3b22a1b06e8" + "sourceSha256": "e28f37952a690f5d448ca24d71f2eab158d3ec8483cbfbb4ac3b5b12b0e5cdb0", + "vendoredSha256": "e28f37952a690f5d448ca24d71f2eab158d3ec8483cbfbb4ac3b5b12b0e5cdb0" }, "packages/shared/src/source-server/contracts.ts": { - "sourceSha256": "12f1dcab1199b7f459c673b6d7bf75461659c925c17ddeeca8fcd663b0ccdde5", - "vendoredSha256": "060a411338f1cd86104e0c111178ca1588897eb2f194355dc656851e907628d8" + "sourceSha256": "e7fa08d2ef558d1c5e73c229044b43073c1137cd3b60f97d903ace6fae63c1f8", + "vendoredSha256": "7d075bfb140061d98a2af26152a6e17cf23730c946a2a3657fcb1706c1d9f9ae" }, "packages/shared/src/source-server/errorCodes.ts": { - "sourceSha256": "38da93eabf6508c206f10708235d0743a4509214efba5eb06c66e65d3cc6cd56", - "vendoredSha256": "38da93eabf6508c206f10708235d0743a4509214efba5eb06c66e65d3cc6cd56" + "sourceSha256": "de3526e4195bc045b4e64090509d4f596e07c8b4f3055ec7e2764e3158f7ce8e", + "vendoredSha256": "de3526e4195bc045b4e64090509d4f596e07c8b4f3055ec7e2764e3158f7ce8e" }, "packages/shared/src/sqlite-migrations/contract.ts": { "sourceSha256": "a4e292393a0b08f180cb307d2ad9d169573eef5976f529646709b0d285ae7505", "vendoredSha256": "a4e292393a0b08f180cb307d2ad9d169573eef5976f529646709b0d285ae7505" }, "packages/shared/src/subagent-profile.ts": { - "sourceSha256": "18cc59f19f9cb016b12d8a78543bd283c937b5cfde53ea7a06c574805c7b09d7", - "vendoredSha256": "18cc59f19f9cb016b12d8a78543bd283c937b5cfde53ea7a06c574805c7b09d7" + "sourceSha256": "a74c3cb3dfa2146a1282b4799f3c63372142498402f8e95e3ad8e7e03a45d61f", + "vendoredSha256": "a74c3cb3dfa2146a1282b4799f3c63372142498402f8e95e3ad8e7e03a45d61f" }, "packages/shared/src/subagent-runtime-config.ts": { "sourceSha256": "82cee4df76835bb37f934ca8a922ffbf32b539e200127c0d288ffb6d2b75eba2", @@ -331,8 +339,8 @@ "vendoredSha256": "bf0ee2afd42bd9f9dd1e3a44babcd3fc664ad9c572e8d7dfb6e466db2c857c6b" }, "packages/shared/src/validationAppSettings.ts": { - "sourceSha256": "2b82b3b730ab25c981faf8bdc2892225974a03da8c3ccca7a0c430acc993071a", - "vendoredSha256": "2b82b3b730ab25c981faf8bdc2892225974a03da8c3ccca7a0c430acc993071a" + "sourceSha256": "52580fd34156d512381cce546e75c8d427de080db6fce55ffc10b9e0f541bfcd", + "vendoredSha256": "52580fd34156d512381cce546e75c8d427de080db6fce55ffc10b9e0f541bfcd" }, "packages/shared/src/version.ts": { "sourceSha256": "76560f6f961c947d6fcd5d5c1f15302945bfff1886c490547036b9b7fa443f2c", @@ -355,20 +363,20 @@ "vendoredSha256": "47ccb08304cf2a24f4795dc6ded2ef5712d1ee1bad5c8bffb4d6081dc86dcde1" }, "packages/shared/src/zcode-protocol-legacy-types.ts": { - "sourceSha256": "c2ea249353347f1a1d1e6ec056e48d4460b6ee506c8a8c213de3385a9cf97719", - "vendoredSha256": "c2ea249353347f1a1d1e6ec056e48d4460b6ee506c8a8c213de3385a9cf97719" + "sourceSha256": "56daaebdd9aadf82dd696d5278890c3d22b7c267e8da22760f1d5f66483eb07a", + "vendoredSha256": "56daaebdd9aadf82dd696d5278890c3d22b7c267e8da22760f1d5f66483eb07a" }, "packages/shared/src/zcode-protocol-v4/apply.ts": { - "sourceSha256": "66c5d9d498b33ab0c91908ce914062610f7b39c083f094d4ed21cac8c0d70ab9", - "vendoredSha256": "66c5d9d498b33ab0c91908ce914062610f7b39c083f094d4ed21cac8c0d70ab9" + "sourceSha256": "74e32d004162cac09e2dc219a33e3ce67f7b8f6796781a71c8eb4e4c65fdfef9", + "vendoredSha256": "74e32d004162cac09e2dc219a33e3ce67f7b8f6796781a71c8eb4e4c65fdfef9" }, "packages/shared/src/zcode-protocol-v4/attachment-ref.ts": { "sourceSha256": "aac64e061641380dbfa3df523a9c84eac5c485e6bec770723480e005a7107c52", "vendoredSha256": "aac64e061641380dbfa3df523a9c84eac5c485e6bec770723480e005a7107c52" }, "packages/shared/src/zcode-protocol-v4/command.ts": { - "sourceSha256": "11fe9b6e498f901b0fc542b7346d18211852935b81f270edee78856cfdfcdffa", - "vendoredSha256": "11fe9b6e498f901b0fc542b7346d18211852935b81f270edee78856cfdfcdffa" + "sourceSha256": "29637915c24fe6c11db6abbb54112a9594aec09771ed017df35a316b15fce438", + "vendoredSha256": "29637915c24fe6c11db6abbb54112a9594aec09771ed017df35a316b15fce438" }, "packages/shared/src/zcode-protocol-v4/core.ts": { "sourceSha256": "97750a7bab0a7580c1d27c8e0155981786fdbfa07373d46c77829f25eb407a39", @@ -387,16 +395,16 @@ "vendoredSha256": "b9e3f0aaad5b356f2add8461fe4b3b1813fc3ea7991499df593606429a062d99" }, "packages/shared/src/zcode-protocol-v4/delta.ts": { - "sourceSha256": "6a6e73d341d0d7bf78da5e95844ed3f329ecba56eb39880f295840fc6b77c2ae", - "vendoredSha256": "6a6e73d341d0d7bf78da5e95844ed3f329ecba56eb39880f295840fc6b77c2ae" + "sourceSha256": "e91ed45f22f8084a1e0753ad2281272d177dbcf88e3da539e8ad9828649cf6a5", + "vendoredSha256": "e91ed45f22f8084a1e0753ad2281272d177dbcf88e3da539e8ad9828649cf6a5" }, "packages/shared/src/zcode-protocol-v4/input-intent.ts": { - "sourceSha256": "6ee238b780411c6d0364e042d547d98c5efe740ebc84580020e6336016431243", - "vendoredSha256": "6ee238b780411c6d0364e042d547d98c5efe740ebc84580020e6336016431243" + "sourceSha256": "c3cb9c435c1084263cda70ca9f5335a8c97b54cb76ad141193eb1c8b3dde5e6b", + "vendoredSha256": "c3cb9c435c1084263cda70ca9f5335a8c97b54cb76ad141193eb1c8b3dde5e6b" }, "packages/shared/src/zcode-protocol-v4/rows.ts": { - "sourceSha256": "4a103cd75457586744d1429e0c31ef5f36df4da76af06512881f4d9ea0fe84ee", - "vendoredSha256": "4a103cd75457586744d1429e0c31ef5f36df4da76af06512881f4d9ea0fe84ee" + "sourceSha256": "66b5283041376ac746ac4e17e48eba60548624195e80f27c4174f568f44123c0", + "vendoredSha256": "66b5283041376ac746ac4e17e48eba60548624195e80f27c4174f568f44123c0" }, "packages/shared/src/zcode-protocol-v4/session-config.ts": { "sourceSha256": "9a261de2b2c5bfc7d6cf8dd10598a9dc681bc54dbe1b46e753cf9909fd9b51a0", @@ -419,8 +427,8 @@ "vendoredSha256": "660f6beb529f853660994f22a56149761cb7c775abb3ea047b3fdd5518294c76" }, "packages/shared/src/zcode-protocol-v4/snapshot.ts": { - "sourceSha256": "0883d7e7b7759d3d08fb910ad45dbfbf10d4c68fa3cce3409ad89efa7678ff59", - "vendoredSha256": "0883d7e7b7759d3d08fb910ad45dbfbf10d4c68fa3cce3409ad89efa7678ff59" + "sourceSha256": "a5c15567e5f0738171158f3d57511e1a6d8a2001d721ef8803d94fdba9c8b975", + "vendoredSha256": "a5c15567e5f0738171158f3d57511e1a6d8a2001d721ef8803d94fdba9c8b975" }, "packages/shared/src/zcode-protocol-v4/submission.ts": { "sourceSha256": "aba9b3d2140065615398429fe1404806b453ae5d854dce05e7c3b4271b0b3c57", @@ -431,8 +439,8 @@ "vendoredSha256": "843ecf6e3d99e8ae602b8a9b106d966f42cfd4d8bd339fc180443737ba8ab964" }, "packages/shared/src/zcode-protocol-v4/transport.ts": { - "sourceSha256": "1e810aecdb469054e998bd789b6fa28558082782e4119a60ac7342d2969f3326", - "vendoredSha256": "1e810aecdb469054e998bd789b6fa28558082782e4119a60ac7342d2969f3326" + "sourceSha256": "42369d8e05d6a093e546c48758028013008d8072cbb54b60409aed07ac09c0cb", + "vendoredSha256": "42369d8e05d6a093e546c48758028013008d8072cbb54b60409aed07ac09c0cb" }, "packages/shared/src/zcode-protocol-v4/wire-assembler.ts": { "sourceSha256": "2ec210289bce920de3ebdb2dec324764ecd1b3d2620d185ea484f2ba7a2c6be1", @@ -467,8 +475,8 @@ "vendoredSha256": "4b21c1e4cbd10ca616c6a590cf1a44dab773a4458a2ec3e8bafee43dbc3466f5" }, "packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts": { - "sourceSha256": "033284846970c574986c3266a95c609c920eb34463f2a7314071bc78c8802524", - "vendoredSha256": "033284846970c574986c3266a95c609c920eb34463f2a7314071bc78c8802524" + "sourceSha256": "fec248584e49a9cbe19a1c6b8fcae48b21c9e02d25a461f1e6453a4943cd356b", + "vendoredSha256": "fec248584e49a9cbe19a1c6b8fcae48b21c9e02d25a461f1e6453a4943cd356b" }, "packages/shared/src/zcode-protocol-v4/workflow-run-settings-command.ts": { "sourceSha256": "81d6ef57823aa2800b8f2cd88dacd1ea62e66b1542d5be970246fd7cc7a0bc82", @@ -491,8 +499,8 @@ "vendoredSha256": "ff8b264a361862e5575145e635c0fa108a2ac7d82091764713e0a40b17a36ce7" }, "packages/shared/src/zcode-protocol/index.ts": { - "sourceSha256": "2e9444710aad5f52e7921bbc3e16adf4ae7c7d808f7078fa186155a3603ca103", - "vendoredSha256": "2e9444710aad5f52e7921bbc3e16adf4ae7c7d808f7078fa186155a3603ca103" + "sourceSha256": "5659f3519bda4563d253fd5420e26ce23233c6ceb01a85d4234654420f41d873", + "vendoredSha256": "5659f3519bda4563d253fd5420e26ce23233c6ceb01a85d4234654420f41d873" }, "packages/shared/src/zcode-protocol/trace.ts": { "sourceSha256": "8d91e253aab67fed52e5b0e628126afad50a7ccdccc03a738c2c89f7460c417b", diff --git a/test/provider.test.ts b/test/provider.test.ts index 744dd06..31878fd 100644 --- a/test/provider.test.ts +++ b/test/provider.test.ts @@ -378,6 +378,58 @@ it("keeps the generic turn failure when ZCode reports no error", async () => { error: { code: "NATIVE_TURN_FAILED", message: "ZCode turn failed." }, }); }); +it("warns once about untrusted project MCP servers only when the project's configuration is used", async () => { + const admission = (digest: string) => + [ + { + op: "state.updated" as const, + patch: { + workspaceMcpAdmission: { pendingCount: 1, bundleDigest: digest }, + }, + }, + ] as const; + const compaction = (f: Awaited>) => + f.host.append({ + ...f.host.rowBase(), + kind: "timelineMarker", + marker: { type: "compact", origin: "auto", status: "success" }, + }); + const notices = (f: Awaited>) => + f.events.flatMap((e) => + e.type === "timeline.item" && e.item.type === "notification" + ? [e.item.message] + : [], + ); + const project = await fixture(); + await project.open(); + await project.host.deltas([...admission("a".repeat(64))]); + await project.host.deltas([...admission("b".repeat(64))]); + await compaction(project); + await project.wait( + (e) => + e.type === "timeline.item" && + e.item.type === "notification" && + e.item.message.startsWith("Context compaction"), + ); + expect(notices(project)).toEqual([ + "ZCode has not started this project's MCP servers because they are not trusted. Trust them in ZCode Desktop under Settings → MCP Servers, then start a new session.", + "Context compaction: success", + ]); + // Paseo's servers replace the project's, which ZCode still counts. + const paseo = await fixture(); + await paseo.open({ + mcpServers: { paseo: { type: "http", url: "http://127.0.0.1/mcp" } }, + }); + await paseo.host.deltas([...admission("a".repeat(64))]); + await compaction(paseo); + await paseo.wait( + (e) => + e.type === "timeline.item" && + e.item.type === "notification" && + e.item.message.startsWith("Context compaction"), + ); + expect(notices(paseo)).toEqual(["Context compaction: success"]); +}); it("shows model change markers only while the setting is on when first seen", async () => { const preferences = { showModelChanges: false }; const f = await fixture(() => preferences);