@temmo/cli 0.0.0-stage → 0.19.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 (445) hide show
  1. package/.claude-plugin/marketplace.json +14 -0
  2. package/.claude-plugin/plugin.json +16 -0
  3. package/.codex-plugin/plugin.json +30 -0
  4. package/.cursor-plugin/plugin.json +22 -0
  5. package/.mcp.json +18 -0
  6. package/LICENSE +202 -0
  7. package/README.md +82 -2
  8. package/THIRD_PARTY_NOTICES +32 -0
  9. package/commands/afk.md +17 -0
  10. package/deploy/build-ui.mjs +65 -0
  11. package/deploy/claude/README.md +16 -0
  12. package/deploy/claude/auto-mode.json +31 -0
  13. package/deploy/postgres/compose.yaml +26 -0
  14. package/deploy/temmo-runner.service +24 -0
  15. package/deploy/verify-ui.mjs +15 -0
  16. package/harness-core/README.md +27 -0
  17. package/harness-core/bin/harness.mjs +17 -0
  18. package/harness-core/package.json +10 -0
  19. package/harness-core/stage.mjs +108 -0
  20. package/harness-core/stages/commit.md +7 -0
  21. package/harness-core/stages/pr.md +7 -0
  22. package/harness-core/stages/push.md +7 -0
  23. package/hooks/codex-hooks.json +14 -0
  24. package/hooks/cursor-hooks.json +17 -0
  25. package/hooks/hooks.json +27 -0
  26. package/lib/acp/permission.js +72 -0
  27. package/lib/acp/sessionConfig.js +109 -0
  28. package/lib/activity.js +244 -0
  29. package/lib/agent-guard.js +72 -0
  30. package/lib/agents-route.js +55 -0
  31. package/lib/agents.js +213 -0
  32. package/lib/agui.js +255 -0
  33. package/lib/alerts.js +36 -0
  34. package/lib/analyze-otlp.js +46 -0
  35. package/lib/analyze-run-code.js +397 -0
  36. package/lib/analyze-sources.js +372 -0
  37. package/lib/approval-card.js +54 -0
  38. package/lib/approval-cli.js +53 -0
  39. package/lib/approval-request.js +81 -0
  40. package/lib/approval-signer.js +48 -0
  41. package/lib/approvals.js +295 -0
  42. package/lib/attachment-cache.js +236 -0
  43. package/lib/attachment.js +63 -0
  44. package/lib/blocked.js +20 -0
  45. package/lib/build-review.js +90 -0
  46. package/lib/builder/cli.js +90 -0
  47. package/lib/builder/policy.js +176 -0
  48. package/lib/builder/recover.js +189 -0
  49. package/lib/builder/run.js +240 -0
  50. package/lib/builder/settle.js +198 -0
  51. package/lib/builder/stage.js +240 -0
  52. package/lib/builder/state.js +73 -0
  53. package/lib/builder/supervisor.js +289 -0
  54. package/lib/builder-clean.js +223 -0
  55. package/lib/builder-code.cjs +67 -0
  56. package/lib/builder.js +9 -0
  57. package/lib/bus-postgres.js +281 -0
  58. package/lib/bus.js +349 -0
  59. package/lib/catalog/author.js +278 -0
  60. package/lib/catalog/dot.js +426 -0
  61. package/lib/catalog/pattern-model.js +193 -0
  62. package/lib/catalog/patterns.js +324 -0
  63. package/lib/catalog/projects.js +83 -0
  64. package/lib/catalog/records.js +2 -0
  65. package/lib/catalog/roster.js +70 -0
  66. package/lib/catalog/team-files.js +49 -0
  67. package/lib/catalog/teams.js +109 -0
  68. package/lib/claude-socket.js +333 -0
  69. package/lib/cli.js +741 -0
  70. package/lib/code-mode.js +45 -0
  71. package/lib/code-read-policy.yaml +9 -0
  72. package/lib/code-run.js +461 -0
  73. package/lib/codex-compact.js +141 -0
  74. package/lib/compaction.js +21 -0
  75. package/lib/config.js +424 -0
  76. package/lib/cursor-trace.js +248 -0
  77. package/lib/deep-link.js +20 -0
  78. package/lib/deliver-push.js +120 -0
  79. package/lib/delivery.js +28 -0
  80. package/lib/deploy-tree.js +227 -0
  81. package/lib/durable.js +404 -0
  82. package/lib/factory-tick.js +32 -0
  83. package/lib/family.js +63 -0
  84. package/lib/fetch-origin.js +53 -0
  85. package/lib/format.js +133 -0
  86. package/lib/harness-surface-cli.js +153 -0
  87. package/lib/harness-surface.js +486 -0
  88. package/lib/harness.js +271 -0
  89. package/lib/hook.mjs +291 -0
  90. package/lib/idle.js +40 -0
  91. package/lib/install-cursor.js +115 -0
  92. package/lib/install-opencode.js +105 -0
  93. package/lib/job.js +82 -0
  94. package/lib/land-cli.js +319 -0
  95. package/lib/land-member.js +64 -0
  96. package/lib/land.js +320 -0
  97. package/lib/lessons.js +223 -0
  98. package/lib/limit-alert.js +423 -0
  99. package/lib/limits.js +284 -0
  100. package/lib/machine-prompt.js +19 -0
  101. package/lib/merge-sweep.js +149 -0
  102. package/lib/messaging.js +1002 -0
  103. package/lib/mission-cli.js +103 -0
  104. package/lib/mission.js +241 -0
  105. package/lib/mode.js +215 -0
  106. package/lib/models.js +114 -0
  107. package/lib/names.js +86 -0
  108. package/lib/opencode-api.js +57 -0
  109. package/lib/opencode-plugin.mjs +313 -0
  110. package/lib/operator-token.js +78 -0
  111. package/lib/operator.js +187 -0
  112. package/lib/pad-activity.js +143 -0
  113. package/lib/pad-fresh.js +44 -0
  114. package/lib/pad.js +198 -0
  115. package/lib/pattern-cli.js +120 -0
  116. package/lib/pattern-compiler.js +68 -0
  117. package/lib/pattern-runs.js +795 -0
  118. package/lib/pattern-stall.js +58 -0
  119. package/lib/pattern-tick.js +45 -0
  120. package/lib/pattern-workflow.js +69 -0
  121. package/lib/pi-extension.mjs +98 -0
  122. package/lib/pi.js +57 -0
  123. package/lib/plugin-copy.js +76 -0
  124. package/lib/pm-review.js +32 -0
  125. package/lib/pm-workspace.js +87 -0
  126. package/lib/postgres.js +115 -0
  127. package/lib/pr-card.js +34 -0
  128. package/lib/probe.js +295 -0
  129. package/lib/process.js +67 -0
  130. package/lib/project-pause.js +23 -0
  131. package/lib/prune.js +793 -0
  132. package/lib/questions.js +250 -0
  133. package/lib/receipts.js +63 -0
  134. package/lib/reflect.js +962 -0
  135. package/lib/rename-migration.js +118 -0
  136. package/lib/run-terminal.js +437 -0
  137. package/lib/runner-request.js +33 -0
  138. package/lib/sandbox-app.js +120 -0
  139. package/lib/sandbox-claims.js +258 -0
  140. package/lib/sandbox-cli.js +188 -0
  141. package/lib/sandbox-hosts-cli.js +68 -0
  142. package/lib/sandbox-hosts.js +94 -0
  143. package/lib/sandbox-pr.js +102 -0
  144. package/lib/sandbox-proposal.js +367 -0
  145. package/lib/sandbox-tools.js +143 -0
  146. package/lib/sandbox.js +501 -0
  147. package/lib/schedule-session.js +68 -0
  148. package/lib/session-activity.js +67 -0
  149. package/lib/session-events.js +94 -0
  150. package/lib/sessions/control.js +244 -0
  151. package/lib/sessions/git-refs.js +265 -0
  152. package/lib/sessions/launch.js +359 -0
  153. package/lib/sessions/registry.js +450 -0
  154. package/lib/sessions/scope.js +111 -0
  155. package/lib/setup.js +377 -0
  156. package/lib/signed-approval.js +225 -0
  157. package/lib/slash.js +167 -0
  158. package/lib/spawn-cli.js +45 -0
  159. package/lib/spawn.js +107 -0
  160. package/lib/start-limit.js +58 -0
  161. package/lib/state.js +24 -0
  162. package/lib/stop.js +308 -0
  163. package/lib/store-read.js +62 -0
  164. package/lib/store.js +252 -0
  165. package/lib/subagent-guard.js +240 -0
  166. package/lib/surfaces/channel-post.js +43 -0
  167. package/lib/surfaces/instructions.js +15 -0
  168. package/lib/surfaces/mcp-reload.js +144 -0
  169. package/lib/surfaces/ops.js +629 -0
  170. package/lib/surfaces/render-mcp.js +33 -0
  171. package/lib/surfaces/run-terminal-ops.js +40 -0
  172. package/lib/surfaces/sandbox-ops.js +36 -0
  173. package/lib/surfaces/schema.js +7 -0
  174. package/lib/surfaces/task-view.js +90 -0
  175. package/lib/surfaces/types.js +4 -0
  176. package/lib/task-cli.js +274 -0
  177. package/lib/task-order.js +34 -0
  178. package/lib/task-order.mjs +2 -0
  179. package/lib/task-route.js +125 -0
  180. package/lib/tasks.js +631 -0
  181. package/lib/team-permission.js +34 -0
  182. package/lib/team-templates/blitz/team.dot +9 -0
  183. package/lib/team-templates/factory/team.dot +26 -0
  184. package/lib/team-templates/feature/team.dot +14 -0
  185. package/lib/team-templates/fix-and-review/team.dot +12 -0
  186. package/lib/team-templates/product/team.dot +16 -0
  187. package/lib/team-templates/release/team.dot +7 -0
  188. package/lib/team-templates/review/team.dot +6 -0
  189. package/lib/terminal-draft.js +42 -0
  190. package/lib/thread-branch.js +82 -0
  191. package/lib/thread-channel-store.js +181 -0
  192. package/lib/thread-channels.js +116 -0
  193. package/lib/thread-listening.js +20 -0
  194. package/lib/thread-routes.js +91 -0
  195. package/lib/threads.js +441 -0
  196. package/lib/tool-api.js +33 -0
  197. package/lib/transcript.js +98 -0
  198. package/lib/ui-build-output.js +19 -0
  199. package/lib/ui-capabilities.js +90 -0
  200. package/lib/usage.js +182 -0
  201. package/lib/vendor/mcp-sdk.d.mts +4 -0
  202. package/lib/vendor/mcp-sdk.mjs +17046 -0
  203. package/lib/waiter.js +127 -0
  204. package/lib/workflows.js +546 -0
  205. package/lib/worktree-setup.js +86 -0
  206. package/package.json +110 -4
  207. package/runner/adapters/claude.js +465 -0
  208. package/runner/adapters/cli-sandbox.js +277 -0
  209. package/runner/adapters/codex.js +675 -0
  210. package/runner/adapters/cursor.mjs +937 -0
  211. package/runner/adapters/fake.js +119 -0
  212. package/runner/adapters/opencode-sandbox.js +370 -0
  213. package/runner/adapters/opencode.js +486 -0
  214. package/runner/adapters/pi-sandbox.js +134 -0
  215. package/runner/adapters/pi.js +364 -0
  216. package/runner/client.js +40 -0
  217. package/runner/contract.js +129 -0
  218. package/runner/control.js +178 -0
  219. package/runner/delivery.js +184 -0
  220. package/runner/factory-tick.mjs +10 -0
  221. package/runner/lock.js +41 -0
  222. package/runner/main.mjs +118 -0
  223. package/runner/pattern-tick.mjs +16 -0
  224. package/runner/publish.js +113 -0
  225. package/runner/runner.js +2612 -0
  226. package/runner/sandbox-run.mjs +239 -0
  227. package/runner/schedules.js +294 -0
  228. package/runner/task-wake.js +59 -0
  229. package/scripts/ai-collab +3 -0
  230. package/scripts/ai-collab-bus.mjs +4 -0
  231. package/scripts/ai-collab-code-mcp.mjs +3 -0
  232. package/scripts/ai-collab-hook +3 -0
  233. package/scripts/ai-collab-hook.mjs +3 -0
  234. package/scripts/ai-collab-mcp-tools.mjs +2 -0
  235. package/scripts/ai-collab-mcp.mjs +3 -0
  236. package/scripts/ai-collab.mjs +3 -0
  237. package/scripts/install-cursor.mjs +11 -0
  238. package/scripts/install-opencode.mjs +10 -0
  239. package/scripts/temmo +3 -0
  240. package/scripts/temmo-bus.mjs +151 -0
  241. package/scripts/temmo-code-mcp.mjs +63 -0
  242. package/scripts/temmo-hook +3 -0
  243. package/scripts/temmo-hook.mjs +201 -0
  244. package/scripts/temmo-mcp-tools.mjs +22 -0
  245. package/scripts/temmo-mcp.mjs +27 -0
  246. package/scripts/temmo.mjs +4 -0
  247. package/skills/antislop/SKILL.md +701 -0
  248. package/skills/antislop/VERSION +1 -0
  249. package/skills/antislop-code/SKILL.md +128 -0
  250. package/skills/antislop-human/LICENSE-web-quality-skills +21 -0
  251. package/skills/antislop-human/SKILL.md +204 -0
  252. package/skills/antislop-human/contrast-check.py +168 -0
  253. package/skills/antislop-human/contrast-mcp.py +125 -0
  254. package/skills/antislop-human/references/A11Y-PATTERNS.md +249 -0
  255. package/skills/antislop-human/references/WCAG.md +127 -0
  256. package/skills/antislop-layoutmobile/SKILL.md +170 -0
  257. package/skills/antislop-ui/LICENSE-web-quality-skills +21 -0
  258. package/skills/antislop-ui/SKILL.md +351 -0
  259. package/skills/antislop-ui/references/CORE-WEB-VITALS.md +181 -0
  260. package/skills/antislop-ui/references/WEB-BASELINE.md +28 -0
  261. package/skills/harness-surface/SKILL.md +42 -0
  262. package/skills/land/SKILL.md +32 -0
  263. package/skills/memory-file/SKILL.md +39 -0
  264. package/skills/temmo/SKILL.md +101 -0
  265. package/skills/temmo/references/role-programs.md +47 -0
  266. package/skills/ui-sdk/SKILL.md +56 -0
  267. package/skills/ui-sdk/references/agent-ready.md +136 -0
  268. package/skills/ui-sdk/references/build-interface.md +187 -0
  269. package/skills/ui-sdk/references/create-component.md +88 -0
  270. package/skills/ui-sdk/references/patterns.md +246 -0
  271. package/skills/ui-sdk/references/styles.md +66 -0
  272. package/skills/ui-sdk/references/testing.md +172 -0
  273. package/skills/ui-sdk/references/web-components.md +78 -0
  274. package/tools/screen-state.mjs +119 -0
  275. package/tools/smoke-ui.mjs +540 -0
  276. package/web/app/activity.jsx +251 -0
  277. package/web/app/agent-mark.tsx +43 -0
  278. package/web/app/alert-level.jsx +16 -0
  279. package/web/app/api/[action]/route.js +8 -0
  280. package/web/app/api/auth/[step]/route.js +12 -0
  281. package/web/app/api/events/route.js +8 -0
  282. package/web/app/api/file/[name]/route.js +8 -0
  283. package/web/app/api/land/route.js +12 -0
  284. package/web/app/api/lessons/route.js +8 -0
  285. package/web/app/api/push/key/route.js +8 -0
  286. package/web/app/api/push/subscribe/route.js +12 -0
  287. package/web/app/api/push/test/route.js +8 -0
  288. package/web/app/api/refs/route.js +8 -0
  289. package/web/app/api/review-diff/route.js +8 -0
  290. package/web/app/api/schedules/route.js +8 -0
  291. package/web/app/api/thread-diff/route.js +8 -0
  292. package/web/app/api/version/route.js +6 -0
  293. package/web/app/cards.jsx +189 -0
  294. package/web/app/chat-api.js +82 -0
  295. package/web/app/chat-composer.jsx +313 -0
  296. package/web/app/chat-console.jsx +691 -0
  297. package/web/app/chat-image.tsx +61 -0
  298. package/web/app/chat-message.jsx +122 -0
  299. package/web/app/chat-shared.jsx +59 -0
  300. package/web/app/chat-sidebar.jsx +25 -0
  301. package/web/app/chat-stream.js +127 -0
  302. package/web/app/chat.jsx +31 -0
  303. package/web/app/compactions.jsx +57 -0
  304. package/web/app/composer-actions.tsx +87 -0
  305. package/web/app/decisions.jsx +53 -0
  306. package/web/app/fonts/OFL-hanken-grotesk.txt +93 -0
  307. package/web/app/fonts/OFL-ibm-plex-mono.txt +93 -0
  308. package/web/app/fonts/hanken-grotesk-latin-wght-normal.woff2 +0 -0
  309. package/web/app/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  310. package/web/app/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  311. package/web/app/globals.css +199 -0
  312. package/web/app/home.jsx +246 -0
  313. package/web/app/icon.svg +1 -0
  314. package/web/app/land-panel.jsx +63 -0
  315. package/web/app/land-reviews.jsx +20 -0
  316. package/web/app/layout.jsx +17 -0
  317. package/web/app/lessons.tsx +76 -0
  318. package/web/app/logo.tsx +13 -0
  319. package/web/app/logos.jsx +16 -0
  320. package/web/app/manifest.js +8 -0
  321. package/web/app/mode-menu.tsx +46 -0
  322. package/web/app/new-session.jsx +275 -0
  323. package/web/app/notify.jsx +180 -0
  324. package/web/app/outcomes.tsx +94 -0
  325. package/web/app/page.jsx +9 -0
  326. package/web/app/pattern-graph.jsx +75 -0
  327. package/web/app/patterns-page.jsx +293 -0
  328. package/web/app/phone-nav.tsx +36 -0
  329. package/web/app/progress-feed.tsx +33 -0
  330. package/web/app/providers.tsx +27 -0
  331. package/web/app/quote.jsx +15 -0
  332. package/web/app/run-card.tsx +200 -0
  333. package/web/app/run-requests.tsx +148 -0
  334. package/web/app/scheduled.jsx +105 -0
  335. package/web/app/session-panel.tsx +174 -0
  336. package/web/app/session-toolbar.tsx +180 -0
  337. package/web/app/shadcn.css +638 -0
  338. package/web/app/shipped.jsx +49 -0
  339. package/web/app/subagent-runs.jsx +31 -0
  340. package/web/app/task-graph.jsx +67 -0
  341. package/web/app/tasks-strip.tsx +36 -0
  342. package/web/app/tasks.jsx +375 -0
  343. package/web/app/team-author.jsx +145 -0
  344. package/web/app/team-editor.jsx +88 -0
  345. package/web/app/thread-agents.tsx +32 -0
  346. package/web/app/thread-place.tsx +9 -0
  347. package/web/app/thread-sessions.tsx +149 -0
  348. package/web/app/thread-sidebar.tsx +418 -0
  349. package/web/app/thread-switcher.tsx +27 -0
  350. package/web/app/tool-diff.jsx +94 -0
  351. package/web/components/a2ui/controls.jsx +36 -0
  352. package/web/components/a2ui/option-picker.jsx +23 -0
  353. package/web/components/a2ui/script.tsx +121 -0
  354. package/web/components/a2ui/surface.jsx +81 -0
  355. package/web/components/chat/thread.jsx +50 -0
  356. package/web/components/script-text.tsx +42 -0
  357. package/web/components/ui/avatar.jsx +115 -0
  358. package/web/components/ui/badge.jsx +47 -0
  359. package/web/components/ui/button.jsx +63 -0
  360. package/web/components/ui/chat-container.jsx +52 -0
  361. package/web/components/ui/choice-list.tsx +72 -0
  362. package/web/components/ui/code-block.jsx +60 -0
  363. package/web/components/ui/copy-button.tsx +41 -0
  364. package/web/components/ui/dropdown-menu.jsx +257 -0
  365. package/web/components/ui/markdown.jsx +84 -0
  366. package/web/components/ui/message.jsx +28 -0
  367. package/web/components/ui/popover.jsx +33 -0
  368. package/web/components/ui/scroll-button.jsx +34 -0
  369. package/web/components/ui/select.jsx +189 -0
  370. package/web/components/ui/sheet.jsx +152 -0
  371. package/web/components/ui/sonner.jsx +10 -0
  372. package/web/components/ui/tabs.jsx +88 -0
  373. package/web/components/ui/textarea.jsx +20 -0
  374. package/web/components/ui/tooltip.jsx +56 -0
  375. package/web/components.json +24 -0
  376. package/web/instrumentation.js +8 -0
  377. package/web/lib/a2ui-catalog.js +34 -0
  378. package/web/lib/a2ui-pr.js +76 -0
  379. package/web/lib/a2ui-run-catalog.js +18 -0
  380. package/web/lib/a2ui-run.js +93 -0
  381. package/web/lib/a2ui.js +262 -0
  382. package/web/lib/activity-rows.js +275 -0
  383. package/web/lib/agent-detail.js +5 -0
  384. package/web/lib/alert-level.js +44 -0
  385. package/web/lib/approval-mode.js +22 -0
  386. package/web/lib/chat-turns.js +174 -0
  387. package/web/lib/child-subagents.js +16 -0
  388. package/web/lib/compaction-view.js +48 -0
  389. package/web/lib/composer-actions.js +40 -0
  390. package/web/lib/context-view.js +57 -0
  391. package/web/lib/fuzzy.js +26 -0
  392. package/web/lib/highlight.js +44 -0
  393. package/web/lib/lessons-view.js +23 -0
  394. package/web/lib/mentions.js +16 -0
  395. package/web/lib/message-routing.js +105 -0
  396. package/web/lib/new-session.js +85 -0
  397. package/web/lib/operator-messages.js +28 -0
  398. package/web/lib/pattern-graph.js +165 -0
  399. package/web/lib/pattern-view.js +33 -0
  400. package/web/lib/pending-summary.js +18 -0
  401. package/web/lib/permission-modes.js +30 -0
  402. package/web/lib/project-feed.js +107 -0
  403. package/web/lib/quote.js +7 -0
  404. package/web/lib/reply-quote.js +31 -0
  405. package/web/lib/scheduled.js +79 -0
  406. package/web/lib/selection.js +110 -0
  407. package/web/lib/send-confirmation.js +22 -0
  408. package/web/lib/session-dead.js +10 -0
  409. package/web/lib/session-state.js +132 -0
  410. package/web/lib/sidebar.js +15 -0
  411. package/web/lib/slash-commands.js +164 -0
  412. package/web/lib/start-default.js +35 -0
  413. package/web/lib/start-mode.js +35 -0
  414. package/web/lib/stream-views.js +49 -0
  415. package/web/lib/subagent-state.js +20 -0
  416. package/web/lib/task-board.js +54 -0
  417. package/web/lib/task-graph.js +183 -0
  418. package/web/lib/task-tags.js +41 -0
  419. package/web/lib/team-editor.js +10 -0
  420. package/web/lib/thread-groups.js +86 -0
  421. package/web/lib/threads.js +28 -0
  422. package/web/lib/tool-diff.js +273 -0
  423. package/web/lib/ui-events.js +58 -0
  424. package/web/lib/utils.js +5 -0
  425. package/web/lib/view-memory.js +25 -0
  426. package/web/next.config.mjs +37 -0
  427. package/web/postcss.config.mjs +1 -0
  428. package/web/proxy.js +25 -0
  429. package/web/public/sw.js +39 -0
  430. package/web/server/auth.js +178 -0
  431. package/web/server/dispatch.js +293 -0
  432. package/web/server/history.js +56 -0
  433. package/web/server/hosted.js +58 -0
  434. package/web/server/hub.js +126 -0
  435. package/web/server/instance.js +5 -0
  436. package/web/server/land-reviews.js +64 -0
  437. package/web/server/push.js +148 -0
  438. package/web/server/run-terminal.js +79 -0
  439. package/web/server/schedules.js +38 -0
  440. package/web/server/shipped.js +51 -0
  441. package/web/server/task-board.js +71 -0
  442. package/web/server/threads.js +209 -0
  443. package/web/server/ui.js +2937 -0
  444. package/web/tsconfig.base.json +16 -0
  445. package/web/tsconfig.json +9 -0
