Liking cljdoc? Tell your friends :D

copilot.client

Main client for interacting with the Copilot CLI.

The CopilotClient manages the connection to the Copilot CLI server and provides methods to create and manage conversation sessions. It can either spawn a CLI server process or connect to an existing server.

Main client for interacting with the Copilot CLI.

The CopilotClient manages the connection to the Copilot CLI server and
provides methods to create and manage conversation sessions.  It can
either spawn a CLI server process or connect to an existing server.
raw docstring

apply-mode-defaultsclj

(apply-mode-defaults params mode)

Apply the client mode defaults to a grouped payload. Internal; exposed for testing. In the :empty mode the empty-mode defaults are filled in where the caller left a member unset; :coding-agent leaves the payload unchanged.

Apply the client mode defaults to a grouped payload.  Internal; exposed for
testing.  In the :empty mode the empty-mode defaults are filled in where the
caller left a member unset; :coding-agent leaves the payload unchanged.
sourceraw docstring

clear-managed-settings-cache!clj

(clear-managed-settings-cache! client-atom)

Clear the runtime's cached managed (enterprise) settings (managedSettings.clearCache) so they are fetched again.

Clear the runtime's cached managed (enterprise) settings
(`managedSettings.clearCache`) so they are fetched again.
sourceraw docstring

create-clientclj

(create-client & {:as opts})

Create a new CopilotClient.

Returns a client map (atom-backed) that manages the CLI process, JSON-RPC connection, and sessions.

Options (all optional): :cli-path, :cli-args, :cwd, :port, :use-stdio, :cli-url, :log-level, :auto-start, :auto-restart, :env, :github-token, :use-logged-in-user, :client-info, :mode, :network

See copilot.types/client-options for full documentation.

Create a new CopilotClient.

Returns a client map (atom-backed) that manages the CLI process, JSON-RPC
connection, and sessions.

Options (all optional):
  :cli-path, :cli-args, :cwd, :port, :use-stdio, :cli-url,
  :log-level, :auto-start, :auto-restart, :env,
  :github-token, :use-logged-in-user, :client-info, :mode, :network

See `copilot.types/client-options` for full documentation.
sourceraw docstring

create-session!clj

(create-session! client-atom & {:as config})

Create a new conversation session with the Copilot CLI.

config - session configuration map (see copilot.types/session-config)

Returns a session atom that can be used with copilot.session functions.

Create a new conversation session with the Copilot CLI.

`config` - session configuration map (see `copilot.types/session-config`)

Returns a session atom that can be used with `copilot.session` functions.
sourceraw docstring

delete-session!clj

(delete-session! client-atom session-id)

Delete a session and its data from disk.

Delete a session and its data from disk.
sourceraw docstring

force-stop!clj

(force-stop! client-atom)

Forcefully stop the CLI server without graceful cleanup.

Forcefully stop the CLI server without graceful cleanup.
sourceraw docstring

get-auth-status!clj

(get-auth-status! client-atom)

Get current authentication status.

Get current authentication status.
sourceraw docstring

get-foreground-session-id!clj

(get-foreground-session-id! client-atom)

Get the foreground session ID (TUI+server mode only).

Get the foreground session ID (TUI+server mode only).
sourceraw docstring

get-last-session-id!clj

(get-last-session-id! client-atom)

Get the ID of the most recently updated session.

Get the ID of the most recently updated session.
sourceraw docstring

get-modeclj

(get-mode client-atom)

Get the client mode: "coding-agent" or "empty".

Get the client mode: "coding-agent" or "empty".
sourceraw docstring

get-session-metadata!clj

(get-session-metadata! client-atom session-id)

Get metadata for a session by ID.

Returns the metadata map, or nil if the session is not found.

Get metadata for a session by ID.

Returns the metadata map, or nil if the session is not found.
sourceraw docstring

get-stateclj

(get-state client-atom)

Get the current connection state: :disconnected :connecting :connected :error

Get the current connection state: :disconnected :connecting :connected :error
sourceraw docstring

get-status!clj

(get-status! client-atom)

Get CLI status including version and protocol information.

Get CLI status including version and protocol information.
sourceraw docstring

group-session-paramsclj

(group-session-params flat resume?)

