From 95bc4179442e817b2c812ccb005a11e07bb2a5b9 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 11 Apr 2026 00:47:42 +0100 Subject: [PATCH] fix(cycles): split residual shared type seams --- src/agents/agent-scope.ts | 2 +- src/agents/model-catalog.ts | 13 +- src/agents/model-catalog.types.ts | 11 + src/agents/skills/agent-filter.ts | 2 +- src/channels/plugins/channel-id.types.ts | 3 + src/channels/plugins/config-writes.ts | 6 +- src/channels/plugins/setup-wizard-types.ts | 264 +----------------- src/channels/plugins/types.adapters.ts | 4 +- src/channels/plugins/types.core.ts | 3 +- .../shared/legacy-config-core-migrate.ts | 2 +- src/context-engine/registry.ts | 2 +- src/infra/approval-handler-runtime.ts | 2 + .../outbound/current-conversation-bindings.ts | 2 +- src/infra/outbound/deliver.ts | 3 +- src/infra/outbound/session-binding-service.ts | 67 ++--- src/infra/outbound/session-binding.types.ts | 47 ++++ src/media-generation/runtime-shared.test.ts | 2 +- src/media-generation/runtime-shared.ts | 2 +- .../apply.echo-transcript.test.ts | 2 +- src/media-understanding/apply.test.ts | 2 +- src/media-understanding/apply.ts | 2 +- src/media-understanding/audio-preflight.ts | 2 +- .../audio-transcription-runner.ts | 2 +- src/media-understanding/defaults.ts | 2 +- .../echo-transcript.test.ts | 2 +- src/media-understanding/echo-transcript.ts | 2 +- .../provider-registry.allowlist.test.ts | 2 +- src/media-understanding/provider-registry.ts | 2 +- src/media-understanding/resolve.test.ts | 2 +- src/media-understanding/resolve.ts | 2 +- .../runner.auto-audio.test.ts | 2 +- .../runner.cli-audio.test.ts | 2 +- .../runner.deepgram.test.ts | 2 +- src/media-understanding/runner.entries.ts | 2 +- src/media-understanding/runner.proxy.test.ts | 2 +- .../runner.skip-tiny-audio.test.ts | 2 +- src/media-understanding/runner.ts | 2 +- src/media-understanding/runner.video.test.ts | 2 +- .../runner.vision-skip.test.ts | 2 +- src/media-understanding/runtime.test.ts | 2 +- src/media-understanding/runtime.ts | 2 +- .../transcribe-audio.test.ts | 2 +- .../channel-inbound-roots.contract.test.ts | 2 +- src/media/channel-inbound-roots.ts | 2 +- src/media/local-roots.ts | 2 +- src/media/read-capability.test.ts | 2 +- src/media/read-capability.ts | 2 +- src/music-generation/live-test-helpers.ts | 2 +- src/music-generation/provider-registry.ts | 2 +- src/music-generation/runtime.test.ts | 2 +- src/music-generation/runtime.ts | 2 +- src/music-generation/types.ts | 2 +- src/plugins/config-state.ts | 2 +- src/plugins/install-security-scan.runtime.ts | 2 +- src/plugins/install-security-scan.ts | 5 +- src/plugins/install-security-scan.types.ts | 3 + src/plugins/manifest-registry.ts | 2 +- src/plugins/memory-embedding-providers.ts | 2 +- src/plugins/plugin-kind.types.ts | 1 + src/plugins/provider-thinking.ts | 19 +- src/plugins/provider-thinking.types.ts | 22 ++ src/plugins/registry-types.ts | 2 +- src/plugins/registry.ts | 2 +- src/plugins/slots.ts | 4 +- src/plugins/types.ts | 38 +-- src/tts/directives.ts | 2 +- src/tts/provider-registry.test.ts | 2 +- src/tts/provider-registry.ts | 2 +- src/tts/provider-types.ts | 2 +- src/tts/status-config.test.ts | 2 +- src/tts/status-config.ts | 2 +- src/tts/tts-config.ts | 3 +- src/tts/tts-core.ts | 2 +- .../live-test-helpers.test.ts | 2 +- src/video-generation/live-test-helpers.ts | 2 +- src/video-generation/provider-registry.ts | 2 +- src/video-generation/runtime.test.ts | 2 +- src/video-generation/runtime.ts | 2 +- src/video-generation/types.ts | 2 +- src/web-fetch/runtime.test.ts | 2 +- src/web-fetch/runtime.ts | 2 +- 81 files changed, 214 insertions(+), 428 deletions(-) create mode 100644 src/agents/model-catalog.types.ts create mode 100644 src/channels/plugins/channel-id.types.ts create mode 100644 src/infra/outbound/session-binding.types.ts create mode 100644 src/plugins/install-security-scan.types.ts create mode 100644 src/plugins/plugin-kind.types.ts create mode 100644 src/plugins/provider-thinking.types.ts diff --git a/src/agents/agent-scope.ts b/src/agents/agent-scope.ts index 906fd7a6b92..6092948e5f2 100644 --- a/src/agents/agent-scope.ts +++ b/src/agents/agent-scope.ts @@ -1,9 +1,9 @@ import fs from "node:fs"; import path from "node:path"; -import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentModelFallbackValues } from "../config/model-input.js"; import { resolveStateDir } from "../config/paths.js"; import type { AgentDefaultsConfig } from "../config/types.agent-defaults.js"; +import type { OpenClawConfig } from "../config/types.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { DEFAULT_AGENT_ID, diff --git a/src/agents/model-catalog.ts b/src/agents/model-catalog.ts index 5849da7b853..2e729d3f9cb 100644 --- a/src/agents/model-catalog.ts +++ b/src/agents/model-catalog.ts @@ -6,22 +6,13 @@ import { normalizeOptionalString, } from "../shared/string-coerce.js"; import { resolveOpenClawAgentDir } from "./agent-paths.js"; +import type { ModelCatalogEntry, ModelInputType } from "./model-catalog.types.js"; import { ensureOpenClawModelsJson } from "./models-config.js"; import { normalizeProviderId } from "./provider-id.js"; const log = createSubsystemLogger("model-catalog"); -export type ModelInputType = "text" | "image" | "document"; - -export type ModelCatalogEntry = { - id: string; - name: string; - provider: string; - alias?: string; - contextWindow?: number; - reasoning?: boolean; - input?: ModelInputType[]; -}; +export type { ModelCatalogEntry, ModelInputType } from "./model-catalog.types.js"; type DiscoveredModel = { id: string; diff --git a/src/agents/model-catalog.types.ts b/src/agents/model-catalog.types.ts new file mode 100644 index 00000000000..6be158ea521 --- /dev/null +++ b/src/agents/model-catalog.types.ts @@ -0,0 +1,11 @@ +export type ModelInputType = "text" | "image" | "document"; + +export type ModelCatalogEntry = { + id: string; + name: string; + provider: string; + alias?: string; + contextWindow?: number; + reasoning?: boolean; + input?: ModelInputType[]; +}; diff --git a/src/agents/skills/agent-filter.ts b/src/agents/skills/agent-filter.ts index 76fdf6ad359..e8d98e7fe5f 100644 --- a/src/agents/skills/agent-filter.ts +++ b/src/agents/skills/agent-filter.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../../config/config.js"; +import type { OpenClawConfig } from "../../config/types.js"; import { normalizeAgentId } from "../../routing/session-key.js"; import { normalizeSkillFilter } from "./filter.js"; diff --git a/src/channels/plugins/channel-id.types.ts b/src/channels/plugins/channel-id.types.ts new file mode 100644 index 00000000000..6cb63fac03e --- /dev/null +++ b/src/channels/plugins/channel-id.types.ts @@ -0,0 +1,3 @@ +import type { ChatChannelId } from "../ids.js"; + +export type ChannelId = ChatChannelId | (string & {}); diff --git a/src/channels/plugins/config-writes.ts b/src/channels/plugins/config-writes.ts index 43e0fa9e0b0..286e94c5324 100644 --- a/src/channels/plugins/config-writes.ts +++ b/src/channels/plugins/config-writes.ts @@ -12,9 +12,9 @@ import { type ConfigWriteTargetLike, } from "./config-write-policy-shared.js"; import type { ChannelId } from "./types.core.js"; -export type ConfigWriteScope = ConfigWriteScopeLike; -export type ConfigWriteTarget = ConfigWriteTargetLike; -export type ConfigWriteAuthorizationResult = ConfigWriteAuthorizationResultLike; +export type ConfigWriteScope = ConfigWriteScopeLike; +export type ConfigWriteTarget = ConfigWriteTargetLike; +export type ConfigWriteAuthorizationResult = ConfigWriteAuthorizationResultLike; function isInternalConfigWriteMessageChannel(channel?: string | null): boolean { return normalizeLowercaseStringOrEmpty(channel) === "webchat"; diff --git a/src/channels/plugins/setup-wizard-types.ts b/src/channels/plugins/setup-wizard-types.ts index e1e100ebde4..d39a910bd1a 100644 --- a/src/channels/plugins/setup-wizard-types.ts +++ b/src/channels/plugins/setup-wizard-types.ts @@ -18,269 +18,7 @@ export type ChannelSetupPlugin = { config: ChannelConfigAdapter; setup?: ChannelSetupAdapter; setupWizard?: ChannelSetupWizard | ChannelSetupWizardAdapter; -}; - -export type ChannelSetupWizardStatus = { - configuredLabel: string; - unconfiguredLabel: string; - configuredHint?: string; - unconfiguredHint?: string; - configuredScore?: number; - unconfiguredScore?: number; - resolveConfigured: (params: { - cfg: OpenClawConfig; - accountId?: string; - }) => boolean | Promise; - resolveStatusLines?: (params: { - cfg: OpenClawConfig; - accountId?: string; - configured: boolean; - }) => string[] | Promise; - resolveSelectionHint?: (params: { - cfg: OpenClawConfig; - accountId?: string; - configured: boolean; - }) => string | undefined | Promise; - resolveQuickstartScore?: (params: { - cfg: OpenClawConfig; - accountId?: string; - configured: boolean; - }) => number | undefined | Promise; -}; - -export type ChannelSetupWizardCredentialState = { - accountConfigured: boolean; - hasConfiguredValue: boolean; - resolvedValue?: string; - envValue?: string; -}; - -export type ChannelSetupWizardCredentialValues = Partial>; - -export type ChannelSetupWizardNote = { - title: string; - lines: string[]; - shouldShow?: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - }) => boolean | Promise; -}; - -export type ChannelSetupWizardEnvShortcut = { - prompt: string; - preferredEnvVar?: string; - isAvailable: (params: { cfg: OpenClawConfig; accountId: string }) => boolean; - apply: (params: { - cfg: OpenClawConfig; - accountId: string; - }) => OpenClawConfig | Promise; -}; - -export type ChannelSetupWizardCredential = { - inputKey: keyof ChannelSetupInput; - providerHint: string; - credentialLabel: string; - preferredEnvVar?: string; - helpTitle?: string; - helpLines?: string[]; - envPrompt: string; - keepPrompt: string; - inputPrompt: string; - allowEnv?: (params: { cfg: OpenClawConfig; accountId: string }) => boolean; - inspect: (params: { - cfg: OpenClawConfig; - accountId: string; - }) => ChannelSetupWizardCredentialState; - shouldPrompt?: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - currentValue?: string; - state: ChannelSetupWizardCredentialState; - }) => boolean | Promise; - applyUseEnv?: (params: { - cfg: OpenClawConfig; - accountId: string; - }) => OpenClawConfig | Promise; - applySet?: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - value: unknown; - resolvedValue: string; - }) => OpenClawConfig | Promise; -}; - -export type ChannelSetupWizardTextInput = { - inputKey: keyof ChannelSetupInput; - message: string; - placeholder?: string; - required?: boolean; - applyEmptyValue?: boolean; - helpTitle?: string; - helpLines?: string[]; - confirmCurrentValue?: boolean; - keepPrompt?: string | ((value: string) => string); - currentValue?: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - }) => string | undefined | Promise; - initialValue?: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - }) => string | undefined | Promise; - shouldPrompt?: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - currentValue?: string; - }) => boolean | Promise; - applyCurrentValue?: boolean; - validate?: (params: { - value: string; - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - }) => string | undefined; - normalizeValue?: (params: { - value: string; - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - }) => string; - applySet?: (params: { - cfg: OpenClawConfig; - accountId: string; - value: string; - }) => OpenClawConfig | Promise; -}; - -export type ChannelSetupWizardAllowFromEntry = { - input: string; - resolved: boolean; - id: string | null; -}; - -export type ChannelSetupWizardAllowFrom = { - helpTitle?: string; - helpLines?: string[]; - credentialInputKey?: keyof ChannelSetupInput; - message: string; - placeholder: string; - invalidWithoutCredentialNote: string; - parseInputs?: (raw: string) => string[]; - parseId: (raw: string) => string | null; - resolveEntries: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - entries: string[]; - }) => Promise; - apply: (params: { - cfg: OpenClawConfig; - accountId: string; - allowFrom: string[]; - }) => OpenClawConfig | Promise; -}; - -export type ChannelSetupWizardGroupAccess = { - label: string; - placeholder: string; - helpTitle?: string; - helpLines?: string[]; - skipAllowlistEntries?: boolean; - currentPolicy: (params: { cfg: OpenClawConfig; accountId: string }) => ChannelAccessPolicy; - currentEntries: (params: { cfg: OpenClawConfig; accountId: string }) => string[]; - updatePrompt: (params: { cfg: OpenClawConfig; accountId: string }) => boolean; - setPolicy: (params: { - cfg: OpenClawConfig; - accountId: string; - policy: ChannelAccessPolicy; - }) => OpenClawConfig; - resolveAllowlist?: (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - entries: string[]; - prompter: Pick; - }) => Promise; - applyAllowlist?: (params: { - cfg: OpenClawConfig; - accountId: string; - resolved: unknown; - }) => OpenClawConfig; -}; - -export type ChannelSetupWizardPrepare = (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - runtime: ChannelSetupConfigureContext["runtime"]; - prompter: WizardPrompter; - options?: ChannelSetupConfigureContext["options"]; -}) => - | { - cfg?: OpenClawConfig; - credentialValues?: ChannelSetupWizardCredentialValues; - } - | void - | Promise<{ - cfg?: OpenClawConfig; - credentialValues?: ChannelSetupWizardCredentialValues; - } | void>; - -export type ChannelSetupWizardFinalize = (params: { - cfg: OpenClawConfig; - accountId: string; - credentialValues: ChannelSetupWizardCredentialValues; - runtime: ChannelSetupConfigureContext["runtime"]; - prompter: WizardPrompter; - options?: ChannelSetupConfigureContext["options"]; - forceAllowFrom: boolean; -}) => - | { - cfg?: OpenClawConfig; - credentialValues?: ChannelSetupWizardCredentialValues; - } - | void - | Promise<{ - cfg?: OpenClawConfig; - credentialValues?: ChannelSetupWizardCredentialValues; - } | void>; - -export type ChannelSetupWizard = { - channel: string; - status: ChannelSetupWizardStatus; - introNote?: ChannelSetupWizardNote; - envShortcut?: ChannelSetupWizardEnvShortcut; - resolveAccountIdForConfigure?: (params: { - cfg: OpenClawConfig; - prompter: WizardPrompter; - options?: ChannelSetupConfigureContext["options"]; - accountOverride?: string; - shouldPromptAccountIds: boolean; - listAccountIds: ChannelSetupPlugin["config"]["listAccountIds"]; - defaultAccountId: string; - }) => string | Promise; - resolveShouldPromptAccountIds?: (params: { - cfg: OpenClawConfig; - options?: ChannelSetupConfigureContext["options"]; - shouldPromptAccountIds: boolean; - }) => boolean; - prepare?: ChannelSetupWizardPrepare; - stepOrder?: "credentials-first" | "text-first"; - credentials: ChannelSetupWizardCredential[]; - textInputs?: ChannelSetupWizardTextInput[]; - finalize?: ChannelSetupWizardFinalize; - completionNote?: ChannelSetupWizardNote; - dmPolicy?: ChannelSetupDmPolicy; - allowFrom?: ChannelSetupWizardAllowFrom; - groupAccess?: ChannelSetupWizardGroupAccess; - disable?: (cfg: OpenClawConfig) => OpenClawConfig; - onAccountRecorded?: ChannelSetupWizardAdapter["onAccountRecorded"]; + setupWizard?: ChannelSetupWizard | ChannelSetupWizardAdapter; }; export type SetupChannelsOptions = { diff --git a/src/channels/plugins/types.adapters.ts b/src/channels/plugins/types.adapters.ts index 745b56bf819..55aa45cf7be 100644 --- a/src/channels/plugins/types.adapters.ts +++ b/src/channels/plugins/types.adapters.ts @@ -36,6 +36,7 @@ import type { } from "./types.core.js"; type ConfiguredBindingRule = AgentBinding; +export type { ChannelApprovalKind } from "../../infra/approval-handler-runtime-types.js"; export type ChannelActionAvailabilityState = | { kind: "enabled" } @@ -666,8 +667,7 @@ export type ChannelApprovalDeliveryAdapter = { request: ExecApprovalRequest; }) => boolean; }; - -export type ChannelApprovalKind = "exec" | "plugin"; +export type { ChannelApprovalKind } from "../../infra/approval-handler-runtime-types.js"; export type ChannelApproveCommandBehavior = | { kind: "allow" } diff --git a/src/channels/plugins/types.core.ts b/src/channels/plugins/types.core.ts index 99bff3f36a7..69f839c9c99 100644 --- a/src/channels/plugins/types.core.ts +++ b/src/channels/plugins/types.core.ts @@ -8,10 +8,11 @@ import type { GatewayClientMode, GatewayClientName } from "../../gateway/protoco import type { OutboundMediaAccess } from "../../media/load-options.js"; import type { PollInput } from "../../polls.js"; import type { ChatType } from "../chat-type.js"; +import type { ChannelId } from "./channel-id.types.js"; import type { ChannelMessageActionName as ChannelMessageActionNameFromList } from "./message-action-names.js"; import type { ChannelMessageCapability } from "./message-capabilities.js"; -export type ChannelId = string & { readonly __openclawChannelIdBrand?: never }; +export type { ChannelId } from "./channel-id.types.js"; export type ChannelExposure = { configured?: boolean; diff --git a/src/commands/doctor/shared/legacy-config-core-migrate.ts b/src/commands/doctor/shared/legacy-config-core-migrate.ts index 7afe55410a4..1e3db3c94b8 100644 --- a/src/commands/doctor/shared/legacy-config-core-migrate.ts +++ b/src/commands/doctor/shared/legacy-config-core-migrate.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../../../config/config.js"; +import type { OpenClawConfig } from "../../../config/types.js"; import { runPluginSetupConfigMigrations } from "../../../plugins/setup-registry.js"; import { collectChannelDoctorCompatibilityMutations } from "./channel-doctor.js"; import { diff --git a/src/context-engine/registry.ts b/src/context-engine/registry.ts index 930c078aba0..23e5c783c30 100644 --- a/src/context-engine/registry.ts +++ b/src/context-engine/registry.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { defaultSlotIdForKey } from "../plugins/slots.js"; import { resolveGlobalSingleton } from "../shared/global-singleton.js"; import type { ContextEngine } from "./types.js"; diff --git a/src/infra/approval-handler-runtime.ts b/src/infra/approval-handler-runtime.ts index c56252cf3b5..e4f49aee105 100644 --- a/src/infra/approval-handler-runtime.ts +++ b/src/infra/approval-handler-runtime.ts @@ -60,6 +60,8 @@ export { createLazyChannelApprovalNativeRuntimeAdapter, }; export type { + ApprovalRequest, + ApprovalResolved, ChannelApprovalCapabilityHandlerContext, ChannelApprovalKind, ChannelApprovalNativeAvailabilityAdapter, diff --git a/src/infra/outbound/current-conversation-bindings.ts b/src/infra/outbound/current-conversation-bindings.ts index 40666ef5301..6263ac840d0 100644 --- a/src/infra/outbound/current-conversation-bindings.ts +++ b/src/infra/outbound/current-conversation-bindings.ts @@ -14,7 +14,7 @@ import type { SessionBindingCapabilities, SessionBindingRecord, SessionBindingUnbindInput, -} from "./session-binding-service.js"; +} from "./session-binding.types.js"; type PersistedCurrentConversationBindingsFile = { version: 1; diff --git a/src/infra/outbound/deliver.ts b/src/infra/outbound/deliver.ts index d0323fc8a50..04b8f2fab3c 100644 --- a/src/infra/outbound/deliver.ts +++ b/src/infra/outbound/deliver.ts @@ -13,7 +13,7 @@ import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load import type { ChannelOutboundAdapter, ChannelOutboundContext, -} from "../../channels/plugins/types.js"; +} from "../../channels/plugins/types.adapters.js"; import { resolveMirroredTranscriptText } from "../../config/sessions/transcript-mirror.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import { fireAndForgetHook } from "../../hooks/fire-and-forget.js"; @@ -39,7 +39,6 @@ import type { NormalizedOutboundPayload } from "./payloads.js"; import { normalizeReplyPayloadsForDelivery } from "./payloads.js"; import { resolveOutboundSendDep, type OutboundSendDeps } from "./send-deps.js"; import type { OutboundSessionContext } from "./session-context.js"; -import type { OutboundChannel } from "./targets.js"; export type { OutboundDeliveryResult } from "./deliver-types.js"; export type { NormalizedOutboundPayload } from "./payloads.js"; diff --git a/src/infra/outbound/session-binding-service.ts b/src/infra/outbound/session-binding-service.ts index e4292f9c701..39d088942d0 100644 --- a/src/infra/outbound/session-binding-service.ts +++ b/src/infra/outbound/session-binding-service.ts @@ -12,54 +12,27 @@ import { buildChannelAccountKey, normalizeConversationRef, } from "./session-binding-normalization.js"; +import type { + ConversationRef, + SessionBindingBindInput, + SessionBindingCapabilities, + SessionBindingErrorCode, + SessionBindingPlacement, + SessionBindingRecord, + SessionBindingUnbindInput, +} from "./session-binding.types.js"; -export type BindingTargetKind = "subagent" | "session"; -export type BindingStatus = "active" | "ending" | "ended"; -export type SessionBindingPlacement = "current" | "child"; -export type SessionBindingErrorCode = - | "BINDING_ADAPTER_UNAVAILABLE" - | "BINDING_CAPABILITY_UNSUPPORTED" - | "BINDING_CREATE_FAILED"; - -export type ConversationRef = { - channel: string; - accountId: string; - conversationId: string; - parentConversationId?: string; -}; - -export type SessionBindingRecord = { - bindingId: string; - targetSessionKey: string; - targetKind: BindingTargetKind; - conversation: ConversationRef; - status: BindingStatus; - boundAt: number; - expiresAt?: number; - metadata?: Record; -}; - -export type SessionBindingBindInput = { - targetSessionKey: string; - targetKind: BindingTargetKind; - conversation: ConversationRef; - placement?: SessionBindingPlacement; - metadata?: Record; - ttlMs?: number; -}; - -export type SessionBindingUnbindInput = { - bindingId?: string; - targetSessionKey?: string; - reason: string; -}; - -export type SessionBindingCapabilities = { - adapterAvailable: boolean; - bindSupported: boolean; - unbindSupported: boolean; - placements: SessionBindingPlacement[]; -}; +export type { + BindingStatus, + BindingTargetKind, + ConversationRef, + SessionBindingBindInput, + SessionBindingCapabilities, + SessionBindingErrorCode, + SessionBindingPlacement, + SessionBindingRecord, + SessionBindingUnbindInput, +} from "./session-binding.types.js"; export class SessionBindingError extends Error { constructor( diff --git a/src/infra/outbound/session-binding.types.ts b/src/infra/outbound/session-binding.types.ts new file mode 100644 index 00000000000..11b523ce991 --- /dev/null +++ b/src/infra/outbound/session-binding.types.ts @@ -0,0 +1,47 @@ +export type BindingTargetKind = "subagent" | "session"; +export type BindingStatus = "active" | "ending" | "ended"; +export type SessionBindingPlacement = "current" | "child"; +export type SessionBindingErrorCode = + | "BINDING_ADAPTER_UNAVAILABLE" + | "BINDING_CAPABILITY_UNSUPPORTED" + | "BINDING_CREATE_FAILED"; + +export type ConversationRef = { + channel: string; + accountId: string; + conversationId: string; + parentConversationId?: string; +}; + +export type SessionBindingRecord = { + bindingId: string; + targetSessionKey: string; + targetKind: BindingTargetKind; + conversation: ConversationRef; + status: BindingStatus; + boundAt: number; + expiresAt?: number; + metadata?: Record; +}; + +export type SessionBindingBindInput = { + targetSessionKey: string; + targetKind: BindingTargetKind; + conversation: ConversationRef; + placement?: SessionBindingPlacement; + metadata?: Record; + ttlMs?: number; +}; + +export type SessionBindingUnbindInput = { + bindingId?: string; + targetSessionKey?: string; + reason: string; +}; + +export type SessionBindingCapabilities = { + adapterAvailable: boolean; + bindSupported: boolean; + unbindSupported: boolean; + placements: SessionBindingPlacement[]; +}; diff --git a/src/media-generation/runtime-shared.test.ts b/src/media-generation/runtime-shared.test.ts index 4dd34337134..8d204850894 100644 --- a/src/media-generation/runtime-shared.test.ts +++ b/src/media-generation/runtime-shared.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { deriveAspectRatioFromSize, normalizeDurationToClosestMax, diff --git a/src/media-generation/runtime-shared.ts b/src/media-generation/runtime-shared.ts index 1dde1ddd31d..5ae5d00daba 100644 --- a/src/media-generation/runtime-shared.ts +++ b/src/media-generation/runtime-shared.ts @@ -3,12 +3,12 @@ import { ensureAuthProfileStore } from "../agents/auth-profiles.js"; import { DEFAULT_PROVIDER } from "../agents/defaults.js"; import { resolveEnvApiKey } from "../agents/model-auth-env.js"; import type { FallbackAttempt } from "../agents/model-fallback.types.js"; -import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentModelFallbackValues, resolveAgentModelPrimaryValue, } from "../config/model-input.js"; import type { AgentModelConfig } from "../config/types.agents-shared.js"; +import type { OpenClawConfig } from "../config/types.js"; import { getProviderEnvVars } from "../secrets/provider-env-vars.js"; import { normalizeOptionalString } from "../shared/string-coerce.js"; diff --git a/src/media-understanding/apply.echo-transcript.test.ts b/src/media-understanding/apply.echo-transcript.test.ts index f50bbf25c47..88e2f675889 100644 --- a/src/media-understanding/apply.echo-transcript.test.ts +++ b/src/media-understanding/apply.echo-transcript.test.ts @@ -2,7 +2,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js"; import { createSafeAudioFixtureBuffer } from "./runner.test-utils.js"; import type { MediaUnderstandingProvider } from "./types.js"; diff --git a/src/media-understanding/apply.test.ts b/src/media-understanding/apply.test.ts index f5c6c4b9981..95ec7ccfe31 100644 --- a/src/media-understanding/apply.test.ts +++ b/src/media-understanding/apply.test.ts @@ -3,7 +3,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js"; import { withEnvAsync } from "../test-utils/env.js"; import { createSafeAudioFixtureBuffer } from "./runner.test-utils.js"; diff --git a/src/media-understanding/apply.ts b/src/media-understanding/apply.ts index 3f18c3ec3fe..c29e1152441 100644 --- a/src/media-understanding/apply.ts +++ b/src/media-understanding/apply.ts @@ -1,7 +1,7 @@ import path from "node:path"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; import { renderFileContextBlock } from "../media/file-context.js"; import { diff --git a/src/media-understanding/audio-preflight.ts b/src/media-understanding/audio-preflight.ts index 19e0dd88626..199633a4740 100644 --- a/src/media-understanding/audio-preflight.ts +++ b/src/media-understanding/audio-preflight.ts @@ -1,5 +1,5 @@ import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; import { isAudioAttachment } from "./attachments.js"; import { runAudioTranscription } from "./audio-transcription-runner.js"; diff --git a/src/media-understanding/audio-transcription-runner.ts b/src/media-understanding/audio-transcription-runner.ts index 2cbc5f15563..fb8b8ab7f44 100644 --- a/src/media-understanding/audio-transcription-runner.ts +++ b/src/media-understanding/audio-transcription-runner.ts @@ -1,5 +1,5 @@ import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { type ActiveMediaModel, buildProviderRegistry, diff --git a/src/media-understanding/defaults.ts b/src/media-understanding/defaults.ts index 36b44dfd357..1ed085b9444 100644 --- a/src/media-understanding/defaults.ts +++ b/src/media-understanding/defaults.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { normalizeOptionalString } from "../shared/string-coerce.js"; import { bundledProviderSupportsNativePdfDocument, diff --git a/src/media-understanding/echo-transcript.test.ts b/src/media-understanding/echo-transcript.test.ts index 2728de5a57b..02784c8e577 100644 --- a/src/media-understanding/echo-transcript.test.ts +++ b/src/media-understanding/echo-transcript.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; const mockDeliverOutboundPayloads = vi.hoisted(() => vi.fn()); diff --git a/src/media-understanding/echo-transcript.ts b/src/media-understanding/echo-transcript.ts index f42d9edf049..7af132d7b11 100644 --- a/src/media-understanding/echo-transcript.ts +++ b/src/media-understanding/echo-transcript.ts @@ -1,5 +1,5 @@ import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js"; import { isDeliverableMessageChannel } from "../utils/message-channel.js"; diff --git a/src/media-understanding/provider-registry.allowlist.test.ts b/src/media-understanding/provider-registry.allowlist.test.ts index 92e264cc5dc..5b259198168 100644 --- a/src/media-understanding/provider-registry.allowlist.test.ts +++ b/src/media-understanding/provider-registry.allowlist.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { createEmptyProviderRegistryAllowlistFallbackRegistry, getProviderRegistryAllowlistMocks, diff --git a/src/media-understanding/provider-registry.ts b/src/media-understanding/provider-registry.ts index 9531a3bf020..3f550b063ca 100644 --- a/src/media-understanding/provider-registry.ts +++ b/src/media-understanding/provider-registry.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolvePluginCapabilityProviders } from "../plugins/capability-provider-runtime.js"; import { describeImageWithModel, describeImagesWithModel } from "./image-runtime.js"; import { normalizeMediaProviderId } from "./provider-id.js"; diff --git a/src/media-understanding/resolve.test.ts b/src/media-understanding/resolve.test.ts index 57edfd7bc3f..6740b3eeb35 100644 --- a/src/media-understanding/resolve.test.ts +++ b/src/media-understanding/resolve.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolveEntriesWithActiveFallback, resolveModelEntries } from "./resolve.js"; import type { MediaUnderstandingCapability } from "./types.js"; diff --git a/src/media-understanding/resolve.ts b/src/media-understanding/resolve.ts index 352acddccfd..0b28a776e20 100644 --- a/src/media-understanding/resolve.ts +++ b/src/media-understanding/resolve.ts @@ -1,5 +1,5 @@ import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { MediaUnderstandingConfig, MediaUnderstandingModelConfig, diff --git a/src/media-understanding/runner.auto-audio.test.ts b/src/media-understanding/runner.auto-audio.test.ts index 925329f9904..f20d25422c2 100644 --- a/src/media-understanding/runner.auto-audio.test.ts +++ b/src/media-understanding/runner.auto-audio.test.ts @@ -2,7 +2,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { withEnvAsync } from "../test-utils/env.js"; import { runCapability } from "./runner.js"; import { withAudioFixture } from "./runner.test-utils.js"; diff --git a/src/media-understanding/runner.cli-audio.test.ts b/src/media-understanding/runner.cli-audio.test.ts index 3b96ff8a3d3..6db28691336 100644 --- a/src/media-understanding/runner.cli-audio.test.ts +++ b/src/media-understanding/runner.cli-audio.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { withAudioFixture } from "./runner.test-utils.js"; const runExecMock = vi.hoisted(() => vi.fn()); diff --git a/src/media-understanding/runner.deepgram.test.ts b/src/media-understanding/runner.deepgram.test.ts index 285f75f9cf1..ae56284d9b1 100644 --- a/src/media-understanding/runner.deepgram.test.ts +++ b/src/media-understanding/runner.deepgram.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { buildProviderRegistry, runCapability } from "./runner.js"; import { withAudioFixture } from "./runner.test-utils.js"; diff --git a/src/media-understanding/runner.entries.ts b/src/media-understanding/runner.entries.ts index ff83a8c8e9d..9e3b09d094d 100644 --- a/src/media-understanding/runner.entries.ts +++ b/src/media-understanding/runner.entries.ts @@ -11,7 +11,7 @@ import { } from "../agents/provider-request-config.js"; import type { MsgContext } from "../auto-reply/templating.js"; import { applyTemplate } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { MediaUnderstandingConfig, MediaUnderstandingModelConfig, diff --git a/src/media-understanding/runner.proxy.test.ts b/src/media-understanding/runner.proxy.test.ts index 48104a75aab..c919cc85189 100644 --- a/src/media-understanding/runner.proxy.test.ts +++ b/src/media-understanding/runner.proxy.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { withAudioFixture, withVideoFixture } from "./runner.test-utils.js"; import type { AudioTranscriptionRequest, VideoDescriptionRequest } from "./types.js"; diff --git a/src/media-understanding/runner.skip-tiny-audio.test.ts b/src/media-understanding/runner.skip-tiny-audio.test.ts index 79b9bf8efd6..59a2558355a 100644 --- a/src/media-understanding/runner.skip-tiny-audio.test.ts +++ b/src/media-understanding/runner.skip-tiny-audio.test.ts @@ -3,7 +3,7 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { MIN_AUDIO_FILE_BYTES } from "./defaults.js"; import { createMediaAttachmentCache, normalizeMediaAttachments } from "./runner.attachments.js"; import { buildProviderRegistry, runCapability } from "./runner.js"; diff --git a/src/media-understanding/runner.ts b/src/media-understanding/runner.ts index 7e7edb1fbe0..5e2d9102f78 100644 --- a/src/media-understanding/runner.ts +++ b/src/media-understanding/runner.ts @@ -10,11 +10,11 @@ import { } from "../agents/model-catalog.js"; import { findNormalizedProviderValue } from "../agents/provider-id.js"; import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentModelFallbackValues, resolveAgentModelPrimaryValue, } from "../config/model-input.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { MediaUnderstandingConfig, MediaUnderstandingModelConfig, diff --git a/src/media-understanding/runner.video.test.ts b/src/media-understanding/runner.video.test.ts index 8f284803e54..3bf0a655819 100644 --- a/src/media-understanding/runner.video.test.ts +++ b/src/media-understanding/runner.video.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { withTempDir } from "../test-helpers/temp-dir.js"; import { withEnvAsync } from "../test-utils/env.js"; import { runCapability } from "./runner.js"; diff --git a/src/media-understanding/runner.vision-skip.test.ts b/src/media-understanding/runner.vision-skip.test.ts index b84645b2eaa..86f5b78d223 100644 --- a/src/media-understanding/runner.vision-skip.test.ts +++ b/src/media-understanding/runner.vision-skip.test.ts @@ -1,6 +1,6 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { MsgContext } from "../auto-reply/templating.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { withBundledPluginAllowlistCompat, withBundledPluginEnablementCompat, diff --git a/src/media-understanding/runtime.test.ts b/src/media-understanding/runtime.test.ts index e0efc034b4d..9d5b2998443 100644 --- a/src/media-understanding/runtime.test.ts +++ b/src/media-understanding/runtime.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { MediaAttachment, MediaUnderstandingOutput } from "../media-understanding/types.js"; import { describeImageFile, runMediaUnderstandingFile } from "./runtime.js"; diff --git a/src/media-understanding/runtime.ts b/src/media-understanding/runtime.ts index f3142b2bf08..345f426ea6c 100644 --- a/src/media-understanding/runtime.ts +++ b/src/media-understanding/runtime.ts @@ -1,6 +1,6 @@ import fs from "node:fs/promises"; import path from "node:path"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { buildProviderRegistry, createMediaAttachmentCache, diff --git a/src/media-understanding/transcribe-audio.test.ts b/src/media-understanding/transcribe-audio.test.ts index 3ecddc60ce3..dbfd145fabe 100644 --- a/src/media-understanding/transcribe-audio.test.ts +++ b/src/media-understanding/transcribe-audio.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; const { transcribeAudioFileFromRuntime } = vi.hoisted(() => { const transcribeAudioFileFromRuntime = vi.fn(); diff --git a/src/media/channel-inbound-roots.contract.test.ts b/src/media/channel-inbound-roots.contract.test.ts index 35ffd845a9c..0dac351389d 100644 --- a/src/media/channel-inbound-roots.contract.test.ts +++ b/src/media/channel-inbound-roots.contract.test.ts @@ -4,7 +4,7 @@ import { resolveIMessageAttachmentRoots, resolveIMessageRemoteAttachmentRoots, } from "../../test/helpers/channels/channel-media-roots-contract.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; describe("channel-inbound-roots contract", () => { function expectResolvedRootsCase(resolve: () => string[], expected: readonly string[]) { diff --git a/src/media/channel-inbound-roots.ts b/src/media/channel-inbound-roots.ts index b22f381a965..41259b6bfdf 100644 --- a/src/media/channel-inbound-roots.ts +++ b/src/media/channel-inbound-roots.ts @@ -1,6 +1,6 @@ import type { MsgContext } from "../auto-reply/templating.js"; import { getBootstrapChannelPlugin } from "../channels/plugins/bootstrap-registry.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js"; function findChannelMessagingAdapter(channelId?: string | null) { diff --git a/src/media/local-roots.ts b/src/media/local-roots.ts index 63a83166f68..3244db5c774 100644 --- a/src/media/local-roots.ts +++ b/src/media/local-roots.ts @@ -1,7 +1,7 @@ import path from "node:path"; import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; -import type { OpenClawConfig } from "../config/config.js"; import { resolveStateDir } from "../config/paths.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js"; import { normalizeOptionalString } from "../shared/string-coerce.js"; import { resolveConfigDir } from "../utils.js"; diff --git a/src/media/read-capability.test.ts b/src/media/read-capability.test.ts index 48da69a0ff8..d6beb814d3b 100644 --- a/src/media/read-capability.test.ts +++ b/src/media/read-capability.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolveAgentScopedOutboundMediaAccess } from "./read-capability.js"; describe("resolveAgentScopedOutboundMediaAccess", () => { diff --git a/src/media/read-capability.ts b/src/media/read-capability.ts index 1af076e5475..3c3b3506d37 100644 --- a/src/media/read-capability.ts +++ b/src/media/read-capability.ts @@ -4,7 +4,7 @@ import { resolveGroupToolPolicy } from "../agents/pi-tools.policy.js"; import { resolveEffectiveToolFsRootExpansionAllowed } from "../agents/tool-fs-policy.js"; import { isToolAllowedByPolicies } from "../agents/tool-policy-match.js"; import { resolveWorkspaceRoot } from "../agents/workspace-dir.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { readLocalFileSafely } from "../infra/fs-safe.js"; import { normalizeOptionalString } from "../shared/string-coerce.js"; import type { OutboundMediaAccess, OutboundMediaReadFile } from "./load-options.js"; diff --git a/src/music-generation/live-test-helpers.ts b/src/music-generation/live-test-helpers.ts index 4d7bb67bd78..db861ebf3e2 100644 --- a/src/music-generation/live-test-helpers.ts +++ b/src/music-generation/live-test-helpers.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { parseLiveCsvFilter, parseProviderModelMap, diff --git a/src/music-generation/provider-registry.ts b/src/music-generation/provider-registry.ts index c8a0bbb1999..ed582e9d806 100644 --- a/src/music-generation/provider-registry.ts +++ b/src/music-generation/provider-registry.ts @@ -1,5 +1,5 @@ import { normalizeProviderId } from "../agents/model-selection.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { isBlockedObjectKey } from "../infra/prototype-keys.js"; import { resolvePluginCapabilityProviders } from "../plugins/capability-provider-runtime.js"; import type { MusicGenerationProviderPlugin } from "../plugins/types.js"; diff --git a/src/music-generation/runtime.test.ts b/src/music-generation/runtime.test.ts index 7e7bedde08e..61423ebca4e 100644 --- a/src/music-generation/runtime.test.ts +++ b/src/music-generation/runtime.test.ts @@ -3,7 +3,7 @@ import { getMediaGenerationRuntimeMocks, resetMusicGenerationRuntimeMocks, } from "../../test/helpers/media-generation/runtime-module-mocks.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { generateMusic, listRuntimeMusicGenerationProviders } from "./runtime.js"; import type { MusicGenerationProvider } from "./types.js"; diff --git a/src/music-generation/runtime.ts b/src/music-generation/runtime.ts index b53a4f0763a..a8847e411c6 100644 --- a/src/music-generation/runtime.ts +++ b/src/music-generation/runtime.ts @@ -1,7 +1,7 @@ import type { AuthProfileStore } from "../agents/auth-profiles.js"; import { describeFailoverError, isFailoverError } from "../agents/failover-error.js"; import type { FallbackAttempt } from "../agents/model-fallback.types.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { formatErrorMessage } from "../infra/errors.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { diff --git a/src/music-generation/types.ts b/src/music-generation/types.ts index e5e9338b859..99c9a197b4d 100644 --- a/src/music-generation/types.ts +++ b/src/music-generation/types.ts @@ -1,5 +1,5 @@ import type { AuthProfileStore } from "../agents/auth-profiles.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { MediaNormalizationEntry } from "../media-generation/runtime-shared.js"; export type MusicGenerationOutputFormat = "mp3" | "wav"; diff --git a/src/plugins/config-state.ts b/src/plugins/config-state.ts index def6621a012..bb11359fecb 100644 --- a/src/plugins/config-state.ts +++ b/src/plugins/config-state.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { normalizeOptionalLowercaseString, normalizeOptionalString, diff --git a/src/plugins/install-security-scan.runtime.ts b/src/plugins/install-security-scan.runtime.ts index 0f53c41124a..c060cebdbbd 100644 --- a/src/plugins/install-security-scan.runtime.ts +++ b/src/plugins/install-security-scan.runtime.ts @@ -11,7 +11,7 @@ import { } from "./dependency-denylist.js"; import { getGlobalHookRunner } from "./hook-runner-global.js"; import { createBeforeInstallHookPayload } from "./install-policy-context.js"; -import type { InstallSafetyOverrides } from "./install-security-scan.js"; +import type { InstallSafetyOverrides } from "./install-security-scan.types.js"; type InstallScanLogger = { warn?: (message: string) => void; diff --git a/src/plugins/install-security-scan.ts b/src/plugins/install-security-scan.ts index f058a679ea8..48095a99d5e 100644 --- a/src/plugins/install-security-scan.ts +++ b/src/plugins/install-security-scan.ts @@ -2,9 +2,8 @@ type InstallScanLogger = { warn?: (message: string) => void; }; -export type InstallSafetyOverrides = { - dangerouslyForceUnsafeInstall?: boolean; -}; +export type { InstallSafetyOverrides } from "./install-security-scan.types.js"; +import type { InstallSafetyOverrides } from "./install-security-scan.types.js"; export type InstallSecurityScanResult = { blocked?: { diff --git a/src/plugins/install-security-scan.types.ts b/src/plugins/install-security-scan.types.ts new file mode 100644 index 00000000000..4b727611a5d --- /dev/null +++ b/src/plugins/install-security-scan.types.ts @@ -0,0 +1,3 @@ +export type InstallSafetyOverrides = { + dangerouslyForceUnsafeInstall?: boolean; +}; diff --git a/src/plugins/manifest-registry.ts b/src/plugins/manifest-registry.ts index 40679a1ef52..916e1f2ad8b 100644 --- a/src/plugins/manifest-registry.ts +++ b/src/plugins/manifest-registry.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; import path from "node:path"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { normalizeOptionalLowercaseString, normalizeOptionalString, diff --git a/src/plugins/memory-embedding-providers.ts b/src/plugins/memory-embedding-providers.ts index ae6ea2dd1b0..2605415cbbe 100644 --- a/src/plugins/memory-embedding-providers.ts +++ b/src/plugins/memory-embedding-providers.ts @@ -1,6 +1,6 @@ import type { OpenClawConfig } from "../config/config.js"; import type { SecretInput } from "../config/types.secrets.js"; -import type { EmbeddingInput } from "../memory-host-sdk/engine-embeddings.js"; +import type { EmbeddingInput } from "../memory-host-sdk/host/embedding-inputs.js"; export type MemoryEmbeddingBatchChunk = { text: string; diff --git a/src/plugins/plugin-kind.types.ts b/src/plugins/plugin-kind.types.ts new file mode 100644 index 00000000000..2bf6450274d --- /dev/null +++ b/src/plugins/plugin-kind.types.ts @@ -0,0 +1 @@ +export type PluginKind = "memory" | "context-engine"; diff --git a/src/plugins/provider-thinking.ts b/src/plugins/provider-thinking.ts index a93ed2a222c..75bf2fcf5a1 100644 --- a/src/plugins/provider-thinking.ts +++ b/src/plugins/provider-thinking.ts @@ -1,12 +1,21 @@ import { normalizeProviderId } from "../agents/provider-id.js"; -import { getActivePluginRegistry } from "./runtime.js"; import type { ProviderDefaultThinkingPolicyContext, - ProviderPlugin, ProviderThinkingPolicyContext, -} from "./types.js"; +} from "./provider-thinking.types.js"; +import { getActivePluginRegistry } from "./runtime.js"; -function matchesProviderId(provider: ProviderPlugin, providerId: string): boolean { +type ThinkingProviderPlugin = { + id: string; + aliases?: string[]; + isBinaryThinking?: (ctx: ProviderThinkingPolicyContext) => boolean | undefined; + supportsXHighThinking?: (ctx: ProviderThinkingPolicyContext) => boolean | undefined; + resolveDefaultThinkingLevel?: ( + ctx: ProviderDefaultThinkingPolicyContext, + ) => "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "adaptive" | null | undefined; +}; + +function matchesProviderId(provider: ThinkingProviderPlugin, providerId: string): boolean { const normalized = normalizeProviderId(providerId); if (!normalized) { return false; @@ -17,7 +26,7 @@ function matchesProviderId(provider: ProviderPlugin, providerId: string): boolea return (provider.aliases ?? []).some((alias) => normalizeProviderId(alias) === normalized); } -function resolveActiveThinkingProvider(providerId: string): ProviderPlugin | undefined { +function resolveActiveThinkingProvider(providerId: string): ThinkingProviderPlugin | undefined { return getActivePluginRegistry()?.providers.find((entry) => { return matchesProviderId(entry.provider, providerId); })?.provider; diff --git a/src/plugins/provider-thinking.types.ts b/src/plugins/provider-thinking.types.ts new file mode 100644 index 00000000000..f68f9ded1b8 --- /dev/null +++ b/src/plugins/provider-thinking.types.ts @@ -0,0 +1,22 @@ +/** + * Provider-owned thinking policy input. + * + * Used by shared `/think`, ACP controls, and directive parsing to ask a + * provider whether a model supports special reasoning UX such as xhigh or a + * binary on/off toggle. + */ +export type ProviderThinkingPolicyContext = { + provider: string; + modelId: string; +}; + +/** + * Provider-owned default thinking policy input. + * + * `reasoning` is the merged catalog hint for the selected model when one is + * available. Providers can use it to keep "reasoning model => low" behavior + * without re-reading the catalog themselves. + */ +export type ProviderDefaultThinkingPolicyContext = ProviderThinkingPolicyContext & { + reasoning?: boolean; +}; diff --git a/src/plugins/registry-types.ts b/src/plugins/registry-types.ts index 4ed300754bc..1c8bc981707 100644 --- a/src/plugins/registry-types.ts +++ b/src/plugins/registry-types.ts @@ -1,6 +1,6 @@ import type { AgentHarness } from "../agents/harness/types.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; -import type { OperatorScope } from "../gateway/method-scopes.js"; +import type { OperatorScope } from "../gateway/operator-scopes.js"; import type { GatewayRequestHandlers } from "../gateway/server-methods/types.js"; import type { HookEntry } from "../hooks/types.js"; import type { PluginActivationSource } from "./config-state.js"; diff --git a/src/plugins/registry.ts b/src/plugins/registry.ts index 4fc4b97ce14..8b0f4efe6b2 100644 --- a/src/plugins/registry.ts +++ b/src/plugins/registry.ts @@ -7,7 +7,7 @@ import type { AgentHarness } from "../agents/harness/types.js"; import type { AnyAgentTool } from "../agents/tools/common.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; import { registerContextEngineForOwner } from "../context-engine/registry.js"; -import type { OperatorScope } from "../gateway/method-scopes.js"; +import type { OperatorScope } from "../gateway/operator-scopes.js"; import type { GatewayRequestHandler } from "../gateway/server-methods/types.js"; import { registerInternalHook, unregisterInternalHook } from "../hooks/internal-hooks.js"; import type { HookEntry } from "../hooks/types.js"; diff --git a/src/plugins/slots.ts b/src/plugins/slots.ts index 24661fe5c70..cbbea0775c2 100644 --- a/src/plugins/slots.ts +++ b/src/plugins/slots.ts @@ -1,6 +1,6 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { PluginSlotsConfig } from "../config/types.plugins.js"; -import type { PluginKind } from "./types.js"; +import type { PluginKind } from "./plugin-kind.types.js"; export type PluginSlotKey = keyof PluginSlotsConfig; diff --git a/src/plugins/types.ts b/src/plugins/types.ts index 52f670a764f..4cd56ea7a53 100644 --- a/src/plugins/types.ts +++ b/src/plugins/types.ts @@ -11,7 +11,8 @@ import type { AuthProfileStore, } from "../agents/auth-profiles/types.js"; import type { AgentHarness } from "../agents/harness/types.js"; -import type { ModelCatalogEntry } from "../agents/model-catalog.js"; +import type { ModelCatalogEntry } from "../agents/model-catalog.types.js"; +import type { AgentHarness } from "../agents/harness/types.js"; import type { FailoverReason } from "../agents/pi-embedded-helpers/types.js"; import type { ModelProviderRequestTransportOverrides } from "../agents/provider-request-config.js"; import type { ProviderSystemPromptContribution } from "../agents/system-prompt-contribution.js"; @@ -31,7 +32,7 @@ import type { import type { ModelCompatConfig } from "../config/types.models.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import type { TtsAutoMode } from "../config/types.tts.js"; -import type { OperatorScope } from "../gateway/method-scopes.js"; +import type { OperatorScope } from "../gateway/operator-scopes.js"; import type { GatewayRequestHandler } from "../gateway/server-methods/types.js"; import type { InternalHookHandler } from "../hooks/internal-hooks.js"; import type { HookEntry } from "../hooks/types.js"; @@ -80,8 +81,13 @@ import type { import type { DeliveryContext } from "../utils/delivery-context.js"; import type { VideoGenerationProvider } from "../video-generation/types.js"; import type { WizardPrompter } from "../wizard/prompts.js"; +import type { PluginKind } from "./plugin-kind.types.js"; import type { SecretInputMode } from "./provider-auth-types.js"; import type { createVpsAwareOAuthHandlers } from "./provider-oauth-flow.js"; +import type { + ProviderDefaultThinkingPolicyContext, + ProviderThinkingPolicyContext, +} from "./provider-thinking.types.js"; import type { PluginRuntime } from "./runtime/types.js"; export type { PluginRuntime } from "./runtime/types.js"; @@ -112,7 +118,7 @@ export type PluginConfigUiHint = { placeholder?: string; }; -export type PluginKind = "memory" | "context-engine"; +export type { PluginKind } from "./plugin-kind.types.js"; export type PluginConfigValidation = | { ok: true; value?: unknown } @@ -901,28 +907,10 @@ export type ProviderBuiltInModelSuppressionResult = { errorMessage?: string; }; -/** - * Provider-owned thinking policy input. - * - * Used by shared `/think`, ACP controls, and directive parsing to ask a - * provider whether a model supports special reasoning UX such as xhigh or a - * binary on/off toggle. - */ -export type ProviderThinkingPolicyContext = { - provider: string; - modelId: string; -}; - -/** - * Provider-owned default thinking policy input. - * - * `reasoning` is the merged catalog hint for the selected model when one is - * available. Providers can use it to keep "reasoning model => low" behavior - * without re-reading the catalog themselves. - */ -export type ProviderDefaultThinkingPolicyContext = ProviderThinkingPolicyContext & { - reasoning?: boolean; -}; +export type { + ProviderDefaultThinkingPolicyContext, + ProviderThinkingPolicyContext, +} from "./provider-thinking.types.js"; /** * Provider-owned "modern model" policy input. diff --git a/src/tts/directives.ts b/src/tts/directives.ts index 4b74c513e2b..45ced71e382 100644 --- a/src/tts/directives.ts +++ b/src/tts/directives.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { SpeechProviderPlugin } from "../plugins/types.js"; import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js"; import { listSpeechProviders } from "./provider-registry.js"; diff --git a/src/tts/provider-registry.test.ts b/src/tts/provider-registry.test.ts index 3b77b078424..f8e122cb5b6 100644 --- a/src/tts/provider-registry.test.ts +++ b/src/tts/provider-registry.test.ts @@ -1,5 +1,5 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { createEmptyPluginRegistry } from "../plugins/registry-empty.js"; import type { SpeechProviderPlugin } from "../plugins/types.js"; diff --git a/src/tts/provider-registry.ts b/src/tts/provider-registry.ts index 1b9f3041499..c145727047c 100644 --- a/src/tts/provider-registry.ts +++ b/src/tts/provider-registry.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolvePluginCapabilityProviders } from "../plugins/capability-provider-runtime.js"; import { buildCapabilityProviderMaps, diff --git a/src/tts/provider-types.ts b/src/tts/provider-types.ts index 3c3c916c3bb..39aa9eea8f4 100644 --- a/src/tts/provider-types.ts +++ b/src/tts/provider-types.ts @@ -1,5 +1,5 @@ -import type { OpenClawConfig } from "../config/config.js"; import type { TalkProviderConfig } from "../config/types.gateway.js"; +import type { OpenClawConfig } from "../config/types.js"; export type SpeechProviderId = string; diff --git a/src/tts/status-config.test.ts b/src/tts/status-config.test.ts index ee92fb044f9..45036c3fe31 100644 --- a/src/tts/status-config.test.ts +++ b/src/tts/status-config.test.ts @@ -2,7 +2,7 @@ import fs from "node:fs"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import { withTempHome } from "../../test/helpers/temp-home.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { resolveStatusTtsSnapshot } from "./status-config.js"; describe("resolveStatusTtsSnapshot", () => { diff --git a/src/tts/status-config.ts b/src/tts/status-config.ts index 696638ab954..810d09bac09 100644 --- a/src/tts/status-config.ts +++ b/src/tts/status-config.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; import path from "node:path"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { TtsAutoMode, TtsConfig, TtsProvider } from "../config/types.tts.js"; import { normalizeOptionalLowercaseString, diff --git a/src/tts/tts-config.ts b/src/tts/tts-config.ts index 2ca892326ed..5f1fc531292 100644 --- a/src/tts/tts-config.ts +++ b/src/tts/tts-config.ts @@ -1,9 +1,8 @@ import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { TtsAutoMode, TtsMode } from "../config/types.tts.js"; import { resolveConfigDir, resolveUserPath } from "../utils.js"; -import { normalizeTtsAutoMode } from "./tts-auto-mode.js"; export { normalizeTtsAutoMode } from "./tts-auto-mode.js"; export function resolveConfiguredTtsMode(cfg: OpenClawConfig): TtsMode { diff --git a/src/tts/tts-core.ts b/src/tts/tts-core.ts index df6e6e65045..7d44500cb68 100644 --- a/src/tts/tts-core.ts +++ b/src/tts/tts-core.ts @@ -9,7 +9,7 @@ import { } from "../agents/model-selection.js"; import { resolveModelAsync } from "../agents/pi-embedded-runner/model.js"; import { prepareModelForSimpleCompletion } from "../agents/simple-completion-transport.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { normalizeOptionalLowercaseString, normalizeOptionalString, diff --git a/src/video-generation/live-test-helpers.test.ts b/src/video-generation/live-test-helpers.test.ts index 507bc34e801..447eac0b7c0 100644 --- a/src/video-generation/live-test-helpers.test.ts +++ b/src/video-generation/live-test-helpers.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { canRunBufferBackedImageToVideoLiveLane, canRunBufferBackedVideoToVideoLiveLane, diff --git a/src/video-generation/live-test-helpers.ts b/src/video-generation/live-test-helpers.ts index b5f03cb2e6a..3d783158aca 100644 --- a/src/video-generation/live-test-helpers.ts +++ b/src/video-generation/live-test-helpers.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { parseLiveCsvFilter, parseProviderModelMap, diff --git a/src/video-generation/provider-registry.ts b/src/video-generation/provider-registry.ts index 0744e7c2b6e..36c6f1530a9 100644 --- a/src/video-generation/provider-registry.ts +++ b/src/video-generation/provider-registry.ts @@ -1,5 +1,5 @@ import { normalizeProviderId } from "../agents/model-selection.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { isBlockedObjectKey } from "../infra/prototype-keys.js"; import { resolvePluginCapabilityProviders } from "../plugins/capability-provider-runtime.js"; import type { VideoGenerationProviderPlugin } from "../plugins/types.js"; diff --git a/src/video-generation/runtime.test.ts b/src/video-generation/runtime.test.ts index 01b50053540..8ef7624586a 100644 --- a/src/video-generation/runtime.test.ts +++ b/src/video-generation/runtime.test.ts @@ -3,7 +3,7 @@ import { getMediaGenerationRuntimeMocks, resetVideoGenerationRuntimeMocks, } from "../../test/helpers/media-generation/runtime-module-mocks.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { generateVideo, listRuntimeVideoGenerationProviders } from "./runtime.js"; import type { VideoGenerationProvider } from "./types.js"; diff --git a/src/video-generation/runtime.ts b/src/video-generation/runtime.ts index 5ce4605e21b..f1af46dc3e7 100644 --- a/src/video-generation/runtime.ts +++ b/src/video-generation/runtime.ts @@ -1,7 +1,7 @@ import type { AuthProfileStore } from "../agents/auth-profiles.js"; import { describeFailoverError, isFailoverError } from "../agents/failover-error.js"; import type { FallbackAttempt } from "../agents/model-fallback.types.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { formatErrorMessage } from "../infra/errors.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { diff --git a/src/video-generation/types.ts b/src/video-generation/types.ts index 5d2442dbdea..83fd595d960 100644 --- a/src/video-generation/types.ts +++ b/src/video-generation/types.ts @@ -1,5 +1,5 @@ import type { AuthProfileStore } from "../agents/auth-profiles.js"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { MediaNormalizationEntry } from "../media-generation/runtime-shared.js"; export type GeneratedVideoAsset = { diff --git a/src/web-fetch/runtime.test.ts b/src/web-fetch/runtime.test.ts index afe98ba725c..baa7b83075c 100644 --- a/src/web-fetch/runtime.test.ts +++ b/src/web-fetch/runtime.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { PluginWebFetchProviderEntry } from "../plugins/types.js"; import type { RuntimeWebFetchMetadata } from "../secrets/runtime-web-tools.types.js"; import { diff --git a/src/web-fetch/runtime.ts b/src/web-fetch/runtime.ts index dac558844fe..500bee087a1 100644 --- a/src/web-fetch/runtime.ts +++ b/src/web-fetch/runtime.ts @@ -1,4 +1,4 @@ -import type { OpenClawConfig } from "../config/config.js"; +import type { OpenClawConfig } from "../config/types.js"; import { logVerbose } from "../globals.js"; import type { PluginWebFetchProviderEntry,