@basein/runner 0.3.14 → 0.3.16
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/README.md +7 -0
- package/dist/bin/bir-scenario.js +8 -5
- package/dist/bin/bir.js +2 -1
- package/dist/bin/investigate.d.ts +71 -0
- package/dist/bin/investigate.js +145 -13
- package/dist/bin/scenario-edit.d.ts +45 -1
- package/dist/bin/scenario-edit.js +134 -14
- package/dist/control/server.d.ts +41 -10
- package/dist/control/server.js +169 -20
- package/dist/record/recorder.d.ts +45 -7
- package/dist/record/remote-recorder.d.ts +3 -4
- package/dist/record/remote-recorder.js +16 -0
- package/dist/record/switchable-recorder.d.ts +1 -5
- package/dist/replay/bundle.d.ts +10 -0
- package/dist/replay/bundle.js +23 -2
- package/dist/replay/controller.d.ts +151 -0
- package/dist/replay/controller.js +510 -58
- package/dist/replay/flatten.d.ts +39 -3
- package/dist/replay/flatten.js +42 -2
- package/dist/replay/handover.d.ts +39 -1
- package/dist/replay/handover.js +81 -2
- package/dist/replay/logic.d.ts +8 -0
- package/dist/replay/logic.js +19 -0
- package/dist/replay/plan.d.ts +165 -4
- package/dist/replay/plan.js +488 -25
- package/dist/replay/source-run.d.ts +14 -1
- package/dist/replay/source-run.js +25 -2
- package/dist/replay/targets.js +8 -1
- package/dist/replay/types.d.ts +52 -3
- package/dist/replay/types.js +14 -0
- package/dist/util/service-headers.d.ts +7 -1
- package/dist/util/service-headers.js +7 -1
- package/docs/BaseInstRunner.md +3 -1
- package/docs/calculatedReplay.md +117 -6
- package/docs/calculatedReplayGuide.md +41 -3
- package/package.json +1 -1
|
@@ -435,6 +435,24 @@ export interface ReplayState {
|
|
|
435
435
|
sharedWith: string[];
|
|
436
436
|
/** Set when the plan handed the task to the model part-way (fallbk.md). */
|
|
437
437
|
handover?: Handover;
|
|
438
|
+
/**
|
|
439
|
+
* Every planned step ran and the model was handed the results to answer
|
|
440
|
+
* from: a steered plan whose last step threaded, a direct run that ran to
|
|
441
|
+
* its end, or a divergence whose bundle carried the rest of the chain. A
|
|
442
|
+
* call the model makes of its own after this is the task done again — it
|
|
443
|
+
* did not take the plan's result as the answer (the service's newestRun.md
|
|
444
|
+
* N7). Never set on a plan that handed over: the hand-over says the rest
|
|
445
|
+
* is the model's.
|
|
446
|
+
*/
|
|
447
|
+
ranToEnd?: boolean;
|
|
448
|
+
/**
|
|
449
|
+
* A divergence is running the plan's remaining steps for real (§8). The
|
|
450
|
+
* plan is already retired by then, so this is what tells a call made beside
|
|
451
|
+
* that work from one made after it: a repeat never opens while steps are
|
|
452
|
+
* still landing, and whether the plan ran to its end or handed over is not
|
|
453
|
+
* known yet (the service's newestRun.md N7).
|
|
454
|
+
*/
|
|
455
|
+
diverging?: boolean;
|
|
438
456
|
/**
|
|
439
457
|
* Which gate declined, as a fixed code (segmented.md R-HIT-14). The prose
|
|
440
458
|
* `why` that `decline()` logs stays free text; this is what code reads — the
|
|
@@ -496,6 +514,60 @@ export interface ReplayState {
|
|
|
496
514
|
* sample of what the task costs unaided.
|
|
497
515
|
*/
|
|
498
516
|
hostStop?: HostStop;
|
|
517
|
+
/**
|
|
518
|
+
* The served chain's revision, for the mark on the plan's own calls when
|
|
519
|
+
* they are recorded into the turn's newest run (autocorrect.md AC2).
|
|
520
|
+
*/
|
|
521
|
+
chainRevision?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Keep every call this plan makes, whole, for the turn's newest run: set by
|
|
524
|
+
* the control server on a prompt plan whose match offered to record the
|
|
525
|
+
* turn as a repeat. A plan that runs to its end and is then redone by the
|
|
526
|
+
* agent has its calls recorded first into that repeat (AC2) — the report's
|
|
527
|
+
* copies are cut to 3,800 bytes, and the agent's work is built on them.
|
|
528
|
+
*/
|
|
529
|
+
keepCalls?: boolean;
|
|
530
|
+
/**
|
|
531
|
+
* Those calls, in the order the plan made them, keyed by frame and step —
|
|
532
|
+
* a sub-task called twice keeps both calls of each step.
|
|
533
|
+
*/
|
|
534
|
+
turnCalls?: Map<string, TurnCall>;
|
|
535
|
+
/** What they hold, in characters: bounded by {@link TURN_CALLS_MAX_CHARS}. */
|
|
536
|
+
turnCallChars?: number;
|
|
537
|
+
/**
|
|
538
|
+
* Steer mode: the steps a test just left out (AC5), and the note that tells
|
|
539
|
+
* the model so — riding on the `PostToolUse` that moved the cursor past
|
|
540
|
+
* them, or given in place of a call the model makes to one of them.
|
|
541
|
+
*/
|
|
542
|
+
skipNote?: {
|
|
543
|
+
text: string;
|
|
544
|
+
tools: Set<string>;
|
|
545
|
+
delivered: boolean;
|
|
546
|
+
refused?: number;
|
|
547
|
+
/**
|
|
548
|
+
* It says the sequence is complete — the steps left out were the plan's
|
|
549
|
+
* last. The only note that outlives the plan: every other one names a step
|
|
550
|
+
* to call next, which a retired plan no longer has (AC5 review).
|
|
551
|
+
*/
|
|
552
|
+
complete?: boolean;
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* One of a plan's own calls, kept whole for the turn's newest run (the
|
|
557
|
+
* service's autocorrect.md AC2): redacted and capped like a recorded call,
|
|
558
|
+
* never cut to what a report carries.
|
|
559
|
+
*/
|
|
560
|
+
export interface TurnCall {
|
|
561
|
+
scenarioId: string;
|
|
562
|
+
stepIndex: number;
|
|
563
|
+
chainRevision: number | null;
|
|
564
|
+
toolName: string;
|
|
565
|
+
/** Serialized and redacted, at most 64 KiB, as a recorded call's input is. */
|
|
566
|
+
input: string;
|
|
567
|
+
/** The tool's answer, when it gave one; on the same terms. */
|
|
568
|
+
output?: string;
|
|
569
|
+
/** What it reported instead, when it failed. */
|
|
570
|
+
error?: string;
|
|
499
571
|
}
|
|
500
572
|
/**
|
|
501
573
|
* Why a match did not arm. One code per gate of the ladder, so the caller can
|
|
@@ -504,10 +576,21 @@ export interface ReplayState {
|
|
|
504
576
|
export type DeclineCode = "replay_disabled" | "not_ready" | "flatten_failed" | "known_bad_first_step" | "nondeterministic_first_step" | "unusable_first_step" | "coverage" | "missing_target" | "no_derive_key"
|
|
505
577
|
/** The service handed over no plan: this runner is too old for it. */
|
|
506
578
|
| "runner_update_required"
|
|
579
|
+
/**
|
|
580
|
+
* The service handed over no plan: it holds it, because the agent did the
|
|
581
|
+
* task again after the plan's last run (the service's autocorrect.md AC4).
|
|
582
|
+
*/
|
|
583
|
+
| "held"
|
|
507
584
|
/** The session's host only records: its adapter asked for no plan with the prompt. */
|
|
508
585
|
| "host_records_only"
|
|
509
586
|
/** The plan names a tool the host's agent does not hold. */
|
|
510
587
|
| "host_tool_missing"
|
|
588
|
+
/**
|
|
589
|
+
* The plan has steps that run only when a test says so (the service's
|
|
590
|
+
* autocorrect.md AC5), and the session's host is another app, whose adapter
|
|
591
|
+
* steps through a plan call by call and knows no tests yet.
|
|
592
|
+
*/
|
|
593
|
+
| "host_tests_unsupported"
|
|
511
594
|
/**
|
|
512
595
|
* No gate said no: the plan was good, and late. Not ready when the prompt
|
|
513
596
|
* had to be answered (`arm_timeout`), or ready just after it had been
|
|
@@ -768,6 +851,50 @@ export declare class ReplayController {
|
|
|
768
851
|
* ({@link pinFailure}). `how` lets the caller say so outright.
|
|
769
852
|
*/
|
|
770
853
|
postTool(state: ReplayState, toolUseId: string, output: string, failed?: string, how?: PostToolOptions): boolean;
|
|
854
|
+
/**
|
|
855
|
+
* A steer plan whose cursor reached its end: in front of a parked step (or a
|
|
856
|
+
* call the service could not answer), which hands over; otherwise it ran to
|
|
857
|
+
* its end — and from here every call is the model's own.
|
|
858
|
+
*/
|
|
859
|
+
private finishSteer;
|
|
860
|
+
/**
|
|
861
|
+
* Move a plan's own cursor past the steps this request does not need, and
|
|
862
|
+
* act on what its tests decide (the service's autocorrect.md AC5). Every
|
|
863
|
+
* verdict is recorded as it is made. `stopped` means the plan handed over —
|
|
864
|
+
* the other half, a test that could not answer, or no step needed at all —
|
|
865
|
+
* and its note waits in {@link takeNote}. Otherwise the steps left out are
|
|
866
|
+
* named in a note for the model ({@link takeSkipNote}), and the caller goes
|
|
867
|
+
* on: a step is due, or the plan is done.
|
|
868
|
+
*
|
|
869
|
+
* Nothing at all for a plan without tests, which behaves exactly as before.
|
|
870
|
+
*/
|
|
871
|
+
private settleCursor;
|
|
872
|
+
/** What the model is told about steps a test left out (AC5). */
|
|
873
|
+
private skipNoteText;
|
|
874
|
+
/**
|
|
875
|
+
* The note naming the steps a test just left out, claimed for delivery on a
|
|
876
|
+
* `PostToolUse` (AC5). Returned once; undefined when there is none.
|
|
877
|
+
*/
|
|
878
|
+
takeSkipNote(state: ReplayState | undefined): string | undefined;
|
|
879
|
+
/**
|
|
880
|
+
* The same note, for a call the model is about to make to one of the steps
|
|
881
|
+
* it names — when the note has not reached the model yet. The control server
|
|
882
|
+
* gives it in place of that call, whether the plan is still steering or has
|
|
883
|
+
* just finished: a step left out must never run because the note was late.
|
|
884
|
+
*/
|
|
885
|
+
skipNoteFor(state: ReplayState | undefined, toolName: string): string | undefined;
|
|
886
|
+
/**
|
|
887
|
+
* The pin guard took a call to the next step as that step: a note still
|
|
888
|
+
* waiting to say that a step before it was left out has nothing left to
|
|
889
|
+
* stop, and goes — as it went at the call before the guard existed.
|
|
890
|
+
*/
|
|
891
|
+
pinTaken(state: ReplayState | undefined): void;
|
|
892
|
+
/**
|
|
893
|
+
* The plan's own calls of the turn, whole, in the order it made them — for
|
|
894
|
+
* the turn's newest run when the agent redoes the task (AC2). Empty unless
|
|
895
|
+
* the control server asked for them to be kept ({@link ReplayState.keepCalls}).
|
|
896
|
+
*/
|
|
897
|
+
turnCallsOf(state: ReplayState | undefined): TurnCall[];
|
|
771
898
|
/**
|
|
772
899
|
* The result of a call pinned under a plan that has since handed over
|
|
773
900
|
* because another call ran beside it (`concurrentCall`). Nothing threads —
|
|
@@ -836,6 +963,16 @@ export declare class ReplayController {
|
|
|
836
963
|
* usual cost.
|
|
837
964
|
*/
|
|
838
965
|
cutShort?: boolean;
|
|
966
|
+
/**
|
|
967
|
+
* The plan ran to its end and the agent redid the task in a repeat the
|
|
968
|
+
* service took (autocorrect.md AC1): that repeat's id and the agent's
|
|
969
|
+
* own calls in it. Only the control server knows, and only for the
|
|
970
|
+
* prompt's plan.
|
|
971
|
+
*/
|
|
972
|
+
redoneBy?: {
|
|
973
|
+
runId: string;
|
|
974
|
+
ownCalls: number;
|
|
975
|
+
};
|
|
839
976
|
}): ExecutionReport | undefined;
|
|
840
977
|
/**
|
|
841
978
|
* The step a failed replay is fairly blamed on: the first whose own logic
|
|
@@ -933,6 +1070,13 @@ export declare class ReplayController {
|
|
|
933
1070
|
* step.
|
|
934
1071
|
*/
|
|
935
1072
|
private stopKindOf;
|
|
1073
|
+
/**
|
|
1074
|
+
* The steps before flat position `bound` that ran, 1-based, and the ones
|
|
1075
|
+
* their tests left out (AC5) — the plan cursor's own, and a divergence
|
|
1076
|
+
* bundle's (`extra`). `left` is empty when no step was left out; `ran` is
|
|
1077
|
+
* then not filled, since every step before `bound` ran.
|
|
1078
|
+
*/
|
|
1079
|
+
private ranBefore;
|
|
936
1080
|
private noteFor;
|
|
937
1081
|
/**
|
|
938
1082
|
* The executor handed to a plan: dispatch a step to the proxy that owns its
|
|
@@ -1020,6 +1164,13 @@ export declare class ReplayController {
|
|
|
1020
1164
|
* the recording's input and output beside this run's verdict.
|
|
1021
1165
|
*/
|
|
1022
1166
|
private recordStep;
|
|
1167
|
+
/**
|
|
1168
|
+
* Keep one call of the plan whole (AC2): its arguments and its answer,
|
|
1169
|
+
* redacted and capped as a recorded call's are. Later news about the same
|
|
1170
|
+
* step replaces earlier, in place, so the order is the order the calls went
|
|
1171
|
+
* out. Past {@link TURN_CALLS_MAX_CHARS} a call keeps only a report's cut.
|
|
1172
|
+
*/
|
|
1173
|
+
private keepCall;
|
|
1023
1174
|
/** The step verdicts, in chain order, for the execution report. */
|
|
1024
1175
|
private stepResultsOf;
|
|
1025
1176
|
private logStep;
|