Liking cljdoc? Tell your friends :D

copilot.session

A CopilotSession maintains conversation state, handles events, and manages tool execution. Sessions are created via copilot.client/create-session! or resumed via copilot.client/resume-session!.

A CopilotSession maintains conversation state, handles events, and manages
tool execution.  Sessions are created via `copilot.client/create-session!`
or resumed via `copilot.client/resume-session!`.
raw docstring

abort!clj

(abort! session-atom)

Abort the currently processing message in this session.

Abort the currently processing message in this session.
sourceraw docstring

create-sessionclj

(create-session session-id rpc-client workspace-path)

Create a new session atom. Internal -- use copilot.client/create-session!.

Returns an atom containing the session state map.

Create a new session atom.  Internal -- use `copilot.client/create-session!`.

Returns an atom containing the session state map.
sourceraw docstring

destroy!clj

(destroy! session-atom)

Destroy this session and release resources.

After calling this, the session can no longer be used.

Destroy this session and release resources.

After calling this, the session can no longer be used.
sourceraw docstring

detach!clj

(detach! session-atom)

Detach from this session (session.detach) without deleting it. The server keeps the session state, so it can be resumed later; this client stops receiving its events and releases local resources.

Detach from this session (`session.detach`) without deleting it.  The
server keeps the session state, so it can be resumed later; this client
stops receiving its events and releases local resources.
sourceraw docstring

dispatch-event!clj

(dispatch-event! session-atom event)

Dispatch an event to all registered handlers. Internal.

Dispatch an event to all registered handlers.  Internal.
sourceraw docstring

get-managed-settings!clj

(get-managed-settings! session-atom)

Get the managed (enterprise) settings snapshot in effect (session.managedSettings.get). Use copilot.types/policy-helper-failure on the result to read a reported policy helper failure.

Get the managed (enterprise) settings snapshot in effect
(`session.managedSettings.get`).  Use `copilot.types/policy-helper-failure`
on the result to read a reported policy helper failure.
sourceraw docstring

get-messages!clj

(get-messages! session-atom)

Retrieve all events/messages from this session's history.

Retrieve all events/messages from this session's history.
sourceraw docstring

get-metadata!clj

(get-metadata! session-atom)

Retrieve metadata for this session.

Retrieve metadata for this session.
sourceraw docstring

get-tool-handlerclj

(get-tool-handler session-atom tool-name)

Get the handler function for a named tool, or nil.

Get the handler function for a named tool, or nil.
sourceraw docstring

handle-exit-plan-mode!clj

(handle-exit-plan-mode! session-atom request)

Handle an incoming exitPlanMode.request. Internal. Approves when no handler is registered.

Handle an incoming exitPlanMode.request.  Internal.  Approves when no
handler is registered.
sourceraw docstring

handle-hooks-invoke!clj

(handle-hooks-invoke! session-atom hook-type input)

Handle an incoming hooks invoke request. Internal.

Handle an incoming hooks invoke request.  Internal.
sourceraw docstring

handle-memory-store!clj

(handle-memory-store! session-atom memory)

Invoke the memory store callback. Internal.

Invoke the memory store callback.  Internal.
sourceraw docstring

handle-permission-request!clj

(handle-permission-request! session-atom request)

Handle an incoming permission request. Internal.

Handle an incoming permission request.  Internal.
sourceraw docstring

handle-shell-authentication-request!clj

(handle-shell-authentication-request! session-atom request)

Invoke the shell authentication handler and return the reply map. Internal. Cancels when no handler is registered or the handler throws.

Invoke the shell authentication handler and return the reply map.
Internal.  Cancels when no handler is registered or the handler throws.
sourceraw docstring

handle-user-input-request!clj

(handle-user-input-request! session-atom request)

Handle an incoming user input request. Internal.

Handle an incoming user input request.  Internal.
sourceraw docstring

on!clj

(on! session-atom handler)

