@attest-ai/core 0.4.2 → 0.6.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 (116) hide show
  1. package/dist/cjs/index.cjs +2595 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.cts +1111 -0
  4. package/dist/cjs/proto/index.cjs +208 -0
  5. package/dist/cjs/proto/index.cjs.map +1 -0
  6. package/dist/cjs/proto/index.d.cts +269 -0
  7. package/dist/esm/cli.d.ts +9 -0
  8. package/dist/esm/cli.js +154 -0
  9. package/dist/esm/cli.js.map +1 -0
  10. package/dist/esm/index.d.ts +1111 -0
  11. package/dist/esm/index.js +2490 -0
  12. package/dist/esm/index.js.map +1 -0
  13. package/dist/esm/proto/index.d.ts +269 -0
  14. package/dist/esm/proto/index.js +152 -0
  15. package/dist/esm/proto/index.js.map +1 -0
  16. package/package.json +37 -11
  17. package/dist/adapters/anthropic.d.ts +0 -31
  18. package/dist/adapters/anthropic.d.ts.map +0 -1
  19. package/dist/adapters/anthropic.js +0 -42
  20. package/dist/adapters/anthropic.js.map +0 -1
  21. package/dist/adapters/gemini.d.ts +0 -30
  22. package/dist/adapters/gemini.d.ts.map +0 -1
  23. package/dist/adapters/gemini.js +0 -41
  24. package/dist/adapters/gemini.js.map +0 -1
  25. package/dist/adapters/index.d.ts +0 -11
  26. package/dist/adapters/index.d.ts.map +0 -1
  27. package/dist/adapters/index.js +0 -7
  28. package/dist/adapters/index.js.map +0 -1
  29. package/dist/adapters/manual.d.ts +0 -9
  30. package/dist/adapters/manual.d.ts.map +0 -1
  31. package/dist/adapters/manual.js +0 -16
  32. package/dist/adapters/manual.js.map +0 -1
  33. package/dist/adapters/ollama.d.ts +0 -19
  34. package/dist/adapters/ollama.d.ts.map +0 -1
  35. package/dist/adapters/ollama.js +0 -30
  36. package/dist/adapters/ollama.js.map +0 -1
  37. package/dist/adapters/openai.d.ts +0 -34
  38. package/dist/adapters/openai.d.ts.map +0 -1
  39. package/dist/adapters/openai.js +0 -42
  40. package/dist/adapters/openai.js.map +0 -1
  41. package/dist/adapters/otel.d.ts +0 -25
  42. package/dist/adapters/otel.d.ts.map +0 -1
  43. package/dist/adapters/otel.js +0 -133
  44. package/dist/adapters/otel.js.map +0 -1
  45. package/dist/agent.d.ts +0 -14
  46. package/dist/agent.d.ts.map +0 -1
  47. package/dist/agent.js +0 -54
  48. package/dist/agent.js.map +0 -1
  49. package/dist/client.d.ts +0 -19
  50. package/dist/client.d.ts.map +0 -1
  51. package/dist/client.js +0 -132
  52. package/dist/client.js.map +0 -1
  53. package/dist/context.d.ts +0 -4
  54. package/dist/context.d.ts.map +0 -1
  55. package/dist/context.js +0 -3
  56. package/dist/context.js.map +0 -1
  57. package/dist/delegate.d.ts +0 -3
  58. package/dist/delegate.d.ts.map +0 -1
  59. package/dist/delegate.js +0 -30
  60. package/dist/delegate.js.map +0 -1
  61. package/dist/engine-downloader.d.ts +0 -7
  62. package/dist/engine-downloader.d.ts.map +0 -1
  63. package/dist/engine-downloader.js +0 -136
  64. package/dist/engine-downloader.js.map +0 -1
  65. package/dist/engine-manager.d.ts +0 -26
  66. package/dist/engine-manager.d.ts.map +0 -1
  67. package/dist/engine-manager.js +0 -172
  68. package/dist/engine-manager.js.map +0 -1
  69. package/dist/expect.d.ts +0 -133
  70. package/dist/expect.d.ts.map +0 -1
  71. package/dist/expect.js +0 -330
  72. package/dist/expect.js.map +0 -1
  73. package/dist/index.d.ts +0 -15
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/index.js +0 -14
  76. package/dist/index.js.map +0 -1
  77. package/dist/proto/codec.d.ts +0 -20
  78. package/dist/proto/codec.d.ts.map +0 -1
  79. package/dist/proto/codec.js +0 -71
  80. package/dist/proto/codec.js.map +0 -1
  81. package/dist/proto/constants.d.ts +0 -21
  82. package/dist/proto/constants.d.ts.map +0 -1
  83. package/dist/proto/constants.js +0 -25
  84. package/dist/proto/constants.js.map +0 -1
  85. package/dist/proto/errors.d.ts +0 -8
  86. package/dist/proto/errors.d.ts.map +0 -1
  87. package/dist/proto/errors.js +0 -13
  88. package/dist/proto/errors.js.map +0 -1
  89. package/dist/proto/index.d.ts +0 -5
  90. package/dist/proto/index.d.ts.map +0 -1
  91. package/dist/proto/index.js +0 -5
  92. package/dist/proto/index.js.map +0 -1
  93. package/dist/proto/types.d.ts +0 -104
  94. package/dist/proto/types.d.ts.map +0 -1
  95. package/dist/proto/types.js +0 -2
  96. package/dist/proto/types.js.map +0 -1
  97. package/dist/result.d.ts +0 -15
  98. package/dist/result.d.ts.map +0 -1
  99. package/dist/result.js +0 -32
  100. package/dist/result.js.map +0 -1
  101. package/dist/tier.d.ts +0 -5
  102. package/dist/tier.d.ts.map +0 -1
  103. package/dist/tier.js +0 -10
  104. package/dist/tier.js.map +0 -1
  105. package/dist/trace-tree.d.ts +0 -20
  106. package/dist/trace-tree.d.ts.map +0 -1
  107. package/dist/trace-tree.js +0 -92
  108. package/dist/trace-tree.js.map +0 -1
  109. package/dist/trace.d.ts +0 -40
  110. package/dist/trace.d.ts.map +0 -1
  111. package/dist/trace.js +0 -85
  112. package/dist/trace.js.map +0 -1
  113. package/dist/version.d.ts +0 -3
  114. package/dist/version.d.ts.map +0 -1
  115. package/dist/version.js +0 -3
  116. package/dist/version.js.map +0 -1
