diff --git a/src/agents/acp-spawn-parent-stream.ts b/src/agents/acp-spawn-parent-stream.ts index 8f8102531a5..2cff43da40b 100644 --- a/src/agents/acp-spawn-parent-stream.ts +++ b/src/agents/acp-spawn-parent-stream.ts @@ -9,7 +9,7 @@ import { scopedHeartbeatWakeOptions } from "../routing/session-key.js"; import { normalizeAssistantPhase } from "../shared/chat-message-content.js"; import { normalizeOptionalString } from "../shared/string-coerce.js"; import { recordTaskRunProgressByRunId } from "../tasks/task-executor.js"; -import { type DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; const DEFAULT_STREAM_FLUSH_MS = 2_500; const DEFAULT_NO_OUTPUT_NOTICE_MS = 60_000; diff --git a/src/agents/plugin-tool-delivery-defaults.ts b/src/agents/plugin-tool-delivery-defaults.ts index cea4e71b100..cec3bc8a3f1 100644 --- a/src/agents/plugin-tool-delivery-defaults.ts +++ b/src/agents/plugin-tool-delivery-defaults.ts @@ -1,4 +1,4 @@ -import type { DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; import type { AnyAgentTool } from "./tools/common.js"; export function applyPluginToolDeliveryDefaults(params: { diff --git a/src/agents/subagent-registry-queries.ts b/src/agents/subagent-registry-queries.ts index cf94f0da693..f6af4e81615 100644 --- a/src/agents/subagent-registry-queries.ts +++ b/src/agents/subagent-registry-queries.ts @@ -1,4 +1,4 @@ -import type { DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; import type { SubagentRunRecord } from "./subagent-registry.types.js"; function resolveControllerSessionKey(entry: SubagentRunRecord): string { diff --git a/src/agents/subagent-registry.types.ts b/src/agents/subagent-registry.types.ts index 82cdf73d1a1..bec68b9389a 100644 --- a/src/agents/subagent-registry.types.ts +++ b/src/agents/subagent-registry.types.ts @@ -1,4 +1,4 @@ -import type { DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; import type { SubagentRunOutcome } from "./subagent-announce-output.js"; import type { SubagentLifecycleEndedReason } from "./subagent-lifecycle-events.js"; import type { SpawnSubagentMode } from "./subagent-spawn.types.js"; diff --git a/src/agents/subagent-spawn.runtime.ts b/src/agents/subagent-spawn.runtime.ts index d2c8a4aea56..2dbfef61369 100644 --- a/src/agents/subagent-spawn.runtime.ts +++ b/src/agents/subagent-spawn.runtime.ts @@ -10,7 +10,7 @@ export { } from "../gateway/session-utils.js"; export { getGlobalHookRunner } from "../plugins/hook-runner-global.js"; export { emitSessionLifecycleEvent } from "../sessions/session-lifecycle-events.js"; -export { normalizeDeliveryContext } from "../utils/delivery-context.js"; +export { normalizeDeliveryContext } from "../utils/delivery-context.shared.js"; export { resolveAgentConfig } from "./agent-scope.js"; export { AGENT_LANE_SUBAGENT } from "./lanes.js"; export { resolveSubagentSpawnModelSelection } from "./model-selection.js"; diff --git a/src/agents/subagent-system-prompt.ts b/src/agents/subagent-system-prompt.ts index 0a75a9272be..f06358ed184 100644 --- a/src/agents/subagent-system-prompt.ts +++ b/src/agents/subagent-system-prompt.ts @@ -1,5 +1,5 @@ import { DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH } from "../config/agent-limits.js"; -import type { DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; export function buildSubagentSystemPrompt(params: { requesterSessionKey?: string; diff --git a/src/auto-reply/reply/session.ts b/src/auto-reply/reply/session.ts index ddab2929aee..094aca73962 100644 --- a/src/auto-reply/reply/session.ts +++ b/src/auto-reply/reply/session.ts @@ -42,7 +42,7 @@ import { normalizeOptionalLowercaseString, normalizeOptionalString, } from "../../shared/string-coerce.js"; -import { normalizeSessionDeliveryFields } from "../../utils/delivery-context.js"; +import { normalizeSessionDeliveryFields } from "../../utils/delivery-context.shared.js"; import { isInternalMessageChannel } from "../../utils/message-channel.js"; import { resolveCommandAuthorization } from "../command-auth.js"; import type { MsgContext, TemplateContext } from "../templating.js"; diff --git a/src/config/sessions/delivery-info.ts b/src/config/sessions/delivery-info.ts index 3fa72ba1988..0b279451a7e 100644 --- a/src/config/sessions/delivery-info.ts +++ b/src/config/sessions/delivery-info.ts @@ -1,4 +1,4 @@ -import { deliveryContextFromSession } from "../../utils/delivery-context.js"; +import { deliveryContextFromSession } from "../../utils/delivery-context.shared.js"; import { loadConfig } from "../io.js"; import { resolveStorePath } from "./paths.js"; import { loadSessionStore } from "./store.js"; diff --git a/src/config/sessions/store-load.ts b/src/config/sessions/store-load.ts index d311766f4c7..bd6490712e2 100644 --- a/src/config/sessions/store-load.ts +++ b/src/config/sessions/store-load.ts @@ -1,5 +1,5 @@ import fs from "node:fs"; -import { normalizeSessionDeliveryFields } from "../../utils/delivery-context.js"; +import { normalizeSessionDeliveryFields } from "../../utils/delivery-context.shared.js"; import { getFileStatSnapshot } from "../cache-utils.js"; import { isSessionStoreCacheEnabled, diff --git a/src/config/sessions/store.ts b/src/config/sessions/store.ts index 2637a04cba5..2a628c65439 100644 --- a/src/config/sessions/store.ts +++ b/src/config/sessions/store.ts @@ -13,8 +13,8 @@ import { mergeDeliveryContext, normalizeDeliveryContext, normalizeSessionDeliveryFields, - type DeliveryContext, -} from "../../utils/delivery-context.js"; +} from "../../utils/delivery-context.shared.js"; +import type { DeliveryContext } from "../../utils/delivery-context.types.js"; import { getFileStatSnapshot } from "../cache-utils.js"; import { enforceSessionDiskBudget, type SessionDiskBudgetSweepResult } from "./disk-budget.js"; import { deriveSessionMetaPatch } from "./metadata.js"; diff --git a/src/config/sessions/types.ts b/src/config/sessions/types.ts index 95048968055..0652bc1da99 100644 --- a/src/config/sessions/types.ts +++ b/src/config/sessions/types.ts @@ -3,7 +3,7 @@ import type { Skill } from "@mariozechner/pi-coding-agent"; import type { ChatType } from "../../channels/chat-type.js"; import type { ChannelId } from "../../channels/plugins/channel-id.types.js"; import { normalizeOptionalString } from "../../shared/string-coerce.js"; -import type { DeliveryContext } from "../../utils/delivery-context.js"; +import type { DeliveryContext } from "../../utils/delivery-context.types.js"; import type { TtsAutoMode } from "../types.tts.js"; export type SessionScope = "per-sender" | "global"; diff --git a/src/gateway/server-methods/agent.ts b/src/gateway/server-methods/agent.ts index d9bf2038877..5a35a9dd1e3 100644 --- a/src/gateway/server-methods/agent.ts +++ b/src/gateway/server-methods/agent.ts @@ -38,7 +38,7 @@ import { mergeDeliveryContext, normalizeDeliveryContext, normalizeSessionDeliveryFields, -} from "../../utils/delivery-context.js"; +} from "../../utils/delivery-context.shared.js"; import { INTERNAL_MESSAGE_CHANNEL, isDeliverableMessageChannel, diff --git a/src/gateway/server-methods/tools-effective.runtime.ts b/src/gateway/server-methods/tools-effective.runtime.ts index 9fcb9794ebb..e464eff6ff2 100644 --- a/src/gateway/server-methods/tools-effective.runtime.ts +++ b/src/gateway/server-methods/tools-effective.runtime.ts @@ -2,5 +2,5 @@ export { listAgentIds, resolveSessionAgentId } from "../../agents/agent-scope.js export { resolveEffectiveToolInventory } from "../../agents/tools-effective-inventory.js"; export { resolveReplyToMode } from "../../auto-reply/reply/reply-threading.js"; export { loadConfig } from "../../config/config.js"; -export { deliveryContextFromSession } from "../../utils/delivery-context.js"; +export { deliveryContextFromSession } from "../../utils/delivery-context.shared.js"; export { loadSessionEntry, resolveSessionModelRef } from "../session-utils.js"; diff --git a/src/gateway/server-restart-sentinel.test.ts b/src/gateway/server-restart-sentinel.test.ts index 467b5ae0723..6355ea90f01 100644 --- a/src/gateway/server-restart-sentinel.test.ts +++ b/src/gateway/server-restart-sentinel.test.ts @@ -69,7 +69,7 @@ vi.mock("./session-utils.js", () => ({ loadSessionEntry: mocks.loadSessionEntry, })); -vi.mock("../utils/delivery-context.js", () => ({ +vi.mock("../utils/delivery-context.shared.js", () => ({ deliveryContextFromSession: mocks.deliveryContextFromSession, mergeDeliveryContext: mocks.mergeDeliveryContext, })); diff --git a/src/gateway/server-restart-sentinel.ts b/src/gateway/server-restart-sentinel.ts index 954832a1617..20541517091 100644 --- a/src/gateway/server-restart-sentinel.ts +++ b/src/gateway/server-restart-sentinel.ts @@ -15,7 +15,10 @@ import { } from "../infra/restart-sentinel.js"; import { enqueueSystemEvent } from "../infra/system-events.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; -import { deliveryContextFromSession, mergeDeliveryContext } from "../utils/delivery-context.js"; +import { + deliveryContextFromSession, + mergeDeliveryContext, +} from "../utils/delivery-context.shared.js"; import { loadSessionEntry } from "./session-utils.js"; const log = createSubsystemLogger("gateway/restart-sentinel"); diff --git a/src/gateway/session-utils.ts b/src/gateway/session-utils.ts index 7eb42284448..cd385d6341d 100644 --- a/src/gateway/session-utils.ts +++ b/src/gateway/session-utils.ts @@ -59,7 +59,7 @@ import { normalizeOptionalLowercaseString, normalizeOptionalString, } from "../shared/string-coerce.js"; -import { normalizeSessionDeliveryFields } from "../utils/delivery-context.js"; +import { normalizeSessionDeliveryFields } from "../utils/delivery-context.shared.js"; import { estimateUsageCost, resolveModelCostConfig } from "../utils/usage-format.js"; import { canonicalizeSessionKeyForAgent, diff --git a/src/gateway/session-utils.types.ts b/src/gateway/session-utils.types.ts index 893e3876ec3..95416ae1ec2 100644 --- a/src/gateway/session-utils.types.ts +++ b/src/gateway/session-utils.types.ts @@ -6,7 +6,7 @@ import type { SessionsListResultBase, SessionsPatchResultBase, } from "../shared/session-types.js"; -import type { DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; export type GatewaySessionsDefaults = { modelProvider: string | null; diff --git a/src/infra/outbound/targets-session.ts b/src/infra/outbound/targets-session.ts index 7f23f2235ec..bc04b733b66 100644 --- a/src/infra/outbound/targets-session.ts +++ b/src/infra/outbound/targets-session.ts @@ -5,7 +5,7 @@ import { } from "../../channels/plugins/target-parsing.js"; import type { ChannelOutboundTargetMode } from "../../channels/plugins/types.public.js"; import type { SessionEntry } from "../../config/sessions.js"; -import { deliveryContextFromSession } from "../../utils/delivery-context.js"; +import { deliveryContextFromSession } from "../../utils/delivery-context.shared.js"; import type { DeliverableMessageChannel, GatewayMessageChannel, diff --git a/src/infra/outbound/targets.ts b/src/infra/outbound/targets.ts index f8d773bcbc5..c65a39aa005 100644 --- a/src/infra/outbound/targets.ts +++ b/src/infra/outbound/targets.ts @@ -8,8 +8,8 @@ import { normalizeAccountId } from "../../routing/session-key.js"; import { deliveryContextFromSession, mergeDeliveryContext, - type DeliveryContext, -} from "../../utils/delivery-context.js"; +} from "../../utils/delivery-context.shared.js"; +import type { DeliveryContext } from "../../utils/delivery-context.types.js"; import type { DeliverableMessageChannel, GatewayMessageChannel, diff --git a/src/infra/session-maintenance-warning.ts b/src/infra/session-maintenance-warning.ts index a2e20a32cb7..0a31dd89e2b 100644 --- a/src/infra/session-maintenance-warning.ts +++ b/src/infra/session-maintenance-warning.ts @@ -2,7 +2,7 @@ import type { SessionMaintenanceWarning } from "../config/sessions/store-mainten import type { SessionEntry } from "../config/sessions/types.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; -import { deliveryContextFromSession } from "../utils/delivery-context.js"; +import { deliveryContextFromSession } from "../utils/delivery-context.shared.js"; import { isDeliverableMessageChannel, normalizeMessageChannel } from "../utils/message-channel.js"; import { buildOutboundSessionContext } from "./outbound/session-context.js"; import { enqueueSystemEvent } from "./system-events.js"; diff --git a/src/infra/system-events.ts b/src/infra/system-events.ts index 6bb55cb1f43..c6b6b245bfd 100644 --- a/src/infra/system-events.ts +++ b/src/infra/system-events.ts @@ -10,8 +10,8 @@ import { import { mergeDeliveryContext, normalizeDeliveryContext, - type DeliveryContext, -} from "../utils/delivery-context.js"; +} from "../utils/delivery-context.shared.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; export type SystemEvent = { text: string; diff --git a/src/plugins/runtime/task-domain-types.ts b/src/plugins/runtime/task-domain-types.ts index 6208e1d4b12..4e347894bb1 100644 --- a/src/plugins/runtime/task-domain-types.ts +++ b/src/plugins/runtime/task-domain-types.ts @@ -9,7 +9,7 @@ import type { TaskStatusCounts, TaskTerminalOutcome, } from "../../tasks/task-registry.types.js"; -import type { DeliveryContext } from "../../utils/delivery-context.js"; +import type { DeliveryContext } from "../../utils/delivery-context.types.js"; export type TaskRunAggregateSummary = { total: number; diff --git a/src/tasks/task-flow-registry.store.sqlite.ts b/src/tasks/task-flow-registry.store.sqlite.ts index 2e362bfd31b..2edd0b81b32 100644 --- a/src/tasks/task-flow-registry.store.sqlite.ts +++ b/src/tasks/task-flow-registry.store.sqlite.ts @@ -1,7 +1,7 @@ import { chmodSync, existsSync, mkdirSync } from "node:fs"; import type { DatabaseSync, StatementSync } from "node:sqlite"; import { requireNodeSqlite } from "../infra/node-sqlite.js"; -import type { DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; import { resolveTaskFlowRegistryDir, resolveTaskFlowRegistrySqlitePath, diff --git a/src/tasks/task-registry.store.sqlite.ts b/src/tasks/task-registry.store.sqlite.ts index 2ac2afb4b94..9cfb40b9f19 100644 --- a/src/tasks/task-registry.store.sqlite.ts +++ b/src/tasks/task-registry.store.sqlite.ts @@ -1,7 +1,7 @@ import { chmodSync, existsSync, mkdirSync } from "node:fs"; import type { DatabaseSync, StatementSync } from "node:sqlite"; import { requireNodeSqlite } from "../infra/node-sqlite.js"; -import type { DeliveryContext } from "../utils/delivery-context.js"; +import type { DeliveryContext } from "../utils/delivery-context.types.js"; import { resolveTaskRegistryDir, resolveTaskRegistrySqlitePath } from "./task-registry.paths.js"; import type { TaskRegistryStoreSnapshot } from "./task-registry.store.types.js"; import type { TaskDeliveryState, TaskRecord } from "./task-registry.types.js";