@raindrop-ai/opencode-plugin 0.0.16 → 0.0.18

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/README.md CHANGED
@@ -10,6 +10,18 @@ pnpm add @raindrop-ai/opencode-plugin @opencode-ai/plugin
10
10
 
11
11
  If your integration also uses the OpenCode SDK directly, install `@opencode-ai/sdk` as well.
12
12
 
13
+ ## Projects
14
+
15
+ If your org has multiple projects, route telemetry to a specific one by setting its slug via the `RAINDROP_PROJECT_ID` env var or the `project_id` key in `~/.config/opencode/raindrop.json` (or project-level `.opencode/raindrop.json`):
16
+
17
+ ```json
18
+ {
19
+ "project_id": "support-prod"
20
+ }
21
+ ```
22
+
23
+ This sets the `X-Raindrop-Project-Id` header on every outbound request. Leave it unset (or use `"default"`) to use your org's default **Production** project — the existing behavior. Single-project orgs need nothing new.
24
+
13
25
  ## Payload size limits
14
26
 
15
27
  Text fields (event input/output, span prompt/response and tool payloads) are
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-WKRW55KX.js
28
28
  function getCrypto() {
29
29
  const c = globalThis.crypto;
30
30
  return c;
@@ -71,6 +71,20 @@ function base64Encode(bytes) {
71
71
  function generateId() {
72
72
  return base64Encode(randomBytes(12)).replace(/[+/=]/g, "").slice(0, 16);
73
73
  }
74
+ function runWithTracingSuppressed(fn) {
75
+ const hook = globalThis.RAINDROP_SUPPRESS_TRACING;
76
+ if (typeof hook !== "function") return fn();
77
+ let started = false;
78
+ try {
79
+ return hook(() => {
80
+ started = true;
81
+ return fn();
82
+ });
83
+ } catch (err) {
84
+ if (started) throw err;
85
+ return fn();
86
+ }
87
+ }
74
88
  var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
75
89
  var MAX_RETRY_DELAY_MS = 3e4;
76
90
  function wait(ms) {
@@ -181,15 +195,17 @@ async function postJson(url, body, headers, opts) {
181
195
  const timeoutMs = (_a = opts.timeoutMs) != null ? _a : DEFAULT_REQUEST_TIMEOUT_MS;
182
196
  await withRetry(
183
197
  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
- });
198
+ const resp = await runWithTracingSuppressed(
199
+ () => fetch(url, {
200
+ method: "POST",
201
+ headers: {
202
+ "Content-Type": "application/json",
203
+ ...headers
204
+ },
205
+ body: JSON.stringify(body),
206
+ signal: AbortSignal.timeout(timeoutMs)
207
+ })
208
+ );
193
209
  if (!resp.ok) {
194
210
  const text = await resp.text().catch(() => "");
195
211
  const err = new Error(
@@ -1137,6 +1153,31 @@ var TraceShipper = class {
1137
1153
  // ../core/dist/index.node.js
1138
1154
  var import_async_hooks = require("async_hooks");
1139
1155
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = import_async_hooks.AsyncLocalStorage;
1156
+ var SUPPRESS_TRACING_KEY = /* @__PURE__ */ Symbol.for(
1157
+ "OpenTelemetry SDK Context Key SUPPRESS_TRACING"
1158
+ );
1159
+ function findOtelContextManager() {
1160
+ var _a;
1161
+ for (const sym of Object.getOwnPropertySymbols(globalThis)) {
1162
+ if (!((_a = sym.description) == null ? void 0 : _a.startsWith("opentelemetry.js.api."))) continue;
1163
+ const api = globalThis[sym];
1164
+ const cm = api == null ? void 0 : api.context;
1165
+ if (cm && typeof cm.with === "function" && typeof cm.active === "function") {
1166
+ return cm;
1167
+ }
1168
+ }
1169
+ return void 0;
1170
+ }
1171
+ function installTracingSuppressionHook() {
1172
+ if (typeof globalThis.RAINDROP_SUPPRESS_TRACING === "function") return;
1173
+ const hook = (fn) => {
1174
+ const cm = findOtelContextManager();
1175
+ if (!cm) return fn();
1176
+ return cm.with(cm.active().setValue(SUPPRESS_TRACING_KEY, true), fn);
1177
+ };
1178
+ globalThis.RAINDROP_SUPPRESS_TRACING = hook;
1179
+ }
1180
+ installTracingSuppressionHook();
1140
1181
 
1141
1182
  // src/config.ts
1142
1183
  var import_node_fs = require("fs");
@@ -1192,7 +1233,7 @@ function resolveLocalWorkshopUrl(fileValue) {
1192
1233
  // package.json
1193
1234
  var package_default = {
1194
1235
  name: "@raindrop-ai/opencode-plugin",
1195
- version: "0.0.16",
1236
+ version: "0.0.18",
1196
1237
  description: "Raindrop observability plugin for OpenCode \u2014 automatic session/event/span tracing",
1197
1238
  type: "module",
1198
1239
  main: "dist/index.js",
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-WKRW55KX.js
9
9
  function getCrypto() {
10
10
  const c = globalThis.crypto;
11
11
  return c;
@@ -52,6 +52,20 @@ function base64Encode(bytes) {
52
52
  function generateId() {
53
53
  return base64Encode(randomBytes(12)).replace(/[+/=]/g, "").slice(0, 16);
54
54
  }
55
+ function runWithTracingSuppressed(fn) {
56
+ const hook = globalThis.RAINDROP_SUPPRESS_TRACING;
57
+ if (typeof hook !== "function") return fn();
58
+ let started = false;
59
+ try {
60
+ return hook(() => {
61
+ started = true;
62
+ return fn();
63
+ });
64
+ } catch (err) {
65
+ if (started) throw err;
66
+ return fn();
67
+ }
68
+ }
55
69
  var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
56
70
  var MAX_RETRY_DELAY_MS = 3e4;
57
71
  function wait(ms) {
@@ -162,15 +176,17 @@ async function postJson(url, body, headers, opts) {
162
176
  const timeoutMs = (_a = opts.timeoutMs) != null ? _a : DEFAULT_REQUEST_TIMEOUT_MS;
163
177
  await withRetry(
164
178
  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
- });
179
+ const resp = await runWithTracingSuppressed(
180
+ () => fetch(url, {
181
+ method: "POST",
182
+ headers: {
183
+ "Content-Type": "application/json",
184
+ ...headers
185
+ },
186
+ body: JSON.stringify(body),
187
+ signal: AbortSignal.timeout(timeoutMs)
188
+ })
189
+ );
174
190
  if (!resp.ok) {
175
191
  const text = await resp.text().catch(() => "");
176
192
  const err = new Error(
@@ -1118,6 +1134,31 @@ var TraceShipper = class {
1118
1134
  // ../core/dist/index.node.js
1119
1135
  import { AsyncLocalStorage } from "async_hooks";
1120
1136
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
1137
+ var SUPPRESS_TRACING_KEY = /* @__PURE__ */ Symbol.for(
1138
+ "OpenTelemetry SDK Context Key SUPPRESS_TRACING"
1139
+ );
1140
+ function findOtelContextManager() {
1141
+ var _a;
1142
+ for (const sym of Object.getOwnPropertySymbols(globalThis)) {
1143
+ if (!((_a = sym.description) == null ? void 0 : _a.startsWith("opentelemetry.js.api."))) continue;
1144
+ const api = globalThis[sym];
1145
+ const cm = api == null ? void 0 : api.context;
1146
+ if (cm && typeof cm.with === "function" && typeof cm.active === "function") {
1147
+ return cm;
1148
+ }
1149
+ }
1150
+ return void 0;
1151
+ }
1152
+ function installTracingSuppressionHook() {
1153
+ if (typeof globalThis.RAINDROP_SUPPRESS_TRACING === "function") return;
1154
+ const hook = (fn) => {
1155
+ const cm = findOtelContextManager();
1156
+ if (!cm) return fn();
1157
+ return cm.with(cm.active().setValue(SUPPRESS_TRACING_KEY, true), fn);
1158
+ };
1159
+ globalThis.RAINDROP_SUPPRESS_TRACING = hook;
1160
+ }
1161
+ installTracingSuppressionHook();
1121
1162
 
1122
1163
  // src/config.ts
1123
1164
  import { existsSync, readFileSync } from "fs";
@@ -1173,7 +1214,7 @@ function resolveLocalWorkshopUrl(fileValue) {
1173
1214
  // package.json
1174
1215
  var package_default = {
1175
1216
  name: "@raindrop-ai/opencode-plugin",
1176
- version: "0.0.16",
1217
+ version: "0.0.18",
1177
1218
  description: "Raindrop observability plugin for OpenCode \u2014 automatic session/event/span tracing",
1178
1219
  type: "module",
1179
1220
  main: "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/opencode-plugin",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
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.0.5"
41
41
  },
42
42
  "tsup": {
43
43
  "entry": [