raindrop-ai 0.0.89 → 0.0.90-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,134 +1,4 @@
1
- // package.json
2
- var package_default = {
3
- name: "raindrop-ai",
4
- version: "0.0.89",
5
- main: "dist/index.js",
6
- module: "dist/index.mjs",
7
- types: "dist/index.d.ts",
8
- license: "MIT",
9
- repository: {
10
- type: "git",
11
- url: "git+https://github.com/raindrop-ai/raindrop-js.git",
12
- directory: "packages/js-sdk"
13
- },
14
- homepage: "https://github.com/raindrop-ai/raindrop-js/tree/main/packages/js-sdk#readme",
15
- bugs: {
16
- url: "https://github.com/raindrop-ai/raindrop-js/issues"
17
- },
18
- exports: {
19
- ".": {
20
- types: "./dist/index.d.ts",
21
- import: "./dist/index.mjs",
22
- require: "./dist/index.js"
23
- },
24
- "./tracing": {
25
- types: "./dist/tracing/index.d.ts",
26
- node: "./dist/tracing/index.js",
27
- import: "./dist/tracing/index.mjs",
28
- require: "./dist/tracing/index.js"
29
- },
30
- "./otel": {
31
- types: "./dist/otel/index.d.ts",
32
- node: "./dist/otel/index.js",
33
- import: "./dist/otel/index.mjs",
34
- require: "./dist/otel/index.js"
35
- }
36
- },
37
- files: [
38
- "dist/**"
39
- ],
40
- scripts: {
41
- build: "tsup",
42
- dev: "tsup --watch",
43
- clean: "rm -rf .turbo && rm -rf dist",
44
- try: "tsx ./src/example/index.ts",
45
- test: "vitest run",
46
- smoke: "tsx ./scripts/smoke.ts",
47
- "smoke:ai-sdk-self-diagnostics": "tsx ./scripts/smoke.ai-sdk-self-diagnostics.ts",
48
- "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install && pnpm smoke",
49
- "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install && pnpm smoke",
50
- "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install && pnpm smoke",
51
- "smoke:self-diagnostics:ai-sdk:all": "pnpm smoke:self-diagnostics:v4 && pnpm smoke:self-diagnostics:v5 && pnpm smoke:self-diagnostics:v6",
52
- "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install && pnpm smoke",
53
- "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install && pnpm smoke",
54
- "smoke:self-diagnostics:all": "pnpm smoke:self-diagnostics:ai-sdk:all && pnpm smoke:self-diagnostics:openai-sdk && pnpm smoke:self-diagnostics:anthropic-sdk"
55
- },
56
- devDependencies: {
57
- "@raindrop-ai/redact-pii": "workspace:*",
58
- "@raindrop-ai/schemas": "workspace:*",
59
- ai: "^6.0.0",
60
- "@types/node": "^20.11.17",
61
- msw: "^2.12.8",
62
- tsup: "^8.4.0",
63
- tsx: "^4.20.3",
64
- typescript: "^5.3.3",
65
- vite: "^6.4.1",
66
- vitest: "^4.0.10"
67
- },
68
- dependencies: {
69
- "@opentelemetry/api": "^1.9.0",
70
- "@opentelemetry/resources": "^2.0.1",
71
- "@traceloop/node-server-sdk": "0.19.0-otel-v1",
72
- weakref: "^0.2.1",
73
- zod: "^3.23.8"
74
- },
75
- publishConfig: {
76
- access: "public",
77
- provenance: false
78
- },
79
- tsup: {
80
- entry: [
81
- "src/index.ts",
82
- "src/tracing/index.ts",
83
- "src/otel/index.ts"
84
- ],
85
- format: [
86
- "cjs",
87
- "esm"
88
- ],
89
- external: [
90
- "@traceloop/node-server-sdk",
91
- "@traceloop/instrumentation-anthropic",
92
- "@traceloop/instrumentation-openai",
93
- "@traceloop/instrumentation-cohere",
94
- "@traceloop/instrumentation-bedrock",
95
- "@traceloop/instrumentation-vertexai",
96
- "@traceloop/instrumentation-pinecone",
97
- "@traceloop/instrumentation-chromadb",
98
- "@traceloop/instrumentation-qdrant",
99
- "@traceloop/instrumentation-together",
100
- "@opentelemetry/instrumentation",
101
- "@opentelemetry/sdk-trace-base"
102
- ],
103
- noExternal: [
104
- "@raindrop-ai/redact-pii",
105
- "@raindrop-ai/schemas"
106
- ],
107
- dts: {
108
- resolve: true
109
- },
110
- clean: true
111
- }
112
- };
113
-
114
- // src/tracing/tracer-core.ts
115
- import { context as context4, SpanStatusCode as SpanStatusCode4, trace as trace4 } from "@opentelemetry/api";
116
- import { AnthropicInstrumentation } from "@traceloop/instrumentation-anthropic";
117
- import { BedrockInstrumentation } from "@traceloop/instrumentation-bedrock";
118
- import { ChromaDBInstrumentation } from "@traceloop/instrumentation-chromadb";
119
- import { CohereInstrumentation } from "@traceloop/instrumentation-cohere";
120
- import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai";
121
- import { PineconeInstrumentation } from "@traceloop/instrumentation-pinecone";
122
- import { QdrantInstrumentation } from "@traceloop/instrumentation-qdrant";
123
- import { TogetherInstrumentation } from "@traceloop/instrumentation-together";
124
- import {
125
- AIPlatformInstrumentation,
126
- VertexAIInstrumentation
127
- } from "@traceloop/instrumentation-vertexai";
128
- import * as traceloop3 from "@traceloop/node-server-sdk";
129
- import { WeakValueMap } from "weakref";
130
-
131
- // ../core/dist/chunk-4UCYIEH4.js
1
+ // ../core/dist/chunk-5KTDM7WD.js
132
2
  function wait(ms) {
133
3
  return new Promise((resolve) => setTimeout(resolve, ms));
134
4
  }
