@databricks/appkit 0.47.1 → 0.49.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 (78) hide show
  1. package/CLAUDE.md +11 -1
  2. package/dist/agents/databricks.d.ts +24 -7
  3. package/dist/agents/databricks.d.ts.map +1 -1
  4. package/dist/agents/databricks.js +25 -0
  5. package/dist/agents/databricks.js.map +1 -1
  6. package/dist/agents/supervisor-api.d.ts +362 -0
  7. package/dist/agents/supervisor-api.d.ts.map +1 -0
  8. package/dist/agents/supervisor-api.js +498 -0
  9. package/dist/agents/supervisor-api.js.map +1 -0
  10. package/dist/appkit/package.js +1 -1
  11. package/dist/beta.d.ts +2 -1
  12. package/dist/beta.js +2 -1
  13. package/dist/cli/commands/lint.js +6 -0
  14. package/dist/cli/commands/lint.js.map +1 -1
  15. package/dist/connectors/serving/client.d.ts +24 -0
  16. package/dist/connectors/serving/client.d.ts.map +1 -0
  17. package/dist/connectors/serving/client.js +34 -14
  18. package/dist/connectors/serving/client.js.map +1 -1
  19. package/dist/core/agent/run-agent.d.ts.map +1 -1
  20. package/dist/core/agent/run-agent.js +51 -2
  21. package/dist/core/agent/run-agent.js.map +1 -1
  22. package/dist/core/agent/types.d.ts +19 -3
  23. package/dist/core/agent/types.d.ts.map +1 -1
  24. package/dist/core/agent/types.js.map +1 -1
  25. package/dist/core/appkit.d.ts.map +1 -1
  26. package/dist/core/appkit.js +39 -1
  27. package/dist/core/appkit.js.map +1 -1
  28. package/dist/index.js +2 -2
  29. package/dist/plugins/agents/agents.d.ts.map +1 -1
  30. package/dist/plugins/agents/agents.js +65 -5
  31. package/dist/plugins/agents/agents.js.map +1 -1
  32. package/dist/plugins/files/plugin.js +2 -2
  33. package/dist/plugins/jobs/plugin.js +2 -2
  34. package/dist/plugins/serving/serving.js +2 -2
  35. package/dist/plugins/ui-variants/choice-sink.js +70 -0
  36. package/dist/plugins/ui-variants/choice-sink.js.map +1 -0
  37. package/dist/plugins/ui-variants/index.js +94 -0
  38. package/dist/plugins/ui-variants/index.js.map +1 -0
  39. package/dist/plugins/ui-variants/manifest.js +17 -0
  40. package/dist/plugins/ui-variants/manifest.js.map +1 -0
  41. package/dist/registry/manifest-loader.d.ts +1 -1
  42. package/dist/schemas/manifest.d.ts +1 -0
  43. package/dist/schemas/manifest.d.ts.map +1 -1
  44. package/dist/schemas/manifest.js +1 -0
  45. package/dist/schemas/manifest.js.map +1 -1
  46. package/dist/shared/src/agent.d.ts +28 -0
  47. package/dist/shared/src/agent.d.ts.map +1 -1
  48. package/dist/shared/src/plugin.d.ts +3 -1
  49. package/dist/shared/src/plugin.d.ts.map +1 -1
  50. package/dist/shared/src/schemas/manifest.d.ts +3 -2
  51. package/dist/shared/src/schemas/manifest.d.ts.map +1 -1
  52. package/dist/stream/index.js +1 -0
  53. package/dist/stream/sse-reader.js +86 -0
  54. package/dist/stream/sse-reader.js.map +1 -0
  55. package/docs/api/appkit/Class.DatabricksAdapter.md +34 -0
  56. package/docs/api/appkit/Class.SupervisorApiAdapter.md +121 -0
  57. package/docs/api/appkit/Function.fromSupervisorApi.md +63 -0
  58. package/docs/api/appkit/Function.isSupervisorTool.md +18 -0
  59. package/docs/api/appkit/Interface.AgentAdapter.md +24 -0
  60. package/docs/api/appkit/Interface.AgentInput.md +13 -0
  61. package/docs/api/appkit/Interface.HostedSupervisorTool.md +21 -0
  62. package/docs/api/appkit/Interface.PluginManifest.md +27 -9
  63. package/docs/api/appkit/Interface.SupervisorApiAdapterOptions.md +38 -0
  64. package/docs/api/appkit/Interface.SupervisorExtension.md +12 -0
  65. package/docs/api/appkit/Interface.WorkspaceClientLike.md +67 -0
  66. package/docs/api/appkit/TypeAlias.AgentTool.md +3 -2
  67. package/docs/api/appkit/TypeAlias.ResolvedToolEntry.md +167 -0
  68. package/docs/api/appkit/TypeAlias.SupervisorTool.md +45 -0
  69. package/docs/api/appkit/Variable.SUPERVISOR_EXTENSION_KEY.md +8 -0
  70. package/docs/api/appkit/Variable.supervisorTools.md +176 -0
  71. package/docs/api/appkit.md +118 -108
  72. package/docs/plugins/agents.md +131 -1
  73. package/docs/plugins/manifest.md +12 -11
  74. package/llms.txt +11 -1
  75. package/package.json +2 -1
  76. package/sbom.cdx.json +1 -1
  77. package/scripts/postinstall.js +0 -1
  78. package/skills/appkit-ui-variants/SKILL.md +183 -0
