@assistant-ui/core 0.3.1 → 0.3.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/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +6 -7
- package/dist/internal.js +5 -6
- package/dist/react/AssistantProvider.d.ts +1 -1
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantProvider.js +35 -9
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +1 -1
- package/dist/react/AssistantRuntimeProvider.js +1 -1
- package/dist/react/RuntimeAdapter.js +2 -2
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +17 -33
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.js +1 -1
- package/dist/react/client/Interactables.js +1 -1
- package/dist/react/client/Tools.js +2 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/interactables-legacy/Interactables.js +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.js +1 -1
- package/dist/react/interactables-legacy/useInteractableState.js +2 -2
- package/dist/react/model-context/useAssistantContext.js +1 -1
- package/dist/react/model-context/useAssistantDataUI.js +2 -2
- package/dist/react/model-context/useAssistantInstructions.js +2 -2
- package/dist/react/model-context/useAssistantTool.js +2 -2
- package/dist/react/model-context/useAssistantToolUI.js +2 -2
- package/dist/react/model-context/useAuiToolOverrides.js +1 -1
- package/dist/react/model-context/useInlineRender.js +1 -1
- package/dist/react/model-context/useInteractable.js +1 -1
- package/dist/react/model-context/useInteractableState.js +2 -2
- package/dist/react/model-context/useInteractableVersions.js +2 -2
- package/dist/react/model-context/useToolArgsStatus.js +2 -2
- package/dist/react/primitive-hooks/useActionBarCopy.js +52 -25
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.js +2 -2
- package/dist/react/primitive-hooks/useActionBarFeedback.js +2 -2
- package/dist/react/primitive-hooks/useActionBarReload.js +2 -2
- package/dist/react/primitive-hooks/useActionBarSpeak.js +2 -2
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +2 -2
- package/dist/react/primitive-hooks/useBranchPickerNext.js +2 -2
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js +2 -2
- package/dist/react/primitive-hooks/useComposerAddAttachment.js +2 -2
- package/dist/react/primitive-hooks/useComposerCancel.js +2 -2
- package/dist/react/primitive-hooks/useComposerDictate.js +2 -2
- package/dist/react/primitive-hooks/useComposerSend.js +2 -2
- package/dist/react/primitive-hooks/useEditComposerCancel.js +2 -2
- package/dist/react/primitive-hooks/useEditComposerSend.js +2 -2
- package/dist/react/primitive-hooks/useMessageBranching.js +2 -2
- package/dist/react/primitive-hooks/useMessageReload.js +2 -2
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +2 -2
- package/dist/react/primitive-hooks/useThreadListItemArchive.js +2 -2
- package/dist/react/primitive-hooks/useThreadListItemDelete.js +2 -2
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js +2 -2
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +2 -2
- package/dist/react/primitive-hooks/useThreadListLoadMore.js +2 -2
- package/dist/react/primitive-hooks/useThreadListNew.js +2 -2
- package/dist/react/primitive-hooks/useThreadMessageIds.js +1 -1
- package/dist/react/primitive-hooks/useVoice.js +2 -2
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +2 -2
- package/dist/react/primitives/composer/ComposerAttachments.js +2 -2
- package/dist/react/primitives/composer/ComposerIf.js +1 -1
- package/dist/react/primitives/composer/ComposerQueue.js +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +2 -2
- package/dist/react/primitives/message/MessageAttachments.js +2 -2
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +2 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +3 -3
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +2 -2
- package/dist/react/primitives/message/MessageQuote.js +2 -2
- package/dist/react/primitives/part/PartMessages.js +2 -2
- package/dist/react/primitives/thread/ThreadMessages.js +2 -2
- package/dist/react/primitives/thread/ThreadSuggestions.js +2 -2
- package/dist/react/primitives/threadList/ThreadListItems.js +2 -2
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.js +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +1 -1
- package/dist/react/providers/MessageByIdProvider.js +1 -1
- package/dist/react/providers/MessageByIndexProvider.js +1 -1
- package/dist/react/providers/PartByIndexProvider.js +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.js +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js +2 -2
- package/dist/react/providers/SuggestionByIndexProvider.js +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +2 -2
- package/dist/react/providers/ThreadListItemByIndexProvider.js +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.js +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +14 -13
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +3 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +22 -12
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.js +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +9 -23
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +24 -2
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +24 -5
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.js +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +7 -13
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/utils/useJSONEqual.js +1 -1
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +5 -1
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/internal.d.ts +4 -4
- package/dist/runtime/internal.js +4 -4
- package/dist/runtime/utils/thread-message-like.js +2 -2
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +5 -4
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/chain-of-thought-client.js +30 -24
- package/dist/store/clients/chain-of-thought-client.js.map +1 -1
- package/dist/store/clients/model-context-client.js +1 -1
- package/dist/store/clients/no-op-composer-client.js +1 -1
- package/dist/store/clients/suggestions.js +2 -2
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +103 -91
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +2 -2
- package/dist/store/runtime-clients/message-runtime-client.js +2 -2
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +2 -2
- package/dist/store/runtime-clients/thread-list-runtime-client.js +2 -2
- package/dist/store/runtime-clients/thread-runtime-client.js +2 -2
- package/dist/store/scopes/thread.d.ts +1 -1
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/message.d.ts +11 -1
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/data-url.js +2 -2
- package/dist/utils/data-url.js.map +1 -1
- package/dist/utils/getGroupStatus.d.ts +9 -0
- package/dist/utils/getGroupStatus.d.ts.map +1 -0
- package/dist/utils/getGroupStatus.js +15 -0
- package/dist/utils/getGroupStatus.js.map +1 -0
- package/dist/utils/normalizePartStatus.d.ts +8 -0
- package/dist/utils/normalizePartStatus.d.ts.map +1 -0
- package/dist/utils/normalizePartStatus.js +39 -0
- package/dist/utils/normalizePartStatus.js.map +1 -0
- package/package.json +4 -4
- package/src/index.ts +1 -0
- package/src/internal.ts +1 -7
- package/src/react/AssistantProvider.tsx +28 -15
- package/src/react/AssistantRuntimeProvider.test.tsx +101 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +28 -7
- package/src/react/index.ts +4 -0
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +109 -14
- package/src/react/primitive-hooks/useActionBarCopy.ts +27 -2
- package/src/react/primitives/message/MessageGroupedParts.tsx +4 -4
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +16 -13
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +53 -10
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +7 -5
- package/src/react/runtimes/cloud/auiV0.ts +51 -12
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +9 -15
- package/src/runtime/api/message-runtime.test.ts +140 -0
- package/src/runtime/api/message-runtime.ts +10 -5
- package/src/runtime/utils/thread-message-like.ts +2 -2
- package/src/runtimes/remote-thread-list/types.ts +5 -4
- package/src/store/clients/chain-of-thought-client.ts +2 -7
- package/src/store/clients/thread-message-client.test.ts +84 -0
- package/src/store/clients/thread-message-client.ts +14 -4
- package/src/store/scopes/thread.ts +1 -1
- package/src/tests/auiV0Encode.test.ts +93 -0
- package/src/tests/remote-thread-list-reactive-threadId.test.ts +0 -92
- package/src/tests/thread-message-like.test.ts +15 -0
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +293 -0
- package/src/types/index.ts +1 -0
- package/src/types/message.ts +19 -0
- package/src/utils/data-url.test.ts +26 -2
- package/src/utils/data-url.ts +2 -2
- package/src/utils/getGroupStatus.test.ts +36 -0
- package/src/utils/getGroupStatus.ts +31 -0
- package/src/utils/normalizePartStatus.test.ts +59 -0
- package/src/utils/normalizePartStatus.ts +55 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "@assistant-ui/tap/react-shim";
|
|
2
1
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
|
+
import "@assistant-ui/tap/react-shim";
|
|
3
3
|
import { resource } from "@assistant-ui/tap";
|
|
4
4
|
//#region src/store/clients/no-op-composer-client.ts
|
|
5
5
|
const useNoOpComposerClient = (t0) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useClientLookup } from "@assistant-ui/store";
|
|
2
|
-
import { useState } from "@assistant-ui/tap/react-shim";
|
|
3
1
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
|
+
import { useState } from "@assistant-ui/tap/react-shim";
|
|
3
|
+
import { useClientLookup } from "@assistant-ui/store";
|
|
4
4
|
import { resource, withKey } from "@assistant-ui/tap";
|
|
5
5
|
//#region src/store/clients/suggestions.ts
|
|
6
6
|
const useSuggestionClient = (state) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-message-client.d.ts","names":[],"sources":["../../../src/store/clients/thread-message-client.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"thread-message-client.d.ts","names":[],"sources":["../../../src/store/clients/thread-message-client.ts"],"mappings":";;;KAmEY;EACV,SAAS;EACT;EACA;EACA;EACA;;cA2GW,iDAAmB,SAAA,0BAAA"}
|
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
import { getThreadMessageText } from "../../utils/text.js";
|
|
2
|
+
import { COMPLETE_STATUS, normalizePartStatus } from "../../utils/normalizePartStatus.js";
|
|
2
3
|
import { NoOpComposerClient } from "./no-op-composer-client.js";
|
|
3
|
-
import { useClientLookup } from "@assistant-ui/store";
|
|
4
|
-
import { useState } from "@assistant-ui/tap/react-shim";
|
|
5
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import { useState } from "@assistant-ui/tap/react-shim";
|
|
6
|
+
import { useClientLookup } from "@assistant-ui/store";
|
|
6
7
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
7
8
|
//#region src/store/clients/thread-message-client.ts
|
|
8
9
|
const useThreadMessagePartClient = (t0) => {
|
|
9
|
-
const $ = c(
|
|
10
|
-
const { part } = t0;
|
|
10
|
+
const $ = c(8);
|
|
11
|
+
const { part, isMessageRunning } = t0;
|
|
11
12
|
let t1;
|
|
12
|
-
if ($[0]
|
|
13
|
-
t1 =
|
|
14
|
-
$[0] =
|
|
15
|
-
|
|
13
|
+
if ($[0] !== isMessageRunning || $[1] !== part) {
|
|
14
|
+
t1 = isMessageRunning ? normalizePartStatus(part) ?? COMPLETE_STATUS : COMPLETE_STATUS;
|
|
15
|
+
$[0] = isMessageRunning;
|
|
16
|
+
$[1] = part;
|
|
17
|
+
$[2] = t1;
|
|
18
|
+
} else t1 = $[2];
|
|
16
19
|
let t2;
|
|
17
|
-
if ($[
|
|
20
|
+
if ($[3] !== part || $[4] !== t1) {
|
|
18
21
|
t2 = {
|
|
19
22
|
...part,
|
|
20
23
|
status: t1
|
|
21
24
|
};
|
|
22
|
-
$[
|
|
23
|
-
$[
|
|
24
|
-
|
|
25
|
+
$[3] = part;
|
|
26
|
+
$[4] = t1;
|
|
27
|
+
$[5] = t2;
|
|
28
|
+
} else t2 = $[5];
|
|
25
29
|
const state = t2;
|
|
26
30
|
let t3;
|
|
27
|
-
if ($[
|
|
31
|
+
if ($[6] !== state) {
|
|
28
32
|
t3 = {
|
|
29
33
|
getState: () => state,
|
|
30
34
|
addToolResult: _temp,
|
|
31
35
|
resumeToolCall: _temp2,
|
|
32
36
|
respondToToolApproval: _temp3
|
|
33
37
|
};
|
|
34
|
-
$[
|
|
35
|
-
$[
|
|
36
|
-
} else t3 = $[
|
|
38
|
+
$[6] = state;
|
|
39
|
+
$[7] = t3;
|
|
40
|
+
} else t3 = $[7];
|
|
37
41
|
return t3;
|
|
38
42
|
};
|
|
39
43
|
const ThreadMessagePartClient = resource(useThreadMessagePartClient);
|
|
@@ -47,48 +51,59 @@ const useThreadMessageAttachmentClient = ({ attachment }) => {
|
|
|
47
51
|
};
|
|
48
52
|
const ThreadMessageAttachmentClient = resource(useThreadMessageAttachmentClient);
|
|
49
53
|
const useThreadMessageClient = (t0) => {
|
|
50
|
-
const $ = c(
|
|
54
|
+
const $ = c(38);
|
|
51
55
|
const { message, index, isLast: t1, branchNumber: t2, branchCount: t3 } = t0;
|
|
52
56
|
const isLast = t1 === void 0 ? true : t1;
|
|
53
57
|
const branchNumber = t2 === void 0 ? 1 : t2;
|
|
54
58
|
const branchCount = t3 === void 0 ? 1 : t3;
|
|
55
59
|
const [isCopiedState, setIsCopied] = useState(false);
|
|
56
60
|
const [isHoveringState, setIsHovering] = useState(false);
|
|
61
|
+
const isMessageRunning = message.role === "assistant" && message.status.type === "running";
|
|
57
62
|
let t4;
|
|
58
|
-
if ($[0] !== message.content) {
|
|
59
|
-
|
|
60
|
-
$[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
if ($[0] !== isMessageRunning || $[1] !== message.content) {
|
|
64
|
+
let t5;
|
|
65
|
+
if ($[3] !== isMessageRunning) {
|
|
66
|
+
t5 = (part, idx) => withKey("toolCallId" in part && part.toolCallId != null ? `toolCallId-${part.toolCallId}` : `index-${idx}`, ThreadMessagePartClient({
|
|
67
|
+
part,
|
|
68
|
+
isMessageRunning
|
|
69
|
+
}), [part, isMessageRunning]);
|
|
70
|
+
$[3] = isMessageRunning;
|
|
71
|
+
$[4] = t5;
|
|
72
|
+
} else t5 = $[4];
|
|
73
|
+
t4 = message.content.map(t5);
|
|
74
|
+
$[0] = isMessageRunning;
|
|
75
|
+
$[1] = message.content;
|
|
76
|
+
$[2] = t4;
|
|
77
|
+
} else t4 = $[2];
|
|
63
78
|
const parts = useClientLookup(t4);
|
|
64
79
|
let t5;
|
|
65
|
-
if ($[
|
|
80
|
+
if ($[5] !== message.attachments) {
|
|
66
81
|
t5 = message.attachments ?? [];
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
} else t5 = $[
|
|
82
|
+
$[5] = message.attachments;
|
|
83
|
+
$[6] = t5;
|
|
84
|
+
} else t5 = $[6];
|
|
70
85
|
let t6;
|
|
71
|
-
if ($[
|
|
72
|
-
t6 = t5.map(
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
} else t6 = $[
|
|
86
|
+
if ($[7] !== t5) {
|
|
87
|
+
t6 = t5.map(_temp4);
|
|
88
|
+
$[7] = t5;
|
|
89
|
+
$[8] = t6;
|
|
90
|
+
} else t6 = $[8];
|
|
76
91
|
const attachments = useClientLookup(t6);
|
|
77
92
|
let t7;
|
|
78
|
-
if ($[
|
|
93
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
79
94
|
t7 = NoOpComposerClient({ type: "edit" });
|
|
80
|
-
$[
|
|
81
|
-
} else t7 = $[
|
|
95
|
+
$[9] = t7;
|
|
96
|
+
} else t7 = $[9];
|
|
82
97
|
const composer = useResource(t7);
|
|
83
98
|
let t8;
|
|
84
|
-
if ($[
|
|
99
|
+
if ($[10] !== composer) {
|
|
85
100
|
t8 = composer.getState();
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
88
|
-
} else t8 = $[
|
|
101
|
+
$[10] = composer;
|
|
102
|
+
$[11] = t8;
|
|
103
|
+
} else t8 = $[11];
|
|
89
104
|
const composerState = t8;
|
|
90
105
|
let t9;
|
|
91
|
-
if ($[
|
|
106
|
+
if ($[12] !== branchCount || $[13] !== branchNumber || $[14] !== composerState || $[15] !== index || $[16] !== isCopiedState || $[17] !== isHoveringState || $[18] !== isLast || $[19] !== message || $[20] !== parts.state) {
|
|
92
107
|
t9 = {
|
|
93
108
|
...message,
|
|
94
109
|
parts: parts.state,
|
|
@@ -102,78 +117,78 @@ const useThreadMessageClient = (t0) => {
|
|
|
102
117
|
isCopied: isCopiedState,
|
|
103
118
|
isHovering: isHoveringState
|
|
104
119
|
};
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
} else t9 = $[
|
|
120
|
+
$[12] = branchCount;
|
|
121
|
+
$[13] = branchNumber;
|
|
122
|
+
$[14] = composerState;
|
|
123
|
+
$[15] = index;
|
|
124
|
+
$[16] = isCopiedState;
|
|
125
|
+
$[17] = isHoveringState;
|
|
126
|
+
$[18] = isLast;
|
|
127
|
+
$[19] = message;
|
|
128
|
+
$[20] = parts.state;
|
|
129
|
+
$[21] = t9;
|
|
130
|
+
} else t9 = $[21];
|
|
116
131
|
const state = t9;
|
|
117
132
|
let t10;
|
|
118
|
-
if ($[
|
|
133
|
+
if ($[22] !== state) {
|
|
119
134
|
t10 = () => state;
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
} else t10 = $[
|
|
135
|
+
$[22] = state;
|
|
136
|
+
$[23] = t10;
|
|
137
|
+
} else t10 = $[23];
|
|
123
138
|
let t11;
|
|
124
|
-
if ($[
|
|
139
|
+
if ($[24] !== composer) {
|
|
125
140
|
t11 = () => composer;
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
} else t11 = $[
|
|
141
|
+
$[24] = composer;
|
|
142
|
+
$[25] = t11;
|
|
143
|
+
} else t11 = $[25];
|
|
129
144
|
let t12;
|
|
130
|
-
if ($[
|
|
145
|
+
if ($[26] !== parts) {
|
|
131
146
|
t12 = (selector) => {
|
|
132
147
|
if ("index" in selector) return parts.get({ index: selector.index });
|
|
133
148
|
else return parts.get({ key: `toolCallId-${selector.toolCallId}` });
|
|
134
149
|
};
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
} else t12 = $[
|
|
150
|
+
$[26] = parts;
|
|
151
|
+
$[27] = t12;
|
|
152
|
+
} else t12 = $[27];
|
|
138
153
|
let t13;
|
|
139
|
-
if ($[
|
|
154
|
+
if ($[28] !== attachments) {
|
|
140
155
|
t13 = (selector_0) => {
|
|
141
156
|
if ("id" in selector_0) return attachments.get({ key: selector_0.id });
|
|
142
157
|
else return attachments.get(selector_0);
|
|
143
158
|
};
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
} else t13 = $[
|
|
159
|
+
$[28] = attachments;
|
|
160
|
+
$[29] = t13;
|
|
161
|
+
} else t13 = $[29];
|
|
147
162
|
let t14;
|
|
148
|
-
if ($[
|
|
163
|
+
if ($[30] !== message) {
|
|
149
164
|
t14 = () => getThreadMessageText(message);
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
} else t14 = $[
|
|
165
|
+
$[30] = message;
|
|
166
|
+
$[31] = t14;
|
|
167
|
+
} else t14 = $[31];
|
|
153
168
|
let t15;
|
|
154
|
-
if ($[
|
|
169
|
+
if ($[32] !== t10 || $[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14) {
|
|
155
170
|
t15 = {
|
|
156
171
|
getState: t10,
|
|
157
172
|
composer: t11,
|
|
158
173
|
part: t12,
|
|
159
174
|
attachment: t13,
|
|
160
|
-
delete:
|
|
161
|
-
reload:
|
|
162
|
-
speak:
|
|
163
|
-
stopSpeaking:
|
|
164
|
-
submitFeedback:
|
|
165
|
-
switchToBranch:
|
|
175
|
+
delete: _temp5,
|
|
176
|
+
reload: _temp6,
|
|
177
|
+
speak: _temp7,
|
|
178
|
+
stopSpeaking: _temp8,
|
|
179
|
+
submitFeedback: _temp9,
|
|
180
|
+
switchToBranch: _temp0,
|
|
166
181
|
getCopyText: t14,
|
|
167
182
|
setIsCopied,
|
|
168
183
|
setIsHovering
|
|
169
184
|
};
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
176
|
-
} else t15 = $[
|
|
185
|
+
$[32] = t10;
|
|
186
|
+
$[33] = t11;
|
|
187
|
+
$[34] = t12;
|
|
188
|
+
$[35] = t13;
|
|
189
|
+
$[36] = t14;
|
|
190
|
+
$[37] = t15;
|
|
191
|
+
} else t15 = $[37];
|
|
177
192
|
return t15;
|
|
178
193
|
};
|
|
179
194
|
const ThreadMessageClient = resource(useThreadMessageClient);
|
|
@@ -186,12 +201,12 @@ function _temp2() {
|
|
|
186
201
|
function _temp3() {
|
|
187
202
|
throw new Error("Not supported");
|
|
188
203
|
}
|
|
189
|
-
function _temp4(
|
|
190
|
-
return withKey("toolCallId" in part && part.toolCallId != null ? `toolCallId-${part.toolCallId}` : `index-${idx}`, ThreadMessagePartClient({ part }), [part]);
|
|
191
|
-
}
|
|
192
|
-
function _temp5(attachment) {
|
|
204
|
+
function _temp4(attachment) {
|
|
193
205
|
return withKey(attachment.id, ThreadMessageAttachmentClient({ attachment }), [attachment]);
|
|
194
206
|
}
|
|
207
|
+
function _temp5() {
|
|
208
|
+
throw new Error("Not supported in ThreadMessageProvider");
|
|
209
|
+
}
|
|
195
210
|
function _temp6() {
|
|
196
211
|
throw new Error("Not supported in ThreadMessageProvider");
|
|
197
212
|
}
|
|
@@ -207,9 +222,6 @@ function _temp9() {
|
|
|
207
222
|
function _temp0() {
|
|
208
223
|
throw new Error("Not supported in ThreadMessageProvider");
|
|
209
224
|
}
|
|
210
|
-
function _temp1() {
|
|
211
|
-
throw new Error("Not supported in ThreadMessageProvider");
|
|
212
|
-
}
|
|
213
225
|
//#endregion
|
|
214
226
|
export { ThreadMessageClient };
|
|
215
227
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-message-client.js","names":["ThreadAssistantMessagePart","ThreadUserMessagePart","ThreadMessage","Attachment","useMemo","useState","useResource","resource","withKey","ClientOutput","useClientLookup","MessageState","PartState","NoOpComposerClient","getThreadMessageText","useThreadMessagePartClient","t0","$","_c","part","t1","Symbol","for","type","t2","status","state","t3","getState","addToolResult","_temp","resumeToolCall","_temp2","respondToToolApproval","_temp3","ThreadMessagePartClient","useThreadMessageAttachmentClient","attachment","remove","Error","ThreadMessageAttachmentClient","ThreadMessageClientProps","message","index","isLast","branchNumber","branchCount","useThreadMessageClient","undefined","isCopiedState","setIsCopied","isHoveringState","setIsHovering","t4","content","map","_temp4","parts","t5","attachments","t6","_temp5","t7","composer","t8","composerState","t9","parentId","speech","isCopied","isHovering","t10","t11","t12","selector","get","key","toolCallId","t13","selector_0","id","t14","t15","delete","_temp6","reload","_temp7","speak","_temp8","stopSpeaking","_temp9","submitFeedback","_temp0","switchToBranch","_temp1","getCopyText","ThreadMessageClient","idx"],"sources":["../../../src/store/clients/thread-message-client.ts"],"sourcesContent":["import type {\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Attachment } from \"../../types/attachment\";\nimport { useMemo, useState } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { MessageState } from \"../scopes/message\";\nimport type { PartState } from \"../scopes/part\";\nimport { NoOpComposerClient } from \"./no-op-composer-client\";\nimport { getThreadMessageText } from \"../../utils/text\";\n\nconst useThreadMessagePartClient = ({\n part,\n}: {\n part: ThreadAssistantMessagePart | ThreadUserMessagePart;\n}): ClientOutput<\"part\"> => {\n const state = useMemo<PartState>(() => {\n return {\n ...part,\n status: { type: \"complete\" },\n };\n }, [part]);\n\n return {\n getState: () => state,\n addToolResult: () => {\n throw new Error(\"Not supported\");\n },\n resumeToolCall: () => {\n throw new Error(\"Not supported\");\n },\n respondToToolApproval: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessagePartClient = resource(useThreadMessagePartClient);\n\nconst useThreadMessageAttachmentClient = ({\n attachment,\n}: {\n attachment: Attachment;\n}): ClientOutput<\"attachment\"> => {\n return {\n getState: () => attachment,\n remove: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessageAttachmentClient = resource(\n useThreadMessageAttachmentClient,\n);\nexport type ThreadMessageClientProps = {\n message: ThreadMessage;\n index: number;\n isLast?: boolean;\n branchNumber?: number;\n branchCount?: number;\n};\n\nconst useThreadMessageClient = ({\n message,\n index,\n isLast = true,\n branchNumber = 1,\n branchCount = 1,\n}: ThreadMessageClientProps): ClientOutput<\"message\"> => {\n const [isCopiedState, setIsCopied] = useState(false);\n const [isHoveringState, setIsHovering] = useState(false);\n\n const parts = useClientLookup(\n message.content.map((part, idx) =>\n withKey(\n \"toolCallId\" in part && part.toolCallId != null\n ? `toolCallId-${part.toolCallId}`\n : `index-${idx}`,\n ThreadMessagePartClient({ part }),\n [part],\n ),\n ),\n );\n\n const attachments = useClientLookup(\n (message.attachments ?? []).map((attachment) =>\n withKey(attachment.id, ThreadMessageAttachmentClient({ attachment }), [\n attachment,\n ]),\n ),\n );\n\n const composer = useResource(NoOpComposerClient({ type: \"edit\" }));\n const composerState = composer.getState();\n\n const state = useMemo<MessageState>(() => {\n return {\n ...message,\n parts: parts.state,\n composer: composerState,\n parentId: null,\n index,\n isLast,\n branchNumber,\n branchCount,\n speech: undefined,\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n message,\n index,\n isCopiedState,\n isHoveringState,\n isLast,\n parts.state,\n composerState,\n branchNumber,\n branchCount,\n ]);\n\n return {\n getState: () => state,\n composer: () => composer,\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.get({ index: selector.index });\n } else {\n return parts.get({ key: `toolCallId-${selector.toolCallId}` });\n }\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n delete: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n reload: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n speak: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n stopSpeaking: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n submitFeedback: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n switchToBranch: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n getCopyText: () => {\n return getThreadMessageText(message);\n },\n setIsCopied,\n setIsHovering,\n };\n};\n\nexport const ThreadMessageClient = resource(useThreadMessageClient);\n"],"mappings":";;;;;;;AAeA,MAAMe,8BAA6BC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAC,SAAAH;CAInC,IAAAI;CAAA,IAAAH,EAAA,OAAAI,OAAAC,IAAA,2BAAA,GAAA;EAIaF,KAAA,EAAAG,MAAQ,WAAW;EAACN,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAE,MAAA;EAFvBK,KAAA;GAAA,GACFL;GAAIM,QACCL;EACV;EAACH,EAAA,KAAAE;EAAAF,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAJH,MAAAS,QACEF;CAIS,IAAAG;CAAA,IAAAV,EAAA,OAAAS,OAAA;EAEJC,KAAA;GAAAC,gBACWF;GAAKG,eACNC;GAEdC,gBACeC;GAEfC,uBACsBC;EAGzB;EAACjB,EAAA,KAAAS;EAAAT,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAXMU;AAWN;AAGH,MAAMQ,0BAA0B5B,SAASQ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AAA,MAAAiE;CAAA,OAAAA,MAAAjE,EAAA;CAAA,OAxCMiE;AAwCN;AAGH,MAAac,sBAAsBzF,SAASwC,sBAAsB;AA1J/B,SAAAjB,QAAA;CAe7B,MAAM,IAAIS,MAAM,eAAe;AAAE;AAfJ,SAAAP,SAAA;CAkB7B,MAAM,IAAIO,MAAM,eAAe;AAAE;AAlBJ,SAAAL,SAAA;CAqB7B,MAAM,IAAIK,MAAM,eAAe;AAAE;AA+BR,SAAAiB,OAAArC,MAAA8E,KAAA;CAAA,OAYzBzF,QACE,gBAAgBW,QAAQA,KAAI0D,cAAe,OAA3C,cACkB1D,KAAI0D,eADtB,SAEaoB,OACb9D,wBAAwB,EAAAhB,KAAO,CAAC,GAChC,CAACA,IAAI,CACP;AAAC;AAlBwB,SAAA0C,OAAAxB,YAAA;CAAA,OAwBzB7B,QAAQ6B,WAAU2C,IAAKxC,8BAA8B,EAAAH,WAAa,CAAC,GAAG,CACpEA,UAAU,CACX;AAAC;AA1BuB,SAAA+C,SAAA;CA6EzB,MAAM,IAAI7C,MAAM,wCAAwC;AAAE;AA7EjC,SAAA+C,SAAA;CAgFzB,MAAM,IAAI/C,MAAM,wCAAwC;AAAE;AAhFjC,SAAAiD,SAAA;CAmFzB,MAAM,IAAIjD,MAAM,wCAAwC;AAAE;AAnFjC,SAAAmD,SAAA;CAsFzB,MAAM,IAAInD,MAAM,wCAAwC;AAAE;AAtFjC,SAAAqD,SAAA;CAyFzB,MAAM,IAAIrD,MAAM,wCAAwC;AAAE;AAzFjC,SAAAuD,SAAA;CA4FzB,MAAM,IAAIvD,MAAM,wCAAwC;AAAE"}
|
|
1
|
+
{"version":3,"file":"thread-message-client.js","names":["ThreadAssistantMessagePart","ThreadUserMessagePart","ThreadMessage","Attachment","useMemo","useState","useResource","resource","withKey","ClientOutput","useClientLookup","MessageState","PartState","NoOpComposerClient","COMPLETE_STATUS","normalizePartStatus","getThreadMessageText","useThreadMessagePartClient","t0","$","_c","part","isMessageRunning","t1","t2","status","state","t3","getState","addToolResult","_temp","resumeToolCall","_temp2","respondToToolApproval","_temp3","ThreadMessagePartClient","useThreadMessageAttachmentClient","attachment","remove","Error","ThreadMessageAttachmentClient","ThreadMessageClientProps","message","index","isLast","branchNumber","branchCount","useThreadMessageClient","undefined","isCopiedState","setIsCopied","isHoveringState","setIsHovering","role","type","t4","content","t5","idx","toolCallId","map","parts","attachments","t6","_temp4","t7","Symbol","for","composer","t8","composerState","t9","parentId","speech","isCopied","isHovering","t10","t11","t12","selector","get","key","t13","selector_0","id","t14","t15","delete","_temp5","reload","_temp6","speak","_temp7","stopSpeaking","_temp8","submitFeedback","_temp9","switchToBranch","_temp0","getCopyText","ThreadMessageClient"],"sources":["../../../src/store/clients/thread-message-client.ts"],"sourcesContent":["import type {\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Attachment } from \"../../types/attachment\";\nimport { useMemo, useState } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { MessageState } from \"../scopes/message\";\nimport type { PartState } from \"../scopes/part\";\nimport { NoOpComposerClient } from \"./no-op-composer-client\";\nimport {\n COMPLETE_STATUS,\n normalizePartStatus,\n} from \"../../utils/normalizePartStatus\";\nimport { getThreadMessageText } from \"../../utils/text\";\n\nconst useThreadMessagePartClient = ({\n part,\n isMessageRunning,\n}: {\n part: ThreadAssistantMessagePart | ThreadUserMessagePart;\n isMessageRunning: boolean;\n}): ClientOutput<\"part\"> => {\n const state = useMemo<PartState>(() => {\n return {\n ...part,\n status: isMessageRunning\n ? (normalizePartStatus(part) ?? COMPLETE_STATUS)\n : COMPLETE_STATUS,\n };\n }, [part, isMessageRunning]);\n\n return {\n getState: () => state,\n addToolResult: () => {\n throw new Error(\"Not supported\");\n },\n resumeToolCall: () => {\n throw new Error(\"Not supported\");\n },\n respondToToolApproval: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessagePartClient = resource(useThreadMessagePartClient);\n\nconst useThreadMessageAttachmentClient = ({\n attachment,\n}: {\n attachment: Attachment;\n}): ClientOutput<\"attachment\"> => {\n return {\n getState: () => attachment,\n remove: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessageAttachmentClient = resource(\n useThreadMessageAttachmentClient,\n);\nexport type ThreadMessageClientProps = {\n message: ThreadMessage;\n index: number;\n isLast?: boolean;\n branchNumber?: number;\n branchCount?: number;\n};\n\nconst useThreadMessageClient = ({\n message,\n index,\n isLast = true,\n branchNumber = 1,\n branchCount = 1,\n}: ThreadMessageClientProps): ClientOutput<\"message\"> => {\n const [isCopiedState, setIsCopied] = useState(false);\n const [isHoveringState, setIsHovering] = useState(false);\n const isMessageRunning =\n message.role === \"assistant\" && message.status.type === \"running\";\n\n const parts = useClientLookup(\n message.content.map((part, idx) =>\n withKey(\n \"toolCallId\" in part && part.toolCallId != null\n ? `toolCallId-${part.toolCallId}`\n : `index-${idx}`,\n ThreadMessagePartClient({ part, isMessageRunning }),\n [part, isMessageRunning],\n ),\n ),\n );\n\n const attachments = useClientLookup(\n (message.attachments ?? []).map((attachment) =>\n withKey(attachment.id, ThreadMessageAttachmentClient({ attachment }), [\n attachment,\n ]),\n ),\n );\n\n const composer = useResource(NoOpComposerClient({ type: \"edit\" }));\n const composerState = composer.getState();\n\n const state = useMemo<MessageState>(() => {\n return {\n ...message,\n parts: parts.state,\n composer: composerState,\n parentId: null,\n index,\n isLast,\n branchNumber,\n branchCount,\n speech: undefined,\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n message,\n index,\n isCopiedState,\n isHoveringState,\n isLast,\n parts.state,\n composerState,\n branchNumber,\n branchCount,\n ]);\n\n return {\n getState: () => state,\n composer: () => composer,\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.get({ index: selector.index });\n } else {\n return parts.get({ key: `toolCallId-${selector.toolCallId}` });\n }\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n delete: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n reload: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n speak: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n stopSpeaking: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n submitFeedback: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n switchToBranch: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n getCopyText: () => {\n return getThreadMessageText(message);\n },\n setIsCopied,\n setIsHovering,\n };\n};\n\nexport const ThreadMessageClient = resource(useThreadMessageClient);\n"],"mappings":";;;;;;;;AAmBA,MAAMiB,8BAA6BC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAC,MAAAC,qBAAAJ;CAMnC,IAAAK;CAAA,IAAAJ,EAAA,OAAAG,oBAAAH,EAAA,OAAAE,MAAA;EAIaE,KAAAD,mBACHP,oBAAoBM,IAAuB,KAA3CP,kBADGA;EAEWK,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAE,QAAAF,EAAA,OAAAI,IAAA;EAJdC,KAAA;GAAA,GACFH;GAAII,QACCF;EAGV;EAACJ,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CANH,MAAAO,QACEF;CAM2B,IAAAG;CAAA,IAAAR,EAAA,OAAAO,OAAA;EAEtBC,KAAA;GAAAC,gBACWF;GAAKG,eACNC;GAEdC,gBACeC;GAEfC,uBACsBC;EAGzB;EAACf,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OA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I3D,MAAM,wCAAwC;AAAE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useSubscribable } from "./useSubscribable.js";
|
|
2
2
|
import { AttachmentRuntimeClient } from "./attachment-runtime-client.js";
|
|
3
|
-
import { useAssistantEmit, useClientLookup } from "@assistant-ui/store";
|
|
4
|
-
import { useEffect } from "@assistant-ui/tap/react-shim";
|
|
5
3
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
|
+
import { useEffect } from "@assistant-ui/tap/react-shim";
|
|
5
|
+
import { useAssistantEmit, useClientLookup } from "@assistant-ui/store";
|
|
6
6
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
7
7
|
//#region src/store/runtime-clients/composer-runtime-client.ts
|
|
8
8
|
const useComposerAttachmentClientByIndex = (t0) => {
|
|
@@ -3,9 +3,9 @@ import { AttachmentRuntimeClient } from "./attachment-runtime-client.js";
|
|
|
3
3
|
import { MessagePartClient } from "./message-part-runtime-client.js";
|
|
4
4
|
import { ComposerClient } from "./composer-runtime-client.js";
|
|
5
5
|
import { liveRef } from "./liveRef.js";
|
|
6
|
-
import { useClientLookup, useClientResource } from "@assistant-ui/store";
|
|
7
|
-
import { useState } from "@assistant-ui/tap/react-shim";
|
|
8
6
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
7
|
+
import { useState } from "@assistant-ui/tap/react-shim";
|
|
8
|
+
import { useClientLookup, useClientResource } from "@assistant-ui/store";
|
|
9
9
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
10
10
|
//#region src/store/runtime-clients/message-runtime-client.ts
|
|
11
11
|
const useMessageAttachmentClientByIndex = (t0) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useSubscribable } from "./useSubscribable.js";
|
|
2
|
-
import { useAssistantEmit } from "@assistant-ui/store";
|
|
3
|
-
import { useEffect } from "@assistant-ui/tap/react-shim";
|
|
4
2
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
+
import { useEffect } from "@assistant-ui/tap/react-shim";
|
|
4
|
+
import { useAssistantEmit } from "@assistant-ui/store";
|
|
5
5
|
import { resource } from "@assistant-ui/tap";
|
|
6
6
|
//#region src/store/runtime-clients/thread-list-item-runtime-client.ts
|
|
7
7
|
const useThreadListItemClient = (t0) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useSubscribable } from "./useSubscribable.js";
|
|
2
2
|
import { ThreadClient } from "./thread-runtime-client.js";
|
|
3
3
|
import { ThreadListItemClient } from "./thread-list-item-runtime-client.js";
|
|
4
|
-
import { useClientLookup, useClientResource } from "@assistant-ui/store";
|
|
5
|
-
import "@assistant-ui/tap/react-shim";
|
|
6
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
6
|
+
import { useClientLookup, useClientResource } from "@assistant-ui/store";
|
|
7
7
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
8
8
|
//#region src/store/runtime-clients/thread-list-runtime-client.ts
|
|
9
9
|
const useThreadListItemClientById = (t0) => {
|
|
@@ -2,9 +2,9 @@ import { useSubscribable } from "./useSubscribable.js";
|
|
|
2
2
|
import { ComposerClient } from "./composer-runtime-client.js";
|
|
3
3
|
import { liveRef } from "./liveRef.js";
|
|
4
4
|
import { MessageClient } from "./message-runtime-client.js";
|
|
5
|
-
import { useAssistantEmit, useClientLookup, useClientResource } from "@assistant-ui/store";
|
|
6
|
-
import { useEffect } from "@assistant-ui/tap/react-shim";
|
|
7
5
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
6
|
+
import { useEffect } from "@assistant-ui/tap/react-shim";
|
|
7
|
+
import { useAssistantEmit, useClientLookup, useClientResource } from "@assistant-ui/store";
|
|
8
8
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
9
9
|
//#region src/store/runtime-clients/thread-runtime-client.ts
|
|
10
10
|
const useMessageClientById = (t0) => {
|
|
@@ -97,7 +97,7 @@ type ThreadMethods = {
|
|
|
97
97
|
* @param initialMessages - Optional array of initial messages to populate the thread
|
|
98
98
|
*/
|
|
99
99
|
reset(initialMessages?: readonly ThreadMessageLike[]): void;
|
|
100
|
-
importExternalState
|
|
100
|
+
importExternalState(state: unknown): void;
|
|
101
101
|
message(selector: {
|
|
102
102
|
id: string;
|
|
103
103
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.d.ts","names":[],"sources":["../../../src/store/scopes/thread.ts"],"mappings":";;;;;;;;;;KAoBY;;;;WAID;;;;WAIA;;;;WAIA;;;;WAIA;;;;WAIA,cAAc;;;;WAId,mBAAmB;;;;;WAKnB,OAAO;;;;WAIP,sBAAsB;;;;WAItB;;WAEA,QAAQ;WACR,OAAO;WACP,UAAU;;KAGT;;;;EAIV,YAAY;;;;EAIZ,YAAY;;;;;;;;;;;;;;;;;EAiBZ,OAAO,SAAS;EAChB,cAAc,2BAA2B;;;;;EAKzC,SAAS,QAAQ;;;;;EAKjB,UAAU,QAAQ;EAClB;EACA,mBAAmB;EACnB,UAAU;EACV,OAAO,YAAY;;;;;EAKnB,MAAM,2BAA2B;EACjC,
|
|
1
|
+
{"version":3,"file":"thread.d.ts","names":[],"sources":["../../../src/store/scopes/thread.ts"],"mappings":";;;;;;;;;;KAoBY;;;;WAID;;;;WAIA;;;;WAIA;;;;WAIA;;;;WAIA,cAAc;;;;WAId,mBAAmB;;;;;WAKnB,OAAO;;;;WAIP,sBAAsB;;;;WAItB;;WAEA,QAAQ;WACR,OAAO;WACP,UAAU;;KAGT;;;;EAIV,YAAY;;;;EAIZ,YAAY;;;;;;;;;;;;;;;;;EAiBZ,OAAO,SAAS;EAChB,cAAc,2BAA2B;;;;;EAKzC,SAAS,QAAQ;;;;;EAKjB,UAAU,QAAQ;EAClB;EACA,mBAAmB;EACnB,UAAU;EACV,OAAO,YAAY;;;;;EAKnB,MAAM,2BAA2B;EACjC,oBAAoB;EACpB,QAAQ;IAAY;;IAAiB;MAAkB;;EAEvD;EACA;EACA;EACA;EACA,qBAAqB,uBAAuB;EAC5C;EACA;EACA,0BAA0B;;KAGhB;EACV;EACA;IAAS;;;KAGC;;;;;EAKV;IAAqB;;;;;;EAKrB;IAAmB;;;;;;;EAMnB;IAAuB;;;;;;EAKvB;IAA+B;;;KAGrB;EACV,SAAS;EACT,MAAM;EACN,QAAQ"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MessagePartStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart } from "./message.js";
|
|
1
|
+
import { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MessagePartStatus, MessagePartStreamStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart } from "./message.js";
|
|
2
2
|
import { Attachment, AttachmentStatus, CompleteAttachment, CreateAttachment, PendingAttachment } from "./attachment.js";
|
|
3
3
|
import { Unstable_TriggerCategory, Unstable_TriggerItem } from "./trigger.js";
|
|
4
4
|
import { Unstable_DirectiveFormatter, Unstable_DirectiveSegment } from "./directive.js";
|
|
5
5
|
import { Unsubscribe } from "./unsubscribe.js";
|
|
6
6
|
import { QuoteInfo } from "./quote.js";
|
|
7
|
-
export type { AppendMessage, Attachment, AttachmentStatus, CompleteAttachment, CreateAttachment, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MessagePartStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, PendingAttachment, QuoteInfo, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_TriggerCategory, Unstable_TriggerItem, Unsubscribe };
|
|
7
|
+
export type { AppendMessage, Attachment, AttachmentStatus, CompleteAttachment, CreateAttachment, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MessagePartStatus, MessagePartStreamStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, PendingAttachment, QuoteInfo, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_TriggerCategory, Unstable_TriggerItem, Unsubscribe };
|
package/dist/types/message.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ type PartProviderMetadata = {
|
|
|
8
8
|
type TextMessagePart = {
|
|
9
9
|
readonly type: "text";
|
|
10
10
|
readonly text: string;
|
|
11
|
+
readonly status?: MessagePartStreamStatus;
|
|
11
12
|
readonly providerMetadata?: PartProviderMetadata;
|
|
12
13
|
readonly parentId?: string;
|
|
13
14
|
};
|
|
14
15
|
type ReasoningMessagePart = {
|
|
15
16
|
readonly type: "reasoning";
|
|
16
17
|
readonly text: string;
|
|
18
|
+
readonly status?: MessagePartStreamStatus;
|
|
17
19
|
readonly providerMetadata?: PartProviderMetadata;
|
|
18
20
|
readonly parentId?: string;
|
|
19
21
|
};
|
|
@@ -214,6 +216,14 @@ type MessagePartStatus = {
|
|
|
214
216
|
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
|
215
217
|
readonly error?: unknown;
|
|
216
218
|
};
|
|
219
|
+
type MessagePartStreamStatus = {
|
|
220
|
+
readonly type: "running";
|
|
221
|
+
} | {
|
|
222
|
+
readonly type: "complete";
|
|
223
|
+
} | {
|
|
224
|
+
readonly type: "incomplete";
|
|
225
|
+
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
|
226
|
+
};
|
|
217
227
|
type ToolCallMessagePartStatus = {
|
|
218
228
|
/** The tool call is waiting for UI or human input before continuing. */
|
|
219
229
|
readonly type: "requires-action";
|
|
@@ -333,5 +343,5 @@ type AppendMessage = Omit<ThreadMessage, "id"> & {
|
|
|
333
343
|
steer?: boolean | undefined;
|
|
334
344
|
};
|
|
335
345
|
//#endregion
|
|
336
|
-
export { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MCP_APP_URI_SCHEME, McpAppMetadata, MessagePartStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartMcpMetadata, ToolCallMessagePartStatus, type ToolCallTiming, type ToolModelContentPart, Unstable_AudioMessagePart, isMcpAppUri };
|
|
346
|
+
export { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MCP_APP_URI_SCHEME, McpAppMetadata, MessagePartStatus, MessagePartStreamStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartMcpMetadata, ToolCallMessagePartStatus, type ToolCallTiming, type ToolModelContentPart, Unstable_AudioMessagePart, isMcpAppUri };
|
|
337
347
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","names":[],"sources":["../../src/types/message.ts"],"mappings":";;;;KASY;YACA,uBAAuB;;KAGvB;WACD;WACA;WACA,mBAAmB;WACnB;;KAGC;WACD;WACA;WACA,mBAAmB;WACnB;;KAGC,yBAAyB;KAEzB;WAEG;WACA;WACA;WACA;WACA;WACA,mBAAmB;WACnB;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,mBAAmB;WACnB;;KAGH;WACD;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;aACE;aACA;;;KAID,gBAAgB;WACjB;WACA;WACA,MAAM;;;;;;;;;;;KAYL;;WAIG;;WAEA,QAAQ;;WAER,oBAAoB;;WAEpB;;;;;KAMH;;WAED,MAAM,4BAA4B;;;;;;;;;;KAWjC;WACD;;WAEA,MAAM;;WAEN;WACA;;KAGC;WACD;WACA;WACA;;WAEA;;cAGE;cAEA,cAAe;KAGhB;WACD,MAAM;;KAGL;KAMA;;WAED;;;;;;;WAOA,MAAM;;WAEN;WACA;;WAEA;;WAEA;IAAsB;IAAgB;;;KAGrC;WAC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;;EAEA"}
|
|
1
|
+
{"version":3,"file":"message.d.ts","names":[],"sources":["../../src/types/message.ts"],"mappings":";;;;KASY;YACA,uBAAuB;;KAGvB;WACD;WACA;WACA,SAAS;WACT,mBAAmB;WACnB;;KAGC;WACD;WACA;WACA,SAAS;WACT,mBAAmB;WACnB;;KAGC,yBAAyB;KAEzB;WAEG;WACA;WACA;WACA;WACA;WACA,mBAAmB;WACnB;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,mBAAmB;WACnB;;KAGH;WACD;WACA;WACA;;KAGC;WACD;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;aACE;aACA;;;KAID,gBAAgB;WACjB;WACA;WACA,MAAM;;;;;;;;;;;KAYL;;WAIG;;WAEA,QAAQ;;WAER,oBAAoB;;WAEpB;;;;;KAMH;;WAED,MAAM,4BAA4B;;;;;;;;;;KAWjC;WACD;;WAEA,MAAM;;WAEN;WACA;;KAGC;WACD;WACA;WACA;;WAEA;;cAGE;cAEA,cAAe;KAGhB;WACD,MAAM;;KAGL;KAMA;;WAED;;;;;;;WAOA,MAAM;;WAEN;WACA;;WAEA;;WAEA;IAAsB;IAAgB;;;KAGrC;WACG;WAA4B;;WAC5B;WAA2B;;WAE3B;WACA;WACA;;KAGH,oBACV,QAAQ,oBACR;;WAGS;;WAEA;;WAEA;;;;;;WAMA,MAAM;;WAEN,SAAS;;WAET;;WAEA;;WAEA;;WAEA,SAAS;;WAET,MAAM;;WAEN,mBAAmB;;WAEnB,wBAAwB;;WAExB;IAAc;IAAe;;;WAE7B;aACE;aACA;aACA;aACA;;aAEA,mBAAmB;;aAEnB;;aAEA;;;WAGF;;;;;WAKA,oBAAoB;;KAGnB,wBACR,kBACA,mBACA,kBACA,kBACA;KAEQ,6BACR,kBACA,uBACA,sBACA,oBACA,kBACA,mBACA,kBACA;KAEQ;WAEG;;WAGA;;WAGA;WACA;WAMA;;KAGH;WAEG;;WAGA;;WAGA;WACA;;KAQH;;WAGG;;WAEA;IAEX;KAEQ;WAEG;;WAGA;WACA;;WAGA;WACA;;WAGA;WACA;WAOA,QAAQ;;KAGX;WACD;WACA;WACA;WACA;WACA;WACA;WACA;;KAGC;WACD;WACA;aAEM;aACA;;;KAKZ;WACM;WACA,WAAW;;KAGV,sBAAsB;WACvB;WACA,mBAAmB;WACnB;aACE;aACA;aACA;aACA;aACA;aACA;aACA,QAAQ;;;KAIT,oBAAoB;WACrB;WACA,kBAAkB;WAClB,sBAAsB;WACtB;aACE;aACA;aACA;aACA;aACA;aACA;aACA;aACA,QAAQ;;;KAIT,yBAAyB;WAC1B;WACA,kBAAkB;WAClB,QAAQ;WACR;aACE,gBAAgB;aAChB,+BAA+B;aAC/B,wBAAwB;aACxB,gBAAgB;aAChB;eAA+B;;aAC/B,SAAS;;;;;aAKT;aACA,QAAQ;;;KAIhB;WACM,SAAS;WACT;aACE,iBAAiB;aACjB,gCAAgC;aAChC,yBAAyB;aACzB,iBAAiB;aACjB;eAA+B;;aAC/B,SAAS;aACT;aACA,QAAQ;;WAEV,cAAc;;KAGb,gBAAgB,qBACzB,sBAAsB,oBAAoB;KAEjC,cAAc;KAEd;WACD,SAAS;;KAGR,gBAAgB,KAAK;EAC/B;;EAGA;EACA,WAAW;EACX;;EAEA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","names":["ReadonlyJSONObject","ReadonlyJSONValue","ToolCallTiming","ToolModelContentPart","CompleteAttachment","PartProviderMetadata","providerName","TextMessagePart","type","text","providerMetadata","parentId","ReasoningMessagePart","SourceProviderMetadata","SourceMessagePart","sourceType","id","url","title","mediaType","filename","ImageMessagePart","image","FileMessagePart","data","mimeType","Unstable_AudioMessagePart","audio","format","DataMessagePart","name","T","GenerativeUINode","component","props","Record","children","key","GenerativeUISpec","root","GenerativeUIMessagePart","spec","McpAppMetadata","resourceUri","visibility","serverId","MCP_APP_URI_SCHEME","isMcpAppUri","uri","startsWith","ToolCallMessagePartMcpMetadata","app","ToolApprovalOptionKind","ToolApprovalOption","kind","label","description","grants","confirm","ToolApprovalResponse","approved","reason","optionId","ToolCallMessagePart","toolCallId","toolName","args","TArgs","result","TResult","isError","argsText","artifact","timing","mcp","modelContent","interrupt","payload","approval","isAutomatic","options","resolution","messages","ThreadMessage","ThreadUserMessagePart","ThreadAssistantMessagePart","MessagePartStatus","error","ToolCallMessagePartStatus","MessageStatus","MessageTiming","streamStartTime","firstTokenTime","totalStreamTime","tokenCount","tokensPerSecond","totalChunks","toolCallCount","ThreadStep","messageId","usage","inputTokens","outputTokens","MessageCommonProps","createdAt","Date","ThreadSystemMessage","role","content","metadata","unstable_state","unstable_annotations","unstable_data","steps","submittedFeedback","custom","ThreadUserMessage","attachments","isOptimistic","ThreadAssistantMessage","status","BaseThreadMessage","MessageRole","RunConfig","AppendMessage","Omit","sourceId","runConfig","startRun","steer"],"sources":["../../src/types/message.ts"],"sourcesContent":["import type {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"assistant-stream/utils\";\nimport type { ToolCallTiming, ToolModelContentPart } from \"assistant-stream\";\nimport type { CompleteAttachment } from \"./attachment\";\n\nexport type { ToolCallTiming, ToolModelContentPart };\n\nexport type PartProviderMetadata = {\n readonly [providerName: string]: ReadonlyJSONObject;\n};\n\nexport type TextMessagePart = {\n readonly type: \"text\";\n readonly text: string;\n readonly providerMetadata?: PartProviderMetadata;\n readonly parentId?: string;\n};\n\nexport type ReasoningMessagePart = {\n readonly type: \"reasoning\";\n readonly text: string;\n readonly providerMetadata?: PartProviderMetadata;\n readonly parentId?: string;\n};\n\nexport type SourceProviderMetadata = PartProviderMetadata;\n\nexport type SourceMessagePart =\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 readonly parentId?: string;\n }\n | {\n readonly type: \"source\";\n readonly sourceType: \"document\";\n readonly id: string;\n readonly url?: undefined;\n readonly title: string;\n readonly mediaType: string;\n readonly filename?: string;\n readonly providerMetadata?: SourceProviderMetadata;\n readonly parentId?: string;\n };\n\nexport type ImageMessagePart = {\n readonly type: \"image\";\n readonly image: string;\n readonly filename?: string;\n};\n\nexport type FileMessagePart = {\n readonly type: \"file\";\n readonly filename?: string;\n readonly data: string;\n readonly mimeType: string;\n readonly parentId?: string;\n};\n\nexport type Unstable_AudioMessagePart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\nexport type DataMessagePart<T = any> = {\n readonly type: \"data\";\n readonly name: string;\n readonly data: T;\n};\n\n/**\n * A JSON spec describing a tree of UI components to render.\n *\n * The agent emits a {@link GenerativeUIMessagePart} containing this spec, and\n * the consumer-provided component allowlist is used to resolve `component`\n * names. Any component referenced that is not present in the allowlist is\n * rejected with a typed error — the allowlist is the security boundary in the\n * default same-realm rendering path.\n */\nexport type GenerativeUINode =\n | string\n | {\n /** Allowlisted component name (resolved against the consumer registry). */\n readonly component: string;\n /** Props passed to the resolved component (must be JSON-serializable). */\n readonly props?: Record<string, unknown>;\n /** Optional children — strings render as text, objects recurse. */\n readonly children?: readonly GenerativeUINode[];\n /** Optional stable key for React reconciliation. */\n readonly key?: string;\n };\n\n/**\n * The root spec for a generative UI tree.\n */\nexport type GenerativeUISpec = {\n /** Root node(s) to render. */\n readonly root: GenerativeUINode | readonly GenerativeUINode[];\n};\n\n/**\n * A message part that carries a JSON spec describing UI to render.\n *\n * Render with `<MessagePrimitive.GenerativeUI components={...} />`. The\n * primitive resolves component names against the consumer-provided allowlist\n * — any unknown name throws a typed error rather than rendering. Stream-\n * friendly: a partially-streamed spec renders progressively.\n */\nexport type GenerativeUIMessagePart = {\n readonly type: \"generative-ui\";\n /** The JSON spec describing the UI tree. */\n readonly spec: GenerativeUISpec;\n /** Optional id (useful for replays / stable keys). */\n readonly id?: string;\n readonly parentId?: string;\n};\n\nexport type McpAppMetadata = {\n readonly resourceUri: string;\n readonly mimeType?: string;\n readonly visibility?: readonly (\"model\" | \"app\")[];\n /** Routable server identity emitted by the agent stack when multiple MCP servers back one agent; for @ag-ui/mcp-apps-middleware this is the configured serverId, falling back to its serverHash. */\n readonly serverId?: string;\n};\n\nexport const MCP_APP_URI_SCHEME = \"ui://\";\n\nexport const isMcpAppUri = (uri: string | undefined): boolean =>\n !!uri?.startsWith(MCP_APP_URI_SCHEME);\n\nexport type ToolCallMessagePartMcpMetadata = {\n readonly app?: McpAppMetadata;\n};\n\nexport type ToolApprovalOptionKind =\n | \"allow-once\"\n | \"allow-always\"\n | \"reject-once\"\n | \"reject-always\";\n\nexport type ToolApprovalOption = {\n /** Opaque, host-defined identifier. Scope semantics (session vs project vs global) belong to the option supplier. */\n readonly id: string;\n /**\n * Decision class. Drives approved-resolution and default rendering.\n * Open union: `_`-prefixed custom kinds are never auto-resolved and the\n * default kit skips them; they must be answered with an explicit\n * `approved` value (optionally alongside the `optionId`).\n */\n readonly kind: ToolApprovalOptionKind | (string & {});\n /** Human label. Renderers supply defaults per kind when omitted. */\n readonly label?: string;\n readonly description?: string;\n /** Patterns or rules this option would persist, shown before the user commits. Supplied by the host; never derived by the library. */\n readonly grants?: readonly string[];\n /** Opt-in confirmation step before this option resolves. */\n readonly confirm?: boolean | { title?: string; description?: string };\n};\n\nexport type ToolApprovalResponse =\n | { readonly approved: boolean; readonly reason?: string }\n | { readonly optionId: string; readonly reason?: string }\n | {\n readonly approved: boolean;\n readonly optionId: string;\n readonly reason?: string;\n };\n\nexport type ToolCallMessagePart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = {\n /** Identifies this part as a tool call. */\n readonly type: \"tool-call\";\n /** Stable identifier for this invocation of the tool. */\n readonly toolCallId: string;\n /** Name of the tool requested by the model. */\n readonly toolName: string;\n /**\n * Arguments supplied by the model. During streaming this is a partial parse:\n * fields may be missing or incomplete. From a tool-call renderer, use\n * `useToolArgsStatus` to detect which fields are still arriving.\n */\n readonly args: TArgs;\n /** Result returned by the tool, if it has completed. */\n readonly result?: TResult | undefined;\n /** Whether the result represents a tool execution error. */\n readonly isError?: boolean | undefined;\n /** Raw JSON argument text streamed by the model. */\n readonly argsText: string;\n /** UI-only artifact associated with the tool result. */\n readonly artifact?: unknown;\n /** Wall-clock timing for this call, when the runtime or host tracks it. */\n readonly timing?: ToolCallTiming;\n /** MCP app metadata associated with this tool call, when present. */\n readonly mcp?: ToolCallMessagePartMcpMetadata;\n /** Provider metadata associated with this tool call, when present. */\n readonly providerMetadata?: PartProviderMetadata;\n /** Content returned to the model for this tool result. */\n readonly modelContent?: readonly ToolModelContentPart[] | undefined;\n /** Human-input request that must be resolved before the run can continue. */\n readonly interrupt?: { type: \"human\"; payload: unknown };\n /** Server-side approval gate. `respondToApproval` may only be called while `approved` is undefined and no `resolution` is recorded. */\n readonly approval?: {\n readonly id: string;\n readonly approved?: boolean;\n readonly reason?: string;\n readonly isAutomatic?: boolean;\n /** Available decisions for this call. Absent: a plain allow / deny pair. */\n readonly options?: readonly ToolApprovalOption[];\n /** The option chosen at resolution, when options were present. */\n readonly optionId?: string;\n /** Terminal non-decision state: the request was cancelled or expired without a user decision. Set by the host. */\n readonly resolution?: \"cancelled\" | \"expired\";\n };\n /** Parent message-part ID when this part belongs to a nested structure. */\n readonly parentId?: string;\n /**\n * Nested thread messages produced by this tool call, for example a sub-agent\n * conversation.\n */\n readonly messages?: readonly ThreadMessage[];\n};\n\nexport type ThreadUserMessagePart =\n | TextMessagePart\n | ImageMessagePart\n | FileMessagePart\n | DataMessagePart\n | Unstable_AudioMessagePart;\n\nexport type ThreadAssistantMessagePart =\n | TextMessagePart\n | ReasoningMessagePart\n | ToolCallMessagePart\n | SourceMessagePart\n | FileMessagePart\n | ImageMessagePart\n | DataMessagePart\n | GenerativeUIMessagePart;\n\nexport type MessagePartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallMessagePartStatus =\n | {\n /** The tool call is waiting for UI or human input before continuing. */\n readonly type: \"requires-action\";\n /** Reason the tool call requires action. */\n readonly reason: \"interrupt\";\n }\n | MessagePartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\" | \"interrupt\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: ReadonlyJSONValue;\n };\n\nexport type MessageTiming = {\n readonly streamStartTime: number;\n readonly firstTokenTime?: number;\n readonly totalStreamTime?: number;\n readonly tokenCount?: number;\n readonly tokensPerSecond?: number;\n readonly totalChunks: number;\n readonly toolCallCount: number;\n};\n\nexport type ThreadStep = {\n readonly messageId?: string;\n readonly usage?:\n | {\n readonly inputTokens: number;\n readonly outputTokens: number;\n }\n | undefined;\n};\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextMessagePart];\n readonly metadata: {\n readonly unstable_state?: undefined;\n readonly unstable_annotations?: undefined;\n readonly unstable_data?: undefined;\n readonly steps?: undefined;\n readonly submittedFeedback?: undefined;\n readonly timing?: undefined;\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserMessagePart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly unstable_state?: undefined;\n readonly unstable_annotations?: undefined;\n readonly unstable_data?: undefined;\n readonly steps?: undefined;\n readonly submittedFeedback?: undefined;\n readonly timing?: undefined;\n readonly isOptimistic?: boolean;\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantMessagePart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_state: ReadonlyJSONValue;\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly ThreadStep[];\n readonly submittedFeedback?: { readonly type: \"positive\" | \"negative\" };\n readonly timing?: MessageTiming;\n /**\n * Marks a client-side optimistic placeholder. Such messages are evicted\n * once off the head branch and are never persisted.\n */\n readonly isOptimistic?: boolean;\n readonly custom: Record<string, unknown>;\n };\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly unstable_state?: ReadonlyJSONValue;\n readonly unstable_annotations?: readonly ReadonlyJSONValue[];\n readonly unstable_data?: readonly ReadonlyJSONValue[];\n readonly steps?: readonly ThreadStep[];\n readonly submittedFeedback?: { readonly type: \"positive\" | \"negative\" };\n readonly timing?: MessageTiming;\n readonly isOptimistic?: boolean;\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\nexport type MessageRole = ThreadMessage[\"role\"];\n\nexport type RunConfig = {\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = Omit<ThreadMessage, \"id\"> & {\n parentId: string | null;\n\n /** The ID of the message that was edited or undefined. */\n sourceId: string | null;\n runConfig: RunConfig | undefined;\n startRun?: boolean | undefined;\n /** Process this message next; only meaningful for queue-capable runtimes. */\n steer?: boolean | undefined;\n};\n"],"mappings":";AAsIA,MAAa8C,qBAAqB;AAElC,MAAaC,eAAeC,QAC1B,CAAC,CAACA,KAAKC,WAAWH,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"message.js","names":["ReadonlyJSONObject","ReadonlyJSONValue","ToolCallTiming","ToolModelContentPart","CompleteAttachment","PartProviderMetadata","providerName","TextMessagePart","type","text","status","MessagePartStreamStatus","providerMetadata","parentId","ReasoningMessagePart","SourceProviderMetadata","SourceMessagePart","sourceType","id","url","title","mediaType","filename","ImageMessagePart","image","FileMessagePart","data","mimeType","Unstable_AudioMessagePart","audio","format","DataMessagePart","name","T","GenerativeUINode","component","props","Record","children","key","GenerativeUISpec","root","GenerativeUIMessagePart","spec","McpAppMetadata","resourceUri","visibility","serverId","MCP_APP_URI_SCHEME","isMcpAppUri","uri","startsWith","ToolCallMessagePartMcpMetadata","app","ToolApprovalOptionKind","ToolApprovalOption","kind","label","description","grants","confirm","ToolApprovalResponse","approved","reason","optionId","ToolCallMessagePart","toolCallId","toolName","args","TArgs","result","TResult","isError","argsText","artifact","timing","mcp","modelContent","interrupt","payload","approval","isAutomatic","options","resolution","messages","ThreadMessage","ThreadUserMessagePart","ThreadAssistantMessagePart","MessagePartStatus","error","ToolCallMessagePartStatus","MessageStatus","MessageTiming","streamStartTime","firstTokenTime","totalStreamTime","tokenCount","tokensPerSecond","totalChunks","toolCallCount","ThreadStep","messageId","usage","inputTokens","outputTokens","MessageCommonProps","createdAt","Date","ThreadSystemMessage","role","content","metadata","unstable_state","unstable_annotations","unstable_data","steps","submittedFeedback","custom","ThreadUserMessage","attachments","isOptimistic","ThreadAssistantMessage","BaseThreadMessage","MessageRole","RunConfig","AppendMessage","Omit","sourceId","runConfig","startRun","steer"],"sources":["../../src/types/message.ts"],"sourcesContent":["import type {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"assistant-stream/utils\";\nimport type { ToolCallTiming, ToolModelContentPart } from \"assistant-stream\";\nimport type { CompleteAttachment } from \"./attachment\";\n\nexport type { ToolCallTiming, ToolModelContentPart };\n\nexport type PartProviderMetadata = {\n readonly [providerName: string]: ReadonlyJSONObject;\n};\n\nexport type TextMessagePart = {\n readonly type: \"text\";\n readonly text: string;\n readonly status?: MessagePartStreamStatus;\n readonly providerMetadata?: PartProviderMetadata;\n readonly parentId?: string;\n};\n\nexport type ReasoningMessagePart = {\n readonly type: \"reasoning\";\n readonly text: string;\n readonly status?: MessagePartStreamStatus;\n readonly providerMetadata?: PartProviderMetadata;\n readonly parentId?: string;\n};\n\nexport type SourceProviderMetadata = PartProviderMetadata;\n\nexport type SourceMessagePart =\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 readonly parentId?: string;\n }\n | {\n readonly type: \"source\";\n readonly sourceType: \"document\";\n readonly id: string;\n readonly url?: undefined;\n readonly title: string;\n readonly mediaType: string;\n readonly filename?: string;\n readonly providerMetadata?: SourceProviderMetadata;\n readonly parentId?: string;\n };\n\nexport type ImageMessagePart = {\n readonly type: \"image\";\n readonly image: string;\n readonly filename?: string;\n};\n\nexport type FileMessagePart = {\n readonly type: \"file\";\n readonly filename?: string;\n readonly data: string;\n readonly mimeType: string;\n readonly parentId?: string;\n};\n\nexport type Unstable_AudioMessagePart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\nexport type DataMessagePart<T = any> = {\n readonly type: \"data\";\n readonly name: string;\n readonly data: T;\n};\n\n/**\n * A JSON spec describing a tree of UI components to render.\n *\n * The agent emits a {@link GenerativeUIMessagePart} containing this spec, and\n * the consumer-provided component allowlist is used to resolve `component`\n * names. Any component referenced that is not present in the allowlist is\n * rejected with a typed error — the allowlist is the security boundary in the\n * default same-realm rendering path.\n */\nexport type GenerativeUINode =\n | string\n | {\n /** Allowlisted component name (resolved against the consumer registry). */\n readonly component: string;\n /** Props passed to the resolved component (must be JSON-serializable). */\n readonly props?: Record<string, unknown>;\n /** Optional children — strings render as text, objects recurse. */\n readonly children?: readonly GenerativeUINode[];\n /** Optional stable key for React reconciliation. */\n readonly key?: string;\n };\n\n/**\n * The root spec for a generative UI tree.\n */\nexport type GenerativeUISpec = {\n /** Root node(s) to render. */\n readonly root: GenerativeUINode | readonly GenerativeUINode[];\n};\n\n/**\n * A message part that carries a JSON spec describing UI to render.\n *\n * Render with `<MessagePrimitive.GenerativeUI components={...} />`. The\n * primitive resolves component names against the consumer-provided allowlist\n * — any unknown name throws a typed error rather than rendering. Stream-\n * friendly: a partially-streamed spec renders progressively.\n */\nexport type GenerativeUIMessagePart = {\n readonly type: \"generative-ui\";\n /** The JSON spec describing the UI tree. */\n readonly spec: GenerativeUISpec;\n /** Optional id (useful for replays / stable keys). */\n readonly id?: string;\n readonly parentId?: string;\n};\n\nexport type McpAppMetadata = {\n readonly resourceUri: string;\n readonly mimeType?: string;\n readonly visibility?: readonly (\"model\" | \"app\")[];\n /** Routable server identity emitted by the agent stack when multiple MCP servers back one agent; for @ag-ui/mcp-apps-middleware this is the configured serverId, falling back to its serverHash. */\n readonly serverId?: string;\n};\n\nexport const MCP_APP_URI_SCHEME = \"ui://\";\n\nexport const isMcpAppUri = (uri: string | undefined): boolean =>\n !!uri?.startsWith(MCP_APP_URI_SCHEME);\n\nexport type ToolCallMessagePartMcpMetadata = {\n readonly app?: McpAppMetadata;\n};\n\nexport type ToolApprovalOptionKind =\n | \"allow-once\"\n | \"allow-always\"\n | \"reject-once\"\n | \"reject-always\";\n\nexport type ToolApprovalOption = {\n /** Opaque, host-defined identifier. Scope semantics (session vs project vs global) belong to the option supplier. */\n readonly id: string;\n /**\n * Decision class. Drives approved-resolution and default rendering.\n * Open union: `_`-prefixed custom kinds are never auto-resolved and the\n * default kit skips them; they must be answered with an explicit\n * `approved` value (optionally alongside the `optionId`).\n */\n readonly kind: ToolApprovalOptionKind | (string & {});\n /** Human label. Renderers supply defaults per kind when omitted. */\n readonly label?: string;\n readonly description?: string;\n /** Patterns or rules this option would persist, shown before the user commits. Supplied by the host; never derived by the library. */\n readonly grants?: readonly string[];\n /** Opt-in confirmation step before this option resolves. */\n readonly confirm?: boolean | { title?: string; description?: string };\n};\n\nexport type ToolApprovalResponse =\n | { readonly approved: boolean; readonly reason?: string }\n | { readonly optionId: string; readonly reason?: string }\n | {\n readonly approved: boolean;\n readonly optionId: string;\n readonly reason?: string;\n };\n\nexport type ToolCallMessagePart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = {\n /** Identifies this part as a tool call. */\n readonly type: \"tool-call\";\n /** Stable identifier for this invocation of the tool. */\n readonly toolCallId: string;\n /** Name of the tool requested by the model. */\n readonly toolName: string;\n /**\n * Arguments supplied by the model. During streaming this is a partial parse:\n * fields may be missing or incomplete. From a tool-call renderer, use\n * `useToolArgsStatus` to detect which fields are still arriving.\n */\n readonly args: TArgs;\n /** Result returned by the tool, if it has completed. */\n readonly result?: TResult | undefined;\n /** Whether the result represents a tool execution error. */\n readonly isError?: boolean | undefined;\n /** Raw JSON argument text streamed by the model. */\n readonly argsText: string;\n /** UI-only artifact associated with the tool result. */\n readonly artifact?: unknown;\n /** Wall-clock timing for this call, when the runtime or host tracks it. */\n readonly timing?: ToolCallTiming;\n /** MCP app metadata associated with this tool call, when present. */\n readonly mcp?: ToolCallMessagePartMcpMetadata;\n /** Provider metadata associated with this tool call, when present. */\n readonly providerMetadata?: PartProviderMetadata;\n /** Content returned to the model for this tool result. */\n readonly modelContent?: readonly ToolModelContentPart[] | undefined;\n /** Human-input request that must be resolved before the run can continue. */\n readonly interrupt?: { type: \"human\"; payload: unknown };\n /** Server-side approval gate. `respondToApproval` may only be called while `approved` is undefined and no `resolution` is recorded. */\n readonly approval?: {\n readonly id: string;\n readonly approved?: boolean;\n readonly reason?: string;\n readonly isAutomatic?: boolean;\n /** Available decisions for this call. Absent: a plain allow / deny pair. */\n readonly options?: readonly ToolApprovalOption[];\n /** The option chosen at resolution, when options were present. */\n readonly optionId?: string;\n /** Terminal non-decision state: the request was cancelled or expired without a user decision. Set by the host. */\n readonly resolution?: \"cancelled\" | \"expired\";\n };\n /** Parent message-part ID when this part belongs to a nested structure. */\n readonly parentId?: string;\n /**\n * Nested thread messages produced by this tool call, for example a sub-agent\n * conversation.\n */\n readonly messages?: readonly ThreadMessage[];\n};\n\nexport type ThreadUserMessagePart =\n | TextMessagePart\n | ImageMessagePart\n | FileMessagePart\n | DataMessagePart\n | Unstable_AudioMessagePart;\n\nexport type ThreadAssistantMessagePart =\n | TextMessagePart\n | ReasoningMessagePart\n | ToolCallMessagePart\n | SourceMessagePart\n | FileMessagePart\n | ImageMessagePart\n | DataMessagePart\n | GenerativeUIMessagePart;\n\nexport type MessagePartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type MessagePartStreamStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n };\n\nexport type ToolCallMessagePartStatus =\n | {\n /** The tool call is waiting for UI or human input before continuing. */\n readonly type: \"requires-action\";\n /** Reason the tool call requires action. */\n readonly reason: \"interrupt\";\n }\n | MessagePartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\" | \"interrupt\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: ReadonlyJSONValue;\n };\n\nexport type MessageTiming = {\n readonly streamStartTime: number;\n readonly firstTokenTime?: number;\n readonly totalStreamTime?: number;\n readonly tokenCount?: number;\n readonly tokensPerSecond?: number;\n readonly totalChunks: number;\n readonly toolCallCount: number;\n};\n\nexport type ThreadStep = {\n readonly messageId?: string;\n readonly usage?:\n | {\n readonly inputTokens: number;\n readonly outputTokens: number;\n }\n | undefined;\n};\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextMessagePart];\n readonly metadata: {\n readonly unstable_state?: undefined;\n readonly unstable_annotations?: undefined;\n readonly unstable_data?: undefined;\n readonly steps?: undefined;\n readonly submittedFeedback?: undefined;\n readonly timing?: undefined;\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserMessagePart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly unstable_state?: undefined;\n readonly unstable_annotations?: undefined;\n readonly unstable_data?: undefined;\n readonly steps?: undefined;\n readonly submittedFeedback?: undefined;\n readonly timing?: undefined;\n readonly isOptimistic?: boolean;\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantMessagePart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_state: ReadonlyJSONValue;\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly ThreadStep[];\n readonly submittedFeedback?: { readonly type: \"positive\" | \"negative\" };\n readonly timing?: MessageTiming;\n /**\n * Marks a client-side optimistic placeholder. Such messages are evicted\n * once off the head branch and are never persisted.\n */\n readonly isOptimistic?: boolean;\n readonly custom: Record<string, unknown>;\n };\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly unstable_state?: ReadonlyJSONValue;\n readonly unstable_annotations?: readonly ReadonlyJSONValue[];\n readonly unstable_data?: readonly ReadonlyJSONValue[];\n readonly steps?: readonly ThreadStep[];\n readonly submittedFeedback?: { readonly type: \"positive\" | \"negative\" };\n readonly timing?: MessageTiming;\n readonly isOptimistic?: boolean;\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\nexport type MessageRole = ThreadMessage[\"role\"];\n\nexport type RunConfig = {\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = Omit<ThreadMessage, \"id\"> & {\n parentId: string | null;\n\n /** The ID of the message that was edited or undefined. */\n sourceId: string | null;\n runConfig: RunConfig | undefined;\n startRun?: boolean | undefined;\n /** Process this message next; only meaningful for queue-capable runtimes. */\n steer?: boolean | undefined;\n};\n"],"mappings":";AAwIA,MAAagD,qBAAqB;AAElC,MAAaC,eAAeC,QAC1B,CAAC,CAACA,KAAKC,WAAWH,kBAAkB"}
|
package/dist/utils/data-url.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//#region src/utils/data-url.ts
|
|
2
2
|
const httpUrlPattern = /^https?:\/\//i;
|
|
3
3
|
function parseDataUrl(value) {
|
|
4
|
-
const match = value.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(
|
|
4
|
+
const match = value.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);
|
|
5
5
|
if (!match) return null;
|
|
6
6
|
return {
|
|
7
|
-
mimeType: match[1],
|
|
7
|
+
mimeType: match[1].toLowerCase(),
|
|
8
8
|
data: match[2]
|
|
9
9
|
};
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-url.js","names":["httpUrlPattern","parseDataUrl","value","mimeType","data","match"],"sources":["../../src/utils/data-url.ts"],"sourcesContent":["export const httpUrlPattern = /^https?:\\/\\//i;\n\nexport function parseDataUrl(\n value: string,\n): { mimeType: string; data: string } | null {\n const match = value.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(
|
|
1
|
+
{"version":3,"file":"data-url.js","names":["httpUrlPattern","parseDataUrl","value","mimeType","data","match","toLowerCase"],"sources":["../../src/utils/data-url.ts"],"sourcesContent":["export const httpUrlPattern = /^https?:\\/\\//i;\n\nexport function parseDataUrl(\n value: string,\n): { mimeType: string; data: string } | null {\n const match = value.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);\n if (!match) return null;\n return { mimeType: match[1]!.toLowerCase(), data: match[2]! };\n}\n"],"mappings":";AAAA,MAAaA,iBAAiB;AAE9B,SAAgBC,aACdC,OAC2C;CAC3C,MAAMG,QAAQH,MAAMG,MAAM,0CAA0C;CACpE,IAAI,CAACA,OAAO,OAAO;CACnB,OAAO;EAAEF,UAAUE,MAAM,EAAE,CAAEC,YAAY;EAAGF,MAAMC,MAAM;CAAI;AAC9D"}
|