@statelyai/agent 2.0.0-alpha.26 → 2.0.0-alpha.28
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 +4 -4
- package/dist/ai-sdk.d.cts +6 -6
- package/dist/ai-sdk.d.mts +6 -6
- package/dist/ai-sdk.mjs +4 -4
- package/dist/{decision-CM9CYZ6t.cjs → decision-CmM8-HHz.cjs} +10 -9
- package/dist/{decision-DzSv1NpD.mjs → decision-RQ0iv0oZ.mjs} +10 -9
- package/dist/{event-log-store-Ba2fsc4E.mjs → event-log-store-2pAFiWuc.mjs} +1 -1
- package/dist/{event-log-store-DvOcs10J.d.cts → event-log-store-2xzFmgr2.d.cts} +1 -1
- package/dist/{event-log-store-DxyVgnas.d.mts → event-log-store-BIPOz-di.d.mts} +1 -1
- package/dist/{event-log-store-DQmImLYk.cjs → event-log-store-C-COhIXP.cjs} +1 -1
- package/dist/index.cjs +13 -195
- package/dist/index.d.cts +25 -105
- package/dist/index.d.mts +25 -105
- package/dist/index.mjs +12 -189
- package/dist/log.cjs +1 -1
- package/dist/log.d.cts +1 -1
- package/dist/log.d.mts +1 -1
- package/dist/log.mjs +1 -1
- package/dist/machines.cjs +4 -7
- package/dist/machines.d.cts +5 -7
- package/dist/machines.d.mts +5 -7
- package/dist/machines.mjs +4 -7
- package/dist/openai.cjs +3 -3
- package/dist/openai.d.cts +5 -5
- package/dist/openai.d.mts +5 -5
- package/dist/openai.mjs +3 -3
- package/dist/otel.cjs +2 -2
- package/dist/otel.d.cts +3 -3
- package/dist/otel.d.mts +3 -3
- package/dist/otel.mjs +2 -2
- package/dist/{run-agent-CG343kFs.d.mts → run-agent-ByO-Bxyd.d.cts} +184 -179
- package/dist/{run-agent-BOfoJg5B.d.cts → run-agent-COXXc0RW.d.mts} +184 -179
- package/dist/{run-agent-Cb1-LS5P.cjs → run-agent-Dmf8GV2d.cjs} +539 -737
- package/dist/{run-agent-DvDQd4If.mjs → run-agent-xNTxpt82.mjs} +537 -705
- package/dist/{setup-agent-CFW-jPI8.mjs → setup-agent-BuanDXeh.mjs} +6 -28
- package/dist/{setup-agent-CPf7MxnG.cjs → setup-agent-DV4cTou-.cjs} +6 -28
- package/dist/testing.cjs +276 -27
- package/dist/testing.d.cts +17 -15
- package/dist/testing.d.mts +17 -15
- package/dist/testing.mjs +260 -12
- package/dist/{text-logic-Bl_ZRxDi.mjs → text-logic-CIqHAmBi.mjs} +10 -26
- package/dist/{text-logic-BFEOxyxv.d.cts → text-logic-D-czVPYp.d.mts} +27 -28
- package/dist/{text-logic-hZSiRUo1.d.mts → text-logic-IjfYy9DP.d.cts} +27 -28
- package/dist/{text-logic-C8xyr6Ag.cjs → text-logic-f5F5sCdc.cjs} +9 -43
- package/dist/{types-B1Qs2q3q.d.cts → types-BgNbNKnJ.d.mts} +3 -3
- package/dist/{types-tA3SdczG.d.mts → types-hR5f5YXa.d.cts} +3 -3
- package/dist/{utils-C2DPqomn.d.mts → utils-_q7F-AZu.d.mts} +2 -2
- package/dist/{utils-ceStNCOh.d.cts → utils-o4YRdHJX.d.cts} +2 -2
- package/dist/validate.cjs +0 -8
- package/dist/validate.mjs +0 -8
- package/package.json +3 -3
- package/readme.md +26 -18
- package/schemas/agent-workflow.json +0 -8
- package/skills/generate-machine/SKILL.md +6 -8
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as isDecisionLogic, c as AgentInvalidEventPayloadError, i as createDecisionRequest, l as getAcceptedEvents, o as renderDecisionAttempts, r as createDecisionLogic, s as resolveDecision, t as AgentDecisionExhaustedError, u as parseAgentEvent } from "./decision-
|
|
1
|
+
import { A as getMessageText, B as AgentTruncatedError, D as getJsonSchema, F as systemMessage, I as toolMessage, L as userMessage, M as getStatePath, N as isStandardSchema, O as getJsonSchemaSync, a as bindRequestExecutor, c as getAgentOutputMode, d as isTextLogic, h as providerOutputSchema, j as getStateMeta, k as getMachineStructuralHash, l as getCallFinishReason, m as parseProviderOutput, p as parseOutput, s as createTextLogic, u as getCallUsage, v as executorBoundLogics, w as assistantMessage, y as getAgentExecutionOptions, z as AgentError } from "./text-logic-CIqHAmBi.mjs";
|
|
2
|
+
import { a as isDecisionLogic, c as AgentInvalidEventPayloadError, i as createDecisionRequest, l as getAcceptedEvents, o as renderDecisionAttempts, r as createDecisionLogic, s as resolveDecision, t as AgentDecisionExhaustedError, u as parseAgentEvent } from "./decision-RQ0iv0oZ.mjs";
|
|
3
3
|
import { t as AGENT_USAGE_EVENT_TYPE } from "./usage-BdEjFuIi.mjs";
|
|
4
|
-
import { n as getAgentSchemas, r as setupAgent, t as createAgentSchemas } from "./setup-agent-
|
|
5
|
-
import {
|
|
6
|
-
import { o as
|
|
4
|
+
import { n as getAgentSchemas, r as setupAgent, t as createAgentSchemas } from "./setup-agent-BuanDXeh.mjs";
|
|
5
|
+
import { o as AgentMachineVersionMismatchError, t as AgentEventLogConflictError } from "./event-log-store-2pAFiWuc.mjs";
|
|
6
|
+
import { a as bindDecisionForProvide, c as getConfiguredInvokeSrcs, d as isStateMachineLogic, f as runToQuiescence, i as bindChildMachineForProvide, l as inspectTransitions, m as traceTransitions, n as AgentMaxModelCallsExceededError, o as bindTextForProvide, p as serializeTraceEvent, r as AgentSnapshotDivergedError, s as createAgentRuntime, t as AGENT_TRACE_SCHEMA_VERSION, u as isAgentIdle } from "./run-agent-xNTxpt82.mjs";
|
|
7
7
|
//#region src/messages.ts
|
|
8
8
|
const KNOWN_PART_TYPES = new Set([
|
|
9
9
|
"text",
|
|
@@ -256,189 +256,12 @@ function eventFromInteraction(snapshot, choice) {
|
|
|
256
256
|
return parseAgentEvent(snapshot, event);
|
|
257
257
|
}
|
|
258
258
|
//#endregion
|
|
259
|
-
//#region src/agent-run.ts
|
|
260
|
-
/**
|
|
261
|
-
* Wraps {@link runAgent} in a canonical run-stream handle: the run's trace
|
|
262
|
-
* events as a pull-based {@link AgentRun.events} async iterator, alongside the
|
|
263
|
-
* unchanged {@link AgentRun.result} promise.
|
|
264
|
-
*
|
|
265
|
-
* Semantics:
|
|
266
|
-
*
|
|
267
|
-
* 1. **Starts immediately.** The underlying `runAgent` is invoked on this call,
|
|
268
|
-
* not on the first `events` iteration — work is already in flight when
|
|
269
|
-
* `createAgentRun` returns.
|
|
270
|
-
* 2. **Buffer, don't stall.** Events are queued in an unbounded in-memory
|
|
271
|
-
* buffer as the run emits them; a slow or absent consumer never applies
|
|
272
|
-
* backpressure to the run. Once `run.end` is delivered, the iterator
|
|
273
|
-
* completes.
|
|
274
|
-
* 3. **Composes `onTrace`.** If `options.onTrace` is passed, it still fires for
|
|
275
|
-
* every event — the wrapper adds queue delivery, it does not replace the
|
|
276
|
-
* caller's sink.
|
|
277
|
-
* 4. **`result` mirrors `runAgent`.** Same resolution and rejection behavior
|
|
278
|
-
* (see {@link AgentRun.result}). A no-op rejection handler is attached
|
|
279
|
-
* internally so a caller who reads only `events` never trips an unhandled
|
|
280
|
-
* rejection on a bind-time throw; the returned promise still rejects for a
|
|
281
|
-
* caller who awaits it.
|
|
282
|
-
* 5. **Resume is identical.** Options pass straight through, so starting from a
|
|
283
|
-
* persisted `snapshot` (+ resume `event`) streams that run's events from its
|
|
284
|
-
* own `run.start`, exactly as `runAgent` would run it.
|
|
285
|
-
* 6. **Early termination does not cancel the run.** Breaking out of a
|
|
286
|
-
* `for await` (or calling `events.return()`) stops delivery, but the run
|
|
287
|
-
* keeps going and `result` still settles. Cancelling the run itself is
|
|
288
|
-
* future work — pass `options.signal` to abort it.
|
|
289
|
-
* 7. **`events` is single-consumer.** See {@link AgentRun.events}.
|
|
290
|
-
*/
|
|
291
|
-
function createAgentRun(machine, options) {
|
|
292
|
-
const buffer = [];
|
|
293
|
-
const resolvers = [];
|
|
294
|
-
let closed = false;
|
|
295
|
-
let stopped = false;
|
|
296
|
-
const push = (event) => {
|
|
297
|
-
if (closed || stopped) return;
|
|
298
|
-
const resolve = resolvers.shift();
|
|
299
|
-
if (resolve) resolve({
|
|
300
|
-
value: event,
|
|
301
|
-
done: false
|
|
302
|
-
});
|
|
303
|
-
else buffer.push(event);
|
|
304
|
-
};
|
|
305
|
-
const drain = () => {
|
|
306
|
-
while (resolvers.length > 0) resolvers.shift()({
|
|
307
|
-
value: void 0,
|
|
308
|
-
done: true
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
const close = () => {
|
|
312
|
-
if (closed) return;
|
|
313
|
-
closed = true;
|
|
314
|
-
drain();
|
|
315
|
-
};
|
|
316
|
-
const userOnTrace = options.onTrace;
|
|
317
|
-
const result = runAgent(machine, {
|
|
318
|
-
...options,
|
|
319
|
-
onTrace: (event) => {
|
|
320
|
-
push(event);
|
|
321
|
-
userOnTrace?.(event);
|
|
322
|
-
if (event.type === "run.end") close();
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
result.then(close, close);
|
|
326
|
-
return {
|
|
327
|
-
events: {
|
|
328
|
-
next() {
|
|
329
|
-
if (buffer.length > 0) return Promise.resolve({
|
|
330
|
-
value: buffer.shift(),
|
|
331
|
-
done: false
|
|
332
|
-
});
|
|
333
|
-
if (closed || stopped) return Promise.resolve({
|
|
334
|
-
value: void 0,
|
|
335
|
-
done: true
|
|
336
|
-
});
|
|
337
|
-
return new Promise((resolve) => {
|
|
338
|
-
resolvers.push(resolve);
|
|
339
|
-
});
|
|
340
|
-
},
|
|
341
|
-
return() {
|
|
342
|
-
stopped = true;
|
|
343
|
-
buffer.length = 0;
|
|
344
|
-
drain();
|
|
345
|
-
return Promise.resolve({
|
|
346
|
-
value: void 0,
|
|
347
|
-
done: true
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
[Symbol.asyncIterator]() {
|
|
351
|
-
return this;
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
result
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
function requestIdentity(request) {
|
|
358
|
-
const candidate = request;
|
|
359
|
-
const id = candidate.id ?? candidate.name ?? "agent.request";
|
|
360
|
-
return {
|
|
361
|
-
name: candidate.kind === "text" ? candidate.input?.name ?? id : candidate.name ?? id,
|
|
362
|
-
id
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Streams one {@link runAgent} call as agent-level events. The machine remains
|
|
367
|
-
* the single artifact; this function only projects its requests, chunks,
|
|
368
|
-
* transitions, emitted events, and terminal result into an async iterable.
|
|
369
|
-
*/
|
|
370
|
-
async function* runAgentStream(machine, options) {
|
|
371
|
-
const run = createAgentRun(machine, options);
|
|
372
|
-
for await (const event of run.events) switch (event.type) {
|
|
373
|
-
case "request.start":
|
|
374
|
-
yield {
|
|
375
|
-
kind: "request",
|
|
376
|
-
phase: "start",
|
|
377
|
-
...requestIdentity(event.request),
|
|
378
|
-
request: event.request
|
|
379
|
-
};
|
|
380
|
-
break;
|
|
381
|
-
case "request.end":
|
|
382
|
-
yield {
|
|
383
|
-
kind: "request",
|
|
384
|
-
phase: "end",
|
|
385
|
-
...requestIdentity(event.request),
|
|
386
|
-
request: event.request,
|
|
387
|
-
output: event.output,
|
|
388
|
-
raw: event.raw
|
|
389
|
-
};
|
|
390
|
-
break;
|
|
391
|
-
case "request.error":
|
|
392
|
-
yield {
|
|
393
|
-
kind: "request",
|
|
394
|
-
phase: "error",
|
|
395
|
-
...requestIdentity(event.request),
|
|
396
|
-
request: event.request,
|
|
397
|
-
error: event.error
|
|
398
|
-
};
|
|
399
|
-
break;
|
|
400
|
-
case "stream.chunk":
|
|
401
|
-
yield {
|
|
402
|
-
kind: "chunk",
|
|
403
|
-
...requestIdentity(event.request),
|
|
404
|
-
delta: event.chunk
|
|
405
|
-
};
|
|
406
|
-
break;
|
|
407
|
-
case "machine.transition":
|
|
408
|
-
yield {
|
|
409
|
-
kind: "transition",
|
|
410
|
-
value: event.snapshot.value,
|
|
411
|
-
event: event.event
|
|
412
|
-
};
|
|
413
|
-
break;
|
|
414
|
-
case "emit":
|
|
415
|
-
yield {
|
|
416
|
-
kind: "emit",
|
|
417
|
-
event: event.event
|
|
418
|
-
};
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
const result = await run.result;
|
|
422
|
-
if (result.status === "done") yield {
|
|
423
|
-
kind: "done",
|
|
424
|
-
result
|
|
425
|
-
};
|
|
426
|
-
else if (result.status === "idle") yield {
|
|
427
|
-
kind: "idle",
|
|
428
|
-
result
|
|
429
|
-
};
|
|
430
|
-
else yield {
|
|
431
|
-
kind: "error",
|
|
432
|
-
result
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
//#endregion
|
|
436
259
|
//#region src/provide-executors.ts
|
|
437
260
|
/**
|
|
438
261
|
* Binds a machine's agent actor sources to a set of host `executors` in one
|
|
439
262
|
* call, returning a `machine.provide(...)`-ed copy ready for a plain
|
|
440
|
-
* `createActor(...)` — the uncontrolled-mode counterpart to {@link
|
|
441
|
-
* No run loop, no
|
|
263
|
+
* `createActor(...)` — the uncontrolled-mode counterpart to {@link createAgentRuntime}.
|
|
264
|
+
* No run loop, no settling: the returned machine drives itself, so
|
|
442
265
|
*
|
|
443
266
|
* ```ts
|
|
444
267
|
* const actor = createActor(provideExecutors(machine, { generateText, decide }), { input });
|
|
@@ -453,10 +276,10 @@ async function* runAgentStream(machine, options) {
|
|
|
453
276
|
* - `mode: 'stream'` text source → `executors.streamText`
|
|
454
277
|
* - decision / `agent.decide` source → `executors.decide` (snapshot-driven
|
|
455
278
|
* candidate events, guard `canTake`, and auto-delivery of the chosen event,
|
|
456
|
-
* mirroring `
|
|
279
|
+
* mirroring `createAgentRuntime` but without its model-call counting)
|
|
457
280
|
*
|
|
458
281
|
* Pass `options.onTrace` to observe request-level trace events (identical in
|
|
459
|
-
* shape to `
|
|
282
|
+
* shape to `createAgentRuntime`'s); pair it with {@link traceTransitions} on the actor's
|
|
460
283
|
* `inspect` to also capture `machine.transition` events in the same stream.
|
|
461
284
|
*
|
|
462
285
|
* A source that already carries its own executor (`.withExecutor(...)`) is left
|
|
@@ -467,7 +290,7 @@ async function* runAgentStream(machine, options) {
|
|
|
467
290
|
* Throws at bind time if a source needs an executor kind that `executors` does
|
|
468
291
|
* not provide.
|
|
469
292
|
*
|
|
470
|
-
* Executor inheritance is RECURSIVE, exactly as in `
|
|
293
|
+
* Executor inheritance is RECURSIVE, exactly as in `createAgentRuntime`: a string-keyed
|
|
471
294
|
* invoked child machine is rebound too, so its own text/decision requests — at
|
|
472
295
|
* any depth — reach the same host executors. A direct-object invoke `src`
|
|
473
296
|
* cannot be swapped via `.provide`, so nothing under one inherits; bind those
|
|
@@ -523,7 +346,7 @@ function executorRequirementOf(logic) {
|
|
|
523
346
|
/**
|
|
524
347
|
* Walks an invoked child machine's own invoked sources (recursively, at any
|
|
525
348
|
* depth) and throws the same missing-executor error `provideExecutors` throws
|
|
526
|
-
* for the top-level machine — before any actor starts. Mirrors
|
|
349
|
+
* for the top-level machine — before any actor starts. Mirrors the runtime's
|
|
527
350
|
* `assertBindable` for the uncontrolled path. Cycle-safe via `visited`.
|
|
528
351
|
*/
|
|
529
352
|
function assertChildBindable(childMachine, executors, path, visited) {
|
|
@@ -546,4 +369,4 @@ function missingExecutorError(src, kind, executor) {
|
|
|
546
369
|
return /* @__PURE__ */ new Error(`provideExecutors: actor source '${src}' is a ${kind} source but no '${executor}' executor was provided. Add it to the executors object, or bind the source with its own executor (logic.withExecutor(...)) before calling provideExecutors.`);
|
|
547
370
|
}
|
|
548
371
|
//#endregion
|
|
549
|
-
export { AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, AgentDecisionExhaustedError, AgentError, AgentEventLogConflictError, AgentInvalidEventPayloadError, AgentMachineVersionMismatchError, AgentMaxModelCallsExceededError, AgentSnapshotDivergedError, AgentTruncatedError, assistantMessage, bindRequestExecutor, createAgentSchemas, createDecisionLogic, createDecisionRequest, createTextLogic, eventFromInteraction,
|
|
372
|
+
export { AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, AgentDecisionExhaustedError, AgentError, AgentEventLogConflictError, AgentInvalidEventPayloadError, AgentMachineVersionMismatchError, AgentMaxModelCallsExceededError, AgentSnapshotDivergedError, AgentTruncatedError, assistantMessage, bindRequestExecutor, createAgentRuntime, createAgentSchemas, createDecisionLogic, createDecisionRequest, createTextLogic, eventFromInteraction, getAcceptedEvents, getAgentOutputMode, getAgentSchemas, getCallFinishReason, getCallUsage, getInteraction, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getMessageText, getStateMeta, getStatePath, inspectTransitions, interactionMetaSchema, isAgentIdle, isAgentMessages, isStandardSchema, messagesSchema, parseAgentEvent, parseOutput, parseProviderOutput, provideExecutors, providerOutputSchema, renderDecisionAttempts, resolveDecision, runToQuiescence, serializeTraceEvent, setupAgent, systemMessage, toolMessage, traceTransitions, userMessage };
|
package/dist/log.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_event_log_store = require("./event-log-store-
|
|
2
|
+
const require_event_log_store = require("./event-log-store-C-COhIXP.cjs");
|
|
3
3
|
//#region src/event-log-store-conformance.ts
|
|
4
4
|
/**
|
|
5
5
|
* The runner-agnostic conformance suite for {@link AgentEventLogStore}
|
package/dist/log.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as validateReplayEntries, C as forkEventLog, D as initEntry, E as getUsageFromEvents, O as rebindActorSession, S as createReplayEntry, T as getSnapshotStateHash, _ as ReplayOptions, a as AGENT_INIT_EVENT_TYPE, b as assertAgentLogEntry, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as NonSerializableAgentEventError, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, k as replay, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayResult, w as getLogExecutionId, x as assertJsonSerializable, y as agentCallOccurrence } from "./event-log-store-
|
|
1
|
+
import { A as validateReplayEntries, C as forkEventLog, D as initEntry, E as getUsageFromEvents, O as rebindActorSession, S as createReplayEntry, T as getSnapshotStateHash, _ as ReplayOptions, a as AGENT_INIT_EVENT_TYPE, b as assertAgentLogEntry, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as NonSerializableAgentEventError, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, k as replay, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayResult, w as getLogExecutionId, x as assertJsonSerializable, y as agentCallOccurrence } from "./event-log-store-2xzFmgr2.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/event-log-store-conformance.d.ts
|
|
4
4
|
/** Produces a fresh, empty store for one case. */
|
package/dist/log.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as validateReplayEntries, C as forkEventLog, D as initEntry, E as getUsageFromEvents, O as rebindActorSession, S as createReplayEntry, T as getSnapshotStateHash, _ as ReplayOptions, a as AGENT_INIT_EVENT_TYPE, b as assertAgentLogEntry, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as NonSerializableAgentEventError, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, k as replay, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayResult, w as getLogExecutionId, x as assertJsonSerializable, y as agentCallOccurrence } from "./event-log-store-
|
|
1
|
+
import { A as validateReplayEntries, C as forkEventLog, D as initEntry, E as getUsageFromEvents, O as rebindActorSession, S as createReplayEntry, T as getSnapshotStateHash, _ as ReplayOptions, a as AGENT_INIT_EVENT_TYPE, b as assertAgentLogEntry, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as NonSerializableAgentEventError, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, k as replay, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayResult, w as getLogExecutionId, x as assertJsonSerializable, y as agentCallOccurrence } from "./event-log-store-BIPOz-di.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/event-log-store-conformance.d.ts
|
|
4
4
|
/** Produces a fresh, empty store for one case. */
|
package/dist/log.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as getUsageFromEvents, a as AgentEventLogError, b as replay, c as NonSerializableAgentEventError, d as assertJsonSerializable, g as getSnapshotStateHash, h as getLogExecutionId, i as AGENT_INIT_EVENT_TYPE, l as agentCallOccurrence, m as forkEventLog, n as createInMemoryEventLogStore, o as AgentMachineVersionMismatchError, p as createReplayEntry, r as AGENT_EVENT_SCHEMA_VERSION, s as AgentReplayDivergenceError, t as AgentEventLogConflictError, u as assertAgentLogEntry, v as initEntry, x as validateReplayEntries, y as rebindActorSession } from "./event-log-store-
|
|
1
|
+
import { _ as getUsageFromEvents, a as AgentEventLogError, b as replay, c as NonSerializableAgentEventError, d as assertJsonSerializable, g as getSnapshotStateHash, h as getLogExecutionId, i as AGENT_INIT_EVENT_TYPE, l as agentCallOccurrence, m as forkEventLog, n as createInMemoryEventLogStore, o as AgentMachineVersionMismatchError, p as createReplayEntry, r as AGENT_EVENT_SCHEMA_VERSION, s as AgentReplayDivergenceError, t as AgentEventLogConflictError, u as assertAgentLogEntry, v as initEntry, x as validateReplayEntries, y as rebindActorSession } from "./event-log-store-2pAFiWuc.mjs";
|
|
2
2
|
//#region src/event-log-store-conformance.ts
|
|
3
3
|
/**
|
|
4
4
|
* The runner-agnostic conformance suite for {@link AgentEventLogStore}
|
package/dist/machines.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_setup_agent = require("./setup-agent-
|
|
2
|
+
const require_setup_agent = require("./setup-agent-DV4cTou-.cjs");
|
|
3
3
|
//#region src/machines/internal.ts
|
|
4
4
|
/** The builtin inline text request every preset lowers a request entry to. */
|
|
5
5
|
const GENERATE_TEXT_SRC = "agent.generateText";
|
|
@@ -149,9 +149,8 @@ const outputSchema$5 = objectSchema({ result: jsonAny }, ["result"]);
|
|
|
149
149
|
* maxSteps: 5,
|
|
150
150
|
* });
|
|
151
151
|
*
|
|
152
|
-
* const result = await
|
|
152
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
153
153
|
* input: { prompt: "What is 42 * 17?" },
|
|
154
|
-
* executors,
|
|
155
154
|
* });
|
|
156
155
|
* // Snapshots and log entries carry machine.version ("1") automatically.
|
|
157
156
|
* ```
|
|
@@ -718,10 +717,9 @@ function transferEventType(agent) {
|
|
|
718
717
|
* },
|
|
719
718
|
* });
|
|
720
719
|
*
|
|
721
|
-
* const next = await
|
|
720
|
+
* const next = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
722
721
|
* snapshot,
|
|
723
722
|
* event: { type: "transfer_to_food", message: "What should I eat there?" },
|
|
724
|
-
* executors,
|
|
725
723
|
* });
|
|
726
724
|
* ```
|
|
727
725
|
*/
|
|
@@ -734,8 +732,7 @@ function createHandoffMachine(config) {
|
|
|
734
732
|
context: contextSchema,
|
|
735
733
|
input: inputSchema,
|
|
736
734
|
events: Object.fromEntries(names.map((name) => [transferEventType(name), transferPayload])),
|
|
737
|
-
actors: machineActors(agents)
|
|
738
|
-
isIdle: (snapshot) => snapshot.matches("waiting")
|
|
735
|
+
actors: machineActors(agents)
|
|
739
736
|
});
|
|
740
737
|
const turnState = (name) => `${name}Turn`;
|
|
741
738
|
const states = {
|
package/dist/machines.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { _ as StandardSchemaV1, s as AgentTools } from "./types-
|
|
1
|
+
import { _ as StandardSchemaV1, s as AgentTools } from "./types-hR5f5YXa.cjs";
|
|
2
2
|
import { AnyActorRef, AnyStateMachine, EventObject, MachineContext, MetaObject, StateMachine, StateSchema, StateValue } from "xstate";
|
|
3
3
|
|
|
4
4
|
//#region src/machines/internal.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* The machine type a preset factory returns: its context, event union, input
|
|
7
|
-
* and output are all concrete, so callers get typed
|
|
7
|
+
* and output are all concrete, so callers get typed run input and
|
|
8
8
|
* output instead of `AnyStateMachine`. The remaining slots (children, state
|
|
9
9
|
* value/tags/config, source maps) are left permissive — a preset builds its
|
|
10
10
|
* states dynamically, so there is no literal state schema to infer.
|
|
@@ -31,7 +31,7 @@ interface PresetRequestEntry {
|
|
|
31
31
|
interface PresetMachineEntry {
|
|
32
32
|
/** What this entry is for. Shown to the routing/supervising model. */
|
|
33
33
|
description?: string;
|
|
34
|
-
/** The child machine to invoke. Registered as an actor source, so
|
|
34
|
+
/** The child machine to invoke. Registered as an actor source, so the runtime binds its executors. */
|
|
35
35
|
machine: AnyStateMachine;
|
|
36
36
|
/** Builds the child's `input`. Defaults to `{ prompt }` (`{ message }` for handoff). */
|
|
37
37
|
input?: (args: {
|
|
@@ -89,9 +89,8 @@ type ToolLoopMachine = PresetMachine<ToolLoopContext, ToolLoopInput, ToolLoopOut
|
|
|
89
89
|
* maxSteps: 5,
|
|
90
90
|
* });
|
|
91
91
|
*
|
|
92
|
-
* const result = await
|
|
92
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
93
93
|
* input: { prompt: "What is 42 * 17?" },
|
|
94
|
-
* executors,
|
|
95
94
|
* });
|
|
96
95
|
* // Snapshots and log entries carry machine.version ("1") automatically.
|
|
97
96
|
* ```
|
|
@@ -454,10 +453,9 @@ declare function transferEventType(agent: string): string;
|
|
|
454
453
|
* },
|
|
455
454
|
* });
|
|
456
455
|
*
|
|
457
|
-
* const next = await
|
|
456
|
+
* const next = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
458
457
|
* snapshot,
|
|
459
458
|
* event: { type: "transfer_to_food", message: "What should I eat there?" },
|
|
460
|
-
* executors,
|
|
461
459
|
* });
|
|
462
460
|
* ```
|
|
463
461
|
*/
|
package/dist/machines.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { _ as StandardSchemaV1, s as AgentTools } from "./types-
|
|
1
|
+
import { _ as StandardSchemaV1, s as AgentTools } from "./types-BgNbNKnJ.mjs";
|
|
2
2
|
import { AnyActorRef, AnyStateMachine, EventObject, MachineContext, MetaObject, StateMachine, StateSchema, StateValue } from "xstate";
|
|
3
3
|
|
|
4
4
|
//#region src/machines/internal.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* The machine type a preset factory returns: its context, event union, input
|
|
7
|
-
* and output are all concrete, so callers get typed
|
|
7
|
+
* and output are all concrete, so callers get typed run input and
|
|
8
8
|
* output instead of `AnyStateMachine`. The remaining slots (children, state
|
|
9
9
|
* value/tags/config, source maps) are left permissive — a preset builds its
|
|
10
10
|
* states dynamically, so there is no literal state schema to infer.
|
|
@@ -31,7 +31,7 @@ interface PresetRequestEntry {
|
|
|
31
31
|
interface PresetMachineEntry {
|
|
32
32
|
/** What this entry is for. Shown to the routing/supervising model. */
|
|
33
33
|
description?: string;
|
|
34
|
-
/** The child machine to invoke. Registered as an actor source, so
|
|
34
|
+
/** The child machine to invoke. Registered as an actor source, so the runtime binds its executors. */
|
|
35
35
|
machine: AnyStateMachine;
|
|
36
36
|
/** Builds the child's `input`. Defaults to `{ prompt }` (`{ message }` for handoff). */
|
|
37
37
|
input?: (args: {
|
|
@@ -89,9 +89,8 @@ type ToolLoopMachine = PresetMachine<ToolLoopContext, ToolLoopInput, ToolLoopOut
|
|
|
89
89
|
* maxSteps: 5,
|
|
90
90
|
* });
|
|
91
91
|
*
|
|
92
|
-
* const result = await
|
|
92
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
93
93
|
* input: { prompt: "What is 42 * 17?" },
|
|
94
|
-
* executors,
|
|
95
94
|
* });
|
|
96
95
|
* // Snapshots and log entries carry machine.version ("1") automatically.
|
|
97
96
|
* ```
|
|
@@ -454,10 +453,9 @@ declare function transferEventType(agent: string): string;
|
|
|
454
453
|
* },
|
|
455
454
|
* });
|
|
456
455
|
*
|
|
457
|
-
* const next = await
|
|
456
|
+
* const next = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
458
457
|
* snapshot,
|
|
459
458
|
* event: { type: "transfer_to_food", message: "What should I eat there?" },
|
|
460
|
-
* executors,
|
|
461
459
|
* });
|
|
462
460
|
* ```
|
|
463
461
|
*/
|
package/dist/machines.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as setupAgent } from "./setup-agent-
|
|
1
|
+
import { r as setupAgent } from "./setup-agent-BuanDXeh.mjs";
|
|
2
2
|
//#region src/machines/internal.ts
|
|
3
3
|
/** The builtin inline text request every preset lowers a request entry to. */
|
|
4
4
|
const GENERATE_TEXT_SRC = "agent.generateText";
|
|
@@ -148,9 +148,8 @@ const outputSchema$5 = objectSchema({ result: jsonAny }, ["result"]);
|
|
|
148
148
|
* maxSteps: 5,
|
|
149
149
|
* });
|
|
150
150
|
*
|
|
151
|
-
* const result = await
|
|
151
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
152
152
|
* input: { prompt: "What is 42 * 17?" },
|
|
153
|
-
* executors,
|
|
154
153
|
* });
|
|
155
154
|
* // Snapshots and log entries carry machine.version ("1") automatically.
|
|
156
155
|
* ```
|
|
@@ -717,10 +716,9 @@ function transferEventType(agent) {
|
|
|
717
716
|
* },
|
|
718
717
|
* });
|
|
719
718
|
*
|
|
720
|
-
* const next = await
|
|
719
|
+
* const next = await runToQuiescence(createAgentRuntime(machine, { executors }), {
|
|
721
720
|
* snapshot,
|
|
722
721
|
* event: { type: "transfer_to_food", message: "What should I eat there?" },
|
|
723
|
-
* executors,
|
|
724
722
|
* });
|
|
725
723
|
* ```
|
|
726
724
|
*/
|
|
@@ -733,8 +731,7 @@ function createHandoffMachine(config) {
|
|
|
733
731
|
context: contextSchema,
|
|
734
732
|
input: inputSchema,
|
|
735
733
|
events: Object.fromEntries(names.map((name) => [transferEventType(name), transferPayload])),
|
|
736
|
-
actors: machineActors(agents)
|
|
737
|
-
isIdle: (snapshot) => snapshot.matches("waiting")
|
|
734
|
+
actors: machineActors(agents)
|
|
738
735
|
});
|
|
739
736
|
const turnState = (name) => `${name}Turn`;
|
|
740
737
|
const states = {
|
package/dist/openai.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_text_logic = require("./text-logic-
|
|
3
|
-
const require_decision = require("./decision-
|
|
2
|
+
const require_text_logic = require("./text-logic-f5F5sCdc.cjs");
|
|
3
|
+
const require_decision = require("./decision-CmM8-HHz.cjs");
|
|
4
4
|
//#region src/openai/index.ts
|
|
5
5
|
/** Thrown for a message part Chat Completions cannot carry — dropping it would
|
|
6
6
|
* silently change what the model sees. */
|
|
@@ -286,7 +286,7 @@ function toToolContent(output) {
|
|
|
286
286
|
* client: new OpenAI(),
|
|
287
287
|
* resolveModel: () => 'gpt-5.4-mini',
|
|
288
288
|
* });
|
|
289
|
-
* const result = await
|
|
289
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), { input });
|
|
290
290
|
* ```
|
|
291
291
|
*/
|
|
292
292
|
function createOpenAiExecutors(options) {
|
package/dist/openai.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as AgentToolChoice, n as AgentMessage, s as AgentTools, u as ChosenEvent } from "./types-
|
|
2
|
-
import { M as AgentDecisionRequest, U as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { i as AgentToolChoice, n as AgentMessage, s as AgentTools, u as ChosenEvent } from "./types-hR5f5YXa.cjs";
|
|
2
|
+
import { M as AgentDecisionRequest, U as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-IjfYy9DP.cjs";
|
|
3
3
|
import OpenAI from "openai";
|
|
4
4
|
import { ChatCompletion, ChatCompletionCreateParamsNonStreaming, ChatCompletionMessageParam, ChatCompletionTool } from "openai/resources/chat/completions/completions.js";
|
|
5
5
|
|
|
@@ -107,7 +107,7 @@ type CreateOpenAiExecutorsOptions = {
|
|
|
107
107
|
* Raw result shape from {@link OpenAiExecutors.generateText} — `result` (the
|
|
108
108
|
* validated structured object for structured-output requests, or the model's
|
|
109
109
|
* text otherwise) plus the call metadata. Core reads `result` and `usage`;
|
|
110
|
-
* everything else flows verbatim to `
|
|
110
|
+
* everything else flows verbatim to `createAgentRuntime`'s `onResult(request, { raw })`.
|
|
111
111
|
*/
|
|
112
112
|
type OpenAiGenerateResult = {
|
|
113
113
|
result: unknown;
|
|
@@ -115,7 +115,7 @@ type OpenAiGenerateResult = {
|
|
|
115
115
|
* `includeReasoning` and the model produced it. Never enters machine
|
|
116
116
|
* context/output. */
|
|
117
117
|
reasoning?: string;
|
|
118
|
-
/** The call's token usage, on the flat field names
|
|
118
|
+
/** The call's token usage, on the flat field names the runtime folds into the
|
|
119
119
|
* run result's aggregated `AgentUsage`. Absent when OpenAI reported none. */
|
|
120
120
|
usage?: AgentCallUsage; /** Why the call stopped, normalized to the portable {@link AgentFinishReason}. OpenAI's own value stays on `raw`. */
|
|
121
121
|
finishReason: AgentFinishReason; /** The untouched OpenAI response. */
|
|
@@ -169,7 +169,7 @@ declare function addAgentCallUsage(total: AgentCallUsage | undefined, next: Agen
|
|
|
169
169
|
* client: new OpenAI(),
|
|
170
170
|
* resolveModel: () => 'gpt-5.4-mini',
|
|
171
171
|
* });
|
|
172
|
-
* const result = await
|
|
172
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), { input });
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
175
|
declare function createOpenAiExecutors(options: CreateOpenAiExecutorsOptions): OpenAiExecutors;
|
package/dist/openai.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as AgentToolChoice, n as AgentMessage, s as AgentTools, u as ChosenEvent } from "./types-
|
|
2
|
-
import { M as AgentDecisionRequest, U as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { i as AgentToolChoice, n as AgentMessage, s as AgentTools, u as ChosenEvent } from "./types-BgNbNKnJ.mjs";
|
|
2
|
+
import { M as AgentDecisionRequest, U as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-D-czVPYp.mjs";
|
|
3
3
|
import OpenAI from "openai";
|
|
4
4
|
import { ChatCompletion, ChatCompletionCreateParamsNonStreaming, ChatCompletionMessageParam, ChatCompletionTool } from "openai/resources/chat/completions/completions.js";
|
|
5
5
|
|
|
@@ -107,7 +107,7 @@ type CreateOpenAiExecutorsOptions = {
|
|
|
107
107
|
* Raw result shape from {@link OpenAiExecutors.generateText} — `result` (the
|
|
108
108
|
* validated structured object for structured-output requests, or the model's
|
|
109
109
|
* text otherwise) plus the call metadata. Core reads `result` and `usage`;
|
|
110
|
-
* everything else flows verbatim to `
|
|
110
|
+
* everything else flows verbatim to `createAgentRuntime`'s `onResult(request, { raw })`.
|
|
111
111
|
*/
|
|
112
112
|
type OpenAiGenerateResult = {
|
|
113
113
|
result: unknown;
|
|
@@ -115,7 +115,7 @@ type OpenAiGenerateResult = {
|
|
|
115
115
|
* `includeReasoning` and the model produced it. Never enters machine
|
|
116
116
|
* context/output. */
|
|
117
117
|
reasoning?: string;
|
|
118
|
-
/** The call's token usage, on the flat field names
|
|
118
|
+
/** The call's token usage, on the flat field names the runtime folds into the
|
|
119
119
|
* run result's aggregated `AgentUsage`. Absent when OpenAI reported none. */
|
|
120
120
|
usage?: AgentCallUsage; /** Why the call stopped, normalized to the portable {@link AgentFinishReason}. OpenAI's own value stays on `raw`. */
|
|
121
121
|
finishReason: AgentFinishReason; /** The untouched OpenAI response. */
|
|
@@ -169,7 +169,7 @@ declare function addAgentCallUsage(total: AgentCallUsage | undefined, next: Agen
|
|
|
169
169
|
* client: new OpenAI(),
|
|
170
170
|
* resolveModel: () => 'gpt-5.4-mini',
|
|
171
171
|
* });
|
|
172
|
-
* const result = await
|
|
172
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), { input });
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
175
|
declare function createOpenAiExecutors(options: CreateOpenAiExecutorsOptions): OpenAiExecutors;
|
package/dist/openai.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as renderDecisionAttempts } from "./decision-
|
|
1
|
+
import { B as AgentTruncatedError, D as getJsonSchema, N as isStandardSchema, O as getJsonSchemaSync, c as getAgentOutputMode, h as providerOutputSchema, m as parseProviderOutput, t as AGENT_USAGE_TOKEN_FIELDS } from "./text-logic-CIqHAmBi.mjs";
|
|
2
|
+
import { o as renderDecisionAttempts } from "./decision-RQ0iv0oZ.mjs";
|
|
3
3
|
//#region src/openai/index.ts
|
|
4
4
|
/** Thrown for a message part Chat Completions cannot carry — dropping it would
|
|
5
5
|
* silently change what the model sees. */
|
|
@@ -285,7 +285,7 @@ function toToolContent(output) {
|
|
|
285
285
|
* client: new OpenAI(),
|
|
286
286
|
* resolveModel: () => 'gpt-5.4-mini',
|
|
287
287
|
* });
|
|
288
|
-
* const result = await
|
|
288
|
+
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), { input });
|
|
289
289
|
* ```
|
|
290
290
|
*/
|
|
291
291
|
function createOpenAiExecutors(options) {
|
package/dist/otel.cjs
CHANGED
|
@@ -71,7 +71,7 @@ function toException(error) {
|
|
|
71
71
|
* GenAI spans: one `invoke_agent` span per run, one child span per model call,
|
|
72
72
|
* transitions and emissions as span events.
|
|
73
73
|
*
|
|
74
|
-
* Works on both paths. On the controlled path (`
|
|
74
|
+
* Works on both paths. On the controlled path (`createAgentRuntime`) the run span opens
|
|
75
75
|
* on `run.start` and closes on `run.end`. On the uncontrolled path
|
|
76
76
|
* (`provideExecutors` + `traceTransitions`) there is no run boundary, so the
|
|
77
77
|
* run span opens lazily on the first event of a `runId` and stays open until
|
|
@@ -84,7 +84,7 @@ function toException(error) {
|
|
|
84
84
|
*
|
|
85
85
|
* const onTrace = createOtelTraceHandler({ tracer: trace.getTracer('my-app') });
|
|
86
86
|
* try {
|
|
87
|
-
* await
|
|
87
|
+
* await runToQuiescence(createAgentRuntime(machine, { executors, onTrace }), { input });
|
|
88
88
|
* } finally {
|
|
89
89
|
* onTrace.dispose();
|
|
90
90
|
* }
|
package/dist/otel.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as AgentTraceEvent } from "./run-agent-ByO-Bxyd.cjs";
|
|
2
2
|
import { Attributes, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
3
3
|
|
|
4
4
|
//#region src/otel/index.d.ts
|
|
@@ -43,7 +43,7 @@ type OtelTraceHandler = ((event: AgentTraceEvent) => void) & {
|
|
|
43
43
|
* GenAI spans: one `invoke_agent` span per run, one child span per model call,
|
|
44
44
|
* transitions and emissions as span events.
|
|
45
45
|
*
|
|
46
|
-
* Works on both paths. On the controlled path (`
|
|
46
|
+
* Works on both paths. On the controlled path (`createAgentRuntime`) the run span opens
|
|
47
47
|
* on `run.start` and closes on `run.end`. On the uncontrolled path
|
|
48
48
|
* (`provideExecutors` + `traceTransitions`) there is no run boundary, so the
|
|
49
49
|
* run span opens lazily on the first event of a `runId` and stays open until
|
|
@@ -56,7 +56,7 @@ type OtelTraceHandler = ((event: AgentTraceEvent) => void) & {
|
|
|
56
56
|
*
|
|
57
57
|
* const onTrace = createOtelTraceHandler({ tracer: trace.getTracer('my-app') });
|
|
58
58
|
* try {
|
|
59
|
-
* await
|
|
59
|
+
* await runToQuiescence(createAgentRuntime(machine, { executors, onTrace }), { input });
|
|
60
60
|
* } finally {
|
|
61
61
|
* onTrace.dispose();
|
|
62
62
|
* }
|
package/dist/otel.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as AgentTraceEvent } from "./run-agent-COXXc0RW.mjs";
|
|
2
2
|
import { Attributes, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
3
3
|
|
|
4
4
|
//#region src/otel/index.d.ts
|
|
@@ -43,7 +43,7 @@ type OtelTraceHandler = ((event: AgentTraceEvent) => void) & {
|
|
|
43
43
|
* GenAI spans: one `invoke_agent` span per run, one child span per model call,
|
|
44
44
|
* transitions and emissions as span events.
|
|
45
45
|
*
|
|
46
|
-
* Works on both paths. On the controlled path (`
|
|
46
|
+
* Works on both paths. On the controlled path (`createAgentRuntime`) the run span opens
|
|
47
47
|
* on `run.start` and closes on `run.end`. On the uncontrolled path
|
|
48
48
|
* (`provideExecutors` + `traceTransitions`) there is no run boundary, so the
|
|
49
49
|
* run span opens lazily on the first event of a `runId` and stays open until
|
|
@@ -56,7 +56,7 @@ type OtelTraceHandler = ((event: AgentTraceEvent) => void) & {
|
|
|
56
56
|
*
|
|
57
57
|
* const onTrace = createOtelTraceHandler({ tracer: trace.getTracer('my-app') });
|
|
58
58
|
* try {
|
|
59
|
-
* await
|
|
59
|
+
* await runToQuiescence(createAgentRuntime(machine, { executors, onTrace }), { input });
|
|
60
60
|
* } finally {
|
|
61
61
|
* onTrace.dispose();
|
|
62
62
|
* }
|
package/dist/otel.mjs
CHANGED
|
@@ -69,7 +69,7 @@ function toException(error) {
|
|
|
69
69
|
* GenAI spans: one `invoke_agent` span per run, one child span per model call,
|
|
70
70
|
* transitions and emissions as span events.
|
|
71
71
|
*
|
|
72
|
-
* Works on both paths. On the controlled path (`
|
|
72
|
+
* Works on both paths. On the controlled path (`createAgentRuntime`) the run span opens
|
|
73
73
|
* on `run.start` and closes on `run.end`. On the uncontrolled path
|
|
74
74
|
* (`provideExecutors` + `traceTransitions`) there is no run boundary, so the
|
|
75
75
|
* run span opens lazily on the first event of a `runId` and stays open until
|
|
@@ -82,7 +82,7 @@ function toException(error) {
|
|
|
82
82
|
*
|
|
83
83
|
* const onTrace = createOtelTraceHandler({ tracer: trace.getTracer('my-app') });
|
|
84
84
|
* try {
|
|
85
|
-
* await
|
|
85
|
+
* await runToQuiescence(createAgentRuntime(machine, { executors, onTrace }), { input });
|
|
86
86
|
* } finally {
|
|
87
87
|
* onTrace.dispose();
|
|
88
88
|
* }
|