@attest-ai/core 0.5.0 → 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 (121) hide show
  1. package/dist/cjs/index.cjs +113 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.cts +33 -7
  4. package/dist/cjs/proto/index.cjs.map +1 -1
  5. package/dist/cjs/proto/index.d.cts +44 -3
  6. package/dist/esm/cli.js +1 -1
  7. package/dist/esm/cli.js.map +1 -1
  8. package/dist/esm/index.d.ts +33 -7
  9. package/dist/esm/index.js +107 -2
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/proto/index.d.ts +44 -3
  12. package/dist/esm/proto/index.js.map +1 -1
  13. package/package.json +4 -4
  14. package/dist/adapters/anthropic.d.ts +0 -31
  15. package/dist/adapters/anthropic.d.ts.map +0 -1
  16. package/dist/adapters/anthropic.js +0 -42
  17. package/dist/adapters/anthropic.js.map +0 -1
  18. package/dist/adapters/gemini.d.ts +0 -30
  19. package/dist/adapters/gemini.d.ts.map +0 -1
  20. package/dist/adapters/gemini.js +0 -41
  21. package/dist/adapters/gemini.js.map +0 -1
  22. package/dist/adapters/index.d.ts +0 -11
  23. package/dist/adapters/index.d.ts.map +0 -1
  24. package/dist/adapters/index.js +0 -7
  25. package/dist/adapters/index.js.map +0 -1
  26. package/dist/adapters/manual.d.ts +0 -9
  27. package/dist/adapters/manual.d.ts.map +0 -1
  28. package/dist/adapters/manual.js +0 -16
  29. package/dist/adapters/manual.js.map +0 -1
  30. package/dist/adapters/ollama.d.ts +0 -19
  31. package/dist/adapters/ollama.d.ts.map +0 -1
  32. package/dist/adapters/ollama.js +0 -30
  33. package/dist/adapters/ollama.js.map +0 -1
  34. package/dist/adapters/openai.d.ts +0 -34
  35. package/dist/adapters/openai.d.ts.map +0 -1
  36. package/dist/adapters/openai.js +0 -42
  37. package/dist/adapters/openai.js.map +0 -1
  38. package/dist/adapters/otel.d.ts +0 -25
  39. package/dist/adapters/otel.d.ts.map +0 -1
  40. package/dist/adapters/otel.js +0 -133
  41. package/dist/adapters/otel.js.map +0 -1
  42. package/dist/agent.d.ts +0 -14
  43. package/dist/agent.d.ts.map +0 -1
  44. package/dist/agent.js +0 -54
  45. package/dist/agent.js.map +0 -1
  46. package/dist/client.d.ts +0 -23
  47. package/dist/client.d.ts.map +0 -1
  48. package/dist/client.js +0 -171
  49. package/dist/client.js.map +0 -1
  50. package/dist/config.d.ts +0 -21
  51. package/dist/config.d.ts.map +0 -1
  52. package/dist/config.js +0 -31
  53. package/dist/config.js.map +0 -1
  54. package/dist/context.d.ts +0 -4
  55. package/dist/context.d.ts.map +0 -1
  56. package/dist/context.js +0 -3
  57. package/dist/context.js.map +0 -1
  58. package/dist/delegate.d.ts +0 -3
  59. package/dist/delegate.d.ts.map +0 -1
  60. package/dist/delegate.js +0 -24
  61. package/dist/delegate.js.map +0 -1
  62. package/dist/engine-downloader.d.ts +0 -7
  63. package/dist/engine-downloader.d.ts.map +0 -1
  64. package/dist/engine-downloader.js +0 -136
  65. package/dist/engine-downloader.js.map +0 -1
  66. package/dist/engine-manager.d.ts +0 -26
  67. package/dist/engine-manager.d.ts.map +0 -1
  68. package/dist/engine-manager.js +0 -172
  69. package/dist/engine-manager.js.map +0 -1
  70. package/dist/expect.d.ts +0 -133
  71. package/dist/expect.d.ts.map +0 -1
  72. package/dist/expect.js +0 -330
  73. package/dist/expect.js.map +0 -1
  74. package/dist/index.d.ts +0 -16
  75. package/dist/index.d.ts.map +0 -1
  76. package/dist/index.js +0 -15
  77. package/dist/index.js.map +0 -1
  78. package/dist/proto/codec.d.ts +0 -20
  79. package/dist/proto/codec.d.ts.map +0 -1
  80. package/dist/proto/codec.js +0 -71
  81. package/dist/proto/codec.js.map +0 -1
  82. package/dist/proto/constants.d.ts +0 -21
  83. package/dist/proto/constants.d.ts.map +0 -1
  84. package/dist/proto/constants.js +0 -25
  85. package/dist/proto/constants.js.map +0 -1
  86. package/dist/proto/errors.d.ts +0 -13
  87. package/dist/proto/errors.d.ts.map +0 -1
  88. package/dist/proto/errors.js +0 -24
  89. package/dist/proto/errors.js.map +0 -1
  90. package/dist/proto/index.d.ts +0 -5
  91. package/dist/proto/index.d.ts.map +0 -1
  92. package/dist/proto/index.js +0 -5
  93. package/dist/proto/index.js.map +0 -1
  94. package/dist/proto/types.d.ts +0 -104
  95. package/dist/proto/types.d.ts.map +0 -1
  96. package/dist/proto/types.js +0 -2
  97. package/dist/proto/types.js.map +0 -1
  98. package/dist/result.d.ts +0 -15
  99. package/dist/result.d.ts.map +0 -1
  100. package/dist/result.js +0 -32
  101. package/dist/result.js.map +0 -1
  102. package/dist/simulation.d.ts +0 -8
  103. package/dist/simulation.d.ts.map +0 -1
  104. package/dist/simulation.js +0 -21
  105. package/dist/simulation.js.map +0 -1
  106. package/dist/tier.d.ts +0 -5
  107. package/dist/tier.d.ts.map +0 -1
  108. package/dist/tier.js +0 -10
  109. package/dist/tier.js.map +0 -1
  110. package/dist/trace-tree.d.ts +0 -20
  111. package/dist/trace-tree.d.ts.map +0 -1
  112. package/dist/trace-tree.js +0 -92
  113. package/dist/trace-tree.js.map +0 -1
  114. package/dist/trace.d.ts +0 -41
  115. package/dist/trace.d.ts.map +0 -1
  116. package/dist/trace.js +0 -88
  117. package/dist/trace.js.map +0 -1
  118. package/dist/version.d.ts +0 -3
  119. package/dist/version.d.ts.map +0 -1
  120. package/dist/version.js +0 -3
  121. package/dist/version.js.map +0 -1
