Skip to content
API reference

effect

Import
import * as api from "@fungi.computer/mule/effect";
Kind Export Description
type alias MuleRetryObservation One observed typed-retry event around a single assistant call.
type alias MulePreparedTool A decoded, authorized invocation ready to execute.
type alias MuleTool Pi tool declaration paired with its Effect-native preparation door.
type alias MuleListener Effect-native listener. Completion is part of run settlement.
type alias MuleRunInput 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 alias MuleEffect Canonical Effect-native Mule interface.
type alias ThinkingLevel Provider-neutral reasoning effort requested by a caller.
type alias ModelThinkingLevel Effective reasoning effort, including disabled thinking.
type alias KnownApi Built-in chat APIs recognized by the pinned Pi adapter.
type alias Api Built-in or caller-defined chat API identifier.
type alias ProviderId Provider identifier carried with a model or assistant message.
type alias ToolChoice Provider-neutral choice to allow or disable tools.
type alias SamplingParams Provider sampling fields passed through unchanged.
type alias SamplingParamsByThinkingLevel Sampling overrides selected by reasoning effort.
type alias ThinkingBudgets Token budgets for providers that meter reasoning separately.
type alias Transport Preferred provider stream transport.
type alias ProviderEnv Request-scoped provider environment overrides.
type alias ProviderHeaders Provider headers; null removes a default header.
type alias FetchFunction Fetch implementation supplied to the provider adapter.
type alias ProviderResponse HTTP status and headers observed before stream consumption.
type alias ProviderRequestOptions Authentication, transport and lifecycle hooks for one provider request.
type alias StreamOptions Common provider stream controls, independent of any SDK.
type alias SimpleStreamOptions Provider-neutral model request options used by Mule.
type alias TextContent Text block with an optional provider continuity signature.
type alias ThinkingContent Reasoning block, including opaque redacted provider thinking.
type alias ImageContent Base64 image bytes with their media type.
type alias ToolCall Model-requested tool invocation with JSON arguments.
type alias Usage Token counts and provider costs for one response or tool result.
type alias StopReason Provider outcome for an assistant response.
type alias JsonValue JSON data carried by messages and tool results.
type alias ProviderValue Provider request/event values, including optional fields, binary bytes and cancellation.
type alias ProviderData Parsed provider request or event fields; Pi owns the provider-specific grammar.
type alias JsonObject Named JSON properties in tool arguments or message metadata.
type alias DeferredHandle Provider receipt used to recover a deferred assistant response.
type alias SystemMessage Prompt and tool-set update at a point in the transcript.
type alias UserMessage User text and image input with its timestamp.
type alias AssistantMessage Provider response, usage and terminal reason, preserved by Mule.
type alias NestedToolCallRecord Bounded evidence of a tool invocation made inside another tool.
type alias NestedToolCalls Recorded nested invocations and whether the record is complete.
type alias ToolResultMessage Correlated tool output with optional JSON details and usage.
type alias Message One system, user, assistant or tool-result transcript entry.
type alias GrammarFormat Provider grammar formats available for constrained sampling.
type alias GrammarVariants Grammar text supplied for each supported provider format.
type alias ConstrainedSamplingConfig Provider constraint for a tool declaration.
type alias Tool Model-visible tool name, description and TypeBox argument schema.
type alias ToolReference Named tool removed by a transcript system update.
type alias Context Model request context; Pi adapters normalize it before provider dispatch.
type alias AssistantMessageEvent Partial updates and the terminal event for an assistant stream.
type alias BaseModel Catalog fields shared by chat model definitions.
type alias Model Chat model configuration accepted by Mule and its Pi adapter.
type alias DiagnosticErrorInfo Serializable diagnostic information retained with an assistant message.
type alias AssistantMessageDiagnostic Timestamped provider diagnostic with optional JSON details.
type alias AssistantMessageEventStream Only the stream operations consumed by Mule. Pi’s concrete stream satisfies this port.
type alias RetryPolicy Bounded assistant-call retries with capped exponential delays.
type alias AttributeValue Scalar or homogeneous-array telemetry attribute.
type alias SpanAttributes Named telemetry attributes, with undefined values omitted by the owner.
type alias SpanOptions Name and initial attributes of a request telemetry span.
type alias SpanStatus Successful or failed telemetry completion.
type alias TelemetryContext Parent context through which a provider opens telemetry spans.
type alias TelemetrySpan Provider telemetry span with events, attributes and completion status.
constant piCodingAgentRetryDefaults 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.
constant muleEffect Canonical Effect-native Mule value.
function isContextOverflow() Apply Pi’s maintained context-overflow semantics to an exact Pi message.
function run() Run Pi’s model/tool loop inside Effect without changing Pi’s values.

