@agentmark-ai/shared-utils 0.1.1 → 0.3.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.
package/dist/index.d.mts CHANGED
@@ -468,6 +468,44 @@ declare class MastraTransformer implements ScopeTransformer {
468
468
  private extractStreamResult;
469
469
  }
470
470
 
471
+ /**
472
+ * Transformer for AgentMark spans emitted via OTEL.
473
+ * Handles GenAI semantic convention attributes and classifies spans.
474
+ *
475
+ * Classification rules (per OTEL GenAI conventions):
476
+ * - GENERATION: Spans that represent actual LLM API calls (chat, text_completion)
477
+ * - SPAN: All other spans (tool execution, agent invocation, grouping spans)
478
+ *
479
+ * Only spans that send requests to the LLM should be GENERATION type.
480
+ * Wrapper/grouping spans like conversations are regular SPAN type.
481
+ */
482
+ declare class AgentMarkTransformer implements ScopeTransformer {
483
+ /**
484
+ * Classify the span type based on span name and attributes.
485
+ *
486
+ * GENERATION type (actual LLM calls):
487
+ * - Spans starting with "chat " (OTEL convention)
488
+ * - gen_ai.llm.turn spans (legacy traced module)
489
+ * - gen_ai.session spans (legacy hooks) - these wrap LLM calls
490
+ * - Spans with gen_ai.operation.name = "chat" or "text_completion"
491
+ *
492
+ * SPAN type (everything else):
493
+ * - gen_ai.conversation (grouping span)
494
+ * - execute_tool / gen_ai.tool.call (tool execution)
495
+ * - invoke_agent / gen_ai.subagent (agent invocation)
496
+ */
497
+ classify(span: OtelSpan, attributes: Record<string, any>): SpanType;
498
+ /**
499
+ * Transform the span and extract normalized fields from GenAI attributes.
500
+ */
501
+ transform(_span: OtelSpan, attributes: Record<string, any>): Partial<NormalizedSpan>;
502
+ }
503
+ /**
504
+ * The scope name used by AgentMark's OTEL tracer.
505
+ * Used by the registry to route spans to this transformer.
506
+ */
507
+ declare const AGENTMARK_SCOPE_NAME = "agentmark";
508
+
471
509
  declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: OtelSpan): NormalizedSpan;
472
510
  /**
473
511
  * Normalize spans from raw OTLP resourceSpans structure
@@ -475,4 +513,4 @@ declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: O
475
513
  */
476
514
  declare function normalizeOtlpSpans(resourceSpans: OtlpResourceSpans[]): NormalizedSpan[];
477
515
 
