@jini-ai/chat 0.7.1 → 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 (198) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +3 -3
  3. package/dist/contracts/chat-bubble-style.d.ts +1 -1
  4. package/dist/contracts/chat-bubble-style.js +1 -1
  5. package/dist/core/ag-ui/event-projection.d.ts +125 -0
  6. package/dist/core/ag-ui/event-projection.js +275 -0
  7. package/dist/core/ag-ui/event-reduction.d.ts +39 -0
  8. package/dist/core/ag-ui/event-reduction.js +99 -0
  9. package/dist/core/ag-ui/run-input.d.ts +53 -0
  10. package/dist/core/ag-ui/run-input.js +87 -0
  11. package/dist/core/agentic/chat-capabilities.d.ts +1 -1
  12. package/dist/core/agentic/index.d.ts +2 -4
  13. package/dist/core/agentic/index.js +2 -3
  14. package/dist/core/agents-port.d.ts +50 -0
  15. package/dist/core/agents-port.js +2 -0
  16. package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
  17. package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
  18. package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
  19. package/dist/core/assistant-client/ag-ui-transport.js +167 -145
  20. package/dist/core/assistant-client/attachment-liveness.js +13 -11
  21. package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
  22. package/dist/core/assistant-client/durable-run-subscription.js +6 -5
  23. package/dist/core/assistant-client/messages.d.ts +7 -4
  24. package/dist/core/assistant-client/messages.js +5 -4
  25. package/dist/core/assistant-client/transport.d.ts +1 -1
  26. package/dist/core/assistant-client/transport.js +4 -4
  27. package/dist/core/index.d.ts +2 -0
  28. package/dist/core/index.js +1 -0
  29. package/dist/core/page-port.d.ts +15 -0
  30. package/dist/core/page-port.js +2 -0
  31. package/dist/core/run-activity.js +1 -1
  32. package/dist/core/run-events/entry.js +1 -0
  33. package/dist/core/user-text-redaction.d.ts +1 -3
  34. package/dist/core/user-text-redaction.js +3 -61
  35. package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
  36. package/dist/embed-widget/browser/agent-inventory.js +36 -0
  37. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
  38. package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
  39. package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
  40. package/dist/embed-widget/react/dialog.hooks.js +15 -0
  41. package/dist/embed-widget/react/embed.d.ts +7 -2
  42. package/dist/embed-widget/react/embed.js +6 -16
  43. package/dist/embed-widget/react/header.d.ts +4 -1
  44. package/dist/embed-widget/react/header.js +2 -2
  45. package/dist/embed-widget/vanilla/state.js +2 -2
  46. package/dist/embed-widget/vanilla/style.css +4 -4
  47. package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
  48. package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
  49. package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
  50. package/dist/react/components/A2uiSurfaceCard.js +14 -227
  51. package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
  52. package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
  53. package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
  54. package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
  55. package/dist/react/components/AttachmentPreviewModal.js +11 -9
  56. package/dist/react/components/AttachmentTray.d.ts +11 -1
  57. package/dist/react/components/AttachmentTray.js +12 -8
  58. package/dist/react/components/ChatFab.d.ts +10 -1
  59. package/dist/react/components/ChatFab.js +2 -2
  60. package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
  61. package/dist/react/components/ChatSettingsDialog.js +9 -6
  62. package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
  63. package/dist/react/components/ChatSettingsSegmented.js +1 -1
  64. package/dist/react/components/Composer.d.ts +9 -1
  65. package/dist/react/components/Composer.hooks.d.ts +79 -0
  66. package/dist/react/components/Composer.hooks.js +336 -0
  67. package/dist/react/components/Composer.js +40 -341
  68. package/dist/react/components/ComposerDiscovery.js +1 -1
  69. package/dist/react/components/ConversationList.d.ts +34 -1
  70. package/dist/react/components/ConversationList.hooks.d.ts +37 -0
  71. package/dist/react/components/ConversationList.hooks.js +177 -1
  72. package/dist/react/components/ConversationList.js +7 -174
  73. package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
  74. package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
  75. package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
  76. package/dist/react/components/ConversationTitleEditor.js +11 -34
  77. package/dist/react/components/CopyMessageButton.d.ts +6 -1
  78. package/dist/react/components/CopyMessageButton.js +4 -4
  79. package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
  80. package/dist/react/components/ExtEventErrorBoundary.js +5 -3
  81. package/dist/react/components/FolderChips.d.ts +11 -1
  82. package/dist/react/components/FolderChips.hooks.d.ts +12 -0
  83. package/dist/react/components/FolderChips.hooks.js +10 -0
  84. package/dist/react/components/FolderChips.js +9 -9
  85. package/dist/react/components/Markdown.js +7 -5
  86. package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
  87. package/dist/react/components/McpUiSurfaceCard.js +29 -16
  88. package/dist/react/components/MessageList.d.ts +10 -1
  89. package/dist/react/components/MessageList.hooks.js +4 -2
  90. package/dist/react/components/MessageList.js +12 -8
  91. package/dist/react/components/MessageRow.d.ts +46 -2
  92. package/dist/react/components/MessageRow.hooks.d.ts +60 -0
  93. package/dist/react/components/MessageRow.hooks.js +94 -0
  94. package/dist/react/components/MessageRow.js +53 -113
  95. package/dist/react/components/MidRunUserMessage.d.ts +6 -1
  96. package/dist/react/components/MidRunUserMessage.js +5 -5
  97. package/dist/react/components/NextStepActions.d.ts +3 -1
  98. package/dist/react/components/NextStepActions.js +3 -3
  99. package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
  100. package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
  101. package/dist/react/components/QuestionForm.d.ts +6 -0
  102. package/dist/react/components/QuestionForm.js +23 -261
  103. package/dist/react/components/QuestionForm.values.d.ts +22 -0
  104. package/dist/react/components/QuestionForm.values.js +58 -0
  105. package/dist/react/components/QuestionFormField.d.ts +17 -0
  106. package/dist/react/components/QuestionFormField.js +114 -0
  107. package/dist/react/components/QuestionsPanel.d.ts +3 -1
  108. package/dist/react/components/QuestionsPanel.js +7 -3
  109. package/dist/react/components/SentAttachment.d.ts +11 -2
  110. package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
  111. package/dist/react/components/SentAttachment.hooks.js +6 -5
  112. package/dist/react/components/SentAttachment.js +5 -3
  113. package/dist/react/components/TodoCard.d.ts +3 -1
  114. package/dist/react/components/TodoCard.js +9 -4
  115. package/dist/react/components/ToolCallGroup.d.ts +11 -1
  116. package/dist/react/components/ToolCallGroup.js +10 -4
  117. package/dist/react/components/ToolCard.d.ts +6 -1
  118. package/dist/react/components/ToolCard.js +79 -69
  119. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  120. package/dist/react/components/mcp-ui-question-input.js +3 -3
  121. package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
  122. package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
  123. package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
  124. package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
  125. package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
  126. package/dist/react/features/chat-pane/claude/model-options.js +2 -0
  127. package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
  128. package/dist/react/features/chat-pane/codex/model-options.js +2 -0
  129. package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
  130. package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
  131. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
  132. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
  133. package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
  134. package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
  135. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
  136. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
  137. package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
  138. package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
  139. package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
  140. package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
  141. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
  142. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
  143. package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
  144. package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
  145. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
  146. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
  147. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
  148. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
  149. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
  150. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
  151. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
  152. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
  153. package/dist/react/features/chat-pane/model-options.js +7 -4
  154. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  155. package/dist/react/features/chat-pane/styles.js +14 -14
  156. package/dist/react/features/chat-pane/types.d.ts +29 -1
  157. package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
  158. package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
  159. package/dist/react/hooks/attachment-preview-cache.js +1 -1
  160. package/dist/react/hooks/fab-position.js +16 -18
  161. package/dist/react/hooks/useConversation.d.ts +6 -1
  162. package/dist/react/hooks/useConversation.js +11 -10
  163. package/dist/react/hooks/useRunStream.d.ts +3 -0
  164. package/dist/react/hooks/useRunStream.js +12 -12
  165. package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
  166. package/dist/react/hooks/useSurfaceRecovery.js +2 -2
  167. package/dist/react/index.d.ts +6 -3
  168. package/dist/react/index.js +5 -3
  169. package/dist/react/styles/chat-settings.css +9 -9
  170. package/dist/react/surfaces.d.ts +91 -0
  171. package/dist/react/surfaces.js +28 -0
  172. package/dist/server/durable-runs/recover.d.ts +4 -3
  173. package/dist/server/durable-runs/recover.js +4 -3
  174. package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
  175. package/dist/store/legacy/sqlite/conversations.js +1 -1
  176. package/dist/store/legacy/sqlite/messages.d.ts +2 -3
  177. package/dist/store/legacy/sqlite/messages.js +6 -6
  178. package/dist/store/pglite/index.d.ts +7 -7
  179. package/dist/store/pglite/index.js +1 -1
  180. package/dist/store/ports.d.ts +5 -2
  181. package/dist/store/postgres/index.d.ts +7 -7
  182. package/dist/store/postgres/index.js +1 -1
  183. package/dist/store/runtime/chat-expiry-sweep.js +2 -4
  184. package/dist/store/runtime/chat-history-store.js +2 -3
  185. package/dist/store/runtime/durable-run-store.js +16 -2
  186. package/dist/store/runtime/history-tools.js +33 -11
  187. package/dist/store/runtime/kernel.d.ts +3 -2
  188. package/dist/store/runtime/run-ledger.js +2 -2
  189. package/dist/store/sql/boundary.d.ts +5 -5
  190. package/dist/store/sql/maintenance.d.ts +3 -2
  191. package/dist/store/sql/store.d.ts +16 -8
  192. package/dist/store/sql/store.js +31 -14
  193. package/dist/store/sqlite/index.d.ts +11 -12
  194. package/dist/store/sqlite/index.js +5 -5
  195. package/dist/store/sqlite/schema.d.ts +1 -1
  196. package/package.json +46 -24
  197. package/dist/core/ag-ui/entry.d.ts +0 -84
  198. package/dist/core/ag-ui/entry.js +0 -225
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/chat",
3
- "version": "0.7.1",
3
+ "version": "0.7.3-next.1",
4
4
  "description": "Jini's chat/artifact frontend, consolidated into one package with two subpaths: framework-free chat vocabulary and pure parsers in `/core`, headless hooks + presentational components + slots in `/react`. Import only the layer you need.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -27,12 +27,15 @@
