@ai-sdk/devtools 1.0.0-canary.22 → 1.0.0-canary.23
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.js +4 -54
- package/package.json +2 -2
- package/src/integration.ts +1 -63
package/dist/index.js
CHANGED
|
@@ -501,9 +501,7 @@ function DevToolsTelemetry() {
|
|
|
501
501
|
const startTime = Date.now();
|
|
502
502
|
const stepState = {
|
|
503
503
|
stepId,
|
|
504
|
-
startTime
|
|
505
|
-
streamChunks: [],
|
|
506
|
-
rawStreamChunks: []
|
|
504
|
+
startTime
|
|
507
505
|
};
|
|
508
506
|
const stepNumber = stepStartEvent.steps.length;
|
|
509
507
|
state.stepStates.set(stepNumber, stepState);
|
|
@@ -544,9 +542,7 @@ function DevToolsTelemetry() {
|
|
|
544
542
|
const startTime = Date.now();
|
|
545
543
|
const stepState = {
|
|
546
544
|
stepId,
|
|
547
|
-
startTime
|
|
548
|
-
streamChunks: [],
|
|
549
|
-
rawStreamChunks: []
|
|
545
|
+
startTime
|
|
550
546
|
};
|
|
551
547
|
state.stepStates.set(stepStartEvent.stepNumber, stepState);
|
|
552
548
|
activeSteps2.set(stepId, stepState);
|
|
@@ -571,50 +567,6 @@ function DevToolsTelemetry() {
|
|
|
571
567
|
provider_options: stepStartEvent.providerOptions ? JSON.stringify(stepStartEvent.providerOptions) : null
|
|
572
568
|
});
|
|
573
569
|
},
|
|
574
|
-
onChunk: async (event) => {
|
|
575
|
-
const { chunk } = event;
|
|
576
|
-
if (chunk.type === "raw") {
|
|
577
|
-
const rawValue = chunk.rawValue;
|
|
578
|
-
for (const [, state] of callStates) {
|
|
579
|
-
let latestStepState;
|
|
580
|
-
let latestStepNumber = -1;
|
|
581
|
-
for (const [stepNumber, ss] of state.stepStates) {
|
|
582
|
-
if (stepNumber > latestStepNumber) {
|
|
583
|
-
latestStepNumber = stepNumber;
|
|
584
|
-
latestStepState = ss;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
if (latestStepState) {
|
|
588
|
-
latestStepState.rawStreamChunks.push(rawValue);
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
if ("callId" in chunk && "stepNumber" in chunk) {
|
|
595
|
-
const typed = chunk;
|
|
596
|
-
const state = callStates.get(typed.callId);
|
|
597
|
-
if (!state) return;
|
|
598
|
-
const stepState = state.stepStates.get(typed.stepNumber);
|
|
599
|
-
if (!stepState) return;
|
|
600
|
-
stepState.streamChunks.push(chunk);
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
for (const [, state] of callStates) {
|
|
604
|
-
let latestStepState;
|
|
605
|
-
let latestStepNumber = -1;
|
|
606
|
-
for (const [stepNumber, ss] of state.stepStates) {
|
|
607
|
-
if (stepNumber > latestStepNumber) {
|
|
608
|
-
latestStepNumber = stepNumber;
|
|
609
|
-
latestStepState = ss;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
if (latestStepState) {
|
|
613
|
-
latestStepState.streamChunks.push(chunk);
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
},
|
|
618
570
|
onStepFinish: async (event) => {
|
|
619
571
|
const stepResult = event;
|
|
620
572
|
const state = callStates.get(stepResult.callId);
|
|
@@ -633,16 +585,14 @@ function DevToolsTelemetry() {
|
|
|
633
585
|
messages: stepResult.response.messages
|
|
634
586
|
}
|
|
635
587
|
};
|
|
636
|
-
const hasStreamChunks = stepState.streamChunks.length > 0;
|
|
637
|
-
const hasRawStreamChunks = stepState.rawStreamChunks.length > 0;
|
|
638
588
|
await updateStepResult(stepState.stepId, {
|
|
639
589
|
duration_ms: durationMs,
|
|
640
590
|
output: JSON.stringify(output),
|
|
641
591
|
usage: stepResult.usage ? JSON.stringify(stepResult.usage) : null,
|
|
642
592
|
error: null,
|
|
643
593
|
raw_request: stepResult.request?.body ? JSON.stringify(stepResult.request.body) : null,
|
|
644
|
-
raw_response: stepResult.response?.body ? JSON.stringify(stepResult.response.body) :
|
|
645
|
-
raw_chunks:
|
|
594
|
+
raw_response: stepResult.response?.body ? JSON.stringify(stepResult.response.body) : null,
|
|
595
|
+
raw_chunks: null
|
|
646
596
|
});
|
|
647
597
|
state.stepStates.delete(stepResult.stepNumber);
|
|
648
598
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/devtools",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"vaul": "^1.1.2",
|
|
57
57
|
"vite": "^6.0.3",
|
|
58
58
|
"zod": "3.25.76",
|
|
59
|
-
"ai": "7.0.0-canary.
|
|
59
|
+
"ai": "7.0.0-canary.137"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public",
|
package/src/integration.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type {
|
|
|
2
2
|
GenerateTextStartEvent,
|
|
3
3
|
GenerateTextStepStartEvent,
|
|
4
4
|
GenerateTextStepEndEvent,
|
|
5
|
-
StreamTextChunkEvent,
|
|
6
5
|
GenerateObjectStartEvent,
|
|
7
6
|
GenerateObjectStepStartEvent,
|
|
8
7
|
GenerateObjectStepEndEvent,
|
|
@@ -21,8 +20,6 @@ type OperationType = 'generate' | 'stream';
|
|
|
21
20
|
interface StepState {
|
|
22
21
|
stepId: string;
|
|
23
22
|
startTime: number;
|
|
24
|
-
streamChunks: unknown[];
|
|
25
|
-
rawStreamChunks: unknown[];
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
interface CallState {
|
|
@@ -231,8 +228,6 @@ export function DevToolsTelemetry(): Telemetry {
|
|
|
231
228
|
const stepState: StepState = {
|
|
232
229
|
stepId,
|
|
233
230
|
startTime,
|
|
234
|
-
streamChunks: [],
|
|
235
|
-
rawStreamChunks: [],
|
|
236
231
|
};
|
|
237
232
|
const stepNumber = stepStartEvent.steps.length;
|
|
238
233
|
state.stepStates.set(stepNumber, stepState);
|
|
@@ -286,8 +281,6 @@ export function DevToolsTelemetry(): Telemetry {
|
|
|
286
281
|
const stepState: StepState = {
|
|
287
282
|
stepId,
|
|
288
283
|
startTime,
|
|
289
|
-
streamChunks: [],
|
|
290
|
-
rawStreamChunks: [],
|
|
291
284
|
};
|
|
292
285
|
state.stepStates.set(stepStartEvent.stepNumber, stepState);
|
|
293
286
|
activeSteps.set(stepId, stepState);
|
|
@@ -316,54 +309,6 @@ export function DevToolsTelemetry(): Telemetry {
|
|
|
316
309
|
});
|
|
317
310
|
},
|
|
318
311
|
|
|
319
|
-
onChunk: async event => {
|
|
320
|
-
const { chunk } = event as StreamTextChunkEvent;
|
|
321
|
-
|
|
322
|
-
if (chunk.type === 'raw') {
|
|
323
|
-
const rawValue = (chunk as { rawValue: unknown }).rawValue;
|
|
324
|
-
for (const [, state] of callStates) {
|
|
325
|
-
let latestStepState: StepState | undefined;
|
|
326
|
-
let latestStepNumber = -1;
|
|
327
|
-
for (const [stepNumber, ss] of state.stepStates) {
|
|
328
|
-
if (stepNumber > latestStepNumber) {
|
|
329
|
-
latestStepNumber = stepNumber;
|
|
330
|
-
latestStepState = ss;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
if (latestStepState) {
|
|
334
|
-
latestStepState.rawStreamChunks.push(rawValue);
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
if ('callId' in chunk && 'stepNumber' in chunk) {
|
|
342
|
-
const typed = chunk as { callId: string; stepNumber: number };
|
|
343
|
-
const state = callStates.get(typed.callId);
|
|
344
|
-
if (!state) return;
|
|
345
|
-
const stepState = state.stepStates.get(typed.stepNumber);
|
|
346
|
-
if (!stepState) return;
|
|
347
|
-
stepState.streamChunks.push(chunk);
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
for (const [, state] of callStates) {
|
|
352
|
-
let latestStepState: StepState | undefined;
|
|
353
|
-
let latestStepNumber = -1;
|
|
354
|
-
for (const [stepNumber, ss] of state.stepStates) {
|
|
355
|
-
if (stepNumber > latestStepNumber) {
|
|
356
|
-
latestStepNumber = stepNumber;
|
|
357
|
-
latestStepState = ss;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (latestStepState) {
|
|
361
|
-
latestStepState.streamChunks.push(chunk);
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
|
|
367
312
|
onStepFinish: async event => {
|
|
368
313
|
const stepResult = event as GenerateTextStepEndEvent<ToolSet>;
|
|
369
314
|
|
|
@@ -388,9 +333,6 @@ export function DevToolsTelemetry(): Telemetry {
|
|
|
388
333
|
},
|
|
389
334
|
};
|
|
390
335
|
|
|
391
|
-
const hasStreamChunks = stepState.streamChunks.length > 0;
|
|
392
|
-
const hasRawStreamChunks = stepState.rawStreamChunks.length > 0;
|
|
393
|
-
|
|
394
336
|
await updateStepResult(stepState.stepId, {
|
|
395
337
|
duration_ms: durationMs,
|
|
396
338
|
output: JSON.stringify(output),
|
|
@@ -401,12 +343,8 @@ export function DevToolsTelemetry(): Telemetry {
|
|
|
401
343
|
: null,
|
|
402
344
|
raw_response: stepResult.response?.body
|
|
403
345
|
? JSON.stringify(stepResult.response.body)
|
|
404
|
-
: hasStreamChunks
|
|
405
|
-
? JSON.stringify(stepState.streamChunks)
|
|
406
|
-
: null,
|
|
407
|
-
raw_chunks: hasRawStreamChunks
|
|
408
|
-
? JSON.stringify(stepState.rawStreamChunks)
|
|
409
346
|
: null,
|
|
347
|
+
raw_chunks: null,
|
|
410
348
|
});
|
|
411
349
|
|
|
412
350
|
state.stepStates.delete(stepResult.stepNumber);
|