Codex.AppServer (Codex SDK v0.14.0)

Copy Markdown View Source

App-server transport for stateful, bidirectional communication with Codex.

Summary

Types

Options for launching and initializing a managed codex app-server child process.

Functions

Lists available apps/connectors.

Lists collaboration mode presets (experimental).

Writes bytes to a running command/exec session.

Backwards-compatible alias for command_exec_write/3 using raw stdin text.

Reads config requirements enforced by the server (if any).

Starts a supervised codex app-server subprocess and completes the initialize handshake.

Copies a file or directory via the app-server filesystem API.

Creates a directory via the app-server filesystem API.

Fetches file or directory metadata via the app-server filesystem API.

Lists directory entries via the app-server filesystem API.

Reads a file via the app-server filesystem API, returning a base64 payload.

Removes a file or directory via the app-server filesystem API.

Writes base64-encoded file contents via the app-server filesystem API.

Reads plugin details from a marketplace entry via the app-server plugin API.

Writes a skills config entry enabling or disabling a skill by path.

Starts server-side context compaction for a thread.

Types

connect_opts()

@type connect_opts() :: [
  init_timeout_ms: pos_integer(),
  client_name: String.t(),
  client_title: String.t(),
  client_version: String.t(),
  experimental_api: boolean(),
  cwd: String.t(),
  process_env: map() | keyword(),
  env: map() | keyword(),
  oauth: keyword()
]

Options for launching and initializing a managed codex app-server child process.

cwd and process_env / env apply to the child process itself. Per-thread working directories still belong on thread/start, thread/resume, or Codex.Thread.Options.

connection()

@type connection() :: pid()

Functions

alive?(conn)

@spec alive?(connection()) :: boolean()

apps_list(conn, opts \\ [])

@spec apps_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Lists available apps/connectors.

collaboration_mode_list(conn)

@spec collaboration_mode_list(connection()) :: {:ok, map()} | {:error, term()}

Lists collaboration mode presets (experimental).

command_exec(conn, command, opts \\ [])

@spec command_exec(connection(), [String.t()], keyword()) ::
  {:ok, map()} | {:error, term()}

command_exec_resize(conn, process_id, size)

@spec command_exec_resize(connection(), String.t(), map() | keyword()) ::
  {:ok, map()} | {:error, term()}

command_exec_terminate(conn, process_id)

@spec command_exec_terminate(connection(), String.t()) ::
  {:ok, map()} | {:error, term()}

command_exec_write(conn, process_id, opts \\ [])

