@ottocode/web-sdk 0.1.305 → 0.1.307
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/agents/agentConstants.d.ts.map +1 -1
- 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/InputSubagentsBar.d.ts +6 -0
- package/dist/components/chat/InputSubagentsBar.d.ts.map +1 -0
- package/dist/components/chat/NewSessionLanding.d.ts.map +1 -1
- package/dist/components/goals/GoalsSidebar.d.ts +6 -0
- package/dist/components/goals/GoalsSidebar.d.ts.map +1 -0
- package/dist/components/goals/GoalsSidebarToggle.d.ts +6 -0
- package/dist/components/goals/GoalsSidebarToggle.d.ts.map +1 -0
- package/dist/components/goals/index.d.ts +3 -0
- package/dist/components/goals/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6735 -5004
- package/dist/components/index.js.map +32 -17
- package/dist/components/messages/GoalStartNotice.d.ts +12 -0
- package/dist/components/messages/GoalStartNotice.d.ts.map +1 -0
- package/dist/components/messages/SubagentResultsNotice.d.ts +21 -0
- package/dist/components/messages/SubagentResultsNotice.d.ts.map +1 -0
- package/dist/components/messages/UserMessageGroup.d.ts.map +1 -1
- package/dist/components/messages/compactActivity.d.ts.map +1 -1
- package/dist/components/messages/renderers/GoalToolRenderer.d.ts +3 -0
- package/dist/components/messages/renderers/GoalToolRenderer.d.ts.map +1 -0
- package/dist/components/messages/renderers/McpManagerRenderer.d.ts +3 -0
- package/dist/components/messages/renderers/McpManagerRenderer.d.ts.map +1 -0
- package/dist/components/messages/renderers/SubagentToolRenderer.d.ts +3 -0
- package/dist/components/messages/renderers/SubagentToolRenderer.d.ts.map +1 -0
- package/dist/components/messages/renderers/index.d.ts.map +1 -1
- package/dist/components/settings/SettingsSidebar.d.ts.map +1 -1
- package/dist/components/subagents/SubagentFloatingViewer.d.ts +6 -0
- package/dist/components/subagents/SubagentFloatingViewer.d.ts.map +1 -0
- package/dist/components/ui/ResizeHandle.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +441 -102
- package/dist/hooks/index.js.map +11 -7
- package/dist/hooks/useAgents.d.ts +2 -1
- package/dist/hooks/useAgents.d.ts.map +1 -1
- package/dist/hooks/useChatComposer.d.ts +56 -0
- package/dist/hooks/useChatComposer.d.ts.map +1 -0
- package/dist/hooks/useConfig.d.ts +4 -0
- package/dist/hooks/useConfig.d.ts.map +1 -1
- package/dist/hooks/useConfigModalControls.d.ts +15 -0
- package/dist/hooks/useConfigModalControls.d.ts.map +1 -0
- package/dist/hooks/useGoals.d.ts +48 -0
- package/dist/hooks/useGoals.d.ts.map +1 -0
- package/dist/hooks/useSessionStream.d.ts.map +1 -1
- package/dist/index.js +6793 -5048
- package/dist/index.js.map +32 -17
- 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/goals.d.ts +70 -0
- package/dist/lib/api-client/goals.d.ts.map +1 -0
- package/dist/lib/api-client/index.d.ts +35 -0
- package/dist/lib/api-client/index.d.ts.map +1 -1
- package/dist/lib/index.js +78 -1
- package/dist/lib/index.js.map +6 -5
- package/dist/stores/goalsPanelStore.d.ts +9 -0
- package/dist/stores/goalsPanelStore.d.ts.map +1 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +61 -9
- package/dist/stores/index.js.map +5 -3
- package/dist/stores/subagentViewerStore.d.ts +15 -0
- package/dist/stores/subagentViewerStore.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/hooks/index.js
CHANGED
|
@@ -758,6 +758,76 @@ var branchesMixin = {
|
|
|
758
758
|
}
|
|
759
759
|
};
|
|
760
760
|
|
|
761
|
+
// src/lib/api-client/goals.ts
|
|
762
|
+
import {
|
|
763
|
+
getSessionGoal as apiGetSessionGoal,
|
|
764
|
+
createSessionGoal as apiCreateSessionGoal,
|
|
765
|
+
updateGoal as apiUpdateGoal,
|
|
766
|
+
addGoalTasks as apiAddGoalTasks,
|
|
767
|
+
updateGoalTask as apiUpdateGoalTask,
|
|
768
|
+
startGoal as apiStartGoal,
|
|
769
|
+
listSessionSubagents as apiListSessionSubagents
|
|
770
|
+
} from "@ottocode/api";
|
|
771
|
+
var goalsMixin = {
|
|
772
|
+
async getSessionGoal(sessionId) {
|
|
773
|
+
const response = await apiGetSessionGoal({ path: { sessionId } });
|
|
774
|
+
if (response.error)
|
|
775
|
+
throw new Error(extractErrorMessage(response.error));
|
|
776
|
+
return response.data;
|
|
777
|
+
},
|
|
778
|
+
async createSessionGoal(sessionId, data) {
|
|
779
|
+
const response = await apiCreateSessionGoal({
|
|
780
|
+
path: { sessionId },
|
|
781
|
+
body: data
|
|
782
|
+
});
|
|
783
|
+
if (response.error)
|
|
784
|
+
throw new Error(extractErrorMessage(response.error));
|
|
785
|
+
return response.data;
|
|
786
|
+
},
|
|
787
|
+
async updateGoal(goalId, data) {
|
|
788
|
+
const response = await apiUpdateGoal({
|
|
789
|
+
path: { goalId },
|
|
790
|
+
body: data
|
|
791
|
+
});
|
|
792
|
+
if (response.error)
|
|
793
|
+
throw new Error(extractErrorMessage(response.error));
|
|
794
|
+
return response.data;
|
|
795
|
+
},
|
|
796
|
+
async addGoalTasks(goalId, tasks) {
|
|
797
|
+
const response = await apiAddGoalTasks({
|
|
798
|
+
path: { goalId },
|
|
799
|
+
body: { tasks }
|
|
800
|
+
});
|
|
801
|
+
if (response.error)
|
|
802
|
+
throw new Error(extractErrorMessage(response.error));
|
|
803
|
+
return response.data;
|
|
804
|
+
},
|
|
805
|
+
async updateGoalTask(goalId, taskId, data) {
|
|
806
|
+
const response = await apiUpdateGoalTask({
|
|
807
|
+
path: { goalId, taskId },
|
|
808
|
+
body: data
|
|
809
|
+
});
|
|
810
|
+
if (response.error)
|
|
811
|
+
throw new Error(extractErrorMessage(response.error));
|
|
812
|
+
return response.data;
|
|
813
|
+
},
|
|
814
|
+
async startGoal(goalId) {
|
|
815
|
+
const response = await apiStartGoal({ path: { goalId } });
|
|
816
|
+
if (response.error)
|
|
817
|
+
throw new Error(extractErrorMessage(response.error));
|
|
818
|
+
return response.data;
|
|
819
|
+
},
|
|
820
|
+
async listSessionSubagents(sessionId, status) {
|
|
821
|
+
const response = await apiListSessionSubagents({
|
|
822
|
+
path: { sessionId },
|
|
823
|
+
query: status ? { status } : undefined
|
|
824
|
+
});
|
|
825
|
+
if (response.error)
|
|
826
|
+
throw new Error(extractErrorMessage(response.error));
|
|
827
|
+
return response.data;
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
|
|
761
831
|
// src/lib/api-client/approval.ts
|
|
762
832
|
import {
|
|
763
833
|
resolveApproval as apiResolveApproval,
|
|
@@ -1313,6 +1383,13 @@ class ApiClient {
|
|
|
1313
1383
|
getShareStatus = branchesMixin.getShareStatus;
|
|
1314
1384
|
shareSession = branchesMixin.shareSession;
|
|
1315
1385
|
syncSession = branchesMixin.syncSession;
|
|
1386
|
+
getSessionGoal = goalsMixin.getSessionGoal;
|
|
1387
|
+
createSessionGoal = goalsMixin.createSessionGoal;
|
|
1388
|
+
updateGoal = goalsMixin.updateGoal;
|
|
1389
|
+
addGoalTasks = goalsMixin.addGoalTasks;
|
|
1390
|
+
updateGoalTask = goalsMixin.updateGoalTask;
|
|
1391
|
+
startGoal = goalsMixin.startGoal;
|
|
1392
|
+
listSessionSubagents = goalsMixin.listSessionSubagents;
|
|
1316
1393
|
approveToolCall = approvalMixin.approveToolCall;
|
|
1317
1394
|
getPendingApprovals = approvalMixin.getPendingApprovals;
|
|
1318
1395
|
submitSecureInput = secureInputMixin.submitSecureInput;
|
|
@@ -4328,6 +4405,8 @@ ${bestEffortUnescapeJsonString(rawTail)}`;
|
|
|
4328
4405
|
}
|
|
4329
4406
|
queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
|
|
4330
4407
|
queryClient.invalidateQueries({ queryKey: sessionsQueryKey });
|
|
4408
|
+
queryClient.invalidateQueries({ queryKey: ["goal", sessionId] });
|
|
4409
|
+
queryClient.invalidateQueries({ queryKey: ["subagents", sessionId] });
|
|
4331
4410
|
break;
|
|
4332
4411
|
}
|
|
4333
4412
|
case "tool.delta": {
|
|
@@ -4455,6 +4534,13 @@ ${bestEffortUnescapeJsonString(rawTail)}`;
|
|
|
4455
4534
|
}
|
|
4456
4535
|
break;
|
|
4457
4536
|
}
|
|
4537
|
+
case "goal.updated": {
|
|
4538
|
+
queryClient.invalidateQueries({ queryKey: ["goal", sessionId] });
|
|
4539
|
+
queryClient.invalidateQueries({
|
|
4540
|
+
queryKey: ["subagents", sessionId]
|
|
4541
|
+
});
|
|
4542
|
+
break;
|
|
4543
|
+
}
|
|
4458
4544
|
case "queue.updated": {
|
|
4459
4545
|
const queueState = normalizeQueueState({
|
|
4460
4546
|
currentMessageId: payload?.currentMessageId,
|
|
@@ -5878,8 +5964,109 @@ function useParentSession(sessionId) {
|
|
|
5878
5964
|
enabled: Boolean(sessionId)
|
|
5879
5965
|
});
|
|
5880
5966
|
}
|
|
5967
|
+
// src/hooks/useGoals.ts
|
|
5968
|
+
import { useMutation as useMutation6, useQuery as useQuery8, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
|
|
5969
|
+
var goalQueryKey = (sessionId) => [
|
|
5970
|
+
"goal",
|
|
5971
|
+
sessionId
|
|
5972
|
+
];
|
|
5973
|
+
var subagentsQueryKey = (sessionId) => [
|
|
5974
|
+
"subagents",
|
|
5975
|
+
sessionId
|
|
5976
|
+
];
|
|
5977
|
+
function useOttoEnabled() {
|
|
5978
|
+
const { data: config2 } = useConfig();
|
|
5979
|
+
return config2?.defaults?.ottoEnabled ?? true;
|
|
5980
|
+
}
|
|
5981
|
+
function useSessionGoal(sessionId) {
|
|
5982
|
+
const ottoEnabled = useOttoEnabled();
|
|
5983
|
+
return useQuery8({
|
|
5984
|
+
queryKey: goalQueryKey(sessionId),
|
|
5985
|
+
queryFn: () => {
|
|
5986
|
+
if (!sessionId)
|
|
5987
|
+
throw new Error("No session ID");
|
|
5988
|
+
return apiClient.getSessionGoal(sessionId);
|
|
5989
|
+
},
|
|
5990
|
+
enabled: Boolean(sessionId) && ottoEnabled,
|
|
5991
|
+
refetchInterval: 15000
|
|
5992
|
+
});
|
|
5993
|
+
}
|
|
5994
|
+
function useCreateSessionGoal(sessionId) {
|
|
5995
|
+
const queryClient = useQueryClient8();
|
|
5996
|
+
return useMutation6({
|
|
5997
|
+
mutationFn: (data) => {
|
|
5998
|
+
if (!sessionId)
|
|
5999
|
+
throw new Error("No session ID");
|
|
6000
|
+
return apiClient.createSessionGoal(sessionId, data);
|
|
6001
|
+
},
|
|
6002
|
+
onSuccess: () => {
|
|
6003
|
+
queryClient.invalidateQueries({ queryKey: goalQueryKey(sessionId) });
|
|
6004
|
+
}
|
|
6005
|
+
});
|
|
6006
|
+
}
|
|
6007
|
+
function useUpdateGoal(sessionId) {
|
|
6008
|
+
const queryClient = useQueryClient8();
|
|
6009
|
+
return useMutation6({
|
|
6010
|
+
mutationFn: (input) => apiClient.updateGoal(input.goalId, {
|
|
6011
|
+
title: input.title,
|
|
6012
|
+
status: input.status
|
|
6013
|
+
}),
|
|
6014
|
+
onSuccess: () => {
|
|
6015
|
+
queryClient.invalidateQueries({ queryKey: goalQueryKey(sessionId) });
|
|
6016
|
+
}
|
|
6017
|
+
});
|
|
6018
|
+
}
|
|
6019
|
+
function useAddGoalTasks(sessionId) {
|
|
6020
|
+
const queryClient = useQueryClient8();
|
|
6021
|
+
return useMutation6({
|
|
6022
|
+
mutationFn: (input) => apiClient.addGoalTasks(input.goalId, input.tasks),
|
|
6023
|
+
onSuccess: () => {
|
|
6024
|
+
queryClient.invalidateQueries({ queryKey: goalQueryKey(sessionId) });
|
|
6025
|
+
}
|
|
6026
|
+
});
|
|
6027
|
+
}
|
|
6028
|
+
function useUpdateGoalTask(sessionId) {
|
|
6029
|
+
const queryClient = useQueryClient8();
|
|
6030
|
+
return useMutation6({
|
|
6031
|
+
mutationFn: (input) => apiClient.updateGoalTask(input.goalId, input.taskId, {
|
|
6032
|
+
content: input.content,
|
|
6033
|
+
status: input.status,
|
|
6034
|
+
note: input.note
|
|
6035
|
+
}),
|
|
6036
|
+
onSuccess: () => {
|
|
6037
|
+
queryClient.invalidateQueries({ queryKey: goalQueryKey(sessionId) });
|
|
6038
|
+
}
|
|
6039
|
+
});
|
|
6040
|
+
}
|
|
6041
|
+
function useSessionSubagents(sessionId, status) {
|
|
6042
|
+
return useQuery8({
|
|
6043
|
+
queryKey: [...subagentsQueryKey(sessionId), status ?? "all"],
|
|
6044
|
+
queryFn: () => {
|
|
6045
|
+
if (!sessionId)
|
|
6046
|
+
throw new Error("No session ID");
|
|
6047
|
+
return apiClient.listSessionSubagents(sessionId, status);
|
|
6048
|
+
},
|
|
6049
|
+
enabled: Boolean(sessionId),
|
|
6050
|
+
refetchInterval: (query) => {
|
|
6051
|
+
const hasRunning = query.state.data?.subagents.some((record) => record.status === "running");
|
|
6052
|
+
return hasRunning ? 5000 : 30000;
|
|
6053
|
+
}
|
|
6054
|
+
});
|
|
6055
|
+
}
|
|
6056
|
+
function useStartGoal(sessionId) {
|
|
6057
|
+
const queryClient = useQueryClient8();
|
|
6058
|
+
return useMutation6({
|
|
6059
|
+
mutationFn: (input) => apiClient.startGoal(input.goalId),
|
|
6060
|
+
onSuccess: () => {
|
|
6061
|
+
queryClient.invalidateQueries({ queryKey: goalQueryKey(sessionId) });
|
|
6062
|
+
if (sessionId) {
|
|
6063
|
+
queryClient.invalidateQueries({ queryKey: ["messages", sessionId] });
|
|
6064
|
+
}
|
|
6065
|
+
}
|
|
6066
|
+
});
|
|
6067
|
+
}
|
|
5881
6068
|
// src/hooks/useResearch.ts
|
|
5882
|
-
import { useQuery as
|
|
6069
|
+
import { useQuery as useQuery9, useMutation as useMutation7, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
|
|
5883
6070
|
import {
|
|
5884
6071
|
createResearchSession as apiCreateResearchSession,
|
|
5885
6072
|
deleteResearchSession as apiDeleteResearchSession,
|
|
@@ -5975,7 +6162,7 @@ class ResearchApiClient {
|
|
|
5975
6162
|
}
|
|
5976
6163
|
var researchApi = new ResearchApiClient;
|
|
5977
6164
|
function useResearchSessions(parentSessionId, enabled = true) {
|
|
5978
|
-
return
|
|
6165
|
+
return useQuery9({
|
|
5979
6166
|
queryKey: ["research", "sessions", parentSessionId],
|
|
5980
6167
|
queryFn: () => researchApi.listResearchSessions(parentSessionId),
|
|
5981
6168
|
enabled: !!parentSessionId && enabled,
|
|
@@ -5983,8 +6170,8 @@ function useResearchSessions(parentSessionId, enabled = true) {
|
|
|
5983
6170
|
});
|
|
5984
6171
|
}
|
|
5985
6172
|
function useCreateResearchSession() {
|
|
5986
|
-
const queryClient =
|
|
5987
|
-
return
|
|
6173
|
+
const queryClient = useQueryClient9();
|
|
6174
|
+
return useMutation7({
|
|
5988
6175
|
mutationFn: ({
|
|
5989
6176
|
parentSessionId,
|
|
5990
6177
|
data
|
|
@@ -5997,8 +6184,8 @@ function useCreateResearchSession() {
|
|
|
5997
6184
|
});
|
|
5998
6185
|
}
|
|
5999
6186
|
function useDeleteResearchSession() {
|
|
6000
|
-
const queryClient =
|
|
6001
|
-
return
|
|
6187
|
+
const queryClient = useQueryClient9();
|
|
6188
|
+
return useMutation7({
|
|
6002
6189
|
mutationFn: (researchId) => researchApi.deleteResearchSession(researchId),
|
|
6003
6190
|
onSuccess: () => {
|
|
6004
6191
|
queryClient.invalidateQueries({ queryKey: ["research", "sessions"] });
|
|
@@ -6007,7 +6194,7 @@ function useDeleteResearchSession() {
|
|
|
6007
6194
|
}
|
|
6008
6195
|
function useInjectContext() {
|
|
6009
6196
|
const addContext = usePendingResearchStore((state) => state.addContext);
|
|
6010
|
-
return
|
|
6197
|
+
return useMutation7({
|
|
6011
6198
|
mutationFn: ({
|
|
6012
6199
|
parentSessionId,
|
|
6013
6200
|
researchSessionId,
|
|
@@ -6024,8 +6211,8 @@ function useInjectContext() {
|
|
|
6024
6211
|
});
|
|
6025
6212
|
}
|
|
6026
6213
|
function useExportToSession() {
|
|
6027
|
-
const queryClient =
|
|
6028
|
-
return
|
|
6214
|
+
const queryClient = useQueryClient9();
|
|
6215
|
+
return useMutation7({
|
|
6029
6216
|
mutationFn: ({
|
|
6030
6217
|
researchId,
|
|
6031
6218
|
data
|
|
@@ -6324,9 +6511,9 @@ function useOttoRouterBalance(providerName) {
|
|
|
6324
6511
|
};
|
|
6325
6512
|
}
|
|
6326
6513
|
// src/hooks/useShareStatus.ts
|
|
6327
|
-
import { useQuery as
|
|
6514
|
+
import { useQuery as useQuery10 } from "@tanstack/react-query";
|
|
6328
6515
|
function useShareStatus(sessionId) {
|
|
6329
|
-
const { data, isLoading, error } =
|
|
6516
|
+
const { data, isLoading, error } = useQuery10({
|
|
6330
6517
|
queryKey: ["share-status", sessionId],
|
|
6331
6518
|
queryFn: () => apiClient.getShareStatus(sessionId),
|
|
6332
6519
|
enabled: !!sessionId,
|
|
@@ -6470,7 +6657,7 @@ function useTopupCallback() {
|
|
|
6470
6657
|
}
|
|
6471
6658
|
// src/hooks/useAuthStatus.ts
|
|
6472
6659
|
import { useEffect as useEffect13, useCallback as useCallback8, useState as useState5, useRef as useRef5 } from "react";
|
|
6473
|
-
import { useQueryClient as
|
|
6660
|
+
import { useQueryClient as useQueryClient10 } from "@tanstack/react-query";
|
|
6474
6661
|
|
|
6475
6662
|
// src/stores/onboardingStore.ts
|
|
6476
6663
|
import { create as create21 } from "zustand";
|
|
@@ -6520,7 +6707,7 @@ function useAuthStatus() {
|
|
|
6520
6707
|
const setError = useOnboardingStore((s) => s.setError);
|
|
6521
6708
|
const authStatus = useOnboardingStore((s) => s.authStatus);
|
|
6522
6709
|
const isOpen = useOnboardingStore((s) => s.isOpen);
|
|
6523
|
-
const queryClient =
|
|
6710
|
+
const queryClient = useQueryClient10();
|
|
6524
6711
|
const [initialized, setInitialized] = useState5(false);
|
|
6525
6712
|
const [oauthPolling, setOauthPolling] = useState5(false);
|
|
6526
6713
|
const oauthPollingRef = useRef5(null);
|
|
@@ -6816,7 +7003,7 @@ function useAuthStatus() {
|
|
|
6816
7003
|
};
|
|
6817
7004
|
}
|
|
6818
7005
|
// src/hooks/useTunnel.ts
|
|
6819
|
-
import { useQuery as
|
|
7006
|
+
import { useQuery as useQuery11, useMutation as useMutation8, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
|
|
6820
7007
|
import { useEffect as useEffect14, useCallback as useCallback9, useRef as useRef6 } from "react";
|
|
6821
7008
|
import {
|
|
6822
7009
|
client as client2,
|
|
@@ -6864,7 +7051,7 @@ function useTunnelStatus() {
|
|
|
6864
7051
|
const setStatus = useTunnelStore((s) => s.setStatus);
|
|
6865
7052
|
const setUrl = useTunnelStore((s) => s.setUrl);
|
|
6866
7053
|
const setError = useTunnelStore((s) => s.setError);
|
|
6867
|
-
const query =
|
|
7054
|
+
const query = useQuery11({
|
|
6868
7055
|
queryKey: ["tunnel", "status"],
|
|
6869
7056
|
queryFn: fetchTunnelStatus,
|
|
6870
7057
|
refetchInterval: 3000,
|
|
@@ -6880,12 +7067,12 @@ function useTunnelStatus() {
|
|
|
6880
7067
|
return query;
|
|
6881
7068
|
}
|
|
6882
7069
|
function useStartTunnel() {
|
|
6883
|
-
const queryClient =
|
|
7070
|
+
const queryClient = useQueryClient11();
|
|
6884
7071
|
const setStatus = useTunnelStore((s) => s.setStatus);
|
|
6885
7072
|
const setUrl = useTunnelStore((s) => s.setUrl);
|
|
6886
7073
|
const setError = useTunnelStore((s) => s.setError);
|
|
6887
7074
|
const setProgress = useTunnelStore((s) => s.setProgress);
|
|
6888
|
-
return
|
|
7075
|
+
return useMutation8({
|
|
6889
7076
|
mutationFn: () => startTunnel(),
|
|
6890
7077
|
onMutate: () => {
|
|
6891
7078
|
setStatus("starting");
|
|
@@ -6914,9 +7101,9 @@ function useStartTunnel() {
|
|
|
6914
7101
|
});
|
|
6915
7102
|
}
|
|
6916
7103
|
function useStopTunnel() {
|
|
6917
|
-
const queryClient =
|
|
7104
|
+
const queryClient = useQueryClient11();
|
|
6918
7105
|
const reset = useTunnelStore((s) => s.reset);
|
|
6919
|
-
return
|
|
7106
|
+
return useMutation8({
|
|
6920
7107
|
mutationFn: stopTunnel,
|
|
6921
7108
|
onSuccess: () => {
|
|
6922
7109
|
reset();
|
|
@@ -6927,7 +7114,7 @@ function useStopTunnel() {
|
|
|
6927
7114
|
function useTunnelQr() {
|
|
6928
7115
|
const url = useTunnelStore((s) => s.url);
|
|
6929
7116
|
const setQrCode = useTunnelStore((s) => s.setQrCode);
|
|
6930
|
-
const query =
|
|
7117
|
+
const query = useQuery11({
|
|
6931
7118
|
queryKey: ["tunnel", "qr", url],
|
|
6932
7119
|
queryFn: fetchTunnelQr,
|
|
6933
7120
|
enabled: !!url
|
|
@@ -7040,9 +7227,9 @@ function useProviderUsage(provider, authType) {
|
|
|
7040
7227
|
};
|
|
7041
7228
|
}
|
|
7042
7229
|
// src/hooks/useFileBrowser.ts
|
|
7043
|
-
import { useQuery as
|
|
7230
|
+
import { useQuery as useQuery12 } from "@tanstack/react-query";
|
|
7044
7231
|
function useFileTree(dirPath, enabled = true) {
|
|
7045
|
-
return
|
|
7232
|
+
return useQuery12({
|
|
7046
7233
|
queryKey: ["files", "tree", dirPath],
|
|
7047
7234
|
queryFn: () => apiClient.getFileTree(dirPath),
|
|
7048
7235
|
enabled,
|
|
@@ -7051,7 +7238,7 @@ function useFileTree(dirPath, enabled = true) {
|
|
|
7051
7238
|
});
|
|
7052
7239
|
}
|
|
7053
7240
|
function useFileContent(filePath) {
|
|
7054
|
-
return
|
|
7241
|
+
return useQuery12({
|
|
7055
7242
|
queryKey: ["files", "read", filePath],
|
|
7056
7243
|
queryFn: () => filePath ? apiClient.readFileContent(filePath) : null,
|
|
7057
7244
|
enabled: !!filePath,
|
|
@@ -7060,7 +7247,7 @@ function useFileContent(filePath) {
|
|
|
7060
7247
|
});
|
|
7061
7248
|
}
|
|
7062
7249
|
function useGitDiffFullFile(file, staged = false, enabled = false) {
|
|
7063
|
-
return
|
|
7250
|
+
return useQuery12({
|
|
7064
7251
|
queryKey: ["git", "diff", "fullFile", file, staged],
|
|
7065
7252
|
queryFn: () => file ? apiClient.getGitDiffFullFile(file, staged) : null,
|
|
7066
7253
|
enabled: enabled && !!file,
|
|
@@ -7069,7 +7256,7 @@ function useGitDiffFullFile(file, staged = false, enabled = false) {
|
|
|
7069
7256
|
});
|
|
7070
7257
|
}
|
|
7071
7258
|
// src/hooks/useMCP.ts
|
|
7072
|
-
import { useQuery as
|
|
7259
|
+
import { useQuery as useQuery13, useMutation as useMutation9, useQueryClient as useQueryClient12 } from "@tanstack/react-query";
|
|
7073
7260
|
import { useEffect as useEffect16, useRef as useRef8, useCallback as useCallback11 } from "react";
|
|
7074
7261
|
import {
|
|
7075
7262
|
listMcpServers,
|
|
@@ -7084,7 +7271,7 @@ import {
|
|
|
7084
7271
|
} from "@ottocode/api";
|
|
7085
7272
|
function useMCPServers() {
|
|
7086
7273
|
const setServers = useMCPStore((s) => s.setServers);
|
|
7087
|
-
const query =
|
|
7274
|
+
const query = useQuery13({
|
|
7088
7275
|
queryKey: ["mcp", "servers"],
|
|
7089
7276
|
queryFn: async () => {
|
|
7090
7277
|
const { data } = await listMcpServers();
|
|
@@ -7100,8 +7287,8 @@ function useMCPServers() {
|
|
|
7100
7287
|
return query;
|
|
7101
7288
|
}
|
|
7102
7289
|
function useStartMCPServer() {
|
|
7103
|
-
const queryClient =
|
|
7104
|
-
return
|
|
7290
|
+
const queryClient = useQueryClient12();
|
|
7291
|
+
return useMutation9({
|
|
7105
7292
|
mutationFn: async (name) => {
|
|
7106
7293
|
const { data, error } = await startMcpServer({
|
|
7107
7294
|
path: { name }
|
|
@@ -7119,9 +7306,9 @@ function useStartMCPServer() {
|
|
|
7119
7306
|
});
|
|
7120
7307
|
}
|
|
7121
7308
|
function useStopMCPServer() {
|
|
7122
|
-
const queryClient =
|
|
7309
|
+
const queryClient = useQueryClient12();
|
|
7123
7310
|
const setLoading = useMCPStore((s) => s.setLoading);
|
|
7124
|
-
return
|
|
7311
|
+
return useMutation9({
|
|
7125
7312
|
mutationFn: async (name) => {
|
|
7126
7313
|
setLoading(name, true);
|
|
7127
7314
|
const { data, error } = await stopMcpServer({
|
|
@@ -7141,8 +7328,8 @@ function useStopMCPServer() {
|
|
|
7141
7328
|
});
|
|
7142
7329
|
}
|
|
7143
7330
|
function useAddMCPServer() {
|
|
7144
|
-
const queryClient =
|
|
7145
|
-
return
|
|
7331
|
+
const queryClient = useQueryClient12();
|
|
7332
|
+
return useMutation9({
|
|
7146
7333
|
mutationFn: async (params) => {
|
|
7147
7334
|
const { data, error } = await addMcpServer({
|
|
7148
7335
|
body: params
|
|
@@ -7160,8 +7347,8 @@ function useAddMCPServer() {
|
|
|
7160
7347
|
});
|
|
7161
7348
|
}
|
|
7162
7349
|
function useRemoveMCPServer() {
|
|
7163
|
-
const queryClient =
|
|
7164
|
-
return
|
|
7350
|
+
const queryClient = useQueryClient12();
|
|
7351
|
+
return useMutation9({
|
|
7165
7352
|
mutationFn: async (name) => {
|
|
7166
7353
|
const { data, error } = await removeMcpServer({
|
|
7167
7354
|
path: { name }
|
|
@@ -7179,8 +7366,8 @@ function useRemoveMCPServer() {
|
|
|
7179
7366
|
});
|
|
7180
7367
|
}
|
|
7181
7368
|
function useAuthenticateMCPServer() {
|
|
7182
|
-
const queryClient =
|
|
7183
|
-
return
|
|
7369
|
+
const queryClient = useQueryClient12();
|
|
7370
|
+
return useMutation9({
|
|
7184
7371
|
mutationFn: async (name) => {
|
|
7185
7372
|
const { data, error } = await initiateMcpAuth({
|
|
7186
7373
|
path: { name }
|
|
@@ -7198,8 +7385,8 @@ function useAuthenticateMCPServer() {
|
|
|
7198
7385
|
});
|
|
7199
7386
|
}
|
|
7200
7387
|
function useRevokeMCPAuth() {
|
|
7201
|
-
const queryClient =
|
|
7202
|
-
return
|
|
7388
|
+
const queryClient = useQueryClient12();
|
|
7389
|
+
return useMutation9({
|
|
7203
7390
|
mutationFn: async (name) => {
|
|
7204
7391
|
const { data, error } = await revokeMcpAuth({
|
|
7205
7392
|
path: { name }
|
|
@@ -7217,7 +7404,7 @@ function useRevokeMCPAuth() {
|
|
|
7217
7404
|
});
|
|
7218
7405
|
}
|
|
7219
7406
|
function useMCPAuthStatus(name) {
|
|
7220
|
-
return
|
|
7407
|
+
return useQuery13({
|
|
7221
7408
|
queryKey: ["mcp", "auth", name],
|
|
7222
7409
|
queryFn: async () => {
|
|
7223
7410
|
if (!name)
|
|
@@ -7235,7 +7422,7 @@ function useCopilotDevicePoller() {
|
|
|
7235
7422
|
const copilotDevice = useMCPStore((s) => s.copilotDevice);
|
|
7236
7423
|
const setCopilotDevice = useMCPStore((s) => s.setCopilotDevice);
|
|
7237
7424
|
const setLoading = useMCPStore((s) => s.setLoading);
|
|
7238
|
-
const queryClient =
|
|
7425
|
+
const queryClient = useQueryClient12();
|
|
7239
7426
|
const timerRef = useRef8(null);
|
|
7240
7427
|
const stopPolling = useCallback11(() => {
|
|
7241
7428
|
if (timerRef.current) {
|
|
@@ -7278,12 +7465,12 @@ function useCopilotDevicePoller() {
|
|
|
7278
7465
|
return copilotDevice;
|
|
7279
7466
|
}
|
|
7280
7467
|
// src/hooks/useSkills.ts
|
|
7281
|
-
import { useMutation as
|
|
7468
|
+
import { useMutation as useMutation10, useQuery as useQuery14, useQueryClient as useQueryClient13 } from "@tanstack/react-query";
|
|
7282
7469
|
import { useEffect as useEffect17 } from "react";
|
|
7283
7470
|
function useSkills(options = {}) {
|
|
7284
7471
|
const enabled = options.enabled ?? true;
|
|
7285
7472
|
const setSkillsConfig = useSkillsStore((s) => s.setSkillsConfig);
|
|
7286
|
-
const query =
|
|
7473
|
+
const query = useQuery14({
|
|
7287
7474
|
queryKey: ["skills"],
|
|
7288
7475
|
queryFn: async () => {
|
|
7289
7476
|
return apiClient.getSkillsConfig();
|
|
@@ -7304,9 +7491,9 @@ function useSkills(options = {}) {
|
|
|
7304
7491
|
return query;
|
|
7305
7492
|
}
|
|
7306
7493
|
function useUpdateSkillsConfig() {
|
|
7307
|
-
const queryClient =
|
|
7494
|
+
const queryClient = useQueryClient13();
|
|
7308
7495
|
const setSkillsConfig = useSkillsStore((s) => s.setSkillsConfig);
|
|
7309
|
-
return
|
|
7496
|
+
return useMutation10({
|
|
7310
7497
|
mutationFn: (input) => apiClient.updateSkillsConfig(input),
|
|
7311
7498
|
onSuccess: (data) => {
|
|
7312
7499
|
setSkillsConfig({
|
|
@@ -7320,7 +7507,7 @@ function useUpdateSkillsConfig() {
|
|
|
7320
7507
|
});
|
|
7321
7508
|
}
|
|
7322
7509
|
function useSkillDetail(name) {
|
|
7323
|
-
return
|
|
7510
|
+
return useQuery14({
|
|
7324
7511
|
queryKey: ["skills", name],
|
|
7325
7512
|
queryFn: async () => {
|
|
7326
7513
|
if (!name)
|
|
@@ -7331,7 +7518,7 @@ function useSkillDetail(name) {
|
|
|
7331
7518
|
});
|
|
7332
7519
|
}
|
|
7333
7520
|
function useSkillFiles(name) {
|
|
7334
|
-
return
|
|
7521
|
+
return useQuery14({
|
|
7335
7522
|
queryKey: ["skills", name, "files"],
|
|
7336
7523
|
queryFn: async () => {
|
|
7337
7524
|
if (!name)
|
|
@@ -7342,7 +7529,7 @@ function useSkillFiles(name) {
|
|
|
7342
7529
|
});
|
|
7343
7530
|
}
|
|
7344
7531
|
function useSkillFileContent(name, filePath) {
|
|
7345
|
-
return
|
|
7532
|
+
return useQuery14({
|
|
7346
7533
|
queryKey: ["skills", name, "files", filePath],
|
|
7347
7534
|
queryFn: async () => {
|
|
7348
7535
|
if (!name || !filePath)
|
|
@@ -7354,7 +7541,7 @@ function useSkillFileContent(name, filePath) {
|
|
|
7354
7541
|
}
|
|
7355
7542
|
// src/hooks/useAgents.ts
|
|
7356
7543
|
import { useEffect as useEffect18 } from "react";
|
|
7357
|
-
import { useMutation as
|
|
7544
|
+
import { useMutation as useMutation11, useQuery as useQuery15, useQueryClient as useQueryClient14 } from "@tanstack/react-query";
|
|
7358
7545
|
|
|
7359
7546
|
// src/stores/agentsStore.ts
|
|
7360
7547
|
import { create as create22 } from "zustand";
|
|
@@ -7429,7 +7616,7 @@ function useAgentDetails(options = {}) {
|
|
|
7429
7616
|
const setAgents = useAgentsStore((s) => s.setAgents);
|
|
7430
7617
|
const selectedAgent = useAgentsStore((s) => s.selectedAgent);
|
|
7431
7618
|
const selectAgent = useAgentsStore((s) => s.selectAgent);
|
|
7432
|
-
const query =
|
|
7619
|
+
const query = useQuery15({
|
|
7433
7620
|
queryKey: ["config", "agents"],
|
|
7434
7621
|
queryFn: () => apiClient.getAgentDetails(),
|
|
7435
7622
|
enabled,
|
|
@@ -7447,7 +7634,7 @@ function useAgentDetails(options = {}) {
|
|
|
7447
7634
|
return query;
|
|
7448
7635
|
}
|
|
7449
7636
|
function useAgent(agentName) {
|
|
7450
|
-
return
|
|
7637
|
+
return useQuery15({
|
|
7451
7638
|
queryKey: ["config", "agents", agentName],
|
|
7452
7639
|
queryFn: async () => {
|
|
7453
7640
|
if (!agentName)
|
|
@@ -7462,7 +7649,7 @@ function useConfigTools(options = {}) {
|
|
|
7462
7649
|
const managerOpen = useAgentsStore((s) => s.isManagerOpen);
|
|
7463
7650
|
const createOpen = useAgentsStore((s) => s.isCreateModalOpen);
|
|
7464
7651
|
const enabled = options.enabled ?? (managerOpen || createOpen);
|
|
7465
|
-
return
|
|
7652
|
+
return useQuery15({
|
|
7466
7653
|
queryKey: ["config", "tools"],
|
|
7467
7654
|
queryFn: () => apiClient.getConfigTools(),
|
|
7468
7655
|
enabled,
|
|
@@ -7470,8 +7657,8 @@ function useConfigTools(options = {}) {
|
|
|
7470
7657
|
});
|
|
7471
7658
|
}
|
|
7472
7659
|
function useUpdateAgent() {
|
|
7473
|
-
const queryClient =
|
|
7474
|
-
return
|
|
7660
|
+
const queryClient = useQueryClient14();
|
|
7661
|
+
return useMutation11({
|
|
7475
7662
|
mutationFn: ({ name, input }) => apiClient.updateAgent(name, input),
|
|
7476
7663
|
onSuccess: (data, variables) => {
|
|
7477
7664
|
queryClient.setQueryData(["config", "agents", variables.name], data);
|
|
@@ -7481,10 +7668,10 @@ function useUpdateAgent() {
|
|
|
7481
7668
|
});
|
|
7482
7669
|
}
|
|
7483
7670
|
function useDeleteAgent() {
|
|
7484
|
-
const queryClient =
|
|
7671
|
+
const queryClient = useQueryClient14();
|
|
7485
7672
|
const setAgents = useAgentsStore((s) => s.setAgents);
|
|
7486
7673
|
const selectAgent = useAgentsStore((s) => s.selectAgent);
|
|
7487
|
-
return
|
|
7674
|
+
return useMutation11({
|
|
7488
7675
|
mutationFn: ({
|
|
7489
7676
|
name,
|
|
7490
7677
|
scope = "local"
|
|
@@ -7505,8 +7692,8 @@ function useDeleteAgent() {
|
|
|
7505
7692
|
});
|
|
7506
7693
|
}
|
|
7507
7694
|
function useSetDefaultAgent() {
|
|
7508
|
-
const queryClient =
|
|
7509
|
-
return
|
|
7695
|
+
const queryClient = useQueryClient14();
|
|
7696
|
+
return useMutation11({
|
|
7510
7697
|
mutationFn: (name) => apiClient.updateDefaults({ agent: name, scope: "global" }),
|
|
7511
7698
|
onSuccess: () => {
|
|
7512
7699
|
queryClient.invalidateQueries({ queryKey: ["config", "agents"] });
|
|
@@ -7522,11 +7709,151 @@ function getAgentToolCount(agent) {
|
|
|
7522
7709
|
...agent.toolConfig.loadable ?? []
|
|
7523
7710
|
])).length;
|
|
7524
7711
|
}
|
|
7712
|
+
// src/hooks/useChatComposer.ts
|
|
7713
|
+
import { useCallback as useCallback12, useEffect as useEffect19, useMemo as useMemo4, useRef as useRef9, useState as useState6 } from "react";
|
|
7714
|
+
function useChatComposer({
|
|
7715
|
+
sessionId,
|
|
7716
|
+
defaultAgent
|
|
7717
|
+
} = {}) {
|
|
7718
|
+
const { data: config2 } = useConfig();
|
|
7719
|
+
const { data: allModels } = useAllModels();
|
|
7720
|
+
const { data: agentDetails } = useAgentDetails({ enabled: true });
|
|
7721
|
+
const session = useSession(sessionId ?? "");
|
|
7722
|
+
const updateSession = useUpdateSession(sessionId ?? "");
|
|
7723
|
+
const [agent, setAgent] = useState6("");
|
|
7724
|
+
const [provider, setProvider] = useState6("");
|
|
7725
|
+
const [model, setModel] = useState6("");
|
|
7726
|
+
const initializedRef = useRef9(false);
|
|
7727
|
+
useEffect19(() => {
|
|
7728
|
+
if (!sessionId || !session)
|
|
7729
|
+
return;
|
|
7730
|
+
setAgent(session.agent);
|
|
7731
|
+
setProvider(session.provider);
|
|
7732
|
+
setModel(session.model);
|
|
7733
|
+
}, [sessionId, session]);
|
|
7734
|
+
useEffect19(() => {
|
|
7735
|
+
if (sessionId || initializedRef.current)
|
|
7736
|
+
return;
|
|
7737
|
+
if (!config2?.defaults || !agentDetails?.agents.length)
|
|
7738
|
+
return;
|
|
7739
|
+
initializedRef.current = true;
|
|
7740
|
+
const initialAgent = defaultAgent || config2.defaults.agent || "general";
|
|
7741
|
+
const selectedAgent = agentDetails.agents.find((agentDetail) => agentDetail.name === initialAgent);
|
|
7742
|
+
setAgent(initialAgent);
|
|
7743
|
+
setProvider(selectedAgent?.provider ?? config2.defaults.provider ?? "");
|
|
7744
|
+
setModel(selectedAgent?.model ?? config2.defaults.model ?? "");
|
|
7745
|
+
}, [sessionId, agentDetails?.agents, config2, defaultAgent]);
|
|
7746
|
+
const agentNames = useMemo4(() => agentDetails?.agents.length ? agentDetails.agents.map((agentDetail) => agentDetail.name) : config2?.agents ?? [], [agentDetails?.agents, config2?.agents]);
|
|
7747
|
+
const selectedModel = useMemo4(() => allModels?.[provider]?.models?.find((m) => m.id === model), [allModels, provider, model]);
|
|
7748
|
+
const persist2 = useCallback12(async (update) => {
|
|
7749
|
+
if (!sessionId)
|
|
7750
|
+
return;
|
|
7751
|
+
try {
|
|
7752
|
+
await updateSession.mutateAsync(update);
|
|
7753
|
+
} catch (error) {
|
|
7754
|
+
console.error("Failed to update session:", error);
|
|
7755
|
+
}
|
|
7756
|
+
}, [sessionId, updateSession]);
|
|
7757
|
+
const handleAgentChange = useCallback12(async (value) => {
|
|
7758
|
+
setAgent(value);
|
|
7759
|
+
const selectedAgent = agentDetails?.agents.find((agentDetail) => agentDetail.name === value);
|
|
7760
|
+
if (!selectedAgent) {
|
|
7761
|
+
await persist2({ agent: value });
|
|
7762
|
+
return;
|
|
7763
|
+
}
|
|
7764
|
+
const nextProvider = selectedAgent.provider ?? config2?.defaults?.provider ?? provider;
|
|
7765
|
+
const nextModel = selectedAgent.model ?? config2?.defaults?.model ?? model;
|
|
7766
|
+
setProvider(nextProvider);
|
|
7767
|
+
setModel(nextModel);
|
|
7768
|
+
await persist2({
|
|
7769
|
+
agent: value,
|
|
7770
|
+
provider: nextProvider,
|
|
7771
|
+
model: nextModel
|
|
7772
|
+
});
|
|
7773
|
+
}, [
|
|
7774
|
+
agentDetails?.agents,
|
|
7775
|
+
config2?.defaults?.model,
|
|
7776
|
+
config2?.defaults?.provider,
|
|
7777
|
+
model,
|
|
7778
|
+
provider,
|
|
7779
|
+
persist2
|
|
7780
|
+
]);
|
|
7781
|
+
const handlePlanModeToggle = useCallback12(async (isPlanMode) => {
|
|
7782
|
+
await handleAgentChange(isPlanMode ? "plan" : "build");
|
|
7783
|
+
}, [handleAgentChange]);
|
|
7784
|
+
const handleModelSelectorChange = useCallback12(async (newProvider, newModel) => {
|
|
7785
|
+
setProvider(newProvider);
|
|
7786
|
+
setModel(newModel);
|
|
7787
|
+
await persist2({ provider: newProvider, model: newModel });
|
|
7788
|
+
}, [persist2]);
|
|
7789
|
+
const handleProviderChange = useCallback12(async (newProvider) => {
|
|
7790
|
+
setProvider(newProvider);
|
|
7791
|
+
if (model) {
|
|
7792
|
+
await persist2({ provider: newProvider, model });
|
|
7793
|
+
}
|
|
7794
|
+
}, [model, persist2]);
|
|
7795
|
+
const handleModelChange = useCallback12(async (newModel) => {
|
|
7796
|
+
setModel(newModel);
|
|
7797
|
+
await persist2({ provider, model: newModel });
|
|
7798
|
+
}, [provider, persist2]);
|
|
7799
|
+
return {
|
|
7800
|
+
config: config2,
|
|
7801
|
+
allModels,
|
|
7802
|
+
agent,
|
|
7803
|
+
provider,
|
|
7804
|
+
model,
|
|
7805
|
+
agentNames,
|
|
7806
|
+
isPlanMode: agent === "plan",
|
|
7807
|
+
modelSupportsReasoning: selectedModel?.reasoningText,
|
|
7808
|
+
modelSupportsVision: selectedModel?.vision,
|
|
7809
|
+
modelSupportsAttachment: selectedModel?.attachment,
|
|
7810
|
+
modelIsFree: selectedModel?.free,
|
|
7811
|
+
providerAuthType: allModels?.[provider]?.authType,
|
|
7812
|
+
isCustomProvider: allModels?.[provider]?.label?.includes("(custom)") ?? false,
|
|
7813
|
+
handleAgentChange,
|
|
7814
|
+
handlePlanModeToggle,
|
|
7815
|
+
handleProviderChange,
|
|
7816
|
+
handleModelChange,
|
|
7817
|
+
handleModelSelectorChange
|
|
7818
|
+
};
|
|
7819
|
+
}
|
|
7820
|
+
// src/hooks/useConfigModalControls.ts
|
|
7821
|
+
import { useCallback as useCallback13, useState as useState7 } from "react";
|
|
7822
|
+
function useConfigModalControls() {
|
|
7823
|
+
const [isConfigOpen, setIsConfigOpen] = useState7(false);
|
|
7824
|
+
const [configFocusTarget, setConfigFocusTarget] = useState7(null);
|
|
7825
|
+
const openConfig = useCallback13((target) => {
|
|
7826
|
+
setConfigFocusTarget(target);
|
|
7827
|
+
setIsConfigOpen(true);
|
|
7828
|
+
}, []);
|
|
7829
|
+
const toggleConfig = useCallback13(() => {
|
|
7830
|
+
setIsConfigOpen((prev) => !prev);
|
|
7831
|
+
}, []);
|
|
7832
|
+
const closeConfig = useCallback13(() => {
|
|
7833
|
+
setIsConfigOpen(false);
|
|
7834
|
+
setConfigFocusTarget(null);
|
|
7835
|
+
}, []);
|
|
7836
|
+
const openModelConfig = useCallback13(() => {
|
|
7837
|
+
openConfig("model");
|
|
7838
|
+
}, [openConfig]);
|
|
7839
|
+
const openAgentConfig = useCallback13(() => {
|
|
7840
|
+
openConfig("agent");
|
|
7841
|
+
}, [openConfig]);
|
|
7842
|
+
return {
|
|
7843
|
+
isConfigOpen,
|
|
7844
|
+
configFocusTarget,
|
|
7845
|
+
openConfig,
|
|
7846
|
+
toggleConfig,
|
|
7847
|
+
closeConfig,
|
|
7848
|
+
openModelConfig,
|
|
7849
|
+
openAgentConfig
|
|
7850
|
+
};
|
|
7851
|
+
}
|
|
7525
7852
|
// src/hooks/useContainerWidth.ts
|
|
7526
|
-
import { useEffect as
|
|
7853
|
+
import { useEffect as useEffect20, useState as useState8 } from "react";
|
|
7527
7854
|
function useContainerWidth(ref) {
|
|
7528
|
-
const [width, setWidth] =
|
|
7529
|
-
|
|
7855
|
+
const [width, setWidth] = useState8(0);
|
|
7856
|
+
useEffect20(() => {
|
|
7530
7857
|
const el = ref.current;
|
|
7531
7858
|
if (!el)
|
|
7532
7859
|
return;
|
|
@@ -7539,7 +7866,7 @@ function useContainerWidth(ref) {
|
|
|
7539
7866
|
return width;
|
|
7540
7867
|
}
|
|
7541
7868
|
// src/hooks/useVoiceInput.ts
|
|
7542
|
-
import { useCallback as
|
|
7869
|
+
import { useCallback as useCallback14, useEffect as useEffect21, useRef as useRef10, useState as useState9 } from "react";
|
|
7543
7870
|
var TARGET_SAMPLE_RATE = 16000;
|
|
7544
7871
|
var PCM_FRAME_BYTES = 3200;
|
|
7545
7872
|
function getAudioContextConstructor() {
|
|
@@ -7596,39 +7923,39 @@ function useVoiceInput({
|
|
|
7596
7923
|
onNeedsInstall,
|
|
7597
7924
|
lang = "en-US"
|
|
7598
7925
|
} = {}) {
|
|
7599
|
-
const [isListening, setIsListening] =
|
|
7600
|
-
const [isTranscribing, setIsTranscribing] =
|
|
7601
|
-
const [analyser, setAnalyser] =
|
|
7602
|
-
const [error, setError] =
|
|
7603
|
-
const streamRef =
|
|
7604
|
-
const audioContextRef =
|
|
7605
|
-
const processorRef =
|
|
7606
|
-
const sourceRef =
|
|
7607
|
-
const socketRef =
|
|
7608
|
-
const frameBufferRef =
|
|
7609
|
-
const stoppingRef =
|
|
7610
|
-
const sessionIdRef =
|
|
7611
|
-
const onTranscriptRef =
|
|
7612
|
-
const onErrorRef =
|
|
7613
|
-
const onNeedsInstallRef =
|
|
7614
|
-
|
|
7926
|
+
const [isListening, setIsListening] = useState9(false);
|
|
7927
|
+
const [isTranscribing, setIsTranscribing] = useState9(false);
|
|
7928
|
+
const [analyser, setAnalyser] = useState9(null);
|
|
7929
|
+
const [error, setError] = useState9(null);
|
|
7930
|
+
const streamRef = useRef10(null);
|
|
7931
|
+
const audioContextRef = useRef10(null);
|
|
7932
|
+
const processorRef = useRef10(null);
|
|
7933
|
+
const sourceRef = useRef10(null);
|
|
7934
|
+
const socketRef = useRef10(null);
|
|
7935
|
+
const frameBufferRef = useRef10(new Uint8Array(0));
|
|
7936
|
+
const stoppingRef = useRef10(false);
|
|
7937
|
+
const sessionIdRef = useRef10(null);
|
|
7938
|
+
const onTranscriptRef = useRef10(onTranscript);
|
|
7939
|
+
const onErrorRef = useRef10(onError);
|
|
7940
|
+
const onNeedsInstallRef = useRef10(onNeedsInstall);
|
|
7941
|
+
useEffect21(() => {
|
|
7615
7942
|
onTranscriptRef.current = onTranscript;
|
|
7616
7943
|
onErrorRef.current = onError;
|
|
7617
7944
|
onNeedsInstallRef.current = onNeedsInstall;
|
|
7618
7945
|
}, [onTranscript, onError, onNeedsInstall]);
|
|
7619
7946
|
const isSupported = typeof window !== "undefined" && !!navigator.mediaDevices?.getUserMedia && !!getAudioContextConstructor() && typeof WebSocket !== "undefined";
|
|
7620
|
-
const emitError =
|
|
7947
|
+
const emitError = useCallback14((message) => {
|
|
7621
7948
|
setError(message);
|
|
7622
7949
|
onErrorRef.current?.(message);
|
|
7623
7950
|
}, []);
|
|
7624
|
-
const handleMissingModel =
|
|
7951
|
+
const handleMissingModel = useCallback14(() => {
|
|
7625
7952
|
if (onNeedsInstallRef.current) {
|
|
7626
7953
|
onNeedsInstallRef.current();
|
|
7627
7954
|
return;
|
|
7628
7955
|
}
|
|
7629
7956
|
emitError("Install a local dictation model from Settings before recording.");
|
|
7630
7957
|
}, [emitError]);
|
|
7631
|
-
const cleanupAudio =
|
|
7958
|
+
const cleanupAudio = useCallback14(() => {
|
|
7632
7959
|
if (processorRef.current) {
|
|
7633
7960
|
processorRef.current.onaudioprocess = null;
|
|
7634
7961
|
processorRef.current.disconnect();
|
|
@@ -7650,7 +7977,7 @@ function useVoiceInput({
|
|
|
7650
7977
|
frameBufferRef.current = new Uint8Array(0);
|
|
7651
7978
|
setAnalyser(null);
|
|
7652
7979
|
}, []);
|
|
7653
|
-
const cleanup =
|
|
7980
|
+
const cleanup = useCallback14(() => {
|
|
7654
7981
|
cleanupAudio();
|
|
7655
7982
|
if (socketRef.current) {
|
|
7656
7983
|
const socket = socketRef.current;
|
|
@@ -7668,7 +7995,7 @@ function useVoiceInput({
|
|
|
7668
7995
|
setIsListening(false);
|
|
7669
7996
|
setIsTranscribing(false);
|
|
7670
7997
|
}, [cleanupAudio]);
|
|
7671
|
-
const flushFrameBuffer =
|
|
7998
|
+
const flushFrameBuffer = useCallback14((force = false) => {
|
|
7672
7999
|
const socket = socketRef.current;
|
|
7673
8000
|
if (!socket || socket.readyState !== WebSocket.OPEN)
|
|
7674
8001
|
return;
|
|
@@ -7684,7 +8011,7 @@ function useVoiceInput({
|
|
|
7684
8011
|
}
|
|
7685
8012
|
frameBufferRef.current = buffer;
|
|
7686
8013
|
}, []);
|
|
7687
|
-
const handleAudioProcess =
|
|
8014
|
+
const handleAudioProcess = useCallback14((event) => {
|
|
7688
8015
|
const audioContext = audioContextRef.current;
|
|
7689
8016
|
const socket = socketRef.current;
|
|
7690
8017
|
if (!audioContext || !socket || socket.readyState !== WebSocket.OPEN || stoppingRef.current) {
|
|
@@ -7695,7 +8022,7 @@ function useVoiceInput({
|
|
|
7695
8022
|
frameBufferRef.current = appendBuffer(frameBufferRef.current, new Uint8Array(floatToPcm16(resampled)));
|
|
7696
8023
|
flushFrameBuffer(false);
|
|
7697
8024
|
}, [flushFrameBuffer]);
|
|
7698
|
-
const stop =
|
|
8025
|
+
const stop = useCallback14(() => {
|
|
7699
8026
|
stoppingRef.current = true;
|
|
7700
8027
|
flushFrameBuffer(true);
|
|
7701
8028
|
cleanupAudio();
|
|
@@ -7709,7 +8036,7 @@ function useVoiceInput({
|
|
|
7709
8036
|
setIsTranscribing(false);
|
|
7710
8037
|
}
|
|
7711
8038
|
}, [cleanupAudio, flushFrameBuffer]);
|
|
7712
|
-
const start =
|
|
8039
|
+
const start = useCallback14(async () => {
|
|
7713
8040
|
if (!isSupported) {
|
|
7714
8041
|
emitError("Voice input is not supported in this browser");
|
|
7715
8042
|
return;
|
|
@@ -7822,7 +8149,7 @@ function useVoiceInput({
|
|
|
7822
8149
|
isSupported,
|
|
7823
8150
|
lang
|
|
7824
8151
|
]);
|
|
7825
|
-
|
|
8152
|
+
useEffect21(() => cleanup, [cleanup]);
|
|
7826
8153
|
return {
|
|
7827
8154
|
isListening,
|
|
7828
8155
|
isTranscribing,
|
|
@@ -7834,8 +8161,8 @@ function useVoiceInput({
|
|
|
7834
8161
|
};
|
|
7835
8162
|
}
|
|
7836
8163
|
// src/hooks/useDictationModels.ts
|
|
7837
|
-
import { useCallback as
|
|
7838
|
-
import { useMutation as
|
|
8164
|
+
import { useCallback as useCallback15, useEffect as useEffect22, useRef as useRef11, useState as useState10 } from "react";
|
|
8165
|
+
import { useMutation as useMutation12, useQuery as useQuery16, useQueryClient as useQueryClient15 } from "@tanstack/react-query";
|
|
7839
8166
|
var DICTATION_STATUS_QUERY_KEY = ["dictation", "status"];
|
|
7840
8167
|
function mergeModelState(current, model) {
|
|
7841
8168
|
if (!current)
|
|
@@ -7856,23 +8183,23 @@ function parseInstallEvent(raw) {
|
|
|
7856
8183
|
}
|
|
7857
8184
|
}
|
|
7858
8185
|
function useDictationModels() {
|
|
7859
|
-
const queryClient =
|
|
7860
|
-
const eventSourceRef =
|
|
7861
|
-
const [activeInstallModelId, setActiveInstallModelId] =
|
|
7862
|
-
const [installProgress, setInstallProgress] =
|
|
7863
|
-
const [installStreamError, setInstallStreamError] =
|
|
7864
|
-
const statusQuery =
|
|
8186
|
+
const queryClient = useQueryClient15();
|
|
8187
|
+
const eventSourceRef = useRef11(null);
|
|
8188
|
+
const [activeInstallModelId, setActiveInstallModelId] = useState10(null);
|
|
8189
|
+
const [installProgress, setInstallProgress] = useState10(null);
|
|
8190
|
+
const [installStreamError, setInstallStreamError] = useState10(null);
|
|
8191
|
+
const statusQuery = useQuery16({
|
|
7865
8192
|
queryKey: DICTATION_STATUS_QUERY_KEY,
|
|
7866
8193
|
queryFn: () => apiClient.getDictationStatus(),
|
|
7867
8194
|
refetchInterval: (query) => query.state.data?.models.some((model) => model.installing) ? 1000 : 30000
|
|
7868
8195
|
});
|
|
7869
|
-
const closeInstallStream =
|
|
8196
|
+
const closeInstallStream = useCallback15(() => {
|
|
7870
8197
|
if (eventSourceRef.current) {
|
|
7871
8198
|
eventSourceRef.current.close();
|
|
7872
8199
|
eventSourceRef.current = null;
|
|
7873
8200
|
}
|
|
7874
8201
|
}, []);
|
|
7875
|
-
const openInstallStream =
|
|
8202
|
+
const openInstallStream = useCallback15((modelId) => {
|
|
7876
8203
|
if (typeof EventSource === "undefined")
|
|
7877
8204
|
return;
|
|
7878
8205
|
closeInstallStream();
|
|
@@ -7903,8 +8230,8 @@ function useDictationModels() {
|
|
|
7903
8230
|
});
|
|
7904
8231
|
};
|
|
7905
8232
|
}, [closeInstallStream, queryClient]);
|
|
7906
|
-
|
|
7907
|
-
const installMutation =
|
|
8233
|
+
useEffect22(() => closeInstallStream, [closeInstallStream]);
|
|
8234
|
+
const installMutation = useMutation12({
|
|
7908
8235
|
mutationFn: (input) => apiClient.installDictationModel(input),
|
|
7909
8236
|
onSuccess: (data) => {
|
|
7910
8237
|
setInstallProgress(data.model);
|
|
@@ -7920,7 +8247,7 @@ function useDictationModels() {
|
|
|
7920
8247
|
}
|
|
7921
8248
|
}
|
|
7922
8249
|
});
|
|
7923
|
-
const removeMutation =
|
|
8250
|
+
const removeMutation = useMutation12({
|
|
7924
8251
|
mutationFn: (model) => apiClient.removeDictationModel(model),
|
|
7925
8252
|
onSuccess: (data) => {
|
|
7926
8253
|
queryClient.setQueryData(DICTATION_STATUS_QUERY_KEY, (current) => mergeModelState(current, data.model));
|
|
@@ -7929,8 +8256,8 @@ function useDictationModels() {
|
|
|
7929
8256
|
});
|
|
7930
8257
|
}
|
|
7931
8258
|
});
|
|
7932
|
-
const installModel =
|
|
7933
|
-
const removeModel =
|
|
8259
|
+
const installModel = useCallback15((model, options = {}) => installMutation.mutateAsync({ model, force: options.force }), [installMutation]);
|
|
8260
|
+
const removeModel = useCallback15((model) => removeMutation.mutateAsync(model), [removeMutation]);
|
|
7934
8261
|
return {
|
|
7935
8262
|
statusQuery,
|
|
7936
8263
|
status: statusQuery.data,
|
|
@@ -7953,6 +8280,8 @@ export {
|
|
|
7953
8280
|
useVoiceInput,
|
|
7954
8281
|
useUpdateSkillsConfig,
|
|
7955
8282
|
useUpdateSession,
|
|
8283
|
+
useUpdateGoalTask,
|
|
8284
|
+
useUpdateGoal,
|
|
7956
8285
|
useUpdateDefaults,
|
|
7957
8286
|
useUpdateAgent,
|
|
7958
8287
|
useUnstageFiles,
|
|
@@ -7966,6 +8295,7 @@ export {
|
|
|
7966
8295
|
useStopMCPServer,
|
|
7967
8296
|
useStartTunnel,
|
|
7968
8297
|
useStartMCPServer,
|
|
8298
|
+
useStartGoal,
|
|
7969
8299
|
useStageFiles,
|
|
7970
8300
|
useSkills,
|
|
7971
8301
|
useSkillFiles,
|
|
@@ -7976,7 +8306,9 @@ export {
|
|
|
7976
8306
|
useSetDefaultAgent,
|
|
7977
8307
|
useSessionsInfinite,
|
|
7978
8308
|
useSessions,
|
|
8309
|
+
useSessionSubagents,
|
|
7979
8310
|
useSessionStream,
|
|
8311
|
+
useSessionGoal,
|
|
7980
8312
|
useSessionFiles,
|
|
7981
8313
|
useSession,
|
|
7982
8314
|
useSendMessage,
|
|
@@ -7993,6 +8325,7 @@ export {
|
|
|
7993
8325
|
useParentSession,
|
|
7994
8326
|
useOttoRouterPayments,
|
|
7995
8327
|
useOttoRouterBalance,
|
|
8328
|
+
useOttoEnabled,
|
|
7996
8329
|
useModels,
|
|
7997
8330
|
useMessages,
|
|
7998
8331
|
useMessageQueuePosition,
|
|
@@ -8021,6 +8354,7 @@ export {
|
|
|
8021
8354
|
useDeleteResearchSession,
|
|
8022
8355
|
useDeleteFiles,
|
|
8023
8356
|
useDeleteAgent,
|
|
8357
|
+
useCreateSessionGoal,
|
|
8024
8358
|
useCreateSession,
|
|
8025
8359
|
useCreateResearchSession,
|
|
8026
8360
|
useCreateGitBranch,
|
|
@@ -8028,10 +8362,12 @@ export {
|
|
|
8028
8362
|
useCopilotDevicePoller,
|
|
8029
8363
|
useContainerWidth,
|
|
8030
8364
|
useConfigTools,
|
|
8365
|
+
useConfigModalControls,
|
|
8031
8366
|
useConfig,
|
|
8032
8367
|
useCommitChanges,
|
|
8033
8368
|
useClientEvents,
|
|
8034
8369
|
useCheckoutBranch,
|
|
8370
|
+
useChatComposer,
|
|
8035
8371
|
useBranches,
|
|
8036
8372
|
useAuthenticateMCPServer,
|
|
8037
8373
|
useAuthStatus,
|
|
@@ -8040,10 +8376,13 @@ export {
|
|
|
8040
8376
|
useAgent,
|
|
8041
8377
|
useAddRemote,
|
|
8042
8378
|
useAddMCPServer,
|
|
8379
|
+
useAddGoalTasks,
|
|
8380
|
+
subagentsQueryKey,
|
|
8043
8381
|
sessionsQueryKey,
|
|
8044
8382
|
optimisticallyQueueMessage,
|
|
8045
8383
|
normalizeQueueState,
|
|
8384
|
+
goalQueryKey,
|
|
8046
8385
|
getAgentToolCount
|
|
8047
8386
|
};
|
|
8048
8387
|
|
|
8049
|
-
//# debugId=
|
|
8388
|
+
//# debugId=A17CCE79470EA61564756E2164756E21
|