@fabric-harness/databricks 4.9.1 → 4.10.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/dist/agent.js CHANGED
@@ -2011,16 +2011,16 @@ function parseResourceDescriptor(value, toolName, index) {
2011
2011
  `databricks governance: invalid resource descriptor ${index} on tool "${toolName}".`
2012
2012
  );
2013
2013
  const row = value;
2014
- const path = typeof row.path === "string" ? row.path : void 0;
2014
+ const path3 = typeof row.path === "string" ? row.path : void 0;
2015
2015
  const staticValue = typeof row.value === "string" ? row.value : void 0;
2016
- if (typeof row.kind !== "string" || !row.kind || path === void 0 && staticValue === void 0 || path !== void 0 && staticValue !== void 0 || path !== void 0 && !path.startsWith("/") || staticValue === "") {
2016
+ if (typeof row.kind !== "string" || !row.kind || path3 === void 0 && staticValue === void 0 || path3 !== void 0 && staticValue !== void 0 || path3 !== void 0 && !path3.startsWith("/") || staticValue === "") {
2017
2017
  throw new Error(
2018
2018
  `databricks governance: descriptor ${index} on tool "${toolName}" requires kind and exactly one absolute path or static value.`
2019
2019
  );
2020
2020
  }
2021
2021
  return {
2022
2022
  kind: row.kind,
2023
- ...path !== void 0 ? { path } : { value: staticValue },
2023
+ ...path3 !== void 0 ? { path: path3 } : { value: staticValue },
2024
2024
  ...row.catalogQualified === true ? { catalogQualified: true } : {},
2025
2025
  ...row.optional === true ? { optional: true } : {}
2026
2026
  };
@@ -2030,12 +2030,12 @@ function parseStringArray(value, label) {
2030
2030
  throw new Error(`databricks governance: ${label} must be a string array.`);
2031
2031
  return value;
2032
2032
  }
2033
- function pointerSegments(path) {
2034
- return path.slice(1).split("/").map((segment2) => segment2.replace(/~1/g, "/").replace(/~0/g, "~"));
2033
+ function pointerSegments(path3) {
2034
+ return path3.slice(1).split("/").map((segment2) => segment2.replace(/~1/g, "/").replace(/~0/g, "~"));
2035
2035
  }
2036
- function pointerValues(input, path) {
2036
+ function pointerValues(input, path3) {
2037
2037
  let current = [input];
2038
- for (const segment2 of pointerSegments(path)) {
2038
+ for (const segment2 of pointerSegments(path3)) {
2039
2039
  current = current.flatMap((value) => {
2040
2040
  if (segment2 === "*") return Array.isArray(value) ? value : [];
2041
2041
  if (!value || typeof value !== "object" || Array.isArray(value)) return [];
@@ -2045,10 +2045,10 @@ function pointerValues(input, path) {
2045
2045
  return current;
2046
2046
  }
2047
2047
  function validateSchemaPath(toolName, schema, descriptor) {
2048
- const path = descriptor.path;
2049
- if (path === void 0) return;
2048
+ const path3 = descriptor.path;
2049
+ if (path3 === void 0) return;
2050
2050
  let current = [schema];
2051
- for (const segment2 of pointerSegments(path)) {
2051
+ for (const segment2 of pointerSegments(path3)) {
2052
2052
  const variants = current.flatMap(schemaVariants);
2053
2053
  const next = [];
2054
2054
  let missing = 0;
@@ -3044,10 +3044,10 @@ function mergeDefs(...defs) {
3044
3044
  function cloneDef(schema) {
3045
3045
  return mergeDefs(schema._zod.def);
3046
3046
  }
3047
- function getElementAtPath(obj, path) {
3048
- if (!path)
3047
+ function getElementAtPath(obj, path3) {
3048
+ if (!path3)
3049
3049
  return obj;
3050
- return path.reduce((acc, key) => acc?.[key], obj);
3050
+ return path3.reduce((acc, key) => acc?.[key], obj);
3051
3051
  }
3052
3052
  function promiseAllObject(promisesObj) {
3053
3053
  const keys = Object.keys(promisesObj);
@@ -3456,11 +3456,11 @@ function explicitlyAborted(x2, startIndex = 0) {
3456
3456
  }
3457
3457
  return false;
3458
3458
  }
3459
- function prefixIssues(path, issues) {
3459
+ function prefixIssues(path3, issues) {
3460
3460
  return issues.map((iss) => {
3461
3461
  var _a3;
3462
3462
  (_a3 = iss).path ?? (_a3.path = []);
3463
- iss.path.unshift(path);
3463
+ iss.path.unshift(path3);
3464
3464
  return iss;
3465
3465
  });
3466
3466
  }
@@ -3607,16 +3607,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
3607
3607
  }
3608
3608
  function formatError(error51, mapper = (issue2) => issue2.message) {
3609
3609
  const fieldErrors = { _errors: [] };
3610
- const processError = (error52, path = []) => {
3610
+ const processError = (error52, path3 = []) => {
3611
3611
  for (const issue2 of error52.issues) {
3612
3612
  if (issue2.code === "invalid_union" && issue2.errors.length) {
3613
- issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
3613
+ issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
3614
3614
  } else if (issue2.code === "invalid_key") {
3615
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
3615
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
3616
3616
  } else if (issue2.code === "invalid_element") {
3617
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
3617
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
3618
3618
  } else {
3619
- const fullpath = [...path, ...issue2.path];
3619
+ const fullpath = [...path3, ...issue2.path];
3620
3620
  if (fullpath.length === 0) {
3621
3621
  fieldErrors._errors.push(mapper(issue2));
3622
3622
  } else {
@@ -3643,17 +3643,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
3643
3643
  }
3644
3644
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
3645
3645
  const result = { errors: [] };
3646
- const processError = (error52, path = []) => {
3646
+ const processError = (error52, path3 = []) => {
3647
3647
  var _a3, _b;
3648
3648
  for (const issue2 of error52.issues) {
3649
3649
  if (issue2.code === "invalid_union" && issue2.errors.length) {
3650
- issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
3650
+ issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
3651
3651
  } else if (issue2.code === "invalid_key") {
3652
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
3652
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
3653
3653
  } else if (issue2.code === "invalid_element") {
3654
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
3654
+ processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
3655
3655
  } else {
3656
- const fullpath = [...path, ...issue2.path];
3656
+ const fullpath = [...path3, ...issue2.path];
3657
3657
  if (fullpath.length === 0) {
3658
3658
  result.errors.push(mapper(issue2));
3659
3659
  continue;
@@ -3685,8 +3685,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
3685
3685
  }
3686
3686
  function toDotPath(_path) {
3687
3687
  const segs = [];
3688
- const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
3689
- for (const seg of path) {
3688
+ const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
3689
+ for (const seg of path3) {
3690
3690
  if (typeof seg === "number")
3691
3691
  segs.push(`[${seg}]`);
3692
3692
  else if (typeof seg === "symbol")
@@ -16372,13 +16372,13 @@ function resolveRef(ref, ctx) {
16372
16372
  if (!ref.startsWith("#")) {
16373
16373
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
16374
16374
  }
16375
- const path = ref.slice(1).split("/").filter(Boolean);
16376
- if (path.length === 0) {
16375
+ const path3 = ref.slice(1).split("/").filter(Boolean);
16376
+ if (path3.length === 0) {
16377
16377
  return ctx.rootSchema;
16378
16378
  }
16379
16379
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
16380
- if (path[0] === defsKey) {
16381
- const key = path[1];
16380
+ if (path3[0] === defsKey) {
16381
+ const key = path3[1];
16382
16382
  if (!key || !ctx.defs[key]) {
16383
16383
  throw new Error(`Reference not found: ${ref}`);
16384
16384
  }
@@ -17075,10 +17075,10 @@ async function findInPath(name) {
17075
17075
  }
17076
17076
  throw legacyError ?? new U2mCredentialsError("CLI_NOT_FOUND", "databricks CLI not found");
17077
17077
  }
17078
- async function validateCliPath(path) {
17078
+ async function validateCliPath(path3) {
17079
17079
  let info;
17080
17080
  try {
17081
- info = await stat(path);
17081
+ info = await stat(path3);
17082
17082
  } catch {
17083
17083
  throw new U2mCredentialsError("CLI_NOT_FOUND", "databricks CLI not found");
17084
17084
  }
@@ -17088,7 +17088,7 @@ async function validateCliPath(path) {
17088
17088
  if (info.size < DATABRICKS_CLI_MIN_SIZE) {
17089
17089
  throw new U2mCredentialsError("LEGACY_CLI_DETECTED", "legacy databricks CLI detected; upgrade to >= 0.100.0");
17090
17090
  }
17091
- return path;
17091
+ return path3;
17092
17092
  }
17093
17093
 
17094
17094
  // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/profiles/errors.js
@@ -17282,9 +17282,9 @@ function defaultConfigFilePath() {
17282
17282
  return "";
17283
17283
  }
17284
17284
  }
17285
- async function fileExists(path) {
17285
+ async function fileExists(path3) {
17286
17286
  try {
17287
- await access(path);
17287
+ await access(path3);
17288
17288
  return true;
17289
17289
  } catch {
17290
17290
  return false;
@@ -17292,25 +17292,25 @@ async function fileExists(path) {
17292
17292
  }
17293
17293
  async function loadFile(filePath, profileName) {
17294
17294
  let explicitFile = filePath !== void 0;
17295
- let path;
17295
+ let path3;
17296
17296
  if (filePath !== void 0) {
17297
- path = filePath;
17297
+ path3 = filePath;
17298
17298
  } else {
17299
17299
  const envPath = process.env.DATABRICKS_CONFIG_FILE ?? "";
17300
17300
  if (envPath !== "") {
17301
- path = envPath;
17301
+ path3 = envPath;
17302
17302
  explicitFile = true;
17303
17303
  } else {
17304
- path = defaultConfigFilePath();
17304
+ path3 = defaultConfigFilePath();
17305
17305
  }
17306
17306
  }
17307
- if (!await fileExists(path)) {
17307
+ if (!await fileExists(path3)) {
17308
17308
  if (explicitFile) {
17309
- throw new ProfileError("CONFIG_FILE_NOT_FOUND", `config file not found: ${path}`);
17309
+ throw new ProfileError("CONFIG_FILE_NOT_FOUND", `config file not found: ${path3}`);
17310
17310
  }
17311
17311
  return {};
17312
17312
  }
17313
- const content = await readFile(path, "utf8");
17313
+ const content = await readFile(path3, "utf8");
17314
17314
  const data = parseIni(content);
17315
17315
  let resolved = profileName;
17316
17316
  if (resolved === void 0) {
@@ -17336,7 +17336,7 @@ async function loadFile(filePath, profileName) {
17336
17336
  const section = data.get(resolved);
17337
17337
  if (section === void 0 || isPhantomDefault(resolved, section)) {
17338
17338
  if (explicitProfile) {
17339
- throw new ProfileError("PROFILE_NOT_FOUND", `profile not found: "${resolved}" in ${path}`);
17339
+ throw new ProfileError("PROFILE_NOT_FOUND", `profile not found: "${resolved}" in ${path3}`);
17340
17340
  }
17341
17341
  return {};
17342
17342
  }
@@ -18063,13 +18063,13 @@ function connectionResourceName(value) {
18063
18063
  ).join(".")}`;
18064
18064
  }
18065
18065
  function externalBasePath(value) {
18066
- const path = value.trim();
18067
- if (!path.startsWith("/") || path.startsWith("//") || path.includes("?") || path.includes("#")) {
18066
+ const path3 = value.trim();
18067
+ if (!path3.startsWith("/") || path3.startsWith("//") || path3.includes("?") || path3.includes("#")) {
18068
18068
  throw new Error(
18069
18069
  "databricks agent services: basePath must be an absolute URL path without a query or fragment."
18070
18070
  );
18071
18071
  }
18072
- return path;
18072
+ return path3;
18073
18073
  }
18074
18074
  function ucIdentifier(value, label) {
18075
18075
  const normalized = value.trim();
@@ -18407,6 +18407,402 @@ function databricksAiQueryTool(client, options) {
18407
18407
  };
18408
18408
  }
18409
18409
 
18410
+ // src/asset-bundles.ts
18411
+ import { access as access3, readFile as readFile2, readdir } from "fs/promises";
18412
+ import path2 from "path";
18413
+
18414
+ // src/app-deployment.ts
18415
+ import { spawn } from "child_process";
18416
+ import { access as access2 } from "fs/promises";
18417
+ import path from "path";
18418
+ async function runDatabricksCommand(command, args, options) {
18419
+ return new Promise((resolve2, reject) => {
18420
+ const child = spawn(command, [...args], {
18421
+ cwd: options.cwd,
18422
+ env: options.env,
18423
+ shell: false,
18424
+ stdio: ["ignore", "pipe", "pipe"]
18425
+ });
18426
+ let stdout = "";
18427
+ let stderr = "";
18428
+ child.stdout.on("data", (chunk) => {
18429
+ stdout += chunk.toString();
18430
+ });
18431
+ child.stderr.on("data", (chunk) => {
18432
+ stderr += chunk.toString();
18433
+ });
18434
+ child.once("error", reject);
18435
+ child.once("close", (code) => resolve2({ exitCode: code ?? -1, stdout, stderr }));
18436
+ });
18437
+ }
18438
+
18439
+ // src/managed-resource.ts
18440
+ var DatabricksManagedResourceConflictError = class extends Error {
18441
+ resourceType;
18442
+ resourceId;
18443
+ expectedFingerprint;
18444
+ actualFingerprint;
18445
+ constructor(input) {
18446
+ super(
18447
+ `Databricks managed ${input.resourceType} ${input.resourceId} changed: expected fingerprint ${input.expectedFingerprint}, found ${input.actualFingerprint}.`
18448
+ );
18449
+ this.name = "DatabricksManagedResourceConflictError";
18450
+ this.resourceType = input.resourceType;
18451
+ this.resourceId = input.resourceId;
18452
+ this.expectedFingerprint = input.expectedFingerprint;
18453
+ this.actualFingerprint = input.actualFingerprint;
18454
+ }
18455
+ };
18456
+ var DatabricksUnmanagedResourceError = class extends Error {
18457
+ resourceType;
18458
+ resourceId;
18459
+ constructor(resourceType, resourceId) {
18460
+ super(
18461
+ `Databricks ${resourceType} ${resourceId} is not recorded as Harness-managed; model-facing mutation is denied.`
18462
+ );
18463
+ this.name = "DatabricksUnmanagedResourceError";
18464
+ this.resourceType = resourceType;
18465
+ this.resourceId = resourceId;
18466
+ }
18467
+ };
18468
+ var MemoryDatabricksManagedResourceStore = class {
18469
+ records = /* @__PURE__ */ new Map();
18470
+ async get(resourceType, resourceId) {
18471
+ const record2 = this.records.get(resourceKey(resourceType, resourceId));
18472
+ return record2 ? structuredClone(record2) : void 0;
18473
+ }
18474
+ async put(record2) {
18475
+ validateRecord(record2);
18476
+ this.records.set(resourceKey(record2.resourceType, record2.resourceId), structuredClone(record2));
18477
+ }
18478
+ async delete(resourceType, resourceId) {
18479
+ this.records.delete(resourceKey(resourceType, resourceId));
18480
+ }
18481
+ async list(resourceType) {
18482
+ return [...this.records.values()].filter((record2) => resourceType === void 0 || record2.resourceType === resourceType).sort(
18483
+ (left, right) => resourceKey(left.resourceType, left.resourceId).localeCompare(
18484
+ resourceKey(right.resourceType, right.resourceId)
18485
+ )
18486
+ ).map((record2) => structuredClone(record2));
18487
+ }
18488
+ };
18489
+ async function databricksResourceFingerprint(value) {
18490
+ const digest = await crypto.subtle.digest(
18491
+ "SHA-256",
18492
+ new TextEncoder().encode(canonicalJson(value))
18493
+ );
18494
+ return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
18495
+ }
18496
+ async function requireDatabricksManagedResource(input) {
18497
+ const record2 = await input.store.get(input.resourceType, input.resourceId);
18498
+ if (!record2) throw new DatabricksUnmanagedResourceError(input.resourceType, input.resourceId);
18499
+ if (input.expectedFingerprint && record2.fingerprint !== input.expectedFingerprint) {
18500
+ throw new DatabricksManagedResourceConflictError({
18501
+ resourceType: input.resourceType,
18502
+ resourceId: input.resourceId,
18503
+ expectedFingerprint: input.expectedFingerprint,
18504
+ actualFingerprint: record2.fingerprint
18505
+ });
18506
+ }
18507
+ return record2;
18508
+ }
18509
+ function validateRecord(record2) {
18510
+ for (const [name, value] of Object.entries({
18511
+ resourceType: record2.resourceType,
18512
+ resourceId: record2.resourceId,
18513
+ fingerprint: record2.fingerprint,
18514
+ createdBy: record2.createdBy,
18515
+ toolCallId: record2.toolCallId,
18516
+ createdAt: record2.createdAt,
18517
+ updatedAt: record2.updatedAt
18518
+ })) {
18519
+ if (!value.trim()) throw new Error(`Databricks managed-resource ${name} cannot be empty.`);
18520
+ }
18521
+ if (!/^\d{4}-\d{2}-\d{2}T/.test(record2.createdAt) || !/^\d{4}-\d{2}-\d{2}T/.test(record2.updatedAt)) {
18522
+ throw new Error("Databricks managed-resource timestamps must be ISO-8601 strings.");
18523
+ }
18524
+ }
18525
+ function resourceKey(resourceType, resourceId) {
18526
+ return `${resourceType.trim()}\0${resourceId.trim()}`;
18527
+ }
18528
+ function canonicalJson(value) {
18529
+ if (value === null || typeof value !== "object") {
18530
+ const encoded = JSON.stringify(value);
18531
+ return encoded === void 0 ? "null" : encoded;
18532
+ }
18533
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
18534
+ return `{${Object.entries(value).filter(([, child]) => child !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`).join(",")}}`;
18535
+ }
18536
+
18537
+ // src/asset-bundles.ts
18538
+ var BUNDLE_RESOURCE_TYPE = "databricks-bundle";
18539
+ var FINGERPRINT_EXCLUDED_DIRS = /* @__PURE__ */ new Set([".databricks", "node_modules", "dist"]);
18540
+ var DatabricksAssetBundleLifecycle = class {
18541
+ /** Resolved bundle directory; also the governed resource identity on the tools. */
18542
+ bundleDir;
18543
+ target;
18544
+ profile;
18545
+ executable;
18546
+ env;
18547
+ commandRunner;
18548
+ store;
18549
+ principalLabel;
18550
+ bundleName;
18551
+ constructor(options) {
18552
+ if (!options.bundleDir?.trim())
18553
+ throw new Error("databricks asset bundles: bundleDir is required.");
18554
+ this.bundleDir = path2.resolve(options.bundleDir);
18555
+ this.executable = options.executable ?? "databricks";
18556
+ this.env = options.env ?? process.env;
18557
+ this.commandRunner = options.run ?? runDatabricksCommand;
18558
+ this.store = options.store ?? new MemoryDatabricksManagedResourceStore();
18559
+ this.principalLabel = options.principalLabel ?? "unknown";
18560
+ if (options.target !== void 0) this.target = options.target;
18561
+ if (options.profile !== void 0) this.profile = options.profile;
18562
+ }
18563
+ /** Run `databricks bundle validate` without mutating the workspace. */
18564
+ async validate() {
18565
+ await this.requireManifest();
18566
+ const args = ["bundle", "validate", ...this.targetArgs(), ...this.profileArgs()];
18567
+ const result = await this.commandRunner(this.executable, args, {
18568
+ cwd: this.bundleDir,
18569
+ env: this.env
18570
+ });
18571
+ requireSuccess("Databricks bundle validation", result);
18572
+ return { valid: true, output: lastNonEmptyLine(result.stdout) };
18573
+ }
18574
+ /** Deterministic sha256 over the sorted bundle source tree (path + content). */
18575
+ async fingerprint() {
18576
+ await this.requireManifest();
18577
+ const files = (await collectSourceFiles(this.bundleDir)).sort();
18578
+ const entries = [];
18579
+ for (const file2 of files) {
18580
+ const content = await readFile2(file2);
18581
+ const digest = await crypto.subtle.digest("SHA-256", content);
18582
+ entries.push({
18583
+ path: path2.relative(this.bundleDir, file2).split(path2.sep).join("/"),
18584
+ sha256: [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("")
18585
+ });
18586
+ }
18587
+ return databricksResourceFingerprint(entries);
18588
+ }
18589
+ /** Validate, deploy, and record the source fingerprint in the managed-resource store. */
18590
+ async deploy(options = {}) {
18591
+ await this.requireManifest();
18592
+ const fingerprint = await this.fingerprint();
18593
+ const resourceId = await this.resourceId();
18594
+ const existing = await this.store.get(BUNDLE_RESOURCE_TYPE, resourceId);
18595
+ if (existing && options.expectedFingerprint !== void 0 && existing.fingerprint !== options.expectedFingerprint) {
18596
+ throw new DatabricksManagedResourceConflictError({
18597
+ resourceType: BUNDLE_RESOURCE_TYPE,
18598
+ resourceId,
18599
+ expectedFingerprint: options.expectedFingerprint,
18600
+ actualFingerprint: existing.fingerprint
18601
+ });
18602
+ }
18603
+ await this.validate();
18604
+ const args = ["bundle", "deploy", ...this.targetArgs(), ...this.profileArgs()];
18605
+ const result = await this.commandRunner(this.executable, args, {
18606
+ cwd: this.bundleDir,
18607
+ env: this.env
18608
+ });
18609
+ requireSuccess("Databricks bundle deployment", result);
18610
+ const now = (/* @__PURE__ */ new Date()).toISOString();
18611
+ await this.store.put({
18612
+ resourceType: BUNDLE_RESOURCE_TYPE,
18613
+ resourceId,
18614
+ fingerprint,
18615
+ createdBy: existing?.createdBy ?? this.principalLabel,
18616
+ toolCallId: "databricks_bundle_deploy",
18617
+ createdAt: existing?.createdAt ?? now,
18618
+ updatedAt: now
18619
+ });
18620
+ return { deployed: true, fingerprint, output: lastNonEmptyLine(result.stdout) };
18621
+ }
18622
+ /**
18623
+ * Submit a run of a bundle-defined job/pipeline by its `databricks.yml` resource key.
18624
+ * Always passes `--no-wait` — waiting inside a tool call would violate finite-agent
18625
+ * boundedness, so run status must be polled through the bounded jobs/lakeflow status
18626
+ * tools. No managed-resource record is required: bundles deployed outside Harness
18627
+ * (e.g. by CI) stay runnable, and the CLI fails cleanly against an undeployed bundle.
18628
+ */
18629
+ async run(options) {
18630
+ await this.requireManifest();
18631
+ const key = options.key?.trim();
18632
+ if (!key) throw new Error("databricks asset bundles: run requires a non-empty resource key.");
18633
+ const args = [
18634
+ "bundle",
18635
+ "run",
18636
+ key,
18637
+ "--no-wait",
18638
+ ...options.restart === true ? ["--restart"] : [],
18639
+ ...this.targetArgs(),
18640
+ ...this.profileArgs()
18641
+ ];
18642
+ const result = await this.commandRunner(this.executable, args, {
18643
+ cwd: this.bundleDir,
18644
+ env: this.env
18645
+ });
18646
+ requireSuccess("Databricks bundle run submission", result);
18647
+ return { submitted: true, output: lastNonEmptyLine(result.stdout) };
18648
+ }
18649
+ /** Destroy a Harness-recorded bundle deployment and delete its managed record. */
18650
+ async destroy(options = {}) {
18651
+ await this.requireManifest();
18652
+ const resourceId = await this.resourceId();
18653
+ const record2 = await requireDatabricksManagedResource({
18654
+ store: this.store,
18655
+ resourceType: BUNDLE_RESOURCE_TYPE,
18656
+ resourceId
18657
+ });
18658
+ if (!options.force) {
18659
+ const current = await this.fingerprint();
18660
+ if (current !== record2.fingerprint)
18661
+ throw new DatabricksManagedResourceConflictError({
18662
+ resourceType: BUNDLE_RESOURCE_TYPE,
18663
+ resourceId,
18664
+ expectedFingerprint: record2.fingerprint,
18665
+ actualFingerprint: current
18666
+ });
18667
+ }
18668
+ const args = [
18669
+ "bundle",
18670
+ "destroy",
18671
+ "--auto-approve",
18672
+ ...this.targetArgs(),
18673
+ ...this.profileArgs()
18674
+ ];
18675
+ const result = await this.commandRunner(this.executable, args, {
18676
+ cwd: this.bundleDir,
18677
+ env: this.env
18678
+ });
18679
+ requireSuccess("Databricks bundle teardown", result);
18680
+ await this.store.delete(BUNDLE_RESOURCE_TYPE, resourceId);
18681
+ return { destroyed: true, output: lastNonEmptyLine(result.stdout) };
18682
+ }
18683
+ /** Bundle `name:` parsed from `databricks.yml`, falling back to the directory basename. */
18684
+ async resourceId() {
18685
+ if (this.bundleName === void 0) {
18686
+ const manifest = await readFile2(path2.join(this.bundleDir, "databricks.yml"), "utf8");
18687
+ const match = /^\s*name:\s*["']?([^\s"']+)["']?\s*$/m.exec(manifest);
18688
+ this.bundleName = match?.[1] ?? path2.basename(this.bundleDir);
18689
+ }
18690
+ return this.bundleName;
18691
+ }
18692
+ async requireManifest() {
18693
+ const manifest = path2.join(this.bundleDir, "databricks.yml");
18694
+ try {
18695
+ await access3(manifest);
18696
+ } catch {
18697
+ throw new Error(`databricks asset bundles: databricks.yml not found at ${manifest}.`);
18698
+ }
18699
+ }
18700
+ targetArgs() {
18701
+ return this.target ? ["--target", this.target] : [];
18702
+ }
18703
+ profileArgs() {
18704
+ return this.profile ? ["--profile", this.profile] : [];
18705
+ }
18706
+ };
18707
+ function databricksAssetBundleLifecycle(options) {
18708
+ return new DatabricksAssetBundleLifecycle(options);
18709
+ }
18710
+ function databricksAssetBundleTools(options) {
18711
+ const lifecycle = options instanceof DatabricksAssetBundleLifecycle ? options : new DatabricksAssetBundleLifecycle(options);
18712
+ const resources = [{ kind: "bundle", value: lifecycle.bundleDir }];
18713
+ return [
18714
+ bundleTool(
18715
+ "databricks_bundle_validate",
18716
+ "Validate the checked-in Databricks Asset Bundle without deploying it.",
18717
+ "read",
18718
+ { type: "object", additionalProperties: false, properties: {} },
18719
+ [],
18720
+ () => lifecycle.validate()
18721
+ ),
18722
+ bundleTool(
18723
+ "databricks_bundle_deploy",
18724
+ "Validate and deploy the checked-in Databricks Asset Bundle, recording its source fingerprint.",
18725
+ "write",
18726
+ {
18727
+ type: "object",
18728
+ additionalProperties: false,
18729
+ properties: { expectedFingerprint: { type: "string" } }
18730
+ },
18731
+ resources,
18732
+ (input) => {
18733
+ const expectedFingerprint = input.expectedFingerprint;
18734
+ return lifecycle.deploy(expectedFingerprint !== void 0 ? { expectedFingerprint } : {});
18735
+ }
18736
+ ),
18737
+ bundleTool(
18738
+ "databricks_bundle_run",
18739
+ "Submit (without waiting) a run of a bundle-defined job or pipeline by its databricks.yml resource key.",
18740
+ "execute",
18741
+ {
18742
+ type: "object",
18743
+ additionalProperties: false,
18744
+ properties: { key: { type: "string" }, restart: { type: "boolean" } },
18745
+ required: ["key"]
18746
+ },
18747
+ resources,
18748
+ (input) => lifecycle.run({
18749
+ key: input.key,
18750
+ restart: input.restart === true
18751
+ })
18752
+ ),
18753
+ bundleTool(
18754
+ "databricks_bundle_destroy",
18755
+ "Destroy a Harness-recorded Databricks Asset Bundle deployment.",
18756
+ "write",
18757
+ {
18758
+ type: "object",
18759
+ additionalProperties: false,
18760
+ properties: { force: { type: "boolean" } }
18761
+ },
18762
+ resources,
18763
+ (input) => lifecycle.destroy({ force: input.force === true })
18764
+ )
18765
+ ];
18766
+ }
18767
+ function bundleTool(name, description, effect, inputSchema, resources, execute2) {
18768
+ return {
18769
+ name,
18770
+ description,
18771
+ inputSchema,
18772
+ metadata: {
18773
+ effect,
18774
+ provider: "databricks",
18775
+ service: "bundles",
18776
+ ...resources.length ? { governance: { resources } } : {}
18777
+ },
18778
+ execute: execute2
18779
+ };
18780
+ }
18781
+ async function collectSourceFiles(dir) {
18782
+ const entries = await readdir(dir, { withFileTypes: true });
18783
+ const files = [];
18784
+ for (const entry of entries) {
18785
+ const full = path2.join(dir, entry.name);
18786
+ if (entry.isDirectory()) {
18787
+ if (!FINGERPRINT_EXCLUDED_DIRS.has(entry.name))
18788
+ files.push(...await collectSourceFiles(full));
18789
+ } else if (entry.isFile()) {
18790
+ files.push(full);
18791
+ }
18792
+ }
18793
+ return files;
18794
+ }
18795
+ function requireSuccess(label, result) {
18796
+ if (result.exitCode === 0) return;
18797
+ const detail = result.stderr.trim().slice(-2e3);
18798
+ throw new Error(
18799
+ `${label} failed with exit code ${result.exitCode}${detail ? `: ${detail}` : ""}`
18800
+ );
18801
+ }
18802
+ function lastNonEmptyLine(value) {
18803
+ return value.split("\n").map((line) => line.trim()).filter(Boolean).at(-1) ?? "";
18804
+ }
18805
+
18410
18806
  // src/consumption.ts
18411
18807
  var GROUP_COLUMNS = {
18412
18808
  sku: { select: "u.sku_name AS sku, u.usage_unit AS unit", group: "u.sku_name, u.usage_unit" },
@@ -18938,64 +19334,6 @@ function optional2(key, value) {
18938
19334
  return value === void 0 ? {} : { [key]: value };
18939
19335
  }
18940
19336
 
18941
- // src/managed-resource.ts
18942
- var DatabricksManagedResourceConflictError = class extends Error {
18943
- resourceType;
18944
- resourceId;
18945
- expectedFingerprint;
18946
- actualFingerprint;
18947
- constructor(input) {
18948
- super(
18949
- `Databricks managed ${input.resourceType} ${input.resourceId} changed: expected fingerprint ${input.expectedFingerprint}, found ${input.actualFingerprint}.`
18950
- );
18951
- this.name = "DatabricksManagedResourceConflictError";
18952
- this.resourceType = input.resourceType;
18953
- this.resourceId = input.resourceId;
18954
- this.expectedFingerprint = input.expectedFingerprint;
18955
- this.actualFingerprint = input.actualFingerprint;
18956
- }
18957
- };
18958
- var DatabricksUnmanagedResourceError = class extends Error {
18959
- resourceType;
18960
- resourceId;
18961
- constructor(resourceType, resourceId) {
18962
- super(
18963
- `Databricks ${resourceType} ${resourceId} is not recorded as Harness-managed; model-facing mutation is denied.`
18964
- );
18965
- this.name = "DatabricksUnmanagedResourceError";
18966
- this.resourceType = resourceType;
18967
- this.resourceId = resourceId;
18968
- }
18969
- };
18970
- async function databricksResourceFingerprint(value) {
18971
- const digest = await crypto.subtle.digest(
18972
- "SHA-256",
18973
- new TextEncoder().encode(canonicalJson(value))
18974
- );
18975
- return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
18976
- }
18977
- async function requireDatabricksManagedResource(input) {
18978
- const record2 = await input.store.get(input.resourceType, input.resourceId);
18979
- if (!record2) throw new DatabricksUnmanagedResourceError(input.resourceType, input.resourceId);
18980
- if (input.expectedFingerprint && record2.fingerprint !== input.expectedFingerprint) {
18981
- throw new DatabricksManagedResourceConflictError({
18982
- resourceType: input.resourceType,
18983
- resourceId: input.resourceId,
18984
- expectedFingerprint: input.expectedFingerprint,
18985
- actualFingerprint: record2.fingerprint
18986
- });
18987
- }
18988
- return record2;
18989
- }
18990
- function canonicalJson(value) {
18991
- if (value === null || typeof value !== "object") {
18992
- const encoded = JSON.stringify(value);
18993
- return encoded === void 0 ? "null" : encoded;
18994
- }
18995
- if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
18996
- return `{${Object.entries(value).filter(([, child]) => child !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`).join(",")}}`;
18997
- }
18998
-
18999
19337
  // src/genie-authoring.ts
19000
19338
  var GENIE_RESOURCE_TYPE = "genie-agent";
19001
19339
  var SERIALIZED_VERSION = 2;
@@ -21556,151 +21894,6 @@ function databricksLakeflowTools(client) {
21556
21894
  ];
21557
21895
  }
21558
21896
 
21559
- // src/mlflow-tracing.ts
21560
- import { createHash } from "crypto";
21561
- import { eventToTelemetrySpan } from "@fabric-harness/sdk";
21562
- function mlflowTraceExporter(options) {
21563
- const onError = options.onError ?? ((context, error51) => {
21564
- console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
21565
- });
21566
- const buffers = /* @__PURE__ */ new Map();
21567
- return {
21568
- sink: {
21569
- record(event) {
21570
- try {
21571
- const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
21572
- if (event.type === "submission_started") {
21573
- buffers.set(key, {
21574
- submissionId: event.submissionId,
21575
- agent: event.agent,
21576
- instanceId: event.instanceId,
21577
- session: event.session,
21578
- startedAtMs: event.at,
21579
- attemptCount: event.attemptCount,
21580
- ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
21581
- spans: []
21582
- });
21583
- return;
21584
- }
21585
- if (event.type !== "submission_settled") return;
21586
- const buffer = buffers.get(key);
21587
- buffers.delete(key);
21588
- const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
21589
- const attemptCount = event.attemptCount ?? buffer?.attemptCount;
21590
- const trace = buildMlflowTrace({
21591
- submissionId: event.submissionId,
21592
- agent: event.agent,
21593
- instanceId: event.instanceId,
21594
- session: event.session,
21595
- experimentId: options.experimentId,
21596
- startedAtMs,
21597
- settledAtMs: event.at,
21598
- state: event.outcome === "completed" ? "OK" : "ERROR",
21599
- spans: buffer?.spans ?? [],
21600
- ...attemptCount !== void 0 ? { attemptCount } : {},
21601
- ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
21602
- ...event.error !== void 0 ? { error: event.error } : {}
21603
- });
21604
- void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
21605
- } catch (error51) {
21606
- onError("telemetry event handling failed", error51);
21607
- }
21608
- }
21609
- },
21610
- onEvent(event) {
21611
- try {
21612
- if (!event.sessionId) return;
21613
- const buffer = buffers.get(event.sessionId);
21614
- if (!buffer) return;
21615
- const span = eventToTelemetrySpan(event);
21616
- if (span) buffer.spans.push(span);
21617
- } catch (error51) {
21618
- onError("event buffering failed", error51);
21619
- }
21620
- }
21621
- };
21622
- }
21623
- function buildMlflowTrace(input) {
21624
- const traceBytes = sha256(input.submissionId).subarray(0, 16);
21625
- const traceIdBase64 = traceBytes.toString("base64");
21626
- const rootSpanId = spanIdFor(input.submissionId, 0);
21627
- const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
21628
- const rootSpan = {
21629
- trace_id: traceIdBase64,
21630
- span_id: rootSpanId,
21631
- name: `fabric.submission ${input.agent}`,
21632
- start_time_unix_nano: toUnixNano(input.startedAtMs),
21633
- end_time_unix_nano: toUnixNano(input.settledAtMs),
21634
- attributes: toOtlpAttributes({
21635
- "fabric.submission_id": input.submissionId,
21636
- "fabric.agent": input.agent,
21637
- "fabric.instance_id": input.instanceId,
21638
- "fabric.session": input.session,
21639
- ...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
21640
- ...input.error !== void 0 ? { "fabric.error": input.error } : {}
21641
- }),
21642
- status: {
21643
- code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
21644
- ...input.error !== void 0 ? { message: input.error } : {}
21645
- }
21646
- };
21647
- const childSpans = input.spans.map(
21648
- (span, index) => ({
21649
- trace_id: traceIdBase64,
21650
- span_id: spanIdFor(input.submissionId, index + 1),
21651
- parent_span_id: rootSpanId,
21652
- name: span.name,
21653
- start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
21654
- end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
21655
- attributes: toOtlpAttributes(span.attributes),
21656
- status: { code: "STATUS_CODE_OK" }
21657
- })
21658
- );
21659
- return {
21660
- trace: {
21661
- trace_info: {
21662
- trace_id: `tr-${traceBytes.toString("hex")}`,
21663
- trace_location: {
21664
- type: "MLFLOW_EXPERIMENT",
21665
- mlflow_experiment: { experiment_id: input.experimentId }
21666
- },
21667
- request_time: new Date(input.startedAtMs).toISOString(),
21668
- execution_duration: `${durationSeconds.toFixed(3)}s`,
21669
- state: input.state,
21670
- trace_metadata: {
21671
- "fabric.submission_id": input.submissionId,
21672
- "fabric.agent": input.agent,
21673
- "fabric.instance_id": input.instanceId,
21674
- "fabric.session": input.session,
21675
- ...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
21676
- },
21677
- tags: {
21678
- "fabric.agent": input.agent,
21679
- ...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
21680
- }
21681
- },
21682
- trace_data: { spans: [rootSpan, ...childSpans] }
21683
- }
21684
- };
21685
- }
21686
- function sha256(seed) {
21687
- return createHash("sha256").update(seed).digest();
21688
- }
21689
- function spanIdFor(submissionId, index) {
21690
- return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
21691
- }
21692
- function toUnixNano(epochMs) {
21693
- return `${Math.round(epochMs)}000000`;
21694
- }
21695
- function toOtlpAttributes(attributes) {
21696
- return Object.entries(attributes).map(([key, value]) => {
21697
- if (typeof value === "number") {
21698
- return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
21699
- }
21700
- return { key, value: { string_value: String(value) } };
21701
- });
21702
- }
21703
-
21704
21897
  // src/mcp.ts
21705
21898
  import {
21706
21899
  connectMcpServer,
@@ -21884,6 +22077,151 @@ function redactedMcpError(error51, secrets) {
21884
22077
  return redacted;
21885
22078
  }
21886
22079
 
22080
+ // src/mlflow-tracing.ts
22081
+ import { createHash } from "crypto";
22082
+ import { eventToTelemetrySpan } from "@fabric-harness/sdk";
22083
+ function mlflowTraceExporter(options) {
22084
+ const onError = options.onError ?? ((context, error51) => {
22085
+ console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
22086
+ });
22087
+ const buffers = /* @__PURE__ */ new Map();
22088
+ return {
22089
+ sink: {
22090
+ record(event) {
22091
+ try {
22092
+ const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
22093
+ if (event.type === "submission_started") {
22094
+ buffers.set(key, {
22095
+ submissionId: event.submissionId,
22096
+ agent: event.agent,
22097
+ instanceId: event.instanceId,
22098
+ session: event.session,
22099
+ startedAtMs: event.at,
22100
+ attemptCount: event.attemptCount,
22101
+ ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
22102
+ spans: []
22103
+ });
22104
+ return;
22105
+ }
22106
+ if (event.type !== "submission_settled") return;
22107
+ const buffer = buffers.get(key);
22108
+ buffers.delete(key);
22109
+ const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
22110
+ const attemptCount = event.attemptCount ?? buffer?.attemptCount;
22111
+ const trace = buildMlflowTrace({
22112
+ submissionId: event.submissionId,
22113
+ agent: event.agent,
22114
+ instanceId: event.instanceId,
22115
+ session: event.session,
22116
+ experimentId: options.experimentId,
22117
+ startedAtMs,
22118
+ settledAtMs: event.at,
22119
+ state: event.outcome === "completed" ? "OK" : "ERROR",
22120
+ spans: buffer?.spans ?? [],
22121
+ ...attemptCount !== void 0 ? { attemptCount } : {},
22122
+ ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
22123
+ ...event.error !== void 0 ? { error: event.error } : {}
22124
+ });
22125
+ void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
22126
+ } catch (error51) {
22127
+ onError("telemetry event handling failed", error51);
22128
+ }
22129
+ }
22130
+ },
22131
+ onEvent(event) {
22132
+ try {
22133
+ if (!event.sessionId) return;
22134
+ const buffer = buffers.get(event.sessionId);
22135
+ if (!buffer) return;
22136
+ const span = eventToTelemetrySpan(event);
22137
+ if (span) buffer.spans.push(span);
22138
+ } catch (error51) {
22139
+ onError("event buffering failed", error51);
22140
+ }
22141
+ }
22142
+ };
22143
+ }
22144
+ function buildMlflowTrace(input) {
22145
+ const traceBytes = sha256(input.submissionId).subarray(0, 16);
22146
+ const traceIdBase64 = traceBytes.toString("base64");
22147
+ const rootSpanId = spanIdFor(input.submissionId, 0);
22148
+ const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
22149
+ const rootSpan = {
22150
+ trace_id: traceIdBase64,
22151
+ span_id: rootSpanId,
22152
+ name: `fabric.submission ${input.agent}`,
22153
+ start_time_unix_nano: toUnixNano(input.startedAtMs),
22154
+ end_time_unix_nano: toUnixNano(input.settledAtMs),
22155
+ attributes: toOtlpAttributes({
22156
+ "fabric.submission_id": input.submissionId,
22157
+ "fabric.agent": input.agent,
22158
+ "fabric.instance_id": input.instanceId,
22159
+ "fabric.session": input.session,
22160
+ ...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
22161
+ ...input.error !== void 0 ? { "fabric.error": input.error } : {}
22162
+ }),
22163
+ status: {
22164
+ code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
22165
+ ...input.error !== void 0 ? { message: input.error } : {}
22166
+ }
22167
+ };
22168
+ const childSpans = input.spans.map(
22169
+ (span, index) => ({
22170
+ trace_id: traceIdBase64,
22171
+ span_id: spanIdFor(input.submissionId, index + 1),
22172
+ parent_span_id: rootSpanId,
22173
+ name: span.name,
22174
+ start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
22175
+ end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
22176
+ attributes: toOtlpAttributes(span.attributes),
22177
+ status: { code: "STATUS_CODE_OK" }
22178
+ })
22179
+ );
22180
+ return {
22181
+ trace: {
22182
+ trace_info: {
22183
+ trace_id: `tr-${traceBytes.toString("hex")}`,
22184
+ trace_location: {
22185
+ type: "MLFLOW_EXPERIMENT",
22186
+ mlflow_experiment: { experiment_id: input.experimentId }
22187
+ },
22188
+ request_time: new Date(input.startedAtMs).toISOString(),
22189
+ execution_duration: `${durationSeconds.toFixed(3)}s`,
22190
+ state: input.state,
22191
+ trace_metadata: {
22192
+ "fabric.submission_id": input.submissionId,
22193
+ "fabric.agent": input.agent,
22194
+ "fabric.instance_id": input.instanceId,
22195
+ "fabric.session": input.session,
22196
+ ...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
22197
+ },
22198
+ tags: {
22199
+ "fabric.agent": input.agent,
22200
+ ...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
22201
+ }
22202
+ },
22203
+ trace_data: { spans: [rootSpan, ...childSpans] }
22204
+ }
22205
+ };
22206
+ }
22207
+ function sha256(seed) {
22208
+ return createHash("sha256").update(seed).digest();
22209
+ }
22210
+ function spanIdFor(submissionId, index) {
22211
+ return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
22212
+ }
22213
+ function toUnixNano(epochMs) {
22214
+ return `${Math.round(epochMs)}000000`;
22215
+ }
22216
+ function toOtlpAttributes(attributes) {
22217
+ return Object.entries(attributes).map(([key, value]) => {
22218
+ if (typeof value === "number") {
22219
+ return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
22220
+ }
22221
+ return { key, value: { string_value: String(value) } };
22222
+ });
22223
+ }
22224
+
21887
22225
  // src/model.ts
21888
22226
  import {
21889
22227
  OpenAICompatibleModelProvider,
@@ -36224,8 +36562,8 @@ function parseResponse9(body, schema) {
36224
36562
  function marshalRequest8(data, schema) {
36225
36563
  return jsonBigint8.stringify(schema.parse(data));
36226
36564
  }
36227
- function encodeMultiSegmentPath(path) {
36228
- return path.split("/").map((segment2) => encodeURIComponent(segment2)).join("/");
36565
+ function encodeMultiSegmentPath(path3) {
36566
+ return path3.split("/").map((segment2) => encodeURIComponent(segment2)).join("/");
36229
36567
  }
36230
36568
  async function sendAndCheckError2(opts) {
36231
36569
  opts.logger.debug("HTTP request", {
@@ -57422,19 +57760,19 @@ var DATABRICKS_RAW_PROTOCOL_RULES = [
57422
57760
  path: /^\/serving-endpoints\/[^/?#]+\/invocations$/u
57423
57761
  }
57424
57762
  ];
57425
- function assertRawProtocolAllowed(method, path) {
57763
+ function assertRawProtocolAllowed(method, path3) {
57426
57764
  const normalizedMethod = method.toUpperCase();
57427
- if (!path.startsWith("/") || path.includes("?") || path.includes("#")) {
57765
+ if (!path3.startsWith("/") || path3.includes("?") || path3.includes("#")) {
57428
57766
  throw new Error(
57429
- `databricks raw protocol denied: ${normalizedMethod} ${path}; pass a relative path and structured query parameters.`
57767
+ `databricks raw protocol denied: ${normalizedMethod} ${path3}; pass a relative path and structured query parameters.`
57430
57768
  );
57431
57769
  }
57432
57770
  const rule = DATABRICKS_RAW_PROTOCOL_RULES.find(
57433
- (candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(path)
57771
+ (candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(path3)
57434
57772
  );
57435
57773
  if (!rule) {
57436
57774
  throw new Error(
57437
- `databricks raw protocol denied: ${normalizedMethod} ${path}; use an official @databricks/sdk-* service client.`
57775
+ `databricks raw protocol denied: ${normalizedMethod} ${path3}; use an official @databricks/sdk-* service client.`
57438
57776
  );
57439
57777
  }
57440
57778
  }
@@ -57455,20 +57793,20 @@ var DatabricksRawProtocolClient = class {
57455
57793
  this.signal = options.signal;
57456
57794
  this.extraHeaders = options.extraHeaders;
57457
57795
  }
57458
- get(path, query, options) {
57459
- return this.requestJson("GET", path, void 0, query, options);
57796
+ get(path3, query, options) {
57797
+ return this.requestJson("GET", path3, void 0, query, options);
57460
57798
  }
57461
- post(path, body, query, options) {
57462
- return this.requestJson("POST", path, body, query, options);
57799
+ post(path3, body, query, options) {
57800
+ return this.requestJson("POST", path3, body, query, options);
57463
57801
  }
57464
- patch(path, body, query, options) {
57465
- return this.requestJson("PATCH", path, body, query, options);
57802
+ patch(path3, body, query, options) {
57803
+ return this.requestJson("PATCH", path3, body, query, options);
57466
57804
  }
57467
- delete(path, body, query, options) {
57468
- return this.requestJson("DELETE", path, body, query, options);
57805
+ delete(path3, body, query, options) {
57806
+ return this.requestJson("DELETE", path3, body, query, options);
57469
57807
  }
57470
- async requestJson(method, path, body, query = {}, options = {}) {
57471
- const response = await this.send(method, path, body, query, options);
57808
+ async requestJson(method, path3, body, query = {}, options = {}) {
57809
+ const response = await this.send(method, path3, body, query, options);
57472
57810
  if (response.status === 204) return void 0;
57473
57811
  return await response.json();
57474
57812
  }
@@ -57476,12 +57814,12 @@ var DatabricksRawProtocolClient = class {
57476
57814
  * Perform an authenticated request while leaving a successful response body unread. This is
57477
57815
  * intended for bounded binary downloads and streaming APIs such as Genie Agent Mode.
57478
57816
  */
57479
- postRaw(path, body, query = {}, options = {}) {
57480
- return this.send("POST", path, body, query, options);
57817
+ postRaw(path3, body, query = {}, options = {}) {
57818
+ return this.send("POST", path3, body, query, options);
57481
57819
  }
57482
- async send(method, path, body, query, options) {
57483
- assertRawProtocolAllowed(method, path);
57484
- const url2 = new URL(`${this.host}${path.startsWith("/") ? path : `/${path}`}`);
57820
+ async send(method, path3, body, query, options) {
57821
+ assertRawProtocolAllowed(method, path3);
57822
+ const url2 = new URL(`${this.host}${path3.startsWith("/") ? path3 : `/${path3}`}`);
57485
57823
  for (const [key, value] of Object.entries(query))
57486
57824
  if (value !== void 0) url2.searchParams.set(key, String(value));
57487
57825
  const canRetry = options.retry === "always" || options.retry !== "never" && (options.retry === "safe" || method === "GET" || method === "HEAD");
@@ -58643,16 +58981,16 @@ var DatabricksWorkspaceAuthoring = class {
58643
58981
  { retry: "never" }
58644
58982
  );
58645
58983
  }
58646
- deleteWorkspaceObject(path, recursive = false) {
58984
+ deleteWorkspaceObject(path3, recursive = false) {
58647
58985
  return this.client.post(
58648
58986
  "/api/2.0/workspace/delete",
58649
- { path, recursive },
58987
+ { path: path3, recursive },
58650
58988
  {},
58651
58989
  { retry: "never" }
58652
58990
  );
58653
58991
  }
58654
- mkdirs(path) {
58655
- return this.client.post("/api/2.0/workspace/mkdirs", { path }, {}, { retry: "safe" });
58992
+ mkdirs(path3) {
58993
+ return this.client.post("/api/2.0/workspace/mkdirs", { path: path3 }, {}, { retry: "safe" });
58656
58994
  }
58657
58995
  };
58658
58996
  function databricksWorkspaceAuthoringTools(client) {
@@ -58778,26 +59116,26 @@ function databricksSqlSandbox(options) {
58778
59116
  };
58779
59117
  }
58780
59118
  },
58781
- async readFile(path) {
58782
- const bytes = memFs.get(path);
58783
- if (!bytes) throw new Error(`No such file: ${path}`);
59119
+ async readFile(path3) {
59120
+ const bytes = memFs.get(path3);
59121
+ if (!bytes) throw new Error(`No such file: ${path3}`);
58784
59122
  return new TextDecoder().decode(bytes);
58785
59123
  },
58786
- async readFileBuffer(path) {
58787
- const bytes = memFs.get(path);
58788
- if (!bytes) throw new Error(`No such file: ${path}`);
59124
+ async readFileBuffer(path3) {
59125
+ const bytes = memFs.get(path3);
59126
+ if (!bytes) throw new Error(`No such file: ${path3}`);
58789
59127
  return bytes;
58790
59128
  },
58791
- async writeFile(path, content) {
58792
- memFs.set(path, typeof content === "string" ? new TextEncoder().encode(content) : content);
59129
+ async writeFile(path3, content) {
59130
+ memFs.set(path3, typeof content === "string" ? new TextEncoder().encode(content) : content);
58793
59131
  },
58794
- async stat(path) {
58795
- const bytes = memFs.get(path);
58796
- if (!bytes) throw new Error(`No such file: ${path}`);
59132
+ async stat(path3) {
59133
+ const bytes = memFs.get(path3);
59134
+ if (!bytes) throw new Error(`No such file: ${path3}`);
58797
59135
  return { type: "file", size: bytes.byteLength };
58798
59136
  },
58799
- async readdir(path) {
58800
- const prefix = path.replace(/\/$/, "");
59137
+ async readdir(path3) {
59138
+ const prefix = path3.replace(/\/$/, "");
58801
59139
  const direct = /* @__PURE__ */ new Set();
58802
59140
  for (const key of memFs.keys()) {
58803
59141
  if (!key.startsWith(`${prefix}/`)) continue;
@@ -58807,14 +59145,14 @@ function databricksSqlSandbox(options) {
58807
59145
  }
58808
59146
  return [...direct];
58809
59147
  },
58810
- async exists(path) {
58811
- return memFs.has(path);
59148
+ async exists(path3) {
59149
+ return memFs.has(path3);
58812
59150
  },
58813
59151
  async mkdir() {
58814
59152
  },
58815
- async rm(path) {
59153
+ async rm(path3) {
58816
59154
  for (const key of [...memFs.keys()]) {
58817
- if (key === path || key.startsWith(`${path}/`)) memFs.delete(key);
59155
+ if (key === path3 || key.startsWith(`${path3}/`)) memFs.delete(key);
58818
59156
  }
58819
59157
  }
58820
59158
  };
@@ -58982,6 +59320,12 @@ function buildDatabricksBundle(config2, scope) {
58982
59320
  const client = native.rawProtocol;
58983
59321
  const genieAgentModeClient = genie.agentMode ? databricksGenieAgentMode(client, genie.agentMode) : void 0;
58984
59322
  const agentServicesClient = config2.agentServices ? databricksAgentServices(client, config2.agentServices) : void 0;
59323
+ const assetBundle = config2.assetBundles ? databricksAssetBundleLifecycle({
59324
+ bundleDir: config2.assetBundles.bundleDir,
59325
+ ...config2.assetBundles.target ? { target: config2.assetBundles.target } : {},
59326
+ ...config2.assetBundles.store ? { store: config2.assetBundles.store } : {},
59327
+ principalLabel: config2.governance?.principalLabel ?? principalLabel(config2.principal)
59328
+ }) : void 0;
58985
59329
  let embeddings;
58986
59330
  let retriever;
58987
59331
  let searchTool;
@@ -59056,6 +59400,7 @@ function buildDatabricksBundle(config2, scope) {
59056
59400
  ...config2.lakeflowAuthoring ? databricksLakeflowAuthoringTools(native.pipelines, {
59057
59401
  ...config2.lakeflowEvents && config2.warehouseId ? { warehouseId: config2.warehouseId, statements: native.statements } : {}
59058
59402
  }) : [],
59403
+ ...assetBundle ? databricksAssetBundleTools(assetBundle) : [],
59059
59404
  ...config2.aiSearchAdmin ? databricksAiSearchAdminTools(native.vectorSearch) : [],
59060
59405
  ...config2.servingAdmin ? databricksServingAdminTools(native.modelServing) : [],
59061
59406
  ...config2.ucAdmin ? databricksUnityCatalogAdminTools(
@@ -59134,6 +59479,7 @@ function buildDatabricksBundle(config2, scope) {
59134
59479
  } : {},
59135
59480
  ...genieAgentModeClient ? { genieAgentMode: genieAgentModeClient } : {},
59136
59481
  ...agentServicesClient ? { agentServices: agentServicesClient } : {},
59482
+ ...assetBundle ? { assetBundle } : {},
59137
59483
  aiGateway: {
59138
59484
  ensure: () => ensureDatabricksAiGateway(client),
59139
59485
  listModelServices: (options) => listDatabricksModelServices(client, options),
@@ -59168,6 +59514,7 @@ function enabledAuthoringServices(config2, genie = normalizeGenieConfig(config2)
59168
59514
  ...config2.jobAuthoring || config2.oneOffCompute ? ["jobs"] : [],
59169
59515
  ...genie.manage ? ["genie"] : [],
59170
59516
  ...config2.lakeflowAuthoring ? ["lakeflow"] : [],
59517
+ ...config2.assetBundles ? ["bundles"] : [],
59171
59518
  ...config2.aiSearchAdmin ? ["ai-search"] : [],
59172
59519
  ...config2.servingAdmin ? ["serving"] : [],
59173
59520
  ...config2.ucAdmin ? ["unity-catalog"] : [],