@matterfact/embed 0.8.0 → 0.10.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 +191 -0
- package/dist/{chunk-R2ZEJARX.js → chunk-4AE5WINC.js} +233 -17
- package/dist/chunk-4AE5WINC.js.map +1 -0
- package/dist/{chunk-PNSYFXXU.js → chunk-CFDPCZO3.js} +233 -15
- package/dist/chunk-CFDPCZO3.js.map +1 -0
- package/dist/{chunk-UD7CAQXV.js → chunk-DXLHTFB4.js} +2 -2
- package/dist/chunk-RL6VIGWK.js +2 -0
- package/dist/chunk-TWMHQF7O.js +3 -0
- package/dist/chunk-TWMHQF7O.js.map +7 -0
- package/dist/{context-MVGSYIMB.js → context-HOOW63MO.js} +6 -2
- package/dist/context-SSQ4HUP3.js +3 -0
- package/dist/{context-ARBB2XD6.js.map → context-SSQ4HUP3.js.map} +1 -1
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +2 -2
- package/dist/index.cjs +243 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -2
- package/dist/index.d.ts +92 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +299 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +172 -1
- package/dist/react.d.ts +172 -1
- package/dist/react.js +60 -4
- package/dist/react.js.map +1 -1
- package/dist/{snapshot-GL4YBMXD.js → snapshot-CRY2IBX6.js} +3 -3
- package/dist/{snapshot-GL4YBMXD.js.map → snapshot-CRY2IBX6.js.map} +1 -1
- package/dist/{snapshot-UGTXZVB6.js → snapshot-EYRXPLRC.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-PNSYFXXU.js.map +0 -1
- package/dist/chunk-R2ZEJARX.js.map +0 -1
- package/dist/chunk-UQCETVRF.js +0 -2
- package/dist/chunk-W52Q7G4J.js +0 -3
- package/dist/chunk-W52Q7G4J.js.map +0 -7
- package/dist/context-ARBB2XD6.js +0 -3
- /package/dist/{chunk-UD7CAQXV.js.map → chunk-DXLHTFB4.js.map} +0 -0
- /package/dist/{chunk-UQCETVRF.js.map → chunk-RL6VIGWK.js.map} +0 -0
- /package/dist/{context-MVGSYIMB.js.map → context-HOOW63MO.js.map} +0 -0
- /package/dist/{snapshot-UGTXZVB6.js.map → snapshot-EYRXPLRC.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* shapes are right, "deeper integration" is a transport swap (postMessage ->
|
|
19
19
|
* direct call), not a rewrite. So model the DOMAIN here, not the plumbing.
|
|
20
20
|
*/
|
|
21
|
-
declare const PROTOCOL_VERSION =
|
|
21
|
+
declare const PROTOCOL_VERSION = 3;
|
|
22
22
|
/** Every message is namespaced so we never collide with the host page's own postMessage traffic. */
|
|
23
23
|
declare const CHANNEL = "mf-embed";
|
|
24
24
|
/**
|
|
@@ -58,6 +58,43 @@ interface PageEntity {
|
|
|
58
58
|
text?: string;
|
|
59
59
|
data?: Record<string, unknown>;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* How a route's content is classified, for the annotated site map.
|
|
63
|
+
*
|
|
64
|
+
* The host DECORATES the site map we auto-derive (see `SiteMapEntry`) so the agent
|
|
65
|
+
* knows which routes carry MATTERFACT content and of what kind — app-wide awareness
|
|
66
|
+
* it can navigate toward. This is CLASSIFICATION only: no per-instance ids, and never
|
|
67
|
+
* a capability token. The concrete artifact/document on the CURRENT page still arrives
|
|
68
|
+
* via `host.context` entities / `host.artifactGrants`, resolved per page.
|
|
69
|
+
*
|
|
70
|
+
* - `mf-artifact` — a co-embedded matterfact artifact (its slug); the token stays on
|
|
71
|
+
* the live iframe / grant, never here.
|
|
72
|
+
* - `mf-document` — a matterfact document (dossier/report), resolved to an MF_DOC_ID
|
|
73
|
+
* host-side per page.
|
|
74
|
+
* - `host-data` — the host's own data; not a matterfact entity.
|
|
75
|
+
*/
|
|
76
|
+
type ContentClass = {
|
|
77
|
+
kind: 'mf-artifact';
|
|
78
|
+
slug: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'mf-document';
|
|
81
|
+
doctype: string;
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'host-data';
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* One route in the annotated site map: the path pattern + label we derived, plus the
|
|
87
|
+
* host's content classification. `current` marks the route the user is on.
|
|
88
|
+
*/
|
|
89
|
+
interface SiteMapEntry {
|
|
90
|
+
/** Route pattern or path, e.g. '/app/company/:ticker/dossier'. */
|
|
91
|
+
path: string;
|
|
92
|
+
/** Human label for the route ('Company Dossier'). */
|
|
93
|
+
label?: string;
|
|
94
|
+
/** The host's classification of this route's content, when it annotated it. */
|
|
95
|
+
content?: ContentClass;
|
|
96
|
+
current?: boolean;
|
|
97
|
+
}
|
|
61
98
|
/** A co-embedded artifact's read-only capability, for the backend to materialize its
|
|
62
99
|
* data. Backend-only — never rendered. `token` is the artifact's own embed token. */
|
|
63
100
|
interface ArtifactGrant {
|
|
@@ -65,6 +102,38 @@ interface ArtifactGrant {
|
|
|
65
102
|
owner: string;
|
|
66
103
|
token: string;
|
|
67
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* A DECLARED artifact grant — the `<MatterfactAgent artifacts>` prop (or
|
|
107
|
+
* `window.matterfact.artifacts`). Same wire shape as a grant discovered by scanning
|
|
108
|
+
* co-embedded `<MatterfactArtifact>` iframes, plus an optional `label`; it feeds the
|
|
109
|
+
* SAME `host.artifactGrants` channel. This is how a host makes a board reachable from
|
|
110
|
+
* a route where its iframe ISN'T mounted, without hidden zero-size iframes smuggling
|
|
111
|
+
* the token into the DOM. The token stays in the grant channel, never in message text.
|
|
112
|
+
*/
|
|
113
|
+
interface DeclaredArtifact {
|
|
114
|
+
slug: string;
|
|
115
|
+
owner: string;
|
|
116
|
+
token: string;
|
|
117
|
+
label?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* One host-tool lifecycle event, surfaced to the host via `onToolEvent` (and the dev
|
|
121
|
+
* panel) — the host's own telemetry hook. Fired loader-side; a throwing or slow
|
|
122
|
+
* callback here NEVER blocks or breaks the call path.
|
|
123
|
+
*
|
|
124
|
+
* - `advertise` — the merged tool list changed (fired with the new set's names).
|
|
125
|
+
* - `call` — a tool call is about to run (`args` present).
|
|
126
|
+
* - `result` — the call settled (`ok`/`error`/`ms`).
|
|
127
|
+
*/
|
|
128
|
+
interface ToolEvent {
|
|
129
|
+
phase: 'advertise' | 'call' | 'result';
|
|
130
|
+
name: string;
|
|
131
|
+
toolClass: 'hoist' | 'mf' | 'app';
|
|
132
|
+
args?: unknown;
|
|
133
|
+
ok?: boolean;
|
|
134
|
+
error?: string;
|
|
135
|
+
ms?: number;
|
|
136
|
+
}
|
|
68
137
|
/**
|
|
69
138
|
* A snapshot of the page as the agent sees it.
|
|
70
139
|
*
|
|
@@ -174,6 +243,17 @@ type HostToWidget = {
|
|
|
174
243
|
} | {
|
|
175
244
|
type: 'host.artifactGrants';
|
|
176
245
|
grants: ArtifactGrant[];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The annotated site map — the app's routes with the host's content
|
|
249
|
+
* classification. Sent on mount and re-sent on navigation (a virtualized SPA can
|
|
250
|
+
* change what's routable). Distinct from the per-page `host.context`: this is the
|
|
251
|
+
* whole app's structure, so the agent can reason about and navigate toward MF
|
|
252
|
+
* content the user isn't currently looking at.
|
|
253
|
+
*/
|
|
254
|
+
| {
|
|
255
|
+
type: 'host.sitemap';
|
|
256
|
+
sitemap: SiteMapEntry[];
|
|
177
257
|
} | {
|
|
178
258
|
type: 'host.tools';
|
|
179
259
|
tools: HostTool[];
|
|
@@ -356,6 +436,16 @@ type WidgetToHost = {
|
|
|
356
436
|
/** The widget has no session; the host must run the hosted-login popup. */
|
|
357
437
|
| {
|
|
358
438
|
type: 'widget.needsAuth';
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Deeplink the host to one of its OWN routes — the "open on page" control on a
|
|
442
|
+
* co-embedded document's side-panel viewer. The widget is a cross-origin iframe and
|
|
443
|
+
* can't navigate the top window itself, so it asks the loader, which resolves the
|
|
444
|
+
* href against the host location and refuses anything off the host's own origin.
|
|
445
|
+
*/
|
|
446
|
+
| {
|
|
447
|
+
type: 'widget.navigate';
|
|
448
|
+
href: string;
|
|
359
449
|
};
|
|
360
450
|
/**
|
|
361
451
|
* Everything on the wire is wrapped.
|
|
@@ -603,4 +693,4 @@ declare class EmbedHost {
|
|
|
603
693
|
*/
|
|
604
694
|
declare function mount(config: LoaderConfig): EmbedHost;
|
|
605
695
|
|
|
606
|
-
export { type ActivityEvent, type ArtifactGrant, CHANNEL, type DomSnapshot, type ElementRef, EmbedHost, type Envelope, type FocusContext, type HostToWidget, type HostTool, type LoaderConfig, PROTOCOL_VERSION, type PageContext, type PageEntity, type ToolCall, type WidgetToHost, envelope, isEnvelope, mount, readConfig };
|
|
696
|
+
export { type ActivityEvent, type ArtifactGrant, CHANNEL, type ContentClass, type DeclaredArtifact, type DomSnapshot, type ElementRef, EmbedHost, type Envelope, type FocusContext, type HostToWidget, type HostTool, type LoaderConfig, PROTOCOL_VERSION, type PageContext, type PageEntity, type SiteMapEntry, type ToolCall, type ToolEvent, type WidgetToHost, envelope, isEnvelope, mount, readConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* shapes are right, "deeper integration" is a transport swap (postMessage ->
|
|
19
19
|
* direct call), not a rewrite. So model the DOMAIN here, not the plumbing.
|
|
20
20
|
*/
|
|
21
|
-
declare const PROTOCOL_VERSION =
|
|
21
|
+
declare const PROTOCOL_VERSION = 3;
|
|
22
22
|
/** Every message is namespaced so we never collide with the host page's own postMessage traffic. */
|
|
23
23
|
declare const CHANNEL = "mf-embed";
|
|
24
24
|
/**
|
|
@@ -58,6 +58,43 @@ interface PageEntity {
|
|
|
58
58
|
text?: string;
|
|
59
59
|
data?: Record<string, unknown>;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* How a route's content is classified, for the annotated site map.
|
|
63
|
+
*
|
|
64
|
+
* The host DECORATES the site map we auto-derive (see `SiteMapEntry`) so the agent
|
|
65
|
+
* knows which routes carry MATTERFACT content and of what kind — app-wide awareness
|
|
66
|
+
* it can navigate toward. This is CLASSIFICATION only: no per-instance ids, and never
|
|
67
|
+
* a capability token. The concrete artifact/document on the CURRENT page still arrives
|
|
68
|
+
* via `host.context` entities / `host.artifactGrants`, resolved per page.
|
|
69
|
+
*
|
|
70
|
+
* - `mf-artifact` — a co-embedded matterfact artifact (its slug); the token stays on
|
|
71
|
+
* the live iframe / grant, never here.
|
|
72
|
+
* - `mf-document` — a matterfact document (dossier/report), resolved to an MF_DOC_ID
|
|
73
|
+
* host-side per page.
|
|
74
|
+
* - `host-data` — the host's own data; not a matterfact entity.
|
|
75
|
+
*/
|
|
76
|
+
type ContentClass = {
|
|
77
|
+
kind: 'mf-artifact';
|
|
78
|
+
slug: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'mf-document';
|
|
81
|
+
doctype: string;
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'host-data';
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* One route in the annotated site map: the path pattern + label we derived, plus the
|
|
87
|
+
* host's content classification. `current` marks the route the user is on.
|
|
88
|
+
*/
|
|
89
|
+
interface SiteMapEntry {
|
|
90
|
+
/** Route pattern or path, e.g. '/app/company/:ticker/dossier'. */
|
|
91
|
+
path: string;
|
|
92
|
+
/** Human label for the route ('Company Dossier'). */
|
|
93
|
+
label?: string;
|
|
94
|
+
/** The host's classification of this route's content, when it annotated it. */
|
|
95
|
+
content?: ContentClass;
|
|
96
|
+
current?: boolean;
|
|
97
|
+
}
|
|
61
98
|
/** A co-embedded artifact's read-only capability, for the backend to materialize its
|
|
62
99
|
* data. Backend-only — never rendered. `token` is the artifact's own embed token. */
|
|
63
100
|
interface ArtifactGrant {
|
|
@@ -65,6 +102,38 @@ interface ArtifactGrant {
|
|
|
65
102
|
owner: string;
|
|
66
103
|
token: string;
|
|
67
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* A DECLARED artifact grant — the `<MatterfactAgent artifacts>` prop (or
|
|
107
|
+
* `window.matterfact.artifacts`). Same wire shape as a grant discovered by scanning
|
|
108
|
+
* co-embedded `<MatterfactArtifact>` iframes, plus an optional `label`; it feeds the
|
|
109
|
+
* SAME `host.artifactGrants` channel. This is how a host makes a board reachable from
|
|
110
|
+
* a route where its iframe ISN'T mounted, without hidden zero-size iframes smuggling
|
|
111
|
+
* the token into the DOM. The token stays in the grant channel, never in message text.
|
|
112
|
+
*/
|
|
113
|
+
interface DeclaredArtifact {
|
|
114
|
+
slug: string;
|
|
115
|
+
owner: string;
|
|
116
|
+
token: string;
|
|
117
|
+
label?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* One host-tool lifecycle event, surfaced to the host via `onToolEvent` (and the dev
|
|
121
|
+
* panel) — the host's own telemetry hook. Fired loader-side; a throwing or slow
|
|
122
|
+
* callback here NEVER blocks or breaks the call path.
|
|
123
|
+
*
|
|
124
|
+
* - `advertise` — the merged tool list changed (fired with the new set's names).
|
|
125
|
+
* - `call` — a tool call is about to run (`args` present).
|
|
126
|
+
* - `result` — the call settled (`ok`/`error`/`ms`).
|
|
127
|
+
*/
|
|
128
|
+
interface ToolEvent {
|
|
129
|
+
phase: 'advertise' | 'call' | 'result';
|
|
130
|
+
name: string;
|
|
131
|
+
toolClass: 'hoist' | 'mf' | 'app';
|
|
132
|
+
args?: unknown;
|
|
133
|
+
ok?: boolean;
|
|
134
|
+
error?: string;
|
|
135
|
+
ms?: number;
|
|
136
|
+
}
|
|
68
137
|
/**
|
|
69
138
|
* A snapshot of the page as the agent sees it.
|
|
70
139
|
*
|
|
@@ -174,6 +243,17 @@ type HostToWidget = {
|
|
|
174
243
|
} | {
|
|
175
244
|
type: 'host.artifactGrants';
|
|
176
245
|
grants: ArtifactGrant[];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The annotated site map — the app's routes with the host's content
|
|
249
|
+
* classification. Sent on mount and re-sent on navigation (a virtualized SPA can
|
|
250
|
+
* change what's routable). Distinct from the per-page `host.context`: this is the
|
|
251
|
+
* whole app's structure, so the agent can reason about and navigate toward MF
|
|
252
|
+
* content the user isn't currently looking at.
|
|
253
|
+
*/
|
|
254
|
+
| {
|
|
255
|
+
type: 'host.sitemap';
|
|
256
|
+
sitemap: SiteMapEntry[];
|
|
177
257
|
} | {
|
|
178
258
|
type: 'host.tools';
|
|
179
259
|
tools: HostTool[];
|
|
@@ -356,6 +436,16 @@ type WidgetToHost = {
|
|
|
356
436
|
/** The widget has no session; the host must run the hosted-login popup. */
|
|
357
437
|
| {
|
|
358
438
|
type: 'widget.needsAuth';
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Deeplink the host to one of its OWN routes — the "open on page" control on a
|
|
442
|
+
* co-embedded document's side-panel viewer. The widget is a cross-origin iframe and
|
|
443
|
+
* can't navigate the top window itself, so it asks the loader, which resolves the
|
|
444
|
+
* href against the host location and refuses anything off the host's own origin.
|
|
445
|
+
*/
|
|
446
|
+
| {
|
|
447
|
+
type: 'widget.navigate';
|
|
448
|
+
href: string;
|
|
359
449
|
};
|
|
360
450
|
/**
|
|
361
451
|
* Everything on the wire is wrapped.
|
|
@@ -603,4 +693,4 @@ declare class EmbedHost {
|
|
|
603
693
|
*/
|
|
604
694
|
declare function mount(config: LoaderConfig): EmbedHost;
|
|
605
695
|
|
|
606
|
-
export { type ActivityEvent, type ArtifactGrant, CHANNEL, type DomSnapshot, type ElementRef, EmbedHost, type Envelope, type FocusContext, type HostToWidget, type HostTool, type LoaderConfig, PROTOCOL_VERSION, type PageContext, type PageEntity, type ToolCall, type WidgetToHost, envelope, isEnvelope, mount, readConfig };
|
|
696
|
+
export { type ActivityEvent, type ArtifactGrant, CHANNEL, type ContentClass, type DeclaredArtifact, type DomSnapshot, type ElementRef, EmbedHost, type Envelope, type FocusContext, type HostToWidget, type HostTool, type LoaderConfig, PROTOCOL_VERSION, type PageContext, type PageEntity, type SiteMapEntry, type ToolCall, type ToolEvent, type WidgetToHost, envelope, isEnvelope, mount, readConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/protocol.ts
|
|
2
|
-
var PROTOCOL_VERSION =
|
|
2
|
+
var PROTOCOL_VERSION = 3;
|
|
3
3
|
var CHANNEL = "mf-embed";
|
|
4
4
|
function envelope(payload, id) {
|
|
5
5
|
return {
|
|
@@ -599,6 +599,9 @@ var EmbedHost = class {
|
|
|
599
599
|
case "widget.needsAuth":
|
|
600
600
|
void this.provideAuth();
|
|
601
601
|
break;
|
|
602
|
+
case "widget.navigate":
|
|
603
|
+
void this.loadContext().then((m) => m.navigateHost(msg.href));
|
|
604
|
+
break;
|
|
602
605
|
}
|
|
603
606
|
}
|
|
604
607
|
/**
|
|
@@ -715,7 +718,7 @@ var EmbedHost = class {
|
|
|
715
718
|
}
|
|
716
719
|
}
|
|
717
720
|
loadContext() {
|
|
718
|
-
this.context ?? (this.context = import('./context-
|
|
721
|
+
this.context ?? (this.context = import('./context-SSQ4HUP3.js').then((m) => {
|
|
719
722
|
m.start(
|
|
720
723
|
this.send,
|
|
721
724
|
this.config.origin,
|