@databricks/appkit-ui 0.83.0 → 0.84.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.
Files changed (58) hide show
  1. package/CLAUDE.md +15 -1
  2. package/dist/cli/commands/agent/eval.js +1 -1
  3. package/dist/cli/commands/generate-types.js +1 -1
  4. package/dist/cli/commands/plugin/sync/sync.js +28 -15
  5. package/dist/cli/commands/plugin/sync/sync.js.map +1 -1
  6. package/dist/cli/commands/registry/add.js +3 -11
  7. package/dist/cli/commands/registry/add.js.map +1 -1
  8. package/dist/cli/commands/registry/config-writer.js +1 -1
  9. package/dist/react/ui/button.d.ts +1 -1
  10. package/dist/schemas/manifest.d.ts +35 -1
  11. package/dist/schemas/manifest.d.ts.map +1 -1
  12. package/dist/schemas/manifest.js +112 -4
  13. package/dist/schemas/manifest.js.map +1 -1
  14. package/dist/shared/src/plugin.d.ts.map +1 -1
  15. package/docs/api/appkit/Class.AppKitError.md +2 -1
  16. package/docs/api/appkit/Class.AuthenticationError.md +1 -1
  17. package/docs/api/appkit/Class.ConfigurationError.md +1 -1
  18. package/docs/api/appkit/Class.ConnectionError.md +1 -1
  19. package/docs/api/appkit/Class.DatabaseValidationError.md +1 -1
  20. package/docs/api/appkit/Class.ExecutionError.md +1 -1
  21. package/docs/api/appkit/Class.IdentityExpiredError.md +190 -0
  22. package/docs/api/appkit/Class.InitializationError.md +1 -1
  23. package/docs/api/appkit/Class.Plugin.md +8 -12
  24. package/docs/api/appkit/Class.ServerError.md +1 -1
  25. package/docs/api/appkit/Class.ServiceContext.md +169 -0
  26. package/docs/api/appkit/Class.TunnelError.md +1 -1
  27. package/docs/api/appkit/Class.ValidationError.md +1 -1
  28. package/docs/api/appkit/Function.createApp.md +12 -12
  29. package/docs/api/appkit/Function.getCallerContext.md +12 -0
  30. package/docs/api/appkit/Function.getCurrentUserId.md +14 -0
  31. package/docs/api/appkit/Function.getExecutionContext.md +1 -1
  32. package/docs/api/appkit/Function.getUserContext.md +16 -0
  33. package/docs/api/appkit/Function.isInUserContext.md +12 -0
  34. package/docs/api/appkit/Function.isUserContext.md +20 -0
  35. package/docs/api/appkit/Function.runAgent.md +1 -1
  36. package/docs/api/appkit/Function.runInCallerContext.md +27 -0
  37. package/docs/api/appkit/Function.runInUserContext.md +29 -0
  38. package/docs/api/appkit/Interface.AgentDefinition.md +11 -0
  39. package/docs/api/appkit/Interface.AgentsPluginConfig.md +11 -0
  40. package/docs/api/appkit/Interface.CallerContext.md +13 -0
  41. package/docs/api/appkit/Interface.IndexConfig.md +1 -1
  42. package/docs/api/appkit/Interface.PluginManifest.md +9 -1
  43. package/docs/api/appkit/Interface.RegisteredAgent.md +11 -0
  44. package/docs/api/appkit/Interface.RunAgentInput.md +45 -1
  45. package/docs/api/appkit/TypeAlias.AgentAuth.md +8 -0
  46. package/docs/api/appkit/TypeAlias.AppKitApi.md +35 -0
  47. package/docs/api/appkit/TypeAlias.ExecutionContext.md +4 -1
  48. package/docs/api/appkit/TypeAlias.ExecutionResult.md +65 -0
  49. package/docs/api/appkit/TypeAlias.ScopedPluginMap.md +12 -0
  50. package/docs/api/appkit/TypeAlias.UserContext.md +109 -0
  51. package/docs/api/appkit/TypeAlias.UserScopedApp.md +39 -0
  52. package/docs/api/appkit.md +14 -0
  53. package/docs/plugins/agents.md +45 -0
  54. package/docs/plugins/execution-context.md +101 -50
  55. package/docs/plugins/lakebase.md +6 -82
  56. package/llms.txt +15 -1
  57. package/package.json +1 -1
  58. package/sbom.cdx.json +1 -1
