@statelyai/agent 1.1.6 → 2.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapter.cjs +15 -0
  3. package/dist/adapter.d.cts +4 -0
  4. package/dist/adapter.d.mts +4 -0
  5. package/dist/adapter.mjs +2 -0
  6. package/dist/ai-sdk.cjs +306 -0
  7. package/dist/ai-sdk.d.cts +96 -0
  8. package/dist/ai-sdk.d.mts +96 -0
  9. package/dist/ai-sdk.mjs +304 -0
  10. package/dist/decision-C3k4ve51.mjs +227 -0
  11. package/dist/decision-D8wJrM8W.cjs +286 -0
  12. package/dist/events-CRQj3VtP.cjs +1010 -0
  13. package/dist/events-JiVPYrct.mjs +759 -0
  14. package/dist/index.cjs +2528 -0
  15. package/dist/index.d.cts +1232 -0
  16. package/dist/index.d.mts +1217 -413
  17. package/dist/index.mjs +2489 -584
  18. package/dist/openai-compat.cjs +309 -0
  19. package/dist/openai-compat.d.cts +59 -0
  20. package/dist/openai-compat.d.mts +59 -0
  21. package/dist/openai-compat.mjs +308 -0
  22. package/dist/steps-BALp1eZo.d.mts +198 -0
  23. package/dist/steps-CVe54GPP.cjs +420 -0
  24. package/dist/steps-CkyyyuHd.mjs +379 -0
  25. package/dist/steps-MjnQI4aB.d.cts +198 -0
  26. package/dist/steps.cjs +12 -0
  27. package/dist/steps.d.cts +3 -0
  28. package/dist/steps.d.mts +3 -0
  29. package/dist/steps.mjs +3 -0
  30. package/dist/text-logic-CaKqgX4Y.d.mts +710 -0
  31. package/dist/text-logic-Ckhr2kKC.d.cts +710 -0
  32. package/dist/types-C9QiMjre.d.cts +219 -0
  33. package/dist/types-qm00QF91.d.mts +219 -0
  34. package/dist/utils-BYqT_Dyv.d.cts +108 -0
  35. package/dist/utils-Do5wIJrh.d.mts +108 -0
  36. package/dist/zod.cjs +31 -0
  37. package/dist/zod.d.cts +30 -0
  38. package/dist/zod.d.mts +30 -0
  39. package/dist/zod.mjs +30 -0
  40. package/package.json +132 -28
  41. package/readme.md +153 -6
  42. package/schemas/agent-workflow.json +526 -0
  43. package/.changeset/README.md +0 -8
  44. package/.changeset/config.json +0 -11
  45. package/.env.template +0 -3
  46. package/.github/actions/ci-setup/action.yml +0 -24
  47. package/.github/workflows/release.yml +0 -46
  48. package/.vscode/launch.json +0 -28
  49. package/CHANGELOG.md +0 -222
  50. package/dist/index.d.ts +0 -428
  51. package/dist/index.js +0 -621
  52. package/examples/chatbot.ts +0 -71
  53. package/examples/cot.ts +0 -89
  54. package/examples/email.ts +0 -118
  55. package/examples/example.ts +0 -81
  56. package/examples/goal.ts +0 -94
  57. package/examples/helpers/helpers.ts +0 -17
  58. package/examples/helpers/loader.ts +0 -32
  59. package/examples/helpers/runner.ts +0 -27
  60. package/examples/joke.ts +0 -225
  61. package/examples/multi.ts +0 -103
  62. package/examples/newspaper.ts +0 -324
  63. package/examples/number.ts +0 -102
  64. package/examples/raffle.ts +0 -105
  65. package/examples/sandbox.ts +0 -28
  66. package/examples/simple.ts +0 -39
  67. package/examples/support.ts +0 -147
  68. package/examples/ticTacToe.ts +0 -224
  69. package/examples/todo.ts +0 -137
  70. package/examples/tutor.ts +0 -100
  71. package/examples/verify.ts +0 -120
  72. package/examples/weather.ts +0 -178
  73. package/examples/wiki.ts +0 -30
  74. package/examples/word.ts +0 -171
  75. package/src/adapters/vercel.ts +0 -7
  76. package/src/agent-experimental.ts +0 -221
  77. package/src/agent.test.ts +0 -506
  78. package/src/agent.ts +0 -300
  79. package/src/decision.test.ts +0 -179
  80. package/src/decision.ts +0 -84
  81. package/src/index.ts +0 -4
  82. package/src/memory.ts +0 -25
  83. package/src/planners/shortestPathPlanner.ts +0 -22
  84. package/src/planners/simplePlanner.ts +0 -139
  85. package/src/schemas.ts +0 -11
  86. package/src/strategies/chain-of-note.ts +0 -155
  87. package/src/templates/defaultText.ts +0 -18
  88. package/src/text.ts +0 -241
  89. package/src/types.ts +0 -499
  90. package/src/utils.ts +0 -72
  91. package/tsconfig.json +0 -109
  92. package/vitest.config.ts +0 -9
