@statelyai/agent 2.0.0-alpha.10 → 2.0.0-alpha.12

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 (62) hide show
  1. package/dist/ai-sdk.cjs +62 -99
  2. package/dist/ai-sdk.d.cts +10 -117
  3. package/dist/ai-sdk.d.mts +10 -117
  4. package/dist/ai-sdk.mjs +63 -91
  5. package/dist/{decision-CQdrKc8k.mjs → decision-BezSD_YC.mjs} +120 -32
  6. package/dist/{decision-b-lkcs4L.cjs → decision-dWGhBh0P.cjs} +141 -53
  7. package/dist/errors-BQRk9eiZ.d.cts +19 -0
  8. package/dist/errors-C9rxnWbX.d.mts +19 -0
  9. package/dist/errors-CeSXQx0v.mjs +23 -0
  10. package/dist/errors-DUBBzRLP.cjs +28 -0
  11. package/dist/event-log-store-CNT_7F0V.cjs +452 -0
  12. package/dist/event-log-store-CriMgX1D.d.mts +144 -0
  13. package/dist/event-log-store-D7pWtIhb.mjs +411 -0
  14. package/dist/event-log-store-Ruq18mGp.d.cts +144 -0
  15. package/dist/index.cjs +2844 -30
  16. package/dist/index.d.cts +1005 -12
  17. package/dist/index.d.mts +1005 -12
  18. package/dist/index.mjs +2799 -4
  19. package/dist/machines.cjs +752 -0
  20. package/dist/machines.d.cts +372 -0
  21. package/dist/machines.d.mts +372 -0
  22. package/dist/machines.mjs +741 -0
  23. package/dist/otel.cjs +268 -0
  24. package/dist/otel.d.cts +67 -0
  25. package/dist/otel.d.mts +67 -0
  26. package/dist/otel.mjs +267 -0
  27. package/dist/run-agent-B1nBa7aV.d.mts +1111 -0
  28. package/dist/run-agent-qkg0evvW.d.cts +1111 -0
  29. package/dist/setup-agent-DAZZSjDS.mjs +1711 -0
  30. package/dist/setup-agent-DP95MFrI.cjs +1836 -0
  31. package/dist/sqlite.cjs +135 -0
  32. package/dist/sqlite.d.cts +57 -0
  33. package/dist/sqlite.d.mts +57 -0
  34. package/dist/sqlite.mjs +133 -0
  35. package/dist/{text-logic-C7WJpCIc.d.mts → text-logic-CorGzucG.d.cts} +110 -66
  36. package/dist/{text-logic-CZjyACzQ.d.cts → text-logic-DjR5PUVz.d.mts} +110 -66
  37. package/dist/{types-C9QiMjre.d.cts → types-QbEfCVny.d.cts} +1 -1
  38. package/dist/{types-qm00QF91.d.mts → types-_FXoFBGO.d.mts} +1 -1
  39. package/package.json +55 -27
  40. package/readme.md +40 -9
  41. package/schemas/agent-workflow.json +44 -26
  42. package/skills/generate-machine/SKILL.md +267 -0
  43. package/dist/cli.cjs +0 -64
  44. package/dist/cli.d.cts +0 -1
  45. package/dist/cli.d.mts +0 -1
  46. package/dist/cli.mjs +0 -65
  47. package/dist/openai-compat.cjs +0 -319
  48. package/dist/openai-compat.d.cts +0 -98
  49. package/dist/openai-compat.d.mts +0 -98
  50. package/dist/openai-compat.mjs +0 -312
  51. package/dist/run-agent-BFMkuI1F.cjs +0 -1599
  52. package/dist/run-agent-BVMd--1l.d.cts +0 -1103
  53. package/dist/run-agent-BoAOq_0Z.mjs +0 -1540
  54. package/dist/run-agent-DzYJb3CK.d.mts +0 -1103
  55. package/dist/src-D-77Ha5p.cjs +0 -1087
  56. package/dist/src-DUeIFjv-.mjs +0 -1016
  57. package/dist/utils-Dri7aeEG.d.cts +0 -108
  58. package/dist/utils-Y6GDRGGE.d.mts +0 -108
  59. package/dist/zod.cjs +0 -31
  60. package/dist/zod.d.cts +0 -30
  61. package/dist/zod.d.mts +0 -30
  62. package/dist/zod.mjs +0 -30
