@lvce-editor/chat-view 7.6.0 → 7.7.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.
@@ -2318,13 +2318,11 @@ const parseToolEnablement = value => {
2318
2318
  };
2319
2319
  const validateToolEnablement = value => {
2320
2320
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
2321
- // eslint-disable-next-line @typescript-eslint/only-throw-error
2322
2321
  throw new TypeError('Tool enablement must be an object map of tool names to booleans.');
2323
2322
  }
2324
2323
  const toolEnablement = {};
2325
2324
  for (const [key, enabled] of Object.entries(value)) {
2326
2325
  if (typeof enabled !== 'boolean') {
2327
- // eslint-disable-next-line @typescript-eslint/only-throw-error
2328
2326
  throw new TypeError(`Tool enablement for "${key}" must be a boolean.`);
2329
2327
  }
2330
2328
  toolEnablement[key] = enabled;
@@ -3919,6 +3917,7 @@ const openFolder = async () => {
3919
3917
  }
3920
3918
  };
3921
3919
 
3920
+ const isFileSystemEntry = entry => !!entry;
3922
3921
  const parseEntries = value => {
3923
3922
  if (!Array.isArray(value)) {
3924
3923
  return [];
@@ -3937,7 +3936,7 @@ const parseEntries = value => {
3937
3936
  };
3938
3937
  }
3939
3938
  return undefined;
3940
- }).filter(entry => !!entry);
3939
+ }).filter(isFileSystemEntry);
3941
3940
  };
3942
3941
 
