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

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 (205) hide show
  1. package/CHANGELOG.md +2 -12
  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.d.ts +0 -4
  90. package/dist/react/components/MessageList.hooks.js +6 -18
  91. package/dist/react/components/MessageList.js +17 -20
  92. package/dist/react/components/MessageList.rules.d.ts +0 -5
  93. package/dist/react/components/MessageList.rules.js +0 -4
  94. package/dist/react/components/MessageRow.d.ts +46 -2
  95. package/dist/react/components/MessageRow.hooks.d.ts +60 -0
  96. package/dist/react/components/MessageRow.hooks.js +94 -0
  97. package/dist/react/components/MessageRow.js +53 -113
  98. package/dist/react/components/MidRunUserMessage.d.ts +6 -1
  99. package/dist/react/components/MidRunUserMessage.js +5 -5
  100. package/dist/react/components/NextStepActions.d.ts +3 -1
  101. package/dist/react/components/NextStepActions.js +3 -3
  102. package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
  103. package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
  104. package/dist/react/components/QuestionForm.d.ts +6 -0
  105. package/dist/react/components/QuestionForm.js +23 -261
  106. package/dist/react/components/QuestionForm.values.d.ts +22 -0
  107. package/dist/react/components/QuestionForm.values.js +58 -0
  108. package/dist/react/components/QuestionFormField.d.ts +17 -0
  109. package/dist/react/components/QuestionFormField.js +114 -0
  110. package/dist/react/components/QuestionsPanel.d.ts +3 -1
  111. package/dist/react/components/QuestionsPanel.js +7 -3
  112. package/dist/react/components/SentAttachment.d.ts +11 -2
  113. package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
  114. package/dist/react/components/SentAttachment.hooks.js +6 -5
  115. package/dist/react/components/SentAttachment.js +5 -3
  116. package/dist/react/components/TodoCard.d.ts +3 -1
  117. package/dist/react/components/TodoCard.js +9 -4
  118. package/dist/react/components/ToolCallGroup.d.ts +11 -1
  119. package/dist/react/components/ToolCallGroup.js +10 -4
  120. package/dist/react/components/ToolCard.d.ts +6 -1
  121. package/dist/react/components/ToolCard.js +79 -69
  122. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  123. package/dist/react/components/mcp-ui-question-input.js +3 -3
  124. package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
  125. package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
  126. package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
  127. package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
  128. package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
  129. package/dist/react/features/chat-pane/claude/model-options.js +2 -0
  130. package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
  131. package/dist/react/features/chat-pane/codex/model-options.js +2 -0
  132. package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
  133. package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
  134. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
  135. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
  136. package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
  137. package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
  138. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
  139. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
  140. package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
  141. package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
  142. package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
  143. package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
  144. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
  145. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
  146. package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
  147. package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
  148. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
  149. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
  150. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
  151. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
  152. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
  153. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
  154. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
  155. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
  156. package/dist/react/features/chat-pane/model-options.js +7 -4
  157. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  158. package/dist/react/features/chat-pane/styles.js +25 -41
  159. package/dist/react/features/chat-pane/types.d.ts +29 -1
  160. package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
  161. package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
  162. package/dist/react/hooks/attachment-preview-cache.js +1 -1
  163. package/dist/react/hooks/fab-position.js +16 -18
  164. package/dist/react/hooks/useConversation.d.ts +6 -1
  165. package/dist/react/hooks/useConversation.js +11 -10
  166. package/dist/react/hooks/useRunStream.d.ts +3 -0
  167. package/dist/react/hooks/useRunStream.js +12 -12
  168. package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
  169. package/dist/react/hooks/useSurfaceRecovery.js +2 -2
  170. package/dist/react/index.d.ts +6 -3
  171. package/dist/react/index.js +5 -3
  172. package/dist/react/styles/chat-settings.css +9 -9
  173. package/dist/react/surfaces.d.ts +91 -0
  174. package/dist/react/surfaces.js +28 -0
  175. package/dist/server/durable-runs/recover.d.ts +4 -3
  176. package/dist/server/durable-runs/recover.js +4 -3
  177. package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
  178. package/dist/store/legacy/sqlite/conversations.js +1 -1
  179. package/dist/store/legacy/sqlite/messages.d.ts +2 -3
  180. package/dist/store/legacy/sqlite/messages.js +6 -6
  181. package/dist/store/pglite/index.d.ts +7 -7
  182. package/dist/store/pglite/index.js +1 -1
  183. package/dist/store/ports.d.ts +5 -2
  184. package/dist/store/postgres/index.d.ts +7 -7
  185. package/dist/store/postgres/index.js +1 -1
  186. package/dist/store/runtime/chat-expiry-sweep.js +2 -4
  187. package/dist/store/runtime/chat-history-store.js +2 -3
  188. package/dist/store/runtime/durable-run-store.js +16 -2
  189. package/dist/store/runtime/history-tools.js +33 -11
  190. package/dist/store/runtime/kernel.d.ts +3 -2
  191. package/dist/store/runtime/run-ledger.js +2 -2
  192. package/dist/store/sql/boundary.d.ts +5 -5
  193. package/dist/store/sql/maintenance.d.ts +3 -2
  194. package/dist/store/sql/store.d.ts +16 -8
  195. package/dist/store/sql/store.js +31 -14
  196. package/dist/store/sqlite/index.d.ts +11 -12
  197. package/dist/store/sqlite/index.js +5 -5
  198. package/dist/store/sqlite/schema.d.ts +1 -1
  199. package/package.json +46 -24
  200. package/dist/core/ag-ui/entry.d.ts +0 -84
  201. package/dist/core/ag-ui/entry.js +0 -225
  202. package/dist/core/browser/page-actions.d.ts +0 -121
  203. package/dist/core/browser/page-actions.js +0 -113
  204. package/dist/embed-widget/browser/page-actions.d.ts +0 -2
  205. package/dist/embed-widget/browser/page-actions.js +0 -3
