@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 +640 -293
- package/dist/agent.js.map +1 -1
- package/dist/asset-bundles.d.ts +100 -0
- package/dist/asset-bundles.d.ts.map +1 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +868 -578
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1937,13 +1937,13 @@ function connectionResourceName(value) {
|
|
|
1937
1937
|
).join(".")}`;
|
|
1938
1938
|
}
|
|
1939
1939
|
function externalBasePath(value) {
|
|
1940
|
-
const
|
|
1941
|
-
if (!
|
|
1940
|
+
const path4 = value.trim();
|
|
1941
|
+
if (!path4.startsWith("/") || path4.startsWith("//") || path4.includes("?") || path4.includes("#")) {
|
|
1942
1942
|
throw new Error(
|
|
1943
1943
|
"databricks agent services: basePath must be an absolute URL path without a query or fragment."
|
|
1944
1944
|
);
|
|
1945
1945
|
}
|
|
1946
|
-
return
|
|
1946
|
+
return path4;
|
|
1947
1947
|
}
|
|
1948
1948
|
function ucIdentifier(value, label) {
|
|
1949
1949
|
const normalized = value.trim();
|
|
@@ -2319,6 +2319,599 @@ function databricksAiQueryTool(client, options) {
|
|
|
2319
2319
|
};
|
|
2320
2320
|
}
|
|
2321
2321
|
|
|
2322
|
+
// src/asset-bundles.ts
|
|
2323
|
+
import { access as access2, readFile, readdir } from "fs/promises";
|
|
2324
|
+
import path2 from "path";
|
|
2325
|
+
|
|
2326
|
+
// src/app-deployment.ts
|
|
2327
|
+
import { spawn } from "child_process";
|
|
2328
|
+
import { access } from "fs/promises";
|
|
2329
|
+
import path from "path";
|
|
2330
|
+
async function validateDatabricksAppArtifact(options) {
|
|
2331
|
+
const artifactDir = path.resolve(options.artifactDir);
|
|
2332
|
+
await access(path.join(artifactDir, "databricks.yml"));
|
|
2333
|
+
const run = options.run ?? runDatabricksCommand;
|
|
2334
|
+
const args = [
|
|
2335
|
+
"bundle",
|
|
2336
|
+
"validate",
|
|
2337
|
+
...options.target ? ["--target", options.target] : [],
|
|
2338
|
+
...options.profile ? ["--profile", options.profile] : []
|
|
2339
|
+
];
|
|
2340
|
+
const executable = options.executable ?? "databricks";
|
|
2341
|
+
options.onCommand?.({ executable, args });
|
|
2342
|
+
const result = await run(executable, args, {
|
|
2343
|
+
cwd: artifactDir,
|
|
2344
|
+
env: options.env ?? process.env
|
|
2345
|
+
});
|
|
2346
|
+
requireSuccess("Databricks bundle validation", result);
|
|
2347
|
+
return { valid: true, output: lastNonEmptyLine(result.stdout) };
|
|
2348
|
+
}
|
|
2349
|
+
async function deployDatabricksAppArtifact(options) {
|
|
2350
|
+
const artifactDir = path.resolve(options.artifactDir);
|
|
2351
|
+
await access(path.join(artifactDir, "databricks.yml"));
|
|
2352
|
+
const run = options.run ?? runDatabricksCommand;
|
|
2353
|
+
const profileArgs = options.profile ? ["--profile", options.profile] : [];
|
|
2354
|
+
const env2 = options.env ?? process.env;
|
|
2355
|
+
const executable = options.executable ?? "databricks";
|
|
2356
|
+
const bundleArgs = [
|
|
2357
|
+
"bundle",
|
|
2358
|
+
"deploy",
|
|
2359
|
+
...options.target ? ["--target", options.target] : [],
|
|
2360
|
+
...profileArgs
|
|
2361
|
+
];
|
|
2362
|
+
options.onCommand?.({ executable, args: bundleArgs });
|
|
2363
|
+
const bundle = await run(executable, bundleArgs, { cwd: artifactDir, env: env2 });
|
|
2364
|
+
requireSuccess("Databricks bundle synchronization", bundle);
|
|
2365
|
+
if (options.startBeforeDeploy && options.appName) {
|
|
2366
|
+
const startArgs = ["apps", "start", options.appName, ...profileArgs];
|
|
2367
|
+
options.onCommand?.({ executable, args: startArgs });
|
|
2368
|
+
const start = await run(executable, startArgs, { cwd: artifactDir, env: env2 });
|
|
2369
|
+
requireSuccess("Databricks App compute start", start);
|
|
2370
|
+
}
|
|
2371
|
+
const appArgs = [
|
|
2372
|
+
"apps",
|
|
2373
|
+
"deploy",
|
|
2374
|
+
...options.appName ? [options.appName] : [],
|
|
2375
|
+
...options.sourceCodePath ? ["--source-code-path", options.sourceCodePath] : [],
|
|
2376
|
+
...options.mode ? ["--mode", options.mode] : [],
|
|
2377
|
+
"--skip-validation",
|
|
2378
|
+
"--auto-approve",
|
|
2379
|
+
...profileArgs
|
|
2380
|
+
];
|
|
2381
|
+
options.onCommand?.({ executable, args: appArgs });
|
|
2382
|
+
const app = await run(executable, appArgs, { cwd: artifactDir, env: env2 });
|
|
2383
|
+
requireSuccess("Databricks App snapshot activation", app);
|
|
2384
|
+
return {
|
|
2385
|
+
bundleSynchronized: true,
|
|
2386
|
+
appSnapshotActivated: true,
|
|
2387
|
+
bundleOutput: lastNonEmptyLine(bundle.stdout),
|
|
2388
|
+
appOutput: lastNonEmptyLine(app.stdout)
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
async function destroyDatabricksAppArtifact(options) {
|
|
2392
|
+
const artifactDir = path.resolve(options.artifactDir);
|
|
2393
|
+
await access(path.join(artifactDir, "databricks.yml"));
|
|
2394
|
+
const run = options.run ?? runDatabricksCommand;
|
|
2395
|
+
const args = [
|
|
2396
|
+
"bundle",
|
|
2397
|
+
"destroy",
|
|
2398
|
+
"--auto-approve",
|
|
2399
|
+
...options.target ? ["--target", options.target] : [],
|
|
2400
|
+
...options.profile ? ["--profile", options.profile] : []
|
|
2401
|
+
];
|
|
2402
|
+
const executable = options.executable ?? "databricks";
|
|
2403
|
+
options.onCommand?.({ executable, args });
|
|
2404
|
+
const result = await run(executable, args, {
|
|
2405
|
+
cwd: artifactDir,
|
|
2406
|
+
env: options.env ?? process.env
|
|
2407
|
+
});
|
|
2408
|
+
requireSuccess("Databricks bundle teardown", result);
|
|
2409
|
+
return { destroyed: true, output: lastNonEmptyLine(result.stdout) };
|
|
2410
|
+
}
|
|
2411
|
+
async function runDatabricksCommand(command, args, options) {
|
|
2412
|
+
return new Promise((resolve2, reject) => {
|
|
2413
|
+
const child = spawn(command, [...args], {
|
|
2414
|
+
cwd: options.cwd,
|
|
2415
|
+
env: options.env,
|
|
2416
|
+
shell: false,
|
|
2417
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2418
|
+
});
|
|
2419
|
+
let stdout = "";
|
|
2420
|
+
let stderr = "";
|
|
2421
|
+
child.stdout.on("data", (chunk) => {
|
|
2422
|
+
stdout += chunk.toString();
|
|
2423
|
+
});
|
|
2424
|
+
child.stderr.on("data", (chunk) => {
|
|
2425
|
+
stderr += chunk.toString();
|
|
2426
|
+
});
|
|
2427
|
+
child.once("error", reject);
|
|
2428
|
+
child.once("close", (code) => resolve2({ exitCode: code ?? -1, stdout, stderr }));
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
function requireSuccess(label, result) {
|
|
2432
|
+
if (result.exitCode === 0) return;
|
|
2433
|
+
const detail = result.stderr.trim().slice(-2e3);
|
|
2434
|
+
throw new Error(
|
|
2435
|
+
`${label} failed with exit code ${result.exitCode}${detail ? `: ${detail}` : ""}`
|
|
2436
|
+
);
|
|
2437
|
+
}
|
|
2438
|
+
function lastNonEmptyLine(value) {
|
|
2439
|
+
return value.split("\n").map((line) => line.trim()).filter(Boolean).at(-1) ?? "";
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
// src/managed-resource.ts
|
|
2443
|
+
var DatabricksManagedResourceConflictError = class extends Error {
|
|
2444
|
+
resourceType;
|
|
2445
|
+
resourceId;
|
|
2446
|
+
expectedFingerprint;
|
|
2447
|
+
actualFingerprint;
|
|
2448
|
+
constructor(input) {
|
|
2449
|
+
super(
|
|
2450
|
+
`Databricks managed ${input.resourceType} ${input.resourceId} changed: expected fingerprint ${input.expectedFingerprint}, found ${input.actualFingerprint}.`
|
|
2451
|
+
);
|
|
2452
|
+
this.name = "DatabricksManagedResourceConflictError";
|
|
2453
|
+
this.resourceType = input.resourceType;
|
|
2454
|
+
this.resourceId = input.resourceId;
|
|
2455
|
+
this.expectedFingerprint = input.expectedFingerprint;
|
|
2456
|
+
this.actualFingerprint = input.actualFingerprint;
|
|
2457
|
+
}
|
|
2458
|
+
};
|
|
2459
|
+
var DatabricksUnmanagedResourceError = class extends Error {
|
|
2460
|
+
resourceType;
|
|
2461
|
+
resourceId;
|
|
2462
|
+
constructor(resourceType, resourceId) {
|
|
2463
|
+
super(
|
|
2464
|
+
`Databricks ${resourceType} ${resourceId} is not recorded as Harness-managed; model-facing mutation is denied.`
|
|
2465
|
+
);
|
|
2466
|
+
this.name = "DatabricksUnmanagedResourceError";
|
|
2467
|
+
this.resourceType = resourceType;
|
|
2468
|
+
this.resourceId = resourceId;
|
|
2469
|
+
}
|
|
2470
|
+
};
|
|
2471
|
+
var MemoryDatabricksManagedResourceStore = class {
|
|
2472
|
+
records = /* @__PURE__ */ new Map();
|
|
2473
|
+
async get(resourceType, resourceId) {
|
|
2474
|
+
const record2 = this.records.get(resourceKey(resourceType, resourceId));
|
|
2475
|
+
return record2 ? structuredClone(record2) : void 0;
|
|
2476
|
+
}
|
|
2477
|
+
async put(record2) {
|
|
2478
|
+
validateRecord(record2);
|
|
2479
|
+
this.records.set(resourceKey(record2.resourceType, record2.resourceId), structuredClone(record2));
|
|
2480
|
+
}
|
|
2481
|
+
async delete(resourceType, resourceId) {
|
|
2482
|
+
this.records.delete(resourceKey(resourceType, resourceId));
|
|
2483
|
+
}
|
|
2484
|
+
async list(resourceType) {
|
|
2485
|
+
return [...this.records.values()].filter((record2) => resourceType === void 0 || record2.resourceType === resourceType).sort(
|
|
2486
|
+
(left, right) => resourceKey(left.resourceType, left.resourceId).localeCompare(
|
|
2487
|
+
resourceKey(right.resourceType, right.resourceId)
|
|
2488
|
+
)
|
|
2489
|
+
).map((record2) => structuredClone(record2));
|
|
2490
|
+
}
|
|
2491
|
+
};
|
|
2492
|
+
var LakebaseDatabricksManagedResourceStore = class {
|
|
2493
|
+
constructor(options) {
|
|
2494
|
+
this.options = options;
|
|
2495
|
+
this.table = sqlIdentifier(options.table ?? "fabric_harness_managed_resources");
|
|
2496
|
+
}
|
|
2497
|
+
table;
|
|
2498
|
+
initialized;
|
|
2499
|
+
async get(resourceType, resourceId) {
|
|
2500
|
+
await this.ensureTable();
|
|
2501
|
+
const result = await this.options.client.query(
|
|
2502
|
+
`SELECT resource_type, resource_id, fingerprint, created_by, tool_call_id, created_at, updated_at, metadata
|
|
2503
|
+
FROM ${this.table}
|
|
2504
|
+
WHERE resource_type = $1 AND resource_id = $2`,
|
|
2505
|
+
[resourceType, resourceId]
|
|
2506
|
+
);
|
|
2507
|
+
return result.rows[0] ? rowToRecord(result.rows[0]) : void 0;
|
|
2508
|
+
}
|
|
2509
|
+
async put(record2) {
|
|
2510
|
+
validateRecord(record2);
|
|
2511
|
+
await this.ensureTable();
|
|
2512
|
+
await this.options.client.query(
|
|
2513
|
+
`INSERT INTO ${this.table}
|
|
2514
|
+
(resource_type, resource_id, fingerprint, created_by, tool_call_id, created_at, updated_at, metadata)
|
|
2515
|
+
VALUES ($1, $2, $3, $4, $5, $6::timestamptz, $7::timestamptz, $8::jsonb)
|
|
2516
|
+
ON CONFLICT (resource_type, resource_id) DO UPDATE SET
|
|
2517
|
+
fingerprint = EXCLUDED.fingerprint,
|
|
2518
|
+
tool_call_id = EXCLUDED.tool_call_id,
|
|
2519
|
+
updated_at = EXCLUDED.updated_at,
|
|
2520
|
+
metadata = EXCLUDED.metadata`,
|
|
2521
|
+
[
|
|
2522
|
+
record2.resourceType,
|
|
2523
|
+
record2.resourceId,
|
|
2524
|
+
record2.fingerprint,
|
|
2525
|
+
record2.createdBy,
|
|
2526
|
+
record2.toolCallId,
|
|
2527
|
+
record2.createdAt,
|
|
2528
|
+
record2.updatedAt,
|
|
2529
|
+
JSON.stringify(record2.metadata ?? {})
|
|
2530
|
+
]
|
|
2531
|
+
);
|
|
2532
|
+
}
|
|
2533
|
+
async delete(resourceType, resourceId) {
|
|
2534
|
+
await this.ensureTable();
|
|
2535
|
+
await this.options.client.query(
|
|
2536
|
+
`DELETE FROM ${this.table} WHERE resource_type = $1 AND resource_id = $2`,
|
|
2537
|
+
[resourceType, resourceId]
|
|
2538
|
+
);
|
|
2539
|
+
}
|
|
2540
|
+
async list(resourceType) {
|
|
2541
|
+
await this.ensureTable();
|
|
2542
|
+
const result = await this.options.client.query(
|
|
2543
|
+
`SELECT resource_type, resource_id, fingerprint, created_by, tool_call_id, created_at, updated_at, metadata
|
|
2544
|
+
FROM ${this.table}
|
|
2545
|
+
${resourceType === void 0 ? "" : "WHERE resource_type = $1"}
|
|
2546
|
+
ORDER BY resource_type, resource_id`,
|
|
2547
|
+
resourceType === void 0 ? [] : [resourceType]
|
|
2548
|
+
);
|
|
2549
|
+
return result.rows.map(rowToRecord);
|
|
2550
|
+
}
|
|
2551
|
+
ensureTable() {
|
|
2552
|
+
this.initialized ??= this.options.client.query(
|
|
2553
|
+
`CREATE TABLE IF NOT EXISTS ${this.table} (
|
|
2554
|
+
resource_type text NOT NULL,
|
|
2555
|
+
resource_id text NOT NULL,
|
|
2556
|
+
fingerprint text NOT NULL,
|
|
2557
|
+
created_by text NOT NULL,
|
|
2558
|
+
tool_call_id text NOT NULL,
|
|
2559
|
+
created_at timestamptz NOT NULL,
|
|
2560
|
+
updated_at timestamptz NOT NULL,
|
|
2561
|
+
metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
2562
|
+
PRIMARY KEY (resource_type, resource_id)
|
|
2563
|
+
)`
|
|
2564
|
+
).then(() => void 0).catch((error51) => {
|
|
2565
|
+
this.initialized = void 0;
|
|
2566
|
+
throw error51;
|
|
2567
|
+
});
|
|
2568
|
+
return this.initialized;
|
|
2569
|
+
}
|
|
2570
|
+
};
|
|
2571
|
+
async function databricksResourceFingerprint(value) {
|
|
2572
|
+
const digest = await crypto.subtle.digest(
|
|
2573
|
+
"SHA-256",
|
|
2574
|
+
new TextEncoder().encode(canonicalJson(value))
|
|
2575
|
+
);
|
|
2576
|
+
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
2577
|
+
}
|
|
2578
|
+
async function requireDatabricksManagedResource(input) {
|
|
2579
|
+
const record2 = await input.store.get(input.resourceType, input.resourceId);
|
|
2580
|
+
if (!record2) throw new DatabricksUnmanagedResourceError(input.resourceType, input.resourceId);
|
|
2581
|
+
if (input.expectedFingerprint && record2.fingerprint !== input.expectedFingerprint) {
|
|
2582
|
+
throw new DatabricksManagedResourceConflictError({
|
|
2583
|
+
resourceType: input.resourceType,
|
|
2584
|
+
resourceId: input.resourceId,
|
|
2585
|
+
expectedFingerprint: input.expectedFingerprint,
|
|
2586
|
+
actualFingerprint: record2.fingerprint
|
|
2587
|
+
});
|
|
2588
|
+
}
|
|
2589
|
+
return record2;
|
|
2590
|
+
}
|
|
2591
|
+
function validateRecord(record2) {
|
|
2592
|
+
for (const [name, value] of Object.entries({
|
|
2593
|
+
resourceType: record2.resourceType,
|
|
2594
|
+
resourceId: record2.resourceId,
|
|
2595
|
+
fingerprint: record2.fingerprint,
|
|
2596
|
+
createdBy: record2.createdBy,
|
|
2597
|
+
toolCallId: record2.toolCallId,
|
|
2598
|
+
createdAt: record2.createdAt,
|
|
2599
|
+
updatedAt: record2.updatedAt
|
|
2600
|
+
})) {
|
|
2601
|
+
if (!value.trim()) throw new Error(`Databricks managed-resource ${name} cannot be empty.`);
|
|
2602
|
+
}
|
|
2603
|
+
if (!/^\d{4}-\d{2}-\d{2}T/.test(record2.createdAt) || !/^\d{4}-\d{2}-\d{2}T/.test(record2.updatedAt)) {
|
|
2604
|
+
throw new Error("Databricks managed-resource timestamps must be ISO-8601 strings.");
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
function resourceKey(resourceType, resourceId) {
|
|
2608
|
+
return `${resourceType.trim()}\0${resourceId.trim()}`;
|
|
2609
|
+
}
|
|
2610
|
+
function rowToRecord(row) {
|
|
2611
|
+
return {
|
|
2612
|
+
resourceType: row.resource_type,
|
|
2613
|
+
resourceId: row.resource_id,
|
|
2614
|
+
fingerprint: row.fingerprint,
|
|
2615
|
+
createdBy: row.created_by,
|
|
2616
|
+
toolCallId: row.tool_call_id,
|
|
2617
|
+
createdAt: timestamp(row.created_at),
|
|
2618
|
+
updatedAt: timestamp(row.updated_at),
|
|
2619
|
+
...optionalMetadata(row.metadata)
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
function timestamp(value) {
|
|
2623
|
+
return value instanceof Date ? value.toISOString() : new Date(value).toISOString();
|
|
2624
|
+
}
|
|
2625
|
+
function optionalMetadata(value) {
|
|
2626
|
+
if (typeof value === "string") {
|
|
2627
|
+
const parsed = JSON.parse(value);
|
|
2628
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? { metadata: parsed } : {};
|
|
2629
|
+
}
|
|
2630
|
+
return value ? { metadata: value } : {};
|
|
2631
|
+
}
|
|
2632
|
+
function sqlIdentifier(value) {
|
|
2633
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value))
|
|
2634
|
+
throw new Error("Databricks managed-resource table must be one unqualified SQL identifier.");
|
|
2635
|
+
return `"${value}"`;
|
|
2636
|
+
}
|
|
2637
|
+
function canonicalJson(value) {
|
|
2638
|
+
if (value === null || typeof value !== "object") {
|
|
2639
|
+
const encoded = JSON.stringify(value);
|
|
2640
|
+
return encoded === void 0 ? "null" : encoded;
|
|
2641
|
+
}
|
|
2642
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
2643
|
+
return `{${Object.entries(value).filter(([, child]) => child !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`).join(",")}}`;
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
// src/asset-bundles.ts
|
|
2647
|
+
var BUNDLE_RESOURCE_TYPE = "databricks-bundle";
|
|
2648
|
+
var FINGERPRINT_EXCLUDED_DIRS = /* @__PURE__ */ new Set([".databricks", "node_modules", "dist"]);
|
|
2649
|
+
var DatabricksAssetBundleLifecycle = class {
|
|
2650
|
+
/** Resolved bundle directory; also the governed resource identity on the tools. */
|
|
2651
|
+
bundleDir;
|
|
2652
|
+
target;
|
|
2653
|
+
profile;
|
|
2654
|
+
executable;
|
|
2655
|
+
env;
|
|
2656
|
+
commandRunner;
|
|
2657
|
+
store;
|
|
2658
|
+
principalLabel;
|
|
2659
|
+
bundleName;
|
|
2660
|
+
constructor(options) {
|
|
2661
|
+
if (!options.bundleDir?.trim())
|
|
2662
|
+
throw new Error("databricks asset bundles: bundleDir is required.");
|
|
2663
|
+
this.bundleDir = path2.resolve(options.bundleDir);
|
|
2664
|
+
this.executable = options.executable ?? "databricks";
|
|
2665
|
+
this.env = options.env ?? process.env;
|
|
2666
|
+
this.commandRunner = options.run ?? runDatabricksCommand;
|
|
2667
|
+
this.store = options.store ?? new MemoryDatabricksManagedResourceStore();
|
|
2668
|
+
this.principalLabel = options.principalLabel ?? "unknown";
|
|
2669
|
+
if (options.target !== void 0) this.target = options.target;
|
|
2670
|
+
if (options.profile !== void 0) this.profile = options.profile;
|
|
2671
|
+
}
|
|
2672
|
+
/** Run `databricks bundle validate` without mutating the workspace. */
|
|
2673
|
+
async validate() {
|
|
2674
|
+
await this.requireManifest();
|
|
2675
|
+
const args = ["bundle", "validate", ...this.targetArgs(), ...this.profileArgs()];
|
|
2676
|
+
const result = await this.commandRunner(this.executable, args, {
|
|
2677
|
+
cwd: this.bundleDir,
|
|
2678
|
+
env: this.env
|
|
2679
|
+
});
|
|
2680
|
+
requireSuccess2("Databricks bundle validation", result);
|
|
2681
|
+
return { valid: true, output: lastNonEmptyLine2(result.stdout) };
|
|
2682
|
+
}
|
|
2683
|
+
/** Deterministic sha256 over the sorted bundle source tree (path + content). */
|
|
2684
|
+
async fingerprint() {
|
|
2685
|
+
await this.requireManifest();
|
|
2686
|
+
const files = (await collectSourceFiles(this.bundleDir)).sort();
|
|
2687
|
+
const entries = [];
|
|
2688
|
+
for (const file2 of files) {
|
|
2689
|
+
const content = await readFile(file2);
|
|
2690
|
+
const digest = await crypto.subtle.digest("SHA-256", content);
|
|
2691
|
+
entries.push({
|
|
2692
|
+
path: path2.relative(this.bundleDir, file2).split(path2.sep).join("/"),
|
|
2693
|
+
sha256: [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("")
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
return databricksResourceFingerprint(entries);
|
|
2697
|
+
}
|
|
2698
|
+
/** Validate, deploy, and record the source fingerprint in the managed-resource store. */
|
|
2699
|
+
async deploy(options = {}) {
|
|
2700
|
+
await this.requireManifest();
|
|
2701
|
+
const fingerprint = await this.fingerprint();
|
|
2702
|
+
const resourceId = await this.resourceId();
|
|
2703
|
+
const existing = await this.store.get(BUNDLE_RESOURCE_TYPE, resourceId);
|
|
2704
|
+
if (existing && options.expectedFingerprint !== void 0 && existing.fingerprint !== options.expectedFingerprint) {
|
|
2705
|
+
throw new DatabricksManagedResourceConflictError({
|
|
2706
|
+
resourceType: BUNDLE_RESOURCE_TYPE,
|
|
2707
|
+
resourceId,
|
|
2708
|
+
expectedFingerprint: options.expectedFingerprint,
|
|
2709
|
+
actualFingerprint: existing.fingerprint
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
await this.validate();
|
|
2713
|
+
const args = ["bundle", "deploy", ...this.targetArgs(), ...this.profileArgs()];
|
|
2714
|
+
const result = await this.commandRunner(this.executable, args, {
|
|
2715
|
+
cwd: this.bundleDir,
|
|
2716
|
+
env: this.env
|
|
2717
|
+
});
|
|
2718
|
+
requireSuccess2("Databricks bundle deployment", result);
|
|
2719
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2720
|
+
await this.store.put({
|
|
2721
|
+
resourceType: BUNDLE_RESOURCE_TYPE,
|
|
2722
|
+
resourceId,
|
|
2723
|
+
fingerprint,
|
|
2724
|
+
createdBy: existing?.createdBy ?? this.principalLabel,
|
|
2725
|
+
toolCallId: "databricks_bundle_deploy",
|
|
2726
|
+
createdAt: existing?.createdAt ?? now,
|
|
2727
|
+
updatedAt: now
|
|
2728
|
+
});
|
|
2729
|
+
return { deployed: true, fingerprint, output: lastNonEmptyLine2(result.stdout) };
|
|
2730
|
+
}
|
|
2731
|
+
/**
|
|
2732
|
+
* Submit a run of a bundle-defined job/pipeline by its `databricks.yml` resource key.
|
|
2733
|
+
* Always passes `--no-wait` — waiting inside a tool call would violate finite-agent
|
|
2734
|
+
* boundedness, so run status must be polled through the bounded jobs/lakeflow status
|
|
2735
|
+
* tools. No managed-resource record is required: bundles deployed outside Harness
|
|
2736
|
+
* (e.g. by CI) stay runnable, and the CLI fails cleanly against an undeployed bundle.
|
|
2737
|
+
*/
|
|
2738
|
+
async run(options) {
|
|
2739
|
+
await this.requireManifest();
|
|
2740
|
+
const key = options.key?.trim();
|
|
2741
|
+
if (!key) throw new Error("databricks asset bundles: run requires a non-empty resource key.");
|
|
2742
|
+
const args = [
|
|
2743
|
+
"bundle",
|
|
2744
|
+
"run",
|
|
2745
|
+
key,
|
|
2746
|
+
"--no-wait",
|
|
2747
|
+
...options.restart === true ? ["--restart"] : [],
|
|
2748
|
+
...this.targetArgs(),
|
|
2749
|
+
...this.profileArgs()
|
|
2750
|
+
];
|
|
2751
|
+
const result = await this.commandRunner(this.executable, args, {
|
|
2752
|
+
cwd: this.bundleDir,
|
|
2753
|
+
env: this.env
|
|
2754
|
+
});
|
|
2755
|
+
requireSuccess2("Databricks bundle run submission", result);
|
|
2756
|
+
return { submitted: true, output: lastNonEmptyLine2(result.stdout) };
|
|
2757
|
+
}
|
|
2758
|
+
/** Destroy a Harness-recorded bundle deployment and delete its managed record. */
|
|
2759
|
+
async destroy(options = {}) {
|
|
2760
|
+
await this.requireManifest();
|
|
2761
|
+
const resourceId = await this.resourceId();
|
|
2762
|
+
const record2 = await requireDatabricksManagedResource({
|
|
2763
|
+
store: this.store,
|
|
2764
|
+
resourceType: BUNDLE_RESOURCE_TYPE,
|
|
2765
|
+
resourceId
|
|
2766
|
+
});
|
|
2767
|
+
if (!options.force) {
|
|
2768
|
+
const current = await this.fingerprint();
|
|
2769
|
+
if (current !== record2.fingerprint)
|
|
2770
|
+
throw new DatabricksManagedResourceConflictError({
|
|
2771
|
+
resourceType: BUNDLE_RESOURCE_TYPE,
|
|
2772
|
+
resourceId,
|
|
2773
|
+
expectedFingerprint: record2.fingerprint,
|
|
2774
|
+
actualFingerprint: current
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
const args = [
|
|
2778
|
+
"bundle",
|
|
2779
|
+
"destroy",
|
|
2780
|
+
"--auto-approve",
|
|
2781
|
+
...this.targetArgs(),
|
|
2782
|
+
...this.profileArgs()
|
|
2783
|
+
];
|
|
2784
|
+
const result = await this.commandRunner(this.executable, args, {
|
|
2785
|
+
cwd: this.bundleDir,
|
|
2786
|
+
env: this.env
|
|
2787
|
+
});
|
|
2788
|
+
requireSuccess2("Databricks bundle teardown", result);
|
|
2789
|
+
await this.store.delete(BUNDLE_RESOURCE_TYPE, resourceId);
|
|
2790
|
+
return { destroyed: true, output: lastNonEmptyLine2(result.stdout) };
|
|
2791
|
+
}
|
|
2792
|
+
/** Bundle `name:` parsed from `databricks.yml`, falling back to the directory basename. */
|
|
2793
|
+
async resourceId() {
|
|
2794
|
+
if (this.bundleName === void 0) {
|
|
2795
|
+
const manifest = await readFile(path2.join(this.bundleDir, "databricks.yml"), "utf8");
|
|
2796
|
+
const match = /^\s*name:\s*["']?([^\s"']+)["']?\s*$/m.exec(manifest);
|
|
2797
|
+
this.bundleName = match?.[1] ?? path2.basename(this.bundleDir);
|
|
2798
|
+
}
|
|
2799
|
+
return this.bundleName;
|
|
2800
|
+
}
|
|
2801
|
+
async requireManifest() {
|
|
2802
|
+
const manifest = path2.join(this.bundleDir, "databricks.yml");
|
|
2803
|
+
try {
|
|
2804
|
+
await access2(manifest);
|
|
2805
|
+
} catch {
|
|
2806
|
+
throw new Error(`databricks asset bundles: databricks.yml not found at ${manifest}.`);
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
targetArgs() {
|
|
2810
|
+
return this.target ? ["--target", this.target] : [];
|
|
2811
|
+
}
|
|
2812
|
+
profileArgs() {
|
|
2813
|
+
return this.profile ? ["--profile", this.profile] : [];
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
function databricksAssetBundleLifecycle(options) {
|
|
2817
|
+
return new DatabricksAssetBundleLifecycle(options);
|
|
2818
|
+
}
|
|
2819
|
+
function databricksAssetBundleTools(options) {
|
|
2820
|
+
const lifecycle = options instanceof DatabricksAssetBundleLifecycle ? options : new DatabricksAssetBundleLifecycle(options);
|
|
2821
|
+
const resources = [{ kind: "bundle", value: lifecycle.bundleDir }];
|
|
2822
|
+
return [
|
|
2823
|
+
bundleTool(
|
|
2824
|
+
"databricks_bundle_validate",
|
|
2825
|
+
"Validate the checked-in Databricks Asset Bundle without deploying it.",
|
|
2826
|
+
"read",
|
|
2827
|
+
{ type: "object", additionalProperties: false, properties: {} },
|
|
2828
|
+
[],
|
|
2829
|
+
() => lifecycle.validate()
|
|
2830
|
+
),
|
|
2831
|
+
bundleTool(
|
|
2832
|
+
"databricks_bundle_deploy",
|
|
2833
|
+
"Validate and deploy the checked-in Databricks Asset Bundle, recording its source fingerprint.",
|
|
2834
|
+
"write",
|
|
2835
|
+
{
|
|
2836
|
+
type: "object",
|
|
2837
|
+
additionalProperties: false,
|
|
2838
|
+
properties: { expectedFingerprint: { type: "string" } }
|
|
2839
|
+
},
|
|
2840
|
+
resources,
|
|
2841
|
+
(input) => {
|
|
2842
|
+
const expectedFingerprint = input.expectedFingerprint;
|
|
2843
|
+
return lifecycle.deploy(expectedFingerprint !== void 0 ? { expectedFingerprint } : {});
|
|
2844
|
+
}
|
|
2845
|
+
),
|
|
2846
|
+
bundleTool(
|
|
2847
|
+
"databricks_bundle_run",
|
|
2848
|
+
"Submit (without waiting) a run of a bundle-defined job or pipeline by its databricks.yml resource key.",
|
|
2849
|
+
"execute",
|
|
2850
|
+
{
|
|
2851
|
+
type: "object",
|
|
2852
|
+
additionalProperties: false,
|
|
2853
|
+
properties: { key: { type: "string" }, restart: { type: "boolean" } },
|
|
2854
|
+
required: ["key"]
|
|
2855
|
+
},
|
|
2856
|
+
resources,
|
|
2857
|
+
(input) => lifecycle.run({
|
|
2858
|
+
key: input.key,
|
|
2859
|
+
restart: input.restart === true
|
|
2860
|
+
})
|
|
2861
|
+
),
|
|
2862
|
+
bundleTool(
|
|
2863
|
+
"databricks_bundle_destroy",
|
|
2864
|
+
"Destroy a Harness-recorded Databricks Asset Bundle deployment.",
|
|
2865
|
+
"write",
|
|
2866
|
+
{
|
|
2867
|
+
type: "object",
|
|
2868
|
+
additionalProperties: false,
|
|
2869
|
+
properties: { force: { type: "boolean" } }
|
|
2870
|
+
},
|
|
2871
|
+
resources,
|
|
2872
|
+
(input) => lifecycle.destroy({ force: input.force === true })
|
|
2873
|
+
)
|
|
2874
|
+
];
|
|
2875
|
+
}
|
|
2876
|
+
function bundleTool(name, description, effect, inputSchema, resources, execute2) {
|
|
2877
|
+
return {
|
|
2878
|
+
name,
|
|
2879
|
+
description,
|
|
2880
|
+
inputSchema,
|
|
2881
|
+
metadata: {
|
|
2882
|
+
effect,
|
|
2883
|
+
provider: "databricks",
|
|
2884
|
+
service: "bundles",
|
|
2885
|
+
...resources.length ? { governance: { resources } } : {}
|
|
2886
|
+
},
|
|
2887
|
+
execute: execute2
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
async function collectSourceFiles(dir) {
|
|
2891
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
2892
|
+
const files = [];
|
|
2893
|
+
for (const entry of entries) {
|
|
2894
|
+
const full = path2.join(dir, entry.name);
|
|
2895
|
+
if (entry.isDirectory()) {
|
|
2896
|
+
if (!FINGERPRINT_EXCLUDED_DIRS.has(entry.name))
|
|
2897
|
+
files.push(...await collectSourceFiles(full));
|
|
2898
|
+
} else if (entry.isFile()) {
|
|
2899
|
+
files.push(full);
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
return files;
|
|
2903
|
+
}
|
|
2904
|
+
function requireSuccess2(label, result) {
|
|
2905
|
+
if (result.exitCode === 0) return;
|
|
2906
|
+
const detail = result.stderr.trim().slice(-2e3);
|
|
2907
|
+
throw new Error(
|
|
2908
|
+
`${label} failed with exit code ${result.exitCode}${detail ? `: ${detail}` : ""}`
|
|
2909
|
+
);
|
|
2910
|
+
}
|
|
2911
|
+
function lastNonEmptyLine2(value) {
|
|
2912
|
+
return value.split("\n").map((line) => line.trim()).filter(Boolean).at(-1) ?? "";
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2322
2915
|
// src/consumption.ts
|
|
2323
2916
|
var GROUP_COLUMNS = {
|
|
2324
2917
|
sku: { select: "u.sku_name AS sku, u.usage_unit AS unit", group: "u.sku_name, u.usage_unit" },
|
|
@@ -3146,210 +3739,6 @@ function optional(key, value) {
|
|
|
3146
3739
|
return value === void 0 ? {} : { [key]: value };
|
|
3147
3740
|
}
|
|
3148
3741
|
|
|
3149
|
-
// src/managed-resource.ts
|
|
3150
|
-
var DatabricksManagedResourceConflictError = class extends Error {
|
|
3151
|
-
resourceType;
|
|
3152
|
-
resourceId;
|
|
3153
|
-
expectedFingerprint;
|
|
3154
|
-
actualFingerprint;
|
|
3155
|
-
constructor(input) {
|
|
3156
|
-
super(
|
|
3157
|
-
`Databricks managed ${input.resourceType} ${input.resourceId} changed: expected fingerprint ${input.expectedFingerprint}, found ${input.actualFingerprint}.`
|
|
3158
|
-
);
|
|
3159
|
-
this.name = "DatabricksManagedResourceConflictError";
|
|
3160
|
-
this.resourceType = input.resourceType;
|
|
3161
|
-
this.resourceId = input.resourceId;
|
|
3162
|
-
this.expectedFingerprint = input.expectedFingerprint;
|
|
3163
|
-
this.actualFingerprint = input.actualFingerprint;
|
|
3164
|
-
}
|
|
3165
|
-
};
|
|
3166
|
-
var DatabricksUnmanagedResourceError = class extends Error {
|
|
3167
|
-
resourceType;
|
|
3168
|
-
resourceId;
|
|
3169
|
-
constructor(resourceType, resourceId) {
|
|
3170
|
-
super(
|
|
3171
|
-
`Databricks ${resourceType} ${resourceId} is not recorded as Harness-managed; model-facing mutation is denied.`
|
|
3172
|
-
);
|
|
3173
|
-
this.name = "DatabricksUnmanagedResourceError";
|
|
3174
|
-
this.resourceType = resourceType;
|
|
3175
|
-
this.resourceId = resourceId;
|
|
3176
|
-
}
|
|
3177
|
-
};
|
|
3178
|
-
var MemoryDatabricksManagedResourceStore = class {
|
|
3179
|
-
records = /* @__PURE__ */ new Map();
|
|
3180
|
-
async get(resourceType, resourceId) {
|
|
3181
|
-
const record2 = this.records.get(resourceKey(resourceType, resourceId));
|
|
3182
|
-
return record2 ? structuredClone(record2) : void 0;
|
|
3183
|
-
}
|
|
3184
|
-
async put(record2) {
|
|
3185
|
-
validateRecord(record2);
|
|
3186
|
-
this.records.set(resourceKey(record2.resourceType, record2.resourceId), structuredClone(record2));
|
|
3187
|
-
}
|
|
3188
|
-
async delete(resourceType, resourceId) {
|
|
3189
|
-
this.records.delete(resourceKey(resourceType, resourceId));
|
|
3190
|
-
}
|
|
3191
|
-
async list(resourceType) {
|
|
3192
|
-
return [...this.records.values()].filter((record2) => resourceType === void 0 || record2.resourceType === resourceType).sort(
|
|
3193
|
-
(left, right) => resourceKey(left.resourceType, left.resourceId).localeCompare(
|
|
3194
|
-
resourceKey(right.resourceType, right.resourceId)
|
|
3195
|
-
)
|
|
3196
|
-
).map((record2) => structuredClone(record2));
|
|
3197
|
-
}
|
|
3198
|
-
};
|
|
3199
|
-
var LakebaseDatabricksManagedResourceStore = class {
|
|
3200
|
-
constructor(options) {
|
|
3201
|
-
this.options = options;
|
|
3202
|
-
this.table = sqlIdentifier(options.table ?? "fabric_harness_managed_resources");
|
|
3203
|
-
}
|
|
3204
|
-
table;
|
|
3205
|
-
initialized;
|
|
3206
|
-
async get(resourceType, resourceId) {
|
|
3207
|
-
await this.ensureTable();
|
|
3208
|
-
const result = await this.options.client.query(
|
|
3209
|
-
`SELECT resource_type, resource_id, fingerprint, created_by, tool_call_id, created_at, updated_at, metadata
|
|
3210
|
-
FROM ${this.table}
|
|
3211
|
-
WHERE resource_type = $1 AND resource_id = $2`,
|
|
3212
|
-
[resourceType, resourceId]
|
|
3213
|
-
);
|
|
3214
|
-
return result.rows[0] ? rowToRecord(result.rows[0]) : void 0;
|
|
3215
|
-
}
|
|
3216
|
-
async put(record2) {
|
|
3217
|
-
validateRecord(record2);
|
|
3218
|
-
await this.ensureTable();
|
|
3219
|
-
await this.options.client.query(
|
|
3220
|
-
`INSERT INTO ${this.table}
|
|
3221
|
-
(resource_type, resource_id, fingerprint, created_by, tool_call_id, created_at, updated_at, metadata)
|
|
3222
|
-
VALUES ($1, $2, $3, $4, $5, $6::timestamptz, $7::timestamptz, $8::jsonb)
|
|
3223
|
-
ON CONFLICT (resource_type, resource_id) DO UPDATE SET
|
|
3224
|
-
fingerprint = EXCLUDED.fingerprint,
|
|
3225
|
-
tool_call_id = EXCLUDED.tool_call_id,
|
|
3226
|
-
updated_at = EXCLUDED.updated_at,
|
|
3227
|
-
metadata = EXCLUDED.metadata`,
|
|
3228
|
-
[
|
|
3229
|
-
record2.resourceType,
|
|
3230
|
-
record2.resourceId,
|
|
3231
|
-
record2.fingerprint,
|
|
3232
|
-
record2.createdBy,
|
|
3233
|
-
record2.toolCallId,
|
|
3234
|
-
record2.createdAt,
|
|
3235
|
-
record2.updatedAt,
|
|
3236
|
-
JSON.stringify(record2.metadata ?? {})
|
|
3237
|
-
]
|
|
3238
|
-
);
|
|
3239
|
-
}
|
|
3240
|
-
async delete(resourceType, resourceId) {
|
|
3241
|
-
await this.ensureTable();
|
|
3242
|
-
await this.options.client.query(
|
|
3243
|
-
`DELETE FROM ${this.table} WHERE resource_type = $1 AND resource_id = $2`,
|
|
3244
|
-
[resourceType, resourceId]
|
|
3245
|
-
);
|
|
3246
|
-
}
|
|
3247
|
-
async list(resourceType) {
|
|
3248
|
-
await this.ensureTable();
|
|
3249
|
-
const result = await this.options.client.query(
|
|
3250
|
-
`SELECT resource_type, resource_id, fingerprint, created_by, tool_call_id, created_at, updated_at, metadata
|
|
3251
|
-
FROM ${this.table}
|
|
3252
|
-
${resourceType === void 0 ? "" : "WHERE resource_type = $1"}
|
|
3253
|
-
ORDER BY resource_type, resource_id`,
|
|
3254
|
-
resourceType === void 0 ? [] : [resourceType]
|
|
3255
|
-
);
|
|
3256
|
-
return result.rows.map(rowToRecord);
|
|
3257
|
-
}
|
|
3258
|
-
ensureTable() {
|
|
3259
|
-
this.initialized ??= this.options.client.query(
|
|
3260
|
-
`CREATE TABLE IF NOT EXISTS ${this.table} (
|
|
3261
|
-
resource_type text NOT NULL,
|
|
3262
|
-
resource_id text NOT NULL,
|
|
3263
|
-
fingerprint text NOT NULL,
|
|
3264
|
-
created_by text NOT NULL,
|
|
3265
|
-
tool_call_id text NOT NULL,
|
|
3266
|
-
created_at timestamptz NOT NULL,
|
|
3267
|
-
updated_at timestamptz NOT NULL,
|
|
3268
|
-
metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
3269
|
-
PRIMARY KEY (resource_type, resource_id)
|
|
3270
|
-
)`
|
|
3271
|
-
).then(() => void 0).catch((error51) => {
|
|
3272
|
-
this.initialized = void 0;
|
|
3273
|
-
throw error51;
|
|
3274
|
-
});
|
|
3275
|
-
return this.initialized;
|
|
3276
|
-
}
|
|
3277
|
-
};
|
|
3278
|
-
async function databricksResourceFingerprint(value) {
|
|
3279
|
-
const digest = await crypto.subtle.digest(
|
|
3280
|
-
"SHA-256",
|
|
3281
|
-
new TextEncoder().encode(canonicalJson(value))
|
|
3282
|
-
);
|
|
3283
|
-
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3284
|
-
}
|
|
3285
|
-
async function requireDatabricksManagedResource(input) {
|
|
3286
|
-
const record2 = await input.store.get(input.resourceType, input.resourceId);
|
|
3287
|
-
if (!record2) throw new DatabricksUnmanagedResourceError(input.resourceType, input.resourceId);
|
|
3288
|
-
if (input.expectedFingerprint && record2.fingerprint !== input.expectedFingerprint) {
|
|
3289
|
-
throw new DatabricksManagedResourceConflictError({
|
|
3290
|
-
resourceType: input.resourceType,
|
|
3291
|
-
resourceId: input.resourceId,
|
|
3292
|
-
expectedFingerprint: input.expectedFingerprint,
|
|
3293
|
-
actualFingerprint: record2.fingerprint
|
|
3294
|
-
});
|
|
3295
|
-
}
|
|
3296
|
-
return record2;
|
|
3297
|
-
}
|
|
3298
|
-
function validateRecord(record2) {
|
|
3299
|
-
for (const [name, value] of Object.entries({
|
|
3300
|
-
resourceType: record2.resourceType,
|
|
3301
|
-
resourceId: record2.resourceId,
|
|
3302
|
-
fingerprint: record2.fingerprint,
|
|
3303
|
-
createdBy: record2.createdBy,
|
|
3304
|
-
toolCallId: record2.toolCallId,
|
|
3305
|
-
createdAt: record2.createdAt,
|
|
3306
|
-
updatedAt: record2.updatedAt
|
|
3307
|
-
})) {
|
|
3308
|
-
if (!value.trim()) throw new Error(`Databricks managed-resource ${name} cannot be empty.`);
|
|
3309
|
-
}
|
|
3310
|
-
if (!/^\d{4}-\d{2}-\d{2}T/.test(record2.createdAt) || !/^\d{4}-\d{2}-\d{2}T/.test(record2.updatedAt)) {
|
|
3311
|
-
throw new Error("Databricks managed-resource timestamps must be ISO-8601 strings.");
|
|
3312
|
-
}
|
|
3313
|
-
}
|
|
3314
|
-
function resourceKey(resourceType, resourceId) {
|
|
3315
|
-
return `${resourceType.trim()}\0${resourceId.trim()}`;
|
|
3316
|
-
}
|
|
3317
|
-
function rowToRecord(row) {
|
|
3318
|
-
return {
|
|
3319
|
-
resourceType: row.resource_type,
|
|
3320
|
-
resourceId: row.resource_id,
|
|
3321
|
-
fingerprint: row.fingerprint,
|
|
3322
|
-
createdBy: row.created_by,
|
|
3323
|
-
toolCallId: row.tool_call_id,
|
|
3324
|
-
createdAt: timestamp(row.created_at),
|
|
3325
|
-
updatedAt: timestamp(row.updated_at),
|
|
3326
|
-
...optionalMetadata(row.metadata)
|
|
3327
|
-
};
|
|
3328
|
-
}
|
|
3329
|
-
function timestamp(value) {
|
|
3330
|
-
return value instanceof Date ? value.toISOString() : new Date(value).toISOString();
|
|
3331
|
-
}
|
|
3332
|
-
function optionalMetadata(value) {
|
|
3333
|
-
if (typeof value === "string") {
|
|
3334
|
-
const parsed = JSON.parse(value);
|
|
3335
|
-
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? { metadata: parsed } : {};
|
|
3336
|
-
}
|
|
3337
|
-
return value ? { metadata: value } : {};
|
|
3338
|
-
}
|
|
3339
|
-
function sqlIdentifier(value) {
|
|
3340
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value))
|
|
3341
|
-
throw new Error("Databricks managed-resource table must be one unqualified SQL identifier.");
|
|
3342
|
-
return `"${value}"`;
|
|
3343
|
-
}
|
|
3344
|
-
function canonicalJson(value) {
|
|
3345
|
-
if (value === null || typeof value !== "object") {
|
|
3346
|
-
const encoded = JSON.stringify(value);
|
|
3347
|
-
return encoded === void 0 ? "null" : encoded;
|
|
3348
|
-
}
|
|
3349
|
-
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
3350
|
-
return `{${Object.entries(value).filter(([, child]) => child !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`).join(",")}}`;
|
|
3351
|
-
}
|
|
3352
|
-
|
|
3353
3742
|
// src/genie-authoring.ts
|
|
3354
3743
|
var GENIE_RESOURCE_TYPE = "genie-agent";
|
|
3355
3744
|
var SERIALIZED_VERSION = 2;
|
|
@@ -5161,16 +5550,16 @@ function parseResourceDescriptor(value, toolName, index) {
|
|
|
5161
5550
|
`databricks governance: invalid resource descriptor ${index} on tool "${toolName}".`
|
|
5162
5551
|
);
|
|
5163
5552
|
const row = value;
|
|
5164
|
-
const
|
|
5553
|
+
const path4 = typeof row.path === "string" ? row.path : void 0;
|
|
5165
5554
|
const staticValue = typeof row.value === "string" ? row.value : void 0;
|
|
5166
|
-
if (typeof row.kind !== "string" || !row.kind ||
|
|
5555
|
+
if (typeof row.kind !== "string" || !row.kind || path4 === void 0 && staticValue === void 0 || path4 !== void 0 && staticValue !== void 0 || path4 !== void 0 && !path4.startsWith("/") || staticValue === "") {
|
|
5167
5556
|
throw new Error(
|
|
5168
5557
|
`databricks governance: descriptor ${index} on tool "${toolName}" requires kind and exactly one absolute path or static value.`
|
|
5169
5558
|
);
|
|
5170
5559
|
}
|
|
5171
5560
|
return {
|
|
5172
5561
|
kind: row.kind,
|
|
5173
|
-
...
|
|
5562
|
+
...path4 !== void 0 ? { path: path4 } : { value: staticValue },
|
|
5174
5563
|
...row.catalogQualified === true ? { catalogQualified: true } : {},
|
|
5175
5564
|
...row.optional === true ? { optional: true } : {}
|
|
5176
5565
|
};
|
|
@@ -5180,12 +5569,12 @@ function parseStringArray(value, label) {
|
|
|
5180
5569
|
throw new Error(`databricks governance: ${label} must be a string array.`);
|
|
5181
5570
|
return value;
|
|
5182
5571
|
}
|
|
5183
|
-
function pointerSegments(
|
|
5184
|
-
return
|
|
5572
|
+
function pointerSegments(path4) {
|
|
5573
|
+
return path4.slice(1).split("/").map((segment2) => segment2.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
5185
5574
|
}
|
|
5186
|
-
function pointerValues(input,
|
|
5575
|
+
function pointerValues(input, path4) {
|
|
5187
5576
|
let current = [input];
|
|
5188
|
-
for (const segment2 of pointerSegments(
|
|
5577
|
+
for (const segment2 of pointerSegments(path4)) {
|
|
5189
5578
|
current = current.flatMap((value) => {
|
|
5190
5579
|
if (segment2 === "*") return Array.isArray(value) ? value : [];
|
|
5191
5580
|
if (!value || typeof value !== "object" || Array.isArray(value)) return [];
|
|
@@ -5195,10 +5584,10 @@ function pointerValues(input, path3) {
|
|
|
5195
5584
|
return current;
|
|
5196
5585
|
}
|
|
5197
5586
|
function validateSchemaPath(toolName, schema, descriptor) {
|
|
5198
|
-
const
|
|
5199
|
-
if (
|
|
5587
|
+
const path4 = descriptor.path;
|
|
5588
|
+
if (path4 === void 0) return;
|
|
5200
5589
|
let current = [schema];
|
|
5201
|
-
for (const segment2 of pointerSegments(
|
|
5590
|
+
for (const segment2 of pointerSegments(path4)) {
|
|
5202
5591
|
const variants = current.flatMap(schemaVariants);
|
|
5203
5592
|
const next = [];
|
|
5204
5593
|
let missing = 0;
|
|
@@ -6194,10 +6583,10 @@ function mergeDefs(...defs) {
|
|
|
6194
6583
|
function cloneDef(schema) {
|
|
6195
6584
|
return mergeDefs(schema._zod.def);
|
|
6196
6585
|
}
|
|
6197
|
-
function getElementAtPath(obj,
|
|
6198
|
-
if (!
|
|
6586
|
+
function getElementAtPath(obj, path4) {
|
|
6587
|
+
if (!path4)
|
|
6199
6588
|
return obj;
|
|
6200
|
-
return
|
|
6589
|
+
return path4.reduce((acc, key) => acc?.[key], obj);
|
|
6201
6590
|
}
|
|
6202
6591
|
function promiseAllObject(promisesObj) {
|
|
6203
6592
|
const keys = Object.keys(promisesObj);
|
|
@@ -6606,11 +6995,11 @@ function explicitlyAborted(x2, startIndex = 0) {
|
|
|
6606
6995
|
}
|
|
6607
6996
|
return false;
|
|
6608
6997
|
}
|
|
6609
|
-
function prefixIssues(
|
|
6998
|
+
function prefixIssues(path4, issues) {
|
|
6610
6999
|
return issues.map((iss) => {
|
|
6611
7000
|
var _a3;
|
|
6612
7001
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
6613
|
-
iss.path.unshift(
|
|
7002
|
+
iss.path.unshift(path4);
|
|
6614
7003
|
return iss;
|
|
6615
7004
|
});
|
|
6616
7005
|
}
|
|
@@ -6757,16 +7146,16 @@ function flattenError(error51, mapper = (issue3) => issue3.message) {
|
|
|
6757
7146
|
}
|
|
6758
7147
|
function formatError(error51, mapper = (issue3) => issue3.message) {
|
|
6759
7148
|
const fieldErrors = { _errors: [] };
|
|
6760
|
-
const processError = (error52,
|
|
7149
|
+
const processError = (error52, path4 = []) => {
|
|
6761
7150
|
for (const issue3 of error52.issues) {
|
|
6762
7151
|
if (issue3.code === "invalid_union" && issue3.errors.length) {
|
|
6763
|
-
issue3.errors.map((issues) => processError({ issues }, [...
|
|
7152
|
+
issue3.errors.map((issues) => processError({ issues }, [...path4, ...issue3.path]));
|
|
6764
7153
|
} else if (issue3.code === "invalid_key") {
|
|
6765
|
-
processError({ issues: issue3.issues }, [...
|
|
7154
|
+
processError({ issues: issue3.issues }, [...path4, ...issue3.path]);
|
|
6766
7155
|
} else if (issue3.code === "invalid_element") {
|
|
6767
|
-
processError({ issues: issue3.issues }, [...
|
|
7156
|
+
processError({ issues: issue3.issues }, [...path4, ...issue3.path]);
|
|
6768
7157
|
} else {
|
|
6769
|
-
const fullpath = [...
|
|
7158
|
+
const fullpath = [...path4, ...issue3.path];
|
|
6770
7159
|
if (fullpath.length === 0) {
|
|
6771
7160
|
fieldErrors._errors.push(mapper(issue3));
|
|
6772
7161
|
} else {
|
|
@@ -6793,17 +7182,17 @@ function formatError(error51, mapper = (issue3) => issue3.message) {
|
|
|
6793
7182
|
}
|
|
6794
7183
|
function treeifyError(error51, mapper = (issue3) => issue3.message) {
|
|
6795
7184
|
const result = { errors: [] };
|
|
6796
|
-
const processError = (error52,
|
|
7185
|
+
const processError = (error52, path4 = []) => {
|
|
6797
7186
|
var _a3, _b;
|
|
6798
7187
|
for (const issue3 of error52.issues) {
|
|
6799
7188
|
if (issue3.code === "invalid_union" && issue3.errors.length) {
|
|
6800
|
-
issue3.errors.map((issues) => processError({ issues }, [...
|
|
7189
|
+
issue3.errors.map((issues) => processError({ issues }, [...path4, ...issue3.path]));
|
|
6801
7190
|
} else if (issue3.code === "invalid_key") {
|
|
6802
|
-
processError({ issues: issue3.issues }, [...
|
|
7191
|
+
processError({ issues: issue3.issues }, [...path4, ...issue3.path]);
|
|
6803
7192
|
} else if (issue3.code === "invalid_element") {
|
|
6804
|
-
processError({ issues: issue3.issues }, [...
|
|
7193
|
+
processError({ issues: issue3.issues }, [...path4, ...issue3.path]);
|
|
6805
7194
|
} else {
|
|
6806
|
-
const fullpath = [...
|
|
7195
|
+
const fullpath = [...path4, ...issue3.path];
|
|
6807
7196
|
if (fullpath.length === 0) {
|
|
6808
7197
|
result.errors.push(mapper(issue3));
|
|
6809
7198
|
continue;
|
|
@@ -6835,8 +7224,8 @@ function treeifyError(error51, mapper = (issue3) => issue3.message) {
|
|
|
6835
7224
|
}
|
|
6836
7225
|
function toDotPath(_path) {
|
|
6837
7226
|
const segs = [];
|
|
6838
|
-
const
|
|
6839
|
-
for (const seg of
|
|
7227
|
+
const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
7228
|
+
for (const seg of path4) {
|
|
6840
7229
|
if (typeof seg === "number")
|
|
6841
7230
|
segs.push(`[${seg}]`);
|
|
6842
7231
|
else if (typeof seg === "symbol")
|
|
@@ -19522,13 +19911,13 @@ function resolveRef(ref, ctx) {
|
|
|
19522
19911
|
if (!ref.startsWith("#")) {
|
|
19523
19912
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19524
19913
|
}
|
|
19525
|
-
const
|
|
19526
|
-
if (
|
|
19914
|
+
const path4 = ref.slice(1).split("/").filter(Boolean);
|
|
19915
|
+
if (path4.length === 0) {
|
|
19527
19916
|
return ctx.rootSchema;
|
|
19528
19917
|
}
|
|
19529
19918
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19530
|
-
if (
|
|
19531
|
-
const key =
|
|
19919
|
+
if (path4[0] === defsKey) {
|
|
19920
|
+
const key = path4[1];
|
|
19532
19921
|
if (!key || !ctx.defs[key]) {
|
|
19533
19922
|
throw new Error(`Reference not found: ${ref}`);
|
|
19534
19923
|
}
|
|
@@ -20225,10 +20614,10 @@ async function findInPath(name) {
|
|
|
20225
20614
|
}
|
|
20226
20615
|
throw legacyError ?? new U2mCredentialsError("CLI_NOT_FOUND", "databricks CLI not found");
|
|
20227
20616
|
}
|
|
20228
|
-
async function validateCliPath(
|
|
20617
|
+
async function validateCliPath(path4) {
|
|
20229
20618
|
let info;
|
|
20230
20619
|
try {
|
|
20231
|
-
info = await stat(
|
|
20620
|
+
info = await stat(path4);
|
|
20232
20621
|
} catch {
|
|
20233
20622
|
throw new U2mCredentialsError("CLI_NOT_FOUND", "databricks CLI not found");
|
|
20234
20623
|
}
|
|
@@ -20238,7 +20627,7 @@ async function validateCliPath(path3) {
|
|
|
20238
20627
|
if (info.size < DATABRICKS_CLI_MIN_SIZE) {
|
|
20239
20628
|
throw new U2mCredentialsError("LEGACY_CLI_DETECTED", "legacy databricks CLI detected; upgrade to >= 0.100.0");
|
|
20240
20629
|
}
|
|
20241
|
-
return
|
|
20630
|
+
return path4;
|
|
20242
20631
|
}
|
|
20243
20632
|
|
|
20244
20633
|
// ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/profiles/errors.js
|
|
@@ -20252,7 +20641,7 @@ var ProfileError = class extends Error {
|
|
|
20252
20641
|
};
|
|
20253
20642
|
|
|
20254
20643
|
// ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/profiles/resolve.js
|
|
20255
|
-
import { access, readFile } from "fs/promises";
|
|
20644
|
+
import { access as access3, readFile as readFile2 } from "fs/promises";
|
|
20256
20645
|
import { homedir } from "os";
|
|
20257
20646
|
import { join as join2 } from "path";
|
|
20258
20647
|
|
|
@@ -20432,9 +20821,9 @@ function defaultConfigFilePath() {
|
|
|
20432
20821
|
return "";
|
|
20433
20822
|
}
|
|
20434
20823
|
}
|
|
20435
|
-
async function fileExists(
|
|
20824
|
+
async function fileExists(path4) {
|
|
20436
20825
|
try {
|
|
20437
|
-
await
|
|
20826
|
+
await access3(path4);
|
|
20438
20827
|
return true;
|
|
20439
20828
|
} catch {
|
|
20440
20829
|
return false;
|
|
@@ -20442,25 +20831,25 @@ async function fileExists(path3) {
|
|
|
20442
20831
|
}
|
|
20443
20832
|
async function loadFile(filePath, profileName) {
|
|
20444
20833
|
let explicitFile = filePath !== void 0;
|
|
20445
|
-
let
|
|
20834
|
+
let path4;
|
|
20446
20835
|
if (filePath !== void 0) {
|
|
20447
|
-
|
|
20836
|
+
path4 = filePath;
|
|
20448
20837
|
} else {
|
|
20449
20838
|
const envPath = process.env.DATABRICKS_CONFIG_FILE ?? "";
|
|
20450
20839
|
if (envPath !== "") {
|
|
20451
|
-
|
|
20840
|
+
path4 = envPath;
|
|
20452
20841
|
explicitFile = true;
|
|
20453
20842
|
} else {
|
|
20454
|
-
|
|
20843
|
+
path4 = defaultConfigFilePath();
|
|
20455
20844
|
}
|
|
20456
20845
|
}
|
|
20457
|
-
if (!await fileExists(
|
|
20846
|
+
if (!await fileExists(path4)) {
|
|
20458
20847
|
if (explicitFile) {
|
|
20459
|
-
throw new ProfileError("CONFIG_FILE_NOT_FOUND", `config file not found: ${
|
|
20848
|
+
throw new ProfileError("CONFIG_FILE_NOT_FOUND", `config file not found: ${path4}`);
|
|
20460
20849
|
}
|
|
20461
20850
|
return {};
|
|
20462
20851
|
}
|
|
20463
|
-
const content = await
|
|
20852
|
+
const content = await readFile2(path4, "utf8");
|
|
20464
20853
|
const data = parseIni(content);
|
|
20465
20854
|
let resolved = profileName;
|
|
20466
20855
|
if (resolved === void 0) {
|
|
@@ -20486,7 +20875,7 @@ async function loadFile(filePath, profileName) {
|
|
|
20486
20875
|
const section = data.get(resolved);
|
|
20487
20876
|
if (section === void 0 || isPhantomDefault(resolved, section)) {
|
|
20488
20877
|
if (explicitProfile) {
|
|
20489
|
-
throw new ProfileError("PROFILE_NOT_FOUND", `profile not found: "${resolved}" in ${
|
|
20878
|
+
throw new ProfileError("PROFILE_NOT_FOUND", `profile not found: "${resolved}" in ${path4}`);
|
|
20490
20879
|
}
|
|
20491
20880
|
return {};
|
|
20492
20881
|
}
|
|
@@ -21767,151 +22156,6 @@ function databricksLakeflowTools(client) {
|
|
|
21767
22156
|
];
|
|
21768
22157
|
}
|
|
21769
22158
|
|
|
21770
|
-
// src/mlflow-tracing.ts
|
|
21771
|
-
import { createHash } from "crypto";
|
|
21772
|
-
import { eventToTelemetrySpan } from "@fabric-harness/sdk";
|
|
21773
|
-
function mlflowTraceExporter(options) {
|
|
21774
|
-
const onError = options.onError ?? ((context, error51) => {
|
|
21775
|
-
console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
|
|
21776
|
-
});
|
|
21777
|
-
const buffers = /* @__PURE__ */ new Map();
|
|
21778
|
-
return {
|
|
21779
|
-
sink: {
|
|
21780
|
-
record(event) {
|
|
21781
|
-
try {
|
|
21782
|
-
const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
|
|
21783
|
-
if (event.type === "submission_started") {
|
|
21784
|
-
buffers.set(key, {
|
|
21785
|
-
submissionId: event.submissionId,
|
|
21786
|
-
agent: event.agent,
|
|
21787
|
-
instanceId: event.instanceId,
|
|
21788
|
-
session: event.session,
|
|
21789
|
-
startedAtMs: event.at,
|
|
21790
|
-
attemptCount: event.attemptCount,
|
|
21791
|
-
...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
|
|
21792
|
-
spans: []
|
|
21793
|
-
});
|
|
21794
|
-
return;
|
|
21795
|
-
}
|
|
21796
|
-
if (event.type !== "submission_settled") return;
|
|
21797
|
-
const buffer = buffers.get(key);
|
|
21798
|
-
buffers.delete(key);
|
|
21799
|
-
const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
|
|
21800
|
-
const attemptCount = event.attemptCount ?? buffer?.attemptCount;
|
|
21801
|
-
const trace = buildMlflowTrace({
|
|
21802
|
-
submissionId: event.submissionId,
|
|
21803
|
-
agent: event.agent,
|
|
21804
|
-
instanceId: event.instanceId,
|
|
21805
|
-
session: event.session,
|
|
21806
|
-
experimentId: options.experimentId,
|
|
21807
|
-
startedAtMs,
|
|
21808
|
-
settledAtMs: event.at,
|
|
21809
|
-
state: event.outcome === "completed" ? "OK" : "ERROR",
|
|
21810
|
-
spans: buffer?.spans ?? [],
|
|
21811
|
-
...attemptCount !== void 0 ? { attemptCount } : {},
|
|
21812
|
-
...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
|
|
21813
|
-
...event.error !== void 0 ? { error: event.error } : {}
|
|
21814
|
-
});
|
|
21815
|
-
void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
|
|
21816
|
-
} catch (error51) {
|
|
21817
|
-
onError("telemetry event handling failed", error51);
|
|
21818
|
-
}
|
|
21819
|
-
}
|
|
21820
|
-
},
|
|
21821
|
-
onEvent(event) {
|
|
21822
|
-
try {
|
|
21823
|
-
if (!event.sessionId) return;
|
|
21824
|
-
const buffer = buffers.get(event.sessionId);
|
|
21825
|
-
if (!buffer) return;
|
|
21826
|
-
const span = eventToTelemetrySpan(event);
|
|
21827
|
-
if (span) buffer.spans.push(span);
|
|
21828
|
-
} catch (error51) {
|
|
21829
|
-
onError("event buffering failed", error51);
|
|
21830
|
-
}
|
|
21831
|
-
}
|
|
21832
|
-
};
|
|
21833
|
-
}
|
|
21834
|
-
function buildMlflowTrace(input) {
|
|
21835
|
-
const traceBytes = sha256(input.submissionId).subarray(0, 16);
|
|
21836
|
-
const traceIdBase64 = traceBytes.toString("base64");
|
|
21837
|
-
const rootSpanId = spanIdFor(input.submissionId, 0);
|
|
21838
|
-
const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
|
|
21839
|
-
const rootSpan = {
|
|
21840
|
-
trace_id: traceIdBase64,
|
|
21841
|
-
span_id: rootSpanId,
|
|
21842
|
-
name: `fabric.submission ${input.agent}`,
|
|
21843
|
-
start_time_unix_nano: toUnixNano(input.startedAtMs),
|
|
21844
|
-
end_time_unix_nano: toUnixNano(input.settledAtMs),
|
|
21845
|
-
attributes: toOtlpAttributes({
|
|
21846
|
-
"fabric.submission_id": input.submissionId,
|
|
21847
|
-
"fabric.agent": input.agent,
|
|
21848
|
-
"fabric.instance_id": input.instanceId,
|
|
21849
|
-
"fabric.session": input.session,
|
|
21850
|
-
...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
|
|
21851
|
-
...input.error !== void 0 ? { "fabric.error": input.error } : {}
|
|
21852
|
-
}),
|
|
21853
|
-
status: {
|
|
21854
|
-
code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
|
|
21855
|
-
...input.error !== void 0 ? { message: input.error } : {}
|
|
21856
|
-
}
|
|
21857
|
-
};
|
|
21858
|
-
const childSpans = input.spans.map(
|
|
21859
|
-
(span, index) => ({
|
|
21860
|
-
trace_id: traceIdBase64,
|
|
21861
|
-
span_id: spanIdFor(input.submissionId, index + 1),
|
|
21862
|
-
parent_span_id: rootSpanId,
|
|
21863
|
-
name: span.name,
|
|
21864
|
-
start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
|
|
21865
|
-
end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
|
|
21866
|
-
attributes: toOtlpAttributes(span.attributes),
|
|
21867
|
-
status: { code: "STATUS_CODE_OK" }
|
|
21868
|
-
})
|
|
21869
|
-
);
|
|
21870
|
-
return {
|
|
21871
|
-
trace: {
|
|
21872
|
-
trace_info: {
|
|
21873
|
-
trace_id: `tr-${traceBytes.toString("hex")}`,
|
|
21874
|
-
trace_location: {
|
|
21875
|
-
type: "MLFLOW_EXPERIMENT",
|
|
21876
|
-
mlflow_experiment: { experiment_id: input.experimentId }
|
|
21877
|
-
},
|
|
21878
|
-
request_time: new Date(input.startedAtMs).toISOString(),
|
|
21879
|
-
execution_duration: `${durationSeconds.toFixed(3)}s`,
|
|
21880
|
-
state: input.state,
|
|
21881
|
-
trace_metadata: {
|
|
21882
|
-
"fabric.submission_id": input.submissionId,
|
|
21883
|
-
"fabric.agent": input.agent,
|
|
21884
|
-
"fabric.instance_id": input.instanceId,
|
|
21885
|
-
"fabric.session": input.session,
|
|
21886
|
-
...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
|
|
21887
|
-
},
|
|
21888
|
-
tags: {
|
|
21889
|
-
"fabric.agent": input.agent,
|
|
21890
|
-
...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
|
|
21891
|
-
}
|
|
21892
|
-
},
|
|
21893
|
-
trace_data: { spans: [rootSpan, ...childSpans] }
|
|
21894
|
-
}
|
|
21895
|
-
};
|
|
21896
|
-
}
|
|
21897
|
-
function sha256(seed) {
|
|
21898
|
-
return createHash("sha256").update(seed).digest();
|
|
21899
|
-
}
|
|
21900
|
-
function spanIdFor(submissionId, index) {
|
|
21901
|
-
return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
|
|
21902
|
-
}
|
|
21903
|
-
function toUnixNano(epochMs) {
|
|
21904
|
-
return `${Math.round(epochMs)}000000`;
|
|
21905
|
-
}
|
|
21906
|
-
function toOtlpAttributes(attributes) {
|
|
21907
|
-
return Object.entries(attributes).map(([key, value]) => {
|
|
21908
|
-
if (typeof value === "number") {
|
|
21909
|
-
return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
|
|
21910
|
-
}
|
|
21911
|
-
return { key, value: { string_value: String(value) } };
|
|
21912
|
-
});
|
|
21913
|
-
}
|
|
21914
|
-
|
|
21915
22159
|
// src/mcp.ts
|
|
21916
22160
|
import {
|
|
21917
22161
|
connectMcpServer,
|
|
@@ -22095,6 +22339,151 @@ function redactedMcpError(error51, secrets) {
|
|
|
22095
22339
|
return redacted;
|
|
22096
22340
|
}
|
|
22097
22341
|
|
|
22342
|
+
// src/mlflow-tracing.ts
|
|
22343
|
+
import { createHash } from "crypto";
|
|
22344
|
+
import { eventToTelemetrySpan } from "@fabric-harness/sdk";
|
|
22345
|
+
function mlflowTraceExporter(options) {
|
|
22346
|
+
const onError = options.onError ?? ((context, error51) => {
|
|
22347
|
+
console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
|
|
22348
|
+
});
|
|
22349
|
+
const buffers = /* @__PURE__ */ new Map();
|
|
22350
|
+
return {
|
|
22351
|
+
sink: {
|
|
22352
|
+
record(event) {
|
|
22353
|
+
try {
|
|
22354
|
+
const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
|
|
22355
|
+
if (event.type === "submission_started") {
|
|
22356
|
+
buffers.set(key, {
|
|
22357
|
+
submissionId: event.submissionId,
|
|
22358
|
+
agent: event.agent,
|
|
22359
|
+
instanceId: event.instanceId,
|
|
22360
|
+
session: event.session,
|
|
22361
|
+
startedAtMs: event.at,
|
|
22362
|
+
attemptCount: event.attemptCount,
|
|
22363
|
+
...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
|
|
22364
|
+
spans: []
|
|
22365
|
+
});
|
|
22366
|
+
return;
|
|
22367
|
+
}
|
|
22368
|
+
if (event.type !== "submission_settled") return;
|
|
22369
|
+
const buffer = buffers.get(key);
|
|
22370
|
+
buffers.delete(key);
|
|
22371
|
+
const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
|
|
22372
|
+
const attemptCount = event.attemptCount ?? buffer?.attemptCount;
|
|
22373
|
+
const trace = buildMlflowTrace({
|
|
22374
|
+
submissionId: event.submissionId,
|
|
22375
|
+
agent: event.agent,
|
|
22376
|
+
instanceId: event.instanceId,
|
|
22377
|
+
session: event.session,
|
|
22378
|
+
experimentId: options.experimentId,
|
|
22379
|
+
startedAtMs,
|
|
22380
|
+
settledAtMs: event.at,
|
|
22381
|
+
state: event.outcome === "completed" ? "OK" : "ERROR",
|
|
22382
|
+
spans: buffer?.spans ?? [],
|
|
22383
|
+
...attemptCount !== void 0 ? { attemptCount } : {},
|
|
22384
|
+
...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
|
|
22385
|
+
...event.error !== void 0 ? { error: event.error } : {}
|
|
22386
|
+
});
|
|
22387
|
+
void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
|
|
22388
|
+
} catch (error51) {
|
|
22389
|
+
onError("telemetry event handling failed", error51);
|
|
22390
|
+
}
|
|
22391
|
+
}
|
|
22392
|
+
},
|
|
22393
|
+
onEvent(event) {
|
|
22394
|
+
try {
|
|
22395
|
+
if (!event.sessionId) return;
|
|
22396
|
+
const buffer = buffers.get(event.sessionId);
|
|
22397
|
+
if (!buffer) return;
|
|
22398
|
+
const span = eventToTelemetrySpan(event);
|
|
22399
|
+
if (span) buffer.spans.push(span);
|
|
22400
|
+
} catch (error51) {
|
|
22401
|
+
onError("event buffering failed", error51);
|
|
22402
|
+
}
|
|
22403
|
+
}
|
|
22404
|
+
};
|
|
22405
|
+
}
|
|
22406
|
+
function buildMlflowTrace(input) {
|
|
22407
|
+
const traceBytes = sha256(input.submissionId).subarray(0, 16);
|
|
22408
|
+
const traceIdBase64 = traceBytes.toString("base64");
|
|
22409
|
+
const rootSpanId = spanIdFor(input.submissionId, 0);
|
|
22410
|
+
const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
|
|
22411
|
+
const rootSpan = {
|
|
22412
|
+
trace_id: traceIdBase64,
|
|
22413
|
+
span_id: rootSpanId,
|
|
22414
|
+
name: `fabric.submission ${input.agent}`,
|
|
22415
|
+
start_time_unix_nano: toUnixNano(input.startedAtMs),
|
|
22416
|
+
end_time_unix_nano: toUnixNano(input.settledAtMs),
|
|
22417
|
+
attributes: toOtlpAttributes({
|
|
22418
|
+
"fabric.submission_id": input.submissionId,
|
|
22419
|
+
"fabric.agent": input.agent,
|
|
22420
|
+
"fabric.instance_id": input.instanceId,
|
|
22421
|
+
"fabric.session": input.session,
|
|
22422
|
+
...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
|
|
22423
|
+
...input.error !== void 0 ? { "fabric.error": input.error } : {}
|
|
22424
|
+
}),
|
|
22425
|
+
status: {
|
|
22426
|
+
code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
|
|
22427
|
+
...input.error !== void 0 ? { message: input.error } : {}
|
|
22428
|
+
}
|
|
22429
|
+
};
|
|
22430
|
+
const childSpans = input.spans.map(
|
|
22431
|
+
(span, index) => ({
|
|
22432
|
+
trace_id: traceIdBase64,
|
|
22433
|
+
span_id: spanIdFor(input.submissionId, index + 1),
|
|
22434
|
+
parent_span_id: rootSpanId,
|
|
22435
|
+
name: span.name,
|
|
22436
|
+
start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
|
|
22437
|
+
end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
|
|
22438
|
+
attributes: toOtlpAttributes(span.attributes),
|
|
22439
|
+
status: { code: "STATUS_CODE_OK" }
|
|
22440
|
+
})
|
|
22441
|
+
);
|
|
22442
|
+
return {
|
|
22443
|
+
trace: {
|
|
22444
|
+
trace_info: {
|
|
22445
|
+
trace_id: `tr-${traceBytes.toString("hex")}`,
|
|
22446
|
+
trace_location: {
|
|
22447
|
+
type: "MLFLOW_EXPERIMENT",
|
|
22448
|
+
mlflow_experiment: { experiment_id: input.experimentId }
|
|
22449
|
+
},
|
|
22450
|
+
request_time: new Date(input.startedAtMs).toISOString(),
|
|
22451
|
+
execution_duration: `${durationSeconds.toFixed(3)}s`,
|
|
22452
|
+
state: input.state,
|
|
22453
|
+
trace_metadata: {
|
|
22454
|
+
"fabric.submission_id": input.submissionId,
|
|
22455
|
+
"fabric.agent": input.agent,
|
|
22456
|
+
"fabric.instance_id": input.instanceId,
|
|
22457
|
+
"fabric.session": input.session,
|
|
22458
|
+
...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
|
|
22459
|
+
},
|
|
22460
|
+
tags: {
|
|
22461
|
+
"fabric.agent": input.agent,
|
|
22462
|
+
...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
|
|
22463
|
+
}
|
|
22464
|
+
},
|
|
22465
|
+
trace_data: { spans: [rootSpan, ...childSpans] }
|
|
22466
|
+
}
|
|
22467
|
+
};
|
|
22468
|
+
}
|
|
22469
|
+
function sha256(seed) {
|
|
22470
|
+
return createHash("sha256").update(seed).digest();
|
|
22471
|
+
}
|
|
22472
|
+
function spanIdFor(submissionId, index) {
|
|
22473
|
+
return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
|
|
22474
|
+
}
|
|
22475
|
+
function toUnixNano(epochMs) {
|
|
22476
|
+
return `${Math.round(epochMs)}000000`;
|
|
22477
|
+
}
|
|
22478
|
+
function toOtlpAttributes(attributes) {
|
|
22479
|
+
return Object.entries(attributes).map(([key, value]) => {
|
|
22480
|
+
if (typeof value === "number") {
|
|
22481
|
+
return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
|
|
22482
|
+
}
|
|
22483
|
+
return { key, value: { string_value: String(value) } };
|
|
22484
|
+
});
|
|
22485
|
+
}
|
|
22486
|
+
|
|
22098
22487
|
// src/model.ts
|
|
22099
22488
|
import {
|
|
22100
22489
|
OpenAICompatibleModelProvider,
|
|
@@ -36435,8 +36824,8 @@ function parseResponse9(body, schema) {
|
|
|
36435
36824
|
function marshalRequest8(data, schema) {
|
|
36436
36825
|
return jsonBigint8.stringify(schema.parse(data));
|
|
36437
36826
|
}
|
|
36438
|
-
function encodeMultiSegmentPath(
|
|
36439
|
-
return
|
|
36827
|
+
function encodeMultiSegmentPath(path4) {
|
|
36828
|
+
return path4.split("/").map((segment2) => encodeURIComponent(segment2)).join("/");
|
|
36440
36829
|
}
|
|
36441
36830
|
async function sendAndCheckError2(opts) {
|
|
36442
36831
|
opts.logger.debug("HTTP request", {
|
|
@@ -57633,19 +58022,19 @@ var DATABRICKS_RAW_PROTOCOL_RULES = [
|
|
|
57633
58022
|
path: /^\/serving-endpoints\/[^/?#]+\/invocations$/u
|
|
57634
58023
|
}
|
|
57635
58024
|
];
|
|
57636
|
-
function assertRawProtocolAllowed(method,
|
|
58025
|
+
function assertRawProtocolAllowed(method, path4) {
|
|
57637
58026
|
const normalizedMethod = method.toUpperCase();
|
|
57638
|
-
if (!
|
|
58027
|
+
if (!path4.startsWith("/") || path4.includes("?") || path4.includes("#")) {
|
|
57639
58028
|
throw new Error(
|
|
57640
|
-
`databricks raw protocol denied: ${normalizedMethod} ${
|
|
58029
|
+
`databricks raw protocol denied: ${normalizedMethod} ${path4}; pass a relative path and structured query parameters.`
|
|
57641
58030
|
);
|
|
57642
58031
|
}
|
|
57643
58032
|
const rule = DATABRICKS_RAW_PROTOCOL_RULES.find(
|
|
57644
|
-
(candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(
|
|
58033
|
+
(candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(path4)
|
|
57645
58034
|
);
|
|
57646
58035
|
if (!rule) {
|
|
57647
58036
|
throw new Error(
|
|
57648
|
-
`databricks raw protocol denied: ${normalizedMethod} ${
|
|
58037
|
+
`databricks raw protocol denied: ${normalizedMethod} ${path4}; use an official @databricks/sdk-* service client.`
|
|
57649
58038
|
);
|
|
57650
58039
|
}
|
|
57651
58040
|
}
|
|
@@ -57666,20 +58055,20 @@ var DatabricksRawProtocolClient = class {
|
|
|
57666
58055
|
this.signal = options.signal;
|
|
57667
58056
|
this.extraHeaders = options.extraHeaders;
|
|
57668
58057
|
}
|
|
57669
|
-
get(
|
|
57670
|
-
return this.requestJson("GET",
|
|
58058
|
+
get(path4, query, options) {
|
|
58059
|
+
return this.requestJson("GET", path4, void 0, query, options);
|
|
57671
58060
|
}
|
|
57672
|
-
post(
|
|
57673
|
-
return this.requestJson("POST",
|
|
58061
|
+
post(path4, body, query, options) {
|
|
58062
|
+
return this.requestJson("POST", path4, body, query, options);
|
|
57674
58063
|
}
|
|
57675
|
-
patch(
|
|
57676
|
-
return this.requestJson("PATCH",
|
|
58064
|
+
patch(path4, body, query, options) {
|
|
58065
|
+
return this.requestJson("PATCH", path4, body, query, options);
|
|
57677
58066
|
}
|
|
57678
|
-
delete(
|
|
57679
|
-
return this.requestJson("DELETE",
|
|
58067
|
+
delete(path4, body, query, options) {
|
|
58068
|
+
return this.requestJson("DELETE", path4, body, query, options);
|
|
57680
58069
|
}
|
|
57681
|
-
async requestJson(method,
|
|
57682
|
-
const response = await this.send(method,
|
|
58070
|
+
async requestJson(method, path4, body, query = {}, options = {}) {
|
|
58071
|
+
const response = await this.send(method, path4, body, query, options);
|
|
57683
58072
|
if (response.status === 204) return void 0;
|
|
57684
58073
|
return await response.json();
|
|
57685
58074
|
}
|
|
@@ -57687,12 +58076,12 @@ var DatabricksRawProtocolClient = class {
|
|
|
57687
58076
|
* Perform an authenticated request while leaving a successful response body unread. This is
|
|
57688
58077
|
* intended for bounded binary downloads and streaming APIs such as Genie Agent Mode.
|
|
57689
58078
|
*/
|
|
57690
|
-
postRaw(
|
|
57691
|
-
return this.send("POST",
|
|
58079
|
+
postRaw(path4, body, query = {}, options = {}) {
|
|
58080
|
+
return this.send("POST", path4, body, query, options);
|
|
57692
58081
|
}
|
|
57693
|
-
async send(method,
|
|
57694
|
-
assertRawProtocolAllowed(method,
|
|
57695
|
-
const url2 = new URL(`${this.host}${
|
|
58082
|
+
async send(method, path4, body, query, options) {
|
|
58083
|
+
assertRawProtocolAllowed(method, path4);
|
|
58084
|
+
const url2 = new URL(`${this.host}${path4.startsWith("/") ? path4 : `/${path4}`}`);
|
|
57696
58085
|
for (const [key, value] of Object.entries(query))
|
|
57697
58086
|
if (value !== void 0) url2.searchParams.set(key, String(value));
|
|
57698
58087
|
const canRetry = options.retry === "always" || options.retry !== "never" && (options.retry === "safe" || method === "GET" || method === "HEAD");
|
|
@@ -59164,16 +59553,16 @@ var DatabricksWorkspaceAuthoring = class {
|
|
|
59164
59553
|
{ retry: "never" }
|
|
59165
59554
|
);
|
|
59166
59555
|
}
|
|
59167
|
-
deleteWorkspaceObject(
|
|
59556
|
+
deleteWorkspaceObject(path4, recursive = false) {
|
|
59168
59557
|
return this.client.post(
|
|
59169
59558
|
"/api/2.0/workspace/delete",
|
|
59170
|
-
{ path:
|
|
59559
|
+
{ path: path4, recursive },
|
|
59171
59560
|
{},
|
|
59172
59561
|
{ retry: "never" }
|
|
59173
59562
|
);
|
|
59174
59563
|
}
|
|
59175
|
-
mkdirs(
|
|
59176
|
-
return this.client.post("/api/2.0/workspace/mkdirs", { path:
|
|
59564
|
+
mkdirs(path4) {
|
|
59565
|
+
return this.client.post("/api/2.0/workspace/mkdirs", { path: path4 }, {}, { retry: "safe" });
|
|
59177
59566
|
}
|
|
59178
59567
|
};
|
|
59179
59568
|
function databricksWorkspaceAuthoringTools(client) {
|
|
@@ -59252,144 +59641,28 @@ function base643(value) {
|
|
|
59252
59641
|
return btoa(String.fromCharCode(...bytes));
|
|
59253
59642
|
}
|
|
59254
59643
|
|
|
59255
|
-
// src/app-deployment.ts
|
|
59256
|
-
import { spawn } from "child_process";
|
|
59257
|
-
import { access as access2 } from "fs/promises";
|
|
59258
|
-
import path from "path";
|
|
59259
|
-
async function validateDatabricksAppArtifact(options) {
|
|
59260
|
-
const artifactDir = path.resolve(options.artifactDir);
|
|
59261
|
-
await access2(path.join(artifactDir, "databricks.yml"));
|
|
59262
|
-
const run = options.run ?? runDatabricksCommand;
|
|
59263
|
-
const args = [
|
|
59264
|
-
"bundle",
|
|
59265
|
-
"validate",
|
|
59266
|
-
...options.target ? ["--target", options.target] : [],
|
|
59267
|
-
...options.profile ? ["--profile", options.profile] : []
|
|
59268
|
-
];
|
|
59269
|
-
const executable = options.executable ?? "databricks";
|
|
59270
|
-
options.onCommand?.({ executable, args });
|
|
59271
|
-
const result = await run(executable, args, {
|
|
59272
|
-
cwd: artifactDir,
|
|
59273
|
-
env: options.env ?? process.env
|
|
59274
|
-
});
|
|
59275
|
-
requireSuccess("Databricks bundle validation", result);
|
|
59276
|
-
return { valid: true, output: lastNonEmptyLine(result.stdout) };
|
|
59277
|
-
}
|
|
59278
|
-
async function deployDatabricksAppArtifact(options) {
|
|
59279
|
-
const artifactDir = path.resolve(options.artifactDir);
|
|
59280
|
-
await access2(path.join(artifactDir, "databricks.yml"));
|
|
59281
|
-
const run = options.run ?? runDatabricksCommand;
|
|
59282
|
-
const profileArgs = options.profile ? ["--profile", options.profile] : [];
|
|
59283
|
-
const env2 = options.env ?? process.env;
|
|
59284
|
-
const executable = options.executable ?? "databricks";
|
|
59285
|
-
const bundleArgs = [
|
|
59286
|
-
"bundle",
|
|
59287
|
-
"deploy",
|
|
59288
|
-
...options.target ? ["--target", options.target] : [],
|
|
59289
|
-
...profileArgs
|
|
59290
|
-
];
|
|
59291
|
-
options.onCommand?.({ executable, args: bundleArgs });
|
|
59292
|
-
const bundle = await run(executable, bundleArgs, { cwd: artifactDir, env: env2 });
|
|
59293
|
-
requireSuccess("Databricks bundle synchronization", bundle);
|
|
59294
|
-
if (options.startBeforeDeploy && options.appName) {
|
|
59295
|
-
const startArgs = ["apps", "start", options.appName, ...profileArgs];
|
|
59296
|
-
options.onCommand?.({ executable, args: startArgs });
|
|
59297
|
-
const start = await run(executable, startArgs, { cwd: artifactDir, env: env2 });
|
|
59298
|
-
requireSuccess("Databricks App compute start", start);
|
|
59299
|
-
}
|
|
59300
|
-
const appArgs = [
|
|
59301
|
-
"apps",
|
|
59302
|
-
"deploy",
|
|
59303
|
-
...options.appName ? [options.appName] : [],
|
|
59304
|
-
...options.sourceCodePath ? ["--source-code-path", options.sourceCodePath] : [],
|
|
59305
|
-
...options.mode ? ["--mode", options.mode] : [],
|
|
59306
|
-
"--skip-validation",
|
|
59307
|
-
"--auto-approve",
|
|
59308
|
-
...profileArgs
|
|
59309
|
-
];
|
|
59310
|
-
options.onCommand?.({ executable, args: appArgs });
|
|
59311
|
-
const app = await run(executable, appArgs, { cwd: artifactDir, env: env2 });
|
|
59312
|
-
requireSuccess("Databricks App snapshot activation", app);
|
|
59313
|
-
return {
|
|
59314
|
-
bundleSynchronized: true,
|
|
59315
|
-
appSnapshotActivated: true,
|
|
59316
|
-
bundleOutput: lastNonEmptyLine(bundle.stdout),
|
|
59317
|
-
appOutput: lastNonEmptyLine(app.stdout)
|
|
59318
|
-
};
|
|
59319
|
-
}
|
|
59320
|
-
async function destroyDatabricksAppArtifact(options) {
|
|
59321
|
-
const artifactDir = path.resolve(options.artifactDir);
|
|
59322
|
-
await access2(path.join(artifactDir, "databricks.yml"));
|
|
59323
|
-
const run = options.run ?? runDatabricksCommand;
|
|
59324
|
-
const args = [
|
|
59325
|
-
"bundle",
|
|
59326
|
-
"destroy",
|
|
59327
|
-
"--auto-approve",
|
|
59328
|
-
...options.target ? ["--target", options.target] : [],
|
|
59329
|
-
...options.profile ? ["--profile", options.profile] : []
|
|
59330
|
-
];
|
|
59331
|
-
const executable = options.executable ?? "databricks";
|
|
59332
|
-
options.onCommand?.({ executable, args });
|
|
59333
|
-
const result = await run(executable, args, {
|
|
59334
|
-
cwd: artifactDir,
|
|
59335
|
-
env: options.env ?? process.env
|
|
59336
|
-
});
|
|
59337
|
-
requireSuccess("Databricks bundle teardown", result);
|
|
59338
|
-
return { destroyed: true, output: lastNonEmptyLine(result.stdout) };
|
|
59339
|
-
}
|
|
59340
|
-
async function runDatabricksCommand(command, args, options) {
|
|
59341
|
-
return new Promise((resolve2, reject) => {
|
|
59342
|
-
const child = spawn(command, [...args], {
|
|
59343
|
-
cwd: options.cwd,
|
|
59344
|
-
env: options.env,
|
|
59345
|
-
shell: false,
|
|
59346
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
59347
|
-
});
|
|
59348
|
-
let stdout = "";
|
|
59349
|
-
let stderr = "";
|
|
59350
|
-
child.stdout.on("data", (chunk) => {
|
|
59351
|
-
stdout += chunk.toString();
|
|
59352
|
-
});
|
|
59353
|
-
child.stderr.on("data", (chunk) => {
|
|
59354
|
-
stderr += chunk.toString();
|
|
59355
|
-
});
|
|
59356
|
-
child.once("error", reject);
|
|
59357
|
-
child.once("close", (code) => resolve2({ exitCode: code ?? -1, stdout, stderr }));
|
|
59358
|
-
});
|
|
59359
|
-
}
|
|
59360
|
-
function requireSuccess(label, result) {
|
|
59361
|
-
if (result.exitCode === 0) return;
|
|
59362
|
-
const detail = result.stderr.trim().slice(-2e3);
|
|
59363
|
-
throw new Error(
|
|
59364
|
-
`${label} failed with exit code ${result.exitCode}${detail ? `: ${detail}` : ""}`
|
|
59365
|
-
);
|
|
59366
|
-
}
|
|
59367
|
-
function lastNonEmptyLine(value) {
|
|
59368
|
-
return value.split("\n").map((line) => line.trim()).filter(Boolean).at(-1) ?? "";
|
|
59369
|
-
}
|
|
59370
|
-
|
|
59371
59644
|
// src/artifact-digest.ts
|
|
59372
59645
|
import { createHash as createHash2 } from "crypto";
|
|
59373
|
-
import { lstat, readFile as
|
|
59374
|
-
import
|
|
59646
|
+
import { lstat, readFile as readFile3, readdir as readdir2 } from "fs/promises";
|
|
59647
|
+
import path3 from "path";
|
|
59375
59648
|
async function digestDatabricksArtifact(target) {
|
|
59376
59649
|
const targetInfo = await lstat(target);
|
|
59377
59650
|
rejectUnsupportedEntry(target, targetInfo);
|
|
59378
59651
|
if (targetInfo.isFile()) {
|
|
59379
|
-
return createHash2("sha256").update(await
|
|
59652
|
+
return createHash2("sha256").update(await readFile3(target)).digest("hex");
|
|
59380
59653
|
}
|
|
59381
59654
|
const hash2 = createHash2("sha256");
|
|
59382
59655
|
async function append(directory, relativeDirectory) {
|
|
59383
|
-
for (const name of (await
|
|
59384
|
-
const candidate =
|
|
59385
|
-
const relative =
|
|
59656
|
+
for (const name of (await readdir2(directory)).sort()) {
|
|
59657
|
+
const candidate = path3.join(directory, name);
|
|
59658
|
+
const relative = path3.join(relativeDirectory, name).replaceAll(path3.sep, "/");
|
|
59386
59659
|
const info = await lstat(candidate);
|
|
59387
59660
|
rejectUnsupportedEntry(relative, info);
|
|
59388
59661
|
if (info.isDirectory()) {
|
|
59389
59662
|
hash2.update(`directory\0${relative}\0`);
|
|
59390
59663
|
await append(candidate, relative);
|
|
59391
59664
|
} else {
|
|
59392
|
-
const bytes = await
|
|
59665
|
+
const bytes = await readFile3(candidate);
|
|
59393
59666
|
hash2.update(`file\0${relative}\0${bytes.byteLength}\0`);
|
|
59394
59667
|
hash2.update(bytes);
|
|
59395
59668
|
}
|
|
@@ -59762,17 +60035,17 @@ var UcVolumesAttachmentStore = class {
|
|
|
59762
60035
|
return `${this.bytesPath(scope, digest)}.json`;
|
|
59763
60036
|
}
|
|
59764
60037
|
// ─── Files API ────────────────────────────────────────────────────────────
|
|
59765
|
-
async writeFile(
|
|
60038
|
+
async writeFile(path4, bytes) {
|
|
59766
60039
|
await this.client.uploadFile({
|
|
59767
|
-
filePath:
|
|
60040
|
+
filePath: path4,
|
|
59768
60041
|
overwrite: true,
|
|
59769
60042
|
contents: new Blob([viewToBuffer(bytes)]).stream()
|
|
59770
60043
|
});
|
|
59771
60044
|
}
|
|
59772
60045
|
/** Raw file bytes, or `null` when the file does not exist (404). */
|
|
59773
|
-
async readFile(
|
|
60046
|
+
async readFile(path4) {
|
|
59774
60047
|
try {
|
|
59775
|
-
const response = await this.client.downloadFile({ filePath:
|
|
60048
|
+
const response = await this.client.downloadFile({ filePath: path4 });
|
|
59776
60049
|
if (!response.contents) return new Uint8Array();
|
|
59777
60050
|
return new Uint8Array(await new Response(response.contents).arrayBuffer());
|
|
59778
60051
|
} catch (error51) {
|
|
@@ -59781,9 +60054,9 @@ var UcVolumesAttachmentStore = class {
|
|
|
59781
60054
|
}
|
|
59782
60055
|
}
|
|
59783
60056
|
/** True when the file existed and was deleted; false on 404. */
|
|
59784
|
-
async deleteFile(
|
|
60057
|
+
async deleteFile(path4) {
|
|
59785
60058
|
try {
|
|
59786
|
-
await this.client.deleteFile({ filePath:
|
|
60059
|
+
await this.client.deleteFile({ filePath: path4 });
|
|
59787
60060
|
return true;
|
|
59788
60061
|
} catch (error51) {
|
|
59789
60062
|
if (isNotFound(error51)) return false;
|
|
@@ -59791,14 +60064,14 @@ var UcVolumesAttachmentStore = class {
|
|
|
59791
60064
|
}
|
|
59792
60065
|
}
|
|
59793
60066
|
/** Immediate children of a directory; empty for a missing directory (404). */
|
|
59794
|
-
async listDirectory(
|
|
60067
|
+
async listDirectory(path4) {
|
|
59795
60068
|
const entries = [];
|
|
59796
60069
|
let pageToken;
|
|
59797
60070
|
do {
|
|
59798
60071
|
let listing;
|
|
59799
60072
|
try {
|
|
59800
60073
|
listing = await this.client.listDirectoryContents({
|
|
59801
|
-
directoryPath:
|
|
60074
|
+
directoryPath: path4,
|
|
59802
60075
|
...pageToken ? { pageToken } : {}
|
|
59803
60076
|
});
|
|
59804
60077
|
} catch (error51) {
|
|
@@ -61869,14 +62142,14 @@ function databricksCompatibilityRecord(evidence) {
|
|
|
61869
62142
|
var ALL_CLOUDS = ["aws", "azure", "gcp"];
|
|
61870
62143
|
var AUTHORING_EVIDENCE_ID = "dbx-cert-d4b16490526892f3945ba5a53249c600581aaed105829c0b87f00eed508bcb18";
|
|
61871
62144
|
var CLASSIC_AUTHORING_EVIDENCE_ID = "dbx-cert-d5bdbd276533a8634910e223898337314446561be2a444030fc2d11baa237bec";
|
|
61872
|
-
var CURRENT_CONSUMPTION_EVIDENCE_ID = "dbx-cert-
|
|
62145
|
+
var CURRENT_CONSUMPTION_EVIDENCE_ID = "dbx-cert-69878cfdd583d1f4331487a5af3272ae7380736914203dcba3bbb8b4d87adb34";
|
|
61873
62146
|
var DATABRICKS_CAPABILITY_EVIDENCE = [
|
|
61874
62147
|
{
|
|
61875
62148
|
id: CURRENT_CONSUMPTION_EVIDENCE_ID,
|
|
61876
62149
|
source: "repository-evidence:artifacts/databricks-certification-current.json",
|
|
61877
|
-
certifiedAt: "2026-07-
|
|
61878
|
-
packageVersion: "4.
|
|
61879
|
-
artifactSha256: "
|
|
62150
|
+
certifiedAt: "2026-07-21T06:14:56.810Z",
|
|
62151
|
+
packageVersion: "4.9.1",
|
|
62152
|
+
artifactSha256: "5e7b9f0a26e0834bcbf703561aeca46f3e48da5be6dd5022084f723bde630ab1",
|
|
61880
62153
|
apiVersions: {
|
|
61881
62154
|
sdkJs: "0.21.0",
|
|
61882
62155
|
jobs: "2.2",
|
|
@@ -61924,6 +62197,10 @@ var DATABRICKS_CAPABILITY_EVIDENCE = [
|
|
|
61924
62197
|
"apps.restart",
|
|
61925
62198
|
"genie.execute",
|
|
61926
62199
|
"genie.authorization-denied",
|
|
62200
|
+
"mcp.invoke",
|
|
62201
|
+
"mcp.authorization-denied",
|
|
62202
|
+
"mcp.obo",
|
|
62203
|
+
"mcp.token-redaction",
|
|
61927
62204
|
"feature-serving.read",
|
|
61928
62205
|
"feature-serving.authorization-denied",
|
|
61929
62206
|
"ai-search.query",
|
|
@@ -62097,7 +62374,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
|
|
|
62097
62374
|
requiredEvidence: ["responses.execute", "responses.recovery"],
|
|
62098
62375
|
evidenceIds: [CURRENT_CONSUMPTION_EVIDENCE_ID],
|
|
62099
62376
|
docs: "/docs/databricks/responses-agent",
|
|
62100
|
-
notes: "The API remains Beta, but execution, streaming output, inference-table configuration and recovery passed on the exact 4.
|
|
62377
|
+
notes: "The API remains Beta, but execution, streaming output, inference-table configuration and recovery passed on the exact 4.9.1 package and App artifacts."
|
|
62101
62378
|
},
|
|
62102
62379
|
{
|
|
62103
62380
|
id: "unity-ai-gateway",
|
|
@@ -62141,7 +62418,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
|
|
|
62141
62418
|
id: "mcp-multi-agent",
|
|
62142
62419
|
name: "Databricks MCP and governed multi-agent composition",
|
|
62143
62420
|
category: "agent",
|
|
62144
|
-
status: "
|
|
62421
|
+
status: "beta",
|
|
62145
62422
|
tier: "first-party",
|
|
62146
62423
|
certification: "protected-live",
|
|
62147
62424
|
auth: ["oauth-m2m", "app-service-principal", "on-behalf-of"],
|
|
@@ -62157,8 +62434,9 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
|
|
|
62157
62434
|
}
|
|
62158
62435
|
],
|
|
62159
62436
|
requiredEvidence: ["mcp.invoke", "mcp.authorization-denied", "mcp.obo", "mcp.token-redaction"],
|
|
62437
|
+
evidenceIds: [CURRENT_CONSUMPTION_EVIDENCE_ID],
|
|
62160
62438
|
docs: "/docs/databricks/integrations",
|
|
62161
|
-
notes: "The adapter,
|
|
62439
|
+
notes: "The first-party adapter, governed context boundary, OBO invocation, and token redaction passed Tier R on the exact 4.9.1 package. Status remains Beta while Databricks managed MCP surfaces are workspace-dependent previews."
|
|
62162
62440
|
},
|
|
62163
62441
|
{
|
|
62164
62442
|
id: "managed-memory",
|
|
@@ -62680,26 +62958,26 @@ function databricksSqlSandbox(options) {
|
|
|
62680
62958
|
};
|
|
62681
62959
|
}
|
|
62682
62960
|
},
|
|
62683
|
-
async readFile(
|
|
62684
|
-
const bytes = memFs.get(
|
|
62685
|
-
if (!bytes) throw new Error(`No such file: ${
|
|
62961
|
+
async readFile(path4) {
|
|
62962
|
+
const bytes = memFs.get(path4);
|
|
62963
|
+
if (!bytes) throw new Error(`No such file: ${path4}`);
|
|
62686
62964
|
return new TextDecoder().decode(bytes);
|
|
62687
62965
|
},
|
|
62688
|
-
async readFileBuffer(
|
|
62689
|
-
const bytes = memFs.get(
|
|
62690
|
-
if (!bytes) throw new Error(`No such file: ${
|
|
62966
|
+
async readFileBuffer(path4) {
|
|
62967
|
+
const bytes = memFs.get(path4);
|
|
62968
|
+
if (!bytes) throw new Error(`No such file: ${path4}`);
|
|
62691
62969
|
return bytes;
|
|
62692
62970
|
},
|
|
62693
|
-
async writeFile(
|
|
62694
|
-
memFs.set(
|
|
62971
|
+
async writeFile(path4, content) {
|
|
62972
|
+
memFs.set(path4, typeof content === "string" ? new TextEncoder().encode(content) : content);
|
|
62695
62973
|
},
|
|
62696
|
-
async stat(
|
|
62697
|
-
const bytes = memFs.get(
|
|
62698
|
-
if (!bytes) throw new Error(`No such file: ${
|
|
62974
|
+
async stat(path4) {
|
|
62975
|
+
const bytes = memFs.get(path4);
|
|
62976
|
+
if (!bytes) throw new Error(`No such file: ${path4}`);
|
|
62699
62977
|
return { type: "file", size: bytes.byteLength };
|
|
62700
62978
|
},
|
|
62701
|
-
async readdir(
|
|
62702
|
-
const prefix =
|
|
62979
|
+
async readdir(path4) {
|
|
62980
|
+
const prefix = path4.replace(/\/$/, "");
|
|
62703
62981
|
const direct = /* @__PURE__ */ new Set();
|
|
62704
62982
|
for (const key of memFs.keys()) {
|
|
62705
62983
|
if (!key.startsWith(`${prefix}/`)) continue;
|
|
@@ -62709,14 +62987,14 @@ function databricksSqlSandbox(options) {
|
|
|
62709
62987
|
}
|
|
62710
62988
|
return [...direct];
|
|
62711
62989
|
},
|
|
62712
|
-
async exists(
|
|
62713
|
-
return memFs.has(
|
|
62990
|
+
async exists(path4) {
|
|
62991
|
+
return memFs.has(path4);
|
|
62714
62992
|
},
|
|
62715
62993
|
async mkdir() {
|
|
62716
62994
|
},
|
|
62717
|
-
async rm(
|
|
62995
|
+
async rm(path4) {
|
|
62718
62996
|
for (const key of [...memFs.keys()]) {
|
|
62719
|
-
if (key ===
|
|
62997
|
+
if (key === path4 || key.startsWith(`${path4}/`)) memFs.delete(key);
|
|
62720
62998
|
}
|
|
62721
62999
|
}
|
|
62722
63000
|
};
|
|
@@ -63544,6 +63822,12 @@ function buildDatabricksBundle(config2, scope) {
|
|
|
63544
63822
|
const client = native.rawProtocol;
|
|
63545
63823
|
const genieAgentModeClient = genie.agentMode ? databricksGenieAgentMode(client, genie.agentMode) : void 0;
|
|
63546
63824
|
const agentServicesClient = config2.agentServices ? databricksAgentServices(client, config2.agentServices) : void 0;
|
|
63825
|
+
const assetBundle = config2.assetBundles ? databricksAssetBundleLifecycle({
|
|
63826
|
+
bundleDir: config2.assetBundles.bundleDir,
|
|
63827
|
+
...config2.assetBundles.target ? { target: config2.assetBundles.target } : {},
|
|
63828
|
+
...config2.assetBundles.store ? { store: config2.assetBundles.store } : {},
|
|
63829
|
+
principalLabel: config2.governance?.principalLabel ?? principalLabel(config2.principal)
|
|
63830
|
+
}) : void 0;
|
|
63547
63831
|
let embeddings;
|
|
63548
63832
|
let retriever;
|
|
63549
63833
|
let searchTool;
|
|
@@ -63618,6 +63902,7 @@ function buildDatabricksBundle(config2, scope) {
|
|
|
63618
63902
|
...config2.lakeflowAuthoring ? databricksLakeflowAuthoringTools(native.pipelines, {
|
|
63619
63903
|
...config2.lakeflowEvents && config2.warehouseId ? { warehouseId: config2.warehouseId, statements: native.statements } : {}
|
|
63620
63904
|
}) : [],
|
|
63905
|
+
...assetBundle ? databricksAssetBundleTools(assetBundle) : [],
|
|
63621
63906
|
...config2.aiSearchAdmin ? databricksAiSearchAdminTools(native.vectorSearch) : [],
|
|
63622
63907
|
...config2.servingAdmin ? databricksServingAdminTools(native.modelServing) : [],
|
|
63623
63908
|
...config2.ucAdmin ? databricksUnityCatalogAdminTools(
|
|
@@ -63696,6 +63981,7 @@ function buildDatabricksBundle(config2, scope) {
|
|
|
63696
63981
|
} : {},
|
|
63697
63982
|
...genieAgentModeClient ? { genieAgentMode: genieAgentModeClient } : {},
|
|
63698
63983
|
...agentServicesClient ? { agentServices: agentServicesClient } : {},
|
|
63984
|
+
...assetBundle ? { assetBundle } : {},
|
|
63699
63985
|
aiGateway: {
|
|
63700
63986
|
ensure: () => ensureDatabricksAiGateway(client),
|
|
63701
63987
|
listModelServices: (options) => listDatabricksModelServices(client, options),
|
|
@@ -63730,6 +64016,7 @@ function enabledAuthoringServices(config2, genie = normalizeGenieConfig(config2)
|
|
|
63730
64016
|
...config2.jobAuthoring || config2.oneOffCompute ? ["jobs"] : [],
|
|
63731
64017
|
...genie.manage ? ["genie"] : [],
|
|
63732
64018
|
...config2.lakeflowAuthoring ? ["lakeflow"] : [],
|
|
64019
|
+
...config2.assetBundles ? ["bundles"] : [],
|
|
63733
64020
|
...config2.aiSearchAdmin ? ["ai-search"] : [],
|
|
63734
64021
|
...config2.servingAdmin ? ["serving"] : [],
|
|
63735
64022
|
...config2.ucAdmin ? ["unity-catalog"] : [],
|
|
@@ -63824,6 +64111,7 @@ export {
|
|
|
63824
64111
|
DATABRICKS_RELEASE_CERTIFICATION_CHECKS,
|
|
63825
64112
|
DATABRICKS_SDK_VERSION,
|
|
63826
64113
|
DatabricksAiSearchAdmin,
|
|
64114
|
+
DatabricksAssetBundleLifecycle,
|
|
63827
64115
|
DatabricksCertificationCleanupLedger,
|
|
63828
64116
|
DatabricksGenieAgentModeProtocolError,
|
|
63829
64117
|
DatabricksGenieAgentModeResponseError,
|
|
@@ -63863,6 +64151,8 @@ export {
|
|
|
63863
64151
|
databricksAnthropicGatewayBaseUrl,
|
|
63864
64152
|
databricksApp,
|
|
63865
64153
|
databricksApprovalRules,
|
|
64154
|
+
databricksAssetBundleLifecycle,
|
|
64155
|
+
databricksAssetBundleTools,
|
|
63866
64156
|
databricksCertificationTier,
|
|
63867
64157
|
databricksCompatibilityRecord,
|
|
63868
64158
|
databricksConsumption,
|