niceeval 0.14.4-canary.67 → 0.15.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.
Files changed (53) hide show
  1. package/INDEX.md +2 -2
  2. package/dist/adapter.cjs +162 -14
  3. package/dist/adapter.cjs.map +1 -1
  4. package/dist/adapter.d.cts +82 -17
  5. package/dist/adapter.d.mts +82 -17
  6. package/dist/adapter.d.ts +82 -17
  7. package/dist/agents/index.cjs.map +1 -1
  8. package/dist/agents/index.d.cts +2 -1
  9. package/dist/agents/index.d.mts +2 -1
  10. package/dist/agents/index.d.ts +2 -1
  11. package/dist/assertions/api.cjs.map +1 -1
  12. package/dist/assertions/api.d.cts +32 -12
  13. package/dist/assertions/api.d.mts +32 -12
  14. package/dist/assertions/api.d.ts +32 -12
  15. package/dist/assertions/runtime.cjs +4 -1
  16. package/dist/assertions/runtime.cjs.map +1 -1
  17. package/dist/coordination/platform/node-process-identity.cjs +99 -21
  18. package/dist/coordination/platform/node-process-identity.cjs.map +1 -1
  19. package/dist/coordination/platform/node-process-identity.d.cts +17 -1
  20. package/dist/coordination/platform/node-process-identity.d.mts +17 -1
  21. package/dist/coordination/platform/node-process-identity.d.ts +17 -1
  22. package/dist/coordination/platform/node-process-identity.js +2 -0
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.mts +2 -2
  26. package/dist/index.d.ts +2 -2
  27. package/dist/record/sqlite/current-schema.cjs +437 -5
  28. package/dist/record/sqlite/current-schema.cjs.map +1 -1
  29. package/dist/record/sqlite/current-schema.d.cts +4 -4
  30. package/dist/record/sqlite/current-schema.d.mts +4 -4
  31. package/dist/record/sqlite/current-schema.d.ts +4 -4
  32. package/dist/record/sqlite/schema.d.cts +1 -1
  33. package/dist/record/sqlite/schema.d.mts +1 -1
  34. package/dist/record/sqlite/schema.d.ts +1 -1
  35. package/dist/runner/attempt-resources.cjs +2 -1
  36. package/dist/runner/attempt-resources.cjs.map +1 -1
  37. package/dist/runner/attempt-resources.d.cts +2 -1
  38. package/dist/runner/attempt-resources.d.mts +2 -1
  39. package/dist/runner/attempt-resources.d.ts +2 -1
  40. package/dist/runner/attempt.cjs +7 -3
  41. package/dist/runner/attempt.cjs.map +1 -1
  42. package/dist/runner/node-process-identity.js +2 -0
  43. package/dist/types.cjs.map +1 -1
  44. package/dist/types.d.cts +2 -1
  45. package/dist/types.d.mts +2 -1
  46. package/dist/types.d.ts +2 -1
  47. package/dist/view/function-runtime.mjs +528 -29
  48. package/docs-site/zh/reference/define-agent.mdx +125 -3
  49. package/docs-site/zh/troubleshooting/debugging.mdx +2 -0
  50. package/docs-site/zh/tutorials/custom-application.mdx +87 -17
  51. package/docs-site/zh/tutorials/evaluation-kinds.mdx +1 -1
  52. package/docs-site/zh/tutorials/viewing-results.mdx +2 -1
  53. package/package.json +1 -1
@@ -532,6 +532,36 @@ export type PostRunBooleanAssertionHandle<Kind extends AssertionEvaluationKind,
532
532
  export interface DirectScoreAssertionHandle extends AssertionHandleBase<false, true> {
533
533
  readonly kind: "direct-score";
534
534
  }
