greatstore 0.2.15 → 0.2.18

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.
@@ -23,10 +23,10 @@ constraints) that the references spell out.
23
23
  | Goal | Use | Read |
24
24
  |---|---|---|
25
25
  | Install the widget; control the panel; readiness, events, troubleshooting | `window.GreatStore` SDK | [references/embed-api.md](references/embed-api.md) |
26
- | AI-generated, catalog-grounded content rendered in **your own HTML/CSS** (highlights, comparisons, FAQs, gift guides) | `generateStructuredContent(schema, prompt)` | [references/structured-content.md](references/structured-content.md) |
26
+ | AI-generated, catalog-grounded content rendered in **your own HTML/CSS** (highlights, comparisons, FAQs, gift guides) | `generateStructuredContent(schema, prompt)` | [references/embed-api/generate-structured-content.md](references/embed-api/generate-structured-content.md) |
27
27
  | Contextual **conversation entry points** anywhere on the page | `sendMessage(text)`, `open()`, `?gs_chat=open` | [references/embed-api/send-message.md](references/embed-api/send-message.md) |
28
28
  | Feed the assistant **invisible page/app state** (current product, cart, selected variant) | `updateModelContext(text)`; an app's `$.updateModelContext` | [references/embed-api/update-model-context.md](references/embed-api/update-model-context.md), [references/apps.md](references/apps.md) |
29
- | **Fetch store data into your own UI** from a connector's read-only tool, or open a full-screen app from a button | `callTool(name, args)`; an app's `$.callTool` | [references/embed-api/call-tool.md](references/embed-api/call-tool.md) |
29
+ | **Fetch store data into your own UI** from a connector's read-only tool, open a full-screen app from a button, or run a page tool || `callTool(name, args)`; an app's `$.callTool` | [references/embed-api/call-tool.md](references/embed-api/call-tool.md) |
30
30
  | Let the assistant **act on the page** (cart, navigation, filters) | WebMCP: `document.modelContext.registerTool(...)` | [references/embed-api/webmcp.md](references/embed-api/webmcp.md) |
31
31
  | Custom **interactive UI inside the chat** (configurators, quizzes, size guides, booking forms) | apps shipped with the `gs` CLI | [references/apps.md](references/apps.md) |
32
32
  | Run one of those apps **on your own page**, outside the conversation | `surfaces: ["embed"]` + the container snippet | [references/apps.md](references/apps.md) |
@@ -256,11 +256,11 @@ component. Never declare a `$` field in `inputSchema` — the build refuses it.
256
256
  |---|---|
257
257
  | `$.sendMessage(text)` | Send text into the chat as if the shopper typed it — lets the app drive the conversation ("Selected size M, what's the return policy?"). |
258
258
  | `$.updateModelContext(context)` | Inject **invisible** background context for the model — the variant the shopper selected, the options they configured, the step they're on. Replaces the prior value (never appends); pass `""` to clear. Read on the next chat turn. Use this instead of `$.sendMessage` when the assistant should *know* state without a message appearing in the transcript. |
259
- | `$.callTool(name, args?)` | The page's `window.GreatStore.callTool`, for the app: run a read-only connector tool and get its result, or open a full-screen app by name — see [embed-api/call-tool.md](embed-api/call-tool.md) for what it reaches, what comes back, and how to look up tools. Never touches the conversation. In the app preview, tools run for real and naming a full-screen app only logs what would open. Inside other AI assistants (ChatGPT, …) it always rejects — handle the rejection. |
259
+ | `$.callTool(name, args?)` | The page's `window.GreatStore.callTool`, for the app: run one of the page's own WebMCP tools or a read-only connector tool and get its result, or open a full-screen app by name — see [embed-api/call-tool.md](embed-api/call-tool.md) for what it reaches, what comes back, and how to look up tools. Never touches the conversation. In the app preview, tools run for real and naming a full-screen app only logs what would open. Inside other AI assistants (ChatGPT, …) it always rejects — handle the rejection. |
260
260
  | `$.showLightbox({ src, originRect? })` | Expand an image in the chat's shared full-screen lightbox — an on-brand zoom overlay you can't render yourself (your app is boxed inside its own bounds and shadow root). Pass the image `src`; for a smooth zoom, also pass the clicked element's `getBoundingClientRect()` as `originRect` (omit it and the image grows from the viewport centre). |
