@basein/runner 0.3.17 → 0.3.19

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 (51) hide show
  1. package/dist/bin/bir-hooks.d.ts +11 -8
  2. package/dist/bin/bir-hooks.js +11 -8
  3. package/dist/bin/bir-scenario.d.ts +5 -1
  4. package/dist/bin/bir-scenario.js +155 -5
  5. package/dist/bin/bir.js +22 -9
  6. package/dist/bin/investigate.d.ts +9 -0
  7. package/dist/bin/investigate.js +26 -12
  8. package/dist/bin/scenario-edit.d.ts +7 -0
  9. package/dist/bin/scenario-edit.js +19 -2
  10. package/dist/bin/scenario-liveness.d.ts +12 -1
  11. package/dist/bin/scenario-liveness.js +8 -4
  12. package/dist/bin/setup.js +3 -3
  13. package/dist/control/client.d.ts +5 -0
  14. package/dist/control/client.js +7 -0
  15. package/dist/control/ensure-hook.d.ts +14 -3
  16. package/dist/control/ensure-hook.js +18 -5
  17. package/dist/control/recorder-main.d.ts +15 -0
  18. package/dist/control/recorder-main.js +33 -8
  19. package/dist/control/server.d.ts +192 -13
  20. package/dist/control/server.js +819 -41
  21. package/dist/control/transcript.d.ts +19 -0
  22. package/dist/control/transcript.js +57 -0
  23. package/dist/proxy/intercept.js +13 -0
  24. package/dist/proxy/session.d.ts +23 -0
  25. package/dist/proxy/session.js +71 -3
  26. package/dist/record/recorder.d.ts +156 -2
  27. package/dist/record/recorder.js +9 -0
  28. package/dist/record/remote-recorder.d.ts +59 -1
  29. package/dist/record/remote-recorder.js +297 -20
  30. package/dist/record/switchable-recorder.js +6 -0
  31. package/dist/replay/bundle.d.ts +8 -0
  32. package/dist/replay/bundle.js +20 -6
  33. package/dist/replay/condition-words.d.ts +28 -0
  34. package/dist/replay/condition-words.js +59 -0
  35. package/dist/replay/controller.d.ts +78 -7
  36. package/dist/replay/controller.js +318 -62
  37. package/dist/replay/derive.d.ts +15 -0
  38. package/dist/replay/derive.js +5 -0
  39. package/dist/replay/handover.d.ts +7 -0
  40. package/dist/replay/handover.js +89 -51
  41. package/dist/replay/plan.d.ts +101 -5
  42. package/dist/replay/plan.js +260 -18
  43. package/dist/replay/source-run.d.ts +2 -2
  44. package/dist/replay/source-run.js +3 -3
  45. package/dist/replay/targets.d.ts +40 -1
  46. package/dist/replay/targets.js +105 -3
  47. package/dist/replay/types.d.ts +25 -8
  48. package/docs/calculatedReplay.md +45 -5
  49. package/docs/calculatedReplayGuide.md +13 -4
  50. package/package.json +1 -1
  51. package/production.md +21 -7
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import type { ExecutionReport, MatchKey, MatchSegment, MatchVerdict } from "../record/recorder.js";
15
15
  import { type ReplayMode, type StepReach } from "./coverage.js";
16
- import { deriveParameters, type DeriveContext } from "./derive.js";
16
+ import { deriveParameters, type AgentDay, type DeriveContext, type DeriveResult } from "./derive.js";
17
17
  import { ProxyWorkQueue } from "./executor.js";
18
18
  import { ScenarioReplayPlan } from "./plan.js";
19
19
  import { type HostSinks } from "./safety.js";
@@ -22,6 +22,13 @@ import { type FlatStop } from "./flatten.js";
22
22
  import { type ExecutionOutcome, type ExecutionStepResult, type FallbackKind, type SerializedScenario, type SerializedScenarioStep } from "./types.js";
23
23
  /** The first-party tool a `direct` plan is delivered through (§6.3). */
24
24
  export declare const DIRECT_TOOL_NAME = "mcp__bir__run_scenario";
25
+ /**
26
+ * `bir`'s own tool for saying a replay's results do not answer the request
27
+ * (bin/bir-scenario.ts; the service's review of calcscenarioautocorrect.md,
28
+ * item 19): the one call a finished bundle lets the agent make, where the
29
+ * session has it ({@link ReplayState.reportTool}).
30
+ */
31
+ export declare const REPORT_TOOL_NAME = "mcp__bir__report_wrong_result";
25
32
  /** How long a `/proxy/poll` is held open before it answers empty. */
