@runtypelabs/persona 4.17.1 → 4.18.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/dist/chunk-3I2S3I5P.js +1 -0
- package/dist/chunk-76IELU7F.js +1 -0
- package/dist/chunk-EFJBUH5F.js +1 -0
- package/dist/chunk-PDPVORUF.js +1 -0
- package/dist/chunk-Q735PSZL.js +1 -0
- package/dist/chunk-VK6JOIYJ.js +1 -0
- package/dist/codegen.cjs +4 -4
- package/dist/codegen.js +4 -4
- package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
- package/dist/context-mentions.cjs +9 -8
- package/dist/context-mentions.d.cts +1212 -14
- package/dist/context-mentions.d.ts +1212 -14
- package/dist/context-mentions.js +9 -8
- package/dist/event-stream-view-4EZ7BGFK.js +1 -0
- package/dist/event-stream-view.cjs +129 -0
- package/dist/event-stream-view.d.cts +8384 -0
- package/dist/event-stream-view.d.ts +8384 -0
- package/dist/event-stream-view.js +129 -0
- package/dist/history-view-BD6OXLNA.js +898 -0
- package/dist/history-view.cjs +898 -0
- package/dist/history-view.d.cts +1461 -0
- package/dist/history-view.d.ts +1461 -0
- package/dist/history-view.js +898 -0
- package/dist/index.cjs +77 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1987 -17
- package/dist/index.d.ts +1987 -17
- package/dist/index.global.js +67 -66
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +77 -77
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +5 -4
- package/dist/launcher.global.js.map +1 -1
- package/dist/plugin-kit.cjs +1 -1
- package/dist/plugin-kit.d.cts +0 -8
- package/dist/plugin-kit.d.ts +0 -8
- package/dist/plugin-kit.js +1 -1
- package/dist/smart-dom-reader.d.cts +1212 -14
- package/dist/smart-dom-reader.d.ts +1212 -14
- package/dist/theme-editor-preview.cjs +970 -73
- package/dist/theme-editor-preview.d.cts +1331 -15
- package/dist/theme-editor-preview.d.ts +1331 -15
- package/dist/theme-editor-preview.js +81 -81
- package/dist/theme-editor.cjs +7 -7
- package/dist/theme-editor.d.cts +1215 -15
- package/dist/theme-editor.d.ts +1215 -15
- package/dist/theme-editor.js +9 -9
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +226 -7
- package/dist/theme-reference.d.ts +226 -7
- package/dist/theme-reference.js +1 -1
- package/dist/widget.css +1 -1
- package/package.json +16 -4
- package/src/client-history-rest.test.ts +1034 -0
- package/src/client-visitor-history.test.ts +596 -0
- package/src/client.ts +1040 -24
- package/src/components/artifact-inline.ts +8 -1
- package/src/components/artifact-pane.test.ts +278 -1
- package/src/components/artifact-pane.ts +135 -67
- package/src/components/artifact-preview.test.ts +14 -1
- package/src/components/artifact-preview.ts +9 -0
- package/src/components/header-builder.ts +3 -0
- package/src/components/header-layouts.test.ts +171 -7
- package/src/components/header-layouts.ts +83 -53
- package/src/components/header-parts.test.ts +154 -1
- package/src/components/header-parts.ts +266 -138
- package/src/components/history-confirm-dialog.ts +177 -0
- package/src/components/history-shell-copy.ts +99 -0
- package/src/components/history-view/announcer.ts +40 -0
- package/src/components/history-view/copy.ts +105 -0
- package/src/components/history-view/css.ts +1078 -0
- package/src/components/history-view/grouping.test.ts +142 -0
- package/src/components/history-view/grouping.ts +142 -0
- package/src/components/history-view/icons.ts +73 -0
- package/src/components/history-view/rows.ts +341 -0
- package/src/components/history-view/state.ts +309 -0
- package/src/components/history-view.test.ts +2660 -0
- package/src/components/history-view.ts +1891 -0
- package/src/components/launcher-surface.test.ts +133 -0
- package/src/components/launcher.test.ts +18 -0
- package/src/components/launcher.ts +7 -7
- package/src/components/panel.ts +17 -7
- package/src/components/welcome.ts +72 -2
- package/src/defaults.ts +36 -3
- package/src/event-stream-view-bundle.test.ts +69 -0
- package/src/event-stream-view-entry.ts +19 -0
- package/src/event-stream-view-loader.ts +31 -0
- package/src/event-stream-view.ts +19 -0
- package/src/generated/runtype-openapi-contract.ts +1 -0
- package/src/history-render.ts +325 -0
- package/src/history-view-bundle.test.ts +78 -0
- package/src/history-view-entry.ts +41 -0
- package/src/history-view-loader.test.ts +30 -0
- package/src/history-view-loader.ts +32 -0
- package/src/history-view.ts +28 -0
- package/src/index-core.ts +50 -2
- package/src/index-global.ts +55 -0
- package/src/internal/demo-history-provider.test.ts +402 -0
- package/src/internal/demo-history-provider.ts +689 -0
- package/src/internal/history-provider-registry.ts +25 -0
- package/src/internal/history-provider.ts +150 -0
- package/src/internal/runtype-history-provider.test.ts +313 -0
- package/src/internal/runtype-history-provider.ts +240 -0
- package/src/plugin-kit.test.ts +16 -0
- package/src/plugin-kit.ts +13 -5
- package/src/plugins/types.ts +177 -1
- package/src/session-history.test.ts +1397 -0
- package/src/session.ts +1200 -26
- package/src/styles/widget-styles.test.ts +133 -0
- package/src/styles/widget.css +227 -8
- package/src/theme-editor/preview-utils.test.ts +19 -0
- package/src/theme-editor/preview-utils.ts +15 -1
- package/src/theme-editor/preview.ts +7 -1
- package/src/theme-editor/role-mappings.ts +4 -1
- package/src/theme-editor/sections.test.ts +168 -1
- package/src/theme-editor/sections.ts +136 -7
- package/src/theme-editor/webmcp/summary.ts +16 -2
- package/src/theme-reference.ts +20 -6
- package/src/types/theme.ts +213 -7
- package/src/types.ts +927 -7
- package/src/ui.artifact-rail-resize.test.ts +235 -0
- package/src/ui.attachments-drop.test.ts +1 -0
- package/src/ui.header-update-stability.test.ts +2 -2
- package/src/ui.history-chunk.test.ts +72 -0
- package/src/ui.history-config-provider.test.ts +318 -0
- package/src/ui.history-controller.test.ts +711 -0
- package/src/ui.history-lifecycle.test.ts +456 -0
- package/src/ui.history-render-hooks.test.ts +904 -0
- package/src/ui.history-shell.test.ts +1887 -0
- package/src/ui.rail-overlay.test.ts +573 -0
- package/src/ui.rail-resize.test.ts +284 -0
- package/src/ui.rebuild-composer.test.ts +21 -0
- package/src/ui.render-welcome.test.ts +42 -0
- package/src/ui.shortcuts.test.ts +166 -0
- package/src/ui.ts +3071 -240
- package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
- package/src/utils/artifact-file.ts +15 -0
- package/src/utils/artifact-gate.test.ts +4 -0
- package/src/utils/artifact-gate.ts +13 -17
- package/src/utils/artifact-resize.test.ts +28 -0
- package/src/utils/artifact-resize.ts +9 -2
- package/src/utils/buttons.ts +188 -1
- package/src/utils/config-merge.test.ts +91 -0
- package/src/utils/dropdown.ts +10 -1
- package/src/utils/history-messages.test.ts +284 -0
- package/src/utils/history-messages.ts +284 -0
- package/src/utils/icons.ts +3 -0
- package/src/utils/shortcuts.test.ts +288 -0
- package/src/utils/shortcuts.ts +221 -0
- package/src/utils/theme.test.ts +501 -4
- package/src/utils/theme.ts +42 -3
- package/src/utils/tokens.ts +153 -15
- package/src/utils/tooltip-timing.ts +4 -0
- package/src/utils/tooltip.test.ts +249 -7
- package/src/utils/tooltip.ts +146 -4
- package/src/utils/visitor-store.test.ts +425 -0
- package/src/utils/visitor-store.ts +337 -0
- package/dist/chunk-QJ4LV2KW.js +0 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List-region state model plus its DOM. These blocks replace the LIST only:
|
|
3
|
+
* the top bar, the primary new-conversation action, and the destructive footer
|
|
4
|
+
* are built once and never move between states.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createNode } from "../../utils/dom";
|
|
8
|
+
import { fillTemplate, type ResolvedHistoryViewCopy } from "./copy";
|
|
9
|
+
import {
|
|
10
|
+
isHistoryProviderError,
|
|
11
|
+
type HistoryProviderErrorCode,
|
|
12
|
+
} from "../../internal/history-provider";
|
|
13
|
+
import type { HistoryIdentityStatus } from "../../types";
|
|
14
|
+
|
|
15
|
+
export type HistoryListErrorReason =
|
|
16
|
+
| "unavailable"
|
|
17
|
+
| "authentication_failed"
|
|
18
|
+
| "authentication_required"
|
|
19
|
+
| "identity_provider_failed"
|
|
20
|
+
| "proof_not_admitted"
|
|
21
|
+
| "unsupported_scope"
|
|
22
|
+
| "unknown";
|
|
23
|
+
|
|
24
|
+
export type HistoryListState =
|
|
25
|
+
| { kind: "loading"; phase: "initial" | "refresh" | "load-more" }
|
|
26
|
+
| { kind: "ready" }
|
|
27
|
+
| { kind: "empty" }
|
|
28
|
+
| { kind: "error"; reason: HistoryListErrorReason; retryable: boolean }
|
|
29
|
+
| { kind: "rate_limited"; retryAfterSeconds: number }
|
|
30
|
+
| { kind: "new_conversation_required" };
|
|
31
|
+
|
|
32
|
+
function reasonForCode(
|
|
33
|
+
code: HistoryProviderErrorCode
|
|
34
|
+
): HistoryListErrorReason {
|
|
35
|
+
switch (code) {
|
|
36
|
+
case "authentication_failed":
|
|
37
|
+
case "authentication_required":
|
|
38
|
+
case "identity_provider_failed":
|
|
39
|
+
case "proof_not_admitted":
|
|
40
|
+
case "unsupported_scope":
|
|
41
|
+
case "unavailable":
|
|
42
|
+
return code;
|
|
43
|
+
default:
|
|
44
|
+
return "unknown";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Provider failures only ever reach the view as this domain vocabulary. */
|
|
49
|
+
export function toListState(error: unknown): HistoryListState {
|
|
50
|
+
if (isHistoryProviderError(error)) {
|
|
51
|
+
if (error.code === "rate_limited") {
|
|
52
|
+
return {
|
|
53
|
+
kind: "rate_limited",
|
|
54
|
+
retryAfterSeconds: error.retryAfterSeconds ?? 0,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const reason = reasonForCode(error.code);
|
|
58
|
+
return {
|
|
59
|
+
kind: "error",
|
|
60
|
+
reason,
|
|
61
|
+
// A scope the provider cannot serve will not start working on retry.
|
|
62
|
+
retryable: reason !== "unsupported_scope",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { kind: "error", reason: "unknown", retryable: true };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface StateBlockOptions {
|
|
69
|
+
state: Exclude<HistoryListState, { kind: "ready" }>;
|
|
70
|
+
copy: ResolvedHistoryViewCopy;
|
|
71
|
+
identityStatus: HistoryIdentityStatus;
|
|
72
|
+
busy: boolean;
|
|
73
|
+
/** Present only where retrying is meaningful. */
|
|
74
|
+
onRetry?: () => void;
|
|
75
|
+
/** Present only for the replacement-conversation recovery state. */
|
|
76
|
+
onStartNew?: () => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Identity failures explain themselves rather than showing an empty list. */
|
|
80
|
+
function identityCopy(
|
|
81
|
+
status: HistoryIdentityStatus,
|
|
82
|
+
copy: ResolvedHistoryViewCopy
|
|
83
|
+
): { title: string; description: string } | null {
|
|
84
|
+
switch (status.state) {
|
|
85
|
+
case "authentication_required":
|
|
86
|
+
return {
|
|
87
|
+
title: copy.authenticationRequiredTitle,
|
|
88
|
+
description: copy.authenticationRequiredDescription,
|
|
89
|
+
};
|
|
90
|
+
case "identity_provider_failed":
|
|
91
|
+
return {
|
|
92
|
+
title: copy.identityProviderFailedTitle,
|
|
93
|
+
description: copy.identityProviderFailedDescription,
|
|
94
|
+
};
|
|
95
|
+
case "configuration_error":
|
|
96
|
+
return {
|
|
97
|
+
title: copy.proofNotAdmittedTitle,
|
|
98
|
+
description: copy.proofNotAdmittedDescription,
|
|
99
|
+
};
|
|
100
|
+
default:
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function errorCopy(
|
|
106
|
+
reason: HistoryListErrorReason,
|
|
107
|
+
copy: ResolvedHistoryViewCopy
|
|
108
|
+
): { title: string; description: string } {
|
|
109
|
+
switch (reason) {
|
|
110
|
+
case "authentication_required":
|
|
111
|
+
case "authentication_failed":
|
|
112
|
+
return {
|
|
113
|
+
title: copy.authenticationRequiredTitle,
|
|
114
|
+
description: copy.authenticationRequiredDescription,
|
|
115
|
+
};
|
|
116
|
+
case "identity_provider_failed":
|
|
117
|
+
return {
|
|
118
|
+
title: copy.identityProviderFailedTitle,
|
|
119
|
+
description: copy.identityProviderFailedDescription,
|
|
120
|
+
};
|
|
121
|
+
case "proof_not_admitted":
|
|
122
|
+
case "unsupported_scope":
|
|
123
|
+
return {
|
|
124
|
+
title: copy.proofNotAdmittedTitle,
|
|
125
|
+
description: copy.proofNotAdmittedDescription,
|
|
126
|
+
};
|
|
127
|
+
case "unavailable":
|
|
128
|
+
return {
|
|
129
|
+
title: copy.unavailableTitle,
|
|
130
|
+
description: copy.unavailableDescription,
|
|
131
|
+
};
|
|
132
|
+
default:
|
|
133
|
+
return { title: copy.errorTitle, description: copy.errorDescription };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function buildAction(
|
|
138
|
+
label: string,
|
|
139
|
+
focusKey: string,
|
|
140
|
+
busy: boolean,
|
|
141
|
+
onClick: () => void
|
|
142
|
+
): HTMLButtonElement {
|
|
143
|
+
const button = createNode("button", {
|
|
144
|
+
className: "persona-history-secondary persona-history-state-action",
|
|
145
|
+
text: label,
|
|
146
|
+
attrs: {
|
|
147
|
+
type: "button",
|
|
148
|
+
"data-persona-history-focus": focusKey,
|
|
149
|
+
...(busy ? { "aria-disabled": "true" } : {}),
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
button.addEventListener("click", () => {
|
|
153
|
+
if (busy) return;
|
|
154
|
+
onClick();
|
|
155
|
+
});
|
|
156
|
+
return button;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function buildBlock(
|
|
160
|
+
kind: string,
|
|
161
|
+
title: string,
|
|
162
|
+
description: string,
|
|
163
|
+
action: HTMLElement | null,
|
|
164
|
+
alert: boolean
|
|
165
|
+
): HTMLElement {
|
|
166
|
+
return createNode(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
className: "persona-history-state",
|
|
170
|
+
attrs: {
|
|
171
|
+
"data-persona-history-state": kind,
|
|
172
|
+
...(alert ? { role: "alert" } : { role: "status" }),
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
createNode("p", { className: "persona-history-state-title", text: title }),
|
|
176
|
+
createNode("p", {
|
|
177
|
+
className: "persona-history-state-description",
|
|
178
|
+
text: description,
|
|
179
|
+
}),
|
|
180
|
+
action
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Three skeletons mirroring the row anatomy (title left, time right, preview
|
|
186
|
+
* under), no fake readable text. Motion is CSS-gated.
|
|
187
|
+
*/
|
|
188
|
+
function buildLoadingBlock(copy: ResolvedHistoryViewCopy): HTMLElement {
|
|
189
|
+
const titleWidths = ["42%", "58%", "34%"];
|
|
190
|
+
const previewWidths = ["94%", "78%", "88%"];
|
|
191
|
+
const rows = [0, 1, 2].map((index) =>
|
|
192
|
+
createNode(
|
|
193
|
+
"div",
|
|
194
|
+
{
|
|
195
|
+
className: "persona-history-skeleton-row",
|
|
196
|
+
attrs: { "aria-hidden": "true" },
|
|
197
|
+
},
|
|
198
|
+
createNode(
|
|
199
|
+
"div",
|
|
200
|
+
{ className: "persona-history-skeleton-head" },
|
|
201
|
+
createNode("div", {
|
|
202
|
+
className:
|
|
203
|
+
"persona-history-skeleton-bar persona-history-skeleton-bar--title",
|
|
204
|
+
style: { width: titleWidths[index] },
|
|
205
|
+
}),
|
|
206
|
+
createNode("div", {
|
|
207
|
+
className:
|
|
208
|
+
"persona-history-skeleton-bar persona-history-skeleton-bar--time",
|
|
209
|
+
})
|
|
210
|
+
),
|
|
211
|
+
createNode("div", {
|
|
212
|
+
className:
|
|
213
|
+
"persona-history-skeleton-bar persona-history-skeleton-bar--preview",
|
|
214
|
+
style: { width: previewWidths[index] },
|
|
215
|
+
})
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
return createNode(
|
|
219
|
+
"div",
|
|
220
|
+
{
|
|
221
|
+
className: "persona-history-view-loading",
|
|
222
|
+
attrs: {
|
|
223
|
+
"data-persona-history-state": "loading",
|
|
224
|
+
role: "status",
|
|
225
|
+
"aria-label": copy.loadingLabel,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
...rows
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function buildStateBlock(options: StateBlockOptions): HTMLElement {
|
|
233
|
+
const { state, copy, busy } = options;
|
|
234
|
+
|
|
235
|
+
if (state.kind === "loading") return buildLoadingBlock(copy);
|
|
236
|
+
|
|
237
|
+
if (state.kind === "empty") {
|
|
238
|
+
const identity = identityCopy(options.identityStatus, copy);
|
|
239
|
+
if (identity) {
|
|
240
|
+
return buildBlock(
|
|
241
|
+
"identity",
|
|
242
|
+
identity.title,
|
|
243
|
+
identity.description,
|
|
244
|
+
options.onRetry
|
|
245
|
+
? buildAction(
|
|
246
|
+
copy.retryIdentityLabel,
|
|
247
|
+
"state-retry",
|
|
248
|
+
busy,
|
|
249
|
+
options.onRetry
|
|
250
|
+
)
|
|
251
|
+
: null,
|
|
252
|
+
true
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return buildBlock("empty", copy.emptyTitle, copy.emptyDescription, null, false);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (state.kind === "rate_limited") {
|
|
259
|
+
const description =
|
|
260
|
+
state.retryAfterSeconds > 0
|
|
261
|
+
? fillTemplate(copy.rateLimitedWaitDescription, {
|
|
262
|
+
seconds: state.retryAfterSeconds,
|
|
263
|
+
})
|
|
264
|
+
: copy.rateLimitedDescription;
|
|
265
|
+
return buildBlock(
|
|
266
|
+
"rate_limited",
|
|
267
|
+
copy.rateLimitedTitle,
|
|
268
|
+
description,
|
|
269
|
+
options.onRetry
|
|
270
|
+
? buildAction(copy.retryLabel, "state-retry", busy, options.onRetry)
|
|
271
|
+
: null,
|
|
272
|
+
false
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (state.kind === "new_conversation_required") {
|
|
277
|
+
return buildBlock(
|
|
278
|
+
"new_conversation_required",
|
|
279
|
+
copy.newConversationRequiredTitle,
|
|
280
|
+
copy.newConversationRequiredDescription,
|
|
281
|
+
options.onStartNew
|
|
282
|
+
? buildAction(
|
|
283
|
+
copy.newConversationLabel,
|
|
284
|
+
"state-retry",
|
|
285
|
+
busy,
|
|
286
|
+
options.onStartNew
|
|
287
|
+
)
|
|
288
|
+
: null,
|
|
289
|
+
true
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const { title, description } = errorCopy(state.reason, copy);
|
|
294
|
+
const retryLabel =
|
|
295
|
+
state.reason === "authentication_required" ||
|
|
296
|
+
state.reason === "authentication_failed" ||
|
|
297
|
+
state.reason === "identity_provider_failed"
|
|
298
|
+
? copy.retryIdentityLabel
|
|
299
|
+
: copy.retryLabel;
|
|
300
|
+
return buildBlock(
|
|
301
|
+
"error",
|
|
302
|
+
title,
|
|
303
|
+
description,
|
|
304
|
+
state.retryable && options.onRetry
|
|
305
|
+
? buildAction(retryLabel, "state-retry", busy, options.onRetry)
|
|
306
|
+
: null,
|
|
307
|
+
true
|
|
308
|
+
);
|
|
309
|
+
}
|