@raindrop-ai/pi-agent 0.0.4 → 0.0.6

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,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-Cxs_NTx0.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-Cxs_NTx0.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
@@ -3,6 +3,7 @@ import {
3
3
  TraceShipper,
4
4
  attrInt,
5
5
  attrString,
6
+ capText,
6
7
  extractAssistantText,
7
8
  formatToolSpanName,
8
9
  generateId,
@@ -13,7 +14,7 @@ import {
13
14
  resolveLocalDebuggerBaseUrl,
14
15
  safeStringify,
15
16
  truncate
16
- } from "./chunk-EWIO36KH.js";
17
+ } from "./chunk-5F37XTG6.js";
17
18
 
18
19
  // src/internal/config.ts
19
20
  import { existsSync, readFileSync } from "fs";
@@ -24,7 +25,7 @@ function getPiAgentDirectory() {
24
25
  return (_a = process.env["PI_CODING_AGENT_DIR"]) != null ? _a : join(homedir(), ".pi", "agent");
25
26
  }
26
27
  function loadConfig(projectDirectory) {
27
- var _a, _b, _c, _d, _e, _f, _g;
28
+ var _a, _b, _c, _d, _e, _f, _g, _h;
28
29
  let merged = {};
29
30
  const configPaths = [
30
31
  join(getPiAgentDirectory(), "raindrop.json"),
@@ -51,9 +52,10 @@ function loadConfig(projectDirectory) {
51
52
  return {
52
53
  writeKey: (_b = (_a = process.env["RAINDROP_WRITE_KEY"]) != null ? _a : merged.write_key) != null ? _b : "",
53
54
  endpoint: (_d = (_c = process.env["RAINDROP_API_URL"]) != null ? _c : merged.api_url) != null ? _d : "https://api.raindrop.ai/v1",
54
- eventName: (_e = merged.event_name) != null ? _e : "pi_session",
55
- debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_f = merged.debug) != null ? _f : false,
56
- 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,
57
59
  eventMetadata,
58
60
  localWorkshopUrl: resolveLocalWorkshopUrl(merged.local_workshop_url)
59
61
  };
@@ -78,6 +80,15 @@ function safeParsArgs(argsStr) {
78
80
  }
79
81
  }
80
82
  var MAX_SYSTEM_PROMPT_LENGTH = 32768;
83
+ var ERROR_LOG_INTERVAL_MS = 3e4;
84
+ var lastErrorLogAt = /* @__PURE__ */ new Map();
85
+ function rateLimitedErrorLog(key, message) {
86
+ const now = Date.now();
87
+ const last = lastErrorLogAt.get(key);
88
+ if (last !== void 0 && now - last < ERROR_LOG_INTERVAL_MS) return;
89
+ lastErrorLogAt.set(key, now);
90
+ console.log(message);
91
+ }
81
92
  function createSessionState(sessionId) {
82
93
  return {
83
94
  sessionId,
@@ -142,7 +153,8 @@ function getState(stateRef, ctx) {
142
153
  function registerTracing(pi, config, eventShipper, traceShipper) {
143
154
  const stateRef = {};
144
155
  function logError(hook, err) {
145
- console.log(
156
+ rateLimitedErrorLog(
157
+ hook,
146
158
  `[raindrop-ai/pi-agent] [error] Error in ${hook}: ${err instanceof Error ? err.message : String(err)}`
147
159
  );
148
160
  }
@@ -195,7 +207,7 @@ function registerTracing(pi, config, eventShipper, traceShipper) {
195
207
  }
196
208
  state.toolSpanStarts.clear();
197
209
  state.toolCallToLlmParent.clear();
198
- state.currentInput = event.prompt;
210
+ state.currentInput = capText(event.prompt);
199
211
  state.turnNumber = 0;
200
212
  state.currentSystemPrompt = config.captureSystemPrompt ? truncateSystemPrompt(event.systemPrompt) : void 0;
201
213
  state.currentEventRequestId = generateId();
@@ -216,7 +228,7 @@ function registerTracing(pi, config, eventShipper, traceShipper) {
216
228
  userId: getUserId(state, config.eventMetadata),
217
229
  convoId: state.sessionId,
218
230
  eventName: getEventName(config),
219
- input: event.prompt,
231
+ input: state.currentInput,
220
232
  ...attachments.length > 0 ? { attachments } : {},
221
233
  properties: getBaseProperties(config, ctx)
222
234
  });
@@ -267,7 +279,7 @@ function registerTracing(pi, config, eventShipper, traceShipper) {
267
279
  const modelId = (_c = message.model) != null ? _c : "";
268
280
  const modelName = provider && modelId ? `${provider}/${modelId}` : modelId || "llm";
269
281
  const errorForSpan = getAssistantError(message);
270
- const outputText = getAssistantText(message);
282
+ const outputText = capText(getAssistantText(message));
271
283
  const inputTokens = (_d = message.usage) == null ? void 0 : _d.input;
272
284
  const outputTokens = (_e = message.usage) == null ? void 0 : _e.output;
273
285
  const cacheReadTokens = (_f = message.usage) == null ? void 0 : _f.cacheRead;
@@ -456,12 +468,14 @@ function extension(pi) {
456
468
  writeKey: config.writeKey,
457
469
  endpoint: config.endpoint,
458
470
  debug: config.debug,
471
+ projectId: config.projectId,
459
472
  localDebuggerUrl: config.localWorkshopUrl
460
473
  });
461
474
  const traceShipper = new TraceShipper({
462
475
  writeKey: config.writeKey,
463
476
  endpoint: config.endpoint,
464
477
  debug: config.debug,
478
+ projectId: config.projectId,
465
479
  localDebuggerUrl: config.localWorkshopUrl
466
480
  });
467
481
  registerTracing(pi, config, eventShipper, traceShipper);