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

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 (214) 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 +15 -0
  86. package/dist/react/chat-cleanup/ChatCleanupPanel.js +17 -0
  87. package/dist/react/chat-cleanup/chat-cleanup.hooks.d.ts +168 -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 +12 -0
  91. package/dist/react/components/ConversationList.d.ts +14 -5
  92. package/dist/react/components/ConversationList.hooks.d.ts +1 -0
  93. package/dist/react/components/ConversationList.hooks.js +4 -2
  94. package/dist/react/components/ConversationList.js +41 -5
  95. package/dist/react/components/Icon.d.ts +1 -1
  96. package/dist/react/components/Icon.js +2 -0
  97. package/dist/react/components/Markdown.js +6 -6
  98. package/dist/react/components/MarkdownLink.d.ts +25 -0
  99. package/dist/react/components/MarkdownLink.js +17 -0
  100. package/dist/react/components/RoutedA2uiSurfaceCard.d.ts +80 -0
  101. package/dist/react/components/RoutedA2uiSurfaceCard.js +15 -0
  102. package/dist/react/components/ToolCard.d.ts +4 -2
  103. package/dist/react/components/ToolCard.js +46 -4
  104. package/dist/react/components/ToolCard.rules.d.ts +5 -2
  105. package/dist/react/components/ToolCard.rules.js +12 -5
  106. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  107. package/dist/react/components/mcp-ui-surface-state.d.ts +3 -1
  108. package/dist/react/components/mcp-ui-surface-state.js +2 -2
  109. package/dist/react/components/own-link.d.ts +26 -0
  110. package/dist/react/components/own-link.js +36 -0
  111. package/dist/react/features/bridged-chat/create-staged-attachment-uploader.d.ts +7 -0
  112. package/dist/react/features/bridged-chat/create-staged-attachment-uploader.js +26 -0
  113. package/dist/react/features/bridged-chat/hooks/useBridgedChatTransport.hooks.d.ts +12 -0
  114. package/dist/react/features/bridged-chat/hooks/useBridgedChatTransport.hooks.js +60 -0
  115. package/dist/react/features/bridged-chat/index.d.ts +8 -0
  116. package/dist/react/features/bridged-chat/index.js +7 -0
  117. package/dist/react/features/bridged-chat/types.d.ts +49 -0
  118. package/dist/react/features/bridged-chat/types.js +2 -0
  119. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +1 -1
  120. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts +6 -0
  121. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js +101 -59
  122. package/dist/react/features/chat-pane/hooks/useChatPaneNewTabLinks.hooks.d.ts +3 -0
  123. package/dist/react/features/chat-pane/hooks/useChatPaneNewTabLinks.hooks.js +26 -16
  124. package/dist/react/features/chat-pane/model-options.d.ts +3 -1
  125. package/dist/react/features/chat-pane/model-options.js +3 -3
  126. package/dist/react/features/chat-pane/rules.js +4 -3
  127. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  128. package/dist/react/features/chat-pane/styles.js +16 -0
  129. package/dist/react/features/conversation-chat-pane/components/ConversationChatPane.d.ts +10 -0
  130. package/dist/react/features/conversation-chat-pane/components/ConversationChatPane.js +19 -0
  131. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneChat.d.ts +12 -0
  132. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneChat.js +21 -0
  133. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneHeader.d.ts +13 -0
  134. package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneHeader.js +9 -0
  135. package/dist/react/features/conversation-chat-pane/components/ConversationDeleteConfirm.d.ts +12 -0
  136. package/dist/react/features/conversation-chat-pane/components/ConversationDeleteConfirm.js +12 -0
  137. package/dist/react/features/conversation-chat-pane/hooks/useConversationChatPane.hooks.d.ts +7 -0
  138. package/dist/react/features/conversation-chat-pane/hooks/useConversationChatPane.hooks.js +43 -0
  139. package/dist/react/features/conversation-chat-pane/index.d.ts +9 -0
  140. package/dist/react/features/conversation-chat-pane/index.js +8 -0
  141. package/dist/react/features/conversation-chat-pane/rules.d.ts +25 -0
  142. package/dist/react/features/conversation-chat-pane/rules.js +29 -0
  143. package/dist/react/features/conversation-chat-pane/types.d.ts +139 -0
  144. package/dist/react/features/conversation-chat-pane/types.js +2 -0
  145. package/dist/react/features/conversations/conversation-controller.d.ts +16 -0
  146. package/dist/react/features/conversations/conversation-controller.js +280 -0
  147. package/dist/react/features/conversations/hooks/useConversationDeleteConfirmation.hooks.d.ts +15 -0
  148. package/dist/react/features/conversations/hooks/useConversationDeleteConfirmation.hooks.js +33 -0
  149. package/dist/react/features/conversations/hooks/useStoredConversations.hooks.d.ts +16 -0
  150. package/dist/react/features/conversations/hooks/useStoredConversations.hooks.js +36 -0
  151. package/dist/react/features/conversations/index.d.ts +9 -0
  152. package/dist/react/features/conversations/index.js +8 -0
  153. package/dist/react/features/conversations/types.d.ts +120 -0
  154. package/dist/react/features/conversations/types.js +2 -0
  155. package/dist/react/features/voice-input/space-hold-rules.d.ts +65 -0
  156. package/dist/react/features/voice-input/space-hold-rules.js +48 -0
  157. package/dist/react/hooks/testing/fake-transport.d.ts +1 -1
  158. package/dist/react/hooks/useAnsweredCards.d.ts +2 -1
  159. package/dist/react/hooks/useConversation.js +5 -2
  160. package/dist/react/hooks/useExtEventGroups.d.ts +1 -1
  161. package/dist/react/hooks/useRunActivity.d.ts +2 -1
  162. package/dist/react/hooks/useRunStream.d.ts +1 -1
  163. package/dist/react/hooks/useRunStream.js +1 -1
  164. package/dist/react/hooks/useSurfaceRecovery.js +3 -1
  165. package/dist/react/hooks/useToolTimeline.d.ts +2 -1
  166. package/dist/react/index.d.ts +5 -2
  167. package/dist/react/index.js +4 -2
  168. package/dist/react/message-blocks.d.ts +1 -48
  169. package/dist/react/message-blocks.js +47 -0
  170. package/dist/react/styles/chat-settings.css +14 -14
  171. package/dist/server/chat-cleanup-routes.d.ts +56 -0
  172. package/dist/server/chat-cleanup-routes.js +56 -0
  173. package/dist/server/durable-runs/recover.js +193 -171
  174. package/dist/server/run-finalizer/entry.js +133 -110
  175. package/dist/store/legacy/sqlite/conversations.js +29 -17
  176. package/dist/store/pglite/index.d.ts +1 -0
  177. package/dist/store/pglite/index.js +1 -0
  178. package/dist/store/ports.d.ts +12 -0
  179. package/dist/store/postgres/index.d.ts +1 -0
  180. package/dist/store/postgres/index.js +1 -0
  181. package/dist/store/runtime/attempt-base-retention.d.ts +57 -0
  182. package/dist/store/runtime/attempt-base-retention.js +103 -0
  183. package/dist/store/runtime/chat-maintenance.d.ts +16 -0
  184. package/dist/store/runtime/chat-maintenance.js +19 -0
  185. package/dist/store/runtime/chat-principal.d.ts +63 -0
  186. package/dist/store/runtime/chat-principal.js +39 -0
  187. package/dist/store/runtime/checkpoint-delta.d.ts +1 -1
  188. package/dist/store/runtime/durable-run-queries.d.ts +124 -0
  189. package/dist/store/runtime/durable-run-queries.js +122 -0
  190. package/dist/store/runtime/durable-run-store.d.ts +1 -1
  191. package/dist/store/runtime/durable-run-store.js +291 -343
  192. package/dist/store/runtime/entry.d.ts +3 -0
  193. package/dist/store/runtime/entry.js +3 -0
  194. package/dist/store/runtime/events-json.d.ts +1 -1
  195. package/dist/store/runtime/lazy-run-ledger.d.ts +19 -0
  196. package/dist/store/runtime/lazy-run-ledger.js +28 -0
  197. package/dist/store/runtime/run-ledger.d.ts +4 -1
  198. package/dist/store/runtime/run-ledger.js +256 -204
  199. package/dist/store/sql/bulk-deletion.d.ts +36 -0
  200. package/dist/store/sql/bulk-deletion.js +103 -0
  201. package/dist/store/sql/store-queries.d.ts +170 -0
  202. package/dist/store/sql/store-queries.js +212 -0
  203. package/dist/store/sql/store-rows.d.ts +106 -0
  204. package/dist/store/sql/store-rows.js +116 -0
  205. package/dist/store/sql/store-writes.d.ts +46 -0
  206. package/dist/store/sql/store-writes.js +161 -0
  207. package/dist/store/sql/store.d.ts +3 -16
  208. package/dist/store/sql/store.js +58 -428
  209. package/dist/store/sql/tables.d.ts +1 -0
  210. package/dist/store/sqlite/index.d.ts +1 -0
  211. package/dist/store/sqlite/index.js +1 -0
  212. package/dist/store/sqlite/schema.d.ts +1 -1
  213. package/dist/store/sqlite/schema.js +5 -1
  214. package/package.json +171 -20
