raindrop-ai 0.2.1 → 0.2.2
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/README.md +34 -0
- package/dist/{chunk-UTCK3OAC.mjs → chunk-2EGS66V2.mjs} +624 -65
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +645 -63
- package/dist/index.mjs +29 -2
- package/dist/tracing/index.d.mts +16 -1
- package/dist/tracing/index.d.ts +16 -1
- package/dist/tracing/index.js +620 -63
- package/dist/tracing/index.mjs +1 -1
- package/package.json +5 -3
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
MAX_RETRY_DELAY_MS,
|
|
4
4
|
POST_SHUTDOWN_TIMEOUT_MS,
|
|
5
5
|
SHUTDOWN_DEADLINE_MS,
|
|
6
|
+
authHintForKey,
|
|
6
7
|
capText,
|
|
7
8
|
mirrorPartialEventToLocalDebugger,
|
|
8
9
|
normalizeFeatureFlags,
|
|
@@ -17,8 +18,9 @@ import {
|
|
|
17
18
|
runWithTracingSuppressed,
|
|
18
19
|
setDefaultMaxTextFieldChars,
|
|
19
20
|
stringifyBounded,
|
|
20
|
-
tracing
|
|
21
|
-
|
|
21
|
+
tracing,
|
|
22
|
+
withRoutingContext
|
|
23
|
+
} from "./chunk-2EGS66V2.mjs";
|
|
22
24
|
import {
|
|
23
25
|
__commonJS,
|
|
24
26
|
__toESM
|
|
@@ -10155,6 +10157,7 @@ var Raindrop = class {
|
|
|
10155
10157
|
setDefaultMaxTextFieldChars(config.maxTextFieldChars);
|
|
10156
10158
|
this.maxTextFieldChars = resolveMaxTextFieldChars(config.maxTextFieldChars);
|
|
10157
10159
|
this.writeKey = (_a = config.writeKey) != null ? _a : "";
|
|
10160
|
+
this.authHint = authHintForKey(this.writeKey);
|
|
10158
10161
|
this.localDebuggerUrlOpt = config.localWorkshopUrl === false ? null : config.localWorkshopUrl;
|
|
10159
10162
|
this.awaitSpanFlushOpt = config.awaitSpanFlush;
|
|
10160
10163
|
this.apiUrl = (_b = this.formatEndpoint(config.endpoint)) != null ? _b : `https://api.raindrop.ai/v1/`;
|
|
@@ -10217,6 +10220,14 @@ var Raindrop = class {
|
|
|
10217
10220
|
/**
|
|
10218
10221
|
* Begins a new interaction.
|
|
10219
10222
|
*
|
|
10223
|
+
* The interaction's routing binding lives until `finish()` (which unbinds it
|
|
10224
|
+
* by identity, so it is removed even if `finish()` runs inside a nested
|
|
10225
|
+
* `withSpan`/`withTool`/`asCurrent` scope or a detached task). One exception:
|
|
10226
|
+
* calling `begin()` INSIDE an `asCurrent(fn)` scope pushes the binding within
|
|
10227
|
+
* that scope, so it dies when the scope exits (matching the Python SDK's
|
|
10228
|
+
* token-reset semantics) — start such interactions outside `asCurrent`, or
|
|
10229
|
+
* keep their work inside the same scope.
|
|
10230
|
+
*
|
|
10220
10231
|
* @param traceContext - The trace context for the interaction.
|
|
10221
10232
|
* @returns The interaction object.
|
|
10222
10233
|
*/
|
|
@@ -10234,6 +10245,22 @@ var Raindrop = class {
|
|
|
10234
10245
|
tracer(globalProperties) {
|
|
10235
10246
|
return this._tracing.tracer(globalProperties);
|
|
10236
10247
|
}
|
|
10248
|
+
/**
|
|
10249
|
+
* Scope all spans created inside `fn` (and its awaited continuations) to this
|
|
10250
|
+
* client's project/key, without an interaction. Use it around auto-
|
|
10251
|
+
* instrumented calls (an LLM SDK call, a framework invocation) that aren't
|
|
10252
|
+
* wrapped by `begin()`/`finish()` so their spans route to this client's
|
|
10253
|
+
* project in a multi-client process. The binding lasts exactly the duration
|
|
10254
|
+
* of `fn` — it is removed when `fn` returns or throws.
|
|
10255
|
+
*
|
|
10256
|
+
* @example
|
|
10257
|
+
* ```ts
|
|
10258
|
+
* const answer = await raindrop.asCurrent(() => llm.chat({ ... }));
|
|
10259
|
+
* ```
|
|
10260
|
+
*/
|
|
10261
|
+
asCurrent(fn) {
|
|
10262
|
+
return withRoutingContext({ projectId: this.projectId, authHint: this.authHint }, fn);
|
|
10263
|
+
}
|
|
10237
10264
|
createSpanProcessor(processorOptions) {
|
|
10238
10265
|
return this._tracing.createSpanProcessor(processorOptions);
|
|
10239
10266
|
}
|
package/dist/tracing/index.d.mts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { Raindrop, RaindropSpanProcessor, PartialAiTrackEvent, Interaction, Tracer } from '../index.mjs';
|
|
1
2
|
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
2
3
|
import * as traceloop from '@traceloop/node-server-sdk';
|
|
3
|
-
import { Raindrop, RaindropSpanProcessor, PartialAiTrackEvent, Interaction, Tracer } from '../index.mjs';
|
|
4
4
|
import '@opentelemetry/api';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Tracing core - the real tracing implementation.
|
|
9
|
+
*
|
|
10
|
+
* Two modes:
|
|
11
|
+
*
|
|
12
|
+
* 1. DEFAULT: Raindrop manages everything
|
|
13
|
+
* - Creates NodeSDK, registers instrumentations, exports traces
|
|
14
|
+
* - Customer just uses raindrop.begin(), withSpan(), etc.
|
|
15
|
+
*
|
|
16
|
+
* 2. EXTERNAL OTEL (useExternalOtel: true): Customer has their own NodeSDK
|
|
17
|
+
* - Raindrop does NOT create a NodeSDK (would conflict!)
|
|
18
|
+
* - Customer adds raindrop.createSpanProcessor() to their NodeSDK
|
|
19
|
+
* - Customer calls raindrop.getInstrumentations() to get configured instrumentations
|
|
20
|
+
*/
|
|
21
|
+
|
|
7
22
|
interface TracingOptions extends traceloop.InitializeOptions {
|
|
8
23
|
/**
|
|
9
24
|
* Set to true when you have your own OpenTelemetry NodeSDK.
|
package/dist/tracing/index.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { Raindrop, RaindropSpanProcessor, PartialAiTrackEvent, Interaction, Tracer } from '../index.js';
|
|
1
2
|
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
2
3
|
import * as traceloop from '@traceloop/node-server-sdk';
|
|
3
|
-
import { Raindrop, RaindropSpanProcessor, PartialAiTrackEvent, Interaction, Tracer } from '../index.js';
|
|
4
4
|
import '@opentelemetry/api';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Tracing core - the real tracing implementation.
|
|
9
|
+
*
|
|
10
|
+
* Two modes:
|
|
11
|
+
*
|
|
12
|
+
* 1. DEFAULT: Raindrop manages everything
|
|
13
|
+
* - Creates NodeSDK, registers instrumentations, exports traces
|
|
14
|
+
* - Customer just uses raindrop.begin(), withSpan(), etc.
|
|
15
|
+
*
|
|
16
|
+
* 2. EXTERNAL OTEL (useExternalOtel: true): Customer has their own NodeSDK
|
|
17
|
+
* - Raindrop does NOT create a NodeSDK (would conflict!)
|
|
18
|
+
* - Customer adds raindrop.createSpanProcessor() to their NodeSDK
|
|
19
|
+
* - Customer calls raindrop.getInstrumentations() to get configured instrumentations
|
|
20
|
+
*/
|
|
21
|
+
|
|
7
22
|
interface TracingOptions extends traceloop.InitializeOptions {
|
|
8
23
|
/**
|
|
9
24
|
* Set to true when you have your own OpenTelemetry NodeSDK.
|