@databricks/ai-sdk-provider 0.2.3 → 0.4.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/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
- import { LanguageModelV2, ProviderV2 } from "@ai-sdk/provider";
1
+ import { LanguageModelV3, ProviderV3 } from "@ai-sdk/provider";
2
2
  import { FetchFunction } from "@ai-sdk/provider-utils";
3
- import { z } from "zod/v4";
4
3
 
5
4
  //#region src/databricks-provider.d.ts
6
5
  type DatabricksLanguageModelConfig = {
@@ -10,13 +9,22 @@ type DatabricksLanguageModelConfig = {
10
9
  path: string;
11
10
  }) => string;
12
11
  fetch?: FetchFunction;
12
+ /**
13
+ * When true, marks all tool calls as dynamic and provider-executed.
14
+ * This indicates that tool execution is handled remotely by Databricks agents.
15
+ * Defaults to true.
16
+ */
17
+ useRemoteToolCalling?: boolean;
13
18
  };
14
- interface DatabricksProvider extends ProviderV2 {
19
+ interface DatabricksProvider extends ProviderV3 {
15
20
  /** Agents */
16
- chatAgent(modelId: string): LanguageModelV2;
17
- responses(modelId: string): LanguageModelV2;
21
+ chatAgent(modelId: string): LanguageModelV3;
22
+ responses(modelId: string): LanguageModelV3;
18
23
  /** Foundation Models */
19
- chatCompletions(modelId: string): LanguageModelV2;
24
+ chatCompletions(modelId: string): LanguageModelV3;
25
+ /** Required overrides from ProviderV3 */
26
+ textEmbeddingModel(modelId: string): never;
27
+ languageModel(modelId: string): never;
20
28
  }
21
29
  interface DatabricksProviderSettings {
22
30
  /** Base URL for the Databricks API calls. */
@@ -37,145 +45,14 @@ interface DatabricksProviderSettings {
37
45
  baseUrl?: string;
38
46
  path: string;
39
47
  }) => string;
48
+ /**
49
+ * When true, marks all tool calls as dynamic and provider-executed.
50
+ * This indicates that tool execution is handled remotely by Databricks agents.
51
+ * Defaults to true.
52
+ */
53
+ useRemoteToolCalling?: boolean;
40
54
  }