@@ -239,30 +239,26 @@ BasePlugin.abortActiveOperations
239
239
 
240
240
  ***
241
241
 
242
- ### asUser()[​](#asuser "Direct link to asUser()")
242
+ ### ~~asUser()~~[​](#asuser "Direct link to asuser")
243
243
 
244
244
  ```ts
245
245
  asUser(req: Request): this;
246
246
 
247
247
  ```
248
248
 
249
- Execute operations using the user's identity from the request. Returns a proxy of this plugin where all method calls execute with the user's Databricks credentials instead of the service principal.
250
-
251
249
  #### Parameters[​](#parameters-1 "Direct link to Parameters")
252
250
 
253
- | Parameter | Type | Description |
254
- | --------- | --------- | -------------------------------------------------------- |
255
- | `req` | `Request` | The Express request containing the user token in headers |
251
+ | Parameter | Type |
252
+ | --------- | --------- |
253
+ | `req` | `Request` |
256
254
 
257
255
  #### Returns[​](#returns-2 "Direct link to Returns")
258
256
 
259
257
  `this`
260
258
 
261
- A proxied plugin instance that executes as the user
259
+ #### Deprecated[​](#deprecated "Direct link to Deprecated")
262
260
 
263
- #### Throws[​](#throws "Direct link to Throws")
264
-
265
- AuthenticationError if user token is not available in request headers (production only). In development mode (`NODE_ENV=development`), skips user impersonation instead of throwing.
261
+ Use appkit.asUser(req) to scope the whole app.
266
262
 
267
263
  ***
268
264
 
@@ -374,7 +370,7 @@ Returns an [ExecutionResult](./docs/api/appkit/TypeAlias.ExecutionResult.md) dis
374
370
  * `{ ok: true, data: T }` on success
375
371
  * `{ ok: false, status: number, message: string }` on failure
376
372
 
377
- Errors are never thrown — the method is production-safe.
373
+ Caller credential expiration retains the failure result and additionally exposes a typed error, preserving existing result-based callers.
378
374
 
379
375
  #### Type Parameters[​](#type-parameters-1 "Direct link to Type Parameters")
380
376
 
