import type { AgentSummary, AsyncTaskRecord, CreateAgentResult, DeleteAgentResult, PromptAcceptanceStatus, SendPromptInput, SendPromptResult, SubagentRecord } from "../types.js"; import type { CreateAgentInput, CreateGroupInput } from "./commands.js"; /** Default poll gap for waitForIdle. Not a host field. */ export declare const DEFAULT_WAIT_FOR_IDLE_INTERVAL_MS = 250; /** Default wall-clock budget for runOnce / runOnceFrom / runOnceLike. */ export declare const DEFAULT_RUN_ONCE_TIMEOUT_MS = 120000; export type OneShotStatus = "idle" | "awaiting-user" | "timeout" | "error"; export type WaitForIdleInput = { id: string; timeoutMs?: number; clientNonce?: string; /** Poll gap. Default 250ms. Not a host field. */ intervalMs?: number; /** When true, timeout throws instead of returning `status: "timeout"`. */ throwOnTimeout?: boolean; signal?: AbortSignal; }; export type WaitForIdleResult = { id: string; status: OneShotStatus; elapsedMs: number; isRunning: boolean; isComposingMessage: boolean; awaitingUserResponse: unknown; asyncTaskCount: number; runningSubagentCount: number; acceptance?: PromptAcceptanceStatus; }; /** * Redacted one-shot receipt. Default includes `reply` (last assistant / * send-message text from getAgentTranscriptTail, falling back to * getAgentTranscript). That is not roster `lastMessagePreview`. No token/usage * fields. Wall-clock is client-side Date.now() only. Pass includeReply: false * (or includeTranscript: false) for metadata-only. */ export type OneShotReceipt = { id: string; accepted: boolean; status: OneShotStatus; elapsedMs: number; deleted: boolean; sourceId?: string; cloneId?: string; /** * `host-clone` is duplicateAgent → manager.cloneAgent (store.db + automations). * `profile-only` is createAgent with copied roster name/description/title/purpose. */ inheritance?: "host-clone" | "profile-only"; /** Last assistant / send-message text. Omitted when includeReply is false. */ reply?: string; error?: string; }; export type RunOnceInput = { prompt: string; /** * Agent display name. When omitted or blank, a unique throwaway name is * minted so host createAgent does not `name.trim()` on undefined. */ name?: string; purpose?: string; /** * Always sent as a string (`""` when omitted). Host mintAgent does not * default description; materializeSession then does `description.trim()`. */ description?: string; title?: string; timeoutMs?: number; intervalMs?: number; keepOnFailure?: boolean; /** * Default true. When false, skip the host tail read and omit `reply`. */ includeReply?: boolean; /** Alias for includeReply. false also opts out. */ includeTranscript?: boolean; signal?: AbortSignal; }; export type RunOnceFromInput = { id: string; prompt: string; timeoutMs?: number; intervalMs?: number; keepOnFailure?: boolean; includeReply?: boolean; includeTranscript?: boolean; signal?: AbortSignal; }; /** * SDK sendPrompt extras. Not host fields — stripped before POST /api/sendPrompt. * Host sendPrompt still returns only `{ accepted: true }`. */ export type SendPromptCallInput = SendPromptInput & { wait?: boolean; timeoutMs?: number; intervalMs?: number; includeReply?: boolean; includeTranscript?: boolean; signal?: AbortSignal; }; /** Returned only when the SDK caller passed `wait: true`. */ export type SendPromptWaitResult = { accepted: boolean; status: OneShotStatus; elapsedMs: number; reply?: string; }; /** Drop SDK-only keys so they never reach the host sendPrompt body. */ export declare function toHostSendPromptBody(body: SendPromptCallInput): SendPromptInput; export type OneShotClient = { resolveAgent(idOrName: string): Promise; listAgents(): Promise; getAsyncTasks(body: { id: string; }): Promise; getSubagents(body: { id: string; }): Promise; promptAcceptanceStatus(body: { accountSlot: string; clientNonce: string; }): Promise; createAgent(body?: CreateAgentInput): Promise; createGroup(body: CreateGroupInput): Promise; sendPrompt(body: { prompt: string; agentId: string; clientNonce?: string; }): Promise; deleteAgent(body: { id: string; }): Promise; duplicateAgent(body: { id: string; }): Promise; getAgentTranscriptTail?(body: { id: string; limit?: number; }): Promise; getAgentTranscript?(body: { id: string; }): Promise; }; export type DiscussTurn = { speaker: string; agentId?: string; kind: string; text: string; timestampMs?: number; }; /** Prefix for minted discussOnce group names when the caller omits `name`. */ export declare const DISCUSS_ONCE_DEFAULT_NAME_PREFIX = "throwaway-discussion-"; /** Prefix for minted createAgent / runOnce names when the caller omits `name`. */ export declare const CREATE_AGENT_DEFAULT_NAME_PREFIX = "throwaway-"; /** * Host createGroup always forwards `{ name: args.name }` into createAgent. * materializeSession then does `profile?.name.trim()` and throws when name * is omitted. Blank / whitespace-only names are treated as omitted. */ export declare function resolveDiscussOnceName(name?: string): string; /** * Host createHostGatewayApi mintAgent forwards * `{ name: args.name, description: args.description }` with no `?? ""`. * materializeSession then does `profile?.name.trim()` and * `profile?.description.trim()` — optional only on `profile`. Omitted name * or description throws. Blank / whitespace-only names are treated as omitted. */ export declare function resolveCreateAgentName(name?: string): string; /** * Always a string. Host mintAgent does not default omitted description; * materializeSession then calls `profile?.description.trim()`. */ export declare function resolveCreateAgentDescription(description?: string): string; /** * Body the SDK POSTs to host createAgent. Always includes a non-empty name * and a string description so materializeSession never trims undefined. */ export declare function toHostCreateAgentBody(body?: CreateAgentInput): CreateAgentInput; export type DiscussOnceInput = { /** Roster name or id. Groups are rejected. Capped at GROUP_MAX_MEMBERS (6). */ agents: string[]; prompt: string; /** * Group display name. When omitted or blank, a unique throwaway name is * minted so host createGroup does not `name.trim()` on undefined. */ name?: string; description?: string; timeoutMs?: number; intervalMs?: number; keepOnFailure?: boolean; /** * Default true. When false, skip the host transcript read and omit * `reply` / `turns` / `transcript`. */ includeReply?: boolean; /** Alias for includeReply. false also opts out. */ includeTranscript?: boolean; signal?: AbortSignal; }; /** * Throwaway group-discussion receipt. `turns` / `transcript` are the full * room (every member line), not `sendPrompt({ wait: true }).reply`. * On awaiting-user the room is kept so a widget can be answered. */ export type DiscussOnceReceipt = { id: string; groupId: string; cloneIds: string[]; sourceIds: string[]; accepted: boolean; status: OneShotStatus; elapsedMs: number; deleted: boolean; /** Last substantive send-message / assistant line. */ reply?: string; /** Ordered room turns (user prompt + every member line). */ turns?: DiscussTurn[]; /** Same parsed record as `turns`. */ transcript?: DiscussTurn[]; error?: string; }; export declare function waitForIdle(bot: OneShotClient, input: WaitForIdleInput): Promise; /** * Host getAgentTranscriptTail / getAgentTranscriptWindow return * `{ entries, nextBeforeSeq? }`. getAgentTranscript returns the entries array. */ export declare function entriesFromTranscriptPayload(value: unknown): unknown[]; /** * Last assistant / send-message text from host parseTranscriptEntry rows. * Walks unknown[] defensively; skips user, tool-call, widget, and junk. */ export declare function lastAssistantTextFromEntries(entries: unknown[]): string | undefined; /** * Ordered discussion turns from host parseTranscriptEntry rows. * Group rooms persist member lines as send-message + author (GroupChatGlue * postGroupMemberMessage / readGroupHistory). Peer rows use fromAgent / toAgent. * Walks unknown[] defensively; skips tools, widgets, notices, streaming previews. */ export declare function turnsFromTranscriptEntries(entries: unknown[]): DiscussTurn[]; /** * After a host sendPrompt accept: poll waitForIdle, then read the tail reply. * Not a host wait field. awaiting-user is a status, not a finished reply. */ export declare function completeSendPromptWait(bot: OneShotClient, input: { agentId: string; accepted: boolean; clientNonce?: string; timeoutMs?: number; intervalMs?: number; includeReply?: boolean; includeTranscript?: boolean; signal?: AbortSignal; startedAt?: number; }): Promise; export declare function runOnce(bot: OneShotClient, input: RunOnceInput): Promise; /** * Host-native throwaway: duplicateAgent → manager.cloneAgent, then send/wait/delete * the clone. This is a full clone (store.db + automations + profile/settings/avatar * / workflow enablement). Groups are rejected. memory/ files are not copied — * cloneAgentDir never touches getAgentMemoryDir, and rewriteClonedAgentIdentity * is called with includesChatHistory=false (conversation cleared). */ export declare function runOnceFrom(bot: OneShotClient, input: RunOnceFromInput): Promise; /** * Profile-only throwaway: createAgent with name/description/title/purpose copied * from listAgents. Not a host clone — does not copy store.db, automations, * avatar, settings, or memory/. */ export declare function runOnceLike(bot: OneShotClient, input: RunOnceFromInput): Promise; /** Receipt JSON. Includes `reply` when present. Never tokens or lastMessagePreview. */ export declare function formatOneShotReceipt(receipt: OneShotReceipt): string; /** * Throwaway group discussion: duplicate each source (never the live agents), * createGroup with the clone ids, sendPrompt to the group (orchestrator), * wait until the group and every clone are idle, snapshot the full room * transcript, then delete group then clones. * * Host createGroup reuses a room with the same member set — that is an error * here (clones should make the set unique). Groups cannot be members or * duplicated. Does not broadcast or message anyone outside the room. * * awaiting-user: snapshot, keep the room so a widget can be answered. * idle / timeout / error: snapshot, then delete unless keepOnFailure. * Omitting `name` mints a unique throwaway name — host createGroup crashes * on undefined `name.trim()`. */ export declare function discussOnce(bot: OneShotClient, input: DiscussOnceInput): Promise; /** Alias for discussOnce. */ export declare const runOnceDiscuss: typeof discussOnce; /** Human turn list: `speaker: text` per line. */ export declare function formatDiscussTurns(turns: DiscussTurn[]): string; /** Receipt JSON plus the full turn list. Never tokens or lastMessagePreview. */ export declare function formatDiscussReceipt(receipt: DiscussOnceReceipt): string; /** Prefix for minted sendAsAgent bus names when the caller omits `name`. */ export declare const SEND_AS_AGENT_DEFAULT_NAME_PREFIX = "bus-"; /** * Host createAgent mintAgent forwards `{ name: args.name }` with no default. * materializeSession then does `profile?.name.trim()` and throws when name * is omitted. Blank / whitespace-only names are treated as omitted. */ export declare function resolveSendAsAgentName(name?: string): string; /** * Tight bus prompt: one SendToAgent to the resolved target id, then stop. * Not a host command — the seat calls the SendToAgent tool during its turn. */ export declare function sendAsAgentPrompt(targetId: string, message: string): string; export type SendAsAgentInput = { /** Roster name or id of the recipient. Never `"all"`. */ to: string; /** Text the bus passes to SendToAgent. */ message: string; /** * Existing bus seat (name or id). When set, that seat is prompted and * not deleted. Alias of `from`. */ bus?: string; /** Existing bus seat (name or id). Alias of `bus`. */ from?: string; /** * When true, keep a minted throwaway bus after the send. Ignored in * reuse mode (an existing bus is never deleted). */ keepBus?: boolean; /** Bus display name. When omitted or blank, a unique `bus-` is minted. */ name?: string; /** * Always sent as a string (`""` when omitted). Host mintAgent does not * default description; materializeSession then does `description.trim()`. */ description?: string; timeoutMs?: number; intervalMs?: number; /** * Default true. When false, skip the host tail read and omit `reply`. */ includeReply?: boolean; /** Alias for includeReply. false also opts out. */ includeTranscript?: boolean; signal?: AbortSignal; }; /** * Bus-seat receipt. `reply` is the last assistant / send-message text from * the bus transcript, not the recipient's reply and not roster * lastMessagePreview. No token/usage fields. No waitForCompletion. */ export type SendAsAgentReceipt = { id: string; busId: string; targetId: string; accepted: boolean; status: OneShotStatus; elapsedMs: number; deleted: boolean; /** Last assistant / send-message text from the bus seat. */ reply?: string; error?: string; }; /** * SDK-only peer send: mint or reuse a bus seat, sendPrompt that seat to call * the SendToAgent tool once, wait until the bus is idle, then delete the * throwaway unless keepBus / reuse. There is no host sendToAgent command — * POST /api/sendToAgent is unknown. Host agentToAgent.sendToAgent is only * reachable as the SendToAgent tool during a seat's turn. Survives Computer * Update because it uses existing host commands only (createAgent, sendPrompt, * waitForIdle, deleteAgent, listAgents). Never broadcastToAgents. */ export declare function sendAsAgent(bot: OneShotClient, input: SendAsAgentInput): Promise; /** Alias for sendAsAgent. */ export declare const runOnceSendToAgent: typeof sendAsAgent; /** Receipt JSON. Includes `reply` when present. Never tokens or lastMessagePreview. */ export declare function formatSendAsAgentReceipt(receipt: SendAsAgentReceipt): string; //# sourceMappingURL=oneshot.d.ts.map