@@ -1,23 +1,15 @@
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-qm00QF91.mjs";
1
+ import { _ as StandardSchemaV1, a as AgentToolChoice, c as AgentTools, d as ChosenEvent, h as InferOutput, l as AllowedEvents, n as AgentMessage } from "./types-QbEfCVny.cjs";
2
+ import { t as AgentError } from "./errors-BQRk9eiZ.cjs";
2
3
  import { AnyMachineSnapshot, AsyncActorLogic, EventObject, LogicActorLogic, MachineSnapshot } from "xstate";
3
4
 
4
5
  //#region src/events.d.ts
5
6
  /** The invoke `src` of an {@link AgentRequest}/{@link AgentDecisionRequest} — a plain string, widened so literal `src` values still narrow in editor hints. */
6
7
  type AgentRequestSource = string & {};
7
- /** Default prefix for the synthetic tool name generated per candidate event (e.g. `send_event_ASK`). Override per-request with {@link AgentEventToolNameResolver}. */
8
- declare const EVENT_TOOL_PREFIX: "send_event_";
9
8
  /** Customizes the tool name generated for a candidate event; see {@link AgentRequestOptions.eventToolName}. */
10
9
  type AgentEventToolNameResolver = (args: {
11
10
  eventType: string;
12
11
  defaultToolName: string;
13
12
  }) => string;
14
- /**
15
- * True when an event type matches an `allowedEvents` entry: an exact type,
16
- * `'*'` (every event), or a `'prefix.*'` wildcard matching any deeper
17
- * segment (`'todo.*'` matches `'todo.add'` and `'todo.list.clear'`, not
18
- * `'todo'` itself — mirroring xstate's partial wildcard events).
19
- */
20
- declare function matchesEventPattern(eventType: string, pattern: string): boolean;
21
13
  /** 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. */
22
14
  interface AgentEventDescriptor {
23
15
  type: string;
@@ -33,21 +25,10 @@ interface AgentRequestOptions {
33
25
  snapshot?: AnyMachineSnapshot;
34
26
  events?: Record<string, StandardSchemaV1>;
35
27
  schemas?: AgentSchemas;
36
- actorSources?: Record<string, unknown>;
28
+ actors?: Record<string, unknown>;
37
29
  /** Customize machine-event tool names. Defaults to send_event_<TYPE>. */
38
30
  eventToolName?: AgentEventToolNameResolver;
39
31
  }
40
- /**
41
- * Lists the events a snapshot can currently accept, as {@link AgentEventDescriptor}s
42
- * a model can be offered (via `resolveDecision`/an adapter's tool-per-event
43
- * mapping). **Filters by event TYPE only** — it does not evaluate guards, so
44
- * a type-legal-but-guard-rejected event can still appear here. Guard
45
- * legality is checked separately, at decision-resolution time, via
46
- * `snapshot.can(event)` (the `canTake` option of {@link resolveDecision} /
47
- * {@link ResolveDecisionOptions}). Pass `eventTypes` to further narrow to a
48
- * declared `allowedEvents` set — entries may be exact types or wildcard
49
- * patterns (`'*'`, `'todo.*'`; see {@link matchesEventPattern}).
50
- */
51
32
  /** Recovers a machine's event union from its snapshot type, so {@link parseAgentEvent} returns the machine-typed event without a downstream cast. @internal */
52
33
  type EventFromSnapshot<TSnapshot> = TSnapshot extends MachineSnapshot<any, infer TEvent, any, any, any, any, any, any> ? TEvent : EventObject;
53
34
  /**
@@ -74,6 +55,22 @@ type EventFromSnapshot<TSnapshot> = TSnapshot extends MachineSnapshot<any, infer
74
55
  declare function parseAgentEvent<TSnapshot extends AnyMachineSnapshot>(snapshot: TSnapshot, event: {
75
56
  type: string;
76
57
  } & Record<string, unknown>, options?: Pick<AgentRequestOptions, "events" | "schemas" | "eventToolName">): EventFromSnapshot<TSnapshot>;
58
+ /**
59
+ * Lists the events a snapshot can currently accept, as {@link AgentEventDescriptor}s
60
+ * a model can be offered (via `resolveDecision`/an adapter's tool-per-event
61
+ * mapping). **Filters by event TYPE only** — it does not evaluate guards, so
62
+ * a type-legal-but-guard-rejected event can still appear here. Guard
63
+ * legality is checked separately, at decision-resolution time, via
64
+ * `snapshot.can(event)` (the `canTake` option of {@link resolveDecision} /
65
+ * {@link ResolveDecisionOptions}). Pass `eventTypes` to further narrow to a
66
+ * declared `allowedEvents` set — entries may be exact types or wildcard
67
+ * patterns (`'*'`, `'todo.*'`; see {@link matchesEventPattern}).
68
+ *
69
+ * XState-internal (`xstate.*`) and library-reserved
70
+ * ({@link RESERVED_AGENT_EVENT_PREFIX}) event types are always excluded, before
71
+ * any `allowedEvents` matching — a machine that handles `'@agent.usage'` still
72
+ * never offers it to a model.
73
+ */
77
74
  declare function getAcceptedEvents(snapshot: AnyMachineSnapshot, options?: Pick<AgentRequestOptions, "events" | "schemas" | "eventToolName"> & {
78
75
  eventTypes?: readonly string[];
79
76
  }): AgentEventDescriptor[];
@@ -211,21 +208,6 @@ interface DecisionLogicConfig<TInputSchema extends StandardSchemaV1 = StandardSc
211
208
  stopSequences?: ResolveTextLogicValue<string[] | undefined, InferOutput<TInputSchema>>;
212
209
  metadata?: ResolveTextLogicValue<TMetadata | undefined, InferOutput<TInputSchema>>;
213
210
  }