@@ -0,0 +1,183 @@
1
+ ---
2
+ name: appkit-ui-variants
3
+ description: Builds a piece of UI in multiple variants, lets the developer pick one live in the browser, then finalizes the chosen variant into source
4
+ argument-hint: <what to build>
5
+ ---
6
+
7
+ # UI — Build in Variants, Pick Live, Finalize
8
+
9
+ User input: $ARGUMENTS
10
+
11
+ Build the requested UI in several variants wrapped in the `<Variants>` picker,
12
+ let the developer choose one **live in the browser**, and then finalize the
13
+ chosen variant into source (removing the wrapper).
14
+
15
+ The picker lets a developer choose between several candidate UIs live in the
16
+ browser during local dev; you then finalize the chosen one into source.
17
+
18
+ **These rules govern your behavior, not your narration.** Apply every rule
19
+ silently. To the developer, speak only about what you're building and what they
20
+ need to do — never about the mechanism (the choices file, how a choice is
21
+ stored, "I read it next turn", or whether you decided to ask).
22
+
23
+ ## The pieces
24
+
25
+ - **`<Variants>` / `<Variant>`** — `@databricks/appkit-ui/react`. A dev-time
26
+ wrapper that renders one candidate at a time with a hover-revealed switcher
27
+ (prev/next, an index pill + label) and a **Confirm** tick.
28
+ - **The recorder** — built into `@databricks/appkit`. Records the confirmed
29
+ choice: Confirm POSTs `{ blockId, chosenIndex, label }` to
30
+ `POST /api/ui-variants/confirm`, upserted into a JSONL file keyed by `blockId`.
31
+ It runs automatically in dev and drops out of production on its own — there's
32
+ nothing to set up.
33
+ - **Choices file** — `node_modules/.databricks/appkit/.appkit-ui-choices.jsonl`,
34
+ gitignored. A **keyed store: one line per `<Variants>` blockId** (not an append
35
+ log) — re-confirming a variant replaces that block's line, so the file always
36
+ reflects the current choice:
37
+ `{ "ts": "...", "blockId": "hero-cta", "chosenIndex": 1, "label": "Solid" }`.
38
+ Its path is relative to the dev server's cwd, not the repo root, so
39
+ **discover** it (finalize step 4) rather than assuming a fixed location.
40
+
41
+ ## 1. Understand the request
42
+
43
+ Work out what to build (a component, a section, a page) and where it lives, then
44
+ pick the natural target file (e.g. a `*.route.tsx` or a component under
45
+ `src/components/…`), and decide the block breakdown before authoring. Two rules
46
+ shape this step:
47
+
48
+ - **Ask for _what_ and _where_; build for _how it looks_.** Before generating,
49
+ ask at most one or two questions **only if the answer changes the build** —
50
+ ambiguous target/surface, an unclear axis of variation, or real-vs-placeholder
51
+ data on a data screen. Do **not** ask appearance/taste questions ("bold or
52
+ minimal?", "which color?"); make one bold and one minimal instead. If the
53
+ request is clear enough, skip questions. Never turn it into a checklist.
54
+ - **One `<Variants>` block = one independent decision** — default to one block
55
+ per distinct section the user names (a hero + about page → two blocks), and
56
+ **default 3 meaningfully different variants per block**.
57
+
58
+ ## 2. Author the variants
59
+
60
+ Wrap each section's candidates in its own `<Variants>` block, following the
61
+ authoring rules below. Note the **file path + every `blockId`** — you need them
62
+ to finalize.
63
+
64
+ - **MUST** treat one `<Variants>` block as **one independent decision** and
65
+ default to **one block per distinct section/region** the user names. A page
66
+ with a hero and an about-us section is **two** blocks (`blockId="hero"`,
67
+ `blockId="about"`), so the developer chooses each section independently. Use a
68
+ single whole-page block **only** when the user asks for whole-page options or
69
+ the sections must move together as one unit.
70
+ - **MUST** give every `<Variants>` block a **stable, unique `blockId`** within its
71
+ file. Duplicate ids are ambiguous — refuse and disambiguate.
72
+ - **MUST** wrap each candidate in `<Variant label="…">` with a short, distinct
73
+ label. The label is shown in the switcher and recorded on confirm.
74
+ - **SHOULD** default to **3 variants** unless the user asks for a specific
75
+ count. Make them meaningfully different (layout / emphasis / density).
76
+ - Keep each variant self-contained: imports it needs should already be present
77
+ so finalizing to any one of them leaves the file valid.
78
+ - **Layout:** `<Variants>` defaults to block layout (full-width, stacking) —
79
+ correct for sections, heroes, and pages. Pass `layout="inline"` only when
80
+ wrapping a small inline element such as a single button.
81
+
82
+ One block per section, each candidate a labelled `<Variant>`:
83
+
84
+ ```tsx
85
+ import { Variants, Variant } from "@databricks/appkit-ui/react";
86
+
87
+ // "page with a hero and an about-us section" → one block per section
88
+ <Variants blockId="hero">
89
+ <Variant label="Centered">…hero A…</Variant>
90
+ <Variant label="Split with stats">…hero B…</Variant>
91
+ <Variant label="Minimal">…hero C…</Variant>
92
+ </Variants>
93
+
94
+ <Variants blockId="about">
95
+ <Variant label="Two column">…about A…</Variant>
96
+ <Variant label="Timeline">…about B…</Variant>
97
+ <Variant label="Team grid">…about C…</Variant>
98
+ </Variants>
99
+ ```
100
+
101
+ ## 3. Ensure the recorder is running
102
+
103
+ - The recorder runs automatically in dev — no setup needed.
104
+ - Confirm the dev server is running so the browser can POST the choice.
105
+
106
+ ## 4. Hand off to the developer
107
+
108
+ Tell the developer to make the choice in the browser:
109
+
110
+ > Flip through the variants in the browser (hover the block to reveal the
111
+ > switcher) and click **Confirm** on the one you want.
112
+
113
+ Then get the "I've chosen" signal — the developer's next message.
114
+
115
+ **The signal is turn-based.** Do **not** start a background watcher. The confirm
116
+ is recorded to the file; read it on your next turn. How to prompt for it:
117
+
118
+ - If your tool has an interactive question prompt **and** the developer is in an
119
+ active session, you MAY ask via that prompt — options like **"I've picked —
120
+ finalize" / "Still deciding" / "Cancel"** — to save them typing.
121
+ - Otherwise, ask in plain text and read the file on a later turn.
122
+
123
+ Two hard rules: the question **must** carry a "still deciding / later" option so
124
+ it never blocks the developer; and only ask when someone is there to answer — if
125
+ unsure, use plain text. If the developer says "done" but no line exists for the
126
+ block yet, they haven't clicked Confirm — ask them to, don't finalize nothing.
127
+
128
+ ## 5. Finalize when the developer says they've chosen
129
+
130
+ 1. When the developer says they've chosen, **discover the choices file** (path
131
+ is relative to the dev server's cwd):
132
+ ```bash
133
+ f=$(find . -path '*/node_modules/.databricks/appkit/.appkit-ui-choices.jsonl' 2>/dev/null | head -1)
134
+ cat "$f" # find the line for your block's blockId
135
+ ```
136
+ 2. For the line matching your block's `blockId`, **reconcile `chosenIndex` against
137
+ `label`:** check the `<Variant>` at `chosenIndex` (zero-based) still has the
138
+ recorded `label`. If they don't match, the file was edited after confirm —
139
+ prefer the `<Variant>` whose `label` matches; if none matches, stop and ask
140
+ the developer to re-confirm.
141
+ 3. Find the `<Variants blockId="<that id>">` block and **replace the whole block with
142
+ the chosen `<Variant>`'s inner JSX** — remove the `<Variants>`/`<Variant>`
143
+ wrapper, drop the now-unused import if nothing else uses it, reconcile
144
+ surrounding code, then format/lint the file
145
+ (`pnpm check:fix`, or `pnpm biome check --write <file>`).
146
+ 4. **Remove the consumed line** for that `blockId` from the choices file. Match the
147
+ `blockId` structurally (not a loose substring) so a label containing the text
148
+ can't delete the wrong line:
149
+ `tmp=$(mktemp); jq -Rc 'fromjson? | select(.blockId != "<that id>")' "$f" > "$tmp" && mv "$tmp" "$f"`.
150
+ 5. Confirm the finalized UI back to the developer.
151
+
152
+ ## 6. Wrap up
153
+
154
+ Offer to iterate (new variants, tweaks) if the developer wants another round.
155
+
156
+ ## Edge cases
157
+
158
+ - **Developer confirms before you ask.** The choice waits in the file; read it
159
+ whenever you next act.
160
+ - **Developer changed their mind.** The store is keyed by `blockId`, so
161
+ re-confirming overwrites the previous line. Read whatever line is there now.
162
+ - **Endpoint absent (prod build / feature off).** The switcher still works as a
163
+ viewer; Confirm shows "Recorder unavailable". Nothing is recorded — nothing to
164
+ finalize.
165
+ - **Duplicate `blockId` in a file.** Ambiguous — refuse to finalize automatically;
166
+ ask which block, or re-author with unique ids.
167
+
168
+ ## Keeping it out of production
169
+
170
+ `<Variants>` is dev-time scaffolding. Always finalize (or remove) every block
171
+ before a production build — a leftover block ships the dev-only picker to
172
+ production.
173
+
174
+ ## Anti-patterns
175
+ - Wrapping several sections in one `<Variants>` block (forces whole-page combos,
176
+ hides most combinations) — one block per section instead.
177
+ - Cosmetic-only variants (same layout, tweaked padding) — make them meaningfully
178
+ different or don't offer a choice.
179
+ - Starting a background watcher/monitor to catch the confirm — the flow is
180
+ turn-based on purpose; read the file when the developer says they're done.
181
+ - Leaving the `<Variants>` wrapper in source after a choice — always finalize
182
+ (or remove) it; a leftover block ships the dev-only picker to production.
183
+ - Forgetting to clear the consumed choices line after finalizing.