@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.
Files changed (158) hide show
  1. package/dist/chunk-3I2S3I5P.js +1 -0
  2. package/dist/chunk-76IELU7F.js +1 -0
  3. package/dist/chunk-EFJBUH5F.js +1 -0
  4. package/dist/chunk-PDPVORUF.js +1 -0
  5. package/dist/chunk-Q735PSZL.js +1 -0
  6. package/dist/chunk-VK6JOIYJ.js +1 -0
  7. package/dist/codegen.cjs +4 -4
  8. package/dist/codegen.js +4 -4
  9. package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
  10. package/dist/context-mentions.cjs +9 -8
  11. package/dist/context-mentions.d.cts +1212 -14
  12. package/dist/context-mentions.d.ts +1212 -14
  13. package/dist/context-mentions.js +9 -8
  14. package/dist/event-stream-view-4EZ7BGFK.js +1 -0
  15. package/dist/event-stream-view.cjs +129 -0
  16. package/dist/event-stream-view.d.cts +8384 -0
  17. package/dist/event-stream-view.d.ts +8384 -0
  18. package/dist/event-stream-view.js +129 -0
  19. package/dist/history-view-BD6OXLNA.js +898 -0
  20. package/dist/history-view.cjs +898 -0
  21. package/dist/history-view.d.cts +1461 -0
  22. package/dist/history-view.d.ts +1461 -0
  23. package/dist/history-view.js +898 -0
  24. package/dist/index.cjs +77 -77
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1987 -17
  27. package/dist/index.d.ts +1987 -17
  28. package/dist/index.global.js +67 -66
  29. package/dist/index.global.js.map +1 -1
  30. package/dist/index.js +77 -77
  31. package/dist/index.js.map +1 -1
  32. package/dist/launcher.global.js +5 -4
  33. package/dist/launcher.global.js.map +1 -1
  34. package/dist/plugin-kit.cjs +1 -1
  35. package/dist/plugin-kit.d.cts +0 -8
  36. package/dist/plugin-kit.d.ts +0 -8
  37. package/dist/plugin-kit.js +1 -1
  38. package/dist/smart-dom-reader.d.cts +1212 -14
  39. package/dist/smart-dom-reader.d.ts +1212 -14
  40. package/dist/theme-editor-preview.cjs +970 -73
  41. package/dist/theme-editor-preview.d.cts +1331 -15
  42. package/dist/theme-editor-preview.d.ts +1331 -15
  43. package/dist/theme-editor-preview.js +81 -81
  44. package/dist/theme-editor.cjs +7 -7
  45. package/dist/theme-editor.d.cts +1215 -15
  46. package/dist/theme-editor.d.ts +1215 -15
  47. package/dist/theme-editor.js +9 -9
  48. package/dist/theme-reference.cjs +1 -1
  49. package/dist/theme-reference.d.cts +226 -7
  50. package/dist/theme-reference.d.ts +226 -7
  51. package/dist/theme-reference.js +1 -1
  52. package/dist/widget.css +1 -1
  53. package/package.json +16 -4
  54. package/src/client-history-rest.test.ts +1034 -0
  55. package/src/client-visitor-history.test.ts +596 -0
  56. package/src/client.ts +1040 -24
  57. package/src/components/artifact-inline.ts +8 -1
  58. package/src/components/artifact-pane.test.ts +278 -1
  59. package/src/components/artifact-pane.ts +135 -67
  60. package/src/components/artifact-preview.test.ts +14 -1
  61. package/src/components/artifact-preview.ts +9 -0
  62. package/src/components/header-builder.ts +3 -0
  63. package/src/components/header-layouts.test.ts +171 -7
  64. package/src/components/header-layouts.ts +83 -53
  65. package/src/components/header-parts.test.ts +154 -1
  66. package/src/components/header-parts.ts +266 -138
  67. package/src/components/history-confirm-dialog.ts +177 -0
  68. package/src/components/history-shell-copy.ts +99 -0
  69. package/src/components/history-view/announcer.ts +40 -0
  70. package/src/components/history-view/copy.ts +105 -0
  71. package/src/components/history-view/css.ts +1078 -0
  72. package/src/components/history-view/grouping.test.ts +142 -0
  73. package/src/components/history-view/grouping.ts +142 -0
  74. package/src/components/history-view/icons.ts +73 -0
  75. package/src/components/history-view/rows.ts +341 -0
  76. package/src/components/history-view/state.ts +309 -0
  77. package/src/components/history-view.test.ts +2660 -0
  78. package/src/components/history-view.ts +1891 -0
  79. package/src/components/launcher-surface.test.ts +133 -0
  80. package/src/components/launcher.test.ts +18 -0
  81. package/src/components/launcher.ts +7 -7
  82. package/src/components/panel.ts +17 -7
  83. package/src/components/welcome.ts +72 -2
  84. package/src/defaults.ts +36 -3
  85. package/src/event-stream-view-bundle.test.ts +69 -0
  86. package/src/event-stream-view-entry.ts +19 -0
  87. package/src/event-stream-view-loader.ts +31 -0
  88. package/src/event-stream-view.ts +19 -0
  89. package/src/generated/runtype-openapi-contract.ts +1 -0
  90. package/src/history-render.ts +325 -0
  91. package/src/history-view-bundle.test.ts +78 -0
  92. package/src/history-view-entry.ts +41 -0
  93. package/src/history-view-loader.test.ts +30 -0
  94. package/src/history-view-loader.ts +32 -0
  95. package/src/history-view.ts +28 -0
  96. package/src/index-core.ts +50 -2
  97. package/src/index-global.ts +55 -0
  98. package/src/internal/demo-history-provider.test.ts +402 -0
  99. package/src/internal/demo-history-provider.ts +689 -0
  100. package/src/internal/history-provider-registry.ts +25 -0
  101. package/src/internal/history-provider.ts +150 -0
  102. package/src/internal/runtype-history-provider.test.ts +313 -0
  103. package/src/internal/runtype-history-provider.ts +240 -0
  104. package/src/plugin-kit.test.ts +16 -0
  105. package/src/plugin-kit.ts +13 -5
  106. package/src/plugins/types.ts +177 -1
  107. package/src/session-history.test.ts +1397 -0
  108. package/src/session.ts +1200 -26
  109. package/src/styles/widget-styles.test.ts +133 -0
  110. package/src/styles/widget.css +227 -8
  111. package/src/theme-editor/preview-utils.test.ts +19 -0
  112. package/src/theme-editor/preview-utils.ts +15 -1
  113. package/src/theme-editor/preview.ts +7 -1
  114. package/src/theme-editor/role-mappings.ts +4 -1
  115. package/src/theme-editor/sections.test.ts +168 -1
  116. package/src/theme-editor/sections.ts +136 -7
  117. package/src/theme-editor/webmcp/summary.ts +16 -2
  118. package/src/theme-reference.ts +20 -6
  119. package/src/types/theme.ts +213 -7
  120. package/src/types.ts +927 -7
  121. package/src/ui.artifact-rail-resize.test.ts +235 -0
  122. package/src/ui.attachments-drop.test.ts +1 -0
  123. package/src/ui.header-update-stability.test.ts +2 -2
  124. package/src/ui.history-chunk.test.ts +72 -0
  125. package/src/ui.history-config-provider.test.ts +318 -0
  126. package/src/ui.history-controller.test.ts +711 -0
  127. package/src/ui.history-lifecycle.test.ts +456 -0
  128. package/src/ui.history-render-hooks.test.ts +904 -0
  129. package/src/ui.history-shell.test.ts +1887 -0
  130. package/src/ui.rail-overlay.test.ts +573 -0
  131. package/src/ui.rail-resize.test.ts +284 -0
  132. package/src/ui.rebuild-composer.test.ts +21 -0
  133. package/src/ui.render-welcome.test.ts +42 -0
  134. package/src/ui.shortcuts.test.ts +166 -0
  135. package/src/ui.ts +3071 -240
  136. package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
  137. package/src/utils/artifact-file.ts +15 -0
  138. package/src/utils/artifact-gate.test.ts +4 -0
  139. package/src/utils/artifact-gate.ts +13 -17
  140. package/src/utils/artifact-resize.test.ts +28 -0
  141. package/src/utils/artifact-resize.ts +9 -2
  142. package/src/utils/buttons.ts +188 -1
  143. package/src/utils/config-merge.test.ts +91 -0
  144. package/src/utils/dropdown.ts +10 -1
  145. package/src/utils/history-messages.test.ts +284 -0
  146. package/src/utils/history-messages.ts +284 -0
  147. package/src/utils/icons.ts +3 -0
  148. package/src/utils/shortcuts.test.ts +288 -0
  149. package/src/utils/shortcuts.ts +221 -0
  150. package/src/utils/theme.test.ts +501 -4
  151. package/src/utils/theme.ts +42 -3
  152. package/src/utils/tokens.ts +153 -15
  153. package/src/utils/tooltip-timing.ts +4 -0
  154. package/src/utils/tooltip.test.ts +249 -7
  155. package/src/utils/tooltip.ts +146 -4
  156. package/src/utils/visitor-store.test.ts +425 -0
  157. package/src/utils/visitor-store.ts +337 -0
  158. package/dist/chunk-QJ4LV2KW.js +0 -1
