@runtypelabs/persona 4.17.0 → 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.
Files changed (165) hide show
  1. package/dist/animations/glyph-cycle.d.cts +1 -1
  2. package/dist/animations/glyph-cycle.d.ts +1 -1
  3. package/dist/animations/{types-BpWGm7_6.d.cts → types-DsmTD8TO.d.cts} +12 -0
  4. package/dist/animations/{types-BpWGm7_6.d.ts → types-DsmTD8TO.d.ts} +12 -0
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/chunk-3I2S3I5P.js +1 -0
  8. package/dist/chunk-76IELU7F.js +1 -0
  9. package/dist/chunk-EFJBUH5F.js +1 -0
  10. package/dist/chunk-PDPVORUF.js +1 -0
  11. package/dist/chunk-Q735PSZL.js +1 -0
  12. package/dist/chunk-VK6JOIYJ.js +1 -0
  13. package/dist/codegen.cjs +4 -4
  14. package/dist/codegen.js +4 -4
  15. package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
  16. package/dist/context-mentions.cjs +9 -8
  17. package/dist/context-mentions.d.cts +1224 -14
  18. package/dist/context-mentions.d.ts +1224 -14
  19. package/dist/context-mentions.js +9 -8
  20. package/dist/event-stream-view-4EZ7BGFK.js +1 -0
  21. package/dist/event-stream-view.cjs +129 -0
  22. package/dist/event-stream-view.d.cts +8384 -0
  23. package/dist/event-stream-view.d.ts +8384 -0
  24. package/dist/event-stream-view.js +129 -0
  25. package/dist/history-view-BD6OXLNA.js +898 -0
  26. package/dist/history-view.cjs +898 -0
  27. package/dist/history-view.d.cts +1461 -0
  28. package/dist/history-view.d.ts +1461 -0
  29. package/dist/history-view.js +898 -0
  30. package/dist/index.cjs +77 -77
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +2040 -21
  33. package/dist/index.d.ts +2040 -21
  34. package/dist/index.global.js +67 -66
  35. package/dist/index.global.js.map +1 -1
  36. package/dist/index.js +77 -77
  37. package/dist/index.js.map +1 -1
  38. package/dist/launcher.global.js +5 -4
  39. package/dist/launcher.global.js.map +1 -1
  40. package/dist/plugin-kit.cjs +1 -1
  41. package/dist/plugin-kit.d.cts +0 -8
  42. package/dist/plugin-kit.d.ts +0 -8
  43. package/dist/plugin-kit.js +1 -1
  44. package/dist/smart-dom-reader.d.cts +1224 -14
  45. package/dist/smart-dom-reader.d.ts +1224 -14
  46. package/dist/theme-editor-preview.cjs +970 -73
  47. package/dist/theme-editor-preview.d.cts +1343 -15
  48. package/dist/theme-editor-preview.d.ts +1343 -15
  49. package/dist/theme-editor-preview.js +81 -81
  50. package/dist/theme-editor.cjs +7 -7
  51. package/dist/theme-editor.d.cts +1227 -15
  52. package/dist/theme-editor.d.ts +1227 -15
  53. package/dist/theme-editor.js +9 -9
  54. package/dist/theme-reference.cjs +1 -1
  55. package/dist/theme-reference.d.cts +226 -7
  56. package/dist/theme-reference.d.ts +226 -7
  57. package/dist/theme-reference.js +1 -1
  58. package/dist/webmcp-polyfill.js +2 -2
  59. package/dist/widget.css +1 -1
  60. package/package.json +18 -6
  61. package/src/client-history-rest.test.ts +1034 -0
  62. package/src/client-visitor-history.test.ts +596 -0
  63. package/src/client.ts +1040 -24
  64. package/src/components/artifact-inline.ts +8 -1
  65. package/src/components/artifact-pane.test.ts +278 -1
  66. package/src/components/artifact-pane.ts +135 -67
  67. package/src/components/artifact-preview.test.ts +14 -1
  68. package/src/components/artifact-preview.ts +9 -0
  69. package/src/components/header-builder.ts +3 -0
  70. package/src/components/header-layouts.test.ts +171 -7
  71. package/src/components/header-layouts.ts +83 -53
  72. package/src/components/header-parts.test.ts +154 -1
  73. package/src/components/header-parts.ts +266 -138
  74. package/src/components/history-confirm-dialog.ts +177 -0
  75. package/src/components/history-shell-copy.ts +99 -0
  76. package/src/components/history-view/announcer.ts +40 -0
  77. package/src/components/history-view/copy.ts +105 -0
  78. package/src/components/history-view/css.ts +1078 -0
  79. package/src/components/history-view/grouping.test.ts +142 -0
  80. package/src/components/history-view/grouping.ts +142 -0
  81. package/src/components/history-view/icons.ts +73 -0
  82. package/src/components/history-view/rows.ts +341 -0
  83. package/src/components/history-view/state.ts +309 -0
  84. package/src/components/history-view.test.ts +2660 -0
  85. package/src/components/history-view.ts +1891 -0
  86. package/src/components/launcher-surface.test.ts +133 -0
  87. package/src/components/launcher.test.ts +18 -0
  88. package/src/components/launcher.ts +7 -7
  89. package/src/components/panel.ts +17 -7
  90. package/src/components/welcome.ts +72 -2
  91. package/src/defaults.ts +36 -3
  92. package/src/event-stream-view-bundle.test.ts +69 -0
  93. package/src/event-stream-view-entry.ts +19 -0
  94. package/src/event-stream-view-loader.ts +31 -0
  95. package/src/event-stream-view.ts +19 -0
  96. package/src/generated/runtype-openapi-contract.ts +54 -4
  97. package/src/history-render.ts +325 -0
  98. package/src/history-view-bundle.test.ts +78 -0
  99. package/src/history-view-entry.ts +41 -0
  100. package/src/history-view-loader.test.ts +30 -0
  101. package/src/history-view-loader.ts +32 -0
  102. package/src/history-view.ts +28 -0
  103. package/src/index-core.ts +50 -2
  104. package/src/index-global.ts +55 -0
  105. package/src/internal/demo-history-provider.test.ts +402 -0
  106. package/src/internal/demo-history-provider.ts +689 -0
  107. package/src/internal/history-provider-registry.ts +25 -0
  108. package/src/internal/history-provider.ts +150 -0
  109. package/src/internal/runtype-history-provider.test.ts +313 -0
  110. package/src/internal/runtype-history-provider.ts +240 -0
  111. package/src/plugin-kit.test.ts +16 -0
  112. package/src/plugin-kit.ts +13 -5
  113. package/src/plugins/types.ts +177 -1
  114. package/src/session-history.test.ts +1397 -0
  115. package/src/session.ts +1200 -26
  116. package/src/styles/widget-styles.test.ts +133 -0
  117. package/src/styles/widget.css +227 -8
  118. package/src/theme-editor/preview-utils.test.ts +19 -0
  119. package/src/theme-editor/preview-utils.ts +15 -1
  120. package/src/theme-editor/preview.ts +7 -1
  121. package/src/theme-editor/role-mappings.ts +4 -1
  122. package/src/theme-editor/sections.test.ts +168 -1
  123. package/src/theme-editor/sections.ts +136 -7
  124. package/src/theme-editor/webmcp/summary.ts +16 -2
  125. package/src/theme-reference.ts +20 -6
  126. package/src/types/theme.ts +213 -7
  127. package/src/types.ts +927 -7
  128. package/src/ui.artifact-rail-resize.test.ts +235 -0
  129. package/src/ui.attachments-drop.test.ts +1 -0
  130. package/src/ui.header-update-stability.test.ts +2 -2
  131. package/src/ui.history-chunk.test.ts +72 -0
  132. package/src/ui.history-config-provider.test.ts +318 -0
  133. package/src/ui.history-controller.test.ts +711 -0
  134. package/src/ui.history-lifecycle.test.ts +456 -0
  135. package/src/ui.history-render-hooks.test.ts +904 -0
  136. package/src/ui.history-shell.test.ts +1887 -0
  137. package/src/ui.rail-overlay.test.ts +573 -0
  138. package/src/ui.rail-resize.test.ts +284 -0
  139. package/src/ui.rebuild-composer.test.ts +21 -0
  140. package/src/ui.render-welcome.test.ts +42 -0
  141. package/src/ui.shortcuts.test.ts +166 -0
  142. package/src/ui.ts +3071 -240
  143. package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
  144. package/src/utils/artifact-file.ts +15 -0
  145. package/src/utils/artifact-gate.test.ts +4 -0
  146. package/src/utils/artifact-gate.ts +13 -17
  147. package/src/utils/artifact-resize.test.ts +28 -0
  148. package/src/utils/artifact-resize.ts +9 -2
  149. package/src/utils/buttons.ts +188 -1
  150. package/src/utils/config-merge.test.ts +91 -0
  151. package/src/utils/dropdown.ts +10 -1
  152. package/src/utils/history-messages.test.ts +284 -0
  153. package/src/utils/history-messages.ts +284 -0
  154. package/src/utils/icons.ts +3 -0
  155. package/src/utils/shortcuts.test.ts +288 -0
  156. package/src/utils/shortcuts.ts +221 -0
  157. package/src/utils/theme.test.ts +501 -4
  158. package/src/utils/theme.ts +42 -3
  159. package/src/utils/tokens.ts +153 -15
  160. package/src/utils/tooltip-timing.ts +4 -0
  161. package/src/utils/tooltip.test.ts +249 -7
  162. package/src/utils/tooltip.ts +146 -4
  163. package/src/utils/visitor-store.test.ts +425 -0
  164. package/src/utils/visitor-store.ts +337 -0
  165. 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
+ }