@chat-lab/ui 0.1.0-beta.84 → 0.1.0-beta.85
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/adk/components/Debug/Events/EventDetail.cjs +43 -0
- package/dist/adk/components/Debug/Events/EventDetail.cjs.map +1 -0
- package/dist/adk/components/Debug/Events/EventDetail.d.ts +8 -0
- package/dist/adk/components/Debug/Events/EventDetail.d.ts.map +1 -0
- package/dist/adk/components/Debug/Events/EventDetail.js +41 -0
- package/dist/adk/components/Debug/Events/EventDetail.js.map +1 -0
- package/dist/adk/components/Debug/Events/EventTab.d.ts +4 -0
- package/dist/adk/components/Debug/Events/EventTab.d.ts.map +1 -0
- package/dist/adk/components/Debug/Events/MessageEndPlugin.cjs +19 -0
- package/dist/adk/components/Debug/Events/MessageEndPlugin.cjs.map +1 -0
- package/dist/adk/components/Debug/Events/MessageEndPlugin.d.ts +11 -0
- package/dist/adk/components/Debug/Events/MessageEndPlugin.d.ts.map +1 -0
- package/dist/adk/components/Debug/Events/MessageEndPlugin.js +17 -0
- package/dist/adk/components/Debug/Events/MessageEndPlugin.js.map +1 -0
- package/dist/adk/components/Debug/Events/index.cjs +63 -0
- package/dist/adk/components/Debug/Events/index.cjs.map +1 -0
- package/dist/adk/components/Debug/Events/index.d.ts +4 -0
- package/dist/adk/components/Debug/Events/index.d.ts.map +1 -0
- package/dist/adk/components/Debug/Events/index.js +61 -0
- package/dist/adk/components/Debug/Events/index.js.map +1 -0
- package/dist/adk/components/Debug/Events/types.d.ts +5 -0
- package/dist/adk/components/Debug/Events/types.d.ts.map +1 -0
- package/dist/adk/components/Debug/Events/useADKEventHooks.cjs +34 -0
- package/dist/adk/components/Debug/Events/useADKEventHooks.cjs.map +1 -0
- package/dist/adk/components/Debug/Events/useADKEventHooks.d.ts +9 -0
- package/dist/adk/components/Debug/Events/useADKEventHooks.d.ts.map +1 -0
- package/dist/adk/components/Debug/Events/useADKEventHooks.js +32 -0
- package/dist/adk/components/Debug/Events/useADKEventHooks.js.map +1 -0
- package/dist/adk/components/Debug/index.cjs +17 -0
- package/dist/adk/components/Debug/index.cjs.map +1 -0
- package/dist/adk/components/Debug/index.d.ts +7 -0
- package/dist/adk/components/Debug/index.d.ts.map +1 -0
- package/dist/adk/components/Debug/index.js +15 -0
- package/dist/adk/components/Debug/index.js.map +1 -0
- package/dist/assets/Empty.cjs +12 -0
- package/dist/assets/Empty.cjs.map +1 -0
- package/dist/assets/Empty.js +10 -0
- package/dist/assets/Empty.js.map +1 -0
- package/dist/components/assistant-ui/markdown-text.cjs +3 -3
- package/dist/components/assistant-ui/markdown-text.cjs.map +1 -1
- package/dist/components/assistant-ui/markdown-text.js +3 -3
- package/dist/components/assistant-ui/markdown-text.js.map +1 -1
- package/dist/components/ui/tabs.cjs +40 -0
- package/dist/components/ui/tabs.cjs.map +1 -0
- package/dist/components/ui/tabs.js +15 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/core/dist/index.cjs +36 -15
- package/dist/core/dist/index.cjs.map +1 -1
- package/dist/core/dist/index.js +36 -15
- package/dist/core/dist/index.js.map +1 -1
- package/dist/index.css +2 -2
- package/package.json +1 -1
package/dist/core/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { last, isNil, throttle, keys, compact, findLastIndex } from 'lodash-es';
|
|
2
2
|
import { v4 } from 'uuid';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
3
4
|
import { proxy } from 'valtio';
|
|
4
5
|
export { snapshot, subscribe, useSnapshot } from 'valtio';
|
|
5
|
-
import dayjs from 'dayjs';
|
|
6
6
|
import { DefaultAgentCardResolver, ClientFactory, ClientFactoryOptions } from '@a2a-js/sdk/client';
|
|
7
7
|
import { proxy as proxy$1 } from 'valtio/vanilla';
|
|
8
8
|
import mitt from 'mitt';
|
|
@@ -46,15 +46,14 @@ var MessageStatus = /* @__PURE__ */ ((MessageStatus2) => {
|
|
|
46
46
|
MessageStatus2["ABORTED"] = "aborted";
|
|
47
47
|
return MessageStatus2;
|
|
48
48
|
})(MessageStatus || {});
|
|
49
|
-
|
|
50
|
-
// src/utils/Message.ts
|
|
51
49
|
function generateModelMessage(message) {
|
|
52
50
|
return {
|
|
53
51
|
id: v4(),
|
|
54
52
|
role: "assistant",
|
|
55
53
|
status: "sending" /* SENDING */,
|
|
56
54
|
content: [],
|
|
57
|
-
createdAt:
|
|
55
|
+
createdAt: dayjs().unix(),
|
|
56
|
+
updatedAt: dayjs().unix(),
|
|
58
57
|
metadata: {},
|
|
59
58
|
...message
|
|
60
59
|
};
|
|
@@ -884,15 +883,33 @@ function getHostUrl(fullUrl) {
|
|
|
884
883
|
return "";
|
|
885
884
|
}
|
|
886
885
|
}
|
|
886
|
+
function getQueryString(fullUrl) {
|
|
887
|
+
if (!fullUrl) return "";
|
|
888
|
+
try {
|
|
889
|
+
const urlObj = new URL(fullUrl);
|
|
890
|
+
return urlObj.search;
|
|
891
|
+
} catch (error) {
|
|
892
|
+
return "";
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
function buildSessionUrl(api, appName, userId, sessionId) {
|
|
896
|
+
const hostUrl = getHostUrl(api);
|
|
897
|
+
const queryString = getQueryString(api);
|
|
898
|
+
const baseUrl = `${hostUrl}/apps/${appName}/users/${userId}/sessions/${sessionId}`;
|
|
899
|
+
return queryString ? `${baseUrl}${queryString}` : baseUrl;
|
|
900
|
+
}
|
|
887
901
|
var AdkCompletion = async (params) => {
|
|
888
902
|
try {
|
|
889
903
|
await completion(params);
|
|
890
904
|
} catch (error) {
|
|
891
905
|
if (error instanceof SSEError && error.message === '{"detail":"Session not found"}') {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
906
|
+
const url = buildSessionUrl(
|
|
907
|
+
params.requestOptions.api,
|
|
908
|
+
params.requestOptions.data?.appName,
|
|
909
|
+
params.requestOptions.data?.userId,
|
|
910
|
+
params.requestOptions.data?.sessionId
|
|
895
911
|
);
|
|
912
|
+
await fetch(url, { method: "post", headers: params.requestOptions.headers });
|
|
896
913
|
await completion(params);
|
|
897
914
|
return;
|
|
898
915
|
}
|
|
@@ -1414,7 +1431,7 @@ var LocalStorage = class {
|
|
|
1414
1431
|
}
|
|
1415
1432
|
};
|
|
1416
1433
|
var pluginName = "ADKPlugin";
|
|
1417
|
-
function
|
|
1434
|
+
function buildSessionUrl2(api, appName, userId, sessionId) {
|
|
1418
1435
|
const apiUrlObj = new URL(api);
|
|
1419
1436
|
const baseUrl = `${apiUrlObj.origin}/apps/${appName}/users/${userId}/sessions/${sessionId}`;
|
|
1420
1437
|
const queryString = apiUrlObj.search;
|
|
@@ -1483,7 +1500,7 @@ var AdkPlugin = class extends ChatkitPlugin {
|
|
|
1483
1500
|
};
|
|
1484
1501
|
let res;
|
|
1485
1502
|
try {
|
|
1486
|
-
const url =
|
|
1503
|
+
const url = buildSessionUrl2(
|
|
1487
1504
|
requestOptions.api,
|
|
1488
1505
|
this.options.appName,
|
|
1489
1506
|
this.options.userId,
|
|
@@ -1569,7 +1586,7 @@ var AdkPlugin = class extends ChatkitPlugin {
|
|
|
1569
1586
|
);
|
|
1570
1587
|
return thread;
|
|
1571
1588
|
}
|
|
1572
|
-
const url =
|
|
1589
|
+
const url = buildSessionUrl2(
|
|
1573
1590
|
requestOptions.api,
|
|
1574
1591
|
this.options.appName,
|
|
1575
1592
|
this.options.userId,
|
|
@@ -1671,7 +1688,7 @@ var AdkPlugin = class extends ChatkitPlugin {
|
|
|
1671
1688
|
}
|
|
1672
1689
|
const threadId = thread.id;
|
|
1673
1690
|
const requestOptions = this.chatController?.getRequestOptions();
|
|
1674
|
-
const url =
|
|
1691
|
+
const url = buildSessionUrl2(
|
|
1675
1692
|
requestOptions.api,
|
|
1676
1693
|
this.options.appName,
|
|
1677
1694
|
this.options.userId,
|
|
@@ -1787,7 +1804,7 @@ async function fetchChatCompletion({
|
|
|
1787
1804
|
...currentMessage,
|
|
1788
1805
|
status: "error" /* ERROR */,
|
|
1789
1806
|
sending: false,
|
|
1790
|
-
endedAt:
|
|
1807
|
+
endedAt: dayjs().unix(),
|
|
1791
1808
|
error: {
|
|
1792
1809
|
message: error.message || "\u672A\u77E5\u9519\u8BEF",
|
|
1793
1810
|
extra: error.stack
|
|
@@ -1802,7 +1819,9 @@ async function fetchChatCompletion({
|
|
|
1802
1819
|
id: currentMessage.id,
|
|
1803
1820
|
threadId: currentMessage.threadId,
|
|
1804
1821
|
status: currentMessage.status !== "error" /* ERROR */ ? "success" /* SUCCESS */ : "error" /* ERROR */,
|
|
1805
|
-
|
|
1822
|
+
updatedAt: dayjs().unix(),
|
|
1823
|
+
endedAt: dayjs().unix(),
|
|
1824
|
+
sending: false
|
|
1806
1825
|
});
|
|
1807
1826
|
} catch (error) {
|
|
1808
1827
|
console.log(error);
|
|
@@ -2114,7 +2133,8 @@ var ChatController = class {
|
|
|
2114
2133
|
});
|
|
2115
2134
|
if (userMessage) storeManager.addMessage(threadId, userMessage);
|
|
2116
2135
|
assistantMessage = assistantMessageFromProps || generateModelMessage({
|
|
2117
|
-
threadId
|
|
2136
|
+
threadId,
|
|
2137
|
+
sending: true
|
|
2118
2138
|
});
|
|
2119
2139
|
if (!assistantMessageFromProps) {
|
|
2120
2140
|
if (override) {
|
|
@@ -2150,8 +2170,9 @@ var ChatController = class {
|
|
|
2150
2170
|
updatedMessage = updatedMessageOrFactory;
|
|
2151
2171
|
}
|
|
2152
2172
|
if (updatedMessage.status === "pending" /* PENDING */ && !updatedMessage.createdAt) {
|
|
2153
|
-
updatedMessage.createdAt =
|
|
2173
|
+
updatedMessage.createdAt = dayjs().unix();
|
|
2154
2174
|
}
|
|
2175
|
+
updatedMessage.updatedAt = dayjs().unix();
|
|
2155
2176
|
storeManager.updateMessage(threadId, updatedMessage.id, {
|
|
2156
2177
|
updatedMessage,
|
|
2157
2178
|
partial: true
|