Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aipoch/open-science/llms.txt
Use this file to discover all available pages before exploring further.
window.api.acp is the primary interface for controlling the AI agent runtime. It manages the agent subprocess lifecycle, session multiplexing, prompt streaming, and the permission approval flow. All state changes are broadcast to the renderer via push events; imperative calls return the latest AcpStateSnapshot once they complete.
Methods
getState()
Returns the current runtime state snapshot without triggering any side effects.
Returns: Promise<AcpStateSnapshot>
connect(request?)
Spawns the agent subprocess and establishes the ACP connection. Safe to call multiple times — subsequent calls while already connected return the current snapshot.
Optional connection parameters.
Promise<AcpStateSnapshot>
disconnect()
Tears down all active sessions and shuts down the agent subprocess.
Returns: Promise<AcpStateSnapshot>
createSession(request?)
Creates a new agent session with MCP servers injected for notebook and artifact access.
Optional session creation parameters.
Promise<AcpCreateSessionResponse>
Unique identifier for the newly created session.
Resolved working directory for the session.
resumeSession(request)
Reattaches to a previously persisted session by ID, restoring the agent’s context.
Promise<AcpCreateSessionResponse>
sendPrompt(request)
Activates an artifact run, sends the user prompt to the agent, and streams events until the agent emits a stop event. The call resolves with the final AcpStateSnapshot once the turn completes.
Promise<AcpStateSnapshot>
cancel(request)
Cancels the in-flight prompt for the given session. The agent’s current run is interrupted and the session returns to an idle state.
Promise<AcpStateSnapshot>
deleteSession(request)
Deletes the session and cancels any pending permission requests associated with it.
Promise<AcpStateSnapshot>
respondToPermission(response)
Resolves a pending permission request with a selected option or a cancellation.
Promise<AcpStateSnapshot>
Event listeners
onState(listener)
Fired after every state change. The callback receives the complete, up-to-date AcpStateSnapshot — not a diff. Suitable for driving all reactive UI that depends on connection status, session lists, or prompt-in-flight flags.
Called with the full current snapshot on every state change.
() => void — call this function to unsubscribe.
onEvent(listener)
Fired for each individual event emitted by the agent during a prompt run. Use this to update the chat transcript, activity feed, and artifact previews incrementally.
Called with each individual runtime event.
() => void — call this function to unsubscribe.
onPermissionRequest(listener)
Fired when the agent requests a new permission approval from the user. Display the options from AcpPermissionRequest.options and call respondToPermission with the result.
Called when a new permission approval is needed.
() => void — call this function to unsubscribe.
Type reference
AcpStateSnapshot
The full runtime state delivered by onState and returned by all imperative methods.
Current connection status:
'idle' | 'connecting' | 'connected' | 'error' | 'closed'Working directory of the agent subprocess.
The most recently active session ID.
All currently live session IDs.
Error message when
status is 'error'.Accumulated runtime events for the current connection lifetime.
Permission requests that have not yet been resolved.
true when any session has a prompt currently being processed.Session IDs that are actively processing a prompt.
AcpRuntimeEvent
A single event emitted by the agent during a prompt run.
Unique event identifier.
Unix epoch milliseconds.
Classifies the event. See the
AcpRuntimeEventKind table below.Severity:
'info' | 'warning' | 'error'Session that produced this event.
Message ID this event belongs to.
Role of the speaker for
message events.Text content for
message, thought, system, and error events.Display title for
tool, plan, and permission events.Lifecycle status string (e.g.,
'in_progress', 'completed').Identifier tying tool events to their originating call.
Files produced during an
artifact event.Artifact run ID for bridging runtime runs to renderer messages.
Claim ID used with
artifacts.finalizeRunArtifacts().Bash stdout/stderr when terminal output is streamed.
Exit code of a terminal command.
AcpRuntimeEventKind values
| Value | Description |
|---|---|
'system' | Internal runtime lifecycle messages |
'message' | Assistant or user message content |
'thought' | Agent reasoning / chain-of-thought text |
'tool' | Tool call lifecycle (start, result, error) |
'plan' | High-level task plan emitted before execution |
'permission' | Permission request lifecycle |
'artifact' | File produced by the agent |
'error' | Runtime or tool error |
'stop' | Signals the end of a prompt turn |
'raw' | Unprocessed protocol message |
AcpPermissionRequest
Unique ID for this permission request.
Session that raised this request.
Tool call that triggered the permission check.
Human-readable description of what is being requested.
Current status of the request (e.g.,
'pending').Available choices to present to the user. Each option has
optionId, name, and kind.