26
33
  export declare const POLL_HOLD_MS = 25000;
27
34
  /**
@@ -233,8 +240,11 @@ export interface ReplayOptions {
233
240
  /** On unless `BIR_REPLAY=0`. Everything here is inert when false. */
234
241
  enabled: boolean;
235
242
  /**
236
- * `BIR_SEGMENT_ARM`. Off means observe-only: the runner asks for no segment
237
- * and arms none, and only logs what would have armed (R-OUT-10).
243
+ * Whether a handed-out segment may run mid-task. The recorder sets it from
244
+ * `BIR_SEGMENT_ARM`: on unless that is `0`, from runner 0.3.19 (the
245
+ * service's segmentsbreakdown.md SB-21). Omitted, as by a test or an
246
+ * embedder, it is off: observe-only, where the runner asks for no segment,
247
+ * arms none, and only logs what would have armed (R-OUT-10).
238
248
  */
239
249
  segmentArm?: boolean;
240
250
  /** `BIR_REPLAY_ALLOW_SERVERS`; undefined means every wrapped server. */
@@ -391,6 +401,14 @@ export interface ReplayState {
391
401
  retired: boolean;
392
402
  /** What armed it: the prompt, or a ReAct iteration's intent (fallbk.md). */
393
403
  armedBy: "prompt" | "intent";
404
+ /**
405
+ * The user's request this plan serves, in their own words: the prompt for a
406
+ * plan the prompt armed (set in `arm`), the turn's prompt for one an intent
407
+ * match armed (set by the control server). Read only for the note of a plan
408
+ * stopped at its decision, which quotes the request's condition sentences
409
+ * (the service's segmentsbreakdown.md SB-18). Never sent anywhere.
410
+ */
411
+ request?: string;
394
412
  /**
395
413
  * The Claude Code session this plan serves, set by the control server. Its
396
414
  * steps run on that session's own proxies (executor.ts). Absent for `bir
@@ -478,7 +496,10 @@ export interface ReplayState {
478
496
  * A plan that finished its work stops costing at that moment: the agent's
479
497
  * later work in the same turn is the agent's, not this plan's. A plan that
480
498
  * handed over or diverged takes no mark, because the follow-on work is the
481
- * direct consequence of its stopping (R-MONEY-3, R-FALL-5).
499
+ * direct consequence of its stopping (R-MONEY-3, R-FALL-5) — except a plan
500
+ * stopped at its decision after a step ran: it did all it was for, and the
501
+ * agent's decision and the half it chose are the agent's own (the service's
502
+ * segmentsbreakdown.md SB-26).
482
503
  */
483
504
  retiredMark?: unknown;
484
505
  retiredAt?: number;
@@ -501,6 +522,25 @@ export interface ReplayState {
501
522
  * is waiting on the service, and obeys its breaker (util/service-health.ts).
502
523
  */
503
524
  deriveOnService?: boolean;
525
+ /** The day the plan's values were read for (issue 1212): the agent's own, or this machine's. */
526
+ deriveDay?: string;
527
+ /** The line that told the agent its day, as the reading was sent it. */
528
+ deriveLine?: string;
529
+ /** The agent's own day, read again when the plan starts. */
530
+ agentDayNow?: () => AgentDay | undefined;
531
+ /** Read the plan's values again for another day; set when the plan armed. */
532
+ rederive?: (day: AgentDay) => Promise<DeriveResult>;
533
+ /** What the second reading left unnamed, once it has answered. */
534
+ rederivedMissing?: string[];
535
+ /**
536
+ * Whether this plan's session has `bir`'s report tool ({@link
537
+ * REPORT_TOOL_NAME}) right now, asked when a bundle is laid out: set by the
538
+ * control server, from what the session's `bir` server said of itself. A
539
+ * bundle that forbids every tool call then makes one exception for it
540
+ * (bundle.ts). Absent — `bir replay`, another host, an older server — the
541
+ * words stay as they were.
542
+ */
543
+ reportTool?: () => boolean;
504
544
  /**
505
545
  * Set when the session's host is not Claude Code (see {@link HostContext}).
506
546
  * Such a plan is always `steer` with every step `live`, and nothing here
@@ -661,9 +701,11 @@ export declare class ReplayController {
661
701
  /**
662
702
  * Whether a handed-out segment may actually arm (segmented.md R-OUT-10).
663
703
  *
664
- * Off by default: until an operator has read the observe-only logs and turned
665
- * `BIR_SEGMENT_ARM=1` on, the runner asks for no segment and arms none. The
666
- * server enforces the same thing from its side (R-OUT-9).
704
+ * Only when the option says so. The recorder passes it on unless
705
+ * `BIR_SEGMENT_ARM=0` (from 0.3.19; the service's segmentsbreakdown.md
706
+ * SB-21); a controller built without it stays observe-only, asks for no
707
+ * segment and arms none. The server enforces the same thing from its side
708
+ * (R-OUT-9).
667
709
  */
668
710
  get segmentArm(): boolean;
669
711
  /** The plan's own delivery vehicle is never a scenario step. */
@@ -706,6 +748,13 @@ export declare class ReplayController {
706
748
  * the field. Built from the same entries the directive lists.
707
749
  */
708
750
  planData(state: ReplayState): PlanData | undefined;
751
+ /**
752
+ * Whether the plan's steps end in front of a decision (the service's
753
+ * segmentsbreakdown.md SB-6): it runs the steps before it, then hands the
754
+ * task back there. The control server gives such a plan a usage mark, so
755
+ * that it is billed only up to the stop (SB-26).
756
+ */
757
+ stopsAtDecision(state: ReplayState): boolean;
709
758
  /**
710
759
  * Take back a plan that armed and has run nothing, as a decline.
711
760
  *
@@ -995,6 +1044,10 @@ export declare class ReplayController {
995
1044
  * there is nothing to be similar *to* and nothing to decline. It books no
996
1045
  * execution either — there is no ticket, and inventing a saving for a manual
997
1046
  * invocation is exactly the kind of number a ledger must never contain.
1047
+ *
1048
+ * One served stop is kept: a plan's decision (the service's
1049
+ * segmentsbreakdown.md SB-6). The run stops in front of it, and `stopped`
1050
+ * says so with the reason `decision`.
998
1051
  */
999
1052
  runAdHoc(scenario: SerializedScenario, prompt: string, wrapped: ReadonlySet<string>): Promise<{
1000
1053
  ok: boolean;
@@ -1070,6 +1123,12 @@ export declare class ReplayController {
1070
1123
  * step.
1071
1124
  */
1072
1125
  private stopKindOf;
1126
+ /**
1127
+ * A divergence's bundle that ended at the plan's decision (SB-17): logged
1128
+ * as `handOver` logs every other hand-over, and its usage mark taken there
1129
+ * when a step of the plan ran (SB-26).
1130
+ */
1131
+ private decidedInDivergence;
1073
1132
  /**
1074
1133
  * The steps before flat position `bound` that ran, 1-based, and the ones
1075
1134
  * their tests left out (AC5) — the plan cursor's own, and a divergence
@@ -1105,6 +1164,12 @@ export declare class ReplayController {
1105
1164
  * cut off by its clock (`uncertain`), a step that ran and broke (`failed`).
1106
1165
  */
1107
1166
  private executeBuiltin;
1167
+ /**
1168
+ * The report tool a bundle may name, when this plan's session has it
1169
+ * ({@link ReplayState.reportTool}); undefined leaves the bundle's words as
1170
+ * they always were. Never for another host: its adapter reads no bundle.
1171
+ */
1172
+ private reportToolFor;
1108
1173
  /** Where recorded outputs come from, when they may stand in at all. */
1109
1174
  private recordedSource;
1110
1175
  /**
@@ -1177,6 +1242,12 @@ export declare class ReplayController {
1177
1242
  /** Outcomes only move forward; `not_steered` is the floor (§11.1). */
1178
1243
  private upgrade;
1179
1244
  private retire;
1245
+ /**
1246
+ * Where the plan's work ended, for its bill: now, and the transcript's
1247
+ * watermark now. Taken at a completing retire, and at a decision hand-over
1248
+ * after a step ran (the service's segmentsbreakdown.md SB-26).
1249
+ */
1250
+ private markRetired;
1180
1251
  }
1181
1252
  /** The subset of `RunMatch` replay consumes. Structural, so tests need no recorder. */
1182
1253
  export interface RunMatchLike {