chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts.

This commit is contained in:
cpojer
2026-02-01 10:03:47 +09:00
parent ad943bd8cf
commit f06dd8df06
1778 changed files with 2949 additions and 4242 deletions
+1 -1
View File
@@ -1,9 +1,9 @@
import os from "node:os";
import path from "node:path";
import type { OpenClawConfig } from "./types.js";
import { DEFAULT_AGENT_ID, normalizeAgentId } from "../routing/session-key.js";
import { resolveUserPath } from "../utils.js";
import { resolveStateDir } from "./paths.js";
import type { OpenClawConfig } from "./types.js";
export type DuplicateAgentDir = {
agentDir: string;
+1 -1
View File
@@ -1,9 +1,9 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import type { ChannelPlugin } from "../channels/plugins/types.js";
import type { PluginRegistry } from "../plugins/registry.js";
import type { OpenClawConfig } from "./config.js";
import { setActivePluginRegistry } from "../plugins/runtime.js";
import { resolveChannelCapabilities } from "./channel-capabilities.js";
import type { OpenClawConfig } from "./config.js";
describe("resolveChannelCapabilities", () => {
beforeEach(() => {
+2 -2
View File
@@ -1,7 +1,7 @@
import { normalizeChannelId } from "../channels/plugins/index.js";
import { normalizeAccountId } from "../routing/session-key.js";
import type { OpenClawConfig } from "./config.js";
import type { TelegramCapabilitiesConfig } from "./types.telegram.js";
import { normalizeChannelId } from "../channels/plugins/index.js";
import { normalizeAccountId } from "../routing/session-key.js";
type CapabilitiesConfig = TelegramCapabilitiesConfig;
+1 -1
View File
@@ -1,6 +1,6 @@
import type { ChannelId } from "../channels/plugins/types.js";
import { normalizeChannelId } from "../channels/plugins/index.js";
import type { NativeCommandsSetting } from "./types.js";
import { normalizeChannelId } from "../channels/plugins/index.js";
function resolveAutoDefault(providerId?: ChannelId): boolean {
const id = normalizeChannelId(providerId);
-1
View File
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import {
getConfigValueAtPath,
parseConfigPath,
+1 -3
View File
@@ -1,9 +1,7 @@
import fs from "node:fs/promises";
import { describe, expect, it } from "vitest";
import { withTempHome } from "./test-helpers.js";
import type { OpenClawConfig } from "./types.js";
import { withTempHome } from "./test-helpers.js";
describe("config backup rotation", () => {
it("keeps a 5-deep backup ring for config writes", async () => {
@@ -1,7 +1,5 @@
import path from "node:path";
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
import { withTempHome } from "./test-helpers.js";
@@ -1,8 +1,6 @@
import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { withTempHome } from "./test-helpers.js";
async function writePluginFixture(params: {
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { OpenClawSchema } from "./zod-schema.js";
describe("skills entries config schema", () => {
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { OpenClawSchema } from "./zod-schema.js";
describe("telegram custom commands schema", () => {
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./validation.js";
// NOTE: These tests ensure allow + alsoAllow cannot be set in the same scope.
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("web search provider config", () => {
+3 -3
View File
@@ -1,9 +1,9 @@
import type { OpenClawConfig } from "./types.js";
import type { ModelDefinitionConfig } from "./types.models.js";
import { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js";
import { parseModelRef } from "../agents/model-selection.js";
import { resolveTalkApiKey } from "./talk.js";
import type { OpenClawConfig } from "./types.js";
import { DEFAULT_AGENT_MAX_CONCURRENT, DEFAULT_SUBAGENT_MAX_CONCURRENT } from "./agent-limits.js";
import type { ModelDefinitionConfig } from "./types.models.js";
import { resolveTalkApiKey } from "./talk.js";
type WarnState = { warned: boolean };
-1
View File
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { MissingEnvVarError, resolveConfigEnvVars } from "./env-substitution.js";
describe("resolveConfigEnvVars", () => {
+1 -1
View File
@@ -1,7 +1,7 @@
import type { ChannelId } from "../channels/plugins/types.js";
import { normalizeAccountId } from "../routing/session-key.js";
import type { OpenClawConfig } from "./config.js";
import type { GroupToolPolicyBySenderConfig, GroupToolPolicyConfig } from "./types.tools.js";
import { normalizeAccountId } from "../routing/session-key.js";
export type GroupPolicyChannel = ChannelId;
-2
View File
@@ -1,7 +1,5 @@
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
CircularIncludeError,
ConfigIncludeError,
+1 -2
View File
@@ -10,11 +10,10 @@
* ```
*/
import JSON5 from "json5";
import fs from "node:fs";
import path from "node:path";
import JSON5 from "json5";
export const INCLUDE_KEY = "$include";
export const MAX_INCLUDE_DEPTH = 10;
-1
View File
@@ -2,7 +2,6 @@ import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { createConfigIO } from "./io.js";
async function withTempHome(run: (home: string) => Promise<void>): Promise<void> {
+3 -5
View File
@@ -1,16 +1,16 @@
import JSON5 from "json5";
import crypto from "node:crypto";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import JSON5 from "json5";
import type { OpenClawConfig, ConfigFileSnapshot, LegacyConfigIssue } from "./types.js";
import {
loadShellEnvFallback,
resolveShellEnvFallbackTimeoutMs,
shouldDeferShellEnvFallback,
shouldEnableShellEnvFallback,
} from "../infra/shell-env.js";
import { VERSION } from "../version.js";
import { DuplicateAgentDirError, findDuplicateAgentDirs } from "./agent-dirs.js";
import {
applyCompactionDefaults,
@@ -22,7 +22,6 @@ import {
applySessionDefaults,
applyTalkApiKey,
} from "./defaults.js";
import { VERSION } from "../version.js";
import { MissingEnvVarError, resolveConfigEnvVars } from "./env-substitution.js";
import { collectConfigEnvVars } from "./env-vars.js";
import { ConfigIncludeError, resolveConfigIncludes } from "./includes.js";
@@ -30,7 +29,6 @@ import { findLegacyConfigIssues } from "./legacy.js";
import { normalizeConfigPaths } from "./normalize-paths.js";
import { resolveConfigPath, resolveDefaultConfigCandidates, resolveStateDir } from "./paths.js";
import { applyConfigOverrides } from "./runtime-overrides.js";
import type { OpenClawConfig, ConfigFileSnapshot, LegacyConfigIssue } from "./types.js";
import { validateConfigObjectWithPlugins } from "./validation.js";
import { compareOpenClawVersions } from "./version.js";
+1 -1
View File
@@ -1,5 +1,5 @@
import { applyLegacyMigrations } from "./legacy.js";
import type { OpenClawConfig } from "./types.js";
import { applyLegacyMigrations } from "./legacy.js";
import { validateConfigObjectWithPlugins } from "./validation.js";
export function migrateLegacyConfig(raw: unknown): {
+1 -1
View File
@@ -1,6 +1,6 @@
import type { LegacyConfigIssue } from "./types.js";
import { LEGACY_CONFIG_MIGRATIONS } from "./legacy.migrations.js";
import { LEGACY_CONFIG_RULES } from "./legacy.rules.js";
import type { LegacyConfigIssue } from "./types.js";
export function findLegacyConfigIssues(raw: unknown): LegacyConfigIssue[] {
if (!raw || typeof raw !== "object") {
+2 -2
View File
@@ -1,7 +1,7 @@
import { normalizeChannelId } from "../channels/plugins/index.js";
import { normalizeAccountId } from "../routing/session-key.js";
import type { OpenClawConfig } from "./config.js";
import type { MarkdownTableMode } from "./types.base.js";
import { normalizeChannelId } from "../channels/plugins/index.js";
import { normalizeAccountId } from "../routing/session-key.js";
type MarkdownConfigEntry = {
markdown?: {
+1 -1
View File
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "./types.js";
import { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js";
import { applyModelDefaults } from "./defaults.js";
import type { OpenClawConfig } from "./types.js";
describe("applyModelDefaults", () => {
it("adds default aliases when models are present", () => {
-2
View File
@@ -1,7 +1,5 @@
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { withTempHome } from "../../test/helpers/temp-home.js";
describe("normalizeConfigPaths", () => {
+1 -1
View File
@@ -1,5 +1,5 @@
import { resolveUserPath } from "../utils.js";
import type { OpenClawConfig } from "./types.js";
import { resolveUserPath } from "../utils.js";
const PATH_VALUE_RE = /^~(?=$|[\\/])/;
-1
View File
@@ -2,7 +2,6 @@ import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import {
resolveDefaultConfigCandidates,
resolveConfigPath,
+5 -5
View File
@@ -1,14 +1,14 @@
import type { OpenClawConfig } from "./config.js";
import { normalizeProviderId } from "../agents/model-selection.js";
import {
getChannelPluginCatalogEntry,
listChannelPluginCatalogEntries,
} from "../channels/plugins/catalog.js";
import {
getChatChannelMeta,
listChatChannels,
normalizeChatChannelId,
} from "../channels/registry.js";
import {
getChannelPluginCatalogEntry,
listChannelPluginCatalogEntries,
} from "../channels/plugins/catalog.js";
import { normalizeProviderId } from "../agents/model-selection.js";
import { hasAnyWhatsAppAuth } from "../web/accounts.js";
type PluginEnableChange = {
+1 -1
View File
@@ -1,4 +1,5 @@
import { beforeEach, describe, expect, it } from "vitest";
import type { OpenClawConfig } from "./types.js";
import {
applyConfigOverrides,
getConfigOverrides,
@@ -6,7 +7,6 @@ import {
setConfigOverride,
unsetConfigOverride,
} from "./runtime-overrides.js";
import type { OpenClawConfig } from "./types.js";
describe("runtime overrides", () => {
beforeEach(() => {
+1 -1
View File
@@ -1,5 +1,5 @@
import { parseConfigPath, setConfigValueAtPath, unsetConfigValueAtPath } from "./config-paths.js";
import type { OpenClawConfig } from "./types.js";
import { parseConfigPath, setConfigValueAtPath, unsetConfigValueAtPath } from "./config-paths.js";
type OverrideTree = Record<string, unknown>;
-1
View File
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { buildConfigSchema } from "./schema.js";
describe("config schema", () => {
-1
View File
@@ -2,7 +2,6 @@ import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
buildGroupDisplayName,
deriveSessionKey,
+1 -1
View File
@@ -1,6 +1,6 @@
import type { MsgContext } from "../../auto-reply/templating.js";
import { listDeliverableMessageChannels } from "../../utils/message-channel.js";
import type { GroupKeyResolution } from "./types.js";
import { listDeliverableMessageChannels } from "../../utils/message-channel.js";
const getGroupSurfaces = () => new Set<string>([...listDeliverableMessageChannels(), "webchat"]);
+1 -1
View File
@@ -1,3 +1,4 @@
import type { SessionScope } from "./types.js";
import {
buildAgentMainSessionKey,
DEFAULT_AGENT_ID,
@@ -6,7 +7,6 @@ import {
resolveAgentIdFromSessionKey,
} from "../../routing/session-key.js";
import { loadConfig } from "../config.js";
import type { SessionScope } from "./types.js";
export function resolveMainSessionKey(cfg?: {
session?: { scope?: SessionScope; mainKey?: string };
-1
View File
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { deriveSessionMetaPatch } from "./metadata.js";
describe("deriveSessionMetaPatch", () => {
+1 -1
View File
@@ -1,11 +1,11 @@
import type { MsgContext } from "../../auto-reply/templating.js";
import type { GroupKeyResolution, SessionEntry, SessionOrigin } from "./types.js";
import { normalizeChatType } from "../../channels/chat-type.js";
import { resolveConversationLabel } from "../../channels/conversation-label.js";
import { getChannelDock } from "../../channels/dock.js";
import { normalizeChannelId } from "../../channels/plugins/index.js";
import { normalizeMessageChannel } from "../../utils/message-channel.js";
import { buildGroupDisplayName, resolveGroupSessionKey } from "./group.js";
import type { GroupKeyResolution, SessionEntry, SessionOrigin } from "./types.js";
const mergeOrigin = (
existing: SessionOrigin | undefined,
+1 -1
View File
@@ -1,8 +1,8 @@
import os from "node:os";
import path from "node:path";
import type { SessionEntry } from "./types.js";
import { DEFAULT_AGENT_ID, normalizeAgentId } from "../../routing/session-key.js";
import { resolveStateDir } from "../paths.js";
import type { SessionEntry } from "./types.js";
function resolveAgentSessionsDir(
agentId?: string,
+1 -1
View File
@@ -1,6 +1,6 @@
import type { SessionConfig, SessionResetConfig } from "../types.base.js";
import { DEFAULT_IDLE_MINUTES } from "./types.js";
import { normalizeMessageChannel } from "../../utils/message-channel.js";
import { DEFAULT_IDLE_MINUTES } from "./types.js";
export type SessionResetMode = "daily" | "idle";
export type SessionResetType = "dm" | "group" | "thread";
+1 -1
View File
@@ -1,4 +1,5 @@
import type { MsgContext } from "../../auto-reply/templating.js";
import type { SessionScope } from "./types.js";
import {
buildAgentMainSessionKey,
DEFAULT_AGENT_ID,
@@ -6,7 +7,6 @@ import {
} from "../../routing/session-key.js";
import { normalizeE164 } from "../../utils.js";
import { resolveGroupSessionKey } from "./group.js";
import type { SessionScope } from "./types.js";
// Decide which session bucket to use (per-sender vs global).
export function deriveSessionKey(scope: SessionScope, ctx: MsgContext) {
+3 -4
View File
@@ -1,9 +1,8 @@
import JSON5 from "json5";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import JSON5 from "json5";
import { getFileMtimeMs, isCacheEnabled, resolveCacheTtlMs } from "../cache-utils.js";
import type { MsgContext } from "../../auto-reply/templating.js";
import {
deliveryContextFromSession,
mergeDeliveryContext,
@@ -11,7 +10,7 @@ import {
normalizeSessionDeliveryFields,
type DeliveryContext,
} from "../../utils/delivery-context.js";
import type { MsgContext } from "../../auto-reply/templating.js";
import { getFileMtimeMs, isCacheEnabled, resolveCacheTtlMs } from "../cache-utils.js";
import { deriveSessionMetaPatch } from "./metadata.js";
import { mergeSessionEntry, type SessionEntry } from "./types.js";
+3 -5
View File
@@ -1,12 +1,10 @@
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
import fs from "node:fs";
import path from "node:path";
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
import type { SessionEntry } from "./types.js";
import { loadSessionStore, updateSessionStore } from "./store.js";
import { resolveDefaultSessionStorePath, resolveSessionTranscriptPath } from "./paths.js";
import { emitSessionTranscriptUpdate } from "../../sessions/transcript-events.js";
import { resolveDefaultSessionStorePath, resolveSessionTranscriptPath } from "./paths.js";
import { loadSessionStore, updateSessionStore } from "./store.js";
function stripQuery(value: string): string {
const noHash = value.split("#")[0] ?? value;
+1 -2
View File
@@ -1,6 +1,5 @@
import crypto from "node:crypto";
import type { Skill } from "@mariozechner/pi-coding-agent";
import crypto from "node:crypto";
import type { NormalizedChatType } from "../../channels/chat-type.js";
import type { ChannelId } from "../../channels/plugins/types.js";
import type { DeliveryContext } from "../../utils/delivery-context.js";
-1
View File
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("Slack HTTP mode config", () => {
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("Slack token config fields", () => {
-1
View File
@@ -1,5 +1,4 @@
import { vi } from "vitest";
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
export async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
+1 -1
View File
@@ -1,10 +1,10 @@
import type { ChannelId } from "../channels/plugins/types.js";
import type {
BlockStreamingChunkConfig,
BlockStreamingCoalesceConfig,
HumanDelayConfig,
TypingMode,
} from "./types.base.js";
import type { ChannelId } from "../channels/plugins/types.js";
import type {
SandboxBrowserSettings,
SandboxDockerSettings,
+1 -1
View File
@@ -1,3 +1,4 @@
import type { GroupPolicy } from "./types.base.js";
import type { DiscordConfig } from "./types.discord.js";
import type { GoogleChatConfig } from "./types.googlechat.js";
import type { IMessageConfig } from "./types.imessage.js";
@@ -6,7 +7,6 @@ import type { SignalConfig } from "./types.signal.js";
import type { SlackConfig } from "./types.slack.js";
import type { TelegramConfig } from "./types.telegram.js";
import type { WhatsAppConfig } from "./types.whatsapp.js";
import type { GroupPolicy } from "./types.base.js";
export type ChannelHeartbeatVisibilityConfig = {
/** Show HEARTBEAT_OK acknowledgments in chat (default: false). */
-1
View File
@@ -1,5 +1,4 @@
import { describe, expect, it } from "vitest";
import { validateConfigObject } from "./config.js";
describe("ui.seamColor", () => {
+1 -2
View File
@@ -1,5 +1,5 @@
import path from "node:path";
import type { OpenClawConfig, ConfigValidationIssue } from "./types.js";
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { CHANNEL_IDS, normalizeChatChannelId } from "../channels/registry.js";
import {
@@ -12,7 +12,6 @@ import { validateJsonSchemaValue } from "../plugins/schema-validator.js";
import { findDuplicateAgentDirs, formatDuplicateAgentDirError } from "./agent-dirs.js";
import { applyAgentDefaults, applyModelDefaults, applySessionDefaults } from "./defaults.js";
import { findLegacyConfigIssues } from "./legacy.js";
import type { OpenClawConfig, ConfigValidationIssue } from "./types.js";
import { OpenClawSchema } from "./zod-schema.js";
const AVATAR_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
-1
View File
@@ -1,5 +1,4 @@
import { z } from "zod";
import { parseDurationMs } from "../cli/parse-duration.js";
import {
GroupChatSchema,
-1
View File
@@ -1,5 +1,4 @@
import { z } from "zod";
import { isSafeExecutableValue } from "../infra/exec-safety.js";
export const ModelApiSchema = z.union([
+7 -8
View File
@@ -1,5 +1,11 @@
import { z } from "zod";
import {
normalizeTelegramCommandDescription,
normalizeTelegramCommandName,
resolveTelegramCustomCommands,
} from "./telegram-custom-commands.js";
import { ToolPolicySchema } from "./zod-schema.agent-runtime.js";
import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js";
import {
BlockStreamingChunkSchema,
BlockStreamingCoalesceSchema,
@@ -14,13 +20,6 @@ import {
RetryConfigSchema,
requireOpenAllowFrom,
} from "./zod-schema.core.js";
import { ToolPolicySchema } from "./zod-schema.agent-runtime.js";
import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js";
import {
normalizeTelegramCommandDescription,
normalizeTelegramCommandName,
resolveTelegramCustomCommands,
} from "./telegram-custom-commands.js";
const ToolPolicyBySenderSchema = z.record(z.string(), ToolPolicySchema).optional();
+2 -3
View File
@@ -1,5 +1,6 @@
import { z } from "zod";
import { ToolPolicySchema } from "./zod-schema.agent-runtime.js";
import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js";
import {
BlockStreamingCoalesceSchema,
DmConfigSchema,
@@ -7,8 +8,6 @@ import {
GroupPolicySchema,
MarkdownConfigSchema,
} from "./zod-schema.core.js";
import { ToolPolicySchema } from "./zod-schema.agent-runtime.js";
import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js";
const ToolPolicyBySenderSchema = z.record(z.string(), ToolPolicySchema).optional();
+2 -3
View File
@@ -1,5 +1,6 @@
import { z } from "zod";
import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js";
import { GroupPolicySchema } from "./zod-schema.core.js";
import {
BlueBubblesConfigSchema,
DiscordConfigSchema,
@@ -11,8 +12,6 @@ import {
TelegramConfigSchema,
} from "./zod-schema.providers-core.js";
import { WhatsAppConfigSchema } from "./zod-schema.providers-whatsapp.js";
import { GroupPolicySchema } from "./zod-schema.core.js";
import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js";
export * from "./zod-schema.providers-core.js";
export * from "./zod-schema.providers-whatsapp.js";
-1
View File
@@ -1,5 +1,4 @@
import { z } from "zod";
import {
GroupChatSchema,
InboundDebounceSchema,
+1 -1
View File
@@ -1,7 +1,7 @@
import { z } from "zod";
import { ToolsSchema } from "./zod-schema.agent-runtime.js";
import { ApprovalsSchema } from "./zod-schema.approvals.js";
import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zod-schema.agents.js";
import { ApprovalsSchema } from "./zod-schema.approvals.js";
import { HexColorSchema, ModelsConfigSchema } from "./zod-schema.core.js";
import { HookMappingSchema, HooksGmailSchema, InternalHooksSchema } from "./zod-schema.hooks.js";
import { ChannelsSchema } from "./zod-schema.providers.js";