tracia 0.3.10 → 0.4.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
@@ -8,6 +8,8 @@ interface RunVariables {
8
8
  }
9
9
  interface RunOptions {
10
10
  model?: string;
11
+ /** Run a specific prompt version instead of the latest */
12
+ version?: number;
11
13
  tags?: string[];
12
14
  userId?: string;
13
15
  sessionId?: string;
@@ -61,7 +63,13 @@ declare enum TraciaErrorCode {
61
63
  declare enum LLMProvider {
62
64
  OPENAI = "openai",
63
65
  ANTHROPIC = "anthropic",
64
- GOOGLE = "google"
66
+ GOOGLE = "google",
67
+ AMAZON_BEDROCK = "amazon_bedrock"
68
+ }
69
+ declare enum SpanKind {
70
+ ROOT = "ROOT",
71
+ LLM = "LLM",
72
+ EMBEDDING = "EMBEDDING"
65
73
  }
66
74
  interface ApiSuccessResponse {
67
75
  text: string;
@@ -338,7 +346,8 @@ interface CreateSpanPayload {
338
346
  model: string;
339
347
  provider: LLMProvider;
340
348
  input: {
341
- messages: LocalPromptMessage[];
349
+ messages?: LocalPromptMessage[];
350
+ text?: string | string[];
342
351
  };
343
352
  variables: Record<string, string> | null;
344
353
  output: string | null;
@@ -360,6 +369,8 @@ interface CreateSpanPayload {
360
369
  traceId?: string;
361
370
  /** Parent span ID for chaining spans in a sequence */
362
371
  parentSpanId?: string;
372
+ /** Span kind override (for embedding spans) */
373
+ spanKind?: SpanKind;
363
374
  }
364
375
  interface CreateSpanResult {
365
376
  spanId: string;
@@ -558,6 +569,65 @@ interface ResponsesStream {
558
569
  /** Abort the stream */
559
570
  abort(): void;
560
571
  }
572
+ interface RunEmbeddingInput {
573
+ /** Text(s) to embed */
574
+ input: string | string[];
575
+ /** Embedding model (e.g., 'text-embedding-3-small') */
576
+ model: string;
577
+ /** Explicitly specify the provider */
578
+ provider?: LLMProvider;
579
+ /** Provider API key override */
580
+ providerApiKey?: string;
581
+ /** Optional dimension override */
582
+ dimensions?: number;
583
+ /** Whether to send span to Tracia (default: true) */
584
+ sendTrace?: boolean;
585
+ /** Custom span ID */
586
+ spanId?: string;
587
+ /** Tags for the span */
588
+ tags?: string[];
589
+ /** User ID for the span */
590
+ userId?: string;
591
+ /** Session ID for the span */
592
+ sessionId?: string;
593
+ /** Trace ID to group related spans together */
594
+ traceId?: string;
595
+ /** Parent span ID for chaining spans in a sequence */
596
+ parentSpanId?: string;
597
+ /** Timeout in milliseconds */
598
+ timeoutMs?: number;
599
+ }
600
+ interface EmbeddingVector {
601
+ /** The embedding values */
602
+ values: number[];
603
+ /** Index of this embedding in the input array */
604
+ index: number;
605
+ }
606
+ interface EmbeddingUsage {
607
+ /** Total tokens used for the embedding request */
608
+ totalTokens: number;
609
+ }
610
+ interface RunEmbeddingResult {
611
+ /** The generated embeddings */
612
+ embeddings: EmbeddingVector[];
613
+ /** Span ID for this request */
614
+ spanId: string;
615
+ /** Trace ID grouping related spans */
616
+ traceId: string;
617
+ /** Latency in milliseconds */
618
+ latencyMs: number;
619
+ /** Token usage */
620
+ usage: EmbeddingUsage;
621
+ /**
622
+ * Estimated cost in USD.
623
+ * Currently always `null` — cost is calculated server-side when the span is ingested.
624
+ */
625
+ cost: number | null;
626
+ /** The provider used */
627
+ provider: LLMProvider;
628
+ /** The model used */
629
+ model: string;
630
+ }
561
631
  /** @deprecated Use SpanStatus instead */
562
632
  type TraceStatus = SpanStatus;
563
633
  /** @deprecated Use SpanListItem instead */
@@ -609,6 +679,11 @@ type SessionRunLocalInput = Omit<RunLocalInput, 'traceId' | 'parentSpanId'>;
609
679
  * as those are managed by the session.
610
680
  */
611
681
  type SessionRunResponsesInput = Omit<RunResponsesInput, 'traceId' | 'parentSpanId'>;
682
+ /**
683
+ * Input for session.runEmbedding() - same as RunEmbeddingInput but without traceId/parentSpanId
684
+ * as those are managed by the session.
685
+ */
686
+ type SessionRunEmbeddingInput = Omit<RunEmbeddingInput, 'traceId' | 'parentSpanId'>;
612
687
  /**
613
688
  * A session for grouping related spans together under a single trace.
614
689
  *
@@ -688,6 +763,11 @@ declare class TraciaSession {
688
763
  }): Promise<RunResponsesResult>;
689
764
  private runResponsesNonStreaming;
690
765
  private runResponsesStreaming;
766
+ /**
767
+ * Generate embeddings, automatically linking the span to this session.
768
+ * See Tracia.runEmbedding() for full documentation.
769
+ */
770
+ runEmbedding(input: SessionRunEmbeddingInput): Promise<RunEmbeddingResult>;
691
771
  private updateSessionState;
692
772
  }
693
773
 
@@ -811,6 +891,29 @@ declare class Tracia {
811
891
  private createResponsesStream;
812
892
  private createLocalStream;
813
893
  private combineAbortSignals;
894
+ /**
895
+ * Generate embeddings for text input(s) using an embedding model.
896
+ *
897
+ * @example Single text
898
+ * ```typescript
899
+ * const result = await tracia.runEmbedding({
900
+ * model: 'text-embedding-3-small',
901
+ * input: 'Hello world',
902
+ * })
903
+ * console.log(result.embeddings[0].values.length) // 1536
904
+ * ```
905
+ *
906
+ * @example Batch
907
+ * ```typescript
908
+ * const result = await tracia.runEmbedding({
909
+ * model: 'text-embedding-3-small',
910
+ * input: ['Hello', 'World'],
911
+ * })
912
+ * console.log(result.embeddings.length) // 2
913
+ * ```
914
+ */
915
+ runEmbedding(input: RunEmbeddingInput): Promise<RunEmbeddingResult>;
916
+ private validateRunEmbeddingInput;
814
917
  flush(): Promise<void>;
815
918
  /**
816
919
  * Create a new session for grouping related spans together under a single trace.
@@ -856,4 +959,4 @@ declare class Tracia {
856
959
  private getProviderApiKey;
857
960
  }
858
961
 
859
- export { type ContentPart, type CreatePromptOptions, type CreateSpanPayload, type CreateSpanResult, type CreateTracePayload, type CreateTraceResult, Eval, type EvaluateOptions, type EvaluateResult, type FinishReason, type JsonSchemaProperty, LLMProvider, type ListSpansOptions, type ListSpansResult, type ListTracesOptions, type ListTracesResult, type LocalPromptMessage, type LocalStream, type MessageRole, type Prompt, type PromptListItem, type PromptMessage, type ResponsesEvent, type ResponsesInputItem, type ResponsesOutputItem, type ResponsesStream, type RunLocalInput, type RunLocalResult, type RunOptions, type RunResponsesInput, type RunResponsesResult, type RunResult, type RunVariables, type SessionRunLocalInput, type SessionRunResponsesInput, type Span, type SpanListItem, type SpanStatus, type StreamResult, type TextPart, type TokenUsage, type ToolCall, type ToolCallPart, type ToolChoice, type ToolDefinition, type ToolParameters, type Trace, type TraceListItem, type TraceStatus, Tracia, TraciaError, TraciaErrorCode, type TraciaOptions, TraciaSession, type UpdatePromptOptions };
962
+ export { type ContentPart, type CreatePromptOptions, type CreateSpanPayload, type CreateSpanResult, type CreateTracePayload, type CreateTraceResult, type EmbeddingUsage, type EmbeddingVector, Eval, type EvaluateOptions, type EvaluateResult, type FinishReason, type JsonSchemaProperty, LLMProvider, type ListSpansOptions, type ListSpansResult, type ListTracesOptions, type ListTracesResult, type LocalPromptMessage, type LocalStream, type MessageRole, type Prompt, type PromptListItem, type PromptMessage, type ResponsesEvent, type ResponsesInputItem, type ResponsesOutputItem, type ResponsesStream, type RunEmbeddingInput, type RunEmbeddingResult, type RunLocalInput, type RunLocalResult, type RunOptions, type RunResponsesInput, type RunResponsesResult, type RunResult, type RunVariables, type SessionRunEmbeddingInput, type SessionRunLocalInput, type SessionRunResponsesInput, type Span, SpanKind, type SpanListItem, type SpanStatus, type StreamResult, type TextPart, type TokenUsage, type ToolCall, type ToolCallPart, type ToolChoice, type ToolDefinition, type ToolParameters, type Trace, type TraceListItem, type TraceStatus, Tracia, TraciaError, TraciaErrorCode, type TraciaOptions, TraciaSession, type UpdatePromptOptions };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,8 @@ interface RunVariables {
8
8
  }
9
9
  interface RunOptions {
10
10
  model?: string;
11
+ /** Run a specific prompt version instead of the latest */
12
+ version?: number;
11
13
  tags?: string[];
12
14
  userId?: string;
13
15
  sessionId?: string;
@@ -61,7 +63,13 @@ declare enum TraciaErrorCode {
61
63
  declare enum LLMProvider {
62
64
  OPENAI = "openai",
63
65
  ANTHROPIC = "anthropic",
64
- GOOGLE = "google"
66
+ GOOGLE = "google",
67
+ AMAZON_BEDROCK = "amazon_bedrock"
68
+ }
69
+ declare enum SpanKind {
70
+ ROOT = "ROOT",
71
+ LLM = "LLM",
72
+ EMBEDDING = "EMBEDDING"
65
73
  }
66
74
  interface ApiSuccessResponse {
67
75
  text: string;
@@ -338,7 +346,8 @@ interface CreateSpanPayload {
338
346
  model: string;
339
347
  provider: LLMProvider;
340
348
  input: {
341
- messages: LocalPromptMessage[];
349
+ messages?: LocalPromptMessage[];
350
+ text?: string | string[];
342
351
  };
343
352
  variables: Record<string, string> | null;
344
353
  output: string | null;
@@ -360,6 +369,8 @@ interface CreateSpanPayload {
360
369
  traceId?: string;
361
370
  /** Parent span ID for chaining spans in a sequence */
362
371
  parentSpanId?: string;
372
+ /** Span kind override (for embedding spans) */
373
+ spanKind?: SpanKind;
363
374
  }
364
375
  interface CreateSpanResult {
365
376
  spanId: string;
@@ -558,6 +569,65 @@ interface ResponsesStream {
558
569
  /** Abort the stream */
559
570
  abort(): void;
560
571
  }
572
+ interface RunEmbeddingInput {
573
+ /** Text(s) to embed */
574
+ input: string | string[];
575
+ /** Embedding model (e.g., 'text-embedding-3-small') */
576
+ model: string;
577
+ /** Explicitly specify the provider */
578
+ provider?: LLMProvider;
579
+ /** Provider API key override */
580
+ providerApiKey?: string;
581
+ /** Optional dimension override */
582
+ dimensions?: number;
583
+ /** Whether to send span to Tracia (default: true) */
584
+ sendTrace?: boolean;
585
+ /** Custom span ID */
586
+ spanId?: string;
587
+ /** Tags for the span */
588
+ tags?: string[];
589
+ /** User ID for the span */
590
+ userId?: string;
591
+ /** Session ID for the span */
592
+ sessionId?: string;
593
+ /** Trace ID to group related spans together */
594
+ traceId?: string;
595
+ /** Parent span ID for chaining spans in a sequence */
596
+ parentSpanId?: string;
597
+ /** Timeout in milliseconds */
598
+ timeoutMs?: number;
599
+ }
600
+ interface EmbeddingVector {
601
+ /** The embedding values */
602
+ values: number[];
603
+ /** Index of this embedding in the input array */
604
+ index: number;
605
+ }
606
+ interface EmbeddingUsage {
607
+ /** Total tokens used for the embedding request */
608
+ totalTokens: number;
609
+ }
610
+ interface RunEmbeddingResult {
611
+ /** The generated embeddings */
612
+ embeddings: EmbeddingVector[];
613
+ /** Span ID for this request */
614
+ spanId: string;
615
+ /** Trace ID grouping related spans */
616
+ traceId: string;
617
+ /** Latency in milliseconds */
618
+ latencyMs: number;
619
+ /** Token usage */
620
+ usage: EmbeddingUsage;
621
+ /**
622
+ * Estimated cost in USD.
623
+ * Currently always `null` — cost is calculated server-side when the span is ingested.
624
+ */
625
+ cost: number | null;
626
+ /** The provider used */
627
+ provider: LLMProvider;
628
+ /** The model used */
629
+ model: string;
630
+ }
561
631
  /** @deprecated Use SpanStatus instead */
562
632
  type TraceStatus = SpanStatus;
563
633
  /** @deprecated Use SpanListItem instead */
@@ -609,6 +679,11 @@ type SessionRunLocalInput = Omit<RunLocalInput, 'traceId' | 'parentSpanId'>;
609
679
  * as those are managed by the session.
610
680
  */
611
681
  type SessionRunResponsesInput = Omit<RunResponsesInput, 'traceId' | 'parentSpanId'>;
682
+ /**
683
+ * Input for session.runEmbedding() - same as RunEmbeddingInput but without traceId/parentSpanId
684
+ * as those are managed by the session.
685
+ */
686
+ type SessionRunEmbeddingInput = Omit<RunEmbeddingInput, 'traceId' | 'parentSpanId'>;
612
687
  /**
613
688
  * A session for grouping related spans together under a single trace.
614
689
  *
@@ -688,6 +763,11 @@ declare class TraciaSession {
688
763
  }): Promise<RunResponsesResult>;
689
764
  private runResponsesNonStreaming;
690
765
  private runResponsesStreaming;
766
+ /**
767
+ * Generate embeddings, automatically linking the span to this session.
768
+ * See Tracia.runEmbedding() for full documentation.
769
+ */
770
+ runEmbedding(input: SessionRunEmbeddingInput): Promise<RunEmbeddingResult>;
691
771
  private updateSessionState;
692
772
  }
693
773
 
@@ -811,6 +891,29 @@ declare class Tracia {
811
891
  private createResponsesStream;
812
892
  private createLocalStream;
813
893
  private combineAbortSignals;
894
+ /**
895
+ * Generate embeddings for text input(s) using an embedding model.
896
+ *
897
+ * @example Single text
898
+ * ```typescript
899
+ * const result = await tracia.runEmbedding({
900
+ * model: 'text-embedding-3-small',
901
+ * input: 'Hello world',
902
+ * })
903
+ * console.log(result.embeddings[0].values.length) // 1536
904
+ * ```
905
+ *
906
+ * @example Batch
907
+ * ```typescript
908
+ * const result = await tracia.runEmbedding({
909
+ * model: 'text-embedding-3-small',
910
+ * input: ['Hello', 'World'],
911
+ * })
912
+ * console.log(result.embeddings.length) // 2
913
+ * ```
914
+ */
915
+ runEmbedding(input: RunEmbeddingInput): Promise<RunEmbeddingResult>;
916
+ private validateRunEmbeddingInput;
814
917
  flush(): Promise<void>;
815
918
  /**
816
919
  * Create a new session for grouping related spans together under a single trace.
@@ -856,4 +959,4 @@ declare class Tracia {
856
959
  private getProviderApiKey;
857
960
  }
858
961
 
859
- export { type ContentPart, type CreatePromptOptions, type CreateSpanPayload, type CreateSpanResult, type CreateTracePayload, type CreateTraceResult, Eval, type EvaluateOptions, type EvaluateResult, type FinishReason, type JsonSchemaProperty, LLMProvider, type ListSpansOptions, type ListSpansResult, type ListTracesOptions, type ListTracesResult, type LocalPromptMessage, type LocalStream, type MessageRole, type Prompt, type PromptListItem, type PromptMessage, type ResponsesEvent, type ResponsesInputItem, type ResponsesOutputItem, type ResponsesStream, type RunLocalInput, type RunLocalResult, type RunOptions, type RunResponsesInput, type RunResponsesResult, type RunResult, type RunVariables, type SessionRunLocalInput, type SessionRunResponsesInput, type Span, type SpanListItem, type SpanStatus, type StreamResult, type TextPart, type TokenUsage, type ToolCall, type ToolCallPart, type ToolChoice, type ToolDefinition, type ToolParameters, type Trace, type TraceListItem, type TraceStatus, Tracia, TraciaError, TraciaErrorCode, type TraciaOptions, TraciaSession, type UpdatePromptOptions };
962
+ export { type ContentPart, type CreatePromptOptions, type CreateSpanPayload, type CreateSpanResult, type CreateTracePayload, type CreateTraceResult, type EmbeddingUsage, type EmbeddingVector, Eval, type EvaluateOptions, type EvaluateResult, type FinishReason, type JsonSchemaProperty, LLMProvider, type ListSpansOptions, type ListSpansResult, type ListTracesOptions, type ListTracesResult, type LocalPromptMessage, type LocalStream, type MessageRole, type Prompt, type PromptListItem, type PromptMessage, type ResponsesEvent, type ResponsesInputItem, type ResponsesOutputItem, type ResponsesStream, type RunEmbeddingInput, type RunEmbeddingResult, type RunLocalInput, type RunLocalResult, type RunOptions, type RunResponsesInput, type RunResponsesResult, type RunResult, type RunVariables, type SessionRunEmbeddingInput, type SessionRunLocalInput, type SessionRunResponsesInput, type Span, SpanKind, type SpanListItem, type SpanStatus, type StreamResult, type TextPart, type TokenUsage, type ToolCall, type ToolCallPart, type ToolChoice, type ToolDefinition, type ToolParameters, type Trace, type TraceListItem, type TraceStatus, Tracia, TraciaError, TraciaErrorCode, type TraciaOptions, TraciaSession, type UpdatePromptOptions };