raindrop-ai 0.0.82 → 0.0.83

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.
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "raindrop-ai",
4
- version: "0.0.82",
4
+ version: "0.0.83",
5
5
  main: "dist/index.js",
6
6
  module: "dist/index.mjs",
7
7
  types: "dist/index.d.ts",
@@ -462,18 +462,23 @@ function setAssociationProperties(span, properties) {
462
462
  span.setAttribute("traceloop.association.properties." + key, String(value));
463
463
  });
464
464
  }
465
+ function serializeSpanValue(value) {
466
+ if (typeof value === "string") {
467
+ return value;
468
+ }
469
+ const jsonValue = JSON.stringify(value);
470
+ return jsonValue === void 0 ? String(value) : jsonValue;
471
+ }
465
472
  var LiveToolSpan = class {
466
473
  constructor(span) {
467
474
  this.hasError = false;
468
475
  this.span = span;
469
476
  }
470
477
  setInput(input) {
471
- const inputStr = typeof input === "string" ? input : JSON.stringify(input);
472
- this.span.setAttribute("traceloop.entity.input", inputStr);
478
+ this.span.setAttribute("traceloop.entity.input", serializeSpanValue(input));
473
479
  }
474
480
  setOutput(output) {
475
- const outputStr = typeof output === "string" ? output : JSON.stringify(output);
476
- this.span.setAttribute("traceloop.entity.output", outputStr);
481
+ this.span.setAttribute("traceloop.entity.output", serializeSpanValue(output));
477
482
  }
478
483
  setError(error) {
479
484
  this.hasError = true;
@@ -488,6 +493,46 @@ var LiveToolSpan = class {
488
493
  this.span.end();
489
494
  }
490
495
  };
496
+ var DirectToolSpan = class {
497
+ constructor(params) {
498
+ this.ended = false;
499
+ this.name = params.name;
500
+ this.properties = params.properties;
501
+ this.directShipper = params.directShipper;
502
+ this.traceId = params.traceId;
503
+ this.parentSpanId = params.parentSpanId;
504
+ this.startTimeMs = Date.now();
505
+ this.input = params.input !== void 0 ? serializeSpanValue(params.input) : void 0;
506
+ }
507
+ setInput(input) {
508
+ this.input = serializeSpanValue(input);
509
+ }
510
+ setOutput(output) {
511
+ this.output = serializeSpanValue(output);
512
+ }
513
+ setError(error) {
514
+ this.error = error instanceof Error ? error.message : String(error);
515
+ }
516
+ end() {
517
+ if (this.ended) {
518
+ return;
519
+ }
520
+ this.ended = true;
521
+ const endTimeMs = Date.now();
522
+ this.directShipper.sendToolSpan({
523
+ name: this.name,
524
+ input: this.input,
525
+ output: this.output,
526
+ durationMs: endTimeMs - this.startTimeMs,
527
+ startTimeMs: this.startTimeMs,
528
+ endTimeMs,
529
+ error: this.error,
530
+ properties: this.properties,
531
+ traceId: this.traceId,
532
+ parentSpanId: this.parentSpanId
533
+ });
534
+ }
535
+ };
491
536
  var LiveInteraction = class {
492
537
  constructor(context3, traceId, analytics, directShipper) {
493
538
  this.context = context3;
@@ -601,18 +646,35 @@ var LiveInteraction = class {
601
646
  return span;
602
647
  }
603
648
  startToolSpan(params) {
604
- var _a;
649
+ var _a, _b;
605
650
  const { name, properties = {}, inputParameters } = params;
606
- const span = this.tracer.startSpan(name);
607
651
  const contextProperties = getPropertiesFromContext(this.context);
652
+ const mergedProperties = {
653
+ ...contextProperties,
654
+ ...properties
655
+ };
656
+ if (this.directShipper) {
657
+ const { traceIdB64, parentSpanIdB64 } = getActiveTraceContext();
658
+ if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
659
+ console.log(`[raindrop] startToolSpan (direct): started tool span "${name}"`);
660
+ }
661
+ return new DirectToolSpan({
662
+ name,
663
+ properties: mergedProperties,
664
+ directShipper: this.directShipper,
665
+ traceId: traceIdB64,
666
+ parentSpanId: parentSpanIdB64,
667
+ input: inputParameters
668
+ });
669
+ }
670
+ const span = this.tracer.startSpan(name);
608
671
  setAssociationProperties(span, contextProperties);
609
672
  span.setAttribute("traceloop.span.kind", "tool");
610
673
  setAssociationProperties(span, properties);
611
674
  if (inputParameters !== void 0) {
612
- const inputStr = typeof inputParameters === "string" ? inputParameters : JSON.stringify(inputParameters);
613
- span.setAttribute("traceloop.entity.input", inputStr);
675
+ span.setAttribute("traceloop.entity.input", serializeSpanValue(inputParameters));
614
676
  }
615
- if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
677
+ if ((_b = this.analytics) == null ? void 0 : _b.debugLogs) {
616
678
  console.log(`[raindrop] startToolSpan: started tool span "${name}"`);
617
679
  }
618
680
  return new LiveToolSpan(span);
package/dist/index.d.mts CHANGED
@@ -622,7 +622,7 @@ interface AnalyticsConfig {
622
622
  */
623
623
  disableBatching?: boolean;
624
624
  /**
625
- * When true, all `trackTool()` and `withTool()` calls bypass the OTEL
625
+ * When true, all `trackTool()`, `withTool()`, and `startToolSpan()` calls bypass the OTEL
626
626
  * exporter pipeline and ship spans directly to the Raindrop API via HTTP POST.
627
627
  *
628
628
  * Spans still read the active OTEL context to inherit traceId
package/dist/index.d.ts CHANGED
@@ -622,7 +622,7 @@ interface AnalyticsConfig {
622
622
  */
623
623
  disableBatching?: boolean;
624
624
  /**
625
- * When true, all `trackTool()` and `withTool()` calls bypass the OTEL
625
+ * When true, all `trackTool()`, `withTool()`, and `startToolSpan()` calls bypass the OTEL
626
626
  * exporter pipeline and ship spans directly to the Raindrop API via HTTP POST.
627
627
  *
628
628
  * Spans still read the active OTEL context to inherit traceId
package/dist/index.js CHANGED
@@ -119,7 +119,7 @@ var SignalEventSchema = import_zod.z.object({
119
119
  properties: import_zod.z.record(import_zod.z.any()).optional().nullable(),
120
120
  attachment_id: import_zod.z.string().optional().nullable(),
121
121
  sentiment: import_zod.z.enum(["POSITIVE", "NEGATIVE"]).optional().nullable(),
122
- signal_type: import_zod.z.enum(["default", "feedback", "edit", "standard"]).default("default")
122
+ signal_type: import_zod.z.enum(["default", "feedback", "edit", "standard", "agent", "agent_internal"]).default("default")
123
123
  });
124
124
  var LegacyAiTrackEventSchema = TrackEventSchema.extend({
125
125
  model: import_zod.z.string().optional(),
@@ -138,7 +138,7 @@ var CategorizationRequestSchema = import_zod.z.object({
138
138
  // package.json
139
139
  var package_default = {
140
140
  name: "raindrop-ai",
141
- version: "0.0.82",
141
+ version: "0.0.83",
142
142
  main: "dist/index.js",
143
143
  module: "dist/index.mjs",
144
144
  types: "dist/index.d.ts",
@@ -685,18 +685,23 @@ function setAssociationProperties(span, properties) {
685
685
  span.setAttribute("traceloop.association.properties." + key, String(value));
686
686
  });
687
687
  }
688
+ function serializeSpanValue(value) {
689
+ if (typeof value === "string") {
690
+ return value;
691
+ }
692
+ const jsonValue = JSON.stringify(value);
693
+ return jsonValue === void 0 ? String(value) : jsonValue;
694
+ }
688
695
  var LiveToolSpan = class {
689
696
  constructor(span) {
690
697
  this.hasError = false;
691
698
  this.span = span;
692
699
  }
693
700
  setInput(input) {
694
- const inputStr = typeof input === "string" ? input : JSON.stringify(input);
695
- this.span.setAttribute("traceloop.entity.input", inputStr);
701
+ this.span.setAttribute("traceloop.entity.input", serializeSpanValue(input));
696
702
  }
697
703
  setOutput(output) {
698
- const outputStr = typeof output === "string" ? output : JSON.stringify(output);
699
- this.span.setAttribute("traceloop.entity.output", outputStr);
704
+ this.span.setAttribute("traceloop.entity.output", serializeSpanValue(output));
700
705
  }
701
706
  setError(error) {
702
707
  this.hasError = true;
@@ -711,6 +716,46 @@ var LiveToolSpan = class {
711
716
  this.span.end();
712
717
  }
713
718
  };
719
+ var DirectToolSpan = class {
720
+ constructor(params) {
721
+ this.ended = false;
722
+ this.name = params.name;
723
+ this.properties = params.properties;
724
+ this.directShipper = params.directShipper;
725
+ this.traceId = params.traceId;
726
+ this.parentSpanId = params.parentSpanId;
727
+ this.startTimeMs = Date.now();
728
+ this.input = params.input !== void 0 ? serializeSpanValue(params.input) : void 0;
729
+ }
730
+ setInput(input) {
731
+ this.input = serializeSpanValue(input);
732
+ }
733
+ setOutput(output) {
734
+ this.output = serializeSpanValue(output);
735
+ }
736
+ setError(error) {
737
+ this.error = error instanceof Error ? error.message : String(error);
738
+ }
739
+ end() {
740
+ if (this.ended) {
741
+ return;
742
+ }
743
+ this.ended = true;
744
+ const endTimeMs = Date.now();
745
+ this.directShipper.sendToolSpan({
746
+ name: this.name,
747
+ input: this.input,
748
+ output: this.output,
749
+ durationMs: endTimeMs - this.startTimeMs,
750
+ startTimeMs: this.startTimeMs,
751
+ endTimeMs,
752
+ error: this.error,
753
+ properties: this.properties,
754
+ traceId: this.traceId,
755
+ parentSpanId: this.parentSpanId
756
+ });
757
+ }
758
+ };
714
759
  var LiveInteraction = class {
715
760
  constructor(context3, traceId, analytics, directShipper) {
716
761
  this.context = context3;
@@ -824,18 +869,35 @@ var LiveInteraction = class {
824
869
  return span;
825
870
  }
826
871
  startToolSpan(params) {
827
- var _a;
872
+ var _a, _b;
828
873
  const { name, properties = {}, inputParameters } = params;
829
- const span = this.tracer.startSpan(name);
830
874
  const contextProperties = getPropertiesFromContext(this.context);
875
+ const mergedProperties = {
876
+ ...contextProperties,
877
+ ...properties
878
+ };
879
+ if (this.directShipper) {
880
+ const { traceIdB64, parentSpanIdB64 } = getActiveTraceContext();
881
+ if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
882
+ console.log(`[raindrop] startToolSpan (direct): started tool span "${name}"`);
883
+ }
884
+ return new DirectToolSpan({
885
+ name,
886
+ properties: mergedProperties,
887
+ directShipper: this.directShipper,
888
+ traceId: traceIdB64,
889
+ parentSpanId: parentSpanIdB64,
890
+ input: inputParameters
891
+ });
892
+ }
893
+ const span = this.tracer.startSpan(name);
831
894
  setAssociationProperties(span, contextProperties);
832
895
  span.setAttribute("traceloop.span.kind", "tool");
833
896
  setAssociationProperties(span, properties);
834
897
  if (inputParameters !== void 0) {
835
- const inputStr = typeof inputParameters === "string" ? inputParameters : JSON.stringify(inputParameters);
836
- span.setAttribute("traceloop.entity.input", inputStr);
898
+ span.setAttribute("traceloop.entity.input", serializeSpanValue(inputParameters));
837
899
  }
838
- if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
900
+ if ((_b = this.analytics) == null ? void 0 : _b.debugLogs) {
839
901
  console.log(`[raindrop] startToolSpan: started tool span "${name}"`);
840
902
  }
841
903
  return new LiveToolSpan(span);
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  package_default,
3
3
  tracing
4
- } from "./chunk-KDYWEOQ4.mjs";
4
+ } from "./chunk-CYYFVRZF.mjs";
5
5
 
6
6
  // ../schemas/src/ingest/index.ts
7
7
  import { z } from "zod";
@@ -86,7 +86,7 @@ var SignalEventSchema = z.object({
86
86
  properties: z.record(z.any()).optional().nullable(),
87
87
  attachment_id: z.string().optional().nullable(),
88
88
  sentiment: z.enum(["POSITIVE", "NEGATIVE"]).optional().nullable(),
89
- signal_type: z.enum(["default", "feedback", "edit", "standard"]).default("default")
89
+ signal_type: z.enum(["default", "feedback", "edit", "standard", "agent", "agent_internal"]).default("default")
90
90
  });
91
91
  var LegacyAiTrackEventSchema = TrackEventSchema.extend({
92
92
  model: z.string().optional(),
@@ -20,8 +20,8 @@ interface TracingOptions extends traceloop.InitializeOptions {
20
20
  */
21
21
  disableBatching?: boolean;
22
22
  /**
23
- * When true, all trackTool() calls bypass the OTEL exporter pipeline
24
- * and ship spans directly via HTTP POST.
23
+ * When true, tool spans from trackTool(), withTool(), and startToolSpan()
24
+ * bypass the OTEL exporter pipeline and ship directly via HTTP POST.
25
25
  */
26
26
  bypassOtelForTools?: boolean;
27
27
  /**
@@ -20,8 +20,8 @@ interface TracingOptions extends traceloop.InitializeOptions {
20
20
  */
21
21
  disableBatching?: boolean;
22
22
  /**
23
- * When true, all trackTool() calls bypass the OTEL exporter pipeline
24
- * and ship spans directly via HTTP POST.
23
+ * When true, tool spans from trackTool(), withTool(), and startToolSpan()
24
+ * bypass the OTEL exporter pipeline and ship directly via HTTP POST.
25
25
  */
26
26
  bypassOtelForTools?: boolean;
27
27
  /**
@@ -184,7 +184,7 @@ function base64Encode(bytes) {
184
184
  // package.json
185
185
  var package_default = {
186
186
  name: "raindrop-ai",
187
- version: "0.0.82",
187
+ version: "0.0.83",
188
188
  main: "dist/index.js",
189
189
  module: "dist/index.mjs",
190
190
  types: "dist/index.d.ts",
@@ -496,18 +496,23 @@ function setAssociationProperties(span, properties) {
496
496
  span.setAttribute("traceloop.association.properties." + key, String(value));
497
497
  });
498
498
  }
499
+ function serializeSpanValue(value) {
500
+ if (typeof value === "string") {
501
+ return value;
502
+ }
503
+ const jsonValue = JSON.stringify(value);
504
+ return jsonValue === void 0 ? String(value) : jsonValue;
505
+ }
499
506
  var LiveToolSpan = class {
500
507
  constructor(span) {
501
508
  this.hasError = false;
502
509
  this.span = span;
503
510
  }
504
511
  setInput(input) {
505
- const inputStr = typeof input === "string" ? input : JSON.stringify(input);
506
- this.span.setAttribute("traceloop.entity.input", inputStr);
512
+ this.span.setAttribute("traceloop.entity.input", serializeSpanValue(input));
507
513
  }
508
514
  setOutput(output) {
509
- const outputStr = typeof output === "string" ? output : JSON.stringify(output);
510
- this.span.setAttribute("traceloop.entity.output", outputStr);
515
+ this.span.setAttribute("traceloop.entity.output", serializeSpanValue(output));
511
516
  }
512
517
  setError(error) {
513
518
  this.hasError = true;
@@ -522,6 +527,46 @@ var LiveToolSpan = class {
522
527
  this.span.end();
523
528
  }
524
529
  };
530
+ var DirectToolSpan = class {
531
+ constructor(params) {
532
+ this.ended = false;
533
+ this.name = params.name;
534
+ this.properties = params.properties;
535
+ this.directShipper = params.directShipper;
536
+ this.traceId = params.traceId;
537
+ this.parentSpanId = params.parentSpanId;
538
+ this.startTimeMs = Date.now();
539
+ this.input = params.input !== void 0 ? serializeSpanValue(params.input) : void 0;
540
+ }
541
+ setInput(input) {
542
+ this.input = serializeSpanValue(input);
543
+ }
544
+ setOutput(output) {
545
+ this.output = serializeSpanValue(output);
546
+ }
547
+ setError(error) {
548
+ this.error = error instanceof Error ? error.message : String(error);
549
+ }
550
+ end() {
551
+ if (this.ended) {
552
+ return;
553
+ }
554
+ this.ended = true;
555
+ const endTimeMs = Date.now();
556
+ this.directShipper.sendToolSpan({
557
+ name: this.name,
558
+ input: this.input,
559
+ output: this.output,
560
+ durationMs: endTimeMs - this.startTimeMs,
561
+ startTimeMs: this.startTimeMs,
562
+ endTimeMs,
563
+ error: this.error,
564
+ properties: this.properties,
565
+ traceId: this.traceId,
566
+ parentSpanId: this.parentSpanId
567
+ });
568
+ }
569
+ };
525
570
  var LiveInteraction = class {
526
571
  constructor(context3, traceId, analytics, directShipper) {
527
572
  this.context = context3;
@@ -635,18 +680,35 @@ var LiveInteraction = class {
635
680
  return span;
636
681
  }
637
682
  startToolSpan(params) {
638
- var _a;
683
+ var _a, _b;
639
684
  const { name, properties = {}, inputParameters } = params;
640
- const span = this.tracer.startSpan(name);
641
685
  const contextProperties = getPropertiesFromContext(this.context);
686
+ const mergedProperties = {
687
+ ...contextProperties,
688
+ ...properties
689
+ };
690
+ if (this.directShipper) {
691
+ const { traceIdB64, parentSpanIdB64 } = getActiveTraceContext();
692
+ if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
693
+ console.log(`[raindrop] startToolSpan (direct): started tool span "${name}"`);
694
+ }
695
+ return new DirectToolSpan({
696
+ name,
697
+ properties: mergedProperties,
698
+ directShipper: this.directShipper,
699
+ traceId: traceIdB64,
700
+ parentSpanId: parentSpanIdB64,
701
+ input: inputParameters
702
+ });
703
+ }
704
+ const span = this.tracer.startSpan(name);
642
705
  setAssociationProperties(span, contextProperties);
643
706
  span.setAttribute("traceloop.span.kind", "tool");
644
707
  setAssociationProperties(span, properties);
645
708
  if (inputParameters !== void 0) {
646
- const inputStr = typeof inputParameters === "string" ? inputParameters : JSON.stringify(inputParameters);
647
- span.setAttribute("traceloop.entity.input", inputStr);
709
+ span.setAttribute("traceloop.entity.input", serializeSpanValue(inputParameters));
648
710
  }
649
- if ((_a = this.analytics) == null ? void 0 : _a.debugLogs) {
711
+ if ((_b = this.analytics) == null ? void 0 : _b.debugLogs) {
650
712
  console.log(`[raindrop] startToolSpan: started tool span "${name}"`);
651
713
  }
652
714
  return new LiveToolSpan(span);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "../chunk-KDYWEOQ4.mjs";
3
+ } from "../chunk-CYYFVRZF.mjs";
4
4
 
5
5
  // src/tracing/index.ts
6
6
  function initTracing() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raindrop-ai",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",