@latitude-data/telemetry 1.0.1 → 1.0.3

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.cjs CHANGED
@@ -141,14 +141,16 @@ const env = { GATEWAY_BASE_URL: GET_GATEWAY_BASE_URL() };
141
141
  var SegmentSource;
142
142
  (function (SegmentSource) {
143
143
  SegmentSource["API"] = "api";
144
- SegmentSource["Playground"] = "playground";
145
- SegmentSource["Evaluation"] = "evaluation";
146
- SegmentSource["Experiment"] = "experiment";
147
- SegmentSource["User"] = "user";
148
- SegmentSource["SharedPrompt"] = "shared_prompt";
149
144
  SegmentSource["AgentAsTool"] = "agent_as_tool";
145
+ SegmentSource["Copilot"] = "copilot";
150
146
  SegmentSource["EmailTrigger"] = "email_trigger";
147
+ SegmentSource["Evaluation"] = "evaluation";
148
+ SegmentSource["Experiment"] = "experiment";
149
+ SegmentSource["Playground"] = "playground";
151
150
  SegmentSource["ScheduledTrigger"] = "scheduled_trigger";
151
+ SegmentSource["IntegrationTrigger"] = "integration_trigger";
152
+ SegmentSource["SharedPrompt"] = "shared_prompt";
153
+ SegmentSource["User"] = "user";
152
154
  })(SegmentSource || (SegmentSource = {}));
153
155
  var SegmentType;
