@raindrop-ai/opencode-plugin 0.0.17 → 0.0.19

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.cjs CHANGED
@@ -24,7 +24,7 @@ __export(index_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(index_exports);
26
26
 
27
- // ../core/dist/chunk-SK6EJEO7.js
27
+ // ../core/dist/chunk-267IXHO5.js
28
28
  function getCrypto() {
29
29
  const c = globalThis.crypto;
30
30
  return c;
@@ -39,6 +39,17 @@ function randomBytes(length) {
39
39
  for (let i = 0; i < out.length; i++) out[i] = Math.floor(Math.random() * 256);
40
40
  return out;
41
41
  }
42
+ function randomUUID() {
43
+ const cryptoObj = getCrypto();
44
+ if (cryptoObj && typeof cryptoObj.randomUUID === "function") {
45
+ return cryptoObj.randomUUID();
46
+ }
47
+ const b = randomBytes(16);
48
+ b[6] = b[6] & 15 | 64;
49
+ b[8] = b[8] & 63 | 128;
50
+ const hex = [...b].map((x) => x.toString(16).padStart(2, "0")).join("");
51
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
52
+ }
42
53
  function base64Encode(bytes) {
43
54
  const maybeBuffer = globalThis.Buffer;
44
55
  if (maybeBuffer) {
@@ -69,7 +80,21 @@ function base64Encode(bytes) {
69
80
  return out;
70
81
  }
71
82
  function generateId() {
72
- return base64Encode(randomBytes(12)).replace(/[+/=]/g, "").slice(0, 16);
83
+ return randomUUID();
84
+ }
85
+ function runWithTracingSuppressed(fn) {
86
+ const hook = globalThis.RAINDROP_SUPPRESS_TRACING;
87
+ if (typeof hook !== "function") return fn();
88
+ let started = false;
89
+ try {
90
+ return hook(() => {
91
+ started = true;
92
+ return fn();
93
+ });
94
+ } catch (err) {
95
+ if (started) throw err;
96
+ return fn();
97
+ }
73
98
  }
74
99
  var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
75
100
  var MAX_RETRY_DELAY_MS = 3e4;
@@ -181,15 +206,17 @@ async function postJson(url, body, headers, opts) {
181
206
  const timeoutMs = (_a = opts.timeoutMs) != null ? _a : DEFAULT_REQUEST_TIMEOUT_MS;
182
207
  await withRetry(
183
208
  async () => {
184
- const resp = await fetch(url, {
185
- method: "POST",
186
- headers: {
187
- "Content-Type": "application/json",
188
- ...headers
189
- },
190
- body: JSON.stringify(body),
191
- signal: AbortSignal.timeout(timeoutMs)
192
- });
209
+ const resp = await runWithTracingSuppressed(
210
+ () => fetch(url, {
211
+ method: "POST",
212
+ headers: {
213
+ "Content-Type": "application/json",
214
+ ...headers
215
+ },
216
+ body: JSON.stringify(body),
217
+ signal: AbortSignal.timeout(timeoutMs)
218
+ })
219
+ );
193
220
  if (!resp.ok) {
194
221
  const text = await resp.text().catch(() => "");
195
222
  const err = new Error(
@@ -390,13 +417,16 @@ function projectIdHeaders(projectId) {
390
417
  var SHUTDOWN_DEADLINE_MS = 1e4;
391
418
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
392
419
  function mergePatches(target, source) {
393
- var _a, _b, _c, _d;
420
+ var _a, _b, _c, _d, _e, _f;
394
421
  const out = { ...target, ...source };
395
422
  if (target.properties || source.properties) {
396
423
  out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
397
424
  }
425
+ if (target.featureFlags || source.featureFlags) {
426
+ out.featureFlags = { ...(_c = target.featureFlags) != null ? _c : {}, ...(_d = source.featureFlags) != null ? _d : {} };
427
+ }
398
428
  if (target.attachments || source.attachments) {
399
- out.attachments = [...(_c = target.attachments) != null ? _c : [], ...(_d = source.attachments) != null ? _d : []];
429
+ out.attachments = [...(_e = target.attachments) != null ? _e : [], ...(_f = source.attachments) != null ? _f : []];
400
430
  }
401
431
  return out;
402
432
  }
@@ -666,6 +696,7 @@ var EventShipper = class {
666
696
  ...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
667
697
  $context: this.context
668
698
  },
699
+ ...accumulated.featureFlags && Object.keys(accumulated.featureFlags).length > 0 ? { feature_flags: accumulated.featureFlags } : {},
669
700
  attachments: accumulated.attachments,
670
701
  is_pending: isPending
671
702
  };
@@ -1137,6 +1168,31 @@ var TraceShipper = class {
1137
1168
  // ../core/dist/index.node.js
1138
1169
  var import_async_hooks = require("async_hooks");
1139
1170
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = import_async_hooks.AsyncLocalStorage;
1171
+ var SUPPRESS_TRACING_KEY = /* @__PURE__ */ Symbol.for(
1172
+ "OpenTelemetry SDK Context Key SUPPRESS_TRACING"
1173
+ );
1174
+ function findOtelContextManager() {
1175
+ var _a;
1176
+ for (const sym of Object.getOwnPropertySymbols(globalThis)) {
1177
+ if (!((_a = sym.description) == null ? void 0 : _a.startsWith("opentelemetry.js.api."))) continue;
1178
+ const api = globalThis[sym];
1179
+ const cm = api == null ? void 0 : api.context;
1180
+ if (cm && typeof cm.with === "function" && typeof cm.active === "function") {
1181
+ return cm;
1182
+ }
1183
+ }
1184
+ return void 0;
1185
+ }
1186
+ function installTracingSuppressionHook() {
1187
+ if (typeof globalThis.RAINDROP_SUPPRESS_TRACING === "function") return;
1188
+ const hook = (fn) => {
1189
+ const cm = findOtelContextManager();
1190
+ if (!cm) return fn();
1191
+ return cm.with(cm.active().setValue(SUPPRESS_TRACING_KEY, true), fn);
1192
+ };
1193
+ globalThis.RAINDROP_SUPPRESS_TRACING = hook;
1194
+ }
1195
+ installTracingSuppressionHook();
1140
1196
 
1141
1197
  // src/config.ts
1142
1198
  var import_node_fs = require("fs");
@@ -1192,7 +1248,7 @@ function resolveLocalWorkshopUrl(fileValue) {
1192
1248
  // package.json
1193
1249
  var package_default = {
1194
1250
  name: "@raindrop-ai/opencode-plugin",
1195
- version: "0.0.17",
1251
+ version: "0.0.19",
1196
1252
  description: "Raindrop observability plugin for OpenCode \u2014 automatic session/event/span tracing",
1197
1253
  type: "module",
1198
1254
  main: "dist/index.js",
@@ -1857,11 +1913,12 @@ type: ${name != null ? name : "UnknownError"}`;
1857
1913
  if (!state.parentId) {
1858
1914
  await eventShipper.finish(state.currentEventId, {
1859
1915
  userId: (_d = (_c = state.eventMetadata) == null ? void 0 : _c.userId) != null ? _d : state.sessionId,
1860
- model: modelName,
1916
+ model: modelID,
1861
1917
  output: outputText,
1862
1918
  properties: {
1863
1919
  plugin_version: PLUGIN_VERSION,
1864
1920
  message_id: messageId,
1921
+ "ai.provider": providerID,
1865
1922
  ...isCompaction ? { is_compaction: true } : {}
1866
1923
  }
1867
1924
  });
@@ -1969,7 +2026,7 @@ type: ${errorName != null ? errorName : "UnknownError"}`;
1969
2026
  promptMeta.properties = m["properties"];
1970
2027
  }
1971
2028
  } else if (part["type"] === "file") {
1972
- const mimeType = part["mediaType"];
2029
+ const mimeType = part["mime"];
1973
2030
  const filename = part["filename"];
1974
2031
  const url = part["url"];
1975
2032
  if (url && (mimeType == null ? void 0 : mimeType.startsWith("image/"))) {
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
5
5
  throw Error('Dynamic require of "' + x + '" is not supported');
6
6
  });
7
7
 
8
- // ../core/dist/chunk-SK6EJEO7.js
8
+ // ../core/dist/chunk-267IXHO5.js
9
9
  function getCrypto() {
10
10
  const c = globalThis.crypto;
11
11
  return c;
@@ -20,6 +20,17 @@ function randomBytes(length) {
20
20
  for (let i = 0; i < out.length; i++) out[i] = Math.floor(Math.random() * 256);
21
21
  return out;
22
22
  }
23
+ function randomUUID() {
24
+ const cryptoObj = getCrypto();
25
+ if (cryptoObj && typeof cryptoObj.randomUUID === "function") {
26
+ return cryptoObj.randomUUID();
27
+ }
28
+ const b = randomBytes(16);
29
+ b[6] = b[6] & 15 | 64;
30
+ b[8] = b[8] & 63 | 128;
31
+ const hex = [...b].map((x) => x.toString(16).padStart(2, "0")).join("");
32
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
33
+ }
23
34
  function base64Encode(bytes) {
24
35
  const maybeBuffer = globalThis.Buffer;
25
36
  if (maybeBuffer) {
@@ -50,7 +61,21 @@ function base64Encode(bytes) {
50
61
  return out;
51
62
  }
52
63
  function generateId() {
53
- return base64Encode(randomBytes(12)).replace(/[+/=]/g, "").slice(0, 16);
64
+ return randomUUID();
65
+ }
66
+ function runWithTracingSuppressed(fn) {
67
+ const hook = globalThis.RAINDROP_SUPPRESS_TRACING;
68
+ if (typeof hook !== "function") return fn();
69
+ let started = false;
70
+ try {
71
+ return hook(() => {
72
+ started = true;
73
+ return fn();
74
+ });
75
+ } catch (err) {
76
+ if (started) throw err;
77
+ return fn();
78
+ }
54
79
  }
55
80
  var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
56
81
  var MAX_RETRY_DELAY_MS = 3e4;
@@ -162,15 +187,17 @@ async function postJson(url, body, headers, opts) {
162
187
  const timeoutMs = (_a = opts.timeoutMs) != null ? _a : DEFAULT_REQUEST_TIMEOUT_MS;
163
188
  await withRetry(
164
189
  async () => {
165
- const resp = await fetch(url, {
166
- method: "POST",
167
- headers: {
168
- "Content-Type": "application/json",
169
- ...headers
170
- },
171
- body: JSON.stringify(body),
172
- signal: AbortSignal.timeout(timeoutMs)
173
- });
190
+ const resp = await runWithTracingSuppressed(
191
+ () => fetch(url, {
192
+ method: "POST",
193
+ headers: {
194
+ "Content-Type": "application/json",
195
+ ...headers
196
+ },
197
+ body: JSON.stringify(body),
198
+ signal: AbortSignal.timeout(timeoutMs)
199
+ })
200
+ );
174
201
  if (!resp.ok) {
175
202
  const text = await resp.text().catch(() => "");
176
203
  const err = new Error(
@@ -371,13 +398,16 @@ function projectIdHeaders(projectId) {
371
398
  var SHUTDOWN_DEADLINE_MS = 1e4;
372
399
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
373
400
  function mergePatches(target, source) {
374
- var _a, _b, _c, _d;
401
+ var _a, _b, _c, _d, _e, _f;
375
402
  const out = { ...target, ...source };
376
403
  if (target.properties || source.properties) {
377
404
  out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
378
405
  }
406
+ if (target.featureFlags || source.featureFlags) {
407
+ out.featureFlags = { ...(_c = target.featureFlags) != null ? _c : {}, ...(_d = source.featureFlags) != null ? _d : {} };
408
+ }
379
409
  if (target.attachments || source.attachments) {
380
- out.attachments = [...(_c = target.attachments) != null ? _c : [], ...(_d = source.attachments) != null ? _d : []];
410
+ out.attachments = [...(_e = target.attachments) != null ? _e : [], ...(_f = source.attachments) != null ? _f : []];
381
411
  }
382
412
  return out;
383
413
  }
@@ -647,6 +677,7 @@ var EventShipper = class {
647
677
  ...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
648
678
  $context: this.context
649
679
  },
680
+ ...accumulated.featureFlags && Object.keys(accumulated.featureFlags).length > 0 ? { feature_flags: accumulated.featureFlags } : {},
650
681
  attachments: accumulated.attachments,
651
682
  is_pending: isPending
652
683
  };
@@ -1118,6 +1149,31 @@ var TraceShipper = class {
1118
1149
  // ../core/dist/index.node.js
1119
1150
  import { AsyncLocalStorage } from "async_hooks";
1120
1151
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
1152
+ var SUPPRESS_TRACING_KEY = /* @__PURE__ */ Symbol.for(
1153
+ "OpenTelemetry SDK Context Key SUPPRESS_TRACING"
1154
+ );
1155
+ function findOtelContextManager() {
1156
+ var _a;
1157
+ for (const sym of Object.getOwnPropertySymbols(globalThis)) {
1158
+ if (!((_a = sym.description) == null ? void 0 : _a.startsWith("opentelemetry.js.api."))) continue;
1159
+ const api = globalThis[sym];
1160
+ const cm = api == null ? void 0 : api.context;
1161
+ if (cm && typeof cm.with === "function" && typeof cm.active === "function") {
1162
+ return cm;
1163
+ }
1164
+ }
1165
+ return void 0;
1166
+ }
1167
+ function installTracingSuppressionHook() {
1168
+ if (typeof globalThis.RAINDROP_SUPPRESS_TRACING === "function") return;
1169
+ const hook = (fn) => {
1170
+ const cm = findOtelContextManager();
1171
+ if (!cm) return fn();
1172
+ return cm.with(cm.active().setValue(SUPPRESS_TRACING_KEY, true), fn);
1173
+ };
1174
+ globalThis.RAINDROP_SUPPRESS_TRACING = hook;
1175
+ }
1176
+ installTracingSuppressionHook();
1121
1177
 
1122
1178
  // src/config.ts
1123
1179
  import { existsSync, readFileSync } from "fs";
@@ -1173,7 +1229,7 @@ function resolveLocalWorkshopUrl(fileValue) {
1173
1229
  // package.json
1174
1230
  var package_default = {
1175
1231
  name: "@raindrop-ai/opencode-plugin",
1176
- version: "0.0.17",
1232
+ version: "0.0.19",
1177
1233
  description: "Raindrop observability plugin for OpenCode \u2014 automatic session/event/span tracing",
1178
1234
  type: "module",
1179
1235
  main: "dist/index.js",
@@ -1838,11 +1894,12 @@ type: ${name != null ? name : "UnknownError"}`;
1838
1894
  if (!state.parentId) {
1839
1895
  await eventShipper.finish(state.currentEventId, {
1840
1896
  userId: (_d = (_c = state.eventMetadata) == null ? void 0 : _c.userId) != null ? _d : state.sessionId,
1841
- model: modelName,
1897
+ model: modelID,
1842
1898
  output: outputText,
1843
1899
  properties: {
1844
1900
  plugin_version: PLUGIN_VERSION,
1845
1901
  message_id: messageId,
1902
+ "ai.provider": providerID,
1846
1903
  ...isCompaction ? { is_compaction: true } : {}
1847
1904
  }
1848
1905
  });
@@ -1950,7 +2007,7 @@ type: ${errorName != null ? errorName : "UnknownError"}`;
1950
2007
  promptMeta.properties = m["properties"];
1951
2008
  }
1952
2009
  } else if (part["type"] === "file") {
1953
- const mimeType = part["mediaType"];
2010
+ const mimeType = part["mime"];
1954
2011
  const filename = part["filename"];
1955
2012
  const url = part["url"];
1956
2013
  if (url && (mimeType == null ? void 0 : mimeType.startsWith("image/"))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/opencode-plugin",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "Raindrop observability plugin for OpenCode — automatic session/event/span tracing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "@types/node": "^20.11.17",
38
38
  "tsup": "^8.4.0",
39
39
  "typescript": "^5.3.3",
40
- "@raindrop-ai/core": "0.0.4"
40
+ "@raindrop-ai/core": "0.1.2"
41
41
  },
42
42
  "tsup": {
43
43
  "entry": [