@raindrop-ai/ai-sdk 0.0.26 → 0.0.28
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/dist/{chunk-76JSTQY3.mjs → chunk-ERNKJNE5.mjs} +76 -14
- package/dist/{index-7aDHuHHR.d.mts → index-TERu6zvv.d.mts} +18 -1
- package/dist/{index-7aDHuHHR.d.ts → index-TERu6zvv.d.ts} +18 -1
- package/dist/index.browser.d.mts +18 -1
- package/dist/index.browser.d.ts +18 -1
- package/dist/index.browser.js +76 -14
- package/dist/index.browser.mjs +76 -14
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +76 -14
- package/dist/index.node.mjs +1 -1
- package/dist/index.workers.d.mts +1 -1
- package/dist/index.workers.d.ts +1 -1
- package/dist/index.workers.js +76 -14
- package/dist/index.workers.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
2
|
|
|
3
|
-
// ../core/dist/chunk-
|
|
3
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
4
4
|
function getCrypto() {
|
|
5
5
|
const c = globalThis.crypto;
|
|
6
6
|
return c;
|
|
@@ -470,10 +470,66 @@ var EventShipper = class {
|
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
472
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
473
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
474
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
475
|
+
function readEnvVar(name) {
|
|
476
|
+
var _a;
|
|
477
|
+
try {
|
|
478
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
479
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
480
|
+
return env[name];
|
|
481
|
+
}
|
|
482
|
+
} catch (e) {
|
|
483
|
+
}
|
|
484
|
+
return void 0;
|
|
485
|
+
}
|
|
486
|
+
function readWorkshopEnv() {
|
|
487
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
488
|
+
if (raw === void 0) return void 0;
|
|
489
|
+
const trimmed = raw.trim();
|
|
490
|
+
if (trimmed.length === 0) return void 0;
|
|
491
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
492
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
493
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
494
|
+
return void 0;
|
|
495
|
+
}
|
|
496
|
+
function isLocalDevHost(hostname) {
|
|
497
|
+
if (!hostname) return false;
|
|
498
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
function readRuntimeHostname() {
|
|
505
|
+
try {
|
|
506
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
507
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
508
|
+
return loc.hostname;
|
|
509
|
+
}
|
|
510
|
+
} catch (e) {
|
|
511
|
+
}
|
|
512
|
+
return void 0;
|
|
513
|
+
}
|
|
514
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
515
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
516
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
473
519
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
474
520
|
var _a, _b, _c;
|
|
475
|
-
|
|
476
|
-
|
|
521
|
+
if (baseUrl === null) return null;
|
|
522
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
523
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
524
|
+
}
|
|
525
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
526
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
527
|
+
const workshopEnv = readWorkshopEnv();
|
|
528
|
+
if (workshopEnv === "disable") return null;
|
|
529
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
530
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
531
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
532
|
+
return null;
|
|
477
533
|
}
|
|
478
534
|
function localDebuggerEnabled(baseUrl) {
|
|
479
535
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -513,7 +569,7 @@ var TraceShipper = class {
|
|
|
513
569
|
constructor(opts) {
|
|
514
570
|
this.queue = [];
|
|
515
571
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
516
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
572
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
517
573
|
this.writeKey = (_a = opts.writeKey) == null ? void 0 : _a.trim();
|
|
518
574
|
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
519
575
|
this.enabled = opts.enabled !== false;
|
|
@@ -526,12 +582,9 @@ var TraceShipper = class {
|
|
|
526
582
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
527
583
|
this.serviceName = (_g = opts.serviceName) != null ? _g : "raindrop.core";
|
|
528
584
|
this.serviceVersion = (_h = opts.serviceVersion) != null ? _h : "0.0.0";
|
|
529
|
-
|
|
530
|
-
if (
|
|
531
|
-
this.
|
|
532
|
-
if (this.debug) {
|
|
533
|
-
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
534
|
-
}
|
|
585
|
+
this.localDebuggerUrl = (_i = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _i : void 0;
|
|
586
|
+
if (this.debug && this.localDebuggerUrl) {
|
|
587
|
+
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
535
588
|
}
|
|
536
589
|
}
|
|
537
590
|
isDebugEnabled() {
|
|
@@ -1435,6 +1488,11 @@ function attrsFromGenAiRequest(options) {
|
|
|
1435
1488
|
)
|
|
1436
1489
|
];
|
|
1437
1490
|
}
|
|
1491
|
+
function attrProviderOptions(options) {
|
|
1492
|
+
if (!isRecord(options) || !isRecord(options["providerOptions"])) return void 0;
|
|
1493
|
+
const json = safeJsonWithUint8(options["providerOptions"]);
|
|
1494
|
+
return json ? attrString("ai.request.providerOptions", json) : void 0;
|
|
1495
|
+
}
|
|
1438
1496
|
|
|
1439
1497
|
// src/internal/call-metadata.ts
|
|
1440
1498
|
var SyncFallbackStorage = class {
|
|
@@ -3969,7 +4027,8 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
3969
4027
|
],
|
|
3970
4028
|
attrString("gen_ai.system", modelInfo.provider),
|
|
3971
4029
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
3972
|
-
...attrsFromGenAiRequest(options)
|
|
4030
|
+
...attrsFromGenAiRequest(options),
|
|
4031
|
+
attrProviderOptions(options)
|
|
3973
4032
|
]
|
|
3974
4033
|
});
|
|
3975
4034
|
}
|
|
@@ -4051,7 +4110,8 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4051
4110
|
],
|
|
4052
4111
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4053
4112
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4054
|
-
...attrsFromGenAiRequest(options)
|
|
4113
|
+
...attrsFromGenAiRequest(options),
|
|
4114
|
+
attrProviderOptions(options)
|
|
4055
4115
|
]
|
|
4056
4116
|
});
|
|
4057
4117
|
}
|
|
@@ -4124,7 +4184,7 @@ function extractNestedTokens(usage, key) {
|
|
|
4124
4184
|
// package.json
|
|
4125
4185
|
var package_default = {
|
|
4126
4186
|
name: "@raindrop-ai/ai-sdk",
|
|
4127
|
-
version: "0.0.
|
|
4187
|
+
version: "0.0.28"};
|
|
4128
4188
|
|
|
4129
4189
|
// src/internal/version.ts
|
|
4130
4190
|
var libraryName = package_default.name;
|
|
@@ -4230,6 +4290,7 @@ function createRaindropAISDK(opts) {
|
|
|
4230
4290
|
debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
|
|
4231
4291
|
partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
|
|
4232
4292
|
});
|
|
4293
|
+
const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
|
|
4233
4294
|
const traceShipper = new TraceShipper2({
|
|
4234
4295
|
writeKey,
|
|
4235
4296
|
endpoint: opts.endpoint,
|
|
@@ -4238,7 +4299,8 @@ function createRaindropAISDK(opts) {
|
|
|
4238
4299
|
debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
|
|
4239
4300
|
flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
|
|
4240
4301
|
maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
|
|
4241
|
-
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
|
|
4302
|
+
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
|
|
4303
|
+
localDebuggerUrl
|
|
4242
4304
|
});
|
|
4243
4305
|
return {
|
|
4244
4306
|
wrap(aiSDK, options) {
|
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -504,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
504
509
|
*/
|
|
505
510
|
writeKey?: string;
|
|
506
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
507
524
|
traces?: {
|
|
508
525
|
enabled?: boolean;
|
|
509
526
|
flushIntervalMs?: number;
|
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -504,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
504
509
|
*/
|
|
505
510
|
writeKey?: string;
|
|
506
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
507
524
|
traces?: {
|
|
508
525
|
enabled?: boolean;
|
|
509
526
|
flushIntervalMs?: number;
|
package/dist/index.browser.d.mts
CHANGED
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -504,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
504
509
|
*/
|
|
505
510
|
writeKey?: string;
|
|
506
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
507
524
|
traces?: {
|
|
508
525
|
enabled?: boolean;
|
|
509
526
|
flushIntervalMs?: number;
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -504,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
504
509
|
*/
|
|
505
510
|
writeKey?: string;
|
|
506
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
507
524
|
traces?: {
|
|
508
525
|
enabled?: boolean;
|
|
509
526
|
flushIntervalMs?: number;
|
package/dist/index.browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// ../core/dist/chunk-
|
|
3
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
4
4
|
function getCrypto() {
|
|
5
5
|
const c = globalThis.crypto;
|
|
6
6
|
return c;
|
|
@@ -470,10 +470,66 @@ var EventShipper = class {
|
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
472
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
473
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
474
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
475
|
+
function readEnvVar(name) {
|
|
476
|
+
var _a;
|
|
477
|
+
try {
|
|
478
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
479
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
480
|
+
return env[name];
|
|
481
|
+
}
|
|
482
|
+
} catch (e) {
|
|
483
|
+
}
|
|
484
|
+
return void 0;
|
|
485
|
+
}
|
|
486
|
+
function readWorkshopEnv() {
|
|
487
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
488
|
+
if (raw === void 0) return void 0;
|
|
489
|
+
const trimmed = raw.trim();
|
|
490
|
+
if (trimmed.length === 0) return void 0;
|
|
491
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
492
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
493
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
494
|
+
return void 0;
|
|
495
|
+
}
|
|
496
|
+
function isLocalDevHost(hostname) {
|
|
497
|
+
if (!hostname) return false;
|
|
498
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
function readRuntimeHostname() {
|
|
505
|
+
try {
|
|
506
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
507
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
508
|
+
return loc.hostname;
|
|
509
|
+
}
|
|
510
|
+
} catch (e) {
|
|
511
|
+
}
|
|
512
|
+
return void 0;
|
|
513
|
+
}
|
|
514
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
515
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
516
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
473
519
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
474
520
|
var _a, _b, _c;
|
|
475
|
-
|
|
476
|
-
|
|
521
|
+
if (baseUrl === null) return null;
|
|
522
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
523
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
524
|
+
}
|
|
525
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
526
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
527
|
+
const workshopEnv = readWorkshopEnv();
|
|
528
|
+
if (workshopEnv === "disable") return null;
|
|
529
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
530
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
531
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
532
|
+
return null;
|
|
477
533
|
}
|
|
478
534
|
function localDebuggerEnabled(baseUrl) {
|
|
479
535
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -513,7 +569,7 @@ var TraceShipper = class {
|
|
|
513
569
|
constructor(opts) {
|
|
514
570
|
this.queue = [];
|
|
515
571
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
516
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
572
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
517
573
|
this.writeKey = (_a = opts.writeKey) == null ? void 0 : _a.trim();
|
|
518
574
|
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
519
575
|
this.enabled = opts.enabled !== false;
|
|
@@ -526,12 +582,9 @@ var TraceShipper = class {
|
|
|
526
582
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
527
583
|
this.serviceName = (_g = opts.serviceName) != null ? _g : "raindrop.core";
|
|
528
584
|
this.serviceVersion = (_h = opts.serviceVersion) != null ? _h : "0.0.0";
|
|
529
|
-
|
|
530
|
-
if (
|
|
531
|
-
this.
|
|
532
|
-
if (this.debug) {
|
|
533
|
-
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
534
|
-
}
|
|
585
|
+
this.localDebuggerUrl = (_i = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _i : void 0;
|
|
586
|
+
if (this.debug && this.localDebuggerUrl) {
|
|
587
|
+
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
535
588
|
}
|
|
536
589
|
}
|
|
537
590
|
isDebugEnabled() {
|
|
@@ -817,7 +870,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
|
|
|
817
870
|
// package.json
|
|
818
871
|
var package_default = {
|
|
819
872
|
name: "@raindrop-ai/ai-sdk",
|
|
820
|
-
version: "0.0.
|
|
873
|
+
version: "0.0.28"};
|
|
821
874
|
|
|
822
875
|
// src/internal/version.ts
|
|
823
876
|
var libraryName = package_default.name;
|
|
@@ -1456,6 +1509,11 @@ function attrsFromGenAiRequest(options) {
|
|
|
1456
1509
|
)
|
|
1457
1510
|
];
|
|
1458
1511
|
}
|
|
1512
|
+
function attrProviderOptions(options) {
|
|
1513
|
+
if (!isRecord(options) || !isRecord(options["providerOptions"])) return void 0;
|
|
1514
|
+
const json = safeJsonWithUint8(options["providerOptions"]);
|
|
1515
|
+
return json ? attrString("ai.request.providerOptions", json) : void 0;
|
|
1516
|
+
}
|
|
1459
1517
|
|
|
1460
1518
|
// src/internal/call-metadata.ts
|
|
1461
1519
|
var SyncFallbackStorage = class {
|
|
@@ -4003,7 +4061,8 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4003
4061
|
],
|
|
4004
4062
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4005
4063
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4006
|
-
...attrsFromGenAiRequest(options)
|
|
4064
|
+
...attrsFromGenAiRequest(options),
|
|
4065
|
+
attrProviderOptions(options)
|
|
4007
4066
|
]
|
|
4008
4067
|
});
|
|
4009
4068
|
}
|
|
@@ -4085,7 +4144,8 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4085
4144
|
],
|
|
4086
4145
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4087
4146
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4088
|
-
...attrsFromGenAiRequest(options)
|
|
4147
|
+
...attrsFromGenAiRequest(options),
|
|
4148
|
+
attrProviderOptions(options)
|
|
4089
4149
|
]
|
|
4090
4150
|
});
|
|
4091
4151
|
}
|
|
@@ -4229,6 +4289,7 @@ function createRaindropAISDK(opts) {
|
|
|
4229
4289
|
debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
|
|
4230
4290
|
partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
|
|
4231
4291
|
});
|
|
4292
|
+
const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
|
|
4232
4293
|
const traceShipper = new TraceShipper2({
|
|
4233
4294
|
writeKey,
|
|
4234
4295
|
endpoint: opts.endpoint,
|
|
@@ -4237,7 +4298,8 @@ function createRaindropAISDK(opts) {
|
|
|
4237
4298
|
debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
|
|
4238
4299
|
flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
|
|
4239
4300
|
maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
|
|
4240
|
-
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
|
|
4301
|
+
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
|
|
4302
|
+
localDebuggerUrl
|
|
4241
4303
|
});
|
|
4242
4304
|
return {
|
|
4243
4305
|
wrap(aiSDK, options) {
|
package/dist/index.browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../core/dist/chunk-
|
|
1
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
2
2
|
function getCrypto() {
|
|
3
3
|
const c = globalThis.crypto;
|
|
4
4
|
return c;
|
|
@@ -468,10 +468,66 @@ var EventShipper = class {
|
|
|
468
468
|
}
|
|
469
469
|
};
|
|
470
470
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
471
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
472
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
473
|
+
function readEnvVar(name) {
|
|
474
|
+
var _a;
|
|
475
|
+
try {
|
|
476
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
477
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
478
|
+
return env[name];
|
|
479
|
+
}
|
|
480
|
+
} catch (e) {
|
|
481
|
+
}
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
function readWorkshopEnv() {
|
|
485
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
486
|
+
if (raw === void 0) return void 0;
|
|
487
|
+
const trimmed = raw.trim();
|
|
488
|
+
if (trimmed.length === 0) return void 0;
|
|
489
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
490
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
491
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
492
|
+
return void 0;
|
|
493
|
+
}
|
|
494
|
+
function isLocalDevHost(hostname) {
|
|
495
|
+
if (!hostname) return false;
|
|
496
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
function readRuntimeHostname() {
|
|
503
|
+
try {
|
|
504
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
505
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
506
|
+
return loc.hostname;
|
|
507
|
+
}
|
|
508
|
+
} catch (e) {
|
|
509
|
+
}
|
|
510
|
+
return void 0;
|
|
511
|
+
}
|
|
512
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
513
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
514
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
471
517
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
472
518
|
var _a, _b, _c;
|
|
473
|
-
|
|
474
|
-
|
|
519
|
+
if (baseUrl === null) return null;
|
|
520
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
521
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
522
|
+
}
|
|
523
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
524
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
525
|
+
const workshopEnv = readWorkshopEnv();
|
|
526
|
+
if (workshopEnv === "disable") return null;
|
|
527
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
528
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
529
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
530
|
+
return null;
|
|
475
531
|
}
|
|
476
532
|
function localDebuggerEnabled(baseUrl) {
|
|
477
533
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -511,7 +567,7 @@ var TraceShipper = class {
|
|
|
511
567
|
constructor(opts) {
|
|
512
568
|
this.queue = [];
|
|
513
569
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
514
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
570
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
515
571
|
this.writeKey = (_a = opts.writeKey) == null ? void 0 : _a.trim();
|
|
516
572
|
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
517
573
|
this.enabled = opts.enabled !== false;
|
|
@@ -524,12 +580,9 @@ var TraceShipper = class {
|
|
|
524
580
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
525
581
|
this.serviceName = (_g = opts.serviceName) != null ? _g : "raindrop.core";
|
|
526
582
|
this.serviceVersion = (_h = opts.serviceVersion) != null ? _h : "0.0.0";
|
|
527
|
-
|
|
528
|
-
if (
|
|
529
|
-
this.
|
|
530
|
-
if (this.debug) {
|
|
531
|
-
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
532
|
-
}
|
|
583
|
+
this.localDebuggerUrl = (_i = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _i : void 0;
|
|
584
|
+
if (this.debug && this.localDebuggerUrl) {
|
|
585
|
+
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
533
586
|
}
|
|
534
587
|
}
|
|
535
588
|
isDebugEnabled() {
|
|
@@ -815,7 +868,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
|
|
|
815
868
|
// package.json
|
|
816
869
|
var package_default = {
|
|
817
870
|
name: "@raindrop-ai/ai-sdk",
|
|
818
|
-
version: "0.0.
|
|
871
|
+
version: "0.0.28"};
|
|
819
872
|
|
|
820
873
|
// src/internal/version.ts
|
|
821
874
|
var libraryName = package_default.name;
|
|
@@ -1454,6 +1507,11 @@ function attrsFromGenAiRequest(options) {
|
|
|
1454
1507
|
)
|
|
1455
1508
|
];
|
|
1456
1509
|
}
|
|
1510
|
+
function attrProviderOptions(options) {
|
|
1511
|
+
if (!isRecord(options) || !isRecord(options["providerOptions"])) return void 0;
|
|
1512
|
+
const json = safeJsonWithUint8(options["providerOptions"]);
|
|
1513
|
+
return json ? attrString("ai.request.providerOptions", json) : void 0;
|
|
1514
|
+
}
|
|
1457
1515
|
|
|
1458
1516
|
// src/internal/call-metadata.ts
|
|
1459
1517
|
var SyncFallbackStorage = class {
|
|
@@ -4001,7 +4059,8 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4001
4059
|
],
|
|
4002
4060
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4003
4061
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4004
|
-
...attrsFromGenAiRequest(options)
|
|
4062
|
+
...attrsFromGenAiRequest(options),
|
|
4063
|
+
attrProviderOptions(options)
|
|
4005
4064
|
]
|
|
4006
4065
|
});
|
|
4007
4066
|
}
|
|
@@ -4083,7 +4142,8 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4083
4142
|
],
|
|
4084
4143
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4085
4144
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4086
|
-
...attrsFromGenAiRequest(options)
|
|
4145
|
+
...attrsFromGenAiRequest(options),
|
|
4146
|
+
attrProviderOptions(options)
|
|
4087
4147
|
]
|
|
4088
4148
|
});
|
|
4089
4149
|
}
|
|
@@ -4227,6 +4287,7 @@ function createRaindropAISDK(opts) {
|
|
|
4227
4287
|
debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
|
|
4228
4288
|
partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
|
|
4229
4289
|
});
|
|
4290
|
+
const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
|
|
4230
4291
|
const traceShipper = new TraceShipper2({
|
|
4231
4292
|
writeKey,
|
|
4232
4293
|
endpoint: opts.endpoint,
|
|
@@ -4235,7 +4296,8 @@ function createRaindropAISDK(opts) {
|
|
|
4235
4296
|
debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
|
|
4236
4297
|
flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
|
|
4237
4298
|
maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
|
|
4238
|
-
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
|
|
4299
|
+
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
|
|
4300
|
+
localDebuggerUrl
|
|
4239
4301
|
});
|
|
4240
4302
|
return {
|
|
4241
4303
|
wrap(aiSDK, options) {
|
package/dist/index.node.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-
|
|
1
|
+
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-TERu6zvv.mjs';
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
package/dist/index.node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-
|
|
1
|
+
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-TERu6zvv.js';
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
package/dist/index.node.js
CHANGED
|
@@ -4,7 +4,7 @@ var async_hooks = require('async_hooks');
|
|
|
4
4
|
|
|
5
5
|
// src/index.node.ts
|
|
6
6
|
|
|
7
|
-
// ../core/dist/chunk-
|
|
7
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
8
8
|
function getCrypto() {
|
|
9
9
|
const c = globalThis.crypto;
|
|
10
10
|
return c;
|
|
@@ -474,10 +474,66 @@ var EventShipper = class {
|
|
|
474
474
|
}
|
|
475
475
|
};
|
|
476
476
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
477
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
478
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
479
|
+
function readEnvVar(name) {
|
|
480
|
+
var _a;
|
|
481
|
+
try {
|
|
482
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
483
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
484
|
+
return env[name];
|
|
485
|
+
}
|
|
486
|
+
} catch (e) {
|
|
487
|
+
}
|
|
488
|
+
return void 0;
|
|
489
|
+
}
|
|
490
|
+
function readWorkshopEnv() {
|
|
491
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
492
|
+
if (raw === void 0) return void 0;
|
|
493
|
+
const trimmed = raw.trim();
|
|
494
|
+
if (trimmed.length === 0) return void 0;
|
|
495
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
496
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
497
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
498
|
+
return void 0;
|
|
499
|
+
}
|
|
500
|
+
function isLocalDevHost(hostname) {
|
|
501
|
+
if (!hostname) return false;
|
|
502
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
function readRuntimeHostname() {
|
|
509
|
+
try {
|
|
510
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
511
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
512
|
+
return loc.hostname;
|
|
513
|
+
}
|
|
514
|
+
} catch (e) {
|
|
515
|
+
}
|
|
516
|
+
return void 0;
|
|
517
|
+
}
|
|
518
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
519
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
520
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
477
523
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
478
524
|
var _a, _b, _c;
|
|
479
|
-
|
|
480
|
-
|
|
525
|
+
if (baseUrl === null) return null;
|
|
526
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
527
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
528
|
+
}
|
|
529
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
530
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
531
|
+
const workshopEnv = readWorkshopEnv();
|
|
532
|
+
if (workshopEnv === "disable") return null;
|
|
533
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
534
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
535
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
536
|
+
return null;
|
|
481
537
|
}
|
|
482
538
|
function localDebuggerEnabled(baseUrl) {
|
|
483
539
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -517,7 +573,7 @@ var TraceShipper = class {
|
|
|
517
573
|
constructor(opts) {
|
|
518
574
|
this.queue = [];
|
|
519
575
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
520
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
576
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
521
577
|
this.writeKey = (_a = opts.writeKey) == null ? void 0 : _a.trim();
|
|
522
578
|
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
523
579
|
this.enabled = opts.enabled !== false;
|
|
@@ -530,12 +586,9 @@ var TraceShipper = class {
|
|
|
530
586
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
531
587
|
this.serviceName = (_g = opts.serviceName) != null ? _g : "raindrop.core";
|
|
532
588
|
this.serviceVersion = (_h = opts.serviceVersion) != null ? _h : "0.0.0";
|
|
533
|
-
|
|
534
|
-
if (
|
|
535
|
-
this.
|
|
536
|
-
if (this.debug) {
|
|
537
|
-
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
538
|
-
}
|
|
589
|
+
this.localDebuggerUrl = (_i = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _i : void 0;
|
|
590
|
+
if (this.debug && this.localDebuggerUrl) {
|
|
591
|
+
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
539
592
|
}
|
|
540
593
|
}
|
|
541
594
|
isDebugEnabled() {
|
|
@@ -822,7 +875,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = async_hooks.AsyncLocalStorage;
|
|
|
822
875
|
// package.json
|
|
823
876
|
var package_default = {
|
|
824
877
|
name: "@raindrop-ai/ai-sdk",
|
|
825
|
-
version: "0.0.
|
|
878
|
+
version: "0.0.28"};
|
|
826
879
|
|
|
827
880
|
// src/internal/version.ts
|
|
828
881
|
var libraryName = package_default.name;
|
|
@@ -1461,6 +1514,11 @@ function attrsFromGenAiRequest(options) {
|
|
|
1461
1514
|
)
|
|
1462
1515
|
];
|
|
1463
1516
|
}
|
|
1517
|
+
function attrProviderOptions(options) {
|
|
1518
|
+
if (!isRecord(options) || !isRecord(options["providerOptions"])) return void 0;
|
|
1519
|
+
const json = safeJsonWithUint8(options["providerOptions"]);
|
|
1520
|
+
return json ? attrString("ai.request.providerOptions", json) : void 0;
|
|
1521
|
+
}
|
|
1464
1522
|
|
|
1465
1523
|
// src/internal/call-metadata.ts
|
|
1466
1524
|
var SyncFallbackStorage = class {
|
|
@@ -4008,7 +4066,8 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4008
4066
|
],
|
|
4009
4067
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4010
4068
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4011
|
-
...attrsFromGenAiRequest(options)
|
|
4069
|
+
...attrsFromGenAiRequest(options),
|
|
4070
|
+
attrProviderOptions(options)
|
|
4012
4071
|
]
|
|
4013
4072
|
});
|
|
4014
4073
|
}
|
|
@@ -4090,7 +4149,8 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4090
4149
|
],
|
|
4091
4150
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4092
4151
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4093
|
-
...attrsFromGenAiRequest(options)
|
|
4152
|
+
...attrsFromGenAiRequest(options),
|
|
4153
|
+
attrProviderOptions(options)
|
|
4094
4154
|
]
|
|
4095
4155
|
});
|
|
4096
4156
|
}
|
|
@@ -4234,6 +4294,7 @@ function createRaindropAISDK(opts) {
|
|
|
4234
4294
|
debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
|
|
4235
4295
|
partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
|
|
4236
4296
|
});
|
|
4297
|
+
const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
|
|
4237
4298
|
const traceShipper = new TraceShipper2({
|
|
4238
4299
|
writeKey,
|
|
4239
4300
|
endpoint: opts.endpoint,
|
|
@@ -4242,7 +4303,8 @@ function createRaindropAISDK(opts) {
|
|
|
4242
4303
|
debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
|
|
4243
4304
|
flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
|
|
4244
4305
|
maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
|
|
4245
|
-
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
|
|
4306
|
+
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
|
|
4307
|
+
localDebuggerUrl
|
|
4246
4308
|
});
|
|
4247
4309
|
return {
|
|
4248
4310
|
wrap(aiSDK, options) {
|
package/dist/index.node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-
|
|
1
|
+
export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-ERNKJNE5.mjs';
|
|
2
2
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
3
|
|
|
4
4
|
globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
|
package/dist/index.workers.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-
|
|
1
|
+
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-TERu6zvv.mjs';
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
package/dist/index.workers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-
|
|
1
|
+
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, E as EndSpanArgs, h as EventBuilder, i as EventMetadataOptions, I as IdentifyInput, R as RaindropAISDKClient, j as RaindropAISDKContext, k as RaindropAISDKOptions, l as RaindropCallMetadata, m as RaindropTelemetryIntegration, n as RaindropTelemetryIntegrationOptions, S as SelfDiagnosticsOptions, o as SelfDiagnosticsSignalDefinition, p as SelfDiagnosticsSignalDefinitions, q as StartSpanArgs, T as TraceSpan, W as WrapAISDKOptions, r as WrappedAI, s as WrappedAISDK, _ as _resetRaindropCallMetadataStorage, t as _resetWarnedMissingUserId, u as createRaindropAISDK, v as currentSpan, w as eventMetadata, x as eventMetadataFromChatRequest, y as getContextManager, z as getCurrentRaindropCallMetadata, D as readRaindropCallMetadataFromArgs, F as runWithRaindropCallMetadata, G as withCurrent } from './index-TERu6zvv.js';
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
package/dist/index.workers.js
CHANGED
|
@@ -4,7 +4,7 @@ var async_hooks = require('async_hooks');
|
|
|
4
4
|
|
|
5
5
|
// src/index.workers.ts
|
|
6
6
|
|
|
7
|
-
// ../core/dist/chunk-
|
|
7
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
8
8
|
function getCrypto() {
|
|
9
9
|
const c = globalThis.crypto;
|
|
10
10
|
return c;
|
|
@@ -474,10 +474,66 @@ var EventShipper = class {
|
|
|
474
474
|
}
|
|
475
475
|
};
|
|
476
476
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
477
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
478
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
479
|
+
function readEnvVar(name) {
|
|
480
|
+
var _a;
|
|
481
|
+
try {
|
|
482
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
483
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
484
|
+
return env[name];
|
|
485
|
+
}
|
|
486
|
+
} catch (e) {
|
|
487
|
+
}
|
|
488
|
+
return void 0;
|
|
489
|
+
}
|
|
490
|
+
function readWorkshopEnv() {
|
|
491
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
492
|
+
if (raw === void 0) return void 0;
|
|
493
|
+
const trimmed = raw.trim();
|
|
494
|
+
if (trimmed.length === 0) return void 0;
|
|
495
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
496
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
497
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
498
|
+
return void 0;
|
|
499
|
+
}
|
|
500
|
+
function isLocalDevHost(hostname) {
|
|
501
|
+
if (!hostname) return false;
|
|
502
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
function readRuntimeHostname() {
|
|
509
|
+
try {
|
|
510
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
511
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
512
|
+
return loc.hostname;
|
|
513
|
+
}
|
|
514
|
+
} catch (e) {
|
|
515
|
+
}
|
|
516
|
+
return void 0;
|
|
517
|
+
}
|
|
518
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
519
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
520
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
477
523
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
478
524
|
var _a, _b, _c;
|
|
479
|
-
|
|
480
|
-
|
|
525
|
+
if (baseUrl === null) return null;
|
|
526
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
527
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
528
|
+
}
|
|
529
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
530
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
531
|
+
const workshopEnv = readWorkshopEnv();
|
|
532
|
+
if (workshopEnv === "disable") return null;
|
|
533
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
534
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
535
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
536
|
+
return null;
|
|
481
537
|
}
|
|
482
538
|
function localDebuggerEnabled(baseUrl) {
|
|
483
539
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -517,7 +573,7 @@ var TraceShipper = class {
|
|
|
517
573
|
constructor(opts) {
|
|
518
574
|
this.queue = [];
|
|
519
575
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
520
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
576
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
521
577
|
this.writeKey = (_a = opts.writeKey) == null ? void 0 : _a.trim();
|
|
522
578
|
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
523
579
|
this.enabled = opts.enabled !== false;
|
|
@@ -530,12 +586,9 @@ var TraceShipper = class {
|
|
|
530
586
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
531
587
|
this.serviceName = (_g = opts.serviceName) != null ? _g : "raindrop.core";
|
|
532
588
|
this.serviceVersion = (_h = opts.serviceVersion) != null ? _h : "0.0.0";
|
|
533
|
-
|
|
534
|
-
if (
|
|
535
|
-
this.
|
|
536
|
-
if (this.debug) {
|
|
537
|
-
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
538
|
-
}
|
|
589
|
+
this.localDebuggerUrl = (_i = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _i : void 0;
|
|
590
|
+
if (this.debug && this.localDebuggerUrl) {
|
|
591
|
+
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
539
592
|
}
|
|
540
593
|
}
|
|
541
594
|
isDebugEnabled() {
|
|
@@ -822,7 +875,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = async_hooks.AsyncLocalStorage;
|
|
|
822
875
|
// package.json
|
|
823
876
|
var package_default = {
|
|
824
877
|
name: "@raindrop-ai/ai-sdk",
|
|
825
|
-
version: "0.0.
|
|
878
|
+
version: "0.0.28"};
|
|
826
879
|
|
|
827
880
|
// src/internal/version.ts
|
|
828
881
|
var libraryName = package_default.name;
|
|
@@ -1461,6 +1514,11 @@ function attrsFromGenAiRequest(options) {
|
|
|
1461
1514
|
)
|
|
1462
1515
|
];
|
|
1463
1516
|
}
|
|
1517
|
+
function attrProviderOptions(options) {
|
|
1518
|
+
if (!isRecord(options) || !isRecord(options["providerOptions"])) return void 0;
|
|
1519
|
+
const json = safeJsonWithUint8(options["providerOptions"]);
|
|
1520
|
+
return json ? attrString("ai.request.providerOptions", json) : void 0;
|
|
1521
|
+
}
|
|
1464
1522
|
|
|
1465
1523
|
// src/internal/call-metadata.ts
|
|
1466
1524
|
var SyncFallbackStorage = class {
|
|
@@ -4008,7 +4066,8 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4008
4066
|
],
|
|
4009
4067
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4010
4068
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4011
|
-
...attrsFromGenAiRequest(options)
|
|
4069
|
+
...attrsFromGenAiRequest(options),
|
|
4070
|
+
attrProviderOptions(options)
|
|
4012
4071
|
]
|
|
4013
4072
|
});
|
|
4014
4073
|
}
|
|
@@ -4090,7 +4149,8 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4090
4149
|
],
|
|
4091
4150
|
attrString("gen_ai.system", modelInfo.provider),
|
|
4092
4151
|
attrString("gen_ai.request.model", modelInfo.modelId),
|
|
4093
|
-
...attrsFromGenAiRequest(options)
|
|
4152
|
+
...attrsFromGenAiRequest(options),
|
|
4153
|
+
attrProviderOptions(options)
|
|
4094
4154
|
]
|
|
4095
4155
|
});
|
|
4096
4156
|
}
|
|
@@ -4234,6 +4294,7 @@ function createRaindropAISDK(opts) {
|
|
|
4234
4294
|
debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
|
|
4235
4295
|
partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
|
|
4236
4296
|
});
|
|
4297
|
+
const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
|
|
4237
4298
|
const traceShipper = new TraceShipper2({
|
|
4238
4299
|
writeKey,
|
|
4239
4300
|
endpoint: opts.endpoint,
|
|
@@ -4242,7 +4303,8 @@ function createRaindropAISDK(opts) {
|
|
|
4242
4303
|
debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
|
|
4243
4304
|
flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
|
|
4244
4305
|
maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
|
|
4245
|
-
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
|
|
4306
|
+
maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
|
|
4307
|
+
localDebuggerUrl
|
|
4246
4308
|
});
|
|
4247
4309
|
return {
|
|
4248
4310
|
wrap(aiSDK, options) {
|
package/dist/index.workers.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-
|
|
1
|
+
export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-ERNKJNE5.mjs';
|
|
2
2
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
3
|
|
|
4
4
|
if (!globalThis.RAINDROP_ASYNC_LOCAL_STORAGE) {
|
package/package.json
CHANGED