@matterfact/embed 0.6.0 → 0.8.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.
- package/README.md +99 -1
- package/dist/chunk-PNSYFXXU.js +791 -0
- package/dist/chunk-PNSYFXXU.js.map +1 -0
- package/dist/chunk-R2ZEJARX.js +776 -0
- package/dist/chunk-R2ZEJARX.js.map +1 -0
- package/dist/{chunk-4Q2ROXLR.js → chunk-UD7CAQXV.js} +2 -2
- package/dist/{chunk-7I37ZFAJ.js → chunk-UQCETVRF.js} +2 -2
- package/dist/chunk-W52Q7G4J.js +3 -0
- package/dist/chunk-W52Q7G4J.js.map +7 -0
- package/dist/context-ARBB2XD6.js +3 -0
- package/dist/{context-YX2KXFLI.js.map → context-ARBB2XD6.js.map} +1 -1
- package/dist/{context-WU2F5CBC.js → context-MVGSYIMB.js} +2 -2
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +4 -4
- package/dist/index.cjs +986 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +140 -31
- package/dist/index.d.ts +140 -31
- package/dist/index.js +542 -130
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1012 -165
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +33 -1
- package/dist/react.d.ts +33 -1
- package/dist/react.js +561 -132
- package/dist/react.js.map +1 -1
- package/dist/{snapshot-MUXE7KXX.js → snapshot-GL4YBMXD.js} +3 -3
- package/dist/{snapshot-MUXE7KXX.js.map → snapshot-GL4YBMXD.js.map} +1 -1
- package/dist/{snapshot-JOGZWESK.js → snapshot-UGTXZVB6.js} +2 -2
- package/examples/embed-demo/.env.example +5 -1
- package/examples/embed-demo/README.md +37 -0
- package/examples/embed-demo/package.json +1 -1
- package/examples/embed-demo/src/App.tsx +82 -44
- package/examples/embed-demo/src/HoistDemo.tsx +390 -0
- package/examples/embed-demo/src/config.ts +34 -4
- package/examples/embed-demo/src/main.tsx +7 -0
- package/examples/embed-demo/src/mockXH.ts +492 -0
- package/examples/embed-demo/src/placement.tsx +43 -0
- package/examples/embed-demo/src/styles.css +147 -2
- package/examples/embed-demo/vite.config.ts +2 -2
- package/package.json +1 -1
- package/dist/chunk-AXKXNYRT.js +0 -381
- package/dist/chunk-AXKXNYRT.js.map +0 -1
- package/dist/chunk-D7R6WVHG.js +0 -2
- package/dist/chunk-D7R6WVHG.js.map +0 -7
- package/dist/chunk-RS6RMZ77.js +0 -396
- package/dist/chunk-RS6RMZ77.js.map +0 -1
- package/dist/context-YX2KXFLI.js +0 -3
- /package/dist/{chunk-4Q2ROXLR.js.map → chunk-UD7CAQXV.js.map} +0 -0
- /package/dist/{chunk-7I37ZFAJ.js.map → chunk-UQCETVRF.js.map} +0 -0
- /package/dist/{context-WU2F5CBC.js.map → context-MVGSYIMB.js.map} +0 -0
- /package/dist/{snapshot-JOGZWESK.js.map → snapshot-UGTXZVB6.js.map} +0 -0
package/README.md
CHANGED
|
@@ -214,6 +214,102 @@ gets nothing back. Default is on: seeing the page is the point of the widget.
|
|
|
214
214
|
<MatterfactAgent publishableKey="pk_live_…" pageContext={false} />
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
+
## Hoist apps
|
|
218
|
+
|
|
219
|
+
If the host page is an [XH Hoist](https://xh.io/) SPA — `window.XH` is present — the widget
|
|
220
|
+
automatically extracts rich page context and a snapshot from it. No `window.matterfact.context`,
|
|
221
|
+
no `getPageContext`, no host code at all: the grids, charts, and navigation already mounted in
|
|
222
|
+
the page are the source of truth. On any other page this is skipped entirely and the widget falls
|
|
223
|
+
back to the generic DOM snapshot described above.
|
|
224
|
+
|
|
225
|
+
This affects two different messages the widget sends, independently:
|
|
226
|
+
|
|
227
|
+
- The per-turn **context** (route + one-line description) still prefers an explicit
|
|
228
|
+
`getPageContext` / `window.matterfact.context` when the host declares one — Hoist is only the
|
|
229
|
+
fallback when neither is set.
|
|
230
|
+
- The on-demand **snapshot** (what the agent sees when it looks at the page) is Hoist-first,
|
|
231
|
+
unconditionally, ahead of the generic DOM walk — whether or not the host also declares context.
|
|
232
|
+
|
|
233
|
+
What gets extracted:
|
|
234
|
+
|
|
235
|
+
- **Route + description** — `XH.routerState`, turned into a one-line summary, e.g. `"Viewing
|
|
236
|
+
default.company.tsr, 1 selected, 1 grid(s)."`
|
|
237
|
+
- **Grids** — each mounted `GridModel` that has rows or a selection (an empty, not-yet-loaded
|
|
238
|
+
grid — e.g. an off-view tab — is skipped), as a table: columns (a grouped column is flattened
|
|
239
|
+
to its visible leaves and prefixed with its group, e.g. `"5Y Value"`), the current selection,
|
|
240
|
+
and up to `rows` data rows with a total count.
|
|
241
|
+
- **Charts** — each mounted `ChartModel` with at least one series, summarised per series (point
|
|
242
|
+
count, min, max, last) — never the raw series.
|
|
243
|
+
- **Site map** — each mounted `TabContainerModel`, joined to the router's routes: the app's
|
|
244
|
+
navigable destinations, grouped by nav level (top tabs, a per-record sidebar, …), with the
|
|
245
|
+
current one marked. This leads the snapshot, since it barely changes turn to turn.
|
|
246
|
+
|
|
247
|
+
It reads roughly like the ARIA snapshot above, with its own block types:
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
- navigation "Site":
|
|
251
|
+
- link "Companies" → /app/companies
|
|
252
|
+
- link "Company Analysis" [current] → /app/company
|
|
253
|
+
- table "Peer TSR":
|
|
254
|
+
- rowgroup "columns":
|
|
255
|
+
- columnheader "Ticker"
|
|
256
|
+
- columnheader "1Y TSR"
|
|
257
|
+
- rowgroup "rows":
|
|
258
|
+
- row:
|
|
259
|
+
- cell "SITE"
|
|
260
|
+
- cell "12.3%"
|
|
261
|
+
- text: "showing 1 of 412 rows"
|
|
262
|
+
- figure "TSR vs Index":
|
|
263
|
+
- text: "series SITE: 4 points, min 1, max 10, last 10"
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Configuring it
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
window.matterfact = {
|
|
270
|
+
hoist: {
|
|
271
|
+
rows: 50, // rows sent per grid before truncating (default 50)
|
|
272
|
+
excludeModels: [], // class names ('ChartModel') or specific model ids to omit
|
|
273
|
+
actions: { navigate: 'off' }, // see "Letting the agent navigate" below
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
| Key | Type | Default | What |
|
|
279
|
+
| ------------------ | ------------------------------ | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
280
|
+
| `rows` | `number` | `50` | Rows sent per grid before truncating. The full row count still rides along. |
|
|
281
|
+
| `excludeModels` | `string[]` | `[]` | Model class names (drops every instance) or specific model ids to omit — applies to grids, charts, and nav tab containers alike. |
|
|
282
|
+
| `actions.navigate` | `'off' \| 'confirm' \| 'auto'` | `'off'` | Whether the agent can drive navigation — see below. |
|
|
283
|
+
|
|
284
|
+
### Letting the agent navigate
|
|
285
|
+
|
|
286
|
+
Set `actions.navigate` and the widget advertises a `hoist.navigate` tool bounded to exactly the
|
|
287
|
+
destinations in the CURRENT site map — the agent can't ask for somewhere that isn't reachable
|
|
288
|
+
from where the user actually is, and every call is re-validated against the live site map (and
|
|
289
|
+
the live policy), never whatever the widget last cached, before it runs:
|
|
290
|
+
|
|
291
|
+
- `'off'` (default) — the tool isn't advertised at all.
|
|
292
|
+
- `'confirm'` — advertised, and the widget shows an approval card the user must accept before
|
|
293
|
+
each call.
|
|
294
|
+
- `'auto'` — advertised and runs without asking.
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
<MatterfactAgent publishableKey="pk_live_…" actions={{ navigate: 'confirm' }} />
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
// script tag — same idea, the global the React prop above is sugar for
|
|
302
|
+
window.matterfact = { hoist: { actions: { navigate: 'confirm' } } };
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Changing `actions` on `<MatterfactAgent>` remounts the widget (a fresh chat session) so the new
|
|
306
|
+
policy is advertised immediately — it's identity-defining config, not a live callback like
|
|
307
|
+
`getPageContext`.
|
|
308
|
+
|
|
309
|
+
Everything else about page observation still applies here: values are redacted before anything
|
|
310
|
+
leaves the page, row counts are capped, and `pageContext={false}` turns this off along with
|
|
311
|
+
everything else (see above).
|
|
312
|
+
|
|
217
313
|
## Microphone / dictation
|
|
218
314
|
|
|
219
315
|
The composer supports voice dictation; the loader grants the iframe `allow="microphone"`.
|
|
@@ -253,7 +349,9 @@ Runnable examples ship inside this package (under `examples/`) and are browsable
|
|
|
253
349
|
cloning anything:
|
|
254
350
|
|
|
255
351
|
- **`examples/embed-demo/`** — a tiny Vite + React app that mounts `<MatterfactAgent inline>`
|
|
256
|
-
in a side panel next to an embedded `<MatterfactArtifact>`, configured entirely via `.env`.
|
|
352
|
+
in a side panel next to an embedded `<MatterfactArtifact>`, configured entirely via `.env`. Also
|
|
353
|
+
ships an opt-in mock Hoist app (`?hoist=1`) to try the automatic Hoist-app path above with no
|
|
354
|
+
real Hoist deployment — see its own README.
|
|
257
355
|
Browse it on [unpkg](https://unpkg.com/browse/@matterfact/embed/examples/embed-demo/), or
|
|
258
356
|
after `npm install @matterfact/embed` find it at
|
|
259
357
|
`node_modules/@matterfact/embed/examples/embed-demo/` — copy it out, `npm install`, `npm run dev`.
|