@plune-ai/cli 0.39.15 → 0.40.0

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/dist/index.d.cts CHANGED
@@ -26,8 +26,16 @@ interface CacheSummary {
26
26
  from_cache: number;
27
27
  from_model: number;
28
28
  missed: number;
29
- /** Rows the provider failed on: answered by neither, so the four counts add up to `total` (dry-run rows aside). */
29
+ /**
30
+ * Rows the provider failed on: answered by neither, so the four counts add up to `total` (dry-run rows and
31
+ * `stubbed` rows aside).
32
+ */
30
33
  errored: number;
34
+ /**
35
+ * Rows of evals with `stubs`: answered by the stub server, or errored there. They are in none of the four
36
+ * counts above. Optional and additive: written only when there are such rows.
37
+ */
38
+ stubbed?: number;
31
39
  saved: {
32
40
  input_tokens: number;
33
41
  output_tokens: number;
@@ -112,6 +120,11 @@ interface RowResult {
112
120
  vars: Record<string, unknown>;
113
121
  output: string | null;
114
122
  cached: boolean;
123
+ /**
124
+ * `true` on a row of an eval with `stubs`: its answer, if it has one, came from the stub server and not from
125
+ * a model, and the model call in its `usage` costs 0. Optional and additive.
126
+ */
127
+ stubbed?: boolean;
115
128
  usage?: Usage;
116
129
  latency_ms?: number;
117
130
  error?: RunError;
@@ -251,6 +264,18 @@ interface EvalResult {
251
264
  type: string;
252
265
  model: string;
253
266
  };
267
+ /**
268
+ * Only on an eval with `stubs` that ran. `never_called`: the places in the stub file (from 0) of the stubs
269
+ * no request of this eval reached. `unmatched`: one entry per request no stub answered, with the scope it
270
+ * was sent in (`<eval id>.row<n>`, and `.run<k>` with repeats) and its method. Optional and additive.
271
+ */
272
+ stubs?: {
273
+ never_called: number[];
274
+ unmatched: {
275
+ scope: string;
276
+ method: string;
277
+ }[];
278
+ };
254
279
  }
255
280
  interface RunResult {
256
281
  schemaVersion: 1;
@@ -317,6 +342,15 @@ interface JsonSchemaAssertion {
317
342
  schema: object;
318
343
  extract?: 'auto' | 'strict';
319
344
  }
345
+ /** The answer's JSON against an expected JSON value; the rules of `expected` are in src/json-verify. */
346
+ interface JsonVerifyAssertion {
347
+ type: 'json-verify';
348
+ /** Any JSON value. A string in it may be a check (`@isString()`), an object a `$mode` or `$literal` marker. */
349
+ expected: unknown;
350
+ /** Default `exact`. */
351
+ mode?: 'exact' | 'unordered' | 'contains';
352
+ extract?: 'auto' | 'strict';
353
+ }
320
354
  /**
321
355
  * The experimental Jev judge of an `llm-judge` check. A decision model, not a text model: it cannot be an eval's
322
356
  * provider, takes none of the eval provider's fields, and its model is always named.
@@ -428,7 +462,7 @@ interface NoDestructiveToolAssertion {
428
462
  type: 'no-destructive-tool';
429
463
  }
430
464
  type ToolCallAssertion = ToolCalledAssertion | ToolNotCalledAssertion | ToolArgsAssertion | ToolOrderAssertion | OnlyToolsAssertion | FirstToolAssertion | NoToolErrorsAssertion | ToolCallCountAssertion | NoRepeatedCallAssertion | TokenBudgetAssertion | ToolLatencyAssertion | ToolResultSizeAssertion | ToolResultSchemaAssertion | NoDestructiveToolAssertion;
431
- type AssertionConfig = ExactMatchAssertion | ContainsAssertion | ContainsAnyAssertion | ContainsAllAssertion | JsonSchemaAssertion | LlmJudgeAssertion | SemanticSimilarityAssertion | FaithfulnessAssertion | AnswerRelevanceAssertion | ContextPrecisionAssertion | ToolCallAssertion;
465
+ type AssertionConfig = ExactMatchAssertion | ContainsAssertion | ContainsAnyAssertion | ContainsAllAssertion | JsonSchemaAssertion | JsonVerifyAssertion | LlmJudgeAssertion | SemanticSimilarityAssertion | FaithfulnessAssertion | AnswerRelevanceAssertion | ContextPrecisionAssertion | ToolCallAssertion;
432
466
  interface EvalConfig {
433
467
  id: string;
434
468
  description?: string;
@@ -444,6 +478,11 @@ interface EvalConfig {
444
478
  pass_threshold?: number;
445
479
  /** The MCP server this eval's model may use, from the root `mcp.servers`. */
446
480
  mcp?: EvalMcpConfig;
481
+ /**
482
+ * A stub file, relative to the folder of the config: during the run a local server answers this eval's
483
+ * model calls from it, in place of the provider. Not with `mcp`.
484
+ */
485
+ stubs?: string;
447
486
  }
448
487
  /** Every limit is a whole number above 0; one left out takes its default (`MCP_LIMIT_DEFAULTS`). */
449
488
  interface McpLimits {
@@ -609,6 +648,11 @@ interface DecisionQuestion {
609
648
  output: string;
610
649
  input?: string;
611
650
  }
651
+ /** A decision judge's answer: the probability of "yes", and the exact model version that gave it. */
652
+ interface DecisionAnswer {
653
+ probability: number;
654
+ model: string;
655
+ }
612
656
  interface Judge {
613
657
  /** Ask the judge LLM a prompt and return its raw text response. */
614
658
  ask(prompt: string): Promise<string>;
@@ -616,7 +660,7 @@ interface Judge {
616
660
  * Only a decision model has it (the experimental `jev` judge of an `llm-judge` check): the probability, 0 to 1,
617
661
  * that the answer meets the criteria. Such a judge gives no reason, and its `ask` throws.
618
662
  */
619
- decide?(question: DecisionQuestion): Promise<number>;
663
+ decide?(question: DecisionQuestion): Promise<DecisionAnswer>;
620
664
  }
621
665
 
622
666
  interface Cache {
@@ -666,12 +710,108 @@ interface AgentServer {
666
710
  /** Opens a session with the server named in `mcp.servers`; a failure rejects with a message already masked. */
667
711
  type AgentConnect = (server: string, timeoutMs: number) => Promise<AgentServer>;
668
712
 
713
+ declare const stubSchema: z.ZodObject<{
714
+ method: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<string, string>>;
715
+ path: z.ZodString;
716
+ body: z.ZodOptional<z.ZodUnknown>;
717
+ match: z.ZodOptional<z.ZodEnum<{
718
+ exact: "exact";
719
+ subset: "subset";
720
+ }>>;
721
+ times: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"always">, z.ZodLiteral<"once">, z.ZodNumber]>>;
722
+ response: z.ZodOptional<z.ZodObject<{
723
+ status: z.ZodDefault<z.ZodNumber>;
724
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
725
+ json: z.ZodOptional<z.ZodUnknown>;
726
+ text: z.ZodOptional<z.ZodString>;
727
+ sse: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
728
+ event: z.ZodOptional<z.ZodString>;
729
+ data: z.ZodUnknown;
730
+ }, z.core.$strict>]>>>;
731
+ }, z.core.$strict>>;
732
+ failure: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
733
+ type: z.ZodLiteral<"timeout">;
734
+ first: z.ZodOptional<z.ZodNumber>;
735
+ }, z.core.$strict>, z.ZodObject<{
736
+ type: z.ZodLiteral<"reset">;
737
+ first: z.ZodOptional<z.ZodNumber>;
738
+ }, z.core.$strict>, z.ZodObject<{
739
+ type: z.ZodLiteral<"http_429">;
740
+ first: z.ZodOptional<z.ZodNumber>;
741
+ retry_after_seconds: z.ZodDefault<z.ZodNumber>;
742
+ }, z.core.$strict>, z.ZodObject<{
743
+ type: z.ZodLiteral<"http_500">;
744
+ first: z.ZodOptional<z.ZodNumber>;
745
+ }, z.core.$strict>, z.ZodObject<{
746
+ type: z.ZodLiteral<"slow_stream">;
747
+ first: z.ZodOptional<z.ZodNumber>;
748
+ bytes_per_sec: z.ZodNumber;
749
+ }, z.core.$strict>, z.ZodObject<{
750
+ type: z.ZodLiteral<"truncated_json">;
751
+ first: z.ZodOptional<z.ZodNumber>;
752
+ content_length: z.ZodDefault<z.ZodEnum<{
753
+ full: "full";
754
+ cut: "cut";
755
+ }>>;
756
+ }, z.core.$strict>], "type">>;
757
+ }, z.core.$strict>;
758
+ type Stub = z.output<typeof stubSchema>;
759
+ type StubInput = z.input<typeof stubSchema>;
760
+
761
+ interface JournalEntry {
762
+ scope: string;
763
+ method: string;
764
+ /** Without the scope segment and without the query string. */
765
+ path: string;
766
+ /** Without the leading `?`; values of secret-looking parameters are masked. */
767
+ query: string;
768
+ /** Lower-case names; values of secret-looking headers are masked. */
769
+ headers: Record<string, string>;
770
+ /** The first `journalBodyCap` bytes. */
771
+ body: string;
772
+ bodyTruncated: boolean;
773
+ /** Whether a stub answered. */
774
+ matched: boolean;
775
+ }
776
+ interface MockScope {
777
+ readonly name: string;
778
+ /** `<server.url>/<name>`: what a provider SDK's base URL starts with. */
779
+ readonly url: string;
780
+ /** The newest `JOURNAL_MAX_ENTRIES` requests that named this scope, in arrival order. */
781
+ readonly journal: readonly JournalEntry[];
782
+ /** How many older entries the journal has let go. */
783
+ readonly dropped: number;
784
+ add(...stubs: StubInput[]): void;
785
+ /**
786
+ * Removes the scope and its stubs, ends the requests it still holds (a `timeout`, a `slow_stream`) by
787
+ * destroying their sockets, and returns the stubs that were never called.
788
+ */
789
+ close(): Stub[];
790
+ }
791
+ interface MockServer {
792
+ readonly url: string;
793
+ readonly port: number;
794
+ /** The newest `JOURNAL_MAX_ENTRIES` requests whose target named no open scope or was refused. */
795
+ readonly unrouted: readonly JournalEntry[];
796
+ /** How many older entries `unrouted` has let go. */
797
+ readonly unroutedDropped: number;
798
+ /** Throws on a name that is taken or cannot be a path segment, and once the server is closed. */
799
+ scope(name: string, stubs?: StubInput[]): MockScope;
800
+ /** Always resolves, destroys open sockets, safe to call twice. */
801
+ close(): Promise<void>;
802
+ }
803
+
669
804
  interface RowParams {
670
805
  template: string;
671
806
  assertions: AssertionConfig[];
672
807
  row: DatasetRow;
673
808
  providerConfig: ProviderConfig;
674
809
  provider: Provider;
810
+ /**
811
+ * The provider a judge asks where `provider` is not the one to ask: on an eval with stubs `provider` is
812
+ * pointed at the stub server, and a judge call is not the eval's own call.
813
+ */
814
+ judgeProvider?: Provider;
675
815
  embedder: Embedder;
676
816
  cache: Cache;
677
817
  now: () => number;
@@ -691,10 +831,24 @@ interface RowParams {
691
831
  */
692
832
  resolveJudge?: (cfg: ProviderConfig) => Provider;
693
833
  /** Builds the experimental `jev` judge of an `llm-judge` check; `onCost` is charged to the row. Without it such a check errors the row. */
694
- jevJudge?: (cfg: JevJudgeConfig, onCost: (usd: number) => void) => Judge;
834
+ jevJudge?: (cfg: JevJudgeConfig, onCost: (cost: {
835
+ cost_usd: number;
836
+ priced?: boolean;
837
+ }) => void) => Judge;
838
+ /** Prices a `jev` judge call of so many input tokens, for a dry run. Without it a dry run leaves such a check out of the estimate. */
839
+ jevCost?: (model: string, inputTokens: number) => {
840
+ cost_usd: number;
841
+ priced?: boolean;
842
+ };
695
843
  }
696
844
  interface RunDeps {
697
- resolveProvider(cfg: ProviderConfig): Provider;
845
+ /** With `stubOrigin` (a scope of the stub server), the provider's client is pointed there, not at the provider. */
846
+ resolveProvider(cfg: ProviderConfig, stubOrigin?: string): Provider;
847
+ /**
848
+ * The stub server of the run, started on the first call and the same one on every call after it; whoever
849
+ * gives it closes it. Called only when a row of an eval with `stubs` runs, so never on a dry run.
850
+ */
851
+ stubServer?: () => Promise<MockServer>;
698
852
  embedder: Embedder;
699
853
  cache: Cache;
700
854
  now: () => number;
@@ -704,6 +858,8 @@ interface RunDeps {
704
858
  connectMcp?: AgentConnect;
705
859
  /** Builds the experimental `jev` judge of an `llm-judge` check. A run without it errors the rows of such a check. */
706
860
  jevJudge?: RowParams['jevJudge'];
861
+ /** Prices a `jev` judge call for a dry run. */
862
+ jevCost?: RowParams['jevCost'];
707
863
  }
708
864
 
709
865
  interface RunOptions {
@@ -729,7 +885,7 @@ declare class NotLoggedInError extends Error {
729
885
  }
730
886
  /** The token was present but the server rejected it (401 — revoked or invalid). (exit 2) */
731
887
  declare class TokenRejectedError extends Error {
732
- constructor();
888
+ constructor(apiUrl?: string);
733
889
  }
734
890
  /** No run to sync, or the run file is unreadable / not a valid RunResult. (exit 2) */
735
891
  declare class SyncFileError extends Error {
@@ -749,7 +905,7 @@ interface SyncDeps {
749
905
  cwd?: string;
750
906
  /** Explicit run JSON to sync instead of `<cwd>/.plune/last-run.json`. */
751
907
  file?: string;
752
- /** Override the API base URL. Falls back to `PLUNE_API_URL`, then the beta default. */
908
+ /** Override the API base URL. Falls back to `PLUNE_API_URL`, then the production default. */
753
909
  apiUrl?: string;
754
910
  /** Token source (injected in tests). Defaults to the real credentials store. */
755
911
  loadToken?: () => string | null;
@@ -810,6 +966,18 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
810
966
  strict: "strict";
811
967
  }>>;
812
968
  }, z.core.$strip>, z.ZodObject<{
969
+ type: z.ZodLiteral<"json-verify">;
970
+ expected: z.ZodOptional<z.ZodAny>;
971
+ mode: z.ZodOptional<z.ZodEnum<{
972
+ exact: "exact";
973
+ unordered: "unordered";
974
+ contains: "contains";
975
+ }>>;
976
+ extract: z.ZodOptional<z.ZodEnum<{
977
+ auto: "auto";
978
+ strict: "strict";
979
+ }>>;
980
+ }, z.core.$strict>, z.ZodObject<{
813
981
  type: z.ZodLiteral<"llm-judge">;
814
982
  criteria: z.ZodString;
815
983
  provider: z.ZodOptional<z.ZodPipe<z.ZodAny, z.ZodTransform<{
@@ -856,8 +1024,8 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
856
1024
  tool: z.ZodString;
857
1025
  args: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
858
1026
  match: z.ZodOptional<z.ZodEnum<{
859
- partial: "partial";
860
1027
  exact: "exact";
1028
+ partial: "partial";
861
1029
  ignore: "ignore";
862
1030
  }>>;
863
1031
  min_count: z.ZodOptional<z.ZodNumber>;
@@ -959,6 +1127,7 @@ declare const runResultSchema: z.ZodObject<{
959
1127
  from_model: z.ZodNumber;
960
1128
  missed: z.ZodNumber;
961
1129
  errored: z.ZodNumber;
1130
+ stubbed: z.ZodOptional<z.ZodNumber>;
962
1131
  saved: z.ZodObject<{
963
1132
  input_tokens: z.ZodNumber;
964
1133
  output_tokens: z.ZodNumber;
@@ -973,6 +1142,7 @@ declare const runResultSchema: z.ZodObject<{
973
1142
  vars: z.ZodRecord<z.ZodString, z.ZodUnknown>;
974
1143
  output: z.ZodNullable<z.ZodString>;
975
1144
  cached: z.ZodBoolean;
1145
+ stubbed: z.ZodOptional<z.ZodBoolean>;
976
1146
  usage: z.ZodOptional<z.ZodObject<{
977
1147
  input_tokens: z.ZodNumber;
978
1148
  output_tokens: z.ZodNumber;
@@ -1128,6 +1298,13 @@ declare const runResultSchema: z.ZodObject<{
1128
1298
  type: z.ZodString;
1129
1299
  model: z.ZodString;
1130
1300
  }, z.core.$strip>>;
1301
+ stubs: z.ZodOptional<z.ZodObject<{
1302
+ never_called: z.ZodArray<z.ZodNumber>;
1303
+ unmatched: z.ZodArray<z.ZodObject<{
1304
+ scope: z.ZodString;
1305
+ method: z.ZodString;
1306
+ }, z.core.$strip>>;
1307
+ }, z.core.$strip>>;
1131
1308
  traceUrl: z.ZodOptional<z.ZodString>;
1132
1309
  }, z.core.$strip>>;
1133
1310
  }, z.core.$strip>;
package/dist/index.d.ts CHANGED
@@ -26,8 +26,16 @@ interface CacheSummary {
26
26
  from_cache: number;
27
27
  from_model: number;
28
28
  missed: number;
29
- /** Rows the provider failed on: answered by neither, so the four counts add up to `total` (dry-run rows aside). */
29
+ /**
30
+ * Rows the provider failed on: answered by neither, so the four counts add up to `total` (dry-run rows and
31
+ * `stubbed` rows aside).
32
+ */
30
33
  errored: number;
34
+ /**
35
+ * Rows of evals with `stubs`: answered by the stub server, or errored there. They are in none of the four
36
+ * counts above. Optional and additive: written only when there are such rows.
37
+ */
38
+ stubbed?: number;
31
39
  saved: {
32
40
  input_tokens: number;
33
41
  output_tokens: number;
@@ -112,6 +120,11 @@ interface RowResult {
112
120
  vars: Record<string, unknown>;
113
121
  output: string | null;
114
122
  cached: boolean;
123
+ /**
124
+ * `true` on a row of an eval with `stubs`: its answer, if it has one, came from the stub server and not from
125
+ * a model, and the model call in its `usage` costs 0. Optional and additive.
126
+ */
127
+ stubbed?: boolean;
115
128
  usage?: Usage;
116
129
  latency_ms?: number;
117
130
  error?: RunError;
@@ -251,6 +264,18 @@ interface EvalResult {
251
264
  type: string;
252
265
  model: string;
253
266
  };
267
+ /**
268
+ * Only on an eval with `stubs` that ran. `never_called`: the places in the stub file (from 0) of the stubs
269
+ * no request of this eval reached. `unmatched`: one entry per request no stub answered, with the scope it
270
+ * was sent in (`<eval id>.row<n>`, and `.run<k>` with repeats) and its method. Optional and additive.
271
+ */
272
+ stubs?: {
273
+ never_called: number[];
274
+ unmatched: {
275
+ scope: string;
276
+ method: string;
277
+ }[];
278
+ };
254
279
  }
255
280
  interface RunResult {
256
281
  schemaVersion: 1;
@@ -317,6 +342,15 @@ interface JsonSchemaAssertion {
317
342
  schema: object;
318
343
  extract?: 'auto' | 'strict';
319
344
  }
345
+ /** The answer's JSON against an expected JSON value; the rules of `expected` are in src/json-verify. */
346
+ interface JsonVerifyAssertion {
347
+ type: 'json-verify';
348
+ /** Any JSON value. A string in it may be a check (`@isString()`), an object a `$mode` or `$literal` marker. */
349
+ expected: unknown;
350
+ /** Default `exact`. */
351
+ mode?: 'exact' | 'unordered' | 'contains';
352
+ extract?: 'auto' | 'strict';
353
+ }
320
354
  /**
321
355
  * The experimental Jev judge of an `llm-judge` check. A decision model, not a text model: it cannot be an eval's
322
356
  * provider, takes none of the eval provider's fields, and its model is always named.
@@ -428,7 +462,7 @@ interface NoDestructiveToolAssertion {
428
462
  type: 'no-destructive-tool';
429
463
  }
430
464
  type ToolCallAssertion = ToolCalledAssertion | ToolNotCalledAssertion | ToolArgsAssertion | ToolOrderAssertion | OnlyToolsAssertion | FirstToolAssertion | NoToolErrorsAssertion | ToolCallCountAssertion | NoRepeatedCallAssertion | TokenBudgetAssertion | ToolLatencyAssertion | ToolResultSizeAssertion | ToolResultSchemaAssertion | NoDestructiveToolAssertion;
431
- type AssertionConfig = ExactMatchAssertion | ContainsAssertion | ContainsAnyAssertion | ContainsAllAssertion | JsonSchemaAssertion | LlmJudgeAssertion | SemanticSimilarityAssertion | FaithfulnessAssertion | AnswerRelevanceAssertion | ContextPrecisionAssertion | ToolCallAssertion;
465
+ type AssertionConfig = ExactMatchAssertion | ContainsAssertion | ContainsAnyAssertion | ContainsAllAssertion | JsonSchemaAssertion | JsonVerifyAssertion | LlmJudgeAssertion | SemanticSimilarityAssertion | FaithfulnessAssertion | AnswerRelevanceAssertion | ContextPrecisionAssertion | ToolCallAssertion;
432
466
  interface EvalConfig {
433
467
  id: string;
434
468
  description?: string;
@@ -444,6 +478,11 @@ interface EvalConfig {
444
478
  pass_threshold?: number;
445
479
  /** The MCP server this eval's model may use, from the root `mcp.servers`. */
446
480
  mcp?: EvalMcpConfig;
481
+ /**
482
+ * A stub file, relative to the folder of the config: during the run a local server answers this eval's
483
+ * model calls from it, in place of the provider. Not with `mcp`.
484
+ */
485
+ stubs?: string;
447
486
  }
448
487
  /** Every limit is a whole number above 0; one left out takes its default (`MCP_LIMIT_DEFAULTS`). */
449
488
  interface McpLimits {
@@ -609,6 +648,11 @@ interface DecisionQuestion {
609
648
  output: string;
610
649
  input?: string;
611
650
  }
651
+ /** A decision judge's answer: the probability of "yes", and the exact model version that gave it. */
652
+ interface DecisionAnswer {
653
+ probability: number;
654
+ model: string;
655
+ }
612
656
  interface Judge {
613
657
  /** Ask the judge LLM a prompt and return its raw text response. */
614
658
  ask(prompt: string): Promise<string>;
@@ -616,7 +660,7 @@ interface Judge {
616
660
  * Only a decision model has it (the experimental `jev` judge of an `llm-judge` check): the probability, 0 to 1,
617
661
  * that the answer meets the criteria. Such a judge gives no reason, and its `ask` throws.
618
662
  */
619
- decide?(question: DecisionQuestion): Promise<number>;
663
+ decide?(question: DecisionQuestion): Promise<DecisionAnswer>;
620
664
  }
621
665
 
622
666
  interface Cache {
@@ -666,12 +710,108 @@ interface AgentServer {
666
710
  /** Opens a session with the server named in `mcp.servers`; a failure rejects with a message already masked. */
667
711
  type AgentConnect = (server: string, timeoutMs: number) => Promise<AgentServer>;
668
712
 
713
+ declare const stubSchema: z.ZodObject<{
714
+ method: z.ZodPipe<z.ZodDefault<z.ZodString>, z.ZodTransform<string, string>>;
715
+ path: z.ZodString;
716
+ body: z.ZodOptional<z.ZodUnknown>;
717
+ match: z.ZodOptional<z.ZodEnum<{
718
+ exact: "exact";
719
+ subset: "subset";
720
+ }>>;
721
+ times: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"always">, z.ZodLiteral<"once">, z.ZodNumber]>>;
722
+ response: z.ZodOptional<z.ZodObject<{
723
+ status: z.ZodDefault<z.ZodNumber>;
724
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
725
+ json: z.ZodOptional<z.ZodUnknown>;
726
+ text: z.ZodOptional<z.ZodString>;
727
+ sse: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
728
+ event: z.ZodOptional<z.ZodString>;
729
+ data: z.ZodUnknown;
730
+ }, z.core.$strict>]>>>;
731
+ }, z.core.$strict>>;
732
+ failure: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
733
+ type: z.ZodLiteral<"timeout">;
734
+ first: z.ZodOptional<z.ZodNumber>;
735
+ }, z.core.$strict>, z.ZodObject<{
736
+ type: z.ZodLiteral<"reset">;
737
+ first: z.ZodOptional<z.ZodNumber>;
738
+ }, z.core.$strict>, z.ZodObject<{
739
+ type: z.ZodLiteral<"http_429">;
740
+ first: z.ZodOptional<z.ZodNumber>;
741
+ retry_after_seconds: z.ZodDefault<z.ZodNumber>;
742
+ }, z.core.$strict>, z.ZodObject<{
743
+ type: z.ZodLiteral<"http_500">;
744
+ first: z.ZodOptional<z.ZodNumber>;
745
+ }, z.core.$strict>, z.ZodObject<{
746
+ type: z.ZodLiteral<"slow_stream">;
747
+ first: z.ZodOptional<z.ZodNumber>;
748
+ bytes_per_sec: z.ZodNumber;
749
+ }, z.core.$strict>, z.ZodObject<{
750
+ type: z.ZodLiteral<"truncated_json">;
751
+ first: z.ZodOptional<z.ZodNumber>;
752
+ content_length: z.ZodDefault<z.ZodEnum<{
753
+ full: "full";
754
+ cut: "cut";
755
+ }>>;
756
+ }, z.core.$strict>], "type">>;
757
+ }, z.core.$strict>;
758
+ type Stub = z.output<typeof stubSchema>;
759
+ type StubInput = z.input<typeof stubSchema>;
760
+
761
+ interface JournalEntry {
762
+ scope: string;
763
+ method: string;
764
+ /** Without the scope segment and without the query string. */
765
+ path: string;
766
+ /** Without the leading `?`; values of secret-looking parameters are masked. */
767
+ query: string;
768
+ /** Lower-case names; values of secret-looking headers are masked. */
769
+ headers: Record<string, string>;
770
+ /** The first `journalBodyCap` bytes. */
771
+ body: string;
772
+ bodyTruncated: boolean;
773
+ /** Whether a stub answered. */
774
+ matched: boolean;
775
+ }
776
+ interface MockScope {
777
+ readonly name: string;
778
+ /** `<server.url>/<name>`: what a provider SDK's base URL starts with. */
779
+ readonly url: string;
780
+ /** The newest `JOURNAL_MAX_ENTRIES` requests that named this scope, in arrival order. */
781
+ readonly journal: readonly JournalEntry[];
782
+ /** How many older entries the journal has let go. */
783
+ readonly dropped: number;
784
+ add(...stubs: StubInput[]): void;
785
+ /**
786
+ * Removes the scope and its stubs, ends the requests it still holds (a `timeout`, a `slow_stream`) by
787
+ * destroying their sockets, and returns the stubs that were never called.
788
+ */
789
+ close(): Stub[];
790
+ }
791
+ interface MockServer {
792
+ readonly url: string;
793
+ readonly port: number;
794
+ /** The newest `JOURNAL_MAX_ENTRIES` requests whose target named no open scope or was refused. */
795
+ readonly unrouted: readonly JournalEntry[];
796
+ /** How many older entries `unrouted` has let go. */
797
+ readonly unroutedDropped: number;
798
+ /** Throws on a name that is taken or cannot be a path segment, and once the server is closed. */
799
+ scope(name: string, stubs?: StubInput[]): MockScope;
800
+ /** Always resolves, destroys open sockets, safe to call twice. */
801
+ close(): Promise<void>;
802
+ }
803
+
669
804
  interface RowParams {
670
805
  template: string;
671
806
  assertions: AssertionConfig[];
672
807
  row: DatasetRow;
673
808
  providerConfig: ProviderConfig;
674
809
  provider: Provider;
810
+ /**
811
+ * The provider a judge asks where `provider` is not the one to ask: on an eval with stubs `provider` is
812
+ * pointed at the stub server, and a judge call is not the eval's own call.
813
+ */
814
+ judgeProvider?: Provider;
675
815
  embedder: Embedder;
676
816
  cache: Cache;
677
817
  now: () => number;
@@ -691,10 +831,24 @@ interface RowParams {
691
831
  */
692
832
  resolveJudge?: (cfg: ProviderConfig) => Provider;
693
833
  /** Builds the experimental `jev` judge of an `llm-judge` check; `onCost` is charged to the row. Without it such a check errors the row. */
694
- jevJudge?: (cfg: JevJudgeConfig, onCost: (usd: number) => void) => Judge;
834
+ jevJudge?: (cfg: JevJudgeConfig, onCost: (cost: {
835
+ cost_usd: number;
836
+ priced?: boolean;
837
+ }) => void) => Judge;
838
+ /** Prices a `jev` judge call of so many input tokens, for a dry run. Without it a dry run leaves such a check out of the estimate. */
839
+ jevCost?: (model: string, inputTokens: number) => {
840
+ cost_usd: number;
841
+ priced?: boolean;
842
+ };
695
843
  }
696
844
  interface RunDeps {
697
- resolveProvider(cfg: ProviderConfig): Provider;
845
+ /** With `stubOrigin` (a scope of the stub server), the provider's client is pointed there, not at the provider. */
846
+ resolveProvider(cfg: ProviderConfig, stubOrigin?: string): Provider;
847
+ /**
848
+ * The stub server of the run, started on the first call and the same one on every call after it; whoever
849
+ * gives it closes it. Called only when a row of an eval with `stubs` runs, so never on a dry run.
850
+ */
851
+ stubServer?: () => Promise<MockServer>;
698
852
  embedder: Embedder;
699
853
  cache: Cache;
700
854
  now: () => number;
@@ -704,6 +858,8 @@ interface RunDeps {
704
858
  connectMcp?: AgentConnect;
705
859
  /** Builds the experimental `jev` judge of an `llm-judge` check. A run without it errors the rows of such a check. */
706
860
  jevJudge?: RowParams['jevJudge'];
861
+ /** Prices a `jev` judge call for a dry run. */
862
+ jevCost?: RowParams['jevCost'];
707
863
  }
708
864
 
709
865
  interface RunOptions {
@@ -729,7 +885,7 @@ declare class NotLoggedInError extends Error {
729
885
  }
730
886
  /** The token was present but the server rejected it (401 — revoked or invalid). (exit 2) */
731
887
  declare class TokenRejectedError extends Error {
732
- constructor();
888
+ constructor(apiUrl?: string);
733
889
  }
734
890
  /** No run to sync, or the run file is unreadable / not a valid RunResult. (exit 2) */
735
891
  declare class SyncFileError extends Error {
@@ -749,7 +905,7 @@ interface SyncDeps {
749
905
  cwd?: string;
750
906
  /** Explicit run JSON to sync instead of `<cwd>/.plune/last-run.json`. */
751
907
  file?: string;
752
- /** Override the API base URL. Falls back to `PLUNE_API_URL`, then the beta default. */
908
+ /** Override the API base URL. Falls back to `PLUNE_API_URL`, then the production default. */
753
909
  apiUrl?: string;
754
910
  /** Token source (injected in tests). Defaults to the real credentials store. */
755
911
  loadToken?: () => string | null;
@@ -810,6 +966,18 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
810
966
  strict: "strict";
811
967
  }>>;
812
968
  }, z.core.$strip>, z.ZodObject<{
969
+ type: z.ZodLiteral<"json-verify">;
970
+ expected: z.ZodOptional<z.ZodAny>;
971
+ mode: z.ZodOptional<z.ZodEnum<{
972
+ exact: "exact";
973
+ unordered: "unordered";
974
+ contains: "contains";
975
+ }>>;
976
+ extract: z.ZodOptional<z.ZodEnum<{
977
+ auto: "auto";
978
+ strict: "strict";
979
+ }>>;
980
+ }, z.core.$strict>, z.ZodObject<{
813
981
  type: z.ZodLiteral<"llm-judge">;
814
982
  criteria: z.ZodString;
815
983
  provider: z.ZodOptional<z.ZodPipe<z.ZodAny, z.ZodTransform<{
@@ -856,8 +1024,8 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
856
1024
  tool: z.ZodString;
857
1025
  args: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>]>;
858
1026
  match: z.ZodOptional<z.ZodEnum<{
859
- partial: "partial";
860
1027
  exact: "exact";
1028
+ partial: "partial";
861
1029
  ignore: "ignore";
862
1030
  }>>;
863
1031
  min_count: z.ZodOptional<z.ZodNumber>;
@@ -959,6 +1127,7 @@ declare const runResultSchema: z.ZodObject<{
959
1127
  from_model: z.ZodNumber;
960
1128
  missed: z.ZodNumber;
961
1129
  errored: z.ZodNumber;
1130
+ stubbed: z.ZodOptional<z.ZodNumber>;
962
1131
  saved: z.ZodObject<{
963
1132
  input_tokens: z.ZodNumber;
964
1133
  output_tokens: z.ZodNumber;
@@ -973,6 +1142,7 @@ declare const runResultSchema: z.ZodObject<{
973
1142
  vars: z.ZodRecord<z.ZodString, z.ZodUnknown>;
974
1143
  output: z.ZodNullable<z.ZodString>;
975
1144
  cached: z.ZodBoolean;
1145
+ stubbed: z.ZodOptional<z.ZodBoolean>;
976
1146
  usage: z.ZodOptional<z.ZodObject<{
977
1147
  input_tokens: z.ZodNumber;
978
1148
  output_tokens: z.ZodNumber;
@@ -1128,6 +1298,13 @@ declare const runResultSchema: z.ZodObject<{
1128
1298
  type: z.ZodString;
1129
1299
  model: z.ZodString;
1130
1300
  }, z.core.$strip>>;
1301
+ stubs: z.ZodOptional<z.ZodObject<{
1302
+ never_called: z.ZodArray<z.ZodNumber>;
1303
+ unmatched: z.ZodArray<z.ZodObject<{
1304
+ scope: z.ZodString;
1305
+ method: z.ZodString;
1306
+ }, z.core.$strip>>;
1307
+ }, z.core.$strip>>;
1131
1308
  traceUrl: z.ZodOptional<z.ZodString>;
1132
1309
  }, z.core.$strip>>;
1133
1310
  }, z.core.$strip>;