effect
Type Aliases
Section titled “Type Aliases”MuleRetryObservation
Section titled “MuleRetryObservation”MuleRetryObservation = {
type:"retry_scheduled";run:MuleIdentity;turn:MuleIdentity;attempt:number;maxAttempts:number;delayMs:number;errorMessage:string; } | {type:"retry_attempt_started";run:MuleIdentity;turn:MuleIdentity;attempt:number; } | {type:"retry_finished";run:MuleIdentity;turn:MuleIdentity;attempt:number;success:boolean;finalError?:string; }
One observed Pi-retry event around a single assistant call.
MulePreparedTool
Section titled “MulePreparedTool”MulePreparedTool =
object
A decoded, authorized invocation ready to execute.
Properties
Section titled “Properties”execute
Section titled “execute”
readonlyexecute: () =>Stream.Stream<MuleToolExecutionPart,MuleError>>
Run the already-decoded and authorized tool call.
Returns
Section titled “Returns”Stream.Stream<MuleToolExecutionPart,
MuleError>
MuleTool
Section titled “MuleTool”MuleTool =
object
Pi tool declaration paired with its Effect-native preparation door.
Properties
Section titled “Properties”descriptor
Section titled “descriptor”
readonlydescriptor:Tool
replay?
Section titled “replay?”
readonlyoptionalreplay?:"safe"|"unsafe"
Only read-only or explicitly idempotent tools may opt into crash replay.
executionMode?
Section titled “executionMode?”
readonlyoptionalexecutionMode?:"parallel"|"sequential"
prepare
Section titled “prepare”
readonlyprepare: (call) =>Effect.Effect<MulePreparedTool,MuleToolRejection>>
Decode and authorize one exact Pi tool call before it can execute.
Parameters
Section titled “Parameters”ToolCall
Returns
Section titled “Returns”Effect.Effect<MulePreparedTool,
MuleToolRejection>
MuleListener
Section titled “MuleListener”MuleListener = (
event) =>Effect.Effect<void,MuleError>>
Effect-native listener. Completion is part of run settlement.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Effect.Effect<void, MuleError>
MuleRunInput
Section titled “MuleRunInput”MuleRunInput =
MuleRunSettings&object
Inputs for one complete Pi model/tool loop. Cancel a run by interrupting its
fiber; the run then ends with a cancelled run_end.
Type Declaration
Section titled “Type Declaration”prepareSystemPrompt?
Section titled “prepareSystemPrompt?”
readonlyoptionalprepareSystemPrompt?: () =>Effect.Effect<string,MuleError>>
Rebuild the model system prompt immediately before each provider request.
Returns
Section titled “Returns”Effect.Effect<string, MuleError>
tools?
Section titled “tools?”
readonlyoptionaltools?: readonlyMuleTool[]
resolveApiKey?
Section titled “resolveApiKey?”
readonlyoptionalresolveApiKey?: (provider) =>Effect.Effect<string|undefined,MuleError>>
Resolve a fresh provider credential immediately before each Pi call.
Parameters
Section titled “Parameters”provider
Section titled “provider”string
Returns
Section titled “Returns”Effect.Effect<string | undefined, MuleError>
getSteeringMessages?
Section titled “getSteeringMessages?”
readonlyoptionalgetSteeringMessages?: () =>Effect.Effect<readonlyMessage[],MuleError>>
Pull messages that should steer the active run at Pi’s safe point.
Returns
Section titled “Returns”Effect.Effect<readonly Message[], MuleError>
getFollowUpMessages?
Section titled “getFollowUpMessages?”
readonlyoptionalgetFollowUpMessages?: () =>Effect.Effect<readonlyMessage[],MuleError>>
Pull messages queued until the run would otherwise finish.
Returns
Section titled “Returns”Effect.Effect<readonly Message[], MuleError>
shouldStopAfterTurn?
Section titled “shouldStopAfterTurn?”
readonlyoptionalshouldStopAfterTurn?: (turn) =>Effect.Effect<boolean,MuleError>>
Request a graceful stop after the current Pi turn has fully settled.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Effect.Effect<boolean, MuleError>
onRetry?
Section titled “onRetry?”
readonlyoptionalonRetry?: (event) =>Effect.Effect<void,MuleError>>
Effect-native observation sink for Pi’s retry policy (retry), one call per
scheduled or finished retry.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Effect.Effect<void, MuleError>
MuleEffect
Section titled “MuleEffect”MuleEffect =
object
Canonical Effect-native Mule interface.
Properties
Section titled “Properties”
readonlyrun: (input,listener?) =>Effect.Effect<MuleRunOutcome,MuleError>>
Run one complete Pi model/tool loop.
Parameters
Section titled “Parameters”listener?
Section titled “listener?”Returns
Section titled “Returns”Effect.Effect<MuleRunOutcome,
MuleError>
Variables
Section titled “Variables”piCodingAgentRetryDefaults
Section titled “piCodingAgentRetryDefaults”
constpiCodingAgentRetryDefaults:RetryPolicy
Pi coding-agent’s retry defaults (settings-manager.js getRetrySettings(),
@earendil-works/pi-ai 0.99.0, the version pinned in the lockfile). Pi-ai’s own
RetryPolicy has no default — an undefined policy means no retry — so a host
that wants Pi coding-agent’s numbers passes this explicitly.
piHttpIdleTimeoutMs
Section titled “piHttpIdleTimeoutMs”
constpiHttpIdleTimeoutMs:300000=300_000
Pi coding-agent’s default stream idle timeout (DEFAULT_HTTP_IDLE_TIMEOUT_MS,
settings-manager.js). A host that wants Pi’s number for
modelStreamIdleTimeoutMs passes this explicitly.
muleEffect
Section titled “muleEffect”
constmuleEffect:MuleEffect
Canonical Effect-native Mule value.
Functions
Section titled “Functions”isContextOverflow()
Section titled “isContextOverflow()”isContextOverflow(
message,contextWindow?):boolean
Apply Pi’s maintained context-overflow semantics to an exact Pi message.
Parameters
Section titled “Parameters”message
Section titled “message”AssistantMessage
contextWindow?
Section titled “contextWindow?”number
Returns
Section titled “Returns”boolean
run(
input,listener?):Effect<MuleRunOutcome,MuleError>>
Run Pi’s model/tool loop inside Effect without changing Pi’s values.
Parameters
Section titled “Parameters”listener?
Section titled “listener?”MuleListener = noListener
Returns
Section titled “Returns”Effect<MuleRunOutcome,
MuleError>
References
Section titled “References”MuleCompletedTurn
Section titled “MuleCompletedTurn”Re-exports MuleCompletedTurn
MuleResume
Section titled “MuleResume”Re-exports MuleResume
MuleToolCheckpoint
Section titled “MuleToolCheckpoint”Re-exports MuleToolCheckpoint
MuleError
Section titled “MuleError”Re-exports MuleError
MuleEvent
Section titled “MuleEvent”Re-exports MuleEvent
MuleIdentity
Section titled “MuleIdentity”Re-exports MuleIdentity
MuleIdentityKind
Section titled “MuleIdentityKind”Re-exports MuleIdentityKind
MuleRunOutcome
Section titled “MuleRunOutcome”Re-exports MuleRunOutcome
MuleRunSettings
Section titled “MuleRunSettings”Re-exports MuleRunSettings
MuleStreamFunction
Section titled “MuleStreamFunction”Re-exports MuleStreamFunction
MuleToolExecutionPart
Section titled “MuleToolExecutionPart”Re-exports MuleToolExecutionPart
MuleToolRejection
Section titled “MuleToolRejection”Re-exports MuleToolRejection
MuleToolResult
Section titled “MuleToolResult”Re-exports MuleToolResult