@statelyai/agent 2.0.0-alpha.37 → 2.0.0-alpha.39
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/CHANGELOG.md +51 -0
- package/dist/{act-CrX0JwWY.cjs → act-B0CVbmo4.cjs} +1 -1
- package/dist/{act-B9hLQls6.mjs → act-Bsz-hUfD.mjs} +1 -1
- package/dist/ai-sdk.cjs +4 -4
- package/dist/ai-sdk.d.cts +2 -3
- package/dist/ai-sdk.d.mts +2 -3
- package/dist/ai-sdk.mjs +4 -4
- package/dist/{decision-m5hGmHpF.mjs → decision-B41YBx5U.mjs} +1 -1
- package/dist/{decision-CMeuNZ1g.cjs → decision-D8bcIGXQ.cjs} +1 -1
- package/dist/{decision-object-DBcLWVvv.d.cts → decision-object-BB8XV5Ec.d.cts} +1 -1
- package/dist/{decision-object-B5zGSPFp.d.mts → decision-object-CH_sE694.d.mts} +1 -1
- package/dist/effects-B9IvUPVh.mjs +23 -0
- package/dist/effects-DrWcUGgc.cjs +34 -0
- package/dist/evals.cjs +810 -0
- package/dist/evals.d.cts +595 -0
- package/dist/evals.d.mts +595 -0
- package/dist/evals.mjs +801 -0
- package/dist/{event-log-DkVlk3Rh.mjs → event-log-CEq_bVXQ.mjs} +8 -4
- package/dist/{event-log-Dkc-yIYu.cjs → event-log-dSOnXHuG.cjs} +7 -15
- package/dist/{event-log-store-Brx9tOHt.mjs → event-log-store-DLAfNM34.mjs} +1 -1
- package/dist/{event-log-store-BBS8so8a.d.mts → event-log-store-DYun526m.d.mts} +15 -14
- package/dist/{event-log-store-Cl-YWDnq.cjs → event-log-store-Dey9ufA4.cjs} +1 -1
- package/dist/{event-log-store-bc4ICGcS.d.cts → event-log-store-aFXK6yZX.d.cts} +15 -14
- package/dist/index.cjs +136 -98
- package/dist/index.d.cts +73 -134
- package/dist/index.d.mts +73 -134
- package/dist/index.mjs +117 -75
- package/dist/internal-BzlpzSux.d.cts +14 -0
- package/dist/internal-BzlpzSux.d.mts +14 -0
- package/dist/log.cjs +2 -3
- package/dist/log.d.cts +2 -2
- package/dist/log.d.mts +2 -2
- package/dist/log.mjs +3 -3
- package/dist/machines.cjs +1 -719
- package/dist/machines.d.cts +2 -424
- package/dist/machines.d.mts +2 -424
- package/dist/machines.mjs +2 -709
- package/dist/{model-source-kjGwqAV8.mjs → model-source-BrsLDvHL.mjs} +1 -1
- package/dist/{model-source-B4WQ8Idp.cjs → model-source-YpxjmWuX.cjs} +1 -1
- package/dist/openai.cjs +3 -3
- package/dist/openai.d.cts +2 -3
- package/dist/openai.d.mts +2 -3
- package/dist/openai.mjs +3 -3
- package/dist/otel.d.cts +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/policy.cjs +77 -0
- package/dist/policy.d.cts +143 -0
- package/dist/policy.d.mts +143 -0
- package/dist/policy.mjs +75 -0
- package/dist/{effects-BT_cSY0j.mjs → run-agent-BE7DOWD6.mjs} +150 -184
- package/dist/{run-agent-DlPzBWj-.d.mts → run-agent-DHlq87G7.d.mts} +18 -34
- package/dist/{effects-DDseYtJk.cjs → run-agent-De3xVFGw.cjs} +149 -201
- package/dist/{run-agent-30mH2moE.d.cts → run-agent-Dq0oSFRm.d.cts} +18 -34
- package/dist/{setup-agent-BDmNr6PC.mjs → setup-agent-CLm6QVGy.mjs} +3 -3
- package/dist/{setup-agent-BaNyz6Q3.d.cts → setup-agent-Cv8Hk3mX.d.cts} +12 -11
- package/dist/{setup-agent-C1CG_nfX.d.mts → setup-agent-DgFAhaPJ.d.mts} +12 -11
- package/dist/{setup-agent-CmEToB8y.cjs → setup-agent-Dv5VpuHe.cjs} +3 -3
- package/dist/tanstack-ai.cjs +4 -4
- package/dist/tanstack-ai.d.cts +2 -3
- package/dist/tanstack-ai.d.mts +2 -3
- package/dist/tanstack-ai.mjs +4 -4
- package/dist/testing.cjs +122 -996
- package/dist/testing.d.cts +36 -695
- package/dist/testing.d.mts +36 -695
- package/dist/testing.mjs +112 -977
- package/dist/{text-logic-BqxalgMr.d.mts → text-logic-x17uLBwA.d.cts} +238 -2
- package/dist/{text-logic-CSf9bqpP.d.cts → text-logic-x17uLBwA.d.mts} +238 -2
- package/dist/trajectory-BFjXaooB.d.cts +96 -0
- package/dist/trajectory-BFjXaooB.d.mts +96 -0
- package/dist/trajectory-BUXj_1Ue.mjs +152 -0
- package/dist/trajectory-CoZSv4wF.cjs +157 -0
- package/dist/{usage-Bm5nvpow.d.cts → usage-B4B-TQSV.d.mts} +1 -1
- package/dist/{usage-BnikdOca.d.mts → usage-DvGcoK6x.d.cts} +1 -1
- package/dist/{utils-7lSa4H-i.d.cts → utils-B8k-YPYI.d.mts} +23 -17
- package/dist/{utils-CBbKw2fM.d.mts → utils-DAclF-kw.d.cts} +23 -17
- package/dist/validate.cjs +4 -4
- package/dist/validate.d.cts +2 -2
- package/dist/validate.d.mts +2 -2
- package/dist/validate.mjs +4 -4
- package/dist/{verify-DJHfEfm6.d.cts → verify-BM0sGmsf.d.cts} +42 -6
- package/dist/{verify-ChyX6jq0.mjs → verify-CWlg3j7B.mjs} +153 -45
- package/dist/{verify-CwlombbC.cjs → verify-Dek6gHCS.cjs} +153 -45
- package/dist/{verify-i9Hiwc5g.d.mts → verify-H3Pr2gNw.d.mts} +42 -6
- package/dist/{with-model-calls-B_WLmOSl.cjs → with-model-calls-D50Ca6qW.cjs} +2 -2
- package/dist/{with-model-calls-BkOwdroS.mjs → with-model-calls-uY-KKliA.mjs} +2 -2
- package/docs/advanced.md +5 -5
- package/docs/choosing-a-run-mode.md +7 -7
- package/docs/debugging.md +6 -8
- package/docs/decisions.md +6 -5
- package/docs/environment-and-policy.md +1 -1
- package/docs/evals.md +57 -43
- package/docs/event-log.md +14 -16
- package/docs/from-a-loop.md +3 -3
- package/docs/generate-machines.md +4 -4
- package/docs/hosts.md +22 -29
- package/docs/human-in-the-loop.md +5 -8
- package/docs/index.md +4 -4
- package/docs/judgments.md +5 -7
- package/docs/langgraph-comparison.md +6 -6
- package/docs/machines-as-data.md +12 -17
- package/docs/machines-presets.md +17 -120
- package/docs/machines.md +13 -13
- package/docs/models-and-providers.md +19 -25
- package/docs/multi-agent.md +1 -1
- package/docs/observability.md +6 -8
- package/docs/persistence.md +15 -25
- package/docs/quickstart.md +4 -4
- package/docs/statechart-policy-examples.md +1 -1
- package/docs/steps.md +5 -6
- package/docs/strangler-fig.md +72 -7
- package/docs/text-requests.md +10 -12
- package/docs/thinking-in-state-machines.md +8 -8
- package/docs/tools.md +10 -12
- package/docs/upgrading.md +1 -1
- package/docs/usage-and-budgets.md +51 -56
- package/docs/validate-and-repair.md +9 -14
- package/docs/verify.md +53 -7
- package/docs/xstate-4-and-5-apps.md +19 -28
- package/llms.txt +1 -1
- package/package.json +31 -6
- package/readme.md +32 -24
- package/dist/internal-C3Lqu538.d.cts +0 -43
- package/dist/internal-DUcdhk-i.d.mts +0 -43
- package/dist/types-DQUOOaZO.d.cts +0 -238
- package/dist/types-DQUOOaZO.d.mts +0 -238
- package/skills/add-evals/SKILL.md +0 -152
- package/skills/add-traces/SKILL.md +0 -152
- package/skills/build-machine/SKILL.md +0 -84
- package/skills/generate-machine/SKILL.md +0 -335
- package/skills/graph-engineering/SKILL.md +0 -43
- package/skills/improve-machine/SKILL.md +0 -261
- package/skills/improve-machine/reference.md +0 -101
- package/skills/loop-to-machine/SKILL.md +0 -205
- package/skills/loop-to-machine/policy.md +0 -154
- package/skills/loop-to-machine/reference.md +0 -260
|
@@ -1002,6 +1002,7 @@ function assertAgentLogEntry(entry) {
|
|
|
1002
1002
|
if (candidate.verification !== void 0 && (candidate.verification === null || typeof candidate.verification !== "object" || typeof candidate.verification.stateHash !== "string" || !candidate.verification.stateHash)) throw new AgentEventLogError("Agent event entry.verification requires a non-empty stateHash string.");
|
|
1003
1003
|
if (candidate.attempts !== void 0) assertLogAttempts(candidate.attempts);
|
|
1004
1004
|
if (candidate.decidedBy !== void 0) requireNonEmptyString(candidate.decidedBy, "entry.decidedBy", " when present");
|
|
1005
|
+
if (candidate.ignored !== void 0 && candidate.ignored !== true) throw new AgentEventLogError("Agent event entry.ignored must be true when present.");
|
|
1005
1006
|
if (candidate.actorPath !== void 0 && (!Array.isArray(candidate.actorPath) || candidate.actorPath.length === 0 || !candidate.actorPath.every((id) => typeof id === "string" && id !== ""))) throw new AgentEventLogError("Agent event entry.actorPath must be a non-empty array of invoke ids when present.");
|
|
1006
1007
|
}
|
|
1007
1008
|
function assertLogAttempts(attempts) {
|
|
@@ -1641,7 +1642,9 @@ function foldLog(machine, entries, options = {}) {
|
|
|
1641
1642
|
* Records a plain `createActor` run as an event log, with no
|
|
1642
1643
|
* `createAgentRuntime`: the init entry (the actor's `input`, or the snapshot
|
|
1643
1644
|
* it was created from), then every event the root machine processed, invoke
|
|
1644
|
-
* completions with their outputs inline.
|
|
1645
|
+
* completions with their outputs inline. A sent event the machine had no
|
|
1646
|
+
* transition for is recorded too, marked `ignored`. Attach it before
|
|
1647
|
+
* `actor.start()`.
|
|
1645
1648
|
*
|
|
1646
1649
|
* @example
|
|
1647
1650
|
* ```ts no-check
|
|
@@ -1660,7 +1663,7 @@ function recordLog(actor) {
|
|
|
1660
1663
|
let fold;
|
|
1661
1664
|
let failure;
|
|
1662
1665
|
const restored = actor._restored ? actor.getPersistedSnapshot() : void 0;
|
|
1663
|
-
const record = (event) => {
|
|
1666
|
+
const record = (event, ignored) => {
|
|
1664
1667
|
if (fold === void 0) {
|
|
1665
1668
|
if (event.type !== "xstate.init") throw new AgentEventLogError("recordLog must be attached before actor.start(): it missed the init event.");
|
|
1666
1669
|
const init = restored ? { snapshot: restored } : { input: event.input };
|
|
@@ -1675,13 +1678,14 @@ function recordLog(actor) {
|
|
|
1675
1678
|
machineVersion,
|
|
1676
1679
|
verification: false
|
|
1677
1680
|
});
|
|
1681
|
+
if (ignored) entry.ignored = true;
|
|
1678
1682
|
entry.verification = { stateHash: getSnapshotStateHash(fold.apply(entry)) };
|
|
1679
1683
|
entries.push(entry);
|
|
1680
1684
|
};
|
|
1681
1685
|
const subscription = actor.system.inspect((inspectionEvent) => {
|
|
1682
1686
|
if (failure !== void 0 || inspectionEvent.type !== "@xstate.transition" || inspectionEvent.actorRef !== actor) return;
|
|
1683
1687
|
try {
|
|
1684
|
-
record(inspectionEvent.event);
|
|
1688
|
+
record(inspectionEvent.event, inspectionEvent.microsteps.length === 0 && !inspectionEvent.event.type.startsWith("xstate."));
|
|
1685
1689
|
} catch (error) {
|
|
1686
1690
|
failure = error;
|
|
1687
1691
|
}
|
|
@@ -1696,4 +1700,4 @@ function recordLog(actor) {
|
|
|
1696
1700
|
};
|
|
1697
1701
|
}
|
|
1698
1702
|
//#endregion
|
|
1699
|
-
export {
|
|
1703
|
+
export { getJsonSchemaSync as $, bindRequestExecutor as A, parseProviderOutput as B, AGENT_USAGE_EVENT_TYPE as C, DECIDE_ACTOR as D, AGENT_USAGE_TOKEN_FIELDS as E, getCallModelCalls as F, getAgentExecutionOptions as G, resolveTextLogicValue as H, getCallUsage as I, missingActor as J, getRegisteredAgentExecutionOptions as K, isTextLogic as L, createTextLogic as M, getAgentOutputMode as N, GENERATE_TEXT_ACTOR as O, getCallFinishReason as P, getJsonSchema as Q, normalizeGeneratorResult as R, validateReplayEntries as S, ACT_ACTOR as T, responseMessagesOf as U, providerOutputSchema as V, executorBoundLogics as W, assistantMessage as X, setAgentExecutionOptions as Y, findNonSerializableContextPaths as Z, getSnapshotStateHash as _, AgentReplayDivergenceError as a, systemMessage as at, recordLog as b, agentCallSite as c, validateSchemaSync as ct, canonicalEventJson as d, isPlainObject as dt, getMessageText as et, createReplayEntry as f, isRecord as ft, getLogExecutionId as g, getDecisionAttempts as h, AgentMachineVersionMismatchError as i, resolveMachineVersion as it, builtinTextActors as j, STREAM_TEXT_ACTOR as k, assertAgentLogEntry as l, canonicalJson as lt, forkEventLog as m, AgentTruncatedError as mt, AGENT_INIT_EVENT_TYPE as n, getStatePath as nt, NonSerializableAgentEventError as o, toolMessage as ot, foldLog as p, AgentError as pt, isUnboundPlaceholder as q, AgentEventLogError as r, isStandardSchema as rt, agentCallOccurrence as s, userMessage as st, AGENT_EVENT_SCHEMA_VERSION as t, getStateMeta as tt, assertJsonSerializable as u, isError as ut, getUsageFromEvents as v, restoreMachineSnapshot as w, replay as x, initEntry as y, parseOutput as z };
|
|
@@ -1002,6 +1002,7 @@ function assertAgentLogEntry(entry) {
|
|
|
1002
1002
|
if (candidate.verification !== void 0 && (candidate.verification === null || typeof candidate.verification !== "object" || typeof candidate.verification.stateHash !== "string" || !candidate.verification.stateHash)) throw new AgentEventLogError("Agent event entry.verification requires a non-empty stateHash string.");
|
|
1003
1003
|
if (candidate.attempts !== void 0) assertLogAttempts(candidate.attempts);
|
|
1004
1004
|
if (candidate.decidedBy !== void 0) requireNonEmptyString(candidate.decidedBy, "entry.decidedBy", " when present");
|
|
1005
|
+
if (candidate.ignored !== void 0 && candidate.ignored !== true) throw new AgentEventLogError("Agent event entry.ignored must be true when present.");
|
|
1005
1006
|
if (candidate.actorPath !== void 0 && (!Array.isArray(candidate.actorPath) || candidate.actorPath.length === 0 || !candidate.actorPath.every((id) => typeof id === "string" && id !== ""))) throw new AgentEventLogError("Agent event entry.actorPath must be a non-empty array of invoke ids when present.");
|
|
1006
1007
|
}
|
|
1007
1008
|
function assertLogAttempts(attempts) {
|
|
@@ -1641,7 +1642,9 @@ function foldLog(machine, entries, options = {}) {
|
|
|
1641
1642
|
* Records a plain `createActor` run as an event log, with no
|
|
1642
1643
|
* `createAgentRuntime`: the init entry (the actor's `input`, or the snapshot
|
|
1643
1644
|
* it was created from), then every event the root machine processed, invoke
|
|
1644
|
-
* completions with their outputs inline.
|
|
1645
|
+
* completions with their outputs inline. A sent event the machine had no
|
|
1646
|
+
* transition for is recorded too, marked `ignored`. Attach it before
|
|
1647
|
+
* `actor.start()`.
|
|
1645
1648
|
*
|
|
1646
1649
|
* @example
|
|
1647
1650
|
* ```ts no-check
|
|
@@ -1660,7 +1663,7 @@ function recordLog(actor) {
|
|
|
1660
1663
|
let fold;
|
|
1661
1664
|
let failure;
|
|
1662
1665
|
const restored = actor._restored ? actor.getPersistedSnapshot() : void 0;
|
|
1663
|
-
const record = (event) => {
|
|
1666
|
+
const record = (event, ignored) => {
|
|
1664
1667
|
if (fold === void 0) {
|
|
1665
1668
|
if (event.type !== "xstate.init") throw new AgentEventLogError("recordLog must be attached before actor.start(): it missed the init event.");
|
|
1666
1669
|
const init = restored ? { snapshot: restored } : { input: event.input };
|
|
@@ -1675,13 +1678,14 @@ function recordLog(actor) {
|
|
|
1675
1678
|
machineVersion,
|
|
1676
1679
|
verification: false
|
|
1677
1680
|
});
|
|
1681
|
+
if (ignored) entry.ignored = true;
|
|
1678
1682
|
entry.verification = { stateHash: getSnapshotStateHash(fold.apply(entry)) };
|
|
1679
1683
|
entries.push(entry);
|
|
1680
1684
|
};
|
|
1681
1685
|
const subscription = actor.system.inspect((inspectionEvent) => {
|
|
1682
1686
|
if (failure !== void 0 || inspectionEvent.type !== "@xstate.transition" || inspectionEvent.actorRef !== actor) return;
|
|
1683
1687
|
try {
|
|
1684
|
-
record(inspectionEvent.event);
|
|
1688
|
+
record(inspectionEvent.event, inspectionEvent.microsteps.length === 0 && !inspectionEvent.event.type.startsWith("xstate."));
|
|
1685
1689
|
} catch (error) {
|
|
1686
1690
|
failure = error;
|
|
1687
1691
|
}
|
|
@@ -1924,12 +1928,6 @@ Object.defineProperty(exports, "getLogExecutionId", {
|
|
|
1924
1928
|
return getLogExecutionId;
|
|
1925
1929
|
}
|
|
1926
1930
|
});
|
|
1927
|
-
Object.defineProperty(exports, "getMachineStructuralHash", {
|
|
1928
|
-
enumerable: true,
|
|
1929
|
-
get: function() {
|
|
1930
|
-
return getMachineStructuralHash;
|
|
1931
|
-
}
|
|
1932
|
-
});
|
|
1933
1931
|
Object.defineProperty(exports, "getMessageText", {
|
|
1934
1932
|
enumerable: true,
|
|
1935
1933
|
get: function() {
|
|
@@ -2038,12 +2036,6 @@ Object.defineProperty(exports, "providerOutputSchema", {
|
|
|
2038
2036
|
return providerOutputSchema;
|
|
2039
2037
|
}
|
|
2040
2038
|
});
|
|
2041
|
-
Object.defineProperty(exports, "rebindActorSession", {
|
|
2042
|
-
enumerable: true,
|
|
2043
|
-
get: function() {
|
|
2044
|
-
return rebindActorSession;
|
|
2045
|
-
}
|
|
2046
|
-
});
|
|
2047
2039
|
Object.defineProperty(exports, "recordLog", {
|
|
2048
2040
|
enumerable: true,
|
|
2049
2041
|
get: function() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as assertAgentLogEntry, m as forkEventLog, pt as AgentError } from "./event-log-CEq_bVXQ.mjs";
|
|
2
2
|
//#region src/event-log-store.ts
|
|
3
3
|
/**
|
|
4
4
|
* Durable storage for {@link AgentLogEntry} logs: the one interface a host
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as DecisionAttempt, at as AgentError, t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { B as DecisionAttempt, at as AgentError, t as AgentCallUsage } from "./text-logic-x17uLBwA.mjs";
|
|
2
2
|
import { Actor, AnyMachineSnapshot, AnyStateMachine, EventObject, Snapshot, SnapshotFrom } from "xstate";
|
|
3
3
|
//#region src/event-log.d.ts
|
|
4
4
|
/** The durable entry envelope version. */
|
|
@@ -70,6 +70,16 @@ interface AgentLogEntry {
|
|
|
70
70
|
* child's state, not just the root's.
|
|
71
71
|
*/
|
|
72
72
|
actorPath?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Set when the machine had no transition for an event sent to it, in the
|
|
75
|
+
* state the event arrived in, so the event changed nothing. Never set on an
|
|
76
|
+
* `xstate.*` event: a stop or a child's completion changes the snapshot
|
|
77
|
+
* with no transition. Only {@link recordLog} sets it: a plain actor
|
|
78
|
+
* processes every event it is sent, refused ones included.
|
|
79
|
+
* Omitted otherwise. It records what happened in the live run: replay does
|
|
80
|
+
* not read it, and the fold applies the event like any other.
|
|
81
|
+
*/
|
|
82
|
+
ignored?: true;
|
|
73
83
|
}
|
|
74
84
|
/** The payload of the reserved {@link AGENT_INIT_EVENT_TYPE} first entry. */
|
|
75
85
|
interface AgentInitEvent extends EventObject {
|
|
@@ -284,17 +294,6 @@ interface AgentLogDecisionAttempts {
|
|
|
284
294
|
* Entries with neither are skipped.
|
|
285
295
|
*/
|
|
286
296
|
declare function getDecisionAttempts(entries: readonly AgentLogEntry[]): AgentLogDecisionAttempts[];
|
|
287
|
-
/**
|
|
288
|
-
* Rewrites a journaled `xstate.done.actor`/`xstate.error.actor` event's
|
|
289
|
-
* `sessionId` to the session the CURRENT fold minted for that `actorId`.
|
|
290
|
-
*
|
|
291
|
-
* Session ids are re-minted on every fold, and XState drops a completion event
|
|
292
|
-
* whose `sessionId` does not match the live child — silently, as a no-op
|
|
293
|
-
* transition. Rebinding is what makes a journaled completion replayable at all.
|
|
294
|
-
* `sessions` caches the mapping per fold, so a later event referring to the
|
|
295
|
-
* recorded session of an already-stopped child still resolves.
|
|
296
|
-
*/
|
|
297
|
-
declare function rebindActorSession(event: EventObject, snapshot: AnyMachineSnapshot, sessions: Map<string, string>): EventObject;
|
|
298
297
|
/** Options for {@link replay}. */
|
|
299
298
|
interface ReplayOptions {
|
|
300
299
|
/** Explicit expected machine version; defaults to the machine's resolved version. */
|
|
@@ -340,7 +339,9 @@ interface LogRecorder {
|
|
|
340
339
|
* Records a plain `createActor` run as an event log, with no
|
|
341
340
|
* `createAgentRuntime`: the init entry (the actor's `input`, or the snapshot
|
|
342
341
|
* it was created from), then every event the root machine processed, invoke
|
|
343
|
-
* completions with their outputs inline.
|
|
342
|
+
* completions with their outputs inline. A sent event the machine had no
|
|
343
|
+
* transition for is recorded too, marked `ignored`. Attach it before
|
|
344
|
+
* `actor.start()`.
|
|
344
345
|
*
|
|
345
346
|
* @example
|
|
346
347
|
* ```ts no-check
|
|
@@ -453,4 +454,4 @@ declare class AgentEventLogConflictError extends AgentError {
|
|
|
453
454
|
*/
|
|
454
455
|
declare function createInMemoryEventLogStore(): AgentEventLogStore;
|
|
455
456
|
//#endregion
|
|
456
|
-
export {
|
|
457
|
+
export { recordLog as A, createReplayEntry as C, getSnapshotStateHash as D, getLogExecutionId as E, validateReplayEntries as M, getUsageFromEvents as O, assertJsonSerializable as S, getDecisionAttempts as T, NonSerializableAgentEventError as _, AGENT_INIT_EVENT_TYPE as a, agentCallOccurrence as b, AgentLogEntry as c, AgentMachineVersionMismatchError as d, AgentPersistedSnapshot as f, LogRecorder as g, JsonValue as h, AGENT_EVENT_SCHEMA_VERSION as i, replay as j, initEntry as k, AgentLogInit as l, CreateReplayEntryOptions as m, AgentEventLogStore as n, AgentEventLogError as o, AgentReplayDivergenceError as p, createInMemoryEventLogStore as r, AgentInitEvent as s, AgentEventLogConflictError as t, AgentLogVerification as u, ReplayOptions as v, forkEventLog as w, assertAgentLogEntry as x, ReplayResult as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as DecisionAttempt, at as AgentError, t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { B as DecisionAttempt, at as AgentError, t as AgentCallUsage } from "./text-logic-x17uLBwA.cjs";
|
|
2
2
|
import { Actor, AnyMachineSnapshot, AnyStateMachine, EventObject, Snapshot, SnapshotFrom } from "xstate";
|
|
3
3
|
//#region src/event-log.d.ts
|
|
4
4
|
/** The durable entry envelope version. */
|
|
@@ -70,6 +70,16 @@ interface AgentLogEntry {
|
|
|
70
70
|
* child's state, not just the root's.
|
|
71
71
|
*/
|
|
72
72
|
actorPath?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Set when the machine had no transition for an event sent to it, in the
|
|
75
|
+
* state the event arrived in, so the event changed nothing. Never set on an
|
|
76
|
+
* `xstate.*` event: a stop or a child's completion changes the snapshot
|
|
77
|
+
* with no transition. Only {@link recordLog} sets it: a plain actor
|
|
78
|
+
* processes every event it is sent, refused ones included.
|
|
79
|
+
* Omitted otherwise. It records what happened in the live run: replay does
|
|
80
|
+
* not read it, and the fold applies the event like any other.
|
|
81
|
+
*/
|
|
82
|
+
ignored?: true;
|
|
73
83
|
}
|
|
74
84
|
/** The payload of the reserved {@link AGENT_INIT_EVENT_TYPE} first entry. */
|
|
75
85
|
interface AgentInitEvent extends EventObject {
|
|
@@ -284,17 +294,6 @@ interface AgentLogDecisionAttempts {
|
|
|
284
294
|
* Entries with neither are skipped.
|
|
285
295
|
*/
|
|
286
296
|
declare function getDecisionAttempts(entries: readonly AgentLogEntry[]): AgentLogDecisionAttempts[];
|
|
287
|
-
/**
|
|
288
|
-
* Rewrites a journaled `xstate.done.actor`/`xstate.error.actor` event's
|
|
289
|
-
* `sessionId` to the session the CURRENT fold minted for that `actorId`.
|
|
290
|
-
*
|
|
291
|
-
* Session ids are re-minted on every fold, and XState drops a completion event
|
|
292
|
-
* whose `sessionId` does not match the live child — silently, as a no-op
|
|
293
|
-
* transition. Rebinding is what makes a journaled completion replayable at all.
|
|
294
|
-
* `sessions` caches the mapping per fold, so a later event referring to the
|
|
295
|
-
* recorded session of an already-stopped child still resolves.
|
|
296
|
-
*/
|
|
297
|
-
declare function rebindActorSession(event: EventObject, snapshot: AnyMachineSnapshot, sessions: Map<string, string>): EventObject;
|
|
298
297
|
/** Options for {@link replay}. */
|
|
299
298
|
interface ReplayOptions {
|
|
300
299
|
/** Explicit expected machine version; defaults to the machine's resolved version. */
|
|
@@ -340,7 +339,9 @@ interface LogRecorder {
|
|
|
340
339
|
* Records a plain `createActor` run as an event log, with no
|
|
341
340
|
* `createAgentRuntime`: the init entry (the actor's `input`, or the snapshot
|
|
342
341
|
* it was created from), then every event the root machine processed, invoke
|
|
343
|
-
* completions with their outputs inline.
|
|
342
|
+
* completions with their outputs inline. A sent event the machine had no
|
|
343
|
+
* transition for is recorded too, marked `ignored`. Attach it before
|
|
344
|
+
* `actor.start()`.
|
|
344
345
|
*
|
|
345
346
|
* @example
|
|
346
347
|
* ```ts no-check
|
|
@@ -453,4 +454,4 @@ declare class AgentEventLogConflictError extends AgentError {
|
|
|
453
454
|
*/
|
|
454
455
|
declare function createInMemoryEventLogStore(): AgentEventLogStore;
|
|
455
456
|
//#endregion
|
|
456
|
-
export {
|
|
457
|
+
export { recordLog as A, createReplayEntry as C, getSnapshotStateHash as D, getLogExecutionId as E, validateReplayEntries as M, getUsageFromEvents as O, assertJsonSerializable as S, getDecisionAttempts as T, NonSerializableAgentEventError as _, AGENT_INIT_EVENT_TYPE as a, agentCallOccurrence as b, AgentLogEntry as c, AgentMachineVersionMismatchError as d, AgentPersistedSnapshot as f, LogRecorder as g, JsonValue as h, AGENT_EVENT_SCHEMA_VERSION as i, replay as j, initEntry as k, AgentLogInit as l, CreateReplayEntryOptions as m, AgentEventLogStore as n, AgentEventLogError as o, AgentReplayDivergenceError as p, createInMemoryEventLogStore as r, AgentInitEvent as s, AgentEventLogConflictError as t, AgentLogVerification as u, ReplayOptions as v, forkEventLog as w, assertAgentLogEntry as x, ReplayResult as y };
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_event_log = require("./event-log-
|
|
3
|
-
const require_decision = require("./decision-
|
|
4
|
-
const require_act = require("./act-
|
|
5
|
-
const require_setup_agent = require("./setup-agent-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
2
|
+
const require_event_log = require("./event-log-dSOnXHuG.cjs");
|
|
3
|
+
const require_decision = require("./decision-D8bcIGXQ.cjs");
|
|
4
|
+
const require_act = require("./act-B0CVbmo4.cjs");
|
|
5
|
+
const require_setup_agent = require("./setup-agent-Dv5VpuHe.cjs");
|
|
6
|
+
const require_event_log_store = require("./event-log-store-Dey9ufA4.cjs");
|
|
7
|
+
const require_run_agent = require("./run-agent-De3xVFGw.cjs");
|
|
8
|
+
const require_effects = require("./effects-DrWcUGgc.cjs");
|
|
8
9
|
let xstate = require("xstate");
|
|
9
10
|
let acorn = require("acorn");
|
|
10
11
|
//#region src/messages.ts
|
|
@@ -686,7 +687,7 @@ function targetsInSource(source, code, choice) {
|
|
|
686
687
|
const conditional = parts.length > 1 || !choice && (read.declines || read.stays);
|
|
687
688
|
return `${parts.join(", ")}${conditional ? " (conditional)" : ""}`;
|
|
688
689
|
}
|
|
689
|
-
/** One transition, as a line: `on GO (human) if context.ready → review; sets draft
|
|
690
|
+
/** One transition, as a line: `on GO (human) if context.ready → review; sets draft - description`. */
|
|
690
691
|
function transitionLine(source, head, transition, options = {}) {
|
|
691
692
|
const code = codeOf(transition);
|
|
692
693
|
let to;
|
|
@@ -715,7 +716,7 @@ function transitionLine(source, head, transition, options = {}) {
|
|
|
715
716
|
to = "?";
|
|
716
717
|
sets = [];
|
|
717
718
|
}
|
|
718
|
-
return `${head}${human ? " (human)" : ""}${guard ? ` if ${guard}` : ""} → ${to}${sets.length ? `; sets ${sets.join(", ")}` : ""}${description ? `
|
|
719
|
+
return `${head}${human ? " (human)" : ""}${guard ? ` if ${guard}` : ""} → ${to}${sets.length ? `; sets ${sets.join(", ")}` : ""}${description ? ` - ${oneLine(description)}` : ""}`;
|
|
719
720
|
}
|
|
720
721
|
function formatMs(ms) {
|
|
721
722
|
if (ms < 1e3) return `${ms}ms`;
|
|
@@ -779,7 +780,7 @@ function stateLine(node, json) {
|
|
|
779
780
|
const tags = node.tags.length ? ` [tags: ${node.tags.join(", ")}]` : "";
|
|
780
781
|
const interaction = node.meta?.interaction;
|
|
781
782
|
const label = !interaction ? "" : typeof interaction.label === "string" ? ` [interaction: "${oneLine(interaction.label)}"]` : typeof interaction.label === "function" ? " [interaction: computed label]" : " [interaction]";
|
|
782
|
-
const description = node.description ? `
|
|
783
|
+
const description = node.description ? ` - ${oneLine(node.description)}` : "";
|
|
783
784
|
return `${node.key}${marker}${tags}${label}${description}`;
|
|
784
785
|
}
|
|
785
786
|
/** The machine's events with their schema descriptions and fields, sorted by type. */
|
|
@@ -796,13 +797,13 @@ function eventLines(machine) {
|
|
|
796
797
|
}
|
|
797
798
|
const direct = schemas[type].description;
|
|
798
799
|
const description = typeof schema?.description === "string" ? schema.description : typeof direct === "string" ? direct : void 0;
|
|
799
|
-
lines.push(` ${type}${description ? `
|
|
800
|
+
lines.push(` ${type}${description ? ` - ${oneLine(description)}` : ""}`);
|
|
800
801
|
const properties = isObject(schema?.properties) ? schema.properties : {};
|
|
801
802
|
const required = new Set(Array.isArray(schema?.required) ? schema.required : []);
|
|
802
803
|
for (const [field, property] of Object.entries(properties)) {
|
|
803
804
|
if (!isObject(property)) continue;
|
|
804
805
|
const fieldType = Array.isArray(property.enum) ? property.enum.map((value) => JSON.stringify(value)).join(" | ") : Array.isArray(property.type) ? property.type.join(" | ") : typeof property.type === "string" ? property.type : void 0;
|
|
805
|
-
const fieldDescription = typeof property.description === "string" ? `
|
|
806
|
+
const fieldDescription = typeof property.description === "string" ? ` - ${oneLine(property.description)}` : "";
|
|
806
807
|
lines.push(` ${field}${required.has(field) ? "" : "?"}${fieldType ? `: ${fieldType}` : ""}${fieldDescription}`);
|
|
807
808
|
}
|
|
808
809
|
}
|
|
@@ -867,76 +868,117 @@ function describeMachine(machine, options = {}) {
|
|
|
867
868
|
return lines.join("\n");
|
|
868
869
|
}
|
|
869
870
|
//#endregion
|
|
870
|
-
//#region src/
|
|
871
|
+
//#region src/generator-bridge.ts
|
|
872
|
+
/** A `runAgent` result that settled with an error. */
|
|
873
|
+
function isFailedRun(value) {
|
|
874
|
+
return typeof value === "object" && value !== null && value.status === "error" && "error" in value;
|
|
875
|
+
}
|
|
871
876
|
/**
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
877
|
+
* A backpressured hand-off between an actor and an async generator's
|
|
878
|
+
* consumer, for a loop whose public surface is an `AsyncGenerator`: the
|
|
879
|
+
* machine owns the loop head, each pass is an actor, and the events it
|
|
880
|
+
* yields still reach the consumer one pull at a time.
|
|
876
881
|
*
|
|
877
|
-
*
|
|
878
|
-
* like any other decider's choice. The policy's input must be JSON (it opens
|
|
879
|
-
* the policy run's event log): the default drops keys whose value is
|
|
880
|
-
* `undefined`, and any other value that is not JSON throws before the run. The policy's token usage is reported on the
|
|
881
|
-
* result, and left out when the policy made no model call. A run that does not
|
|
882
|
-
* end `done` with an event throws `AgentError` with code `policy-not-done`.
|
|
882
|
+
* One bridge serves one run.
|
|
883
883
|
*
|
|
884
884
|
* @example
|
|
885
|
-
* ```ts
|
|
886
|
-
*
|
|
887
|
-
*
|
|
885
|
+
* ```ts
|
|
886
|
+
* async function* carvedLoop(input: Input): AsyncGenerator<Event, Result> {
|
|
887
|
+
* const bridge = createGeneratorBridge<Event>();
|
|
888
|
+
* const pass = createAsyncLogic({
|
|
889
|
+
* run: async () => {
|
|
890
|
+
* const step = await bridge.forward(legacyPass(input));
|
|
891
|
+
* return step.closed ? { kind: "closed" } : step.value;
|
|
892
|
+
* },
|
|
893
|
+
* });
|
|
894
|
+
* const result = yield* bridge.stream(runAgent(loopMachine, { input, actors: { pass } }));
|
|
895
|
+
* if (result.status === "error") throw result.error;
|
|
896
|
+
* return toResult(result);
|
|
897
|
+
* }
|
|
888
898
|
* ```
|
|
889
899
|
*/
|
|
890
|
-
function
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
900
|
+
function createGeneratorBridge() {
|
|
901
|
+
const queue = [];
|
|
902
|
+
let wake;
|
|
903
|
+
let ended = false;
|
|
904
|
+
const notify = () => {
|
|
905
|
+
const resume = wake;
|
|
906
|
+
wake = void 0;
|
|
907
|
+
resume?.();
|
|
908
|
+
};
|
|
909
|
+
const put = (value) => {
|
|
910
|
+
if (ended) return Promise.resolve(false);
|
|
911
|
+
return new Promise((pulled, threw) => {
|
|
912
|
+
queue.push({
|
|
913
|
+
value,
|
|
914
|
+
pulled,
|
|
915
|
+
threw
|
|
916
|
+
});
|
|
917
|
+
notify();
|
|
902
918
|
});
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
919
|
+
};
|
|
920
|
+
return {
|
|
921
|
+
put,
|
|
922
|
+
async forward(generator) {
|
|
923
|
+
let closed = false;
|
|
924
|
+
let step = await generator.next();
|
|
925
|
+
while (!step.done) {
|
|
926
|
+
let pulled;
|
|
927
|
+
try {
|
|
928
|
+
pulled = await put(step.value);
|
|
929
|
+
} catch (error) {
|
|
930
|
+
step = await generator.throw(error);
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
if (pulled || closed) step = await generator.next();
|
|
934
|
+
else {
|
|
935
|
+
closed = true;
|
|
936
|
+
step = await generator.return(void 0);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return {
|
|
940
|
+
closed,
|
|
941
|
+
value: step.value
|
|
942
|
+
};
|
|
943
|
+
},
|
|
944
|
+
stream(settled) {
|
|
945
|
+
const end = () => {
|
|
946
|
+
ended = true;
|
|
947
|
+
for (const item of queue.splice(0)) item.pulled(false);
|
|
948
|
+
notify();
|
|
949
|
+
};
|
|
950
|
+
Promise.resolve(settled).then(end, end);
|
|
951
|
+
const next = async () => {
|
|
952
|
+
while (!queue.length && !ended) await new Promise((resolve) => wake = resolve);
|
|
953
|
+
return queue.shift();
|
|
954
|
+
};
|
|
955
|
+
const loop = async function* (stopped) {
|
|
956
|
+
while (true) {
|
|
957
|
+
const item = await next();
|
|
958
|
+
if (!item) {
|
|
959
|
+
const result = await settled;
|
|
960
|
+
if (stopped && isFailedRun(result)) throw result.error;
|
|
961
|
+
return result;
|
|
962
|
+
}
|
|
963
|
+
let resumed = false;
|
|
964
|
+
try {
|
|
965
|
+
yield item.value;
|
|
966
|
+
resumed = true;
|
|
967
|
+
item.pulled(true);
|
|
968
|
+
} catch (error) {
|
|
969
|
+
resumed = true;
|
|
970
|
+
item.threw(error);
|
|
971
|
+
} finally {
|
|
972
|
+
if (!resumed) {
|
|
973
|
+
item.pulled(false);
|
|
974
|
+
return yield* loop(true);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
return loop(false);
|
|
906
980
|
}
|
|
907
|
-
const event = result.output;
|
|
908
|
-
if (!require_event_log.isRecord(event) || typeof event.type !== "string") throw new require_event_log.AgentError("policy-not-done", `policy '${id}' output is not an event: ${JSON.stringify(event)}`);
|
|
909
|
-
const { modelCalls, ...usage } = result.usage;
|
|
910
|
-
return {
|
|
911
|
-
event,
|
|
912
|
-
...modelCalls > 0 ? { usage } : {}
|
|
913
|
-
};
|
|
914
981
|
};
|
|
915
|
-
async function policyThread(request, policyInput, info) {
|
|
916
|
-
if (threadId) return threadId(request, info);
|
|
917
|
-
if (info?.callKey) return `policy:${info.callKey}:${await sha256(require_event_log.canonicalEventJson(policyInput))}`;
|
|
918
|
-
throw new require_event_log.AgentError("missing-thread-id", `policy '${id}' has a store but no threadId, and the decision came with no callKey to derive one from`);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
function defaultInput(request) {
|
|
922
|
-
const facts = request.metadata?.facts;
|
|
923
|
-
return withoutUndefinedKeys({
|
|
924
|
-
facts,
|
|
925
|
-
options: (request.options ?? []).map((option) => option.event),
|
|
926
|
-
system: request.system,
|
|
927
|
-
prompt: request.prompt
|
|
928
|
-
});
|
|
929
|
-
}
|
|
930
|
-
/** A copy of `value` with every object key whose value is `undefined` removed, at any depth. */
|
|
931
|
-
function withoutUndefinedKeys(value) {
|
|
932
|
-
if (Array.isArray(value)) return value.map(withoutUndefinedKeys);
|
|
933
|
-
if (!require_event_log.isRecord(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) return value;
|
|
934
|
-
return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0).map(([key, child]) => [key, withoutUndefinedKeys(child)]));
|
|
935
|
-
}
|
|
936
|
-
/** Hex SHA-256 of `text`, with Web Crypto (Node, browsers, workers). */
|
|
937
|
-
async function sha256(text) {
|
|
938
|
-
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
939
|
-
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
940
982
|
}
|
|
941
983
|
//#endregion
|
|
942
984
|
//#region src/wrap-workflow.ts
|
|
@@ -967,19 +1009,19 @@ function observeEffects(effects, send, signal, redact = (_name, _part, value) =>
|
|
|
967
1009
|
type: "effect.call",
|
|
968
1010
|
name,
|
|
969
1011
|
call,
|
|
970
|
-
args:
|
|
1012
|
+
args: require_run_agent.toJsonValue(redact(name, "args", args)) ?? []
|
|
971
1013
|
});
|
|
972
1014
|
const done = (result) => send({
|
|
973
1015
|
type: "effect.done",
|
|
974
1016
|
name,
|
|
975
1017
|
call,
|
|
976
|
-
result:
|
|
1018
|
+
result: require_run_agent.toJsonValue(redact(name, "result", result)) ?? null
|
|
977
1019
|
});
|
|
978
1020
|
const failed = (error) => send({
|
|
979
1021
|
type: "effect.error",
|
|
980
1022
|
name,
|
|
981
1023
|
call,
|
|
982
|
-
error:
|
|
1024
|
+
error: require_run_agent.toJsonValue(redact(name, "error", error)) ?? null
|
|
983
1025
|
});
|
|
984
1026
|
let result;
|
|
985
1027
|
try {
|
|
@@ -1218,14 +1260,14 @@ function wrapWorkflow(config) {
|
|
|
1218
1260
|
return {
|
|
1219
1261
|
machine,
|
|
1220
1262
|
async run(input, options = {}) {
|
|
1221
|
-
const { effects: overrides, recorder, ...runOptions } = options;
|
|
1263
|
+
const { effects: overrides, recorder, recordOptions, ...runOptions } = options;
|
|
1222
1264
|
let effects = {
|
|
1223
1265
|
...require_effects.mapEffects(config.effects, (_name, effect) => effect),
|
|
1224
1266
|
...overrides ? require_effects.mapEffects(overrides, (_name, effect) => effect) : {}
|
|
1225
1267
|
};
|
|
1226
|
-
if (recorder) effects = require_effects.mapEffects(effects, (name, effect) => recorder.fn(name, effect));
|
|
1268
|
+
if (recorder) effects = require_effects.mapEffects(effects, (name, effect) => recorder.fn(name, effect, recordOptions?.[name]));
|
|
1227
1269
|
const { signal: _signal, ...agentOptions } = runOptions;
|
|
1228
|
-
const result = await
|
|
1270
|
+
const result = await require_run_agent.runAgent(machine, {
|
|
1229
1271
|
...agentOptions,
|
|
1230
1272
|
input,
|
|
1231
1273
|
actors: { workflow: workflowLogic(config.run, effects, options.signal, config.redact) }
|
|
@@ -1293,11 +1335,11 @@ function provideExecutors(machine, executors, options = {}) {
|
|
|
1293
1335
|
const provided = options.actors ? withActors(machine, options.actors) : machine;
|
|
1294
1336
|
const effectiveSources = provided.sources.actors;
|
|
1295
1337
|
const wrappedSources = {};
|
|
1296
|
-
const invokedSrcs =
|
|
1338
|
+
const invokedSrcs = require_run_agent.getConfiguredInvokeSrcs(provided);
|
|
1297
1339
|
for (const [key, logic] of Object.entries(effectiveSources)) {
|
|
1298
|
-
if (
|
|
1340
|
+
if (require_run_agent.isStateMachineLogic(logic)) {
|
|
1299
1341
|
if (invokedSrcs.has(key)) assertChildBindable(logic, executors, key, /* @__PURE__ */ new Set([provided]));
|
|
1300
|
-
const rebound =
|
|
1342
|
+
const rebound = require_run_agent.bindChildMachineForProvide(logic, executors, bindOptions, /* @__PURE__ */ new Set([provided]));
|
|
1301
1343
|
if (rebound !== logic) wrappedSources[key] = rebound;
|
|
1302
1344
|
continue;
|
|
1303
1345
|
}
|
|
@@ -1305,7 +1347,7 @@ function provideExecutors(machine, executors, options = {}) {
|
|
|
1305
1347
|
if (!requirement) continue;
|
|
1306
1348
|
const binding = {
|
|
1307
1349
|
...requirement,
|
|
1308
|
-
bind: () => require_act.isActLogic(logic) ?
|
|
1350
|
+
bind: () => require_act.isActLogic(logic) ? require_run_agent.bindActForProvide(provided, executors, bindOptions) : require_decision.isDecisionLogic(logic) ? require_run_agent.bindDecisionForProvide(provided, logic, executors, bindOptions) : require_run_agent.bindTextForProvide(provided, logic, executors, bindOptions)
|
|
1309
1351
|
};
|
|
1310
1352
|
if (require_event_log.executorBoundLogics.has(logic)) continue;
|
|
1311
1353
|
if (!executors[binding.executorKey]) {
|
|
@@ -1344,10 +1386,10 @@ function assertChildBindable(childMachine, executors, path, visited) {
|
|
|
1344
1386
|
if (visited.has(childMachine)) return;
|
|
1345
1387
|
const nextVisited = /* @__PURE__ */ new Set([...visited, childMachine]);
|
|
1346
1388
|
const sources = childMachine.sources.actors;
|
|
1347
|
-
for (const src of
|
|
1389
|
+
for (const src of require_run_agent.getConfiguredInvokeSrcs(childMachine)) {
|
|
1348
1390
|
const logic = sources[src];
|
|
1349
1391
|
if (!logic) continue;
|
|
1350
|
-
if (
|
|
1392
|
+
if (require_run_agent.isStateMachineLogic(logic)) {
|
|
1351
1393
|
assertChildBindable(logic, executors, `${path} > ${src}`, nextVisited);
|
|
1352
1394
|
continue;
|
|
1353
1395
|
}
|
|
@@ -1361,29 +1403,28 @@ function missingExecutorError(src, kind, executor) {
|
|
|
1361
1403
|
}
|
|
1362
1404
|
//#endregion
|
|
1363
1405
|
exports.ACT_STATE_EXITED = require_act.ACT_STATE_EXITED;
|
|
1364
|
-
exports.AGENT_TRACE_SCHEMA_VERSION =
|
|
1406
|
+
exports.AGENT_TRACE_SCHEMA_VERSION = require_run_agent.AGENT_TRACE_SCHEMA_VERSION;
|
|
1365
1407
|
exports.AGENT_USAGE_EVENT_TYPE = require_event_log.AGENT_USAGE_EVENT_TYPE;
|
|
1366
1408
|
exports.AgentDecisionExhaustedError = require_decision.AgentDecisionExhaustedError;
|
|
1367
1409
|
exports.AgentError = require_event_log.AgentError;
|
|
1368
1410
|
exports.AgentEventLogConflictError = require_event_log_store.AgentEventLogConflictError;
|
|
1369
1411
|
exports.AgentInvalidEventPayloadError = require_decision.AgentInvalidEventPayloadError;
|
|
1370
1412
|
exports.AgentMachineVersionMismatchError = require_event_log.AgentMachineVersionMismatchError;
|
|
1371
|
-
exports.AgentMaxModelCallsExceededError =
|
|
1372
|
-
exports.AgentSnapshotDivergedError =
|
|
1413
|
+
exports.AgentMaxModelCallsExceededError = require_run_agent.AgentMaxModelCallsExceededError;
|
|
1414
|
+
exports.AgentSnapshotDivergedError = require_run_agent.AgentSnapshotDivergedError;
|
|
1373
1415
|
exports.AgentTruncatedError = require_event_log.AgentTruncatedError;
|
|
1374
1416
|
exports.DEFAULT_ACT_MAX_STEPS = require_act.DEFAULT_ACT_MAX_STEPS;
|
|
1375
1417
|
exports.GROUPED_EVENT_THRESHOLD = require_decision.GROUPED_EVENT_THRESHOLD;
|
|
1376
1418
|
exports.MAX_FINITE_PAYLOADS = require_decision.MAX_FINITE_PAYLOADS;
|
|
1377
1419
|
exports.assistantMessage = require_event_log.assistantMessage;
|
|
1378
1420
|
exports.bindRequestExecutor = require_event_log.bindRequestExecutor;
|
|
1379
|
-
exports.createAgentInbox =
|
|
1380
|
-
exports.createAgentRuntime =
|
|
1421
|
+
exports.createAgentInbox = require_run_agent.createAgentInbox;
|
|
1422
|
+
exports.createAgentRuntime = require_run_agent.createAgentRuntime;
|
|
1381
1423
|
exports.createAgentSchemas = require_setup_agent.createAgentSchemas;
|
|
1382
1424
|
exports.createDecisionLogic = require_decision.createDecisionLogic;
|
|
1383
1425
|
exports.createDecisionRequest = require_decision.createDecisionRequest;
|
|
1384
|
-
exports.
|
|
1426
|
+
exports.createGeneratorBridge = createGeneratorBridge;
|
|
1385
1427
|
exports.createTextLogic = require_event_log.createTextLogic;
|
|
1386
|
-
exports.decideNext = require_effects.decideNext;
|
|
1387
1428
|
exports.describeMachine = describeMachine;
|
|
1388
1429
|
exports.eventFromInteraction = eventFromInteraction;
|
|
1389
1430
|
exports.getAcceptedEvents = require_decision.getAcceptedEvents;
|
|
@@ -1394,13 +1435,11 @@ exports.getCallUsage = require_event_log.getCallUsage;
|
|
|
1394
1435
|
exports.getInteraction = getInteraction;
|
|
1395
1436
|
exports.getJsonSchema = require_event_log.getJsonSchema;
|
|
1396
1437
|
exports.getJsonSchemaSync = require_event_log.getJsonSchemaSync;
|
|
1397
|
-
exports.getMachineStructuralHash = require_event_log.getMachineStructuralHash;
|
|
1398
1438
|
exports.getMessageText = require_event_log.getMessageText;
|
|
1399
1439
|
exports.getStateMeta = require_event_log.getStateMeta;
|
|
1400
1440
|
exports.getStatePath = require_event_log.getStatePath;
|
|
1401
|
-
exports.inspectTransitions = require_effects.inspectTransitions;
|
|
1402
1441
|
exports.interactionMetaSchema = interactionMetaSchema;
|
|
1403
|
-
exports.isAgentIdle =
|
|
1442
|
+
exports.isAgentIdle = require_run_agent.isAgentIdle;
|
|
1404
1443
|
exports.isAgentMessages = isAgentMessages;
|
|
1405
1444
|
exports.isStandardSchema = require_event_log.isStandardSchema;
|
|
1406
1445
|
exports.messagesSchema = messagesSchema;
|
|
@@ -1411,9 +1450,8 @@ exports.provideExecutors = provideExecutors;
|
|
|
1411
1450
|
exports.providerOutputSchema = require_event_log.providerOutputSchema;
|
|
1412
1451
|
exports.renderDecisionAttempts = require_decision.renderDecisionAttempts;
|
|
1413
1452
|
exports.resolveDecision = require_decision.resolveDecision;
|
|
1414
|
-
exports.runAgent =
|
|
1415
|
-
exports.
|
|
1416
|
-
exports.serializeTraceEvent = require_effects.serializeTraceEvent;
|
|
1453
|
+
exports.runAgent = require_run_agent.runAgent;
|
|
1454
|
+
exports.serializeTraceEvent = require_run_agent.serializeTraceEvent;
|
|
1417
1455
|
Object.defineProperty(exports, "setupAgent", {
|
|
1418
1456
|
enumerable: true,
|
|
1419
1457
|
get: function() {
|
|
@@ -1422,6 +1460,6 @@ Object.defineProperty(exports, "setupAgent", {
|
|
|
1422
1460
|
});
|
|
1423
1461
|
exports.systemMessage = require_event_log.systemMessage;
|
|
1424
1462
|
exports.toolMessage = require_event_log.toolMessage;
|
|
1425
|
-
exports.traceTransitions =
|
|
1463
|
+
exports.traceTransitions = require_run_agent.traceTransitions;
|
|
1426
1464
|
exports.userMessage = require_event_log.userMessage;
|
|
1427
1465
|
exports.wrapWorkflow = wrapWorkflow;
|