Repository navigation
fix(macos): acquire agent credentials per model request - #14368
Merged
Merged
Conversation
Remove startup Firebase/BYOK copies, refresh_token IPC, and the bridge refresh loop. Resolve owner-fenced request headers lazily and retry one managed HTTP 401 before exposing response bytes. Carry typed authentication through the runtime, Sign in recovery, journal status, and telemetry. Keep the full Swift HTTP relay as an explicit follow-up; per-request credentials still cross IPC. Failure-Class: new New class: FC-expiring-authority-copied-into-worker Verification: agent npm build/test (885 tests); extension npm test (143 tests) and direct tsc; Swift build --build-tests and focused credential/chat tests (170 tests), installed Swift 6.4. The pinned Xcode 26.6 is unavailable. Hermetic expiry/offline/recovery, owner fencing, bare 401, BYOK, SSE/cancel, Unix-pipe, and synthetic shell/ps environment probes. No app launched or production request made. Full preflight and harness evidence is in the PR.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and change
Beta v0.12.356 retained a startup Firebase token inside pi-mono for about 15 hours. One offline refresh ended the 45-minute bridge timer; the app recovered its own credentials but the worker kept sending the old token. Its bare
HTTP 401 status code (no body)became an unclassified runtime error and invited futile resends.This PR takes the authorized request-scoped stepping stone. Every pi-mono HTTP attempt obtains current Authorization and usable BYOK headers from Swift/AuthService through the existing Unix pipe. The kernel checks the live run capability before dispatch and after reply; Swift fences the owner session and process generation, including a final same-owner session-generation check immediately before IPC. No token is retained in adapter configuration or the subprocess environment. The 45-minute timer, refresh_token IPC, and token-driven subprocess restart are removed. All four harnesses share the scrubbed Swift launch environment; external harnesses retain their own provider authentication.
The installed pi SDK catches and ignores before_provider_headers exceptions. Credential acquisition therefore runs at fetch, where it can prevent network I/O on failure; the existing header hook supplies correlation/context. Managed 401s force-refresh and replay once before response bytes are exposed. Numeric status is carried over pi JSONL as a typed failure; the existing Swift refresh/retry safety net recognizes managed authentication only. BYOK/third-party 401s do not refresh or invalidate the Omi session. Auth failures show “Your session expired” with Sign in; typed journal metadata renders “Session expired” after reload. Telemetry carries the authentication code.
The existing relay is a tool/control JSONL transport, not an HTTP streaming server. A Swift SSE relay with cancellation, backpressure, header fidelity, and all-harness lifecycle coverage is a larger independent boundary. This PR removes expiry correctness from process lifetime without adding a second live credential path or a migration flag. Credentials still cross IPC and exist in per-request Node memory: this is not full subprocess credential isolation.
Product invariants affected
Failure-Class: new
New class: FC-expiring-authority-copied-into-worker
The new static tripwire supplements behavioral expiry/owner/HTTP tests. It is intentionally scoped to the managed desktop agent boundary, including its explicit request-scoped IPC exception, rather than a general secret scanner. It would have rejected the measured v0.12.356 startup credential copy and refresh-driven restart. The new failure class has no merged evidence PR yet; this incident and this PR are its initial evidence. Existing assumed-lifetime and owner-mutation classes do not describe a correctly issued credential copied into a long-lived worker. Obsolete source assertions requiring token propagation/timer startup were removed; the supplied Beta incident is the external evidence for replacing them with request-time behavioral tests.
Line-Count-Exception: desktop/macos/Desktop/Sources/AuthService.swift | 2867 -> 2868 | Inject the credential clock at its existing owner for the expiry/offline regression
Line-Count-Exception: desktop/macos/Desktop/Sources/MainWindow/Components/ChatBubble.swift | 2158 -> 2162 | Render the typed session-expired row status at the existing status switch
Line-Count-Exception: desktop/macos/Desktop/Sources/Providers/ChatProvider.swift | 7362 -> 7365 | Carry the bounded failure code through the existing failure marker and journal projection
Verification
npm --prefix desktop/macos/agent run build— passed TypeScript compilation and runtime packaging copy.npm --prefix desktop/macos/agent test— 71 files / 885 tests passed, including numeric status propagation with exactHTTP 401 status code (no body)and capability-fenced reply routing.npm --prefix desktop/macos/pi-mono-extension test— 143 tests passed, including injected-clock expiry/offline/recovery, one 401 replay, BYOK/third-party isolation, request-body replay, SSE body preservation, cancellation, and a real Unix-socket exchange.desktop/macos/agent/node_modules/.bin/tsc --noEmit --module nodenext --target es2022 --allowImportingTsExtensions --skipLibCheck desktop/macos/pi-mono-extension/index.ts— passed; the extension has no separate package typecheck script.desktop/macos/scripts/run-swift-ci.sh --select-toolchain— unavailable: current checkout pins Xcode 26.6 at /Applications/Xcode_26.6.app; that installation is absent. Installed toolchain is Apple Swift 6.4 / macOS 27 SDK.xcrun swift build --build-tests --package-path desktop/macos/Desktop— passed on the installed toolchain (app plus all test targets).xcrun swift test --skip-build --package-path desktop/macos/Desktop --filter 'AgentModelCredentialsTests|AuthRefreshResilienceTests|AgentRuntimeProcessTests|ChatTurnFailureNoticeTests|ChatTurnFailurePresentationTests|ChatQueryTelemetryTests|ChatErrorStateTests|AgentRuntimeFailureTests'— 170 tests passed, including the real AuthService expiry/offline/recovery seam and typed journal round trip.desktop/macos/scripts/agent-logic-harness.sh— 803 selected Swift tests passed on retry. The first XCTest run stalled while exiting and was stopped by its own PIDs. The retry's Node stage hit one existing Unix-socket test timeout (884/885 passed) under default parallelism.VITEST_MAX_WORKERS=4 desktop/macos/scripts/agent-logic-harness.sh --node-only— passed all 885 agent tests, generated-tool-surface verification, and all 143 extension tests. This uses the harness's supported concurrency setting without skipping tests or changing timeouts.OMI_PR_BODY_FILE="$PWD/.local/pr-body.md" make preflight— all 36 selected local manifest checks passed (881.33 seconds), including both-lane credential tripwire registration, Swift formatting/lint, runtime conformance, and dead-code checks.scripts/pr-preflight --pr-body-file .local/pr-body.md --metadata-only— all four metadata checks passed on the committed head; the new class uses the protocol's literalFailure-Class: newdeclaration.VITEST_MAX_WORKERS=4 OMI_PR_BODY_FILE="$PWD/.local/pr-body.md" git push -u origin fix/agent-credential-relay— all 36 committed-head manifest checks and the complete outer pre-push gate passed, including desktop debug compile and full tool-surface tests. GitHub closed the idle SSH connection; push exited 141 andgit ls-remotereturned no branch. Only then, as authorized,git push --no-verify -u origin fix/agent-credential-relaytransferred the unchanged verified commit. Remote SHA matches8a13184bfbc62b627a91bc98b2d7b493be0e13c0.python3 desktop/macos/scripts/check-agent-credentials.py— passed tripwire and mutation self-tests; registered in both local and CI manifest lanes.python3 desktop/macos/scripts/check_desktop_test_quality.py— passed.Security measurement: pi's installed
createLocalBashOperationscallsgetShellEnv, which spreads process.env. A synthetic local child probe using that actual helper confirmed OMI_AUTH_TOKEN, OMI_API_KEY, and OMI_BYOK_OPENAI are inherited and visible via/bin/ps eww -p <synthetic-child-pid>before scrubbing, and absent afterward. Only inert values were used; no real process environment or credentials were printed. Existing user-MCP stdio servers already use an allowlist. Adapter spawn tests also exercise scrubbing of injected ambient keys.No app was launched, installed, or driven, and Omi Beta was untouched. No production host was contacted. Hermetic tests/builds are not live app acceptance. No backend code or .github workflow was modified.
Follow-ups