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

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 (216) hide show
  1. package/README.md +49 -0
  2. package/dist/core/accepted-input.d.ts +1 -1
  3. package/dist/core/ag-ui/event-projection.d.ts +14 -69
  4. package/dist/core/ag-ui/event-projection.js +58 -133
  5. package/dist/core/ag-ui/event-reduction.d.ts +12 -2
  6. package/dist/core/ag-ui/event-reduction.js +35 -10
  7. package/dist/core/ag-ui/resume.d.ts +110 -0
  8. package/dist/core/ag-ui/resume.js +200 -0
  9. package/dist/core/ag-ui/run-input.d.ts +23 -0
  10. package/dist/core/ag-ui/run-input.js +45 -0
  11. package/dist/core/ag-ui/server.d.ts +69 -0
  12. package/dist/core/ag-ui/server.js +71 -0
  13. package/dist/core/agent-plugin-chat-state.js +13 -11
  14. package/dist/core/assistant-client/ag-ui-approval-relay.d.ts +113 -0
  15. package/dist/core/assistant-client/ag-ui-approval-relay.js +287 -0
  16. package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +25 -10
  17. package/dist/core/assistant-client/ag-ui-fetch-agent.js +25 -6
  18. package/dist/core/assistant-client/ag-ui-transport.d.ts +86 -3
  19. package/dist/core/assistant-client/ag-ui-transport.js +310 -80
  20. package/dist/core/assistant-client/browser-durable-subscription.d.ts +25 -0
  21. package/dist/core/assistant-client/browser-durable-subscription.js +78 -0
  22. package/dist/core/assistant-client/durable-run-subscription.js +141 -130
  23. package/dist/core/assistant-client/entry.d.ts +2 -1
  24. package/dist/core/assistant-client/entry.js +1 -0
  25. package/dist/core/assistant-client/transport-prompt.d.ts +94 -0
  26. package/dist/core/assistant-client/transport-prompt.js +180 -0
  27. package/dist/core/assistant-client/transport-run.d.ts +49 -0
  28. package/dist/core/assistant-client/transport-run.js +432 -0
  29. package/dist/core/assistant-client/transport-stream.d.ts +73 -0
  30. package/dist/core/assistant-client/transport-stream.js +128 -0
  31. package/dist/core/assistant-client/transport.d.ts +1 -1
  32. package/dist/core/assistant-client/transport.js +129 -835
  33. package/dist/core/assistant-content.d.ts +1 -17
  34. package/dist/core/assistant-content.js +16 -0
  35. package/dist/core/assistant-tool-metadata.d.ts +103 -0
  36. package/dist/core/assistant-tool-metadata.js +56 -0
  37. package/dist/core/checkpoint-interval.d.ts +1 -1
  38. package/dist/core/compact-events.d.ts +1 -1
  39. package/dist/core/durable-projection.d.ts +1 -1
  40. package/dist/core/durable-runs/continuation.d.ts +1 -1
  41. package/dist/core/durable-runs/ledger-contracts.d.ts +4 -1
  42. package/dist/core/durable-runs/ports.d.ts +2 -1
  43. package/dist/core/durable-runs/run-contracts.d.ts +1 -1
  44. package/dist/core/durable-runs/run-finalizer.d.ts +145 -0
  45. package/dist/core/durable-runs/run-finalizer.js +171 -0
  46. package/dist/core/events.d.ts +4 -82
  47. package/dist/core/events.js +2 -1
  48. package/dist/core/index.d.ts +4 -1
  49. package/dist/core/index.js +2 -1
  50. package/dist/core/messages.d.ts +1 -1
  51. package/dist/core/persistence/index.d.ts +1 -1
  52. package/dist/core/persistence/index.js +1 -1
  53. package/dist/core/question-form/normalize.d.ts +9 -3
  54. package/dist/core/question-form/normalize.js +20 -20
  55. package/dist/core/question-form/scan.js +15 -19
  56. package/dist/core/run-activity.d.ts +1 -1
  57. package/dist/core/run-events/entry.d.ts +11 -63
  58. package/dist/core/run-events/entry.js +12 -7
  59. package/dist/core/todos.d.ts +1 -1
  60. package/dist/core/todos.js +8 -0
  61. package/dist/core/tool-call-detail.d.ts +8 -1
  62. package/dist/core/tool-call-detail.js +35 -12
  63. package/dist/core/tool-events.d.ts +1 -1
  64. package/dist/core/tool-output.js +2 -6
  65. package/dist/core/tools.d.ts +2 -1
  66. package/dist/core/transport.d.ts +1 -1
  67. package/dist/core/turn-usage.d.ts +1 -1
  68. package/dist/core/util/parser.js +70 -69
  69. package/dist/embed-widget/browser/embed-send-bridge.d.ts +44 -0
  70. package/dist/embed-widget/browser/embed-send-bridge.js +60 -0
  71. package/dist/embed-widget/browser/frontend-invocation-handler.d.ts +39 -0
  72. package/dist/embed-widget/browser/frontend-invocation-handler.js +151 -0
  73. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +28 -0
  74. package/dist/embed-widget/browser/frontend-session-bridge.js +201 -257
  75. package/dist/embed-widget/browser/lazy-loader.js +16 -12
  76. package/dist/embed-widget/browser/session-store.d.ts +19 -1
  77. package/dist/embed-widget/browser/session-store.js +48 -17
  78. package/dist/embed-widget/transports/fetch-sse.d.ts +1 -1
  79. package/dist/embed-widget/vanilla/index.js +131 -67
  80. package/dist/embed-widget/vanilla/state.js +53 -38
  81. package/dist/react/admin-execution/ai-agent-presentation.d.ts +35 -0
  82. package/dist/react/admin-execution/ai-agent-presentation.js +39 -0
  83. package/dist/react/admin-execution/hooks/use-ai-agent-presentation.hooks.d.ts +22 -0
  84. package/dist/react/admin-execution/hooks/use-ai-agent-presentation.hooks.js +25 -0
  85. package/dist/react/chat-cleanup/ChatCleanupPanel.d.ts +32 -0
  86. package/dist/react/chat-cleanup/ChatCleanupPanel.js +34 -0
  87. package/dist/react/chat-cleanup/chat-cleanup.hooks.d.ts +174 -0
  88. package/dist/react/chat-cleanup/chat-cleanup.hooks.js +83 -0
  89. package/dist/react/components/ChatCleanupDialog.d.ts +38 -0
  90. package/dist/react/components/ChatCleanupDialog.js +15 -0
  91. package/dist/react/components/ChatSettingsDialog.d.ts +3 -0
  92. package/dist/react/components/ChatSettingsDialog.js +3 -3
  93. package/dist/react/components/ConversationList.d.ts +19 -5
  94. package/dist/react/components/ConversationList.hooks.d.ts +1 -0
  95. package/dist/react/components/ConversationList.hooks.js +4 -2
  96. package/dist/react/components/ConversationList.js +66 -9
  97. package/dist/react/components/Icon.d.ts +1 -1
  98. package/dist/react/components/Icon.js +7 -0
  99. package/dist/react/components/Markdown.js +6 -6
  100. package/dist/react/components/MarkdownLink.d.ts +25 -0
  101. package/dist/react/components/MarkdownLink.js +17 -0
  102. package/dist/react/components/RoutedA2uiSurfaceCard.d.ts +80 -0
  103. package/dist/react/components/RoutedA2uiSurfaceCard.js +15 -0
  104. package/dist/react/components/ToolCard.d.ts +4 -2
  105. package/dist/react/components/ToolCard.js +46 -4
  106. package/dist/react/components/ToolCard.rules.d.ts +5 -2
  107. package/dist/react/components/ToolCard.rules.js +12 -5
  108. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  109. package/dist/react/components/mcp-ui-surface-state.d.ts +3 -1
  110. package/dist/react/components/mcp-ui-surface-state.js +2 -2
  111. package/dist/react/components/own-link.d.ts +26 -0
  112. package/dist/react/components/own-link.js +36 -0
  113. package/dist/react/features/bridged-chat/create-staged-attachment-uploader.d.ts +7 -0
  114. package/dist/react/features/bridged-chat/create-staged-attachment-uploader.js +26 -0
  115. package/dist/react/features/bridged-chat/hooks/useBridgedChatTransport.hooks.d.ts +12 -0
  116. package/dist/react/features/bridged-chat/hooks/useBridgedChatTransport.hooks.js +60 -0
  117. package/dist/react/features/bridged-chat/index.d.ts +8 -0
  118. package/dist/react/features/bridged-chat/index.js +7 -0
  119. package/dist/react/features/bridged-chat/types.d.ts +49 -0
  120. package/dist/react/features/bridged-chat/types.js +2 -0
  121. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +1 -1
  122. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts +6 -0
  123. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js +101 -59
  124. package/dist/react/features/chat-pane/hooks/useChatPaneNewTabLinks.hooks.d.ts +3 -0
  125. package/dist/react/features/chat-pane/hooks/useChatPaneNewTabLinks.hooks.js +26 -16
  126. package/dist/react/features/chat-pane/model-options.d.ts +3 -1
  127. package/dist/react/features/chat-pane/model-options.js +3 -3
  128. package/dist/react/features/chat-pane/rules.js +4 -3
  129. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  130. package/dist/react/features/chat-pane/styles.js +16 -0
  131. package/dist/react/features/conversation-chat-pane/components/ConversationChatPane.d.ts +10 -0
  132. package/dist/react/features/conversation-chat-pane/components/ConversationChatPane.js +19 -0
  133. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneChat.d.ts +12 -0
  134. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneChat.js +21 -0
  135. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneHeader.d.ts +13 -0
  136. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneHeader.js +9 -0
  137. package/dist/react/features/conversation-chat-pane/components/ConversationDeleteConfirm.d.ts +12 -0
  138. package/dist/react/features/conversation-chat-pane/components/ConversationDeleteConfirm.js +12 -0
  139. package/dist/react/features/conversation-chat-pane/hooks/useConversationChatPane.hooks.d.ts +7 -0
  140. package/dist/react/features/conversation-chat-pane/hooks/useConversationChatPane.hooks.js +43 -0
  141. package/dist/react/features/conversation-chat-pane/index.d.ts +9 -0
  142. package/dist/react/features/conversation-chat-pane/index.js +8 -0
  143. package/dist/react/features/conversation-chat-pane/rules.d.ts +25 -0
  144. package/dist/react/features/conversation-chat-pane/rules.js +29 -0
  145. package/dist/react/features/conversation-chat-pane/types.d.ts +139 -0
  146. package/dist/react/features/conversation-chat-pane/types.js +2 -0
  147. package/dist/react/features/conversations/conversation-controller.d.ts +16 -0
  148. package/dist/react/features/conversations/conversation-controller.js +280 -0
  149. package/dist/react/features/conversations/hooks/useConversationDeleteConfirmation.hooks.d.ts +15 -0
  150. package/dist/react/features/conversations/hooks/useConversationDeleteConfirmation.hooks.js +33 -0
  151. package/dist/react/features/conversations/hooks/useStoredConversations.hooks.d.ts +16 -0
  152. package/dist/react/features/conversations/hooks/useStoredConversations.hooks.js +36 -0
  153. package/dist/react/features/conversations/index.d.ts +9 -0
  154. package/dist/react/features/conversations/index.js +8 -0
  155. package/dist/react/features/conversations/types.d.ts +120 -0
  156. package/dist/react/features/conversations/types.js +2 -0
  157. package/dist/react/features/voice-input/space-hold-rules.d.ts +65 -0
  158. package/dist/react/features/voice-input/space-hold-rules.js +48 -0
  159. package/dist/react/hooks/testing/fake-transport.d.ts +1 -1
  160. package/dist/react/hooks/useAnsweredCards.d.ts +2 -1
  161. package/dist/react/hooks/useConversation.js +5 -2
  162. package/dist/react/hooks/useExtEventGroups.d.ts +1 -1
  163. package/dist/react/hooks/useRunActivity.d.ts +2 -1
  164. package/dist/react/hooks/useRunStream.d.ts +1 -1
  165. package/dist/react/hooks/useRunStream.js +1 -1
  166. package/dist/react/hooks/useSurfaceRecovery.js +3 -1
  167. package/dist/react/hooks/useToolTimeline.d.ts +2 -1
  168. package/dist/react/index.d.ts +5 -2
  169. package/dist/react/index.js +4 -2
  170. package/dist/react/message-blocks.d.ts +1 -48
  171. package/dist/react/message-blocks.js +47 -0
  172. package/dist/react/styles/chat-settings.css +42 -14
  173. package/dist/server/chat-cleanup-routes.d.ts +56 -0
  174. package/dist/server/chat-cleanup-routes.js +56 -0
  175. package/dist/server/durable-runs/recover.js +193 -171
  176. package/dist/server/run-finalizer/entry.js +133 -110
  177. package/dist/store/legacy/sqlite/conversations.js +29 -17
  178. package/dist/store/pglite/index.d.ts +1 -0
  179. package/dist/store/pglite/index.js +1 -0
  180. package/dist/store/ports.d.ts +12 -0
  181. package/dist/store/postgres/index.d.ts +1 -0
  182. package/dist/store/postgres/index.js +1 -0
  183. package/dist/store/runtime/attempt-base-retention.d.ts +57 -0
  184. package/dist/store/runtime/attempt-base-retention.js +103 -0
  185. package/dist/store/runtime/chat-maintenance.d.ts +16 -0
  186. package/dist/store/runtime/chat-maintenance.js +19 -0
  187. package/dist/store/runtime/chat-principal.d.ts +63 -0
  188. package/dist/store/runtime/chat-principal.js +39 -0
  189. package/dist/store/runtime/checkpoint-delta.d.ts +1 -1
  190. package/dist/store/runtime/durable-run-queries.d.ts +124 -0
  191. package/dist/store/runtime/durable-run-queries.js +122 -0
  192. package/dist/store/runtime/durable-run-store.d.ts +1 -1
  193. package/dist/store/runtime/durable-run-store.js +291 -343
  194. package/dist/store/runtime/entry.d.ts +3 -0
  195. package/dist/store/runtime/entry.js +3 -0
  196. package/dist/store/runtime/events-json.d.ts +1 -1
  197. package/dist/store/runtime/lazy-run-ledger.d.ts +19 -0
  198. package/dist/store/runtime/lazy-run-ledger.js +28 -0
  199. package/dist/store/runtime/run-ledger.d.ts +4 -1
  200. package/dist/store/runtime/run-ledger.js +256 -204
  201. package/dist/store/sql/bulk-deletion.d.ts +36 -0
  202. package/dist/store/sql/bulk-deletion.js +103 -0
  203. package/dist/store/sql/store-queries.d.ts +170 -0
  204. package/dist/store/sql/store-queries.js +212 -0
  205. package/dist/store/sql/store-rows.d.ts +106 -0
  206. package/dist/store/sql/store-rows.js +116 -0
  207. package/dist/store/sql/store-writes.d.ts +46 -0
  208. package/dist/store/sql/store-writes.js +161 -0
  209. package/dist/store/sql/store.d.ts +3 -16
  210. package/dist/store/sql/store.js +58 -428
  211. package/dist/store/sql/tables.d.ts +1 -0
  212. package/dist/store/sqlite/index.d.ts +1 -0
  213. package/dist/store/sqlite/index.js +1 -0
  214. package/dist/store/sqlite/schema.d.ts +1 -1
  215. package/dist/store/sqlite/schema.js +5 -1
  216. package/package.json +171 -20
