@fabric-harness/databricks 4.1.1 → 4.3.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.
Files changed (101) hide show
  1. package/dist/agent-services.js +142 -0
  2. package/dist/agent-services.js.map +1 -0
  3. package/dist/agent.js +1727 -1727
  4. package/dist/agent.js.map +1 -1
  5. package/dist/ai-gateway.js +51 -0
  6. package/dist/ai-gateway.js.map +1 -0
  7. package/dist/ai-search-admin.js +194 -0
  8. package/dist/ai-search-admin.js.map +1 -0
  9. package/dist/ai.js +22 -0
  10. package/dist/ai.js.map +1 -0
  11. package/dist/app-deployment.d.ts +79 -0
  12. package/dist/app-deployment.d.ts.map +1 -0
  13. package/dist/app-user-authorization.js +38942 -0
  14. package/dist/app-user-authorization.js.map +1 -0
  15. package/dist/app.js +143 -0
  16. package/dist/app.js.map +1 -0
  17. package/dist/authoring-certification.js +476 -0
  18. package/dist/authoring-certification.js.map +1 -0
  19. package/dist/capabilities.js +633 -0
  20. package/dist/capabilities.js.map +1 -0
  21. package/dist/certification-resource.js +17 -0
  22. package/dist/certification-resource.js.map +1 -0
  23. package/dist/certification-sweeper.js +128 -0
  24. package/dist/certification-sweeper.js.map +1 -0
  25. package/dist/certification.js +236 -0
  26. package/dist/certification.js.map +1 -0
  27. package/dist/client.d.ts +58 -0
  28. package/dist/client.d.ts.map +1 -0
  29. package/dist/client.js +184 -0
  30. package/dist/client.js.map +1 -0
  31. package/dist/compatibility.js +88 -0
  32. package/dist/compatibility.js.map +1 -0
  33. package/dist/consumption.js +85 -0
  34. package/dist/consumption.js.map +1 -0
  35. package/dist/cost-budget-actuals.js +316 -0
  36. package/dist/cost-budget-actuals.js.map +1 -0
  37. package/dist/embeddings.js +24 -0
  38. package/dist/embeddings.js.map +1 -0
  39. package/dist/feature-serving.js +29 -0
  40. package/dist/feature-serving.js.map +1 -0
  41. package/dist/genie-agent-mode.js +374 -0
  42. package/dist/genie-agent-mode.js.map +1 -0
  43. package/dist/genie-authoring.js +898 -0
  44. package/dist/genie-authoring.js.map +1 -0
  45. package/dist/genie.js +405 -0
  46. package/dist/genie.js.map +1 -0
  47. package/dist/governance.js +353 -0
  48. package/dist/governance.js.map +1 -0
  49. package/dist/identity.js +229 -0
  50. package/dist/identity.js.map +1 -0
  51. package/dist/index.d.ts +4 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +1446 -1288
  54. package/dist/index.js.map +1 -1
  55. package/dist/jobs-authoring.js +570 -0
  56. package/dist/jobs-authoring.js.map +1 -0
  57. package/dist/jobs.js +173 -0
  58. package/dist/jobs.js.map +1 -0
  59. package/dist/lakebase.js +110 -0
  60. package/dist/lakebase.js.map +1 -0
  61. package/dist/lakeflow-authoring.js +115 -0
  62. package/dist/lakeflow-authoring.js.map +1 -0
  63. package/dist/lakeflow.js +75 -0
  64. package/dist/lakeflow.js.map +1 -0
  65. package/dist/managed-resource.js +197 -0
  66. package/dist/managed-resource.js.map +1 -0
  67. package/dist/mlflow-tracing.js +167 -0
  68. package/dist/mlflow-tracing.js.map +1 -0
  69. package/dist/mock-provider.js +66 -0
  70. package/dist/mock-provider.js.map +1 -0
  71. package/dist/model.js +173 -0
  72. package/dist/model.js.map +1 -0
  73. package/dist/persistence.js +82 -0
  74. package/dist/persistence.js.map +1 -0
  75. package/dist/rag-chain.js +212 -0
  76. package/dist/rag-chain.js.map +1 -0
  77. package/dist/rag-eval.js +151 -0
  78. package/dist/rag-eval.js.map +1 -0
  79. package/dist/secrets-authoring.js +78 -0
  80. package/dist/secrets-authoring.js.map +1 -0
  81. package/dist/secrets.js +25 -0
  82. package/dist/secrets.js.map +1 -0
  83. package/dist/serving-admin.js +255 -0
  84. package/dist/serving-admin.js.map +1 -0
  85. package/dist/serving-usage.js +100 -0
  86. package/dist/serving-usage.js.map +1 -0
  87. package/dist/sql-exec.js +36 -0
  88. package/dist/sql-exec.js.map +1 -0
  89. package/dist/telemetry-sink.js +180 -0
  90. package/dist/telemetry-sink.js.map +1 -0
  91. package/dist/tools.js +167 -0
  92. package/dist/tools.js.map +1 -0
  93. package/dist/unity-catalog-admin.js +166 -0
  94. package/dist/unity-catalog-admin.js.map +1 -0
  95. package/dist/vector-search.js +65 -0
  96. package/dist/vector-search.js.map +1 -0
  97. package/dist/volumes-attachment-store.js +172 -0
  98. package/dist/volumes-attachment-store.js.map +1 -0
  99. package/dist/workspace-authoring.js +78 -0
  100. package/dist/workspace-authoring.js.map +1 -0
  101. package/package.json +15 -11
package/dist/agent.js CHANGED
@@ -17420,6 +17420,55 @@ function ucIdentifier(value, label) {
17420
17420
  return normalized;
17421
17421
  }
17422
17422
 
