Skip to content

Class: TeamsPlugin

AppKit plugin that configures an instance-owned Adaptive Card runtime and exposes card building as an AppKit agent tool.

import { createApp, server } from "@databricks/appkit";
import { teams } from "@dbx-tools/teams";
await createApp({
plugins: [
server(),
teams({ webhookUrl: process.env.TEAMS_WEBHOOK_URL }),
],
});

new TeamsPlugin(config): TeamsPlugin

TeamsPluginConfig

TeamsPlugin

ToolRegistryPlugin<TeamsPluginConfig>.constructor

protected app: AppManager

ToolRegistryPlugin.app


protected cache: CacheManager

ToolRegistryPlugin.cache


protected config: TeamsPluginConfig

ToolRegistryPlugin.config


protected optional context?: PluginContext

ToolRegistryPlugin.context


protected devFileReader: DevFileReader

ToolRegistryPlugin.devFileReader


protected isReady: boolean

ToolRegistryPlugin.isReady


name: string

Plugin name identifier.

ToolRegistryPlugin.name


protected streamManager: StreamManager

ToolRegistryPlugin.streamManager


protected telemetry: ITelemetry

ToolRegistryPlugin.telemetry


protected readonly toolRegistry: ToolRegistry

The tool this plugin offers to an AppKit agent.

Marked autoInheritable: building a card is a pure, side-effect-free transform (nothing leaves the building), so it is safe to hand to any agent by default - unlike a send.

execute re-parses its arguments with the local schema: AppKit validates against the same schema first, but re-parsing is what gives the body typed arguments instead of unknown.

ToolRegistryPlugin.toolRegistry


static manifest: object

config: object

schema: JSONSchema7 = TEAMS_CONFIG_SCHEMA

description: string

displayName: string = "Teams"

name: "teams" = "teams"

resources: object

optional: never[] = []

required: never[] = []

stability: "beta" = "beta"


static phase: PluginPhase

Plugin initialization phase.

  • ‘core’: Initialized first (e.g., config plugins)
  • ‘normal’: Initialized second (most plugins)
  • ‘deferred’: Initialized last (e.g., server plugin)

ToolRegistryPlugin.phase

abortActiveOperations(): void

Cancel in-flight work (abort signals, SSE streams). Runs in the first phase of graceful shutdown, BEFORE any plugin’s shutdown() hook — so it must not tear down shared resources (e.g. connection pools) that other plugins’ hooks may still need. Put teardown in shutdown().

void

ToolRegistryPlugin.abortActiveOperations


asUser(req): this

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.

Request

The Express request containing the user token in headers

this

A proxied plugin instance that executes as the user

AuthenticationError if user token is not available in request headers (production only). In development mode (NODE_ENV=development), skips user impersonation instead of throwing.

ToolRegistryPlugin.asUser


attachContext(deps?): void

Binds runtime dependencies (telemetry provider, cache, plugin context) to this plugin. Called by AppKit._createApp after construction and before setup(). Idempotent: safe to call if the constructor already bound them eagerly. Kept separate so factories can eagerly construct plugin instances without running this before TelemetryManager.initialize() / CacheManager.getInstance() have run.

unknown

TelemetryOptions

void

ToolRegistryPlugin.attachContext


clientConfig(): Record<string, unknown>

Returns startup config to expose to the client. Override this to surface server-side values that are safe to publish to the frontend, such as feature flags, resource IDs, or other app boot settings.

This runs once when the server starts, so it should not depend on request-scoped or user-specific state.

String values that match non-public environment variables are redacted unless you intentionally expose them via a matching PUBLIC_APPKIT_ env var.

Values must be JSON-serializable plain data (no functions, Dates, classes, Maps, Sets, BigInts, or circular references). By default returns an empty object (plugin contributes nothing to client config).

On the client, read the config with the usePluginClientConfig hook (React) or the getPluginClientConfig function (vanilla JS), both from @databricks/appkit-ui.

Record<string, unknown>

// Server — plugin definition
class MyPlugin extends Plugin<MyConfig> {
clientConfig() {
return {
warehouseId: this.config.warehouseId,
features: { darkMode: true },
};
}
}
// Client — React component
import { usePluginClientConfig } from "@databricks/appkit-ui/react";
interface MyPluginConfig { warehouseId: string; features: { darkMode: boolean } }
const config = usePluginClientConfig<MyPluginConfig>("myPlugin");
config.warehouseId; // "abc-123"
// Client — vanilla JS
import { getPluginClientConfig } from "@databricks/appkit-ui/js";
const config = getPluginClientConfig<MyPluginConfig>("myPlugin");

