@attest-ai/core 0.9.0 → 1.0.0-rc.2

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.
@@ -5,6 +5,18 @@ declare const STEP_AGENT_CALL: "agent_call";
5
5
  declare const STATUS_PASS: "pass";
6
6
  declare const STATUS_SOFT_FAIL: "soft_fail";
7
7
  declare const STATUS_HARD_FAIL: "hard_fail";
8
+ declare const STATUS_NOT_EVALUATED: "not_evaluated";
9
+ declare const REASON_PROVIDER_UNAVAILABLE: "provider_unavailable";
10
+ declare const REASON_PROVIDER_NOT_CONFIGURED: "provider_not_configured";
11
+ declare const REASON_SIMULATION: "simulation";
12
+ declare const REASON_MISSING_EVIDENCE: "missing_evidence";
13
+ declare const REASON_SHORT_CIRCUITED: "short_circuited";
14
+ declare const REASON_BUDGET_EXHAUSTED: "budget_exhausted";
15
+ declare const REASON_JUDGE_ABSTAINED: "judge_abstained";
16
+ declare const OUTCOME_PASS: "pass";
17
+ declare const OUTCOME_FAIL: "fail";
18
+ declare const OUTCOME_SKIP: "skip";
19
+ type Outcome = typeof OUTCOME_PASS | typeof OUTCOME_FAIL | typeof OUTCOME_SKIP;
8
20
  declare const TYPE_SCHEMA: "schema";
9
21
  declare const TYPE_CONSTRAINT: "constraint";
10
22
  declare const TYPE_TRACE: "trace";
@@ -97,6 +109,30 @@ interface TraceMetadata {
97
109
  readonly model?: string;
98
110
  readonly timestamp?: string;
99
111
  }
