@kingsoftcloud/agentkit-harness-ui 0.0.18 → 0.0.20
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/package.json +2 -2
- package/src/components.mjs +1 -1
- package/src/engine-view/adapter.mjs +87 -12
- package/src/engine-view/app.mjs +2 -2
- package/src/host/session-task-events.mjs +65 -9
- package/src/host/state/native-runtime-route.mjs +3 -2
- package/src/host/state/native-status-panel.mjs +6 -0
- package/src/host/task-timeline.mjs +26 -13
- package/src/index.mjs +1 -1
- package/src/project.mjs +2 -2
- package/src/protocol.mjs +7 -1
- package/src/react-binding.mjs +121 -1
- package/src/reducer.mjs +39 -1
- package/src/renderers.mjs +89 -49
- package/src/styles.mjs +46 -5
- package/src/tool-error.mjs +32 -4
- package/src/view.mjs +28 -6
- package/src/work-segments.mjs +2 -2
package/src/react-binding.mjs
CHANGED
|
@@ -483,13 +483,133 @@ function ScrollEnd({ reducedMotion, renderChildren, type, props }) {
|
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
|
|
486
|
+
function WebDelivery({ path, seq, resolve, zh, application = false }) {
|
|
487
|
+
const [preview, setPreview] = useState(null);
|
|
488
|
+
const [pending, setPending] = useState(false);
|
|
489
|
+
const [failed, setFailed] = useState(false);
|
|
490
|
+
const lifetime = useRef(null);
|
|
491
|
+
useEffect(() => {
|
|
492
|
+
const controller = new AbortController();
|
|
493
|
+
lifetime.current = controller;
|
|
494
|
+
void resolve({ path, seq, application }, controller.signal).then(delivery => {
|
|
495
|
+
if (!controller.signal.aborted) setPreview(delivery);
|
|
496
|
+
}).catch(() => {});
|
|
497
|
+
return () => controller.abort();
|
|
498
|
+
}, [path, seq, resolve, application]);
|
|
499
|
+
if (!preview?.href) return null;
|
|
500
|
+
const filename = application ? (zh ? '运行中的应用' : 'Running application') : path.split('/').at(-1);
|
|
501
|
+
const openLabel = zh ? `打开 ${filename}` : `Open ${filename}`;
|
|
502
|
+
const openSidebar = async () => {
|
|
503
|
+
const signal = lifetime.current.signal;
|
|
504
|
+
setFailed(false);
|
|
505
|
+
setPending(true);
|
|
506
|
+
try { await preview.openInSidebar(signal); }
|
|
507
|
+
catch { if (!signal.aborted) setFailed(true); }
|
|
508
|
+
finally { if (!signal.aborted) setPending(false); }
|
|
509
|
+
};
|
|
510
|
+
const newTab = (label, ariaLabel) => createElement('a', { href: preview.href, target: '_blank', rel: 'noopener noreferrer',
|
|
511
|
+
'aria-label': ariaLabel }, label);
|
|
512
|
+
return createElement('div', { className: 'harness-delivery', 'data-testid': 'web-delivery' },
|
|
513
|
+
createElement('span', { className: 'harness-delivery-icon' },
|
|
514
|
+
createElement('svg', { viewBox: '0 0 24 24', width: 20, height: 20, fill: 'none', stroke: 'currentColor',
|
|
515
|
+
strokeWidth: 1.5, 'aria-hidden': true },
|
|
516
|
+
createElement('circle', { cx: 12, cy: 12, r: 9 }), createElement('ellipse', { cx: 12, cy: 12, rx: 4, ry: 9 }),
|
|
517
|
+
createElement('path', { d: 'M3 12h18' }))),
|
|
518
|
+
createElement('span', { className: 'harness-delivery-name' },
|
|
519
|
+
createElement('strong', { title: path }, filename),
|
|
520
|
+
createElement('small', null, application ? path : zh ? '网站 · HTML' : 'Website · HTML')),
|
|
521
|
+
preview.openInSidebar ? createElement('div', { className: 'harness-delivery-actions' },
|
|
522
|
+
createElement('button', { type: 'button', disabled: pending, onClick: openSidebar, 'aria-label': openLabel },
|
|
523
|
+
pending ? (zh ? '正在打开…' : 'Opening…') : (zh ? '打开' : 'Open')),
|
|
524
|
+
createElement('details', { className: 'harness-delivery-menu' },
|
|
525
|
+
createElement('summary', { 'aria-label': zh ? '更多打开方式' : 'More ways to open' },
|
|
526
|
+
createElement('svg', { width: 14, height: 14, viewBox: '0 0 24 24', 'aria-hidden': true, fill: 'none', stroke: 'currentColor' },
|
|
527
|
+
createElement('path', { d: 'm6 9 6 6 6-6', strokeWidth: 2 }))),
|
|
528
|
+
newTab(zh ? '在新标签页打开' : 'Open in a new tab')),
|
|
529
|
+
failed ? createElement('span', { role: 'status' }, zh ? '无法打开侧栏预览' : 'Could not open the sidebar preview') : null)
|
|
530
|
+
: newTab(zh ? '打开' : 'Open', openLabel));
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function DeliveryEvidence({ seq, load, openFile, resolveWebDelivery, deliveries, zh }) {
|
|
534
|
+
const [evidence, setEvidence] = useState(null);
|
|
535
|
+
useEffect(() => {
|
|
536
|
+
const controller = new AbortController();
|
|
537
|
+
if (!load || seq === undefined) return;
|
|
538
|
+
void load(seq, controller.signal).then(value => {
|
|
539
|
+
if (!controller.signal.aborted) setEvidence(value);
|
|
540
|
+
}).catch(() => {});
|
|
541
|
+
return () => controller.abort();
|
|
542
|
+
}, [seq, load]);
|
|
543
|
+
const { files = [], screenshots = [], truncated, application } = evidence ?? {};
|
|
544
|
+
const counts = file => Number.isSafeInteger(file.added) && file.added >= 0
|
|
545
|
+
&& Number.isSafeInteger(file.removed) && file.removed >= 0;
|
|
546
|
+
const delta = (added, removed) => createElement('span', { className: 'harness-delivery-delta' },
|
|
547
|
+
createElement('span', null, `+${added}`), createElement('span', null, `−${removed}`));
|
|
548
|
+
const total = files.length && !truncated && files.every(counts)
|
|
549
|
+
? delta(files.reduce((sum, file) => sum + file.added, 0), files.reduce((sum, file) => sum + file.removed, 0)) : null;
|
|
550
|
+
const label = zh ? `${files.length}${truncated ? '+' : ''} 个文件已更改`
|
|
551
|
+
: `${files.length}${truncated ? '+' : ''} ${files.length === 1 ? 'file' : 'files'} changed`;
|
|
552
|
+
return createElement(React.Fragment, null,
|
|
553
|
+
...(resolveWebDelivery ? [
|
|
554
|
+
...(application ? [{ path: application.path, seq, application: true }] : []),
|
|
555
|
+
...(deliveries ?? []).filter(delivery => delivery.path !== application?.path),
|
|
556
|
+
].map(delivery => createElement(WebDelivery, { key: delivery.path, ...delivery, resolve: resolveWebDelivery, zh })) : []),
|
|
557
|
+
files.length ? createElement('details', { className: 'harness-delivery-changes', 'data-testid': 'delivery-changes' },
|
|
558
|
+
createElement('summary', null, label, total),
|
|
559
|
+
createElement('ul', null, ...files.map(file => createElement('li', { key: file.path },
|
|
560
|
+
file.deleted || !openFile ? createElement('span', null, file.path)
|
|
561
|
+
: createElement('button', { type: 'button', onClick: () => openFile({ path: file.path, kind: 'file' }) }, file.path),
|
|
562
|
+
counts(file) ? delta(file.added, file.removed) : null)))) : null,
|
|
563
|
+
...screenshots.map(({ path, href }) => createElement('a', { key: path, className: 'harness-delivery-image',
|
|
564
|
+
'data-testid': 'delivery-screenshot', href, target: '_blank', rel: 'noopener noreferrer' },
|
|
565
|
+
createElement('img', { src: href, alt: path.split('/').at(-1), loading: 'lazy' }))));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function HarnessTurn({ state, reply, onCopy, onBranch, assistantActions, containerProps, deliveries, resolveWebDelivery,
|
|
569
|
+
deliverySeq, loadDeliveryEvidence, locale = 'zh-CN', ...timeline }) {
|
|
570
|
+
const [copyState, setCopyState] = useState(null);
|
|
571
|
+
const answer = state.items.find(item => item.id === state.finalAnswerId);
|
|
572
|
+
const copy = async () => {
|
|
573
|
+
try {
|
|
574
|
+
const text = answer.sourceMessageId ? state.items.filter(item => item.kind === 'text'
|
|
575
|
+
&& item.sourceMessageId === answer.sourceMessageId).map(item => item.text).join('\n\n') : answer.text;
|
|
576
|
+
await (onCopy ? onCopy(text) : navigator.clipboard.writeText(text));
|
|
577
|
+
setCopyState('copied');
|
|
578
|
+
} catch { setCopyState('failed'); }
|
|
579
|
+
};
|
|
580
|
+
const zh = locale.startsWith('zh');
|
|
581
|
+
const copyLabel = copyState === 'copied' ? (zh ? '已复制' : 'Copied') : (zh ? '复制回复' : 'Copy reply');
|
|
582
|
+
const branchLabel = zh ? '从这里新建分支' : 'Branch from here';
|
|
583
|
+
const button = (label, onClick, path) => createElement('button', { type: 'button', title: label, 'aria-label': label, onClick },
|
|
584
|
+
createElement('svg', { viewBox: '0 0 24 24', width: 16, height: 16, fill: 'none', stroke: 'currentColor',
|
|
585
|
+
strokeWidth: 1.5, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true }, createElement('path', { d: path })));
|
|
586
|
+
const clock = reply?.time ?? state.taskEndedAt;
|
|
587
|
+
return createElement('article', { ...containerProps, className: 'harness-turn', 'data-testid': 'harness-turn' },
|
|
588
|
+
createElement(HarnessTimeline, { state, onCopy, locale, ...timeline }),
|
|
589
|
+
state.taskState === 'failed' && state.taskError
|
|
590
|
+
? createElement('p', { className: 'harness-turn-error', role: 'alert' }, state.taskError)
|
|
591
|
+
: state.taskState === 'paused' && state.taskReason === 'provider_unavailable' && state.taskMessage
|
|
592
|
+
? createElement('p', { className: 'harness-turn-model-pause', role: 'status' }, state.taskMessage) : null,
|
|
593
|
+
answer?.kind === 'text' && !answer.streaming && (resolveWebDelivery || loadDeliveryEvidence)
|
|
594
|
+
? createElement(DeliveryEvidence, { key: deliverySeq, seq: deliverySeq, load: loadDeliveryEvidence, deliveries,
|
|
595
|
+
openFile: timeline.onOpenFile, resolveWebDelivery, zh }) : null,
|
|
596
|
+
answer?.kind === 'text' && !answer.streaming ? createElement('div', { className: 'harness-reply-actions',
|
|
597
|
+
role: 'group', 'aria-label': zh ? '回复操作' : 'Reply actions' },
|
|
598
|
+
button(copyLabel, copy, copyState === 'copied' ? 'm5 12 4 4L19 6' : 'M8 8h11v12H8zM5 16H4V4h11v1'),
|
|
599
|
+
assistantActions,
|
|
600
|
+
reply?.branchable && onBranch ? button(branchLabel, () => onBranch(reply.seq), 'M5 19 19 5m-6 0h6v6M5 10v9h9') : null,
|
|
601
|
+
typeof clock === 'number' && Number.isFinite(clock) ? createElement('time', { dateTime: new Date(clock).toISOString() },
|
|
602
|
+
new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit', hour12: false }).format(clock)) : null,
|
|
603
|
+
copyState === 'failed' ? createElement('span', { role: 'status' }, zh ? '无法复制' : 'Unable to copy') : null) : null);
|
|
604
|
+
}
|
|
605
|
+
|
|
486
606
|
function SubagentPane({ state, loading, error, omittedRows = 0, omittedChars = 0, labels = {}, ...timeline }) {
|
|
487
607
|
return React.createElement('section', { className: 'harness-subagent-pane', 'data-testid': 'subagent-pane', 'aria-readonly': true },
|
|
488
608
|
error ? React.createElement('p', { role: 'alert' }, error) : loading ? React.createElement('p', { role: 'status' }, labels.childSyncing || 'Syncing') : null,
|
|
489
609
|
omittedRows || omittedChars ? React.createElement('p', { className: 'harness-subagent-window-notice' }, labels.childOmitted || 'Earlier rows or long fields are omitted in this observation window.') : null,
|
|
490
610
|
state ? React.createElement(HarnessTimeline, { state, labels, ...timeline }) : null);
|
|
491
611
|
}
|
|
492
|
-
return { HarnessTimeline, SubagentPane };
|
|
612
|
+
return { HarnessTimeline, HarnessTurn, SubagentPane };
|
|
493
613
|
}
|
|
494
614
|
|
|
495
615
|
export { buildViewModel, styles };
|
package/src/reducer.mjs
CHANGED
|
@@ -33,12 +33,17 @@ export function initialState() {
|
|
|
33
33
|
taskError: null,
|
|
34
34
|
taskStartedAt: null, taskEndedAt: null, finalAnswerId: null,
|
|
35
35
|
verificationRequired: null,
|
|
36
|
+
modelRequestActive: false,
|
|
37
|
+
modelRequestRetry: false,
|
|
38
|
+
modelRequestPurpose: null,
|
|
39
|
+
modelThinkingId: null,
|
|
36
40
|
contextMarkers: [],
|
|
37
41
|
subagents: new Map(),
|
|
38
42
|
items: [], // ordered TimelineItem[]
|
|
39
43
|
seen: new Set(), // event ids already applied (dedup/replay)
|
|
40
44
|
pendingThinking: new Set(), // itemIds that had thinking.start but no delta yet
|
|
41
45
|
plan: null, // PlanItem[] | null
|
|
46
|
+
planSummary: null, // null until the session has observed a checklist update
|
|
42
47
|
lastSeq: null,
|
|
43
48
|
};
|
|
44
49
|
}
|
|
@@ -84,6 +89,15 @@ function apply(state, e) {
|
|
|
84
89
|
case EventType.TaskStarted: return applyTaskStarted(state, e);
|
|
85
90
|
case EventType.TaskState: return applyTaskState(state, e);
|
|
86
91
|
case EventType.TaskFinished: return applyTaskFinished(state, e);
|
|
92
|
+
case EventType.ModelRequest:
|
|
93
|
+
if (e.active && state.taskState === TaskState.Paused && state.taskReason === 'provider_unavailable')
|
|
94
|
+
applyTaskState(state, { state: TaskState.Running, reason: null, message: null });
|
|
95
|
+
if (!e.active || state.modelThinkingId !== e.itemId) settleModelPresentation(state);
|
|
96
|
+
state.modelRequestActive = e.active;
|
|
97
|
+
state.modelRequestRetry = e.active && e.retry === true;
|
|
98
|
+
state.modelRequestPurpose = e.active ? e.purpose ?? null : null;
|
|
99
|
+
state.modelThinkingId = e.active ? e.itemId : null;
|
|
100
|
+
return;
|
|
87
101
|
case EventType.TextDelta: return applyTextDelta(state, e);
|
|
88
102
|
case EventType.TextDone: return applyTextDone(state, e);
|
|
89
103
|
case EventType.ThinkingStart: return applyThinkingStart(state, e);
|
|
@@ -141,9 +155,22 @@ function applyTaskStarted(state, e) {
|
|
|
141
155
|
state.taskEndedAt = null; state.finalAnswerId = null;
|
|
142
156
|
}
|
|
143
157
|
|
|
158
|
+
function settleModelPresentation(state) {
|
|
159
|
+
if (!state.modelThinkingId) return;
|
|
160
|
+
applyThinkingDone(state, { itemId: state.modelThinkingId });
|
|
161
|
+
state.items = state.items.filter(item => item.kind !== 'tool-preview' || item.responseId !== state.modelThinkingId);
|
|
162
|
+
}
|
|
163
|
+
|
|
144
164
|
function applyTaskState(state, e) {
|
|
145
165
|
if (!canTransition(state.taskState, e.state)) return; // ignore invalid transitions
|
|
146
166
|
state.taskState = e.state;
|
|
167
|
+
if (e.state !== TaskState.Running) {
|
|
168
|
+
settleModelPresentation(state);
|
|
169
|
+
state.modelRequestActive = false;
|
|
170
|
+
state.modelRequestRetry = false;
|
|
171
|
+
state.modelRequestPurpose = null;
|
|
172
|
+
state.modelThinkingId = null;
|
|
173
|
+
}
|
|
147
174
|
state.taskReason = e.reason;
|
|
148
175
|
state.taskMessage = e.message;
|
|
149
176
|
if (e.state === TaskState.Running || e.state === TaskState.Recovered) {
|
|
@@ -153,6 +180,11 @@ function applyTaskState(state, e) {
|
|
|
153
180
|
}
|
|
154
181
|
|
|
155
182
|
function applyTaskFinished(state, e) {
|
|
183
|
+
settleModelPresentation(state);
|
|
184
|
+
state.modelRequestActive = false;
|
|
185
|
+
state.modelRequestRetry = false;
|
|
186
|
+
state.modelRequestPurpose = null;
|
|
187
|
+
state.modelThinkingId = null;
|
|
156
188
|
state.verificationRequired = e.verificationRequired;
|
|
157
189
|
state.taskOutcome = e.outcome;
|
|
158
190
|
state.taskSummary = e.summary; // host-supplied; may be null — never invented
|
|
@@ -317,7 +349,13 @@ function settlePriorReasoning(state, event) {
|
|
|
317
349
|
}
|
|
318
350
|
|
|
319
351
|
function applyPlan(state, e) {
|
|
320
|
-
state.plan =
|
|
352
|
+
state.plan = e.items.length ? e.items : null;
|
|
353
|
+
const visibleCompleted = e.items.filter(item => item.status === "completed").length;
|
|
354
|
+
const totalCount = Number.isSafeInteger(e.totalCount) && e.totalCount >= e.items.length ? e.totalCount : e.items.length;
|
|
355
|
+
const omittedItems = totalCount - e.items.length;
|
|
356
|
+
const completedCount = Number.isSafeInteger(e.completedCount) && e.completedCount >= visibleCompleted
|
|
357
|
+
&& e.completedCount <= visibleCompleted + omittedItems ? e.completedCount : visibleCompleted;
|
|
358
|
+
state.planSummary = { totalCount, completedCount, omittedItems };
|
|
321
359
|
}
|
|
322
360
|
|
|
323
361
|
function findItemIndex(state, id) {
|
package/src/renderers.mjs
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
// renderers that mirror the ZCode DESKTOP task conversation:
|
|
5
5
|
// - execute (terminal): `$` prompt + bounded command, live output with
|
|
6
6
|
// stdout/stderr/exit/cwd, safe-ANSI plain text, copy + open-terminal actions
|
|
7
|
-
// - read:
|
|
8
|
-
// not toggleable
|
|
7
|
+
// - read/search: compact summaries with expandable file and search details
|
|
9
8
|
// - edit: file chips, +N/-N change count, inline diff with REAL line numbers
|
|
10
9
|
// from the patch hunk headers, unified + split responsive, bounded preview
|
|
11
10
|
// with a full-retrieval callback; never infers a write succeeded from input
|
|
@@ -18,12 +17,12 @@
|
|
|
18
17
|
|
|
19
18
|
import { h, terminalIcon, fileTextIcon, searchIcon, pencilIcon, wrenchIcon, chevronIcon, skillIcon, globeIcon } from "./view.mjs";
|
|
20
19
|
import { ToolStatus } from "./protocol.mjs";
|
|
21
|
-
import { toolTitle, toolDetailLines, toolInputPreview,
|
|
20
|
+
import { toolTitle, toolDetailLines, toolInputPreview, redactError } from "./tool-detail.mjs";
|
|
22
21
|
import { truncateText, latestNonEmptyLine, redactValue, boundedDetailLines } from "./summary.mjs";
|
|
23
22
|
import { parseDiffHunks, countChangeStat, inferOperationKind } from "./diff.mjs";
|
|
24
23
|
import { extractCommand, extractOutput } from "./terminal.mjs";
|
|
25
24
|
import { toolIdentity, localizedToolTitle } from './tool-identity.mjs';
|
|
26
|
-
import { toolErrorSummary } from './tool-error.mjs';
|
|
25
|
+
import { commandPolicyBlockReason, isCommandPolicyBlock, toolErrorSummary } from './tool-error.mjs';
|
|
27
26
|
|
|
28
27
|
/** Tool-name → renderer classification. Host tool names vary across runtimes. */
|
|
29
28
|
|
|
@@ -84,17 +83,15 @@ const toolIsLive = item => item.kind === 'tool-preview' ? item.streaming === tru
|
|
|
84
83
|
* own title span), the primary/secondary content, the status word, and a
|
|
85
84
|
* chevron that rotates when the body is open.
|
|
86
85
|
*
|
|
87
|
-
*
|
|
88
|
-
* search that cannot expand still surfaces its redacted error inline in the
|
|
89
|
-
* summary (role=alert), so the failure is never hidden behind a missing toggle.
|
|
86
|
+
* Policy-blocked commands put the reason inside the disclosure.
|
|
90
87
|
*/
|
|
91
|
-
function toolShell(item, opts, { icon, summary, body, canToggle = true, defaultOpen, actions = [], summaryAction }) {
|
|
88
|
+
function toolShell(item, opts, { icon, summary, body, canToggle = true, defaultOpen, actions = [], summaryAction, commandBlocked = false }) {
|
|
92
89
|
const status = item.status;
|
|
93
90
|
const provisional = item.kind === 'tool-preview';
|
|
94
91
|
const streaming = toolIsLive(item);
|
|
95
92
|
if (provisional) { canToggle = false; summaryAction = undefined; actions = []; }
|
|
96
93
|
const error = status === ToolStatus.Failed && item.error ? redactError(item.error) : null;
|
|
97
|
-
// Plain static
|
|
94
|
+
// Plain static failures are already fully visible inline. Structured
|
|
98
95
|
// failures retain a disclosure for the original bounded diagnostic evidence.
|
|
99
96
|
if (error && !canToggle && toolErrorSummary(item.error, opts) !== error) { canToggle = true; defaultOpen = false; }
|
|
100
97
|
const open = resolveOpen(item, opts, defaultOpen == null ? streaming : defaultOpen, canToggle);
|
|
@@ -105,7 +102,7 @@ function toolShell(item, opts, { icon, summary, body, canToggle = true, defaultO
|
|
|
105
102
|
const errorSummary = error ? toolErrorSummary(item.error, opts) : null;
|
|
106
103
|
// Non-toggleable tools have no body to expand into, so their error must live
|
|
107
104
|
// in the summary; toggleable tools show it inline only when collapsed.
|
|
108
|
-
const showInlineError = error && (canToggle ? !open : true);
|
|
105
|
+
const showInlineError = error && !commandBlocked && (canToggle ? !open : true);
|
|
109
106
|
if (showInlineError) summaryKids.push(h("span", {
|
|
110
107
|
className: "harness-tool-error harness-tool-error-inline",
|
|
111
108
|
role: "alert",
|
|
@@ -115,16 +112,18 @@ function toolShell(item, opts, { icon, summary, body, canToggle = true, defaultO
|
|
|
115
112
|
className: `harness-tool-status harness-tool-status-${status}`,
|
|
116
113
|
"data-testid": "tool-status",
|
|
117
114
|
"data-status": status,
|
|
118
|
-
}, statusLabel(status, opts)));
|
|
115
|
+
}, commandBlocked ? (String(opts.locale).startsWith("zh") ? "未执行" : "Not executed") : statusLabel(status, opts)));
|
|
119
116
|
for (const action of actions) {
|
|
120
117
|
if (action) summaryKids.push(action);
|
|
121
118
|
}
|
|
122
119
|
if (canToggle) summaryKids.push(chevronIcon("harness-tool-chevron"));
|
|
123
120
|
const visibleBody = open && canToggle ? (typeof body === 'function' ? body() : body) : [];
|
|
124
121
|
const bodyKids = Array.isArray(visibleBody) ? visibleBody : [visibleBody];
|
|
125
|
-
|
|
122
|
+
const blockedReason = commandBlocked ? commandPolicyBlockReason(item.error) : null;
|
|
123
|
+
if (error && open && canToggle) bodyKids.unshift(h("div", {
|
|
126
124
|
className: "harness-tool-error", role: "alert", "data-testid": "tool-error",
|
|
127
|
-
},
|
|
125
|
+
}, commandBlocked ? [errorSummary, blockedReason ? h("div", {}, blockedReason) : null]
|
|
126
|
+
: errorSummary === error ? error : [errorSummary, h("div", {}, error)]));
|
|
128
127
|
const detailsProps = canToggle ? {
|
|
129
128
|
open, className: "harness-tool-details", "data-testid": "tool-details",
|
|
130
129
|
"data-call-id": item.callId, "aria-expanded": open,
|
|
@@ -201,6 +200,7 @@ function executeRenderer(item, opts) {
|
|
|
201
200
|
// One extractor handles both normalized event displays (fullText) and
|
|
202
201
|
// Host observation snapshots (stdout/stderr). An empty alias must not hide
|
|
203
202
|
// real streaming bytes supplied through the other supported representation.
|
|
203
|
+
const commandBlocked = item.status === ToolStatus.Failed && isCommandPolicyBlock(item.error);
|
|
204
204
|
const stdout = out.stdout;
|
|
205
205
|
const hasOutput = Boolean(stdout || out.stderr || out.exit != null);
|
|
206
206
|
const title = localizedToolTitle(item.name, toolTitle(item.name, item.input) || item.name, opts.locale);
|
|
@@ -217,7 +217,7 @@ function executeRenderer(item, opts) {
|
|
|
217
217
|
}, truncateText(command, { maxLines: 1, maxChars: 80 })));
|
|
218
218
|
|
|
219
219
|
const body = [commandBlock(item.callId, command, cwd, opts),
|
|
220
|
-
outputBlock(item.callId, { stdout, stderr: out.stderr, exit: out.exit, cwd, running, hasOutput }, opts)];
|
|
220
|
+
commandBlocked ? null : outputBlock(item.callId, { stdout, stderr: out.stderr, exit: out.exit, cwd, running, hasOutput }, opts)];
|
|
221
221
|
// A host progress message (e.g. "running 4 tests") is shown as a live status
|
|
222
222
|
// line under the command, above the output. The reducer never invents it.
|
|
223
223
|
if (item.progress && item.status !== ToolStatus.Completed) {
|
|
@@ -228,7 +228,7 @@ function executeRenderer(item, opts) {
|
|
|
228
228
|
}, item.progress));
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
return toolShell(item, opts, { icon: terminalIcon("harness-tool-kind-icon"), summary, body, canToggle: true, defaultOpen: false });
|
|
231
|
+
return toolShell(item, opts, { icon: terminalIcon("harness-tool-kind-icon"), summary, body, canToggle: true, defaultOpen: false, commandBlocked });
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
function commandBlock(callId, command, cwd, opts) {
|
|
@@ -301,12 +301,6 @@ function copyButton(opts, text, testid) {
|
|
|
301
301
|
|
|
302
302
|
// ── read / search / list ─────────────────────────────────────────────────────
|
|
303
303
|
//
|
|
304
|
-
// The desktop conversation splits "file-read" (ReadToolCallBlock: a file chip)
|
|
305
|
-
// from "search" (SearchToolCallBlock: "Find {query}" / "List {cwd}"). Both are
|
|
306
|
-
// non-toggleable one-line summaries. The path is shown once (leaf in the chip +
|
|
307
|
-
// the workspace-relative path as secondary, full path only in the chip title)
|
|
308
|
-
// rather than repeated across the title, the chip, and a third path line.
|
|
309
|
-
|
|
310
304
|
function readRenderer(item, opts) {
|
|
311
305
|
return readSubKind(item.name, item.input) === "search"
|
|
312
306
|
? searchListRenderer(item, opts)
|
|
@@ -316,15 +310,11 @@ function readRenderer(item, opts) {
|
|
|
316
310
|
function readFileRenderer(item, opts) {
|
|
317
311
|
const meta = readMeta(item);
|
|
318
312
|
const path = meta.path;
|
|
319
|
-
const fileName = leafName(path) ||
|
|
313
|
+
const fileName = leafName(path) || path;
|
|
320
314
|
const running = toolIsLive(item);
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const canOpen = Boolean(opts.onOpenFile) && meta.entryType === "file";
|
|
325
|
-
// Primary content is the file chip itself; the kind label precedes it. The
|
|
326
|
-
// path is NOT duplicated in the title — only the leaf shows in the chip and
|
|
327
|
-
// the workspace-relative path shows once as the secondary.
|
|
315
|
+
const labels = opts.labels || {};
|
|
316
|
+
const kindLabel = running ? labels.readReading || "Reading" : labels.readKind || "Read";
|
|
317
|
+
const canOpen = meta.entryType === "file" && Boolean(opts.onOpenFile);
|
|
328
318
|
const summary = [
|
|
329
319
|
h("span", {
|
|
330
320
|
className: running
|
|
@@ -332,23 +322,48 @@ function readFileRenderer(item, opts) {
|
|
|
332
322
|
: "harness-tool-title",
|
|
333
323
|
"data-testid": "tool-title",
|
|
334
324
|
}, kindLabel),
|
|
335
|
-
|
|
336
|
-
|
|
325
|
+
path ? h("span", { className: "harness-tool-secondary", "aria-hidden": "true" }, "·") : null,
|
|
326
|
+
path ? fileChip(path, fileName, canOpen, opts, "read-chip", "read-file-name",
|
|
327
|
+
{ kind: meta.entryType, callId: item.callId, showIcon: false }) : null,
|
|
328
|
+
];
|
|
329
|
+
const result = item.result;
|
|
330
|
+
const readRange = result?.line_count === 0
|
|
331
|
+
? labels.readNoLines || "No lines returned"
|
|
332
|
+
: formatReadRange(result?.read_range?.start ?? result?.start_line, result?.read_range?.end ?? result?.end_line, labels);
|
|
333
|
+
const requestedRange = formatReadRange(item.input?.start_line, item.input?.end_line, labels);
|
|
334
|
+
const rows = [
|
|
335
|
+
[labels.readPath || "Path", path, "read-file-path"],
|
|
336
|
+
readRange
|
|
337
|
+
? [labels.readLines || "Lines read", readRange, "read-line-range"]
|
|
338
|
+
: [labels.readRequestedLines || "Requested lines", requestedRange, "read-line-range"],
|
|
339
|
+
...(!readRange && !requestedRange ? [
|
|
340
|
+
[labels.readOffset || "Offset", item.input?.offset, "read-offset"],
|
|
341
|
+
[labels.readLimit || "Limit", item.input?.limit, "read-limit"],
|
|
342
|
+
] : []),
|
|
337
343
|
];
|
|
338
|
-
if (path) summary.push(h("span", {
|
|
339
|
-
className: "harness-tool-secondary harness-read-path",
|
|
340
|
-
"data-testid": "read-file-path",
|
|
341
|
-
title: path,
|
|
342
|
-
}, workspaceRelative(path, opts.workspaceRoot)));
|
|
343
|
-
// Read is a one-line chip; it does not toggle. A failed read surfaces its
|
|
344
|
-
// error inline via the shell, and an optional inspect action lets the host
|
|
345
|
-
// open the result/details (the public result-inspection action).
|
|
346
344
|
return toolShell(item, opts, {
|
|
347
345
|
icon: fileTextIcon("harness-tool-kind-icon"),
|
|
348
|
-
summary, body:
|
|
346
|
+
summary, body: () => observationDetails(rows), defaultOpen: false,
|
|
347
|
+
canToggle: Boolean(path || readRange || requestedRange || item.error || item.input?.offset != null || item.input?.limit != null),
|
|
349
348
|
});
|
|
350
349
|
}
|
|
351
350
|
|
|
351
|
+
function formatReadRange(start, end, labels) {
|
|
352
|
+
const hasStart = Number.isSafeInteger(start) && start > 0;
|
|
353
|
+
const hasEnd = Number.isSafeInteger(end) && end > 0;
|
|
354
|
+
if (hasStart && hasEnd) return start === end ? String(start) : `${start}–${end}`;
|
|
355
|
+
if (hasStart) return (labels.readFromLine || "From line {line}").replace("{line}", start);
|
|
356
|
+
if (hasEnd) return (labels.readThroughLine || "Through line {line}").replace("{line}", end);
|
|
357
|
+
return "";
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function observationDetails(rows) {
|
|
361
|
+
return h("dl", { className: "harness-tool-detail" }, rows
|
|
362
|
+
.filter(([, value]) => typeof value === "string" ? value.length > 0 : Number.isSafeInteger(value))
|
|
363
|
+
.map(([label, value, id]) => h("div", { className: "harness-tool-detail-line", key: id },
|
|
364
|
+
h("dt", {}, label), h("dd", { "data-testid": id }, String(value)))));
|
|
365
|
+
}
|
|
366
|
+
|
|
352
367
|
function searchListRenderer(item, opts) {
|
|
353
368
|
const running = toolIsLive(item);
|
|
354
369
|
const isList = isListInput(item.name, item.input);
|
|
@@ -358,10 +373,7 @@ function searchListRenderer(item, opts) {
|
|
|
358
373
|
const kindLabel = running
|
|
359
374
|
? (isList ? (labels.listSearching || "Listing") : (labels.searchSearching || "Searching"))
|
|
360
375
|
: (isList ? (labels.listKind || "List") : (labels.searchKind || "Search"));
|
|
361
|
-
const primary = isList
|
|
362
|
-
? (cwd ? truncateText(cwd, { maxLines: 1, maxChars: 60 }) : '')
|
|
363
|
-
: (query ? (labels.searchFindQuery || "Find {query}").replace("{query}", truncateText(query, { maxLines: 1, maxChars: 80 }))
|
|
364
|
-
: (labels.searchFind || "Find"));
|
|
376
|
+
const primary = truncateText(isList ? cwd : query, { maxLines: 1, maxChars: isList ? 60 : 80 });
|
|
365
377
|
const summary = [
|
|
366
378
|
h("span", {
|
|
367
379
|
className: running
|
|
@@ -369,17 +381,44 @@ function searchListRenderer(item, opts) {
|
|
|
369
381
|
: "harness-tool-title",
|
|
370
382
|
"data-testid": "tool-title",
|
|
371
383
|
}, kindLabel),
|
|
372
|
-
...(
|
|
384
|
+
...(!isList && primary ? [h("span", { className: "harness-tool-secondary", "aria-hidden": "true" }, "·")] : []),
|
|
385
|
+
...(primary ? [h("span", {
|
|
373
386
|
className: "harness-tool-primary harness-search-primary",
|
|
374
387
|
"data-testid": "search-primary",
|
|
375
388
|
}, primary)] : []),
|
|
376
389
|
];
|
|
377
390
|
return toolShell(item, opts, {
|
|
378
391
|
icon: searchIcon("harness-tool-kind-icon"),
|
|
379
|
-
summary, body:
|
|
392
|
+
summary, body: () => searchDetails(item, query, cwd, labels), defaultOpen: false,
|
|
393
|
+
canToggle: !isList && Boolean(query || cwd || item.result != null || item.error),
|
|
380
394
|
});
|
|
381
395
|
}
|
|
382
396
|
|
|
397
|
+
function searchDetails(item, query, cwd, labels) {
|
|
398
|
+
const result = item.result;
|
|
399
|
+
const nativeSearch = item.name === "search_workspace_files";
|
|
400
|
+
const scope = result?.searched_path || cwd || (nativeSearch ? "." : "");
|
|
401
|
+
const locations = Array.isArray(result?.results) ? result.results
|
|
402
|
+
.filter(hit => typeof hit?.path === "string" && hit.path && Number.isSafeInteger(hit.line) && hit.line > 0) : [];
|
|
403
|
+
const count = Number.isSafeInteger(result?.match_count) ? result.match_count : null;
|
|
404
|
+
const shown = locations.slice(0, 12);
|
|
405
|
+
const legacyResult = typeof result === "string" ? redactError(result, { maxChars: 600 }) : "";
|
|
406
|
+
return [
|
|
407
|
+
observationDetails([
|
|
408
|
+
[labels.searchQuery || "Query", truncateText(query, { maxLines: 3, maxChars: 512 }), "search-query"],
|
|
409
|
+
[labels.searchScope || "Scope", scope, "search-scope"],
|
|
410
|
+
[labels.searchGlob || "File pattern", item.input?.glob, "search-glob"],
|
|
411
|
+
[labels.searchMatches || "Matches returned", count, "search-match-count"],
|
|
412
|
+
]),
|
|
413
|
+
shown.length ? h("ul", { className: "harness-search-matches", "data-testid": "search-matches" },
|
|
414
|
+
shown.map(({ path, line }, index) => h("li", { key: index }, `${path}:${line}`))) : null,
|
|
415
|
+
(result?.locations_truncated ?? result?.truncated) === true || (count ?? locations.length) > shown.length
|
|
416
|
+
? h("div", { className: "harness-tool-secondary", "data-testid": "search-results-truncated" },
|
|
417
|
+
labels.searchResultsTruncated || "Some match locations are omitted") : null,
|
|
418
|
+
legacyResult ? h("pre", { className: "harness-search-legacy-result", "data-testid": "search-legacy-result" }, legacyResult) : null,
|
|
419
|
+
];
|
|
420
|
+
}
|
|
421
|
+
|
|
383
422
|
/** A directory listing (list_workspace_files / parsed list_files) vs a search. */
|
|
384
423
|
function isListInput(name, input) {
|
|
385
424
|
const n = String(name || "");
|
|
@@ -428,8 +467,9 @@ function searchCwd(input) {
|
|
|
428
467
|
|
|
429
468
|
function readMeta(item) {
|
|
430
469
|
const disp = item.display || {};
|
|
431
|
-
|
|
432
|
-
return { path:
|
|
470
|
+
const path = readInputPath(item.input) || (typeof item.result?.path === "string" ? item.result.path : "");
|
|
471
|
+
if (disp.kind === "file_read") return { path: disp.path || path, entryType: disp.entryType || "file" };
|
|
472
|
+
return { path, entryType: "file" };
|
|
433
473
|
}
|
|
434
474
|
|
|
435
475
|
function readInputPath(input) {
|
|
@@ -576,7 +616,7 @@ function fileChip(path, label, clickable, opts, chipTestid, nameTestid, action)
|
|
|
576
616
|
const isDir = action && action.kind === "directory" || String(path || "").endsWith("/");
|
|
577
617
|
const glyph = isDir ? searchIcon("harness-file-icon") : fileTextIcon("harness-file-icon");
|
|
578
618
|
const inner = [
|
|
579
|
-
glyph,
|
|
619
|
+
action?.showIcon === false ? null : glyph,
|
|
580
620
|
h("span", { className: "harness-file-name", "data-testid": nameTestid }, label),
|
|
581
621
|
];
|
|
582
622
|
if (clickable && opts.onOpenFile) {
|
package/src/styles.mjs
CHANGED
|
@@ -86,6 +86,7 @@ export const styles = `
|
|
|
86
86
|
user-select: none;
|
|
87
87
|
}
|
|
88
88
|
.harness-thought-summary::-webkit-details-marker, .harness-tool-summary::-webkit-details-marker { display: none; }
|
|
89
|
+
.harness-model-activity { cursor: default; }
|
|
89
90
|
/* Inline SVG icons (Lucide, ISC — see NOTICE) are sized by font-size so they
|
|
90
91
|
sit on the text baseline; stroke is currentColor so they inherit the line
|
|
91
92
|
color and dim with the muted/failure tokens. */
|
|
@@ -98,6 +99,8 @@ export const styles = `
|
|
|
98
99
|
}
|
|
99
100
|
.harness-tool-summary:hover .harness-tool-chevron,
|
|
100
101
|
.harness-thought-summary:hover .harness-thought-chevron { opacity: 1; }
|
|
102
|
+
.harness-tool-read .harness-tool-chevron { opacity: 0.65; }
|
|
103
|
+
.harness-tool-read .harness-tool-summary:is(:hover, :focus-visible) .harness-tool-chevron { opacity: 1; }
|
|
101
104
|
.harness-tool-details[open] .harness-tool-chevron,
|
|
102
105
|
.harness-thought-details[open] .harness-thought-chevron { transform: rotate(90deg); opacity: 1; }
|
|
103
106
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -132,9 +135,8 @@ export const styles = `
|
|
|
132
135
|
max-width: 50ch;
|
|
133
136
|
}
|
|
134
137
|
.harness-tool-secondary { font-size: 0.8rem; color: var(--harness-fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
|
|
135
|
-
.harness-tool-status { font-size: 0.8rem; color: var(--harness-fg-muted); text-transform: lowercase; }
|
|
138
|
+
.harness-tool-status { flex-shrink: 0; white-space: nowrap; font-size: 0.8rem; color: var(--harness-fg-muted); text-transform: lowercase; }
|
|
136
139
|
.harness-tool-status-running { color: var(--harness-running); }
|
|
137
|
-
.harness-tool-status-failed { color: var(--harness-error); }
|
|
138
140
|
.harness-tool-status-completed { display: none; }
|
|
139
141
|
.harness-tool-details-static > summary { cursor: default; list-style: none; }
|
|
140
142
|
.harness-tool-details-static > summary::-webkit-details-marker { display: none; }
|
|
@@ -149,9 +151,11 @@ export const styles = `
|
|
|
149
151
|
.harness-tool-detail-line { display: flex; gap: 6px; }
|
|
150
152
|
.harness-tool-detail-line dt { color: var(--harness-fg-muted); min-width: 8ch; }
|
|
151
153
|
.harness-tool-detail-line dd { margin: 0; word-break: break-all; }
|
|
154
|
+
.harness-search-matches { margin: 6px 0; padding-inline-start: 1.5em; font-size: 0.85rem; overflow-wrap: anywhere; }
|
|
155
|
+
.harness-search-legacy-result { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.85rem; }
|
|
152
156
|
.harness-tool-progress { color: var(--harness-running); font-size: 0.85rem; }
|
|
153
|
-
.harness-tool-error { color: var(--harness-
|
|
154
|
-
.harness-tool-error-inline {
|
|
157
|
+
.harness-tool-error { color: var(--harness-fg-muted); font-size: 0.85rem; }
|
|
158
|
+
.harness-tool-error-inline { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
155
159
|
.harness-tool-result { margin-top: 6px; }
|
|
156
160
|
.harness-tool-result > summary { cursor: pointer; color: var(--harness-fg-muted); font-size: 0.8rem; }
|
|
157
161
|
|
|
@@ -196,7 +200,6 @@ export const styles = `
|
|
|
196
200
|
.harness-file-chip-static:hover { color: var(--harness-fg-muted); text-decoration: none; }
|
|
197
201
|
.harness-file-icon { font-size: 0.85rem; }
|
|
198
202
|
.harness-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
199
|
-
.harness-read-path { font-size: 0.78rem; }
|
|
200
203
|
|
|
201
204
|
/* ── diff count + inline diff (edit) ─────────────────────────────────── */
|
|
202
205
|
.harness-diff-count { display: inline-flex; gap: 4px; align-items: center; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; }
|
|
@@ -263,6 +266,44 @@ button.harness-tool-summary { border: 0; background: none; color: inherit; font:
|
|
|
263
266
|
.harness-subagent-window-notice { font-size: 12px; color: var(--harness-fg-muted, #888); }
|
|
264
267
|
.harness-work-items { display: flex; flex-direction: column; gap: var(--harness-work-gap, 16px); }
|
|
265
268
|
.harness-work-history { margin: 0; }
|
|
269
|
+
.harness-turn { width: 100%; min-width: 0; }
|
|
270
|
+
.harness-turn + .harness-turn { margin-top: 24px; }
|
|
271
|
+
.harness-turn-error { color: #cf222e; color: light-dark(#cf222e, #ff7b72); margin: 8px 0 0; }
|
|
272
|
+
.harness-delivery { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-top: 12px; border-radius: 10px;
|
|
273
|
+
border: 1px solid color-mix(in srgb, currentColor 16%, transparent); background: color-mix(in srgb, currentColor 6%, transparent);
|
|
274
|
+
font-size: var(--ui-font-size, 14px); }
|
|
275
|
+
.harness-delivery-icon { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border-radius: 7px;
|
|
276
|
+
background: color-mix(in srgb, currentColor 8%, transparent); }
|
|
277
|
+
.harness-delivery-name { display: grid; gap: 2px; flex: 1; min-width: 0; }
|
|
278
|
+
.harness-delivery-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
|
279
|
+
.harness-delivery-name small { color: var(--dsh-fg-muted, GrayText); }
|
|
280
|
+
.harness-delivery :is(a, button, summary) { flex: none; padding: 4px 10px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
|
|
281
|
+
border-radius: 6px; color: inherit; text-decoration: none; }
|
|
282
|
+
.harness-delivery :is(a, button, summary):is(:hover, :focus-visible) { background: color-mix(in srgb, currentColor 9%, transparent); }
|
|
283
|
+
.harness-delivery-actions { display: flex; align-items: center; gap: 4px; }
|
|
284
|
+
.harness-delivery button { background: transparent; font: inherit; cursor: pointer; }
|
|
285
|
+
.harness-delivery-menu { position: relative; }
|
|
286
|
+
.harness-delivery-menu summary { display: flex; align-items: center; height: 28px; box-sizing: border-box; cursor: pointer; list-style: none; }
|
|
287
|
+
.harness-delivery-menu summary::-webkit-details-marker { display: none; }
|
|
288
|
+
.harness-delivery-menu a { position: absolute; z-index: 1; inset-inline-end: 0; margin-top: 4px; width: max-content;
|
|
289
|
+
background: var(--color-popover, Canvas); }
|
|
290
|
+
.harness-delivery-changes { margin-top: 12px; border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
|
|
291
|
+
border-radius: 10px; background: color-mix(in srgb, currentColor 6%, transparent); font-size: var(--ui-font-size, 14px); }
|
|
292
|
+
.harness-delivery-changes summary { padding: 10px 12px; cursor: pointer; }
|
|
293
|
+
.harness-delivery-delta { display: inline-flex; gap: 6px; margin-inline-start: 8px; }
|
|
294
|
+
.harness-delivery-delta span:first-child { color: light-dark(#1a7f37, #4ac26b); }
|
|
295
|
+
.harness-delivery-delta span:last-child { color: light-dark(#cf222e, #ff7b72); }
|
|
296
|
+
.harness-delivery-changes ul { list-style: none; margin: 0; padding: 0 12px 8px; }
|
|
297
|
+
.harness-delivery-changes li { display: flex; align-items: center; justify-content: space-between; min-width: 0; }
|
|
298
|
+
.harness-delivery-changes li :is(button, span) { overflow-wrap: anywhere; }
|
|
299
|
+
.harness-delivery-changes li button { padding: 4px 0; text-align: start; background: transparent; color: inherit;
|
|
300
|
+
border: 0; font: inherit; cursor: pointer; }
|
|
301
|
+
.harness-delivery-changes li button:hover { text-decoration: underline; }
|
|
302
|
+
.harness-delivery-image { display: block; width: fit-content; max-width: 100%; margin-top: 12px; }
|
|
303
|
+
.harness-delivery-image img { display: block; max-width: min(100%, 480px); height: auto; border-radius: 10px; }
|
|
304
|
+
.harness-reply-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--dsh-fg-muted, GrayText); font-size: 12px; }
|
|
305
|
+
.harness-reply-actions button { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 5px; color: inherit; background: transparent; cursor: pointer; }
|
|
306
|
+
.harness-reply-actions button:hover, .harness-reply-actions button:focus-visible { background: color-mix(in srgb, currentColor 12%, transparent); }
|
|
266
307
|
.harness-work-history-summary { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--harness-border); color: var(--harness-fg-muted); cursor: pointer; list-style: none; }
|
|
267
308
|
.harness-work-history-summary::-webkit-details-marker { display: none; }
|
|
268
309
|
.harness-work-history-chevron { opacity: .7; }
|
package/src/tool-error.mjs
CHANGED
|
@@ -7,6 +7,13 @@ const summaries = {
|
|
|
7
7
|
capture_limit_exceeded: '工作区变更清单超出观测上限,命令未执行',
|
|
8
8
|
command_policy_blocked: '命令不符合当前执行规则,尚未执行',
|
|
9
9
|
policy_denied: '当前权限规则未允许这次操作',
|
|
10
|
+
approval_prompts_disabled: '这项操作需要单次授权,当前会话未开启审批',
|
|
11
|
+
approval_rejected: '用户未授权这次操作',
|
|
12
|
+
approval_unavailable: '当前没有可用的审批入口',
|
|
13
|
+
approval_cancelled: '这次审批已取消,操作未执行',
|
|
14
|
+
invalid_arguments: '工具参数校验未通过,操作未执行',
|
|
15
|
+
snippet_not_found: '找不到要替换的原文片段',
|
|
16
|
+
ambiguous_edit: '原文匹配次数与预期不符',
|
|
10
17
|
command_evidence_incomplete: '命令回执尚不完整,需要核对执行结果',
|
|
11
18
|
studio_native_browser_unavailable: '本地浏览器不可用,尚未完成网页验证',
|
|
12
19
|
child_capability_unavailable: '该子智能体缺少任务所需工具,尚未启动',
|
|
@@ -20,13 +27,34 @@ const summaries = {
|
|
|
20
27
|
selector_resolution_failed: '无法解析或读取指定目标',
|
|
21
28
|
};
|
|
22
29
|
|
|
30
|
+
function errorValue(error) {
|
|
31
|
+
try { return typeof error === 'string' ? JSON.parse(error) : error; } catch { return null; }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const errorCode = value => value?.error_type ?? value?.code ?? value?.error_code ?? value?.error?.code;
|
|
35
|
+
|
|
36
|
+
export function isRetryableEditFailure(error) {
|
|
37
|
+
return ['invalid_arguments', 'snippet_not_found', 'ambiguous_edit'].includes(errorCode(errorValue(error)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const isCommandPolicyBlock = error => errorCode(errorValue(error)) === 'command_policy_blocked';
|
|
41
|
+
|
|
42
|
+
export function commandPolicyBlockReason(error) {
|
|
43
|
+
const value = errorValue(error);
|
|
44
|
+
const reason = value?.finding?.detail ?? value?.message ?? value?.error_message;
|
|
45
|
+
return typeof reason === 'string' ? redactError(reason) : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
23
48
|
/** Detailed evidence remains expandable; compact rows do not dump wire JSON. */
|
|
24
49
|
export function toolErrorSummary(error, { locale } = {}) {
|
|
25
|
-
|
|
26
|
-
try { value = typeof error === 'string' ? JSON.parse(error) : error; } catch { /* plain error */ }
|
|
50
|
+
const value = errorValue(error);
|
|
27
51
|
if (value && typeof value === 'object') {
|
|
28
|
-
const code = value
|
|
29
|
-
if (String(locale ?? '').startsWith('zh'))
|
|
52
|
+
const code = errorCode(value);
|
|
53
|
+
if (String(locale ?? '').startsWith('zh')) {
|
|
54
|
+
if (code === 'snippet_not_found' && Number.isSafeInteger(value.failed_edit_index) && value.failed_edit_index >= 0)
|
|
55
|
+
return `第 ${value.failed_edit_index + 1} 项找不到原文,本批修改未写入`;
|
|
56
|
+
return summaries[code] ?? '工具调用失败,点击查看具体原因';
|
|
57
|
+
}
|
|
30
58
|
return 'Tool call failed; expand for details';
|
|
31
59
|
}
|
|
32
60
|
return redactError(error);
|