@jini-ai/chat 0.7.2 → 0.7.3-next.2

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 (202) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +3 -3
  3. package/dist/contracts/chat-bubble-style.d.ts +1 -1
  4. package/dist/contracts/chat-bubble-style.js +1 -1
  5. package/dist/core/ag-ui/event-projection.d.ts +125 -0
  6. package/dist/core/ag-ui/event-projection.js +275 -0
  7. package/dist/core/ag-ui/event-reduction.d.ts +39 -0
  8. package/dist/core/ag-ui/event-reduction.js +99 -0
  9. package/dist/core/ag-ui/run-input.d.ts +53 -0
  10. package/dist/core/ag-ui/run-input.js +87 -0
  11. package/dist/core/agentic/chat-capabilities.d.ts +1 -1
  12. package/dist/core/agentic/index.d.ts +2 -4
  13. package/dist/core/agentic/index.js +2 -3
  14. package/dist/core/agents-port.d.ts +50 -0
  15. package/dist/core/agents-port.js +2 -0
  16. package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
  17. package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
  18. package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
  19. package/dist/core/assistant-client/ag-ui-transport.js +167 -145
  20. package/dist/core/assistant-client/attachment-liveness.js +13 -11
  21. package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
  22. package/dist/core/assistant-client/durable-run-subscription.js +6 -5
  23. package/dist/core/assistant-client/messages.d.ts +7 -4
  24. package/dist/core/assistant-client/messages.js +5 -4
  25. package/dist/core/assistant-client/transport.d.ts +1 -1
  26. package/dist/core/assistant-client/transport.js +4 -4
  27. package/dist/core/index.d.ts +2 -0
  28. package/dist/core/index.js +1 -0
  29. package/dist/core/page-port.d.ts +15 -0
  30. package/dist/core/page-port.js +2 -0
  31. package/dist/core/run-activity.js +1 -1
  32. package/dist/core/run-events/entry.js +1 -0
  33. package/dist/core/user-text-redaction.d.ts +1 -3
  34. package/dist/core/user-text-redaction.js +3 -61
  35. package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
  36. package/dist/embed-widget/browser/agent-inventory.js +36 -0
  37. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
  38. package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
  39. package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
  40. package/dist/embed-widget/react/dialog.hooks.js +15 -0
  41. package/dist/embed-widget/react/embed.d.ts +7 -2
  42. package/dist/embed-widget/react/embed.js +6 -16
  43. package/dist/embed-widget/react/header.d.ts +4 -1
  44. package/dist/embed-widget/react/header.js +2 -2
  45. package/dist/embed-widget/vanilla/state.js +2 -2
  46. package/dist/embed-widget/vanilla/style.css +4 -4
  47. package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
  48. package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
  49. package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
  50. package/dist/react/components/A2uiSurfaceCard.js +14 -227
  51. package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
  52. package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
  53. package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
  54. package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
  55. package/dist/react/components/AttachmentPreviewModal.js +11 -9
  56. package/dist/react/components/AttachmentTray.d.ts +11 -1
  57. package/dist/react/components/AttachmentTray.js +12 -8
  58. package/dist/react/components/ChatFab.d.ts +10 -1
  59. package/dist/react/components/ChatFab.js +2 -2
  60. package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
  61. package/dist/react/components/ChatSettingsDialog.js +9 -6
  62. package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
  63. package/dist/react/components/ChatSettingsSegmented.js +1 -1
  64. package/dist/react/components/Composer.d.ts +9 -1
  65. package/dist/react/components/Composer.hooks.d.ts +79 -0
  66. package/dist/react/components/Composer.hooks.js +336 -0
  67. package/dist/react/components/Composer.js +40 -341
  68. package/dist/react/components/ComposerDiscovery.js +1 -1
  69. package/dist/react/components/ConversationList.d.ts +34 -1
  70. package/dist/react/components/ConversationList.hooks.d.ts +37 -0
  71. package/dist/react/components/ConversationList.hooks.js +177 -1
  72. package/dist/react/components/ConversationList.js +7 -174
  73. package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
  74. package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
  75. package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
  76. package/dist/react/components/ConversationTitleEditor.js +11 -34
  77. package/dist/react/components/CopyMessageButton.d.ts +6 -1
  78. package/dist/react/components/CopyMessageButton.js +4 -4
  79. package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
  80. package/dist/react/components/ExtEventErrorBoundary.js +5 -3
  81. package/dist/react/components/FolderChips.d.ts +11 -1
  82. package/dist/react/components/FolderChips.hooks.d.ts +12 -0
  83. package/dist/react/components/FolderChips.hooks.js +10 -0
  84. package/dist/react/components/FolderChips.js +9 -9
  85. package/dist/react/components/Markdown.js +7 -5
  86. package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
  87. package/dist/react/components/McpUiSurfaceCard.js +29 -16
  88. package/dist/react/components/MessageList.d.ts +10 -1
  89. package/dist/react/components/MessageList.hooks.js +4 -2
  90. package/dist/react/components/MessageList.js +12 -8
  91. package/dist/react/components/MessageRow.d.ts +46 -2
  92. package/dist/react/components/MessageRow.hooks.d.ts +60 -0
  93. package/dist/react/components/MessageRow.hooks.js +94 -0
  94. package/dist/react/components/MessageRow.js +53 -113
  95. package/dist/react/components/MidRunUserMessage.d.ts +6 -1
  96. package/dist/react/components/MidRunUserMessage.js +5 -5
  97. package/dist/react/components/NextStepActions.d.ts +3 -1
  98. package/dist/react/components/NextStepActions.js +3 -3
  99. package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
  100. package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
  101. package/dist/react/components/QuestionForm.d.ts +6 -0
  102. package/dist/react/components/QuestionForm.js +23 -261
  103. package/dist/react/components/QuestionForm.values.d.ts +22 -0
  104. package/dist/react/components/QuestionForm.values.js +58 -0
  105. package/dist/react/components/QuestionFormField.d.ts +17 -0
  106. package/dist/react/components/QuestionFormField.js +114 -0
  107. package/dist/react/components/QuestionsPanel.d.ts +3 -1
  108. package/dist/react/components/QuestionsPanel.js +7 -3
  109. package/dist/react/components/SentAttachment.d.ts +11 -2
  110. package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
  111. package/dist/react/components/SentAttachment.hooks.js +6 -5
  112. package/dist/react/components/SentAttachment.js +5 -3
  113. package/dist/react/components/TodoCard.d.ts +3 -1
  114. package/dist/react/components/TodoCard.js +9 -4
  115. package/dist/react/components/ToolCallGroup.d.ts +11 -1
  116. package/dist/react/components/ToolCallGroup.js +10 -4
  117. package/dist/react/components/ToolCard.d.ts +6 -1
  118. package/dist/react/components/ToolCard.js +79 -69
  119. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  120. package/dist/react/components/mcp-ui-question-input.js +3 -3
  121. package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
  122. package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
  123. package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
  124. package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
  125. package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
  126. package/dist/react/features/chat-pane/claude/model-options.js +2 -0
  127. package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
  128. package/dist/react/features/chat-pane/codex/model-options.js +2 -0
  129. package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
  130. package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
  131. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
  132. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
  133. package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
  134. package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
  135. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
  136. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
  137. package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
  138. package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
  139. package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
  140. package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
  141. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
  142. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
  143. package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
  144. package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
  145. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
  146. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
  147. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
  148. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
  149. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
  150. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
  151. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
  152. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
  153. package/dist/react/features/chat-pane/model-options.js +7 -4
  154. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  155. package/dist/react/features/chat-pane/styles.js +14 -14
  156. package/dist/react/features/chat-pane/types.d.ts +29 -1
  157. package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
  158. package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
  159. package/dist/react/hooks/attachment-preview-cache.js +1 -1
  160. package/dist/react/hooks/fab-position.js +16 -18
  161. package/dist/react/hooks/useConversation.d.ts +6 -1
  162. package/dist/react/hooks/useConversation.js +11 -10
  163. package/dist/react/hooks/useRunStream.d.ts +3 -0
  164. package/dist/react/hooks/useRunStream.js +12 -12
  165. package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
  166. package/dist/react/hooks/useSurfaceRecovery.js +2 -2
  167. package/dist/react/index.d.ts +6 -3
  168. package/dist/react/index.js +5 -3
  169. package/dist/react/styles/chat-settings.css +9 -9
  170. package/dist/react/surfaces.d.ts +91 -0
  171. package/dist/react/surfaces.js +28 -0
  172. package/dist/server/durable-runs/recover.d.ts +4 -3
  173. package/dist/server/durable-runs/recover.js +4 -3
  174. package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
  175. package/dist/store/legacy/sqlite/conversations.js +1 -1
  176. package/dist/store/legacy/sqlite/messages.d.ts +2 -3
  177. package/dist/store/legacy/sqlite/messages.js +6 -6
  178. package/dist/store/pglite/index.d.ts +7 -7
  179. package/dist/store/pglite/index.js +1 -1
  180. package/dist/store/ports.d.ts +5 -2
  181. package/dist/store/postgres/index.d.ts +7 -7
  182. package/dist/store/postgres/index.js +1 -1
  183. package/dist/store/runtime/chat-expiry-sweep.js +2 -4
  184. package/dist/store/runtime/chat-history-store.js +2 -3
  185. package/dist/store/runtime/durable-run-store.js +16 -2
  186. package/dist/store/runtime/history-tools.js +33 -11
  187. package/dist/store/runtime/kernel.d.ts +3 -2
  188. package/dist/store/runtime/run-ledger.js +2 -2
  189. package/dist/store/sql/boundary.d.ts +5 -5
  190. package/dist/store/sql/maintenance.d.ts +3 -2
  191. package/dist/store/sql/store.d.ts +16 -8
  192. package/dist/store/sql/store.js +31 -14
  193. package/dist/store/sqlite/index.d.ts +11 -12
  194. package/dist/store/sqlite/index.js +5 -5
  195. package/dist/store/sqlite/schema.d.ts +1 -1
  196. package/package.json +49 -27
  197. package/dist/core/ag-ui/entry.d.ts +0 -84
  198. package/dist/core/ag-ui/entry.js +0 -225
  199. package/dist/core/browser/page-actions.d.ts +0 -121
  200. package/dist/core/browser/page-actions.js +0 -113
  201. package/dist/embed-widget/browser/page-actions.d.ts +0 -2
  202. package/dist/embed-widget/browser/page-actions.js +0 -3
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { formatErrorForLog } from '@jini-ai/core';
2
+ import { describeErrorForLog } from '@jini-ai/core/model-facing-tool-errors';
3
+ import { createConsoleLogger } from '@jini-ai/core/primitives';
3
4
  /**
4
5
  * @module ExtEventErrorBoundary
5
6
  *
@@ -26,12 +27,13 @@ export class ExtEventErrorBoundary extends Component {
26
27
  // React already surfaces this in the dev console via its own error-boundary reporting; this
27
28
  // adds the ext-event `name` React's generic report has no way to know, and gives a host a
28
29
  // hook to route it into its own error reporting.
29
- console.error(`[ExtEventErrorBoundary] ext event "${this.props.name}" failed to render:`, formatErrorForLog({ error }));
30
+ const logger = this.props.report ?? createConsoleLogger({ prefix: '' });
31
+ logger.error({ message: `[ExtEventErrorBoundary] ext event "${this.props.name}" failed to render:` }, { error });
30
32
  this.props.onError?.(error, info);
31
33
  }
32
34
  render() {
33
35
  if (this.state.error) {
34
- return (_jsx("div", { className: "jini-ext-event-error", role: "alert", "data-ext-event-name": this.props.name, children: `"${this.props.name}" failed to render: ${this.state.error.message}` }));
36
+ return (_jsx("div", { className: "jini-ext-event-error", role: "alert", "data-ext-event-name": this.props.name, children: `"${this.props.name}" could not be rendered (${describeErrorForLog({ err: this.state.error })}).` }));
35
37
  }
36
38
  return this.props.children;
37
39
  }
@@ -1,15 +1,25 @@
1
+ import { useT } from '../hooks/context.js';
2
+ import { useFolderChips } from './FolderChips.hooks.js';
1
3
  type OnRemove = (input: {
2
4
  path: string;
3
5
  }, options?: {}) => void;
6
+ /** Hooks FolderChips calls; defaults to the real ones, a test hands in fakes. */
7
+ export declare const defaultFolderChipsHooks: {
8
+ useT: typeof useT;
9
+ useFolderChips: typeof useFolderChips;
10
+ };
11
+ export type FolderChipsHooks = typeof defaultFolderChipsHooks;
4
12
  /**
5
13
  * Shared composer/sent-message folder indicator; references never participate in uploads.
6
14
  * One folder shows its chip directly; a "Folders (n)" toggle would only repeat its name.
7
15
  */