112
+ /** Trace v2: a step whose span ended in error. */
113
+ interface StepError {
114
+ readonly type: string;
115
+ readonly message?: string;
116
+ }
117
+ /** Trace v2: a recorded model request/response pair. */
118
+ interface Exchange {
119
+ readonly request: Record<string, unknown>;
120
+ readonly response: Record<string, unknown>;
121
+ }
122
+ /** Trace v2: one conversation turn and the indices of its steps. */
123
+ interface Turn {
124
+ readonly index: number;
125
+ readonly span_id?: string;
126
+ readonly input?: unknown;
127
+ readonly output?: unknown;
128
+ readonly step_indices: readonly number[];
129
+ }
130
+ /** Trace v2: control passing from one agent to another at an agent_call step. */
131
+ interface Handoff {
132
+ readonly from_agent: string;
133
+ readonly to_agent: string;
134
+ readonly step_index: number;
135
+ }
100
136
  interface Step {
101
137
  readonly type: string;
102
138
  readonly name: string;
@@ -108,6 +144,12 @@ interface Step {
108
144
  readonly ended_at_ms?: number;
109
145
  readonly agent_id?: string;
110
146
  readonly agent_role?: string;
147
+ readonly span_id?: string;
148
+ readonly parent_span_id?: string;
149
+ readonly tool_call_id?: string;
150
+ readonly retry_of?: number;
151
+ readonly error?: StepError;
152
+ readonly exchange?: Exchange;
111
153
  }
112
154
  interface Trace {
113
155
  readonly trace_id: string;
@@ -118,6 +160,9 @@ interface Trace {
118
160
  readonly steps: readonly Step[];
119
161
  readonly metadata?: TraceMetadata;
120
162
  readonly parent_trace_id?: string;
163
+ readonly conversation_id?: string;
164
+ readonly turns?: readonly Turn[];
165
+ readonly handoffs?: readonly Handoff[];
121
166
  }
122
167
  interface Assertion {
123
168
  readonly assertion_id: string;
@@ -132,6 +177,7 @@ interface Assertion {
132
177
  * reviewers need to triage a judge failure.
133
178
  */
134
179
  interface JudgeMetadata {
180
+ readonly provider?: string;
135
181
  readonly model?: string;
136
182
  readonly rubric_name?: string;
137
183
  readonly rubric_version?: string;
@@ -173,6 +219,8 @@ interface AssertionResult {
173
219
  readonly cost?: number;
174
220
  readonly duration_ms?: number;
175
221
  readonly request_id?: string;
222
+ /** Set only when status is "not_evaluated" (REASON_* constants). */
223
+ readonly reason?: string;
176
224
  readonly threshold_source?: string;
177
225
  readonly layer?: number;
178
226
  readonly type?: string;
@@ -181,7 +229,28 @@ interface AssertionResult {
181
229
  readonly actual?: string;
182
230
  readonly suggested_action?: string;
183
231
  readonly judge_metadata?: JudgeMetadata;
232
+ /**
233
+ * Heuristic root-cause label set by the engine
234
+ * (broken_code / flaky_judge / bad_rubric / missing_trace_data /
235
+ * stochastic_variance). Empty/undefined for passes and any result the
236
+ * engine declined to label. Mirrors
237
+ * engine/pkg/types/failure_class.go.
238
+ */
239
+ readonly failure_class?: string;
184
240
  }
241
+ /**
242
+ * FailureClass values mirror engine/pkg/types/failure_class.go. Use
243
+ * these constants when matching on AssertionResult.failure_class so a
244
+ * typo in either codebase fails fast.
245
+ */
246
+ declare const FailureClass: {
247
+ readonly BrokenCode: "broken_code";
248
+ readonly FlakyJudge: "flaky_judge";
249
+ readonly BadRubric: "bad_rubric";
250
+ readonly MissingTraceData: "missing_trace_data";
251
+ readonly StochasticVariance: "stochastic_variance";
252
+ };
253
+ type FailureClass = (typeof FailureClass)[keyof typeof FailureClass];
185
254
  /**
186
255
  * Map an assertion-type string to its pipeline layer (1–8). Returns 0
187
256
  * when the type is unknown so callers can route uncategorised results
@@ -228,14 +297,44 @@ interface InitializeResult {
228
297
  readonly max_trace_size_bytes?: number;
229
298
  readonly max_steps_per_trace?: number;
230
299
  }
300
+ /**
301
+ * Limits for one evaluate_batch call on top of the session budget. A judge or
302
+ * embedding call that cannot reserve against them is not sent and its
303
+ * assertion is not_evaluated with reason "budget_exhausted".
304
+ */
305
+ interface BatchBudget {
306
+ readonly max_judge_calls?: number;
307
+ readonly max_cost_usd?: number;
308
+ }
231
309
  interface EvaluateBatchParams {
232
310
  readonly trace: Trace;
233
311
  readonly assertions: readonly Assertion[];
312
+ /** Omitted when no per-batch budget applies. */
313
+ readonly budget?: BatchBudget;
314
+ }
315
+ /**
316
+ * Attest-initiated model usage (embeddings, judges, judge repeats, bias
317
+ * probes, simulated-user messages). Agent calls not routed through attest
318
+ * are not counted.
319
+ */
320
+ interface Usage {
321
+ readonly model_calls: number;
322
+ /** Judge-provider requests, the part of model_calls that max_judge_calls limits. */
323
+ readonly judge_calls: number;
324
+ readonly input_tokens: number;
325
+ readonly output_tokens: number;
326
+ readonly cached_tokens: number;
327
+ readonly cost_usd: number;
328
+ readonly retry_cost_usd: number;
329
+ readonly unpriced_calls: number;
330
+ readonly budget_refused: number;
234
331
  }
235
332
  interface EvaluateBatchResult {
236
333
  readonly results: readonly AssertionResult[];
237
334
  readonly total_cost?: number;
238
335
  readonly total_duration_ms?: number;
336
+ /** Always sent by the engine; validated by AttestClient.evaluateBatch. */
337
+ readonly usage: Usage;
239
338
  /**
240
339
  * True when this result was produced by an SDK simulation shim rather
241
340
  * than a real engine evaluation. Engine-produced results always carry
@@ -347,6 +446,13 @@ declare class ProtocolDesyncError extends Error {
347
446
  readonly diagnostics: readonly ProtocolDiagnostic[];
348
447
  constructor(message: string, diagnostics: readonly ProtocolDiagnostic[]);
349
448
  }
449
+ /**
450
+ * The engine rejected an OTLP/JSON export (`attest-engine trace convert`). The message is
451
+ * the engine's error, which names the offending span or field.
452
+ */
453
+ declare class OTLPConversionError extends Error {
454
+ constructor(message: string);
455
+ }
350
456
 
351
457
  /**
352
458
  * Encode a JSON-RPC 2.0 request as an NDJSON line.
@@ -367,4 +473,4 @@ declare function extractResult(response: RPCResponse): unknown;
367
473
  */
368
474
  declare function extractId(response: RPCResponse): number;
369
475
 
370
- export { type AgentId, type Assertion, type AssertionId, type AssertionResult, type AssertionSpec, type BiasProbe, type ConstraintSpec, type ContentSpec, type ConversationMessage, type DriftReport, ERR_ASSERTION_ERROR, ERR_ENGINE_ERROR, ERR_INVALID_TRACE, ERR_PROVIDER_ERROR, ERR_SESSION_ERROR, ERR_TIMEOUT, type EmbeddingSpec, EngineTimeoutError, type ErrorData, type EvaluateBatchParams, type EvaluateBatchResult, type GenerateUserMessageParams, type GenerateUserMessageResult, type InitializeParams, type InitializeResult, type JudgeAgreement, type JudgeMetadata, type LlmJudgeSpec, type PluginSpec, ProtocolDesyncError, type ProtocolDiagnostic, ProtocolDiagnosticBuffer, type ProtocolDiagnosticKind, ProtocolError, type ProtocolLogger, type QueryDriftParams, type QueryDriftResult, type RPCError, type RPCRequest, type RPCResponse, STATUS_HARD_FAIL, STATUS_PASS, STATUS_SOFT_FAIL, STEP_AGENT_CALL, STEP_LLM_CALL, STEP_RETRIEVAL, STEP_TOOL_CALL, type SchemaSpec, type ShutdownResult, type SimulateFaultConfig, type SimulatePersona, type Step, type SubmitPluginResultParams, TYPE_CONSTRAINT, TYPE_CONTENT, TYPE_EMBEDDING, TYPE_LLM_JUDGE, TYPE_PLUGIN, TYPE_SCHEMA, TYPE_TRACE, TYPE_TRACE_TREE, type Trace, type TraceId, type TraceMetadata, type TraceSpec, type TraceTreeSpec, agentId, assertionId, decodeResponse, encodeRequest, extractId, extractResult, layerForType, previewLine, traceId };
476
+ export { type AgentId, type Assertion, type AssertionId, type AssertionResult, type AssertionSpec, type BatchBudget, type BiasProbe, type ConstraintSpec, type ContentSpec, type ConversationMessage, type DriftReport, ERR_ASSERTION_ERROR, ERR_ENGINE_ERROR, ERR_INVALID_TRACE, ERR_PROVIDER_ERROR, ERR_SESSION_ERROR, ERR_TIMEOUT, type EmbeddingSpec, EngineTimeoutError, type ErrorData, type EvaluateBatchParams, type EvaluateBatchResult, type Exchange, FailureClass, type GenerateUserMessageParams, type GenerateUserMessageResult, type Handoff, type InitializeParams, type InitializeResult, type JudgeAgreement, type JudgeMetadata, type LlmJudgeSpec, OTLPConversionError, OUTCOME_FAIL, OUTCOME_PASS, OUTCOME_SKIP, type Outcome, type PluginSpec, ProtocolDesyncError, type ProtocolDiagnostic, ProtocolDiagnosticBuffer, type ProtocolDiagnosticKind, ProtocolError, type ProtocolLogger, type QueryDriftParams, type QueryDriftResult, REASON_BUDGET_EXHAUSTED, REASON_JUDGE_ABSTAINED, REASON_MISSING_EVIDENCE, REASON_PROVIDER_NOT_CONFIGURED, REASON_PROVIDER_UNAVAILABLE, REASON_SHORT_CIRCUITED, REASON_SIMULATION, type RPCError, type RPCRequest, type RPCResponse, STATUS_HARD_FAIL, STATUS_NOT_EVALUATED, STATUS_PASS, STATUS_SOFT_FAIL, STEP_AGENT_CALL, STEP_LLM_CALL, STEP_RETRIEVAL, STEP_TOOL_CALL, type SchemaSpec, type ShutdownResult, type SimulateFaultConfig, type SimulatePersona, type Step, type StepError, type SubmitPluginResultParams, TYPE_CONSTRAINT, TYPE_CONTENT, TYPE_EMBEDDING, TYPE_LLM_JUDGE, TYPE_PLUGIN, TYPE_SCHEMA, TYPE_TRACE, TYPE_TRACE_TREE, type Trace, type TraceId, type TraceMetadata, type TraceSpec, type TraceTreeSpec, type Turn, type Usage, agentId, assertionId, decodeResponse, encodeRequest, extractId, extractResult, layerForType, previewLine, traceId };
package/dist/esm/cli.d.ts CHANGED
@@ -1,9 +1,24 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * CLI entry point for Attest: npx attest or attest (after global install).
3
+ * The `attest` command line (`npx attest`).
4
4
  *
5
- * Ported from Python sdks/python/src/attest/__main__.py
5
+ * `attest init` runs in the SDK. Every other command (`doctor`, `baseline`, `policy`,
6
+ * `cache`, `calibrate`, `version` and any command a later engine adds) runs in
7
+ * `attest-engine`: the CLI resolves a version-checked engine with `resolveEngine`, checks
8
+ * that the engine's `help` lists the command, and forwards the arguments, stdio and exit
9
+ * code unchanged. A missing, mismatched or too-old engine exits 1 before anything runs, so
10
+ * a gate such as `attest policy evaluate` never exits 0 without evaluating.
6
11
  */
7
- declare function main(argv?: string[]): void;
12
+ /**
13
+ * `{command: summary}` from `<engine> help`, or null if it lists none.
14
+ *
15
+ * stdin is closed and the probe times out after 10 s, so an engine that predates the
16
+ * command registry (and starts the JSON-RPC server for `help`) cannot hang the CLI.
17
+ */
18
+ declare function engineCommands(engine: string, timeoutMs?: number): Map<string, string> | null;
19
+ /** Map a child's exit to a shell exit status (signal N → 128 + N). */
20
+ declare function exitStatus(status: number | null, signal: NodeJS.Signals | null): number;
21
+ /** Dispatch `attest` arguments and resolve to the process exit code. */
22
+ declare function main(argv?: string[]): Promise<number>;
8
23
 
9
- export { main };
24
+ export { engineCommands, exitStatus, main };