package/README.md CHANGED
@@ -266,3 +266,52 @@ React hosts can import `@jini-ai/chat/react/styles/chat-settings.css` for
266
266
  colors, controls, keyboard focus, and bounded scrolling. Bind its
267
267
  `--jini-chat-settings-*` custom properties to the host theme when needed; no
268
268
  reference or host stylesheet is required for the settings presentation.
269
+
270
+ ## Wiring
271
+
272
+ `AgentEvent` and `ToolResultMediaBlock` are declared in `@jini-ai/core/contracts/site/chat-core`;
273
+ `./core` imports them and keeps a deprecated type re-export until the next major. Hosts import them
274
+ from core.
275
+
276
+ ### Chat principals (`@jini-ai/chat/store/runtime`)
277
+
278
+ `ChatPrincipal` (`AdminChatPrincipal | GuestChatPrincipal`), `ChatStoreFactory`, `hashSessionKey`,
279
+ `chatExpiryFor` and `GUEST_CHAT_TTL_MS` describe whose history a store holds. The host binds a
280
+ principal to `createChatHistoryStore`'s scope (`scopeId` = `workspaceId`, `ownerKind` = `kind`,
281
+ `ownerId` = `userId` or `hashSessionKey({ sessionKey })`), wraps it with `createRunGuardedChatStore`
282
+ and its own run-id policy and ledger, and hands routes only the resulting `ChatStoreFactory`. Guest
283
+ conversations get `chatExpiryFor({ principal })` as their expiry; admin conversations never expire.
284
+
285
+ ### Chat maintenance and lazy run ledger (`@jini-ai/chat/store/runtime`)
286
+
287
+ `createChatMaintenanceForKernel({ kernel })` picks the SQLite/PGlite/Postgres expiry maintenance by
288
+ the borrowed chat kernel's transport; the host injects only its migrated chat `kernel` and hands
289
+ the result to `sweepExpiredChats`/`startChatExpirySweep` at composition time (never to a scoped
290
+ store). `createLazyChatRunLedger({ peek, open, ledgerFor })` serves a `ChatRunLedger` over a
291
+ database opened on first use: the host injects `open` (opens and memoizes its kernel), `peek`
292
+ (the kernel if already open) and `ledgerFor({ kernel })` (its own ledger, with any wrappers).
293
+ `hasActiveRuns` and `reconcileInterrupted` never open an unopened database.
294
+
295
+ ### Visitor transcript store (`@jini-ai/chat/browser/session-store`)
296
+
297
+ `createBrowserSessionStore({ storage, transcriptKey, maxMessages, maxBytes, validateMessage,
298
+ overCapReads?, onFailure? })` keeps one bounded per-tab transcript envelope. The host injects the
299
+ `storage` port (usually a `sessionStorage` wrapper, which may namespace keys), the key, both caps
300
+ and the message validator. Optional: `overCapReads: 'read'` keeps rehydrating an envelope stored
301
+ over the caps (default `'clear'` treats it as corrupt; writes are capped either way), and
302
+ `onFailure({ operation, error })` receives each swallowed `load` / `decode` / `serialize` / `save` /
303
+ `clear` failure (default: silent). A throw from `onFailure` escapes the call.
304
+
305
+ ### Embed send bridge (`@jini-ai/chat/browser/embed-send-bridge`)
306
+
307
+ An embedding page can drive a mounted widget through `installEmbedSendBridge`. The host decides
308
+ `enabled` and names the events; ordinary visitors get no listener. The host injects `send` (the
309
+ mounted widget's own conversation owner — the bridge never opens a parallel transport),
310
+ `requestEventName` (the CustomEvent dispatched on the mount root with `{ text, done }`),
311
+ `readyMessageType` (posted to the parent frame once listening) and optionally `busyMessage`.
312
+ React widgets pass `agentControl: createEmbedSendAgentControl({ root, enabled, invocationId,
313
+ requestEventName, readyMessageType }, { capabilityId?, unmountedMessage? })` to `ChatPane`, which
314
+ relays each request through the existing `chat.send_message` capability.
315
+ `./core/durable-runs/run-finalizer` holds a host run finalizer's pure slices (checkpoint growth and
316
+ size rules, `reportSafely`, `releaseUnreadBody`, and the `RunTimerPort`/`RunLogPort` types). The host
317
+ injects its timer and log through those ports and keeps the ledger, daemon client and watch state.
@@ -1,5 +1,5 @@
1
- import type { AgentEvent } from './events.js';
2
1
  import type { ChatAttachment, ChatMessage } from './messages.js';
