chore: Format files.

This commit is contained in:
cpojer
2026-02-17 11:37:11 +09:00
parent 391796a3fb
commit 9c5f08244e
15 changed files with 38 additions and 38 deletions

View File

@@ -1,7 +1,5 @@
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import type { ThinkLevel } from "../../auto-reply/thinking.js"; 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 { getGlobalHookRunner } from "../../plugins/hook-runner-global.js";
import { enqueueCommandInLane } from "../../process/command-queue.js"; import { enqueueCommandInLane } from "../../process/command-queue.js";
import { isMarkdownCapableMessageChannel } from "../../utils/message-channel.js"; import { isMarkdownCapableMessageChannel } from "../../utils/message-channel.js";
@@ -52,11 +50,13 @@ import { resolveGlobalLane, resolveSessionLane } from "./lanes.js";
import { log } from "./logger.js"; import { log } from "./logger.js";
import { resolveModel } from "./model.js"; import { resolveModel } from "./model.js";
import { runEmbeddedAttempt } from "./run/attempt.js"; import { runEmbeddedAttempt } from "./run/attempt.js";
import type { RunEmbeddedPiAgentParams } from "./run/params.js";
import { buildEmbeddedRunPayloads } from "./run/payloads.js"; import { buildEmbeddedRunPayloads } from "./run/payloads.js";
import { import {
truncateOversizedToolResultsInSession, truncateOversizedToolResultsInSession,
sessionLikelyHasOversizedToolResults, sessionLikelyHasOversizedToolResults,
} from "./tool-result-truncation.js"; } from "./tool-result-truncation.js";
import type { EmbeddedPiAgentMeta, EmbeddedPiRunResult } from "./types.js";
import { describeUnknownError } from "./utils.js"; import { describeUnknownError } from "./utils.js";
type ApiKeyInfo = ResolvedProviderAuth; type ApiKeyInfo = ResolvedProviderAuth;

View File

