ACP v2 TypeScript SDK — EXPERIMENTAL DRAFT - v2.0.0
    Preparing search index...

    Class ActiveSessionExperimental

    Experimental draft ACP v2 convenience wrapper for an active session.

    An active session routes session/update notifications for one session ID into an async queue. Use prompt(...) to submit user content and nextUpdate() to observe the session independently of prompt requests. A stop message reports idle foreground work, not per-prompt completion.

    Index
    • get sessionId(): string
      Experimental

      Session ID returned by session/new.

      Returns string

    • get configOptions(): SessionConfigOption[] | undefined
      Experimental

      Configuration options returned when the session was created, if provided.

      Returns SessionConfigOption[] | undefined

    • get meta(): { [key: string]: unknown } | null | undefined
      Experimental

      Metadata returned when the session was created.

      Returns { [key: string]: unknown } | null | undefined

    • Experimental

      Sends a prompt to this session.

      Strings are converted to one text content block. A single content block is wrapped in an array. The returned promise resolves with the inserted user message's ID once the agent inserts it into the ACP conversation, not when processing finishes. Session updates remain independent of this request; an idle state_update does not establish that this message was processed. Rejection is reported only by this promise, not by the session update queue.

      Parameters

      Returns Promise<PromptResponse>

    • Experimental

      Reads the next update or stop message for this session.

      Idle updates are always returned as stop messages, whether or not a prompt is pending. Queued updates are consumed in arrival order. An abort signal cancels this read without cancelling session work or discarding updates.

      Parameters

      • Optionalsignal: AbortSignal

      Returns Promise<ActiveSessionMessage>

    • Experimental

      Collects agent text from the session queue until the next idle update.

      This consumes the same queue as nextUpdate(), including already queued updates. It does not associate output or idle with any submitted prompt, skip updates when a prompt is sent, or wait for a prompt to be inserted. Use one reader at a time to avoid splitting the session's updates. An abort signal cancels the read without cancelling session work.

      Full agent_message updates replace content for their messageId, while agent_message_chunk updates append to it. Non-text content and other update types are ignored; use nextUpdate() when you need them.

      Parameters

      • Optionalsignal: AbortSignal

      Returns Promise<string>

    • Experimental

      Stops routing updates to this active-session helper.

      This does not close the ACP session on the agent. Use ClientContext session lifecycle methods when the protocol session itself should be closed or deleted.

      Returns void

    • Experimental

      Supports explicit resource management with using.

      Returns void