refactor(onboard): share local workspace+gateway config
This commit is contained in:
21
src/commands/onboard-config.ts
Normal file
21
src/commands/onboard-config.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
|
||||
export function applyOnboardingLocalWorkspaceConfig(
|
||||
baseConfig: OpenClawConfig,
|
||||
workspaceDir: string,
|
||||
): OpenClawConfig {
|
||||
return {
|
||||
...baseConfig,
|
||||
agents: {
|
||||
...baseConfig.agents,
|
||||
defaults: {
|
||||
...baseConfig.agents?.defaults,
|
||||
workspace: workspaceDir,
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
...baseConfig.gateway,
|
||||
mode: "local",
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { resolveGatewayPort, writeConfigFile } from "../../config/config.js";
|
||||
import { logConfigUpdated } from "../../config/logging.js";
|
||||
import { DEFAULT_GATEWAY_DAEMON_RUNTIME } from "../daemon-runtime.js";
|
||||
import { healthCommand } from "../health.js";
|
||||
import { applyOnboardingLocalWorkspaceConfig } from "../onboard-config.js";
|
||||
import {
|
||||
applyWizardMetadata,
|
||||
DEFAULT_WORKSPACE,
|
||||
@@ -35,20 +36,7 @@ export async function runNonInteractiveOnboardingLocal(params: {
|
||||
defaultWorkspaceDir: DEFAULT_WORKSPACE,
|
||||
});
|
||||
|
||||
let nextConfig: OpenClawConfig = {
|
||||
...baseConfig,
|
||||
agents: {
|
||||
...baseConfig.agents,
|
||||
defaults: {
|
||||
...baseConfig.agents?.defaults,
|
||||
workspace: workspaceDir,
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
...baseConfig.gateway,
|
||||
mode: "local",
|
||||
},
|
||||
};
|
||||
let nextConfig: OpenClawConfig = applyOnboardingLocalWorkspaceConfig(baseConfig, workspaceDir);
|
||||
|
||||
const inferredAuthChoice = inferAuthChoiceFromFlags(opts);
|
||||
if (!opts.authChoice && inferredAuthChoice.matches.length > 1) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from "../commands/auth-choice.js";
|
||||
import { applyPrimaryModel, promptDefaultModel } from "../commands/model-picker.js";
|
||||
import { setupChannels } from "../commands/onboard-channels.js";
|
||||
import { applyOnboardingLocalWorkspaceConfig } from "../commands/onboard-config.js";
|
||||
import { promptCustomApiConfig } from "../commands/onboard-custom.js";
|
||||
import {
|
||||
applyWizardMetadata,
|
||||
@@ -352,20 +353,7 @@ export async function runOnboardingWizard(
|
||||
|
||||
const workspaceDir = resolveUserPath(workspaceInput.trim() || DEFAULT_WORKSPACE);
|
||||
|
||||
let nextConfig: OpenClawConfig = {
|
||||
...baseConfig,
|
||||
agents: {
|
||||
...baseConfig.agents,
|
||||
defaults: {
|
||||
...baseConfig.agents?.defaults,
|
||||
workspace: workspaceDir,
|
||||
},
|
||||
},
|
||||
gateway: {
|
||||
...baseConfig.gateway,
|
||||
mode: "local",
|
||||
},
|
||||
};
|
||||
let nextConfig: OpenClawConfig = applyOnboardingLocalWorkspaceConfig(baseConfig, workspaceDir);
|
||||
|
||||
const authStore = ensureAuthProfileStore(undefined, {
|
||||
allowKeychainPrompt: false,
|
||||
|
||||
Reference in New Issue
Block a user