feat(duckdb): move support to standalone driver

This commit is contained in:
t8y2 committed 2026-07-30 00:50:39 +08:00
1 parent ed018dbc77
commit d347c77c3d
76 files changed
+5400 -8258

No files matched your search

+3 -3
View File
@@ -483,8 +483,8 @@ export async function upgradeAllAgents(_source?: UpdateDownloadSource, operation
return post("/api/agents/upgrade-all", { operationId });
}
export async function checkAgentUpdateBlockers(_dbTypes: string[]): Promise<AgentUpdateBlocker[]> {
return [];
export async function checkAgentUpdateBlockers(dbTypes: string[]): Promise<AgentUpdateBlocker[]> {
return post("/api/agents/update-blockers", { dbTypes });
}
export async function uninstallAgent(dbType: string): Promise<void> {
@@ -505,7 +505,7 @@ export async function invalidateAgentRegistryCache(): Promise<void> {
export async function importAgentsFromZip(fileOrPath: string | File, operationId?: string): Promise<number> {
if (typeof fileOrPath === "string") {
throw new Error("Offline ZIP import in web mode requires a File object, not a file path");
throw new Error("Offline package import in web mode requires a File object, not a file path");
}
const formData = new FormData();
if (operationId) formData.append("operationId", operationId);
+1 -1
View File
@@ -1740,7 +1740,7 @@ export async function invalidateAgentRegistryCache(): Promise<void> {
export async function importAgentsFromZip(path: string | File, operationId?: string): Promise<number> {
if (typeof path !== "string") {
throw new Error("Desktop offline ZIP import requires a local file path");
throw new Error("Desktop offline package import requires a local file path");
}
return invoke("import_agents_from_zip", { path, operationId });
}
@@ -1,5 +1,13 @@
import { describe, expect, it } from "vitest";
import { driverStoreFocusForInstallError, hasInstalledAgentVersion } from "@/lib/connection/agentDriverInstallHint";
import { agentDriverInstallKey, driverStoreFocusForInstallError, hasInstalledAgentVersion, showAgentDriverInstallHint } from "@/lib/connection/agentDriverInstallHint";
describe("DuckDB driver installation", () => {
it("requires the downloadable DuckDB driver before connecting", () => {
expect(agentDriverInstallKey("duckdb")).toBe("duckdb");
expect(showAgentDriverInstallHint("duckdb", [])).toBe(true);
expect(showAgentDriverInstallHint("duckdb", [{ db_type: "duckdb", installed: true }])).toBe(false);
});
});
describe("driverStoreFocusForInstallError", () => {
it("focuses the missing agent driver for driver-not-installed errors", () => {
@@ -10,7 +10,7 @@ describe("getCategoryForAgentDriver", () => {
// domestic
expect(getCategoryForAgentDriver("dameng")).toBe("domestic");
// lightweight
expect(getCategoryForAgentDriver("access")).toBe("lightweight");
expect(getCategoryForAgentDriver("duckdb")).toBe("lightweight");
// document
expect(getCategoryForAgentDriver("mongodb")).toBe("document");
// graph_ai
@@ -69,8 +69,8 @@ describe("AGENT_DRIVER_CATEGORY_MAP integrity", () => {
it("covers all known agent driver keys with no stale entries", () => {
// Golden set — mirrors the store-visible entries in agent_catalog.rs
// plus EXTRA_DRIVER_STORE_ENTRIES (kafka, rocketmq, rabbitmq,
// sqlserver-legacy) and the PrestoSQL built-in driver.
// plus EXTRA_DRIVER_STORE_ENTRIES (duckdb, kafka, rocketmq,
// rabbitmq, sqlserver-legacy) and the PrestoSQL built-in driver.
// When an Agent driver is added to the catalog its key MUST appear here;
// removing a key from the map without removing it from the list below
// will fail this test.
@@ -112,6 +112,7 @@ describe("AGENT_DRIVER_CATEGORY_MAP integrity", () => {
"yashandb",
// lightweight
"access",
"duckdb",
"h2",
"h2-legacy",
// document
@@ -24,6 +24,7 @@ export const AGENT_DRIVER_CATEGORY_MAP: Readonly<Record<string, DriverCategoryKe
databend: "analytics",
databricks: "analytics",
db2: "sql",
duckdb: "lightweight",
etcd: "registry_config",
exasol: "analytics",
firebird: "sql",
@@ -2,15 +2,16 @@ import { describe, expect, it } from "vitest";
import { isOfflineDriverPackage, webDriverImportAccept } from "./driverImportSelection";
describe("driver import selection", () => {
it("recognizes ZIP paths and uploaded files case-insensitively", () => {
it("recognizes ZIP and tar.zst packages case-insensitively", () => {
expect(isOfflineDriverPackage("C:\\Downloads\\dbx-agent-h2-0.2.5.ZIP")).toBe(true);
expect(isOfflineDriverPackage({ name: "dbx-agent-kingbase-0.1.34-macos-aarch64.zip" })).toBe(true);
expect(isOfflineDriverPackage({ name: "dbx-agent-duckdb-0.1.0-macos-aarch64.TAR.ZST" })).toBe(true);
expect(isOfflineDriverPackage({ name: "dbx-agent-h2-0.2.5.jar" })).toBe(false);
});
it("allows ZIP alongside the platform raw artifact", () => {
expect(webDriverImportAccept(true, false)).toBe(".zip,.jar");
expect(webDriverImportAccept(false, true)).toBe(".zip,.exe");
expect(webDriverImportAccept(true, false)).toBe(".zip,.tar.zst,.jar");
expect(webDriverImportAccept(false, true)).toBe(".zip,.tar.zst,.exe");
expect(webDriverImportAccept(false, false)).toBe("");
});
});
@@ -2,10 +2,11 @@ export type DriverImportSelection = string | { name: string };
export function isOfflineDriverPackage(selection: DriverImportSelection): boolean {
const name = typeof selection === "string" ? selection : selection.name;
return name.toLowerCase().endsWith(".zip");
const lowerName = name.toLowerCase();
return lowerName.endsWith(".zip") || lowerName.endsWith(".tar.zst");
}
export function webDriverImportAccept(requiresJavaRuntime: boolean, isWindows: boolean): string {
if (requiresJavaRuntime) return ".zip,.jar";
return isWindows ? ".zip,.exe" : "";
if (requiresJavaRuntime) return ".zip,.tar.zst,.jar";
return isWindows ? ".zip,.tar.zst,.exe" : "";
}