Subscribe to all session events.

handler - (fn [event]) called for every event. Returns a zero-arg unsubscribe function.

Subscribe to all session events.

`handler` - (fn [event]) called for every event.
Returns a zero-arg unsubscribe function.
sourceraw docstring

on-type!clj

(on-type! session-atom event-type handler)

Subscribe to a specific event type.

event-type - string, e.g. "assistant.message", "session.idle" handler - (fn [event]) Returns a zero-arg unsubscribe function.

Subscribe to a specific event type.

`event-type` - string, e.g. "assistant.message", "session.idle"
`handler`    - (fn [event])
Returns a zero-arg unsubscribe function.
sourceraw docstring

recheck-policy-helper!clj

(recheck-policy-helper! session-atom)

Re-run the managed-settings policy helper (session.managedSettings.recheckPolicyHelper). Returns the raw result.

Re-run the managed-settings policy helper
(`session.managedSettings.recheckPolicyHelper`).  Returns the raw result.
sourceraw docstring

register-cleanup!clj

(register-cleanup! session-atom f)

Register a zero-arg fn run once when the session is destroyed or detached. Internal.

Register a zero-arg fn run once when the session is destroyed or
detached.  Internal.
sourceraw docstring

register-exit-plan-mode-handler!clj

(register-exit-plan-mode-handler! session-atom handler)

Register an exit plan mode handler.

handler - (fn [request invocation] -> {:approved bool ...})

Register an exit plan mode handler.

`handler` - (fn [request invocation] -> {:approved bool ...})
sourceraw docstring

register-hooks!clj

(register-hooks! session-atom hooks)

Register session hooks.

hooks - map with optional keys: :on-pre-tool-use, :on-post-tool-use, :on-pre-mcp-tool-call, :on-user-prompt-submitted, :on-user-prompt-transformed, :on-session-start, :on-session-end, :on-error-occurred, :on-subagent-start, :on-subagent-stop

Register session hooks.

`hooks` - map with optional keys:
  :on-pre-tool-use, :on-post-tool-use, :on-pre-mcp-tool-call,
  :on-user-prompt-submitted, :on-user-prompt-transformed,
  :on-session-start, :on-session-end, :on-error-occurred,
  :on-subagent-start, :on-subagent-stop
sourceraw docstring

register-memory-store!clj

(register-memory-store! session-atom store-fn)

Register the memory store callback (session option :store-memory).

store-fn - (fn [memory]) where memory is a copilot.types/stored-memory map; throw to report a failed store.

Register the memory store callback (session option :store-memory).

`store-fn` - (fn [memory]) where `memory` is a `copilot.types/stored-memory`
             map; throw to report a failed store.
sourceraw docstring

register-permission-handler!clj

(register-permission-handler! session-atom handler)

Register a permission handler.

handler - (fn [request invocation] -> permission-result-map)

Register a permission handler.

`handler` - (fn [request invocation] -> permission-result-map)
sourceraw docstring

register-session-fs-handler!clj

(register-session-fs-handler! session-atom handler)

Register a session filesystem handler.

handler - map with function-valued keys: :read-file, :write-file, :append-file, :exists?, :stat, :mkdir, :readdir, :readdir-with-types, :rm, :rename

Register a session filesystem handler.

`handler` - map with function-valued keys:
  :read-file, :write-file, :append-file, :exists?, :stat,
  :mkdir, :readdir, :readdir-with-types, :rm, :rename
sourceraw docstring

register-shell-authentication-handler!clj

(register-shell-authentication-handler! session-atom handler)

Register the shell authentication handler (session option :on-shell-authentication-request).

handler - (fn [request] -> value string to accept, or nil to cancel); request is a copilot.types/shell-authentication-request map.

Register the shell authentication handler (session option
:on-shell-authentication-request).

`handler` - (fn [request] -> value string to accept, or nil to cancel);
            `request` is a `copilot.types/shell-authentication-request` map.
