@ottocode/web-sdk 0.1.314 → 0.1.316
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/common/ProviderLogo.d.ts.map +1 -1
- package/dist/components/index.js +153 -44
- package/dist/components/index.js.map +10 -9
- package/dist/hooks/index.js +150 -40
- package/dist/hooks/index.js.map +8 -7
- package/dist/hooks/tool-preview-helpers.d.ts +6 -0
- package/dist/hooks/tool-preview-helpers.d.ts.map +1 -0
- package/dist/hooks/useAgents.d.ts +1 -0
- package/dist/hooks/useAgents.d.ts.map +1 -1
- package/dist/hooks/useChatComposer.d.ts +1 -0
- package/dist/hooks/useChatComposer.d.ts.map +1 -1
- package/dist/hooks/useConfig.d.ts +4 -0
- package/dist/hooks/useConfig.d.ts.map +1 -1
- package/dist/hooks/useSessionStream.d.ts.map +1 -1
- package/dist/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/index.js +153 -44
- package/dist/index.js.map +10 -9
- 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/index.js.map +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-preview-helpers.d.ts","sourceRoot":"","sources":["../../src/hooks/tool-preview-helpers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAsEF,wBAAgB,qCAAqC,CACpD,MAAM,EAAE,MAAM,GACZ,iBAAiB,EAAE,CA8BrB"}
|
|
@@ -185,6 +185,7 @@ export declare function useSetDefaultAgent(): import("@tanstack/react-query").Us
|
|
|
185
185
|
reasoningText?: boolean;
|
|
186
186
|
reasoningLevel?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh";
|
|
187
187
|
theme?: "light" | "dark";
|
|
188
|
+
tuiTheme?: string;
|
|
188
189
|
vimMode?: boolean;
|
|
189
190
|
compactThread?: boolean;
|
|
190
191
|
fontFamily?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAgents.d.ts","sourceRoot":"","sources":["../../src/hooks/useAgents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG9E,YAAY,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,UAAU,gBAAgB;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useAgents.d.ts","sourceRoot":"","sources":["../../src/hooks/useAgents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG9E,YAAY,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,UAAU,gBAAgB;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB;;;;;;;;mBAqIo1sC,CAAC;0BAAwC,CAAC;;sBAA8D,CAAC;oBAAyC,CAAC;;;sBAA2F,CAAC;oBAAyC,CAAC;;;sBAA0F,CAAC;oBAAyC,CAAC;;gBAAoD,CAAC;aAA2B,CAAC;;;;;;UA1Gh4tC;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;;;;;;;;mBAwGivyC,CAAC;0BAAwC,CAAC;;sBAA8D,CAAC;oBAAyC,CAAC;;;sBAA2F,CAAC;oBAAyC,CAAC;;;sBAA0F,CAAC;oBAAyC,CAAC;;gBAAoD,CAAC;aAA2B,CAAC;;;;;UA9FhxzC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,gBAAqB;;;;;;;;mBAwFm1sC,CAAC;0BAAwC,CAAC;;sBAA8D,CAAC;oBAAyC,CAAC;;;sBAA2F,CAAC;oBAAyC,CAAC;;;sBAA0F,CAAC;oBAAyC,CAAC;;gBAAoD,CAAC;aAA2B,CAAC;;;;;;UAjFh4tC;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,gBAAqB;;;mBA+E0k4C,CAAC;;;kBAA6R,CAAC;gBAA0D,CAAC;aAA4B,CAAC;;;UArE7/4C;AAED,wBAAgB,cAAc;;;;;;;;mBAmE4g2C,CAAC;0BAAwC,CAAC;;sBAA8D,CAAC;oBAAyC,CAAC;;;sBAA2F,CAAC;oBAAyC,CAAC;;;sBAA0F,CAAC;oBAAyC,CAAC;;gBAAoD,CAAC;aAA2B,CAAC;;;;;;UAhEj/2C,MAAM;WAAS,gBAAgB;YAQtE;AAED,wBAAgB,cAAc;;;;;;;;;;mBAsDo6vC,CAAC;0BAAwC,CAAC;;sBAA8D,CAAC;oBAAyC,CAAC;;;sBAA2F,CAAC;oBAAyC,CAAC;;;sBAA0F,CAAC;oBAAyC,CAAC;;gBAAoD,CAAC;aAA2B,CAAC;;;;;;UA7Cx6wC,MAAM;YACJ,OAAO,GAAG,QAAQ;YAmB5B;AAED,wBAAgB,kBAAkB;;;;;;oBAuB0iF,CAAC;kBAAsD,CAAC;qBAA2B,CAAC;sBAA4B,CAAC;aAAmE,CAAC;gBAA+B,CAAC;eAAoB,CAAC;qBAA2B,CAAC;kBAAwB,CAAC;kBAAuB,CAAC;qBAA2B,CAAC;wBAA8B,CAAC;kCAAwC,CAAC;uBAAmC,CAAC;mBAAyB,CAAC;;2BAbpiG;AAED,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,MAAM,CAQR"}
|
|
@@ -25,6 +25,7 @@ export declare function useChatComposer({ sessionId, defaultAgent, }?: UseChatCo
|
|
|
25
25
|
reasoningText?: boolean;
|
|
26
26
|
reasoningLevel?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh";
|
|
27
27
|
theme?: "light" | "dark";
|
|
28
|
+
tuiTheme?: string;
|
|
28
29
|
vimMode?: boolean;
|
|
29
30
|
compactThread?: boolean;
|
|
30
31
|
fontFamily?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatComposer.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatComposer.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACtC,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAC/B,SAAS,EACT,YAAY,GACZ,GAAE,sBAA2B;;;;;;;;wBAoBJ,CAAC;sBACG,CAAC;yBAA2B,CAAC;0BACrC,CAAC;iBACkC,CAAC;
|
|
1
|
+
{"version":3,"file":"useChatComposer.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatComposer.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACtC,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAC/B,SAAS,EACT,YAAY,GACZ,GAAE,sBAA2B;;;;;;;;wBAoBJ,CAAC;sBACG,CAAC;yBAA2B,CAAC;0BACrC,CAAC;iBACkC,CAAC;oBAC5C,CAAC;mBAAoB,CAAC;yBACvB,CAAC;sBAAwB,CAAC;sBAErC,CAAC;yBACC,CAAC;4BAA8B,CAAC;sCAClC,CAAC;2BAAmC,CAAC;uBACtC,CAAD;;;;;;;;;;;;;;;+BA6BgB,MAAM;uCA+BD,OAAO;wCAgBN,MAAM;kCAUT,MAAM;6CAnBH,MAAM,YAAY,MAAM;EA+C7C"}
|
|
@@ -10,6 +10,7 @@ export declare function useConfig(): import("@tanstack/react-query").UseQueryRes
|
|
|
10
10
|
reasoningText?: boolean;
|
|
11
11
|
reasoningLevel?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh";
|
|
12
12
|
theme?: "light" | "dark";
|
|
13
|
+
tuiTheme?: string;
|
|
13
14
|
vimMode?: boolean;
|
|
14
15
|
compactThread?: boolean;
|
|
15
16
|
fontFamily?: string;
|
|
@@ -52,6 +53,7 @@ export declare function useUpdateDefaults(): import("@tanstack/react-query").Use
|
|
|
52
53
|
reasoningText?: boolean;
|
|
53
54
|
reasoningLevel?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh";
|
|
54
55
|
theme?: "light" | "dark";
|
|
56
|
+
tuiTheme?: string;
|
|
55
57
|
vimMode?: boolean;
|
|
56
58
|
compactThread?: boolean;
|
|
57
59
|
fontFamily?: string;
|
|
@@ -71,6 +73,7 @@ export declare function useUpdateDefaults(): import("@tanstack/react-query").Use
|
|
|
71
73
|
reasoningText?: boolean;
|
|
72
74
|
reasoningLevel?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh";
|
|
73
75
|
theme?: "light" | "dark";
|
|
76
|
+
tuiTheme?: string;
|
|
74
77
|
vimMode?: boolean;
|
|
75
78
|
compactThread?: boolean;
|
|
76
79
|
fontFamily?: string;
|
|
@@ -94,6 +97,7 @@ export declare function useUpdateDefaults(): import("@tanstack/react-query").Use
|
|
|
94
97
|
reasoningText?: boolean;
|
|
95
98
|
reasoningLevel?: "minimal" | "low" | "medium" | "high" | "max" | "xhigh";
|
|
96
99
|
theme?: "light" | "dark";
|
|
100
|
+
tuiTheme?: string;
|
|
97
101
|
vimMode?: boolean;
|
|
98
102
|
compactThread?: boolean;
|
|
99
103
|
fontFamily?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.d.ts","sourceRoot":"","sources":["../../src/hooks/useConfig.ts"],"names":[],"mappings":"AAKA,wBAAgB,SAAS;;;;;;;
|
|
1
|
+
{"version":3,"file":"useConfig.d.ts","sourceRoot":"","sources":["../../src/hooks/useConfig.ts"],"names":[],"mappings":"AAKA,wBAAgB,SAAS;;;;;;;oBAqDjB,CAAC;kBACO,CAAC;qBACP,CAAC;sBAA6B,CAAA;aAEL,CAAC;gBAEZ,CAAC;eAAoB,CAAC;qBAC5B,CAAC;kBAEb,CAAH;kBAAuB,CAAC;qBACP,CAAC;wBAKjB,CAAC;kCAEM,CAAA;uBACL,CAAA;mBAA0B,CAAA;;UAjE/B;AAED,wBAAgB,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM;;;;gBAwE6+C,CAAC;qBAA2B,CAAC;cAAoB,CAAC;kBAAwB,CAAC;YAAkB,CAAC;qBAA2B,CAAC;uBAA4B,CAAC;iBAAsB,CAAC;yBAA+B,CAAC;;;;;;UAlEruD;AAED,wBAAgB,YAAY,0FAK3B;AAED,wBAAgB,iBAAiB;;;;;;oBAyDiyJ,CAAC;kBAAsD,CAAC;qBAA2B,CAAC;sBAA4B,CAAC;aAAmE,CAAC;gBAA+B,CAAC;eAAoB,CAAC;qBAA2B,CAAC;kBAAwB,CAAC;kBAAuB,CAAC;qBAA2B,CAAC;wBAA8B,CAAC;kCAAwC,CAAC;uBAAmC,CAAC;mBAAyB,CAAC;;;YApDhxK,MAAM;eACH,MAAM;YACT,MAAM;mBACC,MAAM,GAAG,WAAW,GAAG,KAAK,GAAG,MAAM;iBACvC,OAAO;oBACJ,OAAO;qBACN,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO;YAChE,OAAO,GAAG,MAAM;eACb,MAAM;cACP,OAAO;oBACD,OAAO;iBACV,MAAM;iBACN,OAAO;oBACJ,OAAO;uBACJ,OAAO;iCACG,MAAM,GAAG,IAAI;sBACxB,OAAO;kBACX,OAAO;YACb,QAAQ;;;;;;;;;wBAOX,CAAC;sBACO,CAAC;yBACP,CAAC;0BAA6B,CAAA;iBAEL,CAAC;oBAEZ,CAAC;mBAAoB,CAAC;yBAC5B,CAAC;sBAEb,CAAH;sBAAuB,CAAC;yBACP,CAAC;4BAKjB,CAAC;sCAEM,CAAA;2BACL,CAAA;uBAA0B,CAAA;;;GAQ/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSessionStream.d.ts","sourceRoot":"","sources":["../../src/hooks/useSessionStream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSessionStream.d.ts","sourceRoot":"","sources":["../../src/hooks/useSessionStream.ts"],"names":[],"mappings":"AAyBA,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,UAAO,QAo+Dd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVoiceInput.d.ts","sourceRoot":"","sources":["../../src/hooks/useVoiceInput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useVoiceInput.d.ts","sourceRoot":"","sources":["../../src/hooks/useVoiceInput.ts"],"names":[],"mappings":"AA+BA,UAAU,oBAAoB;IAC7B,2DAA2D;IAC3D,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9D,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,mBAAmB;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,IAAI,CAAC;CACjB;AAqED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC7B,YAAY,EACZ,OAAO,EACP,cAAc,EACd,IAAc,GACd,GAAE,oBAAyB,GAAG,mBAAmB,CAgUjD"}
|
package/dist/index.js
CHANGED
|
@@ -3970,7 +3970,6 @@ var providerLogos = {
|
|
|
3970
3970
|
"zai-coding": zaiLogo,
|
|
3971
3971
|
ottorouter: ottorouterLogo,
|
|
3972
3972
|
minimax: minimaxLogo,
|
|
3973
|
-
moonshot: kimiLogo,
|
|
3974
3973
|
kimi: kimiLogo,
|
|
3975
3974
|
opencode: opencodeLogo,
|
|
3976
3975
|
copilot: copilotLogo
|
|
@@ -5504,6 +5503,7 @@ ${text.slice(lineStart)}`;
|
|
|
5504
5503
|
import { useCallback as useCallback7, useEffect as useEffect12, useRef as useRef4, useState as useState5 } from "react";
|
|
5505
5504
|
var TARGET_SAMPLE_RATE = 16000;
|
|
5506
5505
|
var PCM_FRAME_BYTES = 3200;
|
|
5506
|
+
var PROCESSOR_BUFFER_SIZE = 4096;
|
|
5507
5507
|
function getAudioContextConstructor() {
|
|
5508
5508
|
if (typeof window === "undefined")
|
|
5509
5509
|
return null;
|
|
@@ -5648,8 +5648,7 @@ function useVoiceInput({
|
|
|
5648
5648
|
}, []);
|
|
5649
5649
|
const handleAudioProcess = useCallback7((event) => {
|
|
5650
5650
|
const audioContext = audioContextRef.current;
|
|
5651
|
-
|
|
5652
|
-
if (!audioContext || !socket || socket.readyState !== WebSocket.OPEN || stoppingRef.current) {
|
|
5651
|
+
if (!audioContext || stoppingRef.current) {
|
|
5653
5652
|
return;
|
|
5654
5653
|
}
|
|
5655
5654
|
const input = event.inputBuffer.getChannelData(0);
|
|
@@ -5681,9 +5680,53 @@ function useVoiceInput({
|
|
|
5681
5680
|
setIsTranscribing(false);
|
|
5682
5681
|
stoppingRef.current = false;
|
|
5683
5682
|
try {
|
|
5684
|
-
const
|
|
5683
|
+
const streamPromise = navigator.mediaDevices.getUserMedia({
|
|
5684
|
+
audio: {
|
|
5685
|
+
echoCancellation: true,
|
|
5686
|
+
noiseSuppression: true,
|
|
5687
|
+
autoGainControl: true
|
|
5688
|
+
}
|
|
5689
|
+
});
|
|
5690
|
+
const statusPromise = apiClient.getDictationStatus().then((status2) => ({ status: status2 }), (error2) => ({ error: error2 }));
|
|
5691
|
+
const stream = await streamPromise;
|
|
5692
|
+
if (stoppingRef.current) {
|
|
5693
|
+
for (const track of stream.getTracks())
|
|
5694
|
+
track.stop();
|
|
5695
|
+
return;
|
|
5696
|
+
}
|
|
5697
|
+
streamRef.current = stream;
|
|
5698
|
+
const AudioContextCtor = getAudioContextConstructor();
|
|
5699
|
+
if (!AudioContextCtor)
|
|
5700
|
+
throw new Error("AudioContext is unavailable");
|
|
5701
|
+
const audioContext = new AudioContextCtor;
|
|
5702
|
+
audioContextRef.current = audioContext;
|
|
5703
|
+
const source = audioContext.createMediaStreamSource(stream);
|
|
5704
|
+
const analyserNode = audioContext.createAnalyser();
|
|
5705
|
+
analyserNode.fftSize = 256;
|
|
5706
|
+
analyserNode.smoothingTimeConstant = 0.55;
|
|
5707
|
+
const processor = audioContext.createScriptProcessor(PROCESSOR_BUFFER_SIZE, 1, 1);
|
|
5708
|
+
processor.onaudioprocess = handleAudioProcess;
|
|
5709
|
+
source.connect(analyserNode);
|
|
5710
|
+
source.connect(processor);
|
|
5711
|
+
processor.connect(audioContext.destination);
|
|
5712
|
+
sourceRef.current = source;
|
|
5713
|
+
processorRef.current = processor;
|
|
5714
|
+
if (audioContext.state === "suspended") {
|
|
5715
|
+
await audioContext.resume();
|
|
5716
|
+
}
|
|
5717
|
+
if (stoppingRef.current)
|
|
5718
|
+
return;
|
|
5719
|
+
setAnalyser(analyserNode);
|
|
5720
|
+
setIsListening(true);
|
|
5721
|
+
const statusResult = await statusPromise;
|
|
5722
|
+
if ("error" in statusResult)
|
|
5723
|
+
throw statusResult.error;
|
|
5724
|
+
const { status } = statusResult;
|
|
5725
|
+
if (stoppingRef.current)
|
|
5726
|
+
return;
|
|
5685
5727
|
const model = status.models.find((item) => item.id === status.defaultModel);
|
|
5686
5728
|
if (!model?.installed) {
|
|
5729
|
+
cleanup();
|
|
5687
5730
|
handleMissingModel();
|
|
5688
5731
|
return;
|
|
5689
5732
|
}
|
|
@@ -5691,7 +5734,10 @@ function useVoiceInput({
|
|
|
5691
5734
|
model: status.defaultModel,
|
|
5692
5735
|
language: toLanguageCode(lang)
|
|
5693
5736
|
});
|
|
5737
|
+
if (stoppingRef.current)
|
|
5738
|
+
return;
|
|
5694
5739
|
if (!session.modelInstalled) {
|
|
5740
|
+
cleanup();
|
|
5695
5741
|
handleMissingModel();
|
|
5696
5742
|
return;
|
|
5697
5743
|
}
|
|
@@ -5704,7 +5750,6 @@ function useVoiceInput({
|
|
|
5704
5750
|
reject(new Error("Timed out connecting to local dictation"));
|
|
5705
5751
|
}, 5000);
|
|
5706
5752
|
socket.onopen = () => {
|
|
5707
|
-
window.clearTimeout(timeout);
|
|
5708
5753
|
socket.send(JSON.stringify({
|
|
5709
5754
|
type: "start",
|
|
5710
5755
|
model: session.model,
|
|
@@ -5716,7 +5761,23 @@ function useVoiceInput({
|
|
|
5716
5761
|
},
|
|
5717
5762
|
partialResults: false
|
|
5718
5763
|
}));
|
|
5719
|
-
|
|
5764
|
+
};
|
|
5765
|
+
socket.onmessage = (event) => {
|
|
5766
|
+
if (typeof event.data !== "string")
|
|
5767
|
+
return;
|
|
5768
|
+
const payload = parseServerEvent(event.data);
|
|
5769
|
+
if (!payload)
|
|
5770
|
+
return;
|
|
5771
|
+
if (payload.type === "ready") {
|
|
5772
|
+
window.clearTimeout(timeout);
|
|
5773
|
+
flushFrameBuffer(false);
|
|
5774
|
+
resolve();
|
|
5775
|
+
return;
|
|
5776
|
+
}
|
|
5777
|
+
if (payload.type === "error") {
|
|
5778
|
+
window.clearTimeout(timeout);
|
|
5779
|
+
reject(new Error(payload.message));
|
|
5780
|
+
}
|
|
5720
5781
|
};
|
|
5721
5782
|
socket.onerror = () => {
|
|
5722
5783
|
window.clearTimeout(timeout);
|
|
@@ -5744,32 +5805,6 @@ function useVoiceInput({
|
|
|
5744
5805
|
setIsListening(false);
|
|
5745
5806
|
setIsTranscribing(false);
|
|
5746
5807
|
};
|
|
5747
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
5748
|
-
audio: {
|
|
5749
|
-
echoCancellation: true,
|
|
5750
|
-
noiseSuppression: true,
|
|
5751
|
-
autoGainControl: true
|
|
5752
|
-
}
|
|
5753
|
-
});
|
|
5754
|
-
streamRef.current = stream;
|
|
5755
|
-
const AudioContextCtor = getAudioContextConstructor();
|
|
5756
|
-
if (!AudioContextCtor)
|
|
5757
|
-
throw new Error("AudioContext is unavailable");
|
|
5758
|
-
const audioContext = new AudioContextCtor;
|
|
5759
|
-
const source = audioContext.createMediaStreamSource(stream);
|
|
5760
|
-
const analyserNode = audioContext.createAnalyser();
|
|
5761
|
-
analyserNode.fftSize = 256;
|
|
5762
|
-
analyserNode.smoothingTimeConstant = 0.55;
|
|
5763
|
-
const processor = audioContext.createScriptProcessor(4096, 1, 1);
|
|
5764
|
-
processor.onaudioprocess = handleAudioProcess;
|
|
5765
|
-
source.connect(analyserNode);
|
|
5766
|
-
source.connect(processor);
|
|
5767
|
-
processor.connect(audioContext.destination);
|
|
5768
|
-
audioContextRef.current = audioContext;
|
|
5769
|
-
sourceRef.current = source;
|
|
5770
|
-
processorRef.current = processor;
|
|
5771
|
-
setAnalyser(analyserNode);
|
|
5772
|
-
setIsListening(true);
|
|
5773
5808
|
} catch (err) {
|
|
5774
5809
|
const name = err instanceof Error ? err.name : "";
|
|
5775
5810
|
const msg = name === "NotAllowedError" ? "Microphone permission denied" : err instanceof Error ? err.message : "Could not start voice input";
|
|
@@ -5781,6 +5816,7 @@ function useVoiceInput({
|
|
|
5781
5816
|
emitError,
|
|
5782
5817
|
handleAudioProcess,
|
|
5783
5818
|
handleMissingModel,
|
|
5819
|
+
flushFrameBuffer,
|
|
5784
5820
|
isSupported,
|
|
5785
5821
|
lang
|
|
5786
5822
|
]);
|
|
@@ -11669,6 +11705,78 @@ class SSEClient {
|
|
|
11669
11705
|
}
|
|
11670
11706
|
}
|
|
11671
11707
|
|
|
11708
|
+
// src/hooks/tool-preview-helpers.ts
|
|
11709
|
+
function bestEffortUnescapeJsonString(value) {
|
|
11710
|
+
try {
|
|
11711
|
+
return JSON.parse(`"${value.replace(/\\$/, "")}"`);
|
|
11712
|
+
} catch {
|
|
11713
|
+
return value.replace(/\\n/g, `
|
|
11714
|
+
`).replace(/\\t/g, "\t").replace(/\\r/g, "\r").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
11715
|
+
}
|
|
11716
|
+
}
|
|
11717
|
+
function extractJsonStringFieldAt(text, field, startIndex, requireClosed = false) {
|
|
11718
|
+
const marker = `"${field}"`;
|
|
11719
|
+
const markerIndex = text.indexOf(marker, Math.max(0, startIndex));
|
|
11720
|
+
if (markerIndex === -1)
|
|
11721
|
+
return;
|
|
11722
|
+
const colonIndex = text.indexOf(":", markerIndex + marker.length);
|
|
11723
|
+
if (colonIndex === -1)
|
|
11724
|
+
return;
|
|
11725
|
+
const quoteIndex = text.indexOf('"', colonIndex + 1);
|
|
11726
|
+
if (quoteIndex === -1)
|
|
11727
|
+
return;
|
|
11728
|
+
let escaped = "";
|
|
11729
|
+
let escaping = false;
|
|
11730
|
+
let closed = false;
|
|
11731
|
+
let endIndex = text.length;
|
|
11732
|
+
for (let i = quoteIndex + 1;i < text.length; i += 1) {
|
|
11733
|
+
const char = text[i];
|
|
11734
|
+
if (escaping) {
|
|
11735
|
+
escaped += `\\${char}`;
|
|
11736
|
+
escaping = false;
|
|
11737
|
+
continue;
|
|
11738
|
+
}
|
|
11739
|
+
if (char === "\\") {
|
|
11740
|
+
escaping = true;
|
|
11741
|
+
continue;
|
|
11742
|
+
}
|
|
11743
|
+
if (char === '"') {
|
|
11744
|
+
closed = true;
|
|
11745
|
+
endIndex = i + 1;
|
|
11746
|
+
break;
|
|
11747
|
+
}
|
|
11748
|
+
escaped += char;
|
|
11749
|
+
}
|
|
11750
|
+
if (requireClosed && !closed)
|
|
11751
|
+
return;
|
|
11752
|
+
return {
|
|
11753
|
+
value: bestEffortUnescapeJsonString(escaped),
|
|
11754
|
+
endIndex,
|
|
11755
|
+
closed
|
|
11756
|
+
};
|
|
11757
|
+
}
|
|
11758
|
+
function extractStreamingMultiEditPreviewEdits(buffer) {
|
|
11759
|
+
const editsStart = buffer.indexOf('"edits"');
|
|
11760
|
+
if (editsStart === -1)
|
|
11761
|
+
return [];
|
|
11762
|
+
const edits = [];
|
|
11763
|
+
let cursor = editsStart;
|
|
11764
|
+
const maxPreviewEdits = 50;
|
|
11765
|
+
while (cursor < buffer.length && edits.length < maxPreviewEdits) {
|
|
11766
|
+
const oldString = extractJsonStringFieldAt(buffer, "oldString", cursor, true);
|
|
11767
|
+
if (!oldString)
|
|
11768
|
+
break;
|
|
11769
|
+
const newString = extractJsonStringFieldAt(buffer, "newString", oldString.endIndex, false);
|
|
11770
|
+
if (!newString)
|
|
11771
|
+
break;
|
|
11772
|
+
edits.push({ oldString: oldString.value, newString: newString.value });
|
|
11773
|
+
cursor = Math.max(newString.endIndex, oldString.endIndex + 1);
|
|
11774
|
+
if (!newString.closed)
|
|
11775
|
+
break;
|
|
11776
|
+
}
|
|
11777
|
+
return edits;
|
|
11778
|
+
}
|
|
11779
|
+
|
|
11672
11780
|
// src/hooks/useSessionStream.ts
|
|
11673
11781
|
var TOOL_PREVIEW_THROTTLE_MS = 500;
|
|
11674
11782
|
var TOOL_PREVIEW_THROTTLE_MIN_CHARS = 8000;
|
|
@@ -11822,7 +11930,7 @@ ${value.slice(-STREAMING_TOOL_INPUT_TAIL_CHARS)}`;
|
|
|
11822
11930
|
toolInputBuffersRef.current.set(key, next);
|
|
11823
11931
|
return parseArgsRecord(next);
|
|
11824
11932
|
};
|
|
11825
|
-
const
|
|
11933
|
+
const bestEffortUnescapeJsonString2 = (value) => {
|
|
11826
11934
|
try {
|
|
11827
11935
|
return JSON.parse(`"${value.replace(/\\$/, "")}"`);
|
|
11828
11936
|
} catch {
|
|
@@ -11863,7 +11971,7 @@ ${value.slice(-STREAMING_TOOL_INPUT_TAIL_CHARS)}`;
|
|
|
11863
11971
|
}
|
|
11864
11972
|
if (requireClosed && !closed)
|
|
11865
11973
|
return;
|
|
11866
|
-
return
|
|
11974
|
+
return bestEffortUnescapeJsonString2(escaped);
|
|
11867
11975
|
};
|
|
11868
11976
|
const getBufferedToolInput = (payload) => {
|
|
11869
11977
|
const key = getToolBufferKey(payload);
|
|
@@ -11900,7 +12008,7 @@ ${argContent.slice(-STREAMING_WRITE_CONTENT_PREVIEW_CHARS)}`;
|
|
|
11900
12008
|
}
|
|
11901
12009
|
const rawTail = buffer.slice(Math.max(valueStart, buffer.length - STREAMING_WRITE_CONTENT_PREVIEW_CHARS));
|
|
11902
12010
|
return `… showing latest streamed content only …
|
|
11903
|
-
${
|
|
12011
|
+
${bestEffortUnescapeJsonString2(rawTail)}`;
|
|
11904
12012
|
};
|
|
11905
12013
|
const getStreamingPatchPreviewContent = (args, buffer) => {
|
|
11906
12014
|
const argPatch = args?.patch;
|
|
@@ -11929,9 +12037,9 @@ ${argPatch.slice(-STREAMING_PATCH_PREVIEW_TAIL_CHARS)}`;
|
|
|
11929
12037
|
}
|
|
11930
12038
|
const rawHead = buffer.slice(valueStart, valueStart + STREAMING_PATCH_PREVIEW_HEAD_CHARS);
|
|
11931
12039
|
const rawTail = buffer.slice(-STREAMING_PATCH_PREVIEW_TAIL_CHARS);
|
|
11932
|
-
return `${
|
|
12040
|
+
return `${bestEffortUnescapeJsonString2(rawHead)}
|
|
11933
12041
|
… patch preview truncated while streaming …
|
|
11934
|
-
${
|
|
12042
|
+
${bestEffortUnescapeJsonString2(rawTail)}`;
|
|
11935
12043
|
};
|
|
11936
12044
|
const getResultRecord = (payload) => payload?.result && typeof payload.result === "object" && !Array.isArray(payload.result) ? payload.result : null;
|
|
11937
12045
|
const getArtifactRecord = (payload) => {
|
|
@@ -12107,14 +12215,15 @@ ${bestEffortUnescapeJsonString(rawTail)}`;
|
|
|
12107
12215
|
return lines.join(`
|
|
12108
12216
|
`);
|
|
12109
12217
|
};
|
|
12110
|
-
const getMultiEditPreviewEdits = (args) => {
|
|
12218
|
+
const getMultiEditPreviewEdits = (args, buffer) => {
|
|
12111
12219
|
const edits = Array.isArray(args?.edits) ? args.edits : [];
|
|
12112
|
-
|
|
12220
|
+
const parsedEdits = edits.flatMap((edit) => {
|
|
12113
12221
|
if (!edit || typeof edit !== "object" || Array.isArray(edit))
|
|
12114
12222
|
return [];
|
|
12115
12223
|
const record = edit;
|
|
12116
12224
|
return typeof record.oldString === "string" && typeof record.newString === "string" ? [{ oldString: record.oldString, newString: record.newString }] : [];
|
|
12117
12225
|
});
|
|
12226
|
+
return parsedEdits.length > 0 ? parsedEdits : extractStreamingMultiEditPreviewEdits(buffer);
|
|
12118
12227
|
};
|
|
12119
12228
|
const getEditPreviewPatch = (toolName, path, args, buffer, artifact) => {
|
|
12120
12229
|
if (typeof artifact?.patch === "string")
|
|
@@ -12124,7 +12233,7 @@ ${bestEffortUnescapeJsonString(rawTail)}`;
|
|
|
12124
12233
|
const newString = getStringArg(args, buffer, "newString");
|
|
12125
12234
|
return oldString !== undefined && newString !== undefined ? buildStringEditPatchPreview(path, [{ oldString, newString }]) : undefined;
|
|
12126
12235
|
}
|
|
12127
|
-
const edits = getMultiEditPreviewEdits(args);
|
|
12236
|
+
const edits = getMultiEditPreviewEdits(args, buffer);
|
|
12128
12237
|
return buildStringEditPatchPreview(path, edits);
|
|
12129
12238
|
};
|
|
12130
12239
|
const handleReadToolActivity = (eventType, payload, delta) => {
|
|
@@ -41819,7 +41928,7 @@ var ProviderSetupStep = memo75(function ProviderSetupStep2({
|
|
|
41819
41928
|
setOpenAICodeCopied(false);
|
|
41820
41929
|
setOpenAIAuthMode("choice");
|
|
41821
41930
|
setOpenAIModalOpen(true);
|
|
41822
|
-
} else if (providerId === "
|
|
41931
|
+
} else if (providerId === "kimi" && onStartKimiDeviceFlow) {
|
|
41823
41932
|
setKimiPolling(false);
|
|
41824
41933
|
setKimiDevice(null);
|
|
41825
41934
|
setKimiError(null);
|
|
@@ -42426,7 +42535,7 @@ var ProviderSetupStep = memo75(function ProviderSetupStep2({
|
|
|
42426
42535
|
className: "flex items-center gap-2 p-3 bg-card border border-ring rounded-xl overflow-hidden",
|
|
42427
42536
|
children: [
|
|
42428
42537
|
/* @__PURE__ */ jsx154("div", {
|
|
42429
|
-
className: "shrink-0",
|
|
42538
|
+
className: "shrink-0 flex items-center",
|
|
42430
42539
|
children: /* @__PURE__ */ jsx154(ProviderLogo, {
|
|
42431
42540
|
provider: id,
|
|
42432
42541
|
size: 18
|
|
@@ -43224,7 +43333,7 @@ var ProviderSetupStep = memo75(function ProviderSetupStep2({
|
|
|
43224
43333
|
className: "flex items-center gap-3 p-6 border-b border-border",
|
|
43225
43334
|
children: [
|
|
43226
43335
|
/* @__PURE__ */ jsx154(ProviderLogo, {
|
|
43227
|
-
provider: "
|
|
43336
|
+
provider: "kimi",
|
|
43228
43337
|
size: 24
|
|
43229
43338
|
}),
|
|
43230
43339
|
/* @__PURE__ */ jsx154("h3", {
|
|
@@ -46568,4 +46677,4 @@ export {
|
|
|
46568
46677
|
API_BASE_URL
|
|
46569
46678
|
};
|
|
46570
46679
|
|
|
46571
|
-
//# debugId=
|
|
46680
|
+
//# debugId=996FED05264406DC64756E2164756E21
|