@fabric-harness/databricks 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +192 -1
- package/dist/agent.js.map +1 -1
- package/dist/app-user-authorization.d.ts +6 -0
- package/dist/app-user-authorization.d.ts.map +1 -1
- package/dist/app-user-authorization.js +33 -0
- package/dist/app-user-authorization.js.map +1 -1
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/certification-environment.d.ts.map +1 -1
- package/dist/certification.d.ts +8 -1
- package/dist/certification.d.ts.map +1 -1
- package/dist/certify.js +93 -7
- package/dist/certify.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +410 -16
- package/dist/index.js.map +1 -1
- package/dist/release-evidence.d.ts +49 -0
- package/dist/release-evidence.d.ts.map +1 -0
- package/dist/sql-sandbox.d.ts +18 -0
- package/dist/sql-sandbox.d.ts.map +1 -1
- package/dist/sql-sandbox.js +114 -3
- package/dist/sql-sandbox.js.map +1 -1
- package/package.json +1 -1
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAEf,YAAY,EACZ,eAAe,EACf,YAAY,EAGZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,OAAO,EACR,MAAM,qBAAqB,CAAC;AAO7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAI3E,MAAM,MAAM,4BAA4B,CAAC,MAAM,GAAG,UAAU,EAAE,OAAO,GAAG,OAAO,IAAI,IAAI,CACrF,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,KAAK,GAAG,OAAO,CAChB,GAAG;IACF,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,CAAC,EAAE,CACJ,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG;QAAE,UAAU,EAAE,gBAAgB,CAAA;KAAE,KAChE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CACjC,CAAC;AAkEF,wBAAgB,qBAAqB,CAAC,MAAM,GAAG,UAAU,EAAE,OAAO,GAAG,OAAO,EAC1E,OAAO,GAAE,4BAA4B,CAAC,MAAM,EAAE,OAAO,CAAM,GAC1D,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CA6C/B;AAuBD,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAgCnF"}
|
package/dist/agent.js
CHANGED
|
@@ -1793,7 +1793,11 @@ var require_json_bigint = __commonJS({
|
|
|
1793
1793
|
});
|
|
1794
1794
|
|
|
1795
1795
|
// src/agent.ts
|
|
1796
|
-
import {
|
|
1796
|
+
import {
|
|
1797
|
+
defineAgent,
|
|
1798
|
+
listSandboxBackendFactories,
|
|
1799
|
+
mergeCapabilityPolicies
|
|
1800
|
+
} from "@fabric-harness/sdk/strict";
|
|
1797
1801
|
|
|
1798
1802
|
// ../../node_modules/.pnpm/@databricks+sdk-auth@0.21.0/node_modules/@databricks/sdk-auth/package.json
|
|
1799
1803
|
var package_default = {
|
|
@@ -58044,6 +58048,190 @@ function base643(value) {
|
|
|
58044
58048
|
return btoa(String.fromCharCode(...bytes));
|
|
58045
58049
|
}
|
|
58046
58050
|
|
|
58051
|
+
// src/sql-sandbox.ts
|
|
58052
|
+
import { createRemoteSandboxEnv, registerSandboxBackendFactory, registerSandboxRefDecoder, unregisterSandboxBackendFactory, unregisterSandboxRefDecoder } from "@fabric-harness/sdk";
|
|
58053
|
+
var DATABRICKS_SQL_SANDBOX_REF_PROVIDER = "databricks-sql";
|
|
58054
|
+
function databricksSqlSandbox(options) {
|
|
58055
|
+
const identity = databricksIdentity(options.principal);
|
|
58056
|
+
const client = options.client ?? createDatabricksNativeClients({
|
|
58057
|
+
host: options.host,
|
|
58058
|
+
credentials: databricksCredentials(options.principal),
|
|
58059
|
+
tokenProvider: identity,
|
|
58060
|
+
...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {}
|
|
58061
|
+
}).statements;
|
|
58062
|
+
const waitTimeoutSeconds = options.waitTimeoutSeconds ?? 30;
|
|
58063
|
+
const resultFormat = options.resultFormat ?? "jsonl";
|
|
58064
|
+
const memFs = /* @__PURE__ */ new Map();
|
|
58065
|
+
const api = {
|
|
58066
|
+
async exec(command) {
|
|
58067
|
+
const startedAt = Date.now();
|
|
58068
|
+
try {
|
|
58069
|
+
const response = await client.executeStatement({
|
|
58070
|
+
warehouseId: options.warehouseId,
|
|
58071
|
+
statement: command,
|
|
58072
|
+
waitTimeout: `${waitTimeoutSeconds}s`,
|
|
58073
|
+
onWaitTimeout: "CANCEL",
|
|
58074
|
+
...options.catalog ? { catalog: options.catalog } : {},
|
|
58075
|
+
...options.schema ? { schema: options.schema } : {}
|
|
58076
|
+
});
|
|
58077
|
+
if (response.status?.state === "FAILED" || response.status?.state === "CANCELED") {
|
|
58078
|
+
return {
|
|
58079
|
+
command,
|
|
58080
|
+
exitCode: 1,
|
|
58081
|
+
stdout: "",
|
|
58082
|
+
stderr: response.status.error?.message ?? `Statement ${response.status.state}`,
|
|
58083
|
+
durationMs: Date.now() - startedAt
|
|
58084
|
+
};
|
|
58085
|
+
}
|
|
58086
|
+
const stdout = serializeResult(response, resultFormat);
|
|
58087
|
+
return { command, exitCode: 0, stdout, stderr: "", durationMs: Date.now() - startedAt };
|
|
58088
|
+
} catch (error51) {
|
|
58089
|
+
return {
|
|
58090
|
+
command,
|
|
58091
|
+
exitCode: 1,
|
|
58092
|
+
stdout: "",
|
|
58093
|
+
stderr: error51 instanceof Error ? error51.message : String(error51),
|
|
58094
|
+
durationMs: Date.now() - startedAt
|
|
58095
|
+
};
|
|
58096
|
+
}
|
|
58097
|
+
},
|
|
58098
|
+
async readFile(path) {
|
|
58099
|
+
const bytes = memFs.get(path);
|
|
58100
|
+
if (!bytes) throw new Error(`No such file: ${path}`);
|
|
58101
|
+
return new TextDecoder().decode(bytes);
|
|
58102
|
+
},
|
|
58103
|
+
async readFileBuffer(path) {
|
|
58104
|
+
const bytes = memFs.get(path);
|
|
58105
|
+
if (!bytes) throw new Error(`No such file: ${path}`);
|
|
58106
|
+
return bytes;
|
|
58107
|
+
},
|
|
58108
|
+
async writeFile(path, content) {
|
|
58109
|
+
memFs.set(path, typeof content === "string" ? new TextEncoder().encode(content) : content);
|
|
58110
|
+
},
|
|
58111
|
+
async stat(path) {
|
|
58112
|
+
const bytes = memFs.get(path);
|
|
58113
|
+
if (!bytes) throw new Error(`No such file: ${path}`);
|
|
58114
|
+
return { type: "file", size: bytes.byteLength };
|
|
58115
|
+
},
|
|
58116
|
+
async readdir(path) {
|
|
58117
|
+
const prefix = path.replace(/\/$/, "");
|
|
58118
|
+
const direct = /* @__PURE__ */ new Set();
|
|
58119
|
+
for (const key of memFs.keys()) {
|
|
58120
|
+
if (!key.startsWith(`${prefix}/`)) continue;
|
|
58121
|
+
const tail = key.slice(prefix.length + 1);
|
|
58122
|
+
const slash = tail.indexOf("/");
|
|
58123
|
+
direct.add(slash > 0 ? tail.slice(0, slash) : tail);
|
|
58124
|
+
}
|
|
58125
|
+
return [...direct];
|
|
58126
|
+
},
|
|
58127
|
+
async exists(path) {
|
|
58128
|
+
return memFs.has(path);
|
|
58129
|
+
},
|
|
58130
|
+
async mkdir() {
|
|
58131
|
+
},
|
|
58132
|
+
async rm(path) {
|
|
58133
|
+
for (const key of [...memFs.keys()]) {
|
|
58134
|
+
if (key === path || key.startsWith(`${path}/`)) memFs.delete(key);
|
|
58135
|
+
}
|
|
58136
|
+
}
|
|
58137
|
+
};
|
|
58138
|
+
return createRemoteSandboxEnv(api, {
|
|
58139
|
+
cwd: "/workspace",
|
|
58140
|
+
capabilities: { exec: true, filesystem: true, binaryFiles: true, snapshots: false, restore: false, reconnect: true, network: "provider-managed", persistence: "session", isolation: "provider" },
|
|
58141
|
+
encodeRef: () => ({
|
|
58142
|
+
provider: DATABRICKS_SQL_SANDBOX_REF_PROVIDER,
|
|
58143
|
+
providerData: databricksSqlSandboxRefData(options)
|
|
58144
|
+
})
|
|
58145
|
+
});
|
|
58146
|
+
}
|
|
58147
|
+
function registerDatabricksSqlSandboxBackend(registration = {}) {
|
|
58148
|
+
registerSandboxBackendFactory("databricks", (factoryOptions) => createRegisteredDatabricksSqlSandbox(factoryOptions, registration));
|
|
58149
|
+
registerSandboxRefDecoder(DATABRICKS_SQL_SANDBOX_REF_PROVIDER, (providerData) => {
|
|
58150
|
+
const target = assertDatabricksSqlSandboxRefData(providerData);
|
|
58151
|
+
return (factoryOptions) => databricksSqlSandbox({
|
|
58152
|
+
...target,
|
|
58153
|
+
principal: resolveRegisteredPrincipal(factoryOptions, target, registration),
|
|
58154
|
+
...registration.client ? { client: registration.client } : {}
|
|
58155
|
+
});
|
|
58156
|
+
});
|
|
58157
|
+
}
|
|
58158
|
+
function createRegisteredDatabricksSqlSandbox(options, registration) {
|
|
58159
|
+
const env2 = options.env ?? process.env;
|
|
58160
|
+
const metadata = options.metadata ?? {};
|
|
58161
|
+
const catalog = metadataString(metadata, "databricksCatalog") ?? env2.DATABRICKS_CATALOG;
|
|
58162
|
+
const schema = metadataString(metadata, "databricksSchema") ?? env2.DATABRICKS_SCHEMA;
|
|
58163
|
+
const resultFormat = metadataString(metadata, "databricksResultFormat");
|
|
58164
|
+
const target = {
|
|
58165
|
+
host: metadataString(metadata, "databricksHost") ?? env2.DATABRICKS_HOST ?? "",
|
|
58166
|
+
warehouseId: metadataString(metadata, "databricksWarehouseId") ?? env2.DATABRICKS_WAREHOUSE_ID ?? "",
|
|
58167
|
+
...catalog ? { catalog } : {},
|
|
58168
|
+
...schema ? { schema } : {},
|
|
58169
|
+
...resultFormat ? { resultFormat: assertResultFormat(resultFormat) } : {}
|
|
58170
|
+
};
|
|
58171
|
+
assertDatabricksSqlSandboxRefData(target);
|
|
58172
|
+
return databricksSqlSandbox({
|
|
58173
|
+
...target,
|
|
58174
|
+
principal: resolveRegisteredPrincipal(options, target, registration),
|
|
58175
|
+
...registration.client ? { client: registration.client } : {}
|
|
58176
|
+
});
|
|
58177
|
+
}
|
|
58178
|
+
function resolveRegisteredPrincipal(options, target, registration) {
|
|
58179
|
+
const env2 = options.env ?? process.env;
|
|
58180
|
+
return registration.resolvePrincipal?.(env2, target) ?? databricksPrincipalFromEnv(env2);
|
|
58181
|
+
}
|
|
58182
|
+
function databricksSqlSandboxRefData(options) {
|
|
58183
|
+
return {
|
|
58184
|
+
host: options.host,
|
|
58185
|
+
warehouseId: options.warehouseId,
|
|
58186
|
+
...options.catalog ? { catalog: options.catalog } : {},
|
|
58187
|
+
...options.schema ? { schema: options.schema } : {},
|
|
58188
|
+
...options.resultFormat ? { resultFormat: options.resultFormat } : {},
|
|
58189
|
+
...options.waitTimeoutSeconds !== void 0 ? { waitTimeoutSeconds: options.waitTimeoutSeconds } : {}
|
|
58190
|
+
};
|
|
58191
|
+
}
|
|
58192
|
+
function assertDatabricksSqlSandboxRefData(value) {
|
|
58193
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid Databricks SQL sandbox reference.");
|
|
58194
|
+
const data = value;
|
|
58195
|
+
if (typeof data.host !== "string" || data.host.trim().length === 0) throw new Error("Databricks SQL sandbox reference is missing host.");
|
|
58196
|
+
if (typeof data.warehouseId !== "string" || data.warehouseId.trim().length === 0) throw new Error("Databricks SQL sandbox reference is missing warehouseId.");
|
|
58197
|
+
const result = { host: data.host, warehouseId: data.warehouseId };
|
|
58198
|
+
if (typeof data.catalog === "string") result.catalog = data.catalog;
|
|
58199
|
+
if (typeof data.schema === "string") result.schema = data.schema;
|
|
58200
|
+
if (data.resultFormat !== void 0) result.resultFormat = assertResultFormat(data.resultFormat);
|
|
58201
|
+
if (data.waitTimeoutSeconds !== void 0) {
|
|
58202
|
+
if (typeof data.waitTimeoutSeconds !== "number" || !Number.isFinite(data.waitTimeoutSeconds)) throw new Error("Databricks SQL sandbox reference has an invalid waitTimeoutSeconds.");
|
|
58203
|
+
result.waitTimeoutSeconds = data.waitTimeoutSeconds;
|
|
58204
|
+
}
|
|
58205
|
+
return result;
|
|
58206
|
+
}
|
|
58207
|
+
function metadataString(metadata, key) {
|
|
58208
|
+
const value = metadata[key];
|
|
58209
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
58210
|
+
}
|
|
58211
|
+
function assertResultFormat(value) {
|
|
58212
|
+
if (value === "jsonl" || value === "csv") return value;
|
|
58213
|
+
throw new Error("Databricks SQL sandbox result format must be jsonl or csv.");
|
|
58214
|
+
}
|
|
58215
|
+
function serializeResult(response, format) {
|
|
58216
|
+
const columns = response.manifest?.schema?.columns?.map((c2) => c2.name ?? "") ?? [];
|
|
58217
|
+
const rows = response.result?.dataArray ?? [];
|
|
58218
|
+
if (format === "csv") {
|
|
58219
|
+
const header = columns.join(",");
|
|
58220
|
+
const body = rows.map((row) => row.map(formatCsvCell).join(",")).join("\n");
|
|
58221
|
+
return [header, body].filter(Boolean).join("\n");
|
|
58222
|
+
}
|
|
58223
|
+
return rows.map((row) => {
|
|
58224
|
+
const obj = {};
|
|
58225
|
+
for (let i2 = 0; i2 < columns.length; i2 += 1) obj[columns[i2] ?? `_${i2}`] = row[i2];
|
|
58226
|
+
return JSON.stringify(obj);
|
|
58227
|
+
}).join("\n");
|
|
58228
|
+
}
|
|
58229
|
+
function formatCsvCell(value) {
|
|
58230
|
+
if (value === null || value === void 0) return "";
|
|
58231
|
+
const str = String(value);
|
|
58232
|
+
return /[",\n]/.test(str) ? `"${str.replace(/"/g, '""')}"` : str;
|
|
58233
|
+
}
|
|
58234
|
+
|
|
58047
58235
|
// src/index.ts
|
|
58048
58236
|
function databricks(config2) {
|
|
58049
58237
|
return buildDatabricksBundle(config2);
|
|
@@ -58356,6 +58544,9 @@ function defineDatabricksAgent(options = {}) {
|
|
|
58356
58544
|
} = merged;
|
|
58357
58545
|
const directTools = tools.filter((tool7) => typeof tool7 !== "string");
|
|
58358
58546
|
const toolRefs = tools.filter((tool7) => typeof tool7 === "string");
|
|
58547
|
+
if (sandbox === "databricks" && !listSandboxBackendFactories().includes("databricks")) {
|
|
58548
|
+
registerDatabricksSqlSandboxBackend();
|
|
58549
|
+
}
|
|
58359
58550
|
const def = {
|
|
58360
58551
|
...definition,
|
|
58361
58552
|
...directTools.length > 0 ? { tools: directTools } : {},
|