17423
+ // src/ai-gateway.ts
17424
+ async function ensureDatabricksAiGateway(client) {
17425
+ await client.get("/api/ai-gateway/v2/endpoints", { page_size: 1 });
17426
+ }
17427
+ async function listDatabricksModelServices(client, options = {}) {
17428
+ const pageSize = positiveInteger(options.pageSize ?? 100, "pageSize");
17429
+ const maxPages = positiveInteger(options.maxPages ?? 100, "maxPages");
17430
+ const requiredPrefix = options.requiredPrefix ?? "system.ai.";
17431
+ const services = /* @__PURE__ */ new Map();
17432
+ const seenTokens = /* @__PURE__ */ new Set();
17433
+ let pageToken;
17434
+ for (let page = 0; page < maxPages; page += 1) {
17435
+ const response = await client.get(
17436
+ "/api/2.1/unity-catalog/model-services",
17437
+ { page_size: pageSize, ...pageToken ? { page_token: pageToken } : {} }
17438
+ );
17439
+ for (const raw of response.model_services ?? []) {
17440
+ const service = normalizeModelService(raw, requiredPrefix);
17441
+ if (service) services.set(service.name, service);
17442
+ }
17443
+ const next = response.next_page_token?.trim();
17444
+ if (!next) return [...services.values()].sort((a2, b2) => a2.name.localeCompare(b2.name));
17445
+ if (seenTokens.has(next))
17446
+ throw new Error(
17447
+ `databricks model-services pagination repeated token after page ${page + 1}.`
17448
+ );
17449
+ seenTokens.add(next);
17450
+ pageToken = next;
17451
+ }
17452
+ throw new Error(`databricks model-services pagination exceeded ${maxPages} pages.`);
17453
+ }
17454
+ function normalizeModelService(raw, requiredPrefix) {
17455
+ const rawName = typeof raw.name === "string" ? raw.name.trim() : "";
17456
+ const name = rawName.replace(/^model-services\//, "");
17457
+ if (!name.startsWith(requiredPrefix)) return void 0;
17458
+ return {
17459
+ name,
17460
+ ...typeof raw.comment === "string" ? { comment: raw.comment } : {},
17461
+ ...typeof raw.creator === "string" ? { creator: raw.creator } : {},
17462
+ ...typeof raw.created_at === "number" ? { createdAt: raw.created_at } : {},
17463
+ ...typeof raw.updated_at === "number" ? { updatedAt: raw.updated_at } : {}
17464
+ };
17465
+ }
17466
+ function positiveInteger(value, name) {
17467
+ if (!Number.isSafeInteger(value) || value <= 0)
17468
+ throw new Error(`${name} must be a positive integer.`);
17469
+ return value;
17470
+ }
17471
+
17423
17472
  // src/ai-search-admin.ts
17424
17473
  var DatabricksAiSearchAdmin = class {
17425
17474
  constructor(client) {
@@ -17660,55 +17709,6 @@ function jitter(ms) {
17660
17709
  return Math.max(1, Math.round(ms * (0.9 + Math.random() * 0.2)));
17661
17710
  }
17662
17711
 
17663
- // src/ai-gateway.ts
17664
- async function ensureDatabricksAiGateway(client) {
17665
- await client.get("/api/ai-gateway/v2/endpoints", { page_size: 1 });
17666
- }
17667
- async function listDatabricksModelServices(client, options = {}) {
17668
- const pageSize = positiveInteger(options.pageSize ?? 100, "pageSize");
17669
- const maxPages = positiveInteger(options.maxPages ?? 100, "maxPages");
17670
- const requiredPrefix = options.requiredPrefix ?? "system.ai.";
17671
- const services = /* @__PURE__ */ new Map();
17672
- const seenTokens = /* @__PURE__ */ new Set();
17673
- let pageToken;
17674
- for (let page = 0; page < maxPages; page += 1) {
17675
- const response = await client.get(
17676
- "/api/2.1/unity-catalog/model-services",
17677
- { page_size: pageSize, ...pageToken ? { page_token: pageToken } : {} }
17678
- );
17679
- for (const raw of response.model_services ?? []) {
17680
- const service = normalizeModelService(raw, requiredPrefix);
17681
- if (service) services.set(service.name, service);
17682
- }
17683
- const next = response.next_page_token?.trim();
17684
- if (!next) return [...services.values()].sort((a2, b2) => a2.name.localeCompare(b2.name));
17685
- if (seenTokens.has(next))
17686
- throw new Error(
17687
- `databricks model-services pagination repeated token after page ${page + 1}.`
17688
- );
17689
- seenTokens.add(next);
17690
- pageToken = next;
17691
- }
17692
- throw new Error(`databricks model-services pagination exceeded ${maxPages} pages.`);
17693
- }
17694
- function normalizeModelService(raw, requiredPrefix) {
17695
- const rawName = typeof raw.name === "string" ? raw.name.trim() : "";
17696
- const name = rawName.replace(/^model-services\//, "");
17697
- if (!name.startsWith(requiredPrefix)) return void 0;
17698
- return {
17699
- name,
17700
- ...typeof raw.comment === "string" ? { comment: raw.comment } : {},
17701
- ...typeof raw.creator === "string" ? { creator: raw.creator } : {},
17702
- ...typeof raw.created_at === "number" ? { createdAt: raw.created_at } : {},
17703
- ...typeof raw.updated_at === "number" ? { updatedAt: raw.updated_at } : {}
17704
- };
17705
- }
17706
- function positiveInteger(value, name) {
17707
- if (!Number.isSafeInteger(value) || value <= 0)
17708
- throw new Error(`${name} must be a positive integer.`);
17709
- return value;
17710
- }
17711
-
17712
17712
  // src/sql-exec.ts
17713
17713
  var TERMINAL_STATES = /* @__PURE__ */ new Set(["SUCCEEDED", "FAILED", "CANCELED", "CLOSED"]);
17714
17714
  async function runStatement(client, warehouseId, statement, parameters, poll) {
@@ -17767,187 +17767,6 @@ function databricksAiQueryTool(client, options) {
17767
17767
  };
17768
17768
  }
17769
17769
 
17770
- // src/raw-protocol-client.ts
17771
- import { redactText } from "@fabric-harness/sdk";
17772
- function isRetryableStatus(status) {
17773
- return status === 429 || status === 499 || status >= 500 && status <= 599;
17774
- }
17775
- function retryDelayMs(response, attempt, base2) {
17776
- const retryAfter = response.headers.get("retry-after");
17777
- if (retryAfter) {
17778
- const seconds = Number(retryAfter);
17779
- if (Number.isFinite(seconds)) return seconds * 1e3;
17780
- }
17781
- return base2 * 2 ** attempt;
17782
- }
17783
- var DATABRICKS_RAW_PROTOCOL_RULES = [
17784
- {
17785
- id: "workspace-objects",
17786
- methods: ["GET", "POST"],
17787
- path: /^\/api\/2\.0\/workspace\/(?:delete|export|get-status|import|list|mkdirs)$/u
17788
- },
17789
- {
17790
- id: "mlflow-traces-v3",
17791
- methods: ["POST"],
17792
- path: /^\/api\/3\.0\/mlflow\/traces$/u
17793
- },
17794
- {
17795
- id: "ai-gateway-discovery",
17796
- methods: ["GET"],
17797
- path: /^\/api\/(?:ai-gateway\/v2\/endpoints|2\.1\/unity-catalog\/model-services)$/u
17798
- },
17799
- {
17800
- id: "agent-services-beta",
17801
- methods: ["GET", "POST", "PATCH", "DELETE"],
17802
- path: /^\/api\/2\.1\/unity-catalog\/(?:agent-services(?:\/[^/?#]+)?|permissions\/AGENT_SERVICE\/[^/?#]+)$/u
17803
- },
17804
- {
17805
- id: "genie-agent-mode-beta",
17806
- methods: ["GET", "POST"],
17807
- path: /^\/api\/2\.0\/genie\/agents\/[^/?#]+\/(?:responses|conversations\/[^/?#]+\/items)$/u
17808
- },
17809
- {
17810
- id: "genie-query-result-sdk-compatibility",
17811
- methods: ["GET"],
17812
- path: /^\/api\/2\.0\/genie\/spaces\/[^/?#]+\/conversations\/[^/?#]+\/messages\/[^/?#]+\/attachments\/[^/?#]+\/query-result$/u
17813
- },
17814
- {
17815
- id: "vector-search-query-sdk-compatibility",
17816
- methods: ["POST"],
17817
- path: /^\/api\/2\.0\/vector-search\/indexes\/[^/?#]+\/query$/u
17818
- },
17819
- {
17820
- id: "responses-agent-custom-schema",
17821
- methods: ["POST"],
17822
- path: /^\/serving-endpoints\/[^/?#]+\/invocations$/u
17823
- }
17824
- ];
17825
- function assertRawProtocolAllowed(method, path) {
17826
- const normalizedMethod = method.toUpperCase();
17827
- if (!path.startsWith("/") || path.includes("?") || path.includes("#")) {
17828
- throw new Error(
17829
- `databricks raw protocol denied: ${normalizedMethod} ${path}; pass a relative path and structured query parameters.`
17830
- );
17831
- }
17832
- const rule = DATABRICKS_RAW_PROTOCOL_RULES.find(
17833
- (candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(path)
17834
- );
17835
- if (!rule) {
17836
- throw new Error(
17837
- `databricks raw protocol denied: ${normalizedMethod} ${path}; use an official @databricks/sdk-* service client.`
17838
- );
17839
- }
17840
- }
17841
- var DatabricksRawProtocolClient = class {
17842
- host;
17843
- token;
17844
- fetchImpl;
17845
- maxRetries;
17846
- retryBaseDelayMs;
17847
- signal;
17848
- extraHeaders;
17849
- constructor(options) {
17850
- this.host = databricksWorkspaceOrigin(options.host);
17851
- this.token = options.token;
17852
- this.fetchImpl = options.fetchImpl ?? fetch;
17853
- this.maxRetries = options.maxRetries ?? 3;
17854
- this.retryBaseDelayMs = options.retryBaseDelayMs ?? 500;
17855
- this.signal = options.signal;
17856
- this.extraHeaders = options.extraHeaders;
17857
- }
17858
- get(path, query, options) {
17859
- return this.requestJson("GET", path, void 0, query, options);
17860
- }
17861
- post(path, body, query, options) {
17862
- return this.requestJson("POST", path, body, query, options);
17863
- }
17864
- patch(path, body, query, options) {
17865
- return this.requestJson("PATCH", path, body, query, options);
17866
- }
17867
- delete(path, body, query, options) {
17868
- return this.requestJson("DELETE", path, body, query, options);
17869
- }
17870
- async requestJson(method, path, body, query = {}, options = {}) {
17871
- const response = await this.send(method, path, body, query, options);
17872
- if (response.status === 204) return void 0;
17873
- return await response.json();
17874
- }
17875
- /**
17876
- * Perform an authenticated request while leaving a successful response body unread. This is
17877
- * intended for bounded binary downloads and streaming APIs such as Genie Agent Mode.
17878
- */
17879
- postRaw(path, body, query = {}, options = {}) {
17880
- return this.send("POST", path, body, query, options);
17881
- }
17882
- async send(method, path, body, query, options) {
17883
- assertRawProtocolAllowed(method, path);
17884
- const url2 = new URL(`${this.host}${path.startsWith("/") ? path : `/${path}`}`);
17885
- for (const [key, value] of Object.entries(query))
17886
- if (value !== void 0) url2.searchParams.set(key, String(value));
17887
- const canRetry = options.retry === "always" || options.retry !== "never" && (options.retry === "safe" || method === "GET" || method === "HEAD");
17888
- const maxRetries = canRetry ? options.maxRetries ?? this.maxRetries : 0;
17889
- const signal = combineAbortSignals(this.signal, options.signal);
17890
- for (let attempt = 0; ; attempt += 1) {
17891
- const token = typeof this.token === "function" ? await this.token() : this.token;
17892
- const extra = typeof this.extraHeaders === "function" ? await this.extraHeaders() : this.extraHeaders;
17893
- const init = {
17894
- method,
17895
- headers: {
17896
- authorization: `Bearer ${token}`,
17897
- ...options.accept ? { accept: options.accept } : {},
17898
- ...body !== void 0 ? { "content-type": "application/json" } : {},
17899
- ...extra
17900
- },
17901
- ...body !== void 0 ? { body: JSON.stringify(body) } : {},
17902
- ...signal ? { signal } : {}
17903
- };
17904
- let response;
17905
- try {
17906
- response = await this.fetchImpl(url2, init);
17907
- } catch (error51) {
17908
- if (signal?.aborted || attempt >= maxRetries) throw error51;
17909
- await abortableSleep(this.retryBaseDelayMs * 2 ** attempt, signal);
17910
- continue;
17911
- }
17912
- if (response.ok) {
17913
- return response;
17914
- }
17915
- if (isRetryableStatus(response.status) && attempt < maxRetries) {
17916
- await response.body?.cancel();
17917
- await abortableSleep(retryDelayMs(response, attempt, this.retryBaseDelayMs), signal);
17918
- continue;
17919
- }
17920
- const text = redactText(await response.text(), { additionalSecrets: [token] });
17921
- throw new Error(
17922
- `databricks: ${response.status} ${response.statusText}: ${text.slice(0, 2e3)}`
17923
- );
17924
- }
17925
- }
17926
- };
17927
- function combineAbortSignals(clientSignal, requestSignal) {
17928
- if (!clientSignal) return requestSignal;
17929
- if (!requestSignal || requestSignal === clientSignal) return clientSignal;
17930
- return AbortSignal.any([clientSignal, requestSignal]);
17931
- }
17932
- function abortableSleep(ms, signal) {
17933
- if (signal?.aborted)
17934
- return Promise.reject(
17935
- signal.reason ?? new DOMException("The operation was aborted.", "AbortError")
17936
- );
17937
- if (!signal) return new Promise((resolve2) => setTimeout(resolve2, ms));
17938
- return new Promise((resolve2, reject) => {
17939
- const timer = setTimeout(() => {
17940
- signal.removeEventListener("abort", abort);
17941
- resolve2();
17942
- }, ms);
17943
- const abort = () => {
17944
- clearTimeout(timer);
17945
- reject(signal.reason ?? new DOMException("The operation was aborted.", "AbortError"));
17946
- };
17947
- signal.addEventListener("abort", abort, { once: true });
17948
- });
17949
- }
17950
-
17951
17770
  // src/consumption.ts
17952
17771
  var GROUP_COLUMNS = {
17953
17772
  sku: { select: "u.sku_name AS sku, u.usage_unit AS unit", group: "u.sku_name, u.usage_unit" },
@@ -19762,7 +19581,7 @@ var DatabricksGenieClient = class {
19762
19581
  const remaining = deadline - Date.now();
19763
19582
  if (remaining <= 0)
19764
19583
  throw new DatabricksGenieTimeoutError(conversationId, messageId, timeoutMs);
19765
- await abortableSleep2(
19584
+ await abortableSleep(
19766
19585
  Math.min(jitter2(this.pollIntervalMs, this.pollJitterRatio), remaining),
19767
19586
  options.signal
19768
19587
  );
@@ -20080,7 +19899,7 @@ function throwIfAborted(signal) {
20080
19899
  if (signal?.aborted)
20081
19900
  throw signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
20082
19901
  }
20083
- function abortableSleep2(ms, signal) {
19902
+ function abortableSleep(ms, signal) {
20084
19903
  throwIfAborted(signal);
20085
19904
  if (!signal) return new Promise((resolve2) => setTimeout(resolve2, ms));
20086
19905
  return new Promise((resolve2, reject) => {
@@ -21115,443 +20934,1045 @@ function submitSchema() {
21115
20934
  };
21116
20935
  }
21117
20936
 
21118
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/clientinfo.js
21119
- var ClientInfoError = class extends Error {
21120
- code;
21121
- constructor(code, message) {
21122
- super(message);
21123
- this.name = "ClientInfoError";
21124
- this.code = code;
21125
- }
21126
- };
21127
- var SEMVER_CORE = String.raw`(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)`;
21128
- var SEMVER_PRERELEASE = String.raw`(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?`;
21129
- var SEMVER_BUILDMETADATA = String.raw`(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?`;
21130
- var REGEXP_SEMVER = new RegExp("^" + SEMVER_CORE + SEMVER_PRERELEASE + SEMVER_BUILDMETADATA + "$");
21131
- var REGEXP_VALID_SEGMENT = /^[-0-9A-Za-z_.+]+$/;
21132
- var REGEXP_INVALID_SEGMENT_CHAR = /[^-0-9A-Za-z_.+]/g;
21133
- function isValidSegment(s2) {
21134
- return REGEXP_VALID_SEGMENT.test(s2);
21135
- }
21136
- function sanitize(s2) {
21137
- return s2.replace(REGEXP_INVALID_SEGMENT_CHAR, "-");
21138
- }
21139
- var ClientInfo = class _ClientInfo {
21140
- static EMPTY = new _ClientInfo();
21141
- segments;
21142
- constructor(segments = []) {
21143
- this.segments = [...segments];
21144
- }
21145
- /**
21146
- * Returns a new {@link ClientInfo} with the given items appended. Accepts
21147
- * either individual key/value pairs or another {@link ClientInfo} whose
21148
- * segments are merged in order. The original is not modified; mixing the
21149
- * two forms in a single call is supported.
21150
- *
21151
- * Keys and values on pair arguments must contain only alphanumeric
21152
- * characters plus `_`, `.`, `+`, or `-`. Exact key+value duplicates are
21153
- * silently ignored. On error, an exception is thrown (all-or-nothing).
21154
- *
21155
- * @example
21156
- * ```ts
21157
- * base.with({key: 'partner', value: 'acme'});
21158
- * base.with(pkgClientInfo);
21159
- * base.with(pkgClientInfo, {key: 'sdk-feature', value: 'pagination'});
21160
- * ```
21161
- */
21162
- with(...items) {
21163
- if (items.length === 0) {
21164
- return this;
21165
- }
21166
- const newSegments = [...this.segments];
21167
- for (const item of items) {
21168
- const pairs = item instanceof _ClientInfo ? item.segments : [item];
21169
- for (const { key, value } of pairs) {
21170
- if (!isValidSegment(key)) {
21171
- throw new ClientInfoError("INVALID_KEY", `Invalid key: ${key}.`);
21172
- }
21173
- if (!isValidSegment(value)) {
21174
- throw new ClientInfoError("INVALID_VALUE", `Invalid value for "${key}": ${value}.`);
21175
- }
21176
- if (newSegments.some((s2) => s2.key === key && s2.value === value)) {
21177
- continue;
21178
- }
21179
- newSegments.push({ key, value });
21180
- }
21181
- }
21182
- return new _ClientInfo(newSegments);
21183
- }
21184
- /**
21185
- * Returns a string representation of the client info suitable for
21186
- * inclusion in HTTP headers. Key/value pairs are formatted as
21187
- * "key/value" and joined by spaces in the order they were inserted.
21188
- */
21189
- toString() {
21190
- return this.segments.map((s2) => `${s2.key}/${s2.value}`).join(" ");
21191
- }
21192
- };
21193
-
21194
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/package.json
21195
- var package_default2 = {
21196
- name: "@databricks/sdk-core",
21197
- version: "0.21.0",
21198
- description: "Databricks core library for JavaScript/TypeScript",
21199
- type: "module",
21200
- main: "./dist/index.js",
21201
- types: "./dist/index.d.ts",
21202
- exports: {
21203
- ".": {
21204
- types: "./dist/index.d.ts",
21205
- import: "./dist/index.js",
21206
- default: "./dist/index.js"
21207
- },
21208
- "./profiles": {
21209
- types: "./dist/profiles/index.d.ts",
21210
- import: "./dist/profiles/index.js",
21211
- default: "./dist/profiles/index.js"
21212
- },
21213
- "./profiles/browser": {
21214
- types: "./dist/profiles/index.browser.d.ts",
21215
- import: "./dist/profiles/index.browser.js",
21216
- default: "./dist/profiles/index.browser.js"
21217
- },
21218
- "./wkt": {
21219
- types: "./dist/wkt/index.d.ts",
21220
- import: "./dist/wkt/index.js",
21221
- default: "./dist/wkt/index.js"
21222
- },
21223
- "./clientinfo": {
21224
- browser: {
21225
- types: "./dist/clientinfo/index.browser.d.ts",
21226
- import: "./dist/clientinfo/index.browser.js",
21227
- default: "./dist/clientinfo/index.browser.js"
21228
- },
21229
- default: {
21230
- types: "./dist/clientinfo/index.d.ts",
21231
- import: "./dist/clientinfo/index.js",
21232
- default: "./dist/clientinfo/index.js"
21233
- }
21234
- },
21235
- "./clientinfo/browser": {
21236
- types: "./dist/clientinfo/index.browser.d.ts",
21237
- import: "./dist/clientinfo/index.browser.js",
21238
- default: "./dist/clientinfo/index.browser.js"
21239
- },
21240
- "./http": {
21241
- types: "./dist/http/index.d.ts",
21242
- import: "./dist/http/index.js",
21243
- default: "./dist/http/index.js"
21244
- },
21245
- "./logger": {
21246
- types: "./dist/logger/index.d.ts",
21247
- import: "./dist/logger/index.js",
21248
- default: "./dist/logger/index.js"
21249
- },
21250
- "./ops": {
21251
- types: "./dist/ops/index.d.ts",
21252
- import: "./dist/ops/index.js",
21253
- default: "./dist/ops/index.js"
21254
- },
21255
- "./apierror": {
21256
- types: "./dist/apierror/index.d.ts",
21257
- import: "./dist/apierror/index.js",
21258
- default: "./dist/apierror/index.js"
21259
- },
21260
- "./apierror/codes": {
21261
- types: "./dist/apierror/codes/index.d.ts",
21262
- import: "./dist/apierror/codes/index.js",
21263
- default: "./dist/apierror/codes/index.js"
20937
+ // src/lakebase.ts
20938
+ import { createRequire } from "module";
20939
+ var require2 = createRequire(import.meta.url);
20940
+ function lakebaseCredentialProvider(options) {
20941
+ const now = options.now ?? Date.now;
20942
+ const random = options.random ?? Math.random;
20943
+ const refreshBeforeMs = options.refreshBeforeMs ?? 5 * 6e4;
20944
+ const refreshJitterMs = options.refreshJitterMs ?? 3e4;
20945
+ let cached4;
20946
+ let refreshing;
20947
+ const refresh = async () => {
20948
+ const value = await options.client.generateDatabaseCredential({ endpoint: options.endpoint });
20949
+ if (typeof value.token !== "string" || !value.token) {
20950
+ throw new Error("Lakebase credential exchange returned no token.");
21264
20951
  }
21265
- },
21266
- files: [
21267
- "dist",
21268
- "LICENSE"
21269
- ],
21270
- scripts: {
21271
- build: "tsc -b",
21272
- lint: "eslint src tests --ext .ts",
21273
- "lint:fix": "eslint src tests --ext .ts --fix",
21274
- format: 'prettier --write "src/**/*.ts" "tests/**/*.ts"',
21275
- "format:check": 'prettier --check "src/**/*.ts" "tests/**/*.ts"',
21276
- test: "vitest run",
21277
- "test:browser": "vitest run --config vitest.config.browser.ts",
21278
- typecheck: "tsc --noEmit",
21279
- clean: "rm -rf dist tsconfig.tsbuildinfo"
21280
- },
21281
- author: "Databricks",
21282
- license: "Apache-2.0",
21283
- engines: {
21284
- node: ">=22.0.0"
21285
- },
21286
- dependencies: {
21287
- "json-bigint": "^1.0.0",
21288
- zod: "^4.3.6"
21289
- }
21290
- };
21291
-
21292
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/base.js
21293
- var MODULE_NAME = "sdk-js-core";
21294
- var VERSION2 = package_default2.version;
21295
- var base = ClientInfo.EMPTY;
21296
- function getBase() {
21297
- return base;
21298
- }
21299
-
21300
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/agent.js
21301
- var AGENT_ENV_VAR = "AGENT";
21302
- var AI_AGENT_ENV_VAR = "AI_AGENT";
21303
- var MAX_AGENT_FALLBACK_LEN = 64;
21304
- var KNOWN_AGENTS = [
21305
- // The amp agent also sets AGENT=amp, handled by the central fallback.
21306
- { envVar: "AMP_CURRENT_THREAD_ID", product: "amp" },
21307
- { envVar: "ANTIGRAVITY_AGENT", product: "antigravity" },
21308
- { envVar: "AUGMENT_AGENT", product: "augment" },
21309
- { envVar: "CLAUDECODE", product: "claude-code" },
21310
- { envVar: "CLINE_ACTIVE", product: "cline" },
21311
- { envVar: "CODEX_CI", product: "codex" },
21312
- { envVar: "COPILOT_CLI", product: "copilot-cli" },
21313
- { envVar: "CURSOR_AGENT", product: "cursor" },
21314
- { envVar: "GEMINI_CLI", product: "gemini-cli" },
21315
- // The goose agent also sets AGENT=goose, handled by the central
21316
- // fallback.
21317
- { envVar: "GOOSE_TERMINAL", product: "goose" },
21318
- { envVar: "KIRO", product: "kiro" },
21319
- { envVar: "OPENCLAW_SHELL", product: "openclaw" },
21320
- { envVar: "OPENCODE", product: "opencode" },
21321
- // Set by VS Code 1.121+ for agent-initiated terminal commands
21322
- // (https://code.visualstudio.com/updates/v1_121).
21323
- { envVar: "VSCODE_AGENT", product: "vscode-agent" },
21324
- { envVar: "WINDSURF_AGENT", product: "windsurf" }
21325
- ];
21326
- function agentEnvFallback() {
21327
- let v2 = process.env[AGENT_ENV_VAR];
21328
- if (v2 === void 0 || v2 === "") {
21329
- v2 = process.env[AI_AGENT_ENV_VAR];
21330
- }
21331
- if (v2 === void 0 || v2 === "") {
21332
- return "";
21333
- }
21334
- return sanitize(v2).slice(0, MAX_AGENT_FALLBACK_LEN);
21335
- }
21336
- function lookupAgentProvider() {
21337
- const matches = [];
21338
- for (const a2 of KNOWN_AGENTS) {
21339
- if (a2.envVar in process.env) {
21340
- matches.push(a2.product);
20952
+ const expiresAt = value.expireTime?.epochMilliseconds ?? Number.NaN;
20953
+ if (!Number.isFinite(expiresAt)) {
20954
+ throw new Error("Lakebase credential exchange returned an invalid expire_time.");
21341
20955
  }
21342
- }
21343
- if (matches.length === 1) {
21344
- return matches[0];
21345
- }
21346
- if (matches.length > 1) {
21347
- return "multiple";
21348
- }
21349
- return agentEnvFallback();
21350
- }
21351
- var cached2;
21352
- function agentProvider() {
21353
- cached2 ??= lookupAgentProvider();
21354
- return cached2;
20956
+ const jitter4 = Math.max(0, refreshJitterMs) * random();
20957
+ cached4 = {
20958
+ token: value.token,
20959
+ refreshAt: Math.max(now(), expiresAt - Math.max(0, refreshBeforeMs) - jitter4)
20960
+ };
20961
+ return value.token;
20962
+ };
20963
+ return async () => {
20964
+ if (cached4 && now() < cached4.refreshAt) return cached4.token;
20965
+ refreshing ??= refresh().finally(() => {
20966
+ refreshing = void 0;
20967
+ });
20968
+ return refreshing;
20969
+ };
21355
20970
  }
21356
-
21357
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/meta-harness.js
21358
- var KNOWN_META_HARNESSES = [
21359
- // OMNIGENT is set by the omnigent meta-harness
21360
- // (https://github.com/omnigent-ai/omnigent).
21361
- { envVar: "OMNIGENT", product: "omnigent" }
21362
- ];
21363
- function lookupMetaHarnessProvider() {
21364
- const matches = [];
21365
- for (const h2 of KNOWN_META_HARNESSES) {
21366
- if (h2.envVar in process.env) {
21367
- matches.push(h2.product);
20971
+ function lakebaseClient(options) {
20972
+ const factory2 = options.poolFactory ?? defaultPoolFactory();
20973
+ let password = options.password;
20974
+ if (password === void 0) {
20975
+ if (!options.credentialClient || !options.endpoint) {
20976
+ throw new Error(
20977
+ "Lakebase OAuth requires credentialClient and endpoint. A workspace token cannot be used directly as the Postgres password."
20978
+ );
21368
20979
  }
21369
- }
21370
- if (matches.length === 1) {
21371
- return matches[0];
21372
- }
21373
- if (matches.length > 1) {
21374
- return "multiple";
21375
- }
21376
- return "";
21377
- }
21378
- var cached3;
21379
- function metaHarnessProvider() {
21380
- cached3 ??= lookupMetaHarnessProvider();
21381
- return cached3;
21382
- }
21383
-
21384
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/default.js
21385
- var CICD_PROVIDERS = [
21386
- {
21387
- name: "github",
21388
- envVars: [{ name: "GITHUB_ACTIONS", expectedValue: "true" }]
21389
- },
21390
- {
21391
- name: "gitlab",
21392
- envVars: [{ name: "GITLAB_CI", expectedValue: "true" }]
21393
- },
21394
- { name: "jenkins", envVars: [{ name: "JENKINS_URL", expectedValue: "" }] },
21395
- {
21396
- name: "azure-devops",
21397
- envVars: [{ name: "TF_BUILD", expectedValue: "True" }]
21398
- },
21399
- {
21400
- name: "circle",
21401
- envVars: [{ name: "CIRCLECI", expectedValue: "true" }]
21402
- },
21403
- { name: "travis", envVars: [{ name: "TRAVIS", expectedValue: "true" }] },
21404
- {
21405
- name: "bitbucket",
21406
- envVars: [{ name: "BITBUCKET_BUILD_NUMBER", expectedValue: "" }]
21407
- },
21408
- {
21409
- name: "google-cloud-build",
21410
- envVars: [
21411
- { name: "PROJECT_ID", expectedValue: "" },
21412
- { name: "BUILD_ID", expectedValue: "" },
21413
- { name: "PROJECT_NUMBER", expectedValue: "" },
21414
- { name: "LOCATION", expectedValue: "" }
21415
- ]
21416
- },
21417
- {
21418
- name: "aws-code-build",
21419
- envVars: [{ name: "CODEBUILD_BUILD_ARN", expectedValue: "" }]
21420
- },
21421
- { name: "tf-cloud", envVars: [{ name: "TFC_RUN_ID", expectedValue: "" }] }
21422
- ];
21423
- function detectCicd() {
21424
- for (const p2 of CICD_PROVIDERS) {
21425
- const allMatch = p2.envVars.every((ev) => {
21426
- const v2 = process.env[ev.name];
21427
- return v2 !== void 0 && (ev.expectedValue === "" || v2 === ev.expectedValue);
20980
+ password = lakebaseCredentialProvider({
20981
+ client: options.credentialClient,
20982
+ endpoint: options.endpoint,
20983
+ ...options.refreshBeforeMs !== void 0 ? { refreshBeforeMs: options.refreshBeforeMs } : {},
20984
+ ...options.refreshJitterMs !== void 0 ? { refreshJitterMs: options.refreshJitterMs } : {}
21428
20985
  });
21429
- if (allMatch) {
21430
- return p2.name;
21431
- }
21432
- }
21433
- return "";
21434
- }
21435
- function normalizeNodeVersion(raw) {
21436
- if (!raw.startsWith("v")) {
21437
- return "0.0.0-dev";
21438
20986
  }
21439
- return raw.slice(1);
20987
+ const client = factory2({
20988
+ host: options.host,
20989
+ port: options.port ?? 5432,
20990
+ database: options.database,
20991
+ user: options.user,
20992
+ password,
20993
+ ssl: options.ssl ?? { rejectUnauthorized: true },
20994
+ ...options.max !== void 0 ? { max: options.max } : {}
20995
+ });
20996
+ client.on?.("error", options.onPoolError ?? (() => void 0));
20997
+ return client;
21440
20998
  }
21441
- var CACHED_NODE_VERSION = normalizeNodeVersion(process.version);
21442
- function createDefault() {
21443
- const pairs = [
21444
- { key: MODULE_NAME, value: VERSION2 },
21445
- { key: "node", value: CACHED_NODE_VERSION },
21446
- { key: "os", value: process.platform },
21447
- ...getBase().segments
21448
- ];
21449
- const upstream = process.env.DATABRICKS_SDK_UPSTREAM;
21450
- if (upstream !== void 0) {
21451
- const upstreamVersion = process.env.DATABRICKS_SDK_UPSTREAM_VERSION;
21452
- if (upstreamVersion !== void 0) {
21453
- pairs.push({ key: "upstream", value: sanitize(upstream) }, { key: "upstream-version", value: sanitize(upstreamVersion) });
21454
- }
21455
- }
21456
- const cicd = detectCicd();
21457
- if (cicd !== "") {
21458
- pairs.push({ key: "cicd", value: cicd });
21459
- }
21460
- const runtime = process.env.DATABRICKS_RUNTIME_VERSION;
21461
- if (runtime !== void 0 && runtime !== "") {
21462
- pairs.push({ key: "runtime", value: sanitize(runtime) });
21463
- }
21464
- const agent = agentProvider();
21465
- if (agent !== "") {
21466
- pairs.push({ key: "agent", value: agent });
21467
- }
21468
- const metaHarness = metaHarnessProvider();
21469
- if (metaHarness !== "") {
21470
- pairs.push({ key: "meta-harness", value: metaHarness });
20999
+ function defaultPoolFactory() {
21000
+ let PoolCtor;
21001
+ try {
21002
+ PoolCtor = require2("pg").Pool;
21003
+ } catch (error51) {
21004
+ throw new Error(
21005
+ `Lakebase store requires the optional "pg" package to be installed by the application. Run: pnpm add pg. ${error51 instanceof Error ? error51.message : String(error51)}`
21006
+ );
21471
21007
  }
21472
- return ClientInfo.EMPTY.with(...pairs);
21008
+ return (config2) => new PoolCtor(config2);
21473
21009
  }
21474
21010
 
21475
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/logger/logger.js
21476
- var NoOpLogger = class {
21477
- debug() {
21478
- }
21479
- info() {
21480
- }
21481
- warn() {
21482
- }
21483
- error() {
21011
+ // src/lakeflow-authoring.ts
21012
+ var DatabricksLakeflowAuthoring = class {
21013
+ constructor(client, statements) {
21014
+ this.client = client;
21015
+ this.statements = statements;
21484
21016
  }
21485
- };
21486
-
21487
- // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/http/http.js
21488
- function newFetchHttpClient() {
21489
- return {
21490
- async send(request) {
21491
- const init = {
21492
- method: request.method,
21493
- headers: request.headers
21494
- };
21495
- if (request.body !== void 0) {
21496
- init.body = request.body;
21497
- if (request.body instanceof ReadableStream) {
21498
- init.duplex = "half";
21499
- }
21500
- }
21501
- if (request.signal !== void 0) {
21502
- init.signal = request.signal;
21503
- }
21504
- const response = await fetch(request.url, init);
21505
- return {
21506
- statusCode: response.status,
21507
- headers: response.headers,
21508
- body: response.body
21509
- };
21510
- }
21511
- };
21512
- }
21513
-
21514
- // ../../node_modules/.pnpm/@databricks+sdk-accessmanagement@0.21.0/node_modules/@databricks/sdk-accessmanagement/dist/v1/transport.js
21515
- async function resolveClientConfig(options) {
21516
- const profile = await resolve(options.profileOptions);
21517
- const host = options.host ?? profile.host;
21518
- if (host === void 0) {
21519
- throw new Error("Host is required.");
21017
+ async createPipeline(spec) {
21018
+ const response = await this.client.create(serialize(spec));
21019
+ if (!response.pipelineId)
21020
+ throw new Error("Databricks Lakeflow create response did not contain pipeline_id.");
21021
+ return { pipelineId: response.pipelineId };
21520
21022
  }
21521
- const base2 = options.httpClient ?? newFetchHttpClient();
21522
- const credentials = options.credentials ?? defaultCredentials({ profile });
21523
- let httpClient = new AuthHttpClient(base2, credentials);
21524
- if (options.timeout !== void 0) {
21525
- httpClient = new TimeoutHttpClient(httpClient, options.timeout);
21023
+ async updatePipeline(pipelineId, spec) {
21024
+ await this.client.edit({ pipelineId, id: pipelineId, ...serialize(spec) });
21526
21025
  }
21527
- const accountId = options.accountId ?? profile.accountId;
21528
- const workspaceId = options.workspaceId ?? profile.workspaceId;
21529
- return {
21530
- host: host.replace(/\/$/, ""),
21531
- httpClient,
21532
- ...accountId !== void 0 && { accountId },
21533
- ...workspaceId !== void 0 && { workspaceId }
21534
- };
21535
- }
21536
- var AuthHttpClient = class {
21537
- base;
21538
- credentials;
21539
- constructor(base2, credentials) {
21540
- this.base = base2;
21541
- this.credentials = credentials;
21026
+ async deletePipeline(pipelineId) {
21027
+ await this.client.delete({ pipelineId });
21542
21028
  }
21543
- async send(request) {
21544
- const authHeaders = await this.credentials.authHeaders();
21545
- const headers = new Headers(request.headers);
21546
- for (const h2 of authHeaders) {
21547
- headers.set(h2.key, h2.value);
21548
- }
21549
- return this.base.send({ ...request, headers });
21029
+ async pipelineEvents(pipelineId, warehouseId, limit = 100) {
21030
+ const escaped = pipelineId.replace(/'/g, "''");
21031
+ if (!this.statements)
21032
+ throw new Error("Databricks Lakeflow events require a Statement Execution client.");
21033
+ return runStatement(
21034
+ this.statements,
21035
+ warehouseId,
21036
+ `SELECT * FROM event_log('${escaped}') ORDER BY timestamp DESC LIMIT ${Math.max(1, Math.min(1e3, Math.floor(limit)))}`,
21037
+ [],
21038
+ { intervalMs: 2e3, timeoutMs: 12e4 }
21039
+ );
21550
21040
  }
21551
21041
  };
21552
- var TimeoutHttpClient = class {
21553
- base;
21554
- timeout;
21042
+ function databricksLakeflowAuthoringTools(client, options = {}) {
21043
+ const api = new DatabricksLakeflowAuthoring(client, options.statements);
21044
+ const spec = specSchema();
21045
+ const specProperties2 = spec.properties;
21046
+ const resources = [
21047
+ { kind: "pipeline", path: "/name" },
21048
+ { kind: "catalog", path: "/catalog", catalogQualified: true, optional: true },
21049
+ { kind: "notebook", path: "/libraries/*/notebook/path", optional: true }
21050
+ ];
21051
+ const tools = [
21052
+ tool2(
21053
+ "databricks_create_pipeline",
21054
+ "write",
21055
+ spec,
21056
+ resources,
21057
+ (input) => api.createPipeline(input)
21058
+ ),
21059
+ tool2(
21060
+ "databricks_update_pipeline",
21061
+ "write",
21062
+ {
21063
+ type: "object",
21064
+ additionalProperties: false,
21065
+ properties: { pipelineId: { type: "string" }, ...specProperties2 },
21066
+ required: ["pipelineId", "name", "libraries"]
21067
+ },
21068
+ [{ kind: "pipeline", path: "/pipelineId" }, ...resources.slice(1)],
21069
+ (input) => api.updatePipeline(input.pipelineId, input)
21070
+ ),
21071
+ tool2(
21072
+ "databricks_delete_pipeline",
21073
+ "write",
21074
+ idSchema3(),
21075
+ [{ kind: "pipeline", path: "/pipelineId" }],
21076
+ (input) => api.deletePipeline(input.pipelineId)
21077
+ )
21078
+ ];
21079
+ const warehouseId = options.warehouseId;
21080
+ if (warehouseId)
21081
+ tools.push(
21082
+ tool2(
21083
+ "databricks_pipeline_events",
21084
+ "read",
21085
+ {
21086
+ type: "object",
21087
+ additionalProperties: false,
21088
+ properties: { pipelineId: { type: "string" }, limit: { type: "number" } },
21089
+ required: ["pipelineId"]
21090
+ },
21091
+ [{ kind: "pipeline", path: "/pipelineId" }],
21092
+ (input) => api.pipelineEvents(
21093
+ input.pipelineId,
21094
+ warehouseId,
21095
+ input.limit
21096
+ )
21097
+ )
21098
+ );
21099
+ return tools;
21100
+ }
21101
+ function tool2(name, effect, inputSchema, resources, execute2) {
21102
+ return {
21103
+ name,
21104
+ description: name.replaceAll("_", " "),
21105
+ inputSchema,
21106
+ metadata: { effect, provider: "databricks", service: "lakeflow", governance: { resources } },
21107
+ execute: execute2
21108
+ };
21109
+ }
21110
+ function idSchema3() {
21111
+ return {
21112
+ type: "object",
21113
+ additionalProperties: false,
21114
+ properties: { pipelineId: { type: "string" } },
21115
+ required: ["pipelineId"]
21116
+ };
21117
+ }
21118
+ function specSchema() {
21119
+ return {
21120
+ type: "object",
21121
+ additionalProperties: false,
21122
+ properties: {
21123
+ name: { type: "string" },
21124
+ libraries: {
21125
+ type: "array",
21126
+ items: {
21127
+ type: "object",
21128
+ properties: {
21129
+ notebook: { type: "object", properties: { path: { type: "string" } } },
21130
+ file: { type: "object", properties: { path: { type: "string" } } },
21131
+ jar: { type: "string" },
21132
+ whl: { type: "string" }
21133
+ }
21134
+ }
21135
+ },
21136
+ catalog: { type: "string" },
21137
+ target: { type: "string" },
21138
+ continuous: { type: "boolean" },
21139
+ serverless: { type: "boolean" },
21140
+ development: { type: "boolean" },
21141
+ configuration: { type: "object", additionalProperties: { type: "string" } },
21142
+ clusters: { type: "array", items: { type: "object", additionalProperties: true } }
21143
+ },
21144
+ required: ["name", "libraries"]
21145
+ };
21146
+ }
21147
+ function serialize(spec) {
21148
+ return {
21149
+ name: spec.name,
21150
+ libraries: spec.libraries.map(serializeLibrary),
21151
+ ...spec.catalog ? { catalog: spec.catalog } : {},
21152
+ ...spec.target ? { target: spec.target } : {},
21153
+ ...spec.continuous !== void 0 ? { continuous: spec.continuous } : {},
21154
+ ...spec.serverless !== void 0 ? { serverless: spec.serverless } : {},
21155
+ ...spec.development !== void 0 ? { development: spec.development } : {},
21156
+ ...spec.configuration ? { configuration: spec.configuration } : {},
21157
+ ...spec.clusters ? { clusters: spec.clusters } : {}
21158
+ };
21159
+ }
21160
+ function serializeLibrary(library) {
21161
+ if (library.notebook)
21162
+ return { lib: { $case: "notebook", notebook: { path: library.notebook.path } } };
21163
+ if (library.file) return { lib: { $case: "file", file: { path: library.file.path } } };
21164
+ if (library.jar) return { lib: { $case: "jar", jar: library.jar } };
21165
+ if (library.whl) return { lib: { $case: "whl", whl: library.whl } };
21166
+ throw new Error("Databricks Lakeflow library requires notebook, file, jar, or whl.");
21167
+ }
21168
+
21169
+ // src/lakeflow.ts
21170
+ function databricksPipelineListTool(client, options = {}) {
21171
+ return {
21172
+ name: options.name ?? "databricks_pipeline_list",
21173
+ description: options.description ?? "List Lakeflow Declarative Pipelines (DLT) in the workspace.",
21174
+ inputSchema: {
21175
+ type: "object",
21176
+ additionalProperties: false,
21177
+ properties: { maxResults: { type: "number", minimum: 1 }, filter: { type: "string" } }
21178
+ },
21179
+ metadata: { effect: "read", provider: "databricks", service: "lakeflow" },
21180
+ execute: (input) => client.list({
21181
+ ...input.maxResults !== void 0 ? { maxResults: input.maxResults } : {},
21182
+ ...input.filter ? { filter: input.filter } : {}
21183
+ })
21184
+ };
21185
+ }
21186
+ function databricksPipelineStatusTool(client, options = {}) {
21187
+ return {
21188
+ name: options.name ?? "databricks_pipeline_status",
21189
+ description: options.description ?? "Get a Lakeflow pipeline, including its state and latest updates.",
21190
+ inputSchema: {
21191
+ type: "object",
21192
+ additionalProperties: false,
21193
+ properties: { pipelineId: { type: "string" } },
21194
+ required: ["pipelineId"]
21195
+ },
21196
+ metadata: { effect: "read", provider: "databricks", service: "lakeflow" },
21197
+ execute: (input) => client.get({ pipelineId: input.pipelineId })
21198
+ };
21199
+ }
21200
+ function databricksPipelineStartTool(client, options = {}) {
21201
+ return {
21202
+ name: options.name ?? "databricks_pipeline_start",
21203
+ description: options.description ?? "Trigger a Lakeflow pipeline update (run). Set fullRefresh to reprocess all data.",
21204
+ inputSchema: {
21205
+ type: "object",
21206
+ additionalProperties: false,
21207
+ properties: { pipelineId: { type: "string" }, fullRefresh: { type: "boolean" } },
21208
+ required: ["pipelineId"]
21209
+ },
21210
+ metadata: { effect: "execute", provider: "databricks", service: "lakeflow" },
21211
+ execute: (input) => client.start({
21212
+ pipelineId: input.pipelineId,
21213
+ ...input.fullRefresh !== void 0 ? { fullRefresh: input.fullRefresh } : {}
21214
+ })
21215
+ };
21216
+ }
21217
+ function databricksPipelineStopTool(client, options = {}) {
21218
+ return {
21219
+ name: options.name ?? "databricks_pipeline_stop",
21220
+ description: options.description ?? "Stop the active update of a Lakeflow pipeline.",
21221
+ inputSchema: {
21222
+ type: "object",
21223
+ additionalProperties: false,
21224
+ properties: { pipelineId: { type: "string" } },
21225
+ required: ["pipelineId"]
21226
+ },
21227
+ metadata: { effect: "execute", provider: "databricks", service: "lakeflow" },
21228
+ execute: (input) => client.stop({ pipelineId: input.pipelineId })
21229
+ };
21230
+ }
21231
+ function databricksLakeflowTools(client) {
21232
+ return [
21233
+ databricksPipelineListTool(client),
21234
+ databricksPipelineStatusTool(client),
21235
+ databricksPipelineStartTool(client),
21236
+ databricksPipelineStopTool(client)
21237
+ ];
21238
+ }
21239
+
21240
+ // src/mlflow-tracing.ts
21241
+ import { createHash } from "crypto";
21242
+ import { eventToTelemetrySpan } from "@fabric-harness/sdk";
21243
+ function mlflowTraceExporter(options) {
21244
+ const onError = options.onError ?? ((context, error51) => {
21245
+ console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
21246
+ });
21247
+ const buffers = /* @__PURE__ */ new Map();
21248
+ return {
21249
+ sink: {
21250
+ record(event) {
21251
+ try {
21252
+ const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
21253
+ if (event.type === "submission_started") {
21254
+ buffers.set(key, {
21255
+ submissionId: event.submissionId,
21256
+ agent: event.agent,
21257
+ instanceId: event.instanceId,
21258
+ session: event.session,
21259
+ startedAtMs: event.at,
21260
+ attemptCount: event.attemptCount,
21261
+ ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
21262
+ spans: []
21263
+ });
21264
+ return;
21265
+ }
21266
+ if (event.type !== "submission_settled") return;
21267
+ const buffer = buffers.get(key);
21268
+ buffers.delete(key);
21269
+ const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
21270
+ const attemptCount = event.attemptCount ?? buffer?.attemptCount;
21271
+ const trace = buildMlflowTrace({
21272
+ submissionId: event.submissionId,
21273
+ agent: event.agent,
21274
+ instanceId: event.instanceId,
21275
+ session: event.session,
21276
+ experimentId: options.experimentId,
21277
+ startedAtMs,
21278
+ settledAtMs: event.at,
21279
+ state: event.outcome === "completed" ? "OK" : "ERROR",
21280
+ spans: buffer?.spans ?? [],
21281
+ ...attemptCount !== void 0 ? { attemptCount } : {},
21282
+ ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
21283
+ ...event.error !== void 0 ? { error: event.error } : {}
21284
+ });
21285
+ void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
21286
+ } catch (error51) {
21287
+ onError("telemetry event handling failed", error51);
21288
+ }
21289
+ }
21290
+ },
21291
+ onEvent(event) {
21292
+ try {
21293
+ if (!event.sessionId) return;
21294
+ const buffer = buffers.get(event.sessionId);
21295
+ if (!buffer) return;
21296
+ const span = eventToTelemetrySpan(event);
21297
+ if (span) buffer.spans.push(span);
21298
+ } catch (error51) {
21299
+ onError("event buffering failed", error51);
21300
+ }
21301
+ }
21302
+ };
21303
+ }
21304
+ function buildMlflowTrace(input) {
21305
+ const traceBytes = sha256(input.submissionId).subarray(0, 16);
21306
+ const traceIdBase64 = traceBytes.toString("base64");
21307
+ const rootSpanId = spanIdFor(input.submissionId, 0);
21308
+ const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
21309
+ const rootSpan = {
21310
+ trace_id: traceIdBase64,
21311
+ span_id: rootSpanId,
21312
+ name: `fabric.submission ${input.agent}`,
21313
+ start_time_unix_nano: toUnixNano(input.startedAtMs),
21314
+ end_time_unix_nano: toUnixNano(input.settledAtMs),
21315
+ attributes: toOtlpAttributes({
21316
+ "fabric.submission_id": input.submissionId,
21317
+ "fabric.agent": input.agent,
21318
+ "fabric.instance_id": input.instanceId,
21319
+ "fabric.session": input.session,
21320
+ ...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
21321
+ ...input.error !== void 0 ? { "fabric.error": input.error } : {}
21322
+ }),
21323
+ status: {
21324
+ code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
21325
+ ...input.error !== void 0 ? { message: input.error } : {}
21326
+ }
21327
+ };
21328
+ const childSpans = input.spans.map(
21329
+ (span, index) => ({
21330
+ trace_id: traceIdBase64,
21331
+ span_id: spanIdFor(input.submissionId, index + 1),
21332
+ parent_span_id: rootSpanId,
21333
+ name: span.name,
21334
+ start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
21335
+ end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
21336
+ attributes: toOtlpAttributes(span.attributes),
21337
+ status: { code: "STATUS_CODE_OK" }
21338
+ })
21339
+ );
21340
+ return {
21341
+ trace: {
21342
+ trace_info: {
21343
+ trace_id: `tr-${traceBytes.toString("hex")}`,
21344
+ trace_location: {
21345
+ type: "MLFLOW_EXPERIMENT",
21346
+ mlflow_experiment: { experiment_id: input.experimentId }
21347
+ },
21348
+ request_time: new Date(input.startedAtMs).toISOString(),
21349
+ execution_duration: `${durationSeconds.toFixed(3)}s`,
21350
+ state: input.state,
21351
+ trace_metadata: {
21352
+ "fabric.submission_id": input.submissionId,
21353
+ "fabric.agent": input.agent,
21354
+ "fabric.instance_id": input.instanceId,
21355
+ "fabric.session": input.session,
21356
+ ...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
21357
+ },
21358
+ tags: {
21359
+ "fabric.agent": input.agent,
21360
+ ...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
21361
+ }
21362
+ },
21363
+ trace_data: { spans: [rootSpan, ...childSpans] }
21364
+ }
21365
+ };
21366
+ }
21367
+ function sha256(seed) {
21368
+ return createHash("sha256").update(seed).digest();
21369
+ }
21370
+ function spanIdFor(submissionId, index) {
21371
+ return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
21372
+ }
21373
+ function toUnixNano(epochMs) {
21374
+ return `${Math.round(epochMs)}000000`;
21375
+ }
21376
+ function toOtlpAttributes(attributes) {
21377
+ return Object.entries(attributes).map(([key, value]) => {
21378
+ if (typeof value === "number") {
21379
+ return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
21380
+ }
21381
+ return { key, value: { string_value: String(value) } };
21382
+ });
21383
+ }
21384
+
21385
+ // src/model.ts
21386
+ import {
21387
+ OpenAICompatibleModelProvider,
21388
+ currentSubmissionContext as currentSubmissionContext2,
21389
+ registerModelProvider
21390
+ } from "@fabric-harness/sdk";
21391
+ function databricksModelBaseUrl(host, mode) {
21392
+ const normalized = databricksWorkspaceOrigin(host);
21393
+ return mode === "ai-gateway" ? `${normalized}/ai-gateway/mlflow/v1` : `${normalized}/serving-endpoints`;
21394
+ }
21395
+ function isDatabricksModelService(model) {
21396
+ return model?.startsWith("system.ai.") ?? false;
21397
+ }
21398
+ var DatabricksModelProvider = class {
21399
+ name = "databricks";
21400
+ options;
21401
+ gateway;
21402
+ serving;
21403
+ explicit;
21404
+ constructor(options) {
21405
+ this.options = options;
21406
+ const common = {
21407
+ name: this.name,
21408
+ apiKey: typeof options.token === "string" ? options.token : "",
21409
+ ...typeof options.token === "function" ? { tokenProvider: options.token } : {},
21410
+ ...options.defaultModel !== void 0 ? { defaultModel: options.defaultModel } : {},
21411
+ ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {}
21412
+ };
21413
+ this.gateway = new OpenAICompatibleModelProvider({
21414
+ ...common,
21415
+ baseUrl: databricksModelBaseUrl(options.host, "ai-gateway"),
21416
+ headers: () => this.resolveHeaders(true)
21417
+ });
21418
+ this.serving = new OpenAICompatibleModelProvider({
21419
+ ...common,
21420
+ baseUrl: databricksModelBaseUrl(options.host, "serving-endpoints"),
21421
+ headers: () => this.resolveHeaders(false)
21422
+ });
21423
+ this.explicit = options.baseUrl ? new OpenAICompatibleModelProvider({
21424
+ ...common,
21425
+ baseUrl: options.baseUrl,
21426
+ headers: () => this.resolveHeaders(options.baseUrl?.includes("/ai-gateway/") ?? false)
21427
+ }) : void 0;
21428
+ }
21429
+ generate(request) {
21430
+ return this.providerFor(request.model).generate(request);
21431
+ }
21432
+ stream(request) {
21433
+ const provider = this.providerFor(request.model);
21434
+ if (!provider.stream)
21435
+ throw new Error("databricks: selected provider does not support streaming.");
21436
+ return provider.stream(request);
21437
+ }
21438
+ getModelMetadata(model = this.options.defaultModel) {
21439
+ const mode = this.modeFor(model);
21440
+ return {
21441
+ provider: this.name,
21442
+ ...model ? { model } : {},
21443
+ gateway: this.options.baseUrl ?? databricksModelBaseUrl(this.options.host, mode),
21444
+ ...model && this.options.modelMetadata?.[model] ? this.options.modelMetadata[model] : {}
21445
+ };
21446
+ }
21447
+ providerFor(model = this.options.defaultModel) {
21448
+ if (this.explicit) return this.explicit;
21449
+ return this.modeFor(model) === "ai-gateway" ? this.gateway : this.serving;
21450
+ }
21451
+ modeFor(model) {
21452
+ const configured = this.options.mode ?? "auto";
21453
+ if (configured !== "auto") return configured;
21454
+ return isDatabricksModelService(model) ? "ai-gateway" : "serving-endpoints";
21455
+ }
21456
+ async resolveHeaders(gateway) {
21457
+ const configured = typeof this.options.headers === "function" ? await this.options.headers() : this.options.headers ?? {};
21458
+ if (!gateway) return configured;
21459
+ const supplied = typeof this.options.requestTags === "function" ? await this.options.requestTags() : this.options.requestTags ?? {};
21460
+ const context = currentSubmissionContext2();
21461
+ const tags = compactTags({
21462
+ ...context?.submissionId ? { submission_id: context.submissionId } : {},
21463
+ ...context?.attemptId ? { attempt_id: context.attemptId } : {},
21464
+ ...context?.tenantId ? { tenant_id: context.tenantId } : {},
21465
+ ...context?.agent ? { agent: context.agent } : {},
21466
+ ...supplied
21467
+ });
21468
+ return Object.keys(tags).length > 0 ? { ...configured, "Databricks-Ai-Gateway-Request-Tags": JSON.stringify(tags) } : configured;
21469
+ }
21470
+ };
21471
+ function compactTags(tags) {
21472
+ return Object.fromEntries(
21473
+ Object.entries(tags).filter(([key, value]) => key.length > 0 && value.length > 0).map(([key, value]) => [key.slice(0, 128), value.slice(0, 512)])
21474
+ );
21475
+ }
21476
+ function databricksFoundationModelProvider(options) {
21477
+ return new DatabricksModelProvider(options);
21478
+ }
21479
+ function inferenceMode(value) {
21480
+ if (!value) return void 0;
21481
+ if (value === "auto" || value === "ai-gateway" || value === "serving-endpoints") return value;
21482
+ throw new Error(
21483
+ `Invalid DATABRICKS_INFERENCE_MODE "${value}". Use auto, ai-gateway, or serving-endpoints.`
21484
+ );
21485
+ }
21486
+ function origin(value) {
21487
+ try {
21488
+ return new URL(value).origin;
21489
+ } catch {
21490
+ return value;
21491
+ }
21492
+ }
21493
+ var factory = (parsed, providers, env2, warnings) => {
21494
+ const settings = providers?.databricks;
21495
+ const configuredUrl = settings?.baseUrl;
21496
+ const rawHost = env2.DATABRICKS_HOST ?? (configuredUrl ? origin(configuredUrl) : void 0);
21497
+ if (!rawHost)
21498
+ throw new Error(
21499
+ "Missing Databricks host. Set DATABRICKS_HOST or providers.databricks.baseUrl."
21500
+ );
21501
+ const host = rawHost.includes("://") ? rawHost : `https://${rawHost}`;
21502
+ const staticToken = settings?.apiKey?.trim() || env2[settings?.apiKeyEnv ?? "DATABRICKS_TOKEN"]?.trim() || env2.DATABRICKS_API_KEY?.trim();
21503
+ let principal;
21504
+ if (!staticToken) {
21505
+ try {
21506
+ principal = databricksPrincipalFromEnv(env2);
21507
+ } catch {
21508
+ }
21509
+ }
21510
+ if (!staticToken && !principal)
21511
+ throw new Error(
21512
+ "Missing Databricks credentials. Set DATABRICKS_TOKEN, DATABRICKS_CLIENT_ID + DATABRICKS_CLIENT_SECRET, or providers.databricks.apiKey/apiKeyEnv."
21513
+ );
21514
+ const token = staticToken ?? databricksIdentity(principal);
21515
+ const explicitBaseUrl = env2.DATABRICKS_AI_GATEWAY_BASE_URL ?? (configuredUrl && new URL(configuredUrl).pathname !== "/" ? configuredUrl : void 0);
21516
+ const mode = inferenceMode(env2.DATABRICKS_INFERENCE_MODE);
21517
+ return {
21518
+ model: parsed.modelId,
21519
+ provider: databricksFoundationModelProvider({
21520
+ host,
21521
+ token,
21522
+ defaultModel: parsed.modelId,
21523
+ ...explicitBaseUrl ? { baseUrl: explicitBaseUrl } : {},
21524
+ ...mode ? { mode } : {},
21525
+ ...settings?.headers ? { headers: settings.headers } : {}
21526
+ }),
21527
+ providerName: "databricks",
21528
+ modelId: parsed.modelId,
21529
+ warnings
21530
+ };
21531
+ };
21532
+ var registered = false;
21533
+ function registerDatabricksModelProvider() {
21534
+ if (registered) return;
21535
+ registered = true;
21536
+ registerModelProvider("databricks", factory);
21537
+ }
21538
+
21539
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/clientinfo.js
21540
+ var ClientInfoError = class extends Error {
21541
+ code;
21542
+ constructor(code, message) {
21543
+ super(message);
21544
+ this.name = "ClientInfoError";
21545
+ this.code = code;
21546
+ }
21547
+ };
21548
+ var SEMVER_CORE = String.raw`(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)`;
21549
+ var SEMVER_PRERELEASE = String.raw`(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?`;
21550
+ var SEMVER_BUILDMETADATA = String.raw`(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?`;
21551
+ var REGEXP_SEMVER = new RegExp("^" + SEMVER_CORE + SEMVER_PRERELEASE + SEMVER_BUILDMETADATA + "$");
21552
+ var REGEXP_VALID_SEGMENT = /^[-0-9A-Za-z_.+]+$/;
21553
+ var REGEXP_INVALID_SEGMENT_CHAR = /[^-0-9A-Za-z_.+]/g;
21554
+ function isValidSegment(s2) {
21555
+ return REGEXP_VALID_SEGMENT.test(s2);
21556
+ }
21557
+ function sanitize(s2) {
21558
+ return s2.replace(REGEXP_INVALID_SEGMENT_CHAR, "-");
21559
+ }
21560
+ var ClientInfo = class _ClientInfo {
21561
+ static EMPTY = new _ClientInfo();
21562
+ segments;
21563
+ constructor(segments = []) {
21564
+ this.segments = [...segments];
21565
+ }
21566
+ /**
21567
+ * Returns a new {@link ClientInfo} with the given items appended. Accepts
21568
+ * either individual key/value pairs or another {@link ClientInfo} whose
21569
+ * segments are merged in order. The original is not modified; mixing the
21570
+ * two forms in a single call is supported.
21571
+ *
21572
+ * Keys and values on pair arguments must contain only alphanumeric
21573
+ * characters plus `_`, `.`, `+`, or `-`. Exact key+value duplicates are
21574
+ * silently ignored. On error, an exception is thrown (all-or-nothing).
21575
+ *
21576
+ * @example
21577
+ * ```ts
21578
+ * base.with({key: 'partner', value: 'acme'});
21579
+ * base.with(pkgClientInfo);
21580
+ * base.with(pkgClientInfo, {key: 'sdk-feature', value: 'pagination'});
21581
+ * ```
21582
+ */
21583
+ with(...items) {
21584
+ if (items.length === 0) {
21585
+ return this;
21586
+ }
21587
+ const newSegments = [...this.segments];
21588
+ for (const item of items) {
21589
+ const pairs = item instanceof _ClientInfo ? item.segments : [item];
21590
+ for (const { key, value } of pairs) {
21591
+ if (!isValidSegment(key)) {
21592
+ throw new ClientInfoError("INVALID_KEY", `Invalid key: ${key}.`);
21593
+ }
21594
+ if (!isValidSegment(value)) {
21595
+ throw new ClientInfoError("INVALID_VALUE", `Invalid value for "${key}": ${value}.`);
21596
+ }
21597
+ if (newSegments.some((s2) => s2.key === key && s2.value === value)) {
21598
+ continue;
21599
+ }
21600
+ newSegments.push({ key, value });
21601
+ }
21602
+ }
21603
+ return new _ClientInfo(newSegments);
21604
+ }
21605
+ /**
21606
+ * Returns a string representation of the client info suitable for
21607
+ * inclusion in HTTP headers. Key/value pairs are formatted as
21608
+ * "key/value" and joined by spaces in the order they were inserted.
21609
+ */
21610
+ toString() {
21611
+ return this.segments.map((s2) => `${s2.key}/${s2.value}`).join(" ");
21612
+ }
21613
+ };
21614
+
21615
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/package.json
21616
+ var package_default2 = {
21617
+ name: "@databricks/sdk-core",
21618
+ version: "0.21.0",
21619
+ description: "Databricks core library for JavaScript/TypeScript",
21620
+ type: "module",
21621
+ main: "./dist/index.js",
21622
+ types: "./dist/index.d.ts",
21623
+ exports: {
21624
+ ".": {
21625
+ types: "./dist/index.d.ts",
21626
+ import: "./dist/index.js",
21627
+ default: "./dist/index.js"
21628
+ },
21629
+ "./profiles": {
21630
+ types: "./dist/profiles/index.d.ts",
21631
+ import: "./dist/profiles/index.js",
21632
+ default: "./dist/profiles/index.js"
21633
+ },
21634
+ "./profiles/browser": {
21635
+ types: "./dist/profiles/index.browser.d.ts",
21636
+ import: "./dist/profiles/index.browser.js",
21637
+ default: "./dist/profiles/index.browser.js"
21638
+ },
21639
+ "./wkt": {
21640
+ types: "./dist/wkt/index.d.ts",
21641
+ import: "./dist/wkt/index.js",
21642
+ default: "./dist/wkt/index.js"
21643
+ },
21644
+ "./clientinfo": {
21645
+ browser: {
21646
+ types: "./dist/clientinfo/index.browser.d.ts",
21647
+ import: "./dist/clientinfo/index.browser.js",
21648
+ default: "./dist/clientinfo/index.browser.js"
21649
+ },
21650
+ default: {
21651
+ types: "./dist/clientinfo/index.d.ts",
21652
+ import: "./dist/clientinfo/index.js",
21653
+ default: "./dist/clientinfo/index.js"
21654
+ }
21655
+ },
21656
+ "./clientinfo/browser": {
21657
+ types: "./dist/clientinfo/index.browser.d.ts",
21658
+ import: "./dist/clientinfo/index.browser.js",
21659
+ default: "./dist/clientinfo/index.browser.js"
21660
+ },
21661
+ "./http": {
21662
+ types: "./dist/http/index.d.ts",
21663
+ import: "./dist/http/index.js",
21664
+ default: "./dist/http/index.js"
21665
+ },
21666
+ "./logger": {
21667
+ types: "./dist/logger/index.d.ts",
21668
+ import: "./dist/logger/index.js",
21669
+ default: "./dist/logger/index.js"
21670
+ },
21671
+ "./ops": {
21672
+ types: "./dist/ops/index.d.ts",
21673
+ import: "./dist/ops/index.js",
21674
+ default: "./dist/ops/index.js"
21675
+ },
21676
+ "./apierror": {
21677
+ types: "./dist/apierror/index.d.ts",
21678
+ import: "./dist/apierror/index.js",
21679
+ default: "./dist/apierror/index.js"
21680
+ },
21681
+ "./apierror/codes": {
21682
+ types: "./dist/apierror/codes/index.d.ts",
21683
+ import: "./dist/apierror/codes/index.js",
21684
+ default: "./dist/apierror/codes/index.js"
21685
+ }
21686
+ },
21687
+ files: [
21688
+ "dist",
21689
+ "LICENSE"
21690
+ ],
21691
+ scripts: {
21692
+ build: "tsc -b",
21693
+ lint: "eslint src tests --ext .ts",
21694
+ "lint:fix": "eslint src tests --ext .ts --fix",
21695
+ format: 'prettier --write "src/**/*.ts" "tests/**/*.ts"',
21696
+ "format:check": 'prettier --check "src/**/*.ts" "tests/**/*.ts"',
21697
+ test: "vitest run",
21698
+ "test:browser": "vitest run --config vitest.config.browser.ts",
21699
+ typecheck: "tsc --noEmit",
21700
+ clean: "rm -rf dist tsconfig.tsbuildinfo"
21701
+ },
21702
+ author: "Databricks",
21703
+ license: "Apache-2.0",
21704
+ engines: {
21705
+ node: ">=22.0.0"
21706
+ },
21707
+ dependencies: {
21708
+ "json-bigint": "^1.0.0",
21709
+ zod: "^4.3.6"
21710
+ }
21711
+ };
21712
+
21713
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/base.js
21714
+ var MODULE_NAME = "sdk-js-core";
21715
+ var VERSION2 = package_default2.version;
21716
+ var base = ClientInfo.EMPTY;
21717
+ function getBase() {
21718
+ return base;
21719
+ }
21720
+
21721
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/agent.js
21722
+ var AGENT_ENV_VAR = "AGENT";
21723
+ var AI_AGENT_ENV_VAR = "AI_AGENT";
21724
+ var MAX_AGENT_FALLBACK_LEN = 64;
21725
+ var KNOWN_AGENTS = [
21726
+ // The amp agent also sets AGENT=amp, handled by the central fallback.
21727
+ { envVar: "AMP_CURRENT_THREAD_ID", product: "amp" },
21728
+ { envVar: "ANTIGRAVITY_AGENT", product: "antigravity" },
21729
+ { envVar: "AUGMENT_AGENT", product: "augment" },
21730
+ { envVar: "CLAUDECODE", product: "claude-code" },
21731
+ { envVar: "CLINE_ACTIVE", product: "cline" },
21732
+ { envVar: "CODEX_CI", product: "codex" },
21733
+ { envVar: "COPILOT_CLI", product: "copilot-cli" },
21734
+ { envVar: "CURSOR_AGENT", product: "cursor" },
21735
+ { envVar: "GEMINI_CLI", product: "gemini-cli" },
21736
+ // The goose agent also sets AGENT=goose, handled by the central
21737
+ // fallback.
21738
+ { envVar: "GOOSE_TERMINAL", product: "goose" },
21739
+ { envVar: "KIRO", product: "kiro" },
21740
+ { envVar: "OPENCLAW_SHELL", product: "openclaw" },
21741
+ { envVar: "OPENCODE", product: "opencode" },
21742
+ // Set by VS Code 1.121+ for agent-initiated terminal commands
21743
+ // (https://code.visualstudio.com/updates/v1_121).
21744
+ { envVar: "VSCODE_AGENT", product: "vscode-agent" },
21745
+ { envVar: "WINDSURF_AGENT", product: "windsurf" }
21746
+ ];
21747
+ function agentEnvFallback() {
21748
+ let v2 = process.env[AGENT_ENV_VAR];
21749
+ if (v2 === void 0 || v2 === "") {
21750
+ v2 = process.env[AI_AGENT_ENV_VAR];
21751
+ }
21752
+ if (v2 === void 0 || v2 === "") {
21753
+ return "";
21754
+ }
21755
+ return sanitize(v2).slice(0, MAX_AGENT_FALLBACK_LEN);
21756
+ }
21757
+ function lookupAgentProvider() {
21758
+ const matches = [];
21759
+ for (const a2 of KNOWN_AGENTS) {
21760
+ if (a2.envVar in process.env) {
21761
+ matches.push(a2.product);
21762
+ }
21763
+ }
21764
+ if (matches.length === 1) {
21765
+ return matches[0];
21766
+ }
21767
+ if (matches.length > 1) {
21768
+ return "multiple";
21769
+ }
21770
+ return agentEnvFallback();
21771
+ }
21772
+ var cached2;
21773
+ function agentProvider() {
21774
+ cached2 ??= lookupAgentProvider();
21775
+ return cached2;
21776
+ }
21777
+
21778
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/meta-harness.js
21779
+ var KNOWN_META_HARNESSES = [
21780
+ // OMNIGENT is set by the omnigent meta-harness
21781
+ // (https://github.com/omnigent-ai/omnigent).
21782
+ { envVar: "OMNIGENT", product: "omnigent" }
21783
+ ];
21784
+ function lookupMetaHarnessProvider() {
21785
+ const matches = [];
21786
+ for (const h2 of KNOWN_META_HARNESSES) {
21787
+ if (h2.envVar in process.env) {
21788
+ matches.push(h2.product);
21789
+ }
21790
+ }
21791
+ if (matches.length === 1) {
21792
+ return matches[0];
21793
+ }
21794
+ if (matches.length > 1) {
21795
+ return "multiple";
21796
+ }
21797
+ return "";
21798
+ }
21799
+ var cached3;
21800
+ function metaHarnessProvider() {
21801
+ cached3 ??= lookupMetaHarnessProvider();
21802
+ return cached3;
21803
+ }
21804
+
21805
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/clientinfo/default.js
21806
+ var CICD_PROVIDERS = [
21807
+ {
21808
+ name: "github",
21809
+ envVars: [{ name: "GITHUB_ACTIONS", expectedValue: "true" }]
21810
+ },
21811
+ {
21812
+ name: "gitlab",
21813
+ envVars: [{ name: "GITLAB_CI", expectedValue: "true" }]
21814
+ },
21815
+ { name: "jenkins", envVars: [{ name: "JENKINS_URL", expectedValue: "" }] },
21816
+ {
21817
+ name: "azure-devops",
21818
+ envVars: [{ name: "TF_BUILD", expectedValue: "True" }]
21819
+ },
21820
+ {
21821
+ name: "circle",
21822
+ envVars: [{ name: "CIRCLECI", expectedValue: "true" }]
21823
+ },
21824
+ { name: "travis", envVars: [{ name: "TRAVIS", expectedValue: "true" }] },
21825
+ {
21826
+ name: "bitbucket",
21827
+ envVars: [{ name: "BITBUCKET_BUILD_NUMBER", expectedValue: "" }]
21828
+ },
21829
+ {
21830
+ name: "google-cloud-build",
21831
+ envVars: [
21832
+ { name: "PROJECT_ID", expectedValue: "" },
21833
+ { name: "BUILD_ID", expectedValue: "" },
21834
+ { name: "PROJECT_NUMBER", expectedValue: "" },
21835
+ { name: "LOCATION", expectedValue: "" }
21836
+ ]
21837
+ },
21838
+ {
21839
+ name: "aws-code-build",
21840
+ envVars: [{ name: "CODEBUILD_BUILD_ARN", expectedValue: "" }]
21841
+ },
21842
+ { name: "tf-cloud", envVars: [{ name: "TFC_RUN_ID", expectedValue: "" }] }
21843
+ ];
21844
+ function detectCicd() {
21845
+ for (const p2 of CICD_PROVIDERS) {
21846
+ const allMatch = p2.envVars.every((ev) => {
21847
+ const v2 = process.env[ev.name];
21848
+ return v2 !== void 0 && (ev.expectedValue === "" || v2 === ev.expectedValue);
21849
+ });
21850
+ if (allMatch) {
21851
+ return p2.name;
21852
+ }
21853
+ }
21854
+ return "";
21855
+ }
21856
+ function normalizeNodeVersion(raw) {
21857
+ if (!raw.startsWith("v")) {
21858
+ return "0.0.0-dev";
21859
+ }
21860
+ return raw.slice(1);
21861
+ }
21862
+ var CACHED_NODE_VERSION = normalizeNodeVersion(process.version);
21863
+ function createDefault() {
21864
+ const pairs = [
21865
+ { key: MODULE_NAME, value: VERSION2 },
21866
+ { key: "node", value: CACHED_NODE_VERSION },
21867
+ { key: "os", value: process.platform },
21868
+ ...getBase().segments
21869
+ ];
21870
+ const upstream = process.env.DATABRICKS_SDK_UPSTREAM;
21871
+ if (upstream !== void 0) {
21872
+ const upstreamVersion = process.env.DATABRICKS_SDK_UPSTREAM_VERSION;
21873
+ if (upstreamVersion !== void 0) {
21874
+ pairs.push({ key: "upstream", value: sanitize(upstream) }, { key: "upstream-version", value: sanitize(upstreamVersion) });
21875
+ }
21876
+ }
21877
+ const cicd = detectCicd();
21878
+ if (cicd !== "") {
21879
+ pairs.push({ key: "cicd", value: cicd });
21880
+ }
21881
+ const runtime = process.env.DATABRICKS_RUNTIME_VERSION;
21882
+ if (runtime !== void 0 && runtime !== "") {
21883
+ pairs.push({ key: "runtime", value: sanitize(runtime) });
21884
+ }
21885
+ const agent = agentProvider();
21886
+ if (agent !== "") {
21887
+ pairs.push({ key: "agent", value: agent });
21888
+ }
21889
+ const metaHarness = metaHarnessProvider();
21890
+ if (metaHarness !== "") {
21891
+ pairs.push({ key: "meta-harness", value: metaHarness });
21892
+ }
21893
+ return ClientInfo.EMPTY.with(...pairs);
21894
+ }
21895
+
21896
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/logger/logger.js
21897
+ var NoOpLogger = class {
21898
+ debug() {
21899
+ }
21900
+ info() {
21901
+ }
21902
+ warn() {
21903
+ }
21904
+ error() {
21905
+ }
21906
+ };
21907
+
21908
+ // ../../node_modules/.pnpm/@databricks+sdk-core@0.21.0/node_modules/@databricks/sdk-core/dist/http/http.js
21909
+ function newFetchHttpClient() {
21910
+ return {
21911
+ async send(request) {
21912
+ const init = {
21913
+ method: request.method,
21914
+ headers: request.headers
21915
+ };
21916
+ if (request.body !== void 0) {
21917
+ init.body = request.body;
21918
+ if (request.body instanceof ReadableStream) {
21919
+ init.duplex = "half";
21920
+ }
21921
+ }
21922
+ if (request.signal !== void 0) {
21923
+ init.signal = request.signal;
21924
+ }
21925
+ const response = await fetch(request.url, init);
21926
+ return {
21927
+ statusCode: response.status,
21928
+ headers: response.headers,
21929
+ body: response.body
21930
+ };
21931
+ }
21932
+ };
21933
+ }
21934
+
21935
+ // ../../node_modules/.pnpm/@databricks+sdk-accessmanagement@0.21.0/node_modules/@databricks/sdk-accessmanagement/dist/v1/transport.js
21936
+ async function resolveClientConfig(options) {
21937
+ const profile = await resolve(options.profileOptions);
21938
+ const host = options.host ?? profile.host;
21939
+ if (host === void 0) {
21940
+ throw new Error("Host is required.");
21941
+ }
21942
+ const base2 = options.httpClient ?? newFetchHttpClient();
21943
+ const credentials = options.credentials ?? defaultCredentials({ profile });
21944
+ let httpClient = new AuthHttpClient(base2, credentials);
21945
+ if (options.timeout !== void 0) {
21946
+ httpClient = new TimeoutHttpClient(httpClient, options.timeout);
21947
+ }
21948
+ const accountId = options.accountId ?? profile.accountId;
21949
+ const workspaceId = options.workspaceId ?? profile.workspaceId;
21950
+ return {
21951
+ host: host.replace(/\/$/, ""),
21952
+ httpClient,
21953
+ ...accountId !== void 0 && { accountId },
21954
+ ...workspaceId !== void 0 && { workspaceId }
21955
+ };
21956
+ }
21957
+ var AuthHttpClient = class {
21958
+ base;
21959
+ credentials;
21960
+ constructor(base2, credentials) {
21961
+ this.base = base2;
21962
+ this.credentials = credentials;
21963
+ }
21964
+ async send(request) {
21965
+ const authHeaders = await this.credentials.authHeaders();
21966
+ const headers = new Headers(request.headers);
21967
+ for (const h2 of authHeaders) {
21968
+ headers.set(h2.key, h2.value);
21969
+ }
21970
+ return this.base.send({ ...request, headers });
21971
+ }
21972
+ };
21973
+ var TimeoutHttpClient = class {
21974
+ base;
21975
+ timeout;
21555
21976
  constructor(base2, timeout) {
21556
21977
  this.base = base2;
21557
21978
  this.timeout = timeout;
@@ -55096,379 +55517,7 @@ var CreateCdfConfigOperation = class {
55096
55517
  if (op.result?.$case !== "response") {
55097
55518
  throw new Error("operation completed without a response");
55098
55519
  }
55099
- result = external_exports.lazy(() => unmarshalCdfConfigSchema).parse(op.result.response);
55100
- };
55101
- await executeWait6(call, options);
55102
- if (result === void 0) {
55103
- throw new Error("operation completed without a result.");
55104
- }
55105
- return result;
55106
- }
55107
- /** Checks whether the operation has completed */
55108
- async done(options) {
55109
- const op = await this.getOperation({ name: this.operation.name }, options);
55110
- this.operation = op;
55111
- return op.done;
55112
- }
55113
- };
55114
- var CreateDataApiOperation = class {
55115
- operation;
55116
- getOperation;
55117
- constructor(operation, getOperation) {
55118
- this.operation = operation;
55119
- this.getOperation = getOperation;
55120
- }
55121
- /** Returns the server-assigned name of the long-running operation. */
55122
- name() {
55123
- return Promise.resolve(this.operation.name);
55124
- }
55125
- /** Returns metadata associated with the long-running operation. */
55126
- metadata() {
55127
- if (this.operation.metadata === void 0) {
55128
- return Promise.resolve(void 0);
55129
- }
55130
- return Promise.resolve(external_exports.lazy(() => unmarshalDataApiOperationMetadataSchema).parse(this.operation.metadata));
55131
- }
55132
- /**
55133
- * Polls the operation until it completes.
55134
- *
55135
- * Throws if the operation failed.
55136
- */
55137
- async wait(options) {
55138
- let result;
55139
- const call = async (callSignal) => {
55140
- const op = await this.getOperation({
55141
- name: this.operation.name
55142
- }, callSignal !== void 0 ? { signal: callSignal } : void 0);
55143
- this.operation = op;
55144
- if (op.done === void 0) {
55145
- throw new Error("operation is missing the done field");
55146
- }
55147
- if (!op.done) {
55148
- throw new StillRunningError6();
55149
- }
55150
- if (op.result?.$case === "error") {
55151
- const err = op.result.error;
55152
- const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
55153
- const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
55154
- throw new Error(`operation failed: ${errorMsg}`, {
55155
- cause: err
55156
- });
55157
- }
55158
- if (op.result?.$case !== "response") {
55159
- throw new Error("operation completed without a response");
55160
- }
55161
- result = external_exports.lazy(() => unmarshalDataApiSchema).parse(op.result.response);
55162
- };
55163
- await executeWait6(call, options);
55164
- if (result === void 0) {
55165
- throw new Error("operation completed without a result.");
55166
- }
55167
- return result;
55168
- }
55169
- /** Checks whether the operation has completed */
55170
- async done(options) {
55171
- const op = await this.getOperation({ name: this.operation.name }, options);
55172
- this.operation = op;
55173
- return op.done;
55174
- }
55175
- };
55176
- var CreateDatabaseOperation = class {
55177
- operation;
55178
- getOperation;
55179
- constructor(operation, getOperation) {
55180
- this.operation = operation;
55181
- this.getOperation = getOperation;
55182
- }
55183
- /** Returns the server-assigned name of the long-running operation. */
55184
- name() {
55185
- return Promise.resolve(this.operation.name);
55186
- }
55187
- /** Returns metadata associated with the long-running operation. */
55188
- metadata() {
55189
- if (this.operation.metadata === void 0) {
55190
- return Promise.resolve(void 0);
55191
- }
55192
- return Promise.resolve(external_exports.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata));
55193
- }
55194
- /**
55195
- * Polls the operation until it completes.
55196
- *
55197
- * Throws if the operation failed.
55198
- */
55199
- async wait(options) {
55200
- let result;
55201
- const call = async (callSignal) => {
55202
- const op = await this.getOperation({
55203
- name: this.operation.name
55204
- }, callSignal !== void 0 ? { signal: callSignal } : void 0);
55205
- this.operation = op;
55206
- if (op.done === void 0) {
55207
- throw new Error("operation is missing the done field");
55208
- }
55209
- if (!op.done) {
55210
- throw new StillRunningError6();
55211
- }
55212
- if (op.result?.$case === "error") {
55213
- const err = op.result.error;
55214
- const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
55215
- const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
55216
- throw new Error(`operation failed: ${errorMsg}`, {
55217
- cause: err
55218
- });
55219
- }
55220
- if (op.result?.$case !== "response") {
55221
- throw new Error("operation completed without a response");
55222
- }
55223
- result = external_exports.lazy(() => unmarshalDatabaseSchema).parse(op.result.response);
55224
- };
55225
- await executeWait6(call, options);
55226
- if (result === void 0) {
55227
- throw new Error("operation completed without a result.");
55228
- }
55229
- return result;
55230
- }
55231
- /** Checks whether the operation has completed */
55232
- async done(options) {
55233
- const op = await this.getOperation({ name: this.operation.name }, options);
55234
- this.operation = op;
55235
- return op.done;
55236
- }
55237
- };
55238
- var CreateEndpointOperation = class {
55239
- operation;
55240
- getOperation;
55241
- constructor(operation, getOperation) {
55242
- this.operation = operation;
55243
- this.getOperation = getOperation;
55244
- }
55245
- /** Returns the server-assigned name of the long-running operation. */
55246
- name() {
55247
- return Promise.resolve(this.operation.name);
55248
- }
55249
- /** Returns metadata associated with the long-running operation. */
55250
- metadata() {
55251
- if (this.operation.metadata === void 0) {
55252
- return Promise.resolve(void 0);
55253
- }
55254
- return Promise.resolve(external_exports.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata));
55255
- }
55256
- /**
55257
- * Polls the operation until it completes.
55258
- *
55259
- * Throws if the operation failed.
55260
- */
55261
- async wait(options) {
55262
- let result;
55263
- const call = async (callSignal) => {
55264
- const op = await this.getOperation({
55265
- name: this.operation.name
55266
- }, callSignal !== void 0 ? { signal: callSignal } : void 0);
55267
- this.operation = op;
55268
- if (op.done === void 0) {
55269
- throw new Error("operation is missing the done field");
55270
- }
55271
- if (!op.done) {
55272
- throw new StillRunningError6();
55273
- }
55274
- if (op.result?.$case === "error") {
55275
- const err = op.result.error;
55276
- const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
55277
- const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
55278
- throw new Error(`operation failed: ${errorMsg}`, {
55279
- cause: err
55280
- });
55281
- }
55282
- if (op.result?.$case !== "response") {
55283
- throw new Error("operation completed without a response");
55284
- }
55285
- result = external_exports.lazy(() => unmarshalEndpointSchema2).parse(op.result.response);
55286
- };
55287
- await executeWait6(call, options);
55288
- if (result === void 0) {
55289
- throw new Error("operation completed without a result.");
55290
- }
55291
- return result;
55292
- }
55293
- /** Checks whether the operation has completed */
55294
- async done(options) {
55295
- const op = await this.getOperation({ name: this.operation.name }, options);
55296
- this.operation = op;
55297
- return op.done;
55298
- }
55299
- };
55300
- var CreateProjectOperation = class {
55301
- operation;
55302
- getOperation;
55303
- constructor(operation, getOperation) {
55304
- this.operation = operation;
55305
- this.getOperation = getOperation;
55306
- }
55307
- /** Returns the server-assigned name of the long-running operation. */
55308
- name() {
55309
- return Promise.resolve(this.operation.name);
55310
- }
55311
- /** Returns metadata associated with the long-running operation. */
55312
- metadata() {
55313
- if (this.operation.metadata === void 0) {
55314
- return Promise.resolve(void 0);
55315
- }
55316
- return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
55317
- }
55318
- /**
55319
- * Polls the operation until it completes.
55320
- *
55321
- * Throws if the operation failed.
55322
- */
55323
- async wait(options) {
55324
- let result;
55325
- const call = async (callSignal) => {
55326
- const op = await this.getOperation({
55327
- name: this.operation.name
55328
- }, callSignal !== void 0 ? { signal: callSignal } : void 0);
55329
- this.operation = op;
55330
- if (op.done === void 0) {
55331
- throw new Error("operation is missing the done field");
55332
- }
55333
- if (!op.done) {
55334
- throw new StillRunningError6();
55335
- }
55336
- if (op.result?.$case === "error") {
55337
- const err = op.result.error;
55338
- const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
55339
- const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
55340
- throw new Error(`operation failed: ${errorMsg}`, {
55341
- cause: err
55342
- });
55343
- }
55344
- if (op.result?.$case !== "response") {
55345
- throw new Error("operation completed without a response");
55346
- }
55347
- result = external_exports.lazy(() => unmarshalProjectSchema).parse(op.result.response);
55348
- };
55349
- await executeWait6(call, options);
55350
- if (result === void 0) {
55351
- throw new Error("operation completed without a result.");
55352
- }
55353
- return result;
55354
- }
55355
- /** Checks whether the operation has completed */
55356
- async done(options) {
55357
- const op = await this.getOperation({ name: this.operation.name }, options);
55358
- this.operation = op;
55359
- return op.done;
55360
- }
55361
- };
55362
- var CreateRoleOperation = class {
55363
- operation;
55364
- getOperation;
55365
- constructor(operation, getOperation) {
55366
- this.operation = operation;
55367
- this.getOperation = getOperation;
55368
- }
55369
- /** Returns the server-assigned name of the long-running operation. */
55370
- name() {
55371
- return Promise.resolve(this.operation.name);
55372
- }
55373
- /** Returns metadata associated with the long-running operation. */
55374
- metadata() {
55375
- if (this.operation.metadata === void 0) {
55376
- return Promise.resolve(void 0);
55377
- }
55378
- return Promise.resolve(external_exports.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata));
55379
- }
55380
- /**
55381
- * Polls the operation until it completes.
55382
- *
55383
- * Throws if the operation failed.
55384
- */
55385
- async wait(options) {
55386
- let result;
55387
- const call = async (callSignal) => {
55388
- const op = await this.getOperation({
55389
- name: this.operation.name
55390
- }, callSignal !== void 0 ? { signal: callSignal } : void 0);
55391
- this.operation = op;
55392
- if (op.done === void 0) {
55393
- throw new Error("operation is missing the done field");
55394
- }
55395
- if (!op.done) {
55396
- throw new StillRunningError6();
55397
- }
55398
- if (op.result?.$case === "error") {
55399
- const err = op.result.error;
55400
- const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
55401
- const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
55402
- throw new Error(`operation failed: ${errorMsg}`, {
55403
- cause: err
55404
- });
55405
- }
55406
- if (op.result?.$case !== "response") {
55407
- throw new Error("operation completed without a response");
55408
- }
55409
- result = external_exports.lazy(() => unmarshalRoleSchema2).parse(op.result.response);
55410
- };
55411
- await executeWait6(call, options);
55412
- if (result === void 0) {
55413
- throw new Error("operation completed without a result.");
55414
- }
55415
- return result;
55416
- }
55417
- /** Checks whether the operation has completed */
55418
- async done(options) {
55419
- const op = await this.getOperation({ name: this.operation.name }, options);
55420
- this.operation = op;
55421
- return op.done;
55422
- }
55423
- };
55424
- var CreateSyncedTableOperation = class {
55425
- operation;
55426
- getOperation;
55427
- constructor(operation, getOperation) {
55428
- this.operation = operation;
55429
- this.getOperation = getOperation;
55430
- }
55431
- /** Returns the server-assigned name of the long-running operation. */
55432
- name() {
55433
- return Promise.resolve(this.operation.name);
55434
- }
55435
- /** Returns metadata associated with the long-running operation. */
55436
- metadata() {
55437
- if (this.operation.metadata === void 0) {
55438
- return Promise.resolve(void 0);
55439
- }
55440
- return Promise.resolve(external_exports.lazy(() => unmarshalSyncedTableOperationMetadataSchema).parse(this.operation.metadata));
55441
- }
55442
- /**
55443
- * Polls the operation until it completes.
55444
- *
55445
- * Throws if the operation failed.
55446
- */
55447
- async wait(options) {
55448
- let result;
55449
- const call = async (callSignal) => {
55450
- const op = await this.getOperation({
55451
- name: this.operation.name
55452
- }, callSignal !== void 0 ? { signal: callSignal } : void 0);
55453
- this.operation = op;
55454
- if (op.done === void 0) {
55455
- throw new Error("operation is missing the done field");
55456
- }
55457
- if (!op.done) {
55458
- throw new StillRunningError6();
55459
- }
55460
- if (op.result?.$case === "error") {
55461
- const err = op.result.error;
55462
- const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
55463
- const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
55464
- throw new Error(`operation failed: ${errorMsg}`, {
55465
- cause: err
55466
- });
55467
- }
55468
- if (op.result?.$case !== "response") {
55469
- throw new Error("operation completed without a response");
55470
- }
55471
- result = external_exports.lazy(() => unmarshalSyncedTableSchema).parse(op.result.response);
55520
+ result = external_exports.lazy(() => unmarshalCdfConfigSchema).parse(op.result.response);
55472
55521
  };
55473
55522
  await executeWait6(call, options);
55474
55523
  if (result === void 0) {
@@ -55483,7 +55532,7 @@ var CreateSyncedTableOperation = class {
55483
55532
  return op.done;
55484
55533
  }
55485
55534
  };
55486
- var DeleteBranchOperation = class {
55535
+ var CreateDataApiOperation = class {
55487
55536
  operation;
55488
55537
  getOperation;
55489
55538
  constructor(operation, getOperation) {
@@ -55499,7 +55548,7 @@ var DeleteBranchOperation = class {
55499
55548
  if (this.operation.metadata === void 0) {
55500
55549
  return Promise.resolve(void 0);
55501
55550
  }
55502
- return Promise.resolve(external_exports.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata));
55551
+ return Promise.resolve(external_exports.lazy(() => unmarshalDataApiOperationMetadataSchema).parse(this.operation.metadata));
55503
55552
  }
55504
55553
  /**
55505
55554
  * Polls the operation until it completes.
@@ -55507,6 +55556,7 @@ var DeleteBranchOperation = class {
55507
55556
  * Throws if the operation failed.
55508
55557
  */
55509
55558
  async wait(options) {
55559
+ let result;
55510
55560
  const call = async (callSignal) => {
55511
55561
  const op = await this.getOperation({
55512
55562
  name: this.operation.name
@@ -55526,8 +55576,16 @@ var DeleteBranchOperation = class {
55526
55576
  cause: err
55527
55577
  });
55528
55578
  }
55579
+ if (op.result?.$case !== "response") {
55580
+ throw new Error("operation completed without a response");
55581
+ }
55582
+ result = external_exports.lazy(() => unmarshalDataApiSchema).parse(op.result.response);
55529
55583
  };
55530
55584
  await executeWait6(call, options);
55585
+ if (result === void 0) {
55586
+ throw new Error("operation completed without a result.");
55587
+ }
55588
+ return result;
55531
55589
  }
55532
55590
  /** Checks whether the operation has completed */
55533
55591
  async done(options) {
@@ -55536,7 +55594,7 @@ var DeleteBranchOperation = class {
55536
55594
  return op.done;
55537
55595
  }
55538
55596
  };
55539
- var DeleteCatalogOperation = class {
55597
+ var CreateDatabaseOperation = class {
55540
55598
  operation;
55541
55599
  getOperation;
55542
55600
  constructor(operation, getOperation) {
@@ -55552,7 +55610,7 @@ var DeleteCatalogOperation = class {
55552
55610
  if (this.operation.metadata === void 0) {
55553
55611
  return Promise.resolve(void 0);
55554
55612
  }
55555
- return Promise.resolve(external_exports.lazy(() => unmarshalCatalogOperationMetadataSchema).parse(this.operation.metadata));
55613
+ return Promise.resolve(external_exports.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata));
55556
55614
  }
55557
55615
  /**
55558
55616
  * Polls the operation until it completes.
@@ -55560,6 +55618,7 @@ var DeleteCatalogOperation = class {
55560
55618
  * Throws if the operation failed.
55561
55619
  */
55562
55620
  async wait(options) {
55621
+ let result;
55563
55622
  const call = async (callSignal) => {
55564
55623
  const op = await this.getOperation({
55565
55624
  name: this.operation.name
@@ -55579,8 +55638,16 @@ var DeleteCatalogOperation = class {
55579
55638
  cause: err
55580
55639
  });
55581
55640
  }
55641
+ if (op.result?.$case !== "response") {
55642
+ throw new Error("operation completed without a response");
55643
+ }
55644
+ result = external_exports.lazy(() => unmarshalDatabaseSchema).parse(op.result.response);
55582
55645
  };
55583
55646
  await executeWait6(call, options);
55647
+ if (result === void 0) {
55648
+ throw new Error("operation completed without a result.");
55649
+ }
55650
+ return result;
55584
55651
  }
55585
55652
  /** Checks whether the operation has completed */
55586
55653
  async done(options) {
@@ -55589,7 +55656,7 @@ var DeleteCatalogOperation = class {
55589
55656
  return op.done;
55590
55657
  }
55591
55658
  };
55592
- var DeleteCdfConfigOperation = class {
55659
+ var CreateEndpointOperation = class {
55593
55660
  operation;
55594
55661
  getOperation;
55595
55662
  constructor(operation, getOperation) {
@@ -55605,7 +55672,7 @@ var DeleteCdfConfigOperation = class {
55605
55672
  if (this.operation.metadata === void 0) {
55606
55673
  return Promise.resolve(void 0);
55607
55674
  }
55608
- return Promise.resolve(external_exports.lazy(() => unmarshalCdfConfigOperationMetadataSchema).parse(this.operation.metadata));
55675
+ return Promise.resolve(external_exports.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata));
55609
55676
  }
55610
55677
  /**
55611
55678
  * Polls the operation until it completes.
@@ -55613,6 +55680,7 @@ var DeleteCdfConfigOperation = class {
55613
55680
  * Throws if the operation failed.
55614
55681
  */
55615
55682
  async wait(options) {
55683
+ let result;
55616
55684
  const call = async (callSignal) => {
55617
55685
  const op = await this.getOperation({
55618
55686
  name: this.operation.name
@@ -55632,8 +55700,16 @@ var DeleteCdfConfigOperation = class {
55632
55700
  cause: err
55633
55701
  });
55634
55702
  }
55703
+ if (op.result?.$case !== "response") {
55704
+ throw new Error("operation completed without a response");
55705
+ }
55706
+ result = external_exports.lazy(() => unmarshalEndpointSchema2).parse(op.result.response);
55635
55707
  };
55636
55708
  await executeWait6(call, options);
55709
+ if (result === void 0) {
55710
+ throw new Error("operation completed without a result.");
55711
+ }
55712
+ return result;
55637
55713
  }
55638
55714
  /** Checks whether the operation has completed */
55639
55715
  async done(options) {
@@ -55642,7 +55718,7 @@ var DeleteCdfConfigOperation = class {
55642
55718
  return op.done;
55643
55719
  }
55644
55720
  };
55645
- var DeleteDataApiOperation = class {
55721
+ var CreateProjectOperation = class {
55646
55722
  operation;
55647
55723
  getOperation;
55648
55724
  constructor(operation, getOperation) {
@@ -55658,7 +55734,7 @@ var DeleteDataApiOperation = class {
55658
55734
  if (this.operation.metadata === void 0) {
55659
55735
  return Promise.resolve(void 0);
55660
55736
  }
55661
- return Promise.resolve(external_exports.lazy(() => unmarshalDataApiOperationMetadataSchema).parse(this.operation.metadata));
55737
+ return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
55662
55738
  }
55663
55739
  /**
55664
55740
  * Polls the operation until it completes.
@@ -55666,6 +55742,7 @@ var DeleteDataApiOperation = class {
55666
55742
  * Throws if the operation failed.
55667
55743
  */
55668
55744
  async wait(options) {
55745
+ let result;
55669
55746
  const call = async (callSignal) => {
55670
55747
  const op = await this.getOperation({
55671
55748
  name: this.operation.name
@@ -55685,8 +55762,16 @@ var DeleteDataApiOperation = class {
55685
55762
  cause: err
55686
55763
  });
55687
55764
  }
55765
+ if (op.result?.$case !== "response") {
55766
+ throw new Error("operation completed without a response");
55767
+ }
55768
+ result = external_exports.lazy(() => unmarshalProjectSchema).parse(op.result.response);
55688
55769
  };
55689
55770
  await executeWait6(call, options);
55771
+ if (result === void 0) {
55772
+ throw new Error("operation completed without a result.");
55773
+ }
55774
+ return result;
55690
55775
  }
55691
55776
  /** Checks whether the operation has completed */
55692
55777
  async done(options) {
@@ -55695,7 +55780,7 @@ var DeleteDataApiOperation = class {
55695
55780
  return op.done;
55696
55781
  }
55697
55782
  };
55698
- var DeleteDatabaseOperation = class {
55783
+ var CreateRoleOperation = class {
55699
55784
  operation;
55700
55785
  getOperation;
55701
55786
  constructor(operation, getOperation) {
@@ -55711,7 +55796,7 @@ var DeleteDatabaseOperation = class {
55711
55796
  if (this.operation.metadata === void 0) {
55712
55797
  return Promise.resolve(void 0);
55713
55798
  }
55714
- return Promise.resolve(external_exports.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata));
55799
+ return Promise.resolve(external_exports.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata));
55715
55800
  }
55716
55801
  /**
55717
55802
  * Polls the operation until it completes.
@@ -55719,6 +55804,7 @@ var DeleteDatabaseOperation = class {
55719
55804
  * Throws if the operation failed.
55720
55805
  */
55721
55806
  async wait(options) {
55807
+ let result;
55722
55808
  const call = async (callSignal) => {
55723
55809
  const op = await this.getOperation({
55724
55810
  name: this.operation.name
@@ -55738,8 +55824,16 @@ var DeleteDatabaseOperation = class {
55738
55824
  cause: err
55739
55825
  });
55740
55826
  }
55827
+ if (op.result?.$case !== "response") {
55828
+ throw new Error("operation completed without a response");
55829
+ }
55830
+ result = external_exports.lazy(() => unmarshalRoleSchema2).parse(op.result.response);
55741
55831
  };
55742
55832
  await executeWait6(call, options);
55833
+ if (result === void 0) {
55834
+ throw new Error("operation completed without a result.");
55835
+ }
55836
+ return result;
55743
55837
  }
55744
55838
  /** Checks whether the operation has completed */
55745
55839
  async done(options) {
@@ -55748,7 +55842,7 @@ var DeleteDatabaseOperation = class {
55748
55842
  return op.done;
55749
55843
  }
55750
55844
  };
55751
- var DeleteEndpointOperation = class {
55845
+ var CreateSyncedTableOperation = class {
55752
55846
  operation;
55753
55847
  getOperation;
55754
55848
  constructor(operation, getOperation) {
@@ -55764,7 +55858,7 @@ var DeleteEndpointOperation = class {
55764
55858
  if (this.operation.metadata === void 0) {
55765
55859
  return Promise.resolve(void 0);
55766
55860
  }
55767
- return Promise.resolve(external_exports.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata));
55861
+ return Promise.resolve(external_exports.lazy(() => unmarshalSyncedTableOperationMetadataSchema).parse(this.operation.metadata));
55768
55862
  }
55769
55863
  /**
55770
55864
  * Polls the operation until it completes.
@@ -55772,6 +55866,7 @@ var DeleteEndpointOperation = class {
55772
55866
  * Throws if the operation failed.
55773
55867
  */
55774
55868
  async wait(options) {
55869
+ let result;
55775
55870
  const call = async (callSignal) => {
55776
55871
  const op = await this.getOperation({
55777
55872
  name: this.operation.name
@@ -55791,8 +55886,16 @@ var DeleteEndpointOperation = class {
55791
55886
  cause: err
55792
55887
  });
55793
55888
  }
55889
+ if (op.result?.$case !== "response") {
55890
+ throw new Error("operation completed without a response");
55891
+ }
55892
+ result = external_exports.lazy(() => unmarshalSyncedTableSchema).parse(op.result.response);
55794
55893
  };
55795
55894
  await executeWait6(call, options);
55895
+ if (result === void 0) {
55896
+ throw new Error("operation completed without a result.");
55897
+ }
55898
+ return result;
55796
55899
  }
55797
55900
  /** Checks whether the operation has completed */
55798
55901
  async done(options) {
@@ -55801,7 +55904,7 @@ var DeleteEndpointOperation = class {
55801
55904
  return op.done;
55802
55905
  }
55803
55906
  };
55804
- var DeleteProjectOperation = class {
55907
+ var DeleteBranchOperation = class {
55805
55908
  operation;
55806
55909
  getOperation;
55807
55910
  constructor(operation, getOperation) {
@@ -55817,7 +55920,7 @@ var DeleteProjectOperation = class {
55817
55920
  if (this.operation.metadata === void 0) {
55818
55921
  return Promise.resolve(void 0);
55819
55922
  }
55820
- return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
55923
+ return Promise.resolve(external_exports.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata));
55821
55924
  }
55822
55925
  /**
55823
55926
  * Polls the operation until it completes.
@@ -55854,7 +55957,7 @@ var DeleteProjectOperation = class {
55854
55957
  return op.done;
55855
55958
  }
55856
55959
  };
55857
- var DeleteRoleOperation = class {
55960
+ var DeleteCatalogOperation = class {
55858
55961
  operation;
55859
55962
  getOperation;
55860
55963
  constructor(operation, getOperation) {
@@ -55870,7 +55973,7 @@ var DeleteRoleOperation = class {
55870
55973
  if (this.operation.metadata === void 0) {
55871
55974
  return Promise.resolve(void 0);
55872
55975
  }
55873
- return Promise.resolve(external_exports.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata));
55976
+ return Promise.resolve(external_exports.lazy(() => unmarshalCatalogOperationMetadataSchema).parse(this.operation.metadata));
55874
55977
  }
55875
55978
  /**
55876
55979
  * Polls the operation until it completes.
@@ -55907,7 +56010,7 @@ var DeleteRoleOperation = class {
55907
56010
  return op.done;
55908
56011
  }
55909
56012
  };
55910
- var DeleteSyncedTableOperation = class {
56013
+ var DeleteCdfConfigOperation = class {
55911
56014
  operation;
55912
56015
  getOperation;
55913
56016
  constructor(operation, getOperation) {
@@ -55923,7 +56026,7 @@ var DeleteSyncedTableOperation = class {
55923
56026
  if (this.operation.metadata === void 0) {
55924
56027
  return Promise.resolve(void 0);
55925
56028
  }
55926
- return Promise.resolve(external_exports.lazy(() => unmarshalSyncedTableOperationMetadataSchema).parse(this.operation.metadata));
56029
+ return Promise.resolve(external_exports.lazy(() => unmarshalCdfConfigOperationMetadataSchema).parse(this.operation.metadata));
55927
56030
  }
55928
56031
  /**
55929
56032
  * Polls the operation until it completes.
@@ -55960,7 +56063,7 @@ var DeleteSyncedTableOperation = class {
55960
56063
  return op.done;
55961
56064
  }
55962
56065
  };
55963
- var UndeleteBranchOperation = class {
56066
+ var DeleteDataApiOperation = class {
55964
56067
  operation;
55965
56068
  getOperation;
55966
56069
  constructor(operation, getOperation) {
@@ -55976,7 +56079,7 @@ var UndeleteBranchOperation = class {
55976
56079
  if (this.operation.metadata === void 0) {
55977
56080
  return Promise.resolve(void 0);
55978
56081
  }
55979
- return Promise.resolve(external_exports.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata));
56082
+ return Promise.resolve(external_exports.lazy(() => unmarshalDataApiOperationMetadataSchema).parse(this.operation.metadata));
55980
56083
  }
55981
56084
  /**
55982
56085
  * Polls the operation until it completes.
@@ -56013,7 +56116,7 @@ var UndeleteBranchOperation = class {
56013
56116
  return op.done;
56014
56117
  }
56015
56118
  };
56016
- var UndeleteProjectOperation = class {
56119
+ var DeleteDatabaseOperation = class {
56017
56120
  operation;
56018
56121
  getOperation;
56019
56122
  constructor(operation, getOperation) {
@@ -56029,7 +56132,7 @@ var UndeleteProjectOperation = class {
56029
56132
  if (this.operation.metadata === void 0) {
56030
56133
  return Promise.resolve(void 0);
56031
56134
  }
56032
- return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
56135
+ return Promise.resolve(external_exports.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata));
56033
56136
  }
56034
56137
  /**
56035
56138
  * Polls the operation until it completes.
@@ -56066,7 +56169,7 @@ var UndeleteProjectOperation = class {
56066
56169
  return op.done;
56067
56170
  }
56068
56171
  };
56069
- var UpdateBranchOperation = class {
56172
+ var DeleteEndpointOperation = class {
56070
56173
  operation;
56071
56174
  getOperation;
56072
56175
  constructor(operation, getOperation) {
@@ -56082,7 +56185,7 @@ var UpdateBranchOperation = class {
56082
56185
  if (this.operation.metadata === void 0) {
56083
56186
  return Promise.resolve(void 0);
56084
56187
  }
56085
- return Promise.resolve(external_exports.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata));
56188
+ return Promise.resolve(external_exports.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata));
56086
56189
  }
56087
56190
  /**
56088
56191
  * Polls the operation until it completes.
@@ -56090,7 +56193,6 @@ var UpdateBranchOperation = class {
56090
56193
  * Throws if the operation failed.
56091
56194
  */
56092
56195
  async wait(options) {
56093
- let result;
56094
56196
  const call = async (callSignal) => {
56095
56197
  const op = await this.getOperation({
56096
56198
  name: this.operation.name
@@ -56110,16 +56212,114 @@ var UpdateBranchOperation = class {
56110
56212
  cause: err
56111
56213
  });
56112
56214
  }
56113
- if (op.result?.$case !== "response") {
56114
- throw new Error("operation completed without a response");
56215
+ };
56216
+ await executeWait6(call, options);
56217
+ }
56218
+ /** Checks whether the operation has completed */
56219
+ async done(options) {
56220
+ const op = await this.getOperation({ name: this.operation.name }, options);
56221
+ this.operation = op;
56222
+ return op.done;
56223
+ }
56224
+ };
56225
+ var DeleteProjectOperation = class {
56226
+ operation;
56227
+ getOperation;
56228
+ constructor(operation, getOperation) {
56229
+ this.operation = operation;
56230
+ this.getOperation = getOperation;
56231
+ }
56232
+ /** Returns the server-assigned name of the long-running operation. */
56233
+ name() {
56234
+ return Promise.resolve(this.operation.name);
56235
+ }
56236
+ /** Returns metadata associated with the long-running operation. */
56237
+ metadata() {
56238
+ if (this.operation.metadata === void 0) {
56239
+ return Promise.resolve(void 0);
56240
+ }
56241
+ return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
56242
+ }
56243
+ /**
56244
+ * Polls the operation until it completes.
56245
+ *
56246
+ * Throws if the operation failed.
56247
+ */
56248
+ async wait(options) {
56249
+ const call = async (callSignal) => {
56250
+ const op = await this.getOperation({
56251
+ name: this.operation.name
56252
+ }, callSignal !== void 0 ? { signal: callSignal } : void 0);
56253
+ this.operation = op;
56254
+ if (op.done === void 0) {
56255
+ throw new Error("operation is missing the done field");
56256
+ }
56257
+ if (!op.done) {
56258
+ throw new StillRunningError6();
56259
+ }
56260
+ if (op.result?.$case === "error") {
56261
+ const err = op.result.error;
56262
+ const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
56263
+ const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
56264
+ throw new Error(`operation failed: ${errorMsg}`, {
56265
+ cause: err
56266
+ });
56115
56267
  }
56116
- result = external_exports.lazy(() => unmarshalBranchSchema).parse(op.result.response);
56117
56268
  };
56118
56269
  await executeWait6(call, options);
56119
- if (result === void 0) {
56120
- throw new Error("operation completed without a result.");
56270
+ }
56271
+ /** Checks whether the operation has completed */
56272
+ async done(options) {
56273
+ const op = await this.getOperation({ name: this.operation.name }, options);
56274
+ this.operation = op;
56275
+ return op.done;
56276
+ }
56277
+ };
56278
+ var DeleteRoleOperation = class {
56279
+ operation;
56280
+ getOperation;
56281
+ constructor(operation, getOperation) {
56282
+ this.operation = operation;
56283
+ this.getOperation = getOperation;
56284
+ }
56285
+ /** Returns the server-assigned name of the long-running operation. */
56286
+ name() {
56287
+ return Promise.resolve(this.operation.name);
56288
+ }
56289
+ /** Returns metadata associated with the long-running operation. */
56290
+ metadata() {
56291
+ if (this.operation.metadata === void 0) {
56292
+ return Promise.resolve(void 0);
56121
56293
  }
56122
- return result;
56294
+ return Promise.resolve(external_exports.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata));
56295
+ }
56296
+ /**
56297
+ * Polls the operation until it completes.
56298
+ *
56299
+ * Throws if the operation failed.
56300
+ */
56301
+ async wait(options) {
56302
+ const call = async (callSignal) => {
56303
+ const op = await this.getOperation({
56304
+ name: this.operation.name
56305
+ }, callSignal !== void 0 ? { signal: callSignal } : void 0);
56306
+ this.operation = op;
56307
+ if (op.done === void 0) {
56308
+ throw new Error("operation is missing the done field");
56309
+ }
56310
+ if (!op.done) {
56311
+ throw new StillRunningError6();
56312
+ }
56313
+ if (op.result?.$case === "error") {
56314
+ const err = op.result.error;
56315
+ const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
56316
+ const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
56317
+ throw new Error(`operation failed: ${errorMsg}`, {
56318
+ cause: err
56319
+ });
56320
+ }
56321
+ };
56322
+ await executeWait6(call, options);
56123
56323
  }
56124
56324
  /** Checks whether the operation has completed */
56125
56325
  async done(options) {
@@ -56128,7 +56328,7 @@ var UpdateBranchOperation = class {
56128
56328
  return op.done;
56129
56329
  }
56130
56330
  };
56131
- var UpdateDataApiOperation = class {
56331
+ var DeleteSyncedTableOperation = class {
56132
56332
  operation;
56133
56333
  getOperation;
56134
56334
  constructor(operation, getOperation) {
@@ -56144,7 +56344,7 @@ var UpdateDataApiOperation = class {
56144
56344
  if (this.operation.metadata === void 0) {
56145
56345
  return Promise.resolve(void 0);
56146
56346
  }
56147
- return Promise.resolve(external_exports.lazy(() => unmarshalDataApiOperationMetadataSchema).parse(this.operation.metadata));
56347
+ return Promise.resolve(external_exports.lazy(() => unmarshalSyncedTableOperationMetadataSchema).parse(this.operation.metadata));
56148
56348
  }
56149
56349
  /**
56150
56350
  * Polls the operation until it completes.
@@ -56152,7 +56352,6 @@ var UpdateDataApiOperation = class {
56152
56352
  * Throws if the operation failed.
56153
56353
  */
56154
56354
  async wait(options) {
56155
- let result;
56156
56355
  const call = async (callSignal) => {
56157
56356
  const op = await this.getOperation({
56158
56357
  name: this.operation.name
@@ -56172,16 +56371,114 @@ var UpdateDataApiOperation = class {
56172
56371
  cause: err
56173
56372
  });
56174
56373
  }
56175
- if (op.result?.$case !== "response") {
56176
- throw new Error("operation completed without a response");
56374
+ };
56375
+ await executeWait6(call, options);
56376
+ }
56377
+ /** Checks whether the operation has completed */
56378
+ async done(options) {
56379
+ const op = await this.getOperation({ name: this.operation.name }, options);
56380
+ this.operation = op;
56381
+ return op.done;
56382
+ }
56383
+ };
56384
+ var UndeleteBranchOperation = class {
56385
+ operation;
56386
+ getOperation;
56387
+ constructor(operation, getOperation) {
56388
+ this.operation = operation;
56389
+ this.getOperation = getOperation;
56390
+ }
56391
+ /** Returns the server-assigned name of the long-running operation. */
56392
+ name() {
56393
+ return Promise.resolve(this.operation.name);
56394
+ }
56395
+ /** Returns metadata associated with the long-running operation. */
56396
+ metadata() {
56397
+ if (this.operation.metadata === void 0) {
56398
+ return Promise.resolve(void 0);
56399
+ }
56400
+ return Promise.resolve(external_exports.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata));
56401
+ }
56402
+ /**
56403
+ * Polls the operation until it completes.
56404
+ *
56405
+ * Throws if the operation failed.
56406
+ */
56407
+ async wait(options) {
56408
+ const call = async (callSignal) => {
56409
+ const op = await this.getOperation({
56410
+ name: this.operation.name
56411
+ }, callSignal !== void 0 ? { signal: callSignal } : void 0);
56412
+ this.operation = op;
56413
+ if (op.done === void 0) {
56414
+ throw new Error("operation is missing the done field");
56415
+ }
56416
+ if (!op.done) {
56417
+ throw new StillRunningError6();
56418
+ }
56419
+ if (op.result?.$case === "error") {
56420
+ const err = op.result.error;
56421
+ const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
56422
+ const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
56423
+ throw new Error(`operation failed: ${errorMsg}`, {
56424
+ cause: err
56425
+ });
56177
56426
  }
56178
- result = external_exports.lazy(() => unmarshalDataApiSchema).parse(op.result.response);
56179
56427
  };
56180
56428
  await executeWait6(call, options);
56181
- if (result === void 0) {
56182
- throw new Error("operation completed without a result.");
56429
+ }
56430
+ /** Checks whether the operation has completed */
56431
+ async done(options) {
56432
+ const op = await this.getOperation({ name: this.operation.name }, options);
56433
+ this.operation = op;
56434
+ return op.done;
56435
+ }
56436
+ };
56437
+ var UndeleteProjectOperation = class {
56438
+ operation;
56439
+ getOperation;
56440
+ constructor(operation, getOperation) {
56441
+ this.operation = operation;
56442
+ this.getOperation = getOperation;
56443
+ }
56444
+ /** Returns the server-assigned name of the long-running operation. */
56445
+ name() {
56446
+ return Promise.resolve(this.operation.name);
56447
+ }
56448
+ /** Returns metadata associated with the long-running operation. */
56449
+ metadata() {
56450
+ if (this.operation.metadata === void 0) {
56451
+ return Promise.resolve(void 0);
56183
56452
  }
56184
- return result;
56453
+ return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
56454
+ }
56455
+ /**
56456
+ * Polls the operation until it completes.
56457
+ *
56458
+ * Throws if the operation failed.
56459
+ */
56460
+ async wait(options) {
56461
+ const call = async (callSignal) => {
56462
+ const op = await this.getOperation({
56463
+ name: this.operation.name
56464
+ }, callSignal !== void 0 ? { signal: callSignal } : void 0);
56465
+ this.operation = op;
56466
+ if (op.done === void 0) {
56467
+ throw new Error("operation is missing the done field");
56468
+ }
56469
+ if (!op.done) {
56470
+ throw new StillRunningError6();
56471
+ }
56472
+ if (op.result?.$case === "error") {
56473
+ const err = op.result.error;
56474
+ const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
56475
+ const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
56476
+ throw new Error(`operation failed: ${errorMsg}`, {
56477
+ cause: err
56478
+ });
56479
+ }
56480
+ };
56481
+ await executeWait6(call, options);
56185
56482
  }
56186
56483
  /** Checks whether the operation has completed */
56187
56484
  async done(options) {
@@ -56190,7 +56487,7 @@ var UpdateDataApiOperation = class {
56190
56487
  return op.done;
56191
56488
  }
56192
56489
  };
56193
- var UpdateDatabaseOperation = class {
56490
+ var UpdateBranchOperation = class {
56194
56491
  operation;
56195
56492
  getOperation;
56196
56493
  constructor(operation, getOperation) {
@@ -56206,7 +56503,7 @@ var UpdateDatabaseOperation = class {
56206
56503
  if (this.operation.metadata === void 0) {
56207
56504
  return Promise.resolve(void 0);
56208
56505
  }
56209
- return Promise.resolve(external_exports.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata));
56506
+ return Promise.resolve(external_exports.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata));
56210
56507
  }
56211
56508
  /**
56212
56509
  * Polls the operation until it completes.
@@ -56237,7 +56534,7 @@ var UpdateDatabaseOperation = class {
56237
56534
  if (op.result?.$case !== "response") {
56238
56535
  throw new Error("operation completed without a response");
56239
56536
  }
56240
- result = external_exports.lazy(() => unmarshalDatabaseSchema).parse(op.result.response);
56537
+ result = external_exports.lazy(() => unmarshalBranchSchema).parse(op.result.response);
56241
56538
  };
56242
56539
  await executeWait6(call, options);
56243
56540
  if (result === void 0) {
@@ -56252,7 +56549,7 @@ var UpdateDatabaseOperation = class {
56252
56549
  return op.done;
56253
56550
  }
56254
56551
  };
56255
- var UpdateEndpointOperation = class {
56552
+ var UpdateDataApiOperation = class {
56256
56553
  operation;
56257
56554
  getOperation;
56258
56555
  constructor(operation, getOperation) {
@@ -56268,7 +56565,7 @@ var UpdateEndpointOperation = class {
56268
56565
  if (this.operation.metadata === void 0) {
56269
56566
  return Promise.resolve(void 0);
56270
56567
  }
56271
- return Promise.resolve(external_exports.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata));
56568
+ return Promise.resolve(external_exports.lazy(() => unmarshalDataApiOperationMetadataSchema).parse(this.operation.metadata));
56272
56569
  }
56273
56570
  /**
56274
56571
  * Polls the operation until it completes.
@@ -56299,7 +56596,7 @@ var UpdateEndpointOperation = class {
56299
56596
  if (op.result?.$case !== "response") {
56300
56597
  throw new Error("operation completed without a response");
56301
56598
  }
56302
- result = external_exports.lazy(() => unmarshalEndpointSchema2).parse(op.result.response);
56599
+ result = external_exports.lazy(() => unmarshalDataApiSchema).parse(op.result.response);
56303
56600
  };
56304
56601
  await executeWait6(call, options);
56305
56602
  if (result === void 0) {
@@ -56314,7 +56611,7 @@ var UpdateEndpointOperation = class {
56314
56611
  return op.done;
56315
56612
  }
56316
56613
  };
56317
- var UpdateProjectOperation = class {
56614
+ var UpdateDatabaseOperation = class {
56318
56615
  operation;
56319
56616
  getOperation;
56320
56617
  constructor(operation, getOperation) {
@@ -56330,7 +56627,7 @@ var UpdateProjectOperation = class {
56330
56627
  if (this.operation.metadata === void 0) {
56331
56628
  return Promise.resolve(void 0);
56332
56629
  }
56333
- return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
56630
+ return Promise.resolve(external_exports.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata));
56334
56631
  }
56335
56632
  /**
56336
56633
  * Polls the operation until it completes.
@@ -56361,7 +56658,7 @@ var UpdateProjectOperation = class {
56361
56658
  if (op.result?.$case !== "response") {
56362
56659
  throw new Error("operation completed without a response");
56363
56660
  }
56364
- result = external_exports.lazy(() => unmarshalProjectSchema).parse(op.result.response);
56661
+ result = external_exports.lazy(() => unmarshalDatabaseSchema).parse(op.result.response);
56365
56662
  };
56366
56663
  await executeWait6(call, options);
56367
56664
  if (result === void 0) {
@@ -56376,7 +56673,7 @@ var UpdateProjectOperation = class {
56376
56673
  return op.done;
56377
56674
  }
56378
56675
  };
56379
- var UpdateRoleOperation = class {
56676
+ var UpdateEndpointOperation = class {
56380
56677
  operation;
56381
56678
  getOperation;
56382
56679
  constructor(operation, getOperation) {
@@ -56392,7 +56689,7 @@ var UpdateRoleOperation = class {
56392
56689
  if (this.operation.metadata === void 0) {
56393
56690
  return Promise.resolve(void 0);
56394
56691
  }
56395
- return Promise.resolve(external_exports.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata));
56692
+ return Promise.resolve(external_exports.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata));
56396
56693
  }
56397
56694
  /**
56398
56695
  * Polls the operation until it completes.
@@ -56423,7 +56720,7 @@ var UpdateRoleOperation = class {
56423
56720
  if (op.result?.$case !== "response") {
56424
56721
  throw new Error("operation completed without a response");
56425
56722
  }
56426
- result = external_exports.lazy(() => unmarshalRoleSchema2).parse(op.result.response);
56723
+ result = external_exports.lazy(() => unmarshalEndpointSchema2).parse(op.result.response);
56427
56724
  };
56428
56725
  await executeWait6(call, options);
56429
56726
  if (result === void 0) {
@@ -56438,679 +56735,382 @@ var UpdateRoleOperation = class {
56438
56735
  return op.done;
56439
56736
  }
56440
56737
  };
56441
-
56442
- // src/native-sdk.ts
56443
- function stableDatabricksSdkClients(clients) {
56444
- const { rawProtocol: _rawProtocol, ...sdk } = clients;
56445
- return sdk;
56446
- }
56447
- function createDatabricksNativeClients(options) {
56448
- const clientOptions = generatedClientOptions(options);
56449
- return {
56450
- accessManagement: new AccessManagementClient(clientOptions),
56451
- jobs: new JobsClient(clientOptions),
56452
- statements: new StatementExecutionClient(clientOptions),
56453
- pipelines: new PipelinesClient(clientOptions),
56454
- vectorSearch: new VectorSearchClient(clientOptions),
56455
- modelServing: new ModelServingClient(clientOptions),
56456
- modelServingQuery: new ModelServingQueryClient(clientOptions),
56457
- files: new FilesClient(clientOptions),
56458
- secrets: new SecretsClient(clientOptions),
56459
- genie: new GenieClient(clientOptions),
56460
- catalogs: new CatalogsClient(clientOptions),
56461
- schemas: new SchemasClient(clientOptions),
56462
- volumes: new VolumesClient(clientOptions),
56463
- grants: new GrantsClient(clientOptions),
56464
- tables: new TablesClient(clientOptions),
56465
- scim: new ScimClient(clientOptions),
56466
- experiments: new ExperimentsClient(clientOptions),
56467
- postgres: new PostgresClient(clientOptions),
56468
- rawProtocol: new DatabricksRawProtocolClient({
56469
- host: options.host,
56470
- token: options.tokenProvider,
56471
- ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {},
56472
- ...options.extraHeaders ? { extraHeaders: options.extraHeaders } : {}
56473
- })
56474
- };
56475
- }
56476
- function generatedClientOptions(options) {
56477
- return {
56478
- host: options.host,
56479
- credentials: options.credentials,
56480
- httpClient: fabricHttpClient(options.fetchImpl ?? fetch, options.extraHeaders),
56481
- profileOptions: { noProfile: true, disableEnv: true },
56482
- ...options.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {}
56483
- };
56484
- }
56485
- function fabricHttpClient(fetchImpl, extraHeaders) {
56486
- return {
56487
- async send(request) {
56488
- const headers = new Headers(request.headers);
56489
- const resolved = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
56490
- for (const [key, value] of Object.entries(resolved ?? {})) headers.set(key, value);
56491
- const body = request.body instanceof Uint8Array ? request.body.buffer.slice(
56492
- request.body.byteOffset,
56493
- request.body.byteOffset + request.body.byteLength
56494
- ) : request.body;
56495
- const init = {
56496
- method: request.method,
56497
- headers,
56498
- ...body !== void 0 ? { body } : {},
56499
- ...request.signal ? { signal: request.signal } : {}
56500
- };
56501
- if (request.body instanceof ReadableStream) {
56502
- init.duplex = "half";
56503
- }
56504
- const response = await fetchImpl(request.url, init);
56505
- return {
56506
- statusCode: response.status,
56507
- headers: response.headers,
56508
- body: response.body
56509
- };
56510
- }
56511
- };
56512
- }
56513
-
56514
- // src/lakebase.ts
56515
- import { createRequire } from "module";
56516
- var require2 = createRequire(import.meta.url);
56517
- function lakebaseCredentialProvider(options) {
56518
- const now = options.now ?? Date.now;
56519
- const random = options.random ?? Math.random;
56520
- const refreshBeforeMs = options.refreshBeforeMs ?? 5 * 6e4;
56521
- const refreshJitterMs = options.refreshJitterMs ?? 3e4;
56522
- let cached4;
56523
- let refreshing;
56524
- const refresh = async () => {
56525
- const value = await options.client.generateDatabaseCredential({ endpoint: options.endpoint });
56526
- if (typeof value.token !== "string" || !value.token) {
56527
- throw new Error("Lakebase credential exchange returned no token.");
56528
- }
56529
- const expiresAt = value.expireTime?.epochMilliseconds ?? Number.NaN;
56530
- if (!Number.isFinite(expiresAt)) {
56531
- throw new Error("Lakebase credential exchange returned an invalid expire_time.");
56532
- }
56533
- const jitter4 = Math.max(0, refreshJitterMs) * random();
56534
- cached4 = {
56535
- token: value.token,
56536
- refreshAt: Math.max(now(), expiresAt - Math.max(0, refreshBeforeMs) - jitter4)
56537
- };
56538
- return value.token;
56539
- };
56540
- return async () => {
56541
- if (cached4 && now() < cached4.refreshAt) return cached4.token;
56542
- refreshing ??= refresh().finally(() => {
56543
- refreshing = void 0;
56544
- });
56545
- return refreshing;
56546
- };
56547
- }
56548
- function lakebaseClient(options) {
56549
- const factory2 = options.poolFactory ?? defaultPoolFactory();
56550
- let password = options.password;
56551
- if (password === void 0) {
56552
- if (!options.credentialClient || !options.endpoint) {
56553
- throw new Error(
56554
- "Lakebase OAuth requires credentialClient and endpoint. A workspace token cannot be used directly as the Postgres password."
56555
- );
56556
- }
56557
- password = lakebaseCredentialProvider({
56558
- client: options.credentialClient,
56559
- endpoint: options.endpoint,
56560
- ...options.refreshBeforeMs !== void 0 ? { refreshBeforeMs: options.refreshBeforeMs } : {},
56561
- ...options.refreshJitterMs !== void 0 ? { refreshJitterMs: options.refreshJitterMs } : {}
56562
- });
56563
- }
56564
- const client = factory2({
56565
- host: options.host,
56566
- port: options.port ?? 5432,
56567
- database: options.database,
56568
- user: options.user,
56569
- password,
56570
- ssl: options.ssl ?? { rejectUnauthorized: true },
56571
- ...options.max !== void 0 ? { max: options.max } : {}
56572
- });
56573
- client.on?.("error", options.onPoolError ?? (() => void 0));
56574
- return client;
56575
- }
56576
- function defaultPoolFactory() {
56577
- let PoolCtor;
56578
- try {
56579
- PoolCtor = require2("pg").Pool;
56580
- } catch (error51) {
56581
- throw new Error(
56582
- `Lakebase store requires the optional "pg" package to be installed by the application. Run: pnpm add pg. ${error51 instanceof Error ? error51.message : String(error51)}`
56583
- );
56584
- }
56585
- return (config2) => new PoolCtor(config2);
56586
- }
56587
-
56588
- // src/lakeflow-authoring.ts
56589
- var DatabricksLakeflowAuthoring = class {
56590
- constructor(client, statements) {
56591
- this.client = client;
56592
- this.statements = statements;
56593
- }
56594
- async createPipeline(spec) {
56595
- const response = await this.client.create(serialize(spec));
56596
- if (!response.pipelineId)
56597
- throw new Error("Databricks Lakeflow create response did not contain pipeline_id.");
56598
- return { pipelineId: response.pipelineId };
56599
- }
56600
- async updatePipeline(pipelineId, spec) {
56601
- await this.client.edit({ pipelineId, id: pipelineId, ...serialize(spec) });
56602
- }
56603
- async deletePipeline(pipelineId) {
56604
- await this.client.delete({ pipelineId });
56738
+ var UpdateProjectOperation = class {
56739
+ operation;
56740
+ getOperation;
56741
+ constructor(operation, getOperation) {
56742
+ this.operation = operation;
56743
+ this.getOperation = getOperation;
56605
56744
  }
56606
- async pipelineEvents(pipelineId, warehouseId, limit = 100) {
56607
- const escaped = pipelineId.replace(/'/g, "''");
56608
- if (!this.statements)
56609
- throw new Error("Databricks Lakeflow events require a Statement Execution client.");
56610
- return runStatement(
56611
- this.statements,
56612
- warehouseId,
56613
- `SELECT * FROM event_log('${escaped}') ORDER BY timestamp DESC LIMIT ${Math.max(1, Math.min(1e3, Math.floor(limit)))}`,
56614
- [],
56615
- { intervalMs: 2e3, timeoutMs: 12e4 }
56616
- );
56745
+ /** Returns the server-assigned name of the long-running operation. */
56746
+ name() {
56747
+ return Promise.resolve(this.operation.name);
56617
56748
  }
56618
- };
56619
- function databricksLakeflowAuthoringTools(client, options = {}) {
56620
- const api = new DatabricksLakeflowAuthoring(client, options.statements);
56621
- const spec = specSchema();
56622
- const specProperties2 = spec.properties;
56623
- const resources = [
56624
- { kind: "pipeline", path: "/name" },
56625
- { kind: "catalog", path: "/catalog", catalogQualified: true, optional: true },
56626
- { kind: "notebook", path: "/libraries/*/notebook/path", optional: true }
56627
- ];
56628
- const tools = [
56629
- tool2(
56630
- "databricks_create_pipeline",
56631
- "write",
56632
- spec,
56633
- resources,
56634
- (input) => api.createPipeline(input)
56635
- ),
56636
- tool2(
56637
- "databricks_update_pipeline",
56638
- "write",
56639
- {
56640
- type: "object",
56641
- additionalProperties: false,
56642
- properties: { pipelineId: { type: "string" }, ...specProperties2 },
56643
- required: ["pipelineId", "name", "libraries"]
56644
- },
56645
- [{ kind: "pipeline", path: "/pipelineId" }, ...resources.slice(1)],
56646
- (input) => api.updatePipeline(input.pipelineId, input)
56647
- ),
56648
- tool2(
56649
- "databricks_delete_pipeline",
56650
- "write",
56651
- idSchema3(),
56652
- [{ kind: "pipeline", path: "/pipelineId" }],
56653
- (input) => api.deletePipeline(input.pipelineId)
56654
- )
56655
- ];
56656
- const warehouseId = options.warehouseId;
56657
- if (warehouseId)
56658
- tools.push(
56659
- tool2(
56660
- "databricks_pipeline_events",
56661
- "read",
56662
- {
56663
- type: "object",
56664
- additionalProperties: false,
56665
- properties: { pipelineId: { type: "string" }, limit: { type: "number" } },
56666
- required: ["pipelineId"]
56667
- },
56668
- [{ kind: "pipeline", path: "/pipelineId" }],
56669
- (input) => api.pipelineEvents(
56670
- input.pipelineId,
56671
- warehouseId,
56672
- input.limit
56673
- )
56674
- )
56675
- );
56676
- return tools;
56677
- }
56678
- function tool2(name, effect, inputSchema, resources, execute2) {
56679
- return {
56680
- name,
56681
- description: name.replaceAll("_", " "),
56682
- inputSchema,
56683
- metadata: { effect, provider: "databricks", service: "lakeflow", governance: { resources } },
56684
- execute: execute2
56685
- };
56686
- }
56687
- function idSchema3() {
56688
- return {
56689
- type: "object",
56690
- additionalProperties: false,
56691
- properties: { pipelineId: { type: "string" } },
56692
- required: ["pipelineId"]
56693
- };
56694
- }
56695
- function specSchema() {
56696
- return {
56697
- type: "object",
56698
- additionalProperties: false,
56699
- properties: {
56700
- name: { type: "string" },
56701
- libraries: {
56702
- type: "array",
56703
- items: {
56704
- type: "object",
56705
- properties: {
56706
- notebook: { type: "object", properties: { path: { type: "string" } } },
56707
- file: { type: "object", properties: { path: { type: "string" } } },
56708
- jar: { type: "string" },
56709
- whl: { type: "string" }
56710
- }
56711
- }
56712
- },
56713
- catalog: { type: "string" },
56714
- target: { type: "string" },
56715
- continuous: { type: "boolean" },
56716
- serverless: { type: "boolean" },
56717
- development: { type: "boolean" },
56718
- configuration: { type: "object", additionalProperties: { type: "string" } },
56719
- clusters: { type: "array", items: { type: "object", additionalProperties: true } }
56720
- },
56721
- required: ["name", "libraries"]
56722
- };
56723
- }
56724
- function serialize(spec) {
56725
- return {
56726
- name: spec.name,
56727
- libraries: spec.libraries.map(serializeLibrary),
56728
- ...spec.catalog ? { catalog: spec.catalog } : {},
56729
- ...spec.target ? { target: spec.target } : {},
56730
- ...spec.continuous !== void 0 ? { continuous: spec.continuous } : {},
56731
- ...spec.serverless !== void 0 ? { serverless: spec.serverless } : {},
56732
- ...spec.development !== void 0 ? { development: spec.development } : {},
56733
- ...spec.configuration ? { configuration: spec.configuration } : {},
56734
- ...spec.clusters ? { clusters: spec.clusters } : {}
56735
- };
56736
- }
56737
- function serializeLibrary(library) {
56738
- if (library.notebook)
56739
- return { lib: { $case: "notebook", notebook: { path: library.notebook.path } } };
56740
- if (library.file) return { lib: { $case: "file", file: { path: library.file.path } } };
56741
- if (library.jar) return { lib: { $case: "jar", jar: library.jar } };
56742
- if (library.whl) return { lib: { $case: "whl", whl: library.whl } };
56743
- throw new Error("Databricks Lakeflow library requires notebook, file, jar, or whl.");
56744
- }
56745
-
56746
- // src/lakeflow.ts
56747
- function databricksPipelineListTool(client, options = {}) {
56748
- return {
56749
- name: options.name ?? "databricks_pipeline_list",
56750
- description: options.description ?? "List Lakeflow Declarative Pipelines (DLT) in the workspace.",
56751
- inputSchema: {
56752
- type: "object",
56753
- additionalProperties: false,
56754
- properties: { maxResults: { type: "number", minimum: 1 }, filter: { type: "string" } }
56755
- },
56756
- metadata: { effect: "read", provider: "databricks", service: "lakeflow" },
56757
- execute: (input) => client.list({
56758
- ...input.maxResults !== void 0 ? { maxResults: input.maxResults } : {},
56759
- ...input.filter ? { filter: input.filter } : {}
56760
- })
56761
- };
56762
- }
56763
- function databricksPipelineStatusTool(client, options = {}) {
56764
- return {
56765
- name: options.name ?? "databricks_pipeline_status",
56766
- description: options.description ?? "Get a Lakeflow pipeline, including its state and latest updates.",
56767
- inputSchema: {
56768
- type: "object",
56769
- additionalProperties: false,
56770
- properties: { pipelineId: { type: "string" } },
56771
- required: ["pipelineId"]
56772
- },
56773
- metadata: { effect: "read", provider: "databricks", service: "lakeflow" },
56774
- execute: (input) => client.get({ pipelineId: input.pipelineId })
56775
- };
56776
- }
56777
- function databricksPipelineStartTool(client, options = {}) {
56778
- return {
56779
- name: options.name ?? "databricks_pipeline_start",
56780
- description: options.description ?? "Trigger a Lakeflow pipeline update (run). Set fullRefresh to reprocess all data.",
56781
- inputSchema: {
56782
- type: "object",
56783
- additionalProperties: false,
56784
- properties: { pipelineId: { type: "string" }, fullRefresh: { type: "boolean" } },
56785
- required: ["pipelineId"]
56786
- },
56787
- metadata: { effect: "execute", provider: "databricks", service: "lakeflow" },
56788
- execute: (input) => client.start({
56789
- pipelineId: input.pipelineId,
56790
- ...input.fullRefresh !== void 0 ? { fullRefresh: input.fullRefresh } : {}
56791
- })
56792
- };
56793
- }
56794
- function databricksPipelineStopTool(client, options = {}) {
56795
- return {
56796
- name: options.name ?? "databricks_pipeline_stop",
56797
- description: options.description ?? "Stop the active update of a Lakeflow pipeline.",
56798
- inputSchema: {
56799
- type: "object",
56800
- additionalProperties: false,
56801
- properties: { pipelineId: { type: "string" } },
56802
- required: ["pipelineId"]
56803
- },
56804
- metadata: { effect: "execute", provider: "databricks", service: "lakeflow" },
56805
- execute: (input) => client.stop({ pipelineId: input.pipelineId })
56806
- };
56807
- }
56808
- function databricksLakeflowTools(client) {
56809
- return [
56810
- databricksPipelineListTool(client),
56811
- databricksPipelineStatusTool(client),
56812
- databricksPipelineStartTool(client),
56813
- databricksPipelineStopTool(client)
56814
- ];
56815
- }
56816
-
56817
- // src/mlflow-tracing.ts
56818
- import { createHash } from "crypto";
56819
- import { eventToTelemetrySpan } from "@fabric-harness/sdk";
56820
- function mlflowTraceExporter(options) {
56821
- const onError = options.onError ?? ((context, error51) => {
56822
- console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
56823
- });
56824
- const buffers = /* @__PURE__ */ new Map();
56825
- return {
56826
- sink: {
56827
- record(event) {
56828
- try {
56829
- const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
56830
- if (event.type === "submission_started") {
56831
- buffers.set(key, {
56832
- submissionId: event.submissionId,
56833
- agent: event.agent,
56834
- instanceId: event.instanceId,
56835
- session: event.session,
56836
- startedAtMs: event.at,
56837
- attemptCount: event.attemptCount,
56838
- ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
56839
- spans: []
56840
- });
56841
- return;
56842
- }
56843
- if (event.type !== "submission_settled") return;
56844
- const buffer = buffers.get(key);
56845
- buffers.delete(key);
56846
- const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
56847
- const attemptCount = event.attemptCount ?? buffer?.attemptCount;
56848
- const trace = buildMlflowTrace({
56849
- submissionId: event.submissionId,
56850
- agent: event.agent,
56851
- instanceId: event.instanceId,
56852
- session: event.session,
56853
- experimentId: options.experimentId,
56854
- startedAtMs,
56855
- settledAtMs: event.at,
56856
- state: event.outcome === "completed" ? "OK" : "ERROR",
56857
- spans: buffer?.spans ?? [],
56858
- ...attemptCount !== void 0 ? { attemptCount } : {},
56859
- ...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
56860
- ...event.error !== void 0 ? { error: event.error } : {}
56861
- });
56862
- void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
56863
- } catch (error51) {
56864
- onError("telemetry event handling failed", error51);
56865
- }
56866
- }
56867
- },
56868
- onEvent(event) {
56869
- try {
56870
- if (!event.sessionId) return;
56871
- const buffer = buffers.get(event.sessionId);
56872
- if (!buffer) return;
56873
- const span = eventToTelemetrySpan(event);
56874
- if (span) buffer.spans.push(span);
56875
- } catch (error51) {
56876
- onError("event buffering failed", error51);
56877
- }
56749
+ /** Returns metadata associated with the long-running operation. */
56750
+ metadata() {
56751
+ if (this.operation.metadata === void 0) {
56752
+ return Promise.resolve(void 0);
56878
56753
  }
56879
- };
56880
- }
56881
- function buildMlflowTrace(input) {
56882
- const traceBytes = sha256(input.submissionId).subarray(0, 16);
56883
- const traceIdBase64 = traceBytes.toString("base64");
56884
- const rootSpanId = spanIdFor(input.submissionId, 0);
56885
- const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
56886
- const rootSpan = {
56887
- trace_id: traceIdBase64,
56888
- span_id: rootSpanId,
56889
- name: `fabric.submission ${input.agent}`,
56890
- start_time_unix_nano: toUnixNano(input.startedAtMs),
56891
- end_time_unix_nano: toUnixNano(input.settledAtMs),
56892
- attributes: toOtlpAttributes({
56893
- "fabric.submission_id": input.submissionId,
56894
- "fabric.agent": input.agent,
56895
- "fabric.instance_id": input.instanceId,
56896
- "fabric.session": input.session,
56897
- ...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
56898
- ...input.error !== void 0 ? { "fabric.error": input.error } : {}
56899
- }),
56900
- status: {
56901
- code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
56902
- ...input.error !== void 0 ? { message: input.error } : {}
56754
+ return Promise.resolve(external_exports.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata));
56755
+ }
56756
+ /**
56757
+ * Polls the operation until it completes.
56758
+ *
56759
+ * Throws if the operation failed.
56760
+ */
56761
+ async wait(options) {
56762
+ let result;
56763
+ const call = async (callSignal) => {
56764
+ const op = await this.getOperation({
56765
+ name: this.operation.name
56766
+ }, callSignal !== void 0 ? { signal: callSignal } : void 0);
56767
+ this.operation = op;
56768
+ if (op.done === void 0) {
56769
+ throw new Error("operation is missing the done field");
56770
+ }
56771
+ if (!op.done) {
56772
+ throw new StillRunningError6();
56773
+ }
56774
+ if (op.result?.$case === "error") {
56775
+ const err = op.result.error;
56776
+ const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
56777
+ const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
56778
+ throw new Error(`operation failed: ${errorMsg}`, {
56779
+ cause: err
56780
+ });
56781
+ }
56782
+ if (op.result?.$case !== "response") {
56783
+ throw new Error("operation completed without a response");
56784
+ }
56785
+ result = external_exports.lazy(() => unmarshalProjectSchema).parse(op.result.response);
56786
+ };
56787
+ await executeWait6(call, options);
56788
+ if (result === void 0) {
56789
+ throw new Error("operation completed without a result.");
56903
56790
  }
56904
- };
56905
- const childSpans = input.spans.map(
56906
- (span, index) => ({
56907
- trace_id: traceIdBase64,
56908
- span_id: spanIdFor(input.submissionId, index + 1),
56909
- parent_span_id: rootSpanId,
56910
- name: span.name,
56911
- start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
56912
- end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
56913
- attributes: toOtlpAttributes(span.attributes),
56914
- status: { code: "STATUS_CODE_OK" }
56915
- })
56916
- );
56917
- return {
56918
- trace: {
56919
- trace_info: {
56920
- trace_id: `tr-${traceBytes.toString("hex")}`,
56921
- trace_location: {
56922
- type: "MLFLOW_EXPERIMENT",
56923
- mlflow_experiment: { experiment_id: input.experimentId }
56924
- },
56925
- request_time: new Date(input.startedAtMs).toISOString(),
56926
- execution_duration: `${durationSeconds.toFixed(3)}s`,
56927
- state: input.state,
56928
- trace_metadata: {
56929
- "fabric.submission_id": input.submissionId,
56930
- "fabric.agent": input.agent,
56931
- "fabric.instance_id": input.instanceId,
56932
- "fabric.session": input.session,
56933
- ...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
56934
- },
56935
- tags: {
56936
- "fabric.agent": input.agent,
56937
- ...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
56938
- }
56939
- },
56940
- trace_data: { spans: [rootSpan, ...childSpans] }
56791
+ return result;
56792
+ }
56793
+ /** Checks whether the operation has completed */
56794
+ async done(options) {
56795
+ const op = await this.getOperation({ name: this.operation.name }, options);
56796
+ this.operation = op;
56797
+ return op.done;
56798
+ }
56799
+ };
56800
+ var UpdateRoleOperation = class {
56801
+ operation;
56802
+ getOperation;
56803
+ constructor(operation, getOperation) {
56804
+ this.operation = operation;
56805
+ this.getOperation = getOperation;
56806
+ }
56807
+ /** Returns the server-assigned name of the long-running operation. */
56808
+ name() {
56809
+ return Promise.resolve(this.operation.name);
56810
+ }
56811
+ /** Returns metadata associated with the long-running operation. */
56812
+ metadata() {
56813
+ if (this.operation.metadata === void 0) {
56814
+ return Promise.resolve(void 0);
56941
56815
  }
56942
- };
56943
- }
56944
- function sha256(seed) {
56945
- return createHash("sha256").update(seed).digest();
56946
- }
56947
- function spanIdFor(submissionId, index) {
56948
- return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
56949
- }
56950
- function toUnixNano(epochMs) {
56951
- return `${Math.round(epochMs)}000000`;
56952
- }
56953
- function toOtlpAttributes(attributes) {
56954
- return Object.entries(attributes).map(([key, value]) => {
56955
- if (typeof value === "number") {
56956
- return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
56816
+ return Promise.resolve(external_exports.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata));
56817
+ }
56818
+ /**
56819
+ * Polls the operation until it completes.
56820
+ *
56821
+ * Throws if the operation failed.
56822
+ */
56823
+ async wait(options) {
56824
+ let result;
56825
+ const call = async (callSignal) => {
56826
+ const op = await this.getOperation({
56827
+ name: this.operation.name
56828
+ }, callSignal !== void 0 ? { signal: callSignal } : void 0);
56829
+ this.operation = op;
56830
+ if (op.done === void 0) {
56831
+ throw new Error("operation is missing the done field");
56832
+ }
56833
+ if (!op.done) {
56834
+ throw new StillRunningError6();
56835
+ }
56836
+ if (op.result?.$case === "error") {
56837
+ const err = op.result.error;
56838
+ const msg = err.message !== void 0 && err.message !== "" ? err.message : "unknown error";
56839
+ const errorMsg = err.errorCode !== void 0 ? `[${err.errorCode}] ${msg}` : msg;
56840
+ throw new Error(`operation failed: ${errorMsg}`, {
56841
+ cause: err
56842
+ });
56843
+ }
56844
+ if (op.result?.$case !== "response") {
56845
+ throw new Error("operation completed without a response");
56846
+ }
56847
+ result = external_exports.lazy(() => unmarshalRoleSchema2).parse(op.result.response);
56848
+ };
56849
+ await executeWait6(call, options);
56850
+ if (result === void 0) {
56851
+ throw new Error("operation completed without a result.");
56957
56852
  }
56958
- return { key, value: { string_value: String(value) } };
56959
- });
56960
- }
56853
+ return result;
56854
+ }
56855
+ /** Checks whether the operation has completed */
56856
+ async done(options) {
56857
+ const op = await this.getOperation({ name: this.operation.name }, options);
56858
+ this.operation = op;
56859
+ return op.done;
56860
+ }
56861
+ };
56961
56862
 
56962
- // src/model.ts
56963
- import {
56964
- OpenAICompatibleModelProvider,
56965
- currentSubmissionContext as currentSubmissionContext2,
56966
- registerModelProvider
56967
- } from "@fabric-harness/sdk";
56968
- function databricksModelBaseUrl(host, mode) {
56969
- const normalized = databricksWorkspaceOrigin(host);
56970
- return mode === "ai-gateway" ? `${normalized}/ai-gateway/mlflow/v1` : `${normalized}/serving-endpoints`;
56863
+ // src/raw-protocol-client.ts
56864
+ import { redactText } from "@fabric-harness/sdk";
56865
+ function isRetryableStatus(status) {
56866
+ return status === 429 || status === 499 || status >= 500 && status <= 599;
56971
56867
  }
56972
- function isDatabricksModelService(model) {
56973
- return model?.startsWith("system.ai.") ?? false;
56868
+ function retryDelayMs(response, attempt, base2) {
56869
+ const retryAfter = response.headers.get("retry-after");
56870
+ if (retryAfter) {
56871
+ const seconds = Number(retryAfter);
56872
+ if (Number.isFinite(seconds)) return seconds * 1e3;
56873
+ }
56874
+ return base2 * 2 ** attempt;
56974
56875
  }
56975
- var DatabricksModelProvider = class {
56976
- name = "databricks";
56977
- options;
56978
- gateway;
56979
- serving;
56980
- explicit;
56876
+ var DATABRICKS_RAW_PROTOCOL_RULES = [
56877
+ {
56878
+ id: "workspace-objects",
56879
+ methods: ["GET", "POST"],
56880
+ path: /^\/api\/2\.0\/workspace\/(?:delete|export|get-status|import|list|mkdirs)$/u
56881
+ },
56882
+ {
56883
+ id: "mlflow-traces-v3",
56884
+ methods: ["POST"],
56885
+ path: /^\/api\/3\.0\/mlflow\/traces$/u
56886
+ },
56887
+ {
56888
+ id: "ai-gateway-discovery",
56889
+ methods: ["GET"],
56890
+ path: /^\/api\/(?:ai-gateway\/v2\/endpoints|2\.1\/unity-catalog\/model-services)$/u
56891
+ },
56892
+ {
56893
+ id: "agent-services-beta",
56894
+ methods: ["GET", "POST", "PATCH", "DELETE"],
56895
+ path: /^\/api\/2\.1\/unity-catalog\/(?:agent-services(?:\/[^/?#]+)?|permissions\/AGENT_SERVICE\/[^/?#]+)$/u
56896
+ },
56897
+ {
56898
+ id: "genie-agent-mode-beta",
56899
+ methods: ["GET", "POST"],
56900
+ path: /^\/api\/2\.0\/genie\/agents\/[^/?#]+\/(?:responses|conversations\/[^/?#]+\/items)$/u
56901
+ },
56902
+ {
56903
+ id: "genie-query-result-sdk-compatibility",
56904
+ methods: ["GET"],
56905
+ path: /^\/api\/2\.0\/genie\/spaces\/[^/?#]+\/conversations\/[^/?#]+\/messages\/[^/?#]+\/attachments\/[^/?#]+\/query-result$/u
56906
+ },
56907
+ {
56908
+ id: "vector-search-query-sdk-compatibility",
56909
+ methods: ["POST"],
56910
+ path: /^\/api\/2\.0\/vector-search\/indexes\/[^/?#]+\/query$/u
56911
+ },
56912
+ {
56913
+ id: "responses-agent-custom-schema",
56914
+ methods: ["POST"],
56915
+ path: /^\/serving-endpoints\/[^/?#]+\/invocations$/u
56916
+ }
56917
+ ];
56918
+ function assertRawProtocolAllowed(method, path) {
56919
+ const normalizedMethod = method.toUpperCase();
56920
+ if (!path.startsWith("/") || path.includes("?") || path.includes("#")) {
56921
+ throw new Error(
56922
+ `databricks raw protocol denied: ${normalizedMethod} ${path}; pass a relative path and structured query parameters.`
56923
+ );
56924
+ }
56925
+ const rule = DATABRICKS_RAW_PROTOCOL_RULES.find(
56926
+ (candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(path)
56927
+ );
56928
+ if (!rule) {
56929
+ throw new Error(
56930
+ `databricks raw protocol denied: ${normalizedMethod} ${path}; use an official @databricks/sdk-* service client.`
56931
+ );
56932
+ }
56933
+ }
56934
+ var DatabricksRawProtocolClient = class {
56935
+ host;
56936
+ token;
56937
+ fetchImpl;
56938
+ maxRetries;
56939
+ retryBaseDelayMs;
56940
+ signal;
56941
+ extraHeaders;
56981
56942
  constructor(options) {
56982
- this.options = options;
56983
- const common = {
56984
- name: this.name,
56985
- apiKey: typeof options.token === "string" ? options.token : "",
56986
- ...typeof options.token === "function" ? { tokenProvider: options.token } : {},
56987
- ...options.defaultModel !== void 0 ? { defaultModel: options.defaultModel } : {},
56988
- ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {}
56989
- };
56990
- this.gateway = new OpenAICompatibleModelProvider({
56991
- ...common,
56992
- baseUrl: databricksModelBaseUrl(options.host, "ai-gateway"),
56993
- headers: () => this.resolveHeaders(true)
56994
- });
56995
- this.serving = new OpenAICompatibleModelProvider({
56996
- ...common,
56997
- baseUrl: databricksModelBaseUrl(options.host, "serving-endpoints"),
56998
- headers: () => this.resolveHeaders(false)
56999
- });
57000
- this.explicit = options.baseUrl ? new OpenAICompatibleModelProvider({
57001
- ...common,
57002
- baseUrl: options.baseUrl,
57003
- headers: () => this.resolveHeaders(options.baseUrl?.includes("/ai-gateway/") ?? false)
57004
- }) : void 0;
56943
+ this.host = databricksWorkspaceOrigin(options.host);
56944
+ this.token = options.token;
56945
+ this.fetchImpl = options.fetchImpl ?? fetch;
56946
+ this.maxRetries = options.maxRetries ?? 3;
56947
+ this.retryBaseDelayMs = options.retryBaseDelayMs ?? 500;
56948
+ this.signal = options.signal;
56949
+ this.extraHeaders = options.extraHeaders;
57005
56950
  }
57006
- generate(request) {
57007
- return this.providerFor(request.model).generate(request);
56951
+ get(path, query, options) {
56952
+ return this.requestJson("GET", path, void 0, query, options);
57008
56953
  }
57009
- stream(request) {
57010
- const provider = this.providerFor(request.model);
57011
- if (!provider.stream)
57012
- throw new Error("databricks: selected provider does not support streaming.");
57013
- return provider.stream(request);
56954
+ post(path, body, query, options) {
56955
+ return this.requestJson("POST", path, body, query, options);
57014
56956
  }
57015
- getModelMetadata(model = this.options.defaultModel) {
57016
- const mode = this.modeFor(model);
57017
- return {
57018
- provider: this.name,
57019
- ...model ? { model } : {},
57020
- gateway: this.options.baseUrl ?? databricksModelBaseUrl(this.options.host, mode),
57021
- ...model && this.options.modelMetadata?.[model] ? this.options.modelMetadata[model] : {}
57022
- };
56957
+ patch(path, body, query, options) {
56958
+ return this.requestJson("PATCH", path, body, query, options);
57023
56959
  }
57024
- providerFor(model = this.options.defaultModel) {
57025
- if (this.explicit) return this.explicit;
57026
- return this.modeFor(model) === "ai-gateway" ? this.gateway : this.serving;
56960
+ delete(path, body, query, options) {
56961
+ return this.requestJson("DELETE", path, body, query, options);
57027
56962
  }
57028
- modeFor(model) {
57029
- const configured = this.options.mode ?? "auto";
57030
- if (configured !== "auto") return configured;
57031
- return isDatabricksModelService(model) ? "ai-gateway" : "serving-endpoints";
56963
+ async requestJson(method, path, body, query = {}, options = {}) {
56964
+ const response = await this.send(method, path, body, query, options);
56965
+ if (response.status === 204) return void 0;
56966
+ return await response.json();
57032
56967
  }
57033
- async resolveHeaders(gateway) {
57034
- const configured = typeof this.options.headers === "function" ? await this.options.headers() : this.options.headers ?? {};
57035
- if (!gateway) return configured;
57036
- const supplied = typeof this.options.requestTags === "function" ? await this.options.requestTags() : this.options.requestTags ?? {};
57037
- const context = currentSubmissionContext2();
57038
- const tags = compactTags({
57039
- ...context?.submissionId ? { submission_id: context.submissionId } : {},
57040
- ...context?.attemptId ? { attempt_id: context.attemptId } : {},
57041
- ...context?.tenantId ? { tenant_id: context.tenantId } : {},
57042
- ...context?.agent ? { agent: context.agent } : {},
57043
- ...supplied
57044
- });
57045
- return Object.keys(tags).length > 0 ? { ...configured, "Databricks-Ai-Gateway-Request-Tags": JSON.stringify(tags) } : configured;
56968
+ /**
56969
+ * Perform an authenticated request while leaving a successful response body unread. This is
56970
+ * intended for bounded binary downloads and streaming APIs such as Genie Agent Mode.
56971
+ */
56972
+ postRaw(path, body, query = {}, options = {}) {
56973
+ return this.send("POST", path, body, query, options);
56974
+ }
56975
+ async send(method, path, body, query, options) {
56976
+ assertRawProtocolAllowed(method, path);
56977
+ const url2 = new URL(`${this.host}${path.startsWith("/") ? path : `/${path}`}`);
56978
+ for (const [key, value] of Object.entries(query))
56979
+ if (value !== void 0) url2.searchParams.set(key, String(value));
56980
+ const canRetry = options.retry === "always" || options.retry !== "never" && (options.retry === "safe" || method === "GET" || method === "HEAD");
56981
+ const maxRetries = canRetry ? options.maxRetries ?? this.maxRetries : 0;
56982
+ const signal = combineAbortSignals(this.signal, options.signal);
56983
+ for (let attempt = 0; ; attempt += 1) {
56984
+ const token = typeof this.token === "function" ? await this.token() : this.token;
56985
+ const extra = typeof this.extraHeaders === "function" ? await this.extraHeaders() : this.extraHeaders;
56986
+ const init = {
56987
+ method,
56988
+ headers: {
56989
+ authorization: `Bearer ${token}`,
56990
+ ...options.accept ? { accept: options.accept } : {},
56991
+ ...body !== void 0 ? { "content-type": "application/json" } : {},
56992
+ ...extra
56993
+ },
56994
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {},
56995
+ ...signal ? { signal } : {}
56996
+ };
56997
+ let response;
56998
+ try {
56999
+ response = await this.fetchImpl(url2, init);
57000
+ } catch (error51) {
57001
+ if (signal?.aborted || attempt >= maxRetries) throw error51;
57002
+ await abortableSleep2(this.retryBaseDelayMs * 2 ** attempt, signal);
57003
+ continue;
57004
+ }
57005
+ if (response.ok) {
57006
+ return response;
57007
+ }
57008
+ if (isRetryableStatus(response.status) && attempt < maxRetries) {
57009
+ await response.body?.cancel();
57010
+ await abortableSleep2(retryDelayMs(response, attempt, this.retryBaseDelayMs), signal);
57011
+ continue;
57012
+ }
57013
+ const text = redactText(await response.text(), { additionalSecrets: [token] });
57014
+ throw new Error(
57015
+ `databricks: ${response.status} ${response.statusText}: ${text.slice(0, 2e3)}`
57016
+ );
57017
+ }
57046
57018
  }
57047
57019
  };
57048
- function compactTags(tags) {
57049
- return Object.fromEntries(
57050
- Object.entries(tags).filter(([key, value]) => key.length > 0 && value.length > 0).map(([key, value]) => [key.slice(0, 128), value.slice(0, 512)])
57051
- );
57020
+ function combineAbortSignals(clientSignal, requestSignal) {
57021
+ if (!clientSignal) return requestSignal;
57022
+ if (!requestSignal || requestSignal === clientSignal) return clientSignal;
57023
+ return AbortSignal.any([clientSignal, requestSignal]);
57052
57024
  }
57053
- function databricksFoundationModelProvider(options) {
57054
- return new DatabricksModelProvider(options);
57025
+ function abortableSleep2(ms, signal) {
57026
+ if (signal?.aborted)
57027
+ return Promise.reject(
57028
+ signal.reason ?? new DOMException("The operation was aborted.", "AbortError")
57029
+ );
57030
+ if (!signal) return new Promise((resolve2) => setTimeout(resolve2, ms));
57031
+ return new Promise((resolve2, reject) => {
57032
+ const timer = setTimeout(() => {
57033
+ signal.removeEventListener("abort", abort);
57034
+ resolve2();
57035
+ }, ms);
57036
+ const abort = () => {
57037
+ clearTimeout(timer);
57038
+ reject(signal.reason ?? new DOMException("The operation was aborted.", "AbortError"));
57039
+ };
57040
+ signal.addEventListener("abort", abort, { once: true });
57041
+ });
57055
57042
  }
57056
- function inferenceMode(value) {
57057
- if (!value) return void 0;
57058
- if (value === "auto" || value === "ai-gateway" || value === "serving-endpoints") return value;
57059
- throw new Error(
57060
- `Invalid DATABRICKS_INFERENCE_MODE "${value}". Use auto, ai-gateway, or serving-endpoints.`
57061
- );
57043
+
57044
+ // src/native-sdk.ts
57045
+ function stableDatabricksSdkClients(clients) {
57046
+ const { rawProtocol: _rawProtocol, ...sdk } = clients;
57047
+ return sdk;
57062
57048
  }
57063
- function origin(value) {
57064
- try {
57065
- return new URL(value).origin;
57066
- } catch {
57067
- return value;
57068
- }
57049
+ function createDatabricksNativeClients(options) {
57050
+ const clientOptions = generatedClientOptions(options);
57051
+ return {
57052
+ accessManagement: new AccessManagementClient(clientOptions),
57053
+ jobs: new JobsClient(clientOptions),
57054
+ statements: new StatementExecutionClient(clientOptions),
57055
+ pipelines: new PipelinesClient(clientOptions),
57056
+ vectorSearch: new VectorSearchClient(clientOptions),
57057
+ modelServing: new ModelServingClient(clientOptions),
57058
+ modelServingQuery: new ModelServingQueryClient(clientOptions),
57059
+ files: new FilesClient(clientOptions),
57060
+ secrets: new SecretsClient(clientOptions),
57061
+ genie: new GenieClient(clientOptions),
57062
+ catalogs: new CatalogsClient(clientOptions),
57063
+ schemas: new SchemasClient(clientOptions),
57064
+ volumes: new VolumesClient(clientOptions),
57065
+ grants: new GrantsClient(clientOptions),
57066
+ tables: new TablesClient(clientOptions),
57067
+ scim: new ScimClient(clientOptions),
57068
+ experiments: new ExperimentsClient(clientOptions),
57069
+ postgres: new PostgresClient(clientOptions),
57070
+ rawProtocol: new DatabricksRawProtocolClient({
57071
+ host: options.host,
57072
+ token: options.tokenProvider,
57073
+ ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {},
57074
+ ...options.extraHeaders ? { extraHeaders: options.extraHeaders } : {}
57075
+ })
57076
+ };
57069
57077
  }
57070
- var factory = (parsed, providers, env2, warnings) => {
57071
- const settings = providers?.databricks;
57072
- const configuredUrl = settings?.baseUrl;
57073
- const rawHost = env2.DATABRICKS_HOST ?? (configuredUrl ? origin(configuredUrl) : void 0);
57074
- if (!rawHost)
57075
- throw new Error(
57076
- "Missing Databricks host. Set DATABRICKS_HOST or providers.databricks.baseUrl."
57077
- );
57078
- const host = rawHost.includes("://") ? rawHost : `https://${rawHost}`;
57079
- const staticToken = settings?.apiKey?.trim() || env2[settings?.apiKeyEnv ?? "DATABRICKS_TOKEN"]?.trim() || env2.DATABRICKS_API_KEY?.trim();
57080
- let principal;
57081
- if (!staticToken) {
57082
- try {
57083
- principal = databricksPrincipalFromEnv(env2);
57084
- } catch {
57085
- }
57086
- }
57087
- if (!staticToken && !principal)
57088
- throw new Error(
57089
- "Missing Databricks credentials. Set DATABRICKS_TOKEN, DATABRICKS_CLIENT_ID + DATABRICKS_CLIENT_SECRET, or providers.databricks.apiKey/apiKeyEnv."
57090
- );
57091
- const token = staticToken ?? databricksIdentity(principal);
57092
- const explicitBaseUrl = env2.DATABRICKS_AI_GATEWAY_BASE_URL ?? (configuredUrl && new URL(configuredUrl).pathname !== "/" ? configuredUrl : void 0);
57093
- const mode = inferenceMode(env2.DATABRICKS_INFERENCE_MODE);
57078
+ function generatedClientOptions(options) {
57094
57079
  return {
57095
- model: parsed.modelId,
57096
- provider: databricksFoundationModelProvider({
57097
- host,
57098
- token,
57099
- defaultModel: parsed.modelId,
57100
- ...explicitBaseUrl ? { baseUrl: explicitBaseUrl } : {},
57101
- ...mode ? { mode } : {},
57102
- ...settings?.headers ? { headers: settings.headers } : {}
57103
- }),
57104
- providerName: "databricks",
57105
- modelId: parsed.modelId,
57106
- warnings
57080
+ host: options.host,
57081
+ credentials: options.credentials,
57082
+ httpClient: fabricHttpClient(options.fetchImpl ?? fetch, options.extraHeaders),
57083
+ profileOptions: { noProfile: true, disableEnv: true },
57084
+ ...options.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {}
57085
+ };
57086
+ }
57087
+ function fabricHttpClient(fetchImpl, extraHeaders) {
57088
+ return {
57089
+ async send(request) {
57090
+ const headers = new Headers(request.headers);
57091
+ const resolved = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
57092
+ for (const [key, value] of Object.entries(resolved ?? {})) headers.set(key, value);
57093
+ const body = request.body instanceof Uint8Array ? request.body.buffer.slice(
57094
+ request.body.byteOffset,
57095
+ request.body.byteOffset + request.body.byteLength
57096
+ ) : request.body;
57097
+ const init = {
57098
+ method: request.method,
57099
+ headers,
57100
+ ...body !== void 0 ? { body } : {},
57101
+ ...request.signal ? { signal: request.signal } : {}
57102
+ };
57103
+ if (request.body instanceof ReadableStream) {
57104
+ init.duplex = "half";
57105
+ }
57106
+ const response = await fetchImpl(request.url, init);
57107
+ return {
57108
+ statusCode: response.status,
57109
+ headers: response.headers,
57110
+ body: response.body
57111
+ };
57112
+ }
57107
57113
  };
57108
- };
57109
- var registered = false;
57110
- function registerDatabricksModelProvider() {
57111
- if (registered) return;
57112
- registered = true;
57113
- registerModelProvider("databricks", factory);
57114
57114
  }
57115
57115
 
57116
57116
  // src/secrets-authoring.ts