rd-mini 0.1.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,23 @@
1
+ /**
2
+ * Raindrop - Zero-config AI Observability SDK
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { Raindrop } from 'raindrop';
7
+ * import OpenAI from 'openai';
8
+ *
9
+ * const raindrop = new Raindrop({ apiKey: process.env.RAINDROP_API_KEY });
10
+ * const openai = raindrop.wrap(new OpenAI());
11
+ *
12
+ * // All calls are now automatically traced
13
+ * const response = await openai.chat.completions.create({
14
+ * model: 'gpt-4o',
15
+ * messages: [{ role: 'user', content: 'Hello!' }],
16
+ * });
17
+ *
18
+ * console.log(response._traceId); // Access trace ID for feedback
19
+ * ```
20
+ */
21
+ export { Raindrop, Interaction } from './raindrop.js';
22
+ export type { RaindropConfig, UserTraits, FeedbackOptions, RaindropRequestOptions, WithTraceId, InteractionOptions, InteractionContext, WrapToolOptions, BeginOptions, FinishOptions, Attachment, } from './types.js';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Raindrop - Zero-config AI Observability SDK
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { Raindrop } from 'raindrop';
7
+ * import OpenAI from 'openai';
8
+ *
9
+ * const raindrop = new Raindrop({ apiKey: process.env.RAINDROP_API_KEY });
10
+ * const openai = raindrop.wrap(new OpenAI());
11
+ *
12
+ * // All calls are now automatically traced
13
+ * const response = await openai.chat.completions.create({
14
+ * model: 'gpt-4o',
15
+ * messages: [{ role: 'user', content: 'Hello!' }],
16
+ * });
17
+ *
18
+ * console.log(response._traceId); // Access trace ID for feedback
19
+ * ```
20
+ */
21
+ export { Raindrop, Interaction } from './raindrop.js';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Raindrop - Zero-config AI Observability SDK
3
+ *
4
+ * Usage:
5
+ * const raindrop = new Raindrop({ apiKey: process.env.RAINDROP_API_KEY });
6
+ * const openai = raindrop.wrap(new OpenAI());
7
+ * // All calls are now automatically traced
8
+ *
9
+ * Multi-step pipelines:
10
+ * await raindrop.withInteraction({ userId, event: 'rag_query' }, async () => {
11
+ * const docs = await searchDocs(query); // Auto-linked
12
+ * const response = await openai.chat.completions.create(...); // Auto-linked
13
+ * });
14
+ */
15
+ import type { RaindropConfig, UserTraits, FeedbackOptions, RaindropRequestOptions, InteractionOptions, InteractionContext, WrapToolOptions, BeginOptions, FinishOptions, Attachment } from './types.js';
16
+ /**
17
+ * Interaction object returned by begin()
18
+ * Allows manual control over interaction lifecycle
19
+ */
20
+ export declare class Interaction {
21
+ private context;
22
+ private raindrop;
23
+ private finished;
24
+ constructor(context: InteractionContext, raindrop: Raindrop);
25
+ /** Get the interaction/event ID */
26
+ get id(): string;
27
+ /** Get or set the output */
28
+ get output(): string | undefined;
29
+ set output(value: string | undefined);
30
+ /** Set a single property */
31
+ setProperty(key: string, value: unknown): this;
32
+ /** Merge multiple properties */
33
+ setProperties(props: Record<string, unknown>): this;
34
+ /** Add attachments */
35
+ addAttachments(attachments: Attachment[]): this;
36
+ /** Set the input */
37
+ setInput(input: string): this;
38
+ /** Get the underlying context (for internal use) */
39
+ getContext(): InteractionContext;
40
+ /**
41
+ * Finish the interaction and send to Raindrop
42
+ */
43
+ finish(options?: FinishOptions): void;
44
+ }
45
+ export declare class Raindrop {
46
+ private config;
47
+ private transport;
48
+ private currentUserId?;
49
+ private _currentUserTraits?;
50
+ private lastTraceId?;
51
+ private activeInteractions;
52
+ constructor(config: RaindropConfig);
53
+ /**
54
+ * Wrap an AI client or model to auto-trace all calls
55
+ *
56
+ * Supports:
57
+ * - OpenAI client: raindrop.wrap(new OpenAI())
58
+ * - Anthropic client: raindrop.wrap(new Anthropic())
59
+ * - Vercel AI SDK model: raindrop.wrap(openai('gpt-4o'))
60
+ */
61
+ wrap<T>(client: T, options?: RaindropRequestOptions): T;
62
+ /**
63
+ * Identify a user for all subsequent calls
64
+ */
65
+ identify(userId: string, traits?: UserTraits): void;
66
+ /**
67
+ * Send feedback for a specific trace
68
+ */
69
+ feedback(traceId: string, options: FeedbackOptions): Promise<void>;
70
+ /**
71
+ * Start an interaction manually (escape hatch for complex flows)
72
+ *
73
+ * For simple cases, use withInteraction() instead.
74
+ * Use begin() when you need to start and finish in different places.
75
+ *
76
+ * @example
77
+ * const interaction = raindrop.begin({
78
+ * userId: 'user123',
79
+ * event: 'chat_message',
80
+ * input: 'What is X?',
81
+ * });
82
+ *
83
+ * // ... later, maybe in a different function
84
+ * interaction.finish({ output: 'X is...' });
85
+ */
86
+ begin(options?: BeginOptions): Interaction;
87
+ /**
88
+ * Resume an existing interaction by ID
89
+ *
90
+ * @example
91
+ * const interaction = raindrop.resumeInteraction(eventId);
92
+ * interaction.finish({ output: 'Done!' });
93
+ */
94
+ resumeInteraction(eventId: string): Interaction;
95
+ /**
96
+ * Internal: Called by Interaction.finish()
97
+ * @internal
98
+ */
99
+ _finishInteraction(context: InteractionContext): void;
100
+ /**
101
+ * Get the last trace ID (useful if you can't access _traceId on response)
102
+ */
103
+ getLastTraceId(): string | undefined;
104
+ /**
105
+ * Get the current user's traits (set via identify)
106
+ */
107
+ getUserTraits(): UserTraits | undefined;
108
+ /**
109
+ * Flush all pending events and close
110
+ */
111
+ close(): Promise<void>;
112
+ /**
113
+ * Run code within an interaction context
114
+ * All wrapped clients and tools called within will be auto-linked
115
+ *
116
+ * @example
117
+ * await raindrop.withInteraction(
118
+ * { userId: 'user123', event: 'rag_query', input: 'What is X?' },
119
+ * async (ctx) => {
120
+ * const docs = await searchDocs(query); // Auto-linked
121
+ * const response = await openai.chat.completions.create(...); // Auto-linked
122
+ * ctx.output = response.choices[0].message.content; // Set output
123
+ * }
124
+ * );
125
+ */
126
+ withInteraction<T>(options: InteractionOptions, fn: (ctx: InteractionContext) => Promise<T>): Promise<T>;
127
+ /**
128
+ * Wrap a tool function for automatic tracing
129
+ * When called within withInteraction(), the tool will be auto-linked
130
+ *
131
+ * @example
132
+ * const searchDocs = raindrop.wrapTool('search_docs', async (query: string) => {
133
+ * return await vectorDb.search(query);
134
+ * });
135
+ *
136
+ * // Use normally
137
+ * const docs = await searchDocs('how to use raindrop');
138
+ */
139
+ wrapTool<TArgs extends unknown[], TResult>(name: string, fn: (...args: TArgs) => Promise<TResult>, options?: WrapToolOptions): (...args: TArgs) => Promise<TResult>;
140
+ /**
141
+ * Get the current interaction context (if any)
142
+ * Useful for wrappers to check if they're within an interaction
143
+ */
144
+ getInteractionContext(): InteractionContext | undefined;
145
+ /**
146
+ * Internal: Send an interaction with all its spans
147
+ */
148
+ private sendInteraction;
149
+ /**
150
+ * Internal: Send a standalone tool trace
151
+ */
152
+ private sendToolTrace;
153
+ /**
154
+ * Internal: Send a trace
155
+ */
156
+ private sendTrace;
157
+ /**
158
+ * Internal: Generate a unique trace ID
159
+ */
160
+ private generateTraceId;
161
+ /**
162
+ * Internal: Detect the provider type from a client/model
163
+ */
164
+ private detectProvider;
165
+ }
166
+ //# sourceMappingURL=raindrop.d.ts.map
@@ -0,0 +1 @@
1
+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