@mgamadeus/ddd-agents 0.3.13 → 0.4.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 +33 -0
- package/dist/chat.js +12 -12
- package/dist/chat.js.map +1 -1
- package/dist/chunks/{ConversationMessageInputComposerWidgets-CPV4BK3v.js → ConversationMessageInputComposerWidgets-D5NlHJlV.js} +5 -5
- package/dist/chunks/{ConversationMessageInputComposerWidgets-CPV4BK3v.js.map → ConversationMessageInputComposerWidgets-D5NlHJlV.js.map} +1 -1
- package/dist/chunks/{WebSearchResultsConversationWidget-DTnsU_C-.js → WebSearchResultsConversationWidget-Dpy5qp4j.js} +237 -120
- package/dist/chunks/WebSearchResultsConversationWidget-Dpy5qp4j.js.map +1 -0
- package/dist/chunks/{canvas-feature-flags-BmmxC3bz.js → canvas-feature-flags-Cn8xBliA.js} +3 -2
- package/dist/chunks/{canvas-feature-flags-BmmxC3bz.js.map → canvas-feature-flags-Cn8xBliA.js.map} +1 -1
- package/dist/chunks/{canvas-reducers-8GHP6886.js → canvas-reducers-CgL_H6Oc.js} +2 -3
- package/dist/chunks/{canvas-reducers-8GHP6886.js.map → canvas-reducers-CgL_H6Oc.js.map} +1 -1
- package/dist/chunks/{canvas-title-slot-context-C43hdu4i.js → canvas-title-slot-context-_Kf45ABB.js} +3 -3
- package/dist/chunks/{canvas-title-slot-context-C43hdu4i.js.map → canvas-title-slot-context-_Kf45ABB.js.map} +1 -1
- package/dist/chunks/{canvasBodies-DJ-gJy-T.js → canvasBodies-4iDPQLb0.js} +5 -5
- package/dist/chunks/{canvasBodies-DJ-gJy-T.js.map → canvasBodies-4iDPQLb0.js.map} +1 -1
- package/dist/chunks/{canvasStorage-EZDxQQaK.js → canvasStorage-De3tMK4L.js} +2 -2
- package/dist/chunks/{canvasStorage-EZDxQQaK.js.map → canvasStorage-De3tMK4L.js.map} +1 -1
- package/dist/chunks/{widget-name-resolver-Ne0vKw4N.js → widget-name-resolver-JEJ1Hd0T.js} +2 -2
- package/dist/chunks/{widget-name-resolver-Ne0vKw4N.js.map → widget-name-resolver-JEJ1Hd0T.js.map} +1 -1
- package/dist/client-testing.js +4 -4
- package/dist/files/widgets/DriveFilesConversationWidget/DriveFilesConversationWidget.md +3 -0
- package/dist/image-render.js +7 -7
- package/dist/index.js +39 -17
- package/dist/index.js.map +1 -1
- package/dist/kit.js +2 -2
- package/dist/preview.js +5 -6
- package/dist/preview.js.map +1 -1
- package/dist/renderer.js +61 -57
- package/dist/renderer.js.map +1 -1
- package/dist/styles.css +8 -0
- package/dist/types/entries/index.d.ts +2 -0
- package/dist/types/entries/widgets.d.ts +1 -0
- package/dist/types/renderer/canvas/canvas-behaviours.d.ts +18 -6
- package/dist/types/renderer/canvas/canvas-kind-declarations.d.ts +17 -0
- package/dist/types/renderer/canvas/canvas-kinds.d.ts +42 -0
- package/dist/types/renderer/canvas/canvas-state.d.ts +12 -0
- package/dist/types/widgets/CanvasLauncherWidget/CanvasLauncherWidget.d.ts +6 -1
- package/dist/types/widgets/DriveFilesConversationWidget/DriveFilesConversationWidget.d.ts +3 -2
- package/dist/types/widgets/DriveFilesConversationWidget/shared/drive-file-canvas-openers.d.ts +29 -0
- package/dist/widgets.js +61 -58
- package/package.json +1 -1
- package/public-api.json +15 -0
- package/dist/chunks/WebSearchResultsConversationWidget-DTnsU_C-.js.map +0 -1
- package/dist/chunks/canvas-behaviours-C9hzl4a0.js +0 -45
- package/dist/chunks/canvas-behaviours-C9hzl4a0.js.map +0 -1
package/dist/renderer.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { C, a, b, M, W, c, d, e, f, g, i, p, r, s, u } from "./chunks/canvas-title-slot-context-
|
|
3
|
-
import { m as findWidgetFenceByPayloadHash, n as findWidgetFencesInMarkdown } from "./chunks/widget-name-resolver-
|
|
4
|
-
import { o, p as p2, q, t, v, w, j, x, y, z, B, D, F, G } from "./chunks/widget-name-resolver-
|
|
5
|
-
import {
|
|
6
|
-
import { C as C2,
|
|
7
|
-
import {
|
|
8
|
-
import { c as c4, u as u3 } from "./chunks/canvasBodies-DJ-gJy-T.js";
|
|
2
|
+
import { C, a, b, M, W, c, d, e, f, g, i, p, r, s, u } from "./chunks/canvas-title-slot-context-_Kf45ABB.js";
|
|
3
|
+
import { m as findWidgetFenceByPayloadHash, n as findWidgetFencesInMarkdown } from "./chunks/widget-name-resolver-JEJ1Hd0T.js";
|
|
4
|
+
import { o, p as p2, q, t, v, w, j, x, y, z, B, D, F, G } from "./chunks/widget-name-resolver-JEJ1Hd0T.js";
|
|
5
|
+
import { m as useResolvedConversationWidgetAgentSpaceKey, p as payloadHashOfInstanceId } from "./chunks/WebSearchResultsConversationWidget-Dpy5qp4j.js";
|
|
6
|
+
import { C as C2, n, o as o2, q as q2, t as t2, v as v2, w as w2, x as x2, y as y2, D as D2, L, R, S, W as W2, z as z2, h, A, B as B2, E, F as F2, G as G2, H, I, J, K, N, O, j as j2, P, Q, i as i2, T, a as a2, U, V, X, Y, Z, g as g2, _, s as s2, $, u as u2, a0, a1, a2 as a22, a3, a4, a5 } from "./chunks/WebSearchResultsConversationWidget-Dpy5qp4j.js";
|
|
7
|
+
import { c as c2, u as u3 } from "./chunks/canvasBodies-4iDPQLb0.js";
|
|
9
8
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
10
9
|
import { n as Skeleton } from "./chunks/link-navigation-DH3f2g9a.js";
|
|
11
10
|
import { ac, ad, ae, af, ag } from "./chunks/link-navigation-DH3f2g9a.js";
|
|
12
11
|
import { useMemo } from "react";
|
|
13
|
-
import { a as
|
|
14
|
-
import {
|
|
12
|
+
import { a as a6, b as b2, c as c3, d as d2, e as e2 } from "./chunks/canvas-reducers-CgL_H6Oc.js";
|
|
13
|
+
import { a as a7 } from "./chunks/canvas-feature-flags-Cn8xBliA.js";
|
|
15
14
|
const pickSection = (payloadValue, fallback) => {
|
|
16
15
|
return payloadValue ?? fallback.data ?? void 0;
|
|
17
16
|
};
|
|
@@ -41,7 +40,7 @@ const sectionCoversKeys = (payloadValue, requiredKeys) => {
|
|
|
41
40
|
if (!payloadValue) {
|
|
42
41
|
return false;
|
|
43
42
|
}
|
|
44
|
-
return requiredKeys.every((
|
|
43
|
+
return requiredKeys.every((k) => payloadValue[k] !== void 0);
|
|
45
44
|
};
|
|
46
45
|
const isSectionIncomplete = (payloadValue, fallback, requiredKeys) => {
|
|
47
46
|
if (!fallback.isLoading) {
|
|
@@ -50,8 +49,8 @@ const isSectionIncomplete = (payloadValue, fallback, requiredKeys) => {
|
|
|
50
49
|
if (!payloadValue) {
|
|
51
50
|
return true;
|
|
52
51
|
}
|
|
53
|
-
return requiredKeys.some((
|
|
54
|
-
return payloadValue[
|
|
52
|
+
return requiredKeys.some((k) => {
|
|
53
|
+
return payloadValue[k] === void 0;
|
|
55
54
|
});
|
|
56
55
|
};
|
|
57
56
|
const ConversationWidgetGateSkeleton = () => /* @__PURE__ */ jsxs("div", { "data-testid": "ConversationWidgetGateSkeleton", children: [
|
|
@@ -98,22 +97,22 @@ const withConversationWidgetVariant = (base, rawPayload) => {
|
|
|
98
97
|
};
|
|
99
98
|
export {
|
|
100
99
|
ac as AgentsWidgetHydrationStateContainer,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
C2 as CANVAS_BOXED_INSET_PX,
|
|
101
|
+
n as CANVAS_FILLS_SCREEN_WIDTH_PERCENT,
|
|
102
|
+
o2 as CANVAS_MIN_WIDTH_PX,
|
|
103
|
+
q2 as CHAT_COLUMN_MIN_WIDTH_PX,
|
|
105
104
|
C as CanvasTitleSlotContext,
|
|
106
105
|
a as ConversationMarkdown,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
t2 as ConversationWidgetActions,
|
|
107
|
+
v2 as ConversationWidgetAgentSpaceFrame,
|
|
108
|
+
w2 as ConversationWidgetAgentSpaceHeader,
|
|
109
|
+
x2 as ConversationWidgetContext,
|
|
111
110
|
o as ConversationWidgetErrorBoundary,
|
|
112
111
|
p2 as ConversationWidgetFeatureGate,
|
|
113
112
|
ConversationWidgetGateSkeleton,
|
|
114
113
|
b as ConversationWidgetHost,
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
y2 as ConversationWidgetRenderContext,
|
|
115
|
+
D2 as DEFAULT_CANVAS_WIDTH_PERCENT,
|
|
117
116
|
L as LEGACY_CARD_CLICK_ORIGIN,
|
|
118
117
|
M as MarkdownLink,
|
|
119
118
|
R as ReadOnlyConversationWidgetProvider,
|
|
@@ -123,66 +122,71 @@ export {
|
|
|
123
122
|
ae as WidgetHydrationSlice,
|
|
124
123
|
W2 as WidgetRenderReportContext,
|
|
125
124
|
q as addComposedNodeSchemaApplicationPart,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
a6 as applyClearCanvas,
|
|
126
|
+
b2 as applyCloseCanvas,
|
|
127
|
+
c3 as applyOpenCanvas,
|
|
128
|
+
d2 as applyResetCanvasForNewTurn,
|
|
129
|
+
e2 as applySetCanvasCreatedEntityId,
|
|
131
130
|
c as buildComposerWidgetFenceBlock,
|
|
132
131
|
d as buildMessageTextWithComposerWidgets,
|
|
133
|
-
|
|
132
|
+
z2 as buildWidgetAgentSpaceKeyProps,
|
|
134
133
|
e as buildWidgetRenderReportSignal,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
h as canvasBehaviourOf,
|
|
135
|
+
c2 as canvasBodies,
|
|
136
|
+
a7 as canvasFeatureFlagOf,
|
|
137
|
+
A as canvasInstanceIdForActiveAgentSpace,
|
|
138
|
+
B2 as canvasInstanceIdForAgentSpace,
|
|
139
|
+
E as canvasInstanceIdForEntity,
|
|
140
|
+
F2 as canvasInstanceIdForMessage,
|
|
141
|
+
G2 as canvasInstanceIdForMessagePayload,
|
|
142
|
+
H as canvasInstanceIdForReference,
|
|
143
|
+
I as canvasKindOpenerWidgetNamesOf,
|
|
144
|
+
J as canvasWidthPercentOf,
|
|
144
145
|
t as closestWidgetNames,
|
|
145
146
|
v as composedNodeSchema,
|
|
146
147
|
w as composedViewTreeToWire,
|
|
147
148
|
j as conversationWidgetRegistry,
|
|
148
149
|
af as createAgentsWidgetHydrationStateStore,
|
|
149
150
|
f as deepLinkableWidgetNameForCanvas,
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
K as defaultConversationWidgetCallbacks,
|
|
152
|
+
N as entityIdOfInstanceId,
|
|
152
153
|
findWidgetFenceByPayloadHash,
|
|
153
154
|
findWidgetFencesInMarkdown,
|
|
154
155
|
x as getComposedNodeSchema,
|
|
155
156
|
y as getConversationWidgetRegistryRevision,
|
|
156
|
-
|
|
157
|
+
O as getDeclaredCanvasIds,
|
|
157
158
|
ag as getDefaultAgentsStateStore,
|
|
158
159
|
g as getWidgetClickSignalSources,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
j2 as getWidgetHydrator,
|
|
161
|
+
P as hasWidgetHydrator,
|
|
162
|
+
Q as isCanvasAnchorLoaded,
|
|
163
|
+
i2 as isCanvasId,
|
|
164
|
+
T as isCanvasReference,
|
|
165
|
+
a2 as isPackageCanvasId,
|
|
163
166
|
isSectionIncomplete,
|
|
164
167
|
isSectionLoading,
|
|
165
168
|
i as isWidgetClickSignalSource,
|
|
166
169
|
mergeSection,
|
|
167
170
|
mergeSectionValues,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
U as messageAnchor,
|
|
172
|
+
V as packageCanvasBehaviours,
|
|
173
|
+
X as pageAnchor,
|
|
171
174
|
p as parseWidgetRenderReportSignal,
|
|
172
175
|
payloadHashOfInstanceId,
|
|
173
176
|
pickSection,
|
|
174
177
|
z as readComposedViewTree,
|
|
175
178
|
B as readConversationWidgetRegistrations,
|
|
176
179
|
D as readOpenEntityActionTarget,
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
Y as readWidgetAgentSpaceKeyAttribute,
|
|
181
|
+
Z as referenceOfCanvasInstanceId,
|
|
182
|
+
g2 as registerWidgetHydrator,
|
|
179
183
|
F as resolveCanonicalWidgetName,
|
|
180
184
|
r as resolveDeepLinkableWidget,
|
|
181
185
|
G as resolveWidgetName,
|
|
182
|
-
|
|
186
|
+
_ as sameCanvasAnchor,
|
|
183
187
|
s2 as sameCanvasIdentity,
|
|
184
188
|
sectionCoversKeys,
|
|
185
|
-
|
|
189
|
+
$ as shortStringHash,
|
|
186
190
|
s as splitComposerWidgetFencesFromMessageText,
|
|
187
191
|
u2 as unregisterWidgetHydrator,
|
|
188
192
|
useAnchorWidgetAgentSpaceKey,
|
|
@@ -190,13 +194,13 @@ export {
|
|
|
190
194
|
u3 as useAnchorWidgetPayload,
|
|
191
195
|
u as useCanvasTitleSlot,
|
|
192
196
|
useConversationWidgetAgentSpaceFallback,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
a0 as useConversationWidgetContext,
|
|
198
|
+
a1 as useIsEmailWidgetRender,
|
|
199
|
+
a22 as useReportWidgetRenderStatus,
|
|
196
200
|
useResolvedConversationWidgetAgentSpaceKey,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
a3 as useWidgetHydration,
|
|
202
|
+
a4 as useWidgetMemory,
|
|
203
|
+
a5 as useWidgetRenderReporter,
|
|
200
204
|
withConversationWidgetVariant
|
|
201
205
|
};
|
|
202
206
|
//# sourceMappingURL=renderer.js.map
|
package/dist/renderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sources":["../src/renderer/widget-hydration/section-hydration.ts","../src/renderer/_access/ConversationWidgetGateSkeleton.tsx","../src/renderer/_agent-space/use-conversation-widget-agent-space-fallback.ts","../src/renderer/canvas/use-anchor-widget-agent-space-key.ts","../src/renderer/read-conversation-widget-variant.ts"],"sourcesContent":["export interface SectionHydrationResult<T> {\n data: T | null;\n isLoading: boolean;\n error?: string | null;\n}\n\nexport type SectionHydrator<T> = () => SectionHydrationResult<T>;\n\n/**\n * Prefer payload-provided value; fall back to a hydrator result; undefined otherwise.\n * Callers should call the fallback hook unconditionally (React hook rules) and pass\n * its result here.\n */\nexport const pickSection = <T>(payloadValue: T | undefined, fallback: SectionHydrationResult<T>): T | undefined => {\n return payloadValue ?? fallback.data ?? undefined;\n};\n\n/**\n * True when payload is missing the value AND the fallback is still loading.\n */\nexport const isSectionLoading = <T>(payloadValue: T | undefined, fallback: SectionHydrationResult<T>): boolean => {\n return payloadValue === undefined && fallback.isLoading;\n};\n\n/**\n * Field-level merge of two section values. Payload fields (when defined) win\n * over hydrated fields; undefined payload fields are filled from the hydrated\n * value. Use when the agent sends partial section data (e.g. only a CTA) and\n * the client hydrates the remaining fields.\n */\nexport const mergeSectionValues = <T extends object>(\n payloadValue: T | undefined,\n hydratedValue: T | undefined,\n): T | undefined => {\n if (!hydratedValue) {\n return payloadValue;\n }\n if (!payloadValue) {\n return hydratedValue;\n }\n\n const defined: Partial<T> = {};\n for (const key of Object.keys(payloadValue) as Array<keyof T>) {\n const v = payloadValue[key];\n if (v !== undefined) {\n defined[key] = v;\n }\n }\n return { ...hydratedValue, ...defined } as T;\n};\n\n/**\n * Field-level merge for object sections. Payload fields (when defined) win over\n * fallback fields. Undefined payload fields are filled from the fallback. Use\n * this when the agent sends partial section data (e.g. only a CTA) and the\n * client needs to hydrate the remaining fields from app state.\n */\nexport const mergeSection = <T extends object>(\n payloadValue: T | undefined,\n fallback: SectionHydrationResult<T>,\n): T | undefined => {\n return mergeSectionValues(payloadValue, fallback.data ?? undefined);\n};\n\n/**\n * True when the payload provides every field in `requiredKeys` — the section\n * can render straight from the agent payload without waiting for hydration.\n */\nexport const sectionCoversKeys = <T extends object>(\n payloadValue: T | undefined,\n requiredKeys: ReadonlyArray<keyof T>,\n): boolean => {\n if (!payloadValue) {\n return false;\n }\n return requiredKeys.every((k) => payloadValue[k] !== undefined);\n};\n\n/**\n * True when the fallback is still loading AND the payload has not provided\n * every expected field (listed in `requiredKeys`). Use together with\n * `mergeSection` to decide whether to show a skeleton for the section.\n */\nexport const isSectionIncomplete = <T extends object>(\n payloadValue: T | undefined,\n fallback: SectionHydrationResult<T>,\n requiredKeys: ReadonlyArray<keyof T>,\n): boolean => {\n if (!fallback.isLoading) {\n return false;\n }\n if (!payloadValue) {\n return true;\n }\n return requiredKeys.some((k) => {\n return (payloadValue as T)[k] === undefined;\n });\n};\n","import { Skeleton } from \"../../provider/components\";\nimport React from \"react\";\n\n/**\n * Neutral loading state shown by ConversationWidgetFeatureGate while another agent space's feature\n * flags are being fetched. The gate can't know the gated widget's own skeleton, so this\n * is a generic widget-sized placeholder.\n */\nexport const ConversationWidgetGateSkeleton = () => (\n <div data-testid=\"ConversationWidgetGateSkeleton\">\n <Skeleton height=\"20px\" width=\"40%\" />\n <Skeleton height=\"64px\" width=\"100%\" borderRadius=\"8px\" />\n </div>\n);\n","import { SectionHydrationResult } from \"../widget-hydration\";\nimport { useResolvedConversationWidgetAgentSpaceKey } from \"./use-resolved-conversation-widget-agent-space-key\";\n\n/**\n * The empty fallback of a widget of another agent space: such a widget must not merge what the app holds for the\n * ACTIVE agent space into its own data.\n */\nconst ANOTHER_AGENT_SPACE_EMPTY_FALLBACK = { data: null, isLoading: false, error: null } as const;\n\n/**\n * Resolves the widget's agent space and picks the fallback every snapshot widget needs with it.\n *\n * - Active agent space → the caller's live `activeFallback`, so `mergeSection` keeps merging the app's fresher data.\n * - Another agent space → a static empty result, so the widget's own data passes through `mergeSection` unmixed.\n *\n * Pass the result of the active-fallback hook in directly:\n * useConversationWidgetAgentSpaceFallback(agentSpaceKeyAttribute, useSomeActiveHydration())\n * The hook order is the same on every render.\n */\nexport const useConversationWidgetAgentSpaceFallback = <T>(\n agentSpaceKeyAttribute: string | number | undefined,\n activeFallback: SectionHydrationResult<T>,\n): {\n anotherAgentSpaceKey: number | undefined;\n isAnotherAgentSpace: boolean;\n fallback: SectionHydrationResult<T>;\n} => {\n const { anotherAgentSpaceKey, isAnotherAgentSpace } = useResolvedConversationWidgetAgentSpaceKey(agentSpaceKeyAttribute);\n return {\n anotherAgentSpaceKey,\n isAnotherAgentSpace,\n fallback: isAnotherAgentSpace ? (ANOTHER_AGENT_SPACE_EMPTY_FALLBACK as SectionHydrationResult<T>) : activeFallback,\n };\n};\n","import { useMemo } from \"react\";\nimport { useResolvedConversationWidgetAgentSpaceKey } from \"../_agent-space/use-resolved-conversation-widget-agent-space-key\";\nimport type { CanvasState } from \"./canvas-state\";\nimport { payloadHashOfInstanceId } from \"./canvas-state\";\nimport { findWidgetFenceByPayloadHash, findWidgetFencesInMarkdown } from \"./find-widget-fences-in-markdown\";\n\n/**\n * The key of the agent space the fence of the anchor message names — unresolved, exactly what the inline widget\n * receives as its prop. Undefined for a page anchor, a missing anchor message or a fence that names no agent space.\n * For a body whose inline widget resolves the key itself, so both resolve it the same way.\n */\nexport const useAnchorWidgetFenceAgentSpaceKey = (\n canvas: CanvasState,\n anchorMessageMarkdown: string | null,\n widgetName: string,\n): string | undefined =>\n useMemo(() => {\n if (canvas.anchor.kind !== \"message\" || anchorMessageMarkdown === null) return undefined;\n const payloadHash = payloadHashOfInstanceId(canvas.instanceId);\n const fence =\n payloadHash !== undefined\n ? findWidgetFenceByPayloadHash(anchorMessageMarkdown, widgetName, payloadHash)\n : findWidgetFencesInMarkdown(anchorMessageMarkdown).find((candidate) => candidate.name === widgetName);\n return fence?.agentSpaceKey;\n }, [canvas.anchor, canvas.instanceId, anchorMessageMarkdown, widgetName]);\n\n/**\n * The agent space a message-anchored canvas body works on, resolved the way its inline widget resolves it: the agent\n * space the fence names when it is ANOTHER one than the active one, else the chat's agent space (`chatAgentSpaceKey`,\n * passed by the shell), else the active one. For a page anchor: the anchor's agent space.\n *\n * A fence that names the ACTIVE agent space is dropped here in favour of the chat's agent space — the order of the\n * inline widgets that compute `anotherAgentSpaceKey ?? chatAgentSpaceKey`. A widget whose inline render lets the\n * fence win reads {@link useAnchorWidgetFenceAgentSpaceKey} instead.\n */\nexport const useAnchorWidgetAgentSpaceKey = (\n canvas: CanvasState,\n anchorMessageMarkdown: string | null,\n widgetName: string,\n chatAgentSpaceKey: number | undefined,\n): number | undefined => {\n const fenceAgentSpaceKey = useAnchorWidgetFenceAgentSpaceKey(canvas, anchorMessageMarkdown, widgetName);\n const { anotherAgentSpaceKey, activeAgentSpaceKey } = useResolvedConversationWidgetAgentSpaceKey(fenceAgentSpaceKey);\n if (canvas.anchor.kind === \"page\") return canvas.anchor.agentSpaceKey;\n return anotherAgentSpaceKey ?? chatAgentSpaceKey ?? activeAgentSpaceKey;\n};\n","/**\n * Density flag shared by snapshot widgets. Lives on the payload, but it\n * is a PRESENTATION choice the agent makes — independent of whether the widget's data\n * came from the agent's payload or from live hydration.\n */\nexport type ConversationWidgetVariant = \"compact\" | \"full\";\n\ninterface WithVariant {\n variant?: ConversationWidgetVariant;\n}\n\n/**\n * Read just the `variant` flag out of a raw widget payload string, even when the\n * rest of the payload is incomplete (so the agent can request a density with a\n * minimal `{\"variant\":\"compact\"}` and let the data hydrate).\n */\nexport const readPayloadVariant = (rawPayload: string): ConversationWidgetVariant | undefined => {\n try {\n const parsed = JSON.parse(rawPayload) as { variant?: unknown };\n if (parsed && (parsed.variant === \"compact\" || parsed.variant === \"full\")) {\n return parsed.variant;\n }\n } catch {\n // Non-JSON or empty payload — no variant to read.\n }\n return undefined;\n};\n\n/**\n * Overlay the agent's requested `variant` onto the resolved widget data. The agent's\n * payload variant always wins; when the payload omits it the resolved data's own\n * variant (or the widget default) stands.\n */\nexport const withConversationWidgetVariant = <T extends WithVariant>(\n base: T | undefined,\n rawPayload: string,\n): T | undefined => {\n if (!base) {\n return base;\n }\n const variant = readPayloadVariant(rawPayload);\n return variant ? { ...base, variant } : base;\n};\n"],"names":["v","k"],"mappings":";;;;;;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.js","sources":["../src/renderer/widget-hydration/section-hydration.ts","../src/renderer/_access/ConversationWidgetGateSkeleton.tsx","../src/renderer/_agent-space/use-conversation-widget-agent-space-fallback.ts","../src/renderer/canvas/use-anchor-widget-agent-space-key.ts","../src/renderer/read-conversation-widget-variant.ts"],"sourcesContent":["export interface SectionHydrationResult<T> {\n data: T | null;\n isLoading: boolean;\n error?: string | null;\n}\n\nexport type SectionHydrator<T> = () => SectionHydrationResult<T>;\n\n/**\n * Prefer payload-provided value; fall back to a hydrator result; undefined otherwise.\n * Callers should call the fallback hook unconditionally (React hook rules) and pass\n * its result here.\n */\nexport const pickSection = <T>(payloadValue: T | undefined, fallback: SectionHydrationResult<T>): T | undefined => {\n return payloadValue ?? fallback.data ?? undefined;\n};\n\n/**\n * True when payload is missing the value AND the fallback is still loading.\n */\nexport const isSectionLoading = <T>(payloadValue: T | undefined, fallback: SectionHydrationResult<T>): boolean => {\n return payloadValue === undefined && fallback.isLoading;\n};\n\n/**\n * Field-level merge of two section values. Payload fields (when defined) win\n * over hydrated fields; undefined payload fields are filled from the hydrated\n * value. Use when the agent sends partial section data (e.g. only a CTA) and\n * the client hydrates the remaining fields.\n */\nexport const mergeSectionValues = <T extends object>(\n payloadValue: T | undefined,\n hydratedValue: T | undefined,\n): T | undefined => {\n if (!hydratedValue) {\n return payloadValue;\n }\n if (!payloadValue) {\n return hydratedValue;\n }\n\n const defined: Partial<T> = {};\n for (const key of Object.keys(payloadValue) as Array<keyof T>) {\n const v = payloadValue[key];\n if (v !== undefined) {\n defined[key] = v;\n }\n }\n return { ...hydratedValue, ...defined } as T;\n};\n\n/**\n * Field-level merge for object sections. Payload fields (when defined) win over\n * fallback fields. Undefined payload fields are filled from the fallback. Use\n * this when the agent sends partial section data (e.g. only a CTA) and the\n * client needs to hydrate the remaining fields from app state.\n */\nexport const mergeSection = <T extends object>(\n payloadValue: T | undefined,\n fallback: SectionHydrationResult<T>,\n): T | undefined => {\n return mergeSectionValues(payloadValue, fallback.data ?? undefined);\n};\n\n/**\n * True when the payload provides every field in `requiredKeys` — the section\n * can render straight from the agent payload without waiting for hydration.\n */\nexport const sectionCoversKeys = <T extends object>(\n payloadValue: T | undefined,\n requiredKeys: ReadonlyArray<keyof T>,\n): boolean => {\n if (!payloadValue) {\n return false;\n }\n return requiredKeys.every((k) => payloadValue[k] !== undefined);\n};\n\n/**\n * True when the fallback is still loading AND the payload has not provided\n * every expected field (listed in `requiredKeys`). Use together with\n * `mergeSection` to decide whether to show a skeleton for the section.\n */\nexport const isSectionIncomplete = <T extends object>(\n payloadValue: T | undefined,\n fallback: SectionHydrationResult<T>,\n requiredKeys: ReadonlyArray<keyof T>,\n): boolean => {\n if (!fallback.isLoading) {\n return false;\n }\n if (!payloadValue) {\n return true;\n }\n return requiredKeys.some((k) => {\n return (payloadValue as T)[k] === undefined;\n });\n};\n","import { Skeleton } from \"../../provider/components\";\nimport React from \"react\";\n\n/**\n * Neutral loading state shown by ConversationWidgetFeatureGate while another agent space's feature\n * flags are being fetched. The gate can't know the gated widget's own skeleton, so this\n * is a generic widget-sized placeholder.\n */\nexport const ConversationWidgetGateSkeleton = () => (\n <div data-testid=\"ConversationWidgetGateSkeleton\">\n <Skeleton height=\"20px\" width=\"40%\" />\n <Skeleton height=\"64px\" width=\"100%\" borderRadius=\"8px\" />\n </div>\n);\n","import { SectionHydrationResult } from \"../widget-hydration\";\nimport { useResolvedConversationWidgetAgentSpaceKey } from \"./use-resolved-conversation-widget-agent-space-key\";\n\n/**\n * The empty fallback of a widget of another agent space: such a widget must not merge what the app holds for the\n * ACTIVE agent space into its own data.\n */\nconst ANOTHER_AGENT_SPACE_EMPTY_FALLBACK = { data: null, isLoading: false, error: null } as const;\n\n/**\n * Resolves the widget's agent space and picks the fallback every snapshot widget needs with it.\n *\n * - Active agent space → the caller's live `activeFallback`, so `mergeSection` keeps merging the app's fresher data.\n * - Another agent space → a static empty result, so the widget's own data passes through `mergeSection` unmixed.\n *\n * Pass the result of the active-fallback hook in directly:\n * useConversationWidgetAgentSpaceFallback(agentSpaceKeyAttribute, useSomeActiveHydration())\n * The hook order is the same on every render.\n */\nexport const useConversationWidgetAgentSpaceFallback = <T>(\n agentSpaceKeyAttribute: string | number | undefined,\n activeFallback: SectionHydrationResult<T>,\n): {\n anotherAgentSpaceKey: number | undefined;\n isAnotherAgentSpace: boolean;\n fallback: SectionHydrationResult<T>;\n} => {\n const { anotherAgentSpaceKey, isAnotherAgentSpace } = useResolvedConversationWidgetAgentSpaceKey(agentSpaceKeyAttribute);\n return {\n anotherAgentSpaceKey,\n isAnotherAgentSpace,\n fallback: isAnotherAgentSpace ? (ANOTHER_AGENT_SPACE_EMPTY_FALLBACK as SectionHydrationResult<T>) : activeFallback,\n };\n};\n","import { useMemo } from \"react\";\nimport { useResolvedConversationWidgetAgentSpaceKey } from \"../_agent-space/use-resolved-conversation-widget-agent-space-key\";\nimport type { CanvasState } from \"./canvas-state\";\nimport { payloadHashOfInstanceId } from \"./canvas-state\";\nimport { findWidgetFenceByPayloadHash, findWidgetFencesInMarkdown } from \"./find-widget-fences-in-markdown\";\n\n/**\n * The key of the agent space the fence of the anchor message names — unresolved, exactly what the inline widget\n * receives as its prop. Undefined for a page anchor, a missing anchor message or a fence that names no agent space.\n * For a body whose inline widget resolves the key itself, so both resolve it the same way.\n */\nexport const useAnchorWidgetFenceAgentSpaceKey = (\n canvas: CanvasState,\n anchorMessageMarkdown: string | null,\n widgetName: string,\n): string | undefined =>\n useMemo(() => {\n if (canvas.anchor.kind !== \"message\" || anchorMessageMarkdown === null) return undefined;\n const payloadHash = payloadHashOfInstanceId(canvas.instanceId);\n const fence =\n payloadHash !== undefined\n ? findWidgetFenceByPayloadHash(anchorMessageMarkdown, widgetName, payloadHash)\n : findWidgetFencesInMarkdown(anchorMessageMarkdown).find((candidate) => candidate.name === widgetName);\n return fence?.agentSpaceKey;\n }, [canvas.anchor, canvas.instanceId, anchorMessageMarkdown, widgetName]);\n\n/**\n * The agent space a message-anchored canvas body works on, resolved the way its inline widget resolves it: the agent\n * space the fence names when it is ANOTHER one than the active one, else the chat's agent space (`chatAgentSpaceKey`,\n * passed by the shell), else the active one. For a page anchor: the anchor's agent space.\n *\n * A fence that names the ACTIVE agent space is dropped here in favour of the chat's agent space — the order of the\n * inline widgets that compute `anotherAgentSpaceKey ?? chatAgentSpaceKey`. A widget whose inline render lets the\n * fence win reads {@link useAnchorWidgetFenceAgentSpaceKey} instead.\n */\nexport const useAnchorWidgetAgentSpaceKey = (\n canvas: CanvasState,\n anchorMessageMarkdown: string | null,\n widgetName: string,\n chatAgentSpaceKey: number | undefined,\n): number | undefined => {\n const fenceAgentSpaceKey = useAnchorWidgetFenceAgentSpaceKey(canvas, anchorMessageMarkdown, widgetName);\n const { anotherAgentSpaceKey, activeAgentSpaceKey } = useResolvedConversationWidgetAgentSpaceKey(fenceAgentSpaceKey);\n if (canvas.anchor.kind === \"page\") return canvas.anchor.agentSpaceKey;\n return anotherAgentSpaceKey ?? chatAgentSpaceKey ?? activeAgentSpaceKey;\n};\n","/**\n * Density flag shared by snapshot widgets. Lives on the payload, but it\n * is a PRESENTATION choice the agent makes — independent of whether the widget's data\n * came from the agent's payload or from live hydration.\n */\nexport type ConversationWidgetVariant = \"compact\" | \"full\";\n\ninterface WithVariant {\n variant?: ConversationWidgetVariant;\n}\n\n/**\n * Read just the `variant` flag out of a raw widget payload string, even when the\n * rest of the payload is incomplete (so the agent can request a density with a\n * minimal `{\"variant\":\"compact\"}` and let the data hydrate).\n */\nexport const readPayloadVariant = (rawPayload: string): ConversationWidgetVariant | undefined => {\n try {\n const parsed = JSON.parse(rawPayload) as { variant?: unknown };\n if (parsed && (parsed.variant === \"compact\" || parsed.variant === \"full\")) {\n return parsed.variant;\n }\n } catch {\n // Non-JSON or empty payload — no variant to read.\n }\n return undefined;\n};\n\n/**\n * Overlay the agent's requested `variant` onto the resolved widget data. The agent's\n * payload variant always wins; when the payload omits it the resolved data's own\n * variant (or the widget default) stands.\n */\nexport const withConversationWidgetVariant = <T extends WithVariant>(\n base: T | undefined,\n rawPayload: string,\n): T | undefined => {\n if (!base) {\n return base;\n }\n const variant = readPayloadVariant(rawPayload);\n return variant ? { ...base, variant } : base;\n};\n"],"names":["v"],"mappings":";;;;;;;;;;;;;AAaO,MAAM,cAAc,CAAI,cAA6B,aAAuD;AACjH,SAAO,gBAAgB,SAAS,QAAQ;AAC1C;AAKO,MAAM,mBAAmB,CAAI,cAA6B,aAAiD;AAChH,SAAO,iBAAiB,UAAa,SAAS;AAChD;AAQO,MAAM,qBAAqB,CAChC,cACA,kBACkB;AAClB,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AACA,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,UAAsB,CAAA;AAC5B,aAAW,OAAO,OAAO,KAAK,YAAY,GAAqB;AAC7D,UAAMA,KAAI,aAAa,GAAG;AAC1B,QAAIA,OAAM,QAAW;AACnB,cAAQ,GAAG,IAAIA;AAAA,IACjB;AAAA,EACF;AACA,SAAO,EAAE,GAAG,eAAe,GAAG,QAAA;AAChC;AAQO,MAAM,eAAe,CAC1B,cACA,aACkB;AAClB,SAAO,mBAAmB,cAAc,SAAS,QAAQ,MAAS;AACpE;AAMO,MAAM,oBAAoB,CAC/B,cACA,iBACY;AACZ,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AACA,SAAO,aAAa,MAAM,CAAC,MAAM,aAAa,CAAC,MAAM,MAAS;AAChE;AAOO,MAAM,sBAAsB,CACjC,cACA,UACA,iBACY;AACZ,MAAI,CAAC,SAAS,WAAW;AACvB,WAAO;AAAA,EACT;AACA,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AACA,SAAO,aAAa,KAAK,CAAC,MAAM;AAC9B,WAAQ,aAAmB,CAAC,MAAM;AAAA,EACpC,CAAC;AACH;ACzFO,MAAM,iCAAiC,MAC5C,qBAAC,OAAA,EAAI,eAAY,kCACf,UAAA;AAAA,EAAA,oBAAC,UAA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AAC,MAAM;AACT,WAAO;AAAA,EACT;AACA,QAAM,UAAU,mBAAmB,UAAU;AAC7C,SAAO,UAAU,EAAE,GAAG,MAAM,YAAY;AAC1C;"}
|
package/dist/styles.css
CHANGED
|
@@ -4543,6 +4543,10 @@ thead + tbody .agents_row_VBlQR-:first-child {
|
|
|
4543
4543
|
content: "–";
|
|
4544
4544
|
}
|
|
4545
4545
|
|
|
4546
|
+
.agents-icon[data-icon=details]::before {
|
|
4547
|
+
content: "⋯";
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4546
4550
|
.agents-icon[data-icon=download]::before {
|
|
4547
4551
|
content: "↓";
|
|
4548
4552
|
}
|
|
@@ -4639,6 +4643,10 @@ thead + tbody .agents_row_VBlQR-:first-child {
|
|
|
4639
4643
|
content: "↑";
|
|
4640
4644
|
}
|
|
4641
4645
|
|
|
4646
|
+
.agents-icon[data-icon=visibility]::before {
|
|
4647
|
+
content: "◎";
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4642
4650
|
.agents-icon[data-icon=warning]::before {
|
|
4643
4651
|
content: "!";
|
|
4644
4652
|
}
|
|
@@ -2,10 +2,12 @@ import "../styles/agents.scss";
|
|
|
2
2
|
export * from "../provider";
|
|
3
3
|
export { registerConversationWidgets, type ConversationWidgetEntry, } from "../renderer/conversationWidgetRegistry";
|
|
4
4
|
export { registerCanvasBodies } from "../renderer/canvas/canvasBodies";
|
|
5
|
+
export { registerCanvasKind, unregisterCanvasKind, type CanvasKind } from "../renderer/canvas/canvas-kinds";
|
|
5
6
|
export { registerCanvasFeatureFlags } from "../renderer/canvas/canvas-feature-flags";
|
|
6
7
|
export { registerWidgetHydrator } from "../renderer/widget-hydration/widget-hydration.registry";
|
|
7
8
|
export { registerDriveFileCardsSource, type DriveFileCardsSource, } from "../widgets/DriveFilesConversationWidget/shared/drive-file-cards-source";
|
|
8
9
|
export type { DriveFileCard, DriveFileContent, DriveFilesRequest } from "../widgets/DriveFilesConversationWidget/shared/drive-files";
|
|
10
|
+
export { registerDriveFileCanvasOpener, type DriveFileCanvasOpener, } from "../widgets/DriveFilesConversationWidget/shared/drive-file-canvas-openers";
|
|
9
11
|
export { registerComposedViewDataSourceFetcher, type ComposedViewDataSourceFetcher, } from "../renderer/widget-tree/composed-view-data-sources";
|
|
10
12
|
export { getEntityDetailBody, readEntityDetailBodyDefinitions, registerEntityDetailBodies, type EntityDetailBodyDefinition, } from "../kit/entity-detail/entity-detail-bodies";
|
|
11
13
|
export { readConceptExplainerTypeDefinitions, registerConceptExplainerTypes, } from "../widgets/ConceptExplainerConversationWidget/shared/concept-explainer-types";
|
|
@@ -9,6 +9,7 @@ export { ConversationSearchResultsConversationWidget } from "../widgets/Conversa
|
|
|
9
9
|
export { CurrencyConverterConversationWidget } from "../widgets/CurrencyConverterConversationWidget/CurrencyConverterConversationWidget";
|
|
10
10
|
export { DriveFilesConversationWidget } from "../widgets/DriveFilesConversationWidget/DriveFilesConversationWidget";
|
|
11
11
|
export { DRIVE_FILE_CARDS_SOURCE_MISSING, type DriveFileCardsSource, readDriveFileCardsSource, unregisterDriveFileCardsSource, } from "../widgets/DriveFilesConversationWidget/shared/drive-file-cards-source";
|
|
12
|
+
export { type DriveFileCanvasOpener, type DriveFileCanvasTarget, driveFileCanvasTargetOf, readDriveFileCanvasOpener, unregisterDriveFileCanvasOpener, } from "../widgets/DriveFilesConversationWidget/shared/drive-file-canvas-openers";
|
|
12
13
|
export { DRIVE_FILES_MAX_FILES, DRIVE_FILES_WIDGET_TYPE, type DriveFileCard, type DriveFileContent, type DriveFileFamily, type DriveFilesRequest, driveFileCardToOpen, driveFileFamilyOf, driveFileTypeLabelOf, formatDriveFileSize, isDriveFileCardExpired, nodeIdOfReference, parseDriveFilesPayload, safeDriveFileOpenLink, } from "../widgets/DriveFilesConversationWidget/shared/drive-files";
|
|
13
14
|
export { CustomVisualizationConversationWidget } from "../widgets/CustomVisualizationConversationWidget/CustomVisualizationConversationWidget";
|
|
14
15
|
export { CUSTOM_VISUALIZATION_SANDBOX_CONFIG, resolveCustomVisualizationFrameUrl, } from "../widgets/CustomVisualizationConversationWidget/shared/custom-visualization-sandbox-config";
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* detail canvas. The widget registry lists which canvases a widget may open (`opensCanvases`); the canvas BODIES (React
|
|
7
7
|
* components) live in `canvasBodies.tsx`, imported only by the shell. The package declares the canvases of its own
|
|
8
8
|
* widgets here (`packageCanvasBehaviours`); an app declares the canvases of its widgets on its agents environment
|
|
9
|
-
* (`AgentsEnvironment.furtherCanvasBehaviours`), read at every lookup
|
|
9
|
+
* (`AgentsEnvironment.furtherCanvasBehaviours`), read at every lookup; a further package (a drive, an editor) brings a
|
|
10
|
+
* whole canvas kind — behaviour, body, opener widgets — with `registerCanvasKind` (`canvas-kinds.ts`), whose behaviour
|
|
11
|
+
* is kept in `canvas-kind-declarations.ts`. This module imports nothing but that one and the environment
|
|
10
12
|
* module (which has no runtime imports), so the conversation slice and its specs can read it during store
|
|
11
13
|
* initialisation (the widget registry is downstream of the store; a slice → registry import forms a temporal-dead-zone
|
|
12
14
|
* cycle).
|
|
@@ -14,8 +16,8 @@
|
|
|
14
16
|
/** The canvases of the package's own widgets. */
|
|
15
17
|
export type PackageCanvasId = "conversationSearchResults" | "webSearchResults" | "entityDetail" | "mapFullScreen";
|
|
16
18
|
/**
|
|
17
|
-
* The id of a canvas: one of the package's (`PackageCanvasId`)
|
|
18
|
-
* (`AgentsEnvironment.furtherCanvasBehaviours`). Append-only while a stored pointer (`canvasStorage.ts`) may still name
|
|
19
|
+
* The id of a canvas: one of the package's (`PackageCanvasId`), one an app declares
|
|
20
|
+
* (`AgentsEnvironment.furtherCanvasBehaviours`) or one a registered canvas kind brings (`registerCanvasKind`). Append-only while a stored pointer (`canvasStorage.ts`) may still name
|
|
19
21
|
* the id. A string, because the app's ids are not known to the package; `isCanvasId` checks a value against both.
|
|
20
22
|
*/
|
|
21
23
|
export type CanvasId = PackageCanvasId | (string & {});
|
|
@@ -76,13 +78,23 @@ export declare const CANVAS_BOXED_INSET_PX = 8;
|
|
|
76
78
|
export declare const CANVAS_FILLS_SCREEN_WIDTH_PERCENT = 72;
|
|
77
79
|
/** The canvases of the package's own widgets. */
|
|
78
80
|
export declare const packageCanvasBehaviours: Readonly<Record<PackageCanvasId, CanvasBehaviour>>;
|
|
81
|
+
/** Whether the id is one of the package's own canvases (a registered kind and an app can never take one). */
|
|
82
|
+
export declare const isPackageCanvasId: (canvasId: string) => canvasId is PackageCanvasId;
|
|
83
|
+
/**
|
|
84
|
+
* The names of the widgets a registered canvas kind opens from (`CanvasKind.openedByWidgets`): a stored pointer of the
|
|
85
|
+
* kind restores only while its anchor message still carries one of them. Empty for another canvas (its openers are the
|
|
86
|
+
* registry's `opensCanvases`).
|
|
87
|
+
*/
|
|
88
|
+
export declare const canvasKindOpenerWidgetNamesOf: (canvasId: CanvasId) => readonly string[];
|
|
79
89
|
/**
|
|
80
90
|
* The behaviour of a canvas: the package's own, else the one the app declares
|
|
81
|
-
* (`AgentsEnvironment.furtherCanvasBehaviours`)
|
|
82
|
-
* the opening rule ignores it).
|
|
91
|
+
* (`AgentsEnvironment.furtherCanvasBehaviours`), else the one of a registered canvas kind (`registerCanvasKind`);
|
|
92
|
+
* undefined for an id nobody declared (a stale stored pointer, a typo — the opening rule ignores it). Nobody can replace
|
|
93
|
+
* a package canvas's behaviour; the app's declaration wins over a registered kind's, so a host can tune a kind a
|
|
94
|
+
* further package brings.
|
|
83
95
|
*/
|
|
84
96
|
export declare const canvasBehaviourOf: (canvasId: CanvasId) => CanvasBehaviour | undefined;
|
|
85
|
-
/** Every declared canvas id: the package's own first, then the app's further ones. */
|
|
97
|
+
/** Every declared canvas id: the package's own first, then the app's further ones, then the registered kinds'. */
|
|
86
98
|
export declare const getDeclaredCanvasIds: () => readonly CanvasId[];
|
|
87
99
|
/** Type guard for a value read from untrusted input (`sessionStorage`, a URL): is it a declared canvas id? */
|
|
88
100
|
export declare const isCanvasId: (value: unknown) => value is CanvasId;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CanvasBehaviour } from "./canvas-behaviours";
|
|
2
|
+
/**
|
|
3
|
+
* What a registered canvas kind declares besides its body: where `registerCanvasKind` (`canvas-kinds.ts`) keeps the
|
|
4
|
+
* behaviour and the opener widgets, and where the lookups of `canvas-behaviours.ts` read them. A module without a
|
|
5
|
+
* runtime import, so the conversation slice can reach it during store initialisation (the bodies stay with the shell).
|
|
6
|
+
*/
|
|
7
|
+
export interface CanvasKindDeclaration {
|
|
8
|
+
readonly behaviour: CanvasBehaviour;
|
|
9
|
+
readonly openedByWidgets: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
/** Keeps a kind's declaration; a second one for an id replaces the first. Called by `registerCanvasKind` only. */
|
|
12
|
+
export declare const declareCanvasKind: (canvasId: string, declaration: CanvasKindDeclaration) => void;
|
|
13
|
+
/** Takes a kind's declaration off again. Called by `unregisterCanvasKind` only. */
|
|
14
|
+
export declare const forgetCanvasKind: (canvasId: string) => void;
|
|
15
|
+
export declare const readCanvasKindDeclaration: (canvasId: string) => CanvasKindDeclaration | undefined;
|
|
16
|
+
/** The ids of the registered canvas kinds, in the order they were registered. */
|
|
17
|
+
export declare const getCanvasKindIds: () => string[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { type CanvasBehaviour, type CanvasId } from "./canvas-behaviours";
|
|
3
|
+
import type { CanvasBodyProps } from "./canvas-body-props";
|
|
4
|
+
/**
|
|
5
|
+
* A CANVAS KIND — everything one canvas is made of, in one declaration: its id, how it lives on the surface
|
|
6
|
+
* (`behaviour`), the component the pane mounts (`body`) and the widgets it opens from. The way a further package (a
|
|
7
|
+
* drive's file viewer, an editor) brings its canvas to the chat without the app declaring anything: the package calls
|
|
8
|
+
* `registerCanvasKind` once, outside React, before the first render.
|
|
9
|
+
*
|
|
10
|
+
* The app's own canvases keep their two declarations (`AgentsEnvironment.furtherCanvasBehaviours` +
|
|
11
|
+
* `registerCanvasBodies`); both ways end in the same lookups (`canvasBehaviourOf`, `canvasBodies`), and the app's
|
|
12
|
+
* behaviour for an id wins over a kind's.
|
|
13
|
+
*/
|
|
14
|
+
export interface CanvasKind {
|
|
15
|
+
/**
|
|
16
|
+
* The id of the canvas. Append-only while a stored pointer may still name it; never one of the package's own
|
|
17
|
+
* (`PackageCanvasId`). Prefix it with the package's topic (`driveFile`), so two packages never meet on one id.
|
|
18
|
+
*/
|
|
19
|
+
readonly canvasId: CanvasId;
|
|
20
|
+
readonly behaviour: CanvasBehaviour;
|
|
21
|
+
/**
|
|
22
|
+
* The body the pane mounts. It receives the pointer only (`CanvasBodyProps`): what it shows it reads itself from the
|
|
23
|
+
* instance id (`canvasInstanceIdForReference` → `referenceOfCanvasInstanceId`) or from the anchor message.
|
|
24
|
+
*/
|
|
25
|
+
readonly body: React.ComponentType<CanvasBodyProps>;
|
|
26
|
+
/**
|
|
27
|
+
* The names of the widgets in a message this canvas opens from (`DriveFiles`). After a reload the pointer of the
|
|
28
|
+
* canvas restores only while its anchor message still carries one of them; without a name the canvas never restores.
|
|
29
|
+
*/
|
|
30
|
+
readonly openedByWidgets?: readonly string[];
|
|
31
|
+
/** The requirement (an app feature flag) the body is gated on (`registerCanvasFeatureFlags`); default ungated. */
|
|
32
|
+
readonly featureFlag?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Registers a canvas kind: its behaviour, its body, its opener widgets and its gate. Runs outside React, before the
|
|
36
|
+
* first render; a second registration of an id replaces the first (a hot reload registers again).
|
|
37
|
+
*
|
|
38
|
+
* @throws Error for an id of the package's own canvases
|
|
39
|
+
*/
|
|
40
|
+
export declare const registerCanvasKind: (kind: CanvasKind) => void;
|
|
41
|
+
/** Takes a registered canvas kind off again (tests, a host that disconnects a package). */
|
|
42
|
+
export declare const unregisterCanvasKind: (canvasId: CanvasId) => void;
|
|
@@ -105,5 +105,17 @@ export declare const canvasInstanceIdForActiveAgentSpace: (canvasId: CanvasId) =
|
|
|
105
105
|
export declare const canvasInstanceIdForEntity: (canvasId: CanvasId, entityId: number) => string;
|
|
106
106
|
/** The entity id an entity instance id carries, or undefined for another shape of instance id. */
|
|
107
107
|
export declare const entityIdOfInstanceId: (instanceId: string) => number | undefined;
|
|
108
|
+
/** Whether a value has the shape of a store reference an instance id may carry. */
|
|
109
|
+
export declare const isCanvasReference: (value: string) => boolean;
|
|
110
|
+
/**
|
|
111
|
+
* A viewer / editor unique per object of a store (a drive file, a folder): `<canvasId>:reference:<reference>`. The
|
|
112
|
+
* body reads the reference back (`referenceOfCanvasInstanceId`) and loads the object under the viewer's rights —
|
|
113
|
+
* the id carries no data, only what to ask for.
|
|
114
|
+
*
|
|
115
|
+
* @throws Error for a reference of another shape (`isCanvasReference`)
|
|
116
|
+
*/
|
|
117
|
+
export declare const canvasInstanceIdForReference: (canvasId: CanvasId, reference: string) => string;
|
|
118
|
+
/** The reference a reference instance id carries, or undefined for another shape of instance id (also a mangled one). */
|
|
119
|
+
export declare const referenceOfCanvasInstanceId: (instanceId: string) => string | undefined;
|
|
108
120
|
/** True when the anchor message of a canvas is among the loaded messages (a restored pointer must point somewhere). */
|
|
109
121
|
export declare const isCanvasAnchorLoaded: (anchor: CanvasAnchor, loadedMessageIds: ReadonlyArray<number | undefined | null>) => boolean;
|
|
@@ -30,6 +30,11 @@ export interface CanvasLauncherWidgetProps {
|
|
|
30
30
|
translateSubtitle?: boolean;
|
|
31
31
|
/** Optional leading icon (a glyph hinting what the canvas holds). Falls back to a generic panel glyph. */
|
|
32
32
|
icon?: AgentsIconName;
|
|
33
|
+
/**
|
|
34
|
+
* A drawing of the caller for the leading badge (e.g. a folder), in place of the `icon` glyph: for a widget whose
|
|
35
|
+
* subject has no name among the package icons. Decorative; it inherits the badge's colour and box.
|
|
36
|
+
*/
|
|
37
|
+
leading?: ReactNode;
|
|
33
38
|
/**
|
|
34
39
|
* A preview of the picture the canvas opens with. Set → the RICH card: the thumbnail replaces the icon badge, the
|
|
35
40
|
* title gets more weight, and the hover is the component library's `GlobalStateComponent` layer (e.g. an app's closing summary
|
|
@@ -76,4 +81,4 @@ export interface CanvasLauncherWidgetProps {
|
|
|
76
81
|
* - without a `preview` (the canvas is the widget's only surface, behaviour `narrowViewport: "overlay"`): the same
|
|
77
82
|
* named card as on the wide viewport, so closing the canvas leaves a card to re-open.
|
|
78
83
|
*/
|
|
79
|
-
export declare const CanvasLauncherWidget: ({ title, titleReplacements, translateTitle, subtitle, subtitleReplacements, translateSubtitle, icon, thumbnail, justDelivered, canvas, anotherAgentSpaceKey, preview, testId, }: CanvasLauncherWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
export declare const CanvasLauncherWidget: ({ title, titleReplacements, translateTitle, subtitle, subtitleReplacements, translateSubtitle, icon, leading, thumbnail, justDelivered, canvas, anotherAgentSpaceKey, preview, testId, }: CanvasLauncherWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { PayloadConversationWidgetProps } from "../../renderer/conversation-widget-props";
|
|
2
2
|
/**
|
|
3
3
|
* The file card widget `DriveFiles`: the files a block names, read under the viewer's rights through the host's
|
|
4
|
-
* `DriveFileCardsSource`, each with type, size, date, a thumbnail, open (
|
|
5
|
-
*
|
|
4
|
+
* `DriveFileCardsSource`, each with type, size, date, a thumbnail, open (in the canvas of the store when it registered
|
|
5
|
+
* an opener — `registerDriveFileCanvasOpener` — else in a new tab, where an office file opens its PDF twin or only
|
|
6
|
+
* downloads), download and a link to its place in the host's drive screen. A block without a store or references
|
|
6
7
|
* renders nothing and reports it.
|
|
7
8
|
*/
|
|
8
9
|
export declare const DriveFilesConversationWidget: (props: PayloadConversationWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CanvasAnchor, type CanvasIdentity } from "../../../renderer/canvas/canvas-state";
|
|
2
|
+
import type { DriveFileCard } from "./drive-files";
|
|
3
|
+
/**
|
|
4
|
+
* Says which canvas shows a file or folder of one store: the canvas and its instance (`canvasInstanceIdForReference`),
|
|
5
|
+
* or `null` when this entry has none (it then opens in a new tab or only downloads, as without an opener). Pure and
|
|
6
|
+
* cheap: the widget asks on every render of a row.
|
|
7
|
+
*/
|
|
8
|
+
export type DriveFileCanvasOpener = (card: DriveFileCard) => CanvasIdentity | null;
|
|
9
|
+
/**
|
|
10
|
+
* Registers the canvas opener of one drive store (the `store` a `DriveFiles` block names): the entries of that store
|
|
11
|
+
* then open in the canvas beside the chat instead of a new tab. The canvas itself is a registered canvas kind
|
|
12
|
+
* (`registerCanvasKind`, with `openedByWidgets: ["DriveFiles"]`). Call it once per store, outside React, before the
|
|
13
|
+
* first chat; a second call for a store replaces the first. Stores without an opener keep open-in-a-tab and download.
|
|
14
|
+
*/
|
|
15
|
+
export declare const registerDriveFileCanvasOpener: (store: string, opener: DriveFileCanvasOpener) => void;
|
|
16
|
+
/** The opener of a store, or `null` when the store registered none. */
|
|
17
|
+
export declare const readDriveFileCanvasOpener: (store: string) => DriveFileCanvasOpener | null;
|
|
18
|
+
/** Takes a store's opener off again (tests, a host that disconnects its store). */
|
|
19
|
+
export declare const unregisterDriveFileCanvasOpener: (store: string) => void;
|
|
20
|
+
/** The canvas one row of a `DriveFiles` block opens, with its anchor. */
|
|
21
|
+
export interface DriveFileCanvasTarget extends CanvasIdentity {
|
|
22
|
+
readonly anchor: CanvasAnchor;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The canvas a row opens: the store's opener's answer, anchored on the block's message. `null` when the store has no
|
|
26
|
+
* opener, the opener has no canvas for this entry, the canvas it names is not declared (its kind was never registered)
|
|
27
|
+
* or the block does not know its message yet (a reply still streaming) — the row then keeps its former actions.
|
|
28
|
+
*/
|
|
29
|
+
export declare const driveFileCanvasTargetOf: (store: string, card: DriveFileCard, messageId: string | number | undefined) => DriveFileCanvasTarget | null;
|