Repository navigation
fix(pi): model list loads when the server's folder has a project MCP config #28557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import type { PiSettings } from "../settings.ts"; | |
| import { causeErrorTag } from "@t3tools/shared/observability"; | ||
| import { resolveSpawnCommand } from "@t3tools/shared/shell"; | ||
| import { compareSemverVersions } from "@t3tools/shared/semver"; | ||
| import * as Cause from "effect/Cause"; | ||
| import * as DateTime from "effect/DateTime"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Stream from "effect/Stream"; | ||
|
|
@@ -164,13 +165,31 @@ const makePiDiscoveryConnection = Effect.fnUntraced(function* ( | |
| return connection; | ||
| }); | ||
|
|
||
| const PI_PROJECT_TRUST_ARGUMENTS = new Set(["--approve", "-a", "--no-approve", "-na"]); | ||
|
|
||
| /** | ||
| * The machine probe skips project-local files unless the user picked a trust mode. Pi's RPC mode | ||
| * reads stdin only after session_start, so an extension dialog raised there (an MCP adapter asking | ||
| * to approve a project server) can never be answered and Pi exits 0 without replying. | ||
| */ | ||
| function machineProbeLaunchArgs(launchArgs: ReadonlyArray<string>): ReadonlyArray<string> { | ||
| return launchArgs.some((arg) => PI_PROJECT_TRUST_ARGUMENTS.has(arg)) | ||
| ? launchArgs | ||
| : [...launchArgs, "--no-approve"]; | ||
| } | ||
|
|
||
| const discoverPiViaRpc = Effect.fn("PiProviderStatus.discoverPiViaRpc")(function* ( | ||
| piSettings: PiSettings, | ||
| environment: NodeJS.ProcessEnv, | ||
| launchArgs: ReadonlyArray<string>, | ||
| cwd?: string, | ||
| ) { | ||
| const connection = yield* makePiDiscoveryConnection(piSettings, environment, launchArgs, cwd); | ||
| const connection = yield* makePiDiscoveryConnection( | ||
| piSettings, | ||
| environment, | ||
| machineProbeLaunchArgs(launchArgs), | ||
| cwd, | ||
| ); | ||
| const stateData = yield* connection.request({ type: "get_state" }); | ||
| const modelsData = yield* connection.request({ type: "get_available_models" }); | ||
| const commandsData = yield* connection | ||
|
|
@@ -465,8 +484,11 @@ export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function | |
| cwd, | ||
| ).pipe(Effect.timeoutOption(PI_RPC_DISCOVERY_TIMEOUT_MS), Effect.exit); | ||
| if (Exit.isFailure(discoveryExit)) { | ||
| const failure = Cause.findErrorOption(discoveryExit.cause); | ||
| yield* Effect.logWarning("Pi RPC discovery failed.", { | ||
| errorTag: causeErrorTag(discoveryExit.cause), | ||
| // Pi RPC error messages are bounded and carry no stderr. | ||
| ...(Option.isSome(failure) ? { detail: failure.value.message } : {}), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not log the RPC error message. If Pi returns a failed RPC response, As per coding guidelines, “log annotations stay bounded” and exclude “credentials, query strings, or arbitrary defect text.” Based on learnings, raw provider errors can expose secrets in logs.
|
||
| }); | ||
| return buildServerProvider({ | ||
| presentation: PI_PRESENTATION, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
sed -n 160,200p packages/provider-pi/src/server/status.ts rg -n "approve|cwd|trust" packages/provider-pi/srcRepository: pingdotgg/t3code
Length of output: 9393
Preserve saved project trust during discovery.
When
cwdis a trusted project, the probe appends--no-approveand can omit project-local extensions and settings. Models registered by those extensions can therefore disappear from discovery, while real turns still launch Pi without this probe-only flag. Restrict--no-approveto the startup-dialog fallback, or otherwise preserve the normal trust decision for successful discovery.