raindrop-ai 0.0.87 → 0.0.88-otelv2

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.87",
4
+ version: "0.0.88",
5
5
  main: "dist/index.js",
6
6
  module: "dist/index.mjs",
7
7
  types: "dist/index.d.ts",
@@ -725,10 +725,7 @@ var LiveInteraction = class {
725
725
  }
726
726
  addAttachments(attachments) {
727
727
  var _a;
728
- if (!this.context.attachments) {
729
- this.context.attachments = [];
730
- }
731
- this.context.attachments.push(...attachments);
728
+ this.context.attachments = [...this.context.attachments || [], ...attachments];
732
729
  (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
733
730
  eventId: this.context.eventId,
734
731
  attachments
@@ -937,6 +934,118 @@ var LiveTracer = class {
937
934
  };
938
935
 
939
936
  // src/tracing/tracer-core.ts
937
+ try {
938
+ const _bedrockProto = BedrockInstrumentation.prototype;
939
+ _bedrockProto._wrapPromise = function(span, promise) {
940
+ const inst = this;
941
+ return promise.then(async (result) => {
942
+ const rec = result;
943
+ const body = rec == null ? void 0 : rec.body;
944
+ const isStreamBody = body != null && typeof body === "object" && Symbol.asyncIterator in body && !(body instanceof Uint8Array);
945
+ if (!isStreamBody) {
946
+ try {
947
+ await inst._endSpan({ span, result });
948
+ } catch (e) {
949
+ console.warn(
950
+ "[raindrop] Bedrock instrumentation could not process response \u2014 passing through unchanged.",
951
+ e instanceof Error ? e.message : e
952
+ );
953
+ span.setStatus({
954
+ code: SpanStatusCode3.ERROR,
955
+ message: e instanceof Error ? e.message : String(e)
956
+ });
957
+ span.end();
958
+ }
959
+ return result;
960
+ }
961
+ const origIterator = body[Symbol.asyncIterator]();
962
+ const chunks = [];
963
+ let spanEnded = false;
964
+ rec.body = {
965
+ [Symbol.asyncIterator]() {
966
+ return {
967
+ async next() {
968
+ try {
969
+ const iterResult = await origIterator.next();
970
+ if (iterResult.done) {
971
+ try {
972
+ async function* replay() {
973
+ for (const c of chunks) yield c;
974
+ }
975
+ await inst._endSpan({
976
+ span,
977
+ result: { ...rec, body: replay() }
978
+ });
979
+ } catch (e) {
980
+ console.warn(
981
+ "[raindrop] Bedrock instrumentation could not process streaming response \u2014 passing through unchanged.",
982
+ e instanceof Error ? e.message : e
983
+ );
984
+ if (!spanEnded) {
985
+ span.setStatus({
986
+ code: SpanStatusCode3.ERROR,
987
+ message: e instanceof Error ? e.message : String(e)
988
+ });
989
+ span.end();
990
+ }
991
+ }
992
+ spanEnded = true;
993
+ return { done: true, value: void 0 };
994
+ }
995
+ chunks.push(iterResult.value);
996
+ return { done: false, value: iterResult.value };
997
+ } catch (error) {
998
+ if (!spanEnded) {
999
+ const msg = error instanceof Error ? error.message : String(error);
1000
+ span.setStatus({ code: SpanStatusCode3.ERROR, message: msg });
1001
+ span.recordException(error);
1002
+ span.end();
1003
+ spanEnded = true;
1004
+ }
1005
+ throw error;
1006
+ }
1007
+ },
1008
+ async return(value) {
1009
+ var _a;
1010
+ if (!spanEnded) {
1011
+ span.end();
1012
+ spanEnded = true;
1013
+ }
1014
+ await ((_a = origIterator.return) == null ? void 0 : _a.call(origIterator, value));
1015
+ return { done: true, value: void 0 };
1016
+ }
1017
+ };
1018
+ }
1019
+ };
1020
+ return result;
1021
+ }).catch((error) => {
1022
+ span.setStatus({
1023
+ code: SpanStatusCode3.ERROR,
1024
+ message: error.message
1025
+ });
1026
+ span.recordException(error);
1027
+ span.end();
1028
+ throw error;
1029
+ });
1030
+ };
1031
+ _bedrockProto._extractVendorAndModel = function(modelId) {
1032
+ if (!modelId) {
1033
+ return { modelVendor: "", model: "" };
1034
+ }
1035
+ const parts = modelId.split(".");
1036
+ if (parts.length >= 3 && /^[a-z]{2}$/.test(parts[0])) {
1037
+ return {
1038
+ modelVendor: parts[1] || "",
1039
+ model: parts.slice(2).join(".")
1040
+ };
1041
+ }
1042
+ return {
1043
+ modelVendor: parts[0] || "",
1044
+ model: parts[1] || ""
1045
+ };
1046
+ };
1047
+ } catch (e) {
1048
+ }
940
1049
  function patchBedrockStreamingBug(inst) {
941
1050
  const anyInst = inst;
942
1051
  const origEndSpan = anyInst._endSpan.bind(anyInst);
package/dist/index.js CHANGED
@@ -152,7 +152,7 @@ var CategorizationRequestSchema = import_zod.z.object({
152
152
  // package.json
153
153
  var package_default = {
154
154
  name: "raindrop-ai",
155
- version: "0.0.87",
155
+ version: "0.0.88",
156
156
  main: "dist/index.js",
157
157
  module: "dist/index.mjs",
158
158
  types: "dist/index.d.ts",
@@ -962,10 +962,7 @@ var LiveInteraction = class {
962
962
  }
963
963
  addAttachments(attachments) {
964
964
  var _a;
965
- if (!this.context.attachments) {
966
- this.context.attachments = [];
967
- }
968
- this.context.attachments.push(...attachments);
965
+ this.context.attachments = [...this.context.attachments || [], ...attachments];
969
966
  (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
970
967
  eventId: this.context.eventId,
971
968
  attachments
@@ -1174,6 +1171,118 @@ var LiveTracer = class {
1174
1171
  };
1175
1172
 
1176
1173
  // src/tracing/tracer-core.ts
1174
+ try {
1175
+ const _bedrockProto = import_instrumentation_bedrock.BedrockInstrumentation.prototype;
1176
+ _bedrockProto._wrapPromise = function(span, promise) {
1177
+ const inst = this;
1178
+ return promise.then(async (result) => {
1179
+ const rec = result;
1180
+ const body = rec == null ? void 0 : rec.body;
1181
+ const isStreamBody = body != null && typeof body === "object" && Symbol.asyncIterator in body && !(body instanceof Uint8Array);
1182
+ if (!isStreamBody) {
1183
+ try {
1184
+ await inst._endSpan({ span, result });
1185
+ } catch (e) {
1186
+ console.warn(
1187
+ "[raindrop] Bedrock instrumentation could not process response \u2014 passing through unchanged.",
1188
+ e instanceof Error ? e.message : e
1189
+ );
1190
+ span.setStatus({
1191
+ code: import_api4.SpanStatusCode.ERROR,
1192
+ message: e instanceof Error ? e.message : String(e)
1193
+ });
1194
+ span.end();
1195
+ }
1196
+ return result;
1197
+ }
1198
+ const origIterator = body[Symbol.asyncIterator]();
1199
+ const chunks = [];
1200
+ let spanEnded = false;
1201
+ rec.body = {
1202
+ [Symbol.asyncIterator]() {
1203
+ return {
1204
+ async next() {
1205
+ try {
1206
+ const iterResult = await origIterator.next();
1207
+ if (iterResult.done) {
1208
+ try {
1209
+ async function* replay() {
1210
+ for (const c of chunks) yield c;
1211
+ }
1212
+ await inst._endSpan({
1213
+ span,
1214
+ result: { ...rec, body: replay() }
1215
+ });
1216
+ } catch (e) {
1217
+ console.warn(
1218
+ "[raindrop] Bedrock instrumentation could not process streaming response \u2014 passing through unchanged.",
1219
+ e instanceof Error ? e.message : e
1220
+ );
1221
+ if (!spanEnded) {
1222
+ span.setStatus({
1223
+ code: import_api4.SpanStatusCode.ERROR,
1224
+ message: e instanceof Error ? e.message : String(e)
1225
+ });
1226
+ span.end();
1227
+ }
1228
+ }
1229
+ spanEnded = true;
1230
+ return { done: true, value: void 0 };
1231
+ }
1232
+ chunks.push(iterResult.value);
1233
+ return { done: false, value: iterResult.value };
1234
+ } catch (error) {
1235
+ if (!spanEnded) {
1236
+ const msg = error instanceof Error ? error.message : String(error);
1237
+ span.setStatus({ code: import_api4.SpanStatusCode.ERROR, message: msg });
1238
+ span.recordException(error);
1239
+ span.end();
1240
+ spanEnded = true;
1241
+ }
1242
+ throw error;
1243
+ }
1244
+ },
1245
+ async return(value) {
1246
+ var _a;
1247
+ if (!spanEnded) {
1248
+ span.end();
1249
+ spanEnded = true;
1250
+ }
1251
+ await ((_a = origIterator.return) == null ? void 0 : _a.call(origIterator, value));
1252
+ return { done: true, value: void 0 };
1253
+ }
1254
+ };
1255
+ }
1256
+ };
1257
+ return result;
1258
+ }).catch((error) => {
1259
+ span.setStatus({
1260
+ code: import_api4.SpanStatusCode.ERROR,
1261
+ message: error.message
1262
+ });
1263
+ span.recordException(error);
1264
+ span.end();
1265
+ throw error;
1266
+ });
1267
+ };
1268
+ _bedrockProto._extractVendorAndModel = function(modelId) {
1269
+ if (!modelId) {
1270
+ return { modelVendor: "", model: "" };
1271
+ }
1272
+ const parts = modelId.split(".");
1273
+ if (parts.length >= 3 && /^[a-z]{2}$/.test(parts[0])) {
1274
+ return {
1275
+ modelVendor: parts[1] || "",
1276
+ model: parts.slice(2).join(".")
1277
+ };
1278
+ }
1279
+ return {
1280
+ modelVendor: parts[0] || "",
1281
+ model: parts[1] || ""
1282
+ };
1283
+ };
1284
+ } catch (e) {
1285
+ }
1177
1286
  function patchBedrockStreamingBug(inst) {
1178
1287
  const anyInst = inst;
1179
1288
  const origEndSpan = anyInst._endSpan.bind(anyInst);
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  package_default,
3
3
  tracing
4
- } from "./chunk-KZ6B3DZM.mjs";
4
+ } from "./chunk-7MR6AAR4.mjs";
5
5
 
6
6
  // ../schemas/src/ingest/index.ts
7
7
  import { z } from "zod";
@@ -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.87",
187
+ version: "0.0.88",
188
188
  main: "dist/index.js",
189
189
  module: "dist/index.mjs",
190
190
  types: "dist/index.d.ts",
@@ -759,10 +759,7 @@ var LiveInteraction = class {
759
759
  }
760
760
  addAttachments(attachments) {
761
761
  var _a;
762
- if (!this.context.attachments) {
763
- this.context.attachments = [];
764
- }
765
- this.context.attachments.push(...attachments);
762
+ this.context.attachments = [...this.context.attachments || [], ...attachments];
766
763
  (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
767
764
  eventId: this.context.eventId,
768
765
  attachments
@@ -971,6 +968,118 @@ var LiveTracer = class {
971
968
  };
972
969
 
973
970
  // src/tracing/tracer-core.ts
971
+ try {
972
+ const _bedrockProto = import_instrumentation_bedrock.BedrockInstrumentation.prototype;
973
+ _bedrockProto._wrapPromise = function(span, promise) {
974
+ const inst = this;
975
+ return promise.then(async (result) => {
976
+ const rec = result;
977
+ const body = rec == null ? void 0 : rec.body;
978
+ const isStreamBody = body != null && typeof body === "object" && Symbol.asyncIterator in body && !(body instanceof Uint8Array);
979
+ if (!isStreamBody) {
980
+ try {
981
+ await inst._endSpan({ span, result });
982
+ } catch (e) {
983
+ console.warn(
984
+ "[raindrop] Bedrock instrumentation could not process response \u2014 passing through unchanged.",
985
+ e instanceof Error ? e.message : e
986
+ );
987
+ span.setStatus({
988
+ code: import_api4.SpanStatusCode.ERROR,
989
+ message: e instanceof Error ? e.message : String(e)
990
+ });
991
+ span.end();
992
+ }
993
+ return result;
994
+ }
995
+ const origIterator = body[Symbol.asyncIterator]();
996
+ const chunks = [];
997
+ let spanEnded = false;
998
+ rec.body = {
999
+ [Symbol.asyncIterator]() {
1000
+ return {
1001
+ async next() {
1002
+ try {
1003
+ const iterResult = await origIterator.next();
1004
+ if (iterResult.done) {
1005
+ try {
1006
+ async function* replay() {
1007
+ for (const c of chunks) yield c;
1008
+ }
1009
+ await inst._endSpan({
1010
+ span,
1011
+ result: { ...rec, body: replay() }
1012
+ });
1013
+ } catch (e) {
1014
+ console.warn(
1015
+ "[raindrop] Bedrock instrumentation could not process streaming response \u2014 passing through unchanged.",
1016
+ e instanceof Error ? e.message : e
1017
+ );
1018
+ if (!spanEnded) {
1019
+ span.setStatus({
1020
+ code: import_api4.SpanStatusCode.ERROR,
1021
+ message: e instanceof Error ? e.message : String(e)
1022
+ });
1023
+ span.end();
1024
+ }
1025
+ }
1026
+ spanEnded = true;
1027
+ return { done: true, value: void 0 };
1028
+ }
1029
+ chunks.push(iterResult.value);
1030
+ return { done: false, value: iterResult.value };
1031
+ } catch (error) {
1032
+ if (!spanEnded) {
1033
+ const msg = error instanceof Error ? error.message : String(error);
1034
+ span.setStatus({ code: import_api4.SpanStatusCode.ERROR, message: msg });
1035
+ span.recordException(error);
1036
+ span.end();
1037
+ spanEnded = true;
1038
+ }
1039
+ throw error;
1040
+ }
1041
+ },
1042
+ async return(value) {
1043
+ var _a;
1044
+ if (!spanEnded) {
1045
+ span.end();
1046
+ spanEnded = true;
1047
+ }
1048
+ await ((_a = origIterator.return) == null ? void 0 : _a.call(origIterator, value));
1049
+ return { done: true, value: void 0 };
1050
+ }
1051
+ };
1052
+ }
1053
+ };
1054
+ return result;
1055
+ }).catch((error) => {
1056
+ span.setStatus({
1057
+ code: import_api4.SpanStatusCode.ERROR,
1058
+ message: error.message
1059
+ });
1060
+ span.recordException(error);
1061
+ span.end();
1062
+ throw error;
1063
+ });
1064
+ };
1065
+ _bedrockProto._extractVendorAndModel = function(modelId) {
1066
+ if (!modelId) {
1067
+ return { modelVendor: "", model: "" };
1068
+ }
1069
+ const parts = modelId.split(".");
1070
+ if (parts.length >= 3 && /^[a-z]{2}$/.test(parts[0])) {
1071
+ return {
1072
+ modelVendor: parts[1] || "",
1073
+ model: parts.slice(2).join(".")
1074
+ };
1075
+ }
1076
+ return {
1077
+ modelVendor: parts[0] || "",
1078
+ model: parts[1] || ""
1079
+ };
1080
+ };
1081
+ } catch (e) {
1082
+ }
974
1083
  function patchBedrockStreamingBug(inst) {
975
1084
  const anyInst = inst;
976
1085
  const origEndSpan = anyInst._endSpan.bind(anyInst);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "../chunk-KZ6B3DZM.mjs";
3
+ } from "../chunk-7MR6AAR4.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.87",
3
+ "version": "0.0.88-otelv2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -38,7 +38,6 @@
38
38
  "dependencies": {
39
39
  "@opentelemetry/api": "^1.9.0",
40
40
  "@opentelemetry/resources": "^2.0.1",
41
- "@traceloop/node-server-sdk": "0.19.0-otel-v1",
42
41
  "weakref": "^0.2.1",
43
42
  "zod": "^3.23.8",
44
43
  "@dawn-analytics/redact-pii": "0.1.2"
@@ -79,6 +78,9 @@
79
78
  },
80
79
  "clean": true
81
80
  },
81
+ "optionalDependencies": {
82
+ "@traceloop/node-server-sdk": "0.22.2"
83
+ },
82
84
  "scripts": {
83
85
  "build": "tsup",
84
86
  "dev": "tsup --watch",