@@ -65,7 +65,7 @@ interface EmbeddingSpec {
65
65
  readonly type: "embedding";
66
66
  readonly target: string;
67
67
  readonly reference: string;
68
- readonly threshold: number;
68
+ readonly threshold: number | "dynamic";
69
69
  readonly model?: string;
70
70
  readonly soft: boolean;
71
71
  }
@@ -74,7 +74,7 @@ interface LlmJudgeSpec {
74
74
  readonly target: string;
75
75
  readonly criteria: string;
76
76
  readonly rubric: string;
77
- readonly threshold: number;
77
+ readonly threshold: number | "dynamic";
78
78
  readonly model?: string;
79
79
  readonly soft: boolean;
80
80
  }
@@ -193,6 +193,47 @@ interface SubmitPluginResultParams {
193
193
  readonly assertion_id: string;
194
194
  readonly result: AssertionResult;
195
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
+ }
196
237
 
197
238
  declare class ProtocolError extends Error {
198
239
  readonly code: number;
@@ -225,4 +266,4 @@ declare function extractResult(response: RPCResponse): unknown;
225
266
  */
226
267
  declare function extractId(response: RPCResponse): number;
227
268
 
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 };
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 };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/proto/constants.ts","../../../src/proto/types.ts","../../../src/proto/errors.ts","../../../src/proto/codec.ts"],"sourcesContent":["// 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":"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","names":[]}
1
+ {"version":3,"sources":["../../../src/proto/constants.ts","../../../src/proto/types.ts","../../../src/proto/errors.ts","../../../src/proto/codec.ts"],"sourcesContent":["// 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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attest-ai/core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Attest SDK for testing AI agents — protocol types, codec, trace builder, assertion DSL",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.cjs",
@@ -64,10 +64,10 @@
64
64
  }
65
65
  },
