@ottocode/web-sdk 0.1.227 → 0.1.230
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/components/chat/ChatInput.d.ts.map +1 -1
- package/dist/components/chat/ChatInputContainer.d.ts.map +1 -1
- package/dist/components/chat/ConfigModal.d.ts.map +1 -1
- package/dist/components/chat/ConfigSelector.d.ts.map +1 -1
- package/dist/components/index.js +6140 -5413
- package/dist/components/index.js.map +35 -33
- package/dist/components/messages/ActionToolBox.d.ts +8 -0
- package/dist/components/messages/ActionToolBox.d.ts.map +1 -0
- package/dist/components/messages/AssistantMessageGroup.d.ts.map +1 -1
- package/dist/components/messages/CompactActivityGroup.d.ts.map +1 -1
- package/dist/components/messages/MessageThread.d.ts.map +1 -1
- package/dist/components/messages/compactActivity.d.ts +1 -0
- package/dist/components/messages/compactActivity.d.ts.map +1 -1
- package/dist/components/research/ResearchSidebar.d.ts.map +1 -1
- package/dist/components/session-files/SessionFilesSidebar.d.ts.map +1 -1
- package/dist/components/sessions/SessionHeader.d.ts.map +1 -1
- package/dist/components/sessions/SessionItem.d.ts.map +1 -1
- package/dist/components/sessions/SessionListContainer.d.ts.map +1 -1
- package/dist/components/sessions/session-time.d.ts +9 -0
- package/dist/components/sessions/session-time.d.ts.map +1 -0
- package/dist/components/settings/SettingsSidebar.d.ts.map +1 -1
- package/dist/hooks/index.js +227 -51
- package/dist/hooks/index.js.map +11 -11
- package/dist/hooks/useConfig.d.ts +3 -0
- package/dist/hooks/useConfig.d.ts.map +1 -1
- package/dist/hooks/useMessages.d.ts +6 -1
- package/dist/hooks/useMessages.d.ts.map +1 -1
- package/dist/hooks/usePreferences.d.ts +1 -0
- package/dist/hooks/usePreferences.d.ts.map +1 -1
- package/dist/hooks/useProviderUsage.d.ts.map +1 -1
- package/dist/hooks/useResearch.d.ts +1 -1
- package/dist/hooks/useResearch.d.ts.map +1 -1
- package/dist/hooks/useSessionFiles.d.ts +1 -1
- package/dist/hooks/useSessionFiles.d.ts.map +1 -1
- package/dist/hooks/useSessionStream.d.ts +1 -1
- package/dist/hooks/useSessionStream.d.ts.map +1 -1
- package/dist/index.js +6153 -5426
- package/dist/index.js.map +35 -33
- package/dist/lib/api-client/config.d.ts +3 -0
- package/dist/lib/api-client/config.d.ts.map +1 -1
- package/dist/lib/api-client/index.d.ts +3 -0
- package/dist/lib/api-client/index.d.ts.map +1 -1
- package/dist/lib/api-client/utils.d.ts.map +1 -1
- package/dist/lib/index.js +11 -2
- package/dist/lib/index.js.map +4 -4
- package/dist/types/api.d.ts +2 -0
- package/dist/types/api.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MessagePart } from '../../types/api';
|
|
2
|
+
interface ActionToolBoxProps {
|
|
3
|
+
part: MessagePart;
|
|
4
|
+
showLine: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function ActionToolBox({ part, showLine }: ActionToolBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=ActionToolBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionToolBox.d.ts","sourceRoot":"","sources":["../../../src/components/messages/ActionToolBox.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAmInD,UAAU,kBAAkB;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CA4PnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantMessageGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/AssistantMessageGroup.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"AssistantMessageGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/AssistantMessageGroup.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAe5D,UAAU,0BAA0B;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,uBAAuB,EAAE,OAAO,CAAC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAiCD,eAAO,MAAM,qBAAqB,kEAugBjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactActivityGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/CompactActivityGroup.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,oBAAoB,EAEzB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"CompactActivityGroup.d.ts","sourceRoot":"","sources":["../../../src/components/messages/CompactActivityGroup.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,oBAAoB,EAEzB,MAAM,mBAAmB,CAAC;AAM3B,UAAU,yBAAyB;IAClC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,EACpC,OAAO,EACP,aAAa,EACb,QAAQ,EACR,SAAS,GACT,EAAE,yBAAyB,2CAiP3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageThread.d.ts","sourceRoot":"","sources":["../../../src/components/messages/MessageThread.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageThread.d.ts","sourceRoot":"","sources":["../../../src/components/messages/MessageThread.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAWxD,UAAU,kBAAkB;IAC3B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,aAAa,0DA+WxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactActivity.d.ts","sourceRoot":"","sources":["../../../src/components/messages/compactActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkBnD,UAAU,oBAAoB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,UAAU,sBAAsB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAoFD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUhE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,WAAW,GACf,oBAAoB,GAAG,IAAI,CAqG7B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,WAAW,EAAE,GAClB,oBAAoB,EAAE,CA2BxB;AA2CD;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,oBAAoB,EAAE,GAC7B,sBAAsB,CAoGxB;AAED,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"compactActivity.d.ts","sourceRoot":"","sources":["../../../src/components/messages/compactActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkBnD,UAAU,oBAAoB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,UAAU,sBAAsB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAoFD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAUhE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,WAAW,GACf,oBAAoB,GAAG,IAAI,CAqG7B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,WAAW,EAAE,GAClB,oBAAoB,EAAE,CA2BxB;AA2CD;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,oBAAoB,EAAE,GAC7B,sBAAsB,CAoGxB;AAED,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResearchSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/research/ResearchSidebar.tsx"],"names":[],"mappings":"AA0CA,UAAU,oBAAoB;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"ResearchSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/research/ResearchSidebar.tsx"],"names":[],"mappings":"AA0CA,UAAU,oBAAoB;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,eAAe,4DAsmB1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionFilesSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/session-files/SessionFilesSidebar.tsx"],"names":[],"mappings":"AAqBA,UAAU,wBAAwB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA0GD,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"SessionFilesSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/session-files/SessionFilesSidebar.tsx"],"names":[],"mappings":"AAqBA,UAAU,wBAAwB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA0GD,eAAO,MAAM,mBAAmB,gEAiG9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionHeader.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"SessionHeader.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAiB/C,UAAU,kBAAkB;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,aAAa,CAAC,EAC7B,OAAO,EACP,mBAAmB,GACnB,EAAE,kBAAkB,2CAkLpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,UAAU,gBAAgB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,wDAyCtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionListContainer.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionListContainer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SessionListContainer.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/SessionListContainer.tsx"],"names":[],"mappings":"AAOA,UAAU,yBAAyB;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,oBAAoB,iEAsL/B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a timestamp into a compact relative label for session metadata.
|
|
3
|
+
*/
|
|
4
|
+
export declare function formatRelativeSessionTime(timestamp: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a date bucket label for grouping recent sessions in the sidebar.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSessionGroupLabel(timestamp: number): string;
|
|
9
|
+
//# sourceMappingURL=session-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-time.d.ts","sourceRoot":"","sources":["../../../src/components/sessions/session-time.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAqBnE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAc9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/settings/SettingsSidebar.tsx"],"names":[],"mappings":"AAkLA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"SettingsSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/settings/SettingsSidebar.tsx"],"names":[],"mappings":"AAkLA,eAAO,MAAM,eAAe,8CAuQ1B,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -44,6 +44,12 @@ var config = {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// src/lib/api-client/utils.ts
|
|
47
|
+
function getClientAdapter() {
|
|
48
|
+
if (typeof window !== "undefined" && typeof window.fetch === "function") {
|
|
49
|
+
return "fetch";
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
47
53
|
function extractErrorMessage(error) {
|
|
48
54
|
if (!error)
|
|
49
55
|
return "Unknown error";
|
|
@@ -71,7 +77,10 @@ function extractErrorMessage(error) {
|
|
|
71
77
|
function configureApiClient() {
|
|
72
78
|
const win = window;
|
|
73
79
|
const baseURL = win.OTTO_SERVER_URL || API_BASE_URL;
|
|
74
|
-
client.setConfig({
|
|
80
|
+
client.setConfig({
|
|
81
|
+
baseURL,
|
|
82
|
+
adapter: getClientAdapter()
|
|
83
|
+
});
|
|
75
84
|
}
|
|
76
85
|
configureApiClient();
|
|
77
86
|
function getBaseUrl() {
|
|
@@ -925,7 +934,8 @@ import { useCallback, useMemo, useSyncExternalStore } from "react";
|
|
|
925
934
|
var STORAGE_KEY = "otto-preferences";
|
|
926
935
|
var DEFAULT_PREFERENCES = {
|
|
927
936
|
vimMode: false,
|
|
928
|
-
compactThread: true
|
|
937
|
+
compactThread: true,
|
|
938
|
+
fullWidthContent: false
|
|
929
939
|
};
|
|
930
940
|
function resolveInitialPreferences() {
|
|
931
941
|
if (typeof window === "undefined") {
|
|
@@ -1624,7 +1634,8 @@ function useDeleteSession() {
|
|
|
1624
1634
|
}
|
|
1625
1635
|
|
|
1626
1636
|
// src/hooks/useMessages.ts
|
|
1627
|
-
function useMessages(sessionId) {
|
|
1637
|
+
function useMessages(sessionId, options = {}) {
|
|
1638
|
+
const { enabled = true, staleTime = 15000 } = options;
|
|
1628
1639
|
return useQuery4({
|
|
1629
1640
|
queryKey: ["messages", sessionId],
|
|
1630
1641
|
queryFn: () => {
|
|
@@ -1633,7 +1644,9 @@ function useMessages(sessionId) {
|
|
|
1633
1644
|
}
|
|
1634
1645
|
return apiClient.getMessages(sessionId);
|
|
1635
1646
|
},
|
|
1636
|
-
enabled: !!sessionId
|
|
1647
|
+
enabled: !!sessionId && enabled,
|
|
1648
|
+
staleTime,
|
|
1649
|
+
refetchOnWindowFocus: false
|
|
1637
1650
|
});
|
|
1638
1651
|
}
|
|
1639
1652
|
function useSendMessage(sessionId) {
|
|
@@ -1778,11 +1791,10 @@ var useToolApprovalStore = create9((set) => ({
|
|
|
1778
1791
|
}));
|
|
1779
1792
|
|
|
1780
1793
|
// src/hooks/useSessionStream.ts
|
|
1781
|
-
function useSessionStream(sessionId) {
|
|
1794
|
+
function useSessionStream(sessionId, enabled = true) {
|
|
1782
1795
|
const queryClient = useQueryClient5();
|
|
1783
1796
|
const clientRef = useRef(null);
|
|
1784
1797
|
const assistantMessageIdRef = useRef(null);
|
|
1785
|
-
const lastInvalidationRef = useRef(0);
|
|
1786
1798
|
const {
|
|
1787
1799
|
addPendingApproval,
|
|
1788
1800
|
removePendingApproval,
|
|
@@ -1790,8 +1802,7 @@ function useSessionStream(sessionId) {
|
|
|
1790
1802
|
setPendingApprovals
|
|
1791
1803
|
} = useToolApprovalStore();
|
|
1792
1804
|
useEffect(() => {
|
|
1793
|
-
if (!sessionId) {
|
|
1794
|
-
console.log("[useSessionStream] No sessionId, skipping");
|
|
1805
|
+
if (!sessionId || !enabled) {
|
|
1795
1806
|
return;
|
|
1796
1807
|
}
|
|
1797
1808
|
assistantMessageIdRef.current = null;
|
|
@@ -1838,6 +1849,27 @@ function useSessionStream(sessionId) {
|
|
|
1838
1849
|
}
|
|
1839
1850
|
return "";
|
|
1840
1851
|
};
|
|
1852
|
+
const getToolEventCallId = (payload) => {
|
|
1853
|
+
if (typeof payload?.callId === "string")
|
|
1854
|
+
return payload.callId;
|
|
1855
|
+
return typeof payload?.toolCallId === "string" ? payload.toolCallId : null;
|
|
1856
|
+
};
|
|
1857
|
+
const getToolEventName = (payload) => {
|
|
1858
|
+
if (typeof payload?.name === "string")
|
|
1859
|
+
return payload.name;
|
|
1860
|
+
return typeof payload?.toolName === "string" ? payload.toolName : null;
|
|
1861
|
+
};
|
|
1862
|
+
const getToolEventArgs = (payload) => payload?.args ?? payload?.input;
|
|
1863
|
+
const getToolInputDelta = (payload) => {
|
|
1864
|
+
if (typeof payload?.delta === "string")
|
|
1865
|
+
return payload.delta;
|
|
1866
|
+
return typeof payload?.inputTextDelta === "string" ? payload.inputTextDelta : null;
|
|
1867
|
+
};
|
|
1868
|
+
const getToolOutputDelta = (payload) => {
|
|
1869
|
+
if (typeof payload?.delta === "string")
|
|
1870
|
+
return payload.delta;
|
|
1871
|
+
return typeof payload?.outputTextDelta === "string" ? payload.outputTextDelta : null;
|
|
1872
|
+
};
|
|
1841
1873
|
const getOptimisticPartIndex = (parts, stepIndex) => {
|
|
1842
1874
|
if (typeof stepIndex !== "number") {
|
|
1843
1875
|
return parts.length;
|
|
@@ -1970,8 +2002,8 @@ function useSessionStream(sessionId) {
|
|
|
1970
2002
|
const upsertEphemeralToolCall = (payload) => {
|
|
1971
2003
|
if (!payload)
|
|
1972
2004
|
return;
|
|
1973
|
-
const callId =
|
|
1974
|
-
const name =
|
|
2005
|
+
const callId = getToolEventCallId(payload);
|
|
2006
|
+
const name = getToolEventName(payload);
|
|
1975
2007
|
if (!name)
|
|
1976
2008
|
return;
|
|
1977
2009
|
queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
|
|
@@ -1995,7 +2027,7 @@ function useSessionStream(sessionId) {
|
|
|
1995
2027
|
if (partIndex === -1 && !callId) {
|
|
1996
2028
|
partIndex = parts.findIndex((part) => part.ephemeral && part.toolName === name);
|
|
1997
2029
|
}
|
|
1998
|
-
const args = payload
|
|
2030
|
+
const args = getToolEventArgs(payload);
|
|
1999
2031
|
const stepIndex = typeof payload.stepIndex === "number" ? payload.stepIndex : null;
|
|
2000
2032
|
const contentJsonBase = { name };
|
|
2001
2033
|
if (callId)
|
|
@@ -2045,15 +2077,161 @@ function useSessionStream(sessionId) {
|
|
|
2045
2077
|
return nextMessages;
|
|
2046
2078
|
});
|
|
2047
2079
|
};
|
|
2080
|
+
const accumulateToolInputDelta = (payload, delta) => {
|
|
2081
|
+
if (!payload)
|
|
2082
|
+
return;
|
|
2083
|
+
const callId = getToolEventCallId(payload);
|
|
2084
|
+
const name = getToolEventName(payload);
|
|
2085
|
+
if (!name)
|
|
2086
|
+
return;
|
|
2087
|
+
queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
|
|
2088
|
+
if (!oldMessages)
|
|
2089
|
+
return oldMessages;
|
|
2090
|
+
const nextMessages = [...oldMessages];
|
|
2091
|
+
let targetIndex = resolveAssistantTargetIndex(nextMessages);
|
|
2092
|
+
if (typeof payload.messageId === "string") {
|
|
2093
|
+
const explicitIndex = nextMessages.findIndex((message) => message.id === payload.messageId);
|
|
2094
|
+
if (explicitIndex !== -1)
|
|
2095
|
+
targetIndex = explicitIndex;
|
|
2096
|
+
}
|
|
2097
|
+
if (targetIndex === -1)
|
|
2098
|
+
return oldMessages;
|
|
2099
|
+
const targetMessage = nextMessages[targetIndex];
|
|
2100
|
+
const parts = targetMessage.parts ? [...targetMessage.parts] : [];
|
|
2101
|
+
let partIndex = -1;
|
|
2102
|
+
if (callId) {
|
|
2103
|
+
partIndex = parts.findIndex((part) => part.toolCallId === callId && part.ephemeral);
|
|
2104
|
+
}
|
|
2105
|
+
if (partIndex === -1 && !callId) {
|
|
2106
|
+
partIndex = parts.findIndex((part) => part.ephemeral && part.toolName === name);
|
|
2107
|
+
}
|
|
2108
|
+
const stepIndex = typeof payload.stepIndex === "number" ? payload.stepIndex : null;
|
|
2109
|
+
if (partIndex === -1) {
|
|
2110
|
+
const contentJsonBase = {
|
|
2111
|
+
name,
|
|
2112
|
+
_streamedInput: delta
|
|
2113
|
+
};
|
|
2114
|
+
if (callId)
|
|
2115
|
+
contentJsonBase.callId = callId;
|
|
2116
|
+
const newPart = {
|
|
2117
|
+
id: callId ? `ephemeral-tool-call-${callId}` : `ephemeral-tool-call-${name}-${Date.now()}`,
|
|
2118
|
+
messageId: targetMessage.id,
|
|
2119
|
+
index: getOptimisticPartIndex(parts, stepIndex),
|
|
2120
|
+
stepIndex,
|
|
2121
|
+
type: "tool_call",
|
|
2122
|
+
content: JSON.stringify(contentJsonBase),
|
|
2123
|
+
contentJson: contentJsonBase,
|
|
2124
|
+
agent: targetMessage.agent,
|
|
2125
|
+
provider: targetMessage.provider,
|
|
2126
|
+
model: targetMessage.model,
|
|
2127
|
+
startedAt: Date.now(),
|
|
2128
|
+
completedAt: null,
|
|
2129
|
+
toolName: name,
|
|
2130
|
+
toolCallId: callId,
|
|
2131
|
+
toolDurationMs: null,
|
|
2132
|
+
ephemeral: true
|
|
2133
|
+
};
|
|
2134
|
+
parts.push(newPart);
|
|
2135
|
+
} else {
|
|
2136
|
+
const existing = parts[partIndex];
|
|
2137
|
+
const prev = typeof existing.contentJson?._streamedInput === "string" ? existing.contentJson._streamedInput : "";
|
|
2138
|
+
const nextContentJson = {
|
|
2139
|
+
...typeof existing.contentJson === "object" && !Array.isArray(existing.contentJson) ? existing.contentJson : {},
|
|
2140
|
+
_streamedInput: prev + delta
|
|
2141
|
+
};
|
|
2142
|
+
parts[partIndex] = {
|
|
2143
|
+
...existing,
|
|
2144
|
+
content: JSON.stringify(nextContentJson),
|
|
2145
|
+
contentJson: nextContentJson,
|
|
2146
|
+
stepIndex: stepIndex ?? existing.stepIndex ?? null
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
nextMessages[targetIndex] = { ...targetMessage, parts };
|
|
2150
|
+
return nextMessages;
|
|
2151
|
+
});
|
|
2152
|
+
};
|
|
2153
|
+
const accumulateToolOutputDelta = (payload, delta) => {
|
|
2154
|
+
if (!payload)
|
|
2155
|
+
return;
|
|
2156
|
+
const callId = getToolEventCallId(payload);
|
|
2157
|
+
const name = getToolEventName(payload);
|
|
2158
|
+
if (!name)
|
|
2159
|
+
return;
|
|
2160
|
+
queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
|
|
2161
|
+
if (!oldMessages)
|
|
2162
|
+
return oldMessages;
|
|
2163
|
+
const nextMessages = [...oldMessages];
|
|
2164
|
+
let targetIndex = resolveAssistantTargetIndex(nextMessages);
|
|
2165
|
+
if (typeof payload.messageId === "string") {
|
|
2166
|
+
const explicitIndex = nextMessages.findIndex((message) => message.id === payload.messageId);
|
|
2167
|
+
if (explicitIndex !== -1)
|
|
2168
|
+
targetIndex = explicitIndex;
|
|
2169
|
+
}
|
|
2170
|
+
if (targetIndex === -1)
|
|
2171
|
+
return oldMessages;
|
|
2172
|
+
const targetMessage = nextMessages[targetIndex];
|
|
2173
|
+
const parts = targetMessage.parts ? [...targetMessage.parts] : [];
|
|
2174
|
+
let partIndex = -1;
|
|
2175
|
+
if (callId) {
|
|
2176
|
+
partIndex = parts.findIndex((part) => part.toolCallId === callId && part.ephemeral);
|
|
2177
|
+
}
|
|
2178
|
+
if (partIndex === -1 && !callId) {
|
|
2179
|
+
partIndex = parts.findIndex((part) => part.ephemeral && part.toolName === name);
|
|
2180
|
+
}
|
|
2181
|
+
const stepIndex = typeof payload.stepIndex === "number" ? payload.stepIndex : null;
|
|
2182
|
+
if (partIndex === -1) {
|
|
2183
|
+
const contentJsonBase = {
|
|
2184
|
+
name,
|
|
2185
|
+
_streamedOutput: delta
|
|
2186
|
+
};
|
|
2187
|
+
if (callId)
|
|
2188
|
+
contentJsonBase.callId = callId;
|
|
2189
|
+
const newPart = {
|
|
2190
|
+
id: callId ? `ephemeral-tool-call-${callId}` : `ephemeral-tool-call-${name}-${Date.now()}`,
|
|
2191
|
+
messageId: targetMessage.id,
|
|
2192
|
+
index: getOptimisticPartIndex(parts, stepIndex),
|
|
2193
|
+
stepIndex,
|
|
2194
|
+
type: "tool_call",
|
|
2195
|
+
content: JSON.stringify(contentJsonBase),
|
|
2196
|
+
contentJson: contentJsonBase,
|
|
2197
|
+
agent: targetMessage.agent,
|
|
2198
|
+
provider: targetMessage.provider,
|
|
2199
|
+
model: targetMessage.model,
|
|
2200
|
+
startedAt: Date.now(),
|
|
2201
|
+
completedAt: null,
|
|
2202
|
+
toolName: name,
|
|
2203
|
+
toolCallId: callId,
|
|
2204
|
+
toolDurationMs: null,
|
|
2205
|
+
ephemeral: true
|
|
2206
|
+
};
|
|
2207
|
+
parts.push(newPart);
|
|
2208
|
+
} else {
|
|
2209
|
+
const existing = parts[partIndex];
|
|
2210
|
+
const prev = typeof existing.contentJson?._streamedOutput === "string" ? existing.contentJson._streamedOutput : "";
|
|
2211
|
+
const nextContentJson = {
|
|
2212
|
+
...typeof existing.contentJson === "object" && !Array.isArray(existing.contentJson) ? existing.contentJson : {},
|
|
2213
|
+
_streamedOutput: prev + delta
|
|
2214
|
+
};
|
|
2215
|
+
parts[partIndex] = {
|
|
2216
|
+
...existing,
|
|
2217
|
+
content: JSON.stringify(nextContentJson),
|
|
2218
|
+
contentJson: nextContentJson,
|
|
2219
|
+
stepIndex: stepIndex ?? existing.stepIndex ?? null
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
nextMessages[targetIndex] = { ...targetMessage, parts };
|
|
2223
|
+
return nextMessages;
|
|
2224
|
+
});
|
|
2225
|
+
};
|
|
2048
2226
|
const resolveEphemeralToolCall = (payload) => {
|
|
2049
|
-
const callId =
|
|
2227
|
+
const callId = getToolEventCallId(payload);
|
|
2050
2228
|
if (!callId)
|
|
2051
2229
|
return;
|
|
2052
|
-
const payloadName =
|
|
2230
|
+
const payloadName = getToolEventName(payload);
|
|
2053
2231
|
const payloadStepIndex = typeof payload?.stepIndex === "number" ? payload.stepIndex : null;
|
|
2054
2232
|
const payloadResult = payload?.result;
|
|
2055
2233
|
const payloadArtifact = payload?.artifact;
|
|
2056
|
-
const payloadArgs = payload
|
|
2234
|
+
const payloadArgs = getToolEventArgs(payload);
|
|
2057
2235
|
queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
|
|
2058
2236
|
if (!oldMessages)
|
|
2059
2237
|
return oldMessages;
|
|
@@ -2101,7 +2279,7 @@ function useSessionStream(sessionId) {
|
|
|
2101
2279
|
});
|
|
2102
2280
|
};
|
|
2103
2281
|
const removeEphemeralToolCall = (payload) => {
|
|
2104
|
-
const callId =
|
|
2282
|
+
const callId = getToolEventCallId(payload);
|
|
2105
2283
|
if (!callId)
|
|
2106
2284
|
return;
|
|
2107
2285
|
queryClient.setQueryData(["messages", sessionId], (oldMessages) => {
|
|
@@ -2160,20 +2338,6 @@ function useSessionStream(sessionId) {
|
|
|
2160
2338
|
return nextMessages;
|
|
2161
2339
|
});
|
|
2162
2340
|
};
|
|
2163
|
-
const throttledInvalidate = () => {
|
|
2164
|
-
const now = Date.now();
|
|
2165
|
-
if (now - lastInvalidationRef.current < 500) {
|
|
2166
|
-
return;
|
|
2167
|
-
}
|
|
2168
|
-
lastInvalidationRef.current = now;
|
|
2169
|
-
queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
|
|
2170
|
-
};
|
|
2171
|
-
const invalidatingEvents = new Set([
|
|
2172
|
-
"message.completed",
|
|
2173
|
-
"message.updated",
|
|
2174
|
-
"finish-step",
|
|
2175
|
-
"error"
|
|
2176
|
-
]);
|
|
2177
2341
|
const unsubscribe = client2.on("*", (event) => {
|
|
2178
2342
|
const payload = event.payload;
|
|
2179
2343
|
switch (event.type) {
|
|
@@ -2213,7 +2377,6 @@ function useSessionStream(sessionId) {
|
|
|
2213
2377
|
next.sort((a, b) => a.createdAt - b.createdAt);
|
|
2214
2378
|
return next;
|
|
2215
2379
|
});
|
|
2216
|
-
throttledInvalidate();
|
|
2217
2380
|
}
|
|
2218
2381
|
break;
|
|
2219
2382
|
}
|
|
@@ -2232,13 +2395,21 @@ function useSessionStream(sessionId) {
|
|
|
2232
2395
|
}
|
|
2233
2396
|
markMessageCompleted(payload);
|
|
2234
2397
|
clearEphemeralForMessage(id);
|
|
2398
|
+
queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
|
|
2235
2399
|
queryClient.invalidateQueries({ queryKey: sessionsQueryKey });
|
|
2236
2400
|
break;
|
|
2237
2401
|
}
|
|
2238
2402
|
case "tool.delta": {
|
|
2239
2403
|
const channel = typeof payload?.channel === "string" ? payload.channel : null;
|
|
2240
|
-
|
|
2241
|
-
|
|
2404
|
+
const delta = channel === "output" ? getToolOutputDelta(payload) : getToolInputDelta(payload);
|
|
2405
|
+
if (channel === "input" || channel == null && delta) {
|
|
2406
|
+
if (delta) {
|
|
2407
|
+
accumulateToolInputDelta(payload, delta);
|
|
2408
|
+
} else {
|
|
2409
|
+
upsertEphemeralToolCall(payload);
|
|
2410
|
+
}
|
|
2411
|
+
} else if (channel === "output" && delta) {
|
|
2412
|
+
accumulateToolOutputDelta(payload, delta);
|
|
2242
2413
|
}
|
|
2243
2414
|
break;
|
|
2244
2415
|
}
|
|
@@ -2287,6 +2458,7 @@ function useSessionStream(sessionId) {
|
|
|
2287
2458
|
if (messageId) {
|
|
2288
2459
|
clearEphemeralForMessage(messageId);
|
|
2289
2460
|
}
|
|
2461
|
+
queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
|
|
2290
2462
|
break;
|
|
2291
2463
|
}
|
|
2292
2464
|
case "message.updated": {
|
|
@@ -2321,9 +2493,6 @@ function useSessionStream(sessionId) {
|
|
|
2321
2493
|
default:
|
|
2322
2494
|
break;
|
|
2323
2495
|
}
|
|
2324
|
-
if (invalidatingEvents.has(event.type)) {
|
|
2325
|
-
throttledInvalidate();
|
|
2326
|
-
}
|
|
2327
2496
|
if (event.type === "finish-step") {
|
|
2328
2497
|
const now = Date.now();
|
|
2329
2498
|
if (now - lastSessionInvalidation >= 2000) {
|
|
@@ -2341,6 +2510,7 @@ function useSessionStream(sessionId) {
|
|
|
2341
2510
|
queryClient,
|
|
2342
2511
|
addPendingApproval,
|
|
2343
2512
|
removePendingApproval,
|
|
2513
|
+
enabled,
|
|
2344
2514
|
setPendingApprovals,
|
|
2345
2515
|
updatePendingApproval
|
|
2346
2516
|
]);
|
|
@@ -3231,13 +3401,13 @@ function useFileUpload(options = {}) {
|
|
|
3231
3401
|
}
|
|
3232
3402
|
// src/hooks/useSessionFiles.ts
|
|
3233
3403
|
import { useQuery as useQuery5 } from "@tanstack/react-query";
|
|
3234
|
-
function useSessionFiles(sessionId) {
|
|
3404
|
+
function useSessionFiles(sessionId, enabled = true) {
|
|
3235
3405
|
const isExpanded = useSessionFilesStore((state) => state.isExpanded);
|
|
3236
3406
|
return useQuery5({
|
|
3237
3407
|
queryKey: ["session", sessionId, "files"],
|
|
3238
3408
|
queryFn: () => sessionId ? apiClient.getSessionFiles(sessionId) : null,
|
|
3239
|
-
enabled: !!sessionId,
|
|
3240
|
-
refetchInterval: isExpanded ? 5000 : false,
|
|
3409
|
+
enabled: !!sessionId && enabled,
|
|
3410
|
+
refetchInterval: isExpanded && enabled ? 5000 : false,
|
|
3241
3411
|
retry: 1,
|
|
3242
3412
|
staleTime: 3000
|
|
3243
3413
|
});
|
|
@@ -3429,11 +3599,11 @@ class ResearchApiClient {
|
|
|
3429
3599
|
}
|
|
3430
3600
|
}
|
|
3431
3601
|
var researchApi = new ResearchApiClient;
|
|
3432
|
-
function useResearchSessions(parentSessionId) {
|
|
3602
|
+
function useResearchSessions(parentSessionId, enabled = true) {
|
|
3433
3603
|
return useQuery8({
|
|
3434
3604
|
queryKey: ["research", "sessions", parentSessionId],
|
|
3435
3605
|
queryFn: () => researchApi.listResearchSessions(parentSessionId),
|
|
3436
|
-
enabled: !!parentSessionId,
|
|
3606
|
+
enabled: !!parentSessionId && enabled,
|
|
3437
3607
|
staleTime: 30000
|
|
3438
3608
|
});
|
|
3439
3609
|
}
|
|
@@ -4386,7 +4556,7 @@ function useTunnelStream() {
|
|
|
4386
4556
|
return { connect };
|
|
4387
4557
|
}
|
|
4388
4558
|
// src/hooks/useProviderUsage.ts
|
|
4389
|
-
import { useEffect as useEffect13, useCallback as useCallback10 } from "react";
|
|
4559
|
+
import { useEffect as useEffect13, useCallback as useCallback10, useRef as useRef6 } from "react";
|
|
4390
4560
|
|
|
4391
4561
|
// src/stores/usageStore.ts
|
|
4392
4562
|
import { create as create18 } from "zustand";
|
|
@@ -4406,16 +4576,22 @@ var useUsageStore = create18((set) => ({
|
|
|
4406
4576
|
// src/hooks/useProviderUsage.ts
|
|
4407
4577
|
var POLL_INTERVAL = 60000;
|
|
4408
4578
|
var STALE_THRESHOLD = 30000;
|
|
4579
|
+
var inflight = new Set;
|
|
4409
4580
|
function useProviderUsage(provider, authType) {
|
|
4410
4581
|
const setUsage = useUsageStore((s) => s.setUsage);
|
|
4411
4582
|
const setLoading = useUsageStore((s) => s.setLoading);
|
|
4412
4583
|
const setLastFetched = useUsageStore((s) => s.setLastFetched);
|
|
4413
4584
|
const usage = useUsageStore((s) => provider ? s.usage[provider] : undefined);
|
|
4414
|
-
const lastFetched = useUsageStore((s) => provider ? s.lastFetched[provider] : 0);
|
|
4415
4585
|
const isOAuthProvider = authType === "oauth" && (provider === "anthropic" || provider === "openai");
|
|
4416
4586
|
const fetchUsage = useCallback10(async () => {
|
|
4417
4587
|
if (!provider || !isOAuthProvider)
|
|
4418
4588
|
return;
|
|
4589
|
+
if (inflight.has(provider))
|
|
4590
|
+
return;
|
|
4591
|
+
const last = useUsageStore.getState().lastFetched[provider] ?? 0;
|
|
4592
|
+
if (last && Date.now() - last < STALE_THRESHOLD)
|
|
4593
|
+
return;
|
|
4594
|
+
inflight.add(provider);
|
|
4419
4595
|
setLoading(provider, true);
|
|
4420
4596
|
try {
|
|
4421
4597
|
const data = await apiClient.getProviderUsage(provider);
|
|
@@ -4423,18 +4599,18 @@ function useProviderUsage(provider, authType) {
|
|
|
4423
4599
|
setLastFetched(provider, Date.now());
|
|
4424
4600
|
} catch {} finally {
|
|
4425
4601
|
setLoading(provider, false);
|
|
4602
|
+
inflight.delete(provider);
|
|
4426
4603
|
}
|
|
4427
4604
|
}, [provider, isOAuthProvider, setUsage, setLoading, setLastFetched]);
|
|
4605
|
+
const fetchRef = useRef6(fetchUsage);
|
|
4606
|
+
fetchRef.current = fetchUsage;
|
|
4428
4607
|
useEffect13(() => {
|
|
4429
4608
|
if (!isOAuthProvider)
|
|
4430
4609
|
return;
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
fetchUsage();
|
|
4434
|
-
}
|
|
4435
|
-
const interval = setInterval(fetchUsage, POLL_INTERVAL);
|
|
4610
|
+
fetchRef.current();
|
|
4611
|
+
const interval = setInterval(() => fetchRef.current(), POLL_INTERVAL);
|
|
4436
4612
|
return () => clearInterval(interval);
|
|
4437
|
-
}, [isOAuthProvider,
|
|
4613
|
+
}, [isOAuthProvider, provider]);
|
|
4438
4614
|
return {
|
|
4439
4615
|
usage,
|
|
4440
4616
|
fetchUsage,
|
|
@@ -4472,7 +4648,7 @@ function useGitDiffFullFile(file, staged = false, enabled = false) {
|
|
|
4472
4648
|
}
|
|
4473
4649
|
// src/hooks/useMCP.ts
|
|
4474
4650
|
import { useQuery as useQuery12, useMutation as useMutation8, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
|
|
4475
|
-
import { useEffect as useEffect14, useRef as
|
|
4651
|
+
import { useEffect as useEffect14, useRef as useRef7, useCallback as useCallback11 } from "react";
|
|
4476
4652
|
import {
|
|
4477
4653
|
listMcpServers,
|
|
4478
4654
|
startMcpServer,
|
|
@@ -4638,7 +4814,7 @@ function useCopilotDevicePoller() {
|
|
|
4638
4814
|
const setCopilotDevice = useMCPStore((s) => s.setCopilotDevice);
|
|
4639
4815
|
const setLoading = useMCPStore((s) => s.setLoading);
|
|
4640
4816
|
const queryClient = useQueryClient10();
|
|
4641
|
-
const timerRef =
|
|
4817
|
+
const timerRef = useRef7(null);
|
|
4642
4818
|
const stopPolling = useCallback11(() => {
|
|
4643
4819
|
if (timerRef.current) {
|
|
4644
4820
|
clearInterval(timerRef.current);
|
|
@@ -4809,4 +4985,4 @@ export {
|
|
|
4809
4985
|
sessionsQueryKey
|
|
4810
4986
|
};
|
|
4811
4987
|
|
|
4812
|
-
//# debugId=
|
|
4988
|
+
//# debugId=8BD673F5FE928A9E64756E2164756E21
|