@yourgpt/copilot-sdk 2.5.1-beta.0 → 2.5.2-alpha.0
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/{chunk-JPUKXFR4.js → chunk-37HN4F6S.js} +488 -92
- package/dist/chunk-37HN4F6S.js.map +1 -0
- package/dist/{chunk-6R63NBNP.cjs → chunk-4PL7TK42.cjs} +16 -16
- package/dist/{chunk-6R63NBNP.cjs.map → chunk-4PL7TK42.cjs.map} +1 -1
- package/dist/{chunk-ZYLHGNIG.cjs → chunk-GW5ZZHJ7.cjs} +488 -92
- package/dist/chunk-GW5ZZHJ7.cjs.map +1 -0
- package/dist/{chunk-YYLTWY5R.js → chunk-VHJ46HKC.js} +3 -3
- package/dist/{chunk-YYLTWY5R.js.map → chunk-VHJ46HKC.js.map} +1 -1
- package/dist/experimental/index.cjs +2 -2
- package/dist/experimental/index.js +1 -1
- package/dist/react/index.cjs +62 -62
- package/dist/react/index.d.cts +74 -2
- package/dist/react/index.d.ts +74 -2
- package/dist/react/index.js +2 -2
- package/dist/ui/index.cjs +129 -54
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +12 -1
- package/dist/ui/index.d.ts +12 -1
- package/dist/ui/index.js +126 -51
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-JPUKXFR4.js.map +0 -1
- package/dist/chunk-ZYLHGNIG.cjs.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4PL7TK42_cjs = require('../chunk-4PL7TK42.cjs');
|
|
4
4
|
var chunkJO4BHPAD_cjs = require('../chunk-JO4BHPAD.cjs');
|
|
5
5
|
var chunk5EGBIQYS_cjs = require('../chunk-5EGBIQYS.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkGW5ZZHJ7_cjs = require('../chunk-GW5ZZHJ7.cjs');
|
|
7
7
|
var chunk7GWEW2DU_cjs = require('../chunk-7GWEW2DU.cjs');
|
|
8
8
|
require('../chunk-JGPDQDY4.cjs');
|
|
9
9
|
require('../chunk-BJYA5NDL.cjs');
|
|
@@ -4333,7 +4333,8 @@ function FloatingActions({
|
|
|
4333
4333
|
role,
|
|
4334
4334
|
align = "left",
|
|
4335
4335
|
onEdit,
|
|
4336
|
-
className
|
|
4336
|
+
className,
|
|
4337
|
+
copyContent
|
|
4337
4338
|
}) {
|
|
4338
4339
|
const ctx = useMessageActionsContext();
|
|
4339
4340
|
const [copiedId, setCopiedId] = React19__namespace.useState(null);
|
|
@@ -4351,6 +4352,9 @@ function FloatingActions({
|
|
|
4351
4352
|
),
|
|
4352
4353
|
children: actions.map((action) => {
|
|
4353
4354
|
const isHidden = typeof action.hidden === "function" ? action.hidden({ message }) : action.hidden;
|
|
4355
|
+
if (action.id === "copy" && copyContent != null && !copyContent.trim())
|
|
4356
|
+
return null;
|
|
4357
|
+
if (action.id === "copy" && copyContent === null) return null;
|
|
4354
4358
|
if (isHidden) return null;
|
|
4355
4359
|
const isCopied = copiedId === action.id;
|
|
4356
4360
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4373,7 +4377,8 @@ function FloatingActions({
|
|
|
4373
4377
|
return;
|
|
4374
4378
|
}
|
|
4375
4379
|
if (action.id === "copy") {
|
|
4376
|
-
|
|
4380
|
+
const text = copyContent !== void 0 ? copyContent ?? "" : message.content ?? "";
|
|
4381
|
+
navigator.clipboard.writeText(text);
|
|
4377
4382
|
setCopiedId("copy");
|
|
4378
4383
|
setTimeout(() => setCopiedId(null), 1500);
|
|
4379
4384
|
return;
|
|
@@ -4753,18 +4758,30 @@ function DefaultMessage({
|
|
|
4753
4758
|
isLastMessage && isProcessing && !completedTools?.length && !pendingApprovalTools?.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-muted px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(chunk5EGBIQYS_cjs.Loader, { variant: "dots", size: "sm" }) }) : (
|
|
4754
4759
|
/* Show streaming loader when loading with no content and no tools */
|
|
4755
4760
|
isLastMessage && isLoading && !cleanContent?.trim() && !toolsWithCustomRender?.length && !toolsWithoutCustomRender?.length && !pendingApprovalTools?.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-muted px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(chunk5EGBIQYS_cjs.Loader, { variant: loaderVariant, size: "sm" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
4756
|
-
cleanContent?.trim() && /* @__PURE__ */ jsxRuntime.
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4761
|
+
cleanContent?.trim() && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
4762
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4763
|
+
MessageContent,
|
|
4764
|
+
{
|
|
4765
|
+
className: chunk5EGBIQYS_cjs.cn(
|
|
4766
|
+
"csdk-message-assistant rounded-lg px-4 py-2 bg-muted",
|
|
4767
|
+
assistantMessageClassName
|
|
4768
|
+
),
|
|
4769
|
+
markdown: true,
|
|
4770
|
+
size,
|
|
4771
|
+
children: cleanContent
|
|
4772
|
+
}
|
|
4773
|
+
),
|
|
4774
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4775
|
+
FloatingActions,
|
|
4776
|
+
{
|
|
4777
|
+
message,
|
|
4778
|
+
role: "assistant",
|
|
4779
|
+
align: "right",
|
|
4780
|
+
className: "absolute bottom-1 right-1",
|
|
4781
|
+
copyContent: cleanContent
|
|
4782
|
+
}
|
|
4783
|
+
)
|
|
4784
|
+
] }),
|
|
4768
4785
|
toolsWithCustomRender && toolsWithCustomRender.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunk5EGBIQYS_cjs.cn("space-y-2", cleanContent?.trim() && "mt-2"), children: toolsWithCustomRender.map((exec) => {
|
|
4769
4786
|
const toolDef = registeredTools?.find(
|
|
4770
4787
|
(t) => t.name === exec.name
|
|
@@ -4952,15 +4969,6 @@ function DefaultMessage({
|
|
|
4952
4969
|
className: followUpClassName,
|
|
4953
4970
|
buttonClassName: followUpButtonClassName
|
|
4954
4971
|
}
|
|
4955
|
-
),
|
|
4956
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4957
|
-
FloatingActions,
|
|
4958
|
-
{
|
|
4959
|
-
message,
|
|
4960
|
-
role: "assistant",
|
|
4961
|
-
align: "right",
|
|
4962
|
-
className: "absolute bottom-1 right-1"
|
|
4963
|
-
}
|
|
4964
4972
|
)
|
|
4965
4973
|
] })
|
|
4966
4974
|
)
|
|
@@ -5979,6 +5987,7 @@ function ChatComponent({
|
|
|
5979
5987
|
currentThreadId,
|
|
5980
5988
|
onSwitchThread,
|
|
5981
5989
|
isThreadBusy,
|
|
5990
|
+
busyThreadIds,
|
|
5982
5991
|
// Branching
|
|
5983
5992
|
getBranchInfo,
|
|
5984
5993
|
onSwitchBranch,
|
|
@@ -6220,7 +6229,8 @@ function ChatComponent({
|
|
|
6220
6229
|
currentThreadId,
|
|
6221
6230
|
onSwitchThread,
|
|
6222
6231
|
onDeleteThread,
|
|
6223
|
-
isThreadBusy
|
|
6232
|
+
isThreadBusy,
|
|
6233
|
+
busyThreadIds
|
|
6224
6234
|
}),
|
|
6225
6235
|
[
|
|
6226
6236
|
view,
|
|
@@ -6236,7 +6246,8 @@ function ChatComponent({
|
|
|
6236
6246
|
currentThreadId,
|
|
6237
6247
|
onSwitchThread,
|
|
6238
6248
|
onDeleteThread,
|
|
6239
|
-
isThreadBusy
|
|
6249
|
+
isThreadBusy,
|
|
6250
|
+
busyThreadIds
|
|
6240
6251
|
]
|
|
6241
6252
|
);
|
|
6242
6253
|
return /* @__PURE__ */ jsxRuntime.jsx(MessageActionsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(CopilotChatContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -6895,7 +6906,7 @@ function useInternalThreadManager(config = {}) {
|
|
|
6895
6906
|
} = config;
|
|
6896
6907
|
const [state, dispatch] = React19.useReducer(threadReducer, INITIAL_STATE);
|
|
6897
6908
|
const isLoadingRef = React19.useRef(false);
|
|
6898
|
-
const threadManager =
|
|
6909
|
+
const threadManager = chunk4PL7TK42_cjs.useThreadManager({
|
|
6899
6910
|
adapter,
|
|
6900
6911
|
saveDebounce,
|
|
6901
6912
|
autoRestoreLastThread
|
|
@@ -6916,8 +6927,12 @@ function useInternalThreadManager(config = {}) {
|
|
|
6916
6927
|
getAllMessages,
|
|
6917
6928
|
switchBranch,
|
|
6918
6929
|
threadId: sdkThreadId,
|
|
6919
|
-
setActiveThread
|
|
6920
|
-
|
|
6930
|
+
setActiveThread,
|
|
6931
|
+
concurrentThreads,
|
|
6932
|
+
busyThreadIds,
|
|
6933
|
+
assignLocalThreadId,
|
|
6934
|
+
sessionStatus
|
|
6935
|
+
} = chunkGW5ZZHJ7_cjs.useCopilot();
|
|
6921
6936
|
React19.useEffect(() => {
|
|
6922
6937
|
if (!enabled || state.initialized || !currentThread) return;
|
|
6923
6938
|
dispatch({ type: "RESTORE_START" });
|
|
@@ -6925,8 +6940,16 @@ function useInternalThreadManager(config = {}) {
|
|
|
6925
6940
|
if (currentThread.messages && currentThread.messages.length > 0) {
|
|
6926
6941
|
const uiMessages = currentThread.messages.map(coreToUI);
|
|
6927
6942
|
const snapshot = getMessageSnapshot(uiMessages);
|
|
6928
|
-
|
|
6929
|
-
|
|
6943
|
+
if (concurrentThreads) {
|
|
6944
|
+
setActiveThread(currentThread.id, {
|
|
6945
|
+
hydrateMessages: uiMessages,
|
|
6946
|
+
hydrateActiveLeafId: currentThread.activeLeafId
|
|
6947
|
+
});
|
|
6948
|
+
} else {
|
|
6949
|
+
setMessages(uiMessages);
|
|
6950
|
+
if (currentThread.activeLeafId)
|
|
6951
|
+
switchBranch(currentThread.activeLeafId);
|
|
6952
|
+
}
|
|
6930
6953
|
onThreadChange?.(currentThread.id);
|
|
6931
6954
|
dispatch({
|
|
6932
6955
|
type: "RESTORE_COMPLETE",
|
|
@@ -6934,6 +6957,9 @@ function useInternalThreadManager(config = {}) {
|
|
|
6934
6957
|
snapshot
|
|
6935
6958
|
});
|
|
6936
6959
|
} else {
|
|
6960
|
+
if (concurrentThreads) {
|
|
6961
|
+
setActiveThread(currentThread.id);
|
|
6962
|
+
}
|
|
6937
6963
|
onThreadChange?.(currentThread.id);
|
|
6938
6964
|
dispatch({
|
|
6939
6965
|
type: "RESTORE_COMPLETE",
|
|
@@ -6950,7 +6976,9 @@ function useInternalThreadManager(config = {}) {
|
|
|
6950
6976
|
state.initialized,
|
|
6951
6977
|
setMessages,
|
|
6952
6978
|
switchBranch,
|
|
6953
|
-
onThreadChange
|
|
6979
|
+
onThreadChange,
|
|
6980
|
+
concurrentThreads,
|
|
6981
|
+
setActiveThread
|
|
6954
6982
|
]);
|
|
6955
6983
|
React19.useEffect(() => {
|
|
6956
6984
|
if (!enabled) {
|
|
@@ -6965,11 +6993,24 @@ function useInternalThreadManager(config = {}) {
|
|
|
6965
6993
|
if (!enabled) return;
|
|
6966
6994
|
if (state.phase !== "idle") return;
|
|
6967
6995
|
if (isLoadingRef.current) return;
|
|
6968
|
-
if (status === "streaming" || status === "submitted") return;
|
|
6969
6996
|
if (messages.length === 0) return;
|
|
6970
6997
|
if (currentThreadId) return;
|
|
6998
|
+
const streaming = status === "streaming" || status === "submitted";
|
|
6999
|
+
if (streaming && !concurrentThreads) return;
|
|
7000
|
+
if (concurrentThreads && sessionStatus === "creating" && !sdkThreadId) {
|
|
7001
|
+
return;
|
|
7002
|
+
}
|
|
6971
7003
|
dispatch({ type: "FIRST_RESPONSE_COMPLETE" });
|
|
6972
|
-
}, [
|
|
7004
|
+
}, [
|
|
7005
|
+
enabled,
|
|
7006
|
+
state.phase,
|
|
7007
|
+
status,
|
|
7008
|
+
messages.length,
|
|
7009
|
+
currentThreadId,
|
|
7010
|
+
concurrentThreads,
|
|
7011
|
+
sdkThreadId,
|
|
7012
|
+
sessionStatus
|
|
7013
|
+
]);
|
|
6973
7014
|
React19.useEffect(() => {
|
|
6974
7015
|
if (state.phase !== "awaiting_server_id") return;
|
|
6975
7016
|
if (sdkThreadId) {
|
|
@@ -6986,11 +7027,15 @@ function useInternalThreadManager(config = {}) {
|
|
|
6986
7027
|
);
|
|
6987
7028
|
const activeLeafId = messages[messages.length - 1]?.id;
|
|
6988
7029
|
const snapshot = getMessageSnapshot(messages);
|
|
7030
|
+
const usingLocalId = !sdkThreadId;
|
|
6989
7031
|
createThread({
|
|
6990
7032
|
id: sdkThreadId ?? void 0,
|
|
6991
7033
|
messages: coreMessages,
|
|
6992
7034
|
activeLeafId
|
|
6993
7035
|
}).then((thread) => {
|
|
7036
|
+
if (concurrentThreads && usingLocalId) {
|
|
7037
|
+
assignLocalThreadId(thread.id);
|
|
7038
|
+
}
|
|
6994
7039
|
dispatch({ type: "THREAD_CREATED", threadId: thread.id, snapshot });
|
|
6995
7040
|
onThreadChange?.(thread.id);
|
|
6996
7041
|
});
|
|
@@ -7027,41 +7072,62 @@ function useInternalThreadManager(config = {}) {
|
|
|
7027
7072
|
dispatch({ type: "START_SWITCH" });
|
|
7028
7073
|
isLoadingRef.current = true;
|
|
7029
7074
|
const thread = await switchThread(threadId);
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7075
|
+
const uiMessages = thread?.messages ? thread.messages.map(coreToUI) : [];
|
|
7076
|
+
const snapshot = thread?.messages ? getMessageSnapshot(uiMessages) : "";
|
|
7077
|
+
if (concurrentThreads) {
|
|
7078
|
+
setActiveThread(threadId, {
|
|
7079
|
+
hydrateMessages: uiMessages,
|
|
7080
|
+
hydrateActiveLeafId: thread?.activeLeafId
|
|
7081
|
+
});
|
|
7037
7082
|
} else {
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7083
|
+
if (thread?.messages) {
|
|
7084
|
+
setMessages(uiMessages);
|
|
7085
|
+
if (thread.activeLeafId) switchBranch(thread.activeLeafId);
|
|
7086
|
+
} else {
|
|
7087
|
+
setMessages([]);
|
|
7088
|
+
}
|
|
7041
7089
|
}
|
|
7090
|
+
onThreadChange?.(threadId);
|
|
7091
|
+
dispatch({ type: "SWITCH_COMPLETE", threadId, snapshot });
|
|
7042
7092
|
requestAnimationFrame(() => {
|
|
7043
7093
|
isLoadingRef.current = false;
|
|
7044
7094
|
});
|
|
7045
7095
|
},
|
|
7046
|
-
[
|
|
7096
|
+
[
|
|
7097
|
+
switchThread,
|
|
7098
|
+
setMessages,
|
|
7099
|
+
switchBranch,
|
|
7100
|
+
onThreadChange,
|
|
7101
|
+
concurrentThreads,
|
|
7102
|
+
setActiveThread
|
|
7103
|
+
]
|
|
7047
7104
|
);
|
|
7048
7105
|
const handleNewThread = React19.useCallback(async () => {
|
|
7049
7106
|
isLoadingRef.current = true;
|
|
7050
7107
|
clearCurrentThread();
|
|
7051
|
-
|
|
7108
|
+
if (!concurrentThreads) {
|
|
7109
|
+
setMessages([]);
|
|
7110
|
+
}
|
|
7052
7111
|
setActiveThread(null);
|
|
7053
7112
|
onThreadChange?.(null);
|
|
7054
7113
|
dispatch({ type: "NEW_THREAD" });
|
|
7055
7114
|
requestAnimationFrame(() => {
|
|
7056
7115
|
isLoadingRef.current = false;
|
|
7057
7116
|
});
|
|
7058
|
-
}, [
|
|
7059
|
-
|
|
7117
|
+
}, [
|
|
7118
|
+
clearCurrentThread,
|
|
7119
|
+
setMessages,
|
|
7120
|
+
setActiveThread,
|
|
7121
|
+
onThreadChange,
|
|
7122
|
+
concurrentThreads
|
|
7123
|
+
]);
|
|
7124
|
+
const isBusy = !concurrentThreads && (isLoading || status === "streaming" || status === "submitted");
|
|
7060
7125
|
return {
|
|
7061
7126
|
threadManager,
|
|
7062
7127
|
handleSwitchThread,
|
|
7063
7128
|
handleNewThread,
|
|
7064
|
-
isBusy
|
|
7129
|
+
isBusy,
|
|
7130
|
+
busyThreadIds
|
|
7065
7131
|
};
|
|
7066
7132
|
}
|
|
7067
7133
|
function parsePersistenceConfig(persistence, onThreadChange) {
|
|
@@ -7146,8 +7212,9 @@ function CopilotChatBase(props) {
|
|
|
7146
7212
|
switchBranch,
|
|
7147
7213
|
getBranchInfo,
|
|
7148
7214
|
editMessage,
|
|
7149
|
-
error: chatError
|
|
7150
|
-
|
|
7215
|
+
error: chatError,
|
|
7216
|
+
disposeThreadInstance
|
|
7217
|
+
} = chunkGW5ZZHJ7_cjs.useCopilot();
|
|
7151
7218
|
const toolExecutions = rawToolExecutions.map(
|
|
7152
7219
|
(exec) => ({
|
|
7153
7220
|
id: exec.id,
|
|
@@ -7299,16 +7366,23 @@ function CopilotChatBase(props) {
|
|
|
7299
7366
|
suggestions: classNames.suggestions,
|
|
7300
7367
|
footer: classNames.footer
|
|
7301
7368
|
} : void 0;
|
|
7302
|
-
const {
|
|
7369
|
+
const {
|
|
7370
|
+
threadManager,
|
|
7371
|
+
handleSwitchThread,
|
|
7372
|
+
handleNewThread,
|
|
7373
|
+
isBusy,
|
|
7374
|
+
busyThreadIds
|
|
7375
|
+
} = threadManagerResult;
|
|
7303
7376
|
const handleDeleteThread = React19__namespace.default.useCallback(
|
|
7304
7377
|
(threadId) => {
|
|
7305
7378
|
const isCurrentThread = threadManager.currentThreadId === threadId;
|
|
7379
|
+
disposeThreadInstance(threadId);
|
|
7306
7380
|
threadManager.deleteThread(threadId);
|
|
7307
7381
|
if (isCurrentThread) {
|
|
7308
7382
|
handleNewThread();
|
|
7309
7383
|
}
|
|
7310
7384
|
},
|
|
7311
|
-
[threadManager, handleNewThread]
|
|
7385
|
+
[threadManager, handleNewThread, disposeThreadInstance]
|
|
7312
7386
|
);
|
|
7313
7387
|
const threadPickerElement = isPersistenceEnabled && showThreadPicker ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7314
7388
|
ThreadPicker,
|
|
@@ -7358,6 +7432,7 @@ function CopilotChatBase(props) {
|
|
|
7358
7432
|
currentThreadId: threadManager.currentThreadId,
|
|
7359
7433
|
onSwitchThread: isPersistenceEnabled ? handleSwitchThread : void 0,
|
|
7360
7434
|
isThreadBusy: isBusy,
|
|
7435
|
+
busyThreadIds,
|
|
7361
7436
|
getBranchInfo,
|
|
7362
7437
|
onSwitchBranch: switchBranch,
|
|
7363
7438
|
onEditMessage: allowEdit ? editMessage : void 0,
|