@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { formatErrorForLog } from '@jini-ai/core';
|
|
3
3
|
/**
|
|
4
4
|
* @module ConversationList
|
|
@@ -64,6 +64,13 @@ function relativeTime(updatedAt, now) {
|
|
|
64
64
|
return `${hours}h ago`;
|
|
65
65
|
return `${Math.round(hours / 24)}d ago`;
|
|
66
66
|
}
|
|
67
|
+
/** Only the host-supported actions are rendered; row selection remains independent. */
|
|
68
|
+
function ConversationActions({ itemId, editing, canRename, canDelete, onRename, onDelete, t }) {
|
|
69
|
+
return _jsxs(_Fragment, { children: [canRename && !editing ? _jsx("button", { type: "button", className: "jini-conv-item-rename", "aria-label": t('Rename chat'), "data-testid": `conversation-rename-button-${itemId}`, onClick: onRename, children: _jsx(Icon, { name: "pencil", size: 12 }) }) : null, canDelete ? _jsx("button", { type: "button", className: "jini-conv-item-delete", "aria-label": t('Delete conversation'), "data-testid": `conversation-delete-${itemId}`, onClick: (event) => {
|
|
70
|
+
event.stopPropagation();
|
|
71
|
+
onDelete();
|
|
72
|
+
}, children: _jsx(Icon, { name: "close", size: 12 }) }) : null] });
|
|
73
|
+
}
|
|
67
74
|
export function ConversationList({ conversations: savedConversations, activeConversationId, onSelect, onCreate, onDelete, onRename, onSearch, confirmDelete, createDisabled = false, emptyState, triggerLabel, nativeTitle = true, }) {
|
|
68
75
|
const t = useT();
|
|
69
76
|
const [open, setOpen] = useState(false);
|
|
@@ -170,13 +177,18 @@ export function ConversationList({ conversations: savedConversations, activeConv
|
|
|
170
177
|
// No optimistic title update happens here — the row keeps rendering `item.title` from
|
|
171
178
|
// props until the host's own state updates, so a rejection cannot leave the UI showing a
|
|
172
179
|
// title the server didn't accept. Reporting the failure is what closes the remaining gap.
|
|
173
|
-
|
|
180
|
+
if (onRename)
|
|
181
|
+
runConversationListHostEffect('onRename', () => onRename(id, next));
|
|
174
182
|
}, [onRename]);
|
|
175
183
|
const startRename = (id) => {
|
|
184
|
+
if (!onRename)
|
|
185
|
+
return;
|
|
176
186
|
cancelPendingSelect();
|
|
177
187
|
setEditingId(id);
|
|
178
188
|
};
|
|
179
189
|
const requestDelete = useCallback((item) => {
|
|
190
|
+
if (!onDelete)
|
|
191
|
+
return;
|
|
180
192
|
const confirmer = confirmDelete ??
|
|
181
193
|
// Only ever called from a click handler, so a browser `window` always exists here.
|
|
182
194
|
((c) => window.confirm(t('Delete "{title}"? This cannot be undone.').replace('{title}', c.title ?? t('Untitled'))));
|
|
@@ -201,16 +213,13 @@ export function ConversationList({ conversations: savedConversations, activeConv
|
|
|
201
213
|
// the remaining gap between "switcher closed" and "the host actually knows".
|
|
202
214
|
runConversationListHostEffect('onCreate', () => onCreate());
|
|
203
215
|
setOpen(false);
|
|
204
|
-
}, children: [_jsx(Icon, { name: "plus", size: 12 }), _jsx("span", { children: t('New') })] })] }), _jsxs("label", { className: "jini-conv-search", children: [_jsx(Icon, { name: "search", size: 13 }), _jsx("input", { type: "search", value: query, placeholder: t('Search conversations'), "data-testid": "conversation-search", onChange: (event) => setQuery(event.currentTarget.value) })] }), _jsx("div", { className: "jini-conv-list", "data-testid": "conversation-list", children: conversations.length === 0 || visible.length === 0 ? (_jsx("div", { className: "jini-conv-empty", children: emptyLabel() })) : (visible.map((item) => (_jsxs("div", { className: `jini-conv-item${item.id === activeConversationId ? ' jini-conv-item-active' : ''}`, "data-testid": `conversation-item-${item.id}`, children: [editingId === item.id ? (_jsx(ConversationTitleEditor, { title: rawTitles.get(item.id) ?? null, "data-testid": `conversation-rename-${item.id}`, onCommit: (next) => commitRename(item.id, next), onCancel: () => setEditingId(null) })) : (_jsxs("button", { type: "button", className: "jini-conv-item-select", "data-testid": `conversation-select-${item.id}`, title: t('Double-click to rename'), onClick: () => {
|
|
216
|
+
}, children: [_jsx(Icon, { name: "plus", size: 12 }), _jsx("span", { children: t('New') })] })] }), _jsxs("label", { className: "jini-conv-search", children: [_jsx(Icon, { name: "search", size: 13 }), _jsx("input", { type: "search", value: query, placeholder: t('Search conversations'), "data-testid": "conversation-search", onChange: (event) => setQuery(event.currentTarget.value) })] }), _jsx("div", { className: "jini-conv-list", "data-testid": "conversation-list", children: conversations.length === 0 || visible.length === 0 ? (_jsx("div", { className: "jini-conv-empty", children: emptyLabel() })) : (visible.map((item) => (_jsxs("div", { className: `jini-conv-item${item.id === activeConversationId ? ' jini-conv-item-active' : ''}`, "data-testid": `conversation-item-${item.id}`, children: [onRename && editingId === item.id ? (_jsx(ConversationTitleEditor, { title: rawTitles.get(item.id) ?? null, "data-testid": `conversation-rename-${item.id}`, onCommit: (next) => commitRename(item.id, next), onCancel: () => setEditingId(null) })) : (_jsxs("button", { type: "button", className: "jini-conv-item-select", "data-testid": `conversation-select-${item.id}`, title: onRename ? t('Double-click to rename') : undefined, onClick: () => {
|
|
205
217
|
cancelPendingSelect();
|
|
206
218
|
pendingSelectRef.current = setTimeout(() => {
|
|
207
219
|
pendingSelectRef.current = null;
|
|
208
220
|
onSelect(item.id);
|
|
209
221
|
setOpen(false);
|
|
210
222
|
}, DOUBLE_CLICK_GRACE_MS);
|
|
211
|
-
}, onDoubleClick: () => startRename(item.id), children: [_jsx("span", { className: "jini-conv-item-title", children: item.title ?? t('Untitled') }), _jsxs("span", { className: "jini-conv-item-meta", children: [item.messageCount === undefined ? '' : `${item.messageCount} msg · `, relativeTime(item.updatedAt, now)] })] })),
|
|
212
|
-
event.stopPropagation();
|
|
213
|
-
requestDelete(item);
|
|
214
|
-
}, children: _jsx(Icon, { name: "close", size: 12 }) })] }, item.id)))) })] })) : null] }));
|
|
223
|
+
}, onDoubleClick: onRename ? () => startRename(item.id) : undefined, children: [_jsx("span", { className: "jini-conv-item-title", children: item.title ?? t('Untitled') }), _jsxs("span", { className: "jini-conv-item-meta", children: [item.messageCount === undefined ? '' : `${item.messageCount} msg · `, relativeTime(item.updatedAt, now)] })] })), _jsx(ConversationActions, { itemId: item.id, editing: editingId === item.id, canRename: Boolean(onRename), canDelete: Boolean(onDelete), onRename: () => startRename(item.id), onDelete: () => requestDelete(item), t: t })] }, item.id)))) })] })) : null] }));
|
|
215
224
|
}
|
|
216
225
|
//# sourceMappingURL=ConversationList.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
interface CopyMessageButtonProps {
|
|
2
|
+
/** Inherited control identity; ordinary message-copy buttons remain opt-in. */
|
|
3
|
+
agentHandle?: string | false | undefined;
|
|
2
4
|
/** The raw markdown source to place on the clipboard — never rendered/flattened text. */
|
|
3
5
|
text: string;
|
|
4
6
|
/** Accessible name while idle; swaps to a "Copied" label once the copy lands. */
|
|
@@ -16,6 +18,6 @@ interface CopyMessageButtonProps {
|
|
|
16
18
|
* @param props.title - Optional hover tooltip (already translated); swaps to "Copied" like the label.
|
|
17
19
|
* @complexity O(1) — one child hook call, no branching beyond the copied-state read.
|
|
18
20
|
*/
|
|
19
|
-
export declare function CopyMessageButton({ text, label, title }: CopyMessageButtonProps): import("react").JSX.Element;
|
|
21
|
+
export declare function CopyMessageButton({ agentHandle, text, label, title }: CopyMessageButtonProps): import("react").JSX.Element;
|
|
20
22
|
export {};
|
|
21
23
|
//# sourceMappingURL=CopyMessageButton.d.ts.map
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useT } from '../hooks/context.js';
|
|
4
4
|
import { useCopyToClipboard } from '../hooks/useCopyToClipboard.js';
|
|
5
5
|
import { Icon } from './Icon.js';
|
|
6
|
+
import { agentHandleProps } from '@jini-ai/agentic';
|
|
6
7
|
/**
|
|
7
8
|
* Quiet, icon-only copy affordance shared by the user- and assistant-message
|
|
8
9
|
* action rows. Delegates the actual clipboard write (and its
|
|
@@ -13,10 +14,10 @@ import { Icon } from './Icon.js';
|
|
|
13
14
|
* @param props.title - Optional hover tooltip (already translated); swaps to "Copied" like the label.
|
|
14
15
|
* @complexity O(1) — one child hook call, no branching beyond the copied-state read.
|
|
15
16
|
*/
|
|
16
|
-
export function CopyMessageButton({ text, label, title }) {
|
|
17
|
+
export function CopyMessageButton({ agentHandle, text, label, title }) {
|
|
17
18
|
const t = useT();
|
|
18
19
|
const { copied, copy } = useCopyToClipboard();
|
|
19
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "jini-message-action-btn", "aria-label": copied ? t('Copied') : label, title: title && (copied ? t('Copied') : title), onClick: () => {
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { ...agentHandleProps({}, { base: agentHandle || undefined, role: 'button', label }), type: "button", className: "jini-message-action-btn", "aria-label": copied ? t('Copied') : label, title: title && (copied ? t('Copied') : title), onClick: () => {
|
|
20
21
|
void copy(text);
|
|
21
22
|
}, children: _jsx(Icon, { name: copied ? 'check' : 'copy' }) }), _jsx("span", { className: "jini-message-copy-status", "aria-live": "polite", children: copied ? t('Copied to clipboard') : '' })] }));
|
|
22
23
|
}
|
|
@@ -5,7 +5,9 @@ type OnRemove = (input: {
|
|
|
5
5
|
* Shared composer/sent-message folder indicator; references never participate in uploads.
|
|
6
6
|
* One folder shows its chip directly; a "Folders (n)" toggle would only repeat its name.
|
|
7
7
|
*/
|
|
8
|
-
export declare function FolderChips({ folders, onRemove }: {
|
|
8
|
+
export declare function FolderChips({ agentHandle, folders, onRemove }: {
|
|
9
|
+
/** Inherited Composer base; standalone sent-message folders remain opt-in. */
|
|
10
|
+
agentHandle?: string | false | undefined;
|
|
9
11
|
folders?: readonly string[] | undefined;
|
|
10
12
|
onRemove?: OnRemove | undefined;
|
|
11
13
|
}): import("react").JSX.Element | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId, useState } from 'react';
|
|
3
|
+
import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
|
|
3
4
|
import { useT } from '../hooks/context.js';
|
|
4
5
|
import { CopyMessageButton } from './CopyMessageButton.js';
|
|
5
6
|
import { Icon } from './Icon.js';
|
|
@@ -8,25 +9,27 @@ function folderName({ path }, _options = {}) {
|
|
|
8
9
|
return path.split(/[\\/]/).filter(Boolean).at(-1) ?? path;
|
|
9
10
|
}
|
|
10
11
|
/** One folder: last name (full path on hover), copy, and × when removable. */
|
|
11
|
-
function FolderChip({ path, onRemove }) {
|
|
12
|
+
function FolderChip({ base, path, onRemove }) {
|
|
12
13
|
const t = useT();
|
|
14
|
+
const segment = agentHandleSegment({ value: path });
|
|
13
15
|
const copyLabel = t('Copy folder path: {path}', { path });
|
|
14
16
|
const removeLabel = t('Remove folder: {path}', { path });
|
|
15
|
-
return _jsxs("li", { className: "jini-folder-chips__item", children: [_jsx(Icon, { name: "folder" }), _jsx("span", { className: "jini-folder-chips__name", title: path, "aria-label": path, children: folderName({ path }) }), _jsx(CopyMessageButton, { text: path, label: copyLabel, title: copyLabel }), onRemove && _jsx("button", { type: "button", className: "jini-folder-chips__remove", title: removeLabel, "aria-label": removeLabel, onClick: () => onRemove({ path }), children: _jsx(Icon, { name: "close" }) })] });
|
|
17
|
+
return _jsxs("li", { className: "jini-folder-chips__item", children: [_jsx(Icon, { name: "folder" }), _jsx("span", { className: "jini-folder-chips__name", title: path, "aria-label": path, children: folderName({ path }) }), _jsx(CopyMessageButton, { agentHandle: base ? `${base}-folder-copy-${segment}` : false, text: path, label: copyLabel, title: copyLabel }), onRemove && _jsx("button", { type: "button", className: "jini-folder-chips__remove", title: removeLabel, ...agentHandleProps({}, { base, action: `folder-remove-${segment}`, role: 'button', label: removeLabel }), "aria-label": removeLabel, onClick: () => onRemove({ path }), children: _jsx(Icon, { name: "close" }) })] });
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Shared composer/sent-message folder indicator; references never participate in uploads.
|
|
19
21
|
* One folder shows its chip directly; a "Folders (n)" toggle would only repeat its name.
|
|
20
22
|
*/
|
|
21
|
-
export function FolderChips({ folders = [], onRemove }) {
|
|
23
|
+
export function FolderChips({ agentHandle, folders = [], onRemove }) {
|
|
24
|
+
const base = agentHandle || undefined;
|
|
22
25
|
const t = useT();
|
|
23
26
|
const [expanded, setExpanded] = useState(false);
|
|
24
27
|
const id = useId();
|
|
25
28
|
if (folders.length === 0)
|
|
26
29
|
return null;
|
|
27
|
-
const list = (listId) => _jsx("ul", { id: listId, className: "jini-folder-chips__list", children: folders.map(path => _jsx(FolderChip, { path: path, onRemove: onRemove }, path)) });
|
|
30
|
+
const list = (listId) => _jsx("ul", { id: listId, className: "jini-folder-chips__list", children: folders.map(path => _jsx(FolderChip, { base: base, path: path, onRemove: onRemove }, path)) });
|
|
28
31
|
if (folders.length === 1)
|
|
29
32
|
return _jsx("div", { className: "jini-folder-chips", children: list() });
|
|
30
|
-
return _jsxs("div", { className: "jini-folder-chips", children: [_jsxs("button", { type: "button", className: "jini-folder-chips__toggle", "aria-expanded": expanded, "aria-controls": id, onClick: () => setExpanded(value => !value), children: [_jsx(Icon, { name: "folder" }), _jsx("span", { children: t('Folders ({count})', { count: folders.length }) }), _jsx(Icon, { name: expanded ? 'chevron-down' : 'chevron-right' })] }), expanded && list(id)] });
|
|
33
|
+
return _jsxs("div", { className: "jini-folder-chips", children: [_jsxs("button", { type: "button", className: "jini-folder-chips__toggle", "aria-expanded": expanded, "aria-controls": id, ...agentHandleProps({}, { base, action: 'folders-toggle', role: 'button', label: t('Folders ({count})', { count: folders.length }) }), onClick: () => setExpanded(value => !value), children: [_jsx(Icon, { name: "folder" }), _jsx("span", { children: t('Folders ({count})', { count: folders.length }) }), _jsx(Icon, { name: expanded ? 'chevron-down' : 'chevron-right' })] }), expanded && list(id)] });
|
|
31
34
|
}
|
|
32
35
|
//# sourceMappingURL=FolderChips.js.map
|
|
@@ -61,6 +61,6 @@ function QueuedMessage({ prompt, renderAttachment }) {
|
|
|
61
61
|
const t = useT();
|
|
62
62
|
const attachments = prompt.attachments ?? [];
|
|
63
63
|
const gallery = useAttachmentGallery({ attachments });
|
|
64
|
-
return (_jsxs("div", { className: "jini-chat-pane__queued", role: "status", "aria-label": t('Message queued — not yet sent, will send once the current run finishes'), "data-testid": "chat-pane-queued", "data-agent-element": "chat-message-pending", "data-agent-role": "region", "data-agent-label": "A message queued to send once the current run finishes", children: [_jsx("div", { children: t('Queued — sends when this reply finishes') }), prompt.folders?.length ? _jsx("div", { className: "jini-message-attachments", children: _jsx(FolderChips, { folders: prompt.folders }) }) : null, _jsx("div", { className: "jini-chat-pane__queued-text", children: prompt.text }), attachments.length > 0 && _jsx("div", { className: "jini-message-attachments", children: attachments.map(attachment => _jsx(SentAttachmentButton, { attachment: attachment, onOpen: gallery.open, renderAttachment: renderAttachment }, attachment.path)) }), gallery.opened !== null && _jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation }), _jsx("div", { className: "jini-chat-pane__queued-actions", children: _jsx("button", { type: "button", className: "jini-chat-pane__queued-cancel", onClick: () => prompt.onCancel(), title: t('Cancel queued message'), children: t('Cancel') }) })] }));
|
|
64
|
+
return (_jsxs("div", { className: "jini-chat-pane__queued", role: "status", "aria-label": t('Message queued — not yet sent, will send once the current run finishes'), "data-testid": "chat-pane-queued", "data-agent-element": "chat-message-pending", "data-agent-role": "region", "data-agent-label": "A message queued to send once the current run finishes", children: [_jsx("div", { className: "jini-chat-pane__status", children: t('Queued — sends when this reply finishes') }), prompt.folders?.length ? _jsx("div", { className: "jini-message-attachments", children: _jsx(FolderChips, { folders: prompt.folders }) }) : null, _jsx("div", { className: "jini-chat-pane__queued-text", children: prompt.text }), attachments.length > 0 && _jsx("div", { className: "jini-message-attachments", children: attachments.map(attachment => _jsx(SentAttachmentButton, { attachment: attachment, onOpen: gallery.open, renderAttachment: renderAttachment }, attachment.path)) }), gallery.opened !== null && _jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation }), _jsx("div", { className: "jini-chat-pane__queued-actions", children: _jsx("button", { type: "button", className: "jini-chat-pane__queued-cancel", onClick: () => prompt.onCancel(), title: t('Cancel queued message'), children: t('Cancel') }) })] }));
|
|
65
65
|
}
|
|
66
66
|
//# sourceMappingURL=MessageList.js.map
|
|
@@ -160,7 +160,7 @@ function messageAwaitingAnswer({ runStreaming, runInProgress, events }, { isAnsw
|
|
|
160
160
|
}
|
|
161
161
|
function AssistantMessageFooter({ message, usageEvent, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard }, _optional = {}) {
|
|
162
162
|
const t = useT();
|
|
163
|
-
return _jsxs(_Fragment, { children: [usageEvent ? _jsx(UsageSummary, { usage: usageEvent, showTotal: showUsageTotal, message: message, awaitingAnswer: isAwaitingAnswer({ events: message.events }, { isAnsweredCard }) }) : null, terminalNotice ? _jsx("div", { className:
|
|
163
|
+
return _jsxs(_Fragment, { children: [usageEvent ? _jsx(UsageSummary, { usage: usageEvent, showTotal: showUsageTotal, message: message, awaitingAnswer: isAwaitingAnswer({ events: message.events }, { isAnsweredCard }) }) : null, terminalNotice ? _jsx("div", { className: message.runStatus === 'canceled' ? 'jini-chat-pane__notice' : 'jini-message-error', role: "status", children: t(terminalNotice) }) : null, !pending && !runInProgress ? (_jsx("div", { className: "jini-message-actions jini-message-actions--assistant", children: _jsx(CopyMessageButton, { text: visibleContent, label: t('Copy message') }) })) : null, runInProgress ? _jsx(RunActivityLine, { events: message.events, active: pending || (runStreaming === true && runInProgress), isAnsweredCard: isAnsweredCard, sending: runSending, sendingLabel: sendingLabel }) : null] });
|
|
164
164
|
}
|
|
165
165
|
/** Stable empty list for a message with no attachments. */
|
|
166
166
|
const NO_ATTACHMENTS = [];
|
|
@@ -187,16 +187,23 @@ function UserMessageRow({ message, renderAttachment }) {
|
|
|
187
187
|
const gallery = useAttachmentGallery({ attachments: message.attachments ?? NO_ATTACHMENTS });
|
|
188
188
|
return (_jsxs("div", { className: "jini-message jini-message-user", "data-message-id": message.id, "data-agent-element": `chat-message-${message.id}`, "data-agent-role": "region", "data-agent-label": "A message from the user", children: [(message.attachments?.length || message.folders?.length) ? (_jsxs("div", { className: "jini-message-attachments", children: [_jsx(FolderChips, { folders: message.folders }), (message.attachments ?? []).map((a) => (_jsx(SentAttachmentButton, { attachment: a, onOpen: gallery.open, renderAttachment: renderAttachment }, a.path)))] })) : null, _jsx("div", { className: "jini-message-content", children: message.content }), _jsx("div", { className: "jini-message-actions jini-message-actions--user", children: _jsx(CopyMessageButton, { text: message.content, label: t('Copy message') }) }), gallery.opened ? (_jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation })) : null] }));
|
|
189
189
|
}
|
|
190
|
+
// A validated extension may already show the explanation. Keep the generic fallback when its
|
|
191
|
+
// renderer is absent or refuses the payload, so malformed history never hides a failed turn.
|
|
192
|
+
function assistantTerminalNotice({ message, runStreaming, runSucceeded, extGroups, registry }, _options = {}) {
|
|
193
|
+
const extensionExplainsFailure = !runStreaming && !runSucceeded && extGroups.some(group => registry.hasTerminalNotice(group));
|
|
194
|
+
return extensionExplainsFailure ? null : terminalMessageNotice({ message }, {});
|
|
195
|
+
}
|
|
196
|
+
/** Only a completed reply without footer usage can own the final inline usage label. */
|
|
197
|
+
function lastFinishedReplyIndex({ runInProgress, usage }, _options = {}) {
|
|
198
|
+
return !runInProgress && !usage.footer ? usage.replies.findLastIndex(value => value !== undefined) : -1;
|
|
199
|
+
}
|
|
190
200
|
function AssistantMessageRow({ showAccessNotice = true, message, usageSummary, showUsageTotal, showUsageLine, toolCallDisplay, showThinking, runStreaming, runSending, sendingLabel, runSucceeded, questionFormInteractive, questionFormSubmittedAnswers, onQuestionFormSubmit, projectFileNames, onRequestOpenFile, }) {
|
|
191
201
|
const registry = useExtEventRendererRegistry();
|
|
192
202
|
const messageUsage = useMessageUsage({ message, ...(usageSummary === undefined ? {} : { summary: usageSummary }) });
|
|
193
203
|
const timeline = useToolTimeline({ events: message.events }, { runStreaming, runSucceeded });
|
|
194
204
|
const extGroups = useExtEventGroups({ events: message.events }, { slotOf: (name, data) => registry.slot({ name, data }) });
|
|
195
205
|
const answeredCards = useAnsweredCards({ slotOf: registry.slot, events: message.events ?? [], groups: extGroups, runStreaming, runStatus: message.runStatus });
|
|
196
|
-
|
|
197
|
-
// renderer is absent or refuses the payload, so malformed history never hides a failed turn.
|
|
198
|
-
const extensionExplainsFailure = !runStreaming && !runSucceeded && extGroups.some(group => registry.hasTerminalNotice(group));
|
|
199
|
-
const terminalNotice = extensionExplainsFailure ? null : terminalMessageNotice({ message }, {});
|
|
206
|
+
const terminalNotice = assistantTerminalNotice({ message, runStreaming, runSucceeded, extGroups, registry });
|
|
200
207
|
const visibleContent = stripArtifact({ content: message.content });
|
|
201
208
|
const displayBlocks = messageBlocks({ message, rows: timeline.rows, registry }, { toolCallDisplay, includeThinking: showThinking });
|
|
202
209
|
// Artifact stripping trims/replaces text, invalidating the event offsets for rendering. Keep the
|
|
@@ -209,7 +216,7 @@ function AssistantMessageRow({ showAccessNotice = true, message, usageSummary, s
|
|
|
209
216
|
runStreaming: runStreaming && !isTerminalRunStatus({ status: message.runStatus }),
|
|
210
217
|
});
|
|
211
218
|
const footerUsage = showUsageLine ? usage.footer : undefined;
|
|
212
|
-
const lastFinishedReply =
|
|
219
|
+
const lastFinishedReply = lastFinishedReplyIndex({ runInProgress, usage });
|
|
213
220
|
const retriedRows = retriedToolRowIds({ rows: timeline.rows });
|
|
214
221
|
const renderToolCard = (row) => (_jsx(ToolCard, { retried: retriedRows.has(row.id), use: row.use, result: row.result, runStreaming: runStreaming, runSucceeded: runSucceeded, ...(projectFileNames !== undefined ? { projectFileNames } : {}), ...(onRequestOpenFile !== undefined ? { onRequestOpenFile } : {}) }, row.id));
|
|
215
222
|
// Hidden mode reuses the same disclosure and card renderer for unrecovered failures.
|
|
@@ -28,7 +28,7 @@ import { useT, useToolRendererRegistry } from '../hooks/context.js';
|
|
|
28
28
|
import { Icon } from './Icon.js';
|
|
29
29
|
import { SAFE_LINK_HREF } from './Markdown.js';
|
|
30
30
|
import { TodoCard } from './TodoCard.js';
|
|
31
|
-
import { toolRowTarget } from './ToolCard.rules.js';
|
|
31
|
+
import { targetAtOffset, toolRowTarget } from './ToolCard.rules.js';
|
|
32
32
|
import { toolPresentation } from '../../core/tool-presentation.js';
|
|
33
33
|
/**
|
|
34
34
|
* Read by `ErrorBadge` only. A context, not one more prop threaded through every family card,
|
|
@@ -213,7 +213,7 @@ function FileReadCard({ input, result, runStreaming, runSucceeded, ctx }) {
|
|
|
213
213
|
const obj = (input ?? {});
|
|
214
214
|
const file = obj.file_path ?? obj.filePath ?? obj.path ?? '(unnamed)';
|
|
215
215
|
// See OpenInTabButton's baseName comment: `.split('/').pop()` is never undefined.
|
|
216
|
-
const baseName = file.split('/').pop();
|
|
216
|
+
const baseName = targetAtOffset({ target: file.split('/').pop(), offset: obj.offset });
|
|
217
217
|
const isRunning = runStreaming && !result;
|
|
218
218
|
return (_jsxs(ExpandableCard, { className: "op-file", call: { input: input, result: result, runStreaming: runStreaming, runSucceeded: runSucceeded }, head: _jsxs(_Fragment, { children: [_jsx(ResultBadge, { result: result, runStreaming: runStreaming, runSucceeded: runSucceeded }), _jsx("span", { className: `op-title${isRunning ? RUNNING_TITLE_CLASS : ''}`, children: t('Read') }), _jsx("span", { className: "op-meta", children: baseName })] }), after: _jsx(FileErrorDetail, { result: result }), children: [_jsxs("div", { className: "op-card-detail op-card-file-detail", children: [_jsx("code", { className: "op-path", children: file }), _jsx(OpenInTabButton, { filePath: file, ctx: ctx })] }), _jsx(ToolCallDetail, { input: input, result: result, runStreaming: runStreaming, runSucceeded: runSucceeded })] }));
|
|
219
219
|
}
|
|
@@ -253,15 +253,15 @@ function GenericCard({ name, input, result, runStreaming, runSucceeded }) {
|
|
|
253
253
|
* The one row shell every card shares: a real `<button>` head (Enter/Space toggle it) that reports
|
|
254
254
|
* `aria-expanded` and points `aria-controls` at its panel. The panel's `children` mount only while
|
|
255
255
|
* open: a long chat mounts hundreds of collapsed rows, and keeping every full detail mounted made a
|
|
256
|
-
* 38-message chat carry ~13k DOM nodes and 3.45 MB of hidden text. Collapsed, the
|
|
257
|
-
*
|
|
258
|
-
*
|
|
256
|
+
* 38-message chat carry ~13k DOM nodes and 3.45 MB of hidden text. Collapsed, the card holds one
|
|
257
|
+
* screen-reader node outside the collapsed panel with the call's capped gist instead, so a
|
|
258
|
+
* `page.*` DOM reader can inspect the same public text without anyone clicking.
|
|
259
259
|
* `after` renders outside the panel, for content that must stay visible collapsed (an error, media).
|
|
260
260
|
*/
|
|
261
261
|
function ExpandableCard({ className, head, after, call, children }) {
|
|
262
262
|
const [open, setOpen] = useState(false);
|
|
263
263
|
const panelId = useId();
|
|
264
|
-
return (_jsxs("div", { className: `op-card ${className}`, children: [_jsxs("button", { type: "button", className: "op-card-head", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen((o) => !o), children: [head, _jsx("span", { className: "op-expand-chev", "aria-hidden": true, children: _jsx(Icon, { name: open ? 'chevron-down' : 'chevron-right', size: 11 }) })] }), _jsx("div", { id: panelId, className: `accordion-collapsible${open ? ' open' : ''}`, children: open ? _jsx("div", { className: "accordion-collapsible-inner", children: children }) : _jsx(CollapsedReaderText, { call: call })
|
|
264
|
+
return (_jsxs("div", { className: `op-card ${className}`, children: [_jsxs("button", { type: "button", className: "op-card-head", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen((o) => !o), children: [head, _jsx("span", { className: "op-expand-chev", "aria-hidden": true, children: _jsx(Icon, { name: open ? 'chevron-down' : 'chevron-right', size: 11 }) })] }), _jsx("div", { id: panelId, className: `accordion-collapsible${open ? ' open' : ''}`, children: open ? _jsx("div", { className: "accordion-collapsible-inner", children: children }) : null }), open ? null : _jsx(CollapsedReaderText, { call: call }), after] }));
|
|
265
265
|
}
|
|
266
266
|
/** The collapsed row's stand-in for its panel — see {@link ExpandableCard} and `describeCollapsedToolCall`. */
|
|
267
267
|
function CollapsedReaderText({ call }) {
|
|
@@ -273,7 +273,7 @@ function CollapsedReaderText({ call }) {
|
|
|
273
273
|
const runStreaming = !call.result && call.runStreaming;
|
|
274
274
|
const runSucceeded = !call.result && call.runSucceeded;
|
|
275
275
|
const text = useMemo(() => describeCollapsedToolCall({ input, result: resultContent === undefined ? undefined : { content: resultContent, isError: resultIsError } }, { runStreaming, runSucceeded }), [input, resultContent, resultIsError, runStreaming, runSucceeded]);
|
|
276
|
-
return _jsx("span", { className: "op-card-reader-text",
|
|
276
|
+
return _jsx("span", { className: "op-card-reader-text op-sr-prefix", children: text });
|
|
277
277
|
}
|
|
278
278
|
/** The call's input, its result (or why there is none), and any extra `children` — see `describeToolCallDetail` for the redaction and formatting rules. */
|
|
279
279
|
function ToolCallDetail({ input, result, runStreaming, runSucceeded, children }) {
|
|
@@ -17,4 +17,9 @@ export declare function toolRowTarget({ input, resultContent }: {
|
|
|
17
17
|
input: unknown;
|
|
18
18
|
resultContent?: string | undefined;
|
|
19
19
|
}): string | undefined;
|
|
20
|
+
/** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. */
|
|
21
|
+
export declare function targetAtOffset({ target, offset }: {
|
|
22
|
+
target: string | undefined;
|
|
23
|
+
offset: unknown;
|
|
24
|
+
}, _options?: {}): string | undefined;
|
|
20
25
|
//# sourceMappingURL=ToolCard.rules.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* draws it. Moved out of `ToolCard.tsx` (11-01) when the target learned to read the result too.
|
|
4
4
|
*/
|
|
5
5
|
/** Argument keys that name *what* a call acted on, best first: an element handle or page, then a human title/name/slug, then a path or query, then an id. */
|
|
6
|
-
const SUMMARY_KEYS = ['element', 'page', 'handle', 'title', 'name', 'slug', 'file_path', 'path', 'pattern', 'url', 'query', 'command', 'toolId', 'id'];
|
|
6
|
+
const SUMMARY_KEYS = ['element', 'page', 'handle', 'title', 'name', 'slug', 'file_path', 'path', 'pattern', 'url', 'query', 'command', 'toolId', 'pluginId', 'id'];
|
|
7
7
|
/** Result fields that name a record for a person — what a write or read returns about its target. */
|
|
8
8
|
const RESULT_NAME_KEYS = ['title', 'name', 'slug'];
|
|
9
9
|
/** Argument keys that say what *kind* of thing a call acted on — the last-resort target. */
|
|
@@ -88,6 +88,13 @@ export function toolRowTarget({ input, resultContent }) {
|
|
|
88
88
|
return String(input);
|
|
89
89
|
const args = (input ?? {});
|
|
90
90
|
const named = firstReadable(args, SUMMARY_KEYS) ?? resultName(resultContent);
|
|
91
|
-
|
|
91
|
+
const target = named ?? batchTarget(args) ?? firstReadable(args, KIND_KEYS) ?? Object.values(args).find(readable);
|
|
92
|
+
return targetAtOffset({ target, offset: args.offset });
|
|
93
|
+
}
|
|
94
|
+
/** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. */
|
|
95
|
+
export function targetAtOffset({ target, offset }, _options = {}) {
|
|
96
|
+
if (!target || typeof offset !== 'number')
|
|
97
|
+
return target;
|
|
98
|
+
return Number.isSafeInteger(offset) && offset >= 0 ? `${target} (offset ${offset})` : target;
|
|
92
99
|
}
|
|
93
100
|
//# sourceMappingURL=ToolCard.rules.js.map
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
import { questionAnswerText } from '../../core/question-answer.js';
|
|
9
9
|
/** Words in a finished call's result that mean nobody answered in time. */
|
|
10
10
|
const UNANSWERED_RESULT = /\b(expired|abandoned|did not respond|run ended)\b/i;
|
|
11
|
+
/** A confirmation the person cancelled ends with `{"cancelled":true,...}`; that is not an answer. @complexity O(r). */
|
|
12
|
+
function wasCancelled({ content }, _options = {}) {
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(content)?.cancelled === true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* Why a card can no longer be answered, or `undefined` while it still can.
|
|
13
22
|
*
|
|
@@ -28,6 +37,8 @@ function settledLabel(t, call, runStreaming, documentsForUri) {
|
|
|
28
37
|
return runStreaming ? undefined : t('This question expired');
|
|
29
38
|
if (documentsForUri > 1)
|
|
30
39
|
return undefined;
|
|
40
|
+
if (wasCancelled(call.result))
|
|
41
|
+
return t('Cancelled');
|
|
31
42
|
return UNANSWERED_RESULT.test(call.result.content) ? t('This question expired') : t('Answered');
|
|
32
43
|
}
|
|
33
44
|
/**
|
|
@@ -10,5 +10,5 @@ export declare function runtimeAgentStatus({ agent }: {
|
|
|
10
10
|
* @complexity Time: O(n) in the runtime inventory; space: O(n) for ordering.
|
|
11
11
|
* @overallScore 100/100
|
|
12
12
|
*/
|
|
13
|
-
export declare function AgentRuntimePicker({ agents, nativeToolPolicy, value, onChange, onRescan, scanning, daemonOnline, placement, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, }: AgentRuntimePickerProps): import("react").JSX.Element;
|
|
13
|
+
export declare function AgentRuntimePicker({ agentHandle, agents, nativeToolPolicy, value, onChange, onRescan, scanning, daemonOnline, placement, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, }: AgentRuntimePickerProps): import("react").JSX.Element;
|
|
14
14
|
//# sourceMappingURL=AgentRuntimePicker.d.ts.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { modelReasoningOptions } from '@jini-ai/agent-runtime/model-selection';
|
|
2
3
|
import { friendlyModelLabel, pickerModelValue, pickerCatalogNote, pickerModelOptions, shortModelLabel } from '../model-options.js';
|
|
3
4
|
import { useId } from 'react';
|
|
4
5
|
import { createPortal } from 'react-dom';
|
|
5
|
-
import { AgentIcon, RemixIcon, SearchableModelSelect } from '@jini-ai/ui';
|
|
6
|
+
import { AgentIcon, RemixIcon, SearchableModelSelect, useAgentHandle, useOverlayContainer } from '@jini-ai/ui';
|
|
7
|
+
import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
|
|
6
8
|
import { InfoTip } from '@jini-ai/ui/admin-widgets';
|
|
7
9
|
import { assessNativeToolPolicy } from '@jini-ai/agent-runtime/native-tool-policy';
|
|
8
10
|
import { useT } from '../../../hooks/context.js';
|
|
9
11
|
import { definedProps } from '../../../util/defined-props.js';
|
|
10
12
|
import { RuntimeDropUp } from './RuntimeDropUp.js';
|
|
11
|
-
import { defaultChatPaneSelection } from '../rules.js';
|
|
13
|
+
import { defaultChatPaneSelection, resolveChatPaneSelection } from '../rules.js';
|
|
12
14
|
import { runtimeOptionLabel, runtimePopoverPosition, useAgentRuntimePicker, } from '../hooks/useAgentRuntimePicker.hooks.js';
|
|
13
15
|
// Re-exported so this module's public surface is unchanged by the behavior extraction; both are
|
|
14
16
|
// pure and now live beside the hook that consumes them.
|
|
@@ -34,23 +36,23 @@ function NativeToolPolicyWarning({ agent, policy, isApi }) {
|
|
|
34
36
|
if (!agent || isApi)
|
|
35
37
|
return null;
|
|
36
38
|
const warning = policy ? assessNativeToolPolicy({ def: agent, policy }) : null;
|
|
37
|
-
return _jsxs(_Fragment, { children: [agent.fullCliAccessNote ? _jsx(FullAccessNoteTip, { note: agent.fullCliAccessNote, t: t }) : null, warning ? _jsx("
|
|
39
|
+
return _jsxs(_Fragment, { children: [agent.fullCliAccessNote ? _jsx(FullAccessNoteTip, { note: agent.fullCliAccessNote, t: t }) : null, warning ? _jsx(InfoTip, { label: t(warning), triggerLabel: t('Agent permissions required'), placement: "top", icon: _jsx(RemixIcon, { name: "alert-line", size: 16 }) }) : null] });
|
|
38
40
|
}
|
|
39
|
-
function RuntimeModeButtons({ executionMode, daemonOnline, apiModeAvailable, onExecutionModeChange, t, }) {
|
|
41
|
+
function RuntimeModeButtons({ base, executionMode, daemonOnline, apiModeAvailable, onExecutionModeChange, t, }) {
|
|
40
42
|
const localModeLabel = executionMode === 'local' ? t('active') : '';
|
|
41
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: `jini-runtime-mode${executionMode === 'local' ? ' is-active' : ''}`, disabled: !daemonOnline && executionMode !== 'local', onClick: () => onExecutionModeChange?.('local'), children: [_jsx(RemixIcon, { name: "terminal-box-line", size: 18 }), _jsx("span", { children: t('Use Local CLI') }), _jsx("span", { className: "jini-runtime-mode__meta", children: !daemonOnline ? t('offline') : localModeLabel }), executionMode === 'local' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), _jsxs("button", { type: "button", className: `jini-runtime-mode${executionMode === 'api' ? ' is-active' : ''}`, disabled: !apiModeAvailable, onClick: () => onExecutionModeChange?.('api'), children: [_jsx(RemixIcon, { name: "link", size: 18 }), _jsx("span", { children: t('Use API · BYOK') }), !apiModeAvailable ? _jsx("span", { className: "jini-runtime-mode__meta", children: t('not configured') }) : null, executionMode === 'api' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] })] }));
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: 'mode-local', role: 'button', label: t('Use Local CLI') }), className: `jini-runtime-mode${executionMode === 'local' ? ' is-active' : ''}`, disabled: !daemonOnline && executionMode !== 'local', onClick: () => onExecutionModeChange?.('local'), children: [_jsx(RemixIcon, { name: "terminal-box-line", size: 18 }), _jsx("span", { children: t('Use Local CLI') }), _jsx("span", { className: "jini-runtime-mode__meta", children: !daemonOnline ? t('offline') : localModeLabel }), executionMode === 'local' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), _jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: 'mode-api', role: 'button', label: t('Use API · BYOK') }), className: `jini-runtime-mode${executionMode === 'api' ? ' is-active' : ''}`, disabled: !apiModeAvailable, onClick: () => onExecutionModeChange?.('api'), children: [_jsx(RemixIcon, { name: "link", size: 18 }), _jsx("span", { children: t('Use API · BYOK') }), !apiModeAvailable ? _jsx("span", { className: "jini-runtime-mode__meta", children: t('not configured') }) : null, executionMode === 'api' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] })] }));
|
|
42
44
|
}
|
|
43
|
-
function RuntimeAgentList({ orderedAgents, value, onChange, agentIconBasePath, t, }) {
|
|
45
|
+
function RuntimeAgentList({ base, orderedAgents, value, onChange, agentIconBasePath, t, }) {
|
|
44
46
|
const noteIdPrefix = useId();
|
|
45
47
|
if (orderedAgents.length === 0) {
|
|
46
48
|
return _jsx("div", { className: "jini-runtime-empty", children: t('No available code agents') });
|
|
47
49
|
}
|
|
48
|
-
return (_jsx(_Fragment, { children: orderedAgents.map((agent) => (_jsx(RuntimeAgentRow, { agent: agent, active: agent.id === value.agentId, noteId: agent.fullCliAccessNote ? `${noteIdPrefix}-${agent.id}-note` : undefined, onChange: onChange, agentIconBasePath: agentIconBasePath, t: t }, agent.id))) }));
|
|
50
|
+
return (_jsx(_Fragment, { children: orderedAgents.map((agent) => (_jsx(RuntimeAgentRow, { base: base, agent: agent, active: agent.id === value.agentId, noteId: agent.fullCliAccessNote ? `${noteIdPrefix}-${agent.id}-note` : undefined, onChange: onChange, agentIconBasePath: agentIconBasePath, t: t }, agent.id))) }));
|
|
49
51
|
}
|
|
50
|
-
function RuntimeAgentRow({ agent, active, noteId, onChange, agentIconBasePath, t }) {
|
|
52
|
+
function RuntimeAgentRow({ base, agent, active, noteId, onChange, agentIconBasePath, t }) {
|
|
51
53
|
const status = runtimeAgentStatus({ agent: agent });
|
|
52
54
|
// The note's icon is a control of its own, so it sits beside the radio, never inside it.
|
|
53
|
-
return (_jsxs("div", { className: "jini-runtime-agent-row", children: [_jsxs("button", { type: "button", role: "radio", "aria-checked": active, className: `jini-runtime-agent${active ? ' is-active' : ''}`, "aria-current": active ? 'true' : undefined, "aria-label": `${agent.name} · ${status}`, ...(noteId ? { 'aria-describedby': noteId } : {}), onClick: () => onChange(defaultChatPaneSelection({ agent: agent })), children: [_jsx(AgentIcon, { id: agent.id, size: 20, className: "jini-runtime-agent-icon", ...definedProps({ source: { basePath: agentIconBasePath } }) }), _jsx("span", { className: "jini-runtime-agent__copy", children: _jsx("strong", { children: agent.name }) }), agent.supportsTools === false ? (_jsx("span", { className: "jini-runtime-agent__badge", title: t("This CLI has no MCP support, so it cannot use this app's tools."), children: t('No tools') })) : null, _jsx("span", { className: "jini-runtime-agent__status", children: active ? t('selected') : status }), active ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), agent.fullCliAccessNote ? _jsx(FullAccessNoteTip, { note: agent.fullCliAccessNote, descriptionId: noteId, t: t }) : null] }));
|
|
55
|
+
return (_jsxs("div", { className: "jini-runtime-agent-row", children: [_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: `agent-${agentHandleSegment({ value: agent.id })}`, role: 'button', label: agent.name }), role: "radio", "aria-checked": active, className: `jini-runtime-agent${active ? ' is-active' : ''}`, "aria-current": active ? 'true' : undefined, "aria-label": `${agent.name} · ${status}`, ...(noteId ? { 'aria-describedby': noteId } : {}), onClick: () => onChange(defaultChatPaneSelection({ agent: agent })), children: [_jsx(AgentIcon, { id: agent.id, size: 20, className: "jini-runtime-agent-icon", ...definedProps({ source: { basePath: agentIconBasePath } }) }), _jsx("span", { className: "jini-runtime-agent__copy", children: _jsx("strong", { children: agent.name }) }), agent.supportsTools === false ? (_jsx("span", { className: "jini-runtime-agent__badge", title: t("This CLI has no MCP support, so it cannot use this app's tools."), children: t('No tools') })) : null, _jsx("span", { className: "jini-runtime-agent__status", children: active ? t('selected') : status }), active ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), agent.fullCliAccessNote ? _jsx(FullAccessNoteTip, { note: agent.fullCliAccessNote, descriptionId: noteId, t: t }) : null] }));
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* The composer bar's "Model ⌄" and "Effort ⌄" drop-ups for the selected CLI. These replace the
|
|
@@ -59,20 +61,19 @@ function RuntimeAgentRow({ agent, active, noteId, onChange, agentIconBasePath, t
|
|
|
59
61
|
* selection, so nothing else changed. Either one renders nothing when the agent publishes no
|
|
60
62
|
* choices for it, rather than an empty menu.
|
|
61
63
|
*/
|
|
62
|
-
function RuntimeBarMenus({ selectedAgent, value, onChange, modelLabel, t }) {
|
|
64
|
+
function RuntimeBarMenus({ base, selectedAgent, value, onChange, modelLabel, t }) {
|
|
63
65
|
if (!selectedAgent)
|
|
64
66
|
return null;
|
|
65
67
|
// Raw catalog ids (an offline fallback list's rows) read as friendly names in the bar and its list.
|
|
66
68
|
const models = pickerModelOptions(selectedAgent).map((row) => ({ ...row, label: friendlyModelLabel({ label: row.label }) }));
|
|
67
|
-
const
|
|
69
|
+
const selectedModelId = pickerModelValue(selectedAgent, value.model);
|
|
70
|
+
const efforts = modelReasoningOptions({ agent: selectedAgent, model: models.find(option => option.id === selectedModelId) });
|
|
68
71
|
const modelName = friendlyModelLabel({ label: modelLabel });
|
|
69
|
-
return (_jsxs(_Fragment, { children: [models.length > 0 ? (_jsx(RuntimeDropUp, { label: t('Model'), valueLabel: modelName,
|
|
72
|
+
return (_jsxs(_Fragment, { children: [models.length > 0 ? (_jsx(RuntimeDropUp, { agentHandle: base ? `${base}-model` : false, label: t('Model'), valueLabel: modelName,
|
|
70
73
|
// The agent icon sits right beside it, so the bar drops the vendor word and caps the rest.
|
|
71
|
-
triggerLabel: shortModelLabel({ label: modelLabel, agentId: selectedAgent.id }), value: pickerModelValue(selectedAgent, value.model), options: models, note: pickerCatalogNote(selectedAgent, t), width: 260, onSelect: (model) => onChange({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...(value.reasoning ? { reasoning: value.reasoning } : {}),
|
|
75
|
-
}) })) : null, efforts.length > 0 ? (_jsx(RuntimeDropUp, { label: t('Reasoning'),
|
|
74
|
+
triggerLabel: shortModelLabel({ label: modelLabel, agentId: selectedAgent.id }), value: pickerModelValue(selectedAgent, value.model), options: models, note: pickerCatalogNote(selectedAgent, t), width: 260, onSelect: (model) => onChange(value.reasoning ? resolveChatPaneSelection({
|
|
75
|
+
agents: [selectedAgent], requested: { ...value, model },
|
|
76
|
+
}) : { agentId: value.agentId, model }) })) : null, efforts.length > 0 ? (_jsx(RuntimeDropUp, { agentHandle: base ? `${base}-reasoning` : false, label: t('Reasoning'),
|
|
76
77
|
// An unset reasoning shows the first option, as the old native select did.
|
|
77
78
|
valueLabel: efforts.find((option) => option.id === value.reasoning)?.label ?? efforts[0].label, value: value.reasoning ?? '', options: efforts, width: 180, className: "jini-runtime-dropup-trigger--effort", onSelect: (reasoning) => onChange({
|
|
78
79
|
agentId: value.agentId,
|
|
@@ -107,9 +108,9 @@ function resolveByokModel({ onByokModelChange }, { byokRuntime }) {
|
|
|
107
108
|
const pickModel = onByokModelChange !== undefined && models.length > 0 ? onByokModelChange : undefined;
|
|
108
109
|
return { model, models, pickModel };
|
|
109
110
|
}
|
|
110
|
-
function RuntimeByokDetails({ byokRuntime, onByokModelChange, t }) {
|
|
111
|
+
function RuntimeByokDetails({ base, byokRuntime, onByokModelChange, t }) {
|
|
111
112
|
const { model, models, pickModel } = resolveByokModel({ onByokModelChange }, { byokRuntime });
|
|
112
|
-
return (_jsxs("div", { className: "jini-runtime-models", children: [_jsxs("div", { className: "jini-runtime-select jini-runtime-byok-model", children: [_jsx("span", { children: t('Model') }), pickModel ? (_jsx(SearchableModelSelect, { models: models, value: model ?? '', onChange: (next) => pickModel(next), ariaLabel: t('Model'), searchPlaceholder: t('Search models'),
|
|
113
|
+
return (_jsxs("div", { className: "jini-runtime-models", children: [_jsxs("div", { className: "jini-runtime-select jini-runtime-byok-model", children: [_jsx("span", { children: t('Model') }), pickModel ? (_jsx(SearchableModelSelect, { agentHandle: base ? `${base}-byok-model` : false, models: models, value: model ?? '', onChange: (next) => pickModel(next), ariaLabel: t('Model'), searchPlaceholder: t('Search models'),
|
|
113
114
|
// The menu portals to `document.body` at the package default `z-index: 60`, while this
|
|
114
115
|
// popover positions itself at 1000 — so without this the model list opens BEHIND the
|
|
115
116
|
// popover that owns it. Raised here rather than in the shared stylesheet because 60 is
|
|
@@ -117,9 +118,9 @@ function RuntimeByokDetails({ byokRuntime, onByokModelChange, t }) {
|
|
|
117
118
|
// already-elevated surface.
|
|
118
119
|
menuClassName: "jini-runtime-model-menu" })) : (_jsx("strong", { children: model || t('No model configured') }))] }), !model && !pickModel ? (_jsx("div", { className: "jini-runtime-empty", children: t('Set a model in the BYOK settings before sending a message.') })) : null] }));
|
|
119
120
|
}
|
|
120
|
-
function RuntimeRescanFooter({ onRescan, scanning, t }) {
|
|
121
|
+
function RuntimeRescanFooter({ base, onRescan, scanning, t }) {
|
|
121
122
|
if (onRescan) {
|
|
122
|
-
return (_jsxs("button", { type: "button", className: "jini-runtime-rescan", disabled: scanning, onClick: onRescan, children: [_jsx(RemixIcon, { name: "refresh-line", size: 17, ...(scanning ? { className: 'jini-runtime-spinner' } : {}) }), _jsx("span", { children: scanning ? t('Scanning PATH…') : t('Rescan PATH') })] }));
|
|
123
|
+
return (_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: 'rescan', role: 'button', label: t('Rescan PATH') }), className: "jini-runtime-rescan", disabled: scanning, onClick: onRescan, children: [_jsx(RemixIcon, { name: "refresh-line", size: 17, ...(scanning ? { className: 'jini-runtime-spinner' } : {}) }), _jsx("span", { children: scanning ? t('Scanning PATH…') : t('Rescan PATH') })] }));
|
|
123
124
|
}
|
|
124
125
|
if (scanning) {
|
|
125
126
|
return _jsx("div", { className: "jini-runtime-empty", children: t('Scanning PATH…') });
|
|
@@ -136,14 +137,23 @@ function RuntimeTriggerIcon({ picker, isApi, byokRuntime, agentIconBasePath }) {
|
|
|
136
137
|
}
|
|
137
138
|
return _jsx(RemixIcon, { name: "link", size: 20, className: "jini-runtime-agent-icon" });
|
|
138
139
|
}
|
|
139
|
-
function RuntimeTrigger({ picker, isApi, byokRuntime, agentIconBasePath, t }) {
|
|
140
|
-
return (_jsxs("button", { ref: picker.triggerRef, type: "button", className: isApi ? 'jini-runtime-trigger' : 'jini-runtime-trigger jini-runtime-trigger--icon-only', "aria-label": t('Choose AI runtime'), "aria-haspopup": "dialog", "aria-expanded": picker.open, "aria-controls": picker.dialogId, title: `${picker.triggerTitle} · ${picker.modelLabel}`, onClick: picker.toggleOpen, children: [_jsx(RuntimeTriggerIcon, { picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath }), _jsxs("span", { className: "jini-runtime-trigger__copy", children: [_jsx("strong", { children: picker.triggerTitle }), isApi ? _jsx("small", { children: picker.modelLabel }) : null] }), isApi ? (_jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })) : null] }));
|
|
140
|
+
function RuntimeTrigger({ base, picker, isApi, byokRuntime, agentIconBasePath, t }) {
|
|
141
|
+
return (_jsxs("button", { ...agentHandleProps({}, { base, action: 'trigger', role: 'button', label: t('Choose AI runtime') }), ref: picker.triggerRef, type: "button", className: isApi ? 'jini-runtime-trigger' : 'jini-runtime-trigger jini-runtime-trigger--icon-only', "aria-label": t('Choose AI runtime'), "aria-haspopup": "dialog", "aria-expanded": picker.open, "aria-controls": picker.dialogId, title: `${picker.triggerTitle} · ${picker.modelLabel}`, onClick: picker.toggleOpen, children: [_jsx(RuntimeTriggerIcon, { picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath }), _jsxs("span", { className: "jini-runtime-trigger__copy", children: [_jsx("strong", { children: picker.triggerTitle }), isApi ? _jsx("small", { children: picker.modelLabel }) : null] }), isApi ? (_jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })) : null] }));
|
|
142
|
+
}
|
|
143
|
+
/** Keep native-dialog ownership and the originating page across a host overlay portal. */
|
|
144
|
+
function runtimePortalBinding({ trigger, overlay }) {
|
|
145
|
+
return {
|
|
146
|
+
container: trigger?.closest('dialog') ?? overlay,
|
|
147
|
+
page: trigger?.closest('[data-agent-page]')?.getAttribute('data-agent-page') ?? undefined,
|
|
148
|
+
};
|
|
141
149
|
}
|
|
142
|
-
function RuntimePopover({ picker, value, onChange, onRescan, scanning, daemonOnline, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, t, }) {
|
|
143
|
-
|
|
150
|
+
function RuntimePopover({ base, picker, value, onChange, onRescan, scanning, daemonOnline, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, t, }) {
|
|
151
|
+
const overlay = useOverlayContainer({});
|
|
152
|
+
const portal = runtimePortalBinding({ trigger: picker.triggerRef.current, overlay });
|
|
153
|
+
if (!picker.open || !picker.position || !portal.container)
|
|
144
154
|
return null;
|
|
145
155
|
const isApi = executionMode === 'api';
|
|
146
|
-
return createPortal(_jsxs("div", { ref: picker.popoverRef, className: "jini-runtime-popover", ...(picker.originTheme ? { 'data-theme': picker.originTheme } : {}), id: picker.dialogId, role: "dialog", "aria-label": t('Choose AI runtime'), "aria-modal": "false", style: picker.position, onKeyDown: picker.handlePopoverKeyDown, children: [_jsxs("div", { className: "jini-runtime-popover__head", children: [_jsx("strong", { children: executionMode === 'local' ? t('Local CLI') : t('API · BYOK') }), _jsx("span", { children: picker.runtimeSummary })] }), _jsx(RuntimeModeButtons, { executionMode: executionMode, daemonOnline: daemonOnline, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, t: t }), isApi ? (_jsx(RuntimeByokDetails, { byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, t: t })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "jini-runtime-section-label", children: t('Code agent') }), _jsx("div", { role: "radiogroup", "aria-label": t('Code agent'), children: _jsx(RuntimeAgentList, { orderedAgents: picker.orderedAgents, value: value, onChange: onChange, ...definedProps({ source: { agentIconBasePath } }), t: t }) }), _jsx(RuntimeRescanFooter, { onRescan: onRescan, scanning: scanning, t: t })] }))] }),
|
|
156
|
+
return createPortal(_jsxs("div", { ref: picker.popoverRef, className: "jini-runtime-popover", "data-agent-page": portal.page, ...(picker.originTheme ? { 'data-theme': picker.originTheme } : {}), id: picker.dialogId, role: "dialog", "aria-label": t('Choose AI runtime'), "aria-modal": "false", style: picker.position, onKeyDown: picker.handlePopoverKeyDown, children: [_jsxs("div", { className: "jini-runtime-popover__head", children: [_jsx("strong", { children: executionMode === 'local' ? t('Local CLI') : t('API · BYOK') }), _jsx("span", { children: picker.runtimeSummary })] }), _jsx(RuntimeModeButtons, { base: base, executionMode: executionMode, daemonOnline: daemonOnline, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, t: t }), isApi ? (_jsx(RuntimeByokDetails, { base: base, byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, t: t })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "jini-runtime-section-label", children: t('Code agent') }), _jsx("div", { role: "radiogroup", "aria-label": t('Code agent'), children: _jsx(RuntimeAgentList, { base: base, orderedAgents: picker.orderedAgents, value: value, onChange: onChange, ...definedProps({ source: { agentIconBasePath } }), t: t }) }), _jsx(RuntimeRescanFooter, { base: base, onRescan: onRescan, scanning: scanning, t: t })] }))] }), portal.container);
|
|
147
157
|
}
|
|
148
158
|
/**
|
|
149
159
|
* Renders the package-owned local/API, agent, model, and reasoning picker.
|
|
@@ -151,11 +161,12 @@ function RuntimePopover({ picker, value, onChange, onRescan, scanning, daemonOnl
|
|
|
151
161
|
* @complexity Time: O(n) in the runtime inventory; space: O(n) for ordering.
|
|
152
162
|
* @overallScore 100/100
|
|
153
163
|
*/
|
|
154
|
-
export function AgentRuntimePicker({ agents, nativeToolPolicy, value, onChange, onRescan, scanning = false, daemonOnline = true, placement = 'up', executionMode = 'local', apiModeAvailable = false, onExecutionModeChange, byokRuntime, onByokModelChange,
|
|
164
|
+
export function AgentRuntimePicker({ agentHandle, agents, nativeToolPolicy, value, onChange, onRescan, scanning = false, daemonOnline = true, placement = 'up', executionMode = 'local', apiModeAvailable = false, onExecutionModeChange, byokRuntime, onByokModelChange,
|
|
155
165
|
// No default here (was '/agent-icons'): omitted means "let AgentIcon fall back to its own
|
|
156
166
|
// bundled icon set" — see AgentIcon.tsx's BUNDLED_ICON_URLS. A host that still wants to vendor
|
|
157
167
|
// its own asset directory can pass this explicitly, same as before.
|
|
158
168
|
agentIconBasePath, }) {
|
|
169
|
+
const base = useAgentHandle({ agentHandle });
|
|
159
170
|
const t = useT();
|
|
160
171
|
const picker = useAgentRuntimePicker({ agents, value, placement, t, executionMode, byokRuntime });
|
|
161
172
|
// The one branch this component makes. Everything below the mode buttons describes a detected CLI
|
|
@@ -164,6 +175,6 @@ agentIconBasePath, }) {
|
|
|
164
175
|
// operator on BYOK saw a CLI named as "selected" and a model reading "Default (CLI config)"
|
|
165
176
|
// while their messages went to a provider over an API key.
|
|
166
177
|
const isApi = executionMode === 'api';
|
|
167
|
-
return (_jsxs("div", { className: "jini-runtime-picker", children: [_jsx(RuntimeTrigger, { picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath, t: t }), isApi ? null : (_jsx(RuntimeBarMenus, { selectedAgent: picker.selectedAgent, value: value, onChange: onChange, modelLabel: picker.modelLabel, t: t })), _jsx(NativeToolPolicyWarning, { agent: picker.selectedAgent, policy: nativeToolPolicy, isApi: isApi }), _jsx(RuntimePopover, { picker: picker, value: value, onChange: onChange, onRescan: onRescan, scanning: scanning, daemonOnline: daemonOnline, executionMode: executionMode, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, agentIconBasePath: agentIconBasePath, t: t })] }));
|
|
178
|
+
return (_jsxs("div", { className: "jini-runtime-picker", children: [_jsx(RuntimeTrigger, { base: base, picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath, t: t }), isApi ? null : (_jsx(RuntimeBarMenus, { base: base, selectedAgent: picker.selectedAgent, value: value, onChange: onChange, modelLabel: picker.modelLabel, t: t })), _jsx(NativeToolPolicyWarning, { agent: picker.selectedAgent, policy: nativeToolPolicy, isApi: isApi }), _jsx(RuntimePopover, { base: base, picker: picker, value: value, onChange: onChange, onRescan: onRescan, scanning: scanning, daemonOnline: daemonOnline, executionMode: executionMode, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, agentIconBasePath: agentIconBasePath, t: t })] }));
|
|
168
179
|
}
|
|
169
180
|
//# sourceMappingURL=AgentRuntimePicker.js.map
|