mirror of
https://github.com/voideditor/void
synced 2026-05-23 17:38:23 +00:00
fix cors progress
This commit is contained in:
parent
e4107e1257
commit
9ef1aa2c60
12 changed files with 118 additions and 349 deletions
|
|
@ -148,7 +148,7 @@ export class CodeApplication extends Disposable {
|
|||
@IStateService private readonly stateService: IStateService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@IUserDataProfilesMainService private readonly userDataProfilesMainService: IUserDataProfilesMainService
|
||||
@IUserDataProfilesMainService private readonly userDataProfilesMainService: IUserDataProfilesMainService,
|
||||
) {
|
||||
super();
|
||||
|
||||
|
|
@ -1181,6 +1181,10 @@ export class CodeApplication extends Disposable {
|
|||
const keyboardLayoutChannel = ProxyChannel.fromService(accessor.get(IKeyboardLayoutMainService), disposables);
|
||||
mainProcessElectronServer.registerChannel('keyboardLayout', keyboardLayoutChannel);
|
||||
|
||||
// Void
|
||||
const sendLLMMessageChannel = ProxyChannel.fromService(accessor.get(IEncryptionMainService), disposables);
|
||||
mainProcessElectronServer.registerChannel('sendLLMMessage', sendLLMMessageChannel);
|
||||
|
||||
// Native host (main & shared process)
|
||||
this.nativeHostMainService = accessor.get(INativeHostMainService);
|
||||
const nativeHostChannel = ProxyChannel.fromService(this.nativeHostMainService, disposables);
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
// This is from the old repo
|
||||
|
||||
// const tailwindcss = require('tailwindcss')
|
||||
// const autoprefixer = require('autoprefixer')
|
||||
// const postcss = require('postcss')
|
||||
// const fs = require('fs')
|
||||
|
||||
// const convertTailwindToCSS = ({ from, to }) => {
|
||||
// console.log('converting ', from, ' --> ', to)
|
||||
|
||||
// const original_css_contents = fs.readFileSync(from, 'utf8')
|
||||
|
||||
// return postcss([
|
||||
// tailwindcss, // this compiles tailwind of all the files specified in tailwind.config.json
|
||||
// autoprefixer,
|
||||
// ])
|
||||
// .process(original_css_contents, { from, to })
|
||||
// .then(processed_css_contents => { fs.writeFileSync(to, processed_css_contents.css) })
|
||||
// .catch(error => {
|
||||
// console.error('Error in build-css:', error)
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
// const esbuild = require('esbuild')
|
||||
|
||||
// const convertTSXtoJS = async ({ from, to }) => {
|
||||
// console.log('converting ', from, ' --> ', to)
|
||||
|
||||
// return esbuild.build({
|
||||
// entryPoints: [from],
|
||||
// bundle: true,
|
||||
// minify: true,
|
||||
// sourcemap: true,
|
||||
// outfile: to,
|
||||
// format: 'iife', // apparently iife is safe for browsers (safer than cjs)
|
||||
// platform: 'browser',
|
||||
// external: ['vscode'],
|
||||
// }).catch(() => process.exit(1));
|
||||
// }
|
||||
|
||||
// (async () => {
|
||||
// // convert tsx to js
|
||||
// await convertTSXtoJS({
|
||||
// from: 'src/webviews/sidebar/index.tsx',
|
||||
// to: 'dist/webviews/sidebar/index.js',
|
||||
// })
|
||||
|
||||
// await convertTSXtoJS({
|
||||
// from: 'src/webviews/ctrlk/index.tsx',
|
||||
// to: 'dist/webviews/ctrlk/index.js',
|
||||
// })
|
||||
|
||||
// await convertTSXtoJS({
|
||||
// from: 'src/webviews/diffline/index.tsx',
|
||||
// to: 'dist/webviews/diffline/index.js',
|
||||
// })
|
||||
|
||||
// // convert tailwind to css
|
||||
// await convertTailwindToCSS({
|
||||
// from: 'src/webviews/styles.css',
|
||||
// to: 'dist/webviews/styles.css',
|
||||
// })
|
||||
|
||||
// })()
|
||||
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
{
|
||||
"name": "void",
|
||||
"publisher": "void",
|
||||
"displayName": "Void",
|
||||
"description": "",
|
||||
"version": "0.0.1",
|
||||
"engines": {
|
||||
"vscode": "*"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"enabledApiProposals": [
|
||||
"editorInsets"
|
||||
],
|
||||
"activationEvents": [],
|
||||
"main": "./out/extension/extension.js",
|
||||
"contributes": {
|
||||
"configuration": {
|
||||
"title": "Void",
|
||||
"properties": {}
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"command": "typeInspector.inspect",
|
||||
"title": "Inspect Types of All Variables"
|
||||
},
|
||||
{
|
||||
"command": "void.ctrl+l",
|
||||
"title": "Show Sidebar"
|
||||
},
|
||||
{
|
||||
"command": "void.ctrl+k",
|
||||
"title": "Make Inline Edit"
|
||||
},
|
||||
{
|
||||
"command": "void.acceptDiff",
|
||||
"title": "Approve Diff"
|
||||
},
|
||||
{
|
||||
"command": "void.rejectDiff",
|
||||
"title": "Discard Diff"
|
||||
},
|
||||
{
|
||||
"command": "void.startNewThread",
|
||||
"title": "Start a new chat",
|
||||
"icon": "$(add)"
|
||||
},
|
||||
{
|
||||
"command": "void.toggleThreadSelector",
|
||||
"title": "View past chats",
|
||||
"icon": "$(history)"
|
||||
},
|
||||
{
|
||||
"command": "void.toggleSettings",
|
||||
"title": "Void settings",
|
||||
"icon": "$(settings-gear)"
|
||||
}
|
||||
],
|
||||
"viewsContainers": {
|
||||
"activitybar": [
|
||||
{
|
||||
"id": "voidViewContainer",
|
||||
"title": "Chat",
|
||||
"icon": "$(hubot)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"views": {
|
||||
"voidViewContainer": [
|
||||
{
|
||||
"type": "webview",
|
||||
"id": "void.viewnumberone",
|
||||
"name": "Void"
|
||||
}
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "void.ctrl+l",
|
||||
"key": "ctrl+l",
|
||||
"mac": "cmd+l"
|
||||
},
|
||||
{
|
||||
"command": "void.ctrl+k",
|
||||
"key": "ctrl+k",
|
||||
"mac": "cmd+k"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"view/title": [
|
||||
{
|
||||
"command": "void.startNewThread",
|
||||
"when": "view == 'void.viewnumberone'",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "void.toggleThreadSelector",
|
||||
"when": "view == 'void.viewnumberone'",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "void.toggleSettings",
|
||||
"when": "view == 'void.viewnumberone'",
|
||||
"group": "navigation"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"build": "rimraf dist && node build/build.js",
|
||||
"pretest": "tsc -p ./ && eslint src --ext ts",
|
||||
"test": "vscode-test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anthropic-ai/sdk": "^0.31.0",
|
||||
"@eslint/js": "^9.9.1",
|
||||
"@google/generative-ai": "^0.21.0",
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"@rrweb/types": "^2.0.0-alpha.17",
|
||||
"@types/diff": "^5.2.2",
|
||||
"@types/diff-match-patch": "^1.0.36",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/lodash": "^4.17.12",
|
||||
"@types/mocha": "^10.0.8",
|
||||
"@types/node": "^22.5.1",
|
||||
"@types/react": "^18.3.4",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
||||
"@typescript-eslint/parser": "^8.3.0",
|
||||
"@vscode/test-cli": "^0.0.10",
|
||||
"@vscode/test-electron": "2.4.1",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"esbuild": "^0.23.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-react": "^7.35.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.2",
|
||||
"globals": "^15.9.0",
|
||||
"lodash": "^4.17.21",
|
||||
"marked": "^14.1.0",
|
||||
"ollama": "^0.5.9",
|
||||
"openai": "^4.70.2",
|
||||
"postcss": "^8.4.41",
|
||||
"posthog-js": "^1.176.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-markdown": "^9.0.1",
|
||||
"react-syntax-highlighter": "^15.6.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"rrweb-snapshot": "^2.0.0-alpha.4",
|
||||
"tailwindcss": "^3.4.10",
|
||||
"typescript": "5.5.4",
|
||||
"typescript-eslint": "^8.3.0",
|
||||
"uuid": "^10.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"lru-cache": "^11.0.2",
|
||||
"tree-sitter": "^0.21.1",
|
||||
"tree-sitter-javascript": "^0.23.1",
|
||||
"tree-sitter-python": "^0.23.4"
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ import { Ollama } from 'ollama/browser'
|
|||
import { Content, GoogleGenerativeAI, GoogleGenerativeAIFetchError } from '@google/generative-ai';
|
||||
import { posthog } from 'posthog-js'
|
||||
import type { VoidConfig } from '../../../registerConfig.js';
|
||||
import type { LLMMessage, LLMMessageOnText, OnFinalMessage, SendLLMMessageFnType, } from '../../../registerSendLLMMessage.js';
|
||||
import type { LLMMessage, LLMMessageOnText, OnFinalMessage, SendLLMMessageFnType, } from '../../../../../../services/void/browser/sendLLMMessage.js';
|
||||
|
||||
type SendLLMMessageFnTypeInternal = (params: {
|
||||
messages: LLMMessage[];
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import { ICodeEditor, IOverlayWidget, IViewZone } from '../../../../editor/brows
|
|||
|
||||
// import { IUndoRedoService } from '../../../../platform/undoRedo/common/undoRedo.js';
|
||||
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
|
||||
import { sendLLMMessage } from './react/out/util/sendLLMMessage.js';
|
||||
// import { throttle } from '../../../../base/common/decorators.js';
|
||||
import { IVoidConfigStateService } from './registerConfig.js';
|
||||
import { writeFileWithDiffInstructions } from './prompt/systemPrompts.js';
|
||||
|
|
@ -29,6 +28,8 @@ import { ILanguageService } from '../../../../editor/common/languages/language.j
|
|||
import * as dom from '../../../../base/browser/dom.js';
|
||||
import { Widget } from '../../../../base/browser/ui/widget.js';
|
||||
import { URI } from '../../../../base/common/uri.js';
|
||||
import { ISendLLMMessageService } from '../../../services/void/common/sendLLMMessage.js';
|
||||
// import { sendLLMMessage } from './react/out/util/sendLLMMessage.js';
|
||||
|
||||
|
||||
// gets converted to --vscode-void-greenBG, see void.css
|
||||
|
|
@ -148,6 +149,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
|
|||
@IModelService private readonly _modelService: IModelService,
|
||||
@IUndoRedoService private readonly _undoRedoService: IUndoRedoService, // undoRedo service is the history of pressing ctrl+z
|
||||
@ILanguageService private readonly _langService: ILanguageService,
|
||||
@ISendLLMMessageService private readonly _sendLLMMessageService: ISendLLMMessageService,
|
||||
) {
|
||||
super();
|
||||
|
||||
|
|
@ -729,7 +731,7 @@ Please finish writing the new file by applying the diff to the original file. Re
|
|||
|
||||
const abortRef = { current: null } as { current: null | (() => void) }
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
sendLLMMessage({
|
||||
this._sendLLMMessageService.sendLLMMessage({
|
||||
logging: { loggingName: 'streamChunk' },
|
||||
messages: [
|
||||
{ role: 'system', content: writeFileWithDiffInstructions, },
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Glass Devtools, Inc. All rights reserved.
|
||||
* Void Editor additions licensed under the AGPLv3 License.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable } from '../../../../base/common/lifecycle.js';
|
||||
import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js';
|
||||
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
import { Server as UtilityProcessServer } from '../../../../base/parts/ipc/node/ipc.mp.js';
|
||||
import { IChannel, IServerChannel, StaticRouter } from '../../../../base/parts/ipc/common/ipc.js';
|
||||
import { Event } from '../../../../base/common/event.js';
|
||||
import { VoidConfig } from './registerConfig.js';
|
||||
|
||||
export type LLMMessageAbortRef = { current: (() => void) | null }
|
||||
|
||||
export type LLMMessageOnText = (newText: string, fullText: string) => void
|
||||
|
||||
export type OnFinalMessage = (input: string) => void
|
||||
|
||||
export type LLMMessage = {
|
||||
role: 'system' | 'user' | 'assistant';
|
||||
content: string;
|
||||
}
|
||||
|
||||
export type SendLLMMessageFnType = (params: {
|
||||
messages: LLMMessage[];
|
||||
onText: LLMMessageOnText;
|
||||
onFinalMessage: (fullText: string) => void;
|
||||
onError: (error: Error | string) => void;
|
||||
voidConfig: VoidConfig | null;
|
||||
abortRef: LLMMessageAbortRef;
|
||||
|
||||
logging: {
|
||||
loggingName: string,
|
||||
};
|
||||
}) => void
|
||||
|
||||
export const ISendLLMMessageService = createDecorator<ISendLLMMessageService>('sendLLMMessageService');
|
||||
|
||||
export interface ISendLLMMessageService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
sendMessage(params: {
|
||||
messages: LLMMessage[];
|
||||
onText: LLMMessageOnText;
|
||||
onFinalMessage: OnFinalMessage;
|
||||
onError: (error: Error | string) => void;
|
||||
voidConfig: VoidConfig;
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
||||
class SendLLMMessageChannel implements IServerChannel {
|
||||
constructor() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
listen<T>(_: unknown, event: string): Event<T> {
|
||||
throw new Error('No events available');
|
||||
}
|
||||
|
||||
call(context: any, command: string, args?: any[]): Promise<any> {
|
||||
switch (command) {
|
||||
case 'sendMessage':
|
||||
console.log('ARGS', args)
|
||||
// this.service.sendMessage(args![0]);
|
||||
default:
|
||||
throw new Error(`Invalid command ${command}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SendLLMMessageService extends Disposable implements ISendLLMMessageService {
|
||||
_serviceBrand: undefined;
|
||||
private readonly server: UtilityProcessServer;
|
||||
private channel: IChannel | undefined;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// Create the utility process server
|
||||
this.server = this._register(new UtilityProcessServer());
|
||||
|
||||
// Register our channel
|
||||
this.server.registerChannel('sendLLMMessage', new SendLLMMessageChannel());
|
||||
|
||||
// Get the channel from the utility process
|
||||
this.channel = this.server.getChannel('sendLLMMessage', new StaticRouter(() => true));
|
||||
}
|
||||
|
||||
async sendMessage(params: {
|
||||
messages: LLMMessage[];
|
||||
onText: LLMMessageOnText;
|
||||
onFinalMessage: OnFinalMessage;
|
||||
onError: (error: Error | string) => void;
|
||||
voidConfig: VoidConfig;
|
||||
}): Promise<void> {
|
||||
if (!this.channel) {
|
||||
throw new Error('LLM Message service not initialized');
|
||||
}
|
||||
|
||||
try {
|
||||
await this.channel.call('sendMessage', [params]);
|
||||
} catch (error) {
|
||||
params.onError(error instanceof Error ? error : new Error(String(error)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(ISendLLMMessageService, SendLLMMessageService, InstantiationType.Eager);
|
||||
59
src/vs/workbench/services/void/browser/sendLLMMessage.ts
Normal file
59
src/vs/workbench/services/void/browser/sendLLMMessage.ts
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Glass Devtools, Inc. All rights reserved.
|
||||
* Void Editor additions licensed under the AGPLv3 License.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { VoidConfig } from '../../../contrib/void/browser/registerConfig.js';
|
||||
import { ISendLLMMessageService } from '../common/sendLLMMessage.js';
|
||||
import { ProxyChannel } from '../../../../base/parts/ipc/common/ipc.js';
|
||||
import { IMainProcessService } from '../../../../platform/ipc/common/mainProcessService.js';
|
||||
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
|
||||
|
||||
export type LLMMessageAbortRef = { current: (() => void) | null }
|
||||
|
||||
export type LLMMessageOnText = (newText: string, fullText: string) => void
|
||||
|
||||
export type OnFinalMessage = (input: string) => void
|
||||
|
||||
export type LLMMessage = {
|
||||
role: 'system' | 'user' | 'assistant';
|
||||
content: string;
|
||||
}
|
||||
|
||||
export type SendLLMMessageFnType = (params: {
|
||||
messages: LLMMessage[];
|
||||
onText: LLMMessageOnText;
|
||||
onFinalMessage: (fullText: string) => void;
|
||||
onError: (error: Error | string) => void;
|
||||
voidConfig: VoidConfig | null;
|
||||
abortRef: LLMMessageAbortRef;
|
||||
|
||||
logging: {
|
||||
loggingName: string,
|
||||
};
|
||||
}) => void
|
||||
|
||||
|
||||
// BROWSER IMPLEMENTATION OF SENDLLMMESSAGE
|
||||
// Uses a proxy to the actual Node implementation of SendLLMMessageService
|
||||
|
||||
export class SendLLMMessageService implements ISendLLMMessageService {
|
||||
static readonly ID = 'void.contrib.browserSendLLMMessageService';
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
readonly _proxySendLLMService: ISendLLMMessageService
|
||||
|
||||
constructor(
|
||||
@IMainProcessService mainProcessService: IMainProcessService
|
||||
) {
|
||||
this._proxySendLLMService = ProxyChannel.toService<ISendLLMMessageService>(mainProcessService.getChannel('sendLLMMessage'));
|
||||
}
|
||||
|
||||
sendLLMMessage(data: any): Promise<any> {
|
||||
return this._proxySendLLMService.sendLLMMessage(data);
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(ISendLLMMessageService, SendLLMMessageService, InstantiationType.Delayed);
|
||||
|
||||
14
src/vs/workbench/services/void/common/sendLLMMessage.ts
Normal file
14
src/vs/workbench/services/void/common/sendLLMMessage.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// void/common/sendLLMMessage.ts
|
||||
|
||||
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
|
||||
export const ISendLLMMessageService = createDecorator<ISendLLMMessageService>('sendLLMMessageService');
|
||||
|
||||
// defines an interface that node/ creates and browser/ uses
|
||||
export interface ISendLLMMessageService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
sendLLMMessage(data: any): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
|
||||
import { ISendLLMMessageService } from '../common/sendLLMMessage.js';
|
||||
|
||||
|
||||
// NODE IMPLEMENTATION OF SENDLLMMESSAGE
|
||||
|
||||
export class SendLLMMessageService implements ISendLLMMessageService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
async sendLLMMessage(data: any): Promise<any> {
|
||||
console.log('NODE sendLLMMessage', data);
|
||||
// Your existing logic to send a message to the server
|
||||
// For example:
|
||||
// return fetch('https://your-server.com/api', { method: 'POST', body: JSON.stringify(data) });
|
||||
}
|
||||
}
|
||||
registerSingleton(ISendLLMMessageService, SendLLMMessageService, InstantiationType.Delayed);
|
||||
|
|
@ -14,7 +14,7 @@ import './browser/workbench.contribution.js';
|
|||
|
||||
|
||||
|
||||
//#region --- void
|
||||
//#region --- Void
|
||||
// Void added this:
|
||||
import './contrib/void/browser/void.contribution.js';
|
||||
//#endregion
|
||||
|
|
|
|||
|
|
@ -32,6 +32,15 @@ import './electron-sandbox/parts/dialogs/dialog.contribution.js';
|
|||
//#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
//#region --- Void
|
||||
// Void added this (modeling off of import '.*clipboardservice.js'):
|
||||
import './services/void/electron-sandbox/sendLLMMessage.js';
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
//#region --- workbench services
|
||||
|
||||
import './services/textfile/electron-sandbox/nativeTextFileService.js';
|
||||
|
|
|
|||
|
|
@ -32,6 +32,14 @@ import './browser/web.main.js';
|
|||
//#endregion
|
||||
|
||||
|
||||
|
||||
//#region --- Void
|
||||
// Void added this (modeling off of import '.*clipboardservice.js'):
|
||||
import './services/void/browser/sendLLMMessage.js';
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
//#region --- workbench services
|
||||
|
||||
import './services/integrity/browser/integrityService.js';
|
||||
|
|
|
|||
Loading…
Reference in a new issue