@raindrop-ai/ai-sdk 0.0.26 → 0.0.27

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,6 +1,6 @@
1
1
  import { AsyncLocalStorage } from 'async_hooks';
2
2
 
3
- // ../core/dist/chunk-Y7SM66SW.js
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
- 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;
476
- return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
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, _j;
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
- const localDebugger = typeof process !== "undefined" ? (_i = process.env) == null ? void 0 : _i.RAINDROP_LOCAL_DEBUGGER : void 0;
530
- if (localDebugger) {
531
- this.localDebuggerUrl = (_j = resolveLocalDebuggerBaseUrl(localDebugger)) != null ? _j : void 0;
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() {
@@ -4124,7 +4177,7 @@ function extractNestedTokens(usage, key) {
4124
4177
  // package.json
4125
4178
  var package_default = {
4126
4179
  name: "@raindrop-ai/ai-sdk",
4127
- version: "0.0.26"};
4180
+ version: "0.0.27"};
4128
4181
 
4129
4182
  // src/internal/version.ts
4130
4183
  var libraryName = package_default.name;
@@ -4230,6 +4283,7 @@ function createRaindropAISDK(opts) {
4230
4283
  debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
4231
4284
  partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
4232
4285
  });
4286
+ const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
4233
4287
  const traceShipper = new TraceShipper2({
4234
4288
  writeKey,
4235
4289
  endpoint: opts.endpoint,
@@ -4238,7 +4292,8 @@ function createRaindropAISDK(opts) {
4238
4292
  debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
4239
4293
  flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
4240
4294
  maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
4241
- maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
4295
+ maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
4296
+ localDebuggerUrl
4242
4297
  });
4243
4298
  return {
4244
4299
  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 (from RAINDROP_LOCAL_DEBUGGER env var). */
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 (from RAINDROP_LOCAL_DEBUGGER env var). */
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 (from RAINDROP_LOCAL_DEBUGGER env var). */
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 (from RAINDROP_LOCAL_DEBUGGER env var). */
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;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- // ../core/dist/chunk-Y7SM66SW.js
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
- 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;
476
- return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
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, _j;
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
- const localDebugger = typeof process !== "undefined" ? (_i = process.env) == null ? void 0 : _i.RAINDROP_LOCAL_DEBUGGER : void 0;
530
- if (localDebugger) {
531
- this.localDebuggerUrl = (_j = resolveLocalDebuggerBaseUrl(localDebugger)) != null ? _j : void 0;
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.26"};
873
+ version: "0.0.27"};
821
874
 
822
875
  // src/internal/version.ts
823
876
  var libraryName = package_default.name;
@@ -4229,6 +4282,7 @@ function createRaindropAISDK(opts) {
4229
4282
  debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
4230
4283
  partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
4231
4284
  });
4285
+ const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
4232
4286
  const traceShipper = new TraceShipper2({
4233
4287
  writeKey,
4234
4288
  endpoint: opts.endpoint,
@@ -4237,7 +4291,8 @@ function createRaindropAISDK(opts) {
4237
4291
  debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
4238
4292
  flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
4239
4293
  maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
4240
- maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
4294
+ maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
4295
+ localDebuggerUrl
4241
4296
  });
4242
4297
  return {
4243
4298
  wrap(aiSDK, options) {
@@ -1,4 +1,4 @@
1
- // ../core/dist/chunk-Y7SM66SW.js
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
- 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;
474
- return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
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, _j;
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
- const localDebugger = typeof process !== "undefined" ? (_i = process.env) == null ? void 0 : _i.RAINDROP_LOCAL_DEBUGGER : void 0;
528
- if (localDebugger) {
529
- this.localDebuggerUrl = (_j = resolveLocalDebuggerBaseUrl(localDebugger)) != null ? _j : void 0;
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.26"};
871
+ version: "0.0.27"};
819
872
 
820
873
  // src/internal/version.ts
821
874
  var libraryName = package_default.name;
@@ -4227,6 +4280,7 @@ function createRaindropAISDK(opts) {
4227
4280
  debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
4228
4281
  partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
4229
4282
  });
4283
+ const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
4230
4284
  const traceShipper = new TraceShipper2({
4231
4285
  writeKey,
4232
4286
  endpoint: opts.endpoint,
@@ -4235,7 +4289,8 @@ function createRaindropAISDK(opts) {
4235
4289
  debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
4236
4290
  flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
4237
4291
  maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
4238
- maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
4292
+ maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
4293
+ localDebuggerUrl
4239
4294
  });
4240
4295
  return {
4241
4296
  wrap(aiSDK, options) {
@@ -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-7aDHuHHR.mjs';
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>() => {
@@ -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-7aDHuHHR.js';
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>() => {
@@ -4,7 +4,7 @@ var async_hooks = require('async_hooks');
4
4
 
5
5
  // src/index.node.ts
6
6
 
7
- // ../core/dist/chunk-Y7SM66SW.js
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
- 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;
480
- return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
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, _j;
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
- const localDebugger = typeof process !== "undefined" ? (_i = process.env) == null ? void 0 : _i.RAINDROP_LOCAL_DEBUGGER : void 0;
534
- if (localDebugger) {
535
- this.localDebuggerUrl = (_j = resolveLocalDebuggerBaseUrl(localDebugger)) != null ? _j : void 0;
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.26"};
878
+ version: "0.0.27"};
826
879
 
827
880
  // src/internal/version.ts
828
881
  var libraryName = package_default.name;
@@ -4234,6 +4287,7 @@ function createRaindropAISDK(opts) {
4234
4287
  debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
4235
4288
  partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
4236
4289
  });
4290
+ const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
4237
4291
  const traceShipper = new TraceShipper2({
4238
4292
  writeKey,
4239
4293
  endpoint: opts.endpoint,
@@ -4242,7 +4296,8 @@ function createRaindropAISDK(opts) {
4242
4296
  debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
4243
4297
  flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
4244
4298
  maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
4245
- maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
4299
+ maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
4300
+ localDebuggerUrl
4246
4301
  });
4247
4302
  return {
4248
4303
  wrap(aiSDK, options) {
@@ -1,4 +1,4 @@
1
- export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-76JSTQY3.mjs';
1
+ export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-YP2VKVP7.mjs';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
4
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
@@ -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-7aDHuHHR.mjs';
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>() => {
@@ -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-7aDHuHHR.js';
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>() => {
@@ -4,7 +4,7 @@ var async_hooks = require('async_hooks');
4
4
 
5
5
  // src/index.workers.ts
6
6
 
7
- // ../core/dist/chunk-Y7SM66SW.js
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
- 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;
480
- return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
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, _j;
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
- const localDebugger = typeof process !== "undefined" ? (_i = process.env) == null ? void 0 : _i.RAINDROP_LOCAL_DEBUGGER : void 0;
534
- if (localDebugger) {
535
- this.localDebuggerUrl = (_j = resolveLocalDebuggerBaseUrl(localDebugger)) != null ? _j : void 0;
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.26"};
878
+ version: "0.0.27"};
826
879
 
827
880
  // src/internal/version.ts
828
881
  var libraryName = package_default.name;
@@ -4234,6 +4287,7 @@ function createRaindropAISDK(opts) {
4234
4287
  debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
4235
4288
  partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs
4236
4289
  });
4290
+ const localDebuggerUrl = opts.localWorkshopUrl === false ? null : opts.localWorkshopUrl;
4237
4291
  const traceShipper = new TraceShipper2({
4238
4292
  writeKey,
4239
4293
  endpoint: opts.endpoint,
@@ -4242,7 +4296,8 @@ function createRaindropAISDK(opts) {
4242
4296
  debugSpans: ((_f = opts.traces) == null ? void 0 : _f.debugSpans) === true || envDebug,
4243
4297
  flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
4244
4298
  maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
4245
- maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize
4299
+ maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
4300
+ localDebuggerUrl
4246
4301
  });
4247
4302
  return {
4248
4303
  wrap(aiSDK, options) {
@@ -1,4 +1,4 @@
1
- export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-76JSTQY3.mjs';
1
+ export { RaindropTelemetryIntegration, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent } from './chunk-YP2VKVP7.mjs';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
4
  if (!globalThis.RAINDROP_ASYNC_LOCAL_STORAGE) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/ai-sdk",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "Standalone Vercel AI SDK integration for Raindrop (events + OTLP/HTTP JSON traces, no OTEL runtime)",
5
5
  "main": "dist/index.node.js",
6
6
  "module": "dist/index.node.mjs",