@@ -6,7 +6,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
6
6
  * into `ChatPane`'s `leadingAccessory` slot — it needs no changes to `ChatPane` itself.
7
7
  *
8
8
  * Storage-agnostic by construction. It takes data and callbacks and owns nothing durable, so a
9
- * host backs it with `@jini-ai/sqlite-chat`'s `ChatHistoryStore`, an HTTP endpoint, or an in-memory
9
+ * host backs it with `@jini-ai/chat/store/sqlite`'s `ChatHistoryStore`, an HTTP endpoint, or an in-memory
10
10
  * array without this file knowing the difference.
11
11
  *
12
12
  * Search is a **client-side filter by default**, and delegates to `onSearch` when a host provides
@@ -39,20 +39,77 @@ function relativeTime(updatedAt, now) {
39
39
  return `${hours}h ago`;
40
40
  return `${Math.round(hours / 24)}d ago`;
41
41
  }
42
- /** Only the host-supported actions are rendered; row selection remains independent. */
42
+ /**
43
+ * The row's pin toggle: an icon button like rename and delete, outline while unpinned and filled once
44
+ * pinned. It was a bare text button ("Pin" / "Unpin"), which the admin's global button styles painted
45
+ * as a full-size filled accent button on every row (owner, 2026-11-29). The visible tooltip is the
46
+ * short verb; the accessible name keeps the chat's title so a screen reader knows which row it pins.
47
+ */
48
+ function PinButton({ item, t, onTogglePin }) {
49
+ const verb = t(item.pinned ? 'Unpin' : 'Pin');
50
+ return _jsx("button", { type: "button", className: item.pinned ? 'jini-conv-item-pin jini-conv-item-pin--pinned' : 'jini-conv-item-pin', "aria-label": `${verb} ${item.title ?? t('Untitled')}`, title: verb, "data-testid": `conversation-pin-${item.id}`, onClick: () => onTogglePin({ id: item.id, pinned: !item.pinned }), children: _jsx(Icon, { name: "pin", size: 12, fill: item.pinned ? 'currentColor' : 'none' }) });
51
+ }
52
+ /** Only the host-supported actions are rendered; row selection remains independent. Icon-only, so
53
+ * each carries a hover tooltip naming what it does. */
43
54
  function ConversationActions({ itemId, editing, canRename, canDelete, onRename, onDelete, t }) {
44
- return _jsxs(_Fragment, { children: [canRename && !editing ? _jsx("button", { type: "button", className: "jini-conv-item-rename", "aria-label": t('Rename chat'), "data-testid": `conversation-rename-button-${itemId}`, onClick: onRename, children: _jsx(Icon, { name: "pencil", size: 12 }) }) : null, canDelete ? _jsx("button", { type: "button", className: "jini-conv-item-delete", "aria-label": t('Delete conversation'), "data-testid": `conversation-delete-${itemId}`, onClick: (event) => {
55
+ return _jsxs(_Fragment, { children: [canRename && !editing ? _jsx("button", { type: "button", className: "jini-conv-item-rename", "aria-label": t('Rename chat'), title: t('Rename chat'), "data-testid": `conversation-rename-button-${itemId}`, onClick: onRename, children: _jsx(Icon, { name: "pencil", size: 12 }) }) : null, canDelete ? _jsx("button", { type: "button", className: "jini-conv-item-delete", "aria-label": t('Delete conversation'), title: t('Delete conversation'), "data-testid": `conversation-delete-${itemId}`, onClick: (event) => {
45
56
  event.stopPropagation();
46
57
  onDelete();
47
58
  }, children: _jsx(Icon, { name: "close", size: 12 }) }) : null] });
48
59
  }
49
- /** Hooks ConversationList calls; defaults to the real ones, a test hands in fakes. */
60
+ /** Hooks ConversationList calls; the host passes the real ones or a test hands in fakes. */
50
61
  export const defaultConversationListHooks = { useT, useConversationListView };
51
- export function ConversationList({ conversations: savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, createDisabled = false, emptyState, triggerLabel, nativeTitle = true, hooks = defaultConversationListHooks, report, }) {
62
+ /** The selection after a click on `itemId`: shift-click extends from the anchor, otherwise it toggles. */
63
+ function nextSelection({ selectedIds, visible, anchorId, itemId, shiftKey }) {
64
+ const selected = new Set(selectedIds);
65
+ const anchor = visible.findIndex(row => row.id === anchorId);
66
+ const target = visible.findIndex(row => row.id === itemId);
67
+ if (shiftKey && anchor !== -1) {
68
+ for (const row of visible.slice(Math.min(anchor, target), Math.max(anchor, target) + 1))
69
+ selected.add(row.id);
70
+ }
71
+ else if (selected.has(itemId))
72
+ selected.delete(itemId);
73
+ else
74
+ selected.add(itemId);
75
+ return selected;
76
+ }
77
+ function SelectCheckbox({ item, view, t, selectedIds, onSelectionChange }) {
78
+ const { visible, selectionAnchor } = view;
79
+ return _jsx("button", { type: "button", role: "checkbox", className: "jini-conv-item-check", "aria-checked": selectedIds?.includes(item.id) ?? false, "aria-label": `${t('Select')} ${item.title ?? t('Untitled')}`, onClick: event => {
80
+ // Optimistic state belongs to the host, which also owns persistence and rejection handling.
81
+ const selected = nextSelection({ selectedIds, visible, anchorId: selectionAnchor.current, itemId: item.id, shiftKey: event.shiftKey });
82
+ selectionAnchor.current = item.id;
83
+ onSelectionChange?.({ ids: [...selected] });
84
+ } });
85
+ }
86
+ function ConversationItemBody({ item, view, t, onRename }) {
87
+ const { rawTitles, editingId, setEditingId, commitRename, startRename, scheduleSelect, now } = view;
88
+ if (onRename && editingId === item.id) {
89
+ return (_jsx(ConversationTitleEditor, { title: rawTitles.get(item.id) ?? null, "data-testid": `conversation-rename-${item.id}`, onCommit: (next) => commitRename(item.id, next), onCancel: () => setEditingId(null) }));
90
+ }
91
+ return (_jsxs("button", { type: "button", className: "jini-conv-item-select", "data-testid": `conversation-select-${item.id}`, title: onRename ? t('Double-click to rename') : undefined, onClick: () => scheduleSelect(item.id), onDoubleClick: onRename ? () => startRename(item.id) : undefined, children: [_jsx("span", { className: "jini-conv-item-title", children: item.title ?? t('Untitled') }), _jsxs("span", { className: "jini-conv-item-meta", children: [item.messageCount === undefined ? '' : `${item.messageCount} msg · `, relativeTime(item.updatedAt, now)] })] }));
92
+ }
93
+ function ConversationRow({ item, view, t, activeConversationId, selectable, selectedIds, onSelectionChange, onTogglePin, onRename, onDelete }) {
94
+ const { editingId, startRename, requestDelete } = view;
95
+ return (_jsxs("div", { className: `jini-conv-item${item.id === activeConversationId ? ' jini-conv-item-active' : ''}`, "data-testid": `conversation-item-${item.id}`, children: [selectable ? _jsx(SelectCheckbox, { item: item, view: view, t: t, selectedIds: selectedIds, onSelectionChange: onSelectionChange }) : null, _jsx(ConversationItemBody, { item: item, view: view, t: t, onRename: onRename }), onTogglePin ? _jsx(PinButton, { item: item, t: t, onTogglePin: onTogglePin }) : null, _jsx(ConversationActions, { itemId: item.id, editing: editingId === item.id, canRename: Boolean(onRename), canDelete: Boolean(onDelete), onRename: () => startRename(item.id), onDelete: () => requestDelete(item), t: t })] }));
96
+ }
97
+ /** The open menu's heading with its count and "New", then the search field. */
98
+ function ConversationMenuHead({ view, t, createDisabled }) {
99
+ const { query, setQuery, conversations, createConversation } = view;
100
+ return _jsxs(_Fragment, { children: [_jsxs("div", { className: "jini-conv-head", children: [_jsxs("span", { className: "jini-conv-heading", children: [t('Conversations'), _jsx("span", { className: "jini-conv-count", "data-testid": "conversation-count", children: conversations.length })] }), _jsxs("button", { type: "button", className: "jini-conv-new", disabled: createDisabled, "data-testid": "conversation-new",
101
+ // `disabled` alone guards this: a disabled button never dispatches a click.
102
+ onClick: createConversation, children: [_jsx(Icon, { name: "plus", size: 12 }), _jsx("span", { children: t('New') })] })] }), _jsxs("label", { className: "jini-conv-search", children: [_jsx(Icon, { name: "search", size: 13 }), _jsx("input", { type: "search", value: query, placeholder: t('Search conversations'), "data-testid": "conversation-search", onChange: (event) => setQuery(event.currentTarget.value) })] })] });
103
+ }
104
+ /** The menu's scrolling rows (or its empty line), then the host's selection actions while ticking. */
105
+ function ConversationRows({ view, t, selectionActions, ...rowProps }) {
106
+ const { conversations, visible, emptyLabel } = view;
107
+ return _jsxs(_Fragment, { children: [_jsx("div", { className: "jini-conv-list", "data-testid": "conversation-list", children: conversations.length === 0 || visible.length === 0 ? (_jsx("div", { className: "jini-conv-empty", children: emptyLabel() })) : (visible.map((item) => _jsx(ConversationRow, { item: item, view: view, t: t, ...rowProps }, item.id))) }), rowProps.selectable && selectionActions ? (_jsx("div", { className: "jini-conv-selection-actions", "data-testid": "conversation-selection-actions", children: selectionActions })) : null] });
108
+ }
109
+ export function ConversationList({ conversations: savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, createDisabled = false, emptyState, triggerLabel, nativeTitle = true, hooks, report, selectable, selectedIds, onTogglePin, onSelectionChange, selectionActions, }, _optional = {}) {
52
110
  const t = hooks.useT();
53
- const { open, setOpen, query, setQuery, conversations, rawTitles, editingId, setEditingId, rootRef, visible, now, commitRename, startRename, requestDelete, active, emptyLabel, scheduleSelect, createConversation } = hooks.useConversationListView({ savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, emptyState, t }, { report });
54
- return (_jsxs("div", { className: "jini-conv", ref: rootRef, children: [_jsx("button", { type: "button", className: `jini-conv-trigger${open ? ' jini-conv-trigger-open' : ''}`, "aria-haspopup": "menu", "aria-expanded": open, ...conversationTriggerAttributes({ activeTitle: active?.title, t }, { label: triggerLabel, nativeTitle }), "data-testid": "conversation-trigger", onClick: () => setOpen((v) => !v), children: _jsx(Icon, { name: "comment", size: 16 }) }), open ? (_jsxs("div", { className: "jini-conv-menu", role: "menu", "data-testid": "conversation-menu", children: [_jsxs("div", { className: "jini-conv-head", children: [_jsxs("span", { className: "jini-conv-heading", children: [t('Conversations'), _jsx("span", { className: "jini-conv-count", "data-testid": "conversation-count", children: conversations.length })] }), _jsxs("button", { type: "button", className: "jini-conv-new", disabled: createDisabled, "data-testid": "conversation-new",
55
- // `disabled` alone guards this: a disabled button never dispatches a click.
56
- onClick: createConversation, children: [_jsx(Icon, { name: "plus", size: 12 }), _jsx("span", { children: t('New') })] })] }), _jsxs("label", { className: "jini-conv-search", children: [_jsx(Icon, { name: "search", size: 13 }), _jsx("input", { type: "search", value: query, placeholder: t('Search conversations'), "data-testid": "conversation-search", onChange: (event) => setQuery(event.currentTarget.value) })] }), _jsx("div", { className: "jini-conv-list", "data-testid": "conversation-list", children: conversations.length === 0 || visible.length === 0 ? (_jsx("div", { className: "jini-conv-empty", children: emptyLabel() })) : (visible.map((item) => (_jsxs("div", { className: `jini-conv-item${item.id === activeConversationId ? ' jini-conv-item-active' : ''}`, "data-testid": `conversation-item-${item.id}`, children: [onRename && editingId === item.id ? (_jsx(ConversationTitleEditor, { title: rawTitles.get(item.id) ?? null, "data-testid": `conversation-rename-${item.id}`, onCommit: (next) => commitRename(item.id, next), onCancel: () => setEditingId(null) })) : (_jsxs("button", { type: "button", className: "jini-conv-item-select", "data-testid": `conversation-select-${item.id}`, title: onRename ? t('Double-click to rename') : undefined, onClick: () => scheduleSelect(item.id), onDoubleClick: onRename ? () => startRename(item.id) : undefined, children: [_jsx("span", { className: "jini-conv-item-title", children: item.title ?? t('Untitled') }), _jsxs("span", { className: "jini-conv-item-meta", children: [item.messageCount === undefined ? '' : `${item.messageCount} msg · `, relativeTime(item.updatedAt, now)] })] })), _jsx(ConversationActions, { itemId: item.id, editing: editingId === item.id, canRename: Boolean(onRename), canDelete: Boolean(onDelete), onRename: () => startRename(item.id), onDelete: () => requestDelete(item), t: t })] }, item.id)))) })] })) : null] }));
111
+ const view = hooks.useConversationListView({ savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, emptyState, t }, { report });
112
+ const { open, setOpen, active, rootRef } = view;
113
+ return (_jsxs("div", { className: "jini-conv", ref: rootRef, children: [_jsx("button", { type: "button", className: `jini-conv-trigger${open ? ' jini-conv-trigger-open' : ''}`, "aria-haspopup": "menu", "aria-expanded": open, ...conversationTriggerAttributes({ activeTitle: active?.title, t }, { label: triggerLabel, nativeTitle }), "data-testid": "conversation-trigger", onClick: () => setOpen((v) => !v), children: _jsx(Icon, { name: "comment", size: 16 }) }), open ? (_jsxs("div", { className: "jini-conv-menu", role: "menu", "data-testid": "conversation-menu", children: [_jsx(ConversationMenuHead, { view: view, t: t, createDisabled: createDisabled }), _jsx(ConversationRows, { view: view, t: t, activeConversationId: activeConversationId, selectable: selectable, selectedIds: selectedIds, onSelectionChange: onSelectionChange, onTogglePin: onTogglePin, onRename: onRename, onDelete: onDelete, selectionActions: selectionActions })] })) : null] }));
57
114
  }
58
115
  //# sourceMappingURL=ConversationList.js.map
@@ -7,7 +7,7 @@
7
7
  * AgentIcon and WorkingDirPicker.
8
8
  */
9
9
  import type { SVGProps } from 'react';
10
- export type IconName = 'spinner' | 'check' | 'close' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'attach' | 'folder' | 'file' | 'image' | 'x' | 'comment' | 'search' | 'plus' | 'pencil' | 'copy' | 'retry';
10
+ export type IconName = 'spinner' | 'check' | 'close' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'attach' | 'folder' | 'file' | 'image' | 'x' | 'comment' | 'search' | 'plus' | 'pencil' | 'copy' | 'external-link' | 'retry' | 'pin' | 'broom';
11
11
  interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'name'> {
12
12
  name: IconName;
13
13
  size?: number | string;
@@ -21,6 +21,13 @@ const ICON_GLYPHS = {
21
21
  pencil: _jsxs(_Fragment, { children: [_jsx("path", { d: "m16 3 5 5L8 21H3v-5L16 3Z" }), _jsx("path", { d: "m14 5 5 5" })] }),
22
22
  /** Per-message copy affordance (MessageRow.tsx). Two overlapping squares -- the conventional copy glyph. */
23
23
  copy: _jsxs(_Fragment, { children: [_jsx("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" }), _jsx("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })] }),
24
+ /** The small "open in new tab" arrow after a link to the owner's own site or admin (MarkdownLink.tsx). */
25
+ 'external-link': _jsxs(_Fragment, { children: [_jsx("path", { d: "M7 17 17 7" }), _jsx("path", { d: "M8 7h9v9" })] }),
26
+ /** A conversation row's pin toggle (ConversationList.tsx). Drawn as one closed head so a caller's
27
+ * `fill="currentColor"` turns the outline (unpinned) into the solid pin (pinned) with no second glyph. */
28
+ pin: _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 17v5" }), _jsx("path", { d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z" })] }),
29
+ /** "Clean up chats" in the chat settings (ChatCleanupPanel.tsx): a broom reads as tidying, not deleting. */
30
+ broom: _jsxs(_Fragment, { children: [_jsx("path", { d: "m16 22-1-4" }), _jsx("path", { d: "M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1" }), _jsx("path", { d: "M5 14h14l1.97 6.77A1 1 0 0 1 20 22H4a1 1 0 0 1-.97-1.23z" }), _jsx("path", { d: "m8 22 1-4" })] }),
24
31
  };
25
32
  export function Icon({ name, size = 14, strokeWidth = 1.6, ...rest }) {
26
33
  // The spinner alone puts its spin class in front of any caller-supplied one.
@@ -42,6 +42,7 @@ import { Fragment, useEffect, useRef, useState } from 'react';
42
42
  import { useCopyToClipboard } from '../hooks/useCopyToClipboard.js';
43
43
  import { useT } from '../hooks/context.js';
44
44
  import { Icon } from './Icon.js';
45
+ import { MarkdownLink } from './MarkdownLink.js';
45
46
  export function Markdown({ children }) {
46
47
  const blocks = parseBlocks(children);
47
48
  return (_jsx(_Fragment, { children: blocks.map((block, i) => (_jsx(Fragment, { children: renderBlock(block) }, i))) }));
@@ -418,16 +419,15 @@ const INLINE_RE = new RegExp(String.raw `(\x60[^\x60]+\x60)|(${MD_LINK})|(\*\*[^
418
419
  // Only these targets become anchors; anything else (`javascript:`, `data:`, protocol-relative
419
420
  // `//host`) stays literal text, since the text is untrusted model output.
420
421
  export const SAFE_LINK_HREF = /^(?:https?:\/\/|mailto:|\/(?!\/)|#)/iu;
421
- // Every link opens in a new tab — an in-app path too, so following one never navigates the tab the
422
- // chat lives in (owner 2026-10-08). Only a `#` same-document anchor stays in place. ChatPane's
423
- // click guard (`useChatPaneNewTabLinks`) covers links this renderer does not draw.
424
- const NEW_TAB = { target: '_blank', rel: 'noopener noreferrer' };
422
+ // Own-or-other link handling (and the new-tab icon after an own link) lives in `MarkdownLink`: owner
423
+ // decision 2026-11-21, reversing 2026-10-08's "every link opens a new tab". ChatPane's click guard
424
+ // (`useChatPaneNewTabLinks`) applies the same split to links this renderer does not draw.
425
425
  function renderMarkdownLink(source, key) {
426
426
  // `MD_LINK` already matched `source`, so these two groups always capture.
427
427
  const [, label, href] = MD_LINK_PARTS.exec(source);
428
428
  if (!SAFE_LINK_HREF.test(href))
429
429
  return source;
430
- return (_jsx("a", { href: href, ...(href.startsWith('#') ? {} : NEW_TAB), children: renderInline(label) }, key));
430
+ return _jsx(MarkdownLink, { href: href, children: renderInline(label) }, key);
431
431
  }
432
432
  function renderInline(text) {
433
433
  const nodes = [];
@@ -464,7 +464,7 @@ function renderInlineToken({ match, key }) {
464
464
  if (italic)
465
465
  return _jsx("em", { children: renderInline(italic.slice(1, -1)) }, key);
466
466
  if (link)
467
- return _jsx("a", { href: link, ...NEW_TAB, children: link }, key);
467
+ return _jsx(MarkdownLink, { href: link, children: link }, key);
468
468
  return null;
469
469
  }
470
470
  //# sourceMappingURL=Markdown.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @module MarkdownLink
3
+ *
4
+ * The one anchor the chat's markdown draws for a link, so a `[label](url)` and a bare autolink
5
+ * cannot drift apart. Owner decision 2026-11-21, reversing 2026-10-08 (when every chat link opened a
6
+ * new tab so the chat and the page under it were never navigated away from):
7
+ * - a link to the owner's own site or admin navigates the current tab from its text (the admin's
8
+ * own link handler turns an admin path into an in-app navigation, so the chat dock stays), with a
9
+ * small icon right after it that opens a new tab instead;
10
+ * - a link to any other website opens a new tab, with no icon (it already does);
11
+ * - a same-document `#anchor` stays in place, with no icon.
12
+ * `ChatPane`'s click guard (`useChatPaneNewTabLinks`) applies the same own-or-other split to links
13
+ * this renderer does not draw.
14
+ */
15
+ import type { ReactNode } from 'react';
16
+ import { useT } from '../hooks/context.js';
17
+ export interface MarkdownLinkProps {
18
+ readonly href: string;
19
+ readonly children: ReactNode;
20
+ /** The origin that counts as the owner's own; defaults to the page's own origin. */
21
+ readonly origin?: string;
22
+ readonly useTHook?: typeof useT;
23
+ }
24
+ export declare function MarkdownLink({ href, children, origin, useTHook }: MarkdownLinkProps): import("react").JSX.Element;
25
+ //# sourceMappingURL=MarkdownLink.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useT } from '../hooks/context.js';
3
+ import { Icon } from './Icon.js';
4
+ import { currentOrigin, isOwnLinkHref } from './own-link.js';
5
+ const NEW_TAB = { target: '_blank', rel: 'noopener noreferrer' };
6
+ /** The icon's label, also its tooltip: it is the only text the icon has. */
7
+ const OPEN_IN_NEW_TAB = 'Open in new tab';
8
+ export function MarkdownLink({ href, children, origin = currentOrigin(), useTHook = useT }) {
9
+ const t = useTHook();
10
+ if (href.startsWith('#'))
11
+ return _jsx("a", { href: href, children: children });
12
+ if (!isOwnLinkHref({ href, origin }))
13
+ return _jsx("a", { href: href, ...NEW_TAB, children: children });
14
+ const label = t(OPEN_IN_NEW_TAB);
15
+ return (_jsxs(_Fragment, { children: [_jsx("a", { href: href, children: children }), _jsx("a", { className: "jini-md-link-newtab", href: href, ...NEW_TAB, "aria-label": label, title: label, children: _jsx(Icon, { name: "external-link", size: 11 }) })] }));
16
+ }
17
+ //# sourceMappingURL=MarkdownLink.js.map
@@ -0,0 +1,80 @@
1
+ import type { ComponentType } from "react";
2
+ import type { AdminChartProviderSnapshot } from "@jini-ai/core/contracts/headless/chart-providers";
3
+ import type { A2uiSurfaceCardProps } from "./A2uiSurfaceCard.js";
4
+ /**
5
+ * @file Makes `A2uiSurfaceCard` page-aware without touching the card itself, Jini's ext-event
6
+ * registry, or the daemon/tool that emits the a2ui events in the first place (`render-ui-tool.ts`
7
+ * already sends everything needed — this is purely about where the browser puts it).
8
+ *
9
+ * `hooks/use-dock-renderer-registry.hooks.ts` registers this component (not `A2uiSurfaceCard`
10
+ * directly) under `a2ui` in the dock's owned registry. `@jini-ai/chat/react`'s `MessageRow` calls the
11
+ * registered renderer as `renderer(props)` and treats the return value as a `ReactNode` — but the
12
+ * registration itself returns a React element via `createElement`, so
13
+ * React evaluates this component as a real element during its own reconciliation, not as a plain
14
+ * function call. That is what makes hooks safe to use from here — both `useRoutedA2uiSurfaceCard`
15
+ * below and, transitively, everything it calls — the same way it is already safe inside
16
+ * `A2uiSurfaceCard` itself.
17
+ *
18
+ * Routing target, dismiss state, and per-surfaceId error tracking live in
19
+ * `hooks/use-routed-a2ui-surface-card.hooks.ts`, split out the same way `SeeMore`/`SeeMore.hooks.tsx`
20
+ * does: that file owns the state, this one stays props-and-JSX only. (It sits in a `hooks/`
21
+ * subfolder rather than a sibling file — see that file's own doc for why, and for why it has no
22
+ * `*Port`/`useWiredX` pair despite that being this workspace's dominant hook shape elsewhere.)
23
+ *
24
+ * ## The routing decision
25
+ *
26
+ * `useRoutedA2uiSurfaceCard` reads `playground-render-target-bus.ts`'s registered node (set only by
27
+ * `features/playground/Playground.tsx`, on mount/unmount) as `target`:
28
+ *
29
+ * - **No target registered** (Playground is not the active page, or hasn't mounted its canvas
30
+ * yet): falls back to the exact pre-existing behavior — `<A2uiSurfaceCard>` renders inline,
31
+ * wherever this ext-event group lands in the transcript.
32
+ * - **Target registered**: `ReactDOM.createPortal`s the exact same `<A2uiSurfaceCard>` element
33
+ * into Playground's own DOM container instead. The card's own internals (interpreter, local
34
+ * action handling, `onAgentAction` wiring) are unchanged either way — only the DOM location
35
+ * differs. Multiple asks stack in that container in mount order (oldest first, matching normal
36
+ * reading order) — see `playground.css`'s `.playground-render-target` for the flex/gap layout
37
+ * that makes that look intentional rather than accidental.
38
+ *
39
+ * ## Dismissing a drawn surface
40
+ *
41
+ * Portaled surfaces get a small "×" so the canvas doesn't just accumulate forever. Only offered
42
+ * when portaled: the chat transcript is a history, not a scratch surface, so inline cards (no
43
+ * target registered) never get a dismiss control. (See the hooks file for why `dismissed` is local
44
+ * state rather than written back to the render-target bus.)
45
+ *
46
+ * ## A refusal never portals, even with a target registered — but only for AS LONG AS it's live
47
+ *
48
+ * A catalog-validation refusal is diagnostic chat output ("this failed, here's why"), not a real
49
+ * drawn artifact — putting it on Playground's canvas would make the whiteboard look broken instead
50
+ * of the request that actually failed. `hasError`, computed by the hook, tracks the CURRENT surface
51
+ * only, not "has this card ever seen an error" — see `hooks/use-routed-a2ui-surface-card.hooks.ts`
52
+ * for the full reasoning and the regression a sticky flag caused (a genuinely successful retry never
53
+ * reaching the canvas), which is why this file just reads `hasError` rather than deriving it itself.
54
+ */
55
+ export interface RoutedA2uiSurfaceCardProps extends A2uiSurfaceCardProps {
56
+ SurfaceCard: ComponentType<A2uiSurfaceCardProps>;
57
+ useTHook: () => (key: string) => string;
58
+ /** `generation` is the server's chart-provider generation (core's {@link AdminChartProviderSnapshot}); it keys the card so a new catalog remounts the interpreter. */
59
+ useChartRegistryHook: () => {
60
+ registry: NonNullable<A2uiSurfaceCardProps["registry"]>;
61
+ generation: AdminChartProviderSnapshot["generation"];
62
+ stylesheets: readonly string[];
63
+ };
64
+ /** Required seam for the routing/dismiss/error-tracking hook (the host binds its real
65
+ * `useRoutedA2uiSurfaceCard`); a test can pass a fake here to exercise this component's
66
+ * rendering (inline vs. portal, the dismiss control, refusal handling) without driving the real
67
+ * `playground-render-target-bus` subscription or the hook's own local state. Destructured off
68
+ * separately from `...props` below so it is never spread through to the real `A2uiSurfaceCard`. */
69
+ useRoutedA2uiSurfaceCardHook: (props: A2uiSurfaceCardProps) => {
70
+ target: HTMLElement | null;
71
+ dismissed: boolean;
72
+ setDismissed: (required: {
73
+ value: boolean;
74
+ }) => void;
75
+ hasError: boolean;
76
+ handleAgentAction: NonNullable<A2uiSurfaceCardProps["onAgentAction"]>;
77
+ };
78
+ }
79
+ export declare function RoutedA2uiSurfaceCard({ useRoutedA2uiSurfaceCardHook, useTHook, SurfaceCard, useChartRegistryHook, ...props }: RoutedA2uiSurfaceCardProps): import("react").JSX.Element | null;
80
+ //# sourceMappingURL=RoutedA2uiSurfaceCard.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { createElement as _createElement } from "react";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { createPortal } from "react-dom";
4
+ export function RoutedA2uiSurfaceCard({ useRoutedA2uiSurfaceCardHook, useTHook, SurfaceCard, useChartRegistryHook, ...props }) {
5
+ const t = useTHook();
6
+ const { registry, generation, stylesheets } = useChartRegistryHook();
7
+ const { target, dismissed, setDismissed, hasError, handleAgentAction } = useRoutedA2uiSurfaceCardHook(props);
8
+ if (target && !hasError) {
9
+ if (dismissed)
10
+ return null;
11
+ return createPortal(_jsxs("div", { className: "playground-drawn-surface", children: [_jsx("button", { type: "button", className: "playground-drawn-surface-dismiss", onClick: () => setDismissed({ value: true }), "aria-label": t("Remove from canvas"), children: "\u00D7" }), stylesheets.map((href) => _jsx("link", { rel: "stylesheet", href: href }, href)), _createElement(SurfaceCard, { ...props, key: generation, registry: registry, onAgentAction: handleAgentAction })] }), target);
12
+ }
13
+ return _jsxs(_Fragment, { children: [stylesheets.map((href) => _jsx("link", { rel: "stylesheet", href: href }, href)), _createElement(SurfaceCard, { ...props, key: generation, registry: registry, onAgentAction: handleAgentAction })] });
14
+ }
15
+ //# sourceMappingURL=RoutedA2uiSurfaceCard.js.map
@@ -1,6 +1,7 @@
1
1
  import { type Logger } from '@jini-ai/core/primitives';
2
- import type { AgentEvent } from '../../core/index.js';
2
+ import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
3
3
  import { useToolRendererRegistry } from '../hooks/context.js';
4
+ import { useCopyToClipboard } from '../hooks/useCopyToClipboard.js';
4
5
  type ToolUseEvent = Extract<AgentEvent, {
5
6
  kind: 'tool_use';
6
7
  }>;
@@ -22,8 +23,9 @@ export interface ToolCardProps {
22
23
  /** A later call of the same tool in this turn succeeded (`retriedToolRowIds`): a failure shows a neutral "Retried" badge, not red. */
23
24
  retried?: boolean;
24
25
  }
25
- export declare function ToolCard({ use, result, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile, retried, report, useToolRendererRegistryHook }: ToolCardProps & {
26
+ export declare function ToolCard({ use, result, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile, retried, report, useToolRendererRegistryHook, useCopyToClipboardHook }: ToolCardProps & {
26
27
  useToolRendererRegistryHook?: typeof useToolRendererRegistry;
28
+ useCopyToClipboardHook?: typeof useCopyToClipboard;
27
29
  }): import("react").JSX.Element | null;
28
30
  export {};
29
31
  //# sourceMappingURL=ToolCard.d.ts.map
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { createConsoleLogger } from '@jini-ai/core/primitives';
3
3
  const RUNNING_TITLE_CLASS = ' shimmer-text';
4
4
  /**
@@ -25,6 +25,7 @@ const RUNNING_TITLE_CLASS = ' shimmer-text';
25
25
  import { createContext, useContext, useId, useMemo, useState } from 'react';
26
26
  import { COLLAPSED_DETAIL_MAX_CHARS, describeCollapsedToolCall, describeToolCallDetail, humanizeToolName, isDelegatedWrapperToolName, isTodoWriteToolName, parseTodoWriteInput, redactUserText, toRenderProps } from '../../core/index.js';
27
27
  import { useT, useToolRendererRegistry } from '../hooks/context.js';
28
+ import { useCopyToClipboard } from '../hooks/useCopyToClipboard.js';
28
29
  import { Icon } from './Icon.js';
29
30
  import { SAFE_LINK_HREF } from './Markdown.js';
30
31
  import { TodoCard } from './TodoCard.js';
@@ -37,14 +38,18 @@ import { toolPresentation } from '../../core/tool-presentation.js';
37
38
  const RetriedContext = createContext(false);
38
39
  /** A Jini registry tool id: dotted, lowercase, snake_case segments — `page.fill`, `daemon.db.vacuum`, `chat.send_message`. Never matches an agent-vendor tool name (`Bash`, `Write`, `mcp__jini__execute_delegated_tool`), which is the point — this is how a canonical delegated-tool event is told apart from everything else. */
39
40
  const JINI_TOOL_ID_PATTERN = /^[a-z][a-z_]*(\.[a-z][a-z_]*)+$/;
40
- export function ToolCard({ use, result, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile, retried = false, report, useToolRendererRegistryHook = useToolRendererRegistry }) {
41
+ export function ToolCard({ use, result, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile, retried = false, report, useToolRendererRegistryHook = useToolRendererRegistry, useCopyToClipboardHook = useCopyToClipboard }) {
41
42
  const registry = useToolRendererRegistryHook();
42
43
  // Resolve vendor dialects for rendering only; tool ids and stored events stay intact.
43
44
  const presentation = toolPresentation(use);
44
45
  use = { ...use, ...presentation };
45
46
  const name = use.name;
46
47
  const card = { input: use.input, result: result, runStreaming: runStreaming ?? false, runSucceeded: runSucceeded ?? false };
47
- const content = renderToolCardBody({ use, card, wrapper: presentation.wrapper, fileCtx: { projectFileNames, onRequestOpenFile }, registry, report });
48
+ // Classified on the normalized name and ahead of every registered or family renderer: a failed
49
+ // choice's protocol text must not reach any renderer, including one a host registers later.
50
+ const content = result?.isError === true && isChoiceToolName({ name: name })
51
+ ? _jsx(FailedChoiceCard, { result: result, useTHook: useT, useCopyToClipboardHook: useCopyToClipboardHook })
52
+ : renderToolCardBody({ use, card, wrapper: presentation.wrapper, fileCtx: { projectFileNames, onRequestOpenFile }, registry, report });
48
53
  if (content === null)
49
54
  return null;
50
55
  // Tagged once here, at the single dispatch point every branch below funnels through, rather than
@@ -54,6 +59,43 @@ export function ToolCard({ use, result, runStreaming, runSucceeded, projectFileN
54
59
  // ambiguous the way a repeated literal handle would be.
55
60
  return (_jsx("div", { "data-agent-element": `tool-call-${use.id}`, "data-agent-role": "region", "data-agent-label": `A ${humanizeToolName({ name: name })} tool call the AI made`, children: _jsx(RetriedContext.Provider, { value: retried, children: content }) }));
56
61
  }
62
+ const CHOICE_TOOL_NAME = 'assistant_ask_choice';
63
+ /** Bare `assistant_ask_choice`, or `mcp__<server>__assistant_ask_choice` whose exact tool segment is it — never a suffix match (`my_assistant_ask_choice`). O(n) in the name. */
64
+ function isChoiceToolName({ name }, _optional = {}) {
65
+ if (name === CHOICE_TOOL_NAME)
66
+ return true;
67
+ if (!name.startsWith('mcp__'))
68
+ return false;
69
+ // The server segment is at least one character, so its closing `__` starts at index 6 or later.
70
+ const separator = name.indexOf('__', 6);
71
+ return separator !== -1 && name.slice(separator + 2) === CHOICE_TOOL_NAME;
72
+ }
73
+ /** A host translation, or the English default when the adapter has none (it echoes the key or returns ''). */
74
+ function translated({ t, key, fallback }, _optional = {}) {
75
+ const text = t(key);
76
+ return text === '' || text === key ? fallback : text;
77
+ }
78
+ /**
79
+ * A failed `assistant_ask_choice`. Failed tool protocol text (the choice schema, the assistant's own
80
+ * inputs) is for the assistant to repair its call, not a user-facing explanation, so the row,
81
+ * badge, collapsed reader and panel only ever get a safe projection carrying the plain sentence.
82
+ * The redacted diagnostic is built on click and handed straight to the clipboard hook — never
83
+ * rendered, logged, or stored in an attribute. The two representations stay separate so a new
84
+ * renderer cannot accidentally publish the diagnostic.
85
+ */
86
+ function FailedChoiceCard({ result, useTHook, useCopyToClipboardHook }, _optional = {}) {
87
+ const t = useTHook();
88
+ const { copied, copy } = useCopyToClipboardHook();
89
+ const sentence = translated({ t, key: 'chat.toolCard.choiceFailed', fallback: "The assistant couldn't open the choice form. Ask it to try again." });
90
+ const copyLabel = translated({ t, key: 'chat.toolCard.copyDetails', fallback: 'Copy details' });
91
+ const safeResult = { kind: 'tool_result', toolUseId: result.toolUseId, content: sentence, isError: true };
92
+ const safeCall = { input: undefined, result: safeResult, runStreaming: false, runSucceeded: false };
93
+ const copyDetails = () => {
94
+ const diagnostic = describeToolCallDetail({ input: undefined, result }, { resultPresentation: 'copy-diagnostic' }).outputText;
95
+ void copy(diagnostic ?? sentence);
96
+ };
97
+ return (_jsx(ExpandableCard, { className: "jini-op-generic jini-op-choice-failed", call: safeCall, head: _jsxs(_Fragment, { children: [_jsx(ResultBadge, { result: safeResult, runStreaming: false, runSucceeded: false }), _jsx("span", { className: "jini-op-sr-prefix", children: `${t('Tool call')} · ` }), _jsx("span", { className: "op-title", children: sentence })] }), children: _jsxs("div", { className: "jini-op-card-detail", children: [_jsx("p", { className: "jini-op-detail-note", children: sentence }), _jsx("button", { type: "button", className: "jini-op-copy-details", onClick: copyDetails, children: copied ? t('Copied') : copyLabel }), _jsx("span", { className: "jini-message-copy-status", "aria-live": "polite", children: copied ? t('Copied to clipboard') : '' })] }) }));
98
+ }
57
99
  // Hardcoded family cards for tools shipped with this package, keyed by every name each tool goes
58
100
  // by. A `Map`, not an object literal, so a tool named `constructor`/`toString` can never resolve
59
101
  // to an inherited `Object.prototype` member.
@@ -219,7 +261,7 @@ function FileReadCard({ input, result, runStreaming, runSucceeded, ctx, useTHook
219
261
  const obj = (input ?? {});
220
262
  const file = obj.file_path ?? obj.filePath ?? obj.path ?? '(unnamed)';
221
263
  // See OpenInTabButton's baseName comment: `.split('/').pop()` is never undefined.
222
- const baseName = targetAtOffset({ target: file.split('/').pop(), offset: obj.offset });
264
+ const baseName = targetAtOffset({ target: file.split('/').pop(), offset: obj.offset, limit: obj.limit });
223
265
  const call = { input, result, runStreaming, runSucceeded };
224
266
  return (_jsx(FamilyCard, { call: call, className: "jini-op-file", shimmer: true, title: t('Read'), meta: _jsx("span", { className: "jini-op-meta", children: baseName }), after: _jsx(FileErrorDetail, { result: result }), children: _jsxs("div", { className: "jini-op-card-detail jini-op-card-file-detail", children: [_jsx("code", { className: "jini-op-path", children: file }), _jsx(OpenInTabButton, { filePath: file, ctx: ctx })] }) }));
225
267
  }
@@ -17,9 +17,12 @@ export declare function toolRowTarget({ input, resultContent }: {
17
17
  input: unknown;
18
18
  resultContent?: string | undefined;
19
19
  }): string | undefined;
20
- /** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. */
21
- export declare function targetAtOffset({ target, offset }: {
20
+ /** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. Limits follow the same rule.
21
+ * The read window (offset and/or limit) is appended so two reads of one file stay distinguishable.
22
+ */
23
+ export declare function targetAtOffset({ target, offset, limit }: {
22
24
  target: string | undefined;
23
25
  offset: unknown;
26
+ limit?: unknown;
24
27
  }, _options?: {}): string | undefined;
25
28
  //# sourceMappingURL=ToolCard.rules.d.ts.map
@@ -89,12 +89,19 @@ export function toolRowTarget({ input, resultContent }) {
89
89
  const args = (input ?? {});
90
90
  const named = firstReadable(args, SUMMARY_KEYS) ?? resultName(resultContent);
91
91
  const target = named ?? batchTarget(args) ?? firstReadable(args, KIND_KEYS) ?? Object.values(args).find(readable);
92
- return targetAtOffset({ target, offset: args.offset });
92
+ return targetAtOffset({ target, offset: args.offset, limit: args.limit });
93
93
  }
94
- /** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. */
95
- export function targetAtOffset({ target, offset }, _options = {}) {
96
- if (!target || typeof offset !== 'number')
94
+ /** A valid window bound is a safe non-negative integer; anything else is ignored rather than shown. */
95
+ function windowBound({ label, value }) {
96
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? `${label} ${value}` : undefined;
97
+ }
98
+ /** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. Limits follow the same rule.
99
+ * The read window (offset and/or limit) is appended so two reads of one file stay distinguishable.
100
+ */
101
+ export function targetAtOffset({ target, offset, limit }, _options = {}) {
102
+ if (!target)
97
103
  return target;
98
- return Number.isSafeInteger(offset) && offset >= 0 ? `${target} (offset ${offset})` : target;
104
+ const window = [windowBound({ label: 'offset', value: offset }), windowBound({ label: 'limit', value: limit })].filter(Boolean);
105
+ return window.length > 0 ? `${target} (${window.join(', ')})` : target;
99
106
  }
100
107
  //# sourceMappingURL=ToolCard.rules.js.map
@@ -1,7 +1,7 @@
1
1
  /** Read display context from a standalone form; its host may not have emitted a tool call. */
2
2
  import { type UIResource } from '@jini-ai/protocol/mcp-ui';
3
- import type { AgentEvent } from '../../core/events.js';
4
3
  import type { AcceptedInputProjectionOptions } from '../../core/accepted-input.js';
4
+ import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
5
5
  /** Feed recovered form context into the existing receipt projection, including after history reload.
6
6
  * Grouping owns tool/surface association; this hook only supplies missing presentation context.
7
7
  * @complexity O(e + h + c) for events, parsed HTML and controls; no mutation or I/O.
@@ -25,7 +25,9 @@ export declare function closedSurfaceLabel({ t, call, runStreaming, documentsFor
25
25
  *
26
26
  * @complexity O(1).
27
27
  */
28
- export declare function isDeliveredAnswer(result: unknown): boolean;
28
+ export declare function isDeliveredAnswer({ result }: {
29
+ result: unknown;
30
+ }, _optional?: Record<string, never>): boolean;
29
31
  /**
30
32
  * Wraps a card's tool executor so a delivered answer is reported once it resolves. The result is
31
33
  * passed through unchanged; onAnswerText receives readable choice text when available. A rejected call
@@ -60,7 +60,7 @@ export function closedSurfaceLabel({ t, call, runStreaming, documentsForUri, exp
60
60
  *
61
61
  * @complexity O(1).
62
62
  */
63
- export function isDeliveredAnswer(result) {
63
+ export function isDeliveredAnswer({ result }, _optional = {}) {
64
64
  return typeof result === 'object' && result !== null && result.delivered === true;
65
65
  }
66
66
  /**
@@ -73,7 +73,7 @@ export function isDeliveredAnswer(result) {
73
73
  export function reportDeliveredAnswer({ onToolCall, onAnswered, onAnswerText, input }) {
74
74
  return async (call) => {
75
75
  const result = await onToolCall(call);
76
- if (isDeliveredAnswer(result)) {
76
+ if (isDeliveredAnswer({ result })) {
77
77
  const text = questionAnswerText({ answer: call.arguments, input });
78
78
  if (text !== undefined)
79
79
  onAnswerText?.(text);
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @file Which chat links count as "the owner's own site or admin".
3
+ *
4
+ * Owner decision 2026-11-21 (reverses 2026-10-08, when every chat link opened a new tab): a link to
5
+ * the owner's own site or admin navigates the current tab from its text, with a small icon right
6
+ * after it for a new tab. Links to any other website keep opening a new tab. This is the one place
7
+ * that decides which is which, so the markdown renderer (which draws the icon) and the pane's click
8
+ * guard (which leaves own links to the browser or the host's router) cannot disagree.
9
+ */
10
+ /** The page's own origin, or `''` where there is no `window` (server render), which matches nothing. */
11
+ export declare function currentOrigin(_required?: Record<string, never>, _options?: {}): string;
12
+ /**
13
+ * Whether `href` points at `origin`'s own site: an in-app path, or an absolute URL on exactly that
14
+ * origin (scheme, host and port). A same-document `#anchor`, `mailto:`, a protocol-relative `//host`
15
+ * and anything unparseable are not own links, so each keeps the behaviour it had.
16
+ *
17
+ * @param input.href - The link target as written (a path) or resolved (absolute).
18
+ * @param input.origin - The origin that counts as own; usually {@link currentOrigin}.
19
+ * @returns `true` when the link text should navigate this tab.
20
+ * @complexity O(n) in the href length (one URL parse); no I/O.
21
+ */
22
+ export declare function isOwnLinkHref({ href, origin }: {
23
+ href: string;
24
+ origin: string;
25
+ }, _options?: {}): boolean;
26
+ //# sourceMappingURL=own-link.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file Which chat links count as "the owner's own site or admin".
3
+ *
4
+ * Owner decision 2026-11-21 (reverses 2026-10-08, when every chat link opened a new tab): a link to
5
+ * the owner's own site or admin navigates the current tab from its text, with a small icon right
6
+ * after it for a new tab. Links to any other website keep opening a new tab. This is the one place
7
+ * that decides which is which, so the markdown renderer (which draws the icon) and the pane's click
8
+ * guard (which leaves own links to the browser or the host's router) cannot disagree.
9
+ */
10
+ /** The page's own origin, or `''` where there is no `window` (server render), which matches nothing. */
11
+ export function currentOrigin(_required = {}, _options = {}) {
12
+ return typeof window === 'undefined' ? '' : window.location.origin;
13
+ }
14
+ /**
15
+ * Whether `href` points at `origin`'s own site: an in-app path, or an absolute URL on exactly that
16
+ * origin (scheme, host and port). A same-document `#anchor`, `mailto:`, a protocol-relative `//host`
17
+ * and anything unparseable are not own links, so each keeps the behaviour it had.
18
+ *
19
+ * @param input.href - The link target as written (a path) or resolved (absolute).
20
+ * @param input.origin - The origin that counts as own; usually {@link currentOrigin}.
21
+ * @returns `true` when the link text should navigate this tab.
22
+ * @complexity O(n) in the href length (one URL parse); no I/O.
23
+ */
24
+ export function isOwnLinkHref({ href, origin }, _options = {}) {
25
+ if (href.startsWith('//'))
26
+ return false;
27
+ if (href.startsWith('/'))
28
+ return true;
29
+ try {
30
+ return origin !== '' && new URL(href).origin === origin;
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ //# sourceMappingURL=own-link.js.map
@@ -0,0 +1,7 @@
1
+ import type { ChatPaneProps } from '../chat-pane/types.js';
2
+ import type { AttachmentStagingPort } from './types.js';
3
+ /** Builds the uploader over the host's staging bridge. */
4
+ export declare function createStagedAttachmentUploader({ bridge }: {
5
+ bridge: AttachmentStagingPort;
6
+ }, _options?: Record<string, never>): NonNullable<ChatPaneProps['uploadAttachments']>;
7
+ //# sourceMappingURL=create-staged-attachment-uploader.d.ts.map