@statelyai/agent 2.0.0-alpha.31 → 2.0.0-alpha.33
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 +22 -0
- package/dist/ai-sdk.cjs +3 -3
- package/dist/ai-sdk.d.cts +1 -1
- package/dist/ai-sdk.d.mts +1 -1
- package/dist/ai-sdk.mjs +3 -3
- package/dist/{decision-Iys2hzg3.cjs → decision-BPdEaxPf.cjs} +1 -1
- package/dist/{decision-DqO018Tp.mjs → decision-CV7WiV5C.mjs} +1 -1
- package/dist/{event-log-Bdww2l1D.cjs → event-log-CKWeC7H-.cjs} +22 -3
- package/dist/{event-log-DE430ZCa.mjs → event-log-DAqsalT1.mjs} +22 -3
- package/dist/{event-log-store-CCWdTPEP.mjs → event-log-store-BGehvVTb.mjs} +2 -2
- package/dist/{event-log-store-DTf_OzB-.d.cts → event-log-store-C2NjVlWU.d.mts} +13 -5
- package/dist/{event-log-store-BWMLi6oh.cjs → event-log-store-DKyE7JKr.cjs} +2 -2
- package/dist/{event-log-store-RziIobdW.d.mts → event-log-store-s73r1Hxf.d.cts} +13 -5
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +9 -8
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +5 -5
- package/dist/log.cjs +40 -5
- package/dist/log.d.cts +1 -1
- package/dist/log.d.mts +1 -1
- package/dist/log.mjs +40 -5
- package/dist/machines.cjs +1 -1
- package/dist/machines.mjs +1 -1
- package/dist/{model-source-DQ7KgJaT.cjs → model-source-BQ97_l1-.cjs} +1 -1
- package/dist/{model-source-CXsSZPq0.mjs → model-source-BilDEyqk.mjs} +1 -1
- package/dist/openai.cjs +2 -2
- package/dist/openai.d.cts +1 -1
- package/dist/openai.d.mts +1 -1
- package/dist/openai.mjs +2 -2
- package/dist/otel.d.cts +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/{run-agent-DWZ1uyBJ.mjs → run-agent-2UnSUhDb.mjs} +7 -5
- package/dist/{run-agent-D4MwS5GY.d.mts → run-agent-Atu-wEk7.d.mts} +3 -3
- package/dist/{run-agent-B5opVUxx.d.cts → run-agent-B5QhabdY.d.cts} +3 -3
- package/dist/{run-agent-tmk58M0x.cjs → run-agent-Cg0xd3K-.cjs} +7 -5
- package/dist/{setup-agent-yFFVXf5s.d.cts → setup-agent-BiF1N3td.d.cts} +2 -2
- package/dist/{setup-agent-BaffhCcM.mjs → setup-agent-CmhB-U5P.mjs} +2 -2
- package/dist/{setup-agent-D0L8Anl_.cjs → setup-agent-CwUJyqKB.cjs} +2 -2
- package/dist/{setup-agent-CPyg2ic7.d.mts → setup-agent-J9f_Wu5T.d.mts} +2 -2
- package/dist/tanstack-ai.cjs +3 -3
- package/dist/tanstack-ai.d.cts +1 -1
- package/dist/tanstack-ai.d.mts +1 -1
- package/dist/tanstack-ai.mjs +3 -3
- package/dist/testing.cjs +495 -5
- package/dist/testing.d.cts +389 -5
- package/dist/testing.d.mts +389 -5
- package/dist/testing.mjs +491 -6
- package/dist/{text-logic-j9hShB7d.d.cts → text-logic-CYP502VT.d.cts} +5 -3
- package/dist/{text-logic-BwdrDpO9.d.mts → text-logic-DuK9HIFM.d.mts} +5 -3
- package/dist/{usage-BYqv7VBw.d.cts → usage-D7JKAxLc.d.mts} +1 -1
- package/dist/{usage-Bl4nK8D-.d.mts → usage-DVw-646x.d.cts} +1 -1
- package/dist/validate.cjs +3 -3
- package/dist/validate.d.cts +2 -2
- package/dist/validate.d.mts +2 -2
- package/dist/validate.mjs +3 -3
- package/dist/{verify-tkymWz6X.d.mts → verify-BVz4cURF.d.mts} +1 -1
- package/dist/{verify-CS_xxvVU.cjs → verify-CS_WLRXn.cjs} +19 -3
- package/dist/{verify-BH5e0XLK.mjs → verify-DgB8P-Wx.mjs} +14 -4
- package/dist/{verify-CPKDPMwY.d.cts → verify-Dk3Vwnha.d.cts} +1 -1
- package/package.json +1 -1
- package/skills/add-evals/SKILL.md +8 -2
- package/skills/improve-machine/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @statelyai/agent
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.33
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#181](https://github.com/statelyai/agent/pull/181) [`407e2a6`](https://github.com/statelyai/agent/commit/407e2a6c03e463d4b8d92997cf59e72b30301511) Thanks [@davidkpiano](https://github.com/davidkpiano)! - **Four eval helpers in `@statelyai/agent/testing`.**
|
|
8
|
+
|
|
9
|
+
- `traceCoverage(machine, traces, { reachable? })` reports which states and handlers no trace exercised. Coverage is per handler: a state and an event it handles, with the targets it declares and the ones runs reached. `always` handlers are listed as unobservable, because traces record one step per macrostep.
|
|
10
|
+
- `repeatRuns({ scenarios, k, run, passed })` runs each scenario `k` times and reports passes, pass@k, pass^k, distinct paths, and the state where the runs diverged. `report.passHat(j)` estimates the suite's pass^j. `summarizeRepeats` builds the same report from runs collected elsewhere.
|
|
11
|
+
- `judgeAgreement(rows, { positive?, groupBy? })` compares a judge's labels with confirmed human labels: accuracy, per-label recall, the confusion matrix, disagreements, the true positive and true negative rates, and a correction for the judge's bias.
|
|
12
|
+
- `firstDivergence(actual, reference)` finds the first step where a run departs from a reference trace or an expected trajectory, and names the state it was in.
|
|
13
|
+
- `foldTraces` takes a `blame` option and adds a `blamed` column: failed runs counted once, against the state their failure started in. Rows now always include `blamed`, which is 0 without `blame`.
|
|
14
|
+
|
|
15
|
+
## 2.0.0-alpha.32
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#178](https://github.com/statelyai/agent/pull/178) [`efe9dd0`](https://github.com/statelyai/agent/commit/efe9dd029b1fd4b333010f84997e4568eb760eea) Thanks [@davidkpiano](https://github.com/davidkpiano)! - **A fork is its own lineage.** `forkEventLog` and `store.fork` give the fork's init entry a fresh `metadata.executionId` and `metadata.forkedFrom: { executionId?, logIndex }` (the parent's id, when it has one, and the cutoff). Before, a fork kept its parent's execution id, so a call the fork made at the same site got the same `info.callKey` as the parent's, and a cache keyed on it could return the parent's result.
|
|
20
|
+
|
|
21
|
+
- **A custom store's `fork` must store what `forkEventLog` returns** for the prefix. `assertEventLogStoreConformance` now checks the lineage, and its fixtures start with a real init entry.
|
|
22
|
+
- A snapshot taken on the parent no longer takes the fast path when resuming the fork; the fork's log is folded instead. A version bridge still accepts it while the fork has appended nothing since its cutoff.
|
|
23
|
+
- Explicit `events` for a stored thread must also match its init entry's `executionId`, so a parent's log is refused for its fork's thread.
|
|
24
|
+
|
|
3
25
|
## 2.0.0-alpha.31
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/ai-sdk.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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_model_source = require("./model-source-
|
|
2
|
+
const require_event_log = require("./event-log-CKWeC7H-.cjs");
|
|
3
|
+
const require_decision = require("./decision-BPdEaxPf.cjs");
|
|
4
|
+
const require_model_source = require("./model-source-BQ97_l1-.cjs");
|
|
5
5
|
let ai = require("ai");
|
|
6
6
|
//#region src/ai-sdk/mappers.ts
|
|
7
7
|
/**
|
package/dist/ai-sdk.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as AgentTools, u as ChosenEvent } from "./types-Dp5_Ru4R.cjs";
|
|
2
|
-
import { N as AgentDecisionRequest, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-
|
|
2
|
+
import { N as AgentDecisionRequest, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-CYP502VT.cjs";
|
|
3
3
|
import { Experimental_DecisionModel, FinishReason, LanguageModel, LanguageModelUsage, ModelMessage, ToolSet, TypedToolCall, TypedToolResult, generateText } from "ai";
|
|
4
4
|
import { AnyStateMachine } from "xstate";
|
|
5
5
|
//#region src/ai-sdk/mappers.d.ts
|
package/dist/ai-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as AgentTools, u as ChosenEvent } from "./types-Dp5_Ru4R.mjs";
|
|
2
|
-
import { N as AgentDecisionRequest, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-
|
|
2
|
+
import { N as AgentDecisionRequest, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-DuK9HIFM.mjs";
|
|
3
3
|
import { AnyStateMachine } from "xstate";
|
|
4
4
|
import { Experimental_DecisionModel, FinishReason, LanguageModel, LanguageModelUsage, ModelMessage, ToolSet, TypedToolCall, TypedToolResult, generateText } from "ai";
|
|
5
5
|
//#region src/ai-sdk/mappers.d.ts
|
package/dist/ai-sdk.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as providerOutputSchema, dt as AgentTruncatedError, j as getAgentOutputMode, lt as isRecord, tt as isStandardSchema } from "./event-log-
|
|
2
|
-
import { c as renderDecisionAttempts, o as decisionOptionIds } from "./decision-
|
|
3
|
-
import { t as resolveModelSource } from "./model-source-
|
|
1
|
+
import { R as providerOutputSchema, dt as AgentTruncatedError, j as getAgentOutputMode, lt as isRecord, tt as isStandardSchema } from "./event-log-DAqsalT1.mjs";
|
|
2
|
+
import { c as renderDecisionAttempts, o as decisionOptionIds } from "./decision-CV7WiV5C.mjs";
|
|
3
|
+
import { t as resolveModelSource } from "./model-source-BilDEyqk.mjs";
|
|
4
4
|
import { InvalidResponseDataError, NoObjectGeneratedError, Output, experimental_decide, generateText, jsonSchema, stepCountIs, streamText, tool } from "ai";
|
|
5
5
|
//#region src/ai-sdk/mappers.ts
|
|
6
6
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as getAgentExecutionOptions, T as DECIDE_ACTOR, V as executorBoundLogics, at as userMessage, lt as isRecord, ot as validateSchemaSync, u as canonicalEventJson, ut as AgentError, z as resolveTextLogicValue } from "./event-log-
|
|
1
|
+
import { H as getAgentExecutionOptions, T as DECIDE_ACTOR, V as executorBoundLogics, at as userMessage, lt as isRecord, ot as validateSchemaSync, u as canonicalEventJson, ut as AgentError, z as resolveTextLogicValue } from "./event-log-DAqsalT1.mjs";
|
|
2
2
|
import { createAsyncLogic, getNextTransitions } from "xstate";
|
|
3
3
|
//#region src/events.ts
|
|
4
4
|
/**
|
|
@@ -1239,8 +1239,8 @@ function isSnapshotInitEntry(entry) {
|
|
|
1239
1239
|
* Minted once per run and inherited verbatim by every resume of that log, so
|
|
1240
1240
|
* it names one lineage rather than one process. Entry ids cannot serve this
|
|
1241
1241
|
* role — the built-in ids are index-derived, so every log's init entry is
|
|
1242
|
-
* `evt_00000000`. A fork
|
|
1243
|
-
*
|
|
1242
|
+
* `evt_00000000`. A fork ({@link forkEventLog}, `store.fork`) mints its own
|
|
1243
|
+
* and records the parent's in `metadata.forkedFrom`.
|
|
1244
1244
|
*
|
|
1245
1245
|
* Returns `undefined` for a log with no init entry and for one written without
|
|
1246
1246
|
* the field — callers must treat the id as optional.
|
|
@@ -1288,12 +1288,31 @@ function validateReplayEntries(entries, options = {}) {
|
|
|
1288
1288
|
/**
|
|
1289
1289
|
* The prefix `[0, upToIndex)` of a log, as a new log. `upToIndex` is exclusive
|
|
1290
1290
|
* and must leave the init entry in place, so the fork is still self-contained.
|
|
1291
|
+
*
|
|
1292
|
+
* The fork is its own lineage: its init entry gets a fresh
|
|
1293
|
+
* `metadata.executionId` and `metadata.forkedFrom: { executionId?, logIndex }`:
|
|
1294
|
+
* the cutoff, and the parent's id when it had one. Call keys derive
|
|
1295
|
+
* from the execution id, so a fork's calls never collide with its parent's.
|
|
1296
|
+
* Every other entry is copied as is.
|
|
1291
1297
|
*/
|
|
1292
1298
|
function forkEventLog(entries, upToIndex) {
|
|
1293
1299
|
if (!Number.isInteger(upToIndex) || upToIndex < 1 || upToIndex > entries.length) throw new AgentEventLogError(`forkEventLog: upToIndex must be an integer in [1, ${entries.length}]; got ${String(upToIndex)}.`);
|
|
1294
1300
|
const forked = entries.slice(0, upToIndex);
|
|
1295
1301
|
if (!isInitEntry(forked[0])) throw new AgentEventLogError(`forkEventLog: the forked prefix must start with the reserved '${AGENT_INIT_EVENT_TYPE}' entry.`);
|
|
1296
|
-
|
|
1302
|
+
const [init, ...rest] = forked;
|
|
1303
|
+
const parentExecutionId = getLogExecutionId(forked);
|
|
1304
|
+
const forkedFrom = {
|
|
1305
|
+
...parentExecutionId !== void 0 ? { executionId: parentExecutionId } : {},
|
|
1306
|
+
logIndex: upToIndex
|
|
1307
|
+
};
|
|
1308
|
+
return [{
|
|
1309
|
+
...init,
|
|
1310
|
+
metadata: {
|
|
1311
|
+
...init.metadata,
|
|
1312
|
+
executionId: crypto.randomUUID(),
|
|
1313
|
+
forkedFrom
|
|
1314
|
+
}
|
|
1315
|
+
}, ...rest];
|
|
1297
1316
|
}
|
|
1298
1317
|
const DONE_ACTOR_EVENT_TYPE = "xstate.done.actor";
|
|
1299
1318
|
const ERROR_ACTOR_EVENT_TYPE = "xstate.error.actor";
|
|
@@ -1239,8 +1239,8 @@ function isSnapshotInitEntry(entry) {
|
|
|
1239
1239
|
* Minted once per run and inherited verbatim by every resume of that log, so
|
|
1240
1240
|
* it names one lineage rather than one process. Entry ids cannot serve this
|
|
1241
1241
|
* role — the built-in ids are index-derived, so every log's init entry is
|
|
1242
|
-
* `evt_00000000`. A fork
|
|
1243
|
-
*
|
|
1242
|
+
* `evt_00000000`. A fork ({@link forkEventLog}, `store.fork`) mints its own
|
|
1243
|
+
* and records the parent's in `metadata.forkedFrom`.
|
|
1244
1244
|
*
|
|
1245
1245
|
* Returns `undefined` for a log with no init entry and for one written without
|
|
1246
1246
|
* the field — callers must treat the id as optional.
|
|
@@ -1288,12 +1288,31 @@ function validateReplayEntries(entries, options = {}) {
|
|
|
1288
1288
|
/**
|
|
1289
1289
|
* The prefix `[0, upToIndex)` of a log, as a new log. `upToIndex` is exclusive
|
|
1290
1290
|
* and must leave the init entry in place, so the fork is still self-contained.
|
|
1291
|
+
*
|
|
1292
|
+
* The fork is its own lineage: its init entry gets a fresh
|
|
1293
|
+
* `metadata.executionId` and `metadata.forkedFrom: { executionId?, logIndex }`:
|
|
1294
|
+
* the cutoff, and the parent's id when it had one. Call keys derive
|
|
1295
|
+
* from the execution id, so a fork's calls never collide with its parent's.
|
|
1296
|
+
* Every other entry is copied as is.
|
|
1291
1297
|
*/
|
|
1292
1298
|
function forkEventLog(entries, upToIndex) {
|
|
1293
1299
|
if (!Number.isInteger(upToIndex) || upToIndex < 1 || upToIndex > entries.length) throw new AgentEventLogError(`forkEventLog: upToIndex must be an integer in [1, ${entries.length}]; got ${String(upToIndex)}.`);
|
|
1294
1300
|
const forked = entries.slice(0, upToIndex);
|
|
1295
1301
|
if (!isInitEntry(forked[0])) throw new AgentEventLogError(`forkEventLog: the forked prefix must start with the reserved '${AGENT_INIT_EVENT_TYPE}' entry.`);
|
|
1296
|
-
|
|
1302
|
+
const [init, ...rest] = forked;
|
|
1303
|
+
const parentExecutionId = getLogExecutionId(forked);
|
|
1304
|
+
const forkedFrom = {
|
|
1305
|
+
...parentExecutionId !== void 0 ? { executionId: parentExecutionId } : {},
|
|
1306
|
+
logIndex: upToIndex
|
|
1307
|
+
};
|
|
1308
|
+
return [{
|
|
1309
|
+
...init,
|
|
1310
|
+
metadata: {
|
|
1311
|
+
...init.metadata,
|
|
1312
|
+
executionId: crypto.randomUUID(),
|
|
1313
|
+
forkedFrom
|
|
1314
|
+
}
|
|
1315
|
+
}, ...rest];
|
|
1297
1316
|
}
|
|
1298
1317
|
const DONE_ACTOR_EVENT_TYPE = "xstate.done.actor";
|
|
1299
1318
|
const ERROR_ACTOR_EVENT_TYPE = "xstate.error.actor";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as assertAgentLogEntry, ut as AgentError } from "./event-log-
|
|
1
|
+
import { c as assertAgentLogEntry, p as forkEventLog, ut as AgentError } from "./event-log-DAqsalT1.mjs";
|
|
2
2
|
//#region src/event-log-store.ts
|
|
3
3
|
/**
|
|
4
4
|
* Durable storage for {@link AgentLogEntry} logs: the one interface a host
|
|
@@ -65,7 +65,7 @@ function createInMemoryEventLogStore() {
|
|
|
65
65
|
if (!source) throw new Error(`AgentEventLogStore.fork: unknown source thread "${threadId}".`);
|
|
66
66
|
const upTo = upToIndex ?? source.length;
|
|
67
67
|
if (!Number.isInteger(upTo) || upTo < 1 || upTo > source.length) throw new Error(`AgentEventLogStore.fork: upToIndex must be an integer in [1, ${source.length}] on thread "${threadId}"; got ${String(upTo)}.`);
|
|
68
|
-
threads.set(newThreadId, source
|
|
68
|
+
threads.set(newThreadId, forkEventLog(source, upTo).map((entry) => clone(entry)));
|
|
69
69
|
},
|
|
70
70
|
async listThreads(options = {}) {
|
|
71
71
|
const { prefix = "", limit, cursor } = options;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as DecisionAttempt, Q as AgentError, t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { I as DecisionAttempt, Q as AgentError, t as AgentCallUsage } from "./text-logic-DuK9HIFM.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. */
|
|
@@ -186,8 +186,8 @@ declare function initEntry(machine: AnyStateMachine, init?: AgentLogInit, option
|
|
|
186
186
|
* Minted once per run and inherited verbatim by every resume of that log, so
|
|
187
187
|
* it names one lineage rather than one process. Entry ids cannot serve this
|
|
188
188
|
* role — the built-in ids are index-derived, so every log's init entry is
|
|
189
|
-
* `evt_00000000`. A fork
|
|
190
|
-
*
|
|
189
|
+
* `evt_00000000`. A fork ({@link forkEventLog}, `store.fork`) mints its own
|
|
190
|
+
* and records the parent's in `metadata.forkedFrom`.
|
|
191
191
|
*
|
|
192
192
|
* Returns `undefined` for a log with no init entry and for one written without
|
|
193
193
|
* the field — callers must treat the id as optional.
|
|
@@ -210,6 +210,12 @@ declare function validateReplayEntries(entries: readonly AgentLogEntry[], option
|
|
|
210
210
|
/**
|
|
211
211
|
* The prefix `[0, upToIndex)` of a log, as a new log. `upToIndex` is exclusive
|
|
212
212
|
* and must leave the init entry in place, so the fork is still self-contained.
|
|
213
|
+
*
|
|
214
|
+
* The fork is its own lineage: its init entry gets a fresh
|
|
215
|
+
* `metadata.executionId` and `metadata.forkedFrom: { executionId?, logIndex }`:
|
|
216
|
+
* the cutoff, and the parent's id when it had one. Call keys derive
|
|
217
|
+
* from the execution id, so a fork's calls never collide with its parent's.
|
|
218
|
+
* Every other entry is copied as is.
|
|
213
219
|
*/
|
|
214
220
|
declare function forkEventLog(entries: readonly AgentLogEntry[], upToIndex: number): AgentLogEntry[];
|
|
215
221
|
/**
|
|
@@ -380,8 +386,10 @@ interface AgentEventLogStore {
|
|
|
380
386
|
* init entry and stays a self-contained log. The fork then appends
|
|
381
387
|
* independently. Rejects (plain `Error`) if `newThreadId` already has
|
|
382
388
|
* entries, the source is unknown, or `upToIndex` is out of range.
|
|
383
|
-
*
|
|
384
|
-
*
|
|
389
|
+
*
|
|
390
|
+
* The fork is its own lineage: store what {@link forkEventLog} returns for
|
|
391
|
+
* the prefix, whose init entry carries a fresh `metadata.executionId` and
|
|
392
|
+
* `metadata.forkedFrom`. Every other entry must match the source.
|
|
385
393
|
*/
|
|
386
394
|
fork(input: {
|
|
387
395
|
threadId: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_event_log = require("./event-log-
|
|
1
|
+
const require_event_log = require("./event-log-CKWeC7H-.cjs");
|
|
2
2
|
//#region src/event-log-store.ts
|
|
3
3
|
/**
|
|
4
4
|
* Durable storage for {@link AgentLogEntry} logs: the one interface a host
|
|
@@ -65,7 +65,7 @@ function createInMemoryEventLogStore() {
|
|
|
65
65
|
if (!source) throw new Error(`AgentEventLogStore.fork: unknown source thread "${threadId}".`);
|
|
66
66
|
const upTo = upToIndex ?? source.length;
|
|
67
67
|
if (!Number.isInteger(upTo) || upTo < 1 || upTo > source.length) throw new Error(`AgentEventLogStore.fork: upToIndex must be an integer in [1, ${source.length}] on thread "${threadId}"; got ${String(upTo)}.`);
|
|
68
|
-
threads.set(newThreadId,
|
|
68
|
+
threads.set(newThreadId, require_event_log.forkEventLog(source, upTo).map((entry) => clone(entry)));
|
|
69
69
|
},
|
|
70
70
|
async listThreads(options = {}) {
|
|
71
71
|
const { prefix = "", limit, cursor } = options;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as DecisionAttempt, Q as AgentError, t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { I as DecisionAttempt, Q as AgentError, t as AgentCallUsage } from "./text-logic-CYP502VT.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. */
|
|
@@ -186,8 +186,8 @@ declare function initEntry(machine: AnyStateMachine, init?: AgentLogInit, option
|
|
|
186
186
|
* Minted once per run and inherited verbatim by every resume of that log, so
|
|
187
187
|
* it names one lineage rather than one process. Entry ids cannot serve this
|
|
188
188
|
* role — the built-in ids are index-derived, so every log's init entry is
|
|
189
|
-
* `evt_00000000`. A fork
|
|
190
|
-
*
|
|
189
|
+
* `evt_00000000`. A fork ({@link forkEventLog}, `store.fork`) mints its own
|
|
190
|
+
* and records the parent's in `metadata.forkedFrom`.
|
|
191
191
|
*
|
|
192
192
|
* Returns `undefined` for a log with no init entry and for one written without
|
|
193
193
|
* the field — callers must treat the id as optional.
|
|
@@ -210,6 +210,12 @@ declare function validateReplayEntries(entries: readonly AgentLogEntry[], option
|
|
|
210
210
|
/**
|
|
211
211
|
* The prefix `[0, upToIndex)` of a log, as a new log. `upToIndex` is exclusive
|
|
212
212
|
* and must leave the init entry in place, so the fork is still self-contained.
|
|
213
|
+
*
|
|
214
|
+
* The fork is its own lineage: its init entry gets a fresh
|
|
215
|
+
* `metadata.executionId` and `metadata.forkedFrom: { executionId?, logIndex }`:
|
|
216
|
+
* the cutoff, and the parent's id when it had one. Call keys derive
|
|
217
|
+
* from the execution id, so a fork's calls never collide with its parent's.
|
|
218
|
+
* Every other entry is copied as is.
|
|
213
219
|
*/
|
|
214
220
|
declare function forkEventLog(entries: readonly AgentLogEntry[], upToIndex: number): AgentLogEntry[];
|
|
215
221
|
/**
|
|
@@ -380,8 +386,10 @@ interface AgentEventLogStore {
|
|
|
380
386
|
* init entry and stays a self-contained log. The fork then appends
|
|
381
387
|
* independently. Rejects (plain `Error`) if `newThreadId` already has
|
|
382
388
|
* entries, the source is unknown, or `upToIndex` is out of range.
|
|
383
|
-
*
|
|
384
|
-
*
|
|
389
|
+
*
|
|
390
|
+
* The fork is its own lineage: store what {@link forkEventLog} returns for
|
|
391
|
+
* the prefix, whose init entry carries a fresh `metadata.executionId` and
|
|
392
|
+
* `metadata.forkedFrom`. Every other entry must match the source.
|
|
385
393
|
*/
|
|
386
394
|
fork(input: {
|
|
387
395
|
threadId: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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_setup_agent = require("./setup-agent-
|
|
5
|
-
const require_event_log_store = require("./event-log-store-
|
|
6
|
-
const require_run_agent = require("./run-agent-
|
|
2
|
+
const require_event_log = require("./event-log-CKWeC7H-.cjs");
|
|
3
|
+
const require_decision = require("./decision-BPdEaxPf.cjs");
|
|
4
|
+
const require_setup_agent = require("./setup-agent-CwUJyqKB.cjs");
|
|
5
|
+
const require_event_log_store = require("./event-log-store-DKyE7JKr.cjs");
|
|
6
|
+
const require_run_agent = require("./run-agent-Cg0xd3K-.cjs");
|
|
7
7
|
let xstate = require("xstate");
|
|
8
8
|
//#region src/messages.ts
|
|
9
9
|
const KNOWN_PART_TYPES = /* @__PURE__ */ new Set([
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { C as UserMessage, S as ToolResultPart, _ as StandardSchemaV1, a as AgentToolDescriptor, b as ToolCallPart, c as AllowedEvents, d as EventUnion, f as FilePart, h as InferOutput, i as AgentToolChoice, l as AssistantMessage, m as InferInput, n as AgentMessage, o as AgentToolExecute, p as ImagePart, r as AgentTool, s as AgentTools, u as ChosenEvent, v as SystemMessage, x as ToolMessage, y as TextPart } from "./types-Dp5_Ru4R.cjs";
|
|
2
|
-
import { $ as AgentTruncatedError, A as AgentDecisionExhaustedError, B as createDecisionLogic, C as getAgentOutputMode, D as parseProviderOutput, E as parseOutput, F as CreateDecisionRequestOptions, G as AgentInvalidEventPayloadError, H as renderDecisionAttempts, I as DecisionAttempt, J as AgentSchemas, K as AgentRequestOptions, L as DecisionLogic, M as AgentDecisionOption, N as AgentDecisionRequest, O as providerOutputSchema, P as AgentExecutorDecisionRequest, Q as AgentError, R as DecisionLogicConfig, S as createTextLogic, T as getCallUsage, U as resolveDecision, V as createDecisionRequest, W as AgentEventDescriptor, X as getAcceptedEvents, Y as EventFromSnapshot, Z as parseAgentEvent, _ as TextLogic, a as AgentModelRef, b as TextLogicExecutor, c as AgentRequestExecutorInfo, f as AgentTextRequest, g as ProviderStructuredOutput, j as AgentDecisionInput, k as AgentDecisionExecutor, l as AgentRequestExecutorResult, m as AgentUsage, n as AgentExecutorTextRequest, o as AgentOutputMode, p as AgentTextResult, q as AgentRequestSource, r as AgentFinishReason, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors, v as TextLogicConfig, w as getCallFinishReason, x as bindRequestExecutor, y as TextLogicExecuteArgs, z as ResolveDecisionOptions } from "./text-logic-
|
|
3
|
-
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-
|
|
4
|
-
import { C as AgentInteractionEventMeta, D as getInteraction, E as eventFromInteraction, O as interactionMetaSchema, S as AgentInteractionEvent, T as GetInteractionOptions, _ as FromConfigResult, a as WithAgentUsageEvent, b as AgentInteractionChoice, c as setupAgent, d as AgentWorkflowConfig, f as AgentWorkflowInvokeConfig, g as FromConfigOptions, h as AgentWorkflowTransitionConfig, i as WithAgentEvents, l as AgentWorkflowActionConfig, m as AgentWorkflowStateConfig, n as AgentSchemaPack, o as createAgentSchemas, p as AgentWorkflowRequestConfig, r as AgentUsageEventPayload, s as getAgentSchemas, t as AgentDefaultMeta, u as AgentWorkflowActorConfig, v as SchemaCompiler, w as AgentInteractionMeta, x as AgentInteractionDescriptor, y as AgentInteraction } from "./setup-agent-
|
|
5
|
-
import { C as runAgent, D as AgentRequest, E as traceTransitions, O as AgentStepRequest, S as isAgentIdle, T as serializeTraceEvent, _ as AgentTransitionHandler, a as AgentRunErrorCause, b as createAgentRuntime, c as AgentRunOptions, d as AgentRuntime, f as AgentRuntimeOptions, g as AgentTraceEvent, h as AgentTimerScheduler, i as AgentMaxModelCallsExceededError, l as AgentRunResult, m as AgentTimerEvent, n as AgentEffects, o as AgentRunInit, p as AgentSnapshotDivergedError, r as AgentInputFrom, s as AgentRunMeta, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentRunStart, v as InspectedActorRef, w as runToQuiescence, x as inspectTransitions, y as JsonSerializableTraceEvent } from "./run-agent-
|
|
6
|
-
import { c as AgentLogEntry, d as AgentMachineVersionMismatchError, n as AgentEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-
|
|
2
|
+
import { $ as AgentTruncatedError, A as AgentDecisionExhaustedError, B as createDecisionLogic, C as getAgentOutputMode, D as parseProviderOutput, E as parseOutput, F as CreateDecisionRequestOptions, G as AgentInvalidEventPayloadError, H as renderDecisionAttempts, I as DecisionAttempt, J as AgentSchemas, K as AgentRequestOptions, L as DecisionLogic, M as AgentDecisionOption, N as AgentDecisionRequest, O as providerOutputSchema, P as AgentExecutorDecisionRequest, Q as AgentError, R as DecisionLogicConfig, S as createTextLogic, T as getCallUsage, U as resolveDecision, V as createDecisionRequest, W as AgentEventDescriptor, X as getAcceptedEvents, Y as EventFromSnapshot, Z as parseAgentEvent, _ as TextLogic, a as AgentModelRef, b as TextLogicExecutor, c as AgentRequestExecutorInfo, f as AgentTextRequest, g as ProviderStructuredOutput, j as AgentDecisionInput, k as AgentDecisionExecutor, l as AgentRequestExecutorResult, m as AgentUsage, n as AgentExecutorTextRequest, o as AgentOutputMode, p as AgentTextResult, q as AgentRequestSource, r as AgentFinishReason, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors, v as TextLogicConfig, w as getCallFinishReason, x as bindRequestExecutor, y as TextLogicExecuteArgs, z as ResolveDecisionOptions } from "./text-logic-CYP502VT.cjs";
|
|
3
|
+
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-DVw-646x.cjs";
|
|
4
|
+
import { C as AgentInteractionEventMeta, D as getInteraction, E as eventFromInteraction, O as interactionMetaSchema, S as AgentInteractionEvent, T as GetInteractionOptions, _ as FromConfigResult, a as WithAgentUsageEvent, b as AgentInteractionChoice, c as setupAgent, d as AgentWorkflowConfig, f as AgentWorkflowInvokeConfig, g as FromConfigOptions, h as AgentWorkflowTransitionConfig, i as WithAgentEvents, l as AgentWorkflowActionConfig, m as AgentWorkflowStateConfig, n as AgentSchemaPack, o as createAgentSchemas, p as AgentWorkflowRequestConfig, r as AgentUsageEventPayload, s as getAgentSchemas, t as AgentDefaultMeta, u as AgentWorkflowActorConfig, v as SchemaCompiler, w as AgentInteractionMeta, x as AgentInteractionDescriptor, y as AgentInteraction } from "./setup-agent-BiF1N3td.cjs";
|
|
5
|
+
import { C as runAgent, D as AgentRequest, E as traceTransitions, O as AgentStepRequest, S as isAgentIdle, T as serializeTraceEvent, _ as AgentTransitionHandler, a as AgentRunErrorCause, b as createAgentRuntime, c as AgentRunOptions, d as AgentRuntime, f as AgentRuntimeOptions, g as AgentTraceEvent, h as AgentTimerScheduler, i as AgentMaxModelCallsExceededError, l as AgentRunResult, m as AgentTimerEvent, n as AgentEffects, o as AgentRunInit, p as AgentSnapshotDivergedError, r as AgentInputFrom, s as AgentRunMeta, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentRunStart, v as InspectedActorRef, w as runToQuiescence, x as inspectTransitions, y as JsonSerializableTraceEvent } from "./run-agent-B5QhabdY.cjs";
|
|
6
|
+
import { c as AgentLogEntry, d as AgentMachineVersionMismatchError, n as AgentEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-s73r1Hxf.cjs";
|
|
7
7
|
import { a as getMachineStructuralHash, c as getStatePath, d as toolMessage, f as userMessage, i as getJsonSchemaSync, l as isStandardSchema, n as assistantMessage, o as getMessageText, r as getJsonSchema, s as getStateMeta, u as systemMessage } from "./utils-ebVpCYoF.cjs";
|
|
8
8
|
import { AnyActorLogic, AnyMachineSnapshot, AnyStateMachine, ContextFrom, DoneActorEvent, EventFromLogic, InputFrom, OutputFrom, SnapshotFrom, StateValueFrom } from "xstate";
|
|
9
9
|
//#region src/type-helpers.d.ts
|
|
@@ -197,9 +197,10 @@ interface PolicyDeciderOptions<TPolicy extends AnyStateMachine> extends Omit<Age
|
|
|
197
197
|
* retry of one, needs its own thread: a thread that already has entries is
|
|
198
198
|
* resumed, so a shared one would return an earlier decision's choice. Default
|
|
199
199
|
* with a `store`: `policy:${info.callKey}:${hash}`, where `hash` is the
|
|
200
|
-
* SHA-256 of the policy input's canonical JSON. The call key is unique per
|
|
201
|
-
* same when a crashed run re-issues the call;
|
|
202
|
-
* something else at the same call site
|
|
200
|
+
* SHA-256 of the policy input's canonical JSON. The call key is unique per
|
|
201
|
+
* call and attempt and stays the same when a crashed run re-issues the call;
|
|
202
|
+
* the hash keeps a machine that asks something else at the same call site
|
|
203
|
+
* after a version bridge, which keeps the call key, off the earlier thread. Required
|
|
203
204
|
* with a `store` when the decider is called without a `callKey`.
|
|
204
205
|
*/
|
|
205
206
|
threadId?: (request: AgentExecutorDecisionRequest, info?: AgentRequestExecutorInfo) => string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { C as UserMessage, S as ToolResultPart, _ as StandardSchemaV1, a as AgentToolDescriptor, b as ToolCallPart, c as AllowedEvents, d as EventUnion, f as FilePart, h as InferOutput, i as AgentToolChoice, l as AssistantMessage, m as InferInput, n as AgentMessage, o as AgentToolExecute, p as ImagePart, r as AgentTool, s as AgentTools, u as ChosenEvent, v as SystemMessage, x as ToolMessage, y as TextPart } from "./types-Dp5_Ru4R.mjs";
|
|
2
|
-
import { $ as AgentTruncatedError, A as AgentDecisionExhaustedError, B as createDecisionLogic, C as getAgentOutputMode, D as parseProviderOutput, E as parseOutput, F as CreateDecisionRequestOptions, G as AgentInvalidEventPayloadError, H as renderDecisionAttempts, I as DecisionAttempt, J as AgentSchemas, K as AgentRequestOptions, L as DecisionLogic, M as AgentDecisionOption, N as AgentDecisionRequest, O as providerOutputSchema, P as AgentExecutorDecisionRequest, Q as AgentError, R as DecisionLogicConfig, S as createTextLogic, T as getCallUsage, U as resolveDecision, V as createDecisionRequest, W as AgentEventDescriptor, X as getAcceptedEvents, Y as EventFromSnapshot, Z as parseAgentEvent, _ as TextLogic, a as AgentModelRef, b as TextLogicExecutor, c as AgentRequestExecutorInfo, f as AgentTextRequest, g as ProviderStructuredOutput, j as AgentDecisionInput, k as AgentDecisionExecutor, l as AgentRequestExecutorResult, m as AgentUsage, n as AgentExecutorTextRequest, o as AgentOutputMode, p as AgentTextResult, q as AgentRequestSource, r as AgentFinishReason, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors, v as TextLogicConfig, w as getCallFinishReason, x as bindRequestExecutor, y as TextLogicExecuteArgs, z as ResolveDecisionOptions } from "./text-logic-
|
|
3
|
-
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-
|
|
4
|
-
import { C as AgentInteractionEventMeta, D as getInteraction, E as eventFromInteraction, O as interactionMetaSchema, S as AgentInteractionEvent, T as GetInteractionOptions, _ as FromConfigResult, a as WithAgentUsageEvent, b as AgentInteractionChoice, c as setupAgent, d as AgentWorkflowConfig, f as AgentWorkflowInvokeConfig, g as FromConfigOptions, h as AgentWorkflowTransitionConfig, i as WithAgentEvents, l as AgentWorkflowActionConfig, m as AgentWorkflowStateConfig, n as AgentSchemaPack, o as createAgentSchemas, p as AgentWorkflowRequestConfig, r as AgentUsageEventPayload, s as getAgentSchemas, t as AgentDefaultMeta, u as AgentWorkflowActorConfig, v as SchemaCompiler, w as AgentInteractionMeta, x as AgentInteractionDescriptor, y as AgentInteraction } from "./setup-agent-
|
|
5
|
-
import { C as runAgent, D as AgentRequest, E as traceTransitions, O as AgentStepRequest, S as isAgentIdle, T as serializeTraceEvent, _ as AgentTransitionHandler, a as AgentRunErrorCause, b as createAgentRuntime, c as AgentRunOptions, d as AgentRuntime, f as AgentRuntimeOptions, g as AgentTraceEvent, h as AgentTimerScheduler, i as AgentMaxModelCallsExceededError, l as AgentRunResult, m as AgentTimerEvent, n as AgentEffects, o as AgentRunInit, p as AgentSnapshotDivergedError, r as AgentInputFrom, s as AgentRunMeta, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentRunStart, v as InspectedActorRef, w as runToQuiescence, x as inspectTransitions, y as JsonSerializableTraceEvent } from "./run-agent-
|
|
6
|
-
import { c as AgentLogEntry, d as AgentMachineVersionMismatchError, n as AgentEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-
|
|
2
|
+
import { $ as AgentTruncatedError, A as AgentDecisionExhaustedError, B as createDecisionLogic, C as getAgentOutputMode, D as parseProviderOutput, E as parseOutput, F as CreateDecisionRequestOptions, G as AgentInvalidEventPayloadError, H as renderDecisionAttempts, I as DecisionAttempt, J as AgentSchemas, K as AgentRequestOptions, L as DecisionLogic, M as AgentDecisionOption, N as AgentDecisionRequest, O as providerOutputSchema, P as AgentExecutorDecisionRequest, Q as AgentError, R as DecisionLogicConfig, S as createTextLogic, T as getCallUsage, U as resolveDecision, V as createDecisionRequest, W as AgentEventDescriptor, X as getAcceptedEvents, Y as EventFromSnapshot, Z as parseAgentEvent, _ as TextLogic, a as AgentModelRef, b as TextLogicExecutor, c as AgentRequestExecutorInfo, f as AgentTextRequest, g as ProviderStructuredOutput, j as AgentDecisionInput, k as AgentDecisionExecutor, l as AgentRequestExecutorResult, m as AgentUsage, n as AgentExecutorTextRequest, o as AgentOutputMode, p as AgentTextResult, q as AgentRequestSource, r as AgentFinishReason, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors, v as TextLogicConfig, w as getCallFinishReason, x as bindRequestExecutor, y as TextLogicExecuteArgs, z as ResolveDecisionOptions } from "./text-logic-DuK9HIFM.mjs";
|
|
3
|
+
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-D7JKAxLc.mjs";
|
|
4
|
+
import { C as AgentInteractionEventMeta, D as getInteraction, E as eventFromInteraction, O as interactionMetaSchema, S as AgentInteractionEvent, T as GetInteractionOptions, _ as FromConfigResult, a as WithAgentUsageEvent, b as AgentInteractionChoice, c as setupAgent, d as AgentWorkflowConfig, f as AgentWorkflowInvokeConfig, g as FromConfigOptions, h as AgentWorkflowTransitionConfig, i as WithAgentEvents, l as AgentWorkflowActionConfig, m as AgentWorkflowStateConfig, n as AgentSchemaPack, o as createAgentSchemas, p as AgentWorkflowRequestConfig, r as AgentUsageEventPayload, s as getAgentSchemas, t as AgentDefaultMeta, u as AgentWorkflowActorConfig, v as SchemaCompiler, w as AgentInteractionMeta, x as AgentInteractionDescriptor, y as AgentInteraction } from "./setup-agent-J9f_Wu5T.mjs";
|
|
5
|
+
import { C as runAgent, D as AgentRequest, E as traceTransitions, O as AgentStepRequest, S as isAgentIdle, T as serializeTraceEvent, _ as AgentTransitionHandler, a as AgentRunErrorCause, b as createAgentRuntime, c as AgentRunOptions, d as AgentRuntime, f as AgentRuntimeOptions, g as AgentTraceEvent, h as AgentTimerScheduler, i as AgentMaxModelCallsExceededError, l as AgentRunResult, m as AgentTimerEvent, n as AgentEffects, o as AgentRunInit, p as AgentSnapshotDivergedError, r as AgentInputFrom, s as AgentRunMeta, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentRunStart, v as InspectedActorRef, w as runToQuiescence, x as inspectTransitions, y as JsonSerializableTraceEvent } from "./run-agent-Atu-wEk7.mjs";
|
|
6
|
+
import { c as AgentLogEntry, d as AgentMachineVersionMismatchError, n as AgentEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-C2NjVlWU.mjs";
|
|
7
7
|
import { a as getMachineStructuralHash, c as getStatePath, d as toolMessage, f as userMessage, i as getJsonSchemaSync, l as isStandardSchema, n as assistantMessage, o as getMessageText, r as getJsonSchema, s as getStateMeta, u as systemMessage } from "./utils-BnXdWih3.mjs";
|
|
8
8
|
import { AnyActorLogic, AnyMachineSnapshot, AnyStateMachine, ContextFrom, DoneActorEvent, EventFromLogic, InputFrom, OutputFrom, SnapshotFrom, StateValueFrom } from "xstate";
|
|
9
9
|
//#region src/type-helpers.d.ts
|
|
@@ -197,9 +197,10 @@ interface PolicyDeciderOptions<TPolicy extends AnyStateMachine> extends Omit<Age
|
|
|
197
197
|
* retry of one, needs its own thread: a thread that already has entries is
|
|
198
198
|
* resumed, so a shared one would return an earlier decision's choice. Default
|
|
199
199
|
* with a `store`: `policy:${info.callKey}:${hash}`, where `hash` is the
|
|
200
|
-
* SHA-256 of the policy input's canonical JSON. The call key is unique per
|
|
201
|
-
* same when a crashed run re-issues the call;
|
|
202
|
-
* something else at the same call site
|
|
200
|
+
* SHA-256 of the policy input's canonical JSON. The call key is unique per
|
|
201
|
+
* call and attempt and stays the same when a crashed run re-issues the call;
|
|
202
|
+
* the hash keeps a machine that asks something else at the same call site
|
|
203
|
+
* after a version bridge, which keeps the call key, off the earlier thread. Required
|
|
203
204
|
* with a `store` when the decider is called without a `callKey`.
|
|
204
205
|
*/
|
|
205
206
|
threadId?: (request: AgentExecutorDecisionRequest, info?: AgentRequestExecutorInfo) => string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as getStateMeta, A as createTextLogic, C as AGENT_USAGE_EVENT_TYPE, H as getAgentExecutionOptions, I as parseOutput, L as parseProviderOutput, M as getCallFinishReason, N as getCallUsage, O as bindRequestExecutor, P as isTextLogic, Q as getMessageText, R as providerOutputSchema, V as executorBoundLogics, X as getJsonSchemaSync, Y as getJsonSchema, Z as getMachineStructuralHash, at as userMessage, dt as AgentTruncatedError, et as getStatePath, i as AgentMachineVersionMismatchError, it as toolMessage, j as getAgentOutputMode, l as assertJsonSerializable, lt as isRecord, q as assistantMessage, rt as systemMessage, tt as isStandardSchema, u as canonicalEventJson, ut as AgentError } from "./event-log-
|
|
2
|
-
import { a as createDecisionRequest, c as renderDecisionAttempts, d as getAcceptedEvents, f as getHumanEventTypes, i as createDecisionLogic, l as resolveDecision, m as parseAgentEvent, p as isEventPattern, s as isDecisionLogic, t as AgentDecisionExhaustedError, u as AgentInvalidEventPayloadError } from "./decision-
|
|
3
|
-
import { n as getAgentSchemas, r as setupAgent, t as createAgentSchemas } from "./setup-agent-
|
|
4
|
-
import { t as AgentEventLogConflictError } from "./event-log-store-
|
|
5
|
-
import { a as bindDecisionForProvide, c as getConfiguredInvokeSrcs, d as isStateMachineLogic, f as runAgent, h as traceTransitions, i as bindChildMachineForProvide, l as inspectTransitions, m as serializeTraceEvent, n as AgentMaxModelCallsExceededError, o as bindTextForProvide, p as runToQuiescence, r as AgentSnapshotDivergedError, s as createAgentRuntime, t as AGENT_TRACE_SCHEMA_VERSION, u as isAgentIdle } from "./run-agent-
|
|
1
|
+
import { $ as getStateMeta, A as createTextLogic, C as AGENT_USAGE_EVENT_TYPE, H as getAgentExecutionOptions, I as parseOutput, L as parseProviderOutput, M as getCallFinishReason, N as getCallUsage, O as bindRequestExecutor, P as isTextLogic, Q as getMessageText, R as providerOutputSchema, V as executorBoundLogics, X as getJsonSchemaSync, Y as getJsonSchema, Z as getMachineStructuralHash, at as userMessage, dt as AgentTruncatedError, et as getStatePath, i as AgentMachineVersionMismatchError, it as toolMessage, j as getAgentOutputMode, l as assertJsonSerializable, lt as isRecord, q as assistantMessage, rt as systemMessage, tt as isStandardSchema, u as canonicalEventJson, ut as AgentError } from "./event-log-DAqsalT1.mjs";
|
|
2
|
+
import { a as createDecisionRequest, c as renderDecisionAttempts, d as getAcceptedEvents, f as getHumanEventTypes, i as createDecisionLogic, l as resolveDecision, m as parseAgentEvent, p as isEventPattern, s as isDecisionLogic, t as AgentDecisionExhaustedError, u as AgentInvalidEventPayloadError } from "./decision-CV7WiV5C.mjs";
|
|
3
|
+
import { n as getAgentSchemas, r as setupAgent, t as createAgentSchemas } from "./setup-agent-CmhB-U5P.mjs";
|
|
4
|
+
import { t as AgentEventLogConflictError } from "./event-log-store-BGehvVTb.mjs";
|
|
5
|
+
import { a as bindDecisionForProvide, c as getConfiguredInvokeSrcs, d as isStateMachineLogic, f as runAgent, h as traceTransitions, i as bindChildMachineForProvide, l as inspectTransitions, m as serializeTraceEvent, n as AgentMaxModelCallsExceededError, o as bindTextForProvide, p as runToQuiescence, r as AgentSnapshotDivergedError, s as createAgentRuntime, t as AGENT_TRACE_SCHEMA_VERSION, u as isAgentIdle } from "./run-agent-2UnSUhDb.mjs";
|
|
6
6
|
import { getNextTransitions, machineToJSON, transition } from "xstate";
|
|
7
7
|
//#region src/messages.ts
|
|
8
8
|
const KNOWN_PART_TYPES = /* @__PURE__ */ new Set([
|
package/dist/log.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_event_log = require("./event-log-
|
|
3
|
-
const require_event_log_store = require("./event-log-store-
|
|
2
|
+
const require_event_log = require("./event-log-CKWeC7H-.cjs");
|
|
3
|
+
const require_event_log_store = require("./event-log-store-DKyE7JKr.cjs");
|
|
4
4
|
//#region src/event-log-store-conformance.ts
|
|
5
5
|
/**
|
|
6
6
|
* The runner-agnostic conformance suite for {@link AgentEventLogStore}
|
|
@@ -30,8 +30,11 @@ function entry(index, type, metadata) {
|
|
|
30
30
|
...metadata !== void 0 ? { metadata } : {}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
function initFixture(executionId = "exec-src") {
|
|
34
|
+
return entry(0, require_event_log.AGENT_INIT_EVENT_TYPE, { executionId });
|
|
35
|
+
}
|
|
33
36
|
function entriesFrom(start, count) {
|
|
34
|
-
return Array.from({ length: count }, (_unused, i) => entry(start + i, `e${start + i}`));
|
|
37
|
+
return Array.from({ length: count }, (_unused, i) => start + i === 0 ? initFixture() : entry(start + i, `e${start + i}`));
|
|
35
38
|
}
|
|
36
39
|
function assertJsonEqual(actual, expected, message) {
|
|
37
40
|
const a = JSON.stringify(actual);
|
|
@@ -281,10 +284,42 @@ const cases = [
|
|
|
281
284
|
expectedIndex: 1,
|
|
282
285
|
entries: [entry(1, "branch")]
|
|
283
286
|
});
|
|
284
|
-
assertJsonEqual((await store.read("fork-1")).map((e) => e.event.type), [
|
|
287
|
+
assertJsonEqual((await store.read("fork-1")).map((e) => e.event.type), [require_event_log.AGENT_INIT_EVENT_TYPE, "branch"], "a forked thread must append independently from its copied length");
|
|
285
288
|
if (await store.length("src") !== 3) fail("appending to a fork must not touch the source thread");
|
|
286
289
|
}
|
|
287
290
|
},
|
|
291
|
+
{
|
|
292
|
+
name: "a fork is its own lineage: a fresh executionId, and forkedFrom naming the parent",
|
|
293
|
+
async run(create) {
|
|
294
|
+
const store = await create();
|
|
295
|
+
const source = entriesFrom(0, 3);
|
|
296
|
+
await store.append({
|
|
297
|
+
threadId: "src",
|
|
298
|
+
expectedIndex: 0,
|
|
299
|
+
entries: source
|
|
300
|
+
});
|
|
301
|
+
await store.fork({
|
|
302
|
+
threadId: "src",
|
|
303
|
+
newThreadId: "fork-a",
|
|
304
|
+
upToIndex: 2
|
|
305
|
+
});
|
|
306
|
+
await store.fork({
|
|
307
|
+
threadId: "src",
|
|
308
|
+
newThreadId: "fork-b",
|
|
309
|
+
upToIndex: 2
|
|
310
|
+
});
|
|
311
|
+
const [a, b] = [await store.read("fork-a"), await store.read("fork-b")];
|
|
312
|
+
const ids = [require_event_log.getLogExecutionId(a), require_event_log.getLogExecutionId(b)];
|
|
313
|
+
if (typeof ids[0] !== "string" || typeof ids[1] !== "string") fail("a fork's init entry must carry a string metadata.executionId");
|
|
314
|
+
if (ids.includes("exec-src") || ids[0] === ids[1]) fail("every fork must mint its own executionId, not reuse the parent's or a sibling's");
|
|
315
|
+
assertJsonEqual(a[0].metadata?.forkedFrom, {
|
|
316
|
+
executionId: "exec-src",
|
|
317
|
+
logIndex: 2
|
|
318
|
+
}, "a fork's init entry must record forkedFrom: { executionId, logIndex }");
|
|
319
|
+
assertJsonEqual(a.slice(1), source.slice(1, 2), "a fork must copy every entry after the init entry unchanged");
|
|
320
|
+
assertJsonEqual(await store.read("src"), source, "forking must not touch the source thread");
|
|
321
|
+
}
|
|
322
|
+
},
|
|
288
323
|
{
|
|
289
324
|
name: "fork rejects a non-empty target, an unknown source, and an out-of-range cutoff (0 included)",
|
|
290
325
|
async run(create) {
|
|
@@ -357,7 +392,7 @@ const cases = [
|
|
|
357
392
|
]) await store.append({
|
|
358
393
|
threadId,
|
|
359
394
|
expectedIndex: 0,
|
|
360
|
-
entries: [
|
|
395
|
+
entries: [initFixture()]
|
|
361
396
|
});
|
|
362
397
|
await store.fork({
|
|
363
398
|
threadId: "user:a",
|
package/dist/log.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as rebindActorSession, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as replay, N as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as recordLog, k as initEntry, 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 ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-
|
|
1
|
+
import { A as rebindActorSession, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as replay, N as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as recordLog, k as initEntry, 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 ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-s73r1Hxf.cjs";
|
|
2
2
|
//#region src/event-log-store-conformance.d.ts
|
|
3
3
|
/** Produces a fresh, empty store for one case. */
|
|
4
4
|
type CreateStore = () => Promise<AgentEventLogStore> | AgentEventLogStore;
|
package/dist/log.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as rebindActorSession, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as replay, N as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as recordLog, k as initEntry, 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 ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-
|
|
1
|
+
import { A as rebindActorSession, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as replay, N as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as recordLog, k as initEntry, 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 ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-C2NjVlWU.mjs";
|
|
2
2
|
//#region src/event-log-store-conformance.d.ts
|
|
3
3
|
/** Produces a fresh, empty store for one case. */
|
|
4
4
|
type CreateStore = () => Promise<AgentEventLogStore> | AgentEventLogStore;
|
package/dist/log.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as validateReplayEntries, _ as getUsageFromEvents, a as AgentReplayDivergenceError, b as recordLog, c as assertAgentLogEntry, d as createReplayEntry, g as getSnapshotStateHash, h as getLogExecutionId, i as AgentMachineVersionMismatchError, l as assertJsonSerializable, m as getDecisionAttempts, n as AGENT_INIT_EVENT_TYPE, o as NonSerializableAgentEventError, p as forkEventLog, r as AgentEventLogError, s as agentCallOccurrence, t as AGENT_EVENT_SCHEMA_VERSION, v as initEntry, x as replay, y as rebindActorSession } from "./event-log-
|
|
2
|
-
import { n as createInMemoryEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-
|
|
1
|
+
import { S as validateReplayEntries, _ as getUsageFromEvents, a as AgentReplayDivergenceError, b as recordLog, c as assertAgentLogEntry, d as createReplayEntry, g as getSnapshotStateHash, h as getLogExecutionId, i as AgentMachineVersionMismatchError, l as assertJsonSerializable, m as getDecisionAttempts, n as AGENT_INIT_EVENT_TYPE, o as NonSerializableAgentEventError, p as forkEventLog, r as AgentEventLogError, s as agentCallOccurrence, t as AGENT_EVENT_SCHEMA_VERSION, v as initEntry, x as replay, y as rebindActorSession } from "./event-log-DAqsalT1.mjs";
|
|
2
|
+
import { n as createInMemoryEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-BGehvVTb.mjs";
|
|
3
3
|
//#region src/event-log-store-conformance.ts
|
|
4
4
|
/**
|
|
5
5
|
* The runner-agnostic conformance suite for {@link AgentEventLogStore}
|
|
@@ -29,8 +29,11 @@ function entry(index, type, metadata) {
|
|
|
29
29
|
...metadata !== void 0 ? { metadata } : {}
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
function initFixture(executionId = "exec-src") {
|
|
33
|
+
return entry(0, AGENT_INIT_EVENT_TYPE, { executionId });
|
|
34
|
+
}
|
|
32
35
|
function entriesFrom(start, count) {
|
|
33
|
-
return Array.from({ length: count }, (_unused, i) => entry(start + i, `e${start + i}`));
|
|
36
|
+
return Array.from({ length: count }, (_unused, i) => start + i === 0 ? initFixture() : entry(start + i, `e${start + i}`));
|
|
34
37
|
}
|
|
35
38
|
function assertJsonEqual(actual, expected, message) {
|
|
36
39
|
const a = JSON.stringify(actual);
|
|
@@ -280,10 +283,42 @@ const cases = [
|
|
|
280
283
|
expectedIndex: 1,
|
|
281
284
|
entries: [entry(1, "branch")]
|
|
282
285
|
});
|
|
283
|
-
assertJsonEqual((await store.read("fork-1")).map((e) => e.event.type), [
|
|
286
|
+
assertJsonEqual((await store.read("fork-1")).map((e) => e.event.type), [AGENT_INIT_EVENT_TYPE, "branch"], "a forked thread must append independently from its copied length");
|
|
284
287
|
if (await store.length("src") !== 3) fail("appending to a fork must not touch the source thread");
|
|
285
288
|
}
|
|
286
289
|
},
|
|
290
|
+
{
|
|
291
|
+
name: "a fork is its own lineage: a fresh executionId, and forkedFrom naming the parent",
|
|
292
|
+
async run(create) {
|
|
293
|
+
const store = await create();
|
|
294
|
+
const source = entriesFrom(0, 3);
|
|
295
|
+
await store.append({
|
|
296
|
+
threadId: "src",
|
|
297
|
+
expectedIndex: 0,
|
|
298
|
+
entries: source
|
|
299
|
+
});
|
|
300
|
+
await store.fork({
|
|
301
|
+
threadId: "src",
|
|
302
|
+
newThreadId: "fork-a",
|
|
303
|
+
upToIndex: 2
|
|
304
|
+
});
|
|
305
|
+
await store.fork({
|
|
306
|
+
threadId: "src",
|
|
307
|
+
newThreadId: "fork-b",
|
|
308
|
+
upToIndex: 2
|
|
309
|
+
});
|
|
310
|
+
const [a, b] = [await store.read("fork-a"), await store.read("fork-b")];
|
|
311
|
+
const ids = [getLogExecutionId(a), getLogExecutionId(b)];
|
|
312
|
+
if (typeof ids[0] !== "string" || typeof ids[1] !== "string") fail("a fork's init entry must carry a string metadata.executionId");
|
|
313
|
+
if (ids.includes("exec-src") || ids[0] === ids[1]) fail("every fork must mint its own executionId, not reuse the parent's or a sibling's");
|
|
314
|
+
assertJsonEqual(a[0].metadata?.forkedFrom, {
|
|
315
|
+
executionId: "exec-src",
|
|
316
|
+
logIndex: 2
|
|
317
|
+
}, "a fork's init entry must record forkedFrom: { executionId, logIndex }");
|
|
318
|
+
assertJsonEqual(a.slice(1), source.slice(1, 2), "a fork must copy every entry after the init entry unchanged");
|
|
319
|
+
assertJsonEqual(await store.read("src"), source, "forking must not touch the source thread");
|
|
320
|
+
}
|
|
321
|
+
},
|
|
287
322
|
{
|
|
288
323
|
name: "fork rejects a non-empty target, an unknown source, and an out-of-range cutoff (0 included)",
|
|
289
324
|
async run(create) {
|
|
@@ -356,7 +391,7 @@ const cases = [
|
|
|
356
391
|
]) await store.append({
|
|
357
392
|
threadId,
|
|
358
393
|
expectedIndex: 0,
|
|
359
|
-
entries: [
|
|
394
|
+
entries: [initFixture()]
|
|
360
395
|
});
|
|
361
396
|
await store.fork({
|
|
362
397
|
threadId: "user:a",
|
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-CwUJyqKB.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";
|
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-CmhB-U5P.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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_event_log = require("./event-log-
|
|
1
|
+
const require_event_log = require("./event-log-CKWeC7H-.cjs");
|
|
2
2
|
//#region src/internal/model-source.ts
|
|
3
3
|
function hasEntries(value) {
|
|
4
4
|
return require_event_log.isRecord(value) && Object.keys(value).length > 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as getAgentExecutionOptions, lt as isRecord } from "./event-log-
|
|
1
|
+
import { H as getAgentExecutionOptions, lt as isRecord } from "./event-log-DAqsalT1.mjs";
|
|
2
2
|
//#region src/internal/model-source.ts
|
|
3
3
|
function hasEntries(value) {
|
|
4
4
|
return isRecord(value) && Object.keys(value).length > 0;
|