Download src/gateway/server-methods/agent-wait.ts from SaylorTwift/openclaw: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/gateway/server-methods/agent-wait.ts
- Command line
-
hf download hf://SaylorTwift/openclaw/src/gateway/server-methods/agent-wait.ts
-
curl -L -o agent-wait.ts https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/gateway/server-methods/agent-wait.ts
1.78 kB
| import { | |
| ErrorCodes, | |
| errorShape, | |
| validateAgentWaitParams, | |
| type AgentWaitParams, | |
| } from "../../../packages/gateway-protocol/src/index.js"; | |
| import { getAgentRunContext } from "../../infra/agent-run-registry.js"; | |
| import { createAgentTurnService } from "../agent-turn/agent-turn-service.js"; | |
| import { operatorSessionCap } from "../operator-role-policy.js"; | |
| import { | |
| createSessionListEntryFilter, | |
| isGatewayAdmin, | |
| resolveSessionSharingTarget, | |
| } from "../session-sharing.js"; | |
| import type { GatewayRequestHandlers } from "./types.js"; | |
| import { assertValidParams } from "./validation.js"; | |
| export const agentWaitHandler: GatewayRequestHandlers["agent.wait"] = async ({ | |
| params, | |
| respond, | |
| context, | |
| client, | |
| isWebchatConnect, | |
| }) => { | |
| if (!assertValidParams(params, validateAgentWaitParams, "agent.wait", respond)) { | |
| return; | |
| } | |
| const gatewayClient = client ?? null; | |
| if (gatewayClient?.authenticatedUserProfile && !isGatewayAdmin(gatewayClient)) { | |
| const cfg = context.getRuntimeConfig(); | |
| if (operatorSessionCap(gatewayClient, cfg) === "none") { | |
| const run = getAgentRunContext(params.runId); | |
| const target = run?.sessionKey | |
| ? resolveSessionSharingTarget({ cfg, sessionKey: run.sessionKey, agentId: run.agentId }) | |
| : null; | |
| const visibilityFilter = createSessionListEntryFilter({ client: gatewayClient, cfg }); | |
| if (!target || visibilityFilter?.(target.storeKey, target.entry) === false) { | |
| respond( | |
| false, | |
| undefined, | |
| errorShape(ErrorCodes.INVALID_REQUEST, "agent run was not found"), | |
| ); | |
| return; | |
| } | |
| } | |
| } | |
| const result = await createAgentTurnService({ context, isWebchatConnect }).waitForTurn( | |
| params as AgentWaitParams, | |
| ); | |
| respond(true, result); | |
| }; | |