3943
3942
  const getRelativePath = (fromPath, toPath) => {
@@ -3987,17 +3986,19 @@ const toGitUri = (baseUri, ...segments) => {
3987
3986
 
3988
3987
  const FileTypeFile = 1;
3989
3988
  const FileTypeDirectory = 2;
3990
- const collectBranchNames = async (workspaceUri, refsHeadsUri, prefix, branches) => {
3989
+ const collectBranchNames = async (workspaceUri, refsHeadsUri, prefix) => {
3991
3990
  const entries = await readDir(workspaceUri, refsHeadsUri);
3991
+ const branches = [];
3992
3992
  for (const entry of entries) {
3993
3993
  if (entry.type === FileTypeDirectory) {
3994
- await collectBranchNames(workspaceUri, toGitUri(refsHeadsUri, entry.name), `${prefix}${entry.name}/`, branches);
3994
+ branches.push(...(await collectBranchNames(workspaceUri, toGitUri(refsHeadsUri, entry.name), `${prefix}${entry.name}/`)));
3995
3995
  continue;
3996
3996
  }
3997
3997
  if (entry.type === FileTypeFile) {
3998
- branches.add(`${prefix}${entry.name}`);
3998
+ branches.push(`${prefix}${entry.name}`);
3999
3999
  }
4000
4000
  }
4001
+ return branches;
4001
4002
  };
4002
4003
 
4003
4004
  const decodeFileContent = content => {
@@ -4048,7 +4049,6 @@ const parseCurrentBranch = headContent => {
4048
4049
  const getGitBranches = async workspaceUri => {
4049
4050
  const gitDirUri = await getGitDirUri(workspaceUri);
4050
4051
  if (!gitDirUri) {
4051
- // eslint-disable-next-line @typescript-eslint/only-throw-error
4052
4052
  throw new globalThis.Error('Git repository not found.');
4053
4053
  }
4054
4054
  const branches = new Set();
@@ -4063,12 +4063,14 @@ const getGitBranches = async workspaceUri => {
4063
4063
  // Keep trying to discover branches from refs even if HEAD cannot be read.
4064
4064
  }
4065
4065
  try {
4066
- await collectBranchNames(workspaceUri, toGitUri(gitDirUri, 'refs', 'heads'), '', branches);
4066
+ const discoveredBranches = await collectBranchNames(workspaceUri, toGitUri(gitDirUri, 'refs', 'heads'), '');
4067
+ for (const branch of discoveredBranches) {
4068
+ branches.add(branch);
4069
+ }
4067
4070
  } catch {
4068
4071
  // Repositories without local refs should still open and surface any current branch we found.
4069
4072
  }
4070
4073
  if (branches.size === 0) {
4071
- // eslint-disable-next-line @typescript-eslint/only-throw-error
4072
4074
  throw new globalThis.Error('No local git branches found.');
4073
4075
  }
4074
4076
  return [...branches].toSorted((a, b) => a.localeCompare(b)).map(name => ({
@@ -4509,7 +4511,6 @@ const consumeNextLoginResponse = async () => {
4509
4511
  await new Promise(resolve => setTimeout(resolve, response.delay));
4510
4512
  }
4511
4513
  if (response.type === 'error') {
4512
- // eslint-disable-next-line @typescript-eslint/only-throw-error
4513
4514
  throw new Error(response.message);
4514
4515
  }
4515
4516
  return response.response;
@@ -4550,10 +4551,8 @@ const handleClickLogin = async state => {
4550
4551
  set(state.uid, state, signingInState);
4551
4552
  await invoke('Chat.rerender');
4552
4553
  }
4553
- let usedMockResponse = false;
4554
4554
  try {
4555
- usedMockResponse = hasPendingMockLoginResponse();
4556
- if (usedMockResponse) {
4555
+ if (hasPendingMockLoginResponse()) {
4557
4556
  const response = await consumeNextLoginResponse();
4558
4557
  if (!isLoginResponse(response)) {
4559
4558
  return {
@@ -4821,11 +4820,9 @@ const withWriteFileLineCounts = async (workerOutput, rawArguments) => {
4821
4820
  };
4822
4821
  const executeChatTool = async (name, rawArguments, options) => {
4823
4822
  if (!isToolEnabled(options.toolEnablement, name)) {
4824
- // eslint-disable-next-line @typescript-eslint/only-throw-error
4825
4823
  throw new Error(`Tool "${name}" is disabled in chat.toolEnablement preferences.`);
4826
4824
  }
4827
4825
  if (!options.useChatToolWorker) {
4828
- // eslint-disable-next-line @typescript-eslint/only-throw-error
4829
4826
  throw new Error('Chat tools must be executed in a web worker environment. Please set useChatToolWorker to true in the options.');
4830
4827
  }
4831
4828
  const executionOptions = {
@@ -6182,6 +6179,7 @@ const getResponseFromSseEvents = events => {
6182
6179
  return `data: ${data}\n\n`;
6183
6180
  });
6184
6181
  const stream = new ReadableStream({
6182
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6185
6183
  start(controller) {
6186
6184
  for (const chunk of chunks) {
6187
6185
  controller.enqueue(new TextEncoder().encode(chunk));
@@ -7281,10 +7279,11 @@ const getAiResponse = async ({
7281
7279
  const maxToolIterations = safeMaxToolCalls - 1;
7282
7280
  let previousResponseId;
7283
7281
  for (let i = 0; i <= maxToolIterations; i++) {
7282
+ const tools1 = await getBasicChatTools(agentMode, questionToolEnabled, toolEnablement);
7284
7283
  const request = {
7285
7284
  headers,
7286
7285
  method: 'POST',
7287
- payload: getOpenAiParams(openAiInput, modelId, streamingEnabled, passIncludeObfuscation, await getBasicChatTools(agentMode, questionToolEnabled, toolEnablement), agentMode === 'plan' ? false : webSearchEnabled, safeMaxToolCalls, systemPrompt, previousResponseId, reasoningEffort, supportsReasoningEffort),
7286
+ payload: getOpenAiParams(openAiInput, modelId, streamingEnabled, passIncludeObfuscation, tools1, agentMode === 'plan' ? false : webSearchEnabled, safeMaxToolCalls, systemPrompt, previousResponseId, reasoningEffort, supportsReasoningEffort),
7288
7287
  url: getOpenApiApiEndpoint(openApiApiBaseUrl)
7289
7288
  };
7290
7289
  capture(request);
@@ -9889,7 +9888,6 @@ const createExtensionHostRpc = async () => {
9889
9888
  });
9890
9889
  return rpc;
9891
9890
  } catch (error) {
9892
- // eslint-disable-next-line @typescript-eslint/only-throw-error
9893
9891
  throw new VError(error, `Failed to create extension host rpc`);
9894
9892
  }
9895
9893
  };
@@ -10685,6 +10683,35 @@ const openMockSession = async (state, mockSessionId, mockChatMessages, options)
10685
10683
  });
10686
10684
  };
10687
10685
 
10686
+ const getMockSession = index => {
10687
+ const sessionNumber = index + 1;
10688
+ return {
10689
+ id: `session-${sessionNumber}`,
10690
+ messages: [],
10691
+ title: `Chat ${sessionNumber}`
10692
+ };
10693
+ };
10694
+ const openMockSessions = async (state, count) => {
10695
+ if (!Number.isSafeInteger(count) || count < 0) {
10696
+ return state;
10697
+ }
10698
+ const sessions = Array.from({
10699
+ length: count
10700
+ }, (_, index) => getMockSession(index));
10701
+ return {
10702
+ ...state,
10703
+ chatListScrollTop: 0,
10704
+ composerAttachments: [],
10705
+ composerAttachmentsHeight: 0,
10706
+ listFocusedIndex: -1,
10707
+ parsedMessages: [],
10708
+ renamingSessionId: '',
10709
+ selectedSessionId: '',
10710
+ sessions,
10711
+ viewMode: 'list'
10712
+ };
10713
+ };
10714
+
10688
10715
  const pasteInput = async state => {
10689
10716
  const text = await readText();
10690
10717
  return handleInput(state, Composer, text, 'script');
@@ -14986,7 +15013,6 @@ const getRenderer = diffType => {
14986
15013
  case RenderValue:
14987
15014
  return renderValue;
14988
15015
  default:
14989
- // eslint-disable-next-line @typescript-eslint/only-throw-error
14990
15016
  throw new Error('unknown renderer');
14991
15017
  }
14992
15018
  };
@@ -15629,6 +15655,7 @@ const commandMap = {
15629
15655
  'Chat.openGitBranchPicker': wrapCommand(openGitBranchPicker),
15630
15656
  'Chat.openMockProject': wrapCommand(openMockProject),
15631
15657
  'Chat.openMockSession': wrapCommand(openMockSession),
15658
+ 'Chat.openMockSessions': wrapCommand(openMockSessions),
15632
15659
  'Chat.openModelPicker': wrapCommand(openModelPicker),
15633
15660
  'Chat.openReasoningEffortPicker': wrapCommand(openReasoningEffortPicker),
15634
15661
  'Chat.openRunModePicker': wrapCommand(openRunModePicker),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-view",
3
- "version": "7.6.0",
3
+ "version": "7.7.0",
4
4
  "description": "Chat View Worker",
5
5
  "repository": {
6
6
  "type": "git",