@dbx-tools/cli 0.9.154 → 0.9.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dbx-genie.ts +3 -2
- package/index.appkit.ts +9 -0
- package/index.auth.ts +9 -0
- package/index.brand.ts +18 -0
- package/index.genie-code.ts +18 -0
- package/index.graphiti.ts +7 -0
- package/index.lakebase-proxy.ts +18 -0
- package/index.model-gateway.ts +9 -0
- package/index.ts +5 -61
- package/index.tunnel.ts +14 -0
- package/lib/bin/dbx-genie.js +4 -3
- package/lib/index.appkit.d.ts +5 -0
- package/lib/index.appkit.js +8 -0
- package/lib/index.auth.d.ts +5 -0
- package/lib/index.auth.js +8 -0
- package/lib/index.brand.d.ts +14 -0
- package/lib/index.brand.js +14 -0
- package/lib/index.d.ts +5 -61
- package/lib/index.genie-code.d.ts +14 -0
- package/lib/index.genie-code.js +14 -0
- package/lib/index.graphiti.d.ts +3 -0
- package/lib/index.graphiti.js +6 -0
- package/lib/index.js +6 -43
- package/lib/index.lakebase-proxy.d.ts +14 -0
- package/lib/index.lakebase-proxy.js +14 -0
- package/lib/index.model-gateway.d.ts +5 -0
- package/lib/index.model-gateway.js +8 -0
- package/lib/index.tunnel.d.ts +10 -0
- package/lib/index.tunnel.js +12 -0
- package/lib/src/appkit/cli.d.ts +1 -2
- package/lib/src/appkit/cli.js +4 -5
- package/lib/src/auth/cli.d.ts +2 -2
- package/lib/src/auth/cli.js +2 -3
- package/lib/src/auth/options.d.ts +2 -2
- package/lib/src/auth/options.js +4 -6
- package/lib/src/bootstrap.js +10 -14
- package/lib/src/brand/options.js +2 -2
- package/lib/src/brand/run.js +6 -8
- package/lib/src/brand/showcase.js +5 -5
- package/lib/src/bun.js +6 -6
- package/lib/src/genie-code/cli.d.ts +2 -2
- package/lib/src/genie-code/cli.js +4 -4
- package/lib/src/genie-code/config.d.ts +1 -1
- package/lib/src/genie-code/config.js +7 -7
- package/lib/src/genie-code/install.d.ts +2 -2
- package/lib/src/genie-code/install.js +4 -4
- package/lib/src/genie-code/runner.d.ts +2 -3
- package/lib/src/genie-code/runner.js +13 -11
- package/lib/src/genie-code/runtime.d.ts +3 -3
- package/lib/src/genie-code/runtime.js +10 -9
- package/lib/src/graphiti/cli.d.ts +2 -3
- package/lib/src/graphiti/cli.js +7 -8
- package/lib/src/lakebase-proxy/cli.d.ts +1 -2
- package/lib/src/lakebase-proxy/cli.js +3 -4
- package/lib/src/lakebase-proxy/options.js +7 -9
- package/lib/src/lakebase-proxy/proxy.js +8 -8
- package/lib/src/model-gateway/cli.d.ts +2 -3
- package/lib/src/model-gateway/cli.js +3 -4
- package/lib/src/model-gateway/server.d.ts +1 -1
- package/lib/src/model-gateway/server.js +5 -6
- package/lib/src/root.js +3 -3
- package/lib/src/tunnel/app.js +7 -9
- package/lib/src/tunnel/cli.d.ts +1 -2
- package/lib/src/tunnel/cli.js +13 -14
- package/lib/src/tunnel/options.d.ts +5 -5
- package/lib/src/tunnel/options.js +11 -11
- package/lib/src/tunnel/proxy.js +18 -17
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +58 -177
- package/src/appkit/cli.ts +2 -4
- package/src/auth/cli.ts +2 -4
- package/src/auth/options.ts +3 -5
- package/src/bootstrap.ts +9 -13
- package/src/brand/options.ts +1 -1
- package/src/brand/run.ts +7 -7
- package/src/brand/showcase.ts +4 -4
- package/src/bun.ts +6 -6
- package/src/genie-code/cli.ts +4 -4
- package/src/genie-code/config.ts +6 -6
- package/src/genie-code/install.ts +5 -7
- package/src/genie-code/runner.ts +12 -11
- package/src/genie-code/runtime.ts +10 -10
- package/src/graphiti/cli.ts +13 -9
- package/src/lakebase-proxy/cli.ts +7 -3
- package/src/lakebase-proxy/options.ts +13 -8
- package/src/lakebase-proxy/proxy.ts +7 -7
- package/src/model-gateway/cli.ts +7 -3
- package/src/model-gateway/server.ts +9 -5
- package/src/root.ts +2 -2
- package/src/tunnel/app.ts +6 -8
- package/src/tunnel/cli.ts +21 -15
- package/src/tunnel/options.ts +23 -15
- package/src/tunnel/proxy.ts +29 -20
- package/lib/src/appkit/index.d.ts +0 -5
- package/lib/src/appkit/index.js +0 -8
- package/lib/src/auth/index.d.ts +0 -5
- package/lib/src/auth/index.js +0 -8
- package/lib/src/brand/index.d.ts +0 -10
- package/lib/src/brand/index.js +0 -10
- package/lib/src/genie-code/index.d.ts +0 -12
- package/lib/src/genie-code/index.js +0 -12
- package/lib/src/genie-code/options.d.ts +0 -7
- package/lib/src/genie-code/options.js +0 -7
- package/lib/src/graphiti/index.d.ts +0 -5
- package/lib/src/graphiti/index.js +0 -7
- package/lib/src/graphiti/options.d.ts +0 -117
- package/lib/src/graphiti/options.js +0 -26
- package/lib/src/lakebase-proxy/index.d.ts +0 -13
- package/lib/src/lakebase-proxy/index.js +0 -13
- package/lib/src/model-gateway/index.d.ts +0 -3
- package/lib/src/model-gateway/index.js +0 -6
- package/lib/src/tunnel/index.d.ts +0 -8
- package/lib/src/tunnel/index.js +0 -10
- package/src/appkit/index.ts +0 -9
- package/src/auth/index.ts +0 -9
- package/src/brand/index.ts +0 -14
- package/src/genie-code/index.ts +0 -16
- package/src/genie-code/options.ts +0 -14
- package/src/graphiti/index.ts +0 -9
- package/src/graphiti/options.ts +0 -40
- package/src/lakebase-proxy/index.ts +0 -17
- package/src/model-gateway/index.ts +0 -7
- package/src/tunnel/index.ts +0 -12
package/src/brand/run.ts
CHANGED
|
@@ -8,16 +8,16 @@ import { mkdtemp } from "node:fs/promises";
|
|
|
8
8
|
import { tmpdir } from "node:os";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import type { BrandResearch } from "@dbx-tools/appkit-generator";
|
|
11
|
-
import { generateBrandPackage } from "@dbx-tools/appkit-generator
|
|
11
|
+
import { generateBrandPackage } from "@dbx-tools/appkit-generator";
|
|
12
12
|
import {
|
|
13
13
|
runWebAssetPageFetch,
|
|
14
14
|
runWebFetch,
|
|
15
15
|
runWebImageFetch,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import { createWorkspaceClient } from "@dbx-tools/databricks
|
|
20
|
-
import {
|
|
16
|
+
createWebSearchRuntime,
|
|
17
|
+
runWebSearch,
|
|
18
|
+
} from "@dbx-tools/appkit-web-search";
|
|
19
|
+
import { createWorkspaceClient } from "@dbx-tools/databricks";
|
|
20
|
+
import { isRecord } from "@dbx-tools/shared-core";
|
|
21
21
|
import type { BrandGenerationProgressEvent } from "@dbx-tools/shared-generator";
|
|
22
22
|
|
|
23
23
|
import { writeBrandPackage, type WrittenBrandPackage } from "./export.ts";
|
|
@@ -64,7 +64,7 @@ export async function exportBrandFromPrompt(
|
|
|
64
64
|
},
|
|
65
65
|
signal,
|
|
66
66
|
async (event) => {
|
|
67
|
-
if (!
|
|
67
|
+
if (!isRecord(event)) return;
|
|
68
68
|
const status = typeof event.status === "string" ? event.status : undefined;
|
|
69
69
|
const eventMessage =
|
|
70
70
|
typeof event.message === "string" ? event.message.trim() : undefined;
|
package/src/brand/showcase.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { escapeHtml, dedent } from "@dbx-tools/shared-core";
|
|
8
8
|
import type { BrandPackage } from "@dbx-tools/shared-generator";
|
|
9
9
|
|
|
10
10
|
function safeAsset(value: string | undefined): string | undefined {
|
|
@@ -22,13 +22,13 @@ function safeFontFamily(value: string): string {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function listItems(values: readonly string[]): string {
|
|
25
|
-
return values.map((value) => `<li>${
|
|
25
|
+
return values.map((value) => `<li>${escapeHtml(value)}</li>`).join("");
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/** Render one responsive brand presentation with desktop and mobile mockups. */
|
|
29
29
|
export function renderBrandShowcase(brandPackage: BrandPackage): string {
|
|
30
30
|
const { brand, visualReferences } = brandPackage;
|
|
31
|
-
const html =
|
|
31
|
+
const html = escapeHtml;
|
|
32
32
|
const logo = safeAsset(brand.assets.logo.light) ?? safeAsset(brand.assets.icon.light);
|
|
33
33
|
const icon = safeAsset(brand.assets.icon.light);
|
|
34
34
|
const website = safeWebsite(brand.links.website);
|
|
@@ -75,7 +75,7 @@ export function renderBrandShowcase(brandPackage: BrandPackage): string {
|
|
|
75
75
|
const headline = brand.tagline ?? brand.name;
|
|
76
76
|
|
|
77
77
|
// prettier-ignore
|
|
78
|
-
return
|
|
78
|
+
return dedent(
|
|
79
79
|
// ============================================================================
|
|
80
80
|
/*html*/`
|
|
81
81
|
<!doctype html>
|
package/src/bun.ts
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { existsSync } from "node:fs";
|
|
24
24
|
import { delimiter, dirname, join } from "node:path";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
25
|
+
import { spawnSync, npmRegistry } from "@dbx-tools/core";
|
|
26
|
+
import { log, memoize } from "@dbx-tools/shared-core";
|
|
27
27
|
import { needsInstall } from "./root.ts";
|
|
28
28
|
|
|
29
29
|
const logger = log.logger("dbx-tools:bun");
|
|
@@ -43,8 +43,8 @@ const REGISTRY_SUBCOMMANDS = new Set(["add", "install", "i", "update", "up"]);
|
|
|
43
43
|
* container may export it without any `.npmrc` for lookup. Memoized: resolution
|
|
44
44
|
* shells out.
|
|
45
45
|
*/
|
|
46
|
-
const registryOverride =
|
|
47
|
-
|
|
46
|
+
const registryOverride = memoize((): string | undefined =>
|
|
47
|
+
npmRegistry(null, { overrideOnly: true, envVars: true })?.toString(),
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
/** `--registry <url>` for a bun invocation, or `[]` when the subcommand doesn't resolve. */
|
|
@@ -98,7 +98,7 @@ function resolveBunArgvImpl(): string[] {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/** Memoized `[command, ...prefix]` argv prefix to run bun. */
|
|
101
|
-
export const resolveBunArgv =
|
|
101
|
+
export const resolveBunArgv = memoize(resolveBunArgvImpl);
|
|
102
102
|
|
|
103
103
|
/** Run bun with inherited stdio from `cwd`, forcing the resolved registry. */
|
|
104
104
|
export function runBun(args: string[], cwd: string): void {
|
|
@@ -107,7 +107,7 @@ export function runBun(args: string[], cwd: string): void {
|
|
|
107
107
|
if (registryArgs.length > 0) {
|
|
108
108
|
logger.info(`running bun with registry: ${registryArgs[1]}`);
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
spawnSync(command, [...prefix, ...args, ...registryArgs], {
|
|
111
111
|
cwd,
|
|
112
112
|
check: true,
|
|
113
113
|
env: childEnv(),
|
package/src/genie-code/cli.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { addArgs, parseArgs } from "@dbx-tools/cli-args";
|
|
8
|
+
import { GenieCodeOptionsSchema, type GenieCodeOptions } from "@dbx-tools/shared-genie-code";
|
|
8
9
|
import { Command } from "commander";
|
|
9
10
|
|
|
10
|
-
import { GenieCodeCliOptionsSchema, type GenieCodeCliOptions } from "./options.ts";
|
|
11
11
|
import { runGenieCode } from "./runtime.ts";
|
|
12
12
|
|
|
13
13
|
/** Injectable managed Genie execution boundary for parser tests and embedding. */
|
|
@@ -15,7 +15,7 @@ export interface GenieCodeCliDependencies {
|
|
|
15
15
|
run(input: {
|
|
16
16
|
cwd: string;
|
|
17
17
|
genieArgs: readonly string[];
|
|
18
|
-
options:
|
|
18
|
+
options: GenieCodeOptions;
|
|
19
19
|
}): Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -40,13 +40,13 @@ export function buildProgram(
|
|
|
40
40
|
.passThroughOptions()
|
|
41
41
|
.allowExcessArguments()
|
|
42
42
|
.showHelpAfterError(),
|
|
43
|
-
|
|
43
|
+
GenieCodeOptionsSchema,
|
|
44
44
|
);
|
|
45
45
|
program.action(async (genieArgs: string[]) => {
|
|
46
46
|
await dependencies.run({
|
|
47
47
|
cwd: process.cwd(),
|
|
48
48
|
genieArgs,
|
|
49
|
-
options: parseArgs(program,
|
|
49
|
+
options: parseArgs(program, GenieCodeOptionsSchema),
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
return program;
|
package/src/genie-code/config.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
8
8
|
import { chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { dirname, join, resolve } from "node:path";
|
|
11
|
-
import { withFileLock } from "@dbx-tools/core
|
|
12
|
-
import {
|
|
11
|
+
import { withFileLock } from "@dbx-tools/core";
|
|
12
|
+
import { isRecord } from "@dbx-tools/shared-core";
|
|
13
13
|
import {
|
|
14
14
|
GenieCodeBaseConfigSchema,
|
|
15
15
|
GenieCodeConfigSchema,
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
type GenieCodeBaseConfig,
|
|
18
18
|
type GenieCodeConfig,
|
|
19
19
|
type GenieCodeProviderOverlay,
|
|
20
|
-
} from "@dbx-tools/shared-genie-code
|
|
21
|
-
import { genieCodeHomeName } from "@dbx-tools/shared-genie-code
|
|
20
|
+
} from "@dbx-tools/shared-genie-code";
|
|
21
|
+
import { genieCodeHomeName } from "@dbx-tools/shared-genie-code";
|
|
22
22
|
import { parse, stringify } from "smol-toml";
|
|
23
23
|
|
|
24
24
|
/** Provider identifier written to the base and invocation overlay configurations. */
|
|
@@ -65,7 +65,7 @@ export function genieCodeBaseConfig(
|
|
|
65
65
|
): GenieCodeBaseConfig {
|
|
66
66
|
const projects = Object.fromEntries(
|
|
67
67
|
Object.entries(existingProjects).filter(
|
|
68
|
-
([, value]) =>
|
|
68
|
+
([, value]) => isRecord(value) && value.trust_level === "trusted",
|
|
69
69
|
),
|
|
70
70
|
);
|
|
71
71
|
return GenieCodeBaseConfigSchema.parse({
|
|
@@ -118,7 +118,7 @@ export function genieCodeConfig(options: WriteGenieCodeConfigOptions): GenieCode
|
|
|
118
118
|
async function existingProjects(path: string): Promise<Record<string, unknown>> {
|
|
119
119
|
try {
|
|
120
120
|
const value = parse(await readFile(path, "utf8"));
|
|
121
|
-
return
|
|
121
|
+
return isRecord(value.projects) ? value.projects : {};
|
|
122
122
|
} catch (error) {
|
|
123
123
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") return {};
|
|
124
124
|
throw error;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
|
-
import {
|
|
10
|
-
import { GENIE_CODE_VERSION } from "@dbx-tools/shared-genie-code
|
|
9
|
+
import { type BinContext, ensure } from "@dbx-tools/core";
|
|
10
|
+
import { GENIE_CODE_VERSION } from "@dbx-tools/shared-genie-code";
|
|
11
11
|
|
|
12
12
|
interface GenieCodeAsset {
|
|
13
13
|
target: string;
|
|
@@ -63,9 +63,7 @@ export function genieCodeAsset(
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/** Install and return the shared Genie Code package entrypoint. */
|
|
66
|
-
export async function installGenieCode(
|
|
67
|
-
options: InstallGenieCodeOptions = {},
|
|
68
|
-
): Promise<bin.BinContext> {
|
|
66
|
+
export async function installGenieCode(options: InstallGenieCodeOptions = {}): Promise<BinContext> {
|
|
69
67
|
const platform = options.platform ?? process.platform;
|
|
70
68
|
const asset = genieCodeAsset(platform, options.architecture ?? process.arch);
|
|
71
69
|
const executable = platform === "win32" ? "genie.exe" : "genie";
|
|
@@ -78,7 +76,7 @@ export async function installGenieCode(
|
|
|
78
76
|
"releases",
|
|
79
77
|
`${GENIE_CODE_VERSION}-${asset.target}`,
|
|
80
78
|
);
|
|
81
|
-
const destination:
|
|
79
|
+
const destination: BinContext = {
|
|
82
80
|
root,
|
|
83
81
|
binDir: join(root, dirname(entrypoint)),
|
|
84
82
|
path: join(root, entrypoint),
|
|
@@ -86,7 +84,7 @@ export async function installGenieCode(
|
|
|
86
84
|
const url =
|
|
87
85
|
`https://github.com/databricks/genie-code-cli/releases/download/v${GENIE_CODE_VERSION}/` +
|
|
88
86
|
`genie-package-${asset.target}.tar.gz`;
|
|
89
|
-
return
|
|
87
|
+
return ensure(
|
|
90
88
|
"genie",
|
|
91
89
|
{ url, sha256: asset.sha256 },
|
|
92
90
|
{
|
package/src/genie-code/runner.ts
CHANGED
|
@@ -4,18 +4,21 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { GenieCodeRunnerOptionsSchema } from "@dbx-tools/shared-genie-code
|
|
7
|
+
import { configUtils, spawn } from "@dbx-tools/core";
|
|
8
|
+
import { log, poll } from "@dbx-tools/shared-core";
|
|
9
|
+
import { GenieCodeRunnerOptionsSchema } from "@dbx-tools/shared-genie-code";
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
const
|
|
11
|
+
/** Logical configuration key carrying serialized runner options. */
|
|
12
|
+
export const RUNNER_OPTIONS_KEY = "GENIE_RUNNER_OPTIONS";
|
|
13
13
|
const logger = log.logger("genie-code:runner");
|
|
14
14
|
|
|
15
15
|
/** Parse the serialized runner boundary from its private environment field. */
|
|
16
16
|
export function genieCodeRunnerOptions(environment: NodeJS.ProcessEnv = process.env) {
|
|
17
|
-
const serialized =
|
|
18
|
-
|
|
17
|
+
const serialized = configUtils.resolveValue(RUNNER_OPTIONS_KEY, {
|
|
18
|
+
data: environment,
|
|
19
|
+
sources: "config",
|
|
20
|
+
});
|
|
21
|
+
if (!serialized) throw new Error(`${configUtils.name(RUNNER_OPTIONS_KEY)} is required`);
|
|
19
22
|
return GenieCodeRunnerOptionsSchema.parse(JSON.parse(serialized));
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -25,7 +28,7 @@ export async function waitForGenieCodeGateway(
|
|
|
25
28
|
bearerToken: string,
|
|
26
29
|
timeoutMs: number,
|
|
27
30
|
): Promise<void> {
|
|
28
|
-
for await (const ready of
|
|
31
|
+
for await (const ready of poll(
|
|
29
32
|
async ({ signal }) => {
|
|
30
33
|
try {
|
|
31
34
|
const response = await fetch(healthUrl, {
|
|
@@ -65,7 +68,7 @@ export async function runGenieCodeChild(
|
|
|
65
68
|
executable: options.executable,
|
|
66
69
|
home: options.home,
|
|
67
70
|
});
|
|
68
|
-
const child =
|
|
71
|
+
const child = spawn(options.executable, [...options.arguments], {
|
|
69
72
|
cwd: process.cwd(),
|
|
70
73
|
env: {
|
|
71
74
|
...environment,
|
|
@@ -80,5 +83,3 @@ export async function runGenieCodeChild(
|
|
|
80
83
|
const result = await child;
|
|
81
84
|
if (result.exitCode !== 0) process.exitCode = result.exitCode;
|
|
82
85
|
}
|
|
83
|
-
|
|
84
|
-
export { RUNNER_OPTIONS_ENV };
|
|
@@ -7,24 +7,24 @@
|
|
|
7
7
|
import { randomBytes } from "node:crypto";
|
|
8
8
|
import { rm } from "node:fs/promises";
|
|
9
9
|
import { delimiter, dirname } from "node:path";
|
|
10
|
-
import { DatabricksModelRegistry,
|
|
10
|
+
import { DatabricksModelRegistry, codexModelSlug } from "@dbx-tools/appkit-model-gateway";
|
|
11
11
|
import * as auth from "@dbx-tools/auth";
|
|
12
|
-
import { resolveServicePackageBin } from "@dbx-tools/cli-service
|
|
13
|
-
import type
|
|
14
|
-
import {
|
|
12
|
+
import { resolveServicePackageBin } from "@dbx-tools/cli-service";
|
|
13
|
+
import { configUtils, type BinContext } from "@dbx-tools/core";
|
|
14
|
+
import { createWorkspaceClient } from "@dbx-tools/databricks";
|
|
15
15
|
import { log } from "@dbx-tools/shared-core";
|
|
16
16
|
import {
|
|
17
17
|
resolveGenieCodeOptions,
|
|
18
18
|
type GenieCodeOptions,
|
|
19
19
|
type GenieCodeRunnerOptions,
|
|
20
|
-
} from "@dbx-tools/shared-genie-code
|
|
21
|
-
import type { ModelClass } from "@dbx-tools/shared-model
|
|
20
|
+
} from "@dbx-tools/shared-genie-code";
|
|
21
|
+
import type { ModelClass } from "@dbx-tools/shared-model";
|
|
22
22
|
import concurrently from "concurrently";
|
|
23
23
|
import getPort from "get-port";
|
|
24
24
|
|
|
25
25
|
import { writeGenieCodeConfig, type GenieCodeHome } from "./config.ts";
|
|
26
26
|
import { installGenieCode } from "./install.ts";
|
|
27
|
-
import {
|
|
27
|
+
import { RUNNER_OPTIONS_KEY } from "./runner.ts";
|
|
28
28
|
|
|
29
29
|
const logger = log.logger("genie-code");
|
|
30
30
|
|
|
@@ -61,7 +61,7 @@ async function resolveCodexModel(
|
|
|
61
61
|
profile: string,
|
|
62
62
|
modelClass?: ModelClass,
|
|
63
63
|
): Promise<string> {
|
|
64
|
-
const client = await
|
|
64
|
+
const client = await createWorkspaceClient({ profile });
|
|
65
65
|
const target = await new DatabricksModelRegistry({ client }).resolve(model, {
|
|
66
66
|
requiresTools: true,
|
|
67
67
|
...(modelClass ? { modelClass } : {}),
|
|
@@ -72,7 +72,7 @@ async function resolveCodexModel(
|
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
// Genie Code pins the exact system.ai service slug, which wins regardless of gateway preference.
|
|
75
|
-
return
|
|
75
|
+
return codexModelSlug(target, true);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/** Inputs accepted by managed Genie Code preparation and execution. */
|
|
@@ -205,7 +205,7 @@ export async function runGenieCode(input: RunGenieCodeOptions = {}): Promise<voi
|
|
|
205
205
|
...process.env,
|
|
206
206
|
PATH: path,
|
|
207
207
|
DATABRICKS_CONFIG_PROFILE: prepared.profile,
|
|
208
|
-
[
|
|
208
|
+
[configUtils.name(RUNNER_OPTIONS_KEY)]: JSON.stringify(runnerOptions),
|
|
209
209
|
},
|
|
210
210
|
},
|
|
211
211
|
],
|
package/src/graphiti/cli.ts
CHANGED
|
@@ -12,16 +12,20 @@ import { join } from "node:path";
|
|
|
12
12
|
|
|
13
13
|
import { runtime as graphitiRuntime } from "@dbx-tools/appkit-memory/graphiti";
|
|
14
14
|
import { addArgs, parseArgs, serializeArgs } from "@dbx-tools/cli-args";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
import {
|
|
16
|
+
buildServiceCommand,
|
|
17
|
+
type CliServiceCliDependencies,
|
|
18
|
+
defineService,
|
|
19
|
+
type CliServiceDefinition,
|
|
20
|
+
} from "@dbx-tools/cli-service";
|
|
21
|
+
import { serviceTrayIcon } from "@dbx-tools/cli-service";
|
|
20
22
|
import {
|
|
21
23
|
GraphitiCliOptionsSchema,
|
|
22
24
|
GraphitiOptionsSchema,
|
|
23
25
|
type GraphitiOptions,
|
|
24
|
-
} from "
|
|
26
|
+
} from "@dbx-tools/shared-graphiti";
|
|
27
|
+
import { Command } from "commander";
|
|
28
|
+
|
|
25
29
|
import { PACKAGE_VERSION } from "../../index.ts";
|
|
26
30
|
|
|
27
31
|
const DEFAULT_SERVICE_DIRECTORY = join(homedir(), ".dbx-tools", "services", "graphiti");
|
|
@@ -74,18 +78,18 @@ export function buildProgram(
|
|
|
74
78
|
.version(PACKAGE_VERSION, "-v, --version"),
|
|
75
79
|
GraphitiCliOptionsSchema,
|
|
76
80
|
).action(async () => {
|
|
77
|
-
await dependencies.run(
|
|
81
|
+
await dependencies.run(parseGraphitiOptions(program));
|
|
78
82
|
});
|
|
79
83
|
|
|
80
84
|
program.addCommand(
|
|
81
85
|
buildServiceCommand(
|
|
82
|
-
() => graphitiServiceDefinition(
|
|
86
|
+
() => graphitiServiceDefinition(parseGraphitiOptions(program)),
|
|
83
87
|
dependencies.service,
|
|
84
88
|
),
|
|
85
89
|
);
|
|
86
90
|
return program;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
function
|
|
93
|
+
function parseGraphitiOptions(command: Command): GraphitiOptions {
|
|
90
94
|
return GraphitiOptionsSchema.parse(parseArgs(command, GraphitiCliOptionsSchema));
|
|
91
95
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/** Commander entry point for the pure Node Lakebase proxy. */
|
|
2
2
|
|
|
3
3
|
import { addArgs, parseArgs, serializeArgs } from "@dbx-tools/cli-args";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
buildServiceCommand,
|
|
6
|
+
type CliServiceCliDependencies,
|
|
7
|
+
defineService,
|
|
8
|
+
type CliServiceDefinition,
|
|
9
|
+
} from "@dbx-tools/cli-service";
|
|
10
|
+
import { serviceTrayIcon } from "@dbx-tools/cli-service";
|
|
7
11
|
import { connectionUrl } from "@dbx-tools/lakebase";
|
|
8
12
|
import { Command } from "commander";
|
|
9
13
|
|
|
@@ -4,24 +4,29 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
PostgresConfigOptionsSchema,
|
|
9
|
+
listenAddressSchema,
|
|
10
|
+
DatabricksOptionsSchema,
|
|
11
|
+
LakebaseOptionsSchema,
|
|
12
|
+
} from "@dbx-tools/shared-core";
|
|
8
13
|
import { z } from "zod";
|
|
9
14
|
|
|
10
15
|
const text = (description: string) => z.string().trim().min(1).optional().describe(description);
|
|
11
16
|
|
|
12
17
|
export const LakebaseProxyOptionsSchema = z
|
|
13
18
|
.object({
|
|
14
|
-
...
|
|
15
|
-
listen:
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
...PostgresConfigOptionsSchema.shape,
|
|
20
|
+
listen: listenAddressSchema({ port: 5432, loopback: true }).describe(
|
|
21
|
+
"Loopback listener address.",
|
|
22
|
+
),
|
|
18
23
|
startupTimeoutSeconds: z.coerce
|
|
19
24
|
.number<number>()
|
|
20
25
|
.int()
|
|
21
26
|
.nonnegative()
|
|
22
27
|
.default(30)
|
|
23
28
|
.describe("Startup timeout in seconds."),
|
|
24
|
-
profile:
|
|
29
|
+
profile: DatabricksOptionsSchema.shape.profile.describe("Exact Databricks profile."),
|
|
25
30
|
})
|
|
26
31
|
.strict()
|
|
27
32
|
.describe("Lakebase proxy listener and service options.");
|
|
@@ -29,8 +34,8 @@ export const LakebaseProxyOptionsSchema = z
|
|
|
29
34
|
export const LakebaseProxyUrlOptionsSchema = z
|
|
30
35
|
.object({
|
|
31
36
|
target: text("Lakebase project, resource path, host, or URL."),
|
|
32
|
-
lakebaseEndpoint:
|
|
33
|
-
listen:
|
|
37
|
+
lakebaseEndpoint: LakebaseOptionsSchema.shape.lakebaseEndpoint,
|
|
38
|
+
listen: listenAddressSchema({ port: 5432 }).describe("Local proxy address."),
|
|
34
39
|
})
|
|
35
40
|
.strict()
|
|
36
41
|
.refine(
|
|
@@ -4,7 +4,7 @@ import { createServer, type Server, type Socket } from "node:net";
|
|
|
4
4
|
import type { Duplex } from "node:stream";
|
|
5
5
|
import { LakebaseClient, requireAddress } from "@dbx-tools/lakebase";
|
|
6
6
|
import { postgresConnectionOptions } from "@dbx-tools/postgres";
|
|
7
|
-
import {
|
|
7
|
+
import { log, toError, trimToUndefined } from "@dbx-tools/shared-core";
|
|
8
8
|
import { Client } from "pg";
|
|
9
9
|
|
|
10
10
|
import { CancellationRegistry } from "./cancellation.ts";
|
|
@@ -113,20 +113,20 @@ export class LakebaseProxy {
|
|
|
113
113
|
try {
|
|
114
114
|
target = requireAddress(targetText);
|
|
115
115
|
} catch (error) {
|
|
116
|
-
throw new ProxyFailure(message(error), "3D000", { cause:
|
|
116
|
+
throw new ProxyFailure(message(error), "3D000", { cause: toError(error) });
|
|
117
117
|
}
|
|
118
|
-
const startupUser =
|
|
118
|
+
const startupUser = trimToUndefined(startup.parameters.user);
|
|
119
119
|
let resolved;
|
|
120
120
|
try {
|
|
121
121
|
resolved = await this.client.resolve(target, startupUser);
|
|
122
122
|
} catch (error) {
|
|
123
|
-
throw new ProxyFailure(message(error), "3D000", { cause:
|
|
123
|
+
throw new ProxyFailure(message(error), "3D000", { cause: toError(error) });
|
|
124
124
|
}
|
|
125
125
|
let password;
|
|
126
126
|
try {
|
|
127
127
|
password = await this.client.generateDatabaseCredential(resolved.endpoint, startupUser);
|
|
128
128
|
} catch (error) {
|
|
129
|
-
throw new ProxyFailure(message(error), "28000", { cause:
|
|
129
|
+
throw new ProxyFailure(message(error), "28000", { cause: toError(error) });
|
|
130
130
|
}
|
|
131
131
|
let connected;
|
|
132
132
|
try {
|
|
@@ -136,7 +136,7 @@ export class LakebaseProxy {
|
|
|
136
136
|
postgresConnectionOptions(startup.parameters, this.options.postgresRole),
|
|
137
137
|
);
|
|
138
138
|
} catch (error) {
|
|
139
|
-
throw new ProxyFailure(message(error), "08001", { cause:
|
|
139
|
+
throw new ProxyFailure(message(error), "08001", { cause: toError(error) });
|
|
140
140
|
}
|
|
141
141
|
upstream = connected.socket;
|
|
142
142
|
cancellation = this.cancellations.register({
|
|
@@ -168,7 +168,7 @@ export class LakebaseProxy {
|
|
|
168
168
|
? error
|
|
169
169
|
: error instanceof PostgresProtocolError
|
|
170
170
|
? new ProxyFailure(error.message, "08P01", { cause: error })
|
|
171
|
-
: new ProxyFailure(message(error), "08001", { cause:
|
|
171
|
+
: new ProxyFailure(message(error), "08001", { cause: toError(error) });
|
|
172
172
|
logger.warn("Lakebase connection failed", {
|
|
173
173
|
durationMs: Date.now() - started,
|
|
174
174
|
error: failure,
|
package/src/model-gateway/cli.ts
CHANGED
|
@@ -5,14 +5,18 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { addArgs, parseArgs, serializeArgs } from "@dbx-tools/cli-args";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
buildServiceCommand,
|
|
10
|
+
type CliServiceCliDependencies,
|
|
11
|
+
defineService,
|
|
12
|
+
type CliServiceDefinition,
|
|
13
|
+
} from "@dbx-tools/cli-service";
|
|
10
14
|
import {
|
|
11
15
|
ModelGatewayCliOptionsSchema,
|
|
12
16
|
resolveModelGatewayCliOptions,
|
|
13
17
|
type ModelGatewayCliOptions,
|
|
14
18
|
type ModelGatewayOptions,
|
|
15
|
-
} from "@dbx-tools/shared-model-gateway
|
|
19
|
+
} from "@dbx-tools/shared-model-gateway";
|
|
16
20
|
import { Command } from "commander";
|
|
17
21
|
|
|
18
22
|
import { startModelGateway } from "./server.ts";
|
|
@@ -6,14 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
8
8
|
import { createApp, server } from "@databricks/appkit";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import {
|
|
10
|
+
ModelGateway,
|
|
11
|
+
sendHealth,
|
|
12
|
+
sendInference,
|
|
13
|
+
sendModels,
|
|
14
|
+
} from "@dbx-tools/appkit-model-gateway";
|
|
15
|
+
import { createWorkspaceClient } from "@dbx-tools/databricks";
|
|
12
16
|
import {
|
|
13
17
|
resolveModelGatewayOptions,
|
|
14
18
|
type ModelGatewayOptions,
|
|
15
19
|
type ResolvedModelGatewayOptions,
|
|
16
|
-
} from "@dbx-tools/shared-model-gateway
|
|
20
|
+
} from "@dbx-tools/shared-model-gateway";
|
|
17
21
|
import type express from "express";
|
|
18
22
|
|
|
19
23
|
type AppKitServerOptions = NonNullable<Parameters<typeof server>[0]>;
|
|
@@ -65,7 +69,7 @@ export async function startModelGateway(options: ModelGatewayOptions = {}): Prom
|
|
|
65
69
|
...(resolved.modelClass ? { modelClass: resolved.modelClass } : {}),
|
|
66
70
|
preferSystemModels: resolved.preferSystemModels,
|
|
67
71
|
});
|
|
68
|
-
const client = await
|
|
72
|
+
const client = await createWorkspaceClient({
|
|
69
73
|
...(resolved.profile ? { profile: resolved.profile } : {}),
|
|
70
74
|
});
|
|
71
75
|
await createApp({
|
package/src/root.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { basename, join, resolve } from "node:path";
|
|
8
8
|
import { projectUtils } from "@dbx-tools/core";
|
|
9
|
-
import {
|
|
9
|
+
import { memoize } from "@dbx-tools/shared-core";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Walk upward from `startDir` for `.projenrc.ts`. If none is found, try git
|
|
@@ -52,7 +52,7 @@ export function needsToolchain(root: string): boolean {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/** Async, memoized root lookup from the process cwd at first use. */
|
|
55
|
-
export const workspaceRoot =
|
|
55
|
+
export const workspaceRoot = memoize(() => findWorkspaceRoot());
|
|
56
56
|
|
|
57
57
|
/** Short label for log output (`basename` of the resolved root). */
|
|
58
58
|
export function rootLabel(root: string): string {
|
package/src/tunnel/app.ts
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { lakebase, type WorkspaceClient } from "@databricks/appkit";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { createApp } from "@dbx-tools/appkit";
|
|
20
|
+
import { shouldUseLakebase } from "@dbx-tools/auth-gate";
|
|
21
21
|
import { email } from "@dbx-tools/email";
|
|
22
22
|
import { postgresConnectionOptions } from "@dbx-tools/postgres";
|
|
23
|
-
import {
|
|
23
|
+
import { isRecord } from "@dbx-tools/shared-core";
|
|
24
24
|
import { authGate, type AuthGateApi, type AuthGateConfig } from "@dbx-tools/tunnel";
|
|
25
25
|
|
|
26
26
|
/** Boot the gate app and return the handlers the proxy authenticates against. */
|
|
@@ -30,12 +30,10 @@ export async function startGateApp(
|
|
|
30
30
|
): Promise<AuthGateApi> {
|
|
31
31
|
// No `server()` plugin: nothing here listens. `plugins` order matters - `email`
|
|
32
32
|
// registers its transport before `authGate` looks for a sibling to send with.
|
|
33
|
-
const plugins = await
|
|
33
|
+
const plugins = await createApp({
|
|
34
34
|
client,
|
|
35
35
|
plugins: [
|
|
36
|
-
...(
|
|
37
|
-
? [lakebase({ pool: postgresConnectionOptions({}) })]
|
|
38
|
-
: []),
|
|
36
|
+
...(shouldUseLakebase(config) ? [lakebase({ pool: postgresConnectionOptions({}) })] : []),
|
|
39
37
|
...(config.sendCode ? [] : [email()]),
|
|
40
38
|
authGate(config),
|
|
41
39
|
],
|
|
@@ -47,7 +45,7 @@ export async function startGateApp(
|
|
|
47
45
|
|
|
48
46
|
function isAuthGateApi(value: unknown): value is AuthGateApi {
|
|
49
47
|
return (
|
|
50
|
-
|
|
48
|
+
isRecord(value) &&
|
|
51
49
|
typeof value.basePath === "string" &&
|
|
52
50
|
typeof value.passkeysEnabled === "boolean" &&
|
|
53
51
|
typeof value.isProtectedHost === "function" &&
|