@databricks/appkit 0.32.0 → 0.33.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/agents/databricks.d.ts.map +1 -1
- package/dist/agents/databricks.js +8 -3
- package/dist/agents/databricks.js.map +1 -1
- package/dist/appkit/package.js +1 -1
- package/dist/beta.d.ts +5 -3
- package/dist/beta.js +3 -1
- package/dist/connectors/mcp/client.d.ts +27 -2
- package/dist/connectors/mcp/client.d.ts.map +1 -1
- package/dist/connectors/mcp/client.js +117 -18
- package/dist/connectors/mcp/client.js.map +1 -1
- package/dist/connectors/mcp/index.d.ts +1 -1
- package/dist/connectors/mcp/types.d.ts +1 -1
- package/dist/core/agent/build-toolkit.js +3 -8
- package/dist/core/agent/build-toolkit.js.map +1 -1
- package/dist/core/agent/load-agents.d.ts +6 -1
- package/dist/core/agent/load-agents.d.ts.map +1 -1
- package/dist/core/agent/load-agents.js +67 -27
- package/dist/core/agent/load-agents.js.map +1 -1
- package/dist/core/agent/plugins-map.js +44 -0
- package/dist/core/agent/plugins-map.js.map +1 -0
- package/dist/core/agent/run-agent.d.ts +31 -7
- package/dist/core/agent/run-agent.d.ts.map +1 -1
- package/dist/core/agent/run-agent.js +138 -27
- package/dist/core/agent/run-agent.js.map +1 -1
- package/dist/core/agent/toolkit-options.js +28 -0
- package/dist/core/agent/toolkit-options.js.map +1 -0
- package/dist/core/agent/toolkit-resolver.js +44 -0
- package/dist/core/agent/toolkit-resolver.js.map +1 -0
- package/dist/core/agent/tools/define-tool.d.ts +14 -2
- package/dist/core/agent/tools/define-tool.d.ts.map +1 -1
- package/dist/core/agent/tools/define-tool.js +1 -1
- package/dist/core/agent/tools/define-tool.js.map +1 -1
- package/dist/core/agent/tools/function-tool.d.ts +13 -2
- package/dist/core/agent/tools/function-tool.d.ts.map +1 -1
- package/dist/core/agent/tools/function-tool.js +4 -3
- package/dist/core/agent/tools/function-tool.js.map +1 -1
- package/dist/core/agent/tools/index.d.ts +1 -1
- package/dist/core/agent/tools/tool.d.ts +32 -3
- package/dist/core/agent/tools/tool.d.ts.map +1 -1
- package/dist/core/agent/tools/tool.js +4 -3
- package/dist/core/agent/tools/tool.js.map +1 -1
- package/dist/core/agent/types.d.ts +95 -10
- package/dist/core/agent/types.d.ts.map +1 -1
- package/dist/core/agent/types.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/to-plugin.d.ts +3 -13
- package/dist/plugin/to-plugin.d.ts.map +1 -1
- package/dist/plugin/to-plugin.js +1 -8
- package/dist/plugin/to-plugin.js.map +1 -1
- package/dist/plugins/agents/agents.d.ts +184 -2
- package/dist/plugins/agents/agents.d.ts.map +1 -0
- package/dist/plugins/agents/agents.js +169 -72
- package/dist/plugins/agents/agents.js.map +1 -1
- package/dist/plugins/agents/index.d.ts +2 -2
- package/dist/plugins/agents/index.js +1 -1
- package/dist/plugins/agents/manifest.js +4 -5
- package/dist/plugins/agents/tool-approval-gate.js.map +1 -1
- package/dist/plugins/analytics/analytics.d.ts +3 -4
- package/dist/plugins/analytics/analytics.d.ts.map +1 -1
- package/dist/plugins/analytics/analytics.js +8 -6
- package/dist/plugins/analytics/analytics.js.map +1 -1
- package/dist/plugins/analytics/index.js +1 -0
- package/dist/plugins/analytics/types.js +15 -0
- package/dist/plugins/analytics/types.js.map +1 -0
- package/dist/plugins/beta-exports.generated.d.ts +2 -0
- package/dist/plugins/beta-exports.generated.js +4 -0
- package/dist/plugins/files/plugin.d.ts +1 -2
- package/dist/plugins/files/plugin.d.ts.map +1 -1
- package/dist/plugins/files/plugin.js +30 -12
- package/dist/plugins/files/plugin.js.map +1 -1
- package/dist/plugins/genie/genie.d.ts +5 -4
- package/dist/plugins/genie/genie.d.ts.map +1 -1
- package/dist/plugins/genie/genie.js +22 -8
- package/dist/plugins/genie/genie.js.map +1 -1
- package/dist/plugins/genie/types.d.ts +10 -2
- package/dist/plugins/genie/types.d.ts.map +1 -1
- package/dist/plugins/jobs/plugin.d.ts +1 -2
- package/dist/plugins/jobs/plugin.d.ts.map +1 -1
- package/dist/plugins/lakebase/lakebase.d.ts +1 -2
- package/dist/plugins/lakebase/lakebase.d.ts.map +1 -1
- package/dist/plugins/lakebase/lakebase.js +3 -3
- package/dist/plugins/lakebase/lakebase.js.map +1 -1
- package/dist/plugins/lakebase/types.d.ts +5 -4
- package/dist/plugins/lakebase/types.d.ts.map +1 -1
- package/dist/plugins/server/index.d.ts +3 -2
- package/dist/plugins/server/index.d.ts.map +1 -1
- package/dist/plugins/server/index.js +8 -5
- package/dist/plugins/server/index.js.map +1 -1
- package/dist/plugins/server/types.d.ts +11 -0
- package/dist/plugins/server/types.d.ts.map +1 -1
- package/dist/plugins/serving/serving.d.ts +1 -2
- package/dist/plugins/serving/serving.d.ts.map +1 -1
- package/dist/shared/src/agent.d.ts +16 -4
- package/dist/shared/src/agent.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.md +113 -62
- package/docs/plugins/agents.md +441 -0
- package/llms.txt +53 -1
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
|
@@ -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)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Function: toolsFromRegistry()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function toolsFromRegistry(registry: ToolRegistry): AgentToolDefinition[];
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Produces the `AgentToolDefinition[]` a ToolProvider exposes to the LLM, deriving `parameters` JSON Schema from each entry's Zod schema.
|
|
9
|
+
|
|
10
|
+
Tool names come from registry keys (supports dotted names like `uploads.list` for dynamic plugins).
|
|
11
|
+
|
|
12
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
13
|
+
|
|
14
|
+
| Parameter | Type |
|
|
15
|
+
| ---------- | ------------------------------------------------------------------- |
|
|
16
|
+
| `registry` | [`ToolRegistry`](./docs/api/appkit/TypeAlias.ToolRegistry.md) |
|
|
17
|
+
|
|
18
|
+
## Returns[](#returns "Direct link to Returns")
|
|
19
|
+
|
|
20
|
+
[`AgentToolDefinition`](./docs/api/appkit/Interface.AgentToolDefinition.md)\[]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Interface: AgentAdapter
|
|
2
|
+
|
|
3
|
+
## Methods[](#methods "Direct link to Methods")
|
|
4
|
+
|
|
5
|
+
### run()[](#run "Direct link to run()")
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
run(input: AgentInput, context: AgentRunContext): AsyncGenerator<AgentEvent, void, unknown>;
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
#### Parameters[](#parameters "Direct link to Parameters")
|
|
13
|
+
|
|
14
|
+
| Parameter | Type |
|
|
15
|
+
| --------- | ------------------------------------------------------------------------- |
|
|
16
|
+
| `input` | [`AgentInput`](./docs/api/appkit/Interface.AgentInput.md) |
|
|
17
|
+
| `context` | [`AgentRunContext`](./docs/api/appkit/Interface.AgentRunContext.md) |
|
|
18
|
+
|
|
19
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
20
|
+
|
|
21
|
+
`AsyncGenerator`<[`AgentEvent`](./docs/api/appkit/TypeAlias.AgentEvent.md), `void`, `unknown`>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Interface: AgentDefinition
|
|
2
|
+
|
|
3
|
+
## Properties[](#properties "Direct link to Properties")
|
|
4
|
+
|
|
5
|
+
### agents?[](#agents "Direct link to agents?")
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
optional agents: Record<string, AgentDefinition>;
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Sub-agents, exposed as `agent-<key>` tools on this agent.
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### baseSystemPrompt?[](#basesystemprompt "Direct link to baseSystemPrompt?")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
optional baseSystemPrompt: BaseSystemPromptOption;
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Override the plugin's baseSystemPrompt for this agent only.
|
|
24
|
+
|
|
25
|
+
***
|
|
26
|
+
|
|
27
|
+
### ephemeral?[](#ephemeral "Direct link to ephemeral?")
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
optional ephemeral: boolean;
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
When true, the thread used for a chat request against this agent is deleted from `ThreadStore` after the stream completes (success or failure). Use for stateless one-shot agents — e.g. autocomplete, where each request is independent and retaining history would both poison future calls and accumulate unbounded state in the default `InMemoryThreadStore`. Defaults to `false`.
|
|
35
|
+
|
|
36
|
+
***
|
|
37
|
+
|
|
38
|
+
### instructions[](#instructions "Direct link to instructions")
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
instructions: string;
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
System prompt body. For markdown-loaded agents this is the file body.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### maxSteps?[](#maxsteps "Direct link to maxSteps?")
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
optional maxSteps: number;
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
***
|
|
57
|
+
|
|
58
|
+
### maxTokens?[](#maxtokens "Direct link to maxTokens?")
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
optional maxTokens: number;
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### model?[](#model "Direct link to model?")
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
optional model:
|
|
71
|
+
| string
|
|
72
|
+
| AgentAdapter
|
|
73
|
+
| Promise<AgentAdapter>;
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Model adapter (or endpoint-name string sugar for `DatabricksAdapter.fromServingEndpoint({ endpointName })`). Optional — falls back to the plugin's `defaultModel`.
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
81
|
+
### name?[](#name "Direct link to name?")
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
optional name: string;
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Stable identifier for the agent. **Optional and informational** — when the definition is registered via `agents: { foo: def }` (code) or lives at `config/agents/<id>/agent.md` (markdown), the **registry key always wins** and `name` is ignored. The agent will be reachable as `foo` (or `<id>`) regardless of what this field contains.
|
|
89
|
+
|
|
90
|
+
Set `name` when:
|
|
91
|
+
|
|
92
|
+
* Running standalone via `runAgent({ agent: def })`, where there is no enclosing key. The runtime uses it for the agent's slot in error messages and OTel spans.
|
|
93
|
+
* Building a definition that may be passed to either form and you want a consistent fallback label.
|
|
94
|
+
|
|
95
|
+
Setting `name` to a value that differs from the registry key is harmless but confusing — prefer keeping them aligned or omitting `name` entirely.
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
### tools?[](#tools "Direct link to tools?")
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
optional tools:
|
|
103
|
+
| AgentTools
|
|
104
|
+
| AgentToolsFn;
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Per-agent tool record. Key is the LLM-visible tool-call name.
|
|
109
|
+
|
|
110
|
+
Accepts either a plain record (for agents that only use inline tools) or a function `(plugins) => Record<string, AgentTool>` that receives the typed [Plugins](./docs/api/appkit/TypeAlias.Plugins.md) map and returns a tool record (for agents that pull tools from registered plugins).
|
|
111
|
+
|
|
112
|
+
The function is invoked once at agent setup; the result is cached. Don't put per-request logic in there.
|