MuleRetryObservationtype alias

Section titled “MuleRetryObservation”
Signature
type 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 typed-retry event around a single assistant call.


MulePreparedTooltype alias

Section titled “MulePreparedTool”
Signature
type MulePreparedTool = object;

A decoded, authorized invocation ready to execute.

Signature
readonly execute: () => Stream.Stream<MuleToolExecutionPart, MuleError>;

Run the already-decoded and authorized tool call.

Stream.Stream<MuleToolExecutionPart, MuleError>


Signature
type MuleTool = object;

Pi tool declaration paired with its Effect-native preparation door.

Signature
readonly descriptor: Tool;
Signature
readonly optional replay?: "safe" | "unsafe";

Only read-only or explicitly idempotent tools may opt into crash replay.

Signature
readonly optional executionMode?: "parallel" | "sequential";
Signature
readonly prepare: (call) => Effect.Effect<MulePreparedTool, MuleToolRejection>;

Decode and authorize one exact Pi tool call before it can execute.

Parameter Type
call ToolCall

Effect.Effect<MulePreparedTool, MuleToolRejection>


MuleListenertype alias

Section titled “MuleListener”
Signature
type MuleListener = (event) => Effect.Effect<void, MuleError>;

Effect-native listener. Completion is part of run settlement.

Parameter Type
event MuleEvent

Effect.Effect<void, MuleError>


MuleRunInputtype alias

Section titled “MuleRunInput”
Signature
type 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.

Name Type Description
prepareSystemPrompt()? () => Effect.Effect<string, MuleError> Rebuild the model system prompt immediately before each provider request.
tools? readonly MuleTool[] -
resolveApiKey()? (provider) => Effect.Effect<string | undefined, MuleError> Resolve a fresh provider credential immediately before each Pi call.
getSteeringMessages()? () => Effect.Effect<readonly Message[], MuleError> Pull messages that should steer the active run at Pi’s safe point.
getFollowUpMessages()? () => Effect.Effect<readonly Message[], MuleError> Pull messages queued until the run would otherwise finish.
prepareNextTurn()? (turn) => Effect.Effect<readonly Message[] | undefined, MuleError> Pi’s between-turn point: after a turn’s tool results and before the next assistant request of the same run. Return a replacement context, such as one rebuilt after compaction, or undefined to keep the current one.
shouldStopAfterTurn()? (turn) => Effect.Effect<boolean, MuleError> Request a graceful stop after the current Pi turn has fully settled.
onRetry()? (event) => Effect.Effect<void, MuleError> Effect-native observation sink for Pi’s retry policy (retry), one call per scheduled or finished retry.

MuleEffecttype alias

Section titled “MuleEffect”
Signature
type MuleEffect = object;

Canonical Effect-native Mule interface.

Signature
readonly run: (input, listener?) => Effect.Effect<MuleRunOutcome, MuleError>;

Run one complete Pi model/tool loop.

Parameter Type
input MuleRunInput
listener? MuleListener

Effect.Effect<MuleRunOutcome, MuleError>


