@statelyai/agent 2.0.0-alpha.13 → 2.0.0-alpha.15
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/dist/ai-sdk.cjs +1 -1
- package/dist/ai-sdk.d.cts +2 -2
- package/dist/ai-sdk.d.mts +2 -2
- package/dist/ai-sdk.mjs +1 -1
- package/dist/{decision-dWGhBh0P.cjs → decision-C0cUKvNt.cjs} +0 -105
- package/dist/{decision-BezSD_YC.mjs → decision-D9Zi7Xi5.mjs} +2 -65
- package/dist/index.cjs +52 -155
- package/dist/index.d.cts +26 -13
- package/dist/index.d.mts +26 -13
- package/dist/index.mjs +54 -156
- package/dist/machines.cjs +1 -1
- package/dist/machines.d.cts +1 -1
- package/dist/machines.d.mts +1 -1
- package/dist/machines.mjs +1 -1
- package/dist/otel.cjs +5 -15
- package/dist/otel.d.cts +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/otel.mjs +5 -15
- package/dist/{run-agent-C3mFDGTf.d.mts → run-agent-BWzo4FLv.d.mts} +83 -109
- package/dist/{run-agent-DnvtcnTZ.d.cts → run-agent-B_n4Qxye.d.cts} +83 -109
- package/dist/{setup-agent-DP95MFrI.cjs → setup-agent-CpK0ZRWV.cjs} +10 -210
- package/dist/{setup-agent-DAZZSjDS.mjs → setup-agent-DeHRW-qX.mjs} +11 -205
- package/dist/sqlite.d.cts +2 -2
- package/dist/sqlite.d.mts +2 -2
- package/dist/{text-logic-TkKPw8Aq.d.mts → text-logic-C7anC7qX.d.mts} +8 -94
- package/dist/{text-logic-BDxwQNsD.d.cts → text-logic-DZW7XWy9.d.cts} +8 -94
- package/dist/{types-QbEfCVny.d.cts → types-CTBhMnFu.d.mts} +30 -3
- package/dist/{types-_FXoFBGO.d.mts → types-DFD28AWe.d.cts} +30 -3
- package/package.json +1 -1
- /package/dist/{event-log-store-CriMgX1D.d.mts → event-log-store-BkUNtyOF.d.mts} +0 -0
- /package/dist/{event-log-store-Ruq18mGp.d.cts → event-log-store-CVd2eyRy.d.cts} +0 -0
package/dist/ai-sdk.cjs
CHANGED
package/dist/ai-sdk.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as ChosenEvent } from "./types-
|
|
2
|
-
import { k as AgentDecisionExecutor, l as AgentRequestExecutors, o as AgentRequestExecutor } from "./text-logic-
|
|
1
|
+
import { d as ChosenEvent } from "./types-DFD28AWe.cjs";
|
|
2
|
+
import { k as AgentDecisionExecutor, l as AgentRequestExecutors, o as AgentRequestExecutor } from "./text-logic-DZW7XWy9.cjs";
|
|
3
3
|
import { FinishReason, LanguageModel, LanguageModelUsage, ToolSet, TypedToolCall, TypedToolResult } from "ai";
|
|
4
4
|
|
|
5
5
|
//#region src/ai-sdk/index.d.ts
|
package/dist/ai-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as ChosenEvent } from "./types-
|
|
2
|
-
import { k as AgentDecisionExecutor, l as AgentRequestExecutors, o as AgentRequestExecutor } from "./text-logic-
|
|
1
|
+
import { d as ChosenEvent } from "./types-CTBhMnFu.mjs";
|
|
2
|
+
import { k as AgentDecisionExecutor, l as AgentRequestExecutors, o as AgentRequestExecutor } from "./text-logic-C7anC7qX.mjs";
|
|
3
3
|
import { FinishReason, LanguageModel, LanguageModelUsage, ToolSet, TypedToolCall, TypedToolResult } from "ai";
|
|
4
4
|
|
|
5
5
|
//#region src/ai-sdk/index.d.ts
|
package/dist/ai-sdk.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { V as isStandardSchema, i as renderDecisionAttempts, p as buildEnvelopeSchema, v as getAgentOutputMode } from "./decision-D9Zi7Xi5.mjs";
|
|
2
2
|
import { NoObjectGeneratedError, Output, generateText, stepCountIs, streamText, tool } from "ai";
|
|
3
3
|
//#region src/ai-sdk/mappers.ts
|
|
4
4
|
/**
|
|
@@ -281,7 +281,6 @@ const USER_INPUT_ACTOR = "agent.userInput";
|
|
|
281
281
|
const GENERATE_TEXT_ACTOR = "agent.generateText";
|
|
282
282
|
const STREAM_TEXT_ACTOR = "agent.streamText";
|
|
283
283
|
const DECIDE_ACTOR = "agent.decide";
|
|
284
|
-
const PLAN_ACTOR = "agent.plan";
|
|
285
284
|
/** Synthetic `src` stamped on trace requests produced by `getRequests` state interpretation — NOT a registered actor source (nothing is invoked; the pass makes the call directly). */
|
|
286
285
|
const INTERPRET_SOURCE = "agent.interpret";
|
|
287
286
|
/**
|
|
@@ -882,68 +881,6 @@ function decideActorWithExecutor(execute) {
|
|
|
882
881
|
function createDecideActor() {
|
|
883
882
|
return decideActorWithExecutor();
|
|
884
883
|
}
|
|
885
|
-
/**
|
|
886
|
-
* Reserved event type the `agent.plan` builtin adds to every step's
|
|
887
|
-
* candidates as the explicit "no further action needed" move. Choosing it
|
|
888
|
-
* ends the plan (`stopped: 'done'`); it is never sent to the machine, so
|
|
889
|
-
* machines need no no-op sentinel event of their own.
|
|
890
|
-
*/
|
|
891
|
-
const PLAN_DONE_EVENT_TYPE = "agent.plan.done";
|
|
892
|
-
function createPlanActor() {
|
|
893
|
-
const logic = (0, xstate.createLogic)({
|
|
894
|
-
context: ({ input }) => ({
|
|
895
|
-
applied: [],
|
|
896
|
-
stepsRemaining: input.maxSteps ?? 8,
|
|
897
|
-
stopped: null
|
|
898
|
-
}),
|
|
899
|
-
run: ({ context, event }) => event.type === "plan.applied" ? { context: {
|
|
900
|
-
...context,
|
|
901
|
-
applied: [...context.applied, event.event],
|
|
902
|
-
stepsRemaining: context.stepsRemaining - 1
|
|
903
|
-
} } : event.type === "plan.ended" ? {
|
|
904
|
-
context: {
|
|
905
|
-
...context,
|
|
906
|
-
stopped: event.stopped
|
|
907
|
-
},
|
|
908
|
-
status: "done",
|
|
909
|
-
output: {
|
|
910
|
-
steps: context.applied,
|
|
911
|
-
stopped: event.stopped
|
|
912
|
-
}
|
|
913
|
-
} : void 0
|
|
914
|
-
});
|
|
915
|
-
return Object.assign(logic, {
|
|
916
|
-
kind: "statelyai.planLogic",
|
|
917
|
-
maxRetries: 2,
|
|
918
|
-
request: decideRequestFromInput,
|
|
919
|
-
allowedEventTypes: (input) => resolveAllowedEventTypes(input.allowedEvents, input)
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
const PLAN_LEDGER_SCOPE = {
|
|
923
|
-
emit: () => {},
|
|
924
|
-
self: { id: "agent.plan.ledger" }
|
|
925
|
-
};
|
|
926
|
-
/**
|
|
927
|
-
* Builds a fresh plan ledger snapshot from resolved plan input — the shared
|
|
928
|
-
* starting point for BOTH hosts (the step path reads the invoke child's own
|
|
929
|
-
* initial snapshot; runAgent seeds a local ledger with this). @internal
|
|
930
|
-
*/
|
|
931
|
-
function initialPlanLedger(logic, input) {
|
|
932
|
-
return logic.getInitialSnapshot(PLAN_LEDGER_SCOPE, input);
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Advances a plan ledger by one {@link PlanLedgerEvent}, returning the next
|
|
936
|
-
* snapshot (unwrapping `createLogic`'s `[snapshot, effects]` tuple). Pure — no
|
|
937
|
-
* mutation of the input snapshot. @internal
|
|
938
|
-
*/
|
|
939
|
-
function advancePlanLedger(logic, snapshot, event) {
|
|
940
|
-
const result = logic.transition(snapshot, event, PLAN_LEDGER_SCOPE);
|
|
941
|
-
return Array.isArray(result) ? result[0] : result;
|
|
942
|
-
}
|
|
943
|
-
/** Type guard: true for the `agent.plan` builtin logic (checks the `kind` marker). @internal */
|
|
944
|
-
function isPlanLogic(logic) {
|
|
945
|
-
return !!logic && logic.kind === "statelyai.planLogic";
|
|
946
|
-
}
|
|
947
884
|
function resolveAllowedEventTypes(allowedEvents, input) {
|
|
948
885
|
if (allowedEvents === void 0) return;
|
|
949
886
|
const resolved = typeof allowedEvents === "function" ? allowedEvents({ input }) : allowedEvents;
|
|
@@ -1087,30 +1024,12 @@ Object.defineProperty(exports, "INTERPRET_SOURCE", {
|
|
|
1087
1024
|
return INTERPRET_SOURCE;
|
|
1088
1025
|
}
|
|
1089
1026
|
});
|
|
1090
|
-
Object.defineProperty(exports, "PLAN_ACTOR", {
|
|
1091
|
-
enumerable: true,
|
|
1092
|
-
get: function() {
|
|
1093
|
-
return PLAN_ACTOR;
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
Object.defineProperty(exports, "PLAN_DONE_EVENT_TYPE", {
|
|
1097
|
-
enumerable: true,
|
|
1098
|
-
get: function() {
|
|
1099
|
-
return PLAN_DONE_EVENT_TYPE;
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
1027
|
Object.defineProperty(exports, "USER_INPUT_ACTOR", {
|
|
1103
1028
|
enumerable: true,
|
|
1104
1029
|
get: function() {
|
|
1105
1030
|
return USER_INPUT_ACTOR;
|
|
1106
1031
|
}
|
|
1107
1032
|
});
|
|
1108
|
-
Object.defineProperty(exports, "advancePlanLedger", {
|
|
1109
|
-
enumerable: true,
|
|
1110
|
-
get: function() {
|
|
1111
|
-
return advancePlanLedger;
|
|
1112
|
-
}
|
|
1113
|
-
});
|
|
1114
1033
|
Object.defineProperty(exports, "agentExecutionOptions", {
|
|
1115
1034
|
enumerable: true,
|
|
1116
1035
|
get: function() {
|
|
@@ -1147,12 +1066,6 @@ Object.defineProperty(exports, "createDecideActor", {
|
|
|
1147
1066
|
return createDecideActor;
|
|
1148
1067
|
}
|
|
1149
1068
|
});
|
|
1150
|
-
Object.defineProperty(exports, "createPlanActor", {
|
|
1151
|
-
enumerable: true,
|
|
1152
|
-
get: function() {
|
|
1153
|
-
return createPlanActor;
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
1069
|
Object.defineProperty(exports, "createTextLogic", {
|
|
1157
1070
|
enumerable: true,
|
|
1158
1071
|
get: function() {
|
|
@@ -1243,24 +1156,12 @@ Object.defineProperty(exports, "getStateMeta", {
|
|
|
1243
1156
|
return getStateMeta;
|
|
1244
1157
|
}
|
|
1245
1158
|
});
|
|
1246
|
-
Object.defineProperty(exports, "initialPlanLedger", {
|
|
1247
|
-
enumerable: true,
|
|
1248
|
-
get: function() {
|
|
1249
|
-
return initialPlanLedger;
|
|
1250
|
-
}
|
|
1251
|
-
});
|
|
1252
1159
|
Object.defineProperty(exports, "isDecisionLogic", {
|
|
1253
1160
|
enumerable: true,
|
|
1254
1161
|
get: function() {
|
|
1255
1162
|
return isDecisionLogic;
|
|
1256
1163
|
}
|
|
1257
1164
|
});
|
|
1258
|
-
Object.defineProperty(exports, "isPlanLogic", {
|
|
1259
|
-
enumerable: true,
|
|
1260
|
-
get: function() {
|
|
1261
|
-
return isPlanLogic;
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
1165
|
Object.defineProperty(exports, "isStandardSchema", {
|
|
1265
1166
|
enumerable: true,
|
|
1266
1167
|
get: function() {
|
|
@@ -1345,12 +1246,6 @@ Object.defineProperty(exports, "resolveDecision", {
|
|
|
1345
1246
|
return resolveDecision;
|
|
1346
1247
|
}
|
|
1347
1248
|
});
|
|
1348
|
-
Object.defineProperty(exports, "sanitizeEventToolName", {
|
|
1349
|
-
enumerable: true,
|
|
1350
|
-
get: function() {
|
|
1351
|
-
return sanitizeEventToolName;
|
|
1352
|
-
}
|
|
1353
|
-
});
|
|
1354
1249
|
Object.defineProperty(exports, "systemMessage", {
|
|
1355
1250
|
enumerable: true,
|
|
1356
1251
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as AgentError } from "./errors-CeSXQx0v.mjs";
|
|
2
|
-
import { createAsyncLogic,
|
|
2
|
+
import { createAsyncLogic, getNextTransitions } from "xstate";
|
|
3
3
|
//#region src/utils.ts
|
|
4
4
|
/**
|
|
5
5
|
* Deep-clones a snapshot to a plain-JSON value via a `JSON` round-trip, the
|
|
@@ -281,7 +281,6 @@ const USER_INPUT_ACTOR = "agent.userInput";
|
|
|
281
281
|
const GENERATE_TEXT_ACTOR = "agent.generateText";
|
|
282
282
|
const STREAM_TEXT_ACTOR = "agent.streamText";
|
|
283
283
|
const DECIDE_ACTOR = "agent.decide";
|
|
284
|
-
const PLAN_ACTOR = "agent.plan";
|
|
285
284
|
/** Synthetic `src` stamped on trace requests produced by `getRequests` state interpretation — NOT a registered actor source (nothing is invoked; the pass makes the call directly). */
|
|
286
285
|
const INTERPRET_SOURCE = "agent.interpret";
|
|
287
286
|
/**
|
|
@@ -882,68 +881,6 @@ function decideActorWithExecutor(execute) {
|
|
|
882
881
|
function createDecideActor() {
|
|
883
882
|
return decideActorWithExecutor();
|
|
884
883
|
}
|
|
885
|
-
/**
|
|
886
|
-
* Reserved event type the `agent.plan` builtin adds to every step's
|
|
887
|
-
* candidates as the explicit "no further action needed" move. Choosing it
|
|
888
|
-
* ends the plan (`stopped: 'done'`); it is never sent to the machine, so
|
|
889
|
-
* machines need no no-op sentinel event of their own.
|
|
890
|
-
*/
|
|
891
|
-
const PLAN_DONE_EVENT_TYPE = "agent.plan.done";
|
|
892
|
-
function createPlanActor() {
|
|
893
|
-
const logic = createLogic({
|
|
894
|
-
context: ({ input }) => ({
|
|
895
|
-
applied: [],
|
|
896
|
-
stepsRemaining: input.maxSteps ?? 8,
|
|
897
|
-
stopped: null
|
|
898
|
-
}),
|
|
899
|
-
run: ({ context, event }) => event.type === "plan.applied" ? { context: {
|
|
900
|
-
...context,
|
|
901
|
-
applied: [...context.applied, event.event],
|
|
902
|
-
stepsRemaining: context.stepsRemaining - 1
|
|
903
|
-
} } : event.type === "plan.ended" ? {
|
|
904
|
-
context: {
|
|
905
|
-
...context,
|
|
906
|
-
stopped: event.stopped
|
|
907
|
-
},
|
|
908
|
-
status: "done",
|
|
909
|
-
output: {
|
|
910
|
-
steps: context.applied,
|
|
911
|
-
stopped: event.stopped
|
|
912
|
-
}
|
|
913
|
-
} : void 0
|
|
914
|
-
});
|
|
915
|
-
return Object.assign(logic, {
|
|
916
|
-
kind: "statelyai.planLogic",
|
|
917
|
-
maxRetries: 2,
|
|
918
|
-
request: decideRequestFromInput,
|
|
919
|
-
allowedEventTypes: (input) => resolveAllowedEventTypes(input.allowedEvents, input)
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
const PLAN_LEDGER_SCOPE = {
|
|
923
|
-
emit: () => {},
|
|
924
|
-
self: { id: "agent.plan.ledger" }
|
|
925
|
-
};
|
|
926
|
-
/**
|
|
927
|
-
* Builds a fresh plan ledger snapshot from resolved plan input — the shared
|
|
928
|
-
* starting point for BOTH hosts (the step path reads the invoke child's own
|
|
929
|
-
* initial snapshot; runAgent seeds a local ledger with this). @internal
|
|
930
|
-
*/
|
|
931
|
-
function initialPlanLedger(logic, input) {
|
|
932
|
-
return logic.getInitialSnapshot(PLAN_LEDGER_SCOPE, input);
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Advances a plan ledger by one {@link PlanLedgerEvent}, returning the next
|
|
936
|
-
* snapshot (unwrapping `createLogic`'s `[snapshot, effects]` tuple). Pure — no
|
|
937
|
-
* mutation of the input snapshot. @internal
|
|
938
|
-
*/
|
|
939
|
-
function advancePlanLedger(logic, snapshot, event) {
|
|
940
|
-
const result = logic.transition(snapshot, event, PLAN_LEDGER_SCOPE);
|
|
941
|
-
return Array.isArray(result) ? result[0] : result;
|
|
942
|
-
}
|
|
943
|
-
/** Type guard: true for the `agent.plan` builtin logic (checks the `kind` marker). @internal */
|
|
944
|
-
function isPlanLogic(logic) {
|
|
945
|
-
return !!logic && logic.kind === "statelyai.planLogic";
|
|
946
|
-
}
|
|
947
884
|
function resolveAllowedEventTypes(allowedEvents, input) {
|
|
948
885
|
if (allowedEvents === void 0) return;
|
|
949
886
|
const resolved = typeof allowedEvents === "function" ? allowedEvents({ input }) : allowedEvents;
|
|
@@ -1063,4 +1000,4 @@ async function resolveDecision(request, executor, options = {}) {
|
|
|
1063
1000
|
throw new AgentDecisionExhaustedError(attempts);
|
|
1064
1001
|
}
|
|
1065
1002
|
//#endregion
|
|
1066
|
-
export {
|
|
1003
|
+
export { isUnboundPlaceholder as A, getStateMeta as B, parseStructuredEnvelope as C, getMachineStaticTransitionTargets as D, executorBoundLogics as E, findNonSerializableContextPaths as F, userMessage as G, persistSnapshot as H, getAgentMessages as I, validateSchemaSync as K, getJsonSchema as L, machineSuspensionPredicates as M, missingActor as N, getMachineSuspensionPredicate as O, assistantMessage as P, getJsonSchemaSync as R, parseOutput as S, agentExecutionOptions as T, systemMessage as U, isStandardSchema as V, toolMessage as W, extractCallUsage as _, resolveDecision as a, normalizeGeneratorResult as b, AGENT_USAGE_TOKEN_FIELDS as c, USER_INPUT_ACTOR as d, bindRequestExecutor as f, executeAgentTextRequest as g, createTextLogic as h, renderDecisionAttempts as i, machineStaticTransitionTargets as j, getRegisteredAgentExecutionOptions as k, DECIDE_ACTOR as l, builtinTextActors as m, createDecideActor as n, getAcceptedEvents as o, buildEnvelopeSchema as p, isDecisionLogic as r, parseAgentEvent as s, AgentDecisionExhaustedError as t, INTERPRET_SOURCE as u, getAgentOutputMode as v, userInputActor as w, parseModelRef as x, isTextLogic as y, getMachineStructuralHash as z };
|