BreakerState

Circuit breaker states

BreakerState

CircuitBreaker

Circuit breaker for protecting against repeated failures

new CircuitBreaker($0: Object, options: object)
Parameters
$0 (Object = {})
Name Description
$0.name any (default 'default')
$0.failureThreshold any (default 5)
$0.resetTimeMs any (default 30000)
$0.halfOpenMaxAttempts any (default 1)
options (object)
Instance Members
isAllowed()
recordSuccess()
recordFailure()
getStatus()
reset()

getToolKind

Get ACP-compliant tool kind for a given tool name

getToolKind(name: any)
Parameters
name (any)

getToolTitle

Get display title for a tool, including context from input when available

getToolTitle(name: any, parentToolUseId: any, input: any)
Parameters
name (any)
parentToolUseId (any)
input (any)

shortenPath

Shorten a file path for display (show last 2-3 components)

shortenPath(path: any)
Parameters
path (any)

truncate

Truncate string with ellipsis

truncate(str: any, maxLen: any)
Parameters
str (any)
maxLen (any)

getToolLocations

Extract file locations from tool input for ACP locations array

getToolLocations(name: any, input: any)
Parameters
name (any)
input (any)

getInlineToolDescription

Get a short inline description for embedding child tool calls in parent content

getInlineToolDescription(name: any, input: any)
Parameters
name (any)
input (any)

buildSpawnEnv

Build environment for spawning amp process

buildSpawnEnv()

_sessionUpdate

Wrapper for sessionUpdate with severity classification

_sessionUpdate(notif: object, options: object)
Parameters
notif (object) The notification to send
options (object = {}) Options
Name Description
options.critical boolean (default false) If true, throw on failure; if false, log warning only

_validateThreadExists

Validate that a thread exists by checking with amp threads show

_validateThreadExists(threadId: string, cwd: string): Promise<boolean>
Parameters
threadId (string) The thread ID to validate
cwd (string) Working directory
Returns
Promise<boolean>: True if thread exists

gracefulKill

Two-phase graceful kill: SIGTERM first, then SIGKILL after timeout

gracefulKill(proc: ChildProcess, graceMs: number): Promise<("exited" | "killed")>
Parameters
proc (ChildProcess) The process to kill
graceMs (number = 5000) Grace period before SIGKILL (default: 5000ms)
Returns
Promise<("exited" | "killed")>:

NestedToolTracker

State tracker for nested tool call handling Tracks mapping between Amp tool_use_id and child tool metadata Also tracks per-parent progress counters for consolidated display

new NestedToolTracker()
Instance Members
getContentArray(parentId)

getUniqueToolCallId

Generate a session-unique ACP tool call ID from an Amp tool_use_id If the ID already exists, generate a unique replacement and track the mapping

getUniqueToolCallId
Parameters
ampId (string) Original Amp tool_use_id
Returns
string: Session-unique ACP tool call ID

findAcpToolCallId

Find the ACP tool call ID for a given Amp tool_use_id Handles both direct matches and ampId->acpId mappings

findAcpToolCallId
Parameters
ampId (string) Original Amp tool_use_id from tool_result
Returns
(string | null): ACP tool call ID or null if not found

isBashToolUse

Check if a message chunk is a Bash tool_use

isBashToolUse(chunk: any)
Parameters
chunk (any)

getToolResult

Extract tool result info from a tool_result chunk

getToolResult(chunk: any)
Parameters
chunk (any)