@plune-ai/cli 0.3.0 → 0.5.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
@@ -1,3 +1,5 @@
1
+ import { z } from 'zod';
2
+
1
3
  interface Summary {
2
4
  total: number;
3
5
  passed: number;
@@ -212,4 +214,589 @@ interface RunOptions {
212
214
  }
213
215
  declare function handleRun(options: RunOptions, depsFactory?: (config: Config, baseDir: string) => RunDeps): Promise<RunResult>;
214
216
 
215
- export { type AssertionResultRecord, type Config, type EvalResult, type RowResult, type RunError, type RunOptions, type RunResult, type Summary, type Usage, handleRun as run };
217
+ /** No saved token — the user must `plune login` before syncing. (exit 2) */
218
+ declare class NotLoggedInError extends Error {
219
+ constructor();
220
+ }
221
+ /** The token was present but the server rejected it (401 — revoked or invalid). (exit 2) */
222
+ declare class TokenRejectedError extends Error {
223
+ constructor();
224
+ }
225
+ /** No run to sync, or the run file is unreadable / not a valid RunResult. (exit 2) */
226
+ declare class SyncFileError extends Error {
227
+ constructor(message: string);
228
+ }
229
+ /** The API was unreachable (DNS / TLS / offline). Message names the host, never the token. (exit 1) */
230
+ declare class SyncNetworkError extends Error {
231
+ constructor(apiUrl: string);
232
+ }
233
+ /** The server answered with a non-2xx that is not a 401 (e.g. 400 invalid body, 5xx). (exit 1) */
234
+ declare class SyncHttpError extends Error {
235
+ readonly status: number;
236
+ constructor(status: number, detail: string);
237
+ }
238
+ interface SyncDeps {
239
+ /** Base dir the default run file is read from (config dir or cwd). Defaults to `process.cwd()`. */
240
+ cwd?: string;
241
+ /** Explicit run JSON to sync instead of `<cwd>/.plune/last-run.json`. */
242
+ file?: string;
243
+ /** Override the API base URL. Falls back to `PLUNE_API_URL`, then the beta default. */
244
+ apiUrl?: string;
245
+ /** Token source (injected in tests). Defaults to the real credentials store. */
246
+ loadToken?: () => string | null;
247
+ /** HTTP transport (injected in tests — e.g. a real Hono app's `request`). Defaults to global `fetch`. */
248
+ fetchImpl?: typeof fetch;
249
+ }
250
+ interface SyncResult {
251
+ /** Server-assigned run id. */
252
+ id: string;
253
+ /** The `GET /v1/runs/:id` URL where the uploaded run can be read back. */
254
+ url: string;
255
+ }
256
+ /**
257
+ * Upload the latest (or `--file`) local run to `POST {apiUrl}/v1/runs` with the stored Bearer token.
258
+ * Returns the server-assigned id + the read-back URL. Throws a typed error (see the classes above) on
259
+ * every failure path so the CLI can exit cleanly without ever leaking the token or a stack trace.
260
+ */
261
+ declare function handleSync(deps?: SyncDeps): Promise<SyncResult>;
262
+ /**
263
+ * Map a `handleSync` rejection to a friendly stderr line + the exit code to use, or `null` if the error
264
+ * is not a known sync failure (caller then treats it as unexpected).
265
+ */
266
+ declare function reportSyncFailure(err: unknown, write: (s: string) => void): number | null;
267
+
268
+ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
269
+ type: z.ZodLiteral<"exact-match">;
270
+ value: z.ZodString;
271
+ trim: z.ZodOptional<z.ZodBoolean>;
272
+ ignore_case: z.ZodOptional<z.ZodBoolean>;
273
+ }, "strip", z.ZodTypeAny, {
274
+ type: "exact-match";
275
+ value: string;
276
+ trim?: boolean | undefined;
277
+ ignore_case?: boolean | undefined;
278
+ }, {
279
+ type: "exact-match";
280
+ value: string;
281
+ trim?: boolean | undefined;
282
+ ignore_case?: boolean | undefined;
283
+ }>, z.ZodObject<{
284
+ type: z.ZodLiteral<"contains">;
285
+ value: z.ZodString;
286
+ ignore_case: z.ZodOptional<z.ZodBoolean>;
287
+ }, "strip", z.ZodTypeAny, {
288
+ type: "contains";
289
+ value: string;
290
+ ignore_case?: boolean | undefined;
291
+ }, {
292
+ type: "contains";
293
+ value: string;
294
+ ignore_case?: boolean | undefined;
295
+ }>, z.ZodObject<{
296
+ type: z.ZodLiteral<"contains-any">;
297
+ values: z.ZodArray<z.ZodString, "many">;
298
+ ignore_case: z.ZodOptional<z.ZodBoolean>;
299
+ }, "strip", z.ZodTypeAny, {
300
+ type: "contains-any";
301
+ values: string[];
302
+ ignore_case?: boolean | undefined;
303
+ }, {
304
+ type: "contains-any";
305
+ values: string[];
306
+ ignore_case?: boolean | undefined;
307
+ }>, z.ZodObject<{
308
+ type: z.ZodLiteral<"contains-all">;
309
+ values: z.ZodArray<z.ZodString, "many">;
310
+ ignore_case: z.ZodOptional<z.ZodBoolean>;
311
+ }, "strip", z.ZodTypeAny, {
312
+ type: "contains-all";
313
+ values: string[];
314
+ ignore_case?: boolean | undefined;
315
+ }, {
316
+ type: "contains-all";
317
+ values: string[];
318
+ ignore_case?: boolean | undefined;
319
+ }>, z.ZodObject<{
320
+ type: z.ZodLiteral<"json-schema">;
321
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
322
+ extract: z.ZodOptional<z.ZodEnum<["auto", "strict"]>>;
323
+ }, "strip", z.ZodTypeAny, {
324
+ type: "json-schema";
325
+ schema: Record<string, unknown>;
326
+ extract?: "auto" | "strict" | undefined;
327
+ }, {
328
+ type: "json-schema";
329
+ schema: Record<string, unknown>;
330
+ extract?: "auto" | "strict" | undefined;
331
+ }>, z.ZodObject<{
332
+ type: z.ZodLiteral<"llm-judge">;
333
+ criteria: z.ZodString;
334
+ provider: z.ZodOptional<z.ZodObject<{
335
+ type: z.ZodOptional<z.ZodEnum<["anthropic", "openai", "openrouter"]>>;
336
+ model: z.ZodOptional<z.ZodString>;
337
+ temperature: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
338
+ max_tokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
339
+ concurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
340
+ timeout: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
341
+ max_retries: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
342
+ }, "strip", z.ZodTypeAny, {
343
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
344
+ model?: string | undefined;
345
+ temperature?: number | undefined;
346
+ max_tokens?: number | undefined;
347
+ concurrency?: number | undefined;
348
+ timeout?: number | undefined;
349
+ max_retries?: number | undefined;
350
+ }, {
351
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
352
+ model?: string | undefined;
353
+ temperature?: number | undefined;
354
+ max_tokens?: number | undefined;
355
+ concurrency?: number | undefined;
356
+ timeout?: number | undefined;
357
+ max_retries?: number | undefined;
358
+ }>>;
359
+ pass_threshold: z.ZodOptional<z.ZodNumber>;
360
+ }, "strip", z.ZodTypeAny, {
361
+ type: "llm-judge";
362
+ criteria: string;
363
+ provider?: {
364
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
365
+ model?: string | undefined;
366
+ temperature?: number | undefined;
367
+ max_tokens?: number | undefined;
368
+ concurrency?: number | undefined;
369
+ timeout?: number | undefined;
370
+ max_retries?: number | undefined;
371
+ } | undefined;
372
+ pass_threshold?: number | undefined;
373
+ }, {
374
+ type: "llm-judge";
375
+ criteria: string;
376
+ provider?: {
377
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
378
+ model?: string | undefined;
379
+ temperature?: number | undefined;
380
+ max_tokens?: number | undefined;
381
+ concurrency?: number | undefined;
382
+ timeout?: number | undefined;
383
+ max_retries?: number | undefined;
384
+ } | undefined;
385
+ pass_threshold?: number | undefined;
386
+ }>, z.ZodObject<{
387
+ type: z.ZodLiteral<"semantic-similarity">;
388
+ reference: z.ZodString;
389
+ threshold: z.ZodOptional<z.ZodNumber>;
390
+ }, "strip", z.ZodTypeAny, {
391
+ type: "semantic-similarity";
392
+ reference: string;
393
+ threshold?: number | undefined;
394
+ }, {
395
+ type: "semantic-similarity";
396
+ reference: string;
397
+ threshold?: number | undefined;
398
+ }>, z.ZodObject<{
399
+ type: z.ZodLiteral<"faithfulness">;
400
+ context: z.ZodString;
401
+ threshold: z.ZodOptional<z.ZodNumber>;
402
+ }, "strip", z.ZodTypeAny, {
403
+ type: "faithfulness";
404
+ context: string;
405
+ threshold?: number | undefined;
406
+ }, {
407
+ type: "faithfulness";
408
+ context: string;
409
+ threshold?: number | undefined;
410
+ }>, z.ZodObject<{
411
+ type: z.ZodLiteral<"answer-relevance">;
412
+ question: z.ZodString;
413
+ threshold: z.ZodOptional<z.ZodNumber>;
414
+ }, "strip", z.ZodTypeAny, {
415
+ type: "answer-relevance";
416
+ question: string;
417
+ threshold?: number | undefined;
418
+ }, {
419
+ type: "answer-relevance";
420
+ question: string;
421
+ threshold?: number | undefined;
422
+ }>, z.ZodObject<{
423
+ type: z.ZodLiteral<"context-precision">;
424
+ context: z.ZodString;
425
+ question: z.ZodString;
426
+ threshold: z.ZodOptional<z.ZodNumber>;
427
+ }, "strip", z.ZodTypeAny, {
428
+ type: "context-precision";
429
+ context: string;
430
+ question: string;
431
+ threshold?: number | undefined;
432
+ }, {
433
+ type: "context-precision";
434
+ context: string;
435
+ question: string;
436
+ threshold?: number | undefined;
437
+ }>]>;
438
+
439
+ /**
440
+ * Runtime validation for the RunResult contract — the JSON that `plune run --format json` emits.
441
+ *
442
+ * The canonical TypeScript shape is owned by `./results.ts` (golden-pinned, `schemaVersion: 1`,
443
+ * snake_case). This module is its zod mirror: the validator for anything that has to *ingest* that
444
+ * output rather than produce it. `plune sync` validates the local run file with it before uploading,
445
+ * and the Plune platform validates the same body on `POST /v1/runs` — one schema, both ends, so a
446
+ * divergent copy is impossible (the reason it lives here and not in the platform).
447
+ *
448
+ * Superset: an assertion record may carry an optional `binaryVerdicts[]` — the per-question breakdown
449
+ * of an llm-judge verdict `{ question, passed }`. The runner does not emit the field; plain output
450
+ * validates unchanged, and a consumer that enriches a result stays valid. Purely additive.
451
+ */
452
+ /**
453
+ * Version marker for the RunResult contract, type-pinned to the frozen `RunResult['schemaVersion']`
454
+ * literal: if the public contract ever bumps its version, this line fails typecheck until it is
455
+ * updated in lockstep with the golden test.
456
+ */
457
+ declare const RUN_RESULT_SCHEMA_VERSION: RunResult['schemaVersion'];
458
+ declare const binaryVerdictSchema: z.ZodObject<{
459
+ question: z.ZodString;
460
+ passed: z.ZodBoolean;
461
+ }, "strip", z.ZodTypeAny, {
462
+ question: string;
463
+ passed: boolean;
464
+ }, {
465
+ question: string;
466
+ passed: boolean;
467
+ }>;
468
+ declare const assertionResultRecordSchema: z.ZodObject<{
469
+ type: z.ZodString;
470
+ passed: z.ZodBoolean;
471
+ score: z.ZodOptional<z.ZodNumber>;
472
+ reason: z.ZodOptional<z.ZodString>;
473
+ binaryVerdicts: z.ZodOptional<z.ZodArray<z.ZodObject<{
474
+ question: z.ZodString;
475
+ passed: z.ZodBoolean;
476
+ }, "strip", z.ZodTypeAny, {
477
+ question: string;
478
+ passed: boolean;
479
+ }, {
480
+ question: string;
481
+ passed: boolean;
482
+ }>, "many">>;
483
+ }, "strip", z.ZodTypeAny, {
484
+ type: string;
485
+ passed: boolean;
486
+ score?: number | undefined;
487
+ reason?: string | undefined;
488
+ binaryVerdicts?: {
489
+ question: string;
490
+ passed: boolean;
491
+ }[] | undefined;
492
+ }, {
493
+ type: string;
494
+ passed: boolean;
495
+ score?: number | undefined;
496
+ reason?: string | undefined;
497
+ binaryVerdicts?: {
498
+ question: string;
499
+ passed: boolean;
500
+ }[] | undefined;
501
+ }>;
502
+ declare const runResultSchema: z.ZodObject<{
503
+ schemaVersion: z.ZodLiteral<1>;
504
+ plune_version: z.ZodString;
505
+ started_at: z.ZodString;
506
+ finished_at: z.ZodString;
507
+ config_hash: z.ZodString;
508
+ summary: z.ZodObject<{
509
+ total: z.ZodNumber;
510
+ passed: z.ZodNumber;
511
+ failed: z.ZodNumber;
512
+ errored: z.ZodNumber;
513
+ cost_usd: z.ZodNumber;
514
+ duration_ms: z.ZodNumber;
515
+ }, "strip", z.ZodTypeAny, {
516
+ cost_usd: number;
517
+ passed: number;
518
+ failed: number;
519
+ errored: number;
520
+ total: number;
521
+ duration_ms: number;
522
+ }, {
523
+ cost_usd: number;
524
+ passed: number;
525
+ failed: number;
526
+ errored: number;
527
+ total: number;
528
+ duration_ms: number;
529
+ }>;
530
+ evals: z.ZodArray<z.ZodObject<{
531
+ id: z.ZodString;
532
+ tags: z.ZodArray<z.ZodString, "many">;
533
+ rows: z.ZodArray<z.ZodObject<{
534
+ vars: z.ZodRecord<z.ZodString, z.ZodUnknown>;
535
+ output: z.ZodNullable<z.ZodString>;
536
+ cached: z.ZodBoolean;
537
+ usage: z.ZodOptional<z.ZodObject<{
538
+ input_tokens: z.ZodNumber;
539
+ output_tokens: z.ZodNumber;
540
+ cost_usd: z.ZodNumber;
541
+ }, "strip", z.ZodTypeAny, {
542
+ cost_usd: number;
543
+ input_tokens: number;
544
+ output_tokens: number;
545
+ }, {
546
+ cost_usd: number;
547
+ input_tokens: number;
548
+ output_tokens: number;
549
+ }>>;
550
+ latency_ms: z.ZodOptional<z.ZodNumber>;
551
+ error: z.ZodOptional<z.ZodObject<{
552
+ code: z.ZodString;
553
+ message: z.ZodString;
554
+ }, "strip", z.ZodTypeAny, {
555
+ code: string;
556
+ message: string;
557
+ }, {
558
+ code: string;
559
+ message: string;
560
+ }>>;
561
+ assertions: z.ZodArray<z.ZodObject<{
562
+ type: z.ZodString;
563
+ passed: z.ZodBoolean;
564
+ score: z.ZodOptional<z.ZodNumber>;
565
+ reason: z.ZodOptional<z.ZodString>;
566
+ binaryVerdicts: z.ZodOptional<z.ZodArray<z.ZodObject<{
567
+ question: z.ZodString;
568
+ passed: z.ZodBoolean;
569
+ }, "strip", z.ZodTypeAny, {
570
+ question: string;
571
+ passed: boolean;
572
+ }, {
573
+ question: string;
574
+ passed: boolean;
575
+ }>, "many">>;
576
+ }, "strip", z.ZodTypeAny, {
577
+ type: string;
578
+ passed: boolean;
579
+ score?: number | undefined;
580
+ reason?: string | undefined;
581
+ binaryVerdicts?: {
582
+ question: string;
583
+ passed: boolean;
584
+ }[] | undefined;
585
+ }, {
586
+ type: string;
587
+ passed: boolean;
588
+ score?: number | undefined;
589
+ reason?: string | undefined;
590
+ binaryVerdicts?: {
591
+ question: string;
592
+ passed: boolean;
593
+ }[] | undefined;
594
+ }>, "many">;
595
+ }, "strip", z.ZodTypeAny, {
596
+ vars: Record<string, unknown>;
597
+ assertions: {
598
+ type: string;
599
+ passed: boolean;
600
+ score?: number | undefined;
601
+ reason?: string | undefined;
602
+ binaryVerdicts?: {
603
+ question: string;
604
+ passed: boolean;
605
+ }[] | undefined;
606
+ }[];
607
+ output: string | null;
608
+ cached: boolean;
609
+ error?: {
610
+ code: string;
611
+ message: string;
612
+ } | undefined;
613
+ usage?: {
614
+ cost_usd: number;
615
+ input_tokens: number;
616
+ output_tokens: number;
617
+ } | undefined;
618
+ latency_ms?: number | undefined;
619
+ }, {
620
+ vars: Record<string, unknown>;
621
+ assertions: {
622
+ type: string;
623
+ passed: boolean;
624
+ score?: number | undefined;
625
+ reason?: string | undefined;
626
+ binaryVerdicts?: {
627
+ question: string;
628
+ passed: boolean;
629
+ }[] | undefined;
630
+ }[];
631
+ output: string | null;
632
+ cached: boolean;
633
+ error?: {
634
+ code: string;
635
+ message: string;
636
+ } | undefined;
637
+ usage?: {
638
+ cost_usd: number;
639
+ input_tokens: number;
640
+ output_tokens: number;
641
+ } | undefined;
642
+ latency_ms?: number | undefined;
643
+ }>, "many">;
644
+ passed: z.ZodBoolean;
645
+ }, "strip", z.ZodTypeAny, {
646
+ id: string;
647
+ tags: string[];
648
+ passed: boolean;
649
+ rows: {
650
+ vars: Record<string, unknown>;
651
+ assertions: {
652
+ type: string;
653
+ passed: boolean;
654
+ score?: number | undefined;
655
+ reason?: string | undefined;
656
+ binaryVerdicts?: {
657
+ question: string;
658
+ passed: boolean;
659
+ }[] | undefined;
660
+ }[];
661
+ output: string | null;
662
+ cached: boolean;
663
+ error?: {
664
+ code: string;
665
+ message: string;
666
+ } | undefined;
667
+ usage?: {
668
+ cost_usd: number;
669
+ input_tokens: number;
670
+ output_tokens: number;
671
+ } | undefined;
672
+ latency_ms?: number | undefined;
673
+ }[];
674
+ }, {
675
+ id: string;
676
+ tags: string[];
677
+ passed: boolean;
678
+ rows: {
679
+ vars: Record<string, unknown>;
680
+ assertions: {
681
+ type: string;
682
+ passed: boolean;
683
+ score?: number | undefined;
684
+ reason?: string | undefined;
685
+ binaryVerdicts?: {
686
+ question: string;
687
+ passed: boolean;
688
+ }[] | undefined;
689
+ }[];
690
+ output: string | null;
691
+ cached: boolean;
692
+ error?: {
693
+ code: string;
694
+ message: string;
695
+ } | undefined;
696
+ usage?: {
697
+ cost_usd: number;
698
+ input_tokens: number;
699
+ output_tokens: number;
700
+ } | undefined;
701
+ latency_ms?: number | undefined;
702
+ }[];
703
+ }>, "many">;
704
+ }, "strip", z.ZodTypeAny, {
705
+ evals: {
706
+ id: string;
707
+ tags: string[];
708
+ passed: boolean;
709
+ rows: {
710
+ vars: Record<string, unknown>;
711
+ assertions: {
712
+ type: string;
713
+ passed: boolean;
714
+ score?: number | undefined;
715
+ reason?: string | undefined;
716
+ binaryVerdicts?: {
717
+ question: string;
718
+ passed: boolean;
719
+ }[] | undefined;
720
+ }[];
721
+ output: string | null;
722
+ cached: boolean;
723
+ error?: {
724
+ code: string;
725
+ message: string;
726
+ } | undefined;
727
+ usage?: {
728
+ cost_usd: number;
729
+ input_tokens: number;
730
+ output_tokens: number;
731
+ } | undefined;
732
+ latency_ms?: number | undefined;
733
+ }[];
734
+ }[];
735
+ schemaVersion: 1;
736
+ plune_version: string;
737
+ summary: {
738
+ cost_usd: number;
739
+ passed: number;
740
+ failed: number;
741
+ errored: number;
742
+ total: number;
743
+ duration_ms: number;
744
+ };
745
+ started_at: string;
746
+ finished_at: string;
747
+ config_hash: string;
748
+ }, {
749
+ evals: {
750
+ id: string;
751
+ tags: string[];
752
+ passed: boolean;
753
+ rows: {
754
+ vars: Record<string, unknown>;
755
+ assertions: {
756
+ type: string;
757
+ passed: boolean;
758
+ score?: number | undefined;
759
+ reason?: string | undefined;
760
+ binaryVerdicts?: {
761
+ question: string;
762
+ passed: boolean;
763
+ }[] | undefined;
764
+ }[];
765
+ output: string | null;
766
+ cached: boolean;
767
+ error?: {
768
+ code: string;
769
+ message: string;
770
+ } | undefined;
771
+ usage?: {
772
+ cost_usd: number;
773
+ input_tokens: number;
774
+ output_tokens: number;
775
+ } | undefined;
776
+ latency_ms?: number | undefined;
777
+ }[];
778
+ }[];
779
+ schemaVersion: 1;
780
+ plune_version: string;
781
+ summary: {
782
+ cost_usd: number;
783
+ passed: number;
784
+ failed: number;
785
+ errored: number;
786
+ total: number;
787
+ duration_ms: number;
788
+ };
789
+ started_at: string;
790
+ finished_at: string;
791
+ config_hash: string;
792
+ }>;
793
+ /**
794
+ * Type inferred from the zod mirror — structurally a superset of the frozen `RunResult`
795
+ * (adds optional `binaryVerdicts`). The canonical `RunResult` remains the source of truth.
796
+ */
797
+ type ParsedRunResult = z.infer<typeof runResultSchema>;
798
+ type BinaryVerdict = z.infer<typeof binaryVerdictSchema>;
799
+ /** Parse + validate an unknown value as a RunResult. Throws ZodError on failure. */
800
+ declare function parseRunResult(value: unknown): ParsedRunResult;
801
+
802
+ export { type AssertionResultRecord, type BinaryVerdict, type Config, type EvalResult, NotLoggedInError, type ParsedRunResult, RUN_RESULT_SCHEMA_VERSION, type RowResult, type RunError, type RunOptions, type RunResult, type Summary, type SyncDeps, SyncFileError, SyncHttpError, SyncNetworkError, type SyncResult, TokenRejectedError, type Usage, assertionConfigSchema, assertionResultRecordSchema, binaryVerdictSchema, parseRunResult, reportSyncFailure, handleRun as run, runResultSchema, handleSync as sync };