(u: unknown): u is ExecutionPlan<any>Returns true if a value is an ExecutionPlan by checking for the
ExecutionPlan.TypeId marker.
When to use
Use when accepting an unknown value and you need to narrow it to an
ExecutionPlan before reading plan fields or passing it to plan-consuming
APIs.
Gotchas
This is a structural marker check; it does not validate the marker value or the shape of the plan steps.
export const const isExecutionPlan: (
u: unknown
) => u is ExecutionPlan<any>
Returns true if a value is an ExecutionPlan by checking for the
ExecutionPlan.TypeId marker.
When to use
Use when accepting an unknown value and you need to narrow it to an
ExecutionPlan before reading plan fields or passing it to plan-consuming
APIs.
Gotchas
This is a structural marker check; it does not validate the marker value or
the shape of the plan steps.
isExecutionPlan = (u: unknownu: unknown): u: unknownu is interface ExecutionPlan<Config extends { provides: any; input: any; error: any; requirements: any; }>A ExecutionPlan can be used with Effect.withExecutionPlan or Stream.withExecutionPlan, allowing you to provide different resources for each step of execution until the effect succeeds or the plan is exhausted.
Example (Defining fallback execution steps)
import { Effect, ExecutionPlan, Schedule } from "effect"
import type { Layer } from "effect"
import type { LanguageModel } from "effect/unstable/ai"
declare const layerBad: Layer.Layer<LanguageModel.LanguageModel>
declare const layerGood: Layer.Layer<LanguageModel.LanguageModel>
const ThePlan = ExecutionPlan.make(
{
// First try with the bad layer 2 times with a 3 second delay between attempts
provide: layerBad,
attempts: 2,
schedule: Schedule.spaced(3000)
},
// Then try with the bad layer 3 times with a 1 second delay between attempts
{
provide: layerBad,
attempts: 3,
schedule: Schedule.spaced(1000)
},
// Finally try with the good layer.
//
// If `attempts` is omitted, the plan will only attempt once, unless a schedule is provided.
{
provide: layerGood
}
)
declare const effect: Effect.Effect<
void,
never,
LanguageModel.LanguageModel
>
const withPlan: Effect.Effect<void> = Effect.withExecutionPlan(effect, ThePlan)
ExecutionPlan<any> => import PredicatePredicate.const hasProperty: <"~effect/ExecutionPlan">(self: unknown, property: "~effect/ExecutionPlan") => self is { [K in "~effect/ExecutionPlan"]: unknown; } (+1 overload)hasProperty(u: unknownu, const TypeId: TypeIdString literal type used as the runtime type identifier for ExecutionPlan
values.
Runtime type identifier attached to ExecutionPlan values and used by
isExecutionPlan.
TypeId)