netra-artifacts 0.1.0-alpha.0 → 0.1.0-alpha.10

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 (176) hide show
  1. package/CHANGELOG.md +59 -1
  2. package/README.md +59 -54
  3. package/dist/artifacts/htmlArtifact.d.ts +1 -0
  4. package/dist/artifacts/htmlArtifact.d.ts.map +1 -1
  5. package/dist/artifacts/htmlArtifact.js +1 -0
  6. package/dist/artifacts/htmlArtifact.js.map +1 -1
  7. package/dist/classifier/classifierPrompt.d.ts +1 -1
  8. package/dist/classifier/classifierPrompt.d.ts.map +1 -1
  9. package/dist/classifier/classifierPrompt.js +26 -25
  10. package/dist/classifier/classifierPrompt.js.map +1 -1
  11. package/dist/classifier/rules.d.ts.map +1 -1
  12. package/dist/classifier/rules.js +3 -0
  13. package/dist/classifier/rules.js.map +1 -1
  14. package/dist/client/ArtifactChat.d.ts +7 -0
  15. package/dist/client/ArtifactChat.d.ts.map +1 -1
  16. package/dist/client/ArtifactChat.js +29 -2
  17. package/dist/client/ArtifactChat.js.map +1 -1
  18. package/dist/client/ArtifactMessage.d.ts.map +1 -1
  19. package/dist/client/ArtifactMessage.js +1 -1
  20. package/dist/client/ArtifactMessage.js.map +1 -1
  21. package/dist/client/index.d.ts +1 -0
  22. package/dist/client/index.d.ts.map +1 -1
  23. package/dist/client/index.js +1 -0
  24. package/dist/client/index.js.map +1 -1
  25. package/dist/client/starterPrompts.d.ts +28 -0
  26. package/dist/client/starterPrompts.d.ts.map +1 -0
  27. package/dist/client/starterPrompts.js +100 -0
  28. package/dist/client/starterPrompts.js.map +1 -0
  29. package/dist/client/useArtifactStream.d.ts +1 -1
  30. package/dist/client/useArtifactStream.d.ts.map +1 -1
  31. package/dist/client/useArtifactStream.js +15 -3
  32. package/dist/client/useArtifactStream.js.map +1 -1
  33. package/dist/constants/defaults.d.ts.map +1 -1
  34. package/dist/constants/defaults.js +4 -0
  35. package/dist/constants/defaults.js.map +1 -1
  36. package/dist/constants/index.d.ts +1 -0
  37. package/dist/constants/index.d.ts.map +1 -1
  38. package/dist/constants/index.js +1 -0
  39. package/dist/constants/index.js.map +1 -1
  40. package/dist/constants/sandbox.d.ts +5 -7
  41. package/dist/constants/sandbox.d.ts.map +1 -1
  42. package/dist/constants/sandbox.js +5 -8
  43. package/dist/constants/sandbox.js.map +1 -1
  44. package/dist/constants/trustedCdnHosts.d.ts +27 -0
  45. package/dist/constants/trustedCdnHosts.d.ts.map +1 -0
  46. package/dist/constants/trustedCdnHosts.js +58 -0
  47. package/dist/constants/trustedCdnHosts.js.map +1 -0
  48. package/dist/core/lifecycle.d.ts +4 -1
  49. package/dist/core/lifecycle.d.ts.map +1 -1
  50. package/dist/core/lifecycle.js +4 -2
  51. package/dist/core/lifecycle.js.map +1 -1
  52. package/dist/iframe/HtmlArtifactCard.d.ts.map +1 -1
  53. package/dist/iframe/HtmlArtifactCard.js +2 -1
  54. package/dist/iframe/HtmlArtifactCard.js.map +1 -1
  55. package/dist/iframe/HtmlArtifactPreview.d.ts.map +1 -1
  56. package/dist/iframe/HtmlArtifactPreview.js +122 -11
  57. package/dist/iframe/HtmlArtifactPreview.js.map +1 -1
  58. package/dist/iframe/iframeSizing.d.ts +2 -1
  59. package/dist/iframe/iframeSizing.d.ts.map +1 -1
  60. package/dist/iframe/iframeSizing.js +21 -1
  61. package/dist/iframe/iframeSizing.js.map +1 -1
  62. package/dist/iframe/iframeSrcDoc.d.ts +10 -4
  63. package/dist/iframe/iframeSrcDoc.d.ts.map +1 -1
  64. package/dist/iframe/iframeSrcDoc.js +188 -50
  65. package/dist/iframe/iframeSrcDoc.js.map +1 -1
  66. package/dist/prompts/htmlArtifactPrompt.d.ts +8 -0
  67. package/dist/prompts/htmlArtifactPrompt.d.ts.map +1 -1
  68. package/dist/prompts/htmlArtifactPrompt.js +209 -77
  69. package/dist/prompts/htmlArtifactPrompt.js.map +1 -1
  70. package/dist/prompts/index.d.ts +1 -0
  71. package/dist/prompts/index.d.ts.map +1 -1
  72. package/dist/prompts/index.js +1 -0
  73. package/dist/prompts/index.js.map +1 -1
  74. package/dist/prompts/threejsGamePrompt.d.ts +17 -0
  75. package/dist/prompts/threejsGamePrompt.d.ts.map +1 -0
  76. package/dist/prompts/threejsGamePrompt.js +233 -0
  77. package/dist/prompts/threejsGamePrompt.js.map +1 -0
  78. package/dist/sanitizer/dangerousPatterns.d.ts +2 -1
  79. package/dist/sanitizer/dangerousPatterns.d.ts.map +1 -1
  80. package/dist/sanitizer/dangerousPatterns.js +2 -1
  81. package/dist/sanitizer/dangerousPatterns.js.map +1 -1
  82. package/dist/sanitizer/sanitizeConfig.d.ts.map +1 -1
  83. package/dist/sanitizer/sanitizeConfig.js +1 -4
  84. package/dist/sanitizer/sanitizeConfig.js.map +1 -1
  85. package/dist/sanitizer/sanitizeHtml.d.ts.map +1 -1
  86. package/dist/sanitizer/sanitizeHtml.js +251 -4
  87. package/dist/sanitizer/sanitizeHtml.js.map +1 -1
  88. package/dist/server/config.d.ts.map +1 -1
  89. package/dist/server/config.js +12 -1
  90. package/dist/server/config.js.map +1 -1
  91. package/dist/server/createArtifactStreamResponse.js +3 -0
  92. package/dist/server/createArtifactStreamResponse.js.map +1 -1
  93. package/dist/server/createHtmlArtifactStream.d.ts +2 -0
  94. package/dist/server/createHtmlArtifactStream.d.ts.map +1 -1
  95. package/dist/server/createHtmlArtifactStream.js +4 -1
  96. package/dist/server/createHtmlArtifactStream.js.map +1 -1
  97. package/dist/stream/buffering.d.ts +1 -1
  98. package/dist/stream/buffering.d.ts.map +1 -1
  99. package/dist/stream/buffering.js +6 -1
  100. package/dist/stream/buffering.js.map +1 -1
  101. package/dist/stream/events.d.ts +1 -1
  102. package/dist/stream/events.d.ts.map +1 -1
  103. package/dist/stream/events.js +2 -1
  104. package/dist/stream/events.js.map +1 -1
  105. package/dist/stream/predictiveHtmlParser.d.ts.map +1 -1
  106. package/dist/stream/predictiveHtmlParser.js +13 -3
  107. package/dist/stream/predictiveHtmlParser.js.map +1 -1
  108. package/dist/types/artifact.d.ts +6 -0
  109. package/dist/types/artifact.d.ts.map +1 -1
  110. package/dist/types/client.d.ts +11 -4
  111. package/dist/types/client.d.ts.map +1 -1
  112. package/dist/types/config.d.ts +17 -3
  113. package/dist/types/config.d.ts.map +1 -1
  114. package/dist/types/server.d.ts +14 -1
  115. package/dist/types/server.d.ts.map +1 -1
  116. package/dist/types/stream.d.ts +2 -0
  117. package/dist/types/stream.d.ts.map +1 -1
  118. package/dist-cjs/artifacts/htmlArtifact.js +1 -0
  119. package/dist-cjs/artifacts/htmlArtifact.js.map +1 -1
  120. package/dist-cjs/classifier/classifierPrompt.js +26 -25
  121. package/dist-cjs/classifier/classifierPrompt.js.map +1 -1
  122. package/dist-cjs/classifier/rules.js +3 -0
  123. package/dist-cjs/classifier/rules.js.map +1 -1
  124. package/dist-cjs/client/ArtifactChat.js +29 -2
  125. package/dist-cjs/client/ArtifactChat.js.map +1 -1
  126. package/dist-cjs/client/ArtifactMessage.js +1 -1
  127. package/dist-cjs/client/ArtifactMessage.js.map +1 -1
  128. package/dist-cjs/client/index.js +3 -1
  129. package/dist-cjs/client/index.js.map +1 -1
  130. package/dist-cjs/client/starterPrompts.js +103 -0
  131. package/dist-cjs/client/starterPrompts.js.map +1 -0
  132. package/dist-cjs/client/useArtifactStream.js +15 -3
  133. package/dist-cjs/client/useArtifactStream.js.map +1 -1
  134. package/dist-cjs/constants/defaults.js +4 -0
  135. package/dist-cjs/constants/defaults.js.map +1 -1
  136. package/dist-cjs/constants/index.js +1 -0
  137. package/dist-cjs/constants/index.js.map +1 -1
  138. package/dist-cjs/constants/sandbox.js +5 -8
  139. package/dist-cjs/constants/sandbox.js.map +1 -1
  140. package/dist-cjs/constants/trustedCdnHosts.js +63 -0
  141. package/dist-cjs/constants/trustedCdnHosts.js.map +1 -0
  142. package/dist-cjs/core/lifecycle.js +4 -2
  143. package/dist-cjs/core/lifecycle.js.map +1 -1
  144. package/dist-cjs/iframe/HtmlArtifactCard.js +2 -1
  145. package/dist-cjs/iframe/HtmlArtifactCard.js.map +1 -1
  146. package/dist-cjs/iframe/HtmlArtifactPreview.js +122 -11
  147. package/dist-cjs/iframe/HtmlArtifactPreview.js.map +1 -1
  148. package/dist-cjs/iframe/iframeSizing.js +21 -1
  149. package/dist-cjs/iframe/iframeSizing.js.map +1 -1
  150. package/dist-cjs/iframe/iframeSrcDoc.js +187 -49
  151. package/dist-cjs/iframe/iframeSrcDoc.js.map +1 -1
  152. package/dist-cjs/prompts/htmlArtifactPrompt.js +209 -77
  153. package/dist-cjs/prompts/htmlArtifactPrompt.js.map +1 -1
  154. package/dist-cjs/prompts/index.js +1 -0
  155. package/dist-cjs/prompts/index.js.map +1 -1
  156. package/dist-cjs/prompts/threejsGamePrompt.js +237 -0
  157. package/dist-cjs/prompts/threejsGamePrompt.js.map +1 -0
  158. package/dist-cjs/sanitizer/dangerousPatterns.js +2 -1
  159. package/dist-cjs/sanitizer/dangerousPatterns.js.map +1 -1
  160. package/dist-cjs/sanitizer/sanitizeConfig.js +1 -4
  161. package/dist-cjs/sanitizer/sanitizeConfig.js.map +1 -1
  162. package/dist-cjs/sanitizer/sanitizeHtml.js +251 -4
  163. package/dist-cjs/sanitizer/sanitizeHtml.js.map +1 -1
  164. package/dist-cjs/server/config.js +12 -1
  165. package/dist-cjs/server/config.js.map +1 -1
  166. package/dist-cjs/server/createArtifactStreamResponse.js +3 -0
  167. package/dist-cjs/server/createArtifactStreamResponse.js.map +1 -1
  168. package/dist-cjs/server/createHtmlArtifactStream.js +4 -1
  169. package/dist-cjs/server/createHtmlArtifactStream.js.map +1 -1
  170. package/dist-cjs/stream/buffering.js +6 -1
  171. package/dist-cjs/stream/buffering.js.map +1 -1
  172. package/dist-cjs/stream/events.js +2 -1
  173. package/dist-cjs/stream/events.js.map +1 -1
  174. package/dist-cjs/stream/predictiveHtmlParser.js +13 -3
  175. package/dist-cjs/stream/predictiveHtmlParser.js.map +1 -1
  176. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,8 +1,66 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to `netra` are documented here. This project
