@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.
- package/README.md +49 -0
- package/dist/core/accepted-input.d.ts +1 -1
- package/dist/core/ag-ui/event-projection.d.ts +14 -69
- package/dist/core/ag-ui/event-projection.js +58 -133
- package/dist/core/ag-ui/event-reduction.d.ts +12 -2
- package/dist/core/ag-ui/event-reduction.js +35 -10
- package/dist/core/ag-ui/resume.d.ts +110 -0
- package/dist/core/ag-ui/resume.js +200 -0
- package/dist/core/ag-ui/run-input.d.ts +23 -0
- package/dist/core/ag-ui/run-input.js +45 -0
- package/dist/core/ag-ui/server.d.ts +69 -0
- package/dist/core/ag-ui/server.js +71 -0
- package/dist/core/agent-plugin-chat-state.js +13 -11
- package/dist/core/assistant-client/ag-ui-approval-relay.d.ts +113 -0
- package/dist/core/assistant-client/ag-ui-approval-relay.js +287 -0
- package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +25 -10
- package/dist/core/assistant-client/ag-ui-fetch-agent.js +25 -6
- package/dist/core/assistant-client/ag-ui-transport.d.ts +86 -3
- package/dist/core/assistant-client/ag-ui-transport.js +310 -80
- package/dist/core/assistant-client/browser-durable-subscription.d.ts +25 -0
- package/dist/core/assistant-client/browser-durable-subscription.js +78 -0
- package/dist/core/assistant-client/durable-run-subscription.js +141 -130
- package/dist/core/assistant-client/entry.d.ts +2 -1
- package/dist/core/assistant-client/entry.js +1 -0
- package/dist/core/assistant-client/transport-prompt.d.ts +94 -0
- package/dist/core/assistant-client/transport-prompt.js +180 -0
- package/dist/core/assistant-client/transport-run.d.ts +49 -0
- package/dist/core/assistant-client/transport-run.js +432 -0
- package/dist/core/assistant-client/transport-stream.d.ts +73 -0
- package/dist/core/assistant-client/transport-stream.js +128 -0
- package/dist/core/assistant-client/transport.d.ts +1 -1
- package/dist/core/assistant-client/transport.js +129 -835
- package/dist/core/assistant-content.d.ts +1 -17
- package/dist/core/assistant-content.js +16 -0
- package/dist/core/assistant-tool-metadata.d.ts +103 -0
- package/dist/core/assistant-tool-metadata.js +56 -0
- package/dist/core/checkpoint-interval.d.ts +1 -1
- package/dist/core/compact-events.d.ts +1 -1
- package/dist/core/durable-projection.d.ts +1 -1
- package/dist/core/durable-runs/continuation.d.ts +1 -1
- package/dist/core/durable-runs/ledger-contracts.d.ts +4 -1
- package/dist/core/durable-runs/ports.d.ts +2 -1
- package/dist/core/durable-runs/run-contracts.d.ts +1 -1
- package/dist/core/durable-runs/run-finalizer.d.ts +145 -0
- package/dist/core/durable-runs/run-finalizer.js +171 -0
- package/dist/core/events.d.ts +4 -82
- package/dist/core/events.js +2 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.js +2 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/persistence/index.d.ts +1 -1
- package/dist/core/persistence/index.js +1 -1
- package/dist/core/question-form/normalize.d.ts +9 -3
- package/dist/core/question-form/normalize.js +20 -20
- package/dist/core/question-form/scan.js +15 -19
- package/dist/core/run-activity.d.ts +1 -1
- package/dist/core/run-events/entry.d.ts +11 -63
- package/dist/core/run-events/entry.js +12 -7
- package/dist/core/todos.d.ts +1 -1
- package/dist/core/todos.js +8 -0
- package/dist/core/tool-call-detail.d.ts +8 -1
- package/dist/core/tool-call-detail.js +35 -12
- package/dist/core/tool-events.d.ts +1 -1
- package/dist/core/tool-output.js +2 -6
- package/dist/core/tools.d.ts +2 -1
- package/dist/core/transport.d.ts +1 -1
- package/dist/core/turn-usage.d.ts +1 -1
- package/dist/core/util/parser.js +70 -69
- package/dist/embed-widget/browser/embed-send-bridge.d.ts +44 -0
- package/dist/embed-widget/browser/embed-send-bridge.js +60 -0
- package/dist/embed-widget/browser/frontend-invocation-handler.d.ts +39 -0
- package/dist/embed-widget/browser/frontend-invocation-handler.js +151 -0
- package/dist/embed-widget/browser/frontend-session-bridge.d.ts +28 -0
- package/dist/embed-widget/browser/frontend-session-bridge.js +201 -257
- package/dist/embed-widget/browser/lazy-loader.js +16 -12
- package/dist/embed-widget/browser/session-store.d.ts +19 -1
- package/dist/embed-widget/browser/session-store.js +48 -17
- package/dist/embed-widget/transports/fetch-sse.d.ts +1 -1
- package/dist/embed-widget/vanilla/index.js +131 -67
- package/dist/embed-widget/vanilla/state.js +53 -38
- package/dist/react/admin-execution/ai-agent-presentation.d.ts +35 -0
- package/dist/react/admin-execution/ai-agent-presentation.js +39 -0
- package/dist/react/admin-execution/hooks/use-ai-agent-presentation.hooks.d.ts +22 -0
- package/dist/react/admin-execution/hooks/use-ai-agent-presentation.hooks.js +25 -0
- package/dist/react/chat-cleanup/ChatCleanupPanel.d.ts +15 -0
- package/dist/react/chat-cleanup/ChatCleanupPanel.js +17 -0
- package/dist/react/chat-cleanup/chat-cleanup.hooks.d.ts +168 -0
- package/dist/react/chat-cleanup/chat-cleanup.hooks.js +83 -0
- package/dist/react/components/ChatCleanupDialog.d.ts +38 -0
- package/dist/react/components/ChatCleanupDialog.js +12 -0
- package/dist/react/components/ConversationList.d.ts +14 -5
- package/dist/react/components/ConversationList.hooks.d.ts +1 -0
- package/dist/react/components/ConversationList.hooks.js +4 -2
- package/dist/react/components/ConversationList.js +41 -5
- package/dist/react/components/Icon.d.ts +1 -1
- package/dist/react/components/Icon.js +2 -0
- package/dist/react/components/Markdown.js +6 -6
- package/dist/react/components/MarkdownLink.d.ts +25 -0
- package/dist/react/components/MarkdownLink.js +17 -0
- package/dist/react/components/RoutedA2uiSurfaceCard.d.ts +80 -0
- package/dist/react/components/RoutedA2uiSurfaceCard.js +15 -0
- package/dist/react/components/ToolCard.d.ts +4 -2
- package/dist/react/components/ToolCard.js +46 -4
- package/dist/react/components/ToolCard.rules.d.ts +5 -2
- package/dist/react/components/ToolCard.rules.js +12 -5
- package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
- package/dist/react/components/mcp-ui-surface-state.d.ts +3 -1
- package/dist/react/components/mcp-ui-surface-state.js +2 -2
- package/dist/react/components/own-link.d.ts +26 -0
- package/dist/react/components/own-link.js +36 -0
- package/dist/react/features/bridged-chat/create-staged-attachment-uploader.d.ts +7 -0
- package/dist/react/features/bridged-chat/create-staged-attachment-uploader.js +26 -0
- package/dist/react/features/bridged-chat/hooks/useBridgedChatTransport.hooks.d.ts +12 -0
- package/dist/react/features/bridged-chat/hooks/useBridgedChatTransport.hooks.js +60 -0
- package/dist/react/features/bridged-chat/index.d.ts +8 -0
- package/dist/react/features/bridged-chat/index.js +7 -0
- package/dist/react/features/bridged-chat/types.d.ts +49 -0
- package/dist/react/features/bridged-chat/types.js +2 -0
- package/dist/react/features/chat-pane/components/RuntimeDropUp.js +1 -1
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts +6 -0
- package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js +101 -59
- package/dist/react/features/chat-pane/hooks/useChatPaneNewTabLinks.hooks.d.ts +3 -0
- package/dist/react/features/chat-pane/hooks/useChatPaneNewTabLinks.hooks.js +26 -16
- package/dist/react/features/chat-pane/model-options.d.ts +3 -1
- package/dist/react/features/chat-pane/model-options.js +3 -3
- package/dist/react/features/chat-pane/rules.js +4 -3
- package/dist/react/features/chat-pane/styles.d.ts +1 -1
- package/dist/react/features/chat-pane/styles.js +16 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationChatPane.d.ts +10 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationChatPane.js +19 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneChat.d.ts +12 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneChat.js +21 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneHeader.d.ts +13 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationChatPaneHeader.js +9 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationDeleteConfirm.d.ts +12 -0
- package/dist/react/features/conversation-chat-pane/components/ConversationDeleteConfirm.js +12 -0
- package/dist/react/features/conversation-chat-pane/hooks/useConversationChatPane.hooks.d.ts +7 -0
- package/dist/react/features/conversation-chat-pane/hooks/useConversationChatPane.hooks.js +43 -0
- package/dist/react/features/conversation-chat-pane/index.d.ts +9 -0
- package/dist/react/features/conversation-chat-pane/index.js +8 -0
- package/dist/react/features/conversation-chat-pane/rules.d.ts +25 -0
- package/dist/react/features/conversation-chat-pane/rules.js +29 -0
- package/dist/react/features/conversation-chat-pane/types.d.ts +139 -0
- package/dist/react/features/conversation-chat-pane/types.js +2 -0
- package/dist/react/features/conversations/conversation-controller.d.ts +16 -0
- package/dist/react/features/conversations/conversation-controller.js +280 -0
- package/dist/react/features/conversations/hooks/useConversationDeleteConfirmation.hooks.d.ts +15 -0
- package/dist/react/features/conversations/hooks/useConversationDeleteConfirmation.hooks.js +33 -0
- package/dist/react/features/conversations/hooks/useStoredConversations.hooks.d.ts +16 -0
- package/dist/react/features/conversations/hooks/useStoredConversations.hooks.js +36 -0
- package/dist/react/features/conversations/index.d.ts +9 -0
- package/dist/react/features/conversations/index.js +8 -0
- package/dist/react/features/conversations/types.d.ts +120 -0
- package/dist/react/features/conversations/types.js +2 -0
- package/dist/react/features/voice-input/space-hold-rules.d.ts +65 -0
- package/dist/react/features/voice-input/space-hold-rules.js +48 -0
- package/dist/react/hooks/testing/fake-transport.d.ts +1 -1
- package/dist/react/hooks/useAnsweredCards.d.ts +2 -1
- package/dist/react/hooks/useConversation.js +5 -2
- package/dist/react/hooks/useExtEventGroups.d.ts +1 -1
- package/dist/react/hooks/useRunActivity.d.ts +2 -1
- package/dist/react/hooks/useRunStream.d.ts +1 -1
- package/dist/react/hooks/useRunStream.js +1 -1
- package/dist/react/hooks/useSurfaceRecovery.js +3 -1
- package/dist/react/hooks/useToolTimeline.d.ts +2 -1
- package/dist/react/index.d.ts +5 -2
- package/dist/react/index.js +4 -2
- package/dist/react/message-blocks.d.ts +1 -48
- package/dist/react/message-blocks.js +47 -0
- package/dist/react/styles/chat-settings.css +14 -14
- package/dist/server/chat-cleanup-routes.d.ts +56 -0
- package/dist/server/chat-cleanup-routes.js +56 -0
- package/dist/server/durable-runs/recover.js +193 -171
- package/dist/server/run-finalizer/entry.js +133 -110
- package/dist/store/legacy/sqlite/conversations.js +29 -17
- package/dist/store/pglite/index.d.ts +1 -0
- package/dist/store/pglite/index.js +1 -0
- package/dist/store/ports.d.ts +12 -0
- package/dist/store/postgres/index.d.ts +1 -0
- package/dist/store/postgres/index.js +1 -0
- package/dist/store/runtime/attempt-base-retention.d.ts +57 -0
- package/dist/store/runtime/attempt-base-retention.js +103 -0
- package/dist/store/runtime/chat-maintenance.d.ts +16 -0
- package/dist/store/runtime/chat-maintenance.js +19 -0
- package/dist/store/runtime/chat-principal.d.ts +63 -0
- package/dist/store/runtime/chat-principal.js +39 -0
- package/dist/store/runtime/checkpoint-delta.d.ts +1 -1
- package/dist/store/runtime/durable-run-queries.d.ts +124 -0
- package/dist/store/runtime/durable-run-queries.js +122 -0
- package/dist/store/runtime/durable-run-store.d.ts +1 -1
- package/dist/store/runtime/durable-run-store.js +291 -343
- package/dist/store/runtime/entry.d.ts +3 -0
- package/dist/store/runtime/entry.js +3 -0
- package/dist/store/runtime/events-json.d.ts +1 -1
- package/dist/store/runtime/lazy-run-ledger.d.ts +19 -0
- package/dist/store/runtime/lazy-run-ledger.js +28 -0
- package/dist/store/runtime/run-ledger.d.ts +4 -1
- package/dist/store/runtime/run-ledger.js +256 -204
- package/dist/store/sql/bulk-deletion.d.ts +36 -0
- package/dist/store/sql/bulk-deletion.js +103 -0
- package/dist/store/sql/store-queries.d.ts +170 -0
- package/dist/store/sql/store-queries.js +212 -0
- package/dist/store/sql/store-rows.d.ts +106 -0
- package/dist/store/sql/store-rows.js +116 -0
- package/dist/store/sql/store-writes.d.ts +46 -0
- package/dist/store/sql/store-writes.js +161 -0
- package/dist/store/sql/store.d.ts +3 -16
- package/dist/store/sql/store.js +58 -428
- package/dist/store/sql/tables.d.ts +1 -0
- package/dist/store/sqlite/index.d.ts +1 -0
- package/dist/store/sqlite/index.js +1 -0
- package/dist/store/sqlite/schema.d.ts +1 -1
- package/dist/store/sqlite/schema.js +5 -1
- package/package.json +171 -20
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Ports and published shapes for the stored-conversation controller and its React binding.
|
|
3
|
+
* Typed structurally so a host's own store bridge (an IPC preload object, a fetch client, a fake in
|
|
4
|
+
* a test) satisfies {@link ConversationStorePort} without adapting it, and so a host's own summary
|
|
5
|
+
* DTO flows through untouched as `TSummary`.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatMessage } from '../../../core/messages.js';
|
|
8
|
+
import type { ConversationListItem } from '../../components/ConversationList.js';
|
|
9
|
+
/** The two summary fields the controller itself reads; everything else a host's DTO carries is
|
|
10
|
+
* passed through as-is. `title` is `null` until the store auto-titles it or someone renames it. */
|
|
11
|
+
export interface ConversationSummaryLike {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string | null;
|
|
14
|
+
}
|
|
15
|
+
/** The conversation store the controller calls. An `undefined` store makes every action a no-op. */
|
|
16
|
+
export interface ConversationStorePort<TSummary extends ConversationSummaryLike = ConversationSummaryLike> {
|
|
17
|
+
/** Most-recently-active first. */
|
|
18
|
+
listConversations: () => Promise<readonly TSummary[]>;
|
|
19
|
+
loadConversationMessages: (input: {
|
|
20
|
+
conversationId: string;
|
|
21
|
+
}) => Promise<ChatMessage[]>;
|
|
22
|
+
createConversation: () => Promise<TSummary>;
|
|
23
|
+
/** Drops the conversation and every message in it. */
|
|
24
|
+
deleteConversation: (input: {
|
|
25
|
+
id: string;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
renameConversation: (input: {
|
|
28
|
+
id: string;
|
|
29
|
+
title: string;
|
|
30
|
+
}) => Promise<void>;
|
|
31
|
+
/** Upserts one message by id into a conversation's transcript. A store is expected to refuse
|
|
32
|
+
* writes to a deleted conversation. */
|
|
33
|
+
saveConversationMessage: (input: {
|
|
34
|
+
conversationId: string;
|
|
35
|
+
message: ChatMessage;
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/** Where failures are reported. */
|
|
39
|
+
export type ConversationLog = (...args: unknown[]) => void;
|
|
40
|
+
/** What the controller publishes. See `UseStoredConversations` for why `paneKey` is not `activeId`. */
|
|
41
|
+
export interface ConversationState<TSummary extends ConversationSummaryLike = ConversationSummaryLike> {
|
|
42
|
+
conversations: readonly TSummary[];
|
|
43
|
+
activeId: string | null;
|
|
44
|
+
paneKey: string;
|
|
45
|
+
initialMessages: ChatMessage[];
|
|
46
|
+
}
|
|
47
|
+
export interface ConversationController<TSummary extends ConversationSummaryLike = ConversationSummaryLike> {
|
|
48
|
+
/** The current state. Same object identity until something changes (`useSyncExternalStore`). */
|
|
49
|
+
getState: () => ConversationState<TSummary>;
|
|
50
|
+
/** Calls `listener` after every state change; returns the unsubscribe. */
|
|
51
|
+
subscribe: (input: {
|
|
52
|
+
listener: () => void;
|
|
53
|
+
}) => () => void;
|
|
54
|
+
/** Re-reads the list; on failure (or with no store) resolves to the list already published. */
|
|
55
|
+
refresh: () => Promise<readonly TSummary[]>;
|
|
56
|
+
select: (input: {
|
|
57
|
+
id: string;
|
|
58
|
+
}) => void;
|
|
59
|
+
create: () => Promise<void>;
|
|
60
|
+
remove: (input: {
|
|
61
|
+
id: string;
|
|
62
|
+
}) => Promise<void>;
|
|
63
|
+
rename: (input: {
|
|
64
|
+
id: string;
|
|
65
|
+
title: string;
|
|
66
|
+
}) => Promise<void>;
|
|
67
|
+
/** `ChatPane`'s `onMessagesChange` — see `UseStoredConversations.onMessagesChange`. */
|
|
68
|
+
onMessagesChange: (input: {
|
|
69
|
+
messages: ChatMessage[];
|
|
70
|
+
}) => void;
|
|
71
|
+
}
|
|
72
|
+
export interface UseStoredConversations<TSummary extends ConversationSummaryLike = ConversationSummaryLike> {
|
|
73
|
+
conversations: readonly TSummary[];
|
|
74
|
+
activeId: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* `ChatPane`'s `key`. Deliberately NOT `activeId`.
|
|
77
|
+
*
|
|
78
|
+
* `ChatPane` takes `initialMessages` only at MOUNT (`useConversation.ts`'s
|
|
79
|
+
* `useState(options.initialMessages ?? [])`), so switching to a different conversation's
|
|
80
|
+
* transcript means remounting the pane via a changed `key` — pushing new messages into a live
|
|
81
|
+
* pane would fight its own state instead of replacing it. But `activeId` ALSO changes when an
|
|
82
|
+
* untitled pane silently adopts a freshly created conversation mid-turn (see `onMessagesChange`
|
|
83
|
+
* below), and re-keying on THAT would remount the pane out from under a reply it is currently
|
|
84
|
+
* streaming. So the two stay separate: `paneKey` changes only on `select`/`create`/`remove`;
|
|
85
|
+
* `activeId` tracks where the next write goes. Same split as `useAssistantChats`
|
|
86
|
+
* (`../../hooks/assistant-chats-contracts.ts`), which found this the hard way.
|
|
87
|
+
*/
|
|
88
|
+
paneKey: string;
|
|
89
|
+
/** Messages to seed the pane with. Changes identity only on a real conversation switch. */
|
|
90
|
+
initialMessages: ChatMessage[];
|
|
91
|
+
select: (id: string) => void;
|
|
92
|
+
create: () => Promise<void>;
|
|
93
|
+
remove: (id: string) => Promise<void>;
|
|
94
|
+
rename: (id: string, title: string) => Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* `ChatPane`'s `onMessagesChange`. Fires once on MOUNT with whatever `initialMessages` seeded it
|
|
97
|
+
* with (`useChatPane.hooks.ts`'s effect on `conversation.messages`), so a fresh pane with nothing
|
|
98
|
+
* selected calls this with `[]` at mount — `persistableMessages({ messages: [] }).length === 0` makes that a
|
|
99
|
+
* no-op in the controller (`conversation-controller.ts`), rather than mistaking a mount
|
|
100
|
+
* echo for new content to save.
|
|
101
|
+
*/
|
|
102
|
+
onMessagesChange: (messages: ChatMessage[]) => void;
|
|
103
|
+
}
|
|
104
|
+
export interface ConversationDeleteConfirmationState {
|
|
105
|
+
/** The title of the conversation currently asking to be confirmed, or `null` when nothing is
|
|
106
|
+
* pending. Falls back to the `untitled` label the same way `ConversationList` itself does. */
|
|
107
|
+
pendingTitle: string | null;
|
|
108
|
+
/**
|
|
109
|
+
* `ConversationList`'s `confirmDelete` prop. Deliberately NOT `window.confirm` — a native modal
|
|
110
|
+
* blocks the whole renderer, and in an Electron host that also freezes the IPC its window
|
|
111
|
+
* answers on. This returns a promise that resolves only when the user answers the inline
|
|
112
|
+
* confirmation the host's pane renders from `pendingTitle`.
|
|
113
|
+
*/
|
|
114
|
+
confirmDelete: (item: ConversationListItem) => Promise<boolean>;
|
|
115
|
+
/** Answers the pending confirmation, if any. A no-op when nothing is pending. */
|
|
116
|
+
resolvePending: (input: {
|
|
117
|
+
confirmed: boolean;
|
|
118
|
+
}) => void;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Pure decision logic for a hold-to-talk gesture on a composer key — no DOM, no timers, no
|
|
3
|
+
* React — so every branch is directly assertable. The host's hook owns the listeners and the
|
|
4
|
+
* timer, and supplies the bound key and the hold duration; this file owns "what should happen".
|
|
5
|
+
*
|
|
6
|
+
* **Why the gesture is gated on an EMPTY draft.** Holding a printable key inside a text field fires
|
|
7
|
+
* OS key repeat, so a plain "hold the key anywhere" binding types a run of characters into whatever
|
|
8
|
+
* the user was already writing, which then has to be swallowed and undone. Requiring the draft to
|
|
9
|
+
* be empty removes that class of bug outright: there is no text to corrupt, and the one character
|
|
10
|
+
* the initial keydown does type is discarded for free when the composer's insertion rule replaces a
|
|
11
|
+
* whitespace-only draft rather than appending to it (`appendComposerDiscovery` in `@jini-ai/chat`).
|
|
12
|
+
* Key repeat itself is still suppressed — see {@link resolveSpaceHoldKeyDown}'s `"suppress"`
|
|
13
|
+
* action — so the caret never marches across the box during a hold.
|
|
14
|
+
*
|
|
15
|
+
* The mic button stays the always-available path once anything has been typed.
|
|
16
|
+
*/
|
|
17
|
+
/** Where the gesture currently is. `"armed"` means the timer is running but the mic is not open. */
|
|
18
|
+
export type SpaceHoldPhase = "released" | "armed" | "engaged";
|
|
19
|
+
/**
|
|
20
|
+
* - `"ignore"` — leave the event entirely alone; the browser types its normal character.
|
|
21
|
+
* - `"arm"` — start the hold timer. Deliberately does NOT suppress this first keystroke (see the
|
|
22
|
+
* file header): a quick tap must still produce a real, browser-typed character.
|
|
23
|
+
* - `"suppress"` — `preventDefault()` and change nothing. This is the key-repeat case.
|
|
24
|
+
*/
|
|
25
|
+
export type SpaceHoldKeyDownAction = "ignore" | "arm" | "suppress";
|
|
26
|
+
export interface SpaceHoldKeyDownInput {
|
|
27
|
+
/** The key the event reported. */
|
|
28
|
+
key: string;
|
|
29
|
+
/** The key the gesture is bound to, supplied by the host. */
|
|
30
|
+
holdKey: string;
|
|
31
|
+
/** True mid-IME-composition, where the key commits a candidate and is never a gesture. */
|
|
32
|
+
isComposing: boolean;
|
|
33
|
+
phase: SpaceHoldPhase;
|
|
34
|
+
/** The composer's live text. Whitespace-only counts as empty — there is nothing to corrupt. */
|
|
35
|
+
draft: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Decides what a hold-key keydown should do.
|
|
39
|
+
*
|
|
40
|
+
* Whether voice input is available at all is NOT an input here: the caller binds no listener when
|
|
41
|
+
* it is unavailable, so there is exactly one source of truth for that and no second copy here to
|
|
42
|
+
* drift from it.
|
|
43
|
+
*
|
|
44
|
+
* @returns See {@link SpaceHoldKeyDownAction}.
|
|
45
|
+
* @complexity Time/space: O(n) in draft length (one `trim`), O(1) otherwise.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveSpaceHoldKeyDown(input: SpaceHoldKeyDownInput, _optional?: {}): SpaceHoldKeyDownAction;
|
|
48
|
+
/**
|
|
49
|
+
* - `"ignore"` — not the bound key, or no gesture was in flight.
|
|
50
|
+
* - `"disarm"` — released before the threshold: a quick tap. The character the browser already
|
|
51
|
+
* typed on keydown stands; nothing is started and nothing is undone.
|
|
52
|
+
* - `"release"` — released after the mic opened: stop recording and transcribe.
|
|
53
|
+
*/
|
|
54
|
+
export type SpaceHoldKeyUpAction = "ignore" | "disarm" | "release";
|
|
55
|
+
/**
|
|
56
|
+
* Decides what a hold-key keyup should do.
|
|
57
|
+
*
|
|
58
|
+
* @complexity Time/space: O(1).
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveSpaceHoldKeyUp({ key, holdKey, phase }: {
|
|
61
|
+
key: string;
|
|
62
|
+
holdKey: string;
|
|
63
|
+
phase: SpaceHoldPhase;
|
|
64
|
+
}, _optional?: {}): SpaceHoldKeyUpAction;
|
|
65
|
+
//# sourceMappingURL=space-hold-rules.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Pure decision logic for a hold-to-talk gesture on a composer key — no DOM, no timers, no
|
|
3
|
+
* React — so every branch is directly assertable. The host's hook owns the listeners and the
|
|
4
|
+
* timer, and supplies the bound key and the hold duration; this file owns "what should happen".
|
|
5
|
+
*
|
|
6
|
+
* **Why the gesture is gated on an EMPTY draft.** Holding a printable key inside a text field fires
|
|
7
|
+
* OS key repeat, so a plain "hold the key anywhere" binding types a run of characters into whatever
|
|
8
|
+
* the user was already writing, which then has to be swallowed and undone. Requiring the draft to
|
|
9
|
+
* be empty removes that class of bug outright: there is no text to corrupt, and the one character
|
|
10
|
+
* the initial keydown does type is discarded for free when the composer's insertion rule replaces a
|
|
11
|
+
* whitespace-only draft rather than appending to it (`appendComposerDiscovery` in `@jini-ai/chat`).
|
|
12
|
+
* Key repeat itself is still suppressed — see {@link resolveSpaceHoldKeyDown}'s `"suppress"`
|
|
13
|
+
* action — so the caret never marches across the box during a hold.
|
|
14
|
+
*
|
|
15
|
+
* The mic button stays the always-available path once anything has been typed.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Decides what a hold-key keydown should do.
|
|
19
|
+
*
|
|
20
|
+
* Whether voice input is available at all is NOT an input here: the caller binds no listener when
|
|
21
|
+
* it is unavailable, so there is exactly one source of truth for that and no second copy here to
|
|
22
|
+
* drift from it.
|
|
23
|
+
*
|
|
24
|
+
* @returns See {@link SpaceHoldKeyDownAction}.
|
|
25
|
+
* @complexity Time/space: O(n) in draft length (one `trim`), O(1) otherwise.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveSpaceHoldKeyDown(input, _optional = {}) {
|
|
28
|
+
if (input.key !== input.holdKey || input.isComposing)
|
|
29
|
+
return "ignore";
|
|
30
|
+
// Already armed or recording: every further keydown is OS key repeat. Swallow the character so
|
|
31
|
+
// the caret does not march across the box while the user holds.
|
|
32
|
+
if (input.phase !== "released")
|
|
33
|
+
return "suppress";
|
|
34
|
+
return input.draft.trim() === "" ? "arm" : "ignore";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decides what a hold-key keyup should do.
|
|
38
|
+
*
|
|
39
|
+
* @complexity Time/space: O(1).
|
|
40
|
+
*/
|
|
41
|
+
export function resolveSpaceHoldKeyUp({ key, holdKey, phase }, _optional = {}) {
|
|
42
|
+
if (key !== holdKey)
|
|
43
|
+
return "ignore";
|
|
44
|
+
if (phase === "armed")
|
|
45
|
+
return "disarm";
|
|
46
|
+
return phase === "engaged" ? "release" : "ignore";
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=space-hold-rules.js.map
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* exported from the package's public barrel; import via the relative test
|
|
6
6
|
* path (`../testing/fake-transport.js`).
|
|
7
7
|
*/
|
|
8
|
-
import type { AgentEvent } from '../../../core/index.js';
|
|
9
8
|
import type { ChatTransport, RunHandlers, StartRunInput } from '../../../core/index.js';
|
|
9
|
+
import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
|
|
10
10
|
export interface FakeTransportCall {
|
|
11
11
|
input: StartRunInput;
|
|
12
12
|
handlers: RunHandlers;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ChatRunStatus } from '../../core/messages.js';
|
|
2
2
|
import type { ExtEventGroup } from './useExtEventGroups.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IsAnsweredCard } from '../../core/index.js';
|
|
4
|
+
import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
|
|
4
5
|
export interface AnsweredCards {
|
|
5
6
|
/** Live rendering state; a terminal run overrides a stale streaming prop. */
|
|
6
7
|
runStreaming: boolean;
|
|
@@ -256,7 +256,10 @@ export function useConversation(options) {
|
|
|
256
256
|
if (!priorUser || priorUser.role !== 'user')
|
|
257
257
|
return;
|
|
258
258
|
const history = redactUserHistory({ history: messagesRef.current.slice(0, idx) }, options);
|
|
259
|
-
|
|
259
|
+
// A retry is a new reply with its own id, so the failed attempt's id, run id and timestamps
|
|
260
|
+
// never leak into it (hosts key persisted turns by message id).
|
|
261
|
+
const failedAgentId = messagesRef.current[idx].agentId;
|
|
262
|
+
const resetAssistant = pendingAssistantMessage({ id: createMessageId() }, { agentId: failedAgentId });
|
|
260
263
|
activeAssistantIdRef.current = resetAssistant.id;
|
|
261
264
|
// Functional for the same reason as `sendMessage`'s: keep a just-queued terminal update.
|
|
262
265
|
setMessagesState((prev) => {
|
|
@@ -279,7 +282,7 @@ export function useConversation(options) {
|
|
|
279
282
|
...(priorUser.folders !== undefined ? { folders: priorUser.folders } : {}),
|
|
280
283
|
...(priorUser.attachments !== undefined ? { attachments: priorUser.attachments } : {}),
|
|
281
284
|
});
|
|
282
|
-
}, [agentId, conversationId, run, options.redactUserText, options.onSecretRedacted]);
|
|
285
|
+
}, [agentId, conversationId, createMessageId, run, options.redactUserText, options.onSecretRedacted]);
|
|
283
286
|
const cancel = useCallback(() => run.cancel(), [run]);
|
|
284
287
|
const acknowledgeScroll = useCallback(() => setScrollIntent(false), []);
|
|
285
288
|
const suppressScroll = useCallback(() => setScrollIntent(false), []);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IsAnsweredCard } from '../../core/index.js';
|
|
2
|
+
import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
|
|
2
3
|
/** Wall-clock source, swappable in tests. */
|
|
3
4
|
export type NowFn = () => number;
|
|
4
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Logger } from '@jini-ai/core/primitives';
|
|
2
|
-
import type { AgentEvent } from '../../core/index.js';
|
|
3
2
|
import type { ChatTransport, StartRunInput } from '../../core/index.js';
|
|
3
|
+
import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
|
|
4
4
|
export type RunStreamStatus = 'idle' | 'streaming' | 'done' | 'error' | 'canceled';
|
|
5
5
|
export interface RunStreamState {
|
|
6
6
|
runId: string | null;
|
|
@@ -172,7 +172,7 @@ export function useRunStream({ transport }, { report } = {}) {
|
|
|
172
172
|
return;
|
|
173
173
|
setState((prev) => ({ ...prev, status: 'error', error: toError(err) }));
|
|
174
174
|
}
|
|
175
|
-
}, [makeHandlers, teardownSubscription]);
|
|
175
|
+
}, [makeHandlers, teardownSubscription, transport]);
|
|
176
176
|
const cancel = useCallback(() => {
|
|
177
177
|
cancelAbortRef.current?.abort();
|
|
178
178
|
const runId = runIdRef.current;
|
|
@@ -76,7 +76,9 @@ export function useSurfaceRecovery({ resource, call, runStreaming, onToolCall },
|
|
|
76
76
|
return await caller.answer({ call: submitted, signal: controller.signal, onSurface });
|
|
77
77
|
}
|
|
78
78
|
finally {
|
|
79
|
-
|
|
79
|
+
// An older answer settling must not drop the newer answer's controller (unmount aborts it).
|
|
80
|
+
if (answerController.current === controller)
|
|
81
|
+
answerController.current = undefined;
|
|
80
82
|
}
|
|
81
83
|
} : onToolCall;
|
|
82
84
|
return { resource: restored ?? resource, restored: restored !== undefined, live, onToolCall: toolCall };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolRenderProps, ToolStatus } from '../../core/index.js';
|
|
2
|
+
import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
|
|
2
3
|
type ToolUseEvent = Extract<AgentEvent, {
|
|
3
4
|
kind: 'tool_use';
|
|
4
5
|
}>;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -98,11 +98,11 @@ export { TodoCard } from './components/TodoCard.js';
|
|
|
98
98
|
export type { TodoCardProps } from './components/TodoCard.js';
|
|
99
99
|
/**
|
|
100
100
|
* The conversation switcher — new / select / delete / search / rename-on-double-click. Storage
|
|
101
|
-
* agnostic: it takes data plus callbacks, so a host backs it with `@jini-ai/sqlite
|
|
101
|
+
* agnostic: it takes data plus callbacks, so a host backs it with `@jini-ai/chat/store/sqlite`'s
|
|
102
102
|
* `ChatHistoryStore`, an HTTP endpoint, or a plain array. Drop it into `ChatPane`'s
|
|
103
103
|
* `leadingAccessory` slot; it needs no changes to `ChatPane` itself.
|
|
104
104
|
*/
|
|
105
|
-
export { ConversationList } from './components/ConversationList.js';
|
|
105
|
+
export { ConversationList, defaultConversationListHooks } from './components/ConversationList.js';
|
|
106
106
|
export { ConversationTitle, ConversationTitleEditor } from './components/ConversationTitleEditor.js';
|
|
107
107
|
export type { ConversationTitleProps, ConversationTitleEditorProps } from './components/ConversationTitleEditor.js';
|
|
108
108
|
export type { ConversationListProps, ConversationListItem } from './components/ConversationList.js';
|
|
@@ -135,6 +135,7 @@ export { NextStepActions } from './components/NextStepActions.js';
|
|
|
135
135
|
export type { NextStepAction, NextStepActionsProps } from './components/NextStepActions.js';
|
|
136
136
|
export { Markdown } from './components/Markdown.js';
|
|
137
137
|
export type { MarkdownProps } from './components/Markdown.js';
|
|
138
|
+
export { currentOrigin, isOwnLinkHref } from './components/own-link.js';
|
|
138
139
|
export { MessageRow } from './components/MessageRow.js';
|
|
139
140
|
export type { MessageRowProps } from './components/MessageRow.js';
|
|
140
141
|
export { MessageList } from './components/MessageList.js';
|
|
@@ -181,4 +182,6 @@ export type { SurfaceRecoveryInfo } from '../core/surface-recovery.js';
|
|
|
181
182
|
export { ChatSurfacesProvider, useChatSurfaces, McpUiHost } from './surfaces.js';
|
|
182
183
|
export type { ChatSurfaces, McpUiHostProps, ChatSurfaceComponentEntry, ChatSurfaceRegistry, AgentModelContextToolRegistration, AgentModelContextLike, } from './surfaces.js';
|
|
183
184
|
export type { ChatPagePort } from '../core/page-port.js';
|
|
185
|
+
export type { ConversationListHooks } from './components/ConversationList.js';
|
|
186
|
+
export { ChatCleanupDialog } from './components/ChatCleanupDialog.js';
|
|
184
187
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/react/index.js
CHANGED
|
@@ -94,11 +94,11 @@ export { applyToolCallDisplay, isFailedToolRow, summarizeToolGroup, toolGroupLab
|
|
|
94
94
|
export { TodoCard } from './components/TodoCard.js';
|
|
95
95
|
/**
|
|
96
96
|
* The conversation switcher — new / select / delete / search / rename-on-double-click. Storage
|
|
97
|
-
* agnostic: it takes data plus callbacks, so a host backs it with `@jini-ai/sqlite
|
|
97
|
+
* agnostic: it takes data plus callbacks, so a host backs it with `@jini-ai/chat/store/sqlite`'s
|
|
98
98
|
* `ChatHistoryStore`, an HTTP endpoint, or a plain array. Drop it into `ChatPane`'s
|
|
99
99
|
* `leadingAccessory` slot; it needs no changes to `ChatPane` itself.
|
|
100
100
|
*/
|
|
101
|
-
export { ConversationList } from './components/ConversationList.js';
|
|
101
|
+
export { ConversationList, defaultConversationListHooks } from './components/ConversationList.js';
|
|
102
102
|
export { ConversationTitle, ConversationTitleEditor } from './components/ConversationTitleEditor.js';
|
|
103
103
|
/**
|
|
104
104
|
* The conversation an operator last had open, per caller identity — so a host's switcher lands
|
|
@@ -120,6 +120,7 @@ export { QuestionForm } from './components/QuestionForm.js';
|
|
|
120
120
|
export { QuestionsPanel } from './components/QuestionsPanel.js';
|
|
121
121
|
export { NextStepActions } from './components/NextStepActions.js';
|
|
122
122
|
export { Markdown } from './components/Markdown.js';
|
|
123
|
+
export { currentOrigin, isOwnLinkHref } from './components/own-link.js';
|
|
123
124
|
export { MessageRow } from './components/MessageRow.js';
|
|
124
125
|
export { MessageList } from './components/MessageList.js';
|
|
125
126
|
export { Composer } from './components/Composer.js';
|
|
@@ -150,4 +151,5 @@ export { isAwaitingAnswer } from '../core/run-activity.js';
|
|
|
150
151
|
export { createFrontendRequestCaller } from './features/chat-pane/create-frontend-request-caller.js';
|
|
151
152
|
// Hosts bind the rich-surface implementations (MCP-UI iframe host, interactive registry, WebMCP probe) once, at the React root.
|
|
152
153
|
export { ChatSurfacesProvider, useChatSurfaces, McpUiHost } from './surfaces.js';
|
|
154
|
+
export { ChatCleanupDialog } from './components/ChatCleanupDialog.js';
|
|
153
155
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,51 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @module message-blocks
|
|
3
|
-
*
|
|
4
|
-
* Restores the original event-stream ordering of an assistant message: text and tool cards
|
|
5
|
-
* interleaved where they actually happened, instead of all the text followed by all the tools.
|
|
6
|
-
*
|
|
7
|
-
* ## Why this needs computing at all
|
|
8
|
-
*
|
|
9
|
-
* A rendered assistant message draws from three different shapes of the same turn.
|
|
10
|
-
* `ChatMessage.content` is a single string — `useConversation.ts` builds it by concatenating every
|
|
11
|
-
* `kind: 'text'` event (`out += ev.text`) — tool cards come from `ChatMessage.events`'s `tool_use`
|
|
12
|
-
* entries, and interactive surfaces (MCP-UI, A2UI) come from that same array's `kind: 'ext'`
|
|
13
|
-
* entries. Rendering `content`, then the tool timeline, then every `ext` group is the
|
|
14
|
-
* straightforward composition, and it is what `MessageRow.tsx` shipped in v1 (its own header
|
|
15
|
-
* records this as a known deferral pending the `AssistantMessage.tsx` extraction).
|
|
16
|
-
*
|
|
17
|
-
* The cost is not merely cosmetic ordering. Because the text runs on either side of a tool call (or
|
|
18
|
-
* an interactive surface) get concatenated with nothing between them, a message reads as
|
|
19
|
-
* `"I'll look for a tool that changes the site language.Done — the language is now English."` —
|
|
20
|
-
* two separate thoughts, from before and after the tool ran, fused mid-sentence. Worse for an `ext`
|
|
21
|
-
* surface specifically: a reply narrating what the human just submitted through an MCP-UI form (a
|
|
22
|
-
* `text` event that only exists BECAUSE the form's `ext` event was answered) renders ABOVE that
|
|
23
|
-
* form instead of below it — the answer appears to precede the question. The reader cannot tell
|
|
24
|
-
* which claims preceded the evidence and which followed it.
|
|
25
|
-
*
|
|
26
|
-
* Since `content` is exactly the concatenation of the text events, the split points are recoverable:
|
|
27
|
-
* walk the events in order, and every tool call or ext surface marks a boundary in that
|
|
28
|
-
* concatenation.
|
|
29
|
-
*
|
|
30
|
-
* ## Refuses rather than guesses
|
|
31
|
-
*
|
|
32
|
-
* {@link interleaveMessageBlocks} returns `null` whenever it cannot prove the reconstruction is
|
|
33
|
-
* lossless, and the caller falls back to the old flat layout. Losing the ordering is a presentation
|
|
34
|
-
* regression; dropping or duplicating a chunk of the assistant's actual words is a correctness one,
|
|
35
|
-
* so every check below prefers the former.
|
|
36
|
-
*
|
|
37
|
-
* It refuses when:
|
|
38
|
-
* - there are no events, or no tool rows AND no ext events (AND no thinking, when the caller asked
|
|
39
|
-
* for it) to interleave (nothing to do — the flat path is identical);
|
|
40
|
-
* - the concatenated text events do not reproduce `content` byte for byte. This is the load-bearing
|
|
41
|
-
* check. A message persisted before the events schema settled, one rebuilt by a host that
|
|
42
|
-
* assembles `content` some other way, or any future divergence between the two, all land here;
|
|
43
|
-
* - the walk does not emit exactly the rows it was given (a `tool_use` with no matching row, or a
|
|
44
|
-
* row never reached), which would mean silently dropping a tool card.
|
|
45
|
-
*
|
|
46
|
-
* Artifacts are handled by the caller, not here — see `MessageRow.tsx`.
|
|
47
|
-
*/
|
|
48
|
-
import type { AgentEvent } from '../core/index.js';
|
|
1
|
+
import type { AgentEvent } from "@jini-ai/core/contracts/site/chat-core";
|
|
49
2
|
/**
|
|
50
3
|
* One rendered block. Consecutive tool cards are coalesced into a single `tools` block so they keep
|
|
51
4
|
* rendering inside one `.jini-message-tools` container, exactly as the flat layout did — a run of
|
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module message-blocks
|
|
3
|
+
*
|
|
4
|
+
* Restores the original event-stream ordering of an assistant message: text and tool cards
|
|
5
|
+
* interleaved where they actually happened, instead of all the text followed by all the tools.
|
|
6
|
+
*
|
|
7
|
+
* ## Why this needs computing at all
|
|
8
|
+
*
|
|
9
|
+
* A rendered assistant message draws from three different shapes of the same turn.
|
|
10
|
+
* `ChatMessage.content` is a single string — `useConversation.ts` builds it by concatenating every
|
|
11
|
+
* `kind: 'text'` event (`out += ev.text`) — tool cards come from `ChatMessage.events`'s `tool_use`
|
|
12
|
+
* entries, and interactive surfaces (MCP-UI, A2UI) come from that same array's `kind: 'ext'`
|
|
13
|
+
* entries. Rendering `content`, then the tool timeline, then every `ext` group is the
|
|
14
|
+
* straightforward composition, and it is what `MessageRow.tsx` shipped in v1 (its own header
|
|
15
|
+
* records this as a known deferral pending the `AssistantMessage.tsx` extraction).
|
|
16
|
+
*
|
|
17
|
+
* The cost is not merely cosmetic ordering. Because the text runs on either side of a tool call (or
|
|
18
|
+
* an interactive surface) get concatenated with nothing between them, a message reads as
|
|
19
|
+
* `"I'll look for a tool that changes the site language.Done — the language is now English."` —
|
|
20
|
+
* two separate thoughts, from before and after the tool ran, fused mid-sentence. Worse for an `ext`
|
|
21
|
+
* surface specifically: a reply narrating what the human just submitted through an MCP-UI form (a
|
|
22
|
+
* `text` event that only exists BECAUSE the form's `ext` event was answered) renders ABOVE that
|
|
23
|
+
* form instead of below it — the answer appears to precede the question. The reader cannot tell
|
|
24
|
+
* which claims preceded the evidence and which followed it.
|
|
25
|
+
*
|
|
26
|
+
* Since `content` is exactly the concatenation of the text events, the split points are recoverable:
|
|
27
|
+
* walk the events in order, and every tool call or ext surface marks a boundary in that
|
|
28
|
+
* concatenation.
|
|
29
|
+
*
|
|
30
|
+
* ## Refuses rather than guesses
|
|
31
|
+
*
|
|
32
|
+
* {@link interleaveMessageBlocks} returns `null` whenever it cannot prove the reconstruction is
|
|
33
|
+
* lossless, and the caller falls back to the old flat layout. Losing the ordering is a presentation
|
|
34
|
+
* regression; dropping or duplicating a chunk of the assistant's actual words is a correctness one,
|
|
35
|
+
* so every check below prefers the former.
|
|
36
|
+
*
|
|
37
|
+
* It refuses when:
|
|
38
|
+
* - there are no events, or no tool rows AND no ext events (AND no thinking, when the caller asked
|
|
39
|
+
* for it) to interleave (nothing to do — the flat path is identical);
|
|
40
|
+
* - the concatenated text events do not reproduce `content` byte for byte. This is the load-bearing
|
|
41
|
+
* check. A message persisted before the events schema settled, one rebuilt by a host that
|
|
42
|
+
* assembles `content` some other way, or any future divergence between the two, all land here;
|
|
43
|
+
* - the walk does not emit exactly the rows it was given (a `tool_use` with no matching row, or a
|
|
44
|
+
* row never reached), which would mean silently dropping a tool card.
|
|
45
|
+
*
|
|
46
|
+
* Artifacts are handled by the caller, not here — see `MessageRow.tsx`.
|
|
47
|
+
*/
|
|
1
48
|
import { assistantContentFromEvents, isReplyBoundary, legacyAssistantContentFromEvents } from '../core/index.js';
|
|
2
49
|
import { isAssistantStepBoundary } from '../core/assistant-content.js';
|
|
3
50
|
import { MID_RUN_USER_MESSAGE_EVENT_NAME } from '../core/turn-usage.js';
|
|
@@ -42,19 +42,19 @@
|
|
|
42
42
|
}
|
|
43
43
|
.jini-chat-settings-dialog .jini-chat-settings-close:hover { background: var(--jini-chat-settings-subtle, #f4f5f7); color: var(--jini-chat-settings-fg, #1a1916); }
|
|
44
44
|
.jini-chat-settings-dialog .jini-chat-settings-close:focus-visible { outline: 2px solid var(--jini-chat-settings-accent, #3b66c4); outline-offset: 2px; }
|
|
45
|
-
.jini-chat-settings-dialog > .tab-bar { display: flex; border-bottom: 1px solid var(--jini-chat-settings-border, #d9dce2); flex: none; flex-wrap: nowrap; margin: 0.25rem 0 0; padding: 0 1.5rem; gap: 0.5rem; }
|
|
46
|
-
.jini-chat-settings-dialog > .tab-bar .tab-bar-item {
|
|
45
|
+
.jini-chat-settings-dialog > .jini-ui-tab-bar { display: flex; border-bottom: 1px solid var(--jini-chat-settings-border, #d9dce2); flex: none; flex-wrap: nowrap; margin: 0.25rem 0 0; padding: 0 1.5rem; gap: 0.5rem; }
|
|
46
|
+
.jini-chat-settings-dialog > .jini-ui-tab-bar .jini-ui-tab-bar-item {
|
|
47
47
|
display: inline-flex; align-items: center; flex-shrink: 0; background: none;
|
|
48
48
|
border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 0.65rem 0.25rem;
|
|
49
49
|
margin-bottom: -1px; font: inherit; font-size: var(--jini-font-size-sm, 0.875rem); font-weight: 600;
|
|
50
50
|
color: var(--jini-chat-settings-muted, #676767); cursor: pointer; transition: color 140ms, border-color 140ms;
|
|
51
51
|
}
|
|
52
|
-
.jini-chat-settings-dialog > .tab-bar .tab-bar-item:hover { color: var(--jini-chat-settings-fg, #1a1916); }
|
|
53
|
-
.jini-chat-settings-dialog > .tab-bar .tab-bar-item[aria-selected="true"] {
|
|
52
|
+
.jini-chat-settings-dialog > .jini-ui-tab-bar .jini-ui-tab-bar-item:hover { color: var(--jini-chat-settings-fg, #1a1916); }
|
|
53
|
+
.jini-chat-settings-dialog > .jini-ui-tab-bar .jini-ui-tab-bar-item[aria-selected="true"] {
|
|
54
54
|
color: var(--jini-chat-settings-selected-text, var(--jini-chat-settings-accent, #3b66c4));
|
|
55
55
|
border-bottom-color: var(--jini-chat-settings-selected-ring, var(--jini-chat-settings-accent, #3b66c4));
|
|
56
56
|
}
|
|
57
|
-
.jini-chat-settings-dialog .tab-bar-item:focus-visible { outline: 2px solid var(--jini-chat-settings-accent, #3b66c4); outline-offset: -2px; border-radius: 4px 4px 0 0; }
|
|
57
|
+
.jini-chat-settings-dialog .jini-ui-tab-bar-item:focus-visible { outline: 2px solid var(--jini-chat-settings-accent, #3b66c4); outline-offset: -2px; border-radius: 4px 4px 0 0; }
|
|
58
58
|
.jini-chat-settings-body {
|
|
59
59
|
flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
|
|
60
60
|
padding: 1.25rem 1.5rem 1.5rem; overflow-wrap: anywhere;
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
display: inline-flex; flex-wrap: wrap; align-self: flex-start; max-width: 100%; gap: 0.25rem; padding: 0.2rem;
|
|
68
68
|
border: 1px solid var(--jini-chat-settings-border, #d9dce2); border-radius: 8px; background: var(--jini-chat-settings-subtle, #f4f5f7);
|
|
69
69
|
}
|
|
70
|
-
.jini-chat-settings-legend > .info-tip { margin-left: 0.3rem; }
|
|
70
|
+
.jini-chat-settings-legend > .jini-ui-info-tip { margin-left: 0.3rem; }
|
|
71
71
|
.jini-chat-settings-segment {
|
|
72
72
|
position: relative; display: inline-flex; align-items: center; padding: 0.4rem 0.95rem;
|
|
73
73
|
border-radius: 6px; font-size: var(--jini-font-size-sm, 0.875rem); color: var(--jini-chat-settings-muted, #676767); cursor: pointer;
|
|
@@ -93,7 +93,7 @@ button.jini-chat-settings-segment:hover { opacity: 1; }
|
|
|
93
93
|
.jini-chat-settings-text { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
|
|
94
94
|
/* A switch's ⓘ follows its label's text, like the legend's (owner, 2026-10-21), outside the label so a tap never toggles. */
|
|
95
95
|
.jini-chat-settings-label-row { display: flex; align-items: center; gap: 0.3rem; }
|
|
96
|
-
.jini-chat-settings-label-row > .info-tip { flex: none; }
|
|
96
|
+
.jini-chat-settings-label-row > .jini-ui-info-tip { flex: none; }
|
|
97
97
|
.jini-chat-settings-label { font-size: 0.9375rem; line-height: 1.4; cursor: pointer; }
|
|
98
98
|
.jini-chat-settings-description { margin: 0; font-size: 0.8125rem; line-height: 1.35; color: var(--jini-text-muted, var(--jini-chat-settings-muted, #676767)); }
|
|
99
99
|
.jini-chat-settings-description--group { margin: -0.25rem 0 0.625rem; }
|
|
@@ -133,17 +133,17 @@ button.jini-chat-settings-segment:hover { opacity: 1; }
|
|
|
133
133
|
phone floor in styles.css (44px min on every [role="button"] in `.jini-dialog`) did the same,
|
|
134
134
|
so it is undone here and the hit area takes over at that width too. */
|
|
135
135
|
@media (pointer: coarse), (max-width: 640px) {
|
|
136
|
-
.jini-chat-settings-legend .info-tip-icon,
|
|
137
|
-
.jini-chat-settings-label-row > .info-tip .info-tip-icon { position: relative; }
|
|
138
|
-
.jini-chat-settings-legend .info-tip-icon::before,
|
|
139
|
-
.jini-chat-settings-label-row > .info-tip .info-tip-icon::before { content: ""; position: absolute; inset: -13px; }
|
|
140
|
-
.jini-dialog .jini-chat-settings-legend .info-tip-icon[role="button"],
|
|
141
|
-
.jini-dialog .jini-chat-settings-label-row > .info-tip .info-tip-icon[role="button"] { min-width: 0; min-height: 0; }
|
|
136
|
+
.jini-chat-settings-legend .jini-ui-info-tip-icon,
|
|
137
|
+
.jini-chat-settings-label-row > .jini-ui-info-tip .jini-ui-info-tip-icon { position: relative; }
|
|
138
|
+
.jini-chat-settings-legend .jini-ui-info-tip-icon::before,
|
|
139
|
+
.jini-chat-settings-label-row > .jini-ui-info-tip .jini-ui-info-tip-icon::before { content: ""; position: absolute; inset: -13px; }
|
|
140
|
+
.jini-dialog .jini-chat-settings-legend .jini-ui-info-tip-icon[role="button"],
|
|
141
|
+
.jini-dialog .jini-chat-settings-label-row > .jini-ui-info-tip .jini-ui-info-tip-icon[role="button"] { min-width: 0; min-height: 0; }
|
|
142
142
|
}
|
|
143
143
|
@media (max-width: 640px) {
|
|
144
144
|
.jini-chat-settings-dialog input[type="checkbox"][role="switch"] { width: 38px; height: 22px; }
|
|
145
145
|
.jini-chat-settings-body { padding-inline: 1rem; }
|
|
146
|
-
.jini-chat-settings-dialog > .tab-bar { padding-inline: 1rem; }
|
|
146
|
+
.jini-chat-settings-dialog > .jini-ui-tab-bar { padding-inline: 1rem; }
|
|
147
147
|
.jini-chat-settings-header { padding-left: 1rem; }
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CleanupPreviewStore } from '@jini-ai/core/contracts/storage';
|
|
2
|
+
import type { ChatOwnerScope, ChatStore, ChatTitleSource } from '../store/ports.js';
|
|
3
|
+
import type { createChatBulkDeletion } from '../store/sql/bulk-deletion.js';
|
|
4
|
+
export interface ChatCleanupPatchDeps {
|
|
5
|
+
principal: string;
|
|
6
|
+
scope: ChatOwnerScope;
|
|
7
|
+
copy: {
|
|
8
|
+
invalidInput: string;
|
|
9
|
+
expired: string;
|
|
10
|
+
notFound: string;
|
|
11
|
+
};
|
|
12
|
+
readPatchInput: (required: {
|
|
13
|
+
body: unknown;
|
|
14
|
+
}) => {
|
|
15
|
+
title?: string;
|
|
16
|
+
pinned?: boolean;
|
|
17
|
+
source?: ChatTitleSource;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type ChatCleanupPreviewDeps = Omit<ChatCleanupPatchDeps, 'readPatchInput'>;
|
|
21
|
+
export type ChatCleanupApplyDeps = ChatCleanupPreviewDeps;
|
|
22
|
+
export type ChatCleanupSelectedDeps = ChatCleanupPreviewDeps;
|
|
23
|
+
type BulkDeletionForScope = (required: {
|
|
24
|
+
principal: string;
|
|
25
|
+
scope: ChatOwnerScope;
|
|
26
|
+
}) => ReturnType<typeof createChatBulkDeletion>;
|
|
27
|
+
export declare function createChatCleanupRoutes({ paths, bulkDeletionFor, previewStore, store }: {
|
|
28
|
+
paths: {
|
|
29
|
+
patch: string;
|
|
30
|
+
preview: string;
|
|
31
|
+
apply: string;
|
|
32
|
+
deleteSelected: string;
|
|
33
|
+
};
|
|
34
|
+
bulkDeletionFor: BulkDeletionForScope;
|
|
35
|
+
previewStore: CleanupPreviewStore;
|
|
36
|
+
store: (required: {
|
|
37
|
+
principal: string;
|
|
38
|
+
scope: ChatOwnerScope;
|
|
39
|
+
}) => ChatStore;
|
|
40
|
+
}, _optional?: {}): {
|
|
41
|
+
patch: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
42
|
+
id: string;
|
|
43
|
+
body: unknown;
|
|
44
|
+
}, object, ChatCleanupPatchDeps, undefined>;
|
|
45
|
+
preview: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
46
|
+
body: unknown;
|
|
47
|
+
}, object, ChatCleanupPreviewDeps, undefined>;
|
|
48
|
+
apply: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
49
|
+
body: unknown;
|
|
50
|
+
}, object, ChatCleanupPreviewDeps, undefined>;
|
|
51
|
+
deleteSelected: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
52
|
+
body: unknown;
|
|
53
|
+
}, object, ChatCleanupPreviewDeps, undefined>;
|
|
54
|
+
};
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=chat-cleanup-routes.d.ts.map
|