@@ -576,7 +572,7 @@ Returns the `x-forwarded-user` header when present. In development mode (`NODE_E
576
572
 
577
573
  `string`
578
574
 
579
- #### Throws[​](#throws-1 "Direct link to Throws")
575
+ #### Throws[​](#throws "Direct link to Throws")
580
576
 
581
577
  AuthenticationError in production when no user header is present.
582
578
 
@@ -53,7 +53,7 @@ protected readonly optional _clientMessage: string;
53
53
 
54
54
  ```
55
55
 
56
- Client-safe error message. When set, callers serializing the error to a client (SSE, HTTP body) MUST prefer `clientMessage` over `message` — `message` may contain raw upstream / SDK text including statement fragments, internal object names, and correlation IDs.
56
+ Client-safe error message. When set, callers serializing the error to a client (SSE, HTTP body) MUST prefer `clientMessage` over `message`. `message` may contain raw upstream / SDK text including statement fragments, internal object names, and correlation IDs.
57
57
 
58
58
  Subclasses can set this in their constructor for a fixed sanitized string. When unset, `clientMessage` defaults to a generic per-code string (see the getter), and the raw `message` is kept server-side only.
59
59
 
@@ -0,0 +1,169 @@
1
+ # Class: ServiceContext
2
+
3
+ ServiceContext is a singleton that manages the service principal's WorkspaceClient and workspace ID. WarehouseResource owns warehouse bindings.
4
+
5
+ It's initialized once at app startup and provides the foundation for both service principal and user context execution.
6
+
7
+ ## Constructors[​](#constructors "Direct link to Constructors")
8
+
9
+ ### Constructor[​](#constructor "Direct link to Constructor")
10
+
11
+ ```ts
12
+ new ServiceContext(): ServiceContext;
13
+
14
+ ```
15
+
16
+ #### Returns[​](#returns "Direct link to Returns")
17
+
18
+ `ServiceContext`
19
+
20
+ ## Methods[​](#methods "Direct link to Methods")
21
+
22
+ ### createCallerContext()[​](#createcallercontext "Direct link to createCallerContext()")
23
+
24
+ ```ts
25
+ static createCallerContext(
26
+ token: string,
27
+ userId: string,
28
+ userName?: string,
29
+ userEmail?: string): CallerContext;
30
+
31
+ ```
32
+
33
+ Create an immutable caller context from the existing user request headers.
34
+
35
+ #### Parameters[​](#parameters "Direct link to Parameters")
36
+
37
+ | Parameter | Type | Description |
38
+ | ------------ | -------- | ------------------------------------------------------------ |
39
+ | `token` | `string` | The user's access token from x-forwarded-access-token header |
40
+ | `userId` | `string` | The user's ID from x-forwarded-user header |
41
+ | `userName?` | `string` | Optional user name |
42
+ | `userEmail?` | `string` | Optional email from x-forwarded-email |
43
+
44
+ #### Returns[​](#returns-1 "Direct link to Returns")
45
+
46
+ [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md)
47
+
48
+ #### Throws[​](#throws "Direct link to Throws")
49
+
50
+ Error if token is not provided
51
+
52
+ ***
53
+
54
+ ### ~~createUserContext()~~[​](#createusercontext "Direct link to createusercontext")
55
+
56
+ ```ts
57
+ static createUserContext(
58
+ token: string,
59
+ userId: string,
60
+ userName?: string,
61
+ userEmail?: string): CallerContext & UserContext;
62
+
63
+ ```
64
+
65
+ #### Parameters[​](#parameters-1 "Direct link to Parameters")
66
+
67
+ | Parameter | Type |
68
+ | ------------ | -------- |
69
+ | `token` | `string` |
70
+ | `userId` | `string` |
71
+ | `userName?` | `string` |
72
+ | `userEmail?` | `string` |
73
+
74
+ #### Returns[​](#returns-2 "Direct link to Returns")
75
+
76
+ [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md) & [`UserContext`](./docs/api/appkit/TypeAlias.UserContext.md)
77
+
78
+ #### Deprecated[​](#deprecated "Direct link to Deprecated")
79
+
80
+ Use ServiceContext.createCallerContext.
81
+
82
+ ***
83
+
84
+ ### get()[​](#get "Direct link to get()")
85
+
86
+ ```ts
87
+ static get(): ServiceContextState;
88
+
89
+ ```
90
+
91
+ Get the initialized service context.
92
+
93
+ #### Returns[​](#returns-3 "Direct link to Returns")
94
+
95
+ `ServiceContextState`
96
+
97
+ #### Throws[​](#throws-1 "Direct link to Throws")
98
+
99
+ Error if not initialized
100
+
101
+ ***
102
+
103
+ ### getClientOptions()[​](#getclientoptions "Direct link to getClientOptions()")
104
+
105
+ ```ts
106
+ static getClientOptions(): ClientOptions;
107
+
108
+ ```
109
+
110
+ Get the client options for WorkspaceClient. Exposed for testing purposes.
111
+
112
+ #### Returns[​](#returns-4 "Direct link to Returns")
113
+
114
+ `ClientOptions`
115
+
116
+ ***
117
+
118
+ ### initialize()[​](#initialize "Direct link to initialize()")
119
+
120
+ ```ts
121
+ static initialize(options?: {
122
+ warehouseId?: string | boolean;
123
+ }, client?: WorkspaceClient): Promise<ServiceContextState>;
124
+
125
+ ```
126
+
127
+ Initialize the service context. Should be called once at app startup. Safe to call multiple times - will return the same instance.
128
+
129
+ #### Parameters[​](#parameters-2 "Direct link to Parameters")
130
+
131
+ | Parameter | Type | Description |
132
+ | ---------------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
133
+ | `options?` | { `warehouseId?`: `string` \| `boolean`; } | A resolved warehouse ID, or a boolean enabling discovery. |
134
+ | `options.warehouseId?` | `string` \| `boolean` | - |
135
+ | `client?` | [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md) | Optional pre-configured WorkspaceClient to use instead of creating one from environment credentials. |
136
+
137
+ #### Returns[​](#returns-5 "Direct link to Returns")
138
+
139
+ `Promise`<`ServiceContextState`>
140
+
141
+ ***
142
+
143
+ ### isInitialized()[​](#isinitialized "Direct link to isInitialized()")
144
+
145
+ ```ts
146
+ static isInitialized(): boolean;
147
+
148
+ ```
149
+
150
+ Check if the service context has been initialized.
151
+
152
+ #### Returns[​](#returns-6 "Direct link to Returns")
153
+
154
+ `boolean`
155
+
156
+ ***
157
+
158
+ ### reset()[​](#reset "Direct link to reset()")
159
+
160
+ ```ts
161
+ static reset(): void;
162
+
163
+ ```
164
+
165
+ Reset the service context. Only for testing purposes.
166
+
167
+ #### Returns[​](#returns-7 "Direct link to Returns")
168
+
169
+ `void`
@@ -54,7 +54,7 @@ protected readonly optional _clientMessage: string;
54
54
 
55
55
  ```
56
56
 
57
- Client-safe error message. When set, callers serializing the error to a client (SSE, HTTP body) MUST prefer `clientMessage` over `message` — `message` may contain raw upstream / SDK text including statement fragments, internal object names, and correlation IDs.
57
+ Client-safe error message. When set, callers serializing the error to a client (SSE, HTTP body) MUST prefer `clientMessage` over `message`. `message` may contain raw upstream / SDK text including statement fragments, internal object names, and correlation IDs.
58
58
 
59
59
  Subclasses can set this in their constructor for a fixed sanitized string. When unset, `clientMessage` defaults to a generic per-code string (see the getter), and the raw `message` is kept server-side only.
60
60
 
@@ -54,7 +54,7 @@ protected readonly optional _clientMessage: string;
54
54
 
55
55
  ```
56
56
 
57
- Client-safe error message. When set, callers serializing the error to a client (SSE, HTTP body) MUST prefer `clientMessage` over `message` — `message` may contain raw upstream / SDK text including statement fragments, internal object names, and correlation IDs.
57
+ Client-safe error message. When set, callers serializing the error to a client (SSE, HTTP body) MUST prefer `clientMessage` over `message`. `message` may contain raw upstream / SDK text including statement fragments, internal object names, and correlation IDs.
58
58
 
59
59
  Subclasses can set this in their constructor for a fixed sanitized string. When unset, `clientMessage` defaults to a generic per-code string (see the getter), and the raw `message` is kept server-side only.
60
60
 
@@ -5,10 +5,10 @@ function createApp<T>(config: {
5
5
  cache?: CacheConfig;
6
6
  client?: WorkspaceClient;
7
7
  disableInternalTelemetry?: boolean;
8
- onPluginsReady?: (appkit: PluginMap<T>) => void | Promise<void>;
8
+ onPluginsReady?: (appkit: AppKitApi<T>) => void | Promise<void>;
9
9
  plugins?: T;
10
10
  telemetry?: TelemetryConfig;
11
- }): Promise<PluginMap<T>>;
11
+ }): Promise<AppKitApi<T>>;
12
12
 