41
- declare const createDatabricksProvider: (settings: DatabricksProviderSettings) => DatabricksProvider; //#endregion
42
- //#region src/tools.d.ts
43
-
44
- //# sourceMappingURL=databricks-provider.d.ts.map
45
- declare const DATABRICKS_TOOL_CALL_ID = "databricks-tool-call";
46
- /**
47
- * The AI-SDK requires that tools used by the model are defined ahead of time.
48
- *
49
- * Since tool calls can be orchestrated by Databricks' agents we don't know the name, input, or output schemas
50
- * of the tools until the model is called.
51
- *
52
- * In the DatabricksProvider we transform all tool calls to fit this definition, and keep the
53
- * original name as part of the metadata. This allows us to parse any tool orchestrated by Databricks' agents,
54
- * while still being able to render the tool call and result in the UI, and pass it back to the model with the correct name.
55
- */
56
- declare const DATABRICKS_TOOL_DEFINITION: {
57
- name: string;
58
- description: string;
59
- inputSchema: z.ZodAny;
60
- outputSchema: z.ZodAny;
61
- };
62
-
63
- //#endregion
64
- //#region src/mcp.d.ts
65
- //# sourceMappingURL=tools.d.ts.map
66
- /**
67
- * MCP Approval Utility Functions
68
- *
69
- * Shared utilities for handling MCP (Model Context Protocol) approval requests
70
- * and responses across client and server code.
71
- */
72
- /** Key used in tool output to indicate approval status */
73
- declare const MCP_APPROVAL_STATUS_KEY = "__approvalStatus__";
74
- /** Type string for MCP approval requests in provider metadata */
75
- declare const MCP_APPROVAL_REQUEST_TYPE = "mcp_approval_request";
76
- /** Type string for MCP approval responses in provider metadata */
77
- declare const MCP_APPROVAL_RESPONSE_TYPE = "mcp_approval_response";
78
- /** Approval status output object shape */
79
- type ApprovalStatusOutput = {
80
- [MCP_APPROVAL_STATUS_KEY]: boolean;
81
- };
82
- /** State of an MCP approval request */
83
- type McpApprovalState = 'awaiting-approval' | 'approved' | 'denied';
84
- /** Databricks-specific metadata attached to tool calls */
85
- interface DatabricksToolMetadata {
86
- type?: string;
87
- toolName?: string;
88
- itemId?: string;
89
- serverLabel?: string;
90
- mcpServerName?: string;
91
- approvalRequestId?: string;
92
- approve?: boolean;
93
- reason?: string;
94
- }
95
- /**
96
- * Check if output contains an approval status marker.
97
- *
98
- * @example
99
- * if (isApprovalStatusOutput(output)) {
100
- * console.log(output.__approvalStatus__); // TypeScript knows this is boolean
101
- * }
102
- */
103
- declare function isApprovalStatusOutput(output: unknown): output is ApprovalStatusOutput;
104
- /**
105
- * Check if provider metadata indicates an MCP approval request.
106
- *
107
- * @example
108
- * const metadata = extractDatabricksMetadata(part);
109
- * if (isMcpApprovalRequest(metadata)) {
110
- * // Handle MCP approval request
111
- * }
112
- */
113
- declare function isMcpApprovalRequest(metadata: DatabricksToolMetadata | Record<string, unknown> | undefined): boolean;
114
- /**
115
- * Check if provider metadata indicates an MCP approval response.
116
- */
117
- declare function isMcpApprovalResponse(metadata: DatabricksToolMetadata | Record<string, unknown> | undefined): boolean;
118
- /**
119
- * Extract Databricks metadata from a tool call part's callProviderMetadata.
120
- *
121
- * @example
122
- * const metadata = extractDatabricksMetadata(part);
123
- * const toolName = metadata?.toolName;
124
- * const isMcp = isMcpApprovalRequest(metadata);
125
- */
126
- declare function extractDatabricksMetadata(part: {
127
- callProviderMetadata?: Record<string, unknown>;
128
- }): DatabricksToolMetadata | undefined;
129
- /**
130
- * Extract the approval status boolean from an output object.
131
- *
132
- * @returns `true` if approved, `false` if denied, `undefined` if not an approval output
133
- *
134
- * @example
135
- * const status = extractApprovalStatus(output);
136
- * if (status !== undefined) {
137
- * console.log(status ? 'Approved' : 'Denied');
138
- * }
139
- */
140
- declare function extractApprovalStatus(output: unknown): boolean | undefined;
141
- /**
142
- * Extract approval status from a tool result's output value.
143
- * Handles the nested structure where output.type === 'json' and value contains the status.
144
- *
145
- * @example
146
- * const status = extractApprovalStatusFromToolResult(toolResult.output);
147
- */
148
- declare function extractApprovalStatusFromToolResult(output: {
149
- type: string;
150
- value?: unknown;
151
- }): boolean | undefined;
152
- /**
153
- * Create an approval status output object.
154
- *
155
- * @example
156
- * await addToolResult({
157
- * toolCallId,
158
- * output: createApprovalStatusOutput(true), // Approve
159
- * });
160
- */
161
- declare function createApprovalStatusOutput(approve: boolean): ApprovalStatusOutput;
162
- /**
163
- * Determine the MCP approval state from a tool output.
164
- *
165
- * Logic:
166
- * - No output → 'awaiting-approval' (user hasn't responded yet)
167
- * - Output with __approvalStatus__: true → 'approved'
168
- * - Output with __approvalStatus__: false → 'denied'
169
- * - Output without __approvalStatus__ → 'approved' (tool executed, so it was approved)
170
- *
171
- * @example
172
- * const approvalState = getMcpApprovalState(part.output);
173
- * // 'awaiting-approval' | 'approved' | 'denied'
174
- */
175
- declare function getMcpApprovalState(output: unknown): McpApprovalState;
176
-
55
+ declare const createDatabricksProvider: (settings: DatabricksProviderSettings) => DatabricksProvider;
177
56
  //#endregion