214
- /**
215
- * Actor logic for a decision: an async effect that resolves to exactly one
216
- * currently-legal {@link ChosenEvent} (never a plain value). Under `runAgent`
217
- * the chosen event is delivered to the invoking actor automatically — the
218
- * transition it triggers usually exits the invoking state and ends the invoke.
219
- * Built by {@link createDecisionLogic}. Register it under `actorSources:` to reuse/export/
220
- * test it standalone; for a state-local, zero-config decision, use the
221
- * `agent.decide` builtin invoke instead.
222
- */
223
- interface DecisionLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetadata extends Record<string, unknown> = Record<string, unknown>> extends AsyncActorLogic<ChosenEvent, InferOutput<TInputSchema>> {
224
- readonly kind: "statelyai.decisionLogic";
225
- readonly maxRetries: number;
226
- request(input: InferOutput<TInputSchema>): AgentDecisionRequest;
227
- withExecutor(execute: AgentDecisionExecutor): DecisionLogic<TInputSchema, TMetadata>;
228
- }
229
211
  /**
230
212
  * A decision request: resolves to exactly one currently-legal event. See
231
213
  * `resolveDecision`.
@@ -260,6 +242,15 @@ interface AgentDecisionRequest {
260
242
  * `info.signal`). Runtime-only — never serialized into a provider request.
261
243
  */
262
244
  signal?: AbortSignal;
245
+ /**
246
+ * The `runAgent` run this decision belongs to (`run_<n>`, matching trace
247
+ * events), injected by runAgent like `signal` (symmetric with the text
248
+ * executors' `info.runId`). Runtime-only correlation for executor
249
+ * middleware; unset off the runAgent path. Per-attempt context is already
250
+ * on the request: `id` is the durable invoke id and `attempts.length` is
251
+ * the current attempt index.
252
+ */
253
+ runId?: string;
263
254
  }
264
255
  /**
265
256
  * A single failed decision attempt, recorded by {@link resolveDecision} and
@@ -282,8 +273,8 @@ interface DecisionAttempt {
282
273
  * diagnostics; a machine typically routes this via the decision invoke's
283
274
  * `onError`.
284
275
  */
