@raindrop-ai/pi-agent 0.0.2 → 0.0.3
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/{chunk-LZIGXU2D.js → chunk-MHIMKMK7.js} +211 -126
- package/dist/extension.cjs +276 -173
- package/dist/extension.d.cts +11 -1
- package/dist/extension.d.ts +11 -1
- package/dist/extension.js +27 -7
- package/dist/index.cjs +122 -34
- package/dist/{index.d-npTVS9Mf.d.cts → index.d-CtwaEReY.d.cts} +13 -1
- package/dist/{index.d-npTVS9Mf.d.ts → index.d-CtwaEReY.d.ts} +13 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +11 -6
- package/package.json +11 -11
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-
|
|
27
|
+
// ../core/dist/chunk-OLYXZCOK.js
|
|
28
28
|
function getCrypto() {
|
|
29
29
|
const c = globalThis.crypto;
|
|
30
30
|
return c;
|
|
@@ -225,6 +225,91 @@ function buildExportTraceServiceRequest(spans, serviceName = "raindrop.core", se
|
|
|
225
225
|
]
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
+
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
229
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
230
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
231
|
+
function readEnvVar(name) {
|
|
232
|
+
var _a;
|
|
233
|
+
try {
|
|
234
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
235
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
236
|
+
return env[name];
|
|
237
|
+
}
|
|
238
|
+
} catch (e) {
|
|
239
|
+
}
|
|
240
|
+
return void 0;
|
|
241
|
+
}
|
|
242
|
+
function readWorkshopEnv() {
|
|
243
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
244
|
+
if (raw === void 0) return void 0;
|
|
245
|
+
const trimmed = raw.trim();
|
|
246
|
+
if (trimmed.length === 0) return void 0;
|
|
247
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
248
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
249
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
250
|
+
return void 0;
|
|
251
|
+
}
|
|
252
|
+
function isLocalDevHost(hostname2) {
|
|
253
|
+
if (!hostname2) return false;
|
|
254
|
+
if (hostname2 === "localhost" || hostname2 === "127.0.0.1" || hostname2 === "0.0.0.0" || hostname2 === "::1") {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
if (hostname2.endsWith(".localhost")) return true;
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
function readRuntimeHostname() {
|
|
261
|
+
try {
|
|
262
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
263
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
264
|
+
return loc.hostname;
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
}
|
|
268
|
+
return void 0;
|
|
269
|
+
}
|
|
270
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
271
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
272
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
276
|
+
var _a, _b, _c;
|
|
277
|
+
if (baseUrl === null) return null;
|
|
278
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
279
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
280
|
+
}
|
|
281
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
282
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
283
|
+
const workshopEnv = readWorkshopEnv();
|
|
284
|
+
if (workshopEnv === "disable") return null;
|
|
285
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
286
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
287
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
function mirrorTraceExportToLocalDebugger(body, options = {}) {
|
|
291
|
+
var _a;
|
|
292
|
+
const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
|
|
293
|
+
if (!baseUrl) return;
|
|
294
|
+
void postJson(`${baseUrl}traces`, body, {}, {
|
|
295
|
+
maxAttempts: 1,
|
|
296
|
+
debug: (_a = options.debug) != null ? _a : false,
|
|
297
|
+
sdkName: options.sdkName
|
|
298
|
+
}).catch(() => {
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function mirrorPartialEventToLocalDebugger(event, options = {}) {
|
|
302
|
+
var _a;
|
|
303
|
+
const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
|
|
304
|
+
if (!baseUrl) return;
|
|
305
|
+
const headers = options.writeKey ? { Authorization: `Bearer ${options.writeKey}` } : {};
|
|
306
|
+
void postJson(`${baseUrl}events/track_partial`, event, headers, {
|
|
307
|
+
maxAttempts: 1,
|
|
308
|
+
debug: (_a = options.debug) != null ? _a : false,
|
|
309
|
+
sdkName: options.sdkName
|
|
310
|
+
}).catch(() => {
|
|
311
|
+
});
|
|
312
|
+
}
|
|
228
313
|
function mergePatches(target, source) {
|
|
229
314
|
var _a, _b, _c, _d;
|
|
230
315
|
const out = { ...target, ...source };
|
|
@@ -242,7 +327,7 @@ var EventShipper = class {
|
|
|
242
327
|
this.sticky = /* @__PURE__ */ new Map();
|
|
243
328
|
this.timers = /* @__PURE__ */ new Map();
|
|
244
329
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
245
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
330
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
246
331
|
this.writeKey = (_a = opts.writeKey) == null ? void 0 : _a.trim();
|
|
247
332
|
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
248
333
|
this.enabled = opts.enabled !== false;
|
|
@@ -251,11 +336,15 @@ var EventShipper = class {
|
|
|
251
336
|
this.sdkName = (_d = opts.sdkName) != null ? _d : "core";
|
|
252
337
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
253
338
|
this.defaultEventName = (_e = opts.defaultEventName) != null ? _e : "ai_generation";
|
|
339
|
+
this.localDebuggerUrl = (_f = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _f : void 0;
|
|
340
|
+
if (this.debug && this.localDebuggerUrl) {
|
|
341
|
+
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
342
|
+
}
|
|
254
343
|
const isNode = typeof process !== "undefined" && typeof process.version === "string";
|
|
255
344
|
this.context = {
|
|
256
345
|
library: {
|
|
257
|
-
name: (
|
|
258
|
-
version: (
|
|
346
|
+
name: (_g = opts.libraryName) != null ? _g : "@raindrop-ai/core",
|
|
347
|
+
version: (_h = opts.libraryVersion) != null ? _h : "0.0.0"
|
|
259
348
|
},
|
|
260
349
|
metadata: {
|
|
261
350
|
jsRuntime: isNode ? "node" : "web",
|
|
@@ -341,6 +430,7 @@ var EventShipper = class {
|
|
|
341
430
|
}
|
|
342
431
|
}
|
|
343
432
|
];
|
|
433
|
+
if (!this.writeKey) return;
|
|
344
434
|
const url = `${this.baseUrl}signals/track`;
|
|
345
435
|
try {
|
|
346
436
|
await postJson(url, body, this.authHeaders(), {
|
|
@@ -371,6 +461,7 @@ var EventShipper = class {
|
|
|
371
461
|
traits: (_a = user.traits) != null ? _a : {}
|
|
372
462
|
};
|
|
373
463
|
});
|
|
464
|
+
if (!this.writeKey) return;
|
|
374
465
|
if (body.length === 0) return;
|
|
375
466
|
const url = `${this.baseUrl}users/identify`;
|
|
376
467
|
try {
|
|
@@ -447,6 +538,18 @@ var EventShipper = class {
|
|
|
447
538
|
endpoint: url
|
|
448
539
|
});
|
|
449
540
|
}
|
|
541
|
+
if (this.localDebuggerUrl) {
|
|
542
|
+
mirrorPartialEventToLocalDebugger(payload, {
|
|
543
|
+
baseUrl: this.localDebuggerUrl,
|
|
544
|
+
writeKey: this.writeKey,
|
|
545
|
+
debug: this.debug,
|
|
546
|
+
sdkName: this.sdkName
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
if (!this.writeKey) {
|
|
550
|
+
if (!isPending) this.sticky.delete(eventId);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
450
553
|
const p = postJson(url, payload, this.authHeaders(), {
|
|
451
554
|
maxAttempts: 3,
|
|
452
555
|
debug: this.debug,
|
|
@@ -471,28 +574,11 @@ var EventShipper = class {
|
|
|
471
574
|
}
|
|
472
575
|
}
|
|
473
576
|
};
|
|
474
|
-
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
475
|
-
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
476
|
-
var _a, _b, _c;
|
|
477
|
-
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;
|
|
478
|
-
return resolved ? (_c = formatEndpoint(resolved)) != null ? _c : null : null;
|
|
479
|
-
}
|
|
480
|
-
function mirrorTraceExportToLocalDebugger(body, options = {}) {
|
|
481
|
-
var _a;
|
|
482
|
-
const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
|
|
483
|
-
if (!baseUrl) return;
|
|
484
|
-
void postJson(`${baseUrl}traces`, body, {}, {
|
|
485
|
-
maxAttempts: 1,
|
|
486
|
-
debug: (_a = options.debug) != null ? _a : false,
|
|
487
|
-
sdkName: options.sdkName
|
|
488
|
-
}).catch(() => {
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
577
|
var TraceShipper = class {
|
|
492
578
|
constructor(opts) {
|
|
493
579
|
this.queue = [];
|
|
494
580
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
495
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
581
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
496
582
|
this.writeKey = (_a = opts.writeKey) == null ? void 0 : _a.trim();
|
|
497
583
|
this.baseUrl = (_b = formatEndpoint(opts.endpoint)) != null ? _b : "https://api.raindrop.ai/v1/";
|
|
498
584
|
this.enabled = opts.enabled !== false;
|
|
@@ -505,12 +591,9 @@ var TraceShipper = class {
|
|
|
505
591
|
this.prefix = `[raindrop-ai/${this.sdkName}]`;
|
|
506
592
|
this.serviceName = (_g = opts.serviceName) != null ? _g : "raindrop.core";
|
|
507
593
|
this.serviceVersion = (_h = opts.serviceVersion) != null ? _h : "0.0.0";
|
|
508
|
-
|
|
509
|
-
if (
|
|
510
|
-
this.
|
|
511
|
-
if (this.debug) {
|
|
512
|
-
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
513
|
-
}
|
|
594
|
+
this.localDebuggerUrl = (_i = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl)) != null ? _i : void 0;
|
|
595
|
+
if (this.debug && this.localDebuggerUrl) {
|
|
596
|
+
console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
|
|
514
597
|
}
|
|
515
598
|
}
|
|
516
599
|
isDebugEnabled() {
|
|
@@ -638,6 +721,7 @@ var TraceShipper = class {
|
|
|
638
721
|
}
|
|
639
722
|
while (this.queue.length > 0) {
|
|
640
723
|
const batch = this.queue.splice(0, this.maxBatchSize);
|
|
724
|
+
if (!this.writeKey) continue;
|
|
641
725
|
const body = buildExportTraceServiceRequest(batch, this.serviceName, this.serviceVersion);
|
|
642
726
|
const url = `${this.baseUrl}traces`;
|
|
643
727
|
if (this.debug) {
|
|
@@ -683,7 +767,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = import_async_hooks.AsyncLocalStorage;
|
|
|
683
767
|
// package.json
|
|
684
768
|
var package_default = {
|
|
685
769
|
name: "@raindrop-ai/pi-agent",
|
|
686
|
-
version: "0.0.
|
|
770
|
+
version: "0.0.3",
|
|
687
771
|
description: "Raindrop observability for Pi Agent \u2014 automatic tracing via subscriber or pi-coding-agent extension",
|
|
688
772
|
type: "module",
|
|
689
773
|
license: "MIT",
|
|
@@ -1282,23 +1366,26 @@ function envDebugEnabled() {
|
|
|
1282
1366
|
function createRaindropPiAgent(opts) {
|
|
1283
1367
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1284
1368
|
const hasWriteKey = typeof opts.writeKey === "string" && opts.writeKey.trim().length > 0;
|
|
1369
|
+
const resolvedLocalUrl = resolveLocalDebuggerBaseUrl(opts.localWorkshopUrl);
|
|
1370
|
+
const hasLocalDestination = resolvedLocalUrl !== null;
|
|
1285
1371
|
const eventsEnabled = ((_a = opts.events) == null ? void 0 : _a.enabled) !== false;
|
|
1286
1372
|
const tracesEnabled = ((_b = opts.traces) == null ? void 0 : _b.enabled) !== false;
|
|
1287
|
-
if (!hasWriteKey && !opts.endpoint) {
|
|
1373
|
+
if (!hasWriteKey && !opts.endpoint && !hasLocalDestination) {
|
|
1288
1374
|
console.warn(
|
|
1289
1375
|
"[raindrop-ai/pi-agent] writeKey not provided; telemetry shipping is disabled"
|
|
1290
1376
|
);
|
|
1291
1377
|
}
|
|
1292
1378
|
const envDebug = envDebugEnabled();
|
|
1293
1379
|
const debug = ((_c = opts.events) == null ? void 0 : _c.debug) === true || ((_d = opts.traces) == null ? void 0 : _d.debug) === true || envDebug;
|
|
1294
|
-
const eventShipper = eventsEnabled && (hasWriteKey || opts.endpoint) ? new EventShipper2({
|
|
1380
|
+
const eventShipper = eventsEnabled && (hasWriteKey || opts.endpoint || hasLocalDestination) ? new EventShipper2({
|
|
1295
1381
|
writeKey: opts.writeKey,
|
|
1296
1382
|
endpoint: opts.endpoint,
|
|
1297
1383
|
enabled: true,
|
|
1298
1384
|
debug: ((_e = opts.events) == null ? void 0 : _e.debug) === true || envDebug,
|
|
1299
|
-
partialFlushMs: (_f = opts.events) == null ? void 0 : _f.partialFlushMs
|
|
1385
|
+
partialFlushMs: (_f = opts.events) == null ? void 0 : _f.partialFlushMs,
|
|
1386
|
+
localDebuggerUrl: opts.localWorkshopUrl
|
|
1300
1387
|
}) : null;
|
|
1301
|
-
const traceShipper = tracesEnabled && (hasWriteKey || opts.endpoint) ? new TraceShipper2({
|
|
1388
|
+
const traceShipper = tracesEnabled && (hasWriteKey || opts.endpoint || hasLocalDestination) ? new TraceShipper2({
|
|
1302
1389
|
writeKey: opts.writeKey,
|
|
1303
1390
|
endpoint: opts.endpoint,
|
|
1304
1391
|
enabled: true,
|
|
@@ -1306,7 +1393,8 @@ function createRaindropPiAgent(opts) {
|
|
|
1306
1393
|
debugSpans: ((_h = opts.traces) == null ? void 0 : _h.debugSpans) === true || envDebug,
|
|
1307
1394
|
flushIntervalMs: (_i = opts.traces) == null ? void 0 : _i.flushIntervalMs,
|
|
1308
1395
|
maxBatchSize: (_j = opts.traces) == null ? void 0 : _j.maxBatchSize,
|
|
1309
|
-
maxQueueSize: (_k = opts.traces) == null ? void 0 : _k.maxQueueSize
|
|
1396
|
+
maxQueueSize: (_k = opts.traces) == null ? void 0 : _k.maxQueueSize,
|
|
1397
|
+
localDebuggerUrl: opts.localWorkshopUrl
|
|
1310
1398
|
}) : null;
|
|
1311
1399
|
const defaultOptions = {
|
|
1312
1400
|
userId: opts.userId,
|
|
@@ -79,6 +79,11 @@ type EventShipperOptions = {
|
|
|
79
79
|
libraryName?: string;
|
|
80
80
|
libraryVersion?: string;
|
|
81
81
|
defaultEventName?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
84
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
85
|
+
*/
|
|
86
|
+
localDebuggerUrl?: string | null;
|
|
82
87
|
};
|
|
83
88
|
declare class EventShipper {
|
|
84
89
|
private baseUrl;
|
|
@@ -94,6 +99,8 @@ declare class EventShipper {
|
|
|
94
99
|
private sticky;
|
|
95
100
|
private timers;
|
|
96
101
|
private inFlight;
|
|
102
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
103
|
+
private localDebuggerUrl;
|
|
97
104
|
constructor(opts: EventShipperOptions);
|
|
98
105
|
isDebugEnabled(): boolean;
|
|
99
106
|
private authHeaders;
|
|
@@ -130,6 +137,11 @@ type TraceShipperOptions = {
|
|
|
130
137
|
sdkName?: string;
|
|
131
138
|
serviceName?: string;
|
|
132
139
|
serviceVersion?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
142
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
143
|
+
*/
|
|
144
|
+
localDebuggerUrl?: string | null;
|
|
133
145
|
};
|
|
134
146
|
declare class TraceShipper {
|
|
135
147
|
private baseUrl;
|
|
@@ -147,7 +159,7 @@ declare class TraceShipper {
|
|
|
147
159
|
private queue;
|
|
148
160
|
private timer;
|
|
149
161
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
162
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
163
|
private localDebuggerUrl;
|
|
152
164
|
constructor(opts: TraceShipperOptions);
|
|
153
165
|
isDebugEnabled(): boolean;
|
|
@@ -79,6 +79,11 @@ type EventShipperOptions = {
|
|
|
79
79
|
libraryName?: string;
|
|
80
80
|
libraryVersion?: string;
|
|
81
81
|
defaultEventName?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
84
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
85
|
+
*/
|
|
86
|
+
localDebuggerUrl?: string | null;
|
|
82
87
|
};
|
|
83
88
|
declare class EventShipper {
|
|
84
89
|
private baseUrl;
|
|
@@ -94,6 +99,8 @@ declare class EventShipper {
|
|
|
94
99
|
private sticky;
|
|
95
100
|
private timers;
|
|
96
101
|
private inFlight;
|
|
102
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
103
|
+
private localDebuggerUrl;
|
|
97
104
|
constructor(opts: EventShipperOptions);
|
|
98
105
|
isDebugEnabled(): boolean;
|
|
99
106
|
private authHeaders;
|
|
@@ -130,6 +137,11 @@ type TraceShipperOptions = {
|
|
|
130
137
|
sdkName?: string;
|
|
131
138
|
serviceName?: string;
|
|
132
139
|
serviceVersion?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
142
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
143
|
+
*/
|
|
144
|
+
localDebuggerUrl?: string | null;
|
|
133
145
|
};
|
|
134
146
|
declare class TraceShipper {
|
|
135
147
|
private baseUrl;
|
|
@@ -147,7 +159,7 @@ declare class TraceShipper {
|
|
|
147
159
|
private queue;
|
|
148
160
|
private timer;
|
|
149
161
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
162
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
163
|
private localDebuggerUrl;
|
|
152
164
|
constructor(opts: TraceShipperOptions);
|
|
153
165
|
isDebugEnabled(): boolean;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent } from '@mariozechner/pi-agent-core';
|
|
2
|
-
import { A as Attachment } from './index.d-
|
|
2
|
+
import { A as Attachment } from './index.d-CtwaEReY.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for the Raindrop Pi Agent client.
|
|
@@ -20,6 +20,14 @@ interface RaindropPiAgentOptions {
|
|
|
20
20
|
eventName?: string;
|
|
21
21
|
/** Default properties attached to every event */
|
|
22
22
|
properties?: Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Explicit Workshop / local debugger URL forwarded to both shippers as
|
|
25
|
+
* their `localDebuggerUrl`. `null` opts out (overrides
|
|
26
|
+
* `RAINDROP_LOCAL_DEBUGGER` / `RAINDROP_WORKSHOP` env vars and
|
|
27
|
+
* auto-detect). `undefined` falls through to the env / auto-detect
|
|
28
|
+
* resolution in `@raindrop-ai/core`.
|
|
29
|
+
*/
|
|
30
|
+
localWorkshopUrl?: string | null;
|
|
23
31
|
/** Trace shipping configuration */
|
|
24
32
|
traces?: {
|
|
25
33
|
/** Enable trace shipping (default: true) */
|
|
@@ -121,7 +129,7 @@ interface RaindropPiAgentClient {
|
|
|
121
129
|
* import { createRaindropPiAgent } from "@raindrop-ai/pi-agent";
|
|
122
130
|
*
|
|
123
131
|
* const raindrop = createRaindropPiAgent({
|
|
124
|
-
* writeKey: "
|
|
132
|
+
* writeKey: "your-write-key",
|
|
125
133
|
* userId: "user-123",
|
|
126
134
|
* convoId: "session-abc",
|
|
127
135
|
* });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent } from '@mariozechner/pi-agent-core';
|
|
2
|
-
import { A as Attachment } from './index.d-
|
|
2
|
+
import { A as Attachment } from './index.d-CtwaEReY.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for the Raindrop Pi Agent client.
|
|
@@ -20,6 +20,14 @@ interface RaindropPiAgentOptions {
|
|
|
20
20
|
eventName?: string;
|
|
21
21
|
/** Default properties attached to every event */
|
|
22
22
|
properties?: Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Explicit Workshop / local debugger URL forwarded to both shippers as
|
|
25
|
+
* their `localDebuggerUrl`. `null` opts out (overrides
|
|
26
|
+
* `RAINDROP_LOCAL_DEBUGGER` / `RAINDROP_WORKSHOP` env vars and
|
|
27
|
+
* auto-detect). `undefined` falls through to the env / auto-detect
|
|
28
|
+
* resolution in `@raindrop-ai/core`.
|
|
29
|
+
*/
|
|
30
|
+
localWorkshopUrl?: string | null;
|
|
23
31
|
/** Trace shipping configuration */
|
|
24
32
|
traces?: {
|
|
25
33
|
/** Enable trace shipping (default: true) */
|
|
@@ -121,7 +129,7 @@ interface RaindropPiAgentClient {
|
|
|
121
129
|
* import { createRaindropPiAgent } from "@raindrop-ai/pi-agent";
|
|
122
130
|
*
|
|
123
131
|
* const raindrop = createRaindropPiAgent({
|
|
124
|
-
* writeKey: "
|
|
132
|
+
* writeKey: "your-write-key",
|
|
125
133
|
* userId: "user-123",
|
|
126
134
|
* convoId: "session-abc",
|
|
127
135
|
* });
|
package/dist/index.js
CHANGED
|
@@ -13,9 +13,10 @@ import {
|
|
|
13
13
|
getUsername,
|
|
14
14
|
libraryVersion,
|
|
15
15
|
randomUUID,
|
|
16
|
+
resolveLocalDebuggerBaseUrl,
|
|
16
17
|
safeStringify,
|
|
17
18
|
truncate
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-MHIMKMK7.js";
|
|
19
20
|
|
|
20
21
|
// src/internal/subscriber.ts
|
|
21
22
|
function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, options, debug) {
|
|
@@ -376,23 +377,26 @@ function envDebugEnabled() {
|
|
|
376
377
|
function createRaindropPiAgent(opts) {
|
|
377
378
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
378
379
|
const hasWriteKey = typeof opts.writeKey === "string" && opts.writeKey.trim().length > 0;
|
|
380
|
+
const resolvedLocalUrl = resolveLocalDebuggerBaseUrl(opts.localWorkshopUrl);
|
|
381
|
+
const hasLocalDestination = resolvedLocalUrl !== null;
|
|
379
382
|
const eventsEnabled = ((_a = opts.events) == null ? void 0 : _a.enabled) !== false;
|
|
380
383
|
const tracesEnabled = ((_b = opts.traces) == null ? void 0 : _b.enabled) !== false;
|
|
381
|
-
if (!hasWriteKey && !opts.endpoint) {
|
|
384
|
+
if (!hasWriteKey && !opts.endpoint && !hasLocalDestination) {
|
|
382
385
|
console.warn(
|
|
383
386
|
"[raindrop-ai/pi-agent] writeKey not provided; telemetry shipping is disabled"
|
|
384
387
|
);
|
|
385
388
|
}
|
|
386
389
|
const envDebug = envDebugEnabled();
|
|
387
390
|
const debug = ((_c = opts.events) == null ? void 0 : _c.debug) === true || ((_d = opts.traces) == null ? void 0 : _d.debug) === true || envDebug;
|
|
388
|
-
const eventShipper = eventsEnabled && (hasWriteKey || opts.endpoint) ? new EventShipper({
|
|
391
|
+
const eventShipper = eventsEnabled && (hasWriteKey || opts.endpoint || hasLocalDestination) ? new EventShipper({
|
|
389
392
|
writeKey: opts.writeKey,
|
|
390
393
|
endpoint: opts.endpoint,
|
|
391
394
|
enabled: true,
|
|
392
395
|
debug: ((_e = opts.events) == null ? void 0 : _e.debug) === true || envDebug,
|
|
393
|
-
partialFlushMs: (_f = opts.events) == null ? void 0 : _f.partialFlushMs
|
|
396
|
+
partialFlushMs: (_f = opts.events) == null ? void 0 : _f.partialFlushMs,
|
|
397
|
+
localDebuggerUrl: opts.localWorkshopUrl
|
|
394
398
|
}) : null;
|
|
395
|
-
const traceShipper = tracesEnabled && (hasWriteKey || opts.endpoint) ? new TraceShipper({
|
|
399
|
+
const traceShipper = tracesEnabled && (hasWriteKey || opts.endpoint || hasLocalDestination) ? new TraceShipper({
|
|
396
400
|
writeKey: opts.writeKey,
|
|
397
401
|
endpoint: opts.endpoint,
|
|
398
402
|
enabled: true,
|
|
@@ -400,7 +404,8 @@ function createRaindropPiAgent(opts) {
|
|
|
400
404
|
debugSpans: ((_h = opts.traces) == null ? void 0 : _h.debugSpans) === true || envDebug,
|
|
401
405
|
flushIntervalMs: (_i = opts.traces) == null ? void 0 : _i.flushIntervalMs,
|
|
402
406
|
maxBatchSize: (_j = opts.traces) == null ? void 0 : _j.maxBatchSize,
|
|
403
|
-
maxQueueSize: (_k = opts.traces) == null ? void 0 : _k.maxQueueSize
|
|
407
|
+
maxQueueSize: (_k = opts.traces) == null ? void 0 : _k.maxQueueSize,
|
|
408
|
+
localDebuggerUrl: opts.localWorkshopUrl
|
|
404
409
|
}) : null;
|
|
405
410
|
const defaultOptions = {
|
|
406
411
|
userId: opts.userId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raindrop-ai/pi-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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",
|
|
@@ -42,13 +42,6 @@
|
|
|
42
42
|
"dist/**",
|
|
43
43
|
"README.md"
|
|
44
44
|
],
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsup",
|
|
47
|
-
"dev": "tsup --watch",
|
|
48
|
-
"clean": "rm -rf dist",
|
|
49
|
-
"test": "vitest run",
|
|
50
|
-
"test:watch": "vitest"
|
|
51
|
-
},
|
|
52
45
|
"peerDependencies": {
|
|
53
46
|
"@mariozechner/pi-agent-core": ">=0.60.0",
|
|
54
47
|
"@mariozechner/pi-coding-agent": ">=0.65.2"
|
|
@@ -59,14 +52,14 @@
|
|
|
59
52
|
}
|
|
60
53
|
},
|
|
61
54
|
"devDependencies": {
|
|
62
|
-
"@raindrop-ai/core": "workspace:*",
|
|
63
55
|
"@mariozechner/pi-agent-core": "^0.66.0",
|
|
64
56
|
"@mariozechner/pi-coding-agent": "^0.66.0",
|
|
65
57
|
"@types/node": "^20.11.17",
|
|
66
58
|
"msw": "^2.12.7",
|
|
67
59
|
"tsup": "^8.5.1",
|
|
68
60
|
"typescript": "^5.7.3",
|
|
69
|
-
"vitest": "^2.1.9"
|
|
61
|
+
"vitest": "^2.1.9",
|
|
62
|
+
"@raindrop-ai/core": "0.0.1"
|
|
70
63
|
},
|
|
71
64
|
"tsup": {
|
|
72
65
|
"entry": [
|
|
@@ -87,5 +80,12 @@
|
|
|
87
80
|
},
|
|
88
81
|
"publishConfig": {
|
|
89
82
|
"access": "public"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsup",
|
|
86
|
+
"dev": "tsup --watch",
|
|
87
|
+
"clean": "rm -rf dist",
|
|
88
|
+
"test": "vitest run",
|
|
89
|
+
"test:watch": "vitest"
|
|
90
90
|
}
|
|
91
|
-
}
|
|
91
|
+
}
|