@spec command_exec_write(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Writes bytes to a running command/exec session.

command_write_stdin(conn, process_id, stdin, opts \\ [])

@spec command_write_stdin(connection(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Backwards-compatible alias for command_exec_write/3 using raw stdin text.

config_batch_write(conn, edits, opts \\ [])

@spec config_batch_write(connection(), [map()], keyword()) ::
  {:ok, map()} | {:error, term()}

config_read(conn, opts \\ [])

@spec config_read(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

config_requirements(conn)

@spec config_requirements(connection()) :: {:ok, map()} | {:error, term()}

Reads config requirements enforced by the server (if any).

config_write(conn, key_path, value, opts \\ [])

@spec config_write(connection(), String.t(), term(), keyword()) ::
  {:ok, map()} | {:error, term()}

connect(codex_opts, opts \\ [])

@spec connect(Codex.Options.t(), connect_opts()) ::
  {:ok, connection()} | {:error, term()}

Starts a supervised codex app-server subprocess and completes the initialize handshake.

Use cwd and process_env (or the env alias) when the app-server child must run with an isolated working directory or CODEX_HOME without mutating the caller's shell environment.

disconnect(conn)

@spec disconnect(connection()) :: :ok

experimental_feature_list(conn, opts \\ [])

@spec experimental_feature_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

external_agent_config_detect(conn, opts \\ [])

@spec external_agent_config_detect(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

external_agent_config_import(conn, migration_items)

@spec external_agent_config_import(connection(), [map()]) ::
  {:ok, map()} | {:error, term()}

feedback_upload(conn, opts)

@spec feedback_upload(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

fs_copy(conn, source_path, destination_path, opts \\ [])

@spec fs_copy(connection(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Copies a file or directory via the app-server filesystem API.

fs_create_directory(conn, path, opts \\ [])

@spec fs_create_directory(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Creates a directory via the app-server filesystem API.

fs_get_metadata(conn, path)

@spec fs_get_metadata(connection(), String.t()) :: {:ok, map()} | {:error, term()}

Fetches file or directory metadata via the app-server filesystem API.

fs_read_directory(conn, path)

@spec fs_read_directory(connection(), String.t()) :: {:ok, map()} | {:error, term()}

Lists directory entries via the app-server filesystem API.

fs_read_file(conn, path)

@spec fs_read_file(connection(), String.t()) :: {:ok, map()} | {:error, term()}

Reads a file via the app-server filesystem API, returning a base64 payload.

fs_remove(conn, path, opts \\ [])

@spec fs_remove(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Removes a file or directory via the app-server filesystem API.

fs_write_file(conn, path, data_base64)

@spec fs_write_file(connection(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}

Writes base64-encoded file contents via the app-server filesystem API.

fuzzy_file_search(conn, query, opts \\ [])

@spec fuzzy_file_search(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

fuzzy_file_search_session_start(conn, session_id, roots)

@spec fuzzy_file_search_session_start(connection(), String.t(), [String.t()]) ::
  {:ok, map()} | {:error, term()}

fuzzy_file_search_session_stop(conn, session_id)

@spec fuzzy_file_search_session_stop(connection(), String.t()) ::
  {:ok, map()} | {:error, term()}

fuzzy_file_search_session_update(conn, session_id, query)

@spec fuzzy_file_search_session_update(connection(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}

model_list(conn, opts \\ [])

@spec model_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

plugin_install(conn, marketplace_path, plugin_name)

@spec plugin_install(connection(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}

plugin_list(conn, opts \\ [])

@spec plugin_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

plugin_read(conn, marketplace_path, plugin_name)

@spec plugin_read(connection(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}

Reads plugin details from a marketplace entry via the app-server plugin API.

plugin_uninstall(conn, plugin_id)

@spec plugin_uninstall(connection(), String.t()) :: {:ok, map()} | {:error, term()}

respond(conn, id, result)

@spec respond(connection(), String.t() | integer(), map()) :: :ok | {:error, term()}

review_start(conn, thread_id, target, opts \\ [])

@spec review_start(connection(), String.t(), term(), keyword()) ::
  {:ok, map()} | {:error, term()}

skills_config_write(conn, path, enabled)

@spec skills_config_write(connection(), String.t(), boolean()) ::
  {:ok, map()} | {:error, term()}

Writes a skills config entry enabling or disabling a skill by path.

skills_list(conn, opts \\ [])

@spec skills_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

skills_remote_export(conn, hazelnut_id)

@spec skills_remote_export(connection(), String.t()) ::
  {:ok, map()} | {:error, term()}

skills_remote_list(conn, opts \\ [])

@spec skills_remote_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

subscribe(conn, opts \\ [])

@spec subscribe(
  connection(),
  keyword()
) :: :ok | {:error, term()}

thread_archive(conn, thread_id)

@spec thread_archive(connection(), String.t()) :: :ok | {:error, term()}

thread_compact(conn, thread_id)

@spec thread_compact(connection(), String.t()) :: {:ok, map()} | {:error, term()}

Starts server-side context compaction for a thread.

thread_compact_start(conn, thread_id)

@spec thread_compact_start(connection(), String.t()) ::
  {:ok, map()} | {:error, term()}

Explicit alias for thread_compact/2.

thread_fork(conn, thread_id, params \\ %{})

@spec thread_fork(connection(), String.t(), map() | keyword()) ::
  {:ok, map()} | {:error, term()}

thread_list(conn, opts \\ [])

@spec thread_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

thread_loaded_list(conn, opts \\ [])

@spec thread_loaded_list(
  connection(),
  keyword()
) :: {:ok, map()} | {:error, term()}

thread_metadata_update(conn, thread_id, params)

@spec thread_metadata_update(connection(), String.t(), map() | keyword()) ::
  {:ok, map()} | {:error, term()}

thread_name_set(conn, thread_id, name)

@spec thread_name_set(connection(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}

thread_read(conn, thread_id, opts \\ [])

@spec thread_read(connection(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

thread_realtime_append_audio(conn, thread_id, audio)

@spec thread_realtime_append_audio(connection(), String.t(), map() | keyword()) ::
  {:ok, map()} | {:error, term()}

thread_realtime_append_text(conn, thread_id, text)

@spec thread_realtime_append_text(connection(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}

thread_realtime_start(conn, thread_id, prompt, opts \\ [])

@spec thread_realtime_start(connection(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

thread_realtime_stop(conn, thread_id)

@spec thread_realtime_stop(connection(), String.t()) ::
  {:ok, map()} | {:error, term()}

thread_resume(conn, thread_id, params \\ %{})

@spec thread_resume(connection(), String.t(), map() | keyword()) ::
  {:ok, map()} | {:error, term()}

thread_rollback(conn, thread_id, num_turns)

@spec thread_rollback(connection(), String.t(), pos_integer()) ::
  {:ok, map()} | {:error, term()}

thread_start(conn, params \\ %{})

@spec thread_start(connection(), map() | keyword()) :: {:ok, map()} | {:error, term()}

thread_unarchive(conn, thread_id)

@spec thread_unarchive(connection(), String.t()) :: {:ok, map()} | {:error, term()}

thread_unsubscribe(conn, thread_id)

@spec thread_unsubscribe(connection(), String.t()) :: {:ok, map()} | {:error, term()}

turn_interrupt(conn, thread_id, turn_id)

@spec turn_interrupt(connection(), String.t(), String.t()) :: :ok | {:error, term()}

turn_start(conn, thread_id, input, opts \\ [])

@spec turn_start(connection(), String.t(), String.t() | [map()], keyword()) ::
  {:ok, map()} | {:error, term()}

turn_steer(conn, thread_id, input, opts \\ [])

@spec turn_steer(connection(), String.t(), String.t() | [map()], keyword()) ::
  {:ok, map()} | {:error, term()}

unsubscribe(conn)

@spec unsubscribe(connection()) :: :ok

windows_sandbox_setup_start(conn, mode, opts \\ [])

@spec windows_sandbox_setup_start(connection(), atom() | String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}