478
- export { type AgentmarkConfig, type AgentmarkModelConfig, type AgentmarkModelSchema, type AgentmarkModelSettingsConfig, type AgentmarkModelSettingsSchema, AiSdkTransformer, type AiSdkVersion, type AttributeExtractor, MastraTransformer, type McpServerConfig, type McpServers, type McpStdioServerConfig, type McpUrlServerConfig, type Message, type ModelSettingsTypeAspectRatio, type ModelSettingsTypeImageSize, type ModelSettingsTypeSelect, type ModelSettingsTypeSlider, type NormalizedSpan, type OtelEvent, type OtelLink, type OtelResource, type OtelScope, type OtelSpan, type OtlpAttribute, type OtlpAttributeValue, type OtlpEvent, type OtlpLink, type OtlpResource, type OtlpResourceSpans, type OtlpScope, type OtlpScopeSpans, type OtlpSpan, type ScopeTransformer, SpanType, type StandardMessageContent, type StandardTextContent, type StandardToolCallContent, type StandardToolResultContent, type ToolCall, TransformerRegistry, TypeClassifier, convertOtlpAttributes, createSignature, detectVersion, extractCustomMetadata, extractReasoningFromProviderMetadata, extractResourceScopeSpan, fetchPromptsFrontmatter, findPromptFiles, generateTypeDefinitions, generateUnique8CharString, normalizeOtlpSpans, normalizeSpan, parseAgentMarkAttributes, parseMetadata, parseTokens, registry, toFrontMatter, typeClassifier, verifySignature };
516
+ export { AGENTMARK_SCOPE_NAME, AgentMarkTransformer, type AgentmarkConfig, type AgentmarkModelConfig, type AgentmarkModelSchema, type AgentmarkModelSettingsConfig, type AgentmarkModelSettingsSchema, AiSdkTransformer, type AiSdkVersion, type AttributeExtractor, AgentMarkTransformer as ClaudeAgentTransformer, MastraTransformer, type McpServerConfig, type McpServers, type McpStdioServerConfig, type McpUrlServerConfig, type Message, type ModelSettingsTypeAspectRatio, type ModelSettingsTypeImageSize, type ModelSettingsTypeSelect, type ModelSettingsTypeSlider, type NormalizedSpan, type OtelEvent, type OtelLink, type OtelResource, type OtelScope, type OtelSpan, type OtlpAttribute, type OtlpAttributeValue, type OtlpEvent, type OtlpLink, type OtlpResource, type OtlpResourceSpans, type OtlpScope, type OtlpScopeSpans, type OtlpSpan, type ScopeTransformer, SpanType, type StandardMessageContent, type StandardTextContent, type StandardToolCallContent, type StandardToolResultContent, type ToolCall, TransformerRegistry, TypeClassifier, convertOtlpAttributes, createSignature, detectVersion, extractCustomMetadata, extractReasoningFromProviderMetadata, extractResourceScopeSpan, fetchPromptsFrontmatter, findPromptFiles, generateTypeDefinitions, generateUnique8CharString, normalizeOtlpSpans, normalizeSpan, parseAgentMarkAttributes, parseMetadata, parseTokens, registry, toFrontMatter, typeClassifier, verifySignature };
package/dist/index.d.ts CHANGED
@@ -468,6 +468,44 @@ declare class MastraTransformer implements ScopeTransformer {
468
468
  private extractStreamResult;
469
469
  }
470
470
 
471
+ /**
472
+ * Transformer for AgentMark spans emitted via OTEL.
473
+ * Handles GenAI semantic convention attributes and classifies spans.
474
+ *
475
+ * Classification rules (per OTEL GenAI conventions):
476
+ * - GENERATION: Spans that represent actual LLM API calls (chat, text_completion)
477
+ * - SPAN: All other spans (tool execution, agent invocation, grouping spans)
478
+ *
479
+ * Only spans that send requests to the LLM should be GENERATION type.
480
+ * Wrapper/grouping spans like conversations are regular SPAN type.
481
+ */
482
+ declare class AgentMarkTransformer implements ScopeTransformer {
483
+ /**
484
+ * Classify the span type based on span name and attributes.
485
+ *
486
+ * GENERATION type (actual LLM calls):
487
+ * - Spans starting with "chat " (OTEL convention)
488
+ * - gen_ai.llm.turn spans (legacy traced module)
489
+ * - gen_ai.session spans (legacy hooks) - these wrap LLM calls
490
+ * - Spans with gen_ai.operation.name = "chat" or "text_completion"
491
+ *
492
+ * SPAN type (everything else):
493
+ * - gen_ai.conversation (grouping span)
494
+ * - execute_tool / gen_ai.tool.call (tool execution)
495
+ * - invoke_agent / gen_ai.subagent (agent invocation)
496
+ */
497
+ classify(span: OtelSpan, attributes: Record<string, any>): SpanType;
498
+ /**
499
+ * Transform the span and extract normalized fields from GenAI attributes.
500
+ */
501
+ transform(_span: OtelSpan, attributes: Record<string, any>): Partial<NormalizedSpan>;
502
+ }
503
+ /**
504
+ * The scope name used by AgentMark's OTEL tracer.
505
+ * Used by the registry to route spans to this transformer.
506
+ */
507
+ declare const AGENTMARK_SCOPE_NAME = "agentmark";
508
+
471
509
  declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: OtelSpan): NormalizedSpan;
