@kingsoftcloud/agentkit-harness-ui 0.0.14 → 0.0.16
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/README.md +6 -0
- package/package.json +3 -2
- package/src/host/native-approval-actions.mjs +39 -0
- package/src/host/native-run-panel.mjs +2 -0
- package/src/host/state/native-children.mjs +7 -3
- package/src/host/state/native-outcome.mjs +32 -0
- package/src/host/task-timeline.mjs +1 -0
- package/src/inspector.mjs +2 -1
- package/src/renderers.mjs +13 -5
- package/src/tool-detail.mjs +12 -0
package/README.md
CHANGED
|
@@ -22,6 +22,12 @@ callbacks; the component never resolves execution roots or performs I/O. These
|
|
|
22
22
|
are current workspace observations, separate from immutable tool receipts and
|
|
23
23
|
task acceptance. Failed or canceled reads must not fall back to a parent file.
|
|
24
24
|
|
|
25
|
+
`./host/native-approval-actions` adds a Host-owned Session grant action to an
|
|
26
|
+
existing one-call approval card. Lost replies may retry the same offer; an
|
|
27
|
+
explicit stale-offer refusal disables that offer and directs the user to the
|
|
28
|
+
original one-call approval. A later Host offer remains independently usable.
|
|
29
|
+
The component never renews an offer or approves a call without its exact receipt.
|
|
30
|
+
|
|
25
31
|
## Design
|
|
26
32
|
|
|
27
33
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingsoftcloud/agentkit-harness-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Reusable React task-process UI for AgentKit Native: an explicitly versioned event protocol, a pure state reducer, and an accessible timeline. No Studio/DSH/Python imports; React is a peer dependency.",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"./host/native-child-pane": "./src/host/native-child-pane.mjs",
|
|
39
39
|
"./host/native-child-file-pane": "./src/host/native-child-file-pane.mjs",
|
|
40
40
|
"./host/native-run-panel": "./src/host/native-run-panel.mjs",
|
|
41
|
+
"./host/native-approval-actions": "./src/host/native-approval-actions.mjs",
|
|
41
42
|
"./host/native-a2a": "./src/host/native-a2a.mjs",
|
|
42
43
|
"./host/state/native-a2a": "./src/host/state/native-a2a.mjs",
|
|
43
44
|
"./host/state/native-task-read-model": "./src/host/state/native-task-read-model.mjs"
|
|
@@ -96,6 +97,6 @@
|
|
|
96
97
|
"registry": "https://registry.npmjs.org"
|
|
97
98
|
},
|
|
98
99
|
"dependencies": {
|
|
99
|
-
"@kingsoftcloud/agentkit-harness-core": "0.0.
|
|
100
|
+
"@kingsoftcloud/agentkit-harness-core": "0.0.16"
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const contract = 'agentkit.native-session-tool-approval/v1';
|
|
2
|
+
const validId = value => typeof value === 'string' && value.trim().length > 0 && value.length <= 256;
|
|
3
|
+
|
|
4
|
+
/** Optional addition to the Host's existing one-call approval card. */
|
|
5
|
+
export function createNativeApprovalActions({ React: { createElement: h, useState, useRef, useEffect }, hostRemote, Button = 'button' }) {
|
|
6
|
+
return function NativeApprovalActions({ pending }) {
|
|
7
|
+
const [waiting, setWaiting] = useState(false), [failure, setFailure] = useState(null);
|
|
8
|
+
const busy = useRef(false), alive = useRef(true), staleOffer = useRef(null);
|
|
9
|
+
useEffect(() => { alive.current = true; return () => { alive.current = false; }; }, []);
|
|
10
|
+
const offer = pending?.sessionGrant;
|
|
11
|
+
if (offer?.contract !== contract || typeof hostRemote?.grantNativeSessionTool !== 'function'
|
|
12
|
+
|| !['offerId', 'requestId', 'agentId', 'sessionId', 'runId', 'toolName', 'targetSessionId'].every(key => validId(offer[key]))
|
|
13
|
+
|| pending.sessionId !== offer.sessionId || pending.toolName !== offer.toolName
|
|
14
|
+
|| typeof pending.answer !== 'function') return null;
|
|
15
|
+
const stale = staleOffer.current === offer.offerId;
|
|
16
|
+
const error = failure?.offerId === offer.offerId ? failure.message : '';
|
|
17
|
+
const allow = async () => {
|
|
18
|
+
if (busy.current || staleOffer.current === offer.offerId || !pending.answerable) return;
|
|
19
|
+
busy.current = true; setWaiting(true); setFailure(null);
|
|
20
|
+
try {
|
|
21
|
+
const request = Object.fromEntries(['agentId', 'sessionId', 'runId', 'offerId', 'requestId'].map(key => [key, offer[key]]));
|
|
22
|
+
const receipt = await hostRemote.grantNativeSessionTool(request);
|
|
23
|
+
if (!['accepted', 'duplicate'].includes(receipt?.status) || receipt.offerId !== offer.offerId || receipt.requestId !== offer.requestId)
|
|
24
|
+
throw Error('unconfirmed Session grant');
|
|
25
|
+
if (alive.current && pending.answerable) await pending.answer('allowed-once');
|
|
26
|
+
} catch (cause) {
|
|
27
|
+
const invalid = ['session_tool_approval_offer_stale', 'studio_native_session_approval_stale'].includes(cause?.code);
|
|
28
|
+
if (invalid) staleOffer.current = offer.offerId;
|
|
29
|
+
if (alive.current) setFailure({ offerId: offer.offerId, message: invalid
|
|
30
|
+
? '这次会话授权已失效,请选择“允许一次”继续当前操作。'
|
|
31
|
+
: '会话授权尚未确认,请重试或选择仅允许一次。' });
|
|
32
|
+
} finally { busy.current = false; if (alive.current) setWaiting(false); }
|
|
33
|
+
};
|
|
34
|
+
return h('span', null, h(Button, { type: 'button', variant: 'outline', disabled: waiting || stale || !pending.answerable,
|
|
35
|
+
title: `仅记住 ${offer.toolName} 在当前构建及会话运行期间的 Agent 额外审批;Host 和沙箱限制仍然有效。重启或权限变更后需要重新确认。`,
|
|
36
|
+
onClick: allow }, waiting ? '确认授权中…' : stale ? '会话授权已失效' : offer.targetSessionId === offer.sessionId ? '本会话允许此工具' : '本子任务会话允许此工具'),
|
|
37
|
+
error ? h('span', { role: 'alert' }, error) : null);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -67,6 +67,7 @@ export function createNativeChildPanel({ ui: { React: { createElement: h, useEff
|
|
|
67
67
|
stopState.visible && stopState.error ? h('span', { role: 'alert' }, stopState.error) : null,
|
|
68
68
|
h('button', { type: 'button', style: buttonStyle(), onClick: () => setOpen(true) }, '运行与子任务'),
|
|
69
69
|
open ? h(ResourceDialog, { title: '本会话的运行与子任务', detail: '查看运行用量、恢复状态及各轮子任务。子任务结果仍需父任务验收。', wide: true, onClose: () => setOpen(false) },
|
|
70
|
+
presentation?.detail ? h('p', { 'aria-label': '运行原因与后续操作' }, presentation.detail) : null,
|
|
70
71
|
h('button', { type: 'button', style: buttonStyle(), disabled: !controller || state.loading, onClick: () => { void controller?.refresh(); void recovery?.refresh(); } }, state.loading ? '读取中…' : '刷新'),
|
|
71
72
|
recoveryState.error ? h('p', { role: 'alert' }, recoveryState.error) : null,
|
|
72
73
|
recoveryState.status?.error ? h('p', { role: 'alert' }, recoveryState.status.error.message) : null,
|
|
@@ -164,6 +165,7 @@ export function createNativeChildPanel({ ui: { React: { createElement: h, useEff
|
|
|
164
165
|
h('button', { type: 'button', disabled: state.reading, style: buttonStyle(), onClick: () => void controller.read(task) }, task.resultAvailable ? '查看结果' : '查看状态'),
|
|
165
166
|
task.canPromote ? h('button', { type: 'button', disabled: Boolean(state.pending), style: buttonStyle(), onClick: () => void controller.promote(task) }, '转为后台') : null,
|
|
166
167
|
task.canCancel ? h('button', { type: 'button', disabled: Boolean(state.pending), style: buttonStyle(), onClick: () => void controller.cancel(task) }, '停止子任务') : null,
|
|
168
|
+
task.canResume === true ? h('button', { type: 'button', disabled: Boolean(state.pending), style: buttonStyle(), onClick: () => void controller.resume(task) }, '恢复原子任务') : null,
|
|
167
169
|
task.canSendInput ? h('div', null,
|
|
168
170
|
h('textarea', { 'aria-label': `给 ${task.role} 补充指导`, maxLength: 32768, rows: 2, value: drafts[task.childRunId] ?? '',
|
|
169
171
|
disabled: Boolean(state.pending), onChange: event => setDrafts({ ...drafts, [task.childRunId]: event.target.value }) }),
|
|
@@ -11,6 +11,9 @@ export function createNativeChildrenState({ hostRemote, agentId, sessionId, comm
|
|
|
11
11
|
const validTask = task => task && ['childRunId', 'sessionId', 'parentRunId', 'role', 'phase', 'goalPreview']
|
|
12
12
|
.every(key => typeof task[key] === 'string') && typeof task.resultAvailable === 'boolean'
|
|
13
13
|
&& task.usage && Number.isSafeInteger(task.usage.modelCalls) && Number.isSafeInteger(task.usage.toolCalls)
|
|
14
|
+
&& (task.canResume === undefined || typeof task.canResume === 'boolean'
|
|
15
|
+
&& (!task.canResume || task.phase === 'paused'
|
|
16
|
+
&& !['effect_outcome_unknown', 'recovery_retry_exhausted', 'browser_session_unavailable'].includes(task.reason)))
|
|
14
17
|
&& (task.a2aTasks === undefined || Array.isArray(task.a2aTasks) && task.a2aTasks.length <= 10000
|
|
15
18
|
&& task.a2aTasks.every(item => item?.runId === task.parentRunId && item.childRunId === task.childRunId
|
|
16
19
|
&& item.childSessionId === task.sessionId && ['childAgentId', 'operationKey', 'callId']
|
|
@@ -25,7 +28,7 @@ export function createNativeChildrenState({ hostRemote, agentId, sessionId, comm
|
|
|
25
28
|
if (disposed) return;
|
|
26
29
|
valid(page);
|
|
27
30
|
check(Array.isArray(page.tasks) && page.tasks.every(task => validTask(task)
|
|
28
|
-
&& (!(task.canPromote || task.canCancel || task.canSendInput) || task.parentRunId === page.runId)
|
|
31
|
+
&& (!(task.canPromote || task.canCancel || task.canSendInput || task.canResume) || task.parentRunId === page.runId)
|
|
29
32
|
&& (!task.canSendInput || Number.isSafeInteger(task.goalRevision) && task.goalRevision >= 0))
|
|
30
33
|
&& new Set(page.tasks.map(task => task.childRunId)).size === page.tasks.length
|
|
31
34
|
&& Number.isSafeInteger(page.offset) && page.offset >= 0 && page.nextOffset === page.offset + page.tasks.length
|
|
@@ -64,7 +67,7 @@ export function createNativeChildrenState({ hostRemote, agentId, sessionId, comm
|
|
|
64
67
|
const pending = state.pending;
|
|
65
68
|
set({ sending: true, error: '' });
|
|
66
69
|
try {
|
|
67
|
-
const method = { promote: 'promoteNativeChild', send: 'sendNativeChildInput', cancel: 'cancelNativeChild' }[state.pendingAction];
|
|
70
|
+
const method = { promote: 'promoteNativeChild', send: 'sendNativeChildInput', cancel: 'cancelNativeChild', resume: 'resumeNativeChild' }[state.pendingAction];
|
|
68
71
|
const receipt = await hostRemote[method](pending, lifetime.signal);
|
|
69
72
|
check(receipt?.commandId === pending.commandId && ['accepted', 'duplicate'].includes(receipt.status), '子任务操作回执未确认。');
|
|
70
73
|
if (disposed) return;
|
|
@@ -73,7 +76,7 @@ export function createNativeChildrenState({ hostRemote, agentId, sessionId, comm
|
|
|
73
76
|
finally { set({ sending: false }); }
|
|
74
77
|
}
|
|
75
78
|
function control(action, task, extra = {}) {
|
|
76
|
-
const allowed = { promote: task.canPromote, send: task.canSendInput, cancel: task.canCancel }[action];
|
|
79
|
+
const allowed = { promote: task.canPromote, send: task.canSendInput, cancel: task.canCancel, resume: task.canResume === true }[action];
|
|
77
80
|
if (disposed || state.pending || !allowed || task.parentRunId !== state.page?.runId) return;
|
|
78
81
|
if (action === 'send' && (typeof extra.text !== 'string' || !extra.text.trim() || extra.text.length > 32768
|
|
79
82
|
|| !Number.isSafeInteger(task.goalRevision) || task.goalRevision < 0)) return;
|
|
@@ -86,6 +89,7 @@ export function createNativeChildrenState({ hostRemote, agentId, sessionId, comm
|
|
|
86
89
|
subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener); },
|
|
87
90
|
refresh: () => load(), next: () => load(true), read,
|
|
88
91
|
promote: task => control('promote', task), cancel: task => control('cancel', task),
|
|
92
|
+
resume: task => control('resume', task),
|
|
89
93
|
sendInput: (task, text) => control('send', task, { text, expectedGoalRevision: task.goalRevision }),
|
|
90
94
|
retryControl: sendControl, retryPromotion: sendControl,
|
|
91
95
|
dispose() { if (disposed) return; disposed = true; lifetime.abort(); reading++; listeners.clear(); },
|
|
@@ -2,6 +2,27 @@ const phases = { created: '已准备', preparing_context: '整理上下文', req
|
|
|
2
2
|
compacting: '压缩上下文', verifying: '验证结果', executing_tools: '执行工具', awaiting_interaction: '等待审批或输入', paused: '已暂停',
|
|
3
3
|
awaiting_reconciliation: '等待核对执行结果', reconciling_tool: '正在核对执行结果', interrupted: '执行中断,需要核对', finalizing: '收尾中' };
|
|
4
4
|
|
|
5
|
+
// Stable ledger reasons, never raw provider/tool exception text. These are
|
|
6
|
+
// explanations only; canResume still comes from the current Host authority.
|
|
7
|
+
const pauseReasons = {
|
|
8
|
+
child_paused: ['子任务已暂停,等待处理', '原子任务及已提交结果已保留。请在“运行与子任务”中核对暂停原因,明确恢复或取消原子任务。'],
|
|
9
|
+
approval_rejected: ['审批被拒绝,已暂停', '这次操作没有获得批准,尚未执行。已停止继续申请和生成,等待补充指导或明确恢复。'],
|
|
10
|
+
approval_cancelled: ['审批已取消,已暂停', '这次审批被取消,操作尚未执行。原任务已保留,不会自动重新申请。'],
|
|
11
|
+
approval_unavailable: ['审批通道不可用,已暂停', '尚未取得审批结果,操作没有获得批准。请先恢复审批通道再核对原任务。'],
|
|
12
|
+
output_budget_exhausted: ['输出恢复额度已耗尽,已暂停', '同一响应多次达到输出上限,已保留已提交的工具结果和回复片段。'],
|
|
13
|
+
provider_unavailable: ['模型服务暂不可用,已暂停', '模型请求的本轮重试已耗尽,原运行和已提交结果已保留。'],
|
|
14
|
+
context_summary_unavailable: ['上下文整理暂不可用,已暂停', '上下文摘要暂未生成,原运行已保留,没有丢弃必需上下文。'],
|
|
15
|
+
context_source_unavailable: ['上下文读取暂不可用,已暂停', '必需的上下文读取尚未成功,原运行和已提交结果已保留。'],
|
|
16
|
+
};
|
|
17
|
+
const failureReasons = {
|
|
18
|
+
continuation_budget_exhausted: ['输出续写额度已耗尽', '本轮输出续写与重启额度已耗尽,任务没有完成。请核对模型输出上限和运行记录。'],
|
|
19
|
+
model_budget_exhausted: ['模型调用预算已耗尽', '本轮已达到模型调用总预算,不能通过恢复补回已经消耗的预算。'],
|
|
20
|
+
execution_budget_exhausted: ['执行时间预算已耗尽', '本轮已达到执行时间预算,任务没有完成。'],
|
|
21
|
+
provider_retryable_error_retry_exhausted: ['模型请求重试已耗尽', '模型服务持续未能完成请求,任务没有完成。'],
|
|
22
|
+
context_compaction_limit: ['上下文压缩次数已耗尽', '本轮已达到上下文压缩次数上限,任务尚未完成。'],
|
|
23
|
+
context_mandatory_state_over_budget: ['必需上下文超过预算', '任务必需的上下文超过可用预算,无法安全省略后继续。'],
|
|
24
|
+
};
|
|
25
|
+
|
|
5
26
|
/** The committed phase survives a crash; only the owner control state says work is still being driven. */
|
|
6
27
|
export function nativeRunIsInactive(status, transportRunning = true) {
|
|
7
28
|
return status?.state ? status.state !== 'recovering' : !transportRunning;
|
|
@@ -15,6 +36,17 @@ export function nativeRunPresentation(status) {
|
|
|
15
36
|
&& status.backgroundInterruptionReview.confirmedStopped === true && status.state === 'closed')
|
|
16
37
|
return { label: '已结束等待,原结果未知', detail: '已核对原操作停止并关闭本轮;未知结果与原回执保持不变,没有重跑原命令。' };
|
|
17
38
|
if (status.phase === 'canceled') return { label: '已取消', detail: '本轮执行已停止;已经发生的文件或外部修改不会因此自动撤销。' };
|
|
39
|
+
if (status.phase === 'paused' && Object.hasOwn(pauseReasons, status.reason)) {
|
|
40
|
+
const [label, detail] = pauseReasons[status.reason];
|
|
41
|
+
if (status.reason === 'child_paused') return { label, detail };
|
|
42
|
+
return { label, detail: detail + (status.canResume === true
|
|
43
|
+
? '请在运行与子任务中核对后恢复原运行;不会重新执行已提交的操作。'
|
|
44
|
+
: '请在运行与子任务中核对原因及当前可用操作。') };
|
|
45
|
+
}
|
|
46
|
+
if (status.phase === 'failed' && Object.hasOwn(failureReasons, status.reason)) {
|
|
47
|
+
const [label, detail] = failureReasons[status.reason];
|
|
48
|
+
return { label, detail: status.error?.message || detail };
|
|
49
|
+
}
|
|
18
50
|
if (status.outcome === 'blocked') return { label: '任务受阻', detail: status.error?.message || '本轮未能完成任务。请查看回复中的缺项,检查 Agent 的「绑定能力」及审批要求。' };
|
|
19
51
|
if (status.phase === 'failed') return { label: '执行失败', detail: status.error?.message || '本轮执行未成功,请查看错误并核对结果后重试。' };
|
|
20
52
|
if (status.phase === 'interrupted' && status.reason === 'effect_outcome_unknown')
|
|
@@ -22,6 +22,7 @@ const labels = { result: '执行结果', thought: '思考', running: '执行中'
|
|
|
22
22
|
toolDetails: '工具详情', close: '关闭', state: '状态', arguments: '调用参数', noSettledResult: '尚无已确认的结果', appliedChanges: '实际文件变更',
|
|
23
23
|
diffTruncated: '差异预览已截断', diffUnavailable: '无可用差异预览', diffFilesOmitted: '个文件预览已省略', plan: '计划',
|
|
24
24
|
writePending: '请求写入', editPending: '请求修改',
|
|
25
|
+
requestedArguments: '请求参数(非执行结果)',
|
|
25
26
|
subagent: '子智能体', openSubagent: '在右侧打开', childSyncing: '同步中', childOmitted: '当前显示过程窗口,较早内容或较长字段已省略。',
|
|
26
27
|
toolPreparing: '正在生成工具参数', previewStopped: '工具参数生成已中断' };
|
|
27
28
|
|
package/src/inspector.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { redactValue, truncateText } from './summary.mjs';
|
|
2
|
+
import { toolInputPreview } from './tool-detail.mjs';
|
|
2
3
|
|
|
3
4
|
const bounded = value => {
|
|
4
5
|
let parsed = value;
|
|
@@ -27,7 +28,7 @@ export function createToolInspector(React) {
|
|
|
27
28
|
h('header', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
|
|
28
29
|
h('strong', null, item.name), h('button', { type: 'button', onClick: onClose, autoFocus: true }, labels.close || 'Close')),
|
|
29
30
|
h('p', null, `${labels.state || 'State'}: ${item.status}`),
|
|
30
|
-
h('h4', null, labels.arguments || 'Arguments'), h('pre', null,
|
|
31
|
+
h('h4', null, labels.arguments || 'Arguments'), h('pre', null, toolInputPreview(item.input)),
|
|
31
32
|
h('h4', null, labels.result || 'Result'),
|
|
32
33
|
h('pre', null, item.error ? bounded(item.error) : item.result != null ? bounded(item.result)
|
|
33
34
|
: labels.noSettledResult || 'No settled result is available'),
|
package/src/renderers.mjs
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import { h, terminalIcon, fileTextIcon, searchIcon, pencilIcon, wrenchIcon, chevronIcon, skillIcon, globeIcon } from "./view.mjs";
|
|
20
20
|
import { ToolStatus } from "./protocol.mjs";
|
|
21
|
-
import { toolTitle, toolDetailLines, workspaceRelative, redactError } from "./tool-detail.mjs";
|
|
21
|
+
import { toolTitle, toolDetailLines, toolInputPreview, workspaceRelative, redactError } from "./tool-detail.mjs";
|
|
22
22
|
import { truncateText, latestNonEmptyLine, redactValue, boundedDetailLines } from "./summary.mjs";
|
|
23
23
|
import { parseDiffHunks, countChangeStat, inferOperationKind } from "./diff.mjs";
|
|
24
24
|
import { extractCommand, extractOutput } from "./terminal.mjs";
|
|
@@ -448,9 +448,9 @@ function editRenderer(item, opts) {
|
|
|
448
448
|
// Never infer a write succeeded: the diff/count come from the result display
|
|
449
449
|
// only. While running (no result), show the intent + file chips, no diff.
|
|
450
450
|
const opKind = files.length ? inferOperationKind(files[0].operationKind, null, files[0].patch) : "edit";
|
|
451
|
-
const pending = item.kind === 'tool-preview' ||
|
|
452
|
-
const title = pending ? /write|Write/.test(item.name) ? opts.labels
|
|
453
|
-
: opts.labels
|
|
451
|
+
const pending = item.kind === 'tool-preview' || !['file_edit', 'file_diff'].includes(item.display?.kind);
|
|
452
|
+
const title = pending ? /write|Write/.test(item.name) ? opts.labels?.writePending || 'Write requested'
|
|
453
|
+
: opts.labels?.editPending || 'Edit requested' : editKindLabel(opKind, running, opts) || toolTitle(item.name, item.input) || item.name;
|
|
454
454
|
const summary = [h("span", {
|
|
455
455
|
className: running
|
|
456
456
|
? "harness-tool-title harness-tool-title-streaming"
|
|
@@ -485,10 +485,18 @@ function editRenderer(item, opts) {
|
|
|
485
485
|
else if (f.truncated) nodes.push(h("p", { className: "harness-diff-truncated", "data-testid": "edit-diff-truncated" }, opts.labels.diffUnavailable || "Diff preview omitted because of its size"));
|
|
486
486
|
}
|
|
487
487
|
if (item.display?.omittedFiles) nodes.push(h("p", { className: "harness-diff-truncated", "data-testid": "edit-diff-omitted" }, `${item.display.omittedFiles} ${opts.labels.diffFilesOmitted || "file previews omitted"}`));
|
|
488
|
+
// A committed request awaiting approval has no result diff. Keep its
|
|
489
|
+
// disclosure useful without representing proposed content as applied code.
|
|
490
|
+
if (!nodes.length && pending && item.kind !== 'tool-preview') {
|
|
491
|
+
const preview = toolInputPreview(item.input);
|
|
492
|
+
if (preview) nodes.push(h('section', { 'data-testid': 'edit-request-preview' },
|
|
493
|
+
h('p', null, opts.labels?.requestedArguments || 'Requested arguments (not an execution result)'),
|
|
494
|
+
h('pre', { style: { whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', maxHeight: '24rem', overflow: 'auto' } }, preview)));
|
|
495
|
+
}
|
|
488
496
|
return nodes;
|
|
489
497
|
};
|
|
490
498
|
return toolShell(item, opts, { icon: pencilIcon("harness-tool-kind-icon"), summary, body, canToggle: true,
|
|
491
|
-
defaultOpen:
|
|
499
|
+
defaultOpen: !pending && files.length === 1 && running });
|
|
492
500
|
}
|
|
493
501
|
|
|
494
502
|
function editFiles(item) {
|
package/src/tool-detail.mjs
CHANGED
|
@@ -90,6 +90,18 @@ export function toolDetailLines(name, input = {}, opts = {}) {
|
|
|
90
90
|
return boundedDetailLines(input, { maxLines, maxChars });
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/** Read-only argument inspection shared by the timeline and inspector.
|
|
94
|
+
* This is a bounded, redacted request preview, never evidence of execution.
|
|
95
|
+
*/
|
|
96
|
+
export function toolInputPreview(input) {
|
|
97
|
+
let value = input;
|
|
98
|
+
if (typeof value === 'string') { try { value = JSON.parse(value); } catch { /* plain argument text */ } }
|
|
99
|
+
let raw;
|
|
100
|
+
try { raw = typeof value === 'string' ? value : JSON.stringify(value ?? {}, (key, value) => redactValue(key, value), 2); }
|
|
101
|
+
catch { return ''; }
|
|
102
|
+
return truncateText(redactDiagnosticText(raw, 8192), { maxLines: 80, maxChars: 240 });
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
function knownToolDetail(tool, input, workspaceRoot, maxLines, maxChars) {
|
|
94
106
|
const pushBounded = (rows, key, value) => {
|
|
95
107
|
if (rows.length >= maxLines) return rows;
|