13
13
  ```
14
14
 
@@ -24,19 +24,19 @@ Initializes telemetry, cache, and service context, then registers plugins in pha
24
24
 
25
25
  ## Parameters[​](#parameters "Direct link to Parameters")
26
26
 
27
- | Parameter | Type | Description |
28
- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
29
- | `config` | { `cache?`: [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md); `client?`: [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md); `disableInternalTelemetry?`: `boolean`; `onPluginsReady?`: (`appkit`: `PluginMap`<`T`>) => `void` \| `Promise`<`void`>; `plugins?`: `T`; `telemetry?`: [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md); } | - |
30
- | `config.cache?` | [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md) | - |
31
- | `config.client?` | [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md) | - |
32
- | `config.disableInternalTelemetry?` | `boolean` | - |
33
- | `config.onPluginsReady?` | (`appkit`: `PluginMap`<`T`>) => `void` \| `Promise`<`void`> | Runs after plugin setup but **before** the server starts. |
34
- | `config.plugins?` | `T` | - |
35
- | `config.telemetry?` | [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md) | - |
27
+ | Parameter | Type | Description |
28
+ | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
29
+ | `config` | { `cache?`: [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md); `client?`: [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md); `disableInternalTelemetry?`: `boolean`; `onPluginsReady?`: (`appkit`: [`AppKitApi`](./docs/api/appkit/TypeAlias.AppKitApi.md)<`T`>) => `void` \| `Promise`<`void`>; `plugins?`: `T`; `telemetry?`: [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md); } | - |
30
+ | `config.cache?` | [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md) | - |
31
+ | `config.client?` | [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md) | - |
32
+ | `config.disableInternalTelemetry?` | `boolean` | - |
33
+ | `config.onPluginsReady?` | (`appkit`: [`AppKitApi`](./docs/api/appkit/TypeAlias.AppKitApi.md)<`T`>) => `void` \| `Promise`<`void`> | Runs after plugin setup but **before** the server starts. |
34
+ | `config.plugins?` | `T` | - |
35
+ | `config.telemetry?` | [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md) | - |
36
36
 
37
37
  ## Returns[​](#returns "Direct link to Returns")
38
38
 
39
- `Promise`<`PluginMap`<`T`>>
39
+ `Promise`<[`AppKitApi`](./docs/api/appkit/TypeAlias.AppKitApi.md)<`T`>>
40
40
 
41
41
  A `PluginMap` keyed by plugin name with typed exports
42
42
 
@@ -0,0 +1,12 @@
1
+ # Function: getCallerContext()
2
+
3
+ ```ts
4
+ function getCallerContext(): CallerContext | undefined;
5
+
6
+ ```
7
+
8
+ Get the caller context if one is active, otherwise `undefined`. Unlike `getExecutionContext()`, this does not require `ServiceContext` to be initialized and never throws.
9
+
10
+ ## Returns[​](#returns "Direct link to Returns")
11
+
12
+ [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md) | `undefined`
@@ -0,0 +1,14 @@
1
+ # ~~Function: getCurrentUserId()~~
2
+
3
+ ```ts
4
+ function getCurrentUserId(): string;
5
+
6
+ ```
7
+
8
+ ## Returns[​](#returns "Direct link to Returns")
9
+
10
+ `string`
11
+
12
+ ## Deprecated[​](#deprecated "Direct link to Deprecated")
13
+
14
+ Use getCurrentPrincipalKey for new cache keys or getCurrentActorId for audit. Preserves the bare user or service ID for existing callers.
@@ -14,7 +14,7 @@ Get the current execution context.
14
14
 
15
15
  ## Returns[​](#returns "Direct link to Returns")
16
16
 
17
- \| `ServiceContextState` | [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md) & `UserContext`
17
+ \| `ServiceContextState` | [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md) & [`UserContext`](./docs/api/appkit/TypeAlias.UserContext.md)
18
18
 
19
19
  ## Throws[​](#throws "Direct link to Throws")
20
20
 
@@ -0,0 +1,16 @@
1
+ # ~~Function: getUserContext()~~
2
+
3
+ ```ts
4
+ function getUserContext():
5
+ | CallerContext & UserContext
6
+ | undefined;
7
+
8
+ ```
9
+
10
+ ## Returns[​](#returns "Direct link to Returns")
11
+
12
+ \| [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md) & [`UserContext`](./docs/api/appkit/TypeAlias.UserContext.md) | `undefined`
13
+
14
+ ## Deprecated[​](#deprecated "Direct link to Deprecated")
15
+
16
+ Use getCallerContext and its principal field.
@@ -0,0 +1,12 @@
1
+ # Function: isInUserContext()
2
+
3
+ ```ts
4
+ function isInUserContext(): boolean;
5
+
6
+ ```
7
+
8
+ Check if currently running in a user context.
9
+
10
+ ## Returns[​](#returns "Direct link to Returns")
11
+
12
+ `boolean`
@@ -0,0 +1,20 @@
1
+ # ~~Function: isUserContext()~~
2
+
3
+ ```ts
4
+ function isUserContext(ctx: ExecutionContext): ctx is UserContext & Partial<CallerContext>;
5
+
6
+ ```
7
+
8
+ ## Parameters[​](#parameters "Direct link to Parameters")
9
+
10
+ | Parameter | Type |
11
+ | --------- | --------------------------------------------------------------------------- |
12
+ | `ctx` | [`ExecutionContext`](./docs/api/appkit/TypeAlias.ExecutionContext.md) |
13
+
14
+ ## Returns[​](#returns "Direct link to Returns")
15
+
16
+ `ctx is UserContext & Partial<CallerContext>`
17
+
18
+ ## Deprecated[​](#deprecated "Direct link to Deprecated")
19
+
20
+ Use isCallerContext. Active caller contexts retain the legacy identity accessors for callers narrowed by this guard.
@@ -9,7 +9,7 @@ Standalone agent execution without `createApp`. Resolves the adapter, binds inli
9
9
 
10
10
  Limitations vs. running through the agents() plugin:
11
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.
12
+ * **No approval gate**: tools inherit the run's principal, SP by default. Explicit caller credentials enable user execution. The agents-plugin gate that prompts for human confirmation on `effect: "write" | "update" | "destructive"` tools is also absent. LLM-controlled tool arguments flow straight through to the tools. Treat standalone runAgent as a trusted-prompt environment (CI, batch eval, internal scripts), not as an exposed user-facing surface.
13
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
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
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.
@@ -0,0 +1,27 @@
1
+ # Function: runInCallerContext()
2
+
3
+ ```ts
4
+ function runInCallerContext<T>(callerContext: CallerContext, fn: () => T): T;
5
+
6
+ ```
7
+
8
+ Run a function with an immutable snapshot of the caller context. Nested and concurrent scopes keep their own identities.
9
+
10
+ ## Type Parameters[​](#type-parameters "Direct link to Type Parameters")
11
+
12
+ | Type Parameter |
13
+ | -------------- |
14
+ | `T` |
15
+
16
+ ## Parameters[​](#parameters "Direct link to Parameters")
17
+
18
+ | Parameter | Type | Description |
19
+ | --------------- | --------------------------------------------------------------------- | ------------------------- |
20
+ | `callerContext` | [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md) | The caller context to use |
21
+ | `fn` | () => `T` | The function to run |
22
+
23
+ ## Returns[​](#returns "Direct link to Returns")
24
+
25
+ `T`
26
+
27
+ The result of the function
@@ -0,0 +1,29 @@
1
+ # ~~Function: runInUserContext()~~
2
+
3
+ ```ts
4
+ function runInUserContext<T>(userContext:
5
+ | UserContext
6
+ | CallerContext & Pick<UserContext, "warehouseId">, fn: () => T): T;
7
+
8
+ ```
9
+
10
+ ## Type Parameters[​](#type-parameters "Direct link to Type Parameters")
11
+
12
+ | Type Parameter |
13
+ | -------------- |
14
+ | `T` |
15
+
16
+ ## Parameters[​](#parameters "Direct link to Parameters")
17
+
18
+ | Parameter | Type |
19
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
20
+ | `userContext` | \| [`UserContext`](./docs/api/appkit/TypeAlias.UserContext.md) \| [`CallerContext`](./docs/api/appkit/Interface.CallerContext.md) & `Pick`<[`UserContext`](./docs/api/appkit/TypeAlias.UserContext.md), `"warehouseId"`> |
21
+ | `fn` | () => `T` |
22
+
23
+ ## Returns[​](#returns "Direct link to Returns")
24
+
25
+ `T`
26
+
27
+ ## Deprecated[​](#deprecated "Direct link to Deprecated")
28
+
29
+ Use runInCallerContext.
@@ -13,6 +13,17 @@ Sub-agents, exposed as `agent-<key>` tools on this agent.
13
13
 
14
14
  ***
15
15
 
16
+ ### auth?[​](#auth "Direct link to auth?")
17
+
18
+ ```ts
19
+ optional auth: "on-behalf-of-user";
20
+
21
+ ```
22
+
23
+ Run this agent on behalf of the signed-in user: the model call, plugin tools, hand-rolled tools, and sub-agents all use the user's credentials. Overrides `agents({ auth })` for this agent. Omit for the default, where the model and hand-rolled tools run as the app service principal and plugin tools run as the user.
24
+
25
+ ***
26
+
16
27
  ### baseSystemPrompt?[​](#basesystemprompt "Direct link to baseSystemPrompt?")
17
28
 
18
29
  ```ts