@@ -0,0 +1,710 @@
1
+ import { C as StandardSchemaV1, b as InferOutput, f as AllowedEvents, m as ChosenEvent, o as AgentToolChoice, r as AgentMessage, u as AgentTools } from "./types-C9QiMjre.cjs";
2
+ import { AnyMachineSnapshot, AsyncActorLogic, EventObject, LogicActorLogic, MachineSnapshot } from "xstate";
3
+
4
+ //#region src/events.d.ts
5
+ /** The invoke `src` of an {@link AgentRequest}/{@link AgentDecisionRequest} — a plain string, widened so literal `src` values still narrow in editor hints. */
6
+ type AgentRequestSource = string & {};
7
+ /** Customizes the tool name generated for a candidate event; see {@link AgentRequestOptions.eventToolName}. */
8
+ type AgentEventToolNameResolver = (args: {
9
+ eventType: string;
10
+ defaultToolName: string;
11
+ }) => string;
12
+ /**
13
+ * True when an event type matches an `allowedEvents` entry: an exact type,
14
+ * `'*'` (every event), or a `'prefix.*'` wildcard matching any deeper
15
+ * segment (`'todo.*'` matches `'todo.add'` and `'todo.list.clear'`, not
16
+ * `'todo'` itself — mirroring xstate's partial wildcard events).
17
+ */
18
+ declare function matchesEventPattern(eventType: string, pattern: string): boolean;
19
+ /** One candidate event a decision (or {@link getAcceptedEvents} caller) may choose: its type, the synthetic tool name a model can call to pick it, and its payload schema if one is registered. */
20
+ interface AgentEventDescriptor {
21
+ type: string;
22
+ toolName: string;
23
+ inputSchema?: StandardSchemaV1;
24
+ }
25
+ /** Registered event payload schemas, as attached to a machine by `setupAgent`/`createAgentSchemas`. */
26
+ interface AgentSchemas {
27
+ events?: Record<string, StandardSchemaV1>;
28
+ }
29
+ /** Shared options threaded through step discovery ({@link getAgentRequests}/{@link getAcceptedEvents}) — snapshot for event legality, event schemas for payload validation/tool schemas, and registered actor source logics. */
30
+ interface AgentRequestOptions {
31
+ snapshot?: AnyMachineSnapshot;
32
+ events?: Record<string, StandardSchemaV1>;
33
+ schemas?: AgentSchemas;
34
+ actorSources?: Record<string, unknown>;
35
+ /** Customize machine-event tool names. Defaults to send_event_<TYPE>. */
36
+ eventToolName?: AgentEventToolNameResolver;
37
+ }
38
+ /**
39
+ * Lists the events a snapshot can currently accept, as {@link AgentEventDescriptor}s
40
+ * a model can be offered (via `resolveDecision`/an adapter's tool-per-event
41
+ * mapping). **Filters by event TYPE only** — it does not evaluate guards, so
42
+ * a type-legal-but-guard-rejected event can still appear here. Guard
43
+ * legality is checked separately, at decision-resolution time, via
44
+ * `snapshot.can(event)` (the `canTake` option of {@link resolveDecision} /
45
+ * {@link ResolveDecisionOptions}). Pass `eventTypes` to further narrow to a
46
+ * declared `allowedEvents` set — entries may be exact types or wildcard
47
+ * patterns (`'*'`, `'todo.*'`; see {@link matchesEventPattern}).
48
+ */
49
+ /** Recovers a machine's event union from its snapshot type, so {@link parseAgentEvent} returns the machine-typed event without a downstream cast. @internal */
50
+ type EventFromSnapshot<TSnapshot> = TSnapshot extends MachineSnapshot<any, infer TEvent, any, any, any, any, any, any> ? TEvent : EventObject;
51
+ /**
52
+ * Runtime-validates a dynamically-built `{ type, ...payload }` event against a
53
+ * snapshot's currently-accepted events (via {@link getAcceptedEvents}) and,
54
+ * when one is registered, the event type's payload schema — returning the
55
+ * event typed as the machine's event union (recovered from the snapshot type)
56
+ * so it can be sent to `runAgent({ event })` / `actor.send(...)` without an
57
+ * `as never` cast. For generic, meta-driven hosts that assemble events from
58
+ * user input or a wire message.
59
+ *
60
+ * Throws a descriptive error when `event.type` is not currently accepted
61
+ * (listing the accepted types) or when its payload fails the registered schema.
62
+ * Pass event payload schemas via `options.events`/`options.schemas` (the same
63
+ * shape {@link getAcceptedEvents} takes) — the accepted TYPES always come from
64
+ * the live snapshot; the schemas only add payload validation.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const event = parseAgentEvent(result.snapshot, rawEvent, { events: schemas.events });
69
+ * result = await runAgent(machine, { snapshot: result.snapshot, event, executors });
70
+ * ```
71
+ */
72
+ declare function parseAgentEvent<TSnapshot extends AnyMachineSnapshot>(snapshot: TSnapshot, event: {
73
+ type: string;
74
+ } & Record<string, unknown>, options?: Pick<AgentRequestOptions, "events" | "schemas" | "eventToolName">): EventFromSnapshot<TSnapshot>;
75
+ declare function getAcceptedEvents(snapshot: AnyMachineSnapshot, options?: Pick<AgentRequestOptions, "events" | "schemas" | "eventToolName"> & {
76
+ eventTypes?: readonly string[];
77
+ }): AgentEventDescriptor[];
78
+ //#endregion
79
+ //#region src/decision.d.ts
80
+ /**
81
+ * Inline input for the `agent.decide` builtin actor — the zero-config
82
+ * counterpart to {@link createDecisionLogic}, invoked directly from a
83
+ * state's `invoke.input` (typed against the machine's own event schemas).
84
+ * See {@link AgentDecisionRequest} for the request shape this lowers to.
85
+ */
86
+ interface AgentDecisionInput<TEvent extends string = string, TMetadata = Record<string, unknown>, TModel extends string = string> {
87
+ model: TModel;
88
+ system?: string;
89
+ prompt?: string;
90
+ messages?: AgentMessage[];
91
+ allowedEvents?: AllowedEvents<TEvent>;
92
+ maxRetries?: number;
93
+ temperature?: number;
94
+ maxOutputTokens?: number;
95
+ topP?: number;
96
+ topK?: number;
97
+ seed?: number;
98
+ stopSequences?: string[];
99
+ metadata?: TMetadata;
100
+ }
101
+ /**
102
+ * Inline input for the `agent.plan` builtin actor — a multi-event decision.
103
+ * Where `agent.decide` picks exactly one currently-legal event, `agent.plan`
104
+ * applies an ordered sequence of them: each step re-reads the live snapshot,
105
+ * asks the `decide` executor for one legal event (same validation and
106
+ * `rejected-by-guard` retry loop as a decision), sends it to the machine,
107
+ * and repeats until a `stopOn` event is chosen, `maxSteps` is reached, no
108
+ * legal candidate remains, or an applied event exits the invoking state
109
+ * (which cancels the invoke — the machine simply moves on).
110
+ *
111
+ * Requires a snapshot-aware host: {@link runAgent}, or the step path (where an
112
+ * `agent.plan` invoke re-surfaces as a `kind: 'plan'` request that
113
+ * `resolveAgentRequests` drives one step per call).
114
+ */
115
+ interface AgentPlanInput<TEvent extends string = string, TMetadata = Record<string, unknown>, TModel extends string = string> extends AgentDecisionInput<TEvent, TMetadata, TModel> {
116
+ /** Maximum events applied in one plan. Default 8. */
117
+ maxSteps?: number;
118
+ /**
119
+ * Machine events that end the plan once chosen: the event is still
120
+ * validated and sent, then the loop stops. Usually unnecessary — every
121
+ * plan step already offers the built-in {@link PLAN_DONE_EVENT_TYPE}
122
+ * "done" option, which ends the plan without touching the machine.
123
+ * Declare `stopOn` only for "send this real event AND stop" semantics.
124
+ */
125
+ stopOn?: readonly TEvent[];
126
+ }
127
+ /**
128
+ * Reserved event type the `agent.plan` builtin adds to every step's
129
+ * candidates as the explicit "no further action needed" move. Choosing it
130
+ * ends the plan (`stopped: 'done'`); it is never sent to the machine, so
131
+ * machines need no no-op sentinel event of their own.
132
+ */
133
+ declare const PLAN_DONE_EVENT_TYPE: "agent.plan.done";
134
+ /** What an `agent.plan` invoke resolves with (its `onDone` output). */
135
+ interface AgentPlanOutput {
136
+ /** The events applied, in order (possibly empty). */
137
+ steps: ChosenEvent[];
138
+ /** Why the loop ended. */
139
+ stopped: "done" | "stop-event" | "max-steps" | "no-legal-events";
140
+ }
141
+ /**
142
+ * The in-progress state of a plan, held in the `agent.plan` invoke child's own
143
+ * `createLogic` snapshot `context`. Because a `createLogic` snapshot serializes
144
+ * (and restores) by identity, this lands at
145
+ * `children.<planId>.snapshot.context` in a machine's persisted snapshot for
146
+ * free — so a step-path host that persists after every event resumes a plan
147
+ * mid-flight without a bespoke carrier.
148
+ */
149
+ interface PlanLedgerContext {
150
+ /** The events applied so far in this plan, in order (the trail). */
151
+ applied: ChosenEvent[];
152
+ /** How many more events the plan may apply (`maxSteps - applied.length`). */
153
+ stepsRemaining: number;
154
+ /** Set once the plan terminates; `null` while in flight. */
155
+ stopped: AgentPlanOutput["stopped"] | null;
156
+ }
157
+ /**
158
+ * The two ledger events that drive a {@link PlanLedgerContext} forward:
159
+ * `plan.applied` appends one event to the trail and decrements the budget;
160
+ * `plan.ended` records the stop reason and completes the ledger (its snapshot
161
+ * goes `done` with the {@link AgentPlanOutput}).
162
+ */
163
+ type PlanLedgerEvent = {
164
+ type: "plan.applied";
165
+ event: ChosenEvent;
166
+ } | {
167
+ type: "plan.ended";
168
+ stopped: AgentPlanOutput["stopped"];
169
+ };
170
+ /**
171
+ * Actor logic for the `agent.plan` builtin: a stateful, transition-based
172
+ * ledger. Its snapshot `context` ({@link PlanLedgerContext}) IS the plan's
173
+ * in-progress state — the applied trail plus remaining budget — advanced one
174
+ * {@link PlanLedgerEvent} at a time. On the step path the invoke child runs this
175
+ * logic directly (so its context persists at `children.<id>.snapshot.context`);
176
+ * runAgent swaps in an async implementation that drives the SAME ledger via the
177
+ * shared {@link initialPlanLedger}/{@link advancePlanLedger} drivers.
178
+ */
179
+ interface PlanLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1<AgentPlanInput>> extends LogicActorLogic<PlanLedgerContext, AgentPlanOutput, PlanLedgerEvent, InferOutput<TInputSchema>> {
180
+ readonly kind: "statelyai.planLogic";
181
+ readonly maxRetries: number;
182
+ /** Builds the per-step base {@link AgentDecisionRequest} (id/events filled in per step). */
183
+ request(input: InferOutput<TInputSchema>): AgentDecisionRequest;
184
+ /** @internal Resolves declared `allowedEvents` (undefined = all currently legal). */
185
+ allowedEventTypes(input: InferOutput<TInputSchema>): readonly string[] | undefined;
186
+ }
187
+ /**
188
+ * Config for {@link createDecisionLogic}: how to build an
189
+ * {@link AgentDecisionRequest} from typed input. Each field mirrors
190
+ * {@link TextLogicConfig} (static value or a `({ input }) => value`
191
+ * resolver), plus `allowedEvents` to narrow the candidate event set (see
192
+ * {@link AllowedEvents}) and `maxRetries` for {@link resolveDecision}.
193
+ */
194
+ interface DecisionLogicConfig<TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TEvent extends string = string, TMetadata extends Record<string, unknown> = Record<string, unknown>, TModel extends string = string> {
195
+ schemas?: {
196
+ input: TInputSchema;
197
+ };
198
+ model: ResolveTextLogicValue<TModel, InferOutput<TInputSchema>>;
199
+ system?: ResolveTextLogicValue<string | undefined, InferOutput<TInputSchema>>;
200
+ prompt?: ResolveTextLogicValue<string | undefined, InferOutput<TInputSchema>>;
201
+ messages?: ResolveTextLogicValue<AgentMessage[] | undefined, InferOutput<TInputSchema>>;
202
+ allowedEvents?: AllowedEvents<TEvent, InferOutput<TInputSchema>>;
203
+ maxRetries?: number;
204
+ temperature?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
205
+ maxOutputTokens?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
206
+ topP?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
207
+ topK?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
208
+ seed?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
209
+ stopSequences?: ResolveTextLogicValue<string[] | undefined, InferOutput<TInputSchema>>;
210
+ metadata?: ResolveTextLogicValue<TMetadata | undefined, InferOutput<TInputSchema>>;
211
+ }
212
+ /**
213
+ * Actor logic for a decision: an async effect that resolves to exactly one
214
+ * currently-legal {@link ChosenEvent} (never a plain value). Under `runAgent`
215
+ * the chosen event is delivered to the invoking actor automatically — the
216
+ * transition it triggers usually exits the invoking state and ends the invoke.
217
+ * Built by {@link createDecisionLogic}. Register it under `actorSources:` to reuse/export/
218
+ * test it standalone; for a state-local, zero-config decision, use the
219
+ * `agent.decide` builtin invoke instead.
220
+ */
221
+ interface DecisionLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetadata extends Record<string, unknown> = Record<string, unknown>> extends AsyncActorLogic<ChosenEvent, InferOutput<TInputSchema>> {
222
+ readonly kind: "statelyai.decisionLogic";
223
+ readonly maxRetries: number;
224
+ request(input: InferOutput<TInputSchema>): AgentDecisionRequest;
225
+ withExecutor(execute: AgentDecisionExecutor): DecisionLogic<TInputSchema, TMetadata>;
226
+ }
227
+ /**
228
+ * A decision request: resolves to exactly one currently-legal event. See
229
+ * `resolveDecision`.
230
+ */
231
+ interface AgentDecisionRequest {
232
+ kind: "decision";
233
+ /** Durable invoke id. */
234
+ id: string;
235
+ model: string;
236
+ system?: string;
237
+ prompt?: string;
238
+ messages?: AgentMessage[];
239
+ /** Candidate events: declared `allowedEvents` ∩ snapshot-legal events. */
240
+ events: AgentEventDescriptor[];
241
+ /**
242
+ * Prior failed attempts for THIS decision. Empty on the first attempt.
243
+ * Adapters render these into the provider request so retries converge.
244
+ * Core never rewrites prompts/messages — attempts are data on the request.
245
+ */
246
+ attempts: DecisionAttempt[];
247
+ temperature?: number;
248
+ maxOutputTokens?: number;
249
+ topP?: number;
250
+ topK?: number;
251
+ seed?: number;
252
+ stopSequences?: string[];
253
+ metadata?: Record<string, unknown>;
254
+ /**
255
+ * Abort signal for the underlying model call, threaded through by
256
+ * {@link resolveDecision} from its `options.signal` so a `decide` executor
257
+ * can cancel the in-flight request (symmetric with the text executors'
258
+ * `info.signal`). Runtime-only — never serialized into a provider request.
259
+ */
260
+ signal?: AbortSignal;
261
+ }
262
+ /**
263
+ * A single failed decision attempt, recorded by {@link resolveDecision} and
264
+ * fed back to the executor on the next attempt via
265
+ * `request.attempts`. `failure` names which of the three checks rejected the
266
+ * choice: `'unknown-event'` (not among the candidate `events`),
267
+ * `'invalid-payload'` (failed the event's schema), or `'rejected-by-guard'`
268
+ * (failed the `canTake` check — type/payload were legal, but the machine's
269
+ * guard rejected it at apply time).
270
+ */
271
+ interface DecisionAttempt {
272
+ event?: ChosenEvent;
273
+ failure: "unknown-event" | "invalid-payload" | "rejected-by-guard";
274
+ reason: string;
275
+ }
276
+ /**
277
+ * Thrown by {@link resolveDecision} when every attempt (up to
278
+ * `maxRetries + 1` of them) fails one of the three checks recorded in
279
+ * {@link DecisionAttempt.failure}. Carries the full `attempts` list for
280
+ * diagnostics; a machine typically routes this via the decision invoke's
281
+ * `onError`.
282
+ */
283
+ declare class DecisionExhaustedError extends Error {
284
+ attempts: DecisionAttempt[];
285
+ constructor(attempts: DecisionAttempt[]);
286
+ }
287
+ /**
288
+ * Renders a decision request's prior failed `attempts` into feedback messages
289
+ * a host appends to the model call so retries converge — the transport-agnostic
290
+ * "your last choice failed because X, choose again from Y" logic every adapter
291
+ * and raw-SDK host repeats. Returns one `user`-role {@link AgentMessage} per
292
+ * attempt (empty when there are none); adapters map each onto their wire
293
+ * message shape (`attempt.content` is always a string). Core never rewrites the
294
+ * request itself — this only turns the recorded attempts into messages.
295
+ *
296
+ * @example
297
+ * ```ts
298
+ * const messages = [...baseMessages, ...renderDecisionAttempts(request)];
299
+ * ```
300
+ */
301
+ declare function renderDecisionAttempts(request: Pick<AgentDecisionRequest, "events" | "attempts">): AgentMessage[];
302
+ /**
303
+ * Host implementation of "make the model choose one of `request.events`."
304
+ * Third executor slot on {@link AgentRequestExecutors}, symmetric with
305
+ * `generateText`/`streamText` — how the model is coerced into choosing
306
+ * (tool-per-event + forced tool choice, structured output, …) is entirely
307
+ * adapter business; core only validates and retries the returned choice (see
308
+ * {@link resolveDecision}). The optional `reason` is carried through to
309
+ * `onResult`/event-sourcing but never affects validation. Like text
310
+ * executors' `{ output, ...extras }` envelope, any extra keys (usage, finish
311
+ * reason, …) flow untouched to `onResult`'s `raw`.
312
+ */
313
+ type AgentDecisionExecutor = (request: AgentDecisionRequest) => PromiseLike<{
314
+ event: ChosenEvent;
315
+ reason?: string;
316
+ [key: string]: unknown;
317
+ }>;
318
+ /**
319
+ * Options for {@link resolveDecision}. The `TEvent` parameter (the machine's
320
+ * event union, defaulting to the loose {@link ChosenEvent}) types both
321
+ * `canTake`'s argument and {@link resolveDecision}'s return — pass it (or let
322
+ * it infer from `canTake`) to get a machine-typed chosen event out without a
323
+ * downstream cast.
324
+ */
325
+ interface ResolveDecisionOptions<TEvent extends ChosenEvent = ChosenEvent> {
326
+ /** Retries after a failed attempt. Default `2`, so up to 3 attempts total. */
327
+ maxRetries?: number;
328
+ /** Checked before each attempt; aborting rejects the pending decision. */
329
+ signal?: AbortSignal;
330
+ /**
331
+ * Guard-legality check (mode 3), typically `(e) => snapshot.can(e)`. A
332
+ * type-and-payload-valid event that this rejects records a
333
+ * `'rejected-by-guard'` attempt and retries. Omit to skip guard checking
334
+ * (type + payload validation only — e.g. under bare `createActor`, where
335
+ * no snapshot is reachable). Typing its argument as the machine's event
336
+ * union (e.g. `(e: GameEvent) => snapshot.can(e)`) makes
337
+ * {@link resolveDecision} return that union.
338
+ */
339
+ canTake?: (event: TEvent) => boolean;
340
+ }
341
+ /**
342
+ * Validation + retry core for decisions. No provider mechanics — the
343
+ * `executor` is responsible for making the model choose an event; this
344
+ * function only validates the choice and retries on failure, up to
345
+ * `options.maxRetries` (default 2, i.e. up to 3 attempts total).
346
+ *
347
+ * Each attempt is checked in order and can fail one of three ways (recorded
348
+ * as a {@link DecisionAttempt}): `'unknown-event'` (the chosen `type` is not
349
+ * among `request.events`), `'invalid-payload'` (the payload fails that
350
+ * event's schema), or `'rejected-by-guard'` (passes both checks but
351
+ * `options.canTake` returns `false` — a type/payload-legal event the
352
+ * machine's guard rejects right now; omit `canTake` to skip this check).
353
+ * Every prior failed attempt for this call is fed back to the executor on
354
+ * the next attempt via `request.attempts`, so an adapter can render "your
355
+ * last choice failed because X — try again" into the next model call; core
356
+ * never rewrites the request itself. Exhausting all attempts throws
357
+ * {@link DecisionExhaustedError} with the full attempts list.
358
+ *
359
+ * @example
360
+ * ```ts
361
+ * const event = await resolveDecision(request, decide, {
362
+ * canTake: (e) => snapshot.can(e),
363
+ * });
364
+ * ```
365
+ */
366
+ declare function resolveDecision<TEvent extends ChosenEvent = ChosenEvent>(request: AgentDecisionRequest, executor: AgentDecisionExecutor, options?: ResolveDecisionOptions<TEvent>): Promise<TEvent>;
367
+ //#endregion
368
+ //#region src/text-logic.d.ts
369
+ declare const USER_INPUT_ACTOR: "agent.userInput";
370
+ declare const GENERATE_TEXT_ACTOR: "agent.generateText";
371
+ declare const STREAM_TEXT_ACTOR: "agent.streamText";
372
+ declare const DECIDE_ACTOR: "agent.decide";
373
+ declare const PLAN_ACTOR: "agent.plan";
374
+ /** Whether a text request should be resolved with `generateText` (one-shot) or `streamText` (chunked, via `onChunk`). */
375
+ type AgentRequestMode = "generate" | "stream";
376
+ /** A `setupAgent({ models })` model registry, mapping short model refs to provider-specific model values. */
377
+ type AgentModelMap = Record<string, unknown>;
378
+ /**
379
+ * A model reference: any string is legal, but a registered `models` map's keys
380
+ * autocomplete. Refs are opaque routing keys — the host/executor (or the AI SDK
381
+ * adapter's models map / `resolveModel`) resolves them to a real model.
382
+ */
383
+ type AgentModelRef<TModels extends AgentModelMap = {}> = [keyof TModels] extends [never] ? string : (keyof TModels & string) | (string & {});
384
+ /**
385
+ * Splits a portable `"provider/model-id"` model ref (the convention JSON
386
+ * workflows and registry-less hosts use, e.g. `"openai/gpt-5.4-mini"`) into
387
+ * its parts. A ref with no `/` has no provider — `modelId` is the whole ref.
388
+ * The standard building block for a host's `resolveModel`:
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * const resolveModel = (ref: string) => openai(parseModelRef(ref).modelId);
393
+ * ```
394
+ */
395
+ declare function parseModelRef(modelRef: string): {
396
+ provider: string | undefined;
397
+ modelId: string;
398
+ };
399
+ /**
400
+ * Portable, provider-agnostic input a text request passes to a host
401
+ * executor (`generateText`/`streamText` on {@link AgentRequestExecutors}).
402
+ * Built by {@link TextLogic.request} / `DecisionLogic.request` from a
403
+ * `TextLogicConfig`/`DecisionLogicConfig`; adapters (e.g.
404
+ * `createAiSdkExecutors`) map this shape onto their provider's call
405
+ * settings.
406
+ */
407
+ interface AgentTextRequest<TMetadata = Record<string, unknown>> {
408
+ /**
409
+ * The registered name of the request that produced this call — the
410
+ * `setupAgent({ requests })` key (also set by `setupAgent.fromConfig`), or
411
+ * `TextLogicConfig.name` for standalone `createTextLogic` actors. Hosts and
412
+ * test mocks can route on it instead of sniffing `system`/`prompt` text.
413
+ * Absent for ad-hoc `agent.generateText`/`agent.streamText` invokes unless
414
+ * the caller sets it on the inline input.
415
+ */
416
+ name?: string;
417
+ model: string;
418
+ system?: string;
419
+ prompt?: string;
420
+ messages?: AgentMessage[];
421
+ /** Host/model tools that are always available to this text call. */
422
+ tools?: AgentTools;
423
+ toolChoice?: AgentToolChoice;
424
+ outputSchema?: StandardSchemaV1;
425
+ /**
426
+ * Opt-in reasoning for a structured-output request: when `true`, adapters add
427
+ * an optional string `reasoning` property (listed BEFORE `result`) to the
428
+ * structured-output envelope schema, nudging the model to reason before
429
+ * committing to the result. The reasoning is surfaced on the executor's raw
430
+ * result (never in machine context/output). Ignored for text-mode requests.
431
+ */
432
+ reasoning?: boolean;
433
+ temperature?: number;
434
+ /**
435
+ * Maximum number of output tokens to generate. Named `maxOutputTokens` (not
436
+ * `maxTokens`) so an `AgentTextRequest` is spread-compatible with the Vercel
437
+ * AI SDK's `generateText`/`streamText` options.
438
+ */
439
+ maxOutputTokens?: number;
440
+ topP?: number;
441
+ topK?: number;
442
+ seed?: number;
443
+ stopSequences?: string[];
444
+ /**
445
+ * Host-owned per-call options. Use this for provider/runtime details such
446
+ * as Cloudflare bindings, tracing IDs, SDK provider options, or transport
447
+ * hints. The machine carries it; the host decides what it means — e.g.
448
+ * the AI SDK adapter (`createAiSdkExecutors`) reads `metadata.maxSteps` to
449
+ * bound its multi-step tool-call loop for that request.
450
+ */
451
+ metadata?: TMetadata;
452
+ }
453
+ /**
454
+ * Inline input for the `agent.userInput` builtin actor — a human-input request
455
+ * (CLI prompt, chat reply, …) that resolves to the `string` the human typed.
456
+ * See {@link RunAgentOptions.userInput}. For structured input, parse/classify
457
+ * the string in a follow-up state, or register a custom actor source; host
458
+ * rendering hints (a form spec, say) belong in `metadata`.
459
+ */
460
+ interface AgentUserInput<TMetadata = Record<string, unknown>> {
461
+ prompt?: string;
462
+ metadata?: TMetadata;
463
+ }
464
+ /** The five `agent.*` builtin actor logics every setupAgent-built machine registers. @internal */
465
+ type BuiltinAgentActors<TEvent extends string = string, TModel extends string = string> = {
466
+ [GENERATE_TEXT_ACTOR]: AsyncActorLogic<unknown, AgentTextRequest>;
467
+ [STREAM_TEXT_ACTOR]: AsyncActorLogic<unknown, AgentTextRequest>;
468
+ [USER_INPUT_ACTOR]: AsyncActorLogic<string, AgentUserInput>;
469
+ [DECIDE_ACTOR]: AsyncActorLogic<ChosenEvent, AgentDecisionInput<TEvent, Record<string, unknown>, TModel>>;
470
+ [PLAN_ACTOR]: PlanLogic<StandardSchemaV1<AgentPlanInput<TEvent, Record<string, unknown>, TModel>>>;
471
+ };
472
+ /**
473
+ * Validates a raw model/executor output against `schema`, returning the
474
+ * parsed value. Thin wrapper over {@link validateSchemaSync} for parsing a
475
+ * text request's structured output outside of `TextLogic.execute`/
476
+ * `executeAgentRequest` (e.g. a custom host loop).
477
+ */
478
+ declare function parseOutput<TSchema extends StandardSchemaV1>(schema: TSchema, output: unknown): InferOutput<TSchema>;
479
+ /** A TextLogicConfig/DecisionLogicConfig field value: either static, or a `({ input }) => value` resolver. @internal */
480
+ type ResolveTextLogicValue<TValue, TInput> = TValue | ((args: {
481
+ input: TInput;
482
+ }) => TValue);
483
+ /**
484
+ * Config for {@link createTextLogic}: how to build an
485
+ * {@link AgentTextRequest} from typed input, plus the input/output schemas
486
+ * that validate it. Each request-shaping field (`model`, `system`, `prompt`,
487
+ * …) is either a static value or a `({ input }) => value` resolver.
488
+ */
489
+ interface TextLogicConfig<TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetadata = Record<string, unknown>, TModel extends string = string> {
490
+ mode?: AgentRequestMode;
491
+ /** Stamped onto every lowered request as {@link AgentTextRequest.name}. `setupAgent({ requests })` sets this to the request's key. */
492
+ name?: ResolveTextLogicValue<string | undefined, InferOutput<TInputSchema>>;
493
+ schemas: {
494
+ input: TInputSchema;
495
+ output: TOutputSchema;
496
+ };
497
+ model: ResolveTextLogicValue<TModel, InferOutput<TInputSchema>>;
498
+ system?: ResolveTextLogicValue<string | undefined, InferOutput<TInputSchema>>;
499
+ prompt?: ResolveTextLogicValue<string | undefined, InferOutput<TInputSchema>>;
500
+ messages?: ResolveTextLogicValue<AgentMessage[] | undefined, InferOutput<TInputSchema>>;
501
+ tools?: ResolveTextLogicValue<AgentTools | undefined, InferOutput<TInputSchema>>;
502
+ toolChoice?: ResolveTextLogicValue<AgentToolChoice | undefined, InferOutput<TInputSchema>>;
503
+ /** Opt into the structured-output envelope's `reasoning` field (see {@link AgentTextRequest.reasoning}). */
504
+ reasoning?: ResolveTextLogicValue<boolean | undefined, InferOutput<TInputSchema>>;
505
+ temperature?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
506
+ maxOutputTokens?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
507
+ topP?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
508
+ topK?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
509
+ seed?: ResolveTextLogicValue<number | undefined, InferOutput<TInputSchema>>;
510
+ stopSequences?: ResolveTextLogicValue<string[] | undefined, InferOutput<TInputSchema>>;
511
+ metadata?: ResolveTextLogicValue<TMetadata | undefined, InferOutput<TInputSchema>>;
512
+ }
513
+ /** Arguments passed to a {@link TextLogicExecutor}: the typed input, the lowered {@link AgentTextRequest}, and the actor's own `signal`/`system`/`self`/`emit`. */
514
+ interface TextLogicExecuteArgs<TInput, TMetadata = Record<string, unknown>> {
515
+ input: TInput;
516
+ request: AgentTextRequest<TMetadata>;
517
+ signal: AbortSignal;
518
+ system: unknown;
519
+ self: unknown;
520
+ emit: (emitted: EventObject) => void;
521
+ }
522
+ /** Host implementation bound to a specific {@link TextLogic} via `withExecutor`/`createTextLogic`'s second argument — resolves one text request to an `{ output }` envelope typed from the logic's output schema (`{ output: T }`). Passthrough fields (usage, raw, …) are allowed alongside `output`. */
523
+ type TextLogicExecutor<TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetadata = unknown> = (args: TextLogicExecuteArgs<InferOutput<TInputSchema>, TMetadata>) => PromiseLike<AgentRequestExecutorResult<InferOutput<TOutputSchema>>> | AgentRequestExecutorResult<InferOutput<TOutputSchema>>;
524
+ /**
525
+ * Actor logic for a text request: an async effect that resolves typed input
526
+ * to typed, schema-validated output via a model call. Built by
527
+ * {@link createTextLogic}; register under `actorSources:` and invoke by name, or
528
+ * bind an executor later with `withExecutor`. The `agent.generateText`/
529
+ * `agent.streamText` builtins and `setupAgent({ requests })` entries are
530
+ * both `TextLogic` under the hood.
531
+ */
532
+ interface TextLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TOutputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetadata = Record<string, unknown>> extends AsyncActorLogic<InferOutput<TOutputSchema>, InferOutput<TInputSchema>> {
533
+ readonly kind: "statelyai.textLogic";
534
+ readonly mode: AgentRequestMode;
535
+ readonly schemas: {
536
+ readonly input: TInputSchema;
537
+ readonly output: TOutputSchema;
538
+ };
539
+ request(input: InferOutput<TInputSchema>): AgentTextRequest<TMetadata>;
540
+ execute(input: InferOutput<TInputSchema>, executors: AgentRequestExecutors): Promise<InferOutput<TOutputSchema>>;
541
+ withExecutor(execute: TextLogicExecutor<TInputSchema, TOutputSchema, TMetadata>): TextLogic<TInputSchema, TOutputSchema, TMetadata>;
542
+ }
543
+ /** Extracts a {@link TextLogic}'s validated input type. */
544
+ type TextLogicInput<TLogic extends TextLogic> = TLogic extends TextLogic<infer TInputSchema, StandardSchemaV1, infer _TMetadata> ? InferOutput<TInputSchema> : never;
545
+ /** Extracts a {@link TextLogic}'s validated output type. */
546
+ type TextLogicOutput<TLogic extends TextLogic> = TLogic extends TextLogic<StandardSchemaV1, infer TOutputSchema, infer _TMetadata> ? InferOutput<TOutputSchema> : never;
547
+ /**
548
+ * Creates reusable, standalone {@link TextLogic}: an actor that, when run,
549
+ * resolves typed input to typed output via a model call. Register the
550
+ * result under `actorSources:` and invoke it by name (equivalent to what
551
+ * `setupAgent({ requests })` builds internally for each request entry). Pass
552
+ * `execute` here, or bind it later with `.withExecutor(...)`, a runtime
553
+ * adapter's `machine.provide(...)`, or `runAgent`'s `generateText`/
554
+ * `streamText` options.
555
+ *
556
+ * @example
557
+ * ```ts
558
+ * export const tellJoke = createTextLogic({
559
+ * mode: 'stream',
560
+ * schemas: { input: z.object({ topic: z.string() }), output: z.string() },
561
+ * model: 'openai/gpt-5.4-mini',
562
+ * system: 'You tell short, punchy jokes.',
563
+ * prompt: ({ input }) => `Tell a joke about ${input.topic}.`,
564
+ * });
565
+ * ```
566
+ */
567
+ declare function createTextLogic<TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetadata = Record<string, unknown>, TModel extends string = string>(config: TextLogicConfig<TInputSchema, TOutputSchema, TMetadata, TModel>, execute?: TextLogicExecutor<TInputSchema, TOutputSchema, TMetadata>): TextLogic<TInputSchema, TOutputSchema, TMetadata>;
568
+ /**
569
+ * Binds a child machine's {@link TextLogic} to a raw
570
+ * {@link AgentRequestExecutor} (the `generateText`/`streamText` shape hosts
571
+ * implement). Encapsulates the `withExecutor` idiom child agents repeat:
572
+ * default the request's `tools` to `{}`, forward the actor `signal`, call the
573
+ * executor, and return its `{ output }` envelope. Use this to share ONE
574
+ * executor across a parent and its nested children.
575
+ *
576
+ * @example
577
+ * ```ts
578
+ * childMachine.provide({
579
+ * actorSources: {
580
+ * researchTopic: bindRequestExecutor(setup.requests.researchTopic, generateText),
581
+ * },
582
+ * });
583
+ * ```
584
+ */
585
+ declare function bindRequestExecutor<TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetadata>(logic: TextLogic<TInputSchema, TOutputSchema, TMetadata>, executor: AgentRequestExecutor, info?: Pick<AgentRequestExecutorInfo, "onChunk">): TextLogic<TInputSchema, TOutputSchema, TMetadata>;
586
+ /**
587
+ * The envelope an {@link AgentRequestExecutor} must return: `{ output }` where
588
+ * `output` is the request's value (a text string or a structured object).
589
+ * Passthrough fields (usage, toolCalls, finishReason, raw, …) are allowed
590
+ * alongside `output` and preserved on the raw result. {@link normalizeGeneratorResult}
591
+ * unwraps `output`; a non-envelope return is a runtime error.
592
+ */
593
+ type AgentRequestExecutorResult<TOutput = unknown> = {
594
+ output: TOutput;
595
+ [key: string]: unknown;
596
+ };
597
+ /**
598
+ * Optional second argument passed to executors by `runAgent`. The step path
599
+ * (`executeAgentRequest`) never passes this — chunk streaming only exists on
600
+ * the live path, where `onChunk` (§3.1) needs a way to reach the executor.
601
+ */
602
+ interface AgentRequestExecutorInfo {
603
+ onChunk?: (chunk: string) => void;
604
+ signal?: AbortSignal;
605
+ }
606
+ /**
607
+ * A raw Vercel AI SDK `generateText` result shape: resolves `{ text }` (a
608
+ * string or a promise of one) instead of the `{ output }`
609
+ * {@link AgentRequestExecutorResult} envelope. Admitted directly as an executor
610
+ * return type so `ai`'s `generateText` passes to `runAgent`/executors without a
611
+ * cast — {@link normalizeGeneratorResult} unwraps `text` at runtime (text-only;
612
+ * structured output is best-effort JSON parsing against the request's
613
+ * `outputSchema`). Extra fields (`content`, `usage`, …) are ignored.
614
+ */
615
+ type AiSdkShapedTextResult = {
616
+ text: string | PromiseLike<string>;
617
+ [key: string]: unknown;
618
+ };
619
+ /**
620
+ * A raw Vercel AI SDK `streamText` result shape: exposes a `textStream` async
621
+ * iterable of string chunks (and, optionally, a `text` promise for the final
622
+ * text) instead of the `{ output }` {@link AgentRequestExecutorResult} envelope.
623
+ * Admitted directly as an executor return type so `ai`'s `streamText` passes to
624
+ * `runAgent`/executors without a cast — {@link normalizeGeneratorResult}
625
+ * iterates `textStream`, forwarding chunks, then resolves the final text
626
+ * (text-only; structured output is best-effort). Extra fields are ignored.
627
+ */
628
+ type AiSdkShapedStreamResult = {
629
+ textStream: AsyncIterable<string>;
630
+ text?: PromiseLike<string>;
631
+ [key: string]: unknown;
632
+ };
633
+ /**
634
+ * Host implementation of one text call (`generateText` or `streamText`) —
635
+ * resolves a lowered {@link AgentTextRequest} to an `{ output }` envelope (see
636
+ * {@link AgentRequestExecutorResult}), unwrapped by
637
+ * {@link normalizeGeneratorResult}. The return type is widened to also admit the
638
+ * raw Vercel AI SDK shapes ({@link AiSdkShapedTextResult} /
639
+ * {@link AiSdkShapedStreamResult}) so `ai`'s own `generateText`/`streamText`
640
+ * pass through without a cast; `normalizeGeneratorResult` checks for `{ output }`
641
+ * first, then falls back to those shapes at runtime.
642
+ */
643
+ type AgentRequestExecutor<TResult extends AgentRequestExecutorResult = AgentRequestExecutorResult> = (request: AgentTextRequest & {
644
+ tools: AgentTools;
645
+ }, info?: AgentRequestExecutorInfo) => PromiseLike<TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult> | TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult;
646
+ /**
647
+ * The full set of host executors a machine's agent actors are resolved
648
+ * with — passed to `runAgent`, `executeAgentRequest`, and
649
+ * `TextLogic.execute`. Every slot is optional: `generateText` is needed only
650
+ * if the machine has a `mode: 'generate'` text request, `streamText` only for
651
+ * a `mode: 'stream'` request, and `decide` only for a decision/plan — omitting
652
+ * a slot the machine actually needs is a clear bind-time error (see `runAgent`
653
+ * and `provideExecutors`). Adapter result sets (`AiSdkExecutors`,
654
+ * `OpenAiCompatExecutors`) re-require all three.
655
+ */
656
+ interface AgentRequestExecutors<TGenerateResult extends AgentRequestExecutorResult = AgentRequestExecutorResult, TStreamResult extends AgentRequestExecutorResult = AgentRequestExecutorResult> {
657
+ generateText?: AgentRequestExecutor<TGenerateResult>;
658
+ streamText?: AgentRequestExecutor<TStreamResult>;
659
+ decide?: AgentDecisionExecutor;
660
+ }
661
+ /** Whether a text request's output is a validated structured object (`'structured'`) or plain text (`'text'`) — derived from the output schema's JSON Schema `type`. */
662
+ type AgentOutputMode = "structured" | "text";
663
+ /**
664
+ * Classifies a text request's output schema as `'structured'` (its JSON
665
+ * Schema is `type: 'object'`, `type: 'array'`, or a top-level union/
666
+ * composition — `anyOf`/`oneOf`/`allOf`, which a bare `z.union`/
667
+ * `z.discriminatedUnion` emits with no top-level `type`) or `'text'`
668
+ * (anything else, including no schema). Reads the schema's
669
+ * `~standard.jsonSchema.input()` extension — schemas without it are treated
670
+ * as `'text'`.
671
+ */
672
+ declare function getAgentOutputMode(schema?: StandardSchemaV1): AgentOutputMode;
673
+ /** True when {@link getAgentOutputMode} classifies `schema` as `'structured'`. */
674
+ declare function isStructuredOutputSchema(schema?: StandardSchemaV1): boolean;
675
+ /** The unwrapped shape a {@link buildEnvelopeSchema} validate returns: the inner
676
+ * `result` value plus, when opted in and present, the model's `reasoning`. */
677
+ interface StructuredOutputEnvelope {
678
+ result: unknown;
679
+ reasoning?: string;
680
+ }
681
+ /**
682
+ * Builds the uniform structured-output envelope schema every structured request
683
+ * is sent to the provider as: a root object `{ result: <inner> }`, plus — when
684
+ * `options.reasoning` is `true` — an optional string `reasoning` property listed
685
+ * BEFORE `result` (property order nudges the model to reason first). This is THE
686
+ * wire contract for structured output: a root object is universally accepted as
687
+ * a provider response schema, unlike a bare union/array root that many providers
688
+ * reject.
689
+ *
690
+ * The returned {@link StandardSchemaV1} validates the `{ reasoning?, result }`
691
+ * envelope (unwrapping `result` through the original schema, capturing a string
692
+ * `reasoning` when present) and exposes the enveloped JSON Schema. Adapters read
693
+ * `.result` off the provider output before the machine validates it — so this is
694
+ * transparent: user-facing output types stay the declared (un-enveloped) schema,
695
+ * and `reasoning` is surfaced only on the raw executor result, never in machine
696
+ * context/output.
697
+ */
698
+ declare function buildEnvelopeSchema(inner: StandardSchemaV1, options?: {
699
+ reasoning?: boolean;
700
+ }): StandardSchemaV1<StructuredOutputEnvelope>;
701
+ /**
702
+ * Validates a raw provider value against the structured-output envelope for
703
+ * `request` and returns the unwrapped `{ result, reasoning? }` — the checked
704
+ * replacement for `raw as StructuredOutputEnvelope` in hand-written hosts.
705
+ * Pair with {@link buildEnvelopeSchema} (which produced the schema the
706
+ * provider was asked to satisfy).
707
+ */
708
+ declare function parseStructuredEnvelope(request: Pick<AgentTextRequest, "outputSchema" | "reasoning">, value: unknown): StructuredOutputEnvelope;
709
+ //#endregion
710
+ export { AgentDecisionInput as A, ResolveDecisionOptions as B, createTextLogic as C, parseOutput as D, parseModelRef as E, DecisionExhaustedError as F, AgentRequestOptions as G, resolveDecision as H, DecisionLogic as I, matchesEventPattern as J, AgentRequestSource as K, DecisionLogicConfig as L, AgentPlanInput as M, AgentPlanOutput as N, parseStructuredEnvelope as O, DecisionAttempt as P, PLAN_DONE_EVENT_TYPE as R, buildEnvelopeSchema as S, isStructuredOutputSchema as T, AgentEventDescriptor as U, renderDecisionAttempts as V, AgentEventToolNameResolver as W, parseAgentEvent as Y, TextLogicExecuteArgs as _, AgentRequestExecutorInfo as a, TextLogicOutput as b, AgentRequestMode as c, AiSdkShapedStreamResult as d, AiSdkShapedTextResult as f, TextLogicConfig as g, TextLogic as h, AgentRequestExecutor as i, AgentDecisionRequest as j, AgentDecisionExecutor as k, AgentTextRequest as l, StructuredOutputEnvelope as m, AgentModelRef as n, AgentRequestExecutorResult as o, BuiltinAgentActors as p, getAcceptedEvents as q, AgentOutputMode as r, AgentRequestExecutors as s, AgentModelMap as t, AgentUserInput as u, TextLogicExecutor as v, getAgentOutputMode as w, bindRequestExecutor as x, TextLogicInput as y, PlanLogic as z };