@agentmark-ai/shared-utils 0.3.0 → 0.3.2

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
@@ -71,7 +71,7 @@ type AgentmarkConfig = {
71
71
  version: string;
72
72
  builtInModels?: string[];
73
73
  mcpServers?: McpServers;
74
- evals: string[];
74
+ evals?: string[];
75
75
  };
76
76
 
77
77
  declare function toFrontMatter(content: {
@@ -121,7 +121,8 @@ type PromptFrontmatterV0 = {
121
121
  };
122
122
  type PromptFrontmatter = PromptFrontmatterV0 | TextPromptFrontmatterV1_0 | ObjectPromptFrontmatterV1_0 | ImagePromptFrontmatterV1_0;
123
123
  declare function findPromptFiles(dir: string): Promise<string[]>;
124
- declare function generateTypeDefinitions(prompts: PromptFrontmatter[]): Promise<string>;
124
+ type GenerateTypesLanguage = "typescript" | "python";
125
+ declare function generateTypeDefinitions(prompts: PromptFrontmatter[], language?: GenerateTypesLanguage): Promise<string>;
125
126
  declare function fetchPromptsFrontmatter(options: {
126
127
  local?: number;
127
128
  rootDir?: string;
@@ -218,6 +219,7 @@ interface NormalizedSpan {
218
219
  duration: number;
219
220
  name: string;
220
221
  kind: string;
222
+ semanticKind?: string;
221
223
  serviceName?: string;
222
224
  statusCode: string;
223
225
  statusMessage?: string;
@@ -248,6 +250,7 @@ interface NormalizedSpan {
248
250
  datasetPath?: string;
249
251
  datasetItemName?: string;
250
252
  datasetExpectedOutput?: string;
253
+ datasetInput?: string;
251
254
  promptName?: string;
252
255
  props?: string;
253
256
  commitSha?: string;
@@ -441,6 +444,27 @@ declare function extractCustomMetadata(attributes: Record<string, any>, prefix?:
441
444
  */
442
445
  declare function parseAgentMarkAttributes(attributes: Record<string, any>, prefix?: string): Partial<NormalizedSpan>;
443
446
 
447
+ /** Valid semantic kind values. */
448
+ declare const SEMANTIC_KINDS: readonly ["function", "llm", "tool", "agent", "retrieval", "embedding", "guardrail"];
449
+ type SemanticKind = typeof SEMANTIC_KINDS[number];
450
+ /**
451
+ * Resolve the semantic kind of a span using an 8-level priority chain.
452
+ *
453
+ * Priority:
454
+ * 1. normalized.semanticKind (from agentmark.span.kind attribute) — if valid
455
+ * 2. openinference.span.kind attribute
456
+ * 3. Framework-specific attributes (Vercel AI SDK, Traceloop, LangChain, Genkit)
457
+ * 4. gen_ai.operation.name → llm/embedding
458
+ * 5. Type = GENERATION → llm
459
+ * 6. Has non-empty ToolCalls → tool
460
+ * 7. Name-based heuristics
461
+ * 8. Default → function
462
+ */
463
+ declare function resolveSemanticKind(normalized: Partial<NormalizedSpan> & {
464
+ type: SpanType;
465
+ name: string;
466
+ }, allAttributes: Record<string, any>): SemanticKind;
467
+
444
468
  declare class AiSdkTransformer implements ScopeTransformer {
445
469
  private strategies;
446
470
  constructor();
@@ -506,6 +530,27 @@ declare class AgentMarkTransformer implements ScopeTransformer {
506
530
  */
507
531
  declare const AGENTMARK_SCOPE_NAME = "agentmark";
508
532
 
533
+ /**
534
+ * Transformer for the official OTel GenAI Semantic Conventions (v1.37.0+).
535
+ *
536
+ * Handles attribute names:
537
+ * gen_ai.input.messages — JSON array of input messages ({role, parts[]})
538
+ * gen_ai.output.messages — JSON array of output messages ({role, parts[], finish_reason})
539
+ * gen_ai.system_instructions — JSON array of system instruction parts
540
+ *
541
+ * Used by frameworks that follow the official spec:
542
+ * - Pydantic AI (scope: "pydantic-ai")
543
+ * - Any future OTel-compliant GenAI instrumentation
544
+ *
545
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/
546
+ */
547
+
548
+ declare class OtelGenAiTransformer implements ScopeTransformer {
549
+ classify(span: OtelSpan, attributes: Record<string, any>): SpanType;
550
+ transform(span: OtelSpan, attributes: Record<string, any>): Partial<NormalizedSpan>;
551
+ static readonly SCOPE_NAME = "pydantic-ai";
552
+ }
553
+
509
554
  declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: OtelSpan): NormalizedSpan;
510
555
  /**
511
556
  * Normalize spans from raw OTLP resourceSpans structure
@@ -513,4 +558,4 @@ declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: O
513
558
  */
514
559
  declare function normalizeOtlpSpans(resourceSpans: OtlpResourceSpans[]): NormalizedSpan[];
515
560
 
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 };
561
+ export { AGENTMARK_SCOPE_NAME, AgentMarkTransformer, type AgentmarkConfig, type AgentmarkModelConfig, type AgentmarkModelSchema, type AgentmarkModelSettingsConfig, type AgentmarkModelSettingsSchema, AiSdkTransformer, type AiSdkVersion, type AttributeExtractor, AgentMarkTransformer as ClaudeAgentTransformer, type GenerateTypesLanguage, MastraTransformer, type McpServerConfig, type McpServers, type McpStdioServerConfig, type McpUrlServerConfig, type Message, type ModelSettingsTypeAspectRatio, type ModelSettingsTypeImageSize, type ModelSettingsTypeSelect, type ModelSettingsTypeSlider, type NormalizedSpan, type OtelEvent, OtelGenAiTransformer, 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, SEMANTIC_KINDS, type ScopeTransformer, type SemanticKind, 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, resolveSemanticKind, toFrontMatter, typeClassifier, verifySignature };
package/dist/index.d.ts CHANGED
@@ -71,7 +71,7 @@ type AgentmarkConfig = {
71
71
  version: string;
72
72
  builtInModels?: string[];
73
73
  mcpServers?: McpServers;
74
- evals: string[];
74
+ evals?: string[];
75
75
  };
76
76
 
77
77
  declare function toFrontMatter(content: {
@@ -121,7 +121,8 @@ type PromptFrontmatterV0 = {
121
121
  };
122
122
  type PromptFrontmatter = PromptFrontmatterV0 | TextPromptFrontmatterV1_0 | ObjectPromptFrontmatterV1_0 | ImagePromptFrontmatterV1_0;
123
123
  declare function findPromptFiles(dir: string): Promise<string[]>;
124
- declare function generateTypeDefinitions(prompts: PromptFrontmatter[]): Promise<string>;
124
+ type GenerateTypesLanguage = "typescript" | "python";
125
+ declare function generateTypeDefinitions(prompts: PromptFrontmatter[], language?: GenerateTypesLanguage): Promise<string>;
125
126
  declare function fetchPromptsFrontmatter(options: {
126
127
  local?: number;
127
128
  rootDir?: string;
@@ -218,6 +219,7 @@ interface NormalizedSpan {
218
219
  duration: number;
219
220
  name: string;
220
221
  kind: string;
222
+ semanticKind?: string;
221
223
  serviceName?: string;
222
224
  statusCode: string;
223
225
  statusMessage?: string;
@@ -248,6 +250,7 @@ interface NormalizedSpan {
248
250
  datasetPath?: string;
249
251
  datasetItemName?: string;
250
252
  datasetExpectedOutput?: string;
253
+ datasetInput?: string;
251
254
  promptName?: string;
252
255
  props?: string;
253
256
  commitSha?: string;
@@ -441,6 +444,27 @@ declare function extractCustomMetadata(attributes: Record<string, any>, prefix?:
441
444
  */
442
445
  declare function parseAgentMarkAttributes(attributes: Record<string, any>, prefix?: string): Partial<NormalizedSpan>;
443
446
 
447
+ /** Valid semantic kind values. */
448
+ declare const SEMANTIC_KINDS: readonly ["function", "llm", "tool", "agent", "retrieval", "embedding", "guardrail"];
449
+ type SemanticKind = typeof SEMANTIC_KINDS[number];
450
+ /**
451
+ * Resolve the semantic kind of a span using an 8-level priority chain.
452
+ *
453
+ * Priority:
454
+ * 1. normalized.semanticKind (from agentmark.span.kind attribute) — if valid
455
+ * 2. openinference.span.kind attribute
456
+ * 3. Framework-specific attributes (Vercel AI SDK, Traceloop, LangChain, Genkit)
457
+ * 4. gen_ai.operation.name → llm/embedding
458
+ * 5. Type = GENERATION → llm
459
+ * 6. Has non-empty ToolCalls → tool
460
+ * 7. Name-based heuristics
461
+ * 8. Default → function
462
+ */
463
+ declare function resolveSemanticKind(normalized: Partial<NormalizedSpan> & {
464
+ type: SpanType;
465
+ name: string;
466
+ }, allAttributes: Record<string, any>): SemanticKind;
467
+
444
468
  declare class AiSdkTransformer implements ScopeTransformer {
445
469
  private strategies;
446
470
  constructor();
@@ -506,6 +530,27 @@ declare class AgentMarkTransformer implements ScopeTransformer {
506
530
  */
507
531
  declare const AGENTMARK_SCOPE_NAME = "agentmark";
508
532
 
533
+ /**
534
+ * Transformer for the official OTel GenAI Semantic Conventions (v1.37.0+).
535
+ *
536
+ * Handles attribute names:
537
+ * gen_ai.input.messages — JSON array of input messages ({role, parts[]})
538
+ * gen_ai.output.messages — JSON array of output messages ({role, parts[], finish_reason})
539
+ * gen_ai.system_instructions — JSON array of system instruction parts
540
+ *
541
+ * Used by frameworks that follow the official spec:
542
+ * - Pydantic AI (scope: "pydantic-ai")
543
+ * - Any future OTel-compliant GenAI instrumentation
544
+ *
545
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/
546
+ */
547
+
548
+ declare class OtelGenAiTransformer implements ScopeTransformer {
549
+ classify(span: OtelSpan, attributes: Record<string, any>): SpanType;
550
+ transform(span: OtelSpan, attributes: Record<string, any>): Partial<NormalizedSpan>;
551
+ static readonly SCOPE_NAME = "pydantic-ai";
552
+ }
553
+
509
554
  declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: OtelSpan): NormalizedSpan;
510
555
  /**
511
556
  * Normalize spans from raw OTLP resourceSpans structure
@@ -513,4 +558,4 @@ declare function normalizeSpan(resource: OtelResource, scope: OtelScope, span: O
513
558
  */
514
559
  declare function normalizeOtlpSpans(resourceSpans: OtlpResourceSpans[]): NormalizedSpan[];
515
560
 
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 };
561
+ export { AGENTMARK_SCOPE_NAME, AgentMarkTransformer, type AgentmarkConfig, type AgentmarkModelConfig, type AgentmarkModelSchema, type AgentmarkModelSettingsConfig, type AgentmarkModelSettingsSchema, AiSdkTransformer, type AiSdkVersion, type AttributeExtractor, AgentMarkTransformer as ClaudeAgentTransformer, type GenerateTypesLanguage, MastraTransformer, type McpServerConfig, type McpServers, type McpStdioServerConfig, type McpUrlServerConfig, type Message, type ModelSettingsTypeAspectRatio, type ModelSettingsTypeImageSize, type ModelSettingsTypeSelect, type ModelSettingsTypeSlider, type NormalizedSpan, type OtelEvent, OtelGenAiTransformer, 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, SEMANTIC_KINDS, type ScopeTransformer, type SemanticKind, 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, resolveSemanticKind, toFrontMatter, typeClassifier, verifySignature };