Add experimental Lingma remote backend

This commit is contained in:
lutc5
2026-04-30 12:09:51 +08:00
parent 1c188fcf17
commit 2bcb0a6715
15 changed files with 1543 additions and 37 deletions

View File

@@ -260,9 +260,13 @@ func (a *App) saveConfig(cfg service.Config) error {
fileCfg := map[string]any{
"host": cfg.Host,
"port": cfg.Port,
"backend": string(cfg.Backend),
"transport": string(cfg.Transport),
"pipe": cfg.Pipe,
"websocket_url": cfg.WebSocketURL,
"remote_base_url": cfg.RemoteBaseURL,
"remote_auth_file": cfg.RemoteAuthFile,
"remote_version": cfg.RemoteVersion,
"cwd": cfg.Cwd,
"current_file_path": cfg.CurrentFilePath,
"mode": cfg.Mode,
@@ -510,6 +514,7 @@ func defaultConfig() service.Config {
cfg := service.Config{
Host: "127.0.0.1",
Port: 8095,
Backend: service.BackendIPC,
Transport: lingmaipc.TransportAuto,
Cwd: defaultCwd(),
Mode: "agent",
@@ -527,9 +532,13 @@ func defaultConfig() service.Config {
var fileCfg struct {
Host string `json:"host"`
Port int `json:"port"`
Backend string `json:"backend"`
Transport string `json:"transport"`
Pipe string `json:"pipe"`
WebSocketURL string `json:"websocket_url"`
RemoteBaseURL string `json:"remote_base_url"`
RemoteAuthFile string `json:"remote_auth_file"`
RemoteVersion string `json:"remote_version"`
Cwd string `json:"cwd"`
CurrentFilePath string `json:"current_file_path"`
Mode string `json:"mode"`
@@ -545,6 +554,9 @@ func defaultConfig() service.Config {
if fileCfg.Port > 0 {
cfg.Port = fileCfg.Port
}
if fileCfg.Backend != "" {
cfg.Backend = service.BackendMode(fileCfg.Backend)
}
if fileCfg.Transport != "" {
if t, err := lingmaipc.ParseTransport(fileCfg.Transport); err == nil {
cfg.Transport = t
@@ -556,6 +568,15 @@ func defaultConfig() service.Config {
if fileCfg.WebSocketURL != "" {
cfg.WebSocketURL = fileCfg.WebSocketURL
}
if fileCfg.RemoteBaseURL != "" {
cfg.RemoteBaseURL = fileCfg.RemoteBaseURL
}
if fileCfg.RemoteAuthFile != "" {
cfg.RemoteAuthFile = fileCfg.RemoteAuthFile
}
if fileCfg.RemoteVersion != "" {
cfg.RemoteVersion = fileCfg.RemoteVersion
}
if fileCfg.Cwd != "" {
cfg.Cwd = fileCfg.Cwd
}

View File

@@ -222,7 +222,7 @@ onUnmounted(() => {
<span class="status-dot" :class="{ running: status.running }"></span>
<div>
<strong>{{ status.running ? 'Proxy Running' : 'Proxy Stopped' }}</strong>
<small>v1.3.2</small>
<small>v1.4.0</small>
</div>
</div>
</aside>

View File

@@ -9,6 +9,10 @@ const saving = ref(false)
const openSelect = ref('')
const selectOptions = {
Backend: [
{ value: 'ipc', label: 'IPC 插件' },
{ value: 'remote', label: '远端 API' },
],
Transport: [
{ value: 'auto', label: '自动' },
{ value: 'pipe', label: '命名管道' },
@@ -88,6 +92,26 @@ async function save() {
</div>
</div>
<div class="form-grid">
<div class="field">
<label>连接模式</label>
<div class="custom-select" :class="{ open: openSelect === 'Backend' }">
<button type="button" @click="toggleSelect('Backend')">
<span>{{ selectLabel('Backend') }}</span>
<i class="bi bi-chevron-down" aria-hidden="true"></i>
</button>
<div v-if="openSelect === 'Backend'" class="select-menu">
<button
v-for="option in selectOptions.Backend"
:key="option.value"
:class="{ selected: option.value === config.Backend }"
type="button"
@click="chooseOption('Backend', option.value)"
>
{{ option.label }}
</button>
</div>
</div>
</div>
<div class="field">
<label>主机</label>
<input v-model="config.Host" type="text" placeholder="127.0.0.1" />
@@ -128,10 +152,22 @@ async function save() {
<label>命名管道</label>
<input v-model="config.Pipe" type="text" placeholder="留空自动探测 Windows Named Pipe" />
</div>
<div class="field span-2">
<label>远端 API 域名</label>
<input v-model="config.RemoteBaseURL" type="text" placeholder="留空自动探测,默认 https://lingma.alibabacloud.com" />
</div>
<div class="field span-2">
<label>远端认证文件</label>
<input v-model="config.RemoteAuthFile" type="text" placeholder="可选 credentials.json留空只读 ~/.lingma/cache/user" />
</div>
<div class="field span-2">
<label>远端 Cosy 版本</label>
<input v-model="config.RemoteVersion" type="text" placeholder="默认 2.11.2" />
</div>
</div>
<div class="hint-box">
<strong>自动探测失败时</strong>
<span>先确认 VS Code / Lingma 插件已启动并登录macOS 通常填写 WebSocket例如 <code>ws://127.0.0.1:36510/</code>Windows 可填写命名管道,例如 <code>\\.\pipe\lingma-xxxx</code>,也可填写 WebSocket例如 <code>ws://127.0.0.1:36510/</code>。</span>
<span>IPC 模式先确认 VS Code / Lingma 插件已启动并登录远端 API 模式会优先读取认证文件留空时只读 <code>~/.lingma/cache/user</code></span>
</div>
</div>

View File

@@ -66,9 +66,13 @@ export namespace service {
export class Config {
Host: string;
Port: number;
Backend: string;
Transport: string;
Pipe: string;
WebSocketURL: string;
RemoteBaseURL: string;
RemoteAuthFile: string;
RemoteVersion: string;
Cwd: string;
CurrentFilePath: string;
Mode: string;
@@ -85,9 +89,13 @@ export namespace service {
if ('string' === typeof source) source = JSON.parse(source);
this.Host = source["Host"];
this.Port = source["Port"];
this.Backend = source["Backend"];
this.Transport = source["Transport"];
this.Pipe = source["Pipe"];
this.WebSocketURL = source["WebSocketURL"];
this.RemoteBaseURL = source["RemoteBaseURL"];
this.RemoteAuthFile = source["RemoteAuthFile"];
this.RemoteVersion = source["RemoteVersion"];
this.Cwd = source["Cwd"];
this.CurrentFilePath = source["CurrentFilePath"];
this.Mode = source["Mode"];

View File

@@ -11,6 +11,6 @@
"email": "lutc5@asiainfo.com"
},
"info": {
"productVersion": "1.3.2"
"productVersion": "1.4.0"
}
}