@@ -253,6 +123,18 @@ function mirrorTraceExportToLocalDebugger(body, options = {}) {
253
123
  }).catch(() => {
254
124
  });
255
125
  }
126
+ function mirrorPartialEventToLocalDebugger(event, options = {}) {
127
+ var _a;
128
+ const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
129
+ if (!baseUrl) return;
130
+ const headers = options.writeKey ? { Authorization: `Bearer ${options.writeKey}` } : {};
131
+ void postJson(`${baseUrl}events/track_partial`, event, headers, {
132
+ maxAttempts: 1,
133
+ debug: (_a = options.debug) != null ? _a : false,
134
+ sdkName: options.sdkName
135
+ }).catch(() => {
136
+ });
137
+ }
256
138
  function sendLocalDebuggerLiveEvent(event, options = {}) {
257
139
  var _a, _b;
258
140
  const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
@@ -278,6 +160,138 @@ function sendLocalDebuggerLiveEvent(event, options = {}) {
278
160
  import { AsyncLocalStorage } from "async_hooks";
279
161
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
280
162
 
163
+ // package.json
164
+ var package_default = {
165
+ name: "raindrop-ai",
166
+ version: "0.0.90",
167
+ main: "dist/index.js",
168
+ module: "dist/index.mjs",
169
+ types: "dist/index.d.ts",
170
+ license: "MIT",
171
+ repository: {
172
+ type: "git",
173
+ url: "git+https://github.com/raindrop-ai/raindrop-js.git",
174
+ directory: "packages/js-sdk"
175
+ },
176
+ homepage: "https://github.com/raindrop-ai/raindrop-js/tree/main/packages/js-sdk#readme",
177
+ bugs: {
178
+ url: "https://github.com/raindrop-ai/raindrop-js/issues"
179
+ },
180
+ exports: {
181
+ ".": {
182
+ types: "./dist/index.d.ts",
183
+ import: "./dist/index.mjs",
184
+ require: "./dist/index.js"
185
+ },
186
+ "./tracing": {
187
+ types: "./dist/tracing/index.d.ts",
188
+ node: "./dist/tracing/index.js",
189
+ import: "./dist/tracing/index.mjs",
190
+ require: "./dist/tracing/index.js"
191
+ },
192
+ "./otel": {
193
+ types: "./dist/otel/index.d.ts",
194
+ node: "./dist/otel/index.js",
195
+ import: "./dist/otel/index.mjs",
196
+ require: "./dist/otel/index.js"
197
+ }
198
+ },
199
+ files: [
200
+ "dist/**"
201
+ ],
202
+ scripts: {
203
+ build: "tsup",
204
+ dev: "tsup --watch",
205
+ clean: "rm -rf .turbo && rm -rf dist",
206
+ try: "tsx ./src/example/index.ts",
207
+ test: "vitest run",
208
+ smoke: "tsx ./scripts/smoke.ts",
209
+ "smoke:ai-sdk-self-diagnostics": "tsx ./scripts/smoke.ai-sdk-self-diagnostics.ts",
210
+ "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
211
+ "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
212
+ "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
213
+ "smoke:self-diagnostics:ai-sdk:all": "pnpm smoke:self-diagnostics:v4 && pnpm smoke:self-diagnostics:v5 && pnpm smoke:self-diagnostics:v6",
214
+ "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
215
+ "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
216
+ "smoke:self-diagnostics:all": "pnpm smoke:self-diagnostics:ai-sdk:all && pnpm smoke:self-diagnostics:openai-sdk && pnpm smoke:self-diagnostics:anthropic-sdk"
217
+ },
218
+ devDependencies: {
219
+ "@raindrop-ai/core": "workspace:*",
220
+ "@raindrop-ai/redact-pii": "workspace:*",
221
+ "@raindrop-ai/schemas": "workspace:*",
222
+ ai: "^6.0.0",
223
+ "@types/node": "^20.11.17",
224
+ msw: "^2.12.8",
225
+ tsup: "^8.4.0",
226
+ tsx: "^4.20.3",
227
+ typescript: "^5.3.3",
228
+ vite: "^7.3.2",
229
+ vitest: "^4.0.10"
230
+ },
231
+ dependencies: {
232
+ "@opentelemetry/api": "^1.9.0",
233
+ "@opentelemetry/resources": "^2.0.1",
234
+ "@traceloop/node-server-sdk": "0.19.0-otel-v1",
235
+ weakref: "^0.2.1",
236
+ zod: "^3.23.8"
237
+ },
238
+ publishConfig: {
239
+ access: "public",
240
+ provenance: false
241
+ },
242
+ tsup: {
243
+ entry: [
244
+ "src/index.ts",
245
+ "src/tracing/index.ts",
246
+ "src/otel/index.ts"
247
+ ],
248
+ format: [
249
+ "cjs",
250
+ "esm"
251
+ ],
252
+ external: [
253
+ "@traceloop/node-server-sdk",
254
+ "@traceloop/instrumentation-anthropic",
255
+ "@traceloop/instrumentation-openai",
256
+ "@traceloop/instrumentation-cohere",
257
+ "@traceloop/instrumentation-bedrock",
258
+ "@traceloop/instrumentation-vertexai",
259
+ "@traceloop/instrumentation-pinecone",
260
+ "@traceloop/instrumentation-chromadb",
261
+ "@traceloop/instrumentation-qdrant",
262
+ "@traceloop/instrumentation-together",
263
+ "@opentelemetry/instrumentation",
264
+ "@opentelemetry/sdk-trace-base"
265
+ ],
266
+ noExternal: [
267
+ "@raindrop-ai/core",
268
+ "@raindrop-ai/redact-pii",
269
+ "@raindrop-ai/schemas"
270
+ ],
271
+ dts: {
272
+ resolve: true
273
+ },
274
+ clean: true
275
+ }
276
+ };
277
+
278
+ // src/tracing/tracer-core.ts
279
+ import { context as context4, SpanStatusCode as SpanStatusCode4, trace as trace4 } from "@opentelemetry/api";
280
+ import { AnthropicInstrumentation } from "@traceloop/instrumentation-anthropic";
281
+ import { BedrockInstrumentation } from "@traceloop/instrumentation-bedrock";
282
+ import { ChromaDBInstrumentation } from "@traceloop/instrumentation-chromadb";
283
+ import { CohereInstrumentation } from "@traceloop/instrumentation-cohere";
284
+ import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai";
285
+ import { PineconeInstrumentation } from "@traceloop/instrumentation-pinecone";
286
+ import { QdrantInstrumentation } from "@traceloop/instrumentation-qdrant";
287
+ import { TogetherInstrumentation } from "@traceloop/instrumentation-together";
288
+ import {
289
+ AIPlatformInstrumentation,
290
+ VertexAIInstrumentation
291
+ } from "@traceloop/instrumentation-vertexai";
292
+ import * as traceloop3 from "@traceloop/node-server-sdk";
293
+ import { WeakValueMap } from "weakref";
294
+
281
295
  // src/tracing/direct/http.ts
282
296
  function wait2(ms) {
283
297
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -1874,6 +1888,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
1874
1888
  };
1875
1889
 
1876
1890
  export {
1891
+ mirrorPartialEventToLocalDebugger,
1877
1892
  package_default,
1878
1893
  tracing
1879
1894
  };
package/dist/index.js CHANGED
@@ -5771,6 +5771,168 @@ __export(index_exports, {
5771
5771
  });
5772
5772
  module.exports = __toCommonJS(index_exports);
5773
5773
 
5774
+ // ../core/dist/chunk-5KTDM7WD.js
5775
+ function wait(ms) {
5776
+ return new Promise((resolve) => setTimeout(resolve, ms));
5777
+ }
5778
+ function formatEndpoint(endpoint) {
5779
+ if (!endpoint) return void 0;
5780
+ return endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
5781
+ }
5782
+ function parseRetryAfter(headers) {
5783
+ var _a;
5784
+ const value = (_a = headers.get("Retry-After")) != null ? _a : headers.get("retry-after");
5785
+ if (!value) return void 0;
5786
+ const asNumber = Number(value);
5787
+ if (value.trim() !== "" && !Number.isNaN(asNumber)) return asNumber * 1e3;
5788
+ const asDate = new Date(value).getTime();
5789
+ if (!Number.isNaN(asDate)) {
5790
+ const delta = asDate - Date.now();
5791
+ return delta > 0 ? delta : 0;
5792
+ }
5793
+ return void 0;
5794
+ }
5795
+ function getRetryDelayMs(attemptNumber, previousError) {
5796
+ if (previousError && typeof previousError === "object" && previousError !== null && "retryAfterMs" in previousError) {
5797
+ const v = previousError.retryAfterMs;
5798
+ if (typeof v === "number") return Math.max(0, v);
5799
+ }
5800
+ if (attemptNumber <= 1) return 0;
5801
+ const base = 500;
5802
+ const factor = Math.pow(2, attemptNumber - 2);
5803
+ return base * factor;
5804
+ }
5805
+ async function withRetry(operation, opName, opts) {
5806
+ const prefix = opts.sdkName ? `[raindrop-ai/${opts.sdkName}]` : "[raindrop-ai/core]";
5807
+ let lastError = void 0;
5808
+ for (let attemptNumber = 1; attemptNumber <= opts.maxAttempts; attemptNumber++) {
5809
+ if (attemptNumber > 1) {
5810
+ const delay = getRetryDelayMs(attemptNumber, lastError);
5811
+ if (opts.debug) {
5812
+ console.warn(
5813
+ `${prefix} ${opName} retry ${attemptNumber}/${opts.maxAttempts} in ${delay}ms`
5814
+ );
5815
+ }
5816
+ if (delay > 0) await wait(delay);
5817
+ } else if (opts.debug) {
5818
+ console.log(`${prefix} ${opName} attempt ${attemptNumber}/${opts.maxAttempts}`);
5819
+ }
5820
+ try {
5821
+ return await operation();
5822
+ } catch (err) {
5823
+ lastError = err;
5824
+ if (opts.debug) {
5825
+ const msg = err instanceof Error ? err.message : String(err);
5826
+ console.warn(
5827
+ `${prefix} ${opName} attempt ${attemptNumber} failed: ${msg}${attemptNumber === opts.maxAttempts ? " (no more retries)" : ""}`
5828
+ );
5829
+ }
5830
+ if (lastError && typeof lastError === "object" && "retryable" in lastError && !lastError.retryable)
5831
+ break;
5832
+ if (attemptNumber === opts.maxAttempts) break;
5833
+ }
5834
+ }
5835
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
5836
+ }
5837
+ async function postJson(url, body, headers, opts) {
5838
+ const opName = `POST ${url}`;
5839
+ await withRetry(
5840
+ async () => {
5841
+ const resp = await fetch(url, {
5842
+ method: "POST",
5843
+ headers: {
5844
+ "Content-Type": "application/json",
5845
+ ...headers
5846
+ },
5847
+ body: JSON.stringify(body)
5848
+ });
5849
+ if (!resp.ok) {
5850
+ const text = await resp.text().catch(() => "");
5851
+ const err = new Error(
5852
+ `HTTP ${resp.status} ${resp.statusText}${text ? `: ${text}` : ""}`
5853
+ );
5854
+ const retryAfterMs = parseRetryAfter(resp.headers);
5855
+ if (typeof retryAfterMs === "number") err.retryAfterMs = retryAfterMs;
5856
+ err.retryable = resp.status === 429 || resp.status >= 500;
5857
+ throw err;
5858
+ }
5859
+ },
5860
+ opName,
5861
+ opts
5862
+ );
5863
+ }
5864
+ var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
5865
+ function resolveLocalDebuggerBaseUrl(baseUrl) {
5866
+ var _a, _b, _c;
5867
+ const resolved = (_b = baseUrl != null ? baseUrl : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a[LOCAL_DEBUGGER_ENV_VAR] : void 0) != null ? _b : null;
5868
+ return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
5869
+ }
5870
+ function localDebuggerEnabled(baseUrl) {
5871
+ return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
5872
+ }
5873
+ function normalizeLocalDebuggerLiveEventType(type) {
5874
+ switch (type) {
5875
+ case "text-delta":
5876
+ return "text_delta";
5877
+ case "reasoning":
5878
+ case "reasoning-delta":
5879
+ return "reasoning_delta";
5880
+ case "tool-call":
5881
+ return "tool_start";
5882
+ case "tool-result":
5883
+ return "tool_result";
5884
+ default:
5885
+ return type;
5886
+ }
5887
+ }
5888
+ function mirrorTraceExportToLocalDebugger(body, options = {}) {
5889
+ var _a;
5890
+ const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
5891
+ if (!baseUrl) return;
5892
+ void postJson(`${baseUrl}traces`, body, {}, {
5893
+ maxAttempts: 1,
5894
+ debug: (_a = options.debug) != null ? _a : false,
5895
+ sdkName: options.sdkName
5896
+ }).catch(() => {
5897
+ });
5898
+ }
5899
+ function mirrorPartialEventToLocalDebugger(event, options = {}) {
5900
+ var _a;
5901
+ const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
5902
+ if (!baseUrl) return;
5903
+ const headers = options.writeKey ? { Authorization: `Bearer ${options.writeKey}` } : {};
5904
+ void postJson(`${baseUrl}events/track_partial`, event, headers, {
5905
+ maxAttempts: 1,
5906
+ debug: (_a = options.debug) != null ? _a : false,
5907
+ sdkName: options.sdkName
5908
+ }).catch(() => {
5909
+ });
5910
+ }
5911
+ function sendLocalDebuggerLiveEvent(event, options = {}) {
5912
+ var _a, _b;
5913
+ const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
5914
+ if (!baseUrl) return;
5915
+ void postJson(
5916
+ `${baseUrl}live`,
5917
+ {
5918
+ ...event,
5919
+ type: normalizeLocalDebuggerLiveEventType(event.type),
5920
+ timestamp: (_a = event.timestamp) != null ? _a : Date.now()
5921
+ },
5922
+ {},
5923
+ {
5924
+ maxAttempts: 1,
5925
+ debug: (_b = options.debug) != null ? _b : false,
5926
+ sdkName: options.sdkName
5927
+ }
5928
+ ).catch(() => {
5929
+ });
5930
+ }
5931
+
5932
+ // ../core/dist/index.node.js
5933
+ var import_async_hooks = require("async_hooks");
5934
+ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = import_async_hooks.AsyncLocalStorage;
5935
+
5774
5936
  // ../schemas/dist/chunk-HIOHOVGI.js
5775
5937
  var __defProp2 = Object.defineProperty;
5776
5938
  var __export2 = (target, all) => {
@@ -9879,7 +10041,7 @@ var SignalEventSchema = external_exports.object({
9879
10041
  // package.json
9880
10042
  var package_default = {
9881
10043
  name: "raindrop-ai",
9882
- version: "0.0.89",
10044
+ version: "0.0.90",
9883
10045
  main: "dist/index.js",
9884
10046
  module: "dist/index.mjs",
9885
10047
  types: "dist/index.d.ts",
@@ -9923,15 +10085,16 @@ var package_default = {
9923
10085
  test: "vitest run",
9924
10086
  smoke: "tsx ./scripts/smoke.ts",
9925
10087
  "smoke:ai-sdk-self-diagnostics": "tsx ./scripts/smoke.ai-sdk-self-diagnostics.ts",
9926
- "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install && pnpm smoke",
9927
- "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install && pnpm smoke",
9928
- "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install && pnpm smoke",
10088
+ "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
10089
+ "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
10090
+ "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
9929
10091
  "smoke:self-diagnostics:ai-sdk:all": "pnpm smoke:self-diagnostics:v4 && pnpm smoke:self-diagnostics:v5 && pnpm smoke:self-diagnostics:v6",
9930
- "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install && pnpm smoke",
9931
- "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install && pnpm smoke",
10092
+ "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
10093
+ "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
9932
10094
  "smoke:self-diagnostics:all": "pnpm smoke:self-diagnostics:ai-sdk:all && pnpm smoke:self-diagnostics:openai-sdk && pnpm smoke:self-diagnostics:anthropic-sdk"
9933
10095
  },
9934
10096
  devDependencies: {
10097
+ "@raindrop-ai/core": "workspace:*",
9935
10098
  "@raindrop-ai/redact-pii": "workspace:*",
9936
10099
  "@raindrop-ai/schemas": "workspace:*",
9937
10100
  ai: "^6.0.0",
@@ -9940,7 +10103,7 @@ var package_default = {
9940
10103
  tsup: "^8.4.0",
9941
10104
  tsx: "^4.20.3",
9942
10105
  typescript: "^5.3.3",
9943
- vite: "^6.4.1",
10106
+ vite: "^7.3.2",
9944
10107
  vitest: "^4.0.10"
9945
10108
  },
9946
10109
  dependencies: {
@@ -9979,6 +10142,7 @@ var package_default = {
9979
10142
  "@opentelemetry/sdk-trace-base"
9980
10143
  ],
9981
10144
  noExternal: [
10145
+ "@raindrop-ai/core",
9982
10146
  "@raindrop-ai/redact-pii",
9983
10147
  "@raindrop-ai/schemas"
9984
10148
  ],
@@ -10092,156 +10256,6 @@ var import_instrumentation_vertexai = require("@traceloop/instrumentation-vertex
10092
10256
  var traceloop3 = __toESM(require("@traceloop/node-server-sdk"));
10093
10257
  var import_weakref = require("weakref");
10094
10258
 
10095
- // ../core/dist/chunk-4UCYIEH4.js
10096
- function wait(ms) {
10097
- return new Promise((resolve) => setTimeout(resolve, ms));
10098
- }
10099
- function formatEndpoint(endpoint) {
10100
- if (!endpoint) return void 0;
10101
- return endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
10102
- }
10103
- function parseRetryAfter(headers) {
10104
- var _a;
10105
- const value = (_a = headers.get("Retry-After")) != null ? _a : headers.get("retry-after");
10106
- if (!value) return void 0;
10107
- const asNumber = Number(value);
10108
- if (value.trim() !== "" && !Number.isNaN(asNumber)) return asNumber * 1e3;
10109
- const asDate = new Date(value).getTime();
10110
- if (!Number.isNaN(asDate)) {
10111
- const delta = asDate - Date.now();
10112
- return delta > 0 ? delta : 0;
10113
- }
10114
- return void 0;
10115
- }
10116
- function getRetryDelayMs(attemptNumber, previousError) {
10117
- if (previousError && typeof previousError === "object" && previousError !== null && "retryAfterMs" in previousError) {
10118
- const v = previousError.retryAfterMs;
10119
- if (typeof v === "number") return Math.max(0, v);
10120
- }
10121
- if (attemptNumber <= 1) return 0;
10122
- const base = 500;
10123
- const factor = Math.pow(2, attemptNumber - 2);
10124
- return base * factor;
10125
- }
10126
- async function withRetry(operation, opName, opts) {
10127
- const prefix = opts.sdkName ? `[raindrop-ai/${opts.sdkName}]` : "[raindrop-ai/core]";
10128
- let lastError = void 0;
10129
- for (let attemptNumber = 1; attemptNumber <= opts.maxAttempts; attemptNumber++) {
10130
- if (attemptNumber > 1) {
10131
- const delay = getRetryDelayMs(attemptNumber, lastError);
10132
- if (opts.debug) {
10133
- console.warn(
10134
- `${prefix} ${opName} retry ${attemptNumber}/${opts.maxAttempts} in ${delay}ms`
10135
- );
10136
- }
10137
- if (delay > 0) await wait(delay);
10138
- } else if (opts.debug) {
10139
- console.log(`${prefix} ${opName} attempt ${attemptNumber}/${opts.maxAttempts}`);
10140
- }
10141
- try {
10142
- return await operation();
10143
- } catch (err) {
10144
- lastError = err;
10145
- if (opts.debug) {
10146
- const msg = err instanceof Error ? err.message : String(err);
10147
- console.warn(
10148
- `${prefix} ${opName} attempt ${attemptNumber} failed: ${msg}${attemptNumber === opts.maxAttempts ? " (no more retries)" : ""}`
10149
- );
10150
- }
10151
- if (lastError && typeof lastError === "object" && "retryable" in lastError && !lastError.retryable)
10152
- break;
10153
- if (attemptNumber === opts.maxAttempts) break;
10154
- }
10155
- }
10156
- throw lastError instanceof Error ? lastError : new Error(String(lastError));
10157
- }
10158
- async function postJson(url, body, headers, opts) {
10159
- const opName = `POST ${url}`;
10160
- await withRetry(
10161
- async () => {
10162
- const resp = await fetch(url, {
10163
- method: "POST",
10164
- headers: {
10165
- "Content-Type": "application/json",
10166
- ...headers
10167
- },
10168
- body: JSON.stringify(body)
10169
- });
10170
- if (!resp.ok) {
10171
- const text = await resp.text().catch(() => "");
10172
- const err = new Error(
10173
- `HTTP ${resp.status} ${resp.statusText}${text ? `: ${text}` : ""}`
10174
- );
10175
- const retryAfterMs = parseRetryAfter(resp.headers);
10176
- if (typeof retryAfterMs === "number") err.retryAfterMs = retryAfterMs;
10177
- err.retryable = resp.status === 429 || resp.status >= 500;
10178
- throw err;
10179
- }
10180
- },
10181
- opName,
10182
- opts
10183
- );
10184
- }
10185
- var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
10186
- function resolveLocalDebuggerBaseUrl(baseUrl) {
10187
- var _a, _b, _c;
10188
- const resolved = (_b = baseUrl != null ? baseUrl : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a[LOCAL_DEBUGGER_ENV_VAR] : void 0) != null ? _b : null;
10189
- return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
10190
- }
10191
- function localDebuggerEnabled(baseUrl) {
10192
- return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
10193
- }
10194
- function normalizeLocalDebuggerLiveEventType(type) {
10195
- switch (type) {
10196
- case "text-delta":
10197
- return "text_delta";
10198
- case "reasoning":
10199
- case "reasoning-delta":
10200
- return "reasoning_delta";
10201
- case "tool-call":
10202
- return "tool_start";
10203
- case "tool-result":
10204
- return "tool_result";
10205
- default:
10206
- return type;
10207
- }
10208
- }
10209
- function mirrorTraceExportToLocalDebugger(body, options = {}) {
10210
- var _a;
10211
- const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
10212
- if (!baseUrl) return;
10213
- void postJson(`${baseUrl}traces`, body, {}, {
10214
- maxAttempts: 1,
10215
- debug: (_a = options.debug) != null ? _a : false,
10216
- sdkName: options.sdkName
10217
- }).catch(() => {
10218
- });
10219
- }
10220
- function sendLocalDebuggerLiveEvent(event, options = {}) {
10221
- var _a, _b;
10222
- const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
10223
- if (!baseUrl) return;
10224
- void postJson(
10225
- `${baseUrl}live`,
10226
- {
10227
- ...event,
10228
- type: normalizeLocalDebuggerLiveEventType(event.type),
10229
- timestamp: (_a = event.timestamp) != null ? _a : Date.now()
10230
- },
10231
- {},
10232
- {
10233
- maxAttempts: 1,
10234
- debug: (_b = options.debug) != null ? _b : false,
10235
- sdkName: options.sdkName
10236
- }
10237
- ).catch(() => {
10238
- });
10239
- }
10240
-
10241
- // ../core/dist/index.node.js
10242
- var import_async_hooks = require("async_hooks");
10243
- globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = import_async_hooks.AsyncLocalStorage;
10244
-
10245
10259
  // src/tracing/direct/http.ts
10246
10260
  function wait2(ms) {
10247
10261
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -12686,6 +12700,11 @@ var Raindrop = class {
12686
12700
  var _a;
12687
12701
  const endpoint = "events/track_partial";
12688
12702
  const opName = `POST ${endpoint}`;
12703
+ mirrorPartialEventToLocalDebugger(event, {
12704
+ writeKey: this.writeKey,
12705
+ debug: this.debugLogs,
12706
+ sdkName: "js-sdk"
12707
+ });
12689
12708
  try {
12690
12709
  const response = await withRetry3(
12691
12710
  async () => {
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  import {
2
+ mirrorPartialEventToLocalDebugger,
2
3
  package_default,
3
4
  tracing
4
- } from "./chunk-R34PD7NX.mjs";
5
+ } from "./chunk-CPBZ7IYG.mjs";
5
6
  import {
6
7
  __commonJS,
7
8
  __toESM
@@ -10782,6 +10783,11 @@ var Raindrop = class {
10782
10783
  var _a;
10783
10784
  const endpoint = "events/track_partial";
10784
10785
  const opName = `POST ${endpoint}`;
10786
+ mirrorPartialEventToLocalDebugger(event, {
10787
+ writeKey: this.writeKey,
10788
+ debug: this.debugLogs,
10789
+ sdkName: "js-sdk"
10790
+ });
10785
10791
  try {
10786
10792
  const response = await withRetry(
10787
10793
  async () => {
@@ -49,7 +49,7 @@ var import_instrumentation_vertexai = require("@traceloop/instrumentation-vertex
49
49
  var traceloop3 = __toESM(require("@traceloop/node-server-sdk"));
50
50
  var import_weakref = require("weakref");
51
51
 
52
- // ../core/dist/chunk-4UCYIEH4.js
52
+ // ../core/dist/chunk-5KTDM7WD.js
53
53
  function wait(ms) {
54
54
  return new Promise((resolve) => setTimeout(resolve, ms));
55
55
  }
@@ -350,7 +350,7 @@ function base64ToHex(base64) {
350
350
  // package.json
351
351
  var package_default = {
352
352
  name: "raindrop-ai",
353
- version: "0.0.89",
353
+ version: "0.0.90",
354
354
  main: "dist/index.js",
355
355
  module: "dist/index.mjs",
356
356
  types: "dist/index.d.ts",
@@ -394,15 +394,16 @@ var package_default = {
394
394
  test: "vitest run",
395
395
  smoke: "tsx ./scripts/smoke.ts",
396
396
  "smoke:ai-sdk-self-diagnostics": "tsx ./scripts/smoke.ai-sdk-self-diagnostics.ts",
397
- "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install && pnpm smoke",
398
- "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install && pnpm smoke",
399
- "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install && pnpm smoke",
397
+ "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
398
+ "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
399
+ "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
400
400
  "smoke:self-diagnostics:ai-sdk:all": "pnpm smoke:self-diagnostics:v4 && pnpm smoke:self-diagnostics:v5 && pnpm smoke:self-diagnostics:v6",
401
- "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install && pnpm smoke",
402
- "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install && pnpm smoke",
401
+ "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
402
+ "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
403
403
  "smoke:self-diagnostics:all": "pnpm smoke:self-diagnostics:ai-sdk:all && pnpm smoke:self-diagnostics:openai-sdk && pnpm smoke:self-diagnostics:anthropic-sdk"
404
404
  },
405
405
  devDependencies: {
406
+ "@raindrop-ai/core": "workspace:*",
406
407
  "@raindrop-ai/redact-pii": "workspace:*",
407
408
  "@raindrop-ai/schemas": "workspace:*",
408
409
  ai: "^6.0.0",
@@ -411,7 +412,7 @@ var package_default = {
411
412
  tsup: "^8.4.0",
412
413
  tsx: "^4.20.3",
413
414
  typescript: "^5.3.3",
414
- vite: "^6.4.1",
415
+ vite: "^7.3.2",
415
416
  vitest: "^4.0.10"
416
417
  },
417
418
  dependencies: {
@@ -450,6 +451,7 @@ var package_default = {
450
451
  "@opentelemetry/sdk-trace-base"
451
452
  ],
452
453
  noExternal: [
454
+ "@raindrop-ai/core",
453
455
  "@raindrop-ai/redact-pii",
454
456
  "@raindrop-ai/schemas"
455
457
  ],
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "../chunk-R34PD7NX.mjs";
3
+ } from "../chunk-CPBZ7IYG.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.0.89",
3
+ "version": "0.0.90-otelv2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -37,21 +37,21 @@
37
37
  "dist/**"
38
38
  ],
39
39
  "devDependencies": {
40
- "ai": "^6.0.0",
41
40
  "@types/node": "^20.11.17",
41
+ "ai": "^6.0.0",
42
42
  "msw": "^2.12.8",
43
43
  "tsup": "^8.4.0",
44
44
  "tsx": "^4.20.3",
45
45
  "typescript": "^5.3.3",
46
- "vite": "^6.4.1",
46
+ "vite": "^7.3.2",
47
47
  "vitest": "^4.0.10",
48
+ "@raindrop-ai/core": "0.0.1",
48
49
  "@raindrop-ai/redact-pii": "0.1.2",
49
50
  "@raindrop-ai/schemas": "0.0.1"
50
51
  },
51
52
  "dependencies": {
52
53
  "@opentelemetry/api": "^1.9.0",
53
54
  "@opentelemetry/resources": "^2.0.1",
54
- "@traceloop/node-server-sdk": "0.19.0-otel-v1",
55
55
  "weakref": "^0.2.1",
56
56
  "zod": "^3.23.8"
57
57
  },
@@ -84,6 +84,7 @@
84
84
  "@opentelemetry/sdk-trace-base"
85
85
  ],
86
86
  "noExternal": [
87
+ "@raindrop-ai/core",
87
88
  "@raindrop-ai/redact-pii",
88
89
  "@raindrop-ai/schemas"
89
90
  ],
@@ -92,6 +93,9 @@
92
93
  },
93
94
  "clean": true
94
95
  },
96
+ "optionalDependencies": {
97
+ "@traceloop/node-server-sdk": "0.22.2"
98
+ },
95
99
  "scripts": {
96
100
  "build": "tsup",
97
101
  "dev": "tsup --watch",
@@ -100,12 +104,12 @@
100
104
  "test": "vitest run",
101
105
  "smoke": "tsx ./scripts/smoke.ts",
102
106
  "smoke:ai-sdk-self-diagnostics": "tsx ./scripts/smoke.ai-sdk-self-diagnostics.ts",
103
- "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install && pnpm smoke",
104
- "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install && pnpm smoke",
105
- "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install && pnpm smoke",
107
+ "smoke:self-diagnostics:v4": "pnpm build && cd tests/v4 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
108
+ "smoke:self-diagnostics:v5": "pnpm build && cd tests/v5 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
109
+ "smoke:self-diagnostics:v6": "pnpm build && cd tests/v6 && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
106
110
  "smoke:self-diagnostics:ai-sdk:all": "pnpm smoke:self-diagnostics:v4 && pnpm smoke:self-diagnostics:v5 && pnpm smoke:self-diagnostics:v6",
107
- "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install && pnpm smoke",
108
- "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install && pnpm smoke",
111
+ "smoke:self-diagnostics:openai-sdk": "pnpm build && cd tests/openai && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
112
+ "smoke:self-diagnostics:anthropic-sdk": "pnpm build && cd tests/anthropic && pnpm install --ignore-workspace --lockfile=false && pnpm smoke",
109
113
  "smoke:self-diagnostics:all": "pnpm smoke:self-diagnostics:ai-sdk:all && pnpm smoke:self-diagnostics:openai-sdk && pnpm smoke:self-diagnostics:anthropic-sdk"
110
114
  }
111
115
  }