@statelyai/agent 1.1.5 → 2.0.0-alpha.10
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.
- package/LICENSE +21 -0
- package/dist/ai-sdk.cjs +342 -0
- package/dist/ai-sdk.d.cts +206 -0
- package/dist/ai-sdk.d.mts +206 -0
- package/dist/ai-sdk.mjs +331 -0
- package/dist/cli.cjs +64 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +65 -0
- package/dist/decision-CQdrKc8k.mjs +978 -0
- package/dist/decision-b-lkcs4L.cjs +1295 -0
- package/dist/index.cjs +59 -0
- package/dist/index.d.cts +212 -0
- package/dist/index.d.mts +201 -417
- package/dist/index.mjs +4 -583
- package/dist/openai-compat.cjs +319 -0
- package/dist/openai-compat.d.cts +98 -0
- package/dist/openai-compat.d.mts +98 -0
- package/dist/openai-compat.mjs +312 -0
- package/dist/run-agent-BFMkuI1F.cjs +1599 -0
- package/dist/run-agent-BVMd--1l.d.cts +1103 -0
- package/dist/run-agent-BoAOq_0Z.mjs +1540 -0
- package/dist/run-agent-DzYJb3CK.d.mts +1103 -0
- package/dist/src-D-77Ha5p.cjs +1087 -0
- package/dist/src-DUeIFjv-.mjs +1016 -0
- package/dist/text-logic-C7WJpCIc.d.mts +710 -0
- package/dist/text-logic-CZjyACzQ.d.cts +710 -0
- package/dist/types-C9QiMjre.d.cts +219 -0
- package/dist/types-qm00QF91.d.mts +219 -0
- package/dist/utils-Dri7aeEG.d.cts +108 -0
- package/dist/utils-Y6GDRGGE.d.mts +108 -0
- package/dist/zod.cjs +31 -0
- package/dist/zod.d.cts +30 -0
- package/dist/zod.d.mts +30 -0
- package/dist/zod.mjs +30 -0
- package/package.json +110 -29
- package/readme.md +143 -6
- package/schemas/agent-workflow.json +527 -0
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.env.template +0 -3
- package/.github/actions/ci-setup/action.yml +0 -24
- package/.github/workflows/release.yml +0 -46
- package/.vscode/launch.json +0 -28
- package/CHANGELOG.md +0 -215
- package/dist/index.d.ts +0 -428
- package/dist/index.js +0 -616
- package/examples/chatbot.ts +0 -71
- package/examples/cot.ts +0 -89
- package/examples/email.ts +0 -118
- package/examples/example.ts +0 -81
- package/examples/goal.ts +0 -94
- package/examples/helpers/helpers.ts +0 -17
- package/examples/helpers/loader.ts +0 -32
- package/examples/helpers/runner.ts +0 -27
- package/examples/joke.ts +0 -225
- package/examples/multi.ts +0 -103
- package/examples/newspaper.ts +0 -324
- package/examples/number.ts +0 -102
- package/examples/raffle.ts +0 -105
- package/examples/sandbox.ts +0 -28
- package/examples/simple.ts +0 -39
- package/examples/support.ts +0 -147
- package/examples/ticTacToe.ts +0 -224
- package/examples/todo.ts +0 -137
- package/examples/tutor.ts +0 -100
- package/examples/verify.ts +0 -120
- package/examples/weather.ts +0 -178
- package/examples/wiki.ts +0 -30
- package/examples/word.ts +0 -171
- package/src/adapters/vercel.ts +0 -7
- package/src/agent-experimental.ts +0 -221
- package/src/agent.test.ts +0 -506
- package/src/agent.ts +0 -300
- package/src/decision.test.ts +0 -179
- package/src/decision.ts +0 -84
- package/src/index.ts +0 -4
- package/src/memory.ts +0 -25
- package/src/planners/shortestPathPlanner.ts +0 -22
- package/src/planners/simplePlanner.ts +0 -139
- package/src/schemas.ts +0 -11
- package/src/strategies/chain-of-note.ts +0 -155
- package/src/templates/defaultText.ts +0 -18
- package/src/text.ts +0 -236
- package/src/types.ts +0 -499
- package/src/utils.ts +0 -72
- package/tsconfig.json +0 -109
- package/vitest.config.ts +0 -9
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_run_agent = require("./run-agent-BFMkuI1F.cjs");
|
|
3
|
+
const require_decision = require("./decision-b-lkcs4L.cjs");
|
|
4
|
+
const require_src = require("./src-D-77Ha5p.cjs");
|
|
5
|
+
exports.AgentIdleError = require_run_agent.AgentIdleError;
|
|
6
|
+
exports.AgentLintError = require_src.AgentLintError;
|
|
7
|
+
exports.DecisionExhaustedError = require_decision.DecisionExhaustedError;
|
|
8
|
+
exports.EVENT_TOOL_PREFIX = require_decision.EVENT_TOOL_PREFIX;
|
|
9
|
+
exports.IllegalResumeEventError = require_run_agent.IllegalResumeEventError;
|
|
10
|
+
exports.PLAN_DONE_EVENT_TYPE = require_decision.PLAN_DONE_EVENT_TYPE;
|
|
11
|
+
exports.SnapshotVersionMismatchError = require_run_agent.SnapshotVersionMismatchError;
|
|
12
|
+
exports.appendMessages = require_run_agent.appendMessages;
|
|
13
|
+
exports.assertAgentMachine = require_src.assertAgentMachine;
|
|
14
|
+
exports.assistantMessage = require_decision.assistantMessage;
|
|
15
|
+
exports.bindRequestExecutor = require_decision.bindRequestExecutor;
|
|
16
|
+
exports.buildEnvelopeSchema = require_decision.buildEnvelopeSchema;
|
|
17
|
+
exports.canReach = require_src.canReach;
|
|
18
|
+
exports.createAgentSchemas = require_run_agent.createAgentSchemas;
|
|
19
|
+
exports.createTextLogic = require_decision.createTextLogic;
|
|
20
|
+
exports.executeAgentRequest = require_src.executeAgentRequest;
|
|
21
|
+
exports.explorePaths = require_src.explorePaths;
|
|
22
|
+
exports.getAcceptedEvents = require_decision.getAcceptedEvents;
|
|
23
|
+
exports.getAgentMessages = require_decision.getAgentMessages;
|
|
24
|
+
exports.getAgentOutputMode = require_decision.getAgentOutputMode;
|
|
25
|
+
exports.getAgentRequests = require_src.getAgentRequests;
|
|
26
|
+
exports.getJsonSchema = require_decision.getJsonSchema;
|
|
27
|
+
exports.getJsonSchemaSync = require_decision.getJsonSchemaSync;
|
|
28
|
+
exports.getMachineStructuralHash = require_decision.getMachineStructuralHash;
|
|
29
|
+
exports.getStateMeta = require_decision.getStateMeta;
|
|
30
|
+
exports.initialAgentStep = require_src.initialAgentStep;
|
|
31
|
+
exports.inspectTransitions = require_run_agent.inspectTransitions;
|
|
32
|
+
exports.isStandardSchema = require_decision.isStandardSchema;
|
|
33
|
+
exports.isStructuredOutputSchema = require_decision.isStructuredOutputSchema;
|
|
34
|
+
exports.lintAgentMachine = require_src.lintAgentMachine;
|
|
35
|
+
exports.matchesEventPattern = require_decision.matchesEventPattern;
|
|
36
|
+
exports.messagesSchema = require_run_agent.messagesSchema;
|
|
37
|
+
exports.parseAgentEvent = require_decision.parseAgentEvent;
|
|
38
|
+
exports.parseModelRef = require_decision.parseModelRef;
|
|
39
|
+
exports.parseOutput = require_decision.parseOutput;
|
|
40
|
+
exports.parseStructuredEnvelope = require_decision.parseStructuredEnvelope;
|
|
41
|
+
exports.persistSnapshot = require_decision.persistSnapshot;
|
|
42
|
+
exports.renderDecisionAttempts = require_decision.renderDecisionAttempts;
|
|
43
|
+
exports.resolveAgentRequests = require_src.resolveAgentRequests;
|
|
44
|
+
exports.resolveAgentStep = require_src.resolveAgentStep;
|
|
45
|
+
exports.resolveDecision = require_decision.resolveDecision;
|
|
46
|
+
exports.runAgent = require_run_agent.runAgent;
|
|
47
|
+
exports.runAgentToCompletion = require_run_agent.runAgentToCompletion;
|
|
48
|
+
Object.defineProperty(exports, "setupAgent", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function() {
|
|
51
|
+
return require_run_agent.setupAgent;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
exports.simulateAgent = require_src.simulateAgent;
|
|
55
|
+
exports.systemMessage = require_decision.systemMessage;
|
|
56
|
+
exports.toolMessage = require_decision.toolMessage;
|
|
57
|
+
exports.transitionAgentStep = require_src.transitionAgentStep;
|
|
58
|
+
exports.userMessage = require_decision.userMessage;
|
|
59
|
+
exports.validateSchemaSync = require_decision.validateSchemaSync;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { A as UserMessage, C as StandardSchemaV1, D as ToolMessage, E as ToolCallPart, O as ToolResultOutput, S as ProviderOptions, T as TextPart, _ as EventUnion, a as AgentTool, b as InferOutput, c as AgentToolExecute, d as AllowedEventPattern, f as AllowedEvents, g as EventPayload, h as DataContent, i as AgentSnapshotStore, k as ToolResultPart, l as AgentToolSchema, m as ChosenEvent, n as AgentEventSchemaInputMap, o as AgentToolChoice, p as AssistantMessage, r as AgentMessage, s as AgentToolDescriptor, t as AgentEventSchemaInput, u as AgentTools, v as FilePart, w as SystemMessage, x as NormalizedEventSchemas, y as ImagePart } from "./types-C9QiMjre.cjs";
|
|
2
|
+
import { A as AgentDecisionInput, B as renderDecisionAttempts, C as createTextLogic, D as parseOutput, E as parseModelRef, F as DecisionExhaustedError, G as AgentRequestSource, H as AgentEventDescriptor, I as DecisionLogic, J as matchesEventPattern, K as EVENT_TOOL_PREFIX, L as DecisionLogicConfig, M as AgentPlanInput, N as AgentPlanOutput, O as parseStructuredEnvelope, P as DecisionAttempt, R as PLAN_DONE_EVENT_TYPE, S as buildEnvelopeSchema, T as isStructuredOutputSchema, U as AgentEventToolNameResolver, V as resolveDecision, W as AgentRequestOptions, Y as parseAgentEvent, _ as TextLogicExecuteArgs, a as AgentRequestExecutorInfo, b as TextLogicOutput, c as AgentRequestMode, d as AiSdkShapedStreamResult, f as AiSdkShapedTextResult, g as TextLogicConfig, h as TextLogic, i as AgentRequestExecutor, j as AgentDecisionRequest, k as AgentDecisionExecutor, l as AgentTextRequest, m as StructuredOutputEnvelope, n as AgentModelRef, o as AgentRequestExecutorResult, q as getAcceptedEvents, r as AgentOutputMode, s as AgentRequestExecutors, t as AgentModelMap, u as AgentUserInput, v as TextLogicExecutor, w as getAgentOutputMode, x as bindRequestExecutor, y as TextLogicInput, z as ResolveDecisionOptions } from "./text-logic-CZjyACzQ.cjs";
|
|
3
|
+
import { A as AgentSchemaPack, B as AgentWorkflowStateConfig, C as initialAgentStep, D as AgentMachine, E as transitionAgentStep, F as AgentWorkflowActionConfig, G as messagesSchema, H as FromConfigOptions, I as AgentWorkflowActorConfig, L as AgentWorkflowConfig, M as AgentStateNarrowing, N as createAgentSchemas, O as AgentMachineConfig, P as setupAgent, R as AgentWorkflowInvokeConfig, S as getAgentRequests, T as resolveAgentStep, U as SchemaCompiler, V as AgentWorkflowTransitionConfig, W as appendMessages, _ as AgentRequest, a as AgentUserInputExecutor, b as ResolveAgentRequestsOptions, c as PendingUserInput, d as SnapshotVersionMismatchError, f as inspectTransitions, g as AgentPlanRequest, h as AgentStateRequest, i as AgentTraceEvent, j as AgentSetupStateSchema, k as AgentRequestConfig, l as RunAgentOptions, m as runAgentToCompletion, n as AgentMessageInfo, o as IllegalResumeEventError, p as runAgent, r as AgentRunMeta, s as InspectedActorRef, t as AgentIdleError, u as RunAgentResult, v as AgentStep, w as resolveAgentRequests, x as executeAgentRequest, y as AgentStepRequest, z as AgentWorkflowRequestConfig } from "./run-agent-BVMd--1l.cjs";
|
|
4
|
+
import { a as getMachineStructuralHash, c as persistSnapshot, d as userMessage, f as validateSchemaSync, i as getJsonSchemaSync, l as systemMessage, n as getAgentMessages, o as getStateMeta, r as getJsonSchema, s as isStandardSchema, t as assistantMessage, u as toolMessage } from "./utils-Dri7aeEG.cjs";
|
|
5
|
+
import { AnyMachineSnapshot, AnyStateMachine } from "xstate";
|
|
6
|
+
|
|
7
|
+
//#region src/verify.d.ts
|
|
8
|
+
/** Severity of an {@link AgentLintDiagnostic}. `error` findings fail CI/the CLI; `warning`s are advisory. */
|
|
9
|
+
type AgentLintSeverity = "error" | "warning";
|
|
10
|
+
/**
|
|
11
|
+
* One static-analysis finding from {@link lintAgentMachine}. `code` names the
|
|
12
|
+
* check (stable, machine-readable), `path` points at the offending state path
|
|
13
|
+
* or config location, and `message` explains the problem and its remedy.
|
|
14
|
+
*/
|
|
15
|
+
interface AgentLintDiagnostic {
|
|
16
|
+
code: "unreachable-state" | "decide-without-events" | "unserializable-context" | "direct-object-src" | "final-without-output" | "final-output-reads-event" | "missing-final";
|
|
17
|
+
severity: AgentLintSeverity;
|
|
18
|
+
/** State path (`parent.child`) or config pointer (e.g. `(root)`, `context`) the finding is about. */
|
|
19
|
+
path: string;
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
22
|
+
/** Options for {@link lintAgentMachine}. Reserved for future check selection. */
|
|
23
|
+
interface LintAgentMachineOptions {
|
|
24
|
+
/** Skip these check codes entirely. */
|
|
25
|
+
disable?: AgentLintDiagnostic["code"][];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Runs static structural checks over a built agent machine and returns the
|
|
29
|
+
* findings ({@link AgentLintDiagnostic}[], empty when clean). Works for
|
|
30
|
+
* TS-authored (`setupAgent(...).createMachine(...)`) and
|
|
31
|
+
* `setupAgent.fromConfig(...)`-compiled machines alike, reading `machine.config`
|
|
32
|
+
* plus the schemas/actor sources the library already retains per machine.
|
|
33
|
+
*
|
|
34
|
+
* No model calls, no API keys — a coding agent that emits an agent machine can
|
|
35
|
+
* call this to catch dead states, undeliverable decisions, un-rebindable
|
|
36
|
+
* invoke srcs, and output-contract gaps before ever running it.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const errors = lintAgentMachine(machine).filter((d) => d.severity === 'error');
|
|
41
|
+
* if (errors.length) throw new Error(errors.map((e) => `${e.path}: ${e.message}`).join('\n'));
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function lintAgentMachine(machine: AnyStateMachine, options?: LintAgentMachineOptions): AgentLintDiagnostic[];
|
|
45
|
+
/** Options for {@link assertAgentMachine}. */
|
|
46
|
+
interface AssertAgentMachineOptions extends LintAgentMachineOptions {
|
|
47
|
+
/** Also fail on warning-severity findings. Default: errors only. */
|
|
48
|
+
warnings?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Thrown by {@link assertAgentMachine} when lint finds failing diagnostics.
|
|
52
|
+
* `diagnostics` holds the findings; the message lists them one per finding,
|
|
53
|
+
* so a test runner's failure output reads like the CLI's lint report.
|
|
54
|
+
*/
|
|
55
|
+
declare class AgentLintError extends Error {
|
|
56
|
+
diagnostics: AgentLintDiagnostic[];
|
|
57
|
+
constructor(machineId: string, diagnostics: AgentLintDiagnostic[]);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Asserts a machine passes {@link lintAgentMachine}: returns silently when
|
|
61
|
+
* clean, throws {@link AgentLintError} (with the findings on `.diagnostics`)
|
|
62
|
+
* otherwise. Fails on error-severity findings; set `warnings: true` to fail on
|
|
63
|
+
* warnings too. The one-liner for tests and generation loops:
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* test('agent machine is structurally sound', () => {
|
|
68
|
+
* assertAgentMachine(machine);
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function assertAgentMachine(machine: AnyStateMachine, options?: AssertAgentMachineOptions): void;
|
|
73
|
+
/**
|
|
74
|
+
* Scripted responses for a {@link simulateAgent} playthrough. Each channel is a
|
|
75
|
+
* by-`src` map of FIFO queues, consumed in the order the machine reaches the
|
|
76
|
+
* requests:
|
|
77
|
+
* - `text` — output values for text requests, keyed by request src (the
|
|
78
|
+
* `setupAgent({ requests })` key, or `agent.generateText`/`agent.streamText`).
|
|
79
|
+
* - `decisions` — the {@link ChosenEvent} to apply for a decision request,
|
|
80
|
+
* keyed by decision src (usually `agent.decide`).
|
|
81
|
+
* - `userInput` — output values for `agent.userInput` invokes, keyed by src
|
|
82
|
+
* (usually `agent.userInput`).
|
|
83
|
+
*/
|
|
84
|
+
interface SimulationScript {
|
|
85
|
+
text?: Record<string, unknown[]>;
|
|
86
|
+
decisions?: Record<string, ChosenEvent[]>;
|
|
87
|
+
userInput?: Record<string, unknown[]>;
|
|
88
|
+
}
|
|
89
|
+
/** One entry in a {@link SimulateAgentResult.trail}: the state after this step, plus what drove the step. */
|
|
90
|
+
interface SimulationTrailEntry {
|
|
91
|
+
/** The machine state value after applying this step. */
|
|
92
|
+
state: unknown;
|
|
93
|
+
/** The chosen event applied (for a decision request). */
|
|
94
|
+
appliedEvent?: ChosenEvent;
|
|
95
|
+
/** The resolved request (for a text/userInput invoke): its kind and src. */
|
|
96
|
+
resolvedRequest?: {
|
|
97
|
+
kind: "text" | "userInput";
|
|
98
|
+
src: string;
|
|
99
|
+
id: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Options for {@link simulateAgent}. */
|
|
103
|
+
interface SimulateAgentOptions {
|
|
104
|
+
input?: unknown;
|
|
105
|
+
script: SimulationScript;
|
|
106
|
+
/** Max steps before returning `'exhausted'`. Default 100. */
|
|
107
|
+
maxSteps?: number;
|
|
108
|
+
}
|
|
109
|
+
/** The outcome of a {@link simulateAgent} playthrough. */
|
|
110
|
+
interface SimulateAgentResult {
|
|
111
|
+
/** `'done'` = reached a final state; `'idle'` = paused with no pending work; `'exhausted'` = hit `maxSteps`. */
|
|
112
|
+
status: "done" | "idle" | "exhausted";
|
|
113
|
+
snapshot: AnyMachineSnapshot;
|
|
114
|
+
trail: SimulationTrailEntry[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Deterministically plays a machine through, resolving each request from a
|
|
118
|
+
* {@link SimulationScript} instead of a model — no API keys, no model calls.
|
|
119
|
+
* Runs on the pure step path ({@link initialAgentStep} etc.), so it exercises
|
|
120
|
+
* the real transition logic. Returns the terminal `status`, final `snapshot`,
|
|
121
|
+
* and a `trail` of every step taken.
|
|
122
|
+
*
|
|
123
|
+
* Throws a descriptive error when the script runs dry mid-request, naming the
|
|
124
|
+
* pending request's kind, src, and id so the missing scripted response is
|
|
125
|
+
* obvious.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* const { status, snapshot } = simulateAgent(machine, {
|
|
130
|
+
* input: { topic: 'state machines' },
|
|
131
|
+
* script: { decisions: { 'agent.decide': [{ type: 'END' }] } },
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare function simulateAgent(machine: AnyStateMachine, options: SimulateAgentOptions): Promise<SimulateAgentResult>;
|
|
136
|
+
/** Options for {@link explorePaths}. */
|
|
137
|
+
interface ExplorePathsOptions {
|
|
138
|
+
input?: unknown;
|
|
139
|
+
/** Max branch points (decisions + external-event forks) along any path. Default 8. */
|
|
140
|
+
maxDepth?: number;
|
|
141
|
+
/** Total path cap before exploration stops (reported via `hitPathCap`). Default 200. */
|
|
142
|
+
maxPaths?: number;
|
|
143
|
+
/** Canned outputs for text/userInput invokes, keyed by src. A missing src halts that branch with a `needs-output` note. */
|
|
144
|
+
textOutputs?: Record<string, unknown>;
|
|
145
|
+
}
|
|
146
|
+
/** A single explored path's terminal outcome. */
|
|
147
|
+
interface AgentPathTerminal {
|
|
148
|
+
status: "done" | "idle" | "needs-output" | "max-depth";
|
|
149
|
+
/** The chosen/applied events, in order, that produced this terminal. */
|
|
150
|
+
path: ChosenEvent[];
|
|
151
|
+
/** The final state value on this path. */
|
|
152
|
+
state: unknown;
|
|
153
|
+
/** For `needs-output`: the src whose canned output was missing. */
|
|
154
|
+
missingSrc?: string;
|
|
155
|
+
}
|
|
156
|
+
/** The report returned by {@link explorePaths}. */
|
|
157
|
+
interface AgentPathReport {
|
|
158
|
+
/** Every distinct state value (JSON) encountered across all explored paths. */
|
|
159
|
+
reachedStates: unknown[];
|
|
160
|
+
/** One entry per explored path. */
|
|
161
|
+
terminals: AgentPathTerminal[];
|
|
162
|
+
/** How many candidate events were pruned because a guard rejected them. */
|
|
163
|
+
prunedByGuard: number;
|
|
164
|
+
/** Notes about coverage the exploration could not complete (missing outputs, depth/path caps). */
|
|
165
|
+
unexplored: string[];
|
|
166
|
+
/** Total paths explored. */
|
|
167
|
+
pathsExplored: number;
|
|
168
|
+
/** True when the total-paths cap was hit (report is partial). */
|
|
169
|
+
hitPathCap: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Enumerates a machine's decision and external-event branches to a bounded
|
|
173
|
+
* depth, model-free, and reports which states are reached and how each path
|
|
174
|
+
* terminates. At each decision request it forks one branch per candidate event
|
|
175
|
+
* (guard-rejected candidates are counted in `prunedByGuard`, not explored); at
|
|
176
|
+
* an idle wait it forks per externally-accepted event. A `agent.plan` request
|
|
177
|
+
* forks the same way — one branch per candidate, including the reserved
|
|
178
|
+
* `agent.plan.done` move — advancing each branch through the real plan protocol
|
|
179
|
+
* (`resolveAgentRequests`), so a plan can consume several depth units. Text/`userInput` invokes
|
|
180
|
+
* are resolved from `textOutputs` (a by-src canned-output map) — a missing src
|
|
181
|
+
* halts that branch with a `needs-output` terminal rather than throwing.
|
|
182
|
+
*
|
|
183
|
+
* Combinatorics are bounded by `maxDepth` (default 8) and `maxPaths` (default
|
|
184
|
+
* 200, reported via `hitPathCap`).
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* const report = await explorePaths(refundMachine, { input: { request: 'x', amount: 5000 } });
|
|
189
|
+
* // report.terminals → both 'refunded' and 'denied'; report.prunedByGuard → 1
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare function explorePaths(machine: AnyStateMachine, options?: ExplorePathsOptions): Promise<AgentPathReport>;
|
|
193
|
+
/** The result of a {@link canReach} query. */
|
|
194
|
+
interface CanReachResult {
|
|
195
|
+
canReach: boolean;
|
|
196
|
+
/** When reachable, the sequence of chosen/applied events that gets there. */
|
|
197
|
+
witness?: ChosenEvent[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Answers "can the machine reach `statePath`?" by exploring its branches (a
|
|
201
|
+
* thin wrapper over {@link explorePaths}). Returns `{ canReach: true, witness }`
|
|
202
|
+
* with the event sequence that reaches it, or `{ canReach: false }`.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* const { canReach, witness } = await canReach(refundMachine, 'denied', { input: { request: 'x', amount: 5000 } });
|
|
207
|
+
* // canReach → true; witness → [{ type: 'NEEDS_REVIEW' }, { type: 'DENY' }]
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
declare function canReach(machine: AnyStateMachine, statePath: string, options?: ExplorePathsOptions): Promise<CanReachResult>;
|
|
211
|
+
//#endregion
|
|
212
|
+
export { type AgentDecisionExecutor, type AgentDecisionInput, type AgentDecisionRequest, type AgentEventDescriptor, type AgentEventSchemaInput, type AgentEventSchemaInputMap, type AgentEventToolNameResolver, AgentIdleError, type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentMachine, type AgentMachineConfig, type AgentMessage, type AgentMessageInfo, type AgentModelMap, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, type AgentPlanInput, type AgentPlanOutput, type AgentPlanRequest, type AgentRequest, type AgentRequestConfig, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestMode, type AgentRequestOptions, type AgentRequestSource, type AgentRunMeta, type AgentSchemaPack, type AgentSetupStateSchema, type AgentSnapshotStore, type AgentStateNarrowing, type AgentStateRequest, type AgentStep, type AgentStepRequest, type AgentTextRequest, type AgentTool, type AgentToolChoice, type AgentToolDescriptor, type AgentToolExecute, type AgentToolSchema, type AgentTools, type AgentTraceEvent, type AgentUserInput, type AgentUserInputExecutor, type AgentWorkflowActionConfig, type AgentWorkflowActorConfig, type AgentWorkflowConfig, type AgentWorkflowInvokeConfig, type AgentWorkflowRequestConfig, type AgentWorkflowStateConfig, type AgentWorkflowTransitionConfig, type AiSdkShapedStreamResult, type AiSdkShapedTextResult, type AllowedEventPattern, type AllowedEvents, type AssertAgentMachineOptions, type AssistantMessage, type CanReachResult, type ChosenEvent, type DataContent, type DecisionAttempt, DecisionExhaustedError, type DecisionLogic, type DecisionLogicConfig, EVENT_TOOL_PREFIX, type EventPayload, type EventUnion, type ExplorePathsOptions, type FilePart, type FromConfigOptions, IllegalResumeEventError, type ImagePart, type InferOutput, type InspectedActorRef, type LintAgentMachineOptions, type NormalizedEventSchemas, PLAN_DONE_EVENT_TYPE, type PendingUserInput, type ProviderOptions, type ResolveAgentRequestsOptions, type ResolveDecisionOptions, type RunAgentOptions, type RunAgentResult, type SchemaCompiler, type SimulateAgentOptions, type SimulateAgentResult, type SimulationScript, type SimulationTrailEntry, SnapshotVersionMismatchError, type StandardSchemaV1, type StructuredOutputEnvelope, type SystemMessage, type TextLogic, type TextLogicConfig, type TextLogicExecuteArgs, type TextLogicExecutor, type TextLogicInput, type TextLogicOutput, type TextPart, type ToolCallPart, type ToolMessage, type ToolResultOutput, type ToolResultPart, type UserMessage, appendMessages, assertAgentMachine, assistantMessage, bindRequestExecutor, buildEnvelopeSchema, canReach, createAgentSchemas, createTextLogic, executeAgentRequest, explorePaths, getAcceptedEvents, getAgentMessages, getAgentOutputMode, getAgentRequests, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getStateMeta, initialAgentStep, inspectTransitions, isStandardSchema, isStructuredOutputSchema, lintAgentMachine, matchesEventPattern, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, persistSnapshot, renderDecisionAttempts, resolveAgentRequests, resolveAgentStep, resolveDecision, runAgent, runAgentToCompletion, setupAgent, simulateAgent, systemMessage, toolMessage, transitionAgentStep, userMessage, validateSchemaSync };
|