@statelyai/agent 2.0.0-alpha.6 → 2.0.0-alpha.8
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 +100 -7
- package/dist/ai-sdk.d.cts +43 -5
- package/dist/ai-sdk.d.mts +43 -5
- package/dist/ai-sdk.mjs +99 -9
- package/dist/cli.cjs +3 -2
- package/dist/cli.mjs +2 -1
- package/dist/{decision-D1654JdD.mjs → decision-CQdrKc8k.mjs} +42 -4
- package/dist/{decision-CX3YdwrO.cjs → decision-b-lkcs4L.cjs} +59 -3
- package/dist/index.cjs +15 -12
- package/dist/index.d.cts +6 -1039
- package/dist/index.d.mts +6 -1039
- package/dist/index.mjs +4 -3
- package/dist/openai-compat.cjs +1 -1
- package/dist/openai-compat.d.cts +3 -3
- package/dist/openai-compat.d.mts +3 -3
- package/dist/openai-compat.mjs +1 -1
- package/dist/{src-CEa947Dm.mjs → run-agent-7OaHM7SB.mjs} +61 -979
- package/dist/{src-wBfi-kTA.cjs → run-agent-BQ3vV7UI.cjs} +59 -1037
- package/dist/run-agent-BzW4emV_.d.cts +1078 -0
- package/dist/run-agent-XYjmBxHi.d.mts +1078 -0
- package/dist/src-CFtSqm-c.cjs +1043 -0
- package/dist/src-d-jhiOgP.mjs +984 -0
- package/dist/{text-logic-1ZQkO3zr.d.cts → text-logic-C7WJpCIc.d.mts} +34 -6
- package/dist/{text-logic-2EMJIS-n.d.mts → text-logic-CZjyACzQ.d.cts} +34 -6
- package/dist/{types-BHjeDdch.d.cts → types-C9QiMjre.d.cts} +16 -5
- package/dist/{types-Cq1YlAQ6.d.mts → types-qm00QF91.d.mts} +16 -5
- package/dist/{utils-CWUCa3pF.d.mts → utils-Dri7aeEG.d.cts} +1 -1
- package/dist/{utils-lK1wnL2i.d.cts → utils-Y6GDRGGE.d.mts} +1 -1
- package/dist/zod.d.cts +1 -1
- package/dist/zod.d.mts +1 -1
- package/package.json +2 -2
- package/readme.md +22 -23
|
@@ -221,6 +221,9 @@ function validateSchemaSync(schema, value) {
|
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region src/internal/registry.ts
|
|
223
223
|
const agentExecutionOptions = /* @__PURE__ */ new WeakMap();
|
|
224
|
+
function getRegisteredAgentModels(machine) {
|
|
225
|
+
return agentExecutionOptions.get(machine)?.models;
|
|
226
|
+
}
|
|
224
227
|
/**
|
|
225
228
|
* Machine-carried wait-state predicates, keyed on the machine's root `config`
|
|
226
229
|
* object. `config` is shared by reference across `machine.provide(...)` (unlike
|
|
@@ -266,6 +269,27 @@ const DECIDE_ACTOR = "agent.decide";
|
|
|
266
269
|
const PLAN_ACTOR = "agent.plan";
|
|
267
270
|
/** 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). */
|
|
268
271
|
const INTERPRET_SOURCE = "agent.interpret";
|
|
272
|
+
/**
|
|
273
|
+
* Splits a portable `"provider/model-id"` model ref (the convention JSON
|
|
274
|
+
* workflows and registry-less hosts use, e.g. `"openai/gpt-5.4-mini"`) into
|
|
275
|
+
* its parts. A ref with no `/` has no provider — `modelId` is the whole ref.
|
|
276
|
+
* The standard building block for a host's `resolveModel`:
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```ts
|
|
280
|
+
* const resolveModel = (ref: string) => openai(parseModelRef(ref).modelId);
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
function parseModelRef(modelRef) {
|
|
284
|
+
const slash = modelRef.indexOf("/");
|
|
285
|
+
return slash === -1 ? {
|
|
286
|
+
provider: void 0,
|
|
287
|
+
modelId: modelRef
|
|
288
|
+
} : {
|
|
289
|
+
provider: modelRef.slice(0, slash),
|
|
290
|
+
modelId: modelRef.slice(slash + 1)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
269
293
|
const agentTextInputSchema = { "~standard": {
|
|
270
294
|
version: 1,
|
|
271
295
|
vendor: "statelyai-agent",
|
|
@@ -336,7 +360,7 @@ const builtinTextActors = {
|
|
|
336
360
|
[GENERATE_TEXT_ACTOR]: createBuiltinTextActor(GENERATE_TEXT_ACTOR, "generate", unknownOutputSchema),
|
|
337
361
|
[STREAM_TEXT_ACTOR]: createBuiltinTextActor(STREAM_TEXT_ACTOR, "stream", stringOutputSchema)
|
|
338
362
|
};
|
|
339
|
-
/** The unbound `agent.userInput` builtin registered by setupAgent (an unbound-placeholder logic — see internal/registry.ts). @internal */
|
|
363
|
+
/** The unbound `agent.userInput` builtin registered by setupAgent (an unbound-placeholder logic — see internal/registry.ts). Output is `string` — what the human typed. @internal */
|
|
340
364
|
const userInputActor = (0, xstate.createAsyncLogic)({ run: async () => {
|
|
341
365
|
throw new Error(`'${USER_INPUT_ACTOR}' has no host execution. Provide an implementation with machine.provide({ actorSources: { '${USER_INPUT_ACTOR}': ... } }).`);
|
|
342
366
|
} });
|
|
@@ -444,12 +468,15 @@ function createTextLogic(config, execute) {
|
|
|
444
468
|
* });
|
|
445
469
|
* ```
|
|
446
470
|
*/
|
|
447
|
-
function bindRequestExecutor(logic, executor) {
|
|
471
|
+
function bindRequestExecutor(logic, executor, info) {
|
|
448
472
|
return logic.withExecutor(async ({ request, signal }) => {
|
|
449
473
|
const { output } = await executor({
|
|
450
474
|
...request,
|
|
451
475
|
tools: request.tools ?? {}
|
|
452
|
-
}, {
|
|
476
|
+
}, {
|
|
477
|
+
signal,
|
|
478
|
+
onChunk: info?.onChunk
|
|
479
|
+
});
|
|
453
480
|
return { output };
|
|
454
481
|
});
|
|
455
482
|
}
|
|
@@ -524,6 +551,17 @@ function buildEnvelopeSchema(inner, options = {}) {
|
|
|
524
551
|
} }
|
|
525
552
|
} };
|
|
526
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Validates a raw provider value against the structured-output envelope for
|
|
556
|
+
* `request` and returns the unwrapped `{ result, reasoning? }` — the checked
|
|
557
|
+
* replacement for `raw as StructuredOutputEnvelope` in hand-written hosts.
|
|
558
|
+
* Pair with {@link buildEnvelopeSchema} (which produced the schema the
|
|
559
|
+
* provider was asked to satisfy).
|
|
560
|
+
*/
|
|
561
|
+
function parseStructuredEnvelope(request, value) {
|
|
562
|
+
if (!request.outputSchema) throw new Error("parseStructuredEnvelope: the request declares no outputSchema.");
|
|
563
|
+
return validateSchemaSync(buildEnvelopeSchema(request.outputSchema, { reasoning: request.reasoning }), value);
|
|
564
|
+
}
|
|
527
565
|
function getStandardSchemaJson(schema) {
|
|
528
566
|
const jsonSchema = (schema?.["~standard"])?.jsonSchema?.input?.();
|
|
529
567
|
return jsonSchema && !(jsonSchema instanceof Promise) ? jsonSchema : void 0;
|
|
@@ -1099,6 +1137,12 @@ Object.defineProperty(exports, "getRegisteredAgentExecutionOptions", {
|
|
|
1099
1137
|
return getRegisteredAgentExecutionOptions;
|
|
1100
1138
|
}
|
|
1101
1139
|
});
|
|
1140
|
+
Object.defineProperty(exports, "getRegisteredAgentModels", {
|
|
1141
|
+
enumerable: true,
|
|
1142
|
+
get: function() {
|
|
1143
|
+
return getRegisteredAgentModels;
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1102
1146
|
Object.defineProperty(exports, "getStateMeta", {
|
|
1103
1147
|
enumerable: true,
|
|
1104
1148
|
get: function() {
|
|
@@ -1177,12 +1221,24 @@ Object.defineProperty(exports, "parseAgentEvent", {
|
|
|
1177
1221
|
return parseAgentEvent;
|
|
1178
1222
|
}
|
|
1179
1223
|
});
|
|
1224
|
+
Object.defineProperty(exports, "parseModelRef", {
|
|
1225
|
+
enumerable: true,
|
|
1226
|
+
get: function() {
|
|
1227
|
+
return parseModelRef;
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1180
1230
|
Object.defineProperty(exports, "parseOutput", {
|
|
1181
1231
|
enumerable: true,
|
|
1182
1232
|
get: function() {
|
|
1183
1233
|
return parseOutput;
|
|
1184
1234
|
}
|
|
1185
1235
|
});
|
|
1236
|
+
Object.defineProperty(exports, "parseStructuredEnvelope", {
|
|
1237
|
+
enumerable: true,
|
|
1238
|
+
get: function() {
|
|
1239
|
+
return parseStructuredEnvelope;
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1186
1242
|
Object.defineProperty(exports, "persistSnapshot", {
|
|
1187
1243
|
enumerable: true,
|
|
1188
1244
|
get: function() {
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_decision = require("./decision-
|
|
4
|
-
|
|
2
|
+
const require_run_agent = require("./run-agent-BQ3vV7UI.cjs");
|
|
3
|
+
const require_decision = require("./decision-b-lkcs4L.cjs");
|
|
4
|
+
const require_src = require("./src-CFtSqm-c.cjs");
|
|
5
|
+
exports.AgentIdleError = require_run_agent.AgentIdleError;
|
|
5
6
|
exports.DecisionExhaustedError = require_decision.DecisionExhaustedError;
|
|
6
7
|
exports.EVENT_TOOL_PREFIX = require_decision.EVENT_TOOL_PREFIX;
|
|
7
|
-
exports.IllegalResumeEventError =
|
|
8
|
+
exports.IllegalResumeEventError = require_run_agent.IllegalResumeEventError;
|
|
8
9
|
exports.PLAN_DONE_EVENT_TYPE = require_decision.PLAN_DONE_EVENT_TYPE;
|
|
9
|
-
exports.SnapshotVersionMismatchError =
|
|
10
|
-
exports.appendMessages =
|
|
10
|
+
exports.SnapshotVersionMismatchError = require_run_agent.SnapshotVersionMismatchError;
|
|
11
|
+
exports.appendMessages = require_run_agent.appendMessages;
|
|
11
12
|
exports.assistantMessage = require_decision.assistantMessage;
|
|
12
13
|
exports.bindRequestExecutor = require_decision.bindRequestExecutor;
|
|
13
14
|
exports.buildEnvelopeSchema = require_decision.buildEnvelopeSchema;
|
|
14
15
|
exports.canReach = require_src.canReach;
|
|
15
|
-
exports.createAgentSchemas =
|
|
16
|
+
exports.createAgentSchemas = require_run_agent.createAgentSchemas;
|
|
16
17
|
exports.createTextLogic = require_decision.createTextLogic;
|
|
17
18
|
exports.executeAgentRequest = require_src.executeAgentRequest;
|
|
18
19
|
exports.explorePaths = require_src.explorePaths;
|
|
@@ -25,25 +26,27 @@ exports.getJsonSchemaSync = require_decision.getJsonSchemaSync;
|
|
|
25
26
|
exports.getMachineStructuralHash = require_decision.getMachineStructuralHash;
|
|
26
27
|
exports.getStateMeta = require_decision.getStateMeta;
|
|
27
28
|
exports.initialAgentStep = require_src.initialAgentStep;
|
|
28
|
-
exports.inspectTransitions =
|
|
29
|
+
exports.inspectTransitions = require_run_agent.inspectTransitions;
|
|
29
30
|
exports.isStandardSchema = require_decision.isStandardSchema;
|
|
30
31
|
exports.isStructuredOutputSchema = require_decision.isStructuredOutputSchema;
|
|
31
32
|
exports.lintAgentMachine = require_src.lintAgentMachine;
|
|
32
33
|
exports.matchesEventPattern = require_decision.matchesEventPattern;
|
|
33
|
-
exports.messagesSchema =
|
|
34
|
+
exports.messagesSchema = require_run_agent.messagesSchema;
|
|
34
35
|
exports.parseAgentEvent = require_decision.parseAgentEvent;
|
|
36
|
+
exports.parseModelRef = require_decision.parseModelRef;
|
|
35
37
|
exports.parseOutput = require_decision.parseOutput;
|
|
38
|
+
exports.parseStructuredEnvelope = require_decision.parseStructuredEnvelope;
|
|
36
39
|
exports.persistSnapshot = require_decision.persistSnapshot;
|
|
37
40
|
exports.renderDecisionAttempts = require_decision.renderDecisionAttempts;
|
|
38
41
|
exports.resolveAgentRequests = require_src.resolveAgentRequests;
|
|
39
42
|
exports.resolveAgentStep = require_src.resolveAgentStep;
|
|
40
43
|
exports.resolveDecision = require_decision.resolveDecision;
|
|
41
|
-
exports.runAgent =
|
|
42
|
-
exports.runAgentToCompletion =
|
|
44
|
+
exports.runAgent = require_run_agent.runAgent;
|
|
45
|
+
exports.runAgentToCompletion = require_run_agent.runAgentToCompletion;
|
|
43
46
|
Object.defineProperty(exports, "setupAgent", {
|
|
44
47
|
enumerable: true,
|
|
45
48
|
get: function() {
|
|
46
|
-
return
|
|
49
|
+
return require_run_agent.setupAgent;
|
|
47
50
|
}
|
|
48
51
|
});
|
|
49
52
|
exports.simulateAgent = require_src.simulateAgent;
|