@databricks/appkit-ui 0.32.0 → 0.34.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/CLAUDE.md +53 -1
- package/NOTICE.md +1 -0
- package/dist/js/index.js +1 -0
- package/dist/react/hooks/index.d.ts +1 -0
- package/dist/react/hooks/index.js +1 -0
- package/dist/react/hooks/types.d.ts +11 -5
- package/dist/react/hooks/types.d.ts.map +1 -1
- package/dist/react/hooks/use-agent-chat.d.ts +128 -0
- package/dist/react/hooks/use-agent-chat.d.ts.map +1 -0
- package/dist/react/hooks/use-agent-chat.js +133 -0
- package/dist/react/hooks/use-agent-chat.js.map +1 -0
- package/dist/react/hooks/use-analytics-query.d.ts +4 -4
- package/dist/react/hooks/use-analytics-query.d.ts.map +1 -1
- package/dist/react/hooks/use-analytics-query.js +4 -4
- package/dist/react/hooks/use-analytics-query.js.map +1 -1
- package/dist/react/hooks/use-chart-data.js +9 -9
- package/dist/react/hooks/use-chart-data.js.map +1 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/shared/src/index.js +2 -0
- package/dist/shared/src/sql/helpers.d.ts +113 -8
- package/dist/shared/src/sql/helpers.d.ts.map +1 -1
- package/dist/shared/src/sql/helpers.js +116 -7
- package/dist/shared/src/sql/helpers.js.map +1 -1
- package/dist/shared/src/sql/index.js +1 -0
- package/dist/shared/src/sql/types.d.ts +16 -2
- package/dist/shared/src/sql/types.d.ts.map +1 -1
- package/docs/api/appkit/Class.AppKitMcpClient.md +157 -0
- package/docs/api/appkit/Class.DatabricksAdapter.md +151 -0
- package/docs/api/appkit/Function.agentIdFromMarkdownPath.md +18 -0
- package/docs/api/appkit/Function.createAgent.md +33 -0
- package/docs/api/appkit/Function.defineTool.md +26 -0
- package/docs/api/appkit/Function.executeFromRegistry.md +25 -0
- package/docs/api/appkit/Function.functionToolToDefinition.md +16 -0
- package/docs/api/appkit/Function.isFunctionTool.md +16 -0
- package/docs/api/appkit/Function.isHostedTool.md +16 -0
- package/docs/api/appkit/Function.isToolkitEntry.md +18 -0
- package/docs/api/appkit/Function.loadAgentFromFile.md +21 -0
- package/docs/api/appkit/Function.loadAgentsFromDir.md +26 -0
- package/docs/api/appkit/Function.mcpServer.md +28 -0
- package/docs/api/appkit/Function.parseTextToolCalls.md +26 -0
- package/docs/api/appkit/Function.resolveHostedTools.md +16 -0
- package/docs/api/appkit/Function.runAgent.md +26 -0
- package/docs/api/appkit/Function.tool.md +28 -0
- package/docs/api/appkit/Function.toolsFromRegistry.md +20 -0
- package/docs/api/appkit/Interface.AgentAdapter.md +21 -0
- package/docs/api/appkit/Interface.AgentDefinition.md +112 -0
- package/docs/api/appkit/Interface.AgentInput.md +37 -0
- package/docs/api/appkit/Interface.AgentRunContext.md +32 -0
- package/docs/api/appkit/Interface.AgentToolDefinition.md +37 -0
- package/docs/api/appkit/Interface.AgentsPluginConfig.md +241 -0
- package/docs/api/appkit/Interface.AutoInheritToolsConfig.md +27 -0
- package/docs/api/appkit/Interface.BasePluginConfig.md +1 -0
- package/docs/api/appkit/Interface.FunctionTool.md +80 -0
- package/docs/api/appkit/Interface.McpConnectAllResult.md +38 -0
- package/docs/api/appkit/Interface.Message.md +55 -0
- package/docs/api/appkit/Interface.PluginToolkitProvider.md +22 -0
- package/docs/api/appkit/Interface.PromptContext.md +30 -0
- package/docs/api/appkit/Interface.RegisteredAgent.md +75 -0
- package/docs/api/appkit/Interface.RunAgentInput.md +34 -0
- package/docs/api/appkit/Interface.RunAgentResult.md +23 -0
- package/docs/api/appkit/Interface.Thread.md +46 -0
- package/docs/api/appkit/Interface.ThreadStore.md +103 -0
- package/docs/api/appkit/Interface.ToolAnnotations.md +56 -0
- package/docs/api/appkit/Interface.ToolConfig.md +72 -0
- package/docs/api/appkit/Interface.ToolEntry.md +73 -0
- package/docs/api/appkit/Interface.ToolProvider.md +38 -0
- package/docs/api/appkit/Interface.ToolkitEntry.md +59 -0
- package/docs/api/appkit/Interface.ToolkitOptions.md +45 -0
- package/docs/api/appkit/TypeAlias.AgentEvent.md +299 -0
- package/docs/api/appkit/TypeAlias.AgentTool.md +11 -0
- package/docs/api/appkit/TypeAlias.AgentTools.md +8 -0
- package/docs/api/appkit/TypeAlias.AgentToolsFn.md +20 -0
- package/docs/api/appkit/TypeAlias.BaseSystemPromptOption.md +9 -0
- package/docs/api/appkit/TypeAlias.HostedTool.md +10 -0
- package/docs/api/appkit/TypeAlias.Plugins.md +26 -0
- package/docs/api/appkit/TypeAlias.ResolvedToolEntry.md +29 -0
- package/docs/api/appkit/TypeAlias.ToolRegistry.md +6 -0
- package/docs/api/appkit/Variable.agents.md +19 -0
- package/docs/api/appkit/Variable.sql.md +203 -21
- package/docs/api/appkit.md +113 -62
- package/docs/app-management.md +2 -2
- package/docs/plugins/agents.md +441 -0
- package/docs/plugins/analytics.md +7 -2
- package/llms.txt +53 -1
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Class: AppKitMcpClient
|
|
2
|
+
|
|
3
|
+
Lightweight MCP client for Databricks-hosted MCP servers.
|
|
4
|
+
|
|
5
|
+
Uses raw fetch() with JSON-RPC 2.0 over HTTP — no @modelcontextprotocol/sdk or LangChain dependency. Supports the Streamable HTTP transport only (POST with JSON-RPC request, single JSON-RPC response). Implements exactly four methods: `initialize`, `notifications/initialized`, `tools/list`, `tools/call`. No prompts/resources/completion/sampling.
|
|
6
|
+
|
|
7
|
+
All outbound URLs are gated by an McpHostPolicy: unallowlisted hosts are rejected before the first byte is sent, and workspace credentials are only forwarded to the same-origin workspace. See `mcp-host-policy.ts`.
|
|
8
|
+
|
|
9
|
+
Rationale for hand-rolling JSON-RPC instead of `@modelcontextprotocol/sdk`: see the file-level comment at the top of this module.
|
|
10
|
+
|
|
11
|
+
## Constructors[](#constructors "Direct link to Constructors")
|
|
12
|
+
|
|
13
|
+
### Constructor[](#constructor "Direct link to Constructor")
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
new AppKitMcpClient(
|
|
17
|
+
workspaceHost: string,
|
|
18
|
+
authenticate: () => Promise<Record<string, string>>,
|
|
19
|
+
policy: McpHostPolicy,
|
|
20
|
+
options: {
|
|
21
|
+
dnsLookup?: DnsLookup;
|
|
22
|
+
fetchImpl?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
23
|
+
}): AppKitMcpClient;
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### Parameters[](#parameters "Direct link to Parameters")
|
|
28
|
+
|
|
29
|
+
| Parameter | Type |
|
|
30
|
+
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `workspaceHost` | `string` |
|
|
32
|
+
| `authenticate` | () => `Promise`<`Record`<`string`, `string`>> |
|
|
33
|
+
| `policy` | `McpHostPolicy` |
|
|
34
|
+
| `options` | { `dnsLookup?`: `DnsLookup`; `fetchImpl?`: (`input`: `string` \| `URL` \| `Request`, `init?`: `RequestInit`) => `Promise`<`Response`>; } |
|
|
35
|
+
| `options.dnsLookup?` | `DnsLookup` |
|
|
36
|
+
| `options.fetchImpl?` | (`input`: `string` \| `URL` \| `Request`, `init?`: `RequestInit`) => `Promise`<`Response`> |
|
|
37
|
+
|
|
38
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
39
|
+
|
|
40
|
+
`AppKitMcpClient`
|
|
41
|
+
|
|
42
|
+
## Methods[](#methods "Direct link to Methods")
|
|
43
|
+
|
|
44
|
+
### callTool()[](#calltool "Direct link to callTool()")
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
callTool(
|
|
48
|
+
qualifiedName: string,
|
|
49
|
+
args: unknown,
|
|
50
|
+
authHeaders?: Record<string, string>,
|
|
51
|
+
callerSignal?: AbortSignal): Promise<string>;
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
56
|
+
|
|
57
|
+
| Parameter | Type |
|
|
58
|
+
| --------------- | ---------------------------- |
|
|
59
|
+
| `qualifiedName` | `string` |
|
|
60
|
+
| `args` | `unknown` |
|
|
61
|
+
| `authHeaders?` | `Record`<`string`, `string`> |
|
|
62
|
+
| `callerSignal?` | `AbortSignal` |
|
|
63
|
+
|
|
64
|
+
#### Returns[](#returns-1 "Direct link to Returns")
|
|
65
|
+
|
|
66
|
+
`Promise`<`string`>
|
|
67
|
+
|
|
68
|
+
***
|
|
69
|
+
|
|
70
|
+
### canForwardWorkspaceAuth()[](#canforwardworkspaceauth "Direct link to canForwardWorkspaceAuth()")
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
canForwardWorkspaceAuth(serverName: string): boolean;
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Whether the named MCP server may receive workspace-scoped auth headers (e.g., an OBO bearer token from an end-user request). Callers should gate auth-forwarding decisions on this to prevent credential exfiltration to non-workspace hosts.
|
|
78
|
+
|
|
79
|
+
#### Parameters[](#parameters-2 "Direct link to Parameters")
|
|
80
|
+
|
|
81
|
+
| Parameter | Type |
|
|
82
|
+
| ------------ | -------- |
|
|
83
|
+
| `serverName` | `string` |
|
|
84
|
+
|
|
85
|
+
#### Returns[](#returns-2 "Direct link to Returns")
|
|
86
|
+
|
|
87
|
+
`boolean`
|
|
88
|
+
|
|
89
|
+
***
|
|
90
|
+
|
|
91
|
+
### close()[](#close "Direct link to close()")
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
close(): Promise<void>;
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Returns[](#returns-3 "Direct link to Returns")
|
|
99
|
+
|
|
100
|
+
`Promise`<`void`>
|
|
101
|
+
|
|
102
|
+
***
|
|
103
|
+
|
|
104
|
+
### connect()[](#connect "Direct link to connect()")
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
connect(endpoint: McpEndpointConfig): Promise<void>;
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Parameters[](#parameters-3 "Direct link to Parameters")
|
|
112
|
+
|
|
113
|
+
| Parameter | Type |
|
|
114
|
+
| ---------- | ------------------- |
|
|
115
|
+
| `endpoint` | `McpEndpointConfig` |
|
|
116
|
+
|
|
117
|
+
#### Returns[](#returns-4 "Direct link to Returns")
|
|
118
|
+
|
|
119
|
+
`Promise`<`void`>
|
|
120
|
+
|
|
121
|
+
***
|
|
122
|
+
|
|
123
|
+
### connectAll()[](#connectall "Direct link to connectAll()")
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
connectAll(endpoints: McpEndpointConfig[]): Promise<McpConnectAllResult>;
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Connects every endpoint in parallel and returns a structured summary so callers can distinguish "all connected" from "some failed".
|
|
131
|
+
|
|
132
|
+
Returning the result instead of throwing is deliberate: one misconfigured MCP server should not take down the entire agents plugin at boot, and the agents plugin uses the summary to warn at startup with the failed-endpoint names. Errors are also logged here so a caller that ignores the return still gets per-endpoint diagnostics.
|
|
133
|
+
|
|
134
|
+
#### Parameters[](#parameters-4 "Direct link to Parameters")
|
|
135
|
+
|
|
136
|
+
| Parameter | Type |
|
|
137
|
+
| ----------- | ---------------------- |
|
|
138
|
+
| `endpoints` | `McpEndpointConfig`\[] |
|
|
139
|
+
|
|
140
|
+
#### Returns[](#returns-5 "Direct link to Returns")
|
|
141
|
+
|
|
142
|
+
`Promise`<[`McpConnectAllResult`](./docs/api/appkit/Interface.McpConnectAllResult.md)>
|
|
143
|
+
|
|
144
|
+
`connected` lists the endpoint names that initialised successfully; `failed` carries `{ name, error }` for the rest.
|
|
145
|
+
|
|
146
|
+
***
|
|
147
|
+
|
|
148
|
+
### getAllToolDefinitions()[](#getalltooldefinitions "Direct link to getAllToolDefinitions()")
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
getAllToolDefinitions(): AgentToolDefinition[];
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### Returns[](#returns-6 "Direct link to Returns")
|
|
156
|
+
|
|
157
|
+
[`AgentToolDefinition`](./docs/api/appkit/Interface.AgentToolDefinition.md)\[]
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Class: DatabricksAdapter
|
|
2
|
+
|
|
3
|
+
Adapter that talks directly to Databricks Model Serving `/invocations` endpoint.
|
|
4
|
+
|
|
5
|
+
No dependency on the Vercel AI SDK or LangChain. Uses raw `fetch()` to POST OpenAI-compatible payloads and parses the SSE stream itself. Calls `authenticate()` per-request so tokens are always fresh.
|
|
6
|
+
|
|
7
|
+
Handles both structured `tool_calls` responses and text-based tool call fallback parsing for models that output tool calls as text.
|
|
8
|
+
|
|
9
|
+
## Examples[](#examples "Direct link to Examples")
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createApp, createAgent, agents } from "@databricks/appkit";
|
|
13
|
+
import { DatabricksAdapter } from "@databricks/appkit/beta";
|
|
14
|
+
import { WorkspaceClient } from "@databricks/sdk-experimental";
|
|
15
|
+
|
|
16
|
+
const adapter = DatabricksAdapter.fromServingEndpoint({
|
|
17
|
+
workspaceClient: new WorkspaceClient({}),
|
|
18
|
+
endpointName: "my-endpoint",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await createApp({
|
|
22
|
+
plugins: [
|
|
23
|
+
agents({
|
|
24
|
+
agents: {
|
|
25
|
+
assistant: createAgent({
|
|
26
|
+
instructions: "You are a helpful assistant.",
|
|
27
|
+
model: adapter,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const adapter = new DatabricksAdapter({
|
|
38
|
+
endpointUrl: "https://host/serving-endpoints/my-endpoint/invocations",
|
|
39
|
+
authenticate: async () => ({ Authorization: `Bearer ${token}` }),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Implements[](#implements "Direct link to Implements")
|
|
45
|
+
|
|
46
|
+
* [`AgentAdapter`](./docs/api/appkit/Interface.AgentAdapter.md)
|
|
47
|
+
|
|
48
|
+
## Constructors[](#constructors "Direct link to Constructors")
|
|
49
|
+
|
|
50
|
+
### Constructor[](#constructor "Direct link to Constructor")
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
new DatabricksAdapter(options: DatabricksAdapterOptions): DatabricksAdapter;
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Parameters[](#parameters "Direct link to Parameters")
|
|
58
|
+
|
|
59
|
+
| Parameter | Type |
|
|
60
|
+
| --------- | -------------------------- |
|
|
61
|
+
| `options` | `DatabricksAdapterOptions` |
|
|
62
|
+
|
|
63
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
64
|
+
|
|
65
|
+
`DatabricksAdapter`
|
|
66
|
+
|
|
67
|
+
## Methods[](#methods "Direct link to Methods")
|
|
68
|
+
|
|
69
|
+
### run()[](#run "Direct link to run()")
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
run(input: AgentInput, context: AgentRunContext): AsyncGenerator<AgentEvent, void, unknown>;
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
77
|
+
|
|
78
|
+
| Parameter | Type |
|
|
79
|
+
| --------- | ------------------------------------------------------------------------- |
|
|
80
|
+
| `input` | [`AgentInput`](./docs/api/appkit/Interface.AgentInput.md) |
|
|
81
|
+
| `context` | [`AgentRunContext`](./docs/api/appkit/Interface.AgentRunContext.md) |
|
|
82
|
+
|
|
83
|
+
#### Returns[](#returns-1 "Direct link to Returns")
|
|
84
|
+
|
|
85
|
+
`AsyncGenerator`<[`AgentEvent`](./docs/api/appkit/TypeAlias.AgentEvent.md), `void`, `unknown`>
|
|
86
|
+
|
|
87
|
+
#### Implementation of[](#implementation-of "Direct link to Implementation of")
|
|
88
|
+
|
|
89
|
+
[`AgentAdapter`](./docs/api/appkit/Interface.AgentAdapter.md).[`run`](./docs/api/appkit/Interface.AgentAdapter.md#run)
|
|
90
|
+
|
|
91
|
+
***
|
|
92
|
+
|
|
93
|
+
### fromModelServing()[](#frommodelserving "Direct link to fromModelServing()")
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
static fromModelServing(endpointName?: string, options?: ModelServingOptions): Promise<DatabricksAdapter>;
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Creates a DatabricksAdapter from a Model Serving endpoint name. Auto-creates a WorkspaceClient internally. Reads the endpoint name from the argument or the `DATABRICKS_SERVING_ENDPOINT_NAME` env var.
|
|
101
|
+
|
|
102
|
+
#### Parameters[](#parameters-2 "Direct link to Parameters")
|
|
103
|
+
|
|
104
|
+
| Parameter | Type |
|
|
105
|
+
| --------------- | --------------------- |
|
|
106
|
+
| `endpointName?` | `string` |
|
|
107
|
+
| `options?` | `ModelServingOptions` |
|
|
108
|
+
|
|
109
|
+
#### Returns[](#returns-2 "Direct link to Returns")
|
|
110
|
+
|
|
111
|
+
`Promise`<`DatabricksAdapter`>
|
|
112
|
+
|
|
113
|
+
#### Example[](#example "Direct link to Example")
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// Reads endpoint from DATABRICKS_SERVING_ENDPOINT_NAME env var
|
|
117
|
+
const adapter = await DatabricksAdapter.fromModelServing();
|
|
118
|
+
|
|
119
|
+
// Explicit endpoint
|
|
120
|
+
const adapter = await DatabricksAdapter.fromModelServing("my-endpoint");
|
|
121
|
+
|
|
122
|
+
// With options
|
|
123
|
+
const adapter = await DatabricksAdapter.fromModelServing("my-endpoint", {
|
|
124
|
+
maxSteps: 5,
|
|
125
|
+
maxTokens: 2048,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
***
|
|
131
|
+
|
|
132
|
+
### fromServingEndpoint()[](#fromservingendpoint "Direct link to fromServingEndpoint()")
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
static fromServingEndpoint(options: ServingEndpointOptions): Promise<DatabricksAdapter>;
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Creates a DatabricksAdapter for a Databricks Model Serving endpoint.
|
|
140
|
+
|
|
141
|
+
Routes through the shared `connectors/serving/stream` helper, which delegates to the SDK's `apiClient.request({ raw: true })`. That gives the adapter centralised URL encoding + authentication with the rest of the serving surface — no bespoke `fetch()` + `authenticate()` plumbing.
|
|
142
|
+
|
|
143
|
+
#### Parameters[](#parameters-3 "Direct link to Parameters")
|
|
144
|
+
|
|
145
|
+
| Parameter | Type |
|
|
146
|
+
| --------- | ------------------------ |
|
|
147
|
+
| `options` | `ServingEndpointOptions` |
|
|
148
|
+
|
|
149
|
+
#### Returns[](#returns-3 "Direct link to Returns")
|
|
150
|
+
|
|
151
|
+
`Promise`<`DatabricksAdapter`>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Function: agentIdFromMarkdownPath()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function agentIdFromMarkdownPath(filePath: string): string;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Derives the logical agent id from a markdown path. When the file is named `agent.md`, the id is the parent directory name (folder-based layout); otherwise the id is the file stem (e.g. legacy single-file paths).
|
|
9
|
+
|
|
10
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
11
|
+
|
|
12
|
+
| Parameter | Type |
|
|
13
|
+
| ---------- | -------- |
|
|
14
|
+
| `filePath` | `string` |
|
|
15
|
+
|
|
16
|
+
## Returns[](#returns "Direct link to Returns")
|
|
17
|
+
|
|
18
|
+
`string`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Function: createAgent()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function createAgent(def: AgentDefinition): AgentDefinition;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Pure factory for agent definitions. Returns the passed-in definition after cycle-detecting the sub-agent graph. Accepts the full `AgentDefinition` shape and is safe to call at module top-level.
|
|
9
|
+
|
|
10
|
+
The returned value is a plain `AgentDefinition` — no adapter construction, no side effects. Register it with `agents({ agents: { name: def } })` or run it standalone via `runAgent(def, input)`.
|
|
11
|
+
|
|
12
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
13
|
+
|
|
14
|
+
| Parameter | Type |
|
|
15
|
+
| --------- | ------------------------------------------------------------------------- |
|
|
16
|
+
| `def` | [`AgentDefinition`](./docs/api/appkit/Interface.AgentDefinition.md) |
|
|
17
|
+
|
|
18
|
+
## Returns[](#returns "Direct link to Returns")
|
|
19
|
+
|
|
20
|
+
[`AgentDefinition`](./docs/api/appkit/Interface.AgentDefinition.md)
|
|
21
|
+
|
|
22
|
+
## Example[](#example "Direct link to Example")
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const support = createAgent({
|
|
26
|
+
instructions: "You help customers.",
|
|
27
|
+
model: "databricks-claude-sonnet-4-5",
|
|
28
|
+
tools: {
|
|
29
|
+
get_weather: tool({ ... }),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Function: defineTool()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function defineTool<S>(config: ToolEntry<S>): ToolEntry<S>;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Defines a single tool entry for a plugin's internal registry.
|
|
9
|
+
|
|
10
|
+
The generic `S` flows from `schema` through to the `handler` callback so `args` is fully typed from the Zod schema. Names are assigned by the registry key, so they are not repeated inside the entry.
|
|
11
|
+
|
|
12
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
13
|
+
|
|
14
|
+
| Type Parameter |
|
|
15
|
+
| ---------------------------------------------------------------------------------------- |
|
|
16
|
+
| `S` *extends* `ZodType`<`unknown`, `unknown`, `$ZodTypeInternals`<`unknown`, `unknown`>> |
|
|
17
|
+
|
|
18
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
19
|
+
|
|
20
|
+
| Parameter | Type |
|
|
21
|
+
| --------- | ------------------------------------------------------------------ |
|
|
22
|
+
| `config` | [`ToolEntry`](./docs/api/appkit/Interface.ToolEntry.md)<`S`> |
|
|
23
|
+
|
|
24
|
+
## Returns[](#returns "Direct link to Returns")
|
|
25
|
+
|
|
26
|
+
[`ToolEntry`](./docs/api/appkit/Interface.ToolEntry.md)<`S`>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Function: executeFromRegistry()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function executeFromRegistry(
|
|
5
|
+
registry: ToolRegistry,
|
|
6
|
+
name: string,
|
|
7
|
+
args: unknown,
|
|
8
|
+
signal?: AbortSignal): Promise<unknown>;
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Validates tool-call arguments against the entry's schema and invokes its handler. On validation failure, returns an LLM-friendly error string (matching the behavior of `tool()`) rather than throwing, so the model can self-correct on its next turn.
|
|
13
|
+
|
|
14
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
15
|
+
|
|
16
|
+
| Parameter | Type |
|
|
17
|
+
| ---------- | ------------------------------------------------------------------- |
|
|
18
|
+
| `registry` | [`ToolRegistry`](./docs/api/appkit/TypeAlias.ToolRegistry.md) |
|
|
19
|
+
| `name` | `string` |
|
|
20
|
+
| `args` | `unknown` |
|
|
21
|
+
| `signal?` | `AbortSignal` |
|
|
22
|
+
|
|
23
|
+
## Returns[](#returns "Direct link to Returns")
|
|
24
|
+
|
|
25
|
+
`Promise`<`unknown`>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Function: functionToolToDefinition()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function functionToolToDefinition(tool: FunctionTool): AgentToolDefinition;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
9
|
+
|
|
10
|
+
| Parameter | Type |
|
|
11
|
+
| --------- | ------------------------------------------------------------------- |
|
|
12
|
+
| `tool` | [`FunctionTool`](./docs/api/appkit/Interface.FunctionTool.md) |
|
|
13
|
+
|
|
14
|
+
## Returns[](#returns "Direct link to Returns")
|
|
15
|
+
|
|
16
|
+
[`AgentToolDefinition`](./docs/api/appkit/Interface.AgentToolDefinition.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Function: isFunctionTool()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function isFunctionTool(value: unknown): value is FunctionTool;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
9
|
+
|
|
10
|
+
| Parameter | Type |
|
|
11
|
+
| --------- | --------- |
|
|
12
|
+
| `value` | `unknown` |
|
|
13
|
+
|
|
14
|
+
## Returns[](#returns "Direct link to Returns")
|
|
15
|
+
|
|
16
|
+
`value is FunctionTool`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Function: isHostedTool()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function isHostedTool(value: unknown): value is HostedTool;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
9
|
+
|
|
10
|
+
| Parameter | Type |
|
|
11
|
+
| --------- | --------- |
|
|
12
|
+
| `value` | `unknown` |
|
|
13
|
+
|
|
14
|
+
## Returns[](#returns "Direct link to Returns")
|
|
15
|
+
|
|
16
|
+
`value is HostedTool`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Function: isToolkitEntry()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function isToolkitEntry(value: unknown): value is ToolkitEntry;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Type guard for `ToolkitEntry` — used by the agents plugin to differentiate toolkit references from inline tools in a mixed `tools` record.
|
|
9
|
+
|
|
10
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
11
|
+
|
|
12
|
+
| Parameter | Type |
|
|
13
|
+
| --------- | --------- |
|
|
14
|
+
| `value` | `unknown` |
|
|
15
|
+
|
|
16
|
+
## Returns[](#returns "Direct link to Returns")
|
|
17
|
+
|
|
18
|
+
`value is ToolkitEntry`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Function: loadAgentFromFile()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function loadAgentFromFile(filePath: string, ctx: LoadContext): Promise<AgentDefinition>;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Loads a single markdown agent file and resolves its frontmatter against registered plugin toolkits + ambient tool library.
|
|
9
|
+
|
|
10
|
+
Rejects non-empty `agents:` frontmatter because single-file loads have no siblings to resolve sub-agent references against — callers must use [loadAgentsFromDir](./docs/api/appkit/Function.loadAgentsFromDir.md) when markdown agents delegate to one another.
|
|
11
|
+
|
|
12
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
13
|
+
|
|
14
|
+
| Parameter | Type |
|
|
15
|
+
| ---------- | ------------- |
|
|
16
|
+
| `filePath` | `string` |
|
|
17
|
+
| `ctx` | `LoadContext` |
|
|
18
|
+
|
|
19
|
+
## Returns[](#returns "Direct link to Returns")
|
|
20
|
+
|
|
21
|
+
`Promise`<[`AgentDefinition`](./docs/api/appkit/Interface.AgentDefinition.md)>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Function: loadAgentsFromDir()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function loadAgentsFromDir(dir: string, ctx: LoadContext): Promise<LoadResult>;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Scans a directory for one subdirectory per agent, each containing `agent.md` (frontmatter + body). Produces an `AgentDefinition` record keyed by agent id (folder name). Throws on frontmatter errors or unresolved references. Returns an empty map if the directory does not exist.
|
|
9
|
+
|
|
10
|
+
Legacy top-level `*.md` files are rejected with an error — migrate each to `<id>/agent.md` under a sibling folder named for the agent id.
|
|
11
|
+
|
|
12
|
+
Runs in two passes so sub-agent references in frontmatter (`agents: [...]`) can be resolved regardless of directory iteration order:
|
|
13
|
+
|
|
14
|
+
1. Build every agent's definition from its own `agent.md`.
|
|
15
|
+
2. Walk `agents:` references and wire `def.agents = { child: childDef }` by looking them up in the complete map. Dangling names and self-references fail loudly; mutual delegation is allowed and bounded at runtime by `limits.maxSubAgentDepth`.
|
|
16
|
+
|
|
17
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| --------- | ------------- |
|
|
21
|
+
| `dir` | `string` |
|
|
22
|
+
| `ctx` | `LoadContext` |
|
|
23
|
+
|
|
24
|
+
## Returns[](#returns "Direct link to Returns")
|
|
25
|
+
|
|
26
|
+
`Promise`<`LoadResult`>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Function: mcpServer()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function mcpServer(name: string, url: string): CustomMcpServerTool;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Factory for declaring a custom MCP server tool.
|
|
9
|
+
|
|
10
|
+
Replaces the verbose `{ type: "custom_mcp_server", custom_mcp_server: { app_name, app_url } }` wrapper with a concise positional call.
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
mcpServer("my-app", "https://my-app.databricksapps.com/mcp")
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
20
|
+
|
|
21
|
+
| Parameter | Type |
|
|
22
|
+
| --------- | -------- |
|
|
23
|
+
| `name` | `string` |
|
|
24
|
+
| `url` | `string` |
|
|
25
|
+
|
|
26
|
+
## Returns[](#returns "Direct link to Returns")
|
|
27
|
+
|
|
28
|
+
`CustomMcpServerTool`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Function: parseTextToolCalls()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function parseTextToolCalls(text: string): {
|
|
5
|
+
args: unknown;
|
|
6
|
+
name: string;
|
|
7
|
+
}[];
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Parses text-based tool calls from model output.
|
|
12
|
+
|
|
13
|
+
Handles two formats:
|
|
14
|
+
|
|
15
|
+
1. Llama native: `[{"name": "tool_name", "parameters": {"arg": "val"}}]`
|
|
16
|
+
2. Python-style: `[tool_name(arg1='val1', arg2='val2')]`
|
|
17
|
+
|
|
18
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
19
|
+
|
|
20
|
+
| Parameter | Type |
|
|
21
|
+
| --------- | -------- |
|
|
22
|
+
| `text` | `string` |
|
|
23
|
+
|
|
24
|
+
## Returns[](#returns "Direct link to Returns")
|
|
25
|
+
|
|
26
|
+
{ `args`: `unknown`; `name`: `string`; }\[]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Function: resolveHostedTools()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function resolveHostedTools(tools: HostedTool[]): McpEndpointConfig[];
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
9
|
+
|
|
10
|
+
| Parameter | Type |
|
|
11
|
+
| --------- | ------------------------------------------------------------------ |
|
|
12
|
+
| `tools` | [`HostedTool`](./docs/api/appkit/TypeAlias.HostedTool.md)\[] |
|
|
13
|
+
|
|
14
|
+
## Returns[](#returns "Direct link to Returns")
|
|
15
|
+
|
|
16
|
+
`McpEndpointConfig`\[]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Function: runAgent()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function runAgent(def: AgentDefinition, input: RunAgentInput): Promise<RunAgentResult>;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Standalone agent execution without `createApp`. Resolves the adapter, binds inline tools, and drives the adapter's `run()` loop to completion.
|
|
9
|
+
|
|
10
|
+
Limitations vs. running through the agents() plugin:
|
|
11
|
+
|
|
12
|
+
* **No OBO and no approval gate** — there is no HTTP request, so plugin tools run as the service principal. The agents-plugin approval gate that prompts for human confirmation on `effect: "write" | "update" | "destructive"` tools is also absent. LLM-controlled tool arguments flow straight through to the SP. Treat standalone runAgent as a trusted-prompt environment (CI, batch eval, internal scripts) — not as an exposed user-facing surface.
|
|
13
|
+
* **Hosted tools (MCP) are not supported** — they require a live MCP client that only exists inside the agents plugin's lifecycle. `runAgent` rejects them at index-build time with a clear error.
|
|
14
|
+
* **Sub-agents** (`agents: { ... }` on the def) are executed as nested `runAgent` calls with no shared thread state. Plugin instances ARE shared across the recursion (same cache as the parent).
|
|
15
|
+
* **Plugin tools** (used inside the function form via `plugins.<name>.toolkit(...)`) require passing `plugins: [...]` via `RunAgentInput`. Each plugin in that array is constructed once, `attachContext({})` and `await setup()` are called eagerly, and the resulting instance is shared across the top-level run and all sub-agent recursions. Plugins whose `setup()` requires runtime that only `createApp` provides (e.g. `WorkspaceClient`, `ServiceContext`, `PluginContext`) throw at standalone-init time with a clear "use createApp instead" message — not mid-stream.
|
|
16
|
+
|
|
17
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| --------- | ------------------------------------------------------------------------- |
|
|
21
|
+
| `def` | [`AgentDefinition`](./docs/api/appkit/Interface.AgentDefinition.md) |
|
|
22
|
+
| `input` | [`RunAgentInput`](./docs/api/appkit/Interface.RunAgentInput.md) |
|
|
23
|
+
|
|
24
|
+
## Returns[](#returns "Direct link to Returns")
|
|
25
|
+
|
|
26
|
+
`Promise`<[`RunAgentResult`](./docs/api/appkit/Interface.RunAgentResult.md)>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Function: tool()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function tool<S>(config: ToolConfig<S>): FunctionTool;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Factory for defining function tools with Zod schemas.
|
|
9
|
+
|
|
10
|
+
* Generates JSON Schema (for the LLM) from the Zod schema via `z.toJSONSchema()`.
|
|
11
|
+
* Infers the `execute` argument type from the schema.
|
|
12
|
+
* Validates tool call arguments at runtime. On validation failure, returns a formatted error string to the LLM instead of throwing, so the model can self-correct on its next turn.
|
|
13
|
+
|
|
14
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
15
|
+
|
|
16
|
+
| Type Parameter |
|
|
17
|
+
| ---------------------------------------------------------------------------------------- |
|
|
18
|
+
| `S` *extends* `ZodType`<`unknown`, `unknown`, `$ZodTypeInternals`<`unknown`, `unknown`>> |
|
|
19
|
+
|
|
20
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
21
|
+
|
|
22
|
+
| Parameter | Type |
|
|
23
|
+
| --------- | -------------------------------------------------------------------- |
|
|
24
|
+
| `config` | [`ToolConfig`](./docs/api/appkit/Interface.ToolConfig.md)<`S`> |
|
|
25
|
+
|
|
26
|
+
## Returns[](#returns "Direct link to Returns")
|
|
27
|
+
|
|
28
|
+
[`FunctionTool`](./docs/api/appkit/Interface.FunctionTool.md)
|