refactor(gateway): relocate agent turn modules (#121241)

This commit is contained in:
Peter Steinberger
2026-08-09 14:30:10 -07:00
committed by GitHub
parent 59ec48439e
commit 063acb9268
37 changed files with 102 additions and 105 deletions
+1 -1
View File
@@ -7,8 +7,8 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite
import type { AcpInitializeSessionInput } from "../acp/control-plane/manager.types.js";
import type { SessionEntry } from "../config/sessions/types.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { setGatewayDedupeEntry, waitForAgentJob } from "../gateway/agent-turn/agent-job.js";
import type { CallGatewayOptions } from "../gateway/call.js";
import { setGatewayDedupeEntry, waitForAgentJob } from "../gateway/server-methods/agent-job.js";
import type { DedupeEntry } from "../gateway/server-shared.js";
import {
testing as sessionBindingServiceTesting,
@@ -7,8 +7,8 @@ import {
clearRuntimeConfigSnapshot,
getRuntimeConfig,
} from "../config/config.js";
import { prepareAgentRequestPreflight } from "../gateway/agent-turn/agent-request-preflight.js";
import { createAgentTurnIo } from "../gateway/agent-turn/io.js";
import { prepareAgentRequestPreflight } from "../gateway/server-methods/agent-request-preflight.js";
import type {
GatewayRequestContext,
GatewayRequestOptions,
@@ -11,8 +11,12 @@ import {
beginSessionWorkAdmission,
type SessionWorkAdmissionLease,
} from "../../sessions/session-lifecycle-admission.js";
import type { AgentTurnContext, AgentTurnIo } from "../agent-turn/types.js";
import { registerChatAbortController } from "../chat-abort.js";
import {
assertExpectedExistingSession,
consumeExpectedSessionWorkAdmission,
type ExpectedExistingSessionConstraint,
} from "../server-methods/agent-expected-session.js";
import { loadSessionEntry } from "../session-utils.js";
import type { AgentDedupeLifecycle } from "./agent-dedupe-lifecycle.js";
import {
@@ -21,11 +25,7 @@ import {
readGatewayDedupeEntry,
setAbortedAgentDedupeEntries,
} from "./agent-dedupe.js";
import {
assertExpectedExistingSession,
consumeExpectedSessionWorkAdmission,
type ExpectedExistingSessionConstraint,
} from "./agent-expected-session.js";
import type { AgentTurnContext, AgentTurnIo } from "./types.js";
export function createAgentAdmissionController(params: {
cfg: OpenClawConfig;
@@ -29,7 +29,6 @@ import {
isInternalNonDeliveryChannel,
normalizeMessageChannel,
} from "../../utils/message-channel.js";
import type { AgentTurnContext } from "../agent-turn/types.js";
import { resolveChatAttachmentMaxBytes } from "../chat-attachment-policy.js";
import {
MediaOffloadError,
@@ -37,14 +36,15 @@ import {
parseMessageWithAttachments,
type ChatAttachment,
} from "../chat-attachments.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import type { GatewayRequestHandlerOptions } from "../server-methods/types.js";
import {
loadSessionEntry,
resolveGatewayModelSupportsImages,
resolveSessionModelRef,
} from "../session-utils.js";
import { formatForLog } from "../ws-log.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { GatewayRequestHandlerOptions } from "./types.js";
import type { AgentTurnContext } from "./types.js";
type ExplicitRecipientSession = Awaited<
ReturnType<
@@ -2,8 +2,15 @@ import { randomUUID } from "node:crypto";
import { AGENT_RUN_RESTART_ABORT_STOP_REASON } from "../../agents/run-termination.js";
import { resolveAgentTimeoutMs } from "../../agents/timeout.js";
import { getAgentEventLifecycleGeneration } from "../../infra/agent-events.js";
import type { AgentTurnContext, AgentTurnIo } from "../agent-turn/types.js";
import { resolveAgentRunExpiresAtMs } from "../chat-abort.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import type { CommittedResetCompletion } from "../server-methods/agent-reset-phase.js";
import {
buildBareSessionResetResponse,
buildBareSessionResetResult,
sessionResetAckText,
} from "../server-methods/agent-session-reset.js";
import { emitSessionsChanged } from "../server-methods/session-change-event.js";
import { resolveSessionStoreKey } from "../session-utils.js";
import {
isAcceptedAgentDedupePayload,
@@ -12,15 +19,8 @@ import {
setAbortedAgentDedupeEntries,
setGatewayDedupeEntries,
} from "./agent-dedupe.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { CommittedResetCompletion } from "./agent-reset-phase.js";
import { deleteGatewayDedupeEntries } from "./agent-run-dispatch.js";
import {
buildBareSessionResetResponse,
buildBareSessionResetResult,
sessionResetAckText,
} from "./agent-session-reset.js";
import { emitSessionsChanged } from "./session-change-event.js";
import type { AgentTurnContext, AgentTurnIo } from "./types.js";
export type AgentDedupeLifecycle = ReturnType<typeof createAgentDedupeLifecycle>;
@@ -1,6 +1,6 @@
import { uniqueStrings } from "@openclaw/normalization-core/string-normalization";
import type { GatewayRequestContext } from "../server-methods/types.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import type { GatewayRequestContext } from "./types.js";
export function resolveAgentDedupeKeys(params: {
idempotencyKey: string;
@@ -16,10 +16,10 @@ import {
isInternalNonDeliveryChannel,
normalizeMessageChannel,
} from "../../utils/message-channel.js";
import type { AgentTurnContext, AgentTurnPrincipal } from "../agent-turn/types.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import type { GatewayRequestHandlerOptions } from "../server-methods/types.js";
import { formatForLog } from "../ws-log.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { GatewayRequestHandlerOptions } from "./types.js";
import type { AgentTurnContext, AgentTurnPrincipal } from "./types.js";
type DeliveryPlan = Awaited<ReturnType<typeof resolveAgentDeliveryPlanWithSessionRoute>>;
@@ -21,12 +21,12 @@ import {
import type { InputProvenance } from "../../sessions/input-provenance.js";
import { setSafeTimeout } from "../../utils/timer-delay.js";
import { ADMIN_SCOPE } from "../method-scopes.js";
import type { GatewayRequestHandlerOptions } from "../server-methods/types.js";
import {
emitGatewaySessionEndPluginHook,
emitGatewaySessionStartPluginHook,
} from "../session-reset-service.js";
import { loadSessionEntry, resolveDeletedAgentIdFromSessionKey } from "../session-utils.js";
import type { GatewayRequestHandlerOptions } from "./types.js";
export const CRON_CONTINUATION_RELEASE_RECOVERY_DELAYS_MS = [250, 1_000, 4_000, 15_000] as const;
@@ -1,9 +1,9 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { subagentRuns } from "../../agents/subagent-registry-memory.js";
import * as sessionAccessor from "../../config/sessions/session-accessor.js";
import { createAgentTurnService } from "../agent-turn/agent-turn-service.js";
import { createAgentTurnIo } from "../agent-turn/io.js";
import { prepareAgentRequestPreflight } from "./agent-request-preflight.js";
import { createAgentTurnService } from "./agent-turn-service.js";
import { createAgentTurnIo } from "./io.js";
function runPreflight(
swarmOutputSchema?: Record<string, unknown>,
@@ -18,18 +18,18 @@ import {
shouldPreserveUserFacingSessionStateForInputProvenance,
} from "../../sessions/input-provenance.js";
import { isSubagentSessionKey } from "../../sessions/session-key-utils.js";
import type { AgentTurnContext, AgentTurnIo, AgentTurnPrincipal } from "../agent-turn/types.js";
import { readGatewayDedupeEntry, resolveAgentDedupeKeys } from "./agent-dedupe.js";
import {
resolveExpectedExistingSessionConstraint,
type ExpectedExistingSessionConstraint,
} from "./agent-expected-session.js";
} from "../server-methods/agent-expected-session.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import { readGatewayDedupeEntry, resolveAgentDedupeKeys } from "./agent-dedupe.js";
import {
resolveAllowModelOverrideFromClient,
resolveCanUseCronRunContinuation,
resolveCanUseInternalRuntimeHandoff,
} from "./agent-handler-helpers.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { AgentTurnContext, AgentTurnIo, AgentTurnPrincipal } from "./types.js";
export type AgentRequestPreflight = {
request: AgentRunRequest;
@@ -18,18 +18,18 @@ import {
isDeliverableMessageChannel,
normalizeMessageChannel,
} from "../../utils/message-channel.js";
import type { AgentTurnContext } from "../agent-turn/types.js";
import { loadSessionEntry, resolveSessionStoreKey } from "../session-utils.js";
import { formatForLog } from "../ws-log.js";
import { setGatewayDedupeEntries } from "./agent-dedupe.js";
import {
validateExpectedExistingSessionTarget,
type ExpectedExistingSessionConstraint,
} from "./agent-expected-session.js";
} from "../server-methods/agent-expected-session.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import { normalizeRpcAttachmentsToChatAttachments } from "../server-methods/attachment-normalize.js";
import type { GatewayRequestHandlerOptions } from "../server-methods/types.js";
import { loadSessionEntry, resolveSessionStoreKey } from "../session-utils.js";
import { formatForLog } from "../ws-log.js";
import { setGatewayDedupeEntries } from "./agent-dedupe.js";
import { respondUnavailableAgentSessionForKey } from "./agent-handler-helpers.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import { normalizeRpcAttachmentsToChatAttachments } from "./attachment-normalize.js";
import type { GatewayRequestHandlerOptions } from "./types.js";
import type { AgentTurnContext } from "./types.js";
type ExplicitRecipientSession = Awaited<ReturnType<typeof resolveAgentExplicitRecipientSession>>;
@@ -22,8 +22,18 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { claimAgentRunContext } from "../../infra/agent-run-registry.js";
import type { InputProvenance } from "../../sessions/input-provenance.js";
import type { SessionWorkAdmissionLease } from "../../sessions/session-lifecycle-admission.js";
import type { AgentTurnContext, AgentTurnIo, AgentTurnPrincipal } from "../agent-turn/types.js";
import { registerChatAbortController, resolveAgentRunExpiresAtMs } from "../chat-abort.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import {
isConfirmedAcpManualSpawnTaskOwner,
registerPluginSubagentRunFromGateway,
resolveGatewayAgentTaskTrackingMode,
type GatewayAgentTaskTrackingMode,
} from "../server-methods/agent-task-tracking.js";
import {
resolveGatewayCronCreatorAuthorityAdmission,
type GatewayCronCreatorAuthorityAdmission,
} from "../server-methods/cron-creator-authority-admission.js";
import { loadSessionEntry, resolveSessionModelRef } from "../session-utils.js";
import { consumeSubagentCompletionToolHandoff } from "../subagent-completion-tool-handoff.js";
import { formatForLog } from "../ws-log.js";
@@ -34,17 +44,7 @@ import {
} from "./agent-dedupe.js";
import type { AgentDeliveryPhaseResult } from "./agent-delivery-phase.js";
import type { RestoredCronContinuation } from "./agent-handler-helpers.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import {
isConfirmedAcpManualSpawnTaskOwner,
registerPluginSubagentRunFromGateway,
resolveGatewayAgentTaskTrackingMode,
type GatewayAgentTaskTrackingMode,
} from "./agent-task-tracking.js";
import {
resolveGatewayCronCreatorAuthorityAdmission,
type GatewayCronCreatorAuthorityAdmission,
} from "./cron-creator-authority-admission.js";
import type { AgentTurnContext, AgentTurnIo, AgentTurnPrincipal } from "./types.js";
export type PreparedAgentRunDispatch = {
activeGatewayWorkAdmission: SessionWorkAdmissionLease;
@@ -17,15 +17,15 @@ import { defaultRuntime } from "../../runtime.js";
import { createRunningTaskRun } from "../../tasks/detached-task-runtime.js";
import { mapAgentRunTerminalOutcomeToTaskStatus } from "../../tasks/task-registry-common.js";
import { normalizeDeliveryContext } from "../../utils/delivery-context.shared.js";
import type { AgentTurnContext, AgentTurnIo } from "../agent-turn/types.js";
import type { ChatAbortControllerEntry } from "../chat-abort.js";
import { formatForLog } from "../ws-log.js";
import { setGatewayDedupeEntries } from "./agent-dedupe.js";
import {
tryFinalizeTrackedAgentTask,
type GatewayAgentTaskTrackingMode,
} from "./agent-task-tracking.js";
import type { GatewayCronCreatorAuthorityAdmission } from "./cron-creator-authority-admission.js";
} from "../server-methods/agent-task-tracking.js";
import type { GatewayCronCreatorAuthorityAdmission } from "../server-methods/cron-creator-authority-admission.js";
import { formatForLog } from "../ws-log.js";
import { setGatewayDedupeEntries } from "./agent-dedupe.js";
import type { AgentTurnContext, AgentTurnIo } from "./types.js";
function resolveResolvedAgentTimeoutStopReason(
meta: unknown,
@@ -40,7 +40,11 @@ import {
buildRunUserTurnIdempotencyKey,
createUserTurnTranscriptRecorder,
} from "../../sessions/user-turn-transcript.js";
import type { AgentTurnContext, AgentTurnIo, AgentTurnPrincipal } from "../agent-turn/types.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import { createAgentRunModelSelectionHandler } from "../server-methods/agent-run-model-selection.js";
import { resolveSessionRuntimeCwd } from "../server-methods/agent-session-reset.js";
import { gatewayClientSenderFields } from "../server-methods/gateway-client-identity.js";
import { emitSessionsChanged } from "../server-methods/session-change-event.js";
import { reactivateCompletedSubagentSession } from "../session-subagent-reactivation.js";
import { loadSessionEntry } from "../session-utils.js";
import { formatForLog } from "../ws-log.js";
@@ -52,7 +56,6 @@ import {
yieldAfterAgentAcceptedAck,
type RestoredCronContinuation,
} from "./agent-handler-helpers.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import {
resolveAgentRestartRecoveryChannelContext,
resolveAgentRestartRecoveryExecutionIdentityAdmission,
@@ -62,10 +65,7 @@ import {
resolveAbortedAgentStopReason,
dispatchAgentRunFromGateway,
} from "./agent-run-dispatch.js";
import { createAgentRunModelSelectionHandler } from "./agent-run-model-selection.js";
import { resolveSessionRuntimeCwd } from "./agent-session-reset.js";
import { gatewayClientSenderFields } from "./gateway-client-identity.js";
import { emitSessionsChanged } from "./session-change-event.js";
import type { AgentTurnContext, AgentTurnIo, AgentTurnPrincipal } from "./types.js";
export function startAgentRunExecution(params: {
prepared: PreparedAgentRunDispatch;
@@ -24,21 +24,21 @@ import { resolveSendPolicy } from "../../sessions/send-policy.js";
import { recordSessionCreated } from "../../sessions/session-state-events.js";
import { getGeneratedMediaTaskIdsForSessionKey } from "../../tasks/task-status-access.js";
import { sessionDeliveryChannel } from "../../utils/delivery-context.shared.js";
import { formatForLog } from "../ws-log.js";
import {
assertExpectedExistingSession,
ExpectedExistingSessionChangedError,
} from "./agent-expected-session.js";
} from "../server-methods/agent-expected-session.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import type { AgentSessionPatchBuild } from "../server-methods/agent-session-patch.js";
import type { TrustedSessionCreation } from "../server-methods/session-creation-provenance.js";
import type { GatewayRequestHandlerOptions } from "../server-methods/types.js";
import { formatForLog } from "../ws-log.js";
import {
cronContinuationHasReusableRuntime,
emitAgentSendSessionLifecycleTransition,
withSqliteSessionFileMarker,
type RestoredCronContinuation,
} from "./agent-handler-helpers.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { AgentSessionPatchBuild } from "./agent-session-patch.js";
import type { TrustedSessionCreation } from "./session-creation-provenance.js";
import type { GatewayRequestHandlerOptions } from "./types.js";
export type CronContinuationClaim = {
storePath: string;
+12 -15
View File
@@ -13,30 +13,27 @@ import { mergeSessionEntry, type SessionEntry } from "../../config/sessions.js";
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { getAgentEventLifecycleGeneration } from "../../infra/agent-events.js";
import { normalizeDeliveryContext } from "../../utils/delivery-context.shared.js";
import { createAgentAdmissionController } from "../server-methods/agent-admission-controller.js";
import { prepareAgentContentPhase } from "../server-methods/agent-content-phase.js";
import { createCronContinuationController } from "../server-methods/agent-cron-continuation.js";
import { createAgentDedupeLifecycle } from "../server-methods/agent-dedupe-lifecycle.js";
import {
isAcceptedAgentDedupePayload,
readGatewayDedupeEntry,
} from "../server-methods/agent-dedupe.js";
import { resolveAgentDeliveryPhase } from "../server-methods/agent-delivery-phase.js";
import type { RestoredCronContinuation } from "../server-methods/agent-handler-helpers.js";
import { waitForAgentJob } from "../server-methods/agent-job.js";
import type { AgentRequestPreflight } from "../server-methods/agent-request-preflight.js";
import { prepareAgentRequestRouting } from "../server-methods/agent-request-routing.js";
import { runAgentResetPhase } from "../server-methods/agent-reset-phase.js";
import { prepareAgentRunDispatch } from "../server-methods/agent-run-admission-phase.js";
import { startAgentRunExecution } from "../server-methods/agent-run-execution-phase.js";
import { buildAgentSessionPatch } from "../server-methods/agent-session-patch.js";
import { persistAgentSessionPhase } from "../server-methods/agent-session-persist.js";
import { prepareAgentSession } from "../server-methods/agent-session-prepare.js";
import { handleChatAbortRequest } from "../server-methods/chat-abort-handler.js";
import { resolveAgentRunSessionCreation } from "../server-methods/session-creation-provenance.js";
import type { GatewayRequestHandlerOptions, RespondFn } from "../server-methods/shared-types.js";
import { authorizeResolvedSessionMutation } from "../session-sharing.js";
import { formatForLog } from "../ws-log.js";
import { createAgentAdmissionController } from "./agent-admission-controller.js";
import { prepareAgentContentPhase } from "./agent-content-phase.js";
import { createAgentDedupeLifecycle } from "./agent-dedupe-lifecycle.js";
import { isAcceptedAgentDedupePayload, readGatewayDedupeEntry } from "./agent-dedupe.js";
import { resolveAgentDeliveryPhase } from "./agent-delivery-phase.js";
import type { RestoredCronContinuation } from "./agent-handler-helpers.js";
import { waitForAgentJob } from "./agent-job.js";
import type { AgentRequestPreflight } from "./agent-request-preflight.js";
import { prepareAgentRequestRouting } from "./agent-request-routing.js";
import { prepareAgentRunDispatch } from "./agent-run-admission-phase.js";
import { startAgentRunExecution } from "./agent-run-execution-phase.js";
import { persistAgentSessionPhase } from "./agent-session-persist.js";
import type { AgentTurnIo, AgentTurnPrincipal } from "./types.js";
type AgentTurnStartRequest = {
@@ -1,9 +1,9 @@
import { expectDefined } from "@openclaw/normalization-core";
import { afterEach, describe, expect, it, vi } from "vitest";
import { emitAgentEvent } from "../../infra/agent-events.js";
import { agentHandlers } from "../server-methods/agent.js";
import type { DedupeEntry } from "../server-shared.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import { agentHandlers } from "./agent.js";
function waitThroughGateway(
params: { runId: string; timeoutMs: number },
+1 -1
View File
@@ -5,9 +5,9 @@ import {
unwrapGatewayMethodDispatchResponse,
} from "../server-in-process-dispatch.js";
import { runWithGatewayRequestEnvelope } from "../server-methods.js";
import { prepareAgentRequestPreflight } from "../server-methods/agent-request-preflight.js";
import type { AgentRunRequest } from "../server-methods/agent-request-types.js";
import type { GatewayRequestOptions } from "../server-methods/types.js";
import { prepareAgentRequestPreflight } from "./agent-request-preflight.js";
import { createAgentTurnService } from "./agent-turn-service.js";
import { captureAgentTurnPrincipal } from "./principal.js";
import type { AgentTurnFrame, AgentTurnIo } from "./types.js";
@@ -6,13 +6,13 @@ import { getAgentEventLifecycleGeneration } from "../../infra/agent-events.js";
import { runWithGatewayIndependentRootWorkContinuation } from "../../process/gateway-work-admission.js";
import { parseCronRunScopeSuffix } from "../../sessions/session-key-utils.js";
import { hasNewGeneratedMediaTaskForSessionKey } from "../../tasks/task-status-access.js";
import { formatForLog } from "../ws-log.js";
import {
CRON_CONTINUATION_RELEASE_RECOVERY_DELAYS_MS,
waitForCronContinuationReleaseRecovery,
withoutCronRunContinuation,
} from "./agent-handler-helpers.js";
import type { CronContinuationClaim } from "./agent-session-persist.js";
} from "../agent-turn/agent-handler-helpers.js";
import type { CronContinuationClaim } from "../agent-turn/agent-session-persist.js";
import { formatForLog } from "../ws-log.js";
import { emitSessionsChanged } from "./session-change-event.js";
import type { GatewayRequestHandlerOptions } from "./types.js";
@@ -10,10 +10,10 @@ import {
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { assertAgentRunLifecycleGenerationCurrent } from "../../infra/agent-events.js";
import { AGENT_SESSION_RESET_COMMAND_RE } from "../agent-command-policy.js";
import { setGatewayDedupeEntries } from "../agent-turn/agent-dedupe.js";
import { clientHasAdminScope } from "../agent-turn/agent-handler-helpers.js";
import { ADMIN_SCOPE } from "../method-scopes.js";
import { formatForLog } from "../ws-log.js";
import { setGatewayDedupeEntries } from "./agent-dedupe.js";
import { clientHasAdminScope } from "./agent-handler-helpers.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import {
buildBareSessionResetResponse,
@@ -3,10 +3,10 @@ import {
hasGatewayClientCap,
} from "../../../packages/gateway-protocol/src/client-info.js";
import { validateAgentParams } from "../../../packages/gateway-protocol/src/index.js";
import { prepareAgentRequestPreflight } from "../agent-turn/agent-request-preflight.js";
import { createAgentTurnService } from "../agent-turn/agent-turn-service.js";
import { createAgentTurnIo } from "../agent-turn/io.js";
import { captureAgentTurnPrincipal } from "../agent-turn/principal.js";
import { prepareAgentRequestPreflight } from "./agent-request-preflight.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { GatewayRequestHandlers } from "./types.js";
import { assertValidParams } from "./validation.js";
@@ -24,11 +24,11 @@ import { isRecoverableTerminalSessionStatus } from "../../config/sessions/termin
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { parseCronRunScopeSuffix } from "../../sessions/session-key-utils.js";
import { sessionDeliveryChannel } from "../../utils/delivery-context.shared.js";
import { loadSessionEntry } from "../session-utils.js";
import {
respondDeletedAgentSession,
type RestoredCronContinuation,
} from "./agent-handler-helpers.js";
} from "../agent-turn/agent-handler-helpers.js";
import { loadSessionEntry } from "../session-utils.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { GatewayRequestHandlerOptions } from "./types.js";
@@ -4,10 +4,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { registerExecApprovalFollowupRuntimeHandoff } from "../../agents/bash-tools.exec-approval-followup-state.js";
import type { InternalSessionEntry as SessionEntry } from "../../config/sessions.js";
import { runExclusiveSessionLifecycleMutation } from "../../sessions/session-lifecycle-admission.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import { prepareAgentRunDispatch } from "../agent-turn/agent-run-admission-phase.js";
import { createAgentTurnIo } from "../agent-turn/io.js";
import { resolveAgentRunExpiresAtMs } from "../chat-abort.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import { prepareAgentRunDispatch } from "./agent-run-admission-phase.js";
import {
getAgentTestMocks,
makeContext,
@@ -18,8 +18,8 @@ import {
} from "../../tasks/task-registry.js";
import { setDetachedTaskLifecycleRuntime } from "../../tasks/task-runtime.test-helpers.js";
import { withTempDir } from "../../test-helpers/temp-dir.js";
import { dispatchAgentRunFromGateway } from "../agent-turn/agent-run-dispatch.js";
import { createAgentTurnIo } from "../agent-turn/io.js";
import { dispatchAgentRunFromGateway } from "./agent-run-dispatch.js";
import { registerPluginSubagentRunFromGateway } from "./agent-task-tracking.js";
import {
applyGatewaySubagentRegistryTestDeps,
@@ -2,11 +2,11 @@
import { uniqueStrings } from "@openclaw/normalization-core/string-normalization";
import { normalizeAgentId } from "../../routing/session-key.js";
import { parseAgentSessionKey } from "../../sessions/session-key-utils.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import type { ChatAbortControllerEntry } from "../chat-abort.js";
import { ADMIN_SCOPE } from "../method-scopes.js";
import { createChatAbortMarker } from "../server-chat-state.js";
import { pendingChatSendDedupeKey } from "../server-shared.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import {
normalizeOptionalChatText as normalizeOptionalText,
normalizeUnknownChatText as normalizeUnknownText,
@@ -15,11 +15,11 @@ import {
import { getAgentEventLifecycleGeneration } from "../../infra/agent-events.js";
import { claimAgentRunContext, clearAgentRunContext } from "../../infra/agent-run-registry.js";
import { beginSessionWorkAdmission } from "../../sessions/session-lifecycle-admission.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import { registerChatAbortController, resolveChatRunExpiresAtMs } from "../chat-abort.js";
import { PENDING_CHAT_SEND_DEDUPE_PREFIX, type DedupeEntry } from "../server-shared.js";
import { loadSessionEntry } from "../session-utils.js";
import { formatForLog } from "../ws-log.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import {
buildAbortedChatSendPayload,
readPreRegisteredRun,
@@ -3,10 +3,10 @@ import { resolveDefaultAgentId } from "../../agents/agent-scope.js";
import { clearAgentRunContext } from "../../infra/agent-run-registry.js";
import { retainGatewayRootWorkAdmissionContinuation } from "../../process/gateway-work-admission.js";
import type { UserTurnTranscriptRecorder } from "../../sessions/user-turn-transcript.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import { chatAbortMarkerTimestampMs } from "../server-chat-state.js";
import { persistGatewaySessionLifecycleEvent } from "../session-lifecycle-state.js";
import { formatForLog } from "../ws-log.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import { buildAbortedChatSendPayload } from "./chat-abort-authorization.js";
import { broadcastChatError, broadcastChatFinal } from "./chat-broadcast.js";
import type { AdmittedChatSend } from "./chat-send-admission.js";
@@ -16,9 +16,9 @@ import {
} from "../../infra/diagnostics-timeline.js";
import { retainGatewayRootWorkAdmissionContinuation } from "../../process/gateway-work-admission.js";
import { isOperatorUiClient } from "../../utils/message-channel.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import { updateChatRunProvider } from "../chat-abort.js";
import type { ChatRunTiming } from "../server-chat-state.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import { broadcastChatError, broadcastChatFinal } from "./chat-broadcast.js";
import { hasGatewayAdminScope } from "./chat-origin-routing.js";
import { terminalizeRestartSafeChatAdmission } from "./chat-restart-recovery.js";
@@ -18,7 +18,7 @@ import { updateSessionEntry } from "../../config/sessions/session-accessor.js";
import { isDiagnosticsEnabled } from "../../infra/diagnostic-events.js";
import { logMessageProcessed, logMessageReceived } from "../../logging/diagnostic.js";
import { getGlobalHookRunner } from "../../plugins/hook-runner-global.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import { broadcastChatFinal } from "./chat-broadcast.js";
import { buildChatSendReplyInjectionText } from "./chat-send-reply-context.js";
import type { NormalizedChatSendRequest } from "./chat-send-request.js";
@@ -4,10 +4,10 @@ import { resolveSessionWorkStartError } from "../../config/sessions.js";
import { SESSION_ROUTING_CHANGED_ERROR_REASON } from "../../config/sessions/main-session.js";
import { resolveSendPolicy } from "../../sessions/send-policy.js";
import { sessionDeliveryChannel } from "../../utils/delivery-context.shared.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import { chatAbortMarkerTimestampMs } from "../server-chat-state.js";
import { PENDING_CHAT_SEND_DEDUPE_PREFIX } from "../server-shared.js";
import { loadSessionEntry } from "../session-utils.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import {
buildAbortedChatSendPayload,
readPreRegisteredRun,
@@ -1,5 +1,5 @@
import type { InputProvenance } from "../../sessions/input-provenance.js";
import { clientHasAdminScope } from "./agent-handler-helpers.js";
import { clientHasAdminScope } from "../agent-turn/agent-handler-helpers.js";
import type { AgentRunRequest } from "./agent-request-types.js";
import type { GatewayClient } from "./shared-types.js";
@@ -28,6 +28,7 @@ import {
} from "../../infra/system-run-approval-binding.js";
import { resetLogger, setLoggerOverride } from "../../logging.js";
import { createOpenClawTestState } from "../../test-utils/openclaw-test-state.js";
import { waitForAgentJob } from "../agent-turn/agent-job.js";
import {
DEFAULT_CHAT_HISTORY_TEXT_MAX_CHARS,
augmentChatHistoryWithCanvasBlocks,
@@ -39,7 +40,6 @@ import {
import { ExecApprovalManager } from "../exec-approval-manager.js";
import { createChatRunState } from "../server-chat-state.js";
import { HEALTH_REFRESH_INTERVAL_MS } from "../server-constants.js";
import { waitForAgentJob } from "./agent-job.js";
import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js";
import { normalizeRpcAttachmentsToChatAttachments } from "./attachment-normalize.js";
import { createExecApprovalHandlers } from "./exec-approval.js";
+1 -1
View File
@@ -17,6 +17,7 @@ import {
} from "../../config/sessions.js";
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { normalizeAgentId, parseAgentSessionKey } from "../../routing/session-key.js";
import { setGatewayDedupeEntry } from "../agent-turn/agent-job.js";
import { resolveSessionKeyForRun } from "../server-session-key.js";
import { resolveRequestedSessionAgentId as resolveRequestedGlobalAgentId } from "../session-request-agent.js";
import {
@@ -28,7 +29,6 @@ import {
import { loadSessionEntry } from "../session-utils.js";
import { asWorkerInferenceControl } from "../worker-environments/inference-control.js";
import { resolveWorkerSessionTarget } from "../worker-environments/session-target.js";
import { setGatewayDedupeEntry } from "./agent-job.js";
import { handleChatAbortRequestWithLifecycle } from "./chat-abort-handler.js";
import { emitSessionsChanged } from "./session-change-event.js";
import { requireSessionKey } from "./sessions-shared.js";