@assistant-ui/react 0.15.14 → 0.15.16
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/assistant-transport.d.ts +32 -0
- package/dist/assistant-transport.d.ts.map +1 -0
- package/dist/assistant-transport.js +27 -0
- package/dist/assistant-transport.js.map +1 -0
- package/dist/context/providers/MessageProvider.js +1 -1
- package/dist/devtools/DevToolsHooks.d.ts +0 -2
- package/dist/devtools/DevToolsHooks.d.ts.map +1 -1
- package/dist/devtools/DevToolsHooks.js +10 -12
- package/dist/devtools/DevToolsHooks.js.map +1 -1
- package/dist/hooks/useMessageQuote.js +1 -1
- package/dist/hooks/useToolCallElapsed.js +1 -1
- package/dist/index.d.ts +4 -7
- package/dist/index.js +6 -8
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js +18 -2
- package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
- package/dist/mcp-apps/bridge.d.ts.map +1 -1
- package/dist/mcp-apps/bridge.js +33 -24
- package/dist/mcp-apps/bridge.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +5 -2
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +24 -37
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +1 -1
- package/dist/primitives/attachment/AttachmentName.js +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js +20 -15
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts +2 -2
- package/dist/primitives/composer/ComposerDictationTranscript.js +3 -3
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +2 -2
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js +1 -1
- package/dist/primitives/composer/ComposerRoot.js +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js +24 -20
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/composer/useComposerInputState.js +1 -1
- package/dist/primitives/message/MessageIf.js +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +1 -1
- package/dist/primitives/message/MessageRoot.js +1 -1
- package/dist/primitives/message.js +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js +1 -1
- package/dist/primitives/queueItem/QueueItemText.js +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +1 -1
- package/dist/primitives/thread/ThreadIf.js +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts +3 -0
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +44 -9
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +2 -13
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +23 -8
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +1 -1
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +6 -1
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useComposerInput.d.ts +2 -2
- package/dist/unstable/useComposerInput.js +1 -1
- package/dist/unstable/useComposerInput.js.map +1 -1
- package/dist/unstable/useComposerInputHistory.js +2 -2
- package/dist/unstable/useComposerInputHistory.js.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.d.ts +5 -0
- package/dist/unstable/useLiveCompletionAdapter.d.ts.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.js +16 -3
- package/dist/unstable/useLiveCompletionAdapter.js.map +1 -1
- package/dist/unstable/useMentionAdapter.d.ts +1 -1
- package/dist/utils/invokeCallbackSafely.d.ts +5 -0
- package/dist/utils/invokeCallbackSafely.d.ts.map +1 -0
- package/dist/utils/invokeCallbackSafely.js +15 -0
- package/dist/utils/invokeCallbackSafely.js.map +1 -0
- package/dist/utils/smooth/SmoothContext.d.ts +6 -6
- package/dist/utils/smooth/SmoothContext.js +1 -1
- package/dist/utils/smooth/useSmooth.d.ts +3 -0
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +16 -1
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +1 -1
- package/package.json +10 -10
- package/src/assistant-transport.ts +94 -0
- package/src/devtools/DevToolsHooks.test.ts +40 -0
- package/src/devtools/DevToolsHooks.ts +10 -15
- package/src/index.ts +8 -4
- package/src/mcp-apps/McpAppsRemoteHost.test.ts +29 -3
- package/src/mcp-apps/McpAppsRemoteHost.ts +42 -7
- package/src/mcp-apps/bridge.test.ts +153 -0
- package/src/mcp-apps/bridge.ts +42 -30
- package/src/model-context/frame/SPEC_AssistantFrame.md +1 -1
- package/src/primitives/actionBar/ActionBarExportMarkdown.test.tsx +67 -0
- package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +3 -1
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +0 -9
- package/src/primitives/branchPicker/BranchPickerRoot.tsx +5 -3
- package/src/primitives/composer/ComposerDictationTranscript.tsx +2 -2
- package/src/primitives/composer/ComposerInput.tsx +1 -1
- package/src/primitives/composer/trigger/triggerSelectionResource.test.ts +135 -0
- package/src/primitives/composer/trigger/triggerSelectionResource.ts +2 -0
- package/src/primitives/thread/ThreadRoot.test.tsx +251 -0
- package/src/primitives/thread/ThreadRoot.tsx +33 -0
- package/src/primitives/thread/ThreadViewport.tsx +1 -8
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +152 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +26 -19
- package/src/sandbox-host/SandboxHost.test.tsx +90 -0
- package/src/sandbox-host/SandboxHost.tsx +8 -2
- package/src/tests/RemoteThreadListRuntime.adapterProvider.test.tsx +24 -3
- package/src/tests/RemoteThreadListRuntime.reloadMainThread.test.tsx +1 -2
- package/src/tests/augmentations.test.ts +49 -0
- package/src/tests/in-memory-thread-list.test.tsx +1 -1
- package/src/tests/threadMessageById.test.tsx +61 -1
- package/src/unstable/useComposerInput.ts +2 -2
- package/src/unstable/useComposerInputHistory.test.tsx +4 -4
- package/src/unstable/useComposerInputHistory.ts +1 -1
- package/src/unstable/useLiveCompletionAdapter.test.tsx +157 -0
- package/src/unstable/useLiveCompletionAdapter.ts +41 -17
- package/src/utils/invokeCallbackSafely.ts +11 -0
- package/src/utils/smooth/useSmooth.test.tsx +110 -0
- package/src/utils/smooth/useSmooth.ts +20 -6
- package/dist/client/InMemoryThreadList.d.ts +0 -12
- package/dist/client/InMemoryThreadList.d.ts.map +0 -1
- package/dist/client/InMemoryThreadList.js +0 -374
- package/dist/client/InMemoryThreadList.js.map +0 -1
- package/dist/context/react/utils/ensureBinding.d.ts +0 -5
- package/dist/context/react/utils/ensureBinding.d.ts.map +0 -1
- package/dist/context/react/utils/ensureBinding.js +0 -24
- package/dist/context/react/utils/ensureBinding.js.map +0 -1
- package/dist/context/react/utils/useRuntimeState.d.ts +0 -13
- package/dist/context/react/utils/useRuntimeState.d.ts.map +0 -1
- package/dist/context/react/utils/useRuntimeState.js +0 -33
- package/dist/context/react/utils/useRuntimeState.js.map +0 -1
- package/dist/legacy-runtime/cloud/auiV0.d.ts +0 -119
- package/dist/legacy-runtime/cloud/auiV0.d.ts.map +0 -1
- package/dist/legacy-runtime/cloud/auiV0.js +0 -137
- package/dist/legacy-runtime/cloud/auiV0.js.map +0 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts +0 -16
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js +0 -36
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts +0 -17
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js +0 -55
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts +0 -11
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js +0 -165
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.d.ts +0 -15
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js +0 -81
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +0 -126
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.js +0 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts +0 -14
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +0 -290
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts +0 -7
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js +0 -25
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.d.ts +0 -7
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js +0 -27
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/utils.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/assistant-transport/utils.js +0 -2
- package/src/client/InMemoryThreadList.ts +0 -247
- package/src/context/react/utils/ensureBinding.ts +0 -46
- package/src/context/react/utils/useRuntimeState.ts +0 -46
- package/src/legacy-runtime/cloud/auiV0.ts +0 -331
- package/src/legacy-runtime/cloud/useCloudThreadListRuntime.ts +0 -31
- package/src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts +0 -68
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.test.ts +0 -455
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts +0 -172
- package/src/legacy-runtime/runtime-cores/assistant-transport/runManager.ts +0 -113
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-delivery.test.tsx +0 -79
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-parentid.test.tsx +0 -97
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-scheduling.test.ts +0 -307
- package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +0 -170
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransport.spec.md +0 -141
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.test.tsx +0 -585
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +0 -476
- package/src/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.ts +0 -20
- package/src/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.ts +0 -9
- package/src/legacy-runtime/runtime-cores/assistant-transport/utils.ts +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ensureBinding } from "./ensureBinding.js";
|
|
2
|
-
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
-
import { useDebugValue, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
|
|
4
|
-
//#region src/context/react/utils/useRuntimeState.ts
|
|
5
|
-
function useRuntimeStateInternal(runtime, t0) {
|
|
6
|
-
const $ = c(4);
|
|
7
|
-
const selector = t0 === void 0 ? identity : t0;
|
|
8
|
-
ensureBinding(runtime);
|
|
9
|
-
let t1;
|
|
10
|
-
let t2;
|
|
11
|
-
if ($[0] !== runtime || $[1] !== selector) {
|
|
12
|
-
t1 = () => selector(runtime.getState());
|
|
13
|
-
t2 = () => selector(runtime.getState());
|
|
14
|
-
$[0] = runtime;
|
|
15
|
-
$[1] = selector;
|
|
16
|
-
$[2] = t1;
|
|
17
|
-
$[3] = t2;
|
|
18
|
-
} else {
|
|
19
|
-
t1 = $[2];
|
|
20
|
-
t2 = $[3];
|
|
21
|
-
}
|
|
22
|
-
const slice = useSyncExternalStore(runtime.subscribe, t1, t2);
|
|
23
|
-
useDebugValue(slice);
|
|
24
|
-
return slice;
|
|
25
|
-
}
|
|
26
|
-
const identity = (arg) => arg;
|
|
27
|
-
function useRuntimeState(runtime, selector) {
|
|
28
|
-
return useRuntimeStateInternal(runtime, selector);
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { useRuntimeState, useRuntimeStateInternal };
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=useRuntimeState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRuntimeState.js","names":["Unsubscribe","useDebugValue","useSyncExternalStore","ensureBinding","SubscribableRuntime","getState","TState","subscribe","callback","useRuntimeStateInternal","runtime","t0","$","_c","selector","undefined","identity","t1","t2","slice","arg","T","useRuntimeState","state","TSelected"],"sources":["../../../../src/context/react/utils/useRuntimeState.ts"],"sourcesContent":["import type { Unsubscribe } from \"@assistant-ui/core\";\nimport { useDebugValue, useSyncExternalStore } from \"react\";\nimport { ensureBinding } from \"./ensureBinding\";\n\nexport type SubscribableRuntime<TState> = {\n getState: () => TState;\n subscribe: (callback: () => void) => Unsubscribe;\n};\n\nexport function useRuntimeStateInternal<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected | TState) | undefined = identity,\n): TSelected | TState {\n // TODO move to useRuntimeState\n ensureBinding(runtime);\n\n const slice = useSyncExternalStore(\n runtime.subscribe,\n () => selector(runtime.getState()),\n () => selector(runtime.getState()),\n );\n useDebugValue(slice);\n return slice;\n}\n\nconst identity = <T>(arg: T): T => arg;\nexport function useRuntimeState<TState>(\n runtime: SubscribableRuntime<TState>,\n): TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: (state: TState) => TSelected,\n): TSelected;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected) | undefined,\n): TSelected | TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector?: ((state: TState) => TSelected) | undefined,\n): TSelected | TState {\n // ensure that the runtime is bound\n // ensureBinding(runtime);\n\n return useRuntimeStateInternal(runtime, selector);\n}\n"],"mappings":";;;;AASA,SAAOS,wBAAAC,SAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAEL,MAAAC,WAAAH,OAAAI,KAAAA,IAAAC,WAAAL;CAGAR,cAAcO,OAAO;CAAC,IAAAO;CAAA,IAAAC;CAAA,IAAAN,EAAA,OAAAF,WAAAE,EAAA,OAAAE,UAAA;EAIpBG,WAAMH,SAASJ,QAAOL,SAAU,CAAC;EACjCa,WAAMJ,SAASJ,QAAOL,SAAU,CAAC;EAACO,EAAA,KAAAF;EAAAE,EAAA,KAAAE;EAAAF,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAA;EAAAD,KAAAL,EAAA;EAAAM,KAAAN,EAAA;CAAA;CAHpC,MAAAO,QAAcjB,qBACZQ,QAAOH,WACPU,IACAC,EACF;CACAjB,cAAckB,KAAK;CAAC,OACbA;AAAK;AAGd,MAAMH,YAAeI,QAAcA;AAYnC,SAAOE,gBAAAZ,SAAAI,UAAA;CAAA,OAOEL,wBAAwBC,SAASI,QAAQ;AAAC"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { ExportedMessageRepositoryItem } from "../runtime-cores/utils/MessageRepository.js";
|
|
2
|
-
import { CloudMessage } from "assistant-cloud";
|
|
3
|
-
import { CompleteAttachment, MessageStatus, SourceProviderMetadata, ThreadMessage, ToolApprovalOption } from "@assistant-ui/core";
|
|
4
|
-
import { ReadonlyJSONObject, ReadonlyJSONValue } from "assistant-stream/utils";
|
|
5
|
-
//#region src/legacy-runtime/cloud/auiV0.d.ts
|
|
6
|
-
type AuiV0ToolApproval = {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
readonly approved?: boolean;
|
|
9
|
-
readonly reason?: string;
|
|
10
|
-
readonly isAutomatic?: boolean;
|
|
11
|
-
readonly options?: readonly ToolApprovalOption[];
|
|
12
|
-
readonly optionId?: string;
|
|
13
|
-
readonly resolution?: "cancelled" | "expired";
|
|
14
|
-
};
|
|
15
|
-
type AuiV0MessagePart = {
|
|
16
|
-
readonly type: "text";
|
|
17
|
-
readonly text: string;
|
|
18
|
-
} | {
|
|
19
|
-
readonly type: "reasoning";
|
|
20
|
-
readonly text: string;
|
|
21
|
-
readonly unstable_summary?: string;
|
|
22
|
-
} | {
|
|
23
|
-
readonly type: "source";
|
|
24
|
-
readonly sourceType: "url";
|
|
25
|
-
readonly id: string;
|
|
26
|
-
readonly url: string;
|
|
27
|
-
readonly title?: string;
|
|
28
|
-
readonly providerMetadata?: SourceProviderMetadata;
|
|
29
|
-
} | {
|
|
30
|
-
readonly type: "source";
|
|
31
|
-
readonly sourceType: "document";
|
|
32
|
-
readonly id: string;
|
|
33
|
-
readonly title: string;
|
|
34
|
-
readonly mediaType: string;
|
|
35
|
-
readonly filename?: string;
|
|
36
|
-
readonly providerMetadata?: SourceProviderMetadata;
|
|
37
|
-
} | {
|
|
38
|
-
readonly type: "tool-call";
|
|
39
|
-
readonly toolCallId: string;
|
|
40
|
-
readonly toolName: string;
|
|
41
|
-
readonly args: ReadonlyJSONObject;
|
|
42
|
-
readonly result?: ReadonlyJSONValue;
|
|
43
|
-
readonly isError?: true;
|
|
44
|
-
readonly approval?: AuiV0ToolApproval;
|
|
45
|
-
} | {
|
|
46
|
-
readonly type: "tool-call";
|
|
47
|
-
readonly toolCallId: string;
|
|
48
|
-
readonly toolName: string;
|
|
49
|
-
readonly argsText: string;
|
|
50
|
-
readonly result?: ReadonlyJSONValue;
|
|
51
|
-
readonly isError?: true;
|
|
52
|
-
readonly approval?: AuiV0ToolApproval;
|
|
53
|
-
} | {
|
|
54
|
-
readonly type: "image";
|
|
55
|
-
readonly image: string;
|
|
56
|
-
} | {
|
|
57
|
-
readonly type: "file";
|
|
58
|
-
readonly data: string;
|
|
59
|
-
readonly mimeType: string;
|
|
60
|
-
readonly filename?: string;
|
|
61
|
-
readonly sourceType?: "url" | "id";
|
|
62
|
-
};
|
|
63
|
-
type AuiV0AttachmentPart = {
|
|
64
|
-
readonly type: "text";
|
|
65
|
-
readonly text: string;
|
|
66
|
-
} | {
|
|
67
|
-
readonly type: "image";
|
|
68
|
-
readonly image: string;
|
|
69
|
-
readonly filename?: string;
|
|
70
|
-
} | {
|
|
71
|
-
readonly type: "file";
|
|
72
|
-
readonly data: string;
|
|
73
|
-
readonly mimeType: string;
|
|
74
|
-
readonly filename?: string;
|
|
75
|
-
readonly sourceType?: "url" | "id";
|
|
76
|
-
} | {
|
|
77
|
-
readonly type: "audio";
|
|
78
|
-
readonly audio: {
|
|
79
|
-
readonly data: string;
|
|
80
|
-
readonly format: "mp3" | "wav";
|
|
81
|
-
};
|
|
82
|
-
} | {
|
|
83
|
-
readonly type: "data";
|
|
84
|
-
readonly name: string;
|
|
85
|
-
readonly data: ReadonlyJSONValue;
|
|
86
|
-
};
|
|
87
|
-
type AuiV0Attachment = {
|
|
88
|
-
readonly id: string;
|
|
89
|
-
readonly type: CompleteAttachment["type"];
|
|
90
|
-
readonly name: string;
|
|
91
|
-
readonly contentType?: string;
|
|
92
|
-
readonly status: CompleteAttachment["status"];
|
|
93
|
-
readonly content: readonly AuiV0AttachmentPart[];
|
|
94
|
-
};
|
|
95
|
-
type AuiV0Message = {
|
|
96
|
-
readonly role: "assistant" | "user" | "system";
|
|
97
|
-
readonly status?: MessageStatus;
|
|
98
|
-
readonly content: readonly AuiV0MessagePart[];
|
|
99
|
-
readonly attachments?: readonly AuiV0Attachment[];
|
|
100
|
-
readonly metadata: {
|
|
101
|
-
readonly unstable_state?: ReadonlyJSONValue;
|
|
102
|
-
readonly unstable_annotations: readonly ReadonlyJSONValue[];
|
|
103
|
-
readonly unstable_data: readonly ReadonlyJSONValue[];
|
|
104
|
-
readonly steps: readonly {
|
|
105
|
-
readonly usage?: {
|
|
106
|
-
readonly inputTokens: number;
|
|
107
|
-
readonly outputTokens: number;
|
|
108
|
-
};
|
|
109
|
-
}[];
|
|
110
|
-
readonly custom: ReadonlyJSONObject;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
declare function auiV0Encode(message: ThreadMessage): AuiV0Message;
|
|
114
|
-
declare function auiV0Decode(cloudMessage: CloudMessage & {
|
|
115
|
-
format: "aui/v0";
|
|
116
|
-
}): ExportedMessageRepositoryItem;
|
|
117
|
-
//#endregion
|
|
118
|
-
export { auiV0Decode, auiV0Encode };
|
|
119
|
-
//# sourceMappingURL=auiV0.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auiV0.d.ts","names":[],"sources":["../../../src/legacy-runtime/cloud/auiV0.ts"],"mappings":";;;;;KAgBK;WACM;WACA;WACA;WACA;WACA,mBAAmB;WACnB;WACA;;KAGN;WAEU;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA,MAAM;WACN,SAAS;WACT;WACA,WAAW;;WAGX;WACA;WACA;WACA;WACA,SAAS;WACT;WACA,WAAW;;WAGX;WACA;;WAGA;WACA;WACA;WACA;WACA;;KAGV;WAEU;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;;WAGA;WACA;aACE;aACA;;;WAIF;WACA;WACA,MAAM;;KAGhB;WACM;WACA,MAAM;WACN;WACA;WACA,QAAQ;WACR,kBAAkB;;KAGxB;WACM;WACA,SAAS;WACT,kBAAkB;WAClB,uBAAuB;WACvB;aACE,iBAAiB;aACjB,+BAA+B;aAC/B,wBAAwB;aACxB;eACE;iBACE;iBACA;;;aAGJ,QAAQ;;;iBA2EL,YAAY,SAAS,gBAAgB;iBAoGrC,YACd,cAAc;EAAiB;IAC9B"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { fromThreadMessageLike } from "../runtime-cores/external-store/ThreadMessageLike.js";
|
|
2
|
-
import { isJSONValue } from "@assistant-ui/core/internal";
|
|
3
|
-
//#region src/legacy-runtime/cloud/auiV0.ts
|
|
4
|
-
const encodeAttachmentPart = (part) => {
|
|
5
|
-
const type = part.type;
|
|
6
|
-
switch (type) {
|
|
7
|
-
case "text": return {
|
|
8
|
-
type: "text",
|
|
9
|
-
text: part.text
|
|
10
|
-
};
|
|
11
|
-
case "image": return {
|
|
12
|
-
type: "image",
|
|
13
|
-
image: part.image,
|
|
14
|
-
...part.filename != null ? { filename: part.filename } : void 0
|
|
15
|
-
};
|
|
16
|
-
case "file": return {
|
|
17
|
-
type: "file",
|
|
18
|
-
data: part.data,
|
|
19
|
-
mimeType: part.mimeType,
|
|
20
|
-
...part.filename != null ? { filename: part.filename } : void 0,
|
|
21
|
-
...part.sourceType != null ? { sourceType: part.sourceType } : void 0
|
|
22
|
-
};
|
|
23
|
-
case "audio": return {
|
|
24
|
-
type: "audio",
|
|
25
|
-
audio: {
|
|
26
|
-
data: part.audio.data,
|
|
27
|
-
format: part.audio.format
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
case "data":
|
|
31
|
-
if (!isJSONValue(part.data)) console.warn(`attachment data is not JSON! ${JSON.stringify(part)}`);
|
|
32
|
-
return {
|
|
33
|
-
type: "data",
|
|
34
|
-
name: part.name,
|
|
35
|
-
data: part.data
|
|
36
|
-
};
|
|
37
|
-
default: throw new Error(`Attachment part type not supported by aui/v0: ${type}`);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const encodeAttachments = (message) => {
|
|
41
|
-
if (message.role !== "user" || message.attachments.length === 0) return;
|
|
42
|
-
return message.attachments.map(({ id, type, name, contentType, status, content }) => ({
|
|
43
|
-
id,
|
|
44
|
-
type,
|
|
45
|
-
name,
|
|
46
|
-
status,
|
|
47
|
-
...contentType != null ? { contentType } : void 0,
|
|
48
|
-
content: content.map(encodeAttachmentPart)
|
|
49
|
-
}));
|
|
50
|
-
};
|
|
51
|
-
function auiV0Encode(message) {
|
|
52
|
-
const status = message.status?.type === "running" ? {
|
|
53
|
-
type: "incomplete",
|
|
54
|
-
reason: "cancelled"
|
|
55
|
-
} : message.status;
|
|
56
|
-
const attachments = encodeAttachments(message);
|
|
57
|
-
return {
|
|
58
|
-
role: message.role,
|
|
59
|
-
content: message.content.map((part) => {
|
|
60
|
-
const type = part.type;
|
|
61
|
-
switch (type) {
|
|
62
|
-
case "text": return {
|
|
63
|
-
type: "text",
|
|
64
|
-
text: part.text
|
|
65
|
-
};
|
|
66
|
-
case "reasoning": return {
|
|
67
|
-
type: "reasoning",
|
|
68
|
-
text: part.text,
|
|
69
|
-
...part.unstable_summary !== void 0 ? { unstable_summary: part.unstable_summary } : void 0
|
|
70
|
-
};
|
|
71
|
-
case "source":
|
|
72
|
-
if (part.sourceType === "url") return {
|
|
73
|
-
type: "source",
|
|
74
|
-
sourceType: "url",
|
|
75
|
-
id: part.id,
|
|
76
|
-
url: part.url,
|
|
77
|
-
...part.title != null ? { title: part.title } : void 0,
|
|
78
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : void 0
|
|
79
|
-
};
|
|
80
|
-
return {
|
|
81
|
-
type: "source",
|
|
82
|
-
sourceType: "document",
|
|
83
|
-
id: part.id,
|
|
84
|
-
title: part.title,
|
|
85
|
-
mediaType: part.mediaType,
|
|
86
|
-
...part.filename != null ? { filename: part.filename } : void 0,
|
|
87
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : void 0
|
|
88
|
-
};
|
|
89
|
-
case "tool-call":
|
|
90
|
-
if (part.result !== void 0 && !isJSONValue(part.result)) console.warn(`tool-call result is not JSON! ${JSON.stringify(part)}`);
|
|
91
|
-
return {
|
|
92
|
-
type: "tool-call",
|
|
93
|
-
toolCallId: part.toolCallId,
|
|
94
|
-
toolName: part.toolName,
|
|
95
|
-
...JSON.stringify(part.args) === part.argsText ? { args: part.args } : { argsText: part.argsText },
|
|
96
|
-
...part.result !== void 0 ? { result: part.result } : void 0,
|
|
97
|
-
...part.isError ? { isError: true } : void 0,
|
|
98
|
-
...part.approval ? { approval: part.approval } : void 0
|
|
99
|
-
};
|
|
100
|
-
case "image": return {
|
|
101
|
-
type: "image",
|
|
102
|
-
image: part.image
|
|
103
|
-
};
|
|
104
|
-
case "file": return {
|
|
105
|
-
type: "file",
|
|
106
|
-
data: part.data,
|
|
107
|
-
mimeType: part.mimeType,
|
|
108
|
-
...part.filename ? { filename: part.filename } : void 0,
|
|
109
|
-
...part.sourceType ? { sourceType: part.sourceType } : void 0
|
|
110
|
-
};
|
|
111
|
-
default: throw new Error(`Message part type not supported by aui/v0: ${type}`);
|
|
112
|
-
}
|
|
113
|
-
}),
|
|
114
|
-
metadata: message.metadata,
|
|
115
|
-
...status ? { status } : void 0,
|
|
116
|
-
...attachments ? { attachments } : void 0
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function auiV0Decode(cloudMessage) {
|
|
120
|
-
const payload = cloudMessage.content;
|
|
121
|
-
const message = fromThreadMessageLike({
|
|
122
|
-
id: cloudMessage.id,
|
|
123
|
-
createdAt: cloudMessage.created_at,
|
|
124
|
-
...payload
|
|
125
|
-
}, cloudMessage.id, {
|
|
126
|
-
type: "complete",
|
|
127
|
-
reason: "unknown"
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
parentId: cloudMessage.parent_id,
|
|
131
|
-
message
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
export { auiV0Decode, auiV0Encode };
|
|
136
|
-
|
|
137
|
-
//# sourceMappingURL=auiV0.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auiV0.js","names":["CompleteAttachment","MessageStatus","SourceProviderMetadata","ThreadMessage","ToolApprovalOption","fromThreadMessageLike","CloudMessage","isJSONValue","ReadonlyJSONObject","ReadonlyJSONValue","ExportedMessageRepositoryItem","AuiV0ToolApproval","id","approved","reason","isAutomatic","options","optionId","resolution","AuiV0MessagePart","type","text","unstable_summary","sourceType","url","title","providerMetadata","mediaType","filename","toolCallId","toolName","args","result","isError","approval","argsText","image","data","mimeType","AuiV0AttachmentPart","audio","format","name","AuiV0Attachment","contentType","status","content","AuiV0Message","role","attachments","metadata","unstable_state","unstable_annotations","unstable_data","steps","usage","inputTokens","outputTokens","custom","encodeAttachmentPart","part","undefined","console","warn","JSON","stringify","unhandledType","Error","encodeAttachments","message","length","map","auiV0Encode","auiV0Decode","cloudMessage","payload","createdAt","created_at","parentId","parent_id"],"sources":["../../../src/legacy-runtime/cloud/auiV0.ts"],"sourcesContent":["import type {\n CompleteAttachment,\n MessageStatus,\n SourceProviderMetadata,\n ThreadMessage,\n ToolApprovalOption,\n} from \"@assistant-ui/core\";\nimport { fromThreadMessageLike } from \"../runtime-cores/external-store/ThreadMessageLike\";\nimport type { CloudMessage } from \"assistant-cloud\";\nimport { isJSONValue } from \"@assistant-ui/core/internal\";\nimport type {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"assistant-stream/utils\";\nimport type { ExportedMessageRepositoryItem } from \"../runtime-cores/utils/MessageRepository\";\n\ntype AuiV0ToolApproval = {\n readonly id: string;\n readonly approved?: boolean;\n readonly reason?: string;\n readonly isAutomatic?: boolean;\n readonly options?: readonly ToolApprovalOption[];\n readonly optionId?: string;\n readonly resolution?: \"cancelled\" | \"expired\";\n};\n\ntype AuiV0MessagePart =\n | {\n readonly type: \"text\";\n readonly text: string;\n }\n | {\n readonly type: \"reasoning\";\n readonly text: string;\n readonly unstable_summary?: string;\n }\n | {\n readonly type: \"source\";\n readonly sourceType: \"url\";\n readonly id: string;\n readonly url: string;\n readonly title?: string;\n readonly providerMetadata?: SourceProviderMetadata;\n }\n | {\n readonly type: \"source\";\n readonly sourceType: \"document\";\n readonly id: string;\n readonly title: string;\n readonly mediaType: string;\n readonly filename?: string;\n readonly providerMetadata?: SourceProviderMetadata;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: ReadonlyJSONObject;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n readonly approval?: AuiV0ToolApproval;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly argsText: string;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n readonly approval?: AuiV0ToolApproval;\n }\n | {\n readonly type: \"image\";\n readonly image: string;\n }\n | {\n readonly type: \"file\";\n readonly data: string;\n readonly mimeType: string;\n readonly filename?: string;\n readonly sourceType?: \"url\" | \"id\";\n };\n\ntype AuiV0AttachmentPart =\n | {\n readonly type: \"text\";\n readonly text: string;\n }\n | {\n readonly type: \"image\";\n readonly image: string;\n readonly filename?: string;\n }\n | {\n readonly type: \"file\";\n readonly data: string;\n readonly mimeType: string;\n readonly filename?: string;\n readonly sourceType?: \"url\" | \"id\";\n }\n | {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n }\n | {\n readonly type: \"data\";\n readonly name: string;\n readonly data: ReadonlyJSONValue;\n };\n\ntype AuiV0Attachment = {\n readonly id: string;\n readonly type: CompleteAttachment[\"type\"];\n readonly name: string;\n readonly contentType?: string;\n readonly status: CompleteAttachment[\"status\"];\n readonly content: readonly AuiV0AttachmentPart[];\n};\n\ntype AuiV0Message = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly status?: MessageStatus;\n readonly content: readonly AuiV0MessagePart[];\n readonly attachments?: readonly AuiV0Attachment[];\n readonly metadata: {\n readonly unstable_state?: ReadonlyJSONValue;\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly {\n readonly usage?: {\n readonly inputTokens: number;\n readonly outputTokens: number;\n };\n }[];\n readonly custom: ReadonlyJSONObject;\n };\n};\n\nconst encodeAttachmentPart = (\n part: CompleteAttachment[\"content\"][number],\n): AuiV0AttachmentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n return { type: \"text\", text: part.text };\n\n case \"image\":\n return {\n type: \"image\",\n image: part.image,\n ...(part.filename != null ? { filename: part.filename } : undefined),\n };\n\n case \"file\":\n return {\n type: \"file\",\n data: part.data,\n mimeType: part.mimeType,\n ...(part.filename != null ? { filename: part.filename } : undefined),\n ...(part.sourceType != null\n ? { sourceType: part.sourceType }\n : undefined),\n };\n\n case \"audio\":\n return {\n type: \"audio\",\n audio: { data: part.audio.data, format: part.audio.format },\n };\n\n case \"data\": {\n if (!isJSONValue(part.data)) {\n console.warn(`attachment data is not JSON! ${JSON.stringify(part)}`);\n }\n return {\n type: \"data\",\n name: part.name,\n data: part.data as ReadonlyJSONValue,\n };\n }\n\n default: {\n const unhandledType: never = type;\n throw new Error(\n `Attachment part type not supported by aui/v0: ${unhandledType}`,\n );\n }\n }\n};\n\nconst encodeAttachments = (\n message: ThreadMessage,\n): readonly AuiV0Attachment[] | undefined => {\n if (message.role !== \"user\" || message.attachments.length === 0) {\n return undefined;\n }\n\n return message.attachments.map(\n ({ id, type, name, contentType, status, content }) => ({\n id,\n type,\n name,\n status,\n ...(contentType != null ? { contentType } : undefined),\n content: content.map(encodeAttachmentPart),\n }),\n );\n};\n\nexport function auiV0Encode(message: ThreadMessage): AuiV0Message {\n // info: ID and createdAt are ignored (we use the server value instead)\n const status: MessageStatus | undefined =\n message.status?.type === \"running\"\n ? { type: \"incomplete\", reason: \"cancelled\" }\n : message.status;\n const attachments = encodeAttachments(message);\n\n return {\n role: message.role,\n content: message.content.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\":\n return { type: \"text\", text: part.text };\n\n case \"reasoning\":\n return {\n type: \"reasoning\",\n text: part.text,\n ...(part.unstable_summary !== undefined\n ? { unstable_summary: part.unstable_summary }\n : undefined),\n };\n\n case \"source\":\n if (part.sourceType === \"url\") {\n return {\n type: \"source\",\n sourceType: \"url\",\n id: part.id,\n url: part.url,\n ...(part.title != null ? { title: part.title } : undefined),\n ...(part.providerMetadata != null\n ? { providerMetadata: part.providerMetadata }\n : undefined),\n };\n }\n\n return {\n type: \"source\",\n sourceType: \"document\",\n id: part.id,\n title: part.title,\n mediaType: part.mediaType,\n ...(part.filename != null\n ? { filename: part.filename }\n : undefined),\n ...(part.providerMetadata != null\n ? { providerMetadata: part.providerMetadata }\n : undefined),\n };\n\n case \"tool-call\": {\n if (part.result !== undefined && !isJSONValue(part.result)) {\n console.warn(\n `tool-call result is not JSON! ${JSON.stringify(part)}`,\n );\n }\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(JSON.stringify(part.args) === part.argsText\n ? { args: part.args }\n : { argsText: part.argsText }),\n ...(part.result !== undefined\n ? { result: part.result as ReadonlyJSONValue }\n : undefined),\n ...(part.isError ? { isError: true } : undefined),\n ...(part.approval ? { approval: part.approval } : undefined),\n };\n }\n\n case \"image\":\n return { type: \"image\", image: part.image };\n\n case \"file\":\n return {\n type: \"file\",\n data: part.data,\n mimeType: part.mimeType,\n ...(part.filename ? { filename: part.filename } : undefined),\n ...(part.sourceType ? { sourceType: part.sourceType } : undefined),\n };\n\n default: {\n const unhandledType: \"audio\" | \"data\" | \"generative-ui\" = type;\n throw new Error(\n `Message part type not supported by aui/v0: ${unhandledType}`,\n );\n }\n }\n }),\n metadata: message.metadata as AuiV0Message[\"metadata\"],\n ...(status ? { status } : undefined),\n ...(attachments ? { attachments } : undefined),\n };\n}\n\nexport function auiV0Decode(\n cloudMessage: CloudMessage & { format: \"aui/v0\" },\n): ExportedMessageRepositoryItem {\n const payload = cloudMessage.content as unknown as AuiV0Message;\n const message = fromThreadMessageLike(\n {\n id: cloudMessage.id,\n createdAt: cloudMessage.created_at,\n ...payload,\n },\n cloudMessage.id,\n { type: \"complete\", reason: \"unknown\" },\n );\n\n return {\n parentId: cloudMessage.parent_id,\n message,\n };\n}\n"],"mappings":"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"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AssistantCloud } from "assistant-cloud";
|
|
2
|
-
import { AssistantRuntime } from "@assistant-ui/core";
|
|
3
|
-
//#region src/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts
|
|
4
|
-
type ThreadData = {
|
|
5
|
-
externalId: string;
|
|
6
|
-
};
|
|
7
|
-
type CloudThreadListAdapter = {
|
|
8
|
-
cloud: AssistantCloud;
|
|
9
|
-
runtimeHook: () => AssistantRuntime;
|
|
10
|
-
create?(): Promise<ThreadData>;
|
|
11
|
-
delete?(threadId: string): Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
declare function useCloudThreadListRuntime({ runtimeHook, ...adapterOptions }: CloudThreadListAdapter): AssistantRuntime;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { useCloudThreadListRuntime };
|
|
16
|
-
//# sourceMappingURL=useCloudThreadListRuntime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCloudThreadListRuntime.d.ts","names":[],"sources":["../../../src/legacy-runtime/cloud/useCloudThreadListRuntime.ts"],"mappings":";;;KAOK;EACH;;KAGG;EACH,OAAO;EAEP,mBAAmB;EAEnB,WAAW,QAAQ;EACnB,QAAQ,mBAAmB;;iBAGb,4BACd,gBACG,kBACF,yBAAsB"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useRemoteThreadListRuntime } from "../runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js";
|
|
3
|
-
import { useCloudThreadListAdapter } from "../runtime-cores/remote-thread-list/adapter/cloud.js";
|
|
4
|
-
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
-
//#region src/legacy-runtime/cloud/useCloudThreadListRuntime.ts
|
|
6
|
-
function useCloudThreadListRuntime(t0) {
|
|
7
|
-
const $ = c(6);
|
|
8
|
-
let adapterOptions;
|
|
9
|
-
let runtimeHook;
|
|
10
|
-
if ($[0] !== t0) {
|
|
11
|
-
({runtimeHook, ...adapterOptions} = t0);
|
|
12
|
-
$[0] = t0;
|
|
13
|
-
$[1] = adapterOptions;
|
|
14
|
-
$[2] = runtimeHook;
|
|
15
|
-
} else {
|
|
16
|
-
adapterOptions = $[1];
|
|
17
|
-
runtimeHook = $[2];
|
|
18
|
-
}
|
|
19
|
-
const adapter = useCloudThreadListAdapter(adapterOptions);
|
|
20
|
-
let t1;
|
|
21
|
-
if ($[3] !== adapter || $[4] !== runtimeHook) {
|
|
22
|
-
t1 = {
|
|
23
|
-
runtimeHook,
|
|
24
|
-
adapter,
|
|
25
|
-
allowNesting: true
|
|
26
|
-
};
|
|
27
|
-
$[3] = adapter;
|
|
28
|
-
$[4] = runtimeHook;
|
|
29
|
-
$[5] = t1;
|
|
30
|
-
} else t1 = $[5];
|
|
31
|
-
return useRemoteThreadListRuntime(t1);
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { useCloudThreadListRuntime };
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=useCloudThreadListRuntime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCloudThreadListRuntime.js","names":["c","_c","AssistantCloud","AssistantRuntime","useRemoteThreadListRuntime","useCloudThreadListAdapter","ThreadData","externalId","CloudThreadListAdapter","cloud","runtimeHook","create","Promise","delete","threadId","useCloudThreadListRuntime","t0","$","adapterOptions","adapter","t1","allowNesting"],"sources":["../../../src/legacy-runtime/cloud/useCloudThreadListRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AssistantCloud } from \"assistant-cloud\";\nimport type { AssistantRuntime } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../runtime-cores/remote-thread-list/useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"../runtime-cores/remote-thread-list/adapter/cloud\";\n\ntype ThreadData = {\n externalId: string;\n};\n\ntype CloudThreadListAdapter = {\n cloud: AssistantCloud;\n\n runtimeHook: () => AssistantRuntime;\n\n create?(): Promise<ThreadData>;\n delete?(threadId: string): Promise<void>;\n};\n\nexport function useCloudThreadListRuntime({\n runtimeHook,\n ...adapterOptions\n}: CloudThreadListAdapter) {\n const adapter = useCloudThreadListAdapter(adapterOptions);\n return useRemoteThreadListRuntime({\n runtimeHook,\n adapter,\n allowNesting: true,\n });\n}\n"],"mappings":";;;;;AAoBA,SAAOe,0BAAAC,IAAA;CAAA,MAAAC,IAAAhB,EAAA,CAAA;CAAA,IAAAiB;CAAA,IAAAR;CAAA,IAAAO,EAAA,OAAAD,IAAA;EAAmC,CAAA,CAAAN,gBAAAQ,kBAAAF;EAGjBC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAP;CAAA,OAAA;EAAAQ,iBAAAD,EAAA;EAAAP,cAAAO,EAAA;CAAA;CACvB,MAAAE,UAAgBd,0BAA0Ba,cAAc;CAAE,IAAAE;CAAA,IAAAH,EAAA,OAAAE,WAAAF,EAAA,OAAAP,aAAA;EACxBU,KAAA;GAAAV;GAAAS;GAAAE,cAGlB;EAChB;EAACJ,EAAA,KAAAE;EAAAF,EAAA,KAAAP;EAAAO,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAJMb,2BAA2BgB,EAIjC;AAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AssistantTransportCommand, CommandQueueState, QueuedCommand } from "./types.js";
|
|
2
|
-
//#region src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts
|
|
3
|
-
declare const createInitialQueueState: () => CommandQueueState;
|
|
4
|
-
declare const useCommandQueue: (opts: {
|
|
5
|
-
onQueue: () => void;
|
|
6
|
-
}) => {
|
|
7
|
-
readonly state: CommandQueueState;
|
|
8
|
-
enqueue: (command: AssistantTransportCommand, options?: {
|
|
9
|
-
schedule?: boolean;
|
|
10
|
-
}) => void;
|
|
11
|
-
flush: () => QueuedCommand[];
|
|
12
|
-
markDelivered: () => void;
|
|
13
|
-
reset: () => void;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { createInitialQueueState, useCommandQueue };
|
|
17
|
-
//# sourceMappingURL=commandQueue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandQueue.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts"],"mappings":";;cAOa,+BAA8B;cAK9B,kBAAmB;EAAQ;;;EAU3B,UAAA,SAAA,2BAAyB;IACtB;;EAWI,aAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
|
|
2
|
-
//#region src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts
|
|
3
|
-
const createInitialQueueState = () => ({
|
|
4
|
-
queued: [],
|
|
5
|
-
inTransit: []
|
|
6
|
-
});
|
|
7
|
-
const useCommandQueue = (opts) => {
|
|
8
|
-
const onQueueRef = useRef(opts.onQueue);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
onQueueRef.current = opts.onQueue;
|
|
11
|
-
});
|
|
12
|
-
const [, rerender] = useState(0);
|
|
13
|
-
const queueStateRef = useRef(createInitialQueueState());
|
|
14
|
-
const enqueue = (command, options) => {
|
|
15
|
-
queueStateRef.current = {
|
|
16
|
-
queued: [...queueStateRef.current.queued, command],
|
|
17
|
-
inTransit: queueStateRef.current.inTransit
|
|
18
|
-
};
|
|
19
|
-
rerender((prev) => prev + 1);
|
|
20
|
-
if (options?.schedule !== false) onQueueRef.current();
|
|
21
|
-
};
|
|
22
|
-
const flush = () => {
|
|
23
|
-
if (queueStateRef.current.queued.length === 0) return [];
|
|
24
|
-
const queued = queueStateRef.current.queued;
|
|
25
|
-
queueStateRef.current = {
|
|
26
|
-
queued: [],
|
|
27
|
-
inTransit: [...queueStateRef.current.inTransit, ...queued]
|
|
28
|
-
};
|
|
29
|
-
rerender((prev_0) => prev_0 + 1);
|
|
30
|
-
return queued;
|
|
31
|
-
};
|
|
32
|
-
const markDelivered = () => {
|
|
33
|
-
queueStateRef.current = {
|
|
34
|
-
...queueStateRef.current,
|
|
35
|
-
inTransit: []
|
|
36
|
-
};
|
|
37
|
-
rerender((prev_1) => prev_1 + 1);
|
|
38
|
-
};
|
|
39
|
-
return {
|
|
40
|
-
get state() {
|
|
41
|
-
return queueStateRef.current;
|
|
42
|
-
},
|
|
43
|
-
enqueue,
|
|
44
|
-
flush,
|
|
45
|
-
markDelivered,
|
|
46
|
-
reset: useCallback(() => {
|
|
47
|
-
queueStateRef.current = createInitialQueueState();
|
|
48
|
-
rerender((prev_2) => prev_2 + 1);
|
|
49
|
-
}, [])
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
//#endregion
|
|
53
|
-
export { createInitialQueueState, useCommandQueue };
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=commandQueue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandQueue.js","names":["useState","useCallback","useRef","useEffect","AssistantTransportCommand","CommandQueueState","QueuedCommand","createInitialQueueState","queued","inTransit","useCommandQueue","opts","onQueue","onQueueRef","current","rerender","queueStateRef","enqueue","command","options","schedule","prev","flush","length","markDelivered","reset","state"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts"],"sourcesContent":["import { useState, useCallback, useRef, useEffect } from \"react\";\nimport type {\n AssistantTransportCommand,\n CommandQueueState,\n QueuedCommand,\n} from \"./types\";\n\nexport const createInitialQueueState = (): CommandQueueState => ({\n queued: [],\n inTransit: [],\n});\n\nexport const useCommandQueue = (opts: { onQueue: () => void }) => {\n const onQueueRef = useRef(opts.onQueue);\n useEffect(() => {\n onQueueRef.current = opts.onQueue;\n });\n\n const [, rerender] = useState(0);\n const queueStateRef = useRef<CommandQueueState>(createInitialQueueState());\n\n const enqueue = (\n command: AssistantTransportCommand,\n options?: { schedule?: boolean },\n ) => {\n queueStateRef.current = {\n queued: [...queueStateRef.current.queued, command],\n inTransit: queueStateRef.current.inTransit,\n };\n rerender((prev) => prev + 1);\n\n if (options?.schedule !== false) onQueueRef.current();\n };\n\n const flush = (): QueuedCommand[] => {\n if (queueStateRef.current.queued.length === 0) return [];\n\n const queued = queueStateRef.current.queued;\n queueStateRef.current = {\n queued: [],\n inTransit: [...queueStateRef.current.inTransit, ...queued],\n };\n rerender((prev) => prev + 1);\n\n return queued;\n };\n\n const markDelivered = () => {\n queueStateRef.current = { ...queueStateRef.current, inTransit: [] };\n rerender((prev) => prev + 1);\n };\n\n const reset = useCallback(() => {\n queueStateRef.current = createInitialQueueState();\n rerender((prev) => prev + 1);\n }, []);\n\n return {\n // live getter — callbacks firing between renders must not see a stale snapshot\n get state() {\n return queueStateRef.current;\n },\n enqueue,\n flush,\n markDelivered,\n reset,\n };\n};\n"],"mappings":";;AAOA,MAAaO,iCAAoD;CAC/DC,QAAQ,CAAA;CACRC,WAAW,CAAA;AACb;AAEA,MAAaC,mBAAmBC,SAAkC;CAChE,MAAME,aAAaX,OAAOS,KAAKC,OAAO;CACtCT,gBAAgB;EACdU,WAAWC,UAAUH,KAAKC;CAC5B,CAAC;CAED,MAAM,GAAGG,YAAYf,SAAS,CAAC;CAC/B,MAAMgB,gBAAgBd,OAA0BK,wBAAwB,CAAC;CAEzE,MAAMU,WACJC,SACAC,YACG;EACHH,cAAcF,UAAU;GACtBN,QAAQ,CAAC,GAAGQ,cAAcF,QAAQN,QAAQU,OAAO;GACjDT,WAAWO,cAAcF,QAAQL;EACnC;EACAM,UAAUM,SAASA,OAAO,CAAC;EAE3B,IAAIF,SAASC,aAAa,OAAOP,WAAWC,QAAQ;CACtD;CAEA,MAAMQ,cAA+B;EACnC,IAAIN,cAAcF,QAAQN,OAAOe,WAAW,GAAG,OAAO,CAAA;EAEtD,MAAMf,SAASQ,cAAcF,QAAQN;EACrCQ,cAAcF,UAAU;GACtBN,QAAQ,CAAA;GACRC,WAAW,CAAC,GAAGO,cAAcF,QAAQL,WAAW,GAAGD,MAAM;EAC3D;EACAO,UAAUM,WAASA,SAAO,CAAC;EAE3B,OAAOb;CACT;CAEA,MAAMgB,sBAAsB;EAC1BR,cAAcF,UAAU;GAAE,GAAGE,cAAcF;GAASL,WAAW,CAAA;EAAG;EAClEM,UAAUM,WAASA,SAAO,CAAC;CAC7B;CAOA,OAAO;EAEL,IAAIK,QAAQ;GACV,OAAOV,cAAcF;EACvB;EACAG;EACAK;EACAE;EACAC,OAbYxB,kBAAkB;GAC9Be,cAAcF,UAAUP,wBAAwB;GAChDQ,UAAUM,WAASA,SAAO,CAAC;EAC7B,GAAG,CAAA,CAUDI;CACF;AACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts
|
|
2
|
-
declare const REPLAY_CONTENT_LENGTH_HEADER = "Aui-Replay-Content-Length";
|
|
3
|
-
type ReplayBoundaryStreamOptions = {
|
|
4
|
-
setReplaying: (value: boolean) => void;
|
|
5
|
-
waitForRender: () => Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
declare const useReplayRenderWait: () => () => Promise<void>;
|
|
8
|
-
declare const createReplayBoundaryStream: (response: Response, { setReplaying, waitForRender: waitForReplayRender }: ReplayBoundaryStreamOptions) => Promise<ReadableStream<Uint8Array>>;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { REPLAY_CONTENT_LENGTH_HEADER, createReplayBoundaryStream, useReplayRenderWait };
|
|
11
|
-
//# sourceMappingURL=replayBoundaryStream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replayBoundaryStream.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts"],"mappings":";cAIa;KAER;EACH,eAAe;EACf,qBAAqB;;cAGV,iCAAmB;cA6DnB,6BACX,UAAU,YACV,cAAA,eAAA,uBAGG,gCACF,QAAQ,eAAe"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
-
import { useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
|
|
4
|
-
//#region src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts
|
|
5
|
-
const REPLAY_CONTENT_LENGTH_HEADER = "Aui-Replay-Content-Length";
|
|
6
|
-
const useReplayRenderWait = () => {
|
|
7
|
-
const $ = c(8);
|
|
8
|
-
const [renderTicket, setRenderTicket] = useState(0);
|
|
9
|
-
const mountedRef = useRef(true);
|
|
10
|
-
const nextTicketRef = useRef(0);
|
|
11
|
-
let t0;
|
|
12
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13
|
-
t0 = [];
|
|
14
|
-
$[0] = t0;
|
|
15
|
-
} else t0 = $[0];
|
|
16
|
-
const waitersRef = useRef(t0);
|
|
17
|
-
let t1;
|
|
18
|
-
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
19
|
-
t1 = (committedTicket) => {
|
|
20
|
-
const pendingWaiters = [];
|
|
21
|
-
for (const waiter of waitersRef.current) if (committedTicket === void 0 || waiter.ticket <= committedTicket) waiter.resolve();
|
|
22
|
-
else pendingWaiters.push(waiter);
|
|
23
|
-
waitersRef.current = pendingWaiters;
|
|
24
|
-
};
|
|
25
|
-
$[1] = t1;
|
|
26
|
-
} else t1 = $[1];
|
|
27
|
-
const resolveWaiters = t1;
|
|
28
|
-
let t2;
|
|
29
|
-
let t3;
|
|
30
|
-
if ($[2] !== renderTicket) {
|
|
31
|
-
t2 = () => {
|
|
32
|
-
mountedRef.current = true;
|
|
33
|
-
resolveWaiters(renderTicket);
|
|
34
|
-
};
|
|
35
|
-
t3 = [renderTicket, resolveWaiters];
|
|
36
|
-
$[2] = renderTicket;
|
|
37
|
-
$[3] = t2;
|
|
38
|
-
$[4] = t3;
|
|
39
|
-
} else {
|
|
40
|
-
t2 = $[3];
|
|
41
|
-
t3 = $[4];
|
|
42
|
-
}
|
|
43
|
-
useEffect(t2, t3);
|
|
44
|
-
let t4;
|
|
45
|
-
let t5;
|
|
46
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
47
|
-
t4 = () => () => {
|
|
48
|
-
mountedRef.current = false;
|
|
49
|
-
resolveWaiters();
|
|
50
|
-
};
|
|
51
|
-
t5 = [resolveWaiters];
|
|
52
|
-
$[5] = t4;
|
|
53
|
-
$[6] = t5;
|
|
54
|
-
} else {
|
|
55
|
-
t4 = $[5];
|
|
56
|
-
t5 = $[6];
|
|
57
|
-
}
|
|
58
|
-
useEffect(t4, t5);
|
|
59
|
-
let t6;
|
|
60
|
-
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
61
|
-
t6 = () => new Promise((resolve) => {
|
|
62
|
-
setTimeout(() => {
|
|
63
|
-
if (!mountedRef.current) {
|
|
64
|
-
resolve();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const ticket = nextTicketRef.current + 1;
|
|
68
|
-
nextTicketRef.current = ticket;
|
|
69
|
-
waitersRef.current.push({
|
|
70
|
-
ticket,
|
|
71
|
-
resolve
|
|
72
|
-
});
|
|
73
|
-
setRenderTicket(ticket);
|
|
74
|
-
}, 0);
|
|
75
|
-
});
|
|
76
|
-
$[7] = t6;
|
|
77
|
-
} else t6 = $[7];
|
|
78
|
-
return t6;
|
|
79
|
-
};
|
|
80
|
-
const parseReplayContentLength = (headers) => {
|
|
81
|
-
const raw = headers.get(REPLAY_CONTENT_LENGTH_HEADER);
|
|
82
|
-
if (raw == null) return 0;
|
|
83
|
-
const boundary = Number(raw);
|
|
84
|
-
return Number.isSafeInteger(boundary) && boundary > 0 ? boundary : 0;
|
|
85
|
-
};
|
|
86
|
-
const createReplayBoundaryStream = async (response, { setReplaying, waitForRender: waitForReplayRender }) => {
|
|
87
|
-
const body = response.body;
|
|
88
|
-
const replayContentLength = parseReplayContentLength(response.headers);
|
|
89
|
-
if (replayContentLength <= 0) return body;
|
|
90
|
-
setReplaying(true);
|
|
91
|
-
await waitForReplayRender();
|
|
92
|
-
const reader = body.getReader();
|
|
93
|
-
let bytesForwarded = 0;
|
|
94
|
-
let replayFinished = false;
|
|
95
|
-
let readerCleanup;
|
|
96
|
-
const releaseReader = () => {
|
|
97
|
-
if (readerCleanup) return readerCleanup;
|
|
98
|
-
reader.releaseLock();
|
|
99
|
-
readerCleanup = Promise.resolve();
|
|
100
|
-
return readerCleanup;
|
|
101
|
-
};
|
|
102
|
-
const cancelReader = (reason) => {
|
|
103
|
-
if (readerCleanup) return readerCleanup;
|
|
104
|
-
readerCleanup = (async () => {
|
|
105
|
-
try {
|
|
106
|
-
await reader.cancel(reason);
|
|
107
|
-
} finally {
|
|
108
|
-
reader.releaseLock();
|
|
109
|
-
}
|
|
110
|
-
})();
|
|
111
|
-
return readerCleanup;
|
|
112
|
-
};
|
|
113
|
-
const finishReplay = async () => {
|
|
114
|
-
if (replayFinished) return;
|
|
115
|
-
replayFinished = true;
|
|
116
|
-
await waitForReplayRender();
|
|
117
|
-
setReplaying(false);
|
|
118
|
-
await waitForReplayRender();
|
|
119
|
-
};
|
|
120
|
-
return new ReadableStream({
|
|
121
|
-
async pull(controller) {
|
|
122
|
-
try {
|
|
123
|
-
const { done, value } = await reader.read();
|
|
124
|
-
if (done) {
|
|
125
|
-
await releaseReader();
|
|
126
|
-
await finishReplay();
|
|
127
|
-
controller.close();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (replayFinished) {
|
|
131
|
-
controller.enqueue(value);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const nextBytesForwarded = bytesForwarded + value.byteLength;
|
|
135
|
-
if (nextBytesForwarded < replayContentLength) {
|
|
136
|
-
bytesForwarded = nextBytesForwarded;
|
|
137
|
-
controller.enqueue(value);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (nextBytesForwarded === replayContentLength) {
|
|
141
|
-
controller.enqueue(value);
|
|
142
|
-
await finishReplay();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const replayBytesInChunk = replayContentLength - bytesForwarded;
|
|
146
|
-
controller.enqueue(value.subarray(0, replayBytesInChunk));
|
|
147
|
-
await finishReplay();
|
|
148
|
-
controller.enqueue(value.subarray(replayBytesInChunk));
|
|
149
|
-
} catch (error) {
|
|
150
|
-
await cancelReader(error).catch(() => {});
|
|
151
|
-
throw error;
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
async cancel(reason) {
|
|
155
|
-
const wasFinished = replayFinished;
|
|
156
|
-
replayFinished = true;
|
|
157
|
-
if (!wasFinished) setReplaying(false);
|
|
158
|
-
await cancelReader(reason);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
//#endregion
|
|
163
|
-
export { REPLAY_CONTENT_LENGTH_HEADER, createReplayBoundaryStream, useReplayRenderWait };
|
|
164
|
-
|
|
165
|
-
//# sourceMappingURL=replayBoundaryStream.js.map
|