472
510
  /**
473
511
  * Normalize spans from raw OTLP resourceSpans structure
@@ -475,4 +513,4 @@ declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: O
475
513
  */
476
514
  declare function normalizeOtlpSpans(resourceSpans: OtlpResourceSpans[]): NormalizedSpan[];
477
515
 
478
- export { type AgentmarkConfig, type AgentmarkModelConfig, type AgentmarkModelSchema, type AgentmarkModelSettingsConfig, type AgentmarkModelSettingsSchema, AiSdkTransformer, type AiSdkVersion, type AttributeExtractor, MastraTransformer, type McpServerConfig, type McpServers, type McpStdioServerConfig, type McpUrlServerConfig, type Message, type ModelSettingsTypeAspectRatio, type ModelSettingsTypeImageSize, type ModelSettingsTypeSelect, type ModelSettingsTypeSlider, type NormalizedSpan, type OtelEvent, type OtelLink, type OtelResource, type OtelScope, type OtelSpan, type OtlpAttribute, type OtlpAttributeValue, type OtlpEvent, type OtlpLink, type OtlpResource, type OtlpResourceSpans, type OtlpScope, type OtlpScopeSpans, type OtlpSpan, type ScopeTransformer, SpanType, type StandardMessageContent, type StandardTextContent, type StandardToolCallContent, type StandardToolResultContent, type ToolCall, TransformerRegistry, TypeClassifier, convertOtlpAttributes, createSignature, detectVersion, extractCustomMetadata, extractReasoningFromProviderMetadata, extractResourceScopeSpan, fetchPromptsFrontmatter, findPromptFiles, generateTypeDefinitions, generateUnique8CharString, normalizeOtlpSpans, normalizeSpan, parseAgentMarkAttributes, parseMetadata, parseTokens, registry, toFrontMatter, typeClassifier, verifySignature };
516
+ export { AGENTMARK_SCOPE_NAME, AgentMarkTransformer, type AgentmarkConfig, type AgentmarkModelConfig, type AgentmarkModelSchema, type AgentmarkModelSettingsConfig, type AgentmarkModelSettingsSchema, AiSdkTransformer, type AiSdkVersion, type AttributeExtractor, AgentMarkTransformer as ClaudeAgentTransformer, MastraTransformer, type McpServerConfig, type McpServers, type McpStdioServerConfig, type McpUrlServerConfig, type Message, type ModelSettingsTypeAspectRatio, type ModelSettingsTypeImageSize, type ModelSettingsTypeSelect, type ModelSettingsTypeSlider, type NormalizedSpan, type OtelEvent, type OtelLink, type OtelResource, type OtelScope, type OtelSpan, type OtlpAttribute, type OtlpAttributeValue, type OtlpEvent, type OtlpLink, type OtlpResource, type OtlpResourceSpans, type OtlpScope, type OtlpScopeSpans, type OtlpSpan, type ScopeTransformer, SpanType, type StandardMessageContent, type StandardTextContent, type StandardToolCallContent, type StandardToolResultContent, type ToolCall, TransformerRegistry, TypeClassifier, convertOtlpAttributes, createSignature, detectVersion, extractCustomMetadata, extractReasoningFromProviderMetadata, extractResourceScopeSpan, fetchPromptsFrontmatter, findPromptFiles, generateTypeDefinitions, generateUnique8CharString, normalizeOtlpSpans, normalizeSpan, parseAgentMarkAttributes, parseMetadata, parseTokens, registry, toFrontMatter, typeClassifier, verifySignature };
package/dist/index.js CHANGED
@@ -30,7 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AGENTMARK_SCOPE_NAME: () => AGENTMARK_SCOPE_NAME,
34
+ AgentMarkTransformer: () => AgentMarkTransformer,
33
35
  AiSdkTransformer: () => AiSdkTransformer,
36
+ ClaudeAgentTransformer: () => AgentMarkTransformer,
34
37
  MastraTransformer: () => MastraTransformer,
