@databricks/appkit 0.63.0 → 0.65.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 (93) hide show
  1. package/CLAUDE.md +3 -2
  2. package/dist/appkit/package.js +1 -1
  3. package/dist/cli/commands/doctor/resolve-targets.js +1 -1
  4. package/dist/cli/commands/plugin/create/scaffold.js +2 -2
  5. package/dist/cli/commands/plugin/create/scaffold.js.map +1 -1
  6. package/dist/core/agent/agent-dirs.js +14 -0
  7. package/dist/core/agent/agent-dirs.js.map +1 -0
  8. package/dist/core/agent/create-agent.d.ts +5 -7
  9. package/dist/core/agent/create-agent.d.ts.map +1 -1
  10. package/dist/core/agent/create-agent.js +28 -7
  11. package/dist/core/agent/create-agent.js.map +1 -1
  12. package/dist/core/agent/load-agents.d.ts.map +1 -1
  13. package/dist/core/agent/load-agents.js +4 -4
  14. package/dist/core/agent/load-agents.js.map +1 -1
  15. package/dist/core/agent/load-code-agents.js +115 -0
  16. package/dist/core/agent/load-code-agents.js.map +1 -0
  17. package/dist/core/agent/types.d.ts +20 -6
  18. package/dist/core/agent/types.d.ts.map +1 -1
  19. package/dist/core/agent/types.js.map +1 -1
  20. package/dist/core/appkit.js +1 -1
  21. package/dist/index.d.ts +12 -12
  22. package/dist/index.js +2 -2
  23. package/dist/plugin/plugin.d.ts +2 -2
  24. package/dist/plugins/agents/agents.d.ts +38 -7
  25. package/dist/plugins/agents/agents.d.ts.map +1 -1
  26. package/dist/plugins/agents/agents.js +147 -39
  27. package/dist/plugins/agents/agents.js.map +1 -1
  28. package/dist/plugins/agents/tool-approval-gate.js.map +1 -1
  29. package/dist/plugins/ai-search/ai-search.d.ts +1 -1
  30. package/dist/plugins/ai-search/ai-search.d.ts.map +1 -1
  31. package/dist/plugins/ai-search/ai-search.js +3 -1
  32. package/dist/plugins/ai-search/ai-search.js.map +1 -1
  33. package/dist/plugins/analytics/analytics.d.ts +2 -2
  34. package/dist/plugins/analytics/analytics.d.ts.map +1 -1
  35. package/dist/plugins/analytics/analytics.js +3 -1
  36. package/dist/plugins/analytics/analytics.js.map +1 -1
  37. package/dist/plugins/files/plugin.d.ts +5 -4
  38. package/dist/plugins/files/plugin.d.ts.map +1 -1
  39. package/dist/plugins/files/plugin.js +2 -1
  40. package/dist/plugins/files/plugin.js.map +1 -1
  41. package/dist/plugins/genie/genie.d.ts +2 -2
  42. package/dist/plugins/genie/genie.d.ts.map +1 -1
  43. package/dist/plugins/genie/genie.js +3 -1
  44. package/dist/plugins/genie/genie.js.map +1 -1
  45. package/dist/plugins/jobs/plugin.d.ts +3 -2
  46. package/dist/plugins/jobs/plugin.d.ts.map +1 -1
  47. package/dist/plugins/jobs/plugin.js +2 -1
  48. package/dist/plugins/jobs/plugin.js.map +1 -1
  49. package/dist/plugins/lakebase/lakebase.d.ts +4 -4
  50. package/dist/plugins/lakebase/lakebase.d.ts.map +1 -1
  51. package/dist/plugins/lakebase/lakebase.js +3 -1
  52. package/dist/plugins/lakebase/lakebase.js.map +1 -1
  53. package/dist/plugins/server/index.d.ts +1 -1
  54. package/dist/plugins/server/index.d.ts.map +1 -1
  55. package/dist/plugins/server/index.js +3 -1
  56. package/dist/plugins/server/index.js.map +1 -1
  57. package/dist/plugins/serving/serving.d.ts +1 -0
  58. package/dist/plugins/serving/serving.d.ts.map +1 -1
  59. package/dist/plugins/serving/serving.js +2 -1
  60. package/dist/plugins/serving/serving.js.map +1 -1
  61. package/dist/plugins/ui-variants/index.js +3 -1
  62. package/dist/plugins/ui-variants/index.js.map +1 -1
  63. package/dist/registry/index.d.ts +1 -1
  64. package/dist/registry/index.js +1 -1
  65. package/dist/registry/manifest-loader.d.ts +20 -1
  66. package/dist/registry/manifest-loader.d.ts.map +1 -1
  67. package/dist/registry/manifest-loader.js +23 -1
  68. package/dist/registry/manifest-loader.js.map +1 -1
  69. package/dist/schemas/manifest.d.ts +1 -1
  70. package/dist/shared/src/agent.d.ts +1 -1
  71. package/dist/shared/src/index.d.ts +1 -1
  72. package/dist/shared/src/naming.js +13 -1
  73. package/dist/shared/src/naming.js.map +1 -1
  74. package/dist/shared/src/schemas/manifest.d.ts +1 -1
  75. package/dist/shared/src/schemas/manifest.js +463 -0
  76. package/dist/shared/src/schemas/manifest.js.map +1 -0
  77. package/dist/testing/fixtures.d.ts +1 -1
  78. package/dist/tsdown/index.d.ts +58 -0
  79. package/dist/tsdown/index.d.ts.map +1 -0
  80. package/dist/tsdown/index.js +71 -0
  81. package/dist/tsdown/index.js.map +1 -0
  82. package/docs/api/appkit/Function.createAgent.md +1 -3
  83. package/docs/api/appkit/Function.defineManifest.md +32 -0
  84. package/docs/api/appkit/Interface.AgentDefinition.md +12 -1
  85. package/docs/api/appkit/Interface.AgentsPluginConfig.md +6 -15
  86. package/docs/api/appkit/TypeAlias.AgentEvent.md +1 -1
  87. package/docs/api/appkit/Variable.agents.md +2 -2
  88. package/docs/api/appkit.md +47 -46
  89. package/docs/plugins/agents.md +85 -21
  90. package/docs/plugins/testing.md +2 -2
  91. package/llms.txt +3 -2
  92. package/package.json +5 -1
  93. package/sbom.cdx.json +1 -1