66
66
  "devDependencies": {
67
- "@types/node": "^25.3.0",
67
+ "@types/node": "^25.6.0",
68
68
  "tsup": "^8.0.0",
69
- "typescript": "^5.7.0",
70
- "vitest": "^4.0.18"
69
+ "typescript": "^5.9.3",
70
+ "vitest": "^4.1.4"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsup",
@@ -1,31 +0,0 @@
1
- import type { Trace } from "../proto/types.js";
2
- interface AnthropicTextBlock {
3
- type: "text";
4
- text: string;
5
- }
6
- interface AnthropicToolUseBlock {
7
- type: "tool_use";
8
- name: string;
9
- input: Record<string, unknown>;
10
- }
11
- type AnthropicContentBlock = AnthropicTextBlock | AnthropicToolUseBlock;
12
- interface AnthropicUsage {
13
- input_tokens: number;
14
- output_tokens: number;
15
- }
16
- interface AnthropicMessage {
17
- model?: string;
18
- usage?: AnthropicUsage;
19
- content: AnthropicContentBlock[];
20
- }
21
- export declare class AnthropicAdapter {
22
- private readonly agentId;
23
- constructor(agentId?: string);
24
- traceFromResponse(response: AnthropicMessage, options?: {
25
- inputMessages?: Record<string, unknown>[];
26
- costUsd?: number;
27
- latencyMs?: number;
28
- }): Trace;
29
- }
30
- export {};
31
- //# sourceMappingURL=anthropic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/adapters/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,qBAAqB;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,KAAK,qBAAqB,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AAExE,UAAU,cAAc;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,CAAC,EAAE,MAAM;IAI5B,iBAAiB,CACf,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,KAAK;CAwCT"}
@@ -1,42 +0,0 @@
1
- import { TraceBuilder } from "../trace.js";
2
- export class AnthropicAdapter {
3
- agentId;
4
- constructor(agentId) {
5
- this.agentId = agentId;
6
- }
7
- traceFromResponse(response, options) {
8
- const builder = new TraceBuilder(this.agentId);
9
- if (options?.inputMessages) {
10
- builder.setInput({ messages: options.inputMessages });
11
- }
12
- const completionParts = [];
13
- for (const block of response.content) {
14
- if (block.type === "text") {
15
- completionParts.push(block.text);
16
- }
17
- else if (block.type === "tool_use") {
18
- builder.addToolCall(block.name, {
19
- args: block.input,
20
- });
21
- }
22
- }
23
- const completionText = completionParts.join("\n");
24
- const stepArgs = {};
25
- if (response.model !== undefined)
26
- stepArgs.model = response.model;
27
- builder.addLlmCall("completion", { args: stepArgs, result: { completion: completionText } });
28
- builder.setOutput({ message: completionText });
29
- let totalTokens;
30
- if (response.usage) {
31
- totalTokens = response.usage.input_tokens + response.usage.output_tokens;
32
- }
33
- builder.setMetadata({
34
- total_tokens: totalTokens,
35
- cost_usd: options?.costUsd,
36
- latency_ms: options?.latencyMs,
37
- model: response.model,
38
- });
39
- return builder.build();
40
- }
41
- }
42
- //# sourceMappingURL=anthropic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/adapters/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA0B3C,MAAM,OAAO,gBAAgB;IACV,OAAO,CAAqB;IAE7C,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,iBAAiB,CACf,QAA0B,EAC1B,OAIC;QAED,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/C,IAAI,OAAO,EAAE,aAAa,EAAE,CAAC;YAC3B,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,eAAe,GAAa,EAAE,CAAC;QACrC,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACrC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC1B,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;iBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACrC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE;oBAC9B,IAAI,EAAE,KAAK,CAAC,KAAK;iBAClB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAElD,MAAM,QAAQ,GAA4B,EAAE,CAAC;QAC7C,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;YAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QAElE,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;QAC7F,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;QAE/C,IAAI,WAA+B,CAAC;QACpC,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACnB,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC;QAC3E,CAAC;QAED,OAAO,CAAC,WAAW,CAAC;YAClB,YAAY,EAAE,WAAW;YACzB,QAAQ,EAAE,OAAO,EAAE,OAAO;YAC1B,UAAU,EAAE,OAAO,EAAE,SAAS;YAC9B,KAAK,EAAE,QAAQ,CAAC,KAAK;SACtB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -1,30 +0,0 @@
1
- import type { Trace } from "../proto/types.js";
2
- interface GeminiFunctionCall {
3
- name: string;
4
- args?: Record<string, unknown>;
5
- }
6
- interface GeminiPart {
7
- text?: string;
8
- functionCall?: GeminiFunctionCall;
9
- }
10
- interface GeminiCandidate {
11
- content: {
12
- parts: GeminiPart[];
13
- };
14
- }
15
- interface GeminiResponse {
16
- text?: string;
17
- candidates?: GeminiCandidate[];
18
- }
19
- export declare class GeminiAdapter {
20
- private readonly agentId;
21
- constructor(agentId?: string);
22
- traceFromResponse(response: GeminiResponse, options?: {
23
- inputText?: string;
24
- costUsd?: number;
25
- latencyMs?: number;
26
- model?: string;
27
- }): Trace;
28
- }
29
- export {};
30
- //# sourceMappingURL=gemini.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/adapters/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAED,UAAU,eAAe;IACvB,OAAO,EAAE;QAAE,KAAK,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;CAClC;AAED,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;CAChC;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,CAAC,EAAE,MAAM;IAI5B,iBAAiB,CACf,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,KAAK;CAsCT"}
@@ -1,41 +0,0 @@
1
- import { TraceBuilder } from "../trace.js";
2
- export class GeminiAdapter {
3
- agentId;
4
- constructor(agentId) {
5
- this.agentId = agentId;
6
- }
7
- traceFromResponse(response, options) {
8
- const builder = new TraceBuilder(this.agentId);
9
- if (options?.inputText) {
10
- builder.setInput({ text: options.inputText });
11
- }
12
- let completionText = "";
13
- if (response.text != null) {
14
- completionText = response.text;
15
- }
16
- else if (response.candidates && response.candidates.length > 0) {
17
- completionText = response.candidates[0].content.parts
18
- .filter((p) => p.text != null)
19
- .map((p) => p.text)
20
- .join("");
21
- }
22
- if (response.candidates && response.candidates.length > 0) {
23
- for (const part of response.candidates[0].content.parts) {
24
- if (part.functionCall) {
25
- builder.addToolCall(part.functionCall.name, {
26
- args: part.functionCall.args ?? {},
27
- });
28
- }
29
- }
30
- }
31
- builder.addLlmCall("completion", { result: { completion: completionText } });
32
- builder.setOutput({ message: completionText });
33
- builder.setMetadata({
34
- cost_usd: options?.costUsd,
35
- latency_ms: options?.latencyMs,
36
- model: options?.model,
37
- });
38
- return builder.build();
39
- }
40
- }
41
- //# sourceMappingURL=gemini.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/adapters/gemini.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqB3C,MAAM,OAAO,aAAa;IACP,OAAO,CAAqB;IAE7C,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,iBAAiB,CACf,QAAwB,EACxB,OAKC;QAED,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/C,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,cAAc,GAAG,EAAE,CAAC;QACxB,IAAI,QAAQ,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YAC1B,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC;QACjC,CAAC;aAAM,IAAI,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjE,cAAc,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK;iBAClD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC;iBAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAK,CAAC;iBACnB,IAAI,CAAC,EAAE,CAAC,CAAC;QACd,CAAC;QAED,IAAI,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1D,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;gBACxD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACtB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;wBAC1C,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,EAAE;qBACnC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;QAC7E,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;QAE/C,OAAO,CAAC,WAAW,CAAC;YAClB,QAAQ,EAAE,OAAO,EAAE,OAAO;YAC1B,UAAU,EAAE,OAAO,EAAE,SAAS;YAC9B,KAAK,EAAE,OAAO,EAAE,KAAK;SACtB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -1,11 +0,0 @@
1
- import type { Trace } from "../proto/types.js";
2
- export interface TraceAdapter {
3
- capture(...args: unknown[]): Trace;
4
- }
5
- export { ManualAdapter } from "./manual.js";
6
- export { OpenAIAdapter } from "./openai.js";
7
- export { AnthropicAdapter } from "./anthropic.js";
8
- export { GeminiAdapter } from "./gemini.js";
9
- export { OllamaAdapter } from "./ollama.js";
10
- export { OTelAdapter } from "./otel.js";
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;CACpC;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
@@ -1,7 +0,0 @@
1
- export { ManualAdapter } from "./manual.js";
2
- export { OpenAIAdapter } from "./openai.js";
3
- export { AnthropicAdapter } from "./anthropic.js";
4
- export { GeminiAdapter } from "./gemini.js";
5
- export { OllamaAdapter } from "./ollama.js";
6
- export { OTelAdapter } from "./otel.js";
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { Trace } from "../proto/types.js";
2
- import { TraceBuilder } from "../trace.js";
3
- export declare class ManualAdapter {
4
- private readonly agentId;
5
- constructor(agentId?: string);
6
- capture(builderFn: (builder: TraceBuilder) => void): Trace;
7
- createBuilder(): TraceBuilder;
8
- }
9
- //# sourceMappingURL=manual.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../../src/adapters/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,CAAC,EAAE,MAAM;IAI5B,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,KAAK;IAM1D,aAAa,IAAI,YAAY;CAG9B"}
@@ -1,16 +0,0 @@
1
- import { TraceBuilder } from "../trace.js";
2
- export class ManualAdapter {
3
- agentId;
4
- constructor(agentId) {
5
- this.agentId = agentId;
6
- }
7
- capture(builderFn) {
8
- const builder = new TraceBuilder(this.agentId);
9
- builderFn(builder);
10
- return builder.build();
11
- }
12
- createBuilder() {
13
- return new TraceBuilder(this.agentId);
14
- }
15
- }
16
- //# sourceMappingURL=manual.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manual.js","sourceRoot":"","sources":["../../src/adapters/manual.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,OAAO,aAAa;IACP,OAAO,CAAqB;IAE7C,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,SAA0C;QAChD,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,SAAS,CAAC,OAAO,CAAC,CAAC;QACnB,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,aAAa;QACX,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -1,19 +0,0 @@
1
- import type { Trace } from "../proto/types.js";
2
- interface OllamaResponse {
3
- model?: string;
4
- message?: {
5
- content?: string;
6
- };
7
- eval_count?: number;
8
- prompt_eval_count?: number;
9
- }
10
- export declare class OllamaAdapter {
11
- private readonly agentId;
12
- constructor(agentId?: string);
13
- traceFromResponse(response: OllamaResponse, options?: {
14
- inputMessages?: Record<string, unknown>[];
15
- latencyMs?: number;
16
- }): Trace;
17
- }
18
- export {};
19
- //# sourceMappingURL=ollama.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/adapters/ollama.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,CAAC,EAAE,MAAM;IAI5B,iBAAiB,CACf,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,KAAK;CA6BT"}
@@ -1,30 +0,0 @@
1
- import { TraceBuilder } from "../trace.js";
2
- export class OllamaAdapter {
3
- agentId;
4
- constructor(agentId) {
5
- this.agentId = agentId;
6
- }
7
- traceFromResponse(response, options) {
8
- const builder = new TraceBuilder(this.agentId);
9
- if (options?.inputMessages) {
10
- builder.setInput({ messages: options.inputMessages });
11
- }
12
- const completionText = response.message?.content ?? "";
13
- builder.addLlmCall("completion", {
14
- args: { model: response.model ?? "" },
15
- result: { completion: completionText },
16
- });
17
- builder.setOutput({ message: completionText });
18
- let totalTokens;
19
- if (response.eval_count !== undefined && response.prompt_eval_count !== undefined) {
20
- totalTokens = response.eval_count + response.prompt_eval_count;
21
- }
22
- builder.setMetadata({
23
- total_tokens: totalTokens,
24
- latency_ms: options?.latencyMs,
25
- model: response.model,
26
- });
27
- return builder.build();
28
- }
29
- }
30
- //# sourceMappingURL=ollama.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ollama.js","sourceRoot":"","sources":["../../src/adapters/ollama.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAS3C,MAAM,OAAO,aAAa;IACP,OAAO,CAAqB;IAE7C,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,iBAAiB,CACf,QAAwB,EACxB,OAGC;QAED,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/C,IAAI,OAAO,EAAE,aAAa,EAAE,CAAC;YAC3B,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;QAEvD,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE;YAC/B,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE,EAAE;YACrC,MAAM,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE;SACvC,CAAC,CAAC;QAEH,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;QAE/C,IAAI,WAA+B,CAAC;QACpC,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,IAAI,QAAQ,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YAClF,WAAW,GAAG,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,iBAAiB,CAAC;QACjE,CAAC;QAED,OAAO,CAAC,WAAW,CAAC;YAClB,YAAY,EAAE,WAAW;YACzB,UAAU,EAAE,OAAO,EAAE,SAAS;YAC9B,KAAK,EAAE,QAAQ,CAAC,KAAK;SACtB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -1,34 +0,0 @@
1
- import type { Trace } from "../proto/types.js";
2
- interface OpenAIUsage {
3
- total_tokens?: number;
4
- }
5
- interface OpenAIToolCall {
6
- function: {
7
- name: string;
8
- arguments: string;
9
- };
10
- }
11
- interface OpenAIMessage {
12
- content: string | null;
13
- tool_calls?: OpenAIToolCall[];
14
- }
15
- interface OpenAIChoice {
16
- message: OpenAIMessage;
17
- }
18
- interface OpenAIChatCompletion {
19
- model?: string;
20
- usage?: OpenAIUsage;
21
- choices: OpenAIChoice[];
22
- }
23
- export declare class OpenAIAdapter {
24
- private readonly agentId;
25
- constructor(agentId?: string);
26
- traceFromResponse(response: OpenAIChatCompletion, options?: {
27
- inputMessages?: Record<string, unknown>[];
28
- costUsd?: number;
29
- latencyMs?: number;
30
- structuredOutput?: Record<string, unknown>;
31
- }): Trace;
32
- }
33
- export {};
34
- //# sourceMappingURL=openai.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,UAAU,oBAAoB;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,CAAC,EAAE,MAAM;IAI5B,iBAAiB,CACf,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC5C,GACA,KAAK;CA0CT"}
@@ -1,42 +0,0 @@
1
- import { TraceBuilder } from "../trace.js";
2
- export class OpenAIAdapter {
3
- agentId;
4
- constructor(agentId) {
5
- this.agentId = agentId;
6
- }
7
- traceFromResponse(response, options) {
8
- const builder = new TraceBuilder(this.agentId);
9
- if (options?.inputMessages) {
10
- builder.setInput({ messages: options.inputMessages });
11
- }
12
- const message = response.choices[0].message;
13
- const completionText = message.content ?? "";
14
- const stepArgs = {};
15
- if (response.model !== undefined)
16
- stepArgs.model = response.model;
17
- const stepResult = { completion: completionText };
18
- if (response.usage?.total_tokens !== undefined) {
19
- stepResult.tokens = response.usage.total_tokens;
20
- }
21
- builder.addLlmCall("completion", { args: stepArgs, result: stepResult });
22
- if (message.tool_calls) {
23
- for (const tc of message.tool_calls) {
24
- builder.addToolCall(tc.function.name, {
25
- args: { arguments: tc.function.arguments },
26
- });
27
- }
28
- }
29
- builder.setOutput({
30
- message: completionText,
31
- structured: options?.structuredOutput ?? {},
32
- });
33
- builder.setMetadata({
34
- total_tokens: response.usage?.total_tokens,
35
- cost_usd: options?.costUsd,
36
- latency_ms: options?.latencyMs,
37
- model: response.model,
38
- });
39
- return builder.build();
40
- }
41
- }
42
- //# sourceMappingURL=openai.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAyB3C,MAAM,OAAO,aAAa;IACP,OAAO,CAAqB;IAE7C,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,iBAAiB,CACf,QAA8B,EAC9B,OAKC;QAED,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/C,IAAI,OAAO,EAAE,aAAa,EAAE,CAAC;YAC3B,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC5C,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QAE7C,MAAM,QAAQ,GAA4B,EAAE,CAAC;QAC7C,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;YAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QAElE,MAAM,UAAU,GAA4B,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;QAC3E,IAAI,QAAQ,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS,EAAE,CAAC;YAC/C,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC;QAClD,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAEzE,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACpC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE;oBACpC,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE;iBAC3C,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,CAAC,SAAS,CAAC;YAChB,OAAO,EAAE,cAAc;YACvB,UAAU,EAAE,OAAO,EAAE,gBAAgB,IAAI,EAAE;SAC5C,CAAC,CAAC;QAEH,OAAO,CAAC,WAAW,CAAC;YAClB,YAAY,EAAE,QAAQ,CAAC,KAAK,EAAE,YAAY;YAC1C,QAAQ,EAAE,OAAO,EAAE,OAAO;YAC1B,UAAU,EAAE,OAAO,EAAE,SAAS;YAC9B,KAAK,EAAE,QAAQ,CAAC,KAAK;SACtB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -1,25 +0,0 @@
1
- import type { Trace } from "../proto/types.js";
2
- interface OTelSpanContext {
3
- traceId: string;
4
- }
5
- interface OTelSpan {
6
- name: string;
7
- startTime: [number, number];
8
- endTime: [number, number];
9
- attributes?: Record<string, unknown>;
10
- parentSpanId?: string;
11
- spanContext(): OTelSpanContext;
12
- }
13
- export declare class OTelAdapter {
14
- private readonly agentId;
15
- constructor(agentId?: string);
16
- static fromSpans(spans: OTelSpan[], agentId?: string): Trace;
17
- private buildTrace;
18
- private findRootSpan;
19
- private classifySpan;
20
- private extractLlmStep;
21
- private extractToolStep;
22
- private spanMetadata;
23
- }
24
- export {};
25
- //# sourceMappingURL=otel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../src/adapters/otel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,IAAI,eAAe,CAAC;CAChC;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,CAAC,EAAE,MAAM;IAI5B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK;IAK5D,OAAO,CAAC,UAAU;IAuElB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,YAAY;CAKrB"}