8
- export declare function FolderChips({ agentHandle, folders, onRemove }: {
16
+ export declare function FolderChips({ agentHandle, folders, onRemove, hooks }: {
9
17
  /** Inherited Composer base; standalone sent-message folders remain opt-in. */
10
18
  agentHandle?: string | false | undefined;
11
19
  folders?: readonly string[] | undefined;
12
20
  onRemove?: OnRemove | undefined;
21
+ } & {
22
+ hooks?: FolderChipsHooks | undefined;
13
23
  }): import("react").JSX.Element | null;
14
24
  export {};
15
25
  //# sourceMappingURL=FolderChips.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { type ReactNode } from 'react';
2
+ /** Track disclosure state and render the same list for single and multiple folders. */
3
+ export declare function useFolderChips({ folders, renderChip }: {
4
+ folders: readonly string[];
5
+ renderChip: (path: string) => ReactNode;
6
+ }, _options?: {}): {
7
+ expanded: boolean;
8
+ setExpanded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
9
+ id: string;
10
+ list: (listId?: string) => import("react").JSX.Element;
11
+ };
12
+ //# sourceMappingURL=FolderChips.hooks.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useId, useState } from 'react';
3
+ /** Track disclosure state and render the same list for single and multiple folders. */
4
+ export function useFolderChips({ folders, renderChip }, _options = {}) {
5
+ const [expanded, setExpanded] = useState(false);
6
+ const id = useId();
7
+ const list = (listId) => _jsx("ul", { id: listId, className: "jini-folder-chips__list", children: folders.map(renderChip) });
8
+ return { expanded, setExpanded, id, list };
9
+ }
10
+ //# sourceMappingURL=FolderChips.hooks.js.map
@@ -1,33 +1,33 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useId, useState } from 'react';
3
- import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
2
+ import { agentHandleProps, agentHandleSegment } from '@jini-ai/core/agent-handles';
4
3
  import { useT } from '../hooks/context.js';
5
4
  import { CopyMessageButton } from './CopyMessageButton.js';
6
5
  import { Icon } from './Icon.js';
6
+ import { useFolderChips } from './FolderChips.hooks.js';
7
7
  /** Display only: splitting both separators never changes the exact path carried or copied. */
8
8
  function folderName({ path }, _options = {}) {
9
9
  return path.split(/[\\/]/).filter(Boolean).at(-1) ?? path;
10
10
  }
11
11
  /** One folder: last name (full path on hover), copy, and × when removable. */
12
- function FolderChip({ base, path, onRemove }) {
13
- const t = useT();
12
+ function FolderChip({ base, path, onRemove, useTHook = useT }) {
13
+ const t = useTHook();
14
14
  const segment = agentHandleSegment({ value: path });
15
15
  const copyLabel = t('Copy folder path: {path}', { path });
16
16
  const removeLabel = t('Remove folder: {path}', { path });
17
17
  return _jsxs("li", { className: "jini-folder-chips__item", children: [_jsx(Icon, { name: "folder" }), _jsx("span", { className: "jini-folder-chips__name", title: path, "aria-label": path, children: folderName({ path }) }), _jsx(CopyMessageButton, { agentHandle: base ? `${base}-folder-copy-${segment}` : false, text: path, label: copyLabel, title: copyLabel }), onRemove && _jsx("button", { type: "button", className: "jini-folder-chips__remove", title: removeLabel, ...agentHandleProps({}, { base, action: `folder-remove-${segment}`, role: 'button', label: removeLabel }), "aria-label": removeLabel, onClick: () => onRemove({ path }), children: _jsx(Icon, { name: "close" }) })] });
18
18
  }
19
+ /** Hooks FolderChips calls; defaults to the real ones, a test hands in fakes. */
20
+ export const defaultFolderChipsHooks = { useT, useFolderChips };
19
21
  /**
20
22
  * Shared composer/sent-message folder indicator; references never participate in uploads.
21
23
  * One folder shows its chip directly; a "Folders (n)" toggle would only repeat its name.
22
24
  */
23
- export function FolderChips({ agentHandle, folders = [], onRemove }) {
25
+ export function FolderChips({ agentHandle, folders = [], onRemove, hooks = defaultFolderChipsHooks }) {
24
26
  const base = agentHandle || undefined;
25
- const t = useT();
26
- const [expanded, setExpanded] = useState(false);
27
- const id = useId();
27
+ const t = hooks.useT();
28
+ const { expanded, setExpanded, id, list } = hooks.useFolderChips({ folders, renderChip: path => _jsx(FolderChip, { base: base, path: path, onRemove: onRemove }, path) });
28
29
  if (folders.length === 0)
29
30
  return null;
30
- const list = (listId) => _jsx("ul", { id: listId, className: "jini-folder-chips__list", children: folders.map(path => _jsx(FolderChip, { base: base, path: path, onRemove: onRemove }, path)) });
31
31
  if (folders.length === 1)
32
32
  return _jsx("div", { className: "jini-folder-chips", children: list() });
33
33
  return _jsxs("div", { className: "jini-folder-chips", children: [_jsxs("button", { type: "button", className: "jini-folder-chips__toggle", "aria-expanded": expanded, "aria-controls": id, ...agentHandleProps({}, { base, action: 'folders-toggle', role: 'button', label: t('Folders ({count})', { count: folders.length }) }), onClick: () => setExpanded(value => !value), children: [_jsx(Icon, { name: "folder" }), _jsx("span", { children: t('Folders ({count})', { count: folders.length }) }), _jsx(Icon, { name: expanded ? 'chevron-down' : 'chevron-right' })] }), expanded && list(id)] });
@@ -303,12 +303,14 @@ function renderBlock(block) {
303
303
  function CodeBlock({ lang, body }) {
304
304
  return (_jsxs("div", { className: "jini-md-code-block", children: [_jsx("div", { className: "jini-md-code-toolbar", children: _jsx(CopyCodeButton, { code: body }) }), _jsx("pre", { children: _jsx("code", { "data-lang": lang ?? undefined, children: body }) })] }));
305
305
  }
306
+ /** Hooks CopyCodeButton calls; defaults to the real ones, a test hands in fakes. */
307
+ const defaultCopyCodeButtonHooks = { useT, useCopyToClipboard };
306
308
  // Per-block copy affordance for CodeBlock above. Mirrors MessageRow.tsx's CopyMessageButton
307
309
  // one-for-one in shape -- same hook, same icon swap, same visually-hidden aria-live announce --
308
310
  // but stays its own component rather than a shared one; see this module's header comment for why.
309
- function CopyCodeButton({ code }) {
310
- const t = useT();
311
- const { copied, copy } = useCopyToClipboard();
311
+ function CopyCodeButton({ code, hooks = defaultCopyCodeButtonHooks }) {
312
+ const t = hooks.useT();
313
+ const { copied, copy } = hooks.useCopyToClipboard();
312
314
  return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "jini-md-code-copy", "aria-label": copied ? t('Copied') : t('Copy code'), onClick: () => {
313
315
  void copy(code);
314
316
  }, children: _jsx(Icon, { name: copied ? 'check' : 'copy' }) }), _jsx("span", { className: "jini-md-code-copy-status", "aria-live": "polite", children: copied ? t('Copied to clipboard') : '' })] }));
@@ -377,8 +379,8 @@ function closeTableDialog(dialog) {
377
379
  }
378
380
  dialog.removeAttribute('open');
379
381
  }