261
261
  | `$.generateStructuredContent(schema, prompt, fallback)` | Ask the store's assistant for content matching a JSON Schema (or Zod schema) and get back the generated object. Personalized to the shopper. Works the same in the conversation on the storefront and every embed. Best for async apps that build their render from a generated payload. `fallback` is **required**: a schema-shaped object you provide that the app preview renders (no live store there), validated against the schema — a mismatch throws. |
262
262
  | `$.close()` | Dismiss the host slot. `over-input` clears the overlay, `fullscreen` reverts the pane, `inline` is a no-op. |
263
- | `$.useVoiceCall()` | A hook — call it at the top of your component like any other — returning `{ status, available, start, end }` for a voice call with the store's assistant. `start()` starts the call without opening the chat — it runs in the collapsed chat bar (which stays hidden if the store hides the chat until opened), and the chat opens only when the assistant shows an inline app (call it from a click; it rejects when the store has no voice), `end()` hangs up. `available` says whether the store has voice. `status` is `null` until a call starts, then `started`, `connecting`, `connected`, `listening` / `speaking` / `working` as the conversation goes, `disconnected` while the network drops (the call recovers on its own), and `ended`. Your app re-renders on every change. |
263
+ | `$.useVoiceCall()` | A hook — call it at the top of your component like any other — returning `{ status, available, start, end }` for a voice call with the store's assistant. `start()` starts the call without opening the chat — it runs in the collapsed chat bar (which stays hidden if the store hides the chat until opened), and the chat opens only when the assistant shows an inline app (call it from a click; it rejects when the store has no voice), `end()` hangs up. `available` says whether the store has voice. `status` is `null` until a call starts, then `started`, `connecting`, `connected`, `listening` / `speaking` / `working` as the conversation goes, `disconnected` while the network drops (the call recovers on its own), and `ended` — or `rejected` instead of `ended` when the shopper refuses the microphone (calling `start()` again asks again, though a browser where they blocked it refuses without asking). Your app re-renders on every change. |
264
264
  | `$.Image` | A drop-in for `<img>` — render `<Image src=… alt=… />` and the image is served at the right size for the store. Takes the same props as `<img>`. |
265
265
  | `$.store` | `{ slug }` — the store the app is running in. |
266
266
 
