@you-agent-factory/factory-emulator 0.0.0 → 0.0.2

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.
Files changed (69) hide show
  1. package/LICENSE.md +19 -1
  2. package/README.md +305 -286
  3. package/dist/compatibility.d.ts +19 -0
  4. package/dist/compatibility.js +156 -0
  5. package/dist/event-sink.d.ts +29 -0
  6. package/dist/event-sink.js +58 -0
  7. package/dist/generated/scenario-schema.d.ts +268 -0
  8. package/dist/generated/scenario-schema.js +319 -0
  9. package/dist/index.d.ts +8 -0
  10. package/dist/index.js +8 -0
  11. package/dist/logical-move.d.ts +10 -0
  12. package/dist/logical-move.js +18 -0
  13. package/dist/recording-sink.d.ts +22 -0
  14. package/dist/recording-sink.js +122 -0
  15. package/dist/runtime-reference-conformance.d.ts +20 -0
  16. package/dist/runtime-reference-conformance.js +138 -0
  17. package/dist/runtime-reference-evidence.d.ts +9 -0
  18. package/dist/runtime-reference-evidence.js +193 -0
  19. package/dist/runtime-reference-fixtures.d.ts +7 -0
  20. package/dist/runtime-reference-fixtures.js +308 -0
  21. package/dist/runtime-reference.d.ts +48 -0
  22. package/dist/runtime-reference.js +143 -0
  23. package/dist/scenario-contracts.d.ts +81 -0
  24. package/dist/scenario-contracts.js +11 -0
  25. package/dist/scenario.d.ts +271 -0
  26. package/dist/scenario.js +333 -0
  27. package/dist/scheduler.d.ts +24 -0
  28. package/dist/scheduler.js +104 -0
  29. package/dist/session-contracts.d.ts +262 -0
  30. package/dist/session-contracts.js +74 -0
  31. package/dist/session.d.ts +4 -0
  32. package/dist/session.js +1490 -0
  33. package/dist/submission-replay.d.ts +14 -0
  34. package/dist/submission-replay.js +96 -0
  35. package/dist/submission-validation.d.ts +3 -0
  36. package/dist/submission-validation.js +113 -0
  37. package/examples/customer-support.scenario.v1.json +45 -0
  38. package/package.json +44 -22
  39. package/schema/scenario.schema.json +171 -0
  40. package/generated/factory-emulator-scenario.schema.json +0 -191
  41. package/generated/factory.schema.json +0 -2606
  42. package/src/contracts.ts +0 -41
  43. package/src/data-error.js +0 -21
  44. package/src/data-only.js +0 -208
  45. package/src/emulator.js +0 -195
  46. package/src/emulator.ts +0 -86
  47. package/src/examples.js +0 -86
  48. package/src/examples.ts +0 -11
  49. package/src/generated/factory-schema.d.ts +0 -3
  50. package/src/generated/factory-schema.js +0 -5
  51. package/src/generated/scenario-schema.d.ts +0 -4
  52. package/src/generated/scenario-schema.js +0 -6
  53. package/src/generated/scenario.ts +0 -103
  54. package/src/identity.js +0 -55
  55. package/src/index.js +0 -34
  56. package/src/index.ts +0 -102
  57. package/src/limits.js +0 -125
  58. package/src/parser.js +0 -113
  59. package/src/parser.ts +0 -56
  60. package/src/scheduler.js +0 -374
  61. package/src/semantics.js +0 -354
  62. package/src/semantics.ts +0 -38
  63. package/src/session.js +0 -1201
  64. package/src/session.ts +0 -324
  65. package/src/sinks.js +0 -118
  66. package/src/sinks.ts +0 -56
  67. package/src/support.js +0 -334
  68. package/src/support.ts +0 -15
  69. package/src/virtual-time.js +0 -36
