mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
refactor(commands): hide onboarding defaults
This commit is contained in:
@@ -1,25 +1,17 @@
|
||||
// Onboard config tests cover workspace, bootstrap, and local setup config mutations.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import {
|
||||
applyLocalSetupWorkspaceConfig,
|
||||
ONBOARDING_DEFAULT_DM_SCOPE,
|
||||
ONBOARDING_DEFAULT_TOOLS_PROFILE,
|
||||
} from "./onboard-config.js";
|
||||
import { applyLocalSetupWorkspaceConfig } from "./onboard-config.js";
|
||||
|
||||
describe("applyLocalSetupWorkspaceConfig", () => {
|
||||
it("defaults local setup tool profile to coding", () => {
|
||||
expect(ONBOARDING_DEFAULT_TOOLS_PROFILE).toBe("coding");
|
||||
});
|
||||
|
||||
it("sets secure dmScope default when unset", () => {
|
||||
const baseConfig: OpenClawConfig = {};
|
||||
const result = applyLocalSetupWorkspaceConfig(baseConfig, "/tmp/workspace");
|
||||
|
||||
expect(result.session?.dmScope).toBe(ONBOARDING_DEFAULT_DM_SCOPE);
|
||||
expect(result.session?.dmScope).toBe("per-channel-peer");
|
||||
expect(result.gateway?.mode).toBe("local");
|
||||
expect(result.agents?.defaults?.workspace).toBe("/tmp/workspace");
|
||||
expect(result.tools?.profile).toBe(ONBOARDING_DEFAULT_TOOLS_PROFILE);
|
||||
expect(result.tools?.profile).toBe("coding");
|
||||
});
|
||||
|
||||
it("preserves existing dmScope when already configured", () => {
|
||||
|
||||
@@ -5,9 +5,9 @@ import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import type { ToolProfileId } from "../config/types.tools.js";
|
||||
|
||||
/** Default DM scoping selected during local onboarding. */
|
||||
export const ONBOARDING_DEFAULT_DM_SCOPE: DmScope = "per-channel-peer";
|
||||
const ONBOARDING_DEFAULT_DM_SCOPE: DmScope = "per-channel-peer";
|
||||
/** Default tool profile selected during local onboarding. */
|
||||
export const ONBOARDING_DEFAULT_TOOLS_PROFILE: ToolProfileId = "coding";
|
||||
const ONBOARDING_DEFAULT_TOOLS_PROFILE: ToolProfileId = "coding";
|
||||
|
||||
/** Applies local gateway/workspace defaults without overwriting explicit user defaults. */
|
||||
export function applyLocalSetupWorkspaceConfig(
|
||||
|
||||
@@ -6,12 +6,13 @@ import {
|
||||
applyCustomApiConfig,
|
||||
buildAnthropicVerificationProbeRequest,
|
||||
buildOpenAiVerificationProbeRequest,
|
||||
CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS,
|
||||
inferCustomModelSupportsImageInput,
|
||||
parseNonInteractiveCustomApiFlags,
|
||||
resolveCustomModelImageInputInference,
|
||||
} from "./onboard-custom-config.js";
|
||||
|
||||
const EXPECTED_CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS = 128_000;
|
||||
|
||||
function buildCustomProviderConfig(contextWindow?: number) {
|
||||
if (contextWindow === undefined) {
|
||||
return {} as OpenClawConfig;
|
||||
@@ -129,17 +130,17 @@ describe("applyCustomApiConfig", () => {
|
||||
{
|
||||
name: "uses stable default context window for newly added custom models",
|
||||
existingContextWindow: undefined,
|
||||
expectedContextWindow: CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS,
|
||||
expectedContextWindow: EXPECTED_CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS,
|
||||
},
|
||||
{
|
||||
name: "upgrades existing custom model context window when below hard minimum",
|
||||
existingContextWindow: 2048,
|
||||
expectedContextWindow: CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS,
|
||||
expectedContextWindow: EXPECTED_CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS,
|
||||
},
|
||||
{
|
||||
name: "raises legacy generated hard-min context window (#79428)",
|
||||
existingContextWindow: CONTEXT_WINDOW_HARD_MIN_TOKENS,
|
||||
expectedContextWindow: CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS,
|
||||
expectedContextWindow: EXPECTED_CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS,
|
||||
},
|
||||
{
|
||||
name: "preserves explicit small context window when already valid",
|
||||
|
||||
@@ -24,7 +24,7 @@ import { normalizeAlias } from "./models/alias-name.js";
|
||||
* Mirrors the generic persisted custom-model catalog fallback and leaves enough
|
||||
* room above the default compaction reserve floor in `agent-settings.ts`.
|
||||
*/
|
||||
export const CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS = 128_000;
|
||||
const CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS = 128_000;
|
||||
const DEFAULT_CONTEXT_WINDOW = CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS;
|
||||
const DEFAULT_MAX_TOKENS = 4096;
|
||||
// Azure OpenAI uses the Responses API, which supports larger generated defaults.
|
||||
|
||||
Reference in New Issue
Block a user