@@ -60,6 +60,17 @@ Milliseconds to wait before auto-denying. Default: 60\_000.
60
60
 
61
61
  ***
62
62
 
63
+ ### auth?[​](#auth "Direct link to auth?")
64
+
65
+ ```ts
66
+ optional auth: "on-behalf-of-user";
67
+
68
+ ```
69
+
70
+ Default identity for agents that don't set their own `auth`. `"on-behalf-of-user"` runs the whole agent as the signed-in user.
71
+
72
+ ***
73
+
63
74
  ### autoInheritSkills?[​](#autoinheritskills "Direct link to autoInheritSkills?")
64
75
 
65
76
  ```ts
@@ -33,6 +33,19 @@ Truncated SHA-256 hash of the caller token, used to detect rotation.
33
33
 
34
34
  ***
35
35
 
36
+ ### ~~warehouseId?~~[​](#warehouseid "Direct link to warehouseid")
37
+
38
+ ```ts
39
+ readonly optional warehouseId: Promise<string>;
40
+
41
+ ```
42
+
43
+ #### Deprecated[​](#deprecated "Direct link to Deprecated")
44
+
45
+ Use getWarehouseId(). Only legacy context access exposes this field.
46
+
47
+ ***
48
+
36
49
  ### workspaceId[​](#workspaceid "Direct link to workspaceId")
37
50
 
38
51
  ```ts
