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