@jini-ai/chat 0.6.22 → 0.7.0
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 +26 -0
- package/README.md +8 -0
- package/dist/core/accepted-input.d.ts +1 -1
- package/dist/core/accepted-input.js +5 -4
- package/dist/core/assistant-client/ag-ui-transport.js +9 -3
- package/dist/core/assistant-client/transport.js +15 -8
- package/dist/core/durable-projection.js +8 -1
- package/dist/core/durable-runs/ports.d.ts +4 -1
- package/dist/core/question-answer.js +2 -1
- package/dist/core/turn-usage.d.ts +1 -1
- package/dist/core/turn-usage.js +4 -5
- package/dist/embed-widget/browser/frontend-session-bridge.d.ts +18 -0
- package/dist/embed-widget/browser/frontend-session-bridge.js +27 -0
- package/dist/react/components/AttachmentTray.d.ts +4 -1
- package/dist/react/components/AttachmentTray.js +20 -5
- package/dist/react/components/Composer.d.ts +3 -1
- package/dist/react/components/Composer.js +16 -14
- package/dist/react/components/ComposerDiscovery.d.ts +2 -0
- package/dist/react/components/ComposerDiscovery.js +4 -3
- package/dist/react/components/ConversationList.d.ts +4 -2
- package/dist/react/components/ConversationList.js +16 -7
- package/dist/react/components/CopyMessageButton.d.ts +3 -1
- package/dist/react/components/CopyMessageButton.js +3 -2
- package/dist/react/components/FolderChips.d.ts +3 -1
- package/dist/react/components/FolderChips.js +8 -5
- package/dist/react/components/MessageList.js +1 -1
- package/dist/react/components/MessageRow.js +13 -6
- package/dist/react/components/ToolCard.js +7 -7
- package/dist/react/components/ToolCard.rules.d.ts +5 -0
- package/dist/react/components/ToolCard.rules.js +9 -2
- package/dist/react/components/mcp-ui-surface-state.js +11 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +1 -1
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +39 -28
- package/dist/react/features/chat-pane/components/ChatPane.js +20 -8
- package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +2 -1
- package/dist/react/features/chat-pane/components/RuntimeDropUp.js +11 -6
- package/dist/react/features/chat-pane/create-frontend-request-caller.d.ts +23 -0
- package/dist/react/features/chat-pane/create-frontend-request-caller.js +56 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +2 -0
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +16 -0
- package/dist/react/features/chat-pane/rules.d.ts +22 -1
- package/dist/react/features/chat-pane/rules.js +36 -10
- package/dist/react/features/chat-pane/styles.d.ts +1 -1
- package/dist/react/features/chat-pane/styles.js +32 -39
- package/dist/react/features/chat-pane/surface-recovery-stream.d.ts +11 -3
- package/dist/react/features/chat-pane/surface-recovery-stream.js +28 -18
- package/dist/react/features/chat-pane/types.d.ts +13 -0
- package/dist/react/index.d.ts +5 -2
- package/dist/react/index.js +2 -1
- package/dist/react/styles/chat-settings.css +149 -0
- package/dist/server/durable-runs/recover.js +43 -6
- package/package.json +21 -18
|
@@ -2,13 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { AgentPluginUsage } from './AgentPluginUsage.js';
|
|
3
3
|
import { SECRET_REDACTED_NOTICE } from '../../../../core/user-text-redaction.js';
|
|
4
4
|
import { useEffect, useId, useMemo, useRef } from 'react';
|
|
5
|
-
import { WorkingDirPicker } from '@jini-ai/ui';
|
|
5
|
+
import { WorkingDirPicker, useAgentHandle } from '@jini-ai/ui';
|
|
6
6
|
import { Composer } from '../../../components/Composer.js';
|
|
7
7
|
import { appendComposerDiscovery } from '../../../components/composer-discovery.js';
|
|
8
|
+
import { Icon } from '../../../components/Icon.js';
|
|
8
9
|
import { MessageList } from '../../../components/MessageList.js';
|
|
9
10
|
import { useT } from '../../../hooks/context.js';
|
|
10
11
|
import { definedProps } from '../../../util/defined-props.js';
|
|
11
|
-
import { describeChatPaneSendBlocker, describeTypedAnswerNotice, isChatPaneApiModeConfigured, isChatPaneFileDropEnabled } from '../rules.js';
|
|
12
|
+
import { chatPaneSendBlockerNeedsNotice, describeAttachmentError, describeChatPaneSendBlocker, describeTypedAnswerNotice, isChatPaneApiModeConfigured, isChatPaneFileDropEnabled } from '../rules.js';
|
|
12
13
|
import { useChatPane } from '../hooks/useChatPane.hooks.js';
|
|
13
14
|
import { useChatPaneAgentControl } from '../hooks/useChatPaneAgentControl.hooks.js';
|
|
14
15
|
import { useChatPaneComposerPlaceholder } from '../hooks/useChatPaneComposerPlaceholder.hooks.js';
|
|
@@ -115,6 +116,11 @@ function ChatPaneTypedAnswerNotice({ typedAnswerNotice, t, }) {
|
|
|
115
116
|
return null;
|
|
116
117
|
return (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: t(describeTypedAnswerNotice({ notice: typedAnswerNotice })) }));
|
|
117
118
|
}
|
|
119
|
+
/** A failed upload, in plain words, with redacted details a person can copy into a report. */
|
|
120
|
+
function ChatPaneAttachmentError({ error, t }) {
|
|
121
|
+
const { summary, details } = describeAttachmentError({ error });
|
|
122
|
+
return (_jsxs("div", { className: "jini-chat-pane__error", role: "alert", children: [_jsx("div", { children: t(summary) }), details ? _jsxs("div", { className: "jini-chat-pane__error-details", children: [t('Details:'), " ", details] }) : null] }));
|
|
123
|
+
}
|
|
118
124
|
/** A send the server never accepted. Its text went back into the composer if that was still empty;
|
|
119
125
|
* Retry sends it again either way (see `useChatPane`'s `retrySend`). */
|
|
120
126
|
function ChatPaneSendError({ sendError, onRetry, t }) {
|
|
@@ -126,7 +132,7 @@ function ChatPaneSendError({ sendError, onRetry, t }) {
|
|
|
126
132
|
* source of truth, so they are rendered as siblings rather than folded into one derived state. */
|
|
127
133
|
function ChatPaneStatusMessages({ sendError, onRetrySend, attachmentError, dropReadError, workingDirectoryError, workingDirectoryPending, workingDirectoryInvalid, runtimeInventoryError, typedAnswerNotice, ...availability }) {
|
|
128
134
|
const { t } = availability;
|
|
129
|
-
return (_jsxs(_Fragment, { children: [_jsx(ChatPaneAvailabilityStatus, { ...availability }), _jsx(ChatPaneSendError, { sendError: sendError, onRetry: onRetrySend, t: t }), attachmentError ?
|
|
135
|
+
return (_jsxs(_Fragment, { children: [_jsx(ChatPaneAvailabilityStatus, { ...availability }), _jsx(ChatPaneSendError, { sendError: sendError, onRetry: onRetrySend, t: t }), attachmentError ? _jsx(ChatPaneAttachmentError, { error: attachmentError, t: t }) : null, dropReadError ? (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: dropReadError })) : null, workingDirectoryError ? (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: workingDirectoryError.message })) : null, _jsx(ChatPaneWorkingDirectoryStatus, { workingDirectoryPending: workingDirectoryPending, workingDirectoryInvalid: workingDirectoryInvalid, t: t }), runtimeInventoryError && !availability.connectingAgents ? (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: runtimeInventoryError.message })) : null, _jsx(ChatPaneTypedAnswerNotice, { typedAnswerNotice: typedAnswerNotice, t: t })] }));
|
|
130
136
|
}
|
|
131
137
|
function ChatPaneWorkingDirectoryBlock({ workingDirectoryAccess, workingDirectoryControlPlacement, pane, t, }) {
|
|
132
138
|
if (workingDirectoryAccess && workingDirectoryControlPlacement === 'below') {
|
|
@@ -215,17 +221,21 @@ function resolveComposerWorkingDirectory(workingDirectoryAccess, workingDirector
|
|
|
215
221
|
* The pending-turn strip previously lived here (a banner bolted above the composer). It now
|
|
216
222
|
* renders inside `<MessageList>` itself, as the newest transcript entry — see that component's
|
|
217
223
|
* `pendingPrompts` prop and this component's own call site below. */
|
|
218
|
-
function ChatPaneComposerArea({ fileDrop, uploadAttachments, pane, disabled, unavailable, placeholder, slots, attachmentAccept, workingDirectoryAccess, workingDirectoryControlPlacement, t, }) {
|
|
224
|
+
function ChatPaneComposerArea({ agentHandle, fileDrop, uploadAttachments, pane, disabled, unavailable, placeholder, slots, attachmentAccept, workingDirectoryAccess, workingDirectoryControlPlacement, t, }) {
|
|
219
225
|
const sendDisabledReasonId = useId();
|
|
220
226
|
const sendDisabledReason = pane.sendBlocker && pane.sendBlocker !== 'streaming'
|
|
221
227
|
? t(describeChatPaneSendBlocker(pane.sendBlocker))
|
|
222
228
|
: undefined;
|
|
223
|
-
|
|
229
|
+
// MOVE: the reason used to sit in the composer's footer row beside the folder and model buttons.
|
|
230
|
+
// It is now a notice above the composer, with the other pane notices; Send's tooltip keeps it.
|
|
231
|
+
// While the pane is unavailable its own banner (loading, no usable CLI) already says it.
|
|
232
|
+
const showsNotice = sendDisabledReason !== undefined && !unavailable && chatPaneSendBlockerNeedsNotice({ blocker: pane.sendBlocker });
|
|
233
|
+
return (_jsxs("div", { className: `jini-chat-pane__drop-target${fileDrop.draggingFiles ? ' is-dragging-files' : ''}`, "data-testid": "chat-pane-file-drop-target", "data-dragging-files": fileDrop.draggingFiles ? 'true' : 'false', ...resolveDropTargetProps(uploadAttachments, fileDrop), children: [fileDrop.draggingFiles ? (_jsx("span", { className: "jini-chat-pane__drop-announcement", role: "status", children: t('Drop files to attach') })) : null, showsNotice ? (_jsxs("div", { id: sendDisabledReasonId, className: "jini-chat-pane__status jini-chat-pane__blocker", role: "status", children: [pane.sendBlocker === 'uploads-pending' ? _jsx(Icon, { name: "spinner", size: 13 }) : null, _jsx("span", { children: sendDisabledReason })] })) : null, _jsx(Composer, { agentHandle: agentHandle, composer: pane.composer, onSend: () => void pane.send(),
|
|
224
234
|
// Streaming no longer locks the textarea: `pane.send()` queues a turn typed during a run
|
|
225
235
|
// rather than refusing it, so the operator can keep writing while the agent thinks.
|
|
226
236
|
disabled: disabled || unavailable,
|
|
227
237
|
// The one blocker `send()` handles itself. Every other refusal still greys out the button.
|
|
228
|
-
sendDisabled: !pane.canSend && pane.sendBlocker !== 'streaming', ...definedProps({ source: { sendDisabledReason, sendDisabledReasonId:
|
|
238
|
+
sendDisabled: !pane.canSend && pane.sendBlocker !== 'streaming', ...definedProps({ source: { sendDisabledReason, sendDisabledReasonId: showsNotice ? sendDisabledReasonId : undefined } }), running: pane.conversation.isStreaming, onCancel: pane.conversation.cancel, ...definedProps({ source: { placeholder } }), slots: slots, ...resolveComposerAttachmentPicker(uploadAttachments, pane, attachmentAccept), ...resolveComposerWorkingDirectory(workingDirectoryAccess, workingDirectoryControlPlacement, pane) }), _jsx(ChatPaneWorkingDirectoryBlock, { workingDirectoryAccess: workingDirectoryAccess, workingDirectoryControlPlacement: workingDirectoryControlPlacement, pane: pane, t: t })] }));
|
|
229
239
|
}
|
|
230
240
|
const EMPTY_SUGGESTIONS = [];
|
|
231
241
|
const CHAT_PANE_DEFAULTS = {
|
|
@@ -323,6 +333,7 @@ function showsControlsSuggestions(embed, messageCount, emptyState) {
|
|
|
323
333
|
*/
|
|
324
334
|
export function ChatPane(props) {
|
|
325
335
|
const p = applyChatPaneDefaults(props);
|
|
336
|
+
const base = useAgentHandle({ agentHandle: p.agentHandle });
|
|
326
337
|
const t = useT();
|
|
327
338
|
const surface = useChatPaneSurface({
|
|
328
339
|
variant: p.variant,
|
|
@@ -363,6 +374,7 @@ export function ChatPane(props) {
|
|
|
363
374
|
uploadAttachments: p.uploadAttachments,
|
|
364
375
|
onActivityChange: p.onActivityChange,
|
|
365
376
|
onMessagesChange: p.onMessagesChange,
|
|
377
|
+
subscribeToSurfaces: p.subscribeToSurfaces,
|
|
366
378
|
redactUserText: p.redactUserText,
|
|
367
379
|
onSecretRedacted: p.onSecretRedacted,
|
|
368
380
|
workingDirectory: p.workingDirectory,
|
|
@@ -394,7 +406,7 @@ export function ChatPane(props) {
|
|
|
394
406
|
const slots = buildChatPaneSlots({
|
|
395
407
|
surfaceSlots: surface.composerSlots,
|
|
396
408
|
embed: surface.embed,
|
|
397
|
-
renderRuntimePicker: () => (_jsx(AgentRuntimePicker, { agents: runtimeView.agents, value: pane.selection, onChange: pane.setSelection, ...definedProps({ source: { onRescan: runtimeView.rescanAgents } }), scanning: runtimeView.scanningAgents, daemonOnline: runtimeView.daemonOnline, placement: p.runtimePickerPlacement, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, ...definedProps({ source: {
|
|
409
|
+
renderRuntimePicker: () => (_jsx(AgentRuntimePicker, { agentHandle: base ? `${base}-runtime` : false, agents: runtimeView.agents, value: pane.selection, onChange: pane.setSelection, ...definedProps({ source: { onRescan: runtimeView.rescanAgents } }), scanning: runtimeView.scanningAgents, daemonOnline: runtimeView.daemonOnline, placement: p.runtimePickerPlacement, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, ...definedProps({ source: {
|
|
398
410
|
onExecutionModeChange: p.onExecutionModeChange,
|
|
399
411
|
byokRuntime: p.byokRuntime,
|
|
400
412
|
onByokModelChange: p.onByokModelChange,
|
|
@@ -405,6 +417,6 @@ export function ChatPane(props) {
|
|
|
405
417
|
const selectSuggestion = useChatPaneSuggestion({ rootRef, setDraft: pane.composer.setDraft });
|
|
406
418
|
const openLinkInNewTab = useChatPaneNewTabLinks();
|
|
407
419
|
const { pendingPrompts, projectFileNameSet } = useChatPaneTranscriptProps({ pane }, definedProps({ source: { projectFileNames: p.projectFileNames } }));
|
|
408
|
-
return (_jsxs("section", { className: chatPaneClassName(p.variant, p.className), style: p.style, "data-activity": pane.activity, ref: rootRef, onClickCapture: openLinkInNewTab, children: [_jsx("style", { "data-jini-chat-pane-styles": "true", children: CHAT_PANE_STYLES }), p.header ?? defaultHeader(p.title, pane.reset, t), p.agentPluginsMode !== 'off' && _jsx(AgentPluginUsage, { conversationId: pane.conversation.conversationId, messages: pane.conversation.messages }), _jsxs("div", { className: "jini-chat-pane__body", children: [_jsx(ChatPaneTranscript, { pane: pane, sendingLabel: p.sendingLabel, emptyState: p.emptyState, embed: surface.embed, suggestions: p.suggestions, onSelectSuggestion: selectSuggestion, pendingPrompts: pendingPrompts, projectFileNameSet: projectFileNameSet, toolCallDisplay: p.toolCallDisplay, showUsageLine: p.showUsageLine, showThinking: p.showThinking, t: t }), _jsxs("div", { className: "jini-chat-pane__controls", ref: controlsRef, children: [showsControlsSuggestions(surface.embed, pane.conversation.messages.length, p.emptyState) && (_jsx(ChatPaneSuggestionsRow, { suggestions: p.suggestions, onSelect: selectSuggestion, t: t })), pane.secretRedacted ? (_jsxs("div", { className: "jini-chat-pane__status jini-chat-pane__status--dismissible", role: "status", children: [_jsx("span", { children: t(SECRET_REDACTED_NOTICE) }), _jsx("button", { type: "button", className: "jini-chat-pane__error-action", onClick: pane.dismissSecretRedacted, children: t('Dismiss') })] })) : null, _jsx(ChatPaneStatusMessages, { unavailable: unavailable, scanningAgents: runtimeView.scanningAgents, connectingAgents: runtimeView.connectingAgents, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, onExecutionModeChange: p.onExecutionModeChange, sendError: pane.conversation.sendError, onRetrySend: () => void pane.retrySend(), attachmentError: pane.attachmentError, dropReadError: fileDrop.dropReadError, workingDirectoryError: pane.workingDirectoryError, workingDirectoryPending: pane.workingDirectoryPending, workingDirectoryInvalid: pane.workingDirectoryInvalid, runtimeInventoryError: inventory.runtimeInventoryError, typedAnswerNotice: pane.typedAnswerNotice, t: t }), _jsx(ChatPaneComposerArea, { fileDrop: fileDrop, uploadAttachments: surface.uploadAttachments, pane: pane, disabled: p.disabled, unavailable: unavailable, placeholder: composerPlaceholder, slots: slots, attachmentAccept: p.attachmentAccept, workingDirectoryAccess: p.workingDirectoryAccess, workingDirectoryControlPlacement: surface.workingDirectoryControlPlacement, t: t })] })] }), p.footer] }));
|
|
420
|
+
return (_jsxs("section", { className: chatPaneClassName(p.variant, p.className), style: p.style, "data-activity": pane.activity, ref: rootRef, onClickCapture: openLinkInNewTab, children: [_jsx("style", { "data-jini-chat-pane-styles": "true", children: CHAT_PANE_STYLES }), p.header ?? defaultHeader(p.title, pane.reset, t), p.agentPluginsMode !== 'off' && _jsx(AgentPluginUsage, { conversationId: pane.conversation.conversationId, messages: pane.conversation.messages }), _jsxs("div", { className: "jini-chat-pane__body", children: [_jsx(ChatPaneTranscript, { pane: pane, sendingLabel: p.sendingLabel, emptyState: p.emptyState, embed: surface.embed, suggestions: p.suggestions, onSelectSuggestion: selectSuggestion, pendingPrompts: pendingPrompts, projectFileNameSet: projectFileNameSet, toolCallDisplay: p.toolCallDisplay, showUsageLine: p.showUsageLine, showThinking: p.showThinking, t: t }), _jsxs("div", { className: "jini-chat-pane__controls", ref: controlsRef, children: [showsControlsSuggestions(surface.embed, pane.conversation.messages.length, p.emptyState) && (_jsx(ChatPaneSuggestionsRow, { suggestions: p.suggestions, onSelect: selectSuggestion, t: t })), pane.secretRedacted ? (_jsxs("div", { className: "jini-chat-pane__status jini-chat-pane__status--dismissible", role: "status", children: [_jsx("span", { children: t(SECRET_REDACTED_NOTICE) }), _jsx("button", { type: "button", className: "jini-chat-pane__error-action", onClick: pane.dismissSecretRedacted, children: t('Dismiss') })] })) : null, _jsx(ChatPaneStatusMessages, { unavailable: unavailable, scanningAgents: runtimeView.scanningAgents, connectingAgents: runtimeView.connectingAgents, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, onExecutionModeChange: p.onExecutionModeChange, sendError: pane.conversation.sendError, onRetrySend: () => void pane.retrySend(), attachmentError: pane.attachmentError, dropReadError: fileDrop.dropReadError, workingDirectoryError: pane.workingDirectoryError, workingDirectoryPending: pane.workingDirectoryPending, workingDirectoryInvalid: pane.workingDirectoryInvalid, runtimeInventoryError: inventory.runtimeInventoryError, typedAnswerNotice: pane.typedAnswerNotice, t: t }), _jsx(ChatPaneComposerArea, { agentHandle: base ? `${base}-composer` : false, fileDrop: fileDrop, uploadAttachments: surface.uploadAttachments, pane: pane, disabled: p.disabled, unavailable: unavailable, placeholder: composerPlaceholder, slots: slots, attachmentAccept: p.attachmentAccept, workingDirectoryAccess: p.workingDirectoryAccess, workingDirectoryControlPlacement: surface.workingDirectoryControlPlacement, t: t })] })] }), p.footer] }));
|
|
409
421
|
}
|
|
410
422
|
//# sourceMappingURL=ChatPane.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
export interface RuntimeDropUpProps {
|
|
3
|
+
agentHandle?: string | false | undefined;
|
|
3
4
|
/** Names both the trigger (with the current value appended) and the menu. */
|
|
4
5
|
label: string;
|
|
5
6
|
/** What the trigger shows: the current choice's display label. */
|
|
@@ -25,5 +26,5 @@ export interface RuntimeDropUpProps {
|
|
|
25
26
|
*
|
|
26
27
|
* @complexity Time/space: O(n) in the option count.
|
|
27
28
|
*/
|
|
28
|
-
export declare function RuntimeDropUp({ label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }: RuntimeDropUpProps): ReactNode;
|
|
29
|
+
export declare function RuntimeDropUp({ agentHandle, label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }: RuntimeDropUpProps): ReactNode;
|
|
29
30
|
//# sourceMappingURL=RuntimeDropUp.d.ts.map
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
3
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { RemixIcon, infoTipBubbleStyle, useInfoTip } from '@jini-ai/ui';
|
|
4
|
+
import { RemixIcon, infoTipBubbleStyle, useInfoTip, useAgentHandle } from '@jini-ai/ui';
|
|
5
|
+
import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
|
|
4
6
|
import { useRuntimeDropUp } from '../hooks/useRuntimeDropUp.hooks.js';
|
|
5
7
|
/** The full `valueLabel` in the same white bubble `InfoTip` uses, portalled to `document.body`. */
|
|
6
8
|
function RuntimeDropUpTipBubble({ tip, valueLabel }) {
|
|
7
9
|
return createPortal(_jsx("span", { ref: tip.bubbleRef, className: tip.placement === 'below' ? 'info-tip-bubble info-tip-bubble-below' : 'info-tip-bubble', role: "presentation", "aria-hidden": "true", style: infoTipBubbleStyle(tip.coords), children: valueLabel }), document.body);
|
|
8
10
|
}
|
|
9
|
-
function RuntimeDropUpMenu({ dropUp, label, value, options, onSelect, note }) {
|
|
11
|
+
function RuntimeDropUpMenu({ base, dropUp, label, value, options, onSelect, note }) {
|
|
10
12
|
if (!dropUp.open || !dropUp.position)
|
|
11
13
|
return null;
|
|
12
14
|
return (_jsxs("div", { ref: dropUp.menuRef, id: dropUp.menuId, role: "menu", "aria-label": label, className: "jini-runtime-dropup", style: dropUp.position, onKeyDown: dropUp.handleMenuKeyDown, children: [note ? _jsx("div", { className: "jini-runtime-dropup__note", children: note }) : null, options.map((option) => {
|
|
13
15
|
const active = option.id === value;
|
|
14
|
-
return (
|
|
16
|
+
return (_createElement("button", { type: "button", ...agentHandleProps({}, { base, action: `option-${agentHandleSegment({ value: option.id })}`, role: 'button', label: option.label }), role: "menuitemradio", "aria-checked": active, className: `jini-runtime-dropup__item${active ? ' is-active' : ''}`, key: option.id, onClick: () => dropUp.choose(() => onSelect(option.id)) },
|
|
17
|
+
_jsx("span", { className: "jini-runtime-dropup__item-label", children: option.label }),
|
|
18
|
+
active ? _jsx(RemixIcon, { name: "check-line", size: 16, className: "jini-runtime-check" }) : null));
|
|
15
19
|
})] }));
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
@@ -20,7 +24,8 @@ function RuntimeDropUpMenu({ dropUp, label, value, options, onSelect, note }) {
|
|
|
20
24
|
*
|
|
21
25
|
* @complexity Time/space: O(n) in the option count.
|
|
22
26
|
*/
|
|
23
|
-
export function RuntimeDropUp({ label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }) {
|
|
27
|
+
export function RuntimeDropUp({ agentHandle, label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }) {
|
|
28
|
+
const base = useAgentHandle({ agentHandle });
|
|
24
29
|
const dropUp = useRuntimeDropUp({ width });
|
|
25
30
|
const { menuId, open, triggerRef, toggleOpen, handleTriggerKeyDown } = dropUp;
|
|
26
31
|
// The same white bubble as `InfoTip` (its hook places it), rather than the browser's own title
|
|
@@ -33,13 +38,13 @@ export function RuntimeDropUp({ label, valueLabel, triggerLabel, value, options,
|
|
|
33
38
|
if (tipVisible)
|
|
34
39
|
tip.show();
|
|
35
40
|
};
|
|
36
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { ref: triggerRef, type: "button", className: 'jini-runtime-dropup-trigger' + (className ? ' ' + className : ''), "aria-label": `${label}: ${valueLabel}`, "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": menuId, ...(shortened ? {} : { title: valueLabel }), onClick: () => {
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { ...agentHandleProps({}, { base, role: 'button', label }), ref: triggerRef, type: "button", className: 'jini-runtime-dropup-trigger' + (className ? ' ' + className : ''), "aria-label": `${label}: ${valueLabel}`, "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": menuId, ...(shortened ? {} : { title: valueLabel }), onClick: () => {
|
|
37
42
|
tip.hide();
|
|
38
43
|
toggleOpen();
|
|
39
44
|
}, onKeyDown: (event) => {
|
|
40
45
|
if (event.key === 'Escape')
|
|
41
46
|
tip.hide();
|
|
42
47
|
handleTriggerKeyDown(event);
|
|
43
|
-
}, onMouseEnter: showTip, onMouseLeave: tip.leave, onFocus: showTip, onBlur: tip.hide, children: [_jsx("span", { ref: tip.iconRef, className: "jini-runtime-dropup-trigger__label", children: triggerLabel ?? valueLabel }), _jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })] }), tip.open && tipVisible ? _jsx(RuntimeDropUpTipBubble, { tip: tip, valueLabel: valueLabel }) : null, _jsx(RuntimeDropUpMenu, { dropUp: dropUp, label: label, value: value, options: options, onSelect: onSelect, note: note })] }));
|
|
48
|
+
}, onMouseEnter: showTip, onMouseLeave: tip.leave, onFocus: showTip, onBlur: tip.hide, children: [_jsx("span", { ref: tip.iconRef, className: "jini-runtime-dropup-trigger__label", children: triggerLabel ?? valueLabel }), _jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })] }), tip.open && tipVisible ? _jsx(RuntimeDropUpTipBubble, { tip: tip, valueLabel: valueLabel }) : null, _jsx(RuntimeDropUpMenu, { base: base, dropUp: dropUp, label: label, value: value, options: options, onSelect: onSelect, note: note })] }));
|
|
44
49
|
}
|
|
45
50
|
//# sourceMappingURL=RuntimeDropUp.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SurfaceEmission } from '@jini-ai/core';
|
|
2
|
+
export interface FrontendRequestCallerRequired {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly fetch: typeof globalThis.fetch;
|
|
5
|
+
readonly bindToken: () => string | undefined;
|
|
6
|
+
readonly onSurface: (emission: SurfaceEmission) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface FrontendRequestInput {
|
|
9
|
+
readonly capabilityId: string;
|
|
10
|
+
readonly input: Record<string, unknown>;
|
|
11
|
+
readonly signal: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
/** Execute one browser-requested capability through the host's authenticated gate, never retrying.
|
|
14
|
+
* The current bind token and serialized arguments are captured before the first asynchronous wait.
|
|
15
|
+
* @returns A caller that renders cards immediately and resolves only after the tool settles.
|
|
16
|
+
* @throws On absent attachment, HTTP refusal, cancellation or an incomplete execution stream.
|
|
17
|
+
* @complexity O(request + response bytes) time; O(largest response frame) space, capped at 5 MiB.
|
|
18
|
+
* @overallScore 100
|
|
19
|
+
*/
|
|
20
|
+
export declare function createFrontendRequestCaller({ path, fetch, bindToken, onSurface }: FrontendRequestCallerRequired, { headers }?: {
|
|
21
|
+
headers?: () => Record<string, string>;
|
|
22
|
+
}): (required: FrontendRequestInput, optional?: Record<string, never>) => Promise<unknown>;
|
|
23
|
+
//# sourceMappingURL=create-frontend-request-caller.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readSurfaceFrames } from './surface-recovery-stream.js';
|
|
2
|
+
/** Execute one browser-requested capability through the host's authenticated gate, never retrying.
|
|
3
|
+
* The current bind token and serialized arguments are captured before the first asynchronous wait.
|
|
4
|
+
* @returns A caller that renders cards immediately and resolves only after the tool settles.
|
|
5
|
+
* @throws On absent attachment, HTTP refusal, cancellation or an incomplete execution stream.
|
|
6
|
+
* @complexity O(request + response bytes) time; O(largest response frame) space, capped at 5 MiB.
|
|
7
|
+
* @overallScore 100
|
|
8
|
+
*/
|
|
9
|
+
export function createFrontendRequestCaller({ path, fetch, bindToken, onSurface }, { headers = () => ({}) } = {}) {
|
|
10
|
+
return async ({ capabilityId, input, signal }, _optional = {}) => {
|
|
11
|
+
const token = bindToken();
|
|
12
|
+
if (!token)
|
|
13
|
+
throw new Error('Page control has not attached to this browser tab. Reopen the assistant to retry.');
|
|
14
|
+
const response = await fetch(path, { method: 'POST', credentials: 'same-origin',
|
|
15
|
+
headers: { ...headers(), 'content-type': 'application/json' },
|
|
16
|
+
body: JSON.stringify({ capabilityId, input, bindToken: token }), signal,
|
|
17
|
+
});
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
const body = await response.json();
|
|
20
|
+
throw new Error(body.error ?? `The page request was refused (HTTP ${response.status}).`);
|
|
21
|
+
}
|
|
22
|
+
let completed = false;
|
|
23
|
+
let output;
|
|
24
|
+
await readSurfaceFrames({ response, onFrame: frame => {
|
|
25
|
+
switch (frame.type) {
|
|
26
|
+
case 'surface':
|
|
27
|
+
if (frame.emission)
|
|
28
|
+
onSurface(frame.emission);
|
|
29
|
+
return;
|
|
30
|
+
case 'throw':
|
|
31
|
+
throw new Error(frame.error?.message ?? 'The page action could not be executed.');
|
|
32
|
+
case 'result':
|
|
33
|
+
if (completed)
|
|
34
|
+
throw new Error('The page action returned more than one result.');
|
|
35
|
+
output = completedOutput(frame.result);
|
|
36
|
+
completed = true;
|
|
37
|
+
return;
|
|
38
|
+
default: return;
|
|
39
|
+
}
|
|
40
|
+
} });
|
|
41
|
+
if (!completed)
|
|
42
|
+
throw new Error('The page action ended without a result. Its outcome is unknown; it was not retried.');
|
|
43
|
+
return output;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Only a completed gated execution has an output; refusals keep the host's specific message.
|
|
47
|
+
* @complexity O(1) time and space.
|
|
48
|
+
* @overallScore 100
|
|
49
|
+
*/
|
|
50
|
+
function completedOutput(value) {
|
|
51
|
+
const result = value;
|
|
52
|
+
if (result?.status !== 'completed')
|
|
53
|
+
throw new Error(result?.error ?? `The page action was ${result?.status ?? 'not completed'}.`);
|
|
54
|
+
return result.output;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=create-frontend-request-caller.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AcceptedChatInput } from '../../../../core/accepted-input.js';
|
|
2
|
+
import type { SurfaceEmission } from '@jini-ai/core';
|
|
2
3
|
import type { UserTextRedactionOptions } from '../../../../core/user-text-redaction.js';
|
|
3
4
|
import { type ChatPaneSendBlocker } from '../rules.js';
|
|
4
5
|
import type { ChatPaneActivity, ChatPaneAgent, ChatPaneAttachmentUploadOptions, ChatPaneAgentSelection, ChatPaneRunContext, ChatPaneWorkingDirectoryAccess, DeliverMidRunMessage, DeliverTypedAnswer, TypedAnswerNotice } from '../types.js';
|
|
@@ -28,6 +29,7 @@ export interface UseChatPaneOptions extends UserTextRedactionOptions {
|
|
|
28
29
|
uploadAttachments?: (files: File[], options?: ChatPaneAttachmentUploadOptions) => Promise<ChatAttachment[]>;
|
|
29
30
|
onActivityChange?: (activity: ChatPaneActivity) => void;
|
|
30
31
|
onMessagesChange?: (messages: ChatMessage[]) => void;
|
|
32
|
+
subscribeToSurfaces?: (listener: (emission: SurfaceEmission) => void) => () => void;
|
|
31
33
|
workingDirectory?: string | null;
|
|
32
34
|
initialWorkingDirectory?: string | null;
|
|
33
35
|
onChangeWorkingDirectory?: (workingDirectory: string | null) => void;
|
|
@@ -246,6 +246,14 @@ export function useChatPane(options) {
|
|
|
246
246
|
// absent), so only the falsy "no agent selected" case should omit the key.
|
|
247
247
|
agentId: selection.agentId || undefined,
|
|
248
248
|
} }));
|
|
249
|
+
useEffect(() => options.subscribeToSurfaces?.(emission => {
|
|
250
|
+
// Browser-requested cards are not agent turns and cannot supply run/answer authority.
|
|
251
|
+
const data = emission.channel === 'mcp-ui' ? emission.payload.resource : emission.payload;
|
|
252
|
+
conversation.setMessages(messages => [...messages, {
|
|
253
|
+
id: createChatLocalId({}), role: 'assistant', content: '', createdAt: Date.now(),
|
|
254
|
+
events: [{ kind: 'ext', name: emission.channel, data }],
|
|
255
|
+
}]);
|
|
256
|
+
}), [options.subscribeToSurfaces, conversation.setMessages]);
|
|
249
257
|
const composer = useComposer(definedProps({ source: {
|
|
250
258
|
initialDraft: options.initialDraft,
|
|
251
259
|
historyMessages: conversation.messages,
|
|
@@ -349,6 +357,14 @@ export function useChatPane(options) {
|
|
|
349
357
|
latestFoldersRef.current = composer.folders ?? [];
|
|
350
358
|
const latestAttachmentsRef = useRef(composer.attachments);
|
|
351
359
|
latestAttachmentsRef.current = composer.attachments;
|
|
360
|
+
// Removing an attachment is how the user makes room after a "total too large" failure, so the
|
|
361
|
+
// failure notice goes with it instead of staying on screen (it still also clears on the next upload).
|
|
362
|
+
const attachmentCountRef = useRef(composer.attachments.length);
|
|
363
|
+
useEffect(() => {
|
|
364
|
+
if (composer.attachments.length < attachmentCountRef.current)
|
|
365
|
+
setAttachmentError(null);
|
|
366
|
+
attachmentCountRef.current = composer.attachments.length;
|
|
367
|
+
}, [composer.attachments.length]);
|
|
352
368
|
useEffect(() => {
|
|
353
369
|
const previous = typedAnswerConversationRef.current;
|
|
354
370
|
typedAnswerConversationRef.current = options.conversationId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChatMessage } from '@jini-ai/chat';
|
|
2
|
-
import type
|
|
2
|
+
import { type UserTextRedaction } from '../../../core/user-text-redaction.js';
|
|
3
3
|
import type { ByokRuntimeSummary, ChatPaneAgent, ChatPaneAgentSelection, TypedAnswerNotice } from './types.js';
|
|
4
4
|
export declare function defaultChatPaneSelection({ agent }: {
|
|
5
5
|
agent: ChatPaneAgent;
|
|
@@ -70,6 +70,27 @@ export declare function isChatPaneFileDropEnabled({ canUpload, disabled, unavail
|
|
|
70
70
|
* @returns The first blocker found, or `null` when sending is allowed.
|
|
71
71
|
*/
|
|
72
72
|
export declare function findChatPaneSendBlocker(state: ChatPaneSendability): ChatPaneSendBlocker | null;
|
|
73
|
+
/**
|
|
74
|
+
* Whether a blocker needs its own notice above the composer. `streaming` is handled by Send turning
|
|
75
|
+
* into Stop, and the working-directory ones already have a banner of their own
|
|
76
|
+
* (`ChatPaneWorkingDirectoryStatus` and the working-directory error banner), so repeating them would
|
|
77
|
+
* show the same sentence twice. Their text still reaches Send's tooltip.
|
|
78
|
+
*/
|
|
79
|
+
export declare function chatPaneSendBlockerNeedsNotice({ blocker }: {
|
|
80
|
+
blocker: ChatPaneSendBlocker | null;
|
|
81
|
+
}): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Plain words for a failed attachment upload: what happened and what to do, plus the reason with
|
|
84
|
+
* credential shapes removed, short enough to paste into a bug report.
|
|
85
|
+
*
|
|
86
|
+
* @complexity O(n) in the error message length.
|
|
87
|
+
*/
|
|
88
|
+
export declare function describeAttachmentError({ error }: {
|
|
89
|
+
error: Error;
|
|
90
|
+
}): {
|
|
91
|
+
summary: string;
|
|
92
|
+
details: string;
|
|
93
|
+
};
|
|
73
94
|
/** Human/model-readable reason for a blocker, so a refused agent send explains itself. */
|
|
74
95
|
export declare function describeChatPaneSendBlocker(blocker: ChatPaneSendBlocker): string;
|
|
75
96
|
/**
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { modelReasoningOptions } from '@jini-ai/agent-runtime/model-selection';
|
|
1
2
|
import { configuredPickerModel, pickerModelOptions, isConcretePickerModel } from './model-options.js';
|
|
2
3
|
import { isTerminalRunStatus } from '../../../core/messages.js';
|
|
3
4
|
import { acceptedInputEvent } from '../../../core/accepted-input.js';
|
|
4
5
|
import { isAwaitingAnswer } from '../../../core/run-activity.js';
|
|
6
|
+
import { redactUserText } from '../../../core/user-text-redaction.js';
|
|
5
7
|
function preferredOptionId(options) {
|
|
6
8
|
return options?.find((option) => option.id === 'default')?.id ?? options?.[0]?.id;
|
|
7
9
|
}
|
|
@@ -33,7 +35,7 @@ export function defaultChatPaneSelection({ agent }) {
|
|
|
33
35
|
// Use that fallback for unresolved native defaults too: an off-list alias must not strand
|
|
34
36
|
// a usable catalog. The picker still excludes aliases without concrete model evidence.
|
|
35
37
|
const model = configuredPickerModel(agent) || pickerModelOptions(agent)[0]?.id;
|
|
36
|
-
const reasoning = preferredOptionId(agent.
|
|
38
|
+
const reasoning = preferredOptionId(modelReasoningOptions({ agent, model: pickerModelOptions(agent).find(option => option.id === model) }));
|
|
37
39
|
return selectionOf({ agentId: agent.id, model, reasoning });
|
|
38
40
|
}
|
|
39
41
|
export function resolveChatPaneSelection({ agents, requested }) {
|
|
@@ -45,7 +47,8 @@ export function resolveChatPaneSelection({ agents, requested }) {
|
|
|
45
47
|
if (agent !== requestedAgent)
|
|
46
48
|
return defaults;
|
|
47
49
|
const model = resolveRequestedModel({ agent, requested: requested.model, fallback: defaults.model });
|
|
48
|
-
const
|
|
50
|
+
const efforts = modelReasoningOptions({ agent, model: pickerModelOptions(agent).find(option => option.id === model) });
|
|
51
|
+
const reasoning = validatedOptionId(efforts, requested.reasoning, preferredOptionId(efforts));
|
|
49
52
|
return selectionOf({ agentId: agent.id, model, reasoning });
|
|
50
53
|
}
|
|
51
54
|
/**
|
|
@@ -120,15 +123,38 @@ function findReadinessSendBlocker(state) {
|
|
|
120
123
|
return null;
|
|
121
124
|
}
|
|
122
125
|
const SEND_BLOCKER_MESSAGES = {
|
|
123
|
-
'no-agent-selected': '
|
|
124
|
-
'agent-unavailable':
|
|
125
|
-
'model-unresolved': '
|
|
126
|
-
streaming: '
|
|
127
|
-
'uploads-pending': '
|
|
128
|
-
'working-directory-pending': 'the working directory
|
|
129
|
-
'working-directory-invalid':
|
|
130
|
-
'working-directory-error': 'the working directory
|
|
126
|
+
'no-agent-selected': 'Choose an agent to send.',
|
|
127
|
+
'agent-unavailable': "The selected agent isn't available.",
|
|
128
|
+
'model-unresolved': 'Choose a model to send.',
|
|
129
|
+
streaming: 'A reply is still running. Stop it first.',
|
|
130
|
+
'uploads-pending': 'Attachment still uploading.',
|
|
131
|
+
'working-directory-pending': 'Still checking the working directory.',
|
|
132
|
+
'working-directory-invalid': "The working directory isn't valid.",
|
|
133
|
+
'working-directory-error': "Couldn't read the working directory.",
|
|
131
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Whether a blocker needs its own notice above the composer. `streaming` is handled by Send turning
|
|
137
|
+
* into Stop, and the working-directory ones already have a banner of their own
|
|
138
|
+
* (`ChatPaneWorkingDirectoryStatus` and the working-directory error banner), so repeating them would
|
|
139
|
+
* show the same sentence twice. Their text still reaches Send's tooltip.
|
|
140
|
+
*/
|
|
141
|
+
export function chatPaneSendBlockerNeedsNotice({ blocker }) {
|
|
142
|
+
return blocker !== null && blocker !== 'streaming' && !blocker.startsWith('working-directory-');
|
|
143
|
+
}
|
|
144
|
+
const ATTACHMENT_DETAILS_MAX = 300;
|
|
145
|
+
/**
|
|
146
|
+
* Plain words for a failed attachment upload: what happened and what to do, plus the reason with
|
|
147
|
+
* credential shapes removed, short enough to paste into a bug report.
|
|
148
|
+
*
|
|
149
|
+
* @complexity O(n) in the error message length.
|
|
150
|
+
*/
|
|
151
|
+
export function describeAttachmentError({ error }) {
|
|
152
|
+
const redacted = redactUserText({ text: error.message }).text.trim();
|
|
153
|
+
return {
|
|
154
|
+
summary: 'Attachment upload failed. Remove it and try again.',
|
|
155
|
+
details: redacted.length > ATTACHMENT_DETAILS_MAX ? `${redacted.slice(0, ATTACHMENT_DETAILS_MAX)}…` : redacted,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
132
158
|
/** Human/model-readable reason for a blocker, so a refused agent send explains itself. */
|
|
133
159
|
export function describeChatPaneSendBlocker(blocker) {
|
|
134
160
|
return SEND_BLOCKER_MESSAGES[blocker];
|