@@ -8,44 +8,13 @@ const REDACTION_MARKER = /\[REDACTED:[^\]\r\n]+\]/g;
8
8
  const CHAT_RULES = [
9
9
  { kind: 'chat_key', pattern: /(?<![A-Za-z0-9_-])sk-[A-Za-z0-9_-]{16,}/g, replacement: () => INTERNAL_REMOVED },
10
10
  // Kept on top of the shared Slack rule: that rule refuses a token preceded by `-` (e.g. a URL path
11
- // segment `/-xoxb-…`) and the entropy fallback below exempts URLs, so without this rule such a token
11
+ // segment `/-xoxb-…`), so without this rule such a token
12
12
  // would reach storage and model history. Only drop it once the shared rule covers that case.
13
13
  { kind: 'chat_key', pattern: /(?<!\w)xox[baprs]-[A-Za-z0-9-]{16,}/g, replacement: () => INTERNAL_REMOVED },
14
14
  // Explicit authorization syntax catches even short values. Exempt scheme descriptions in prose.
15
15
  { kind: 'chat_bearer', pattern: /\bBearer[ \t]+(?!\[REDACTED)(?!(?:token|tokens|authentication|authorization|auth|scheme|credentials?)\b)[\w.~+\/=-]+/gi, replacement: () => 'Bearer ' + INTERNAL_REMOVED },
16
16
  ];
17
- function entropy(text) {
18
- const counts = new Map();
19
- for (const char of text)
20
- counts.set(char, (counts.get(char) ?? 0) + 1);
21
- let bits = 0;
22
- for (const count of counts.values()) {
23
- const probability = count / text.length;
24
- bits -= probability * Math.log2(probability);
25
- }
26
- return bits;
27
- }
28
- /** Recognize identifier paths, including the fragment after a space in a typed path.
29
- * Require multiple segments and readable words: arbitrary base64 and long digit-mixed runs
30
- * must still reach the entropy guard. Specific credential rules have already run. */
31
- function isIdentifierPath({ text }, _options = {}) {
32
- const segments = text.replace(/^(?:[a-z]:|~)?[\\/]*/i, '').split(/[\\/]/).filter(Boolean);
33
- return segments.length >= 2 && segments.every(segment => /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/.test(segment)
34
- || segment.split(/[-_.]/).every(word => /^[A-Z]$/.test(word)
35
- || /^[A-Z]?[a-z]{2,}(?:[A-Z][a-z]{2,}|[0-9]{1,4}(?=[A-Z][a-z]{2,}|$))*$/.test(word)));
36
- }
37
- /** A piece of a random key: long, both letter cases, and a character-class change at most positions.
38
- * Readable names (CamelCase, SCREAMING_CASE, dated file names) change class far less often, and
39
- * every piece of a 40-character base64 key split by '/' is 12+ characters in most keys. */
40
- function isOpaqueSegment(segment) {
41
- if (segment.length < 12 || !/[A-Z]/.test(segment) || !/[a-z]/.test(segment))
42
- return false;
43
- const changes = segment.match(/[A-Z](?=[^A-Z])|[a-z](?=[^a-z])|\d(?=\D)/g)?.length ?? 0;
44
- return changes / (segment.length - 1) >= 0.4;
45
- }
46
- /** Stricter than error redaction: also detects unlabelled long tokens, while retaining ordinary URLs,
47
- * filesystem paths, hexadecimal hashes, identifiers and prose. Strong credential syntax inside
48
- * URLs or paths is still caught. */
17
+ /** Masks recognisable secrets only (shared rules plus the chat rules above); paths, file names, ids and prose stay as typed. */
49
18
  export function redactUserText({ text }, { secretField = false } = {}) {
50
19
  // Existing removal markers must survive a second pass through assignment rules (api_key=…).
51
20
  const literalMarkers = new Map();
@@ -59,34 +28,7 @@ export function redactUserText({ text }, { secretField = false } = {}) {
59
28
  }).replaceAll(REMOVED, INTERNAL_REMOVED);
60
29
  const base = redactSecretShapes({ text: protectedText, policy: { additionalRules: CHAT_RULES } });
61
30
  let count = base.redactions;
62
- // Exempt locations only AFTER specific secret rules. Only quoted paths may contain whitespace;
63
- // unquoted paths and URLs end there, and at , | ; and invisible separators, so an adjacent
64
- // secret glued after them cannot inherit the exemption.
65
- // A quoted path ends at its first matching quote, which must sit on a word boundary, so an
66
- // apostrophe later in the line ("don't") cannot close an unterminated quote and exempt the gap.
67
- // Require a root boundary so a slash inside an opaque token cannot exempt that token, and a
68
- // folder after the root so a bare "/" + token is not mistaken for a path.
69
- const locations = [
70
- ...[...base.text.matchAll(/\b[a-z][a-z0-9+.-]*:\/\/[^\s<>"'`,|;\u200B-\u200D\uFEFF]+|(?<!\w)(["'`])(?:~\/|[a-z]:[\\/]|\\\\|\/)[^\r\n"'`\\/]+[\\/](?:(?!\1)[^\r\n])*\1(?!\w)|(?<![\w+\/=\\~.-])(?:~\/|[a-z]:[\\/]|\\\\|\/)[^\s<>"'`,|;\u200B-\u200D\uFEFF\\/]+[\\/][^\s<>"'`,|;\u200B-\u200D\uFEFF]*/gi)]
71
- .map(match => ({ match, url: /^[a-z][a-z0-9+.-]*:\/\//i.test(match[0]) })),
72
- // The part of a hand-typed unquoted path after a space (Work/CustomerPortal…) has no root.
73
- ...[...base.text.matchAll(/[^\s<>"'`,|;\u200B-\u200D\uFEFF]+/g)]
74
- .filter(match => isIdentifierPath({ text: match[0] })).map(match => ({ match, url: false })),
75
- ].map(({ match, url }) => ({ start: match.index, end: match.index + match[0].length, url }));
76
- let cleaned = base.text.replace(/(?<![A-Za-z0-9_+\/=-])[A-Za-z0-9_+\/=-]{40,}(?![A-Za-z0-9_+\/=-])/g, (candidate, offset) => {
77
- const location = locations.find(span => offset >= span.start && offset + candidate.length <= span.end);
78
- // A key glued straight onto a path (/proj/KEY) is still checked; URLs keep their opaque ids.
79
- if (location && (location.url || !candidate.split(/[\\/]/).some(isOpaqueSegment)))
80
- return candidate;
81
- if (/^[a-f0-9]+$/i.test(candidate) || !/[A-Za-z]/.test(candidate))
82
- return candidate;
83
- const bits = entropy(candidate);
84
- const mixedAlphabet = /[A-Z]/.test(candidate) && /[a-z]/.test(candidate);
85
- if (bits < 4 || (!/\d/.test(candidate) && (!mixedAlphabet || bits < 4.5)))
86
- return candidate;
87
- count += 1;
88
- return INTERNAL_REMOVED;
89
- });
31
+ let cleaned = base.text;
90
32
  // A labelled credential answer can be a short password with no recognisable shape at all.
91
33
  if (secretField && cleaned.trim() !== '' && cleaned !== INTERNAL_REMOVED) {
92
34
  cleaned = INTERNAL_REMOVED;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file Last-known agent inventory as an instant placeholder.
3
+ *
4
+ * A host that lists agents from a slow source (a cold daemon re-probing installed CLIs) can show the
5
+ * last live answer this browser saw instead of an empty picker, and swap it for the live list the
6
+ * moment that resolves. The last live answer is the same machine's own probe result, usually still
7
+ * exact, whereas a list bundled into the client would be a hand-maintained duplicate of the server's
8
+ * registry that drifts.
9
+ *
10
+ * Every storage access is fail-soft: browser storage throws in some privacy modes and on quota
11
+ * exhaustion, and a missing placeholder only costs the host's normal loading state.
12
+ */
13
+ import type { SessionStoragePort } from './session-store.js';
14
+ /** The fields a stored entry must carry to be trusted; hosts may store richer entries. */
15
+ export interface AgentInventoryEntry {
16
+ readonly id: string;
17
+ readonly name: string;
18
+ }
19
+ export interface AgentInventorySnapshot<T extends AgentInventoryEntry> {
20
+ /** The last stored inventory, or `undefined` when there is none, it is empty, or it is unreadable. */
21
+ read(args: Record<string, never>): readonly T[] | undefined;
22
+ /** Stores a live inventory. An empty list is not stored: it would replace a useful placeholder with
23
+ * one that shows nothing. Silent no-op on any storage failure. */
24
+ write(args: {
25
+ agents: readonly T[];
26
+ }): void;
27
+ }
28
+ export interface AgentInventorySnapshotArgs {
29
+ readonly storage: Pick<SessionStoragePort, 'getItem' | 'setItem'>;
30
+ /** Version the key so a later change to the stored shape ignores old entries instead of misreading them. */
31
+ readonly key: string;
32
+ }
33
+ /** @complexity read/write O(n) in stored agents. */
34
+ export declare function createAgentInventorySnapshot<T extends AgentInventoryEntry>({ storage, key }: AgentInventorySnapshotArgs, _optional?: {
35
+ readonly [K in never]?: never;
36
+ }): AgentInventorySnapshot<T>;
37
+ //# sourceMappingURL=agent-inventory.d.ts.map
@@ -0,0 +1,36 @@
1
+ function isEntryShape(value) {
2
+ if (typeof value !== 'object' || value === null)
3
+ return false;
4
+ const candidate = value;
5
+ return typeof candidate.id === 'string' && typeof candidate.name === 'string';
6
+ }
7
+ /** @complexity read/write O(n) in stored agents. */
8
+ export function createAgentInventorySnapshot({ storage, key }, _optional = {}) {
9
+ return {
10
+ read: () => {
11
+ try {
12
+ const raw = storage.getItem(key);
13
+ if (!raw)
14
+ return undefined;
15
+ const parsed = JSON.parse(raw);
16
+ if (!Array.isArray(parsed) || parsed.length === 0 || !parsed.every(isEntryShape))
17
+ return undefined;
18
+ return parsed;
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ },
24
+ write: ({ agents }) => {
25
+ if (agents.length === 0)
26
+ return;
27
+ try {
28
+ storage.setItem(key, JSON.stringify(agents));
29
+ }
30
+ catch {
31
+ // Best-effort: the live list is already on screen; only the next cold load loses its placeholder.
32
+ }
33
+ },
34
+ };
35
+ }
36
+ //# sourceMappingURL=agent-inventory.js.map
@@ -1,4 +1,4 @@
1
- import { type PageDriver } from '@jini-ai/agentic';
1
+ import type { ChatPagePort } from '../../core/page-port.js';
2
2
  import type { ApprovalAnswer } from '@jini-ai/core';
3
3
  import type { ChatPaneAgentToolAction, ChatPaneAgentBridgeAccess } from '../../react/features/chat-pane/types.js';
4
4
  export interface FrontendSessionBridgeOptions {
@@ -31,7 +31,7 @@ export interface FrontendSessionBridgeOptions {
31
31
  }): Promise<ApprovalAnswer>;
32
32
  };
33
33
  /** Supplying one claims the six `page.*` verbs. Omit for a chat-only surface. */
34
- readonly pageDriver?: PageDriver;
34
+ readonly page?: ChatPagePort;
35
35
  /**
36
36
  * Product capabilities, keyed by id prefix (`'cms.'`). Each claims every capability under it.
37
37
  * This is how a consumer exposes verbs the engine has never heard of.
@@ -18,7 +18,7 @@ import { decodeSseFrames } from '@jini-ai/core/primitives';
18
18
  * control dies when the pane unmounts — and the page is drivable whether or not a chat pane
19
19
  * exists. `subscribe` registers a listener; `close()` tears the connection down.
20
20
  * - **Capabilities are claimed from what is actually wired.** The claim sent at connect time is
21
- * derived from the presence of a `pageDriver` and the keys of `executors`, never from a static
21
+ * derived from the presence of a `page` port and the keys of `executors`, never from a static
22
22
  * list. A surface that claims what it cannot serve turns a fast, named refusal into a timeout.
23
23
  * - **An executed invocation is never executed twice.** If the stream drops between the daemon
24
24
  * delivering an invocation and this page POSTing the answer, the daemon correctly fails that
@@ -36,7 +36,6 @@ import { decodeSseFrames } from '@jini-ai/core/primitives';
36
36
  * belongs in a run request. Park/failure closes the transport; hosts explicitly rebind after wake.
37
37
  */
38
38
  import { CHAT_CAPABILITIES } from '../../core/index.js';
39
- import { PAGE_CAPABILITIES, executePageCapability } from '@jini-ai/agentic';
40
39
  /** How many settled invocation ids to remember for replay suppression. */
41
40
  const EXECUTED_MEMORY = 256;
42
41
  /** Ids this surface can actually serve, given what the host wired up. */
@@ -44,8 +43,8 @@ function claimedCapabilities(options) {
44
43
  if (options.capabilityIds)
45
44
  return [...options.capabilityIds];
46
45
  const claims = CHAT_CAPABILITIES.map((capability) => capability.id);
47
- if (options.pageDriver !== undefined) {
48
- claims.push(...PAGE_CAPABILITIES.map((capability) => capability.id));
46
+ if (options.page !== undefined) {
47
+ claims.push(...options.page.capabilityIds);
49
48
  }
50
49
  // Dialog-support handshake only; page.approval is not an executable tool id.
51
50
  if (options.pageApproval)
@@ -206,14 +205,14 @@ export function createFrontendSessionBridge({ baseUrl: base, openStream, request
206
205
  }
207
206
  if (signal.aborted)
208
207
  return { executed: false, reason: 'abandoned' };
209
- return executePageCapability({ driver: options.pageDriver, ...args }, { signal });
208
+ return options.page.execute(args, { signal });
210
209
  }
211
210
  /** Runs one non-chat invocation here and answers it. Chat ones go to the pane instead. */
212
211
  async function serveLocally(action, controller) {
213
212
  let output;
214
213
  try {
215
214
  controller.signal.throwIfAborted();
216
- if (options.pageDriver !== undefined && action.capabilityId.startsWith('page.')) {
215
+ if (options.page !== undefined && action.capabilityId.startsWith('page.')) {
217
216
  output = await servePage(action, controller.signal);
218
217
  }
219
218
  else {
@@ -282,6 +281,17 @@ export function createFrontendSessionBridge({ baseUrl: base, openStream, request
282
281
  else
283
282
  void serveLocally(action, controller);
284
283
  }
284
+ /** Adopt a fresh attachment: drop work from the previous one, then release every waiter. */
285
+ function attach({ frame }, _optional = {}) {
286
+ abortPending();
287
+ sessionId = frame.sessionId;
288
+ currentBindToken = frame.bindToken;
289
+ // A no-op after the first attach — which is exactly why `currentBindToken` exists.
290
+ resolveReady({ sessionId, bindToken: currentBindToken });
291
+ for (const waiter of attachments)
292
+ waiter.resolve({ sessionId, bindToken: currentBindToken });
293
+ attachments.clear();
294
+ }
285
295
  function connect() {
286
296
  const current = openStream({ url: `${base}${endpointPrefix}/stream?${query}`, ...(headers ? { headers: headers() } : {}) });
287
297
  source = current;
@@ -294,14 +304,7 @@ export function createFrontendSessionBridge({ baseUrl: base, openStream, request
294
304
  pending.get(frame.invocationId)?.abort();
295
305
  return;
296
306
  case 'attached':
297
- abortPending();
298
- sessionId = frame.sessionId;
299
- currentBindToken = frame.bindToken;
300
- // A no-op after the first attach — which is exactly why `currentBindToken` exists.
301
- resolveReady({ sessionId, bindToken: currentBindToken });
302
- for (const waiter of attachments)
303
- waiter.resolve({ sessionId, bindToken: currentBindToken });
304
- attachments.clear();
307
+ attach({ frame });
305
308
  return;
306
309
  case 'refused': {
307
310
  const error = new Error(frame.message);
@@ -1,4 +1,6 @@
1
1
  import { type RefObject } from 'react';
2
+ import type { ChatMessage } from '../../core/messages.js';
3
+ import type { BrowserSessionStore } from '../browser/session-store.js';
2
4
  /**
3
5
  * Shares the panel-kit trap across embeds. Escape respects a child popup's preventDefault;
4
6
  * Closing restores the mounted launcher, including after a lazy-loader handoff.
@@ -25,4 +27,18 @@ export declare function useEmbedChatSurface({ initialOpen }: {
25
27
  launcherRef: RefObject<HTMLDivElement | null>;
26
28
  panelId: string;
27
29
  };
30
+ /** Persist the embed transcript and remount its pane when the host confirms a reset. */
31
+ export declare function useEmbedChatWidget({ session }: {
32
+ session: BrowserSessionStore;
33
+ }, _options?: {}): {
34
+ paneKey: number;
35
+ messages: ChatMessage[];
36
+ reset: () => void;
37
+ onMessagesChange: (next: ChatMessage[]) => void;
38
+ open: boolean;
39
+ toggle: () => void;
40
+ panelRef: RefObject<HTMLDivElement | null>;
41
+ launcherRef: RefObject<HTMLDivElement | null>;
42
+ panelId: string;
43
+ };
28
44
  //# sourceMappingURL=dialog.hooks.d.ts.map
@@ -51,4 +51,19 @@ export function useEmbedChatSurface({ initialOpen }, { resetKey } = {}) {
51
51
  useEmbedChatDialog({ open, onClose: close, panelRef, launcherRef }, { resetKey });
52
52
  return { open, toggle, panelRef, launcherRef, panelId };
53
53
  }
54
+ /** Persist the embed transcript and remount its pane when the host confirms a reset. */
55
+ export function useEmbedChatWidget({ session }, _options = {}) {
56
+ const [initial] = useState(() => session.load({}));
57
+ const [paneKey, setPaneKey] = useState(0);
58
+ const surface = useEmbedChatSurface({ initialOpen: initial.open }, { resetKey: paneKey });
59
+ const [messages, setMessages] = useState(initial.messages);
60
+ useEffect(() => { session.save({ state: { open: surface.open, messages } }); }, [session, surface.open, messages]);
61
+ const reset = useCallback(() => {
62
+ session.clear({});
63
+ setMessages([]);
64
+ setPaneKey(key => key + 1);
65
+ }, [session]);
66
+ const onMessagesChange = useCallback((next) => { setMessages(next); }, []);
67
+ return { ...surface, paneKey, messages, reset, onMessagesChange };
68
+ }
54
69
  //# sourceMappingURL=dialog.hooks.js.map
@@ -1,6 +1,8 @@
1
1
  import type { ChatTransport } from '../../core/transport.js';
2
2
  import type { ChatPaneAgent } from '../../react/chat-pane.js';
3
+ import { type ChatSurfaces } from '../../react/surfaces.js';
3
4
  import type { BrowserSessionStore } from '../browser/session-store.js';
5
+ import { useEmbedChatWidget } from './dialog.hooks.js';
4
6
  export { useEmbedChatDialog } from './dialog.hooks.js';
5
7
  import type { EmbedHeaderCopy, EscapeKeyPort } from './header.js';
6
8
  export { EmbedChatHeader } from './header.js';
@@ -28,11 +30,14 @@ export interface EmbedChatWidgetArgs {
28
30
  * cannot replay effects. Reset remounts the pane after confirmation.
29
31
  * @complexity O(messages + latest reply events) per transcript update; O(message IDs) retained.
30
32
  */
31
- export declare function EmbedChatWidget(args: EmbedChatWidgetArgs): import("react").JSX.Element;
33
+ export declare function EmbedChatWidget({ useEmbedChatWidgetHook, ...args }: EmbedChatWidgetArgs & {
34
+ useEmbedChatWidgetHook?: typeof useEmbedChatWidget;
35
+ }): import("react").JSX.Element;
32
36
  /** Mounts into a host-provided node and returns lifecycle cleanup. O(1) plus React rendering. */
33
- export declare function mountEmbedChat({ element, widget }: {
37
+ export declare function mountEmbedChat({ element, widget, surfaces }: {
34
38
  element: Element;
35
39
  widget: EmbedChatWidgetArgs;
40
+ surfaces: ChatSurfaces;
36
41
  }): {
37
42
  unmount: (args: Record<string, never>) => void;
38
43
  };
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useState } from 'react';
3
2
  import { createRoot } from 'react-dom/client';
4
3
  import { ChatPane } from '../../react/chat-pane.js';
4
+ import { ChatSurfacesProvider } from '../../react/surfaces.js';
5
5
  import { ChatFab } from '../../react/components/ChatFab.js';
6
6
  import { JiniChatProvider } from '../../react/components/JiniChatProvider.js';
7
7
  import { EmbedChatHeader } from './header.js';
8
- import { useEmbedChatSurface } from './dialog.hooks.js';
8
+ import { useEmbedChatWidget } from './dialog.hooks.js';
9
9
  export { useEmbedChatDialog } from './dialog.hooks.js';
10
10
  export { EmbedChatHeader } from './header.js';
11
11
  const shellStyles = `
@@ -21,25 +21,15 @@ const shellStyles = `
21
21
  * cannot replay effects. Reset remounts the pane after confirmation.
22
22
  * @complexity O(messages + latest reply events) per transcript update; O(message IDs) retained.
23
23
  */
24
- export function EmbedChatWidget(args) {
24
+ export function EmbedChatWidget({ useEmbedChatWidgetHook = useEmbedChatWidget, ...args }) {
25
25
  const { agent, copy, transport, session, keyboard } = args;
26
- const [initial] = useState(() => session.load({}));
27
- const [paneKey, setPaneKey] = useState(0);
28
- const { open, toggle, panelRef, launcherRef, panelId } = useEmbedChatSurface({ initialOpen: initial.open }, { resetKey: paneKey });
29
- const [messages, setMessages] = useState(initial.messages);
30
- useEffect(() => { session.save({ state: { open, messages } }); }, [session, open, messages]);
31
- const reset = useCallback(() => {
32
- session.clear({});
33
- setMessages([]);
34
- setPaneKey(key => key + 1);
35
- }, [session]);
36
- const onMessagesChange = useCallback((next) => { setMessages(next); }, []);
26
+ const { open, toggle, panelRef, launcherRef, panelId, paneKey, messages, reset, onMessagesChange } = useEmbedChatWidgetHook({ session });
37
27
  return _jsxs("div", { className: "jini-chat-embed", children: [_jsx("style", { children: shellStyles }), _jsx("div", { ref: launcherRef, tabIndex: -1, children: _jsx(ChatFab, { open: open, onToggle: toggle, "aria-label": copy.fabLabel, label: copy.fabLabel, "aria-controls": panelId, "aria-haspopup": "dialog" }) }), _jsx(JiniChatProvider, { transport: transport, children: _jsx("div", { id: panelId, className: "jini-chat-embed__panel", hidden: !open, ref: panelRef, role: "dialog", "aria-modal": "true", "aria-label": copy.title, children: _jsx(ChatPane, { transport: transport, agents: [agent], initialSelection: { agentId: agent.id }, initialMessages: messages, title: copy.title, placeholder: copy.placeholder, variant: "embed", header: _jsx(EmbedChatHeader, { title: copy.title, hasMessages: messages.length > 0, onReset: reset, copy: copy, keyboard: keyboard }), onMessagesChange: onMessagesChange }, paneKey) }) })] });
38
28
  }
39
29
  /** Mounts into a host-provided node and returns lifecycle cleanup. O(1) plus React rendering. */
40
- export function mountEmbedChat({ element, widget }) {
30
+ export function mountEmbedChat({ element, widget, surfaces }) {
41
31
  const root = createRoot(element);
42
- root.render(_jsx(EmbedChatWidget, { ...widget }));
32
+ root.render(_jsx(ChatSurfacesProvider, { surfaces: surfaces, children: _jsx(EmbedChatWidget, { ...widget }) }));
43
33
  return { unmount: (_args) => root.unmount() };
44
34
  }
45
35
  //# sourceMappingURL=embed.js.map
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
+ import { useEmbedChatHeader } from './header.hooks.js';
2
3
  export interface EmbedHeaderCopy {
3
4
  readonly eyebrow: string;
4
5
  readonly newThread: string;
@@ -19,5 +20,7 @@ export interface EmbedChatHeaderArgs {
19
20
  readonly closeAction?: ReactNode;
20
21
  }
21
22
  /** Two-step reset with safe initial focus, Cancel and host-wide Escape. O(1) state and listeners. */
22
- export declare function EmbedChatHeader({ title, hasMessages, onReset, copy, keyboard, closeAction }: EmbedChatHeaderArgs): import("react").JSX.Element;
23
+ export declare function EmbedChatHeader({ title, hasMessages, onReset, copy, keyboard, closeAction, useEmbedChatHeaderHook }: EmbedChatHeaderArgs & {
24
+ useEmbedChatHeaderHook?: typeof useEmbedChatHeader;
25
+ }): import("react").JSX.Element;
23
26
  //# sourceMappingURL=header.d.ts.map
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEmbedChatHeader } from './header.hooks.js';
3
3
  /** Two-step reset with safe initial focus, Cancel and host-wide Escape. O(1) state and listeners. */
4
- export function EmbedChatHeader({ title, hasMessages, onReset, copy, keyboard, closeAction }) {
5
- const { confirming, cancel, requestReset, confirmReset, headerRef, resetButtonRef } = useEmbedChatHeader({ hasMessages, onReset, keyboard });
4
+ export function EmbedChatHeader({ title, hasMessages, onReset, copy, keyboard, closeAction, useEmbedChatHeaderHook = useEmbedChatHeader }) {
5
+ const { confirming, cancel, requestReset, confirmReset, headerRef, resetButtonRef } = useEmbedChatHeaderHook({ hasMessages, onReset, keyboard });
6
6
  return _jsxs("div", { className: "jini-chat-pane__header", ref: headerRef, children: [_jsxs("div", { className: "jini-chat-pane__heading", children: [copy.eyebrow && _jsx("span", { className: "jini-chat-pane__eyebrow", children: copy.eyebrow }), _jsx("h2", { className: "jini-chat-pane__title", children: title })] }), confirming ? _jsxs("div", { className: "jini-chat-embed__reset-confirm", children: [_jsx("button", { type: "button", className: "jini-chat-embed__reset-cancel", autoFocus: true, onClick: cancel, children: copy.cancel }), _jsx("button", { type: "button", className: "jini-chat-pane__new-thread", onClick: confirmReset, children: copy.discard })] }) : _jsx("button", { type: "button", className: "jini-chat-pane__new-thread", ref: resetButtonRef, onClick: requestReset, children: copy.newThread }), closeAction] });
7
7
  }
8
8
  //# sourceMappingURL=header.js.map
@@ -40,11 +40,11 @@ export function createVanillaChatController(args, _options = {}) {
40
40
  state = { ...state, messages: state.messages.map(message => message.id === reply.id ? next : message) };
41
41
  publish({ persist });
42
42
  };
43
- const fail = (error) => {
43
+ const fail = (_error) => {
44
44
  if (!current())
45
45
  return;
46
46
  failed = true;
47
- state = { ...state, error: error.message };
47
+ state = { ...state, error: 'The message could not be sent to the agent; send it again.' };
48
48
  updateReply({ ...reply, content: assistantContentFromEvents({ events }), events: [...events], runStatus: 'failed' });
49
49
  };
50
50
  const done = (final) => {
@@ -1,4 +1,4 @@
1
- .jini-chat-vanilla{display:var(--jini-floating-ui-display,block)}.jini-chat-bubble{position:fixed;right:var(--jini-embed-right,24px);bottom:24px;width:56px;height:56px;border:0;border-radius:50%;background:var(--jini-chat-accent,var(--color-primary,#2563eb));color:var(--jini-chat-accent-text,#fff);box-shadow:0 4px 16px #0003;cursor:pointer;z-index:var(--jini-embed-z-index,1000);display:var(--jini-floating-ui-display,grid);place-items:center}
1
+ .jini-chat-vanilla{display:var(--jini-floating-ui-display,block)}.jini-chat-bubble{position:fixed;right:var(--jini-embed-right,24px);bottom:24px;width:56px;height:56px;border:0;border-radius:50%;background:var(--jini-chat-accent,#2563eb);color:var(--jini-chat-accent-text,#fff);box-shadow:0 4px 16px #0003;cursor:pointer;z-index:var(--jini-embed-z-index,1000);display:var(--jini-floating-ui-display,grid);place-items:center}
2
2
  .jini-chat-bubble[hidden]{display:none!important}
3
3
  .jini-chat-bubble svg{width:24px;height:24px}
4
4
  .jini-chat-bubble:focus-visible{outline:3px solid var(--jini-chat-accent,#2563eb);outline-offset:3px}
@@ -8,8 +8,8 @@
8
8
  .jini-chat-vanilla [hidden]{display:none!important}
9
9
  .jini-chat-vanilla svg{width:24px;height:24px}
10
10
  .jini-chat-vanilla :focus-visible{outline:3px solid var(--jini-chat-accent,#2563eb);outline-offset:3px}
11
- .jini-chat-vanilla{font:14px/1.5 var(--font-body,system-ui,sans-serif);color:var(--jini-chat-text,var(--color-text,CanvasText))}
12
- .jini-chat-vanilla__panel{position:fixed;right:var(--jini-embed-right,24px);bottom:88px;width:min(var(--jini-embed-width,440px),calc(100vw - 32px));height:min(var(--jini-embed-height,620px),calc(100dvh - 120px));z-index:var(--jini-embed-z-index,1000);display:flex;flex-direction:column;background:var(--jini-chat-background,var(--color-background,Canvas));border:1px solid var(--jini-chat-border,#767676);border-radius:16px;box-shadow:0 12px 48px #0003;overflow:hidden}
11
+ .jini-chat-vanilla{font:14px/1.5 var(--jini-chat-font-body,system-ui,sans-serif);color:var(--jini-chat-text,CanvasText)}
12
+ .jini-chat-vanilla__panel{position:fixed;right:var(--jini-embed-right,24px);bottom:88px;width:min(var(--jini-embed-width,440px),calc(100vw - 32px));height:min(var(--jini-embed-height,620px),calc(100dvh - 120px));z-index:var(--jini-embed-z-index,1000);display:flex;flex-direction:column;background:var(--jini-chat-background,Canvas);border:1px solid var(--jini-chat-border,#767676);border-radius:16px;box-shadow:0 12px 48px #0003;overflow:hidden}
13
13
  .jini-chat-vanilla__header,.jini-chat-vanilla__composer,.jini-chat-vanilla__confirmation,.jini-chat-vanilla__tool-confirmation{display:flex;align-items:center;gap:8px;padding:12px;border-bottom:1px solid var(--jini-chat-border,#767676)}
14
14
  .jini-chat-vanilla__title{flex:1}
15
15
  .jini-chat-vanilla__button{font:inherit;color:inherit;background:transparent;border:1px solid var(--jini-chat-border,#767676);border-radius:8px;padding:6px 10px;cursor:pointer}
@@ -19,7 +19,7 @@
19
19
  .jini-chat-vanilla__message--user{white-space:pre-wrap;padding:10px;border-radius:8px;background:var(--jini-chat-user-background,#8882)}
20
20
  .jini-chat-vanilla__message p{margin:0 0 8px}
21
21
  .jini-chat-vanilla__message pre{overflow:auto;padding:8px;background:#8882;border-radius:8px}
22
- .jini-chat-vanilla__message a{color:var(--jini-chat-accent,var(--color-primary,#2563eb));text-decoration:underline}
22
+ .jini-chat-vanilla__message a{color:var(--jini-chat-accent,#2563eb);text-decoration:underline}
23
23
  .jini-chat-vanilla__input{flex:1;min-width:0;resize:none;font:inherit;font-size:16px;color:inherit;background:transparent;border:1px solid var(--jini-chat-border,#767676);border-radius:8px;padding:8px}
24
24
  .jini-chat-vanilla__status,.jini-chat-vanilla__error{padding:0 12px}
25
25
  .jini-chat-vanilla__error{color:var(--jini-chat-error,#b91c1c)}
@@ -1,5 +1,8 @@
1
- import { type InteractiveUiRegistry } from '@jini-ai/ui/interactive-ui';
1
+ import type { Clock } from '@jini-ai/core/primitives';
2
+ import { useChatSurfaces, type ChatSurfaceRegistry } from '../surfaces.js';
2
3
  import type { ExtEventRenderProps } from '../ext-event-renderer-registry.js';
4
+ import { useT } from '../hooks/context.js';
5
+ import { useA2uiSurfaceCard } from './A2uiSurfaceCard.hooks.js';
3
6
  /**
4
7
  * What a host reports back after attempting to deliver an agent-directed action. Returned (not
5
8
  * thrown) because a delivery failure here is routine, not exceptional — a closed exchange, a
@@ -13,9 +16,11 @@ export type A2uiAgentActionOutcome = {
13
16
  readonly reason: string;
14
17
  };
15
18
  export interface A2uiSurfaceCardProps extends ExtEventRenderProps {
16
- /** Host registry used for both wire validation and rendering. Defaults to ui's built-ins.
19
+ /** Host clock port; the card derives action ids and interpreter timing from it. */
20
+ clock: Clock;
21
+ /** Host registry used for both wire validation and rendering. Defaults to the host's `surfaces.interactiveUi.defaultRegistry`.
17
22
  * Supply a stable registry for the card's lifetime; remount the card to switch catalogs. */
18
- registry?: Pick<InteractiveUiRegistry, 'list' | 'resolveById'>;
23
+ registry?: Pick<ChatSurfaceRegistry, 'list' | 'resolveById'>;
19
24
  /**
20
25
  * Called when a rendered surface produces a `message`-shaped action meant for the agent (as
21
26
  * opposed to a `local` client-side function call, which this component already resolves and
@@ -34,6 +39,15 @@ export interface A2uiSurfaceCardProps extends ExtEventRenderProps {
34
39
  */
35
40
  onAgentAction?: (runId: string | undefined, message: unknown) => void | Promise<A2uiAgentActionOutcome>;
36
41
  }
42
+ /** Hooks A2uiSurfaceCard calls; defaults to the real ones, a test hands in fakes. */
43
+ export declare const defaultA2uiSurfaceCardHooks: {
44
+ useT: typeof useT;
45
+ useChatSurfaces: typeof useChatSurfaces;
46
+ useA2uiSurfaceCard: typeof useA2uiSurfaceCard;
47
+ };
48
+ export type A2uiSurfaceCardHooks = typeof defaultA2uiSurfaceCardHooks;
37
49
  /** Registered against `ext-event-renderer-registry.ts`'s `'a2ui'` name — see module doc. */
38
- export declare function A2uiSurfaceCard({ events, runId, onAgentAction, registry }: A2uiSurfaceCardProps): import("react").JSX.Element;
50
+ export declare function A2uiSurfaceCard({ events, runId, onAgentAction, clock, registry: registryProp, hooks }: A2uiSurfaceCardProps & {
51
+ hooks?: A2uiSurfaceCardHooks | undefined;
52
+ }): import("react").JSX.Element;
39
53
  //# sourceMappingURL=A2uiSurfaceCard.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { type A2uiInterpreter } from '@jini-ai/protocol/a2ui';
2
+ import type { Clock } from '@jini-ai/core/primitives';
3
+ import { type ChatSurfaceRegistry } from '../surfaces.js';
4
+ import type { useT } from '../hooks/context.js';
5
+ import type { A2uiSurfaceCardProps } from './A2uiSurfaceCard.js';
6
+ export interface RenderComponentProps {
7
+ interpreter: A2uiInterpreter;
8
+ surfaceId: string;
9
+ componentId: string;
10
+ ancestors: ReadonlySet<string>;
11
+ onAction: (componentId: string) => void;
12
+ registry: Pick<ChatSurfaceRegistry, 'list' | 'resolveById'>;
13
+ }
14
+ /** Apply streamed surface events and report local or agent action outcomes. */
15
+ export declare function useA2uiSurfaceCard({ events, runId, onAgentAction, registry, t, clock }: {
16
+ clock: Clock;
17
+ events: A2uiSurfaceCardProps['events'];
18
+ runId: A2uiSurfaceCardProps['runId'];
19
+ onAgentAction: A2uiSurfaceCardProps['onAgentAction'];
20
+ registry: NonNullable<A2uiSurfaceCardProps['registry']>;
21
+ t: ReturnType<typeof useT>;
22
+ }, _options?: {}): {
23
+ interpreter: A2uiInterpreter;
24
+ surfaceId: string | undefined;
25
+ root: import("@jini-ai/protocol/a2ui").ComponentInstance | undefined;
26
+ refusalNotice: string | null;
27
+ pendingAgentAction: string | null;
28
+ localActionResult: {
29
+ componentId: string;
30
+ value: unknown;
31
+ } | null;
32
+ deliveryFailureNotice: string | null;
33
+ handleAction: (componentId: string) => void;
34
+ formatLocalActionValue: (value: unknown) => string;
35
+ };
36
+ //# sourceMappingURL=A2uiSurfaceCard.hooks.d.ts.map