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/README.md +25 -0
- package/package.json +5 -1
- package/src/adapter.js +161 -0
- package/src/ag-ui.d.ts +6 -4
- package/src/ag-ui.js +17 -9
- package/src/anthropic.d.ts +6 -4
- package/src/anthropic.js +38 -24
- package/src/assistant-ui.d.ts +6 -4
- package/src/assistant-ui.js +29 -18
- package/src/gemini.d.ts +6 -4
- package/src/gemini.js +8 -5
- package/src/index.d.ts +141 -8
- package/src/index.js +89 -24
- package/src/internal/abortable-source.js +82 -0
- package/src/internal/diagnostics.js +9 -0
- package/src/internal/errors.js +14 -0
- package/src/internal/integration.js +105 -15
- package/src/internal/snapshots.js +58 -0
- package/src/internal/wasm-runtime.js +31 -5
- package/src/langchain.d.ts +6 -4
- package/src/langchain.js +8 -4
- package/src/openai.d.ts +6 -4
- package/src/openai.js +22 -15
- package/src/read-structured.js +74 -0
- package/src/testing.d.ts +13 -0
- package/src/testing.js +121 -0
- package/src/vercel-ai.d.ts +6 -4
- package/src/vercel-ai.js +34 -16
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(
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 };
|