agent-kit
API reference

@rivus/agent-kit/catalog

isBuiltinCodingAgentId, Result, ok, err, AgentKitError, isAgentKitError — anywhere

Functions

err()

function err<E>(error: E): Result<never, E>;

Type Parameters

E

E

Parameters

error

E

Returns

Result<never, E>


isAgentKitError()

function isAgentKitError(value: unknown): value is AgentKitError<string>;

Parameters

value

unknown

Returns

value is AgentKitError<string>


isBuiltinCodingAgentId()

function isBuiltinCodingAgentId(value: string): value is "codex" | "dsh" | "claude-code" | "grok" | "opencode" | "gemini-cli" | "cursor" | "pi" | "zcode";

Parameters

value

string

Returns

value is "codex" | "dsh" | "claude-code" | "grok" | "opencode" | "gemini-cli" | "cursor" | "pi" | "zcode"


ok()

function ok<T>(value: T): Result<T, never>;

Type Parameters

T

T

Parameters

value

T

Returns

Result<T, never>

Classes

AgentKitError

The only public class of the kit. Expected failures are returned as tagged Result values; this error is thrown for caller mistakes such as naming an agent that has no adapter, and code names which one.

Extends

  • Error

Type Parameters

Code

Code extends string = string

Constructors

Constructor
new AgentKitError<Code extends string = string>(
   code: Code, 
   message: string, 
   options?: AgentKitErrorOptions
): AgentKitError<Code>;
Parameters
code

Code

message

string

options?

AgentKitErrorOptions

Returns

AgentKitError<Code>

Overrides

Error.constructor

Properties

code
readonly code: Code;

Methods

[hasInstance]()
static [hasInstance](value: unknown): boolean;
Parameters
value

unknown

Returns

boolean

Interfaces

AgentHome

The configuration and data root of one CodingAgent on this machine, and what set it.

Properties

agent
readonly agent: string;
path
readonly path: string;
source
readonly source: AgentHomeSource;

CodingAgent

The identity of a CodingAgent: what every context needs to agree on, and nothing more.

Extended by

Properties

aliases
readonly aliases: readonly string[];

Other ids that name the same agent, such as claude; parseCodingAgentId maps them to id.

displayName
readonly displayName: string;
home?
readonly home?: HomeRule;

Absent until an upstream source or the agent's documentation confirms where it keeps its data.

id
readonly id: string;

CodingAgentWithHome

The identity of a CodingAgent: what every context needs to agree on, and nothing more.

Extends

Properties

aliases
readonly aliases: readonly string[];

Other ids that name the same agent, such as claude; parseCodingAgentId maps them to id.

Inherited from

CodingAgent.aliases

displayName
readonly displayName: string;
Inherited from

CodingAgent.displayName

home
readonly home: HomeRule;

Absent until an upstream source or the agent's documentation confirms where it keeps its data.

Overrides

CodingAgent.home

id
readonly id: string;
Inherited from

CodingAgent.id


HomeContext

The environment variables and the user's home directory that home rules read; a Platform satisfies it.

Properties

env
readonly env: Readonly<Record<string, string | undefined>>;
home
readonly home: string;

HomeRule

Where a CodingAgent keeps its configuration and data. An override variable either names the agent home itself (CODEX_HOME), or a base directory under which the agent appends its own path (XDG_DATA_HOME plus opencode); envSubpath holds that appended path.

Properties

defaultPath
readonly defaultPath: readonly string[];

Path segments under the user's home directory when the variable is unset or blank.

envSubpath?
readonly envSubpath?: readonly string[];
envVar?
readonly envVar?: string;
expandsTilde?
readonly expandsTilde?: boolean;

The agent expands a leading ~ in the variable to the user's home directory.

Type Aliases

BuiltinCodingAgentId

type BuiltinCodingAgentId = keyof typeof builtinCodingAgents;

Built-in ids come from the shell's provider identities, not a second list in a context.


CodingAgentId

type CodingAgentId = BuiltinCodingAgentId | string & object;

Accept third-party ids while keeping editor completion for built-ins.


Result

type Result<T, E> = 
  | {
  ok: true;
  value: T;
}
  | {
  error: E;
  ok: false;
};

An expected outcome of a plain TS function. Failures carry a _tag union; only defects throw.

Type Parameters

T

T

E

E