diff --git a/extensions/kilocode/provider-models.ts b/extensions/kilocode/provider-models.ts index b36400b2a71..eb8453cf85a 100644 --- a/extensions/kilocode/provider-models.ts +++ b/extensions/kilocode/provider-models.ts @@ -1,4 +1,3 @@ -import type { KilocodeModelCatalogEntry } from "openclaw/plugin-sdk/provider-model-shared"; import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared"; import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env"; import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime"; @@ -10,6 +9,15 @@ export const KILOCODE_DEFAULT_MODEL_ID = "kilo/auto"; export const KILOCODE_DEFAULT_MODEL_REF = `kilocode/${KILOCODE_DEFAULT_MODEL_ID}`; export const KILOCODE_DEFAULT_MODEL_NAME = "Kilo Auto"; +export type KilocodeModelCatalogEntry = { + id: string; + name: string; + reasoning: boolean; + input: Array<"text" | "image">; + contextWindow?: number; + maxTokens?: number; +}; + export const KILOCODE_MODEL_CATALOG: KilocodeModelCatalogEntry[] = [ { id: KILOCODE_DEFAULT_MODEL_ID, diff --git a/extensions/kilocode/shared.ts b/extensions/kilocode/shared.ts index a6ab80aa805..ebe981aa702 100644 --- a/extensions/kilocode/shared.ts +++ b/extensions/kilocode/shared.ts @@ -9,4 +9,4 @@ export { KILOCODE_MODEL_CATALOG, } from "./provider-models.js"; -export type { KilocodeModelCatalogEntry } from "openclaw/plugin-sdk/provider-model-shared"; +export type { KilocodeModelCatalogEntry } from "./provider-models.js"; diff --git a/src/agents/channel-tools.ts b/src/agents/channel-tools.ts index 53affcf2399..02758047b87 100644 --- a/src/agents/channel-tools.ts +++ b/src/agents/channel-tools.ts @@ -134,23 +134,6 @@ export function resolveChannelMessageToolHints(params: { .filter(Boolean); } -export function resolveChannelMessageToolCapabilities(params: { - cfg?: OpenClawConfig; - channel?: string | null; - accountId?: string | null; -}): string[] { - const channelId = normalizeAnyChannelId(params.channel); - if (!channelId) { - return []; - } - const resolve = getChannelPlugin(channelId)?.agentPrompt?.messageToolCapabilities; - if (!resolve) { - return []; - } - const cfg = params.cfg ?? ({} as OpenClawConfig); - return normalizePromptCapabilities(resolve({ cfg, accountId: params.accountId })); -} - export function resolveChannelPromptCapabilities(params: { cfg?: OpenClawConfig; channel?: string | null; diff --git a/src/agents/copilot-dynamic-headers.ts b/src/agents/copilot-dynamic-headers.ts index a7fd35ca2b0..8a25404104c 100644 --- a/src/agents/copilot-dynamic-headers.ts +++ b/src/agents/copilot-dynamic-headers.ts @@ -1,13 +1,7 @@ import type { Context } from "@mariozechner/pi-ai"; import { buildCopilotIdeHeaders } from "../plugin-sdk/provider-auth.js"; -export { - buildCopilotIdeHeaders, - COPILOT_EDITOR_PLUGIN_VERSION, - COPILOT_EDITOR_VERSION, - COPILOT_GITHUB_API_VERSION, - COPILOT_USER_AGENT, -} from "../plugin-sdk/provider-auth.js"; +export { buildCopilotIdeHeaders } from "../plugin-sdk/provider-auth.js"; function inferCopilotInitiator(messages: Context["messages"]): "agent" | "user" { const last = messages[messages.length - 1]; diff --git a/src/agents/model-auth-label.test.ts b/src/agents/model-auth-label.test.ts index 66fc0b4cdb5..c960c110d0d 100644 --- a/src/agents/model-auth-label.test.ts +++ b/src/agents/model-auth-label.test.ts @@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; const mocks = vi.hoisted(() => ({ ensureAuthProfileStore: vi.fn(), + externalCliDiscoveryForProviderAuth: vi.fn(() => undefined), loadAuthProfileStoreWithoutExternalProfiles: vi.fn(), resolveAuthProfileOrder: vi.fn(), resolveAuthProfileDisplayLabel: vi.fn(), @@ -12,6 +13,7 @@ const mocks = vi.hoisted(() => ({ vi.mock("./auth-profiles.js", () => ({ ensureAuthProfileStore: mocks.ensureAuthProfileStore, + externalCliDiscoveryForProviderAuth: mocks.externalCliDiscoveryForProviderAuth, loadAuthProfileStoreWithoutExternalProfiles: mocks.loadAuthProfileStoreWithoutExternalProfiles, resolveAuthProfileOrder: mocks.resolveAuthProfileOrder, resolveAuthProfileDisplayLabel: mocks.resolveAuthProfileDisplayLabel, @@ -35,6 +37,8 @@ describe("resolveModelAuthLabel", () => { ({ resolveModelAuthLabel } = await import("./model-auth-label.js")); } mocks.ensureAuthProfileStore.mockReset(); + mocks.externalCliDiscoveryForProviderAuth.mockReset(); + mocks.externalCliDiscoveryForProviderAuth.mockReturnValue(undefined); mocks.loadAuthProfileStoreWithoutExternalProfiles.mockReset(); mocks.resolveAuthProfileOrder.mockReset(); mocks.resolveAuthProfileDisplayLabel.mockReset(); diff --git a/src/agents/openai-tool-schema.ts b/src/agents/openai-tool-schema.ts index beddb3b5515..81d4248f965 100644 --- a/src/agents/openai-tool-schema.ts +++ b/src/agents/openai-tool-schema.ts @@ -1,8 +1,5 @@ import { normalizeToolParameterSchema } from "./pi-tools-parameter-schema.js"; -export { - resolveOpenAIStrictToolSetting, - resolvesToNativeOpenAIStrictTools, -} from "./openai-strict-tool-setting.js"; +export { resolveOpenAIStrictToolSetting } from "./openai-strict-tool-setting.js"; type ToolWithParameters = { name?: unknown; diff --git a/src/agents/pi-embedded-runner/cache-ttl.ts b/src/agents/pi-embedded-runner/cache-ttl.ts index 22197d52ffa..2ac0227773c 100644 --- a/src/agents/pi-embedded-runner/cache-ttl.ts +++ b/src/agents/pi-embedded-runner/cache-ttl.ts @@ -106,17 +106,3 @@ export function readLastCacheTtlTimestamp( return null; } } - -export function appendCacheTtlTimestamp(sessionManager: unknown, data: CacheTtlEntryData): void { - const sm = sessionManager as { - appendCustomEntry?: (customType: string, data: unknown) => void; - }; - if (!sm?.appendCustomEntry) { - return; - } - try { - sm.appendCustomEntry(CACHE_TTL_CUSTOM_TYPE, data); - } catch { - // ignore persistence failures - } -} diff --git a/src/agents/pi-embedded-runner/openai-stream-wrappers.ts b/src/agents/pi-embedded-runner/openai-stream-wrappers.ts index a89997c9c46..b630b83e477 100644 --- a/src/agents/pi-embedded-runner/openai-stream-wrappers.ts +++ b/src/agents/pi-embedded-runner/openai-stream-wrappers.ts @@ -464,15 +464,6 @@ export function createCodexNativeWebSearchWrapper( }); }; } -export function createCodexDefaultTransportWrapper(baseStreamFn: StreamFn | undefined): StreamFn { - const underlying = baseStreamFn ?? streamSimple; - return (model, context, options) => - underlying(model, context, { - ...options, - transport: options?.transport ?? "auto", - }); -} - export function createOpenAIDefaultTransportWrapper(baseStreamFn: StreamFn | undefined): StreamFn { const underlying = baseStreamFn ?? streamSimple; return (model, context, options) => { diff --git a/src/agents/pi-embedded-runner/proxy-stream-wrappers.ts b/src/agents/pi-embedded-runner/proxy-stream-wrappers.ts index ec5a6697277..4a6c3e52600 100644 --- a/src/agents/pi-embedded-runner/proxy-stream-wrappers.ts +++ b/src/agents/pi-embedded-runner/proxy-stream-wrappers.ts @@ -1,7 +1,6 @@ import type { StreamFn } from "@mariozechner/pi-agent-core"; import { streamSimple } from "@mariozechner/pi-ai"; import type { ThinkLevel } from "../../auto-reply/thinking.js"; -import { isProxyReasoningUnsupportedModelHint } from "../../plugin-sdk/provider-model-shared.js"; import { normalizeOptionalLowercaseString, readStringValue } from "../../shared/string-coerce.js"; import { resolveProviderRequestPolicy } from "../provider-attribution.js"; import { resolveProviderRequestPolicyConfig } from "../provider-request-config.js"; @@ -108,7 +107,9 @@ export function createOpenRouterWrapper( } export function isProxyReasoningUnsupported(modelId: string): boolean { - return isProxyReasoningUnsupportedModelHint(modelId); + const trimmed = normalizeOptionalLowercaseString(modelId); + const slashIndex = trimmed?.indexOf("/") ?? -1; + return slashIndex > 0 && trimmed?.slice(0, slashIndex) === "x-ai"; } export function createKilocodeWrapper( diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index 31cd27c81d7..def2558a43a 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -353,7 +353,6 @@ export { shouldInjectHeartbeatPrompt, } from "./attempt.prompt-helpers.js"; export { - buildSessionsYieldContextMessage, persistSessionsYieldContextMessage, queueSessionsYieldInterruptMessage, stripSessionsYieldArtifacts, diff --git a/src/agents/pi-embedded-runner/run/failover-policy.ts b/src/agents/pi-embedded-runner/run/failover-policy.ts index 1053fd69173..841b392c01e 100644 --- a/src/agents/pi-embedded-runner/run/failover-policy.ts +++ b/src/agents/pi-embedded-runner/run/failover-policy.ts @@ -1,12 +1,5 @@ import type { FailoverReason } from "../../pi-embedded-helpers.js"; -export type RunFailoverDecisionAction = - | "continue_normal" - | "rotate_profile" - | "fallback_model" - | "surface_error" - | "return_error_payload"; - export type RunFailoverDecision = | { action: "continue_normal"; diff --git a/src/agents/pi-hooks/context-pruning.ts b/src/agents/pi-hooks/context-pruning.ts index b80addb9dbd..9a504441dcb 100644 --- a/src/agents/pi-hooks/context-pruning.ts +++ b/src/agents/pi-hooks/context-pruning.ts @@ -8,11 +8,6 @@ export { default } from "./context-pruning/extension.js"; export { pruneContextMessages } from "./context-pruning/pruner.js"; -export type { - ContextPruningConfig, - ContextPruningToolMatch, - EffectiveContextPruningSettings, -} from "./context-pruning/settings.js"; export { computeEffectiveSettings, DEFAULT_CONTEXT_PRUNING_SETTINGS, diff --git a/src/agents/sandbox/backend.ts b/src/agents/sandbox/backend.ts index 43f29a10723..c2747e63cb7 100644 --- a/src/agents/sandbox/backend.ts +++ b/src/agents/sandbox/backend.ts @@ -20,7 +20,6 @@ export type { SandboxBackendCommandResult, SandboxBackendExecSpec, SandboxBackendHandle, - SandboxFsBridgeContext, } from "./backend-handle.types.js"; const SANDBOX_BACKEND_FACTORIES = new Map(); diff --git a/src/agents/sandbox/sanitize-env-vars.ts b/src/agents/sandbox/sanitize-env-vars.ts index a0d5f518b76..3caea56ac3f 100644 --- a/src/agents/sandbox/sanitize-env-vars.ts +++ b/src/agents/sandbox/sanitize-env-vars.ts @@ -100,11 +100,3 @@ export function sanitizeEnvVars( return { allowed, blocked, warnings }; } - -export function getBlockedPatterns(): string[] { - return BLOCKED_ENV_VAR_PATTERNS.map((pattern) => pattern.source); -} - -export function getAllowedPatterns(): string[] { - return ALLOWED_ENV_VAR_PATTERNS.map((pattern) => pattern.source); -} diff --git a/src/agents/subagent-registry-queries.ts b/src/agents/subagent-registry-queries.ts index e70cf91882e..33ac1bceff7 100644 --- a/src/agents/subagent-registry-queries.ts +++ b/src/agents/subagent-registry-queries.ts @@ -6,23 +6,6 @@ function resolveControllerSessionKey(entry: SubagentRunRecord): string { return entry.controllerSessionKey?.trim() || entry.requesterSessionKey; } -export function findRunIdsByChildSessionKeyFromRuns( - runs: Map, - childSessionKey: string, -): string[] { - const key = childSessionKey.trim(); - if (!key) { - return []; - } - const runIds: string[] = []; - for (const [runId, entry] of runs.entries()) { - if (entry.childSessionKey === key) { - runIds.push(runId); - } - } - return runIds; -} - export function listRunsForRequesterFromRuns( runs: Map, requesterSessionKey: string, diff --git a/src/agents/subagent-registry.store.ts b/src/agents/subagent-registry.store.ts index 5e9c90ab330..38fce68e6d9 100644 --- a/src/agents/subagent-registry.store.ts +++ b/src/agents/subagent-registry.store.ts @@ -7,8 +7,6 @@ import { readStringValue } from "../shared/string-coerce.js"; import { normalizeDeliveryContext } from "../utils/delivery-context.shared.js"; import type { SubagentRunRecord } from "./subagent-registry.types.js"; -export type PersistedSubagentRegistryVersion = 1 | 2; - type PersistedSubagentRegistryV1 = { version: 1; runs: Record; diff --git a/src/agents/tools/chat-history-text.ts b/src/agents/tools/chat-history-text.ts index 7c7329ce704..fca4128fe5c 100644 --- a/src/agents/tools/chat-history-text.ts +++ b/src/agents/tools/chat-history-text.ts @@ -20,24 +20,6 @@ export function sanitizeTextContent(text: string): string { return sanitizeAssistantVisibleTextWithProfile(text, "history"); } -export function hasAssistantPhaseMetadata(message: unknown): boolean { - if (!message || typeof message !== "object") { - return false; - } - if ((message as { role?: unknown }).role !== "assistant") { - return false; - } - const content = (message as { content?: unknown }).content; - if (!Array.isArray(content)) { - return false; - } - return content.some( - (block) => - block && - typeof block === "object" && - typeof (block as { textSignature?: unknown }).textSignature === "string", - ); -} export function extractAssistantText(message: unknown): string | undefined { if (!message || typeof message !== "object") { return undefined; diff --git a/src/agents/tools/session-message-text.ts b/src/agents/tools/session-message-text.ts index f4fcc6a3a7a..f4ccb9ddb47 100644 --- a/src/agents/tools/session-message-text.ts +++ b/src/agents/tools/session-message-text.ts @@ -1,5 +1 @@ -export { - extractAssistantText, - sanitizeTextContent, - stripToolMessages, -} from "./chat-history-text.js"; +export { extractAssistantText, sanitizeTextContent } from "./chat-history-text.js"; diff --git a/src/agents/tools/sessions-access.test.ts b/src/agents/tools/sessions-access.test.ts index 69ce1b32823..533c5b70b0b 100644 --- a/src/agents/tools/sessions-access.test.ts +++ b/src/agents/tools/sessions-access.test.ts @@ -5,9 +5,9 @@ import { createSessionVisibilityGuard, resolveEffectiveSessionToolsVisibility, resolveSandboxSessionToolsVisibility, - resolveSandboxedSessionToolContext, resolveSessionToolsVisibility, -} from "./sessions-access.js"; +} from "../../plugin-sdk/session-visibility.js"; +import { resolveSandboxedSessionToolContext } from "./sessions-access.js"; import { __testing as sessionsResolutionTesting } from "./sessions-resolution.js"; describe("resolveSessionToolsVisibility", () => { diff --git a/src/agents/tools/sessions-access.ts b/src/agents/tools/sessions-access.ts index 18349790c5f..63f6eeeecd5 100644 --- a/src/agents/tools/sessions-access.ts +++ b/src/agents/tools/sessions-access.ts @@ -6,27 +6,17 @@ import { listSpawnedSessionKeys, resolveEffectiveSessionToolsVisibility, resolveSandboxSessionToolsVisibility, - resolveSessionToolsVisibility, } from "../../plugin-sdk/session-visibility.js"; import { isSubagentSessionKey } from "../../routing/session-key.js"; import { normalizeOptionalString } from "../../shared/string-coerce.js"; import { resolveInternalSessionKey, resolveMainSessionAlias } from "./sessions-resolution.js"; -export type { - AgentToAgentPolicy, - SessionAccessAction, - SessionAccessResult, - SessionToolsVisibility, -} from "../../plugin-sdk/session-visibility.js"; - export { createAgentToAgentPolicy, createSessionVisibilityChecker, createSessionVisibilityGuard, listSpawnedSessionKeys, resolveEffectiveSessionToolsVisibility, - resolveSandboxSessionToolsVisibility, - resolveSessionToolsVisibility, } from "../../plugin-sdk/session-visibility.js"; export function resolveSandboxedSessionToolContext(params: { diff --git a/src/agents/tools/sessions-helpers.ts b/src/agents/tools/sessions-helpers.ts index ccda3d43576..2f7b96feb88 100644 --- a/src/agents/tools/sessions-helpers.ts +++ b/src/agents/tools/sessions-helpers.ts @@ -1,25 +1,11 @@ -export type { - AgentToAgentPolicy, - SessionAccessAction, - SessionAccessResult, - SessionToolsVisibility, -} from "./sessions-access.js"; export { createAgentToAgentPolicy, createSessionVisibilityGuard, resolveEffectiveSessionToolsVisibility, - resolveSandboxSessionToolsVisibility, resolveSandboxedSessionToolContext, - resolveSessionToolsVisibility, } from "./sessions-access.js"; import { resolveSandboxedSessionToolContext } from "./sessions-access.js"; -export type { SessionReferenceResolution } from "./sessions-resolution.js"; export { - isRequesterSpawnedSessionVisible, - isResolvedSessionVisibleToRequester, - listSpawnedSessionKeys, - looksLikeSessionId, - looksLikeSessionKey, resolveCurrentSessionClientAlias, resolveDisplaySessionKey, resolveInternalSessionKey, @@ -27,7 +13,6 @@ export { resolveSessionReference, resolveVisibleSessionReference, shouldResolveSessionIdInput, - shouldVerifyRequesterSpawnedSessionVisibility, } from "./sessions-resolution.js"; export { extractAssistantText, diff --git a/src/agents/tools/web-search-provider-config.ts b/src/agents/tools/web-search-provider-config.ts index 276dee6963b..eb7f7c325ac 100644 --- a/src/agents/tools/web-search-provider-config.ts +++ b/src/agents/tools/web-search-provider-config.ts @@ -1,41 +1,6 @@ import { resolvePluginWebSearchConfig } from "../../config/plugin-web-search-config.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; -type ConfiguredWebSearchProvider = NonNullable< - NonNullable["web"]>["search"] ->["provider"]; - -export type WebSearchConfig = NonNullable["web"] extends infer Web - ? Web extends { search?: infer Search } - ? Search - : undefined - : undefined; - -function cloneWithDescriptors(value: T | undefined): T { - const next = Object.create(Object.getPrototypeOf(value ?? {})) as T; - if (value) { - Object.defineProperties(next, Object.getOwnPropertyDescriptors(value)); - } - return next; -} - -export function withForcedProvider( - config: OpenClawConfig | undefined, - provider: ConfiguredWebSearchProvider, -): OpenClawConfig { - const next = cloneWithDescriptors(config ?? {}); - const tools = cloneWithDescriptors(next.tools ?? {}); - const web = cloneWithDescriptors(tools.web ?? {}); - const search = cloneWithDescriptors(web.search ?? {}); - - search.provider = provider; - web.search = search; - tools.web = web; - next.tools = tools; - - return next; -} - export function getTopLevelCredentialValue(searchConfig?: Record): unknown { return searchConfig?.apiKey; } @@ -102,14 +67,6 @@ export function mergeScopedSearchConfig( return next; } -export function resolveSearchConfig(cfg?: OpenClawConfig): WebSearchConfig { - const search = cfg?.tools?.web?.search; - if (!search || typeof search !== "object") { - return undefined; - } - return search as WebSearchConfig; -} - export function resolveProviderWebSearchPluginConfig( config: OpenClawConfig | undefined, pluginId: string, @@ -143,16 +100,3 @@ export function setProviderWebSearchPluginConfigValue( const webSearch = ensureObject(config, "webSearch"); webSearch[key] = value; } - -export function resolveSearchEnabled(params: { - search?: WebSearchConfig; - sandboxed?: boolean; -}): boolean { - if (typeof params.search?.enabled === "boolean") { - return params.search.enabled; - } - if (params.sandboxed) { - return true; - } - return true; -} diff --git a/src/agents/tools/web-tools.ts b/src/agents/tools/web-tools.ts index f509afb8dd1..baf24c7839d 100644 --- a/src/agents/tools/web-tools.ts +++ b/src/agents/tools/web-tools.ts @@ -1,2 +1,2 @@ -export { createWebFetchTool, extractReadableContent } from "./web-fetch.js"; +export { createWebFetchTool } from "./web-fetch.js"; export { createWebSearchTool } from "./web-search.js"; diff --git a/src/auto-reply/reply/agent-runner-memory.ts b/src/auto-reply/reply/agent-runner-memory.ts index 6b6f613236a..1e0c27b1307 100644 --- a/src/auto-reply/reply/agent-runner-memory.ts +++ b/src/auto-reply/reply/agent-runner-memory.ts @@ -368,23 +368,6 @@ function estimatePromptTokensFromSessionTranscript(params: { } } -export async function readPromptTokensFromSessionLog( - sessionId?: string, - sessionEntry?: SessionEntry, - sessionKey?: string, - opts?: { storePath?: string }, -): Promise { - const snapshot = await readSessionLogSnapshot({ - sessionId, - sessionEntry, - sessionKey, - opts, - includeByteSize: false, - includeUsage: true, - }); - return snapshot.usage; -} - export async function runPreflightCompactionIfNeeded(params: { cfg: OpenClawConfig; followupRun: FollowupRun; diff --git a/src/auto-reply/reply/commands-subagents-dispatch.ts b/src/auto-reply/reply/commands-subagents-dispatch.ts index df3dbb30ac8..74abb38b048 100644 --- a/src/auto-reply/reply/commands-subagents-dispatch.ts +++ b/src/auto-reply/reply/commands-subagents-dispatch.ts @@ -2,19 +2,13 @@ import type { SubagentRunRecord } from "../../agents/subagent-registry.types.js" import type { HandleCommandsParams } from "./commands-types.js"; export { - ACTIONS, COMMAND, - COMMAND_AGENTS, - COMMAND_FOCUS, COMMAND_KILL, COMMAND_STEER, - COMMAND_TELL, - COMMAND_UNFOCUS, resolveHandledPrefix, resolveRequesterSessionKey, resolveSubagentsAction, stopWithText, - type SubagentsAction, } from "./commands-subagents/shared.js"; export type SubagentsCommandContext = { diff --git a/src/auto-reply/reply/commands-subagents.ts b/src/auto-reply/reply/commands-subagents.ts index e9107a58f3d..210a994c471 100644 --- a/src/auto-reply/reply/commands-subagents.ts +++ b/src/auto-reply/reply/commands-subagents.ts @@ -8,8 +8,6 @@ import { } from "./commands-subagents-dispatch.js"; import type { CommandHandler } from "./commands-types.js"; -export { extractMessageText } from "./commands-subagents-text.js"; - let actionAgentsPromise: Promise | null = null; let actionFocusPromise: Promise | null = diff --git a/src/auto-reply/reply/commands-subagents/shared.ts b/src/auto-reply/reply/commands-subagents/shared.ts index 64a687e4f2c..38a61f2136d 100644 --- a/src/auto-reply/reply/commands-subagents/shared.ts +++ b/src/auto-reply/reply/commands-subagents/shared.ts @@ -1,4 +1,3 @@ -import { resolveModelDisplayName } from "../../../agents/model-selection-display.js"; import { resolveStoredSubagentCapabilities } from "../../../agents/subagent-capabilities.js"; import type { ResolvedSubagentController } from "../../../agents/subagent-control.js"; import { subagentRuns } from "../../../agents/subagent-registry-memory.js"; @@ -11,11 +10,7 @@ import { resolveMainSessionAlias, stripToolMessages, } from "../../../agents/tools/sessions-helpers.js"; -import type { resolveStorePath as resolveStorePathFn } from "../../../config/sessions/paths.js"; -import type { loadSessionStore as loadSessionStoreFn } from "../../../config/sessions/store-load.js"; -import type { SessionEntry } from "../../../config/sessions/types.js"; import { callGateway } from "../../../gateway/call.js"; -import { formatTimeAgo } from "../../../infra/format-time/format-relative.ts"; import { parseAgentSessionKey } from "../../../routing/session-key.js"; import { isSubagentSessionKey } from "../../../routing/session-key.js"; import { looksLikeSessionId } from "../../../sessions/session-id.js"; @@ -23,17 +18,11 @@ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, } from "../../../shared/string-coerce.js"; -import { - formatDurationCompact, - formatTokenUsageDisplay, - truncateLine, -} from "../../../shared/subagents-format.js"; import { resolveCommandSurfaceChannel, resolveChannelAccountId } from "../channel-context.js"; import { extractMessageText, type ChatMessage } from "../commands-subagents-text.js"; import type { CommandHandler, CommandHandlerResult } from "../commands-types.js"; import { formatRunLabel, - formatRunStatus, resolveSubagentTargetFromRuns, type SubagentTargetResolution, } from "../subagents-utils.js"; @@ -45,11 +34,11 @@ export type { ChatMessage } from "../commands-subagents-text.js"; export const COMMAND = "/subagents"; export const COMMAND_KILL = "/kill"; export const COMMAND_STEER = "/steer"; -export const COMMAND_TELL = "/tell"; -export const COMMAND_FOCUS = "/focus"; -export const COMMAND_UNFOCUS = "/unfocus"; -export const COMMAND_AGENTS = "/agents"; -export const ACTIONS = new Set([ +const COMMAND_TELL = "/tell"; +const COMMAND_FOCUS = "/focus"; +const COMMAND_UNFOCUS = "/unfocus"; +const COMMAND_AGENTS = "/agents"; +const ACTIONS = new Set([ "list", "kill", "log", @@ -64,81 +53,8 @@ export const ACTIONS = new Set([ ]); export const RECENT_WINDOW_MINUTES = 30; -const SUBAGENT_TASK_PREVIEW_MAX = 110; -export const STEER_ABORT_SETTLE_TIMEOUT_MS = 5_000; -function compactLine(value: string) { - return value.replace(/\s+/g, " ").trim(); -} - -function formatTaskPreview(value: string) { - return truncateLine(compactLine(value), SUBAGENT_TASK_PREVIEW_MAX); -} - -export function resolveDisplayStatus( - entry: SubagentRunRecord, - options?: { pendingDescendants?: number }, -) { - const pendingDescendants = Math.max(0, options?.pendingDescendants ?? 0); - if (pendingDescendants > 0) { - const childLabel = pendingDescendants === 1 ? "child" : "children"; - return `active (waiting on ${pendingDescendants} ${childLabel})`; - } - const status = formatRunStatus(entry); - return status === "error" ? "failed" : status; -} - -export function formatSubagentListLine(params: { - entry: SubagentRunRecord; - index: number; - runtimeMs: number; - sessionEntry?: SessionEntry; - pendingDescendants?: number; -}) { - const usageText = formatTokenUsageDisplay(params.sessionEntry); - const label = truncateLine(formatRunLabel(params.entry, { maxLength: 48 }), 48); - const task = formatTaskPreview(params.entry.task); - const runtime = formatDurationCompact(params.runtimeMs) ?? "n/a"; - const status = resolveDisplayStatus(params.entry, { - pendingDescendants: params.pendingDescendants, - }); - return `${params.index}. ${label} (${resolveModelDisplayName({ - runtimeProvider: - typeof params.sessionEntry?.modelProvider === "string" - ? params.sessionEntry.modelProvider - : null, - runtimeModel: typeof params.sessionEntry?.model === "string" ? params.sessionEntry.model : null, - overrideProvider: - typeof params.sessionEntry?.providerOverride === "string" - ? params.sessionEntry.providerOverride - : null, - overrideModel: - typeof params.sessionEntry?.modelOverride === "string" - ? params.sessionEntry.modelOverride - : null, - fallbackModel: params.entry.model, - })}, ${runtime}${usageText ? `, ${usageText}` : ""}) ${status}${ - normalizeLowercaseStringOrEmpty(task) !== normalizeLowercaseStringOrEmpty(label) - ? ` - ${task}` - : "" - }`; -} - -function formatTimestamp(valueMs?: number) { - if (!valueMs || !Number.isFinite(valueMs) || valueMs <= 0) { - return "n/a"; - } - return new Date(valueMs).toISOString(); -} - -export function formatTimestampWithAge(valueMs?: number) { - if (!valueMs || !Number.isFinite(valueMs) || valueMs <= 0) { - return "n/a"; - } - return `${formatTimestamp(valueMs)} (${formatTimeAgo(Date.now() - valueMs, { fallback: "n/a" })})`; -} - -export type SubagentsAction = +type SubagentsAction = | "list" | "kill" | "log" @@ -395,26 +311,3 @@ export function formatLogLines(messages: ChatMessage[]) { } return lines; } - -export type SessionStoreCache = Map>; - -export function loadSubagentSessionEntry( - params: SubagentsCommandParams, - childKey: string, - loaders: { - loadSessionStore: typeof loadSessionStoreFn; - resolveStorePath: typeof resolveStorePathFn; - }, - storeCache?: SessionStoreCache, -) { - const parsed = parseAgentSessionKey(childKey); - const storePath = loaders.resolveStorePath(params.cfg.session?.store, { - agentId: parsed?.agentId, - }); - let store = storeCache?.get(storePath); - if (!store) { - store = loaders.loadSessionStore(storePath); - storeCache?.set(storePath, store); - } - return { storePath, store, entry: store[childKey] }; -} diff --git a/src/auto-reply/reply/commands.ts b/src/auto-reply/reply/commands.ts index 183ed2710ac..b964ad291a7 100644 --- a/src/auto-reply/reply/commands.ts +++ b/src/auto-reply/reply/commands.ts @@ -1,8 +1,3 @@ export { buildCommandContext } from "./commands-context.js"; export { handleCommands } from "./commands-core.js"; export { buildStatusReply } from "./commands-status.js"; -export type { - CommandContext, - CommandHandlerResult, - HandleCommandsParams, -} from "./commands-types.js"; diff --git a/src/auto-reply/reply/directive-handling.ts b/src/auto-reply/reply/directive-handling.ts index c376ab0a2cb..3b045ac3756 100644 --- a/src/auto-reply/reply/directive-handling.ts +++ b/src/auto-reply/reply/directive-handling.ts @@ -1,8 +1 @@ -export { applyInlineDirectivesFastLane } from "./directive-handling.fast-lane.js"; -export * from "./directive-handling.impl.js"; export type { InlineDirectives } from "./directive-handling.parse.js"; -export { isDirectiveOnly } from "./directive-handling.directive-only.js"; -export { parseInlineDirectives } from "./directive-handling.parse.js"; -export { persistInlineDirectives } from "./directive-handling.persist.js"; -export { resolveDefaultModel } from "./directive-handling.defaults.js"; -export { formatDirectiveAck } from "./directive-handling.shared.js"; diff --git a/src/auto-reply/reply/directives.ts b/src/auto-reply/reply/directives.ts index 85741d08c2f..c3ded4a257c 100644 --- a/src/auto-reply/reply/directives.ts +++ b/src/auto-reply/reply/directives.ts @@ -4,7 +4,6 @@ import { type ElevatedLevel, normalizeFastMode, normalizeElevatedLevel, - normalizeNoticeLevel, normalizeReasoningLevel, normalizeTraceLevel, normalizeThinkLevel, @@ -162,24 +161,6 @@ export function extractFastDirective(body?: string): { }; } -export function extractNoticeDirective(body?: string): { - cleaned: string; - noticeLevel?: NoticeLevel; - rawLevel?: string; - hasDirective: boolean; -} { - if (!body) { - return { cleaned: "", hasDirective: false }; - } - const extracted = extractLevelDirective(body, ["notice", "notices"], normalizeNoticeLevel); - return { - cleaned: extracted.cleaned, - noticeLevel: extracted.level, - rawLevel: extracted.rawLevel, - hasDirective: extracted.hasDirective, - }; -} - export function extractElevatedDirective(body?: string): { cleaned: string; elevatedLevel?: ElevatedLevel; diff --git a/src/auto-reply/reply/memory-flush.ts b/src/auto-reply/reply/memory-flush.ts index e4be2b3a7a0..6d2d76ec803 100644 --- a/src/auto-reply/reply/memory-flush.ts +++ b/src/auto-reply/reply/memory-flush.ts @@ -1,4 +1,3 @@ -import crypto from "node:crypto"; import { resolveContextTokensForModel } from "../../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS } from "../../agents/defaults.js"; import { parseNonNegativeByteSize } from "../../config/byte-size.js"; @@ -122,20 +121,3 @@ export function hasAlreadyFlushedForCurrentCompaction( const lastFlushAt = entry.memoryFlushCompactionCount; return typeof lastFlushAt === "number" && lastFlushAt === compactionCount; } - -/** - * Compute a lightweight content hash from the tail of a session transcript. - * Used for state-based flush deduplication — if the hash hasn't changed since - * the last flush, the context is effectively the same and flushing again would - * produce duplicate memory entries. - * - * Hash input: `messages.length` + content of the last 3 user/assistant messages. - * Algorithm: SHA-256 truncated to 16 hex chars (collision-resistant enough for dedup). - */ -export function computeContextHash(messages: Array<{ role?: string; content?: unknown }>): string { - const userAssistant = messages.filter((m) => m.role === "user" || m.role === "assistant"); - const tail = userAssistant.slice(-3); - const payload = `${messages.length}:${tail.map((m, i) => `[${i}:${m.role ?? ""}]${typeof m.content === "string" ? m.content : JSON.stringify(m.content ?? "")}`).join("\x00")}`; - const hash = crypto.createHash("sha256").update(payload).digest("hex"); - return hash.slice(0, 16); -} diff --git a/src/auto-reply/reply/mentions.ts b/src/auto-reply/reply/mentions.ts index 372167e8ede..95fe33d9db3 100644 --- a/src/auto-reply/reply/mentions.ts +++ b/src/auto-reply/reply/mentions.ts @@ -14,12 +14,7 @@ import { import { escapeRegExp } from "../../utils.js"; import type { MsgContext } from "../templating.js"; import type { ExplicitMentionSignal } from "./mentions.types.js"; -export type { - BuildMentionRegexes, - ExplicitMentionSignal, - MatchesMentionPatterns, - MatchesMentionWithExplicit, -} from "./mentions.types.js"; +export type { ExplicitMentionSignal } from "./mentions.types.js"; function deriveMentionPatterns(identity?: { name?: string; emoji?: string }) { const patterns: string[] = []; diff --git a/src/channels/plugins/allowlist-match.ts b/src/channels/plugins/allowlist-match.ts index 3fd989abc29..fdf4d1d7a99 100644 --- a/src/channels/plugins/allowlist-match.ts +++ b/src/channels/plugins/allowlist-match.ts @@ -1,2 +1,2 @@ export type { AllowlistMatch, AllowlistMatchSource } from "../allowlist-match.js"; -export { formatAllowlistMatchMeta, resolveAllowlistMatchSimple } from "../allowlist-match.js"; +export { formatAllowlistMatchMeta } from "../allowlist-match.js"; diff --git a/src/channels/plugins/binding-provider.ts b/src/channels/plugins/binding-provider.ts index dc455e113bb..27dc5c49951 100644 --- a/src/channels/plugins/binding-provider.ts +++ b/src/channels/plugins/binding-provider.ts @@ -1,4 +1,3 @@ -import { getChannelPlugin, normalizeChannelId } from "./registry.js"; import type { ChannelConfiguredBindingProvider } from "./types.adapters.js"; import type { ChannelPlugin } from "./types.plugin.js"; @@ -13,13 +12,3 @@ export function resolveChannelConfiguredBindingProvider( ): ChannelConfiguredBindingProvider | undefined { return plugin?.bindings; } - -export function resolveChannelConfiguredBindingProviderByChannel( - channel: string, -): ChannelConfiguredBindingProvider | undefined { - const normalizedChannel = normalizeChannelId(channel); - if (!normalizedChannel) { - return undefined; - } - return resolveChannelConfiguredBindingProvider(getChannelPlugin(normalizedChannel)); -} diff --git a/src/channels/plugins/bluebubbles-actions.ts b/src/channels/plugins/bluebubbles-actions.ts index 2f98dba717e..6b47be318c2 100644 --- a/src/channels/plugins/bluebubbles-actions.ts +++ b/src/channels/plugins/bluebubbles-actions.ts @@ -20,15 +20,6 @@ export const BLUEBUBBLES_ACTIONS = { sendAttachment: { gate: "sendAttachment" }, } as const satisfies Partial>; -const BLUEBUBBLES_ACTION_SPECS = BLUEBUBBLES_ACTIONS as Record< - keyof typeof BLUEBUBBLES_ACTIONS, - BlueBubblesActionSpec ->; - export const BLUEBUBBLES_ACTION_NAMES = Object.keys( BLUEBUBBLES_ACTIONS, ) as (keyof typeof BLUEBUBBLES_ACTIONS)[]; - -export const BLUEBUBBLES_GROUP_ACTIONS = new Set( - BLUEBUBBLES_ACTION_NAMES.filter((action) => BLUEBUBBLES_ACTION_SPECS[action]?.groupOnly), -); diff --git a/src/channels/plugins/bootstrap-registry.ts b/src/channels/plugins/bootstrap-registry.ts index 1e09adaf98b..9d7b4523a7f 100644 --- a/src/channels/plugins/bootstrap-registry.ts +++ b/src/channels/plugins/bootstrap-registry.ts @@ -73,10 +73,6 @@ export function* iterateBootstrapChannelPlugins(): IterableIterator, -): boolean { - return resolveChannelExposure(meta).docs; -} diff --git a/src/channels/plugins/pairing.ts b/src/channels/plugins/pairing.ts index e4bc8ad5163..7a9976af0e3 100644 --- a/src/channels/plugins/pairing.ts +++ b/src/channels/plugins/pairing.ts @@ -1,9 +1,8 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js"; import type { RuntimeEnv } from "../../runtime.js"; -import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js"; import type { ChannelId } from "./channel-id.types.js"; import type { ChannelPairingAdapter } from "./pairing.types.js"; -import { getChannelPlugin, listChannelPlugins, normalizeChannelId } from "./registry.js"; +import { getChannelPlugin, listChannelPlugins } from "./registry.js"; export function listPairingChannels(): ChannelId[] { // Channel docking: pairing support is declared via plugin.pairing. @@ -25,24 +24,6 @@ export function requirePairingAdapter(channelId: ChannelId): ChannelPairingAdapt return adapter; } -export function resolvePairingChannel(raw: unknown): ChannelId { - const value = - typeof raw === "string" - ? raw - : typeof raw === "number" || typeof raw === "boolean" - ? String(raw) - : ""; - const normalizedValue = normalizeLowercaseStringOrEmpty(value); - const normalized = normalizeChannelId(normalizedValue); - const channels = listPairingChannels(); - if (!normalized || !channels.includes(normalized)) { - throw new Error( - `Invalid channel: ${normalizedValue || "(empty)"} (expected one of: ${channels.join(", ")})`, - ); - } - return normalized; -} - export async function notifyPairingApproved(params: { channelId: ChannelId; id: string; diff --git a/src/cli/gateway-cli/run.option-collisions.test.ts b/src/cli/gateway-cli/run.option-collisions.test.ts index e34c7ce2180..171900b3529 100644 --- a/src/cli/gateway-cli/run.option-collisions.test.ts +++ b/src/cli/gateway-cli/run.option-collisions.test.ts @@ -317,7 +317,9 @@ describe("gateway run option collisions", () => { }); startGatewayServer.mockRejectedValueOnce(err); - await runGatewayCli(["gateway", "run", "--allow-unconfigured"]); + await expect(runGatewayCli(["gateway", "run", "--allow-unconfigured"])).rejects.toThrow( + "__exit__:0", + ); expect(writeDiagnosticStabilityBundleForFailureSync).not.toHaveBeenCalled(); }); diff --git a/src/cli/program/message/register.thread.ts b/src/cli/program/message/register.thread.ts index f67602acca4..755bce95374 100644 --- a/src/cli/program/message/register.thread.ts +++ b/src/cli/program/message/register.thread.ts @@ -77,5 +77,3 @@ export function registerMessageThreadCommands(message: Command, helpers: Message await helpers.runMessageAction("thread-reply", opts); }); } - -export const __test__ = { resolveThreadCreateRequest }; diff --git a/src/commands/agent/session.ts b/src/commands/agent/session.ts index 232bb38327c..46d7445709f 100644 --- a/src/commands/agent/session.ts +++ b/src/commands/agent/session.ts @@ -1 +1,4 @@ -export * from "../../agents/command/session.js"; +export { + buildExplicitSessionIdSessionKey, + resolveSessionKeyForRequest, +} from "../../agents/command/session.js"; diff --git a/src/commands/auth-choice.apply-helpers.ts b/src/commands/auth-choice.apply-helpers.ts index 17b9162ffe5..f3bee59ada5 100644 --- a/src/commands/auth-choice.apply-helpers.ts +++ b/src/commands/auth-choice.apply-helpers.ts @@ -1,99 +1,4 @@ -import type { ApplyAuthChoiceParams } from "./auth-choice.apply.types.js"; -import { applyDefaultModelChoice } from "./auth-choice.default-model.js"; - -export type { - SecretInputModePromptCopy, - SecretRefSetupPromptCopy, -} from "../plugins/provider-auth-input.js"; export { - ensureApiKeyFromEnvOrPrompt, - ensureApiKeyFromOptionEnvOrPrompt, - maybeApplyApiKeyFromOption, normalizeSecretInputModeInput, normalizeTokenProviderInput, - promptSecretRefForSetup, - resolveSecretInputModeForEnvSelection, } from "../plugins/provider-auth-input.js"; - -export function createAuthChoiceAgentModelNoter( - params: ApplyAuthChoiceParams, -): (model: string) => Promise { - return async (model: string) => { - if (!params.agentId) { - return; - } - await params.prompter.note( - `Default model set to ${model} for agent "${params.agentId}".`, - "Model configured", - ); - }; -} - -export interface ApplyAuthChoiceModelState { - config: ApplyAuthChoiceParams["config"]; - agentModelOverride: string | undefined; -} - -export function createAuthChoiceModelStateBridge(bindings: { - getConfig: () => ApplyAuthChoiceParams["config"]; - setConfig: (config: ApplyAuthChoiceParams["config"]) => void; - getAgentModelOverride: () => string | undefined; - setAgentModelOverride: (model: string | undefined) => void; -}): ApplyAuthChoiceModelState { - return { - get config() { - return bindings.getConfig(); - }, - set config(config) { - bindings.setConfig(config); - }, - get agentModelOverride() { - return bindings.getAgentModelOverride(); - }, - set agentModelOverride(model) { - bindings.setAgentModelOverride(model); - }, - }; -} - -export function createAuthChoiceDefaultModelApplier( - params: ApplyAuthChoiceParams, - state: ApplyAuthChoiceModelState, -): ( - options: Omit< - Parameters[0], - "config" | "setDefaultModel" | "noteAgentModel" | "prompter" - >, -) => Promise { - const noteAgentModel = createAuthChoiceAgentModelNoter(params); - - return async (options) => { - const applied = await applyDefaultModelChoice({ - config: state.config, - setDefaultModel: params.setDefaultModel, - noteAgentModel, - prompter: params.prompter, - ...options, - }); - state.config = applied.config; - state.agentModelOverride = applied.agentModelOverride ?? state.agentModelOverride; - }; -} - -export function createAuthChoiceDefaultModelApplierForMutableState( - params: ApplyAuthChoiceParams, - getConfig: () => ApplyAuthChoiceParams["config"], - setConfig: (config: ApplyAuthChoiceParams["config"]) => void, - getAgentModelOverride: () => string | undefined, - setAgentModelOverride: (model: string | undefined) => void, -): ReturnType { - return createAuthChoiceDefaultModelApplier( - params, - createAuthChoiceModelStateBridge({ - getConfig, - setConfig, - getAgentModelOverride, - setAgentModelOverride, - }), - ); -} diff --git a/src/commands/doctor/shared/legacy-web-fetch-migrate.ts b/src/commands/doctor/shared/legacy-web-fetch-migrate.ts index 1a44e8d5db6..68fbb541d27 100644 --- a/src/commands/doctor/shared/legacy-web-fetch-migrate.ts +++ b/src/commands/doctor/shared/legacy-web-fetch-migrate.ts @@ -1,5 +1,4 @@ import { mergeMissing } from "../../../config/legacy.shared.js"; -import type { OpenClawConfig } from "../../../config/types.openclaw.js"; import { cloneRecord, ensureRecord, @@ -85,19 +84,6 @@ export function listLegacyWebFetchConfigPaths(raw: unknown): string[] { return Object.keys(firecrawl).map((key) => `tools.web.fetch.firecrawl.${key}`); } -export function normalizeLegacyWebFetchConfig(raw: T): T { - if (!isRecord(raw)) { - return raw; - } - - const fetch = resolveLegacyFetchConfig(raw); - if (!fetch) { - return raw; - } - - return normalizeLegacyWebFetchConfigRecord(raw).config; -} - export function migrateLegacyWebFetchConfig(raw: T): { config: T; changes: string[] } { if (!isRecord(raw) || !hasMappedLegacyWebFetchConfig(raw)) { return { config: raw, changes: [] }; @@ -145,14 +131,3 @@ function normalizeLegacyWebFetchConfigRecord( return { config: nextRoot, changes }; } - -export function resolvePluginWebFetchConfig( - config: OpenClawConfig | undefined, - pluginId: string, -): Record | undefined { - const pluginConfig = config?.plugins?.entries?.[pluginId]?.config; - if (!isRecord(pluginConfig)) { - return undefined; - } - return isRecord(pluginConfig.webFetch) ? pluginConfig.webFetch : undefined; -} diff --git a/src/commands/doctor/shared/legacy-web-search-migrate.ts b/src/commands/doctor/shared/legacy-web-search-migrate.ts index 4b4a22ea110..5089a518a90 100644 --- a/src/commands/doctor/shared/legacy-web-search-migrate.ts +++ b/src/commands/doctor/shared/legacy-web-search-migrate.ts @@ -1,5 +1,4 @@ import { mergeMissing } from "../../../config/legacy.shared.js"; -import type { OpenClawConfig } from "../../../config/types.openclaw.js"; import { loadPluginManifestRegistryForPluginRegistry, resolveManifestContractOwnerPluginId, @@ -155,19 +154,6 @@ export function listLegacyWebSearchConfigPaths(raw: unknown): string[] { return paths; } -export function normalizeLegacyWebSearchConfig(raw: T): T { - if (!isRecord(raw)) { - return raw; - } - - const search = resolveLegacySearchConfig(raw); - if (!search) { - return raw; - } - - return normalizeLegacyWebSearchConfigRecord(raw).config; -} - export function migrateLegacyWebSearchConfig(raw: T): { config: T; changes: string[] } { if (!isRecord(raw)) { return { config: raw, changes: [] }; @@ -249,15 +235,3 @@ function normalizeLegacyWebSearchConfigRecord( return { config: nextRoot, changes }; } - -export function resolvePluginWebSearchConfig( - config: OpenClawConfig | undefined, - pluginId: string, -): Record | undefined { - const pluginConfig = config?.plugins?.entries?.[pluginId]?.config; - if (!isRecord(pluginConfig)) { - return undefined; - } - const webSearch = pluginConfig.webSearch; - return isRecord(webSearch) ? webSearch : undefined; -} diff --git a/src/commands/models/auth.test.ts b/src/commands/models/auth.test.ts index c370905a22a..fa3879b112c 100644 --- a/src/commands/models/auth.test.ts +++ b/src/commands/models/auth.test.ts @@ -117,7 +117,7 @@ vi.mock("../oauth-env.js", () => ({ isRemoteEnvironment: mocks.isRemoteEnvironment, })); -vi.mock("../oauth-flow.js", () => ({ +vi.mock("../../plugins/provider-oauth-flow.js", () => ({ createVpsAwareOAuthHandlers: vi.fn(() => ({ onAuth: vi.fn(), onPrompt: vi.fn(), @@ -128,7 +128,7 @@ vi.mock("../auth-token.js", () => ({ validateAnthropicSetupToken: vi.fn(() => undefined), })); -vi.mock("../provider-auth-helpers.js", () => { +vi.mock("../../plugins/provider-auth-choice-helpers.js", () => { const normalize = (value: string | undefined) => value?.trim().toLowerCase() ?? ""; const isRecord = (value: unknown): value is Record => Boolean(value && typeof value === "object" && !Array.isArray(value)); diff --git a/src/commands/models/auth.ts b/src/commands/models/auth.ts index 112aaa5d3ed..1d985185c1c 100644 --- a/src/commands/models/auth.ts +++ b/src/commands/models/auth.ts @@ -21,7 +21,14 @@ import { formatCliCommand } from "../../cli/command-format.js"; import { parseDurationMs } from "../../cli/parse-duration.js"; import { logConfigUpdated } from "../../config/logging.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; +import { + applyProviderAuthConfigPatch, + applyDefaultModel, + pickAuthMethod, + resolveProviderMatch, +} from "../../plugins/provider-auth-choice-helpers.js"; import { applyAuthProfileConfig } from "../../plugins/provider-auth-helpers.js"; +import { createVpsAwareOAuthHandlers } from "../../plugins/provider-oauth-flow.js"; import { resolvePluginProviders } from "../../plugins/providers.runtime.js"; import type { ProviderAuthMethod, @@ -37,13 +44,6 @@ import { stylePromptHint, stylePromptMessage } from "../../terminal/prompt-style import { createClackPrompter } from "../../wizard/clack-prompter.js"; import { validateAnthropicSetupToken } from "../auth-token.js"; import { isRemoteEnvironment } from "../oauth-env.js"; -import { createVpsAwareOAuthHandlers } from "../oauth-flow.js"; -import { - applyProviderAuthConfigPatch, - applyDefaultModel, - pickAuthMethod, - resolveProviderMatch, -} from "../provider-auth-helpers.js"; import { loadValidConfigOrThrow, resolveKnownAgentId, updateConfig } from "./shared.js"; function guardCancel(value: T | symbol): T { diff --git a/src/commands/models/list.format.ts b/src/commands/models/list.format.ts index f80debebc09..9d1152dcd74 100644 --- a/src/commands/models/list.format.ts +++ b/src/commands/models/list.format.ts @@ -1,4 +1,4 @@ -import { colorize, isRich as isRichTerminal, theme } from "../../terminal/theme.js"; +import { isRich as isRichTerminal, theme } from "../../terminal/theme.js"; export { maskApiKey } from "../../utils/mask-api-key.js"; export const isRich = (opts?: { json?: boolean; plain?: boolean }) => @@ -6,19 +6,6 @@ export const isRich = (opts?: { json?: boolean; plain?: boolean }) => export const pad = (value: string, size: number) => value.padEnd(size); -export const formatKey = (key: string, rich: boolean) => colorize(rich, theme.warn, key); - -export const formatValue = (value: string, rich: boolean) => colorize(rich, theme.info, value); - -export const formatKeyValue = ( - key: string, - value: string, - rich: boolean, - valueColor: (value: string) => string = theme.info, -) => `${formatKey(key, rich)}=${colorize(rich, valueColor, value)}`; - -export const formatSeparator = (rich: boolean) => colorize(rich, theme.muted, " | "); - export const formatTag = (tag: string, rich: boolean) => { if (!rich) { return tag; diff --git a/src/commands/node-daemon-runtime.ts b/src/commands/node-daemon-runtime.ts index c1375f979ca..535c20ce623 100644 --- a/src/commands/node-daemon-runtime.ts +++ b/src/commands/node-daemon-runtime.ts @@ -1,6 +1,5 @@ import { DEFAULT_GATEWAY_DAEMON_RUNTIME, - GATEWAY_DAEMON_RUNTIME_OPTIONS, isGatewayDaemonRuntime, type GatewayDaemonRuntime, } from "./daemon-runtime.js"; @@ -9,8 +8,6 @@ export type NodeDaemonRuntime = GatewayDaemonRuntime; export const DEFAULT_NODE_DAEMON_RUNTIME = DEFAULT_GATEWAY_DAEMON_RUNTIME; -export const NODE_DAEMON_RUNTIME_OPTIONS = GATEWAY_DAEMON_RUNTIME_OPTIONS; - export function isNodeDaemonRuntime(value: string | undefined): value is NodeDaemonRuntime { return isGatewayDaemonRuntime(value); } diff --git a/src/commands/oauth-flow.ts b/src/commands/oauth-flow.ts deleted file mode 100644 index 48e89b25720..00000000000 --- a/src/commands/oauth-flow.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../plugins/provider-oauth-flow.js"; diff --git a/src/commands/onboard-custom.test.ts b/src/commands/onboard-custom.test.ts index ab56ff99f3d..b71ab6e07d2 100644 --- a/src/commands/onboard-custom.test.ts +++ b/src/commands/onboard-custom.test.ts @@ -2,8 +2,6 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import type { ensureApiKeyFromEnvOrPrompt } from "../plugins/provider-auth-input.js"; import { promptCustomApiConfig } from "./onboard-custom.js"; -const OLLAMA_DEFAULT_BASE_URL_FOR_TEST = "http://127.0.0.1:11434"; - vi.mock("../plugins/provider-auth-input.js", () => ({ ensureApiKeyFromEnvOrPrompt: vi.fn( async (params: Parameters[0]) => { @@ -138,7 +136,7 @@ describe("promptCustomApiConfig", () => { }); }); - it("defaults custom setup to the native Ollama base URL", async () => { + it("does not seed custom setup with a provider-specific base URL", async () => { const prompter = createTestPrompter({ text: ["http://localhost:11434", "", "llama3", "custom", ""], select: ["plaintext", "openai"], @@ -150,7 +148,7 @@ describe("promptCustomApiConfig", () => { expect(prompter.text).toHaveBeenCalledWith( expect.objectContaining({ message: "API Base URL", - initialValue: OLLAMA_DEFAULT_BASE_URL_FOR_TEST, + initialValue: undefined, }), ); }); diff --git a/src/commands/onboard-custom.ts b/src/commands/onboard-custom.ts index 24927eaa294..0fd2eba0f03 100644 --- a/src/commands/onboard-custom.ts +++ b/src/commands/onboard-custom.ts @@ -2,7 +2,6 @@ import { modelKey } from "../agents/model-selection.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import type { SecretInput } from "../config/types.secrets.js"; import { ensureApiKeyFromEnvOrPrompt } from "../plugins/provider-auth-input.js"; -import { OLLAMA_DEFAULT_BASE_URL } from "../plugins/provider-model-defaults.js"; import type { RuntimeEnv } from "../runtime.js"; import { fetchWithTimeout } from "../utils/fetch-timeout.js"; import { normalizeSecretInput } from "../utils/normalize-secret-input.js"; @@ -137,7 +136,7 @@ async function promptBaseUrlAndKey(params: { }): Promise<{ baseUrl: string; apiKey?: SecretInput; resolvedApiKey: string }> { const baseUrlInput = await params.prompter.text({ message: "API Base URL", - initialValue: params.initialBaseUrl ?? OLLAMA_DEFAULT_BASE_URL, + initialValue: params.initialBaseUrl, placeholder: "https://api.example.com/v1", validate: (val) => { return URL.canParse(val) ? undefined : "Please enter a valid URL (e.g. http://...)"; diff --git a/src/commands/provider-auth-helpers.ts b/src/commands/provider-auth-helpers.ts deleted file mode 100644 index a9fabf9f1bd..00000000000 --- a/src/commands/provider-auth-helpers.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "../plugins/provider-auth-choice-helpers.js"; diff --git a/src/commands/sandbox-formatters.ts b/src/commands/sandbox-formatters.ts index b48f5878aec..2fa0f0638bd 100644 --- a/src/commands/sandbox-formatters.ts +++ b/src/commands/sandbox-formatters.ts @@ -14,20 +14,6 @@ export function formatImageMatch(matches: boolean): string { return matches ? "✓" : "⚠️ mismatch"; } -/** - * Type guard and counter utilities - */ - -export type ContainerItem = { - running: boolean; - imageMatch: boolean; - containerName: string; - sessionKey: string; - image: string; - createdAtMs: number; - lastUsedAtMs: number; -}; - export function countRunning(items: readonly { running: boolean }[]): number { return items.filter((item) => item.running).length; } diff --git a/src/commands/status-all/gateway.ts b/src/commands/status-all/gateway.ts index fc671418766..a1d1b60ebbd 100644 --- a/src/commands/status-all/gateway.ts +++ b/src/commands/status-all/gateway.ts @@ -178,5 +178,3 @@ export function summarizeLogTail(rawLines: string[], opts?: { maxLines?: number ]; return kept; } - -export { pickGatewaySelfPresence } from "../gateway-presence.js"; diff --git a/src/commands/status.scan.bootstrap-shared.ts b/src/commands/status.scan.bootstrap-shared.ts index 045da41a138..8d09f56317f 100644 --- a/src/commands/status.scan.bootstrap-shared.ts +++ b/src/commands/status.scan.bootstrap-shared.ts @@ -71,15 +71,6 @@ type StatusScanCoreBootstrapParams = { getAgentLocalStatuses: (cfg: OpenClawConfig) => Promise; }; -type StatusScanBootstrapParams = - StatusScanCoreBootstrapParams & { - sourceConfig: OpenClawConfig; - getStatusSummary: (params: { - config: OpenClawConfig; - sourceConfig: OpenClawConfig; - }) => Promise; - }; - export async function createStatusScanCoreBootstrap( params: StatusScanCoreBootstrapParams, ) { @@ -131,27 +122,3 @@ export async function createStatusScanCoreBootstrap( }), }; } - -export async function createStatusScanBootstrap( - params: StatusScanBootstrapParams, -) { - const core = await createStatusScanCoreBootstrap({ - coldStart: params.coldStart, - cfg: params.cfg, - hasConfiguredChannels: params.hasConfiguredChannels, - opts: params.opts, - getTailnetHostname: params.getTailnetHostname, - getUpdateCheckResult: params.getUpdateCheckResult, - getAgentLocalStatuses: params.getAgentLocalStatuses, - }); - const summaryPromise = core.skipColdStartNetworkChecks - ? Promise.resolve(buildColdStartStatusSummary() as TSummary) - : params.getStatusSummary({ - config: params.cfg, - sourceConfig: params.sourceConfig, - }); - return { - ...core, - summaryPromise, - }; -} diff --git a/src/compat/legacy-names.ts b/src/compat/legacy-names.ts index 684f21b2bab..f5f6c21da9d 100644 --- a/src/compat/legacy-names.ts +++ b/src/compat/legacy-names.ts @@ -6,10 +6,4 @@ export const MANIFEST_KEY = PROJECT_NAME; export const LEGACY_MANIFEST_KEYS = LEGACY_PROJECT_NAMES; -export const LEGACY_PLUGIN_MANIFEST_FILENAMES = [] as const; - -export const LEGACY_CANVAS_HANDLER_NAMES = [] as const; - export const MACOS_APP_SOURCES_DIR = "apps/macos/Sources/OpenClaw" as const; - -export const LEGACY_MACOS_APP_SOURCES_DIRS = [] as const; diff --git a/src/config/bindings.ts b/src/config/bindings.ts index 0307db4b8e7..049fd5ddfad 100644 --- a/src/config/bindings.ts +++ b/src/config/bindings.ts @@ -1,8 +1,6 @@ import type { AgentAcpBinding, AgentBinding, AgentRouteBinding } from "./types.agents.js"; import type { OpenClawConfig } from "./types.openclaw.js"; -export type ConfiguredBindingRule = AgentBinding; - function normalizeBindingType(binding: AgentBinding): "route" | "acp" { return binding.type === "acp" ? "acp" : "route"; } diff --git a/src/config/defaults.ts b/src/config/defaults.ts index 9f9812f35ba..242d4c82ac1 100644 --- a/src/config/defaults.ts +++ b/src/config/defaults.ts @@ -405,7 +405,3 @@ export function applyCompactionDefaults(cfg: OpenClawConfig): OpenClawConfig { }, }; } - -export function resetSessionDefaultsWarningForTests() { - defaultWarnState = { warned: false }; -} diff --git a/src/config/legacy.shared.ts b/src/config/legacy.shared.ts index 60ced600741..5134c0e18e3 100644 --- a/src/config/legacy.shared.ts +++ b/src/config/legacy.shared.ts @@ -18,7 +18,6 @@ export type LegacyConfigMigrationSpec = LegacyConfigMigration & { }; import { isSafeExecutableValue } from "../infra/exec-safety.js"; -import { normalizeOptionalString } from "../shared/string-coerce.js"; import { isRecord } from "../utils.js"; import { isBlockedObjectKey } from "./prototype-keys.js"; export { isRecord }; @@ -89,53 +88,6 @@ export const mapLegacyAudioTranscription = (value: unknown): Record | null) => { - const list = agents?.list; - return Array.isArray(list) ? list : []; -}; - -export const resolveDefaultAgentIdFromRaw = (raw: Record) => { - const agents = getRecord(raw.agents); - const list = getAgentsList(agents); - const defaultEntry = list.find( - (entry): entry is { id: string } => - isRecord(entry) && - entry.default === true && - typeof entry.id === "string" && - normalizeOptionalString(entry.id) !== undefined, - ); - if (defaultEntry) { - return normalizeOptionalString(defaultEntry.id) ?? "main"; - } - const routing = getRecord(raw.routing); - const routingDefault = normalizeOptionalString(routing?.defaultAgentId) ?? ""; - if (routingDefault) { - return routingDefault; - } - const firstEntry = list.find( - (entry): entry is { id: string } => - isRecord(entry) && normalizeOptionalString(entry.id) !== undefined, - ); - if (firstEntry) { - return normalizeOptionalString(firstEntry.id) ?? "main"; - } - return "main"; -}; - -export const ensureAgentEntry = (list: unknown[], id: string): Record => { - const normalized = id.trim(); - const existing = list.find( - (entry): entry is Record => - isRecord(entry) && typeof entry.id === "string" && entry.id.trim() === normalized, - ); - if (existing) { - return existing; - } - const created: Record = { id: normalized }; - list.push(created); - return created; -}; - export const defineLegacyConfigMigration = ( migration: LegacyConfigMigrationSpec, ): LegacyConfigMigrationSpec => migration; diff --git a/src/config/plugin-install-config-migration.ts b/src/config/plugin-install-config-migration.ts index fa46b9409f9..e1650799a0e 100644 --- a/src/config/plugin-install-config-migration.ts +++ b/src/config/plugin-install-config-migration.ts @@ -36,13 +36,3 @@ export function stripShippedPluginInstallConfigRecords(config: unknown): unknown const { plugins: _plugins, ...rest } = config; return plugins === undefined ? rest : { ...rest, plugins }; } - -export function prepareShippedPluginInstallConfigMigration(config: unknown): { - config: unknown; - installRecords: Record; -} { - return { - config: stripShippedPluginInstallConfigRecords(config), - installRecords: extractShippedPluginInstallConfigRecords(config), - }; -} diff --git a/src/config/port-defaults.ts b/src/config/port-defaults.ts index ac21045168d..b09f590658e 100644 --- a/src/config/port-defaults.ts +++ b/src/config/port-defaults.ts @@ -1,4 +1,4 @@ -export type PortRange = { start: number; end: number }; +type PortRange = { start: number; end: number }; function isValidPort(port: number): boolean { return Number.isFinite(port) && port > 0 && port <= 65535; @@ -12,26 +12,11 @@ function derivePort(base: number, offset: number, fallback: number): number { return clampPort(base + offset, fallback); } -export const DEFAULT_BRIDGE_PORT = 18790; -export const DEFAULT_BROWSER_CONTROL_PORT = 18791; -export const DEFAULT_CANVAS_HOST_PORT = 18793; export const DEFAULT_BROWSER_CDP_PORT_RANGE_START = 18800; export const DEFAULT_BROWSER_CDP_PORT_RANGE_END = 18899; const DEFAULT_BROWSER_CDP_PORT_RANGE_SPAN = DEFAULT_BROWSER_CDP_PORT_RANGE_END - DEFAULT_BROWSER_CDP_PORT_RANGE_START; -export function deriveDefaultBridgePort(gatewayPort: number): number { - return derivePort(gatewayPort, 1, DEFAULT_BRIDGE_PORT); -} - -export function deriveDefaultBrowserControlPort(gatewayPort: number): number { - return derivePort(gatewayPort, 2, DEFAULT_BROWSER_CONTROL_PORT); -} - -export function deriveDefaultCanvasHostPort(gatewayPort: number): number { - return derivePort(gatewayPort, 4, DEFAULT_CANVAS_HOST_PORT); -} - export function deriveDefaultBrowserCdpPortRange(browserControlPort: number): PortRange { const start = derivePort(browserControlPort, 9, DEFAULT_BROWSER_CDP_PORT_RANGE_START); const end = start + DEFAULT_BROWSER_CDP_PORT_RANGE_SPAN; diff --git a/src/cron/service/timer.ts b/src/cron/service/timer.ts index 324d4135aa6..d0909d4a984 100644 --- a/src/cron/service/timer.ts +++ b/src/cron/service/timer.ts @@ -1291,17 +1291,6 @@ async function applyStartupCatchupOutcomes( }); } -export async function runDueJobs(state: CronServiceState) { - if (!state.store) { - return; - } - const now = state.deps.nowMs(); - const due = collectRunnableJobs(state, now); - for (const job of due) { - await executeJob(state, job, now, { forced: false }); - } -} - export async function executeJobCore( state: CronServiceState, job: CronJob, diff --git a/src/flows/provider-flow.ts b/src/flows/provider-flow.ts index 97f45fc287f..2b1e192814a 100644 --- a/src/flows/provider-flow.ts +++ b/src/flows/provider-flow.ts @@ -13,8 +13,6 @@ export type ProviderSetupFlowOption = FlowOption & { onboardingScopes?: ProviderFlowScope[]; }; -export type ProviderModelPickerFlowEntry = FlowOption; - export type ProviderSetupFlowContribution = FlowContribution & { kind: "provider"; surface: "setup"; diff --git a/src/gateway/canvas-documents.ts b/src/gateway/canvas-documents.ts index f73e0a7dd4c..bb307b15236 100644 --- a/src/gateway/canvas-documents.ts +++ b/src/gateway/canvas-documents.ts @@ -304,29 +304,6 @@ export async function createCanvasDocument( return manifest; } -export async function loadCanvasDocumentManifest( - documentId: string, - options?: { stateDir?: string; canvasRootDir?: string }, -): Promise { - const id = normalizeCanvasDocumentId(documentId); - const manifestPath = path.join( - resolveCanvasDocumentDir(id, { - stateDir: options?.stateDir, - rootDir: options?.canvasRootDir, - }), - "manifest.json", - ); - try { - const raw = await fs.readFile(manifestPath, "utf8"); - const parsed = JSON.parse(raw); - return parsed && typeof parsed === "object" && !Array.isArray(parsed) - ? (parsed as CanvasDocumentManifest) - : null; - } catch { - return null; - } -} - export function resolveCanvasDocumentAssets( manifest: CanvasDocumentManifest, options?: { baseUrl?: string; stateDir?: string; canvasRootDir?: string }, diff --git a/src/gateway/chat-abort.ts b/src/gateway/chat-abort.ts index 70bf1472122..f378a20d7d2 100644 --- a/src/gateway/chat-abort.ts +++ b/src/gateway/chat-abort.ts @@ -197,24 +197,3 @@ export function abortChatRunById( } return { aborted: true }; } - -export function abortChatRunsForSessionKey( - ops: ChatAbortOps, - params: { - sessionKey: string; - stopReason?: string; - }, -): { aborted: boolean; runIds: string[] } { - const { sessionKey, stopReason } = params; - const runIds: string[] = []; - for (const [runId, active] of ops.chatAbortControllers) { - if (active.sessionKey !== sessionKey) { - continue; - } - const res = abortChatRunById(ops, { runId, sessionKey, stopReason }); - if (res.aborted) { - runIds.push(runId); - } - } - return { aborted: runIds.length > 0, runIds }; -} diff --git a/src/gateway/credentials.ts b/src/gateway/credentials.ts index c1d066b5c1d..2f944dcb7df 100644 --- a/src/gateway/credentials.ts +++ b/src/gateway/credentials.ts @@ -323,14 +323,3 @@ export function resolveGatewayProbeCredentialsFromConfig(params: { remoteTokenFallback: "remote-only", }); } - -export function resolveGatewayDriftCheckCredentialsFromConfig(params: { - cfg: OpenClawConfig; -}): ResolvedGatewayCredentials { - return resolveGatewayCredentialsFromConfig({ - cfg: params.cfg, - env: {} as NodeJS.ProcessEnv, - modeOverride: "local", - localTokenPrecedence: "config-first", - }); -} diff --git a/src/gateway/net.ts b/src/gateway/net.ts index 3c23227597d..eccf604f850 100644 --- a/src/gateway/net.ts +++ b/src/gateway/net.ts @@ -9,7 +9,7 @@ import { pickMatchingExternalInterfaceAddress, readNetworkInterfaces, } from "../infra/network-interfaces.js"; -import { pickPrimaryTailnetIPv4, pickPrimaryTailnetIPv6 } from "../infra/tailnet.js"; +import { pickPrimaryTailnetIPv4 } from "../infra/tailnet.js"; import { isCanonicalDottedDecimalIPv4, isIpInCidr, @@ -206,31 +206,6 @@ export function resolveRequestClientIp( }); } -export function isLocalGatewayAddress(ip: string | undefined): boolean { - if (isLoopbackAddress(ip)) { - return true; - } - if (!ip) { - return false; - } - const normalized = normalizeIp(ip); - if (!normalized) { - return false; - } - const tailnetIPv4 = pickPrimaryTailnetIPv4(); - if (tailnetIPv4 && normalized === normalizeLowercaseStringOrEmpty(tailnetIPv4)) { - return true; - } - const tailnetIPv6 = pickPrimaryTailnetIPv6(); - if ( - tailnetIPv6 && - normalizeLowercaseStringOrEmpty(ip) === normalizeLowercaseStringOrEmpty(tailnetIPv6) - ) { - return true; - } - return false; -} - export { isContainerEnvironment, __resetContainerEnvironmentCacheForTest as __resetContainerCacheForTest, diff --git a/src/gateway/security-path.ts b/src/gateway/security-path.ts index 0802c0e22d2..d369146b71c 100644 --- a/src/gateway/security-path.ts +++ b/src/gateway/security-path.ts @@ -121,11 +121,6 @@ export function canonicalizePathForSecurity(pathname: string): SecurityPathCanon }; } -export function hasSecurityPathCanonicalizationAnomaly(pathname: string): boolean { - const canonical = canonicalizePathForSecurity(pathname); - return canonical.malformedEncoding || canonical.decodePassLimitReached; -} - const normalizedPrefixesCache = new WeakMap(); function getNormalizedPrefixes(prefixes: readonly string[]): readonly string[] { diff --git a/src/gateway/server-methods/doctor.memory-core-runtime.ts b/src/gateway/server-methods/doctor.memory-core-runtime.ts index 1912107d72c..e4d1b8dc82e 100644 --- a/src/gateway/server-methods/doctor.memory-core-runtime.ts +++ b/src/gateway/server-methods/doctor.memory-core-runtime.ts @@ -1,6 +1,5 @@ export { dedupeDreamDiaryEntries, - filterRecallEntriesWithinLookback, previewGroundedRemMarkdown, previewRemHarness, removeBackfillDiaryEntries, diff --git a/src/gateway/server-methods/doctor.ts b/src/gateway/server-methods/doctor.ts index 382f19ce387..95e05fcb4de 100644 --- a/src/gateway/server-methods/doctor.ts +++ b/src/gateway/server-methods/doctor.ts @@ -227,10 +227,6 @@ export type DoctorMemoryRemHarnessErrorPayload = { error: string; }; -export type DoctorMemoryRemHarnessPayload = - | DoctorMemoryRemHarnessSuccessPayload - | DoctorMemoryRemHarnessErrorPayload; - function extractIsoDayFromPath(filePath: string): string | null { const match = filePath.replaceAll("\\", "/").match(/(\d{4}-\d{2}-\d{2})\.md$/i); return match?.[1] ?? null; diff --git a/src/gateway/server-methods/models-auth-status.ts b/src/gateway/server-methods/models-auth-status.ts index e7533872824..51de215ed3d 100644 --- a/src/gateway/server-methods/models-auth-status.ts +++ b/src/gateway/server-methods/models-auth-status.ts @@ -24,9 +24,6 @@ import type { GatewayRequestHandlers } from "./types.js"; const log = createSubsystemLogger("models-auth-status"); -/** The `ts` sentinel the UI uses to distinguish "never loaded" from "load failed". */ -export const MODEL_AUTH_STATUS_NEVER_LOADED = 0; - /** * Models-auth status wire types. Mirrored in ui/src/ui/types.ts via an * `import(...)` re-export — edit here and the UI picks up the change. diff --git a/src/gateway/server-methods/nodes.helpers.ts b/src/gateway/server-methods/nodes.helpers.ts index 110f7592daa..5e8969a2473 100644 --- a/src/gateway/server-methods/nodes.helpers.ts +++ b/src/gateway/server-methods/nodes.helpers.ts @@ -32,13 +32,6 @@ export async function respondUnavailableOnThrow(respond: RespondFn, fn: () => Pr } } -export function uniqueSortedStrings(values: unknown[]) { - return [...new Set(values.filter((v) => typeof v === "string"))] - .map((v) => v.trim()) - .filter(Boolean) - .toSorted(); -} - export function respondUnavailableOnNodeInvokeError( respond: RespondFn, res: T, diff --git a/src/hooks/workspace.ts b/src/hooks/workspace.ts index 84320311e53..c4c1a7c3aa4 100644 --- a/src/hooks/workspace.ts +++ b/src/hooks/workspace.ts @@ -7,7 +7,6 @@ import { createSubsystemLogger } from "../logging/subsystem.js"; import { isPathInsideWithRealpath } from "../security/scan-paths.js"; import { CONFIG_DIR, resolveUserPath } from "../utils.js"; import { resolveBundledHooksDir } from "./bundled-dir.js"; -import { shouldIncludeHook } from "./config.js"; import { parseFrontmatter, resolveHookInvocationPolicy, @@ -15,14 +14,7 @@ import { } from "./frontmatter.js"; import { resolvePluginHookDirs } from "./plugin-hooks.js"; import { resolveHookEntries } from "./policy.js"; -import type { - Hook, - HookEligibilityContext, - HookEntry, - HookSnapshot, - HookSource, - ParsedHookFrontmatter, -} from "./types.js"; +import type { Hook, HookEntry, HookSource, ParsedHookFrontmatter } from "./types.js"; type HookPackageManifest = { name?: string; @@ -34,14 +26,6 @@ type LoadedHook = { frontmatter: ParsedHookFrontmatter; }; -function filterHookEntries( - entries: HookEntry[], - config?: OpenClawConfig, - eligibility?: HookEligibilityContext, -): HookEntry[] { - return entries.filter((entry) => shouldIncludeHook({ entry, config, eligibility })); -} - function readHookPackageManifest(dir: string): HookPackageManifest | null { const manifestPath = path.join(dir, "package.json"); const raw = readBoundaryFileUtf8({ @@ -291,30 +275,6 @@ export function discoverWorkspaceHookEntries( return [...extraHooks, ...bundledHooks, ...pluginHooks, ...managedHooks, ...workspaceHooks]; } -export function buildWorkspaceHookSnapshot( - workspaceDir: string, - opts?: { - config?: OpenClawConfig; - managedHooksDir?: string; - bundledHooksDir?: string; - entries?: HookEntry[]; - eligibility?: HookEligibilityContext; - snapshotVersion?: number; - }, -): HookSnapshot { - const hookEntries = opts?.entries ?? loadWorkspaceHookEntries(workspaceDir, opts); - const eligible = filterHookEntries(hookEntries, opts?.config, opts?.eligibility); - - return { - hooks: eligible.map((entry) => ({ - name: entry.hook.name, - events: entry.metadata?.events ?? [], - })), - resolvedHooks: eligible.map((entry) => entry.hook), - version: opts?.snapshotVersion, - }; -} - export function loadWorkspaceHookEntries( workspaceDir: string, opts?: { diff --git a/src/infra/diagnostic-trace-context.ts b/src/infra/diagnostic-trace-context.ts index d8705af730e..d7c1cc0f8ac 100644 --- a/src/infra/diagnostic-trace-context.ts +++ b/src/infra/diagnostic-trace-context.ts @@ -230,13 +230,6 @@ export function runWithDiagnosticTraceContext( return getDiagnosticTraceScopeState().storage.run(freezeDiagnosticTraceContext(trace), callback); } -export function runWithNewDiagnosticTraceContext( - input: DiagnosticTraceContextInput, - callback: () => T, -): T { - return runWithDiagnosticTraceContext(createDiagnosticTraceContext(input), callback); -} - export function resetDiagnosticTraceContextForTest(): void { getDiagnosticTraceScopeState().storage.disable(); } diff --git a/src/infra/dotenv.ts b/src/infra/dotenv.ts index 305a19a5e57..d15654668fa 100644 --- a/src/infra/dotenv.ts +++ b/src/infra/dotenv.ts @@ -167,23 +167,6 @@ function readDotEnvFile(params: { return { filePath: params.filePath, entries }; } -export function loadRuntimeDotEnvFile(filePath: string, opts?: { quiet?: boolean }) { - const parsed = readDotEnvFile({ - filePath, - shouldBlockKey: shouldBlockRuntimeDotEnvKey, - quiet: opts?.quiet ?? true, - }); - if (!parsed) { - return; - } - for (const { key, value } of parsed.entries) { - if (process.env[key] !== undefined) { - continue; - } - process.env[key] = value; - } -} - export function loadWorkspaceDotEnvFile(filePath: string, opts?: { quiet?: boolean }) { const parsed = readDotEnvFile({ filePath, diff --git a/src/infra/exec-approval-forwarder.ts b/src/infra/exec-approval-forwarder.ts index a0e41da28a0..282249278aa 100644 --- a/src/infra/exec-approval-forwarder.ts +++ b/src/infra/exec-approval-forwarder.ts @@ -791,13 +791,3 @@ export function createExecApprovalForwarder( }, }; } - -export function shouldForwardExecApproval(params: { - config?: ExecApprovalForwardingConfig; - request: ExecApprovalRequest; -}): boolean { - return shouldForwardRoute({ - config: params.config, - routeRequest: execApprovalStrategy.getRouteRequestFromRequest(params.request), - }); -} diff --git a/src/infra/tailscale.ts b/src/infra/tailscale.ts index 251df488c93..6dc8a5cf935 100644 --- a/src/infra/tailscale.ts +++ b/src/infra/tailscale.ts @@ -179,18 +179,6 @@ export async function getTailscaleBinary(): Promise { return cachedTailscaleBinary ?? "tailscale"; } -export async function readTailscaleStatusJson( - exec: typeof runExec = runExec, - opts?: { timeoutMs?: number }, -): Promise> { - const tailscaleBin = await getTailscaleBinary(); - const { stdout } = await exec(tailscaleBin, ["status", "--json"], { - timeoutMs: opts?.timeoutMs ?? 5000, - maxBuffer: 400_000, - }); - return stdout ? parsePossiblyNoisyJsonObject(stdout) : {}; -} - export async function ensureGoInstalled( exec: typeof runExec = runExec, prompt: typeof promptYesNo = promptYesNo, diff --git a/src/logging/diagnostic-stability.ts b/src/logging/diagnostic-stability.ts index 493e67e32ed..01bc9125b60 100644 --- a/src/logging/diagnostic-stability.ts +++ b/src/logging/diagnostic-stability.ts @@ -103,12 +103,6 @@ export type DiagnosticStabilitySnapshot = { }; }; -export type DiagnosticStabilityQuery = { - limit?: number; - type?: string; - sinceSeq?: number; -}; - export type DiagnosticStabilityQueryInput = { limit?: unknown; type?: unknown; diff --git a/src/logging/diagnostic-support-bundle.ts b/src/logging/diagnostic-support-bundle.ts index 3af4451b44a..815e6921f93 100644 --- a/src/logging/diagnostic-support-bundle.ts +++ b/src/logging/diagnostic-support-bundle.ts @@ -98,23 +98,6 @@ export function writeSupportBundleFile(outputDir: string, file: DiagnosticSuppor }); } -export function copySupportBundleFile(params: { - outputDir: string; - sourceFile: string; - path: string; -}): DiagnosticSupportBundleContent { - const outputPath = resolveSupportBundleFilePath(params.outputDir, params.path); - fs.mkdirSync(path.dirname(outputPath), { recursive: true, mode: 0o700 }); - fs.copyFileSync(params.sourceFile, outputPath, fs.constants.COPYFILE_EXCL); - fs.chmodSync(outputPath, 0o600); - const stat = fs.statSync(outputPath); - return { - path: assertSafeBundleRelativePath(params.path), - mediaType: "application/x-ndjson", - bytes: stat.size, - }; -} - export function writeSupportBundleDirectory(params: { outputDir: string; files: readonly DiagnosticSupportBundleFile[]; diff --git a/src/media-understanding/resolve.ts b/src/media-understanding/resolve.ts index 334ef4357aa..969c2e86d8c 100644 --- a/src/media-understanding/resolve.ts +++ b/src/media-understanding/resolve.ts @@ -65,13 +65,6 @@ export function resolveMaxBytes(params: { return DEFAULT_MAX_BYTES[params.capability]; } -export function resolveCapabilityConfig( - cfg: OpenClawConfig, - capability: MediaUnderstandingCapability, -): MediaUnderstandingConfig | undefined { - return cfg.tools?.media?.[capability]; -} - export function resolveScopeDecision(params: { scope?: MediaUnderstandingScopeConfig; ctx: MsgContext; diff --git a/src/media-understanding/types.ts b/src/media-understanding/types.ts index 3d705504f81..18843cfbfc1 100644 --- a/src/media-understanding/types.ts +++ b/src/media-understanding/types.ts @@ -47,8 +47,6 @@ export type MediaUnderstandingModelDecision = { reason?: string; }; -export type MediaUnderstandingAttemptOutcome = MediaUnderstandingModelDecision["outcome"]; - export type MediaUnderstandingAttachmentDecision = { attachmentIndex: number; attempts: MediaUnderstandingModelDecision[]; diff --git a/src/node-host/invoke-system-run.ts b/src/node-host/invoke-system-run.ts index 8ad091776da..b673eda1ef4 100644 --- a/src/node-host/invoke-system-run.ts +++ b/src/node-host/invoke-system-run.ts @@ -248,7 +248,6 @@ async function sendSystemRunCompleted( }); } -export { formatSystemRunAllowlistMissMessage } from "./exec-policy.js"; export { buildSystemRunApprovalPlan } from "./invoke-system-run-plan.js"; async function parseSystemRunPhase( diff --git a/src/pairing/allow-from-store-read.ts b/src/pairing/allow-from-store-read.ts index cf00de8be12..3eb0ccd581c 100644 --- a/src/pairing/allow-from-store-read.ts +++ b/src/pairing/allow-from-store-read.ts @@ -3,7 +3,6 @@ import { clearAllowFromFileReadCacheForNamespace, dedupePreserveOrder, readAllowFromFileSyncWithExists, - readAllowFromFileWithExists, resolveAllowFromAccountId, resolveAllowFromFilePath, shouldIncludeLegacyAllowFromEntries, @@ -20,16 +19,6 @@ function normalizeRawAllowFromList(store: AllowFromStore): string[] { ); } -async function readAllowFromEntriesForPathWithExists( - filePath: string, -): Promise<{ entries: string[]; exists: boolean }> { - return await readAllowFromFileWithExists({ - cacheNamespace: ALLOW_FROM_STORE_READ_CACHE_NAMESPACE, - filePath, - normalizeStore: normalizeRawAllowFromList, - }); -} - function readAllowFromEntriesForPathSyncWithExists(filePath: string): { entries: string[]; exists: boolean; @@ -49,45 +38,6 @@ export function resolveChannelAllowFromPath( return resolveAllowFromFilePath(channel, env, accountId); } -export async function readLegacyChannelAllowFromStoreEntries( - channel: PairingChannel, - env: NodeJS.ProcessEnv = process.env, -): Promise { - const filePath = resolveAllowFromFilePath(channel, env); - return (await readAllowFromEntriesForPathWithExists(filePath)).entries; -} - -export async function readChannelAllowFromStoreEntries( - channel: PairingChannel, - env: NodeJS.ProcessEnv = process.env, - accountId?: string, -): Promise { - const resolvedAccountId = resolveAllowFromAccountId(accountId); - if (!shouldIncludeLegacyAllowFromEntries(resolvedAccountId)) { - return ( - await readAllowFromEntriesForPathWithExists( - resolveAllowFromFilePath(channel, env, resolvedAccountId), - ) - ).entries; - } - const scopedEntries = ( - await readAllowFromEntriesForPathWithExists( - resolveAllowFromFilePath(channel, env, resolvedAccountId), - ) - ).entries; - const legacyEntries = ( - await readAllowFromEntriesForPathWithExists(resolveAllowFromFilePath(channel, env)) - ).entries; - return dedupePreserveOrder([...scopedEntries, ...legacyEntries]); -} - -export function readLegacyChannelAllowFromStoreEntriesSync( - channel: PairingChannel, - env: NodeJS.ProcessEnv = process.env, -): string[] { - return readAllowFromEntriesForPathSyncWithExists(resolveAllowFromFilePath(channel, env)).entries; -} - export function readChannelAllowFromStoreEntriesSync( channel: PairingChannel, env: NodeJS.ProcessEnv = process.env, diff --git a/src/plugin-sdk/image-generation-core.ts b/src/plugin-sdk/image-generation-core.ts index a231cdcf69d..150fecbc34f 100644 --- a/src/plugin-sdk/image-generation-core.ts +++ b/src/plugin-sdk/image-generation-core.ts @@ -33,7 +33,7 @@ export { parseImageGenerationModelRef } from "../image-generation/model-ref.js"; export { createSubsystemLogger } from "../logging/subsystem.js"; export { normalizeGooglePreviewModelId as normalizeGoogleModelId } from "./provider-model-shared.js"; export { getProviderEnvVars } from "../secrets/provider-env-vars.js"; -export { OPENAI_DEFAULT_IMAGE_MODEL } from "../plugins/provider-model-defaults.js"; +export const OPENAI_DEFAULT_IMAGE_MODEL = "gpt-image-2"; type ImageGenerationCoreAuthRuntimeModule = typeof import("./image-generation-core.auth.runtime.js"); diff --git a/src/plugin-sdk/provider-model-shared.ts b/src/plugin-sdk/provider-model-shared.ts index b1d3437ee88..6e2a3c334ec 100644 --- a/src/plugin-sdk/provider-model-shared.ts +++ b/src/plugin-sdk/provider-model-shared.ts @@ -39,7 +39,6 @@ export type { ProviderEndpointResolution, } from "../agents/provider-attribution.js"; export type { ProviderPlugin } from "../plugins/types.js"; -export type { KilocodeModelCatalogEntry } from "../plugins/provider-model-kilocode.js"; export { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js"; export { diff --git a/src/plugins/bundled-runtime-deps-activity.ts b/src/plugins/bundled-runtime-deps-activity.ts index a0474d409db..1a19d12755d 100644 --- a/src/plugins/bundled-runtime-deps-activity.ts +++ b/src/plugins/bundled-runtime-deps-activity.ts @@ -1,4 +1,4 @@ -export type BundledRuntimeDepsInstallActivity = { +type BundledRuntimeDepsInstallActivity = { id: number; installRoot: string; missingSpecs: string[]; @@ -54,10 +54,6 @@ export function getActiveBundledRuntimeDepsInstallCount(): number { return activeInstalls.size; } -export function listActiveBundledRuntimeDepsInstalls(): BundledRuntimeDepsInstallActivity[] { - return [...activeInstalls.values()].toSorted((left, right) => left.id - right.id); -} - export async function waitForBundledRuntimeDepsInstallIdle( timeoutMs?: number, ): Promise<{ drained: boolean; active: number }> { diff --git a/src/plugins/config-activation-shared.ts b/src/plugins/config-activation-shared.ts index e0cf4401d50..dd4e6b543d1 100644 --- a/src/plugins/config-activation-shared.ts +++ b/src/plugins/config-activation-shared.ts @@ -3,13 +3,6 @@ type EnableStateLike = { reason?: string; }; -type EnableStateParamsLike = { - id: string; - origin: string; - config: unknown; - enabledByDefault?: boolean; -}; - type PluginKindLike = string | readonly string[] | undefined; export type PluginActivationSource = "disabled" | "explicit" | "auto" | "default"; @@ -315,13 +308,6 @@ export function resolveEnableStateResult( return toEnableStateResult(resolveState(params)); } -export function resolveEnableStateShared( - params: TParams, - resolveState: (params: TParams) => EnableStateLike, -): { enabled: boolean; reason?: string } { - return resolveEnableStateResult(params, resolveState); -} - export function createPluginEnableStateResolver( resolveState: (params: { id: string; diff --git a/src/plugins/config-policy.ts b/src/plugins/config-policy.ts index 5d706517047..c608a1204fb 100644 --- a/src/plugins/config-policy.ts +++ b/src/plugins/config-policy.ts @@ -1,7 +1,5 @@ import type { OpenClawConfig } from "../config/types.openclaw.js"; import { - createEffectiveEnableStateResolver, - createPluginEnableStateResolver, resolveMemorySlotDecisionShared, resolvePluginActivationDecisionShared, toPluginActivationState, @@ -54,11 +52,6 @@ export function resolvePluginActivationState(params: { } export const hasExplicitPluginConfig = hasExplicitPluginConfigShared; -export const resolveEnableState = createPluginEnableStateResolver< - NormalizedPluginsConfig, - PluginOrigin ->(resolvePluginActivationState); - export const isBundledChannelEnabledByChannelConfig = isBundledChannelEnabledByChannelConfigShared; type PolicyEffectiveActivationParams = { @@ -72,11 +65,6 @@ type PolicyEffectiveActivationParams = { autoEnabledReason?: string; }; -export const resolveEffectiveEnableState = - createEffectiveEnableStateResolver( - resolveEffectivePluginActivationState, - ); - export function resolveEffectivePluginActivationState( params: PolicyEffectiveActivationParams, ): PluginActivationState { diff --git a/src/plugins/document-extractor-public-artifacts.ts b/src/plugins/document-extractor-public-artifacts.ts index 69081c4e65d..e451f0f8070 100644 --- a/src/plugins/document-extractor-public-artifacts.ts +++ b/src/plugins/document-extractor-public-artifacts.ts @@ -2,10 +2,7 @@ import type { DocumentExtractorPlugin, PluginDocumentExtractorEntry, } from "./document-extractor-types.js"; -import { - loadBundledPluginPublicArtifactModuleSync, - resolveBundledPluginPublicArtifactPath, -} from "./public-surface-loader.js"; +import { loadBundledPluginPublicArtifactModuleSync } from "./public-surface-loader.js"; const DOCUMENT_EXTRACTOR_ARTIFACT_CANDIDATES = [ "document-extractor.js", @@ -100,9 +97,3 @@ export function loadBundledDocumentExtractorEntriesFromDir(params: { } return extractors.map((extractor) => Object.assign({}, extractor, { pluginId: params.pluginId })); } - -export function hasBundledDocumentExtractorPublicArtifact(pluginId: string): boolean { - return DOCUMENT_EXTRACTOR_ARTIFACT_CANDIDATES.some((artifactBasename) => - Boolean(resolveBundledPluginPublicArtifactPath({ dirName: pluginId, artifactBasename })), - ); -} diff --git a/src/plugins/installed-plugin-index-store.ts b/src/plugins/installed-plugin-index-store.ts index c6d85effc38..6bc1d979e3a 100644 --- a/src/plugins/installed-plugin-index-store.ts +++ b/src/plugins/installed-plugin-index-store.ts @@ -23,7 +23,6 @@ import { type RefreshInstalledPluginIndexParams, } from "./installed-plugin-index.js"; export { - INSTALLED_PLUGIN_INDEX_STORE_PATH, resolveInstalledPluginIndexStorePath, type InstalledPluginIndexStoreOptions, } from "./installed-plugin-index-store-path.js"; diff --git a/src/plugins/provider-model-defaults.ts b/src/plugins/provider-model-defaults.ts deleted file mode 100644 index 65d6c0330df..00000000000 --- a/src/plugins/provider-model-defaults.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type { OpenClawConfig } from "../config/types.openclaw.js"; -export { - applyOpencodeZenModelDefault, - OPENCODE_ZEN_DEFAULT_MODEL, -} from "../plugin-sdk/opencode.js"; -import { ensureModelAllowlistEntry } from "./provider-model-allowlist.js"; -import { applyAgentDefaultPrimaryModel } from "./provider-model-primary.js"; - -export const OPENAI_DEFAULT_MODEL = "openai/gpt-5.5"; -export const OPENAI_CODEX_DEFAULT_MODEL = "openai-codex/gpt-5.5"; -export const OPENAI_DEFAULT_IMAGE_MODEL = "gpt-image-2"; -export const OPENAI_DEFAULT_TTS_MODEL = "gpt-4o-mini-tts"; -export const OPENAI_DEFAULT_TTS_VOICE = "alloy"; -export const OPENAI_DEFAULT_AUDIO_TRANSCRIPTION_MODEL = "gpt-4o-transcribe"; -export const OPENAI_DEFAULT_EMBEDDING_MODEL = "text-embedding-3-small"; -export const GOOGLE_GEMINI_DEFAULT_MODEL = "google/gemini-3.1-pro-preview"; -export const OLLAMA_DEFAULT_BASE_URL = "http://127.0.0.1:11434"; -export const OPENCODE_GO_DEFAULT_MODEL_REF = "opencode-go/kimi-k2.6"; - -export function applyGoogleGeminiModelDefault(cfg: OpenClawConfig): { - next: OpenClawConfig; - changed: boolean; -} { - return applyAgentDefaultPrimaryModel({ cfg, model: GOOGLE_GEMINI_DEFAULT_MODEL }); -} - -export function applyOpenAIProviderConfig(cfg: OpenClawConfig): OpenClawConfig { - const next = ensureModelAllowlistEntry({ - cfg, - modelRef: OPENAI_DEFAULT_MODEL, - }); - const models = { ...next.agents?.defaults?.models }; - models[OPENAI_DEFAULT_MODEL] = { - ...models[OPENAI_DEFAULT_MODEL], - alias: models[OPENAI_DEFAULT_MODEL]?.alias ?? "GPT", - }; - - return { - ...next, - agents: { - ...next.agents, - defaults: { - ...next.agents?.defaults, - models, - }, - }, - }; -} - -export function applyOpenAIConfig(cfg: OpenClawConfig): OpenClawConfig { - const next = applyOpenAIProviderConfig(cfg); - return { - ...next, - agents: { - ...next.agents, - defaults: { - ...next.agents?.defaults, - model: - next.agents?.defaults?.model && typeof next.agents.defaults.model === "object" - ? { - ...next.agents.defaults.model, - primary: OPENAI_DEFAULT_MODEL, - } - : { primary: OPENAI_DEFAULT_MODEL }, - }, - }, - }; -} - -export function applyOpencodeGoModelDefault(cfg: OpenClawConfig): { - next: OpenClawConfig; - changed: boolean; -} { - return applyAgentDefaultPrimaryModel({ cfg, model: OPENCODE_GO_DEFAULT_MODEL_REF }); -} diff --git a/src/plugins/provider-model-kilocode.ts b/src/plugins/provider-model-kilocode.ts deleted file mode 100644 index f87e0921e7d..00000000000 --- a/src/plugins/provider-model-kilocode.ts +++ /dev/null @@ -1,37 +0,0 @@ -export const KILOCODE_BASE_URL = "https://api.kilo.ai/api/gateway/"; -export const KILOCODE_DEFAULT_MODEL_ID = "kilo/auto"; -export const KILOCODE_DEFAULT_MODEL_REF = `kilocode/${KILOCODE_DEFAULT_MODEL_ID}`; -export const KILOCODE_DEFAULT_MODEL_NAME = "Kilo Auto"; - -export type KilocodeModelCatalogEntry = { - id: string; - name: string; - reasoning: boolean; - input: Array<"text" | "image">; - contextWindow?: number; - maxTokens?: number; -}; - -/** - * Static fallback catalog used by synchronous config surfaces and as the - * discovery fallback when the gateway model endpoint is unavailable. - */ -export const KILOCODE_MODEL_CATALOG: KilocodeModelCatalogEntry[] = [ - { - id: KILOCODE_DEFAULT_MODEL_ID, - name: KILOCODE_DEFAULT_MODEL_NAME, - reasoning: true, - input: ["text", "image"], - contextWindow: 1000000, - maxTokens: 128000, - }, -]; - -export const KILOCODE_DEFAULT_CONTEXT_WINDOW = 1000000; -export const KILOCODE_DEFAULT_MAX_TOKENS = 128000; -export const KILOCODE_DEFAULT_COST = { - input: 0, - output: 0, - cacheRead: 0, - cacheWrite: 0, -} as const; diff --git a/src/plugins/runtime/runtime-plugin-boundary.ts b/src/plugins/runtime/runtime-plugin-boundary.ts index cd9d485f4ac..13fdb81cefe 100644 --- a/src/plugins/runtime/runtime-plugin-boundary.ts +++ b/src/plugins/runtime/runtime-plugin-boundary.ts @@ -11,13 +11,6 @@ type PluginRuntimeRecord = { source: string; }; -type CachedPluginBoundaryLoaderParams = { - pluginId: string; - entryBaseName: string; - required?: boolean; - missingLabel?: string; -}; - export function readPluginBoundaryConfigSafely() { try { return getRuntimeConfig(); @@ -130,48 +123,3 @@ export function loadPluginBoundaryModuleWithJiti( ): TModule { return getPluginBoundaryJiti(modulePath, loaders)(modulePath) as TModule; } - -// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Dynamic plugin boundary loaders use caller-supplied module types. -export function createCachedPluginBoundaryModuleLoader( - params: CachedPluginBoundaryLoaderParams, -): () => TModule | null { - let cachedModulePath: string | null = null; - let cachedModule: TModule | null = null; - const loaders: PluginJitiLoaderCache = new Map(); - - return () => { - const missingLabel = params.missingLabel ?? `${params.pluginId} plugin runtime`; - const record = resolvePluginRuntimeRecord( - params.pluginId, - params.required - ? () => { - throw new Error(`${missingLabel} is unavailable: missing plugin '${params.pluginId}'`); - } - : undefined, - ); - if (!record) { - return null; - } - const modulePath = resolvePluginRuntimeModulePath( - record, - params.entryBaseName, - params.required - ? () => { - throw new Error( - `${missingLabel} is unavailable: missing ${params.entryBaseName} for plugin '${params.pluginId}'`, - ); - } - : undefined, - ); - if (!modulePath) { - return null; - } - if (cachedModule && cachedModulePath === modulePath) { - return cachedModule; - } - const loaded = loadPluginBoundaryModuleWithJiti(modulePath, loaders); - cachedModulePath = modulePath; - cachedModule = loaded; - return loaded; - }; -} diff --git a/src/plugins/setup-browser.ts b/src/plugins/setup-browser.ts index 1bf9dd37bde..c036d887324 100644 --- a/src/plugins/setup-browser.ts +++ b/src/plugins/setup-browser.ts @@ -1,6 +1,2 @@ -export { - openUrl, - resolveBrowserOpenCommand, - type BrowserOpenCommand, -} from "../infra/browser-open.js"; +export { openUrl } from "../infra/browser-open.js"; export { isRemoteEnvironment } from "../infra/remote-env.js"; diff --git a/src/plugins/slots.ts b/src/plugins/slots.ts index cbbea0775c2..bda44bc8ded 100644 --- a/src/plugins/slots.ts +++ b/src/plugins/slots.ts @@ -35,17 +35,6 @@ export function hasKind(kind: PluginKind | PluginKind[] | undefined, target: Plu return Array.isArray(kind) ? kind.includes(target) : kind === target; } -/** - * Returns the slot key for a single-kind plugin. - * For multi-kind plugins use `slotKeysForPluginKind` instead. - */ -export function slotKeyForPluginKind(kind?: PluginKind): PluginSlotKey | null { - if (!kind) { - return null; - } - return SLOT_BY_KIND[kind] ?? null; -} - /** Order-insensitive equality check for two kind values (string or array). */ export function kindsEqual( a: PluginKind | PluginKind[] | undefined, diff --git a/src/plugins/web-content-extractor-public-artifacts.ts b/src/plugins/web-content-extractor-public-artifacts.ts index fcfb420f81e..ce7a9268520 100644 --- a/src/plugins/web-content-extractor-public-artifacts.ts +++ b/src/plugins/web-content-extractor-public-artifacts.ts @@ -1,7 +1,4 @@ -import { - loadBundledPluginPublicArtifactModuleSync, - resolveBundledPluginPublicArtifactPath, -} from "./public-surface-loader.js"; +import { loadBundledPluginPublicArtifactModuleSync } from "./public-surface-loader.js"; import type { PluginWebContentExtractorEntry, WebContentExtractorPlugin, @@ -83,9 +80,3 @@ export function loadBundledWebContentExtractorEntriesFromDir(params: { } return extractors.map((extractor) => Object.assign({}, extractor, { pluginId: params.pluginId })); } - -export function hasBundledWebContentExtractorPublicArtifact(pluginId: string): boolean { - return WEB_CONTENT_EXTRACTOR_ARTIFACT_CANDIDATES.some((artifactBasename) => - Boolean(resolveBundledPluginPublicArtifactPath({ dirName: pluginId, artifactBasename })), - ); -} diff --git a/src/process/spawn-utils.ts b/src/process/spawn-utils.ts index 58d49598a4c..a068970ac3b 100644 --- a/src/process/spawn-utils.ts +++ b/src/process/spawn-utils.ts @@ -31,28 +31,6 @@ export function resolveCommandStdio(params: { return [stdin, "pipe", "pipe"]; } -export function formatSpawnError(err: unknown): string { - if (!(err instanceof Error)) { - return String(err); - } - const details = err as NodeJS.ErrnoException; - const parts: string[] = []; - const message = err.message?.trim(); - if (message) { - parts.push(message); - } - if (details.code && !message?.includes(details.code)) { - parts.push(details.code); - } - if (details.syscall) { - parts.push(`syscall=${details.syscall}`); - } - if (typeof details.errno === "number") { - parts.push(`errno=${details.errno}`); - } - return parts.join(" "); -} - function shouldRetry(err: unknown, codes: string[]): boolean { const code = err && typeof err === "object" && "code" in err ? String((err as { code?: unknown }).code) : ""; diff --git a/src/routing/resolve-route.ts b/src/routing/resolve-route.ts index d75ad6c127c..14131fcdf75 100644 --- a/src/routing/resolve-route.ts +++ b/src/routing/resolve-route.ts @@ -66,7 +66,7 @@ export type ResolvedAgentRoute = { | "default"; }; -export { DEFAULT_ACCOUNT_ID, DEFAULT_AGENT_ID } from "./session-key.js"; +export { DEFAULT_ACCOUNT_ID } from "./session-key.js"; export function deriveLastRoutePolicy(params: { sessionKey: string; diff --git a/src/secrets/auth-store-paths.ts b/src/secrets/auth-store-paths.ts index 22d756c61ac..b2d68468e66 100644 --- a/src/secrets/auth-store-paths.ts +++ b/src/secrets/auth-store-paths.ts @@ -34,7 +34,3 @@ export function listAuthProfileStorePaths(config: OpenClawConfig, stateDir: stri return [...paths]; } - -export function collectAuthStorePaths(config: OpenClawConfig, stateDir: string): string[] { - return listAuthProfileStorePaths(config, stateDir); -} diff --git a/src/secrets/json-pointer.ts b/src/secrets/json-pointer.ts index 6e70b1add6c..e6ce94d2a95 100644 --- a/src/secrets/json-pointer.ts +++ b/src/secrets/json-pointer.ts @@ -65,34 +65,3 @@ export function readJsonPointer( } return current; } - -export function setJsonPointer( - root: Record, - pointer: string, - value: unknown, -): void { - if (!pointer.startsWith("/")) { - throw new Error(`Invalid JSON pointer "${pointer}".`); - } - - const tokens = pointer - .slice(1) - .split("/") - .map((token) => decodeJsonPointerToken(token)); - - let current: Record = root; - for (let index = 0; index < tokens.length; index += 1) { - const token = tokens[index]; - const isLast = index === tokens.length - 1; - if (isLast) { - current[token] = value; - return; - } - const child = current[token]; - const next: Record = isJsonObject(child) ? child : {}; - if (next !== child) { - current[token] = next; - } - current = next; - } -} diff --git a/src/secrets/target-registry-query.ts b/src/secrets/target-registry-query.ts index cc42ada89e9..f543992bc19 100644 --- a/src/secrets/target-registry-query.ts +++ b/src/secrets/target-registry-query.ts @@ -251,12 +251,6 @@ export function listSecretTargetRegistryEntries(): SecretTargetRegistryEntry[] { ); } -export function isKnownSecretTargetType(value: unknown): value is string { - return ( - typeof value === "string" && getCompiledSecretTargetRegistryState().targetsByType.has(value) - ); -} - export function isKnownSecretTargetId(value: unknown): value is string { return ( typeof value === "string" && getCompiledSecretTargetRegistryState().knownTargetIds.has(value) @@ -396,11 +390,7 @@ export function discoverConfigSecretTargetsByIds( return discoverSecretTargetsFromEntries(config, discoveryEntries); } -export function discoverAuthProfileSecretTargets(store: unknown): DiscoveredConfigSecretTarget[] { - return discoverAuthProfileSecretTargetsByIds(store); -} - -export function discoverAuthProfileSecretTargetsByIds( +export function discoverAuthProfileSecretTargets( store: unknown, targetIds?: Iterable, ): DiscoveredConfigSecretTarget[] { diff --git a/src/shared/silent-reply-policy.ts b/src/shared/silent-reply-policy.ts index 1a7c526d275..9c17edd285d 100644 --- a/src/shared/silent-reply-policy.ts +++ b/src/shared/silent-reply-policy.ts @@ -1,7 +1,6 @@ import { normalizeLowercaseStringOrEmpty } from "./string-coerce.js"; export type SilentReplyPolicy = "allow" | "disallow"; -export type SilentReplyMode = "allow" | "rewrite"; export type SilentReplyConversationType = "direct" | "group" | "internal"; export type SilentReplyPolicyShape = Partial< Record diff --git a/src/shared/text/plain-text-tool-call-blocks.ts b/src/shared/text/plain-text-tool-call-blocks.ts index 47ad96b332a..3ecf9dd82b0 100644 --- a/src/shared/text/plain-text-tool-call-blocks.ts +++ b/src/shared/text/plain-text-tool-call-blocks.ts @@ -1,6 +1 @@ -export { - parseStandalonePlainTextToolCallBlocks, - stripPlainTextToolCallBlocks, - type PlainTextToolCallBlock, - type PlainTextToolCallParseOptions, -} from "../../plugin-sdk/tool-payload.js"; +export { stripPlainTextToolCallBlocks } from "../../plugin-sdk/tool-payload.js"; diff --git a/src/tasks/detached-task-runtime-state.ts b/src/tasks/detached-task-runtime-state.ts index bab33b916ae..5b47005d7bb 100644 --- a/src/tasks/detached-task-runtime-state.ts +++ b/src/tasks/detached-task-runtime-state.ts @@ -49,6 +49,3 @@ export function restoreDetachedTaskLifecycleRuntimeRegistration( export function clearDetachedTaskLifecycleRuntimeRegistration(): void { detachedTaskLifecycleRuntimeRegistration = undefined; } - -export const _resetDetachedTaskLifecycleRuntimeRegistration = - clearDetachedTaskLifecycleRuntimeRegistration; diff --git a/src/tasks/runtime-internal.ts b/src/tasks/runtime-internal.ts index 78354bff3b2..0c45fb8ee79 100644 --- a/src/tasks/runtime-internal.ts +++ b/src/tasks/runtime-internal.ts @@ -4,23 +4,16 @@ export { deleteTaskRecordById, ensureTaskRegistryReady, resetTaskRegistryControlRuntimeForTests, - findLatestTaskForOwnerKey, findLatestTaskForFlowId, - findLatestTaskForRelatedSessionKey, - findTaskByRunId, finalizeTaskRunByRunId, getTaskById, - getTaskRegistrySnapshot, - getTaskRegistrySummary, listTaskRecords, listTasksForFlowId, listTasksForOwnerKey, - listTasksForRelatedSessionKey, linkTaskToFlowById, markTaskLostById, markTaskRunningByRunId, markTaskTerminalById, - markTaskTerminalByRunId, maybeDeliverTaskTerminalUpdate, recordTaskProgressByRunId, reloadTaskRegistryFromStore, @@ -31,8 +24,6 @@ export { setTaskRegistryControlRuntimeForTests, setTaskRegistryDeliveryRuntimeForTests, setTaskCleanupAfterById, - setTaskProgressById, setTaskRunDeliveryStatusByRunId, - setTaskTimingById, updateTaskNotifyPolicyById, } from "./task-registry.js"; diff --git a/src/tasks/task-flow-runtime-internal.ts b/src/tasks/task-flow-runtime-internal.ts index 1f479649c56..7290e61546c 100644 --- a/src/tasks/task-flow-runtime-internal.ts +++ b/src/tasks/task-flow-runtime-internal.ts @@ -1,14 +1,11 @@ export { createTaskFlowForTask, - createFlowRecord, createManagedTaskFlow, deleteTaskFlowRecordById, - findLatestTaskFlowForOwnerKey, failFlow, finishFlow, getTaskFlowById, listTaskFlowRecords, - listTaskFlowsForOwnerKey, requestFlowCancel, resolveTaskFlowForLookupToken, resetTaskFlowRegistryForTests, diff --git a/src/tasks/task-registry.reconcile.ts b/src/tasks/task-registry.reconcile.ts index 780cabe8558..276009cbe86 100644 --- a/src/tasks/task-registry.reconcile.ts +++ b/src/tasks/task-registry.reconcile.ts @@ -1,5 +1,4 @@ export { reconcileInspectableTasks, reconcileTaskLookupToken, - reconcileTaskRecordForOperatorInspection, } from "./task-registry.maintenance.js"; diff --git a/src/utils/message-channel-core.ts b/src/utils/message-channel-core.ts index fc8122436d1..2d5f8e641f8 100644 --- a/src/utils/message-channel-core.ts +++ b/src/utils/message-channel-core.ts @@ -24,10 +24,3 @@ export function isDeliverableMessageChannel(value: string): boolean { normalized !== undefined && normalized !== INTERNAL_MESSAGE_CHANNEL && normalized === value ); } - -export function resolveMessageChannel( - primary?: string | null, - fallback?: string | null, -): string | undefined { - return normalizeMessageChannel(primary) ?? normalizeMessageChannel(fallback); -} diff --git a/src/utils/message-channel-normalize.ts b/src/utils/message-channel-normalize.ts index 4c98646c5b0..6dcd844a4c7 100644 --- a/src/utils/message-channel-normalize.ts +++ b/src/utils/message-channel-normalize.ts @@ -1,8 +1,5 @@ -import { CHANNEL_IDS, listChatChannelAliases } from "../channels/ids.js"; -import { - listRegisteredChannelPluginAliases, - listRegisteredChannelPluginIds, -} from "../channels/registry.js"; +import { CHANNEL_IDS } from "../channels/ids.js"; +import { listRegisteredChannelPluginIds } from "../channels/registry.js"; import { INTERNAL_MESSAGE_CHANNEL, type InternalMessageChannel, @@ -15,8 +12,6 @@ export type DeliverableMessageChannel = ChannelId; export type GatewayMessageChannel = DeliverableMessageChannel; -export type GatewayAgentChannelHint = GatewayMessageChannel; - export function normalizeMessageChannel(raw?: string | null): string | undefined { return normalizeMessageChannelCore(raw); } @@ -25,26 +20,14 @@ const listPluginChannelIds = (): string[] => { return listRegisteredChannelPluginIds(); }; -const listPluginChannelAliases = (): string[] => { - return listRegisteredChannelPluginAliases(); -}; - export const listDeliverableMessageChannels = (): ChannelId[] => Array.from(new Set([...CHANNEL_IDS, ...listPluginChannelIds()])); -export const listGatewayMessageChannels = (): GatewayMessageChannel[] => [ +const listGatewayMessageChannels = (): GatewayMessageChannel[] => [ ...listDeliverableMessageChannels(), INTERNAL_MESSAGE_CHANNEL, ]; -export const listGatewayAgentChannelAliases = (): string[] => - Array.from(new Set([...listChatChannelAliases(), ...listPluginChannelAliases()])); - -export const listGatewayAgentChannelValues = (): string[] => - Array.from( - new Set([...listGatewayMessageChannels(), "last", ...listGatewayAgentChannelAliases()]), - ); - export function isGatewayMessageChannel(value: string): value is GatewayMessageChannel { return listGatewayMessageChannels().includes(value as GatewayMessageChannel); } diff --git a/src/utils/message-channel.ts b/src/utils/message-channel.ts index 99516d878b9..55f6a7d6d7e 100644 --- a/src/utils/message-channel.ts +++ b/src/utils/message-channel.ts @@ -12,14 +12,10 @@ export { isDeliverableMessageChannel, isGatewayMessageChannel, listDeliverableMessageChannels, - listGatewayAgentChannelAliases, - listGatewayAgentChannelValues, - listGatewayMessageChannels, normalizeMessageChannel, resolveGatewayMessageChannel, resolveMessageChannel, type DeliverableMessageChannel, - type GatewayAgentChannelHint, type GatewayMessageChannel, } from "./message-channel-normalize.js"; export { @@ -27,7 +23,6 @@ export { INTERNAL_NON_DELIVERY_CHANNELS, isInternalNonDeliveryChannel, type InternalMessageChannel, - type InternalNonDeliveryChannel, } from "./message-channel-constants.js"; import { INTERNAL_MESSAGE_CHANNEL,