35
38
  SpanType: () => SpanType,
36
39
  TransformerRegistry: () => TransformerRegistry,
@@ -170,7 +173,15 @@ ${jsonToFrontMatter(content)}---
170
173
  // src/generate-types.ts
171
174
  var fs = __toESM(require("fs-extra"));
172
175
  var import_path = __toESM(require("path"));
173
- var import_front_matter = __toESM(require("front-matter"));
176
+ var import_js_yaml = __toESM(require("js-yaml"));
177
+ function extractFrontmatter(content) {
178
+ const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
179
+ if (!match) {
180
+ return { attributes: {} };
181
+ }
182
+ const attributes = import_js_yaml.default.load(match[1]);
183
+ return { attributes: attributes || {} };
184
+ }
174
185
  var _compile = null;
175
186
  async function getCompile() {
176
187
  var _a;
@@ -414,7 +425,7 @@ async function fetchPromptsFrontmatter(options) {
414
425
  return Promise.all(
415
426
  promptFiles.map(async (file) => {
416
427
  const content = await fs.readFile(file, "utf-8");
417
- const { attributes } = (0, import_front_matter.default)(content);
428
+ const { attributes } = extractFrontmatter(content);
418
429
  if (isNewFormat(attributes)) {
419
430
  return {
420
431
  path: import_path.default.relative(options.rootDir, file),
@@ -1333,6 +1344,218 @@ var MastraTransformer = class {
1333
1344
  }
1334
1345
  };
1335
1346
 
1347
+ // src/normalizer/extractors/agentmark-parser.ts
1348
+ function parseAgentMarkAttributes(attributes, prefix = "agentmark.") {
1349
+ const result = {};
1350
+ const get = (key) => attributes[`${prefix}${key}`];
1351
+ if (get("session_id")) result.sessionId = String(get("session_id"));
1352
+ if (get("session_name")) result.sessionName = String(get("session_name"));
1353
+ if (get("user_id")) result.userId = String(get("user_id"));
1354
+ if (get("trace_name")) result.traceName = String(get("trace_name"));
1355
+ if (get("prompt_name")) result.promptName = String(get("prompt_name"));
1356
+ if (get("props")) result.props = String(get("props"));
1357
+ if (get("dataset_run_id")) result.datasetRunId = String(get("dataset_run_id"));
1358
+ if (get("dataset_run_name")) result.datasetRunName = String(get("dataset_run_name"));
1359
+ if (get("dataset_item_name")) result.datasetItemName = String(get("dataset_item_name"));
1360
+ if (get("dataset_expected_output")) result.datasetExpectedOutput = String(get("dataset_expected_output"));
1361
+ if (get("dataset_path")) result.datasetPath = String(get("dataset_path"));
1362
+ return result;
1363
+ }
1364
+
1365
+ // src/normalizer/transformers/agentmark/index.ts
1366
+ var GenAIAttributes = {
1367
+ SYSTEM: "gen_ai.system",
1368
+ OPERATION_NAME: "gen_ai.operation.name",
1369
+ REQUEST_MODEL: "gen_ai.request.model",
1370
+ REQUEST_MAX_TOKENS: "gen_ai.request.max_tokens",
1371
+ REQUEST_TEMPERATURE: "gen_ai.request.temperature",
1372
+ REQUEST_INPUT: "gen_ai.request.input",
1373
+ RESPONSE_ID: "gen_ai.response.id",
1374
+ RESPONSE_MODEL: "gen_ai.response.model",
1375
+ RESPONSE_OUTPUT: "gen_ai.response.output",
1376
+ RESPONSE_FINISH_REASONS: "gen_ai.response.finish_reasons",
1377
+ USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens",
1378
+ USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens",
1379
+ TOOL_NAME: "gen_ai.tool.name",
1380
+ TOOL_CALL_ID: "gen_ai.tool.call.id",
1381
+ TOOL_INPUT: "gen_ai.tool.input",
1382
+ TOOL_OUTPUT: "gen_ai.tool.output"
1383
+ };
1384
+ var SpanNames = {
1385
+ // OTEL GenAI standard operation names (these can be followed by model/tool/agent name)
1386
+ CHAT: "chat",
1387
+ EXECUTE_TOOL: "execute_tool",
1388
+ INVOKE_AGENT: "invoke_agent",
1389
+ // Legacy span names (for backwards compatibility)
1390
+ SESSION: "gen_ai.session",
1391
+ TOOL_CALL: "gen_ai.tool.call",
1392
+ SUBAGENT: "gen_ai.subagent",
1393
+ CONVERSATION: "gen_ai.conversation",
1394
+ LLM_TURN: "gen_ai.llm.turn"
1395
+ };
1396
+ var OperationNames = {
1397
+ CHAT: "chat",
1398
+ EMBEDDINGS: "embeddings",
1399
+ TEXT_COMPLETION: "text_completion",
1400
+ GENERATE_CONTENT: "generate_content",
1401
+ EXECUTE_TOOL: "execute_tool",
1402
+ CREATE_AGENT: "create_agent",
1403
+ INVOKE_AGENT: "invoke_agent"
1404
+ };
1405
+ var AgentMarkTransformer = class {
1406
+ /**
1407
+ * Classify the span type based on span name and attributes.
1408
+ *
1409
+ * GENERATION type (actual LLM calls):
1410
+ * - Spans starting with "chat " (OTEL convention)
1411
+ * - gen_ai.llm.turn spans (legacy traced module)
1412
+ * - gen_ai.session spans (legacy hooks) - these wrap LLM calls
1413
+ * - Spans with gen_ai.operation.name = "chat" or "text_completion"
1414
+ *
1415
+ * SPAN type (everything else):
1416
+ * - gen_ai.conversation (grouping span)
1417
+ * - execute_tool / gen_ai.tool.call (tool execution)
1418
+ * - invoke_agent / gen_ai.subagent (agent invocation)
1419
+ */
1420
+ classify(span, attributes) {
1421
+ const operationName = attributes[GenAIAttributes.OPERATION_NAME];
1422
+ if (operationName === OperationNames.CHAT || operationName === OperationNames.TEXT_COMPLETION) {
1423
+ return "GENERATION" /* GENERATION */;
1424
+ }
1425
+ if (span.name === SpanNames.CHAT || span.name.startsWith(SpanNames.CHAT + " ")) {
1426
+ return "GENERATION" /* GENERATION */;
1427
+ }
1428
+ if (span.name === SpanNames.LLM_TURN) {
1429
+ return "GENERATION" /* GENERATION */;
1430
+ }
1431
+ if (span.name === SpanNames.SESSION) {
1432
+ return "GENERATION" /* GENERATION */;
1433
+ }
1434
+ if (span.name === SpanNames.EXECUTE_TOOL || span.name.startsWith(SpanNames.EXECUTE_TOOL + " ") || span.name.startsWith(SpanNames.TOOL_CALL)) {
1435
+ return "SPAN" /* SPAN */;
1436
+ }
1437
+ if (span.name === SpanNames.INVOKE_AGENT || span.name.startsWith(SpanNames.INVOKE_AGENT + " ")) {
1438
+ return "SPAN" /* SPAN */;
1439
+ }
1440
+ if (span.name === SpanNames.CONVERSATION || span.name === SpanNames.SUBAGENT) {
1441
+ return "SPAN" /* SPAN */;
1442
+ }
1443
+ if (attributes[GenAIAttributes.SYSTEM] === "anthropic") {
1444
+ if (attributes[GenAIAttributes.USAGE_INPUT_TOKENS] !== void 0 && attributes[GenAIAttributes.RESPONSE_OUTPUT] !== void 0) {
1445
+ return "GENERATION" /* GENERATION */;
1446
+ }
1447
+ }
1448
+ return "SPAN" /* SPAN */;
1449
+ }
1450
+ /**
1451
+ * Transform the span and extract normalized fields from GenAI attributes.
1452
+ */
1453
+ transform(_span, attributes) {
1454
+ const result = {};
1455
+ const responseModel = attributes[GenAIAttributes.RESPONSE_MODEL];
1456
+ const requestModel = attributes[GenAIAttributes.REQUEST_MODEL];
1457
+ if (responseModel) {
1458
+ result.model = String(responseModel);
1459
+ } else if (requestModel) {
1460
+ result.model = String(requestModel);
1461
+ }
1462
+ const inputTokens = attributes[GenAIAttributes.USAGE_INPUT_TOKENS];
1463
+ const outputTokens = attributes[GenAIAttributes.USAGE_OUTPUT_TOKENS];
1464
+ if (typeof inputTokens === "number") {
1465
+ result.inputTokens = inputTokens;
1466
+ }
1467
+ if (typeof outputTokens === "number") {
1468
+ result.outputTokens = outputTokens;
1469
+ }
1470
+ if (result.inputTokens !== void 0 && result.outputTokens !== void 0) {
1471
+ result.totalTokens = result.inputTokens + result.outputTokens;
1472
+ }
1473
+ const finishReasons = attributes[GenAIAttributes.RESPONSE_FINISH_REASONS];
1474
+ if (finishReasons) {
1475
+ try {
1476
+ const reasons = JSON.parse(finishReasons);
1477
+ if (Array.isArray(reasons) && reasons.length > 0) {
1478
+ result.finishReason = String(reasons[0]);
1479
+ }
1480
+ } catch {
1481
+ result.finishReason = String(finishReasons);
1482
+ }
1483
+ }
1484
+ const maxTokens = attributes[GenAIAttributes.REQUEST_MAX_TOKENS];
1485
+ const temperature = attributes[GenAIAttributes.REQUEST_TEMPERATURE];
1486
+ if (maxTokens !== void 0 || temperature !== void 0) {
1487
+ result.settings = {};
1488
+ if (typeof maxTokens === "number") {
1489
+ result.settings.maxTokens = maxTokens;
1490
+ }
1491
+ if (typeof temperature === "number") {
1492
+ result.settings.temperature = temperature;
1493
+ }
1494
+ }
1495
+ const requestInput = attributes[GenAIAttributes.REQUEST_INPUT];
1496
+ if (requestInput && typeof requestInput === "string") {
1497
+ try {
1498
+ const parsed = JSON.parse(requestInput);
1499
+ if (Array.isArray(parsed) && parsed.length > 0) {
1500
+ const isMessagesArray = parsed.every(
1501
+ (item) => item && typeof item === "object" && "role" in item && "content" in item
1502
+ );
1503
+ if (isMessagesArray) {
1504
+ result.input = parsed;
1505
+ } else {
1506
+ result.input = [{ role: "user", content: requestInput }];
1507
+ }
1508
+ } else {
1509
+ result.input = [{ role: "user", content: requestInput }];
1510
+ }
1511
+ } catch {
1512
+ result.input = [{ role: "user", content: requestInput }];
1513
+ }
1514
+ }
1515
+ const responseOutput = attributes[GenAIAttributes.RESPONSE_OUTPUT];
1516
+ if (responseOutput && typeof responseOutput === "string") {
1517
+ result.output = responseOutput;
1518
+ }
1519
+ const toolName = attributes[GenAIAttributes.TOOL_NAME];
1520
+ const toolCallId = attributes[GenAIAttributes.TOOL_CALL_ID];
1521
+ const toolInput = attributes[GenAIAttributes.TOOL_INPUT];
1522
+ const toolOutput = attributes[GenAIAttributes.TOOL_OUTPUT];
1523
+ if (toolName && typeof toolName === "string") {
1524
+ result.name = toolName;
1525
+ const toolCall = {
1526
+ type: "tool-call",
1527
+ toolCallId: typeof toolCallId === "string" ? toolCallId : "",
1528
+ toolName,
1529
+ args: {}
1530
+ };
1531
+ if (toolInput && typeof toolInput === "string") {
1532
+ try {
1533
+ toolCall.args = JSON.parse(toolInput);
1534
+ } catch {
1535
+ toolCall.args = { raw: toolInput };
1536
+ }
1537
+ }
1538
+ if (toolOutput && typeof toolOutput === "string") {
1539
+ toolCall.result = toolOutput;
1540
+ }
1541
+ result.toolCalls = [toolCall];
1542
+ }
1543
+ const agentmarkAttrs = parseAgentMarkAttributes(attributes);
1544
+ const metadataAttrs = parseMetadata(attributes, "agentmark.metadata.");
1545
+ const customMetadata = extractCustomMetadata(attributes, "agentmark.metadata.");
1546
+ return {
1547
+ ...result,
1548
+ ...metadataAttrs,
1549
+ // agentmark.metadata.* values (lower priority)
1550
+ ...agentmarkAttrs,
1551
+ // agentmark.* values (higher priority)
1552
+ // Only include metadata field if there are custom metadata keys
1553
+ ...Object.keys(customMetadata).length > 0 ? { metadata: customMetadata } : {}
1554
+ };
1555
+ }
1556
+ };
1557
+ var AGENTMARK_SCOPE_NAME = "agentmark";
1558
+
1336
1559
  // src/normalizer/converters/otlp-converter.ts
1337
1560
  function convertOtlpValue(value) {
1338
1561
  var _a;
@@ -1413,22 +1636,6 @@ function extractResourceScopeSpan(resourceSpans) {
1413
1636
  return result;
1414
1637
  }
1415
1638
 
1416
- // src/normalizer/extractors/agentmark-parser.ts
1417
- function parseAgentMarkAttributes(attributes, prefix = "agentmark.") {
1418
- const result = {};
1419
- const get = (key) => attributes[`${prefix}${key}`];
1420
- if (get("session_id")) result.sessionId = String(get("session_id"));
1421
- if (get("session_name")) result.sessionName = String(get("session_name"));
1422
- if (get("user_id")) result.userId = String(get("user_id"));
1423
- if (get("trace_name")) result.traceName = String(get("trace_name"));
1424
- if (get("dataset_run_id")) result.datasetRunId = String(get("dataset_run_id"));
1425
- if (get("dataset_run_name")) result.datasetRunName = String(get("dataset_run_name"));
1426
- if (get("dataset_item_name")) result.datasetItemName = String(get("dataset_item_name"));
1427
- if (get("dataset_expected_output")) result.datasetExpectedOutput = String(get("dataset_expected_output"));
1428
- if (get("dataset_path")) result.datasetPath = String(get("dataset_path"));
1429
- return result;
1430
- }
1431
-
1432
1639
  // src/normalizer/type-classifier.ts
1433
1640
  var TypeClassifier = class {
1434
1641
  classify(span, attributes) {
@@ -1449,6 +1656,7 @@ var typeClassifier = new TypeClassifier();
1449
1656
  // src/normalizer/index.ts
1450
1657
  registry.register("ai", new AiSdkTransformer());
1451
1658
  registry.register("default-tracer", new MastraTransformer());
1659
+ registry.register("agentmark", new AgentMarkTransformer());
1452
1660
  registry.setDefault(new AiSdkTransformer());
1453
1661
  function normalizeSpan(resource, scope, span) {
1454
1662
  var _a, _b, _c;
@@ -1519,7 +1727,10 @@ function normalizeOtlpSpans(resourceSpans) {
1519
1727
  }
1520
1728
  // Annotate the CommonJS export names for ESM import in node:
1521
1729
  0 && (module.exports = {
1730
+ AGENTMARK_SCOPE_NAME,
1731
+ AgentMarkTransformer,
1522
1732
  AiSdkTransformer,
1733
+ ClaudeAgentTransformer,
1523
1734
  MastraTransformer,
1524
1735
  SpanType,
1525
1736
  TransformerRegistry,