154
156
  (function (SegmentType) {
@@ -248,7 +250,7 @@ const SPAN_SPECIFICATIONS = {
248
250
  name: 'Segment',
249
251
  description: 'A (partial) segment of a trace',
250
252
  isGenAI: false,
251
- isHidden: true,
253
+ isHidden: false,
252
254
  },
253
255
  [SpanType.Unknown]: {
254
256
  name: 'Unknown',
@@ -431,16 +433,6 @@ zod.z.object({
431
433
  isError: zod.z.boolean().optional(),
432
434
  text: zod.z.string().optional(),
433
435
  });
434
- var FinishReason;
435
- (function (FinishReason) {
436
- FinishReason["Stop"] = "stop";
437
- FinishReason["Length"] = "length";
438
- FinishReason["ContentFilter"] = "content-filter";
439
- FinishReason["ToolCalls"] = "tool-calls";
440
- FinishReason["Error"] = "error";
441
- FinishReason["Other"] = "other";
442
- FinishReason["Unknown"] = "unknown";
443
- })(FinishReason || (FinishReason = {}));
444
436
 
445
437
  var ParameterType;
446
438
  (function (ParameterType) {
@@ -778,17 +770,18 @@ var LegacyChainEventTypes;
778
770
 
779
771
  var ChainEventTypes;
780
772
  (function (ChainEventTypes) {
773
+ ChainEventTypes["ChainCompleted"] = "chain-completed";
774
+ ChainEventTypes["ChainError"] = "chain-error";
781
775
  ChainEventTypes["ChainStarted"] = "chain-started";
782
- ChainEventTypes["StepStarted"] = "step-started";
783
- ChainEventTypes["ProviderStarted"] = "provider-started";
776
+ ChainEventTypes["IntegrationWakingUp"] = "integration-waking-up";
784
777
  ChainEventTypes["ProviderCompleted"] = "provider-completed";
785
- ChainEventTypes["ToolsStarted"] = "tools-started";
786
- ChainEventTypes["ToolCompleted"] = "tool-completed";
778
+ ChainEventTypes["ProviderStarted"] = "provider-started";
787
779
  ChainEventTypes["StepCompleted"] = "step-completed";
788
- ChainEventTypes["ChainCompleted"] = "chain-completed";
789
- ChainEventTypes["ChainError"] = "chain-error";
780
+ ChainEventTypes["StepStarted"] = "step-started";
781
+ ChainEventTypes["ToolCompleted"] = "tool-completed";
790
782
  ChainEventTypes["ToolsRequested"] = "tools-requested";
791
- ChainEventTypes["IntegrationWakingUp"] = "integration-waking-up";
783
+ ChainEventTypes["ToolResult"] = "tool-result";
784
+ ChainEventTypes["ToolsStarted"] = "tools-started";
792
785
  })(ChainEventTypes || (ChainEventTypes = {}));
793
786
 
794
787
  var IntegrationType;
@@ -901,6 +894,14 @@ var EvaluationResultableType;
901
894
  EvaluationResultableType["Number"] = "evaluation_resultable_numbers";
902
895
  })(EvaluationResultableType || (EvaluationResultableType = {}));
903
896
 
897
+ var MessageRole;
898
+ (function (MessageRole) {
899
+ MessageRole["system"] = "system";
900
+ MessageRole["user"] = "user";
901
+ MessageRole["assistant"] = "assistant";
902
+ MessageRole["tool"] = "tool";
903
+ })(MessageRole || (MessageRole = {}));
904
+
904
905
  var ModifiedDocumentType;
905
906
  (function (ModifiedDocumentType) {
906
907
  ModifiedDocumentType["Created"] = "created";
@@ -936,6 +937,7 @@ var DocumentTriggerType;
936
937
  (function (DocumentTriggerType) {
937
938
  DocumentTriggerType["Email"] = "email";
938
939
  DocumentTriggerType["Scheduled"] = "scheduled";
940
+ DocumentTriggerType["Integration"] = "integration";
939
941
  })(DocumentTriggerType || (DocumentTriggerType = {}));
940
942
  var DocumentTriggerParameters;
941
943
  (function (DocumentTriggerParameters) {
@@ -1602,44 +1604,6 @@ class LatitudeInstrumentation {
1602
1604
  // Note: this is an estimation to not bundle a tokenizer
1603
1605
  return Math.ceil(length / 4);
1604
1606
  }
1605
- withTraceContext(ctx, fn) {
1606
- return otel.context.with(this.telemetry.resume(ctx), fn);
1607
- }
1608
- async wrapToolHandler(fn, ...args) {
1609
- const toolArguments = args[0];
1610
- const { toolId, toolName } = args[1];
1611
- const $tool = this.telemetry.tool(otel.context.active(), {
1612
- name: toolName,
1613
- call: {
1614
- id: toolId,
1615
- arguments: toolArguments,
1616
- },
1617
- });
1618
- let result;
1619
- try {
1620
- result = await otel.context.with($tool.context, async () => await fn(...args));
1621
- }
1622
- catch (error) {
1623
- if (error.name === 'ToolExecutionPausedError') {
1624
- $tool.fail(error);
1625
- throw error;
1626
- }
1627
- $tool.end({
1628
- result: {
1629
- value: error.message,
1630
- isError: true,
1631
- },
1632
- });
1633
- throw error;
1634
- }
1635
- $tool.end({
1636
- result: {
1637
- value: result,
1638
- isError: false,
1639
- },
1640
- });
1641
- return result;
1642
- }
1643
1607
  async wrapRenderChain(fn, ...args) {
1644
1608
  const { prompt, parameters } = args[0];
1645
1609
  const $prompt = this.telemetry.prompt(otel.context.active(), {
@@ -1659,25 +1623,6 @@ class LatitudeInstrumentation {
1659
1623
  $prompt.end();
1660
1624
  return result;
1661
1625
  }
1662
- async wrapRenderAgent(fn, ...args) {
1663
- const { prompt, parameters } = args[0];
1664
- const $prompt = this.telemetry.prompt(otel.context.active(), {
1665
- versionUuid: prompt.versionUuid,
1666
- promptUuid: prompt.uuid,
1667
- template: prompt.content,
1668
- parameters: parameters,
1669
- });
1670
- let result;
1671
- try {
1672
- result = await otel.context.with($prompt.context, async () => await fn(...args));
1673
- }
1674
- catch (error) {
1675
- $prompt.fail(error);
1676
- throw error;
1677
- }
1678
- $prompt.end();
1679
- return result;
1680
- }
1681
1626
  async wrapRenderStep(fn, ...args) {
1682
1627
  const $step = this.telemetry.step(otel.context.active());
1683
1628
  let result;
@@ -1748,8 +1693,8 @@ class LatitudeInstrumentation {
1748
1693
  }
1749
1694
  $tool.end({
1750
1695
  result: {
1751
- value: result,
1752
- isError: false, // Note: currently unknown
1696
+ value: result.result,
1697
+ isError: result.isError,
1753
1698
  },
1754
1699
  });
1755
1700
  return result;