@@ -0,0 +1,1111 @@
1
+ import { InitializeResult, Trace, Assertion, EvaluateBatchResult, DriftReport, SimulatePersona, ConversationMessage, SimulateFaultConfig, Step, AssertionResult } from './proto/index.cjs';
2
+ export { AgentId, AssertionId, AssertionSpec, ConstraintSpec, ContentSpec, ERR_ASSERTION_ERROR, ERR_ENGINE_ERROR, ERR_INVALID_TRACE, ERR_PROVIDER_ERROR, ERR_SESSION_ERROR, ERR_TIMEOUT, EmbeddingSpec, EngineTimeoutError, ErrorData, EvaluateBatchParams, GenerateUserMessageParams, GenerateUserMessageResult, InitializeParams, LlmJudgeSpec, PluginSpec, ProtocolError, QueryDriftParams, QueryDriftResult, RPCError, RPCRequest, RPCResponse, STATUS_HARD_FAIL, STATUS_PASS, STATUS_SOFT_FAIL, STEP_AGENT_CALL, STEP_LLM_CALL, STEP_RETRIEVAL, STEP_TOOL_CALL, SchemaSpec, ShutdownResult, SubmitPluginResultParams, TYPE_CONSTRAINT, TYPE_CONTENT, TYPE_EMBEDDING, TYPE_LLM_JUDGE, TYPE_PLUGIN, TYPE_SCHEMA, TYPE_TRACE, TYPE_TRACE_TREE, TraceId, TraceMetadata, TraceSpec, TraceTreeSpec, agentId, assertionId, decodeResponse, encodeRequest, extractId, extractResult, traceId } from './proto/index.cjs';
3
+ import { ChildProcess } from 'node:child_process';
4
+ import { Interface } from 'node:readline';
5
+ import { AsyncLocalStorage } from 'node:async_hooks';
6
+ import { EventEmitter } from 'node:events';
7
+
8
+ declare const VERSION = "0.6.0";
9
+ declare const ENGINE_VERSION = "0.6.0";
10
+
11
+ declare class EngineManager {
12
+ private enginePath;
13
+ private readonly logLevel;
14
+ private process;
15
+ private reader;
16
+ private initialized;
17
+ private requestId;
18
+ private initResult;
19
+ constructor(options?: {
20
+ enginePath?: string;
21
+ logLevel?: string;
22
+ });
23
+ start(): Promise<InitializeResult>;
24
+ stop(): Promise<void>;
25
+ sendRequest(method: string, params: Record<string, unknown>): Promise<unknown>;
26
+ private sendRequestInternal;
27
+ get isRunning(): boolean;
28
+ /** Expose process for AttestClient reader loop access */
29
+ get childProcess(): ChildProcess | null;
30
+ /** Expose readline interface for AttestClient reader loop */
31
+ get readlineInterface(): Interface | null;
32
+ }
33
+
34
+ declare class AttestClient {
35
+ private readonly engine;
36
+ private requestId;
37
+ private readonly pending;
38
+ private writeChain;
39
+ private readerActive;
40
+ private lineHandler;
41
+ constructor(engine: EngineManager);
42
+ startReader(): void;
43
+ stopReader(): void;
44
+ private handleLine;
45
+ private failAll;
46
+ sendRequest(method: string, params: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
47
+ evaluateBatch(trace: Trace, assertions: readonly Assertion[], options?: {
48
+ timeout?: number;
49
+ }): Promise<EvaluateBatchResult>;
50
+ submitPluginResult(traceId: string, pluginName: string, assertionId: string, status: string, score: number, explanation: string, options?: {
51
+ timeout?: number;
52
+ }): Promise<boolean>;
53
+ queryDrift(assertionId: string, windowSize?: number, options?: {
54
+ timeout?: number;
55
+ }): Promise<DriftReport>;
56
+ generateUserMessage(persona: SimulatePersona, conversationHistory: readonly ConversationMessage[], faultConfig?: SimulateFaultConfig, options?: {
57
+ timeout?: number;
58
+ }): Promise<string>;
59
+ }
60
+
61
+ declare class TraceBuilder {
62
+ private traceId;
63
+ private agentId;
64
+ private input;
65
+ private readonly steps;
66
+ private output;
67
+ private metadata;
68
+ private parentTraceId;
69
+ constructor(agentId?: string);
70
+ setTraceId(traceId: string): this;
71
+ setInput(input: Record<string, unknown>): this;
72
+ addLlmCall(name: string, options?: {
73
+ args?: Record<string, unknown>;
74
+ result?: Record<string, unknown>;
75
+ metadata?: Record<string, unknown>;
76
+ }): this;
77
+ addToolCall(name: string, options?: {
78
+ args?: Record<string, unknown>;
79
+ result?: Record<string, unknown>;
80
+ metadata?: Record<string, unknown>;
81
+ }): this;
82
+ addRetrieval(name: string, options?: {
83
+ args?: Record<string, unknown>;
84
+ result?: Record<string, unknown>;
85
+ metadata?: Record<string, unknown>;
86
+ }): this;
87
+ addStep(step: Step): this;
88
+ setOutput(output: Record<string, unknown>): this;
89
+ setMetadata(metadata: {
90
+ total_tokens?: number;
91
+ cost_usd?: number;
92
+ latency_ms?: number;
93
+ model?: string;
94
+ timestamp?: string;
95
+ }): this;
96
+ getTraceId(): string;
97
+ setParentTraceId(parentId: string): this;
98
+ build(): Trace;
99
+ }
100
+
101
+ declare class AgentResult {
102
+ readonly trace: Trace;
103
+ readonly assertionResults: readonly AssertionResult[];
104
+ readonly totalCost: number;
105
+ readonly totalDurationMs: number;
106
+ constructor(trace: Trace, assertionResults?: readonly AssertionResult[], totalCost?: number, totalDurationMs?: number);
107
+ get passed(): boolean;
108
+ get failedAssertions(): readonly AssertionResult[];
109
+ get hardFailures(): readonly AssertionResult[];
110
+ get softFailures(): readonly AssertionResult[];
111
+ get passCount(): number;
112
+ get failCount(): number;
113
+ }
114
+
115
+ declare class TraceTree {
116
+ readonly root: Trace;
117
+ constructor(root: Trace);
118
+ get agents(): string[];
119
+ private collectAgents;
120
+ findAgent(agentId: string): Trace | undefined;
121
+ private findAgentIn;
122
+ get depth(): number;
123
+ private computeDepth;
124
+ flatten(): Trace[];
125
+ private flattenInto;
126
+ get delegations(): [string, string][];
127
+ private collectDelegations;
128
+ allToolCalls(): Step[];
129
+ get aggregateTokens(): number;
130
+ get aggregateCost(): number;
131
+ get aggregateLatency(): number;
132
+ }
133
+
134
+ declare class ExpectChain {
135
+ private readonly _result;
136
+ private readonly _assertions;
137
+ constructor(result: AgentResult);
138
+ get assertions(): Assertion[];
139
+ get trace(): Trace;
140
+ private add;
141
+ /**
142
+ * Assert that `output.structured` conforms to the given JSON Schema.
143
+ *
144
+ * @param schema - A JSON Schema object to validate against.
145
+ * @returns The chain for fluent composition.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * expect(result).outputMatchesSchema({ type: "object", required: ["answer"] });
150
+ * ```
151
+ */
152
+ outputMatchesSchema(schema: Record<string, unknown>): this;
153
+ /**
154
+ * Assert that a specific output field conforms to the given JSON Schema.
155
+ *
156
+ * @param field - Dot-delimited path under `output` (e.g. `"structured.items"`).
157
+ * @param schema - A JSON Schema object to validate against.
158
+ * @returns The chain for fluent composition.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * expect(result).outputFieldMatchesSchema("structured.items", { type: "array" });
163
+ * ```
164
+ */
165
+ outputFieldMatchesSchema(field: string, schema: Record<string, unknown>): this;
166
+ /**
167
+ * Assert that a named tool's arguments conform to the given JSON Schema.
168
+ *
169
+ * @param toolName - The tool name to match in `steps`.
170
+ * @param schema - A JSON Schema object to validate against.
171
+ * @returns The chain for fluent composition.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * expect(result).toolArgsMatchSchema("search", { type: "object", required: ["query"] });
176
+ * ```
177
+ */
178
+ toolArgsMatchSchema(toolName: string, schema: Record<string, unknown>): this;
179
+ /**
180
+ * Assert that a named tool's result conforms to the given JSON Schema.
181
+ *
182
+ * @param toolName - The tool name to match in `steps`.
183
+ * @param schema - A JSON Schema object to validate against.
184
+ * @returns The chain for fluent composition.
185
+ *
186
+ * @example
187
+ * ```ts
188
+ * expect(result).toolResultMatchesSchema("search", { type: "object" });
189
+ * ```
190
+ */
191
+ toolResultMatchesSchema(toolName: string, schema: Record<string, unknown>): this;
192
+ /**
193
+ * Assert total cost (in USD) is at or below `maxCost`.
194
+ *
195
+ * @param maxCost - Maximum allowed cost in USD.
196
+ * @param opts.soft - When `true` the failure is non-blocking.
197
+ * @returns The chain for fluent composition.
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * expect(result).costUnder(0.05);
202
+ * expect(result).costUnder(0.05, { soft: true });
203
+ * ```
204
+ */
205
+ costUnder(maxCost: number, opts?: {
206
+ soft?: boolean;
207
+ }): this;
208
+ /**
209
+ * Assert total latency is at or below `maxMs` milliseconds.
210
+ *
211
+ * @param maxMs - Maximum allowed latency in milliseconds.
212
+ * @param opts.soft - When `true` the failure is non-blocking.
213
+ * @returns The chain for fluent composition.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * expect(result).latencyUnder(2000);
218
+ * ```
219
+ */
220
+ latencyUnder(maxMs: number, opts?: {
221
+ soft?: boolean;
222
+ }): this;
223
+ /**
224
+ * Assert total token usage is at or below `maxTokens`.
225
+ *
226
+ * @param maxTokens - Maximum allowed token count.
227
+ * @param opts.soft - When `true` the failure is non-blocking.
228
+ * @returns The chain for fluent composition.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * expect(result).tokensUnder(500);
233
+ * ```
234
+ */
235
+ tokensUnder(maxTokens: number, opts?: {
236
+ soft?: boolean;
237
+ }): this;
238
+ /**
239
+ * Assert total token usage is between `minTokens` and `maxTokens` (inclusive).
240
+ *
241
+ * @param minTokens - Minimum allowed token count.
242
+ * @param maxTokens - Maximum allowed token count.
243
+ * @param opts.soft - When `true` the failure is non-blocking.
244
+ * @returns The chain for fluent composition.
245
+ *
246
+ * @example
247
+ * ```ts
248
+ * expect(result).tokensBetween(100, 500);
249
+ * ```
250
+ */
251
+ tokensBetween(minTokens: number, maxTokens: number, opts?: {
252
+ soft?: boolean;
253
+ }): this;
254
+ /**
255
+ * Assert the number of steps satisfies the given comparison.
256
+ *
257
+ * @param operator - Comparison operator (e.g. `"eq"`, `"lte"`, `"gte"`).
258
+ * @param value - The reference count to compare against.
259
+ * @param opts.soft - When `true` the failure is non-blocking.
260
+ * @returns The chain for fluent composition.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * expect(result).stepCount("lte", 5);
265
+ * ```
266
+ */
267
+ stepCount(operator: string, value: number, opts?: {
268
+ soft?: boolean;
269
+ }): this;
270
+ /**
271
+ * Assert the number of tool-call steps satisfies the given comparison.
272
+ *
273
+ * @param operator - Comparison operator (e.g. `"eq"`, `"lte"`, `"gte"`).
274
+ * @param value - The reference count to compare against.
275
+ * @param opts.soft - When `true` the failure is non-blocking.
276
+ * @returns The chain for fluent composition.
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * expect(result).toolCallCount("gte", 1);
281
+ * ```
282
+ */
283
+ toolCallCount(operator: string, value: number, opts?: {
284
+ soft?: boolean;
285
+ }): this;
286
+ /**
287
+ * Generic constraint assertion on any field.
288
+ *
289
+ * @param field - Dot-delimited path into the trace (e.g. `"metadata.cost_usd"`).
290
+ * @param operator - Comparison operator.
291
+ * @param opts.value - Reference value for single-operand operators.
292
+ * @param opts.min - Minimum for `"between"` operator.
293
+ * @param opts.max - Maximum for `"between"` operator.
294
+ * @param opts.soft - When `true` the failure is non-blocking.
295
+ * @returns The chain for fluent composition.
296
+ *
297
+ * @example
298
+ * ```ts
299
+ * expect(result).constraint("metadata.cost_usd", "lte", { value: 0.1 });
300
+ * ```
301
+ */
302
+ constraint(field: string, operator: string, opts?: {
303
+ value?: number;
304
+ min?: number;
305
+ max?: number;
306
+ soft?: boolean;
307
+ }): this;
308
+ /**
309
+ * Assert that tools were called in the given order (non-contiguous allowed).
310
+ *
311
+ * @param tools - Ordered list of tool names expected.
312
+ * @param opts.soft - When `true` the failure is non-blocking.
313
+ * @returns The chain for fluent composition.
314
+ *
315
+ * @example
316
+ * ```ts
317
+ * expect(result).toolsCalledInOrder(["search", "write"]);
318
+ * ```
319
+ */
320
+ toolsCalledInOrder(tools: string[], opts?: {
321
+ soft?: boolean;
322
+ }): this;
323
+ /**
324
+ * Assert that tools were called in exact contiguous order.
325
+ *
326
+ * @param tools - Exact ordered list of tool names.
327
+ * @param opts.soft - When `true` the failure is non-blocking.
328
+ * @returns The chain for fluent composition.
329
+ *
330
+ * @example
331
+ * ```ts
332
+ * expect(result).toolsCalledExactly(["search", "summarize", "respond"]);
333
+ * ```
334
+ */
335
+ toolsCalledExactly(tools: string[], opts?: {
336
+ soft?: boolean;
337
+ }): this;
338
+ /**
339
+ * Assert a tool is not called more than `maxRepetitions` times consecutively.
340
+ *
341
+ * @param tool - The tool name to check.
342
+ * @param maxRepetitions - Maximum allowed consecutive calls (default `1`).
343
+ * @param opts.soft - When `true` the failure is non-blocking.
344
+ * @returns The chain for fluent composition.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * expect(result).noToolLoops("fetch", 2);
349
+ * ```
350
+ */
351
+ noToolLoops(tool: string, maxRepetitions?: number, opts?: {
352
+ soft?: boolean;
353
+ }): this;
354
+ /**
355
+ * Assert no tool is called more than once.
356
+ *
357
+ * @param opts.soft - When `true` the failure is non-blocking.
358
+ * @returns The chain for fluent composition.
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * expect(result).noDuplicateTools();
363
+ * ```
364
+ */
365
+ noDuplicateTools(opts?: {
366
+ soft?: boolean;
367
+ }): this;
368
+ /**
369
+ * Assert that all listed tools were called at least once.
370
+ *
371
+ * @param tools - Tool names that must appear in the trace.
372
+ * @param opts.soft - When `true` the failure is non-blocking.
373
+ * @returns The chain for fluent composition.
374
+ *
375
+ * @example
376
+ * ```ts
377
+ * expect(result).requiredTools(["search", "respond"]);
378
+ * ```
379
+ */
380
+ requiredTools(tools: string[], opts?: {
381
+ soft?: boolean;
382
+ }): this;
383
+ /**
384
+ * Assert that none of the listed tools were called.
385
+ *
386
+ * @param tools - Tool names that must not appear in the trace.
387
+ * @param opts.soft - When `true` the failure is non-blocking.
388
+ * @returns The chain for fluent composition.
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * expect(result).forbiddenTools(["delete_user", "drop_table"]);
393
+ * ```
394
+ */
395
+ forbiddenTools(tools: string[], opts?: {
396
+ soft?: boolean;
397
+ }): this;
398
+ /**
399
+ * Assert the output message contains the given string.
400
+ *
401
+ * @param value - Substring to search for.
402
+ * @param opts.caseSensitive - Enable case-sensitive matching (default `false`).
403
+ * @param opts.soft - When `true` the failure is non-blocking.
404
+ * @returns The chain for fluent composition.
405
+ *
406
+ * @example
407
+ * ```ts
408
+ * expect(result).outputContains("refund approved");
409
+ * ```
410
+ */
411
+ outputContains(value: string, opts?: {
412
+ caseSensitive?: boolean;
413
+ soft?: boolean;
414
+ }): this;
415
+ /**
416
+ * Assert the output message does not contain the given string.
417
+ *
418
+ * @param value - Substring that must be absent.
419
+ * @param opts.caseSensitive - Enable case-sensitive matching (default `false`).
420
+ * @param opts.soft - When `true` the failure is non-blocking.
421
+ * @returns The chain for fluent composition.
422
+ *
423
+ * @example
424
+ * ```ts
425
+ * expect(result).outputNotContains("internal error");
426
+ * ```
427
+ */
428
+ outputNotContains(value: string, opts?: {
429
+ caseSensitive?: boolean;
430
+ soft?: boolean;
431
+ }): this;
432
+ /**
433
+ * Assert the output message matches the given regular expression.
434
+ *
435
+ * @param pattern - Regex pattern string.
436
+ * @param opts.soft - When `true` the failure is non-blocking.
437
+ * @returns The chain for fluent composition.
438
+ *
439
+ * @example
440
+ * ```ts
441
+ * expect(result).outputMatchesRegex("order #\\d{5}");
442
+ * ```
443
+ */
444
+ outputMatchesRegex(pattern: string, opts?: {
445
+ soft?: boolean;
446
+ }): this;
447
+ /**
448
+ * Assert the output message contains all of the given keywords.
449
+ *
450
+ * @param keywords - Keywords that must all be present.
451
+ * @param opts.caseSensitive - Enable case-sensitive matching (default `false`).
452
+ * @param opts.soft - When `true` the failure is non-blocking.
453
+ * @returns The chain for fluent composition.
454
+ *
455
+ * @example
456
+ * ```ts
457
+ * expect(result).outputHasAllKeywords(["refund", "processed"]);
458
+ * ```
459
+ */
460
+ outputHasAllKeywords(keywords: string[], opts?: {
461
+ caseSensitive?: boolean;
462
+ soft?: boolean;
463
+ }): this;
464
+ /**
465
+ * Assert the output message contains at least one of the given keywords.
466
+ *
467
+ * @param keywords - Keywords where at least one must be present.
468
+ * @param opts.caseSensitive - Enable case-sensitive matching (default `false`).
469
+ * @param opts.soft - When `true` the failure is non-blocking.
470
+ * @returns The chain for fluent composition.
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * expect(result).outputHasAnyKeyword(["yes", "confirmed"]);
475
+ * ```
476
+ */
477
+ outputHasAnyKeyword(keywords: string[], opts?: {
478
+ caseSensitive?: boolean;
479
+ soft?: boolean;
480
+ }): this;
481
+ /**
482
+ * Assert the output message contains none of the forbidden terms.
483
+ *
484
+ * @param terms - Terms that must not appear in the output.
485
+ * @returns The chain for fluent composition.
486
+ *
487
+ * @example
488
+ * ```ts
489
+ * expect(result).outputForbids(["password", "api_key"]);
490
+ * ```
491
+ */
492
+ outputForbids(terms: string[]): this;
493
+ /**
494
+ * Generic content-contains check on any target path.
495
+ *
496
+ * @param target - Dot-delimited path into the trace.
497
+ * @param value - Substring to search for.
498
+ * @param opts.caseSensitive - Enable case-sensitive matching (default `false`).
499
+ * @param opts.soft - When `true` the failure is non-blocking.
500
+ * @returns The chain for fluent composition.
501
+ *
502
+ * @example
503
+ * ```ts
504
+ * expect(result).contentContains("steps[0].result.text", "success");
505
+ * ```
506
+ */
507
+ contentContains(target: string, value: string, opts?: {
508
+ caseSensitive?: boolean;
509
+ soft?: boolean;
510
+ }): this;
511
+ /**
512
+ * Assert the output is semantically similar to a reference string via embeddings.
513
+ *
514
+ * @param reference - The reference text to compare against.
515
+ * @param opts.threshold - Minimum cosine similarity (default `0.8`).
516
+ * @param opts.model - Override the embedding model.
517
+ * @param opts.soft - When `true` the failure is non-blocking.
518
+ * @returns The chain for fluent composition.
519
+ *
520
+ * @example
521
+ * ```ts
522
+ * expect(result).outputSimilarTo("The order has been refunded", { threshold: 0.85 });
523
+ * ```
524
+ */
525
+ outputSimilarTo(reference: string, opts?: {
526
+ threshold?: number | "dynamic";
527
+ model?: string;
528
+ soft?: boolean;
529
+ }): this;
530
+ /**
531
+ * Assert the output passes LLM judge evaluation against given criteria.
532
+ *
533
+ * @param criteria - Natural language description of what makes a good response.
534
+ * @param opts.rubric - Rubric name (default `"default"`).
535
+ * @param opts.threshold - Minimum passing score (default `0.8`).
536
+ * @param opts.model - Override the judge model.
537
+ * @param opts.soft - When `true` the failure is non-blocking.
538
+ * @returns The chain for fluent composition.
539
+ *
540
+ * @example
541
+ * ```ts
542
+ * expect(result).passesJudge("Response is polite and helpful", { threshold: 0.9 });
543
+ * ```
544
+ */
545
+ passesJudge(criteria: string, opts?: {
546
+ rubric?: string;
547
+ threshold?: number | "dynamic";
548
+ model?: string;
549
+ soft?: boolean;
550
+ }): this;
551
+ /**
552
+ * Assert that a specific agent was called in the trace tree.
553
+ *
554
+ * @param agentId - The agent identifier to look for.
555
+ * @param opts.soft - When `true` the failure is non-blocking.
556
+ * @returns The chain for fluent composition.
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * expect(result).agentCalled("summarizer");
561
+ * ```
562
+ */
563
+ agentCalled(agentId: string, opts?: {
564
+ soft?: boolean;
565
+ }): this;
566
+ /**
567
+ * Assert the trace tree delegation depth does not exceed `maxDepth`.
568
+ *
569
+ * @param maxDepth - Maximum allowed delegation depth.
570
+ * @param opts.soft - When `true` the failure is non-blocking.
571
+ * @returns The chain for fluent composition.
572
+ *
573
+ * @example
574
+ * ```ts
575
+ * expect(result).delegationDepth(3);
576
+ * ```
577
+ */
578
+ delegationDepth(maxDepth: number, opts?: {
579
+ soft?: boolean;
580
+ }): this;
581
+ /**
582
+ * Assert a sub-agent's output contains the given string.
583
+ *
584
+ * @param agentId - The agent whose output to check.
585
+ * @param value - Substring to search for.
586
+ * @param opts.caseSensitive - Enable case-sensitive matching (default `false`).
587
+ * @param opts.soft - When `true` the failure is non-blocking.
588
+ * @returns The chain for fluent composition.
589
+ *
590
+ * @example
591
+ * ```ts
592
+ * expect(result).agentOutputContains("summarizer", "key findings");
593
+ * ```
594
+ */
595
+ agentOutputContains(agentId: string, value: string, opts?: {
596
+ caseSensitive?: boolean;
597
+ soft?: boolean;
598
+ }): this;
599
+ /**
600
+ * Assert data flows from one agent's output to another agent's input.
601
+ *
602
+ * @param fromAgent - Source agent ID.
603
+ * @param toAgent - Destination agent ID.
604
+ * @param field - The data field that must flow between agents.
605
+ * @param opts.soft - When `true` the failure is non-blocking.
606
+ * @returns The chain for fluent composition.
607
+ *
608
+ * @example
609
+ * ```ts
610
+ * expect(result).crossAgentDataFlow("researcher", "writer", "findings");
611
+ * ```
612
+ */
613
+ crossAgentDataFlow(fromAgent: string, toAgent: string, field: string, opts?: {
614
+ soft?: boolean;
615
+ }): this;
616
+ /**
617
+ * Assert agent delegations follow the specified transitions.
618
+ *
619
+ * @param transitions - Array of `[fromAgent, toAgent]` pairs.
620
+ * @param opts.soft - When `true` the failure is non-blocking.
621
+ * @returns The chain for fluent composition.
622
+ *
623
+ * @example
624
+ * ```ts
625
+ * expect(result).followsTransitions([["root", "planner"], ["planner", "executor"]]);
626
+ * ```
627
+ */
628
+ followsTransitions(transitions: [string, string][], opts?: {
629
+ soft?: boolean;
630
+ }): this;
631
+ /**
632
+ * Assert aggregate cost across the entire trace tree is at or below `maxCost`.
633
+ *
634
+ * @param maxCost - Maximum allowed aggregate cost in USD.
635
+ * @param opts.soft - When `true` the failure is non-blocking.
636
+ * @returns The chain for fluent composition.
637
+ *
638
+ * @example
639
+ * ```ts
640
+ * expect(result).aggregateCostUnder(0.50);
641
+ * ```
642
+ */
643
+ aggregateCostUnder(maxCost: number, opts?: {
644
+ soft?: boolean;
645
+ }): this;
646
+ /**
647
+ * Assert aggregate tokens across the entire trace tree is at or below `maxTokens`.
648
+ *
649
+ * @param maxTokens - Maximum allowed aggregate token count.
650
+ * @param opts.soft - When `true` the failure is non-blocking.
651
+ * @returns The chain for fluent composition.
652
+ *
653
+ * @example
654
+ * ```ts
655
+ * expect(result).aggregateTokensUnder(10000);
656
+ * ```
657
+ */
658
+ aggregateTokensUnder(maxTokens: number, opts?: {
659
+ soft?: boolean;
660
+ }): this;
661
+ /**
662
+ * Assert `agentA` started before `agentB` in the trace tree.
663
+ *
664
+ * @param agentA - The agent expected to run first.
665
+ * @param agentB - The agent expected to run second.
666
+ * @param opts.soft - When `true` the failure is non-blocking.
667
+ * @returns The chain for fluent composition.
668
+ *
669
+ * @example
670
+ * ```ts
671
+ * expect(result).agentOrderedBefore("planner", "executor");
672
+ * ```
673
+ */
674
+ agentOrderedBefore(agentA: string, agentB: string, opts?: {
675
+ soft?: boolean;
676
+ }): this;
677
+ /**
678
+ * Assert `agentA` and `agentB` ran concurrently (overlapping wall-clock time).
679
+ *
680
+ * @param agentA - First agent ID.
681
+ * @param agentB - Second agent ID.
682
+ * @param opts.soft - When `true` the failure is non-blocking.
683
+ * @returns The chain for fluent composition.
684
+ *
685
+ * @example
686
+ * ```ts
687
+ * expect(result).agentsOverlap("worker-1", "worker-2");
688
+ * ```
689
+ */
690
+ agentsOverlap(agentA: string, agentB: string, opts?: {
691
+ soft?: boolean;
692
+ }): this;
693
+ /**
694
+ * Assert a specific agent's wall-clock duration is under `maxMs` milliseconds.
695
+ *
696
+ * @param agentId - The agent to check.
697
+ * @param maxMs - Maximum allowed wall-clock time in milliseconds.
698
+ * @param opts.soft - When `true` the failure is non-blocking.
699
+ * @returns The chain for fluent composition.
700
+ *
701
+ * @example
702
+ * ```ts
703
+ * expect(result).agentWallTimeUnder("summarizer", 5000);
704
+ * ```
705
+ */
706
+ agentWallTimeUnder(agentId: string, maxMs: number, opts?: {
707
+ soft?: boolean;
708
+ }): this;
709
+ /**
710
+ * Assert agents ran in ordered groups (parallel within each group, sequential across groups).
711
+ *
712
+ * @param groups - Array of agent-ID arrays. Each sub-array is a parallel group.
713
+ * @param opts.soft - When `true` the failure is non-blocking.
714
+ * @returns The chain for fluent composition.
715
+ *
716
+ * @example
717
+ * ```ts
718
+ * expect(result).orderedAgents([["planner"], ["worker-1", "worker-2"], ["aggregator"]]);
719
+ * ```
720
+ */
721
+ orderedAgents(groups: string[][], opts?: {
722
+ soft?: boolean;
723
+ }): this;
724
+ /**
725
+ * Assert via a registered plugin (Layer 8).
726
+ *
727
+ * @param pluginId - Identifier of the plugin registered with the engine.
728
+ * @param config - Plugin-specific configuration passed at evaluation time.
729
+ * @param opts.soft - When `true` the failure is non-blocking.
730
+ * @returns The chain for fluent composition.
731
+ *
732
+ * @example
733
+ * ```ts
734
+ * expect(result).plugin("custom-safety-check", { threshold: 0.95 });
735
+ * ```
736
+ */
737
+ plugin(pluginId: string, config?: Record<string, unknown>, opts?: {
738
+ soft?: boolean;
739
+ }): this;
740
+ /**
741
+ * Assert aggregate latency across the trace tree is at or below `maxMs`.
742
+ *
743
+ * @param maxMs - Maximum allowed aggregate latency in milliseconds.
744
+ * @param opts.soft - When `true` the failure is non-blocking.
745
+ * @returns The chain for fluent composition.
746
+ *
747
+ * @example
748
+ * ```ts
749
+ * expect(result).aggregateLatencyUnder(5000);
750
+ * ```
751
+ */
752
+ aggregateLatencyUnder(maxMs: number, opts?: {
753
+ soft?: boolean;
754
+ }): this;
755
+ /**
756
+ * Assert that all specified tools were called across the entire trace tree.
757
+ *
758
+ * @param toolNames - Tool names that must appear somewhere in the tree.
759
+ * @param opts.soft - When `true` the failure is non-blocking.
760
+ * @returns The chain for fluent composition.
761
+ *
762
+ * @example
763
+ * ```ts
764
+ * expect(result).allToolsCalled(["search", "summarize"]);
765
+ * ```
766
+ */
767
+ allToolsCalled(toolNames: string[], opts?: {
768
+ soft?: boolean;
769
+ }): this;
770
+ }
771
+ /**
772
+ * Create an assertion chain for an agent result.
773
+ *
774
+ * Accepts either an {@link AgentResult} or a raw {@link Trace}. When a
775
+ * `Trace` is passed it is automatically wrapped in an `AgentResult`.
776
+ *
777
+ * @param result - An `AgentResult` or raw `Trace` to build assertions on.
778
+ * @returns A new {@link ExpectChain} for fluent assertion building.
779
+ *
780
+ * @example
781
+ * ```ts
782
+ * attestExpect(result).outputContains("hello").costUnder(0.05);
783
+ * attestExpect(trace).requiredTools(["search"]);
784
+ * ```
785
+ */
786
+ declare function attestExpect(result: AgentResult | Trace): ExpectChain;
787
+
788
+ declare class Agent {
789
+ readonly name: string;
790
+ private readonly fn;
791
+ constructor(name: string, fn?: (builder: TraceBuilder, args: Record<string, unknown>) => unknown);
792
+ run(args?: Record<string, unknown>): AgentResult;
793
+ arun(args?: Record<string, unknown>): Promise<AgentResult>;
794
+ private setOutput;
795
+ withTrace(trace: Trace): AgentResult;
796
+ }
797
+ declare function agent(name: string, fn: (builder: TraceBuilder, args: Record<string, unknown>) => unknown): (args?: Record<string, unknown>) => AgentResult;
798
+
799
+ declare function delegate(agentId: string, fn: (child: TraceBuilder) => Promise<void> | void): Promise<void>;
800
+
801
+ declare const activeBuilder: AsyncLocalStorage<TraceBuilder>;
802
+
803
+ declare const TIER_1: 1;
804
+ declare const TIER_2: 2;
805
+ declare const TIER_3: 3;
806
+ declare function tier(level: number): <T extends (...args: never[]) => unknown>(fn: T) => T;
807
+
808
+ /**
809
+ * Configure global SDK options.
810
+ *
811
+ * @param options.simulation - Enable simulation mode. All `evaluateBatch` calls
812
+ * return deterministic pass results without spawning the engine or calling any
813
+ * LLM. Equivalent to setting `ATTEST_SIMULATION=1` in the environment.
814
+ * @param options.sampleRate - Sampling rate for continuous evaluation (0.0–1.0).
815
+ * Equivalent to setting `ATTEST_SAMPLE_RATE` in the environment.
816
+ */
817
+ declare function config(options: {
818
+ simulation?: boolean;
819
+ sampleRate?: number;
820
+ }): void;
821
+ /**
822
+ * Returns true when simulation mode is active via either the programmatic API
823
+ * or the `ATTEST_SIMULATION` environment variable.
824
+ */
825
+ declare function isSimulationMode(): boolean;
826
+ /**
827
+ * Returns the sampling rate for continuous evaluation. Priority:
828
+ * programmatic `config({ sampleRate })` > `ATTEST_SAMPLE_RATE` env var > 0.
829
+ */
830
+ declare function getSampleRate(): number;
831
+ /**
832
+ * Reset all programmatic config to defaults. Primarily for use in tests.
833
+ * Environment variables are not affected.
834
+ */
835
+ declare function resetConfig(): void;
836
+
837
+ /**
838
+ * Return a deterministic all-pass result for every assertion without
839
+ * contacting the engine or any LLM provider. Used when simulation mode
840
+ * is active (`ATTEST_SIMULATION=1` or `config({ simulation: true })`).
841
+ */
842
+ declare function simulationEvaluateBatch(assertions: readonly Assertion[]): EvaluateBatchResult;
843
+
844
+ interface PluginResult {
845
+ readonly status: string;
846
+ readonly score: number;
847
+ readonly explanation: string;
848
+ readonly metadata?: Record<string, unknown>;
849
+ }
850
+ interface AttestPlugin {
851
+ readonly name: string;
852
+ readonly pluginType: string;
853
+ execute(trace: Trace, spec: Record<string, unknown>): PluginResult | Promise<PluginResult>;
854
+ }
855
+ declare class PluginRegistry {
856
+ private readonly plugins;
857
+ register(name: string, plugin: AttestPlugin): void;
858
+ get(pluginType: string, name: string): AttestPlugin | undefined;
859
+ listPlugins(pluginType?: string): string[];
860
+ }
861
+ declare function executePluginAssertion(plugin: AttestPlugin, trace: Trace, spec: Record<string, unknown>, client: AttestClient, traceId: string, assertionId: string, timeoutMs?: number): Promise<PluginResult>;
862
+
863
+ declare class Sampler {
864
+ private readonly rate;
865
+ constructor(rate: number);
866
+ shouldSample(): boolean;
867
+ }
868
+ interface AlertPayload {
869
+ drift_type: string;
870
+ score: number | string;
871
+ trace_id: string;
872
+ [key: string]: unknown;
873
+ }
874
+ declare class AlertDispatcher extends EventEmitter {
875
+ private readonly webhookUrl;
876
+ private readonly slackUrl;
877
+ constructor(webhookUrl?: string, slackUrl?: string);
878
+ dispatch(alert: AlertPayload): Promise<void>;
879
+ private postJson;
880
+ }
881
+ declare class ContinuousEvalRunner {
882
+ private readonly client;
883
+ private readonly assertions;
884
+ private readonly sampler;
885
+ private readonly dispatcher;
886
+ private readonly queue;
887
+ private readonly maxSize;
888
+ private running;
889
+ private loopTimer;
890
+ constructor(client: AttestClient, assertions: readonly Assertion[], options?: {
891
+ sampleRate?: number;
892
+ alertWebhook?: string;
893
+ alertSlackUrl?: string;
894
+ maxSize?: number;
895
+ });
896
+ get alertEmitter(): AlertDispatcher;
897
+ evaluateTrace(trace: Trace): Promise<EvaluateBatchResult | null>;
898
+ submit(trace: Trace): boolean;
899
+ start(): void;
900
+ stop(): void;
901
+ get queueLength(): number;
902
+ get isRunning(): boolean;
903
+ private scheduleNext;
904
+ }
905
+
906
+ declare const FRIENDLY_USER: SimulatePersona;
907
+ declare const ADVERSARIAL_USER: SimulatePersona;
908
+ declare const CONFUSED_USER: SimulatePersona;
909
+ declare const COOPERATIVE_USER: SimulatePersona;
910
+
911
+ declare class ManualAdapter {
912
+ private readonly agentId;
913
+ constructor(agentId?: string);
914
+ capture(builderFn: (builder: TraceBuilder) => void): Trace;
915
+ createBuilder(): TraceBuilder;
916
+ }
917
+
918
+ interface OpenAIUsage {
919
+ total_tokens?: number;
920
+ }
921
+ interface OpenAIToolCall {
922
+ function: {
923
+ name: string;
924
+ arguments: string;
925
+ };
926
+ }
927
+ interface OpenAIMessage {
928
+ content: string | null;
929
+ tool_calls?: OpenAIToolCall[];
930
+ }
931
+ interface OpenAIChoice {
932
+ message: OpenAIMessage;
933
+ }
934
+ interface OpenAIChatCompletion {
935
+ model?: string;
936
+ usage?: OpenAIUsage;
937
+ choices: OpenAIChoice[];
938
+ }
939
+ declare class OpenAIAdapter {
940
+ private readonly agentId;
941
+ constructor(agentId?: string);
942
+ traceFromResponse(response: OpenAIChatCompletion, options?: {
943
+ inputMessages?: Record<string, unknown>[];
944
+ costUsd?: number;
945
+ latencyMs?: number;
946
+ structuredOutput?: Record<string, unknown>;
947
+ }): Trace;
948
+ }
949
+
950
+ interface AnthropicTextBlock {
951
+ type: "text";
952
+ text: string;
953
+ }
954
+ interface AnthropicToolUseBlock {
955
+ type: "tool_use";
956
+ name: string;
957
+ input: Record<string, unknown>;
958
+ }
959
+ type AnthropicContentBlock = AnthropicTextBlock | AnthropicToolUseBlock;
960
+ interface AnthropicUsage {
961
+ input_tokens: number;
962
+ output_tokens: number;
963
+ }
964
+ interface AnthropicMessage {
965
+ model?: string;
966
+ usage?: AnthropicUsage;
967
+ content: AnthropicContentBlock[];
968
+ }
969
+ declare class AnthropicAdapter {
970
+ private readonly agentId;
971
+ constructor(agentId?: string);
972
+ traceFromResponse(response: AnthropicMessage, options?: {
973
+ inputMessages?: Record<string, unknown>[];
974
+ costUsd?: number;
975
+ latencyMs?: number;
976
+ }): Trace;
977
+ }
978
+
979
+ interface GeminiFunctionCall {
980
+ name: string;
981
+ args?: Record<string, unknown>;
982
+ }
983
+ interface GeminiPart {
984
+ text?: string;
985
+ functionCall?: GeminiFunctionCall;
986
+ }
987
+ interface GeminiCandidate {
988
+ content: {
989
+ parts: GeminiPart[];
990
+ };
991
+ }
992
+ interface GeminiResponse {
993
+ text?: string;
994
+ candidates?: GeminiCandidate[];
995
+ }
996
+ declare class GeminiAdapter {
997
+ private readonly agentId;
998
+ constructor(agentId?: string);
999
+ traceFromResponse(response: GeminiResponse, options?: {
1000
+ inputText?: string;
1001
+ costUsd?: number;
1002
+ latencyMs?: number;
1003
+ model?: string;
1004
+ }): Trace;
1005
+ }
1006
+
1007
+ interface OllamaResponse {
1008
+ model?: string;
1009
+ message?: {
1010
+ content?: string;
1011
+ };
1012
+ eval_count?: number;
1013
+ prompt_eval_count?: number;
1014
+ }
1015
+ declare class OllamaAdapter {
1016
+ private readonly agentId;
1017
+ constructor(agentId?: string);
1018
+ traceFromResponse(response: OllamaResponse, options?: {
1019
+ inputMessages?: Record<string, unknown>[];
1020
+ latencyMs?: number;
1021
+ }): Trace;
1022
+ }
1023
+
1024
+ interface OTelSpanContext {
1025
+ traceId: string;
1026
+ }
1027
+ interface OTelSpan {
1028
+ name: string;
1029
+ startTime: [number, number];
1030
+ endTime: [number, number];
1031
+ attributes?: Record<string, unknown>;
1032
+ parentSpanId?: string;
1033
+ spanContext(): OTelSpanContext;
1034
+ }
1035
+ declare class OTelAdapter {
1036
+ private readonly agentId;
1037
+ constructor(agentId?: string);
1038
+ static fromSpans(spans: OTelSpan[], agentId?: string): Trace;
1039
+ private buildTrace;
1040
+ private findRootSpan;
1041
+ private classifySpan;
1042
+ private extractLlmStep;
1043
+ private extractToolStep;
1044
+ private spanMetadata;
1045
+ }
1046
+
1047
+ /**
1048
+ * Minimal type definitions for `@langchain/core` callback handler.
1049
+ * These avoid a hard dependency on `@langchain/core` — the actual types
1050
+ * are checked at runtime when the user provides real LangChain objects.
1051
+ */
1052
+ interface LangChainLLMResult {
1053
+ generations: Array<Array<{
1054
+ text: string;
1055
+ [key: string]: unknown;
1056
+ }>>;
1057
+ llmOutput?: Record<string, unknown>;
1058
+ }
1059
+ interface LangChainToolEnd {
1060
+ name?: string;
1061
+ output: string;
1062
+ [key: string]: unknown;
1063
+ }
1064
+ interface LangChainChainValues {
1065
+ [key: string]: unknown;
1066
+ }
1067
+ declare class LangChainAdapter {
1068
+ private readonly agentId;
1069
+ private readonly llmCalls;
1070
+ private readonly toolCalls;
1071
+ private chainOutput;
1072
+ private startTime;
1073
+ constructor(agentId?: string);
1074
+ /**
1075
+ * Reset accumulated state for a new trace capture session.
1076
+ */
1077
+ reset(): void;
1078
+ /**
1079
+ * Call this when a chain starts (maps to `handleChainStart`).
1080
+ */
1081
+ handleChainStart(): void;
1082
+ /**
1083
+ * Call this when an LLM call completes (maps to `handleLLMEnd`).
1084
+ */
1085
+ handleLLMEnd(output: LangChainLLMResult): void;
1086
+ /**
1087
+ * Call this when a tool call completes (maps to `handleToolEnd`).
1088
+ */
1089
+ handleToolEnd(output: string, metadata?: LangChainToolEnd): void;
1090
+ /**
1091
+ * Call this when a chain completes (maps to `handleChainEnd`).
1092
+ */
1093
+ handleChainEnd(output: LangChainChainValues): void;
1094
+ /**
1095
+ * Build a Trace from accumulated callback events.
1096
+ *
1097
+ * @param options.costUsd - Total cost override.
1098
+ * @param options.model - Model name override.
1099
+ * @returns A finalized Trace object.
1100
+ */
1101
+ buildTrace(options?: {
1102
+ costUsd?: number;
1103
+ model?: string;
1104
+ }): Trace;
1105
+ }
1106
+
1107
+ interface TraceAdapter {
1108
+ traceFromResponse(response: unknown, options?: Record<string, unknown>): Trace;
1109
+ }
1110
+
1111
+ export { ADVERSARIAL_USER, Agent, AgentResult, AlertDispatcher, type AlertPayload, AnthropicAdapter, Assertion, AssertionResult, AttestClient, type AttestPlugin, CONFUSED_USER, COOPERATIVE_USER, ContinuousEvalRunner, ConversationMessage, DriftReport, ENGINE_VERSION, EngineManager, EvaluateBatchResult, ExpectChain, FRIENDLY_USER, GeminiAdapter, InitializeResult, LangChainAdapter, ManualAdapter, OTelAdapter, OllamaAdapter, OpenAIAdapter, PluginRegistry, type PluginResult, Sampler, SimulateFaultConfig, SimulatePersona, Step, TIER_1, TIER_2, TIER_3, Trace, type TraceAdapter, TraceBuilder, TraceTree, VERSION, activeBuilder, agent, attestExpect, config, delegate, executePluginAssertion, getSampleRate, isSimulationMode, resetConfig, simulationEvaluateBatch, tier };