178
- //# sourceMappingURL=mcp.d.ts.map
179
-
180
- export { ApprovalStatusOutput, DATABRICKS_TOOL_CALL_ID, DATABRICKS_TOOL_DEFINITION, DatabricksLanguageModelConfig, DatabricksProvider, DatabricksProviderSettings, DatabricksToolMetadata, MCP_APPROVAL_REQUEST_TYPE, MCP_APPROVAL_RESPONSE_TYPE, MCP_APPROVAL_STATUS_KEY, McpApprovalState, createApprovalStatusOutput, createDatabricksProvider, extractApprovalStatus, extractApprovalStatusFromToolResult, extractDatabricksMetadata, getMcpApprovalState, isApprovalStatusOutput, isMcpApprovalRequest, isMcpApprovalResponse };
57
+ export { DatabricksLanguageModelConfig, DatabricksProvider, DatabricksProviderSettings, createDatabricksProvider };
181
58
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/databricks-provider.ts","../src/tools.ts","../src/mcp.ts"],"sourcesContent":null,"mappings":";;;;;KAMY,6BAAA;;iBAEK;EAFL,GAAA,EAAA,CAAA,OAAA,EAAA;IAA6B,IAAA,EAAA,MAAA;EAAA,CAAA,EAExB,GAAA,MAAA;EAAM,KAEb,CAAA,EAAA,aAAA;AAAa,CAAA;AAGN,UAAA,kBAAA,SAA2B,UAAR,CAAA;EAAA;EAAA,SAEN,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,eAAA;EAAe,SACf,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B,CAAA,CAAA,EA8EI,sBA9EQ,GAAoB,SAC7B;;AAIH;;AAGA;;;;;;;;iBAwFgB,qBAAA;AAjEhB;;;;;;;iBA+EgB,mCAAA;;;AA7DhB,CAAA,CAAA,EAAgB,OAAA,GAAA,SAAA;;;;AAC2B;;;;AAQ3C;;AACY,iBAkFI,0BAAA,CAlFJ,OAAA,EAAA,OAAA,CAAA,EAkFkD,oBAlFlD;;AAA+B;;;;;;;;;AAiB3C;;;AAEI,iBAoFY,mBAAA,CApFZ,MAAA,EAAA,OAAA,CAAA,EAoFkD,gBApFlD;;;AAAsB"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/databricks-provider.ts"],"mappings":";;;;KAMY,6BAAA;EACV,QAAA;EACA,OAAA,QAAe,MAAA;EACf,GAAA,GAAM,OAAA;IAAW,IAAA;EAAA;EACjB,KAAA,GAAQ,aAAA;EAFR;;;;;EAQA,oBAAA;AAAA;AAAA,UAGe,kBAAA,SAA2B,UAAA;EAHtB;EAKpB,SAAA,CAAU,OAAA,WAAkB,eAAA;EAC5B,SAAA,CAAU,OAAA,WAAkB,eAAA;EAHM;EAMlC,eAAA,CAAgB,OAAA,WAAkB,eAAA;EAJN;EAO5B,kBAAA,CAAmB,OAAA;EACnB,aAAA,CAAc,OAAA;AAAA;AAAA,UAGC,0BAAA;EAbqC;EAepD,OAAA;EAbA;EAeA,OAAA,GAAU,MAAA;EAfkB;EAiB5B,QAAA;EAhBU;;;;EAsBV,KAAA,GAAQ,aAAA;EAhBR;;;EAqBA,SAAA,IAAa,OAAA;IAAW,OAAA;IAAkB,IAAA;EAAA;EAjBD;;;;;EAwBzC,oBAAA;AAAA;AAAA,cAGW,wBAAA,GACX,QAAA,EAAU,0BAAA,KACT,kBAAA"}
@@ -0,0 +1,58 @@
1
+ import { FetchFunction } from "@ai-sdk/provider-utils";
2
+ import { LanguageModelV3, ProviderV3 } from "@ai-sdk/provider";
3
+
4
+ //#region src/databricks-provider.d.ts
5
+ type DatabricksLanguageModelConfig = {
6
+ provider: string;
7
+ headers: () => Record<string, string | undefined>;
8
+ url: (options: {
9
+ path: string;
10
+ }) => string;
11
+ fetch?: FetchFunction;
12
+ /**
13
+ * When true, marks all tool calls as dynamic and provider-executed.
14
+ * This indicates that tool execution is handled remotely by Databricks agents.
15
+ * Defaults to true.
16
+ */
17
+ useRemoteToolCalling?: boolean;
18
+ };
19
+ interface DatabricksProvider extends ProviderV3 {
20
+ /** Agents */
21
+ chatAgent(modelId: string): LanguageModelV3;
22
+ responses(modelId: string): LanguageModelV3;
23
+ /** Foundation Models */
24
+ chatCompletions(modelId: string): LanguageModelV3;
25
+ /** Required overrides from ProviderV3 */
26
+ textEmbeddingModel(modelId: string): never;
27
+ languageModel(modelId: string): never;
28
+ }
29
+ interface DatabricksProviderSettings {
30
+ /** Base URL for the Databricks API calls. */
31
+ baseURL: string;
32
+ /** Custom headers to include in the requests. */
33
+ headers?: Record<string, string>;
34
+ /** Provider name. Overrides the `databricks` default name for 3rd party providers. */
35
+ provider?: string;
36
+ /**
37
+ * Custom fetch implementation. You can use it as a middleware to intercept requests,
38
+ * or to provide a custom fetch implementation for e.g. testing.
39
+ * */
40
+ fetch?: FetchFunction;
41
+ /**
42
+ * Optional function to format the URL
43
+ */
44
+ formatUrl?: (options: {
45
+ baseUrl?: string;
46
+ path: string;
47
+ }) => string;
48
+ /**
49
+ * When true, marks all tool calls as dynamic and provider-executed.
50
+ * This indicates that tool execution is handled remotely by Databricks agents.
51
+ * Defaults to true.
52
+ */
53
+ useRemoteToolCalling?: boolean;
54
+ }
55
+ declare const createDatabricksProvider: (settings: DatabricksProviderSettings) => DatabricksProvider;
56
+ //#endregion
57
+ export { DatabricksLanguageModelConfig, DatabricksProvider, DatabricksProviderSettings, createDatabricksProvider };
58
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/databricks-provider.ts"],"mappings":";;;;KAMY,6BAAA;EACV,QAAA;EACA,OAAA,QAAe,MAAA;EACf,GAAA,GAAM,OAAA;IAAW,IAAA;EAAA;EACjB,KAAA,GAAQ,aAAA;EAFR;;;;;EAQA,oBAAA;AAAA;AAAA,UAGe,kBAAA,SAA2B,UAAA;EAHtB;EAKpB,SAAA,CAAU,OAAA,WAAkB,eAAA;EAC5B,SAAA,CAAU,OAAA,WAAkB,eAAA;EAHM;EAMlC,eAAA,CAAgB,OAAA,WAAkB,eAAA;EAJN;EAO5B,kBAAA,CAAmB,OAAA;EACnB,aAAA,CAAc,OAAA;AAAA;AAAA,UAGC,0BAAA;EAbqC;EAepD,OAAA;EAbA;EAeA,OAAA,GAAU,MAAA;EAfkB;EAiB5B,QAAA;EAhBU;;;;EAsBV,KAAA,GAAQ,aAAA;EAhBR;;;EAqBA,SAAA,IAAa,OAAA;IAAW,OAAA;IAAkB,IAAA;EAAA;EAjBD;;;;;EAwBzC,oBAAA;AAAA;AAAA,cAGW,wBAAA,GACX,QAAA,EAAU,0BAAA,KACT,kBAAA"}