ThinkingLeveltype alias

Section titled “ThinkingLevel”
Signature
type ThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh" | "max";

Provider-neutral reasoning effort requested by a caller.


ModelThinkingLeveltype alias

Section titled “ModelThinkingLevel”
Signature
type ModelThinkingLevel = "off" | ThinkingLevel;

Effective reasoning effort, including disabled thinking.


Signature
type KnownApi =
| "openai-completions"
| "mistral-conversations"
| "openai-responses"
| "azure-openai-responses"
| "openai-codex-responses"
| "anthropic-messages"
| "bedrock-converse-stream"
| "google-generative-ai"
| "google-vertex"
| "pi-messages";

Built-in chat APIs recognized by the pinned Pi adapter.


Signature
type Api = KnownApi | (string & object);

Built-in or caller-defined chat API identifier.


ProviderIdtype alias

Section titled “ProviderId”
Signature
type ProviderId = string;

Provider identifier carried with a model or assistant message.


ToolChoicetype alias

Section titled “ToolChoice”
Signature
type ToolChoice = "auto" | "none";

Provider-neutral choice to allow or disable tools.


SamplingParamstype alias

Section titled “SamplingParams”
Signature
type SamplingParams = JsonObject;

Provider sampling fields passed through unchanged.


SamplingParamsByThinkingLeveltype alias

Section titled “SamplingParamsByThinkingLevel”
Signature
type SamplingParamsByThinkingLevel = Partial<
Record<ModelThinkingLevel, SamplingParams>
>;

Sampling overrides selected by reasoning effort.


ThinkingBudgetstype alias

Section titled “ThinkingBudgets”
Signature
type ThinkingBudgets = object;

Token budgets for providers that meter reasoning separately.

Signature
optional minimal?: number;
Signature
optional low?: number;
Signature
optional medium?: number;
Signature
optional high?: number;

Transporttype alias

Section titled “Transport”
Signature
type Transport = "sse" | "websocket" | "websocket-cached" | "auto";

Preferred provider stream transport.


ProviderEnvtype alias

Section titled “ProviderEnv”
Signature
type ProviderEnv = Record<string, string>;

Request-scoped provider environment overrides.


ProviderHeaderstype alias

Section titled “ProviderHeaders”
Signature
type ProviderHeaders = Record<string, string | null>;

Provider headers; null removes a default header.


FetchFunctiontype alias

Section titled “FetchFunction”
Signature
type FetchFunction = typeof globalThis.fetch;

Fetch implementation supplied to the provider adapter.


ProviderResponsetype alias

Section titled “ProviderResponse”
Signature
type ProviderResponse = object;

HTTP status and headers observed before stream consumption.

Signature
status: number;
Signature
headers: Record<string, string>;

ProviderRequestOptionstype alias

Section titled “ProviderRequestOptions”
Signature
type ProviderRequestOptions<TModel> = object;

Authentication, transport and lifecycle hooks for one provider request.

Type Parameter Default type
TModel Model<Api>
Signature
optional signal?: AbortSignal;
Signature
optional telemetryContext?: TelemetryContext;
Signature
optional apiKey?: string;
Signature
optional fetch?: FetchFunction;

Override HTTP transport for this request.

Signature
optional env?: ProviderEnv;
Signature
optional onPayload?: (payload, model) =>
| ProviderData
| undefined
| Promise<ProviderData | undefined>;

Observe or replace the provider payload before dispatch.

Parameter Type
payload ProviderData
model TModel

| ProviderData | undefined | Promise<ProviderData | undefined>

Signature
optional onResponse?: (response, model) => void | Promise<void>;

Observe status and headers before provider stream consumption.

Parameter Type
response ProviderResponse
model TModel

void | Promise<void>

Signature
optional headers?: ProviderHeaders;
Signature
optional timeoutMs?: number;
Signature
optional maxRetries?: number;
Signature
optional maxRetryDelayMs?: number;