ToolRegistryPlugin.clientConfig


protected execute<T>(fn, options, userKey?): Promise<ExecutionResult<T>>

Execute a function with the plugin’s interceptor chain.

Returns an ExecutionResult discriminated union:

  • { ok: true, data: T } on success
  • { ok: false, status: number, message: string } on failure

Errors are never thrown — the method is production-safe.

T

(signal?) => Promise<T>

PluginExecutionSettings

string

Promise<ExecutionResult<T>>

ToolRegistryPlugin.execute


executeAgentTool(name, args, signal?, _context?): Promise<unknown>

Validate and dispatch one AppKit agent tool call.

string

unknown

AbortSignal

AgentToolExecutionContext

Promise<unknown>

ToolRegistryPlugin.executeAgentTool


protected executeStream<T>(res, fn, options, userKey?): Promise<void>

T

IAppResponse

StreamExecuteHandler<T>

StreamExecutionSettings

string

Promise<void>

ToolRegistryPlugin.executeStream


exports(): object

Returns the public exports for this plugin. Override this to define a custom public API. By default, returns an empty object.

The returned object becomes the plugin’s public API on the AppKit instance (e.g. appkit.myPlugin.method()). AppKit automatically binds method context and adds asUser(req) for user-scoped execution.

buildCard: (spec, signal?) => Promise<{ card: { $schema: string; actions?: Record<string, unknown>[]; body: Record<string, unknown>[]; type: "AdaptiveCard"; version: string; }; title: string; }>

Compile a card spec into an Adaptive Card document. For agent-driven builds use teamsCardTool instead.

object[] = ...

object[] = ...

string = ...

string = ...

string = ...

AbortSignal

Promise<{ card: { $schema: string; actions?: Record<string, unknown>[]; body: Record<string, unknown>[]; type: "AdaptiveCard"; version: string; }; title: string; }>

postCard: (cardDocument, signal?) => Promise<void>

Post a compiled card to the configured Teams incoming webhook. Throws when no webhook is configured.

string = ...

Record<string, unknown>[] = ...

Record<string, unknown>[] = ...

"AdaptiveCard" = ...

string = ...

AbortSignal

Promise<void>

class MyPlugin extends Plugin {
private getData() { return []; }
exports() {
return { getData: this.getData };
}
}
// After registration:
const appkit = await createApp({ plugins: [myPlugin()] });
appkit.myPlugin.getData();

ToolRegistryPlugin.exports


getAgentTools(): AgentToolDefinition[]

Tool definitions offered to an AppKit agent.

AgentToolDefinition[]

ToolRegistryPlugin.getAgentTools


getEndpoints(): PluginEndpointMap

PluginEndpointMap

ToolRegistryPlugin.getEndpoints


getSkipBodyParsingPaths(): ReadonlySet<string>

ReadonlySet<string>

ToolRegistryPlugin.getSkipBodyParsingPaths


injectRoutes(router): void

Mount the card-building and card-posting routes under the plugin base path (/api/teams). POST /card is what the dev display page calls to preview a card live; POST /post pushes a compiled card to the configured Teams incoming webhook.

Neither route is wrapped in asUser(req): compiling a card is a pure transform of the request body and posting goes to a preconfigured webhook, so neither reads workspace data on the caller’s behalf and neither needs an OBO token. Wrapping them would make the routes throw AuthenticationError whenever the user-token header is absent (a local curl, a health probe), which - since AppKit does not catch a rejection raised inside the handler - takes the process down rather than answering 401.

Router

void

ToolRegistryPlugin.injectRoutes


protected registerEndpoint(name, path): void

string

string

void

ToolRegistryPlugin.registerEndpoint


protected resolveUserId(req): string

Resolve the effective user ID from a request.

Returns the x-forwarded-user header when present. In development mode (NODE_ENV=development) falls back to the current context user ID so that callers outside an active runInUserContext scope still get a consistent value.

Request

string

AuthenticationError in production when no user header is present.

ToolRegistryPlugin.resolveUserId


protected route<_TResponse>(router, config): void

_TResponse

Router

RouteConfig

void

ToolRegistryPlugin.route


setup(): Promise<void>

Log the effective config so the resolved card version and whether a webhook is wired up are obvious at boot. Runtime construction already resolved config and captured this plugin’s interceptor chain.

Promise<void>

ToolRegistryPlugin.setup


shutdown(): void

Release this plugin’s instance-owned runtime.

void