285
- declare class DecisionExhaustedError extends Error {
286
- attempts: DecisionAttempt[];
276
+ declare class AgentDecisionExhaustedError extends AgentError {
277
+ readonly attempts: DecisionAttempt[];
287
278
  constructor(attempts: DecisionAttempt[]);
288
279
  }
289
280
  /**
@@ -309,12 +300,15 @@ declare function renderDecisionAttempts(request: Pick<AgentDecisionRequest, "eve
309
300
  * adapter business; core only validates and retries the returned choice (see
310
301
  * {@link resolveDecision}). The optional `reason` is carried through to
311
302
  * `onResult`/event-sourcing but never affects validation. Like text
312
- * executors' `{ output, ...extras }` envelope, any extra keys (usage, finish
313
- * reason, …) flow untouched to `onResult`'s `raw`.
303
+ * executors' `{ output, ...extras }` envelope, any extra keys (finish reason,
304
+ * …) flow untouched to `onResult`'s `raw`; `usage` is the one core reads —
305
+ * report this attempt's tokens there and `runAgent` folds them into the run's
306
+ * aggregated {@link AgentUsage}.
314
307
  */
315
308
  type AgentDecisionExecutor = (request: AgentDecisionRequest) => PromiseLike<{
316
309
  event: ChosenEvent;
317
- reason?: string;
310
+ reason?: string; /** This attempt's token usage, aggregated into the run result's {@link AgentUsage}. */
311
+ usage?: AgentCallUsage;
318
312
  [key: string]: unknown;
319
313
  }>;
320
314
  /**
@@ -356,7 +350,7 @@ interface ResolveDecisionOptions<TEvent extends ChosenEvent = ChosenEvent> {
356
350
  * the next attempt via `request.attempts`, so an adapter can render "your
357
351
  * last choice failed because X — try again" into the next model call; core
358
352
  * never rewrites the request itself. Exhausting all attempts throws
359
- * {@link DecisionExhaustedError} with the full attempts list.
353
+ * {@link AgentDecisionExhaustedError} with the full attempts list.
360
354
  *
361
355
  * @example
362
356
  * ```ts
@@ -452,6 +446,34 @@ interface AgentTextRequest<TMetadata = Record<string, unknown>> {
452
446
  */
453
447
  metadata?: TMetadata;
454
448
  }
449
+ /**
450
+ * Aggregated model-call usage for ONE `runAgent` call — the run-level total
451
+ * attached to every settled {@link RunAgentResult} (and therefore to
452
+ * `generateResult`'s `{ output, snapshot, events, usage }`).
453
+ *
454
+ * - `modelCalls` counts every model/decision call this run made (each decision
455
+ * retry counts separately) — the same seam `maxModelCalls` budgets. Always a
456
+ * number, even when no executor reported tokens.
457
+ * - Token fields are OPTIONAL and are PARTIAL SUMS: each one sums only the
458
+ * calls that reported it, and stays `undefined` when NO call reported it.
459
+ * Executors that report nothing (custom hosts, test mocks) simply do not
460
+ * contribute — a run mixing reporting and non-reporting calls yields a sum
461
+ * over the reporting subset, not `undefined`.
462
+ * - Aggregation is per-run: a resumed run counts only ITS OWN calls, never the
463
+ * history behind `snapshot`/`events`. Add prior runs' totals yourself if you
464
+ * want a conversation-wide figure.
465
+ */
466
+ interface AgentUsage {
467
+ inputTokens?: number;
468
+ outputTokens?: number;
469
+ totalTokens?: number;
470
+ reasoningTokens?: number;
471
+ cachedInputTokens?: number;
472
+ /** Model/decision calls made by this run (decision retries count separately). */
473
+ modelCalls: number;
474
+ }
475
+ /** One model call's reported usage — {@link AgentUsage} without the run-level `modelCalls` count. What an executor puts on its result's `usage` field. */
476
+ type AgentCallUsage = Omit<AgentUsage, "modelCalls">;
455
477
  /**
456
478
  * Inline input for the `agent.userInput` builtin actor — a human-input request
457
479
  * (CLI prompt, chat reply, …) that resolves to the `string` the human typed.
@@ -488,13 +510,19 @@ type ResolveTextLogicValue<TValue, TInput> = TValue | ((args: {
488
510
  * that validate it. Each request-shaping field (`model`, `system`, `prompt`,
489
511
  * …) is either a static value or a `({ input }) => value` resolver.
490
512
  */
