Skip to content

Open-source, local-first AI agent for real work.

5.5 KB
Raw Blame
---
title: Coding Agent API reference
description: Find public exports for sessions, hosts, configuration, resources, extensions, and runtime services, and respect lifecycle and compatibility boundaries.
---

This page maps the exports of `@vetta/coding-agent`. The declarations in the source are the source of truth for types, parameters, and return values. Examples must import only from entry points listed in `package.json#exports`; never deep-import `src/**` or `dist/**`.

<Callout type="info" title="Publication status">
  `@vetta/coding-agent` is not currently published to npm. It is used only inside the Vetta monorepo as a workspace dependency (`"@vetta/coding-agent": "workspace:*"`). For integrations outside the repository, prefer driving the installed desktop app through [RPC mode](/developers/rpc/).
</Callout>

## Export paths

| Entry point | Purpose |
| --- | --- |
| `@vetta/coding-agent` | Package root; the same stable Extension facade as `/extensions` |
| `@vetta/coding-agent/sdk` | Create and manage in-process Sessions, Hosts, and offline Catalogs |
| `@vetta/coding-agent/rpc` | NDJSON RPC frames, commands, events, `RpcClient`, and `RPC_FAILURE_CODES` |
| `@vetta/coding-agent/settings` | Global and project settings and their schema |
| `@vetta/coding-agent/config` | Config directory, package directory, and environment variable constants (such as `getAgentDir()` and `CONFIG_DIR_NAME`) |
| `@vetta/coding-agent/resources` | Skill, Extension, and Prompt resource sources |
| `@vetta/coding-agent/extensions` | Extension contracts and lifecycle |
| `@vetta/coding-agent/extensions/pi-compat` | Load and adapt Extensions and tool definitions from the pi ecosystem |
| `@vetta/coding-agent/session-extensions` | Session-level extension capabilities |
| `@vetta/coding-agent/hooks` | Host and Agent lifecycle hooks |
| `@vetta/coding-agent/host-services` | Model, file, and runtime services provided by the host |
| `@vetta/coding-agent/host` | Node host capabilities for runtime tool composition roots, such as edit and write path policies |
| `@vetta/coding-agent/composition` | Product composition root: runtime definitions, Session selection, tool result policies, and observation constants |
| `@vetta/coding-agent/historical-sessions` | Read and manage historical sessions offline |
| `@vetta/coding-agent/bootstrap` | Build host configuration from startup arguments and the environment |
| `@vetta/coding-agent/function-extensions` | Function-based extension sources |
| `@vetta/coding-agent/plugin-runtime` | Plugin runtime bridge |
| `@vetta/coding-agent/export-html` | Session HTML export |
| `@vetta/coding-agent/profile` | Host profile selection |
| `@vetta/coding-agent/cli-guidance` | CLI entry hints and argument guidance |
| `@vetta/coding-agent/runtime` | Runtime composition and lifecycle interfaces |
| `@vetta/coding-agent/model-context` | Model context and message input contracts |

## Session lifecycle

The recommended order is:

```text
create → inspect diagnostics → subscribe → prompt / steer / followUp
      → abort or complete → unsubscribe → close
```

- Handle `diagnostics` during creation; do not silently discard resource or extension load failures.
- Call the unsubscribe function returned by `subscribe()` when the host is destroyed.
- `abort()` stops only the current execution; it does not replace `close()`.
- File-backed Sessions must state create, resume, or in-memory semantics explicitly; multiple active Sessions must not write the same session file.
- Hosts should preserve Agent, turn, message, tool, compaction, retry, and termination event semantics.

See [Use the Coding Agent SDK](/developers/sdk/) for a complete minimal example.

## Integration boundaries

| Need | Recommended entry point | Avoid |
| --- | --- | --- |
| Run the Agent inside a TypeScript process | `sdk` | Parsing CLI stdout or copying the Session state machine |
| Language-independent or isolated process | `rpc` | Mixing diagnostic logs into stdout |
| Show history offline | `historical-sessions` | Opening every active Session to render a list |
| Provide model, file, or other host capabilities | `host-services` / `runtime` | Importing from private Desktop implementation directories |
| Inject Skills, Prompts, or Extensions | `resources` / `extensions` | Editing built-in resource directories directly |
| Use plugin-contributed capabilities | `plugin-runtime` | Bypassing manifest and permission checks |

## Compatibility strategy

1. Upgrade together with the monorepo; do not copy `dist/` output outside the repository for long-term use.
2. Record versions and diagnostics at startup, and degrade or fail clearly when a capability is unknown.
3. RPC hosts route responses and events separately and handle events without an `id`.
4. Map cancellation, retries, compaction, tool failures, and process exit to upper-layer state.
5. Treat only public exports, type definitions, and documented fields as integration contracts.

<Callout title="Declarations are the API source of truth" type="warn">
  This page helps you choose an entry point; it does not replace the API declarations. After pulling new code, recheck export paths, event union types, and error codes, and run your host's own contract tests.
</Callout>

<Continue>
  <ContinueLink href="/developers/rpc/" title="Integrate with RPC mode" description="NDJSON frames, responses, events, cancellation, and the Host Bridge." />
  <ContinueLink href="/developers/cli-and-settings/" title="CLI and settings" description="Start tasks from scripts and handle configuration precedence." />
</Continue>