@@ -0,0 +1,121 @@
1
+ "use client";
2
+ import { createComponentImplementation } from "@a2ui/react/v0_9";
3
+ import { Drawer, DrawerBackdrop, DrawerClose, DrawerContent, DrawerDescription, DrawerTitle } from "@ui-sdk/react/drawer";
4
+ import { Maximize2, X } from "lucide-react";
5
+ import { type ReactNode, useEffect, useLayoutEffect, useRef, useState } from "react";
6
+ import { CopyButton } from "@/components/ui/copy-button";
7
+ import { ScriptApi } from "@/lib/a2ui-run-catalog";
8
+ import { CHECK_TEXT, type Check, Lines, digest, lineCount } from "@/components/script-text";
9
+ import { cn } from "@/lib/utils";
10
+
11
+ /** The whole text in a bottom sheet with its line count, hash and a copy button; output opens at its last line. */
12
+ function FullText({ label, text, lines, hash, follow, close }: { label: string; text: string; lines: string[]; hash: ReactNode; follow?: boolean; close: () => void }) {
13
+ return <Drawer open onOpenChange={(open: boolean) => { if (!open) close(); }}>
14
+ <DrawerBackdrop className="bg-black/30"/>
15
+ <DrawerContent initialFocus="content" className="flex h-[92dvh] w-full flex-col rounded-t-3xl bg-card shadow-raised">
16
+ <div aria-hidden className="mx-auto mt-2 h-1.5 w-10 shrink-0 rounded-full bg-muted-foreground/30"/>
17
+ <header className="flex shrink-0 items-center gap-2 border-b px-4 pt-2 pb-3">
18
+ <div className="min-w-0 flex-1">
19
+ <DrawerTitle className="font-mono text-sm font-medium">{label}</DrawerTitle>
20
+ <DrawerDescription className="text-xs text-muted-foreground">{lineCount(lines)}</DrawerDescription>
21
+ </div>
22
+ <CopyButton text={text}/>
23
+ <DrawerClose aria-label="Close" className="grid size-11 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">
24
+ <X aria-hidden className="size-4"/>
25
+ </DrawerClose>
26
+ </header>
27
+ {hash && <div className="shrink-0 border-b px-4 py-2">{hash}</div>}
28
+ <pre tabIndex={0} aria-label={label} ref={node => { if (node && follow) node.scrollTop = node.scrollHeight; }}
29
+ className="min-h-0 flex-1 overflow-y-auto overscroll-contain bg-muted/40 px-4 py-3 font-mono text-xs leading-5"><Lines lines={lines}/></pre>
30
+ </DrawerContent>
31
+ </Drawer>;
32
+ }
33
+
34
+ /**
35
+ * A labelled text block. The card shows a short preview (output shows its tail) with the line count, a copy button and
36
+ * Show all, which opens the whole text in a sheet; a hashed block shows the server's sha256 and whether the browser's own
37
+ * digest of the full text matches it. inline renders one truncated line that wraps when tapped, for a path.
38
+ */
39
+ export const ScriptImpl = createComponentImplementation(ScriptApi, ({ props }) => {
40
+ const text = String(props.text ?? "");
41
+ const label = props.label || "Text";
42
+ const expected = props.sha256;
43
+ const follow = Boolean(props.follow);
44
+ const lines = text.split("\n");
45
+ // The binder makes a new setter each render; a ref keeps the hash effect from re-running for it.
46
+ const setShown = useRef<((value: string) => void) | undefined>(undefined);
47
+ setShown.current = (props as { setShown?: (value: string) => void }).setShown;
48
+ const [check, setCheck] = useState<Check>("checking");
49
+ const [full, setFull] = useState(false);
50
+ const [wrapped, setWrapped] = useState(false);
51
+ const [clipped, setClipped] = useState(false);
52
+ const preview = useRef<HTMLDivElement>(null);
53
+ useEffect(() => {
54
+ if (!expected) return;
55
+ if (!globalThis.crypto?.subtle) { setCheck("unavailable"); return; }
56
+ let live = true;
57
+ digest(text).then(hex => {
58
+ if (!live) return;
59
+ setCheck(hex === expected ? "match" : "differs");
60
+ setShown.current?.(hex);
61
+ }, () => live && setCheck("unavailable"));
62
+ return () => { live = false; };
63
+ }, [text, expected]);
64
+ useLayoutEffect(() => {
65
+ const node = preview.current;
66
+ // Output pinned to the end overflows at the top, where scrollHeight does not count it, so compare the text's own height.
67
+ if (node?.firstElementChild) setClipped((node.firstElementChild as HTMLElement).offsetHeight > node.clientHeight + 1);
68
+ });
69
+
70
+ if (props.inline) return <button type="button" title={text} aria-expanded={wrapped} onClick={() => setWrapped(!wrapped)}
71
+ className="flex min-h-6 w-full min-w-0 items-baseline gap-2 rounded-sm text-left text-xs focus-visible:outline-2 focus-visible:outline-ring">
72
+ <span className="shrink-0 font-medium text-muted-foreground">{label}</span>
73
+ <span className={cn("min-w-0 font-mono", wrapped ? "break-all" : "truncate [direction:rtl]")}><bdi>{text}</bdi></span>
74
+ </button>;
75
+
76
+ const differs = check === "differs";
77
+ const hash = expected && <p className={cn("flex min-w-0 gap-1 font-mono text-xs text-muted-foreground", differs && "font-semibold text-destructive")}>
78
+ <span className="shrink-0">sha256</span>
79
+ <span title={expected} className={cn("min-w-0", full ? "break-all" : "truncate")}>{expected}</span>
80
+ <span className="shrink-0">·</span>
81
+ <span className={cn("shrink-0 font-sans", !full && "max-w-[60%] truncate")} title={CHECK_TEXT[check]}>{CHECK_TEXT[check]}</span>
82
+ </p>;
83
+ const fullHash = expected && <p className={cn("font-mono text-xs break-all text-muted-foreground", differs && "font-semibold text-destructive")}>
84
+ sha256 {expected} · {CHECK_TEXT[check]}
85
+ </p>;
86
+ // At most eight lines in the card; output keeps its last lines in view, the rest opens in the sheet.
87
+ // A clipped preview fades out where the text goes on: the end of a script, the start of output.
88
+ const block = <div ref={preview} className={cn("relative flex max-h-[calc(8lh+0.75rem+2px)] flex-col overflow-hidden rounded-md border bg-muted/40 px-2 py-1.5 font-mono text-xs leading-4",
89
+ follow && "justify-end")}>
90
+ <pre className="font-mono"><Lines lines={lines}/></pre>
91
+ {clipped && <span aria-hidden className={cn("pointer-events-none absolute inset-x-0 h-8 from-card to-transparent", follow ? "top-0 bg-linear-to-b" : "bottom-0 bg-linear-to-t")}/>}
92
+ </div>;
93
+ // The negative margin keeps 44px tap targets without spacing the rows apart.
94
+ const tools = <div className="-my-1.5 flex shrink-0 items-center">
95
+ <CopyButton text={text}/>
96
+ {clipped && <button type="button" aria-label={"Show all of " + label} onClick={() => setFull(true)}
97
+ className="flex h-9 items-center gap-1 rounded-md px-2 text-xs font-medium text-foreground hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring pointer-coarse:h-11">
98
+ <Maximize2 aria-hidden className="size-3.5"/>Show all
99
+ </button>}
100
+ </div>;
101
+ const sheet = full && <FullText label={label} text={text} lines={lines} hash={fullHash} follow={follow} close={() => setFull(false)}/>;
102
+ const meta = `${label} · ${lineCount(lines)}`;
103
+ // A collapsed block folds behind its label and line count; the hash check still runs on the full text.
104
+ if (props.collapsed) return <details className="group/script flex min-w-0 flex-col gap-1">
105
+ <summary className="-my-1.5 min-h-11 cursor-pointer content-center text-xs font-medium text-muted-foreground">{meta}</summary>
106
+ <div className="flex min-w-0 flex-col gap-1">
107
+ <div className="flex min-w-0 items-center justify-end">{tools}</div>
108
+ {block}{hash}
109
+ </div>
110
+ {sheet}
111
+ </details>;
112
+ return <div className="flex min-w-0 flex-col gap-1">
113
+ <div className="flex min-w-0 items-center justify-between gap-2">
114
+ <span className="min-w-0 truncate text-xs font-medium text-muted-foreground">{meta}</span>
115
+ {tools}
116
+ </div>
117
+ {block}
118
+ {hash}
119
+ {sheet}
120
+ </div>;
121
+ });
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { Component, createContext, useContext, useMemo, useRef } from "react";
3
+ import { A2uiSurface } from "@a2ui/react/v0_9";
4
+ import { MessageProcessor } from "@a2ui/web_core/v0_9";
5
+ import { temmoCatalog } from "@/lib/a2ui-catalog";
6
+ import { cn } from "@/lib/utils";
7
+ import { OptionPicker } from "./option-picker";
8
+ import { ButtonImpl, ChipImpl, TextFieldImpl } from "./controls";
9
+ import { ScriptImpl } from "./script";
10
+
11
+ // The card shell shared with the legacy cards in web/app/cards.jsx.
12
+ export const CARD = "w-full max-w-full rounded-2xl border bg-card px-3.5 py-3 text-sm text-card-foreground shadow-xs [overflow-wrap:anywhere]";
13
+ // A2UI theme variables mapped onto the app's tokens, so both themes follow the app's light and dark values.
14
+ const THEME = {
15
+ "--a2ui-color-background": "var(--card)", "--a2ui-color-on-background": "var(--card-foreground)",
16
+ "--a2ui-color-surface": "var(--card)", "--a2ui-color-on-surface": "var(--card-foreground)",
17
+ "--a2ui-color-primary": "var(--primary)", "--a2ui-color-on-primary": "var(--primary-foreground)",
18
+ "--a2ui-color-primary-hover": "var(--primary)",
19
+ "--a2ui-color-secondary": "var(--muted)", "--a2ui-color-on-secondary": "var(--foreground)",
20
+ "--a2ui-color-secondary-hover": "var(--accent)",
21
+ "--a2ui-color-border": "var(--border)", "--a2ui-border": "1px solid var(--border)",
22
+ "--a2ui-color-input": "var(--background)", "--a2ui-color-on-input": "var(--foreground)",
23
+ "--a2ui-font-size": "0.875rem", "--a2ui-line-height-body": "1.45",
24
+ "--a2ui-button-font-weight": "500", "--a2ui-button-border-radius": "var(--radius-md)",
25
+ };
26
+ const catalog = temmoCatalog([OptionPicker, ButtonImpl, TextFieldImpl, ChipImpl, ScriptImpl]);
27
+ // Surfaces by id from the AG-UI stream, and the submit that posts a surface action (null when signed out).
28
+ export const SurfaceContext = createContext({ surfaces: {}, submit: null, disabled: false });
29
+
30
+ // A render error in a surface shows the legacy card instead of breaking the chat.
31
+ class SurfaceBoundary extends Component {
32
+ constructor(props) {
33
+ super(props);
34
+ this.state = { failed: false };
35
+ }
36
+ static getDerivedStateFromError() {
37
+ return { failed: true };
38
+ }
39
+ componentDidCatch(error) {
40
+ console.error("A2UI surface failed; showing the card", error);
41
+ }
42
+ render() {
43
+ return this.state.failed ? this.props.fallback : this.props.children;
44
+ }
45
+ }
46
+
47
+ // Builds the surface from its operations; a protocol error throws, so the boundary shows the card.
48
+ function Rendered({ id, operations, submit }) {
49
+ const submitRef = useRef(submit);
50
+ submitRef.current = submit;
51
+ const surface = useMemo(() => {
52
+ const processor = new MessageProcessor([catalog], userAction => submitRef.current?.({ forwardedProps: { a2uiAction: { userAction } } }));
53
+ const errors = processor.processMessagesWithErrors(operations);
54
+ if (errors.length) throw new Error(errors[0].error.message);
55
+ const built = processor.model.surfacesMap.get(id);
56
+ if (!built) throw new Error("A2UI surface " + id + " was not created");
57
+ return built;
58
+ }, [id, operations]);
59
+ return <A2uiSurface surface={surface}/>;
60
+ }
61
+
62
+ /**
63
+ * The A2UI surface with this id in a card with a header row (head: the asking agent; kind: its label), or the fallback card
64
+ * when the server sent none, the stream has no submit, or rendering fails. open lights the border while it waits for an answer; className adds to the card's.
65
+ */
66
+ export function Surface({ id, fallback, head = null, kind = "", open = false, className = "" }) {
67
+ const { surfaces, submit, disabled } = useContext(SurfaceContext);
68
+ const operations = surfaces[id];
69
+ if (!operations || !submit) return fallback;
70
+ // inert blocks taps and keys while the chat is busy or not connected, as the legacy card's disabled does.
71
+ return <SurfaceBoundary fallback={fallback}>
72
+ <section data-surface={id} inert={disabled || undefined} aria-disabled={disabled || undefined}
73
+ className={cn(CARD, "flex flex-col gap-2.5", open && "border-primary/50", disabled && "opacity-60", className)} style={THEME}>
74
+ {(head || kind) && <header className="flex min-w-0 items-center justify-between gap-2 text-xs text-muted-foreground">
75
+ {head && <div className="flex min-w-0 items-center gap-2 font-medium text-foreground">{head}</div>}
76
+ {kind && <span className="shrink-0 font-medium">{kind}</span>}
77
+ </header>}
78
+ <Rendered id={id} operations={operations} submit={submit}/>
79
+ </section>
80
+ </SurfaceBoundary>;
81
+ }
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ // The chat thread on assistant-ui: the feed's thread entries (chat messages interleaved with activity rows)
3
+ // ride an external-store runtime so the message list and markdown come from maintained primitives instead of
4
+ // hand-rolled ones. The console keeps its own scroll container: the feed's pull-to-refresh and scroll memory
5
+ // need raw scroll control the assistant-ui viewport does not expose, so only the message list moved.
6
+ import { createContext, useCallback, useContext } from "react";
7
+ import { AssistantRuntimeProvider, MessageNotSentError, useExternalStoreRuntime } from "@assistant-ui/react";
8
+ import { MarkdownTextPrimitive } from "@assistant-ui/react-markdown";
9
+ import { MARKDOWN_COMPONENTS } from "@/components/ui/markdown";
10
+ import { withMentions } from "@/lib/mentions";
11
+
12
+ /**
13
+ * Runtime over the thread entries from web/lib/chat-turns.js and project-feed.js.
14
+ * A chat message becomes a text part; an activity row becomes a data part so one ordered
15
+ * list drives the thread, and the renderer dispatches on the entry bound to each message.
16
+ * The composer gets its own instance with no entries: onSend is the console's send path; a result that is
17
+ * not true throws MessageNotSentError, which makes the runtime hand the draft back to the input.
18
+ */
19
+ export function ChatRuntimeProvider({ entries, operator, onSend, children }) {
20
+ const convertMessage = useCallback((entry) => entry.message
21
+ ? {
22
+ id: String(entry.message.id),
23
+ role: entry.message.from === operator ? "user" : "assistant",
24
+ createdAt: entry.message.time ? new Date(entry.message.time * 1000) : undefined,
25
+ content: [{ type: "text", text: entry.message.body || "" }],
26
+ }
27
+ : {
28
+ id: String(entry.activity.id),
29
+ role: "assistant",
30
+ createdAt: entry.activity.time ? new Date(entry.activity.time * 1000) : undefined,
31
+ content: [{ type: "data-activity", data: entry.activity }],
32
+ }, [operator]);
33
+ const onNew = useCallback(async (message) => {
34
+ const text = Array.isArray(message.content) ? (message.content.find(part => part.type === "text")?.text ?? "") : "";
35
+ const result = await onSend?.(text);
36
+ if (result !== true) throw new MessageNotSentError(result === "draftHeld" ? "The terminal holds an unsent draft" : "The message was not sent");
37
+ }, [onSend]);
38
+ const runtime = useExternalStoreRuntime({ messages: entries, convertMessage, onNew, isRunning: false });
39
+ return <AssistantRuntimeProvider runtime={runtime}>{children}</AssistantRuntimeProvider>;
40
+ }
41
+
42
+ /** Per-bubble render settings, read by BubbleText inside the message part context. */
43
+ export const BubbleContext = createContext({ plugins: null });
44
+
45
+ /** The maintained markdown renderer, with the app's remark config, mention links and shiki code blocks. */
46
+ export function BubbleText() {
47
+ const { plugins } = useContext(BubbleContext);
48
+ return <MarkdownTextPrimitive className="contents" smooth={false} remarkPlugins={plugins || undefined}
49
+ components={MARKDOWN_COMPONENTS} preprocess={withMentions}/>;
50
+ }
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+
4
+ // Shared by the A2UI Script block (components/a2ui/script.tsx) and the run card (app/run-card.tsx).
5
+ export type Check = "checking" | "match" | "differs" | "unavailable";
6
+
7
+ export const CHECK_TEXT: Record<Check, string> = {
8
+ checking: "Hashing what is shown…",
9
+ match: "matches the bytes shown",
10
+ differs: "DIFFERS from the bytes shown: do not run",
11
+ unavailable: "This browser cannot hash the script (needs HTTPS), so Run stays off",
12
+ };
13
+
14
+ export async function digest(text: string): Promise<string> {
15
+ const bytes = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
16
+ return [...new Uint8Array(bytes)].map(byte => byte.toString(16).padStart(2, "0")).join("");
17
+ }
18
+
19
+ /** The browser's own sha256 of text and whether it equals expected; hex stays "" until the digest matches. */
20
+ export function useScriptCheck(text: string, expected?: string): { check: Check; hex: string } {
21
+ const [state, setState] = useState<{ check: Check; hex: string }>({ check: "checking", hex: "" });
22
+ useEffect(() => {
23
+ if (!expected) return;
24
+ if (!globalThis.crypto?.subtle) { setState({ check: "unavailable", hex: "" }); return; }
25
+ let live = true;
26
+ digest(text).then(hex => live && setState(hex === expected ? { check: "match", hex } : { check: "differs", hex: "" }),
27
+ () => live && setState({ check: "unavailable", hex: "" }));
28
+ return () => { live = false; };
29
+ }, [text, expected]);
30
+ return state;
31
+ }
32
+
33
+ export const lineCount = (lines: string[]) => `${lines.length} ${lines.length === 1 ? "line" : "lines"}`;
34
+
35
+ // Long lines wrap rather than scroll, so no byte sits off screen; numbers tell a wrap from a newline.
36
+ export function Lines({ lines, from = 1, numbers = lines.length > 1 }: { lines: string[]; from?: number; numbers?: boolean }) {
37
+ const gutter = String(from + lines.length - 1).length + "ch";
38
+ return lines.map((line, i) => <span key={i} className="flex gap-2">
39
+ {numbers && <span aria-hidden style={{ width: gutter }} className="shrink-0 text-right text-muted-foreground/70 select-none">{from + i}</span>}
40
+ <span className="min-h-[1lh] min-w-0 break-all whitespace-pre-wrap">{line}</span>
41
+ </span>);
42
+ }
@@ -0,0 +1,115 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cn } from "@/lib/utils"
5
+ import { Avatar as AvatarPrimitive } from "radix-ui"
6
+
7
+ function Avatar({
8
+ className,
9
+ size = "default",
10
+ ...props
11
+ }) {
12
+ return (
13
+ <AvatarPrimitive.Root
14
+ data-slot="avatar"
15
+ data-size={size}
16
+ className={cn(
17
+ "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
18
+ className
19
+ )}
20
+ {...props}
21
+ />
22
+ )
23
+ }
24
+
25
+ function AvatarImage({
26
+ className,
27
+ ...props
28
+ }) {
29
+ return (
30
+ <AvatarPrimitive.Image
31
+ data-slot="avatar-image"
32
+ className={cn(
33
+ "aspect-square size-full rounded-full object-cover",
34
+ className
35
+ )}
36
+ {...props}
37
+ />
38
+ )
39
+ }
40
+
41
+ function AvatarFallback({
42
+ className,
43
+ ...props
44
+ }) {
45
+ return (
46
+ <AvatarPrimitive.Fallback
47
+ data-slot="avatar-fallback"
48
+ className={cn(
49
+ "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
50
+ className
51
+ )}
52
+ {...props}
53
+ />
54
+ )
55
+ }
56
+
57
+ function AvatarBadge({
58
+ className,
59
+ ...props
60
+ }) {
61
+ return (
62
+ <span
63
+ data-slot="avatar-badge"
64
+ className={cn(
65
+ "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
66
+ "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
67
+ "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
68
+ "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
69
+ className
70
+ )}
71
+ {...props}
72
+ />
73
+ )
74
+ }
75
+
76
+ function AvatarGroup({
77
+ className,
78
+ ...props
79
+ }) {
80
+ return (
81
+ <div
82
+ data-slot="avatar-group"
83
+ className={cn(
84
+ "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
85
+ className
86
+ )}
87
+ {...props}
88
+ />
89
+ )
90
+ }
91
+
92
+ function AvatarGroupCount({
93
+ className,
94
+ ...props
95
+ }) {
96
+ return (
97
+ <div
98
+ data-slot="avatar-group-count"
99
+ className={cn(
100
+ "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
101
+ className
102
+ )}
103
+ {...props}
104
+ />
105
+ )
106
+ }
107
+
108
+ export {
109
+ Avatar,
110
+ AvatarImage,
111
+ AvatarFallback,
112
+ AvatarGroup,
113
+ AvatarGroupCount,
114
+ AvatarBadge,
115
+ }
@@ -0,0 +1,47 @@
1
+ import * as React from "react"
2
+ import { cva } from "class-variance-authority";
3
+ import { cn } from "@/lib/utils"
4
+ import { Slot } from "radix-ui"
5
+
6
+ const badgeVariants = cva(
7
+ "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-md border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
12
+ secondary:
13
+ "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
14
+ destructive:
15
+ "bg-destructive/10 text-destructive dark:bg-destructive/20 [a]:hover:bg-destructive/20",
16
+ outline:
17
+ "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
18
+ ghost:
19
+ "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ },
23
+ defaultVariants: {
24
+ variant: "default",
25
+ },
26
+ }
27
+ )
28
+
29
+ function Badge({
30
+ className,
31
+ variant = "default",
32
+ asChild = false,
33
+ ...props
34
+ }) {
35
+ const Comp = asChild ? Slot.Root : "span"
36
+
37
+ return (
38
+ <Comp
39
+ data-slot="badge"
40
+ data-variant={variant}
41
+ className={cn(badgeVariants({ variant }), className)}
42
+ {...props}
43
+ />
44
+ )
45
+ }
46
+
47
+ export { Badge, badgeVariants }
@@ -0,0 +1,63 @@
1
+ import * as React from "react"
2
+ import { cva } from "class-variance-authority";
3
+ import { cn } from "@/lib/utils"
4
+ import { Slot } from "radix-ui"
5
+
6
+ const buttonVariants = cva(
7
+ "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
12
+ outline:
13
+ "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
14
+ secondary:
15
+ "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
16
+ ghost:
17
+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
18
+ destructive:
19
+ "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 dark:bg-destructive/20 dark:hover:bg-destructive/30",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ size: {
23
+ default:
24
+ "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
25
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
26
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
27
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
28
+ icon: "size-8",
29
+ "icon-xs":
30
+ "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
31
+ "icon-sm":
32
+ "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
33
+ "icon-lg": "size-9",
34
+ },
35
+ },
36
+ defaultVariants: {
37
+ variant: "default",
38
+ size: "default",
39
+ },
40
+ }
41
+ )
42
+
43
+ function Button({
44
+ className,
45
+ variant = "default",
46
+ size = "default",
47
+ asChild = false,
48
+ ...props
49
+ }) {
50
+ const Comp = asChild ? Slot.Root : "button"
51
+
52
+ return (
53
+ <Comp
54
+ data-slot="button"
55
+ data-variant={variant}
56
+ data-size={size}
57
+ className={cn(buttonVariants({ variant, size, className }))}
58
+ {...props}
59
+ />
60
+ )
61
+ }
62
+
63
+ export { Button, buttonVariants }
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { cn } from "@/lib/utils"
3
+ import { StickToBottom } from "use-stick-to-bottom"
4
+
5
+ function ChatContainerRoot({
6
+ children,
7
+ className,
8
+ ...props
9
+ }) {
10
+ return (
11
+ <StickToBottom
12
+ className={cn("flex overflow-hidden", className)}
13
+ resize="smooth"
14
+ initial="instant"
15
+ role="log"
16
+ {...props}
17
+ >
18
+ {children}
19
+ </StickToBottom>
20
+ )
21
+ }
22
+
23
+ function ChatContainerContent({
24
+ children,
25
+ className,
26
+ ...props
27
+ }) {
28
+ return (
29
+ <StickToBottom.Content
30
+ scrollClassName="overflow-y-auto overscroll-contain"
31
+ className={cn("flex w-full flex-col", className)}
32
+ {...props}
33
+ >
34
+ {children}
35
+ </StickToBottom.Content>
36
+ )
37
+ }
38
+
39
+ function ChatContainerScrollAnchor({
40
+ className,
41
+ ...props
42
+ }) {
43
+ return (
44
+ <div
45
+ className={cn("h-px w-full shrink-0 scroll-mt-4", className)}
46
+ aria-hidden="true"
47
+ {...props}
48
+ />
49
+ )
50
+ }
51
+
52
+ export { ChatContainerRoot, ChatContainerContent, ChatContainerScrollAnchor }
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { useId, type ReactNode } from "react";
3
+ import { Check } from "lucide-react";
4
+ import { Checkbox, CheckboxGroup, CheckboxIndicator } from "@ui-sdk/react/checkbox";
5
+ import { Radio, RadioGroup, RadioIndicator } from "@ui-sdk/react/radio";
6
+ import { cn } from "@/lib/utils";
7
+
8
+ export type ChoiceOption = { label: string; description?: string; preview?: string };
9
+
10
+ // The whole row is the radio or checkbox; the inset shadow thickens the selected border without moving the content.
11
+ const ROW = cn("group flex min-h-11 w-full min-w-0 cursor-pointer items-start gap-3 rounded-lg border border-border px-3 py-2.5 text-left transition-colors",
12
+ "hover:bg-accent data-[checked]:border-primary data-[checked]:bg-primary/8 data-[checked]:shadow-[inset_0_0_0_1px_var(--primary)] data-[checked]:hover:bg-primary/12",
13
+ "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-60 data-[disabled]:hover:bg-transparent");
14
+ const MARK = "mt-0.5 grid size-4 shrink-0 place-items-center border border-muted-foreground/70 bg-background group-data-[checked]:border-primary group-data-[checked]:bg-primary";
15
+
16
+ function Body({ id, option }: { id: string; option: ChoiceOption }) {
17
+ return <span className="flex min-w-0 flex-1 flex-col gap-0.5">
18
+ <span id={id + "-label"} className="text-sm leading-snug font-medium wrap-anywhere text-foreground">{option.label}</span>
19
+ {option.description && <span id={id + "-description"} className="text-sm leading-snug wrap-anywhere text-muted-foreground">{option.description}</span>}
20
+ {option.preview && <span className="mt-1 block max-h-32 overflow-auto rounded-md border bg-muted/50 px-2 py-1 font-mono text-xs wrap-anywhere whitespace-pre-wrap text-foreground">{option.preview}</span>}
21
+ </span>;
22
+ }
23
+
24
+ /** A question and its options as full-row radios, or checkboxes when multiSelect; the group is named by the question. */
25
+ export function ChoiceList({ question, options, multiSelect = false, value, onValueChange, disabled = false, children }: {
26
+ question?: ReactNode; options: ChoiceOption[]; multiSelect?: boolean; value: string[];
27
+ onValueChange: (value: string[]) => void; disabled?: boolean; children?: ReactNode;
28
+ }) {
29
+ const id = useId();
30
+ const named = (index: number, option: ChoiceOption) => ({
31
+ "aria-labelledby": `${id}-${index}-label`,
32
+ ...(option.description ? { "aria-describedby": `${id}-${index}-description` } : {}),
33
+ });
34
+ return <div className="flex min-w-0 flex-col gap-2.5">
35
+ <div className="flex min-w-0 flex-col gap-0.5">
36
+ {question && <p id={id + "-question"} className="text-[0.9375rem] leading-snug font-semibold wrap-anywhere text-foreground">{question}</p>}
37
+ <p id={id + "-hint"} className="text-xs text-muted-foreground">{multiSelect ? "Pick any" : "Pick one"}</p>
38
+ </div>
39
+ {multiSelect
40
+ ? <CheckboxGroup value={value} onValueChange={next => onValueChange(next)} disabled={disabled}
41
+ aria-labelledby={id + "-question"} aria-describedby={id + "-hint"} className="flex flex-col gap-1.5">
42
+ {options.map((option, index) => <Checkbox key={option.label} value={option.label} className={ROW} {...named(index, option)}>
43
+ <span aria-hidden className={cn(MARK, "rounded-[3px]")}>
44
+ <CheckboxIndicator className="text-primary-foreground"><Check className="size-3" strokeWidth={3}/></CheckboxIndicator>
45
+ </span>
46
+ <Body id={`${id}-${index}`} option={option}/>
47
+ </Checkbox>)}
48
+ </CheckboxGroup>
49
+ : <RadioGroup value={value[0] ?? null} onValueChange={next => onValueChange(next ? [next] : [])} disabled={disabled}
50
+ aria-labelledby={id + "-question"} aria-describedby={id + "-hint"} className="flex flex-col gap-1.5">
51
+ {options.map((option, index) => <Radio key={option.label} value={option.label} className={ROW} {...named(index, option)}>
52
+ <span aria-hidden className={cn(MARK, "rounded-full")}>
53
+ <RadioIndicator className="size-1.5 rounded-full bg-primary-foreground"/>
54
+ </span>
55
+ <Body id={`${id}-${index}`} option={option}/>
56
+ </Radio>)}
57
+ </RadioGroup>}
58
+ {children}
59
+ </div>;
60
+ }
61
+
62
+ /** A closed question: the question, then the chosen answers with a check. */
63
+ export function ChoiceSummary({ question, chosen }: { question?: ReactNode; chosen: string[] }) {
64
+ return <div className="flex min-w-0 flex-col gap-1">
65
+ {question && <p className="text-sm leading-snug wrap-anywhere text-muted-foreground">{question}</p>}
66
+ {chosen.length > 0 && <ul className="flex min-w-0 flex-col gap-0.5">
67
+ {chosen.map(label => <li key={label} className="flex min-w-0 items-start gap-1.5 text-sm font-medium text-foreground">
68
+ <Check aria-hidden className="mt-0.5 size-4 shrink-0 text-primary"/><span className="min-w-0 wrap-anywhere">{label}</span>
69
+ </li>)}
70
+ </ul>}
71
+ </div>;
72
+ }