491
- interface TextLogicConfig<TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetadata = Record<string, unknown>, TModel extends string = string> {
513
+ interface TextLogicConfig<TInputSchema extends StandardSchemaV1 = StandardSchemaV1<undefined>, TOutputSchema extends StandardSchemaV1 = StandardSchemaV1<string>, TMetadata = Record<string, unknown>, TModel extends string = string> {
492
514
  mode?: AgentRequestMode;
493
515
  /** Stamped onto every lowered request as {@link AgentTextRequest.name}. `setupAgent({ requests })` sets this to the request's key. */
494
516
  name?: ResolveTextLogicValue<string | undefined, InferOutput<TInputSchema>>;
495
- schemas: {
496
- input: TInputSchema;
497
- output: TOutputSchema;
517
+ /**
518
+ * The request's input/output schemas. Both are optional:
519
+ * - `output` defaults to a string schema (a plain text request).
520
+ * - `input` defaults to a schema that accepts (and types) `undefined`, so
521
+ * the request takes no `input` at the invoke site.
522
+ */
523
+ schemas?: {
524
+ input?: TInputSchema;
525
+ output?: TOutputSchema;
498
526
  };
499
527
  model: ResolveTextLogicValue<TModel, InferOutput<TInputSchema>>;
500
528
  system?: ResolveTextLogicValue<string | undefined, InferOutput<TInputSchema>>;
@@ -526,7 +554,7 @@ type TextLogicExecutor<TInputSchema extends StandardSchemaV1, TOutputSchema exte
526
554
  /**
527
555
  * Actor logic for a text request: an async effect that resolves typed input
528
556
  * to typed, schema-validated output via a model call. Built by
529
- * {@link createTextLogic}; register under `actorSources:` and invoke by name, or
557
+ * {@link createTextLogic}; register under `actors:` and invoke by name, or
530
558
  * bind an executor later with `withExecutor`. The `agent.generateText`/
531
559
  * `agent.streamText` builtins and `setupAgent({ requests })` entries are
532
560
  * both `TextLogic` under the hood.
@@ -542,14 +570,10 @@ interface TextLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TO
542
570
  execute(input: InferOutput<TInputSchema>, executors: AgentRequestExecutors): Promise<InferOutput<TOutputSchema>>;
543
571
  withExecutor(execute: TextLogicExecutor<TInputSchema, TOutputSchema, TMetadata>): TextLogic<TInputSchema, TOutputSchema, TMetadata>;
544
572
  }
545
- /** Extracts a {@link TextLogic}'s validated input type. */
546
- type TextLogicInput<TLogic extends TextLogic> = TLogic extends TextLogic<infer TInputSchema, StandardSchemaV1, infer _TMetadata> ? InferOutput<TInputSchema> : never;
547
- /** Extracts a {@link TextLogic}'s validated output type. */
548
- type TextLogicOutput<TLogic extends TextLogic> = TLogic extends TextLogic<StandardSchemaV1, infer TOutputSchema, infer _TMetadata> ? InferOutput<TOutputSchema> : never;
549
573
  /**
550
574
  * Creates reusable, standalone {@link TextLogic}: an actor that, when run,
551
575
  * resolves typed input to typed output via a model call. Register the
552
- * result under `actorSources:` and invoke it by name (equivalent to what
576
+ * result under `actors:` and invoke it by name (equivalent to what
553
577
  * `setupAgent({ requests })` builds internally for each request entry). Pass
554
578
  * `execute` here, or bind it later with `.withExecutor(...)`, a runtime
555
579
  * adapter's `machine.provide(...)`, or `runAgent`'s `generateText`/
@@ -566,7 +590,7 @@ type TextLogicOutput<TLogic extends TextLogic> = TLogic extends TextLogic<Standa
566
590
  * });
567
591
  * ```
568
592
  */
569
- 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>;
593
+ declare function createTextLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1<undefined>, TOutputSchema extends StandardSchemaV1 = StandardSchemaV1<string>, TMetadata = Record<string, unknown>, TModel extends string = string>(config: TextLogicConfig<TInputSchema, TOutputSchema, TMetadata, TModel>, execute?: TextLogicExecutor<TInputSchema, TOutputSchema, TMetadata>): TextLogic<TInputSchema, TOutputSchema, TMetadata>;
570
594
  /**
571
595
  * Binds a child machine's {@link TextLogic} to a raw
572
596
  * {@link AgentRequestExecutor} (the `generateText`/`streamText` shape hosts
@@ -578,7 +602,7 @@ declare function createTextLogic<TInputSchema extends StandardSchemaV1, TOutputS
578
602
  * @example
579
603
  * ```ts
580
604
  * childMachine.provide({
581
- * actorSources: {
605
+ * actors: {
582
606
  * researchTopic: bindRequestExecutor(setup.requests.researchTopic, generateText),
583
607
  * },
584
608
  * });
@@ -588,12 +612,18 @@ declare function bindRequestExecutor<TInputSchema extends StandardSchemaV1, TOut
588
612
  /**
589
613
  * The envelope an {@link AgentRequestExecutor} must return: `{ output }` where
590
614
  * `output` is the request's value (a text string or a structured object).
591
- * Passthrough fields (usage, toolCalls, finishReason, raw, …) are allowed
592
- * alongside `output` and preserved on the raw result. {@link normalizeGeneratorResult}
615
+ * Passthrough fields (toolCalls, finishReason, raw, …) are allowed alongside
616
+ * `output` and preserved on the raw result. {@link normalizeGeneratorResult}
593
617
  * unwraps `output`; a non-envelope return is a runtime error.
618
+ *
619
+ * `usage` is the one passthrough field core reads: report this call's tokens
620
+ * there and `runAgent` folds them into the run's aggregated
621
+ * {@link AgentUsage}. Optional — an executor that reports nothing still counts
622
+ * toward `modelCalls`.
594
623
  */
595
624
  type AgentRequestExecutorResult<TOutput = unknown> = {
596
- output: TOutput;
625
+ output: TOutput; /** This call's token usage, aggregated into the run result's {@link AgentUsage}. */
626
+ usage?: AgentCallUsage;
597
627
  [key: string]: unknown;
598
628
  };
599
629
  /**
@@ -604,6 +634,20 @@ type AgentRequestExecutorResult<TOutput = unknown> = {
604
634
  interface AgentRequestExecutorInfo {
605
635
  onChunk?: (chunk: string) => void;
606
636
  signal?: AbortSignal;
637
+ /**
638
+ * The `runAgent` run this call belongs to (`run_<n>`, matching trace
639
+ * events). Undefined off the runAgent path (bare `provideExecutors` /
640
+ * direct `TextLogic.execute`). Lets executor middleware (caching, rate
641
+ * limits, span parenting) correlate calls without side channels.
642
+ */
643
+ runId?: string;
644
+ /**
645
+ * The durable invoke id of the request making this call (e.g.
646
+ * `'0.(machine).asking'`) — stable across resume/replay, and it encodes the
647
+ * invoking state, so per-state middleware can key on it. Undefined when the
648
+ * call has no invoking actor.
649
+ */
650
+ requestId?: string;
607
651
  }
608
652
  /**
609
653
  * A raw Vercel AI SDK `generateText` result shape: resolves `{ text }` (a
@@ -648,13 +692,15 @@ type AgentRequestExecutor<TResult extends AgentRequestExecutorResult = AgentRequ
648
692
  /**
649
693
  * The full set of host executors a machine's agent actors are resolved
650
694
  * with — passed to `runAgent`, `executeAgentRequest`, and
651
- * `TextLogic.execute`. `generateText` is required; `streamText` is only
652
- * needed if the machine has a `mode: 'stream'` text request, and `decide`
653
- * only if it uses a decision omitting either is a bind-time error when the
654
- * machine actually needs it (see `runAgent`).
695
+ * `TextLogic.execute`. Every slot is optional: `generateText` is needed only
696
+ * if the machine has a `mode: 'generate'` text request, `streamText` only for
697
+ * a `mode: 'stream'` request, and `decide` only for a decision/plan omitting
698
+ * a slot the machine actually needs is a clear bind-time error (see `runAgent`
699
+ * and `provideExecutors`). Adapter result sets (`AiSdkExecutors`,
700
+ * `OpenAiCompatExecutors`) re-require all three.
655
701
  */
656
702
  interface AgentRequestExecutors<TGenerateResult extends AgentRequestExecutorResult = AgentRequestExecutorResult, TStreamResult extends AgentRequestExecutorResult = AgentRequestExecutorResult> {
657
- generateText: AgentRequestExecutor<TGenerateResult>;
703
+ generateText?: AgentRequestExecutor<TGenerateResult>;
658
704
  streamText?: AgentRequestExecutor<TStreamResult>;
659
705
  decide?: AgentDecisionExecutor;
660
706
  }
@@ -670,8 +716,6 @@ type AgentOutputMode = "structured" | "text";
670
716
  * as `'text'`.
671
717
  */
672
718
  declare function getAgentOutputMode(schema?: StandardSchemaV1): AgentOutputMode;
673
- /** True when {@link getAgentOutputMode} classifies `schema` as `'structured'`. */
674
- declare function isStructuredOutputSchema(schema?: StandardSchemaV1): boolean;
675
719
  /** The unwrapped shape a {@link buildEnvelopeSchema} validate returns: the inner
676
720
  * `result` value plus, when opted in and present, the model's `reasoning`. */
677
721
  interface StructuredOutputEnvelope {
@@ -707,4 +751,4 @@ declare function buildEnvelopeSchema(inner: StandardSchemaV1, options?: {
707
751
  */
708
752
  declare function parseStructuredEnvelope(request: Pick<AgentTextRequest, "outputSchema" | "reasoning">, value: unknown): StructuredOutputEnvelope;
709
753
  //#endregion
710
- export { AgentDecisionInput as A, renderDecisionAttempts as B, createTextLogic as C, parseOutput as D, parseModelRef as E, DecisionExhaustedError as F, AgentRequestSource as G, AgentEventDescriptor as H, DecisionLogic as I, matchesEventPattern as J, EVENT_TOOL_PREFIX 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, AgentEventToolNameResolver as U, resolveDecision as V, AgentRequestOptions 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, ResolveDecisionOptions as z };
754
+ export { AgentDecisionInput as A, resolveDecision as B, createTextLogic as C, parseStructuredEnvelope as D, parseOutput as E, DecisionLogicConfig as F, getAcceptedEvents as G, AgentEventToolNameResolver as H, PLAN_DONE_EVENT_TYPE as I, parseAgentEvent as K, PlanLogic as L, AgentPlanInput as M, AgentPlanOutput as N, AgentDecisionExecutor as O, DecisionAttempt as P, ResolveDecisionOptions as R, buildEnvelopeSchema as S, parseModelRef as T, AgentRequestOptions as U, AgentEventDescriptor as V, AgentRequestSource as W, TextLogic as _, AgentRequestExecutor as a, TextLogicExecutor as b, AgentRequestExecutors as c, AgentUsage as d, AgentUserInput as f, StructuredOutputEnvelope as g, BuiltinAgentActors as h, AgentOutputMode as i, AgentDecisionRequest as j, AgentDecisionExhaustedError as k, AgentRequestMode as l, AiSdkShapedTextResult as m, AgentModelMap as n, AgentRequestExecutorInfo as o, AiSdkShapedStreamResult as p, AgentModelRef as r, AgentRequestExecutorResult as s, AgentCallUsage as t, AgentTextRequest as u, TextLogicConfig as v, getAgentOutputMode as w, bindRequestExecutor as x, TextLogicExecuteArgs as y, renderDecisionAttempts as z };