feat(harness-pi): add agentDir option to createPi for reusing CLI config#16492
Open
Albert-Gao wants to merge 4 commits into
Open
feat(harness-pi): add agentDir option to createPi for reusing CLI config#16492Albert-Gao wants to merge 4 commits into
agentDir option to createPi for reusing CLI config#16492Albert-Gao wants to merge 4 commits into
Conversation
… config ## Background The Pi harness currently hardcodes a per-session temp directory for `AuthStorage`, `ModelRegistry`, and uses `SettingsManager.inMemory()`. This means the harness cannot reuse a user's existing CLI login (`~/.pi/agent/auth.json`), model config (`models.json`), or settings (`settings.json` including `defaultProvider`/`defaultModel`). When embedding the Pi harness in a host application that wants to reuse the user's interactive CLI credentials (zero-setup auth), there is no way to point the harness at the user's agent directory. ## Summary Add an optional `agentDir` field to `PiHarnessSettings` and `CreatePiSessionInput`. When provided, the harness constructs `AuthStorage`, `ModelRegistry`, and `SettingsManager` against that directory instead of the temp dir. When omitted, behavior is unchanged (temp dir + `inMemory` settings) — purely additive, non-breaking. ## Manual Verification Unit tests added in `pi-session.test.ts` covering both paths: - `agentDir` provided → `AuthStorage.create` / `ModelRegistry.create` called with paths under `agentDir`, `SettingsManager.create` used - `agentDir` omitted → `SettingsManager.inMemory` used (existing behavior)
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.
Summary
Add an optional
agentDirfield toPiHarnessSettingsandCreatePiSessionInput. When provided, the harness constructsAuthStorage,ModelRegistry, andSettingsManageragainst that directory instead of the per-session temp dir. When omitted, behavior is unchanged — purely additive, non-breaking.This lets host applications reuse a user's existing Pi CLI login (
~/.pi/agent/auth.json), model config (models.json), and settings (settings.jsonincludingdefaultProvider/defaultModel) without managing credentials themselves.Manual Verification
Unit tests added in
pi-session.test.tscovering both paths:agentDirprovided →AuthStorage.create/ModelRegistry.createcalled with paths underagentDir,SettingsManager.createusedagentDiromitted →SettingsManager.inMemoryused (existing behavior preserved)Checklist
pnpm changesetin the project root)Related Issues
Fixes #16491