@@ -0,0 +1,99 @@
1
+ /**
2
+ * History copy the SHELL renders outside the lazy Messages chunk: the header
3
+ * button, the destructive confirmations, the "show earlier messages" pill, and
4
+ * the reset notices.
5
+ *
6
+ * Lives in core so a control can be labelled before the chunk loads. The chunk
7
+ * spreads these defaults into its own resolved table, so every key still has
8
+ * exactly one default. `AgentWidgetHistoryCopy` (types.ts) stays the single
9
+ * authoritative host-facing type.
10
+ *
11
+ * House style: sentence case, no em-dashes, no all-caps.
12
+ */
13
+
14
+ import type { AgentWidgetHistoryCopy } from "../types";
15
+
16
+ const SHELL_COPY_KEYS = [
17
+ "viewTitle",
18
+ "openHistoryLabel",
19
+ "openHistoryBusyLabel",
20
+ "newConversationLabel",
21
+ // The rail toggle's pair: the shell renders the overlay trigger before the
22
+ // chunk loads, and relabels the view's toggle while the rail floats.
23
+ "expandLabel",
24
+ "collapseLabel",
25
+ // The rail's resize handle is shell chrome, not part of the view.
26
+ "resizeLabel",
27
+ "showEarlierMessagesLabel",
28
+ "openConversationLoadingLabel",
29
+ "openConversationErrorTitle",
30
+ "openConversationRetryLabel",
31
+ "openConversationBackLabel",
32
+ "confirmCancelLabel",
33
+ "deleteConversationConfirmTitle",
34
+ "deleteConversationConfirm",
35
+ "deleteConversationConfirmLabel",
36
+ "clearHistoryConfirmTitle",
37
+ "clearHistoryConfirm",
38
+ "clearHistoryVerifiedConfirm",
39
+ "clearHistoryConfirmLabel",
40
+ "resetIdentityConfirmTitle",
41
+ "resetIdentityConfirm",
42
+ "resetIdentityConfirmLabel",
43
+ "conversationDeletedNotice",
44
+ "identityResetNotice",
45
+ "identityResetUnconfirmedNotice",
46
+ ] as const;
47
+
48
+ export type HistoryShellCopyKey = (typeof SHELL_COPY_KEYS)[number];
49
+
50
+ export type ResolvedHistoryShellCopy = Required<
51
+ Pick<AgentWidgetHistoryCopy, HistoryShellCopyKey>
52
+ >;
53
+
54
+ export const HISTORY_SHELL_COPY_DEFAULTS: ResolvedHistoryShellCopy = {
55
+ viewTitle: "Messages",
56
+ openHistoryLabel: "Messages",
57
+ openHistoryBusyLabel: "Messages, available once the reply finishes",
58
+ newConversationLabel: "New conversation",
59
+ expandLabel: "Expand conversation list",
60
+ collapseLabel: "Collapse conversation list",
61
+ resizeLabel: "Resize conversation list",
62
+ showEarlierMessagesLabel: "Show earlier messages",
63
+ openConversationLoadingLabel: "Loading conversation",
64
+ openConversationErrorTitle: "Could not open the conversation.",
65
+ openConversationRetryLabel: "Try again",
66
+ openConversationBackLabel: "Back to messages",
67
+ confirmCancelLabel: "Cancel",
68
+ deleteConversationConfirmTitle: "Delete conversation",
69
+ deleteConversationConfirm: "Delete this conversation? This cannot be undone.",
70
+ deleteConversationConfirmLabel: "Delete",
71
+ clearHistoryConfirmTitle: "Delete all conversations",
72
+ clearHistoryConfirm:
73
+ "Delete all conversations for this assistant on this browser? This cannot be undone.",
74
+ clearHistoryVerifiedConfirm:
75
+ "Delete all conversations for this assistant and signed-in user? This cannot be undone.",
76
+ clearHistoryConfirmLabel: "Delete all",
77
+ resetIdentityConfirmTitle: "Forget this device",
78
+ resetIdentityConfirm:
79
+ "Forget this device? All Persona data stored in this browser is cleared. Records are not deleted elsewhere.",
80
+ resetIdentityConfirmLabel: "Forget this device",
81
+ conversationDeletedNotice:
82
+ "That conversation was deleted. You are now in a new conversation.",
83
+ identityResetNotice: "This device was forgotten.",
84
+ identityResetUnconfirmedNotice:
85
+ "This device was cleared here, but the server could not confirm it.",
86
+ };
87
+
88
+ /** Empty-string overrides are ignored so a control never loses its label. */
89
+ export function resolveHistoryShellCopy(
90
+ copy: AgentWidgetHistoryCopy | undefined
91
+ ): ResolvedHistoryShellCopy {
92
+ if (!copy) return HISTORY_SHELL_COPY_DEFAULTS;
93
+ const resolved = { ...HISTORY_SHELL_COPY_DEFAULTS };
94
+ for (const key of SHELL_COPY_KEYS) {
95
+ const value = copy[key];
96
+ if (typeof value === "string" && value.length > 0) resolved[key] = value;
97
+ }
98
+ return resolved;
99
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Polite live region owned by the view (loading, deletion, rate limit, removal,
3
+ * identity changes). Chunk-local rather than `utils/live-region.ts` because that
4
+ * helper depends on `widget.css`'s sr-only class and hosts on `document.body`
5
+ * under Shadow DOM; this one is self-contained and lives inside the view root.
6
+ */
7
+
8
+ export interface HistoryAnnouncer {
9
+ element: HTMLElement;
10
+ announce(message: string): void;
11
+ destroy(): void;
12
+ }
13
+
14
+ export function createHistoryAnnouncer(): HistoryAnnouncer {
15
+ const element = document.createElement("div");
16
+ element.className = "persona-history-sr-only";
17
+ element.setAttribute("role", "status");
18
+ element.setAttribute("aria-live", "polite");
19
+ element.setAttribute("aria-atomic", "true");
20
+ element.setAttribute("data-persona-history-live-region", "");
21
+
22
+ // Clear and set must land in separate tasks or an identical repeat is silent.
23
+ let pending: ReturnType<typeof setTimeout> | undefined;
24
+
25
+ return {
26
+ element,
27
+ announce(message: string) {
28
+ if (pending !== undefined) clearTimeout(pending);
29
+ element.textContent = "";
30
+ pending = setTimeout(() => {
31
+ pending = undefined;
32
+ element.textContent = message;
33
+ }, 0);
34
+ },
35
+ destroy() {
36
+ if (pending !== undefined) clearTimeout(pending);
37
+ element.remove();
38
+ },
39
+ };
40
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Resolved copy for the history ("Messages") view.
3
+ *
4
+ * `AgentWidgetHistoryCopy` (types.ts) is the single authoritative
5
+ * host-overridable type; the defaults live here, in the chunk. The handful of
6
+ * strings the shell must render before this chunk loads come from
7
+ * `components/history-shell-copy.ts` so each key still has one default.
8
+ *
9
+ * House style: sentence case, no em-dashes, no all-caps.
10
+ */
11
+
12
+ import type { AgentWidgetHistoryCopy } from "../../types";
13
+ import { HISTORY_SHELL_COPY_DEFAULTS } from "../history-shell-copy";
14
+
15
+ export type HistoryViewCopyInput = AgentWidgetHistoryCopy;
16
+
17
+ export type ResolvedHistoryViewCopy = Required<AgentWidgetHistoryCopy>;
18
+
19
+ export const HISTORY_VIEW_COPY_DEFAULTS: ResolvedHistoryViewCopy = {
20
+ ...HISTORY_SHELL_COPY_DEFAULTS,
21
+ emptyTitle: "No conversations yet",
22
+ emptyDescription: "Start a conversation and it will show up here.",
23
+ errorTitle: "Could not load conversations",
24
+ errorDescription: "Something went wrong. Please try again.",
25
+ retryLabel: "Retry",
26
+ rateLimitedTitle: "Too many requests",
27
+ rateLimitedDescription: "Please wait a moment before trying again.",
28
+ groupStarred: "Starred",
29
+ groupToday: "Today",
30
+ groupYesterday: "Yesterday",
31
+ groupPrevious7Days: "Previous 7 days",
32
+ groupPrevious30Days: "Previous 30 days",
33
+ groupMonthYear: "{month} {year}",
34
+ browserOnlyTitle: "On this device",
35
+ browserOnlyDescription:
36
+ "Another browser or device keeps its own separate history.",
37
+ verifyingTitle: "Checking your account",
38
+ verifyingDescription: "Looking for messages linked to your account.",
39
+ verifiedTitle: "Available across signed-in devices",
40
+ verifiedDescription:
41
+ "This list refreshes when the chat opens rather than syncing live.",
42
+ authenticationRequiredTitle: "Sign in to see your messages",
43
+ authenticationRequiredDescription:
44
+ "Your session expired. Sign in again to load account history.",
45
+ identityProviderFailedTitle: "Account history is unavailable",
46
+ identityProviderFailedDescription:
47
+ "We could not verify your account, so account history is not shown here.",
48
+ proofNotAdmittedTitle: "Account history is unavailable",
49
+ proofNotAdmittedDescription:
50
+ "This assistant is not set up to accept your account identity.",
51
+ retryIdentityLabel: "Try again",
52
+ backLabel: "Back to conversation",
53
+ closeLabel: "Close conversation list",
54
+ loadingLabel: "Loading conversations",
55
+ loadMoreLabel: "Load more",
56
+ loadingMoreLabel: "Loading more conversations",
57
+ conversationsTitle: "Conversations",
58
+ rowActionsLabel: "Conversation options",
59
+ listOptionsLabel: "Conversation options",
60
+ deleteConversationLabel: "Delete",
61
+ clearHistoryLabel: "Delete all conversations",
62
+ resetIdentityLabel: "Forget this device",
63
+ messageCountLabel: "{count} messages",
64
+ messageCountLabelOne: "1 message",
65
+ conversationRemovedNotice: "Conversation deleted.",
66
+ historyClearedNotice: "All conversations were deleted.",
67
+ unavailableTitle: "Conversation history is unavailable",
68
+ unavailableDescription: "Try again later.",
69
+ newConversationRequiredTitle: "Start a new conversation",
70
+ newConversationRequiredDescription:
71
+ "The previous conversation is gone. Start a new one to keep chatting.",
72
+ rateLimitedWaitDescription: "You can try again in {seconds} seconds.",
73
+ openFailedLabel: "Could not open that conversation.",
74
+ deleteFailedLabel: "Could not delete that conversation.",
75
+ relativeNow: "now",
76
+ relativeMinutes: "{value}m",
77
+ relativeHours: "{value}h",
78
+ relativeDays: "{value}d",
79
+ relativeWeeks: "{value}w",
80
+ relativeYears: "{value}y",
81
+ };
82
+
83
+ /** Idempotent: safe to call on an already-resolved copy object. */
84
+ export function resolveHistoryViewCopy(
85
+ copy: HistoryViewCopyInput | undefined
86
+ ): ResolvedHistoryViewCopy {
87
+ if (!copy) return HISTORY_VIEW_COPY_DEFAULTS;
88
+ const resolved = { ...HISTORY_VIEW_COPY_DEFAULTS };
89
+ for (const [key, value] of Object.entries(copy)) {
90
+ if (typeof value === "string" && value.length > 0) {
91
+ (resolved as Record<string, string>)[key] = value;
92
+ }
93
+ }
94
+ return resolved;
95
+ }
96
+
97
+ /** `{name}` substitution. Missing keys are left alone rather than blanked. */
98
+ export function fillTemplate(
99
+ template: string,
100
+ values: Record<string, string | number>
101
+ ): string {
102
+ return template.replace(/\{(\w+)\}/g, (match, key: string) =>
103
+ key in values ? String(values[key]) : match
104
+ );
105
+ }