niceeval 0.14.4-canary.66 → 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
@@ -1,4 +1,4 @@
1
- import type { AssertionSubject, AssertionsRuntime, MeasurementAssertionHandle } from "./assertions/api.mjs";
1
+ import type { AssertionCheck, AssertionSubject, AssertionsRuntime, BooleanAssertionHandle, MeasurementAssertionHandle, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle } from "./assertions/api.mjs";
2
2
  import type { ScoreMatch } from "./assertions/match.mjs";
3
3
  import type { EvalDefinition, EvalInput, ScoreEvalInput } from "./runner/types.mjs";
4
4
  import type { EvaluationKind } from "./shared/evaluation.mjs";
@@ -8,6 +8,27 @@ import type { AdapterIdentity } from "./record/model/run-context.mjs";
8
8
  export type { AdapterIdentity } from "./record/model/run-context.mjs";
9
9
  declare const ADAPTER_CONTRACT_TOKEN: unique symbol;
10
10
  declare const EVAL_ADAPTER_CONTRACT_TOKEN: unique symbol;
11
+ /**
12
+ * Synchronously assembles Attempt-local Assertion methods from the guarded app
13
+ * facade and the shared check registrar. The returned object must contain only
14
+ * ordinary, synchronously returning methods. Generic and overloaded Assertion
15
+ * sugar is intentionally not callable after binding; use ordinary named
16
+ * parameters so argument and native handle types remain exact.
17
+ */
18
+ export type AdapterAssertionsFactory<Context extends object, Assertions extends object = object> = (context: AdapterAssertionsFactoryContext<Context>) => Assertions;
19
+ /**
20
+ * Definition inputs for Adapter Assertion sugar. `app` becomes callable after
21
+ * assembly, and `check` may only be called by a returned Assertion method.
22
+ */
23
+ export interface AdapterAssertionsFactoryContext<Context extends object> {
24
+ readonly app: Readonly<Context>;
25
+ readonly check: AssertionCheck<"polymorphic">;
26
+ }
27
+ type BoundAdapterAssertionResult<Kind extends EvaluationKind, Result> = Result extends PolymorphicBooleanAssertionHandle<infer Refined, infer HasGate> ? BooleanAssertionHandle<Kind, Refined, HasGate> : Result extends PolymorphicMeasurementAssertionHandle<infer HasCondition> ? MeasurementAssertionHandle<Kind, HasCondition> : never;
28
+ type BoundAdapterAssertionMethod<Kind extends EvaluationKind, Method> = Method extends (...args: infer Args) => infer Result ? ((...args: Args) => Result) extends Method ? (...args: Args) => BoundAdapterAssertionResult<Kind, Result> : never : never;
29
+ type AdapterAssertionsFor<Assertions extends object | undefined, Kind extends EvaluationKind> = Assertions extends object ? {
30
+ readonly [Key in keyof Assertions]: BoundAdapterAssertionMethod<Kind, Assertions[Key]>;
31
+ } : {};
11
32
  /** Keys owned by the neutral Eval runtime or unsafe on a merged object root. */