3
+ All notable changes to `netra-artifacts` are documented here. This project
4
4
  adheres to [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [Unreleased]
7
+
8
+ ### Added
9
+
10
+ - **Starter prompt templates.** `STARTER_PROMPTS` (exported from
11
+ `netra-artifacts/client`) ships 8 prebuilt templates — each a short show
12
+ `label` plus a rich `prompt` actually sent to the model — covering an HTML
13
+ artifact, markdown answer, three.js game, generative-UI-from-JSON, image-rich
14
+ page, YouTube video page, pricing page, and sign-up form. `ArtifactChat`
15
+ renders them as chips below the composer; each carries per-request `body`
16
+ overrides (`mode`/`game`/`allowVideoEmbeds`/…) now merged by `sendMessage`'s
17
+ new second argument. Pass `starterPrompts={[]}` to hide them.
18
+ - **Single-file three.js games.** New `allowModuleImports` sanitize/preview flag
19
+ keeps a `<script type="importmap">` whose targets resolve to a trusted,
20
+ version-pinned ESM CDN (`esm.sh`, `cdn.jsdelivr.net`, `unpkg.com`,
21
+ `cdn.skypack.dev`), so a self-contained game can `import … from "three"` with
22
+ no build step. The game frame runs in the isolated `allow-scripts` sandbox
23
+ (no `allow-same-origin`) with a defense-in-depth CSP pinning script/connect to
24
+ those CDNs. New `game` server option switches the HTML prompt to a dedicated
25
+ three.js game builder (pinned import map + module + fixed-timestep loop) and
26
+ implies `allowModuleImports`. New `threejs-games` agent skill + single-file
27
+ setup guidance in `threejs-fundamentals`.
28
+
29
+ ### Changed
30
+
31
+ - Trusted YouTube embeds and inline JavaScript are now explicit opt-ins. The
32
+ script-capable iframe sandbox omits `allow-same-origin`, and an internal
33
+ postMessage resize bridge keeps isolated video/script previews auto-sized.
34
+ - HTML-artifact prompt reworked to a **hybrid styling model**: one small shared
35
+ `<style>` design system (box-sizing reset + fluid `clamp()` type/space scale +
36
+ element defaults + `.wrap/.stack/.grid/.row/.card/.scroll-x` utility classes)
37
+ plus inline `style=""` for per-element specifics, with an optional 1–2 `@media`
38
+ breakpoints as a third tier. Cuts repeated inline markup and yields
39
+ compact-on-mobile, comfortable-on-desktop layouts. (`<style>` was always
40
+ sanitizer-allowed; the prompt previously forbade it for streaming reasons.)
41
+ - Camouflage/seamless rendering now **preserves inner card surfaces**: only
42
+ `html`/`body` are forced transparent so the page blends into the host, while
43
+ data cards keep their own backgrounds, gradients, text, and border colours
44
+ (previously every block element was force-transparented, flattening the UI).
45
+ The seamless prompt now requires visible card surfaces.
46
+
47
+ ### Fixed
48
+
49
+ - Artifacts that pinned the root to the viewport (`height:100%`,
50
+ `min-height:100vh`) collapsed to ~0 height in the auto-sizing iframe and
51
+ rendered blank. `SEAMLESS_BASE` and the camouflage pass now force
52
+ `html,body{height:auto;min-height:0}`, and the prompt forbids viewport-relative
53
+ root heights (the artifact is auto-sized to content).
54
+ - `position:sticky`/`position:fixed` ghosting over scrolled content, and CSS
55
+ leaking as visible text when a data-URI `<svg>` (or backslash-escaped quotes)
56
+ was placed inside a `style` attribute — both now hard rules in the prompt and
57
+ the `html-practices` skill.
58
+ - Camouflage CSS normalizer is now brace-aware: nested `@media`/`@supports`/
59
+ `@container` blocks are preserved and their inner rules normalized, instead of
60
+ being mangled by a flat regex.
61
+ - Theme-aware custom scrollbars are injected into the artifact iframe (tinted
62
+ from `--foreground`/`--fg`), so inner scroll containers match the palette.
63
+
6
64
  ## [0.1.0] - 2026-05-29
7
65
 
8
66
  ### Added
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Netra Predictive HTML Parser
2
2
 
3
- Experimental dependency-free package for streaming AI-generated HTML into
4
- sandboxed iframe previews. Bring any model SDK that can produce text chunks.
5
-
6
- The high-level server helper is provider-agnostic: pass a
7
- `generateTextStream(args) => AsyncIterable<string>` adapter. For lower-level
8
- integrations, `streamHtmlArtifactFromTextStream` accepts raw text chunks
9
- directly.
3
+ Experimental dependency-free package for streaming AI-generated HTML into
4
+ sandboxed iframe previews. Bring any model SDK that can produce text chunks.
5
+
6
+ The high-level server helper is provider-agnostic: pass a
7
+ `generateTextStream(args) => AsyncIterable<string>` adapter. For lower-level
8
+ integrations, `streamHtmlArtifactFromTextStream` accepts raw text chunks
9
+ directly.
10
10
 
11
11
  Netra keeps two versions of streamed HTML:
12
12
 
@@ -19,38 +19,41 @@ document.
19
19
 
20
20
  ## Install
21
21
 
22
- ```bash
23
- npm install netra
24
- ```
25
-
26
- Add whatever provider SDK you want:
27
-
28
- ```bash
29
- npm install @ai-sdk/google
30
- ```
22
+ ```bash
23
+ npm install netra-artifacts
24
+ ```
25
+
26
+ Add whatever provider SDK you want:
27
+
28
+ ```bash
29
+ npm install @ai-sdk/google
30
+ ```
31
31
 
32
32
  ## Backend
33
33
 
34
- ```ts
35
- import { createGoogleGenerativeAI } from "@ai-sdk/google";
36
- import { generateText, streamText } from "ai";
37
- import { createArtifactStreamResponse } from "netra/server";
38
-
39
- const google = createGoogleGenerativeAI({
40
- apiKey: process.env.GOOGLE_API_KEY,
41
- });
42
-
43
- export async function POST(req: Request) {
44
- const { messages } = await req.json();
45
- const model = google("gemini-2.5-flash");
46
-
47
- return createArtifactStreamResponse({
48
- messages,
49
- generateTextStream: (args) => streamText({ model, ...args }).textStream,
50
- generateText: async (args) => (await generateText({ model, ...args })).text,
51
- mode: "auto",
52
- snapshotIntervalMs: 0,
53
- allowExternalFonts: true,
34
+ ```ts
35
+ import { createGoogleGenerativeAI } from "@ai-sdk/google";
36
+ import { generateText, streamText } from "ai";
37
+ import { createArtifactStreamResponse } from "netra-artifacts/server";
38
+
39
+ const google = createGoogleGenerativeAI({
40
+ apiKey: process.env.GOOGLE_API_KEY,
41
+ });
42
+
43
+ export async function POST(req: Request) {
44
+ // Spread the body so per-request fields from the client (mode, game,
45
+ // allowVideoEmbeds, allowModuleImports) — e.g. those sent by the built-in
46
+ // starter prompts — are forwarded into the options.
47
+ const body = await req.json();
48
+ const model = google("gemini-2.5-flash");
49
+
50
+ return createArtifactStreamResponse({
51
+ ...body,
52
+ generateTextStream: (args) => streamText({ model, ...args }).textStream,
53
+ generateText: async (args) => (await generateText({ model, ...args })).text,
54
+ mode: body.mode ?? "auto",
55
+ snapshotIntervalMs: 0,
56
+ allowExternalFonts: true,
54
57
  });
55
58
  }
56
59
  ```
@@ -63,7 +66,7 @@ import {
63
66
  createSseResponse,
64
67
  event,
65
68
  streamHtmlArtifactFromTextStream,
66
- } from "netra/server";
69
+ } from "netra-artifacts/server";
67
70
 
68
71
  async function* toText(chunks: AsyncIterable<unknown>) {
69
72
  for await (const chunk of chunks) {
@@ -98,6 +101,7 @@ export async function POST(req: Request) {
98
101
  allowStyleTags: true,
99
102
  allowSvg: true,
100
103
  allowExternalFonts: false,
104
+ allowVideoEmbeds: false,
101
105
  },
102
106
  snapshotIntervalMs: 0,
103
107
  },
@@ -114,7 +118,7 @@ export async function POST(req: Request) {
114
118
  ```tsx
115
119
  "use client";
116
120
 
117
- import { ArtifactMessage, useArtifactStream } from "netra/client";
121
+ import { ArtifactMessage, useArtifactStream } from "netra-artifacts/client";
118
122
 
119
123
  export function Chat() {
120
124
  const { messages, artifacts, status, sendMessage } = useArtifactStream({
@@ -153,7 +157,7 @@ export function Chat() {
153
157
  ## Direct Parser Usage
154
158
 
155
159
  ```ts
156
- import { PredictiveHtmlParser } from "netra/stream";
160
+ import { PredictiveHtmlParser } from "netra-artifacts/stream";
157
161
 
158
162
  const parser = new PredictiveHtmlParser();
159
163
 
@@ -170,7 +174,7 @@ const frameB = parser.push('<input type="email" />');
170
174
  ## One-Shot Assembly
171
175
 
172
176
  ```ts
173
- import { assembleStreamingHtml } from "netra/stream";
177
+ import { assembleStreamingHtml } from "netra-artifacts/stream";
174
178
 
175
179
  const result = assembleStreamingHtml("<html><body><main><h1>Hello");
176
180
 
@@ -185,14 +189,14 @@ result.renderable;
185
189
 
186
190
  | Import | Purpose |
187
191
  | --- | --- |
188
- | `netra` | Isomorphic helpers, types, parser, sanitizer |
189
- | `netra/server` | Server response helpers for SSE |
190
- | `netra/client` | React hook and UI components |
191
- | `netra/iframe` | Iframe card and preview primitives |
192
- | `netra/stream` | Parser, SSE, buffering utilities |
193
- | `netra/sanitizer` | Sanitizer helpers |
194
- | `netra/classifier` | Auto-mode classifier |
195
- | `netra/types` | Public types |
192
+ | `netra-artifacts` | Isomorphic helpers, types, parser, sanitizer |
193
+ | `netra-artifacts/server` | Server response helpers for SSE |
194
+ | `netra-artifacts/client` | React hook and UI components |
195
+ | `netra-artifacts/iframe` | Iframe card and preview primitives |
196
+ | `netra-artifacts/stream` | Parser, SSE, buffering utilities |
197
+ | `netra-artifacts/sanitizer` | Sanitizer helpers |
198
+ | `netra-artifacts/classifier` | Auto-mode classifier |
199
+ | `netra-artifacts/types` | Public types |
196
200
 
197
201
  ## Protocol
198
202
 
@@ -212,17 +216,18 @@ type ArtifactStreamEvent =
212
216
 
213
217
  ## Security
214
218
 
215
- Artifacts are static HTML/CSS:
219
+ Artifacts are static HTML/CSS by default:
216
220
 
217
- - Scripts are stripped
221
+ - Scripts are stripped unless `allowScripts` is explicitly enabled
218
222
  - Event handler attributes are stripped
219
223
  - Dangerous URLs are stripped
220
- - Iframes, embeds, object tags, and refresh meta tags are stripped
221
- - The preview iframe never receives `allow-scripts`
224
+ - Iframes, embeds, object tags, and refresh meta tags are stripped unless `allowVideoEmbeds` keeps a normalized trusted YouTube iframe
225
+ - `<script type="importmap">` is stripped unless `allowModuleImports` is set, and then only mappings that resolve to a trusted, version-pinned ESM CDN survive — enabling single-file ESM games (e.g. three.js) with a defense-in-depth CSP on the frame
226
+ - The preview iframe receives `allow-scripts` only for opt-in inline scripts, trusted video embeds, or module-import games, and that script-capable path omits `allow-same-origin`
222
227
  - `allowExternalFonts` only keeps approved Google Fonts hosts
223
228
 
224
- Use Netra for safe previews of generated static HTML, not for executing
225
- generated application logic.
229
+ Use Netra's default mode for safe previews of generated static HTML. Opt into
230
+ scripts only for artifacts you are comfortable executing in an isolated iframe.
226
231
 
227
232
  ## Checks
228
233
 
@@ -4,6 +4,7 @@ export declare function createHtmlArtifact(params: {
4
4
  id: string;
5
5
  title?: string;
6
6
  status?: ArtifactStatus;
7
+ camouflage?: boolean;
7
8
  }): HtmlArtifact;
8
9
  /** Immutably apply a partial update, refreshing `updatedAt`. */
9
10
  export declare function updateHtmlArtifact(artifact: HtmlArtifact, patch: Partial<Omit<HtmlArtifact, "id" | "type" | "createdAt">>): HtmlArtifact;
@@ -1 +1 @@
1
- {"version":3,"file":"htmlArtifact.d.ts","sourceRoot":"","sources":["../../src/artifacts/htmlArtifact.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEzE,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,GAAG,YAAY,CAYf;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC,GAC9D,YAAY,CAEd"}
1
+ {"version":3,"file":"htmlArtifact.d.ts","sourceRoot":"","sources":["../../src/artifacts/htmlArtifact.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEzE,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,YAAY,CAaf;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC,GAC9D,YAAY,CAEd"}
@@ -8,6 +8,7 @@ export function createHtmlArtifact(params) {
8
8
  type: "html",
9
9
  html: "",
10
10
  snapshot: "",
11
+ camouflage: params.camouflage,
11
12
  status: params.status ?? ARTIFACT_STATUS.STREAMING,
12
13
  createdAt: now,
13
14
  updatedAt: now,
@@ -1 +1 @@
1
- {"version":3,"file":"htmlArtifact.js","sourceRoot":"","sources":["../../src/artifacts/htmlArtifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,+DAA+D;AAC/D,MAAM,UAAU,kBAAkB,CAAC,MAIlC;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,mBAAmB;QAC1C,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,eAAe,CAAC,SAAS;QAClD,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,kBAAkB,CAChC,QAAsB,EACtB,KAA+D;IAE/D,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"file":"htmlArtifact.js","sourceRoot":"","sources":["../../src/artifacts/htmlArtifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,+DAA+D;AAC/D,MAAM,UAAU,kBAAkB,CAAC,MAKlC;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,mBAAmB;QAC1C,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,eAAe,CAAC,SAAS;QAClD,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,kBAAkB,CAChC,QAAsB,EACtB,KAA+D;IAE/D,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAC1D,CAAC"}
@@ -2,6 +2,6 @@
2
2
  * The classifier prompt. The model must return ONLY JSON of the shape
3
3
  * `{ "mode": "markdown" | "artifact" | "generative_ui", "reason": "short reason" }`.
4
4
  */
5
- export declare const CLASSIFIER_SYSTEM_PROMPT = "You are a routing classifier for an AI assistant that can answer in three ways:\n\n1. \"markdown\" \u2014 a normal text/markdown chat answer.\n2. \"artifact\" \u2014 a standalone, self-contained, STATIC HTML/CSS document rendered in a framed preview card (no JavaScript).\n3. \"generative_ui\" \u2014 a chromeless, transparent, STATIC HTML/CSS UI rendered inline so it blends with the host app (no JavaScript).\n\nDecide which mode best serves the user's most recent request.\n\nChoose \"markdown\" when text is enough:\n- explanations, Q&A, definitions, summaries\n- debugging help, error analysis, code review\n- writing code, functions, queries, scripts\n- system design, architecture, best practices, advice\n- comparisons that read fine as prose or a small table\n- general writing and conversation\n\nChoose \"artifact\" when a visual, standalone document/page adds real value:\n- standalone forms (sign-up, login, contact, survey)\n- landing pages, hero sections, pricing cards, product pages\n- dashboards, stat grids, report/stat visualizations\n- invoices, receipts, certificates, resumes/CVs\n- email/newsletter templates\n- profile/business cards, onboarding screens\n- comparison cards, timelines, funnels, galleries\n- CSS/SVG charts (bar, line, donut, progress) when the user wants a visual\n\nChoose \"generative_ui\" when the user specifically wants UI that should feel native/inline in the host app:\n- generative UI, inline UI, seamless/camouflaged/native UI\n- widgets, components, interface states, UI kits/systems, component variations\n- app/interface prototypes or explorations intended to sit inside the chat surface\n\nBe conservative: if the request is primarily about understanding, reasoning, or code, prefer \"markdown\". Do not pick an HTML mode just because a topic could be visualized \u2014 only when the user actually wants a rendered UI/document.\n\nReturn ONLY minified JSON, no prose, no code fences:\n{\"mode\":\"markdown\"|\"artifact\"|\"generative_ui\",\"reason\":\"short reason\"}";
5
+ export declare const CLASSIFIER_SYSTEM_PROMPT = "You are a routing classifier for an AI assistant that can answer in three ways:\n\n1. \"markdown\" \u2014 a normal text/markdown chat answer.\n2. \"artifact\" \u2014 a standalone, self-contained, STATIC HTML/CSS document rendered in a framed preview card (no JavaScript).\n3. \"generative_ui\" \u2014 a chromeless, transparent, STATIC HTML/CSS UI rendered inline so it blends with the host app (no JavaScript).\n\nDecide which mode best serves the user's most recent request.\n\nChoose \"markdown\" when text is enough:\n- explanations, Q&A, definitions, summaries\n- debugging help, error analysis, code review\n- writing code, functions, queries, scripts\n- system design, architecture, best practices, advice\n- comparisons that read fine as prose or a small table\n- general writing and conversation\n\nChoose \"artifact\" when a visual, standalone document/page adds real value:\n- standalone forms (sign-up, login, contact, survey)\n- landing pages, hero sections, pricing cards, product pages\n- dashboards, stat grids, report/stat visualizations\n- invoices, receipts, certificates, resumes/CVs\n- email/newsletter templates\n- profile/business cards, onboarding screens\n- comparison cards, timelines, funnels, galleries\n- video/youtube player embeds when the user supplies or asks for a video link\n- CSS/SVG charts (bar, line, donut, progress) when the user wants a visual\n\nChoose \"generative_ui\" when the user specifically wants UI that should feel native/inline in the host app:\n- generative UI, inline UI, seamless/camouflaged/native UI\n- widgets, components, interface states, UI kits/systems, component variations\n- app/interface prototypes or explorations intended to sit inside the chat surface\n\nBe conservative: if the request is primarily about understanding, reasoning, or code, prefer \"markdown\". Do not pick an HTML mode just because a topic could be visualized \u2014 only when the user actually wants a rendered UI/document.\n\nReturn ONLY minified JSON, no prose, no code fences:\n{\"mode\":\"markdown\"|\"artifact\"|\"generative_ui\",\"reason\":\"short reason\"}";
6
6
  export declare function buildClassifierUserPrompt(query: string): string;
7
7
  //# sourceMappingURL=classifierPrompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"classifierPrompt.d.ts","sourceRoot":"","sources":["../../src/classifier/classifierPrompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,2+DAkCkC,CAAC;AAExE,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D"}
1
+ {"version":3,"file":"classifierPrompt.d.ts","sourceRoot":"","sources":["../../src/classifier/classifierPrompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,0jEAmCkC,CAAC;AAExE,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D"}
@@ -2,40 +2,41 @@
2
2
  * The classifier prompt. The model must return ONLY JSON of the shape
3
3
  * `{ "mode": "markdown" | "artifact" | "generative_ui", "reason": "short reason" }`.
4
4
  */
5
- export const CLASSIFIER_SYSTEM_PROMPT = `You are a routing classifier for an AI assistant that can answer in three ways:
6
-
7
- 1. "markdown" — a normal text/markdown chat answer.
8
- 2. "artifact" — a standalone, self-contained, STATIC HTML/CSS document rendered in a framed preview card (no JavaScript).
9
- 3. "generative_ui" — a chromeless, transparent, STATIC HTML/CSS UI rendered inline so it blends with the host app (no JavaScript).
10
-
11
- Decide which mode best serves the user's most recent request.
12
-
5
+ export const CLASSIFIER_SYSTEM_PROMPT = `You are a routing classifier for an AI assistant that can answer in three ways:
6
+
7
+ 1. "markdown" — a normal text/markdown chat answer.
8
+ 2. "artifact" — a standalone, self-contained, STATIC HTML/CSS document rendered in a framed preview card (no JavaScript).
9
+ 3. "generative_ui" — a chromeless, transparent, STATIC HTML/CSS UI rendered inline so it blends with the host app (no JavaScript).
10
+
11
+ Decide which mode best serves the user's most recent request.
12
+
13
13
  Choose "markdown" when text is enough:
14
14
  - explanations, Q&A, definitions, summaries
15
15
  - debugging help, error analysis, code review
16
16
  - writing code, functions, queries, scripts
17
17
  - system design, architecture, best practices, advice
18
- - comparisons that read fine as prose or a small table
19
- - general writing and conversation
20
-
21
- Choose "artifact" when a visual, standalone document/page adds real value:
22
- - standalone forms (sign-up, login, contact, survey)
23
- - landing pages, hero sections, pricing cards, product pages
24
- - dashboards, stat grids, report/stat visualizations
25
- - invoices, receipts, certificates, resumes/CVs
18
+ - comparisons that read fine as prose or a small table
19
+ - general writing and conversation
20
+
21
+ Choose "artifact" when a visual, standalone document/page adds real value:
22
+ - standalone forms (sign-up, login, contact, survey)
23
+ - landing pages, hero sections, pricing cards, product pages
24
+ - dashboards, stat grids, report/stat visualizations
25
+ - invoices, receipts, certificates, resumes/CVs
26
26
  - email/newsletter templates
27
27
  - profile/business cards, onboarding screens
28
28
  - comparison cards, timelines, funnels, galleries
29
+ - video/youtube player embeds when the user supplies or asks for a video link
29
30
  - CSS/SVG charts (bar, line, donut, progress) when the user wants a visual
30
-
31
- Choose "generative_ui" when the user specifically wants UI that should feel native/inline in the host app:
32
- - generative UI, inline UI, seamless/camouflaged/native UI
33
- - widgets, components, interface states, UI kits/systems, component variations
34
- - app/interface prototypes or explorations intended to sit inside the chat surface
35
-
36
- Be conservative: if the request is primarily about understanding, reasoning, or code, prefer "markdown". Do not pick an HTML mode just because a topic could be visualized — only when the user actually wants a rendered UI/document.
37
-
38
- Return ONLY minified JSON, no prose, no code fences:
31
+
32
+ Choose "generative_ui" when the user specifically wants UI that should feel native/inline in the host app:
33
+ - generative UI, inline UI, seamless/camouflaged/native UI
34
+ - widgets, components, interface states, UI kits/systems, component variations
35
+ - app/interface prototypes or explorations intended to sit inside the chat surface
36
+
37
+ Be conservative: if the request is primarily about understanding, reasoning, or code, prefer "markdown". Do not pick an HTML mode just because a topic could be visualized — only when the user actually wants a rendered UI/document.
38
+
39
+ Return ONLY minified JSON, no prose, no code fences:
39
40
  {"mode":"markdown"|"artifact"|"generative_ui","reason":"short reason"}`;
40
41
  export function buildClassifierUserPrompt(query) {
41
42
  return `Classify this request:\n\n"""${query}"""\n\nReturn only the JSON object.`;
@@ -1 +1 @@
1
- {"version":3,"file":"classifierPrompt.js","sourceRoot":"","sources":["../../src/classifier/classifierPrompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uEAkC+B,CAAC;AAExE,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACrD,OAAO,gCAAgC,KAAK,qCAAqC,CAAC;AACpF,CAAC"}
1
+ {"version":3,"file":"classifierPrompt.js","sourceRoot":"","sources":["../../src/classifier/classifierPrompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uEAmC+B,CAAC;AAExE,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACrD,OAAO,gCAAgC,KAAK,qCAAqC,CAAC;AACpF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/classifier/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;CACpB;AA6ED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAwCjE"}
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/classifier/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;CACpB;AAgFD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAwCjE"}
@@ -29,6 +29,9 @@ const VISUAL_SIGNALS = [
29
29
  /\bmenu\b.*\b(restaurant|cafe|food)\b/i,
30
30
  /\btimeline\b/i,
31
31
  /\bgallery\b/i,
32
+ /\b(video|youtube)\s*(player|embed|preview|card|page|ui|artifact)\b/i,
33
+ /\b(embed|show|play|render|make|create|build)\b[\s\S]*\b(youtube|video)\b/i,
34
+ /https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\//i,
32
35
  /\b(bar|line|pie|donut|doughnut)\s*chart\b/i,
33
36
  /\b(report|stats?)\s*(visuali[sz]ation|view)\b/i,
34
37
  /\bsign[\s-]?up\s*form\b|\blogin\s*form\b|\bcontact\s*form\b/i,
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/classifier/rules.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,cAAc,GAAa;IAC/B,qBAAqB;IACrB,gBAAgB;IAChB,cAAc;IACd,cAAc;IACd,oBAAoB;IACpB,uBAAuB;IACvB,kCAAkC;IAClC,4BAA4B;IAC5B,qBAAqB;IACrB,sBAAsB;IACtB,iCAAiC;IACjC,iDAAiD;IACjD,uCAAuC;IACvC,wCAAwC;IACxC,gBAAgB;IAChB,iBAAiB;IACjB,sBAAsB;IACtB,kFAAkF;IAClF,2FAA2F;IAC3F,gFAAgF;IAChF,oDAAoD;IACpD,0DAA0D;IAC1D,kBAAkB;IAClB,uCAAuC;IACvC,eAAe;IACf,cAAc;IAC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1,10 +1,17 @@
1
1
  import * as React from "react";
2
+ import { type StarterPrompt } from "./starterPrompts.js";
2
3
  import type { HtmlArtifactCardProps, UseArtifactStreamOptions } from "../types/client.js";
3
4
  export interface ArtifactChatProps extends UseArtifactStreamOptions {
4
5
  placeholder?: string;
5
6
  emptyState?: React.ReactNode;
6
7
  cardProps?: Partial<Omit<HtmlArtifactCardProps, "artifact">>;
7
8
  className?: string;
9
+ /**
10
+ * Template chips shown below the composer. Defaults to {@link STARTER_PROMPTS}.
11
+ * Pass `[]` to hide them. Clicking one sends its detailed prompt with its
12
+ * per-request `body` overrides (mode/game/allowVideoEmbeds/…).
13
+ */
14
+ starterPrompts?: StarterPrompt[];
8
15
  }
9
16
  /**
10
17
  * A batteries-included chat surface: message list, streaming status, and a
@@ -1 +1 @@
1
- {"version":3,"file":"ArtifactChat.d.ts","sourceRoot":"","sources":["../../src/client/ArtifactChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE1F,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAgGpD"}
1
+ {"version":3,"file":"ArtifactChat.d.ts","sourceRoot":"","sources":["../../src/client/ArtifactChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE1F,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CA4IpD"}
@@ -3,17 +3,23 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { useArtifactStream } from "./useArtifactStream.js";
5
5
  import { ArtifactMessage } from "./ArtifactMessage.js";
6
+ import { STARTER_PROMPTS } from "./starterPrompts.js";
6
7
  /**
7
8
  * A batteries-included chat surface: message list, streaming status, and a
8
9
  * composer. Drop it in with just an `endpoint` to get the full experience, or
9
10
  * compose `useArtifactStream` + `ArtifactMessage` yourself for custom layouts.
10
11
  */
11
12
  export function ArtifactChat(props) {
12
- const { placeholder = "Ask anything, or describe a UI to generate…", emptyState, cardProps, className, ...streamOptions } = props;
13
+ const { placeholder = "Ask anything, or describe a UI to generate…", emptyState, cardProps, className, starterPrompts = STARTER_PROMPTS, ...streamOptions } = props;
13
14
  const { messages, artifacts, status, sendMessage, stop } = useArtifactStream(streamOptions);
14
15
  const [input, setInput] = React.useState("");
15
16
  const scrollRef = React.useRef(null);
16
17
  const busy = status === "submitted" || status === "streaming";
18
+ const showStarters = !busy && messages.length === 0 && starterPrompts.length > 0;
19
+ const runStarter = (p) => {
20
+ setInput("");
21
+ void sendMessage(p.prompt, p.body);
22
+ };
17
23
  React.useEffect(() => {
18
24
  scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight, behavior: "smooth" });
19
25
  }, [messages, artifacts]);
@@ -44,7 +50,28 @@ export function ArtifactChat(props) {
44
50
  fontSize: 14.5,
45
51
  outline: "none",
46
52
  background: "#fff",
47
- } }), busy ? (_jsx("button", { type: "button", onClick: stop, style: btn("#ef4444"), children: "Stop" })) : (_jsx("button", { type: "submit", disabled: !input.trim(), style: btn("#2563eb", !input.trim()), children: "Send" }))] })] }));
53
+ } }), busy ? (_jsx("button", { type: "button", onClick: stop, style: btn("#ef4444"), children: "Stop" })) : (_jsx("button", { type: "submit", disabled: !input.trim(), style: btn("#2563eb", !input.trim()), children: "Send" }))] }), showStarters && (_jsx("div", { role: "list", "aria-label": "Starter prompts", style: {
54
+ display: "flex",
55
+ flexWrap: "wrap",
56
+ gap: 8,
57
+ padding: "0 10px 12px",
58
+ }, children: starterPrompts.map((p) => (_jsxs("button", { type: "button", role: "listitem", onClick: () => runStarter(p), title: p.hint, style: chip(), children: [_jsx("span", { "aria-hidden": "true", style: { fontSize: 15 }, children: p.emoji }), _jsx("span", { style: { fontWeight: 600 }, children: p.label }), _jsxs("span", { style: { color: "#9ca3af", fontWeight: 400 }, children: ["\u00B7 ", p.hint] })] }, p.id))) }))] }));
59
+ }
60
+ function chip() {
61
+ return {
62
+ display: "inline-flex",
63
+ alignItems: "center",
64
+ gap: 7,
65
+ border: "1px solid rgba(0,0,0,0.12)",
66
+ borderRadius: 999,
67
+ padding: "7px 13px",
68
+ fontSize: 13,
69
+ lineHeight: 1.2,
70
+ color: "var(--aha-fg, #1f2430)",
71
+ background: "rgba(0,0,0,0.02)",
72
+ cursor: "pointer",
73
+ whiteSpace: "nowrap",
74
+ };
48
75
  }
49
76
  function btn(bg, disabled = false) {
50
77
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"ArtifactChat.js","sourceRoot":"","sources":["../../src/client/ArtifactChat.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA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C3E,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7D;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CACvD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAyC1D"}
1
+ {"version":3,"file":"ArtifactMessage.d.ts","sourceRoot":"","sources":["../../src/client/ArtifactMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,WAAW,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7D;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CACvD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA6C1D"}
@@ -24,6 +24,6 @@ export function ArtifactMessage(props) {
24
24
  }, children: message.content }) }));
25
25
  }
26
26
  return (_jsxs("div", { style: { margin: "10px 0", display: "flex", flexDirection: "column", gap: 12 }, children: [message.content.trim() !== "" &&
27
- (renderMarkdown ? (renderMarkdown(message.content)) : (_jsx(MarkdownMessage, { content: message.content }))), resolved && (_jsx(HtmlArtifactCard, { artifact: resolved, ...cardProps }))] }));
27
+ (renderMarkdown ? (renderMarkdown(message.content)) : (_jsx(MarkdownMessage, { content: message.content }))), resolved && (_jsx(HtmlArtifactCard, { artifact: resolved, ...cardProps, presentation: resolved.camouflage ? "seamless" : cardProps?.presentation }))] }));
28
28
  }
29
29
  //# sourceMappingURL=ArtifactMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArtifactMessage.js","sourceRoot":"","sources":["../../src/client/ArtifactMessage.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAoBjE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAC1E,MAAM,QAAQ,GACZ,QAAQ;QACR,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAErE,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,CACL,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,YAC3E,cACE,KAAK,EAAE;oBACL,QAAQ,EAAE,iBAAiB;oBAC3B,UAAU,EAAE,iCAAiC;oBAC7C,KAAK,EAAE,MAAM;oBACb,OAAO,EAAE,WAAW;oBACpB,YAAY,EAAE,oBAAoB;oBAClC,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,GAAG;oBACf,UAAU,EAAE,UAAU;oBACtB,SAAS,EAAE,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AQ,EAAE,YAC3E,cACE,KAAK,EAAE;oBACL,QAAQ,EAAE,iBAAiB;oBAC3B,UAAU,EAAE,iCAAiC;oBAC7C,KAAK,EAAE,MAAM;oBACb,OAAO,EAAE,WAAW;oBACpB,YAAY,EAAE,oBAAoB;oBAClC,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,GAAG;oBACf,UAAU,EAAE,UAAU;oBACtB,SAAS,EAAE,YAAY;iBACxB,YAEA,OAAO,CAAC,OAAO,GACZ,GACF,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,aAChF,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE;gBAC5B,CAAC,cAAc,CAAC,CAAC,CAAC,CAChB,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAChC,CAAC,CAAC,CAAC,CACF,KAAC,eAAe,IAAC,OAAO,EAAE,OAAO,CAAC,OAAO,GAAI,CAC9C,CAAC,EACH,QAAQ,IAAI,CACX,KAAC,gBAAgB,IACf,QAAQ,EAAE,QAAQ,KACd,SAAS,EACb,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,GACxE,CACH,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -2,6 +2,7 @@ export { useArtifactStream } from "./useArtifactStream.js";
2
2
  export { ArtifactChat, type ArtifactChatProps } from "./ArtifactChat.js";
3
3
  export { ArtifactMessage, type ArtifactMessageProps } from "./ArtifactMessage.js";
4
4
  export { MarkdownMessage, type MarkdownMessageProps } from "./MarkdownMessage.js";
5
+ export { STARTER_PROMPTS, type StarterPrompt } from "./starterPrompts.js";
5
6
  export { HtmlArtifactCard, HtmlArtifactPreview, HtmlArtifactModal, HtmlArtifactToolbar, HtmlArtifactCodeView, } from "../iframe/index.js";
6
7
  export type { ChatMessage, ArtifactStreamStatus, UseArtifactStreamOptions, UseArtifactStreamReturn, HtmlArtifactCardProps, HtmlArtifactPreviewOptions, } from "../types/client.js";
7
8
  export type { HtmlArtifact, ArtifactTheme, ArtifactPresentation, } from "../types/artifact.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGlF,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,YAAY,EACZ,aAAa,EACb,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG1E,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,YAAY,EACZ,aAAa,EACb,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
@@ -3,6 +3,7 @@ export { useArtifactStream } from "./useArtifactStream.js";
3
3
  export { ArtifactChat } from "./ArtifactChat.js";
4
4
  export { ArtifactMessage } from "./ArtifactMessage.js";
5
5
  export { MarkdownMessage } from "./MarkdownMessage.js";
6
+ export { STARTER_PROMPTS } from "./starterPrompts.js";
6
7
  // Re-export the iframe surface for convenience from the client entry.
7
8
  export { HtmlArtifactCard, HtmlArtifactPreview, HtmlArtifactModal, HtmlArtifactToolbar, HtmlArtifactCodeView, } from "../iframe/index.js";
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAA0B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,eAAe,EAA6B,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,eAAe,EAA6B,MAAM,sBAAsB,CAAC;AAElF,sEAAsE;AACtE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAA0B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,eAAe,EAA6B,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,eAAe,EAA6B,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAsB,MAAM,qBAAqB,CAAC;AAE1E,sEAAsE;AACtE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Prebuilt starter prompts shown below the composer. Each has a short `label`
3
+ * (the chip the user sees) and a rich `prompt` (the detailed message actually
4
+ * sent to the model). The prompts are written in a natural, human voice —
5
+ * describing the desired RESULT, not implementation — so users never feel they
6
+ * need to know any technical details. `body` carries per-request overrides
7
+ * merged into the POST body by `sendMessage` (e.g. `{ game: true }`).
8
+ *
9
+ * NOTE: for the `body` overrides to take effect, the server route must forward
10
+ * those fields into `createArtifactStreamResponse` options, e.g.:
11
+ * `createArtifactStreamResponse({ ...(await req.json()), generateTextStream })`.
12
+ */
13
+ export interface StarterPrompt {
14
+ /** Stable id. */
15
+ id: string;
16
+ /** Short chip text shown to the user. */
17
+ label: string;
18
+ /** One-line description of what it produces. */
19
+ hint: string;
20
+ /** Leading glyph for the chip. */
21
+ emoji: string;
22
+ /** The full, natural-language message sent to the chat. */
23
+ prompt: string;
24
+ /** Per-request body overrides merged into the POST body for this prompt. */
25
+ body?: Record<string, unknown>;
26
+ }
27
+ export declare const STARTER_PROMPTS: StarterPrompt[];
28
+ //# sourceMappingURL=starterPrompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starterPrompts.d.ts","sourceRoot":"","sources":["../../src/client/starterPrompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAqCD,eAAO,MAAM,eAAe,EAAE,aAAa,EA6E1C,CAAC"}