@statelyai/agent 2.0.0-alpha.29 → 2.0.0-alpha.30
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 +5 -5
- package/dist/ai-sdk.d.mts +5 -5
- package/dist/ai-sdk.mjs +4 -4
- package/dist/{decision-Bl_rKQnU.mjs → decision-BHkvuImD.mjs} +2 -2
- package/dist/{decision-oevZnkBe.cjs → decision-CIb7ddIv.cjs} +2 -2
- package/dist/{event-log-Dtb16p1p.cjs → event-log-BZRfBRd7.cjs} +1 -1
- package/dist/{event-log-GPZO9p7_.mjs → event-log-DJCMHek_.mjs} +1 -1
- package/dist/{event-log-store-CN9ygggF.d.cts → event-log-store-CIIJohjj.d.mts} +1 -1
- package/dist/{event-log-store-DS836wch.d.mts → event-log-store-CLAC9q2Y.d.cts} +1 -1
- package/dist/{event-log-store-bCdskPNS.cjs → event-log-store-DZR4IIWe.cjs} +1 -1
- package/dist/{event-log-store-yalq8C77.mjs → event-log-store-DsP6GCRh.mjs} +1 -1
- package/dist/index.cjs +12 -7
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +12 -7
- package/dist/log.cjs +2 -2
- package/dist/log.d.cts +1 -1
- package/dist/log.d.mts +1 -1
- package/dist/log.mjs +2 -2
- package/dist/machines.cjs +1 -1
- package/dist/machines.mjs +1 -1
- package/dist/{model-source-DjJPjGSP.cjs → model-source-BCKg4qJ1.cjs} +2 -2
- package/dist/{model-source-C7FFP2Sj.mjs → model-source-BaHwJ1wK.mjs} +2 -2
- package/dist/openai.cjs +3 -3
- package/dist/openai.d.cts +2 -2
- package/dist/openai.d.mts +2 -2
- package/dist/openai.mjs +3 -3
- package/dist/otel.d.cts +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/{run-agent-CuQT1xSS.mjs → run-agent-BpHqkaZw.mjs} +14 -5
- package/dist/{run-agent-CxSyZmIE.d.mts → run-agent-CAVt5R-r.d.mts} +11 -3
- package/dist/{run-agent-C9ubX8Tx.d.cts → run-agent-CTlMc3Jb.d.cts} +11 -3
- package/dist/{run-agent-cToZ3K42.cjs → run-agent-ctLCvNgL.cjs} +14 -5
- package/dist/{setup-agent-DniLvDu7.mjs → setup-agent-7rV_cujV.mjs} +2 -2
- package/dist/{setup-agent-tsc3vm5I.d.mts → setup-agent-CGELn1qZ.d.mts} +2 -2
- package/dist/{setup-agent-DlbgwsIJ.d.cts → setup-agent-CLPCkXsu.d.cts} +2 -2
- package/dist/{setup-agent-DTF3NQg3.cjs → setup-agent-DoUk7EdC.cjs} +2 -2
- package/dist/tanstack-ai.cjs +3 -3
- package/dist/tanstack-ai.d.cts +2 -2
- package/dist/tanstack-ai.d.mts +2 -2
- package/dist/tanstack-ai.mjs +3 -3
- package/dist/testing.cjs +110 -4
- package/dist/testing.d.cts +85 -4
- package/dist/testing.d.mts +85 -4
- package/dist/testing.mjs +110 -5
- package/dist/{text-logic-BDbGjYMh.d.mts → text-logic-BRYOPWvY.d.mts} +2 -2
- package/dist/{text-logic-9fv1i9aK.d.cts → text-logic-DmciuVUQ.d.cts} +2 -2
- package/dist/{usage-D8UphgEA.d.mts → usage-BkM3z02Y.d.mts} +1 -1
- package/dist/{usage-R1NTmLxY.d.cts → usage-Cm_ovz9V.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-B5qGC5WN.mjs → verify-COFWyprJ.mjs} +2 -2
- package/dist/{verify-Cqghu4gz.cjs → verify-CVlsTZ-V.cjs} +2 -2
- package/dist/{verify-CBuYIpsa.d.mts → verify-Cn86rT8l.d.mts} +1 -1
- package/dist/{verify-DYH_2VzU.d.cts → verify-Dzwd4Mvk.d.cts} +1 -1
- package/package.json +1 -1
- package/readme.md +3 -3
- package/skills/add-evals/SKILL.md +129 -0
- package/skills/add-traces/SKILL.md +135 -0
- package/skills/generate-machine/SKILL.md +5 -5
- package/skills/graph-engineering/SKILL.md +33 -0
- package/skills/improve-machine/SKILL.md +70 -19
- package/skills/improve-machine/reference.md +12 -7
- package/skills/loop-to-machine/SKILL.md +183 -0
- package/skills/loop-to-machine/policy.md +158 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_event_log = require("./event-log-
|
|
2
|
-
const require_decision = require("./decision-
|
|
3
|
-
const require_event_log_store = require("./event-log-store-
|
|
1
|
+
const require_event_log = require("./event-log-BZRfBRd7.cjs");
|
|
2
|
+
const require_decision = require("./decision-CIb7ddIv.cjs");
|
|
3
|
+
const require_event_log_store = require("./event-log-store-DZR4IIWe.cjs");
|
|
4
4
|
let xstate = require("xstate");
|
|
5
5
|
let xstate_durable = require("xstate/durable");
|
|
6
6
|
//#region src/run-agent.ts
|
|
@@ -918,6 +918,8 @@ function createAgentRuntime(machine, options = {}) {
|
|
|
918
918
|
let traceSeq = 0;
|
|
919
919
|
const machineId = machine.config.id ?? machine.id ?? "(machine)";
|
|
920
920
|
const machineVersion = require_event_log.resolveMachineVersion(machine);
|
|
921
|
+
if (options.metadata !== void 0) require_event_log.assertJsonSerializable(options.metadata, "metadata");
|
|
922
|
+
const initMetadata = options.metadata === void 0 ? void 0 : structuredClone(options.metadata);
|
|
921
923
|
const onTrace = createTraceDispatch({
|
|
922
924
|
onTrace: (payload) => {
|
|
923
925
|
options.onTrace?.({
|
|
@@ -1370,16 +1372,23 @@ function createAgentRuntime(machine, options = {}) {
|
|
|
1370
1372
|
logIndex: resumeEvents.length
|
|
1371
1373
|
};
|
|
1372
1374
|
seedInitEntry = () => appendInitEntry(snapshotInitCandidates(), {
|
|
1375
|
+
...initMetadata,
|
|
1373
1376
|
...logExecutionId !== void 0 ? { executionId: logExecutionId } : {},
|
|
1374
1377
|
migratedFrom
|
|
1375
1378
|
});
|
|
1376
1379
|
}
|
|
1377
1380
|
} else if (init.snapshot !== void 0) {
|
|
1378
1381
|
logExecutionId = crypto.randomUUID();
|
|
1379
|
-
seedInitEntry = () => appendInitEntry(snapshotInitCandidates(), {
|
|
1382
|
+
seedInitEntry = () => appendInitEntry(snapshotInitCandidates(), {
|
|
1383
|
+
...initMetadata,
|
|
1384
|
+
executionId: logExecutionId
|
|
1385
|
+
});
|
|
1380
1386
|
} else {
|
|
1381
1387
|
logExecutionId = crypto.randomUUID();
|
|
1382
|
-
seedInitEntry = () => appendInitEntry([resolvedInput !== void 0 ? { input: resolvedInput } : {}], {
|
|
1388
|
+
seedInitEntry = () => appendInitEntry([resolvedInput !== void 0 ? { input: resolvedInput } : {}], {
|
|
1389
|
+
...initMetadata,
|
|
1390
|
+
executionId: logExecutionId
|
|
1391
|
+
});
|
|
1383
1392
|
}
|
|
1384
1393
|
const resumedHistory = [...logEntries];
|
|
1385
1394
|
const siteCallCounts = /* @__PURE__ */ new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as createTextLogic, C as AGENT_USAGE_EVENT_TYPE, G as missingActor, H as getAgentExecutionOptions, K as setAgentExecutionOptions, T as DECIDE_ACTOR, k as builtinTextActors, ot as validateSchemaSync } from "./event-log-
|
|
2
|
-
import { r as createDecideActor } from "./decision-
|
|
1
|
+
import { A as createTextLogic, C as AGENT_USAGE_EVENT_TYPE, G as missingActor, H as getAgentExecutionOptions, K as setAgentExecutionOptions, T as DECIDE_ACTOR, k as builtinTextActors, ot as validateSchemaSync } from "./event-log-DJCMHek_.mjs";
|
|
2
|
+
import { r as createDecideActor } from "./decision-BHkvuImD.mjs";
|
|
3
3
|
import { machineFromJSON, setup } from "xstate";
|
|
4
4
|
//#region src/workflow-config.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as StandardSchemaV1, d as EventUnion, g as NormalizedEventSchemas, h as InferOutput, i as AgentToolChoice, m as InferInput, s as AgentTools, t as AgentEventSchemaInputMap, w as WithAgentInputSchema } from "./types-Dp5_Ru4R.mjs";
|
|
2
|
-
import { J as AgentSchemas, Y as EventFromSnapshot, _ as TextLogic, a as AgentModelRef, d as AgentRequestMode, h as BuiltinAgentActors, i as AgentModelMap, v as TextLogicConfig } from "./text-logic-
|
|
3
|
-
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-
|
|
2
|
+
import { J as AgentSchemas, Y as EventFromSnapshot, _ as TextLogic, a as AgentModelRef, d as AgentRequestMode, h as BuiltinAgentActors, i as AgentModelMap, v as TextLogicConfig } from "./text-logic-BRYOPWvY.mjs";
|
|
3
|
+
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-BkM3z02Y.mjs";
|
|
4
4
|
import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventObject, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema } from "xstate";
|
|
5
5
|
//#region src/interaction.d.ts
|
|
6
6
|
interface AgentInteractionEvent<TType extends string = string> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as StandardSchemaV1, d as EventUnion, g as NormalizedEventSchemas, h as InferOutput, i as AgentToolChoice, m as InferInput, s as AgentTools, t as AgentEventSchemaInputMap, w as WithAgentInputSchema } from "./types-Dp5_Ru4R.cjs";
|
|
2
|
-
import { J as AgentSchemas, Y as EventFromSnapshot, _ as TextLogic, a as AgentModelRef, d as AgentRequestMode, h as BuiltinAgentActors, i as AgentModelMap, v as TextLogicConfig } from "./text-logic-
|
|
3
|
-
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-
|
|
2
|
+
import { J as AgentSchemas, Y as EventFromSnapshot, _ as TextLogic, a as AgentModelRef, d as AgentRequestMode, h as BuiltinAgentActors, i as AgentModelMap, v as TextLogicConfig } from "./text-logic-DmciuVUQ.cjs";
|
|
3
|
+
import { n as AgentUsageEvent, t as AGENT_USAGE_EVENT_TYPE } from "./usage-Cm_ovz9V.cjs";
|
|
4
4
|
import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventObject, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema } from "xstate";
|
|
5
5
|
//#region src/interaction.d.ts
|
|
6
6
|
interface AgentInteractionEvent<TType extends string = string> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_event_log = require("./event-log-
|
|
2
|
-
const require_decision = require("./decision-
|
|
1
|
+
const require_event_log = require("./event-log-BZRfBRd7.cjs");
|
|
2
|
+
const require_decision = require("./decision-CIb7ddIv.cjs");
|
|
3
3
|
let xstate = require("xstate");
|
|
4
4
|
//#region src/workflow-config.ts
|
|
5
5
|
/**
|
package/dist/tanstack-ai.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-BZRfBRd7.cjs");
|
|
3
|
+
const require_decision = require("./decision-CIb7ddIv.cjs");
|
|
4
|
+
const require_model_source = require("./model-source-BCKg4qJ1.cjs");
|
|
5
5
|
let _tanstack_ai = require("@tanstack/ai");
|
|
6
6
|
//#region src/tanstack-ai/index.ts
|
|
7
7
|
/**
|
package/dist/tanstack-ai.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as AgentToolChoice, n as AgentMessage, s as AgentTools, u as ChosenEvent } from "./types-Dp5_Ru4R.cjs";
|
|
2
|
-
import { N as AgentDecisionRequest, W as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-
|
|
2
|
+
import { N as AgentDecisionRequest, W as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-DmciuVUQ.cjs";
|
|
3
3
|
import { AnyStateMachine } from "xstate";
|
|
4
4
|
import { AnyTextAdapter, ModelMessage, StreamChunk, TokenUsage, Tool } from "@tanstack/ai";
|
|
5
5
|
import { TextActivityOptions } from "@tanstack/ai/adapters";
|
|
@@ -195,7 +195,7 @@ export declare function toTextAdapter(entry: TanStackAiModelEntry): AnyTextAdapt
|
|
|
195
195
|
* ```ts
|
|
196
196
|
* import { openaiText } from '@tanstack/ai-openai';
|
|
197
197
|
*
|
|
198
|
-
* const executors = createTanStackAiExecutors({ models: { quick: openaiText('gpt-
|
|
198
|
+
* const executors = createTanStackAiExecutors({ models: { quick: openaiText('gpt-6-luna') } });
|
|
199
199
|
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), { input });
|
|
200
200
|
* ```
|
|
201
201
|
*/
|
package/dist/tanstack-ai.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as AgentToolChoice, n as AgentMessage, s as AgentTools, u as ChosenEvent } from "./types-Dp5_Ru4R.mjs";
|
|
2
|
-
import { N as AgentDecisionRequest, W as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-
|
|
2
|
+
import { N as AgentDecisionRequest, W as AgentEventDescriptor, c as AgentRequestExecutorInfo, f as AgentTextRequest, r as AgentFinishReason, t as AgentCallUsage } from "./text-logic-BRYOPWvY.mjs";
|
|
3
3
|
import { AnyStateMachine } from "xstate";
|
|
4
4
|
import { AnyTextAdapter, ModelMessage, StreamChunk, TokenUsage, Tool } from "@tanstack/ai";
|
|
5
5
|
import { TextActivityOptions } from "@tanstack/ai/adapters";
|
|
@@ -195,7 +195,7 @@ export declare function toTextAdapter(entry: TanStackAiModelEntry): AnyTextAdapt
|
|
|
195
195
|
* ```ts
|
|
196
196
|
* import { openaiText } from '@tanstack/ai-openai';
|
|
197
197
|
*
|
|
198
|
-
* const executors = createTanStackAiExecutors({ models: { quick: openaiText('gpt-
|
|
198
|
+
* const executors = createTanStackAiExecutors({ models: { quick: openaiText('gpt-6-luna') } });
|
|
199
199
|
* const result = await runToQuiescence(createAgentRuntime(machine, { executors }), { input });
|
|
200
200
|
* ```
|
|
201
201
|
*/
|
package/dist/tanstack-ai.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as parseProviderOutput, R as providerOutputSchema, X as getJsonSchemaSync, Y as getJsonSchema, ct as AgentTruncatedError, j as getAgentOutputMode, tt as isStandardSchema, w as AGENT_USAGE_TOKEN_FIELDS } from "./event-log-
|
|
2
|
-
import { c as renderDecisionAttempts } from "./decision-
|
|
3
|
-
import { t as resolveModelSource } from "./model-source-
|
|
1
|
+
import { L as parseProviderOutput, R as providerOutputSchema, X as getJsonSchemaSync, Y as getJsonSchema, ct as AgentTruncatedError, j as getAgentOutputMode, tt as isStandardSchema, w as AGENT_USAGE_TOKEN_FIELDS } from "./event-log-DJCMHek_.mjs";
|
|
2
|
+
import { c as renderDecisionAttempts } from "./decision-BHkvuImD.mjs";
|
|
3
|
+
import { t as resolveModelSource } from "./model-source-BaHwJ1wK.mjs";
|
|
4
4
|
import { chat, maxIterations } from "@tanstack/ai";
|
|
5
5
|
//#region src/tanstack-ai/index.ts
|
|
6
6
|
/**
|
package/dist/testing.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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_run_agent = require("./run-agent-
|
|
5
|
-
const require_verify = require("./verify-
|
|
2
|
+
const require_event_log = require("./event-log-BZRfBRd7.cjs");
|
|
3
|
+
const require_decision = require("./decision-CIb7ddIv.cjs");
|
|
4
|
+
const require_run_agent = require("./run-agent-ctLCvNgL.cjs");
|
|
5
|
+
const require_verify = require("./verify-CVlsTZ-V.cjs");
|
|
6
6
|
//#region src/trajectory.ts
|
|
7
7
|
/**
|
|
8
8
|
* Classifies one item. Event-shaped things (log entries, events) become events;
|
|
@@ -438,10 +438,116 @@ function statePaths(value, prefix = "") {
|
|
|
438
438
|
return entries.flatMap(([key, child]) => statePaths(child, `${prefix}${key}.`));
|
|
439
439
|
}
|
|
440
440
|
//#endregion
|
|
441
|
+
//#region src/compare-runs.ts
|
|
442
|
+
/**
|
|
443
|
+
* Runs every scenario through a baseline and a candidate implementation and
|
|
444
|
+
* labels each difference, so a port can show where it behaves like the code it
|
|
445
|
+
* replaces and where it differs on purpose.
|
|
446
|
+
*
|
|
447
|
+
* Parity is outcome-level: the terminal outcome and the effects in the world,
|
|
448
|
+
* not the sequence of tool calls, since a machine usually reorders steps. A
|
|
449
|
+
* candidate that broke no rule where the baseline broke one is intended, even
|
|
450
|
+
* when the outcome matches. A difference also counts as intended when only the
|
|
451
|
+
* candidate reached the scenario's `expected` outcome. Every other difference,
|
|
452
|
+
* and every candidate rule break, is a regression for a person to review.
|
|
453
|
+
*
|
|
454
|
+
* Runs are sequential, baseline first. A run that throws is recorded with
|
|
455
|
+
* outcome `'threw'` and the error message as its `detail`. Parity holds for
|
|
456
|
+
* these scenarios and these runs only; with a live model, run it more than once.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts no-check
|
|
460
|
+
* const report = await compareRuns({
|
|
461
|
+
* scenarios,
|
|
462
|
+
* baseline: async (s) => toParityRun(await runRawLoop(s)),
|
|
463
|
+
* candidate: async (s) => toParityRun(await runDesk(s)),
|
|
464
|
+
* });
|
|
465
|
+
* expect(report.ok).toBe(true);
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
async function compareRuns(options) {
|
|
469
|
+
const scenarios = [];
|
|
470
|
+
const counts = {
|
|
471
|
+
same: 0,
|
|
472
|
+
intended: 0,
|
|
473
|
+
regression: 0
|
|
474
|
+
};
|
|
475
|
+
for (const scenario of options.scenarios) {
|
|
476
|
+
const baseline = await settle(() => options.baseline(scenario));
|
|
477
|
+
const candidate = await settle(() => options.candidate(scenario));
|
|
478
|
+
const { label, reason } = labelRun(scenario.expected, baseline, candidate);
|
|
479
|
+
counts[label]++;
|
|
480
|
+
scenarios.push({
|
|
481
|
+
id: scenario.id,
|
|
482
|
+
scenario,
|
|
483
|
+
label,
|
|
484
|
+
reason,
|
|
485
|
+
baseline,
|
|
486
|
+
candidate
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
scenarios,
|
|
491
|
+
counts,
|
|
492
|
+
ok: counts.regression === 0
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
async function settle(run) {
|
|
496
|
+
try {
|
|
497
|
+
return await run();
|
|
498
|
+
} catch (error) {
|
|
499
|
+
return {
|
|
500
|
+
outcome: "threw",
|
|
501
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function labelRun(expected, baseline, candidate) {
|
|
506
|
+
if (candidate.violations?.length) return {
|
|
507
|
+
label: "regression",
|
|
508
|
+
reason: `candidate broke a rule: ${list(candidate.violations)}`
|
|
509
|
+
};
|
|
510
|
+
if (candidate.outcome === "threw") return {
|
|
511
|
+
label: "regression",
|
|
512
|
+
reason: `candidate threw: ${String(candidate.detail)}`
|
|
513
|
+
};
|
|
514
|
+
if (baseline.violations?.length) return {
|
|
515
|
+
label: "intended",
|
|
516
|
+
reason: `baseline broke a rule: ${list(baseline.violations)}`
|
|
517
|
+
};
|
|
518
|
+
const sameOutcome = baseline.outcome === candidate.outcome;
|
|
519
|
+
if (sameOutcome && structurallyEqual(baseline.effects, candidate.effects)) return {
|
|
520
|
+
label: "same",
|
|
521
|
+
reason: ""
|
|
522
|
+
};
|
|
523
|
+
if (expected !== void 0 && candidate.outcome === expected && baseline.outcome !== expected) return {
|
|
524
|
+
label: "intended",
|
|
525
|
+
reason: `only the candidate reached the expected '${expected}'`
|
|
526
|
+
};
|
|
527
|
+
return {
|
|
528
|
+
label: "regression",
|
|
529
|
+
reason: sameOutcome ? "effects differ" : `outcome differs: ${baseline.outcome} → ${candidate.outcome}`
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
function list(items) {
|
|
533
|
+
return items.map((item) => typeof item === "string" ? item : JSON.stringify(item)).join(", ");
|
|
534
|
+
}
|
|
535
|
+
function structurallyEqual(a, b) {
|
|
536
|
+
if (Object.is(a, b)) return true;
|
|
537
|
+
if (a instanceof Date || b instanceof Date) return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
538
|
+
if (a instanceof Map || b instanceof Map) return a instanceof Map && b instanceof Map && structurallyEqual([...a], [...b]);
|
|
539
|
+
if (a instanceof Set || b instanceof Set) return a instanceof Set && b instanceof Set && structurallyEqual([...a], [...b]);
|
|
540
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => structurallyEqual(item, b[index]));
|
|
541
|
+
if (!require_decision.isRecord(a) || !require_decision.isRecord(b)) return false;
|
|
542
|
+
const keys = Object.keys(a);
|
|
543
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && structurallyEqual(a[key], b[key]));
|
|
544
|
+
}
|
|
545
|
+
//#endregion
|
|
441
546
|
exports.AgentLintError = require_verify.AgentLintError;
|
|
442
547
|
exports.AgentUnknownStateError = require_verify.AgentUnknownStateError;
|
|
443
548
|
exports.assertAgentMachine = require_verify.assertAgentMachine;
|
|
444
549
|
exports.canReach = require_verify.canReach;
|
|
550
|
+
exports.compareRuns = compareRuns;
|
|
445
551
|
exports.explorePaths = require_verify.explorePaths;
|
|
446
552
|
exports.foldTraces = foldTraces;
|
|
447
553
|
exports.lintAgentMachine = require_verify.lintAgentMachine;
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as AgentRequestExecutorInfo, f as AgentTextRequest, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors } from "./text-logic-
|
|
2
|
-
import { f as AgentRuntimeOptions, l as AgentRunResult, o as AgentRunInit } from "./run-agent-
|
|
1
|
+
import { c as AgentRequestExecutorInfo, f as AgentTextRequest, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors } from "./text-logic-DmciuVUQ.cjs";
|
|
2
|
+
import { f as AgentRuntimeOptions, l as AgentRunResult, o as AgentRunInit } from "./run-agent-CTlMc3Jb.cjs";
|
|
3
3
|
import { t as MetaOfSnapshot } from "./utils-ebVpCYoF.cjs";
|
|
4
|
-
import { _ as explorePaths, a as AgentPathTerminal, c as CanReachResult, d as SimulateAgentOptions, f as SimulateAgentResult, g as canReach, h as assertAgentMachine, i as AgentPathReport, l as ExplorePathsOptions, m as SimulationTrailEntry, n as AgentLintError, o as AgentUnknownStateError, p as SimulationScript, r as AgentLintSeverity, s as AssertAgentMachineOptions, t as AgentLintDiagnostic, u as LintAgentMachineOptions, v as lintAgentMachine, y as simulateAgent } from "./verify-
|
|
4
|
+
import { _ as explorePaths, a as AgentPathTerminal, c as CanReachResult, d as SimulateAgentOptions, f as SimulateAgentResult, g as canReach, h as assertAgentMachine, i as AgentPathReport, l as ExplorePathsOptions, m as SimulationTrailEntry, n as AgentLintError, o as AgentUnknownStateError, p as SimulationScript, r as AgentLintSeverity, s as AssertAgentMachineOptions, t as AgentLintDiagnostic, u as LintAgentMachineOptions, v as lintAgentMachine, y as simulateAgent } from "./verify-Dzwd4Mvk.cjs";
|
|
5
5
|
import { AnyStateMachine, EventFromLogic, InputFrom, SnapshotFrom, StateValue } from "xstate";
|
|
6
6
|
//#region src/trajectory.d.ts
|
|
7
7
|
/** An event-shaped trajectory item: anything with a string `type`. */
|
|
@@ -320,4 +320,85 @@ export declare function foldTraces<TTrace extends readonly {
|
|
|
320
320
|
readonly type: string;
|
|
321
321
|
}[]>(traces: Iterable<TTrace>, options: FoldTracesOptions<TTrace>): StateStats[];
|
|
322
322
|
//#endregion
|
|
323
|
-
|
|
323
|
+
//#region src/compare-runs.d.ts
|
|
324
|
+
/** One run of one scenario, reduced to what parity compares. See {@link compareRuns}. */
|
|
325
|
+
interface ParityRun {
|
|
326
|
+
/** How the run ended: a final state name, or the label of the loop's return. `'threw'` marks a run that threw. */
|
|
327
|
+
outcome: string;
|
|
328
|
+
/** What the run changed in the world, compared structurally. Sort lists whose order does not matter. */
|
|
329
|
+
effects?: unknown;
|
|
330
|
+
/** The rules the run broke, from ground truth. Any entry marks the run as rule-breaking. */
|
|
331
|
+
violations?: readonly unknown[];
|
|
332
|
+
/** Anything else to keep in the report. Not compared. */
|
|
333
|
+
detail?: unknown;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* How one scenario's candidate run relates to its baseline run.
|
|
337
|
+
*
|
|
338
|
+
* - `same`: same outcome, same effects, and neither run broke a rule.
|
|
339
|
+
* - `intended`: the candidate broke no rule, and the baseline broke one (even
|
|
340
|
+
* with the same outcome and effects), or the baseline missed the scenario's
|
|
341
|
+
* `expected` outcome that the candidate reached.
|
|
342
|
+
* - `regression`: the candidate broke a rule, or they differ for any other reason.
|
|
343
|
+
*/
|
|
344
|
+
type ParityLabel = "same" | "intended" | "regression";
|
|
345
|
+
/** One scenario's row in a {@link ParityReport}. */
|
|
346
|
+
interface ParityResult<TScenario> {
|
|
347
|
+
id: string;
|
|
348
|
+
scenario: TScenario;
|
|
349
|
+
label: ParityLabel;
|
|
350
|
+
/** Why the label was given, in a few words. Empty for `same`. */
|
|
351
|
+
reason: string;
|
|
352
|
+
baseline: ParityRun;
|
|
353
|
+
candidate: ParityRun;
|
|
354
|
+
}
|
|
355
|
+
/** The result of {@link compareRuns}. */
|
|
356
|
+
interface ParityReport<TScenario> {
|
|
357
|
+
scenarios: ParityResult<TScenario>[];
|
|
358
|
+
counts: Record<ParityLabel, number>;
|
|
359
|
+
/** True when no scenario is a `regression`. */
|
|
360
|
+
ok: boolean;
|
|
361
|
+
}
|
|
362
|
+
/** Options for {@link compareRuns}. */
|
|
363
|
+
interface CompareRunsOptions<TScenario extends {
|
|
364
|
+
id: string;
|
|
365
|
+
expected?: string;
|
|
366
|
+
}> {
|
|
367
|
+
scenarios: readonly TScenario[];
|
|
368
|
+
/** Runs the existing implementation (the loop) on one scenario. */
|
|
369
|
+
baseline: (scenario: TScenario) => Promise<ParityRun>;
|
|
370
|
+
/** Runs the replacement (the machine) on one scenario. */
|
|
371
|
+
candidate: (scenario: TScenario) => Promise<ParityRun>;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Runs every scenario through a baseline and a candidate implementation and
|
|
375
|
+
* labels each difference, so a port can show where it behaves like the code it
|
|
376
|
+
* replaces and where it differs on purpose.
|
|
377
|
+
*
|
|
378
|
+
* Parity is outcome-level: the terminal outcome and the effects in the world,
|
|
379
|
+
* not the sequence of tool calls, since a machine usually reorders steps. A
|
|
380
|
+
* candidate that broke no rule where the baseline broke one is intended, even
|
|
381
|
+
* when the outcome matches. A difference also counts as intended when only the
|
|
382
|
+
* candidate reached the scenario's `expected` outcome. Every other difference,
|
|
383
|
+
* and every candidate rule break, is a regression for a person to review.
|
|
384
|
+
*
|
|
385
|
+
* Runs are sequential, baseline first. A run that throws is recorded with
|
|
386
|
+
* outcome `'threw'` and the error message as its `detail`. Parity holds for
|
|
387
|
+
* these scenarios and these runs only; with a live model, run it more than once.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts no-check
|
|
391
|
+
* const report = await compareRuns({
|
|
392
|
+
* scenarios,
|
|
393
|
+
* baseline: async (s) => toParityRun(await runRawLoop(s)),
|
|
394
|
+
* candidate: async (s) => toParityRun(await runDesk(s)),
|
|
395
|
+
* });
|
|
396
|
+
* expect(report.ok).toBe(true);
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
export declare function compareRuns<TScenario extends {
|
|
400
|
+
id: string;
|
|
401
|
+
expected?: string;
|
|
402
|
+
}>(options: CompareRunsOptions<TScenario>): Promise<ParityReport<TScenario>>;
|
|
403
|
+
//#endregion
|
|
404
|
+
export { type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentPathReport, type AgentPathTerminal, AgentUnknownStateError, type AssertAgentMachineOptions, type CanReachResult, type CompareRunsOptions, type ExplorePathsOptions, type FoldTracesOptions, type LintAgentMachineOptions, type MatchTrajectoryOptions, type ParityLabel, type ParityReport, type ParityResult, type ParityRun, type RunSeamOptions, type RunSeamResult, type SeamCall, type SeamRef, type SeamScriptEntry, type SeamSlice, type SeamTurn, type SimulateAgentOptions, type SimulateAgentResult, type SimulationScript, type SimulationTrailEntry, type StateStats, type TrajectoryEvent, type TrajectoryItem, type TrajectoryMatch, type TrajectoryMiss, assertAgentMachine, canReach, explorePaths, lintAgentMachine, simulateAgent };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as AgentRequestExecutorInfo, f as AgentTextRequest, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors } from "./text-logic-
|
|
2
|
-
import { f as AgentRuntimeOptions, l as AgentRunResult, o as AgentRunInit } from "./run-agent-
|
|
1
|
+
import { c as AgentRequestExecutorInfo, f as AgentTextRequest, s as AgentRequestExecutor, t as AgentCallUsage, u as AgentRequestExecutors } from "./text-logic-BRYOPWvY.mjs";
|
|
2
|
+
import { f as AgentRuntimeOptions, l as AgentRunResult, o as AgentRunInit } from "./run-agent-CAVt5R-r.mjs";
|
|
3
3
|
import { t as MetaOfSnapshot } from "./utils-BnXdWih3.mjs";
|
|
4
|
-
import { _ as explorePaths, a as AgentPathTerminal, c as CanReachResult, d as SimulateAgentOptions, f as SimulateAgentResult, g as canReach, h as assertAgentMachine, i as AgentPathReport, l as ExplorePathsOptions, m as SimulationTrailEntry, n as AgentLintError, o as AgentUnknownStateError, p as SimulationScript, r as AgentLintSeverity, s as AssertAgentMachineOptions, t as AgentLintDiagnostic, u as LintAgentMachineOptions, v as lintAgentMachine, y as simulateAgent } from "./verify-
|
|
4
|
+
import { _ as explorePaths, a as AgentPathTerminal, c as CanReachResult, d as SimulateAgentOptions, f as SimulateAgentResult, g as canReach, h as assertAgentMachine, i as AgentPathReport, l as ExplorePathsOptions, m as SimulationTrailEntry, n as AgentLintError, o as AgentUnknownStateError, p as SimulationScript, r as AgentLintSeverity, s as AssertAgentMachineOptions, t as AgentLintDiagnostic, u as LintAgentMachineOptions, v as lintAgentMachine, y as simulateAgent } from "./verify-Cn86rT8l.mjs";
|
|
5
5
|
import { AnyStateMachine, EventFromLogic, InputFrom, SnapshotFrom, StateValue } from "xstate";
|
|
6
6
|
//#region src/trajectory.d.ts
|
|
7
7
|
/** An event-shaped trajectory item: anything with a string `type`. */
|
|
@@ -320,4 +320,85 @@ export declare function foldTraces<TTrace extends readonly {
|
|
|
320
320
|
readonly type: string;
|
|
321
321
|
}[]>(traces: Iterable<TTrace>, options: FoldTracesOptions<TTrace>): StateStats[];
|
|
322
322
|
//#endregion
|
|
323
|
-
|
|
323
|
+
//#region src/compare-runs.d.ts
|
|
324
|
+
/** One run of one scenario, reduced to what parity compares. See {@link compareRuns}. */
|
|
325
|
+
interface ParityRun {
|
|
326
|
+
/** How the run ended: a final state name, or the label of the loop's return. `'threw'` marks a run that threw. */
|
|
327
|
+
outcome: string;
|
|
328
|
+
/** What the run changed in the world, compared structurally. Sort lists whose order does not matter. */
|
|
329
|
+
effects?: unknown;
|
|
330
|
+
/** The rules the run broke, from ground truth. Any entry marks the run as rule-breaking. */
|
|
331
|
+
violations?: readonly unknown[];
|
|
332
|
+
/** Anything else to keep in the report. Not compared. */
|
|
333
|
+
detail?: unknown;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* How one scenario's candidate run relates to its baseline run.
|
|
337
|
+
*
|
|
338
|
+
* - `same`: same outcome, same effects, and neither run broke a rule.
|
|
339
|
+
* - `intended`: the candidate broke no rule, and the baseline broke one (even
|
|
340
|
+
* with the same outcome and effects), or the baseline missed the scenario's
|
|
341
|
+
* `expected` outcome that the candidate reached.
|
|
342
|
+
* - `regression`: the candidate broke a rule, or they differ for any other reason.
|
|
343
|
+
*/
|
|
344
|
+
type ParityLabel = "same" | "intended" | "regression";
|
|
345
|
+
/** One scenario's row in a {@link ParityReport}. */
|
|
346
|
+
interface ParityResult<TScenario> {
|
|
347
|
+
id: string;
|
|
348
|
+
scenario: TScenario;
|
|
349
|
+
label: ParityLabel;
|
|
350
|
+
/** Why the label was given, in a few words. Empty for `same`. */
|
|
351
|
+
reason: string;
|
|
352
|
+
baseline: ParityRun;
|
|
353
|
+
candidate: ParityRun;
|
|
354
|
+
}
|
|
355
|
+
/** The result of {@link compareRuns}. */
|
|
356
|
+
interface ParityReport<TScenario> {
|
|
357
|
+
scenarios: ParityResult<TScenario>[];
|
|
358
|
+
counts: Record<ParityLabel, number>;
|
|
359
|
+
/** True when no scenario is a `regression`. */
|
|
360
|
+
ok: boolean;
|
|
361
|
+
}
|
|
362
|
+
/** Options for {@link compareRuns}. */
|
|
363
|
+
interface CompareRunsOptions<TScenario extends {
|
|
364
|
+
id: string;
|
|
365
|
+
expected?: string;
|
|
366
|
+
}> {
|
|
367
|
+
scenarios: readonly TScenario[];
|
|
368
|
+
/** Runs the existing implementation (the loop) on one scenario. */
|
|
369
|
+
baseline: (scenario: TScenario) => Promise<ParityRun>;
|
|
370
|
+
/** Runs the replacement (the machine) on one scenario. */
|
|
371
|
+
candidate: (scenario: TScenario) => Promise<ParityRun>;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Runs every scenario through a baseline and a candidate implementation and
|
|
375
|
+
* labels each difference, so a port can show where it behaves like the code it
|
|
376
|
+
* replaces and where it differs on purpose.
|
|
377
|
+
*
|
|
378
|
+
* Parity is outcome-level: the terminal outcome and the effects in the world,
|
|
379
|
+
* not the sequence of tool calls, since a machine usually reorders steps. A
|
|
380
|
+
* candidate that broke no rule where the baseline broke one is intended, even
|
|
381
|
+
* when the outcome matches. A difference also counts as intended when only the
|
|
382
|
+
* candidate reached the scenario's `expected` outcome. Every other difference,
|
|
383
|
+
* and every candidate rule break, is a regression for a person to review.
|
|
384
|
+
*
|
|
385
|
+
* Runs are sequential, baseline first. A run that throws is recorded with
|
|
386
|
+
* outcome `'threw'` and the error message as its `detail`. Parity holds for
|
|
387
|
+
* these scenarios and these runs only; with a live model, run it more than once.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts no-check
|
|
391
|
+
* const report = await compareRuns({
|
|
392
|
+
* scenarios,
|
|
393
|
+
* baseline: async (s) => toParityRun(await runRawLoop(s)),
|
|
394
|
+
* candidate: async (s) => toParityRun(await runDesk(s)),
|
|
395
|
+
* });
|
|
396
|
+
* expect(report.ok).toBe(true);
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
export declare function compareRuns<TScenario extends {
|
|
400
|
+
id: string;
|
|
401
|
+
expected?: string;
|
|
402
|
+
}>(options: CompareRunsOptions<TScenario>): Promise<ParityReport<TScenario>>;
|
|
403
|
+
//#endregion
|
|
404
|
+
export { type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentPathReport, type AgentPathTerminal, AgentUnknownStateError, type AssertAgentMachineOptions, type CanReachResult, type CompareRunsOptions, type ExplorePathsOptions, type FoldTracesOptions, type LintAgentMachineOptions, type MatchTrajectoryOptions, type ParityLabel, type ParityReport, type ParityResult, type ParityRun, type RunSeamOptions, type RunSeamResult, type SeamCall, type SeamRef, type SeamScriptEntry, type SeamSlice, type SeamTurn, type SimulateAgentOptions, type SimulateAgentResult, type SimulationScript, type SimulationTrailEntry, type StateStats, type TrajectoryEvent, type TrajectoryItem, type TrajectoryMatch, type TrajectoryMiss, assertAgentMachine, canReach, explorePaths, lintAgentMachine, simulateAgent };
|
package/dist/testing.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as getStateMeta, F as normalizeGeneratorResult, N as getCallUsage, st as AgentError } from "./event-log-
|
|
2
|
-
import { m as isRecord } from "./decision-
|
|
3
|
-
import { p as runToQuiescence, s as createAgentRuntime } from "./run-agent-
|
|
4
|
-
import { a as explorePaths, i as canReach, n as AgentUnknownStateError, o as lintAgentMachine, r as assertAgentMachine, s as simulateAgent, t as AgentLintError } from "./verify-
|
|
1
|
+
import { $ as getStateMeta, F as normalizeGeneratorResult, N as getCallUsage, st as AgentError } from "./event-log-DJCMHek_.mjs";
|
|
2
|
+
import { m as isRecord } from "./decision-BHkvuImD.mjs";
|
|
3
|
+
import { p as runToQuiescence, s as createAgentRuntime } from "./run-agent-BpHqkaZw.mjs";
|
|
4
|
+
import { a as explorePaths, i as canReach, n as AgentUnknownStateError, o as lintAgentMachine, r as assertAgentMachine, s as simulateAgent, t as AgentLintError } from "./verify-COFWyprJ.mjs";
|
|
5
5
|
//#region src/trajectory.ts
|
|
6
6
|
/**
|
|
7
7
|
* Classifies one item. Event-shaped things (log entries, events) become events;
|
|
@@ -437,4 +437,109 @@ function statePaths(value, prefix = "") {
|
|
|
437
437
|
return entries.flatMap(([key, child]) => statePaths(child, `${prefix}${key}.`));
|
|
438
438
|
}
|
|
439
439
|
//#endregion
|
|
440
|
-
|
|
440
|
+
//#region src/compare-runs.ts
|
|
441
|
+
/**
|
|
442
|
+
* Runs every scenario through a baseline and a candidate implementation and
|
|
443
|
+
* labels each difference, so a port can show where it behaves like the code it
|
|
444
|
+
* replaces and where it differs on purpose.
|
|
445
|
+
*
|
|
446
|
+
* Parity is outcome-level: the terminal outcome and the effects in the world,
|
|
447
|
+
* not the sequence of tool calls, since a machine usually reorders steps. A
|
|
448
|
+
* candidate that broke no rule where the baseline broke one is intended, even
|
|
449
|
+
* when the outcome matches. A difference also counts as intended when only the
|
|
450
|
+
* candidate reached the scenario's `expected` outcome. Every other difference,
|
|
451
|
+
* and every candidate rule break, is a regression for a person to review.
|
|
452
|
+
*
|
|
453
|
+
* Runs are sequential, baseline first. A run that throws is recorded with
|
|
454
|
+
* outcome `'threw'` and the error message as its `detail`. Parity holds for
|
|
455
|
+
* these scenarios and these runs only; with a live model, run it more than once.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```ts no-check
|
|
459
|
+
* const report = await compareRuns({
|
|
460
|
+
* scenarios,
|
|
461
|
+
* baseline: async (s) => toParityRun(await runRawLoop(s)),
|
|
462
|
+
* candidate: async (s) => toParityRun(await runDesk(s)),
|
|
463
|
+
* });
|
|
464
|
+
* expect(report.ok).toBe(true);
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
async function compareRuns(options) {
|
|
468
|
+
const scenarios = [];
|
|
469
|
+
const counts = {
|
|
470
|
+
same: 0,
|
|
471
|
+
intended: 0,
|
|
472
|
+
regression: 0
|
|
473
|
+
};
|
|
474
|
+
for (const scenario of options.scenarios) {
|
|
475
|
+
const baseline = await settle(() => options.baseline(scenario));
|
|
476
|
+
const candidate = await settle(() => options.candidate(scenario));
|
|
477
|
+
const { label, reason } = labelRun(scenario.expected, baseline, candidate);
|
|
478
|
+
counts[label]++;
|
|
479
|
+
scenarios.push({
|
|
480
|
+
id: scenario.id,
|
|
481
|
+
scenario,
|
|
482
|
+
label,
|
|
483
|
+
reason,
|
|
484
|
+
baseline,
|
|
485
|
+
candidate
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
return {
|
|
489
|
+
scenarios,
|
|
490
|
+
counts,
|
|
491
|
+
ok: counts.regression === 0
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
async function settle(run) {
|
|
495
|
+
try {
|
|
496
|
+
return await run();
|
|
497
|
+
} catch (error) {
|
|
498
|
+
return {
|
|
499
|
+
outcome: "threw",
|
|
500
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function labelRun(expected, baseline, candidate) {
|
|
505
|
+
if (candidate.violations?.length) return {
|
|
506
|
+
label: "regression",
|
|
507
|
+
reason: `candidate broke a rule: ${list(candidate.violations)}`
|
|
508
|
+
};
|
|
509
|
+
if (candidate.outcome === "threw") return {
|
|
510
|
+
label: "regression",
|
|
511
|
+
reason: `candidate threw: ${String(candidate.detail)}`
|
|
512
|
+
};
|
|
513
|
+
if (baseline.violations?.length) return {
|
|
514
|
+
label: "intended",
|
|
515
|
+
reason: `baseline broke a rule: ${list(baseline.violations)}`
|
|
516
|
+
};
|
|
517
|
+
const sameOutcome = baseline.outcome === candidate.outcome;
|
|
518
|
+
if (sameOutcome && structurallyEqual(baseline.effects, candidate.effects)) return {
|
|
519
|
+
label: "same",
|
|
520
|
+
reason: ""
|
|
521
|
+
};
|
|
522
|
+
if (expected !== void 0 && candidate.outcome === expected && baseline.outcome !== expected) return {
|
|
523
|
+
label: "intended",
|
|
524
|
+
reason: `only the candidate reached the expected '${expected}'`
|
|
525
|
+
};
|
|
526
|
+
return {
|
|
527
|
+
label: "regression",
|
|
528
|
+
reason: sameOutcome ? "effects differ" : `outcome differs: ${baseline.outcome} → ${candidate.outcome}`
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function list(items) {
|
|
532
|
+
return items.map((item) => typeof item === "string" ? item : JSON.stringify(item)).join(", ");
|
|
533
|
+
}
|
|
534
|
+
function structurallyEqual(a, b) {
|
|
535
|
+
if (Object.is(a, b)) return true;
|
|
536
|
+
if (a instanceof Date || b instanceof Date) return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
537
|
+
if (a instanceof Map || b instanceof Map) return a instanceof Map && b instanceof Map && structurallyEqual([...a], [...b]);
|
|
538
|
+
if (a instanceof Set || b instanceof Set) return a instanceof Set && b instanceof Set && structurallyEqual([...a], [...b]);
|
|
539
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => structurallyEqual(item, b[index]));
|
|
540
|
+
if (!isRecord(a) || !isRecord(b)) return false;
|
|
541
|
+
const keys = Object.keys(a);
|
|
542
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && structurallyEqual(a[key], b[key]));
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
545
|
+
export { AgentLintError, AgentUnknownStateError, assertAgentMachine, canReach, compareRuns, explorePaths, foldTraces, lintAgentMachine, matchesTrajectory, runSeam, simulateAgent };
|
|
@@ -228,7 +228,7 @@ interface DecisionLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1
|
|
|
228
228
|
*
|
|
229
229
|
* export const chooseMove = createDecisionLogic({
|
|
230
230
|
* schemas: { input: z.object({ playerHp: z.number(), enemyHp: z.number() }) },
|
|
231
|
-
* model: 'openai/gpt-
|
|
231
|
+
* model: 'openai/gpt-6-luna',
|
|
232
232
|
* system: 'You are playing a turn-based game. Choose exactly one legal move.',
|
|
233
233
|
* prompt: ({ input }) => `Player HP: ${input.playerHp}\nEnemy HP: ${input.enemyHp}`,
|
|
234
234
|
* allowedEvents: ({ input }) =>
|
|
@@ -733,7 +733,7 @@ interface TextLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TO
|
|
|
733
733
|
* export const tellJoke = createTextLogic({
|
|
734
734
|
* mode: 'stream',
|
|
735
735
|
* schemas: { input: z.object({ topic: z.string() }), output: z.string() },
|
|
736
|
-
* model: 'openai/gpt-
|
|
736
|
+
* model: 'openai/gpt-6-luna',
|
|
737
737
|
* system: 'You tell short, punchy jokes.',
|
|
738
738
|
* prompt: ({ input }) => `Tell a joke about ${input.topic}.`,
|
|
739
739
|
* });
|
|
@@ -228,7 +228,7 @@ interface DecisionLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1
|
|
|
228
228
|
*
|
|
229
229
|
* export const chooseMove = createDecisionLogic({
|
|
230
230
|
* schemas: { input: z.object({ playerHp: z.number(), enemyHp: z.number() }) },
|
|
231
|
-
* model: 'openai/gpt-
|
|
231
|
+
* model: 'openai/gpt-6-luna',
|
|
232
232
|
* system: 'You are playing a turn-based game. Choose exactly one legal move.',
|
|
233
233
|
* prompt: ({ input }) => `Player HP: ${input.playerHp}\nEnemy HP: ${input.enemyHp}`,
|
|
234
234
|
* allowedEvents: ({ input }) =>
|
|
@@ -733,7 +733,7 @@ interface TextLogic<TInputSchema extends StandardSchemaV1 = StandardSchemaV1, TO
|
|
|
733
733
|
* export const tellJoke = createTextLogic({
|
|
734
734
|
* mode: 'stream',
|
|
735
735
|
* schemas: { input: z.object({ topic: z.string() }), output: z.string() },
|
|
736
|
-
* model: 'openai/gpt-
|
|
736
|
+
* model: 'openai/gpt-6-luna',
|
|
737
737
|
* system: 'You tell short, punchy jokes.',
|
|
738
738
|
* prompt: ({ input }) => `Tell a joke about ${input.topic}.`,
|
|
739
739
|
* });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { t as AgentCallUsage } from "./text-logic-BRYOPWvY.mjs";
|
|
2
2
|
import { EventObject } from "xstate";
|
|
3
3
|
//#region src/usage.d.ts
|
|
4
4
|
/** Reserved event delivered after a model call reports token usage. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as AgentCallUsage } from "./text-logic-
|
|
1
|
+
import { t as AgentCallUsage } from "./text-logic-DmciuVUQ.cjs";
|
|
2
2
|
import { EventObject } from "xstate";
|
|
3
3
|
//#region src/usage.d.ts
|
|
4
4
|
/** Reserved event delivered after a model call reports token usage. */
|