535
+ /**
536
+ * Definition-time handle shared by Adapter Assertion factories. It exposes
537
+ * only operations whose meaning is identical in Pass and Score Evals; the
538
+ * bound Eval factory replaces it with the native handle for its Kind.
539
+ */
540
+ export interface PolymorphicBooleanAssertionHandle<out Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {
541
+ readonly kind: "boolean";
542
+ readonly [assertionGateStateBrand]: HasGate;
543
+ gate(this: PolymorphicBooleanAssertionHandle<Refined, false>): PolymorphicBooleanAssertionHandle<Refined, true>;
544
+ orStop(): Promise<Refined>;
545
+ }
546
+ /** Definition-time measurement counterpart to PolymorphicBooleanAssertionHandle. */
547
+ export interface PolymorphicMeasurementAssertionHandle<HasCondition extends boolean = false> extends AssertionHandleBase<HasCondition, false> {
548
+ readonly kind: "measurement";
549
+ gate(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): PolymorphicMeasurementAssertionHandle<true>;
550
+ orStop(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): Promise<number>;
551
+ orStop(this: PolymorphicMeasurementAssertionHandle<true>): Promise<number>;
552
+ }
553
+ export type AssertionCheckKind = AssertionEvaluationKind | "polymorphic";
554
+ type CheckedBooleanHandle<Kind extends AssertionCheckKind, Refined> = Kind extends AssertionEvaluationKind ? BooleanAssertionHandle<Kind, Refined> : PolymorphicBooleanAssertionHandle<Refined>;
555
+ type CheckedMeasurementHandle<Kind extends AssertionCheckKind> = Kind extends AssertionEvaluationKind ? MeasurementAssertionHandle<Kind> : PolymorphicMeasurementAssertionHandle;
556
+ /** Single owner for the public check overload set, including Adapter-polymorphic factories. */
557
+ export interface AssertionCheck<Kind extends AssertionCheckKind> {
558
+ <Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): CheckedBooleanHandle<Kind, Refined>;
559
+ <Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): CheckedBooleanHandle<Kind, Value>;
560
+ <S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): CheckedBooleanHandle<Kind, ManagedToolCalls<S>>;
561
+ <S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): CheckedBooleanHandle<Kind, ManagedEventOccurrences<S>>;
562
+ <Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): CheckedBooleanHandle<Kind, Value>;
563
+ <Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): CheckedMeasurementHandle<Kind>;
564
+ }
535
565
  export interface AssertionGroupContext {
536
566
  /**
537
567
  * Runs an ordinary author callback with one display-only group segment. The
@@ -542,21 +572,11 @@ export interface AssertionGroupContext {
542
572
  }
543
573
  export interface PassAssertionsContext extends AssertionGroupContext {
544
574
  readonly evaluationKind: "pass";
545
- check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): PassBooleanAssertionHandle<Refined>;
546
- check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): PassBooleanAssertionHandle<Value>;
547
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): PassBooleanAssertionHandle<ManagedToolCalls<S>>;
548
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): PassBooleanAssertionHandle<ManagedEventOccurrences<S>>;
549
- check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): PassBooleanAssertionHandle<Value>;
550
- check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): PassMeasurementAssertionHandle;
575
+ readonly check: AssertionCheck<"pass">;
551
576
  }
552
577
  export interface ScoreAssertionsContext extends AssertionGroupContext {
553
578
  readonly evaluationKind: "score";
554
- check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): ScoreBooleanAssertionHandle<Refined>;
555
- check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): ScoreBooleanAssertionHandle<Value>;
556
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): ScoreBooleanAssertionHandle<ManagedToolCalls<S>>;
557
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): ScoreBooleanAssertionHandle<ManagedEventOccurrences<S>>;
558
- check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): ScoreBooleanAssertionHandle<Value>;
559
- check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): ScoreMeasurementAssertionHandle;
579
+ readonly check: AssertionCheck<"score">;
560
580
  score(points: number): DirectScoreAssertionHandle;
561
581
  }
562
582
  export type AssertionsContext<Kind extends AssertionEvaluationKind> = Kind extends "pass" ? PassAssertionsContext : ScoreAssertionsContext;
@@ -532,6 +532,36 @@ export type PostRunBooleanAssertionHandle<Kind extends AssertionEvaluationKind,
532
532
  export interface DirectScoreAssertionHandle extends AssertionHandleBase<false, true> {
533
533
  readonly kind: "direct-score";
534
534
  }
535
+ /**
536
+ * Definition-time handle shared by Adapter Assertion factories. It exposes
537
+ * only operations whose meaning is identical in Pass and Score Evals; the
538
+ * bound Eval factory replaces it with the native handle for its Kind.
539
+ */
540
+ export interface PolymorphicBooleanAssertionHandle<out Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {
541
+ readonly kind: "boolean";
542
+ readonly [assertionGateStateBrand]: HasGate;
543
+ gate(this: PolymorphicBooleanAssertionHandle<Refined, false>): PolymorphicBooleanAssertionHandle<Refined, true>;
544
+ orStop(): Promise<Refined>;
545
+ }
546
+ /** Definition-time measurement counterpart to PolymorphicBooleanAssertionHandle. */
547
+ export interface PolymorphicMeasurementAssertionHandle<HasCondition extends boolean = false> extends AssertionHandleBase<HasCondition, false> {
548
+ readonly kind: "measurement";
549
+ gate(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): PolymorphicMeasurementAssertionHandle<true>;
550
+ orStop(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): Promise<number>;
551
+ orStop(this: PolymorphicMeasurementAssertionHandle<true>): Promise<number>;
552
+ }
553
+ export type AssertionCheckKind = AssertionEvaluationKind | "polymorphic";
554
+ type CheckedBooleanHandle<Kind extends AssertionCheckKind, Refined> = Kind extends AssertionEvaluationKind ? BooleanAssertionHandle<Kind, Refined> : PolymorphicBooleanAssertionHandle<Refined>;
555
+ type CheckedMeasurementHandle<Kind extends AssertionCheckKind> = Kind extends AssertionEvaluationKind ? MeasurementAssertionHandle<Kind> : PolymorphicMeasurementAssertionHandle;
556
+ /** Single owner for the public check overload set, including Adapter-polymorphic factories. */
557
+ export interface AssertionCheck<Kind extends AssertionCheckKind> {
558
+ <Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): CheckedBooleanHandle<Kind, Refined>;
559
+ <Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): CheckedBooleanHandle<Kind, Value>;
560
+ <S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): CheckedBooleanHandle<Kind, ManagedToolCalls<S>>;
561
+ <S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): CheckedBooleanHandle<Kind, ManagedEventOccurrences<S>>;
562
+ <Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): CheckedBooleanHandle<Kind, Value>;
563
+ <Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): CheckedMeasurementHandle<Kind>;
564
+ }
535
565
  export interface AssertionGroupContext {
536
566
  /**
537
567
  * Runs an ordinary author callback with one display-only group segment. The
@@ -542,21 +572,11 @@ export interface AssertionGroupContext {
542
572
  }
543
573
  export interface PassAssertionsContext extends AssertionGroupContext {
544
574
  readonly evaluationKind: "pass";
545
- check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): PassBooleanAssertionHandle<Refined>;
546
- check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): PassBooleanAssertionHandle<Value>;
547
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): PassBooleanAssertionHandle<ManagedToolCalls<S>>;
548
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): PassBooleanAssertionHandle<ManagedEventOccurrences<S>>;
549
- check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): PassBooleanAssertionHandle<Value>;
550
- check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): PassMeasurementAssertionHandle;
575
+ readonly check: AssertionCheck<"pass">;
551
576
  }
552
577
  export interface ScoreAssertionsContext extends AssertionGroupContext {
553
578
  readonly evaluationKind: "score";
554
- check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): ScoreBooleanAssertionHandle<Refined>;
555
- check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): ScoreBooleanAssertionHandle<Value>;
556
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): ScoreBooleanAssertionHandle<ManagedToolCalls<S>>;
557
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): ScoreBooleanAssertionHandle<ManagedEventOccurrences<S>>;
558
- check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): ScoreBooleanAssertionHandle<Value>;
559
- check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): ScoreMeasurementAssertionHandle;
579
+ readonly check: AssertionCheck<"score">;
560
580
  score(points: number): DirectScoreAssertionHandle;
561
581
  }
562
582
  export type AssertionsContext<Kind extends AssertionEvaluationKind> = Kind extends "pass" ? PassAssertionsContext : ScoreAssertionsContext;
@@ -532,6 +532,36 @@ export type PostRunBooleanAssertionHandle<Kind extends AssertionEvaluationKind,
532
532
  export interface DirectScoreAssertionHandle extends AssertionHandleBase<false, true> {
533
533
  readonly kind: "direct-score";
534
534
  }
535
+ /**
536
+ * Definition-time handle shared by Adapter Assertion factories. It exposes
537
+ * only operations whose meaning is identical in Pass and Score Evals; the
538
+ * bound Eval factory replaces it with the native handle for its Kind.
539
+ */
540
+ export interface PolymorphicBooleanAssertionHandle<out Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {
541
+ readonly kind: "boolean";
542
+ readonly [assertionGateStateBrand]: HasGate;
543
+ gate(this: PolymorphicBooleanAssertionHandle<Refined, false>): PolymorphicBooleanAssertionHandle<Refined, true>;
544
+ orStop(): Promise<Refined>;
545
+ }
546
+ /** Definition-time measurement counterpart to PolymorphicBooleanAssertionHandle. */
547
+ export interface PolymorphicMeasurementAssertionHandle<HasCondition extends boolean = false> extends AssertionHandleBase<HasCondition, false> {
548
+ readonly kind: "measurement";
549
+ gate(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): PolymorphicMeasurementAssertionHandle<true>;
550
+ orStop(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): Promise<number>;
551
+ orStop(this: PolymorphicMeasurementAssertionHandle<true>): Promise<number>;
552
+ }
553
+ export type AssertionCheckKind = AssertionEvaluationKind | "polymorphic";
554
+ type CheckedBooleanHandle<Kind extends AssertionCheckKind, Refined> = Kind extends AssertionEvaluationKind ? BooleanAssertionHandle<Kind, Refined> : PolymorphicBooleanAssertionHandle<Refined>;
555
+ type CheckedMeasurementHandle<Kind extends AssertionCheckKind> = Kind extends AssertionEvaluationKind ? MeasurementAssertionHandle<Kind> : PolymorphicMeasurementAssertionHandle;
556
+ /** Single owner for the public check overload set, including Adapter-polymorphic factories. */
557
+ export interface AssertionCheck<Kind extends AssertionCheckKind> {
558
+ <Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): CheckedBooleanHandle<Kind, Refined>;
559
+ <Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): CheckedBooleanHandle<Kind, Value>;
560
+ <S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): CheckedBooleanHandle<Kind, ManagedToolCalls<S>>;
561
+ <S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): CheckedBooleanHandle<Kind, ManagedEventOccurrences<S>>;
562
+ <Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): CheckedBooleanHandle<Kind, Value>;
563
+ <Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): CheckedMeasurementHandle<Kind>;
564
+ }
535
565
  export interface AssertionGroupContext {
536
566
  /**
537
567
  * Runs an ordinary author callback with one display-only group segment. The
@@ -542,21 +572,11 @@ export interface AssertionGroupContext {
542
572
  }
543
573
  export interface PassAssertionsContext extends AssertionGroupContext {
544
574
  readonly evaluationKind: "pass";
545
- check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): PassBooleanAssertionHandle<Refined>;
546
- check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): PassBooleanAssertionHandle<Value>;
547
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): PassBooleanAssertionHandle<ManagedToolCalls<S>>;
548
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): PassBooleanAssertionHandle<ManagedEventOccurrences<S>>;
549
- check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): PassBooleanAssertionHandle<Value>;
550
- check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): PassMeasurementAssertionHandle;
575
+ readonly check: AssertionCheck<"pass">;
551
576
  }
552
577
  export interface ScoreAssertionsContext extends AssertionGroupContext {
553
578
  readonly evaluationKind: "score";
554
- check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, "value">): ScoreBooleanAssertionHandle<Refined>;
555
- check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): ScoreBooleanAssertionHandle<Value>;
556
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): ScoreBooleanAssertionHandle<ManagedToolCalls<S>>;
557
- check<S extends "turn" | "session" | "attempt">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): ScoreBooleanAssertionHandle<ManagedEventOccurrences<S>>;
558
- check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): ScoreBooleanAssertionHandle<Value>;
559
- check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): ScoreMeasurementAssertionHandle;
579
+ readonly check: AssertionCheck<"score">;
560
580
  score(points: number): DirectScoreAssertionHandle;
561
581
  }
562
582
  export type AssertionsContext<Kind extends AssertionEvaluationKind> = Kind extends "pass" ? PassAssertionsContext : ScoreAssertionsContext;
@@ -109,7 +109,10 @@ function boundedSnapshotValue(value, depth, state) {
109
109
  return boundedSnapshotString(value, state);
110
110
  }
111
111
  if (typeof value === "undefined") {
112
- markTruncated(state);
112
+ // undefined has no JSON primitive representation, but the tagged
113
+ // placeholder below preserves the fact exactly. It is therefore complete
114
+ // snapshot material; only values that cannot be represented safely or
115
+ // boundedly should make coverage partial.
113
116
  return marker("undefined");
114
117
  }
115
118
  if (typeof value === "bigint" || typeof value === "symbol" || typeof value === "function") {