@raindrop-ai/langchain 0.0.4 → 0.0.5

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/index.d.mts CHANGED
@@ -91,6 +91,13 @@ type EventShipperOptions = {
91
91
  * Pass `null` to opt out of all mirroring (including auto-detect).
92
92
  */
93
93
  localDebuggerUrl?: string | null;
94
+ /**
95
+ * Optional project slug. When set, every outbound cloud request includes an
96
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
97
+ * values are ignored. Slug format is validated on construction but never
98
+ * throws — the backend returns 400 on invalid values.
99
+ */
100
+ projectId?: string;
94
101
  /**
95
102
  * Per-field character cap applied to event input/output BEFORE buffering
96
103
  * or serialization, so oversized payloads cost the cap — not the payload —
@@ -109,6 +116,7 @@ declare class EventShipper {
109
116
  private sdkName;
110
117
  private prefix;
111
118
  private defaultEventName;
119
+ private projectId;
112
120
  private context;
113
121
  private buffers;
114
122
  private sticky;
@@ -132,6 +140,7 @@ declare class EventShipper {
132
140
  constructor(opts: EventShipperOptions);
133
141
  isDebugEnabled(): boolean;
134
142
  private authHeaders;
143
+ private requestHeaders;
135
144
  /**
136
145
  * Build the retry/timeout options for one POST, honoring the shutdown
137
146
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -203,6 +212,13 @@ type TraceShipperOptions = {
203
212
  * Pass `null` to opt out of all mirroring (including auto-detect).
204
213
  */
205
214
  localDebuggerUrl?: string | null;
215
+ /**
216
+ * Optional project slug. When set, every OTLP trace export includes an
217
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
218
+ * values are ignored. Slug format is validated on construction but never
219
+ * throws — the backend returns 400 on invalid values.
220
+ */
221
+ projectId?: string;
206
222
  /**
207
223
  * Per-span hook that fires for every OTLP span right before the span is
208
224
  * shipped (both to the Raindrop API and to a local debugger). Lets callers
@@ -260,6 +276,7 @@ declare class TraceShipper {
260
276
  private flushIntervalMs;
261
277
  private maxBatchSize;
262
278
  private maxQueueSize;
279
+ private projectId;
263
280
  private queue;
264
281
  private timer;
265
282
  private inFlight;
@@ -310,6 +327,7 @@ declare class TraceShipper {
310
327
  private redactSpan;
311
328
  isDebugEnabled(): boolean;
312
329
  private authHeaders;
330
+ private requestHeaders;
313
331
  startSpan(args: {
314
332
  name: string;
315
333
  parent?: {
@@ -441,6 +459,12 @@ interface LangChainOptions {
441
459
  debug?: boolean;
442
460
  userId?: string;
443
461
  convoId?: string;
462
+ /**
463
+ * Optional Raindrop project slug. When set, every outbound cloud request
464
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
465
+ * resolves to `default` server-side; byte-identical to prior behavior).
466
+ */
467
+ projectId?: string;
444
468
  traceChains?: boolean;
445
469
  traceRetrievers?: boolean;
446
470
  /**
package/dist/index.d.ts CHANGED
@@ -91,6 +91,13 @@ type EventShipperOptions = {
91
91
  * Pass `null` to opt out of all mirroring (including auto-detect).
92
92
  */
93
93
  localDebuggerUrl?: string | null;
94
+ /**
95
+ * Optional project slug. When set, every outbound cloud request includes an
96
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
97
+ * values are ignored. Slug format is validated on construction but never
98
+ * throws — the backend returns 400 on invalid values.
99
+ */
100
+ projectId?: string;
94
101
  /**
95
102
  * Per-field character cap applied to event input/output BEFORE buffering
96
103
  * or serialization, so oversized payloads cost the cap — not the payload —
@@ -109,6 +116,7 @@ declare class EventShipper {
109
116
  private sdkName;
110
117
  private prefix;
111
118
  private defaultEventName;
119
+ private projectId;
112
120
  private context;
113
121
  private buffers;
114
122
  private sticky;
@@ -132,6 +140,7 @@ declare class EventShipper {
132
140
  constructor(opts: EventShipperOptions);
133
141
  isDebugEnabled(): boolean;
134
142
  private authHeaders;
143
+ private requestHeaders;
135
144
  /**
136
145
  * Build the retry/timeout options for one POST, honoring the shutdown
137
146
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -203,6 +212,13 @@ type TraceShipperOptions = {
203
212
  * Pass `null` to opt out of all mirroring (including auto-detect).
204
213
  */
205
214
  localDebuggerUrl?: string | null;
215
+ /**
216
+ * Optional project slug. When set, every OTLP trace export includes an
217
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
218
+ * values are ignored. Slug format is validated on construction but never
219
+ * throws — the backend returns 400 on invalid values.
220
+ */
221
+ projectId?: string;
206
222
  /**
207
223
  * Per-span hook that fires for every OTLP span right before the span is
208
224
  * shipped (both to the Raindrop API and to a local debugger). Lets callers
@@ -260,6 +276,7 @@ declare class TraceShipper {
260
276
  private flushIntervalMs;
261
277
  private maxBatchSize;
262
278
  private maxQueueSize;
279
+ private projectId;
263
280
  private queue;
264
281
  private timer;
265
282
  private inFlight;
@@ -310,6 +327,7 @@ declare class TraceShipper {
310
327
  private redactSpan;
311
328
  isDebugEnabled(): boolean;
312
329
  private authHeaders;
330
+ private requestHeaders;
313
331
  startSpan(args: {
314
332
  name: string;
315
333
  parent?: {
@@ -441,6 +459,12 @@ interface LangChainOptions {
441
459
  debug?: boolean;
442
460
  userId?: string;
443
461
  convoId?: string;
462
+ /**
463
+ * Optional Raindrop project slug. When set, every outbound cloud request
464
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
465
+ * resolves to `default` server-side; byte-identical to prior behavior).
466
+ */
467
+ projectId?: string;
444
468
  traceChains?: boolean;
445
469
  traceRetrievers?: boolean;
446
470
  /**
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(index_exports);
28
28
  // src/callback-handler.ts
29
29
  var import_base = require("@langchain/core/callbacks/base");
30
30
 
31
- // ../core/dist/chunk-U5HUTMR5.js
31
+ // ../core/dist/chunk-SK6EJEO7.js
32
32
  function getCrypto() {
33
33
  const c = globalThis.crypto;
34
34
  return c;
@@ -380,6 +380,25 @@ function mirrorPartialEventToLocalDebugger(event, options = {}) {
380
380
  }).catch(() => {
381
381
  });
382
382
  }
383
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
384
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
385
+ function isValidProjectIdSlug(value) {
386
+ return PROJECT_ID_SLUG_PATTERN.test(value);
387
+ }
388
+ function normalizeProjectId(raw, opts) {
389
+ if (typeof raw !== "string") return void 0;
390
+ const trimmed = raw.trim();
391
+ if (!trimmed) return void 0;
392
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
393
+ console.warn(
394
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
395
+ );
396
+ }
397
+ return trimmed;
398
+ }
399
+ function projectIdHeaders(projectId) {
400
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
401
+ }
383
402
  var SHUTDOWN_DEADLINE_MS = 1e4;
384
403
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
385
404
  function mergePatches(target, source) {
@@ -414,6 +433,10 @@ var EventShipper = class {
414
433
  if (this.debug && this.localDebuggerUrl) {
415
434
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
416
435
  }
436
+ this.projectId = normalizeProjectId(opts.projectId, {
437
+ debug: this.debug,
438
+ prefix: this.prefix
439
+ });
417
440
  const isNode = typeof process !== "undefined" && typeof process.version === "string";
418
441
  this.context = {
419
442
  library: {
@@ -432,6 +455,9 @@ var EventShipper = class {
432
455
  authHeaders() {
433
456
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
434
457
  }
458
+ requestHeaders() {
459
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
460
+ }
435
461
  /**
436
462
  * Build the retry/timeout options for one POST, honoring the shutdown
437
463
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -561,7 +587,7 @@ var EventShipper = class {
561
587
  return;
562
588
  }
563
589
  try {
564
- await postJson(url, body, this.authHeaders(), opts);
590
+ await postJson(url, body, this.requestHeaders(), opts);
565
591
  } catch (err) {
566
592
  const msg = err instanceof Error ? err.message : String(err);
567
593
  rateLimitedLog(
@@ -597,7 +623,7 @@ var EventShipper = class {
597
623
  return;
598
624
  }
599
625
  try {
600
- await postJson(url, body, this.authHeaders(), opts);
626
+ await postJson(url, body, this.requestHeaders(), opts);
601
627
  } catch (err) {
602
628
  const msg = err instanceof Error ? err.message : String(err);
603
629
  rateLimitedLog(
@@ -693,7 +719,7 @@ var EventShipper = class {
693
719
  if (!isPending) this.sticky.delete(eventId);
694
720
  return;
695
721
  }
696
- const p = postJson(url, payload, this.authHeaders(), opts);
722
+ const p = postJson(url, payload, this.requestHeaders(), opts);
697
723
  this.inFlight.add(p);
698
724
  try {
699
725
  try {
@@ -840,6 +866,10 @@ var TraceShipper = class {
840
866
  if (this.debug && this.localDebuggerUrl) {
841
867
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
842
868
  }
869
+ this.projectId = normalizeProjectId(opts.projectId, {
870
+ debug: this.debug,
871
+ prefix: this.prefix
872
+ });
843
873
  this.transformSpanHook = opts.transformSpan;
844
874
  this.disableDefaultRedaction = opts.disableDefaultRedaction === true;
845
875
  this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
@@ -916,6 +946,9 @@ var TraceShipper = class {
916
946
  authHeaders() {
917
947
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
918
948
  }
949
+ requestHeaders() {
950
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
951
+ }
919
952
  startSpan(args) {
920
953
  var _a, _b;
921
954
  const ids = createSpanIds(args.parent);
@@ -1047,7 +1080,7 @@ var TraceShipper = class {
1047
1080
  endpoint: url
1048
1081
  });
1049
1082
  }
1050
- const p = postJson(url, body, this.authHeaders(), opts);
1083
+ const p = postJson(url, body, this.requestHeaders(), opts);
1051
1084
  this.inFlight.add(p);
1052
1085
  try {
1053
1086
  try {
@@ -1642,7 +1675,7 @@ function extractLLMMetadata(output) {
1642
1675
  // package.json
1643
1676
  var package_default = {
1644
1677
  name: "@raindrop-ai/langchain",
1645
- version: "0.0.4",
1678
+ version: "0.0.5",
1646
1679
  description: "Raindrop integration for LangChain",
1647
1680
  main: "dist/index.js",
1648
1681
  module: "dist/index.mjs",
@@ -1725,6 +1758,7 @@ function createRaindropLangChain(opts) {
1725
1758
  endpoint: opts.endpoint,
1726
1759
  enabled,
1727
1760
  debug: (_a = opts.debug) != null ? _a : false,
1761
+ projectId: opts.projectId,
1728
1762
  sdkName: "langchain",
1729
1763
  libraryName,
1730
1764
  libraryVersion
@@ -1734,6 +1768,7 @@ function createRaindropLangChain(opts) {
1734
1768
  endpoint: opts.endpoint,
1735
1769
  enabled,
1736
1770
  debug: (_b = opts.debug) != null ? _b : false,
1771
+ projectId: opts.projectId,
1737
1772
  sdkName: "langchain",
1738
1773
  serviceName: "raindrop.langchain",
1739
1774
  serviceVersion: libraryVersion
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/callback-handler.ts
2
2
  import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
3
3
 
4
- // ../core/dist/chunk-U5HUTMR5.js
4
+ // ../core/dist/chunk-SK6EJEO7.js
5
5
  function getCrypto() {
6
6
  const c = globalThis.crypto;
7
7
  return c;
@@ -353,6 +353,25 @@ function mirrorPartialEventToLocalDebugger(event, options = {}) {
353
353
  }).catch(() => {
354
354
  });
355
355
  }
356
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
357
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
358
+ function isValidProjectIdSlug(value) {
359
+ return PROJECT_ID_SLUG_PATTERN.test(value);
360
+ }
361
+ function normalizeProjectId(raw, opts) {
362
+ if (typeof raw !== "string") return void 0;
363
+ const trimmed = raw.trim();
364
+ if (!trimmed) return void 0;
365
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
366
+ console.warn(
367
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
368
+ );
369
+ }
370
+ return trimmed;
371
+ }
372
+ function projectIdHeaders(projectId) {
373
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
374
+ }
356
375
  var SHUTDOWN_DEADLINE_MS = 1e4;
357
376
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
358
377
  function mergePatches(target, source) {
@@ -387,6 +406,10 @@ var EventShipper = class {
387
406
  if (this.debug && this.localDebuggerUrl) {
388
407
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
389
408
  }
409
+ this.projectId = normalizeProjectId(opts.projectId, {
410
+ debug: this.debug,
411
+ prefix: this.prefix
412
+ });
390
413
  const isNode = typeof process !== "undefined" && typeof process.version === "string";
391
414
  this.context = {
392
415
  library: {
@@ -405,6 +428,9 @@ var EventShipper = class {
405
428
  authHeaders() {
406
429
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
407
430
  }
431
+ requestHeaders() {
432
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
433
+ }
408
434
  /**
409
435
  * Build the retry/timeout options for one POST, honoring the shutdown
410
436
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -534,7 +560,7 @@ var EventShipper = class {
534
560
  return;
535
561
  }
536
562
  try {
537
- await postJson(url, body, this.authHeaders(), opts);
563
+ await postJson(url, body, this.requestHeaders(), opts);
538
564
  } catch (err) {
539
565
  const msg = err instanceof Error ? err.message : String(err);
540
566
  rateLimitedLog(
@@ -570,7 +596,7 @@ var EventShipper = class {
570
596
  return;
571
597
  }
572
598
  try {
573
- await postJson(url, body, this.authHeaders(), opts);
599
+ await postJson(url, body, this.requestHeaders(), opts);
574
600
  } catch (err) {
575
601
  const msg = err instanceof Error ? err.message : String(err);
576
602
  rateLimitedLog(
@@ -666,7 +692,7 @@ var EventShipper = class {
666
692
  if (!isPending) this.sticky.delete(eventId);
667
693
  return;
668
694
  }
669
- const p = postJson(url, payload, this.authHeaders(), opts);
695
+ const p = postJson(url, payload, this.requestHeaders(), opts);
670
696
  this.inFlight.add(p);
671
697
  try {
672
698
  try {
@@ -813,6 +839,10 @@ var TraceShipper = class {
813
839
  if (this.debug && this.localDebuggerUrl) {
814
840
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
815
841
  }
842
+ this.projectId = normalizeProjectId(opts.projectId, {
843
+ debug: this.debug,
844
+ prefix: this.prefix
845
+ });
816
846
  this.transformSpanHook = opts.transformSpan;
817
847
  this.disableDefaultRedaction = opts.disableDefaultRedaction === true;
818
848
  this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
@@ -889,6 +919,9 @@ var TraceShipper = class {
889
919
  authHeaders() {
890
920
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
891
921
  }
922
+ requestHeaders() {
923
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
924
+ }
892
925
  startSpan(args) {
893
926
  var _a, _b;
894
927
  const ids = createSpanIds(args.parent);
@@ -1020,7 +1053,7 @@ var TraceShipper = class {
1020
1053
  endpoint: url
1021
1054
  });
1022
1055
  }
1023
- const p = postJson(url, body, this.authHeaders(), opts);
1056
+ const p = postJson(url, body, this.requestHeaders(), opts);
1024
1057
  this.inFlight.add(p);
1025
1058
  try {
1026
1059
  try {
@@ -1615,7 +1648,7 @@ function extractLLMMetadata(output) {
1615
1648
  // package.json
1616
1649
  var package_default = {
1617
1650
  name: "@raindrop-ai/langchain",
1618
- version: "0.0.4",
1651
+ version: "0.0.5",
1619
1652
  description: "Raindrop integration for LangChain",
1620
1653
  main: "dist/index.js",
1621
1654
  module: "dist/index.mjs",
@@ -1698,6 +1731,7 @@ function createRaindropLangChain(opts) {
1698
1731
  endpoint: opts.endpoint,
1699
1732
  enabled,
1700
1733
  debug: (_a = opts.debug) != null ? _a : false,
1734
+ projectId: opts.projectId,
1701
1735
  sdkName: "langchain",
1702
1736
  libraryName,
1703
1737
  libraryVersion
@@ -1707,6 +1741,7 @@ function createRaindropLangChain(opts) {
1707
1741
  endpoint: opts.endpoint,
1708
1742
  enabled,
1709
1743
  debug: (_b = opts.debug) != null ? _b : false,
1744
+ projectId: opts.projectId,
1710
1745
  sdkName: "langchain",
1711
1746
  serviceName: "raindrop.langchain",
1712
1747
  serviceVersion: libraryVersion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/langchain",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Raindrop integration for LangChain",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -36,7 +36,7 @@
36
36
  "tsup": "^8.4.0",
37
37
  "typescript": "^5.3.3",
38
38
  "vitest": "^2.1.9",
39
- "@raindrop-ai/core": "0.0.3"
39
+ "@raindrop-ai/core": "0.0.4"
40
40
  },
41
41
  "tsup": {
42
42
  "entry": [