380
- function TableBlock(props) {
381
- const { wrapRef, isOverflowing } = useTableOverflow();
382
+ function TableBlock({ useTableOverflowHook = useTableOverflow, ...props }) {
383
+ const { wrapRef, isOverflowing } = useTableOverflowHook();
382
384
  const [expanded, setExpanded] = useState(false);
383
385
  const dialogRef = useRef(null);
384
386
  useEffect(() => {
@@ -1,6 +1,8 @@
1
- import { type McpUiToolCallHandler } from '@jini-ai/ui/mcp-ui';
2
- import { type ExtEventRendererRegistry, type ExtEventRenderProps } from '../ext-event-renderer-registry.js';
3
- import { type SurfaceExpiryClock } from '../hooks/useSurfaceExpiry.js';
1
+ import { type McpUiToolCallHandler } from '@jini-ai/protocol/mcp-ui';
2
+ import { type ExtEventRendererRegistry, type ExtEventCall, type ExtEventRenderProps } from '../ext-event-renderer-registry.js';
3
+ import { useT } from '../hooks/context.js';
4
+ import { useSurfaceExpiry, type SurfaceExpiryClock } from '../hooks/useSurfaceExpiry.js';
5
+ import { useSurfaceRecovery } from '../hooks/useSurfaceRecovery.js';
4
6
  /** The `kind: 'ext'` event name this renderer claims. */
5
7
  export declare const MCP_UI_EXT_EVENT_NAME = "mcp-ui";
6
8
  export interface McpUiSurfaceCardProps extends ExtEventRenderProps {
@@ -8,7 +10,7 @@ export interface McpUiSurfaceCardProps extends ExtEventRenderProps {
8
10
  * Where the sandbox proxy page is served. Required since 2026-08-18, when this card's rendering
9
11
  * switched from a hand-rolled `srcdoc` iframe to the real `@mcp-ui/client` `AppRenderer`, which
10
12
  * mounts every View through a real, separately-served proxy page rather than inline HTML — see
11
- * `@jini-ai/ui/mcp-ui`'s `SANDBOX_PROXY_HTML` (in `sandbox-proxy.js`) for what must be running at
13
+ * `@jini-ai/ui/mcp-ui`'s `SANDBOX_PROXY_HTML` (in `packages/ui/src/features/mcp-ui/sandbox-proxy.ts`) for what must be running at
12
14
  * that URL and why this package cannot supply a default itself.
13
15
  */
14
16
  sandboxProxyUrl: URL;
@@ -29,8 +31,29 @@ export interface McpUiSurfaceCardProps extends ExtEventRenderProps {
29
31
  */
30
32
  expiryClock?: SurfaceExpiryClock;
31
33
  }
34
+ /** Hooks McpUiSurfaceCard calls; defaults to the real ones, a test hands in fakes. */
35
+ export declare const defaultMcpUiSurfaceCardHooks: {
36
+ useT: typeof useT;
37
+ useSurfaceRecovery: typeof useSurfaceRecovery;
38
+ useSurfaceQuestionCall: typeof useSurfaceQuestionCall;
39
+ useSurfaceExpiry: typeof useSurfaceExpiry;
40
+ };
41
+ export type McpUiSurfaceCardHooks = typeof defaultMcpUiSurfaceCardHooks;
32
42
  /** Registered against `ext-event-renderer-registry.ts`'s `'mcp-ui'` name — see module doc. */
33
- export declare function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded }: McpUiSurfaceCardProps): import("react").JSX.Element;
43
+ export declare function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded, hooks }: McpUiSurfaceCardProps & {
44
+ hooks?: McpUiSurfaceCardHooks | undefined;
45
+ }): import("react").JSX.Element;
46
+ /** A standalone form's call may lack the question; its current document supplies the title and
47
+ * option labels, so retry answers read as labels rather than raw values from the replaced question.
48
+ * Receipt recovery retains the original document separately in useSurfaceAnswerContexts. */
49
+ declare function useSurfaceQuestionCall({ events, call }: {
50
+ events: readonly unknown[];
51
+ call: ExtEventCall | undefined;
52
+ }, _options?: {}): {
53
+ displayCall: ExtEventCall;
54
+ input: unknown;
55
+ standalone: boolean;
56
+ };
34
57
  /**
35
58
  * The ext-event slot key for MCP-UI: one slot per `ui://` URI. Each resource is its own card, so a
36
59
  * run's second card renders where it arrived instead of inside the first card's slot, while a
@@ -67,4 +90,5 @@ export declare function registerMcpUiSurfaceRenderer(options: {
67
90
  /** Register in owned state when supplied; otherwise preserve the global API. */
68
91
  registry?: ExtEventRendererRegistry;
69
92
  }): () => void;