StreamOptionstype alias

Section titled “StreamOptions”
Signature
type StreamOptions = object & ProviderRequestOptions;

Common provider stream controls, independent of any SDK.

Name Type Description
onProviderStreamEvent()? (data, model) => void | Promise<void> Observe an adapter-parsed event before Pi normalizes it.
temperature? number -
samplingParams? SamplingParams -
maxTokens? number -
transport? Transport -
cacheRetention? CacheRetention -
sessionId? string -
websocketConnectTimeoutMs? number -
metadata? JsonObject -

SimpleStreamOptionstype alias

Section titled “SimpleStreamOptions”
Signature
type SimpleStreamOptions = object & StreamOptions;

Provider-neutral model request options used by Mule.

Name Type
toolChoice? ToolChoice
reasoning? ThinkingLevel
deferred? | boolean | { window?: "15m" | "1h" | "24h"; }
thinkingBudgets? ThinkingBudgets

TextContenttype alias

Section titled “TextContent”
Signature
type TextContent = object;

Text block with an optional provider continuity signature.

Signature
type: "text";
Signature
text: string;
Signature
optional textSignature?: string;

ThinkingContenttype alias

Section titled “ThinkingContent”
Signature
type ThinkingContent = object;

Reasoning block, including opaque redacted provider thinking.

Signature
type: "thinking";
Signature
thinking: string;
Signature
optional thinkingSignature?: string;
Signature
optional redacted?: boolean;

ImageContenttype alias

Section titled “ImageContent”
Signature
type ImageContent = object;

Base64 image bytes with their media type.

Signature
type: "image";
Signature
data: string;
Signature
mimeType: string;

Signature
type ToolCall = object;

Model-requested tool invocation with JSON arguments.

Signature
type: "toolCall";
Signature
id: string;
Signature
name: string;
Signature
arguments: JsonObject;
Signature
optional thoughtSignature?: string;
Signature
optional namespace?: string;
Signature
optional argumentsError?: string;

Signature
type Usage = object;

Token counts and provider costs for one response or tool result.

Signature
input: number;
Signature
output: number;
Signature
cacheRead: number;
Signature
cacheWrite: number;
Signature
optional cacheWrite1h?: number;
Signature
optional reasoning?: number;
Signature
totalTokens: number;
Signature
cost: object;
Signature
input: number;
Signature
output: number;
Signature
cacheRead: number;
Signature
cacheWrite: number;
Signature
total: number;

StopReasontype alias

Section titled “StopReason”
Signature
type StopReason =
"pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";

Provider outcome for an assistant response.


JsonValuetype alias

Section titled “JsonValue”
Signature
type JsonValue =
null | boolean | number | string | readonly JsonValue[] | JsonObject;

JSON data carried by messages and tool results.


ProviderValuetype alias

Section titled “ProviderValue”
Signature
type ProviderValue =
| undefined
| null
| boolean
| number
| string
| Uint8Array
| AbortSignal
| readonly ProviderValue[]
| ProviderData;

Provider request/event values, including optional fields, binary bytes and cancellation.


ProviderDatatype alias

Section titled “ProviderData”
Signature
type ProviderData = object;

Parsed provider request or event fields; Pi owns the provider-specific grammar.

Signature
[key: string]: ProviderValue

JsonObjecttype alias

Section titled “JsonObject”
Signature
type JsonObject = object;

Named JSON properties in tool arguments or message metadata.

Signature
[key: string]: JsonValue

DeferredHandletype alias

Section titled “DeferredHandle”
Signature
type DeferredHandle = object;

Provider receipt used to recover a deferred assistant response.

Signature
provider: string;
Signature
modelId: string;
Signature
api: string;
Signature
id: string;
Signature
optional expiresAt?: number;
Signature
optional pollAfterMs?: number;
Signature
optional data?: JsonValue;

SystemMessagetype alias

