diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index 381b23b27fb..6c84f9268c4 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -1,7 +1,5 @@ import fs from "node:fs/promises"; import type { ThinkLevel } from "../../auto-reply/thinking.js"; -import type { RunEmbeddedPiAgentParams } from "./run/params.js"; -import type { EmbeddedPiAgentMeta, EmbeddedPiRunResult } from "./types.js"; import { getGlobalHookRunner } from "../../plugins/hook-runner-global.js"; import { enqueueCommandInLane } from "../../process/command-queue.js"; import { isMarkdownCapableMessageChannel } from "../../utils/message-channel.js"; @@ -52,11 +50,13 @@ import { resolveGlobalLane, resolveSessionLane } from "./lanes.js"; import { log } from "./logger.js"; import { resolveModel } from "./model.js"; import { runEmbeddedAttempt } from "./run/attempt.js"; +import type { RunEmbeddedPiAgentParams } from "./run/params.js"; import { buildEmbeddedRunPayloads } from "./run/payloads.js"; import { truncateOversizedToolResultsInSession, sessionLikelyHasOversizedToolResults, } from "./tool-result-truncation.js"; +import type { EmbeddedPiAgentMeta, EmbeddedPiRunResult } from "./types.js"; import { describeUnknownError } from "./utils.js"; type ApiKeyInfo = ResolvedProviderAuth; diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index 1d79a7c5cc5..11bf3f5da3b 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -1,10 +1,9 @@ +import fs from "node:fs/promises"; +import os from "node:os"; import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { ImageContent } from "@mariozechner/pi-ai"; import { streamSimple } from "@mariozechner/pi-ai"; import { createAgentSession, SessionManager, SettingsManager } from "@mariozechner/pi-coding-agent"; -import fs from "node:fs/promises"; -import os from "node:os"; -import type { EmbeddedRunAttemptParams, EmbeddedRunAttemptResult } from "./types.js"; import { resolveHeartbeatPrompt } from "../../../auto-reply/heartbeat.js"; import { resolveChannelCapabilities } from "../../../config/channel-capabilities.js"; import { getMachineDisplayName } from "../../../infra/machine-name.js"; @@ -104,6 +103,7 @@ import { shouldFlagCompactionTimeout, } from "./compaction-timeout.js"; import { detectAndLoadPromptImages } from "./images.js"; +import type { EmbeddedRunAttemptParams, EmbeddedRunAttemptResult } from "./types.js"; export function injectHistoryImagesIntoMessages( messages: AgentMessage[], diff --git a/src/agents/pi-embedded-subscribe.handlers.tools.test.ts b/src/agents/pi-embedded-subscribe.handlers.tools.test.ts index 473f6fdb8d9..c03eb00da57 100644 --- a/src/agents/pi-embedded-subscribe.handlers.tools.test.ts +++ b/src/agents/pi-embedded-subscribe.handlers.tools.test.ts @@ -1,14 +1,14 @@ import type { AgentEvent } from "@mariozechner/pi-agent-core"; import { describe, expect, it, vi } from "vitest"; import type { MessagingToolSend } from "./pi-embedded-messaging.js"; -import type { - ToolCallSummary, - ToolHandlerContext, -} from "./pi-embedded-subscribe.handlers.types.js"; import { handleToolExecutionEnd, handleToolExecutionStart, } from "./pi-embedded-subscribe.handlers.tools.js"; +import type { + ToolCallSummary, + ToolHandlerContext, +} from "./pi-embedded-subscribe.handlers.types.js"; type ToolExecutionStartEvent = Extract; type ToolExecutionEndEvent = Extract; diff --git a/src/agents/pi-embedded-subscribe.handlers.tools.ts b/src/agents/pi-embedded-subscribe.handlers.tools.ts index d7bbbc9e074..e5569ae5d5c 100644 --- a/src/agents/pi-embedded-subscribe.handlers.tools.ts +++ b/src/agents/pi-embedded-subscribe.handlers.tools.ts @@ -1,13 +1,13 @@ import type { AgentEvent } from "@mariozechner/pi-agent-core"; +import { emitAgentEvent } from "../infra/agent-events.js"; +import { getGlobalHookRunner } from "../plugins/hook-runner-global.js"; import type { PluginHookAfterToolCallEvent } from "../plugins/types.js"; +import { normalizeTextForComparison } from "./pi-embedded-helpers.js"; +import { isMessagingTool, isMessagingToolSendAction } from "./pi-embedded-messaging.js"; import type { ToolCallSummary, ToolHandlerContext, } from "./pi-embedded-subscribe.handlers.types.js"; -import { emitAgentEvent } from "../infra/agent-events.js"; -import { getGlobalHookRunner } from "../plugins/hook-runner-global.js"; -import { normalizeTextForComparison } from "./pi-embedded-helpers.js"; -import { isMessagingTool, isMessagingToolSendAction } from "./pi-embedded-messaging.js"; import { extractToolErrorMessage, extractToolResultMediaPaths, diff --git a/src/agents/tools/image-tool.ts b/src/agents/tools/image-tool.ts index 55072fb1232..f27f9bdaaaf 100644 --- a/src/agents/tools/image-tool.ts +++ b/src/agents/tools/image-tool.ts @@ -1,9 +1,7 @@ +import path from "node:path"; import { type Api, type Context, complete, type Model } from "@mariozechner/pi-ai"; import { Type } from "@sinclair/typebox"; -import path from "node:path"; import type { OpenClawConfig } from "../../config/config.js"; -import type { SandboxFsBridge } from "../sandbox/fs-bridge.js"; -import type { AnyAgentTool } from "./common.js"; import { resolveUserPath } from "../../utils.js"; import { getDefaultLocalRoots, loadWebMedia } from "../../web/media.js"; import { ensureAuthProfileStore, listProfilesForProvider } from "../auth-profiles.js"; @@ -14,7 +12,9 @@ import { runWithImageModelFallback } from "../model-fallback.js"; import { resolveConfiguredModelRef } from "../model-selection.js"; import { ensureOpenClawModelsJson } from "../models-config.js"; import { discoverAuthStorage, discoverModels } from "../pi-model-discovery.js"; +import type { SandboxFsBridge } from "../sandbox/fs-bridge.js"; import { normalizeWorkspaceDir } from "../workspace-dir.js"; +import type { AnyAgentTool } from "./common.js"; import { coerceImageAssistantText, coerceImageModelConfig, diff --git a/src/commands/doctor-config-flow.ts b/src/commands/doctor-config-flow.ts index 44ca303c6c8..d79cf150a26 100644 --- a/src/commands/doctor-config-flow.ts +++ b/src/commands/doctor-config-flow.ts @@ -1,13 +1,12 @@ -import type { ZodIssue } from "zod"; import fs from "node:fs/promises"; import path from "node:path"; -import type { OpenClawConfig } from "../config/config.js"; -import type { DoctorOptions } from "./doctor-prompter.js"; +import type { ZodIssue } from "zod"; import { isNumericTelegramUserId, normalizeTelegramAllowFromEntry, } from "../channels/telegram/allow-from.js"; import { formatCliCommand } from "../cli/command-format.js"; +import type { OpenClawConfig } from "../config/config.js"; import { OpenClawSchema, CONFIG_PATH, @@ -19,6 +18,7 @@ import { listTelegramAccountIds, resolveTelegramAccount } from "../telegram/acco import { note } from "../terminal/note.js"; import { isRecord, resolveHomeDir } from "../utils.js"; import { normalizeLegacyConfigValues } from "./doctor-legacy-config.js"; +import type { DoctorOptions } from "./doctor-prompter.js"; import { autoMigrateLegacyStateDir } from "./doctor-state-migrations.js"; type UnrecognizedKeysIssue = ZodIssue & { diff --git a/src/commands/doctor.ts b/src/commands/doctor.ts index b467b9b3755..0208a712c9b 100644 --- a/src/commands/doctor.ts +++ b/src/commands/doctor.ts @@ -1,7 +1,5 @@ -import { intro as clackIntro, outro as clackOutro } from "@clack/prompts"; import fs from "node:fs"; -import type { OpenClawConfig } from "../config/config.js"; -import type { RuntimeEnv } from "../runtime.js"; +import { intro as clackIntro, outro as clackOutro } from "@clack/prompts"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { loadModelCatalog } from "../agents/model-catalog.js"; @@ -11,12 +9,14 @@ import { resolveHooksGmailModel, } from "../agents/model-selection.js"; import { formatCliCommand } from "../cli/command-format.js"; +import type { OpenClawConfig } from "../config/config.js"; import { CONFIG_PATH, readConfigFileSnapshot, writeConfigFile } from "../config/config.js"; import { logConfigUpdated } from "../config/logging.js"; import { resolveGatewayService } from "../daemon/service.js"; import { resolveGatewayAuth } from "../gateway/auth.js"; import { buildGatewayConnectionDetails } from "../gateway/call.js"; import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; +import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { note } from "../terminal/note.js"; import { stylePromptTitle } from "../terminal/prompt-style.js"; diff --git a/src/gateway/channel-health-monitor.test.ts b/src/gateway/channel-health-monitor.test.ts index 730a219f02d..228b7b66e9e 100644 --- a/src/gateway/channel-health-monitor.test.ts +++ b/src/gateway/channel-health-monitor.test.ts @@ -1,8 +1,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { ChannelId } from "../channels/plugins/types.js"; import type { ChannelAccountSnapshot } from "../channels/plugins/types.js"; -import type { ChannelManager, ChannelRuntimeSnapshot } from "./server-channels.js"; import { startChannelHealthMonitor } from "./channel-health-monitor.js"; +import type { ChannelManager, ChannelRuntimeSnapshot } from "./server-channels.js"; function createMockChannelManager(overrides?: Partial): ChannelManager { return { diff --git a/src/gateway/channel-health-monitor.ts b/src/gateway/channel-health-monitor.ts index 8349df0ed1a..4b26efcec95 100644 --- a/src/gateway/channel-health-monitor.ts +++ b/src/gateway/channel-health-monitor.ts @@ -1,6 +1,6 @@ import type { ChannelId } from "../channels/plugins/types.js"; -import type { ChannelManager } from "./server-channels.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; +import type { ChannelManager } from "./server-channels.js"; const log = createSubsystemLogger("gateway/health-monitor"); diff --git a/src/gateway/server-channels.test.ts b/src/gateway/server-channels.test.ts index 1e18c286e02..30fcf3b959e 100644 --- a/src/gateway/server-channels.test.ts +++ b/src/gateway/server-channels.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import type { RuntimeEnv } from "../runtime.js"; import { type ChannelId, type ChannelPlugin } from "../channels/plugins/types.js"; import { createSubsystemLogger, @@ -9,6 +8,7 @@ import { import { createEmptyPluginRegistry, type PluginRegistry } from "../plugins/registry.js"; import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; +import type { RuntimeEnv } from "../runtime.js"; import { createChannelManager } from "./server-channels.js"; const hoisted = vi.hoisted(() => { diff --git a/src/gateway/server-channels.ts b/src/gateway/server-channels.ts index e2c7a4e4fc4..c5a4064e2f1 100644 --- a/src/gateway/server-channels.ts +++ b/src/gateway/server-channels.ts @@ -1,13 +1,13 @@ -import type { ChannelAccountSnapshot } from "../channels/plugins/types.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { createSubsystemLogger } from "../logging/subsystem.js"; -import type { RuntimeEnv } from "../runtime.js"; import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; import { type ChannelId, getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js"; +import type { ChannelAccountSnapshot } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; import { type BackoffPolicy, computeBackoff, sleepWithAbort } from "../infra/backoff.js"; import { formatErrorMessage } from "../infra/errors.js"; import { resetDirectoryCache } from "../infra/outbound/target-resolver.js"; +import type { createSubsystemLogger } from "../logging/subsystem.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; +import type { RuntimeEnv } from "../runtime.js"; const CHANNEL_RESTART_POLICY: BackoffPolicy = { initialMs: 5_000, diff --git a/src/plugins/hooks.model-override-wiring.test.ts b/src/plugins/hooks.model-override-wiring.test.ts index 901e0c9d936..1ebe6bb2be2 100644 --- a/src/plugins/hooks.model-override-wiring.test.ts +++ b/src/plugins/hooks.model-override-wiring.test.ts @@ -7,6 +7,8 @@ * 3. before_agent_start remains a legacy compatibility fallback */ import { beforeEach, describe, expect, it, vi } from "vitest"; +import { createHookRunner } from "./hooks.js"; +import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js"; import type { PluginHookAgentContext, PluginHookBeforeAgentStartResult, @@ -16,8 +18,6 @@ import type { PluginHookBeforePromptBuildResult, TypedPluginHookRegistration, } from "./types.js"; -import { createHookRunner } from "./hooks.js"; -import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js"; function addBeforeModelResolveHook( registry: PluginRegistry, diff --git a/src/plugins/hooks.phase-hooks.test.ts b/src/plugins/hooks.phase-hooks.test.ts index 9dcafd917fb..a75c5ac3349 100644 --- a/src/plugins/hooks.phase-hooks.test.ts +++ b/src/plugins/hooks.phase-hooks.test.ts @@ -1,11 +1,11 @@ import { beforeEach, describe, expect, it } from "vitest"; +import { createHookRunner } from "./hooks.js"; +import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js"; import type { PluginHookBeforeModelResolveResult, PluginHookBeforePromptBuildResult, TypedPluginHookRegistration, } from "./types.js"; -import { createHookRunner } from "./hooks.js"; -import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js"; function addTypedHook( registry: PluginRegistry, diff --git a/src/plugins/types.ts b/src/plugins/types.ts index 03d9ffbae56..fc54fdece8a 100644 --- a/src/plugins/types.ts +++ b/src/plugins/types.ts @@ -1,6 +1,6 @@ +import type { IncomingMessage, ServerResponse } from "node:http"; import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { Command } from "commander"; -import type { IncomingMessage, ServerResponse } from "node:http"; import type { AuthProfileCredential, OAuthCredential } from "../agents/auth-profiles/types.js"; import type { AnyAgentTool } from "../agents/tools/common.js"; import type { ReplyPayload } from "../auto-reply/types.js"; diff --git a/src/telegram/bot-message-context.ts b/src/telegram/bot-message-context.ts index 7961fb469ed..3be196e57f0 100644 --- a/src/telegram/bot-message-context.ts +++ b/src/telegram/bot-message-context.ts @@ -1,8 +1,4 @@ import type { Bot } from "grammy"; -import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js"; -import type { StickerMetadata, TelegramContext } from "./bot/types.js"; import { resolveAckReaction } from "../agents/identity.js"; import { findModelInCatalog, @@ -20,14 +16,17 @@ import { } from "../auto-reply/reply/history.js"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import { buildMentionRegexes, matchesMentionWithExplicit } from "../auto-reply/reply/mentions.js"; +import type { MsgContext } from "../auto-reply/templating.js"; import { shouldAckReaction as shouldAckReactionGate } from "../channels/ack-reactions.js"; import { resolveControlCommandGate } from "../channels/command-gating.js"; import { formatLocationText, toLocationContext } from "../channels/location.js"; import { logInboundDrop } from "../channels/logging.js"; import { resolveMentionGatingWithBypass } from "../channels/mention-gating.js"; import { recordInboundSession } from "../channels/session.js"; +import type { OpenClawConfig } from "../config/config.js"; import { loadConfig } from "../config/config.js"; import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js"; +import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; import { recordChannelActivity } from "../infra/channel-activity.js"; import { buildPairingReply } from "../pairing/pairing-messages.js"; @@ -57,6 +56,7 @@ import { hasBotMention, resolveTelegramThreadSpec, } from "./bot/helpers.js"; +import type { StickerMetadata, TelegramContext } from "./bot/types.js"; import { evaluateTelegramGroupBaseAccess } from "./group-access.js"; export type TelegramMediaRef = {