@lvce-editor/chat-view 5.1.0 → 5.4.0
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/chatViewWorkerMain.js +177 -52
- package/package.json +1 -1
|
@@ -1027,7 +1027,7 @@ const createMockRpc = ({
|
|
|
1027
1027
|
};
|
|
1028
1028
|
|
|
1029
1029
|
const rpcs = Object.create(null);
|
|
1030
|
-
const set$
|
|
1030
|
+
const set$6 = (id, rpc) => {
|
|
1031
1031
|
rpcs[id] = rpc;
|
|
1032
1032
|
};
|
|
1033
1033
|
const get$2 = id => {
|
|
@@ -1060,7 +1060,7 @@ const create$2 = rpcId => {
|
|
|
1060
1060
|
const mockRpc = createMockRpc({
|
|
1061
1061
|
commandMap
|
|
1062
1062
|
});
|
|
1063
|
-
set$
|
|
1063
|
+
set$6(rpcId, mockRpc);
|
|
1064
1064
|
// @ts-ignore
|
|
1065
1065
|
mockRpc[Symbol.dispose] = () => {
|
|
1066
1066
|
remove(rpcId);
|
|
@@ -1069,20 +1069,20 @@ const create$2 = rpcId => {
|
|
|
1069
1069
|
return mockRpc;
|
|
1070
1070
|
},
|
|
1071
1071
|
set(rpc) {
|
|
1072
|
-
set$
|
|
1072
|
+
set$6(rpcId, rpc);
|
|
1073
1073
|
}
|
|
1074
1074
|
};
|
|
1075
1075
|
};
|
|
1076
1076
|
|
|
1077
1077
|
const {
|
|
1078
|
-
invoke: invoke$
|
|
1079
|
-
set: set$
|
|
1078
|
+
invoke: invoke$4,
|
|
1079
|
+
set: set$5
|
|
1080
1080
|
} = create$2(6007);
|
|
1081
1081
|
const getMathBlockDom = async node => {
|
|
1082
|
-
return invoke$
|
|
1082
|
+
return invoke$4('ChatMath.getMathBlockDom', node);
|
|
1083
1083
|
};
|
|
1084
1084
|
const getMathInlineDom = async node => {
|
|
1085
|
-
return invoke$
|
|
1085
|
+
return invoke$4('ChatMath.getMathInlineDom', node);
|
|
1086
1086
|
};
|
|
1087
1087
|
|
|
1088
1088
|
const Button$2 = 'button';
|
|
@@ -1171,26 +1171,26 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1171
1171
|
const FocusChatInput = 8000;
|
|
1172
1172
|
|
|
1173
1173
|
const {
|
|
1174
|
-
invoke: invoke$
|
|
1175
|
-
set: set$
|
|
1174
|
+
invoke: invoke$3,
|
|
1175
|
+
set: set$4
|
|
1176
1176
|
} = create$2(ChatNetworkWorker);
|
|
1177
1177
|
|
|
1178
1178
|
const {
|
|
1179
|
-
invoke: invoke$
|
|
1180
|
-
set: set$
|
|
1179
|
+
invoke: invoke$2,
|
|
1180
|
+
set: set$3
|
|
1181
1181
|
} = create$2(ExtensionHostWorker);
|
|
1182
1182
|
|
|
1183
1183
|
const {
|
|
1184
|
-
invoke,
|
|
1184
|
+
invoke: invoke$1,
|
|
1185
1185
|
invokeAndTransfer,
|
|
1186
|
-
set: set$
|
|
1186
|
+
set: set$2
|
|
1187
1187
|
} = create$2(RendererWorker);
|
|
1188
1188
|
const sendMessagePortToChatMathWorker$1 = async (port, rpcId) => {
|
|
1189
1189
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1190
1190
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatMathWorker', port, command, rpcId);
|
|
1191
1191
|
};
|
|
1192
1192
|
const readFile = async uri => {
|
|
1193
|
-
return invoke('FileSystem.readFile', uri);
|
|
1193
|
+
return invoke$1('FileSystem.readFile', uri);
|
|
1194
1194
|
};
|
|
1195
1195
|
const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
1196
1196
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
@@ -1200,22 +1200,22 @@ const sendMessagePortToChatNetworkWorker = async port => {
|
|
|
1200
1200
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatNetworkWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
1201
1201
|
};
|
|
1202
1202
|
const writeFile = async (uri, text) => {
|
|
1203
|
-
await invoke('FileSystem.writeFile', uri, text);
|
|
1203
|
+
await invoke$1('FileSystem.writeFile', uri, text);
|
|
1204
1204
|
};
|
|
1205
1205
|
const activateByEvent$1 = (event, assetDir, platform) => {
|
|
1206
|
-
return invoke('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
|
|
1206
|
+
return invoke$1('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
|
|
1207
1207
|
};
|
|
1208
1208
|
const getWorkspacePath = () => {
|
|
1209
|
-
return invoke('Workspace.getPath');
|
|
1209
|
+
return invoke$1('Workspace.getPath');
|
|
1210
1210
|
};
|
|
1211
1211
|
const getPreference = async key => {
|
|
1212
|
-
return await invoke('Preferences.get', key);
|
|
1212
|
+
return await invoke$1('Preferences.get', key);
|
|
1213
1213
|
};
|
|
1214
1214
|
const openExternal = async uri => {
|
|
1215
|
-
await invoke('Open.openExternal', uri);
|
|
1215
|
+
await invoke$1('Open.openExternal', uri);
|
|
1216
1216
|
};
|
|
1217
1217
|
const measureTextBlockHeight$1 = async (actualInput, fontFamily, fontSize, lineHeightPx, width) => {
|
|
1218
|
-
return invoke(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
|
|
1218
|
+
return invoke$1(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
|
|
1219
1219
|
};
|
|
1220
1220
|
|
|
1221
1221
|
const toCommandId = key => {
|
|
@@ -1643,6 +1643,7 @@ const createDefaultState = () => {
|
|
|
1643
1643
|
tokensUsed: 0,
|
|
1644
1644
|
uid: 0,
|
|
1645
1645
|
usageOverviewEnabled: false,
|
|
1646
|
+
useChatCoordinatorWorker: false,
|
|
1646
1647
|
useChatMathWorker: true,
|
|
1647
1648
|
useChatNetworkWorkerForRequests: false,
|
|
1648
1649
|
useMockApi: false,
|
|
@@ -1660,7 +1661,7 @@ const {
|
|
|
1660
1661
|
get: get$1,
|
|
1661
1662
|
getCommandIds,
|
|
1662
1663
|
registerCommands,
|
|
1663
|
-
set,
|
|
1664
|
+
set: set$1,
|
|
1664
1665
|
wrapCommand,
|
|
1665
1666
|
wrapGetter
|
|
1666
1667
|
} = create$1();
|
|
@@ -1676,7 +1677,7 @@ const create = (uid, x, y, width, height, platform, assetDir) => {
|
|
|
1676
1677
|
x,
|
|
1677
1678
|
y
|
|
1678
1679
|
};
|
|
1679
|
-
set(uid, state, state);
|
|
1680
|
+
set$1(uid, state, state);
|
|
1680
1681
|
};
|
|
1681
1682
|
|
|
1682
1683
|
const toError = error => {
|
|
@@ -2916,6 +2917,10 @@ const getMenuEntryIds = () => {
|
|
|
2916
2917
|
return [];
|
|
2917
2918
|
};
|
|
2918
2919
|
|
|
2920
|
+
const getQuickPickMenuEntries = () => {
|
|
2921
|
+
return [];
|
|
2922
|
+
};
|
|
2923
|
+
|
|
2919
2924
|
const getSelectedSessionId = state => {
|
|
2920
2925
|
return state.selectedSessionId;
|
|
2921
2926
|
};
|
|
@@ -2948,7 +2953,7 @@ const handleChatListContextMenu = async (state, eventX, eventY) => {
|
|
|
2948
2953
|
if (!item) {
|
|
2949
2954
|
return state;
|
|
2950
2955
|
}
|
|
2951
|
-
await invoke('ContextMenu.show', eventX, eventY, CHAT_LIST_ITEM_CONTEXT_MENU, item.id);
|
|
2956
|
+
await invoke$1('ContextMenu.show', eventX, eventY, CHAT_LIST_ITEM_CONTEXT_MENU, item.id);
|
|
2952
2957
|
return state;
|
|
2953
2958
|
};
|
|
2954
2959
|
|
|
@@ -2979,7 +2984,7 @@ const createSession = async (state, projectIdOverride = '') => {
|
|
|
2979
2984
|
|
|
2980
2985
|
const openFolder = async () => {
|
|
2981
2986
|
try {
|
|
2982
|
-
return await invoke('FilePicker.showDirectoryPicker');
|
|
2987
|
+
return await invoke$1('FilePicker.showDirectoryPicker');
|
|
2983
2988
|
} catch {
|
|
2984
2989
|
return '';
|
|
2985
2990
|
}
|
|
@@ -3056,7 +3061,7 @@ const handleClickCreateProject = async state => {
|
|
|
3056
3061
|
};
|
|
3057
3062
|
|
|
3058
3063
|
const handleClickOpenApiApiKeySettings = async state => {
|
|
3059
|
-
await invoke('Main.openUri', 'app://settings.json');
|
|
3064
|
+
await invoke$1('Main.openUri', 'app://settings.json');
|
|
3060
3065
|
return state;
|
|
3061
3066
|
};
|
|
3062
3067
|
|
|
@@ -3066,7 +3071,7 @@ const handleClickOpenApiApiKeyWebsite = async state => {
|
|
|
3066
3071
|
};
|
|
3067
3072
|
|
|
3068
3073
|
const handleClickOpenRouterApiKeySettings = async state => {
|
|
3069
|
-
await invoke('Main.openUri', 'app://settings.json');
|
|
3074
|
+
await invoke$1('Main.openUri', 'app://settings.json');
|
|
3070
3075
|
return state;
|
|
3071
3076
|
};
|
|
3072
3077
|
|
|
@@ -3084,6 +3089,21 @@ const openRouterTooManyRequestsMessage = 'OpenRouter rate limit reached (429). P
|
|
|
3084
3089
|
const openRouterRequestFailureReasons = ['ContentSecurityPolicyViolation: Check DevTools for details.', 'OpenRouter server offline: Check DevTools for details.', 'Check your internet connection.'];
|
|
3085
3090
|
const openRouterTooManyRequestsReasons = ['Wait a short time and retry your request.', 'Reduce request frequency to avoid rate limits.', 'Use a different model if this one is saturated.'];
|
|
3086
3091
|
|
|
3092
|
+
let rpc;
|
|
3093
|
+
const set = value => {
|
|
3094
|
+
rpc = value;
|
|
3095
|
+
};
|
|
3096
|
+
const invoke = async (method, ...params) => {
|
|
3097
|
+
if (!rpc) {
|
|
3098
|
+
throw new Error('ChatCoordinatorWorker is not initialized');
|
|
3099
|
+
}
|
|
3100
|
+
return rpc.invoke(method, ...params);
|
|
3101
|
+
};
|
|
3102
|
+
|
|
3103
|
+
const getAiResponse$1 = async options => {
|
|
3104
|
+
return invoke('ChatCoordinator.getAiResponse', options);
|
|
3105
|
+
};
|
|
3106
|
+
|
|
3087
3107
|
const getToolErrorPayload = error => {
|
|
3088
3108
|
const rawStack = error && typeof error === 'object' ? Reflect.get(error, 'stack') : undefined;
|
|
3089
3109
|
return {
|
|
@@ -3117,7 +3137,7 @@ const executeListFilesTool = async (args, _options) => {
|
|
|
3117
3137
|
});
|
|
3118
3138
|
}
|
|
3119
3139
|
try {
|
|
3120
|
-
const entries = await invoke('FileSystem.readDirWithFileTypes', uri);
|
|
3140
|
+
const entries = await invoke$1('FileSystem.readDirWithFileTypes', uri);
|
|
3121
3141
|
return JSON.stringify({
|
|
3122
3142
|
entries,
|
|
3123
3143
|
uri
|
|
@@ -3438,6 +3458,15 @@ const setHttpErrorResponse = (statusCode, body) => {
|
|
|
3438
3458
|
type: 'error'
|
|
3439
3459
|
};
|
|
3440
3460
|
};
|
|
3461
|
+
const setRequestFailedResponse = (isOffline = false) => {
|
|
3462
|
+
errorResult = {
|
|
3463
|
+
details: 'request-failed',
|
|
3464
|
+
...(isOffline ? {
|
|
3465
|
+
isOffline: true
|
|
3466
|
+
} : {}),
|
|
3467
|
+
type: 'error'
|
|
3468
|
+
};
|
|
3469
|
+
};
|
|
3441
3470
|
const takeErrorResponse = () => {
|
|
3442
3471
|
const error = errorResult;
|
|
3443
3472
|
errorResult = undefined;
|
|
@@ -3709,7 +3738,7 @@ const executeProvider = async ({
|
|
|
3709
3738
|
}) => {
|
|
3710
3739
|
await activateByEvent(event, assetDir, platform);
|
|
3711
3740
|
// @ts-ignore
|
|
3712
|
-
const result = invoke$
|
|
3741
|
+
const result = invoke$2(method, ...params);
|
|
3713
3742
|
return result;
|
|
3714
3743
|
};
|
|
3715
3744
|
|
|
@@ -3841,10 +3870,10 @@ const getOpenApiApiEndpoint = openApiApiBaseUrl => {
|
|
|
3841
3870
|
};
|
|
3842
3871
|
|
|
3843
3872
|
const makeApiRequest = async options => {
|
|
3844
|
-
return invoke$
|
|
3873
|
+
return invoke$3('ChatNetwork.makeApiRequest', options);
|
|
3845
3874
|
};
|
|
3846
3875
|
const makeStreamingApiRequest = async options => {
|
|
3847
|
-
return invoke$
|
|
3876
|
+
return invoke$3('ChatNetwork.makeStreamingApiRequest', options);
|
|
3848
3877
|
};
|
|
3849
3878
|
|
|
3850
3879
|
const getTextContent = content => {
|
|
@@ -4890,7 +4919,7 @@ const getOpenApiErrorMessage = errorResult => {
|
|
|
4890
4919
|
return openApiRequestFailedMessage;
|
|
4891
4920
|
}
|
|
4892
4921
|
case 'request-failed':
|
|
4893
|
-
if (isOffline()) {
|
|
4922
|
+
if (errorResult.isOffline || isOffline()) {
|
|
4894
4923
|
return openApiRequestFailedOfflineMessage;
|
|
4895
4924
|
}
|
|
4896
4925
|
return openApiRequestFailedMessage;
|
|
@@ -5305,6 +5334,7 @@ const getAiResponse = async ({
|
|
|
5305
5334
|
mockAiResponseDelay = 800,
|
|
5306
5335
|
mockApiCommandId,
|
|
5307
5336
|
models,
|
|
5337
|
+
nextMessageId,
|
|
5308
5338
|
onDataEvent,
|
|
5309
5339
|
onEventStreamFinished,
|
|
5310
5340
|
onTextChunk,
|
|
@@ -5317,11 +5347,50 @@ const getAiResponse = async ({
|
|
|
5317
5347
|
platform,
|
|
5318
5348
|
selectedModelId,
|
|
5319
5349
|
streamingEnabled = true,
|
|
5350
|
+
useChatCoordinatorWorker = false,
|
|
5320
5351
|
useChatNetworkWorkerForRequests = false,
|
|
5321
5352
|
useMockApi,
|
|
5322
5353
|
userText,
|
|
5323
5354
|
webSearchEnabled = false
|
|
5324
5355
|
}) => {
|
|
5356
|
+
if (useChatCoordinatorWorker) {
|
|
5357
|
+
try {
|
|
5358
|
+
const result = await getAiResponse$1({
|
|
5359
|
+
assetDir,
|
|
5360
|
+
...(messageId ? {
|
|
5361
|
+
messageId
|
|
5362
|
+
} : {}),
|
|
5363
|
+
messages,
|
|
5364
|
+
mockAiResponseDelay,
|
|
5365
|
+
mockApiCommandId,
|
|
5366
|
+
models,
|
|
5367
|
+
nextMessageId,
|
|
5368
|
+
openApiApiBaseUrl,
|
|
5369
|
+
openApiApiKey,
|
|
5370
|
+
openRouterApiBaseUrl,
|
|
5371
|
+
openRouterApiKey,
|
|
5372
|
+
passIncludeObfuscation,
|
|
5373
|
+
platform,
|
|
5374
|
+
selectedModelId,
|
|
5375
|
+
streamingEnabled,
|
|
5376
|
+
useChatNetworkWorkerForRequests,
|
|
5377
|
+
useMockApi,
|
|
5378
|
+
userText,
|
|
5379
|
+
webSearchEnabled
|
|
5380
|
+
});
|
|
5381
|
+
if (streamingEnabled) {
|
|
5382
|
+
if (onTextChunk) {
|
|
5383
|
+
await onTextChunk(result.text);
|
|
5384
|
+
}
|
|
5385
|
+
if (onEventStreamFinished) {
|
|
5386
|
+
await onEventStreamFinished();
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
return result;
|
|
5390
|
+
} catch {
|
|
5391
|
+
// Fall back to the local implementation if coordinator worker RPC is unavailable.
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5325
5394
|
let text = '';
|
|
5326
5395
|
const usesOpenApiModel = isOpenApiModel(selectedModelId, models);
|
|
5327
5396
|
const usesOpenRouterModel = isOpenRouterModel(selectedModelId, models);
|
|
@@ -5444,7 +5513,7 @@ const get = async key => {
|
|
|
5444
5513
|
return getPreference(key);
|
|
5445
5514
|
};
|
|
5446
5515
|
const update = async settings => {
|
|
5447
|
-
await invoke('Preferences.update', settings);
|
|
5516
|
+
await invoke$1('Preferences.update', settings);
|
|
5448
5517
|
};
|
|
5449
5518
|
|
|
5450
5519
|
const setOpenApiApiKey = async (state, openApiApiKey, persist = true) => {
|
|
@@ -5489,6 +5558,7 @@ const handleClickSaveOpenApiApiKey = async state => {
|
|
|
5489
5558
|
mockAiResponseDelay: updatedState.mockAiResponseDelay,
|
|
5490
5559
|
mockApiCommandId: updatedState.mockApiCommandId,
|
|
5491
5560
|
models: updatedState.models,
|
|
5561
|
+
nextMessageId: updatedState.nextMessageId,
|
|
5492
5562
|
openApiApiBaseUrl: updatedState.openApiApiBaseUrl,
|
|
5493
5563
|
openApiApiKey: updatedState.openApiApiKey,
|
|
5494
5564
|
openRouterApiBaseUrl: updatedState.openRouterApiBaseUrl,
|
|
@@ -5496,6 +5566,7 @@ const handleClickSaveOpenApiApiKey = async state => {
|
|
|
5496
5566
|
platform: updatedState.platform,
|
|
5497
5567
|
selectedModelId: updatedState.selectedModelId,
|
|
5498
5568
|
streamingEnabled: updatedState.streamingEnabled,
|
|
5569
|
+
useChatCoordinatorWorker: updatedState.useChatCoordinatorWorker,
|
|
5499
5570
|
useChatNetworkWorkerForRequests: updatedState.useChatNetworkWorkerForRequests,
|
|
5500
5571
|
useMockApi: updatedState.useMockApi,
|
|
5501
5572
|
userText: previousUserMessage.text
|
|
@@ -5543,9 +5614,9 @@ const handleClickSaveOpenRouterApiKey = async state => {
|
|
|
5543
5614
|
...state,
|
|
5544
5615
|
openRouterApiKeyState: 'saving'
|
|
5545
5616
|
};
|
|
5546
|
-
set(state.uid, state, optimisticState);
|
|
5617
|
+
set$1(state.uid, state, optimisticState);
|
|
5547
5618
|
// @ts-ignore
|
|
5548
|
-
await invoke('Chat.rerender');
|
|
5619
|
+
await invoke$1('Chat.rerender');
|
|
5549
5620
|
const persistedState = await setOpenRouterApiKey(optimisticState, openRouterApiKey);
|
|
5550
5621
|
const updatedState = {
|
|
5551
5622
|
...persistedState,
|
|
@@ -5571,12 +5642,14 @@ const handleClickSaveOpenRouterApiKey = async state => {
|
|
|
5571
5642
|
mockAiResponseDelay: updatedState.mockAiResponseDelay,
|
|
5572
5643
|
mockApiCommandId: updatedState.mockApiCommandId,
|
|
5573
5644
|
models: updatedState.models,
|
|
5645
|
+
nextMessageId: updatedState.nextMessageId,
|
|
5574
5646
|
openApiApiBaseUrl: updatedState.openApiApiBaseUrl,
|
|
5575
5647
|
openApiApiKey: updatedState.openApiApiKey,
|
|
5576
5648
|
openRouterApiBaseUrl: updatedState.openRouterApiBaseUrl,
|
|
5577
5649
|
openRouterApiKey,
|
|
5578
5650
|
platform: updatedState.platform,
|
|
5579
5651
|
selectedModelId: updatedState.selectedModelId,
|
|
5652
|
+
useChatCoordinatorWorker: updatedState.useChatCoordinatorWorker,
|
|
5580
5653
|
useChatNetworkWorkerForRequests: updatedState.useChatNetworkWorkerForRequests,
|
|
5581
5654
|
useMockApi: updatedState.useMockApi,
|
|
5582
5655
|
userText: previousUserMessage.text
|
|
@@ -6507,6 +6580,7 @@ Assistant: ${assistantText}`;
|
|
|
6507
6580
|
mockAiResponseDelay: state.mockAiResponseDelay,
|
|
6508
6581
|
mockApiCommandId: state.mockApiCommandId,
|
|
6509
6582
|
models,
|
|
6583
|
+
nextMessageId: state.nextMessageId,
|
|
6510
6584
|
openApiApiBaseUrl,
|
|
6511
6585
|
openApiApiKey,
|
|
6512
6586
|
openRouterApiBaseUrl,
|
|
@@ -6515,6 +6589,7 @@ Assistant: ${assistantText}`;
|
|
|
6515
6589
|
platform: state.platform,
|
|
6516
6590
|
selectedModelId,
|
|
6517
6591
|
streamingEnabled: false,
|
|
6592
|
+
useChatCoordinatorWorker: state.useChatCoordinatorWorker,
|
|
6518
6593
|
useChatNetworkWorkerForRequests: state.useChatNetworkWorkerForRequests,
|
|
6519
6594
|
useMockApi,
|
|
6520
6595
|
userText: titlePrompt,
|
|
@@ -6666,9 +6741,9 @@ const handleTextChunkFunction = async (uid, assistantMessageId, chunk, handleTex
|
|
|
6666
6741
|
parsedMessages: updated.parsedMessages,
|
|
6667
6742
|
sessions: updated.sessions
|
|
6668
6743
|
};
|
|
6669
|
-
set(uid, handleTextChunkState.previousState, nextState);
|
|
6744
|
+
set$1(uid, handleTextChunkState.previousState, nextState);
|
|
6670
6745
|
// @ts-ignore
|
|
6671
|
-
await invoke('Chat.rerender');
|
|
6746
|
+
await invoke$1('Chat.rerender');
|
|
6672
6747
|
return {
|
|
6673
6748
|
latestState: nextState,
|
|
6674
6749
|
previousState: nextState
|
|
@@ -6695,9 +6770,9 @@ const handleToolCallsChunkFunction = async (uid, assistantMessageId, toolCalls,
|
|
|
6695
6770
|
parsedMessages: updated.parsedMessages,
|
|
6696
6771
|
sessions: updated.sessions
|
|
6697
6772
|
};
|
|
6698
|
-
set(uid, handleTextChunkState.previousState, nextState);
|
|
6773
|
+
set$1(uid, handleTextChunkState.previousState, nextState);
|
|
6699
6774
|
// @ts-ignore
|
|
6700
|
-
await invoke('Chat.rerender');
|
|
6775
|
+
await invoke$1('Chat.rerender');
|
|
6701
6776
|
return {
|
|
6702
6777
|
latestState: nextState,
|
|
6703
6778
|
previousState: nextState
|
|
@@ -6777,6 +6852,7 @@ const handleSubmit = async state => {
|
|
|
6777
6852
|
selectedSessionId,
|
|
6778
6853
|
sessions,
|
|
6779
6854
|
streamingEnabled,
|
|
6855
|
+
useChatCoordinatorWorker,
|
|
6780
6856
|
useChatNetworkWorkerForRequests,
|
|
6781
6857
|
useMockApi,
|
|
6782
6858
|
viewMode,
|
|
@@ -6882,9 +6958,9 @@ const handleSubmit = async state => {
|
|
|
6882
6958
|
sessions: updatedSessions
|
|
6883
6959
|
});
|
|
6884
6960
|
}
|
|
6885
|
-
set(state.uid, state, optimisticState);
|
|
6961
|
+
set$1(state.uid, state, optimisticState);
|
|
6886
6962
|
// @ts-ignore
|
|
6887
|
-
await invoke('Chat.rerender');
|
|
6963
|
+
await invoke$1('Chat.rerender');
|
|
6888
6964
|
let handleTextChunkState = {
|
|
6889
6965
|
latestState: optimisticState,
|
|
6890
6966
|
previousState: optimisticState
|
|
@@ -6903,6 +6979,7 @@ const handleSubmit = async state => {
|
|
|
6903
6979
|
mockAiResponseDelay,
|
|
6904
6980
|
mockApiCommandId,
|
|
6905
6981
|
models,
|
|
6982
|
+
nextMessageId: optimisticState.nextMessageId,
|
|
6906
6983
|
onDataEvent: async value => {
|
|
6907
6984
|
if (!emitStreamingFunctionCallEvents && isStreamingFunctionCallEvent(value)) {
|
|
6908
6985
|
return;
|
|
@@ -6937,6 +7014,7 @@ const handleSubmit = async state => {
|
|
|
6937
7014
|
platform,
|
|
6938
7015
|
selectedModelId,
|
|
6939
7016
|
streamingEnabled,
|
|
7017
|
+
useChatCoordinatorWorker,
|
|
6940
7018
|
useChatNetworkWorkerForRequests,
|
|
6941
7019
|
useMockApi,
|
|
6942
7020
|
userText,
|
|
@@ -7223,7 +7301,7 @@ const handleClickBack = async state => {
|
|
|
7223
7301
|
|
|
7224
7302
|
const handleClickClose = async () => {
|
|
7225
7303
|
// @ts-ignore
|
|
7226
|
-
await invoke('Layout.hideSecondarySideBar');
|
|
7304
|
+
await invoke$1('Layout.hideSecondarySideBar');
|
|
7227
7305
|
};
|
|
7228
7306
|
|
|
7229
7307
|
const handleClickDelete = async (state, sessionId = '') => {
|
|
@@ -7242,17 +7320,17 @@ const handleClickReadFile = async uri => {
|
|
|
7242
7320
|
if (!uri) {
|
|
7243
7321
|
return;
|
|
7244
7322
|
}
|
|
7245
|
-
await invoke('Main.openUri', uri);
|
|
7323
|
+
await invoke$1('Main.openUri', uri);
|
|
7246
7324
|
};
|
|
7247
7325
|
|
|
7248
7326
|
const handleClickSessionDebug = async state => {
|
|
7249
|
-
await invoke('Main.openUri', `chat-debug://${state.selectedSessionId}`);
|
|
7327
|
+
await invoke$1('Main.openUri', `chat-debug://${state.selectedSessionId}`);
|
|
7250
7328
|
return state;
|
|
7251
7329
|
};
|
|
7252
7330
|
|
|
7253
7331
|
const handleClickSettings = async () => {
|
|
7254
7332
|
// TODO
|
|
7255
|
-
await invoke('Main.openUri', 'app://settings.json');
|
|
7333
|
+
await invoke$1('Main.openUri', 'app://settings.json');
|
|
7256
7334
|
};
|
|
7257
7335
|
|
|
7258
7336
|
const handleDragEnter = async (state, name, hasFiles = true) => {
|
|
@@ -7465,7 +7543,7 @@ const handleKeyDown = async (state, key, shiftKey) => {
|
|
|
7465
7543
|
};
|
|
7466
7544
|
|
|
7467
7545
|
const handleMessagesContextMenu = async state => {
|
|
7468
|
-
await invoke('ContextMenu.show', 1234);
|
|
7546
|
+
await invoke$1('ContextMenu.show', 1234);
|
|
7469
7547
|
return state;
|
|
7470
7548
|
};
|
|
7471
7549
|
|
|
@@ -7534,7 +7612,7 @@ const createExtensionHostRpc = async () => {
|
|
|
7534
7612
|
|
|
7535
7613
|
const initialize = async () => {
|
|
7536
7614
|
const rpc = await createExtensionHostRpc();
|
|
7537
|
-
set$
|
|
7615
|
+
set$3(rpc);
|
|
7538
7616
|
};
|
|
7539
7617
|
|
|
7540
7618
|
const isObject = value => {
|
|
@@ -7690,6 +7768,15 @@ const loadStreamingEnabled = async () => {
|
|
|
7690
7768
|
}
|
|
7691
7769
|
};
|
|
7692
7770
|
|
|
7771
|
+
const loadUseChatCoordinatorWorker = async () => {
|
|
7772
|
+
try {
|
|
7773
|
+
const savedUseChatCoordinatorWorker = await get('chatView.useChatCoordinatorWorker');
|
|
7774
|
+
return typeof savedUseChatCoordinatorWorker === 'boolean' ? savedUseChatCoordinatorWorker : false;
|
|
7775
|
+
} catch {
|
|
7776
|
+
return false;
|
|
7777
|
+
}
|
|
7778
|
+
};
|
|
7779
|
+
|
|
7693
7780
|
const loadUseChatMathWorker = async () => {
|
|
7694
7781
|
try {
|
|
7695
7782
|
const savedUseChatMathWorker = await get('chatView.useChatMathWorker');
|
|
@@ -7718,7 +7805,7 @@ const loadVoiceDictationEnabled = async () => {
|
|
|
7718
7805
|
};
|
|
7719
7806
|
|
|
7720
7807
|
const loadPreferences = async () => {
|
|
7721
|
-
const [aiSessionTitleGenerationEnabled, composerDropEnabled, openApiApiKey, openRouterApiKey, emitStreamingFunctionCallEvents, streamingEnabled, passIncludeObfuscation, useChatMathWorker, useChatNetworkWorkerForRequests, voiceDictationEnabled] = await Promise.all([loadAiSessionTitleGenerationEnabled(), loadComposerDropEnabled(), loadOpenApiApiKey(), loadOpenRouterApiKey(), loadEmitStreamingFunctionCallEvents(), loadStreamingEnabled(), loadPassIncludeObfuscation(), loadUseChatMathWorker(), loadUseChatNetworkWorkerForRequests(), loadVoiceDictationEnabled()]);
|
|
7808
|
+
const [aiSessionTitleGenerationEnabled, composerDropEnabled, openApiApiKey, openRouterApiKey, emitStreamingFunctionCallEvents, streamingEnabled, passIncludeObfuscation, useChatCoordinatorWorker, useChatMathWorker, useChatNetworkWorkerForRequests, voiceDictationEnabled] = await Promise.all([loadAiSessionTitleGenerationEnabled(), loadComposerDropEnabled(), loadOpenApiApiKey(), loadOpenRouterApiKey(), loadEmitStreamingFunctionCallEvents(), loadStreamingEnabled(), loadPassIncludeObfuscation(), loadUseChatCoordinatorWorker(), loadUseChatMathWorker(), loadUseChatNetworkWorkerForRequests(), loadVoiceDictationEnabled()]);
|
|
7722
7809
|
return {
|
|
7723
7810
|
aiSessionTitleGenerationEnabled,
|
|
7724
7811
|
composerDropEnabled,
|
|
@@ -7727,6 +7814,7 @@ const loadPreferences = async () => {
|
|
|
7727
7814
|
openRouterApiKey,
|
|
7728
7815
|
passIncludeObfuscation,
|
|
7729
7816
|
streamingEnabled,
|
|
7817
|
+
useChatCoordinatorWorker,
|
|
7730
7818
|
useChatMathWorker,
|
|
7731
7819
|
useChatNetworkWorkerForRequests,
|
|
7732
7820
|
voiceDictationEnabled
|
|
@@ -7866,6 +7954,7 @@ const loadContent = async (state, savedState) => {
|
|
|
7866
7954
|
openRouterApiKey,
|
|
7867
7955
|
passIncludeObfuscation,
|
|
7868
7956
|
streamingEnabled,
|
|
7957
|
+
useChatCoordinatorWorker,
|
|
7869
7958
|
useChatMathWorker,
|
|
7870
7959
|
useChatNetworkWorkerForRequests,
|
|
7871
7960
|
voiceDictationEnabled
|
|
@@ -7941,6 +8030,7 @@ const loadContent = async (state, savedState) => {
|
|
|
7941
8030
|
selectedSessionId,
|
|
7942
8031
|
sessions,
|
|
7943
8032
|
streamingEnabled,
|
|
8033
|
+
useChatCoordinatorWorker,
|
|
7944
8034
|
useChatMathWorker,
|
|
7945
8035
|
useChatNetworkWorkerForRequests,
|
|
7946
8036
|
viewMode,
|
|
@@ -7962,6 +8052,11 @@ const mockOpenApiSetHttpErrorResponse = (state, statusCode, body) => {
|
|
|
7962
8052
|
return state;
|
|
7963
8053
|
};
|
|
7964
8054
|
|
|
8055
|
+
const mockOpenApiSetRequestFailedResponse = (state, isOffline = false) => {
|
|
8056
|
+
setRequestFailedResponse(isOffline);
|
|
8057
|
+
return state;
|
|
8058
|
+
};
|
|
8059
|
+
|
|
7965
8060
|
const mockOpenApiStreamFinish = state => {
|
|
7966
8061
|
finish();
|
|
7967
8062
|
return state;
|
|
@@ -8875,6 +8970,7 @@ const getMissingApiKeyDom = ({
|
|
|
8875
8970
|
}, text(saveButtonText), {
|
|
8876
8971
|
childCount: 1,
|
|
8877
8972
|
className: mergeClassNames(Button, ButtonSecondary),
|
|
8973
|
+
inputType: 'button',
|
|
8878
8974
|
name: openSettingsButtonName,
|
|
8879
8975
|
onClick: HandleClick,
|
|
8880
8976
|
type: Button$1
|
|
@@ -9971,7 +10067,7 @@ const render2 = (uid, diffResult) => {
|
|
|
9971
10067
|
newState,
|
|
9972
10068
|
oldState
|
|
9973
10069
|
} = get$1(uid);
|
|
9974
|
-
set(uid, newState, newState);
|
|
10070
|
+
set$1(uid, newState, newState);
|
|
9975
10071
|
const commands = applyRender(oldState, newState, diffResult);
|
|
9976
10072
|
return commands;
|
|
9977
10073
|
};
|
|
@@ -10138,7 +10234,9 @@ const reset = async state => {
|
|
|
10138
10234
|
composerHeight: getMinComposerHeightForState(state),
|
|
10139
10235
|
composerValue: '',
|
|
10140
10236
|
mockAiResponseDelay: 0,
|
|
10237
|
+
openApiApiKey: '',
|
|
10141
10238
|
openRouterApiKey: '',
|
|
10239
|
+
openRouterApiKeyInput: '',
|
|
10142
10240
|
selectedModelId: 'test',
|
|
10143
10241
|
selectedSessionId: '',
|
|
10144
10242
|
sessions: [],
|
|
@@ -10223,6 +10321,18 @@ const setStreamingEnabled = (state, streamingEnabled) => {
|
|
|
10223
10321
|
};
|
|
10224
10322
|
};
|
|
10225
10323
|
|
|
10324
|
+
const setUseChatCoordinatorWorker = async (state, useChatCoordinatorWorker, persist = true) => {
|
|
10325
|
+
if (persist) {
|
|
10326
|
+
await update({
|
|
10327
|
+
'chatView.useChatCoordinatorWorker': useChatCoordinatorWorker
|
|
10328
|
+
});
|
|
10329
|
+
}
|
|
10330
|
+
return {
|
|
10331
|
+
...state,
|
|
10332
|
+
useChatCoordinatorWorker
|
|
10333
|
+
};
|
|
10334
|
+
};
|
|
10335
|
+
|
|
10226
10336
|
const setUseChatMathWorker = async (state, useChatMathWorker, persist = true) => {
|
|
10227
10337
|
if (persist) {
|
|
10228
10338
|
await update({
|
|
@@ -10272,6 +10382,7 @@ const commandMap = {
|
|
|
10272
10382
|
'Chat.getKeyBindings': getKeyBindings,
|
|
10273
10383
|
'Chat.getMenuEntries': getMenuEntries,
|
|
10274
10384
|
'Chat.getMenuEntryIds': getMenuEntryIds,
|
|
10385
|
+
'Chat.getQuickPickMenuEntries': getQuickPickMenuEntries,
|
|
10275
10386
|
'Chat.getSelectedSessionId': wrapGetter(getSelectedSessionId),
|
|
10276
10387
|
'Chat.handleChatListContextMenu': handleChatListContextMenu,
|
|
10277
10388
|
'Chat.handleChatListScroll': wrapCommand(handleChatListScroll),
|
|
@@ -10304,6 +10415,7 @@ const commandMap = {
|
|
|
10304
10415
|
'Chat.mockOpenApiRequestGetAll': wrapGetter(mockOpenApiRequestGetAll),
|
|
10305
10416
|
'Chat.mockOpenApiRequestReset': wrapCommand(mockOpenApiRequestReset),
|
|
10306
10417
|
'Chat.mockOpenApiSetHttpErrorResponse': wrapCommand(mockOpenApiSetHttpErrorResponse),
|
|
10418
|
+
'Chat.mockOpenApiSetRequestFailedResponse': wrapCommand(mockOpenApiSetRequestFailedResponse),
|
|
10307
10419
|
'Chat.mockOpenApiStreamFinish': wrapCommand(mockOpenApiStreamFinish),
|
|
10308
10420
|
'Chat.mockOpenApiStreamPushChunk': wrapCommand(mockOpenApiStreamPushChunk),
|
|
10309
10421
|
'Chat.mockOpenApiStreamReset': wrapCommand(mockOpenApiStreamReset),
|
|
@@ -10319,12 +10431,25 @@ const commandMap = {
|
|
|
10319
10431
|
'Chat.setEmitStreamingFunctionCallEvents': wrapCommand(setEmitStreamingFunctionCallEvents),
|
|
10320
10432
|
'Chat.setOpenRouterApiKey': wrapCommand(setOpenRouterApiKey),
|
|
10321
10433
|
'Chat.setStreamingEnabled': wrapCommand(setStreamingEnabled),
|
|
10434
|
+
'Chat.setUseChatCoordinatorWorker': wrapCommand(setUseChatCoordinatorWorker),
|
|
10322
10435
|
'Chat.setUseChatMathWorker': wrapCommand(setUseChatMathWorker),
|
|
10323
10436
|
'Chat.setUseChatNetworkWorkerForRequests': wrapCommand(setUseChatNetworkWorkerForRequests),
|
|
10324
10437
|
'Chat.terminate': terminate,
|
|
10325
10438
|
'Chat.useMockApi': wrapCommand(useMockApi)
|
|
10326
10439
|
};
|
|
10327
10440
|
|
|
10441
|
+
const sendMessagePortToChatCoordinatorWorker = async port => {
|
|
10442
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
10443
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatCoordinatorWorker', port, command);
|
|
10444
|
+
};
|
|
10445
|
+
const initializeChatCoordinatorWorker = async () => {
|
|
10446
|
+
const rpc = await create$4({
|
|
10447
|
+
commandMap: {},
|
|
10448
|
+
send: sendMessagePortToChatCoordinatorWorker
|
|
10449
|
+
});
|
|
10450
|
+
set(rpc);
|
|
10451
|
+
};
|
|
10452
|
+
|
|
10328
10453
|
const sendMessagePortToChatMathWorker = async port => {
|
|
10329
10454
|
await sendMessagePortToChatMathWorker$1(port, 0);
|
|
10330
10455
|
};
|
|
@@ -10333,7 +10458,7 @@ const initializeChatMathWorker = async () => {
|
|
|
10333
10458
|
commandMap: {},
|
|
10334
10459
|
send: sendMessagePortToChatMathWorker
|
|
10335
10460
|
});
|
|
10336
|
-
set$
|
|
10461
|
+
set$5(rpc);
|
|
10337
10462
|
};
|
|
10338
10463
|
|
|
10339
10464
|
const send = port => {
|
|
@@ -10344,7 +10469,7 @@ const initializeChatNetworkWorker = async () => {
|
|
|
10344
10469
|
commandMap: {},
|
|
10345
10470
|
send
|
|
10346
10471
|
});
|
|
10347
|
-
set$
|
|
10472
|
+
set$4(rpc);
|
|
10348
10473
|
};
|
|
10349
10474
|
|
|
10350
10475
|
const listen = async () => {
|
|
@@ -10352,8 +10477,8 @@ const listen = async () => {
|
|
|
10352
10477
|
const rpc = await create$3({
|
|
10353
10478
|
commandMap: commandMap
|
|
10354
10479
|
});
|
|
10355
|
-
set$
|
|
10356
|
-
await Promise.all([initializeChatNetworkWorker(), initializeChatMathWorker()]);
|
|
10480
|
+
set$2(rpc);
|
|
10481
|
+
await Promise.all([initializeChatNetworkWorker(), initializeChatMathWorker(), initializeChatCoordinatorWorker()]);
|
|
10357
10482
|
};
|
|
10358
10483
|
|
|
10359
10484
|
const main = async () => {
|