2
+ import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
3
3
  export interface AcceptedChatInput {
4
4
  id: string;
5
5
  text: string;
@@ -7,8 +7,9 @@
7
7
  * are injected, with official AG-UI types authoritative; auth, routes and encoder stay with the host.
8
8
  * The host emits RUN_STARTED and terminal RUN_FINISHED/RUN_ERROR outside this pure projection. */
9
9
  import { EventType, type AGUIEvent, type Interrupt } from '@ag-ui/core';
10
- import type { AgentEvent } from '../events.js';
11
10
  import { type RunNotices } from '../run-events/entry.js';
11
+ import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
12
+ export { confirmationInterrupt, readConfirmationResume, createAgUiPauseStore } from './resume.js';
12
13
  export interface EventIdGenerator {
13
14
  next(args: {
14
15
  prefix: string;
@@ -52,74 +53,18 @@ interface AgUiFrameContext {
52
53
  notices: RunNotices;
53
54
  write: (event: AgUiEvent) => void;
54
55
  }
55
- /** Drains one AG-UI run's daemon frames to completion, writing translated events directly to
56
- * `ctx.res` and ending the response either on an explicit terminal frame, on the stream simply
57
- * closing (same dual-completion posture `consumeByokStream` uses for the identical case), or on a
58
- * read error. Split out of `handleAgUiRun` so the try/catch and its loop don't add to that
59
- * function's own branch count.
60
- * @returns How the run ended, for its agent-run span: a terminal frame's own status (an `end` the
61
- * daemon classified as failed or canceled is that, not `succeeded`); a natural close counts as
62
- * `succeeded`, like the `RUN_FINISHED` it writes; a read error is `failed` with that error. */
63
- export declare function drainRunFramesToAgUi(ctx: AgUiFrameContext): Promise<{
64
- status: "succeeded" | "failed" | "canceled";
56
+ type PauseOn = (required: {
57
+ event: AgUiEvent;
58
+ cursor: string | undefined;
59
+ }, optional: Record<string, never>) => Interrupt | undefined;
60
+ type DrainStatus = "succeeded" | "failed" | "canceled";
61
+ /** Project daemon frames until a verdict, accepted pause, or interruption. Owns reader cleanup. */
62
+ export declare function drainRunFramesToAgUi(ctx: AgUiFrameContext, { interruptionMessage, failureMessage, pauseOn }?: {
63
+ interruptionMessage?: string;
64
+ failureMessage?: string;
65
+ pauseOn?: PauseOn;
66
+ }): Promise<{
67
+ status: DrainStatus;
65
68
  error?: unknown;
66
69
  }>;
67
- export declare function confirmationInterrupt({ threadId, runId, interrupt }: {
68
- threadId: string;
69
- runId: string;
70
- interrupt: Interrupt;
71
- }, _optional?: Record<string, never>): Extract<AgUiEvent, {
72
- type: EventType.RUN_FINISHED;
73
- }>;
74
- export declare function readConfirmationResume({ input, threadId, runId, interruptId }: {
75
- input: unknown;
76
- threadId: string;
77
- runId: string;
78
- interruptId: string;
79
- }, _optional?: Record<string, never>): {
80
- decision: 'allow' | 'deny';
81
- } | undefined;
82
- export declare function createAgUiPauseStore({ caps, nowMs }: {
83
- caps: {
84
- global: number;
85
- perScope: number;
86
- };
87
- nowMs: () => number;
88
- }, _optional?: Record<string, never>): {
89
- park(entry: Parameters<(key: string, value: {
90
- owner: string;
91
- threadId: string;
92
- runId: string;
93
- interruptId: string;
94
- state: unknown;
95
- scopeKey: string;
96
- abandonAtMs: number;
97
- }) => Map<string, {
98
- owner: string;
99
- threadId: string;
100
- runId: string;
101
- interruptId: string;
102
- state: unknown;
103
- scopeKey: string;
104
- abandonAtMs: number;
105
- }>>[1], _optional?: Record<string, never>): boolean;
106
- claim({ owner, threadId, runId, interruptId }: {
107
- owner: string;
108
- threadId: string;
109
- runId: string;
110
- interruptId: string;
111
- }, _optional?: Record<string, never>): {
112
- owner: string;
113
- threadId: string;
114
- runId: string;
115
- interruptId: string;
116
- state: unknown;
117
- scopeKey: string;
118
- abandonAtMs: number;
119
- } | undefined;
120
- remove({ interruptId }: {
121
- interruptId: string;
122
- }, _optional?: Record<string, never>): boolean;
123
- };
124
- export {};
125
70
  //# sourceMappingURL=event-projection.d.ts.map
@@ -6,8 +6,11 @@
6
6
  * reads them back. Strict interruption ordering closes a message before a tool starts. IDs and custom event names
7
7
  * are injected, with official AG-UI types authoritative; auth, routes and encoder stay with the host.
8
8
  * The host emits RUN_STARTED and terminal RUN_FINISHED/RUN_ERROR outside this pure projection. */
9
- import { EventType, InterruptSchema, RunAgentInputSchema } from '@ag-ui/core';
9
+ import { EventType } from '@ag-ui/core';
10
+ import { InterruptSchema } from '@ag-ui/core/schemas';
10
11
  import { readSseFrames, readTerminalReason, translateRunFrame } from '../run-events/entry.js';
12
+ import { confirmationInterrupt } from './resume.js';
13
+ export { confirmationInterrupt, readConfirmationResume, createAgUiPauseStore } from './resume.js';
11
14
  /** Create isolated per-run translation state with explicit IDs and custom-event wire names. */
12
15
  export function createAgUiTranslationState({ ids, customEventNames }) {
13
16
  return { openTextMessageId: null, openReasoningMessageId: null, nextId: 0, ids, customEventNames: { ...customEventNames } };
@@ -113,32 +116,6 @@ export function translateAgentEventToAgUi({ event, state }) {
113
116
  export function closeAgUiRun({ state }) {
114
117
  return closeOpenMessages(state);
115
118
  }
116
- /**
117
- * Hands Jini's `readSseFrames` the daemon response as a stream while this route keeps the reader.
118
- *
119
- * `readSseFrames` takes a stream and holds its only reader until the frames end. The route needs
120
- * its own handle on the daemon response too: the `res.on("close", ...)` hook cancels that reader so
121
- * a client that leaves stops the upstream read at once, not at the daemon's next frame. A
122
- * `ReadableStream` can only have one active reader at a time — a second `body.getReader()` throws
123
- * `TypeError: ReadableStream is locked` — so the route keeps the one reader and Jini pulls through
124
- * it. Cancelling the reader resolves the pending pull as done, which ends the frames the same way
125
- * a daemon close does.
126
- *
127
- * `id:` lines are ignored by the frame reader: this path has no reattach story to resume a cursor
128
- * for.
129
- */
130
- function streamFromReader({ reader }, _optional = {}) {
131
- return new ReadableStream({
132
- async pull(controller) {
133
- const { done, value } = await reader.read();
134
- if (done)
135
- controller.close();
136
- else
137
- controller.enqueue(value);
138
- },
139
- cancel: (reason) => reader.cancel(reason),
140
- });
141
- }
142
119
  /** Writes every event in `events` to `res`, in order — the repeated `for (const e of events)
143
120
  * writeAgUiEvent(res, e)` pattern below, named once so each caller is a flat sequence of
144
121
  * statements rather than its own loop. */
@@ -146,27 +123,33 @@ function writeAllAgUiEvents({ write, events }, _optional = {}) {
146
123
  for (const event of events)
147
124
  write(event);
148
125
  }
149
- /**
150
- * Writes one translated daemon frame as AG-UI events. Every daemon SSE frame's `data:` line is the
151
- * FULL `RunProtocolEventWire` envelope, not the inner payload; Jini's `translateRunFrame` unwraps
152
- * it, and a frame it cannot read yields no events instead of failing the run.
153
- *
154
- * A terminal frame (`error`, or `end`) first writes its own notices, then closes any open
155
- * message/reasoning segment, then the one terminal event: `RUN_ERROR` for an `error` frame and for
156
- * an `end` the daemon classified as failed, else `RUN_FINISHED` — with reason `cancelled` for an
157
- * `end` the daemon classified as canceled, else the frame's own reason (`stop` when it names none).
158
- *
159
- * @returns the run's final status once a terminal frame has closed it — the caller stops reading
160
- * further frames and ends the response — else `null`.
161
- */
162
- function writeFrameOutcome({ frame, outcome, ctx }, _optional = {}) {
163
- for (const event of outcome.events)
164
- writeAllAgUiEvents({ write: ctx.write, events: translateAgentEventToAgUi({ event, state: ctx.state }) });
126
+ function frameEvent({ event, daemonError, failureMessage }) {
127
+ if (!daemonError || event.kind !== "status")
128
+ return event;
129
+ return { kind: "status", label: failureMessage, ...(event.code ? { code: event.code } : {}) };
130
+ }
131
+ /** Offer each projected event to the host before writing it. A refused card is unchanged. */
132
+ function writeFrameEvents({ frame, outcome, ctx, failureMessage, pauseOn }) {
133
+ const daemonError = Boolean(outcome.error) && !outcome.terminal;
134
+ const projected = outcome.events.flatMap(event => translateAgentEventToAgUi({
135
+ event: frameEvent({ event, daemonError, failureMessage }), state: ctx.state,
136
+ }));
137
+ for (const event of projected) {
138
+ const interrupt = pauseOn?.({ event, cursor: frame.cursor }, {});
139
+ ctx.write(event);
140
+ if (interrupt)
141
+ return interrupt;
142
+ }
143
+ return undefined;
144
+ }
145
+ /** Maps a terminal frame to its closing events and the run's final status; `null` (and nothing
146
+ * written) for a frame that neither errors nor ends the run. */
147
+ function writeFrameTerminal({ frame, outcome, ctx, failureMessage }, _optional = {}) {
165
148
  if (!outcome.error && !outcome.terminal)
166
149
  return null;
167
150
  writeAllAgUiEvents({ write: ctx.write, events: closeAgUiRun({ state: ctx.state }) });
168
151
  if (outcome.error) {
169
- ctx.write({ type: EventType.RUN_ERROR, message: outcome.error.message });
152
+ ctx.write({ type: EventType.RUN_ERROR, message: failureMessage });
170
153
  return "failed";
171
154
  }
172
155
  const canceled = outcome.terminal === "canceled";
@@ -174,102 +157,44 @@ function writeFrameOutcome({ frame, outcome, ctx }, _optional = {}) {
174
157
  ctx.write({ type: EventType.RUN_FINISHED, threadId: ctx.threadId, runId: ctx.runId, result: { reason } });
175
158
  return canceled ? "canceled" : "succeeded";
176
159
  }
177
- /** Drains one AG-UI run's daemon frames to completion, writing translated events directly to
178
- * `ctx.res` and ending the response either on an explicit terminal frame, on the stream simply
179
- * closing (same dual-completion posture `consumeByokStream` uses for the identical case), or on a
180
- * read error. Split out of `handleAgUiRun` so the try/catch and its loop don't add to that
181
- * function's own branch count.
182
- * @returns How the run ended, for its agent-run span: a terminal frame's own status (an `end` the
183
- * daemon classified as failed or canceled is that, not `succeeded`); a natural close counts as
184
- * `succeeded`, like the `RUN_FINISHED` it writes; a read error is `failed` with that error. */
185
- export async function drainRunFramesToAgUi(ctx) {
186
- // One carry per daemon connection, so the later chunks of a split echo line are dropped too.
160
+ function handleFrame({ frame, ctx, carry, failureMessage, pauseOn }) {
161
+ let marked;
162
+ const outcome = translateRunFrame({ kind: frame.event, raw: frame.data, notices: ctx.notices }, {
163
+ carry,
164
+ onAgentPayload: ({ pendingApproval }) => {
165
+ const marker = InterruptSchema.safeParse(pendingApproval);
166
+ // The validator's optional field types include explicit undefined, unlike Interrupt.
167
+ if (marker.success)
168
+ marked = marker.data;
169
+ },
170
+ });
171
+ // The existing daemon marker is control-only. New host parks deliver the ordinary card first.
172
+ const interrupt = marked ?? writeFrameEvents({ frame, outcome, ctx, failureMessage, pauseOn });
173
+ if (!interrupt)
174
+ return writeFrameTerminal({ frame, outcome, ctx, failureMessage });
175
+ writeAllAgUiEvents({ write: ctx.write, events: closeAgUiRun({ state: ctx.state }) });
176
+ ctx.write(confirmationInterrupt({ threadId: ctx.threadId, runId: ctx.runId, interrupt }));
177
+ return "succeeded";
178
+ }
179
+ function writeInterrupted({ ctx, message }) {
180
+ writeAllAgUiEvents({ write: ctx.write, events: closeAgUiRun({ state: ctx.state }) });
181
+ ctx.write({ type: EventType.RUN_ERROR, message });
182
+ }
183
+ /** Project daemon frames until a verdict, accepted pause, or interruption. Owns reader cleanup. */
184
+ export async function drainRunFramesToAgUi(ctx, { interruptionMessage = "The response was interrupted. Try again.", failureMessage = "The run failed. Try again.", pauseOn } = {}) {
187
185
  const carry = {};
188
186
  try {
189
- for await (const frame of readSseFrames({ body: streamFromReader({ reader: ctx.reader }) })) {
190
- const outcome = translateRunFrame({ kind: frame.event, raw: frame.data, notices: ctx.notices }, { carry });
191
- if (frame.event === 'agent' && outcome.events.length > 0) {
192
- const marker = InterruptSchema.safeParse(JSON.parse(frame.data).payload.pendingApproval);
193
- if (marker.success) {
194
- writeAllAgUiEvents({ write: ctx.write, events: closeAgUiRun({ state: ctx.state }) });
195
- ctx.write(confirmationInterrupt({ threadId: ctx.threadId, runId: ctx.runId, interrupt: marker.data }));
196
- return { status: 'succeeded' };
197
- }
198
- }
199
- const status = writeFrameOutcome({ frame, outcome, ctx });
200
- if (status) {
187
+ for await (const frame of readSseFrames({ reader: ctx.reader }, { includeCursor: true })) {
188
+ const status = handleFrame({ frame, ctx, carry, failureMessage, pauseOn });
189
+ if (status)
201
190
  return { status };
202
- }
203
191
  }
204
- writeAllAgUiEvents({ write: ctx.write, events: closeAgUiRun({ state: ctx.state }) });
205
- ctx.write({ type: EventType.RUN_FINISHED, threadId: ctx.threadId, runId: ctx.runId, result: { reason: "stop" } });
206
- return { status: "succeeded" };
207
192
  }
208
193
  catch (error) {
209
- writeAllAgUiEvents({ write: ctx.write, events: closeAgUiRun({ state: ctx.state }) });
210
- ctx.write({ type: EventType.RUN_ERROR, message: error instanceof Error ? error.message : String(error) });
194
+ writeInterrupted({ ctx, message: interruptionMessage });
211
195
  return { status: "failed", error };
212
196
  }
213
- }
214
- export function confirmationInterrupt({ threadId, runId, interrupt }, _optional = {}) {
215
- return { type: EventType.RUN_FINISHED, threadId, runId,
216
- outcome: { type: 'interrupt', interrupts: [{ ...interrupt, reason: 'confirmation' }] } };
217
- }
218
- export function readConfirmationResume({ input, threadId, runId, interruptId }, _optional = {}) {
219
- const parsed = RunAgentInputSchema.safeParse(input);
220
- if (!parsed.success)
221
- return undefined;
222
- const value = parsed.data;
223
- if (value.threadId !== threadId || value.parentRunId !== runId)
224
- return undefined;
225
- if (value.resume?.length !== 1)
226
- return undefined;
227
- const entry = value.resume[0];
228
- if (entry.interruptId !== interruptId)
229
- return undefined;
230
- if (entry.status === 'cancelled')
231
- return { decision: 'deny' };
232
- if (entry.payload === 'allow')
233
- return { decision: 'allow' };
234
- if (['deny', 'dismissed'].includes(entry.payload))
235
- return { decision: 'deny' };
236
- return undefined;
237
- }
238
- export function createAgUiPauseStore({ caps, nowMs }, _optional = {}) {
239
- const records = new Map();
240
- return {
241
- park(entry, _optional = {}) {
242
- const now = nowMs();
243
- let scoped = 0;
244
- for (const [id, record] of records) {
245
- if (record.abandonAtMs <= now)
246
- records.delete(id);
247
- else if (record.scopeKey === entry.scopeKey)
248
- scoped++;
249
- }
250
- if (entry.abandonAtMs <= now || records.has(entry.interruptId))
251
- return false;
252
- if (records.size >= caps.global || scoped >= caps.perScope)
253
- return false;
254
- records.set(entry.interruptId, { ...entry });
255
- return true;
256
- },
257
- claim({ owner, threadId, runId, interruptId }, _optional = {}) {
258
- const record = records.get(interruptId);
259
- if (!record)
260
- return undefined;
261
- if (record.abandonAtMs <= nowMs()) {
262
- records.delete(interruptId);
263
- return undefined;
264
- }
265
- if (record.owner !== owner || record.threadId !== threadId || record.runId !== runId)
266
- return undefined;
267
- records.delete(interruptId);
268
- return record;
269
- },
270
- remove({ interruptId }, _optional = {}) {
271
- return records.delete(interruptId);
272
- },
273
- };
197
+ writeInterrupted({ ctx, message: interruptionMessage });
198
+ return { status: "failed" };
274
199
  }
275
200
  //# sourceMappingURL=event-projection.js.map
@@ -1,5 +1,5 @@
1
- import type { AgentEvent } from '../events.js';
2
1
  import type { AgUiEvent, CustomEventNames } from './event-projection.js';
2
+ import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
3
3
  /**
4
4
  * Accumulates `TOOL_CALL_ARGS` deltas by `toolCallId` between a call's `TOOL_CALL_START` and
5
5
  * `TOOL_CALL_END` — the inverse of `assistant-ag-ui.ts`'s server-side translator, which emits all
@@ -11,6 +11,7 @@ import type { AgUiEvent, CustomEventNames } from './event-projection.js';
11
11
  export interface AgUiToAgentTranslationState {
12
12
  toolCalls: Map<string, AgUiOpenToolCall>;
13
13
  readonly customEventNames: CustomEventNames;
14
+ readonly toolOptions?: ToolDecodeOptions;
14
15
  }
15
16
  /** One call between its `TOOL_CALL_START` and `TOOL_CALL_END`. `toolOrigin` and `bridgeCall` are
16
17
  * the start event's extra fields as received, not yet checked. */
@@ -20,9 +21,17 @@ export interface AgUiOpenToolCall {
20
21
  toolOrigin?: unknown;
21
22
  bridgeCall?: unknown;
22
23
  }
24
+ interface ToolDecodeOptions {
25
+ acceptToolCall?: (required: {
26
+ toolCallId: string;
27
+ toolCallName: string;
28
+ }, optional: Record<string, never>) => boolean;
29
+ maxToolArgsChars?: number;
30
+ }
31
+ /** Start one segment's decoder. Opt-in tool policies drop malformed calls instead of displaying raw arguments. */
23
32
  export declare function createAgUiToAgentTranslationState({ customEventNames }: {
24
33
  customEventNames: CustomEventNames;
25
- }, _options?: Record<string, never>): AgUiToAgentTranslationState;
34
+ }, toolOptions?: ToolDecodeOptions): AgUiToAgentTranslationState;
26
35
  /**
27
36
  * Translates one AG-UI event into zero or more chat-core `AgentEvent`s, threading `state` across
28
37
  * calls within a single run for tool-call argument accumulation.
@@ -36,4 +45,5 @@ export declare function translateAgUiEventToAgentEvent({ event, state }: {
36
45
  event: AgUiEvent;
37
46
  state: AgUiToAgentTranslationState;
38
47
  }, _options?: Record<string, never>): AgentEvent[];
48
+ export {};
39
49
  //# sourceMappingURL=event-reduction.d.ts.map
@@ -5,15 +5,39 @@
5
5
  * the daemon wire accept and ignore exactly the same shapes. */
6
6
  import { EventType } from '@ag-ui/core';
7
7
  import { asString, translateRunAgentPayload } from '../run-events/entry.js';
8
- export function createAgUiToAgentTranslationState({ customEventNames }, _options = {}) {
9
- return { toolCalls: new Map(), customEventNames: { ...customEventNames } };
8
+ /** Read one of the projection's extra fields off a validated event. AG-UI 1.0's generated event
9
+ * types are closed, but its validators stay passthrough (as 0.x's were), so these fields still
10
+ * arrive on the wire; they read as `unknown`, exactly as 0.x's passthrough index signature typed
11
+ * them, and the payload reducer narrows them.
12
+ * @complexity O(1). */
13
+ function readExtraField({ event, key }, _optional = {}) {
14
+ return event[key];
15
+ }
16
+ /** Start one segment's decoder. Opt-in tool policies drop malformed calls instead of displaying raw arguments. */
17
+ export function createAgUiToAgentTranslationState({ customEventNames }, toolOptions = {}) {
18
+ return { toolCalls: new Map(), customEventNames: { ...customEventNames },
19
+ ...(toolOptions.acceptToolCall || toolOptions.maxToolArgsChars !== undefined ? { toolOptions: { ...toolOptions } } : {}) };
20
+ }
21
+ function beginToolCall({ event, state }) {
22
+ const { toolCallId, toolCallName } = event;
23
+ if (state.toolOptions?.acceptToolCall?.({ toolCallId, toolCallName }, {}) === false) {
24
+ state.toolCalls.delete(toolCallId);
25
+ return;
26
+ }
27
+ state.toolCalls.set(toolCallId, { name: toolCallName, argsJson: "",
28
+ toolOrigin: readExtraField({ event, key: "toolOrigin" }), bridgeCall: readExtraField({ event, key: "bridgeCall" }) });
10
29
  }
11
30
  /** The `TOOL_CALL_ARGS` case of {@link translateAgUiEventToAgentEvent} — accumulates one delta onto
12
31
  * the in-flight call's buffer, a silent no-op for an id with no matching `TOOL_CALL_START`. Split
13
32
  * out so this `if` is scored in its own complexity budget rather than the switch's. */
14
33
  function accumulateToolCallArgs({ toolCallId, delta, state }) {
15
34
  const call = state.toolCalls.get(toolCallId);
16
- if (call)
35
+ if (!call)
36
+ return;
37
+ const max = state.toolOptions?.maxToolArgsChars ?? Infinity;
38
+ if (call.argsJson.length + delta.length > max)
39
+ state.toolCalls.delete(toolCallId);
40
+ else
17
41
  call.argsJson += delta;
18
42
  }
19
43
  /** `TEXT_MESSAGE_START` keeps an explicit step boundary so two assistant messages cannot fuse into
@@ -27,16 +51,17 @@ function translateAgUiStepStart({ event }, _options = {}) {
27
51
  /** The `TOOL_CALL_END` case of {@link translateAgUiEventToAgentEvent} — parses the accumulated
28
52
  * args buffer (already removed from `state` by the caller) into one `tool_use` event, or `[]` for
29
53
  * an id with no matching `TOOL_CALL_START`. */
30
- function finalizeToolCallAgentEvent({ toolCallId, call }) {
31
- if (!call)
54
+ function finalizeToolCallAgentEvent({ toolCallId, call, strict }) {
55
+ if (!call || (strict && !call.argsJson))
32
56
  return [];
33
57
  let input = {};
34
58
  try {
35
59
  input = call.argsJson.length > 0 ? JSON.parse(call.argsJson) : {};
36
60
  }
37
61
  catch {
38
- // A malformed/partial args buffer must not throw and drop the whole tool call — the raw
39
- // string is still more useful to a human than nothing.
62
+ if (strict)
63
+ return [];
64
+ // An unbounded display adapter can still show the raw arguments.
40
65
  input = call.argsJson;
41
66
  }
42
67
  return reduced({ payload: { type: "tool_use", id: toolCallId, name: call.name, input, toolOrigin: call.toolOrigin, bridgeCall: call.bridgeCall } });
@@ -73,7 +98,7 @@ export function translateAgUiEventToAgentEvent({ event, state }, _options = {})
73
98
  case EventType.REASONING_MESSAGE_CONTENT:
74
99
  return [{ kind: "thinking", text: event.delta }];
75
100
  case EventType.TOOL_CALL_START:
76
- state.toolCalls.set(event.toolCallId, { name: event.toolCallName, argsJson: "", toolOrigin: event.toolOrigin, bridgeCall: event.bridgeCall });
101
+ beginToolCall({ event, state });
77
102
  return [];
78
103
  case EventType.TOOL_CALL_ARGS:
79
104
  accumulateToolCallArgs({ toolCallId: event.toolCallId, delta: event.delta, state });
@@ -81,13 +106,13 @@ export function translateAgUiEventToAgentEvent({ event, state }, _options = {})
81
106
  case EventType.TOOL_CALL_END: {
82
107
  const call = state.toolCalls.get(event.toolCallId);
83
108
  state.toolCalls.delete(event.toolCallId);
84
- return finalizeToolCallAgentEvent({ toolCallId: event.toolCallId, call });
109
+ return finalizeToolCallAgentEvent({ toolCallId: event.toolCallId, call, strict: state.toolOptions !== undefined });
85
110
  }
86
111
  case EventType.TOOL_CALL_RESULT:
87
112
  // AG-UI's `ToolCallResultEvent` has no standard `isError`, `media` or `outcome` field. The
88
113
  // projection writes them as extra fields; a server that sends none (an older one, or another
89
114
  // AG-UI server) reads as a plain successful result, as before.
90
- return reduced({ payload: { type: "tool_result", toolUseId: event.toolCallId, content: event.content, isError: event.isError, media: event.media, outcome: event.outcome } });
115
+ return reduced({ payload: { type: "tool_result", toolUseId: event.toolCallId, content: event.content, isError: readExtraField({ event, key: "isError" }), media: readExtraField({ event, key: "media" }), outcome: readExtraField({ event, key: "outcome" }) } });
91
116
  case EventType.RAW:
92
117
  return [{ kind: "raw", line: asString({ value: event.event }) }];
93
118
  case EventType.CUSTOM:
@@ -0,0 +1,110 @@
1
+ /** One-use, host-owned confirmation handoff. No route, authentication or run I/O lives here. */
2
+ import { EventType, type Interrupt } from '@ag-ui/core';
3
+ import type { AgUiEvent } from './event-projection.js';
4
+ type Empty = Record<string, never>;
5
+ type ResumeDecision = 'allow' | 'deny' | 'cancelled';
6
+ export declare function confirmationInterrupt({ threadId, runId, interrupt }: {
7
+ threadId: string;
8
+ runId: string;
9
+ interrupt: Interrupt;
10
+ }, _optional?: Empty): Extract<AgUiEvent, {
11
+ type: EventType.RUN_FINISHED;
12
+ }>;
13
+ /** Legacy readers treat dismissed and cancelled answers as denials. */
14
+ export declare function readConfirmationResume({ input, threadId, runId, interruptId }: {
15
+ input: unknown;
16
+ threadId: string;
17
+ runId: string;
18
+ interruptId: string;
19
+ }, _optional?: Empty): {
20
+ decision: 'allow' | 'deny';
21
+ } | undefined;
22
+ type Caps = {
23
+ global: number;
24
+ perScope: number;
25
+ };
26
+ type PauseAddress = {
27
+ ownerKey: string;
28
+ threadId: string;
29
+ parentRunId: string;
30
+ };
31
+ export interface AgUiResumeRecord<State> extends PauseAddress {
32
+ scopeKey: string;
33
+ interruptId: string;
34
+ expiresAtMs: number;
35
+ state: State;
36
+ }
37
+ type AbandonReason = 'expired' | 'stopped' | 'shutdown';
38
+ type Abandoned<State> = {
39
+ entry: AgUiResumeRecord<State>;
40
+ reason: AbandonReason;
41
+ };
42
+ export interface AgUiResumeRegistry<State> {
43
+ park(required: AgUiResumeRecord<State>, optional?: Empty): boolean;
44
+ claim(required: {
45
+ input: unknown;
46
+ ownerKey: string;
47
+ }, optional?: Empty): {
48
+ entry: AgUiResumeRecord<State>;
49
+ runId: string;
50
+ decision: ResumeDecision;
51
+ } | undefined;
52
+ abandon(required: {
53
+ interruptId: string;
54
+ reason: AbandonReason;
55
+ }, optional?: Empty): boolean;
56
+ abandonWhere(required: {
57
+ matches: (entry: AgUiResumeRecord<State>) => boolean;
58
+ reason: AbandonReason;
59
+ }, optional?: Empty): number;
60
+ shutdown(required: Empty, optional?: Empty): void;
61
+ }
62
+ /** Park typed host state until its verified owner claims it, or one abandonment path takes it. */
63
+ export declare function createAgUiResumeRegistry<State>({ caps, nowMs, schedule, onAbandon }: {
64
+ caps: Caps;
65
+ nowMs: () => number;
66
+ schedule: (required: {
67
+ delayMs: number;
68
+ callback: () => void;
69
+ }, optional: Empty) => () => void;
70
+ onAbandon: (required: Abandoned<State>, optional: Empty) => void;
71
+ }, { maxWireIdChars }?: {
72
+ maxWireIdChars?: number;
73
+ }): AgUiResumeRegistry<State>;
74
+ type LegacyAddress = {
75
+ owner: string;
76
+ threadId: string;
77
+ runId: string;
78
+ interruptId: string;
79
+ };
80
+ type LegacyEntry = LegacyAddress & {
81
+ state: unknown;
82
+ scopeKey: string;
83
+ abandonAtMs: number;
84
+ };
85
+ interface LegacyStore {
86
+ park(entry: LegacyEntry, optional?: Empty): boolean;
87
+ claim(address: LegacyAddress, optional?: Empty): LegacyEntry | undefined;
88
+ remove(required: {
89
+ interruptId: string;
90
+ }, optional?: Empty): boolean;
91
+ }
92
+ /** Preserve the original untimed store interface over the same one-use pause table. */
93
+ export declare function createAgUiPauseStore({ caps, nowMs }: {
94
+ caps: Caps;
95
+ nowMs: () => number;
96
+ }, _optional?: Empty): LegacyStore;
97
+ export interface AgUiApprovalCard {
98
+ exchangeId: string;
99
+ toolId: string;
100
+ message: string;
101
+ expiresAtMs?: number;
102
+ }
103
+ /** Identify only MCP-UI exchange cards with both confirmation actions. Other cards stay ordinary. */
104
+ export declare function readAgUiApprovalCard({ event, extensionPrefix, fallbackMessage }: {
105
+ event: AgUiEvent;
106
+ extensionPrefix: string;
107
+ fallbackMessage: string;
108
+ }, _optional?: Empty): AgUiApprovalCard | undefined;
109
+ export {};
110
+ //# sourceMappingURL=resume.d.ts.map