sourceraw docstring

register-tools!clj

(register-tools! session-atom tools)

Register tool handlers for this session.

tools - vector of tool maps (see copilot.types/tool)

Register tool handlers for this session.

`tools` - vector of tool maps (see `copilot.types/tool`)
sourceraw docstring

register-trace-context-provider!clj

(register-trace-context-provider! session-atom provider)

Register a trace context provider. provider is a zero-arg fn returning {:traceparent s :tracestate s} (see copilot.types/trace-context); the values are attached to every send!.

Register a trace context provider.  `provider` is a zero-arg fn returning
{:traceparent s :tracestate s} (see `copilot.types/trace-context`); the
values are attached to every `send!`.
sourceraw docstring

register-user-input-handler!clj

(register-user-input-handler! session-atom handler)

Register a user input handler.

handler - (fn [request invocation] -> {:answer str :wasFreeform bool})

Register a user input handler.

`handler` - (fn [request invocation] -> {:answer str :wasFreeform bool})
sourceraw docstring

send!clj

(send! session-atom options)

Send a message to this session.

options - message options map with :prompt and optional :attachments, :mode, :response-format, :image-options, :agent-mode, :display-prompt, :request-headers, :source ("user", "system", or "agent-<id>"; see copilot.types/message-source), :response-schema (JSON Schema map for structured output; takes precedence over :response-format), :client-turn-id (opaque caller-chosen turn identifier)

Returns the message ID string.

Send a message to this session.

`options` - message options map with :prompt and optional :attachments, :mode,
            :response-format, :image-options, :agent-mode, :display-prompt,
            :request-headers, :source ("user", "system", or "agent-<id>";
            see `copilot.types/message-source`), :response-schema (JSON Schema
            map for structured output; takes precedence over :response-format),
            :client-turn-id (opaque caller-chosen turn identifier)

Returns the message ID string.
sourceraw docstring

send-and-wait!clj

(send-and-wait! session-atom options)
(send-and-wait! session-atom options timeout-ms)

Send a message and wait until the session becomes idle.

Returns the last assistant.message event, or nil if none received.

options - message options map with :prompt timeout-ms - timeout in milliseconds (default 60000)

Send a message and wait until the session becomes idle.

Returns the last assistant.message event, or nil if none received.

`options`    - message options map with :prompt
`timeout-ms` - timeout in milliseconds (default 60000)
sourceraw docstring

session-idclj

(session-id session-atom)

Get the session ID.

Get the session ID.
sourceraw docstring

set-permission-mode!clj

(set-permission-mode! session-atom mode)

Change the permission mode (session.permissions.setMode), for example "manual", "assisted", or "allow-all". Returns {:success bool :mode str :reason str}; a refused change has :success false and, when known, :reason "managed_policy" (copilot.types/permission-mode-refusals).

Change the permission mode (`session.permissions.setMode`), for example
"manual", "assisted", or "allow-all".  Returns
{:success bool :mode str :reason str}; a refused change has :success false
and, when known, :reason "managed_policy"
(`copilot.types/permission-mode-refusals`).
sourceraw docstring

switch-auto-tier!clj

(switch-auto-tier! session-atom tier)

Change the Auto routing preference without changing the selected model (session.model.switchAutoTier). tier is "fast", "efficiency", "balance", or "intelligence" (see copilot.types/auto-tiers); nil returns to the provider's default Auto routing. Returns the raw result.

Change the Auto routing preference without changing the selected model
(`session.model.switchAutoTier`).  `tier` is "fast", "efficiency",
"balance", or "intelligence" (see `copilot.types/auto-tiers`); nil
returns to the provider's default Auto routing.  Returns the raw result.
sourceraw docstring

workspace-pathclj

(workspace-path session-atom)

Get the workspace path (when infinite sessions are enabled), or nil.

Get the workspace path (when infinite sessions are enabled), or nil.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close