@@ -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 { AgentMessage } from "@mariozechner/pi-agent-core";
import type { ImageContent } from "@mariozechner/pi-ai"; import type { ImageContent } from "@mariozechner/pi-ai";
import { streamSimple } from "@mariozechner/pi-ai"; import { streamSimple } from "@mariozechner/pi-ai";
import { createAgentSession, SessionManager, SettingsManager } from "@mariozechner/pi-coding-agent"; 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 { resolveHeartbeatPrompt } from "../../../auto-reply/heartbeat.js";
import { resolveChannelCapabilities } from "../../../config/channel-capabilities.js"; import { resolveChannelCapabilities } from "../../../config/channel-capabilities.js";
import { getMachineDisplayName } from "../../../infra/machine-name.js"; import { getMachineDisplayName } from "../../../infra/machine-name.js";
@@ -104,6 +103,7 @@ import {
shouldFlagCompactionTimeout, shouldFlagCompactionTimeout,
} from "./compaction-timeout.js"; } from "./compaction-timeout.js";
import { detectAndLoadPromptImages } from "./images.js"; import { detectAndLoadPromptImages } from "./images.js";
import type { EmbeddedRunAttemptParams, EmbeddedRunAttemptResult } from "./types.js";
export function injectHistoryImagesIntoMessages( export function injectHistoryImagesIntoMessages(
messages: AgentMessage[], messages: AgentMessage[],

View File

@@ -1,14 +1,14 @@
import type { AgentEvent } from "@mariozechner/pi-agent-core"; import type { AgentEvent } from "@mariozechner/pi-agent-core";
import { describe, expect, it, vi } from "vitest"; import { describe, expect, it, vi } from "vitest";
import type { MessagingToolSend } from "./pi-embedded-messaging.js"; import type { MessagingToolSend } from "./pi-embedded-messaging.js";
import type {
ToolCallSummary,
ToolHandlerContext,
} from "./pi-embedded-subscribe.handlers.types.js";
import { import {
handleToolExecutionEnd, handleToolExecutionEnd,
handleToolExecutionStart, handleToolExecutionStart,
} from "./pi-embedded-subscribe.handlers.tools.js"; } from "./pi-embedded-subscribe.handlers.tools.js";
import type {
ToolCallSummary,
ToolHandlerContext,
} from "./pi-embedded-subscribe.handlers.types.js";
type ToolExecutionStartEvent = Extract<AgentEvent, { type: "tool_execution_start" }>; type ToolExecutionStartEvent = Extract<AgentEvent, { type: "tool_execution_start" }>;
type ToolExecutionEndEvent = Extract<AgentEvent, { type: "tool_execution_end" }>; type ToolExecutionEndEvent = Extract<AgentEvent, { type: "tool_execution_end" }>;

View File

@@ -1,13 +1,13 @@
import type { AgentEvent } from "@mariozechner/pi-agent-core"; 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 type { PluginHookAfterToolCallEvent } from "../plugins/types.js";
import { normalizeTextForComparison } from "./pi-embedded-helpers.js";
import { isMessagingTool, isMessagingToolSendAction } from "./pi-embedded-messaging.js";
import type { import type {
ToolCallSummary, ToolCallSummary,
ToolHandlerContext, ToolHandlerContext,
} from "./pi-embedded-subscribe.handlers.types.js"; } 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 { import {
extractToolErrorMessage, extractToolErrorMessage,
extractToolResultMediaPaths, extractToolResultMediaPaths,

View File

@@ -1,9 +1,7 @@
import path from "node:path";
import { type Api, type Context, complete, type Model } from "@mariozechner/pi-ai"; import { type Api, type Context, complete, type Model } from "@mariozechner/pi-ai";
import { Type } from "@sinclair/typebox"; import { Type } from "@sinclair/typebox";
import path from "node:path";
import type { OpenClawConfig } from "../../config/config.js"; 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 { resolveUserPath } from "../../utils.js";
import { getDefaultLocalRoots, loadWebMedia } from "../../web/media.js"; import { getDefaultLocalRoots, loadWebMedia } from "../../web/media.js";
import { ensureAuthProfileStore, listProfilesForProvider } from "../auth-profiles.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 { resolveConfiguredModelRef } from "../model-selection.js";
import { ensureOpenClawModelsJson } from "../models-config.js"; import { ensureOpenClawModelsJson } from "../models-config.js";
import { discoverAuthStorage, discoverModels } from "../pi-model-discovery.js"; import { discoverAuthStorage, discoverModels } from "../pi-model-discovery.js";
import type { SandboxFsBridge } from "../sandbox/fs-bridge.js";
import { normalizeWorkspaceDir } from "../workspace-dir.js"; import { normalizeWorkspaceDir } from "../workspace-dir.js";
import type { AnyAgentTool } from "./common.js";
import { import {
coerceImageAssistantText, coerceImageAssistantText,
coerceImageModelConfig, coerceImageModelConfig,

View File

@@ -1,13 +1,12 @@
import type { ZodIssue } from "zod";
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import path from "node:path"; import path from "node:path";
import type { OpenClawConfig } from "../config/config.js"; import type { ZodIssue } from "zod";
import type { DoctorOptions } from "./doctor-prompter.js";
import { import {
isNumericTelegramUserId, isNumericTelegramUserId,
normalizeTelegramAllowFromEntry, normalizeTelegramAllowFromEntry,
} from "../channels/telegram/allow-from.js"; } from "../channels/telegram/allow-from.js";
import { formatCliCommand } from "../cli/command-format.js"; import { formatCliCommand } from "../cli/command-format.js";
import type { OpenClawConfig } from "../config/config.js";
import { import {
OpenClawSchema, OpenClawSchema,
CONFIG_PATH, CONFIG_PATH,
@@ -19,6 +18,7 @@ import { listTelegramAccountIds, resolveTelegramAccount } from "../telegram/acco
import { note } from "../terminal/note.js"; import { note } from "../terminal/note.js";
import { isRecord, resolveHomeDir } from "../utils.js"; import { isRecord, resolveHomeDir } from "../utils.js";
import { normalizeLegacyConfigValues } from "./doctor-legacy-config.js"; import { normalizeLegacyConfigValues } from "./doctor-legacy-config.js";
import type { DoctorOptions } from "./doctor-prompter.js";
import { autoMigrateLegacyStateDir } from "./doctor-state-migrations.js"; import { autoMigrateLegacyStateDir } from "./doctor-state-migrations.js";
type UnrecognizedKeysIssue = ZodIssue & { type UnrecognizedKeysIssue = ZodIssue & {

View File

@@ -1,7 +1,5 @@
import { intro as clackIntro, outro as clackOutro } from "@clack/prompts";
import fs from "node:fs"; import fs from "node:fs";
import type { OpenClawConfig } from "../config/config.js"; import { intro as clackIntro, outro as clackOutro } from "@clack/prompts";
import type { RuntimeEnv } from "../runtime.js";
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
import { loadModelCatalog } from "../agents/model-catalog.js"; import { loadModelCatalog } from "../agents/model-catalog.js";
@@ -11,12 +9,14 @@ import {
resolveHooksGmailModel, resolveHooksGmailModel,
} from "../agents/model-selection.js"; } from "../agents/model-selection.js";
import { formatCliCommand } from "../cli/command-format.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 { CONFIG_PATH, readConfigFileSnapshot, writeConfigFile } from "../config/config.js";
import { logConfigUpdated } from "../config/logging.js"; import { logConfigUpdated } from "../config/logging.js";
import { resolveGatewayService } from "../daemon/service.js"; import { resolveGatewayService } from "../daemon/service.js";
import { resolveGatewayAuth } from "../gateway/auth.js"; import { resolveGatewayAuth } from "../gateway/auth.js";
import { buildGatewayConnectionDetails } from "../gateway/call.js"; import { buildGatewayConnectionDetails } from "../gateway/call.js";
import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js";
import type { RuntimeEnv } from "../runtime.js";
import { defaultRuntime } from "../runtime.js"; import { defaultRuntime } from "../runtime.js";
import { note } from "../terminal/note.js"; import { note } from "../terminal/note.js";
import { stylePromptTitle } from "../terminal/prompt-style.js"; import { stylePromptTitle } from "../terminal/prompt-style.js";

View File

@@ -1,8 +1,8 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { ChannelId } from "../channels/plugins/types.js"; import type { ChannelId } from "../channels/plugins/types.js";
import type { ChannelAccountSnapshot } 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 { startChannelHealthMonitor } from "./channel-health-monitor.js";
import type { ChannelManager, ChannelRuntimeSnapshot } from "./server-channels.js";
function createMockChannelManager(overrides?: Partial<ChannelManager>): ChannelManager { function createMockChannelManager(overrides?: Partial<ChannelManager>): ChannelManager {
return { return {

View File

@@ -1,6 +1,6 @@
import type { ChannelId } from "../channels/plugins/types.js"; import type { ChannelId } from "../channels/plugins/types.js";
import type { ChannelManager } from "./server-channels.js";
import { createSubsystemLogger } from "../logging/subsystem.js"; import { createSubsystemLogger } from "../logging/subsystem.js";
import type { ChannelManager } from "./server-channels.js";
const log = createSubsystemLogger("gateway/health-monitor"); const log = createSubsystemLogger("gateway/health-monitor");

View File

@@ -1,5 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; 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 { type ChannelId, type ChannelPlugin } from "../channels/plugins/types.js";
import { import {
createSubsystemLogger, createSubsystemLogger,
@@ -9,6 +8,7 @@ import {
import { createEmptyPluginRegistry, type PluginRegistry } from "../plugins/registry.js"; import { createEmptyPluginRegistry, type PluginRegistry } from "../plugins/registry.js";
import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js"; import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js";
import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js";
import type { RuntimeEnv } from "../runtime.js";
import { createChannelManager } from "./server-channels.js"; import { createChannelManager } from "./server-channels.js";
const hoisted = vi.hoisted(() => { const hoisted = vi.hoisted(() => {

View File

@@ -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 { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js";
import { type ChannelId, getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.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 { type BackoffPolicy, computeBackoff, sleepWithAbort } from "../infra/backoff.js";
import { formatErrorMessage } from "../infra/errors.js"; import { formatErrorMessage } from "../infra/errors.js";
import { resetDirectoryCache } from "../infra/outbound/target-resolver.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 { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js";
import type { RuntimeEnv } from "../runtime.js";
const CHANNEL_RESTART_POLICY: BackoffPolicy = { const CHANNEL_RESTART_POLICY: BackoffPolicy = {
initialMs: 5_000, initialMs: 5_000,

View File

@@ -7,6 +7,8 @@
* 3. before_agent_start remains a legacy compatibility fallback * 3. before_agent_start remains a legacy compatibility fallback
*/ */
import { beforeEach, describe, expect, it, vi } from "vitest"; import { beforeEach, describe, expect, it, vi } from "vitest";
import { createHookRunner } from "./hooks.js";
import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js";
import type { import type {
PluginHookAgentContext, PluginHookAgentContext,
PluginHookBeforeAgentStartResult, PluginHookBeforeAgentStartResult,
@@ -16,8 +18,6 @@ import type {
PluginHookBeforePromptBuildResult, PluginHookBeforePromptBuildResult,
TypedPluginHookRegistration, TypedPluginHookRegistration,
} from "./types.js"; } from "./types.js";
import { createHookRunner } from "./hooks.js";
import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js";
function addBeforeModelResolveHook( function addBeforeModelResolveHook(
registry: PluginRegistry, registry: PluginRegistry,

View File

@@ -1,11 +1,11 @@
import { beforeEach, describe, expect, it } from "vitest"; import { beforeEach, describe, expect, it } from "vitest";
import { createHookRunner } from "./hooks.js";
import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js";
import type { import type {
PluginHookBeforeModelResolveResult, PluginHookBeforeModelResolveResult,
PluginHookBeforePromptBuildResult, PluginHookBeforePromptBuildResult,
TypedPluginHookRegistration, TypedPluginHookRegistration,
} from "./types.js"; } from "./types.js";
import { createHookRunner } from "./hooks.js";
import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js";
function addTypedHook( function addTypedHook(
registry: PluginRegistry, registry: PluginRegistry,

View File

@@ -1,6 +1,6 @@
import type { IncomingMessage, ServerResponse } from "node:http";
import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { AgentMessage } from "@mariozechner/pi-agent-core";
import type { Command } from "commander"; import type { Command } from "commander";
import type { IncomingMessage, ServerResponse } from "node:http";
import type { AuthProfileCredential, OAuthCredential } from "../agents/auth-profiles/types.js"; import type { AuthProfileCredential, OAuthCredential } from "../agents/auth-profiles/types.js";
import type { AnyAgentTool } from "../agents/tools/common.js"; import type { AnyAgentTool } from "../agents/tools/common.js";
import type { ReplyPayload } from "../auto-reply/types.js"; import type { ReplyPayload } from "../auto-reply/types.js";

View File

@@ -1,8 +1,4 @@
import type { Bot } from "grammy"; 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 { resolveAckReaction } from "../agents/identity.js";
import { import {
findModelInCatalog, findModelInCatalog,
@@ -20,14 +16,17 @@ import {
} from "../auto-reply/reply/history.js"; } from "../auto-reply/reply/history.js";
import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js";
import { buildMentionRegexes, matchesMentionWithExplicit } from "../auto-reply/reply/mentions.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 { shouldAckReaction as shouldAckReactionGate } from "../channels/ack-reactions.js";
import { resolveControlCommandGate } from "../channels/command-gating.js"; import { resolveControlCommandGate } from "../channels/command-gating.js";
import { formatLocationText, toLocationContext } from "../channels/location.js"; import { formatLocationText, toLocationContext } from "../channels/location.js";
import { logInboundDrop } from "../channels/logging.js"; import { logInboundDrop } from "../channels/logging.js";
import { resolveMentionGatingWithBypass } from "../channels/mention-gating.js"; import { resolveMentionGatingWithBypass } from "../channels/mention-gating.js";
import { recordInboundSession } from "../channels/session.js"; import { recordInboundSession } from "../channels/session.js";
import type { OpenClawConfig } from "../config/config.js";
import { loadConfig } from "../config/config.js"; import { loadConfig } from "../config/config.js";
import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js"; import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js";
import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js";
import { logVerbose, shouldLogVerbose } from "../globals.js"; import { logVerbose, shouldLogVerbose } from "../globals.js";
import { recordChannelActivity } from "../infra/channel-activity.js"; import { recordChannelActivity } from "../infra/channel-activity.js";
import { buildPairingReply } from "../pairing/pairing-messages.js"; import { buildPairingReply } from "../pairing/pairing-messages.js";
@@ -57,6 +56,7 @@ import {
hasBotMention, hasBotMention,
resolveTelegramThreadSpec, resolveTelegramThreadSpec,
} from "./bot/helpers.js"; } from "./bot/helpers.js";
import type { StickerMetadata, TelegramContext } from "./bot/types.js";
import { evaluateTelegramGroupBaseAccess } from "./group-access.js"; import { evaluateTelegramGroupBaseAccess } from "./group-access.js";
export type TelegramMediaRef = { export type TelegramMediaRef = {