@statelyai/agent 2.0.0-alpha.36 → 2.0.0-alpha.38
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 +33 -0
- package/dist/{effects-CuOUNYtZ.mjs → effects-BT_cSY0j.mjs} +95 -11
- package/dist/{effects-B23bFZEs.cjs → effects-DDseYtJk.cjs} +95 -11
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +6 -6
- package/dist/otel.d.cts +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/{run-agent-BcQ-9NRT.d.cts → run-agent-30mH2moE.d.cts} +2 -2
- package/dist/{run-agent-C86drZtN.d.mts → run-agent-DlPzBWj-.d.mts} +2 -2
- package/dist/{setup-agent-jlo4vtaZ.d.cts → setup-agent-BaNyz6Q3.d.cts} +1 -1
- package/dist/{setup-agent-BIKcbVXV.d.mts → setup-agent-C1CG_nfX.d.mts} +1 -1
- package/dist/testing.cjs +2411 -1799
- package/dist/testing.d.cts +167 -4
- package/dist/testing.d.mts +167 -4
- package/dist/testing.mjs +2412 -1801
- package/dist/{usage-HtnrUsl9.d.cts → usage-Bm5nvpow.d.cts} +5 -0
- package/dist/{usage-DoP0Oi84.d.mts → usage-BnikdOca.d.mts} +5 -0
- package/dist/validate.cjs +1 -1
- package/dist/validate.d.cts +2 -2
- package/dist/validate.d.mts +2 -2
- package/dist/validate.mjs +1 -1
- package/dist/{verify-Dpz1u5Pe.mjs → verify-ChyX6jq0.mjs} +75 -20
- package/dist/{verify-Bink-Drw.cjs → verify-CwlombbC.cjs} +75 -20
- package/dist/{verify-CciG8UP-.d.cts → verify-DJHfEfm6.d.cts} +9 -4
- package/dist/{verify-Buh8XSUr.d.mts → verify-i9Hiwc5g.d.mts} +9 -4
- package/docs/decisions.md +1 -1
- package/docs/event-log.md +3 -2
- package/docs/hosts.md +2 -2
- package/docs/machines-as-data.md +5 -5
- package/docs/persistence.md +76 -5
- package/docs/quickstart.md +1 -1
- package/docs/steps.md +2 -0
- package/docs/usage-and-budgets.md +2 -0
- package/docs/verify.md +7 -2
- package/package.json +1 -1
- package/skills/build-machine/SKILL.md +4 -1
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { $ as getJsonSchema, B as parseOutput, F as getCallFinishReason, G as ex
|
|
|
2
2
|
import { a as createDecisionRequest, c as renderDecisionAttempts, d as GROUPED_EVENT_THRESHOLD, f as MAX_FINITE_PAYLOADS, h as getAcceptedEvents, i as createDecisionLogic, m as AgentInvalidEventPayloadError, s as isDecisionLogic, t as AgentDecisionExhaustedError, u as resolveDecision, v as parseAgentEvent } from "./decision-m5hGmHpF.mjs";
|
|
3
3
|
import { i as isActLogic, n as DEFAULT_ACT_MAX_STEPS, t as ACT_STATE_EXITED } from "./act-B9hLQls6.mjs";
|
|
4
4
|
import { n as getAgentSchemas, r as setupAgent, t as createAgentSchemas } from "./setup-agent-BDmNr6PC.mjs";
|
|
5
|
-
import { _ as runToQuiescence, a as AgentSnapshotDivergedError, b as traceTransitions, c as bindDecisionForProvide, d as createAgentRuntime, f as getConfiguredInvokeSrcs, g as runAgent, h as isStateMachineLogic, i as AgentMaxModelCallsExceededError, l as bindTextForProvide, m as isAgentIdle, n as mapEffects, o as bindActForProvide, p as inspectTransitions, r as AGENT_TRACE_SCHEMA_VERSION, s as bindChildMachineForProvide, t as isAsyncIterable, u as createAgentInbox, v as serializeTraceEvent, x as decideNext, y as toJsonValue } from "./effects-
|
|
5
|
+
import { _ as runToQuiescence, a as AgentSnapshotDivergedError, b as traceTransitions, c as bindDecisionForProvide, d as createAgentRuntime, f as getConfiguredInvokeSrcs, g as runAgent, h as isStateMachineLogic, i as AgentMaxModelCallsExceededError, l as bindTextForProvide, m as isAgentIdle, n as mapEffects, o as bindActForProvide, p as inspectTransitions, r as AGENT_TRACE_SCHEMA_VERSION, s as bindChildMachineForProvide, t as isAsyncIterable, u as createAgentInbox, v as serializeTraceEvent, x as decideNext, y as toJsonValue } from "./effects-BT_cSY0j.mjs";
|
|
6
6
|
import { t as AgentEventLogConflictError } from "./event-log-store-Brx9tOHt.mjs";
|
|
7
7
|
import { createAsyncLogic, machineToJSON } from "xstate";
|
|
8
8
|
import { parse } from "acorn";
|
|
@@ -685,7 +685,7 @@ function targetsInSource(source, code, choice) {
|
|
|
685
685
|
const conditional = parts.length > 1 || !choice && (read.declines || read.stays);
|
|
686
686
|
return `${parts.join(", ")}${conditional ? " (conditional)" : ""}`;
|
|
687
687
|
}
|
|
688
|
-
/** One transition, as a line: `on GO (human) if context.ready → review; sets draft
|
|
688
|
+
/** One transition, as a line: `on GO (human) if context.ready → review; sets draft - description`. */
|
|
689
689
|
function transitionLine(source, head, transition, options = {}) {
|
|
690
690
|
const code = codeOf(transition);
|
|
691
691
|
let to;
|
|
@@ -714,7 +714,7 @@ function transitionLine(source, head, transition, options = {}) {
|
|
|
714
714
|
to = "?";
|
|
715
715
|
sets = [];
|
|
716
716
|
}
|
|
717
|
-
return `${head}${human ? " (human)" : ""}${guard ? ` if ${guard}` : ""} → ${to}${sets.length ? `; sets ${sets.join(", ")}` : ""}${description ? `
|
|
717
|
+
return `${head}${human ? " (human)" : ""}${guard ? ` if ${guard}` : ""} → ${to}${sets.length ? `; sets ${sets.join(", ")}` : ""}${description ? ` - ${oneLine(description)}` : ""}`;
|
|
718
718
|
}
|
|
719
719
|
function formatMs(ms) {
|
|
720
720
|
if (ms < 1e3) return `${ms}ms`;
|
|
@@ -778,7 +778,7 @@ function stateLine(node, json) {
|
|
|
778
778
|
const tags = node.tags.length ? ` [tags: ${node.tags.join(", ")}]` : "";
|
|
779
779
|
const interaction = node.meta?.interaction;
|
|
780
780
|
const label = !interaction ? "" : typeof interaction.label === "string" ? ` [interaction: "${oneLine(interaction.label)}"]` : typeof interaction.label === "function" ? " [interaction: computed label]" : " [interaction]";
|
|
781
|
-
const description = node.description ? `
|
|
781
|
+
const description = node.description ? ` - ${oneLine(node.description)}` : "";
|
|
782
782
|
return `${node.key}${marker}${tags}${label}${description}`;
|
|
783
783
|
}
|
|
784
784
|
/** The machine's events with their schema descriptions and fields, sorted by type. */
|
|
@@ -795,13 +795,13 @@ function eventLines(machine) {
|
|
|
795
795
|
}
|
|
796
796
|
const direct = schemas[type].description;
|
|
797
797
|
const description = typeof schema?.description === "string" ? schema.description : typeof direct === "string" ? direct : void 0;
|
|
798
|
-
lines.push(` ${type}${description ? `
|
|
798
|
+
lines.push(` ${type}${description ? ` - ${oneLine(description)}` : ""}`);
|
|
799
799
|
const properties = isObject(schema?.properties) ? schema.properties : {};
|
|
800
800
|
const required = new Set(Array.isArray(schema?.required) ? schema.required : []);
|
|
801
801
|
for (const [field, property] of Object.entries(properties)) {
|
|
802
802
|
if (!isObject(property)) continue;
|
|
803
803
|
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;
|
|
804
|
-
const fieldDescription = typeof property.description === "string" ? `
|
|
804
|
+
const fieldDescription = typeof property.description === "string" ? ` - ${oneLine(property.description)}` : "";
|
|
805
805
|
lines.push(` ${field}${required.has(field) ? "" : "?"}${fieldType ? `: ${fieldType}` : ""}${fieldDescription}`);
|
|
806
806
|
}
|
|
807
807
|
}
|
package/dist/otel.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as AgentTraceEvent } from "./run-agent-
|
|
1
|
+
import { _ as AgentTraceEvent } from "./run-agent-30mH2moE.cjs";
|
|
2
2
|
import { Attributes, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
3
3
|
//#region src/otel/index.d.ts
|
|
4
4
|
/** Options for {@link createOtelTraceHandler}. */
|
package/dist/otel.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as AgentTraceEvent } from "./run-agent-
|
|
1
|
+
import { _ as AgentTraceEvent } from "./run-agent-DlPzBWj-.mjs";
|
|
2
2
|
import { Attributes, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
3
3
|
//#region src/otel/index.d.ts
|
|
4
4
|
/** Options for {@link createOtelTraceHandler}. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as StandardSchemaV1, j as WithAgentInputSchema, l as AgentTools, y as InferInput } from "./types-DQUOOaZO.cjs";
|
|
2
2
|
import { B as DecisionAttempt, L as AgentDecisionRequest, Z as AgentEventDescriptor, at as AgentError, d as AgentRequestMode, et as AgentRequestSource, f as AgentTextRequest, m as AgentUsage, r as AgentFinishReason, t as AgentCallUsage, u as AgentRequestExecutors } from "./text-logic-CSf9bqpP.cjs";
|
|
3
|
-
import { n as AgentUsageEvent } from "./usage-
|
|
3
|
+
import { n as AgentUsageEvent } from "./usage-Bm5nvpow.cjs";
|
|
4
4
|
import { c as AgentLogEntry, h as JsonValue$1, n as AgentEventLogStore } from "./event-log-store-bc4ICGcS.cjs";
|
|
5
5
|
import { AnyActorLogic, AnyActorRef, AnyMachineSnapshot, AnyStateMachine, AsyncActorLogic, EmittedFrom, EventFromLogic, EventObject, InputFrom, InspectionEvent, OutputFrom, Snapshot, SnapshotFrom, StateValue } from "xstate";
|
|
6
6
|
import { DurableExecution } from "xstate/durable";
|
|
@@ -684,7 +684,7 @@ interface AgentRunOptions<TMachine extends AnyStateMachine> extends AgentRuntime
|
|
|
684
684
|
*/
|
|
685
685
|
onIdle?: (snapshot: SnapshotFrom<TMachine>, options: {
|
|
686
686
|
signal: AbortSignal | undefined;
|
|
687
|
-
}) => Promise<EventFromLogic<TMachine
|
|
687
|
+
}) => Promise<EventFromLogic<TMachine> | AgentTimerEvent>;
|
|
688
688
|
/**
|
|
689
689
|
* A send handle for events pushed mid-run (a cancel, a user message), from
|
|
690
690
|
* {@link createAgentInbox}. Each `inbox.send` goes to the current pass's
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as StandardSchemaV1, j as WithAgentInputSchema, l as AgentTools, y as InferInput } from "./types-DQUOOaZO.mjs";
|
|
2
2
|
import { B as DecisionAttempt, L as AgentDecisionRequest, Z as AgentEventDescriptor, at as AgentError, d as AgentRequestMode, et as AgentRequestSource, f as AgentTextRequest, m as AgentUsage, r as AgentFinishReason, t as AgentCallUsage, u as AgentRequestExecutors } from "./text-logic-BqxalgMr.mjs";
|
|
3
|
-
import { n as AgentUsageEvent } from "./usage-
|
|
3
|
+
import { n as AgentUsageEvent } from "./usage-BnikdOca.mjs";
|
|
4
4
|
import { c as AgentLogEntry, h as JsonValue$1, n as AgentEventLogStore } from "./event-log-store-BBS8so8a.mjs";
|
|
5
5
|
import { AnyActorLogic, AnyActorRef, AnyMachineSnapshot, AnyStateMachine, AsyncActorLogic, EmittedFrom, EventFromLogic, EventObject, InputFrom, InspectionEvent, OutputFrom, Snapshot, SnapshotFrom, StateValue } from "xstate";
|
|
6
6
|
import { DurableExecution } from "xstate/durable";
|
|
@@ -684,7 +684,7 @@ interface AgentRunOptions<TMachine extends AnyStateMachine> extends AgentRuntime
|
|
|
684
684
|
*/
|
|
685
685
|
onIdle?: (snapshot: SnapshotFrom<TMachine>, options: {
|
|
686
686
|
signal: AbortSignal | undefined;
|
|
687
|
-
}) => Promise<EventFromLogic<TMachine
|
|
687
|
+
}) => Promise<EventFromLogic<TMachine> | AgentTimerEvent>;
|
|
688
688
|
/**
|
|
689
689
|
* A send handle for events pushed mid-run (a cancel, a user message), from
|
|
690
690
|
* {@link createAgentInbox}. Each `inbox.send` goes to the current pass's
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as StandardSchemaV1, a as AgentToolChoice, b as InferOutput, g as EventUnion, j as WithAgentInputSchema, l as AgentTools, n as AgentEventSchemaInputMap, x as NormalizedEventSchemas, y as InferInput } from "./types-DQUOOaZO.cjs";
|
|
2
2
|
import { _ as TextLogic, a as AgentModelRef, d as AgentRequestMode, h as BuiltinAgentActors, i as AgentModelMap, nt as EventFromSnapshot, tt as AgentSchemas, v as TextLogicConfig } from "./text-logic-CSf9bqpP.cjs";
|
|
3
|
-
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-
|
|
3
|
+
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-Bm5nvpow.cjs";
|
|
4
4
|
import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventObject, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema } from "xstate";
|
|
5
5
|
//#region src/interaction.d.ts
|
|
6
6
|
interface AgentInteractionEvent<TType extends string = string> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as StandardSchemaV1, a as AgentToolChoice, b as InferOutput, g as EventUnion, j as WithAgentInputSchema, l as AgentTools, n as AgentEventSchemaInputMap, x as NormalizedEventSchemas, y as InferInput } from "./types-DQUOOaZO.mjs";
|
|
2
2
|
import { _ as TextLogic, a as AgentModelRef, d as AgentRequestMode, h as BuiltinAgentActors, i as AgentModelMap, nt as EventFromSnapshot, tt as AgentSchemas, v as TextLogicConfig } from "./text-logic-BqxalgMr.mjs";
|
|
3
|
-
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-
|
|
3
|
+
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-BnikdOca.mjs";
|
|
4
4
|
import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventObject, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema } from "xstate";
|
|
5
5
|
//#region src/interaction.d.ts
|
|
6
6
|
interface AgentInteractionEvent<TType extends string = string> {
|