@@ -0,0 +1,58 @@
1
+ //#region src/tsdown/index.d.ts
2
+ /**
3
+ * `@databricks/appkit/tsdown` — the server build preset.
4
+ *
5
+ * A scaffolded app's `tsdown.server.config.ts` is a single line:
6
+ *
7
+ * ```ts
8
+ * import { appkitServerConfig } from "@databricks/appkit/tsdown";
9
+ * export default appkitServerConfig();
10
+ * ```
11
+ *
12
+ * so the agent-discovery build wiring lives in the package and reaches existing
13
+ * apps on upgrade, instead of being hand-maintained in every scaffold. The
14
+ * returned object is a plain tsdown config (no `defineConfig` wrapper needed).
15
+ *
16
+ * This module is intentionally dependency-free (only `node:` builtins) — it is
17
+ * loaded at build time and must not pull in the runtime SDK.
18
+ */
19
+ /** The tsdown options this preset sets. A structural subset of tsdown's config. */
20
+ interface ServerBuildConfig {
21
+ entry?: string | string[];
22
+ unbundle?: boolean;
23
+ clean?: boolean;
24
+ external?: (id: string) => boolean;
25
+ outExtensions?: () => {
26
+ js: string;
27
+ };
28
+ tsconfig?: string;
29
+ /** Any other tsdown option passes through untouched. */
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * Overrides accepted by {@link appkitServerConfig}: either a partial config
34
+ * (merged — `entry` is unioned, `external` composed, other keys win) or a
35
+ * function that receives AppKit's computed base config for full control.
36
+ */
37
+ type ServerConfigOverrides = ServerBuildConfig | ((base: ServerBuildConfig) => ServerBuildConfig);
38
+ /**
39
+ * The server tsdown config, merging AppKit's required wiring with `overrides`.
40
+ *
41
+ * Object overrides merge with intent, not a blind spread:
42
+ * - `entry` is UNIONed — the agent glob can't be dropped by an override;
43
+ * - `external` is COMPOSED — the caller's predicate runs alongside AppKit's;
44
+ * - every other key wins.
45
+ * A function override instead receives the computed base and returns the final
46
+ * config, for callers that need full control (including removing the glob).
47
+ *
48
+ * The agent entry + `clean` are included only when `server/agents/` actually
49
+ * holds code agents, so the same call works for every app. Pass
50
+ * `opts.codeAgents` to force that decision (e.g. a non-standard layout).
51
+ */
52
+ declare function appkitServerConfig(overrides?: ServerConfigOverrides, opts?: {
53
+ cwd?: string;
54
+ codeAgents?: boolean;
55
+ }): ServerBuildConfig;
56
+ //#endregion
57
+ export { ServerBuildConfig, ServerConfigOverrides, appkitServerConfig };
58
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/tsdown/index.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;;AAgBA;;UAhBiB,iBAAA;EACf,KAAA;EACA,QAAA;EACA,KAAA;EACA,QAAA,IAAY,EAAA;EACZ,aAAA;IAAwB,EAAA;EAAA;EACxB,QAAA;EAYgC;EAAA,CAV/B,GAAA;AAAA;AAkEH;;;;;AAAA,KA1DY,qBAAA,GACR,iBAAA,KACE,IAAA,EAAM,iBAAA,KAAsB,iBAAA;;;;;;;;;;;;;;;iBAwDlB,kBAAA,CACd,SAAA,GAAW,qBAAA,EACX,IAAA;EAAQ,GAAA;EAAc,UAAA;AAAA,IACrB,iBAAA"}
@@ -0,0 +1,71 @@
1
+ import path from "node:path";
2
+ import { readdirSync } from "node:fs";
3
+
4
+ //#region src/tsdown/index.ts
5
+ const SERVER_ENTRY = "server/server.ts";
6
+ const AGENT_ENTRY = "server/agents/*/agent.ts";
7
+ /** AppKit default: keep anything resolving outside the project out of the bundle. */
8
+ const defaultExternal = (id) => /^[^./]/.test(id) || id.includes("/node_modules/");
9
+ function toEntryArray(entry) {
10
+ if (entry === void 0) return [];
11
+ return Array.isArray(entry) ? entry : [entry];
12
+ }
13
+ /** True when `server/agents/` holds at least one `<id>/agent.ts` (a code agent). */
14
+ function hasCodeAgents(cwd) {
15
+ const root = path.join(cwd, "server", "agents");
16
+ try {
17
+ return readdirSync(root, { withFileTypes: true }).some((e) => {
18
+ if (!e.isDirectory() && !e.isSymbolicLink()) return false;
19
+ try {
20
+ return readdirSync(path.join(root, e.name)).includes("agent.ts");
21
+ } catch {
22
+ return false;
23
+ }
24
+ });
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+ /** AppKit's base server config, with the agent entry + `clean` only when needed. */
30
+ function baseConfig(codeAgents) {
31
+ return {
32
+ entry: [SERVER_ENTRY, ...codeAgents ? [AGENT_ENTRY] : []],
33
+ unbundle: true,
34
+ external: defaultExternal,
35
+ outExtensions: () => ({ js: ".js" }),
36
+ ...codeAgents ? { clean: true } : {}
37
+ };
38
+ }
39
+ /**
40
+ * The server tsdown config, merging AppKit's required wiring with `overrides`.
41
+ *
42
+ * Object overrides merge with intent, not a blind spread:
43
+ * - `entry` is UNIONed — the agent glob can't be dropped by an override;
44
+ * - `external` is COMPOSED — the caller's predicate runs alongside AppKit's;
45
+ * - every other key wins.
46
+ * A function override instead receives the computed base and returns the final
47
+ * config, for callers that need full control (including removing the glob).
48
+ *
49
+ * The agent entry + `clean` are included only when `server/agents/` actually
50
+ * holds code agents, so the same call works for every app. Pass
51
+ * `opts.codeAgents` to force that decision (e.g. a non-standard layout).
52
+ */
53
+ function appkitServerConfig(overrides = {}, opts = {}) {
54
+ const cwd = opts.cwd ?? process.cwd();
55
+ const base = baseConfig(opts.codeAgents ?? hasCodeAgents(cwd));
56
+ if (typeof overrides === "function") return overrides(base);
57
+ const baseEntries = toEntryArray(base.entry);
58
+ const entry = [...baseEntries, ...toEntryArray(overrides.entry).filter((e) => !baseEntries.includes(e))];
59
+ const userExternal = overrides.external;
60
+ const external = userExternal ? (id) => defaultExternal(id) || userExternal(id) : defaultExternal;
61
+ return {
62
+ ...base,
63
+ ...overrides,
64
+ entry,
65
+ external
66
+ };
67
+ }
68
+
69
+ //#endregion
70
+ export { appkitServerConfig };
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/tsdown/index.ts"],"sourcesContent":["import { readdirSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * `@databricks/appkit/tsdown` — the server build preset.\n *\n * A scaffolded app's `tsdown.server.config.ts` is a single line:\n *\n * ```ts\n * import { appkitServerConfig } from \"@databricks/appkit/tsdown\";\n * export default appkitServerConfig();\n * ```\n *\n * so the agent-discovery build wiring lives in the package and reaches existing\n * apps on upgrade, instead of being hand-maintained in every scaffold. The\n * returned object is a plain tsdown config (no `defineConfig` wrapper needed).\n *\n * This module is intentionally dependency-free (only `node:` builtins) — it is\n * loaded at build time and must not pull in the runtime SDK.\n */\n\n/** The tsdown options this preset sets. A structural subset of tsdown's config. */\nexport interface ServerBuildConfig {\n entry?: string | string[];\n unbundle?: boolean;\n clean?: boolean;\n external?: (id: string) => boolean;\n outExtensions?: () => { js: string };\n tsconfig?: string;\n /** Any other tsdown option passes through untouched. */\n [key: string]: unknown;\n}\n\n/**\n * Overrides accepted by {@link appkitServerConfig}: either a partial config\n * (merged — `entry` is unioned, `external` composed, other keys win) or a\n * function that receives AppKit's computed base config for full control.\n */\nexport type ServerConfigOverrides =\n | ServerBuildConfig\n | ((base: ServerBuildConfig) => ServerBuildConfig);\n\nconst SERVER_ENTRY = \"server/server.ts\";\nconst AGENT_ENTRY = \"server/agents/*/agent.ts\";\n\n/** AppKit default: keep anything resolving outside the project out of the bundle. */\nconst defaultExternal = (id: string): boolean =>\n /^[^./]/.test(id) || id.includes(\"/node_modules/\");\n\nfunction toEntryArray(entry: string | string[] | undefined): string[] {\n if (entry === undefined) return [];\n return Array.isArray(entry) ? entry : [entry];\n}\n\n/** True when `server/agents/` holds at least one `<id>/agent.ts` (a code agent). */\nfunction hasCodeAgents(cwd: string): boolean {\n const root = path.join(cwd, \"server\", \"agents\");\n try {\n return readdirSync(root, { withFileTypes: true }).some((e) => {\n if (!e.isDirectory() && !e.isSymbolicLink()) return false;\n try {\n return readdirSync(path.join(root, e.name)).includes(\"agent.ts\");\n } catch {\n return false;\n }\n });\n } catch {\n return false;\n }\n}\n\n/** AppKit's base server config, with the agent entry + `clean` only when needed. */\nfunction baseConfig(codeAgents: boolean): ServerBuildConfig {\n return {\n entry: [SERVER_ENTRY, ...(codeAgents ? [AGENT_ENTRY] : [])],\n unbundle: true,\n external: defaultExternal,\n outExtensions: () => ({ js: \".js\" }),\n ...(codeAgents ? { clean: true } : {}),\n };\n}\n\n/**\n * The server tsdown config, merging AppKit's required wiring with `overrides`.\n *\n * Object overrides merge with intent, not a blind spread:\n * - `entry` is UNIONed — the agent glob can't be dropped by an override;\n * - `external` is COMPOSED — the caller's predicate runs alongside AppKit's;\n * - every other key wins.\n * A function override instead receives the computed base and returns the final\n * config, for callers that need full control (including removing the glob).\n *\n * The agent entry + `clean` are included only when `server/agents/` actually\n * holds code agents, so the same call works for every app. Pass\n * `opts.codeAgents` to force that decision (e.g. a non-standard layout).\n */\nexport function appkitServerConfig(\n overrides: ServerConfigOverrides = {},\n opts: { cwd?: string; codeAgents?: boolean } = {},\n): ServerBuildConfig {\n const cwd = opts.cwd ?? process.cwd();\n const codeAgents = opts.codeAgents ?? hasCodeAgents(cwd);\n const base = baseConfig(codeAgents);\n\n if (typeof overrides === \"function\") return overrides(base);\n\n const baseEntries = toEntryArray(base.entry);\n const entry = [\n ...baseEntries,\n ...toEntryArray(overrides.entry).filter((e) => !baseEntries.includes(e)),\n ];\n\n const userExternal = overrides.external;\n const external = userExternal\n ? (id: string): boolean => defaultExternal(id) || userExternal(id)\n : defaultExternal;\n\n return { ...base, ...overrides, entry, external };\n}\n"],"mappings":";;;;AA0CA,MAAM,eAAe;AACrB,MAAM,cAAc;;AAGpB,MAAM,mBAAmB,OACvB,SAAS,KAAK,GAAG,IAAI,GAAG,SAAS,iBAAiB;AAEpD,SAAS,aAAa,OAAgD;AACpE,KAAI,UAAU,OAAW,QAAO,EAAE;AAClC,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;;;AAI/C,SAAS,cAAc,KAAsB;CAC3C,MAAM,OAAO,KAAK,KAAK,KAAK,UAAU,SAAS;AAC/C,KAAI;AACF,SAAO,YAAY,MAAM,EAAE,eAAe,MAAM,CAAC,CAAC,MAAM,MAAM;AAC5D,OAAI,CAAC,EAAE,aAAa,IAAI,CAAC,EAAE,gBAAgB,CAAE,QAAO;AACpD,OAAI;AACF,WAAO,YAAY,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,WAAW;WAC1D;AACN,WAAO;;IAET;SACI;AACN,SAAO;;;;AAKX,SAAS,WAAW,YAAwC;AAC1D,QAAO;EACL,OAAO,CAAC,cAAc,GAAI,aAAa,CAAC,YAAY,GAAG,EAAE,CAAE;EAC3D,UAAU;EACV,UAAU;EACV,sBAAsB,EAAE,IAAI,OAAO;EACnC,GAAI,aAAa,EAAE,OAAO,MAAM,GAAG,EAAE;EACtC;;;;;;;;;;;;;;;;AAiBH,SAAgB,mBACd,YAAmC,EAAE,EACrC,OAA+C,EAAE,EAC9B;CACnB,MAAM,MAAM,KAAK,OAAO,QAAQ,KAAK;CAErC,MAAM,OAAO,WADM,KAAK,cAAc,cAAc,IAAI,CACrB;AAEnC,KAAI,OAAO,cAAc,WAAY,QAAO,UAAU,KAAK;CAE3D,MAAM,cAAc,aAAa,KAAK,MAAM;CAC5C,MAAM,QAAQ,CACZ,GAAG,aACH,GAAG,aAAa,UAAU,MAAM,CAAC,QAAQ,MAAM,CAAC,YAAY,SAAS,EAAE,CAAC,CACzE;CAED,MAAM,eAAe,UAAU;CAC/B,MAAM,WAAW,gBACZ,OAAwB,gBAAgB,GAAG,IAAI,aAAa,GAAG,GAChE;AAEJ,QAAO;EAAE,GAAG;EAAM,GAAG;EAAW;EAAO;EAAU"}
@@ -5,9 +5,7 @@ function createAgent(def: AgentDefinition): AgentDefinition;
5
5
 
6
6
  ```
7
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)`.
8
+ Pure factory for agent definitions: cycle-detects the sub-agent graph and returns the same object, stamped with a non-enumerable AGENT\_BRAND so discovery recognizes it. Safe at module top-level; no adapter is built. Don't `Object.freeze` the definition before passing it in — the brand is written onto the argument.
11
9
 
12
10
  ## Parameters[​](#parameters "Direct link to Parameters")
13
11
 
@@ -0,0 +1,32 @@
1
+ # Function: defineManifest()
2
+
3
+ ```ts
4
+ function defineManifest<TName>(manifest: unknown): PluginManifest<TName>;
5
+
6
+ ```
7
+
8
+ Validates a raw manifest (typically a `manifest.json` import) against the canonical Zod schema and returns it as a strict [PluginManifest](./docs/api/appkit/Interface.PluginManifest.md).
9
+
10
+ Plugins declare `static manifest = defineManifest<"my-plugin">(manifestJson)` instead of casting. A plain `as PluginManifest` can't work: a JSON import widens every field to `string`, and `PluginManifest.resources[].type` is the nominal `ResourceType` enum, so the structural JSON shape never assigns. The single internal assertion here bridges that gap in one audited place — after `parse()` has confirmed the values are real `ResourceType`/permission strings — rather than every plugin repeating `as unknown as PluginManifest`.
11
+
12
+ Pass the plugin name as `TName` so the literal is preserved: `toPlugin` derives the typed plugin key from `manifest.name`, and a widened `string` there would collapse the typed plugin registry.
13
+
14
+ ## Type Parameters[​](#type-parameters "Direct link to Type Parameters")
15
+
16
+ | Type Parameter | Default type |
17
+ | -------------------------- | ------------ |
18
+ | `TName` *extends* `string` | `string` |
19
+
20
+ ## Parameters[​](#parameters "Direct link to Parameters")
21
+
22
+ | Parameter | Type |
23
+ | ---------- | --------- |
24
+ | `manifest` | `unknown` |
25
+
26
+ ## Returns[​](#returns "Direct link to Returns")
27
+
28
+ [`PluginManifest`](./docs/api/appkit/Interface.PluginManifest.md)<`TName`>
29
+
30
+ ## Throws[​](#throws "Direct link to Throws")
31
+
32
+ If the manifest doesn't match the schema.
@@ -24,6 +24,17 @@ Override the plugin's baseSystemPrompt for this agent only.
24
24
 
25
25
  ***
26
26
 
27
+ ### default?[​](#default "Direct link to default?")
28
+
29
+ ```ts
30
+ optional default: boolean;
31
+
32
+ ```
33
+
34
+ Marks this agent as the default one chosen when a client doesn't name an agent. Mirrors markdown frontmatter `default: true`. When several agents set it, a code (discovered) agent wins over a markdown one, then the lowest id; an explicit `agents({ defaultAgent })` always overrides it. Defaults to `false`.
35
+
36
+ ***
37
+
27
38
  ### ephemeral?[​](#ephemeral "Direct link to ephemeral?")
28
39
 
29
40
  ```ts
@@ -96,7 +107,7 @@ optional name: string;
96
107
 
97
108
  ```
98
109
 
99
- 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.
110
+ Stable identifier for the agent. **Optional and informational** — when the definition is registered via `agents: { foo: def }` (code) or lives at `server/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.
100
111
 
101
112
  Set `name` when:
102
113
 
@@ -15,14 +15,16 @@ Base configuration interface for AppKit plugins
15
15
 
16
16
  ## Properties[​](#properties "Direct link to Properties")
17
17
 
18
- ### agents?[​](#agents "Direct link to agents?")
18
+ ### ~~agents?~~[​](#agents "Direct link to agents")
19
19
 
20
20
  ```ts
21
21
  optional agents: Record<string, AgentDefinition>;
22
22
 
23
23
  ```
24
24
 
25
- Code-defined agents, merged with file-loaded ones (code wins on key collision).
25
+ #### Deprecated[​](#deprecated "Direct link to Deprecated")
26
+
27
+ Put each code agent in its own folder under `server/agents/<id>/agent.ts` (`export default createAgent({ ... })`); it is discovered automatically at startup and the call collapses to `agents({ ... })` with no map. Still honored for backward compatibility (emits a one-time deprecation warning) but will be removed in a future minor. If both discovery and this map define the same id, discovery wins and the map entry is ignored.
26
28
 
27
29
  ***
28
30
 
@@ -36,7 +38,7 @@ optional approval: {
36
38
 
37
39
  ```
38
40
 
39
- Human-in-the-loop approval gate for mutating tool calls. When enabled (the default), the agents plugin emits an `appkit.approval_pending` SSE event before executing any tool whose annotation flags it as mutating — `effect: "write" | "update" | "destructive"` (preferred) or the legacy `destructive: true` boolean — and waits for a `POST /chat/approve` decision from the same user who initiated the stream. A missing decision after `timeoutMs` auto-denies the call.
41
+ Human-in-the-loop approval gate for mutating tool calls. When enabled (the default), the agents plugin emits an `appkit.approval_pending` SSE event before executing any tool whose annotation flags it as mutating — `effect: "write" | "update" | "destructive"` (preferred) or the legacy `destructive: true` boolean — and waits for a `POST /api/agents/approve` decision from the same user who initiated the stream. A missing decision after `timeoutMs` auto-denies the call.
40
42
 
41
43
  #### requireForDestructive?[​](#requirefordestructive "Direct link to requireForDestructive?")
42
44
 
@@ -89,7 +91,7 @@ optional defaultAgent: string;
89
91
 
90
92
  ```
91
93
 
92
- Agent used when clients don't specify one. Defaults to the first-registered agent or the file with `default: true` frontmatter.
94
+ Agent used when clients don't specify one. Precedence: this value, else a code agent with `default: true`, else a markdown agent with `default: true`, else the first-registered agent.
93
95
 
94
96
  ***
95
97
 
@@ -107,17 +109,6 @@ Default model for agents that don't specify their own (in code or frontmatter).
107
109
 
108
110
  ***
109
111
 
110
- ### dir?[​](#dir "Direct link to dir?")
111
-
112
- ```ts
113
- optional dir: string | false;
114
-
115
- ```
116
-
117
- Directory of agent packages (`<id>/agent.md` each). Default `./config/agents`. Set to `false` to disable.
118
-
119
- ***
120
-
121
112
  ### host?[​](#host "Direct link to host?")
122
113
 
123
114
  ```ts
@@ -296,4 +296,4 @@ type: "approval_pending";
296
296
 
297
297
  ```
298
298
 
299
- Emitted by the agents plugin (not adapters) when a mutating tool call is awaiting human approval — fires for tools annotated with `effect: "write" | "update" | "destructive"` (preferred) or the legacy `destructive: true` boolean. Clients should render an approval prompt and POST to `/chat/approve` with the matching `approvalId` and a `decision` of `approve` or `deny`.
299
+ Emitted by the agents plugin (not adapters) when a mutating tool call is awaiting human approval — fires for tools annotated with `effect: "write" | "update" | "destructive"` (preferred) or the legacy `destructive: true` boolean. Clients should render an approval prompt and POST to `/api/agents/approve` with the matching `approvalId` and a `decision` of `approve` or `deny`.
@@ -1,11 +1,11 @@
1
1
  # Variable: agents
2
2
 
3
3
  ```ts
4
- const agents: ToPlugin<typeof AgentsPlugin, AgentsPluginConfig, string>;
4
+ const agents: ToPlugin<typeof AgentsPlugin, AgentsPluginConfig, "agents">;
5
5
 
6
6
  ```
7
7
 
8
- Plugin factory for the agents plugin. Reads `config/agents/*.md` by default, resolves toolkits/tools from registered plugins, exposes `appkit.agents.*` runtime API and mounts `POST /invocations` and `POST /responses` (aliased non-streaming invoke endpoints) plus `POST /chat` (streaming, HITL-capable).
8
+ Plugin factory for the agents plugin. Discovers agents from `server/agents/<id>/agent.{ts,md}` by default (markdown still in `config/agents/` is read as a deprecated fallback), resolves toolkits/tools from registered plugins, exposes the `appkit.agents.*` runtime API and mounts `POST /invocations` and `POST /responses` (aliased non-streaming invoke endpoints) plus `POST /chat` (streaming, HITL-capable).
9
9
 
10
10
  ## Example[​](#example "Direct link to Example")
11
11
 
@@ -124,52 +124,53 @@ Documentation merge entry for Typedoc — combines the stable `@databricks/appki
124
124
 
125
125
  ## Variables[​](#variables "Direct link to Variables")
126
126
 
127
- | Variable | Description |
128
- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
129
- | [agents](./docs/api/appkit/Variable.agents.md) | Plugin factory for the agents plugin. Reads `config/agents/*.md` by default, resolves toolkits/tools from registered plugins, exposes `appkit.agents.*` runtime API and mounts `POST /invocations` and `POST /responses` (aliased non-streaming invoke endpoints) plus `POST /chat` (streaming, HITL-capable). |
130
- | [aiSearch](./docs/api/appkit/Variable.aiSearch.md) | - |
131
- | [READ\_ACTIONS](./docs/api/appkit/Variable.READ_ACTIONS.md) | Actions that only read data. |
132
- | [sql](./docs/api/appkit/Variable.sql.md) | SQL helper namespace |
133
- | [SUPERVISOR\_EXTENSION\_KEY](./docs/api/appkit/Variable.SUPERVISOR_EXTENSION_KEY.md) | Namespace key under which the adapter reads its hosted-tool payload from [AgentInput.extensions](./docs/api/appkit/Interface.AgentInput.md#extensions). Exported so the agents plugin and standalone `runAgent` (the producers) can write under the same key the adapter reads. |
134
- | [supervisorTools](./docs/api/appkit/Variable.supervisorTools.md) | Concise factories for declaring Supervisor API tools. |
135
- | [WRITE\_ACTIONS](./docs/api/appkit/Variable.WRITE_ACTIONS.md) | Actions that mutate data. |
127
+ | Variable | Description |
128
+ | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
129
+ | [agents](./docs/api/appkit/Variable.agents.md) | Plugin factory for the agents plugin. Discovers agents from `server/agents/<id>/agent.{ts,md}` by default (markdown still in `config/agents/` is read as a deprecated fallback), resolves toolkits/tools from registered plugins, exposes the `appkit.agents.*` runtime API and mounts `POST /invocations` and `POST /responses` (aliased non-streaming invoke endpoints) plus `POST /chat` (streaming, HITL-capable). |
130
+ | [aiSearch](./docs/api/appkit/Variable.aiSearch.md) | - |
131
+ | [READ\_ACTIONS](./docs/api/appkit/Variable.READ_ACTIONS.md) | Actions that only read data. |
132
+ | [sql](./docs/api/appkit/Variable.sql.md) | SQL helper namespace |
133
+ | [SUPERVISOR\_EXTENSION\_KEY](./docs/api/appkit/Variable.SUPERVISOR_EXTENSION_KEY.md) | Namespace key under which the adapter reads its hosted-tool payload from [AgentInput.extensions](./docs/api/appkit/Interface.AgentInput.md#extensions). Exported so the agents plugin and standalone `runAgent` (the producers) can write under the same key the adapter reads. |
134
+ | [supervisorTools](./docs/api/appkit/Variable.supervisorTools.md) | Concise factories for declaring Supervisor API tools. |
135
+ | [WRITE\_ACTIONS](./docs/api/appkit/Variable.WRITE_ACTIONS.md) | Actions that mutate data. |
136
136
 
137
137
  ## Functions[​](#functions "Direct link to Functions")
138
138
 
139
- | Function | Description |
140
- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
141
- | [agentIdFromMarkdownPath](./docs/api/appkit/Function.agentIdFromMarkdownPath.md) | 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). |
142
- | [appKitServingTypesPlugin](./docs/api/appkit/Function.appKitServingTypesPlugin.md) | Vite plugin to generate TypeScript types for AppKit serving endpoints. Fetches OpenAPI schemas from Databricks and generates a .d.ts with ServingEndpointRegistry module augmentation. |
143
- | [appKitTypesPlugin](./docs/api/appkit/Function.appKitTypesPlugin.md) | Vite plugin to generate types for AppKit queries. Calls generateFromEntryPoint under the hood. |
144
- | [createAgent](./docs/api/appkit/Function.createAgent.md) | 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. |
145
- | [createApp](./docs/api/appkit/Function.createApp.md) | Bootstraps AppKit with the provided configuration. |
146
- | [createLakebasePool](./docs/api/appkit/Function.createLakebasePool.md) | Create a Lakebase pool with appkit's logger integration. Telemetry automatically uses appkit's OpenTelemetry configuration via global registry. |
147
- | [createLakebasePoolManager](./docs/api/appkit/Function.createLakebasePoolManager.md) | Create a pool manager that maintains per-key Lakebase connection pools. |
148
- | [createWorkspaceClient](./docs/api/appkit/Function.createWorkspaceClient.md) | Construct an AppKit workspace client. |
149
- | [defineTool](./docs/api/appkit/Function.defineTool.md) | Defines a single tool entry for a plugin's internal registry. |
150
- | [executeFromRegistry](./docs/api/appkit/Function.executeFromRegistry.md) | 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. |
151
- | [extractServingEndpoints](./docs/api/appkit/Function.extractServingEndpoints.md) | Extract serving endpoint config from a server file by AST-parsing it. Looks for `serving({ endpoints: { alias: { env: "..." }, ... } })` calls and extracts the endpoint alias names and their environment variable mappings. |
152
- | [findServerFile](./docs/api/appkit/Function.findServerFile.md) | Find the server entry file by checking candidate paths in order. |
153
- | [fromSupervisorApi](./docs/api/appkit/Function.fromSupervisorApi.md) | Creates an [AgentAdapter](./docs/api/appkit/Interface.AgentAdapter.md) backed by the Databricks AI Gateway Responses API (`/ai-gateway/mlflow/v1/responses`). |
154
- | [functionToolToDefinition](./docs/api/appkit/Function.functionToolToDefinition.md) | - |
155
- | [generateDatabaseCredential](./docs/api/appkit/Function.generateDatabaseCredential.md) | Generate OAuth credentials for Postgres database connection using the proper Postgres API. |
156
- | [getExecutionContext](./docs/api/appkit/Function.getExecutionContext.md) | Get the current execution context. |
157
- | [getLakebaseOrmConfig](./docs/api/appkit/Function.getLakebaseOrmConfig.md) | Get Lakebase connection configuration for ORMs that don't accept pg.Pool directly. |
158
- | [getLakebasePgConfig](./docs/api/appkit/Function.getLakebasePgConfig.md) | Get Lakebase connection configuration for PostgreSQL clients. |
159
- | [getPluginManifest](./docs/api/appkit/Function.getPluginManifest.md) | Loads and validates the manifest from a plugin constructor. Normalizes string type/permission to strict ResourceType/ResourcePermission. |
160
- | [getResourceRequirements](./docs/api/appkit/Function.getResourceRequirements.md) | Gets the resource requirements from a plugin's manifest. |
161
- | [getUsernameWithApiLookup](./docs/api/appkit/Function.getUsernameWithApiLookup.md) | Resolves the PostgreSQL username for a Lakebase connection. |
162
- | [getWorkspaceClient](./docs/api/appkit/Function.getWorkspaceClient.md) | Get workspace client from config or SDK default auth chain |
163
- | [isFunctionTool](./docs/api/appkit/Function.isFunctionTool.md) | - |
164
- | [isHostedTool](./docs/api/appkit/Function.isHostedTool.md) | - |
165
- | [isSQLTypeMarker](./docs/api/appkit/Function.isSQLTypeMarker.md) | Type guard to check if a value is a SQL type marker |
166
- | [isSupervisorTool](./docs/api/appkit/Function.isSupervisorTool.md) | Type guard for [HostedSupervisorTool](./docs/api/appkit/Interface.HostedSupervisorTool.md). Used by the agents plugin (`buildToolIndex`) and standalone `runAgent` (`classifyTool`) to route supervisor-hosted tools to the extensions payload rather than the adapter's `tools` array. |
167
- | [isToolkitEntry](./docs/api/appkit/Function.isToolkitEntry.md) | Type guard for `ToolkitEntry` — used by the agents plugin to differentiate toolkit references from inline tools in a mixed `tools` record. |
168
- | [loadAgentFromFile](./docs/api/appkit/Function.loadAgentFromFile.md) | Loads a single markdown agent file and resolves its frontmatter against registered plugin toolkits + ambient tool library. |
169
- | [loadAgentsFromDir](./docs/api/appkit/Function.loadAgentsFromDir.md) | 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. |
170
- | [mcpServer](./docs/api/appkit/Function.mcpServer.md) | Factory for declaring a custom MCP server tool. |
171
- | [parseTextToolCalls](./docs/api/appkit/Function.parseTextToolCalls.md) | Parses text-based tool calls from model output. |
172
- | [resolveHostedTools](./docs/api/appkit/Function.resolveHostedTools.md) | - |
173
- | [runAgent](./docs/api/appkit/Function.runAgent.md) | Standalone agent execution without `createApp`. Resolves the adapter, binds inline tools, and drives the adapter's `run()` loop to completion. |
174
- | [tool](./docs/api/appkit/Function.tool.md) | Factory for defining function tools with Zod schemas. |
175
- | [toolsFromRegistry](./docs/api/appkit/Function.toolsFromRegistry.md) | Produces the `AgentToolDefinition[]` a ToolProvider exposes to the LLM, deriving `parameters` JSON Schema from each entry's Zod schema. |
139
+ | Function | Description |
140
+ | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
141
+ | [agentIdFromMarkdownPath](./docs/api/appkit/Function.agentIdFromMarkdownPath.md) | 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). |
142
+ | [appKitServingTypesPlugin](./docs/api/appkit/Function.appKitServingTypesPlugin.md) | Vite plugin to generate TypeScript types for AppKit serving endpoints. Fetches OpenAPI schemas from Databricks and generates a .d.ts with ServingEndpointRegistry module augmentation. |
143
+ | [appKitTypesPlugin](./docs/api/appkit/Function.appKitTypesPlugin.md) | Vite plugin to generate types for AppKit queries. Calls generateFromEntryPoint under the hood. |
144
+ | [createAgent](./docs/api/appkit/Function.createAgent.md) | Pure factory for agent definitions: cycle-detects the sub-agent graph and returns the same object, stamped with a non-enumerable AGENT\_BRAND so discovery recognizes it. Safe at module top-level; no adapter is built. Don't `Object.freeze` the definition before passing it in — the brand is written onto the argument. |
145
+ | [createApp](./docs/api/appkit/Function.createApp.md) | Bootstraps AppKit with the provided configuration. |
146
+ | [createLakebasePool](./docs/api/appkit/Function.createLakebasePool.md) | Create a Lakebase pool with appkit's logger integration. Telemetry automatically uses appkit's OpenTelemetry configuration via global registry. |
147
+ | [createLakebasePoolManager](./docs/api/appkit/Function.createLakebasePoolManager.md) | Create a pool manager that maintains per-key Lakebase connection pools. |
148
+ | [createWorkspaceClient](./docs/api/appkit/Function.createWorkspaceClient.md) | Construct an AppKit workspace client. |
149
+ | [defineManifest](./docs/api/appkit/Function.defineManifest.md) | Validates a raw manifest (typically a `manifest.json` import) against the canonical Zod schema and returns it as a strict [PluginManifest](./docs/api/appkit/Interface.PluginManifest.md). |
150
+ | [defineTool](./docs/api/appkit/Function.defineTool.md) | Defines a single tool entry for a plugin's internal registry. |
151
+ | [executeFromRegistry](./docs/api/appkit/Function.executeFromRegistry.md) | 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. |
152
+ | [extractServingEndpoints](./docs/api/appkit/Function.extractServingEndpoints.md) | Extract serving endpoint config from a server file by AST-parsing it. Looks for `serving({ endpoints: { alias: { env: "..." }, ... } })` calls and extracts the endpoint alias names and their environment variable mappings. |
153
+ | [findServerFile](./docs/api/appkit/Function.findServerFile.md) | Find the server entry file by checking candidate paths in order. |
154
+ | [fromSupervisorApi](./docs/api/appkit/Function.fromSupervisorApi.md) | Creates an [AgentAdapter](./docs/api/appkit/Interface.AgentAdapter.md) backed by the Databricks AI Gateway Responses API (`/ai-gateway/mlflow/v1/responses`). |
155
+ | [functionToolToDefinition](./docs/api/appkit/Function.functionToolToDefinition.md) | - |
156
+ | [generateDatabaseCredential](./docs/api/appkit/Function.generateDatabaseCredential.md) | Generate OAuth credentials for Postgres database connection using the proper Postgres API. |
157
+ | [getExecutionContext](./docs/api/appkit/Function.getExecutionContext.md) | Get the current execution context. |
158
+ | [getLakebaseOrmConfig](./docs/api/appkit/Function.getLakebaseOrmConfig.md) | Get Lakebase connection configuration for ORMs that don't accept pg.Pool directly. |
159
+ | [getLakebasePgConfig](./docs/api/appkit/Function.getLakebasePgConfig.md) | Get Lakebase connection configuration for PostgreSQL clients. |
160
+ | [getPluginManifest](./docs/api/appkit/Function.getPluginManifest.md) | Loads and validates the manifest from a plugin constructor. Normalizes string type/permission to strict ResourceType/ResourcePermission. |
161
+ | [getResourceRequirements](./docs/api/appkit/Function.getResourceRequirements.md) | Gets the resource requirements from a plugin's manifest. |
162
+ | [getUsernameWithApiLookup](./docs/api/appkit/Function.getUsernameWithApiLookup.md) | Resolves the PostgreSQL username for a Lakebase connection. |
163
+ | [getWorkspaceClient](./docs/api/appkit/Function.getWorkspaceClient.md) | Get workspace client from config or SDK default auth chain |
164
+ | [isFunctionTool](./docs/api/appkit/Function.isFunctionTool.md) | - |
165
+ | [isHostedTool](./docs/api/appkit/Function.isHostedTool.md) | - |
166
+ | [isSQLTypeMarker](./docs/api/appkit/Function.isSQLTypeMarker.md) | Type guard to check if a value is a SQL type marker |
167
+ | [isSupervisorTool](./docs/api/appkit/Function.isSupervisorTool.md) | Type guard for [HostedSupervisorTool](./docs/api/appkit/Interface.HostedSupervisorTool.md). Used by the agents plugin (`buildToolIndex`) and standalone `runAgent` (`classifyTool`) to route supervisor-hosted tools to the extensions payload rather than the adapter's `tools` array. |
168
+ | [isToolkitEntry](./docs/api/appkit/Function.isToolkitEntry.md) | Type guard for `ToolkitEntry` — used by the agents plugin to differentiate toolkit references from inline tools in a mixed `tools` record. |
169
+ | [loadAgentFromFile](./docs/api/appkit/Function.loadAgentFromFile.md) | Loads a single markdown agent file and resolves its frontmatter against registered plugin toolkits + ambient tool library. |
170
+ | [loadAgentsFromDir](./docs/api/appkit/Function.loadAgentsFromDir.md) | 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. |
171
+ | [mcpServer](./docs/api/appkit/Function.mcpServer.md) | Factory for declaring a custom MCP server tool. |
172
+ | [parseTextToolCalls](./docs/api/appkit/Function.parseTextToolCalls.md) | Parses text-based tool calls from model output. |
173
+ | [resolveHostedTools](./docs/api/appkit/Function.resolveHostedTools.md) | - |
174
+ | [runAgent](./docs/api/appkit/Function.runAgent.md) | Standalone agent execution without `createApp`. Resolves the adapter, binds inline tools, and drives the adapter's `run()` loop to completion. |
175
+ | [tool](./docs/api/appkit/Function.tool.md) | Factory for defining function tools with Zod schemas. |
176
+ | [toolsFromRegistry](./docs/api/appkit/Function.toolsFromRegistry.md) | Produces the `AgentToolDefinition[]` a ToolProvider exposes to the LLM, deriving `parameters` JSON Schema from each entry's Zod schema. |