@fabric-harness/databricks 3.0.3 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -12
- package/dist/agent.js +495 -29
- package/dist/agent.js.map +1 -1
- package/dist/app-user-authorization.d.ts.map +1 -1
- package/dist/app.d.ts +6 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/authoring-certification.d.ts +18 -2
- package/dist/authoring-certification.d.ts.map +1 -1
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/certification-sweeper.d.ts +11 -0
- package/dist/certification-sweeper.d.ts.map +1 -1
- package/dist/certify.js +2141 -1993
- package/dist/certify.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/compatibility.d.ts +4 -2
- package/dist/compatibility.d.ts.map +1 -1
- package/dist/genie-authoring.d.ts.map +1 -1
- package/dist/index.d.ts +30 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +581 -464
- package/dist/index.js.map +1 -1
- package/dist/native-sdk.d.ts +4 -0
- package/dist/native-sdk.d.ts.map +1 -1
- package/dist/serving-admin.d.ts +29 -4
- package/dist/serving-admin.d.ts.map +1 -1
- package/dist/sql-sandbox.js +69 -7
- package/dist/sql-sandbox.js.map +1 -1
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -17142,6 +17142,64 @@ function retryDelayMs(response, attempt, base2) {
|
|
|
17142
17142
|
}
|
|
17143
17143
|
return base2 * 2 ** attempt;
|
|
17144
17144
|
}
|
|
17145
|
+
var DATABRICKS_RAW_PROTOCOL_RULES = [
|
|
17146
|
+
{
|
|
17147
|
+
id: "workspace-objects",
|
|
17148
|
+
methods: ["GET", "POST"],
|
|
17149
|
+
path: /^\/api\/2\.0\/workspace\/(?:delete|export|get-status|import|list|mkdirs)$/u
|
|
17150
|
+
},
|
|
17151
|
+
{
|
|
17152
|
+
id: "mlflow-traces-v3",
|
|
17153
|
+
methods: ["POST"],
|
|
17154
|
+
path: /^\/api\/3\.0\/mlflow\/traces$/u
|
|
17155
|
+
},
|
|
17156
|
+
{
|
|
17157
|
+
id: "ai-gateway-discovery",
|
|
17158
|
+
methods: ["GET"],
|
|
17159
|
+
path: /^\/api\/(?:ai-gateway\/v2\/endpoints|2\.1\/unity-catalog\/model-services)$/u
|
|
17160
|
+
},
|
|
17161
|
+
{
|
|
17162
|
+
id: "agent-services-beta",
|
|
17163
|
+
methods: ["GET", "POST", "PATCH", "DELETE"],
|
|
17164
|
+
path: /^\/api\/2\.1\/unity-catalog\/(?:agent-services(?:\/[^/?#]+)?|permissions\/agent-service\/[^/?#]+)$/u
|
|
17165
|
+
},
|
|
17166
|
+
{
|
|
17167
|
+
id: "genie-permissions",
|
|
17168
|
+
methods: ["GET", "PATCH"],
|
|
17169
|
+
path: /^\/api\/2\.0\/permissions\/genie\/[^/?#]+$/u
|
|
17170
|
+
},
|
|
17171
|
+
{
|
|
17172
|
+
id: "genie-agent-mode-beta",
|
|
17173
|
+
methods: ["GET", "POST"],
|
|
17174
|
+
path: /^\/api\/2\.0\/genie\/agents\/[^/?#]+\/(?:responses|conversations\/[^/?#]+\/items)$/u
|
|
17175
|
+
},
|
|
17176
|
+
{
|
|
17177
|
+
id: "genie-query-result-sdk-compatibility",
|
|
17178
|
+
methods: ["GET"],
|
|
17179
|
+
path: /^\/api\/2\.0\/genie\/spaces\/[^/?#]+\/conversations\/[^/?#]+\/messages\/[^/?#]+\/attachments\/[^/?#]+\/query-result$/u
|
|
17180
|
+
},
|
|
17181
|
+
{
|
|
17182
|
+
id: "responses-agent-custom-schema",
|
|
17183
|
+
methods: ["POST"],
|
|
17184
|
+
path: /^\/serving-endpoints\/[^/?#]+\/invocations$/u
|
|
17185
|
+
}
|
|
17186
|
+
];
|
|
17187
|
+
function assertRawProtocolAllowed(method, path) {
|
|
17188
|
+
const normalizedMethod = method.toUpperCase();
|
|
17189
|
+
if (!path.startsWith("/") || path.includes("?") || path.includes("#")) {
|
|
17190
|
+
throw new Error(
|
|
17191
|
+
`databricks raw protocol denied: ${normalizedMethod} ${path}; pass a relative path and structured query parameters.`
|
|
17192
|
+
);
|
|
17193
|
+
}
|
|
17194
|
+
const rule = DATABRICKS_RAW_PROTOCOL_RULES.find(
|
|
17195
|
+
(candidate) => candidate.methods.includes(normalizedMethod) && candidate.path.test(path)
|
|
17196
|
+
);
|
|
17197
|
+
if (!rule) {
|
|
17198
|
+
throw new Error(
|
|
17199
|
+
`databricks raw protocol denied: ${normalizedMethod} ${path}; use an official @databricks/sdk-* service client.`
|
|
17200
|
+
);
|
|
17201
|
+
}
|
|
17202
|
+
}
|
|
17145
17203
|
var DatabricksPreviewClient = class {
|
|
17146
17204
|
host;
|
|
17147
17205
|
token;
|
|
@@ -17184,6 +17242,7 @@ var DatabricksPreviewClient = class {
|
|
|
17184
17242
|
* intended for bounded binary downloads and streaming APIs such as Genie Agent Mode.
|
|
17185
17243
|
*/
|
|
17186
17244
|
async requestRaw(method, path, body, query = {}, options = {}) {
|
|
17245
|
+
assertRawProtocolAllowed(method, path);
|
|
17187
17246
|
const url2 = new URL(`${this.host}${path.startsWith("/") ? path : `/${path}`}`);
|
|
17188
17247
|
for (const [key, value] of Object.entries(query))
|
|
17189
17248
|
if (value !== void 0) url2.searchParams.set(key, String(value));
|
|
@@ -17385,6 +17444,172 @@ function fabricPrincipalFor(principal, overrides = {}) {
|
|
|
17385
17444
|
// src/index.ts
|
|
17386
17445
|
import { createSearchTool } from "@fabric-harness/sdk";
|
|
17387
17446
|
|
|
17447
|
+
// src/agent-services.ts
|
|
17448
|
+
var DATABRICKS_AGENT_SERVICES_API = "/api/2.1/unity-catalog/agent-services";
|
|
17449
|
+
var DATABRICKS_AGENT_SERVICE_SECURABLE = "AGENT_SERVICE";
|
|
17450
|
+
var DatabricksAgentServices = class {
|
|
17451
|
+
constructor(client, options) {
|
|
17452
|
+
this.client = client;
|
|
17453
|
+
if (options.acknowledgeBeta !== true) {
|
|
17454
|
+
throw new Error("databricks agent services: acknowledgeBeta must be true.");
|
|
17455
|
+
}
|
|
17456
|
+
}
|
|
17457
|
+
create(options) {
|
|
17458
|
+
const catalog = ucIdentifier(options.catalog, "catalog");
|
|
17459
|
+
const schema = ucIdentifier(options.schema, "schema");
|
|
17460
|
+
const id = ucIdentifier(options.id, "agent service id");
|
|
17461
|
+
const basePath = externalBasePath(options.basePath ?? "/responses");
|
|
17462
|
+
return this.client.post(
|
|
17463
|
+
DATABRICKS_AGENT_SERVICES_API,
|
|
17464
|
+
{
|
|
17465
|
+
agent_service_type: "AGENT_SERVICE_TYPE_EXTERNAL",
|
|
17466
|
+
...options.comment !== void 0 ? { comment: options.comment } : {},
|
|
17467
|
+
config: {
|
|
17468
|
+
connection: { name: connectionResourceName(options.connection) },
|
|
17469
|
+
base_path: basePath,
|
|
17470
|
+
...options.systemPrompt !== void 0 ? { system_prompt: options.systemPrompt } : {}
|
|
17471
|
+
}
|
|
17472
|
+
},
|
|
17473
|
+
{ parent: `schemas/${catalog}.${schema}`, agent_service_id: id },
|
|
17474
|
+
{ retry: "never" }
|
|
17475
|
+
);
|
|
17476
|
+
}
|
|
17477
|
+
get(fullName) {
|
|
17478
|
+
return this.client.get(agentServicePath(fullName));
|
|
17479
|
+
}
|
|
17480
|
+
list(options = {}) {
|
|
17481
|
+
if (options.catalog === void 0 !== (options.schema === void 0)) {
|
|
17482
|
+
throw new Error("databricks agent services: catalog and schema must be provided together.");
|
|
17483
|
+
}
|
|
17484
|
+
const parent = options.catalog && options.schema ? `schemas/${ucIdentifier(options.catalog, "catalog")}.${ucIdentifier(options.schema, "schema")}` : void 0;
|
|
17485
|
+
return this.client.get(DATABRICKS_AGENT_SERVICES_API, {
|
|
17486
|
+
parent,
|
|
17487
|
+
page_token: options.pageToken
|
|
17488
|
+
});
|
|
17489
|
+
}
|
|
17490
|
+
update(fullName, options) {
|
|
17491
|
+
const mask = [];
|
|
17492
|
+
const config2 = {};
|
|
17493
|
+
const body = {};
|
|
17494
|
+
if (options.comment !== void 0) {
|
|
17495
|
+
mask.push("comment");
|
|
17496
|
+
body.comment = options.comment;
|
|
17497
|
+
}
|
|
17498
|
+
if (options.basePath !== void 0) {
|
|
17499
|
+
mask.push("config.base_path");
|
|
17500
|
+
config2.base_path = externalBasePath(options.basePath);
|
|
17501
|
+
}
|
|
17502
|
+
if (options.systemPrompt !== void 0) {
|
|
17503
|
+
mask.push("config.system_prompt");
|
|
17504
|
+
config2.system_prompt = options.systemPrompt;
|
|
17505
|
+
}
|
|
17506
|
+
if (mask.length === 0) {
|
|
17507
|
+
throw new Error(
|
|
17508
|
+
"databricks agent services: update requires comment, basePath or systemPrompt."
|
|
17509
|
+
);
|
|
17510
|
+
}
|
|
17511
|
+
if (Object.keys(config2).length > 0) body.config = config2;
|
|
17512
|
+
return this.client.request(
|
|
17513
|
+
"PATCH",
|
|
17514
|
+
agentServicePath(fullName),
|
|
17515
|
+
body,
|
|
17516
|
+
{ update_mask: mask.join(",") },
|
|
17517
|
+
{ retry: "safe" }
|
|
17518
|
+
);
|
|
17519
|
+
}
|
|
17520
|
+
delete(fullName) {
|
|
17521
|
+
return this.client.request(
|
|
17522
|
+
"DELETE",
|
|
17523
|
+
agentServicePath(fullName),
|
|
17524
|
+
void 0,
|
|
17525
|
+
{},
|
|
17526
|
+
{ retry: "never" }
|
|
17527
|
+
);
|
|
17528
|
+
}
|
|
17529
|
+
permissions(fullName) {
|
|
17530
|
+
return this.client.get(permissionsPath(fullName));
|
|
17531
|
+
}
|
|
17532
|
+
updatePermissions(fullName, changes) {
|
|
17533
|
+
if (changes.length === 0) {
|
|
17534
|
+
throw new Error("databricks agent services: at least one permission change is required.");
|
|
17535
|
+
}
|
|
17536
|
+
for (const change of changes) {
|
|
17537
|
+
if (!change.principal.trim())
|
|
17538
|
+
throw new Error("databricks agent services: principal cannot be empty.");
|
|
17539
|
+
if ((change.add?.length ?? 0) === 0 && (change.remove?.length ?? 0) === 0) {
|
|
17540
|
+
throw new Error(
|
|
17541
|
+
`databricks agent services: ${change.principal} has no privileges to add or remove.`
|
|
17542
|
+
);
|
|
17543
|
+
}
|
|
17544
|
+
}
|
|
17545
|
+
return this.client.request(
|
|
17546
|
+
"PATCH",
|
|
17547
|
+
permissionsPath(fullName),
|
|
17548
|
+
{ changes },
|
|
17549
|
+
{},
|
|
17550
|
+
{ retry: "safe" }
|
|
17551
|
+
);
|
|
17552
|
+
}
|
|
17553
|
+
grant(fullName, principal, privileges = ["EXECUTE"]) {
|
|
17554
|
+
return this.updatePermissions(fullName, [{ principal, add: privileges }]);
|
|
17555
|
+
}
|
|
17556
|
+
revoke(fullName, principal, privileges = ["EXECUTE"]) {
|
|
17557
|
+
return this.updatePermissions(fullName, [{ principal, remove: privileges }]);
|
|
17558
|
+
}
|
|
17559
|
+
};
|
|
17560
|
+
function databricksAgentServices(client, options) {
|
|
17561
|
+
return new DatabricksAgentServices(client, options);
|
|
17562
|
+
}
|
|
17563
|
+
function agentServicePath(fullName) {
|
|
17564
|
+
return `${DATABRICKS_AGENT_SERVICES_API}/${encodeURIComponent(fullUcName(fullName))}`;
|
|
17565
|
+
}
|
|
17566
|
+
function permissionsPath(fullName) {
|
|
17567
|
+
return `/api/2.1/unity-catalog/permissions/${DATABRICKS_AGENT_SERVICE_SECURABLE}/${encodeURIComponent(fullUcName(fullName))}`;
|
|
17568
|
+
}
|
|
17569
|
+
function fullUcName(value) {
|
|
17570
|
+
const parts = value.split(".");
|
|
17571
|
+
if (parts.length !== 3) {
|
|
17572
|
+
throw new Error(
|
|
17573
|
+
`databricks agent services: expected catalog.schema.service, received ${value}.`
|
|
17574
|
+
);
|
|
17575
|
+
}
|
|
17576
|
+
return parts.map(
|
|
17577
|
+
(part, index) => ucIdentifier(part, ["catalog", "schema", "service"][index] ?? "identifier")
|
|
17578
|
+
).join(".");
|
|
17579
|
+
}
|
|
17580
|
+
function connectionResourceName(value) {
|
|
17581
|
+
const trimmed = value.trim();
|
|
17582
|
+
const name = trimmed.startsWith("connections/") ? trimmed.slice("connections/".length) : trimmed;
|
|
17583
|
+
const parts = name.split(".");
|
|
17584
|
+
if (parts.length !== 1 && parts.length !== 3) {
|
|
17585
|
+
throw new Error(
|
|
17586
|
+
`databricks agent services: expected connection name or catalog.schema.connection, received ${value}.`
|
|
17587
|
+
);
|
|
17588
|
+
}
|
|
17589
|
+
return `connections/${parts.map(
|
|
17590
|
+
(part, index) => ucIdentifier(
|
|
17591
|
+
part,
|
|
17592
|
+
parts.length === 1 ? "connection" : ["catalog", "schema", "connection"][index] ?? "identifier"
|
|
17593
|
+
)
|
|
17594
|
+
).join(".")}`;
|
|
17595
|
+
}
|
|
17596
|
+
function externalBasePath(value) {
|
|
17597
|
+
const path = value.trim();
|
|
17598
|
+
if (!path.startsWith("/") || path.startsWith("//") || path.includes("?") || path.includes("#")) {
|
|
17599
|
+
throw new Error(
|
|
17600
|
+
"databricks agent services: basePath must be an absolute URL path without a query or fragment."
|
|
17601
|
+
);
|
|
17602
|
+
}
|
|
17603
|
+
return path;
|
|
17604
|
+
}
|
|
17605
|
+
function ucIdentifier(value, label) {
|
|
17606
|
+
const normalized = value.trim();
|
|
17607
|
+
if (!/^[A-Za-z0-9_][A-Za-z0-9_$-]*$/.test(normalized)) {
|
|
17608
|
+
throw new Error(`databricks agent services: invalid ${label} ${JSON.stringify(value)}.`);
|
|
17609
|
+
}
|
|
17610
|
+
return normalized;
|
|
17611
|
+
}
|
|
17612
|
+
|
|
17388
17613
|
// src/ai-search-admin.ts
|
|
17389
17614
|
var DatabricksAiSearchAdmin = class {
|
|
17390
17615
|
constructor(client) {
|
|
@@ -17625,6 +17850,55 @@ function jitter(ms) {
|
|
|
17625
17850
|
return Math.max(1, Math.round(ms * (0.9 + Math.random() * 0.2)));
|
|
17626
17851
|
}
|
|
17627
17852
|
|
|
17853
|
+
// src/ai-gateway.ts
|
|
17854
|
+
async function ensureDatabricksAiGateway(client) {
|
|
17855
|
+
await client.get("/api/ai-gateway/v2/endpoints", { page_size: 1 });
|
|
17856
|
+
}
|
|
17857
|
+
async function listDatabricksModelServices(client, options = {}) {
|
|
17858
|
+
const pageSize = positiveInteger(options.pageSize ?? 100, "pageSize");
|
|
17859
|
+
const maxPages = positiveInteger(options.maxPages ?? 100, "maxPages");
|
|
17860
|
+
const requiredPrefix = options.requiredPrefix ?? "system.ai.";
|
|
17861
|
+
const services = /* @__PURE__ */ new Map();
|
|
17862
|
+
const seenTokens = /* @__PURE__ */ new Set();
|
|
17863
|
+
let pageToken;
|
|
17864
|
+
for (let page = 0; page < maxPages; page += 1) {
|
|
17865
|
+
const response = await client.get(
|
|
17866
|
+
"/api/2.1/unity-catalog/model-services",
|
|
17867
|
+
{ page_size: pageSize, ...pageToken ? { page_token: pageToken } : {} }
|
|
17868
|
+
);
|
|
17869
|
+
for (const raw of response.model_services ?? []) {
|
|
17870
|
+
const service = normalizeModelService(raw, requiredPrefix);
|
|
17871
|
+
if (service) services.set(service.name, service);
|
|
17872
|
+
}
|
|
17873
|
+
const next = response.next_page_token?.trim();
|
|
17874
|
+
if (!next) return [...services.values()].sort((a2, b2) => a2.name.localeCompare(b2.name));
|
|
17875
|
+
if (seenTokens.has(next))
|
|
17876
|
+
throw new Error(
|
|
17877
|
+
`databricks model-services pagination repeated token after page ${page + 1}.`
|
|
17878
|
+
);
|
|
17879
|
+
seenTokens.add(next);
|
|
17880
|
+
pageToken = next;
|
|
17881
|
+
}
|
|
17882
|
+
throw new Error(`databricks model-services pagination exceeded ${maxPages} pages.`);
|
|
17883
|
+
}
|
|
17884
|
+
function normalizeModelService(raw, requiredPrefix) {
|
|
17885
|
+
const rawName = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
17886
|
+
const name = rawName.replace(/^model-services\//, "");
|
|
17887
|
+
if (!name.startsWith(requiredPrefix)) return void 0;
|
|
17888
|
+
return {
|
|
17889
|
+
name,
|
|
17890
|
+
...typeof raw.comment === "string" ? { comment: raw.comment } : {},
|
|
17891
|
+
...typeof raw.creator === "string" ? { creator: raw.creator } : {},
|
|
17892
|
+
...typeof raw.created_at === "number" ? { createdAt: raw.created_at } : {},
|
|
17893
|
+
...typeof raw.updated_at === "number" ? { updatedAt: raw.updated_at } : {}
|
|
17894
|
+
};
|
|
17895
|
+
}
|
|
17896
|
+
function positiveInteger(value, name) {
|
|
17897
|
+
if (!Number.isSafeInteger(value) || value <= 0)
|
|
17898
|
+
throw new Error(`${name} must be a positive integer.`);
|
|
17899
|
+
return value;
|
|
17900
|
+
}
|
|
17901
|
+
|
|
17628
17902
|
// src/sql-exec.ts
|
|
17629
17903
|
var TERMINAL_STATES = /* @__PURE__ */ new Set(["SUCCEEDED", "FAILED", "CANCELED", "CLOSED"]);
|
|
17630
17904
|
async function runStatement(client, warehouseId, statement, parameters, poll) {
|
|
@@ -17857,10 +18131,10 @@ var DatabricksGenieAgentModeClient = class {
|
|
|
17857
18131
|
if (options.acknowledgeBeta !== true)
|
|
17858
18132
|
throw new Error("Databricks Genie Agent Mode requires acknowledgeBeta: true.");
|
|
17859
18133
|
this.agentId = validateAgentId(options.agentId);
|
|
17860
|
-
this.maxEventBytes =
|
|
17861
|
-
this.maxEvents =
|
|
17862
|
-
this.timeoutMs =
|
|
17863
|
-
this.idleTimeoutMs =
|
|
18134
|
+
this.maxEventBytes = positiveInteger2(options.maxEventBytes ?? 2 * 1024 * 1024, "maxEventBytes");
|
|
18135
|
+
this.maxEvents = positiveInteger2(options.maxEvents ?? 1e4, "maxEvents");
|
|
18136
|
+
this.timeoutMs = positiveInteger2(options.timeoutMs ?? 90 * 6e4, "timeoutMs");
|
|
18137
|
+
this.idleTimeoutMs = positiveInteger2(options.idleTimeoutMs ?? 2 * 6e4, "idleTimeoutMs");
|
|
17864
18138
|
this.onEvent = options.onEvent;
|
|
17865
18139
|
}
|
|
17866
18140
|
agentId;
|
|
@@ -17975,7 +18249,7 @@ var DatabricksGenieAgentModeClient = class {
|
|
|
17975
18249
|
`/api/2.0/genie/agents/${encodeURIComponent(this.agentId)}/conversations/${encodeURIComponent(nonEmpty(conversationId, "conversationId"))}/items`,
|
|
17976
18250
|
{
|
|
17977
18251
|
after: optionalNonEmpty(options.after, "after"),
|
|
17978
|
-
limit: options.limit === void 0 ? void 0 :
|
|
18252
|
+
limit: options.limit === void 0 ? void 0 : positiveInteger2(options.limit, "limit")
|
|
17979
18253
|
},
|
|
17980
18254
|
signalOption(options.signal)
|
|
17981
18255
|
);
|
|
@@ -17994,7 +18268,7 @@ function databricksGenieAgentMode(client, options) {
|
|
|
17994
18268
|
}
|
|
17995
18269
|
function databricksGenieAgentModeTool(client, agentId, options = {}) {
|
|
17996
18270
|
const configuredAgentId = validateAgentId(agentId);
|
|
17997
|
-
const maxOutputBytes =
|
|
18271
|
+
const maxOutputBytes = positiveInteger2(options.maxOutputBytes ?? 1024 * 1024, "maxOutputBytes");
|
|
17998
18272
|
return {
|
|
17999
18273
|
name: "databricks_genie_agent_mode",
|
|
18000
18274
|
description: "Ask a Databricks Genie Agent through the Beta Agent Mode streaming API and return its terminal response.",
|
|
@@ -18194,7 +18468,7 @@ function nonEmpty(value, name) {
|
|
|
18194
18468
|
function optionalNonEmpty(value, name) {
|
|
18195
18469
|
return value === void 0 ? void 0 : nonEmpty(value, name);
|
|
18196
18470
|
}
|
|
18197
|
-
function
|
|
18471
|
+
function positiveInteger2(value, name) {
|
|
18198
18472
|
if (!Number.isSafeInteger(value) || value <= 0)
|
|
18199
18473
|
throw new Error(`Databricks Genie Agent Mode ${name} must be a positive integer.`);
|
|
18200
18474
|
return value;
|
|
@@ -18629,10 +18903,17 @@ function databricksGenieAuthoringTools(client, options) {
|
|
|
18629
18903
|
}
|
|
18630
18904
|
throw error51;
|
|
18631
18905
|
}
|
|
18632
|
-
|
|
18633
|
-
|
|
18634
|
-
|
|
18635
|
-
|
|
18906
|
+
let current;
|
|
18907
|
+
try {
|
|
18908
|
+
current = await admin.get(agentId, {
|
|
18909
|
+
includeConfiguration: true,
|
|
18910
|
+
...contextSignal(context)
|
|
18911
|
+
});
|
|
18912
|
+
} catch (lookupError) {
|
|
18913
|
+
if (!isGenieAbsentError(lookupError)) throw lookupError;
|
|
18914
|
+
await options.managedResourceStore.delete(GENIE_RESOURCE_TYPE, agentId);
|
|
18915
|
+
return { deleted: true, agentId, alreadyAbsent: true };
|
|
18916
|
+
}
|
|
18636
18917
|
if (current.fingerprint !== expectedFingerprint) {
|
|
18637
18918
|
throw new DatabricksManagedResourceConflictError({
|
|
18638
18919
|
resourceType: GENIE_RESOURCE_TYPE,
|
|
@@ -19347,19 +19628,19 @@ var DatabricksGenieClient = class {
|
|
|
19347
19628
|
this.agentId = resolveAgentId(options);
|
|
19348
19629
|
this.previewClient = options.previewClient;
|
|
19349
19630
|
this.basePath = `/api/2.0/genie/spaces/${enc2(this.agentId)}`;
|
|
19350
|
-
this.pollIntervalMs =
|
|
19351
|
-
this.timeoutMs =
|
|
19631
|
+
this.pollIntervalMs = positiveInteger3(options.pollIntervalMs ?? 2e3, "pollIntervalMs");
|
|
19632
|
+
this.timeoutMs = positiveInteger3(options.timeoutMs ?? 12e4, "timeoutMs");
|
|
19352
19633
|
this.pollJitterRatio = boundedRatio(options.pollJitterRatio ?? 0.2, "pollJitterRatio");
|
|
19353
|
-
this.maxAttachments =
|
|
19634
|
+
this.maxAttachments = positiveInteger3(options.maxAttachments ?? 32, "maxAttachments");
|
|
19354
19635
|
this.maxUnknownAttachments = nonNegativeInteger(
|
|
19355
19636
|
options.maxUnknownAttachments ?? 8,
|
|
19356
19637
|
"maxUnknownAttachments"
|
|
19357
19638
|
);
|
|
19358
|
-
this.maxResultBytes =
|
|
19639
|
+
this.maxResultBytes = positiveInteger3(
|
|
19359
19640
|
options.maxResultBytes ?? 2 * 1024 * 1024,
|
|
19360
19641
|
"maxResultBytes"
|
|
19361
19642
|
);
|
|
19362
|
-
this.maxTextChars =
|
|
19643
|
+
this.maxTextChars = positiveInteger3(options.maxTextChars ?? 1e5, "maxTextChars");
|
|
19363
19644
|
}
|
|
19364
19645
|
agentId;
|
|
19365
19646
|
basePath;
|
|
@@ -19694,7 +19975,7 @@ function nonEmpty3(value, name) {
|
|
|
19694
19975
|
if (!normalized) throw new Error(`Databricks Genie ${name} cannot be empty.`);
|
|
19695
19976
|
return normalized;
|
|
19696
19977
|
}
|
|
19697
|
-
function
|
|
19978
|
+
function positiveInteger3(value, name) {
|
|
19698
19979
|
if (!Number.isInteger(value) || value <= 0)
|
|
19699
19980
|
throw new Error(`Databricks Genie ${name} must be a positive integer.`);
|
|
19700
19981
|
return value;
|
|
@@ -20439,7 +20720,10 @@ function serializeTask(task) {
|
|
|
20439
20720
|
policyId: task.newCluster.policyId,
|
|
20440
20721
|
sparkVersion: task.newCluster.sparkVersion,
|
|
20441
20722
|
nodeTypeId: task.newCluster.nodeTypeId,
|
|
20442
|
-
|
|
20723
|
+
size: {
|
|
20724
|
+
$case: "numWorkers",
|
|
20725
|
+
numWorkers: task.newCluster.numWorkers
|
|
20726
|
+
},
|
|
20443
20727
|
...task.newCluster.customTags ? { customTags: task.newCluster.customTags } : {}
|
|
20444
20728
|
} }
|
|
20445
20729
|
} : {}
|
|
@@ -55236,13 +55520,7 @@ function stableDatabricksSdkClients(clients) {
|
|
|
55236
55520
|
return sdk;
|
|
55237
55521
|
}
|
|
55238
55522
|
function createDatabricksNativeClients(options) {
|
|
55239
|
-
const clientOptions =
|
|
55240
|
-
host: options.host,
|
|
55241
|
-
credentials: options.credentials,
|
|
55242
|
-
httpClient: fabricHttpClient(options.fetchImpl ?? fetch, options.extraHeaders),
|
|
55243
|
-
profileOptions: { noProfile: true, disableEnv: true },
|
|
55244
|
-
...options.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {}
|
|
55245
|
-
};
|
|
55523
|
+
const clientOptions = generatedClientOptions(options);
|
|
55246
55524
|
return {
|
|
55247
55525
|
jobs: new JobsClient(clientOptions),
|
|
55248
55526
|
statements: new StatementExecutionClient(clientOptions),
|
|
@@ -55269,6 +55547,15 @@ function createDatabricksNativeClients(options) {
|
|
|
55269
55547
|
})
|
|
55270
55548
|
};
|
|
55271
55549
|
}
|
|
55550
|
+
function generatedClientOptions(options) {
|
|
55551
|
+
return {
|
|
55552
|
+
host: options.host,
|
|
55553
|
+
credentials: options.credentials,
|
|
55554
|
+
httpClient: fabricHttpClient(options.fetchImpl ?? fetch, options.extraHeaders),
|
|
55555
|
+
profileOptions: { noProfile: true, disableEnv: true },
|
|
55556
|
+
...options.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {}
|
|
55557
|
+
};
|
|
55558
|
+
}
|
|
55272
55559
|
function fabricHttpClient(fetchImpl, extraHeaders) {
|
|
55273
55560
|
return {
|
|
55274
55561
|
async send(request) {
|
|
@@ -55601,6 +55888,151 @@ function databricksLakeflowTools(client) {
|
|
|
55601
55888
|
];
|
|
55602
55889
|
}
|
|
55603
55890
|
|
|
55891
|
+
// src/mlflow-tracing.ts
|
|
55892
|
+
import { createHash } from "crypto";
|
|
55893
|
+
import { eventToTelemetrySpan } from "@fabric-harness/sdk";
|
|
55894
|
+
function mlflowTraceExporter(options) {
|
|
55895
|
+
const onError = options.onError ?? ((context, error51) => {
|
|
55896
|
+
console.error(`[fabric-harness:mlflow-tracing] ${context}:`, error51);
|
|
55897
|
+
});
|
|
55898
|
+
const buffers = /* @__PURE__ */ new Map();
|
|
55899
|
+
return {
|
|
55900
|
+
sink: {
|
|
55901
|
+
record(event) {
|
|
55902
|
+
try {
|
|
55903
|
+
const key = `agent:${event.agent}:${event.instanceId}:${event.session}`;
|
|
55904
|
+
if (event.type === "submission_started") {
|
|
55905
|
+
buffers.set(key, {
|
|
55906
|
+
submissionId: event.submissionId,
|
|
55907
|
+
agent: event.agent,
|
|
55908
|
+
instanceId: event.instanceId,
|
|
55909
|
+
session: event.session,
|
|
55910
|
+
startedAtMs: event.at,
|
|
55911
|
+
attemptCount: event.attemptCount,
|
|
55912
|
+
...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
|
|
55913
|
+
spans: []
|
|
55914
|
+
});
|
|
55915
|
+
return;
|
|
55916
|
+
}
|
|
55917
|
+
if (event.type !== "submission_settled") return;
|
|
55918
|
+
const buffer = buffers.get(key);
|
|
55919
|
+
buffers.delete(key);
|
|
55920
|
+
const startedAtMs = buffer?.startedAtMs ?? event.at - (event.durationMs ?? 0);
|
|
55921
|
+
const attemptCount = event.attemptCount ?? buffer?.attemptCount;
|
|
55922
|
+
const trace = buildMlflowTrace({
|
|
55923
|
+
submissionId: event.submissionId,
|
|
55924
|
+
agent: event.agent,
|
|
55925
|
+
instanceId: event.instanceId,
|
|
55926
|
+
session: event.session,
|
|
55927
|
+
experimentId: options.experimentId,
|
|
55928
|
+
startedAtMs,
|
|
55929
|
+
settledAtMs: event.at,
|
|
55930
|
+
state: event.outcome === "completed" ? "OK" : "ERROR",
|
|
55931
|
+
spans: buffer?.spans ?? [],
|
|
55932
|
+
...attemptCount !== void 0 ? { attemptCount } : {},
|
|
55933
|
+
...event.tenantId !== void 0 ? { tenantId: event.tenantId } : {},
|
|
55934
|
+
...event.error !== void 0 ? { error: event.error } : {}
|
|
55935
|
+
});
|
|
55936
|
+
void options.client.post("/api/3.0/mlflow/traces", trace).catch((error51) => onError(`trace export failed for ${event.submissionId}`, error51));
|
|
55937
|
+
} catch (error51) {
|
|
55938
|
+
onError("telemetry event handling failed", error51);
|
|
55939
|
+
}
|
|
55940
|
+
}
|
|
55941
|
+
},
|
|
55942
|
+
onEvent(event) {
|
|
55943
|
+
try {
|
|
55944
|
+
if (!event.sessionId) return;
|
|
55945
|
+
const buffer = buffers.get(event.sessionId);
|
|
55946
|
+
if (!buffer) return;
|
|
55947
|
+
const span = eventToTelemetrySpan(event);
|
|
55948
|
+
if (span) buffer.spans.push(span);
|
|
55949
|
+
} catch (error51) {
|
|
55950
|
+
onError("event buffering failed", error51);
|
|
55951
|
+
}
|
|
55952
|
+
}
|
|
55953
|
+
};
|
|
55954
|
+
}
|
|
55955
|
+
function buildMlflowTrace(input) {
|
|
55956
|
+
const traceBytes = sha256(input.submissionId).subarray(0, 16);
|
|
55957
|
+
const traceIdBase64 = traceBytes.toString("base64");
|
|
55958
|
+
const rootSpanId = spanIdFor(input.submissionId, 0);
|
|
55959
|
+
const durationSeconds = Math.max(0, input.settledAtMs - input.startedAtMs) / 1e3;
|
|
55960
|
+
const rootSpan = {
|
|
55961
|
+
trace_id: traceIdBase64,
|
|
55962
|
+
span_id: rootSpanId,
|
|
55963
|
+
name: `fabric.submission ${input.agent}`,
|
|
55964
|
+
start_time_unix_nano: toUnixNano(input.startedAtMs),
|
|
55965
|
+
end_time_unix_nano: toUnixNano(input.settledAtMs),
|
|
55966
|
+
attributes: toOtlpAttributes({
|
|
55967
|
+
"fabric.submission_id": input.submissionId,
|
|
55968
|
+
"fabric.agent": input.agent,
|
|
55969
|
+
"fabric.instance_id": input.instanceId,
|
|
55970
|
+
"fabric.session": input.session,
|
|
55971
|
+
...input.attemptCount !== void 0 ? { "fabric.attempt_count": input.attemptCount } : {},
|
|
55972
|
+
...input.error !== void 0 ? { "fabric.error": input.error } : {}
|
|
55973
|
+
}),
|
|
55974
|
+
status: {
|
|
55975
|
+
code: input.state === "OK" ? "STATUS_CODE_OK" : "STATUS_CODE_ERROR",
|
|
55976
|
+
...input.error !== void 0 ? { message: input.error } : {}
|
|
55977
|
+
}
|
|
55978
|
+
};
|
|
55979
|
+
const childSpans = input.spans.map(
|
|
55980
|
+
(span, index) => ({
|
|
55981
|
+
trace_id: traceIdBase64,
|
|
55982
|
+
span_id: spanIdFor(input.submissionId, index + 1),
|
|
55983
|
+
parent_span_id: rootSpanId,
|
|
55984
|
+
name: span.name,
|
|
55985
|
+
start_time_unix_nano: toUnixNano(Date.parse(span.startedAt)),
|
|
55986
|
+
end_time_unix_nano: toUnixNano(Date.parse(span.endedAt)),
|
|
55987
|
+
attributes: toOtlpAttributes(span.attributes),
|
|
55988
|
+
status: { code: "STATUS_CODE_OK" }
|
|
55989
|
+
})
|
|
55990
|
+
);
|
|
55991
|
+
return {
|
|
55992
|
+
trace: {
|
|
55993
|
+
trace_info: {
|
|
55994
|
+
trace_id: `tr-${traceBytes.toString("hex")}`,
|
|
55995
|
+
trace_location: {
|
|
55996
|
+
type: "MLFLOW_EXPERIMENT",
|
|
55997
|
+
mlflow_experiment: { experiment_id: input.experimentId }
|
|
55998
|
+
},
|
|
55999
|
+
request_time: new Date(input.startedAtMs).toISOString(),
|
|
56000
|
+
execution_duration: `${durationSeconds.toFixed(3)}s`,
|
|
56001
|
+
state: input.state,
|
|
56002
|
+
trace_metadata: {
|
|
56003
|
+
"fabric.submission_id": input.submissionId,
|
|
56004
|
+
"fabric.agent": input.agent,
|
|
56005
|
+
"fabric.instance_id": input.instanceId,
|
|
56006
|
+
"fabric.session": input.session,
|
|
56007
|
+
...input.attemptCount !== void 0 ? { "fabric.attempt_count": String(input.attemptCount) } : {}
|
|
56008
|
+
},
|
|
56009
|
+
tags: {
|
|
56010
|
+
"fabric.agent": input.agent,
|
|
56011
|
+
...input.tenantId !== void 0 ? { "fabric.tenant_id": input.tenantId } : {}
|
|
56012
|
+
}
|
|
56013
|
+
},
|
|
56014
|
+
trace_data: { spans: [rootSpan, ...childSpans] }
|
|
56015
|
+
}
|
|
56016
|
+
};
|
|
56017
|
+
}
|
|
56018
|
+
function sha256(seed) {
|
|
56019
|
+
return createHash("sha256").update(seed).digest();
|
|
56020
|
+
}
|
|
56021
|
+
function spanIdFor(submissionId, index) {
|
|
56022
|
+
return sha256(`${submissionId}:span:${index}`).subarray(0, 8).toString("base64");
|
|
56023
|
+
}
|
|
56024
|
+
function toUnixNano(epochMs) {
|
|
56025
|
+
return `${Math.round(epochMs)}000000`;
|
|
56026
|
+
}
|
|
56027
|
+
function toOtlpAttributes(attributes) {
|
|
56028
|
+
return Object.entries(attributes).map(([key, value]) => {
|
|
56029
|
+
if (typeof value === "number") {
|
|
56030
|
+
return Number.isInteger(value) ? { key, value: { int_value: String(value) } } : { key, value: { double_value: value } };
|
|
56031
|
+
}
|
|
56032
|
+
return { key, value: { string_value: String(value) } };
|
|
56033
|
+
});
|
|
56034
|
+
}
|
|
56035
|
+
|
|
55604
56036
|
// src/model.ts
|
|
55605
56037
|
import {
|
|
55606
56038
|
OpenAICompatibleModelProvider,
|
|
@@ -55887,11 +56319,19 @@ var DatabricksServingAdmin = class {
|
|
|
55887
56319
|
});
|
|
55888
56320
|
}
|
|
55889
56321
|
updateAiGateway(name, update) {
|
|
56322
|
+
const rateLimits = update.rateLimits?.map((limit) => ({
|
|
56323
|
+
...limit.calls !== void 0 ? { calls: positiveBigInt(limit.calls, "rateLimits.calls") } : {},
|
|
56324
|
+
...limit.tokens !== void 0 ? { tokens: positiveBigInt(limit.tokens, "rateLimits.tokens") } : {},
|
|
56325
|
+
...limit.key !== void 0 ? { key: limit.key } : {},
|
|
56326
|
+
...limit.renewalPeriod !== void 0 ? { renewalPeriod: limit.renewalPeriod } : {},
|
|
56327
|
+
...limit.principal !== void 0 ? { principal: limit.principal } : {}
|
|
56328
|
+
}));
|
|
55890
56329
|
return this.client.putInferenceEndpointAiGateway({
|
|
55891
56330
|
name,
|
|
55892
|
-
...
|
|
56331
|
+
...rateLimits ? { rateLimits } : {},
|
|
55893
56332
|
...update.guardrails ? { guardrails: update.guardrails } : {},
|
|
55894
|
-
...update.
|
|
56333
|
+
...update.inferenceTableConfig ? { inferenceTableConfig: update.inferenceTableConfig } : {},
|
|
56334
|
+
...update.usageTrackingConfig ? { usageTrackingConfig: update.usageTrackingConfig } : {},
|
|
55895
56335
|
...update.fallbackEnabled !== void 0 ? { fallbackConfig: { enabled: update.fallbackEnabled } } : {}
|
|
55896
56336
|
});
|
|
55897
56337
|
}
|
|
@@ -55978,6 +56418,11 @@ function validate(spec) {
|
|
|
55978
56418
|
throw new Error("databricks serving: provisionedModelUnits must be a positive integer.");
|
|
55979
56419
|
}
|
|
55980
56420
|
}
|
|
56421
|
+
function positiveBigInt(value, name) {
|
|
56422
|
+
if (!Number.isSafeInteger(value) || value <= 0)
|
|
56423
|
+
throw new Error(`databricks serving: ${name} must be a positive safe integer.`);
|
|
56424
|
+
return BigInt(value);
|
|
56425
|
+
}
|
|
55981
56426
|
function serialize2(spec) {
|
|
55982
56427
|
return {
|
|
55983
56428
|
name: spec.name,
|
|
@@ -56125,9 +56570,23 @@ function gatewaySchema() {
|
|
|
56125
56570
|
additionalProperties: false,
|
|
56126
56571
|
properties: {
|
|
56127
56572
|
name: { type: "string" },
|
|
56128
|
-
rateLimits: {
|
|
56573
|
+
rateLimits: {
|
|
56574
|
+
type: "array",
|
|
56575
|
+
items: {
|
|
56576
|
+
type: "object",
|
|
56577
|
+
additionalProperties: false,
|
|
56578
|
+
properties: {
|
|
56579
|
+
calls: { type: "integer", minimum: 1 },
|
|
56580
|
+
tokens: { type: "integer", minimum: 1 },
|
|
56581
|
+
key: { type: "string" },
|
|
56582
|
+
renewalPeriod: { type: "string" },
|
|
56583
|
+
principal: { type: "string" }
|
|
56584
|
+
}
|
|
56585
|
+
}
|
|
56586
|
+
},
|
|
56129
56587
|
guardrails: { type: "object", additionalProperties: true },
|
|
56130
|
-
|
|
56588
|
+
inferenceTableConfig: { type: "object", additionalProperties: true },
|
|
56589
|
+
usageTrackingConfig: { type: "object", additionalProperties: true },
|
|
56131
56590
|
fallbackEnabled: { type: "boolean" }
|
|
56132
56591
|
},
|
|
56133
56592
|
required: ["name"]
|
|
@@ -56624,6 +57083,7 @@ function buildDatabricksBundle(config2, scope) {
|
|
|
56624
57083
|
});
|
|
56625
57084
|
const client = native.preview;
|
|
56626
57085
|
const genieAgentModeClient = genie.agentMode ? databricksGenieAgentMode(client, genie.agentMode) : void 0;
|
|
57086
|
+
const agentServicesClient = config2.agentServices ? databricksAgentServices(client, config2.agentServices) : void 0;
|
|
56627
57087
|
let embeddings;
|
|
56628
57088
|
let retriever;
|
|
56629
57089
|
let searchTool;
|
|
@@ -56744,6 +57204,12 @@ function buildDatabricksBundle(config2, scope) {
|
|
|
56744
57204
|
})
|
|
56745
57205
|
} : {},
|
|
56746
57206
|
...genieAgentModeClient ? { genieAgentMode: genieAgentModeClient } : {},
|
|
57207
|
+
...agentServicesClient ? { agentServices: agentServicesClient } : {},
|
|
57208
|
+
aiGateway: {
|
|
57209
|
+
ensure: () => ensureDatabricksAiGateway(client),
|
|
57210
|
+
listModelServices: (options) => listDatabricksModelServices(client, options)
|
|
57211
|
+
},
|
|
57212
|
+
mlflowTraceExporter: (options) => mlflowTraceExporter({ client, ...options }),
|
|
56747
57213
|
forPrincipal(input) {
|
|
56748
57214
|
const scoped = buildDatabricksBundle(config2, {
|
|
56749
57215
|
identity: input.tokenProvider,
|