@runtypelabs/flue-otel 0.5.4 → 0.5.6
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.cjs +1289 -1138
- package/dist/index.d.cts +318 -312
- package/dist/index.d.ts +318 -312
- package/dist/index.mjs +1276 -1107
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { Tracer } from
|
|
2
|
-
|
|
1
|
+
import { Tracer } from "@opentelemetry/api";
|
|
2
|
+
//#region src/flue-types.d.ts
|
|
3
3
|
/** Correlation fields stamped onto every delivered observation. */
|
|
4
4
|
interface FlueEventEnvelope {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
/** Durable event-format version. `3` on both supported lines. */
|
|
6
|
+
v?: number;
|
|
7
|
+
eventIndex?: number;
|
|
8
|
+
timestamp?: string;
|
|
9
|
+
instanceId?: string;
|
|
10
|
+
submissionId?: string;
|
|
11
|
+
agentName?: string;
|
|
12
|
+
conversationId?: string;
|
|
13
|
+
session?: string;
|
|
14
|
+
parentSession?: string;
|
|
15
|
+
taskId?: string;
|
|
16
|
+
harness?: string;
|
|
17
|
+
operationId?: string;
|
|
18
|
+
turnId?: string;
|
|
19
19
|
}
|
|
20
20
|
/** Token counts and cost for one model turn. Byte-identical on both lines. */
|
|
21
21
|
interface FluePromptUsage {
|
|
22
|
+
input: number;
|
|
23
|
+
output: number;
|
|
24
|
+
cacheRead: number;
|
|
25
|
+
cacheWrite: number;
|
|
26
|
+
totalTokens: number;
|
|
27
|
+
cost?: {
|
|
22
28
|
input: number;
|
|
23
29
|
output: number;
|
|
24
30
|
cacheRead: number;
|
|
25
31
|
cacheWrite: number;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
input: number;
|
|
29
|
-
output: number;
|
|
30
|
-
cacheRead: number;
|
|
31
|
-
cacheWrite: number;
|
|
32
|
-
total: number;
|
|
33
|
-
};
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
34
|
}
|
|
35
35
|
/** The non-content half of a model request. */
|
|
36
36
|
interface FlueModelRequestInfo {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
providerId?: string;
|
|
38
|
+
providerName?: string;
|
|
39
|
+
requestedModel?: string;
|
|
40
|
+
api?: string;
|
|
41
|
+
serverAddress?: string;
|
|
42
|
+
serverPort?: number;
|
|
43
|
+
reasoningLevel?: string;
|
|
44
|
+
maxTokens?: number;
|
|
45
|
+
temperature?: number;
|
|
46
|
+
contextCompacted?: true;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* The request's payload half. `tools` is read for its PRESENCE only (`runtype.tools.reported`).
|
|
@@ -51,41 +51,41 @@ interface FlueModelRequestInfo {
|
|
|
51
51
|
* byte-identical on both lines, read only when message content is opted in — see `messages.ts`.
|
|
52
52
|
*/
|
|
53
53
|
interface FlueModelRequestInput {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
systemPrompt?: string;
|
|
55
|
+
messages?: unknown[];
|
|
56
|
+
tools?: unknown[];
|
|
57
57
|
}
|
|
58
58
|
interface FlueModelRequest extends FlueModelRequestInfo {
|
|
59
|
-
|
|
59
|
+
input?: FlueModelRequestInput;
|
|
60
60
|
}
|
|
61
61
|
interface FlueModelResponse {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
responseId?: string;
|
|
63
|
+
responseModel?: string;
|
|
64
|
+
/** The assistant message this turn produced, in Flue's normalized `LlmAssistantMessage` shape. */
|
|
65
|
+
output?: unknown;
|
|
66
|
+
usage?: FluePromptUsage;
|
|
67
|
+
finishReason?: string;
|
|
68
|
+
/** 2.x only. The provider's raw finish value before normalization. */
|
|
69
|
+
providerFinishReason?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The response's own gateway log id (e.g. Cloudflare AI Gateway's
|
|
72
|
+
* `cf-aig-log-id`), for correlating a specific turn with its entry in the
|
|
73
|
+
* gateway dashboard. Telemetry only — present only when the provider records
|
|
74
|
+
* one. The Workers AI provider attaches it today.
|
|
75
|
+
*/
|
|
76
|
+
gatewayLogId?: string;
|
|
77
|
+
error?: FlueErrorInfo;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Classified error details. stack is described but never read or exported because it can expose
|
|
81
81
|
* deployment paths.
|
|
82
82
|
*/
|
|
83
83
|
interface FlueErrorInfo {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
type?: string;
|
|
85
|
+
name?: string;
|
|
86
|
+
message?: string;
|
|
87
|
+
stack?: string;
|
|
88
|
+
meta?: Record<string, unknown>;
|
|
89
89
|
}
|
|
90
90
|
/** 1.x-only implementation-class axis; absent on 2.x. */
|
|
91
91
|
type FlueToolSemanticType = 'function' | 'extension' | 'datastore';
|
|
@@ -96,10 +96,10 @@ type FlueToolOrigin = 'model' | 'caller' | 'framework' | 'adapter';
|
|
|
96
96
|
* `toolType` exists only on 1.x, which is what `compat.ts` probes for.
|
|
97
97
|
*/
|
|
98
98
|
interface FlueObservationDetail {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
origin?: FlueToolOrigin;
|
|
100
|
+
toolType?: FlueToolSemanticType;
|
|
101
|
+
toolCallId?: string;
|
|
102
|
+
errorInfo?: FlueErrorInfo;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* The event variants this package acts on. Every other variant Flue emits is
|
|
@@ -107,69 +107,69 @@ interface FlueObservationDetail {
|
|
|
107
107
|
* through the projection's switch untouched.
|
|
108
108
|
*/
|
|
109
109
|
type FlueEventVariant = {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
type: 'operation_start';
|
|
111
|
+
operationId: string;
|
|
112
|
+
operationKind: string;
|
|
113
113
|
} | {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
type: 'operation';
|
|
115
|
+
operationId: string;
|
|
116
|
+
operationKind: string;
|
|
117
|
+
durationMs?: number;
|
|
118
|
+
isError?: boolean;
|
|
119
|
+
error?: unknown;
|
|
120
|
+
usage?: FluePromptUsage;
|
|
121
121
|
} | {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
type: 'task_start';
|
|
123
|
+
taskId: string;
|
|
124
|
+
prompt?: string;
|
|
125
|
+
agent?: string;
|
|
126
126
|
} | {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
type: 'task';
|
|
128
|
+
taskId: string;
|
|
129
|
+
agent?: string;
|
|
130
|
+
isError?: boolean;
|
|
131
|
+
result?: unknown;
|
|
132
132
|
} | {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
type: 'compaction_start';
|
|
134
|
+
reason?: string;
|
|
135
|
+
estimatedTokens?: number;
|
|
136
136
|
} | {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
type: 'compaction';
|
|
138
|
+
isError?: boolean;
|
|
139
|
+
error?: unknown;
|
|
140
|
+
usage?: FluePromptUsage;
|
|
141
141
|
} | {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
type: 'turn_request';
|
|
143
|
+
turnId: string;
|
|
144
|
+
purpose?: string;
|
|
145
|
+
request: FlueModelRequest;
|
|
146
146
|
} | {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
type: 'turn';
|
|
148
|
+
turnId: string;
|
|
149
|
+
purpose?: string;
|
|
150
|
+
durationMs?: number;
|
|
151
|
+
request?: FlueModelRequestInfo;
|
|
152
|
+
response: FlueModelResponse;
|
|
153
|
+
isError?: boolean;
|
|
154
154
|
} | {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
type: 'tool_start';
|
|
156
|
+
toolName: string;
|
|
157
|
+
toolCallId: string;
|
|
158
|
+
args?: unknown;
|
|
159
159
|
} | {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
type: 'tool';
|
|
161
|
+
toolName: string;
|
|
162
|
+
toolCallId: string;
|
|
163
|
+
isError?: boolean;
|
|
164
|
+
result?: unknown;
|
|
165
|
+
effectiveResult?: unknown;
|
|
166
|
+
durationMs?: number;
|
|
167
167
|
} | {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
type: 'submission_settled';
|
|
169
|
+
submissionId: string;
|
|
170
|
+
outcome: string;
|
|
171
171
|
} | {
|
|
172
|
-
|
|
172
|
+
type: string;
|
|
173
173
|
};
|
|
174
174
|
/** One delivered observation: an event, its envelope, and its detail sidecar. */
|
|
175
175
|
type FlueObservation = FlueEventVariant & FlueEventEnvelope & FlueObservationDetail;
|
|
@@ -178,50 +178,50 @@ type FlueObservation = FlueEventVariant & FlueEventEnvelope & FlueObservationDet
|
|
|
178
178
|
* matters here — the fields this package needs all live on the envelope.
|
|
179
179
|
*/
|
|
180
180
|
interface FlueEventContext {
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
readonly id?: string;
|
|
182
|
+
readonly agentName?: string;
|
|
183
183
|
}
|
|
184
184
|
/** W3C trace context offered by the host on a detached execution. */
|
|
185
185
|
interface FlueTraceCarrier {
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
traceparent: string;
|
|
187
|
+
tracestate?: string;
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
190
|
* The operation the interceptor wraps. `coordinator` exists on 2.x only; the
|
|
191
191
|
* open arm makes an unknown future kind fall through rather than crash.
|
|
192
192
|
*/
|
|
193
193
|
type FlueExecutionOperation = {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
type: 'agent';
|
|
195
|
+
operationId: string;
|
|
196
|
+
operationKind?: string;
|
|
197
197
|
} | {
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
type: 'model';
|
|
199
|
+
turnId: string;
|
|
200
200
|
} | {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
type: 'tool';
|
|
202
|
+
toolCallId: string;
|
|
203
|
+
toolName?: string;
|
|
204
204
|
} | {
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
type: 'task';
|
|
206
|
+
taskId: string;
|
|
207
207
|
} | {
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
type: 'coordinator';
|
|
209
|
+
phase?: string;
|
|
210
210
|
} | {
|
|
211
|
-
|
|
211
|
+
type: string;
|
|
212
212
|
};
|
|
213
213
|
interface FlueExecutionContext {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
214
|
+
eventContext?: FlueEventContext;
|
|
215
|
+
instanceId?: string;
|
|
216
|
+
submissionId?: string;
|
|
217
|
+
agentName?: string;
|
|
218
|
+
conversationId?: string;
|
|
219
|
+
harness?: string;
|
|
220
|
+
session?: string;
|
|
221
|
+
operationId?: string;
|
|
222
|
+
turnId?: string;
|
|
223
|
+
taskId?: string;
|
|
224
|
+
traceCarrier?: FlueTraceCarrier;
|
|
225
225
|
}
|
|
226
226
|
type FlueObservationSubscriber = (observation: FlueObservation, ctx: FlueEventContext) => void | Promise<void>;
|
|
227
227
|
type FlueExecutionInterceptor = <T>(operation: FlueExecutionOperation, ctx: FlueExecutionContext, next: () => Promise<T>) => Promise<T>;
|
|
@@ -231,67 +231,69 @@ type FlueExecutionInterceptor = <T>(operation: FlueExecutionOperation, ctx: Flue
|
|
|
231
231
|
* one of these.
|
|
232
232
|
*/
|
|
233
233
|
interface FlueInstrumentation {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
key?: symbol;
|
|
235
|
+
observe: FlueObservationSubscriber;
|
|
236
|
+
interceptor: FlueExecutionInterceptor;
|
|
237
|
+
dispose(): void | Promise<void>;
|
|
238
238
|
}
|
|
239
|
-
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/messages.d.ts
|
|
240
241
|
/**
|
|
241
242
|
* One semconv structured message, the element shape of `gen_ai.input.messages`
|
|
242
243
|
* and `gen_ai.output.messages`. Text parts only; see the README's content section.
|
|
243
244
|
*/
|
|
244
245
|
interface FlueContentMessage {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
role: 'system' | 'user' | 'assistant';
|
|
247
|
+
parts: Array<{
|
|
248
|
+
type: 'text';
|
|
249
|
+
content: string;
|
|
250
|
+
}>;
|
|
250
251
|
}
|
|
251
|
-
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/content.d.ts
|
|
252
254
|
/**
|
|
253
255
|
* What to emit. Every switch defaults to ON, so `{}` and an absent option both
|
|
254
256
|
* emit everything; set a switch to `false` to drop that one kind, or pass
|
|
255
257
|
* `content: false` to emit no content at all.
|
|
256
258
|
*/
|
|
257
259
|
interface FlueContentOptions {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
260
|
+
/**
|
|
261
|
+
* Emit the call's arguments as `gen_ai.tool.call.arguments` when the
|
|
262
|
+
* `execute_tool` span opens. Read from Flue's stable `tool_start.args`.
|
|
263
|
+
*/
|
|
264
|
+
toolArguments?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Emit successful tool results when the span closes; failed-tool payloads stay off the wire. Prefer
|
|
267
|
+
* effectiveResult when present, including undefined; otherwise use result.
|
|
268
|
+
*/
|
|
269
|
+
toolResults?: boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Emit the conversation the run was given as `gen_ai.input.messages` on the `invoke_agent` span:
|
|
272
|
+
* text-only user and assistant rows from Flue's normalized `turn_request.request.input.messages`,
|
|
273
|
+
* plus any user message a later turn's history carries, minus the run's own assistant rows.
|
|
274
|
+
*/
|
|
275
|
+
inputMessages?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Emit the run's final assistant text as `gen_ai.output.messages` on the `invoke_agent` span, read
|
|
278
|
+
* from the last agent turn whose `turn.response.output` carried text.
|
|
279
|
+
*/
|
|
280
|
+
outputMessages?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Emit the system prompt as `gen_ai.system_instructions` on the `invoke_agent` span, read from
|
|
283
|
+
* `turn_request.request.input.systemPrompt`. Usually the largest value a run carries; mind `maxChars`.
|
|
284
|
+
*/
|
|
285
|
+
systemInstructions?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Per-value UTF-16 code-unit ceiling, including the truncation marker. Defaults to
|
|
288
|
+
* DEFAULT_CONTENT_MAX_CHARS and clamps to INGEST_CONTENT_ATTRIBUTE_CEILING, above which ingest drops
|
|
289
|
+
* the whole attribute.
|
|
290
|
+
*/
|
|
291
|
+
maxChars?: number;
|
|
292
|
+
/**
|
|
293
|
+
* Redact the raw value before encoding or truncation. Returning undefined or throwing suppresses only
|
|
294
|
+
* this attribute, not the span.
|
|
295
|
+
*/
|
|
296
|
+
redact?: (value: unknown, context: FlueContentRedactContext) => unknown;
|
|
295
297
|
}
|
|
296
298
|
/**
|
|
297
299
|
* What `redact` is looking at. Tool kinds receive the raw Flue payload; `input_messages` and
|
|
@@ -299,11 +301,11 @@ interface FlueContentOptions {
|
|
|
299
301
|
* receives the prompt string.
|
|
300
302
|
*/
|
|
301
303
|
type FlueContentRedactContext = {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
kind: 'arguments' | 'result';
|
|
305
|
+
toolName: string;
|
|
304
306
|
} | {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
+
kind: 'input_messages' | 'output_messages' | 'system_instructions';
|
|
308
|
+
toolName?: undefined;
|
|
307
309
|
};
|
|
308
310
|
type FlueMessageContentKind = 'input_messages' | 'output_messages';
|
|
309
311
|
/**
|
|
@@ -312,73 +314,74 @@ type FlueMessageContentKind = 'input_messages' | 'output_messages';
|
|
|
312
314
|
* arguments plus result on one span sit well inside ingest's 384 KiB per-span
|
|
313
315
|
* ceiling — a customer who raises it should know that ceiling exists.
|
|
314
316
|
*/
|
|
315
|
-
declare const DEFAULT_CONTENT_MAX_CHARS = 65536;
|
|
317
|
+
export declare const DEFAULT_CONTENT_MAX_CHARS = 65536;
|
|
316
318
|
/**
|
|
317
319
|
* Inline the private ingest per-attribute ceiling so npm installs need no private dependency.
|
|
318
320
|
* tests/contract.test.ts pins equality.
|
|
319
321
|
*/
|
|
320
|
-
declare const INGEST_CONTENT_ATTRIBUTE_CEILING = 262144;
|
|
322
|
+
export declare const INGEST_CONTENT_ATTRIBUTE_CEILING = 262144;
|
|
321
323
|
/** The resolved, always-complete policy the projection consults. */
|
|
322
324
|
type FlueContentSetting = FlueContentOptions | false;
|
|
323
|
-
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/projection.d.ts
|
|
324
327
|
/** Attribute values OTLP can carry. Deliberately narrower than OTel's type. */
|
|
325
328
|
type SpanAttributes = Record<string, string | number | boolean | string[]>;
|
|
326
329
|
/** Where a span sits relative to the process boundary. */
|
|
327
330
|
type ProjectedSpanKind = 'internal' | 'client';
|
|
328
331
|
interface OpenSpanIntent {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
332
|
+
kind: 'open';
|
|
333
|
+
/** Stable identity for the span; the driver keys its live-span map on it. */
|
|
334
|
+
ref: string;
|
|
335
|
+
name: string;
|
|
336
|
+
spanKind: ProjectedSpanKind;
|
|
337
|
+
/**
|
|
338
|
+
* The span this one nests under, when the projection knows it. Absent means
|
|
339
|
+
* "use whatever is active" — which, inside Flue's interceptor, is the
|
|
340
|
+
* enclosing span, so the driver's fallback repairs chains the correlation
|
|
341
|
+
* fields cannot express (a task nested inside another task, most notably).
|
|
342
|
+
*/
|
|
343
|
+
parentRef?: string;
|
|
344
|
+
/** Flue's own event timestamp, ISO-8601. Spans stay on the runtime's clock. */
|
|
345
|
+
startTime?: string;
|
|
346
|
+
attributes: SpanAttributes;
|
|
347
|
+
/**
|
|
348
|
+
* Drop bookkeeping spans without a parent: ingest could otherwise treat a host shell or compaction
|
|
349
|
+
* span as a phantom run envelope.
|
|
350
|
+
*/
|
|
351
|
+
requiresParent?: boolean;
|
|
349
352
|
}
|
|
350
353
|
interface UpdateSpanIntent {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
kind: 'update';
|
|
355
|
+
ref: string;
|
|
356
|
+
attributes: SpanAttributes;
|
|
354
357
|
}
|
|
355
358
|
interface CloseSpanIntent {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
359
|
+
kind: 'close';
|
|
360
|
+
ref: string;
|
|
361
|
+
endTime?: string;
|
|
362
|
+
/**
|
|
363
|
+
* Failure type and exception class only. Error messages and stacks can expose prompts or deployment
|
|
364
|
+
* paths and are excluded even when tool-content export is enabled.
|
|
365
|
+
*/
|
|
366
|
+
error?: {
|
|
367
|
+
type: string;
|
|
368
|
+
exceptionType?: string;
|
|
369
|
+
};
|
|
367
370
|
}
|
|
368
371
|
type SpanIntent = OpenSpanIntent | UpdateSpanIntent | CloseSpanIntent;
|
|
369
372
|
interface FlueProjectionOptions {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
373
|
+
/**
|
|
374
|
+
* Agent id by Flue agent name, stamped on the envelope. Resource attribution takes precedence;
|
|
375
|
+
* delegated subagents are not separate executions. Use runtypeFlueResourceAttributes for single-agent
|
|
376
|
+
* processes.
|
|
377
|
+
*/
|
|
378
|
+
agents?: Record<string, string>;
|
|
379
|
+
/**
|
|
380
|
+
* Content: tool arguments and results on `execute_tool` spans, messages and the system prompt on
|
|
381
|
+
* the `invoke_agent` envelope. All ON by default; set a switch to `false` to drop one kind, or
|
|
382
|
+
* `content: false` for none. See {@link FlueContentOptions} for the size ceiling and redaction hook.
|
|
383
|
+
*/
|
|
384
|
+
content?: FlueContentSetting;
|
|
382
385
|
}
|
|
383
386
|
/**
|
|
384
387
|
* Resource attributes for the customer's `Resource`. Exported rather than set
|
|
@@ -386,74 +389,75 @@ interface FlueProjectionOptions {
|
|
|
386
389
|
* processor, the exporter and the resource are all the application's, and a
|
|
387
390
|
* library that reached into them would fight whatever the customer already runs.
|
|
388
391
|
*/
|
|
389
|
-
declare function runtypeFlueResourceAttributes(resource?: {
|
|
390
|
-
|
|
392
|
+
export declare function runtypeFlueResourceAttributes(resource?: {
|
|
393
|
+
agentId?: string | null;
|
|
391
394
|
}): SpanAttributes;
|
|
392
|
-
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/semconv.d.ts
|
|
393
397
|
/**
|
|
394
398
|
* GenAI semantic-convention attribute names. Mirrors the subset of
|
|
395
399
|
* `packages/shared/src/gen-ai-semconv.ts` this instrumentation can populate
|
|
396
400
|
* from Flue's STABLE observation plane.
|
|
397
401
|
*/
|
|
398
|
-
declare const GEN_AI: {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
402
|
+
export declare const GEN_AI: {
|
|
403
|
+
readonly operationName: 'gen_ai.operation.name';
|
|
404
|
+
readonly providerName: 'gen_ai.provider.name';
|
|
405
|
+
readonly agentName: 'gen_ai.agent.name';
|
|
406
|
+
readonly conversationId: 'gen_ai.conversation.id';
|
|
407
|
+
readonly requestModel: 'gen_ai.request.model';
|
|
408
|
+
readonly responseModel: 'gen_ai.response.model';
|
|
409
|
+
readonly responseId: 'gen_ai.response.id';
|
|
410
|
+
readonly requestStream: 'gen_ai.request.stream';
|
|
411
|
+
readonly reasoningLevel: 'gen_ai.request.reasoning.level';
|
|
412
|
+
readonly maxTokens: 'gen_ai.request.max_tokens';
|
|
413
|
+
readonly temperature: 'gen_ai.request.temperature';
|
|
414
|
+
readonly finishReasons: 'gen_ai.response.finish_reasons';
|
|
415
|
+
readonly usageInputTokens: 'gen_ai.usage.input_tokens';
|
|
416
|
+
readonly usageOutputTokens: 'gen_ai.usage.output_tokens';
|
|
417
|
+
readonly usageCacheReadTokens: 'gen_ai.usage.cache_read.input_tokens';
|
|
418
|
+
readonly usageCacheCreationTokens: 'gen_ai.usage.cache_creation.input_tokens';
|
|
419
|
+
readonly toolName: 'gen_ai.tool.name';
|
|
420
|
+
readonly toolCallId: 'gen_ai.tool.call.id';
|
|
421
|
+
readonly toolType: 'gen_ai.tool.type';
|
|
422
|
+
readonly conversationCompacted: 'gen_ai.conversation.compacted';
|
|
423
|
+
readonly errorType: 'error.type';
|
|
424
|
+
readonly serverAddress: 'server.address';
|
|
425
|
+
readonly serverPort: 'server.port';
|
|
422
426
|
};
|
|
423
427
|
/**
|
|
424
428
|
* Content attribute names, separate from the structural GEN_AI set. Tool content goes on
|
|
425
429
|
* `execute_tool` spans, message content on the `invoke_agent` envelope; each kind can be switched
|
|
426
430
|
* off through the content options. Mirrored in shared ingest semconv.
|
|
427
431
|
*/
|
|
428
|
-
declare const GEN_AI_CONTENT: {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
432
|
+
export declare const GEN_AI_CONTENT: {
|
|
433
|
+
readonly inputMessages: 'gen_ai.input.messages';
|
|
434
|
+
readonly outputMessages: 'gen_ai.output.messages';
|
|
435
|
+
readonly systemInstructions: 'gen_ai.system_instructions';
|
|
436
|
+
readonly toolCallArguments: 'gen_ai.tool.call.arguments';
|
|
437
|
+
readonly toolCallResult: 'gen_ai.tool.call.result';
|
|
434
438
|
};
|
|
435
439
|
/**
|
|
436
440
|
* Runtype's extension vocabulary. Placement is part of the contract and the
|
|
437
441
|
* reader enforces it — see the `RUNTYPE_ATTRIBUTES` doc block in the shared
|
|
438
442
|
* module for which level each name belongs on.
|
|
439
443
|
*/
|
|
440
|
-
declare const RUNTYPE: {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
444
|
+
export declare const RUNTYPE: {
|
|
445
|
+
readonly agentId: 'runtype.agent.id';
|
|
446
|
+
readonly schemaVersion: 'runtype.schema.version';
|
|
447
|
+
readonly adapterName: 'runtype.adapter.name';
|
|
448
|
+
readonly adapterVersion: 'runtype.adapter.version';
|
|
449
|
+
readonly executionId: 'runtype.execution.id';
|
|
450
|
+
readonly iteration: 'runtype.iteration';
|
|
451
|
+
readonly iterations: 'runtype.iterations';
|
|
452
|
+
readonly totalCost: 'runtype.total_cost';
|
|
453
|
+
readonly stopReason: 'runtype.stop_reason';
|
|
454
|
+
readonly toolsReported: 'runtype.tools.reported';
|
|
455
|
+
readonly toolType: 'runtype.tool.type';
|
|
456
|
+
readonly turnId: 'runtype.turn.id';
|
|
457
|
+
readonly turnIndex: 'runtype.turn.index';
|
|
458
|
+
readonly providerFinishReason: 'runtype.provider.finish_reason';
|
|
459
|
+
readonly providerServiceTier: 'runtype.provider.service_tier';
|
|
460
|
+
readonly gatewayLogId: 'runtype.gateway.log_id';
|
|
457
461
|
};
|
|
458
462
|
/**
|
|
459
463
|
* `runtype.tool.type` values — the closed domain that drives display and
|
|
@@ -461,7 +465,7 @@ declare const RUNTYPE: {
|
|
|
461
465
|
* members this instrumentation can honestly assert are ever emitted (see
|
|
462
466
|
* `projection.ts`).
|
|
463
467
|
*/
|
|
464
|
-
declare const RUNTYPE_TOOL_TYPES: readonly [
|
|
468
|
+
export declare const RUNTYPE_TOOL_TYPES: readonly ['flow', 'mcp', 'builtin', 'custom', 'external', 'advisor', 'subagent', 'local', 'data_connection', 'search'];
|
|
465
469
|
type RuntypeToolType = (typeof RUNTYPE_TOOL_TYPES)[number];
|
|
466
470
|
/**
|
|
467
471
|
* Terminal stop reasons, in Runtype's own wire vocabulary
|
|
@@ -469,35 +473,37 @@ type RuntypeToolType = (typeof RUNTYPE_TOOL_TYPES)[number];
|
|
|
469
473
|
* `runtype.stop_reason` is written to the run row verbatim, so an invented
|
|
470
474
|
* value would render in the dashboard as a real fact.
|
|
471
475
|
*/
|
|
472
|
-
declare const RUNTYPE_STOP_REASONS: readonly [
|
|
476
|
+
export declare const RUNTYPE_STOP_REASONS: readonly ['end_turn', 'max_tool_calls', 'length', 'content_filter', 'error', 'unknown'];
|
|
473
477
|
type RuntypeStopReason = (typeof RUNTYPE_STOP_REASONS)[number];
|
|
474
478
|
/** The version of the `runtype.*` vocabulary this package was built against. */
|
|
475
|
-
declare const RUNTYPE_SCHEMA_VERSION = "1";
|
|
479
|
+
export declare const RUNTYPE_SCHEMA_VERSION = "1";
|
|
476
480
|
/** What this package reports itself as in `runtype.adapter.name`. */
|
|
477
|
-
declare const ADAPTER_NAME = "@runtypelabs/flue-otel";
|
|
481
|
+
export declare const ADAPTER_NAME = "@runtypelabs/flue-otel";
|
|
478
482
|
/** What this package reports itself as in `runtype.adapter.version`. */
|
|
479
|
-
declare const ADAPTER_VERSION: string;
|
|
480
|
-
|
|
483
|
+
export declare const ADAPTER_VERSION: string;
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region src/index.d.ts
|
|
481
486
|
/**
|
|
482
487
|
* The instrumentation key. Distinct from stock's
|
|
483
488
|
* `Symbol.for('@flue/opentelemetry')` so `instrument()` treats the two as
|
|
484
489
|
* different subscribers and composes them rather than replacing one.
|
|
485
490
|
*/
|
|
486
|
-
declare const RUNTYPE_FLUE_INSTRUMENTATION_KEY: unique symbol;
|
|
487
|
-
interface RuntypeFlueInstrumentationOptions extends FlueProjectionOptions {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
491
|
+
export declare const RUNTYPE_FLUE_INSTRUMENTATION_KEY: unique symbol;
|
|
492
|
+
export interface RuntypeFlueInstrumentationOptions extends FlueProjectionOptions {
|
|
493
|
+
/**
|
|
494
|
+
* Where spans are written. Defaults to the globally registered provider's
|
|
495
|
+
* tracer, which is what an application that called `setGlobalTracerProvider`
|
|
496
|
+
* (or `NodeSDK.start()`) already has. Pass one explicitly to route Runtype's
|
|
497
|
+
* spans through a provider separate from the rest of the process.
|
|
498
|
+
*/
|
|
499
|
+
tracer?: Tracer;
|
|
495
500
|
}
|
|
496
501
|
/**
|
|
497
502
|
* Build an observe/interceptor pair for Flue's instrument(). The interceptor activates spans and joins
|
|
498
503
|
* dispatched trace carriers. Configure the OTel SDK externally, and point only one instrumentation at
|
|
499
504
|
* Runtype to avoid double counting.
|
|
500
505
|
*/
|
|
501
|
-
declare function createRuntypeFlueInstrumentation(options?: RuntypeFlueInstrumentationOptions): FlueInstrumentation;
|
|
502
|
-
|
|
503
|
-
export {
|
|
506
|
+
export declare function createRuntypeFlueInstrumentation(options?: RuntypeFlueInstrumentationOptions): FlueInstrumentation;
|
|
507
|
+
//#endregion
|
|
508
|
+
export type { FlueContentMessage, FlueContentOptions, FlueContentRedactContext, FlueContentSetting, FlueInstrumentation, FlueMessageContentKind, FlueProjectionOptions, RuntypeStopReason, RuntypeToolType, SpanAttributes, SpanIntent };
|
|
509
|
+
export {}
|