@@ -5,7 +5,7 @@
5
5
  ### auth?[​](#auth "Direct link to auth?")
6
6
 
7
7
  ```ts
8
- optional auth: "service-principal" | "on-behalf-of-user";
8
+ optional auth: "on-behalf-of-user" | "service-principal";
9
9
 
10
10
  ```
11
11
 
@@ -327,13 +327,21 @@ Omit.scaffolding
327
327
 
328
328
  ```ts
329
329
  optional scopes: (
330
+ | "postgres"
331
+ | "sql"
332
+ | "model-serving"
333
+ | "genie"
334
+ | "files"
335
+ | "vector-search"
336
+ | "catalog.connections"
330
337
  | "ai-gateway"
331
338
  | "mcp.external"
332
339
  | "mcp.functions"
333
340
  | "workspace.workspace"
334
341
  | "catalog.catalogs:read"
335
342
  | "catalog.schemas:read"
336
- | "catalog.tables:read")[];
343
+ | "catalog.tables:read"
344
+ | "sql:restricted-query")[];
337
345
 
338
346
  ```
339
347
 
@@ -11,6 +11,17 @@ adapter: AgentAdapter;
11
11
 
12
12
  ***
13
13
 
14
+ ### auth?[​](#auth "Direct link to auth?")
15
+
16
+ ```ts
17
+ optional auth: "on-behalf-of-user";
18
+
19
+ ```
20
+
21
+ Effective identity: the agent's `auth`, else the plugin default.
22
+
23
+ ***
24
+
14
25
  ### baseSystemPrompt?[​](#basesystemprompt "Direct link to baseSystemPrompt?")
