@databricks/appkit 0.59.0 → 0.61.0
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/NOTICE.md +11 -10
- package/dist/agents/databricks.js +1 -2
- package/dist/agents/databricks.js.map +1 -1
- package/dist/agents/supervisor-api.js +1 -2
- package/dist/agents/supervisor-api.js.map +1 -1
- package/dist/appkit/package.js +1 -1
- package/dist/cache/index.js +2 -3
- package/dist/cache/index.js.map +1 -1
- package/dist/cli/commands/doctor/bundle.js +3 -11
- package/dist/cli/commands/doctor/bundle.js.map +1 -1
- package/dist/cli/commands/doctor/databricks-client.js +18 -22
- package/dist/cli/commands/doctor/databricks-client.js.map +1 -1
- package/dist/cli/commands/registry/add.js +410 -0
- package/dist/cli/commands/registry/add.js.map +1 -0
- package/dist/cli/commands/registry/client.js +94 -0
- package/dist/cli/commands/registry/client.js.map +1 -0
- package/dist/cli/commands/registry/config-plan.js +110 -0
- package/dist/cli/commands/registry/config-plan.js.map +1 -0
- package/dist/cli/commands/registry/config-writer.js +176 -0
- package/dist/cli/commands/registry/config-writer.js.map +1 -0
- package/dist/cli/commands/registry/constants.js +62 -0
- package/dist/cli/commands/registry/constants.js.map +1 -0
- package/dist/cli/commands/registry/env-reconcile.js +116 -0
- package/dist/cli/commands/registry/env-reconcile.js.map +1 -0
- package/dist/cli/commands/registry/env-writer.js +198 -0
- package/dist/cli/commands/registry/env-writer.js.map +1 -0
- package/dist/cli/commands/registry/index.js +25 -0
- package/dist/cli/commands/registry/index.js.map +1 -0
- package/dist/cli/commands/registry/info.js +45 -0
- package/dist/cli/commands/registry/info.js.map +1 -0
- package/dist/cli/commands/registry/list.js +130 -0
- package/dist/cli/commands/registry/list.js.map +1 -0
- package/dist/cli/commands/registry/requirements.js +92 -0
- package/dist/cli/commands/registry/requirements.js.map +1 -0
- package/dist/cli/commands/registry/server-register.js +124 -0
- package/dist/cli/commands/registry/server-register.js.map +1 -0
- package/dist/cli/commands/registry/workspace-picker.js +353 -0
- package/dist/cli/commands/registry/workspace-picker.js.map +1 -0
- package/dist/cli/deploy-config.js +36 -0
- package/dist/cli/deploy-config.js.map +1 -0
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/connectors/context.js +1 -2
- package/dist/connectors/context.js.map +1 -1
- package/dist/connectors/files/client.js +1 -2
- package/dist/connectors/files/client.js.map +1 -1
- package/dist/connectors/genie/client.js +1 -2
- package/dist/connectors/genie/client.js.map +1 -1
- package/dist/connectors/jobs/client.js +1 -2
- package/dist/connectors/jobs/client.js.map +1 -1
- package/dist/connectors/sql-warehouse/client.js +1 -2
- package/dist/connectors/sql-warehouse/client.js.map +1 -1
- package/dist/context/execution-context.d.ts +0 -1
- package/dist/context/execution-context.d.ts.map +1 -1
- package/dist/context/service-context.d.ts +1 -2
- package/dist/context/service-context.d.ts.map +1 -1
- package/dist/context/service-context.js +2 -3
- package/dist/context/service-context.js.map +1 -1
- package/dist/core/appkit.d.ts +1 -2
- package/dist/core/appkit.d.ts.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +2 -3
- package/dist/plugins/agents/agents.d.ts.map +1 -1
- package/dist/plugins/agents/agents.js +117 -80
- package/dist/plugins/agents/agents.js.map +1 -1
- package/dist/plugins/agents/manifest.js +10 -0
- package/dist/plugins/agents/mlflow.js +123 -0
- package/dist/plugins/agents/mlflow.js.map +1 -0
- package/dist/plugins/agents/schemas.js +4 -2
- package/dist/plugins/agents/schemas.js.map +1 -1
- package/dist/plugins/files/plugin.js +1 -2
- package/dist/plugins/files/plugin.js.map +1 -1
- package/dist/plugins/files/types.d.ts +1 -2
- package/dist/plugins/files/types.d.ts.map +1 -1
- package/dist/plugins/jobs/types.d.ts +1 -2
- package/dist/plugins/jobs/types.d.ts.map +1 -1
- package/dist/plugins/lakebase/lakebase.js +1 -2
- package/dist/plugins/lakebase/lakebase.js.map +1 -1
- package/dist/schemas/manifest.js +4 -4
- package/dist/schemas/manifest.js.map +1 -1
- package/dist/shared/src/index.d.ts +4 -1
- package/dist/shared/src/schemas/manifest.d.ts +6 -6
- package/dist/shared/src/workspace-client/client.js +57 -0
- package/dist/shared/src/workspace-client/client.js.map +1 -0
- package/dist/shared/src/workspace-client/errors.d.ts +2 -0
- package/dist/shared/src/workspace-client/errors.js +3 -0
- package/dist/shared/src/workspace-client/factory.d.ts +19 -0
- package/dist/shared/src/workspace-client/factory.d.ts.map +1 -0
- package/dist/shared/src/workspace-client/factory.js +24 -0
- package/dist/shared/src/workspace-client/factory.js.map +1 -0
- package/dist/shared/src/workspace-client/index.d.ts +4 -0
- package/dist/shared/src/workspace-client/legacy.d.ts +31 -0
- package/dist/shared/src/workspace-client/legacy.d.ts.map +1 -0
- package/dist/shared/src/workspace-client/legacy.js +23 -0
- package/dist/shared/src/workspace-client/legacy.js.map +1 -0
- package/dist/shared/src/workspace-client/types.d.ts +49 -0
- package/dist/shared/src/workspace-client/types.d.ts.map +1 -0
- package/dist/type-generator/index.js +1 -2
- package/dist/type-generator/index.js.map +1 -1
- package/dist/type-generator/query-registry.js +1 -2
- package/dist/type-generator/query-registry.js.map +1 -1
- package/dist/type-generator/serving/fetcher.js +1 -2
- package/dist/type-generator/serving/fetcher.js.map +1 -1
- package/dist/type-generator/serving/generator.js +1 -2
- package/dist/type-generator/serving/generator.js.map +1 -1
- package/dist/type-generator/vite-plugin.js +1 -2
- package/dist/type-generator/vite-plugin.js.map +1 -1
- package/dist/workspace-client/index.d.ts +4 -3
- package/dist/workspace-client/index.js +2 -2
- package/dist/workspace-client/legacy.d.ts +9 -4
- package/dist/workspace-client/legacy.d.ts.map +1 -1
- package/dist/workspace-client/legacy.js +3 -3
- package/dist/workspace-client/legacy.js.map +1 -1
- package/dist/workspace-client/types.d.ts +2 -2
- package/docs/api/appkit/Function.createWorkspaceClient.md +4 -4
- package/docs/api/appkit/Interface.WorkspaceClientOptions.md +11 -0
- package/package.json +6 -4
- package/sbom.cdx.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lakebase.js","names":["manifest"],"sources":["../../../src/plugins/lakebase/lakebase.ts"],"sourcesContent":["import type { QueryResult, QueryResultRow } from \"pg\";\nimport type { AgentToolDefinition, ToolProvider } from \"shared\";\nimport { z } from \"zod\";\nimport {\n createLakebasePool,\n createLakebasePoolManager,\n getLakebaseOrmConfig,\n getLakebasePgConfig,\n getUsernameWithApiLookup,\n type LakebasePool,\n type LakebasePoolManager,\n RoutingPool,\n} from \"../../connectors/lakebase\";\nimport { getClientOptions } from \"../../context/client-options\";\nimport { getUserContext } from \"../../context/execution-context\";\nimport { buildToolkitEntries } from \"../../core/agent/build-toolkit\";\nimport {\n defineTool,\n executeFromRegistry,\n toolsFromRegistry,\n} from \"../../core/agent/tools/define-tool\";\nimport { assertReadOnlySql } from \"../../core/agent/tools/sql-policy\";\nimport { createLogger } from \"../../logging/logger\";\nimport { Plugin, toPlugin } from \"../../plugin\";\nimport type { PluginManifest } from \"../../registry\";\nimport { createWorkspaceClient } from \"../../workspace-client\";\nimport manifest from \"./manifest.json\";\nimport type { ILakebaseConfig } from \"./types\";\n\nconst logger = createLogger(\"lakebase\");\n\n/** Default pool settings for per-user OBO pools. */\nconst OBO_POOL_DEFAULTS = {\n max: 3,\n allowExitOnIdle: true,\n idleTimeoutMillis: 30_000,\n};\n\n/**\n * AppKit plugin for Databricks Lakebase Autoscaling.\n *\n * Wraps `@databricks/lakebase` to provide a standard `pg.Pool` with automatic\n * OAuth token refresh, integrated with AppKit's logger and OpenTelemetry setup.\n *\n * Supports On-Behalf-Of (OBO) via `asUser(req)` — each user gets a separate\n * `pg.Pool` authenticated with their Databricks identity, enabling features\n * like Row-Level Security (RLS). Routing is handled transparently by\n * {@link RoutingPool}, which reads the execution context set by the base\n * class `asUser()`.\n *\n * @example\n * ```ts\n * import { createApp, lakebase, server } from \"@databricks/appkit\";\n *\n * const AppKit = await createApp({\n * plugins: [server(), lakebase()],\n * });\n *\n * // Service principal query\n * const result = await AppKit.lakebase.query(\"SELECT * FROM users WHERE id = $1\", [userId]);\n *\n * // User-scoped query (per-user pool, RLS enforced)\n * const mine = await AppKit.lakebase.asUser(req).query(\"SELECT * FROM my_data\");\n * ```\n */\nexport class LakebasePlugin extends Plugin implements ToolProvider {\n /** Plugin manifest declaring metadata and resource requirements */\n static manifest = manifest as PluginManifest<\"lakebase\">;\n\n protected declare config: ILakebaseConfig;\n private pool: RoutingPool | null = null;\n private oboPoolManager: LakebasePoolManager | null = null;\n\n /**\n * Initializes the Lakebase connection pool and OBO pool manager.\n * Called automatically by AppKit during the plugin setup phase.\n *\n * Creates a {@link RoutingPool} that automatically routes queries to either\n * the service-principal pool or a per-user pool based on the execution\n * context (set by `Plugin.asUser(req)` via AsyncLocalStorage).\n */\n async setup() {\n const poolConfig = {\n ...this.config.pool,\n workspaceClient:\n this.config.pool?.workspaceClient ??\n createWorkspaceClient({\n clientOptions: getClientOptions(),\n }).toLegacyWorkspaceClient(),\n };\n const user = await getUsernameWithApiLookup(poolConfig);\n\n const spPool = createLakebasePool({ ...poolConfig, user });\n logger.info(\"Lakebase SP pool initialized\");\n\n this.oboPoolManager = createLakebasePoolManager({\n ...poolConfig,\n ...OBO_POOL_DEFAULTS,\n });\n logger.info(\"Lakebase OBO pool manager initialized\");\n\n const oboManager = this.oboPoolManager;\n this.pool = new RoutingPool(spPool, (ctx) => {\n if (!oboManager) throw new Error(\"OBO pool manager not initialized\");\n // Lakebase OAuth roles use email as the postgres role when available\n const userKey = ctx.userEmail ?? ctx.userId;\n const isNew = !oboManager.hasPool(userKey);\n const pool = oboManager.getPool(\n userKey,\n {\n workspaceClient: ctx.client.toLegacyWorkspaceClient(),\n user: userKey,\n },\n ctx.tokenFingerprint,\n );\n if (isNew) {\n logger.debug(\"Created OBO pool for user (total: %d)\", oboManager.size);\n }\n return pool;\n });\n }\n\n /**\n * Executes a parameterized SQL query against the Lakebase pool.\n *\n * When called inside `asUser(req)`, the query automatically routes to\n * the per-user pool via {@link RoutingPool}.\n *\n * @param text - SQL query string, using `$1`, `$2`, ... placeholders\n * @param values - Parameter values corresponding to placeholders\n * @returns Query result with typed rows\n *\n * @example\n * ```ts\n * const result = await AppKit.lakebase.query<{ id: number; name: string }>(\n * \"SELECT id, name FROM users WHERE active = $1\",\n * [true],\n * );\n * ```\n */\n async query<T extends QueryResultRow = any>(\n text: string,\n values?: unknown[],\n ): Promise<QueryResult<T>> {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup(), which AppKit always awaits before exposing the plugin API\n return this.pool!.query<T>(text, values);\n }\n\n /**\n * Execute a single statement inside a `BEGIN READ ONLY … ROLLBACK`\n * transaction on a dedicated client.\n *\n * The three commands MUST share a connection — a naive\n * `pool.query(\"BEGIN READ ONLY; <stmt>; ROLLBACK\")` batch cannot accept\n * parameter values (PostgreSQL's Extended Query protocol rejects multi-\n * statement prepared queries), which would silently break every\n * parameterized query the agent tool issues.\n *\n * Returns the raw `rows` array for the user's statement. Side effects the\n * statement may attempt (writes, writable-function side effects) are\n * rejected by PostgreSQL under the read-only transaction posture.\n */\n private async runReadOnlyStatement(\n text: string,\n values?: unknown[],\n ): Promise<unknown[]> {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup()\n const client = await this.pool!.connect();\n try {\n await client.query(\"BEGIN READ ONLY\");\n const result = await client.query(text, values);\n return result.rows;\n } finally {\n try {\n await client.query(\"ROLLBACK\");\n } finally {\n client.release();\n }\n }\n }\n\n /**\n * Gracefully drains and closes all connection pools (SP + OBO).\n *\n * Runs as the plugin's `shutdown()` hook (phase 3 of the core lifecycle\n * manager's graceful shutdown), NOT in `abortActiveOperations()` (phase 2):\n * other plugins' `shutdown()` hooks may still need database connections to\n * drain state,\n * so the pools must outlive the abort phase. `pg.Pool#end()` waits for\n * checked-out clients to be released, so hooks running concurrently with\n * this one can still finish their in-flight queries. Errors are caught\n * and logged; this hook never throws.\n */\n async shutdown(): Promise<void> {\n if (this.pool) {\n logger.info(\"Closing Lakebase SP pool\");\n try {\n await this.pool.end();\n } catch (err) {\n logger.error(\"Error closing Lakebase SP pool: %O\", err);\n }\n this.pool = null;\n }\n if (this.oboPoolManager) {\n logger.info(\n \"Closing all Lakebase OBO pools (%d)\",\n this.oboPoolManager.size,\n );\n try {\n await this.oboPoolManager.closeAll();\n } catch (err) {\n logger.error(\"Error closing Lakebase OBO pools: %O\", err);\n }\n this.oboPoolManager = null;\n }\n }\n\n /**\n * Agent tool registry. Empty by default — the Lakebase plugin does NOT\n * expose its SQL connection to LLM agents unless the developer explicitly\n * opts in via `config.exposeAsAgentTool`. See {@link buildQueryTool}.\n */\n private tools: Record<string, ReturnType<typeof this.buildQueryTool>> = {};\n\n constructor(config: ILakebaseConfig) {\n super(config);\n this.config = config;\n if (config.exposeAsAgentTool) {\n this.tools = { query: this.buildQueryTool(config.exposeAsAgentTool) };\n logger.warn(\n \"Lakebase agent tool is enabled (readOnly=%s). Every agent with access to this plugin can execute SQL against the Lakebase database as the requesting user's identity.\",\n config.exposeAsAgentTool.readOnly !== false,\n );\n }\n }\n\n private buildQueryTool(\n opt: NonNullable<ILakebaseConfig[\"exposeAsAgentTool\"]>,\n ) {\n const readOnly = opt.readOnly !== false;\n return defineTool({\n description: readOnly\n ? \"Execute a read-only SQL query against the Lakebase PostgreSQL database. Only SELECT, WITH, SHOW, EXPLAIN, and DESCRIBE statements are accepted. Use $1, $2, etc. as placeholders and pass values separately.\"\n : \"Execute a parameterized SQL statement against the Lakebase PostgreSQL database. Use $1, $2, etc. as placeholders and pass values separately. This tool can modify data; every invocation requires explicit human approval.\",\n schema: z.object({\n text: z\n .string()\n .describe(\n \"SQL statement with $1, $2, ... placeholders for parameters\",\n ),\n values: z\n .array(z.unknown())\n .optional()\n .describe(\"Parameter values corresponding to placeholders\"),\n }),\n annotations: {\n effect: readOnly ? \"read\" : \"destructive\",\n idempotent: false,\n requiresUserContext: true,\n },\n execute: async (args, signal) => {\n // Matches the files plugin pattern: the pg connection API\n // doesn't accept AbortSignal in its current shape, so deeper\n // mid-call cancellation needs a separate plumbing pass on the\n // connector. This entry check still catches the common case —\n // a tool dispatched after the user already cancelled the\n // stream — and unwinds cleanly instead of running to\n // completion against the SQL warehouse.\n signal?.throwIfAborted();\n if (readOnly) {\n assertReadOnlySql(args.text);\n return this.runReadOnlyStatement(args.text, args.values);\n }\n const result = await this.query(args.text, args.values);\n return result.rows;\n },\n });\n }\n\n getAgentTools(): AgentToolDefinition[] {\n return toolsFromRegistry(this.tools);\n }\n\n async executeAgentTool(\n name: string,\n args: unknown,\n signal?: AbortSignal,\n ): Promise<unknown> {\n return executeFromRegistry(this.tools, name, args, signal);\n }\n\n toolkit(opts?: import(\"../../core/agent/types\").ToolkitOptions) {\n return buildToolkitEntries(this.name, this.tools, opts);\n }\n\n /**\n * Returns the pool config for the current execution context.\n * Inside `asUser(req)`, returns user-scoped config; otherwise SP config.\n */\n private activePoolConfig() {\n const ctx = getUserContext();\n if (ctx) {\n const user = ctx.userEmail ?? ctx.userId;\n return {\n ...this.config.pool,\n workspaceClient: ctx.client.toLegacyWorkspaceClient(),\n user,\n };\n }\n return this.config.pool;\n }\n\n /**\n * Returns the plugin's public API, accessible via `AppKit.lakebase`.\n *\n * - `pool` — The connection pool (routes to per-user pool when inside `asUser(req)`)\n * - `query` — Convenience method for executing parameterized SQL queries\n * - `getOrmConfig()` — Returns a config object compatible with Drizzle, TypeORM, Sequelize, etc.\n * Inside `asUser(req)`, returns user-scoped config.\n * - `getPgConfig()` — Returns a `pg.PoolConfig` object for manual pool construction.\n * Inside `asUser(req)`, returns user-scoped config.\n *\n * Use `AppKit.lakebase.asUser(req)` to get the same API backed by a per-user pool.\n */\n exports() {\n return {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup(), which AppKit always awaits before exposing the plugin API\n pool: this.pool! as LakebasePool,\n query: this.query.bind(this),\n getOrmConfig: () => getLakebaseOrmConfig(this.activePoolConfig()),\n getPgConfig: () => getLakebasePgConfig(this.activePoolCon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K,qBAAqB,KAAK,MAAM,KAAK,OAAO;;AAG1D,YADe,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,OAAO,EACzC;;GAEjB,CAAC;;CAGJ,gBAAuC;AACrC,SAAO,kBAAkB,KAAK,MAAM;;CAGtC,MAAM,iBACJ,MACA,MACA,QACkB;AAClB,SAAO,oBAAoB,KAAK,OAAO,MAAM,MAAM,OAAO;;CAG5D,QAAQ,MAAwD;AAC9D,SAAO,oBAAoB,KAAK,MAAM,KAAK,OAAO,KAAK;;;;;;CAOzD,AAAQ,mBAAmB;EACzB,MAAM,MAAM,gBAAgB;AAC5B,MAAI,KAAK;GACP,MAAM,OAAO,IAAI,aAAa,IAAI;AAClC,UAAO;IACL,GAAG,KAAK,OAAO;IACf,iBAAiB,IAAI,OAAO,yBAAyB;IACrD;IACD;;AAEH,SAAO,KAAK,OAAO;;;;;;;;;;;;;;CAerB,UAAU;AACR,SAAO;GAEL,MAAM,KAAK;GACX,OAAO,KAAK,MAAM,KAAK,KAAK;GAC5B,oBAAoB,qBAAqB,KAAK,kBAAkB,CAAC;GACjE,mBAAmB,oBAAoB,KAAK,kBAAkB,CAAC;GAChE;;;;;;AAOL,MAAa,WAAW,SAAS,eAAe"}
|
|
1
|
+
{"version":3,"file":"lakebase.js","names":["manifest"],"sources":["../../../src/plugins/lakebase/lakebase.ts"],"sourcesContent":["import type { QueryResult, QueryResultRow } from \"pg\";\nimport type { AgentToolDefinition, ToolProvider } from \"shared\";\nimport { z } from \"zod\";\nimport {\n createLakebasePool,\n createLakebasePoolManager,\n getLakebaseOrmConfig,\n getLakebasePgConfig,\n getUsernameWithApiLookup,\n type LakebasePool,\n type LakebasePoolManager,\n RoutingPool,\n} from \"../../connectors/lakebase\";\nimport { getClientOptions } from \"../../context/client-options\";\nimport { getUserContext } from \"../../context/execution-context\";\nimport { buildToolkitEntries } from \"../../core/agent/build-toolkit\";\nimport {\n defineTool,\n executeFromRegistry,\n toolsFromRegistry,\n} from \"../../core/agent/tools/define-tool\";\nimport { assertReadOnlySql } from \"../../core/agent/tools/sql-policy\";\nimport { createLogger } from \"../../logging/logger\";\nimport { Plugin, toPlugin } from \"../../plugin\";\nimport type { PluginManifest } from \"../../registry\";\nimport { createWorkspaceClient } from \"../../workspace-client\";\nimport manifest from \"./manifest.json\";\nimport type { ILakebaseConfig } from \"./types\";\n\nconst logger = createLogger(\"lakebase\");\n\n/** Default pool settings for per-user OBO pools. */\nconst OBO_POOL_DEFAULTS = {\n max: 3,\n allowExitOnIdle: true,\n idleTimeoutMillis: 30_000,\n};\n\n/**\n * AppKit plugin for Databricks Lakebase Autoscaling.\n *\n * Wraps `@databricks/lakebase` to provide a standard `pg.Pool` with automatic\n * OAuth token refresh, integrated with AppKit's logger and OpenTelemetry setup.\n *\n * Supports On-Behalf-Of (OBO) via `asUser(req)` — each user gets a separate\n * `pg.Pool` authenticated with their Databricks identity, enabling features\n * like Row-Level Security (RLS). Routing is handled transparently by\n * {@link RoutingPool}, which reads the execution context set by the base\n * class `asUser()`.\n *\n * @example\n * ```ts\n * import { createApp, lakebase, server } from \"@databricks/appkit\";\n *\n * const AppKit = await createApp({\n * plugins: [server(), lakebase()],\n * });\n *\n * // Service principal query\n * const result = await AppKit.lakebase.query(\"SELECT * FROM users WHERE id = $1\", [userId]);\n *\n * // User-scoped query (per-user pool, RLS enforced)\n * const mine = await AppKit.lakebase.asUser(req).query(\"SELECT * FROM my_data\");\n * ```\n */\nexport class LakebasePlugin extends Plugin implements ToolProvider {\n /** Plugin manifest declaring metadata and resource requirements */\n static manifest = manifest as PluginManifest<\"lakebase\">;\n\n protected declare config: ILakebaseConfig;\n private pool: RoutingPool | null = null;\n private oboPoolManager: LakebasePoolManager | null = null;\n\n /**\n * Initializes the Lakebase connection pool and OBO pool manager.\n * Called automatically by AppKit during the plugin setup phase.\n *\n * Creates a {@link RoutingPool} that automatically routes queries to either\n * the service-principal pool or a per-user pool based on the execution\n * context (set by `Plugin.asUser(req)` via AsyncLocalStorage).\n */\n async setup() {\n const poolConfig = {\n ...this.config.pool,\n workspaceClient:\n this.config.pool?.workspaceClient ??\n createWorkspaceClient({\n clientOptions: getClientOptions(),\n }).toLegacyWorkspaceClient(),\n };\n const user = await getUsernameWithApiLookup(poolConfig);\n\n const spPool = createLakebasePool({ ...poolConfig, user });\n logger.info(\"Lakebase SP pool initialized\");\n\n this.oboPoolManager = createLakebasePoolManager({\n ...poolConfig,\n ...OBO_POOL_DEFAULTS,\n });\n logger.info(\"Lakebase OBO pool manager initialized\");\n\n const oboManager = this.oboPoolManager;\n this.pool = new RoutingPool(spPool, (ctx) => {\n if (!oboManager) throw new Error(\"OBO pool manager not initialized\");\n // Lakebase OAuth roles use email as the postgres role when available\n const userKey = ctx.userEmail ?? ctx.userId;\n const isNew = !oboManager.hasPool(userKey);\n const pool = oboManager.getPool(\n userKey,\n {\n workspaceClient: ctx.client.toLegacyWorkspaceClient(),\n user: userKey,\n },\n ctx.tokenFingerprint,\n );\n if (isNew) {\n logger.debug(\"Created OBO pool for user (total: %d)\", oboManager.size);\n }\n return pool;\n });\n }\n\n /**\n * Executes a parameterized SQL query against the Lakebase pool.\n *\n * When called inside `asUser(req)`, the query automatically routes to\n * the per-user pool via {@link RoutingPool}.\n *\n * @param text - SQL query string, using `$1`, `$2`, ... placeholders\n * @param values - Parameter values corresponding to placeholders\n * @returns Query result with typed rows\n *\n * @example\n * ```ts\n * const result = await AppKit.lakebase.query<{ id: number; name: string }>(\n * \"SELECT id, name FROM users WHERE active = $1\",\n * [true],\n * );\n * ```\n */\n async query<T extends QueryResultRow = any>(\n text: string,\n values?: unknown[],\n ): Promise<QueryResult<T>> {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup(), which AppKit always awaits before exposing the plugin API\n return this.pool!.query<T>(text, values);\n }\n\n /**\n * Execute a single statement inside a `BEGIN READ ONLY … ROLLBACK`\n * transaction on a dedicated client.\n *\n * The three commands MUST share a connection — a naive\n * `pool.query(\"BEGIN READ ONLY; <stmt>; ROLLBACK\")` batch cannot accept\n * parameter values (PostgreSQL's Extended Query protocol rejects multi-\n * statement prepared queries), which would silently break every\n * parameterized query the agent tool issues.\n *\n * Returns the raw `rows` array for the user's statement. Side effects the\n * statement may attempt (writes, writable-function side effects) are\n * rejected by PostgreSQL under the read-only transaction posture.\n */\n private async runReadOnlyStatement(\n text: string,\n values?: unknown[],\n ): Promise<unknown[]> {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup()\n const client = await this.pool!.connect();\n try {\n await client.query(\"BEGIN READ ONLY\");\n const result = await client.query(text, values);\n return result.rows;\n } finally {\n try {\n await client.query(\"ROLLBACK\");\n } finally {\n client.release();\n }\n }\n }\n\n /**\n * Gracefully drains and closes all connection pools (SP + OBO).\n *\n * Runs as the plugin's `shutdown()` hook (phase 3 of the core lifecycle\n * manager's graceful shutdown), NOT in `abortActiveOperations()` (phase 2):\n * other plugins' `shutdown()` hooks may still need database connections to\n * drain state,\n * so the pools must outlive the abort phase. `pg.Pool#end()` waits for\n * checked-out clients to be released, so hooks running concurrently with\n * this one can still finish their in-flight queries. Errors are caught\n * and logged; this hook never throws.\n */\n async shutdown(): Promise<void> {\n if (this.pool) {\n logger.info(\"Closing Lakebase SP pool\");\n try {\n await this.pool.end();\n } catch (err) {\n logger.error(\"Error closing Lakebase SP pool: %O\", err);\n }\n this.pool = null;\n }\n if (this.oboPoolManager) {\n logger.info(\n \"Closing all Lakebase OBO pools (%d)\",\n this.oboPoolManager.size,\n );\n try {\n await this.oboPoolManager.closeAll();\n } catch (err) {\n logger.error(\"Error closing Lakebase OBO pools: %O\", err);\n }\n this.oboPoolManager = null;\n }\n }\n\n /**\n * Agent tool registry. Empty by default — the Lakebase plugin does NOT\n * expose its SQL connection to LLM agents unless the developer explicitly\n * opts in via `config.exposeAsAgentTool`. See {@link buildQueryTool}.\n */\n private tools: Record<string, ReturnType<typeof this.buildQueryTool>> = {};\n\n constructor(config: ILakebaseConfig) {\n super(config);\n this.config = config;\n if (config.exposeAsAgentTool) {\n this.tools = { query: this.buildQueryTool(config.exposeAsAgentTool) };\n logger.warn(\n \"Lakebase agent tool is enabled (readOnly=%s). Every agent with access to this plugin can execute SQL against the Lakebase database as the requesting user's identity.\",\n config.exposeAsAgentTool.readOnly !== false,\n );\n }\n }\n\n private buildQueryTool(\n opt: NonNullable<ILakebaseConfig[\"exposeAsAgentTool\"]>,\n ) {\n const readOnly = opt.readOnly !== false;\n return defineTool({\n description: readOnly\n ? \"Execute a read-only SQL query against the Lakebase PostgreSQL database. Only SELECT, WITH, SHOW, EXPLAIN, and DESCRIBE statements are accepted. Use $1, $2, etc. as placeholders and pass values separately.\"\n : \"Execute a parameterized SQL statement against the Lakebase PostgreSQL database. Use $1, $2, etc. as placeholders and pass values separately. This tool can modify data; every invocation requires explicit human approval.\",\n schema: z.object({\n text: z\n .string()\n .describe(\n \"SQL statement with $1, $2, ... placeholders for parameters\",\n ),\n values: z\n .array(z.unknown())\n .optional()\n .describe(\"Parameter values corresponding to placeholders\"),\n }),\n annotations: {\n effect: readOnly ? \"read\" : \"destructive\",\n idempotent: false,\n requiresUserContext: true,\n },\n execute: async (args, signal) => {\n // Matches the files plugin pattern: the pg connection API\n // doesn't accept AbortSignal in its current shape, so deeper\n // mid-call cancellation needs a separate plumbing pass on the\n // connector. This entry check still catches the common case —\n // a tool dispatched after the user already cancelled the\n // stream — and unwinds cleanly instead of running to\n // completion against the SQL warehouse.\n signal?.throwIfAborted();\n if (readOnly) {\n assertReadOnlySql(args.text);\n return this.runReadOnlyStatement(args.text, args.values);\n }\n const result = await this.query(args.text, args.values);\n return result.rows;\n },\n });\n }\n\n getAgentTools(): AgentToolDefinition[] {\n return toolsFromRegistry(this.tools);\n }\n\n async executeAgentTool(\n name: string,\n args: unknown,\n signal?: AbortSignal,\n ): Promise<unknown> {\n return executeFromRegistry(this.tools, name, args, signal);\n }\n\n toolkit(opts?: import(\"../../core/agent/types\").ToolkitOptions) {\n return buildToolkitEntries(this.name, this.tools, opts);\n }\n\n /**\n * Returns the pool config for the current execution context.\n * Inside `asUser(req)`, returns user-scoped config; otherwise SP config.\n */\n private activePoolConfig() {\n const ctx = getUserContext();\n if (ctx) {\n const user = ctx.userEmail ?? ctx.userId;\n return {\n ...this.config.pool,\n workspaceClient: ctx.client.toLegacyWorkspaceClient(),\n user,\n };\n }\n return this.config.pool;\n }\n\n /**\n * Returns the plugin's public API, accessible via `AppKit.lakebase`.\n *\n * - `pool` — The connection pool (routes to per-user pool when inside `asUser(req)`)\n * - `query` — Convenience method for executing parameterized SQL queries\n * - `getOrmConfig()` — Returns a config object compatible with Drizzle, TypeORM, Sequelize, etc.\n * Inside `asUser(req)`, returns user-scoped config.\n * - `getPgConfig()` — Returns a `pg.PoolConfig` object for manual pool construction.\n * Inside `asUser(req)`, returns user-scoped config.\n *\n * Use `AppKit.lakebase.asUser(req)` to get the same API backed by a per-user pool.\n */\n exports() {\n return {\n // biome-ignore lint/style/noNonNullAssertion: pool is guaranteed non-null after setup(), which AppKit always awaits before exposing the plugin API\n pool: this.pool! as LakebasePool,\n query: this.query.bind(this),\n getOrmConfig: () => getLakebaseOrmConfig(this.activePoolConfig()),\n getPgConfig: () => getLakebasePgConfig(this.activePoolConfig()),\n };\n }\n}\n\n/**\n * @internal\n */\nexport const lakebase = toPlugin(LakebasePlugin);\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,MAAM,SAAS,aAAa,WAAW;;AAGvC,MAAM,oBAAoB;CACxB,KAAK;CACL,iBAAiB;CACjB,mBAAmB;CACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,IAAa,iBAAb,cAAoC,OAA+B;;CAEjE,OAAO,WAAWA;CAGlB,AAAQ,OAA2B;CACnC,AAAQ,iBAA6C;;;;;;;;;CAUrD,MAAM,QAAQ;EACZ,MAAM,aAAa;GACjB,GAAG,KAAK,OAAO;GACf,iBACE,KAAK,OAAO,MAAM,mBAClB,sBAAsB,EACpB,eAAe,kBAAkB,EAClC,CAAC,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B,IAAI,OAAO,yBAAyB;IACrD;IACD;;AAEH,SAAO,KAAK,OAAO;;;;;;;;;;;;;;CAerB,UAAU;AACR,SAAO;GAEL,MAAM,KAAK;GACX,OAAO,KAAK,MAAM,KAAK,KAAK;GAC5B,oBAAoB,qBAAqB,KAAK,kBAAkB,CAAC;GACjE,mBAAmB,oBAAoB,KAAK,kBAAkB,CAAC;GAChE;;;;;;AAOL,MAAa,WAAW,SAAS,eAAe"}
|
package/dist/schemas/manifest.js
CHANGED
|
@@ -354,9 +354,9 @@ const originSchema = z.enum([
|
|
|
354
354
|
* - `resolve !== undefined` → `"cli"` (resolved by the CLI during init).
|
|
355
355
|
* - else → `"user"` (user must provide the value at init time).
|
|
356
356
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* through
|
|
357
|
+
* The single source for this rule: `plugin sync`'s transform stamps `origin`
|
|
358
|
+
* with it, and consumers that read an authored manifest (no stamped `origin`)
|
|
359
|
+
* derive it through this rather than re-implementing the cascade.
|
|
360
360
|
*/
|
|
361
361
|
function computeOriginFromField(field) {
|
|
362
362
|
if (field.localOnly) return "platform";
|
|
@@ -522,5 +522,5 @@ const templatePluginsManifestSchema = z.object({
|
|
|
522
522
|
}).describe("Aggregated plugin manifest for AppKit templates. Read by Databricks CLI during init to discover available plugins and their resource requirements.");
|
|
523
523
|
|
|
524
524
|
//#endregion
|
|
525
|
-
export { TEMPLATE_SCAFFOLDING, appPermissionSchema, databasePermissionSchema, experimentPermissionSchema, genieSpacePermissionSchema, jobPermissionSchema, pluginManifestSchema, postgresPermissionSchema, resourceTypeSchema, secretPermissionSchema, servingEndpointPermissionSchema, sqlWarehousePermissionSchema, templateFieldEntrySchema, templatePluginsManifestSchema, ucConnectionPermissionSchema, ucFunctionPermissionSchema, vectorSearchIndexPermissionSchema, volumePermissionSchema };
|
|
525
|
+
export { TEMPLATE_SCAFFOLDING, appPermissionSchema, computeOriginFromField, databasePermissionSchema, experimentPermissionSchema, genieSpacePermissionSchema, jobPermissionSchema, pluginManifestSchema, postgresPermissionSchema, resourceTypeSchema, secretPermissionSchema, servingEndpointPermissionSchema, sqlWarehousePermissionSchema, templateFieldEntrySchema, templatePluginsManifestSchema, ucConnectionPermissionSchema, ucFunctionPermissionSchema, vectorSearchIndexPermissionSchema, volumePermissionSchema };
|
|
526
526
|
//# sourceMappingURL=manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":[],"sources":["../../src/schemas/manifest.ts"],"sourcesContent":["/**\n * Zod-authoring module for AppKit plugin manifest schemas.\n *\n * Single source of truth for the plugin manifest contract. JSON Schema\n * artifacts published at the docs URL are emitted from these schemas via\n * `tools/generate-json-schema.ts` and live only in `docs/static/schemas/`\n * (no package-internal copies).\n *\n * - Cross-field constraints (cycle/dangling-reference checks, `<PROFILE>`\n * placeholder, post-scaffold instruction non-empty) are refinements\n * co-located with the shape they constrain. Validation is driven through\n * the Standard Schema interface from `validate-manifest.ts`.\n * - `templateFieldEntrySchema` is a transform that emits `origin` from\n * `localOnly`/`value`/`resolve`. The input slot is still allowed so\n * re-parsing previously-synced template manifests does not fail, but the\n * transform always overwrites it — drift-by-construction for hand-edits.\n * - `discoveryDescriptorSchema` is a discriminated union over a `type`\n * literal. The `kind` variant references one of the well-known\n * `resourceKind` values for which AppKit owns the CLI command map (see\n * `RESOURCE_KIND_COMMANDS` below). The `cli` variant is the escape hatch\n * carrying the existing free-form fields (with the `<PROFILE>`\n * refinement). Hierarchical context for volumes (catalog/schema parent\n * walk) is encoded via the kind's `parents` array, not via dependsOn.\n * - Scaffolding rule items carry a `maxLength` (120 chars) so\n * `rules.never[]` / `rules.must[]` / `rules.should[]` stay short\n * directives by contract, and the canonical `TEMPLATE_SCAFFOLDING`\n * constant lives co-located with the scaffolding schemas (sync.ts\n * imports it).\n */\n\nimport { z } from \"zod\";\nimport { PLUGIN_NAME_PATTERN } from \"../naming\";\n\n// ── Resource type + per-type permission enums ────────────────────────────\n\nexport const resourceTypeSchema = z\n .enum([\n \"secret\",\n \"job\",\n \"sql_warehouse\",\n \"serving_endpoint\",\n \"volume\",\n \"vector_search_index\",\n \"uc_function\",\n \"uc_connection\",\n \"database\",\n \"postgres\",\n \"genie_space\",\n \"experiment\",\n \"app\",\n ])\n .describe(\"Type of Databricks resource\");\n\nexport const secretPermissionSchema = z\n .enum([\"READ\", \"WRITE\", \"MANAGE\"])\n .describe(\"Permission for secret resources (order: weakest to strongest)\");\n\nexport const jobPermissionSchema = z\n .enum([\"CAN_VIEW\", \"CAN_MANAGE_RUN\", \"CAN_MANAGE\"])\n .describe(\"Permission for job resources (order: weakest to strongest)\");\n\nexport const sqlWarehousePermissionSchema = z\n .enum([\"CAN_USE\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for SQL warehouse resources (order: weakest to strongest)\",\n );\n\nexport const servingEndpointPermissionSchema = z\n .enum([\"CAN_VIEW\", \"CAN_QUERY\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for serving endpoint resources (order: weakest to strongest)\",\n );\n\nexport const volumePermissionSchema = z\n .enum([\"READ_VOLUME\", \"WRITE_VOLUME\"])\n .describe(\"Permission for Unity Catalog volume resources\");\n\nexport const vectorSearchIndexPermissionSchema = z\n .enum([\"SELECT\"])\n .describe(\"Permission for vector search index resources\");\n\nexport const ucFunctionPermissionSchema = z\n .enum([\"EXECUTE\"])\n .describe(\"Permission for Unity Catalog function resources\");\n\nexport const ucConnectionPermissionSchema = z\n .enum([\"USE_CONNECTION\"])\n .describe(\"Permission for Unity Catalog connection resources\");\n\nexport const databasePermissionSchema = z\n .enum([\"CAN_CONNECT_AND_CREATE\"])\n .describe(\"Permission for database resources\");\n\nexport const postgresPermissionSchema = z\n .enum([\"CAN_CONNECT_AND_CREATE\"])\n .describe(\"Permission for Postgres resources\");\n\nexport const genieSpacePermissionSchema = z\n .enum([\"CAN_VIEW\", \"CAN_RUN\", \"CAN_EDIT\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for Genie Space resources (order: weakest to strongest)\",\n );\n\nexport const experimentPermissionSchema = z\n .enum([\"CAN_READ\", \"CAN_EDIT\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for MLflow experiment resources (order: weakest to strongest)\",\n );\n\nexport const appPermissionSchema = z\n .enum([\"CAN_USE\"])\n .describe(\"Permission for Databricks App resources\");\n\n// ── Discovery descriptor (discriminated union) ───────────────────────────\n\n/**\n * Well-known Databricks resource kinds for which AppKit owns the CLI\n * command map. Plugins reference one of these via the `kind` variant of the\n * discovery descriptor; everything else falls back to the free-form `cli`\n * variant.\n *\n * Kept narrow on purpose: each entry costs an addition to\n * `RESOURCE_KIND_COMMANDS` below, which is the single source of truth for\n * how that kind is enumerated.\n */\nexport const resourceKindSchema = z\n .enum([\n \"warehouse\",\n \"genie_space\",\n \"postgres_project\",\n \"postgres_branch\",\n \"postgres_database\",\n \"volume\",\n ])\n .describe(\n \"Well-known Databricks resource kind whose listing command is owned by AppKit (see RESOURCE_KIND_COMMANDS).\",\n );\n\nexport const kindDiscoveryDescriptorSchema = z\n .object({\n type: z\n .literal(\"kind\")\n .describe(\n \"Discriminator: 'kind' uses the AppKit-owned command map for the named resourceKind.\",\n ),\n resourceKind: resourceKindSchema.describe(\n \"Reference to a well-known Databricks resource kind. AppKit owns the CLI command, response shape, and unwrap rules.\",\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Field name in the parsed CLI response used as the selected value (e.g., 'id'). Defaults to the kind's natural identifier when omitted.\",\n ),\n display: z\n .string()\n .optional()\n .describe(\n \"Field name in the parsed CLI response shown to the user in selection UI. Defaults to `select` if omitted.\",\n ),\n dependsOn: z\n .string()\n .optional()\n .describe(\n \"Name of a sibling field within the same resource that must be resolved first. Used to express ordering dependencies between resource fields.\",\n ),\n shortcut: z\n .string()\n .optional()\n .describe(\n \"Single-value fast-path command that returns exactly one value, skipping interactive selection.\",\n ),\n })\n .strict()\n .describe(\n \"Discovery via a well-known resource kind. AppKit owns the CLI command and unwrap rules for the named kind.\",\n );\n\n/**\n * Shell metacharacters rejected on free-form CLI command strings. Catches the\n * common foot-guns (statement separators, pipes, redirects via shell, command\n * substitution, newlines). Not a security boundary on its own — executors must\n * always pass these via argv, never shell-exec the string. Angle brackets are\n * permitted because `<PROFILE>` (and future `<…>` placeholders) are part of\n * the command-template convention.\n */\nconst SHELL_METACHAR_RE = /[;|&`$\\n\\r]/;\n\nexport const cliDiscoveryDescriptorSchema = z\n .object({\n type: z\n .literal(\"cli\")\n .describe(\n \"Discriminator: 'cli' uses a free-form Databricks CLI command supplied by the plugin.\",\n ),\n cliCommand: z\n .string()\n .describe(\n \"Databricks CLI command that lists resources. Must include <PROFILE>. Shell metacharacters (;|&`$ and newlines) are rejected; for first-party Databricks resources prefer the `kind` variant which uses AppKit's typed command map.\",\n ),\n selectField: z\n .string()\n .describe(\n \"jq-style path to the field used as the selected value (e.g., '.id', '.name').\",\n ),\n displayField: z\n .string()\n .optional()\n .describe(\n \"jq-style path to the field shown to the user in selection UI. Defaults to selectField if omitted.\",\n ),\n dependsOn: z\n .string()\n .optional()\n .describe(\n \"Name of a sibling field within the same resource that must be resolved first. Used to express ordering dependencies between resource fields.\",\n ),\n shortcut: z\n .string()\n .optional()\n .describe(\n \"Single-value fast-path command that returns exactly one value, skipping interactive selection. Shell metacharacters are rejected.\",\n ),\n })\n .strict()\n .refine((descriptor) => descriptor.cliCommand.includes(\"<PROFILE>\"), {\n message: \"must include <PROFILE> placeholder\",\n path: [\"cliCommand\"],\n })\n .refine((descriptor) => !SHELL_METACHAR_RE.test(descriptor.cliCommand), {\n message:\n \"must not contain shell metacharacters (;|&`$ or newlines); use the `kind` variant for typed Databricks resources\",\n path: [\"cliCommand\"],\n })\n .refine(\n (descriptor) =>\n descriptor.shortcut === undefined ||\n !SHELL_METACHAR_RE.test(descriptor.shortcut),\n {\n message: \"must not contain shell metacharacters (;|&`$ or newlines)\",\n path: [\"shortcut\"],\n },\n )\n .describe(\n \"Discovery via a free-form Databricks CLI command. Escape hatch — prefer the `kind` variant when a typed resourceKind covers the resource. This shape is intentionally minimal and may tighten further in future versions.\",\n );\n\nexport const discoveryDescriptorSchema = z\n .discriminatedUnion(\"type\", [\n kindDiscoveryDescriptorSchema,\n cliDiscoveryDescriptorSchema,\n ])\n .describe(\n \"Describes how the CLI discovers values for a resource field. 'kind' references a well-known Databricks resource kind whose command is owned by AppKit; 'cli' is the escape hatch carrying a free-form Databricks CLI command.\",\n );\n\n// ── Resource kind → CLI command map ──────────────────────────────────────\n\n/**\n * Descriptor for how a well-known resource kind is listed via the\n * Databricks CLI.\n *\n * - `command` is the CLI invocation template. It carries two kinds of\n * placeholders:\n * - `<PROFILE>` — substituted with the user's CLI profile by the runner.\n * - `{<fieldName>}` — substituted with the resolved value of the named\n * sibling field (used for `dependsOn` chains).\n * - `unwrap`, when set, is the JSON path into the response wrapper (e.g.,\n * `\"warehouses\"` for `{ warehouses: [...] }`). Omitted when the response\n * is already a flat array.\n * - `parents`, when set, lists transient query inputs the runner must\n * collect (as free-text prompts) before invoking the command. Each\n * `parents[i]` value substitutes the matching `{name}` placeholder in\n * the command string. Unlike `dependsOn` (which references a sibling\n * field on the same resource), `parents` covers inputs that aren't\n * persisted as fields on the resource.\n */\nexport type ResourceKindCommand = {\n command: string;\n unwrap?: string;\n parents?: readonly string[];\n};\n\n/**\n * Single source of truth for AppKit-owned discovery commands.\n *\n * To add a new resource kind: extend `resourceKindSchema` and add an entry\n * here. Plugins reference the kind via `discovery: { type: \"kind\",\n * resourceKind: \"...\" }` and inherit the command + response shape.\n *\n * `unwrap` defaults are unset: the existing core plugin manifests use simple\n * jq paths (`.id`, `.name`, `.full_name`), implying the listed CLI commands\n * return flat arrays. Refine in a follow-up if a kind's CLI returns wrapped\n * data.\n *\n * Volume's catalog/schema parent context is supplied via the `parents`\n * array, which the runner collects from the user as free-text prompts\n * before invoking the listing command.\n */\nexport const RESOURCE_KIND_COMMANDS: Record<\n z.infer<typeof resourceKindSchema>,\n { command: string; unwrap?: string; parents?: readonly string[] }\n> = {\n warehouse: {\n command: \"databricks warehouses list --profile <PROFILE> --output json\",\n },\n genie_space: {\n command: \"databricks genie list-spaces --profile <PROFILE> --output json\",\n },\n postgres_project: {\n command:\n \"databricks postgres list-projects --profile <PROFILE> --output json\",\n },\n postgres_branch: {\n // {project} is a placeholder for the resolved value of the `project`\n // sibling field (declared via `dependsOn: \"project\"` on the kind variant).\n // The Databricks CLI requires the parent project resource name (format\n // `projects/{project_id}`) as a positional argument.\n command:\n \"databricks postgres list-branches {project} --profile <PROFILE> --output json\",\n },\n postgres_database: {\n // {branch} is a placeholder for the resolved value of the `branch`\n // sibling field (declared via `dependsOn: \"branch\"` on the kind variant).\n command:\n \"databricks postgres list-databases {branch} --profile <PROFILE> --output json\",\n },\n volume: {\n // `parents` declares free-text user prompts the runner must collect before\n // invoking the discovery command. Each `parents[i]` value substitutes the\n // matching `{name}` placeholder in the command string above. Unlike\n // `dependsOn` (which references a sibling field on the same resource),\n // `parents` covers transient query inputs that aren't persisted as fields.\n command:\n \"databricks volumes list {catalog} {schema} --profile <PROFILE> --output json\",\n parents: [\"catalog\", \"schema\"] as const,\n },\n};\n\n// ── Resource field entry (plugin manifest variant) ───────────────────────\n\nexport const resourceFieldEntrySchema = z\n .object({\n env: z\n .string()\n .regex(/^[A-Z][A-Z0-9_]*$/)\n .optional()\n .describe(\"Environment variable name for this field\"),\n description: z\n .string()\n .optional()\n .describe(\"Human-readable description for this field\"),\n bundleIgnore: z\n .boolean()\n .optional()\n .describe(\n \"When true, this field is excluded from Databricks bundle configuration (databricks.yml) generation.\",\n ),\n examples: z\n .array(z.string())\n .optional()\n .describe(\"Example values showing the expected format for this field\"),\n localOnly: z\n .boolean()\n .optional()\n .describe(\n \"When true, this field is only generated for local .env files. The Databricks Apps platform auto-injects it at deploy time.\",\n ),\n value: z\n .string()\n .optional()\n .describe(\n \"Static value for this field. Used when no prompted or resolved value exists.\",\n ),\n resolve: z\n .string()\n .regex(/^[a-z_]+:[a-zA-Z]+$/)\n .optional()\n .describe(\n \"Named resolver prefixed by resource type (e.g., 'postgres:host'). The CLI resolves this value during the init prompt flow.\",\n ),\n discovery: discoveryDescriptorSchema.optional(),\n })\n .strict()\n .describe(\n \"Defines a single field for a resource. Each field has its own environment variable and optional description. Single-value types use one key (e.g. id); multi-value types (database, secret) use multiple (e.g. instance_name, database_name or scope, key).\",\n );\n\n// ── Resource requirement (per-type permission discriminator) ─────────────\n\n/**\n * Build a per-type variant. Each variant fixes `type` to a literal and constrains\n * `permission` to the matching enum, mirroring the existing JSON Schema's\n * `allOf + if/then` block. `fields` and the rest of the shape come from a\n * shared base.\n */\nconst resourceRequirementBaseShape = {\n alias: z\n .string()\n .min(1)\n .describe(\n \"Human-readable label for UI/display only. Deduplication uses resourceKey, not alias.\",\n ),\n resourceKey: z\n .string()\n .regex(/^[a-z][a-z0-9-]*$/)\n .describe(\n \"Stable key for machine use: deduplication, env naming, composite keys, app.yaml. Required for registry lookup.\",\n ),\n description: z\n .string()\n .min(1)\n .describe(\"Human-readable description of why this resource is needed\"),\n fields: z\n .record(z.string(), resourceFieldEntrySchema)\n .refine((obj) => Object.keys(obj).length >= 1, {\n message: \"fields must contain at least one entry\",\n })\n .optional()\n .describe(\n \"Map of field name to env and optional description. Single-value types use one key (e.g. id); multi-value (database, secret) use multiple (e.g. instance_name, database_name or scope, key).\",\n ),\n};\n\n/**\n * Adds the cycle/dangling-reference cross-field check to a resource variant.\n * Iterates the resource's `fields`, validates each `discovery.dependsOn` target\n * is a sibling field name, then runs DFS over the dependsOn graph to detect\n * cycles. Issue paths target either the offending field's `dependsOn` slot or\n * the resource itself for cycles.\n */\nfunction refineResourceDependsOn(\n resource: { fields?: Record<string, { discovery?: { dependsOn?: string } }> },\n ctx: z.core.$RefinementCtx,\n): void {\n if (!resource.fields) return;\n const fieldNames = new Set(Object.keys(resource.fields));\n\n // Pass 1: validate dependsOn references and build the dependency graph.\n const deps = new Map<string, string>();\n for (const [name, field] of Object.entries(resource.fields)) {\n const dep = field.discovery?.dependsOn;\n if (!dep) continue;\n if (!fieldNames.has(dep)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"fields\", name, \"discovery\", \"dependsOn\"],\n message: `references non-existent sibling field '${dep}'`,\n });\n }\n deps.set(name, dep);\n }\n\n // Pass 2: detect cycles via DFS. Emit one issue per cycle found.\n const visited = new Set<string>();\n const visiting = new Set<string>();\n\n function dfs(node: string, chain: string[]): string[] | null {\n if (visiting.has(node)) return [...chain, node];\n if (visited.has(node)) return null;\n visiting.add(node);\n const next = deps.get(node);\n if (next) {\n const cycle = dfs(next, [...chain, node]);\n if (cycle) return cycle;\n }\n visiting.delete(node);\n visited.add(node);\n return null;\n }\n\n for (const node of deps.keys()) {\n if (visited.has(node)) continue;\n const cycle = dfs(node, []);\n if (cycle) {\n ctx.addIssue({\n code: \"custom\",\n path: [],\n message: `discovery.dependsOn creates a cycle: ${cycle.join(\" → \")}`,\n });\n // One cycle error per resource is enough.\n break;\n }\n }\n}\n\nfunction makeResourceVariant<\n TType extends z.ZodLiteral<string>,\n TPerm extends z.ZodTypeAny,\n>(typeLiteral: TType, permission: TPerm) {\n return z\n .object({\n type: typeLiteral,\n ...resourceRequirementBaseShape,\n permission: permission.describe(\n \"Required permission level. Validated per resource type.\",\n ),\n })\n .strict()\n .superRefine(refineResourceDependsOn);\n}\n\nexport const resourceRequirementSchema = z\n .discriminatedUnion(\"type\", [\n makeResourceVariant(z.literal(\"secret\"), secretPermissionSchema),\n makeResourceVariant(z.literal(\"job\"), jobPermissionSchema),\n makeResourceVariant(\n z.literal(\"sql_warehouse\"),\n sqlWarehousePermissionSchema,\n ),\n makeResourceVariant(\n z.literal(\"serving_endpoint\"),\n servingEndpointPermissionSchema,\n ),\n makeResourceVariant(z.literal(\"volume\"), volumePermissionSchema),\n makeResourceVariant(\n z.literal(\"vector_search_index\"),\n vectorSearchIndexPermissionSchema,\n ),\n makeResourceVariant(z.literal(\"uc_function\"), ucFunctionPermissionSchema),\n makeResourceVariant(\n z.literal(\"uc_connection\"),\n ucConnectionPermissionSchema,\n ),\n makeResourceVariant(z.literal(\"database\"), databasePermissionSchema),\n makeResourceVariant(z.literal(\"postgres\"), postgresPermissionSchema),\n makeResourceVariant(z.literal(\"genie_space\"), genieSpacePermissionSchema),\n makeResourceVariant(z.literal(\"experiment\"), experimentPermissionSchema),\n makeResourceVariant(z.literal(\"app\"), appPermissionSchema),\n ])\n .describe(\n \"Declares a resource requirement for a plugin. Can be defined statically in a manifest or dynamically via getResourceRequirements().\",\n );\n\n// ── Config schema (recursive) ────────────────────────────────────────────\n\nexport const configSchemaPropertySchema: z.ZodType = z.lazy(() =>\n z\n .object({\n type: z.enum([\n \"object\",\n \"array\",\n \"string\",\n \"number\",\n \"boolean\",\n \"integer\",\n ]),\n description: z.string().optional(),\n default: z.unknown().optional(),\n enum: z.array(z.unknown()).optional(),\n properties: z.record(z.string(), configSchemaPropertySchema).optional(),\n items: configSchemaPropertySchema.optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n minLength: z.number().int().min(0).optional(),\n maxLength: z.number().int().min(0).optional(),\n required: z.array(z.string()).optional(),\n // `additionalProperties` is a standard JSON Schema keyword used by core\n // plugin manifests (e.g., serving, ai-search, genie) to constrain\n // dictionary-shaped properties. Allowed on nested property entries as\n // either a boolean or a sub-schema, mirroring JSON Schema semantics.\n additionalProperties: z\n .union([z.boolean(), configSchemaPropertySchema])\n .optional(),\n })\n .strict(),\n);\n\nexport const configSchemaSchema: z.ZodType = z.lazy(() =>\n z\n .object({\n type: z.enum([\"object\", \"array\", \"string\", \"number\", \"boolean\"]),\n properties: z.record(z.string(), configSchemaPropertySchema).optional(),\n items: configSchemaSchema.optional(),\n required: z.array(z.string()).optional(),\n additionalProperties: z.boolean().optional(),\n })\n .strict(),\n);\n\n// ── Plugin-level scaffolding rules ───────────────────────────────────────\n\n/**\n * Per-item upper bound on plugin-level scaffolding rule strings. Matches the\n * template-level `SCAFFOLDING_RULE_MAX_LENGTH` defined below — rules at both\n * levels are short directives, not prose. The literal value lives here (and\n * not by reference to the template-side constant) because this declaration\n * is read in source order and the template constant is declared later.\n */\nconst PLUGIN_SCAFFOLDING_RULE_MAX_LENGTH = 120;\n\nconst pluginScaffoldingRuleItemSchema = z\n .string()\n .min(1)\n .max(\n PLUGIN_SCAFFOLDING_RULE_MAX_LENGTH,\n `rule entries must be ≤ ${PLUGIN_SCAFFOLDING_RULE_MAX_LENGTH} chars`,\n );\n\nexport const pluginScaffoldingRulesSchema = z\n .object({\n must: z\n .array(pluginScaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must always perform.\"),\n should: z\n .array(pluginScaffoldingRuleItemSchema)\n .optional()\n .describe(\"Recommended actions for the scaffolding agent.\"),\n never: z\n .array(pluginScaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must never perform.\"),\n })\n .strict()\n .superRefine((rules, ctx) => {\n // (a) Reject duplicate entries within any single array.\n const buckets: Array<[\"must\" | \"should\" | \"never\", string[] | undefined]> =\n [\n [\"must\", rules.must],\n [\"should\", rules.should],\n [\"never\", rules.never],\n ];\n for (const [bucketName, items] of buckets) {\n if (!items) continue;\n const seen = new Map<string, number>();\n items.forEach((item, idx) => {\n const prev = seen.get(item);\n if (prev === undefined) {\n seen.set(item, idx);\n return;\n }\n ctx.addIssue({\n code: \"custom\",\n path: [bucketName, idx],\n message: `duplicate rule entry: \"${item}\" already declared at index ${prev}`,\n });\n });\n }\n // (b) Reject a string that appears in more than one of must/should/never.\n type Bucket = \"must\" | \"should\" | \"never\";\n const owner = new Map<string, Bucket>();\n for (const [bucketName, items] of buckets) {\n if (!items) continue;\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const existing = owner.get(item);\n if (existing === undefined) {\n owner.set(item, bucketName);\n continue;\n }\n if (existing !== bucketName) {\n ctx.addIssue({\n code: \"custom\",\n path: [bucketName, i],\n message: `rule entry \"${item}\" appears in both '${existing}' and '${bucketName}'; rules must belong to exactly one bucket`,\n });\n }\n }\n }\n })\n .describe(\n \"Structured rules for scaffolding agents declared at the plugin level. Each rule is a short directive (≤120 chars).\",\n );\n\n// ── Plugin manifest (root) ───────────────────────────────────────────────\n\nexport const pluginManifestSchema = z\n .object({\n $schema: z\n .string()\n .optional()\n .describe(\"Reference to the JSON Schema for validation\"),\n name: z\n .string()\n .regex(PLUGIN_NAME_PATTERN)\n .describe(\n \"Plugin identifier and JS binding. Must start with a lowercase letter; camelCase for multi-word names (e.g. aiSearch).\",\n ),\n displayName: z\n .string()\n .min(1)\n .describe(\"Human-readable display name for UI and CLI\"),\n description: z\n .string()\n .min(1)\n .describe(\"Brief description of what the plugin does\"),\n resources: z\n .object({\n required: z\n .array(resourceRequirementSchema)\n .describe(\n \"Resources that must be available for the plugin to function\",\n ),\n optional: z\n .array(resourceRequirementSchema)\n .describe(\n \"Resources that enhance functionality but are not mandatory\",\n ),\n })\n .strict()\n .describe(\"Databricks resource requirements for this plugin\"),\n config: z\n .object({\n schema: configSchemaSchema.optional(),\n })\n .strict()\n .optional()\n .describe(\"Configuration schema for the plugin\"),\n author: z.string().optional().describe(\"Author name or organization\"),\n version: z\n .string()\n .regex(/^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?$/)\n .optional()\n .describe(\"Plugin version (semver format)\"),\n repository: z\n .url()\n .optional()\n .describe(\"URL to the plugin's source repository\"),\n keywords: z\n .array(z.string())\n .optional()\n .describe(\"Keywords for plugin discovery\"),\n license: z.string().optional().describe(\"SPDX license identifier\"),\n onSetupMessage: z\n .string()\n .optional()\n .describe(\n \"Message displayed to the user after project initialization. Use this to inform about manual setup steps (e.g. environment variables, resource provisioning).\",\n ),\n hidden: z\n .boolean()\n .optional()\n .describe(\n \"When true, this plugin is excluded from the template plugins manifest (appkit.plugins.json) during sync.\",\n ),\n devOnly: z\n .boolean()\n .optional()\n .describe(\n \"When true, this plugin is only registered when NODE_ENV === 'development'. In any other environment createApp skips it entirely (not constructed, no routes, resources not validated). Use for dev-only tooling that must never run in a deployed app.\",\n ),\n stability: z\n .enum([\"beta\", \"ga\"])\n .optional()\n .describe(\n \"Plugin stability level. Beta plugins may have breaking API changes between minor releases but are on a path to GA. GA (general availability) plugins follow semver strictly.\",\n ),\n scaffolding: z\n .object({\n rules: pluginScaffoldingRulesSchema\n .optional()\n .describe(\n \"Structured rules for scaffolding agents declared at the plugin level.\",\n ),\n })\n .strict()\n .optional()\n .describe(\n \"Plugin-level scaffolding metadata consumed by scaffolding agents. Symmetric with template-level `scaffolding`.\",\n ),\n })\n .strict()\n .describe(\n \"Schema for Databricks AppKit plugin manifest files. Defines plugin metadata, resource requirements, and configuration options.\",\n );\n\n// ── Origin enum ──────────────────────────────────────────────────────────\n\nexport const originSchema = z\n .enum([\"user\", \"platform\", \"static\", \"cli\"])\n .describe(\n \"How the field value is determined. Computed during sync, not authored by plugin developers.\",\n );\n\n// ── Template field entry (origin computed by transform) ─────────────────\n\n/**\n * Derives the canonical origin of a resource field value from its shape.\n *\n * - `localOnly: true` → `\"platform\"` (auto-injected by the Databricks Apps\n * platform at deploy time; takes precedence over `value`/`resolve`).\n * - `value !== undefined` → `\"static\"` (hardcoded value).\n * - `resolve !== undefined` → `\"cli\"` (resolved by the CLI during init).\n * - else → `\"user\"` (user must provide the value at init time).\n *\n * Co-located with `templateFieldEntrySchema` because the transform is the\n * only consumer. Kept private so any other \"origin computation\" goes\n * through the schema rather than re-implementing the rules.\n */\nfunction computeOriginFromField(field: {\n localOnly?: boolean;\n value?: string;\n resolve?: string;\n}): z.infer<typeof originSchema> {\n if (field.localOnly) return \"platform\";\n if (field.value !== undefined) return \"static\";\n if (field.resolve !== undefined) return \"cli\";\n return \"user\";\n}\n\n/**\n * Template field entry: extends the plugin manifest field entry with an\n * optional `origin` input slot, then runs a `.transform()` that overwrites\n * `origin` with the computed value. Allowing `origin` on input means\n * re-parsing a previously-synced template manifest does not fail; emitting\n * `origin` always means hand-edits in synced JSON are silently corrected\n * on the next parse — drift-by-construction.\n */\nexport const templateFieldEntrySchema = resourceFieldEntrySchema\n .extend({ origin: originSchema.optional() })\n .transform((field) => ({\n ...field,\n origin: computeOriginFromField(field),\n }));\n\n// ── Template resource requirement (uses templateFieldEntrySchema) ────────\n\nconst templateResourceRequirementBaseShape = {\n alias: z\n .string()\n .min(1)\n .describe(\"Human-readable label for UI/display only.\"),\n resourceKey: z\n .string()\n .regex(/^[a-z][a-z0-9-]*$/)\n .describe(\n \"Stable key for machine use: deduplication, env naming, composite keys.\",\n ),\n description: z\n .string()\n .min(1)\n .describe(\"Human-readable description of why this resource is needed\"),\n fields: z\n .record(z.string(), templateFieldEntrySchema)\n .refine((obj) => Object.keys(obj).length >= 1, {\n message: \"fields must contain at least one entry\",\n })\n .optional()\n .describe(\"Map of field name to field entry with computed origin.\"),\n};\n\nfunction makeTemplateResourceVariant<\n TType extends z.ZodLiteral<string>,\n TPerm extends z.ZodTypeAny,\n>(typeLiteral: TType, permission: TPerm) {\n return z\n .object({\n type: typeLiteral,\n ...templateResourceRequirementBaseShape,\n permission: permission.describe(\n \"Required permission level. Validated per resource type.\",\n ),\n })\n .strict()\n .superRefine(refineResourceDependsOn);\n}\n\nexport const templateResourceRequirementSchema = z\n .discriminatedUnion(\"type\", [\n makeTemplateResourceVariant(z.literal(\"secret\"), secretPermissionSchema),\n makeTemplateResourceVariant(z.literal(\"job\"), jobPermissionSchema),\n makeTemplateResourceVariant(\n z.literal(\"sql_warehouse\"),\n sqlWarehousePermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"serving_endpoint\"),\n servingEndpointPermissionSchema,\n ),\n makeTemplateResourceVariant(z.literal(\"volume\"), volumePermissionSchema),\n makeTemplateResourceVariant(\n z.literal(\"vector_search_index\"),\n vectorSearchIndexPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"uc_function\"),\n ucFunctionPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"uc_connection\"),\n ucConnectionPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"database\"),\n databasePermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"postgres\"),\n postgresPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"genie_space\"),\n genieSpacePermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"experiment\"),\n experimentPermissionSchema,\n ),\n makeTemplateResourceVariant(z.literal(\"app\"), appPermissionSchema),\n ])\n .describe(\n \"Resource requirement with template-specific field entries (includes computed origin).\",\n );\n\n// ── Template plugin (extends plugin manifest) ────────────────────────────\n\nexport const templatePluginSchema = z\n .object({\n name: z\n .string()\n .regex(PLUGIN_NAME_PATTERN)\n .describe(\n \"Plugin identifier and JS binding. Must start with a lowercase letter; camelCase for multi-word names (e.g. aiSearch).\",\n ),\n displayName: z\n .string()\n .min(1)\n .describe(\"Human-readable display name for UI and CLI\"),\n description: z\n .string()\n .min(1)\n .describe(\"Brief description of what the plugin does\"),\n package: z\n .string()\n .min(1)\n .describe(\"NPM package name that provides this plugin\"),\n requiredByTemplate: z\n .boolean()\n .optional()\n .describe(\n \"When true, this plugin is required by the template and cannot be deselected during CLI init. The user will only be prompted to configure its resources. When absent or false, the plugin is optional and the user can choose whether to include it.\",\n ),\n onSetupMessage: z\n .string()\n .optional()\n .describe(\n \"Message displayed to the user after project initialization. Use this to inform about manual setup steps (e.g. environment variables, resource provisioning).\",\n ),\n stability: z\n .enum([\"beta\", \"ga\"])\n .optional()\n .describe(\n \"Plugin stability level. Beta is heading to GA; APIs may change between minor releases. GA (general availability) follows semver.\",\n ),\n scaffolding: z\n .object({\n rules: pluginScaffoldingRulesSchema\n .optional()\n .describe(\n \"Structured rules for scaffolding agents propagated from the plugin manifest.\",\n ),\n })\n .strict()\n .optional()\n .describe(\n \"Plugin-level scaffolding metadata propagated from the plugin manifest.\",\n ),\n resources: z\n .object({\n required: z\n .array(templateResourceRequirementSchema)\n .describe(\n \"Resources that must be available for the plugin to function\",\n ),\n optional: z\n .array(templateResourceRequirementSchema)\n .describe(\n \"Resources that enhance functionality but are not mandatory\",\n ),\n })\n .strict()\n .describe(\"Databricks resource requirements for this plugin\"),\n })\n .strict()\n .describe(\"Plugin manifest with package source information\");\n\n// ── Scaffolding descriptor ───────────────────────────────────────────────\n\nexport const scaffoldingFlagSchema = z\n .object({\n description: z.string().describe(\"Human-readable description of the flag.\"),\n required: z.boolean().optional().describe(\"Whether this flag is required.\"),\n pattern: z\n .string()\n .optional()\n .describe(\"Regex pattern for validating the flag value.\"),\n default: z.string().optional().describe(\"Default value for this flag.\"),\n })\n .strict()\n .describe(\"A flag for the scaffolding command.\");\n\n/**\n * Per-item upper bound on scaffolding rule strings. The intent is to enforce\n * \"short directive\" by contract — long paragraphs fail validation and force\n * authors to split prose into discrete actionable items.\n */\nconst SCAFFOLDING_RULE_MAX_LENGTH = 120;\n\nconst scaffoldingRuleItemSchema = z\n .string()\n .max(\n SCAFFOLDING_RULE_MAX_LENGTH,\n `rule item must be ≤ ${SCAFFOLDING_RULE_MAX_LENGTH} chars`,\n );\n\nexport const scaffoldingRulesSchema = z\n .object({\n never: z\n .array(scaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must never perform.\"),\n must: z\n .array(scaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must always perform.\"),\n should: z\n .array(scaffoldingRuleItemSchema)\n .optional()\n .describe(\n \"Recommended actions for the scaffolding agent (parity with plugin-level rules).\",\n ),\n })\n .strict()\n .describe(\"Structured rules for scaffolding agents.\");\n\nexport const scaffoldingDescriptorSchema = z\n .object({\n command: z\n .string()\n .describe(\"The scaffolding command (e.g., 'databricks apps init').\"),\n flags: z\n .record(z.string(), scaffoldingFlagSchema)\n .optional()\n .describe(\"Map of flag name to flag descriptor.\"),\n rules: scaffoldingRulesSchema\n .optional()\n .describe(\"Structured rules for scaffolding agents.\"),\n })\n .strict()\n .describe(\n \"Describes the scaffolding command, flags, and rules for project initialization.\",\n );\n\n/**\n * Canonical scaffolding descriptor for the `databricks apps init` command,\n * embedded in v2.0 template manifests to guide scaffolding agents.\n *\n * Co-located with `scaffoldingDescriptorSchema` so any change to the rule set\n * (or the schema's `maxLength` ceiling) shows up next to its consumer. The\n * `satisfies` annotation gives compile-time validation that the literal\n * matches the schema's input shape; if a `must`/`never` entry exceeds the\n * `maxLength` ceiling at runtime, `scaffoldingDescriptorSchema.parse` would\n * surface the breach in tests.\n */\nexport const TEMPLATE_SCAFFOLDING = {\n command: \"databricks apps init\",\n flags: {\n \"--name\": {\n description:\n \"Project name — sets {{.projectName}} in package.json, databricks.yml, and .env. Required for non-interactive scaffolding.\",\n required: true,\n pattern: \"^[a-z][a-z0-9-]*$\",\n },\n \"--template\": {\n description: \"Template path (local directory or GitHub URL)\",\n required: false,\n },\n \"--version\": {\n description: \"AppKit version to use; defaults to auto-detected\",\n required: false,\n },\n \"--features\": {\n description:\n \"Plugins to enable (comma-separated, no spaces; must match keys in this manifest's plugins map)\",\n required: false,\n pattern: \"^[a-zA-Z0-9_-]+(,[a-zA-Z0-9_-]+)*$\",\n },\n \"--set\": {\n description:\n \"Set resource values (format: plugin.resourceKey.field=value, repeatable)\",\n required: false,\n },\n \"--output-dir\": {\n description: \"Directory to write the project to\",\n required: false,\n },\n \"--description\": {\n description: \"App description\",\n required: false,\n },\n \"--run\": {\n description: \"Run the app after creation (none, dev, dev-remote)\",\n required: false,\n },\n \"--auto-approve\": {\n description:\n \"Pass as a bare flag (no value) to skip prompts for optional resources. Not recommended for agent-driven init — conflicts with the 'ask user when in doubt' rule.\",\n required: false,\n },\n \"--profile\": {\n description:\n \"Databricks CLI profile to use for authentication (global flag)\",\n required: false,\n },\n },\n rules: {\n must: [\n \"Treat `databricks apps init` output as starter code, not requirements; adapt or replace it to match the requested app\",\n \"Keep all secrets and credentials only in app.yaml, databricks.yml, and/or .env\",\n ],\n should: [\"ask user when in doubt of resource to use for plugin\"],\n never: [\n \"guess resources when multiple or no options are available\",\n \"embed secrets in files that will go to the client-bundle\",\n ],\n },\n} satisfies z.infer<typeof scaffoldingDescriptorSchema>;\n\n// ── Template plugins manifest (root) ─────────────────────────────────────\n\nexport const templatePluginsManifestSchema = z\n .object({\n $schema: z\n .string()\n .optional()\n .describe(\"Reference to the JSON Schema for validation\"),\n version: z\n .enum([\"1.0\", \"1.1\", \"2.0\"])\n .describe(\"Schema version for the template plugins manifest\"),\n plugins: z\n .record(z.string(), templatePluginSchema)\n .describe(\"Map of plugin name to plugin manifest with package source\"),\n scaffolding: scaffoldingDescriptorSchema\n .optional()\n .describe(\n \"Describes the scaffolding command and its configuration for project initialization.\",\n ),\n })\n .strict()\n .superRefine((value, ctx) => {\n if (value.version === \"2.0\" && !value.scaffolding) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"scaffolding\"],\n message: \"scaffolding is required when version is '2.0'\",\n });\n }\n })\n .describe(\n \"Aggregated plugin manifest for AppKit templates. Read by Databricks CLI during init to discover available plugins and their resource requirements.\",\n );\n\n// ── Inferred types ───────────────────────────────────────────────────────\n\nexport type ResourceType = z.infer<typeof resourceTypeSchema>;\nexport type SecretPermission = z.infer<typeof secretPermissionSchema>;\nexport type JobPermission = z.infer<typeof jobPermissionSchema>;\nexport type SqlWarehousePermission = z.infer<\n typeof sqlWarehousePermissionSchema\n>;\nexport type ServingEndpointPermission = z.infer<\n typeof servingEndpointPermissionSchema\n>;\nexport type VolumePermission = z.infer<typeof volumePermissionSchema>;\nexport type VectorSearchIndexPermission = z.infer<\n typeof vectorSearchIndexPermissionSchema\n>;\nexport type UcFunctionPermission = z.infer<typeof ucFunctionPermissionSchema>;\nexport type UcConnectionPermission = z.infer<\n typeof ucConnectionPermissionSchema\n>;\nexport type DatabasePermission = z.infer<typeof databasePermissionSchema>;\nexport type PostgresPermission = z.infer<typeof postgresPermissionSchema>;\nexport type GenieSpacePermission = z.infer<typeof genieSpacePermissionSchema>;\nexport type ExperimentPermission = z.infer<typeof experimentPermissionSchema>;\nexport type AppPermission = z.infer<typeof appPermissionSchema>;\nexport type ResourceKind = z.infer<typeof resourceKindSchema>;\nexport type KindDiscoveryDescriptor = z.infer<\n typeof kindDiscoveryDescriptorSchema\n>;\nexport type CliDiscoveryDescriptor = z.infer<\n typeof cliDiscoveryDescriptorSchema\n>;\nexport type DiscoveryDescriptor = z.infer<typeof discoveryDescriptorSchema>;\nexport type ResourceFieldEntry = z.infer<typeof resourceFieldEntrySchema>;\nexport type ResourceRequirement = z.infer<typeof resourceRequirementSchema>;\nexport type ConfigSchemaProperty = z.infer<typeof configSchemaPropertySchema>;\nexport type ConfigSchema = z.infer<typeof configSchemaSchema>;\nexport type PluginScaffoldingRules = z.infer<\n typeof pluginScaffoldingRulesSchema\n>;\nexport type PluginManifest = z.infer<typeof pluginManifestSchema>;\nexport type Origin = z.infer<typeof originSchema>;\n// Template-side types use `z.input` so callers can construct a TemplatePlugin\n// from a parsed PluginManifest before the field-level origin transform runs.\n// `writeManifest` parses every field through `templateFieldEntrySchema` at\n// write-time, so the on-disk shape always has origin populated. The runtime\n// invariant: origin is *always* present after sync writes; the type slot\n// stays optional so the in-memory pipeline does not need to fabricate origin\n// before assignment.\nexport type TemplateFieldEntry = z.input<typeof templateFieldEntrySchema>;\nexport type TemplateResourceRequirement = z.input<\n typeof templateResourceRequirementSchema\n>;\nexport type TemplatePlugin = z.input<typeof templatePluginSchema>;\nexport type ScaffoldingFlag = z.infer<typeof scaffoldingFlagSchema>;\nexport type ScaffoldingRules = z.infer<typeof scaffoldingRulesSchema>;\nexport type ScaffoldingDescriptor = z.infer<typeof scaffoldingDescriptorSchema>;\nexport type TemplatePluginsManifest = z.input<\n typeof templatePluginsManifestSchema\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,qBAAqB,EAC/B,KAAK;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,CACD,SAAS,8BAA8B;AAE1C,MAAa,yBAAyB,EACnC,KAAK;CAAC;CAAQ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O;EACL,MAAM,CACJ,yHACA,iFACD;EACD,QAAQ,CAAC,uDAAuD;EAChE,OAAO,CACL,6DACA,2DACD;EACF;CACF;AAID,MAAa,gCAAgC,EAC1C,OAAO;CACN,SAAS,EACN,QAAQ,CACR,UAAU,CACV,SAAS,8CAA8C;CAC1D,SAAS,EACN,KAAK;EAAC;EAAO;EAAO;EAAM,CAAC,CAC3B,SAAS,mDAAmD;CAC/D,SAAS,EACN,OAAO,EAAE,QAAQ,EAAE,qBAAqB,CACxC,SAAS,4DAA4D;CACxE,aAAa,4BACV,UAAU,CACV,SACC,sFACD;CACJ,CAAC,CACD,QAAQ,CACR,aAAa,OAAO,QAAQ;AAC3B,KAAI,MAAM,YAAY,SAAS,CAAC,MAAM,YACpC,KAAI,SAAS;EACX,MAAM;EACN,MAAM,CAAC,cAAc;EACrB,SAAS;EACV,CAAC;EAEJ,CACD,SACC,qJACD"}
|
|
1
|
+
{"version":3,"file":"manifest.js","names":[],"sources":["../../src/schemas/manifest.ts"],"sourcesContent":["/**\n * Zod-authoring module for AppKit plugin manifest schemas.\n *\n * Single source of truth for the plugin manifest contract. JSON Schema\n * artifacts published at the docs URL are emitted from these schemas via\n * `tools/generate-json-schema.ts` and live only in `docs/static/schemas/`\n * (no package-internal copies).\n *\n * - Cross-field constraints (cycle/dangling-reference checks, `<PROFILE>`\n * placeholder, post-scaffold instruction non-empty) are refinements\n * co-located with the shape they constrain. Validation is driven through\n * the Standard Schema interface from `validate-manifest.ts`.\n * - `templateFieldEntrySchema` is a transform that emits `origin` from\n * `localOnly`/`value`/`resolve`. The input slot is still allowed so\n * re-parsing previously-synced template manifests does not fail, but the\n * transform always overwrites it — drift-by-construction for hand-edits.\n * - `discoveryDescriptorSchema` is a discriminated union over a `type`\n * literal. The `kind` variant references one of the well-known\n * `resourceKind` values for which AppKit owns the CLI command map (see\n * `RESOURCE_KIND_COMMANDS` below). The `cli` variant is the escape hatch\n * carrying the existing free-form fields (with the `<PROFILE>`\n * refinement). Hierarchical context for volumes (catalog/schema parent\n * walk) is encoded via the kind's `parents` array, not via dependsOn.\n * - Scaffolding rule items carry a `maxLength` (120 chars) so\n * `rules.never[]` / `rules.must[]` / `rules.should[]` stay short\n * directives by contract, and the canonical `TEMPLATE_SCAFFOLDING`\n * constant lives co-located with the scaffolding schemas (sync.ts\n * imports it).\n */\n\nimport { z } from \"zod\";\nimport { PLUGIN_NAME_PATTERN } from \"../naming\";\n\n// ── Resource type + per-type permission enums ────────────────────────────\n\nexport const resourceTypeSchema = z\n .enum([\n \"secret\",\n \"job\",\n \"sql_warehouse\",\n \"serving_endpoint\",\n \"volume\",\n \"vector_search_index\",\n \"uc_function\",\n \"uc_connection\",\n \"database\",\n \"postgres\",\n \"genie_space\",\n \"experiment\",\n \"app\",\n ])\n .describe(\"Type of Databricks resource\");\n\nexport const secretPermissionSchema = z\n .enum([\"READ\", \"WRITE\", \"MANAGE\"])\n .describe(\"Permission for secret resources (order: weakest to strongest)\");\n\nexport const jobPermissionSchema = z\n .enum([\"CAN_VIEW\", \"CAN_MANAGE_RUN\", \"CAN_MANAGE\"])\n .describe(\"Permission for job resources (order: weakest to strongest)\");\n\nexport const sqlWarehousePermissionSchema = z\n .enum([\"CAN_USE\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for SQL warehouse resources (order: weakest to strongest)\",\n );\n\nexport const servingEndpointPermissionSchema = z\n .enum([\"CAN_VIEW\", \"CAN_QUERY\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for serving endpoint resources (order: weakest to strongest)\",\n );\n\nexport const volumePermissionSchema = z\n .enum([\"READ_VOLUME\", \"WRITE_VOLUME\"])\n .describe(\"Permission for Unity Catalog volume resources\");\n\nexport const vectorSearchIndexPermissionSchema = z\n .enum([\"SELECT\"])\n .describe(\"Permission for vector search index resources\");\n\nexport const ucFunctionPermissionSchema = z\n .enum([\"EXECUTE\"])\n .describe(\"Permission for Unity Catalog function resources\");\n\nexport const ucConnectionPermissionSchema = z\n .enum([\"USE_CONNECTION\"])\n .describe(\"Permission for Unity Catalog connection resources\");\n\nexport const databasePermissionSchema = z\n .enum([\"CAN_CONNECT_AND_CREATE\"])\n .describe(\"Permission for database resources\");\n\nexport const postgresPermissionSchema = z\n .enum([\"CAN_CONNECT_AND_CREATE\"])\n .describe(\"Permission for Postgres resources\");\n\nexport const genieSpacePermissionSchema = z\n .enum([\"CAN_VIEW\", \"CAN_RUN\", \"CAN_EDIT\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for Genie Space resources (order: weakest to strongest)\",\n );\n\nexport const experimentPermissionSchema = z\n .enum([\"CAN_READ\", \"CAN_EDIT\", \"CAN_MANAGE\"])\n .describe(\n \"Permission for MLflow experiment resources (order: weakest to strongest)\",\n );\n\nexport const appPermissionSchema = z\n .enum([\"CAN_USE\"])\n .describe(\"Permission for Databricks App resources\");\n\n// ── Discovery descriptor (discriminated union) ───────────────────────────\n\n/**\n * Well-known Databricks resource kinds for which AppKit owns the CLI\n * command map. Plugins reference one of these via the `kind` variant of the\n * discovery descriptor; everything else falls back to the free-form `cli`\n * variant.\n *\n * Kept narrow on purpose: each entry costs an addition to\n * `RESOURCE_KIND_COMMANDS` below, which is the single source of truth for\n * how that kind is enumerated.\n */\nexport const resourceKindSchema = z\n .enum([\n \"warehouse\",\n \"genie_space\",\n \"postgres_project\",\n \"postgres_branch\",\n \"postgres_database\",\n \"volume\",\n ])\n .describe(\n \"Well-known Databricks resource kind whose listing command is owned by AppKit (see RESOURCE_KIND_COMMANDS).\",\n );\n\nexport const kindDiscoveryDescriptorSchema = z\n .object({\n type: z\n .literal(\"kind\")\n .describe(\n \"Discriminator: 'kind' uses the AppKit-owned command map for the named resourceKind.\",\n ),\n resourceKind: resourceKindSchema.describe(\n \"Reference to a well-known Databricks resource kind. AppKit owns the CLI command, response shape, and unwrap rules.\",\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Field name in the parsed CLI response used as the selected value (e.g., 'id'). Defaults to the kind's natural identifier when omitted.\",\n ),\n display: z\n .string()\n .optional()\n .describe(\n \"Field name in the parsed CLI response shown to the user in selection UI. Defaults to `select` if omitted.\",\n ),\n dependsOn: z\n .string()\n .optional()\n .describe(\n \"Name of a sibling field within the same resource that must be resolved first. Used to express ordering dependencies between resource fields.\",\n ),\n shortcut: z\n .string()\n .optional()\n .describe(\n \"Single-value fast-path command that returns exactly one value, skipping interactive selection.\",\n ),\n })\n .strict()\n .describe(\n \"Discovery via a well-known resource kind. AppKit owns the CLI command and unwrap rules for the named kind.\",\n );\n\n/**\n * Shell metacharacters rejected on free-form CLI command strings. Catches the\n * common foot-guns (statement separators, pipes, redirects via shell, command\n * substitution, newlines). Not a security boundary on its own — executors must\n * always pass these via argv, never shell-exec the string. Angle brackets are\n * permitted because `<PROFILE>` (and future `<…>` placeholders) are part of\n * the command-template convention.\n */\nconst SHELL_METACHAR_RE = /[;|&`$\\n\\r]/;\n\nexport const cliDiscoveryDescriptorSchema = z\n .object({\n type: z\n .literal(\"cli\")\n .describe(\n \"Discriminator: 'cli' uses a free-form Databricks CLI command supplied by the plugin.\",\n ),\n cliCommand: z\n .string()\n .describe(\n \"Databricks CLI command that lists resources. Must include <PROFILE>. Shell metacharacters (;|&`$ and newlines) are rejected; for first-party Databricks resources prefer the `kind` variant which uses AppKit's typed command map.\",\n ),\n selectField: z\n .string()\n .describe(\n \"jq-style path to the field used as the selected value (e.g., '.id', '.name').\",\n ),\n displayField: z\n .string()\n .optional()\n .describe(\n \"jq-style path to the field shown to the user in selection UI. Defaults to selectField if omitted.\",\n ),\n dependsOn: z\n .string()\n .optional()\n .describe(\n \"Name of a sibling field within the same resource that must be resolved first. Used to express ordering dependencies between resource fields.\",\n ),\n shortcut: z\n .string()\n .optional()\n .describe(\n \"Single-value fast-path command that returns exactly one value, skipping interactive selection. Shell metacharacters are rejected.\",\n ),\n })\n .strict()\n .refine((descriptor) => descriptor.cliCommand.includes(\"<PROFILE>\"), {\n message: \"must include <PROFILE> placeholder\",\n path: [\"cliCommand\"],\n })\n .refine((descriptor) => !SHELL_METACHAR_RE.test(descriptor.cliCommand), {\n message:\n \"must not contain shell metacharacters (;|&`$ or newlines); use the `kind` variant for typed Databricks resources\",\n path: [\"cliCommand\"],\n })\n .refine(\n (descriptor) =>\n descriptor.shortcut === undefined ||\n !SHELL_METACHAR_RE.test(descriptor.shortcut),\n {\n message: \"must not contain shell metacharacters (;|&`$ or newlines)\",\n path: [\"shortcut\"],\n },\n )\n .describe(\n \"Discovery via a free-form Databricks CLI command. Escape hatch — prefer the `kind` variant when a typed resourceKind covers the resource. This shape is intentionally minimal and may tighten further in future versions.\",\n );\n\nexport const discoveryDescriptorSchema = z\n .discriminatedUnion(\"type\", [\n kindDiscoveryDescriptorSchema,\n cliDiscoveryDescriptorSchema,\n ])\n .describe(\n \"Describes how the CLI discovers values for a resource field. 'kind' references a well-known Databricks resource kind whose command is owned by AppKit; 'cli' is the escape hatch carrying a free-form Databricks CLI command.\",\n );\n\n// ── Resource kind → CLI command map ──────────────────────────────────────\n\n/**\n * Descriptor for how a well-known resource kind is listed via the\n * Databricks CLI.\n *\n * - `command` is the CLI invocation template. It carries two kinds of\n * placeholders:\n * - `<PROFILE>` — substituted with the user's CLI profile by the runner.\n * - `{<fieldName>}` — substituted with the resolved value of the named\n * sibling field (used for `dependsOn` chains).\n * - `unwrap`, when set, is the JSON path into the response wrapper (e.g.,\n * `\"warehouses\"` for `{ warehouses: [...] }`). Omitted when the response\n * is already a flat array.\n * - `parents`, when set, lists transient query inputs the runner must\n * collect (as free-text prompts) before invoking the command. Each\n * `parents[i]` value substitutes the matching `{name}` placeholder in\n * the command string. Unlike `dependsOn` (which references a sibling\n * field on the same resource), `parents` covers inputs that aren't\n * persisted as fields on the resource.\n */\nexport type ResourceKindCommand = {\n command: string;\n unwrap?: string;\n parents?: readonly string[];\n};\n\n/**\n * Single source of truth for AppKit-owned discovery commands.\n *\n * To add a new resource kind: extend `resourceKindSchema` and add an entry\n * here. Plugins reference the kind via `discovery: { type: \"kind\",\n * resourceKind: \"...\" }` and inherit the command + response shape.\n *\n * `unwrap` defaults are unset: the existing core plugin manifests use simple\n * jq paths (`.id`, `.name`, `.full_name`), implying the listed CLI commands\n * return flat arrays. Refine in a follow-up if a kind's CLI returns wrapped\n * data.\n *\n * Volume's catalog/schema parent context is supplied via the `parents`\n * array, which the runner collects from the user as free-text prompts\n * before invoking the listing command.\n */\nexport const RESOURCE_KIND_COMMANDS: Record<\n z.infer<typeof resourceKindSchema>,\n { command: string; unwrap?: string; parents?: readonly string[] }\n> = {\n warehouse: {\n command: \"databricks warehouses list --profile <PROFILE> --output json\",\n },\n genie_space: {\n command: \"databricks genie list-spaces --profile <PROFILE> --output json\",\n },\n postgres_project: {\n command:\n \"databricks postgres list-projects --profile <PROFILE> --output json\",\n },\n postgres_branch: {\n // {project} is a placeholder for the resolved value of the `project`\n // sibling field (declared via `dependsOn: \"project\"` on the kind variant).\n // The Databricks CLI requires the parent project resource name (format\n // `projects/{project_id}`) as a positional argument.\n command:\n \"databricks postgres list-branches {project} --profile <PROFILE> --output json\",\n },\n postgres_database: {\n // {branch} is a placeholder for the resolved value of the `branch`\n // sibling field (declared via `dependsOn: \"branch\"` on the kind variant).\n command:\n \"databricks postgres list-databases {branch} --profile <PROFILE> --output json\",\n },\n volume: {\n // `parents` declares free-text user prompts the runner must collect before\n // invoking the discovery command. Each `parents[i]` value substitutes the\n // matching `{name}` placeholder in the command string above. Unlike\n // `dependsOn` (which references a sibling field on the same resource),\n // `parents` covers transient query inputs that aren't persisted as fields.\n command:\n \"databricks volumes list {catalog} {schema} --profile <PROFILE> --output json\",\n parents: [\"catalog\", \"schema\"] as const,\n },\n};\n\n// ── Resource field entry (plugin manifest variant) ───────────────────────\n\nexport const resourceFieldEntrySchema = z\n .object({\n env: z\n .string()\n .regex(/^[A-Z][A-Z0-9_]*$/)\n .optional()\n .describe(\"Environment variable name for this field\"),\n description: z\n .string()\n .optional()\n .describe(\"Human-readable description for this field\"),\n bundleIgnore: z\n .boolean()\n .optional()\n .describe(\n \"When true, this field is excluded from Databricks bundle configuration (databricks.yml) generation.\",\n ),\n examples: z\n .array(z.string())\n .optional()\n .describe(\"Example values showing the expected format for this field\"),\n localOnly: z\n .boolean()\n .optional()\n .describe(\n \"When true, this field is only generated for local .env files. The Databricks Apps platform auto-injects it at deploy time.\",\n ),\n value: z\n .string()\n .optional()\n .describe(\n \"Static value for this field. Used when no prompted or resolved value exists.\",\n ),\n resolve: z\n .string()\n .regex(/^[a-z_]+:[a-zA-Z]+$/)\n .optional()\n .describe(\n \"Named resolver prefixed by resource type (e.g., 'postgres:host'). The CLI resolves this value during the init prompt flow.\",\n ),\n discovery: discoveryDescriptorSchema.optional(),\n })\n .strict()\n .describe(\n \"Defines a single field for a resource. Each field has its own environment variable and optional description. Single-value types use one key (e.g. id); multi-value types (database, secret) use multiple (e.g. instance_name, database_name or scope, key).\",\n );\n\n// ── Resource requirement (per-type permission discriminator) ─────────────\n\n/**\n * Build a per-type variant. Each variant fixes `type` to a literal and constrains\n * `permission` to the matching enum, mirroring the existing JSON Schema's\n * `allOf + if/then` block. `fields` and the rest of the shape come from a\n * shared base.\n */\nconst resourceRequirementBaseShape = {\n alias: z\n .string()\n .min(1)\n .describe(\n \"Human-readable label for UI/display only. Deduplication uses resourceKey, not alias.\",\n ),\n resourceKey: z\n .string()\n .regex(/^[a-z][a-z0-9-]*$/)\n .describe(\n \"Stable key for machine use: deduplication, env naming, composite keys, app.yaml. Required for registry lookup.\",\n ),\n description: z\n .string()\n .min(1)\n .describe(\"Human-readable description of why this resource is needed\"),\n fields: z\n .record(z.string(), resourceFieldEntrySchema)\n .refine((obj) => Object.keys(obj).length >= 1, {\n message: \"fields must contain at least one entry\",\n })\n .optional()\n .describe(\n \"Map of field name to env and optional description. Single-value types use one key (e.g. id); multi-value (database, secret) use multiple (e.g. instance_name, database_name or scope, key).\",\n ),\n};\n\n/**\n * Adds the cycle/dangling-reference cross-field check to a resource variant.\n * Iterates the resource's `fields`, validates each `discovery.dependsOn` target\n * is a sibling field name, then runs DFS over the dependsOn graph to detect\n * cycles. Issue paths target either the offending field's `dependsOn` slot or\n * the resource itself for cycles.\n */\nfunction refineResourceDependsOn(\n resource: { fields?: Record<string, { discovery?: { dependsOn?: string } }> },\n ctx: z.core.$RefinementCtx,\n): void {\n if (!resource.fields) return;\n const fieldNames = new Set(Object.keys(resource.fields));\n\n // Pass 1: validate dependsOn references and build the dependency graph.\n const deps = new Map<string, string>();\n for (const [name, field] of Object.entries(resource.fields)) {\n const dep = field.discovery?.dependsOn;\n if (!dep) continue;\n if (!fieldNames.has(dep)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"fields\", name, \"discovery\", \"dependsOn\"],\n message: `references non-existent sibling field '${dep}'`,\n });\n }\n deps.set(name, dep);\n }\n\n // Pass 2: detect cycles via DFS. Emit one issue per cycle found.\n const visited = new Set<string>();\n const visiting = new Set<string>();\n\n function dfs(node: string, chain: string[]): string[] | null {\n if (visiting.has(node)) return [...chain, node];\n if (visited.has(node)) return null;\n visiting.add(node);\n const next = deps.get(node);\n if (next) {\n const cycle = dfs(next, [...chain, node]);\n if (cycle) return cycle;\n }\n visiting.delete(node);\n visited.add(node);\n return null;\n }\n\n for (const node of deps.keys()) {\n if (visited.has(node)) continue;\n const cycle = dfs(node, []);\n if (cycle) {\n ctx.addIssue({\n code: \"custom\",\n path: [],\n message: `discovery.dependsOn creates a cycle: ${cycle.join(\" → \")}`,\n });\n // One cycle error per resource is enough.\n break;\n }\n }\n}\n\nfunction makeResourceVariant<\n TType extends z.ZodLiteral<string>,\n TPerm extends z.ZodTypeAny,\n>(typeLiteral: TType, permission: TPerm) {\n return z\n .object({\n type: typeLiteral,\n ...resourceRequirementBaseShape,\n permission: permission.describe(\n \"Required permission level. Validated per resource type.\",\n ),\n })\n .strict()\n .superRefine(refineResourceDependsOn);\n}\n\nexport const resourceRequirementSchema = z\n .discriminatedUnion(\"type\", [\n makeResourceVariant(z.literal(\"secret\"), secretPermissionSchema),\n makeResourceVariant(z.literal(\"job\"), jobPermissionSchema),\n makeResourceVariant(\n z.literal(\"sql_warehouse\"),\n sqlWarehousePermissionSchema,\n ),\n makeResourceVariant(\n z.literal(\"serving_endpoint\"),\n servingEndpointPermissionSchema,\n ),\n makeResourceVariant(z.literal(\"volume\"), volumePermissionSchema),\n makeResourceVariant(\n z.literal(\"vector_search_index\"),\n vectorSearchIndexPermissionSchema,\n ),\n makeResourceVariant(z.literal(\"uc_function\"), ucFunctionPermissionSchema),\n makeResourceVariant(\n z.literal(\"uc_connection\"),\n ucConnectionPermissionSchema,\n ),\n makeResourceVariant(z.literal(\"database\"), databasePermissionSchema),\n makeResourceVariant(z.literal(\"postgres\"), postgresPermissionSchema),\n makeResourceVariant(z.literal(\"genie_space\"), genieSpacePermissionSchema),\n makeResourceVariant(z.literal(\"experiment\"), experimentPermissionSchema),\n makeResourceVariant(z.literal(\"app\"), appPermissionSchema),\n ])\n .describe(\n \"Declares a resource requirement for a plugin. Can be defined statically in a manifest or dynamically via getResourceRequirements().\",\n );\n\n// ── Config schema (recursive) ────────────────────────────────────────────\n\nexport const configSchemaPropertySchema: z.ZodType = z.lazy(() =>\n z\n .object({\n type: z.enum([\n \"object\",\n \"array\",\n \"string\",\n \"number\",\n \"boolean\",\n \"integer\",\n ]),\n description: z.string().optional(),\n default: z.unknown().optional(),\n enum: z.array(z.unknown()).optional(),\n properties: z.record(z.string(), configSchemaPropertySchema).optional(),\n items: configSchemaPropertySchema.optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n minLength: z.number().int().min(0).optional(),\n maxLength: z.number().int().min(0).optional(),\n required: z.array(z.string()).optional(),\n // `additionalProperties` is a standard JSON Schema keyword used by core\n // plugin manifests (e.g., serving, ai-search, genie) to constrain\n // dictionary-shaped properties. Allowed on nested property entries as\n // either a boolean or a sub-schema, mirroring JSON Schema semantics.\n additionalProperties: z\n .union([z.boolean(), configSchemaPropertySchema])\n .optional(),\n })\n .strict(),\n);\n\nexport const configSchemaSchema: z.ZodType = z.lazy(() =>\n z\n .object({\n type: z.enum([\"object\", \"array\", \"string\", \"number\", \"boolean\"]),\n properties: z.record(z.string(), configSchemaPropertySchema).optional(),\n items: configSchemaSchema.optional(),\n required: z.array(z.string()).optional(),\n additionalProperties: z.boolean().optional(),\n })\n .strict(),\n);\n\n// ── Plugin-level scaffolding rules ───────────────────────────────────────\n\n/**\n * Per-item upper bound on plugin-level scaffolding rule strings. Matches the\n * template-level `SCAFFOLDING_RULE_MAX_LENGTH` defined below — rules at both\n * levels are short directives, not prose. The literal value lives here (and\n * not by reference to the template-side constant) because this declaration\n * is read in source order and the template constant is declared later.\n */\nconst PLUGIN_SCAFFOLDING_RULE_MAX_LENGTH = 120;\n\nconst pluginScaffoldingRuleItemSchema = z\n .string()\n .min(1)\n .max(\n PLUGIN_SCAFFOLDING_RULE_MAX_LENGTH,\n `rule entries must be ≤ ${PLUGIN_SCAFFOLDING_RULE_MAX_LENGTH} chars`,\n );\n\nexport const pluginScaffoldingRulesSchema = z\n .object({\n must: z\n .array(pluginScaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must always perform.\"),\n should: z\n .array(pluginScaffoldingRuleItemSchema)\n .optional()\n .describe(\"Recommended actions for the scaffolding agent.\"),\n never: z\n .array(pluginScaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must never perform.\"),\n })\n .strict()\n .superRefine((rules, ctx) => {\n // (a) Reject duplicate entries within any single array.\n const buckets: Array<[\"must\" | \"should\" | \"never\", string[] | undefined]> =\n [\n [\"must\", rules.must],\n [\"should\", rules.should],\n [\"never\", rules.never],\n ];\n for (const [bucketName, items] of buckets) {\n if (!items) continue;\n const seen = new Map<string, number>();\n items.forEach((item, idx) => {\n const prev = seen.get(item);\n if (prev === undefined) {\n seen.set(item, idx);\n return;\n }\n ctx.addIssue({\n code: \"custom\",\n path: [bucketName, idx],\n message: `duplicate rule entry: \"${item}\" already declared at index ${prev}`,\n });\n });\n }\n // (b) Reject a string that appears in more than one of must/should/never.\n type Bucket = \"must\" | \"should\" | \"never\";\n const owner = new Map<string, Bucket>();\n for (const [bucketName, items] of buckets) {\n if (!items) continue;\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const existing = owner.get(item);\n if (existing === undefined) {\n owner.set(item, bucketName);\n continue;\n }\n if (existing !== bucketName) {\n ctx.addIssue({\n code: \"custom\",\n path: [bucketName, i],\n message: `rule entry \"${item}\" appears in both '${existing}' and '${bucketName}'; rules must belong to exactly one bucket`,\n });\n }\n }\n }\n })\n .describe(\n \"Structured rules for scaffolding agents declared at the plugin level. Each rule is a short directive (≤120 chars).\",\n );\n\n// ── Plugin manifest (root) ───────────────────────────────────────────────\n\nexport const pluginManifestSchema = z\n .object({\n $schema: z\n .string()\n .optional()\n .describe(\"Reference to the JSON Schema for validation\"),\n name: z\n .string()\n .regex(PLUGIN_NAME_PATTERN)\n .describe(\n \"Plugin identifier and JS binding. Must start with a lowercase letter; camelCase for multi-word names (e.g. aiSearch).\",\n ),\n displayName: z\n .string()\n .min(1)\n .describe(\"Human-readable display name for UI and CLI\"),\n description: z\n .string()\n .min(1)\n .describe(\"Brief description of what the plugin does\"),\n resources: z\n .object({\n required: z\n .array(resourceRequirementSchema)\n .describe(\n \"Resources that must be available for the plugin to function\",\n ),\n optional: z\n .array(resourceRequirementSchema)\n .describe(\n \"Resources that enhance functionality but are not mandatory\",\n ),\n })\n .strict()\n .describe(\"Databricks resource requirements for this plugin\"),\n config: z\n .object({\n schema: configSchemaSchema.optional(),\n })\n .strict()\n .optional()\n .describe(\"Configuration schema for the plugin\"),\n author: z.string().optional().describe(\"Author name or organization\"),\n version: z\n .string()\n .regex(/^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?$/)\n .optional()\n .describe(\"Plugin version (semver format)\"),\n repository: z\n .url()\n .optional()\n .describe(\"URL to the plugin's source repository\"),\n keywords: z\n .array(z.string())\n .optional()\n .describe(\"Keywords for plugin discovery\"),\n license: z.string().optional().describe(\"SPDX license identifier\"),\n onSetupMessage: z\n .string()\n .optional()\n .describe(\n \"Message displayed to the user after project initialization. Use this to inform about manual setup steps (e.g. environment variables, resource provisioning).\",\n ),\n hidden: z\n .boolean()\n .optional()\n .describe(\n \"When true, this plugin is excluded from the template plugins manifest (appkit.plugins.json) during sync.\",\n ),\n devOnly: z\n .boolean()\n .optional()\n .describe(\n \"When true, this plugin is only registered when NODE_ENV === 'development'. In any other environment createApp skips it entirely (not constructed, no routes, resources not validated). Use for dev-only tooling that must never run in a deployed app.\",\n ),\n stability: z\n .enum([\"beta\", \"ga\"])\n .optional()\n .describe(\n \"Plugin stability level. Beta plugins may have breaking API changes between minor releases but are on a path to GA. GA (general availability) plugins follow semver strictly.\",\n ),\n scaffolding: z\n .object({\n rules: pluginScaffoldingRulesSchema\n .optional()\n .describe(\n \"Structured rules for scaffolding agents declared at the plugin level.\",\n ),\n })\n .strict()\n .optional()\n .describe(\n \"Plugin-level scaffolding metadata consumed by scaffolding agents. Symmetric with template-level `scaffolding`.\",\n ),\n })\n .strict()\n .describe(\n \"Schema for Databricks AppKit plugin manifest files. Defines plugin metadata, resource requirements, and configuration options.\",\n );\n\n// ── Origin enum ──────────────────────────────────────────────────────────\n\nexport const originSchema = z\n .enum([\"user\", \"platform\", \"static\", \"cli\"])\n .describe(\n \"How the field value is determined. Computed during sync, not authored by plugin developers.\",\n );\n\n// ── Template field entry (origin computed by transform) ─────────────────\n\n/**\n * Derives the canonical origin of a resource field value from its shape.\n *\n * - `localOnly: true` → `\"platform\"` (auto-injected by the Databricks Apps\n * platform at deploy time; takes precedence over `value`/`resolve`).\n * - `value !== undefined` → `\"static\"` (hardcoded value).\n * - `resolve !== undefined` → `\"cli\"` (resolved by the CLI during init).\n * - else → `\"user\"` (user must provide the value at init time).\n *\n * The single source for this rule: `plugin sync`'s transform stamps `origin`\n * with it, and consumers that read an authored manifest (no stamped `origin`)\n * derive it through this rather than re-implementing the cascade.\n */\nexport function computeOriginFromField(field: {\n localOnly?: boolean;\n value?: string;\n resolve?: string;\n}): z.infer<typeof originSchema> {\n if (field.localOnly) return \"platform\";\n if (field.value !== undefined) return \"static\";\n if (field.resolve !== undefined) return \"cli\";\n return \"user\";\n}\n\n/**\n * Template field entry: extends the plugin manifest field entry with an\n * optional `origin` input slot, then runs a `.transform()` that overwrites\n * `origin` with the computed value. Allowing `origin` on input means\n * re-parsing a previously-synced template manifest does not fail; emitting\n * `origin` always means hand-edits in synced JSON are silently corrected\n * on the next parse — drift-by-construction.\n */\nexport const templateFieldEntrySchema = resourceFieldEntrySchema\n .extend({ origin: originSchema.optional() })\n .transform((field) => ({\n ...field,\n origin: computeOriginFromField(field),\n }));\n\n// ── Template resource requirement (uses templateFieldEntrySchema) ────────\n\nconst templateResourceRequirementBaseShape = {\n alias: z\n .string()\n .min(1)\n .describe(\"Human-readable label for UI/display only.\"),\n resourceKey: z\n .string()\n .regex(/^[a-z][a-z0-9-]*$/)\n .describe(\n \"Stable key for machine use: deduplication, env naming, composite keys.\",\n ),\n description: z\n .string()\n .min(1)\n .describe(\"Human-readable description of why this resource is needed\"),\n fields: z\n .record(z.string(), templateFieldEntrySchema)\n .refine((obj) => Object.keys(obj).length >= 1, {\n message: \"fields must contain at least one entry\",\n })\n .optional()\n .describe(\"Map of field name to field entry with computed origin.\"),\n};\n\nfunction makeTemplateResourceVariant<\n TType extends z.ZodLiteral<string>,\n TPerm extends z.ZodTypeAny,\n>(typeLiteral: TType, permission: TPerm) {\n return z\n .object({\n type: typeLiteral,\n ...templateResourceRequirementBaseShape,\n permission: permission.describe(\n \"Required permission level. Validated per resource type.\",\n ),\n })\n .strict()\n .superRefine(refineResourceDependsOn);\n}\n\nexport const templateResourceRequirementSchema = z\n .discriminatedUnion(\"type\", [\n makeTemplateResourceVariant(z.literal(\"secret\"), secretPermissionSchema),\n makeTemplateResourceVariant(z.literal(\"job\"), jobPermissionSchema),\n makeTemplateResourceVariant(\n z.literal(\"sql_warehouse\"),\n sqlWarehousePermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"serving_endpoint\"),\n servingEndpointPermissionSchema,\n ),\n makeTemplateResourceVariant(z.literal(\"volume\"), volumePermissionSchema),\n makeTemplateResourceVariant(\n z.literal(\"vector_search_index\"),\n vectorSearchIndexPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"uc_function\"),\n ucFunctionPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"uc_connection\"),\n ucConnectionPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"database\"),\n databasePermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"postgres\"),\n postgresPermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"genie_space\"),\n genieSpacePermissionSchema,\n ),\n makeTemplateResourceVariant(\n z.literal(\"experiment\"),\n experimentPermissionSchema,\n ),\n makeTemplateResourceVariant(z.literal(\"app\"), appPermissionSchema),\n ])\n .describe(\n \"Resource requirement with template-specific field entries (includes computed origin).\",\n );\n\n// ── Template plugin (extends plugin manifest) ────────────────────────────\n\nexport const templatePluginSchema = z\n .object({\n name: z\n .string()\n .regex(PLUGIN_NAME_PATTERN)\n .describe(\n \"Plugin identifier and JS binding. Must start with a lowercase letter; camelCase for multi-word names (e.g. aiSearch).\",\n ),\n displayName: z\n .string()\n .min(1)\n .describe(\"Human-readable display name for UI and CLI\"),\n description: z\n .string()\n .min(1)\n .describe(\"Brief description of what the plugin does\"),\n package: z\n .string()\n .min(1)\n .describe(\"NPM package name that provides this plugin\"),\n requiredByTemplate: z\n .boolean()\n .optional()\n .describe(\n \"When true, this plugin is required by the template and cannot be deselected during CLI init. The user will only be prompted to configure its resources. When absent or false, the plugin is optional and the user can choose whether to include it.\",\n ),\n onSetupMessage: z\n .string()\n .optional()\n .describe(\n \"Message displayed to the user after project initialization. Use this to inform about manual setup steps (e.g. environment variables, resource provisioning).\",\n ),\n stability: z\n .enum([\"beta\", \"ga\"])\n .optional()\n .describe(\n \"Plugin stability level. Beta is heading to GA; APIs may change between minor releases. GA (general availability) follows semver.\",\n ),\n scaffolding: z\n .object({\n rules: pluginScaffoldingRulesSchema\n .optional()\n .describe(\n \"Structured rules for scaffolding agents propagated from the plugin manifest.\",\n ),\n })\n .strict()\n .optional()\n .describe(\n \"Plugin-level scaffolding metadata propagated from the plugin manifest.\",\n ),\n resources: z\n .object({\n required: z\n .array(templateResourceRequirementSchema)\n .describe(\n \"Resources that must be available for the plugin to function\",\n ),\n optional: z\n .array(templateResourceRequirementSchema)\n .describe(\n \"Resources that enhance functionality but are not mandatory\",\n ),\n })\n .strict()\n .describe(\"Databricks resource requirements for this plugin\"),\n })\n .strict()\n .describe(\"Plugin manifest with package source information\");\n\n// ── Scaffolding descriptor ───────────────────────────────────────────────\n\nexport const scaffoldingFlagSchema = z\n .object({\n description: z.string().describe(\"Human-readable description of the flag.\"),\n required: z.boolean().optional().describe(\"Whether this flag is required.\"),\n pattern: z\n .string()\n .optional()\n .describe(\"Regex pattern for validating the flag value.\"),\n default: z.string().optional().describe(\"Default value for this flag.\"),\n })\n .strict()\n .describe(\"A flag for the scaffolding command.\");\n\n/**\n * Per-item upper bound on scaffolding rule strings. The intent is to enforce\n * \"short directive\" by contract — long paragraphs fail validation and force\n * authors to split prose into discrete actionable items.\n */\nconst SCAFFOLDING_RULE_MAX_LENGTH = 120;\n\nconst scaffoldingRuleItemSchema = z\n .string()\n .max(\n SCAFFOLDING_RULE_MAX_LENGTH,\n `rule item must be ≤ ${SCAFFOLDING_RULE_MAX_LENGTH} chars`,\n );\n\nexport const scaffoldingRulesSchema = z\n .object({\n never: z\n .array(scaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must never perform.\"),\n must: z\n .array(scaffoldingRuleItemSchema)\n .optional()\n .describe(\"Actions the scaffolding agent must always perform.\"),\n should: z\n .array(scaffoldingRuleItemSchema)\n .optional()\n .describe(\n \"Recommended actions for the scaffolding agent (parity with plugin-level rules).\",\n ),\n })\n .strict()\n .describe(\"Structured rules for scaffolding agents.\");\n\nexport const scaffoldingDescriptorSchema = z\n .object({\n command: z\n .string()\n .describe(\"The scaffolding command (e.g., 'databricks apps init').\"),\n flags: z\n .record(z.string(), scaffoldingFlagSchema)\n .optional()\n .describe(\"Map of flag name to flag descriptor.\"),\n rules: scaffoldingRulesSchema\n .optional()\n .describe(\"Structured rules for scaffolding agents.\"),\n })\n .strict()\n .describe(\n \"Describes the scaffolding command, flags, and rules for project initialization.\",\n );\n\n/**\n * Canonical scaffolding descriptor for the `databricks apps init` command,\n * embedded in v2.0 template manifests to guide scaffolding agents.\n *\n * Co-located with `scaffoldingDescriptorSchema` so any change to the rule set\n * (or the schema's `maxLength` ceiling) shows up next to its consumer. The\n * `satisfies` annotation gives compile-time validation that the literal\n * matches the schema's input shape; if a `must`/`never` entry exceeds the\n * `maxLength` ceiling at runtime, `scaffoldingDescriptorSchema.parse` would\n * surface the breach in tests.\n */\nexport const TEMPLATE_SCAFFOLDING = {\n command: \"databricks apps init\",\n flags: {\n \"--name\": {\n description:\n \"Project name — sets {{.projectName}} in package.json, databricks.yml, and .env. Required for non-interactive scaffolding.\",\n required: true,\n pattern: \"^[a-z][a-z0-9-]*$\",\n },\n \"--template\": {\n description: \"Template path (local directory or GitHub URL)\",\n required: false,\n },\n \"--version\": {\n description: \"AppKit version to use; defaults to auto-detected\",\n required: false,\n },\n \"--features\": {\n description:\n \"Plugins to enable (comma-separated, no spaces; must match keys in this manifest's plugins map)\",\n required: false,\n pattern: \"^[a-zA-Z0-9_-]+(,[a-zA-Z0-9_-]+)*$\",\n },\n \"--set\": {\n description:\n \"Set resource values (format: plugin.resourceKey.field=value, repeatable)\",\n required: false,\n },\n \"--output-dir\": {\n description: \"Directory to write the project to\",\n required: false,\n },\n \"--description\": {\n description: \"App description\",\n required: false,\n },\n \"--run\": {\n description: \"Run the app after creation (none, dev, dev-remote)\",\n required: false,\n },\n \"--auto-approve\": {\n description:\n \"Pass as a bare flag (no value) to skip prompts for optional resources. Not recommended for agent-driven init — conflicts with the 'ask user when in doubt' rule.\",\n required: false,\n },\n \"--profile\": {\n description:\n \"Databricks CLI profile to use for authentication (global flag)\",\n required: false,\n },\n },\n rules: {\n must: [\n \"Treat `databricks apps init` output as starter code, not requirements; adapt or replace it to match the requested app\",\n \"Keep all secrets and credentials only in app.yaml, databricks.yml, and/or .env\",\n ],\n should: [\"ask user when in doubt of resource to use for plugin\"],\n never: [\n \"guess resources when multiple or no options are available\",\n \"embed secrets in files that will go to the client-bundle\",\n ],\n },\n} satisfies z.infer<typeof scaffoldingDescriptorSchema>;\n\n// ── Template plugins manifest (root) ─────────────────────────────────────\n\nexport const templatePluginsManifestSchema = z\n .object({\n $schema: z\n .string()\n .optional()\n .describe(\"Reference to the JSON Schema for validation\"),\n version: z\n .enum([\"1.0\", \"1.1\", \"2.0\"])\n .describe(\"Schema version for the template plugins manifest\"),\n plugins: z\n .record(z.string(), templatePluginSchema)\n .describe(\"Map of plugin name to plugin manifest with package source\"),\n scaffolding: scaffoldingDescriptorSchema\n .optional()\n .describe(\n \"Describes the scaffolding command and its configuration for project initialization.\",\n ),\n })\n .strict()\n .superRefine((value, ctx) => {\n if (value.version === \"2.0\" && !value.scaffolding) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"scaffolding\"],\n message: \"scaffolding is required when version is '2.0'\",\n });\n }\n })\n .describe(\n \"Aggregated plugin manifest for AppKit templates. Read by Databricks CLI during init to discover available plugins and their resource requirements.\",\n );\n\n// ── Inferred types ───────────────────────────────────────────────────────\n\nexport type ResourceType = z.infer<typeof resourceTypeSchema>;\nexport type SecretPermission = z.infer<typeof secretPermissionSchema>;\nexport type JobPermission = z.infer<typeof jobPermissionSchema>;\nexport type SqlWarehousePermission = z.infer<\n typeof sqlWarehousePermissionSchema\n>;\nexport type ServingEndpointPermission = z.infer<\n typeof servingEndpointPermissionSchema\n>;\nexport type VolumePermission = z.infer<typeof volumePermissionSchema>;\nexport type VectorSearchIndexPermission = z.infer<\n typeof vectorSearchIndexPermissionSchema\n>;\nexport type UcFunctionPermission = z.infer<typeof ucFunctionPermissionSchema>;\nexport type UcConnectionPermission = z.infer<\n typeof ucConnectionPermissionSchema\n>;\nexport type DatabasePermission = z.infer<typeof databasePermissionSchema>;\nexport type PostgresPermission = z.infer<typeof postgresPermissionSchema>;\nexport type GenieSpacePermission = z.infer<typeof genieSpacePermissionSchema>;\nexport type ExperimentPermission = z.infer<typeof experimentPermissionSchema>;\nexport type AppPermission = z.infer<typeof appPermissionSchema>;\nexport type ResourceKind = z.infer<typeof resourceKindSchema>;\nexport type KindDiscoveryDescriptor = z.infer<\n typeof kindDiscoveryDescriptorSchema\n>;\nexport type CliDiscoveryDescriptor = z.infer<\n typeof cliDiscoveryDescriptorSchema\n>;\nexport type DiscoveryDescriptor = z.infer<typeof discoveryDescriptorSchema>;\nexport type ResourceFieldEntry = z.infer<typeof resourceFieldEntrySchema>;\nexport type ResourceRequirement = z.infer<typeof resourceRequirementSchema>;\nexport type ConfigSchemaProperty = z.infer<typeof configSchemaPropertySchema>;\nexport type ConfigSchema = z.infer<typeof configSchemaSchema>;\nexport type PluginScaffoldingRules = z.infer<\n typeof pluginScaffoldingRulesSchema\n>;\nexport type PluginManifest = z.infer<typeof pluginManifestSchema>;\nexport type Origin = z.infer<typeof originSchema>;\n// Template-side types use `z.input` so callers can construct a TemplatePlugin\n// from a parsed PluginManifest before the field-level origin transform runs.\n// `writeManifest` parses every field through `templateFieldEntrySchema` at\n// write-time, so the on-disk shape always has origin populated. The runtime\n// invariant: origin is *always* present after sync writes; the type slot\n// stays optional so the in-memory pipeline does not need to fabricate origin\n// before assignment.\nexport type TemplateFieldEntry = z.input<typeof templateFieldEntrySchema>;\nexport type TemplateResourceRequirement = z.input<\n typeof templateResourceRequirementSchema\n>;\nexport type TemplatePlugin = z.input<typeof templatePluginSchema>;\nexport type ScaffoldingFlag = z.infer<typeof scaffoldingFlagSchema>;\nexport type ScaffoldingRules = z.infer<typeof scaffoldingRulesSchema>;\nexport type ScaffoldingDescriptor = z.infer<typeof scaffoldingDescriptorSchema>;\nexport type TemplatePluginsManifest = z.input<\n typeof templatePluginsManifestSchema\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,qBAAqB,EAC/B,KAAK;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,CACD,SAAS,8BAA8B;AAE1C,MAAa,yBAAyB,EACnC,KAAK;CAAC;CAAQ;CAAS;CAAS,CAAC,CACjC,SAAS,gEAAgE;AAE5E,MAAa,sBAAsB,EAChC,KAAK;CAAC;CAAY;CAAkB;CAAa,CAAC,CAClD,SAAS,6DAA6D;AAEzE,MAAa,+BAA+B,EACzC,KAAK,CAAC,WAAW,aAAa,CAAC,CAC/B,SACC,uEACD;AAEH,MAAa,kCAAkC,EAC5C,KAAK;CAAC;CAAY;CAAa;CAAa,CAAC,CAC7C,SACC,0EACD;AAEH,MAAa,yBAAyB,EACnC,KAAK,CAAC,eAAe,eAAe,CAAC,CACrC,SAAS,gDAAgD;AAE5D,MAAa,oCAAoC,EAC9C,KAAK,CAAC,SAAS,CAAC,CAChB,SAAS,+CAA+C;AAE3D,MAAa,6BAA6B,EACvC,KAAK,CAAC,UAAU,CAAC,CACjB,SAAS,kDAAkD;AAE9D,MAAa,+BAA+B,EACzC,KAAK,CAAC,iBAAiB,CAAC,CACxB,SAAS,oDAAoD;AAEhE,MAAa,2BAA2B,EACrC,KAAK,CAAC,yBAAyB,CAAC,CAChC,SAAS,oCAAoC;AAEhD,MAAa,2BAA2B,EACrC,KAAK,CAAC,yBAAyB,CAAC,CAChC,SAAS,oCAAoC;AAEhD,MAAa,6BAA6B,EACvC,KAAK;CAAC;CAAY;CAAW;CAAY;CAAa,CAAC,CACvD,SACC,qEACD;AAEH,MAAa,6BAA6B,EACvC,KAAK;CAAC;CAAY;CAAY;CAAa,CAAC,CAC5C,SACC,2EACD;AAEH,MAAa,sBAA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a;GACX,aAAa;GACb,UAAU;GACX;EACD,cAAc;GACZ,aACE;GACF,UAAU;GACV,SAAS;GACV;EACD,SAAS;GACP,aACE;GACF,UAAU;GACX;EACD,gBAAgB;GACd,aAAa;GACb,UAAU;GACX;EACD,iBAAiB;GACf,aAAa;GACb,UAAU;GACX;EACD,SAAS;GACP,aAAa;GACb,UAAU;GACX;EACD,kBAAkB;GAChB,aACE;GACF,UAAU;GACX;EACD,aAAa;GACX,aACE;GACF,UAAU;GACX;EACF;CACD,OAAO;EACL,MAAM,CACJ,yHACA,iFACD;EACD,QAAQ,CAAC,uDAAuD;EAChE,OAAO,CACL,6DACA,2DACD;EACF;CACF;AAID,MAAa,gCAAgC,EAC1C,OAAO;CACN,SAAS,EACN,QAAQ,CACR,UAAU,CACV,SAAS,8CAA8C;CAC1D,SAAS,EACN,KAAK;EAAC;EAAO;EAAO;EAAM,CAAC,CAC3B,SAAS,mDAAmD;CAC/D,SAAS,EACN,OAAO,EAAE,QAAQ,EAAE,qBAAqB,CACxC,SAAS,4DAA4D;CACxE,aAAa,4BACV,UAAU,CACV,SACC,sFACD;CACJ,CAAC,CACD,QAAQ,CACR,aAAa,OAAO,QAAQ;AAC3B,KAAI,MAAM,YAAY,SAAS,CAAC,MAAM,YACpC,KAAI,SAAS;EACX,MAAM;EACN,MAAM,CAAC,cAAc;EACrB,SAAS;EACV,CAAC;EAEJ,CACD,SACC,qJACD"}
|
|
@@ -8,4 +8,7 @@ import { MetricViewColumnDisplay, MetricViewsMetadata } from "./metric-metadata.
|
|
|
8
8
|
import { SQLBinaryMarker, SQLBooleanMarker, SQLDateMarker, SQLNumberMarker, SQLStringMarker, SQLTimestampMarker, SQLTypeMarker } from "./sql/types.js";
|
|
9
9
|
import { isSQLTypeMarker, sql } from "./sql/helpers.js";
|
|
10
10
|
import "./sse/analytics.js";
|
|
11
|
-
import { PendingFetch, PendingFileRead, TunnelConnection } from "./tunnel.js";
|
|
11
|
+
import { PendingFetch, PendingFileRead, TunnelConnection } from "./tunnel.js";
|
|
12
|
+
import { ApiError } from "./workspace-client/errors.js";
|
|
13
|
+
import { createWorkspaceClient } from "./workspace-client/factory.js";
|
|
14
|
+
import "./workspace-client/index.js";
|
|
@@ -162,9 +162,9 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
162
162
|
type: z.ZodLiteral<"sql_warehouse">;
|
|
163
163
|
}, z.core.$strict>, z.ZodObject<{
|
|
164
164
|
permission: z.ZodEnum<{
|
|
165
|
+
CAN_QUERY: "CAN_QUERY";
|
|
165
166
|
CAN_VIEW: "CAN_VIEW";
|
|
166
167
|
CAN_MANAGE: "CAN_MANAGE";
|
|
167
|
-
CAN_QUERY: "CAN_QUERY";
|
|
168
168
|
}>;
|
|
169
169
|
alias: z.ZodString;
|
|
170
170
|
resourceKey: z.ZodString;
|
|
@@ -438,10 +438,10 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
438
438
|
type: z.ZodLiteral<"postgres">;
|
|
439
439
|
}, z.core.$strict>, z.ZodObject<{
|
|
440
440
|
permission: z.ZodEnum<{
|
|
441
|
+
CAN_EDIT: "CAN_EDIT";
|
|
441
442
|
CAN_VIEW: "CAN_VIEW";
|
|
442
443
|
CAN_MANAGE: "CAN_MANAGE";
|
|
443
444
|
CAN_RUN: "CAN_RUN";
|
|
444
|
-
CAN_EDIT: "CAN_EDIT";
|
|
445
445
|
}>;
|
|
446
446
|
alias: z.ZodString;
|
|
447
447
|
resourceKey: z.ZodString;
|
|
@@ -480,8 +480,8 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
480
480
|
type: z.ZodLiteral<"genie_space">;
|
|
481
481
|
}, z.core.$strict>, z.ZodObject<{
|
|
482
482
|
permission: z.ZodEnum<{
|
|
483
|
-
CAN_MANAGE: "CAN_MANAGE";
|
|
484
483
|
CAN_EDIT: "CAN_EDIT";
|
|
484
|
+
CAN_MANAGE: "CAN_MANAGE";
|
|
485
485
|
CAN_READ: "CAN_READ";
|
|
486
486
|
}>;
|
|
487
487
|
alias: z.ZodString;
|
|
@@ -683,9 +683,9 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
683
683
|
type: z.ZodLiteral<"sql_warehouse">;
|
|
684
684
|
}, z.core.$strict>, z.ZodObject<{
|
|
685
685
|
permission: z.ZodEnum<{
|
|
686
|
+
CAN_QUERY: "CAN_QUERY";
|
|
686
687
|
CAN_VIEW: "CAN_VIEW";
|
|
687
688
|
CAN_MANAGE: "CAN_MANAGE";
|
|
688
|
-
CAN_QUERY: "CAN_QUERY";
|
|
689
689
|
}>;
|
|
690
690
|
alias: z.ZodString;
|
|
691
691
|
resourceKey: z.ZodString;
|
|
@@ -959,10 +959,10 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
959
959
|
type: z.ZodLiteral<"postgres">;
|
|
960
960
|
}, z.core.$strict>, z.ZodObject<{
|
|
961
961
|
permission: z.ZodEnum<{
|
|
962
|
+
CAN_EDIT: "CAN_EDIT";
|
|
962
963
|
CAN_VIEW: "CAN_VIEW";
|
|
963
964
|
CAN_MANAGE: "CAN_MANAGE";
|
|
964
965
|
CAN_RUN: "CAN_RUN";
|
|
965
|
-
CAN_EDIT: "CAN_EDIT";
|
|
966
966
|
}>;
|
|
967
967
|
alias: z.ZodString;
|
|
968
968
|
resourceKey: z.ZodString;
|
|
@@ -1001,8 +1001,8 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
1001
1001
|
type: z.ZodLiteral<"genie_space">;
|
|
1002
1002
|
}, z.core.$strict>, z.ZodObject<{
|
|
1003
1003
|
permission: z.ZodEnum<{
|
|
1004
|
-
CAN_MANAGE: "CAN_MANAGE";
|
|
1005
1004
|
CAN_EDIT: "CAN_EDIT";
|
|
1005
|
+
CAN_MANAGE: "CAN_MANAGE";
|
|
1006
1006
|
CAN_READ: "CAN_READ";
|
|
1007
1007
|
}>;
|
|
1008
1008
|
alias: z.ZodString;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { buildLegacyWorkspaceClient } from "./legacy.js";
|
|
2
|
+
|
|
3
|
+
//#region ../shared/src/workspace-client/client.ts
|
|
4
|
+
/**
|
|
5
|
+
* `AppKitWorkspaceClient` — the facade implementation. Construct via
|
|
6
|
+
* `createWorkspaceClient(...)`; this class is internal.
|
|
7
|
+
*
|
|
8
|
+
* Every service accessor delegates to a single lazily-constructed legacy SDK
|
|
9
|
+
* client. This is the seam: to migrate a service to the modular SDK, replace
|
|
10
|
+
* its getter here with a modular client instance (and update its connector +
|
|
11
|
+
* the accessor type in `types.ts`). No other AppKit module touches the SDK.
|
|
12
|
+
*/
|
|
13
|
+
var AppKitWorkspaceClient = class {
|
|
14
|
+
#opts;
|
|
15
|
+
#legacy;
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
this.#opts = opts;
|
|
18
|
+
}
|
|
19
|
+
get files() {
|
|
20
|
+
return this.#getLegacy().files;
|
|
21
|
+
}
|
|
22
|
+
get warehouses() {
|
|
23
|
+
return this.#getLegacy().warehouses;
|
|
24
|
+
}
|
|
25
|
+
get genie() {
|
|
26
|
+
return this.#getLegacy().genie;
|
|
27
|
+
}
|
|
28
|
+
get jobs() {
|
|
29
|
+
return this.#getLegacy().jobs;
|
|
30
|
+
}
|
|
31
|
+
get statementExecution() {
|
|
32
|
+
return this.#getLegacy().statementExecution;
|
|
33
|
+
}
|
|
34
|
+
get servingEndpoints() {
|
|
35
|
+
return this.#getLegacy().servingEndpoints;
|
|
36
|
+
}
|
|
37
|
+
get currentUser() {
|
|
38
|
+
return this.#getLegacy().currentUser;
|
|
39
|
+
}
|
|
40
|
+
get config() {
|
|
41
|
+
return this.#getLegacy().config;
|
|
42
|
+
}
|
|
43
|
+
get apiClient() {
|
|
44
|
+
return this.#getLegacy().apiClient;
|
|
45
|
+
}
|
|
46
|
+
toLegacyWorkspaceClient() {
|
|
47
|
+
return this.#getLegacy();
|
|
48
|
+
}
|
|
49
|
+
#getLegacy() {
|
|
50
|
+
if (!this.#legacy) this.#legacy = buildLegacyWorkspaceClient(this.#opts);
|
|
51
|
+
return this.#legacy;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { AppKitWorkspaceClient };
|
|
57
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":["#opts","#getLegacy","#legacy"],"sources":["../../../../../shared/src/workspace-client/client.ts"],"sourcesContent":["/**\n * `AppKitWorkspaceClient` — the facade implementation. Construct via\n * `createWorkspaceClient(...)`; this class is internal.\n *\n * Every service accessor delegates to a single lazily-constructed legacy SDK\n * client. This is the seam: to migrate a service to the modular SDK, replace\n * its getter here with a modular client instance (and update its connector +\n * the accessor type in `types.ts`). No other AppKit module touches the SDK.\n */\nimport {\n buildLegacyWorkspaceClient,\n type LegacyWorkspaceClient,\n type WorkspaceClientOptions,\n} from \"./legacy\";\nimport type { WorkspaceClient } from \"./types\";\n\nexport class AppKitWorkspaceClient implements WorkspaceClient {\n readonly #opts: WorkspaceClientOptions;\n #legacy?: LegacyWorkspaceClient;\n\n constructor(opts: WorkspaceClientOptions) {\n this.#opts = opts;\n }\n\n get files() {\n return this.#getLegacy().files;\n }\n\n get warehouses() {\n return this.#getLegacy().warehouses;\n }\n\n get genie() {\n return this.#getLegacy().genie;\n }\n\n get jobs() {\n return this.#getLegacy().jobs;\n }\n\n get statementExecution() {\n return this.#getLegacy().statementExecution;\n }\n\n get servingEndpoints() {\n return this.#getLegacy().servingEndpoints;\n }\n\n get currentUser() {\n return this.#getLegacy().currentUser;\n }\n\n get config() {\n return this.#getLegacy().config;\n }\n\n get apiClient() {\n return this.#getLegacy().apiClient;\n }\n\n toLegacyWorkspaceClient(): LegacyWorkspaceClient {\n return this.#getLegacy();\n }\n\n #getLegacy(): LegacyWorkspaceClient {\n if (!this.#legacy) {\n this.#legacy = buildLegacyWorkspaceClient(this.#opts);\n }\n return this.#legacy;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,IAAa,wBAAb,MAA8D;CAC5D,CAASA;CACT;CAEA,YAAY,MAA8B;AACxC,QAAKA,OAAQ;;CAGf,IAAI,QAAQ;AACV,SAAO,MAAKC,WAAY,CAAC;;CAG3B,IAAI,aAAa;AACf,SAAO,MAAKA,WAAY,CAAC;;CAG3B,IAAI,QAAQ;AACV,SAAO,MAAKA,WAAY,CAAC;;CAG3B,IAAI,OAAO;AACT,SAAO,MAAKA,WAAY,CAAC;;CAG3B,IAAI,qBAAqB;AACvB,SAAO,MAAKA,WAAY,CAAC;;CAG3B,IAAI,mBAAmB;AACrB,SAAO,MAAKA,WAAY,CAAC;;CAG3B,IAAI,cAAc;AAChB,SAAO,MAAKA,WAAY,CAAC;;CAG3B,IAAI,SAAS;AACX,SAAO,MAAKA,WAAY,CAAC;;CAG3B,IAAI,YAAY;AACd,SAAO,MAAKA,WAAY,CAAC;;CAG3B,0BAAiD;AAC/C,SAAO,MAAKA,WAAY;;CAG1B,aAAoC;AAClC,MAAI,CAAC,MAAKC,OACR,OAAKA,SAAU,2BAA2B,MAAKF,KAAM;AAEvD,SAAO,MAAKE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WorkspaceClientOptions } from "./legacy.js";
|
|
2
|
+
import { WorkspaceClient } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region ../shared/src/workspace-client/factory.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Construct an AppKit workspace client.
|
|
7
|
+
*
|
|
8
|
+
* Auth resolution:
|
|
9
|
+
* - If `opts.token` is set, uses PAT credentials.
|
|
10
|
+
* - Otherwise walks the SDK default auth chain (env vars + ~/.databrickscfg).
|
|
11
|
+
*
|
|
12
|
+
* Host resolution:
|
|
13
|
+
* - Explicit `opts.host` → use it.
|
|
14
|
+
* - Otherwise resolved by the SDK from `DATABRICKS_HOST` / profile.
|
|
15
|
+
*/
|
|
16
|
+
declare function createWorkspaceClient(opts?: WorkspaceClientOptions): WorkspaceClient;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { createWorkspaceClient };
|
|
19
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","names":[],"sources":["../../../../../shared/src/workspace-client/factory.ts"],"mappings":";;;;;;AAkBA;;;;;;;;;iBAAgB,qBAAA,CACd,IAAA,GAAM,sBAAA,GACL,eAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AppKitWorkspaceClient } from "./client.js";
|
|
2
|
+
|
|
3
|
+
//#region ../shared/src/workspace-client/factory.ts
|
|
4
|
+
/**
|
|
5
|
+
* Public factory for constructing a wrapper instance.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Construct an AppKit workspace client.
|
|
9
|
+
*
|
|
10
|
+
* Auth resolution:
|
|
11
|
+
* - If `opts.token` is set, uses PAT credentials.
|
|
12
|
+
* - Otherwise walks the SDK default auth chain (env vars + ~/.databrickscfg).
|
|
13
|
+
*
|
|
14
|
+
* Host resolution:
|
|
15
|
+
* - Explicit `opts.host` → use it.
|
|
16
|
+
* - Otherwise resolved by the SDK from `DATABRICKS_HOST` / profile.
|
|
17
|
+
*/
|
|
18
|
+
function createWorkspaceClient(opts = {}) {
|
|
19
|
+
return new AppKitWorkspaceClient(opts);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { createWorkspaceClient };
|
|
24
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","names":[],"sources":["../../../../../shared/src/workspace-client/factory.ts"],"sourcesContent":["/**\n * Public factory for constructing a wrapper instance.\n */\nimport { AppKitWorkspaceClient } from \"./client\";\nimport type { WorkspaceClientOptions } from \"./legacy\";\nimport type { WorkspaceClient } from \"./types\";\n\n/**\n * Construct an AppKit workspace client.\n *\n * Auth resolution:\n * - If `opts.token` is set, uses PAT credentials.\n * - Otherwise walks the SDK default auth chain (env vars + ~/.databrickscfg).\n *\n * Host resolution:\n * - Explicit `opts.host` → use it.\n * - Otherwise resolved by the SDK from `DATABRICKS_HOST` / profile.\n */\nexport function createWorkspaceClient(\n opts: WorkspaceClientOptions = {},\n): WorkspaceClient {\n return new AppKitWorkspaceClient(opts);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAAgB,sBACd,OAA+B,EAAE,EAChB;AACjB,QAAO,IAAI,sBAAsB,KAAK"}
|