@raindrop-ai/eve 0.0.10 → 0.0.11
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.mts +455 -0
- package/dist/index.d.ts +455 -0
- package/dist/index.js +1089 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1079 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import * as _vercel_otel from '@vercel/otel';
|
|
2
|
+
import { RaindropAISDKClient } from '@raindrop-ai/ai-sdk';
|
|
3
|
+
|
|
4
|
+
type HrTime = [number, number];
|
|
5
|
+
type AttributeValue = string | number | boolean | Array<string | number | boolean | null | undefined> | null | undefined;
|
|
6
|
+
interface Attributes {
|
|
7
|
+
[key: string]: AttributeValue;
|
|
8
|
+
}
|
|
9
|
+
interface SpanContext {
|
|
10
|
+
traceId: string;
|
|
11
|
+
spanId: string;
|
|
12
|
+
traceFlags?: number;
|
|
13
|
+
}
|
|
14
|
+
interface InstrumentationScope {
|
|
15
|
+
name: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
schemaUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
interface Resource {
|
|
20
|
+
attributes: Attributes;
|
|
21
|
+
}
|
|
22
|
+
interface ReadableSpan {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly kind: number;
|
|
25
|
+
readonly startTime: HrTime;
|
|
26
|
+
readonly endTime: HrTime;
|
|
27
|
+
readonly status: {
|
|
28
|
+
code: number;
|
|
29
|
+
message?: string;
|
|
30
|
+
};
|
|
31
|
+
readonly attributes: Attributes;
|
|
32
|
+
readonly resource: Resource;
|
|
33
|
+
readonly instrumentationLibrary?: InstrumentationScope;
|
|
34
|
+
readonly instrumentationScope?: InstrumentationScope;
|
|
35
|
+
spanContext(): SpanContext;
|
|
36
|
+
readonly parentSpanId?: string;
|
|
37
|
+
readonly parentSpanContext?: SpanContext;
|
|
38
|
+
}
|
|
39
|
+
interface ExportResult {
|
|
40
|
+
code: number;
|
|
41
|
+
error?: Error;
|
|
42
|
+
}
|
|
43
|
+
interface RaindropEveExporterOptions {
|
|
44
|
+
/**
|
|
45
|
+
* Raindrop write key. Required to ship to Raindrop's hosted endpoint; when
|
|
46
|
+
* omitted, the exporter still mirrors to Workshop (when one is reachable).
|
|
47
|
+
*/
|
|
48
|
+
writeKey?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Raindrop API endpoint. Defaults to `https://api.raindrop.ai/v1/`.
|
|
51
|
+
* Trailing slash optional; `/traces` is always appended.
|
|
52
|
+
*/
|
|
53
|
+
endpoint?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Workshop / local debugger URL. Pass `false` to opt out entirely. Pass a
|
|
56
|
+
* URL string to force-enable. Leave undefined to use env vars +
|
|
57
|
+
* auto-detect (`RAINDROP_WORKSHOP`, `RAINDROP_LOCAL_DEBUGGER`, localhost in
|
|
58
|
+
* development).
|
|
59
|
+
*/
|
|
60
|
+
localWorkshopUrl?: string | false;
|
|
61
|
+
/** Logical service name used as the OTel `service.name` resource attribute. */
|
|
62
|
+
serviceName?: string;
|
|
63
|
+
/** Service version (defaults to the eve SDK version). */
|
|
64
|
+
serviceVersion?: string;
|
|
65
|
+
/** SDK identifier used in log prefixes and User-Agent. */
|
|
66
|
+
sdkName?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Optional Raindrop project slug. When set, every cloud trace export carries
|
|
69
|
+
* an `X-Raindrop-Project-Id` header. Empty / whitespace-only values are
|
|
70
|
+
* ignored. Unset → no header (byte-identical to prior behavior).
|
|
71
|
+
*/
|
|
72
|
+
projectId?: string;
|
|
73
|
+
/** Print extra logs while exporting / mirroring. */
|
|
74
|
+
debug?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Per-attribute character cap for exported string attribute values
|
|
77
|
+
* (truncated values end with `...[truncated by raindrop]`). Enforced
|
|
78
|
+
* before the OTLP batch is serialized so multi-MB prompt/completion
|
|
79
|
+
* attributes cost the cap — not the payload — and land truncated instead
|
|
80
|
+
* of being dropped at the ingest size limit. A stricter
|
|
81
|
+
* `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored.
|
|
82
|
+
* Defaults to 1,000,000.
|
|
83
|
+
*/
|
|
84
|
+
maxTextFieldChars?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* SpanExporter implementation that posts spans to Raindrop's OTLP/HTTP JSON
|
|
88
|
+
* endpoint and (optionally) mirrors to a local Workshop daemon.
|
|
89
|
+
*/
|
|
90
|
+
declare class RaindropEveSpanExporter {
|
|
91
|
+
private readonly writeKey;
|
|
92
|
+
private readonly baseUrl;
|
|
93
|
+
private readonly localDebuggerUrl;
|
|
94
|
+
private serviceName;
|
|
95
|
+
private readonly serviceVersion;
|
|
96
|
+
private readonly sdkName;
|
|
97
|
+
private readonly projectId;
|
|
98
|
+
private readonly debug;
|
|
99
|
+
private readonly prefix;
|
|
100
|
+
private readonly maxTextFieldChars;
|
|
101
|
+
private inFlight;
|
|
102
|
+
private shuttingDown;
|
|
103
|
+
private auxShutdowns;
|
|
104
|
+
constructor(opts?: RaindropEveExporterOptions);
|
|
105
|
+
/** True when we have at least one destination (Raindrop or Workshop). */
|
|
106
|
+
hasDestinations(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Update the OTLP `service.name` attribute. Called by Eve's
|
|
109
|
+
* `setup({ agentName })` so the resource attribute reflects the actual
|
|
110
|
+
* agent name when the caller didn't pin one via `opts.serviceName`.
|
|
111
|
+
*/
|
|
112
|
+
setServiceName(serviceName: string): void;
|
|
113
|
+
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
114
|
+
forceFlush(): Promise<void>;
|
|
115
|
+
shutdown(): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Register an extra teardown hook to run during {@link shutdown}. Used to
|
|
118
|
+
* drain the AI SDK trace + event shippers that the `@raindrop-ai/eve`
|
|
119
|
+
* integration builds alongside this exporter — without this, pending
|
|
120
|
+
* `track_partial` events and AI SDK trace spans would be dropped on
|
|
121
|
+
* SIGINT / SIGTERM.
|
|
122
|
+
*/
|
|
123
|
+
attachAuxShutdown(fn: () => Promise<void>): void;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare const RAINDROP_EVE_SDK_NAME: string;
|
|
127
|
+
declare const RAINDROP_EVE_SDK_VERSION: string;
|
|
128
|
+
/**
|
|
129
|
+
* Test-only: clear the per-session canonical turn-id cache between cases so a
|
|
130
|
+
* session id reused across tests doesn't inherit a previous test's turn id.
|
|
131
|
+
*/
|
|
132
|
+
declare function _resetCanonicalTurnIds(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Signature of `registerOTel` from `@vercel/otel`. Re-exported via the
|
|
135
|
+
* package's own type so consumers don't have to import the type themselves
|
|
136
|
+
* and we don't take a runtime dependency on the package.
|
|
137
|
+
*/
|
|
138
|
+
type RegisterOTelFn = typeof _vercel_otel.registerOTel;
|
|
139
|
+
/**
|
|
140
|
+
* A single bag of author-supplied metadata, mirroring Eve 0.45's
|
|
141
|
+
* `InstrumentationMetadata` (`Readonly<Record<string, string>>`). Keys
|
|
142
|
+
* beginning with `eve.` are reserved by Eve and dropped if returned.
|
|
143
|
+
*/
|
|
144
|
+
type RaindropEveInstrumentationMetadata = Readonly<Record<string, string>>;
|
|
145
|
+
/**
|
|
146
|
+
* The channel projection Eve exposes to instrumentation callbacks. `kind` is
|
|
147
|
+
* the channel identity Eve has for the current turn (`"http"`, `"schedule"`,
|
|
148
|
+
* `"subagent"`, `"unknown"`, or `channel:<name>` for authored channels);
|
|
149
|
+
* `metadata` is the channel's metadata snapshot (e.g. Slack `channelId` /
|
|
150
|
+
* `teamId` / `threadTs` / `triggeringUserId`).
|
|
151
|
+
*
|
|
152
|
+
* Typed structurally so `@raindrop-ai/eve` doesn't take a hard dependency on
|
|
153
|
+
* `eve`'s types (it's an optional peer). Cast `metadata` values
|
|
154
|
+
* to the concrete channel shape inside your callback when you need narrowing.
|
|
155
|
+
*/
|
|
156
|
+
interface RaindropEveInstrumentationChannel {
|
|
157
|
+
readonly kind: string;
|
|
158
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
159
|
+
}
|
|
160
|
+
interface RaindropEveInstrumentationSession {
|
|
161
|
+
readonly auth: {
|
|
162
|
+
readonly current: unknown;
|
|
163
|
+
readonly initiator: unknown;
|
|
164
|
+
};
|
|
165
|
+
readonly id: string;
|
|
166
|
+
readonly parent?: unknown;
|
|
167
|
+
}
|
|
168
|
+
interface RaindropEveInstrumentationTurn {
|
|
169
|
+
readonly id: string;
|
|
170
|
+
readonly sequence: number;
|
|
171
|
+
}
|
|
172
|
+
interface RaindropEveInstrumentationStep {
|
|
173
|
+
readonly index: number;
|
|
174
|
+
}
|
|
175
|
+
interface RaindropEveInstrumentationModelInput {
|
|
176
|
+
readonly instructions: string | readonly unknown[] | undefined;
|
|
177
|
+
readonly messages: readonly unknown[];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Input passed to the `step.started` hook. Identical across Eve 0.45's
|
|
181
|
+
* `metadata["step.started"]` and Eve 0.53's `events["step.started"]`:
|
|
182
|
+
* `session.id` is the current session id and `turn` is top-level. The callback
|
|
183
|
+
* runs after Eve has built the final model input for a model-call attempt and
|
|
184
|
+
* before the AI SDK model call is constructed, so the returned values are
|
|
185
|
+
* inherited by every child span the AI SDK creates for that step.
|
|
186
|
+
*/
|
|
187
|
+
interface RaindropEveStepStartedMetadataInput {
|
|
188
|
+
readonly channel: RaindropEveInstrumentationChannel;
|
|
189
|
+
readonly modelInput: RaindropEveInstrumentationModelInput;
|
|
190
|
+
readonly session: RaindropEveInstrumentationSession;
|
|
191
|
+
readonly step: RaindropEveInstrumentationStep;
|
|
192
|
+
readonly turn: RaindropEveInstrumentationTurn;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Alias for the `events["step.started"]` input on Eve 0.53+. The shape is the
|
|
196
|
+
* same as {@link RaindropEveStepStartedMetadataInput}; only the config key
|
|
197
|
+
* (`events` vs `metadata`) and the result wrapper (`{ runtimeContext }` vs a
|
|
198
|
+
* flat record) changed between 0.45 and 0.53.
|
|
199
|
+
*/
|
|
200
|
+
type RaindropEveStepStartedEventInput = RaindropEveStepStartedMetadataInput;
|
|
201
|
+
/**
|
|
202
|
+
* Eve 0.45–0.52's `InstrumentationMetadataConfig` — the callback-driven
|
|
203
|
+
* metadata hooks accepted by `defineInstrumentation`'s `metadata` field.
|
|
204
|
+
* Forwarded to Eve so the returned values land on AI SDK telemetry spans for
|
|
205
|
+
* the matching step. Superseded on Eve 0.53+ by
|
|
206
|
+
* {@link RaindropEveInstrumentationEventsConfig}; we emit both so a single
|
|
207
|
+
* definition works across the supported range.
|
|
208
|
+
*/
|
|
209
|
+
interface RaindropEveInstrumentationMetadataConfig {
|
|
210
|
+
/**
|
|
211
|
+
* Per-attempt metadata resolved before the model call so child spans
|
|
212
|
+
* created by the AI SDK inherit the returned values.
|
|
213
|
+
*/
|
|
214
|
+
readonly "step.started"?: (input: RaindropEveStepStartedMetadataInput) => RaindropEveInstrumentationMetadata;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Result returned by the Eve 0.53+ `events["step.started"]` hook. The authored
|
|
218
|
+
* runtime context is merged into the AI SDK telemetry spans for the step. Keys
|
|
219
|
+
* beginning with `eve.` are reserved by Eve and dropped, so author `raindrop.*`
|
|
220
|
+
* keys only.
|
|
221
|
+
*/
|
|
222
|
+
interface RaindropEveStepStartedEventResult {
|
|
223
|
+
readonly runtimeContext: RaindropEveInstrumentationMetadata;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Eve 0.53+'s `InstrumentationEvents` — the callback-driven event hooks
|
|
227
|
+
* accepted by `defineInstrumentation`'s `events` field. The forward-looking
|
|
228
|
+
* shape consumers should prefer on Eve 0.53+. The callback returns
|
|
229
|
+
* `{ runtimeContext }` rather than the flat record the 0.45 `metadata` hook
|
|
230
|
+
* used.
|
|
231
|
+
*/
|
|
232
|
+
interface RaindropEveInstrumentationEventsConfig {
|
|
233
|
+
/**
|
|
234
|
+
* Per-attempt runtime context resolved before the model call so child spans
|
|
235
|
+
* created by the AI SDK inherit the returned values.
|
|
236
|
+
*/
|
|
237
|
+
readonly "step.started"?: (input: RaindropEveStepStartedEventInput) => RaindropEveStepStartedEventResult | undefined;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Options for {@link defineRaindropInstrumentation}.
|
|
241
|
+
*/
|
|
242
|
+
interface RaindropEveInstrumentationOptions {
|
|
243
|
+
/**
|
|
244
|
+
* `registerOTel` from `@vercel/otel`. Pass the function directly so the
|
|
245
|
+
* SDK doesn't have to dynamically import a peer dep at runtime.
|
|
246
|
+
*
|
|
247
|
+
* Optional only because tests and advanced wiring may pre-register OTel
|
|
248
|
+
* elsewhere; in a normal Eve project you should always pass this.
|
|
249
|
+
*/
|
|
250
|
+
registerOTel?: RegisterOTelFn;
|
|
251
|
+
/**
|
|
252
|
+
* Raindrop write key. Required to ship traces to Raindrop's hosted endpoint.
|
|
253
|
+
* When omitted, the integration still mirrors to Workshop if one is
|
|
254
|
+
* reachable — useful for local development without a hosted account.
|
|
255
|
+
*
|
|
256
|
+
* Falls back to `process.env.RAINDROP_WRITE_KEY` when undefined.
|
|
257
|
+
*/
|
|
258
|
+
writeKey?: string;
|
|
259
|
+
/**
|
|
260
|
+
* Raindrop API endpoint. Defaults to `https://api.raindrop.ai/v1/`.
|
|
261
|
+
* Falls back to `process.env.RAINDROP_ENDPOINT` when undefined.
|
|
262
|
+
*/
|
|
263
|
+
endpoint?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Optional Raindrop project slug. When set, every outbound cloud request
|
|
266
|
+
* (trace exports and the AI SDK event/trace shippers) carries an
|
|
267
|
+
* `X-Raindrop-Project-Id` header. Unset → no header (the project resolves to
|
|
268
|
+
* `default` server-side; byte-identical to prior behavior). Falls back to
|
|
269
|
+
* `process.env.RAINDROP_PROJECT_ID` when undefined.
|
|
270
|
+
*/
|
|
271
|
+
projectId?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Workshop / local debugger URL.
|
|
274
|
+
*
|
|
275
|
+
* - `string` — force-enable mirroring to that URL.
|
|
276
|
+
* - `false` — opt out of mirroring entirely (no env vars, no auto-detect).
|
|
277
|
+
* - `undefined` — use the standard precedence: `RAINDROP_WORKSHOP` /
|
|
278
|
+
* `RAINDROP_LOCAL_DEBUGGER` env vars, then auto-detect during local
|
|
279
|
+
* development (localhost hostname or `NODE_ENV=development`).
|
|
280
|
+
*/
|
|
281
|
+
localWorkshopUrl?: string | false;
|
|
282
|
+
/**
|
|
283
|
+
* OTel `service.name`. Defaults to the agent name resolved by Eve at compile
|
|
284
|
+
* time, so you rarely need to set this.
|
|
285
|
+
*/
|
|
286
|
+
serviceName?: string;
|
|
287
|
+
/**
|
|
288
|
+
* Override the OTel `service.version` resource attribute.
|
|
289
|
+
*/
|
|
290
|
+
serviceVersion?: string;
|
|
291
|
+
/**
|
|
292
|
+
* Forwarded to Eve: override the function identifier attached to AI SDK
|
|
293
|
+
* spans. Defaults to the agent name.
|
|
294
|
+
*/
|
|
295
|
+
functionId?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Eve 0.45 `InstrumentationMetadataConfig` — callback-driven metadata
|
|
298
|
+
* forwarded *verbatim* to Eve so the values it returns land on the AI SDK
|
|
299
|
+
* telemetry spans for the matching step. Use this for per-turn/per-step
|
|
300
|
+
* dynamic metadata sourced from the live request (e.g. Slack
|
|
301
|
+
* `channelId` / `teamId` / `threadTs` / `triggeringUserId` off
|
|
302
|
+
* `input.channel.metadata`):
|
|
303
|
+
*
|
|
304
|
+
* ```ts
|
|
305
|
+
* defineRaindropInstrumentation({
|
|
306
|
+
* staticMetadata: { app: "demo-data-agent", team: "data" },
|
|
307
|
+
* metadata: {
|
|
308
|
+
* "step.started"(input) {
|
|
309
|
+
* return {
|
|
310
|
+
* "slack.channel_id": String(input.channel.metadata.channelId ?? ""),
|
|
311
|
+
* "raindrop.userId": String(input.channel.metadata.triggeringUserId ?? ""),
|
|
312
|
+
* };
|
|
313
|
+
* },
|
|
314
|
+
* },
|
|
315
|
+
* });
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* The `step.started` callback is handed to Eve as instrumentation metadata
|
|
319
|
+
* and is **never** iterated as static authored metadata by this helper.
|
|
320
|
+
*
|
|
321
|
+
* For backwards compatibility a flat `Record<string, string>` is still
|
|
322
|
+
* accepted and treated exactly like {@link staticMetadata}; prefer
|
|
323
|
+
* `staticMetadata` for static values and reserve `metadata` for the Eve
|
|
324
|
+
* callback config.
|
|
325
|
+
*/
|
|
326
|
+
metadata?: RaindropEveInstrumentationMetadataConfig | Record<string, string>;
|
|
327
|
+
/**
|
|
328
|
+
* Eve 0.53+ `events` config. The forward-looking equivalent of
|
|
329
|
+
* {@link metadata}'s `step.started` callback: the hook returns
|
|
330
|
+
* `{ runtimeContext }` instead of a flat record. Prefer this on Eve 0.53+.
|
|
331
|
+
*
|
|
332
|
+
* When both {@link events} and {@link metadata} supply a `step.started`
|
|
333
|
+
* hook, `events` wins. Whichever is provided is forwarded on BOTH the
|
|
334
|
+
* definition's `events` (read by Eve 0.53+) and `metadata` (read by Eve
|
|
335
|
+
* 0.45–0.52) fields, so a single config works across the supported range.
|
|
336
|
+
*/
|
|
337
|
+
events?: RaindropEveInstrumentationEventsConfig;
|
|
338
|
+
/**
|
|
339
|
+
* Static Raindrop metadata merged onto every shipped Raindrop event /
|
|
340
|
+
* telemetry span. Unlike {@link metadata}'s `step.started` callback, these
|
|
341
|
+
* values are authored once and applied by the Raindrop helper itself
|
|
342
|
+
* (routed through `raindrop.properties` / `raindrop.*` control keys the
|
|
343
|
+
* same way the legacy flat `metadata` option was). Use this for stable
|
|
344
|
+
* attributes like `app` / `team` / `environment`.
|
|
345
|
+
*/
|
|
346
|
+
staticMetadata?: Record<string, string>;
|
|
347
|
+
/**
|
|
348
|
+
* Default `userId` attached to every Raindrop event shipped from this
|
|
349
|
+
* agent. The integration won't emit a `track_partial` event unless it has
|
|
350
|
+
* a `userId`, so leave this populated if you want the run to show up in
|
|
351
|
+
* Workshop's Overview tab and in the Raindrop dashboard's event feed.
|
|
352
|
+
*
|
|
353
|
+
* When omitted, the SDK uses Eve's session id (`eve.session.id`) when it
|
|
354
|
+
* can resolve one per call, and falls back to the agent name otherwise.
|
|
355
|
+
*/
|
|
356
|
+
userId?: string;
|
|
357
|
+
/**
|
|
358
|
+
* Default `eventName` for shipped events. Defaults to the AI SDK
|
|
359
|
+
* `operationId` (e.g. `"ai.streamText"`); usually you'd set this to
|
|
360
|
+
* something user-meaningful like `"agent.turn"`.
|
|
361
|
+
*/
|
|
362
|
+
eventName?: string;
|
|
363
|
+
/**
|
|
364
|
+
* Forwarded to Eve: whether to record full model inputs in spans. Defaults
|
|
365
|
+
* to Eve's own default (`true` when instrumentation is configured).
|
|
366
|
+
*/
|
|
367
|
+
recordInputs?: boolean;
|
|
368
|
+
/**
|
|
369
|
+
* Forwarded to Eve: whether to record full model outputs in spans. Defaults
|
|
370
|
+
* to Eve's own default (`true` when instrumentation is configured).
|
|
371
|
+
*/
|
|
372
|
+
recordOutputs?: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Print extra logs while exporting / mirroring spans. Also enabled by
|
|
375
|
+
* `RAINDROP_AI_DEBUG=1` in the environment.
|
|
376
|
+
*/
|
|
377
|
+
debug?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Per-attribute character cap for exported string span attributes
|
|
380
|
+
* (truncated values end with `...[truncated by raindrop]`). Multi-MB
|
|
381
|
+
* prompt/completion attributes are capped before OTLP serialization so
|
|
382
|
+
* they cost the cap — not the payload — and land truncated instead of
|
|
383
|
+
* being dropped at the ingest size limit. A stricter
|
|
384
|
+
* `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored.
|
|
385
|
+
* Defaults to 1,000,000.
|
|
386
|
+
*/
|
|
387
|
+
maxTextFieldChars?: number;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* The shape returned by {@link defineRaindropInstrumentation}. It matches Eve's
|
|
391
|
+
* `InstrumentationDefinition` so it can be the default export of
|
|
392
|
+
* `agent/instrumentation.ts`.
|
|
393
|
+
*/
|
|
394
|
+
interface RaindropInstrumentationDefinition {
|
|
395
|
+
readonly functionId?: string;
|
|
396
|
+
/**
|
|
397
|
+
* Eve 0.45–0.52 reads the `step.started` hook from here. Always populated
|
|
398
|
+
* (the default hook pushes cross-sandbox sub-agent lineage) when running on
|
|
399
|
+
* those versions.
|
|
400
|
+
*/
|
|
401
|
+
readonly metadata?: RaindropEveInstrumentationMetadataConfig;
|
|
402
|
+
/**
|
|
403
|
+
* Eve 0.53+ reads the `step.started` hook from here instead of `metadata`.
|
|
404
|
+
* Always populated; carries the same lineage + static + author metadata as
|
|
405
|
+
* `metadata`, just wrapped in `{ runtimeContext }`.
|
|
406
|
+
*/
|
|
407
|
+
readonly events?: RaindropEveInstrumentationEventsConfig;
|
|
408
|
+
readonly recordInputs?: boolean;
|
|
409
|
+
readonly recordOutputs?: boolean;
|
|
410
|
+
readonly setup: (context: {
|
|
411
|
+
agentName: string;
|
|
412
|
+
}) => void;
|
|
413
|
+
/** The underlying exporter — exported for tests and advanced wiring. */
|
|
414
|
+
readonly exporter: RaindropEveSpanExporter;
|
|
415
|
+
/**
|
|
416
|
+
* The Raindrop AI SDK client backing this instrumentation. Use it from
|
|
417
|
+
* application / tool code to:
|
|
418
|
+
* - `raindrop.users.identify(...)` to attach traits to the active user
|
|
419
|
+
* - `raindrop.signals.track(...)` to record feedback / programmatic signals
|
|
420
|
+
* - `raindrop.events.patch(...)` / `.finish(...)` / `.addAttachments(...)`
|
|
421
|
+
* for fine-grained event updates
|
|
422
|
+
* - `raindrop.traces.startSpan(...)` / `.createSpan(...)` for custom spans
|
|
423
|
+
* - `raindrop.flush()` / `raindrop.shutdown()` for explicit lifecycle control
|
|
424
|
+
*
|
|
425
|
+
* `raindrop.shutdown()` is already wired into the OTel exporter's shutdown
|
|
426
|
+
* lifecycle, so most callers don't need to invoke it themselves.
|
|
427
|
+
*/
|
|
428
|
+
readonly raindrop: RaindropAISDKClient;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Build a Raindrop-flavored Eve instrumentation definition.
|
|
432
|
+
*
|
|
433
|
+
* `agent/instrumentation.ts`:
|
|
434
|
+
*
|
|
435
|
+
* ```ts
|
|
436
|
+
* import { defineRaindropInstrumentation } from "@raindrop-ai/eve";
|
|
437
|
+
*
|
|
438
|
+
* export default defineRaindropInstrumentation({
|
|
439
|
+
* writeKey: process.env.RAINDROP_WRITE_KEY,
|
|
440
|
+
* staticMetadata: { team: "support" },
|
|
441
|
+
* events: {
|
|
442
|
+
* "step.started"(input) {
|
|
443
|
+
* return {
|
|
444
|
+
* runtimeContext: {
|
|
445
|
+
* "slack.channel_id": String(input.channel.metadata.channelId ?? ""),
|
|
446
|
+
* },
|
|
447
|
+
* };
|
|
448
|
+
* },
|
|
449
|
+
* },
|
|
450
|
+
* });
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
declare function defineRaindropInstrumentation(opts?: RaindropEveInstrumentationOptions): RaindropInstrumentationDefinition;
|
|
454
|
+
|
|
455
|
+
export { RAINDROP_EVE_SDK_NAME, RAINDROP_EVE_SDK_VERSION, type RaindropEveExporterOptions, type RaindropEveInstrumentationChannel, type RaindropEveInstrumentationEventsConfig, type RaindropEveInstrumentationMetadata, type RaindropEveInstrumentationMetadataConfig, type RaindropEveInstrumentationModelInput, type RaindropEveInstrumentationOptions, type RaindropEveInstrumentationSession, type RaindropEveInstrumentationStep, type RaindropEveInstrumentationTurn, RaindropEveSpanExporter, type RaindropEveStepStartedEventInput, type RaindropEveStepStartedEventResult, type RaindropEveStepStartedMetadataInput, type RaindropInstrumentationDefinition, type RegisterOTelFn, _resetCanonicalTurnIds, defineRaindropInstrumentation as default, defineRaindropInstrumentation };
|