@raindrop-ai/pi-agent 0.0.9 → 0.0.10

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-WKRW55KX.js
1
+ // ../core/dist/chunk-267IXHO5.js
2
2
  function getCrypto() {
3
3
  const c = globalThis.crypto;
4
4
  return c;
@@ -54,7 +54,7 @@ function base64Encode(bytes) {
54
54
  return out;
55
55
  }
56
56
  function generateId() {
57
- return base64Encode(randomBytes(12)).replace(/[+/=]/g, "").slice(0, 16);
57
+ return randomUUID();
58
58
  }
59
59
  function runWithTracingSuppressed(fn) {
60
60
  const hook = globalThis.RAINDROP_SUPPRESS_TRACING;
@@ -391,13 +391,16 @@ function projectIdHeaders(projectId) {
391
391
  var SHUTDOWN_DEADLINE_MS = 1e4;
392
392
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
393
393
  function mergePatches(target, source) {
394
- var _a, _b, _c, _d;
394
+ var _a, _b, _c, _d, _e, _f;
395
395
  const out = { ...target, ...source };
396
396
  if (target.properties || source.properties) {
397
397
  out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
398
398
  }
399
+ if (target.featureFlags || source.featureFlags) {
400
+ out.featureFlags = { ...(_c = target.featureFlags) != null ? _c : {}, ...(_d = source.featureFlags) != null ? _d : {} };
401
+ }
399
402
  if (target.attachments || source.attachments) {
400
- out.attachments = [...(_c = target.attachments) != null ? _c : [], ...(_d = source.attachments) != null ? _d : []];
403
+ out.attachments = [...(_e = target.attachments) != null ? _e : [], ...(_f = source.attachments) != null ? _f : []];
401
404
  }
402
405
  return out;
403
406
  }
@@ -667,6 +670,7 @@ var EventShipper = class {
667
670
  ...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
668
671
  $context: this.context
669
672
  },
673
+ ...accumulated.featureFlags && Object.keys(accumulated.featureFlags).length > 0 ? { feature_flags: accumulated.featureFlags } : {},
670
674
  attachments: accumulated.attachments,
671
675
  is_pending: isPending
672
676
  };
@@ -1167,7 +1171,7 @@ installTracingSuppressionHook();
1167
1171
  // package.json
1168
1172
  var package_default = {
1169
1173
  name: "@raindrop-ai/pi-agent",
1170
- version: "0.0.9",
1174
+ version: "0.0.10",
1171
1175
  description: "Raindrop observability for Pi Agent \u2014 automatic tracing via subscriber or pi-coding-agent extension",
1172
1176
  type: "module",
1173
1177
  license: "MIT",
@@ -25,7 +25,7 @@ __export(extension_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(extension_exports);
27
27
 
28
- // ../core/dist/chunk-WKRW55KX.js
28
+ // ../core/dist/chunk-267IXHO5.js
29
29
  function getCrypto() {
30
30
  const c = globalThis.crypto;
31
31
  return c;
@@ -40,6 +40,17 @@ function randomBytes(length) {
40
40
  for (let i = 0; i < out.length; i++) out[i] = Math.floor(Math.random() * 256);
41
41
  return out;
42
42
  }
43
+ function randomUUID() {
44
+ const cryptoObj = getCrypto();
45
+ if (cryptoObj && typeof cryptoObj.randomUUID === "function") {
46
+ return cryptoObj.randomUUID();
47
+ }
48
+ const b = randomBytes(16);
49
+ b[6] = b[6] & 15 | 64;
50
+ b[8] = b[8] & 63 | 128;
51
+ const hex = [...b].map((x) => x.toString(16).padStart(2, "0")).join("");
52
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
53
+ }
43
54
  function base64Encode(bytes) {
44
55
  const maybeBuffer = globalThis.Buffer;
45
56
  if (maybeBuffer) {
@@ -70,7 +81,7 @@ function base64Encode(bytes) {
70
81
  return out;
71
82
  }
72
83
  function generateId() {
73
- return base64Encode(randomBytes(12)).replace(/[+/=]/g, "").slice(0, 16);
84
+ return randomUUID();
74
85
  }
75
86
  function runWithTracingSuppressed(fn) {
76
87
  const hook = globalThis.RAINDROP_SUPPRESS_TRACING;
@@ -407,13 +418,16 @@ function projectIdHeaders(projectId) {
407
418
  var SHUTDOWN_DEADLINE_MS = 1e4;
408
419
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
409
420
  function mergePatches(target, source) {
410
- var _a, _b, _c, _d;
421
+ var _a, _b, _c, _d, _e, _f;
411
422
  const out = { ...target, ...source };
412
423
  if (target.properties || source.properties) {
413
424
  out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
414
425
  }
426
+ if (target.featureFlags || source.featureFlags) {
427
+ out.featureFlags = { ...(_c = target.featureFlags) != null ? _c : {}, ...(_d = source.featureFlags) != null ? _d : {} };
428
+ }
415
429
  if (target.attachments || source.attachments) {
416
- out.attachments = [...(_c = target.attachments) != null ? _c : [], ...(_d = source.attachments) != null ? _d : []];
430
+ out.attachments = [...(_e = target.attachments) != null ? _e : [], ...(_f = source.attachments) != null ? _f : []];
417
431
  }
418
432
  return out;
419
433
  }
@@ -683,6 +697,7 @@ var EventShipper = class {
683
697
  ...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
684
698
  $context: this.context
685
699
  },
700
+ ...accumulated.featureFlags && Object.keys(accumulated.featureFlags).length > 0 ? { feature_flags: accumulated.featureFlags } : {},
686
701
  attachments: accumulated.attachments,
687
702
  is_pending: isPending
688
703
  };
@@ -1238,7 +1253,7 @@ function resolveLocalWorkshopUrl(fileValue) {
1238
1253
  // package.json
1239
1254
  var package_default = {
1240
1255
  name: "@raindrop-ai/pi-agent",
1241
- version: "0.0.9",
1256
+ version: "0.0.10",
1242
1257
  description: "Raindrop observability for Pi Agent \u2014 automatic tracing via subscriber or pi-coding-agent extension",
1243
1258
  type: "module",
1244
1259
  license: "MIT",
@@ -1756,11 +1771,12 @@ function registerTracing(pi, config, eventShipper, traceShipper) {
1756
1771
  state.currentRootSpan = void 0;
1757
1772
  await eventShipper.finish((_h = state.currentEventRequestId) != null ? _h : state.currentEventId, {
1758
1773
  userId: getUserId(state, config.eventMetadata),
1759
- model: modelName,
1774
+ ...modelId ? { model: modelId } : {},
1760
1775
  ...outputText.trim() ? { output: outputText } : {},
1761
1776
  properties: {
1762
1777
  sdk_version: libraryVersion,
1763
1778
  stop_reason: message.stopReason,
1779
+ ...provider ? { "ai.provider": provider } : {},
1764
1780
  ...state.totalInputTokens > 0 ? { "ai.usage.prompt_tokens": state.totalInputTokens } : {},
1765
1781
  ...state.totalOutputTokens > 0 ? { "ai.usage.completion_tokens": state.totalOutputTokens } : {},
1766
1782
  ...state.totalCacheReadTokens > 0 ? { "ai.usage.cache_read_tokens": state.totalCacheReadTokens } : {}
@@ -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-CSO1bDLs.cjs';
2
+ import { E as EventShipper$1, T as TraceShipper$1, O as OtlpSpan } from './index.d-DBLTz2Nz.cjs';
3
3
 
4
4
  interface EventMetadata {
5
5
  userId?: string;
@@ -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-CSO1bDLs.js';
2
+ import { E as EventShipper$1, T as TraceShipper$1, O as OtlpSpan } from './index.d-DBLTz2Nz.js';
3
3
 
4
4
  interface EventMetadata {
5
5
  userId?: string;
package/dist/extension.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  resolveLocalDebuggerBaseUrl,
15
15
  safeStringify,
16
16
  truncate
17
- } from "./chunk-TEXLELWC.js";
17
+ } from "./chunk-GXL5WZE5.js";
18
18
 
19
19
  // src/internal/config.ts
20
20
  import { existsSync, readFileSync } from "fs";
@@ -334,11 +334,12 @@ function registerTracing(pi, config, eventShipper, traceShipper) {
334
334
  state.currentRootSpan = void 0;
335
335
  await eventShipper.finish((_h = state.currentEventRequestId) != null ? _h : state.currentEventId, {
336
336
  userId: getUserId(state, config.eventMetadata),
337
- model: modelName,
337
+ ...modelId ? { model: modelId } : {},
338
338
  ...outputText.trim() ? { output: outputText } : {},
339
339
  properties: {
340
340
  sdk_version: libraryVersion,
341
341
  stop_reason: message.stopReason,
342
+ ...provider ? { "ai.provider": provider } : {},
342
343
  ...state.totalInputTokens > 0 ? { "ai.usage.prompt_tokens": state.totalInputTokens } : {},
343
344
  ...state.totalOutputTokens > 0 ? { "ai.usage.completion_tokens": state.totalOutputTokens } : {},
344
345
  ...state.totalCacheReadTokens > 0 ? { "ai.usage.cache_read_tokens": state.totalCacheReadTokens } : {}
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-WKRW55KX.js
27
+ // ../core/dist/chunk-267IXHO5.js
28
28
  function getCrypto() {
29
29
  const c = globalThis.crypto;
30
30
  return c;
@@ -414,13 +414,16 @@ function projectIdHeaders(projectId) {
414
414
  var SHUTDOWN_DEADLINE_MS = 1e4;
415
415
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
416
416
  function mergePatches(target, source) {
417
- var _a, _b, _c, _d;
417
+ var _a, _b, _c, _d, _e, _f;
418
418
  const out = { ...target, ...source };
419
419
  if (target.properties || source.properties) {
420
420
  out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
421
421
  }
422
+ if (target.featureFlags || source.featureFlags) {
423
+ out.featureFlags = { ...(_c = target.featureFlags) != null ? _c : {}, ...(_d = source.featureFlags) != null ? _d : {} };
424
+ }
422
425
  if (target.attachments || source.attachments) {
423
- out.attachments = [...(_c = target.attachments) != null ? _c : [], ...(_d = source.attachments) != null ? _d : []];
426
+ out.attachments = [...(_e = target.attachments) != null ? _e : [], ...(_f = source.attachments) != null ? _f : []];
424
427
  }
425
428
  return out;
426
429
  }
@@ -690,6 +693,7 @@ var EventShipper = class {
690
693
  ...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
691
694
  $context: this.context
692
695
  },
696
+ ...accumulated.featureFlags && Object.keys(accumulated.featureFlags).length > 0 ? { feature_flags: accumulated.featureFlags } : {},
693
697
  attachments: accumulated.attachments,
694
698
  is_pending: isPending
695
699
  };
@@ -1190,7 +1194,7 @@ installTracingSuppressionHook();
1190
1194
  // package.json
1191
1195
  var package_default = {
1192
1196
  name: "@raindrop-ai/pi-agent",
1193
- version: "0.0.9",
1197
+ version: "0.0.10",
1194
1198
  description: "Raindrop observability for Pi Agent \u2014 automatic tracing via subscriber or pi-coding-agent extension",
1195
1199
  type: "module",
1196
1200
  license: "MIT",
@@ -1585,17 +1589,22 @@ function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, opt
1585
1589
  }
1586
1590
  if (!("role" in message) || message.role !== "assistant") return;
1587
1591
  const model = extractModelName(message);
1592
+ const provider = "provider" in message && typeof message.provider === "string" ? message.provider : void 0;
1593
+ const bareModel = typeof message.model === "string" ? message.model : void 0;
1588
1594
  const usage = extractTokenUsage(message);
1589
1595
  const assistantText = extractAssistantText(message);
1590
- if (model) currentRun.lastModel = model;
1596
+ if (bareModel) {
1597
+ currentRun.lastModel = bareModel;
1598
+ currentRun.lastProvider = provider;
1599
+ }
1591
1600
  if (usage) {
1592
1601
  currentRun.totalInputTokens += usage.input;
1593
1602
  currentRun.totalOutputTokens += usage.output;
1594
1603
  if (usage.cacheRead) currentRun.totalCacheReadTokens += usage.cacheRead;
1595
1604
  }
1596
1605
  if (!traceShipper || !currentRun.currentTurnSpan) return;
1597
- const rawProvider = "provider" in message && typeof message.provider === "string" ? message.provider : void 0;
1598
- const rawModelId = typeof message.model === "string" ? message.model : void 0;
1606
+ const rawProvider = provider;
1607
+ const rawModelId = bareModel;
1599
1608
  const stopReason = "stopReason" in message && typeof message.stopReason === "string" ? message.stopReason : void 0;
1600
1609
  const llmAttrs = [
1601
1610
  attrString("ai.operationId", "generateText")
@@ -1753,7 +1762,7 @@ function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, opt
1753
1762
  attrString("ai.operationId", "generateText")
1754
1763
  ];
1755
1764
  if (run.lastModel) {
1756
- run.rootSpan.name = run.lastModel;
1765
+ run.rootSpan.name = run.lastProvider ? `${run.lastProvider}/${run.lastModel}` : run.lastModel;
1757
1766
  rootAttrs.push(attrString("gen_ai.response.model", run.lastModel));
1758
1767
  }
1759
1768
  if (run.currentInput) {
@@ -1782,6 +1791,7 @@ function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, opt
1782
1791
  properties: {
1783
1792
  ...properties,
1784
1793
  sdk_version: libraryVersion,
1794
+ ...run.lastProvider ? { "ai.provider": run.lastProvider } : {},
1785
1795
  ...run.totalInputTokens > 0 ? { "ai.usage.prompt_tokens": run.totalInputTokens } : {},
1786
1796
  ...run.totalOutputTokens > 0 ? { "ai.usage.completion_tokens": run.totalOutputTokens } : {},
1787
1797
  ...run.totalCacheReadTokens > 0 ? { "ai.usage.cache_read_tokens": run.totalCacheReadTokens } : {}
@@ -53,6 +53,7 @@ type Patch = {
53
53
  output?: string;
54
54
  model?: string;
55
55
  properties?: Record<string, unknown>;
56
+ featureFlags?: Record<string, string>;
56
57
  attachments?: Attachment[];
57
58
  isPending?: boolean;
58
59
  timestamp?: string;
@@ -153,6 +154,7 @@ declare class EventShipper {
153
154
  output?: string;
154
155
  model?: string;
155
156
  properties?: Record<string, unknown>;
157
+ featureFlags?: Record<string, string>;
156
158
  userId?: string;
157
159
  }): Promise<void>;
158
160
  flush(): Promise<void>;
@@ -53,6 +53,7 @@ type Patch = {
53
53
  output?: string;
54
54
  model?: string;
55
55
  properties?: Record<string, unknown>;
56
+ featureFlags?: Record<string, string>;
56
57
  attachments?: Attachment[];
57
58
  isPending?: boolean;
58
59
  timestamp?: string;
@@ -153,6 +154,7 @@ declare class EventShipper {
153
154
  output?: string;
154
155
  model?: string;
155
156
  properties?: Record<string, unknown>;
157
+ featureFlags?: Record<string, string>;
156
158
  userId?: string;
157
159
  }): Promise<void>;
158
160
  flush(): Promise<void>;
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-CSO1bDLs.cjs';
2
+ import { A as Attachment } from './index.d-DBLTz2Nz.cjs';
3
3
 
4
4
  /**
5
5
  * Options for the Raindrop Pi Agent client.
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-CSO1bDLs.js';
2
+ import { A as Attachment } from './index.d-DBLTz2Nz.js';
3
3
 
4
4
  /**
5
5
  * Options for the Raindrop Pi Agent client.
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  resolveLocalDebuggerBaseUrl,
18
18
  safeStringify,
19
19
  truncate
20
- } from "./chunk-TEXLELWC.js";
20
+ } from "./chunk-GXL5WZE5.js";
21
21
 
22
22
  // src/internal/subscriber.ts
23
23
  function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, options, debug) {
@@ -116,17 +116,22 @@ function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, opt
116
116
  }
117
117
  if (!("role" in message) || message.role !== "assistant") return;
118
118
  const model = extractModelName(message);
119
+ const provider = "provider" in message && typeof message.provider === "string" ? message.provider : void 0;
120
+ const bareModel = typeof message.model === "string" ? message.model : void 0;
119
121
  const usage = extractTokenUsage(message);
120
122
  const assistantText = extractAssistantText(message);
121
- if (model) currentRun.lastModel = model;
123
+ if (bareModel) {
124
+ currentRun.lastModel = bareModel;
125
+ currentRun.lastProvider = provider;
126
+ }
122
127
  if (usage) {
123
128
  currentRun.totalInputTokens += usage.input;
124
129
  currentRun.totalOutputTokens += usage.output;
125
130
  if (usage.cacheRead) currentRun.totalCacheReadTokens += usage.cacheRead;
126
131
  }
127
132
  if (!traceShipper || !currentRun.currentTurnSpan) return;
128
- const rawProvider = "provider" in message && typeof message.provider === "string" ? message.provider : void 0;
129
- const rawModelId = typeof message.model === "string" ? message.model : void 0;
133
+ const rawProvider = provider;
134
+ const rawModelId = bareModel;
130
135
  const stopReason = "stopReason" in message && typeof message.stopReason === "string" ? message.stopReason : void 0;
131
136
  const llmAttrs = [
132
137
  attrString("ai.operationId", "generateText")
@@ -284,7 +289,7 @@ function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, opt
284
289
  attrString("ai.operationId", "generateText")
285
290
  ];
286
291
  if (run.lastModel) {
287
- run.rootSpan.name = run.lastModel;
292
+ run.rootSpan.name = run.lastProvider ? `${run.lastProvider}/${run.lastModel}` : run.lastModel;
288
293
  rootAttrs.push(attrString("gen_ai.response.model", run.lastModel));
289
294
  }
290
295
  if (run.currentInput) {
@@ -313,6 +318,7 @@ function createSubscriber(agent, eventShipper, traceShipper, defaultOptions, opt
313
318
  properties: {
314
319
  ...properties,
315
320
  sdk_version: libraryVersion,
321
+ ...run.lastProvider ? { "ai.provider": run.lastProvider } : {},
316
322
  ...run.totalInputTokens > 0 ? { "ai.usage.prompt_tokens": run.totalInputTokens } : {},
317
323
  ...run.totalOutputTokens > 0 ? { "ai.usage.completion_tokens": run.totalOutputTokens } : {},
318
324
  ...run.totalCacheReadTokens > 0 ? { "ai.usage.cache_read_tokens": run.totalCacheReadTokens } : {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/pi-agent",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
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",
@@ -54,7 +54,7 @@
54
54
  "tsup": "^8.5.1",
55
55
  "typescript": "^5.7.3",
56
56
  "vitest": "^2.1.9",
57
- "@raindrop-ai/core": "0.0.5"
57
+ "@raindrop-ai/core": "0.1.2"
58
58
  },
59
59
  "tsup": {
60
60
  "entry": [