Skip to content

Commit 61eb7b9

Browse files
authored
fix(agents): keep guided auth atomic through creation (#126096)
* fix(agents): make guided auth creation atomic * fix(auth): keep staged agent workspace explicit * test(auth): use managed temp directory * fix(gateway): finish detached lifecycle dispatch migration * fix(auth): carry staged workspace through providers * test(auth): align mocks with batch persistence
1 parent f3c076c commit 61eb7b9

23 files changed

Lines changed: 807 additions & 167 deletions

‎extensions/cloudflare-ai-gateway/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export default definePluginEntry({
9999
? (ctx.secretInputMode ?? "plaintext")
100100
: ctx.secretInputMode,
101101
config: ctx.config,
102+
workspaceDir: ctx.workspaceDir,
102103
expectedProviders: [PROVIDER_ID],
103104
provider: PROVIDER_ID,
104105
envLabel: PROVIDER_ENV_VAR,

‎extensions/lmstudio/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export default definePluginEntry({
190190
return await providerSetup.promptAndConfigureLmstudioInteractive({
191191
config: ctx.config,
192192
agentDir: ctx.agentDir,
193+
workspaceDir: ctx.workspaceDir,
193194
prompter: ctx.prompter,
194195
secretInputMode: ctx.secretInputMode,
195196
allowSecretRefPrompt: ctx.allowSecretRefPrompt,

‎extensions/lmstudio/src/setup.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ export async function prepareAppGuidedLmstudioSetup(
508508
export async function promptAndConfigureLmstudioInteractive(params: {
509509
config: OpenClawConfig;
510510
agentDir?: string;
511+
workspaceDir?: string;
511512
prompter?: WizardPrompter;
512513
secretInputMode?: SecretInputMode;
513514
allowSecretRefPrompt?: boolean;
@@ -541,6 +542,7 @@ export async function promptAndConfigureLmstudioInteractive(params: {
541542
: params.prompter
542543
? await ensureApiKeyFromEnvOrPrompt({
543544
config: params.config,
545+
workspaceDir: params.workspaceDir,
544546
provider: PROVIDER_ID,
545547
envLabel: LMSTUDIO_DEFAULT_API_KEY_ENV_VAR,
546548
promptMessage: `${LMSTUDIO_PROVIDER_LABEL} API key`,

‎extensions/microsoft-foundry/auth.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export const apiKeyAuthMethod: ProviderAuthMethod = {
235235
? (ctx.secretInputMode ?? "plaintext")
236236
: ctx.secretInputMode,
237237
config: ctx.config,
238+
workspaceDir: ctx.workspaceDir,
238239
expectedProviders: [PROVIDER_ID],
239240
provider: PROVIDER_ID,
240241
envLabel: "AZURE_OPENAI_API_KEY",

‎extensions/ollama/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ export default definePluginEntry({
10501050
const result = await promptAndConfigureOllama({
10511051
cfg: ctx.config,
10521052
env: ctx.env,
1053+
workspaceDir: ctx.workspaceDir,
10531054
opts: ctx.opts as Record<string, unknown> | undefined,
10541055
prompter: ctx.prompter,
10551056
...(ctx.signal ? { signal: ctx.signal } : {}),

‎extensions/ollama/src/setup.runtime.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export async function checkOllamaCloudAuth(
147147
async function promptForOllamaCloudCredential(params: {
148148
cfg: OpenClawConfig;
149149
env?: NodeJS.ProcessEnv;
150+
workspaceDir?: string;
150151
opts?: Record<string, unknown>;
151152
prompter: WizardPrompter;
152153
secretInputMode?: SecretInputMode;
@@ -169,6 +170,7 @@ async function promptForOllamaCloudCredential(params: {
169170
: params.secretInputMode,
170171
config: params.cfg,
171172
env: params.env,
173+
workspaceDir: params.workspaceDir,
172174
expectedProviders: ["ollama"],
173175
provider: "ollama",
174176
envLabel: "OLLAMA_API_KEY",
@@ -383,6 +385,7 @@ async function promptAndConfigureHostBackedOllama(params: {
383385
export async function promptAndConfigureOllama(params: {
384386
cfg: OpenClawConfig;
385387
env?: NodeJS.ProcessEnv;
388+
workspaceDir?: string;
386389
opts?: Record<string, unknown>;
387390
prompter: WizardPrompter;
388391
secretInputMode?: SecretInputMode;
@@ -405,6 +408,7 @@ export async function promptAndConfigureOllama(params: {
405408
const { credential, credentialMode, discoveryApiKey } = await promptForOllamaCloudCredential({
406409
cfg: params.cfg,
407410
env: params.env,
411+
workspaceDir: params.workspaceDir,
408412
opts: params.opts,
409413
prompter: params.prompter,
410414
secretInputMode: params.secretInputMode,

‎extensions/pixverse/index.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function registerPixVerseProvider() {
2424
function createRuntimeContext(
2525
region: "international" | "cn",
2626
config: Record<string, unknown> = {
27+
agents: { entries: { main: {}, work: { workspace: "/tmp/pixverse-workspace" } } },
2728
models: {
2829
providers: {
2930
pixverse: {
@@ -42,6 +43,7 @@ function createRuntimeContext(
4243
const ctx = {
4344
config,
4445
env: {},
46+
workspaceDir: "/tmp/pixverse-workspace",
4547
prompter: {
4648
intro: vi.fn(),
4749
outro: vi.fn(),

‎extensions/pixverse/onboard.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ async function runPixVerseApiKeyAuth(ctx: ProviderAuthContext): Promise<PixVerse
144144
: ctx.secretInputMode,
145145
config: ctx.config,
146146
env: ctx.env,
147+
workspaceDir: ctx.workspaceDir,
147148
expectedProviders: [PIXVERSE_PROVIDER_ID],
148149
provider: PIXVERSE_PROVIDER_ID,
149150
envLabel: "PIXVERSE_API_KEY",

‎extensions/xiaomi/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ async function runXiaomiApiKeyAuth(
191191
: ctx.secretInputMode,
192192
config: ctx.config,
193193
env: ctx.env,
194+
workspaceDir: ctx.workspaceDir,
194195
expectedProviders: [params.providerId],
195196
provider: params.providerId,
196197
envLabel: params.envVar,

‎extensions/zai/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ async function runZaiApiKeyAuth(
187187
? (ctx.secretInputMode ?? "plaintext")
188188
: ctx.secretInputMode,
189189
config: ctx.config,
190+
workspaceDir: ctx.workspaceDir,
190191
expectedProviders: [PROVIDER_ID, "z-ai"],
191192
provider: PROVIDER_ID,
192193
envLabel: "ZAI_API_KEY",

0 commit comments

Comments
 (0)