@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,208 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/proto/index.ts
21
+ var proto_exports = {};
22
+ __export(proto_exports, {
23
+ ERR_ASSERTION_ERROR: () => ERR_ASSERTION_ERROR,
24
+ ERR_ENGINE_ERROR: () => ERR_ENGINE_ERROR,
25
+ ERR_INVALID_TRACE: () => ERR_INVALID_TRACE,
26
+ ERR_PROVIDER_ERROR: () => ERR_PROVIDER_ERROR,
27
+ ERR_SESSION_ERROR: () => ERR_SESSION_ERROR,
28
+ ERR_TIMEOUT: () => ERR_TIMEOUT,
29
+ EngineTimeoutError: () => EngineTimeoutError,
30
+ ProtocolError: () => ProtocolError,
31
+ STATUS_HARD_FAIL: () => STATUS_HARD_FAIL,
32
+ STATUS_PASS: () => STATUS_PASS,
33
+ STATUS_SOFT_FAIL: () => STATUS_SOFT_FAIL,
34
+ STEP_AGENT_CALL: () => STEP_AGENT_CALL,
35
+ STEP_LLM_CALL: () => STEP_LLM_CALL,
36
+ STEP_RETRIEVAL: () => STEP_RETRIEVAL,
37
+ STEP_TOOL_CALL: () => STEP_TOOL_CALL,
38
+ TYPE_CONSTRAINT: () => TYPE_CONSTRAINT,
39
+ TYPE_CONTENT: () => TYPE_CONTENT,
40
+ TYPE_EMBEDDING: () => TYPE_EMBEDDING,
41
+ TYPE_LLM_JUDGE: () => TYPE_LLM_JUDGE,
42
+ TYPE_PLUGIN: () => TYPE_PLUGIN,
43
+ TYPE_SCHEMA: () => TYPE_SCHEMA,
44
+ TYPE_TRACE: () => TYPE_TRACE,
45
+ TYPE_TRACE_TREE: () => TYPE_TRACE_TREE,
46
+ agentId: () => agentId,
47
+ assertionId: () => assertionId,
48
+ decodeResponse: () => decodeResponse,
49
+ encodeRequest: () => encodeRequest,
50
+ extractId: () => extractId,
51
+ extractResult: () => extractResult,
52
+ traceId: () => traceId
53
+ });
54
+ module.exports = __toCommonJS(proto_exports);
55
+
56
+ // src/proto/constants.ts
57
+ var STEP_LLM_CALL = "llm_call";
58
+ var STEP_TOOL_CALL = "tool_call";
59
+ var STEP_RETRIEVAL = "retrieval";
60
+ var STEP_AGENT_CALL = "agent_call";
61
+ var STATUS_PASS = "pass";
62
+ var STATUS_SOFT_FAIL = "soft_fail";
63
+ var STATUS_HARD_FAIL = "hard_fail";
64
+ var TYPE_SCHEMA = "schema";
65
+ var TYPE_CONSTRAINT = "constraint";
66
+ var TYPE_TRACE = "trace";
67
+ var TYPE_CONTENT = "content";
68
+ var TYPE_EMBEDDING = "embedding";
69
+ var TYPE_LLM_JUDGE = "llm_judge";
70
+ var TYPE_TRACE_TREE = "trace_tree";
71
+ var TYPE_PLUGIN = "plugin";
72
+ var ERR_INVALID_TRACE = 1001;
73
+ var ERR_ASSERTION_ERROR = 1002;
74
+ var ERR_PROVIDER_ERROR = 2001;
75
+ var ERR_ENGINE_ERROR = 3001;
76
+ var ERR_TIMEOUT = 3002;
77
+ var ERR_SESSION_ERROR = 3003;
78
+
79
+ // src/proto/types.ts
80
+ function traceId(id) {
81
+ return id;
82
+ }
83
+ function assertionId(id) {
84
+ return id;
85
+ }
86
+ function agentId(id) {
87
+ return id;
88
+ }
89
+
90
+ // src/proto/errors.ts
91
+ var ProtocolError = class extends Error {
92
+ code;
93
+ errorMessage;
94
+ data;
95
+ constructor(code, message, data) {
96
+ super(message);
97
+ this.name = "ProtocolError";
98
+ this.code = code;
99
+ this.errorMessage = message;
100
+ this.data = data;
101
+ }
102
+ };
103
+ var EngineTimeoutError = class extends Error {
104
+ method;
105
+ timeoutMs;
106
+ constructor(method, timeoutMs) {
107
+ super(
108
+ `Engine request '${method}' timed out after ${timeoutMs}ms. Set ATTEST_ENGINE_TIMEOUT to increase the limit.`
109
+ );
110
+ this.name = "EngineTimeoutError";
111
+ this.method = method;
112
+ this.timeoutMs = timeoutMs;
113
+ }
114
+ };
115
+
116
+ // src/proto/codec.ts
117
+ function encodeRequest(id, method, params) {
118
+ const msg = {
119
+ jsonrpc: "2.0",
120
+ id,
121
+ method,
122
+ params
123
+ };
124
+ return JSON.stringify(msg) + "\n";
125
+ }
126
+ function decodeResponse(line) {
127
+ const text = line.trim();
128
+ if (!text) {
129
+ throw new Error("empty response line");
130
+ }
131
+ let data;
132
+ try {
133
+ data = JSON.parse(text);
134
+ } catch (e) {
135
+ throw new Error(`malformed JSON response: ${e instanceof Error ? e.message : String(e)}`);
136
+ }
137
+ if (typeof data !== "object" || data === null || Array.isArray(data)) {
138
+ throw new Error(`expected JSON object, got ${Array.isArray(data) ? "array" : typeof data}`);
139
+ }
140
+ const obj = data;
141
+ if (obj.jsonrpc !== "2.0") {
142
+ throw new Error(`invalid jsonrpc version: ${String(obj.jsonrpc)}`);
143
+ }
144
+ if (obj.error != null) {
145
+ const err = obj.error;
146
+ let errorData;
147
+ if (err.data != null) {
148
+ const raw = err.data;
149
+ errorData = {
150
+ error_type: raw.error_type ?? "",
151
+ retryable: raw.retryable ?? false,
152
+ detail: raw.detail ?? ""
153
+ };
154
+ }
155
+ throw new ProtocolError(
156
+ err.code ?? -1,
157
+ err.message ?? "unknown error",
158
+ errorData
159
+ );
160
+ }
161
+ return obj;
162
+ }
163
+ function extractResult(response) {
164
+ if (response.result === void 0) {
165
+ throw new Error("response missing 'result' field");
166
+ }
167
+ return response.result;
168
+ }
169
+ function extractId(response) {
170
+ if (response.id === void 0) {
171
+ throw new Error("response missing 'id' field");
172
+ }
173
+ return Number(response.id);
174
+ }
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {
177
+ ERR_ASSERTION_ERROR,
178
+ ERR_ENGINE_ERROR,
179
+ ERR_INVALID_TRACE,
180
+ ERR_PROVIDER_ERROR,
181
+ ERR_SESSION_ERROR,
182
+ ERR_TIMEOUT,
183
+ EngineTimeoutError,
184
+ ProtocolError,
185
+ STATUS_HARD_FAIL,
186
+ STATUS_PASS,
187
+ STATUS_SOFT_FAIL,
188
+ STEP_AGENT_CALL,
189
+ STEP_LLM_CALL,
190
+ STEP_RETRIEVAL,
191
+ STEP_TOOL_CALL,
192
+ TYPE_CONSTRAINT,
193
+ TYPE_CONTENT,
194
+ TYPE_EMBEDDING,
195
+ TYPE_LLM_JUDGE,
196
+ TYPE_PLUGIN,
197
+ TYPE_SCHEMA,
198
+ TYPE_TRACE,
199
+ TYPE_TRACE_TREE,
200
+ agentId,
201
+ assertionId,
202
+ decodeResponse,
203
+ encodeRequest,
204
+ extractId,
205
+ extractResult,
206
+ traceId
207
+ });
208
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/proto/index.ts","../../../src/proto/constants.ts","../../../src/proto/types.ts","../../../src/proto/errors.ts","../../../src/proto/codec.ts"],"sourcesContent":["export * from \"./constants.js\";\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport { encodeRequest, decodeResponse, extractResult, extractId } from \"./codec.js\";\n","// Step type constants\nexport const STEP_LLM_CALL = \"llm_call\" as const;\nexport const STEP_TOOL_CALL = \"tool_call\" as const;\nexport const STEP_RETRIEVAL = \"retrieval\" as const;\nexport const STEP_AGENT_CALL = \"agent_call\" as const;\n\n// Status constants\nexport const STATUS_PASS = \"pass\" as const;\nexport const STATUS_SOFT_FAIL = \"soft_fail\" as const;\nexport const STATUS_HARD_FAIL = \"hard_fail\" as const;\n\n// Assertion type constants\nexport const TYPE_SCHEMA = \"schema\" as const;\nexport const TYPE_CONSTRAINT = \"constraint\" as const;\nexport const TYPE_TRACE = \"trace\" as const;\nexport const TYPE_CONTENT = \"content\" as const;\nexport const TYPE_EMBEDDING = \"embedding\" as const;\nexport const TYPE_LLM_JUDGE = \"llm_judge\" as const;\nexport const TYPE_TRACE_TREE = \"trace_tree\" as const;\nexport const TYPE_PLUGIN = \"plugin\" as const;\n\n// Error code constants\nexport const ERR_INVALID_TRACE = 1001 as const;\nexport const ERR_ASSERTION_ERROR = 1002 as const;\nexport const ERR_PROVIDER_ERROR = 2001 as const;\nexport const ERR_ENGINE_ERROR = 3001 as const;\nexport const ERR_TIMEOUT = 3002 as const;\nexport const ERR_SESSION_ERROR = 3003 as const;\n","// ---------------------------------------------------------------------------\n// Branded ID types (T6)\n// ---------------------------------------------------------------------------\n\ndeclare const __brand: unique symbol;\ntype Brand<T, B extends string> = T & { readonly [__brand]: B };\n\nexport type TraceId = Brand<string, \"TraceId\">;\nexport type AssertionId = Brand<string, \"AssertionId\">;\nexport type AgentId = Brand<string, \"AgentId\">;\n\nexport function traceId(id: string): TraceId {\n return id as TraceId;\n}\n\nexport function assertionId(id: string): AssertionId {\n return id as AssertionId;\n}\n\nexport function agentId(id: string): AgentId {\n return id as AgentId;\n}\n\n// ---------------------------------------------------------------------------\n// Assertion spec discriminated unions (T5)\n// ---------------------------------------------------------------------------\n\nexport interface SchemaSpec {\n readonly type: \"schema\";\n readonly target: string;\n readonly schema: Record<string, unknown>;\n}\n\nexport interface ConstraintSpec {\n readonly type: \"constraint\";\n readonly field: string;\n readonly operator: string;\n readonly value?: number;\n readonly min?: number;\n readonly max?: number;\n readonly soft: boolean;\n}\n\nexport interface TraceSpec {\n readonly type: \"trace\";\n readonly check: string;\n readonly tools?: string[];\n readonly tool?: string;\n readonly max_repetitions?: number;\n readonly soft: boolean;\n}\n\nexport interface ContentSpec {\n readonly type: \"content\";\n readonly target: string;\n readonly check: string;\n readonly value?: string;\n readonly values?: string[];\n readonly case_sensitive?: boolean;\n readonly soft?: boolean;\n}\n\nexport interface EmbeddingSpec {\n readonly type: \"embedding\";\n readonly target: string;\n readonly reference: string;\n readonly threshold: number | \"dynamic\";\n readonly model?: string;\n readonly soft: boolean;\n}\n\nexport interface LlmJudgeSpec {\n readonly type: \"llm_judge\";\n readonly target: string;\n readonly criteria: string;\n readonly rubric: string;\n readonly threshold: number | \"dynamic\";\n readonly model?: string;\n readonly soft: boolean;\n}\n\nexport interface TraceTreeSpec {\n readonly type: \"trace_tree\";\n readonly check: string;\n readonly [key: string]: unknown;\n}\n\nexport interface PluginSpec {\n readonly type: \"plugin\";\n readonly plugin_id: string;\n readonly config?: Record<string, unknown>;\n readonly soft: boolean;\n}\n\nexport type AssertionSpec =\n | SchemaSpec\n | ConstraintSpec\n | TraceSpec\n | ContentSpec\n | EmbeddingSpec\n | LlmJudgeSpec\n | TraceTreeSpec\n | PluginSpec;\n\n// ---------------------------------------------------------------------------\n// Core protocol types\n// ---------------------------------------------------------------------------\n\nexport interface TraceMetadata {\n readonly total_tokens?: number;\n readonly cost_usd?: number;\n readonly latency_ms?: number;\n readonly model?: string;\n readonly timestamp?: string;\n}\n\nexport interface Step {\n readonly type: string;\n readonly name: string;\n readonly args?: Record<string, unknown>;\n readonly result?: Record<string, unknown>;\n readonly sub_trace?: Trace;\n readonly metadata?: Record<string, unknown>;\n readonly started_at_ms?: number;\n readonly ended_at_ms?: number;\n readonly agent_id?: string;\n readonly agent_role?: string;\n}\n\nexport interface Trace {\n readonly trace_id: string;\n readonly output: Record<string, unknown>;\n readonly schema_version?: number;\n readonly agent_id?: string;\n readonly input?: Record<string, unknown>;\n readonly steps: readonly Step[];\n readonly metadata?: TraceMetadata;\n readonly parent_trace_id?: string;\n}\n\nexport interface Assertion {\n readonly assertion_id: string;\n readonly type: string;\n readonly spec: Record<string, unknown>;\n readonly request_id?: string;\n}\n\nexport interface AssertionResult {\n readonly assertion_id: string;\n readonly status: string;\n readonly score: number;\n readonly explanation: string;\n readonly cost?: number;\n readonly duration_ms?: number;\n readonly request_id?: string;\n}\n\nexport interface ErrorData {\n readonly error_type: string;\n readonly retryable: boolean;\n readonly detail: string;\n}\n\nexport interface RPCError {\n readonly code: number;\n readonly message: string;\n readonly data?: ErrorData;\n}\n\nexport interface RPCRequest {\n readonly jsonrpc: \"2.0\";\n readonly id: number;\n readonly method: string;\n readonly params: Record<string, unknown>;\n}\n\nexport interface RPCResponse {\n readonly jsonrpc: \"2.0\";\n readonly id: number;\n readonly result?: unknown;\n readonly error?: RPCError;\n}\n\nexport interface InitializeParams {\n readonly sdk_name: string;\n readonly sdk_version: string;\n readonly protocol_version: number;\n readonly required_capabilities: readonly string[];\n readonly preferred_encoding?: string;\n}\n\nexport interface InitializeResult {\n readonly engine_version: string;\n readonly protocol_version: number;\n readonly capabilities: readonly string[];\n readonly missing: readonly string[];\n readonly compatible: boolean;\n readonly encoding?: string;\n readonly max_concurrent_requests?: number;\n readonly max_trace_size_bytes?: number;\n readonly max_steps_per_trace?: number;\n}\n\nexport interface EvaluateBatchParams {\n readonly trace: Trace;\n readonly assertions: readonly Assertion[];\n}\n\nexport interface EvaluateBatchResult {\n readonly results: readonly AssertionResult[];\n readonly total_cost?: number;\n readonly total_duration_ms?: number;\n}\n\nexport interface ShutdownResult {\n readonly sessions_completed: number;\n readonly assertions_evaluated: number;\n}\n\nexport interface SubmitPluginResultParams {\n readonly trace_id: string;\n readonly plugin_name: string;\n readonly assertion_id: string;\n readonly result: AssertionResult;\n}\n\n// ---------------------------------------------------------------------------\n// Drift detection types\n// ---------------------------------------------------------------------------\n\nexport interface DriftReport {\n readonly assertion_id: string;\n readonly mean: number;\n readonly stddev: number;\n readonly count: number;\n readonly latest_score: number;\n readonly deviation: number;\n readonly status: string;\n}\n\nexport interface QueryDriftParams {\n readonly assertion_id: string;\n readonly window_size: number;\n}\n\nexport interface QueryDriftResult {\n readonly report: DriftReport;\n}\n\n// ---------------------------------------------------------------------------\n// Simulation types\n// ---------------------------------------------------------------------------\n\nexport interface SimulatePersona {\n readonly name: string;\n readonly system_prompt: string;\n readonly style: string;\n readonly temperature: number;\n readonly max_tokens?: number;\n}\n\nexport interface SimulateFaultConfig {\n readonly error_rate: number;\n readonly latency_jitter_ms: number;\n readonly content_corruption: boolean;\n readonly timeout_after_ms: number;\n}\n\nexport interface ConversationMessage {\n readonly role: string;\n readonly content: string;\n}\n\nexport interface GenerateUserMessageParams {\n readonly persona: SimulatePersona;\n readonly conversation_history: readonly ConversationMessage[];\n readonly fault_config?: SimulateFaultConfig;\n}\n\nexport interface GenerateUserMessageResult {\n readonly message: string;\n}\n","import type { ErrorData } from \"./types.js\";\n\nexport class ProtocolError extends Error {\n readonly code: number;\n readonly errorMessage: string;\n readonly data: ErrorData | undefined;\n\n constructor(code: number, message: string, data?: ErrorData) {\n super(message);\n this.name = \"ProtocolError\";\n this.code = code;\n this.errorMessage = message;\n this.data = data;\n }\n}\n\nexport class EngineTimeoutError extends Error {\n readonly method: string;\n readonly timeoutMs: number;\n\n constructor(method: string, timeoutMs: number) {\n super(\n `Engine request '${method}' timed out after ${timeoutMs}ms. ` +\n \"Set ATTEST_ENGINE_TIMEOUT to increase the limit.\",\n );\n this.name = \"EngineTimeoutError\";\n this.method = method;\n this.timeoutMs = timeoutMs;\n }\n}\n","import type { ErrorData, RPCResponse } from \"./types.js\";\nimport { ProtocolError } from \"./errors.js\";\n\n/**\n * Encode a JSON-RPC 2.0 request as an NDJSON line.\n */\nexport function encodeRequest(\n id: number,\n method: string,\n params: Record<string, unknown>,\n): string {\n const msg = {\n jsonrpc: \"2.0\" as const,\n id,\n method,\n params,\n };\n return JSON.stringify(msg) + \"\\n\";\n}\n\n/**\n * Decode a JSON-RPC 2.0 response from an NDJSON line.\n * Throws ProtocolError if the response contains an error.\n * Throws Error for malformed JSON or invalid responses.\n */\nexport function decodeResponse(line: string): RPCResponse {\n const text = line.trim();\n if (!text) {\n throw new Error(\"empty response line\");\n }\n\n let data: unknown;\n try {\n data = JSON.parse(text);\n } catch (e) {\n throw new Error(`malformed JSON response: ${e instanceof Error ? e.message : String(e)}`);\n }\n\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) {\n throw new Error(`expected JSON object, got ${Array.isArray(data) ? \"array\" : typeof data}`);\n }\n\n const obj = data as Record<string, unknown>;\n\n if (obj.jsonrpc !== \"2.0\") {\n throw new Error(`invalid jsonrpc version: ${String(obj.jsonrpc)}`);\n }\n\n if (obj.error != null) {\n const err = obj.error as Record<string, unknown>;\n let errorData: ErrorData | undefined;\n\n if (err.data != null) {\n const raw = err.data as Record<string, unknown>;\n errorData = {\n error_type: (raw.error_type as string) ?? \"\",\n retryable: (raw.retryable as boolean) ?? false,\n detail: (raw.detail as string) ?? \"\",\n };\n }\n\n throw new ProtocolError(\n (err.code as number) ?? -1,\n (err.message as string) ?? \"unknown error\",\n errorData,\n );\n }\n\n return obj as unknown as RPCResponse;\n}\n\n/**\n * Extract the result field from a decoded response.\n */\nexport function extractResult(response: RPCResponse): unknown {\n if (response.result === undefined) {\n throw new Error(\"response missing 'result' field\");\n }\n return response.result;\n}\n\n/**\n * Extract the request ID from a decoded response.\n */\nexport function extractId(response: RPCResponse): number {\n if (response.id === undefined) {\n throw new Error(\"response missing 'id' field\");\n }\n return Number(response.id);\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,269 @@
1
+ declare const STEP_LLM_CALL: "llm_call";
2
+ declare const STEP_TOOL_CALL: "tool_call";
3
+ declare const STEP_RETRIEVAL: "retrieval";
4
+ declare const STEP_AGENT_CALL: "agent_call";
5
+ declare const STATUS_PASS: "pass";
6
+ declare const STATUS_SOFT_FAIL: "soft_fail";
7
+ declare const STATUS_HARD_FAIL: "hard_fail";
8
+ declare const TYPE_SCHEMA: "schema";
9
+ declare const TYPE_CONSTRAINT: "constraint";
10
+ declare const TYPE_TRACE: "trace";
11
+ declare const TYPE_CONTENT: "content";
12
+ declare const TYPE_EMBEDDING: "embedding";
13
+ declare const TYPE_LLM_JUDGE: "llm_judge";
14
+ declare const TYPE_TRACE_TREE: "trace_tree";
15
+ declare const TYPE_PLUGIN: "plugin";
16
+ declare const ERR_INVALID_TRACE: 1001;
17
+ declare const ERR_ASSERTION_ERROR: 1002;
18
+ declare const ERR_PROVIDER_ERROR: 2001;
19
+ declare const ERR_ENGINE_ERROR: 3001;
20
+ declare const ERR_TIMEOUT: 3002;
21
+ declare const ERR_SESSION_ERROR: 3003;
22
+
23
+ declare const __brand: unique symbol;
24
+ type Brand<T, B extends string> = T & {
25
+ readonly [__brand]: B;
26
+ };
27
+ type TraceId = Brand<string, "TraceId">;
28
+ type AssertionId = Brand<string, "AssertionId">;
29
+ type AgentId = Brand<string, "AgentId">;
30
+ declare function traceId(id: string): TraceId;
31
+ declare function assertionId(id: string): AssertionId;
32
+ declare function agentId(id: string): AgentId;
33
+ interface SchemaSpec {
34
+ readonly type: "schema";
35
+ readonly target: string;
36
+ readonly schema: Record<string, unknown>;
37
+ }
38
+ interface ConstraintSpec {
39
+ readonly type: "constraint";
40
+ readonly field: string;
41
+ readonly operator: string;
42
+ readonly value?: number;
43
+ readonly min?: number;
44
+ readonly max?: number;
45
+ readonly soft: boolean;
46
+ }
47
+ interface TraceSpec {
48
+ readonly type: "trace";
49
+ readonly check: string;
50
+ readonly tools?: string[];
51
+ readonly tool?: string;
52
+ readonly max_repetitions?: number;
53
+ readonly soft: boolean;
54
+ }
55
+ interface ContentSpec {
56
+ readonly type: "content";
57
+ readonly target: string;
58
+ readonly check: string;
59
+ readonly value?: string;
60
+ readonly values?: string[];
61
+ readonly case_sensitive?: boolean;
62
+ readonly soft?: boolean;
63
+ }
64
+ interface EmbeddingSpec {
65
+ readonly type: "embedding";
66
+ readonly target: string;
67
+ readonly reference: string;
68
+ readonly threshold: number | "dynamic";
69
+ readonly model?: string;
70
+ readonly soft: boolean;
71
+ }
72
+ interface LlmJudgeSpec {
73
+ readonly type: "llm_judge";
74
+ readonly target: string;
75
+ readonly criteria: string;
76
+ readonly rubric: string;
77
+ readonly threshold: number | "dynamic";
78
+ readonly model?: string;
79
+ readonly soft: boolean;
80
+ }
81
+ interface TraceTreeSpec {
82
+ readonly type: "trace_tree";
83
+ readonly check: string;
84
+ readonly [key: string]: unknown;
85
+ }
86
+ interface PluginSpec {
87
+ readonly type: "plugin";
88
+ readonly plugin_id: string;
89
+ readonly config?: Record<string, unknown>;
90
+ readonly soft: boolean;
91
+ }
92
+ type AssertionSpec = SchemaSpec | ConstraintSpec | TraceSpec | ContentSpec | EmbeddingSpec | LlmJudgeSpec | TraceTreeSpec | PluginSpec;
93
+ interface TraceMetadata {
94
+ readonly total_tokens?: number;
95
+ readonly cost_usd?: number;
96
+ readonly latency_ms?: number;
97
+ readonly model?: string;
98
+ readonly timestamp?: string;
99
+ }
100
+ interface Step {
101
+ readonly type: string;
102
+ readonly name: string;
103
+ readonly args?: Record<string, unknown>;
104
+ readonly result?: Record<string, unknown>;
105
+ readonly sub_trace?: Trace;
106
+ readonly metadata?: Record<string, unknown>;
107
+ readonly started_at_ms?: number;
108
+ readonly ended_at_ms?: number;
109
+ readonly agent_id?: string;
110
+ readonly agent_role?: string;
111
+ }
112
+ interface Trace {
113
+ readonly trace_id: string;
114
+ readonly output: Record<string, unknown>;
115
+ readonly schema_version?: number;
116
+ readonly agent_id?: string;
117
+ readonly input?: Record<string, unknown>;
118
+ readonly steps: readonly Step[];
119
+ readonly metadata?: TraceMetadata;
120
+ readonly parent_trace_id?: string;
121
+ }
122
+ interface Assertion {
123
+ readonly assertion_id: string;
124
+ readonly type: string;
125
+ readonly spec: Record<string, unknown>;
126
+ readonly request_id?: string;
127
+ }
128
+ interface AssertionResult {
129
+ readonly assertion_id: string;
130
+ readonly status: string;
131
+ readonly score: number;
132
+ readonly explanation: string;
133
+ readonly cost?: number;
134
+ readonly duration_ms?: number;
135
+ readonly request_id?: string;
136
+ }
137
+ interface ErrorData {
138
+ readonly error_type: string;
139
+ readonly retryable: boolean;
140
+ readonly detail: string;
141
+ }
142
+ interface RPCError {
143
+ readonly code: number;
144
+ readonly message: string;
145
+ readonly data?: ErrorData;
146
+ }
147
+ interface RPCRequest {
148
+ readonly jsonrpc: "2.0";
149
+ readonly id: number;
150
+ readonly method: string;
151
+ readonly params: Record<string, unknown>;
152
+ }
153
+ interface RPCResponse {
154
+ readonly jsonrpc: "2.0";
155
+ readonly id: number;
156
+ readonly result?: unknown;
157
+ readonly error?: RPCError;
158
+ }
159
+ interface InitializeParams {
160
+ readonly sdk_name: string;
161
+ readonly sdk_version: string;
162
+ readonly protocol_version: number;
163
+ readonly required_capabilities: readonly string[];
164
+ readonly preferred_encoding?: string;
165
+ }
166
+ interface InitializeResult {
167
+ readonly engine_version: string;
168
+ readonly protocol_version: number;
169
+ readonly capabilities: readonly string[];
170
+ readonly missing: readonly string[];
171
+ readonly compatible: boolean;
172
+ readonly encoding?: string;
173
+ readonly max_concurrent_requests?: number;
174
+ readonly max_trace_size_bytes?: number;
175
+ readonly max_steps_per_trace?: number;
176
+ }
177
+ interface EvaluateBatchParams {
178
+ readonly trace: Trace;
179
+ readonly assertions: readonly Assertion[];
180
+ }
181
+ interface EvaluateBatchResult {
182
+ readonly results: readonly AssertionResult[];
183
+ readonly total_cost?: number;
184
+ readonly total_duration_ms?: number;
185
+ }
186
+ interface ShutdownResult {
187
+ readonly sessions_completed: number;
188
+ readonly assertions_evaluated: number;
189
+ }
190
+ interface SubmitPluginResultParams {
191
+ readonly trace_id: string;
192
+ readonly plugin_name: string;
193
+ readonly assertion_id: string;
194
+ readonly result: AssertionResult;
195
+ }
196
+ interface DriftReport {
197
+ readonly assertion_id: string;
198
+ readonly mean: number;
199
+ readonly stddev: number;
200
+ readonly count: number;
201
+ readonly latest_score: number;
202
+ readonly deviation: number;
203
+ readonly status: string;
204
+ }
205
+ interface QueryDriftParams {
206
+ readonly assertion_id: string;
207
+ readonly window_size: number;
208
+ }
209
+ interface QueryDriftResult {
210
+ readonly report: DriftReport;
211
+ }
212
+ interface SimulatePersona {
213
+ readonly name: string;
214
+ readonly system_prompt: string;
215
+ readonly style: string;
216
+ readonly temperature: number;
217
+ readonly max_tokens?: number;
218
+ }
219
+ interface SimulateFaultConfig {
220
+ readonly error_rate: number;
221
+ readonly latency_jitter_ms: number;
222
+ readonly content_corruption: boolean;
223
+ readonly timeout_after_ms: number;
224
+ }
225
+ interface ConversationMessage {
226
+ readonly role: string;
227
+ readonly content: string;
228
+ }
229
+ interface GenerateUserMessageParams {
230
+ readonly persona: SimulatePersona;
231
+ readonly conversation_history: readonly ConversationMessage[];
232
+ readonly fault_config?: SimulateFaultConfig;
233
+ }
234
+ interface GenerateUserMessageResult {
235
+ readonly message: string;
236
+ }
237
+
238
+ declare class ProtocolError extends Error {
239
+ readonly code: number;
240
+ readonly errorMessage: string;
241
+ readonly data: ErrorData | undefined;
242
+ constructor(code: number, message: string, data?: ErrorData);
243
+ }
244
+ declare class EngineTimeoutError extends Error {
245
+ readonly method: string;
246
+ readonly timeoutMs: number;
247
+ constructor(method: string, timeoutMs: number);
248
+ }
249
+
250
+ /**
251
+ * Encode a JSON-RPC 2.0 request as an NDJSON line.
252
+ */
253
+ declare function encodeRequest(id: number, method: string, params: Record<string, unknown>): string;
254
+ /**
255
+ * Decode a JSON-RPC 2.0 response from an NDJSON line.
256
+ * Throws ProtocolError if the response contains an error.
257
+ * Throws Error for malformed JSON or invalid responses.
258
+ */
259
+ declare function decodeResponse(line: string): RPCResponse;
260
+ /**
261
+ * Extract the result field from a decoded response.
262
+ */
263
+ declare function extractResult(response: RPCResponse): unknown;
264
+ /**
265
+ * Extract the request ID from a decoded response.
266
+ */
267
+ declare function extractId(response: RPCResponse): number;
268
+
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 };
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry point for Attest: npx attest or attest (after global install).
4
+ *
5
+ * Ported from Python sdks/python/src/attest/__main__.py
6
+ */
7
+ declare function main(argv?: string[]): void;
8
+
9
+ export { main };
@@ -0,0 +1,154 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
+ import * as os from "os";
7
+
8
+ // src/version.ts
9
+ var VERSION = "0.6.0";
10
+
11
+ // src/cli.ts
12
+ function cacheDir() {
13
+ const envOverride = process.env["ATTEST_CACHE_DIR"];
14
+ if (envOverride) return envOverride;
15
+ return path.join(os.homedir(), ".attest", "cache");
16
+ }
17
+ function cacheDbPath() {
18
+ return path.join(cacheDir(), "attest.db");
19
+ }
20
+ function cmdCacheStats() {
21
+ const dbPath = cacheDbPath();
22
+ const exists = fs.existsSync(dbPath);
23
+ let fileSize = 0;
24
+ if (exists) {
25
+ fileSize = fs.statSync(dbPath).size;
26
+ }
27
+ const stats = { exists, file_size: fileSize, path: dbPath };
28
+ process.stdout.write(JSON.stringify(stats) + "\n");
29
+ }
30
+ function cmdCacheClear() {
31
+ const dbPath = cacheDbPath();
32
+ if (fs.existsSync(dbPath)) {
33
+ fs.unlinkSync(dbPath);
34
+ process.stdout.write(`Cleared cache: ${dbPath}
35
+ `);
36
+ } else {
37
+ process.stdout.write(`No cache to clear: ${dbPath}
38
+ `);
39
+ }
40
+ }
41
+ var CONFTEST_TEMPLATE = `import { describe, it, expect } from "vitest";
42
+ import { attestExpect, TraceBuilder } from "@attest-ai/core";
43
+
44
+ describe("my agent", () => {
45
+ it("returns expected output", async () => {
46
+ const trace = new TraceBuilder("my-agent")
47
+ .setInput({ user_message: "hello" })
48
+ .setOutput({ message: "world" })
49
+ .build();
50
+
51
+ attestExpect(trace).outputContains("world");
52
+ });
53
+ });
54
+ `;
55
+ function cmdInit(targetDir) {
56
+ const testsDir = path.join(targetDir, "tests");
57
+ fs.mkdirSync(testsDir, { recursive: true });
58
+ process.stdout.write(`Directory: ${testsDir}
59
+ `);
60
+ const sampleTestPath = path.join(testsDir, "test_my_agent.test.ts");
61
+ if (fs.existsSync(sampleTestPath)) {
62
+ process.stderr.write(`Skipped (exists): ${sampleTestPath}
63
+ `);
64
+ } else {
65
+ fs.writeFileSync(sampleTestPath, CONFTEST_TEMPLATE);
66
+ process.stdout.write(`Created: ${sampleTestPath}
67
+ `);
68
+ }
69
+ }
70
+ function cmdValidate(targetDir) {
71
+ const testsDir = path.join(targetDir, "tests");
72
+ let testFiles = [];
73
+ if (fs.existsSync(testsDir)) {
74
+ testFiles = fs.readdirSync(testsDir).filter((f) => f.endsWith(".test.ts") || f.endsWith(".test.js"));
75
+ }
76
+ if (testFiles.length === 0) {
77
+ process.stderr.write(
78
+ `Warning: no test files (*.test.ts / *.test.js) found in ${testsDir}.
79
+ `
80
+ );
81
+ } else {
82
+ process.stdout.write(`Found ${testFiles.length} test file(s) in ${testsDir}
83
+ `);
84
+ }
85
+ const STALE_DAYS = 30;
86
+ const now = Date.now();
87
+ const goldenFiles = findGoldenFiles(targetDir);
88
+ for (const golden of goldenFiles) {
89
+ const mtime = fs.statSync(golden).mtimeMs;
90
+ const ageDays = Math.floor((now - mtime) / (1e3 * 60 * 60 * 24));
91
+ if (ageDays > STALE_DAYS) {
92
+ process.stderr.write(
93
+ `Warning: golden trace ${golden} is ${ageDays} days old (>${STALE_DAYS} days). Consider regenerating.
94
+ `
95
+ );
96
+ }
97
+ }
98
+ }
99
+ function findGoldenFiles(dir) {
100
+ const results = [];
101
+ if (!fs.existsSync(dir)) return results;
102
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
103
+ for (const entry of entries) {
104
+ const fullPath = path.join(dir, entry.name);
105
+ if (entry.isDirectory() && entry.name !== "node_modules") {
106
+ results.push(...findGoldenFiles(fullPath));
107
+ } else if (entry.isFile() && entry.name.endsWith(".golden")) {
108
+ results.push(fullPath);
109
+ }
110
+ }
111
+ return results;
112
+ }
113
+ function main(argv = process.argv.slice(2)) {
114
+ const args = argv;
115
+ if (args[0] === "--version") {
116
+ process.stdout.write(`attest ${VERSION}
117
+ `);
118
+ process.exit(0);
119
+ }
120
+ if (args[0] === "cache" && args.length >= 2) {
121
+ if (args[1] === "stats") {
122
+ cmdCacheStats();
123
+ process.exit(0);
124
+ } else if (args[1] === "clear") {
125
+ cmdCacheClear();
126
+ process.exit(0);
127
+ } else {
128
+ process.stderr.write(`Unknown cache subcommand: ${args[1]}
129
+ `);
130
+ process.stderr.write("Available: cache stats, cache clear\n");
131
+ process.exit(1);
132
+ }
133
+ }
134
+ if (args[0] === "init") {
135
+ cmdInit(process.cwd());
136
+ process.exit(0);
137
+ }
138
+ if (args[0] === "validate") {
139
+ cmdValidate(process.cwd());
140
+ process.exit(0);
141
+ }
142
+ process.stderr.write(
143
+ "Usage: attest <command>\n\nCommands:\n --version Print version\n init Scaffold a test project\n validate Validate test suite\n cache stats Show cache statistics\n cache clear Clear cache database\n"
144
+ );
145
+ process.exit(args.length === 0 ? 0 : 1);
146
+ }
147
+ var isDirectExecution = typeof import.meta.url === "string" && import.meta.url.startsWith("file:") && process.argv[1] !== void 0 && import.meta.url.endsWith(path.basename(process.argv[1]));
148
+ if (isDirectExecution) {
149
+ main();
150
+ }
151
+ export {
152
+ main
153
+ };
154
+ //# sourceMappingURL=cli.js.map