package/src/contracts.ts DELETED
@@ -1,41 +0,0 @@
1
- import type { FactoryEvent } from "@you-agent-factory/client";
2
-
3
- /**
4
- * One ordered canonical Factory event batch submitted by an emulator logical
5
- * tick. This value contains data only, so hosts can structured-clone it across
6
- * process or worker boundaries.
7
- */
8
- export interface FactoryEventBatch {
9
- readonly events: readonly FactoryEvent[];
10
- }
11
-
12
- /**
13
- * The only successful result of a batch write. A receipt is returned only when
14
- * every supplied event was accepted in its supplied order; partial acceptance
15
- * must reject the write instead of returning this receipt.
16
- */
17
- export interface FactoryEventSinkWriteReceipt {
18
- readonly status: "accepted";
19
- }
20
-
21
- /**
22
- * The only successful result of an explicit sink close. Closing does not
23
- * implicitly accept a pending batch; callers must await its write first.
24
- */
25
- export interface FactoryEventSinkCloseReceipt {
26
- readonly status: "closed";
27
- }
28
-
29
- /**
30
- * Caller-owned asynchronous destination for canonical Factory events.
31
- *
32
- * `write` is the backpressure boundary: resolution means the entire ordered
33
- * batch was accepted, while rejection means none of the batch was accepted.
34
- * `close` is explicit and asynchronous so a host can observe either its
35
- * successful completion or rejection. The contract deliberately has no
36
- * subscription, replay, transport, browser, or dashboard dependency.
37
- */
38
- export interface FactoryEventSink {
39
- write(batch: FactoryEventBatch): Promise<FactoryEventSinkWriteReceipt>;
40
- close(): Promise<FactoryEventSinkCloseReceipt>;
41
- }
package/src/data-error.js DELETED
@@ -1,21 +0,0 @@
1
- export function defineDataError(name, code, fields) {
2
- const DataError = function (...args) {
3
- return {
4
- name,
5
- message: fields.message(...args),
6
- code,
7
- ...fields.details(...args),
8
- };
9
- };
10
- Object.defineProperty(DataError, "name", { value: name });
11
- Object.defineProperty(DataError, Symbol.hasInstance, {
12
- value(candidate) {
13
- return candidate !== null
14
- && typeof candidate === "object"
15
- && Object.getPrototypeOf(candidate) === Object.prototype
16
- && candidate.name === name
17
- && candidate.code === code;
18
- },
19
- });
20
- return DataError;
21
- }
package/src/data-only.js DELETED
@@ -1,208 +0,0 @@
1
- const DATA_ONLY_EXPECTATION =
2
- "plain objects, dense arrays, null, booleans, strings, or finite numbers";
3
-
4
- const MAXIMUM_DATA_ONLY_NODES = 10_000;
5
- const MAXIMUM_DATA_ONLY_DEPTH = 100;
6
-
7
- /** Returns deterministic JSON-Pointer diagnostics for values outside the data-only graph. */
8
- export function dataOnlyDiagnostics(value, { code, rootPath = "/" }) {
9
- const diagnostics = [];
10
- const ancestors = new Set();
11
- const stack = [{ depth: 0, kind: "visit", path: rootPath, value }];
12
- let inspectedNodes = 0;
13
-
14
- while (stack.length > 0) {
15
- const frame = stack.pop();
16
- if (frame.kind === "leave") {
17
- ancestors.delete(frame.value);
18
- continue;
19
- }
20
-
21
- inspectedNodes += 1;
22
- if (inspectedNodes > MAXIMUM_DATA_ONLY_NODES) {
23
- diagnostics.push(boundDiagnostic(
24
- code,
25
- frame.path,
26
- `more than ${MAXIMUM_DATA_ONLY_NODES} data nodes`,
27
- ));
28
- break;
29
- }
30
- if (frame.depth > MAXIMUM_DATA_ONLY_DEPTH) {
31
- diagnostics.push(boundDiagnostic(
32
- code,
33
- frame.path,
34
- `data nested deeper than ${MAXIMUM_DATA_ONLY_DEPTH} levels`,
35
- ));
36
- break;
37
- }
38
- if (isPrimitive(frame.value)) {
39
- continue;
40
- }
41
- if (typeof frame.value !== "object") {
42
- diagnostics.push(diagnostic(code, frame.path, typeof frame.value));
43
- continue;
44
- }
45
-
46
- const inspection = inspectObject(frame.value, frame.path, code, ancestors);
47
- if (inspection.diagnostic !== undefined) {
48
- diagnostics.push(inspection.diagnostic);
49
- continue;
50
- }
51
- if (inspection.children.length > MAXIMUM_DATA_ONLY_NODES - inspectedNodes) {
52
- diagnostics.push(boundDiagnostic(
53
- code,
54
- frame.path,
55
- `more than ${MAXIMUM_DATA_ONLY_NODES} data nodes`,
56
- ));
57
- break;
58
- }
59
-
60
- ancestors.add(frame.value);
61
- stack.push({ kind: "leave", value: frame.value });
62
- for (let index = inspection.children.length - 1; index >= 0; index -= 1) {
63
- stack.push({
64
- ...inspection.children[index],
65
- depth: frame.depth + 1,
66
- kind: "visit",
67
- });
68
- }
69
- diagnostics.push(...inspection.propertyDiagnostics);
70
- }
71
- return diagnostics;
72
- }
73
-
74
- function isPrimitive(value) {
75
- return (
76
- value === null ||
77
- typeof value === "string" ||
78
- typeof value === "boolean" ||
79
- (typeof value === "number" && Number.isFinite(value))
80
- );
81
- }
82
-
83
- function inspectObject(value, path, code, ancestors) {
84
- let prototype;
85
- let descriptors;
86
- try {
87
- prototype = Object.getPrototypeOf(value);
88
- if (prototype !== Object.prototype && prototype !== Array.prototype) {
89
- return { diagnostic: diagnostic(code, path, "an object with an unsupported prototype") };
90
- }
91
- if (ancestors.has(value)) {
92
- return { diagnostic: diagnostic(code, path, "a circular reference") };
93
- }
94
- if (Array.isArray(value) && value.length > MAXIMUM_DATA_ONLY_NODES) {
95
- return {
96
- diagnostic: boundDiagnostic(
97
- code,
98
- path,
99
- `an array longer than ${MAXIMUM_DATA_ONLY_NODES} entries`,
100
- ),
101
- };
102
- }
103
- if (!Array.isArray(value) && hasTooManyEnumerableProperties(value)) {
104
- return {
105
- diagnostic: boundDiagnostic(
106
- code,
107
- path,
108
- `an object with more than ${MAXIMUM_DATA_ONLY_NODES} entries`,
109
- ),
110
- };
111
- }
112
- descriptors = Object.getOwnPropertyDescriptors(value);
113
- } catch {
114
- return { diagnostic: diagnostic(code, path, "an uninspectable object") };
115
- }
116
-
117
- return Array.isArray(value)
118
- ? inspectArray(value, path, code, descriptors)
119
- : inspectRecord(path, code, descriptors);
120
- }
121
-
122
- function hasTooManyEnumerableProperties(value) {
123
- let count = 0;
124
- for (const key in value) {
125
- if (!Object.hasOwn(value, key)) {
126
- continue;
127
- }
128
- count += 1;
129
- if (count > MAXIMUM_DATA_ONLY_NODES) {
130
- return true;
131
- }
132
- }
133
- return false;
134
- }
135
-
136
- function inspectArray(value, path, code, descriptors) {
137
- const children = [];
138
- const propertyDiagnostics = [];
139
- for (let index = 0; index < value.length; index += 1) {
140
- const childPath = joinPath(path, String(index));
141
- const descriptor = descriptors[index];
142
- if (descriptor === undefined) {
143
- propertyDiagnostics.push(diagnostic(code, childPath, "a sparse array slot"));
144
- continue;
145
- }
146
- inspectDescriptor(descriptor, childPath, code, children, propertyDiagnostics);
147
- }
148
- for (const key of Reflect.ownKeys(descriptors)) {
149
- if (key === "length" || (typeof key === "string" && isArrayIndex(key, value.length))) {
150
- continue;
151
- }
152
- propertyDiagnostics.push(
153
- diagnostic(code, joinPath(path, String(key)), "an array property"),
154
- );
155
- }
156
- return { children, propertyDiagnostics };
157
- }
158
-
159
- function inspectRecord(path, code, descriptors) {
160
- const children = [];
161
- const propertyDiagnostics = [];
162
- for (const key of Reflect.ownKeys(descriptors)) {
163
- const childPath = typeof key === "symbol" ? path : joinPath(path, key);
164
- if (typeof key === "symbol") {
165
- propertyDiagnostics.push(diagnostic(code, childPath, "a symbol-keyed property"));
166
- continue;
167
- }
168
- inspectDescriptor(descriptors[key], childPath, code, children, propertyDiagnostics);
169
- }
170
- return { children, propertyDiagnostics };
171
- }
172
-
173
- function inspectDescriptor(descriptor, path, code, children, diagnostics) {
174
- if (!descriptor.enumerable || !("value" in descriptor)) {
175
- diagnostics.push(diagnostic(code, path, "an accessor or non-enumerable property"));
176
- return;
177
- }
178
- children.push({ path, value: descriptor.value });
179
- }
180
-
181
- function isArrayIndex(key, length) {
182
- const index = Number(key);
183
- return Number.isInteger(index) && index >= 0 && index < length && String(index) === key;
184
- }
185
-
186
- function joinPath(parent, property) {
187
- const escaped = property.replaceAll("~", "~0").replaceAll("/", "~1");
188
- return parent === "/" ? `/${escaped}` : `${parent}/${escaped}`;
189
- }
190
-
191
- function diagnostic(code, path, received) {
192
- return {
193
- code,
194
- path,
195
- message: `${path} must contain data-only values; received ${received}.`,
196
- expectation: DATA_ONLY_EXPECTATION,
197
- };
198
- }
199
-
200
- function boundDiagnostic(code, path, received) {
201
- return {
202
- code,
203
- path,
204
- message: `${path} exceeds the bounded data-only inspection: ${received}.`,
205
- expectation:
206
- `${DATA_ONLY_EXPECTATION} within ${MAXIMUM_DATA_ONLY_NODES} nodes and ${MAXIMUM_DATA_ONLY_DEPTH} levels`,
207
- };
208
- }
package/src/emulator.js DELETED
@@ -1,195 +0,0 @@
1
- const committedReceipt = Object.freeze({ status: "committed" });
2
-
3
- export class FactoryEmulatorAdvanceInProgressError extends Error {
4
- constructor() {
5
- super("Factory emulator is waiting for the current logical tick to be accepted");
6
- this.name = "FactoryEmulatorAdvanceInProgressError";
7
- }
8
- }
9
-
10
- export class FactoryEmulatorPendingTransactionError extends Error {
11
- constructor() {
12
- super("Factory emulator has a rejected logical tick that must be retried or reset");
13
- this.name = "FactoryEmulatorPendingTransactionError";
14
- }
15
- }
16
-
17
- export class FactoryEmulatorClosedError extends Error {
18
- constructor() {
19
- super("Factory emulator is closed");
20
- this.name = "FactoryEmulatorClosedError";
21
- }
22
- }
23
-
24
- /**
25
- * Creates a transport-neutral logical-tick emulator.
26
- *
27
- * State and calculated tick values are copied at the emulator boundary. This
28
- * keeps the sink write and the eventual commit paired to one immutable
29
- * calculation, even when the host retains or mutates its original values.
30
- */
31
- export function createFactoryEmulator({ calculateClose, calculateTick, initialState, sink }) {
32
- if (typeof calculateTick !== "function") {
33
- throw new TypeError("calculateTick must be a function");
34
- }
35
- if (!sink || typeof sink.write !== "function") {
36
- throw new TypeError("sink must provide a write function");
37
- }
38
-
39
- let committedState = copy(initialState);
40
- let advanceInProgress = false;
41
- let closed = false;
42
- let pendingTick;
43
- let pendingCloseBatch;
44
- let pendingCloseBatchAccepted = false;
45
- let lastError;
46
-
47
- return Object.freeze({
48
- async advance() {
49
- if (advanceInProgress) {
50
- throw new FactoryEmulatorAdvanceInProgressError();
51
- }
52
- assertOpen(closed);
53
- if (pendingCloseBatch) {
54
- throw new FactoryEmulatorPendingTransactionError();
55
- }
56
-
57
- const calculation = pendingTick ?? calculateCalculation(calculateTick, committedState);
58
- return writeAndCommitTick(calculation);
59
- },
60
- async close() {
61
- if (advanceInProgress) {
62
- throw new FactoryEmulatorAdvanceInProgressError();
63
- }
64
- if (closed) {
65
- throw new FactoryEmulatorClosedError();
66
- }
67
- if (pendingTick) {
68
- throw new FactoryEmulatorPendingTransactionError();
69
- }
70
-
71
- if (!pendingCloseBatch) {
72
- if (typeof calculateClose !== "function") {
73
- throw new TypeError("calculateClose must be a function before closing the emulator");
74
- }
75
- pendingCloseBatch = calculateCloseBatch(calculateClose, committedState);
76
- }
77
- if (!pendingCloseBatchAccepted) {
78
- advanceInProgress = true;
79
- try {
80
- await sink.write(copy(pendingCloseBatch));
81
- pendingCloseBatchAccepted = true;
82
- lastError = undefined;
83
- } catch (error) {
84
- lastError = errorStatus("write", error);
85
- throw error;
86
- } finally {
87
- advanceInProgress = false;
88
- }
89
- }
90
-
91
- advanceInProgress = true;
92
- try {
93
- await sink.close();
94
- closed = true;
95
- lastError = undefined;
96
- return copy({ status: "closed", batch: pendingCloseBatch });
97
- } catch (error) {
98
- lastError = errorStatus("close", error);
99
- throw error;
100
- } finally {
101
- advanceInProgress = false;
102
- }
103
- },
104
- reset() {
105
- if (advanceInProgress) {
106
- throw new FactoryEmulatorAdvanceInProgressError();
107
- }
108
- if (closed) {
109
- throw new FactoryEmulatorClosedError();
110
- }
111
- if (pendingCloseBatch) {
112
- if (pendingCloseBatchAccepted) {
113
- throw new FactoryEmulatorPendingTransactionError();
114
- }
115
- pendingCloseBatch = undefined;
116
- lastError = undefined;
117
- return;
118
- }
119
- pendingTick = undefined;
120
- lastError = undefined;
121
- },
122
- pending() {
123
- return pendingTick ? copy(pendingTick.batch) : undefined;
124
- },
125
- status() {
126
- return copy({
127
- phase: closed ? "closed" : pendingCloseBatch ? "closing" : pendingTick ? "pending" : "open",
128
- lastError,
129
- });
130
- },
131
- state() {
132
- return copy(committedState);
133
- },
134
- });
135
-
136
- async function writeAndCommitTick(calculation) {
137
- advanceInProgress = true;
138
- try {
139
- await sink.write(copy(calculation.batch));
140
- committedState = calculation.state;
141
- pendingTick = undefined;
142
- lastError = undefined;
143
- return copy({ ...committedReceipt, batch: calculation.batch });
144
- } catch (error) {
145
- pendingTick = calculation;
146
- lastError = errorStatus("write", error);
147
- throw error;
148
- } finally {
149
- advanceInProgress = false;
150
- }
151
- }
152
- }
153
-
154
- function calculateCalculation(calculateTick, committedState) {
155
- const calculation = copy(calculateTick(copy(committedState)));
156
- assertCalculation(calculation);
157
- return calculation;
158
- }
159
-
160
- function calculateCloseBatch(calculateClose, committedState) {
161
- const batch = copy(calculateClose(copy(committedState)));
162
- if (!batch || !Array.isArray(batch.events)) {
163
- throw new TypeError("calculateClose must return a terminal lifecycle event batch");
164
- }
165
- return batch;
166
- }
167
-
168
- function assertCalculation(calculation) {
169
- if (!calculation || typeof calculation !== "object") {
170
- throw new TypeError("calculateTick must return a logical tick calculation");
171
- }
172
- if (!calculation.batch || !Array.isArray(calculation.batch.events)) {
173
- throw new TypeError("logical tick calculation batch must contain an events array");
174
- }
175
- if (!("state" in calculation)) {
176
- throw new TypeError("logical tick calculation must contain the calculated state");
177
- }
178
- }
179
-
180
- function assertOpen(closed) {
181
- if (closed) {
182
- throw new FactoryEmulatorClosedError();
183
- }
184
- }
185
-
186
- function errorStatus(operation, error) {
187
- return {
188
- operation,
189
- message: error instanceof Error ? error.message : String(error),
190
- };
191
- }
192
-
193
- function copy(value) {
194
- return structuredClone(value);
195
- }
package/src/emulator.ts DELETED
@@ -1,86 +0,0 @@
1
- import type { FactoryEventBatch, FactoryEventSink } from "./contracts.js";
2
-
3
- /** Raised when an advancing command arrives before the prior tick is accepted. */
4
- export declare class FactoryEmulatorAdvanceInProgressError extends Error {}
5
-
6
- /** Raised when a rejected tick must be retried or explicitly reset first. */
7
- export declare class FactoryEmulatorPendingTransactionError extends Error {}
8
-
9
- /** Raised when a command is issued after the emulator has closed. */
10
- export declare class FactoryEmulatorClosedError extends Error {}
11
-
12
- /**
13
- * The complete result of calculating one logical scheduler step. The emulator
14
- * writes `batch` before it makes `state` visible as its next committed state.
15
- */
16
- export interface FactoryEmulatorTick<State> {
17
- readonly batch: FactoryEventBatch;
18
- readonly state: State;
19
- }
20
-
21
- /** Computes one complete logical tick from a detached committed-state snapshot. */
22
- export type FactoryEmulatorTickCalculator<State> = (
23
- state: State,
24
- ) => FactoryEmulatorTick<State>;
25
-
26
- /** Builds the terminal lifecycle event batch written before the sink closes. */
27
- export type FactoryEmulatorCloseCalculator<State> = (
28
- state: State,
29
- ) => FactoryEventBatch;
30
-
31
- /** Dependencies and initial state for one caller-owned emulator session. */
32
- export interface FactoryEmulatorOptions<State> {
33
- /** Required when callers use `close`; returns the terminal lifecycle batch. */
34
- readonly calculateClose?: FactoryEmulatorCloseCalculator<State>;
35
- readonly calculateTick: FactoryEmulatorTickCalculator<State>;
36
- readonly initialState: State;
37
- readonly sink: FactoryEventSink;
38
- }
39
-
40
- /** Returned only after the matching sink write accepts the entire batch. */
41
- export interface FactoryEmulatorAdvanceReceipt {
42
- readonly status: "committed";
43
- readonly batch: FactoryEventBatch;
44
- }
45
-
46
- /** The result returned after a terminal batch and sink close both succeed. */
47
- export interface FactoryEmulatorCloseReceipt {
48
- readonly status: "closed";
49
- readonly batch: FactoryEventBatch;
50
- }
51
-
52
- /** Observable retry and lifecycle status for one emulator session. */
53
- export interface FactoryEmulatorStatus {
54
- readonly phase: "open" | "pending" | "closing" | "closed";
55
- readonly lastError?: {
56
- readonly operation: "write" | "close";
57
- readonly message: string;
58
- };
59
- }
60
-
61
- /**
62
- * A caller-owned logical-tick runtime.
63
- *
64
- * `advance` computes one full batch, awaits the asynchronous sink write, and
65
- * commits the calculated state only after that write resolves. A second
66
- * advancing command while the write is unresolved rejects explicitly, so it
67
- * cannot calculate or commit a later tick ahead of the pending batch.
68
- * A rejected write retains the calculated batch unchanged; the next `advance`
69
- * retries it before new work is calculated, while `reset` explicitly discards
70
- * it. `close` retries its caller-calculated terminal lifecycle batch unchanged
71
- * after rejection, then closes the sink. It cannot bypass a rejected tick.
72
- * `state` returns a detached snapshot of the latest committed state.
73
- */
74
- export interface FactoryEmulator<State> {
75
- advance(): Promise<FactoryEmulatorAdvanceReceipt>;
76
- close(): Promise<FactoryEmulatorCloseReceipt>;
77
- reset(): void;
78
- pending(): FactoryEventBatch | undefined;
79
- status(): FactoryEmulatorStatus;
80
- state(): State;
81
- }
82
-
83
- /** Creates an emulator with explicit state, scheduling, and sink ownership. */
84
- export declare function createFactoryEmulator<State>(
85
- options: FactoryEmulatorOptions<State>,
86
- ): FactoryEmulator<State>;
package/src/examples.js DELETED
@@ -1,86 +0,0 @@
1
- import { SUPPORTED_SCENARIO_VERSION } from "./generated/scenario-schema.js";
2
-
3
- /** Published, parser-validated documents for consumers starting an emulator host. */
4
- export const emulatorScenarioExamples = Object.freeze([
5
- {
6
- name: "minimal",
7
- factory: {
8
- name: "minimal-emulator-factory",
9
- workTypes: [{ name: "checkout", states: [] }],
10
- workstations: [{
11
- name: "complete",
12
- worker: "emulator",
13
- inputs: [],
14
- behavior: "STANDARD",
15
- }],
16
- },
17
- scenario: {
18
- version: SUPPORTED_SCENARIO_VERSION,
19
- id: "minimal-checkout",
20
- seed: "minimal-checkout-seed",
21
- startAt: "2026-07-18T08:00:00Z",
22
- rules: [{
23
- id: "complete-checkout",
24
- match: { kind: "workType", workType: "checkout" },
25
- outcomes: [{ kind: "complete" }],
26
- exhaustionBehavior: { kind: "repeatLast" },
27
- }],
28
- unmatchedBehavior: { kind: "ignore" },
29
- },
30
- },
31
- {
32
- name: "multi-rule-lineage",
33
- factory: {
34
- name: "multi-rule-emulator-factory",
35
- workTypes: [
36
- { name: "checkout", states: [] },
37
- { name: "fulfillment", states: [] },
38
- { name: "other", states: [] },
39
- ],
40
- workstations: [{
41
- name: "complete",
42
- worker: "emulator",
43
- inputs: [],
44
- behavior: "STANDARD",
45
- }],
46
- },
47
- scenario: {
48
- version: SUPPORTED_SCENARIO_VERSION,
49
- id: "checkout-and-fulfillment",
50
- seed: "checkout-and-fulfillment-seed",
51
- startAt: "2026-07-18T08:30:00Z",
52
- activityLabel: "Emulating deterministic checkout",
53
- initialSubmissions: [
54
- { id: "checkout-1", workType: "checkout" },
55
- { id: "fulfillment-1", workType: "fulfillment" },
56
- ],
57
- rules: [
58
- {
59
- id: "priority-checkout",
60
- match: { kind: "submissionId", submissionId: "checkout-1" },
61
- outcomes: [{
62
- kind: "complete",
63
- lineageCursor: { kind: "initialSubmission", submissionId: "checkout-1" },
64
- }],
65
- exhaustionBehavior: { kind: "useUnmatchedBehavior" },
66
- },
67
- {
68
- id: "remaining-checkout",
69
- match: { kind: "workType", workType: "checkout" },
70
- outcomes: [{ kind: "complete" }],
71
- exhaustionBehavior: { kind: "repeatLast" },
72
- },
73
- {
74
- id: "fulfillment-from-checkout",
75
- match: { kind: "workType", workType: "fulfillment" },
76
- outcomes: [{
77
- kind: "complete",
78
- lineageCursor: { kind: "scriptedOutcome", ruleId: "priority-checkout", outcomeIndex: 0 },
79
- }],
80
- exhaustionBehavior: { kind: "useUnmatchedBehavior" },
81
- },
82
- ],
83
- unmatchedBehavior: { kind: "reject", reason: "no scripted match" },
84
- },
85
- },
86
- ]);
package/src/examples.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { EmulatorScenario } from "./generated/scenario.js";
2
- import type { EmulatorFactoryDefinition } from "./parser.js";
3
-
4
- export interface EmulatorScenarioExample {
5
- readonly name: "minimal" | "multi-rule-lineage";
6
- readonly factory: EmulatorFactoryDefinition;
7
- readonly scenario: EmulatorScenario;
8
- }
9
-
10
- /** Published, parser-validated documents for consumers starting an emulator host. */
11
- export declare const emulatorScenarioExamples: readonly EmulatorScenarioExample[];
@@ -1,3 +0,0 @@
1
- // Code generated by scripts/generate-emulator.mjs; DO NOT EDIT.
2
-
3
- export declare const factorySchema: Readonly<Record<string, unknown>>;
@@ -1,5 +0,0 @@
1
- // Code generated by scripts/generate-emulator.mjs; DO NOT EDIT.
2
-
3
- import schema from "../../generated/factory.schema.json" with { type: "json" };
4
-
5
- export const factorySchema = schema;
@@ -1,4 +0,0 @@
1
- // Code generated by scripts/generate-emulator.mjs; DO NOT EDIT.
2
-
3
- export declare const SUPPORTED_SCENARIO_VERSION: "you-agent-factory.emulator.scenario.v1";
4
- export declare const scenarioSchema: Readonly<Record<string, unknown>>;
@@ -1,6 +0,0 @@
1
- // Code generated by scripts/generate-emulator.mjs; DO NOT EDIT.
2
-
3
- import schema from "../../generated/factory-emulator-scenario.schema.json" with { type: "json" };
4
-
5
- export const SUPPORTED_SCENARIO_VERSION = "you-agent-factory.emulator.scenario.v1";
6
- export const scenarioSchema = schema;