@downcity/city/local
Use City's local database, paths, repositories, environment assembly, and Power loader.
@downcity/city/local provides the local host capabilities shared by the CLI and Desktop:
the SQLite adapter, paths, product schemas, repositories, environment assembly, and Power loader.
import {
LocalDatabase,
AgentRepository,
WorkspaceRepository,
ensure_local_schema,
} from "@downcity/city/local";
const database = new LocalDatabase({ filename: database_path });
ensure_local_schema(database);
const workspaces = new WorkspaceRepository(database);
const agents = new AgentRepository(root_path);The CLI and Desktop create these dependencies in their own composition roots, read configuration,
and explicitly call new Agent(). The local subpath does not create an Agent, Workspace, Model, or
City. Workspace and platform settings are stored as plaintext JSON, with 0600 permissions on the
local database for user-level isolation.
Connect to an existing local host
LocalHostClient discovers a host for the data root and verifies its root, instance, protocol version, and required capabilities. It does not acquire a root lease, open a database, or create City.
import { LocalHostClient } from "@downcity/city/local";
const client = await LocalHostClient.connect({
root_path,
required_capabilities: ["extension.list"],
});
if (client) {
try {
const projects = await client.call("extension.list");
} finally {
await client.close();
}
}Only an explicit absence of a host returns null. An unreachable host, identity mismatch, or missing capability throws an error; callers must not fall back to offline writes. Closing a client cancels only its waits, without stopping accepted work or closing the borrowed City.
An explicitly authorized local-host composition root can use select_local_host(options, open_local). It returns a borrowed client when a host exists and calls open_local only when none exists. The local factory must still acquire the exclusive lease and rediscover the host inside that lease. The capability directory describes actual shared operations, not the complete Desktop product API.