@@ -384,7 +384,7 @@ export default async function Results(props: Props) {
384
384
  ## When to build an app vs. the other facets
385
385
 
386
386
  - Content for the **merchant's page** → `window.GreatStore.generateStructuredContent`
387
- ([structured-content.md](structured-content.md)). Inside an app, use
387
+ ([embed-api/generate-structured-content.md](embed-api/generate-structured-content.md)). Inside an app, use
388
388
  `$.generateStructuredContent` instead — same idea, but personalized to the
389
389
  shopper and available on every surface without the global.
390
390
  - Letting the assistant **act on the page** → WebMCP page tools
@@ -1,6 +1,6 @@
1
1
  # `callTool(name: string, args?: object): Promise<object | undefined>`
2
2
 
3
- The page's own way to reach two things by name, without the shopper asking
3
+ The page's own way to reach three things by name, without the shopper asking
4
4
  and without touching the conversation (nothing is added to the chat and the
5
5
  assistant never learns the call happened).
6
6
 
@@ -16,6 +16,20 @@ page's, not the conversation's — a reload drops it. `inline` and
16
16
  window.GreatStore.callTool("show_size_guide", { category: "boots" });
17
17
  ```
18
18
 
19
+ **A page tool.** Name a WebMCP tool the page registered once GreatStore was
20
+ ready (anything listed in `window.GreatStore.tools`) and it runs right there
21
+ on the page, resolving with the tool's result: `content`, plus
22
+ `structuredContent` when `execute` returned an object. Unlike a connector tool it may change state —
23
+ it is the page's own code. A page tool wins over an app or connector tool of
24
+ the same name, which is how a page overrides one for GreatStore alone.
25
+
26
+ ```js
27
+ await window.GreatStore.callTool("add_to_cart", { variant_id: 123, quantity: 1 });
28
+ ```
29
+
30
+ `npx greatstore connectors tools webmcp --store my-store` lists the page
31
+ tools the store's pages have registered in recent chats.
32
+
19
33
  **A read-only connector tool.** Name any read-only tool from the store's
20
34
  connectors (Maker MCP or the merchant's own MCP servers) and it resolves
21
35
  with the tool's MCP `tools/call` result exactly as the server returned it:
@@ -43,15 +57,14 @@ not when it doesn't. Trust that line over your own reading of the tool. It
43
57
  also spells out every input: type, whether it's required, allowed values,
44
58
  limits and description, nested fields included. Add `--json` for the raw input
45
59
  schema. In short, only read-only tools the assistant itself can call are
46
- reachable. A tool that changes state (cart, checkout) is refused, and so are
47
- WebMCP page tools (the page already has those). When an app and a tool share
48
- a name, the app wins. Before writing code against the
60
+ reachable. A connector tool that changes state (cart, checkout) is refused.
61
+ When an app and a connector tool share a name, the app wins. Before writing code against the
49
62
  result, call the tool once from the browser console and read what comes back:
50
63
  the result's shape is the connector's too, and the listing doesn't describe
51
64
  it.
52
65
 
53
- It rejects with an `Error` when the name is neither, when an app isn't
54
- full-screen or the args don't match its schema, when the tool is not
66
+ It rejects with an `Error` when the name is none of these, when an app isn't
67
+ full-screen or the args don't match its schema, when a connector tool is not
55
68
  read-only, when the tool answers with an error (the message is the tool's
56
69
  own text), or when the server can't be reached. Loads the chat first if it
57
70
  isn't up yet.
@@ -1,15 +1,285 @@
1
1
  # `generateStructuredContent(schema: object, prompt: string): Promise<unknown>`
2
2
 
3
3
  Generates JSON matching `schema` from `prompt`, grounded in the store's live
4
- catalog. Resolves to the generated data object itself. Rejects with `Error`
5
- on any failure (invalid input, decline, validation failure, rate limit,
6
- network); a decline sets `error.reason`. See
7
- [structured-content.md](../structured-content.md) for the full
8
- contract, schema support, caching, and error semantics.
9
-
10
- Accepts either a plain JSON Schema object or any object exposing a
11
- `.toJSONSchema()` method (e.g. Zod schemas) — the conversion is called for
12
- you.
13
-
14
- Throws synchronously (rejects) if `prompt` is not a non-empty string or
15
- `schema` is not an object.
4
+ catalog, for UI the page renders itself — the chat panel is not involved.
5
+ Resolves to **the generated data object itself**. Rejects with an `Error` on
6
+ any failure (invalid input, decline, validation failure, rate limit,
7
+ network); see [Errors](#errors).
8
+
9
+ ```js
10
+ const data = await window.GreatStore.generateStructuredContent(schema, prompt);
11
+ ```
12
+
13
+ - `schema` — a JSON Schema object describing the output, or any object
14
+ exposing `.toJSONSchema()` (e.g. a Zod schema); the conversion is called
15
+ for you, and `.describe("…")` becomes the field's `description`.
16
+ - `prompt` — what to generate.
17
+
18
+ Rejects immediately if `prompt` is not a non-empty string or `schema` is not
19
+ an object.
20
+
21
+ ## The rules that make it work well
22
+
23
+ Each is unpacked in the sections below; this is the checklist.
24
+
25
+ 1. **Top level must be an object.** Want a list? Wrap it:
26
+ `{ type: "object", properties: { items: { type: "array", … } }, required: ["items"] }`.
27
+ 2. **Steer the whole output with the prompt, single fields with
28
+ `description`.** Use self-explanatory property names (`benefitHeadline`,
29
+ not `text1`) and describe only where the name isn't enough.
30
+ 3. **Only `require` what's guaranteed.** `required` is strictly enforced; if
31
+ the catalog can't ground a required field the whole call can fail. Require
32
+ structural fields, keep per-product details (image URLs, prices) optional,
33
+ and make rendering tolerate missing values.
34
+ 4. **Point, don't paste.** GreatStore researches the store's live catalog on
35
+ its own — name the entity (`` `…the product "${productName}" (SKU ${sku})` ``)
36
+ and let it look the facts up. The one thing it *can't* see is your page,
37
+ so page-only context (which page the shopper is on, what the section is
38
+ for) does belong in the prompt.
39
+ 5. **Research is bounded by the store's connectors — validate before you
40
+ build.** Ask for something no connector provides — currency conversion,
41
+ live shipping rates, review data the store never wired up — and it has
42
+ nothing to ground on, so it will decline, omit… or hallucinate. Run
43
+ `npx greatstore connectors` (and `npx greatstore connectors health`,
44
+ [store-admin.md](../store-admin.md)) first; if there's no connector for
45
+ it, don't ask for it.
46
+ 6. **Responses are cached** for up to ~24h per page + prompt + schema. Keep
47
+ prompts deterministic per page — no timestamps, random values, or
48
+ per-visitor data.
49
+ 7. **Progressive enhancement, always.** Generate after the page renders into
50
+ a hidden container, reveal on success, leave the fallback on error. Render
51
+ generated strings via `textContent`, never `innerHTML`.
52
+ 8. **One rich call beats many small ones** — there's a per-IP rate limit
53
+ (~20 requests/minute); fetch multiple surfaces with one combined schema.
54
+
55
+ ## What happens on a call
56
+
57
+ 1. The SDK posts your schema + prompt to the store, along with the current
58
+ **page context**, sent automatically — you don't pass it, and you can't
59
+ override it:
60
+ - the page URL, **without its query string or fragment**;
61
+ - the page title;
62
+ - a small, length-capped subset of the page's schema.org JSON-LD
63
+ (`Product`, `ProductGroup`, `Offer`, `Article`, `WebPage`, `FAQPage`,
64
+ `AggregateRating`). For products that's identifiers only — name,
65
+ brand, SKU, GTIN, URL — so emitting product JSON-LD is the most
66
+ reliable way to tell GreatStore exactly which product the page is
67
+ about.
68
+ 2. GreatStore **researches** the store's live catalog (products, prices,
69
+ availability, store info) using read-only lookups. The page context only
70
+ hints at which product or category to look up — it is *not* a source of
71
+ product data, and nothing else on the page (visible text, reviews, your
72
+ markup) is read. Its reach is exactly the store's MCP connectors.
73
+ 3. The AI fills your schema from the researched data under a strict
74
+ grounding contract: it must not invent product names, prices, images, IDs,
75
+ or descriptions. Fields it can't ground are omitted or `null`. For an
76
+ identified shopper it also sees their shopper profile — the same identity
77
+ the chat assistant has — so the output can be subtly personalized without
78
+ you passing anything about the visitor.
79
+ 4. The output is validated against your schema (with internal retries)
80
+ before being returned and cached.
81
+
82
+ Because GreatStore already knows who's reading, never put shopper data in
83
+ the prompt — it's redundant, and it poisons the cache key.
84
+
85
+ ## Schema support
86
+
87
+ Top level **must describe an object**: `type: "object"` (or a bare
88
+ `properties` / `anyOf`).
89
+
90
+ Supported keywords (anything else is tolerated but ignored):
91
+
92
+ - Types: `object`, `array`, `string`, `number`, `integer`, `boolean`, `null`
93
+ - Structure: `properties`, `required`, `items`, `additionalProperties`
94
+ - Choice: `enum`, `const`, `anyOf`, `nullable`
95
+ - Constraints: `minimum`, `maximum`, `minLength`, `maxLength`, `minItems`,
96
+ `maxItems`, `pattern`, `format`, `default`
97
+ - Guidance: `description`, `example`, `title` (on any property)
98
+
99
+ Validation of the output is real: `required` is enforced, `enum`/`const`
100
+ must match, numeric and length bounds are checked, and
101
+ `additionalProperties: false` rejects extra keys. Constraints are therefore a
102
+ *tool* — `enum` reliably restricts a field — but every constraint is also a
103
+ way for generation to fail, so apply them only where you'd rather have no
104
+ content than non-conforming content.
105
+
106
+ Item counts are the exception. `minItems` is honored as the content is
107
+ written, so a list comes back with at least that many entries, and a list
108
+ longer than `maxItems` is cut to its first `maxItems` entries rather than
109
+ failing. The same applies to an app's `inputSchema`.
110
+
111
+ ### Field descriptions
112
+
113
+ A property's `description` is shown to the AI as guidance for that one
114
+ field, and an `example` shows the exact shape you want (`"4.5 out of 5"`,
115
+ `"SKU-1234"`). Both are optional: a field without them is filled from its
116
+ name, the prompt, and its constraints.
117
+
118
+ ```js
119
+ {
120
+ type: "object",
121
+ properties: {
122
+ headline: { type: "string", maxLength: 60 },
123
+ priceJustification: {
124
+ type: "string",
125
+ description: "One sentence on why the price is fair, citing a real material or feature",
126
+ },
127
+ rating: { type: "string", example: "4.5 out of 5" },
128
+ },
129
+ required: ["headline"],
130
+ }
131
+ ```
132
+
133
+ Split the work between the two channels:
134
+
135
+ - **Prompt** — the situation, the task as a whole, grounding, and voice.
136
+ - **`description` / `example`** — what one specific field holds: its unit,
137
+ length in words, perspective ("first-person, as the shopper"), or how it
138
+ relates to a sibling.
139
+ - Property *names* still carry most of the intent — make them
140
+ self-documenting (`ctaLabel`, `warmthRating`, `priceJustification`) and
141
+ reach for a description when the name can't say it.
142
+
143
+ ## Prompting
144
+
145
+ A good prompt states, in order:
146
+
147
+ 1. **Context** — what page/situation the shopper is in, naming the entity so
148
+ research targets the right thing (the AI can't see your DOM):
149
+ `The shopper is viewing the product "Aurora Down Parka" (SKU AUR-021) on its product page.`
150
+ 2. **Task** — what to generate, mapped loosely onto your schema's fields:
151
+ `Write a heading and 3 reasons to love it; each reason has a short title and one supporting sentence.`
152
+ 3. **Grounding expectations** — what store data to draw on:
153
+ `Base every claim on the product's real materials, features, and price.`
154
+ 4. **Voice** — tone and constraints:
155
+ `Warm and concrete. No exclamation marks, no generic marketing filler.`
156
+
157
+ Note what's *not* in that prompt: no pasted specs, prices, or descriptions.
158
+ Pointing at the SKU is enough, and the data research finds is live rather
159
+ than whatever was true when you wrote the prompt.
160
+
161
+ Anti-patterns:
162
+
163
+ - **Pasting researched material into the prompt** (specs, prices,
164
+ descriptions fetched from your platform's API). Pasted facts go stale,
165
+ bloat the cache key, and compete with the fresher data research returns.
166
+ - **Per-visitor or per-moment data in the prompt** (names, cart contents,
167
+ timestamps, `Math.random()`): destroys caching, so every visitor pays full
168
+ generation latency and the store pays for every call — and it's redundant,
169
+ because identified shoppers are personalized for server-side. For
170
+ per-shopper *interaction*, use [`sendMessage`](send-message.md) and the
171
+ chat panel.
172
+ - **Asking for data no connector provides** ("convert the price to EUR",
173
+ "estimate delivery to the shopper's city"): the AI may hallucinate
174
+ plausible-looking values rather than leave the field empty.
175
+ - **Asking it to read the page** ("summarize the reviews shown below") — it
176
+ can't. Page-only data (review snippets, UGC, things that exist nowhere but
177
+ the DOM) is the one kind worth inlining — keep it stable per page so
178
+ caching still works.
179
+ - **Asking for minute-fresh operational data** (exact live stock counts,
180
+ delivery countdowns). Even when a connector could answer, responses cache
181
+ for up to ~24h — display operational data from your own platform APIs and
182
+ use GreatStore for *editorial intelligence over the catalog*.
183
+ - **Putting whole-output instructions in a field's `description`** (voice,
184
+ grounding, what the page is) — they belong in the prompt, where they apply
185
+ to every field.
186
+
187
+ ## Caching
188
+
189
+ Responses are cached server-side for up to **24 hours**, keyed by page
190
+ context (URL path, title, JSON-LD identifiers) + prompt + schema. Anonymous
191
+ visitors share one entry per key; identified shoppers each get their own
192
+ (their output may be personalized, so it's only ever served back to them).
193
+
194
+ **The query string and fragment never reach GreatStore.** `/product?id=123`
195
+ and `/product?id=456` are the same page to it — same hints, same cache entry.
196
+ If your page picks its product from a query param, name that product in the
197
+ prompt (`` `…the product "${name}" (SKU ${sku})` ``), or emit JSON-LD for it;
198
+ either one differentiates the content and the cache.
199
+
200
+ The one exception is `intent_id`, the ad reference some ad landing URLs
201
+ carry: when it's present, content is steered toward what that ad showed and
202
+ cached for that ad alone. You don't need to do anything for this, and the
203
+ call behaves the same either way.
204
+
205
+ Practical consequences:
206
+
207
+ - **The first render pays, repeats fly.** Expect a few seconds on a cache
208
+ miss and near-instant responses after. The catalog research underneath is
209
+ also cached briefly and shared, so even misses — and several distinct
210
+ surfaces on one page — are cheaper than cold. Design loading states for
211
+ the miss case.
212
+ - **Same call on different pages = different content**, automatically — the
213
+ page path is in the key and in the AI's hints. A single site-wide snippet
214
+ with a constant prompt yields per-page content for free.
215
+ - **Content refreshes roughly daily.** Don't build experiences that assume
216
+ minute-level freshness.
217
+ - **To force different content, change the prompt or schema** (e.g. a
218
+ campaign variant string that changes weekly — deliberate, low-cardinality
219
+ variation is fine; per-visitor cardinality is not).
220
+
221
+ ## Errors
222
+
223
+ The promise rejects with `new Error(message)`. The message is
224
+ developer-facing — never render it to shoppers. Server-side failures also
225
+ carry `error.code`, and a decline carries `error.reason`.
226
+
227
+ | Case | Message you'll see | Retry? |
228
+ |---|---|---|
229
+ | Bad input (empty prompt, non-object schema) | rejected immediately by the SDK | Fix the call |
230
+ | Invalid schema shape, or constraints no output could satisfy | `Invalid schema: …` | Fix the schema |
231
+ | AI declined the request | `The assistant declined to generate content for this request.` with `error.reason` (below) | No — rework the prompt. `insufficient_data` alone can change as the catalog does. |
232
+ | Output couldn't satisfy the schema | `Failed to produce valid structured content` | No — usually `required`/constraints demand data the catalog lacks. Loosen the schema. |
233
+ | Rate limit (~20/min per IP address) | rate-limit message | Later — and consolidate calls |
234
+ | Network / server | varies | Next page load |
235
+
236
+ A decline is only ever one of these `error.reason` values — anything else
237
+ (vague wording, missing data for optional fields, marketing copy) is served:
238
+
239
+ | `reason` | Declined because the request… |
240
+ |---|---|
241
+ | `off_topic` | has nothing to do with the store or shopping there (homework, code, news, another business's products) |
242
+ | `harmful` | asks for unsafe, hateful, sexual, or illegal content, or advice that could hurt someone |
243
+ | `deceptive` | asks for fake reviews, invented discounts or scarcity, claims the catalog contradicts, or impersonating/disparaging a named brand or person |
244
+ | `system_probe` | asks about or tries to override the assistant's own instructions or tools |
245
+ | `insufficient_data` | needs store data that isn't there — the catalog doesn't carry what it's about, or nothing it needs could be found |
246
+
247
+ The uniform shopper-facing strategy: render into a hidden-by-default
248
+ container, reveal on success, leave hidden (or show your static fallback) on
249
+ any rejection. One `try/catch`, no case analysis needed unless you're
250
+ logging.
251
+
252
+ ## Performance pattern
253
+
254
+ Fire generation as early as possible without blocking render — top of your
255
+ deferred script, before other work:
256
+
257
+ ```js
258
+ const highlightsPromise = window.GreatStore?.generateStructuredContent
259
+ ? window.GreatStore.generateStructuredContent(schema, prompt).catch(() => null)
260
+ : Promise.resolve(null);
261
+
262
+ // …rest of page setup…
263
+
264
+ const data = await highlightsPromise;
265
+ if (data) renderHighlights(data);
266
+ ```
267
+
268
+ The `.catch(() => null)` attached immediately avoids unhandled-rejection
269
+ noise while keeping a single render path.
270
+
271
+ For multiple surfaces on one page, prefer **one call with a combined
272
+ schema** over parallel calls — it's one research pass, one cache entry, and
273
+ no rate-limit pressure:
274
+
275
+ ```js
276
+ const schema = {
277
+ type: "object",
278
+ properties: {
279
+ highlights: { /* … */ },
280
+ faq: { /* … */ },
281
+ crossSell: { /* … */ },
282
+ },
283
+ required: ["highlights"],
284
+ };
285
+ ```
@@ -24,16 +24,33 @@ receives the status) and as a `greatstore:voicestatus` event on `window`
24
24
  | `speaking` | The assistant is talking. |
25
25
  | `working` | The assistant is thinking or looking something up. |
26
26
  | `disconnected` | The shopper's network dropped mid-call. The call recovers on its own, back to `listening`. |
27
- | `ended` | The call is over — hung up, ended by the assistant, failed, or the microphone was refused. Always the last status. |
27
+ | `ended` | The call is over — hung up, ended by the assistant, or failed. |
28
+ | `rejected` | The shopper refused the microphone, so the call never connected. Comes in place of `ended`. |
29
+
30
+ Every call finishes on exactly one of `ended` or `rejected`.
31
+
32
+ Use `rejected` to tell the shopper why nothing happened. Calling
33
+ `startVoiceCall()` again asks for the microphone again, but whether the shopper
34
+ sees the prompt is up to the browser: once they've blocked the microphone for
35
+ the site, the browser refuses without asking (and `rejected` fires again) until
36
+ they allow it in the browser's site settings. A prompt the shopper only closed
37
+ usually comes back.
28
38
 
29
39
  ```js
30
40
  const callButton = document.querySelector("#talk");
41
+ const micNote = document.querySelector("#mic-note");
31
42
  callButton.addEventListener("click", () => {
32
43
  if (callButton.dataset.live) window.GreatStore.endVoiceCall();
33
44
  else window.GreatStore.startVoiceCall().catch(() => (callButton.hidden = true));
34
45
  });
35
46
  window.addEventListener("greatstore:voicestatus", (event) => {
36
- const live = event.detail.status !== "ended";
47
+ const { status } = event.detail;
48
+ if (status === "rejected") {
49
+ micNote.textContent = "Allow microphone access in your browser to talk to us.";
50
+ } else if (status === "started") {
51
+ micNote.textContent = "";
52
+ }
53
+ const live = status !== "ended" && status !== "rejected";
37
54
  callButton.dataset.live = live ? "1" : "";
38
55
  callButton.textContent = live ? "Hang up" : "Talk to us";
39
56
  });
@@ -112,7 +112,7 @@ and replay in order.
112
112
  | `load()`, `open()`, `close()`, `toggle()`, `destroy()` | Pre-warm, show, hide, or tear down the chat panel. | [embed-api/panel.md](embed-api/panel.md) |
113
113
  | `sendMessage(text)` | Send a visible message as the shopper and open the panel — a conversation entry point from any element. | [embed-api/send-message.md](embed-api/send-message.md) |
114
114
  | `updateModelContext(text)` | Give the assistant invisible background context about the page (product, cart, account). | [embed-api/update-model-context.md](embed-api/update-model-context.md) |
115
- | `callTool(name, args)` | Open a full-screen app from the page, or fetch data from a connector's read-only tool. | [embed-api/call-tool.md](embed-api/call-tool.md) |
115
+ | `callTool(name, args)` | Run one of the page's own WebMCP tools, open a full-screen app from the page, or fetch data from a connector's read-only tool. | [embed-api/call-tool.md](embed-api/call-tool.md) |
116
116
  | `on(event, handler)` | Subscribe to panel and voice events. | [embed-api/events.md](embed-api/events.md) |
117
117
  | `startVoiceCall()`, `endVoiceCall()` | Start or hang up a voice call without opening the chat. | [embed-api/voice-call.md](embed-api/voice-call.md) |
118
118
  | `generateStructuredContent(schema, prompt)` | Generate catalog-grounded JSON for the page's own UI. | [embed-api/generate-structured-content.md](embed-api/generate-structured-content.md) |
@@ -32,6 +32,7 @@ npx greatstore configure --store my-store --json # brand config
32
32
  npx greatstore connectors --store my-store --json # MCP connectors feeding the assistant
33
33
  npx greatstore connectors health --store my-store # live-probe them (reports tool counts)
34
34
  npx greatstore connectors tools maker --store my-store # a connector's tools, inputs in full
35
+ npx greatstore connectors tools webmcp --store my-store # the page tools the store's pages register
35
36
  npx greatstore connectors errors --store my-store --json # tools' most frequent errors, last 7 days
36
37
  npx greatstore apps list --store my-store --json # deployed custom in-chat apps
37
38
  ```
@@ -45,17 +46,22 @@ What each read is good for:
45
46
  - **`npx greatstore connectors`** — which MCP connectors the assistant has, and whether
46
47
  the Maker MCP is on. This tells you what the assistant can actually *do*:
47
48
  check it before building features that lean on catalog data (e.g.
48
- [structured content](structured-content.md) grounding), and before
49
+ [structured content](embed-api/generate-structured-content.md) grounding), and before
49
50
  registering WebMCP page tools that would duplicate a capability a
