Compare commits

...

4 Commits

Author SHA1 Message Date
Vincent Koc
2b644ace7c fix(infra): extract exec approvals allowlist types 2026-04-09 02:05:11 +01:00
Vincent Koc
81c6e9ad8f fix(commands): split auth choice apply types 2026-04-09 02:03:04 +01:00
Vincent Koc
02ee512367 fix(config): stop owner-display barrel cycles 2026-04-09 02:01:27 +01:00
Vincent Koc
27bff10585 fix(logging): break console/logger type cycle 2026-04-09 01:56:18 +01:00
17 changed files with 61 additions and 52 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { ensureOwnerDisplaySecret, resolveOwnerDisplaySetting } from "./owner-display.js";
describe("resolveOwnerDisplaySetting", () => {

View File

@@ -1,5 +1,5 @@
import crypto from "node:crypto";
import type { OpenClawConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { normalizeOptionalString } from "../shared/string-coerce.js";
export type OwnerDisplaySetting = {

View File

@@ -1,4 +1,4 @@
import type { ApplyAuthChoiceParams } from "./auth-choice.apply.js";
import type { ApplyAuthChoiceParams } from "./auth-choice.apply.types.js";
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
export type {

View File

@@ -2,7 +2,7 @@ import { resolveProviderMatch } from "../plugins/provider-auth-choice-helpers.js
import { resolvePluginProviders } from "../plugins/provider-auth-choice.runtime.js";
import type { ProviderAuthKind } from "../plugins/types.js";
import { normalizeTokenProviderInput } from "./auth-choice.apply-helpers.js";
import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js";
import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.types.js";
import type { AuthChoice } from "./onboard-types.js";
function resolveProviderAuthChoiceByKind(params: {

View File

@@ -1,4 +1,4 @@
import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js";
import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.types.js";
export async function applyAuthChoiceOAuth(
_params: ApplyAuthChoiceParams,

View File

@@ -6,7 +6,7 @@ import {
} from "../plugins/provider-auth-choice.js";
import type { ProviderPlugin } from "../plugins/types.js";
import type { ProviderAuthMethod } from "../plugins/types.js";
import type { ApplyAuthChoiceParams } from "./auth-choice.apply.js";
import type { ApplyAuthChoiceParams } from "./auth-choice.apply.types.js";
const resolvePluginProviders = vi.hoisted(() => vi.fn<() => ProviderPlugin[]>(() => []));
const resolveProviderPluginChoice = vi.hoisted(() =>

View File

@@ -1,29 +1,11 @@
import type { OpenClawConfig } from "../config/config.js";
import { applyAuthChoiceLoadedPluginProvider } from "../plugins/provider-auth-choice.js";
import type { RuntimeEnv } from "../runtime.js";
import type { WizardPrompter } from "../wizard/prompts.js";
import { normalizeLegacyOnboardAuthChoice } from "./auth-choice-legacy.js";
import { applyAuthChoiceApiProviders } from "./auth-choice.apply.api-providers.js";
import { normalizeApiKeyTokenProviderAuthChoice } from "./auth-choice.apply.api-providers.js";
import { applyAuthChoiceOAuth } from "./auth-choice.apply.oauth.js";
import type { AuthChoice, OnboardOptions } from "./onboard-types.js";
import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.types.js";
export type ApplyAuthChoiceParams = {
authChoice: AuthChoice;
config: OpenClawConfig;
env?: NodeJS.ProcessEnv;
prompter: WizardPrompter;
runtime: RuntimeEnv;
agentDir?: string;
setDefaultModel: boolean;
agentId?: string;
opts?: Partial<OnboardOptions>;
};
export type ApplyAuthChoiceResult = {
config: OpenClawConfig;
agentModelOverride?: string;
};
export type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.types.js";
export async function applyAuthChoice(
params: ApplyAuthChoiceParams,

View File

@@ -0,0 +1,21 @@
import type { OpenClawConfig } from "../config/types.openclaw.js";
import type { RuntimeEnv } from "../runtime.js";
import type { WizardPrompter } from "../wizard/prompts.js";
import type { AuthChoice, OnboardOptions } from "./onboard-types.js";
export type ApplyAuthChoiceParams = {
authChoice: AuthChoice;
config: OpenClawConfig;
env?: NodeJS.ProcessEnv;
prompter: WizardPrompter;
runtime: RuntimeEnv;
agentDir?: string;
setDefaultModel: boolean;
agentId?: string;
opts?: Partial<OnboardOptions>;
};
export type ApplyAuthChoiceResult = {
config: OpenClawConfig;
agentModelOverride?: string;
};

View File

@@ -1,9 +1,9 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "./config.js";
import {
type OwnerDisplaySecretPersistState,
persistGeneratedOwnerDisplaySecret,
} from "./io.owner-display-secret.js";
import type { OpenClawConfig } from "./types.openclaw.js";
function createState(): OwnerDisplaySecretPersistState {
return {

View File

@@ -1,4 +1,4 @@
import type { OpenClawConfig } from "./config.js";
import type { OpenClawConfig } from "./types.openclaw.js";
export type OwnerDisplaySecretPersistState = {
pendingByPath: Map<string, string>;

View File

@@ -21,7 +21,7 @@ import {
type ExecutableResolution,
type ShellChainOperator,
} from "./exec-approvals-analysis.js";
import type { ExecAllowlistEntry } from "./exec-approvals.js";
import type { ExecAllowlistEntry } from "./exec-approvals.types.js";
import {
detectInterpreterInlineEvalArgv,
isInterpreterLikeAllowlistPattern,

View File

@@ -10,10 +10,12 @@ import {
} from "../shared/string-coerce.js";
import { resolveAllowAlwaysPatternEntries } from "./exec-approvals-allowlist.js";
import type { ExecCommandSegment } from "./exec-approvals-analysis.js";
import type { ExecAllowlistEntry } from "./exec-approvals.types.js";
import { expandHomePrefix } from "./home-dir.js";
import { requestJsonlSocket } from "./jsonl-socket.js";
export * from "./exec-approvals-analysis.js";
export * from "./exec-approvals-allowlist.js";
export type { ExecAllowlistEntry } from "./exec-approvals.types.js";
export type ExecHost = "sandbox" | "gateway" | "node";
export type ExecTarget = "auto" | ExecHost;
@@ -124,17 +126,6 @@ export type ExecApprovalsDefaults = {
autoAllowSkills?: boolean;
};
export type ExecAllowlistEntry = {
id?: string;
pattern: string;
source?: "allow-always";
commandText?: string;
argPattern?: string;
lastUsedAt?: number;
lastUsedCommand?: string;
lastResolvedPath?: string;
};
export type ExecApprovalsAgent = ExecApprovalsDefaults & {
allowlist?: ExecAllowlistEntry[];
};

View File

@@ -0,0 +1,10 @@
export type ExecAllowlistEntry = {
id?: string;
pattern: string;
source?: "allow-always";
commandText?: string;
argPattern?: string;
lastUsedAt?: number;
lastUsedCommand?: string;
lastResolvedPath?: string;
};

View File

@@ -2,7 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
import { matchesExecAllowlistPattern } from "./exec-allowlist-pattern.js";
import type { ExecAllowlistEntry } from "./exec-approvals.js";
import type { ExecAllowlistEntry } from "./exec-approvals.types.js";
import { resolveExecWrapperTrustPlan } from "./exec-wrapper-trust-plan.js";
import {
resolveExecutablePath as resolveExecutableCandidatePath,

View File

@@ -5,12 +5,13 @@ import { stripAnsi } from "../terminal/ansi.js";
import { readLoggingConfig, shouldSkipMutatingLoggingConfigRead } from "./config.js";
import { resolveEnvLogLevelOverride } from "./env-log-level.js";
import { type LogLevel, normalizeLogLevel } from "./levels.js";
import { getLogger, type LoggerSettings } from "./logger.js";
import { getLogger } from "./logger.js";
import { resolveNodeRequireFromMeta } from "./node-require.js";
import { loggingState } from "./state.js";
import { formatLocalIsoWithOffset, formatTimestamp } from "./timestamps.js";
import type { ConsoleStyle, LoggerSettings } from "./types.js";
export type ConsoleStyle = "pretty" | "compact" | "json";
export type { ConsoleStyle } from "./types.js";
type ConsoleSettings = {
level: LogLevel;
style: ConsoleStyle;

View File

@@ -7,12 +7,13 @@ import {
resolvePreferredOpenClawTmpDir,
} from "../infra/tmp-openclaw-dir.js";
import { readLoggingConfig, shouldSkipMutatingLoggingConfigRead } from "./config.js";
import type { ConsoleStyle } from "./console.js";
import { resolveEnvLogLevelOverride } from "./env-log-level.js";
import { type LogLevel, levelToMinLevel, normalizeLogLevel } from "./levels.js";
import { resolveNodeRequireFromMeta } from "./node-require.js";
import { loggingState } from "./state.js";
import { formatTimestamp } from "./timestamps.js";
import type { LoggerSettings } from "./types.js";
export type { LoggerSettings } from "./types.js";
type ProcessWithBuiltinModule = NodeJS.Process & {
getBuiltinModule?: (id: string) => unknown;
@@ -50,14 +51,6 @@ const DEFAULT_MAX_LOG_FILE_BYTES = 500 * 1024 * 1024; // 500 MB
const requireConfig = resolveNodeRequireFromMeta(import.meta.url);
export type LoggerSettings = {
level?: LogLevel;
file?: string;
maxFileBytes?: number;
consoleLevel?: LogLevel;
consoleStyle?: ConsoleStyle;
};
type LogObj = { date?: Date } & Record<string, unknown>;
type ResolvedSettings = {

11
src/logging/types.ts Normal file
View File

@@ -0,0 +1,11 @@
import type { LogLevel } from "./levels.js";
export type ConsoleStyle = "pretty" | "compact" | "json";
export type LoggerSettings = {
level?: LogLevel;
file?: string;
maxFileBytes?: number;
consoleLevel?: LogLevel;
consoleStyle?: ConsoleStyle;
};