同步完整源码至远程:扁平化重构现状 + 未入库源文件
- 补入库:server/internal/db/dump.go、redis 分页/扫描预算测试、opsxdb-mcp main_test、 packages/opsxdb-mcp package-lock、docs 审计与对比文档等 37 个新文件 - 含结构扁平化进行中的 80 处修改与 155 处旧结构删除(server/ src/ src-tauri/ 为当前有效源) - 构建产物(bin/target/dist)与签名私钥仍按规则排除
This commit is contained in:
1 parent
5c0be49217
commit
2c0bfafd8d
269 files changed
+10372
-16435
No files matched your search
+29
-12
@@ -838,17 +838,32 @@ export async function getAiConfig(signal?: AbortSignal) {
|
||||
}
|
||||
|
||||
|
||||
/** 桌面连接双写到 ~/.opsxdb/connections.json,供 MCP 进程读取(P0)。失败不抛,避免挡保存。 */
|
||||
export async function syncConnectionsToDisk(connections: SavedConnection[]): Promise<void> {
|
||||
try {
|
||||
await fetch(`${API}/api/db/connections-store`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json", ...authHeaders() },
|
||||
body: JSON.stringify({ connections }),
|
||||
});
|
||||
} catch {
|
||||
/* 后端未起时忽略 */
|
||||
}
|
||||
let connectionSyncQueue: Promise<void> = Promise.resolve();
|
||||
|
||||
/** 按顺序同步桌面连接;Agent 必须等待成功,避免旧快照覆盖最新连接。 */
|
||||
export function syncConnectionsToDisk(connections: SavedConnection[]): Promise<void> {
|
||||
const body = JSON.stringify({ connections });
|
||||
const sync = connectionSyncQueue.catch(() => {}).then(async () => {
|
||||
const controller = new AbortController();
|
||||
const timer = setTimeout(() => controller.abort(), 10000);
|
||||
try {
|
||||
const res = await fetch(`${API}/api/db/connections-store`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json", ...authHeaders() },
|
||||
body,
|
||||
signal: controller.signal,
|
||||
});
|
||||
if (!res.ok) throw new Error(`本机服务返回 ${res.status}`);
|
||||
const result = await res.json();
|
||||
if (result?.ok !== true) throw new Error("本机服务未确认连接已保存");
|
||||
} catch (e) {
|
||||
throw new Error(`连接同步失败,Agent 尚未执行任务:${controller.signal.aborted ? "本机服务响应超时" : e instanceof Error ? e.message : String(e)}`);
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
});
|
||||
connectionSyncQueue = sync;
|
||||
return sync;
|
||||
}
|
||||
|
||||
export async function loadConnectionsFromDisk(): Promise<SavedConnection[] | null> {
|
||||
@@ -914,7 +929,9 @@ export async function driverStatus() {
|
||||
const res = await fetch(`${API}/api/drivers/status`);
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error((data as { error?: string }).error || res.statusText);
|
||||
return (data as { drivers: DriverStatusItem[] }).drivers;
|
||||
const drivers = (data as { drivers?: DriverStatusItem[] }).drivers;
|
||||
if (!Array.isArray(drivers)) throw new Error("本机服务未提供驱动状态,请重启桌面应用后重试");
|
||||
return drivers;
|
||||
}
|
||||
|
||||
export async function driverInstall(driver: string) {
|
||||
|
||||
Reference in new issue
Block a user