@fabric-harness/databricks 0.16.1 → 1.0.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.
- package/dist/agent.d.ts +45 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +206 -0
- package/dist/agent.js.map +1 -0
- package/dist/ai.d.ts +19 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +22 -0
- package/dist/ai.js.map +1 -0
- package/dist/app.d.ts +81 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +87 -0
- package/dist/app.js.map +1 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +114 -0
- package/dist/client.js.map +1 -0
- package/dist/consumption.d.ts +45 -0
- package/dist/consumption.d.ts.map +1 -0
- package/dist/consumption.js +85 -0
- package/dist/consumption.js.map +1 -0
- package/dist/cost-budget-actuals.d.ts +27 -0
- package/dist/cost-budget-actuals.d.ts.map +1 -0
- package/dist/cost-budget-actuals.js +265 -0
- package/dist/cost-budget-actuals.js.map +1 -0
- package/dist/embeddings.d.ts +18 -0
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +24 -0
- package/dist/embeddings.js.map +1 -0
- package/dist/feature-serving.d.ts +17 -0
- package/dist/feature-serving.d.ts.map +1 -0
- package/dist/feature-serving.js +29 -0
- package/dist/feature-serving.js.map +1 -0
- package/dist/genie.d.ts +22 -0
- package/dist/genie.d.ts.map +1 -0
- package/dist/genie.js +60 -0
- package/dist/genie.js.map +1 -0
- package/dist/governance.d.ts +70 -0
- package/dist/governance.d.ts.map +1 -0
- package/dist/governance.js +123 -0
- package/dist/governance.js.map +1 -0
- package/dist/identity.d.ts +72 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +119 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +143 -80
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +111 -227
- package/dist/index.js.map +1 -1
- package/dist/lakebase.d.ts +49 -0
- package/dist/lakebase.d.ts.map +1 -0
- package/dist/lakebase.js +25 -0
- package/dist/lakebase.js.map +1 -0
- package/dist/lakeflow.d.ts +28 -0
- package/dist/lakeflow.d.ts.map +1 -0
- package/dist/lakeflow.js +75 -0
- package/dist/lakeflow.js.map +1 -0
- package/dist/mlflow-tracing.d.ts +111 -0
- package/dist/mlflow-tracing.d.ts.map +1 -0
- package/dist/mlflow-tracing.js +167 -0
- package/dist/mlflow-tracing.js.map +1 -0
- package/dist/mock-provider.d.ts +26 -0
- package/dist/mock-provider.d.ts.map +1 -0
- package/dist/mock-provider.js +66 -0
- package/dist/mock-provider.js.map +1 -0
- package/dist/model.d.ts +29 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +50 -0
- package/dist/model.js.map +1 -0
- package/dist/persistence.d.ts +73 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +82 -0
- package/dist/persistence.js.map +1 -0
- package/dist/serving-usage.d.ts +48 -0
- package/dist/serving-usage.d.ts.map +1 -0
- package/dist/serving-usage.js +100 -0
- package/dist/serving-usage.js.map +1 -0
- package/dist/sql-exec.d.ts +17 -0
- package/dist/sql-exec.d.ts.map +1 -0
- package/dist/sql-exec.js +36 -0
- package/dist/sql-exec.js.map +1 -0
- package/dist/sql-sandbox.d.ts +1 -1
- package/dist/sql-sandbox.d.ts.map +1 -1
- package/dist/sql-sandbox.js +1 -1
- package/dist/sql-sandbox.js.map +1 -1
- package/dist/telemetry-sink.d.ts +29 -0
- package/dist/telemetry-sink.d.ts.map +1 -0
- package/dist/telemetry-sink.js +129 -0
- package/dist/telemetry-sink.js.map +1 -0
- package/dist/tools.d.ts +71 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +176 -0
- package/dist/tools.js.map +1 -0
- package/dist/vector-search.d.ts +24 -0
- package/dist/vector-search.d.ts.map +1 -0
- package/dist/vector-search.js +63 -0
- package/dist/vector-search.js.map +1 -0
- package/dist/volumes-attachment-store.d.ts +64 -0
- package/dist/volumes-attachment-store.d.ts.map +1 -0
- package/dist/volumes-attachment-store.js +172 -0
- package/dist/volumes-attachment-store.js.map +1 -0
- package/package.json +20 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,85 +1,148 @@
|
|
|
1
|
-
import type { FilesystemSource,
|
|
2
|
-
|
|
1
|
+
import type { CapabilityPolicy, EmbeddingProvider, FilesystemSource, ModelProvider, Retriever, SessionStore, ToolDef } from '@fabric-harness/sdk';
|
|
2
|
+
import { DatabricksRestClient } from './client.js';
|
|
3
|
+
import type { DatabricksWorkspaceSourceOptions } from './tools.js';
|
|
4
|
+
import type { DatabricksPrincipal, DatabricksTokenProvider } from './identity.js';
|
|
5
|
+
import type { DatabricksLineageRecord } from './governance.js';
|
|
6
|
+
import type { LakebaseClient, LakebasePoolFactory } from './lakebase.js';
|
|
7
|
+
import type { DatabricksConsumption } from './consumption.js';
|
|
8
|
+
export { DatabricksRestClient, createDatabricksClient, waitForDatabricksRun, waitForDatabricksStatement } from './client.js';
|
|
9
|
+
export type { DatabricksClientOptions, DatabricksWaitOptions } from './client.js';
|
|
10
|
+
export { databricksSqlTool, databricksRunJobTool, databricksNotebookTool, databricksMlflowLogMetricTool, databricksMlflowLogParamTool, unityCatalogTablesTool, databricksTableInfoTool, databricksWorkspaceSource } from './tools.js';
|
|
11
|
+
export type { DatabricksSqlToolOptions, DatabricksWorkspaceSourceOptions } from './tools.js';
|
|
12
|
+
export { databricksFoundationModelProvider, registerDatabricksModelProvider } from './model.js';
|
|
13
|
+
export type { DatabricksModelOptions } from './model.js';
|
|
14
|
+
export { appServicePrincipalFromEnv, databricksIdentity, fabricPrincipalFor, onBehalfOfFromHeaders } from './identity.js';
|
|
15
|
+
export type { DatabricksPrincipal, DatabricksTokenProvider, FabricPrincipalOverrides } from './identity.js';
|
|
16
|
+
export { withGovernance, withGovernanceTools, databricksApprovalRules, databricksGovernancePolicy } from './governance.js';
|
|
17
|
+
export type { DatabricksGovernanceOptions, DatabricksLineageRecord, DatabricksApprovalRuleOptions, DatabricksGovernancePolicyOptions } from './governance.js';
|
|
18
|
+
export { lakebaseClient } from './lakebase.js';
|
|
19
|
+
export { databricksPersistence } from './persistence.js';
|
|
20
|
+
export { databricksTelemetry, ensureDatabricksTelemetryTables } from './telemetry-sink.js';
|
|
21
|
+
export { databricksApp } from './app.js';
|
|
22
|
+
export type { DatabricksAppOptions, DatabricksAppRuntime } from './app.js';
|
|
23
|
+
export type { DatabricksTelemetry, DatabricksTelemetryOptions } from './telemetry-sink.js';
|
|
24
|
+
export type { DatabricksPersistence, DatabricksPersistenceOptions, DatabricksPersistenceStoreModule } from './persistence.js';
|
|
25
|
+
export type { LakebaseClient, LakebaseClientOptions, LakebasePoolConfig, LakebasePoolFactory } from './lakebase.js';
|
|
26
|
+
export { UcVolumesAttachmentStore } from './volumes-attachment-store.js';
|
|
27
|
+
export type { UcVolumesAttachmentStoreOptions } from './volumes-attachment-store.js';
|
|
28
|
+
export { buildMlflowTrace, mlflowTraceExporter } from './mlflow-tracing.js';
|
|
29
|
+
export type { MlflowTraceExporter, MlflowTraceExporterOptions, MlflowTraceInput, MlflowTracePayload } from './mlflow-tracing.js';
|
|
30
|
+
export { inferenceTableUsageQuery, servingUsageCapture } from './serving-usage.js';
|
|
31
|
+
export type { InferenceTableUsageQueryOptions, ServingUsageCaptureOptions } from './serving-usage.js';
|
|
32
|
+
export { databricksEmbeddings } from './embeddings.js';
|
|
33
|
+
export type { DatabricksEmbeddingsOptions } from './embeddings.js';
|
|
34
|
+
export { databricksVectorSearch } from './vector-search.js';
|
|
35
|
+
export type { DatabricksVectorSearchOptions } from './vector-search.js';
|
|
36
|
+
export { databricksAiQueryTool } from './ai.js';
|
|
37
|
+
export type { DatabricksAiQueryToolOptions } from './ai.js';
|
|
38
|
+
export { databricksGenieTool } from './genie.js';
|
|
39
|
+
export type { DatabricksGenieToolOptions } from './genie.js';
|
|
40
|
+
export { databricksLakeflowTools, databricksPipelineListTool, databricksPipelineStatusTool, databricksPipelineStartTool, databricksPipelineStopTool } from './lakeflow.js';
|
|
41
|
+
export { databricksConsumption, databricksConsumptionTool } from './consumption.js';
|
|
42
|
+
export type { ConsumptionGroupBy, ConsumptionSummary, ConsumptionSummaryOptions, DatabricksConsumption, DatabricksConsumptionOptions, DatabricksConsumptionToolOptions } from './consumption.js';
|
|
43
|
+
export { databricksActualCostSource, databricksTenantCostLimit } from './cost-budget-actuals.js';
|
|
44
|
+
export type { DatabricksActualCostSourceOptions } from './cost-budget-actuals.js';
|
|
45
|
+
export { databricksFeatureLookupTool } from './feature-serving.js';
|
|
46
|
+
export type { DatabricksFeatureLookupToolOptions } from './feature-serving.js';
|
|
47
|
+
export { databricksAgent, defineDatabricksAgent, resolveToolRefs } from './agent.js';
|
|
48
|
+
export type { DatabricksAgentOptions, DefineDatabricksAgentOptions } from './agent.js';
|
|
49
|
+
export { MockDatabricksModelProvider } from './mock-provider.js';
|
|
50
|
+
export type { MockDatabricksModelProviderOptions } from './mock-provider.js';
|
|
51
|
+
export interface DatabricksBundleConfig {
|
|
52
|
+
/** Workspace host, e.g. https://adb-1234567890.0.cloud.databricks.com */
|
|
3
53
|
host: string;
|
|
4
|
-
|
|
54
|
+
/** Acting identity — UC enforces this principal's grants on every call. */
|
|
55
|
+
principal: DatabricksPrincipal;
|
|
56
|
+
/** Default serving-endpoint name for the returned model provider. */
|
|
57
|
+
model?: string;
|
|
58
|
+
/** SQL Warehouse id; when set, a governed `databricks_sql` tool is included. */
|
|
59
|
+
warehouseId?: string;
|
|
60
|
+
/** Extra Databricks tools to include; governed alongside the defaults. */
|
|
61
|
+
tools?: ToolDef[];
|
|
62
|
+
governance?: {
|
|
63
|
+
/** When set, sensitive (write/execute) tools route to this approval audience. */
|
|
64
|
+
stewardAudience?: string;
|
|
65
|
+
approvalServices?: string[];
|
|
66
|
+
/** Belt-and-suspenders catalog allowlist enforced before tool execution (UC stays source of truth). */
|
|
67
|
+
catalogs?: string[];
|
|
68
|
+
approvalTtlSeconds?: number;
|
|
69
|
+
/** Label recorded in lineage for the acting principal (never a token). */
|
|
70
|
+
principalLabel?: string;
|
|
71
|
+
/** Sink for audit/lineage records; wire to OTel / onEvent at the app layer. */
|
|
72
|
+
onLineage?: (record: DatabricksLineageRecord) => void;
|
|
73
|
+
};
|
|
74
|
+
/** Lakebase (managed Postgres) connection for durable session/journal state. */
|
|
75
|
+
lakebase?: {
|
|
76
|
+
host: string;
|
|
77
|
+
database: string;
|
|
78
|
+
user: string;
|
|
79
|
+
port?: number;
|
|
80
|
+
ssl?: boolean | {
|
|
81
|
+
rejectUnauthorized?: boolean;
|
|
82
|
+
};
|
|
83
|
+
poolFactory?: LakebasePoolFactory;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Builds a SessionStore from the Lakebase client. Injected so this package stays decoupled from
|
|
87
|
+
* `@fabric-harness/node` — e.g. `(client) => new PostgresSessionStore({ client })`.
|
|
88
|
+
*/
|
|
89
|
+
sessionStoreFactory?: (client: LakebaseClient) => SessionStore;
|
|
90
|
+
/** Mosaic AI Vector Search for RAG. Adds a governed `search` tool and exposes `retriever`. */
|
|
91
|
+
vectorSearch?: {
|
|
92
|
+
/** Full index name `catalog.schema.index`. */
|
|
93
|
+
index: string;
|
|
94
|
+
/** Column holding the chunk text. */
|
|
95
|
+
textColumn: string;
|
|
96
|
+
columns?: string[];
|
|
97
|
+
idColumn?: string;
|
|
98
|
+
/** `'text'` (managed-embedding index, default) or `'vector'` (self-managed; requires `embeddingEndpoint`). */
|
|
99
|
+
queryType?: 'text' | 'vector';
|
|
100
|
+
/** Serving-endpoint name for query embeddings (required for `queryType: 'vector'`). */
|
|
101
|
+
embeddingEndpoint?: string;
|
|
102
|
+
/** Override the search tool name (default `search`). */
|
|
103
|
+
searchToolName?: string;
|
|
104
|
+
};
|
|
105
|
+
/** Add the governed `ai_query` tool (in-warehouse model inference). Requires `warehouseId`. */
|
|
106
|
+
aiFunctions?: boolean;
|
|
107
|
+
/** Add the governed Genie tool for natural-language analytics over a Genie space. */
|
|
108
|
+
genie?: {
|
|
109
|
+
spaceId: string;
|
|
110
|
+
};
|
|
111
|
+
/** Add governed Lakeflow pipeline tools (list/status read; start/stop execute). */
|
|
112
|
+
lakeflow?: boolean;
|
|
113
|
+
/** Add the System-Tables consumption tool + expose `bundle.consumption`. Requires `warehouseId`. */
|
|
114
|
+
consumption?: boolean;
|
|
115
|
+
/** Add a governed low-latency feature-lookup tool against a Feature Serving endpoint. */
|
|
116
|
+
featureServing?: {
|
|
117
|
+
endpoint: string;
|
|
118
|
+
};
|
|
5
119
|
fetchImpl?: typeof fetch;
|
|
6
120
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
121
|
+
export interface DatabricksBundle {
|
|
122
|
+
/** Rotating token provider shared by the model provider, REST client, and Lakebase client. */
|
|
123
|
+
identity: DatabricksTokenProvider;
|
|
124
|
+
modelProvider: ModelProvider;
|
|
125
|
+
client: DatabricksRestClient;
|
|
126
|
+
/** Governed Databricks tools (lineage-stamped, catalog-allowlisted). */
|
|
127
|
+
tools: ToolDef[];
|
|
128
|
+
/** Approval routing + egress allowlist for the tool set. Merge into the agent's policy. */
|
|
129
|
+
policy: CapabilityPolicy;
|
|
130
|
+
lakebase?: LakebaseClient;
|
|
131
|
+
store?: SessionStore;
|
|
132
|
+
/** Mount Databricks workspace files as a read-only context source. */
|
|
133
|
+
workspaceSource: (rootPath: string, options?: DatabricksWorkspaceSourceOptions) => FilesystemSource;
|
|
134
|
+
/** Vector Search retriever, when `vectorSearch` is configured. */
|
|
135
|
+
retriever?: Retriever;
|
|
136
|
+
/** Query-embedding provider, when `vectorSearch.embeddingEndpoint` is configured. */
|
|
137
|
+
embeddings?: EmbeddingProvider;
|
|
138
|
+
/** System-Tables consumption reporter, when `consumption` is enabled (needs `warehouseId`). */
|
|
139
|
+
consumption?: DatabricksConsumption;
|
|
15
140
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export declare function
|
|
23
|
-
export interface DatabricksSqlToolOptions {
|
|
24
|
-
warehouseId: string;
|
|
25
|
-
name?: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
waitTimeout?: string;
|
|
28
|
-
disposition?: 'INLINE' | 'EXTERNAL_LINKS';
|
|
29
|
-
}
|
|
30
|
-
export declare function databricksSqlTool(client: DatabricksRestClient, options: DatabricksSqlToolOptions): ToolDef<{
|
|
31
|
-
statement: string;
|
|
32
|
-
catalog?: string;
|
|
33
|
-
schema?: string;
|
|
34
|
-
}, unknown>;
|
|
35
|
-
export declare function databricksRunJobTool(client: DatabricksRestClient, options?: {
|
|
36
|
-
name?: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
}): ToolDef<{
|
|
39
|
-
jobId: number;
|
|
40
|
-
notebookParams?: JsonObject;
|
|
41
|
-
pythonParams?: string[];
|
|
42
|
-
jarParams?: string[];
|
|
43
|
-
}, unknown>;
|
|
44
|
-
export declare function databricksNotebookTool(client: DatabricksRestClient, options?: {
|
|
45
|
-
name?: string;
|
|
46
|
-
description?: string;
|
|
47
|
-
existingClusterId?: string;
|
|
48
|
-
}): ToolDef<{
|
|
49
|
-
notebookPath: string;
|
|
50
|
-
baseParameters?: JsonObject;
|
|
51
|
-
runName?: string;
|
|
52
|
-
}, unknown>;
|
|
53
|
-
export declare function databricksMlflowLogMetricTool(client: DatabricksRestClient, options?: {
|
|
54
|
-
name?: string;
|
|
55
|
-
description?: string;
|
|
56
|
-
}): ToolDef<{
|
|
57
|
-
runId: string;
|
|
58
|
-
key: string;
|
|
59
|
-
value: number;
|
|
60
|
-
step?: number;
|
|
61
|
-
timestamp?: number;
|
|
62
|
-
}, unknown>;
|
|
63
|
-
export declare function databricksMlflowLogParamTool(client: DatabricksRestClient, options?: {
|
|
64
|
-
name?: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
}): ToolDef<{
|
|
67
|
-
runId: string;
|
|
68
|
-
key: string;
|
|
69
|
-
value: string;
|
|
70
|
-
}, unknown>;
|
|
71
|
-
export declare function unityCatalogTablesTool(client: DatabricksRestClient, options?: {
|
|
72
|
-
name?: string;
|
|
73
|
-
description?: string;
|
|
74
|
-
}): ToolDef<{
|
|
75
|
-
catalog: string;
|
|
76
|
-
schema: string;
|
|
77
|
-
}, unknown>;
|
|
78
|
-
export interface DatabricksWorkspaceSourceOptions {
|
|
79
|
-
name?: string;
|
|
80
|
-
include?: (path: string) => boolean;
|
|
81
|
-
recursive?: boolean;
|
|
82
|
-
format?: 'SOURCE' | 'HTML' | 'JUPYTER' | 'DBC';
|
|
83
|
-
}
|
|
84
|
-
export declare function databricksWorkspaceSource(client: DatabricksRestClient, rootPath: string, options?: DatabricksWorkspaceSourceOptions): FilesystemSource;
|
|
141
|
+
/**
|
|
142
|
+
* One-call wiring for a Databricks-native agent: model serving, a UC principal threaded through
|
|
143
|
+
* model + data + state, governed tools, an approval/egress policy, and (optionally) Lakebase-backed
|
|
144
|
+
* durable state. Also registers `databricks/*` + `mosaic-ai/*` model refs. Everything is layered on
|
|
145
|
+
* Unity Catalog — never a replacement for it.
|
|
146
|
+
*/
|
|
147
|
+
export declare function databricks(config: DatabricksBundleConfig): DatabricksBundle;
|
|
85
148
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAElJ,OAAO,EAAE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|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { createSearchTool } from '@fabric-harness/sdk';
|
|
2
|
+
import { DatabricksRestClient } from './client.js';
|
|
3
|
+
import { databricksSqlTool, databricksTableInfoTool, databricksWorkspaceSource, unityCatalogTablesTool } from './tools.js';
|
|
4
|
+
import { databricksIdentity } from './identity.js';
|
|
5
|
+
import { databricksFoundationModelProvider, registerDatabricksModelProvider } from './model.js';
|
|
6
|
+
import { databricksGovernancePolicy, withGovernanceTools } from './governance.js';
|
|
7
|
+
import { lakebaseClient } from './lakebase.js';
|
|
8
|
+
import { databricksEmbeddings } from './embeddings.js';
|
|
9
|
+
import { databricksVectorSearch } from './vector-search.js';
|
|
10
|
+
import { databricksAiQueryTool } from './ai.js';
|
|
11
|
+
import { databricksGenieTool } from './genie.js';
|
|
12
|
+
import { databricksLakeflowTools } from './lakeflow.js';
|
|
13
|
+
import { databricksConsumption, databricksConsumptionTool } from './consumption.js';
|
|
14
|
+
import { databricksFeatureLookupTool } from './feature-serving.js';
|
|
15
|
+
import { databricksActualCostSource, databricksTenantCostLimit } from './cost-budget-actuals.js';
|
|
16
|
+
// REST client + wait helpers (client.ts) and tool factories + workspace source (tools.ts).
|
|
17
|
+
export { DatabricksRestClient, createDatabricksClient, waitForDatabricksRun, waitForDatabricksStatement } from './client.js';
|
|
18
|
+
export { databricksSqlTool, databricksRunJobTool, databricksNotebookTool, databricksMlflowLogMetricTool, databricksMlflowLogParamTool, unityCatalogTablesTool, databricksTableInfoTool, databricksWorkspaceSource } from './tools.js';
|
|
19
|
+
export { databricksFoundationModelProvider, registerDatabricksModelProvider } from './model.js';
|
|
20
|
+
export { appServicePrincipalFromEnv, databricksIdentity, fabricPrincipalFor, onBehalfOfFromHeaders } from './identity.js';
|
|
21
|
+
export { withGovernance, withGovernanceTools, databricksApprovalRules, databricksGovernancePolicy } from './governance.js';
|
|
22
|
+
export { lakebaseClient } from './lakebase.js';
|
|
23
|
+
export { databricksPersistence } from './persistence.js';
|
|
24
|
+
export { databricksTelemetry, ensureDatabricksTelemetryTables } from './telemetry-sink.js';
|
|
25
|
+
export { databricksApp } from './app.js';
|
|
26
|
+
export { UcVolumesAttachmentStore } from './volumes-attachment-store.js';
|
|
27
|
+
export { buildMlflowTrace, mlflowTraceExporter } from './mlflow-tracing.js';
|
|
28
|
+
export { inferenceTableUsageQuery, servingUsageCapture } from './serving-usage.js';
|
|
29
|
+
export { databricksEmbeddings } from './embeddings.js';
|
|
30
|
+
export { databricksVectorSearch } from './vector-search.js';
|
|
31
|
+
export { databricksAiQueryTool } from './ai.js';
|
|
32
|
+
export { databricksGenieTool } from './genie.js';
|
|
33
|
+
export { databricksLakeflowTools, databricksPipelineListTool, databricksPipelineStatusTool, databricksPipelineStartTool, databricksPipelineStopTool } from './lakeflow.js';
|
|
34
|
+
export { databricksConsumption, databricksConsumptionTool } from './consumption.js';
|
|
35
|
+
export { databricksActualCostSource, databricksTenantCostLimit } from './cost-budget-actuals.js';
|
|
36
|
+
export { databricksFeatureLookupTool } from './feature-serving.js';
|
|
37
|
+
export { databricksAgent, defineDatabricksAgent, resolveToolRefs } from './agent.js';
|
|
38
|
+
export { MockDatabricksModelProvider } from './mock-provider.js';
|
|
39
|
+
/**
|
|
40
|
+
* One-call wiring for a Databricks-native agent: model serving, a UC principal threaded through
|
|
41
|
+
* model + data + state, governed tools, an approval/egress policy, and (optionally) Lakebase-backed
|
|
42
|
+
* durable state. Also registers `databricks/*` + `mosaic-ai/*` model refs. Everything is layered on
|
|
43
|
+
* Unity Catalog — never a replacement for it.
|
|
44
|
+
*/
|
|
45
|
+
export function databricks(config) {
|
|
46
|
+
registerDatabricksModelProvider();
|
|
47
|
+
const identity = databricksIdentity(config.principal);
|
|
48
|
+
const client = new DatabricksRestClient({ host: config.host, token: identity, ...(config.fetchImpl ? { fetchImpl: config.fetchImpl } : {}) });
|
|
49
|
+
let embeddings;
|
|
50
|
+
let retriever;
|
|
51
|
+
let searchTool;
|
|
52
|
+
if (config.vectorSearch) {
|
|
53
|
+
if (config.vectorSearch.embeddingEndpoint)
|
|
54
|
+
embeddings = databricksEmbeddings({ client, endpoint: config.vectorSearch.embeddingEndpoint });
|
|
55
|
+
retriever = databricksVectorSearch({
|
|
56
|
+
client,
|
|
57
|
+
index: config.vectorSearch.index,
|
|
58
|
+
textColumn: config.vectorSearch.textColumn,
|
|
59
|
+
...(config.vectorSearch.columns ? { columns: config.vectorSearch.columns } : {}),
|
|
60
|
+
...(config.vectorSearch.idColumn ? { idColumn: config.vectorSearch.idColumn } : {}),
|
|
61
|
+
...(config.vectorSearch.queryType ? { queryType: config.vectorSearch.queryType } : {}),
|
|
62
|
+
...(embeddings ? { embeddings } : {}),
|
|
63
|
+
});
|
|
64
|
+
searchTool = createSearchTool(retriever, {
|
|
65
|
+
...(config.vectorSearch.searchToolName ? { name: config.vectorSearch.searchToolName } : {}),
|
|
66
|
+
metadata: { provider: 'databricks', service: 'vector-search' },
|
|
30
67
|
});
|
|
31
|
-
if (!response.ok) {
|
|
32
|
-
const text = redactText(await response.text(), { additionalSecrets: [token] });
|
|
33
|
-
throw new Error(`databricks: ${response.status} ${response.statusText}: ${text.slice(0, 500)}`);
|
|
34
|
-
}
|
|
35
|
-
if (response.status === 204)
|
|
36
|
-
return undefined;
|
|
37
|
-
return await response.json();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export function createDatabricksClient(options) {
|
|
41
|
-
return new DatabricksRestClient(options);
|
|
42
|
-
}
|
|
43
|
-
export async function waitForDatabricksRun(client, runId, options = {}) {
|
|
44
|
-
const deadline = Date.now() + (options.timeoutMs ?? 600_000);
|
|
45
|
-
const interval = options.pollIntervalMs ?? 5_000;
|
|
46
|
-
let current = await client.get('/api/2.1/jobs/runs/get', { run_id: runId });
|
|
47
|
-
while (!isTerminalDatabricksRunState(current) && Date.now() < deadline) {
|
|
48
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
49
|
-
current = await client.get('/api/2.1/jobs/runs/get', { run_id: runId });
|
|
50
|
-
}
|
|
51
|
-
return current;
|
|
52
|
-
}
|
|
53
|
-
export async function waitForDatabricksStatement(client, statementId, options = {}) {
|
|
54
|
-
const deadline = Date.now() + (options.timeoutMs ?? 300_000);
|
|
55
|
-
const interval = options.pollIntervalMs ?? 2_000;
|
|
56
|
-
let current = await client.get(`/api/2.0/sql/statements/${encodeURIComponent(statementId)}`);
|
|
57
|
-
while (!isTerminalDatabricksStatementState(current) && Date.now() < deadline) {
|
|
58
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
59
|
-
current = await client.get(`/api/2.0/sql/statements/${encodeURIComponent(statementId)}`);
|
|
60
68
|
}
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
const rawTools = [
|
|
70
|
+
...(config.warehouseId ? [databricksSqlTool(client, { warehouseId: config.warehouseId })] : []),
|
|
71
|
+
unityCatalogTablesTool(client),
|
|
72
|
+
databricksTableInfoTool(client),
|
|
73
|
+
...(searchTool ? [searchTool] : []),
|
|
74
|
+
...(config.aiFunctions && config.warehouseId ? [databricksAiQueryTool(client, { warehouseId: config.warehouseId })] : []),
|
|
75
|
+
...(config.genie ? [databricksGenieTool(client, { spaceId: config.genie.spaceId })] : []),
|
|
76
|
+
...(config.lakeflow ? databricksLakeflowTools(client) : []),
|
|
77
|
+
...(config.consumption && config.warehouseId ? [databricksConsumptionTool(client, { warehouseId: config.warehouseId })] : []),
|
|
78
|
+
...(config.featureServing ? [databricksFeatureLookupTool(client, { endpoint: config.featureServing.endpoint })] : []),
|
|
79
|
+
...(config.tools ?? []),
|
|
80
|
+
];
|
|
81
|
+
const tools = withGovernanceTools(rawTools, {
|
|
82
|
+
principal: config.governance?.principalLabel ?? principalLabel(config.principal),
|
|
83
|
+
...(config.governance?.onLineage ? { onLineage: config.governance.onLineage } : {}),
|
|
84
|
+
...(config.governance?.catalogs ? { catalogs: config.governance.catalogs } : {}),
|
|
85
|
+
});
|
|
86
|
+
const policy = databricksGovernancePolicy({
|
|
87
|
+
tools,
|
|
88
|
+
host: config.host,
|
|
89
|
+
...(config.governance?.stewardAudience ? { stewardAudience: config.governance.stewardAudience } : {}),
|
|
90
|
+
...(config.governance?.approvalServices ? { approvalServices: config.governance.approvalServices } : {}),
|
|
91
|
+
...(config.governance?.approvalTtlSeconds !== undefined ? { ttlSeconds: config.governance.approvalTtlSeconds } : {}),
|
|
92
|
+
});
|
|
93
|
+
const bundle = {
|
|
94
|
+
identity,
|
|
95
|
+
modelProvider: databricksFoundationModelProvider({ host: config.host, token: identity, ...(config.model ? { defaultModel: config.model } : {}) }),
|
|
96
|
+
client,
|
|
97
|
+
tools,
|
|
98
|
+
policy,
|
|
99
|
+
workspaceSource: (rootPath, options) => databricksWorkspaceSource(client, rootPath, options ?? {}),
|
|
100
|
+
...(retriever ? { retriever } : {}),
|
|
101
|
+
...(embeddings ? { embeddings } : {}),
|
|
102
|
+
...(config.consumption && config.warehouseId ? { consumption: databricksConsumption(client, { warehouseId: config.warehouseId }) } : {}),
|
|
86
103
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
inputSchema: {
|
|
93
|
-
type: 'object',
|
|
94
|
-
additionalProperties: false,
|
|
95
|
-
properties: {
|
|
96
|
-
jobId: { type: 'number' },
|
|
97
|
-
notebookParams: { type: 'object', additionalProperties: true },
|
|
98
|
-
pythonParams: { type: 'array', items: { type: 'string' } },
|
|
99
|
-
jarParams: { type: 'array', items: { type: 'string' } },
|
|
100
|
-
},
|
|
101
|
-
required: ['jobId'],
|
|
102
|
-
},
|
|
103
|
-
metadata: { effect: 'execute', provider: 'databricks', service: 'jobs' },
|
|
104
|
-
execute: (input) => client.post('/api/2.1/jobs/run-now', {
|
|
105
|
-
job_id: input.jobId,
|
|
106
|
-
...(input.notebookParams ? { notebook_params: input.notebookParams } : {}),
|
|
107
|
-
...(input.pythonParams ? { python_params: input.pythonParams } : {}),
|
|
108
|
-
...(input.jarParams ? { jar_params: input.jarParams } : {}),
|
|
109
|
-
}),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
export function databricksNotebookTool(client, options = {}) {
|
|
113
|
-
return {
|
|
114
|
-
name: options.name ?? 'databricks_run_notebook',
|
|
115
|
-
description: options.description ?? 'Submit a one-off Databricks notebook run.',
|
|
116
|
-
inputSchema: {
|
|
117
|
-
type: 'object',
|
|
118
|
-
additionalProperties: false,
|
|
119
|
-
properties: {
|
|
120
|
-
notebookPath: { type: 'string' },
|
|
121
|
-
baseParameters: { type: 'object', additionalProperties: true },
|
|
122
|
-
runName: { type: 'string' },
|
|
123
|
-
},
|
|
124
|
-
required: ['notebookPath'],
|
|
125
|
-
},
|
|
126
|
-
metadata: { effect: 'execute', provider: 'databricks', service: 'jobs' },
|
|
127
|
-
execute: (input) => client.post('/api/2.1/jobs/runs/submit', {
|
|
128
|
-
run_name: input.runName ?? `fabric-harness:${input.notebookPath}`,
|
|
129
|
-
...(options.existingClusterId ? { existing_cluster_id: options.existingClusterId } : {}),
|
|
130
|
-
notebook_task: {
|
|
131
|
-
notebook_path: input.notebookPath,
|
|
132
|
-
...(input.baseParameters ? { base_parameters: input.baseParameters } : {}),
|
|
133
|
-
},
|
|
134
|
-
}),
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
export function databricksMlflowLogMetricTool(client, options = {}) {
|
|
138
|
-
return {
|
|
139
|
-
name: options.name ?? 'databricks_mlflow_log_metric',
|
|
140
|
-
description: options.description ?? 'Log a metric to an MLflow run hosted in Databricks.',
|
|
141
|
-
inputSchema: {
|
|
142
|
-
type: 'object',
|
|
143
|
-
additionalProperties: false,
|
|
144
|
-
properties: {
|
|
145
|
-
runId: { type: 'string' },
|
|
146
|
-
key: { type: 'string' },
|
|
147
|
-
value: { type: 'number' },
|
|
148
|
-
step: { type: 'number' },
|
|
149
|
-
timestamp: { type: 'number' },
|
|
150
|
-
},
|
|
151
|
-
required: ['runId', 'key', 'value'],
|
|
152
|
-
},
|
|
153
|
-
metadata: { effect: 'write', provider: 'databricks', service: 'mlflow' },
|
|
154
|
-
execute: (input) => client.post('/api/2.0/mlflow/runs/log-metric', {
|
|
155
|
-
run_id: input.runId,
|
|
156
|
-
key: input.key,
|
|
157
|
-
value: input.value,
|
|
158
|
-
timestamp: input.timestamp ?? Date.now(),
|
|
159
|
-
...(input.step !== undefined ? { step: input.step } : {}),
|
|
160
|
-
}),
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
export function databricksMlflowLogParamTool(client, options = {}) {
|
|
164
|
-
return {
|
|
165
|
-
name: options.name ?? 'databricks_mlflow_log_param',
|
|
166
|
-
description: options.description ?? 'Log a parameter to an MLflow run hosted in Databricks.',
|
|
167
|
-
inputSchema: {
|
|
168
|
-
type: 'object',
|
|
169
|
-
additionalProperties: false,
|
|
170
|
-
properties: { runId: { type: 'string' }, key: { type: 'string' }, value: { type: 'string' } },
|
|
171
|
-
required: ['runId', 'key', 'value'],
|
|
172
|
-
},
|
|
173
|
-
metadata: { effect: 'write', provider: 'databricks', service: 'mlflow' },
|
|
174
|
-
execute: (input) => client.post('/api/2.0/mlflow/runs/log-parameter', { run_id: input.runId, key: input.key, value: input.value }),
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
export function unityCatalogTablesTool(client, options = {}) {
|
|
178
|
-
return {
|
|
179
|
-
name: options.name ?? 'databricks_unity_catalog_tables',
|
|
180
|
-
description: options.description ?? 'List Unity Catalog tables in a catalog and schema.',
|
|
181
|
-
inputSchema: {
|
|
182
|
-
type: 'object',
|
|
183
|
-
additionalProperties: false,
|
|
184
|
-
properties: { catalog: { type: 'string' }, schema: { type: 'string' } },
|
|
185
|
-
required: ['catalog', 'schema'],
|
|
186
|
-
},
|
|
187
|
-
metadata: { effect: 'read', provider: 'databricks', service: 'unity-catalog' },
|
|
188
|
-
execute: (input) => client.get('/api/2.1/unity-catalog/tables', { catalog_name: input.catalog, schema_name: input.schema }),
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
export function databricksWorkspaceSource(client, rootPath, options = {}) {
|
|
192
|
-
const include = options.include ?? (() => true);
|
|
193
|
-
return {
|
|
194
|
-
name: options.name ?? `databricks-workspace:${rootPath}`,
|
|
195
|
-
async *entries() {
|
|
196
|
-
yield* walkWorkspace(client, rootPath, rootPath, include, options.recursive ?? true, options.format ?? 'SOURCE');
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
async function* walkWorkspace(client, root, current, include, recursive, format) {
|
|
201
|
-
const listing = await client.get('/api/2.0/workspace/list', { path: current });
|
|
202
|
-
for (const object of listing.objects ?? []) {
|
|
203
|
-
if (object.object_type === 'DIRECTORY') {
|
|
204
|
-
if (recursive)
|
|
205
|
-
yield* walkWorkspace(client, root, object.path, include, recursive, format);
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
const relative = object.path.slice(root.length).replace(/^\/+/, '');
|
|
209
|
-
if (!relative || !include(relative))
|
|
210
|
-
continue;
|
|
211
|
-
const exported = await client.get('/api/2.0/workspace/export', { path: object.path, format });
|
|
212
|
-
yield { path: relative, content: exported.content ? base64ToBytes(exported.content) : new Uint8Array() };
|
|
104
|
+
if (config.lakebase) {
|
|
105
|
+
const lakebase = lakebaseClient({ ...config.lakebase, token: identity });
|
|
106
|
+
bundle.lakebase = lakebase;
|
|
107
|
+
if (config.sessionStoreFactory)
|
|
108
|
+
bundle.store = config.sessionStoreFactory(lakebase);
|
|
213
109
|
}
|
|
110
|
+
return bundle;
|
|
214
111
|
}
|
|
215
|
-
function
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
function isTerminalDatabricksStatementState(statement) {
|
|
221
|
-
const status = statement.status;
|
|
222
|
-
const state = status?.state;
|
|
223
|
-
return state === 'SUCCEEDED' || state === 'FAILED' || state === 'CANCELED' || state === 'CLOSED';
|
|
224
|
-
}
|
|
225
|
-
function base64ToBytes(value) {
|
|
226
|
-
if (typeof Buffer !== 'undefined')
|
|
227
|
-
return new Uint8Array(Buffer.from(value, 'base64'));
|
|
228
|
-
const binary = atob(value);
|
|
229
|
-
const bytes = new Uint8Array(binary.length);
|
|
230
|
-
for (let i = 0; i < binary.length; i += 1)
|
|
231
|
-
bytes[i] = binary.charCodeAt(i);
|
|
232
|
-
return bytes;
|
|
112
|
+
function principalLabel(principal) {
|
|
113
|
+
if (principal.kind === 'service-principal')
|
|
114
|
+
return `sp:${principal.clientId}`;
|
|
115
|
+
// pat / on-behalf-of: prefer an explicit label (e.g. the channel actor / user id) over the bare kind.
|
|
116
|
+
return principal.label ?? principal.kind;
|
|
233
117
|
}
|
|
234
118
|
//# sourceMappingURL=index.js.map
|