ClaudeAgent
Agent backed by Claude Code (@anthropic-ai/claude-agent-sdk).
import { ClaudeAgent, ClaudeSdk } from "@jpowersdev/effect-agent/claude"program.pipe(Effect.provide(ClaudeAgent.layer().pipe(Layer.provide(ClaudeSdk.layer()))))Turns are defined by the CLI’s command_lifecycle frames: a turn starts
when one of our messages goes started while no turn is running (its
TurnId is that message’s id) and ends at the next result. A message that
goes started while a turn is running has landed in it (MessageLanded).
Each session’s CLI is started through Launcher (if provided) in its own
process group; pid is that process. RunOptions.watchdog interrupts a
turn that goes quiet, kills the process if the interrupt doesn’t end it
within stallGrace, and ends the turn Stalled either way.
RunOptions.hooks become SDK hooks (sdkHooks).
status starts an idle CLI (no prompt) and reads accountInfo() and the
experimental usage API. history reads a stored transcript.
The pure parts (buildOptions, sdkHooks, frameEvents, step,
classifyOutcome, accountStatus, historyEvents) are exported for testing.
Since v0.1.0
Constants
Section titled “Constants”provider
Section titled “provider”The Capabilities.provider name.
Signature
declare const provider: "claude"Since v0.1.0
Constructors
Section titled “Constructors”capabilities
Section titled “capabilities”Capabilities for a Claude Code CLI version (null when unknown).
Signature
declare const capabilities: (version: string | null) => CapabilitiesSince v0.1.0
Layers
Section titled “Layers”Agent backed by Claude Code; requires ClaudeSdk.
Signature
declare const layer: ( options?: ClaudeAgentOptions,) => Layer.Layer<Agent, never, ClaudeSdk.ClaudeSdk>Since v0.1.0
Models
Section titled “Models”ClaudeAgentOptions (interface)
Section titled “ClaudeAgentOptions (interface)”Signature
export interface ClaudeAgentOptions { /** * Filesystem settings to load. Defaults to the CLI default (all sources, so project * `CLAUDE.md` loads). MCP isolation holds regardless, unless `RunOptions.mcp` is set. */ readonly settingSources?: ReadonlyArray<SettingSource> /** Use this `claude` binary instead of the one bundled with the SDK. */ readonly pathToClaudeCodeExecutable?: string /** * How tool calls are permitted. `bypassPermissions` (the default) runs every * tool that isn't disabled or refused. `dontAsk` runs only what a permission * rule allows, from `allowedTools` or the settings files * (`settingSources`), and denies the rest: nobody is there to ask. * `settings` passes no mode, so the settings files' `permissions.defaultMode` * decides, as for `claude -p`: with none, what a rule (or `allowedTools`) * doesn't allow is denied. `disable`, `mcp` and `beforeTool` refusals hold in * all three. */ readonly permissionMode?: "bypassPermissions" | "dontAsk" | "settings" /** * Permission rules that allow a tool without asking, in Claude Code's * syntax: `Read`, `Bash(git log:*)`, `Edit(/repo/src/**)`, * `mcp__task__progress`. Matters unless `permissionMode` bypasses them. */ readonly allowedTools?: ReadonlyArray<string> /** Model when `RunOptions.model` is not set. */ readonly model?: string /** * Check that a resumed session exists (`getSessionInfo`) before spawning. * Default true; the CLI's own "No conversation found" is still mapped to * `SessionNotFound` either way. */ readonly checkResume?: boolean /** * Applied over the host environment for every process this layer starts * (sessions and `status`); `RunOptions.env` applies on top. `undefined` * removes a variable, e.g. `{ CLAUDE_CONFIG_DIR: "/path" }` for another account. */ readonly env?: Readonly<Record<string, string | undefined>> /** Default for `RunOptions.watchdog.grace` (10 seconds when neither is set). */ readonly stallGrace?: Duration.Input}Since v0.1.0