@assistant-ui/core 0.1.1 → 0.1.3
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/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +2 -4
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/react/RuntimeAdapter.js +4 -1
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +7 -1
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +97 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +111 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +115 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +444 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -0
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +18 -0
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -0
- package/dist/react/runtimes/RuntimeAdapterProvider.js +14 -0
- package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -0
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +5 -0
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +528 -0
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -0
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +15 -0
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +83 -0
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -0
- package/dist/react/runtimes/cloud/auiV0.d.ts +62 -0
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/auiV0.js +74 -0
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -0
- package/dist/react/runtimes/cloud/index.d.ts +4 -0
- package/dist/react/runtimes/cloud/index.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/index.js +4 -0
- package/dist/react/runtimes/cloud/index.js.map +1 -0
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +13 -0
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +102 -0
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -0
- package/dist/react/runtimes/createMessageConverter.d.ts +17 -0
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -0
- package/dist/react/runtimes/createMessageConverter.js +50 -0
- package/dist/react/runtimes/createMessageConverter.js.map +1 -0
- package/dist/react/runtimes/external-message-converter.d.ts +34 -0
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -0
- package/dist/react/runtimes/external-message-converter.js +309 -0
- package/dist/react/runtimes/external-message-converter.js.map +1 -0
- package/dist/react/runtimes/index.d.ts +10 -0
- package/dist/react/runtimes/index.d.ts.map +1 -0
- package/dist/react/runtimes/index.js +10 -0
- package/dist/react/runtimes/index.js.map +1 -0
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts +4 -0
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -0
- package/dist/react/runtimes/useExternalStoreRuntime.js +19 -0
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -0
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +4 -0
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -0
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +48 -0
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -0
- package/dist/react/runtimes/useToolInvocations.d.ts +38 -0
- package/dist/react/runtimes/useToolInvocations.d.ts.map +1 -0
- package/dist/react/runtimes/useToolInvocations.js +411 -0
- package/dist/react/runtimes/useToolInvocations.js.map +1 -0
- package/dist/react/types/store-augmentation.d.ts +0 -1
- package/dist/react/types/store-augmentation.d.ts.map +1 -1
- package/dist/react/types/store-augmentation.js +1 -1
- package/dist/react/types/store-augmentation.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +2 -0
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -2
- package/dist/store/index.js.map +1 -1
- package/dist/utils/json/is-json-equal.d.ts +2 -0
- package/dist/utils/json/is-json-equal.d.ts.map +1 -0
- package/dist/utils/json/is-json-equal.js +31 -0
- package/dist/utils/json/is-json-equal.js.map +1 -0
- package/dist/utils/json/is-json.d.ts +6 -0
- package/dist/utils/json/is-json.d.ts.map +1 -0
- package/dist/utils/json/is-json.js +33 -0
- package/dist/utils/json/is-json.js.map +1 -0
- package/package.json +10 -9
- package/src/model-context/frame/provider.ts +2 -6
- package/src/react/RuntimeAdapter.ts +5 -1
- package/src/react/index.ts +2 -1
- package/src/react/model-context/toolbox.ts +7 -3
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +176 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +534 -0
- package/src/react/runtimes/RuntimeAdapterProvider.tsx +40 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +785 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +101 -0
- package/src/react/runtimes/cloud/auiV0.ts +160 -0
- package/src/react/runtimes/cloud/index.ts +3 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +152 -0
- package/src/react/runtimes/createMessageConverter.ts +77 -0
- package/src/react/runtimes/external-message-converter.ts +487 -0
- package/src/react/runtimes/index.ts +30 -0
- package/src/react/runtimes/useExternalStoreRuntime.ts +27 -0
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +76 -0
- package/src/react/runtimes/useToolInvocations.ts +594 -0
- package/src/react/types/store-augmentation.ts +0 -2
- package/src/runtime/base/base-composer-runtime-core.ts +2 -0
- package/src/store/index.ts +1 -2
- package/src/utils/json/is-json-equal.ts +48 -0
- package/src/utils/json/is-json.ts +58 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReadonlyJSONArray,
|
|
3
|
+
ReadonlyJSONObject,
|
|
4
|
+
ReadonlyJSONValue,
|
|
5
|
+
} from "assistant-stream/utils";
|
|
6
|
+
|
|
7
|
+
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
8
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isJSONValue(
|
|
12
|
+
value: unknown,
|
|
13
|
+
currentDepth: number = 0,
|
|
14
|
+
): value is ReadonlyJSONValue {
|
|
15
|
+
// Protect against too deep recursion
|
|
16
|
+
if (currentDepth > 100) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (
|
|
21
|
+
value === null ||
|
|
22
|
+
typeof value === "string" ||
|
|
23
|
+
typeof value === "boolean"
|
|
24
|
+
) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Handle special number cases
|
|
29
|
+
if (typeof value === "number") {
|
|
30
|
+
return !Number.isNaN(value) && Number.isFinite(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
return value.every((item) => isJSONValue(item, currentDepth + 1));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isRecord(value)) {
|
|
38
|
+
return Object.entries(value).every(
|
|
39
|
+
([key, val]) =>
|
|
40
|
+
typeof key === "string" && isJSONValue(val, currentDepth + 1),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function isJSONArray(value: unknown): value is ReadonlyJSONArray {
|
|
48
|
+
return Array.isArray(value) && value.every(isJSONValue);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function isJSONObject(value: unknown): value is ReadonlyJSONObject {
|
|
52
|
+
return (
|
|
53
|
+
isRecord(value) &&
|
|
54
|
+
Object.entries(value).every(
|
|
55
|
+
([key, val]) => typeof key === "string" && isJSONValue(val),
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
}
|