@kortix/ui 0.16.4 → 0.16.5
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/dist/customize/sections/view/review-center-connected.js +64 -71
- package/dist/customize/sections/view/secret-delivery.d.ts +11 -20
- package/dist/customize/sections/view/secret-delivery.js +20 -29
- package/dist/customize/sections/view/secrets-view.js +9 -24
- package/dist/i18n/en.d.ts +116 -13
- package/dist/i18n/en.js +127 -24
- package/dist/i18n/ui-catalog/product-catalog-translation-keys.generated.js +2 -0
- package/dist/internal/auth/auth-card-shell.d.ts +24 -3
- package/dist/internal/auth/auth-card-shell.js +15 -8
- package/dist/internal/auth/auth-primitives.d.ts +15 -2
- package/dist/internal/auth/auth-primitives.js +22 -5
- package/dist/internal/components/agent-mark.d.ts +2 -1
- package/dist/internal/components/agent-mark.js +14 -3
- package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
- package/dist/internal/hooks/use-review-session-summary.js +1 -1
- package/dist/internal/layout/project-nav-row.d.ts +3 -1
- package/dist/internal/layout/project-nav-row.js +2 -2
- package/dist/markdown/setup-links/secret-intake-form.d.ts +4 -1
- package/dist/markdown/setup-links/secret-intake-form.js +60 -16
- package/dist/markdown/setup-links/setup-link-button.js +6 -1
- package/dist/session/agents/agent-hover-card.d.ts +26 -0
- package/dist/session/agents/agent-hover-card.js +70 -0
- package/dist/session/agents/agent-strip.js +33 -7
- package/dist/session/agents/agent-surface.d.ts +26 -1
- package/dist/session/agents/agent-surface.js +57 -6
- package/dist/session/agents/held-messages.js +2 -2
- package/dist/session/agents/subagent-dialog-content.js +2 -2
- package/dist/session/composer/ComposerCard.js +4 -1
- package/dist/session/composer/composer-toolbar.d.ts +8 -1
- package/dist/session/composer/composer-toolbar.js +2 -2
- package/dist/session/composer/dictation/dictation-control.d.ts +10 -0
- package/dist/session/composer/dictation/dictation-control.js +28 -0
- package/dist/session/composer/dictation/dictation-state.d.ts +26 -0
- package/dist/session/composer/dictation/dictation-state.js +71 -0
- package/dist/session/composer/dictation/recorder.d.ts +30 -0
- package/dist/session/composer/dictation/recorder.js +129 -0
- package/dist/session/composer/dictation/use-composer-dictation.d.ts +25 -0
- package/dist/session/composer/dictation/use-composer-dictation.js +218 -0
- package/dist/session/composer/queued-prompt-list.js +5 -1
- package/dist/session/panel/easy/apps-card.js +3 -10
- package/dist/session/panel/easy/background-tasks-card.d.ts +23 -0
- package/dist/session/panel/easy/background-tasks-card.js +119 -0
- package/dist/session/panel/easy/change-requests-card.js +1 -1
- package/dist/session/panel/easy/changes-card.js +4 -6
- package/dist/session/panel/easy/context-card.js +8 -9
- package/dist/session/panel/easy/context-meter.d.ts +2 -0
- package/dist/session/panel/easy/context-meter.js +18 -4
- package/dist/session/panel/easy/detail-view.js +4 -2
- package/dist/session/panel/easy/easy-panel-logic.d.ts +4 -15
- package/dist/session/panel/easy/easy-panel-logic.js +4 -17
- package/dist/session/panel/easy/easy-panel.js +5 -4
- package/dist/session/panel/easy/outputs-card.d.ts +1 -13
- package/dist/session/panel/easy/outputs-card.js +14 -40
- package/dist/session/panel/easy/panel-card.d.ts +13 -40
- package/dist/session/panel/easy/panel-card.js +17 -55
- package/dist/session/panel/easy/plan-card.js +4 -7
- package/dist/session/panel/model-switch-event.d.ts +2 -2
- package/dist/session/panel/model-switch-event.js +13 -9
- package/dist/session/panel/session-panel-provider.d.ts +2 -1
- package/dist/session/panel/session-panel-provider.js +3 -3
- package/dist/session/panel/shared/derive-panels.js +14 -1
- package/dist/session/panel/shared/use-panel-handoffs.d.ts +0 -1
- package/dist/session/panel/shared/use-panel-handoffs.js +3 -15
- package/dist/session/thread/chat-minimap.js +7 -1
- package/dist/session/thread/session-chat.js +59 -15
- package/dist/session/tool/shared/infrastructure-contexts.d.ts +2 -0
- package/dist/session/tool/shared/infrastructure-contexts.js +2 -0
- package/dist/session/tool/shared/infrastructure-row-header.js +4 -1
- package/dist/session/tool/shared/infrastructure-rows.js +19 -19
- package/dist/session/tool/tool-part-renderer.js +23 -9
- package/dist/session/tool/tools/bash-tool.js +3 -2
- package/dist/session/tool/tools/codemode-tool.d.ts +15 -0
- package/dist/session/tool/tools/codemode-tool.js +54 -2
- package/dist/session/tool/tools/kortix-action-tool.d.ts +1 -0
- package/dist/session/tool/tools/kortix-action-tool.js +19 -8
- package/dist/session/tool/tools/multi-agent-tool-bodies.d.ts +8 -1
- package/dist/session/tool/tools/multi-agent-tool-bodies.js +76 -10
- package/dist/session/tool/tools/task-tool.js +17 -5
- package/dist/session/turn/peer-message-row.d.ts +3 -0
- package/dist/session/turn/peer-message-row.js +8 -2
- package/dist/session/turn/subagent-notice-row.js +5 -3
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +116 -13
- package/dist/workspace/projects/modal/project-icon-field.d.ts +3 -1
- package/dist/workspace/projects/modal/project-icon-field.js +3 -3
- package/dist/workspace/review/review-center.d.ts +9 -1
- package/dist/workspace/review/review-center.js +107 -14
- package/dist/workspace/review/review-detail.d.ts +19 -0
- package/dist/workspace/review/review-detail.js +18 -3
- package/dist/workspace/review/review-swipe-deck.d.ts +27 -0
- package/dist/workspace/review/review-swipe-deck.js +304 -0
- package/dist/workspace/review/review-swipe.d.ts +17 -0
- package/dist/workspace/review/review-swipe.js +10 -0
- package/dist/workspace/sidebar/footer/project-review-nav.d.ts +13 -0
- package/dist/workspace/sidebar/footer/project-review-nav.js +29 -0
- package/dist/workspace/sidebar/project-nav-items.d.ts +3 -1
- package/dist/workspace/sidebar/project-nav-items.js +24 -5
- package/dist/workspace/sidebar/project-spaces-nav.js +3 -10
- package/dist/workspace/sidebar/sidebar-more-group.js +1 -1
- package/package.json +3 -3
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { narrationToolName, normalizeActivityToolName } from '@kortix/sdk';
|
|
4
4
|
import { useClearFocusedToolCall, useFocusedAgent, useFocusedToolCallId, useKortixComputerStore } from '../../../internal/stores/kortix-computer-store.js';
|
|
5
5
|
import { SubagentPanel } from '../../agents/subagent-view.js';
|
|
6
6
|
import { DetailSidebarToggle, ToolParts } from '../easy/detail-view.js';
|
|
7
7
|
import { useSessionBrowserStore } from '../../../internal/stores/session-browser-store.js';
|
|
8
|
-
import { pathOutput,
|
|
8
|
+
import { pathOutput, shouldAutoOpenPayoff, stepForCallId } from '../easy/easy-panel-logic.js';
|
|
9
9
|
import { StepDetailBody } from '../easy/step-detail-body.js';
|
|
10
10
|
import { StepIcon } from '../easy/step-icon.js';
|
|
11
11
|
import { selectPrimaryDeliverable } from './output-priority.js';
|
|
12
12
|
export function usePanelHandoffs({ sessionId, projectId, projectSessionId, isRunning, outcome, apps, files, steps, calls, detail, handleOpenOutput, openDetail, closeDetail, openTerminal, openAudit, openReminders, openDesktop, openBrowser, openFiles, }) {
|
|
13
|
-
// Auto-expand Outputs the moment a run finishes with something to show —
|
|
14
|
-
// never on every render of an already-finished (or still-running) run, and
|
|
15
|
-
// never on a failed one: a pile of half-written files is not a celebration.
|
|
16
|
-
const wasRunningRef = useRef(isRunning);
|
|
17
|
-
const [outputsDefaultOpen, setOutputsDefaultOpen] = useState(false);
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (outcome === 'succeeded' &&
|
|
20
|
-
shouldAutoExpandOutputs(wasRunningRef.current, isRunning, files.length)) {
|
|
21
|
-
setOutputsDefaultOpen(true);
|
|
22
|
-
}
|
|
23
|
-
wasRunningRef.current = isRunning;
|
|
24
|
-
}, [isRunning, files.length, outcome]);
|
|
25
13
|
// Payoff (W2): present the primary deliverable exactly once, at the finish,
|
|
26
14
|
// and only when the user hasn't taken the wheel themselves this run.
|
|
27
15
|
//
|
|
@@ -233,5 +221,5 @@ export function usePanelHandoffs({ sessionId, projectId, projectSessionId, isRun
|
|
|
233
221
|
openBrowser,
|
|
234
222
|
openFiles,
|
|
235
223
|
]);
|
|
236
|
-
return {
|
|
224
|
+
return { pendingQuickView };
|
|
237
225
|
}
|
|
@@ -130,7 +130,13 @@ export function ChatMinimap({ turns, scrollRef, contentRef }) {
|
|
|
130
130
|
// Focus opens the card and magnifies the dash, but a keyboard
|
|
131
131
|
// user still needs a ring they can locate — it goes on the ROW,
|
|
132
132
|
// because a ring around a 3px dash is unreadable.
|
|
133
|
-
className: cn('hit-area-x-5 last:hit-area-b-3 first:hit-area-t-3 flex cursor-pointer items-center justify-start rounded-sm px-0.5', 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none'), onPointerEnter: () => focusRow(row), onFocus: () => focusRow(row), onBlur: () => focusRow(null),
|
|
133
|
+
className: cn('hit-area-x-5 last:hit-area-b-3 first:hit-area-t-3 flex cursor-pointer items-center justify-start rounded-sm px-0.5', 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none'), onPointerEnter: () => focusRow(row), onFocus: () => focusRow(row), onBlur: () => focusRow(null),
|
|
134
|
+
// The jump shows the message itself, so its preview closes: a preview left
|
|
135
|
+
// over the transcript hid the very text the reader jumped to.
|
|
136
|
+
onClick: () => {
|
|
137
|
+
handleJump(item.id);
|
|
138
|
+
focusRow(null);
|
|
139
|
+
}, children: _jsx("span", { "aria-hidden": true, style: {
|
|
134
140
|
width: dashWidth(distance),
|
|
135
141
|
height: DASH_THICKNESS,
|
|
136
142
|
opacity: dashOpacity(distance),
|
|
@@ -1447,9 +1447,27 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
1447
1447
|
}));
|
|
1448
1448
|
return parked.length ? [...livePermissions, ...parked] : livePermissions;
|
|
1449
1449
|
}, [livePermissions, parkedAsks, sessionId]);
|
|
1450
|
+
// A question the person answered or dismissed stays hidden for this mount,
|
|
1451
|
+
// even while a source still lists it: the live list can keep a replied
|
|
1452
|
+
// question for minutes (until the turn moves on), and the parked-asks poll
|
|
1453
|
+
// lags the answer. A card that came back would show nothing, because the
|
|
1454
|
+
// prompt hides itself once replied, and its collapsed wrapper left an empty
|
|
1455
|
+
// strip above the composer. A reply that fails releases the id, and the card
|
|
1456
|
+
// comes back as a fresh, answerable one (`questionRetries` remounts it).
|
|
1450
1457
|
const suppressedQuestionIdsRef = useRef(new Map());
|
|
1451
|
-
|
|
1458
|
+
// Retries per question: a failed reply remounts only its own card.
|
|
1459
|
+
const [questionRetries, setQuestionRetries] = useState({});
|
|
1460
|
+
// A ref write renders nothing: the tick makes the question lists re-read the
|
|
1461
|
+
// map, so a hidden card leaves at once instead of after the reply lands.
|
|
1462
|
+
const [suppressTick, setSuppressTick] = useState(0);
|
|
1463
|
+
const suppressQuestionFor = useCallback((requestId, ms = Number.POSITIVE_INFINITY) => {
|
|
1452
1464
|
suppressedQuestionIdsRef.current.set(requestId, Date.now() + ms);
|
|
1465
|
+
setSuppressTick((n) => n + 1);
|
|
1466
|
+
}, []);
|
|
1467
|
+
const releaseQuestion = useCallback((requestId) => {
|
|
1468
|
+
suppressedQuestionIdsRef.current.delete(requestId);
|
|
1469
|
+
setSuppressTick((n) => n + 1);
|
|
1470
|
+
setQuestionRetries((retries) => ({ ...retries, [requestId]: (retries[requestId] ?? 0) + 1 }));
|
|
1453
1471
|
}, []);
|
|
1454
1472
|
const isQuestionSuppressed = useCallback((requestId) => {
|
|
1455
1473
|
const expiresAt = suppressedQuestionIdsRef.current.get(requestId);
|
|
@@ -1462,14 +1480,18 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
1462
1480
|
return true;
|
|
1463
1481
|
}, []);
|
|
1464
1482
|
const liveQuestions = useMemo(() => (sessionState?.questions ??
|
|
1465
|
-
Object.values(allQuestions).filter((q) => q.sessionID === sessionId)).filter((q) => !isQuestionSuppressed(q.id)),
|
|
1483
|
+
Object.values(allQuestions).filter((q) => q.sessionID === sessionId)).filter((q) => !isQuestionSuppressed(q.id)),
|
|
1484
|
+
// `suppressTick` re-reads the suppression map when a card hides or returns.
|
|
1485
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1486
|
+
[sessionState?.questions, allQuestions, sessionId, isQuestionSuppressed, suppressTick]);
|
|
1466
1487
|
const pendingQuestions = useMemo(() => {
|
|
1467
1488
|
const live = new Set(liveQuestions.map((q) => q.id));
|
|
1468
1489
|
const parked = parkedAsks
|
|
1469
1490
|
.filter((ask) => ask.kind === 'question' && ask.question && !live.has(ask.request_id) && !isQuestionSuppressed(ask.request_id))
|
|
1470
1491
|
.map((ask) => ({ id: ask.request_id, sessionID: sessionId, questions: ask.question.questions }));
|
|
1471
1492
|
return parked.length ? [...liveQuestions, ...parked] : liveQuestions;
|
|
1472
|
-
|
|
1493
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1494
|
+
}, [liveQuestions, parkedAsks, sessionId, isQuestionSuppressed, suppressTick]);
|
|
1473
1495
|
/**
|
|
1474
1496
|
* The runtime is parked on an answer only the user can give.
|
|
1475
1497
|
*
|
|
@@ -1542,12 +1564,13 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
1542
1564
|
// stayed open (KRTX-4450). A question in neither list is one just answered,
|
|
1543
1565
|
// held only for its fade-out: unlocked, so text typed into the fade is a
|
|
1544
1566
|
// message, never a swallowed answer.
|
|
1567
|
+
// From the filtered list: a question hidden after its answer (still in the
|
|
1568
|
+
// asks cache while the reply lands) must not take the next message.
|
|
1545
1569
|
const questionLock = useMemo(() => {
|
|
1546
1570
|
if (!renderedQuestion)
|
|
1547
1571
|
return false;
|
|
1548
|
-
return
|
|
1549
|
-
|
|
1550
|
-
}, [renderedQuestion, liveQuestions, parkedAskIdByRequest]);
|
|
1572
|
+
return pendingQuestions.some((q) => q.id === renderedQuestion.id);
|
|
1573
|
+
}, [renderedQuestion, pendingQuestions]);
|
|
1551
1574
|
// Transcript-placed waiting entries share the turn renderer. The inbox marks their IDs as
|
|
1552
1575
|
// pending until delivery; a client-minted wire ID does not place a message.
|
|
1553
1576
|
// Each is the user message `sessionLogPromptMessage` mints for its prompt.
|
|
@@ -2090,24 +2113,34 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
2090
2113
|
// answer against the tool part's ID.
|
|
2091
2114
|
const questionReq = sessionState?.questions.find((question) => question.id === requestId) ??
|
|
2092
2115
|
useRuntimePendingStore.getState().questions[requestId];
|
|
2116
|
+
// Hide the card at once; the question leaves the store only once the
|
|
2117
|
+
// answer lands. A failed reply then needs no restore (which could bring
|
|
2118
|
+
// back a question the runtime did answer): releasing the hide is enough.
|
|
2093
2119
|
suppressQuestionFor(requestId);
|
|
2094
|
-
// Optimistically remove the question so the textarea shows immediately
|
|
2095
|
-
removeQuestion(requestId);
|
|
2096
2120
|
const parkedAskId = liveQuestions.some((q) => q.id === requestId) ? undefined : parkedAskIdByRequest.get(requestId);
|
|
2097
2121
|
if (parkedAskId) {
|
|
2098
2122
|
// Parked: the answer reaches the agent as a message that quotes the question.
|
|
2099
|
-
|
|
2123
|
+
// Awaited per request: a second decision must not replace this one's outcome.
|
|
2124
|
+
try {
|
|
2125
|
+
await answerParkedAsk.mutateAsync({ askId: parkedAskId, answer: { answers } });
|
|
2126
|
+
removeQuestion(requestId);
|
|
2127
|
+
}
|
|
2128
|
+
catch {
|
|
2129
|
+
releaseQuestion(requestId);
|
|
2130
|
+
}
|
|
2100
2131
|
return;
|
|
2101
2132
|
}
|
|
2102
2133
|
// Save the answers in the optimistic cache keyed by the question call's
|
|
2103
2134
|
// block id. This cache survives updates that may overwrite the call
|
|
2104
2135
|
// before the server includes its answers; the transcript's answered
|
|
2105
2136
|
// questions read from it as a fallback.
|
|
2137
|
+
let cachedBlockId = null;
|
|
2106
2138
|
if (questionReq?.tool?.messageID) {
|
|
2107
2139
|
const { messageID, callID } = questionReq.tool;
|
|
2108
2140
|
const message = threadRef.current?.messages.find((m) => m.message_id === messageID);
|
|
2109
2141
|
const match = message?.blocks.find((b) => b.type === 'tool_call' && isQuestionTool(b.name) && b.call_id === callID);
|
|
2110
2142
|
if (match?.type === 'tool_call') {
|
|
2143
|
+
cachedBlockId = match.id;
|
|
2111
2144
|
optimisticAnswersCache.set(match.id, {
|
|
2112
2145
|
answers,
|
|
2113
2146
|
input: match.input && typeof match.input === 'object'
|
|
@@ -2121,11 +2154,16 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
2121
2154
|
await sessionState.answerQuestion(requestId, answers);
|
|
2122
2155
|
else
|
|
2123
2156
|
await replyToQuestion(requestId, answers);
|
|
2157
|
+
removeQuestion(requestId);
|
|
2124
2158
|
}
|
|
2125
2159
|
catch {
|
|
2126
|
-
//
|
|
2160
|
+
// The answer did not land: the card comes back, fresh, if the question
|
|
2161
|
+
// is still open. The cached answer goes: the transcript must not show it.
|
|
2162
|
+
if (cachedBlockId)
|
|
2163
|
+
optimisticAnswersCache.delete(cachedBlockId);
|
|
2164
|
+
releaseQuestion(requestId);
|
|
2127
2165
|
}
|
|
2128
|
-
}, [sessionState, removeQuestion, suppressQuestionFor, liveQuestions, parkedAskIdByRequest, answerParkedAsk]);
|
|
2166
|
+
}, [sessionState, removeQuestion, suppressQuestionFor, releaseQuestion, liveQuestions, parkedAskIdByRequest, answerParkedAsk]);
|
|
2129
2167
|
const handleQuestionReject = useCallback(async (requestId) => {
|
|
2130
2168
|
suppressQuestionFor(requestId);
|
|
2131
2169
|
// Optimistically remove the question so the textarea shows immediately
|
|
@@ -2133,7 +2171,12 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
2133
2171
|
const parkedAskId = liveQuestions.some((q) => q.id === requestId) ? undefined : parkedAskIdByRequest.get(requestId);
|
|
2134
2172
|
if (parkedAskId) {
|
|
2135
2173
|
// Dismissing a parked question closes it; nothing runs, so nothing is stopped.
|
|
2136
|
-
|
|
2174
|
+
try {
|
|
2175
|
+
await answerParkedAsk.mutateAsync({ askId: parkedAskId, answer: { dismiss: true } });
|
|
2176
|
+
}
|
|
2177
|
+
catch {
|
|
2178
|
+
releaseQuestion(requestId);
|
|
2179
|
+
}
|
|
2137
2180
|
return;
|
|
2138
2181
|
}
|
|
2139
2182
|
try {
|
|
@@ -2143,7 +2186,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
2143
2186
|
await rejectQuestion(requestId);
|
|
2144
2187
|
}
|
|
2145
2188
|
catch {
|
|
2146
|
-
// ignore —
|
|
2189
|
+
// ignore — the cancel below ends the turn the question holds
|
|
2147
2190
|
}
|
|
2148
2191
|
// Also abort the session so the "The operation was aborted." banner
|
|
2149
2192
|
// appears. Routed through `issueSessionCancel` (T10) so this
|
|
@@ -2155,7 +2198,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
2155
2198
|
else if (!abortSession.isPending) {
|
|
2156
2199
|
issueSessionCancel();
|
|
2157
2200
|
}
|
|
2158
|
-
}, [sessionState, removeQuestion, abortSession, suppressQuestionFor, issueSessionCancel]);
|
|
2201
|
+
}, [sessionState, removeQuestion, abortSession, suppressQuestionFor, releaseQuestion, liveQuestions, parkedAskIdByRequest, answerParkedAsk, issueSessionCancel]);
|
|
2159
2202
|
// A compaction turn of any state (`turn.compaction`), so a failed attempt's
|
|
2160
2203
|
// turn suppresses the optimistic "Compacting…" marker instead of leaving it
|
|
2161
2204
|
// shimmering beside the failure row.
|
|
@@ -3501,7 +3544,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
3501
3544
|
]);
|
|
3502
3545
|
const chatInputSlot = useMemo(() => (_jsxs(_Fragment, { children: [_jsx(SessionApprovalPrompt, { onDockedChange: setApprovalDocked }), _jsx(SessionAccessPrompt, { projectId: projectId ?? '', asks: accessAsks, onDockedChange: setAccessDocked }), _jsx(SessionPermissionPrompt, { sessionId: sessionId, agentName: sessionScopeAgentName, permissions: pendingPermissions, onReply: handlePermissionReply }), renderedQuestion ? (_jsx("div", { className: cn('w-full overflow-hidden transition-[max-height,opacity,transform] ease-in-out', questionPromptVisible
|
|
3503
3546
|
? 'duration-slow max-h-130 translate-y-0 opacity-100'
|
|
3504
|
-
: 'duration-slow pointer-events-none max-h-0 -translate-y-1 opacity-0'), children: _jsx(QuestionPrompt, { ref: questionPromptRef, request: renderedQuestion, onReply: handleQuestionReply, onReject: handleQuestionReject, onActionChange: handleQuestionActionChange }, renderedQuestion.id) })) : null] })), [
|
|
3547
|
+
: 'duration-slow pointer-events-none max-h-0 -translate-y-1 opacity-0'), children: _jsx(QuestionPrompt, { ref: questionPromptRef, request: renderedQuestion, onReply: handleQuestionReply, onReject: handleQuestionReject, onActionChange: handleQuestionActionChange }, `${renderedQuestion.id}:${questionRetries[renderedQuestion.id] ?? 0}`) })) : null] })), [
|
|
3505
3548
|
projectId,
|
|
3506
3549
|
accessAsks,
|
|
3507
3550
|
sessionId,
|
|
@@ -3509,6 +3552,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
3509
3552
|
pendingPermissions,
|
|
3510
3553
|
handlePermissionReply,
|
|
3511
3554
|
renderedQuestion,
|
|
3555
|
+
questionRetries,
|
|
3512
3556
|
questionPromptVisible,
|
|
3513
3557
|
handleQuestionReply,
|
|
3514
3558
|
handleQuestionReject,
|
|
@@ -90,6 +90,8 @@ export declare const ImageGenRunsContext: import("react").Context<ReadonlyMap<st
|
|
|
90
90
|
*/
|
|
91
91
|
export declare const InTranscriptTurnContext: import("react").Context<boolean>;
|
|
92
92
|
export declare const ToolDurationContext: import("react").Context<number | undefined>;
|
|
93
|
+
/** When the call started (ISO), for rows that show a time. */
|
|
94
|
+
export declare const ToolStartedAtContext: import("react").Context<string | undefined>;
|
|
93
95
|
/**
|
|
94
96
|
* True in a read-only session view (the sub-session modal): a tool card shows
|
|
95
97
|
* what happened and offers no fix (connect a model, reconnect ChatGPT).
|
|
@@ -94,6 +94,8 @@ export const ImageGenRunsContext = createContext(new Map());
|
|
|
94
94
|
*/
|
|
95
95
|
export const InTranscriptTurnContext = createContext(false);
|
|
96
96
|
export const ToolDurationContext = createContext(undefined);
|
|
97
|
+
/** When the call started (ISO), for rows that show a time. */
|
|
98
|
+
export const ToolStartedAtContext = createContext(undefined);
|
|
97
99
|
/**
|
|
98
100
|
* True in a read-only session view (the sub-session modal): a tool card shows
|
|
99
101
|
* what happened and offers no fix (connect a model, reconnect ChatGPT).
|
|
@@ -119,7 +119,10 @@ export function PanelRowTitle({ trigger, running, onSubtitleClick, }) {
|
|
|
119
119
|
// Same read, same reason as the inline row — one behaviour, two surfaces.
|
|
120
120
|
const open = useToolOpen();
|
|
121
121
|
const subtitle = open && trigger.hideSubtitleWhenOpen ? undefined : trigger.subtitle;
|
|
122
|
-
return (_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden", children: [running ? (_jsx(TextShimmer, { className: cn(PANEL_TITLE_CLASS, 'text-sm
|
|
122
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden", children: [running ? (_jsx(TextShimmer, { className: cn(PANEL_TITLE_CLASS, 'text-sm'), children: trigger.title || 'Working' })) : (
|
|
123
|
+
// The verb is meta ink when a value follows it: the value is what the
|
|
124
|
+
// reader scans for. Alone, the title is the row's name.
|
|
125
|
+
_jsx("span", { className: cn('text-sm', subtitle ? 'text-muted-foreground' : 'text-foreground', PANEL_TITLE_CLASS), children: trigger.title })), subtitle && (_jsx("span", { className: cn('text-foreground min-w-0 truncate font-mono text-xs', onSubtitleClick &&
|
|
123
126
|
'hover:text-foreground cursor-pointer underline-offset-2 hover:underline'), role: onSubtitleClick ? 'button' : undefined, tabIndex: onSubtitleClick ? 0 : undefined, title: subtitle, onKeyDown: onSubtitleClick
|
|
124
127
|
? (e) => {
|
|
125
128
|
if (e.key !== 'Enter' && e.key !== ' ')
|
|
@@ -19,14 +19,11 @@ import { isTriggerTitle } from './infrastructure-parts.js';
|
|
|
19
19
|
* A row inverts it: the detail opens as a list of one-line summaries, and the
|
|
20
20
|
* reader expands the one they came for.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* denser, plainer thing that rotates its chevron in CSS. Same vocabulary, not
|
|
28
|
-
* the same component. No rail, no connector, no per-row header: the gap between
|
|
29
|
-
* rows is the whole rhythm.
|
|
22
|
+
* Each call is its own card (`bg-popover rounded-md border`), and the list
|
|
23
|
+
* spaces the cards apart (`ToolParts`, `gap-2`). The caret points down once a
|
|
24
|
+
* card is open, and the body opens under one hairline inside the card. The
|
|
25
|
+
* verb ("Ran command") is meta ink; the value it acted on (the command, the
|
|
26
|
+
* path, the query) is the bright text.
|
|
30
27
|
*
|
|
31
28
|
* Interaction is gated on having a body — a childless call has nothing to
|
|
32
29
|
* disclose, so it gets no chevron, no `role="button"`, and no cursor change
|
|
@@ -40,17 +37,20 @@ function PanelToolRow({ icon, trigger, children, running, badge, outcome, onSubt
|
|
|
40
37
|
// call leads with the verdict on both surfaces or the two disagree about what
|
|
41
38
|
// happened. See {@link ToolOutcomeIcon}.
|
|
42
39
|
const leading = outcome === 'ok' ? icon : _jsx(ToolOutcomeIcon, { outcome: outcome });
|
|
43
|
-
const row = (_jsxs("div", { className: cn(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
const row = (_jsxs("div", { className: cn(
|
|
41
|
+
// `items-start` + one-line slots (`h-[1lh]`): every glyph sits on the
|
|
42
|
+
// first line, so a two-line row (an agent and its task) keeps its
|
|
43
|
+
// icon, state and caret beside the name, not between the lines.
|
|
44
|
+
'flex min-h-10 w-full items-start gap-2.5 px-3 py-2.5 text-left text-sm', hasBody && 'transition-colors duration-(--duration-fast)', hasBody && !locked && 'hover:bg-hover cursor-pointer'), children: [leading && (_jsx("span", { className: "text-muted-foreground flex h-[1lh] w-4 shrink-0 items-center justify-center [&>svg]:size-4", children: leading })), isTriggerTitle(trigger) ? (_jsx(PanelRowTitle, { trigger: trigger, running: running, onSubtitleClick: onSubtitleClick })) : (
|
|
45
|
+
// `overflow-hidden` CLIPS an over-long node at the badge rather than
|
|
46
|
+
// pushing the chevron off the card; the row is one line.
|
|
47
|
+
// A row, not a block: a node trigger is flex children (a lead word, an
|
|
48
|
+
// agent chip, a subtitle), and a block stacked them one per line.
|
|
49
|
+
_jsx("div", { className: "[&>span:first-child>svg]:text-muted-foreground text-foreground flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-sm font-medium whitespace-nowrap [&>span:first-child>svg]:size-4", children: trigger })), badge && (_jsx("span", { className: "text-muted-foreground flex h-[1lh] shrink-0 items-center font-mono text-xs whitespace-nowrap tabular-nums", children: badge })), action && _jsx("span", { className: "flex h-[1lh] shrink-0 items-center", children: action }), hasBody && (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center", children: _jsx(CaretRightIcon, { "aria-hidden": true,
|
|
50
|
+
// CSS, not `motion` — the rotation is a 150ms state change on one
|
|
51
|
+
// property, and every row on the pane would otherwise carry a
|
|
52
|
+
// motion component. `motion-reduce` snaps it instead.
|
|
53
|
+
className: cn('text-muted-foreground size-4 shrink-0 transition-transform motion-reduce:transition-none', open && 'rotate-90') }) }))] }));
|
|
54
54
|
return (_jsxs(Disclosure, { open: open, onOpenChange: onOpenChange, className: "bg-popover border-border overflow-hidden rounded-md border", children: [hasBody ? _jsx(DisclosureTrigger, { children: row }) : row, hasBody && (_jsx(DisclosureContent, { children: _jsx("div", { className: cn('border-border border-t px-3 py-3 text-sm', className), children: children }) }))] }));
|
|
55
55
|
}
|
|
56
56
|
// Inline row that acts as a plain button (fires `onClick`, no disclosure).
|
|
@@ -5,16 +5,17 @@ import { STATUS_TEXT } from '../../primitives/status.js';
|
|
|
5
5
|
import { QuestionPrompt } from '../prompts/question-prompt.js';
|
|
6
6
|
import { SessionConnectCard } from '../prompts/session-connect-card.js';
|
|
7
7
|
import { GenericTool } from './generic-tool.js';
|
|
8
|
-
import { BasicTool, BoundActivateContext, partOutcome, StalePendingContext, ToolActivateContext, ToolDurationContext, ToolNavigationContext, ToolOutcomeContext, ToolRunningContext, ToolSurfaceContext, TurnLiveContext, isUnpresentedFailure, } from './shared/infrastructure.js';
|
|
8
|
+
import { BasicTool, BoundActivateContext, partOutcome, StalePendingContext, ToolActivateContext, ToolDurationContext, ToolStartedAtContext, ToolNavigationContext, ToolOutcomeContext, ToolRunningContext, ToolSurfaceContext, TurnLiveContext, isUnpresentedFailure, } from './shared/infrastructure.js';
|
|
9
9
|
import { ToolRegistry } from './shared/registry.js';
|
|
10
10
|
import { ToolError } from './tool-error.js';
|
|
11
|
+
import { parseErrorContent } from './shared/error-and-connector.js';
|
|
11
12
|
import { replyToInlinePermission } from './inline-permission-reply.js';
|
|
12
13
|
import { errorToast } from '../../primitives/toast.js';
|
|
13
14
|
import { cn } from '../../lib/utils.js';
|
|
14
|
-
import { partError, partMetadata, partStreamingInput } from './shared/infrastructure-parts.js';
|
|
15
|
+
import { firstMeaningfulLine, partError, partMetadata, partStreamingInput } from './shared/infrastructure-parts.js';
|
|
15
16
|
import { kortixCardTool, parseKortixToolResult } from './tools/kortix-tool-card.js';
|
|
16
17
|
import { isWorkflowTool, parseWorkflowRun } from './tools/workflow-run.js';
|
|
17
|
-
import { PERMISSION_LABELS,
|
|
18
|
+
import { PERMISSION_LABELS, shouldShowToolPart, } from '../../internal/session-types/index.js';
|
|
18
19
|
import { sessionLogCallStatus, sessionLogOpenCall, toolCallConnectorSignIns, toolKind, } from '@kortix/sdk';
|
|
19
20
|
import { useTranslations } from '../../i18n/index.js';
|
|
20
21
|
import { memo, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
@@ -42,6 +43,7 @@ function PermissionPromptInline({ permission, onReply }) {
|
|
|
42
43
|
}
|
|
43
44
|
function ToolPartRendererImpl({ call: given, sessionId, permission, question, onPermissionReply, onQuestionReply, onQuestionReject, defaultOpen, disableNavigation = false, }) {
|
|
44
45
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
46
|
+
const tAgent = useTranslations('tools.agent');
|
|
45
47
|
// One open block per call object (`sessionLogOpenCall` caches it), so the memos
|
|
46
48
|
// below and the renderers' own memos hold while the call is unchanged.
|
|
47
49
|
const call = sessionLogOpenCall(given);
|
|
@@ -88,11 +90,11 @@ function ToolPartRendererImpl({ call: given, sessionId, permission, question, on
|
|
|
88
90
|
// below left the child thread unopenable from the session UI, which is
|
|
89
91
|
// exactly what a failed subagent looked like to a reader (KRTX-1746).
|
|
90
92
|
// TaskTool draws `state.error` itself, so the failure reason stays on the
|
|
91
|
-
// row too.
|
|
92
|
-
//
|
|
93
|
-
//
|
|
93
|
+
// row too. A call that failed before any child existed takes the same route:
|
|
94
|
+
// the agent row names the agent it tried to start (`market-scout`) and says
|
|
95
|
+
// why, where the generic card said only "Agent failed".
|
|
94
96
|
const errorStr = partError(call);
|
|
95
|
-
const childBearingTaskError = errorStr !== undefined && toolKind(call.name) === 'task'
|
|
97
|
+
const childBearingTaskError = errorStr !== undefined && toolKind(call.name) === 'task';
|
|
96
98
|
// A failed codemode script keeps its partial output and the calls it made before
|
|
97
99
|
// the failure: its own row draws them, with the error. The image card draws its
|
|
98
100
|
// failure (with the Connect ChatGPT action) and a stop in place of the image.
|
|
@@ -123,7 +125,11 @@ function ToolPartRendererImpl({ call: given, sessionId, permission, question, on
|
|
|
123
125
|
// showing it.
|
|
124
126
|
return (_jsx(BoundActivateContext.Provider, { value: boundActivate, children: _jsx(ToolOutcomeContext.Provider, { value: outcome, children: _jsx(ToolDurationContext.Provider, { value: toolDurationMs, children: _jsx(BasicTool, { trigger: {
|
|
125
127
|
title: display,
|
|
126
|
-
|
|
128
|
+
// "failed · The project policy denies this workflow call.": the
|
|
129
|
+
// reason is the one thing the reader opens the row for.
|
|
130
|
+
subtitle: POLICY_DENIED.test(errorStr.trim())
|
|
131
|
+
? tAgent('policyBlocked')
|
|
132
|
+
: [tI18nComplete.raw('text5d28a90f4498'), errorReason(errorStr)].filter(Boolean).join(' · '),
|
|
127
133
|
args: server ? [server] : undefined,
|
|
128
134
|
}, badge: "error", defaultOpen: defaultOpen, forceOpen: !!permission || !!question, locked: !!permission || !!question, children: _jsx(ToolError, { error: errorStr, toolName: call.name }) }) }) }) }));
|
|
129
135
|
}
|
|
@@ -150,7 +156,7 @@ function ToolPartRendererImpl({ call: given, sessionId, permission, question, on
|
|
|
150
156
|
// whole class of call permanently closed and unopenable on the panel — the
|
|
151
157
|
// one surface where a single call IS the view.
|
|
152
158
|
_jsx(GenericTool, { call: call, defaultOpen: defaultOpen, forceOpen: forceOpen, locked: isLocked }));
|
|
153
|
-
return (_jsx(ToolNavigationContext.Provider, { value: !disableNavigation, children: _jsx(ToolRunningContext.Provider, { value: isRunning, children: _jsx(ToolOutcomeContext.Provider, { value: outcome, children: _jsx(ToolDurationContext.Provider, { value: toolDurationMs, children: _jsx(StalePendingContext.Provider, { value: isStalePending, children: _jsx(BoundActivateContext.Provider, { value: boundActivate, children: _jsxs("div", { className: cn('relative', fillsPanel && 'h-full'), children: [toolElement, signIns.length > 0 && _jsx(SessionConnectCard, { calls: signIns, className: "mt-1.5" }), permission && onPermissionReply && (_jsx("div", { className: "mt-1.5", children: _jsx(PermissionPromptInline, { permission: permission, onReply: onPermissionReply }) })), question && onQuestionReply && onQuestionReject && (_jsx("div", { className: "mt-1.5", children: _jsx(QuestionPrompt, { request: question, onReply: onQuestionReply, onReject: onQuestionReject }) }))] }) }) }) }) }) }) }));
|
|
159
|
+
return (_jsx(ToolNavigationContext.Provider, { value: !disableNavigation, children: _jsx(ToolRunningContext.Provider, { value: isRunning, children: _jsx(ToolOutcomeContext.Provider, { value: outcome, children: _jsx(ToolDurationContext.Provider, { value: toolDurationMs, children: _jsx(ToolStartedAtContext.Provider, { value: call.started_at, children: _jsx(StalePendingContext.Provider, { value: isStalePending, children: _jsx(BoundActivateContext.Provider, { value: boundActivate, children: _jsxs("div", { className: cn('relative', fillsPanel && 'h-full'), children: [toolElement, signIns.length > 0 && _jsx(SessionConnectCard, { calls: signIns, className: "mt-1.5" }), permission && onPermissionReply && (_jsx("div", { className: "mt-1.5", children: _jsx(PermissionPromptInline, { permission: permission, onReply: onPermissionReply }) })), question && onQuestionReply && onQuestionReject && (_jsx("div", { className: "mt-1.5", children: _jsx(QuestionPrompt, { request: question, onReply: onQuestionReply, onReject: onQuestionReject }) }))] }) }) }) }) }) }) }) }));
|
|
154
160
|
}
|
|
155
161
|
/**
|
|
156
162
|
* The tools whose rows are an agent's work: they open in place, never in the side panel.
|
|
@@ -186,3 +192,11 @@ function ToolPartRendererGuard(props) {
|
|
|
186
192
|
}
|
|
187
193
|
export const ToolPartRenderer = memo(ToolPartRendererGuard);
|
|
188
194
|
ToolPartRenderer.displayName = 'ToolPartRenderer';
|
|
195
|
+
/** The runtime's policy refusal (`decide` in pi `runtime.ts`): a block, not a failure. */
|
|
196
|
+
const POLICY_DENIED = /^The project policy denies this [\w./-]+ call\.?$/;
|
|
197
|
+
/** One short line that says why a call failed: a JSON or traceback error reads as its summary. */
|
|
198
|
+
function errorReason(error) {
|
|
199
|
+
const { summary } = parseErrorContent(error);
|
|
200
|
+
const line = firstMeaningfulLine(summary || error, 140);
|
|
201
|
+
return /^[[{]$/.test(line) ? '' : line;
|
|
202
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { HighlightedCode } from '../../../markdown/code/index.js';
|
|
4
4
|
import { TextShimmer } from '../../../primitives/text-shimmer.js';
|
|
5
|
-
import { BasicTool, partInput, partMetadata, partOutput, partStatus, partStreamingInput, StructuredOutput, RecoveredCallsContext, ToolRunningContext, useToolCardFrame, useToolCardPad, useToolIndent, useToolOpen, partRawOutput, } from '../shared/infrastructure.js';
|
|
5
|
+
import { BasicTool, partInput, partMetadata, partOutput, partStatus, partStreamingInput, StructuredOutput, RecoveredCallsContext, ToolRunningContext, ToolSurfaceContext, useToolCardFrame, useToolCardPad, useToolIndent, useToolOpen, partRawOutput, } from '../shared/infrastructure.js';
|
|
6
6
|
import { GenericTool } from '../generic-tool.js';
|
|
7
7
|
import { ToolRegistry } from '../shared/registry.js';
|
|
8
8
|
import { cn } from '../../../lib/utils.js';
|
|
@@ -107,6 +107,7 @@ function CommandBlock({ command, output, richOutput, exitCode, settled, }) {
|
|
|
107
107
|
function BashTrigger({ title, failed, command, commandPreview, extraLines, live, }) {
|
|
108
108
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
109
109
|
const open = useToolOpen();
|
|
110
|
+
const valueFirst = useContext(ToolSurfaceContext) === 'panel' && !open;
|
|
110
111
|
if (live) {
|
|
111
112
|
return (_jsx("div", { className: "flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden", children: open ? (
|
|
112
113
|
// The shimmer moves to the label: mid-flight the row still has to
|
|
@@ -116,7 +117,7 @@ function BashTrigger({ title, failed, command, commandPreview, extraLines, live,
|
|
|
116
117
|
}
|
|
117
118
|
return (_jsx("div", { className: "flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden", children: _jsxs("span", { className: "flex min-w-0 shrink-0 items-center gap-2 text-xs",
|
|
118
119
|
// Redundant once the card spells the command out below.
|
|
119
|
-
title: open ? undefined : command, children: [_jsx("span", { className:
|
|
120
|
+
title: open ? undefined : command, children: [_jsx("span", { className: cn('min-w-0 truncate', valueFirst ? 'text-muted-foreground' : 'text-foreground'), children: title }), !open && (_jsxs(_Fragment, { children: [_jsx("span", { className: cn('min-w-0 truncate font-mono', valueFirst ? 'text-foreground' : 'text-muted-foreground'), children: commandPreview }), extraLines > 0 && (_jsxs("span", { className: "text-muted-foreground shrink-0 tabular-nums", children: ["+", extraLines] }))] }))] }) }));
|
|
120
121
|
}
|
|
121
122
|
export function BashTool({ call, defaultOpen, forceOpen, locked }) {
|
|
122
123
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
@@ -18,4 +18,19 @@ export interface ScriptCall {
|
|
|
18
18
|
export declare function scriptCalls(metadata: Record<string, unknown>): ScriptCall[];
|
|
19
19
|
/** The script's result without pi's `Script completed|failed`, `Wall time` and `Output:` header lines. */
|
|
20
20
|
export declare function scriptResult(text: string): string;
|
|
21
|
+
/** One Kortix tool result a script printed: its card's title line and its rows. */
|
|
22
|
+
export interface ScriptCard {
|
|
23
|
+
title: string;
|
|
24
|
+
rows: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A script that returns Kortix tool results (`text(await tools.task_stop(…))`)
|
|
28
|
+
* prints them as escaped JSON. Read each one as its card: the title ("faq-writer
|
|
29
|
+
* had already ended") and every row under it, so a list keeps its entries.
|
|
30
|
+
* Null when the output is anything else, or when a card carries a link or a
|
|
31
|
+
* change the summary would drop.
|
|
32
|
+
*/
|
|
33
|
+
export declare function scriptCards(result: string): ScriptCard[] | null;
|
|
34
|
+
/** The cards as plain text, for the copy button. */
|
|
35
|
+
export declare function scriptCardsText(cards: ScriptCard[]): string;
|
|
21
36
|
export declare function CodemodeTool({ call, defaultOpen, forceOpen, locked }: ToolProps): import("react").JSX.Element;
|
|
@@ -8,7 +8,7 @@ import { BasicTool, partError, partInput, partMetadata, partOutput, partStatus,
|
|
|
8
8
|
import { ToolRegistry } from '../shared/registry.js';
|
|
9
9
|
import { useTranslations } from '../../../i18n/index.js';
|
|
10
10
|
import { cn } from '../../../lib/utils.js';
|
|
11
|
-
import { getToolPrimaryArg } from '@kortix/sdk';
|
|
11
|
+
import { getToolPrimaryArg, parseKortixToolResult } from '@kortix/sdk';
|
|
12
12
|
import { CheckIcon, CodeIcon, MinusIcon, ProhibitIcon, WarningIcon } from '@phosphor-icons/react';
|
|
13
13
|
import { useContext } from 'react';
|
|
14
14
|
const STATUS = {
|
|
@@ -59,6 +59,57 @@ export function scriptCalls(metadata) {
|
|
|
59
59
|
export function scriptResult(text) {
|
|
60
60
|
return text.replace(/^Script (?:completed|failed)\n(?:Wall time [^\n]*\n)?(?:Output:\n)?/, '').trim();
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* A script that returns Kortix tool results (`text(await tools.task_stop(…))`)
|
|
64
|
+
* prints them as escaped JSON. Read each one as its card: the title ("faq-writer
|
|
65
|
+
* had already ended") and every row under it, so a list keeps its entries.
|
|
66
|
+
* Null when the output is anything else, or when a card carries a link or a
|
|
67
|
+
* change the summary would drop.
|
|
68
|
+
*/
|
|
69
|
+
export function scriptCards(result) {
|
|
70
|
+
let value;
|
|
71
|
+
try {
|
|
72
|
+
value = JSON.parse(result);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const items = Array.isArray(value) ? value : [value];
|
|
78
|
+
const cards = [];
|
|
79
|
+
for (const item of items) {
|
|
80
|
+
const raw = typeof item === 'string' ? item : JSON.stringify(item);
|
|
81
|
+
const parsed = parseKortixToolResult(raw);
|
|
82
|
+
if (!parsed)
|
|
83
|
+
return null;
|
|
84
|
+
const { card } = parsed;
|
|
85
|
+
// The parser caps a card's rows: a longer list keeps the original output, so no row is lost.
|
|
86
|
+
if (rawRowCount(raw) !== card.rows.length)
|
|
87
|
+
return null;
|
|
88
|
+
// A link (a sign-in, a row's session URL) or a setting change is an action or
|
|
89
|
+
// a fact the summary would drop: the original output stays.
|
|
90
|
+
if (card.links.length > 0 || card.changes.length > 0 || card.rows.some((row) => row.href))
|
|
91
|
+
return null;
|
|
92
|
+
cards.push({
|
|
93
|
+
title: card.subtitle ? `${card.title} · ${card.subtitle}` : card.title,
|
|
94
|
+
rows: card.rows.map((row) => [row.title, row.detail, row.badge].filter(Boolean).join(' · ')),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return cards.length ? cards : null;
|
|
98
|
+
}
|
|
99
|
+
/** How many rows the card had before parsing. */
|
|
100
|
+
function rawRowCount(raw) {
|
|
101
|
+
try {
|
|
102
|
+
const rows = JSON.parse(raw).card?.rows;
|
|
103
|
+
return Array.isArray(rows) ? rows.length : 0;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return -1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** The cards as plain text, for the copy button. */
|
|
110
|
+
export function scriptCardsText(cards) {
|
|
111
|
+
return cards.map((card) => [card.title, ...card.rows.map((row) => ` ${row}`)].join('\n')).join('\n');
|
|
112
|
+
}
|
|
62
113
|
function formatDuration(ms) {
|
|
63
114
|
return ms < 1000 ? `${Math.round(ms)} ms` : `${(ms / 1000).toFixed(1)} s`;
|
|
64
115
|
}
|
|
@@ -99,8 +150,9 @@ export function CodemodeTool({ call, defaultOpen, forceOpen, locked }) {
|
|
|
99
150
|
const failed = status === 'error';
|
|
100
151
|
const live = running && !failed && status !== 'completed';
|
|
101
152
|
const result = scriptResult(failed ? (partError(call) ?? '') : partOutput(call));
|
|
153
|
+
const cards = failed ? null : scriptCards(result);
|
|
102
154
|
const names = [...new Set(calls.map((c) => c.name))].join(' · ');
|
|
103
155
|
const summary = calls.length ? `${t('calls', { count: calls.length })}${names ? ` · ${names}` : ''}` : '';
|
|
104
|
-
return (_jsx(BasicTool, { icon: _jsx(CodeIcon, { className: "size-4 shrink-0" }), trigger: _jsx(ScriptTrigger, { title: live ? t('runningScript') : failed ? t('scriptFailed') : t('ranScript'), live: live, summary: summary }), defaultOpen: defaultOpen, forceOpen: forceOpen, locked: locked, children: _jsx("div", { className: cn(indent && 'mt-1.5', indent), children: _jsxs("div", { className: cn('relative overflow-hidden', frame), children: [calls.length > 0 && (_jsx("div", { className: cn(paneInset, 'border-border/60 border-b'), children: _jsx(CallList, { calls: calls }) })), code && (_jsxs("div", { className: "relative", children: [_jsx("div", { "data-scrollable": true, className: cn('max-h-64 overflow-auto', frame && 'bg-muted/40'), children: _jsx("pre", { className: cn('text-foreground font-mono text-xs leading-relaxed wrap-break-word whitespace-pre-wrap [&_code]:border-none [&_code]:bg-transparent [&_code]:p-0 [&_code]:text-xs [&_code]:leading-relaxed [&_code]:whitespace-pre-wrap [&_pre]:whitespace-pre-wrap [&_span]:border-none [&_span]:outline-none', paneInset, 'pr-11'), children: _jsx(HighlightedCode, { code: code, language: "javascript", children: code }) }) }), _jsx("div", { className: "absolute top-2 right-2", children: _jsx(CopyButton, { code: code, className: "text-muted-foreground hover:text-foreground" }) })] })), (result || status === 'completed') && (_jsxs("div", { className: "border-border/60 relative border-t", children: [_jsx("div", { "data-scrollable": true, className: "max-h-80 overflow-auto", children: _jsx("div", { className: cn('font-mono text-xs leading-relaxed wrap-break-word whitespace-pre-wrap', failed ? 'text-foreground' : 'text-muted-foreground', paneInset, 'pr-11'), children: result || t('noOutput') }) }), result && (_jsx("div", { className: "absolute top-2 right-2", children: _jsx(CopyButton, { code: result, className: "text-muted-foreground hover:text-foreground" }) }))] }))] }) }) }));
|
|
156
|
+
return (_jsx(BasicTool, { icon: _jsx(CodeIcon, { className: "size-4 shrink-0" }), trigger: _jsx(ScriptTrigger, { title: live ? t('runningScript') : failed ? t('scriptFailed') : t('ranScript'), live: live, summary: summary }), defaultOpen: defaultOpen, forceOpen: forceOpen, locked: locked, children: _jsx("div", { className: cn(indent && 'mt-1.5', indent), children: _jsxs("div", { className: cn('relative overflow-hidden', frame), children: [calls.length > 0 && (_jsx("div", { className: cn(paneInset, 'border-border/60 border-b'), children: _jsx(CallList, { calls: calls }) })), code && (_jsxs("div", { className: "relative", children: [_jsx("div", { "data-scrollable": true, className: cn('max-h-64 overflow-auto', frame && 'bg-muted/40'), children: _jsx("pre", { className: cn('text-foreground font-mono text-xs leading-relaxed wrap-break-word whitespace-pre-wrap [&_code]:border-none [&_code]:bg-transparent [&_code]:p-0 [&_code]:text-xs [&_code]:leading-relaxed [&_code]:whitespace-pre-wrap [&_pre]:whitespace-pre-wrap [&_span]:border-none [&_span]:outline-none', paneInset, 'pr-11'), children: _jsx(HighlightedCode, { code: code, language: "javascript", children: code }) }) }), _jsx("div", { className: "absolute top-2 right-2", children: _jsx(CopyButton, { code: code, className: "text-muted-foreground hover:text-foreground" }) })] })), (result || status === 'completed') && (_jsxs("div", { className: "border-border/60 relative border-t", children: [_jsx("div", { "data-scrollable": true, className: "max-h-80 overflow-auto", children: cards ? (_jsx("ul", { "data-slot": "script-card-lines", className: cn('text-foreground flex flex-col gap-2 text-sm', paneInset, 'pr-11'), children: cards.map((card, index) => (_jsxs("li", { className: "flex min-w-0 flex-col gap-0.5 wrap-break-word", children: [_jsx("span", { children: card.title }), card.rows.map((row, rowIndex) => (_jsx("span", { className: "text-muted-foreground text-xs", children: row }, rowIndex)))] }, index))) })) : (_jsx("div", { className: cn('font-mono text-xs leading-relaxed wrap-break-word whitespace-pre-wrap', failed ? 'text-foreground' : 'text-muted-foreground', paneInset, 'pr-11'), children: result || t('noOutput') })) }), result && (_jsx("div", { className: "absolute top-2 right-2", children: _jsx(CopyButton, { code: cards ? scriptCardsText(cards) : result, className: "text-muted-foreground hover:text-foreground" }) }))] }))] }) }) }));
|
|
105
157
|
}
|
|
106
158
|
ToolRegistry.register('codemode', CodemodeTool);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { ToolProps } from '../shared/types.js';
|
|
2
|
+
/** Kortix platform calls (agents, sessions, access, connectors). In the side panel they are the same flat rows as every other call. */
|
|
2
3
|
export declare function KortixActionTool(props: ToolProps): import("react").JSX.Element;
|