fix(utils): bypass delivery context wrapper for shared consumers

This commit is contained in:
Vincent Koc
2026-04-11 17:25:11 +01:00
parent e1b2ae235a
commit f630e8d440
24 changed files with 30 additions and 27 deletions

View File

@@ -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;

View File

@@ -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: {

View File

@@ -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 {

View File

@@ -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";

View File

@@ -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";

View File

@@ -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;

View File

@@ -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";

View File

@@ -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";

View File

@@ -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,

View File

@@ -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";

View File

@@ -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";

View File

@@ -38,7 +38,7 @@ import {
mergeDeliveryContext,
normalizeDeliveryContext,
normalizeSessionDeliveryFields,
} from "../../utils/delivery-context.js";
} from "../../utils/delivery-context.shared.js";
import {
INTERNAL_MESSAGE_CHANNEL,
isDeliverableMessageChannel,

View File

@@ -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";

View File

@@ -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,
}));

View File

@@ -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");

View File

@@ -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,

View File

@@ -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;

View File

@@ -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,

View File

@@ -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,

View File

@@ -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";

View File

@@ -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;

View File

@@ -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;

View File

@@ -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,

View File

@@ -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";