50
51
  server-side connector already provides.
51
52
  - **`npx greatstore connectors health`** — a connector being listed doesn't mean it's
52
53
  reachable; this probes each one live. Run it when assistant behaviour
53
54
  suggests a tool isn't responding.
54
- - **`npx greatstore connectors tools <name|maker> [<tool>]`** — what a
55
+ - **`npx greatstore connectors tools <name|maker|webmcp> [<tool>]`** — what a
55
56
  connector offers, live: each tool's group, whether the assistant may call it,
56
57
  whether a page can call it with `GreatStore.callTool`, its description and
57
58
  every input with its type, constraints and description. Read it before
58
59
  writing a `callTool` call (see [embed-api/call-tool.md](embed-api/call-tool.md)).
60
+ `webmcp` lists the WebMCP page tools the store's pages have registered in
61
+ recent chats, with their names and descriptions; their inputs are whatever
62
+ the page's own `registerTool` call declares. Check it before registering a
63
+ page tool, so you extend or override what the site already has instead of
64
+ duplicating it. A tool only appears after a chat on a page that registers it.
59
65
  - **`npx greatstore connectors errors`** — what actually went wrong when the assistant
60
66
  called a tool on shoppers' behalf: each connector, custom-app or page tool's
61
67
  distinct errors, how often each happened and when last. Health only says a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greatstore",
3
- "version": "0.2.15",
3
+ "version": "0.2.18",
4
4
  "description": "CLI for administering GreatStore stores and authoring custom components.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",