@raindrop-ai/opencode-plugin 0.1.4 → 0.3.0

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.d.ts CHANGED
@@ -1,85 +1,12 @@
1
+ import { I as IdentifyInput, A as AppGitOptions, S as SelfDiagnosticsOptions } from './self-diagnostics-NiAq-SZ8.js';
2
+ export { a as SelfDiagnosticsSignalDefinition, b as SelfDiagnosticsSignalDefinitions } from './self-diagnostics-NiAq-SZ8.js';
1
3
  import { Hooks, PluginInput } from '@opencode-ai/plugin';
2
4
 
3
- /** Kept structural so public integration declarations do not depend on private schemas. */
4
- type AppGitOptions = {
5
- commitSha?: string | null;
6
- commitDirty?: boolean | null;
7
- branch?: string | null;
8
- detectBranch?: boolean;
9
- sourceDirectory?: string;
10
- autoDetect?: boolean;
11
- };
12
- type IdentifyInput = {
13
- userId: string;
14
- traits?: Record<string, unknown>;
15
- };
16
-
17
- /**
18
- * Run telemetry egress with OpenTelemetry tracing suppressed.
19
- *
20
- * Why this exists
21
- * ---------------
22
- * Raindrop integrations ship spans/events over HTTP with the global `fetch`
23
- * (see {@link ../http.ts `postJson`}). When the host app also runs an OTel
24
- * fetch/undici instrumentation — e.g. `@vercel/otel`'s `registerOTel`, which
25
- * every Eve agent installs — that instrumentation wraps *our own* telemetry
26
- * POSTs in a `fetch POST <endpoint>` span. Those spans are then handed to the
27
- * very exporter that issued the request, so they get shipped right back to
28
- * Raindrop and Workshop as standalone "runs" (and, because each export issues
29
- * another fetch, they feed back on themselves). The result is a run list
30
- * flooded with `fetch POST .../v1/traces`, `.../events/track_partial` and
31
- * `.../live` entries that drown out the real agent turns — especially with
32
- * sub-agents, where every sandbox runs its own instrumentation.
33
- *
34
- * The OTel-blessed fix is to mark the active context as "tracing suppressed"
35
- * around the request; instrumentations check `isTracingSuppressed` and return
36
- * a no-op span instead of recording one. We do this through a hook stashed on
37
- * `globalThis` by the Node entrypoint ({@link ../index.node.ts}) so that:
38
- * - `@opentelemetry/api` / `@opentelemetry/core` stay *optional* — core never
39
- * hard-depends on them, and the hook is simply absent when they (and thus
40
- * any instrumentation to suppress) are not installed; and
41
- * - the browser bundle never pulls in `node:module`, mirroring how core
42
- * injects `AsyncLocalStorage` via `RAINDROP_ASYNC_LOCAL_STORAGE`.
43
- *
44
- * When no hook is present the callback runs unchanged, so suppression is a
45
- * best-effort no-op rather than a hard requirement.
46
- */
47
- /** Hook signature: run `fn` with OTel tracing suppressed, returning its value. */
48
- type SuppressTracingHook = <T>(fn: () => T) => T;
49
- declare global {
50
- var RAINDROP_SUPPRESS_TRACING: SuppressTracingHook | undefined;
51
- }
52
-
53
- type ParentSpanContext = {
54
- traceIdB64: string;
55
- spanIdB64: string;
56
- eventId: string;
57
- };
58
- interface ContextSpan {
59
- readonly traceIdB64: string;
60
- readonly spanIdB64: string;
61
- readonly eventId: string;
62
- log?(data: Record<string, unknown>): void;
63
- }
64
- interface AsyncLocalStorageLike<T> {
65
- getStore(): T | undefined;
66
- run<R>(store: T, callback: () => R): R;
67
- enterWith?(store: T): void;
68
- }
69
- declare abstract class ContextManager {
70
- abstract getParentSpanIds(): ParentSpanContext | undefined;
71
- abstract runInContext<R>(span: ContextSpan, callback: () => R): R;
72
- abstract getCurrentSpan(): ContextSpan | undefined;
73
- abstract isReady(): boolean;
74
- }
75
- declare global {
76
- var RAINDROP_CONTEXT_MANAGER: (new () => ContextManager) | undefined;
77
- var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => AsyncLocalStorageLike<T>) | undefined;
78
- }
79
-
80
5
  interface RaindropOpencodeOptions {
81
6
  /** Application Git identity override. false disables enrichment. */
82
7
  appGit?: AppGitOptions | false;
8
+ /** Built-in self-diagnostics: injects a `__raindrop_report` tool when enabled. */
9
+ selfDiagnostics?: SelfDiagnosticsOptions;
83
10
  }
84
11
  /**
85
12
  * The Raindrop control handle exposed alongside the OpenCode hooks.
@@ -101,6 +28,8 @@ interface RaindropOpencodeHandle {
101
28
  */
102
29
  identify(users: IdentifyInput | IdentifyInput[]): Promise<void>;
103
30
  };
31
+ /** Raindrop eventId of the turn currently open for this OpenCode session, if any. */
32
+ currentEventId(sessionID: string): string | undefined;
104
33
  /** Drain the buffered event + trace shippers. */
105
34
  flush(): Promise<void>;
106
35
  /** Flush and tear down the shippers (also wired into session teardown). */
@@ -129,4 +58,4 @@ type RaindropOpencodeHooks = Hooks & {
129
58
  */
130
59
  declare function plugin(input: PluginInput, opts?: RaindropOpencodeOptions): Promise<RaindropOpencodeHooks>;
131
60
 
132
- export { type IdentifyInput, type RaindropOpencodeHandle, type RaindropOpencodeHooks, type RaindropOpencodeOptions, plugin as default };
61
+ export { IdentifyInput, type RaindropOpencodeHandle, type RaindropOpencodeHooks, type RaindropOpencodeOptions, SelfDiagnosticsOptions, plugin as default };