27
27
  "./store/legacy/sqlite": "node",
28
28
  "./core/run-events": "universal",
29
29
  "./core/ag-ui": "universal",
30
+ "./core/ag-ui/reduction": "universal",
31
+ "./server/ag-ui/run-input": "universal",
30
32
  "./server/run-finalizer": "universal",
31
33
  "./react/embed": "browser",
32
34
  "./transports/fetch-sse": "universal",
33
35
  "./transports/http": "universal",
34
36
  "./transports/ag-ui": "universal",
35
37
  "./browser/session-store": "browser",
38
+ "./browser/agent-inventory": "browser",
36
39
  "./server/durable-runs": "node",
37
40
  "./store/runtime": "node",
38
41
  "./vanilla": "browser",
@@ -63,7 +66,6 @@
63
66
  "@radix-ui/react-select": "opt-in: interactive ui controls; import @jini-ai/chat/react — Interactive UI controls could not load @radix-ui/react-select. Install @radix-ui/react-select to enable this feature, or check its installed version and native binaries.",
64
67
  "@radix-ui/react-slot": "opt-in: interactive ui controls — Interactive UI controls could not load @radix-ui/react-slot. Install @radix-ui/react-slot to enable this feature, or check its installed version and native binaries.",
65
68
  "@jini-ai/agent-runtime": "opt-in: agent execution adapters; import @jini-ai/chat/react — Agent execution adapters could not load @jini-ai/agent-runtime. Install @jini-ai/agent-runtime to enable this feature, or check its installed version and native binaries.",
