raindrop-ai 0.1.0 → 0.1.1

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,4 +1,4 @@
1
- // ../core/dist/chunk-LMIWKHOH.js
1
+ // ../core/dist/chunk-OLYXZCOK.js
2
2
  function wait(ms) {
3
3
  return new Promise((resolve) => setTimeout(resolve, ms));
4
4
  }
@@ -204,7 +204,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
204
204
  // package.json
205
205
  var package_default = {
206
206
  name: "raindrop-ai",
207
- version: "0.1.0",
207
+ version: "0.1.1",
208
208
  main: "dist/index.js",
209
209
  module: "dist/index.mjs",
210
210
  types: "dist/index.d.ts",
@@ -1283,16 +1283,23 @@ var LiveInteraction = class {
1283
1283
  getEventId() {
1284
1284
  return this.context.eventId;
1285
1285
  }
1286
- finish(resultEvent) {
1287
- var _a;
1286
+ async finish(resultEvent) {
1287
+ var _a, _b;
1288
+ if (!this.traceId) {
1289
+ this.resolveLiveTraceId();
1290
+ }
1291
+ try {
1292
+ await ((_a = this.analytics) == null ? void 0 : _a.forceFlush());
1293
+ } catch (e) {
1294
+ }
1288
1295
  if (this.traceId) {
1289
1296
  this.setProperty("trace_id", this.traceId);
1290
1297
  }
1291
- (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
1298
+ await ((_b = this.analytics) == null ? void 0 : _b._trackAiPartial({
1292
1299
  ...resultEvent,
1293
1300
  eventId: resultEvent.eventId || this.context.eventId,
1294
1301
  isPending: false
1295
- });
1302
+ }));
1296
1303
  }
1297
1304
  trackTool(params) {
1298
1305
  var _a, _b;
@@ -2173,6 +2180,24 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2173
2180
  tracer(globalProperties) {
2174
2181
  return new LiveTracer(globalProperties, directShipper);
2175
2182
  },
2183
+ /**
2184
+ * Best-effort drain of in-flight OTel spans and direct shipper batches.
2185
+ * Safe to call when nothing is in flight; never throws.
2186
+ */
2187
+ async forceFlush() {
2188
+ if (directShipper) {
2189
+ try {
2190
+ await directShipper.flush();
2191
+ } catch (e) {
2192
+ }
2193
+ }
2194
+ if (traceloopInitialized) {
2195
+ try {
2196
+ await traceloop3.forceFlush();
2197
+ } catch (e) {
2198
+ }
2199
+ }
2200
+ },
2176
2201
  async close() {
2177
2202
  activeInteractions.clear();
2178
2203
  activeInteractionsByEventId.clear();
package/dist/index.d.mts CHANGED
@@ -605,7 +605,7 @@ type Interaction = {
605
605
  * // End the interaction with the response
606
606
  * interaction.end("I can help you with various tasks. Here are some examples...");
607
607
  */
608
- finish(resultEvent: FinishInteractionOptions): void;
608
+ finish(resultEvent: FinishInteractionOptions): Promise<void>;
609
609
  /**
610
610
  * Returns metadata for Vercel AI SDK's experimental_telemetry option.
611
611
  *
@@ -977,7 +977,7 @@ declare class Raindrop {
977
977
  *
978
978
  * @param event - The PartialAiTrackEvent, requires eventId.
979
979
  */
980
- _trackAiPartial(event: PartialAiTrackEvent): void;
980
+ _trackAiPartial(event: PartialAiTrackEvent): Promise<void>;
981
981
  /**
982
982
  * Flushes a single accumulated partial event by its ID.
983
983
  * This is called internally by the timeout or by the close method.
@@ -994,6 +994,11 @@ declare class Raindrop {
994
994
  * @param event - The event data conforming to ClientAiTrack schema.
995
995
  */
996
996
  private sendPartialEvent;
997
+ /**
998
+ * Best-effort flush of in-flight OTel spans and pending partial-event POSTs.
999
+ * Safe to call multiple times; never throws.
1000
+ */
1001
+ forceFlush(): Promise<void>;
997
1002
  close(): Promise<void>;
998
1003
  }
999
1004
 
package/dist/index.d.ts CHANGED
@@ -605,7 +605,7 @@ type Interaction = {
605
605
  * // End the interaction with the response
606
606
  * interaction.end("I can help you with various tasks. Here are some examples...");
607
607
  */
608
- finish(resultEvent: FinishInteractionOptions): void;
608
+ finish(resultEvent: FinishInteractionOptions): Promise<void>;
609
609
  /**
610
610
  * Returns metadata for Vercel AI SDK's experimental_telemetry option.
611
611
  *
@@ -977,7 +977,7 @@ declare class Raindrop {
977
977
  *
978
978
  * @param event - The PartialAiTrackEvent, requires eventId.
979
979
  */
980
- _trackAiPartial(event: PartialAiTrackEvent): void;
980
+ _trackAiPartial(event: PartialAiTrackEvent): Promise<void>;
981
981
  /**
982
982
  * Flushes a single accumulated partial event by its ID.
983
983
  * This is called internally by the timeout or by the close method.
@@ -994,6 +994,11 @@ declare class Raindrop {
994
994
  * @param event - The event data conforming to ClientAiTrack schema.
995
995
  */
996
996
  private sendPartialEvent;
997
+ /**
998
+ * Best-effort flush of in-flight OTel spans and pending partial-event POSTs.
999
+ * Safe to call multiple times; never throws.
1000
+ */
1001
+ forceFlush(): Promise<void>;
997
1002
  close(): Promise<void>;
998
1003
  }
999
1004
 
package/dist/index.js CHANGED
@@ -5771,7 +5771,7 @@ __export(index_exports, {
5771
5771
  });
5772
5772
  module.exports = __toCommonJS(index_exports);
5773
5773
 
5774
- // ../core/dist/chunk-LMIWKHOH.js
5774
+ // ../core/dist/chunk-OLYXZCOK.js
5775
5775
  function wait(ms) {
5776
5776
  return new Promise((resolve) => setTimeout(resolve, ms));
5777
5777
  }
@@ -10082,7 +10082,7 @@ var SignalEventSchema = external_exports.object({
10082
10082
  // package.json
10083
10083
  var package_default = {
10084
10084
  name: "raindrop-ai",
10085
- version: "0.1.0",
10085
+ version: "0.1.1",
10086
10086
  main: "dist/index.js",
10087
10087
  module: "dist/index.mjs",
10088
10088
  types: "dist/index.d.ts",
@@ -11241,16 +11241,23 @@ var LiveInteraction = class {
11241
11241
  getEventId() {
11242
11242
  return this.context.eventId;
11243
11243
  }
11244
- finish(resultEvent) {
11245
- var _a;
11244
+ async finish(resultEvent) {
11245
+ var _a, _b;
11246
+ if (!this.traceId) {
11247
+ this.resolveLiveTraceId();
11248
+ }
11249
+ try {
11250
+ await ((_a = this.analytics) == null ? void 0 : _a.forceFlush());
11251
+ } catch (e) {
11252
+ }
11246
11253
  if (this.traceId) {
11247
11254
  this.setProperty("trace_id", this.traceId);
11248
11255
  }
11249
- (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
11256
+ await ((_b = this.analytics) == null ? void 0 : _b._trackAiPartial({
11250
11257
  ...resultEvent,
11251
11258
  eventId: resultEvent.eventId || this.context.eventId,
11252
11259
  isPending: false
11253
- });
11260
+ }));
11254
11261
  }
11255
11262
  trackTool(params) {
11256
11263
  var _a, _b;
@@ -12131,6 +12138,24 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12131
12138
  tracer(globalProperties) {
12132
12139
  return new LiveTracer(globalProperties, directShipper);
12133
12140
  },
12141
+ /**
12142
+ * Best-effort drain of in-flight OTel spans and direct shipper batches.
12143
+ * Safe to call when nothing is in flight; never throws.
12144
+ */
12145
+ async forceFlush() {
12146
+ if (directShipper) {
12147
+ try {
12148
+ await directShipper.flush();
12149
+ } catch (e) {
12150
+ }
12151
+ }
12152
+ if (traceloopInitialized) {
12153
+ try {
12154
+ await traceloop3.forceFlush();
12155
+ } catch (e) {
12156
+ }
12157
+ }
12158
+ },
12134
12159
  async close() {
12135
12160
  activeInteractions.clear();
12136
12161
  activeInteractionsByEventId.clear();
@@ -12871,12 +12896,12 @@ var Raindrop = class {
12871
12896
  */
12872
12897
  _trackAiPartial(event) {
12873
12898
  if (this.disabled) {
12874
- return;
12899
+ return Promise.resolve();
12875
12900
  }
12876
12901
  const { eventId, isPending, ...rest } = event;
12877
12902
  if (!eventId) {
12878
12903
  console.warn("[raindrop] trackAiPartial requires an eventId.");
12879
- return;
12904
+ return Promise.resolve();
12880
12905
  }
12881
12906
  const existingEvent = this.partialEventBuffer.get(eventId) || {};
12882
12907
  const mergedEvent = this.deepMergeObjects(
@@ -12893,8 +12918,7 @@ var Raindrop = class {
12893
12918
  clearTimeout(existingTimeout);
12894
12919
  }
12895
12920
  if (!mergedEvent.isPending) {
12896
- this.flushPartialEvent(eventId);
12897
- return;
12921
+ return this.flushPartialEvent(eventId);
12898
12922
  }
12899
12923
  const PARTIAL_EVENT_TIMEOUT = 2e3;
12900
12924
  const newTimeout = setTimeout(() => {
@@ -12912,6 +12936,7 @@ var Raindrop = class {
12912
12936
  `[raindrop] Updated partial event buffer for eventId: ${eventId}. Timeout reset (20s). Event: ${JSON.stringify(mergedEvent)}`
12913
12937
  );
12914
12938
  }
12939
+ return Promise.resolve();
12915
12940
  }
12916
12941
  /**
12917
12942
  * Flushes a single accumulated partial event by its ID.
@@ -13070,6 +13095,19 @@ var Raindrop = class {
13070
13095
  throw error;
13071
13096
  }
13072
13097
  }
13098
+ /**
13099
+ * Best-effort flush of in-flight OTel spans and pending partial-event POSTs.
13100
+ * Safe to call multiple times; never throws.
13101
+ */
13102
+ async forceFlush() {
13103
+ try {
13104
+ await this._tracing.forceFlush();
13105
+ } catch (e) {
13106
+ }
13107
+ if (this.inFlightRequests.size > 0) {
13108
+ await Promise.allSettled(Array.from(this.inFlightRequests));
13109
+ }
13110
+ }
13073
13111
  async close() {
13074
13112
  await this._tracing.close();
13075
13113
  try {
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  package_default,
4
4
  resolveLocalDebuggerBaseUrl,
5
5
  tracing
6
- } from "./chunk-S6UIW5C4.mjs";
6
+ } from "./chunk-DP5ED5DR.mjs";
7
7
  import {
8
8
  __commonJS,
9
9
  __toESM
@@ -10661,12 +10661,12 @@ var Raindrop = class {
10661
10661
  */
10662
10662
  _trackAiPartial(event) {
10663
10663
  if (this.disabled) {
10664
- return;
10664
+ return Promise.resolve();
10665
10665
  }
10666
10666
  const { eventId, isPending, ...rest } = event;
10667
10667
  if (!eventId) {
10668
10668
  console.warn("[raindrop] trackAiPartial requires an eventId.");
10669
- return;
10669
+ return Promise.resolve();
10670
10670
  }
10671
10671
  const existingEvent = this.partialEventBuffer.get(eventId) || {};
10672
10672
  const mergedEvent = this.deepMergeObjects(
@@ -10683,8 +10683,7 @@ var Raindrop = class {
10683
10683
  clearTimeout(existingTimeout);
10684
10684
  }
10685
10685
  if (!mergedEvent.isPending) {
10686
- this.flushPartialEvent(eventId);
10687
- return;
10686
+ return this.flushPartialEvent(eventId);
10688
10687
  }
10689
10688
  const PARTIAL_EVENT_TIMEOUT = 2e3;
10690
10689
  const newTimeout = setTimeout(() => {
@@ -10702,6 +10701,7 @@ var Raindrop = class {
10702
10701
  `[raindrop] Updated partial event buffer for eventId: ${eventId}. Timeout reset (20s). Event: ${JSON.stringify(mergedEvent)}`
10703
10702
  );
10704
10703
  }
10704
+ return Promise.resolve();
10705
10705
  }
10706
10706
  /**
10707
10707
  * Flushes a single accumulated partial event by its ID.
@@ -10860,6 +10860,19 @@ var Raindrop = class {
10860
10860
  throw error;
10861
10861
  }
10862
10862
  }
10863
+ /**
10864
+ * Best-effort flush of in-flight OTel spans and pending partial-event POSTs.
10865
+ * Safe to call multiple times; never throws.
10866
+ */
10867
+ async forceFlush() {
10868
+ try {
10869
+ await this._tracing.forceFlush();
10870
+ } catch (e) {
10871
+ }
10872
+ if (this.inFlightRequests.size > 0) {
10873
+ await Promise.allSettled(Array.from(this.inFlightRequests));
10874
+ }
10875
+ }
10863
10876
  async close() {
10864
10877
  await this._tracing.close();
10865
10878
  try {
@@ -84,6 +84,11 @@ declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, o
84
84
  begin(traceContext: PartialAiTrackEvent): Interaction;
85
85
  getActiveInteraction(eventId: string): Interaction;
86
86
  tracer(globalProperties?: Record<string, string>): Tracer;
87
+ /**
88
+ * Best-effort drain of in-flight OTel spans and direct shipper batches.
89
+ * Safe to call when nothing is in flight; never throws.
90
+ */
91
+ forceFlush(): Promise<void>;
87
92
  close(): Promise<void>;
88
93
  };
89
94
  type Tracing = ReturnType<typeof tracing>;
@@ -84,6 +84,11 @@ declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, o
84
84
  begin(traceContext: PartialAiTrackEvent): Interaction;
85
85
  getActiveInteraction(eventId: string): Interaction;
86
86
  tracer(globalProperties?: Record<string, string>): Tracer;
87
+ /**
88
+ * Best-effort drain of in-flight OTel spans and direct shipper batches.
89
+ * Safe to call when nothing is in flight; never throws.
90
+ */
91
+ forceFlush(): Promise<void>;
87
92
  close(): Promise<void>;
88
93
  };
89
94
  type Tracing = ReturnType<typeof tracing>;
@@ -50,7 +50,7 @@ var import_instrumentation_vertexai = require("@traceloop/instrumentation-vertex
50
50
  var traceloop3 = __toESM(require("@traceloop/node-server-sdk"));
51
51
  var import_weakref = require("weakref");
52
52
 
53
- // ../core/dist/chunk-LMIWKHOH.js
53
+ // ../core/dist/chunk-OLYXZCOK.js
54
54
  function wait(ms) {
55
55
  return new Promise((resolve) => setTimeout(resolve, ms));
56
56
  }
@@ -392,7 +392,7 @@ function base64ToHex(base64) {
392
392
  // package.json
393
393
  var package_default = {
394
394
  name: "raindrop-ai",
395
- version: "0.1.0",
395
+ version: "0.1.1",
396
396
  main: "dist/index.js",
397
397
  module: "dist/index.mjs",
398
398
  types: "dist/index.d.ts",
@@ -1299,16 +1299,23 @@ var LiveInteraction = class {
1299
1299
  getEventId() {
1300
1300
  return this.context.eventId;
1301
1301
  }
1302
- finish(resultEvent) {
1303
- var _a;
1302
+ async finish(resultEvent) {
1303
+ var _a, _b;
1304
+ if (!this.traceId) {
1305
+ this.resolveLiveTraceId();
1306
+ }
1307
+ try {
1308
+ await ((_a = this.analytics) == null ? void 0 : _a.forceFlush());
1309
+ } catch (e) {
1310
+ }
1304
1311
  if (this.traceId) {
1305
1312
  this.setProperty("trace_id", this.traceId);
1306
1313
  }
1307
- (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
1314
+ await ((_b = this.analytics) == null ? void 0 : _b._trackAiPartial({
1308
1315
  ...resultEvent,
1309
1316
  eventId: resultEvent.eventId || this.context.eventId,
1310
1317
  isPending: false
1311
- });
1318
+ }));
1312
1319
  }
1313
1320
  trackTool(params) {
1314
1321
  var _a, _b;
@@ -2189,6 +2196,24 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2189
2196
  tracer(globalProperties) {
2190
2197
  return new LiveTracer(globalProperties, directShipper);
2191
2198
  },
2199
+ /**
2200
+ * Best-effort drain of in-flight OTel spans and direct shipper batches.
2201
+ * Safe to call when nothing is in flight; never throws.
2202
+ */
2203
+ async forceFlush() {
2204
+ if (directShipper) {
2205
+ try {
2206
+ await directShipper.flush();
2207
+ } catch (e) {
2208
+ }
2209
+ }
2210
+ if (traceloopInitialized) {
2211
+ try {
2212
+ await traceloop3.forceFlush();
2213
+ } catch (e) {
2214
+ }
2215
+ }
2216
+ },
2192
2217
  async close() {
2193
2218
  activeInteractions.clear();
2194
2219
  activeInteractionsByEventId.clear();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "../chunk-S6UIW5C4.mjs";
3
+ } from "../chunk-DP5ED5DR.mjs";
4
4
  import "../chunk-UJCSKKID.mjs";
5
5
 
6
6
  // src/tracing/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raindrop-ai",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -46,8 +46,8 @@
46
46
  "typescript": "^5.3.3",
47
47
  "vite": "^7.3.2",
48
48
  "vitest": "^4.0.10",
49
- "@raindrop-ai/core": "0.0.1",
50
49
  "@raindrop-ai/redact-pii": "0.1.2",
50
+ "@raindrop-ai/core": "0.0.1",
51
51
  "@raindrop-ai/schemas": "0.0.1"
52
52
  },
53
53
  "dependencies": {