@attest-ai/core 0.6.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +890 -127
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +158 -16
- package/dist/cjs/proto/index.cjs +117 -0
- package/dist/cjs/proto/index.cjs.map +1 -1
- package/dist/cjs/proto/index.d.cts +135 -1
- package/dist/esm/cli.d.ts +19 -4
- package/dist/esm/cli.js +478 -116
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/index.d.ts +158 -16
- package/dist/esm/index.js +870 -128
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/proto/index.d.ts +135 -1
- package/dist/esm/proto/index.js +103 -0
- package/dist/esm/proto/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -5,6 +5,16 @@ 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 OUTCOME_PASS: "pass";
|
|
15
|
+
declare const OUTCOME_FAIL: "fail";
|
|
16
|
+
declare const OUTCOME_SKIP: "skip";
|
|
17
|
+
type Outcome = typeof OUTCOME_PASS | typeof OUTCOME_FAIL | typeof OUTCOME_SKIP;
|
|
8
18
|
declare const TYPE_SCHEMA: "schema";
|
|
9
19
|
declare const TYPE_CONSTRAINT: "constraint";
|
|
10
20
|
declare const TYPE_TRACE: "trace";
|
|
@@ -125,6 +135,46 @@ interface Assertion {
|
|
|
125
135
|
readonly spec: Record<string, unknown>;
|
|
126
136
|
readonly request_id?: string;
|
|
127
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Audit trail for an LLM-judge evaluation. Mirrors
|
|
140
|
+
* engine/pkg/types/assertion.go::JudgeMetadata so report v2 payloads
|
|
141
|
+
* round-trip without losing the model / rubric / variance evidence
|
|
142
|
+
* reviewers need to triage a judge failure.
|
|
143
|
+
*/
|
|
144
|
+
interface JudgeMetadata {
|
|
145
|
+
readonly model?: string;
|
|
146
|
+
readonly rubric_name?: string;
|
|
147
|
+
readonly rubric_version?: string;
|
|
148
|
+
readonly prompt_hash?: string;
|
|
149
|
+
readonly sample_scores?: readonly number[];
|
|
150
|
+
readonly score_mean?: number;
|
|
151
|
+
readonly score_stddev?: number;
|
|
152
|
+
readonly high_variance?: boolean;
|
|
153
|
+
readonly bias_probes?: readonly BiasProbe[];
|
|
154
|
+
readonly calibration?: JudgeAgreement;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* One judge-bias probe result. Score is the score the judge produced on
|
|
158
|
+
* the mutated input; delta is `score - baseline`. A well-calibrated
|
|
159
|
+
* judge has |delta| close to zero. Mirrors
|
|
160
|
+
* engine/pkg/types/assertion.go::BiasProbe.
|
|
161
|
+
*/
|
|
162
|
+
interface BiasProbe {
|
|
163
|
+
readonly name: string;
|
|
164
|
+
readonly score: number;
|
|
165
|
+
readonly delta: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Calibration agreement summary keyed by
|
|
169
|
+
* (rubric_name, rubric_version, prompt_hash). Mirrors
|
|
170
|
+
* engine/pkg/types/assertion.go::JudgeAgreement.
|
|
171
|
+
*/
|
|
172
|
+
interface JudgeAgreement {
|
|
173
|
+
readonly label_count: number;
|
|
174
|
+
readonly agreement: number;
|
|
175
|
+
readonly cohen_kappa: number;
|
|
176
|
+
readonly roc_auc?: number;
|
|
177
|
+
}
|
|
128
178
|
interface AssertionResult {
|
|
129
179
|
readonly assertion_id: string;
|
|
130
180
|
readonly status: string;
|
|
@@ -133,7 +183,44 @@ interface AssertionResult {
|
|
|
133
183
|
readonly cost?: number;
|
|
134
184
|
readonly duration_ms?: number;
|
|
135
185
|
readonly request_id?: string;
|
|
186
|
+
/** Set only when status is "not_evaluated" (REASON_* constants). */
|
|
187
|
+
readonly reason?: string;
|
|
188
|
+
readonly threshold_source?: string;
|
|
189
|
+
readonly layer?: number;
|
|
190
|
+
readonly type?: string;
|
|
191
|
+
readonly trace_node_path?: string;
|
|
192
|
+
readonly expected?: string;
|
|
193
|
+
readonly actual?: string;
|
|
194
|
+
readonly suggested_action?: string;
|
|
195
|
+
readonly judge_metadata?: JudgeMetadata;
|
|
196
|
+
/**
|
|
197
|
+
* Heuristic root-cause label set by the engine
|
|
198
|
+
* (broken_code / flaky_judge / bad_rubric / missing_trace_data /
|
|
199
|
+
* stochastic_variance). Empty/undefined for passes and any result the
|
|
200
|
+
* engine declined to label. Mirrors
|
|
201
|
+
* engine/pkg/types/failure_class.go.
|
|
202
|
+
*/
|
|
203
|
+
readonly failure_class?: string;
|
|
136
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* FailureClass values mirror engine/pkg/types/failure_class.go. Use
|
|
207
|
+
* these constants when matching on AssertionResult.failure_class so a
|
|
208
|
+
* typo in either codebase fails fast.
|
|
209
|
+
*/
|
|
210
|
+
declare const FailureClass: {
|
|
211
|
+
readonly BrokenCode: "broken_code";
|
|
212
|
+
readonly FlakyJudge: "flaky_judge";
|
|
213
|
+
readonly BadRubric: "bad_rubric";
|
|
214
|
+
readonly MissingTraceData: "missing_trace_data";
|
|
215
|
+
readonly StochasticVariance: "stochastic_variance";
|
|
216
|
+
};
|
|
217
|
+
type FailureClass = (typeof FailureClass)[keyof typeof FailureClass];
|
|
218
|
+
/**
|
|
219
|
+
* Map an assertion-type string to its pipeline layer (1–8). Returns 0
|
|
220
|
+
* when the type is unknown so callers can route uncategorised results
|
|
221
|
+
* into their own bucket.
|
|
222
|
+
*/
|
|
223
|
+
declare function layerForType(assertionType: string | undefined): number;
|
|
137
224
|
interface ErrorData {
|
|
138
225
|
readonly error_type: string;
|
|
139
226
|
readonly retryable: boolean;
|
|
@@ -182,6 +269,13 @@ interface EvaluateBatchResult {
|
|
|
182
269
|
readonly results: readonly AssertionResult[];
|
|
183
270
|
readonly total_cost?: number;
|
|
184
271
|
readonly total_duration_ms?: number;
|
|
272
|
+
/**
|
|
273
|
+
* True when this result was produced by an SDK simulation shim rather
|
|
274
|
+
* than a real engine evaluation. Engine-produced results always carry
|
|
275
|
+
* simulated=false. CI gates can fail builds that accidentally evaluate
|
|
276
|
+
* against the simulator by checking this flag.
|
|
277
|
+
*/
|
|
278
|
+
readonly simulated?: boolean;
|
|
185
279
|
}
|
|
186
280
|
interface ShutdownResult {
|
|
187
281
|
readonly sessions_completed: number;
|
|
@@ -235,6 +329,36 @@ interface GenerateUserMessageResult {
|
|
|
235
329
|
readonly message: string;
|
|
236
330
|
}
|
|
237
331
|
|
|
332
|
+
/**
|
|
333
|
+
* Protocol diagnostic types for client-side observability.
|
|
334
|
+
*
|
|
335
|
+
* The reader loop emits diagnostics whenever it cannot route a response
|
|
336
|
+
* line: malformed JSON, missing id, unknown id, or non-routable protocol
|
|
337
|
+
* errors. Diagnostics are buffered in a bounded ring (32 entries) and
|
|
338
|
+
* trigger a desync error when the rate exceeds the configured threshold.
|
|
339
|
+
*/
|
|
340
|
+
type ProtocolDiagnosticKind = "malformed_json" | "non_object_response" | "invalid_jsonrpc_version" | "missing_id" | "unknown_id" | "non_routable_error";
|
|
341
|
+
interface ProtocolDiagnostic {
|
|
342
|
+
readonly kind: ProtocolDiagnosticKind;
|
|
343
|
+
readonly message: string;
|
|
344
|
+
readonly rawLine: string;
|
|
345
|
+
readonly timestampMs: number;
|
|
346
|
+
}
|
|
347
|
+
interface ProtocolLogger {
|
|
348
|
+
warn(message: string, ...args: unknown[]): void;
|
|
349
|
+
error(message: string, ...args: unknown[]): void;
|
|
350
|
+
}
|
|
351
|
+
declare class ProtocolDiagnosticBuffer {
|
|
352
|
+
private readonly capacity;
|
|
353
|
+
private readonly entries;
|
|
354
|
+
constructor(capacity?: number);
|
|
355
|
+
push(diagnostic: ProtocolDiagnostic): void;
|
|
356
|
+
snapshot(): readonly ProtocolDiagnostic[];
|
|
357
|
+
countWithin(windowMs: number, nowMs: number): number;
|
|
358
|
+
clear(): void;
|
|
359
|
+
}
|
|
360
|
+
declare function previewLine(line: string): string;
|
|
361
|
+
|
|
238
362
|
declare class ProtocolError extends Error {
|
|
239
363
|
readonly code: number;
|
|
240
364
|
readonly errorMessage: string;
|
|
@@ -246,6 +370,16 @@ declare class EngineTimeoutError extends Error {
|
|
|
246
370
|
readonly timeoutMs: number;
|
|
247
371
|
constructor(method: string, timeoutMs: number);
|
|
248
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Raised when the reader loop detects that engine output has lost
|
|
375
|
+
* framing or contains repeated unparseable lines. All in-flight requests
|
|
376
|
+
* are rejected with this error so callers see a visible failure rather
|
|
377
|
+
* than a hung promise.
|
|
378
|
+
*/
|
|
379
|
+
declare class ProtocolDesyncError extends Error {
|
|
380
|
+
readonly diagnostics: readonly ProtocolDiagnostic[];
|
|
381
|
+
constructor(message: string, diagnostics: readonly ProtocolDiagnostic[]);
|
|
382
|
+
}
|
|
249
383
|
|
|
250
384
|
/**
|
|
251
385
|
* Encode a JSON-RPC 2.0 request as an NDJSON line.
|
|
@@ -266,4 +400,4 @@ declare function extractResult(response: RPCResponse): unknown;
|
|
|
266
400
|
*/
|
|
267
401
|
declare function extractId(response: RPCResponse): number;
|
|
268
402
|
|
|
269
|
-
export { type AgentId, type Assertion, type AssertionId, type AssertionResult, type AssertionSpec, 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 LlmJudgeSpec, type PluginSpec, ProtocolError, 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, traceId };
|
|
403
|
+
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, FailureClass, type GenerateUserMessageParams, type GenerateUserMessageResult, type InitializeParams, type InitializeResult, type JudgeAgreement, type JudgeMetadata, type LlmJudgeSpec, OUTCOME_FAIL, OUTCOME_PASS, OUTCOME_SKIP, type Outcome, type PluginSpec, ProtocolDesyncError, type ProtocolDiagnostic, ProtocolDiagnosticBuffer, type ProtocolDiagnosticKind, ProtocolError, type ProtocolLogger, type QueryDriftParams, type QueryDriftResult, 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 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 };
|
package/dist/esm/cli.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The `attest` command line (`npx attest`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
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
|
-
|
|
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 };
|