66
- "@jini-ai/protocol": "opt-in: agent protocol adapters; import @jini-ai/chat/server/durable-runs — Agent protocol adapters could not load @jini-ai/protocol. Install @jini-ai/protocol to enable this feature, or check its installed version and native binaries.",
67
69
  "@jini-ai/ui": "opt-in: ui integrations; import @jini-ai/chat/react — UI integrations could not load @jini-ai/ui. Install @jini-ai/ui to enable this feature, or check its installed version and native binaries.",
68
70
  "react": "opt-in: react chat ui; import @jini-ai/chat/react — React chat UI could not load react. Install react to enable this feature, or check its installed version.",
69
71
  "react-dom": "opt-in: react chat ui; import @jini-ai/chat/react — React chat UI could not load react-dom. Install react-dom to enable this feature, or check its installed version."
@@ -134,9 +136,19 @@
134
136
  "default": "./dist/core/run-events/entry.js"
135
137
  },
136
138
  "./core/ag-ui": {
137
- "types": "./dist/core/ag-ui/entry.d.ts",
138
- "import": "./dist/core/ag-ui/entry.js",
139
- "default": "./dist/core/ag-ui/entry.js"
139
+ "types": "./dist/core/ag-ui/event-projection.d.ts",
140
+ "import": "./dist/core/ag-ui/event-projection.js",
141
+ "default": "./dist/core/ag-ui/event-projection.js"
142
+ },
143
+ "./core/ag-ui/reduction": {
144
+ "types": "./dist/core/ag-ui/event-reduction.d.ts",
145
+ "import": "./dist/core/ag-ui/event-reduction.js",
146
+ "default": "./dist/core/ag-ui/event-reduction.js"
147
+ },
148
+ "./server/ag-ui/run-input": {
149
+ "types": "./dist/core/ag-ui/run-input.d.ts",
150
+ "import": "./dist/core/ag-ui/run-input.js",
151
+ "default": "./dist/core/ag-ui/run-input.js"
140
152
  },
