@assistant-ui/react 0.8.6 → 0.8.8
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/cloud/auiV0.d.ts.map +1 -1
- package/dist/cloud/auiV0.js +9 -2
- package/dist/cloud/auiV0.js.map +1 -1
- package/dist/cloud/auiV0.mjs +9 -2
- package/dist/cloud/auiV0.mjs.map +1 -1
- package/dist/primitives/contentPart/useContentPartFile.d.ts +5 -0
- package/dist/primitives/contentPart/useContentPartFile.d.ts.map +1 -0
- package/dist/{runtimes/edge/streams/utils/index.js → primitives/contentPart/useContentPartFile.js} +18 -12
- package/dist/primitives/contentPart/useContentPartFile.js.map +1 -0
- package/dist/primitives/contentPart/useContentPartFile.mjs +18 -0
- package/dist/primitives/contentPart/useContentPartFile.mjs.map +1 -0
- package/dist/primitives/contentPart/useContentPartSource.d.ts +5 -0
- package/dist/primitives/contentPart/useContentPartSource.d.ts.map +1 -0
- package/dist/{runtimes/edge/streams/utils/PipeableTransformStream.js → primitives/contentPart/useContentPartSource.js} +18 -16
- package/dist/primitives/contentPart/useContentPartSource.js.map +1 -0
- package/dist/primitives/contentPart/useContentPartSource.mjs +18 -0
- package/dist/primitives/contentPart/useContentPartSource.mjs.map +1 -0
- package/dist/primitives/index.d.ts +3 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +7 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/index.mjs +5 -1
- package/dist/primitives/index.mjs.map +1 -1
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts +5 -1
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.js.map +1 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.d.ts +1 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.d.ts.map +1 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.js +2 -2
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.js.map +1 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.mjs +2 -2
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.mjs.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.d.ts +1 -2
- package/dist/runtimes/edge/EdgeChatAdapter.d.ts.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.js +6 -8
- package/dist/runtimes/edge/EdgeChatAdapter.js.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.mjs +9 -8
- package/dist/runtimes/edge/EdgeChatAdapter.mjs.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.d.ts +2 -2
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js +5 -2
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs +5 -2
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.js +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.mjs +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js +2 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +2 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts +2 -2
- package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js +17 -34
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs +21 -37
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs.map +1 -1
- package/dist/runtimes/edge/index.d.ts +0 -1
- package/dist/runtimes/edge/index.d.ts.map +1 -1
- package/dist/runtimes/edge/index.js +1 -3
- package/dist/runtimes/edge/index.js.map +1 -1
- package/dist/runtimes/edge/index.mjs +0 -1
- package/dist/runtimes/edge/index.mjs.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.d.ts +2 -33
- package/dist/runtimes/edge/streams/toolResultStream.d.ts.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.js +19 -96
- package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.mjs +19 -86
- package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +1 -0
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +1 -0
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.d.ts +2 -2
- package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +3 -2
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +22 -7
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +22 -7
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/utils/MessageRepository.d.ts +1 -0
- package/dist/runtimes/utils/MessageRepository.d.ts.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js +3 -0
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.mjs +3 -0
- package/dist/runtimes/utils/MessageRepository.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +1 -1
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/utils/json/is-json.d.ts +1 -1
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/is-json.js +10 -4
- package/dist/utils/json/is-json.js.map +1 -1
- package/dist/utils/json/is-json.mjs +10 -4
- package/dist/utils/json/is-json.mjs.map +1 -1
- package/package.json +5 -5
- package/src/cloud/auiV0.ts +9 -2
- package/src/primitives/contentPart/useContentPartFile.tsx +18 -0
- package/src/primitives/contentPart/useContentPartSource.tsx +18 -0
- package/src/primitives/index.ts +3 -1
- package/src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts +5 -1
- package/src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts +2 -2
- package/src/runtimes/edge/EdgeChatAdapter.ts +18 -19
- package/src/runtimes/edge/converters/fromLanguageModelMessages.ts +24 -14
- package/src/runtimes/edge/converters/toCoreMessages.ts +6 -2
- package/src/runtimes/edge/converters/toLanguageModelMessages.ts +3 -2
- package/src/runtimes/edge/createEdgeRuntimeAPI.ts +25 -47
- package/src/runtimes/edge/index.ts +0 -2
- package/src/runtimes/edge/streams/toolResultStream.ts +28 -152
- package/src/runtimes/external-store/ThreadMessageLike.tsx +2 -1
- package/src/runtimes/local/ChatModelAdapter.tsx +2 -0
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +31 -7
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +1 -2
- package/src/runtimes/utils/MessageRepository.tsx +4 -0
- package/src/types/AssistantTypes.ts +2 -1
- package/src/utils/json/is-json.ts +17 -4
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.d.ts +0 -62
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.js +0 -46
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.js.map +0 -1
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.mjs +0 -21
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.mjs.map +0 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.d.ts +0 -5
- package/dist/runtimes/edge/streams/assistantDecoderStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.js +0 -170
- package/dist/runtimes/edge/streams/assistantDecoderStream.js.map +0 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.mjs +0 -147
- package/dist/runtimes/edge/streams/assistantDecoderStream.mjs.map +0 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.d.ts +0 -5
- package/dist/runtimes/edge/streams/assistantEncoderStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.js +0 -137
- package/dist/runtimes/edge/streams/assistantEncoderStream.js.map +0 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.mjs +0 -114
- package/dist/runtimes/edge/streams/assistantEncoderStream.mjs.map +0 -1
- package/dist/runtimes/edge/streams/runResultStream.d.ts +0 -4
- package/dist/runtimes/edge/streams/runResultStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/runResultStream.js +0 -313
- package/dist/runtimes/edge/streams/runResultStream.js.map +0 -1
- package/dist/runtimes/edge/streams/runResultStream.mjs +0 -288
- package/dist/runtimes/edge/streams/runResultStream.mjs.map +0 -1
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.d.ts +0 -4
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.js.map +0 -1
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.mjs +0 -15
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.mjs.map +0 -1
- package/dist/runtimes/edge/streams/utils/StreamPart.d.ts +0 -7
- package/dist/runtimes/edge/streams/utils/StreamPart.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/utils/StreamPart.js +0 -19
- package/dist/runtimes/edge/streams/utils/StreamPart.js.map +0 -1
- package/dist/runtimes/edge/streams/utils/StreamPart.mjs +0 -1
- package/dist/runtimes/edge/streams/utils/StreamPart.mjs.map +0 -1
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.d.ts +0 -2
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.js +0 -48
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.js.map +0 -1
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.mjs +0 -23
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.mjs.map +0 -1
- package/dist/runtimes/edge/streams/utils/index.d.ts +0 -14
- package/dist/runtimes/edge/streams/utils/index.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/utils/index.js.map +0 -1
- package/dist/runtimes/edge/streams/utils/index.mjs +0 -11
- package/dist/runtimes/edge/streams/utils/index.mjs.map +0 -1
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.d.ts +0 -4
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.js +0 -50
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.js.map +0 -1
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.mjs +0 -25
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.mjs.map +0 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.d.ts +0 -3
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.js +0 -48
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.js.map +0 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.mjs +0 -23
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.mjs.map +0 -1
- package/src/runtimes/edge/streams/AssistantStreamChunkType.ts +0 -73
- package/src/runtimes/edge/streams/assistantDecoderStream.ts +0 -170
- package/src/runtimes/edge/streams/assistantEncoderStream.ts +0 -126
- package/src/runtimes/edge/streams/runResultStream.ts +0 -360
- package/src/runtimes/edge/streams/utils/PipeableTransformStream.ts +0 -10
- package/src/runtimes/edge/streams/utils/StreamPart.ts +0 -3
- package/src/runtimes/edge/streams/utils/chunkByLineStream.ts +0 -24
- package/src/runtimes/edge/streams/utils/index.ts +0 -15
- package/src/runtimes/edge/streams/utils/streamPartDecoderStream.ts +0 -29
- package/src/runtimes/edge/streams/utils/streamPartEncoderStream.ts +0 -23
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/json/is-json.ts"],"sourcesContent":["import {\n ReadonlyJSONArray,\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"./json-value\";\n\nexport function isJSONValue(value: unknown): value is ReadonlyJSONValue {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"
|
1
|
+
{"version":3,"sources":["../../../src/utils/json/is-json.ts"],"sourcesContent":["import {\n ReadonlyJSONArray,\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"./json-value\";\n\nexport function isJSONValue(\n value: unknown,\n currentDepth: number = 0,\n): value is ReadonlyJSONValue {\n // Protect against too deep recursion\n if (currentDepth > 100) {\n return false;\n }\n\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n ) {\n return true;\n }\n\n // Handle special number cases\n if (typeof value === \"number\") {\n return !Number.isNaN(value) && Number.isFinite(value);\n }\n\n if (Array.isArray(value)) {\n return value.every((item) => isJSONValue(item, currentDepth + 1));\n }\n\n if (typeof value === \"object\") {\n return Object.entries(value).every(\n ([key, val]) =>\n typeof key === \"string\" && isJSONValue(val, currentDepth + 1),\n );\n }\n\n return false;\n}\n\nexport function isJSONArray(value: unknown): value is ReadonlyJSONArray {\n return Array.isArray(value) && value.every(isJSONValue);\n}\n\nexport function isJSONObject(value: unknown): value is ReadonlyJSONObject {\n return (\n value != null &&\n typeof value === \"object\" &&\n Object.entries(value).every(\n ([key, val]) => typeof key === \"string\" && isJSONValue(val),\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,YACd,OACA,eAAuB,GACK;AAE5B,MAAI,eAAe,KAAK;AACtB,WAAO;AAAA,EACT;AAEA,MACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,CAAC,OAAO,MAAM,KAAK,KAAK,OAAO,SAAS,KAAK;AAAA,EACtD;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,MAAM,CAAC,SAAS,YAAY,MAAM,eAAe,CAAC,CAAC;AAAA,EAClE;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,YAAY,YAAY,KAAK,eAAe,CAAC;AAAA,IAChE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,YAAY,OAA4C;AACtE,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,WAAW;AACxD;AAEO,SAAS,aAAa,OAA6C;AACxE,SACE,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,QAAQ,KAAK,EAAE;AAAA,IACpB,CAAC,CAAC,KAAK,GAAG,MAAM,OAAO,QAAQ,YAAY,YAAY,GAAG;AAAA,EAC5D;AAEJ;","names":[]}
|
@@ -1,14 +1,20 @@
|
|
1
1
|
// src/utils/json/is-json.ts
|
2
|
-
function isJSONValue(value) {
|
3
|
-
if (
|
2
|
+
function isJSONValue(value, currentDepth = 0) {
|
3
|
+
if (currentDepth > 100) {
|
4
|
+
return false;
|
5
|
+
}
|
6
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
4
7
|
return true;
|
5
8
|
}
|
9
|
+
if (typeof value === "number") {
|
10
|
+
return !Number.isNaN(value) && Number.isFinite(value);
|
11
|
+
}
|
6
12
|
if (Array.isArray(value)) {
|
7
|
-
return value.every(isJSONValue);
|
13
|
+
return value.every((item) => isJSONValue(item, currentDepth + 1));
|
8
14
|
}
|
9
15
|
if (typeof value === "object") {
|
10
16
|
return Object.entries(value).every(
|
11
|
-
([key, val]) => typeof key === "string" && isJSONValue(val)
|
17
|
+
([key, val]) => typeof key === "string" && isJSONValue(val, currentDepth + 1)
|
12
18
|
);
|
13
19
|
}
|
14
20
|
return false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/json/is-json.ts"],"sourcesContent":["import {\n ReadonlyJSONArray,\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"./json-value\";\n\nexport function isJSONValue(value: unknown): value is ReadonlyJSONValue {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"
|
1
|
+
{"version":3,"sources":["../../../src/utils/json/is-json.ts"],"sourcesContent":["import {\n ReadonlyJSONArray,\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"./json-value\";\n\nexport function isJSONValue(\n value: unknown,\n currentDepth: number = 0,\n): value is ReadonlyJSONValue {\n // Protect against too deep recursion\n if (currentDepth > 100) {\n return false;\n }\n\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n ) {\n return true;\n }\n\n // Handle special number cases\n if (typeof value === \"number\") {\n return !Number.isNaN(value) && Number.isFinite(value);\n }\n\n if (Array.isArray(value)) {\n return value.every((item) => isJSONValue(item, currentDepth + 1));\n }\n\n if (typeof value === \"object\") {\n return Object.entries(value).every(\n ([key, val]) =>\n typeof key === \"string\" && isJSONValue(val, currentDepth + 1),\n );\n }\n\n return false;\n}\n\nexport function isJSONArray(value: unknown): value is ReadonlyJSONArray {\n return Array.isArray(value) && value.every(isJSONValue);\n}\n\nexport function isJSONObject(value: unknown): value is ReadonlyJSONObject {\n return (\n value != null &&\n typeof value === \"object\" &&\n Object.entries(value).every(\n ([key, val]) => typeof key === \"string\" && isJSONValue(val),\n )\n );\n}\n"],"mappings":";AAMO,SAAS,YACd,OACA,eAAuB,GACK;AAE5B,MAAI,eAAe,KAAK;AACtB,WAAO;AAAA,EACT;AAEA,MACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,CAAC,OAAO,MAAM,KAAK,KAAK,OAAO,SAAS,KAAK;AAAA,EACtD;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,MAAM,CAAC,SAAS,YAAY,MAAM,eAAe,CAAC,CAAC;AAAA,EAClE;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,YAAY,YAAY,KAAK,eAAe,CAAC;AAAA,IAChE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,YAAY,OAA4C;AACtE,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,WAAW;AACxD;AAEO,SAAS,aAAa,OAA6C;AACxE,SACE,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,QAAQ,KAAK,EAAE;AAAA,IACpB,CAAC,CAAC,KAAK,GAAG,MAAM,OAAO,QAAQ,YAAY,YAAY,GAAG;AAAA,EAC5D;AAEJ;","names":[]}
|
package/package.json
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
"conversational-ui",
|
30
30
|
"conversational-ai"
|
31
31
|
],
|
32
|
-
"version": "0.8.
|
32
|
+
"version": "0.8.8",
|
33
33
|
"license": "MIT",
|
34
34
|
"exports": {
|
35
35
|
".": {
|
@@ -56,7 +56,7 @@
|
|
56
56
|
],
|
57
57
|
"sideEffects": false,
|
58
58
|
"dependencies": {
|
59
|
-
"@ai-sdk/provider": "^1.0
|
59
|
+
"@ai-sdk/provider": "^1.1.0",
|
60
60
|
"@radix-ui/primitive": "^1.1.1",
|
61
61
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
62
62
|
"@radix-ui/react-context": "^1.1.1",
|
@@ -72,7 +72,7 @@
|
|
72
72
|
"zod": "^3.24.1",
|
73
73
|
"zod-to-json-schema": "^3.24.1",
|
74
74
|
"zustand": "^5.0.3",
|
75
|
-
"assistant-stream": "^0.0.
|
75
|
+
"assistant-stream": "^0.0.23"
|
76
76
|
},
|
77
77
|
"peerDependencies": {
|
78
78
|
"@types/react": "*",
|
@@ -94,8 +94,8 @@
|
|
94
94
|
"eslint": "^9",
|
95
95
|
"eslint-config-next": "15.1.6",
|
96
96
|
"tsx": "^4.19.2",
|
97
|
-
"@assistant-ui/
|
98
|
-
"@assistant-ui/
|
97
|
+
"@assistant-ui/tsbuildutils": "^0.0.1",
|
98
|
+
"@assistant-ui/tsconfig": "0.0.0"
|
99
99
|
},
|
100
100
|
"publishConfig": {
|
101
101
|
"access": "public",
|
package/src/cloud/auiV0.ts
CHANGED
@@ -82,8 +82,15 @@ export const auiV0Encode = (message: ThreadMessage): AuiV0Message => {
|
|
82
82
|
};
|
83
83
|
}
|
84
84
|
|
85
|
-
case "source":
|
86
|
-
return
|
85
|
+
case "source": {
|
86
|
+
return {
|
87
|
+
type: "source",
|
88
|
+
sourceType: part.sourceType,
|
89
|
+
id: part.id,
|
90
|
+
url: part.url,
|
91
|
+
...(part.title ? { title: part.title } : undefined),
|
92
|
+
};
|
93
|
+
}
|
87
94
|
|
88
95
|
case "tool-call": {
|
89
96
|
if (!isJSONValue(part.result)) {
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { ContentPartState } from "../../api/ContentPartRuntime";
|
4
|
+
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
|
+
import { FileContentPart } from "../../types";
|
6
|
+
|
7
|
+
export const useContentPartFile = () => {
|
8
|
+
const file = useContentPart((c) => {
|
9
|
+
if (c.type !== "file")
|
10
|
+
throw new Error(
|
11
|
+
"ContentPartFile can only be used inside file content parts.",
|
12
|
+
);
|
13
|
+
|
14
|
+
return c as ContentPartState & FileContentPart;
|
15
|
+
});
|
16
|
+
|
17
|
+
return file;
|
18
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { ContentPartState } from "../../api/ContentPartRuntime";
|
4
|
+
import { useContentPart } from "../../context/react/ContentPartContext";
|
5
|
+
import { SourceContentPart } from "../../types";
|
6
|
+
|
7
|
+
export const useContentPartSource = () => {
|
8
|
+
const source = useContentPart((c) => {
|
9
|
+
if (c.type !== "source")
|
10
|
+
throw new Error(
|
11
|
+
"ContentPartSource can only be used inside source content parts.",
|
12
|
+
);
|
13
|
+
|
14
|
+
return c as ContentPartState & SourceContentPart;
|
15
|
+
});
|
16
|
+
|
17
|
+
return source;
|
18
|
+
};
|
package/src/primitives/index.ts
CHANGED
@@ -9,7 +9,9 @@ export * as ThreadPrimitive from "./thread";
|
|
9
9
|
export * as ThreadListPrimitive from "./threadList";
|
10
10
|
export * as ThreadListItemPrimitive from "./threadListItem";
|
11
11
|
|
12
|
-
export { useContentPartImage } from "./contentPart/useContentPartImage";
|
13
12
|
export { useContentPartText } from "./contentPart/useContentPartText";
|
14
13
|
export { useContentPartReasoning } from "./contentPart/useContentPartReasoning";
|
14
|
+
export { useContentPartSource } from "./contentPart/useContentPartSource";
|
15
|
+
export { useContentPartFile } from "./contentPart/useContentPartFile";
|
16
|
+
export { useContentPartImage } from "./contentPart/useContentPartImage";
|
15
17
|
export { useThreadViewportAutoScroll } from "./thread/useThreadViewportAutoScroll";
|
@@ -1,9 +1,13 @@
|
|
1
|
+
import { ChatModelRunOptions, ChatModelRunResult } from "../../local";
|
1
2
|
import {
|
2
3
|
ExportedMessageRepository,
|
3
4
|
ExportedMessageRepositoryItem,
|
4
5
|
} from "../../utils/MessageRepository";
|
5
6
|
|
6
7
|
export type ThreadHistoryAdapter = {
|
7
|
-
load(): Promise<ExportedMessageRepository>;
|
8
|
+
load(): Promise<ExportedMessageRepository & { unstable_resume?: boolean }>;
|
9
|
+
resume?(
|
10
|
+
options: ChatModelRunOptions,
|
11
|
+
): AsyncGenerator<ChatModelRunResult, void, unknown>;
|
8
12
|
append(item: ExportedMessageRepositoryItem): Promise<void>;
|
9
13
|
};
|
@@ -5,13 +5,13 @@ import {
|
|
5
5
|
import { toCoreMessages } from "../edge/converters/toCoreMessages";
|
6
6
|
import { toLanguageModelTools } from "../edge/converters/toLanguageModelTools";
|
7
7
|
import { EdgeRuntimeRequestOptions } from "../edge/EdgeRuntimeRequestOptions";
|
8
|
-
import { runResultStream } from "../edge/streams/runResultStream";
|
9
8
|
import { toolResultStream } from "../edge/streams/toolResultStream";
|
10
9
|
import { asAsyncIterable } from "../edge/EdgeChatAdapter";
|
11
10
|
import {
|
12
11
|
CreateEdgeRuntimeAPIOptions,
|
13
12
|
getEdgeRuntimeStream,
|
14
13
|
} from "../edge/createEdgeRuntimeAPI";
|
14
|
+
import { AssistantMessageAccumulator } from "assistant-stream";
|
15
15
|
|
16
16
|
export type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
|
17
17
|
|
@@ -33,7 +33,7 @@ export class DangerousInBrowserAdapter implements ChatModelAdapter {
|
|
33
33
|
|
34
34
|
const stream = res
|
35
35
|
.pipeThrough(toolResultStream(context.tools, abortSignal))
|
36
|
-
.pipeThrough(
|
36
|
+
.pipeThrough(new AssistantMessageAccumulator());
|
37
37
|
|
38
38
|
for await (const update of asAsyncIterable(stream)) {
|
39
39
|
yield update;
|
@@ -2,13 +2,9 @@ import {
|
|
2
2
|
ChatModelAdapter,
|
3
3
|
ChatModelRunOptions,
|
4
4
|
} from "../local/ChatModelAdapter";
|
5
|
-
import { ChatModelRunResult } from "../local/ChatModelAdapter";
|
6
5
|
import { toCoreMessages } from "./converters/toCoreMessages";
|
7
6
|
import { toLanguageModelTools } from "./converters/toLanguageModelTools";
|
8
7
|
import { EdgeRuntimeRequestOptions } from "./EdgeRuntimeRequestOptions";
|
9
|
-
import { assistantDecoderStream } from "./streams/assistantDecoderStream";
|
10
|
-
import { streamPartDecoderStream } from "./streams/utils/streamPartDecoderStream";
|
11
|
-
import { runResultStream } from "./streams/runResultStream";
|
12
8
|
import { toolResultStream } from "./streams/toolResultStream";
|
13
9
|
import { toLanguageModelMessages } from "./converters";
|
14
10
|
import { ThreadMessage } from "../../types";
|
@@ -16,6 +12,10 @@ import { Tool } from "../../model-context";
|
|
16
12
|
import { z } from "zod";
|
17
13
|
import zodToJsonSchema from "zod-to-json-schema";
|
18
14
|
import { JSONSchema7 } from "json-schema";
|
15
|
+
import {
|
16
|
+
AssistantMessageAccumulator,
|
17
|
+
DataStreamDecoder,
|
18
|
+
} from "assistant-stream";
|
19
19
|
|
20
20
|
export function asAsyncIterable<T>(
|
21
21
|
source: ReadableStream<T>,
|
@@ -67,13 +67,13 @@ export type EdgeChatAdapterOptions = {
|
|
67
67
|
onError?: (error: Error) => void;
|
68
68
|
|
69
69
|
credentials?: RequestCredentials;
|
70
|
-
|
70
|
+
|
71
71
|
/**
|
72
72
|
* Headers to be sent with the request.
|
73
73
|
* Can be a static headers object or a function that returns a Promise of headers.
|
74
74
|
*/
|
75
75
|
headers?: HeadersValue | (() => Promise<HeadersValue>);
|
76
|
-
|
76
|
+
|
77
77
|
body?: object;
|
78
78
|
|
79
79
|
/**
|
@@ -120,10 +120,11 @@ export class EdgeChatAdapter implements ChatModelAdapter {
|
|
120
120
|
unstable_assistantMessageId,
|
121
121
|
unstable_getMessage,
|
122
122
|
}: ChatModelRunOptions) {
|
123
|
-
const headersValue =
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
const headersValue =
|
124
|
+
typeof this.options.headers === "function"
|
125
|
+
? await this.options.headers()
|
126
|
+
: this.options.headers;
|
127
|
+
|
127
128
|
const headers = new Headers(headersValue);
|
128
129
|
headers.set("Content-Type", "application/json");
|
129
130
|
|
@@ -165,21 +166,19 @@ export class EdgeChatAdapter implements ChatModelAdapter {
|
|
165
166
|
if (!result.ok) {
|
166
167
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
167
168
|
}
|
169
|
+
if (!result.body) {
|
170
|
+
throw new Error("Response body is null");
|
171
|
+
}
|
168
172
|
|
169
|
-
const stream = result
|
170
|
-
.
|
171
|
-
.pipeThrough(assistantDecoderStream())
|
173
|
+
const stream = result.body
|
174
|
+
.pipeThrough(new DataStreamDecoder())
|
172
175
|
.pipeThrough(toolResultStream(context.tools, abortSignal))
|
173
|
-
.pipeThrough(
|
176
|
+
.pipeThrough(new AssistantMessageAccumulator());
|
174
177
|
|
175
|
-
|
176
|
-
for await (update of asAsyncIterable(stream)) {
|
178
|
+
for await (const update of asAsyncIterable(stream)) {
|
177
179
|
yield update;
|
178
180
|
}
|
179
181
|
|
180
|
-
if (update === undefined)
|
181
|
-
throw new Error("No data received from Edge Runtime");
|
182
|
-
|
183
182
|
this.options.onFinish?.(unstable_getMessage());
|
184
183
|
} catch (error: unknown) {
|
185
184
|
this.options.onError?.(error as Error);
|
@@ -4,12 +4,12 @@ import { Writable } from "stream";
|
|
4
4
|
import { ReadonlyJSONObject } from "../../../utils/json/json-value";
|
5
5
|
|
6
6
|
type fromLanguageModelMessagesOptions = {
|
7
|
-
mergeSteps
|
7
|
+
mergeSteps?: boolean;
|
8
8
|
};
|
9
9
|
|
10
10
|
export const fromLanguageModelMessages = (
|
11
11
|
lm: LanguageModelV1Message[],
|
12
|
-
{ mergeSteps }: fromLanguageModelMessagesOptions,
|
12
|
+
{ mergeSteps }: fromLanguageModelMessagesOptions = {},
|
13
13
|
): CoreMessage[] => {
|
14
14
|
const messages: CoreMessage[] = [];
|
15
15
|
|
@@ -70,18 +70,28 @@ export const fromLanguageModelMessages = (
|
|
70
70
|
break;
|
71
71
|
}
|
72
72
|
case "assistant": {
|
73
|
-
const newContent = lmMessage.content
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
73
|
+
const newContent = lmMessage.content
|
74
|
+
.map((part) => {
|
75
|
+
if (part.type === "tool-call") {
|
76
|
+
return {
|
77
|
+
type: "tool-call",
|
78
|
+
toolCallId: part.toolCallId,
|
79
|
+
toolName: part.toolName,
|
80
|
+
argsText: JSON.stringify(part.args),
|
81
|
+
args: part.args as ReadonlyJSONObject,
|
82
|
+
} satisfies ToolCallContentPart;
|
83
|
+
}
|
84
|
+
// TODO handle these
|
85
|
+
if (
|
86
|
+
part.type === "redacted-reasoning" ||
|
87
|
+
part.type === "file" ||
|
88
|
+
part.type === "reasoning"
|
89
|
+
) {
|
90
|
+
return null;
|
91
|
+
}
|
92
|
+
return part;
|
93
|
+
})
|
94
|
+
.filter((p) => !!p);
|
85
95
|
|
86
96
|
if (mergeSteps) {
|
87
97
|
const previousMessage = messages[messages.length - 1];
|
@@ -23,8 +23,12 @@ export const toCoreMessage = <T extends boolean = false>(
|
|
23
23
|
role,
|
24
24
|
content: message.content
|
25
25
|
.map((part) => {
|
26
|
-
if (
|
27
|
-
|
26
|
+
if (
|
27
|
+
part.type === "reasoning" ||
|
28
|
+
part.type === "source" ||
|
29
|
+
part.type === "file"
|
30
|
+
)
|
31
|
+
return null; // reasoning, source, and file parts are omitted
|
28
32
|
if (part.type === "tool-call") {
|
29
33
|
const { argsText, ...rest } = part;
|
30
34
|
return rest;
|
@@ -151,8 +151,9 @@ export function toLanguageModelMessages(
|
|
151
151
|
const type = part.type;
|
152
152
|
switch (type) {
|
153
153
|
case "reasoning":
|
154
|
-
case "source":
|
155
|
-
|
154
|
+
case "source":
|
155
|
+
case "file": {
|
156
|
+
break; // reasoning, source, and file parts are omitted
|
156
157
|
}
|
157
158
|
|
158
159
|
case "text": {
|
@@ -10,24 +10,24 @@ import {
|
|
10
10
|
ThreadMessage,
|
11
11
|
ThreadStep,
|
12
12
|
} from "../../types/AssistantTypes";
|
13
|
-
import { assistantEncoderStream } from "./streams/assistantEncoderStream";
|
14
13
|
import { EdgeRuntimeRequestOptionsSchema } from "./EdgeRuntimeRequestOptions";
|
15
14
|
import { toLanguageModelMessages } from "./converters/toLanguageModelMessages";
|
16
15
|
import { toLanguageModelTools } from "./converters/toLanguageModelTools";
|
17
|
-
import {
|
18
|
-
toolResultStream,
|
19
|
-
ToolResultStreamPart,
|
20
|
-
} from "./streams/toolResultStream";
|
21
|
-
import { runResultStream } from "./streams/runResultStream";
|
16
|
+
import { toolResultStream } from "./streams/toolResultStream";
|
22
17
|
import {
|
23
18
|
LanguageModelConfig,
|
24
19
|
LanguageModelV1CallSettings,
|
25
20
|
LanguageModelV1CallSettingsSchema,
|
26
21
|
Tool,
|
27
22
|
} from "../../model-context/ModelContextTypes";
|
28
|
-
import { CoreChatModelRunResult } from "../local/ChatModelAdapter";
|
29
|
-
import { streamPartEncoderStream } from "./streams/utils/streamPartEncoderStream";
|
30
23
|
import { z } from "zod";
|
24
|
+
import {
|
25
|
+
AssistantMessage,
|
26
|
+
AssistantMessageAccumulator,
|
27
|
+
AssistantStreamChunk,
|
28
|
+
DataStreamEncoder,
|
29
|
+
} from "assistant-stream";
|
30
|
+
import { LanguageModelV1StreamDecoder } from "assistant-stream/ai-sdk";
|
31
31
|
|
32
32
|
type FinishResult = {
|
33
33
|
messages: readonly (CoreMessage | ThreadMessage)[];
|
@@ -48,14 +48,6 @@ export type CreateEdgeRuntimeAPIOptions = LanguageModelV1CallSettings & {
|
|
48
48
|
onFinish?: (result: FinishResult) => void;
|
49
49
|
};
|
50
50
|
|
51
|
-
const voidStream = () => {
|
52
|
-
return new WritableStream({
|
53
|
-
abort(reason) {
|
54
|
-
console.error("Server stream processing aborted:", reason);
|
55
|
-
},
|
56
|
-
});
|
57
|
-
};
|
58
|
-
|
59
51
|
type GetEdgeRuntimeStreamOptions = {
|
60
52
|
abortSignal: AbortSignal;
|
61
53
|
requestData: z.infer<typeof EdgeRuntimeRequestOptionsSchema>;
|
@@ -106,7 +98,7 @@ export const getEdgeRuntimeStream = async ({
|
|
106
98
|
? await modelOrCreator({ apiKey, baseUrl, modelName })
|
107
99
|
: modelOrCreator;
|
108
100
|
|
109
|
-
let stream: ReadableStream<
|
101
|
+
let stream: ReadableStream<AssistantStreamChunk>;
|
110
102
|
const streamResult = await streamMessage({
|
111
103
|
...(settings as Partial<StreamMessageOptions>),
|
112
104
|
...callSettings,
|
@@ -119,7 +111,7 @@ export const getEdgeRuntimeStream = async ({
|
|
119
111
|
tools: lmServerTools.concat(clientTools as LanguageModelV1FunctionTool[]),
|
120
112
|
...(toolChoice ? { toolChoice } : undefined),
|
121
113
|
});
|
122
|
-
stream = streamResult.stream;
|
114
|
+
stream = streamResult.stream.pipeThrough(new LanguageModelV1StreamDecoder());
|
123
115
|
|
124
116
|
// add tool results if we have server tools
|
125
117
|
const canExecuteTools = hasServerTools && toolChoice?.type !== "none";
|
@@ -134,13 +126,13 @@ export const getEdgeRuntimeStream = async ({
|
|
134
126
|
let serverStream = tees[1];
|
135
127
|
|
136
128
|
if (onFinish) {
|
137
|
-
let lastChunk:
|
138
|
-
serverStream
|
139
|
-
new
|
140
|
-
|
129
|
+
let lastChunk: AssistantMessage | undefined;
|
130
|
+
serverStream.pipeThrough(new AssistantMessageAccumulator()).pipeTo(
|
131
|
+
new WritableStream({
|
132
|
+
write(chunk) {
|
141
133
|
lastChunk = chunk;
|
142
134
|
},
|
143
|
-
|
135
|
+
close() {
|
144
136
|
if (!lastChunk?.status || lastChunk.status.type === "running")
|
145
137
|
return;
|
146
138
|
|
@@ -152,32 +144,22 @@ export const getEdgeRuntimeStream = async ({
|
|
152
144
|
role: "assistant",
|
153
145
|
content: lastChunk.content,
|
154
146
|
status: lastChunk.status,
|
155
|
-
metadata:
|
156
|
-
unstable_data: lastChunk.metadata?.unstable_data ?? [],
|
157
|
-
unstable_annotations:
|
158
|
-
lastChunk.metadata?.unstable_annotations ?? [],
|
159
|
-
steps: lastChunk.metadata?.steps ?? [],
|
160
|
-
custom: lastChunk.metadata?.custom ?? {},
|
161
|
-
},
|
147
|
+
metadata: lastChunk.metadata,
|
162
148
|
} satisfies ThreadMessage,
|
163
149
|
];
|
164
150
|
onFinish({
|
165
151
|
messages: resultingMessages,
|
166
152
|
metadata: {
|
167
|
-
|
168
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
169
|
-
steps: lastChunk.metadata?.steps!,
|
153
|
+
steps: lastChunk.metadata.steps,
|
170
154
|
},
|
171
155
|
});
|
172
156
|
},
|
157
|
+
abort(e) {
|
158
|
+
console.error("Server stream processing error:", e);
|
159
|
+
},
|
173
160
|
}),
|
174
161
|
);
|
175
162
|
}
|
176
|
-
|
177
|
-
// drain the server stream
|
178
|
-
serverStream.pipeTo(voidStream()).catch((e) => {
|
179
|
-
console.error("Server stream processing error:", e);
|
180
|
-
});
|
181
163
|
}
|
182
164
|
|
183
165
|
return stream;
|
@@ -191,16 +173,12 @@ export const getEdgeRuntimeResponse = async (
|
|
191
173
|
options: getEdgeRuntimeResponse.Options,
|
192
174
|
) => {
|
193
175
|
const stream = await getEdgeRuntimeStream(options);
|
194
|
-
return new Response(
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
{
|
199
|
-
headers: {
|
200
|
-
"Content-Type": "text/plain; charset=utf-8",
|
201
|
-
},
|
176
|
+
return new Response(stream.pipeThrough(new DataStreamEncoder()), {
|
177
|
+
headers: {
|
178
|
+
"Content-Type": "text/plain; charset=utf-8",
|
179
|
+
"x-vercel-ai-data-stream": "v1",
|
202
180
|
},
|
203
|
-
);
|
181
|
+
});
|
204
182
|
};
|
205
183
|
|
206
184
|
export const createEdgeRuntimeAPI = (options: CreateEdgeRuntimeAPIOptions) => ({
|
@@ -1,7 +1,5 @@
|
|
1
1
|
export * from "./converters";
|
2
2
|
|
3
|
-
export * from "./streams/utils";
|
4
|
-
|
5
3
|
export { useEdgeRuntime, type EdgeRuntimeOptions } from "./useEdgeRuntime";
|
6
4
|
export { EdgeChatAdapter } from "./EdgeChatAdapter";
|
7
5
|
export type { EdgeRuntimeRequestOptions } from "./EdgeRuntimeRequestOptions";
|