@fabric-harness/databricks 3.0.3 → 4.0.1

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/index.js CHANGED
@@ -1795,6 +1795,172 @@ var require_json_bigint = __commonJS({
1795
1795
  // src/index.ts
1796
1796
  import { createSearchTool as createSearchTool2 } from "@fabric-harness/sdk";
1797
1797
 
1798
+ // src/agent-services.ts
1799
+ var DATABRICKS_AGENT_SERVICES_API = "/api/2.1/unity-catalog/agent-services";
1800
+ var DATABRICKS_AGENT_SERVICE_SECURABLE = "AGENT_SERVICE";
1801
+ var DatabricksAgentServices = class {
1802
+ constructor(client, options) {
1803
+ this.client = client;
1804
+ if (options.acknowledgeBeta !== true) {
1805
+ throw new Error("databricks agent services: acknowledgeBeta must be true.");
1806
+ }
1807
+ }
1808
+ create(options) {
1809
+ const catalog = ucIdentifier(options.catalog, "catalog");
1810
+ const schema = ucIdentifier(options.schema, "schema");
1811
+ const id = ucIdentifier(options.id, "agent service id");
1812
+ const basePath = externalBasePath(options.basePath ?? "/responses");
1813
+ return this.client.post(
1814
+ DATABRICKS_AGENT_SERVICES_API,
1815
+ {
1816
+ agent_service_type: "AGENT_SERVICE_TYPE_EXTERNAL",
1817
+ ...options.comment !== void 0 ? { comment: options.comment } : {},
1818
+ config: {
1819
+ connection: { name: connectionResourceName(options.connection) },
1820
+ base_path: basePath,
1821
+ ...options.systemPrompt !== void 0 ? { system_prompt: options.systemPrompt } : {}
1822
+ }
1823
+ },
1824
+ { parent: `schemas/${catalog}.${schema}`, agent_service_id: id },
1825
+ { retry: "never" }
1826
+ );
1827
+ }
1828
+ get(fullName) {
1829
+ return this.client.get(agentServicePath(fullName));
1830
+ }
1831
+ list(options = {}) {
1832
+ if (options.catalog === void 0 !== (options.schema === void 0)) {
1833
+ throw new Error("databricks agent services: catalog and schema must be provided together.");
1834
+ }
1835
+ const parent = options.catalog && options.schema ? `schemas/${ucIdentifier(options.catalog, "catalog")}.${ucIdentifier(options.schema, "schema")}` : void 0;
1836
+ return this.client.get(DATABRICKS_AGENT_SERVICES_API, {
1837
+ parent,
1838
+ page_token: options.pageToken
1839
+ });
1840
+ }
1841
+ update(fullName, options) {
1842
+ const mask = [];
1843
+ const config2 = {};
1844
+ const body = {};
1845
+ if (options.comment !== void 0) {
1846
+ mask.push("comment");
1847
+ body.comment = options.comment;
1848
+ }
1849
+ if (options.basePath !== void 0) {
1850
+ mask.push("config.base_path");
1851
+ config2.base_path = externalBasePath(options.basePath);
1852
+ }
1853
+ if (options.systemPrompt !== void 0) {
1854
+ mask.push("config.system_prompt");
1855
+ config2.system_prompt = options.systemPrompt;
1856
+ }
1857
+ if (mask.length === 0) {
1858
+ throw new Error(
1859
+ "databricks agent services: update requires comment, basePath or systemPrompt."
1860
+ );
1861
+ }
1862
+ if (Object.keys(config2).length > 0) body.config = config2;
1863
+ return this.client.request(
1864
+ "PATCH",
1865
+ agentServicePath(fullName),
1866
+ body,
1867
+ { update_mask: mask.join(",") },
1868
+ { retry: "safe" }
1869
+ );
1870
+ }
1871
+ delete(fullName) {
1872
+ return this.client.request(
1873
+ "DELETE",
1874
+ agentServicePath(fullName),
1875
+ void 0,
1876
+ {},
1877
+ { retry: "never" }
1878
+ );
1879
+ }
1880
+ permissions(fullName) {
1881
+ return this.client.get(permissionsPath(fullName));
1882
+ }
1883
+ updatePermissions(fullName, changes) {
1884
+ if (changes.length === 0) {
1885
+ throw new Error("databricks agent services: at least one permission change is required.");
1886
+ }
1887
+ for (const change of changes) {
1888
+ if (!change.principal.trim())
1889
+ throw new Error("databricks agent services: principal cannot be empty.");
1890
+ if ((change.add?.length ?? 0) === 0 && (change.remove?.length ?? 0) === 0) {
1891
+ throw new Error(
1892
+ `databricks agent services: ${change.principal} has no privileges to add or remove.`
1893
+ );
1894
+ }
1895
+ }
1896
+ return this.client.request(
1897
+ "PATCH",
1898
+ permissionsPath(fullName),
1899
+ { changes },
1900
+ {},
1901
+ { retry: "safe" }
1902
+ );
1903
+ }
1904
+ grant(fullName, principal, privileges = ["EXECUTE"]) {
1905
+ return this.updatePermissions(fullName, [{ principal, add: privileges }]);
1906
+ }
1907
+ revoke(fullName, principal, privileges = ["EXECUTE"]) {
1908
+ return this.updatePermissions(fullName, [{ principal, remove: privileges }]);
1909
+ }
1910
+ };
1911
+ function databricksAgentServices(client, options) {
1912
+ return new DatabricksAgentServices(client, options);
1913
+ }
1914
+ function agentServicePath(fullName) {
1915
+ return `${DATABRICKS_AGENT_SERVICES_API}/${encodeURIComponent(fullUcName(fullName))}`;
1916
+ }
1917
+ function permissionsPath(fullName) {
1918
+ return `/api/2.1/unity-catalog/permissions/${DATABRICKS_AGENT_SERVICE_SECURABLE}/${encodeURIComponent(fullUcName(fullName))}`;
1919
+ }
1920
+ function fullUcName(value) {
1921
+ const parts = value.split(".");
1922
+ if (parts.length !== 3) {
1923
+ throw new Error(
1924
+ `databricks agent services: expected catalog.schema.service, received ${value}.`
1925
+ );
1926
+ }
1927
+ return parts.map(
1928
+ (part, index) => ucIdentifier(part, ["catalog", "schema", "service"][index] ?? "identifier")
1929
+ ).join(".");
1930
+ }
1931
+ function connectionResourceName(value) {
1932
+ const trimmed = value.trim();
1933
+ const name = trimmed.startsWith("connections/") ? trimmed.slice("connections/".length) : trimmed;
1934
+ const parts = name.split(".");
1935
+ if (parts.length !== 1 && parts.length !== 3) {
1936
+ throw new Error(
1937
+ `databricks agent services: expected connection name or catalog.schema.connection, received ${value}.`
1938
+ );
1939
+ }
1940
+ return `connections/${parts.map(
1941
+ (part, index) => ucIdentifier(
1942
+ part,
1943
+ parts.length === 1 ? "connection" : ["catalog", "schema", "connection"][index] ?? "identifier"
1944
+ )
1945
+ ).join(".")}`;
1946
+ }
1947
+ function externalBasePath(value) {
1948
+ const path = value.trim();
1949
+ if (!path.startsWith("/") || path.startsWith("//") || path.includes("?") || path.includes("#")) {
1950
+ throw new Error(
1951
+ "databricks agent services: basePath must be an absolute URL path without a query or fragment."
1952
+ );
1953
+ }
1954
+ return path;
1955
+ }
1956
+ function ucIdentifier(value, label) {
1957
+ const normalized = value.trim();
1958
+ if (!/^[A-Za-z0-9_][A-Za-z0-9_$-]*$/.test(normalized)) {
1959
+ throw new Error(`databricks agent services: invalid ${label} ${JSON.stringify(value)}.`);
1960
+ }
1961
+ return normalized;
1962
+ }
1963
+
1798
1964
  // src/ai-search-admin.ts
1799
1965
  var DatabricksAiSearchAdmin = class {
1800
1966
  constructor(client) {
@@ -2035,6 +2201,55 @@ function jitter(ms) {
2035
2201
  return Math.max(1, Math.round(ms * (0.9 + Math.random() * 0.2)));
2036
2202
  }
2037
2203
 
2204
+ // src/ai-gateway.ts
2205
+ async function ensureDatabricksAiGateway(client) {
2206
+ await client.get("/api/ai-gateway/v2/endpoints", { page_size: 1 });
2207
+ }
2208
+ async function listDatabricksModelServices(client, options = {}) {
2209
+ const pageSize = positiveInteger(options.pageSize ?? 100, "pageSize");
2210
+ const maxPages = positiveInteger(options.maxPages ?? 100, "maxPages");
2211
+ const requiredPrefix = options.requiredPrefix ?? "system.ai.";
2212
+ const services = /* @__PURE__ */ new Map();
2213
+ const seenTokens = /* @__PURE__ */ new Set();
2214
+ let pageToken;
2215
+ for (let page = 0; page < maxPages; page += 1) {
2216
+ const response = await client.get(
2217
+ "/api/2.1/unity-catalog/model-services",
2218
+ { page_size: pageSize, ...pageToken ? { page_token: pageToken } : {} }
2219
+ );
2220
+ for (const raw of response.model_services ?? []) {
2221
+ const service = normalizeModelService(raw, requiredPrefix);
2222
+ if (service) services.set(service.name, service);
2223
+ }
2224
+ const next = response.next_page_token?.trim();
2225
+ if (!next) return [...services.values()].sort((a2, b2) => a2.name.localeCompare(b2.name));
2226
+ if (seenTokens.has(next))
2227
+ throw new Error(
2228
+ `databricks model-services pagination repeated token after page ${page + 1}.`
2229
+ );
2230
+ seenTokens.add(next);
2231
+ pageToken = next;
2232
+ }
2233
+ throw new Error(`databricks model-services pagination exceeded ${maxPages} pages.`);
2234
+ }
2235
+ function normalizeModelService(raw, requiredPrefix) {
2236
+ const rawName = typeof raw.name === "string" ? raw.name.trim() : "";
2237
+ const name = rawName.replace(/^model-services\//, "");
2238
+ if (!name.startsWith(requiredPrefix)) return void 0;
2239
+ return {
2240
+ name,
2241
+ ...typeof raw.comment === "string" ? { comment: raw.comment } : {},
2242
+ ...typeof raw.creator === "string" ? { creator: raw.creator } : {},
2243
+ ...typeof raw.created_at === "number" ? { createdAt: raw.created_at } : {},
2244
+ ...typeof raw.updated_at === "number" ? { updatedAt: raw.updated_at } : {}
2245
+ };
2246
+ }
2247
+ function positiveInteger(value, name) {
2248
+ if (!Number.isSafeInteger(value) || value <= 0)
2249
+ throw new Error(`${name} must be a positive integer.`);
2250
+ return value;
2251
+ }
2252
+
2038
2253
  // src/sql-exec.ts
2039
2254
  var TERMINAL_STATES = /* @__PURE__ */ new Set(["SUCCEEDED", "FAILED", "CANCELED", "CLOSED"]);
2040
2255
  async function runStatement(client, warehouseId, statement, parameters, poll) {
@@ -2106,6 +2321,64 @@ function retryDelayMs(response, attempt, base2) {
2106
2321
  }
2107
2322
  return base2 * 2 ** attempt;
2108
2323
  }
2324
+ var DATABRICKS_RAW_PROTOCOL_RULES = [
2325
+ {
2326
+ id: "workspace-objects",
2327
+ methods: ["GET", "POST"],
2328
+ path: /^\/api\/2\.0\/workspace\/(?:delete|export|get-status|import|list|mkdirs)$/u
2329
+ },
2330
+ {
2331
+ id: "mlflow-traces-v3",
2332
+ methods: ["POST"],
2333
+ path: /^\/api\/3\.0\/mlflow\/traces$/u
2334
+ },
2335
+ {
2336
+ id: "ai-gateway-discovery",
2337
+ methods: ["GET"],
2338
+ path: /^\/api\/(?:ai-gateway\/v2\/endpoints|2\.1\/unity-catalog\/model-services)$/u
2339
+ },
2340
+ {
2341
+ id: "agent-services-beta",
2342
+ methods: ["GET", "POST", "PATCH", "DELETE"],
2343
+ path: /^\/api\/2\.1\/unity-catalog\/(?:agent-services(?:\/[^/?#]+)?|permissions\/agent-service\/[^/?#]+)$/u
2344
+ },
2345
+ {
2346
+ id: "genie-permissions",
2347
+ methods: ["GET", "PATCH"],
2348
+ path: /^\/api\/2\.0\/permissions\/genie\/[^/?#]+$/u
2349
+ },
2350
+ {
2351
+ id: "genie-agent-mode-beta",
2352
+ methods: ["GET", "POST"],
2353
+ path: /^\/api\/2\.0\/genie\/agents\/[^/?#]+\/(?:responses|conversations\/[^/?#]+\/items)$/u
2354
+ },
2355
+ {
2356
+ id: "genie-query-result-sdk-compatibility",
2357
+ methods: ["GET"],
2358
+ path: /^\/api\/2\.0\/genie\/spaces\/[^/?#]+\/conversations\/[^/?#]+\/messages\/[^/?#]+\/attachments\/[^/?#]+\/query-result$/u
2359
+ },
2360
+ {
2361
+ id: "responses-agent-custom-schema",
2362
+ methods: ["POST"],
2363
+ path: /^\/serving-endpoints\/[^/?#]+\/invocations$/u
2364
+ }
2365
+ ];
2366
+ function assertRawProtocolAllowed(method, path) {
2367
+ const normalizedMethod = method.toUpperCase();
2368
+ if (!path.startsWith("/") || path.includes("?") || path.includes("#")) {
2369
+ throw new Error(
2370
+ `databricks raw protocol denied: ${normalizedMethod} ${path}; pass a relative path and structured query parameters.`
2371
+ );
2372
+ }
2373
+ const rule = DATABRICKS_RAW_PROTOCOL_RULES.find(
2374
+ (candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(path)
2375
+ );
2376
+ if (!rule) {
2377
+ throw new Error(
2378
+ `databricks raw protocol denied: ${normalizedMethod} ${path}; use an official @databricks/sdk-* service client.`
2379
+ );
2380
+ }
2381
+ }
2109
2382
  var DatabricksPreviewClient = class {
2110
2383
  host;
2111
2384
  token;
@@ -2148,6 +2421,7 @@ var DatabricksPreviewClient = class {
2148
2421
  * intended for bounded binary downloads and streaming APIs such as Genie Agent Mode.
2149
2422
  */
2150
2423
  async requestRaw(method, path, body, query = {}, options = {}) {
2424
+ assertRawProtocolAllowed(method, path);
2151
2425
  const url2 = new URL(`${this.host}${path.startsWith("/") ? path : `/${path}`}`);
2152
2426
  for (const [key, value] of Object.entries(query))
2153
2427
  if (value !== void 0) url2.searchParams.set(key, String(value));
@@ -2694,10 +2968,10 @@ var DatabricksGenieAgentModeClient = class {
2694
2968
  if (options.acknowledgeBeta !== true)
2695
2969
  throw new Error("Databricks Genie Agent Mode requires acknowledgeBeta: true.");
2696
2970
  this.agentId = validateAgentId(options.agentId);
2697
- this.maxEventBytes = positiveInteger(options.maxEventBytes ?? 2 * 1024 * 1024, "maxEventBytes");
2698
- this.maxEvents = positiveInteger(options.maxEvents ?? 1e4, "maxEvents");
2699
- this.timeoutMs = positiveInteger(options.timeoutMs ?? 90 * 6e4, "timeoutMs");
2700
- this.idleTimeoutMs = positiveInteger(options.idleTimeoutMs ?? 2 * 6e4, "idleTimeoutMs");
2971
+ this.maxEventBytes = positiveInteger2(options.maxEventBytes ?? 2 * 1024 * 1024, "maxEventBytes");
2972
+ this.maxEvents = positiveInteger2(options.maxEvents ?? 1e4, "maxEvents");
2973
+ this.timeoutMs = positiveInteger2(options.timeoutMs ?? 90 * 6e4, "timeoutMs");
2974
+ this.idleTimeoutMs = positiveInteger2(options.idleTimeoutMs ?? 2 * 6e4, "idleTimeoutMs");
2701
2975
  this.onEvent = options.onEvent;
2702
2976
  }
2703
2977
  agentId;
@@ -2812,7 +3086,7 @@ var DatabricksGenieAgentModeClient = class {
2812
3086
  `/api/2.0/genie/agents/${encodeURIComponent(this.agentId)}/conversations/${encodeURIComponent(nonEmpty(conversationId, "conversationId"))}/items`,
2813
3087
  {
2814
3088
  after: optionalNonEmpty(options.after, "after"),
2815
- limit: options.limit === void 0 ? void 0 : positiveInteger(options.limit, "limit")
3089
+ limit: options.limit === void 0 ? void 0 : positiveInteger2(options.limit, "limit")
2816
3090
  },
2817
3091
  signalOption(options.signal)
2818
3092
  );
@@ -2831,7 +3105,7 @@ function databricksGenieAgentMode(client, options) {
2831
3105
  }
2832
3106
  function databricksGenieAgentModeTool(client, agentId, options = {}) {
2833
3107
  const configuredAgentId = validateAgentId(agentId);
2834
- const maxOutputBytes = positiveInteger(options.maxOutputBytes ?? 1024 * 1024, "maxOutputBytes");
3108
+ const maxOutputBytes = positiveInteger2(options.maxOutputBytes ?? 1024 * 1024, "maxOutputBytes");
2835
3109
  return {
2836
3110
  name: "databricks_genie_agent_mode",
2837
3111
  description: "Ask a Databricks Genie Agent through the Beta Agent Mode streaming API and return its terminal response.",
@@ -3031,7 +3305,7 @@ function nonEmpty(value, name) {
3031
3305
  function optionalNonEmpty(value, name) {
3032
3306
  return value === void 0 ? void 0 : nonEmpty(value, name);
3033
3307
  }
3034
- function positiveInteger(value, name) {
3308
+ function positiveInteger2(value, name) {
3035
3309
  if (!Number.isSafeInteger(value) || value <= 0)
3036
3310
  throw new Error(`Databricks Genie Agent Mode ${name} must be a positive integer.`);
3037
3311
  return value;
@@ -3612,10 +3886,17 @@ function databricksGenieAuthoringTools(client, options) {
3612
3886
  }
3613
3887
  throw error51;
3614
3888
  }
3615
- const current = await admin.get(agentId, {
3616
- includeConfiguration: true,
3617
- ...contextSignal(context)
3618
- });
3889
+ let current;
3890
+ try {
3891
+ current = await admin.get(agentId, {
3892
+ includeConfiguration: true,
3893
+ ...contextSignal(context)
3894
+ });
3895
+ } catch (lookupError) {
3896
+ if (!isGenieAbsentError(lookupError)) throw lookupError;
3897
+ await options.managedResourceStore.delete(GENIE_RESOURCE_TYPE, agentId);
3898
+ return { deleted: true, agentId, alreadyAbsent: true };
3899
+ }
3619
3900
  if (current.fingerprint !== expectedFingerprint) {
3620
3901
  throw new DatabricksManagedResourceConflictError({
3621
3902
  resourceType: GENIE_RESOURCE_TYPE,
@@ -4333,19 +4614,19 @@ var DatabricksGenieClient = class {
4333
4614
  this.agentId = resolveAgentId(options);
4334
4615
  this.previewClient = options.previewClient;
4335
4616
  this.basePath = `/api/2.0/genie/spaces/${enc2(this.agentId)}`;
4336
- this.pollIntervalMs = positiveInteger2(options.pollIntervalMs ?? 2e3, "pollIntervalMs");
4337
- this.timeoutMs = positiveInteger2(options.timeoutMs ?? 12e4, "timeoutMs");
4617
+ this.pollIntervalMs = positiveInteger3(options.pollIntervalMs ?? 2e3, "pollIntervalMs");
4618
+ this.timeoutMs = positiveInteger3(options.timeoutMs ?? 12e4, "timeoutMs");
4338
4619
  this.pollJitterRatio = boundedRatio(options.pollJitterRatio ?? 0.2, "pollJitterRatio");
4339
- this.maxAttachments = positiveInteger2(options.maxAttachments ?? 32, "maxAttachments");
4620
+ this.maxAttachments = positiveInteger3(options.maxAttachments ?? 32, "maxAttachments");
4340
4621
  this.maxUnknownAttachments = nonNegativeInteger(
4341
4622
  options.maxUnknownAttachments ?? 8,
4342
4623
  "maxUnknownAttachments"
4343
4624
  );
4344
- this.maxResultBytes = positiveInteger2(
4625
+ this.maxResultBytes = positiveInteger3(
4345
4626
  options.maxResultBytes ?? 2 * 1024 * 1024,
4346
4627
  "maxResultBytes"
4347
4628
  );
4348
- this.maxTextChars = positiveInteger2(options.maxTextChars ?? 1e5, "maxTextChars");
4629
+ this.maxTextChars = positiveInteger3(options.maxTextChars ?? 1e5, "maxTextChars");
4349
4630
  }
4350
4631
  agentId;
4351
4632
  basePath;
@@ -4680,7 +4961,7 @@ function nonEmpty3(value, name) {
4680
4961
  if (!normalized) throw new Error(`Databricks Genie ${name} cannot be empty.`);
4681
4962
  return normalized;
4682
4963
  }
4683
- function positiveInteger2(value, name) {
4964
+ function positiveInteger3(value, name) {
4684
4965
  if (!Number.isInteger(value) || value <= 0)
4685
4966
  throw new Error(`Databricks Genie ${name} must be a positive integer.`);
4686
4967
  return value;
@@ -20905,7 +21186,10 @@ function serializeTask(task) {
20905
21186
  policyId: task.newCluster.policyId,
20906
21187
  sparkVersion: task.newCluster.sparkVersion,
20907
21188
  nodeTypeId: task.newCluster.nodeTypeId,
20908
- numWorkers: task.newCluster.numWorkers,
21189
+ size: {
21190
+ $case: "numWorkers",
21191
+ numWorkers: task.newCluster.numWorkers
21192
+ },
20909
21193
  ...task.newCluster.customTags ? { customTags: task.newCluster.customTags } : {}
20910
21194
  } }
20911
21195
  } : {}
@@ -55713,13 +55997,7 @@ function stableDatabricksSdkClients(clients) {
55713
55997
  return sdk;
55714
55998
  }
55715
55999
  function createDatabricksNativeClients(options) {
55716
- const clientOptions = {
55717
- host: options.host,
55718
- credentials: options.credentials,
55719
- httpClient: fabricHttpClient(options.fetchImpl ?? fetch, options.extraHeaders),
55720
- profileOptions: { noProfile: true, disableEnv: true },
55721
- ...options.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {}
55722
- };
56000
+ const clientOptions = generatedClientOptions(options);
55723
56001
  return {
55724
56002
  jobs: new JobsClient(clientOptions),
55725
56003
  statements: new StatementExecutionClient(clientOptions),
@@ -55746,6 +56024,18 @@ function createDatabricksNativeClients(options) {
55746
56024
  })
55747
56025
  };
55748
56026
  }
56027
+ function createDatabricksScimClient(options) {
56028
+ return new ScimClient(generatedClientOptions(options));
56029
+ }
56030
+ function generatedClientOptions(options) {
56031
+ return {
56032
+ host: options.host,
56033
+ credentials: options.credentials,
56034
+ httpClient: fabricHttpClient(options.fetchImpl ?? fetch, options.extraHeaders),
56035
+ profileOptions: { noProfile: true, disableEnv: true },
56036
+ ...options.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {}
56037
+ };
56038
+ }
55749
56039
  function fabricHttpClient(fetchImpl, extraHeaders) {
55750
56040
  return {
55751
56041
  async send(request) {
@@ -56078,6 +56368,151 @@ function databricksLakeflowTools(client) {
56078
56368
  ];
56079
56369
  }
56080
56370
 
56371
+ // src/mlflow-tracing.ts
56372
+ import { createHash } from "crypto";
56373
+ import { eventToTelemetrySpan } from "@fabric-harness/sdk";
56374
+ function mlflowTraceExporter(options) {
56375
+ const onError = options.onError ?? ((context, error51) => {
56376
+ console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
56377
+ });
56378
+ const buffers = /* @__PURE__ */ new Map();
56379
+ return {
56380
+ sink: {
56381
+ record(event) {
56382
+ try {
56383
+ const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
56384
+ if (event.type === "submission_started") {
56385
+ buffers.set(key, {
56386
+ submissionId: event.submissionId,
56387
+ agent: event.agent,
56388
+ instanceId: event.instanceId,
56389
+ session: event.session,
56390
+ startedAtMs: event.at,
56391
+ attemptCount: event.attemptCount,
56392
+ ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
56393
+ spans: []
56394
+ });
56395
+ return;
56396
+ }
56397
+ if (event.type !== "submission_settled") return;
56398
+ const buffer = buffers.get(key);
56399
+ buffers.delete(key);
56400
+ const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
56401
+ const attemptCount = event.attemptCount ?? buffer?.attemptCount;
56402
+ const trace = buildMlflowTrace({
56403
+ submissionId: event.submissionId,
56404
+ agent: event.agent,
56405
+ instanceId: event.instanceId,
56406
+ session: event.session,
56407
+ experimentId: options.experimentId,
56408
+ startedAtMs,
56409
+ settledAtMs: event.at,
56410
+ state: event.outcome === "completed" ? "OK" : "ERROR",
56411
+ spans: buffer?.spans ?? [],
56412
+ ...attemptCount !== void 0 ? { attemptCount } : {},
56413
+ ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
56414
+ ...event.error !== void 0 ? { error: event.error } : {}
56415
+ });
56416
+ void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
56417
+ } catch (error51) {
56418
+ onError("telemetry event handling failed", error51);
56419
+ }
56420
+ }
56421
+ },
56422
+ onEvent(event) {
56423
+ try {
56424
+ if (!event.sessionId) return;
56425
+ const buffer = buffers.get(event.sessionId);
56426
+ if (!buffer) return;
56427
+ const span = eventToTelemetrySpan(event);
56428
+ if (span) buffer.spans.push(span);
56429
+ } catch (error51) {
56430
+ onError("event buffering failed", error51);
56431
+ }
56432
+ }
56433
+ };
56434
+ }
56435
+ function buildMlflowTrace(input) {
56436
+ const traceBytes = sha256(input.submissionId).subarray(0, 16);
56437
+ const traceIdBase64 = traceBytes.toString("base64");
56438
+ const rootSpanId = spanIdFor(input.submissionId, 0);
56439
+ const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
56440
+ const rootSpan = {
56441
+ trace_id: traceIdBase64,
56442
+ span_id: rootSpanId,
56443
+ name: `fabric.submission ${input.agent}`,
56444
+ start_time_unix_nano: toUnixNano(input.startedAtMs),
56445
+ end_time_unix_nano: toUnixNano(input.settledAtMs),
56446
+ attributes: toOtlpAttributes({
56447
+ "fabric.submission_id": input.submissionId,
56448
+ "fabric.agent": input.agent,
56449
+ "fabric.instance_id": input.instanceId,
56450
+ "fabric.session": input.session,
56451
+ ...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
56452
+ ...input.error !== void 0 ? { "fabric.error": input.error } : {}
56453
+ }),
56454
+ status: {
56455
+ code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
56456
+ ...input.error !== void 0 ? { message: input.error } : {}
56457
+ }
56458
+ };
56459
+ const childSpans = input.spans.map(
56460
+ (span, index) => ({
56461
+ trace_id: traceIdBase64,
56462
+ span_id: spanIdFor(input.submissionId, index + 1),
56463
+ parent_span_id: rootSpanId,
56464
+ name: span.name,
56465
+ start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
56466
+ end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
56467
+ attributes: toOtlpAttributes(span.attributes),
56468
+ status: { code: "STATUS_CODE_OK" }
56469
+ })
56470
+ );
56471
+ return {
56472
+ trace: {
56473
+ trace_info: {
56474
+ trace_id: `tr-${traceBytes.toString("hex")}`,
56475
+ trace_location: {
56476
+ type: "MLFLOW_EXPERIMENT",
56477
+ mlflow_experiment: { experiment_id: input.experimentId }
56478
+ },
56479
+ request_time: new Date(input.startedAtMs).toISOString(),
56480
+ execution_duration: `${durationSeconds.toFixed(3)}s`,
56481
+ state: input.state,
56482
+ trace_metadata: {
56483
+ "fabric.submission_id": input.submissionId,
56484
+ "fabric.agent": input.agent,
56485
+ "fabric.instance_id": input.instanceId,
56486
+ "fabric.session": input.session,
56487
+ ...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
56488
+ },
56489
+ tags: {
56490
+ "fabric.agent": input.agent,
56491
+ ...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
56492
+ }
56493
+ },
56494
+ trace_data: { spans: [rootSpan, ...childSpans] }
56495
+ }
56496
+ };
56497
+ }
56498
+ function sha256(seed) {
56499
+ return createHash("sha256").update(seed).digest();
56500
+ }
56501
+ function spanIdFor(submissionId, index) {
56502
+ return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
56503
+ }
56504
+ function toUnixNano(epochMs) {
56505
+ return `${Math.round(epochMs)}000000`;
56506
+ }
56507
+ function toOtlpAttributes(attributes) {
56508
+ return Object.entries(attributes).map(([key, value]) => {
56509
+ if (typeof value === "number") {
56510
+ return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
56511
+ }
56512
+ return { key, value: { string_value: String(value) } };
56513
+ });
56514
+ }
56515
+
56081
56516
  // src/model.ts
56082
56517
  import {
56083
56518
  OpenAICompatibleModelProvider,
@@ -56364,11 +56799,19 @@ var DatabricksServingAdmin = class {
56364
56799
  });
56365
56800
  }
56366
56801
  updateAiGateway(name, update) {
56802
+ const rateLimits = update.rateLimits?.map((limit) => ({
56803
+ ...limit.calls !== void 0 ? { calls: positiveBigInt(limit.calls, "rateLimits.calls") } : {},
56804
+ ...limit.tokens !== void 0 ? { tokens: positiveBigInt(limit.tokens, "rateLimits.tokens") } : {},
56805
+ ...limit.key !== void 0 ? { key: limit.key } : {},
56806
+ ...limit.renewalPeriod !== void 0 ? { renewalPeriod: limit.renewalPeriod } : {},
56807
+ ...limit.principal !== void 0 ? { principal: limit.principal } : {}
56808
+ }));
56367
56809
  return this.client.putInferenceEndpointAiGateway({
56368
56810
  name,
56369
- ...update.rateLimits ? { rateLimits: update.rateLimits } : {},
56811
+ ...rateLimits ? { rateLimits } : {},
56370
56812
  ...update.guardrails ? { guardrails: update.guardrails } : {},
56371
- ...update.usageTracking ? { inferenceTableConfig: update.usageTracking } : {},
56813
+ ...update.inferenceTableConfig ? { inferenceTableConfig: update.inferenceTableConfig } : {},
56814
+ ...update.usageTrackingConfig ? { usageTrackingConfig: update.usageTrackingConfig } : {},
56372
56815
  ...update.fallbackEnabled !== void 0 ? { fallbackConfig: { enabled: update.fallbackEnabled } } : {}
56373
56816
  });
56374
56817
  }
@@ -56455,6 +56898,11 @@ function validate(spec) {
56455
56898
  throw new Error("databricks serving: provisionedModelUnits must be a positive integer.");
56456
56899
  }
56457
56900
  }
56901
+ function positiveBigInt(value, name) {
56902
+ if (!Number.isSafeInteger(value) || value <= 0)
56903
+ throw new Error(`databricks serving: ${name} must be a positive safe integer.`);
56904
+ return BigInt(value);
56905
+ }
56458
56906
  function serialize2(spec) {
56459
56907
  return {
56460
56908
  name: spec.name,
@@ -56602,9 +57050,23 @@ function gatewaySchema() {
56602
57050
  additionalProperties: false,
56603
57051
  properties: {
56604
57052
  name: { type: "string" },
56605
- rateLimits: { type: "array", items: { type: "object", additionalProperties: true } },
57053
+ rateLimits: {
57054
+ type: "array",
57055
+ items: {
57056
+ type: "object",
57057
+ additionalProperties: false,
57058
+ properties: {
57059
+ calls: { type: "integer", minimum: 1 },
57060
+ tokens: { type: "integer", minimum: 1 },
57061
+ key: { type: "string" },
57062
+ renewalPeriod: { type: "string" },
57063
+ principal: { type: "string" }
57064
+ }
57065
+ }
57066
+ },
56606
57067
  guardrails: { type: "object", additionalProperties: true },
56607
- usageTracking: { type: "object", additionalProperties: true },
57068
+ inferenceTableConfig: { type: "object", additionalProperties: true },
57069
+ usageTrackingConfig: { type: "object", additionalProperties: true },
56608
57070
  fallbackEnabled: { type: "boolean" }
56609
57071
  },
56610
57072
  required: ["name"]
@@ -57365,221 +57827,6 @@ function base643(value) {
57365
57827
  return btoa(String.fromCharCode(...bytes));
57366
57828
  }
57367
57829
 
57368
- // src/agent-services.ts
57369
- var DATABRICKS_AGENT_SERVICES_API = "/api/2.1/unity-catalog/agent-services";
57370
- var DATABRICKS_AGENT_SERVICE_SECURABLE = "AGENT_SERVICE";
57371
- var DatabricksAgentServices = class {
57372
- constructor(client, options) {
57373
- this.client = client;
57374
- if (options.acknowledgeBeta !== true) {
57375
- throw new Error("databricks agent services: acknowledgeBeta must be true.");
57376
- }
57377
- }
57378
- create(options) {
57379
- const catalog = ucIdentifier(options.catalog, "catalog");
57380
- const schema = ucIdentifier(options.schema, "schema");
57381
- const id = ucIdentifier(options.id, "agent service id");
57382
- const basePath = externalBasePath(options.basePath ?? "/responses");
57383
- return this.client.post(
57384
- DATABRICKS_AGENT_SERVICES_API,
57385
- {
57386
- agent_service_type: "AGENT_SERVICE_TYPE_EXTERNAL",
57387
- ...options.comment !== void 0 ? { comment: options.comment } : {},
57388
- config: {
57389
- connection: { name: connectionResourceName(options.connection) },
57390
- base_path: basePath,
57391
- ...options.systemPrompt !== void 0 ? { system_prompt: options.systemPrompt } : {}
57392
- }
57393
- },
57394
- { parent: `schemas/${catalog}.${schema}`, agent_service_id: id },
57395
- { retry: "never" }
57396
- );
57397
- }
57398
- get(fullName) {
57399
- return this.client.get(agentServicePath(fullName));
57400
- }
57401
- list(options = {}) {
57402
- if (options.catalog === void 0 !== (options.schema === void 0)) {
57403
- throw new Error("databricks agent services: catalog and schema must be provided together.");
57404
- }
57405
- const parent = options.catalog && options.schema ? `schemas/${ucIdentifier(options.catalog, "catalog")}.${ucIdentifier(options.schema, "schema")}` : void 0;
57406
- return this.client.get(DATABRICKS_AGENT_SERVICES_API, {
57407
- parent,
57408
- page_token: options.pageToken
57409
- });
57410
- }
57411
- update(fullName, options) {
57412
- const mask = [];
57413
- const config2 = {};
57414
- const body = {};
57415
- if (options.comment !== void 0) {
57416
- mask.push("comment");
57417
- body.comment = options.comment;
57418
- }
57419
- if (options.basePath !== void 0) {
57420
- mask.push("config.base_path");
57421
- config2.base_path = externalBasePath(options.basePath);
57422
- }
57423
- if (options.systemPrompt !== void 0) {
57424
- mask.push("config.system_prompt");
57425
- config2.system_prompt = options.systemPrompt;
57426
- }
57427
- if (mask.length === 0) {
57428
- throw new Error(
57429
- "databricks agent services: update requires comment, basePath or systemPrompt."
57430
- );
57431
- }
57432
- if (Object.keys(config2).length > 0) body.config = config2;
57433
- return this.client.request(
57434
- "PATCH",
57435
- agentServicePath(fullName),
57436
- body,
57437
- { update_mask: mask.join(",") },
57438
- { retry: "safe" }
57439
- );
57440
- }
57441
- delete(fullName) {
57442
- return this.client.request(
57443
- "DELETE",
57444
- agentServicePath(fullName),
57445
- void 0,
57446
- {},
57447
- { retry: "never" }
57448
- );
57449
- }
57450
- permissions(fullName) {
57451
- return this.client.get(permissionsPath(fullName));
57452
- }
57453
- updatePermissions(fullName, changes) {
57454
- if (changes.length === 0) {
57455
- throw new Error("databricks agent services: at least one permission change is required.");
57456
- }
57457
- for (const change of changes) {
57458
- if (!change.principal.trim())
57459
- throw new Error("databricks agent services: principal cannot be empty.");
57460
- if ((change.add?.length ?? 0) === 0 && (change.remove?.length ?? 0) === 0) {
57461
- throw new Error(
57462
- `databricks agent services: ${change.principal} has no privileges to add or remove.`
57463
- );
57464
- }
57465
- }
57466
- return this.client.request(
57467
- "PATCH",
57468
- permissionsPath(fullName),
57469
- { changes },
57470
- {},
57471
- { retry: "safe" }
57472
- );
57473
- }
57474
- grant(fullName, principal, privileges = ["EXECUTE"]) {
57475
- return this.updatePermissions(fullName, [{ principal, add: privileges }]);
57476
- }
57477
- revoke(fullName, principal, privileges = ["EXECUTE"]) {
57478
- return this.updatePermissions(fullName, [{ principal, remove: privileges }]);
57479
- }
57480
- };
57481
- function databricksAgentServices(client, options) {
57482
- return new DatabricksAgentServices(client, options);
57483
- }
57484
- function agentServicePath(fullName) {
57485
- return `${DATABRICKS_AGENT_SERVICES_API}/${encodeURIComponent(fullUcName(fullName))}`;
57486
- }
57487
- function permissionsPath(fullName) {
57488
- return `/api/2.1/unity-catalog/permissions/${DATABRICKS_AGENT_SERVICE_SECURABLE}/${encodeURIComponent(fullUcName(fullName))}`;
57489
- }
57490
- function fullUcName(value) {
57491
- const parts = value.split(".");
57492
- if (parts.length !== 3) {
57493
- throw new Error(
57494
- `databricks agent services: expected catalog.schema.service, received ${value}.`
57495
- );
57496
- }
57497
- return parts.map(
57498
- (part, index) => ucIdentifier(part, ["catalog", "schema", "service"][index] ?? "identifier")
57499
- ).join(".");
57500
- }
57501
- function connectionResourceName(value) {
57502
- const trimmed = value.trim();
57503
- const name = trimmed.startsWith("connections/") ? trimmed.slice("connections/".length) : trimmed;
57504
- const parts = name.split(".");
57505
- if (parts.length !== 1 && parts.length !== 3) {
57506
- throw new Error(
57507
- `databricks agent services: expected connection name or catalog.schema.connection, received ${value}.`
57508
- );
57509
- }
57510
- return `connections/${parts.map(
57511
- (part, index) => ucIdentifier(
57512
- part,
57513
- parts.length === 1 ? "connection" : ["catalog", "schema", "connection"][index] ?? "identifier"
57514
- )
57515
- ).join(".")}`;
57516
- }
57517
- function externalBasePath(value) {
57518
- const path = value.trim();
57519
- if (!path.startsWith("/") || path.startsWith("//") || path.includes("?") || path.includes("#")) {
57520
- throw new Error(
57521
- "databricks agent services: basePath must be an absolute URL path without a query or fragment."
57522
- );
57523
- }
57524
- return path;
57525
- }
57526
- function ucIdentifier(value, label) {
57527
- const normalized = value.trim();
57528
- if (!/^[A-Za-z0-9_][A-Za-z0-9_$-]*$/.test(normalized)) {
57529
- throw new Error(`databricks agent services: invalid ${label} ${JSON.stringify(value)}.`);
57530
- }
57531
- return normalized;
57532
- }
57533
-
57534
- // src/ai-gateway.ts
57535
- async function ensureDatabricksAiGateway(client) {
57536
- await client.get("/api/ai-gateway/v2/endpoints", { page_size: 1 });
57537
- }
57538
- async function listDatabricksModelServices(client, options = {}) {
57539
- const pageSize = positiveInteger3(options.pageSize ?? 100, "pageSize");
57540
- const maxPages = positiveInteger3(options.maxPages ?? 100, "maxPages");
57541
- const requiredPrefix = options.requiredPrefix ?? "system.ai.";
57542
- const services = /* @__PURE__ */ new Map();
57543
- const seenTokens = /* @__PURE__ */ new Set();
57544
- let pageToken;
57545
- for (let page = 0; page < maxPages; page += 1) {
57546
- const response = await client.get(
57547
- "/api/2.1/unity-catalog/model-services",
57548
- { page_size: pageSize, ...pageToken ? { page_token: pageToken } : {} }
57549
- );
57550
- for (const raw of response.model_services ?? []) {
57551
- const service = normalizeModelService(raw, requiredPrefix);
57552
- if (service) services.set(service.name, service);
57553
- }
57554
- const next = response.next_page_token?.trim();
57555
- if (!next) return [...services.values()].sort((a2, b2) => a2.name.localeCompare(b2.name));
57556
- if (seenTokens.has(next))
57557
- throw new Error(
57558
- `databricks model-services pagination repeated token after page ${page + 1}.`
57559
- );
57560
- seenTokens.add(next);
57561
- pageToken = next;
57562
- }
57563
- throw new Error(`databricks model-services pagination exceeded ${maxPages} pages.`);
57564
- }
57565
- function normalizeModelService(raw, requiredPrefix) {
57566
- const rawName = typeof raw.name === "string" ? raw.name.trim() : "";
57567
- const name = rawName.replace(/^model-services\//, "");
57568
- if (!name.startsWith(requiredPrefix)) return void 0;
57569
- return {
57570
- name,
57571
- ...typeof raw.comment === "string" ? { comment: raw.comment } : {},
57572
- ...typeof raw.creator === "string" ? { creator: raw.creator } : {},
57573
- ...typeof raw.created_at === "number" ? { createdAt: raw.created_at } : {},
57574
- ...typeof raw.updated_at === "number" ? { updatedAt: raw.updated_at } : {}
57575
- };
57576
- }
57577
- function positiveInteger3(value, name) {
57578
- if (!Number.isSafeInteger(value) || value <= 0)
57579
- throw new Error(`${name} must be a positive integer.`);
57580
- return value;
57581
- }
57582
-
57583
57830
  // src/persistence.ts
57584
57831
  function databricksPersistence(options) {
57585
57832
  const client = isLakebaseClient(options.lakebase) ? options.lakebase : lakebaseClient(options.lakebase);
@@ -58067,6 +58314,7 @@ function databricksApp(options = {}) {
58067
58314
  ...persistence ? { persistence } : {},
58068
58315
  ...telemetry ? { telemetry } : {},
58069
58316
  ...attachmentStore ? { attachmentStore } : {},
58317
+ mlflowTraceExporter: (traceOptions) => mlflowTraceExporter({ client: native.preview, ...traceOptions }),
58070
58318
  async serverOptions() {
58071
58319
  if (!persistence) return attachmentStore ? { attachmentStore } : {};
58072
58320
  const { store, submissionStore, conversationStreamStore } = await persistence.connectAll();
@@ -58100,7 +58348,7 @@ function parseInferenceMode(value) {
58100
58348
  }
58101
58349
 
58102
58350
  // src/app-user-authorization.ts
58103
- import { createHash } from "crypto";
58351
+ import { createHash as createHash2 } from "crypto";
58104
58352
  var DATABRICKS_APP_USER_PERMISSIONS = [
58105
58353
  "agent:invoke",
58106
58354
  "approval:read",
@@ -58122,7 +58370,7 @@ function createDatabricksAppUserAuthenticator(options) {
58122
58370
  if (!delegated) return void 0;
58123
58371
  const now = options.now?.() ?? Date.now();
58124
58372
  const token = await databricksIdentity(delegated)();
58125
- const digest = createHash("sha256").update(token).digest("hex");
58373
+ const digest = createHash2("sha256").update(token).digest("hex");
58126
58374
  const cached4 = cache.get(digest);
58127
58375
  if (cached4 && cached4.expiresAt > now) return cached4.principal;
58128
58376
  try {
@@ -58133,7 +58381,7 @@ function createDatabricksAppUserAuthenticator(options) {
58133
58381
  ...options.now ? { now: options.now } : {}
58134
58382
  });
58135
58383
  const id = inspection.principal.id;
58136
- const tenantId = options.tenantId?.(inspection) ?? `databricks-user:${createHash("sha256").update(id).digest("hex").slice(0, 24)}`;
58384
+ const tenantId = options.tenantId?.(inspection) ?? `databricks-user:${createHash2("sha256").update(id).digest("hex").slice(0, 24)}`;
58137
58385
  if (!tenantId) return false;
58138
58386
  const principal = {
58139
58387
  id,
@@ -58160,15 +58408,19 @@ async function inspectDatabricksAppUserAuthorization(options) {
58160
58408
  const delegated = onBehalfOfFromHeaders(options.headers);
58161
58409
  if (!delegated) throw new Error("Databricks App request did not include user authorization.");
58162
58410
  const token = await databricksIdentity(delegated)();
58163
- const fetchImpl = options.fetchImpl ?? fetch;
58164
- const response = await fetchImpl(
58165
- `${databricksWorkspaceOrigin(options.host)}/api/2.0/preview/scim/v2/Me`,
58166
- { headers: { authorization: `Bearer ${token}` } }
58167
- );
58168
- if (!response.ok) {
58169
- throw new Error(`Databricks App user authorization validation returned ${response.status}.`);
58411
+ let identity;
58412
+ try {
58413
+ identity = await createDatabricksScimClient({
58414
+ host: options.host,
58415
+ credentials: databricksCredentials(delegated),
58416
+ ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {}
58417
+ }).me({});
58418
+ } catch (error51) {
58419
+ const status = typeof error51 === "object" && error51 !== null && "httpStatusCode" in error51 ? Number(error51.httpStatusCode) : void 0;
58420
+ throw new Error(
58421
+ `Databricks App user authorization validation returned ${Number.isFinite(status) ? status : "an error"}.`
58422
+ );
58170
58423
  }
58171
- const identity = await response.json();
58172
58424
  const id = typeof identity.id === "string" ? identity.id : typeof identity.userName === "string" ? identity.userName : void 0;
58173
58425
  if (!id) throw new Error("Databricks current-user response did not include an identity.");
58174
58426
  const claims = jwtLifetimeClaims(token);
@@ -58205,151 +58457,6 @@ function jwtLifetimeClaims(token) {
58205
58457
  }
58206
58458
  }
58207
58459
 
58208
- // src/mlflow-tracing.ts
58209
- import { createHash as createHash2 } from "crypto";
58210
- import { eventToTelemetrySpan } from "@fabric-harness/sdk";
58211
- function mlflowTraceExporter(options) {
58212
- const onError = options.onError ?? ((context, error51) => {
58213
- console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
58214
- });
58215
- const buffers = /* @__PURE__ */ new Map();
58216
- return {
58217
- sink: {
58218
- record(event) {
58219
- try {
58220
- const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
58221
- if (event.type === "submission_started") {
58222
- buffers.set(key, {
58223
- submissionId: event.submissionId,
58224
- agent: event.agent,
58225
- instanceId: event.instanceId,
58226
- session: event.session,
58227
- startedAtMs: event.at,
58228
- attemptCount: event.attemptCount,
58229
- ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
58230
- spans: []
58231
- });
58232
- return;
58233
- }
58234
- if (event.type !== "submission_settled") return;
58235
- const buffer = buffers.get(key);
58236
- buffers.delete(key);
58237
- const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
58238
- const attemptCount = event.attemptCount ?? buffer?.attemptCount;
58239
- const trace = buildMlflowTrace({
58240
- submissionId: event.submissionId,
58241
- agent: event.agent,
58242
- instanceId: event.instanceId,
58243
- session: event.session,
58244
- experimentId: options.experimentId,
58245
- startedAtMs,
58246
- settledAtMs: event.at,
58247
- state: event.outcome === "completed" ? "OK" : "ERROR",
58248
- spans: buffer?.spans ?? [],
58249
- ...attemptCount !== void 0 ? { attemptCount } : {},
58250
- ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
58251
- ...event.error !== void 0 ? { error: event.error } : {}
58252
- });
58253
- void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
58254
- } catch (error51) {
58255
- onError("telemetry event handling failed", error51);
58256
- }
58257
- }
58258
- },
58259
- onEvent(event) {
58260
- try {
58261
- if (!event.sessionId) return;
58262
- const buffer = buffers.get(event.sessionId);
58263
- if (!buffer) return;
58264
- const span = eventToTelemetrySpan(event);
58265
- if (span) buffer.spans.push(span);
58266
- } catch (error51) {
58267
- onError("event buffering failed", error51);
58268
- }
58269
- }
58270
- };
58271
- }
58272
- function buildMlflowTrace(input) {
58273
- const traceBytes = sha256(input.submissionId).subarray(0, 16);
58274
- const traceIdBase64 = traceBytes.toString("base64");
58275
- const rootSpanId = spanIdFor(input.submissionId, 0);
58276
- const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
58277
- const rootSpan = {
58278
- trace_id: traceIdBase64,
58279
- span_id: rootSpanId,
58280
- name: `fabric.submission ${input.agent}`,
58281
- start_time_unix_nano: toUnixNano(input.startedAtMs),
58282
- end_time_unix_nano: toUnixNano(input.settledAtMs),
58283
- attributes: toOtlpAttributes({
58284
- "fabric.submission_id": input.submissionId,
58285
- "fabric.agent": input.agent,
58286
- "fabric.instance_id": input.instanceId,
58287
- "fabric.session": input.session,
58288
- ...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
58289
- ...input.error !== void 0 ? { "fabric.error": input.error } : {}
58290
- }),
58291
- status: {
58292
- code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
58293
- ...input.error !== void 0 ? { message: input.error } : {}
58294
- }
58295
- };
58296
- const childSpans = input.spans.map(
58297
- (span, index) => ({
58298
- trace_id: traceIdBase64,
58299
- span_id: spanIdFor(input.submissionId, index + 1),
58300
- parent_span_id: rootSpanId,
58301
- name: span.name,
58302
- start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
58303
- end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
58304
- attributes: toOtlpAttributes(span.attributes),
58305
- status: { code: "STATUS_CODE_OK" }
58306
- })
58307
- );
58308
- return {
58309
- trace: {
58310
- trace_info: {
58311
- trace_id: `tr-${traceBytes.toString("hex")}`,
58312
- trace_location: {
58313
- type: "MLFLOW_EXPERIMENT",
58314
- mlflow_experiment: { experiment_id: input.experimentId }
58315
- },
58316
- request_time: new Date(input.startedAtMs).toISOString(),
58317
- execution_duration: `${durationSeconds.toFixed(3)}s`,
58318
- state: input.state,
58319
- trace_metadata: {
58320
- "fabric.submission_id": input.submissionId,
58321
- "fabric.agent": input.agent,
58322
- "fabric.instance_id": input.instanceId,
58323
- "fabric.session": input.session,
58324
- ...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
58325
- },
58326
- tags: {
58327
- "fabric.agent": input.agent,
58328
- ...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
58329
- }
58330
- },
58331
- trace_data: { spans: [rootSpan, ...childSpans] }
58332
- }
58333
- };
58334
- }
58335
- function sha256(seed) {
58336
- return createHash2("sha256").update(seed).digest();
58337
- }
58338
- function spanIdFor(submissionId, index) {
58339
- return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
58340
- }
58341
- function toUnixNano(epochMs) {
58342
- return `${Math.round(epochMs)}000000`;
58343
- }
58344
- function toOtlpAttributes(attributes) {
58345
- return Object.entries(attributes).map(([key, value]) => {
58346
- if (typeof value === "number") {
58347
- return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
58348
- }
58349
- return { key, value: { string_value: String(value) } };
58350
- });
58351
- }
58352
-
58353
58460
  // src/serving-usage.ts
58354
58461
  import { currentSubmissionContext as currentSubmissionContext3, emitSubmissionTelemetry } from "@fabric-harness/sdk";
58355
58462
  function servingUsageCapture(options) {
@@ -58718,7 +58825,12 @@ function createDatabricksAuthoringCertificationChecks(fixtures) {
58718
58825
  check2(
58719
58826
  "jobs-authoring",
58720
58827
  fixtures.enabled && Boolean(fixtures.jobs),
58721
- () => jobsLifecycle(fixtures)
58828
+ () => jobsLifecycle(fixtures, requiredFixture(fixtures.jobs, "jobs"), "job")
58829
+ ),
58830
+ check2(
58831
+ "jobs-classic-authoring",
58832
+ fixtures.enabled && Boolean(fixtures.classicJobs),
58833
+ () => jobsLifecycle(fixtures, requiredFixture(fixtures.classicJobs, "classicJobs"), "classic-job")
58722
58834
  ),
58723
58835
  check2(
58724
58836
  "lakeflow-authoring",
@@ -58728,12 +58840,22 @@ function createDatabricksAuthoringCertificationChecks(fixtures) {
58728
58840
  check2(
58729
58841
  "ai-search-admin",
58730
58842
  fixtures.enabled && Boolean(fixtures.aiSearch),
58731
- () => aiSearchLifecycle(fixtures)
58843
+ () => aiSearchLifecycle(fixtures, requiredFixture(fixtures.aiSearch, "aiSearch"), "ai-search-endpoint")
58844
+ ),
58845
+ check2(
58846
+ "ai-search-delta-sync-admin",
58847
+ fixtures.enabled && Boolean(fixtures.deltaAiSearch),
58848
+ () => aiSearchLifecycle(fixtures, requiredFixture(fixtures.deltaAiSearch, "deltaAiSearch"), "ai-search-delta-sync-endpoint")
58732
58849
  ),
58733
58850
  check2(
58734
58851
  "serving-admin",
58735
58852
  fixtures.enabled && Boolean(fixtures.serving),
58736
- () => servingLifecycle(fixtures)
58853
+ () => servingLifecycle(fixtures, requiredFixture(fixtures.serving, "serving"), "serving-endpoint")
58854
+ ),
58855
+ check2(
58856
+ "serving-provisioned-throughput-admin",
58857
+ fixtures.enabled && Boolean(fixtures.provisionedServing),
58858
+ () => servingLifecycle(fixtures, requiredFixture(fixtures.provisionedServing, "provisionedServing"), "serving-provisioned-throughput-endpoint")
58737
58859
  ),
58738
58860
  check2(
58739
58861
  "uc-admin-obo-execution",
@@ -58766,7 +58888,7 @@ function check2(id, configured, run) {
58766
58888
  };
58767
58889
  }
58768
58890
  function authoringEvidenceChecks(id) {
58769
- const prefix = id === "jobs-authoring" ? "jobs" : id === "lakeflow-authoring" ? "lakeflow" : id === "ai-search-admin" ? "ai-search-admin" : id === "serving-admin" ? "serving" : id === "uc-admin-obo-execution" ? "uc-admin" : id === "workspace-write" ? "workspace" : id === "secrets-write" ? "secrets" : id === "genie-authoring" ? "genie-authoring" : void 0;
58891
+ const prefix = id === "jobs-authoring" || id === "jobs-classic-authoring" ? "jobs" : id === "lakeflow-authoring" ? "lakeflow" : id === "ai-search-admin" || id === "ai-search-delta-sync-admin" ? "ai-search-admin" : id === "serving-admin" || id === "serving-provisioned-throughput-admin" ? "serving" : id === "uc-admin-obo-execution" ? "uc-admin" : id === "workspace-write" ? "workspace" : id === "secrets-write" ? "secrets" : id === "genie-authoring" ? "genie-authoring" : void 0;
58770
58892
  if (!prefix) return ["approval.request", "approval.consume", "lineage.write"];
58771
58893
  return [
58772
58894
  `${prefix}.create`,
@@ -58801,15 +58923,14 @@ async function approvalProvenance(fixtures) {
58801
58923
  throw new Error("Approval probe returned the wrong resource.");
58802
58924
  return runner.evidence();
58803
58925
  }
58804
- async function jobsLifecycle(fixtures) {
58805
- const config2 = requiredFixture(fixtures.jobs, "jobs");
58926
+ async function jobsLifecycle(fixtures, config2, kind) {
58806
58927
  const jobsClient = requiredFixture(fixtures.jobsClient, "jobs native SDK client");
58807
58928
  const runner = new GovernedCertificationRunner(fixtures);
58808
58929
  const tools = databricksJobsAuthoringTools(jobsClient, config2.computePolicy);
58809
58930
  const api = new DatabricksJobsAuthoring(jobsClient, config2.computePolicy);
58810
58931
  let jobId2 = 0;
58811
58932
  const lifecycle = await runDatabricksAuthoringLifecycle({
58812
- kind: "job",
58933
+ kind,
58813
58934
  create: async () => {
58814
58935
  const created = await runner.execute(
58815
58936
  findTool(tools, "databricks_create_job"),
@@ -58854,7 +58975,7 @@ async function lakeflowLifecycle(fixtures) {
58854
58975
  config2.spec
58855
58976
  ),
58856
58977
  identify: (created) => created.pipelineId,
58857
- verifyCreated: (created) => fixtures.client.get(`/api/2.0/pipelines/${encodeURIComponent(created.pipelineId)}`),
58978
+ verifyCreated: (created) => pipelinesClient.get({ pipelineId: created.pipelineId }),
58858
58979
  mutate: async (created) => {
58859
58980
  const name = config2.mutateName ?? `${config2.spec.name}-verified`;
58860
58981
  await runner.execute(findTool(tools, "databricks_update_pipeline"), {
@@ -58865,24 +58986,19 @@ async function lakeflowLifecycle(fixtures) {
58865
58986
  return name;
58866
58987
  },
58867
58988
  verifyMutated: async (created, name) => {
58868
- const row = await fixtures.client.get(
58869
- `/api/2.0/pipelines/${encodeURIComponent(created.pipelineId)}`
58870
- );
58871
- if (row.spec?.name !== name && row.name !== name)
58989
+ const row = await pipelinesClient.get({ pipelineId: created.pipelineId });
58990
+ if (row.spec?.name !== name)
58872
58991
  throw new Error("Lakeflow mutation was not observable.");
58873
58992
  },
58874
58993
  delete: (created) => runner.execute(findTool(tools, "databricks_delete_pipeline"), {
58875
58994
  pipelineId: created.pipelineId
58876
58995
  }),
58877
- verifyDeleted: (created) => expectNotFound(
58878
- () => fixtures.client.get(`/api/2.0/pipelines/${encodeURIComponent(created.pipelineId)}`)
58879
- )
58996
+ verifyDeleted: (created) => expectNotFound(() => pipelinesClient.get({ pipelineId: created.pipelineId }))
58880
58997
  });
58881
58998
  void api;
58882
58999
  return runner.evidence(lifecycle);
58883
59000
  }
58884
- async function aiSearchLifecycle(fixtures) {
58885
- const config2 = requiredFixture(fixtures.aiSearch, "aiSearch");
59001
+ async function aiSearchLifecycle(fixtures, config2, kind) {
58886
59002
  const vectorSearchClient = requiredFixture(
58887
59003
  fixtures.vectorSearchClient,
58888
59004
  "vector search native SDK client"
@@ -58891,7 +59007,7 @@ async function aiSearchLifecycle(fixtures) {
58891
59007
  const tools = databricksAiSearchAdminTools(vectorSearchClient);
58892
59008
  const api = new DatabricksAiSearchAdmin(vectorSearchClient);
58893
59009
  const lifecycle = await runDatabricksAuthoringLifecycle({
58894
- kind: "ai-search-endpoint",
59010
+ kind,
58895
59011
  create: async () => {
58896
59012
  await runner.execute(findTool(tools, "databricks_create_search_endpoint"), {
58897
59013
  name: config2.endpointName,
@@ -58922,8 +59038,7 @@ async function aiSearchLifecycle(fixtures) {
58922
59038
  });
58923
59039
  return runner.evidence(lifecycle);
58924
59040
  }
58925
- async function servingLifecycle(fixtures) {
58926
- const config2 = requiredFixture(fixtures.serving, "serving");
59041
+ async function servingLifecycle(fixtures, config2, kind) {
58927
59042
  const modelServingClient = requiredFixture(
58928
59043
  fixtures.modelServingClient,
58929
59044
  "model serving native SDK client"
@@ -58932,7 +59047,7 @@ async function servingLifecycle(fixtures) {
58932
59047
  const tools = databricksServingAdminTools(modelServingClient);
58933
59048
  const api = new DatabricksServingAdmin(modelServingClient);
58934
59049
  const lifecycle = await runDatabricksAuthoringLifecycle({
58935
- kind: "serving-endpoint",
59050
+ kind,
58936
59051
  create: async () => {
58937
59052
  await runner.execute(
58938
59053
  findTool(tools, "databricks_create_serving_endpoint"),
@@ -58963,7 +59078,8 @@ async function unityCatalogLifecycle(fixtures) {
58963
59078
  if (fixtures.executingPrincipal.ucPrincipal !== config2.oboPrincipal) {
58964
59079
  throw new Error("UC certification requires the executing OBO principal to match oboPrincipal.");
58965
59080
  }
58966
- const currentUser = await fixtures.client.get("/api/2.0/preview/scim/v2/Me");
59081
+ const scimClient = requiredFixture(fixtures.scimClient, "SCIM native SDK client");
59082
+ const currentUser = await scimClient.me({});
58967
59083
  if (currentUser.userName !== config2.oboPrincipal && currentUser.id !== fixtures.executingPrincipal.id) {
58968
59084
  throw new Error("UC certification OBO token resolved to a different Databricks principal.");
58969
59085
  }
@@ -58985,7 +59101,7 @@ async function unityCatalogLifecycle(fixtures) {
58985
59101
  return { id: fullName };
58986
59102
  },
58987
59103
  identify: (created) => created.id,
58988
- verifyCreated: () => fixtures.client.get(`/api/2.1/unity-catalog/schemas/${encodeURIComponent(fullName)}`),
59104
+ verifyCreated: () => unityCatalogClients.schemas.getSchema({ fullNameArg: fullName }),
58989
59105
  mutate: async () => {
58990
59106
  await runner.execute(findTool(tools, "databricks_grant"), {
58991
59107
  securableType: "schema",
@@ -58996,16 +59112,15 @@ async function unityCatalogLifecycle(fixtures) {
58996
59112
  return "USE_SCHEMA";
58997
59113
  },
58998
59114
  verifyMutated: async () => {
58999
- const permissions = await fixtures.client.get(
59000
- `/api/2.1/unity-catalog/permissions/schema/${encodeURIComponent(fullName)}`
59001
- );
59115
+ const permissions = await unityCatalogClients.grants.getPermissions({
59116
+ securableType: "schema",
59117
+ securableFullName: fullName
59118
+ });
59002
59119
  if (!JSON.stringify(permissions).includes(config2.oboPrincipal))
59003
59120
  throw new Error("UC grant was not observable for the OBO principal.");
59004
59121
  },
59005
59122
  delete: () => runner.execute(findTool(tools, "databricks_delete_uc_object"), { kind: "schema", fullName }),
59006
- verifyDeleted: () => expectNotFound(
59007
- () => fixtures.client.get(`/api/2.1/unity-catalog/schemas/${encodeURIComponent(fullName)}`)
59008
- )
59123
+ verifyDeleted: () => expectNotFound(() => unityCatalogClients.schemas.getSchema({ fullNameArg: fullName }))
59009
59124
  });
59010
59125
  return runner.evidence(lifecycle);
59011
59126
  }
@@ -59052,22 +59167,19 @@ async function secretsLifecycle(fixtures) {
59052
59167
  return { id: config2.scope };
59053
59168
  },
59054
59169
  identify: (created) => created.id,
59055
- verifyCreated: () => verifySecretScope(fixtures.client, config2.scope),
59170
+ verifyCreated: () => verifySecretScope(secretsClient, config2.scope),
59056
59171
  mutate: () => runner.execute(findTool(tools, "databricks_put_secret"), {
59057
59172
  scope: config2.scope,
59058
59173
  key: config2.key,
59059
59174
  secretRef: { kind: "secret", name: config2.secretName }
59060
59175
  }),
59061
59176
  verifyMutated: async () => {
59062
- const keys = await fixtures.client.get(
59063
- "/api/2.0/secrets/list",
59064
- { scope: config2.scope }
59065
- );
59177
+ const keys = await secretsClient.listSecrets({ scope: config2.scope });
59066
59178
  if (!keys.secrets?.some((row) => row.key === config2.key))
59067
59179
  throw new Error("Written secret key was not listed.");
59068
59180
  },
59069
59181
  delete: () => runner.execute(findTool(tools, "databricks_delete_secret_scope"), { scope: config2.scope }),
59070
- verifyDeleted: () => verifySecretScopeMissing(fixtures.client, config2.scope)
59182
+ verifyDeleted: () => verifySecretScopeMissing(secretsClient, config2.scope)
59071
59183
  });
59072
59184
  return runner.evidence(lifecycle);
59073
59185
  }
@@ -59173,16 +59285,12 @@ async function expectNotFound(operation) {
59173
59285
  throw new Error("Deleted Databricks resource is still readable.");
59174
59286
  }
59175
59287
  async function verifySecretScope(client, scope) {
59176
- const scopes = await client.get(
59177
- "/api/2.0/secrets/scopes/list"
59178
- );
59288
+ const scopes = await client.listScopes({});
59179
59289
  if (!scopes.scopes?.some((row) => row.name === scope))
59180
59290
  throw new Error("Created secret scope was not listed.");
59181
59291
  }
59182
59292
  async function verifySecretScopeMissing(client, scope) {
59183
- const scopes = await client.get(
59184
- "/api/2.0/secrets/scopes/list"
59185
- );
59293
+ const scopes = await client.listScopes({});
59186
59294
  if (scopes.scopes?.some((row) => row.name === scope))
59187
59295
  throw new Error("Deleted secret scope is still listed.");
59188
59296
  }
@@ -59190,6 +59298,20 @@ async function verifySecretScopeMissing(client, scope) {
59190
59298
  // src/certification-sweeper.ts
59191
59299
  var DATABRICKS_CERTIFICATION_RESOURCE_PREFIX = "fabric-harness-authoring-cert-";
59192
59300
  var DATABRICKS_CERTIFICATION_SQL_RESOURCE_PREFIX = "fabric_harness_authoring_cert_";
59301
+ function sweepDatabricksAuthoringCertificationWorkspace(options) {
59302
+ const tokenProvider = databricksIdentity(options.principal);
59303
+ const clients = createDatabricksNativeClients({
59304
+ host: options.host,
59305
+ credentials: databricksCredentials(options.principal),
59306
+ tokenProvider,
59307
+ ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {}
59308
+ });
59309
+ return sweepDatabricksAuthoringCertification(clients, {
59310
+ ...options.catalogs ? { catalogs: options.catalogs } : {},
59311
+ ...options.workspaceRoots ? { workspaceRoots: options.workspaceRoots } : {},
59312
+ ...options.dryRun !== void 0 ? { dryRun: options.dryRun } : {}
59313
+ });
59314
+ }
59193
59315
  async function sweepDatabricksAuthoringCertification(clients, options = {}) {
59194
59316
  const dryRun = options.dryRun ?? true;
59195
59317
  const discovered = [];
@@ -59315,8 +59437,9 @@ function isCertificationResource(id) {
59315
59437
  }
59316
59438
 
59317
59439
  // src/compatibility.ts
59440
+ var DATABRICKS_SDK_VERSION = VERSION;
59318
59441
  var DATABRICKS_API_VERSIONS = {
59319
- sdkJs: "0.21.0",
59442
+ sdkJs: DATABRICKS_SDK_VERSION,
59320
59443
  jobs: "2.2",
59321
59444
  sqlStatements: "2.0",
59322
59445
  unityCatalog: "2.1",
@@ -59334,7 +59457,7 @@ var DATABRICKS_API_VERSIONS = {
59334
59457
  var DATABRICKS_PACKAGE_COMPATIBILITY = {
59335
59458
  node: ">=22.0.0",
59336
59459
  package: "@fabric-harness/databricks",
59337
- packageRange: ">=3.0.0 <4",
59460
+ packageRange: ">=4.0.1 <5",
59338
59461
  pg: "^8.11.0 (only for Lakebase)"
59339
59462
  };
59340
59463
  var DATABRICKS_AUTH_MODES = [
@@ -59561,8 +59684,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
59561
59684
  {
59562
59685
  package: "@fabric-harness/databricks",
59563
59686
  exports: [
59564
- "ensureDatabricksAiGateway",
59565
- "listDatabricksModelServices",
59687
+ "databricks",
59566
59688
  "databricksFoundationModelProvider"
59567
59689
  ]
59568
59690
  }
@@ -59580,7 +59702,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
59580
59702
  certification: "contract",
59581
59703
  auth: ["oauth-m2m", "app-service-principal"],
59582
59704
  contractClouds: ALL_CLOUDS,
59583
- surfaces: [{ package: "@fabric-harness/databricks", exports: ["databricksAgentServices"] }],
59705
+ surfaces: [{ package: "@fabric-harness/databricks", exports: ["databricks"] }],
59584
59706
  requiredEvidence: [
59585
59707
  "agent-services.create",
59586
59708
  "agent-services.verify",
@@ -59625,7 +59747,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
59625
59747
  auth: ["oauth-m2m", "app-service-principal", "pat"],
59626
59748
  contractClouds: ALL_CLOUDS,
59627
59749
  surfaces: [
59628
- { package: "@fabric-harness/databricks", exports: ["mlflowTraceExporter", "scoreRagTurn"] }
59750
+ { package: "@fabric-harness/databricks", exports: ["databricks", "scoreRagTurn"] }
59629
59751
  ],
59630
59752
  requiredEvidence: ["mlflow.trace", "mlflow.evaluate"],
59631
59753
  evidenceIds: ["dbx-cert-d03df5a0a5b69a98d8acb0ad4c1e9ef9bcffefea7e433cbd2ba0ff3d792fec71"],
@@ -59712,7 +59834,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
59712
59834
  surfaces: [
59713
59835
  {
59714
59836
  package: "@fabric-harness/databricks",
59715
- exports: ["DatabricksGenieAdmin", "databricksGenieAuthoringTools"]
59837
+ exports: ["databricks", "serializeDatabricksGenieAgentSpec"]
59716
59838
  }
59717
59839
  ],
59718
59840
  docs: "/docs/databricks/authoring",
@@ -59738,7 +59860,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
59738
59860
  surfaces: [
59739
59861
  {
59740
59862
  package: "@fabric-harness/databricks",
59741
- exports: ["DatabricksGenieAgentModeClient", "databricksGenieAgentMode"]
59863
+ exports: ["databricks", "databricksGenieAgentModeTool"]
59742
59864
  }
59743
59865
  ],
59744
59866
  docs: "/docs/databricks/authoring",
@@ -59885,7 +60007,7 @@ var DATABRICKS_CAPABILITY_DEFINITIONS = [
59885
60007
  surfaces: [
59886
60008
  {
59887
60009
  package: "@fabric-harness/databricks",
59888
- exports: ["DatabricksWorkspaceAuthoring", "databricksWorkspaceAuthoringTools"]
60010
+ exports: ["databricks"]
59889
60011
  }
59890
60012
  ],
59891
60013
  docs: "/docs/databricks/authoring",
@@ -60680,6 +60802,7 @@ function buildDatabricksBundle(config2, scope) {
60680
60802
  });
60681
60803
  const client = native.preview;
60682
60804
  const genieAgentModeClient = genie.agentMode ? databricksGenieAgentMode(client, genie.agentMode) : void 0;
60805
+ const agentServicesClient = config2.agentServices ? databricksAgentServices(client, config2.agentServices) : void 0;
60683
60806
  let embeddings;
60684
60807
  let retriever;
60685
60808
  let searchTool;
@@ -60800,6 +60923,12 @@ function buildDatabricksBundle(config2, scope) {
60800
60923
  })
60801
60924
  } : {},
60802
60925
  ...genieAgentModeClient ? { genieAgentMode: genieAgentModeClient } : {},
60926
+ ...agentServicesClient ? { agentServices: agentServicesClient } : {},
60927
+ aiGateway: {
60928
+ ensure: () => ensureDatabricksAiGateway(client),
60929
+ listModelServices: (options) => listDatabricksModelServices(client, options)
60930
+ },
60931
+ mlflowTraceExporter: (options) => mlflowTraceExporter({ client, ...options }),
60803
60932
  forPrincipal(input) {
60804
60933
  const scoped = buildDatabricksBundle(config2, {
60805
60934
  identity: input.tokenProvider,
@@ -60916,11 +61045,9 @@ export {
60916
61045
  DATABRICKS_CAPABILITY_EVIDENCE,
60917
61046
  DATABRICKS_CERTIFICATION_RESOURCE_PREFIX,
60918
61047
  DATABRICKS_PACKAGE_COMPATIBILITY,
60919
- DatabricksAgentServices,
61048
+ DATABRICKS_SDK_VERSION,
60920
61049
  DatabricksAiSearchAdmin,
60921
61050
  DatabricksCertificationCleanupLedger,
60922
- DatabricksGenieAdmin,
60923
- DatabricksGenieAgentModeClient,
60924
61051
  DatabricksGenieAgentModeProtocolError,
60925
61052
  DatabricksGenieAgentModeResponseError,
60926
61053
  DatabricksGenieAgentModeTimeoutError,
@@ -60933,13 +61060,11 @@ export {
60933
61060
  DatabricksJobsAuthoring,
60934
61061
  DatabricksLakeflowAuthoring,
60935
61062
  DatabricksManagedResourceConflictError,
60936
- DatabricksPreviewClient,
60937
61063
  DatabricksRunTimeoutError,
60938
61064
  DatabricksSecretsAuthoring,
60939
61065
  DatabricksServingAdmin,
60940
61066
  DatabricksUnityCatalogAdmin,
60941
61067
  DatabricksUnmanagedResourceError,
60942
- DatabricksWorkspaceAuthoring,
60943
61068
  LakebaseDatabricksManagedResourceStore,
60944
61069
  MemoryDatabricksManagedResourceStore,
60945
61070
  MockDatabricksModelProvider,
@@ -60951,7 +61076,6 @@ export {
60951
61076
  createDatabricksRagChain,
60952
61077
  databricks,
60953
61078
  databricksActualCostSource,
60954
- databricksAgentServices,
60955
61079
  databricksAiQueryTool,
60956
61080
  databricksAiSearch,
60957
61081
  databricksAiSearchAdminTools,
@@ -60964,10 +61088,7 @@ export {
60964
61088
  databricksFeatureLookupTool,
60965
61089
  databricksFoundationModelProvider,
60966
61090
  databricksGenie,
60967
- databricksGenieAdmin,
60968
- databricksGenieAgentMode,
60969
61091
  databricksGenieAgentModeTool,
60970
- databricksGenieAuthoringTools,
60971
61092
  databricksGenieTool,
60972
61093
  databricksGovernancePolicy,
60973
61094
  databricksIdentity,
@@ -60998,11 +61119,8 @@ export {
60998
61119
  databricksTelemetry,
60999
61120
  databricksTenantCostLimit,
61000
61121
  databricksUnityCatalogAdminTools,
61001
- databricksWorkspaceAuthoringTools,
61002
61122
  databricksWorkspaceOrigin,
61003
- databricksWorkspaceSource,
61004
61123
  defineDatabricksAgent,
61005
- ensureDatabricksAiGateway,
61006
61124
  ensureDatabricksTelemetryTables,
61007
61125
  exportAgentEvaluationJsonl,
61008
61126
  exportMlflow3EvaluationJsonl,
@@ -61016,9 +61134,7 @@ export {
61016
61134
  lakebaseClient,
61017
61135
  lakebaseCredentialProvider,
61018
61136
  listDatabricksCapabilities,
61019
- listDatabricksModelServices,
61020
61137
  missingDatabricksCapabilityEvidence,
61021
- mlflowTraceExporter,
61022
61138
  normalizeDatabricksGenieAgentSpec,
61023
61139
  onBehalfOfFromHeaders,
61024
61140
  queryDatabricksLineageEvidence,
@@ -61034,6 +61150,7 @@ export {
61034
61150
  serializeDatabricksGenieAgentSpec,
61035
61151
  servingUsageCapture,
61036
61152
  sweepDatabricksAuthoringCertification,
61153
+ sweepDatabricksAuthoringCertificationWorkspace,
61037
61154
  toAgentEvaluationRecord,
61038
61155
  toMlflow3EvaluationRecord,
61039
61156
  unityCatalogTablesTool,