@fabric-harness/databricks 7.0.1 → 7.1.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.
@@ -1 +1 @@
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;AAS7B,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EAEvB,MAAM,YAAY,CAAC;AAIpB,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,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,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,CAyE/B;AA0ED,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBA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package/dist/agent.js CHANGED
@@ -23024,6 +23024,11 @@ function databricksModelBaseUrl(host, mode) {
23024
23024
  function isDatabricksModelService(model) {
23025
23025
  return model?.startsWith("system.ai.") ?? false;
23026
23026
  }
23027
+ function databricksNativeModelId(model) {
23028
+ if (model === void 0) return void 0;
23029
+ const prefix = "databricks/";
23030
+ return model.startsWith(prefix) ? model.slice(prefix.length) : model;
23031
+ }
23027
23032
  var DatabricksModelProvider = class {
23028
23033
  name = "databricks";
23029
23034
  options;
@@ -23056,26 +23061,29 @@ var DatabricksModelProvider = class {
23056
23061
  }) : void 0;
23057
23062
  }
23058
23063
  generate(request) {
23059
- return this.providerFor(request.model).generate(request);
23064
+ const model = databricksNativeModelId(request.model);
23065
+ return this.providerFor(model).generate({ ...request, ...model !== void 0 ? { model } : {} });
23060
23066
  }
23061
23067
  stream(request) {
23062
- const provider = this.providerFor(request.model);
23068
+ const model = databricksNativeModelId(request.model);
23069
+ const provider = this.providerFor(model);
23063
23070
  if (!provider.stream)
23064
23071
  throw new Error("databricks: selected provider does not support streaming.");
23065
- return provider.stream(request);
23072
+ return provider.stream({ ...request, ...model !== void 0 ? { model } : {} });
23066
23073
  }
23067
23074
  getModelMetadata(model = this.options.defaultModel) {
23068
- const mode = this.modeFor(model);
23075
+ const native = databricksNativeModelId(model);
23076
+ const mode = this.modeFor(native);
23069
23077
  return {
23070
23078
  provider: this.name,
23071
- ...model ? { model } : {},
23079
+ ...native ? { model: native } : {},
23072
23080
  gateway: this.options.baseUrl ?? databricksModelBaseUrl(this.options.host, mode),
23073
- ...model && this.options.modelMetadata?.[model] ? this.options.modelMetadata[model] : {}
23081
+ ...native && this.options.modelMetadata?.[native] ? this.options.modelMetadata[native] : {}
23074
23082
  };
23075
23083
  }
23076
23084
  providerFor(model = this.options.defaultModel) {
23077
23085
  if (this.explicit) return this.explicit;
23078
- return this.modeFor(model) === "ai-gateway" ? this.gateway : this.serving;
23086
+ return this.modeFor(databricksNativeModelId(model)) === "ai-gateway" ? this.gateway : this.serving;
23079
23087
  }
23080
23088
  modeFor(model) {
23081
23089
  const configured = this.options.mode ?? "auto";
@@ -61660,27 +61668,52 @@ function databricksAnalyticsCostLimitFromEnv(env2, config2, bundle) {
61660
61668
  onExceed: "throw"
61661
61669
  });
61662
61670
  }