Section titled “SystemMessage”
Signature
type SystemMessage = object;

Prompt and tool-set update at a point in the transcript.

Signature
role: "system";
Signature
content: string | TextContent[];
Signature
optional sections?: Record<string, string | null>;
Signature
optional toolsAdded?: Tool[];
Signature
optional toolsRemoved?: ToolReference[];
Signature
timestamp: number;

UserMessagetype alias

Section titled “UserMessage”
Signature
type UserMessage = object;

User text and image input with its timestamp.

Signature
role: "user";
Signature
content:
| string
| (TextContent | ImageContent)[];
Signature
timestamp: number;

AssistantMessagetype alias

Section titled “AssistantMessage”
Signature
type AssistantMessage = object;

Provider response, usage and terminal reason, preserved by Mule.

Signature
role: "assistant";
Signature
content: (
| TextContent
| ThinkingContent
| ToolCall)[];
Signature
api: Api;
Signature
provider: ProviderId;
Signature
model: string;
Signature
optional responseModel?: string;
Signature
optional responseId?: string;
Signature
optional providerThinkingLevel?: string;
Signature
optional thinkingLevel?: ModelThinkingLevel;
Signature
optional diagnostics?: AssistantMessageDiagnostic[];
Signature
usage: Usage;
Signature
stopReason: StopReason;
Signature
optional deferred?: DeferredHandle;
Signature
optional errorMessage?: string;
Signature
optional providerError?: string;

Provider prose for the failed conversation turn, never a diagnostic.

Signature
optional rawStopReason?: string;
Signature
optional endTurn?: boolean;
Signature
timestamp: number;
Signature
optional durationMs?: number;

NestedToolCallRecordtype alias

Section titled “NestedToolCallRecord”
Signature
type NestedToolCallRecord = object;

Bounded evidence of a tool invocation made inside another tool.

Signature
id: string;
Signature
name: string;
Signature
optional arguments?: JsonObject;
Signature
optional argumentsBytes?: number;
Signature
status: "ok" | "error" | "unfinished";
Signature
optional durationMs?: number;
Signature
optional error?: string;

NestedToolCallstype alias

Section titled “NestedToolCalls”
Signature
type NestedToolCalls = object;

Recorded nested invocations and whether the record is complete.

Signature
calls: NestedToolCallRecord[];
Signature
complete: boolean;

ToolResultMessagetype alias

Section titled “ToolResultMessage”
Signature
type ToolResultMessage = object;

Correlated tool output with optional JSON details and usage.

Signature
role: "toolResult";
Signature
toolCallId: string;
Signature
toolName: string;
Signature
content: (TextContent | ImageContent)[];
Signature
optional details?: JsonValue;
Signature
optional usage?: Usage;
Signature
optional nestedCalls?: NestedToolCalls;
Signature
isError: boolean;
Signature
timestamp: number;
Signature
optional durationMs?: number;

Signature
type Message =
SystemMessage | UserMessage | AssistantMessage | ToolResultMessage;

One system, user, assistant or tool-result transcript entry.


GrammarFormattype alias

Section titled “GrammarFormat”
Signature
type GrammarFormat = "openai_lark" | "openai_regex";

Provider grammar formats available for constrained sampling.


GrammarVariantstype alias

Section titled “GrammarVariants”
Signature
type GrammarVariants = Partial<Record<GrammarFormat, string>>;

Grammar text supplied for each supported provider format.


ConstrainedSamplingConfigtype alias

Section titled “ConstrainedSamplingConfig”
Signature
type ConstrainedSamplingConfig =
| {
type: "json_schema";
strict: "prefer" | "require";
}
| {
type: "grammar";
variants: GrammarVariants;
};

Provider constraint for a tool declaration.


Signature
type Tool<TParameters> = object;

Model-visible tool name, description and TypeBox argument schema.

