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