12
33
  declare const RESERVED_ADAPTER_CONTEXT_KEYS: readonly ["evaluationKind", "check", "judge", "factuality", "faithfulness", "instructionFollowing", "pairwisePreference", "closeQA", "score", "group", "skip", "signal", "model", "reasoningEffort", "flags", "progress", "diagnostic", "log", "then", "Object", "constructor", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"];
13
34
  export type ReservedAdapterContextKey = typeof RESERVED_ADAPTER_CONTEXT_KEYS[number];
@@ -15,19 +36,47 @@ type InvalidContextBranch<Context> = Context extends unknown ? Context extends o
15
36
  type AdapterContextValidation<Context> = unknown extends Context ? unknown : [InvalidContextBranch<Context>] extends [never] ? unknown : {
16
37
  readonly invalidAdapterContext: InvalidContextBranch<Context>;
17
38
  };
39
+ type InvalidAssertionMethodKey<Context extends object, Assertions> = Assertions extends object ? {
40
+ [Key in keyof Assertions]: Key extends string ? Key extends ReservedAdapterContextKey | keyof Context ? Key : Assertions[Key] extends (...args: readonly never[]) => infer Result ? Result extends PolymorphicBooleanAssertionHandle<unknown, boolean> | PolymorphicMeasurementAssertionHandle<boolean> ? never : Key : Key : Key;
41
+ }[keyof Assertions] : "assertions";
42
+ type InvalidAdapterAssertions<Context extends object, Assertions extends object> = InvalidAssertionMethodKey<Context, Assertions>;
43
+ type AdapterAssertionsValidation<Context extends object, Assertions extends object> = [InvalidAdapterAssertions<Context, Assertions>] extends [never] ? unknown : {
44
+ readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;
45
+ };
46
+ type AdapterAssertionsValidationArgs<Context extends object, Assertions extends object> = [InvalidAdapterAssertions<Context, Assertions>] extends [never] ? [] : [error: {
47
+ readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;
48
+ }];
18
49
  type AdapterFactory<Context extends object> = (context: AdapterCreateContext) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;
50
+ export interface AdapterCleanupContext {
51
+ /** 当前 Adapter cleanup 总窗口的取消信号。它独立于 Attempt signal,并在 30 秒总预算结束时取消。 */
52
+ readonly signal: AbortSignal;
53
+ }
19
54
  export interface AdapterCreateContext {
55
+ /** 当前 Eval 的公开 ID。 */
20
56
  readonly evalId: string;
57
+ /** 当前 Experiment 的公开 ID。 */
21
58
  readonly experimentId: string;
59
+ /** 当前 Attempt 的零起始序号。 */
22
60
  readonly attempt: number;
61
+ /** Attempt 执行信号;取消或超时后会中止,不用于 cleanup 窗口。 */
23
62
  readonly signal: AbortSignal;
63
+ /** Experiment 选择的模型。 */
24
64
  readonly model?: string;
65
+ /** Experiment 选择的推理强度。 */
25
66
  readonly reasoningEffort?: string;
67
+ /** Experiment 传给 Adapter 的只读 flags。 */
26
68
  readonly flags: Readonly<Record<string, JsonValue>>;
69
+ /** 更新当前 Attempt 的人读进度。 */
27
70
  progress(update: ProgressUpdate): void;
71
+ /** 为当前 Attempt 追加结构化诊断。 */
28
72
  diagnostic(input: DiagnosticInput): void;
73
+ /** 为当前 Attempt 追加日志。 */
29
74
  log(message: string): void;
30
- onCleanup(cleanup: () => void | Promise<void>): void;
75
+ /**
76
+ * 登记 Attempt-local 资源释放。回调按全局 LIFO 执行;一项失败不会跳过其余项。
77
+ * 零参数回调仍可直接传入。传入的 context 已冻结,同一 cleanup 窗口的回调共享一个 signal。
78
+ */
79
+ onCleanup(cleanup: (context: AdapterCleanupContext) => void | Promise<void>): void;
31
80
  }
32
81
  type EvalContextBase<Kind extends EvaluationKind> = JudgePresetMethods<Kind> & {
33
82
  readonly evaluationKind: Kind;
@@ -55,29 +104,32 @@ type AdapterScoreEvalFields = Omit<ScoreEvalInput<undefined>, "test" | "sandbox"
55
104
  readonly sandbox?: never;
56
105
  readonly diff?: never;
57
106
  };
58
- export type AdapterEvalInput<Context extends object> = AdapterEvalFields & {
59
- test(t: EvalContext<"pass"> & Readonly<Context>): void | Promise<void>;
107
+ export type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined> = AdapterEvalFields & {
108
+ test(t: EvalContext<"pass"> & Readonly<Context> & AdapterAssertionsFor<Assertions, "pass">): void | Promise<void>;
60
109
  };
61
- export type AdapterScoreEvalInput<Context extends object> = AdapterScoreEvalFields & {
62
- test(t: EvalContext<"score"> & Readonly<Context>): void | Promise<void>;
110
+ export type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined> = AdapterScoreEvalFields & {
111
+ test(t: EvalContext<"score"> & Readonly<Context> & AdapterAssertionsFor<Assertions, "score">): void | Promise<void>;
63
112
  };
64
- interface AdapterContractToken<Context extends object> {
113
+ interface AdapterContractToken<Context extends object, Assertions extends object | undefined> {
65
114
  readonly name: string;
115
+ readonly assertions: AdapterAssertionsFactory<Context> | undefined;
116
+ /** Keeps the Assertion method shape invariant without exposing a constructible brand. */
117
+ readonly assertionTypes: (value: Assertions) => Assertions;
66
118
  /** Keeps the context parameter invariant without exposing a constructible brand. */
67
119
  readonly context: (value: Context) => Context;
68
120
  }
69
- export interface AdapterEvalDefinition<Kind extends EvaluationKind, Context extends object> extends EvalDefinition<Kind, EvalContext<Kind> & Readonly<Context>, undefined> {
70
- readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context>;
121
+ export interface AdapterEvalDefinition<Kind extends EvaluationKind, Context extends object, Assertions extends object | undefined = undefined> extends EvalDefinition<Kind, EvalContext<Kind> & Readonly<Context> & AdapterAssertionsFor<Assertions, Kind>, undefined> {
122
+ readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions>;
71
123
  }
72
124
  /** @internal Existential discovery view; concrete bound factories retain their exact Context. */
73
125
  export interface AdapterRuntimeEvalDefinition<Kind extends EvaluationKind> extends EvalDefinition<Kind, never, undefined> {
74
126
  readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: object;
75
127
  }
76
128
  /** Common public surface for an Adapter definition with bound Eval factories. */
77
- export interface AdapterDefinition<Context extends object> {
129
+ export interface AdapterDefinition<Context extends object, Assertions extends object | undefined = undefined> {
78
130
  readonly name: string;
79
- defineEval(input: AdapterEvalInput<Context>): AdapterEvalDefinition<"pass", Context>;
80
- defineScoreEval(input: AdapterScoreEvalInput<Context>): AdapterEvalDefinition<"score", Context>;
131
+ defineEval(input: AdapterEvalInput<Context, Assertions>): AdapterEvalDefinition<"pass", Context, Assertions>;
132
+ defineScoreEval(input: AdapterScoreEvalInput<Context, Assertions>): AdapterEvalDefinition<"score", Context, Assertions>;
81
133
  }
82
134
  /** Existential runtime view used by Experiment without erasing a concrete context to `any`. */
83
135
  export interface AdapterRuntimeDefinition {
@@ -90,11 +142,11 @@ export interface AdapterRuntimeDefinition {
90
142
  readonly defineScoreEval: (...args: never[]) => unknown;
91
143
  create(context: AdapterCreateContext): object | Promise<object>;
92
144
  }
93
- export interface AdapterImplementation<Context extends object> extends AdapterDefinition<Context> {
145
+ export interface AdapterImplementation<Context extends object, Assertions extends object | undefined = undefined> extends AdapterDefinition<Context, Assertions> {
94
146
  readonly kind: "custom";
95
147
  readonly contract: string;
96
148
  readonly behaviorRevision: string | null;
97
- readonly [ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context>;
149
+ readonly [ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions>;
98
150
  create(context: AdapterCreateContext): Context | Promise<Context>;
99
151
  }
100
152
  export type AdapterImplementationInput<Context extends object, ImplementationContext extends Context = Context> = {
@@ -102,9 +154,14 @@ export type AdapterImplementationInput<Context extends object, ImplementationCon
102
154
  readonly behaviorRevision?: string;
103
155
  readonly create: AdapterFactory<ImplementationContext>;
104
156
  } & AdapterContextValidation<NoInfer<ImplementationContext>>;
105
- export interface AdapterContract<Context extends object> extends AdapterDefinition<Context> {
157
+ export interface AdapterContract<Context extends object, Assertions extends object | undefined = undefined> extends AdapterDefinition<Context, Assertions> {
106
158
  readonly name: string;
107
- implement<ImplementationContext extends Context>(input: AdapterImplementationInput<Context, ImplementationContext>): AdapterImplementation<Context>;
159
+ implement<ImplementationContext extends Context>(input: AdapterImplementationInput<Context, ImplementationContext>): AdapterImplementation<Context, Assertions>;
160
+ /**
161
+ * Returns a contract whose Eval factories and every implementation share
162
+ * this exact Assertion factory. Implementations cannot replace it.
163
+ */
164
+ withAssertions<NextAssertions extends object>(factory: AdapterAssertionsFactory<Context, NextAssertions>, ...validation: AdapterAssertionsValidationArgs<Context, NoInfer<NextAssertions>>): AdapterContract<Context, NextAssertions>;
108
165
  }
109
166
  export type Adapter = import("./agents/types.mjs").Agent | AdapterRuntimeDefinition;
110
167
  /** Defines one Adapter implementation with an automatically private contract. */
@@ -112,7 +169,15 @@ export declare function defineAdapter<Context extends object>(input: {
112
169
  readonly name: string;
113
170
  readonly behaviorRevision?: string;
114
171
  readonly create: AdapterFactory<Context>;
172
+ readonly assertions?: undefined;
115
173
  } & AdapterContextValidation<NoInfer<Context>>): AdapterImplementation<Context>;
174
+ export declare function defineAdapter<Context extends object, Assertions extends object>(input: {
175
+ readonly name: string;
176
+ readonly behaviorRevision?: string;
177
+ readonly create: AdapterFactory<Context>;
178
+ /** Attempt-local Assertion sugar, assembled once after create() succeeds. */
179
+ readonly assertions: AdapterAssertionsFactory<Context, Assertions>;
180
+ } & AdapterContextValidation<NoInfer<Context>> & AdapterAssertionsValidation<Context, NoInfer<Assertions>>): AdapterImplementation<Context, Assertions>;
116
181
  /** Defines a reusable contract whose implementations and Evals share one runtime-only token. */
117
182
  export declare function defineAdapterContract<Context extends object>(input: {
118
183
  readonly name: string;
@@ -124,4 +189,4 @@ export declare function adapterAcceptsEval(adapter: Adapter, definition: object)
124
189
  /** @internal Returns the readable contract name without revealing the pairing token. */
125
190
  export declare function adapterContractRequiredByEval(definition: object): string | undefined;
126
191
  /** @internal Builds the frozen single-t facade after create settles. */
127
- export declare function bindAdapterEvalContext<Kind extends EvaluationKind, Context>(core: EvalContext<Kind>, context: Context, assertAuthorOpen: () => void): EvalContext<Kind> & Readonly<Context>;
192
+ export declare function bindAdapterEvalContext<Kind extends EvaluationKind, Context>(core: EvalContext<Kind>, context: Context, adapter: AdapterRuntimeDefinition, assertAuthorOpen: () => void): EvalContext<Kind> & Readonly<Context>;
package/dist/adapter.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AssertionSubject, AssertionsRuntime, MeasurementAssertionHandle } from "./assertions/api.js";
1
+ import type { AssertionCheck, AssertionSubject, AssertionsRuntime, BooleanAssertionHandle, MeasurementAssertionHandle, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle } from "./assertions/api.js";
2
2
  import type { ScoreMatch } from "./assertions/match.js";
3
3
  import type { EvalDefinition, EvalInput, ScoreEvalInput } from "./runner/types.js";
4
4
  import type { EvaluationKind } from "./shared/evaluation.js";
@@ -8,6 +8,27 @@ import type { AdapterIdentity } from "./record/model/run-context.js";
8
8
  export type { AdapterIdentity } from "./record/model/run-context.js";
9
9
  declare const ADAPTER_CONTRACT_TOKEN: unique symbol;
10
10
  declare const EVAL_ADAPTER_CONTRACT_TOKEN: unique symbol;
11
+ /**
12
+ * Synchronously assembles Attempt-local Assertion methods from the guarded app
13
+ * facade and the shared check registrar. The returned object must contain only
14
+ * ordinary, synchronously returning methods. Generic and overloaded Assertion
15
+ * sugar is intentionally not callable after binding; use ordinary named
16
+ * parameters so argument and native handle types remain exact.
17
+ */
18
+ export type AdapterAssertionsFactory<Context extends object, Assertions extends object = object> = (context: AdapterAssertionsFactoryContext<Context>) => Assertions;
19
+ /**
20
+ * Definition inputs for Adapter Assertion sugar. `app` becomes callable after
21
+ * assembly, and `check` may only be called by a returned Assertion method.
22
+ */
23
+ export interface AdapterAssertionsFactoryContext<Context extends object> {
24
+ readonly app: Readonly<Context>;
25
+ readonly check: AssertionCheck<"polymorphic">;
26
+ }
27
+ type BoundAdapterAssertionResult<Kind extends EvaluationKind, Result> = Result extends PolymorphicBooleanAssertionHandle<infer Refined, infer HasGate> ? BooleanAssertionHandle<Kind, Refined, HasGate> : Result extends PolymorphicMeasurementAssertionHandle<infer HasCondition> ? MeasurementAssertionHandle<Kind, HasCondition> : never;
28
+ type BoundAdapterAssertionMethod<Kind extends EvaluationKind, Method> = Method extends (...args: infer Args) => infer Result ? ((...args: Args) => Result) extends Method ? (...args: Args) => BoundAdapterAssertionResult<Kind, Result> : never : never;
29
+ type AdapterAssertionsFor<Assertions extends object | undefined, Kind extends EvaluationKind> = Assertions extends object ? {
30
+ readonly [Key in keyof Assertions]: BoundAdapterAssertionMethod<Kind, Assertions[Key]>;
31
+ } : {};
11
32
  /** Keys owned by the neutral Eval runtime or unsafe on a merged object root. */
12
33
  declare const RESERVED_ADAPTER_CONTEXT_KEYS: readonly ["evaluationKind", "check", "judge", "factuality", "faithfulness", "instructionFollowing", "pairwisePreference", "closeQA", "score", "group", "skip", "signal", "model", "reasoningEffort", "flags", "progress", "diagnostic", "log", "then", "Object", "constructor", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"];
13
34
  export type ReservedAdapterContextKey = typeof RESERVED_ADAPTER_CONTEXT_KEYS[number];
@@ -15,19 +36,47 @@ type InvalidContextBranch<Context> = Context extends unknown ? Context extends o
15
36
  type AdapterContextValidation<Context> = unknown extends Context ? unknown : [InvalidContextBranch<Context>] extends [never] ? unknown : {
16
37
  readonly invalidAdapterContext: InvalidContextBranch<Context>;
17
38
  };
39
+ type InvalidAssertionMethodKey<Context extends object, Assertions> = Assertions extends object ? {
40
+ [Key in keyof Assertions]: Key extends string ? Key extends ReservedAdapterContextKey | keyof Context ? Key : Assertions[Key] extends (...args: readonly never[]) => infer Result ? Result extends PolymorphicBooleanAssertionHandle<unknown, boolean> | PolymorphicMeasurementAssertionHandle<boolean> ? never : Key : Key : Key;
41
+ }[keyof Assertions] : "assertions";
42
+ type InvalidAdapterAssertions<Context extends object, Assertions extends object> = InvalidAssertionMethodKey<Context, Assertions>;
43
+ type AdapterAssertionsValidation<Context extends object, Assertions extends object> = [InvalidAdapterAssertions<Context, Assertions>] extends [never] ? unknown : {
44
+ readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;
45
+ };
46
+ type AdapterAssertionsValidationArgs<Context extends object, Assertions extends object> = [InvalidAdapterAssertions<Context, Assertions>] extends [never] ? [] : [error: {
47
+ readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;
48
+ }];
18
49
  type AdapterFactory<Context extends object> = (context: AdapterCreateContext) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;
50
+ export interface AdapterCleanupContext {
51
+ /** 当前 Adapter cleanup 总窗口的取消信号。它独立于 Attempt signal,并在 30 秒总预算结束时取消。 */
52
+ readonly signal: AbortSignal;
53
+ }
19
54
  export interface AdapterCreateContext {
55
+ /** 当前 Eval 的公开 ID。 */
20
56
  readonly evalId: string;
57
+ /** 当前 Experiment 的公开 ID。 */
21
58
  readonly experimentId: string;
59
+ /** 当前 Attempt 的零起始序号。 */
22
60
  readonly attempt: number;
61
+ /** Attempt 执行信号;取消或超时后会中止,不用于 cleanup 窗口。 */
23
62
  readonly signal: AbortSignal;
63
+ /** Experiment 选择的模型。 */
24
64
  readonly model?: string;
65
+ /** Experiment 选择的推理强度。 */
25
66
  readonly reasoningEffort?: string;
67
+ /** Experiment 传给 Adapter 的只读 flags。 */
26
68
  readonly flags: Readonly<Record<string, JsonValue>>;
69
+ /** 更新当前 Attempt 的人读进度。 */
27
70
  progress(update: ProgressUpdate): void;
71
+ /** 为当前 Attempt 追加结构化诊断。 */
28
72
  diagnostic(input: DiagnosticInput): void;
73
+ /** 为当前 Attempt 追加日志。 */
29
74
  log(message: string): void;
30
- onCleanup(cleanup: () => void | Promise<void>): void;
75
+ /**
76
+ * 登记 Attempt-local 资源释放。回调按全局 LIFO 执行;一项失败不会跳过其余项。
77
+ * 零参数回调仍可直接传入。传入的 context 已冻结,同一 cleanup 窗口的回调共享一个 signal。
78
+ */
79
+ onCleanup(cleanup: (context: AdapterCleanupContext) => void | Promise<void>): void;
31
80
  }
32
81
  type EvalContextBase<Kind extends EvaluationKind> = JudgePresetMethods<Kind> & {
33
82
  readonly evaluationKind: Kind;
@@ -55,29 +104,32 @@ type AdapterScoreEvalFields = Omit<ScoreEvalInput<undefined>, "test" | "sandbox"
55
104
  readonly sandbox?: never;
56
105
  readonly diff?: never;
57
106
  };
58
- export type AdapterEvalInput<Context extends object> = AdapterEvalFields & {
59
- test(t: EvalContext<"pass"> & Readonly<Context>): void | Promise<void>;
107
+ export type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined> = AdapterEvalFields & {
108
+ test(t: EvalContext<"pass"> & Readonly<Context> & AdapterAssertionsFor<Assertions, "pass">): void | Promise<void>;
60
109
  };
61
- export type AdapterScoreEvalInput<Context extends object> = AdapterScoreEvalFields & {
62
- test(t: EvalContext<"score"> & Readonly<Context>): void | Promise<void>;
110
+ export type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined> = AdapterScoreEvalFields & {
111
+ test(t: EvalContext<"score"> & Readonly<Context> & AdapterAssertionsFor<Assertions, "score">): void | Promise<void>;
63
112
  };
64
- interface AdapterContractToken<Context extends object> {
113
+ interface AdapterContractToken<Context extends object, Assertions extends object | undefined> {
65
114
  readonly name: string;
115
+ readonly assertions: AdapterAssertionsFactory<Context> | undefined;
116
+ /** Keeps the Assertion method shape invariant without exposing a constructible brand. */
117
+ readonly assertionTypes: (value: Assertions) => Assertions;
66
118
  /** Keeps the context parameter invariant without exposing a constructible brand. */
67
119
  readonly context: (value: Context) => Context;
68
120
  }
69
- export interface AdapterEvalDefinition<Kind extends EvaluationKind, Context extends object> extends EvalDefinition<Kind, EvalContext<Kind> & Readonly<Context>, undefined> {
70
- readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context>;
121
+ export interface AdapterEvalDefinition<Kind extends EvaluationKind, Context extends object, Assertions extends object | undefined = undefined> extends EvalDefinition<Kind, EvalContext<Kind> & Readonly<Context> & AdapterAssertionsFor<Assertions, Kind>, undefined> {
122
+ readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions>;
71
123
  }
72
124
  /** @internal Existential discovery view; concrete bound factories retain their exact Context. */
73
125
  export interface AdapterRuntimeEvalDefinition<Kind extends EvaluationKind> extends EvalDefinition<Kind, never, undefined> {
74
126
  readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: object;
75
127
  }
76
128
  /** Common public surface for an Adapter definition with bound Eval factories. */
77
- export interface AdapterDefinition<Context extends object> {
129
+ export interface AdapterDefinition<Context extends object, Assertions extends object | undefined = undefined> {
78
130
  readonly name: string;
79
- defineEval(input: AdapterEvalInput<Context>): AdapterEvalDefinition<"pass", Context>;
80
- defineScoreEval(input: AdapterScoreEvalInput<Context>): AdapterEvalDefinition<"score", Context>;
131
+ defineEval(input: AdapterEvalInput<Context, Assertions>): AdapterEvalDefinition<"pass", Context, Assertions>;
132
+ defineScoreEval(input: AdapterScoreEvalInput<Context, Assertions>): AdapterEvalDefinition<"score", Context, Assertions>;
81
133
  }
82
134
  /** Existential runtime view used by Experiment without erasing a concrete context to `any`. */
83
135
  export interface AdapterRuntimeDefinition {
@@ -90,11 +142,11 @@ export interface AdapterRuntimeDefinition {
90
142
  readonly defineScoreEval: (...args: never[]) => unknown;
91
143
  create(context: AdapterCreateContext): object | Promise<object>;
92
144
  }
93
- export interface AdapterImplementation<Context extends object> extends AdapterDefinition<Context> {
145
+ export interface AdapterImplementation<Context extends object, Assertions extends object | undefined = undefined> extends AdapterDefinition<Context, Assertions> {
94
146
  readonly kind: "custom";
95
147
  readonly contract: string;
96
148
  readonly behaviorRevision: string | null;
97
- readonly [ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context>;
149
+ readonly [ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions>;
98
150
  create(context: AdapterCreateContext): Context | Promise<Context>;
99
151
  }
100
152
  export type AdapterImplementationInput<Context extends object, ImplementationContext extends Context = Context> = {
@@ -102,9 +154,14 @@ export type AdapterImplementationInput<Context extends object, ImplementationCon
102
154
  readonly behaviorRevision?: string;
103
155
  readonly create: AdapterFactory<ImplementationContext>;
104
156
  } & AdapterContextValidation<NoInfer<ImplementationContext>>;
105
- export interface AdapterContract<Context extends object> extends AdapterDefinition<Context> {
157
+ export interface AdapterContract<Context extends object, Assertions extends object | undefined = undefined> extends AdapterDefinition<Context, Assertions> {
106
158
  readonly name: string;
107
- implement<ImplementationContext extends Context>(input: AdapterImplementationInput<Context, ImplementationContext>): AdapterImplementation<Context>;
159
+ implement<ImplementationContext extends Context>(input: AdapterImplementationInput<Context, ImplementationContext>): AdapterImplementation<Context, Assertions>;
160
+ /**
161
+ * Returns a contract whose Eval factories and every implementation share
162
+ * this exact Assertion factory. Implementations cannot replace it.
163
+ */
164
+ withAssertions<NextAssertions extends object>(factory: AdapterAssertionsFactory<Context, NextAssertions>, ...validation: AdapterAssertionsValidationArgs<Context, NoInfer<NextAssertions>>): AdapterContract<Context, NextAssertions>;
108
165
  }
109
166
  export type Adapter = import("./agents/types.js").Agent | AdapterRuntimeDefinition;
110
167
  /** Defines one Adapter implementation with an automatically private contract. */
@@ -112,7 +169,15 @@ export declare function defineAdapter<Context extends object>(input: {
112
169
  readonly name: string;
113
170
  readonly behaviorRevision?: string;
114
171
  readonly create: AdapterFactory<Context>;
172
+ readonly assertions?: undefined;
115
173
  } & AdapterContextValidation<NoInfer<Context>>): AdapterImplementation<Context>;
174
+ export declare function defineAdapter<Context extends object, Assertions extends object>(input: {
175
+ readonly name: string;
176
+ readonly behaviorRevision?: string;
177
+ readonly create: AdapterFactory<Context>;
178
+ /** Attempt-local Assertion sugar, assembled once after create() succeeds. */
179
+ readonly assertions: AdapterAssertionsFactory<Context, Assertions>;
180
+ } & AdapterContextValidation<NoInfer<Context>> & AdapterAssertionsValidation<Context, NoInfer<Assertions>>): AdapterImplementation<Context, Assertions>;
116
181
  /** Defines a reusable contract whose implementations and Evals share one runtime-only token. */
117
182
  export declare function defineAdapterContract<Context extends object>(input: {
118
183
  readonly name: string;
@@ -124,4 +189,4 @@ export declare function adapterAcceptsEval(adapter: Adapter, definition: object)
124
189
  /** @internal Returns the readable contract name without revealing the pairing token. */
125
190
  export declare function adapterContractRequiredByEval(definition: object): string | undefined;
126
191
  /** @internal Builds the frozen single-t facade after create settles. */
127
- export declare function bindAdapterEvalContext<Kind extends EvaluationKind, Context>(core: EvalContext<Kind>, context: Context, assertAuthorOpen: () => void): EvalContext<Kind> & Readonly<Context>;
192
+ export declare function bindAdapterEvalContext<Kind extends EvaluationKind, Context>(core: EvalContext<Kind>, context: Context, adapter: AdapterRuntimeDefinition, assertAuthorOpen: () => void): EvalContext<Kind> & Readonly<Context>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uEAAuE;AACvE,4CAAqE;AAA5D,2GAAA,aAAa,OAAA;AAAE,mHAAA,qBAAqB,OAAA;AAE7C,0CAA+D;AAAtD,wGAAA,WAAW,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AACxC,qDAAsD;AAA7C,oHAAA,iBAAiB,OAAA;AAC1B,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AAEf,iDAAkE;AAAzD,sHAAA,qBAAqB,OAAA;AAAE,yGAAA,QAAQ,OAAA;AAExC,2DAA6D;AAApD,2HAAA,qBAAqB,OAAA;AAC9B,8DAA8D;AAC9D,iEAAiE;AACjE,yDAAqE;AAA5D,uHAAA,wBAAwB,OAAA;AAEjC,qDAAqD;AACrD,2EAA2E;AAC3E,uDAAuD;AACvD,uEAAuK;AAA9J,mIAAA,0BAA0B,OAAA;AAAE,0HAAA,iBAAiB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAAE,6HAAA,oBAAoB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAE9H,+DAA+D;AAC/D,qDAAqD;AACrD,wCAAwC;AACxC,qDAAqD;AACrD,gEAA+E;AAAtE,mHAAA,eAAe,OAAA;AAAE,mHAAA,eAAe,OAAA;AAGzC,iEAAmH;AAA1G,8HAAA,yBAAyB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAE7E,iEAAiE;AACjE,mEAAmE;AACnE,2DAA2D;AAC3D,8EAA8E;AAC9E,0DAAkE;AAAzD,uGAAA,OAAO,OAAA;AAAE,4GAAA,YAAY,OAAA;AAE9B,0DAA8D;AAArD,yGAAA,aAAa,OAAA;AACtB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAE7B,qDAAqD;AACrD,yBAAyB;AACzB,uDAA2I;AAAlI,kIAAA,8BAA8B,OAAA;AAAE,6HAAA,yBAAyB,OAAA;AAAE,0HAAA,sBAAsB,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAE7G,0DAA0D;AAC1D,mDAAqI;AAA5H,+GAAA,aAAa,OAAA;AAAE,4HAAA,0BAA0B,OAAA;AAAE,0HAAA,wBAAwB,OAAA;AAAE,8HAAA,4BAA4B,OAAA;AAE1G,2DAA2D;AAC3D,+CAA4D;AAAnD,0HAAA,0BAA0B,OAAA;AAEnC,kFAAkF;AAClF,qDAAqD;AACrD,iDAAiD;AACjD,+DAA+D;AAC/D,+CAA+D;AAAtD,gHAAA,gBAAgB,OAAA;AAAE,2GAAA,WAAW,OAAA;AAEtC,mEAAmE;AACnE,yDAAyD;AACzD,yCAAwD;AAA/C,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAElC,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AACvB,mDAAmD;AAA1C,iHAAA,eAAe,OAAA;AACxB,uCAAwC;AAA/B,sGAAA,UAAU,OAAA;AACnB,mCAAoC;AAA3B,kGAAA,QAAQ,OAAA;AACjB,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AACtB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AACtB,mCAAoC;AAA3B,kGAAA,QAAQ,OAAA;AACjB,6DAA6D;AAApD,2HAAA,oBAAoB,OAAA","sourcesContent":["// niceeval/adapter 公开导出:「连到哪个 AI」相关的类型 + 内置 adapter + 自定义 adapter 的入口。\nexport { defineAdapter, defineAdapterContract } from \"../adapter.ts\";\nexport type { Adapter, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from \"../adapter.ts\";\nexport { defineAgent, defineSandboxAgent } from \"../define.ts\";\nexport { createSessionSlot } from \"./session-slot.ts\";\nexport { shared } from \"./shared.ts\";\nexport type { Shared } from \"./shared.ts\";\nexport { createNpmCliInstaller, agentBin } from \"./npm-staged.ts\";\nexport type { NpmCliInstallerOptions } from \"./npm-staged.ts\";\nexport { acquireManagedProcess } from \"./managed-process.ts\";\n// 证据覆盖声明:官方 SDK 适配器声明全通道 complete 用 completeEvidenceCoverage;\n// 手写映射按实际情况声明(见 docs/feature/adapters/architecture/evidence.md)。\nexport { completeEvidenceCoverage } from \"../assertions/coverage.ts\";\nexport type { EvidenceCoverageStatus, EvidenceCoverageEntry, EvidenceCoverage, TurnEvidenceCoverage, } from \"../types.ts\";\n// tool operation 的 command 分类只能由 Adapter 根据原生协议事实产生。\n// structured argv 走 commandProjection() 与同一 logical-command/v1 normalizer;\n// 无法安全取得 argv 时显式 opaque,确认不是 command 时显式 not-command。\nexport { LOGICAL_COMMAND_NORMALIZER, commandProjection, normalizeLogicalCommand, notCommandProjection, opaqueCommandProjection, } from \"../o11y/command-projection.ts\";\nexport type { CommandProjection, LogicalCommandInvocation, LogicalCommandNormalizer, OriginalCommandInvocation, OriginalCommandOpaqueReason, } from \"../o11y/types.ts\";\n// 执行失败分类:`Agent.classifySendFailure` 认的结构化 envelope 与同源摘要。两轴词表\n// (FailureClass / FailureScope)与包根导出的是同一个形状——adapter\n// 作者与 eval 作者各自的入口拿到同一份类型。判据、分类链与重试执行体见\n// docs/feature/error-classification/architecture.md。\nexport { makeSendFailure, sendFailureText } from \"../context/send-failures.ts\";\nexport type { SendFailure, SendFailureClassifier } from \"../context/send-failures.ts\";\nexport type { FailureClass, FailureScope } from \"../shared/failure-class.ts\";\nexport { externalCauseMessageChain, externalCauseText, normalizeExternalCause } from \"../shared/external-cause.ts\";\nexport type { ExternalCause, ExternalCauseFact, ExternalCauseLink } from \"../shared/external-cause.ts\";\n// span → canonical GenAI 归一(只服务瀑布图,不喂断言)。私有埋点写自己的 spanMapper 时用:\n// tagSpan 把判定写回 span(原属性只增不改),heuristicTag 是通用兜底判定;mapCodexSpans 是\n// 现成的参考实现(无侵入接 codex 后端时直接声明 `spanMapper: mapCodexSpans`)。\n// 映射目标(什么属性亮起瀑布图的什么)见 apps/docs-site/zh/tutorials/connect-otel.mdx「瀑布图画得准不准」。\nexport { tagSpan, heuristicTag } from \"../o11y/otlp/canonical.ts\";\nexport type { SpanTag } from \"../o11y/otlp/canonical.ts\";\nexport { mapCodexSpans } from \"../o11y/otlp/mappers/codex.ts\";\nexport { uiMessageStreamAgent } from \"./ui-message-stream.ts\";\nexport type { UiMessageStreamAgentOptions, UIMessageLike, UIMessagePartLike } from \"./ui-message-stream.ts\";\n// 两种 OpenAI 响应形状(不限于 OpenAI 官方,任何声明兼容这两种协议形状的服务都能用)的\n// 官方转换器:整段响应 → Turn,零映射。\nexport { chatCompletionEvidenceCoverage, responsesEvidenceCoverage, turnFromChatCompletion, turnFromResponses, } from \"./openai-compat.ts\";\nexport type { ChatCompletionLike, ChatCompletionCustomToolCallLike, ChatCompletionFunctionToolCallLike, ChatCompletionMessageLike, ChatCompletionToolCallLike, ChatCompletionUnknownToolCallLike, ChatCompletionUsageLike, ResponseFunctionCallItemLike, ResponseLike, ResponseMessageItemLike, ResponseOutputItemLike, ResponseOutputTextLike, ResponseUsageLike, } from \"./openai-compat.ts\";\n// SDK 原生事件流 → 标准事件的官方转换器(无侵入 adapter 只剩传输粘合)+ 通用 SSE 读帧器。\nexport { sseJsonFrames, createClaudeSdkEventStream, createPiAgentEventStream, createCodexThreadEventStream } from \"./sdk-streams.ts\";\nexport type { SseFrameCursor, ClaudeSdkMessageLike, ClaudeSdkStream, PiAgentEventLike, PiAgentStream, CodexThreadEventLike, CodexThreadStream, } from \"./sdk-streams.ts\";\n// LangGraph 官方事件流转换器(不绑定 transport,不提供 langGraphAgent 工厂)。\nexport { createLangGraphEventStream } from \"./langgraph.ts\";\nexport type { LangGraphEventLike, LangGraphContentBlockLike, LangGraphStream } from \"./langgraph.ts\";\n// 通用「拼装方式」件:逐帧驱动循环、逐 token/参数增量累加器。见 apps/docs-site/zh/tutorials/write-send.mdx——\n// 这些和任何具体协议无关,自己写 adapter 时优先拿这些拼,只有 transport(怎么发)与\n// 「帧类型 → 操作」这张映射表才是真正要手写的。会话续接与 HITL 停轮现场不再是可选件,\n// 而是 ctx.session(AgentSession)本身的 typed slot 与 id/capture 存取器。\nexport { driveFrameStream, deltaStream } from \"./streaming.ts\";\nexport type { FrameReducer, FrameHook, DeltaOp, DeltaStreamSpec } from \"./streaming.ts\";\n// tracing 管线的内置实现 aiSdkOtel() 在 `niceeval/adapter/otel`(独立子路径,不从这里\n// re-export):OTel 三件套是可选 peer 依赖,只有 import 那个入口的项目才需要安装。\nexport { turnFromAiSdk, aiSdkAgent } from \"./ai-sdk.ts\";\nexport type { AiSdkAgentOptions, AiSdkGenerateContext, AiSdkResultLike, AiSdkStepLike, AiSdkTelemetrySettings, AiSdkToolCallLike, AiSdkToolResultLike, AiSdkTracing, AiSdkTurn, AiSdkTurnTelemetry, AiSdkUsageLike, } from \"./ai-sdk.ts\";\nexport { BUILTIN_AGENTS } from \"./builtin.ts\";\nexport { claudeCodeAgent } from \"./claude-code.ts\";\nexport { codexAgent } from \"./codex.ts\";\nexport { bubAgent } from \"./bub.ts\";\nexport { openCodeAgent } from \"./opencode.ts\";\nexport { hermesAgent } from \"./hermes.ts\";\nexport { openClawAgent } from \"./openclaw.ts\";\nexport { ompAgent } from \"./omp.ts\";\nexport { deepSeekHarnessAgent } from \"./deepseek-harness.ts\";\nexport type { ClaudeCodeConfig, ClaudeCodePluginSpec } from \"./claude-code.ts\";\nexport type { CodexConfig, CodexPluginSpec } from \"./codex.ts\";\nexport type { BubConfig, PythonPluginSpec } from \"./bub.ts\";\nexport type { OpenCodeConfig } from \"./opencode.ts\";\nexport type { HermesConfig } from \"./hermes.ts\";\nexport type { OpenClawConfig } from \"./openclaw.ts\";\nexport type { OmpConfig } from \"./omp.ts\";\nexport type { DeepSeekHarnessConfig } from \"./deepseek-harness.ts\";\nexport type { Agent, AgentContext, AgentIdentity, AgentInstallMode, AgentArtifactPlatform, AgentStagedArtifact, AgentEnsureOutcome, AgentEnsure, AgentInstaller, AgentArtifactContext, AgentInstallContext, StagedAgentInstallContext, DirectAgent, DirectAgentDef, DirectAgentSetup, DirectAgentTeardown, AgentSession, SessionSlot, AgentSetup, AgentSetupManifest, AgentSetupSkill, AgentTeardown, AgentTracing, SpanMapper, Telemetry, SandboxAgentDef, SandboxAgent, SandboxAgentContext, SandboxAgentSetupContext, McpServer, SkillSpec, } from \"../types.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uEAAuE;AACvE,4CAAqE;AAA5D,2GAAA,aAAa,OAAA;AAAE,mHAAA,qBAAqB,OAAA;AAG7C,0CAA+D;AAAtD,wGAAA,WAAW,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AACxC,qDAAsD;AAA7C,oHAAA,iBAAiB,OAAA;AAC1B,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AAEf,iDAAkE;AAAzD,sHAAA,qBAAqB,OAAA;AAAE,yGAAA,QAAQ,OAAA;AAExC,2DAA6D;AAApD,2HAAA,qBAAqB,OAAA;AAC9B,8DAA8D;AAC9D,iEAAiE;AACjE,yDAAqE;AAA5D,uHAAA,wBAAwB,OAAA;AAEjC,qDAAqD;AACrD,2EAA2E;AAC3E,uDAAuD;AACvD,uEAAuK;AAA9J,mIAAA,0BAA0B,OAAA;AAAE,0HAAA,iBAAiB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAAE,6HAAA,oBAAoB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAE9H,+DAA+D;AAC/D,qDAAqD;AACrD,wCAAwC;AACxC,qDAAqD;AACrD,gEAA+E;AAAtE,mHAAA,eAAe,OAAA;AAAE,mHAAA,eAAe,OAAA;AAGzC,iEAAmH;AAA1G,8HAAA,yBAAyB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAE7E,iEAAiE;AACjE,mEAAmE;AACnE,2DAA2D;AAC3D,8EAA8E;AAC9E,0DAAkE;AAAzD,uGAAA,OAAO,OAAA;AAAE,4GAAA,YAAY,OAAA;AAE9B,0DAA8D;AAArD,yGAAA,aAAa,OAAA;AACtB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAE7B,qDAAqD;AACrD,yBAAyB;AACzB,uDAA2I;AAAlI,kIAAA,8BAA8B,OAAA;AAAE,6HAAA,yBAAyB,OAAA;AAAE,0HAAA,sBAAsB,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAE7G,0DAA0D;AAC1D,mDAAqI;AAA5H,+GAAA,aAAa,OAAA;AAAE,4HAAA,0BAA0B,OAAA;AAAE,0HAAA,wBAAwB,OAAA;AAAE,8HAAA,4BAA4B,OAAA;AAE1G,2DAA2D;AAC3D,+CAA4D;AAAnD,0HAAA,0BAA0B,OAAA;AAEnC,kFAAkF;AAClF,qDAAqD;AACrD,iDAAiD;AACjD,+DAA+D;AAC/D,+CAA+D;AAAtD,gHAAA,gBAAgB,OAAA;AAAE,2GAAA,WAAW,OAAA;AAEtC,mEAAmE;AACnE,yDAAyD;AACzD,yCAAwD;AAA/C,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAElC,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AACvB,mDAAmD;AAA1C,iHAAA,eAAe,OAAA;AACxB,uCAAwC;AAA/B,sGAAA,UAAU,OAAA;AACnB,mCAAoC;AAA3B,kGAAA,QAAQ,OAAA;AACjB,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AACtB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AACtB,mCAAoC;AAA3B,kGAAA,QAAQ,OAAA;AACjB,6DAA6D;AAApD,2HAAA,oBAAoB,OAAA","sourcesContent":["// niceeval/adapter 公开导出:「连到哪个 AI」相关的类型 + 内置 adapter + 自定义 adapter 的入口。\nexport { defineAdapter, defineAdapterContract } from \"../adapter.ts\";\nexport type { AssertionCheck, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle, } from \"../assertions/api.ts\";\nexport type { Adapter, AdapterAssertionsFactory, AdapterAssertionsFactoryContext, AdapterCleanupContext, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from \"../adapter.ts\";\nexport { defineAgent, defineSandboxAgent } from \"../define.ts\";\nexport { createSessionSlot } from \"./session-slot.ts\";\nexport { shared } from \"./shared.ts\";\nexport type { Shared } from \"./shared.ts\";\nexport { createNpmCliInstaller, agentBin } from \"./npm-staged.ts\";\nexport type { NpmCliInstallerOptions } from \"./npm-staged.ts\";\nexport { acquireManagedProcess } from \"./managed-process.ts\";\n// 证据覆盖声明:官方 SDK 适配器声明全通道 complete 用 completeEvidenceCoverage;\n// 手写映射按实际情况声明(见 docs/feature/adapters/architecture/evidence.md)。\nexport { completeEvidenceCoverage } from \"../assertions/coverage.ts\";\nexport type { EvidenceCoverageStatus, EvidenceCoverageEntry, EvidenceCoverage, TurnEvidenceCoverage, } from \"../types.ts\";\n// tool operation 的 command 分类只能由 Adapter 根据原生协议事实产生。\n// structured argv 走 commandProjection() 与同一 logical-command/v1 normalizer;\n// 无法安全取得 argv 时显式 opaque,确认不是 command 时显式 not-command。\nexport { LOGICAL_COMMAND_NORMALIZER, commandProjection, normalizeLogicalCommand, notCommandProjection, opaqueCommandProjection, } from \"../o11y/command-projection.ts\";\nexport type { CommandProjection, LogicalCommandInvocation, LogicalCommandNormalizer, OriginalCommandInvocation, OriginalCommandOpaqueReason, } from \"../o11y/types.ts\";\n// 执行失败分类:`Agent.classifySendFailure` 认的结构化 envelope 与同源摘要。两轴词表\n// (FailureClass / FailureScope)与包根导出的是同一个形状——adapter\n// 作者与 eval 作者各自的入口拿到同一份类型。判据、分类链与重试执行体见\n// docs/feature/error-classification/architecture.md。\nexport { makeSendFailure, sendFailureText } from \"../context/send-failures.ts\";\nexport type { SendFailure, SendFailureClassifier } from \"../context/send-failures.ts\";\nexport type { FailureClass, FailureScope } from \"../shared/failure-class.ts\";\nexport { externalCauseMessageChain, externalCauseText, normalizeExternalCause } from \"../shared/external-cause.ts\";\nexport type { ExternalCause, ExternalCauseFact, ExternalCauseLink } from \"../shared/external-cause.ts\";\n// span → canonical GenAI 归一(只服务瀑布图,不喂断言)。私有埋点写自己的 spanMapper 时用:\n// tagSpan 把判定写回 span(原属性只增不改),heuristicTag 是通用兜底判定;mapCodexSpans 是\n// 现成的参考实现(无侵入接 codex 后端时直接声明 `spanMapper: mapCodexSpans`)。\n// 映射目标(什么属性亮起瀑布图的什么)见 apps/docs-site/zh/tutorials/connect-otel.mdx「瀑布图画得准不准」。\nexport { tagSpan, heuristicTag } from \"../o11y/otlp/canonical.ts\";\nexport type { SpanTag } from \"../o11y/otlp/canonical.ts\";\nexport { mapCodexSpans } from \"../o11y/otlp/mappers/codex.ts\";\nexport { uiMessageStreamAgent } from \"./ui-message-stream.ts\";\nexport type { UiMessageStreamAgentOptions, UIMessageLike, UIMessagePartLike } from \"./ui-message-stream.ts\";\n// 两种 OpenAI 响应形状(不限于 OpenAI 官方,任何声明兼容这两种协议形状的服务都能用)的\n// 官方转换器:整段响应 → Turn,零映射。\nexport { chatCompletionEvidenceCoverage, responsesEvidenceCoverage, turnFromChatCompletion, turnFromResponses, } from \"./openai-compat.ts\";\nexport type { ChatCompletionLike, ChatCompletionCustomToolCallLike, ChatCompletionFunctionToolCallLike, ChatCompletionMessageLike, ChatCompletionToolCallLike, ChatCompletionUnknownToolCallLike, ChatCompletionUsageLike, ResponseFunctionCallItemLike, ResponseLike, ResponseMessageItemLike, ResponseOutputItemLike, ResponseOutputTextLike, ResponseUsageLike, } from \"./openai-compat.ts\";\n// SDK 原生事件流 → 标准事件的官方转换器(无侵入 adapter 只剩传输粘合)+ 通用 SSE 读帧器。\nexport { sseJsonFrames, createClaudeSdkEventStream, createPiAgentEventStream, createCodexThreadEventStream } from \"./sdk-streams.ts\";\nexport type { SseFrameCursor, ClaudeSdkMessageLike, ClaudeSdkStream, PiAgentEventLike, PiAgentStream, CodexThreadEventLike, CodexThreadStream, } from \"./sdk-streams.ts\";\n// LangGraph 官方事件流转换器(不绑定 transport,不提供 langGraphAgent 工厂)。\nexport { createLangGraphEventStream } from \"./langgraph.ts\";\nexport type { LangGraphEventLike, LangGraphContentBlockLike, LangGraphStream } from \"./langgraph.ts\";\n// 通用「拼装方式」件:逐帧驱动循环、逐 token/参数增量累加器。见 apps/docs-site/zh/tutorials/write-send.mdx——\n// 这些和任何具体协议无关,自己写 adapter 时优先拿这些拼,只有 transport(怎么发)与\n// 「帧类型 → 操作」这张映射表才是真正要手写的。会话续接与 HITL 停轮现场不再是可选件,\n// 而是 ctx.session(AgentSession)本身的 typed slot 与 id/capture 存取器。\nexport { driveFrameStream, deltaStream } from \"./streaming.ts\";\nexport type { FrameReducer, FrameHook, DeltaOp, DeltaStreamSpec } from \"./streaming.ts\";\n// tracing 管线的内置实现 aiSdkOtel() 在 `niceeval/adapter/otel`(独立子路径,不从这里\n// re-export):OTel 三件套是可选 peer 依赖,只有 import 那个入口的项目才需要安装。\nexport { turnFromAiSdk, aiSdkAgent } from \"./ai-sdk.ts\";\nexport type { AiSdkAgentOptions, AiSdkGenerateContext, AiSdkResultLike, AiSdkStepLike, AiSdkTelemetrySettings, AiSdkToolCallLike, AiSdkToolResultLike, AiSdkTracing, AiSdkTurn, AiSdkTurnTelemetry, AiSdkUsageLike, } from \"./ai-sdk.ts\";\nexport { BUILTIN_AGENTS } from \"./builtin.ts\";\nexport { claudeCodeAgent } from \"./claude-code.ts\";\nexport { codexAgent } from \"./codex.ts\";\nexport { bubAgent } from \"./bub.ts\";\nexport { openCodeAgent } from \"./opencode.ts\";\nexport { hermesAgent } from \"./hermes.ts\";\nexport { openClawAgent } from \"./openclaw.ts\";\nexport { ompAgent } from \"./omp.ts\";\nexport { deepSeekHarnessAgent } from \"./deepseek-harness.ts\";\nexport type { ClaudeCodeConfig, ClaudeCodePluginSpec } from \"./claude-code.ts\";\nexport type { CodexConfig, CodexPluginSpec } from \"./codex.ts\";\nexport type { BubConfig, PythonPluginSpec } from \"./bub.ts\";\nexport type { OpenCodeConfig } from \"./opencode.ts\";\nexport type { HermesConfig } from \"./hermes.ts\";\nexport type { OpenClawConfig } from \"./openclaw.ts\";\nexport type { OmpConfig } from \"./omp.ts\";\nexport type { DeepSeekHarnessConfig } from \"./deepseek-harness.ts\";\nexport type { Agent, AgentContext, AgentIdentity, AgentInstallMode, AgentArtifactPlatform, AgentStagedArtifact, AgentEnsureOutcome, AgentEnsure, AgentInstaller, AgentArtifactContext, AgentInstallContext, StagedAgentInstallContext, DirectAgent, DirectAgentDef, DirectAgentSetup, DirectAgentTeardown, AgentSession, SessionSlot, AgentSetup, AgentSetupManifest, AgentSetupSkill, AgentTeardown, AgentTracing, SpanMapper, Telemetry, SandboxAgentDef, SandboxAgent, SandboxAgentContext, SandboxAgentSetupContext, McpServer, SkillSpec, } from \"../types.ts\";\n"]}
@@ -1,5 +1,6 @@
1
1
  export { defineAdapter, defineAdapterContract } from "../adapter.cjs";
2
- export type { Adapter, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from "../adapter.cjs";
2
+ export type { AssertionCheck, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle, } from "../assertions/api.cjs";
3
+ export type { Adapter, AdapterAssertionsFactory, AdapterAssertionsFactoryContext, AdapterCleanupContext, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from "../adapter.cjs";
3
4
  export { defineAgent, defineSandboxAgent } from "../define.cjs";
4
5
  export { createSessionSlot } from "./session-slot.cjs";
5
6
  export { shared } from "./shared.cjs";
@@ -1,5 +1,6 @@
1
1
  export { defineAdapter, defineAdapterContract } from "../adapter.mjs";
2
- export type { Adapter, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from "../adapter.mjs";
2
+ export type { AssertionCheck, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle, } from "../assertions/api.mjs";
3
+ export type { Adapter, AdapterAssertionsFactory, AdapterAssertionsFactoryContext, AdapterCleanupContext, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from "../adapter.mjs";
3
4
  export { defineAgent, defineSandboxAgent } from "../define.mjs";
4
5
  export { createSessionSlot } from "./session-slot.mjs";
5
6
  export { shared } from "./shared.mjs";
@@ -1,5 +1,6 @@
1
1
  export { defineAdapter, defineAdapterContract } from "../adapter.js";
2
- export type { Adapter, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from "../adapter.js";
2
+ export type { AssertionCheck, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle, } from "../assertions/api.js";
3
+ export type { Adapter, AdapterAssertionsFactory, AdapterAssertionsFactoryContext, AdapterCleanupContext, AdapterContract, AdapterCreateContext, AdapterDefinition, AdapterEvalDefinition, AdapterEvalInput, AdapterIdentity, AdapterImplementation, AdapterImplementationInput, AdapterRuntimeDefinition, AdapterScoreEvalInput, EvalContext, ReservedAdapterContextKey, } from "../adapter.js";
3
4
  export { defineAgent, defineSandboxAgent } from "../define.js";
4
5
  export { createSessionSlot } from "./session-slot.js";
5
6
  export { shared } from "./shared.js";
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["api.ts"],"names":[],"mappings":";;;AAqXA;;;;GAIG;AACU,QAAA,oBAAoB,GAAkB,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAsBvF;;;;;GAKG;AACH,MAAa,6BAA8B,SAAQ,KAAK;IAE/B;IADZ,IAAI,GAAG,+BAA+B,CAAC;IAChD,YAAqB,MAA4G;QAC7H,KAAK,CAAC,kDAAkD,MAAM,EAAE,CAAC,CAAC;QADjD,WAAM,GAAN,MAAM,CAAsG;QAE7H,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAChD,CAAC;CACJ;AAND,sEAMC","sourcesContent":["import type { Effect } from \"effect\";\nimport type { BooleanMatch, CollectionMatch, ManagedToolCalls, MatchDiagnostic, NumericComparator, NumericComparisonMatch, ScoreMatch, EventMatch, ManagedEventOccurrences, ToolMatch, } from \"./match.ts\";\nimport type { AgentWorkspaceDiff } from \"./workspace-diff.ts\";\nimport type { EvaluationKind } from \"../shared/evaluation.ts\";\n/** The two Evaluation kinds deliberately share one Assertion entry model. */\nexport type AssertionEvaluationKind = EvaluationKind;\n/**\n * A bounded JSON-shaped value owned by the authoring runtime. It is a\n * domain value, not the durable Assertions attachment material type.\n */\nexport type AssertionSnapshotValue = null | boolean | number | string | readonly AssertionSnapshotValue[] | AssertionSnapshotObject;\nexport interface AssertionSnapshotObject {\n readonly [key: string]: AssertionSnapshotValue;\n}\nexport interface AssertionDisplay {\n readonly key?: string;\n readonly label?: string;\n readonly groupPath: readonly string[];\n}\nexport type AssertionCoverage = {\n readonly state: \"complete\";\n} | {\n readonly state: \"partial\";\n readonly reason: \"sampled\" | \"truncated\" | \"redacted\" | \"provider-limited\";\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"not-collected\" | \"source-unavailable\" | \"producer-failed\";\n} | {\n readonly state: \"not-applicable\";\n readonly reason: \"optional-material\" | \"unsupported-subject\";\n};\nexport type AssertionLimitation = {\n readonly kind: \"redacted\";\n readonly fieldCount: number;\n} | {\n readonly kind: \"sampled\";\n readonly captured: number;\n readonly knownTotal?: number;\n} | {\n readonly kind: \"truncated\";\n readonly omittedBytes: number;\n} | {\n readonly kind: \"provider-limited\";\n};\n/**\n * Authoring material intentionally has no blob ref, attachment entry ID, or\n * durable schema identity. The private producer adapter selects the exact\n * same-owner Attachment schema when it serializes this domain reference.\n */\nexport type AssertionMaterial = {\n readonly kind: \"snapshot\";\n readonly value: AssertionSnapshotValue;\n} | {\n readonly kind: \"record-attachment\";\n readonly preview: string;\n};\nexport type AssertionCriterion = {\n readonly kind: \"value-match\";\n readonly subject: \"explicit-value\";\n readonly matcher: {\n readonly state: \"declared\";\n readonly name: string;\n } | {\n readonly state: \"unavailable\";\n };\n} | {\n /** Package-private runtime variant encoded as numeric-comparison/v1. */\n readonly kind: \"value-match\";\n readonly numeric: {\n readonly comparator: NumericComparator;\n readonly threshold: number;\n readonly subject: {\n readonly kind: \"explicit-value\";\n } | {\n readonly kind: \"scope-metric\";\n readonly metric: \"tokens\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly unit: \"tokens\";\n } | {\n readonly kind: \"scope-metric\";\n readonly metric: \"cost\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly unit: \"usd\";\n } | {\n readonly kind: \"collection-cardinality\";\n readonly collection: \"tool-calls\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n };\n };\n} | {\n readonly kind: \"scope-status\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly assertion: \"succeeded\" | \"no-failed-actions\";\n} | {\n readonly kind: \"occurrence\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly occurrence: \"tool\" | \"skill\" | \"event\";\n readonly assertion: \"present\" | \"absent\" | \"count\" | \"order\";\n readonly matcher?: string;\n readonly quantifier?: {\n readonly kind: \"absent\";\n } | {\n readonly kind: \"at-least\" | \"less-than\" | \"at-most\" | \"greater-than\" | \"exact\";\n readonly count: number;\n };\n} | {\n readonly kind: \"judge-measurement\";\n readonly name: string;\n readonly scale: \"unit-interval\";\n} | {\n readonly kind: \"managed-score-measurement\";\n readonly name: string;\n readonly scale: \"unit-interval\";\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"changed-paths\";\n readonly paths: readonly string[];\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"no-changes\";\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"file-changed\";\n readonly path: string;\n readonly status?: \"added\" | \"modified\" | \"deleted\";\n readonly before?: string;\n readonly after?: string;\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"file-deleted\";\n readonly path: string;\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"not-in-diff\";\n readonly pattern: string;\n readonly flags: string;\n readonly content: \"added\" | \"removed\" | \"both\";\n} | {\n readonly kind: \"direct-score\";\n readonly source: \"author\";\n} | {\n readonly kind: \"third-party\";\n readonly name: string;\n readonly schemaId: string;\n readonly data: AssertionSnapshotValue;\n};\nexport type AssertionScoreContribution = {\n readonly state: \"not-scored\";\n} | {\n readonly state: \"earned\";\n readonly points: number;\n readonly earned: number;\n} | {\n readonly state: \"unavailable\";\n readonly points: number;\n readonly reason: \"source-unavailable\" | \"evaluation-errored\" | \"not-applicable\";\n};\n/** Constant-size semantic receipt for one collection evaluation. */\nexport interface AssertionCollectionReceipt {\n readonly examined: number;\n readonly matched: number;\n readonly mismatched: number;\n readonly unavailable: number;\n readonly knownTotal: number | null;\n readonly complete: boolean;\n readonly exhaustive: boolean;\n readonly decisive: boolean;\n}\nexport type MatcherRelationStatus = {\n readonly state: \"exact\";\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"historical-not-recorded\" | \"source-unavailable\" | \"ambiguous\";\n};\nexport type MatcherSourceLocator = {\n readonly kind: \"tool-occurrence\";\n readonly toolOccurrenceId: string;\n readonly relation: MatcherRelationStatus;\n} | {\n readonly kind: \"event\";\n readonly eventId: string;\n readonly toolOccurrenceId?: string;\n readonly relation: MatcherRelationStatus;\n};\nexport interface MatcherRetainedRow {\n readonly locator: MatcherSourceLocator;\n readonly result: \"matched\" | \"mismatched\" | \"unavailable\" | \"not-evaluated\";\n readonly difference?: AssertionSnapshotValue;\n}\nexport interface MatcherQueryStep {\n readonly step: number;\n readonly summary: AssertionSnapshotValue;\n}\nexport type MatcherSourceSnapshot = {\n readonly scope: \"turn\";\n readonly sessionId: string;\n readonly turnId: string;\n readonly scopeId: string;\n readonly throughSessionSequence: number;\n readonly source: {\n readonly family: \"niceeval.agent-turns\";\n readonly schemaVersion: number;\n };\n readonly collectionAtCut: \"complete\" | \"partial\" | \"unavailable\";\n} | {\n readonly scope: \"session\";\n readonly sessionId: string;\n readonly scopeId: string;\n readonly throughSessionSequence: number;\n readonly source: {\n readonly family: \"niceeval.agent-turns\";\n readonly schemaVersion: number;\n };\n readonly collectionAtCut: \"complete\" | \"partial\" | \"unavailable\";\n} | {\n readonly scope: \"attempt\";\n readonly scopeId: string;\n readonly sessions: readonly {\n readonly sessionId: string;\n readonly throughSessionSequence: number;\n }[];\n readonly source: {\n readonly family: \"niceeval.agent-turns\";\n readonly schemaVersion: number;\n };\n readonly collectionAtCut: \"complete\" | \"partial\" | \"unavailable\";\n};\nexport interface OrderStepReceipt {\n readonly step: number;\n readonly comparisons: number;\n readonly matched: number;\n readonly mismatched: number;\n readonly unavailable: number;\n}\nexport interface OrderEvaluationReceipt {\n readonly sourceRows: number;\n readonly comparisons: number;\n readonly unavailableComparisons: number;\n readonly definitePrefixLength: number;\n readonly possiblePrefixLength: number;\n readonly stepReceipts: readonly OrderStepReceipt[];\n readonly complete: boolean;\n readonly exhaustive: boolean;\n readonly decisive: boolean;\n}\nexport interface MatcherOrderPathNode {\n readonly step: number;\n readonly locator: MatcherSourceLocator;\n readonly sessionId: string;\n readonly sessionSequence: number;\n readonly result: \"matched\" | \"unavailable\";\n}\nexport interface MatcherFailureFrontier {\n readonly longestDefinitePrefix: readonly MatcherOrderPathNode[];\n readonly longestPossiblePrefix: readonly MatcherOrderPathNode[];\n readonly firstBlockingStep: number;\n readonly suffixChecked: AssertionCollectionReceipt;\n readonly representatives: readonly MatcherRetainedRow[];\n}\nexport type MatcherQueryArtifact = {\n readonly kind: \"collection-filter\";\n readonly sourceSnapshot: MatcherSourceSnapshot;\n readonly query: MatcherQueryStep;\n readonly receipt: AssertionCollectionReceipt;\n readonly retainedRows: readonly MatcherRetainedRow[];\n} | {\n readonly kind: \"ordered-sequence\";\n readonly sourceSnapshot: Extract<MatcherSourceSnapshot, {\n readonly scope: \"turn\" | \"session\";\n }>;\n readonly querySteps: readonly MatcherQueryStep[];\n readonly receipt: OrderEvaluationReceipt;\n readonly result: {\n readonly state: \"matched\";\n readonly witnessPath: readonly MatcherOrderPathNode[];\n } | {\n readonly state: \"mismatched\";\n readonly failureFrontier: MatcherFailureFrontier;\n } | {\n readonly state: \"unavailable\";\n readonly reason: string;\n };\n readonly retainedRows: readonly MatcherRetainedRow[];\n};\nexport type AssertionConditionPolicy = {\n readonly kind: \"boolean\";\n readonly expected: true;\n} | {\n readonly kind: \"at-least\";\n readonly threshold: number;\n} | {\n readonly kind: \"record-only\";\n};\nexport interface AssertionPolicy {\n readonly requirement: \"required\" | \"optional\";\n readonly condition: AssertionConditionPolicy;\n}\nexport type AssertionObserved = {\n readonly kind: \"boolean\";\n readonly outcome: \"matched\" | \"mismatched\" | \"unavailable\" | \"errored\" | \"not-applicable\";\n} | {\n readonly kind: \"measurement\";\n readonly state: \"available\";\n readonly value: number;\n} | {\n readonly kind: \"measurement\";\n readonly state: \"unavailable\";\n} | {\n readonly kind: \"direct-score\";\n readonly state: \"available\";\n readonly value: number;\n} | {\n readonly kind: \"direct-score\";\n readonly state: \"unavailable\";\n};\nexport type AssertionResult = {\n readonly state: \"matched\";\n readonly gate: \"not-gate\" | \"satisfied\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"earned\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"mismatched\";\n readonly reason: \"condition-not-met\";\n readonly gate: \"not-gate\" | \"failed\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"earned\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"evidence-unavailable\" | \"source-unavailable\" | \"redacted\";\n readonly gate: \"not-gate\" | \"unavailable\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"unavailable\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"errored\";\n readonly reason: \"evaluator-failed\" | \"producer-interrupted\" | \"invalid-subject\";\n readonly gate: \"not-gate\" | \"unavailable\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"unavailable\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"not-applicable\";\n readonly reason: \"coverage-not-applicable\";\n readonly gate: \"not-gate\" | \"not-applicable\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"unavailable\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n};\n/** One fully formed author/runtime result, before durable attachment encoding. */\nexport interface SealedAssertionEntry {\n readonly display: AssertionDisplay;\n readonly criterion: AssertionCriterion;\n readonly subject: AssertionMaterial;\n readonly evidence: readonly AssertionMaterial[];\n readonly coverage: AssertionCoverage;\n readonly limitations: readonly AssertionLimitation[];\n readonly result: AssertionResult;\n readonly policy: AssertionPolicy;\n readonly observed: AssertionObserved;\n readonly matcherArtifact?: MatcherQueryArtifact;\n}\n/**\n * Assertion handles are runtime-owned capabilities, not subjects for another\n * `t.check`. The symbol is public only for TypeScript's nominal boundary; the\n * runtime also keeps an unforgeable ownership registry.\n */\nexport const assertionHandleBrand: unique symbol = Symbol(\"niceeval.assertion-handle\");\ndeclare const assertionConditionStateBrand: unique symbol;\ndeclare const assertionGateStateBrand: unique symbol;\ndeclare const assertionScoreStateBrand: unique symbol;\nexport interface AssertionHandleBase<HasCondition extends boolean = boolean, HasScore extends boolean = boolean> {\n readonly [assertionHandleBrand]: true;\n readonly [assertionConditionStateBrand]: HasCondition;\n readonly [assertionScoreStateBrand]: HasScore;\n key(value: string): this;\n label(value: string): this;\n /** Adds one display-only group segment to this already registered entry. */\n group(title: string): this;\n}\n/** A value that is not an AssertionHandle. */\nexport type AssertionSubject<Value> = Value extends AssertionHandleBase ? never : Value;\n/** Numeric cardinality deliberately excludes the managed event occurrence subject. */\nexport type NumericAssertionSubject<Value> = Value extends ManagedEventOccurrences ? never : AssertionSubject<Value>;\nexport interface AssertionStopError {\n readonly _tag: \"AssertionStopError\";\n readonly entryIndex: number;\n readonly reason: \"condition-not-met\" | \"source-unavailable\" | \"evaluator-failed\" | \"not-applicable\";\n}\n/**\n * A public authoring call reached an Attempt boundary which is no longer able\n * to accept it. Keeping this distinct from an evaluator failure lets a\n * detached Promise diagnose its own lifecycle error instead of looking like a\n * failed assertion.\n */\nexport class AssertionAuthoringClosedError extends Error {\n readonly _tag = \"AssertionAuthoringClosedError\";\n constructor(readonly reason: \"stop-latched\" | \"attempt-sealing\" | \"attempt-sealed\" | \"attempt-interrupted\" | \"runtime-unattached\") {\n super(`Cannot use an Assertion authoring handle after ${reason}`);\n this.name = \"AssertionAuthoringClosedError\";\n }\n}\n/**\n * The owning Attempt executes a requested stop barrier in its existing Effect\n * scope. Handles only enqueue this request; they never create a runtime.\n */\nexport type AssertionStopExecutor = <Value>(effect: Effect.Effect<Value, AssertionStopError, never>) => Promise<Value>;\n/** A Boolean entry is evaluated once and may retain a refinement witness. */\nexport type BooleanAssertionEvaluation<Refined> = {\n readonly state: \"matched\";\n readonly value: Refined;\n readonly diagnostic?: MatchDiagnostic;\n readonly receipt?: AssertionCollectionReceipt;\n readonly matcherArtifact?: MatcherQueryArtifact;\n} | {\n readonly state: \"mismatched\";\n readonly diagnostic?: MatchDiagnostic;\n readonly receipt?: AssertionCollectionReceipt;\n readonly matcherArtifact?: MatcherQueryArtifact;\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"evidence-unavailable\" | \"source-unavailable\" | \"redacted\";\n readonly diagnostic?: MatchDiagnostic;\n readonly receipt?: AssertionCollectionReceipt;\n readonly matcherArtifact?: MatcherQueryArtifact;\n} | {\n readonly state: \"not-applicable\";\n readonly diagnostic?: MatchDiagnostic;\n readonly matcherArtifact?: MatcherQueryArtifact;\n};\n/** A measurement is always a finite unit-interval value when it is available. */\nexport type MeasurementAssertionEvaluation = {\n readonly state: \"measured\";\n readonly value: number;\n readonly detail?: AssertionSnapshotObject;\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"evidence-unavailable\" | \"source-unavailable\" | \"redacted\";\n readonly detail?: AssertionSnapshotObject;\n} | {\n readonly state: \"not-applicable\";\n readonly detail?: AssertionSnapshotObject;\n} | {\n readonly state: \"errored\";\n readonly detail?: AssertionSnapshotObject;\n};\nexport interface CapturedAssertionSnapshot {\n readonly material: Extract<AssertionMaterial, {\n readonly kind: \"snapshot\";\n }>;\n readonly coverage: AssertionCoverage;\n readonly limitations: readonly AssertionLimitation[];\n}\nexport interface AssertionRegistrationBase {\n readonly criterion: AssertionCriterion;\n readonly subject: AssertionMaterial;\n readonly evidence?: readonly AssertionMaterial[];\n readonly coverage?: AssertionCoverage;\n readonly limitations?: readonly AssertionLimitation[];\n}\n/**\n * Scope, Judge, and Sandbox adapters use this internal registration shape.\n * They still register exactly one Assertion entry; they do not manufacture a\n * separate intermediate value for a later consumer.\n */\nexport interface BooleanAssertionRegistration<Refined> extends AssertionRegistrationBase {\n /** Sealed when Attempt interruption prevents the ordinary evaluator from running. */\n readonly interruptedMatcherArtifact?: MatcherQueryArtifact;\n readonly evaluate: () => Effect.Effect<BooleanAssertionEvaluation<Refined>, unknown, never>;\n}\nexport interface MeasurementAssertionRegistration extends AssertionRegistrationBase {\n /** Bytes synchronously reserved from an Attempt-local producer budget. */\n readonly retainedBytes?: number;\n /** Complete terminal Content appended exactly once by the shared sealing path. */\n readonly terminalEvidence?: () => readonly AssertionMaterial[];\n /** Terminal producer facts frozen by the shared Assertion sealing path. */\n readonly terminalDetail?: () => AssertionSnapshotObject;\n readonly evaluate: () => Effect.Effect<MeasurementAssertionEvaluation, unknown, never>;\n}\nexport interface PassBooleanAssertionHandle<out Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n /** An unavailable/errored optional entry does not independently error Verdict. */\n optional(): this;\n gate(this: PassBooleanAssertionHandle<Refined, false>): PassBooleanAssertionHandle<Refined, true>;\n orStop(): Promise<Refined>;\n}\nexport interface ScoreBooleanAssertionHandle<out Refined, HasGate extends boolean = false, HasScore extends boolean = false> extends AssertionHandleBase<true, HasScore> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n gate(this: ScoreBooleanAssertionHandle<Refined, false, HasScore>): ScoreBooleanAssertionHandle<Refined, true, HasScore>;\n score(this: ScoreBooleanAssertionHandle<Refined, HasGate, false>, points: number): ScoreBooleanAssertionHandle<Refined, HasGate, true>;\n orStop(): Promise<Refined>;\n}\nexport interface PassMeasurementAssertionHandle<HasCondition extends boolean = false> extends AssertionHandleBase<HasCondition, false> {\n readonly kind: \"measurement\";\n gate(this: PassMeasurementAssertionHandle<false>, minimum: number): PassMeasurementAssertionHandle<true>;\n orStop(this: PassMeasurementAssertionHandle<false>, minimum: number): Promise<number>;\n orStop(this: PassMeasurementAssertionHandle<true>): Promise<number>;\n}\nexport interface ScoreMeasurementAssertionHandle<HasCondition extends boolean = false, HasScore extends boolean = false> extends AssertionHandleBase<HasCondition, HasScore> {\n readonly kind: \"measurement\";\n gate(this: ScoreMeasurementAssertionHandle<false, HasScore>, minimum: number): ScoreMeasurementAssertionHandle<true, HasScore>;\n score(this: ScoreMeasurementAssertionHandle<HasCondition, false>, points: number): ScoreMeasurementAssertionHandle<HasCondition, true>;\n orStop(this: ScoreMeasurementAssertionHandle<false, HasScore>, minimum: number): Promise<number>;\n orStop(this: ScoreMeasurementAssertionHandle<true, HasScore>): Promise<number>;\n}\n/** A Boolean Assertion that intentionally has no author control-flow operation. */\ninterface PostRunPassBooleanAssertionHandle<Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n optional(): this;\n gate(this: PostRunPassBooleanAssertionHandle<Refined, false>): PostRunPassBooleanAssertionHandle<Refined, true>;\n}\ninterface PostRunScoreBooleanAssertionHandle<Refined, HasGate extends boolean = false, HasScore extends boolean = false> extends AssertionHandleBase<true, HasScore> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n gate(this: PostRunScoreBooleanAssertionHandle<Refined, false, HasScore>): PostRunScoreBooleanAssertionHandle<Refined, true, HasScore>;\n score(this: PostRunScoreBooleanAssertionHandle<Refined, HasGate, false>, points: number): PostRunScoreBooleanAssertionHandle<Refined, HasGate, true>;\n}\nexport type PostRunBooleanAssertionHandle<Kind extends AssertionEvaluationKind, Refined, HasGate extends boolean = false, HasScore extends boolean = false> = Kind extends \"pass\" ? PostRunPassBooleanAssertionHandle<Refined, HasGate> : PostRunScoreBooleanAssertionHandle<Refined, HasGate, HasScore>;\n/** Direct score is an Assertion entry, but has no condition or stop barrier. */\nexport interface DirectScoreAssertionHandle extends AssertionHandleBase<false, true> {\n readonly kind: \"direct-score\";\n}\nexport interface AssertionGroupContext {\n /**\n * Runs an ordinary author callback with one display-only group segment. The\n * callback remains inside the Attempt's outer Promise boundary; this facade\n * does not evaluate an Effect or create an independent runtime.\n */\n group<Value>(title: string, body: () => Value | PromiseLike<Value>): Promise<Awaited<Value>>;\n}\nexport interface PassAssertionsContext extends AssertionGroupContext {\n readonly evaluationKind: \"pass\";\n check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, \"value\">): PassBooleanAssertionHandle<Refined>;\n check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): PassBooleanAssertionHandle<Value>;\n check<S extends \"turn\" | \"session\" | \"attempt\">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): PassBooleanAssertionHandle<ManagedToolCalls<S>>;\n check<S extends \"turn\" | \"session\" | \"attempt\">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): PassBooleanAssertionHandle<ManagedEventOccurrences<S>>;\n check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): PassBooleanAssertionHandle<Value>;\n check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): PassMeasurementAssertionHandle;\n}\nexport interface ScoreAssertionsContext extends AssertionGroupContext {\n readonly evaluationKind: \"score\";\n check<Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, \"value\">): ScoreBooleanAssertionHandle<Refined>;\n check<Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): ScoreBooleanAssertionHandle<Value>;\n check<S extends \"turn\" | \"session\" | \"attempt\">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): ScoreBooleanAssertionHandle<ManagedToolCalls<S>>;\n check<S extends \"turn\" | \"session\" | \"attempt\">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): ScoreBooleanAssertionHandle<ManagedEventOccurrences<S>>;\n check<Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): ScoreBooleanAssertionHandle<Value>;\n check<Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): ScoreMeasurementAssertionHandle;\n score(points: number): DirectScoreAssertionHandle;\n}\nexport type AssertionsContext<Kind extends AssertionEvaluationKind> = Kind extends \"pass\" ? PassAssertionsContext : ScoreAssertionsContext;\nexport type BooleanAssertionHandle<Kind extends AssertionEvaluationKind, Refined, HasGate extends boolean = false, HasScore extends boolean = false> = Kind extends \"pass\" ? PassBooleanAssertionHandle<Refined, HasGate> : ScoreBooleanAssertionHandle<Refined, HasGate, HasScore>;\nexport type MeasurementAssertionHandle<Kind extends AssertionEvaluationKind, HasCondition extends boolean = false, HasScore extends boolean = false> = Kind extends \"pass\" ? PassMeasurementAssertionHandle<HasCondition> : ScoreMeasurementAssertionHandle<HasCondition, HasScore>;\nexport interface AssertionSealOptions {\n readonly execution?: \"completed\" | \"errored\";\n readonly explicitlySkipped?: boolean;\n /**\n * The owning Attempt was interrupted before ordinary evaluation could\n * finish. Unsettled entries are sealed as producer-interrupted instead of\n * being silently omitted or evaluated on a detached runtime.\n */\n readonly interrupted?: boolean;\n}\n/** Sealing has no expected authoring failure after registration-time validation. */\nexport type AssertionSealError = never;\n/** The sealed evaluation is a domain result, not a durable Record payload. */\nexport interface SealedAssertionEvaluationEntry {\n readonly required: boolean;\n readonly result: AssertionResult;\n}\nexport interface SealedAssertionEvaluation {\n readonly execution: \"completed\" | \"errored\";\n readonly explicitlySkipped: boolean;\n readonly assertions: readonly SealedAssertionEvaluationEntry[];\n}\n/**\n * One immutable result feeds the Verdict/Score fold and the private durable\n * producer adapter. No RecordAttachment writer type crosses this boundary.\n */\nexport interface SealedAssertionsRuntime {\n readonly entries: readonly SealedAssertionEntry[];\n readonly evaluation: SealedAssertionEvaluation;\n}\n/** The runtime Verdict is independent of the durable Verdict attachment codec. */\nexport interface AssertionVerdict {\n readonly state: import(\"../shared/types.ts\").Verdict;\n}\nexport type AssertionScoreIncompleteReason = \"execution-errored\" | \"source-unavailable\" | \"evaluation-errored\" | \"not-applicable\";\n/** The runtime Score is independent of the durable Score attachment codec. */\nexport type AssertionScore = {\n readonly state: \"complete\";\n readonly earned: number;\n} | {\n readonly state: \"partial\";\n readonly earned: number;\n readonly reasons: readonly AssertionScoreIncompleteReason[];\n} | {\n readonly state: \"unavailable\";\n readonly reasons: readonly AssertionScoreIncompleteReason[];\n};\n/**\n * The attempt-owned frozen result is handed from Runner to the Evaluation\n * Record adapter. The adapter alone adds attachment schemas and writes.\n */\nexport interface SealedAttemptAssertions {\n readonly entries: readonly SealedAssertionEntry[];\n readonly evaluation: SealedAssertionEvaluation;\n readonly workspaceDiff?: AgentWorkspaceDiff;\n readonly verdict: AssertionVerdict;\n readonly score?: AssertionScore;\n}\nexport interface AssertionsRuntime<Kind extends AssertionEvaluationKind> {\n readonly evaluationKind: Kind;\n readonly t: AssertionsContext<Kind>;\n /** @internal Reject before an adapter reads or snapshots author material. */\n assertAuthoringOpen(): void;\n /** Attempt-owned synchronous admission close; sealing still happens once through `seal`. */\n closeAuthoring(reason: \"attempt-sealing\" | \"attempt-interrupted\"): void;\n registerBoolean<Refined>(definition: BooleanAssertionRegistration<Refined>): BooleanAssertionHandle<Kind, Refined>;\n registerMeasurement(definition: MeasurementAssertionRegistration): MeasurementAssertionHandle<Kind>;\n seal(options?: AssertionSealOptions): Effect.Effect<SealedAssertionsRuntime, AssertionSealError, never>;\n}\n"]}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["api.ts"],"names":[],"mappings":";;;AAqXA;;;;GAIG;AACU,QAAA,oBAAoB,GAAkB,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAsBvF;;;;;GAKG;AACH,MAAa,6BAA8B,SAAQ,KAAK;IAE/B;IADZ,IAAI,GAAG,+BAA+B,CAAC;IAChD,YAAqB,MAA4G;QAC7H,KAAK,CAAC,kDAAkD,MAAM,EAAE,CAAC,CAAC;QADjD,WAAM,GAAN,MAAM,CAAsG;QAE7H,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAChD,CAAC;CACJ;AAND,sEAMC","sourcesContent":["import type { Effect } from \"effect\";\nimport type { BooleanMatch, CollectionMatch, ManagedToolCalls, MatchDiagnostic, NumericComparator, NumericComparisonMatch, ScoreMatch, EventMatch, ManagedEventOccurrences, ToolMatch, } from \"./match.ts\";\nimport type { AgentWorkspaceDiff } from \"./workspace-diff.ts\";\nimport type { EvaluationKind } from \"../shared/evaluation.ts\";\n/** The two Evaluation kinds deliberately share one Assertion entry model. */\nexport type AssertionEvaluationKind = EvaluationKind;\n/**\n * A bounded JSON-shaped value owned by the authoring runtime. It is a\n * domain value, not the durable Assertions attachment material type.\n */\nexport type AssertionSnapshotValue = null | boolean | number | string | readonly AssertionSnapshotValue[] | AssertionSnapshotObject;\nexport interface AssertionSnapshotObject {\n readonly [key: string]: AssertionSnapshotValue;\n}\nexport interface AssertionDisplay {\n readonly key?: string;\n readonly label?: string;\n readonly groupPath: readonly string[];\n}\nexport type AssertionCoverage = {\n readonly state: \"complete\";\n} | {\n readonly state: \"partial\";\n readonly reason: \"sampled\" | \"truncated\" | \"redacted\" | \"provider-limited\";\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"not-collected\" | \"source-unavailable\" | \"producer-failed\";\n} | {\n readonly state: \"not-applicable\";\n readonly reason: \"optional-material\" | \"unsupported-subject\";\n};\nexport type AssertionLimitation = {\n readonly kind: \"redacted\";\n readonly fieldCount: number;\n} | {\n readonly kind: \"sampled\";\n readonly captured: number;\n readonly knownTotal?: number;\n} | {\n readonly kind: \"truncated\";\n readonly omittedBytes: number;\n} | {\n readonly kind: \"provider-limited\";\n};\n/**\n * Authoring material intentionally has no blob ref, attachment entry ID, or\n * durable schema identity. The private producer adapter selects the exact\n * same-owner Attachment schema when it serializes this domain reference.\n */\nexport type AssertionMaterial = {\n readonly kind: \"snapshot\";\n readonly value: AssertionSnapshotValue;\n} | {\n readonly kind: \"record-attachment\";\n readonly preview: string;\n};\nexport type AssertionCriterion = {\n readonly kind: \"value-match\";\n readonly subject: \"explicit-value\";\n readonly matcher: {\n readonly state: \"declared\";\n readonly name: string;\n } | {\n readonly state: \"unavailable\";\n };\n} | {\n /** Package-private runtime variant encoded as numeric-comparison/v1. */\n readonly kind: \"value-match\";\n readonly numeric: {\n readonly comparator: NumericComparator;\n readonly threshold: number;\n readonly subject: {\n readonly kind: \"explicit-value\";\n } | {\n readonly kind: \"scope-metric\";\n readonly metric: \"tokens\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly unit: \"tokens\";\n } | {\n readonly kind: \"scope-metric\";\n readonly metric: \"cost\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly unit: \"usd\";\n } | {\n readonly kind: \"collection-cardinality\";\n readonly collection: \"tool-calls\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n };\n };\n} | {\n readonly kind: \"scope-status\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly assertion: \"succeeded\" | \"no-failed-actions\";\n} | {\n readonly kind: \"occurrence\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly occurrence: \"tool\" | \"skill\" | \"event\";\n readonly assertion: \"present\" | \"absent\" | \"count\" | \"order\";\n readonly matcher?: string;\n readonly quantifier?: {\n readonly kind: \"absent\";\n } | {\n readonly kind: \"at-least\" | \"less-than\" | \"at-most\" | \"greater-than\" | \"exact\";\n readonly count: number;\n };\n} | {\n readonly kind: \"judge-measurement\";\n readonly name: string;\n readonly scale: \"unit-interval\";\n} | {\n readonly kind: \"managed-score-measurement\";\n readonly name: string;\n readonly scale: \"unit-interval\";\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"changed-paths\";\n readonly paths: readonly string[];\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"no-changes\";\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"file-changed\";\n readonly path: string;\n readonly status?: \"added\" | \"modified\" | \"deleted\";\n readonly before?: string;\n readonly after?: string;\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"file-deleted\";\n readonly path: string;\n} | {\n readonly kind: \"sandbox-result\";\n readonly operation: \"not-in-diff\";\n readonly pattern: string;\n readonly flags: string;\n readonly content: \"added\" | \"removed\" | \"both\";\n} | {\n readonly kind: \"direct-score\";\n readonly source: \"author\";\n} | {\n readonly kind: \"third-party\";\n readonly name: string;\n readonly schemaId: string;\n readonly data: AssertionSnapshotValue;\n};\nexport type AssertionScoreContribution = {\n readonly state: \"not-scored\";\n} | {\n readonly state: \"earned\";\n readonly points: number;\n readonly earned: number;\n} | {\n readonly state: \"unavailable\";\n readonly points: number;\n readonly reason: \"source-unavailable\" | \"evaluation-errored\" | \"not-applicable\";\n};\n/** Constant-size semantic receipt for one collection evaluation. */\nexport interface AssertionCollectionReceipt {\n readonly examined: number;\n readonly matched: number;\n readonly mismatched: number;\n readonly unavailable: number;\n readonly knownTotal: number | null;\n readonly complete: boolean;\n readonly exhaustive: boolean;\n readonly decisive: boolean;\n}\nexport type MatcherRelationStatus = {\n readonly state: \"exact\";\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"historical-not-recorded\" | \"source-unavailable\" | \"ambiguous\";\n};\nexport type MatcherSourceLocator = {\n readonly kind: \"tool-occurrence\";\n readonly toolOccurrenceId: string;\n readonly relation: MatcherRelationStatus;\n} | {\n readonly kind: \"event\";\n readonly eventId: string;\n readonly toolOccurrenceId?: string;\n readonly relation: MatcherRelationStatus;\n};\nexport interface MatcherRetainedRow {\n readonly locator: MatcherSourceLocator;\n readonly result: \"matched\" | \"mismatched\" | \"unavailable\" | \"not-evaluated\";\n readonly difference?: AssertionSnapshotValue;\n}\nexport interface MatcherQueryStep {\n readonly step: number;\n readonly summary: AssertionSnapshotValue;\n}\nexport type MatcherSourceSnapshot = {\n readonly scope: \"turn\";\n readonly sessionId: string;\n readonly turnId: string;\n readonly scopeId: string;\n readonly throughSessionSequence: number;\n readonly source: {\n readonly family: \"niceeval.agent-turns\";\n readonly schemaVersion: number;\n };\n readonly collectionAtCut: \"complete\" | \"partial\" | \"unavailable\";\n} | {\n readonly scope: \"session\";\n readonly sessionId: string;\n readonly scopeId: string;\n readonly throughSessionSequence: number;\n readonly source: {\n readonly family: \"niceeval.agent-turns\";\n readonly schemaVersion: number;\n };\n readonly collectionAtCut: \"complete\" | \"partial\" | \"unavailable\";\n} | {\n readonly scope: \"attempt\";\n readonly scopeId: string;\n readonly sessions: readonly {\n readonly sessionId: string;\n readonly throughSessionSequence: number;\n }[];\n readonly source: {\n readonly family: \"niceeval.agent-turns\";\n readonly schemaVersion: number;\n };\n readonly collectionAtCut: \"complete\" | \"partial\" | \"unavailable\";\n};\nexport interface OrderStepReceipt {\n readonly step: number;\n readonly comparisons: number;\n readonly matched: number;\n readonly mismatched: number;\n readonly unavailable: number;\n}\nexport interface OrderEvaluationReceipt {\n readonly sourceRows: number;\n readonly comparisons: number;\n readonly unavailableComparisons: number;\n readonly definitePrefixLength: number;\n readonly possiblePrefixLength: number;\n readonly stepReceipts: readonly OrderStepReceipt[];\n readonly complete: boolean;\n readonly exhaustive: boolean;\n readonly decisive: boolean;\n}\nexport interface MatcherOrderPathNode {\n readonly step: number;\n readonly locator: MatcherSourceLocator;\n readonly sessionId: string;\n readonly sessionSequence: number;\n readonly result: \"matched\" | \"unavailable\";\n}\nexport interface MatcherFailureFrontier {\n readonly longestDefinitePrefix: readonly MatcherOrderPathNode[];\n readonly longestPossiblePrefix: readonly MatcherOrderPathNode[];\n readonly firstBlockingStep: number;\n readonly suffixChecked: AssertionCollectionReceipt;\n readonly representatives: readonly MatcherRetainedRow[];\n}\nexport type MatcherQueryArtifact = {\n readonly kind: \"collection-filter\";\n readonly sourceSnapshot: MatcherSourceSnapshot;\n readonly query: MatcherQueryStep;\n readonly receipt: AssertionCollectionReceipt;\n readonly retainedRows: readonly MatcherRetainedRow[];\n} | {\n readonly kind: \"ordered-sequence\";\n readonly sourceSnapshot: Extract<MatcherSourceSnapshot, {\n readonly scope: \"turn\" | \"session\";\n }>;\n readonly querySteps: readonly MatcherQueryStep[];\n readonly receipt: OrderEvaluationReceipt;\n readonly result: {\n readonly state: \"matched\";\n readonly witnessPath: readonly MatcherOrderPathNode[];\n } | {\n readonly state: \"mismatched\";\n readonly failureFrontier: MatcherFailureFrontier;\n } | {\n readonly state: \"unavailable\";\n readonly reason: string;\n };\n readonly retainedRows: readonly MatcherRetainedRow[];\n};\nexport type AssertionConditionPolicy = {\n readonly kind: \"boolean\";\n readonly expected: true;\n} | {\n readonly kind: \"at-least\";\n readonly threshold: number;\n} | {\n readonly kind: \"record-only\";\n};\nexport interface AssertionPolicy {\n readonly requirement: \"required\" | \"optional\";\n readonly condition: AssertionConditionPolicy;\n}\nexport type AssertionObserved = {\n readonly kind: \"boolean\";\n readonly outcome: \"matched\" | \"mismatched\" | \"unavailable\" | \"errored\" | \"not-applicable\";\n} | {\n readonly kind: \"measurement\";\n readonly state: \"available\";\n readonly value: number;\n} | {\n readonly kind: \"measurement\";\n readonly state: \"unavailable\";\n} | {\n readonly kind: \"direct-score\";\n readonly state: \"available\";\n readonly value: number;\n} | {\n readonly kind: \"direct-score\";\n readonly state: \"unavailable\";\n};\nexport type AssertionResult = {\n readonly state: \"matched\";\n readonly gate: \"not-gate\" | \"satisfied\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"earned\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"mismatched\";\n readonly reason: \"condition-not-met\";\n readonly gate: \"not-gate\" | \"failed\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"earned\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"evidence-unavailable\" | \"source-unavailable\" | \"redacted\";\n readonly gate: \"not-gate\" | \"unavailable\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"unavailable\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"errored\";\n readonly reason: \"evaluator-failed\" | \"producer-interrupted\" | \"invalid-subject\";\n readonly gate: \"not-gate\" | \"unavailable\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"unavailable\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n} | {\n readonly state: \"not-applicable\";\n readonly reason: \"coverage-not-applicable\";\n readonly gate: \"not-gate\" | \"not-applicable\";\n readonly score: Extract<AssertionScoreContribution, {\n readonly state: \"not-scored\" | \"unavailable\";\n }>;\n readonly diagnostic?: AssertionSnapshotObject;\n readonly receipt?: AssertionCollectionReceipt;\n};\n/** One fully formed author/runtime result, before durable attachment encoding. */\nexport interface SealedAssertionEntry {\n readonly display: AssertionDisplay;\n readonly criterion: AssertionCriterion;\n readonly subject: AssertionMaterial;\n readonly evidence: readonly AssertionMaterial[];\n readonly coverage: AssertionCoverage;\n readonly limitations: readonly AssertionLimitation[];\n readonly result: AssertionResult;\n readonly policy: AssertionPolicy;\n readonly observed: AssertionObserved;\n readonly matcherArtifact?: MatcherQueryArtifact;\n}\n/**\n * Assertion handles are runtime-owned capabilities, not subjects for another\n * `t.check`. The symbol is public only for TypeScript's nominal boundary; the\n * runtime also keeps an unforgeable ownership registry.\n */\nexport const assertionHandleBrand: unique symbol = Symbol(\"niceeval.assertion-handle\");\ndeclare const assertionConditionStateBrand: unique symbol;\ndeclare const assertionGateStateBrand: unique symbol;\ndeclare const assertionScoreStateBrand: unique symbol;\nexport interface AssertionHandleBase<HasCondition extends boolean = boolean, HasScore extends boolean = boolean> {\n readonly [assertionHandleBrand]: true;\n readonly [assertionConditionStateBrand]: HasCondition;\n readonly [assertionScoreStateBrand]: HasScore;\n key(value: string): this;\n label(value: string): this;\n /** Adds one display-only group segment to this already registered entry. */\n group(title: string): this;\n}\n/** A value that is not an AssertionHandle. */\nexport type AssertionSubject<Value> = Value extends AssertionHandleBase ? never : Value;\n/** Numeric cardinality deliberately excludes the managed event occurrence subject. */\nexport type NumericAssertionSubject<Value> = Value extends ManagedEventOccurrences ? never : AssertionSubject<Value>;\nexport interface AssertionStopError {\n readonly _tag: \"AssertionStopError\";\n readonly entryIndex: number;\n readonly reason: \"condition-not-met\" | \"source-unavailable\" | \"evaluator-failed\" | \"not-applicable\";\n}\n/**\n * A public authoring call reached an Attempt boundary which is no longer able\n * to accept it. Keeping this distinct from an evaluator failure lets a\n * detached Promise diagnose its own lifecycle error instead of looking like a\n * failed assertion.\n */\nexport class AssertionAuthoringClosedError extends Error {\n readonly _tag = \"AssertionAuthoringClosedError\";\n constructor(readonly reason: \"stop-latched\" | \"attempt-sealing\" | \"attempt-sealed\" | \"attempt-interrupted\" | \"runtime-unattached\") {\n super(`Cannot use an Assertion authoring handle after ${reason}`);\n this.name = \"AssertionAuthoringClosedError\";\n }\n}\n/**\n * The owning Attempt executes a requested stop barrier in its existing Effect\n * scope. Handles only enqueue this request; they never create a runtime.\n */\nexport type AssertionStopExecutor = <Value>(effect: Effect.Effect<Value, AssertionStopError, never>) => Promise<Value>;\n/** A Boolean entry is evaluated once and may retain a refinement witness. */\nexport type BooleanAssertionEvaluation<Refined> = {\n readonly state: \"matched\";\n readonly value: Refined;\n readonly diagnostic?: MatchDiagnostic;\n readonly receipt?: AssertionCollectionReceipt;\n readonly matcherArtifact?: MatcherQueryArtifact;\n} | {\n readonly state: \"mismatched\";\n readonly diagnostic?: MatchDiagnostic;\n readonly receipt?: AssertionCollectionReceipt;\n readonly matcherArtifact?: MatcherQueryArtifact;\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"evidence-unavailable\" | \"source-unavailable\" | \"redacted\";\n readonly diagnostic?: MatchDiagnostic;\n readonly receipt?: AssertionCollectionReceipt;\n readonly matcherArtifact?: MatcherQueryArtifact;\n} | {\n readonly state: \"not-applicable\";\n readonly diagnostic?: MatchDiagnostic;\n readonly matcherArtifact?: MatcherQueryArtifact;\n};\n/** A measurement is always a finite unit-interval value when it is available. */\nexport type MeasurementAssertionEvaluation = {\n readonly state: \"measured\";\n readonly value: number;\n readonly detail?: AssertionSnapshotObject;\n} | {\n readonly state: \"unavailable\";\n readonly reason: \"evidence-unavailable\" | \"source-unavailable\" | \"redacted\";\n readonly detail?: AssertionSnapshotObject;\n} | {\n readonly state: \"not-applicable\";\n readonly detail?: AssertionSnapshotObject;\n} | {\n readonly state: \"errored\";\n readonly detail?: AssertionSnapshotObject;\n};\nexport interface CapturedAssertionSnapshot {\n readonly material: Extract<AssertionMaterial, {\n readonly kind: \"snapshot\";\n }>;\n readonly coverage: AssertionCoverage;\n readonly limitations: readonly AssertionLimitation[];\n}\nexport interface AssertionRegistrationBase {\n readonly criterion: AssertionCriterion;\n readonly subject: AssertionMaterial;\n readonly evidence?: readonly AssertionMaterial[];\n readonly coverage?: AssertionCoverage;\n readonly limitations?: readonly AssertionLimitation[];\n}\n/**\n * Scope, Judge, and Sandbox adapters use this internal registration shape.\n * They still register exactly one Assertion entry; they do not manufacture a\n * separate intermediate value for a later consumer.\n */\nexport interface BooleanAssertionRegistration<Refined> extends AssertionRegistrationBase {\n /** Sealed when Attempt interruption prevents the ordinary evaluator from running. */\n readonly interruptedMatcherArtifact?: MatcherQueryArtifact;\n readonly evaluate: () => Effect.Effect<BooleanAssertionEvaluation<Refined>, unknown, never>;\n}\nexport interface MeasurementAssertionRegistration extends AssertionRegistrationBase {\n /** Bytes synchronously reserved from an Attempt-local producer budget. */\n readonly retainedBytes?: number;\n /** Complete terminal Content appended exactly once by the shared sealing path. */\n readonly terminalEvidence?: () => readonly AssertionMaterial[];\n /** Terminal producer facts frozen by the shared Assertion sealing path. */\n readonly terminalDetail?: () => AssertionSnapshotObject;\n readonly evaluate: () => Effect.Effect<MeasurementAssertionEvaluation, unknown, never>;\n}\nexport interface PassBooleanAssertionHandle<out Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n /** An unavailable/errored optional entry does not independently error Verdict. */\n optional(): this;\n gate(this: PassBooleanAssertionHandle<Refined, false>): PassBooleanAssertionHandle<Refined, true>;\n orStop(): Promise<Refined>;\n}\nexport interface ScoreBooleanAssertionHandle<out Refined, HasGate extends boolean = false, HasScore extends boolean = false> extends AssertionHandleBase<true, HasScore> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n gate(this: ScoreBooleanAssertionHandle<Refined, false, HasScore>): ScoreBooleanAssertionHandle<Refined, true, HasScore>;\n score(this: ScoreBooleanAssertionHandle<Refined, HasGate, false>, points: number): ScoreBooleanAssertionHandle<Refined, HasGate, true>;\n orStop(): Promise<Refined>;\n}\nexport interface PassMeasurementAssertionHandle<HasCondition extends boolean = false> extends AssertionHandleBase<HasCondition, false> {\n readonly kind: \"measurement\";\n gate(this: PassMeasurementAssertionHandle<false>, minimum: number): PassMeasurementAssertionHandle<true>;\n orStop(this: PassMeasurementAssertionHandle<false>, minimum: number): Promise<number>;\n orStop(this: PassMeasurementAssertionHandle<true>): Promise<number>;\n}\nexport interface ScoreMeasurementAssertionHandle<HasCondition extends boolean = false, HasScore extends boolean = false> extends AssertionHandleBase<HasCondition, HasScore> {\n readonly kind: \"measurement\";\n gate(this: ScoreMeasurementAssertionHandle<false, HasScore>, minimum: number): ScoreMeasurementAssertionHandle<true, HasScore>;\n score(this: ScoreMeasurementAssertionHandle<HasCondition, false>, points: number): ScoreMeasurementAssertionHandle<HasCondition, true>;\n orStop(this: ScoreMeasurementAssertionHandle<false, HasScore>, minimum: number): Promise<number>;\n orStop(this: ScoreMeasurementAssertionHandle<true, HasScore>): Promise<number>;\n}\n/** A Boolean Assertion that intentionally has no author control-flow operation. */\ninterface PostRunPassBooleanAssertionHandle<Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n optional(): this;\n gate(this: PostRunPassBooleanAssertionHandle<Refined, false>): PostRunPassBooleanAssertionHandle<Refined, true>;\n}\ninterface PostRunScoreBooleanAssertionHandle<Refined, HasGate extends boolean = false, HasScore extends boolean = false> extends AssertionHandleBase<true, HasScore> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n gate(this: PostRunScoreBooleanAssertionHandle<Refined, false, HasScore>): PostRunScoreBooleanAssertionHandle<Refined, true, HasScore>;\n score(this: PostRunScoreBooleanAssertionHandle<Refined, HasGate, false>, points: number): PostRunScoreBooleanAssertionHandle<Refined, HasGate, true>;\n}\nexport type PostRunBooleanAssertionHandle<Kind extends AssertionEvaluationKind, Refined, HasGate extends boolean = false, HasScore extends boolean = false> = Kind extends \"pass\" ? PostRunPassBooleanAssertionHandle<Refined, HasGate> : PostRunScoreBooleanAssertionHandle<Refined, HasGate, HasScore>;\n/** Direct score is an Assertion entry, but has no condition or stop barrier. */\nexport interface DirectScoreAssertionHandle extends AssertionHandleBase<false, true> {\n readonly kind: \"direct-score\";\n}\n/**\n * Definition-time handle shared by Adapter Assertion factories. It exposes\n * only operations whose meaning is identical in Pass and Score Evals; the\n * bound Eval factory replaces it with the native handle for its Kind.\n */\nexport interface PolymorphicBooleanAssertionHandle<out Refined, HasGate extends boolean = false> extends AssertionHandleBase<true, false> {\n readonly kind: \"boolean\";\n readonly [assertionGateStateBrand]: HasGate;\n gate(this: PolymorphicBooleanAssertionHandle<Refined, false>): PolymorphicBooleanAssertionHandle<Refined, true>;\n orStop(): Promise<Refined>;\n}\n/** Definition-time measurement counterpart to PolymorphicBooleanAssertionHandle. */\nexport interface PolymorphicMeasurementAssertionHandle<HasCondition extends boolean = false> extends AssertionHandleBase<HasCondition, false> {\n readonly kind: \"measurement\";\n gate(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): PolymorphicMeasurementAssertionHandle<true>;\n orStop(this: PolymorphicMeasurementAssertionHandle<false>, minimum: number): Promise<number>;\n orStop(this: PolymorphicMeasurementAssertionHandle<true>): Promise<number>;\n}\nexport type AssertionCheckKind = AssertionEvaluationKind | \"polymorphic\";\ntype CheckedBooleanHandle<Kind extends AssertionCheckKind, Refined> = Kind extends AssertionEvaluationKind ? BooleanAssertionHandle<Kind, Refined> : PolymorphicBooleanAssertionHandle<Refined>;\ntype CheckedMeasurementHandle<Kind extends AssertionCheckKind> = Kind extends AssertionEvaluationKind ? MeasurementAssertionHandle<Kind> : PolymorphicMeasurementAssertionHandle;\n/** Single owner for the public check overload set, including Adapter-polymorphic factories. */\nexport interface AssertionCheck<Kind extends AssertionCheckKind> {\n <Value, Refined extends Value>(value: AssertionSubject<Value>, match: BooleanMatch<NoInfer<Value>, Refined, \"value\">): CheckedBooleanHandle<Kind, Refined>;\n <Value extends readonly unknown[]>(value: NumericAssertionSubject<Value>, match: NumericComparisonMatch): CheckedBooleanHandle<Kind, Value>;\n <S extends \"turn\" | \"session\" | \"attempt\">(value: AssertionSubject<ManagedToolCalls<S>>, match: ToolMatch): CheckedBooleanHandle<Kind, ManagedToolCalls<S>>;\n <S extends \"turn\" | \"session\" | \"attempt\">(value: AssertionSubject<ManagedEventOccurrences<S>>, match: EventMatch): CheckedBooleanHandle<Kind, ManagedEventOccurrences<S>>;\n <Value>(value: AssertionSubject<Value>, match: CollectionMatch<NoInfer<Value>>): CheckedBooleanHandle<Kind, Value>;\n <Value>(value: AssertionSubject<Value>, match: ScoreMatch<NoInfer<Value>>): CheckedMeasurementHandle<Kind>;\n}\nexport interface AssertionGroupContext {\n /**\n * Runs an ordinary author callback with one display-only group segment. The\n * callback remains inside the Attempt's outer Promise boundary; this facade\n * does not evaluate an Effect or create an independent runtime.\n */\n group<Value>(title: string, body: () => Value | PromiseLike<Value>): Promise<Awaited<Value>>;\n}\nexport interface PassAssertionsContext extends AssertionGroupContext {\n readonly evaluationKind: \"pass\";\n readonly check: AssertionCheck<\"pass\">;\n}\nexport interface ScoreAssertionsContext extends AssertionGroupContext {\n readonly evaluationKind: \"score\";\n readonly check: AssertionCheck<\"score\">;\n score(points: number): DirectScoreAssertionHandle;\n}\nexport type AssertionsContext<Kind extends AssertionEvaluationKind> = Kind extends \"pass\" ? PassAssertionsContext : ScoreAssertionsContext;\nexport type BooleanAssertionHandle<Kind extends AssertionEvaluationKind, Refined, HasGate extends boolean = false, HasScore extends boolean = false> = Kind extends \"pass\" ? PassBooleanAssertionHandle<Refined, HasGate> : ScoreBooleanAssertionHandle<Refined, HasGate, HasScore>;\nexport type MeasurementAssertionHandle<Kind extends AssertionEvaluationKind, HasCondition extends boolean = false, HasScore extends boolean = false> = Kind extends \"pass\" ? PassMeasurementAssertionHandle<HasCondition> : ScoreMeasurementAssertionHandle<HasCondition, HasScore>;\nexport interface AssertionSealOptions {\n readonly execution?: \"completed\" | \"errored\";\n readonly explicitlySkipped?: boolean;\n /**\n * The owning Attempt was interrupted before ordinary evaluation could\n * finish. Unsettled entries are sealed as producer-interrupted instead of\n * being silently omitted or evaluated on a detached runtime.\n */\n readonly interrupted?: boolean;\n}\n/** Sealing has no expected authoring failure after registration-time validation. */\nexport type AssertionSealError = never;\n/** The sealed evaluation is a domain result, not a durable Record payload. */\nexport interface SealedAssertionEvaluationEntry {\n readonly required: boolean;\n readonly result: AssertionResult;\n}\nexport interface SealedAssertionEvaluation {\n readonly execution: \"completed\" | \"errored\";\n readonly explicitlySkipped: boolean;\n readonly assertions: readonly SealedAssertionEvaluationEntry[];\n}\n/**\n * One immutable result feeds the Verdict/Score fold and the private durable\n * producer adapter. No RecordAttachment writer type crosses this boundary.\n */\nexport interface SealedAssertionsRuntime {\n readonly entries: readonly SealedAssertionEntry[];\n readonly evaluation: SealedAssertionEvaluation;\n}\n/** The runtime Verdict is independent of the durable Verdict attachment codec. */\nexport interface AssertionVerdict {\n readonly state: import(\"../shared/types.ts\").Verdict;\n}\nexport type AssertionScoreIncompleteReason = \"execution-errored\" | \"source-unavailable\" | \"evaluation-errored\" | \"not-applicable\";\n/** The runtime Score is independent of the durable Score attachment codec. */\nexport type AssertionScore = {\n readonly state: \"complete\";\n readonly earned: number;\n} | {\n readonly state: \"partial\";\n readonly earned: number;\n readonly reasons: readonly AssertionScoreIncompleteReason[];\n} | {\n readonly state: \"unavailable\";\n readonly reasons: readonly AssertionScoreIncompleteReason[];\n};\n/**\n * The attempt-owned frozen result is handed from Runner to the Evaluation\n * Record adapter. The adapter alone adds attachment schemas and writes.\n */\nexport interface SealedAttemptAssertions {\n readonly entries: readonly SealedAssertionEntry[];\n readonly evaluation: SealedAssertionEvaluation;\n readonly workspaceDiff?: AgentWorkspaceDiff;\n readonly verdict: AssertionVerdict;\n readonly score?: AssertionScore;\n}\nexport interface AssertionsRuntime<Kind extends AssertionEvaluationKind> {\n readonly evaluationKind: Kind;\n readonly t: AssertionsContext<Kind>;\n /** @internal Reject before an adapter reads or snapshots author material. */\n assertAuthoringOpen(): void;\n /** Attempt-owned synchronous admission close; sealing still happens once through `seal`. */\n closeAuthoring(reason: \"attempt-sealing\" | \"attempt-interrupted\"): void;\n registerBoolean<Refined>(definition: BooleanAssertionRegistration<Refined>): BooleanAssertionHandle<Kind, Refined>;\n registerMeasurement(definition: MeasurementAssertionRegistration): MeasurementAssertionHandle<Kind>;\n seal(options?: AssertionSealOptions): Effect.Effect<SealedAssertionsRuntime, AssertionSealError, never>;\n}\n"]}