@dbx-tools/cli 0.9.61 → 0.9.65

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/src/cli.ts CHANGED
@@ -160,9 +160,7 @@ export function buildProgram(name: string = PROGRAM_NAMES[0]): Command {
160
160
  /** Build the complete command tree used for generated documentation. */
161
161
  export async function buildDocumentationProgram(name: string = PROGRAM_NAMES[0]): Promise<Command> {
162
162
  const program = buildProgram(name);
163
- (program.commands as Command[]).splice(
164
- 1,
165
- program.commands.length - 1,
163
+ const children = [
166
164
  (await import("./appkit/cli.ts")).buildProgram("appkit"),
167
165
  (await import("./auth/cli.ts")).buildProgram("auth"),
168
166
  (await import("./tunnel/cli.ts")).buildProgram("tunnel"),
@@ -170,7 +168,9 @@ export async function buildDocumentationProgram(name: string = PROGRAM_NAMES[0])
170
168
  (await import("./model-gateway/cli.ts")).buildProgram("model-gateway"),
171
169
  (await import("./genie-code/cli.ts")).buildProgram("genie"),
172
170
  (await import("./graphiti/cli.ts")).buildProgram("graphiti"),
173
- );
171
+ ];
172
+ (program.commands as Command[]).splice(1, program.commands.length - 1);
173
+ for (const child of children) program.addCommand(child);
174
174
  return program;
175
175
  }
176
176
 
@@ -18,7 +18,7 @@ import {
18
18
  type GenieCodeConfig,
19
19
  type GenieCodeProviderOverlay,
20
20
  } from "@dbx-tools/shared-genie-code/config";
21
- import { genieCodePairingName } from "@dbx-tools/shared-genie-code/options";
21
+ import { genieCodeHomeName } from "@dbx-tools/shared-genie-code/options";
22
22
  import { parse, stringify } from "smol-toml";
23
23
 
24
24
  /** Provider identifier written to the base and invocation overlay configurations. */
@@ -34,30 +34,26 @@ export interface WriteGenieCodeConfigOptions {
34
34
  projectDirectory: string;
35
35
  }
36
36
 
37
- /** Stable persistent home for one exact profile-model pairing. */
38
- export interface GenieCodePairingHome {
37
+ /** Stable persistent home for one exact Databricks profile. */
38
+ export interface GenieCodeProfileHome {
39
39
  configPath: string;
40
40
  home: string;
41
41
  name: string;
42
42
  }
43
43
 
44
- /** Persistent pairing home and invocation-specific provider overlay. */
45
- export interface GenieCodeHome extends GenieCodePairingHome {
44
+ /** Persistent profile home and invocation-specific model-provider overlay. */
45
+ export interface GenieCodeHome extends GenieCodeProfileHome {
46
46
  overlayName: string;
47
47
  overlayPath: string;
48
48
  }
49
49
 
50
- /** Derive the stable home for one exact profile-model pair. */
50
+ /** Derive the stable home for one exact Databricks profile. */
51
51
  export function genieCodeHome(
52
52
  profile: string,
53
- model: string,
54
53
  homeDirectory: string = homedir(),
55
- ): GenieCodePairingHome {
56
- const digest = createHash("sha256")
57
- .update(JSON.stringify([profile, model]))
58
- .digest("hex")
59
- .slice(0, 12);
60
- const name = genieCodePairingName({ profile, model, digest });
54
+ ): GenieCodeProfileHome {
55
+ const digest = createHash("sha256").update(profile).digest("hex").slice(0, 12);
56
+ const name = genieCodeHomeName({ profile, digest });
61
57
  const home = join(homeDirectory, ".dbx-tools", "genie", "profiles", name);
62
58
  return { name, home, configPath: join(home, "config.toml") };
63
59
  }
@@ -73,8 +69,6 @@ export function genieCodeBaseConfig(
73
69
  ),
74
70
  );
75
71
  return GenieCodeBaseConfigSchema.parse({
76
- model_provider: GENIE_CODE_GATEWAY_PROVIDER,
77
- model: options.model,
78
72
  databricks_profile: options.profile,
79
73
  projects: {
80
74
  ...projects,
@@ -82,11 +76,6 @@ export function genieCodeBaseConfig(
82
76
  trust_level: "trusted",
83
77
  },
84
78
  },
85
- tui: {
86
- model_availability_nux: {
87
- [options.model]: 1,
88
- },
89
- },
90
79
  });
91
80
  }
92
81
 
@@ -95,6 +84,8 @@ export function genieCodeProviderOverlay(
95
84
  options: WriteGenieCodeConfigOptions,
96
85
  ): GenieCodeProviderOverlay {
97
86
  return GenieCodeProviderOverlaySchema.parse({
87
+ model_provider: GENIE_CODE_GATEWAY_PROVIDER,
88
+ model: options.model,
98
89
  model_providers: {
99
90
  [GENIE_CODE_GATEWAY_PROVIDER]: {
100
91
  name: "dbx-tools model gateway",
@@ -108,6 +99,11 @@ export function genieCodeProviderOverlay(
108
99
  },
109
100
  },
110
101
  },
102
+ tui: {
103
+ model_availability_nux: {
104
+ [options.model]: 1,
105
+ },
106
+ },
111
107
  });
112
108
  }
113
109
 
@@ -144,7 +140,7 @@ async function writePrivateToml(path: string, value: unknown): Promise<void> {
144
140
  export async function writeGenieCodeConfig(
145
141
  options: WriteGenieCodeConfigOptions,
146
142
  ): Promise<GenieCodeHome> {
147
- const base = genieCodeHome(options.profile, options.model, options.homeDirectory);
143
+ const base = genieCodeHome(options.profile, options.homeDirectory);
148
144
  const overlayName = `dbx-${randomUUID().replaceAll("-", "")}`;
149
145
  const destination = {
150
146
  ...base,
@@ -18,6 +18,7 @@ import {
18
18
  type GenieCodeOptions,
19
19
  type GenieCodeRunnerOptions,
20
20
  } from "@dbx-tools/shared-genie-code/options";
21
+ import type { ModelClass } from "@dbx-tools/shared-model/contracts";
21
22
  import concurrently from "concurrently";
22
23
  import getPort from "get-port";
23
24
 
@@ -33,7 +34,11 @@ export interface GenieCodeRuntimeDependencies {
33
34
  install: typeof installGenieCode;
34
35
  port(options: { host: string; port?: number }): Promise<number>;
35
36
  resolveBin(packageReference: string, binName: string): string;
36
- resolveCodexModel(model: string, profile: string): Promise<string>;
37
+ resolveCodexModel(
38
+ model: string | undefined,
39
+ profile: string,
40
+ modelClass?: ModelClass,
41
+ ): Promise<string>;
37
42
  supervise: typeof concurrently;
38
43
  token(): string;
39
44
  writeConfig: typeof writeGenieCodeConfig;
@@ -51,12 +56,21 @@ const DEFAULT_DEPENDENCIES: GenieCodeRuntimeDependencies = {
51
56
  };
52
57
 
53
58
  /** Resolve a Genie `--model` value to the Codex catalogue slug the gateway publishes. */
54
- async function resolveCodexModel(model: string, profile: string): Promise<string> {
59
+ async function resolveCodexModel(
60
+ model: string | undefined,
61
+ profile: string,
62
+ modelClass?: ModelClass,
63
+ ): Promise<string> {
55
64
  const client = await workspaceClient.createWorkspaceClient({ profile });
56
65
  const target = await new DatabricksModelRegistry({ client }).resolve(model, {
57
66
  requiresTools: true,
67
+ ...(modelClass ? { modelClass } : {}),
58
68
  });
59
- if (!target) throw new Error(`Genie Code model not found: ${model}`);
69
+ if (!target) {
70
+ throw new Error(
71
+ model ? `Genie Code model not found: ${model}` : "No tool-capable chat model is available",
72
+ );
73
+ }
60
74
  return models.codexModelSlug(target);
61
75
  }
62
76
 
@@ -100,6 +114,7 @@ export async function prepareGenieCodeRuntime(
100
114
  logger.info("preparing Genie Code runtime", {
101
115
  profile,
102
116
  model: options.model,
117
+ modelClass: options.modelClass,
103
118
  });
104
119
  const installation = await dependencies.install();
105
120
  const host = options.gatewayListen.host;
@@ -111,8 +126,12 @@ export async function prepareGenieCodeRuntime(
111
126
  if (requestedPort > 0 && gatewayPort !== requestedPort) {
112
127
  throw new Error(`Genie Code gateway port ${requestedPort} is already in use`);
113
128
  }
114
- const model = await dependencies.resolveCodexModel(options.model, profile);
115
- logger.info("resolved Genie Code model", { requested: options.model, model });
129
+ const model = await dependencies.resolveCodexModel(options.model, profile, options.modelClass);
130
+ logger.info("resolved Genie Code model", {
131
+ requested: options.model,
132
+ modelClass: options.modelClass,
133
+ model,
134
+ });
116
135
  const urlHost = host.includes(":") ? `[${host}]` : host;
117
136
  const gatewayBaseUrl = `http://${urlHost}:${gatewayPort}/v1`;
118
137
  const gatewayHealthUrl = `http://${urlHost}:${gatewayPort}/api/healthz`;
@@ -13,12 +13,12 @@ import { defineService, type CliServiceDefinition } from "@dbx-tools/cli-service
13
13
  import { runGraphiti, type GraphitiRuntimeOptions } from "@dbx-tools/graphiti/runtime";
14
14
  import { Command } from "commander";
15
15
 
16
- import { PACKAGE_VERSION } from "../../index.ts";
17
16
  import {
18
17
  GraphitiCliOptionsSchema,
19
18
  GraphitiOptionsSchema,
20
19
  type GraphitiOptions,
21
20
  } from "./options.ts";
21
+ import { PACKAGE_VERSION } from "../../index.ts";
22
22
 
23
23
  /** Injectable runtime and service lifecycle boundaries for CLI callers. */
24
24
  export interface GraphitiCliDependencies {
@@ -6,7 +6,6 @@ import { defineService, type CliServiceDefinition } from "@dbx-tools/cli-service
6
6
  import { connectionUrl } from "@dbx-tools/lakebase";
7
7
  import { Command } from "commander";
8
8
 
9
- import { PACKAGE_VERSION } from "../../index.ts";
10
9
  import {
11
10
  LakebaseProxyOptionsSchema,
12
11
  LakebaseProxyUrlOptionsSchema,
@@ -14,6 +13,7 @@ import {
14
13
  type LakebaseProxyOptions,
15
14
  } from "./options.ts";
16
15
  import { LakebaseProxy } from "./proxy.ts";
16
+ import { PACKAGE_VERSION } from "../../index.ts";
17
17
 
18
18
  /** Injectable service boundary for Lakebase proxy CLI composition and tests. */
19
19
  export interface LakebaseProxyCliDependencies {
@@ -60,7 +60,10 @@ export function gatewayBearerMiddleware(token: string): express.RequestHandler {
60
60
  /** Start the foreground model gateway and keep its AppKit server active. */
61
61
  export async function startModelGateway(options: ModelGatewayOptions = {}): Promise<void> {
62
62
  const resolved = resolveModelGatewayOptions(options);
63
- const gateway = new ModelGateway();
63
+ const gateway = new ModelGateway({
64
+ ...(resolved.model ? { model: resolved.model } : {}),
65
+ ...(resolved.modelClass ? { modelClass: resolved.modelClass } : {}),
66
+ });
64
67
  const client = await workspaceClient.createWorkspaceClient({
65
68
  ...(resolved.profile ? { profile: resolved.profile } : {}),
66
69
  });