@spine-event-engine/testing 2.0.0-snapshot.21 → 2.0.0-snapshot.23

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.
@@ -0,0 +1,607 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ import { clone, create, toBinary, toJsonString } from "@bufbuild/protobuf";
15
+ import { createHash } from "node:crypto";
16
+ import { AnyMessages } from "@spine-event-engine/core";
17
+ import { assertAiOutcomeContext, deriveOutputSchema, } from "@spine-event-engine/ai/spi/adapter";
18
+ import { AiAttemptIdSchema, AiContentDigestSchema, AiDiagnosticIdSchema, AiOutcome, AiUsageSchema, DecisionAnswerSchema, DecisionAlternativeKeySchema, DecisionDistributionSchema, DecisionProbabilitySchema, DecisionQuestionIdSchema, DecisionQuestionKind, DecisionQuestionSchema, DecisionChoiceSchema, DecisionRequestSchema, DecisionResponseSchema, GenerationRequestSchema, GenerationResponseSchema, } from "@spine-event-engine/proto/agent";
19
+ /**
20
+ * Renders the exact scripted generation input and correction feedback.
21
+ *
22
+ * @param record Physical request observation.
23
+ * @returns Persistable prepared prompt JSON.
24
+ */
25
+ const generationPrompt = (record) => JSON.stringify({
26
+ input: record.inputJson,
27
+ ...(record.correctionCandidate !== undefined
28
+ ? { correction: { candidate: record.correctionCandidate, issues: record.correctionIssues } }
29
+ : {}),
30
+ });
31
+ /**
32
+ * One externally released response gate.
33
+ */
34
+ class Gate {
35
+ #release;
36
+ #ready = new Promise((resolve) => {
37
+ this.#release = resolve;
38
+ });
39
+ /**
40
+ * Completes the pending response.
41
+ */
42
+ release() {
43
+ this.#release();
44
+ }
45
+ /**
46
+ * Awaits gate release or cancellation.
47
+ *
48
+ * @param signal Signal for this operation.
49
+ * @returns Completion after release or cancellation.
50
+ */
51
+ async wait(signal) {
52
+ if (signal.aborted)
53
+ throw new Error("Scripted AI request cancelled.");
54
+ let abort;
55
+ const cancelled = new Promise((_resolve, reject) => {
56
+ abort = () => {
57
+ reject(new Error("Scripted AI request cancelled."));
58
+ };
59
+ signal.addEventListener("abort", abort, { once: true });
60
+ });
61
+ try {
62
+ await Promise.race([this.#ready, cancelled]);
63
+ }
64
+ finally {
65
+ signal.removeEventListener("abort", abort);
66
+ }
67
+ }
68
+ }
69
+ /**
70
+ * Writes detached scripted responses for one validated capability.
71
+ *
72
+ * @typeParam O Generated output descriptor.
73
+ */
74
+ class QueueResponses {
75
+ #queue;
76
+ #output;
77
+ /**
78
+ * Creates a queue writer for a capability.
79
+ *
80
+ * @param queue Queue for this operation.
81
+ * @param output Output for this operation.
82
+ */
83
+ constructor(queue, output) {
84
+ this.#queue = queue;
85
+ this.#output = output;
86
+ }
87
+ /**
88
+ * Queues a serialized typed generation candidate.
89
+ *
90
+ * @param value Value for this operation.
91
+ * @returns This response queue.
92
+ */
93
+ respondWith(value) {
94
+ this.requireKind("generation");
95
+ this.#queue.scripts.push({ kind: "text", text: toJsonString(this.#output, value) });
96
+ return this;
97
+ }
98
+ /**
99
+ * Queues exact raw generation text.
100
+ *
101
+ * @param text Text for this operation.
102
+ * @returns This response queue.
103
+ */
104
+ respondWithText(text) {
105
+ this.requireKind("generation");
106
+ this.#queue.scripts.push({ kind: "text", text });
107
+ return this;
108
+ }
109
+ /**
110
+ * Queues defensively copied decision answers.
111
+ *
112
+ * @param result Result for this operation.
113
+ * @returns This response queue.
114
+ */
115
+ respondWithDecision(result) {
116
+ this.requireKind("decision");
117
+ this.#queue.scripts.push({ kind: "decision", result: structuredClone(result) });
118
+ return this;
119
+ }
120
+ /**
121
+ * Queues a safe failure category without retaining its supplied ID.
122
+ *
123
+ * @param failure Failure for this operation.
124
+ * @returns This response queue.
125
+ */
126
+ failWith(failure) {
127
+ this.#queue.scripts.push({
128
+ kind: "failure",
129
+ code: failure.code,
130
+ retryable: failure.retryableByNewSignal,
131
+ });
132
+ return this;
133
+ }
134
+ /**
135
+ * Queues a provider refusal.
136
+ *
137
+ * @returns This response queue.
138
+ */
139
+ refuse() {
140
+ this.#queue.scripts.push({ kind: "failure", code: "REFUSED", retryable: false });
141
+ return this;
142
+ }
143
+ /**
144
+ * Attaches immutable usage to the latest response.
145
+ *
146
+ * @param usage Usage for this operation.
147
+ * @returns This response queue.
148
+ */
149
+ withUsage(usage) {
150
+ const last = this.#queue.scripts.at(-1);
151
+ if (last === undefined || last.kind === "delay")
152
+ throw new TypeError("Usage requires a queued response.");
153
+ last.usage = clone(AiUsageSchema, usage);
154
+ return this;
155
+ }
156
+ /**
157
+ * Queues one externally released response pause.
158
+ *
159
+ * @returns The release gate.
160
+ */
161
+ delay() {
162
+ const gate = new Gate();
163
+ this.#queue.scripts.push({ kind: "delay", gate });
164
+ return gate;
165
+ }
166
+ /**
167
+ * Validates the scripted response kind.
168
+ *
169
+ * @param kind Kind for this operation.
170
+ */
171
+ requireKind(kind) {
172
+ if (this.#queue.definition.kind !== kind)
173
+ throw new TypeError(`${kind === "generation" ? "Typed generation response" : "Decision answer"} requires a ${kind} backend.`);
174
+ }
175
+ }
176
+ /**
177
+ * Constructs scripted requests and crosses the same runtime barriers as adapters.
178
+ */
179
+ export const ScriptedAttempts = Object.freeze({
180
+ /**
181
+ * Returns a capability key without conflating revisions.
182
+ *
183
+ * @param name Name for this operation.
184
+ * @param version Version for this operation.
185
+ * @returns Revision-qualified capability key.
186
+ */
187
+ key(name, version) {
188
+ return `${String(name.length)}:${name}${String(version.length)}:${version}`;
189
+ },
190
+ /**
191
+ * Creates a queue writer with defensive snapshots.
192
+ *
193
+ * @typeParam O Generated output descriptor.
194
+ * @param queue Queue for this operation.
195
+ * @param output Output for this operation.
196
+ * @returns Queue writer for this capability.
197
+ */
198
+ responses(queue, output) {
199
+ return new QueueResponses(queue, output);
200
+ },
201
+ /**
202
+ * Records bounded prepared input and advertised tool names.
203
+ *
204
+ * @param request Request for this operation.
205
+ * @param attempt Attempt for this operation.
206
+ * @param prior Prior for this operation.
207
+ * @returns Mutable internal request record.
208
+ */
209
+ record(request, attempt, prior) {
210
+ const inputJson = toJsonString(request.definition.input, request.input);
211
+ if (request.definition.limits.maxInputBytes !== undefined &&
212
+ Buffer.byteLength(inputJson, "utf8") > request.definition.limits.maxInputBytes)
213
+ throw new RangeError("Scripted prepared input exceeds the capability byte limit.");
214
+ return {
215
+ operation: request.operationId.value,
216
+ modelName: request.definition.name,
217
+ call: request.call,
218
+ attempt,
219
+ inputJson,
220
+ ...(prior?.ticketId ? { corrects: prior.ticketId } : {}),
221
+ ...(prior?.candidateText !== undefined ? { correctionCandidate: prior.candidateText } : {}),
222
+ validationIssues: [],
223
+ correctionIssues: prior?.validationIssues.map((issue) => ({ ...issue })) ?? [],
224
+ toolNames: request.definition.kind === "generation"
225
+ ? Object.freeze((request.definition.tools ?? []).map((tool) => `${tool.server}/${tool.tool}`))
226
+ : Object.freeze([]),
227
+ };
228
+ },
229
+ /**
230
+ * Returns an immutable observation without sharing queued objects.
231
+ *
232
+ * @param record Record for this operation.
233
+ * @returns Immutable physical-request observation.
234
+ */
235
+ snapshot(record) {
236
+ return Object.freeze({
237
+ modelName: record.modelName,
238
+ call: record.call,
239
+ attempt: record.attempt,
240
+ inputJson: record.inputJson,
241
+ ...(record.corrects ? { corrects: record.corrects } : {}),
242
+ validationIssues: Object.freeze(record.validationIssues.map((issue) => Object.freeze({ ...issue }))),
243
+ correctionIssues: Object.freeze(record.correctionIssues.map((issue) => Object.freeze({ ...issue }))),
244
+ toolNames: Object.freeze([...record.toolNames]),
245
+ });
246
+ },
247
+ /**
248
+ * Executes one physical scripted request after durable reservation.
249
+ *
250
+ * @param request Request for this operation.
251
+ * @param record Record for this operation.
252
+ * @param queue Queue for this operation.
253
+ * @returns Admitted output or recorded failure.
254
+ */
255
+ async execute(request, record, queue) {
256
+ const prepared = this.prepare(request, record);
257
+ const ticket = await request.control.beginAttempt(prepared);
258
+ record.ticketId = ticket.id;
259
+ if ("kind" in ticket) {
260
+ record.validationIssues = ticket.issues ?? [];
261
+ return this.replay(request, ticket);
262
+ }
263
+ const bytes = toBinary(prepared.kind === "generation" ? GenerationRequestSchema : DecisionRequestSchema, prepared.content).length;
264
+ await request.control.reserveTransport(ticket.id, bytes, ticket.maxOutputBytes);
265
+ record.dispatched = true;
266
+ let script = queue?.scripts.shift();
267
+ const gates = [];
268
+ while (script?.kind === "delay") {
269
+ gates.push(script.gate);
270
+ script = queue?.scripts.shift();
271
+ }
272
+ for (const gate of gates)
273
+ await gate.wait(ticket.signal);
274
+ if (!script) {
275
+ record.unexpected = true;
276
+ return this.failure(request, ticket, "UNAVAILABLE", true);
277
+ }
278
+ if (script.kind === "failure")
279
+ return this.failure(request, ticket, script.code, script.retryable, script.usage);
280
+ if (script.kind === "text")
281
+ return this.generation(request, ticket, record, script);
282
+ return this.decision(request, ticket, record, script);
283
+ },
284
+ /**
285
+ * Restores a saved typed response without consuming a queued physical script.
286
+ *
287
+ * @param request Selected scripted execution.
288
+ * @param saved Durable response and matching original failure, if any.
289
+ * @returns Saved admitted output or exact recorded failure.
290
+ */
291
+ replay(request, saved) {
292
+ const response = saved.response;
293
+ if (request.definition.kind === "generation" &&
294
+ response.$typeName !== "spine.ts.agent.GenerationResponse")
295
+ throw new Error("Saved scripted response has a changed request kind.");
296
+ if (request.definition.kind === "decision" &&
297
+ response.$typeName !== "spine.ts.agent.DecisionResponse")
298
+ throw new Error("Saved scripted response has a changed request kind.");
299
+ assertAiOutcomeContext(response);
300
+ if (response.outcome !== AiOutcome.ADMITTED)
301
+ return this.replayFailure(response, saved.failure);
302
+ if (!response.admittedOutput)
303
+ throw new Error("Saved scripted output is missing.");
304
+ const value = AnyMessages.unpack(response.admittedOutput, request.definition.output);
305
+ if (!value)
306
+ throw new Error("Saved scripted response has a changed output type.");
307
+ return { ok: true, value };
308
+ },
309
+ /**
310
+ * Requires the original persisted failure category and matching diagnostic.
311
+ *
312
+ * @param response Saved terminal response.
313
+ * @param failure Original persisted failure, when available.
314
+ * @returns Exact failure without inventing retryability.
315
+ */
316
+ replayFailure(response, failure) {
317
+ if (![AiOutcome.INVALID_OUTPUT, AiOutcome.FAILED, AiOutcome.REFUSED].includes(response.outcome) ||
318
+ !failure ||
319
+ response.diagnosticId?.value !== failure.diagnosticId)
320
+ throw new Error("Saved scripted failure cannot be reconstructed.");
321
+ if (response.outcome === AiOutcome.INVALID_OUTPUT && failure.code !== "INVALID_OUTPUT")
322
+ throw new Error("Saved scripted failure category changed.");
323
+ if (response.outcome === AiOutcome.REFUSED && failure.code !== "REFUSED")
324
+ throw new Error("Saved scripted failure category changed.");
325
+ if (response.outcome === AiOutcome.FAILED &&
326
+ (failure.code === "INVALID_OUTPUT" || failure.code === "REFUSED"))
327
+ throw new Error("Saved scripted failure category changed.");
328
+ return { ok: false, failure };
329
+ },
330
+ /**
331
+ * Materializes the exact typed generation or decision request.
332
+ *
333
+ * @param request Request for this operation.
334
+ * @param record Record for this operation.
335
+ * @returns Typed model-facing request.
336
+ */
337
+ prepare(request, record) {
338
+ const definition = request.definition;
339
+ const input = AnyMessages.pack(definition.input, request.input);
340
+ if (definition.kind === "decision") {
341
+ const questions = Object.entries(definition.questions).map(([id, question]) => this.question(id, question));
342
+ const digest = this.digest(JSON.stringify({ input: record.inputJson, questions }));
343
+ return {
344
+ kind: "decision",
345
+ content: create(DecisionRequestSchema, { input, questions, digest }),
346
+ };
347
+ }
348
+ const outputSchemaJson = JSON.stringify(deriveOutputSchema(definition.output));
349
+ const promptJson = generationPrompt(record);
350
+ const digest = this.digest(JSON.stringify({ instructions: definition.instructions, outputSchemaJson, promptJson }));
351
+ return {
352
+ kind: "generation",
353
+ content: create(GenerationRequestSchema, {
354
+ input,
355
+ instructions: definition.instructions,
356
+ outputSchemaJson,
357
+ promptJson,
358
+ digest,
359
+ ...(record.corrects
360
+ ? { corrects: create(AiAttemptIdSchema, { value: record.corrects }) }
361
+ : {}),
362
+ }),
363
+ };
364
+ },
365
+ /**
366
+ * Creates one declared decision question.
367
+ *
368
+ * @param id Id for this operation.
369
+ * @param question Question for this operation.
370
+ * @returns Typed question record.
371
+ */
372
+ question(id, question) {
373
+ const kind = question.type === "choice"
374
+ ? DecisionQuestionKind.CHOICE
375
+ : question.type === "score"
376
+ ? DecisionQuestionKind.SCORE
377
+ : DecisionQuestionKind.BOOLEAN;
378
+ return create(DecisionQuestionSchema, {
379
+ id: create(DecisionQuestionIdSchema, { value: id }),
380
+ kind,
381
+ instructions: question.instructions,
382
+ ...(question.type === "choice"
383
+ ? {
384
+ choices: Object.entries(question.criteria).map(([key, description]) => create(DecisionChoiceSchema, {
385
+ key: create(DecisionAlternativeKeySchema, { value: key }),
386
+ description,
387
+ })),
388
+ }
389
+ : {}),
390
+ ...(question.type === "score" ? { rubric: [...question.criteria] } : {}),
391
+ });
392
+ },
393
+ /**
394
+ * Returns the SHA-256 digest of content.
395
+ *
396
+ * @param value Value for this operation.
397
+ * @returns SHA-256 content digest.
398
+ */
399
+ digest(value) {
400
+ return create(AiContentDigestSchema, {
401
+ value: createHash("sha256").update(value).digest("hex"),
402
+ });
403
+ },
404
+ /**
405
+ * Records safe failure with a runtime-assigned diagnostic ID.
406
+ *
407
+ * @param request Request for this operation.
408
+ * @param ticket Ticket for this operation.
409
+ * @param code Code for this operation.
410
+ * @param retryable Retryable for this operation.
411
+ * @param usage Usage for this operation.
412
+ * @returns Runtime-recorded safe failure.
413
+ */
414
+ async failure(request, ticket, code, retryable, usage) {
415
+ const failure = await request.control.recordFailure(code, retryable);
416
+ const response = request.definition.kind === "generation"
417
+ ? create(GenerationResponseSchema, {
418
+ outcome: code === "REFUSED" ? AiOutcome.REFUSED : AiOutcome.FAILED,
419
+ diagnosticId: create(AiDiagnosticIdSchema, { value: failure.diagnosticId }),
420
+ ...(usage ? { usage } : {}),
421
+ })
422
+ : create(DecisionResponseSchema, {
423
+ outcome: code === "REFUSED" ? AiOutcome.REFUSED : AiOutcome.FAILED,
424
+ diagnosticId: create(AiDiagnosticIdSchema, { value: failure.diagnosticId }),
425
+ ...(usage ? { usage } : {}),
426
+ });
427
+ await request.control.finishAttempt({
428
+ ticketId: ticket.id,
429
+ response,
430
+ ...(usage ? { usage } : {}),
431
+ });
432
+ return { ok: false, failure };
433
+ },
434
+ /**
435
+ * Validates and journals one generation candidate.
436
+ *
437
+ * @param request Request for this operation.
438
+ * @param ticket Ticket for this operation.
439
+ * @param record Record for this operation.
440
+ * @param script Script for this operation.
441
+ * @returns Validated output or recorded failure.
442
+ */
443
+ async generation(request, ticket, record, script) {
444
+ if (request.definition.kind !== "generation")
445
+ throw new TypeError("Generation script used for decision backend.");
446
+ const bytes = Buffer.byteLength(script.text, "utf8");
447
+ request.control.onReceived(ticket.id, bytes);
448
+ if (ticket.maxOutputBytes !== undefined && bytes > ticket.maxOutputBytes)
449
+ return this.failure(request, ticket, "BUDGET_EXCEEDED", false, script.usage);
450
+ record.candidateText = script.text;
451
+ const admitted = await request.control.admitGeneration(script.text, request.definition, request.input);
452
+ record.validationIssues = admitted.ok ? [] : admitted.issues;
453
+ const failure = admitted.ok
454
+ ? undefined
455
+ : await request.control.recordFailure("INVALID_OUTPUT", false);
456
+ const response = this.generationReply(request, script, admitted, failure);
457
+ await request.control.finishAttempt({
458
+ ticketId: ticket.id,
459
+ receivedBytes: bytes,
460
+ response,
461
+ ...(!admitted.ok ? { issues: admitted.issues } : {}),
462
+ ...(script.usage ? { usage: script.usage } : {}),
463
+ });
464
+ if (admitted.ok)
465
+ return { ok: true, value: admitted.value };
466
+ if (failure === undefined)
467
+ throw new Error("Scripted failure diagnostic was not recorded.");
468
+ return { ok: false, failure };
469
+ },
470
+ /**
471
+ * Validates and journals one non-generative decision.
472
+ *
473
+ * @param request Request for this operation.
474
+ * @param ticket Ticket for this operation.
475
+ * @param record Record for this operation.
476
+ * @param script Script for this operation.
477
+ * @returns Validated output or recorded failure.
478
+ */
479
+ async decision(request, ticket, record, script) {
480
+ if (request.definition.kind !== "decision")
481
+ throw new TypeError("Decision script used for generation backend.");
482
+ const text = JSON.stringify(script.result);
483
+ const bytes = Buffer.byteLength(text, "utf8");
484
+ request.control.onReceived(ticket.id, bytes);
485
+ if (ticket.maxOutputBytes !== undefined && bytes > ticket.maxOutputBytes)
486
+ return this.failure(request, ticket, "BUDGET_EXCEEDED", false, script.usage);
487
+ const admitted = await request.control.admitDecision(script.result, request.definition, request.input);
488
+ record.validationIssues = admitted.ok ? [] : admitted.issues;
489
+ const failure = admitted.ok
490
+ ? undefined
491
+ : await request.control.recordFailure("INVALID_OUTPUT", false);
492
+ const response = this.decisionReply(request, script, admitted, failure);
493
+ await request.control.finishAttempt({
494
+ ticketId: ticket.id,
495
+ receivedBytes: bytes,
496
+ response,
497
+ ...(!admitted.ok ? { issues: admitted.issues } : {}),
498
+ ...(script.usage ? { usage: script.usage } : {}),
499
+ });
500
+ if (admitted.ok)
501
+ return { ok: true, value: admitted.value };
502
+ if (failure === undefined)
503
+ throw new Error("Scripted failure diagnostic was not recorded.");
504
+ return { ok: false, failure };
505
+ },
506
+ /**
507
+ * Builds a generation response for the journal.
508
+ *
509
+ * @param request Request for this operation.
510
+ * @param script Script for this operation.
511
+ * @param admitted Admitted for this operation.
512
+ * @param failure Failure for this operation.
513
+ * @returns Journal-ready generation response.
514
+ */
515
+ generationReply(request, script, admitted, failure) {
516
+ return create(GenerationResponseSchema, {
517
+ rawOutput: script.text,
518
+ outcome: admitted.ok ? AiOutcome.ADMITTED : AiOutcome.INVALID_OUTPUT,
519
+ ...(admitted.ok
520
+ ? { admittedOutput: AnyMessages.pack(request.definition.output, admitted.value) }
521
+ : {}),
522
+ ...(failure
523
+ ? { diagnosticId: create(AiDiagnosticIdSchema, { value: failure.diagnosticId }) }
524
+ : {}),
525
+ ...(script.usage ? { usage: script.usage } : {}),
526
+ digest: this.digest(script.text),
527
+ });
528
+ },
529
+ /**
530
+ * Builds a decision response for the journal.
531
+ *
532
+ * @param request Request for this operation.
533
+ * @param script Script for this operation.
534
+ * @param admitted Admitted for this operation.
535
+ * @param failure Failure for this operation.
536
+ * @returns Journal-ready decision response.
537
+ */
538
+ decisionReply(request, script, admitted, failure) {
539
+ return create(DecisionResponseSchema, {
540
+ answers: Object.entries(script.result.answers).map(([id, answer]) => this.answer(id, answer)),
541
+ outcome: admitted.ok ? AiOutcome.ADMITTED : AiOutcome.INVALID_OUTPUT,
542
+ ...(admitted.ok
543
+ ? { admittedOutput: AnyMessages.pack(request.definition.output, admitted.value) }
544
+ : {}),
545
+ ...(failure
546
+ ? { diagnosticId: create(AiDiagnosticIdSchema, { value: failure.diagnosticId }) }
547
+ : {}),
548
+ ...(script.usage ? { usage: script.usage } : {}),
549
+ });
550
+ },
551
+ /**
552
+ * Builds one provider answer for the decision journal.
553
+ *
554
+ * @param id Id for this operation.
555
+ * @param answer Answer for this operation.
556
+ * @returns Typed provider answer.
557
+ */
558
+ answer(id, answer) {
559
+ const kind = answer.type === "choice"
560
+ ? DecisionQuestionKind.CHOICE
561
+ : answer.type === "score"
562
+ ? DecisionQuestionKind.SCORE
563
+ : DecisionQuestionKind.BOOLEAN;
564
+ const value = this.answerValue(answer);
565
+ const probabilities = answer.type === "boolean" ? undefined : answer.probabilities;
566
+ return create(DecisionAnswerSchema, {
567
+ id: create(DecisionQuestionIdSchema, { value: id }),
568
+ kind,
569
+ value,
570
+ ...(probabilities ? { distribution: this.distribution(probabilities) } : {}),
571
+ ...(answer.type !== "boolean" && answer.confidence !== undefined
572
+ ? { confidence: answer.confidence }
573
+ : {}),
574
+ });
575
+ },
576
+ /**
577
+ * Maps one answer kind to its Proto oneof.
578
+ *
579
+ * @param answer Answer for this operation.
580
+ * @returns Typed answer oneof.
581
+ */
582
+ answerValue(answer) {
583
+ if (answer.type === "choice")
584
+ return {
585
+ case: "choice",
586
+ value: create(DecisionAlternativeKeySchema, { value: answer.choice }),
587
+ };
588
+ if (answer.type === "score")
589
+ return { case: "score", value: answer.score };
590
+ return { case: "booleanProbability", value: answer.probability };
591
+ },
592
+ /**
593
+ * Builds a provider answer distribution.
594
+ *
595
+ * @param probabilities Probabilities for this operation.
596
+ * @returns Typed full distribution.
597
+ */
598
+ distribution(probabilities) {
599
+ return create(DecisionDistributionSchema, {
600
+ probabilities: Object.entries(probabilities).map(([key, probability]) => create(DecisionProbabilitySchema, {
601
+ key: create(DecisionAlternativeKeySchema, { value: key }),
602
+ probability,
603
+ })),
604
+ });
605
+ },
606
+ });
607
+ //# sourceMappingURL=scripted-attempts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scripted-attempts.js","sourceRoot":"","sources":["../../src/ai-test/scripted-attempts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAqB,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAsB,MAAM,0BAA0B,CAAC;AAQ3E,OAAO,EACL,sBAAsB,EACtB,kBAAkB,GAOnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GAQzB,MAAM,iCAAiC,CAAC;AA6FzC;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,CAAC,MAAqB,EAAU,EAAE,CACz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