@attest-ai/core 0.4.2 → 0.5.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 (43) hide show
  1. package/dist/cjs/index.cjs +2484 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.cts +1085 -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 +228 -0
  7. package/dist/client.d.ts +7 -3
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +48 -9
  10. package/dist/client.js.map +1 -1
  11. package/dist/config.d.ts +21 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +31 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/delegate.d.ts.map +1 -1
  16. package/dist/delegate.js +1 -7
  17. package/dist/delegate.js.map +1 -1
  18. package/dist/esm/cli.d.ts +9 -0
  19. package/dist/esm/cli.js +154 -0
  20. package/dist/esm/cli.js.map +1 -0
  21. package/dist/esm/index.d.ts +1085 -0
  22. package/dist/esm/index.js +2385 -0
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/esm/proto/index.d.ts +228 -0
  25. package/dist/esm/proto/index.js +152 -0
  26. package/dist/esm/proto/index.js.map +1 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/proto/errors.d.ts +5 -0
  32. package/dist/proto/errors.d.ts.map +1 -1
  33. package/dist/proto/errors.js +11 -0
  34. package/dist/proto/errors.js.map +1 -1
  35. package/dist/simulation.d.ts +8 -0
  36. package/dist/simulation.d.ts.map +1 -0
  37. package/dist/simulation.js +21 -0
  38. package/dist/simulation.js.map +1 -0
  39. package/dist/trace.d.ts +1 -0
  40. package/dist/trace.d.ts.map +1 -1
  41. package/dist/trace.js +3 -0
  42. package/dist/trace.js.map +1 -1
  43. package/package.json +34 -8
