Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
Merge remote-tracking branch 'upstream/main' into fix/optional-client-cert
yixin907e0edfec8e
diff --cc docs/adr/provider-metadata-client-certificate-retry.mdindex f5742f92f,000000000..8e76710acmode 100644,000000..100644--- a/docs/adr/provider-metadata-client-certificate-retry.md+++ b/docs/adr/provider-metadata-client-certificate-retry.md@@@ -1,58 -1,0 +1,58 @@@- # Provider metadata recovery from optional client certificate requests++# ADR: Provider metadata recovery from optional client certificate requests++- Status: Implemented candidate+- Date: 2026-10-16+- Related: issue #1676, ADR 0177, `03-runtime/07-process-model.md`++## Context++Electron 43's net module leaves its client certificate responder unimplemented.+A server requesting an optional client certificate therefore aborts model+metadata discovery with `net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED` before HTTP is+sent, even when it accepts an empty client identity. An app-level+`select-client-certificate` listener cannot reach that path. Electron #52162+fixes it in 44, but that release also removes macOS 12 support and changes the+clipboard API. This repair retains the existing platform compatibility.++## Decision++Keep Chromium as the primary transport. Extract the metadata transport from+model discovery and connection probes. On exactly the client-auth-certificate+error, retry that HTTPS GET or OPTIONS once through Node TLS, without a client+identity. Do not install a global fetch fallback or retry agent turns, plugin+requests, ordinary HTTP responses, unrelated TLS failures or cancelled work.++The retry uses the existing authenticated loopback SOCKS relay. Its resolver+consults the default Chromium session, including the active System/PAC, Direct,+custom proxy and bypass configuration. There is no direct fallback when proxy+routing fails. The request retains its original AbortSignal and manual redirect+mode; the existing model discovery origin guard remains the only redirect owner.++Use bundled/default and OS CA roots per request, without changing process-wide+TLS settings or disabling chain, expiration or hostname verification. The+metadata attempt owns its tunnel, TLS socket and HTTP agent through response+consumption and closes them on success, failure or cancellation. A tunnel that+completes after cancellation is destroyed on arrival; the underlying existing+SOCKS handshake remains bounded by its own timeout.++## Consequences++Optional client authentication reaches ordinary HTTP responses; mandatory client+authentication still fails. There are no persistence, IPC or plugin contract+changes. The Node retry inherits the existing relay limitation for interactive+or OS-integrated proxy authentication and fails closed in those environments.++A focused Electron E2E reproduces the original failure and exercises actual+model discovery and connection tests through direct and authenticated proxy+routes. Lower-level TLS tests cover trust, hostname validation, mandatory client+authentication, redirects, compressed metadata and cancellation.++## Alternatives++- Electron 44: the upstream solution, but requires a separate platform/API+ migration decision. Remove the compatibility retry when a validated runtime+ provides native recovery and an explicit client-identity policy.+- Only add an app event handler: Electron 43 never emits it for net requests.+- Replace global fetch with Node: changes unrelated networking, cookies, proxy+ authentication and plugin behavior.+- Disable server certificate checks: unrelated to the root cause and unsafe.diff --cc docs/spec/06-delivery/04-e2e-test-plan.mdindex 9ac37f1ba,fc3b8c260..7d0919282--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@@ -18167,34 -18173,47 +18174,72 @@@ host-created files. The full app's file- **Acceptance**: The "is anything running under here?" answer is availablefrom a collapsed project group, and each affordance can be switched offindependently through a persisted setting.+ - **Status**: Draft. Existing unit coverage in+ `apps/desktop/test/sidebar-project-runs.test.mjs` covers count+ classification, master/sub-switch gating, both render call sites, and+ theme-token and reduced-motion guarantees. It does not exercise settings+ API default normalization or the full interaction; those remain manual+ validation in a capable environment.++ ### E2E-267: A plugin follows the selected session and opens its own view++ - **Preconditions**: A development plugin that declares one+ `contributes.views` entry and holds `ui.view`, and whose command calls+ `pi.session.getActive()`, subscribes to `pi.events.on("session:activated")`,+ and then calls `pi.ui.revealView({ location: "src/App.tsx" })`. Two sessions+ exist in different projects; one of them is running a turn.+ - **Steps**:+ 1. Select the idle session and run the plugin's command.+ 2. Switch to the other project's session and start a turn; re-check the+ payload the plugin reported.+ 3. While that turn runs, run the plugin's command and inspect the work panel.+ 4. Switch to the first session, then run the plugin's command again from a+ stale reference to the previous session id.+ 5. Disable the plugin and re-open the same work-panel tab.+ - **Expected**: `pi.session.getActive()` answers with the session on screen, its+ project path, and `activeTurn: null` while it is idle. `session:activated`+ arrives once per real change — a selection switch, a project change, and the+ turn starting or finishing — and the running session reports the durable+ `turnId` with its start time rather than an inferred one. `pi.ui.revealView`+ opens the plugin's view as a work-panel tab of the active session and focuses+ it, and the view receives `src/App.tsx` through `piViewOpen`/`view:open`+ without being reloaded when it is already open. A call naming a session the+ user left fails with `INVALID_ARGUMENT` and opens nothing. Revealing without+ `ui.view` fails with `PERMISSION_DENIED`. With the plugin disabled the tab+ reports the missing view instead of showing stale content.+ - **Specs linked**: `07-plugins/03-plugin-api.md` §ui, §session follow, §5+ events, §6 panel bridge; ADR 0331.+ - **Acceptance**: A plugin can follow the selected session and show its own view+ beside it without importing host internals, and a stale session can never be+ revealed onto a panel the user is no longer looking at.- **Status**: Draft. Unit coverage in- `apps/desktop/test/sidebar-project-runs.test.mjs` covers the count- classification, the master/sub-switch gating, both render call sites, and- the theme-token and reduced-motion guarantees; the interactive sidebar- scenario remains a manual validation scenario run in a capable- environment.+ `apps/desktop/test/plugin-session-follow.test.mjs` (snapshot assembly,+ announcement deduplication, stale-turn and stale-session refusal,+ `ui.view` gating, panel-bridge channel) and the wiring contract in+ `apps/desktop/test/main-wiring-contract.test.mjs`; the interactive Electron+ scenario remains a manual validation run.++### E2E-PROVIDER-optional-client-certificate++- **Preconditions:** The locked Electron 43 runtime, built workspace packages,+ and an isolated profile. Only a local HTTPS fixture and local proxy are used;+ trust is confined to the test process/session and fixture certificate.+- **Steps:** Run `node scripts/e2e-provider-client-certificate.mjs`. Confirm the+ original `net.fetch` aborts before HTTP. Probe the model list and connection+ through the real metadata service; repeat with an invalid fixture key and an+ authenticated custom HTTP proxy. Return a cross-origin redirect, then cancel+ a pending response.+- **Expected:** Valid credentials return the fixture model; invalid credentials+ reach HTTP 401. The retry follows the proxy route, sends no client identity,+ refuses cross-origin redirects and aborts with the original signal.+- **Security coverage:** `provider-https-metadata.test.mjs` additionally checks+ mandatory client authentication, untrusted server certificates, hostname+ mismatch, compressed responses, and late-tunnel cleanup. The metadata policy+ tests reject fallback on other TLS/network errors or HTTP failures.+- **Specs linked:** `03-runtime/07-process-model.md`,+ ADR `provider-metadata-client-certificate-retry`, issue #1676.+- **Acceptance:** Recovery without an Electron major upgrade, TLS verification+ bypass, direct proxy bypass, or change to persisted provider bindings.+- **Milestone:** Maintenance.+- **Status:** Automated fixture; record the tested head/base and execution+ result in the delivery report.diff --cc docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex bfbfd76b2,6783212d8..a399bccf7--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@@ -5723,6 -5723,6 +5723,7 @@@ eleven-tool-round desktop paths are ver## 8. 可追溯性矩阵| 验收 | 应用场景 ||---|---|++| B / Security / Quality — Optional provider client certificate requests | E2E-PROVIDER-optional-client-certificate || C / E / F / Quality / Security — Session Todo checklist | E2E-CHAT-session-todo-checklist || C / E / Security / Quality — Live Voice 四阶段交互 | E2E-LIVE-VOICE-four-stage-ui || C / F — Hourly task updates | E2E-SCHEDULED-manual-to-hourly |