@jini-ai/chat 0.7.1 → 0.7.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +3 -3
- package/dist/contracts/chat-bubble-style.d.ts +1 -1
- package/dist/contracts/chat-bubble-style.js +1 -1
- package/dist/core/ag-ui/event-projection.d.ts +125 -0
- package/dist/core/ag-ui/event-projection.js +275 -0
- package/dist/core/ag-ui/event-reduction.d.ts +39 -0
- package/dist/core/ag-ui/event-reduction.js +99 -0
- package/dist/core/ag-ui/run-input.d.ts +53 -0
- package/dist/core/ag-ui/run-input.js +87 -0
- package/dist/core/agentic/chat-capabilities.d.ts +1 -1
- package/dist/core/agentic/index.d.ts +2 -4
- package/dist/core/agentic/index.js +2 -3
- package/dist/core/agents-port.d.ts +50 -0
- package/dist/core/agents-port.js +2 -0
- package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
- package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
- package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
- package/dist/core/assistant-client/ag-ui-transport.js +167 -145
- package/dist/core/assistant-client/attachment-liveness.js +13 -11
- package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
- package/dist/core/assistant-client/durable-run-subscription.js +6 -5
- package/dist/core/assistant-client/messages.d.ts +7 -4
- package/dist/core/assistant-client/messages.js +5 -4
- package/dist/core/assistant-client/transport.d.ts +1 -1
- package/dist/core/assistant-client/transport.js +4 -4
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +1 -0
- package/dist/core/page-port.d.ts +15 -0
- package/dist/core/page-port.js +2 -0
- package/dist/core/run-activity.js +1 -1
- package/dist/core/run-events/entry.js +1 -0
- package/dist/core/user-text-redaction.d.ts +1 -3
- package/dist/core/user-text-redaction.js +3 -61
- package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
- package/dist/embed-widget/browser/agent-inventory.js +36 -0
- package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
- package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
- package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
- package/dist/embed-widget/react/dialog.hooks.js +15 -0
- package/dist/embed-widget/react/embed.d.ts +7 -2
- package/dist/embed-widget/react/embed.js +6 -16
- package/dist/embed-widget/react/header.d.ts +4 -1
- package/dist/embed-widget/react/header.js +2 -2
- package/dist/embed-widget/vanilla/state.js +2 -2
- package/dist/embed-widget/vanilla/style.css +4 -4
- package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
- package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
- package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
- package/dist/react/components/A2uiSurfaceCard.js +14 -227
- package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
- package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
- package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
- package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
- package/dist/react/components/AttachmentPreviewModal.js +11 -9
- package/dist/react/components/AttachmentTray.d.ts +11 -1
- package/dist/react/components/AttachmentTray.js +12 -8
- package/dist/react/components/ChatFab.d.ts +10 -1
- package/dist/react/components/ChatFab.js +2 -2
- package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
- package/dist/react/components/ChatSettingsDialog.js +9 -6
- package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
- package/dist/react/components/ChatSettingsSegmented.js +1 -1
- package/dist/react/components/Composer.d.ts +9 -1
- package/dist/react/components/Composer.hooks.d.ts +79 -0
- package/dist/react/components/Composer.hooks.js +336 -0
- package/dist/react/components/Composer.js +40 -341
- package/dist/react/components/ComposerDiscovery.js +1 -1
- package/dist/react/components/ConversationList.d.ts +34 -1
- package/dist/react/components/ConversationList.hooks.d.ts +37 -0
- package/dist/react/components/ConversationList.hooks.js +177 -1
- package/dist/react/components/ConversationList.js +7 -174
- package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
- package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
- package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
- package/dist/react/components/ConversationTitleEditor.js +11 -34
- package/dist/react/components/CopyMessageButton.d.ts +6 -1
- package/dist/react/components/CopyMessageButton.js +4 -4
- package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
- package/dist/react/components/ExtEventErrorBoundary.js +5 -3
- package/dist/react/components/FolderChips.d.ts +11 -1
- package/dist/react/components/FolderChips.hooks.d.ts +12 -0
- package/dist/react/components/FolderChips.hooks.js +10 -0
- package/dist/react/components/FolderChips.js +9 -9
- package/dist/react/components/Markdown.js +7 -5
- package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
- package/dist/react/components/McpUiSurfaceCard.js +29 -16
- package/dist/react/components/MessageList.d.ts +10 -1
- package/dist/react/components/MessageList.hooks.js +4 -2
- package/dist/react/components/MessageList.js +12 -8
- package/dist/react/components/MessageRow.d.ts +46 -2
- package/dist/react/components/MessageRow.hooks.d.ts +60 -0
- package/dist/react/components/MessageRow.hooks.js +94 -0
- package/dist/react/components/MessageRow.js +53 -113
- package/dist/react/components/MidRunUserMessage.d.ts +6 -1
- package/dist/react/components/MidRunUserMessage.js +5 -5
- package/dist/react/components/NextStepActions.d.ts +3 -1
- package/dist/react/components/NextStepActions.js +3 -3
- package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
- package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
- package/dist/react/components/QuestionForm.d.ts +6 -0
- package/dist/react/components/QuestionForm.js +23 -261
- package/dist/react/components/QuestionForm.values.d.ts +22 -0
- package/dist/react/components/QuestionForm.values.js +58 -0
- package/dist/react/components/QuestionFormField.d.ts +17 -0
- package/dist/react/components/QuestionFormField.js +114 -0
- package/dist/react/components/QuestionsPanel.d.ts +3 -1
- package/dist/react/components/QuestionsPanel.js +7 -3
- package/dist/react/components/SentAttachment.d.ts +11 -2
- package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
- package/dist/react/components/SentAttachment.hooks.js +6 -5
- package/dist/react/components/SentAttachment.js +5 -3
- package/dist/react/components/TodoCard.d.ts +3 -1
- package/dist/react/components/TodoCard.js +9 -4
- package/dist/react/components/ToolCallGroup.d.ts +11 -1
- package/dist/react/components/ToolCallGroup.js +10 -4
- package/dist/react/components/ToolCard.d.ts +6 -1
- package/dist/react/components/ToolCard.js +79 -69
- package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
- package/dist/react/components/mcp-ui-question-input.js +3 -3
- package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
- package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
- package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
- package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/claude/model-options.js +2 -0
- package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/codex/model-options.js +2 -0
- package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
- package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
- package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
- package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
- package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
- package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
- package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
- package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
- package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
- package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
- package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
- package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
- package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
- package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
- package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
- package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
- package/dist/react/features/chat-pane/model-options.js +7 -4
- package/dist/react/features/chat-pane/styles.d.ts +1 -1
- package/dist/react/features/chat-pane/styles.js +14 -14
- package/dist/react/features/chat-pane/types.d.ts +29 -1
- package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
- package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
- package/dist/react/hooks/attachment-preview-cache.js +1 -1
- package/dist/react/hooks/fab-position.js +16 -18
- package/dist/react/hooks/useConversation.d.ts +6 -1
- package/dist/react/hooks/useConversation.js +11 -10
- package/dist/react/hooks/useRunStream.d.ts +3 -0
- package/dist/react/hooks/useRunStream.js +12 -12
- package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
- package/dist/react/hooks/useSurfaceRecovery.js +2 -2
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -3
- package/dist/react/styles/chat-settings.css +9 -9
- package/dist/react/surfaces.d.ts +91 -0
- package/dist/react/surfaces.js +28 -0
- package/dist/server/durable-runs/recover.d.ts +4 -3
- package/dist/server/durable-runs/recover.js +4 -3
- package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
- package/dist/store/legacy/sqlite/conversations.js +1 -1
- package/dist/store/legacy/sqlite/messages.d.ts +2 -3
- package/dist/store/legacy/sqlite/messages.js +6 -6
- package/dist/store/pglite/index.d.ts +7 -7
- package/dist/store/pglite/index.js +1 -1
- package/dist/store/ports.d.ts +5 -2
- package/dist/store/postgres/index.d.ts +7 -7
- package/dist/store/postgres/index.js +1 -1
- package/dist/store/runtime/chat-expiry-sweep.js +2 -4
- package/dist/store/runtime/chat-history-store.js +2 -3
- package/dist/store/runtime/durable-run-store.js +16 -2
- package/dist/store/runtime/history-tools.js +33 -11
- package/dist/store/runtime/kernel.d.ts +3 -2
- package/dist/store/runtime/run-ledger.js +2 -2
- package/dist/store/sql/boundary.d.ts +5 -5
- package/dist/store/sql/maintenance.d.ts +3 -2
- package/dist/store/sql/store.d.ts +16 -8
- package/dist/store/sql/store.js +31 -14
- package/dist/store/sqlite/index.d.ts +11 -12
- package/dist/store/sqlite/index.js +5 -5
- package/dist/store/sqlite/schema.d.ts +1 -1
- package/package.json +46 -24
- package/dist/core/ag-ui/entry.d.ts +0 -84
- package/dist/core/ag-ui/entry.js +0 -225
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { type Logger } from '@jini-ai/core/primitives';
|
|
1
2
|
import { type AcceptedChatInput } from '../../core/accepted-input.js';
|
|
2
3
|
import { type UserTextRedactionOptions } from '../../core/user-text-redaction.js';
|
|
3
4
|
import type { ChatAttachment, ChatMessage } from '../../core/index.js';
|
|
4
5
|
import type { ChatTransport, RunContext } from '../../core/index.js';
|
|
6
|
+
import { useRunStream } from './useRunStream.js';
|
|
5
7
|
export interface UseConversationOptions extends UserTextRedactionOptions {
|
|
8
|
+
report?: Pick<Logger, 'error'> | undefined;
|
|
9
|
+
useRunStreamHook?: typeof useRunStream;
|
|
6
10
|
transport: ChatTransport;
|
|
7
11
|
initialMessages?: ChatMessage[];
|
|
8
12
|
/** Optional host loader and browser ports, e.g. `{ loadMessages, visibility: document, focus: window }`; refresh stays passive. */
|
|
@@ -15,8 +19,9 @@ export interface UseConversationOptions extends UserTextRedactionOptions {
|
|
|
15
19
|
};
|
|
16
20
|
conversationId?: string | null;
|
|
17
21
|
agentId?: string;
|
|
18
|
-
/** Defaults to a `crypto.randomUUID()`-based id generator when available, else
|
|
22
|
+
/** Defaults to a `crypto.randomUUID()`-based id generator when available, else decimal entropy. */
|
|
19
23
|
createMessageId?: () => string;
|
|
24
|
+
random?: () => number;
|
|
20
25
|
}
|
|
21
26
|
export interface SendMessageOptions {
|
|
22
27
|
/** Queue flushes reuse the input receipts recorded when they were queued. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createConsoleLogger } from '@jini-ai/core/primitives';
|
|
2
2
|
import { acceptedInputUserEvent, projectAcceptedInputEvents } from '../../core/accepted-input.js';
|
|
3
3
|
import { redactUserHistory, redactUserMessage } from '../../core/user-text-redaction.js';
|
|
4
4
|
import { preserveAssistantContent, mergeRunEvents } from '../../core/durable-projection.js';
|
|
@@ -17,12 +17,10 @@ import { preserveAssistantContent, mergeRunEvents } from '../../core/durable-pro
|
|
|
17
17
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
18
18
|
import { assistantContentFromEvents, isTerminalRunStatus } from '../../core/index.js';
|
|
19
19
|
import { useRunStream } from './useRunStream.js';
|
|
20
|
-
|
|
21
|
-
function defaultCreateMessageId() {
|
|
20
|
+
function defaultCreateMessageId({ random }, _options = {}) {
|
|
22
21
|
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function')
|
|
23
22
|
return crypto.randomUUID();
|
|
24
|
-
|
|
25
|
-
return `msg-${Date.now()}-${fallbackIdCounter}`;
|
|
23
|
+
return `msg-${Date.now()}-${Math.floor(random() * Number.MAX_SAFE_INTEGER)}`;
|
|
26
24
|
}
|
|
27
25
|
function pendingUserMessage({ content, sendOptions, createMessageId }, options = {}) {
|
|
28
26
|
return redactUserMessage({ message: {
|
|
@@ -71,11 +69,12 @@ function runStartInput({ assistantMessageId, history, conversationId, sendOption
|
|
|
71
69
|
};
|
|
72
70
|
}
|
|
73
71
|
export function useConversation(options) {
|
|
74
|
-
const
|
|
72
|
+
const defaultMessageId = useCallback(() => defaultCreateMessageId({ random: options.random ?? Math.random }), [options.random]);
|
|
73
|
+
const { transport, conversationId = null, agentId, createMessageId = defaultMessageId, useRunStreamHook = useRunStream } = options;
|
|
75
74
|
const [messages, setMessagesState] = useState(() => redactUserHistory({ history: options.initialMessages ?? [] }, { ...(options.redactUserText ? { redactUserText: options.redactUserText } : {}) }));
|
|
76
75
|
const [scrollIntent, setScrollIntent] = useState(false);
|
|
77
76
|
const [sendRefused, setSendRefused] = useState(false);
|
|
78
|
-
const run =
|
|
77
|
+
const run = useRunStreamHook({ transport }, { report: options.report });
|
|
79
78
|
// The assistant message id the currently-active run is writing into.
|
|
80
79
|
const activeAssistantIdRef = useRef(null);
|
|
81
80
|
const messagesRef = useRef(messages);
|
|
@@ -99,8 +98,10 @@ export function useConversation(options) {
|
|
|
99
98
|
setMessagesState(prev => mergeSavedMessages({ previous: prev, saved }));
|
|
100
99
|
}
|
|
101
100
|
catch (error) {
|
|
102
|
-
if (!disposed)
|
|
103
|
-
|
|
101
|
+
if (!disposed) {
|
|
102
|
+
const logger = options.report ?? createConsoleLogger({ prefix: '' });
|
|
103
|
+
logger.error({ message: '[chat] conversation refresh failed' }, { error });
|
|
104
|
+
}
|
|
104
105
|
}
|
|
105
106
|
finally {
|
|
106
107
|
pending = false;
|
|
@@ -116,7 +117,7 @@ export function useConversation(options) {
|
|
|
116
117
|
target.addEventListener(event, schedule);
|
|
117
118
|
return () => { disposed = true; clearTimeout(timer); for (const [target, event] of events)
|
|
118
119
|
target.removeEventListener(event, schedule); };
|
|
119
|
-
}, [options.refreshSignal, run.isStreaming]);
|
|
120
|
+
}, [options.refreshSignal, run.isStreaming, options.report]);
|
|
120
121
|
/**
|
|
121
122
|
* The mount-time snapshot of `initialMessages`, captured once — the same "read once, never react
|
|
122
123
|
* to a later identity change" contract `messages`'s own `useState` initializer above already has
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Logger } from '@jini-ai/core/primitives';
|
|
1
2
|
import type { AgentEvent } from '../../core/index.js';
|
|
2
3
|
import type { ChatTransport, StartRunInput } from '../../core/index.js';
|
|
3
4
|
export type RunStreamStatus = 'idle' | 'streaming' | 'done' | 'error' | 'canceled';
|
|
@@ -25,5 +26,7 @@ export interface UseRunStreamResult extends RunStreamState {
|
|
|
25
26
|
}
|
|
26
27
|
export declare function useRunStream({ transport }: {
|
|
27
28
|
transport: ChatTransport;
|
|
29
|
+
}, { report }?: {
|
|
30
|
+
report?: Pick<Logger, 'error'> | undefined;
|
|
28
31
|
}): UseRunStreamResult;
|
|
29
32
|
//# sourceMappingURL=useRunStream.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createConsoleLogger } from '@jini-ai/core/primitives';
|
|
2
2
|
/**
|
|
3
3
|
* @module useRunStream
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ import { formatErrorForLog } from '@jini-ai/core';
|
|
|
6
6
|
* error/terminal state, and the ephemeral tool-input-delta buffer (keyed by
|
|
7
7
|
* tool id) for a single active run. Calls `transport.startRun`/
|
|
8
8
|
* `reattachRun`/`stopRun` — never touches `fetch`/`EventSource` itself; the
|
|
9
|
-
* `ChatTransport` port (see
|
|
9
|
+
* `ChatTransport` port (see `packages/chat/src/core/transport.ts`) is the only I/O this hook
|
|
10
10
|
* performs. Per `ADS-memory/reports/jini-port/recon/r4b-webui-design.md` §4's hook table.
|
|
11
11
|
*
|
|
12
12
|
* This hook IS the "single-instance orchestrator" the §4 accumulating-
|
|
@@ -20,8 +20,8 @@ import { formatErrorForLog } from '@jini-ai/core';
|
|
|
20
20
|
*/
|
|
21
21
|
import { mergeRunEvents } from '../../core/durable-projection.js';
|
|
22
22
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
23
|
-
function reportRunStreamHostEffectFailure(effectName, error) {
|
|
24
|
-
|
|
23
|
+
function reportRunStreamHostEffectFailure({ effectName, error }, { report: logger = createConsoleLogger({ prefix: '' }) } = {}) {
|
|
24
|
+
logger.error({ message: `[@jini-ai/chat] useRunStream ${effectName} host effect failed:` }, { error });
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Fire-and-forget teardown call to `transport.stopRun`. Invokes it synchronously, then observes
|
|
@@ -30,17 +30,17 @@ function reportRunStreamHostEffectFailure(effectName, error) {
|
|
|
30
30
|
* the browser it is a silent, undiagnosable console error. Neither call site awaits the result
|
|
31
31
|
* or calls `setState`, so there is nothing here that could touch state after unmount.
|
|
32
32
|
*/
|
|
33
|
-
function runStopRunHostEffect(effectName, effect) {
|
|
33
|
+
function runStopRunHostEffect({ effectName, effect }, { report } = {}) {
|
|
34
34
|
let result;
|
|
35
35
|
try {
|
|
36
36
|
result = effect();
|
|
37
37
|
}
|
|
38
38
|
catch (error) {
|
|
39
|
-
reportRunStreamHostEffectFailure(effectName, error);
|
|
39
|
+
reportRunStreamHostEffectFailure({ effectName, error }, { report });
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
void result.catch((error) => {
|
|
43
|
-
reportRunStreamHostEffectFailure(effectName, error);
|
|
43
|
+
reportRunStreamHostEffectFailure({ effectName, error }, { report });
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
const INITIAL_STATE = {
|
|
@@ -50,7 +50,7 @@ const INITIAL_STATE = {
|
|
|
50
50
|
error: null,
|
|
51
51
|
toolInputDeltas: {},
|
|
52
52
|
};
|
|
53
|
-
export function useRunStream({ transport }) {
|
|
53
|
+
export function useRunStream({ transport }, { report } = {}) {
|
|
54
54
|
const [state, setState] = useState(INITIAL_STATE);
|
|
55
55
|
// Acceptance/checkpoints can precede React's next commit. Cancellation needs the live id,
|
|
56
56
|
// even when the Stop handler still belongs to the render that showed a pending start.
|
|
@@ -132,7 +132,7 @@ export function useRunStream({ transport }) {
|
|
|
132
132
|
if (generationRef.current !== generation) {
|
|
133
133
|
// Consumed rather than assumed: only a CANCEL leaves an orphan here.
|
|
134
134
|
if (canceledGenerations.current.delete(generation)) {
|
|
135
|
-
runStopRunHostEffect('transport.stopRun (orphaned generation)', () => transport.stopRun(runId));
|
|
135
|
+
runStopRunHostEffect({ effectName: 'transport.stopRun (orphaned generation)', effect: () => transport.stopRun(runId) }, { report });
|
|
136
136
|
}
|
|
137
137
|
return { runId };
|
|
138
138
|
}
|
|
@@ -149,7 +149,7 @@ export function useRunStream({ transport }) {
|
|
|
149
149
|
setState((prev) => ({ ...prev, status: 'error', error: toError(err) }));
|
|
150
150
|
return null;
|
|
151
151
|
}
|
|
152
|
-
}, [makeHandlers, teardownSubscription, transport]);
|
|
152
|
+
}, [makeHandlers, teardownSubscription, transport, report]);
|
|
153
153
|
const reattach = useCallback(async (runId, initialEvents = []) => {
|
|
154
154
|
teardownSubscription();
|
|
155
155
|
generationRef.current += 1;
|
|
@@ -185,8 +185,8 @@ export function useRunStream({ transport }) {
|
|
|
185
185
|
teardownSubscription();
|
|
186
186
|
setState((prev) => ({ ...prev, status: 'canceled' }));
|
|
187
187
|
if (runId)
|
|
188
|
-
runStopRunHostEffect('transport.stopRun (cancel)', () => transport.stopRun(runId));
|
|
189
|
-
}, [teardownSubscription, transport]);
|
|
188
|
+
runStopRunHostEffect({ effectName: 'transport.stopRun (cancel)', effect: () => transport.stopRun(runId) }, { report });
|
|
189
|
+
}, [teardownSubscription, transport, report]);
|
|
190
190
|
const reset = useCallback(() => {
|
|
191
191
|
generationRef.current += 1;
|
|
192
192
|
runIdRef.current = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type McpUiToolCallHandler, type UIResource } from '@jini-ai/
|
|
1
|
+
import { type McpUiToolCallHandler, type UIResource } from '@jini-ai/protocol/mcp-ui';
|
|
2
2
|
import type { ExtEventCall } from '../ext-event-renderer-registry.js';
|
|
3
3
|
/** Restore only an unanswered call: completed decisions must never execute twice. */
|
|
4
4
|
export declare function surfaceNeedsRecovery({ call, runStreaming }: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { parseUIResource } from '@jini-ai/
|
|
2
|
+
import { parseUIResource, } from '@jini-ai/protocol/mcp-ui';
|
|
3
3
|
import { recoverableSurfaceResource, surfaceRecoveryInfo, SURFACE_EXCHANGE_META } from '../../core/surface-recovery.js';
|
|
4
4
|
/** Restore only an unanswered call: completed decisions must never execute twice. */
|
|
5
5
|
export function surfaceNeedsRecovery({ call, runStreaming }, _options = {}) {
|
|
@@ -32,7 +32,7 @@ export function useSurfaceRecovery({ resource, call, runStreaming, onToolCall },
|
|
|
32
32
|
const onSurface = (emission) => {
|
|
33
33
|
if (emission.channel !== 'mcp-ui')
|
|
34
34
|
return;
|
|
35
|
-
const next = parseUIResource(recoverableSurfaceResource({ resource: emission.payload['resource'], exchange: emission.payload['surfaceExchange'] }));
|
|
35
|
+
const next = parseUIResource({ value: recoverableSurfaceResource({ resource: emission.payload['resource'], exchange: emission.payload['surfaceExchange'] }) });
|
|
36
36
|
if (next) {
|
|
37
37
|
setRestored(next);
|
|
38
38
|
setLive(true);
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* chat/core vocabulary. Every export is explicit: adding or renaming a name here is a public API
|
|
4
4
|
* review, so internal module exports cannot silently become public. Do not use export *.
|
|
5
5
|
*/
|
|
6
|
+
export { Icon } from './components/Icon.js';
|
|
7
|
+
export type { IconName } from './components/Icon.js';
|
|
6
8
|
export { ChatSettingsDialog } from './components/ChatSettingsDialog.js';
|
|
7
9
|
export { ChatSettingsSegmented } from './components/ChatSettingsSegmented.js';
|
|
8
10
|
export { useChatSettingsDialog } from './components/ChatSettingsDialog.hooks.js';
|
|
@@ -151,12 +153,10 @@ export type { JiniChatProviderProps, JiniChatSlots } from './components/JiniChat
|
|
|
151
153
|
* Lives here rather than in an example because a consumer cannot copy-paste its way to a
|
|
152
154
|
* transport: this is the piece that makes `ChatPaneAgentBridgeAccess` satisfiable at all.
|
|
153
155
|
*
|
|
154
|
-
*
|
|
155
|
-
* extraction — re-exported here so existing `@jini-ai/chat-react` importers keep working.
|
|
156
|
+
* The DOM page driver lives in `@jini-ai/agentic/dom`; hosts bind it through the bridge's `page` port.
|
|
156
157
|
*/
|
|
157
158
|
export { createFrontendSessionBridge, createFrontendNavigationGuard } from './agent-bridge/frontend-session-bridge.js';
|
|
158
159
|
export type { FrontendSessionBridge, FrontendNavigationGuard, FrontendSessionBridgeArgs, FrontendSessionBridgeOptions, } from './agent-bridge/frontend-session-bridge.js';
|
|
159
|
-
export { createDomPageDriver, currentAgentPage, type DomPageDriverOptions } from '@jini-ai/agentic/dom';
|
|
160
160
|
export { createBrowserComposerHistoryStorage } from './hooks/composer-history-storage.js';
|
|
161
161
|
export type { ComposerHistoryStoragePort } from '../core/composer-history.js';
|
|
162
162
|
export { SECRET_REDACTED_NOTICE, redactUserText } from '../core/user-text-redaction.js';
|
|
@@ -178,4 +178,7 @@ export { isAwaitingAnswer } from '../core/run-activity.js';
|
|
|
178
178
|
export { createFrontendRequestCaller } from './features/chat-pane/create-frontend-request-caller.js';
|
|
179
179
|
export type { FrontendRequestCallerRequired, FrontendRequestInput } from './features/chat-pane/create-frontend-request-caller.js';
|
|
180
180
|
export type { SurfaceRecoveryInfo } from '../core/surface-recovery.js';
|
|
181
|
+
export { ChatSurfacesProvider, useChatSurfaces, McpUiHost } from './surfaces.js';
|
|
182
|
+
export type { ChatSurfaces, McpUiHostProps, ChatSurfaceComponentEntry, ChatSurfaceRegistry, AgentModelContextToolRegistration, AgentModelContextLike, } from './surfaces.js';
|
|
183
|
+
export type { ChatPagePort } from '../core/page-port.js';
|
|
181
184
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/react/index.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* chat/core vocabulary. Every export is explicit: adding or renaming a name here is a public API
|
|
4
4
|
* review, so internal module exports cannot silently become public. Do not use export *.
|
|
5
5
|
*/
|
|
6
|
+
// The chat-pane feature renders this glyph set; a consumer composing the same surface needs the same icons.
|
|
7
|
+
export { Icon } from './components/Icon.js';
|
|
6
8
|
export { ChatSettingsDialog } from './components/ChatSettingsDialog.js';
|
|
7
9
|
export { ChatSettingsSegmented } from './components/ChatSettingsSegmented.js';
|
|
8
10
|
export { useChatSettingsDialog } from './components/ChatSettingsDialog.hooks.js';
|
|
@@ -130,11 +132,9 @@ export { JiniChatProvider, useJiniChatSlots, useOnFeedback } from './components/
|
|
|
130
132
|
* Lives here rather than in an example because a consumer cannot copy-paste its way to a
|
|
131
133
|
* transport: this is the piece that makes `ChatPaneAgentBridgeAccess` satisfiable at all.
|
|
132
134
|
*
|
|
133
|
-
*
|
|
134
|
-
* extraction — re-exported here so existing `@jini-ai/chat-react` importers keep working.
|
|
135
|
+
* The DOM page driver lives in `@jini-ai/agentic/dom`; hosts bind it through the bridge's `page` port.
|
|
135
136
|
*/
|
|
136
137
|
export { createFrontendSessionBridge, createFrontendNavigationGuard } from './agent-bridge/frontend-session-bridge.js';
|
|
137
|
-
export { createDomPageDriver, currentAgentPage } from '@jini-ai/agentic/dom';
|
|
138
138
|
export { createBrowserComposerHistoryStorage } from './hooks/composer-history-storage.js';
|
|
139
139
|
// ChatPane consumers share the same redaction and draft/preview state owners.
|
|
140
140
|
export { SECRET_REDACTED_NOTICE, redactUserText } from '../core/user-text-redaction.js';
|
|
@@ -148,4 +148,6 @@ export { AGENT_PLUGIN_STATE_CHANGED, readAgentPluginChatState, writeAgentPluginC
|
|
|
148
148
|
export { acceptedInputEvent, acceptedInputUserEvent, projectAcceptedInputEvents } from '../core/accepted-input.js';
|
|
149
149
|
export { isAwaitingAnswer } from '../core/run-activity.js';
|
|
150
150
|
export { createFrontendRequestCaller } from './features/chat-pane/create-frontend-request-caller.js';
|
|
151
|
+
// Hosts bind the rich-surface implementations (MCP-UI iframe host, interactive registry, WebMCP probe) once, at the React root.
|
|
152
|
+
export { ChatSurfacesProvider, useChatSurfaces, McpUiHost } from './surfaces.js';
|
|
151
153
|
//# sourceMappingURL=index.js.map
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
padding: 0;
|
|
19
19
|
overflow: hidden;
|
|
20
20
|
border: var(--jini-border-width, 1px) solid var(--jini-chat-settings-border, #d9dce2);
|
|
21
|
-
border-radius: var(--radius-lg, 12px);
|
|
21
|
+
border-radius: var(--jini-chat-radius-lg, 12px);
|
|
22
22
|
background: var(--jini-chat-settings-bg, #fff);
|
|
23
23
|
color: var(--jini-chat-settings-fg, #1a1916);
|
|
24
24
|
font: inherit;
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
.jini-chat-settings-dialog .jini-chat-settings-close {
|
|
38
38
|
display: inline-flex; align-items: center; justify-content: center; flex: none;
|
|
39
39
|
width: 2.25rem; height: 2.25rem; min-width: 0; min-height: 0; padding: 0;
|
|
40
|
-
border: 0; border-radius: var(--radius, 8px); background: transparent; color: var(--jini-chat-settings-muted, #676767);
|
|
40
|
+
border: 0; border-radius: var(--jini-chat-radius, 8px); background: transparent; color: var(--jini-chat-settings-muted, #676767);
|
|
41
41
|
font-size: 1.5rem; line-height: 1; cursor: pointer;
|
|
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); }
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
.jini-chat-settings-dialog > .tab-bar .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
|
-
margin-bottom: -1px; font: inherit; font-size: var(--
|
|
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
52
|
.jini-chat-settings-dialog > .tab-bar .tab-bar-item:hover { color: var(--jini-chat-settings-fg, #1a1916); }
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
}
|
|
62
62
|
.jini-chat-settings-group { display: flex; flex-direction: column; min-width: 0; margin: 0; padding: 0; border: 0; }
|
|
63
63
|
.jini-chat-settings-group + .jini-chat-settings-group { margin-top: 1.25rem; }
|
|
64
|
-
.jini-chat-settings-legend { padding: 0; margin-bottom: 0.5rem; font-size: var(--
|
|
64
|
+
.jini-chat-settings-legend { padding: 0; margin-bottom: 0.5rem; font-size: var(--jini-font-size-sm, 0.875rem); font-weight: 600; color: var(--jini-chat-settings-fg, #1a1916); }
|
|
65
65
|
/* Tool calls: the shared segmented-control look, built on real radios for keyboard and AT. */
|
|
66
66
|
.jini-chat-settings-segmented {
|
|
67
67
|
display: inline-flex; flex-wrap: wrap; align-self: flex-start; max-width: 100%; gap: 0.25rem; padding: 0.2rem;
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
.jini-chat-settings-legend > .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
|
-
border-radius: 6px; font-size: var(--
|
|
73
|
+
border-radius: 6px; font-size: var(--jini-font-size-sm, 0.875rem); color: var(--jini-chat-settings-muted, #676767); cursor: pointer;
|
|
74
74
|
}
|
|
75
75
|
.jini-chat-settings-segment input {
|
|
76
76
|
position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
|
|
@@ -116,16 +116,16 @@ button.jini-chat-settings-segment:hover { opacity: 1; }
|
|
|
116
116
|
@media (prefers-reduced-motion: reduce) {
|
|
117
117
|
.jini-chat-settings-dialog input[role="switch"], .jini-chat-settings-dialog input[role="switch"]::after { transition: none; }
|
|
118
118
|
}
|
|
119
|
-
.jini-chat-settings-note { margin: 0 0 1rem; font-size: var(--
|
|
120
|
-
.jini-chat-settings-error { margin: 1rem 0 0; font-size: var(--
|
|
119
|
+
.jini-chat-settings-note { margin: 0 0 1rem; font-size: var(--jini-font-size-sm, 0.875rem); color: var(--jini-chat-settings-muted, #676767); line-height: 1.5; }
|
|
120
|
+
.jini-chat-settings-error { margin: 1rem 0 0; font-size: var(--jini-font-size-sm, 0.875rem); color: var(--jini-chat-settings-danger, #b42318); }
|
|
121
121
|
.jini-chat-settings-row--master {
|
|
122
|
-
padding: 0.625rem 1rem; border: 1px solid var(--jini-chat-settings-border, #d9dce2); border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
|
|
122
|
+
padding: 0.625rem 1rem; border: 1px solid var(--jini-chat-settings-border, #d9dce2); border-radius: var(--jini-chat-radius-lg, 12px) var(--jini-chat-radius-lg, 12px) 0 0;
|
|
123
123
|
background: var(--jini-chat-settings-subtle, #f4f5f7);
|
|
124
124
|
}
|
|
125
125
|
.jini-chat-settings-row--master .jini-chat-settings-label { font-weight: 600; }
|
|
126
126
|
.jini-chat-settings-capabilities {
|
|
127
127
|
padding: 0.375rem 1rem 0.5rem 1.75rem; border: 1px solid var(--jini-chat-settings-border, #d9dce2); border-top: 0;
|
|
128
|
-
border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
|
|
128
|
+
border-radius: 0 0 var(--jini-chat-radius-lg, 12px) var(--jini-chat-radius-lg, 12px);
|
|
129
129
|
}
|
|
130
130
|
/* Help has its own touch target, outside every setting's button or label. The 44px target is an
|
|
131
131
|
invisible hit area (17.6px icon + 2 × 13px), not a wider icon: sizing the icon itself to 44px
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Chat's rich-surface port: the implementations a chat card renders through but must not
|
|
3
|
+
* import (owner 2026-11-15, everything injected). Wire vocabulary (A2UI, MCP-UI resources) is NOT
|
|
4
|
+
* here: it is plain data from @jini-ai/protocol. What is here renders or probes the host: the
|
|
5
|
+
* MCP-UI sandbox iframe, the interactive component registry, the registry->catalog builder, and
|
|
6
|
+
* WebMCP model-context detection. The host proves compatibility with `satisfies ChatSurfaces`.
|
|
7
|
+
* The first `surfaces` value is kept: `useModelContext`-style slots must not change identity.
|
|
8
|
+
*/
|
|
9
|
+
import { type ComponentType, type ReactNode } from 'react';
|
|
10
|
+
import type { Catalog, ComponentSpec } from '@jini-ai/protocol/a2ui';
|
|
11
|
+
import type { McpUiToolCallHandler } from '@jini-ai/protocol/mcp-ui';
|
|
12
|
+
/** Only the props chat passes to the MCP-UI iframe host. */
|
|
13
|
+
export interface McpUiHostProps {
|
|
14
|
+
readonly title: string;
|
|
15
|
+
readonly html: string;
|
|
16
|
+
readonly sandboxProxyUrl: URL;
|
|
17
|
+
readonly toolName?: string;
|
|
18
|
+
readonly sessionKey?: string | number;
|
|
19
|
+
readonly onToolCall?: McpUiToolCallHandler;
|
|
20
|
+
readonly onOpenLink?: (url: string) => void;
|
|
21
|
+
readonly initialHeight?: number;
|
|
22
|
+
readonly maxHeight?: number | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** A registry component chat can render inside an A2UI surface. */
|
|
25
|
+
export interface ChatSurfaceComponentEntry {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly propsSchema: ComponentSpec['propsSchema'];
|
|
28
|
+
readonly Component: ComponentType<Record<string, unknown>>;
|
|
29
|
+
readonly actionProp?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ChatSurfaceRegistry {
|
|
32
|
+
list(required?: Record<string, never>, optional?: Record<string, never>): readonly ChatSurfaceComponentEntry[];
|
|
33
|
+
resolveById(required: {
|
|
34
|
+
id: string;
|
|
35
|
+
}, optional?: Record<string, never>): ChatSurfaceComponentEntry | null;
|
|
36
|
+
}
|
|
37
|
+
export interface AgentModelContextToolRegistration {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly title?: string;
|
|
40
|
+
readonly description: string;
|
|
41
|
+
readonly inputSchema: unknown;
|
|
42
|
+
readonly execute: (args: Record<string, unknown>) => Promise<unknown>;
|
|
43
|
+
readonly annotations?: {
|
|
44
|
+
readonly readOnlyHint?: boolean;
|
|
45
|
+
readonly untrustedContentHint?: boolean;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface AgentModelContextLike {
|
|
49
|
+
registerTool(required: {
|
|
50
|
+
tool: AgentModelContextToolRegistration;
|
|
51
|
+
}, options?: {
|
|
52
|
+
readonly signal?: AbortSignal;
|
|
53
|
+
readonly exposedTo?: readonly string[];
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
unregisterTool?(required: {
|
|
56
|
+
name: string;
|
|
57
|
+
}, _optional?: Record<string, never>): void;
|
|
58
|
+
}
|
|
59
|
+
export interface ChatSurfaces {
|
|
60
|
+
readonly mcpUi: {
|
|
61
|
+
readonly Host: ComponentType<McpUiHostProps>;
|
|
62
|
+
};
|
|
63
|
+
readonly interactiveUi: {
|
|
64
|
+
readonly defaultRegistry: ChatSurfaceRegistry;
|
|
65
|
+
};
|
|
66
|
+
readonly a2ui: {
|
|
67
|
+
catalogFromRegistry(required: {
|
|
68
|
+
registry: Pick<ChatSurfaceRegistry, 'list'>;
|
|
69
|
+
catalogId: string;
|
|
70
|
+
}, optional?: {
|
|
71
|
+
base?: Catalog;
|
|
72
|
+
}): Catalog;
|
|
73
|
+
};
|
|
74
|
+
readonly page: {
|
|
75
|
+
getModelContext(required: {
|
|
76
|
+
host: {
|
|
77
|
+
candidates(required: Record<string, never>): readonly unknown[];
|
|
78
|
+
};
|
|
79
|
+
}, optional?: Record<string, never>): AgentModelContextLike | undefined;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export declare function ChatSurfacesProvider(required: {
|
|
83
|
+
surfaces: ChatSurfaces;
|
|
84
|
+
children: ReactNode;
|
|
85
|
+
}): import("react").JSX.Element;
|
|
86
|
+
export declare function useChatSurfaces(): ChatSurfaces;
|
|
87
|
+
/** Same-name facade, so McpUiSurfaceCard changes only its import line. */
|
|
88
|
+
export declare function McpUiHost({ useChatSurfacesHook, ...props }: McpUiHostProps & {
|
|
89
|
+
useChatSurfacesHook?: typeof useChatSurfaces;
|
|
90
|
+
}): import("react").JSX.Element;
|
|
91
|
+
//# sourceMappingURL=surfaces.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @file Chat's rich-surface port: the implementations a chat card renders through but must not
|
|
4
|
+
* import (owner 2026-11-15, everything injected). Wire vocabulary (A2UI, MCP-UI resources) is NOT
|
|
5
|
+
* here: it is plain data from @jini-ai/protocol. What is here renders or probes the host: the
|
|
6
|
+
* MCP-UI sandbox iframe, the interactive component registry, the registry->catalog builder, and
|
|
7
|
+
* WebMCP model-context detection. The host proves compatibility with `satisfies ChatSurfaces`.
|
|
8
|
+
* The first `surfaces` value is kept: `useModelContext`-style slots must not change identity.
|
|
9
|
+
*/
|
|
10
|
+
import { createContext, useContext, useState } from 'react';
|
|
11
|
+
const ChatSurfacesContext = createContext(null);
|
|
12
|
+
export function ChatSurfacesProvider(required) {
|
|
13
|
+
const [surfaces] = useState(() => required.surfaces);
|
|
14
|
+
return _jsx(ChatSurfacesContext.Provider, { value: surfaces, children: required.children });
|
|
15
|
+
}
|
|
16
|
+
export function useChatSurfaces() {
|
|
17
|
+
const surfaces = useContext(ChatSurfacesContext);
|
|
18
|
+
if (!surfaces)
|
|
19
|
+
throw new Error('Chat MCP-UI and A2UI cards need <ChatSurfacesProvider surfaces={...}> above them '
|
|
20
|
+
+ '(or a ChatKitProvider whose kit has `surfaces`). Hosts bind the implementations once per React root.');
|
|
21
|
+
return surfaces;
|
|
22
|
+
}
|
|
23
|
+
/** Same-name facade, so McpUiSurfaceCard changes only its import line. */
|
|
24
|
+
export function McpUiHost({ useChatSurfacesHook = useChatSurfaces, ...props }) {
|
|
25
|
+
const { Host } = useChatSurfacesHook().mcpUi;
|
|
26
|
+
return _jsx(Host, { ...props });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=surfaces.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type Logger } from '@jini-ai/core/primitives';
|
|
1
2
|
import type { DurableRecovery, RecoveryPorts } from "../../core/durable-runs/ports.js";
|
|
2
3
|
export { RECOVERY_LIMIT, RECOVERY_WINDOW_MS, RUN_STALENESS_MS, SAVED_WORK_NOTICE, AWAITING_ANSWER_NOTICE, EXHAUSTED_NOTICE } from "../../core/durable-runs/policies.js";
|
|
3
4
|
/** Recovery coordinator behind explicit host ports. One CAS owns both the attempt and its conversation slot.
|
|
4
|
-
* Each recovery decision
|
|
5
|
-
export declare function createDurableRecovery(ports: RecoveryPorts, {
|
|
6
|
-
|
|
5
|
+
* Each recovery decision reports run metadata through the host port or the safe default logger. */
|
|
6
|
+
export declare function createDurableRecovery(ports: RecoveryPorts, { report }?: {
|
|
7
|
+
report?: Pick<Logger, "info">;
|
|
7
8
|
}): DurableRecovery;
|
|
8
9
|
//# sourceMappingURL=recover.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createConsoleLogger } from '@jini-ai/core/primitives';
|
|
1
2
|
import { recoveredRunEvents } from "../../core/index.js";
|
|
2
3
|
import { classifyAgentServiceFailure, startupFailureMessage } from "@jini-ai/agent-runtime";
|
|
3
4
|
import { continuationRequest } from "../../core/durable-runs/continuation.js";
|
|
@@ -133,8 +134,8 @@ function continuesNow({ run, trigger, now }, _optional = {}) {
|
|
|
133
134
|
return trigger === "attempt-failed" || now - run.attemptStartedAt >= 10_000;
|
|
134
135
|
}
|
|
135
136
|
/** Recovery coordinator behind explicit host ports. One CAS owns both the attempt and its conversation slot.
|
|
136
|
-
* Each recovery decision
|
|
137
|
-
export function createDurableRecovery(ports, {
|
|
137
|
+
* Each recovery decision reports run metadata through the host port or the safe default logger. */
|
|
138
|
+
export function createDurableRecovery(ports, { report = createConsoleLogger({ prefix: '' }) } = {}) {
|
|
138
139
|
/** Replay starts from attemptBase. Carry this attempt's saved launch notice into it too, so
|
|
139
140
|
* reconnect/reload cannot replace that evidence with the daemon's shorter replay prefix.
|
|
140
141
|
* O(e) in saved events; no additional store read, write, or polling. */
|
|
@@ -312,7 +313,7 @@ export function createDurableRecovery(ports, { logger = console } = {}) {
|
|
|
312
313
|
// The watcher re-confirms its own live run every resolution window; log only real recovery
|
|
313
314
|
// decisions. Metadata only: diagnostics, answers and cancel reasons can hold secrets.
|
|
314
315
|
if (options.liveRunId !== run.runId)
|
|
315
|
-
|
|
316
|
+
report.info({ message: "[durable-recovery] Recovery decision." }, { meta: { runId: run.runId, trigger, probe, decision, failureClass: failure } });
|
|
316
317
|
return decision;
|
|
317
318
|
},
|
|
318
319
|
};
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Owns conversation CRUD and list/get queries with per-conversation run summaries and
|
|
4
4
|
* total run-duration aggregation. Imports only the core/ kernel (types + rows helper).
|
|
5
5
|
*/
|
|
6
|
-
import type { SqliteDb } from '@jini-ai/
|
|
7
|
-
import type { DbRow } from '@jini-ai/db/core';
|
|
6
|
+
import type { SqliteDb, DbRow } from '@jini-ai/core/contracts/storage';
|
|
8
7
|
import type { ChatSessionMode } from '../index.js';
|
|
9
8
|
/**
|
|
10
9
|
* Returns all conversations for a project, newest first, each enriched with message count,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rows } from '@jini-ai/
|
|
1
|
+
import { rows } from '@jini-ai/core/contracts/storage';
|
|
2
2
|
/**
|
|
3
3
|
* @internal Builds the summary query shared by `listConversations` and `getConversation`: every
|
|
4
4
|
* conversation matching `filterColumn = ?`, each enriched with message count, the latest assistant
|
|
@@ -9,11 +9,10 @@ import { type SecretRedactionSignal, type UserTextRedactionOptions } from '../..
|
|
|
9
9
|
* scope for this port), `produced_files_json` and `trace_object_files_json` (design-canvas file
|
|
10
10
|
* output tracking), `feedback_json` (Critique Theater's scoring feedback), `pre_turn_file_names_json`
|
|
11
11
|
* (design-canvas per-turn file context), and `applied_plugin_snapshot_json` (OD's plugin host). The
|
|
12
|
-
* already-ported `schema
|
|
12
|
+
* already-ported `packages/chat/src/store/legacy/sqlite/schema.ts` messages table was pre-trimmed to match; see that file and
|
|
13
13
|
* `source-map.md`'s Design Decisions for the same drop list.
|
|
14
14
|
*/
|
|
15
|
-
import type { SqliteDb } from '@jini-ai/
|
|
16
|
-
import type { DbRow } from '@jini-ai/db/core';
|
|
15
|
+
import type { SqliteDb, DbRow } from '@jini-ai/core/contracts/storage';
|
|
17
16
|
import type { ChatSessionMode } from '../index.js';
|
|
18
17
|
/**
|
|
19
18
|
* Returns all messages for a conversation in ascending position order, with JSON columns parsed.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { withFolderReceipt, foldersFromReceipts } from "../../../core/accepted-input.js";
|
|
2
2
|
import { redactUserText } from '../../../core/user-text-redaction.js';
|
|
3
|
-
import { parseJsonOrUndef } from '@jini-ai/
|
|
3
|
+
import { parseJsonOrUndef } from '@jini-ai/core/contracts/storage';
|
|
4
4
|
/** @internal Column alias list used by both `listMessages` and `upsertMessage`'s re-fetch. */
|
|
5
5
|
const MESSAGE_COLS = `id, role, content, agent_id AS agentId, agent_name AS agentName,
|
|
6
6
|
run_id AS runId, run_status AS runStatus,
|
|
@@ -228,7 +228,7 @@ function readStoredEvents({ db, messageId }) {
|
|
|
228
228
|
.get(messageId);
|
|
229
229
|
if (!row)
|
|
230
230
|
return null;
|
|
231
|
-
const parsed = parseJsonOrUndef(row.eventsJson);
|
|
231
|
+
const parsed = parseJsonOrUndef({ s: row.eventsJson });
|
|
232
232
|
return Array.isArray(parsed) ? parsed : [];
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
@@ -274,7 +274,7 @@ export function deleteMessage({ db, id }) {
|
|
|
274
274
|
}
|
|
275
275
|
/** @internal Converts a raw SQLite row to a plain object with JSON columns parsed and null coerced to undefined. */
|
|
276
276
|
function normalizeMessage(row) {
|
|
277
|
-
const folders = foldersFromReceipts({ events: parseJsonOrUndef(row.eventsJson) });
|
|
277
|
+
const folders = foldersFromReceipts({ events: parseJsonOrUndef({ s: row.eventsJson }) });
|
|
278
278
|
return {
|
|
279
279
|
id: row.id,
|
|
280
280
|
role: row.role,
|
|
@@ -284,11 +284,11 @@ function normalizeMessage(row) {
|
|
|
284
284
|
runId: row.runId ?? undefined,
|
|
285
285
|
runStatus: row.runStatus ?? undefined,
|
|
286
286
|
lastRunEventId: row.lastRunEventId ?? undefined,
|
|
287
|
-
events: parseJsonOrUndef(row.eventsJson),
|
|
288
|
-
attachments: parseJsonOrUndef(row.attachmentsJson),
|
|
287
|
+
events: parseJsonOrUndef({ s: row.eventsJson }),
|
|
288
|
+
attachments: parseJsonOrUndef({ s: row.attachmentsJson }),
|
|
289
289
|
...(folders.length ? { folders } : {}),
|
|
290
290
|
sessionMode: normalizeMessageSessionMode(row.sessionMode),
|
|
291
|
-
runContext: parseJsonOrUndef(row.runContextJson),
|
|
291
|
+
runContext: parseJsonOrUndef({ s: row.runContextJson }),
|
|
292
292
|
createdAt: row.createdAt ?? undefined,
|
|
293
293
|
startedAt: row.startedAt ?? undefined,
|
|
294
294
|
endedAt: row.endedAt ?? undefined,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { UserTextRedactionOptions } from '../../core/user-text-redaction.js';
|
|
2
2
|
/** Pglite transcript adapter. The host owns the opened, migrated kernel and its lifetime. */
|
|
3
3
|
import type { Clock } from '@jini-ai/core/primitives';
|
|
4
|
-
import type { StorageKernel } from '@jini-ai/
|
|
4
|
+
import type { StorageKernel } from '@jini-ai/core/contracts/storage';
|
|
5
5
|
import type { ChatDatabase } from '../sql/tables.js';
|
|
6
6
|
import type { ChatOwnerScope, ChatStore, ChatHistoryMaintenance } from '../ports.js';
|
|
7
|
+
import type { Kysely } from 'kysely';
|
|
7
8
|
export type { ChatDatabase, AiChatsTable, AiChatMessagesTable } from '../sql/tables.js';
|
|
8
9
|
/** Borrow an existing kernel, with no configuration, migration or connection lifecycle effects.
|
|
9
|
-
* @example createPgliteChatStore({ kernel, scope
|
|
10
|
+
* @example createPgliteChatStore({ kernel, scope, clock: { nowMs: () => 42 } })
|
|
10
11
|
* @throws ChatStoreError invalid-input for a mismatched dialect/transport or owner scope.
|
|
11
12
|
*/
|
|
12
13
|
export declare function createPgliteChatStore<DB extends ChatDatabase>(required: {
|
|
13
|
-
kernel: StorageKernel<DB>;
|
|
14
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
14
15
|
scope: ChatOwnerScope;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} & UserTextRedactionOptions): ChatStore;
|
|
16
|
+
clock: Clock;
|
|
17
|
+
}, optional?: UserTextRedactionOptions): ChatStore;
|
|
18
18
|
/** Privileged bounded expiry maintenance; never hand this collaborator to request handlers. */
|
|
19
19
|
export declare function createPgliteChatMaintenance<DB extends ChatDatabase>(required: {
|
|
20
|
-
kernel: StorageKernel<DB>;
|
|
20
|
+
kernel: StorageKernel<Kysely<DB>, DB>;
|
|
21
21
|
}): ChatHistoryMaintenance;
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { createSqlChatStore } from '../sql/store.js';
|
|
|
2
2
|
import { createSqlChatMaintenance } from '../sql/maintenance.js';
|
|
3
3
|
import { validateKernel } from '../sql/boundary.js';
|
|
4
4
|
/** Borrow an existing kernel, with no configuration, migration or connection lifecycle effects.
|
|
5
|
-
* @example createPgliteChatStore({ kernel, scope
|
|
5
|
+
* @example createPgliteChatStore({ kernel, scope, clock: { nowMs: () => 42 } })
|
|
6
6
|
* @throws ChatStoreError invalid-input for a mismatched dialect/transport or owner scope.
|
|
7
7
|
*/
|
|
8
8
|
export function createPgliteChatStore(required, optional = {}) {
|