@@ -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;\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;\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","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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAGxB,IAAM,cAAc;AACpB,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AAGzB,IAAM,cAAc;AACpB,IAAM,kBAAkB;AACxB,IAAM,aAAa;AACnB,IAAM,eAAe;AACrB,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AACxB,IAAM,cAAc;AAGpB,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAC5B,IAAM,qBAAqB;AAC3B,IAAM,mBAAmB;AACzB,IAAM,cAAc;AACpB,IAAM,oBAAoB;;;AChB1B,SAAS,QAAQ,IAAqB;AAC3C,SAAO;AACT;AAEO,SAAS,YAAY,IAAyB;AACnD,SAAO;AACT;AAEO,SAAS,QAAQ,IAAqB;AAC3C,SAAO;AACT;;;ACnBO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAc,SAAiB,MAAkB;AAC3D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACnC;AAAA,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B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAKO,SAAS,cAAc,UAAgC;AAC5D,MAAI,SAAS,WAAW,QAAW;AACjC,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACA,SAAO,SAAS;AAClB;AAKO,SAAS,UAAU,UAA+B;AACvD,MAAI,SAAS,OAAO,QAAW;AAC7B,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,SAAO,OAAO,SAAS,EAAE;AAC3B;","names":[]}
@@ -0,0 +1,228 @@
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;
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;
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
+
197
+ declare class ProtocolError extends Error {
198
+ readonly code: number;
199
+ readonly errorMessage: string;
200
+ readonly data: ErrorData | undefined;
201
+ constructor(code: number, message: string, data?: ErrorData);
202
+ }
203
+ declare class EngineTimeoutError extends Error {
204
+ readonly method: string;
205
+ readonly timeoutMs: number;
206
+ constructor(method: string, timeoutMs: number);
207
+ }
208
+
209
+ /**
210
+ * Encode a JSON-RPC 2.0 request as an NDJSON line.
211
+ */
212
+ declare function encodeRequest(id: number, method: string, params: Record<string, unknown>): string;
213
+ /**
214
+ * Decode a JSON-RPC 2.0 response from an NDJSON line.
215
+ * Throws ProtocolError if the response contains an error.
216
+ * Throws Error for malformed JSON or invalid responses.
217
+ */
218
+ declare function decodeResponse(line: string): RPCResponse;
219
+ /**
220
+ * Extract the result field from a decoded response.
221
+ */
222
+ declare function extractResult(response: RPCResponse): unknown;
223
+ /**
224
+ * Extract the request ID from a decoded response.
225
+ */
226
+ declare function extractId(response: RPCResponse): number;
227
+
228
+ export { type AgentId, type Assertion, type AssertionId, type AssertionResult, type AssertionSpec, type ConstraintSpec, type ContentSpec, 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 InitializeParams, type InitializeResult, type LlmJudgeSpec, type PluginSpec, ProtocolError, 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 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 };
package/dist/client.d.ts CHANGED
@@ -12,8 +12,12 @@ export declare class AttestClient {
12
12
  stopReader(): void;
13
13
  private handleLine;
14
14
  private failAll;
15
- sendRequest(method: string, params: Record<string, unknown>): Promise<unknown>;
16
- evaluateBatch(trace: Trace, assertions: readonly Assertion[]): Promise<EvaluateBatchResult>;
17
- submitPluginResult(traceId: string, pluginName: string, assertionId: string, status: string, score: number, explanation: string): Promise<boolean>;
15
+ sendRequest(method: string, params: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
16
+ evaluateBatch(trace: Trace, assertions: readonly Assertion[], options?: {
17
+ timeout?: number;
18
+ }): Promise<EvaluateBatchResult>;
19
+ submitPluginResult(traceId: string, pluginName: string, assertionId: string, status: string, score: number, explanation: string, options?: {
20
+ timeout?: number;
21
+ }): Promise<boolean>;
18
22
  }
19
23
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,KAAK,EAEN,MAAM,kBAAkB,CAAC;AAQ1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,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W,CAAyC;gBAEhD,MAAM,EAAE,aAAa;IAIjC,WAAW,IAAI,IAAI;IAkBnB,UAAU,IAAI,IAAI;IAYlB,OAAO,CAAC,UAAU;IAoClB,OAAO,CAAC,OAAO;IAOT,WAAW,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC;IA8Cb,aAAa,CACjB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,mBAAmB,CAAC;IAiBzB,kBAAkB,CACtB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,OAAO,CAAC;CAsBpB"}
package/dist/client.js CHANGED
@@ -1,5 +1,28 @@
1
- import { ProtocolError } from "./proto/errors.js";
1
+ import { ProtocolError, EngineTimeoutError } from "./proto/errors.js";
2
2
  import { decodeResponse, encodeRequest, extractId, extractResult, } from "./proto/codec.js";
3
+ import { isSimulationMode } from "./config.js";
4
+ import { simulationEvaluateBatch } from "./simulation.js";
5
+ const DEFAULT_TIMEOUT_MS = 30_000;
6
+ function resolveTimeoutMs(override) {
7
+ if (override !== undefined)
8
+ return override;
9
+ const env = process.env["ATTEST_ENGINE_TIMEOUT"];
10
+ if (env !== undefined && env !== "") {
11
+ const parsed = Number(env);
12
+ if (!Number.isFinite(parsed) || parsed <= 0) {
13
+ throw new Error(`ATTEST_ENGINE_TIMEOUT must be a positive number of milliseconds, got: '${env}'`);
14
+ }
15
+ return parsed;
16
+ }
17
+ return DEFAULT_TIMEOUT_MS;
18
+ }
19
+ function makeTimeoutPromise(method, timeoutMs) {
20
+ return new Promise((_, reject) => {
21
+ setTimeout(() => {
22
+ reject(new EngineTimeoutError(method, timeoutMs));
23
+ }, timeoutMs);
24
+ });
25
+ }
3
26
  export class AttestClient {
4
27
  engine;
5
28
  requestId = 0;
@@ -77,20 +100,26 @@ export class AttestClient {
77
100
  }
78
101
  this.pending.clear();
79
102
  }
80
- async sendRequest(method, params) {
103
+ async sendRequest(method, params, timeoutMs) {
104
+ const resolvedTimeout = resolveTimeoutMs(timeoutMs);
81
105
  if (!this.readerActive) {
82
- // Delegate to engine sequential mode
83
- return this.engine.sendRequest(method, params);
106
+ // Delegate to engine sequential mode with timeout
107
+ return Promise.race([
108
+ this.engine.sendRequest(method, params),
109
+ makeTimeoutPromise(method, resolvedTimeout),
110
+ ]);
84
111
  }
85
112
  const cp = this.engine.childProcess;
86
113
  if (cp === null || cp.stdin === null) {
87
114
  throw new Error("Engine process not started.");
88
115
  }
89
- return new Promise((resolve, reject) => {
116
+ let capturedReqId;
117
+ const requestPromise = new Promise((resolve, reject) => {
90
118
  // Serialize writes through promise chain
91
119
  this.writeChain = this.writeChain.then(() => {
92
120
  this.requestId += 1;
93
121
  const reqId = this.requestId;
122
+ capturedReqId = reqId;
94
123
  this.pending.set(reqId, { resolve, reject });
95
124
  const requestStr = encodeRequest(reqId, method, params);
96
125
  cp.stdin.write(requestStr, (err) => {
@@ -101,16 +130,26 @@ export class AttestClient {
101
130
  });
102
131
  });
103
132
  });
133
+ const timeoutPromise = makeTimeoutPromise(method, resolvedTimeout);
134
+ return Promise.race([requestPromise, timeoutPromise]).catch((err) => {
135
+ if (err instanceof EngineTimeoutError && capturedReqId !== undefined) {
136
+ this.pending.delete(capturedReqId);
137
+ }
138
+ throw err;
139
+ });
104
140
  }
105
- async evaluateBatch(trace, assertions) {
141
+ async evaluateBatch(trace, assertions, options) {
142
+ if (isSimulationMode()) {
143
+ return simulationEvaluateBatch(assertions);
144
+ }
106
145
  const params = {
107
146
  trace,
108
147
  assertions: [...assertions],
109
148
  };
110
- const raw = await this.sendRequest("evaluate_batch", params);
149
+ const raw = await this.sendRequest("evaluate_batch", params, options?.timeout);
111
150
  return raw;
112
151
  }
113
- async submitPluginResult(traceId, pluginName, assertionId, status, score, explanation) {
152
+ async submitPluginResult(traceId, pluginName, assertionId, status, score, explanation, options) {
114
153
  const result = {
115
154
  assertion_id: assertionId,
116
155
  status,
@@ -125,7 +164,7 @@ export class AttestClient {
125
164
  assertion_id: assertionId,
126
165
  result,
127
166
  };
128
- const raw = await this.sendRequest("submit_plugin_result", params);
167
+ const raw = await this.sendRequest("submit_plugin_result", params, options?.timeout);
129
168
  return Boolean(raw?.accepted ?? false);
130
169
  }
131
170
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACL,cAAc,EACd,aAAa,EACb,SAAS,EACT,aAAa,GACd,MAAM,kBAAkB,CAAC;AAQ1B,MAAM,OAAO,YAAY;IACN,MAAM,CAAgB;IAC/B,SAAS,GAAG,CAAC,CAAC;IACL,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IACrD,UAAU,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC9C,YAAY,GAAG,KAAK,CAAC;IACrB,WAAW,GAAoC,IAAI,CAAC;IAE5D,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO;QAE9B,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QACzC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;QACzF,CAAC;QAED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AC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,KAAY,EACZ,UAAgC,EAChC,OAA8B;QAE9B,IAAI,gBAAgB,EAAE,EAAE,CAAC;YACvB,OAAO,uBAAuB,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,MAAM,GAAG;YACb,KAAK;YACL,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC;SAC5B,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,WAAW,CAChC,gBAAgB,EAChB,MAAiC,EACjC,OAAO,EAAE,OAAO,CACjB,CAAC;QACF,OAAO,GAA0B,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,OAAe,EACf,UAAkB,EAClB,WAAmB,EACnB,MAAc,EACd,KAAa,EACb,WAAmB,EACnB,OAA8B;QAE9B,MAAM,MAAM,GAAoB;YAC9B,YAAY,EAAE,WAAW;YACzB,MAAM;YACN,KAAK;YACL,WAAW;YACX,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,CAAC;SACf,CAAC;QACF,MAAM,MAAM,GAAG;YACb,QAAQ,EAAE,OAAO;YACjB,WAAW,EAAE,UAAU;YACvB,YAAY,EAAE,WAAW;YACzB,MAAM;SACP,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,WAAW,CAChC,sBAAsB,EACtB,MAAiC,EACjC,OAAO,EAAE,OAAO,CACjB,CAAC;QACF,OAAO,OAAO,CAAE,GAA+B,EAAE,QAAQ,IAAI,KAAK,CAAC,CAAC;IACtE,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Configure global SDK options.
3
+ *
4
+ * @param options.simulation - Enable simulation mode. All `evaluateBatch` calls
5
+ * return deterministic pass results without spawning the engine or calling any
6
+ * LLM. Equivalent to setting `ATTEST_SIMULATION=1` in the environment.
7
+ */
8
+ export declare function config(options: {
9
+ simulation?: boolean;
10
+ }): void;
11
+ /**
12
+ * Returns true when simulation mode is active via either the programmatic API
13
+ * or the `ATTEST_SIMULATION` environment variable.
14
+ */
15
+ export declare function isSimulationMode(): boolean;
16
+ /**
17
+ * Reset all programmatic config to defaults. Primarily for use in tests.
18
+ * Environment variables are not affected.
19
+ */
20
+ export declare function resetConfig(): void;
21
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAI9D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAO1C;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
package/dist/config.js ADDED
@@ -0,0 +1,31 @@
1
+ let _simulationMode = false;
2
+ /**
3
+ * Configure global SDK options.
4
+ *
5
+ * @param options.simulation - Enable simulation mode. All `evaluateBatch` calls
6
+ * return deterministic pass results without spawning the engine or calling any
7
+ * LLM. Equivalent to setting `ATTEST_SIMULATION=1` in the environment.
8
+ */
9
+ export function config(options) {
10
+ if (options.simulation !== undefined) {
11
+ _simulationMode = options.simulation;
12
+ }
13
+ }
14
+ /**
15
+ * Returns true when simulation mode is active via either the programmatic API
16
+ * or the `ATTEST_SIMULATION` environment variable.
17
+ */
18
+ export function isSimulationMode() {
19
+ return (_simulationMode ||
20
+ process.env["ATTEST_SIMULATION"] === "1" ||
21
+ process.env["ATTEST_SIMULATION"] === "true" ||
22
+ process.env["ATTEST_SIMULATION"] === "yes");
23
+ }
24
+ /**
25
+ * Reset all programmatic config to defaults. Primarily for use in tests.
26
+ * Environment variables are not affected.
27
+ */
28
+ export function resetConfig() {
29
+ _simulationMode = false;
30
+ }
31
+ //# sourceMappingURL=config.js.map