@barry-rocks/sdk/sessions
Types for live sessions: turns, delivery, continuation, approvals, and the per-turn options a session adapter works with. Most bags don’t need it; session adapters and apps that drive sessions do.
import { … } from "@barry-rocks/sdk/sessions";Classes
Section titled “Classes”EventQueue
Section titled “EventQueue”Events pushed by a session and pulled by its reader, each delivered once.
Buffers while nobody is reading, because a reader typically starts reading just after delivering a message — and the harness may already have answered.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Implements
Section titled “Implements”AsyncIterable<T>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EventQueue<
T>():EventQueue<T>
Returns
Section titled “Returns”EventQueue<T>
Methods
Section titled “Methods”[asyncIterator]()
Section titled “[asyncIterator]()”[asyncIterator]():
AsyncIterator<T>
Returns
Section titled “Returns”AsyncIterator<T>
Implementation of
Section titled “Implementation of”AsyncIterable.[asyncIterator]
end():
void
Readers drain what is buffered, then stop.
Returns
Section titled “Returns”void
push()
Section titled “push()”push(
item):void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
item |
T |
Returns
Section titled “Returns”void
LiveContinuation
Section titled “LiveContinuation”A live permission callback is retained, never represented as a durable snapshot.
Implements
Section titled “Implements”Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
approvalContinuation |
readonly |
"live" |
Methods
Section titled “Methods”begin()
Section titled “begin()”begin(
content,emit,conversation?):Promise<SegmentOutcome>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content |
string |
emit |
(event) => Promise<void> |
conversation? |
ContinuationDescriptor |
Returns
Section titled “Returns”Promise<SegmentOutcome>
Implementation of
Section titled “Implementation of”close()
Section titled “close()”close():
Promise<void>
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”interrupt()
Section titled “interrupt()”interrupt():
Promise<void>
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”restore()
Section titled “restore()”restore(
continuation,decisions,effects,emit):Promise<SegmentOutcome>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
continuation |
ContinuationDescriptor |
decisions |
ReadonlyMap<string, PermissionDecision> |
effects |
ContinuationEffects |
emit |
(event) => Promise<void> |
Returns
Section titled “Returns”Promise<SegmentOutcome>
Implementation of
Section titled “Implementation of”validate()
Section titled “validate()”validate(
continuation):void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
continuation |
ContinuationDescriptor |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”open()
Section titled “open()”
staticopen(adapterId,fingerprint,config,start):Promise<LiveContinuation>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
adapterId |
string |
fingerprint |
string |
config |
SessionConfig |
start |
(config) => Promise<Session> |
Returns
Section titled “Returns”Promise<LiveContinuation>
NotSupportedInMode
Section titled “NotSupportedInMode”A method the session’s mode cannot perform, naming the mode that refused.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NotSupportedInMode(
operation,mode):NotSupportedInMode
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
operation |
string |
mode |
ModeId |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
mode |
readonly |
ModeId |
operation |
readonly |
string |
TurnExecution
Section titled “TurnExecution”One execution path for HTTP, apps and workflow turn receipts.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TurnExecution(
dependencies):TurnExecution
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
dependencies |
TurnExecutionDependencies |
Returns
Section titled “Returns”Methods
Section titled “Methods”admit()
Section titled “admit()”admit(
input):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ actor: string; content: unknown; ifActive?: "error" | "queue"; policy: { mode: "automatic"; } | { expiresAt?: string; mode: "review_required"; }; requestId: string; runId: string; sessionId: string; } |
input.actor |
string |
input.content |
unknown |
input.ifActive? |
"error" | "queue" |
input.policy |
{ mode: "automatic"; } | { expiresAt?: string; mode: "review_required"; } |
input.requestId |
string |
input.runId |
string |
input.sessionId |
string |
Returns
Section titled “Returns”cancel()
Section titled “cancel()”cancel(
sessionId,turnId):Promise<TurnSnapshot>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
Returns
Section titled “Returns”Promise<TurnSnapshot>
close()
Section titled “close()”close():
Promise<void>
Returns
Section titled “Returns”Promise<void>
recover()
Section titled “recover()”recover(
turn,input?,restoring?):void
Only runnable, unclaimed records are dispatched; never steal a process lease.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
turn |
TurnSnapshot |
undefined |
input? |
unknown |
undefined |
restoring? |
boolean |
true |
Returns
Section titled “Returns”void
resolve()
Section titled “resolve()”resolve(
input):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ actor: string; context?: unknown; decisions: ApprovalDecision[]; requestId: string; runId: string; sessionId: string; turnId: string; } |
input.actor |
string |
input.context? |
unknown |
input.decisions |
ApprovalDecision[] |
input.requestId |
string |
input.runId |
string |
input.sessionId |
string |
input.turnId |
string |
Returns
Section titled “Returns”settled()
Section titled “settled()”settled(
turnId):Promise<void>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
turnId |
string |
Returns
Section titled “Returns”Promise<void>
Interfaces
Section titled “Interfaces”ApprovalDecision
Section titled “ApprovalDecision”Properties
Section titled “Properties”| Property | Type |
|---|---|
decision |
PermissionDecision |
interruptId |
string |
ContinuationDescriptor
Section titled “ContinuationDescriptor”Private adapter data. Never include this value in an app snapshot.
Properties
Section titled “Properties”| Property | Type |
|---|---|
adapterId |
string |
adapterVersion |
string |
configFingerprint |
string |
format |
string |
harnessVersion |
string |
payload |
unknown |
version |
number |
ContinuationEffects
Section titled “ContinuationEffects”Every call goes through current authority and a persisted effect boundary.
Methods
Section titled “Methods”authorize()
Section titled “authorize()”authorize(
call):Promise<PermissionDecision>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call |
PermissionRequest |
Returns
Section titled “Returns”Promise<PermissionDecision>
denied()?
Section titled “denied()?”
optionaldenied(call,result):Promise<RecordedCallResult>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call |
PermissionRequest |
result |
RecordedCallResult |
Returns
Section titled “Returns”Promise<RecordedCallResult>
execute()
Section titled “execute()”execute(
call,effect):Promise<RecordedCallResult>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call |
PermissionRequest |
effect |
() => Promise<RecordedCallResult> |
Returns
Section titled “Returns”Promise<RecordedCallResult>
recorded()?
Section titled “recorded()?”
optionalrecorded(call):Promise<RecordedCallResult|undefined>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call |
PermissionRequest |
Returns
Section titled “Returns”Promise<RecordedCallResult | undefined>
ContinuationHarness
Section titled “ContinuationHarness”A quiescent segment returns before its runtime is released. The owner commits the returned checkpoint before publishing an interrupt or closing the handle.
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
approvalContinuation |
readonly |
ApprovalContinuation |
Methods
Section titled “Methods”begin()
Section titled “begin()”begin(
content,emit,conversation?):Promise<SegmentOutcome>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content |
string |
emit |
(event) => Promise<void> |
conversation? |
ContinuationDescriptor |
Returns
Section titled “Returns”Promise<SegmentOutcome>
close()
Section titled “close()”close():
Promise<void>
Returns
Section titled “Returns”Promise<void>
interrupt()
Section titled “interrupt()”interrupt():
Promise<void>
Returns
Section titled “Returns”Promise<void>
restore()
Section titled “restore()”restore(
continuation,decisions,effects,emit):Promise<SegmentOutcome>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
continuation |
ContinuationDescriptor |
decisions |
ReadonlyMap<string, PermissionDecision> |
effects |
ContinuationEffects |
emit |
(event) => Promise<void> |
Returns
Section titled “Returns”Promise<SegmentOutcome>
validate()
Section titled “validate()”validate(
continuation):void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
continuation |
ContinuationDescriptor |
Returns
Section titled “Returns”void
DeliveryOptions
Section titled “DeliveryOptions”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
from? |
Sender |
- |
ifActive? |
"queue" | "steer" |
Asked for, not promised: a session that cannot steer queues, and its receipt says so. |
outputSchema? |
JsonSchema |
Constrains this turn’s final answer; see runStructured for harnesses that cannot. |
DeliveryReceipt
Section titled “DeliveryReceipt”What actually happened to a delivery, which is what the sender is told.
Properties
Section titled “Properties”EgressPolicy
Section titled “EgressPolicy”The network half of a bound, when it asks to be enforced by a sandbox rather than by guards. An empty allowlist means nothing leaves the machine.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
allowDomains |
string[] |
- |
allowUnixSockets? |
string[] |
Unix sockets the session still needs, such as a local MCP server. |
PermissionRequest
Section titled “PermissionRequest”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
description? |
string |
The harness’s own description, when it gives one. |
id |
string |
- |
input |
unknown |
- |
tool |
string |
- |
PerTurnOptions
Section titled “PerTurnOptions”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
guarantees |
Guarantees |
- |
harnessSessionId? |
string |
The conversation to continue, when resuming one. |
harnessVersion? |
string |
- |
id |
string |
- |
Methods
Section titled “Methods”close()?
Section titled “close()?”
optionalclose():Promise<void>
Release anything held across turns.
Returns
Section titled “Returns”Promise<void>
runTurn()
Section titled “runTurn()”runTurn(
content,turn):AsyncIterable<SessionEvent>
Run one turn to completion. harnessSessionId is the conversation so far —
null on the first turn of a new one — so each turn resumes the last.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content |
string |
turn |
{ harnessSessionId: string | null; outputSchema?: JsonSchema; signal: AbortSignal; } |
turn.harnessSessionId |
string | null |
turn.outputSchema? |
JsonSchema |
turn.signal |
AbortSignal |
Returns
Section titled “Returns”AsyncIterable<SessionEvent>
PublicInterrupt
Section titled “PublicInterrupt”Properties
Section titled “Properties”| Property | Type |
|---|---|
call |
PermissionRequest |
expiresAt? |
string |
id |
string |
runId |
string |
status |
"pending" | "cancelled" | "approved" | "denied" | "expired" |
RecordedCallResult
Section titled “RecordedCallResult”Properties
Section titled “Properties”| Property | Type |
|---|---|
error? |
boolean |
id |
string |
result |
unknown |
Sender
Section titled “Sender”Properties
Section titled “Properties”| Property | Type |
|---|---|
name |
string |
sessionId? |
string |
Session
Section titled “Session”Properties
Section titled “Properties”| Property | Modifier | Type | Description |
|---|---|---|---|
guarantees |
readonly |
Guarantees |
Copied from the mode that started it — what this session has, not what a new one would. |
harnessSessionId |
readonly |
string | null |
- |
harnessVersion |
readonly |
string | null |
The harness build this session observed, when it could see one. |
id |
readonly |
string |
- |
mode |
readonly |
ModeId |
- |
warnings? |
readonly |
readonly string[] |
What the adapter wants known about this session as it starts — the same notes a launch returns in LaunchPlan.warnings, such as native tools still reachable that Barry has equivalents for. Absent means none. |
Methods
Section titled “Methods”answer()
Section titled “answer()”answer(
request,decision):Promise<void>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
PermissionRequest |
decision |
PermissionDecision |
Returns
Section titled “Returns”Promise<void>
attach()?
Section titled “attach()?”
optionalattach():Promise<SessionAttachment>
Opens the session to a vendor TUI that renders it, where the harness’s TUI
can attach to Barry’s engine. The engine stays up while anything is
attached; each attach is undone by one detach.
Returns
Section titled “Returns”Promise<SessionAttachment>
close()
Section titled “close()”close():
Promise<void>
Returns
Section titled “Returns”Promise<void>
compact()?
Section titled “compact()?”
optionalcompact():Promise<void>
Compact the conversation so far, where the harness supports it. Optional:
its presence is the capability. A harness that cannot compact (codex,
cursor, opencode today) simply does not define it, and callers answer 501
rather than sending a literal /compact that lands as a user message.
Returns
Section titled “Returns”Promise<void>
deliver()
Section titled “deliver()”deliver(
content,options?):Promise<DeliveryReceipt>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
content |
string |
options? |
DeliveryOptions |
Returns
Section titled “Returns”Promise<DeliveryReceipt>
detach()?
Section titled “detach()?”
optionaldetach():void
Returns
Section titled “Returns”void
events()
Section titled “events()”events():
AsyncIterable<SessionEvent>
Every event, across turns, each yielded once. A session has one reader; events that arrive while nobody is reading wait for the next one.
Returns
Section titled “Returns”AsyncIterable<SessionEvent>
externalTurns()?
Section titled “externalTurns()?”
optionalexternalTurns():AsyncIterable<SessionEvent>
Turns another client started, such as a person typing in an attached TUI,
kept apart from events(), whose reader is waiting on Barry’s own turns.
The person’s message arrives as a text with role user. Each turn ends
with one done.
Returns
Section titled “Returns”AsyncIterable<SessionEvent>
interrupt()
Section titled “interrupt()”interrupt():
Promise<void>
Stop the running turn. Rejects with NotSupportedInMode where the mode
cannot — resolving and doing nothing would read as “stopped” to every caller.
Returns
Section titled “Returns”Promise<void>
status()
Section titled “status()”status():
"error"|"idle"|"active"
Returns
Section titled “Returns”"error" | "idle" | "active"
SessionAttachment
Section titled “SessionAttachment”Where a vendor TUI attaches to render a hosted session.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
address |
string |
The engine’s address, as the TUI’s own client takes it. |
harnessSessionId |
string |
The conversation the TUI resumes. |
SessionConfig
Section titled “SessionConfig”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
allowedNativeTools? |
string[] |
- |
cwd |
string |
- |
decide? |
(request) => Promise<PermissionDecision> |
Rules on each native tool call the harness asks about. Absent means every such call is refused: a hosted session with no bound would otherwise run whatever the harness offers. |
deniedTools? |
string[] |
Honoured only where the harness can deny natively; see HarnessCapabilities.toolDenial. |
egressSandbox? |
EgressPolicy |
- |
endpoint? |
Endpoint |
Set only when the model’s vendor is not the harness’s own: where to send requests instead, and with what key. Absent means the harness’s own settings. |
env |
Record<string, string | undefined> |
- |
ephemeral? |
boolean |
The session runs one piece of work and is never resumed, so the harness keeps no state past close — a structured run, not a conversation. |
extraArgs? |
string[] |
Raw passthrough args the user typed after Barry’s own flags. |
maxTurns? |
number |
- |
mcpServers |
Record<string, McpServerConfig> |
- |
model? |
`${string}/${string}` |
Absent means the harness picks its own model. |
options? |
unknown |
Harness-specific settings, validated against Adapter.options. |
pluginDirs? |
string[] |
Directories of skills and commands to mount, where the harness mounts plugins. |
projectRoots? |
string[] |
Extra roots the agent may reach, under the harness’s own access rules. |
resume? |
object |
- |
resume.harnessSessionId? |
string |
- |
resume.last? |
boolean |
- |
resume.picker? |
boolean |
- |
sessionId |
string |
Barry’s session id. |
smallModel? |
`${string}/${string}` |
For the harness’s own cheap background calls, where it makes any. |
strictMcpConfig? |
boolean |
False lets the harness also load MCP servers from its own config (--relax). |
systemPrompt? |
string |
- |
telemetryEndpoint? |
string |
Where Barry’s OTLP receiver listens. Passed in because where a bag service listens is a host fact an adapter must not look up. |
telemetryHeaders? |
Record<string, string> |
Headers the receiver requires — its auth, which is the host’s to know. |
SessionDeclaration
Section titled “SessionDeclaration”Properties
Section titled “Properties”| Property | Type |
|---|---|
guarantees |
Guarantees |
guaranteesUnverified |
boolean |
harnessVersion? |
string |
StructuredReply
Section titled “StructuredReply”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
data |
unknown |
- |
harnessSessionId? |
string |
- |
raw |
string |
The final text the payload was taken from. |
StructuredRun
Section titled “StructuredRun”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
maxRetries? |
number |
Correction rounds after the first prompted attempt. Default 1. |
prompt |
string |
- |
schema |
JsonSchema |
- |
signal? |
AbortSignal |
Stops the attempt in flight and the run; the run then rejects. |
structuredOutput |
"native" | "prompted" |
From the session’s mode, overridden by the endpoint when a model is routed elsewhere. |
Methods
Section titled “Methods”start()
Section titled “start()”start():
Promise<Session>
A FRESH session per attempt. Retries carry the previous output and its errors in the prompt rather than continuing a conversation, because not every harness can resume one, and a structured run must behave the same on all of them.
Returns
Section titled “Returns”Promise<Session>
TurnExecutionDependencies
Section titled “TurnExecutionDependencies”Properties
Section titled “Properties”| Property | Type |
|---|---|
store |
TurnExecutionStore |
Methods
Section titled “Methods”acquire()?
Section titled “acquire()?”
optionalacquire():Promise<{release:void; }>
Returns
Section titled “Returns”Promise<{ release: void; }>
authorize()
Section titled “authorize()”authorize(
sessionId,call):Promise<PermissionDecision>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
call |
PermissionRequest |
Returns
Section titled “Returns”Promise<PermissionDecision>
committed()?
Section titled “committed()?”
optionalcommitted(sessionId,sequence):void
Notification is only a wake-up; the committed store is the replay source.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
sequence |
number |
Returns
Section titled “Returns”void
openHarness()
Section titled “openHarness()”openHarness(
sessionId):Promise<ContinuationHarness>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
Returns
Section titled “Returns”Promise<ContinuationHarness>
TurnExecutionStore
Section titled “TurnExecutionStore”Methods
Section titled “Methods”admit()
Section titled “admit()”admit(
input):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ actor: string; content: unknown; ifActive?: "error" | "queue"; policy: { mode: "automatic"; } | { expiresAt?: string; mode: "review_required"; }; requestId: string; runId: string; sessionId: string; } |
input.actor |
string |
input.content |
unknown |
input.ifActive? |
"error" | "queue" |
input.policy |
{ mode: "automatic"; } | { expiresAt?: string; mode: "review_required"; } |
input.requestId |
string |
input.runId |
string |
input.sessionId |
string |
Returns
Section titled “Returns”append()
Section titled “append()”append(
sessionId,turnId,event):number
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
event |
unknown |
Returns
Section titled “Returns”number
cancel()
Section titled “cancel()”cancel(
sessionId,turnId):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
Returns
Section titled “Returns”claim()
Section titled “claim()”claim(
sessionId,turnId,owner):boolean
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
owner |
string |
Returns
Section titled “Returns”boolean
continuation()
Section titled “continuation()”continuation(
sessionId,turnId):ContinuationDescriptor
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
Returns
Section titled “Returns”conversation()
Section titled “conversation()”conversation(
sessionId):ContinuationDescriptor|undefined
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
Returns
Section titled “Returns”ContinuationDescriptor | undefined
decisions()
Section titled “decisions()”decisions(
sessionId,turnId):Map<string,PermissionDecision>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
Returns
Section titled “Returns”Map<string, PermissionDecision>
denied()
Section titled “denied()”denied(
sessionId,turnId,owner,call,outcome):RecordedCallResult
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
owner |
string |
call |
PermissionRequest |
outcome |
RecordedCallResult |
Returns
Section titled “Returns”execute()
Section titled “execute()”execute(
sessionId,turnId,owner,call,effect):Promise<RecordedCallResult>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
owner |
string |
call |
PermissionRequest |
effect |
() => Promise<RecordedCallResult> |
Returns
Section titled “Returns”Promise<RecordedCallResult>
finish()
Section titled “finish()”finish(
sessionId,turnId,owner,outcome):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
owner |
string |
outcome |
{ conversation?: ContinuationDescriptor; error?: string; result?: unknown; state: "failed" | "completed" | "recovery_required"; } |
outcome.conversation? |
ContinuationDescriptor |
outcome.error? |
string |
outcome.result? |
unknown |
outcome.state |
"failed" | "completed" | "recovery_required" |
Returns
Section titled “Returns”lost()
Section titled “lost()”lost(
sessionId,turnId,error):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
error |
string |
Returns
Section titled “Returns”pause()
Section titled “pause()”pause(
sessionId,turnId,owner,continuation,calls):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
owner |
string |
continuation |
ContinuationDescriptor |
calls |
PermissionRequest[] |
Returns
Section titled “Returns”promoteQueued()?
Section titled “promoteQueued()?”
optionalpromoteQueued(sessionId): {input:unknown;turn:TurnSnapshot; } |undefined
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
Returns
Section titled “Returns”{ input: unknown; turn: TurnSnapshot; } | undefined
recorded()
Section titled “recorded()”recorded(
sessionId,turnId,call):RecordedCallResult|undefined
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
call |
PermissionRequest |
Returns
Section titled “Returns”RecordedCallResult | undefined
released()
Section titled “released()”released(
sessionId,turnId,owner):void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
owner |
string |
Returns
Section titled “Returns”void
resolve()
Section titled “resolve()”resolve(
input):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ actor: string; context?: unknown; decisions: ApprovalDecision[]; requestId: string; runId: string; sessionId: string; turnId: string; } |
input.actor |
string |
input.context? |
unknown |
input.decisions |
ApprovalDecision[] |
input.requestId |
string |
input.runId |
string |
input.sessionId |
string |
input.turnId |
string |
Returns
Section titled “Returns”snapshot()
Section titled “snapshot()”snapshot(
sessionId,turnId):TurnSnapshot
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
turnId |
string |
Returns
Section titled “Returns”TurnSnapshot
Section titled “TurnSnapshot”Properties
Section titled “Properties”| Property | Type |
|---|---|
error? |
string |
id |
string |
interrupts |
PublicInterrupt[] |
result? |
unknown |
reviewPolicy |
{ mode: "automatic"; } | { expiresAt?: string; mode: "review_required"; } |
revision |
number |
runId |
string |
sessionId |
string |
state |
TurnState |
Type Aliases
Section titled “Type Aliases”ApprovalContinuation
Section titled “ApprovalContinuation”ApprovalContinuation =
"durable"|"live"|"unsupported"
CallState
Section titled “CallState”CallState =
"not_started"|"executing"|"completed"|"failed"|"denied"|"uncertain"
McpServerConfig
Section titled “McpServerConfig”McpServerConfig = {
args?:string[];command:string;env?:Record<string,string>;type?:"stdio"; } | {headers?:Record<string,string>;type:"http"|"sse";url:string; }
PermissionDecision
Section titled “PermissionDecision”PermissionDecision = {
allow:true;persist?:boolean; } | {allow:false;reason?:string; }
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ allow: true; persist?: boolean; }
persist applies the answer to every later call of the same shape.
Type Literal
Section titled “Type Literal”{ allow: false; reason?: string; }
ReviewPolicy
Section titled “ReviewPolicy”ReviewPolicy =
z.infer<typeofReviewPolicySchema>
SegmentOutcome
Section titled “SegmentOutcome”SegmentOutcome = {
conversation?:ContinuationDescriptor;result?:unknown;type:"completed"; } | {error:string;type:"failed"; } | {calls:PermissionRequest[];continuation:ContinuationDescriptor;type:"interrupted"; }
SessionEvent
Section titled “SessionEvent”SessionEvent =
object& {harnessSessionId:string;type:"init"; } | {role?:"assistant"|"user";text:string;type:"text"; } | {text:string;type:"partial"; } | {id:string;input:unknown;tool:string;type:"tool_use"; } | {error?:boolean;id?:string;result:unknown;type:"tool_result"; } | {elapsedSeconds:number;id:string;tool:string;type:"tool_progress"; } | {description?:string;id:string;input:unknown;tool:string;type:"permission_request"; } | {status:"idle"|"active"|"error";type:"status"; } | {error?:string;result?:string;structured?:unknown;type:"result"; } | {error:string;type:"error"; } | {id:string;type:"usage";usage:TokenUsage; } | {durationMs?:number;turns?:number;type:"done";usage?:TokenUsage; }
The one event vocabulary. Every turn ends with exactly one done, so a
reader can wait for it without knowing how the harness ends a turn.
Type Declaration
Section titled “Type Declaration”| Name | Type | Description |
|---|---|---|
parentToolUseId? |
string |
Set when a subagent, not the main thread, produced the event: the tool call that spawned it. |
TurnState
Section titled “TurnState”TurnState =
"queued"|"running"|"waiting_for_input"|"recovery_required"|"completed"|"failed"|"cancelled"
Variables
Section titled “Variables”ReviewPolicySchema
Section titled “ReviewPolicySchema”
constReviewPolicySchema:ZodDiscriminatedUnion<[ZodObject<{mode:ZodLiteral<"automatic">; },$strict>,ZodObject<{expiresAt:ZodOptional<ZodISODateTime>;mode:ZodLiteral<"review_required">; },$strict>],"mode">
Functions
Section titled “Functions”allowedNative()
Section titled “allowedNative()”allowedNative(
config,nativeTools,native?):string[]
The native tools a session may use (ADP-6): every adapter derived this the
same way, so it lives here once. grantable restricts to a declared subset
(pi); omit it to allow any requested native tool. inseparable groups drop
whole when any member is unavailable. Denials are case-insensitive, matching
the native policy and configureHarnessSession.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config |
Pick<SessionConfig, "allowedNativeTools" | "deniedTools"> |
nativeTools |
readonly string[] |
native? |
NativeControl |
Returns
Section titled “Returns”string[]
assertSessionOwner()
Section titled “assertSessionOwner()”assertSessionOwner(
session,identity):void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
session |
{ identity_id?: number | null; } | undefined |
identity |
number |
Returns
Section titled “Returns”void
canEnforceInSandbox()
Section titled “canEnforceInSandbox()”canEnforceInSandbox(
actions):boolean
Whether Barry’s egress proxy can fully enforce a network bound’s actions.
The proxy filters by host, not by HTTP method, so it cannot express “reads allowed, writes denied”. Partial denials fall back to the app-level guards; callers should say so rather than implying kernel-grade coverage.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
actions |
string[] | undefined |
Returns
Section titled “Returns”boolean
canonicalJson()
Section titled “canonicalJson()”canonicalJson(
value):string
Canonical JSON rejects values that would silently change across persistence.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”string
configureHarnessSession()
Section titled “configureHarnessSession()”configureHarnessSession(
input,nativeTools,native?):SessionConfig
Apply the non-negotiable native ceiling before any adapter starts work.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
SessionConfig |
nativeTools |
readonly string[] |
native? |
NativeControl |
Returns
Section titled “Returns”configureSession()
Section titled “configureSession()”configureSession(
input):SessionConfig
Every interface supplies the same effective harness configuration. Own mutable collections.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
SessionConfig |
Returns
Section titled “Returns”declareSession()
Section titled “declareSession()”declareSession(
mode,observedVersion?):SessionDeclaration
An unknown build is not a mismatch: not every harness reports one, and marking every such session unverified would make the flag meaningless.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
mode |
Mode |
observedVersion? |
string |
Returns
Section titled “Returns”disallowedTools()
Section titled “disallowedTools()”disallowedTools(
config,nativeTools,native?):string[]
The native tools a session must refuse: the complement of allowedNative over the adapter’s table, plus the caller’s explicit denials (ADP-6).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config |
Pick<SessionConfig, "allowedNativeTools" | "deniedTools"> |
nativeTools |
readonly string[] |
native? |
NativeControl |
Returns
Section titled “Returns”string[]
executionHash()
Section titled “executionHash()”executionHash(
value):string
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
Returns
Section titled “Returns”string
extractFence()
Section titled “extractFence()”extractFence(
text,label):string|null
Extract labeled fences, preferring four backticks and respecting JSON strings when balancing three-backtick payloads.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
label |
string |
Returns
Section titled “Returns”string | null
isScopedMcpTool()
Section titled “isScopedMcpTool()”isScopedMcpTool(
tool,servers):boolean
Vendor spellings for a tool on an explicitly configured MCP server.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
tool |
string |
servers |
readonly string[] |
Returns
Section titled “Returns”boolean
perTurnSession()
Section titled “perTurnSession()”perTurnSession(
options):Session
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
PerTurnOptions |
Returns
Section titled “Returns”refuseDeniedTools()
Section titled “refuseDeniedTools()”refuseDeniedTools(
deniedTools?): (request) =>Promise<PermissionDecision>
The ruling for a session whose only per-call policy is its denied tools: a tool denied by name is refused, and everything else runs — what the session got before its harness asked. A hosted session given no ruling refuses every call, so a caller with nothing to deny still passes this.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
deniedTools |
readonly string[] |
[] |
Returns
Section titled “Returns”(request) => Promise<PermissionDecision>
runStructured()
Section titled “runStructured()”runStructured(
run):Promise<StructuredReply>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
run |
StructuredRun |
Returns
Section titled “Returns”Promise<StructuredReply>
structuredOutputFor()
Section titled “structuredOutputFor()”structuredOutputFor(
mode,route):"native"|"prompted"
Who enforces a structured run’s schema. The endpoint a model is routed to has the final say when the model is another vendor’s: a compatible API can accept a schema field and ignore it, which is measured per endpoint. Else the hosted mode does.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
mode |
{ structuredOutput: "native" | "prompted"; } |
mode.structuredOutput |
"native" | "prompted" |
route |
{ harnessVendor: string | undefined; model: `${string}/${string}` | undefined; models: Pick<Models, "endpoint">; } |
route.harnessVendor |
string | undefined |
route.model |
`${string}/${string}` | undefined |
route.models |
Pick<Models, "endpoint"> |
Returns
Section titled “Returns”"native" | "prompted"