@raindrop-ai/pi-agent 0.0.5 → 0.0.7

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,4 +1,4 @@
1
- // ../core/dist/chunk-U5HUTMR5.js
1
+ // ../core/dist/chunk-SK6EJEO7.js
2
2
  function getCrypto() {
3
3
  const c = globalThis.crypto;
4
4
  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 {
@@ -1093,18 +1126,13 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
1093
1126
  // package.json
1094
1127
  var package_default = {
1095
1128
  name: "@raindrop-ai/pi-agent",
1096
- version: "0.0.5",
1129
+ version: "0.0.7",
1097
1130
  description: "Raindrop observability for Pi Agent \u2014 automatic tracing via subscriber or pi-coding-agent extension",
1098
1131
  type: "module",
1099
1132
  license: "MIT",
1100
- repository: {
1101
- type: "git",
1102
- url: "git+https://github.com/raindrop-ai/raindrop-js.git",
1103
- directory: "packages/pi-agent"
1104
- },
1105
- homepage: "https://github.com/raindrop-ai/raindrop-js/tree/main/packages/pi-agent#readme",
1133
+ homepage: "https://www.raindrop.ai/docs/integrations/pi-agent/",
1106
1134
  bugs: {
1107
- url: "https://github.com/raindrop-ai/raindrop-js/issues"
1135
+ url: "https://www.raindrop.ai/docs/support/"
1108
1136
  },
1109
1137
  keywords: [
1110
1138
  "pi-package",
@@ -25,7 +25,7 @@ __export(extension_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(extension_exports);
27
27
 
28
- // ../core/dist/chunk-U5HUTMR5.js
28
+ // ../core/dist/chunk-SK6EJEO7.js
29
29
  function getCrypto() {
30
30
  const c = globalThis.crypto;
31
31
  return c;
@@ -369,6 +369,25 @@ function mirrorPartialEventToLocalDebugger(event, options = {}) {
369
369
  }).catch(() => {
370
370
  });
371
371
  }
372
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
373
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
374
+ function isValidProjectIdSlug(value) {
375
+ return PROJECT_ID_SLUG_PATTERN.test(value);
376
+ }
377
+ function normalizeProjectId(raw, opts) {
378
+ if (typeof raw !== "string") return void 0;
379
+ const trimmed = raw.trim();
380
+ if (!trimmed) return void 0;
381
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
382
+ console.warn(
383
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
384
+ );
385
+ }
386
+ return trimmed;
387
+ }
388
+ function projectIdHeaders(projectId) {
389
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
390
+ }
372
391
  var SHUTDOWN_DEADLINE_MS = 1e4;
373
392
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
374
393
  function mergePatches(target, source) {
@@ -403,6 +422,10 @@ var EventShipper = class {
403
422
  if (this.debug && this.localDebuggerUrl) {
404
423
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
405
424
  }
425
+ this.projectId = normalizeProjectId(opts.projectId, {
426
+ debug: this.debug,
427
+ prefix: this.prefix
428
+ });
406
429
  const isNode = typeof process !== "undefined" && typeof process.version === "string";
407
430
  this.context = {
408
431
  library: {
@@ -421,6 +444,9 @@ var EventShipper = class {
421
444
  authHeaders() {
422
445
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
423
446
  }
447
+ requestHeaders() {
448
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
449
+ }
424
450
  /**
425
451
  * Build the retry/timeout options for one POST, honoring the shutdown
426
452
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -550,7 +576,7 @@ var EventShipper = class {
550
576
  return;
551
577
  }
552
578
  try {
553
- await postJson(url, body, this.authHeaders(), opts);
579
+ await postJson(url, body, this.requestHeaders(), opts);
554
580
  } catch (err) {
555
581
  const msg = err instanceof Error ? err.message : String(err);
556
582
  rateLimitedLog(
@@ -586,7 +612,7 @@ var EventShipper = class {
586
612
  return;
587
613
  }
588
614
  try {
589
- await postJson(url, body, this.authHeaders(), opts);
615
+ await postJson(url, body, this.requestHeaders(), opts);
590
616
  } catch (err) {
591
617
  const msg = err instanceof Error ? err.message : String(err);
592
618
  rateLimitedLog(
@@ -682,7 +708,7 @@ var EventShipper = class {
682
708
  if (!isPending) this.sticky.delete(eventId);
683
709
  return;
684
710
  }
685
- const p = postJson(url, payload, this.authHeaders(), opts);
711
+ const p = postJson(url, payload, this.requestHeaders(), opts);
686
712
  this.inFlight.add(p);
687
713
  try {
688
714
  try {
@@ -829,6 +855,10 @@ var TraceShipper = class {
829
855
  if (this.debug && this.localDebuggerUrl) {
830
856
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
831
857
  }
858
+ this.projectId = normalizeProjectId(opts.projectId, {
859
+ debug: this.debug,
860
+ prefix: this.prefix
861
+ });
832
862
  this.transformSpanHook = opts.transformSpan;
833
863
  this.disableDefaultRedaction = opts.disableDefaultRedaction === true;
834
864
  this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
@@ -905,6 +935,9 @@ var TraceShipper = class {
905
935
  authHeaders() {
906
936
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
907
937
  }
938
+ requestHeaders() {
939
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
940
+ }
908
941
  startSpan(args) {
909
942
  var _a, _b;
910
943
  const ids = createSpanIds(args.parent);
@@ -1036,7 +1069,7 @@ var TraceShipper = class {
1036
1069
  endpoint: url
1037
1070
  });
1038
1071
  }
1039
- const p = postJson(url, body, this.authHeaders(), opts);
1072
+ const p = postJson(url, body, this.requestHeaders(), opts);
1040
1073
  this.inFlight.add(p);
1041
1074
  try {
1042
1075
  try {
@@ -1115,7 +1148,7 @@ function getPiAgentDirectory() {
1115
1148
  return (_a = process.env["PI_CODING_AGENT_DIR"]) != null ? _a : (0, import_node_path.join)((0, import_node_os.homedir)(), ".pi", "agent");
1116
1149
  }
1117
1150
  function loadConfig(projectDirectory) {
1118
- var _a, _b, _c, _d, _e, _f, _g;
1151
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1119
1152
  let merged = {};
1120
1153
  const configPaths = [
1121
1154
  (0, import_node_path.join)(getPiAgentDirectory(), "raindrop.json"),
@@ -1142,9 +1175,10 @@ function loadConfig(projectDirectory) {
1142
1175
  return {
1143
1176
  writeKey: (_b = (_a = process.env["RAINDROP_WRITE_KEY"]) != null ? _a : merged.write_key) != null ? _b : "",
1144
1177
  endpoint: (_d = (_c = process.env["RAINDROP_API_URL"]) != null ? _c : merged.api_url) != null ? _d : "https://api.raindrop.ai/v1",
1145
- eventName: (_e = merged.event_name) != null ? _e : "pi_session",
1146
- debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_f = merged.debug) != null ? _f : false,
1147
- captureSystemPrompt: process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] !== void 0 ? process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] === "true" : (_g = merged.capture_system_prompt) != null ? _g : false,
1178
+ projectId: (_e = process.env["RAINDROP_PROJECT_ID"]) != null ? _e : merged.project_id,
1179
+ eventName: (_f = merged.event_name) != null ? _f : "pi_session",
1180
+ debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_g = merged.debug) != null ? _g : false,
1181
+ captureSystemPrompt: process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] !== void 0 ? process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] === "true" : (_h = merged.capture_system_prompt) != null ? _h : false,
1148
1182
  eventMetadata,
1149
1183
  localWorkshopUrl: resolveLocalWorkshopUrl(merged.local_workshop_url)
1150
1184
  };
@@ -1163,18 +1197,13 @@ function resolveLocalWorkshopUrl(fileValue) {
1163
1197
  // package.json
1164
1198
  var package_default = {
1165
1199
  name: "@raindrop-ai/pi-agent",
1166
- version: "0.0.5",
1200
+ version: "0.0.7",
1167
1201
  description: "Raindrop observability for Pi Agent \u2014 automatic tracing via subscriber or pi-coding-agent extension",
1168
1202
  type: "module",
1169
1203
  license: "MIT",
1170
- repository: {
1171
- type: "git",
1172
- url: "git+https://github.com/raindrop-ai/raindrop-js.git",
1173
- directory: "packages/pi-agent"
1174
- },
1175
- homepage: "https://github.com/raindrop-ai/raindrop-js/tree/main/packages/pi-agent#readme",
1204
+ homepage: "https://www.raindrop.ai/docs/integrations/pi-agent/",
1176
1205
  bugs: {
1177
- url: "https://github.com/raindrop-ai/raindrop-js/issues"
1206
+ url: "https://www.raindrop.ai/docs/support/"
1178
1207
  },
1179
1208
  keywords: [
1180
1209
  "pi-package",
@@ -1820,12 +1849,14 @@ function extension(pi) {
1820
1849
  writeKey: config.writeKey,
1821
1850
  endpoint: config.endpoint,
1822
1851
  debug: config.debug,
1852
+ projectId: config.projectId,
1823
1853
  localDebuggerUrl: config.localWorkshopUrl
1824
1854
  });
1825
1855
  const traceShipper = new TraceShipper2({
1826
1856
  writeKey: config.writeKey,
1827
1857
  endpoint: config.endpoint,
1828
1858
  debug: config.debug,
1859
+ projectId: config.projectId,
1829
1860
  localDebuggerUrl: config.localWorkshopUrl
1830
1861
  });
1831
1862
  registerTracing(pi, config, eventShipper, traceShipper);
@@ -1,5 +1,5 @@
1
1
  import { ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
- import { E as EventShipper$1, T as TraceShipper$1, O as OtlpSpan } from './index.d-CRPiWjXE.cjs';
2
+ import { E as EventShipper$1, T as TraceShipper$1, O as OtlpSpan } from './index.d-D0J2tEXx.cjs';
3
3
 
4
4
  interface EventMetadata {
5
5
  userId?: string;
@@ -9,6 +9,13 @@ interface EventMetadata {
9
9
  interface RaindropExtensionConfig {
10
10
  writeKey: string;
11
11
  endpoint: string;
12
+ /**
13
+ * Optional Raindrop project slug. When set, every outbound cloud request
14
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
15
+ * resolves to `default` server-side; byte-identical to prior behavior).
16
+ * Sourced from `RAINDROP_PROJECT_ID` or the `project_id` config-file key.
17
+ */
18
+ projectId?: string;
12
19
  eventName: string;
13
20
  debug: boolean;
14
21
  captureSystemPrompt: boolean;
@@ -1,5 +1,5 @@
1
1
  import { ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
- import { E as EventShipper$1, T as TraceShipper$1, O as OtlpSpan } from './index.d-CRPiWjXE.js';
2
+ import { E as EventShipper$1, T as TraceShipper$1, O as OtlpSpan } from './index.d-D0J2tEXx.js';
3
3
 
4
4
  interface EventMetadata {
5
5
  userId?: string;
@@ -9,6 +9,13 @@ interface EventMetadata {
9
9
  interface RaindropExtensionConfig {
10
10
  writeKey: string;
11
11
  endpoint: string;
12
+ /**
13
+ * Optional Raindrop project slug. When set, every outbound cloud request
14
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
15
+ * resolves to `default` server-side; byte-identical to prior behavior).
16
+ * Sourced from `RAINDROP_PROJECT_ID` or the `project_id` config-file key.
17
+ */
18
+ projectId?: string;
12
19
  eventName: string;
13
20
  debug: boolean;
14
21
  captureSystemPrompt: boolean;
package/dist/extension.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  resolveLocalDebuggerBaseUrl,
15
15
  safeStringify,
16
16
  truncate
17
- } from "./chunk-2NGOEVWI.js";
17
+ } from "./chunk-GILK5ZDM.js";
18
18
 
19
19
  // src/internal/config.ts
20
20
  import { existsSync, readFileSync } from "fs";
@@ -25,7 +25,7 @@ function getPiAgentDirectory() {
25
25
  return (_a = process.env["PI_CODING_AGENT_DIR"]) != null ? _a : join(homedir(), ".pi", "agent");
26
26
  }
27
27
  function loadConfig(projectDirectory) {
28
- var _a, _b, _c, _d, _e, _f, _g;
28
+ var _a, _b, _c, _d, _e, _f, _g, _h;
29
29
  let merged = {};
30
30
  const configPaths = [
31
31
  join(getPiAgentDirectory(), "raindrop.json"),
@@ -52,9 +52,10 @@ function loadConfig(projectDirectory) {
52
52
  return {
53
53
  writeKey: (_b = (_a = process.env["RAINDROP_WRITE_KEY"]) != null ? _a : merged.write_key) != null ? _b : "",
54
54
  endpoint: (_d = (_c = process.env["RAINDROP_API_URL"]) != null ? _c : merged.api_url) != null ? _d : "https://api.raindrop.ai/v1",
55
- eventName: (_e = merged.event_name) != null ? _e : "pi_session",
56
- debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_f = merged.debug) != null ? _f : false,
57
- captureSystemPrompt: process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] !== void 0 ? process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] === "true" : (_g = merged.capture_system_prompt) != null ? _g : false,
55
+ projectId: (_e = process.env["RAINDROP_PROJECT_ID"]) != null ? _e : merged.project_id,
56
+ eventName: (_f = merged.event_name) != null ? _f : "pi_session",
57
+ debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_g = merged.debug) != null ? _g : false,
58
+ captureSystemPrompt: process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] !== void 0 ? process.env["RAINDROP_CAPTURE_SYSTEM_PROMPT"] === "true" : (_h = merged.capture_system_prompt) != null ? _h : false,
58
59
  eventMetadata,
59
60
  localWorkshopUrl: resolveLocalWorkshopUrl(merged.local_workshop_url)
60
61
  };
@@ -467,12 +468,14 @@ function extension(pi) {
467
468
  writeKey: config.writeKey,
468
469
  endpoint: config.endpoint,
469
470
  debug: config.debug,
471
+ projectId: config.projectId,
470
472
  localDebuggerUrl: config.localWorkshopUrl
471
473
  });
472
474
  const traceShipper = new TraceShipper({
473
475
  writeKey: config.writeKey,
474
476
  endpoint: config.endpoint,
475
477
  debug: config.debug,
478
+ projectId: config.projectId,
476
479
  localDebuggerUrl: config.localWorkshopUrl
477
480
  });
478
481
  registerTracing(pi, config, eventShipper, traceShipper);
package/dist/index.cjs CHANGED
@@ -24,7 +24,7 @@ __export(index_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(index_exports);
26
26
 
27
- // ../core/dist/chunk-U5HUTMR5.js
27
+ // ../core/dist/chunk-SK6EJEO7.js
28
28
  function getCrypto() {
29
29
  const c = globalThis.crypto;
30
30
  return c;
@@ -376,6 +376,25 @@ function mirrorPartialEventToLocalDebugger(event, options = {}) {
376
376
  }).catch(() => {
377
377
  });
378
378
  }
379
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
380
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
381
+ function isValidProjectIdSlug(value) {
382
+ return PROJECT_ID_SLUG_PATTERN.test(value);
383
+ }
384
+ function normalizeProjectId(raw, opts) {
385
+ if (typeof raw !== "string") return void 0;
386
+ const trimmed = raw.trim();
387
+ if (!trimmed) return void 0;
388
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
389
+ console.warn(
390
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
391
+ );
392
+ }
393
+ return trimmed;
394
+ }
395
+ function projectIdHeaders(projectId) {
396
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
397
+ }
379
398
  var SHUTDOWN_DEADLINE_MS = 1e4;
380
399
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
381
400
  function mergePatches(target, source) {
@@ -410,6 +429,10 @@ var EventShipper = class {
410
429
  if (this.debug && this.localDebuggerUrl) {
411
430
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
412
431
  }
432
+ this.projectId = normalizeProjectId(opts.projectId, {
433
+ debug: this.debug,
434
+ prefix: this.prefix
435
+ });
413
436
  const isNode = typeof process !== "undefined" && typeof process.version === "string";
414
437
  this.context = {
415
438
  library: {
@@ -428,6 +451,9 @@ var EventShipper = class {
428
451
  authHeaders() {
429
452
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
430
453
  }
454
+ requestHeaders() {
455
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
456
+ }
431
457
  /**
432
458
  * Build the retry/timeout options for one POST, honoring the shutdown
433
459
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -557,7 +583,7 @@ var EventShipper = class {
557
583
  return;
558
584
  }
559
585
  try {
560
- await postJson(url, body, this.authHeaders(), opts);
586
+ await postJson(url, body, this.requestHeaders(), opts);
561
587
  } catch (err) {
562
588
  const msg = err instanceof Error ? err.message : String(err);
563
589
  rateLimitedLog(
@@ -593,7 +619,7 @@ var EventShipper = class {
593
619
  return;
594
620
  }
595
621
  try {
596
- await postJson(url, body, this.authHeaders(), opts);
622
+ await postJson(url, body, this.requestHeaders(), opts);
597
623
  } catch (err) {
598
624
  const msg = err instanceof Error ? err.message : String(err);
599
625
  rateLimitedLog(
@@ -689,7 +715,7 @@ var EventShipper = class {
689
715
  if (!isPending) this.sticky.delete(eventId);
690
716
  return;
691
717
  }
692
- const p = postJson(url, payload, this.authHeaders(), opts);
718
+ const p = postJson(url, payload, this.requestHeaders(), opts);
693
719
  this.inFlight.add(p);
694
720
  try {
695
721
  try {
@@ -836,6 +862,10 @@ var TraceShipper = class {
836
862
  if (this.debug && this.localDebuggerUrl) {
837
863
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
838
864
  }
865
+ this.projectId = normalizeProjectId(opts.projectId, {
866
+ debug: this.debug,
867
+ prefix: this.prefix
868
+ });
839
869
  this.transformSpanHook = opts.transformSpan;
840
870
  this.disableDefaultRedaction = opts.disableDefaultRedaction === true;
841
871
  this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
@@ -912,6 +942,9 @@ var TraceShipper = class {
912
942
  authHeaders() {
913
943
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
914
944
  }
945
+ requestHeaders() {
946
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
947
+ }
915
948
  startSpan(args) {
916
949
  var _a, _b;
917
950
  const ids = createSpanIds(args.parent);
@@ -1043,7 +1076,7 @@ var TraceShipper = class {
1043
1076
  endpoint: url
1044
1077
  });
1045
1078
  }
1046
- const p = postJson(url, body, this.authHeaders(), opts);
1079
+ const p = postJson(url, body, this.requestHeaders(), opts);
1047
1080
  this.inFlight.add(p);
1048
1081
  try {
1049
1082
  try {
@@ -1116,18 +1149,13 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = import_async_hooks.AsyncLocalStorage;
1116
1149
  // package.json
1117
1150
  var package_default = {
1118
1151
  name: "@raindrop-ai/pi-agent",
1119
- version: "0.0.5",
1152
+ version: "0.0.7",
1120
1153
  description: "Raindrop observability for Pi Agent \u2014 automatic tracing via subscriber or pi-coding-agent extension",
1121
1154
  type: "module",
1122
1155
  license: "MIT",
1123
- repository: {
1124
- type: "git",
1125
- url: "git+https://github.com/raindrop-ai/raindrop-js.git",
1126
- directory: "packages/pi-agent"
1127
- },
1128
- homepage: "https://github.com/raindrop-ai/raindrop-js/tree/main/packages/pi-agent#readme",
1156
+ homepage: "https://www.raindrop.ai/docs/integrations/pi-agent/",
1129
1157
  bugs: {
1130
- url: "https://github.com/raindrop-ai/raindrop-js/issues"
1158
+ url: "https://www.raindrop.ai/docs/support/"
1131
1159
  },
1132
1160
  keywords: [
1133
1161
  "pi-package",
@@ -1796,6 +1824,7 @@ function createRaindropPiAgent(opts) {
1796
1824
  enabled: true,
1797
1825
  debug: ((_e = opts.events) == null ? void 0 : _e.debug) === true || envDebug,
1798
1826
  partialFlushMs: (_f = opts.events) == null ? void 0 : _f.partialFlushMs,
1827
+ projectId: opts.projectId,
1799
1828
  localDebuggerUrl: opts.localWorkshopUrl
1800
1829
  }) : null;
1801
1830
  const traceShipper = tracesEnabled && (hasWriteKey || opts.endpoint || hasLocalDestination) ? new TraceShipper2({
@@ -1807,6 +1836,7 @@ function createRaindropPiAgent(opts) {
1807
1836
  flushIntervalMs: (_i = opts.traces) == null ? void 0 : _i.flushIntervalMs,
1808
1837
  maxBatchSize: (_j = opts.traces) == null ? void 0 : _j.maxBatchSize,
1809
1838
  maxQueueSize: (_k = opts.traces) == null ? void 0 : _k.maxQueueSize,
1839
+ projectId: opts.projectId,
1810
1840
  localDebuggerUrl: opts.localWorkshopUrl
1811
1841
  }) : null;
1812
1842
  const defaultOptions = {
@@ -83,6 +83,13 @@ type EventShipperOptions = {
83
83
  * Pass `null` to opt out of all mirroring (including auto-detect).
84
84
  */
85
85
  localDebuggerUrl?: string | null;
86
+ /**
87
+ * Optional project slug. When set, every outbound cloud request includes an
88
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
89
+ * values are ignored. Slug format is validated on construction but never
90
+ * throws — the backend returns 400 on invalid values.
91
+ */
92
+ projectId?: string;
86
93
  /**
87
94
  * Per-field character cap applied to event input/output BEFORE buffering
88
95
  * or serialization, so oversized payloads cost the cap — not the payload —
@@ -101,6 +108,7 @@ declare class EventShipper {
101
108
  private sdkName;
102
109
  private prefix;
103
110
  private defaultEventName;
111
+ private projectId;
104
112
  private context;
105
113
  private buffers;
106
114
  private sticky;
@@ -124,6 +132,7 @@ declare class EventShipper {
124
132
  constructor(opts: EventShipperOptions);
125
133
  isDebugEnabled(): boolean;
126
134
  private authHeaders;
135
+ private requestHeaders;
127
136
  /**
128
137
  * Build the retry/timeout options for one POST, honoring the shutdown
129
138
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -195,6 +204,13 @@ type TraceShipperOptions = {
195
204
  * Pass `null` to opt out of all mirroring (including auto-detect).
196
205
  */
197
206
  localDebuggerUrl?: string | null;
207
+ /**
208
+ * Optional project slug. When set, every OTLP trace export includes an
209
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
210
+ * values are ignored. Slug format is validated on construction but never
211
+ * throws — the backend returns 400 on invalid values.
212
+ */
213
+ projectId?: string;
198
214
  /**
199
215
  * Per-span hook that fires for every OTLP span right before the span is
200
216
  * shipped (both to the Raindrop API and to a local debugger). Lets callers
@@ -252,6 +268,7 @@ declare class TraceShipper {
252
268
  private flushIntervalMs;
253
269
  private maxBatchSize;
254
270
  private maxQueueSize;
271
+ private projectId;
255
272
  private queue;
256
273
  private timer;
257
274
  private inFlight;
@@ -302,6 +319,7 @@ declare class TraceShipper {
302
319
  private redactSpan;
303
320
  isDebugEnabled(): boolean;
304
321
  private authHeaders;
322
+ private requestHeaders;
305
323
  startSpan(args: {
306
324
  name: string;
307
325
  parent?: {
@@ -83,6 +83,13 @@ type EventShipperOptions = {
83
83
  * Pass `null` to opt out of all mirroring (including auto-detect).
84
84
  */
85
85
  localDebuggerUrl?: string | null;
86
+ /**
87
+ * Optional project slug. When set, every outbound cloud request includes an
88
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
89
+ * values are ignored. Slug format is validated on construction but never
90
+ * throws — the backend returns 400 on invalid values.
91
+ */
92
+ projectId?: string;
86
93
  /**
87
94
  * Per-field character cap applied to event input/output BEFORE buffering
88
95
  * or serialization, so oversized payloads cost the cap — not the payload —
@@ -101,6 +108,7 @@ declare class EventShipper {
101
108
  private sdkName;
102
109
  private prefix;
103
110
  private defaultEventName;
111
+ private projectId;
104
112
  private context;
105
113
  private buffers;
106
114
  private sticky;
@@ -124,6 +132,7 @@ declare class EventShipper {
124
132
  constructor(opts: EventShipperOptions);
125
133
  isDebugEnabled(): boolean;
126
134
  private authHeaders;
135
+ private requestHeaders;
127
136
  /**
128
137
  * Build the retry/timeout options for one POST, honoring the shutdown
129
138
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -195,6 +204,13 @@ type TraceShipperOptions = {
195
204
  * Pass `null` to opt out of all mirroring (including auto-detect).
196
205
  */
197
206
  localDebuggerUrl?: string | null;
207
+ /**
208
+ * Optional project slug. When set, every OTLP trace export includes an
209
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
210
+ * values are ignored. Slug format is validated on construction but never
211
+ * throws — the backend returns 400 on invalid values.
212
+ */
213
+ projectId?: string;
198
214
  /**
199
215
  * Per-span hook that fires for every OTLP span right before the span is
200
216
  * shipped (both to the Raindrop API and to a local debugger). Lets callers
@@ -252,6 +268,7 @@ declare class TraceShipper {
252
268
  private flushIntervalMs;
253
269
  private maxBatchSize;
254
270
  private maxQueueSize;
271
+ private projectId;
255
272
  private queue;
256
273
  private timer;
257
274
  private inFlight;
@@ -302,6 +319,7 @@ declare class TraceShipper {
302
319
  private redactSpan;
303
320
  isDebugEnabled(): boolean;
304
321
  private authHeaders;
322
+ private requestHeaders;
305
323
  startSpan(args: {
306
324
  name: string;
307
325
  parent?: {
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Agent } from '@earendil-works/pi-agent-core';
2
- import { A as Attachment } from './index.d-CRPiWjXE.cjs';
2
+ import { A as Attachment } from './index.d-D0J2tEXx.cjs';
3
3
 
4
4
  /**
5
5
  * Options for the Raindrop Pi Agent client.
@@ -12,6 +12,12 @@ interface RaindropPiAgentOptions {
12
12
  writeKey?: string;
13
13
  /** API endpoint URL (defaults to production) */
14
14
  endpoint?: string;
15
+ /**
16
+ * Optional Raindrop project slug. When set, every outbound cloud request
17
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
18
+ * resolves to `default` server-side; byte-identical to prior behavior).
19
+ */
20
+ projectId?: string;
15
21
  /** Default user ID for all events */
16
22
  userId?: string;
17
23
  /** Default conversation ID to group related events */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Agent } from '@earendil-works/pi-agent-core';
2
- import { A as Attachment } from './index.d-CRPiWjXE.js';
2
+ import { A as Attachment } from './index.d-D0J2tEXx.js';
3
3
 
4
4
  /**
5
5
  * Options for the Raindrop Pi Agent client.
@@ -12,6 +12,12 @@ interface RaindropPiAgentOptions {
12
12
  writeKey?: string;
13
13
  /** API endpoint URL (defaults to production) */
14
14
  endpoint?: string;
15
+ /**
16
+ * Optional Raindrop project slug. When set, every outbound cloud request
17
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
18
+ * resolves to `default` server-side; byte-identical to prior behavior).
19
+ */
20
+ projectId?: string;
15
21
  /** Default user ID for all events */
16
22
  userId?: string;
17
23
  /** Default conversation ID to group related events */
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  resolveLocalDebuggerBaseUrl,
18
18
  safeStringify,
19
19
  truncate
20
- } from "./chunk-2NGOEVWI.js";
20
+ } from "./chunk-GILK5ZDM.js";
21
21
 
22
22
  // src/internal/subscriber.ts
23
23
  function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, options, debug) {
@@ -396,6 +396,7 @@ function createRaindropPiAgent(opts) {
396
396
  enabled: true,
397
397
  debug: ((_e = opts.events) == null ? void 0 : _e.debug) === true || envDebug,
398
398
  partialFlushMs: (_f = opts.events) == null ? void 0 : _f.partialFlushMs,
399
+ projectId: opts.projectId,
399
400
  localDebuggerUrl: opts.localWorkshopUrl
400
401
  }) : null;
401
402
  const traceShipper = tracesEnabled && (hasWriteKey || opts.endpoint || hasLocalDestination) ? new TraceShipper({
@@ -407,6 +408,7 @@ function createRaindropPiAgent(opts) {
407
408
  flushIntervalMs: (_i = opts.traces) == null ? void 0 : _i.flushIntervalMs,
408
409
  maxBatchSize: (_j = opts.traces) == null ? void 0 : _j.maxBatchSize,
409
410
  maxQueueSize: (_k = opts.traces) == null ? void 0 : _k.maxQueueSize,
411
+ projectId: opts.projectId,
410
412
  localDebuggerUrl: opts.localWorkshopUrl
411
413
  }) : null;
412
414
  const defaultOptions = {
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "@raindrop-ai/pi-agent",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Raindrop observability for Pi Agent — automatic tracing via subscriber or pi-coding-agent extension",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/raindrop-ai/raindrop-js.git",
10
- "directory": "packages/pi-agent"
11
- },
12
- "homepage": "https://github.com/raindrop-ai/raindrop-js/tree/main/packages/pi-agent#readme",
7
+ "homepage": "https://www.raindrop.ai/docs/integrations/pi-agent/",
13
8
  "bugs": {
14
- "url": "https://github.com/raindrop-ai/raindrop-js/issues"
9
+ "url": "https://www.raindrop.ai/docs/support/"
15
10
  },
16
11
  "keywords": [
17
12
  "pi-package",
@@ -59,7 +54,7 @@
59
54
  "tsup": "^8.5.1",
60
55
  "typescript": "^5.7.3",
61
56
  "vitest": "^2.1.9",
62
- "@raindrop-ai/core": "0.0.3"
57
+ "@raindrop-ai/core": "0.0.4"
63
58
  },
64
59
  "tsup": {
65
60
  "entry": [