streamfold 0.1.4 → 0.1.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/src/vercel-ai.js CHANGED
@@ -1,22 +1,40 @@
1
1
  import { createStructuredStreamPool } from "./index.js";
2
2
  import { createIntegration } from "./internal/integration.js";
3
3
 
4
- export const vercelAI = (pool = createStructuredStreamPool()) =>
5
- createIntegration(pool, (event, complete) => {
6
- const id = event.id ?? event.toolCallId;
7
- if (id === undefined) return undefined;
4
+ export const vercelAI = (pool = createStructuredStreamPool(), options) =>
5
+ createIntegration(
6
+ pool,
7
+ (event, calls) => {
8
+ const id = event.id ?? event.toolCallId;
9
+ if (id === undefined) {
10
+ if (
11
+ [
12
+ "tool-input-start",
13
+ "tool-input-delta",
14
+ "tool-input-end",
15
+ "tool-input-available",
16
+ ].includes(event.type)
17
+ ) {
18
+ calls.unmatched("Tool input event is missing its call id");
19
+ }
20
+ return undefined;
21
+ }
8
22
 
9
- if (event.type === "tool-input-start") return pool.start(id);
10
- if (event.type === "tool-input-delta") {
11
- return pool.push(id, event.delta ?? event.inputTextDelta);
12
- }
13
- if (
14
- event.type === "tool-input-end" ||
15
- event.type === "tool-input-available"
16
- ) {
17
- return complete(id);
18
- }
19
- return undefined;
20
- });
23
+ if (event.type === "tool-input-start") return calls.start(id);
24
+ if (event.type === "tool-input-delta") {
25
+ return calls.push(id, event.delta ?? event.inputTextDelta);
26
+ }
27
+ if (
28
+ event.type === "tool-input-end" ||
29
+ event.type === "tool-input-available"
30
+ ) {
31
+ return calls.complete(id);
32
+ }
33
+ return undefined;
34
+ },
35
+ undefined,
36
+ "vercel-ai",
37
+ options,
38
+ );
21
39
 
22
40
  export { vercelAI as createStructuredStream };