93
+ export {};
70
94
  //# sourceMappingURL=McpUiSurfaceCard.d.ts.map
@@ -65,7 +65,8 @@ import { trimChars } from '@jini-ai/core/primitives';
65
65
  import { questionAnswerFromResult, questionAnswerLabel } from '../../core/question-answer.js';
66
66
  import { MidRunUserMessage } from './MidRunUserMessage.js';
67
67
  import { Fragment, useMemo } from 'react';
68
- import { McpUiHost, parseUIResource, readActionPlan, readExpiresAt, readPreferredFrameSize, } from '@jini-ai/ui/mcp-ui';
68
+ import { McpUiHost } from '../surfaces.js';
69
+ import { parseUIResource, readActionPlan, readExpiresAt, readPreferredFrameSize, } from '@jini-ai/protocol/mcp-ui';
69
70
  import { defaultExtEventRendererRegistry } from '../ext-event-renderer-registry.js';
70
71
  import { useT } from '../hooks/context.js';
71
72
  import { useSurfaceExpiry } from '../hooks/useSurfaceExpiry.js';
@@ -78,7 +79,7 @@ export const MCP_UI_EXT_EVENT_NAME = 'mcp-ui';
78
79
  function latestResourcesByUri(events) {
79
80
  const byUri = new Map();
80
81
  for (const event of events) {
81
- const resource = parseUIResource(event);
82
+ const resource = parseUIResource({ value: event });
82
83
  if (resource === undefined)
83
84
  continue;
84
85
  byUri.set(resource.resource.uri, resource);
@@ -140,39 +141,51 @@ function ClosedSurface({ call, label }) {
140
141
  function surfaceInteraction({ resource, answered, onToolCall, onAnswered, onAnswerText, call }, _options = {}) {
141
142
  // An answered card has no deadline left: its countdown goes, and the deadline passing while the
142
143
  // answer's work still runs must not relabel it "This question expired".
143
- const expiresAtMs = resource === undefined || answered === true ? undefined : readExpiresAt(resource);
144
+ const expiresAtMs = resource === undefined || answered === true ? undefined : readExpiresAt({ resource });
144
145
  // Reports the person's delivered answer to the row, which stops the "Waiting for your answer" line.
145
146
  const toolCall = onToolCall === undefined || onAnswered === undefined ? onToolCall : reportDeliveredAnswer({ onToolCall, onAnswered, onAnswerText, input: call?.input });
146
147
  return { expiresAtMs, toolCall };
147
148
  }
149
+ /** Hooks McpUiSurfaceCard calls; defaults to the real ones, a test hands in fakes. */
150
+ export const defaultMcpUiSurfaceCardHooks = { useT, useSurfaceRecovery, useSurfaceQuestionCall, useSurfaceExpiry };
148
151
  /** Registered against `ext-event-renderer-registry.ts`'s `'mcp-ui'` name — see module doc. */
149
- export function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded }) {
150
- const t = useT();
152
+ export function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded, hooks = defaultMcpUiSurfaceCardHooks }) {
153
+ const t = hooks.useT();
151
154
  const originalResources = useMemo(() => latestResourcesByUri(events), [events]);
152
- const recovery = useSurfaceRecovery({ resource: originalResources.length === 1 ? originalResources[0] : undefined,
155
+ const recovery = hooks.useSurfaceRecovery({ resource: originalResources.length === 1 ? originalResources[0] : undefined,
153
156
  call, runStreaming, onToolCall });
154
- const resources = recovery.restored && recovery.resource ? [recovery.resource] : originalResources;
157
+ const { resources, currentEvents, currentCall } = recoveredView({ recovery, resources: originalResources, events, call });
155
158
  // One card per slot is the registered shape (`mcpUiSurfaceSlotKey`), so `call` belongs to exactly
156
159
  // that card. A group holding several URIs has no single call to judge them by, and stays live.
157
160
  const single = resources.length === 1 ? resources[0] : undefined;
158
- const currentEvents = recovery.restored && recovery.resource ? [recovery.resource] : events;
159
- const currentCall = recovery.restored ? undefined : call;
160
- const { displayCall, input, standalone } = useSurfaceQuestionCall({ events: currentEvents, call: currentCall });
161
+ const { displayCall, input, standalone } = hooks.useSurfaceQuestionCall({ events: currentEvents, call: currentCall });
161
162
  const { expiresAtMs, toolCall } = surfaceInteraction({ resource: single, answered, onToolCall: recovery.onToolCall, onAnswered, onAnswerText, call: displayCall });
162
- const expiry = useSurfaceExpiry({ expiresAtMs }, expiryClock === undefined ? {} : { clock: expiryClock });
163
+ const expiry = hooks.useSurfaceExpiry({ expiresAtMs }, expiryClock === undefined ? {} : { clock: expiryClock });
163
164
  const closed = single === undefined
164
165
  ? undefined
165
166
  : closedSurfaceLabel({ t, call: currentCall, runStreaming: recovery.live || runStreaming,
166
167
  documentsForUri: currentEvents.length, expired: expiry?.expired === true });
167
168
  // A completed call answered the original document; a replacement outcome or retry owns its view.
168
- const answer = (currentEvents.length === 1 ? questionAnswerFromResult({ result: currentCall?.result, input }) : undefined) ?? answerText;
169
+ const answer = recordedOrTypedAnswer({ events: currentEvents, call: currentCall, input, answerText });
169
170
  return _jsx(SurfaceCardContent, { resources: resources, single: single, answerRecorded: answerRecorded, answer: answer, closed: closed, call: displayCall, standalone: standalone, t: t, sandboxProxyUrl: sandboxProxyUrl, toolCall: toolCall, onOpenLink: onOpenLink, maxHeight: maxHeight, expiry: expiry });
170
171
  }
172
+ /** A completed call's answer, when exactly one document was shown for it; else the answer the host typed. */
173
+ function recordedOrTypedAnswer({ events, call, input, answerText }, _options = {}) {
174
+ return (events.length === 1 ? questionAnswerFromResult({ result: call?.result, input }) : undefined) ?? answerText;
175
+ }
176
+ /** What the card shows after recovery: a restored document replaces the originals and leaves no call to judge it by. */
177
+ function recoveredView({ recovery, resources, events, call }, _options = {}) {
178
+ return {
179
+ resources: recovery.restored && recovery.resource ? [recovery.resource] : resources,
180
+ currentEvents: recovery.restored && recovery.resource ? [recovery.resource] : events,
181
+ currentCall: recovery.restored ? undefined : call,
182
+ };
183
+ }
171
184
  /** A standalone form's call may lack the question; its current document supplies the title and
172
185
  * option labels, so retry answers read as labels rather than raw values from the replaced question.
173
186
  * Receipt recovery retains the original document separately in useSurfaceAnswerContexts. */
174
187
  function useSurfaceQuestionCall({ events, call }, _options = {}) {
175
- const resource = parseUIResource(events.at(-1));
188
+ const resource = parseUIResource({ value: events.at(-1) });
176
189
  const input = useMemo(() => surfaceQuestionInput({ resource, input: call?.input }), [resource?.resource.text, resource?.resource._meta, call?.input]);
177
190
  const displayCall = call === undefined ? { name: '', input } : { ...call, input };
178
191
  return { displayCall, input, standalone: input !== call?.input };
@@ -208,9 +221,9 @@ function SurfaceCardContent({ resources, single, answerRecorded, answer, closed,
208
221
  return (_jsx("div", { className: "mcpui-surface-card mcpui-surface-card-empty", role: "status", children: t('This MCP-UI event carried no renderable resource.') }));
209
222
  }
210
223
  return (_jsxs("div", { className: "mcpui-surface-card", children: [resources.map((resource) => {
211
- const preferred = readPreferredFrameSize(resource);
224
+ const preferred = readPreferredFrameSize({ resource });
212
225
  const height = preferred === undefined ? undefined : Number.parseInt(preferred[1], 10);
213
- const plan = readActionPlan(resource);
226
+ const plan = readActionPlan({ resource });
214
227
  return (_jsxs(Fragment, { children: [_jsx(McpUiHost, { title: frameTitle ?? surfaceQuestionTitle({ resource }), html: resource.resource.text, sandboxProxyUrl: sandboxProxyUrl, toolName: resource.resource.uri,
215
228
  // The whole document, not its LENGTH. `useMcpUiHost` already defaults `sessionKey` to
216
229
  // `html` — exact by construction — and this override replaced that with a digest so
@@ -230,7 +243,7 @@ function SurfaceCardContent({ resources, single, answerRecorded, answer, closed,
230
243
  * when registering a custom MCP-UI renderer; {@link registerMcpUiSurfaceRenderer} already does.
231
244
  */
232
245
  export function mcpUiSurfaceSlotKey({ data }) {
233
- return parseUIResource(data)?.resource.uri;
246
+ return parseUIResource({ value: data })?.resource.uri;
234
247
  }
235
248
  /**
236
249
  * Registers {@link McpUiSurfaceCard} against the ext-event registry.
@@ -1,4 +1,5 @@
1
1
  import type { ChatAttachment, ChatMessage } from '../../core/index.js';
2
+ import { useMessageListAutoScroll, useConversationUsage } from './MessageList.hooks.js';
2
3
  import { type MessageRowProps } from './MessageRow.js';
3
4
  interface PendingPrompt {
4
5
  id?: string;
@@ -24,12 +25,20 @@ export interface MessageListProps extends Pick<MessageRowProps, 'projectFileName
24
25
  pendingPrompt?: PendingPrompt | null;
25
26
  pendingPrompts?: readonly PendingPrompt[];
26
27
  }
28
+ /** Hooks MessageList calls; defaults to the real ones, a test hands in fakes. */
29
+ export declare const defaultMessageListHooks: {
30
+ useConversationUsage: typeof useConversationUsage;
31
+ useMessageListAutoScroll: typeof useMessageListAutoScroll;
32
+ };
33
+ export type MessageListHooks = typeof defaultMessageListHooks;
27
34
  /**
28
35
  * Memoized: the pane re-renders on every composer keystroke, and re-rendering a long transcript
29
36
  * (hundreds of tool rows, MCP-UI cards, markdown) per key made typing lag (owner report
30
37
  * 2026-10-08). Callers must pass stable props — `ChatPane` memoizes `pendingPrompts` and
31
38
  * `projectFileNames` for exactly this.
32
39
  */
33
- export declare const MessageList: import("react").NamedExoticComponent<MessageListProps>;
40
+ export declare const MessageList: import("react").NamedExoticComponent<MessageListProps & {
41
+ hooks?: MessageListHooks | undefined;
42
+ }>;
34
43
  export {};
35
44
  //# sourceMappingURL=MessageList.d.ts.map
@@ -35,6 +35,9 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
35
35
  // Starts true: a freshly mounted pane opens on the latest turn, same as scrollIntent's own default.
36
36
  const stickToBottomRef = useRef(true);
37
37
  const previousMessagesRef = useRef(messages);
38
+ // Read the latest callback without making callback identity trigger an extra scroll.
39
+ const onScrolledRef = useRef(onScrolled);
40
+ onScrolledRef.current = onScrolled;
38
41
  // `scrollTop` at the previous `scroll` event — `nextStickToBottom` needs the direction of travel.
39
42
  // Only scroll events write it (a browser fires one for programmatic scrolls too). Starts at
40
43
  // Infinity, "no position seen yet", so a first event away from the bottom unsticks as it always did.
@@ -70,8 +73,7 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
70
73
  if (el && stickToBottomRef.current) {
71
74
  el.scrollTop = el.scrollHeight;
72
75
  }
73
- onScrolled?.();
74
- // eslint-disable-next-line react-hooks/exhaustive-deps
76
+ onScrolledRef.current?.();
75
77
  }, [scrollIntent, messages]);
76
78
  // Re-sticks to the bottom when a message ROW grows after mount with no accompanying `messages`
77
79
  // change — the exact case an embedded MCP-UI/A2UI surface hits: it mounts at an initial guessed
@@ -24,19 +24,21 @@ function renderMessageRow({ message, isLast, isStreaming, usageSummary, sending,
24
24
  const runStreaming = isLast && isStreaming && !isTerminalRunStatus({ status: message.runStatus });
25
25
  return (_jsx(MessageRow, { message: message, ...rowProps, showAccessNotice: showAccessNotice, ...(usageSummary === undefined ? {} : { usageSummary }), runStreaming: runStreaming, runSending: sending, runSucceeded: message.runStatus === 'succeeded', questionFormInteractive: message.id === activeQuestionFormMessageId, ...(questionFormSubmittedAnswersByMessageId?.[message.id] !== undefined ? { questionFormSubmittedAnswers: questionFormSubmittedAnswersByMessageId[message.id] } : {}), ...(onQuestionFormSubmit !== undefined ? { onQuestionFormSubmit: (text, answers) => onQuestionFormSubmit(message.id, text, answers) } : {}) }, message.id));
26
26
  }
27
+ /** Hooks MessageList calls; defaults to the real ones, a test hands in fakes. */
28
+ export const defaultMessageListHooks = { useConversationUsage, useMessageListAutoScroll };
27
29
  /**
28
30
  * Memoized: the pane re-renders on every composer keystroke, and re-rendering a long transcript
29
31
  * (hundreds of tool rows, MCP-UI cards, markdown) per key made typing lag (owner report
30
32
  * 2026-10-08). Callers must pass stable props — `ChatPane` memoizes `pendingPrompts` and
31
33
  * `projectFileNames` for exactly this.
32
34
  */
33
- export const MessageList = memo(function MessageList({ messages: sourceMessages, isStreaming = false, scrollIntent = false, onScrolled, pendingPrompt, pendingPrompts, ...rowProps }) {
35
+ export const MessageList = memo(function MessageList({ messages: sourceMessages, isStreaming = false, scrollIntent = false, onScrolled, pendingPrompt, pendingPrompts, hooks = defaultMessageListHooks, ...rowProps }) {
34
36
  const messages = useMemo(() => projectAcceptedInputMessages({ messages: sourceMessages }), [sourceMessages]);
35
- const usageByMessage = useConversationUsage({ messages });
37
+ const usageByMessage = hooks.useConversationUsage({ messages });
36
38
  // Derive from the conversation's saved events, so replay/remount does not repeat the notice.
37
39
  const accessNoticeId = useMemo(() => messages.find(message => message.role === 'assistant'
38
40
  && message.events?.some(event => event.kind === 'status' && event.label === 'full_cli_access' && event.detail))?.id, [messages]);
39
- const { containerRef, onScroll, awayFromLatest, jumpToLatest, scrollable, jumpToTop } = useMessageListAutoScroll({ messages, scrollIntent }, onScrolled !== undefined ? { onScrolled } : {});
41
+ const { containerRef, onScroll, awayFromLatest, jumpToLatest, scrollable, jumpToTop } = hooks.useMessageListAutoScroll({ messages, scrollIntent }, onScrolled !== undefined ? { onScrolled } : {});
40
42
  return (_jsxs("div", { className: "jini-message-list", ref: containerRef, onScroll: onScroll, "data-agent-element": "chat-transcript", "data-agent-role": "list", "data-agent-label": "The conversation transcript, oldest message first", children: [messages.map((message, index) => renderMessageRow({
41
43
  message,
42
44
  showAccessNotice: message.id === accessNoticeId,
@@ -56,18 +58,20 @@ export const MessageList = memo(function MessageList({ messages: sourceMessages,
56
58
  * now — down to the latest when scrolled away, up to the top when already there. The label lives in
57
59
  * aria-label/title only, so screen readers and hover still name it.
58
60
  */
59
- function JumpArrow({ direction, onJump }) {
60
- const t = useT();
61
+ function JumpArrow({ direction, onJump, useTHook = useT }) {
62
+ const t = useTHook();
61
63
  const label = direction === 'down' ? t('Jump to latest') : t('Jump to top');
62
64
  return (_jsx("div", { className: "jini-message-list__jump", children: _jsx("button", { type: "button", className: "jini-message-list__jump-btn", onClick: onJump, "aria-label": label, title: label, children: _jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: direction === 'down'
63
65
  ? _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 5v14" }), _jsx("path", { d: "m19 12-7 7-7-7" })] })
64
66
  : _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 19V5" }), _jsx("path", { d: "m5 12 7-7 7 7" })] }) }) }) }));
65
67
  }
68
+ /** Hooks QueuedMessage calls; defaults to the real ones, a test hands in fakes. */
69
+ const defaultQueuedMessageHooks = { useT, useAttachmentGallery };
66
70
  /** One cancelable queue receipt; attachment rendering reuses the sent-message preview owner. */
67
- function QueuedMessage({ prompt, renderAttachment }) {
68
- const t = useT();
71
+ function QueuedMessage({ prompt, renderAttachment, hooks = defaultQueuedMessageHooks }) {
72
+ const t = hooks.useT();
69
73
  const attachments = prompt.attachments ?? [];
70
- const gallery = useAttachmentGallery({ attachments });
74
+ const gallery = hooks.useAttachmentGallery({ attachments });
71
75
  return (_jsxs("div", { className: "jini-chat-pane__queued", role: "status", "aria-label": t('Message queued — not yet sent, will send once the current run finishes'), "data-testid": "chat-pane-queued", "data-agent-element": "chat-message-pending", "data-agent-role": "region", "data-agent-label": "A message queued to send once the current run finishes", children: [_jsx("div", { className: "jini-chat-pane__status", children: t('Queued — sends when this reply finishes') }), prompt.folders?.length ? _jsx("div", { className: "jini-message-attachments", children: _jsx(FolderChips, { folders: prompt.folders }) }) : null, _jsx("div", { className: "jini-chat-pane__queued-text", children: prompt.text }), attachments.length > 0 && _jsx("div", { className: "jini-message-attachments", children: attachments.map(attachment => _jsx(SentAttachmentButton, { attachment: attachment, onOpen: gallery.open, renderAttachment: renderAttachment }, attachment.path)) }), gallery.opened !== null && _jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation }), _jsx("div", { className: "jini-chat-pane__queued-actions", children: _jsx("button", { type: "button", className: "jini-chat-pane__queued-cancel", onClick: () => prompt.onCancel(), title: t('Cancel queued message'), children: t('Cancel') }) })] }));
72
76
  }
73
77
  //# sourceMappingURL=MessageList.js.map
@@ -1,4 +1,7 @@
1
+ import type { Logger } from '@jini-ai/core/primitives';
2
+ import { useSurfaceAnswerContexts } from './mcp-ui-question-input.js';
1
3
  import type { ChatUsageSummary } from '../../core/turn-usage.js';
4
+ import { useUsageSummary } from './MessageRow.usage.js';
2
5
  /**
3
6
  * @module MessageRow
4
7
  *
@@ -50,9 +53,11 @@ import type { ChatUsageSummary } from '../../core/turn-usage.js';
50
53
  * chunk stopped arriving.
51
54
  */
52
55
  import React, { type ReactNode } from 'react';
53
- import type { ChatAttachment, ChatMessage } from '../../core/index.js';
56
+ import type { ChatAttachment, ChatMessage, IsAnsweredCard } from '../../core/index.js';
57
+ import { useT } from '../hooks/context.js';
54
58
  import { type ToolCallDisplay } from '../tool-call-display.js';
55
59
  export interface MessageRowProps {
60
+ report?: Pick<Logger, 'error'> | undefined;
56
61
  message: ChatMessage;
57
62
  /** Conversation hosts show the first access status only; standalone rows retain it by default. */
58
63
  showAccessNotice?: boolean;
@@ -88,10 +93,49 @@ export interface MessageRowProps {
88
93
  /** Host-supplied renderer for a `ChatAttachment` chip. Falls back to a plain filename chip. */
89
94
  renderAttachment?: (attachment: ChatAttachment) => ReactNode;
90
95
  }
96
+ /** Hooks UsageSummary calls; defaults to the real ones, a test hands in fakes. */
97
+ export declare const defaultUsageSummaryHooks: {
98
+ useT: typeof useT;
99
+ useUsageSummary: typeof useUsageSummary;
100
+ };
101
+ export type UsageSummaryHooks = typeof defaultUsageSummaryHooks;
102
+ /** One "Done · 6m 29s · $0.41 · total $2.50" line from reported usage, never estimated (the total is
103
+ * left off when `showTotal` is false). Partial usage stays partial; output tokens are available to
104
+ * assistive technology and in the tooltip. */
105
+ export declare function UsageSummary({ usage, showTotal, message, awaitingAnswer, hooks }: {
106
+ usage: ChatUsageSummary;
107
+ showTotal: boolean;
108
+ message?: ChatMessage;
109
+ awaitingAnswer?: boolean;
110
+ } & {
111
+ hooks?: UsageSummaryHooks | undefined;
112
+ }): React.JSX.Element | null;
113
+ export declare function ThinkingBlock({ text, useTHook }: {
114
+ text: string;
115
+ } & {
116
+ useTHook?: typeof useT;
117
+ }): React.JSX.Element | null;
118
+ export declare function AssistantMessageFooter({ message, usageEvent, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard, useTHook }: {
119
+ message: ChatMessage;
120
+ usageEvent: ChatUsageSummary | undefined;
121
+ showUsageTotal: boolean;
122
+ terminalNotice: string | null;
123
+ pending: boolean;
124
+ runInProgress: boolean;
125
+ runStreaming?: boolean;
126
+ runSending: boolean;
127
+ visibleContent: string;
128
+ isAnsweredCard: IsAnsweredCard;
129
+ sendingLabel: string | undefined;
130
+ } & {
131
+ useTHook?: typeof useT;
132
+ }): React.JSX.Element;
91
133
  /**
92
134
  * Memoized so a transcript re-render (a streaming update to the newest message, or a parent that
93
135
  * re-renders per composer keystroke) only re-renders rows whose props actually changed. Messages
94
136
  * are replaced, never mutated, so identity is a sound change signal.
95
137
  */
96
- export declare const MessageRow: React.NamedExoticComponent<MessageRowProps>;
138
+ export declare const MessageRow: React.NamedExoticComponent<MessageRowProps & {
139
+ useSurfaceAnswerContextsHook?: typeof useSurfaceAnswerContexts;
140
+ }>;
97
141
  //# sourceMappingURL=MessageRow.d.ts.map
@@ -0,0 +1,60 @@
1
+ import type { Logger } from '@jini-ai/core/primitives';
2
+ import React, { type ReactNode } from 'react';
3
+ import type { ChatMessage } from '../../core/index.js';
4
+ import type { ToolTimelineRow } from '../hooks/useToolTimeline.js';
5
+ import type { ExtEventGroup } from '../hooks/useExtEventGroups.js';
6
+ import type { AnsweredCards } from '../hooks/useAnsweredCards.js';
7
+ import type { ExtEventRendererRegistry } from '../ext-event-renderer-registry.js';
8
+ import type { MessageBlock } from '../message-blocks.js';
9
+ import { type ToolCallDisplay } from '../tool-call-display.js';
10
+ import { type usageLayout } from './MessageRow.usage.js';
11
+ import type { MessageRowProps, UsageSummary as UsageSummaryComponent, ThinkingBlock as ThinkingBlockComponent, AssistantMessageFooter as AssistantMessageFooterComponent } from './MessageRow.js';
12
+ type AssistantBlock = MessageBlock<ToolTimelineRow>;
13
+ /** Build the assistant transcript renderers with the current row's state and host callbacks. */
14
+ export declare function useAssistantMessageRenderers({ message, rows, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile, toolCallDisplay, registry, answeredCards, runInProgress, awaitingAnswer, questionFormInteractive, questionFormSubmittedAnswers, onQuestionFormSubmit, usage, showUsageLine, showUsageTotal, lastFinishedReply, extGroups, footerUsage, terminalNotice, pending, runSending, sendingLabel, visibleContent, flatTools, flatExtGroups, UsageSummary, ThinkingBlock, AssistantMessageFooter }: {
15
+ message: ChatMessage;
16
+ rows: ToolTimelineRow[];
17
+ runStreaming: boolean;
18
+ runSucceeded: boolean;
19
+ projectFileNames: MessageRowProps['projectFileNames'];
20
+ onRequestOpenFile: MessageRowProps['onRequestOpenFile'];
21
+ toolCallDisplay: ToolCallDisplay;
22
+ registry: ExtEventRendererRegistry;
23
+ answeredCards: AnsweredCards;
24
+ runInProgress: boolean;
25
+ awaitingAnswer: boolean;
26
+ questionFormInteractive: boolean;
27
+ questionFormSubmittedAnswers: MessageRowProps['questionFormSubmittedAnswers'];
28
+ onQuestionFormSubmit: MessageRowProps['onQuestionFormSubmit'];
29
+ usage: ReturnType<typeof usageLayout>;
30
+ showUsageLine: boolean;
31
+ showUsageTotal: boolean;
32
+ lastFinishedReply: number;
33
+ extGroups: ExtEventGroup[];
34
+ footerUsage: ReturnType<typeof usageLayout>['footer'];
35
+ terminalNotice: string | null;
36
+ pending: boolean;
37
+ runSending: boolean;
38
+ sendingLabel: string | undefined;
39
+ visibleContent: string;
40
+ flatTools: {
41
+ rows: readonly ToolTimelineRow[];
42
+ key: string;
43
+ }[];
44
+ flatExtGroups: ExtEventGroup[];
45
+ UsageSummary: typeof UsageSummaryComponent;
46
+ ThinkingBlock: typeof ThinkingBlockComponent;
47
+ AssistantMessageFooter: typeof AssistantMessageFooterComponent;
48
+ }, { report }?: {
49
+ report?: Pick<Logger, 'error'> | undefined;
50
+ }): {
51
+ renderBlock: (block: AssistantBlock) => ReactNode;
52
+ renderExtGroup: (group: ExtEventGroup) => React.JSX.Element | null;
53
+ renderAssistantSection: ({ section, key, footer }: {
54
+ section: readonly AssistantBlock[] | null;
55
+ key: string;
56
+ footer: boolean;
57
+ }) => React.JSX.Element;
58
+ };
59
+ export {};
60
+ //# sourceMappingURL=MessageRow.hooks.d.ts.map