61671
+ function collectDatabricksEnvPrerequisites(env2, options = {}) {
61672
+ if (env2.FABRIC_MOCK === "1") return [];
61673
+ const missing = [];
61674
+ if (!env2.DATABRICKS_HOST?.trim()) {
61675
+ missing.push(
61676
+ "DATABRICKS_HOST \u2014 workspace URL (e.g. https://adb-1234567890.0.azuredatabricks.net)"
61677
+ );
61678
+ }
61679
+ if (options.analyticsCopilot === true) {
61680
+ if (!env2.DATABRICKS_WAREHOUSE_ID?.trim()) {
61681
+ missing.push(
61682
+ "DATABRICKS_WAREHOUSE_ID \u2014 SQL warehouse id (SELECT-only tools and cost enforcement; a stopped warehouse id is enough to start)"
61683
+ );
61684
+ }
61685
+ if (!env2.DATABRICKS_GENIE_SPACE_ID?.trim()) {
61686
+ missing.push("DATABRICKS_GENIE_SPACE_ID \u2014 Genie space id for the analytics copilot");
61687
+ }
61688
+ if (!env2.DATABRICKS_ANALYTICS_STEWARD_AUDIENCE?.trim()) {
61689
+ missing.push("DATABRICKS_ANALYTICS_STEWARD_AUDIENCE \u2014 governance steward audience");
61690
+ }
61691
+ if (!env2.DATABRICKS_COST_TENANT_ID?.trim()) {
61692
+ missing.push("DATABRICKS_COST_TENANT_ID \u2014 tenant id for per-day cost enforcement");
61693
+ }
61694
+ const perDayUsd = Number(env2.DATABRICKS_COST_PER_DAY_USD);
61695
+ if (!Number.isFinite(perDayUsd) || perDayUsd <= 0) {
61696
+ missing.push("DATABRICKS_COST_PER_DAY_USD \u2014 positive number for per-day cost enforcement");
61697
+ }
61698
+ }
61699
+ return missing;
61700
+ }
61663
61701
  function databricksConfigFromEnv(env2, options = {}) {
61664
- const rawHost = env2.DATABRICKS_HOST;
61665
- const host = rawHost ? rawHost.includes("://") ? rawHost : `https://${rawHost}` : void 0;
61666
- if (!host && env2.FABRIC_MOCK !== "1") {
61702
+ const analyticsCopilot = options.analyticsCopilot === true;
61703
+ const missing = collectDatabricksEnvPrerequisites(env2, { analyticsCopilot });
61704
+ if (missing.length > 0) {
61705
+ const rows = missing.map((row) => `- ${row}`).join("\n");
61667
61706
  throw new Error(
61668
- "Missing DATABRICKS_HOST environment variable. Set it or pass an explicit databricks config."
61707
+ `Databricks agent is missing required configuration (${missing.length} ${missing.length === 1 ? "issue" : "issues"}):
61708
+ ${rows}
61709
+ Set every variable in .env (see .env.example) or pass an explicit databricks config to defineDatabricksAgent.`
61669
61710
  );
61670
61711
  }
61712
+ const rawHost = env2.DATABRICKS_HOST;
61713
+ const host = rawHost ? rawHost.includes("://") ? rawHost : `https://${rawHost}` : void 0;
61671
61714
  const principal = env2.FABRIC_MOCK === "1" ? { kind: "pat", token: "mock-token" } : databricksPrincipalFromEnv(env2);
61672
- const analyticsCopilot = options.analyticsCopilot === true;
61673
61715
  const genieAgentId = env2.DATABRICKS_GENIE_SPACE_ID;
61674
61716
  const stewardAudience = env2.DATABRICKS_ANALYTICS_STEWARD_AUDIENCE;
61675
- if (analyticsCopilot && env2.FABRIC_MOCK !== "1" && !env2.DATABRICKS_WAREHOUSE_ID) {
61676
- throw new Error("Analytics copilot requires DATABRICKS_WAREHOUSE_ID.");
61677
- }
61678
- if (analyticsCopilot && env2.FABRIC_MOCK !== "1" && !genieAgentId) {
61679
- throw new Error("Analytics copilot requires DATABRICKS_GENIE_SPACE_ID.");
61680
- }
61681
- if (analyticsCopilot && env2.FABRIC_MOCK !== "1" && !stewardAudience) {
61682
- throw new Error("Analytics copilot requires DATABRICKS_ANALYTICS_STEWARD_AUDIENCE.");
61683
- }
61684
61717
  const catalog = env2.DATABRICKS_CATALOG?.trim();
61685
61718
  return {
61686
61719
  host: host ?? "https://mock.databricks.com",