import type { SessionAuth } from "#context/session-context.js"; import type { AgentSessionContext } from "#execution/agent-sessions/context.js"; import type { JsonObject } from "#shared/json.js"; /** Where a session a run opened lives, for its later sends, cancels, and end. */ export type AgentSessionAddress = { readonly kind: "local"; readonly name: string; readonly nodeId: string; readonly sessionId: string; } | { readonly callbackBaseUrl: string; readonly kind: "remote"; readonly forwardPrincipal?: boolean; readonly name: string; readonly nodeId: string; /** Keys the authored credential functions, as on `agent.started`. */ readonly resolverId?: string; readonly sessionId: string; readonly url: string; }; /** A session a run opened, with the context of the call that opened it: its lineage. */ export interface OpenedAgentSession { readonly address: AgentSessionAddress; readonly context: AgentSessionContext; /** Names the session within its run, as when it opened. */ readonly key: string; } /** * One message to a session, as the call that sends it: the session runs the * message with that call's auth. Its turn's result and questions arrive on * `replyTo`. */ export interface AgentSessionMessage { readonly auth: SessionAuth; readonly message: string; readonly outputSchema?: JsonObject; readonly replyTo: string; } /** * Opens a run's session with its first message, as a child of the call whose * `context` it binds. `key` names the handle within the run, so a retried step * reaches the same session instead of a second one. */ export declare function openAgentSessionStep(input: AgentSessionMessage & { readonly context: AgentSessionContext; readonly key: string; readonly name: string; }): Promise; /** * Sends a later message; it joins the session's running turn or starts the * next. It keeps the session's lineage and carries its own auth. */ export declare function sendAgentSessionMessageStep(input: AgentSessionMessage & OpenedAgentSession): Promise; /** Cancels a session's running turn; the turn still reports, as cancelled. */ export declare function cancelAgentSessionTurnStep(input: OpenedAgentSession): Promise; /** Ends a run's sessions when the run finishes, cancelling any turn still running. */ export declare function endAgentSessionsStep(input: { readonly sessions: readonly OpenedAgentSession[]; }): Promise;