Convert the flat session payload built by this SDK into the SDK protocol 4 grouped payload sent with session.create (resume? false) and session.resume (resume? true). Internal; exposed for testing.

Protocol 4 runtimes reject the old flat keys and unknown group members but tolerate unknown root keys. Known flat keys move to their exact group.member (for example :streaming to events.streaming and :hooks true to hooks.hasHandlers); root keys and unrecognized keys stay at the top level; nil values are skipped (except an explicit :defaultProvider nil on resume, which clears the default); members invalid for the method are dropped (filesystem.trustWorkingDirectory and instructions.refreshCustomInstructions on resume, canvases.open on create); and empty groups are not emitted. Already-grouped maps are merged and their members win. The legacy single :provider becomes the named "default" connection.

Convert the flat session payload built by this SDK into the SDK protocol 4
grouped payload sent with session.create (`resume?` false) and
session.resume (`resume?` true).  Internal; exposed for testing.

Protocol 4 runtimes reject the old flat keys and unknown group members but
tolerate unknown root keys.  Known flat keys move to their exact
group.member (for example :streaming to events.streaming and :hooks true to
hooks.hasHandlers); root keys and unrecognized keys stay at the top level;
nil values are skipped (except an explicit :defaultProvider nil on resume,
which clears the default); members invalid for the method are dropped
(filesystem.trustWorkingDirectory and instructions.refreshCustomInstructions
on resume, canvases.open on create); and empty groups are not emitted.
Already-grouped maps are merged and their members win.  The legacy single
:provider becomes the named "default" connection.
sourceraw docstring

list-models!clj

(list-models! client-atom)

List available models. Results are cached after the first call.

Returns a vector of model-info maps.

List available models. Results are cached after the first call.

Returns a vector of model-info maps.
sourceraw docstring

list-sessions!clj

(list-sessions! client-atom)

List all available sessions.

Returns a vector of session-metadata maps.

List all available sessions.

Returns a vector of session-metadata maps.
sourceraw docstring

on-lifecycle!clj

(on-lifecycle! client-atom handler)

Subscribe to session lifecycle events.

handler - (fn [event]) where event is a session-lifecycle-event map. Returns a zero-arg function that unsubscribes the handler.

Subscribe to session lifecycle events.

`handler` - (fn [event]) where event is a session-lifecycle-event map.
Returns a zero-arg function that unsubscribes the handler.
sourceraw docstring

on-lifecycle-type!clj

(on-lifecycle-type! client-atom event-type handler)

Subscribe to a specific session lifecycle event type.

event-type - string like "session.created", "session.deleted", etc. handler - (fn [event]) Returns an unsubscribe function.

Subscribe to a specific session lifecycle event type.

`event-type` - string like "session.created", "session.deleted", etc.
`handler`    - (fn [event])
Returns an unsubscribe function.
sourceraw docstring

ping!clj

(ping! client-atom & {:keys [message]})

Send a ping request to the server.

Returns {:message ... :timestamp ... :protocol-version ...}

Send a ping request to the server.

Returns {:message ... :timestamp ... :protocol-version ...}
sourceraw docstring

resume-session!clj

(resume-session! client-atom session-id & {:as config})

Resume an existing conversation session.

session-id - the ID of the session to resume config - optional resume configuration map

Returns a session atom.

Resume an existing conversation session.

`session-id` - the ID of the session to resume
`config`     - optional resume configuration map

Returns a session atom.
sourceraw docstring

set-foreground-session-id!clj

(set-foreground-session-id! client-atom session-id)

Set the foreground session (TUI+server mode only).

Set the foreground session (TUI+server mode only).
sourceraw docstring

start!clj

(start! client-atom)

Start the CLI server and establish a connection.

If the client was created with :cli-url, only establishes the connection. Otherwise spawns the CLI server process and connects via stdio or TCP.

This is called automatically when creating a session if :auto-start is true (the default).

Start the CLI server and establish a connection.

If the client was created with :cli-url, only establishes the connection.
Otherwise spawns the CLI server process and connects via stdio or TCP.

This is called automatically when creating a session if :auto-start is
true (the default).
sourceraw docstring

stop!clj

(stop! client-atom)

Stop the CLI server and close all active sessions.

Returns a vector of error messages encountered during cleanup.

Stop the CLI server and close all active sessions.

Returns a vector of error messages encountered during cleanup.
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