@agent-inspect/ai-sdk 1.7.0 → 1.8.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.mjs CHANGED
@@ -37,6 +37,12 @@ function countRecordKeys(value) {
37
37
  }
38
38
  return Object.keys(value).length;
39
39
  }
40
+ function normalizeMaxPreviewChars(value) {
41
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
42
+ return void 0;
43
+ }
44
+ return Math.floor(value);
45
+ }
40
46
  function summarizeUnknown(value) {
41
47
  if (value === null) return { type: "null" };
42
48
  if (Array.isArray(value)) return { type: "array", itemCount: value.length };
@@ -100,264 +106,375 @@ function summarizeFinishReason(finishReason) {
100
106
  var AgentInspectAiSdkTelemetryIntegration = class {
101
107
  constructor(options) {
102
108
  this.options = options;
109
+ this.requestedCapture = options.capture ?? "metadata-only";
103
110
  this.writer = options.writer ?? (options.traceDir ? fileWriter({ dir: options.traceDir }) : void 0);
111
+ this.recordCaptureOptionWarnings();
104
112
  }
105
113
  options;
106
114
  writer;
115
+ requestedCapture;
116
+ effectiveCapture = "metadata-only";
107
117
  diagnostics = {
108
- writeFailures: 0
118
+ writeFailures: 0,
119
+ lifecycleWarnings: 0,
120
+ flushFailures: 0,
121
+ closeFailures: 0
109
122
  };
110
123
  activeRun;
124
+ suspendedReason;
111
125
  getDiagnostics() {
112
126
  return { ...this.diagnostics };
113
127
  }
114
128
  async onStart(event) {
115
- const startedAt = nowIso();
116
- const runId = createId("ai_sdk_run");
117
- const eventId = createId("event");
118
- const name = this.options.runName ?? event.functionId ?? event.model.modelId ?? "ai-sdk-generation";
119
- this.activeRun = {
120
- runId,
121
- eventId,
122
- name,
123
- startedAt,
124
- model: event.model,
125
- steps: /* @__PURE__ */ new Map(),
126
- tools: /* @__PURE__ */ new Map()
127
- };
128
- await this.write({
129
- schemaVersion: "0.2",
130
- eventId,
131
- runId,
132
- kind: "RUN",
133
- name,
134
- status: "running",
135
- timestamp: startedAt,
136
- startedAt,
137
- confidence: "explicit",
138
- source: AI_SDK_SOURCE,
139
- attributes: {
140
- ...summarizeModel(event.model),
141
- functionId: event.functionId,
142
- capture: this.options.capture ?? "metadata-only",
143
- recordInputsRequired: false,
144
- recordOutputsRequired: false,
145
- toolCount: countRecordKeys(event.tools),
146
- hasPrompt: event.prompt !== void 0,
147
- hasMessages: event.messages !== void 0,
148
- metadataKeyCount: countRecordKeys(event.metadata)
129
+ await this.handleLifecycle("onStart", async () => {
130
+ if (this.activeRun || this.suspendedReason) {
131
+ this.activeRun = void 0;
132
+ this.suspendedReason = "Overlapping AI SDK generation ignored; create one agentInspect() integration per concurrent generation.";
133
+ this.recordLifecycleWarning(this.suspendedReason);
134
+ return;
149
135
  }
136
+ const startedAt = nowIso();
137
+ const runId = createId("ai_sdk_run");
138
+ const eventId = createId("event");
139
+ const name = this.options.runName ?? event.functionId ?? event.model.modelId ?? "ai-sdk-generation";
140
+ this.activeRun = {
141
+ runId,
142
+ eventId,
143
+ name,
144
+ startedAt,
145
+ model: event.model,
146
+ steps: /* @__PURE__ */ new Map(),
147
+ tools: /* @__PURE__ */ new Map()
148
+ };
149
+ await this.write({
150
+ schemaVersion: "0.2",
151
+ eventId,
152
+ runId,
153
+ kind: "RUN",
154
+ name,
155
+ status: "running",
156
+ timestamp: startedAt,
157
+ startedAt,
158
+ confidence: "explicit",
159
+ source: AI_SDK_SOURCE,
160
+ attributes: {
161
+ legacyEvent: "run_started",
162
+ ...summarizeModel(event.model),
163
+ functionId: event.functionId,
164
+ capture: this.effectiveCapture,
165
+ requestedCapture: this.requestedCapture === this.effectiveCapture ? void 0 : this.requestedCapture,
166
+ previewCaptureSupported: this.requestedCapture === "preview" ? false : void 0,
167
+ redactionProfile: this.options.redactionProfile,
168
+ maxPreviewChars: normalizeMaxPreviewChars(this.options.maxPreviewChars),
169
+ recordInputsRequired: false,
170
+ recordOutputsRequired: false,
171
+ toolCount: countRecordKeys(event.tools),
172
+ hasPrompt: event.prompt !== void 0,
173
+ hasMessages: event.messages !== void 0,
174
+ metadataKeyCount: countRecordKeys(event.metadata)
175
+ }
176
+ });
150
177
  });
151
178
  }
152
179
  async onStepStart(event) {
153
- const run = this.ensureRun(event.model, event.functionId);
154
- const startedAt = nowIso();
155
- const stepEventId = createId("event");
156
- run.steps.set(event.stepNumber, {
157
- eventId: stepEventId,
158
- startedAt
159
- });
160
- await this.write({
161
- schemaVersion: "0.2",
162
- eventId: stepEventId,
163
- runId: run.runId,
164
- parentId: run.eventId,
165
- kind: "LLM",
166
- name: `ai-sdk-step-${event.stepNumber}`,
167
- status: "running",
168
- timestamp: startedAt,
169
- startedAt,
170
- confidence: "explicit",
171
- source: AI_SDK_SOURCE,
172
- attributes: {
173
- ...summarizeModel(event.model),
174
- functionId: event.functionId,
175
- stepNumber: event.stepNumber,
176
- priorStepCount: event.steps.length,
177
- activeToolCount: event.activeTools?.length,
178
- toolCount: countRecordKeys(event.tools),
179
- messageCount: event.messages.length,
180
- metadataKeyCount: countRecordKeys(event.metadata)
181
- }
180
+ await this.handleLifecycle("onStepStart", async () => {
181
+ const run = this.getActiveRun("onStepStart");
182
+ if (!run) return;
183
+ const startedAt = nowIso();
184
+ const stepEventId = createId("event");
185
+ run.steps.set(event.stepNumber, {
186
+ eventId: stepEventId,
187
+ parentId: run.eventId,
188
+ startedAt
189
+ });
190
+ await this.write({
191
+ schemaVersion: "0.2",
192
+ eventId: stepEventId,
193
+ runId: run.runId,
194
+ parentId: run.eventId,
195
+ kind: "LLM",
196
+ name: `ai-sdk-step-${event.stepNumber}`,
197
+ status: "running",
198
+ timestamp: startedAt,
199
+ startedAt,
200
+ confidence: "explicit",
201
+ source: AI_SDK_SOURCE,
202
+ attributes: {
203
+ legacyEvent: "step_started",
204
+ stepId: stepEventId,
205
+ ...summarizeModel(event.model),
206
+ functionId: event.functionId,
207
+ stepNumber: event.stepNumber,
208
+ priorStepCount: event.steps.length,
209
+ activeToolCount: event.activeTools?.length,
210
+ toolCount: countRecordKeys(event.tools),
211
+ messageCount: event.messages.length,
212
+ metadataKeyCount: countRecordKeys(event.metadata)
213
+ }
214
+ });
182
215
  });
183
216
  }
184
217
  async onStepFinish(event) {
185
- const run = this.ensureRun(event.model, event.functionId);
186
- const endedAt = nowIso();
187
- const activeStep = run.steps.get(event.stepNumber) ?? {
188
- eventId: createId("event"),
189
- startedAt: endedAt
190
- };
191
- await this.write({
192
- schemaVersion: "0.2",
193
- eventId: createId("event"),
194
- runId: run.runId,
195
- parentId: activeStep.eventId,
196
- kind: "LLM",
197
- name: `ai-sdk-step-${event.stepNumber}`,
198
- status: "ok",
199
- timestamp: endedAt,
200
- startedAt: activeStep.startedAt,
201
- endedAt,
202
- durationMs: durationMs(activeStep.startedAt, endedAt),
203
- confidence: "explicit",
204
- source: AI_SDK_SOURCE,
205
- attributes: {
206
- ...summarizeModel(event.model),
207
- functionId: event.functionId,
208
- stepNumber: event.stepNumber,
209
- ...summarizeFinishReason(event.finishReason),
210
- warningCount: event.warnings?.length ?? 0,
211
- contentPartCount: event.content.length,
212
- toolCallCount: event.toolCalls.length,
213
- toolResultCount: event.toolResults.length,
214
- responseId: event.response.id,
215
- responseModelId: event.response.modelId,
216
- responseTimestamp: event.response.timestamp?.toISOString(),
217
- metadataKeyCount: countRecordKeys(event.metadata)
218
- },
219
- tokenUsage: summarizeUsage(event.usage),
220
- outputSummary: {
221
- contentPartCount: event.content.length,
222
- textLength: event.text.length,
223
- reasoningPartCount: event.reasoning.length,
224
- fileCount: event.files.length,
225
- sourceCount: event.sources.length
218
+ await this.handleLifecycle("onStepFinish", async () => {
219
+ const run = this.getActiveRun("onStepFinish");
220
+ if (!run) return;
221
+ const endedAt = nowIso();
222
+ const activeStep = run.steps.get(event.stepNumber);
223
+ if (!activeStep) {
224
+ this.recordLifecycleWarning(
225
+ `onStepFinish ignored because step ${event.stepNumber} has no matching start callback.`
226
+ );
227
+ return;
226
228
  }
229
+ await this.write({
230
+ schemaVersion: "0.2",
231
+ eventId: activeStep.eventId,
232
+ runId: run.runId,
233
+ parentId: activeStep.parentId,
234
+ kind: "LLM",
235
+ name: `ai-sdk-step-${event.stepNumber}`,
236
+ status: "ok",
237
+ timestamp: endedAt,
238
+ startedAt: activeStep.startedAt,
239
+ endedAt,
240
+ durationMs: durationMs(activeStep.startedAt, endedAt),
241
+ confidence: "explicit",
242
+ source: AI_SDK_SOURCE,
243
+ attributes: {
244
+ legacyEvent: "step_completed",
245
+ stepId: activeStep.eventId,
246
+ ...summarizeModel(event.model),
247
+ functionId: event.functionId,
248
+ stepNumber: event.stepNumber,
249
+ ...summarizeFinishReason(event.finishReason),
250
+ warningCount: event.warnings?.length ?? 0,
251
+ contentPartCount: event.content.length,
252
+ toolCallCount: event.toolCalls.length,
253
+ toolResultCount: event.toolResults.length,
254
+ responseId: event.response.id,
255
+ responseModelId: event.response.modelId,
256
+ responseTimestamp: event.response.timestamp?.toISOString(),
257
+ metadataKeyCount: countRecordKeys(event.metadata)
258
+ },
259
+ tokenUsage: summarizeUsage(event.usage),
260
+ outputSummary: {
261
+ contentPartCount: event.content.length,
262
+ textLength: event.text.length,
263
+ reasoningPartCount: event.reasoning.length,
264
+ fileCount: event.files.length,
265
+ sourceCount: event.sources.length
266
+ }
267
+ });
227
268
  });
228
269
  }
229
270
  async onToolCallStart(event) {
230
- const run = this.ensureRun(event.model, event.functionId);
231
- const startedAt = nowIso();
232
- const eventId = createId("event");
233
- const toolCall = event.toolCall;
234
- run.tools.set(toolCall.toolCallId, {
235
- eventId,
236
- startedAt,
237
- toolName: toolCall.toolName
238
- });
239
- const step = event.stepNumber === void 0 ? void 0 : run.steps.get(event.stepNumber);
240
- await this.write({
241
- schemaVersion: "0.2",
242
- eventId,
243
- runId: run.runId,
244
- parentId: step?.eventId ?? run.eventId,
245
- kind: "TOOL",
246
- name: toolCall.toolName,
247
- status: "running",
248
- timestamp: startedAt,
249
- startedAt,
250
- confidence: "explicit",
251
- source: AI_SDK_SOURCE,
252
- attributes: {
253
- ...summarizeModel(event.model),
254
- functionId: event.functionId,
255
- stepNumber: event.stepNumber,
256
- toolCallId: toolCall.toolCallId,
257
- toolName: toolCall.toolName,
258
- dynamic: toolCall.dynamic === true,
259
- invalid: toolCall.invalid === true,
260
- providerExecuted: toolCall.providerExecuted === true,
261
- messageCount: event.messages.length,
262
- metadataKeyCount: countRecordKeys(event.metadata),
263
- providerMetadataKeyCount: countRecordKeys(toolCall.providerMetadata),
264
- toolMetadataKeyCount: countRecordKeys(toolCall.toolMetadata)
265
- },
266
- inputSummary: summarizeUnknown(toolCall.input),
267
- error: toolCall.invalid ? summarizeError(toolCall.error) : void 0
271
+ await this.handleLifecycle("onToolCallStart", async () => {
272
+ const run = this.getActiveRun("onToolCallStart");
273
+ if (!run) return;
274
+ const startedAt = nowIso();
275
+ const eventId = createId("event");
276
+ const toolCall = event.toolCall;
277
+ const step = event.stepNumber === void 0 ? void 0 : run.steps.get(event.stepNumber);
278
+ const parentId = step?.eventId ?? run.eventId;
279
+ if (event.stepNumber === void 0 || !step) {
280
+ this.recordLifecycleWarning(
281
+ "onToolCallStart attached tool to run because the AI SDK callback did not expose a matching active step."
282
+ );
283
+ }
284
+ run.tools.set(toolCall.toolCallId, {
285
+ eventId,
286
+ parentId,
287
+ startedAt,
288
+ toolName: toolCall.toolName
289
+ });
290
+ await this.write({
291
+ schemaVersion: "0.2",
292
+ eventId,
293
+ runId: run.runId,
294
+ parentId,
295
+ kind: "TOOL",
296
+ name: toolCall.toolName,
297
+ status: "running",
298
+ timestamp: startedAt,
299
+ startedAt,
300
+ confidence: "explicit",
301
+ source: AI_SDK_SOURCE,
302
+ attributes: {
303
+ legacyEvent: "step_started",
304
+ stepId: eventId,
305
+ ...summarizeModel(event.model),
306
+ functionId: event.functionId,
307
+ stepNumber: event.stepNumber,
308
+ toolCallId: toolCall.toolCallId,
309
+ toolName: toolCall.toolName,
310
+ dynamic: toolCall.dynamic === true,
311
+ invalid: toolCall.invalid === true,
312
+ providerExecuted: toolCall.providerExecuted === true,
313
+ messageCount: event.messages.length,
314
+ metadataKeyCount: countRecordKeys(event.metadata),
315
+ providerMetadataKeyCount: countRecordKeys(toolCall.providerMetadata),
316
+ toolMetadataKeyCount: countRecordKeys(toolCall.toolMetadata)
317
+ },
318
+ inputSummary: summarizeUnknown(toolCall.input),
319
+ error: toolCall.invalid ? summarizeError(toolCall.error) : void 0
320
+ });
268
321
  });
269
322
  }
270
323
  async onToolCallFinish(event) {
271
- const run = this.ensureRun(event.model, event.functionId);
272
- const endedAt = nowIso();
273
- const toolCall = event.toolCall;
274
- const activeTool = run.tools.get(toolCall.toolCallId) ?? {
275
- eventId: createId("event"),
276
- startedAt: endedAt,
277
- toolName: toolCall.toolName
278
- };
279
- await this.write({
280
- schemaVersion: "0.2",
281
- eventId: createId("event"),
282
- runId: run.runId,
283
- parentId: activeTool.eventId,
284
- kind: "TOOL",
285
- name: activeTool.toolName,
286
- status: event.success ? "ok" : "error",
287
- timestamp: endedAt,
288
- startedAt: activeTool.startedAt,
289
- endedAt,
290
- durationMs: event.durationMs,
291
- confidence: "explicit",
292
- source: AI_SDK_SOURCE,
293
- attributes: {
294
- ...summarizeModel(event.model),
295
- functionId: event.functionId,
296
- stepNumber: event.stepNumber,
297
- toolCallId: toolCall.toolCallId,
298
- toolName: toolCall.toolName,
299
- dynamic: toolCall.dynamic === true,
300
- invalid: toolCall.invalid === true,
301
- providerExecuted: toolCall.providerExecuted === true,
302
- messageCount: event.messages.length,
303
- metadataKeyCount: countRecordKeys(event.metadata),
304
- providerMetadataKeyCount: countRecordKeys(toolCall.providerMetadata),
305
- toolMetadataKeyCount: countRecordKeys(toolCall.toolMetadata)
306
- },
307
- outputSummary: event.success ? summarizeUnknown(event.output) : void 0,
308
- error: event.success ? void 0 : summarizeError(event.error)
324
+ await this.handleLifecycle("onToolCallFinish", async () => {
325
+ const run = this.getActiveRun("onToolCallFinish");
326
+ if (!run) return;
327
+ const endedAt = nowIso();
328
+ const toolCall = event.toolCall;
329
+ const activeTool = run.tools.get(toolCall.toolCallId);
330
+ if (!activeTool) {
331
+ this.recordLifecycleWarning(
332
+ `onToolCallFinish ignored because tool call ${toolCall.toolCallId} has no matching start callback.`
333
+ );
334
+ return;
335
+ }
336
+ await this.write({
337
+ schemaVersion: "0.2",
338
+ eventId: activeTool.eventId,
339
+ runId: run.runId,
340
+ parentId: activeTool.parentId,
341
+ kind: "TOOL",
342
+ name: activeTool.toolName,
343
+ status: event.success ? "ok" : "error",
344
+ timestamp: endedAt,
345
+ startedAt: activeTool.startedAt,
346
+ endedAt,
347
+ durationMs: event.durationMs,
348
+ confidence: "explicit",
349
+ source: AI_SDK_SOURCE,
350
+ attributes: {
351
+ legacyEvent: "step_completed",
352
+ stepId: activeTool.eventId,
353
+ ...summarizeModel(event.model),
354
+ functionId: event.functionId,
355
+ stepNumber: event.stepNumber,
356
+ toolCallId: toolCall.toolCallId,
357
+ toolName: toolCall.toolName,
358
+ dynamic: toolCall.dynamic === true,
359
+ invalid: toolCall.invalid === true,
360
+ providerExecuted: toolCall.providerExecuted === true,
361
+ messageCount: event.messages.length,
362
+ metadataKeyCount: countRecordKeys(event.metadata),
363
+ providerMetadataKeyCount: countRecordKeys(toolCall.providerMetadata),
364
+ toolMetadataKeyCount: countRecordKeys(toolCall.toolMetadata)
365
+ },
366
+ outputSummary: event.success ? summarizeUnknown(event.output) : void 0,
367
+ error: event.success ? void 0 : summarizeError(event.error)
368
+ });
309
369
  });
310
370
  }
311
371
  async onFinish(event) {
312
- const run = this.ensureRun(event.model, event.functionId);
313
- const endedAt = nowIso();
314
- await this.write({
315
- schemaVersion: "0.2",
316
- eventId: createId("event"),
317
- runId: run.runId,
318
- kind: "RUN",
319
- name: run.name,
320
- status: "ok",
321
- timestamp: endedAt,
322
- startedAt: run.startedAt,
323
- endedAt,
324
- durationMs: durationMs(run.startedAt, endedAt),
325
- confidence: "explicit",
326
- source: AI_SDK_SOURCE,
327
- attributes: {
328
- ...summarizeModel(event.model ?? run.model),
329
- functionId: event.functionId,
330
- ...summarizeFinishReason(event.finishReason),
331
- stepCount: event.steps.length,
332
- warningCount: event.warnings?.length ?? 0,
333
- toolCallCount: event.toolCalls.length,
334
- toolResultCount: event.toolResults.length,
335
- metadataKeyCount: countRecordKeys(event.metadata)
336
- },
337
- tokenUsage: summarizeUsage(event.totalUsage),
338
- outputSummary: {
339
- contentPartCount: event.content.length,
340
- textLength: event.text.length,
341
- reasoningPartCount: event.reasoning.length,
342
- fileCount: event.files.length,
343
- sourceCount: event.sources.length
372
+ await this.handleLifecycle("onFinish", async () => {
373
+ if (this.suspendedReason) {
374
+ this.suspendedReason = void 0;
375
+ return;
344
376
  }
377
+ const run = this.getActiveRun("onFinish");
378
+ if (!run) return;
379
+ const endedAt = nowIso();
380
+ await this.write({
381
+ schemaVersion: "0.2",
382
+ eventId: run.eventId,
383
+ runId: run.runId,
384
+ kind: "RUN",
385
+ name: run.name,
386
+ status: "ok",
387
+ timestamp: endedAt,
388
+ startedAt: run.startedAt,
389
+ endedAt,
390
+ durationMs: durationMs(run.startedAt, endedAt),
391
+ confidence: "explicit",
392
+ source: AI_SDK_SOURCE,
393
+ attributes: {
394
+ legacyEvent: "run_completed",
395
+ ...summarizeModel(event.model ?? run.model),
396
+ functionId: event.functionId,
397
+ ...summarizeFinishReason(event.finishReason),
398
+ stepCount: event.steps.length,
399
+ warningCount: event.warnings?.length ?? 0,
400
+ toolCallCount: event.toolCalls.length,
401
+ toolResultCount: event.toolResults.length,
402
+ metadataKeyCount: countRecordKeys(event.metadata)
403
+ },
404
+ tokenUsage: summarizeUsage(event.totalUsage),
405
+ outputSummary: {
406
+ contentPartCount: event.content.length,
407
+ textLength: event.text.length,
408
+ reasoningPartCount: event.reasoning.length,
409
+ fileCount: event.files.length,
410
+ sourceCount: event.sources.length
411
+ }
412
+ });
413
+ this.activeRun = void 0;
345
414
  });
346
- this.activeRun = void 0;
347
415
  }
348
- ensureRun(model, functionId) {
416
+ getWriterStats() {
417
+ return this.writer?.getStats?.();
418
+ }
419
+ async flush() {
420
+ try {
421
+ await this.writer?.flush?.();
422
+ } catch (error) {
423
+ this.diagnostics.flushFailures += 1;
424
+ this.diagnostics.lastError = normalizeError(error);
425
+ }
426
+ }
427
+ async close() {
428
+ try {
429
+ await this.writer?.close?.();
430
+ } catch (error) {
431
+ this.diagnostics.closeFailures += 1;
432
+ this.diagnostics.lastError = normalizeError(error);
433
+ } finally {
434
+ this.activeRun = void 0;
435
+ this.suspendedReason = void 0;
436
+ }
437
+ }
438
+ getActiveRun(callbackName) {
439
+ if (this.suspendedReason) {
440
+ this.recordLifecycleWarning(
441
+ `${callbackName} ignored while integration is suspended: ${this.suspendedReason}`
442
+ );
443
+ return void 0;
444
+ }
349
445
  if (this.activeRun) return this.activeRun;
350
- const startedAt = nowIso();
351
- this.activeRun = {
352
- runId: createId("ai_sdk_run"),
353
- eventId: createId("event"),
354
- name: this.options.runName ?? functionId ?? model?.modelId ?? "ai-sdk-generation",
355
- startedAt,
356
- model,
357
- steps: /* @__PURE__ */ new Map(),
358
- tools: /* @__PURE__ */ new Map()
359
- };
360
- return this.activeRun;
446
+ this.recordLifecycleWarning(
447
+ `${callbackName} ignored because no active AI SDK generation was started.`
448
+ );
449
+ return void 0;
450
+ }
451
+ async handleLifecycle(callbackName, run) {
452
+ try {
453
+ await run();
454
+ } catch (error) {
455
+ this.recordLifecycleWarning(`${callbackName}: ${normalizeError(error)}`);
456
+ }
457
+ }
458
+ recordLifecycleWarning(message) {
459
+ this.diagnostics.lifecycleWarnings += 1;
460
+ this.diagnostics.lastWarning = message;
461
+ }
462
+ recordCaptureOptionWarnings() {
463
+ const previewOnlyOptions = [];
464
+ if (this.requestedCapture === "preview") previewOnlyOptions.push("capture");
465
+ if (this.options.redactionProfile !== void 0) previewOnlyOptions.push("redactionProfile");
466
+ if (this.options.maxPreviewChars !== void 0) previewOnlyOptions.push("maxPreviewChars");
467
+ if (this.requestedCapture === "preview") {
468
+ this.recordLifecycleWarning(
469
+ `AI SDK preview capture is not supported yet; falling back to metadata-only capture. Unsupported options: ${previewOnlyOptions.join(", ")}.`
470
+ );
471
+ return;
472
+ }
473
+ if (previewOnlyOptions.length > 0) {
474
+ this.recordLifecycleWarning(
475
+ `AI SDK preview-only options have no effect in metadata-only capture: ${previewOnlyOptions.join(", ")}.`
476
+ );
477
+ }
361
478
  }
362
479
  async write(event) {
363
480
  if (!this.writer) return;
@@ -373,7 +490,10 @@ function agentInspect(options = {}) {
373
490
  const integration = new AgentInspectAiSdkTelemetryIntegration(options);
374
491
  return {
375
492
  ...bindTelemetryIntegration(integration),
376
- getDiagnostics: () => integration.getDiagnostics()
493
+ getDiagnostics: () => integration.getDiagnostics(),
494
+ getWriterStats: () => integration.getWriterStats(),
495
+ flush: () => integration.flush(),
496
+ close: () => integration.close()
377
497
  };
378
498
  }
379
499