141
153
  "./server/run-finalizer": {
142
154
  "types": "./dist/server/run-finalizer/entry.d.ts",
@@ -168,6 +180,11 @@
168
180
  "import": "./dist/embed-widget/browser/session-store.js",
169
181
  "default": "./dist/embed-widget/browser/session-store.js"
170
182
  },
183
+ "./browser/agent-inventory": {
184
+ "types": "./dist/embed-widget/browser/agent-inventory.d.ts",
185
+ "import": "./dist/embed-widget/browser/agent-inventory.js",
186
+ "default": "./dist/embed-widget/browser/agent-inventory.js"
187
+ },
171
188
  "./server/durable-runs": {
172
189
  "types": "./dist/server/durable-runs/entry.d.ts",
173
190
  "import": "./dist/server/durable-runs/entry.js",
@@ -216,10 +233,10 @@
216
233
  },
217
234
  "dependencies": {
218
235
  "kysely": "^0.29.6",
219
- "@jini-ai/diagnostics": "^0.7.1",
220
- "@jini-ai/core": "^0.7.1",
221
- "@jini-ai/agentic": "^0.7.1",
222
- "@jini-ai/db": "^0.7.1"
236
+ "@jini-ai/core": "^0.7.3-next.1",
237
+ "@jini-ai/db": "^0.7.3-next.1",
238
+ "@jini-ai/diagnostics": "^0.7.3-next.1",
239
+ "@jini-ai/protocol": "^0.7.3-next.1"
223
240
  },
224
241
  "peerDependencies": {
225
242
  "react": "^18.3.0 || ^19.0.0",
@@ -234,9 +251,8 @@
234
251
  "@radix-ui/react-radio-group": "^1.4.7",
235
252
  "@radix-ui/react-select": "^2.3.7",
236
253
  "@radix-ui/react-slot": "^1.3.3",
237
- "@jini-ai/agent-runtime": "^0.7.0",
238
- "@jini-ai/protocol": "^0.7.0",
239
- "@jini-ai/ui": "^0.7.0"
254
+ "@jini-ai/agent-runtime": "^0.7.3-next.1",
255
+ "@jini-ai/ui": "^0.7.3-next.1"
240
256
  },
241
257
  "devDependencies": {
242
258
  "@mcp-ui/client": "7.1.1",
@@ -263,14 +279,14 @@
263
279
  "pg": "8.23.0",
264
280
  "@ag-ui/core": "0.0.58",
265
281
  "fast-check": "4.3.0",
266
- "@jini-ai/db": "0.7.1",
267
- "@jini-ai/ui-kit": "^0.7.1",
268
- "@jini-ai/agentic": "^0.7.1",
269
- "@jini-ai/protocol": "^0.7.1",
270
- "@jini-ai/core": "^0.7.1",
271
- "@jini-ai/agent-runtime": "0.7.1",
272
- "@jini-ai/diagnostics": "^0.7.1",
273
- "@jini-ai/ui": "^0.7.1"
282
+ "@jini-ai/ui-kit": "^0.7.3-next.1",
283
+ "@jini-ai/db": "0.7.3-next.1",
284
+ "@jini-ai/agent-runtime": "0.7.3-next.1",
285
+ "@jini-ai/ui": "^0.7.3-next.1",
286
+ "@jini-ai/agentic": "^0.7.3-next.1",
287
+ "@jini-ai/core": "^0.7.3-next.1",
288
+ "@jini-ai/diagnostics": "^0.7.3-next.1",
289
+ "@jini-ai/protocol": "^0.7.3-next.1"
274
290
  },
