@openprose/reactor-cradle 0.1.0-rc.1

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 (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +270 -0
  3. package/dist/assert/index.d.ts +35 -0
  4. package/dist/assert/index.d.ts.map +1 -0
  5. package/dist/assert/index.js +398 -0
  6. package/dist/baselines/cost-thesis/index.d.ts +103 -0
  7. package/dist/baselines/cost-thesis/index.d.ts.map +1 -0
  8. package/dist/baselines/cost-thesis/index.js +337 -0
  9. package/dist/baselines/naive-loop/index.d.ts +46 -0
  10. package/dist/baselines/naive-loop/index.d.ts.map +1 -0
  11. package/dist/baselines/naive-loop/index.js +188 -0
  12. package/dist/baselines/no-memo/index.d.ts +84 -0
  13. package/dist/baselines/no-memo/index.d.ts.map +1 -0
  14. package/dist/baselines/no-memo/index.js +226 -0
  15. package/dist/doubles/clock.d.ts +9 -0
  16. package/dist/doubles/clock.d.ts.map +1 -0
  17. package/dist/doubles/clock.js +42 -0
  18. package/dist/doubles/storage.d.ts +24 -0
  19. package/dist/doubles/storage.d.ts.map +1 -0
  20. package/dist/doubles/storage.js +191 -0
  21. package/dist/eval/index.d.ts +204 -0
  22. package/dist/eval/index.d.ts.map +1 -0
  23. package/dist/eval/index.js +596 -0
  24. package/dist/index.d.ts +24 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +39 -0
  27. package/dist/policy-author/index.d.ts +103 -0
  28. package/dist/policy-author/index.d.ts.map +1 -0
  29. package/dist/policy-author/index.js +358 -0
  30. package/dist/policy-drift/index.d.ts +64 -0
  31. package/dist/policy-drift/index.d.ts.map +1 -0
  32. package/dist/policy-drift/index.js +495 -0
  33. package/dist/policy-replay/index.d.ts +106 -0
  34. package/dist/policy-replay/index.d.ts.map +1 -0
  35. package/dist/policy-replay/index.js +361 -0
  36. package/dist/provider-parity/index.d.ts +91 -0
  37. package/dist/provider-parity/index.d.ts.map +1 -0
  38. package/dist/provider-parity/index.js +439 -0
  39. package/dist/recompile/index.d.ts +161 -0
  40. package/dist/recompile/index.d.ts.map +1 -0
  41. package/dist/recompile/index.js +690 -0
  42. package/dist/release-candidate/index.d.ts +139 -0
  43. package/dist/release-candidate/index.d.ts.map +1 -0
  44. package/dist/release-candidate/index.js +553 -0
  45. package/dist/release-parity/index.d.ts +80 -0
  46. package/dist/release-parity/index.d.ts.map +1 -0
  47. package/dist/release-parity/index.js +1035 -0
  48. package/dist/replay/model-gateway.d.ts +25 -0
  49. package/dist/replay/model-gateway.d.ts.map +1 -0
  50. package/dist/replay/model-gateway.js +166 -0
  51. package/dist/replay/parity.d.ts +110 -0
  52. package/dist/replay/parity.d.ts.map +1 -0
  53. package/dist/replay/parity.js +232 -0
  54. package/dist/rollback/index.d.ts +106 -0
  55. package/dist/rollback/index.d.ts.map +1 -0
  56. package/dist/rollback/index.js +694 -0
  57. package/dist/scenario/parser.d.ts +11 -0
  58. package/dist/scenario/parser.d.ts.map +1 -0
  59. package/dist/scenario/parser.js +490 -0
  60. package/dist/scenario/runner.d.ts +12 -0
  61. package/dist/scenario/runner.d.ts.map +1 -0
  62. package/dist/scenario/runner.js +345 -0
  63. package/dist/scenario/synthetic-world-adapter.d.ts +4 -0
  64. package/dist/scenario/synthetic-world-adapter.d.ts.map +1 -0
  65. package/dist/scenario/synthetic-world-adapter.js +82 -0
  66. package/dist/scenario/time.d.ts +4 -0
  67. package/dist/scenario/time.d.ts.map +1 -0
  68. package/dist/scenario/time.js +45 -0
  69. package/dist/scenario/types.d.ts +149 -0
  70. package/dist/scenario/types.d.ts.map +1 -0
  71. package/dist/scenario/types.js +5 -0
  72. package/dist/spikes/index.d.ts +10 -0
  73. package/dist/spikes/index.d.ts.map +1 -0
  74. package/dist/spikes/index.js +29 -0
  75. package/dist/spikes/k1-ensemble-spread.d.ts +88 -0
  76. package/dist/spikes/k1-ensemble-spread.d.ts.map +1 -0
  77. package/dist/spikes/k1-ensemble-spread.js +396 -0
  78. package/dist/spikes/k2-policy-author.d.ts +25 -0
  79. package/dist/spikes/k2-policy-author.d.ts.map +1 -0
  80. package/dist/spikes/k2-policy-author.js +503 -0
  81. package/dist/spikes/live-refresh.d.ts +150 -0
  82. package/dist/spikes/live-refresh.d.ts.map +1 -0
  83. package/dist/spikes/live-refresh.js +511 -0
  84. package/dist/world/index.d.ts +2 -0
  85. package/dist/world/index.d.ts.map +1 -0
  86. package/dist/world/index.js +17 -0
  87. package/dist/world/synthetic-world.d.ts +104 -0
  88. package/dist/world/synthetic-world.d.ts.map +1 -0
  89. package/dist/world/synthetic-world.js +449 -0
  90. package/package.json +139 -0
@@ -0,0 +1,11 @@
1
+ import { type ReactorScenarioV0 } from "./types";
2
+ export interface ParseScenarioOptionsV0 {
3
+ readonly sourceName?: string;
4
+ }
5
+ export declare class ScenarioParseError extends Error {
6
+ readonly sourceName: string;
7
+ readonly line: number;
8
+ constructor(sourceName: string, line: number, message: string);
9
+ }
10
+ export declare function parseScenarioV0(text: string, options?: ParseScenarioOptionsV0): ReactorScenarioV0;
11
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/scenario/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EASvB,MAAM,SAAS,CAAC;AAMjB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAuBD,qBAAa,kBAAmB,SAAQ,KAAK;IAEzC,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM;gBADZ,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,sBAA2B,GACnC,iBAAiB,CAmDnB"}
@@ -0,0 +1,490 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScenarioParseError = void 0;
4
+ exports.parseScenarioV0 = parseScenarioV0;
5
+ const types_1 = require("./types");
6
+ const time_1 = require("./time");
7
+ const TOP_LEVEL_KEYS = new Set(["scenario", "world", "initial", "initial_instant", "cassette"]);
8
+ const BLOCK_KEYS = new Set(["sources", "script", "expect"]);
9
+ const WORLD_PROFILES = new Set([
10
+ "static",
11
+ "periodic-surprise",
12
+ "adversarial-silent",
13
+ ]);
14
+ const MODEL_REQUEST_KINDS = new Set(["judge", "policy-compile", "spike"]);
15
+ class ScenarioParseError extends Error {
16
+ sourceName;
17
+ line;
18
+ constructor(sourceName, line, message) {
19
+ super(`${sourceName}:${line}: ${message}`);
20
+ this.sourceName = sourceName;
21
+ this.line = line;
22
+ this.name = "ScenarioParseError";
23
+ }
24
+ }
25
+ exports.ScenarioParseError = ScenarioParseError;
26
+ function parseScenarioV0(text, options = {}) {
27
+ const sourceName = options.sourceName ?? "<scenario>";
28
+ const draft = {
29
+ sources: [],
30
+ script: [],
31
+ relationships: [],
32
+ };
33
+ let currentBlock;
34
+ for (const [zeroIndex, rawLine] of text.split(/\r?\n/).entries()) {
35
+ const lineNumber = zeroIndex + 1;
36
+ const line = stripComment(rawLine).trim();
37
+ if (line.length === 0) {
38
+ continue;
39
+ }
40
+ if (line.startsWith("-")) {
41
+ if (currentBlock === undefined) {
42
+ throw parseError(sourceName, lineNumber, "list item is not inside a block");
43
+ }
44
+ parseListItem(draft, currentBlock, line.slice(1).trim(), sourceName, lineNumber);
45
+ continue;
46
+ }
47
+ const topLevel = /^([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*(.*)$/.exec(line);
48
+ if (topLevel === null) {
49
+ throw parseError(sourceName, lineNumber, "expected a top-level key or list item");
50
+ }
51
+ const key = topLevel[1];
52
+ const value = topLevel[2];
53
+ if (key === undefined || value === undefined) {
54
+ throw parseError(sourceName, lineNumber, "malformed top-level key");
55
+ }
56
+ if (BLOCK_KEYS.has(key) && value.length === 0) {
57
+ currentBlock = key;
58
+ continue;
59
+ }
60
+ currentBlock = undefined;
61
+ if (!TOP_LEVEL_KEYS.has(key)) {
62
+ throw parseError(sourceName, lineNumber, `unexpected top-level key ${key}`);
63
+ }
64
+ if (value.length === 0) {
65
+ throw parseError(sourceName, lineNumber, `${key} must have a value`);
66
+ }
67
+ setTopLevel(draft, key, parseInlineScalar(value), sourceName, lineNumber);
68
+ }
69
+ return finalizeScenario(draft, sourceName);
70
+ }
71
+ function parseListItem(draft, block, text, sourceName, lineNumber) {
72
+ if (text.length === 0) {
73
+ throw parseError(sourceName, lineNumber, "list item must not be empty");
74
+ }
75
+ const fields = parseFields(text, sourceName, lineNumber);
76
+ switch (block) {
77
+ case "sources":
78
+ draft.sources.push(parseSource(fields, sourceName, lineNumber));
79
+ return;
80
+ case "script":
81
+ draft.script.push(parseScriptStep(fields, sourceName, lineNumber));
82
+ return;
83
+ case "expect":
84
+ draft.relationships.push(parseRelationship(fields, sourceName, lineNumber));
85
+ return;
86
+ }
87
+ }
88
+ function setTopLevel(draft, key, value, sourceName, lineNumber) {
89
+ switch (key) {
90
+ case "scenario":
91
+ draft.id = requireIdentifier(value, "scenario", sourceName, lineNumber);
92
+ return;
93
+ case "world":
94
+ draft.world = parseWorldConfig(value, sourceName, lineNumber);
95
+ return;
96
+ case "initial":
97
+ case "initial_instant":
98
+ draft.initialInstant = (0, time_1.canonicalScenarioInstant)(value, key);
99
+ return;
100
+ case "cassette":
101
+ draft.cassette = requireNonEmpty(value, "cassette", sourceName, lineNumber);
102
+ return;
103
+ default:
104
+ throw parseError(sourceName, lineNumber, `unexpected top-level key ${key}`);
105
+ }
106
+ }
107
+ function parseSource(fields, sourceName, lineNumber) {
108
+ const idValue = readStringField(fields, "id") ?? readStringField(fields, "source");
109
+ const id = requireIdentifier(idValue, "source id", sourceName, lineNumber);
110
+ const kind = readStringField(fields, "kind");
111
+ const fixtureRef = readStringField(fields, "fixture");
112
+ const extra = omitFields(fields, ["id", "source", "kind", "fixture"]);
113
+ return {
114
+ id,
115
+ ...(kind === undefined ? {} : { kind }),
116
+ ...(fixtureRef === undefined ? {} : { fixture_ref: fixtureRef }),
117
+ fields: freezeFields(extra),
118
+ };
119
+ }
120
+ function parseScriptStep(fields, sourceName, lineNumber) {
121
+ const time = parseStepTime(fields, sourceName, lineNumber);
122
+ const label = readStringField(fields, "label");
123
+ if (fields.has("ingest")) {
124
+ const event = stringFieldValue(fields.get("ingest"), "ingest", sourceName, lineNumber);
125
+ const sourceId = readStringField(fields, "source");
126
+ const extra = omitFields(fields, ["at", "after", "label", "ingest", "source"]);
127
+ return {
128
+ kind: "ingest",
129
+ time,
130
+ event,
131
+ ...(label === undefined ? {} : { label }),
132
+ ...(sourceId === undefined ? {} : { source_id: sourceId }),
133
+ fields: freezeFields(extra),
134
+ };
135
+ }
136
+ if (fields.has("tick")) {
137
+ const tickValue = fields.get("tick");
138
+ const recheckKind = readTickRecheckKind(tickValue, sourceName, lineNumber);
139
+ const extra = omitFields(fields, ["at", "after", "label", "tick"]);
140
+ return {
141
+ kind: "tick",
142
+ time,
143
+ ...(label === undefined ? {} : { label }),
144
+ ...(recheckKind === undefined ? {} : { recheck_kind: recheckKind }),
145
+ fields: freezeFields(extra),
146
+ };
147
+ }
148
+ if (fields.has("read")) {
149
+ const sourceId = stringFieldValue(fields.get("read"), "read", sourceName, lineNumber);
150
+ const extra = omitFields(fields, ["at", "after", "label", "read"]);
151
+ return {
152
+ kind: "read",
153
+ time,
154
+ source_id: sourceId,
155
+ ...(label === undefined ? {} : { label }),
156
+ fields: freezeFields(extra),
157
+ };
158
+ }
159
+ if (fields.has("model")) {
160
+ const requestKind = stringFieldValue(fields.get("model"), "model", sourceName, lineNumber);
161
+ if (!MODEL_REQUEST_KINDS.has(requestKind)) {
162
+ throw parseError(sourceName, lineNumber, "model must be judge, policy-compile, or spike");
163
+ }
164
+ const prompt = readStringField(fields, "prompt");
165
+ if (prompt === undefined) {
166
+ throw parseError(sourceName, lineNumber, "model step requires prompt");
167
+ }
168
+ const extra = omitFields(fields, ["at", "after", "label", "model", "prompt"]);
169
+ return {
170
+ kind: "model",
171
+ time,
172
+ request_kind: requestKind,
173
+ prompt,
174
+ ...(label === undefined ? {} : { label }),
175
+ fields: freezeFields(extra),
176
+ };
177
+ }
178
+ throw parseError(sourceName, lineNumber, "script item must declare ingest, tick, read, or model");
179
+ }
180
+ function parseStepTime(fields, sourceName, lineNumber) {
181
+ const at = readStringField(fields, "at");
182
+ const after = readStringField(fields, "after");
183
+ if (at !== undefined && after !== undefined) {
184
+ throw parseError(sourceName, lineNumber, "script item cannot use both at and after");
185
+ }
186
+ if (at === undefined && after === undefined) {
187
+ throw parseError(sourceName, lineNumber, "script item requires at or after");
188
+ }
189
+ if (at !== undefined) {
190
+ (0, time_1.parseScenarioDurationMs)(at, "at");
191
+ return { at };
192
+ }
193
+ if (after === undefined) {
194
+ throw parseError(sourceName, lineNumber, "script item requires after");
195
+ }
196
+ (0, time_1.parseScenarioDurationMs)(after, "after");
197
+ return { after };
198
+ }
199
+ function readTickRecheckKind(value, sourceName, lineNumber) {
200
+ if (value === undefined || value === true || value === "forecast") {
201
+ return undefined;
202
+ }
203
+ if (value === "evidence-age" || value === "plan-age") {
204
+ return value;
205
+ }
206
+ if (typeof value === "string") {
207
+ throw parseError(sourceName, lineNumber, "tick must be forecast, evidence-age, or plan-age when it carries a value");
208
+ }
209
+ throw parseError(sourceName, lineNumber, "tick value must be a string");
210
+ }
211
+ function parseRelationship(fields, sourceName, lineNumber) {
212
+ const relationship = readStringField(fields, "relationship") ??
213
+ readStringField(fields, "assertion") ??
214
+ readBareRelationship(fields);
215
+ if (relationship === undefined) {
216
+ throw parseError(sourceName, lineNumber, "expect item requires relationship");
217
+ }
218
+ return {
219
+ relationship: requireIdentifier(relationship, "relationship", sourceName, lineNumber),
220
+ fields: freezeFields(omitFields(fields, ["relationship", "assertion", relationship])),
221
+ };
222
+ }
223
+ function readBareRelationship(fields) {
224
+ if (fields.size !== 1) {
225
+ return undefined;
226
+ }
227
+ const first = fields.entries().next().value;
228
+ if (first === undefined) {
229
+ return undefined;
230
+ }
231
+ const [key, value] = first;
232
+ return value === true ? key : undefined;
233
+ }
234
+ function finalizeScenario(draft, sourceName) {
235
+ const missing = [];
236
+ if (draft.id === undefined) {
237
+ missing.push("scenario");
238
+ }
239
+ if (draft.world === undefined) {
240
+ missing.push("world");
241
+ }
242
+ if (draft.initialInstant === undefined) {
243
+ missing.push("initial");
244
+ }
245
+ if (draft.cassette === undefined) {
246
+ missing.push("cassette");
247
+ }
248
+ if (draft.sources.length === 0) {
249
+ missing.push("sources");
250
+ }
251
+ if (draft.script.length === 0) {
252
+ missing.push("script");
253
+ }
254
+ if (missing.length > 0) {
255
+ throw new ScenarioParseError(sourceName, 0, `scenario is missing required field(s): ${missing.join(", ")}`);
256
+ }
257
+ return {
258
+ schema: types_1.REACTOR_SCENARIO_SCHEMA_V0,
259
+ v: types_1.REACTOR_SCENARIO_VERSION_V0,
260
+ id: draft.id,
261
+ world: draft.world,
262
+ initial_instant: draft.initialInstant,
263
+ cassette: { path: draft.cassette },
264
+ sources: Object.freeze([...draft.sources]),
265
+ script: Object.freeze([...draft.script]),
266
+ expect: {
267
+ relationships: Object.freeze([...draft.relationships]),
268
+ },
269
+ };
270
+ }
271
+ function parseWorldConfig(value, sourceName, lineNumber) {
272
+ const tokens = tokenize(value, sourceName, lineNumber);
273
+ const profileToken = tokens[0];
274
+ if (profileToken === undefined) {
275
+ throw parseError(sourceName, lineNumber, "world must have a profile");
276
+ }
277
+ if (profileToken.includes("=") || profileToken.includes(":")) {
278
+ throw parseError(sourceName, lineNumber, "world profile must be the first bare value");
279
+ }
280
+ if (!WORLD_PROFILES.has(profileToken)) {
281
+ throw parseError(sourceName, lineNumber, "world must be one of static, periodic-surprise, adversarial-silent");
282
+ }
283
+ const fields = parseFields(tokens.slice(1).join(" "), sourceName, lineNumber);
284
+ const everyEvents = fields.get("every_events");
285
+ if (everyEvents !== undefined) {
286
+ if (typeof everyEvents !== "number" ||
287
+ !Number.isSafeInteger(everyEvents) ||
288
+ everyEvents <= 0) {
289
+ throw parseError(sourceName, lineNumber, "world every_events must be a positive safe integer");
290
+ }
291
+ if (profileToken !== "periodic-surprise") {
292
+ throw parseError(sourceName, lineNumber, "world every_events only applies to periodic-surprise");
293
+ }
294
+ }
295
+ if (fields.size > (everyEvents === undefined ? 0 : 1)) {
296
+ throw parseError(sourceName, lineNumber, "world has unsupported field(s)");
297
+ }
298
+ return everyEvents === undefined
299
+ ? { profile: profileToken }
300
+ : {
301
+ profile: profileToken,
302
+ every_events: everyEvents,
303
+ };
304
+ }
305
+ function parseFields(text, sourceName, lineNumber) {
306
+ const fields = new Map();
307
+ const tokens = tokenize(text, sourceName, lineNumber);
308
+ let index = 0;
309
+ while (index < tokens.length) {
310
+ const token = tokens[index];
311
+ if (token === undefined) {
312
+ break;
313
+ }
314
+ const inline = splitInlineKeyValue(token);
315
+ if (inline !== undefined) {
316
+ setField(fields, inline.key, parseFieldValue(inline.value), sourceName, lineNumber);
317
+ index += 1;
318
+ continue;
319
+ }
320
+ if (token.endsWith(":") && token.length > 1) {
321
+ const key = token.slice(0, -1);
322
+ const next = tokens[index + 1];
323
+ if (next === undefined || isKeyToken(next)) {
324
+ setField(fields, key, true, sourceName, lineNumber);
325
+ index += 1;
326
+ continue;
327
+ }
328
+ setField(fields, key, parseFieldValue(next), sourceName, lineNumber);
329
+ index += 2;
330
+ continue;
331
+ }
332
+ setField(fields, token, true, sourceName, lineNumber);
333
+ index += 1;
334
+ }
335
+ return fields;
336
+ }
337
+ function splitInlineKeyValue(token) {
338
+ const equalsIndex = token.indexOf("=");
339
+ if (equalsIndex > 0) {
340
+ return {
341
+ key: token.slice(0, equalsIndex),
342
+ value: token.slice(equalsIndex + 1),
343
+ };
344
+ }
345
+ const colonIndex = token.indexOf(":");
346
+ if (colonIndex > 0 && colonIndex < token.length - 1) {
347
+ return {
348
+ key: token.slice(0, colonIndex),
349
+ value: token.slice(colonIndex + 1),
350
+ };
351
+ }
352
+ return undefined;
353
+ }
354
+ function tokenize(text, sourceName, lineNumber) {
355
+ const tokens = [];
356
+ let current = "";
357
+ let quote;
358
+ for (let index = 0; index < text.length; index += 1) {
359
+ const char = text[index];
360
+ if (char === undefined) {
361
+ continue;
362
+ }
363
+ if (quote !== undefined) {
364
+ if (char === quote) {
365
+ quote = undefined;
366
+ }
367
+ else {
368
+ current += char;
369
+ }
370
+ continue;
371
+ }
372
+ if (char === "'" || char === "\"") {
373
+ quote = char;
374
+ continue;
375
+ }
376
+ if (/\s/.test(char)) {
377
+ if (current.length > 0) {
378
+ tokens.push(current);
379
+ current = "";
380
+ }
381
+ continue;
382
+ }
383
+ current += char;
384
+ }
385
+ if (quote !== undefined) {
386
+ throw parseError(sourceName, lineNumber, "unterminated quoted value");
387
+ }
388
+ if (current.length > 0) {
389
+ tokens.push(current);
390
+ }
391
+ return tokens;
392
+ }
393
+ function stripComment(line) {
394
+ let quote;
395
+ for (let index = 0; index < line.length; index += 1) {
396
+ const char = line[index];
397
+ if (char === undefined) {
398
+ continue;
399
+ }
400
+ if (quote !== undefined) {
401
+ if (char === quote) {
402
+ quote = undefined;
403
+ }
404
+ continue;
405
+ }
406
+ if (char === "'" || char === "\"") {
407
+ quote = char;
408
+ continue;
409
+ }
410
+ if (char === "#") {
411
+ return line.slice(0, index);
412
+ }
413
+ }
414
+ return line;
415
+ }
416
+ function isKeyToken(token) {
417
+ return token.endsWith(":") || /^[A-Za-z_][A-Za-z0-9_-]*(?:=|:).+$/.test(token);
418
+ }
419
+ function parseFieldValue(value) {
420
+ const scalar = parseInlineScalar(value);
421
+ if (scalar === "true") {
422
+ return true;
423
+ }
424
+ if (scalar === "false") {
425
+ return false;
426
+ }
427
+ if (/^-?\d+$/.test(scalar)) {
428
+ const parsed = Number(scalar);
429
+ if (Number.isSafeInteger(parsed)) {
430
+ return parsed;
431
+ }
432
+ }
433
+ return scalar;
434
+ }
435
+ function parseInlineScalar(value) {
436
+ const trimmed = value.trim();
437
+ if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) ||
438
+ (trimmed.startsWith("'") && trimmed.endsWith("'"))) {
439
+ return trimmed.slice(1, -1);
440
+ }
441
+ return trimmed;
442
+ }
443
+ function setField(fields, key, value, sourceName, lineNumber) {
444
+ if (!/^[A-Za-z_][A-Za-z0-9_-]*$/.test(key)) {
445
+ throw parseError(sourceName, lineNumber, `invalid field key ${key}`);
446
+ }
447
+ if (fields.has(key)) {
448
+ throw parseError(sourceName, lineNumber, `duplicate field key ${key}`);
449
+ }
450
+ fields.set(key, value);
451
+ }
452
+ function readStringField(fields, key) {
453
+ const value = fields.get(key);
454
+ return typeof value === "string" ? value : undefined;
455
+ }
456
+ function stringFieldValue(value, key, sourceName, lineNumber) {
457
+ if (typeof value !== "string") {
458
+ throw parseError(sourceName, lineNumber, `${key} must be a string value`);
459
+ }
460
+ return requireNonEmpty(value, key, sourceName, lineNumber);
461
+ }
462
+ function omitFields(fields, omitted) {
463
+ const omittedKeys = new Set(omitted);
464
+ const result = {};
465
+ for (const [key, value] of fields.entries()) {
466
+ if (!omittedKeys.has(key)) {
467
+ result[key] = value;
468
+ }
469
+ }
470
+ return result;
471
+ }
472
+ function freezeFields(fields) {
473
+ return Object.freeze({ ...fields });
474
+ }
475
+ function requireIdentifier(value, label, sourceName, lineNumber) {
476
+ const id = requireNonEmpty(value, label, sourceName, lineNumber);
477
+ if (!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(id)) {
478
+ throw parseError(sourceName, lineNumber, `${label} must use letters, numbers, dots, underscores, colons, or dashes`);
479
+ }
480
+ return id;
481
+ }
482
+ function requireNonEmpty(value, label, sourceName, lineNumber) {
483
+ if (value === undefined || value.length === 0) {
484
+ throw parseError(sourceName, lineNumber, `${label} must be non-empty`);
485
+ }
486
+ return value;
487
+ }
488
+ function parseError(sourceName, lineNumber, message) {
489
+ return new ScenarioParseError(sourceName, lineNumber, message);
490
+ }
@@ -0,0 +1,12 @@
1
+ import type { ReactorModelGatewayAdapterV0 } from "@openprose/reactor/sdk";
2
+ import { type ReactorScenarioV0, type ScenarioClockAdapterV0, type ScenarioRunReceiptV0, type ScenarioRunnerReactorV0, type ScenarioRunnerStorageV0, type ScenarioWorldAdapterV0 } from "./types";
3
+ export interface RunScenarioInputV0 {
4
+ readonly scenario: ReactorScenarioV0;
5
+ readonly clock: ScenarioClockAdapterV0;
6
+ readonly world: ScenarioWorldAdapterV0;
7
+ readonly modelGateway: ReactorModelGatewayAdapterV0;
8
+ readonly storage?: ScenarioRunnerStorageV0;
9
+ readonly reactor?: ScenarioRunnerReactorV0;
10
+ }
11
+ export declare function runScenarioV0(input: RunScenarioInputV0): ScenarioRunReceiptV0;
12
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/scenario/runner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,4BAA4B,EAE7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAG3B,KAAK,oBAAoB,EAEzB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAG5B,KAAK,sBAAsB,EAG5B,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;IACvC,QAAQ,CAAC,YAAY,EAAE,4BAA4B,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;CAC5C;AAkBD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,kBAAkB,GACxB,oBAAoB,CAqCtB"}