























@@ -262,6 +262,23 @@ function createEmptyAuthProfileStore(): AuthProfileStore {
262262};
263263}
264264265+function createScopedAuthProfileStore(
266+store: AuthProfileStore,
267+profileId: string | undefined,
268+): AuthProfileStore {
269+const normalizedProfileId = profileId?.trim();
270+const profiles = store.profiles ?? {};
271+const credential = normalizedProfileId ? profiles[normalizedProfileId] : undefined;
272+return credential && normalizedProfileId
273+ ? {
274+version: store.version,
275+profiles: {
276+[normalizedProfileId]: credential,
277+},
278+}
279+ : createEmptyAuthProfileStore();
280+}
281+265282function buildTraceToolSummary(params: {
266283toolMetas?: Array<{ toolName: string; meta?: string }>;
267284hadFailure: boolean;
@@ -575,6 +592,11 @@ export async function runEmbeddedPiAgent(
575592 : ensureAuthProfileStoreWithoutExternalProfiles(agentDir, {
576593allowKeychainPrompt: false,
577594});
595+const attemptAuthProfileStore = pluginHarnessOwnsTransport
596+ ? ensureAuthProfileStoreWithoutExternalProfiles(agentDir, {
597+allowKeychainPrompt: false,
598+})
599+ : authStore;
578600const requestedProfileId = params.authProfileId?.trim();
579601const resolvePluginHarnessPreferredProfileId = (): string | undefined => {
580602if (requestedProfileId) {
@@ -595,12 +617,9 @@ export async function runEmbeddedPiAgent(
595617if (!harnessAuthProvider) {
596618return undefined;
597619}
598-const harnessAuthStore = ensureAuthProfileStoreWithoutExternalProfiles(agentDir, {
599-allowKeychainPrompt: false,
600-});
601620return resolveAuthProfileOrder({
602621cfg: params.config,
603-store: harnessAuthStore,
622+store: attemptAuthProfileStore,
604623provider: harnessAuthProvider,
605624})[0]?.trim();
606625};
@@ -777,6 +796,9 @@ export async function runEmbeddedPiAgent(
777796lastProfileId = forwardedPluginHarnessProfileId;
778797}
779798startupStages.mark("auth");
799+const runAttemptAuthProfileStore = pluginHarnessOwnsTransport
800+ ? createScopedAuthProfileStore(attemptAuthProfileStore, lastProfileId)
801+ : attemptAuthProfileStore;
780802const { sessionAgentId } = resolveSessionAgentIds({
781803sessionKey: params.sessionKey,
782804config: params.config,
@@ -1211,7 +1233,7 @@ export async function runEmbeddedPiAgent(
12111233authProfileIdSource: lockedProfileId ? "user" : "auto",
12121234initialReplayState: accumulatedReplayState,
12131235 authStorage,
1214-authProfileStore: authStore,
1236+authProfileStore: runAttemptAuthProfileStore,
12151237 modelRegistry,
12161238agentId: workspaceResolution.agentId,
12171239 legacyBeforeAgentStartResult,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。