275
291
  "typesVersions": {
276
292
  "*": {
@@ -302,7 +318,13 @@
302
318
  "./dist/core/run-events/entry.d.ts"
303
319
  ],
304
320
  "core/ag-ui": [
305
- "./dist/core/ag-ui/entry.d.ts"
321
+ "./dist/core/ag-ui/event-projection.d.ts"
322
+ ],
323
+ "core/ag-ui/reduction": [
324
+ "./dist/core/ag-ui/event-reduction.d.ts"
325
+ ],
326
+ "server/ag-ui/run-input": [
327
+ "./dist/core/ag-ui/run-input.d.ts"
306
328
  ],
307
329
  "server/run-finalizer": [
308
330
  "./dist/server/run-finalizer/entry.d.ts"
@@ -322,6 +344,9 @@
322
344
  "browser/session-store": [
323
345
  "./dist/embed-widget/browser/session-store.d.ts"
324
346
  ],
347
+ "browser/agent-inventory": [
348
+ "./dist/embed-widget/browser/agent-inventory.d.ts"
349
+ ],
325
350
  "server/durable-runs": [
326
351
  "./dist/server/durable-runs/entry.d.ts"
327
352
  ],
@@ -373,9 +398,6 @@
373
398
  "@jini-ai/agent-runtime": {
374
399
  "optional": true
375
400
  },
376
- "@jini-ai/protocol": {
377
- "optional": true
378
- },
379
401
  "@jini-ai/ui": {
380
402
  "optional": true
381
403
  },
@@ -1,84 +0,0 @@
1
- /** Pure chat-event to AG-UI projection; lifecycle state belongs to one run.
2
- * This legacy wire reducer is independent of saved-chat reduction: partial tool input remains
3
- * a CUSTOM extension, while media stays in run-event vocabulary and is absent from TOOL_CALL_RESULT.
4
- * Strict interruption ordering closes a message before a tool starts. IDs and custom event names
5
- * are injected, with official AG-UI types authoritative; auth, routes and encoder stay with the host.
6
- * The host emits RUN_STARTED and terminal RUN_FINISHED/RUN_ERROR outside this pure projection. */
7
- import { EventType, type AGUIEvent } from '@ag-ui/core';
8
- import type { AgentEvent } from '../events.js';
9
- export interface EventIdGenerator {
10
- next(args: {
11
- prefix: string;
12
- ordinal: number;
13
- }): string;
14
- }
15
- export interface CustomEventNames {
16
- readonly usage: string;
17
- readonly status: string;
18
- readonly extensionPrefix: string;
19
- }
20
- export interface RunAgentWirePayload {
21
- readonly type: string;
22
- readonly [key: string]: unknown;
23
- }
24
- /** Preserve the legacy AG-UI wire reduction, including partial input as extension events.
25
- * Unlike the saved-chat reducer, this projection carries partial tool-input extensions. */
26
- export declare function reduceAgentWirePayload({ payload }: {
27
- payload: RunAgentWirePayload;
28
- }): AgentEvent | null;
29
- export type AgUiEvent = Extract<AGUIEvent, {
30
- type: EventType.RUN_STARTED | EventType.RUN_FINISHED | EventType.RUN_ERROR | EventType.TEXT_MESSAGE_START | EventType.TEXT_MESSAGE_CONTENT | EventType.TEXT_MESSAGE_END | EventType.REASONING_START | EventType.REASONING_MESSAGE_START | EventType.REASONING_MESSAGE_CONTENT | EventType.REASONING_MESSAGE_END | EventType.REASONING_END | EventType.TOOL_CALL_START | EventType.TOOL_CALL_ARGS | EventType.TOOL_CALL_END | EventType.TOOL_CALL_RESULT | EventType.RAW | EventType.CUSTOM;
31
- }>;
32
- export interface AgUiTranslationState {
33
- openTextMessageId: string | null;
34
- openReasoningMessageId: string | null;
35
- nextId: number;
36
- readonly ids: EventIdGenerator;
37
- readonly customEventNames: CustomEventNames;
38
- }
39
- /** Create isolated per-run translation state with explicit IDs and custom-event wire names. */
40
- export declare function createAgUiTranslationState({ ids, customEventNames }: {
41
- ids: EventIdGenerator;
42
- customEventNames: CustomEventNames;
43
- }): AgUiTranslationState;
44
- /** Emit ordered message/tool lifecycles; a tool call closes the preceding message first. */
45
- export declare function translateAgentEventToAgUi({ event, state }: {
46
- event: AgentEvent;
47
- state: AgUiTranslationState;
48
- }): AgUiEvent[];
49
- /** Close open text/reasoning before the host emits RUN_FINISHED or RUN_ERROR. */
50
- export declare function closeAgUiRun({ state }: {
51
- state: AgUiTranslationState;
52
- }): AgUiEvent[];
53
- /**
54
- * Accumulates `TOOL_CALL_ARGS` deltas by `toolCallId` between a call's `TOOL_CALL_START` and
55
- * `TOOL_CALL_END` — the inverse of `assistant-ag-ui.ts`'s server-side translator, which emits all
56
- * three tool-call events back-to-back for one chat `tool_use` event today, but this side is written
57
- * to accumulate real streamed deltas too (a future daemon driver that streams `tool_input_delta`
58
- * incrementally needs no transport-layer change to render correctly). One instance per run, NOT a
59
- * module-level singleton — the same reasoning `assistant-ag-ui.ts`'s `AgUiTranslationState` gives.
60
- */
61
- export interface AgUiToAgentTranslationState {
62
- toolCalls: Map<string, {
63
- name: string;
64
- argsJson: string;
65
- }>;
66
- readonly customEventNames: CustomEventNames;
67
- }
68
- export declare function createAgUiToAgentTranslationState({ customEventNames }: {
69
- customEventNames: CustomEventNames;
70
- }, _options?: Record<string, never>): AgUiToAgentTranslationState;
71
- /**
72
- * Translates one AG-UI event into zero or more chat-core `AgentEvent`s, threading `state` across
73
- * calls within a single run for tool-call argument accumulation.
74
- *
75
- * `TEXT_MESSAGE_START` preserves an explicit step boundary so two assistant messages cannot fuse
76
- * into one word. End/reasoning markers carry no text. The two cases
77
- * with real internal branching (`TOOL_CALL_END`, `CUSTOM`) and the one with a guard (`TOOL_CALL_ARGS`)
78
- * are pulled into their own named functions above so this switch's own cost is just its case count.
79
- */
80
- export declare function translateAgUiEventToAgentEvent({ event, state }: {
81
- event: AgUiEvent;
82
- state: AgUiToAgentTranslationState;
83
- }, _options?: Record<string, never>): AgentEvent[];
84
- //# sourceMappingURL=entry.d.ts.map
@@ -1,225 +0,0 @@
1
- /** Pure chat-event to AG-UI projection; lifecycle state belongs to one run.
2
- * This legacy wire reducer is independent of saved-chat reduction: partial tool input remains
3
- * a CUSTOM extension, while media stays in run-event vocabulary and is absent from TOOL_CALL_RESULT.
4
- * Strict interruption ordering closes a message before a tool starts. IDs and custom event names
5
- * are injected, with official AG-UI types authoritative; auth, routes and encoder stay with the host.
6
- * The host emits RUN_STARTED and terminal RUN_FINISHED/RUN_ERROR outside this pure projection. */
7
- import { EventType } from '@ag-ui/core';
8
- function asString(v) {
9
- if (typeof v === "string")
10
- return v;
11
- return v == null ? "" : JSON.stringify(v);
12
- }
13
- function reduceUsagePayload(payload) {
14
- const usage = (payload.usage ?? {});
15
- return {
16
- kind: "usage",
17
- ...(typeof usage.input_tokens === "number" ? { inputTokens: usage.input_tokens } : {}),
18
- ...(typeof usage.output_tokens === "number" ? { outputTokens: usage.output_tokens } : {}),
19
- ...(typeof payload.costUsd === "number" ? { costUsd: payload.costUsd } : {}),
20
- ...(typeof payload.cumulativeCostUsd === "number" ? { cumulativeCostUsd: payload.cumulativeCostUsd } : {}),
21
- ...(typeof payload.costSessionId === "string" ? { costSessionId: payload.costSessionId } : {}),
22
- ...(typeof payload.durationMs === "number" ? { durationMs: payload.durationMs } : {}),
23
- };
24
- }
25
- const WIRE_PAYLOAD_REDUCERS = {
26
- status: (payload) => ({ kind: "status", label: asString(payload.label), ...(payload.detail ? { detail: asString(payload.detail) } : {}) }),
27
- text_delta: (payload) => ({ kind: "text", text: asString(payload.delta) }),
28
- thinking_delta: (payload) => ({ kind: "thinking", text: asString(payload.delta) }),
29
- tool_use: (payload) => ({ kind: "tool_use", id: asString(payload.id), name: asString(payload.name), input: payload.input }),
30
- tool_result: (payload) => ({
31
- kind: "tool_result",
32
- toolUseId: asString(payload.toolUseId),
33
- content: asString(payload.content),
34
- isError: Boolean(payload.isError),
35
- }),
36
- usage: reduceUsagePayload,
37
- raw: (payload) => ({ kind: "raw", line: asString(payload.line) }),
38
- "mcp-ui": (payload) => ({ kind: "ext", name: "mcp-ui", data: payload.resource }),
39
- a2ui: (payload) => ({ kind: "ext", name: "a2ui", data: payload.message }),
40
- thinking_start: () => null,
41
- };
42
- /** Preserve the legacy AG-UI wire reduction, including partial input as extension events.
43
- * Unlike the saved-chat reducer, this projection carries partial tool-input extensions. */
44
- export function reduceAgentWirePayload({ payload }) {
45
- const reducer = Object.hasOwn(WIRE_PAYLOAD_REDUCERS, payload.type) ? WIRE_PAYLOAD_REDUCERS[payload.type] : undefined;
46
- return reducer ? reducer(payload) : { kind: "ext", name: payload.type, data: payload };
47
- }
48
- /** Create isolated per-run translation state with explicit IDs and custom-event wire names. */
49
- export function createAgUiTranslationState({ ids, customEventNames }) {
50
- return { openTextMessageId: null, openReasoningMessageId: null, nextId: 0, ids, customEventNames: { ...customEventNames } };
51
- }
52
- function mintId(state, prefix) {
53
- state.nextId += 1;
54
- return state.ids.next({ prefix, ordinal: state.nextId });
55
- }
56
- function closeOpenMessages(state) {
57
- const events = [];
58
- if (state.openTextMessageId) {
59
- events.push({ type: EventType.TEXT_MESSAGE_END, messageId: state.openTextMessageId });
60
- state.openTextMessageId = null;
61
- }
62
- if (state.openReasoningMessageId) {
63
- const messageId = state.openReasoningMessageId;
64
- events.push({ type: EventType.REASONING_MESSAGE_END, messageId });
65
- events.push({ type: EventType.REASONING_END, messageId });
66
- state.openReasoningMessageId = null;
67
- }
68
- return events;
69
- }
70
- function handleTextAgentEvent(event, state) {
71
- const events = [];
72
- if (state.openReasoningMessageId)
73
- events.push(...closeOpenMessages(state));
74
- if (!state.openTextMessageId) {
75
- state.openTextMessageId = mintId(state, "msg");
76
- events.push({ type: EventType.TEXT_MESSAGE_START, messageId: state.openTextMessageId, role: "assistant" });
77
- }
78
- events.push({ type: EventType.TEXT_MESSAGE_CONTENT, messageId: state.openTextMessageId, delta: event.text });
79
- return events;
80
- }
81
- function handleThinkingAgentEvent(event, state) {
82
- const events = [];
83
- if (state.openTextMessageId)
84
- events.push(...closeOpenMessages(state));
85
- if (!state.openReasoningMessageId) {
86
- state.openReasoningMessageId = mintId(state, "reasoning");
87
- events.push({ type: EventType.REASONING_START, messageId: state.openReasoningMessageId });
88
- events.push({ type: EventType.REASONING_MESSAGE_START, messageId: state.openReasoningMessageId, role: "reasoning" });
89
- }
90
- events.push({ type: EventType.REASONING_MESSAGE_CONTENT, messageId: state.openReasoningMessageId, delta: event.text });
91
- return events;
92
- }
93
- function handleToolUseAgentEvent(event, state) {
94
- const events = [];
95
- if (state.openTextMessageId || state.openReasoningMessageId)
96
- events.push(...closeOpenMessages(state));
97
- events.push({ type: EventType.TOOL_CALL_START, toolCallId: event.id, toolCallName: event.name });
98
- events.push({ type: EventType.TOOL_CALL_ARGS, toolCallId: event.id, delta: JSON.stringify(event.input ?? {}) });
99
- events.push({ type: EventType.TOOL_CALL_END, toolCallId: event.id });
100
- return events;
101
- }
102
- /** Emit ordered message/tool lifecycles; a tool call closes the preceding message first. */
103
- export function translateAgentEventToAgUi({ event, state }) {
104
- switch (event.kind) {
105
- case "text":
106
- return handleTextAgentEvent(event, state);
107
- case "thinking":
108
- return handleThinkingAgentEvent(event, state);
109
- case "tool_use":
110
- return handleToolUseAgentEvent(event, state);
111
- case "tool_result":
112
- return [
113
- {
114
- type: EventType.TOOL_CALL_RESULT,
115
- messageId: mintId(state, "tool_result_msg"),
116
- toolCallId: event.toolUseId,
117
- content: event.content,
118
- role: "tool",
119
- },
120
- ];
121
- case "usage":
122
- return [{ type: EventType.CUSTOM, name: state.customEventNames.usage, value: event }];
123
- case "status":
124
- return [{ type: EventType.CUSTOM, name: state.customEventNames.status, value: event }];
125
- case "raw":
126
- return [{ type: EventType.RAW, event: event.line }];
127
- case "ext":
128
- return [{ type: EventType.CUSTOM, name: `${state.customEventNames.extensionPrefix}${event.name}`, value: event.data }];
129
- default: {
130
- const neverEvent = event;
131
- throw new Error(`translateAgentEventToAgUi: unhandled AgentEvent.kind ${JSON.stringify(neverEvent)}`);
132
- }
133
- }
134
- }
135
- /** Close open text/reasoning before the host emits RUN_FINISHED or RUN_ERROR. */
136
- export function closeAgUiRun({ state }) {
137
- return closeOpenMessages(state);
138
- }
139
- export function createAgUiToAgentTranslationState({ customEventNames }, _options = {}) {
140
- return { toolCalls: new Map(), customEventNames: { ...customEventNames } };
141
- }
142
- /** The `TOOL_CALL_ARGS` case of {@link translateAgUiEventToAgentEvent} — accumulates one delta onto
143
- * the in-flight call's buffer, a silent no-op for an id with no matching `TOOL_CALL_START`. Split
144
- * out so this `if` is scored in its own complexity budget rather than the switch's. */
145
- function accumulateToolCallArgs(toolCallId, delta, state) {
146
- const call = state.toolCalls.get(toolCallId);
147
- if (call)
148
- call.argsJson += delta;
149
- }
150
- /** `TEXT_MESSAGE_START` keeps an explicit step boundary so two assistant messages cannot fuse into
151
- * one word; every other unmapped event translates to nothing. Split out so this `if` is scored in
152
- * its own complexity budget rather than the switch's. */
153
- function translateAgUiStepStart({ event }, _options = {}) {
154
- if (event.type !== EventType.TEXT_MESSAGE_START)
155
- return [];
156
- return [{ kind: 'status', code: 'step_start', label: '', data: { messageId: event.messageId } }];
157
- }
158
- /** The `TOOL_CALL_END` case of {@link translateAgUiEventToAgentEvent} — parses the accumulated
159
- * args buffer (already removed from `state` by the caller) into one `tool_use` event, or `[]` for
160
- * an id with no matching `TOOL_CALL_START`. */
161
- function finalizeToolCallAgentEvent(toolCallId, call) {
162
- if (!call)
163
- return [];
164
- let input = {};
165
- try {
166
- input = call.argsJson.length > 0 ? JSON.parse(call.argsJson) : {};
167
- }
168
- catch {
169
- // A malformed/partial args buffer must not throw and drop the whole tool call — the raw
170
- // string is still more useful to a human than nothing.
171
- input = call.argsJson;
172
- }
173
- return [{ kind: "tool_use", id: toolCallId, name: call.name, input }];
174
- }
175
- /** The `CUSTOM` case of {@link translateAgUiEventToAgentEvent}. */
176
- function translateAgUiCustomEvent(event, names) {
177
- // Host-supplied usage/status names: the server's own translator put the ORIGINAL `AgentEvent`
178
- // straight into `.value` (see `assistant-ag-ui.ts`'s `translateAgentEventToAgUi`), so this is
179
- // an exact round trip, not a re-derivation.
180
- if (event.name === names.usage || event.name === names.status)
181
- return [event.value];
182
- if (event.name.startsWith(names.extensionPrefix))
183
- return [{ kind: "ext", name: event.name.slice(names.extensionPrefix.length), data: event.value }];
184
- return [{ kind: "ext", name: event.name, data: event.value }];
185
- }
186
- /**
187
- * Translates one AG-UI event into zero or more chat-core `AgentEvent`s, threading `state` across
188
- * calls within a single run for tool-call argument accumulation.
189
- *
190
- * `TEXT_MESSAGE_START` preserves an explicit step boundary so two assistant messages cannot fuse
191
- * into one word. End/reasoning markers carry no text. The two cases
192
- * with real internal branching (`TOOL_CALL_END`, `CUSTOM`) and the one with a guard (`TOOL_CALL_ARGS`)
193
- * are pulled into their own named functions above so this switch's own cost is just its case count.
194
- */
195
- export function translateAgUiEventToAgentEvent({ event, state }, _options = {}) {
196
- switch (event.type) {
197
- case EventType.TEXT_MESSAGE_CONTENT:
198
- return [{ kind: "text", text: event.delta }];
199
- case EventType.REASONING_MESSAGE_CONTENT:
200
- return [{ kind: "thinking", text: event.delta }];
201
- case EventType.TOOL_CALL_START:
202
- state.toolCalls.set(event.toolCallId, { name: event.toolCallName, argsJson: "" });
203
- return [];
204
- case EventType.TOOL_CALL_ARGS:
205
- accumulateToolCallArgs(event.toolCallId, event.delta, state);
206
- return [];
207
- case EventType.TOOL_CALL_END: {
208
- const call = state.toolCalls.get(event.toolCallId);
209
- state.toolCalls.delete(event.toolCallId);
210
- return finalizeToolCallAgentEvent(event.toolCallId, call);
211
- }
212
- case EventType.TOOL_CALL_RESULT:
213
- // AG-UI's `ToolCallResultEvent` carries no `isError` field (verified against the real schema)
214
- // — a genuine protocol-level fidelity gap, not a translator bug: chat's `isError` flag cannot
215
- // survive the round trip through AG-UI's wire shape, so it always reconstructs as `false`.
216
- return [{ kind: "tool_result", toolUseId: event.toolCallId, content: event.content, isError: false }];
217
- case EventType.RAW:
218
- return [{ kind: "raw", line: asString(event.event) }];
219
- case EventType.CUSTOM:
220
- return translateAgUiCustomEvent(event, state.customEventNames);
221
- default:
222
- return translateAgUiStepStart({ event });
223
- }
224
- }
225
- //# sourceMappingURL=entry.js.map