15
26
 
16
27
  ```ts
@@ -2,6 +2,50 @@
2
2
 
3
3
  ## Properties[​](#properties "Direct link to Properties")
4
4
 
5
+ ### caller?[​](#caller "Direct link to caller?")
6
+
7
+ ```ts
8
+ optional caller: {
9
+ host: string;
10
+ principal: CallerPrincipal;
11
+ token: string;
12
+ workspaceId: string;
13
+ };
14
+
15
+ ```
16
+
17
+ Explicit user credentials for standalone execution. Host and workspace ID are required, so no CLI profile or service-principal identity is selected. Omit to inherit the ambient scope, or use SP when no caller scope is open. Obtain the token through a trusted authentication flow, not model input.
18
+
19
+ #### host[​](#host "Direct link to host")
20
+
21
+ ```ts
22
+ readonly host: string;
23
+
24
+ ```
25
+
26
+ #### principal[​](#principal "Direct link to principal")
27
+
28
+ ```ts
29
+ readonly principal: CallerPrincipal;
30
+
31
+ ```
32
+
33
+ #### token[​](#token "Direct link to token")
34
+
35
+ ```ts
36
+ readonly token: string;
37
+
38
+ ```
39
+
40
+ #### workspaceId[​](#workspaceid "Direct link to workspaceId")
41
+
42
+ ```ts
43
+ readonly workspaceId: string;
44
+
45
+ ```
46
+
47
+ ***
48
+
5
49
  ### messages[​](#messages "Direct link to messages")
6
50
 
7
51
  ```ts
@@ -20,7 +64,7 @@ optional plugins: PluginData<PluginConstructor, unknown, string>[];
20
64
 
21
65
  ```
22
66
 
23
- Optional plugin list. Required when `def.tools` is the function form `(plugins) => Record<string, AgentTool>` and the function dereferences any plugins. `runAgent` constructs a fresh instance per plugin and dispatches tool calls against it as the service principal (no OBO — there is no HTTP request in standalone mode).
67
+ Optional plugin list. Required when `def.tools` is the function form `(plugins) => Record<string, AgentTool>` and the function dereferences any plugins. `runAgent` constructs a fresh instance per plugin and dispatches tool calls with the run's ambient principal.
24
68
 
25
69
  ***
26
70
 
@@ -0,0 +1,8 @@
1
+ # Type Alias: AgentAuth
2
+
3
+ ```ts
4
+ type AgentAuth = "on-behalf-of-user";
5
+
6
+ ```
7
+
8
+ Identity an agent runs under. The only value is on-behalf-of-user.