Type Parameter Default type
TParameters extends TSchema TSchema
Signature
name: string;
Signature
description: string;
Signature
parameters: TParameters;
Signature
optional constrainedSampling?: false | ConstrainedSamplingConfig;

ToolReferencetype alias

Section titled “ToolReference”
Signature
type ToolReference = object;

Named tool removed by a transcript system update.

Signature
name: string;

Signature
type Context = object;

Model request context; Pi adapters normalize it before provider dispatch.

Signature
optional systemPrompt?: string;
Signature
messages: Message[];
Signature
optional tools?: Tool[];

AssistantMessageEventtype alias

Section titled “AssistantMessageEvent”
Signature
type AssistantMessageEvent =
| {
type: "start";
partial: AssistantMessage;
}
| {
type: "text_start";
contentIndex: number;
partial: AssistantMessage;
}
| {
type: "text_delta";
contentIndex: number;
delta: string;
partial: AssistantMessage;
}
| {
type: "text_end";
contentIndex: number;
content: string;
partial: AssistantMessage;
}
| {
type: "thinking_start";
contentIndex: number;
partial: AssistantMessage;
}
| {
type: "thinking_delta";
contentIndex: number;
delta: string;
partial: AssistantMessage;
}
| {
type: "thinking_end";
contentIndex: number;
content: string;
partial: AssistantMessage;
}
| {
type: "toolcall_start";
contentIndex: number;
partial: AssistantMessage;
}
| {
type: "toolcall_delta";
contentIndex: number;
delta: string;
partial: AssistantMessage;
}
| {
type: "toolcall_end";
contentIndex: number;
toolCall: ToolCall;
partial: AssistantMessage;
}
| {
type: "done";
reason: Extract<StopReason, "stop" | "length" | "toolUse" | "deferred">;
message: AssistantMessage;
}
| {
type: "error";
reason: Extract<StopReason, "aborted" | "error">;
error: AssistantMessage;
};

Partial updates and the terminal event for an assistant stream.


BaseModeltype alias

Section titled “BaseModel”
Signature
type BaseModel<TApi> = object;

Catalog fields shared by chat model definitions.

Type Parameter
TApi extends string
Signature
id: string;
Signature
name: string;
Signature
api: TApi;
Signature
provider: ProviderId;
Signature
baseUrl: string;
Signature
input: ModelInputModality[];
Signature
optional inputLimits?: ModelInputLimits;
Signature
cost: ModelCost;
Signature
optional headers?: Record<string, string>;

Signature
type Model<TApi> = object & BaseModel<TApi>;

Chat model configuration accepted by Mule and its Pi adapter.

Name Type
type? "chat"
reasoning boolean
thinkingLevelMap? ThinkingLevelMap
promptCache? ModelPromptCache
contextWindow number
maxTokens number
samplingParams? SamplingParams
samplingParamsByThinkingLevel? SamplingParamsByThinkingLevel
compat? TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends | "openai-responses" | "azure-openai-responses" | "openai-codex-responses" ? OpenAIResponsesCompat : TApi extends "anthropic-messages" ? AnthropicMessagesCompat : TApi extends "bedrock-converse-stream" ? BedrockCompat : TApi extends "mistral-conversations" ? MistralConversationsCompat : never
Type Parameter
TApi extends Api

DiagnosticErrorInfotype alias

Section titled “DiagnosticErrorInfo”
Signature
type DiagnosticErrorInfo = object;

Serializable diagnostic information retained with an assistant message.

Signature
optional name?: string;
Signature
message: string;
Signature
optional stack?: string;
Signature
optional code?: string | number;

AssistantMessageDiagnostictype alias

Section titled “AssistantMessageDiagnostic”
Signature
type AssistantMessageDiagnostic = object;

Timestamped provider diagnostic with optional JSON details.

Signature
type: string;
Signature
timestamp: number;
Signature
optional error?: DiagnosticErrorInfo;
Signature
optional details?: JsonObject;

