mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 23:51:23 +00:00
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 { logConfigUpdated } from "../../config/logging.js";
|
||||||
import { DEFAULT_GATEWAY_DAEMON_RUNTIME } from "../daemon-runtime.js";
|
import { DEFAULT_GATEWAY_DAEMON_RUNTIME } from "../daemon-runtime.js";
|
||||||
import { healthCommand } from "../health.js";
|
import { healthCommand } from "../health.js";
|
||||||
|
import { applyOnboardingLocalWorkspaceConfig } from "../onboard-config.js";
|
||||||
import {
|
import {
|
||||||
applyWizardMetadata,
|
applyWizardMetadata,
|
||||||
DEFAULT_WORKSPACE,
|
DEFAULT_WORKSPACE,
|
||||||
@@ -35,20 +36,7 @@ export async function runNonInteractiveOnboardingLocal(params: {
|
|||||||
defaultWorkspaceDir: DEFAULT_WORKSPACE,
|
defaultWorkspaceDir: DEFAULT_WORKSPACE,
|
||||||
});
|
});
|
||||||
|
|
||||||
let nextConfig: OpenClawConfig = {
|
let nextConfig: OpenClawConfig = applyOnboardingLocalWorkspaceConfig(baseConfig, workspaceDir);
|
||||||
...baseConfig,
|
|
||||||
agents: {
|
|
||||||
...baseConfig.agents,
|
|
||||||
defaults: {
|
|
||||||
...baseConfig.agents?.defaults,
|
|
||||||
workspace: workspaceDir,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
gateway: {
|
|
||||||
...baseConfig.gateway,
|
|
||||||
mode: "local",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const inferredAuthChoice = inferAuthChoiceFromFlags(opts);
|
const inferredAuthChoice = inferAuthChoiceFromFlags(opts);
|
||||||
if (!opts.authChoice && inferredAuthChoice.matches.length > 1) {
|
if (!opts.authChoice && inferredAuthChoice.matches.length > 1) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from "../commands/auth-choice.js";
|
} from "../commands/auth-choice.js";
|
||||||
import { applyPrimaryModel, promptDefaultModel } from "../commands/model-picker.js";
|
import { applyPrimaryModel, promptDefaultModel } from "../commands/model-picker.js";
|
||||||
import { setupChannels } from "../commands/onboard-channels.js";
|
import { setupChannels } from "../commands/onboard-channels.js";
|
||||||
|
import { applyOnboardingLocalWorkspaceConfig } from "../commands/onboard-config.js";
|
||||||
import { promptCustomApiConfig } from "../commands/onboard-custom.js";
|
import { promptCustomApiConfig } from "../commands/onboard-custom.js";
|
||||||
import {
|
import {
|
||||||
applyWizardMetadata,
|
applyWizardMetadata,
|
||||||
@@ -352,20 +353,7 @@ export async function runOnboardingWizard(
|
|||||||
|
|
||||||
const workspaceDir = resolveUserPath(workspaceInput.trim() || DEFAULT_WORKSPACE);
|
const workspaceDir = resolveUserPath(workspaceInput.trim() || DEFAULT_WORKSPACE);
|
||||||
|
|
||||||
let nextConfig: OpenClawConfig = {
|
let nextConfig: OpenClawConfig = applyOnboardingLocalWorkspaceConfig(baseConfig, workspaceDir);
|
||||||
...baseConfig,
|
|
||||||
agents: {
|
|
||||||
...baseConfig.agents,
|
|
||||||
defaults: {
|
|
||||||
...baseConfig.agents?.defaults,
|
|
||||||
workspace: workspaceDir,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
gateway: {
|
|
||||||
...baseConfig.gateway,
|
|
||||||
mode: "local",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const authStore = ensureAuthProfileStore(undefined, {
|
const authStore = ensureAuthProfileStore(undefined, {
|
||||||
allowKeychainPrompt: false,
|
allowKeychainPrompt: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user