@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/view.mjs
CHANGED
|
@@ -19,6 +19,8 @@ import { latestSummaryLine } from './summary-playback.mjs';
|
|
|
19
19
|
import { visibleItems, isWaitingForFirstToken, planProgress, DEFAULT_LABELS } from "./project.mjs";
|
|
20
20
|
import { latestNonEmptyLine, truncateText } from "./summary.mjs";
|
|
21
21
|
import { renderTool } from "./renderers.mjs";
|
|
22
|
+
import { isRetryableEditFailure } from "./tool-error.mjs";
|
|
23
|
+
import { toolIdentity } from "./tool-identity.mjs";
|
|
22
24
|
import { activityGroups, activityGroupSummary } from './activity-groups.mjs';
|
|
23
25
|
import { conversationWorkSegments, completedWorkLabel } from './work-segments.mjs';
|
|
24
26
|
|
|
@@ -167,17 +169,23 @@ export function buildViewModel(state, options = {}) {
|
|
|
167
169
|
"data-testid": "harness-timeline",
|
|
168
170
|
"data-has-user-input": String(items.some(item => item.kind === 'text' && item.role === 'user')),
|
|
169
171
|
role: "log",
|
|
170
|
-
"aria-label": opts.ariaLabel,
|
|
171
|
-
"aria-busy": isWaitingForFirstToken(state) ? "true" : "false",
|
|
172
|
+
"aria-label": options.ariaLabel ?? (String(opts.locale ?? '').startsWith('zh') ? '任务过程' : opts.ariaLabel),
|
|
173
|
+
"aria-busy": (isWaitingForFirstToken(state) || state.taskState === "running" && state.modelRequestActive) ? "true" : "false",
|
|
172
174
|
...(opts.rootProps || {}),
|
|
173
175
|
}, ...rootChildren);
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
function timelineList(state, items, opts) {
|
|
177
179
|
const kids = [];
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
const modelActive = state.taskState === "running" && state.modelRequestActive;
|
|
181
|
+
if (!modelActive && isWaitingForFirstToken(state)) kids.push(waitingPlaceholder(opts));
|
|
182
|
+
const transcript = state.taskState === 'running' ? items.filter(item =>
|
|
183
|
+
!(item.kind === 'tool' && item.status === 'failed' && toolIdentity(item.name).family === 'edit'
|
|
184
|
+
&& isRetryableEditFailure(item.error))) : items;
|
|
185
|
+
const segments = conversationWorkSegments(state, transcript);
|
|
180
186
|
for (const [index, segment] of segments.entries()) {
|
|
187
|
+
const showModelActivity = modelActive && index === segments.length - 1
|
|
188
|
+
&& !segment.process.some(item => item.streaming && ["thought", "tool-preview"].includes(item.kind));
|
|
181
189
|
kids.push(...renderTimelineItems(segment.inputs, opts));
|
|
182
190
|
if (segment.collapsible) {
|
|
183
191
|
const open = Boolean(opts.historyOpen?.get(segment.id));
|
|
@@ -186,11 +194,13 @@ function timelineList(state, items, opts) {
|
|
|
186
194
|
h('span', {}, completedWorkLabel(state, opts.locale)), chevronIcon('harness-work-history-chevron')),
|
|
187
195
|
open ? h('div', { className: 'harness-work-items harness-work-history-content', 'data-testid': 'work-history-content' },
|
|
188
196
|
...renderTimelineItems(segment.process, opts)) : null));
|
|
189
|
-
} else if (segment.process.length) kids.push(h('div', { className: 'harness-work-items', 'data-testid': 'work-process' },
|
|
197
|
+
} else if (segment.process.length || showModelActivity) kids.push(h('div', { className: 'harness-work-items', 'data-testid': 'work-process' },
|
|
190
198
|
...renderTimelineItems(segment.process, opts, state.taskState === 'running'
|
|
191
|
-
&& index === segments.length - 1 && segment.following.length === 0)
|
|
199
|
+
&& index === segments.length - 1 && segment.following.length === 0),
|
|
200
|
+
showModelActivity ? modelActivity(opts, state) : null));
|
|
192
201
|
kids.push(...renderTimelineItems(segment.following, opts));
|
|
193
202
|
}
|
|
203
|
+
if (modelActive && !segments.length) kids.push(modelActivity(opts, state));
|
|
194
204
|
if (!kids.length && opts.emptyState) kids.push(opts.emptyState);
|
|
195
205
|
if (opts.following === false) kids.push(jumpToLatest(opts));
|
|
196
206
|
return h("div", { className: "harness-timeline", "data-testid": "harness-timeline-list" }, ...kids);
|
|
@@ -260,6 +270,18 @@ function textBlock(item, opts) {
|
|
|
260
270
|
}, h("span", { className: "harness-text-content" }, text));
|
|
261
271
|
}
|
|
262
272
|
|
|
273
|
+
function modelActivity(opts, state) {
|
|
274
|
+
const zh = String(opts.locale ?? '').startsWith('zh');
|
|
275
|
+
const compacting = state.modelRequestPurpose === 'compaction', retry = state.modelRequestRetry;
|
|
276
|
+
const label = compacting ? (retry ? (zh ? '正在重试上下文压缩…' : 'Retrying context compaction…')
|
|
277
|
+
: (zh ? '正在压缩上下文…' : 'Compacting context…'))
|
|
278
|
+
: retry ? (zh ? '模型正在重试…' : 'Retrying model request…') : opts.labels.thinking;
|
|
279
|
+
return h("div", { className: "harness-thought-summary harness-model-activity", role: "status",
|
|
280
|
+
"data-testid": compacting ? "model-compaction" : retry ? "model-retry" : "model-thinking" },
|
|
281
|
+
brainIcon("harness-thought-icon"),
|
|
282
|
+
h("span", { className: "harness-thought-label harness-thought-label-streaming" }, label));
|
|
283
|
+
}
|
|
284
|
+
|
|
263
285
|
function thoughtBlock(item, opts) {
|
|
264
286
|
const streaming = Boolean(item.streaming);
|
|
265
287
|
const userOpen = opts.thoughtOpen ? Boolean(opts.thoughtOpen.get(item.id)) : null;
|
package/src/work-segments.mjs
CHANGED
|
@@ -11,6 +11,7 @@ export function conversationWorkSegments(state, items) {
|
|
|
11
11
|
}
|
|
12
12
|
if (segment.inputs.length || segment.work.length) segments.push(segment);
|
|
13
13
|
const closed = ['completed', 'unverified'].includes(state.taskState) && !state.taskError;
|
|
14
|
+
const ended = closed || ['failed', 'cancelled', 'interrupted'].includes(state.taskState);
|
|
14
15
|
return segments.map((segment, index) => {
|
|
15
16
|
const rows = segment.work;
|
|
16
17
|
const candidate = rows.find(item => item.id === state.finalAnswerId)
|
|
@@ -19,9 +20,8 @@ export function conversationWorkSegments(state, items) {
|
|
|
19
20
|
const answerIndex = final ? rows.findIndex(item => item.kind === 'text' && (item.id === final.id
|
|
20
21
|
|| final.sourceMessageId && item.sourceMessageId === final.sourceMessageId)) : -1;
|
|
21
22
|
const process = answerIndex >= 0 ? rows.slice(0, answerIndex) : rows;
|
|
22
|
-
const unresolved = rows.some(item => item.kind === 'tool' && ['scheduled', 'running', 'waiting', 'uncertain', 'interrupted'].includes(item.status));
|
|
23
23
|
return { ...segment, process, following: answerIndex >= 0 ? rows.slice(answerIndex) : [],
|
|
24
|
-
collapsible:
|
|
24
|
+
collapsible: ended && process.length > 0 };
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
|