AssistantMessageEventStreamtype alias

Section titled “AssistantMessageEventStream”
Signature
type AssistantMessageEventStream = object &
AsyncIterable<AssistantMessageEvent>;

Only the stream operations consumed by Mule. Pi’s concrete stream satisfies this port.

Name Type Description
result() () => Promise<AssistantMessage> Await the authoritative final assistant message.

RetryPolicytype alias

Section titled “RetryPolicy”
Signature
type RetryPolicy = object;

Bounded assistant-call retries with capped exponential delays.

Signature
enabled: boolean;
Signature
maxRetries: number;
Signature
baseDelayMs: number;
Signature
optional maxAgentDelayMs?: number;

AttributeValuetype alias

Section titled “AttributeValue”
Signature
type AttributeValue =
| string
| number
| boolean
| readonly string[]
| readonly number[]
| readonly boolean[];

Scalar or homogeneous-array telemetry attribute.


SpanAttributestype alias

Section titled “SpanAttributes”
Signature
type SpanAttributes = Record<string, AttributeValue | undefined>;

Named telemetry attributes, with undefined values omitted by the owner.


SpanOptionstype alias

Section titled “SpanOptions”
Signature
type SpanOptions = object;

Name and initial attributes of a request telemetry span.

Signature
name: string;
Signature
optional attributes?: SpanAttributes;

SpanStatustype alias

Section titled “SpanStatus”
Signature
type SpanStatus =
| {
status: "ok";
}
| {
status: "error";
error?: {
name: string;
message: string;
};
};

Successful or failed telemetry completion.


TelemetryContexttype alias

Section titled “TelemetryContext”
Signature
type TelemetryContext = object;

Parent context through which a provider opens telemetry spans.

Signature
startSpan<T>(options, callback): Promise<T>;

Run provider work under a child span.

Type Parameter
T
Parameter Type
options SpanOptions
callback (span) => T | Promise<T>

Promise<T>


TelemetrySpantype alias

Section titled “TelemetrySpan”
Signature
type TelemetrySpan = object & TelemetryContext;

Provider telemetry span with events, attributes and completion status.

Name Type Description
addEvent() (name, attributes?) => void Record a timestamped event on this span.
setAttributes() (attributes) => void Add or replace attributes on this span.
setStatus() (status) => void Record the completion status of this span.

piCodingAgentRetryDefaultsconstant

Section titled “piCodingAgentRetryDefaults”
Signature
const piCodingAgentRetryDefaults: 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.


muleEffectconstant

Section titled “muleEffect”
Signature
const muleEffect: MuleEffect;

Canonical Effect-native Mule value.

isContextOverflow()function

Section titled “isContextOverflow()”
Signature
function isContextOverflow(message, contextWindow?): boolean;

Apply Pi’s maintained context-overflow semantics to an exact Pi message.

Parameter Type
message AssistantMessage
contextWindow? number

boolean


Signature
function run(input, listener?): Effect<MuleRunOutcome, MuleError>;

Run Pi’s model/tool loop inside Effect without changing Pi’s values.

Parameter Type Default value
input MuleRunInput undefined
listener MuleListener noListener

Effect<MuleRunOutcome, MuleError>

Re-exports decodeProviderData


Re-exports streamModel


Re-exports isRetryableProviderRejection


Re-exports observeProviderStatus


Re-exports ProviderRejection


Re-exports ProviderStatusRecorder


Re-exports normalizeModel


Re-exports MuleCompletedTurn


Re-exports MuleResume


Re-exports MuleToolCheckpoint


Re-exports MuleError


Re-exports MuleEvent


Re-exports MuleIdentity


Re-exports MuleIdentityKind


Re-exports MuleRunOutcome


Re-exports MuleRunSettings


Re-exports MuleStreamFunction


Re-exports MuleToolExecutionPart


Re-exports MuleToolRejection


Re-exports MuleToolResult