@ottocode/web-sdk 0.1.304 → 0.1.306
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/CreateAgentModal.d.ts.map +1 -1
- package/dist/components/agents/agentConstants.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/NewSessionLanding.d.ts.map +1 -1
- package/dist/components/index.js +4218 -3935
- package/dist/components/index.js.map +15 -12
- 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/index.d.ts.map +1 -1
- package/dist/components/ui/ResizeHandle.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +189 -41
- package/dist/hooks/index.js.map +7 -5
- package/dist/hooks/useAgents.d.ts.map +1 -1
- package/dist/hooks/useChatComposer.d.ts +55 -0
- package/dist/hooks/useChatComposer.d.ts.map +1 -0
- package/dist/hooks/useConfigModalControls.d.ts +15 -0
- package/dist/hooks/useConfigModalControls.d.ts.map +1 -0
- package/dist/index.js +4258 -3973
- package/dist/index.js.map +15 -12
- package/dist/stores/agentsStore.d.ts.map +1 -1
- package/dist/stores/index.js +6 -2
- package/dist/stores/index.js.map +3 -3
- package/package.json +3 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { GenericRendererProps } from './types';
|
|
2
|
+
export declare function McpManagerRenderer({ contentJson, toolDurationMs, isExpanded, onToggle, compact, }: GenericRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=McpManagerRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpManagerRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/renderers/McpManagerRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAuHpD,wBAAgB,kBAAkB,CAAC,EAClC,WAAW,EACX,cAAc,EACd,UAAU,EACV,QAAQ,EACR,OAAO,GACP,EAAE,oBAAoB,2CAuGtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/renderers/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/messages/renderers/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA6B3C,UAAU,uBAAuB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAgED,wBAAgB,kBAAkB,CAAC,EAClC,QAAQ,EACR,WAAW,EACX,cAAc,EACd,KAAK,EACL,mBAAmB,EACnB,OAAO,EACP,SAAS,EACT,OAAO,EACP,SAAS,GACT,EAAE,uBAAuB,2CAqGzB;AAED,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeHandle.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ResizeHandle.tsx"],"names":[],"mappings":"AAGA,UAAU,iBAAiB;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"ResizeHandle.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ResizeHandle.tsx"],"names":[],"mappings":"AAGA,UAAU,iBAAiB;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,YAAY,yDA4DvB,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export * from './useFileBrowser';
|
|
|
27
27
|
export * from './useMCP';
|
|
28
28
|
export * from './useSkills';
|
|
29
29
|
export * from './useAgents';
|
|
30
|
+
export * from './useChatComposer';
|
|
31
|
+
export * from './useConfigModalControls';
|
|
30
32
|
export * from './useContainerWidth';
|
|
31
33
|
export * from './useVoiceInput';
|
|
32
34
|
export * from './useDictationModels';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -7414,7 +7414,11 @@ var useAgentsStore = create22((set) => ({
|
|
|
7414
7414
|
}),
|
|
7415
7415
|
setEditorPage: (page) => set({ editorPage: page }),
|
|
7416
7416
|
openCreateModal: () => set({ isManagerOpen: true, isExpanded: true, isCreateModalOpen: true }),
|
|
7417
|
-
closeCreateModal: () => set({
|
|
7417
|
+
closeCreateModal: () => set({
|
|
7418
|
+
isCreateModalOpen: false,
|
|
7419
|
+
managerMode: "library",
|
|
7420
|
+
editorPage: "overview"
|
|
7421
|
+
})
|
|
7418
7422
|
}));
|
|
7419
7423
|
|
|
7420
7424
|
// src/hooks/useAgents.ts
|
|
@@ -7472,6 +7476,7 @@ function useUpdateAgent() {
|
|
|
7472
7476
|
onSuccess: (data, variables) => {
|
|
7473
7477
|
queryClient.setQueryData(["config", "agents", variables.name], data);
|
|
7474
7478
|
queryClient.invalidateQueries({ queryKey: ["config", "agents"] });
|
|
7479
|
+
queryClient.invalidateQueries({ queryKey: ["config"] });
|
|
7475
7480
|
}
|
|
7476
7481
|
});
|
|
7477
7482
|
}
|
|
@@ -7495,6 +7500,7 @@ function useDeleteAgent() {
|
|
|
7495
7500
|
const next = refreshed.agents.find((a) => a.name === refreshed.default)?.name ?? refreshed.agents[0]?.name ?? null;
|
|
7496
7501
|
selectAgent(next);
|
|
7497
7502
|
}
|
|
7503
|
+
queryClient.invalidateQueries({ queryKey: ["config"] });
|
|
7498
7504
|
}
|
|
7499
7505
|
});
|
|
7500
7506
|
}
|
|
@@ -7516,11 +7522,151 @@ function getAgentToolCount(agent) {
|
|
|
7516
7522
|
...agent.toolConfig.loadable ?? []
|
|
7517
7523
|
])).length;
|
|
7518
7524
|
}
|
|
7525
|
+
// src/hooks/useChatComposer.ts
|
|
7526
|
+
import { useCallback as useCallback12, useEffect as useEffect19, useMemo as useMemo4, useRef as useRef9, useState as useState6 } from "react";
|
|
7527
|
+
function useChatComposer({
|
|
7528
|
+
sessionId,
|
|
7529
|
+
defaultAgent
|
|
7530
|
+
} = {}) {
|
|
7531
|
+
const { data: config2 } = useConfig();
|
|
7532
|
+
const { data: allModels } = useAllModels();
|
|
7533
|
+
const { data: agentDetails } = useAgentDetails({ enabled: true });
|
|
7534
|
+
const session = useSession(sessionId ?? "");
|
|
7535
|
+
const updateSession = useUpdateSession(sessionId ?? "");
|
|
7536
|
+
const [agent, setAgent] = useState6("");
|
|
7537
|
+
const [provider, setProvider] = useState6("");
|
|
7538
|
+
const [model, setModel] = useState6("");
|
|
7539
|
+
const initializedRef = useRef9(false);
|
|
7540
|
+
useEffect19(() => {
|
|
7541
|
+
if (!sessionId || !session)
|
|
7542
|
+
return;
|
|
7543
|
+
setAgent(session.agent);
|
|
7544
|
+
setProvider(session.provider);
|
|
7545
|
+
setModel(session.model);
|
|
7546
|
+
}, [sessionId, session]);
|
|
7547
|
+
useEffect19(() => {
|
|
7548
|
+
if (sessionId || initializedRef.current)
|
|
7549
|
+
return;
|
|
7550
|
+
if (!config2?.defaults || !agentDetails?.agents.length)
|
|
7551
|
+
return;
|
|
7552
|
+
initializedRef.current = true;
|
|
7553
|
+
const initialAgent = defaultAgent || config2.defaults.agent || "general";
|
|
7554
|
+
const selectedAgent = agentDetails.agents.find((agentDetail) => agentDetail.name === initialAgent);
|
|
7555
|
+
setAgent(initialAgent);
|
|
7556
|
+
setProvider(selectedAgent?.provider ?? config2.defaults.provider ?? "");
|
|
7557
|
+
setModel(selectedAgent?.model ?? config2.defaults.model ?? "");
|
|
7558
|
+
}, [sessionId, agentDetails?.agents, config2, defaultAgent]);
|
|
7559
|
+
const agentNames = useMemo4(() => agentDetails?.agents.length ? agentDetails.agents.map((agentDetail) => agentDetail.name) : config2?.agents ?? [], [agentDetails?.agents, config2?.agents]);
|
|
7560
|
+
const selectedModel = useMemo4(() => allModels?.[provider]?.models?.find((m) => m.id === model), [allModels, provider, model]);
|
|
7561
|
+
const persist2 = useCallback12(async (update) => {
|
|
7562
|
+
if (!sessionId)
|
|
7563
|
+
return;
|
|
7564
|
+
try {
|
|
7565
|
+
await updateSession.mutateAsync(update);
|
|
7566
|
+
} catch (error) {
|
|
7567
|
+
console.error("Failed to update session:", error);
|
|
7568
|
+
}
|
|
7569
|
+
}, [sessionId, updateSession]);
|
|
7570
|
+
const handleAgentChange = useCallback12(async (value) => {
|
|
7571
|
+
setAgent(value);
|
|
7572
|
+
const selectedAgent = agentDetails?.agents.find((agentDetail) => agentDetail.name === value);
|
|
7573
|
+
if (!selectedAgent) {
|
|
7574
|
+
await persist2({ agent: value });
|
|
7575
|
+
return;
|
|
7576
|
+
}
|
|
7577
|
+
const nextProvider = selectedAgent.provider ?? config2?.defaults?.provider ?? provider;
|
|
7578
|
+
const nextModel = selectedAgent.model ?? config2?.defaults?.model ?? model;
|
|
7579
|
+
setProvider(nextProvider);
|
|
7580
|
+
setModel(nextModel);
|
|
7581
|
+
await persist2({
|
|
7582
|
+
agent: value,
|
|
7583
|
+
provider: nextProvider,
|
|
7584
|
+
model: nextModel
|
|
7585
|
+
});
|
|
7586
|
+
}, [
|
|
7587
|
+
agentDetails?.agents,
|
|
7588
|
+
config2?.defaults?.model,
|
|
7589
|
+
config2?.defaults?.provider,
|
|
7590
|
+
model,
|
|
7591
|
+
provider,
|
|
7592
|
+
persist2
|
|
7593
|
+
]);
|
|
7594
|
+
const handlePlanModeToggle = useCallback12(async (isPlanMode) => {
|
|
7595
|
+
await handleAgentChange(isPlanMode ? "plan" : "build");
|
|
7596
|
+
}, [handleAgentChange]);
|
|
7597
|
+
const handleModelSelectorChange = useCallback12(async (newProvider, newModel) => {
|
|
7598
|
+
setProvider(newProvider);
|
|
7599
|
+
setModel(newModel);
|
|
7600
|
+
await persist2({ provider: newProvider, model: newModel });
|
|
7601
|
+
}, [persist2]);
|
|
7602
|
+
const handleProviderChange = useCallback12(async (newProvider) => {
|
|
7603
|
+
setProvider(newProvider);
|
|
7604
|
+
if (model) {
|
|
7605
|
+
await persist2({ provider: newProvider, model });
|
|
7606
|
+
}
|
|
7607
|
+
}, [model, persist2]);
|
|
7608
|
+
const handleModelChange = useCallback12(async (newModel) => {
|
|
7609
|
+
setModel(newModel);
|
|
7610
|
+
await persist2({ provider, model: newModel });
|
|
7611
|
+
}, [provider, persist2]);
|
|
7612
|
+
return {
|
|
7613
|
+
config: config2,
|
|
7614
|
+
allModels,
|
|
7615
|
+
agent,
|
|
7616
|
+
provider,
|
|
7617
|
+
model,
|
|
7618
|
+
agentNames,
|
|
7619
|
+
isPlanMode: agent === "plan",
|
|
7620
|
+
modelSupportsReasoning: selectedModel?.reasoningText,
|
|
7621
|
+
modelSupportsVision: selectedModel?.vision,
|
|
7622
|
+
modelSupportsAttachment: selectedModel?.attachment,
|
|
7623
|
+
modelIsFree: selectedModel?.free,
|
|
7624
|
+
providerAuthType: allModels?.[provider]?.authType,
|
|
7625
|
+
isCustomProvider: allModels?.[provider]?.label?.includes("(custom)") ?? false,
|
|
7626
|
+
handleAgentChange,
|
|
7627
|
+
handlePlanModeToggle,
|
|
7628
|
+
handleProviderChange,
|
|
7629
|
+
handleModelChange,
|
|
7630
|
+
handleModelSelectorChange
|
|
7631
|
+
};
|
|
7632
|
+
}
|
|
7633
|
+
// src/hooks/useConfigModalControls.ts
|
|
7634
|
+
import { useCallback as useCallback13, useState as useState7 } from "react";
|
|
7635
|
+
function useConfigModalControls() {
|
|
7636
|
+
const [isConfigOpen, setIsConfigOpen] = useState7(false);
|
|
7637
|
+
const [configFocusTarget, setConfigFocusTarget] = useState7(null);
|
|
7638
|
+
const openConfig = useCallback13((target) => {
|
|
7639
|
+
setConfigFocusTarget(target);
|
|
7640
|
+
setIsConfigOpen(true);
|
|
7641
|
+
}, []);
|
|
7642
|
+
const toggleConfig = useCallback13(() => {
|
|
7643
|
+
setIsConfigOpen((prev) => !prev);
|
|
7644
|
+
}, []);
|
|
7645
|
+
const closeConfig = useCallback13(() => {
|
|
7646
|
+
setIsConfigOpen(false);
|
|
7647
|
+
setConfigFocusTarget(null);
|
|
7648
|
+
}, []);
|
|
7649
|
+
const openModelConfig = useCallback13(() => {
|
|
7650
|
+
openConfig("model");
|
|
7651
|
+
}, [openConfig]);
|
|
7652
|
+
const openAgentConfig = useCallback13(() => {
|
|
7653
|
+
openConfig("agent");
|
|
7654
|
+
}, [openConfig]);
|
|
7655
|
+
return {
|
|
7656
|
+
isConfigOpen,
|
|
7657
|
+
configFocusTarget,
|
|
7658
|
+
openConfig,
|
|
7659
|
+
toggleConfig,
|
|
7660
|
+
closeConfig,
|
|
7661
|
+
openModelConfig,
|
|
7662
|
+
openAgentConfig
|
|
7663
|
+
};
|
|
7664
|
+
}
|
|
7519
7665
|
// src/hooks/useContainerWidth.ts
|
|
7520
|
-
import { useEffect as
|
|
7666
|
+
import { useEffect as useEffect20, useState as useState8 } from "react";
|
|
7521
7667
|
function useContainerWidth(ref) {
|
|
7522
|
-
const [width, setWidth] =
|
|
7523
|
-
|
|
7668
|
+
const [width, setWidth] = useState8(0);
|
|
7669
|
+
useEffect20(() => {
|
|
7524
7670
|
const el = ref.current;
|
|
7525
7671
|
if (!el)
|
|
7526
7672
|
return;
|
|
@@ -7533,7 +7679,7 @@ function useContainerWidth(ref) {
|
|
|
7533
7679
|
return width;
|
|
7534
7680
|
}
|
|
7535
7681
|
// src/hooks/useVoiceInput.ts
|
|
7536
|
-
import { useCallback as
|
|
7682
|
+
import { useCallback as useCallback14, useEffect as useEffect21, useRef as useRef10, useState as useState9 } from "react";
|
|
7537
7683
|
var TARGET_SAMPLE_RATE = 16000;
|
|
7538
7684
|
var PCM_FRAME_BYTES = 3200;
|
|
7539
7685
|
function getAudioContextConstructor() {
|
|
@@ -7590,39 +7736,39 @@ function useVoiceInput({
|
|
|
7590
7736
|
onNeedsInstall,
|
|
7591
7737
|
lang = "en-US"
|
|
7592
7738
|
} = {}) {
|
|
7593
|
-
const [isListening, setIsListening] =
|
|
7594
|
-
const [isTranscribing, setIsTranscribing] =
|
|
7595
|
-
const [analyser, setAnalyser] =
|
|
7596
|
-
const [error, setError] =
|
|
7597
|
-
const streamRef =
|
|
7598
|
-
const audioContextRef =
|
|
7599
|
-
const processorRef =
|
|
7600
|
-
const sourceRef =
|
|
7601
|
-
const socketRef =
|
|
7602
|
-
const frameBufferRef =
|
|
7603
|
-
const stoppingRef =
|
|
7604
|
-
const sessionIdRef =
|
|
7605
|
-
const onTranscriptRef =
|
|
7606
|
-
const onErrorRef =
|
|
7607
|
-
const onNeedsInstallRef =
|
|
7608
|
-
|
|
7739
|
+
const [isListening, setIsListening] = useState9(false);
|
|
7740
|
+
const [isTranscribing, setIsTranscribing] = useState9(false);
|
|
7741
|
+
const [analyser, setAnalyser] = useState9(null);
|
|
7742
|
+
const [error, setError] = useState9(null);
|
|
7743
|
+
const streamRef = useRef10(null);
|
|
7744
|
+
const audioContextRef = useRef10(null);
|
|
7745
|
+
const processorRef = useRef10(null);
|
|
7746
|
+
const sourceRef = useRef10(null);
|
|
7747
|
+
const socketRef = useRef10(null);
|
|
7748
|
+
const frameBufferRef = useRef10(new Uint8Array(0));
|
|
7749
|
+
const stoppingRef = useRef10(false);
|
|
7750
|
+
const sessionIdRef = useRef10(null);
|
|
7751
|
+
const onTranscriptRef = useRef10(onTranscript);
|
|
7752
|
+
const onErrorRef = useRef10(onError);
|
|
7753
|
+
const onNeedsInstallRef = useRef10(onNeedsInstall);
|
|
7754
|
+
useEffect21(() => {
|
|
7609
7755
|
onTranscriptRef.current = onTranscript;
|
|
7610
7756
|
onErrorRef.current = onError;
|
|
7611
7757
|
onNeedsInstallRef.current = onNeedsInstall;
|
|
7612
7758
|
}, [onTranscript, onError, onNeedsInstall]);
|
|
7613
7759
|
const isSupported = typeof window !== "undefined" && !!navigator.mediaDevices?.getUserMedia && !!getAudioContextConstructor() && typeof WebSocket !== "undefined";
|
|
7614
|
-
const emitError =
|
|
7760
|
+
const emitError = useCallback14((message) => {
|
|
7615
7761
|
setError(message);
|
|
7616
7762
|
onErrorRef.current?.(message);
|
|
7617
7763
|
}, []);
|
|
7618
|
-
const handleMissingModel =
|
|
7764
|
+
const handleMissingModel = useCallback14(() => {
|
|
7619
7765
|
if (onNeedsInstallRef.current) {
|
|
7620
7766
|
onNeedsInstallRef.current();
|
|
7621
7767
|
return;
|
|
7622
7768
|
}
|
|
7623
7769
|
emitError("Install a local dictation model from Settings before recording.");
|
|
7624
7770
|
}, [emitError]);
|
|
7625
|
-
const cleanupAudio =
|
|
7771
|
+
const cleanupAudio = useCallback14(() => {
|
|
7626
7772
|
if (processorRef.current) {
|
|
7627
7773
|
processorRef.current.onaudioprocess = null;
|
|
7628
7774
|
processorRef.current.disconnect();
|
|
@@ -7644,7 +7790,7 @@ function useVoiceInput({
|
|
|
7644
7790
|
frameBufferRef.current = new Uint8Array(0);
|
|
7645
7791
|
setAnalyser(null);
|
|
7646
7792
|
}, []);
|
|
7647
|
-
const cleanup =
|
|
7793
|
+
const cleanup = useCallback14(() => {
|
|
7648
7794
|
cleanupAudio();
|
|
7649
7795
|
if (socketRef.current) {
|
|
7650
7796
|
const socket = socketRef.current;
|
|
@@ -7662,7 +7808,7 @@ function useVoiceInput({
|
|
|
7662
7808
|
setIsListening(false);
|
|
7663
7809
|
setIsTranscribing(false);
|
|
7664
7810
|
}, [cleanupAudio]);
|
|
7665
|
-
const flushFrameBuffer =
|
|
7811
|
+
const flushFrameBuffer = useCallback14((force = false) => {
|
|
7666
7812
|
const socket = socketRef.current;
|
|
7667
7813
|
if (!socket || socket.readyState !== WebSocket.OPEN)
|
|
7668
7814
|
return;
|
|
@@ -7678,7 +7824,7 @@ function useVoiceInput({
|
|
|
7678
7824
|
}
|
|
7679
7825
|
frameBufferRef.current = buffer;
|
|
7680
7826
|
}, []);
|
|
7681
|
-
const handleAudioProcess =
|
|
7827
|
+
const handleAudioProcess = useCallback14((event) => {
|
|
7682
7828
|
const audioContext = audioContextRef.current;
|
|
7683
7829
|
const socket = socketRef.current;
|
|
7684
7830
|
if (!audioContext || !socket || socket.readyState !== WebSocket.OPEN || stoppingRef.current) {
|
|
@@ -7689,7 +7835,7 @@ function useVoiceInput({
|
|
|
7689
7835
|
frameBufferRef.current = appendBuffer(frameBufferRef.current, new Uint8Array(floatToPcm16(resampled)));
|
|
7690
7836
|
flushFrameBuffer(false);
|
|
7691
7837
|
}, [flushFrameBuffer]);
|
|
7692
|
-
const stop =
|
|
7838
|
+
const stop = useCallback14(() => {
|
|
7693
7839
|
stoppingRef.current = true;
|
|
7694
7840
|
flushFrameBuffer(true);
|
|
7695
7841
|
cleanupAudio();
|
|
@@ -7703,7 +7849,7 @@ function useVoiceInput({
|
|
|
7703
7849
|
setIsTranscribing(false);
|
|
7704
7850
|
}
|
|
7705
7851
|
}, [cleanupAudio, flushFrameBuffer]);
|
|
7706
|
-
const start =
|
|
7852
|
+
const start = useCallback14(async () => {
|
|
7707
7853
|
if (!isSupported) {
|
|
7708
7854
|
emitError("Voice input is not supported in this browser");
|
|
7709
7855
|
return;
|
|
@@ -7816,7 +7962,7 @@ function useVoiceInput({
|
|
|
7816
7962
|
isSupported,
|
|
7817
7963
|
lang
|
|
7818
7964
|
]);
|
|
7819
|
-
|
|
7965
|
+
useEffect21(() => cleanup, [cleanup]);
|
|
7820
7966
|
return {
|
|
7821
7967
|
isListening,
|
|
7822
7968
|
isTranscribing,
|
|
@@ -7828,7 +7974,7 @@ function useVoiceInput({
|
|
|
7828
7974
|
};
|
|
7829
7975
|
}
|
|
7830
7976
|
// src/hooks/useDictationModels.ts
|
|
7831
|
-
import { useCallback as
|
|
7977
|
+
import { useCallback as useCallback15, useEffect as useEffect22, useRef as useRef11, useState as useState10 } from "react";
|
|
7832
7978
|
import { useMutation as useMutation11, useQuery as useQuery15, useQueryClient as useQueryClient14 } from "@tanstack/react-query";
|
|
7833
7979
|
var DICTATION_STATUS_QUERY_KEY = ["dictation", "status"];
|
|
7834
7980
|
function mergeModelState(current, model) {
|
|
@@ -7851,22 +7997,22 @@ function parseInstallEvent(raw) {
|
|
|
7851
7997
|
}
|
|
7852
7998
|
function useDictationModels() {
|
|
7853
7999
|
const queryClient = useQueryClient14();
|
|
7854
|
-
const eventSourceRef =
|
|
7855
|
-
const [activeInstallModelId, setActiveInstallModelId] =
|
|
7856
|
-
const [installProgress, setInstallProgress] =
|
|
7857
|
-
const [installStreamError, setInstallStreamError] =
|
|
8000
|
+
const eventSourceRef = useRef11(null);
|
|
8001
|
+
const [activeInstallModelId, setActiveInstallModelId] = useState10(null);
|
|
8002
|
+
const [installProgress, setInstallProgress] = useState10(null);
|
|
8003
|
+
const [installStreamError, setInstallStreamError] = useState10(null);
|
|
7858
8004
|
const statusQuery = useQuery15({
|
|
7859
8005
|
queryKey: DICTATION_STATUS_QUERY_KEY,
|
|
7860
8006
|
queryFn: () => apiClient.getDictationStatus(),
|
|
7861
8007
|
refetchInterval: (query) => query.state.data?.models.some((model) => model.installing) ? 1000 : 30000
|
|
7862
8008
|
});
|
|
7863
|
-
const closeInstallStream =
|
|
8009
|
+
const closeInstallStream = useCallback15(() => {
|
|
7864
8010
|
if (eventSourceRef.current) {
|
|
7865
8011
|
eventSourceRef.current.close();
|
|
7866
8012
|
eventSourceRef.current = null;
|
|
7867
8013
|
}
|
|
7868
8014
|
}, []);
|
|
7869
|
-
const openInstallStream =
|
|
8015
|
+
const openInstallStream = useCallback15((modelId) => {
|
|
7870
8016
|
if (typeof EventSource === "undefined")
|
|
7871
8017
|
return;
|
|
7872
8018
|
closeInstallStream();
|
|
@@ -7897,7 +8043,7 @@ function useDictationModels() {
|
|
|
7897
8043
|
});
|
|
7898
8044
|
};
|
|
7899
8045
|
}, [closeInstallStream, queryClient]);
|
|
7900
|
-
|
|
8046
|
+
useEffect22(() => closeInstallStream, [closeInstallStream]);
|
|
7901
8047
|
const installMutation = useMutation11({
|
|
7902
8048
|
mutationFn: (input) => apiClient.installDictationModel(input),
|
|
7903
8049
|
onSuccess: (data) => {
|
|
@@ -7923,8 +8069,8 @@ function useDictationModels() {
|
|
|
7923
8069
|
});
|
|
7924
8070
|
}
|
|
7925
8071
|
});
|
|
7926
|
-
const installModel =
|
|
7927
|
-
const removeModel =
|
|
8072
|
+
const installModel = useCallback15((model, options = {}) => installMutation.mutateAsync({ model, force: options.force }), [installMutation]);
|
|
8073
|
+
const removeModel = useCallback15((model) => removeMutation.mutateAsync(model), [removeMutation]);
|
|
7928
8074
|
return {
|
|
7929
8075
|
statusQuery,
|
|
7930
8076
|
status: statusQuery.data,
|
|
@@ -8022,10 +8168,12 @@ export {
|
|
|
8022
8168
|
useCopilotDevicePoller,
|
|
8023
8169
|
useContainerWidth,
|
|
8024
8170
|
useConfigTools,
|
|
8171
|
+
useConfigModalControls,
|
|
8025
8172
|
useConfig,
|
|
8026
8173
|
useCommitChanges,
|
|
8027
8174
|
useClientEvents,
|
|
8028
8175
|
useCheckoutBranch,
|
|
8176
|
+
useChatComposer,
|
|
8029
8177
|
useBranches,
|
|
8030
8178
|
useAuthenticateMCPServer,
|
|
8031
8179
|
useAuthStatus,
|
|
@@ -8040,4 +8188,4 @@ export {
|
|
|
8040
8188
|
getAgentToolCount
|
|
8041
8189
|
};
|
|
8042
8190
|
|
|
8043
|
-
//# debugId=
|
|
8191
|
+
//# debugId=0386469E53572E8E64756E2164756E21
|