@steerable/agent-shell-web 0.9.2 → 0.10.1
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 +4 -4
- package/src/components/chat/AskUserQuestionMenu.tsx +22 -0
- package/src/components/chat/AssistantMessage.tsx +7 -0
- package/src/components/chat/ChatInput.tsx +21 -0
- package/src/components/chat/LocalChatPanel.tsx +16 -0
- package/src/components/chat/MessageList.tsx +34 -0
- package/src/components/chat/OrchestrationChildrenCard.tsx +140 -22
- package/src/components/chat/SessionOrchestrationFlow.tsx +136 -110
- package/src/components/chat/TurnProcessGroup.tsx +21 -0
- package/src/components/chat/orchestration-children-model.ts +274 -28
- package/src/components/chat/orchestration-flow-model.ts +43 -0
- package/src/components/settings/AgentsSettingsPanel.tsx +45 -0
- package/src/components/settings/OrchestrationSettingsPanel.tsx +81 -5
- package/src/components/settings/UsagePanel.tsx +12 -0
- package/src/lib/local-api.ts +7 -0
- package/src/lib/orchestration-settings.ts +122 -0
- package/src/pages/AgentPage.tsx +121 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerable/agent-shell-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Steerable framework — product-neutral renderer SPA source for @steerable/agent-shell (React + Vite). Consumed by product web entry points via the `@/` alias (anchored at this package's src/) and the createProductViteConfig factory. Published as a source package (src/), plus the compiled vite.base config factory (vite.base.js + .d.ts) for Node-side config loading.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react-router-dom": "^6.30.0",
|
|
46
46
|
"rehype-raw": "^7.0.0",
|
|
47
47
|
"remark-gfm": "^4.0.1",
|
|
48
|
-
"@steerable/agent-protocol": "0.
|
|
49
|
-
"@steerable/agent-ui": "0.
|
|
48
|
+
"@steerable/agent-protocol": "0.10.1",
|
|
49
|
+
"@steerable/agent-ui": "0.10.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@tailwindcss/vite": "^4.3.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"typescript": "^5.8.3",
|
|
60
60
|
"vite": "^5.4.21",
|
|
61
61
|
"vitest": "^3.2.4",
|
|
62
|
-
"@steerable/pack-sdk": "0.
|
|
62
|
+
"@steerable/pack-sdk": "0.10.1"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"gen": "echo agent-shell-web",
|
|
@@ -539,6 +539,13 @@ export interface AskUserQuestionMenuProps {
|
|
|
539
539
|
onSubmit: (answers: Record<string, AnswerValue>) => void;
|
|
540
540
|
onAutoContinue?: () => void;
|
|
541
541
|
bottomHint?: string;
|
|
542
|
+
/**
|
|
543
|
+
* R7-3: the sub-agent this question came from, when it came from one.
|
|
544
|
+
* Rendered above the intro so the user knows which of several running
|
|
545
|
+
* agents is blocked — the answer goes to that child, not to the parent's
|
|
546
|
+
* own reasoning.
|
|
547
|
+
*/
|
|
548
|
+
source?: { childId: string; profile?: string };
|
|
542
549
|
}
|
|
543
550
|
|
|
544
551
|
export function AskUserQuestionMenu({
|
|
@@ -547,6 +554,7 @@ export function AskUserQuestionMenu({
|
|
|
547
554
|
onSubmit,
|
|
548
555
|
onAutoContinue,
|
|
549
556
|
bottomHint,
|
|
557
|
+
source,
|
|
550
558
|
}: AskUserQuestionMenuProps) {
|
|
551
559
|
const normalized = useMemo(() => normalizeQuestions(questions), [questions]);
|
|
552
560
|
const [step, setStep] = useState(0);
|
|
@@ -585,6 +593,20 @@ export function AskUserQuestionMenu({
|
|
|
585
593
|
<div className="overflow-hidden rounded-agent-lg border border-agent-border bg-agent-canvas text-xs text-agent-foreground shadow-xl">
|
|
586
594
|
<div className="flex items-start justify-between gap-2 border-b border-agent-border px-3 py-2">
|
|
587
595
|
<div className="min-w-0 flex-1">
|
|
596
|
+
{source ? (
|
|
597
|
+
// 来源行:几个子代理同时在跑时,用户要知道这份提问是谁的。
|
|
598
|
+
<p
|
|
599
|
+
className="mb-0.5 text-[10px] font-medium text-violet-700 dark:text-violet-300"
|
|
600
|
+
data-testid="ask-user-source"
|
|
601
|
+
>
|
|
602
|
+
{source.profile
|
|
603
|
+
? t('From sub-agent {id} ({profile})', {
|
|
604
|
+
id: source.childId,
|
|
605
|
+
profile: source.profile,
|
|
606
|
+
})
|
|
607
|
+
: t('From sub-agent {id}', { id: source.childId })}
|
|
608
|
+
</p>
|
|
609
|
+
) : null}
|
|
588
610
|
<p className="text-xs font-medium text-agent-foreground">
|
|
589
611
|
{intro || t('Your input is needed')}
|
|
590
612
|
</p>
|
|
@@ -157,6 +157,9 @@ interface AssistantMessageProps {
|
|
|
157
157
|
*/
|
|
158
158
|
onShare?: () => Promise<boolean>;
|
|
159
159
|
onInspectTask?: (task: InspectTaskInput) => void;
|
|
160
|
+
/** R7:子代理面板的「继续」/「停止」。 */
|
|
161
|
+
onContinueChild?: (childId: string, recordId: string) => void;
|
|
162
|
+
onStopChild?: (childId: string) => void;
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
function agentInitial(name: string): string {
|
|
@@ -457,6 +460,8 @@ export function AssistantMessage({
|
|
|
457
460
|
turnFiles,
|
|
458
461
|
onShare,
|
|
459
462
|
onInspectTask,
|
|
463
|
+
onContinueChild,
|
|
464
|
+
onStopChild,
|
|
460
465
|
}: AssistantMessageProps) {
|
|
461
466
|
const content = message.content || '';
|
|
462
467
|
const failure = readTurnFailure(message, content);
|
|
@@ -550,6 +555,8 @@ export function AssistantMessage({
|
|
|
550
555
|
chatId={chatId}
|
|
551
556
|
onInspectTask={onInspectTask}
|
|
552
557
|
orchestrationChildren={orchestrationChildren}
|
|
558
|
+
onContinueChild={onContinueChild}
|
|
559
|
+
onStopChild={onStopChild}
|
|
553
560
|
emptyFallback={
|
|
554
561
|
failure ? (
|
|
555
562
|
wrapContinued(
|
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
} from '@/lib/slash-sources';
|
|
55
55
|
import { useAskUserPrompt } from './AskUserPromptProvider';
|
|
56
56
|
import { AskUserQuestionMenu } from './AskUserQuestionMenu';
|
|
57
|
+
import { childAwaitingInput, type ChildInfo } from './orchestration-children-model';
|
|
57
58
|
import { useApprovalPrompt } from './ApprovalPromptProvider';
|
|
58
59
|
import { ApprovalPromptMenu } from './ApprovalModal';
|
|
59
60
|
import { ExecPolicyPicker } from './ExecPolicyPicker';
|
|
@@ -117,6 +118,12 @@ export interface ChatInputProps {
|
|
|
117
118
|
onChange: (next: string) => void;
|
|
118
119
|
onSubmit: () => void | Promise<void>;
|
|
119
120
|
onCancel?: () => void;
|
|
121
|
+
/**
|
|
122
|
+
* R7-3: this turn's sub-agents. Only used to say which child a structured
|
|
123
|
+
* question came from, so the answer's owner is visible while several agents
|
|
124
|
+
* are running.
|
|
125
|
+
*/
|
|
126
|
+
orchestrationChildren?: ChildInfo[];
|
|
120
127
|
/**
|
|
121
128
|
* 轮中插队(streaming 期间 ⌘/Ctrl+Enter):优先把文本注入运行中的回合;注入
|
|
122
129
|
* 失败由 hook 兜底——回合仍在跑则排入 W6-2 follow-up 队列('queued',
|
|
@@ -821,6 +828,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
821
828
|
currentAgent,
|
|
822
829
|
agents = [],
|
|
823
830
|
chats = [],
|
|
831
|
+
orchestrationChildren = [],
|
|
824
832
|
selectedAgentId,
|
|
825
833
|
onSelectAgent,
|
|
826
834
|
onOpenSettings: _onOpenSettings,
|
|
@@ -841,6 +849,9 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
841
849
|
ref,
|
|
842
850
|
) {
|
|
843
851
|
const askUserPrompt = useAskUserPrompt(chatId);
|
|
852
|
+
// R7-3: which child is waiting on the user. The card says so, so the
|
|
853
|
+
// answer is not attributed to the parent's own reasoning.
|
|
854
|
+
const askUserSource = childAwaitingInput(orchestrationChildren);
|
|
844
855
|
const approvalPrompt = useApprovalPrompt(chatId);
|
|
845
856
|
const editorRef = useRef<HTMLDivElement>(null);
|
|
846
857
|
const agentMenuRef = useRef<HTMLDivElement>(null);
|
|
@@ -1811,6 +1822,16 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1811
1822
|
questions={request.questions}
|
|
1812
1823
|
onSubmit={askUserPrompt.answer}
|
|
1813
1824
|
onAutoContinue={() => askUserPrompt.answer({})}
|
|
1825
|
+
source={
|
|
1826
|
+
askUserSource
|
|
1827
|
+
? {
|
|
1828
|
+
childId: askUserSource.childId,
|
|
1829
|
+
...(askUserSource.profile
|
|
1830
|
+
? { profile: askUserSource.profile }
|
|
1831
|
+
: {}),
|
|
1832
|
+
}
|
|
1833
|
+
: undefined
|
|
1834
|
+
}
|
|
1814
1835
|
bottomHint={
|
|
1815
1836
|
askUserPrompt.pendingCount > 0
|
|
1816
1837
|
? t('{count} more question groups to answer', {
|
|
@@ -163,6 +163,13 @@ export interface LocalChatPanelProps {
|
|
|
163
163
|
onInspectTask?: (task: InspectTaskInput) => void;
|
|
164
164
|
/** 终态卡「忽略」(本次挂载内隐藏,不落库)。 */
|
|
165
165
|
onDismissFinishedTask?: (taskId: string) => void;
|
|
166
|
+
/** R7:子代理面板的「继续」。 */
|
|
167
|
+
onContinueChild?: (childId: string, recordId: string) => void;
|
|
168
|
+
/** R7:子代理面板的「停止」。 */
|
|
169
|
+
onStopChild?: (childId: string) => void;
|
|
170
|
+
/** R7:子代理操作失败的原因(已关闭、不在运行等)。 */
|
|
171
|
+
childActionError?: string | null;
|
|
172
|
+
onDismissChildActionError?: () => void;
|
|
166
173
|
/** 分享当前对话(截图)。落到最近一条助手消息的时间戳行。 */
|
|
167
174
|
onShare?: () => Promise<boolean>;
|
|
168
175
|
/**
|
|
@@ -223,6 +230,10 @@ export function LocalChatPanel({
|
|
|
223
230
|
finishedTasks,
|
|
224
231
|
onInspectTask,
|
|
225
232
|
onDismissFinishedTask,
|
|
233
|
+
onContinueChild,
|
|
234
|
+
onStopChild,
|
|
235
|
+
childActionError,
|
|
236
|
+
onDismissChildActionError,
|
|
226
237
|
onShare,
|
|
227
238
|
suggestedReplies,
|
|
228
239
|
onSelectSuggestion,
|
|
@@ -437,6 +448,7 @@ export function LocalChatPanel({
|
|
|
437
448
|
currentAgent={currentAgent}
|
|
438
449
|
agents={agents}
|
|
439
450
|
chats={chats}
|
|
451
|
+
orchestrationChildren={currentTurnChildren}
|
|
440
452
|
selectedAgentId={selectedAgentId}
|
|
441
453
|
onSelectAgent={onSelectAgent}
|
|
442
454
|
onOpenSettings={onOpenSettings}
|
|
@@ -528,6 +540,10 @@ export function LocalChatPanel({
|
|
|
528
540
|
finishedTasks={finishedTasks}
|
|
529
541
|
onInspectTask={onInspectTask}
|
|
530
542
|
onDismissFinishedTask={onDismissFinishedTask}
|
|
543
|
+
onContinueChild={onContinueChild}
|
|
544
|
+
onStopChild={onStopChild}
|
|
545
|
+
childActionError={childActionError}
|
|
546
|
+
onDismissChildActionError={onDismissChildActionError}
|
|
531
547
|
onShare={onShare}
|
|
532
548
|
suggestedReplies={suggestedReplies}
|
|
533
549
|
onSelectSuggestion={onSelectSuggestion}
|
|
@@ -186,6 +186,12 @@ interface MessageListProps {
|
|
|
186
186
|
onInspectTask?: (task: InspectTaskInput) => void;
|
|
187
187
|
/** 点「忽略」:隐藏这条终态通知(本次挂载内,不落库)。 */
|
|
188
188
|
onDismissFinishedTask?: (taskId: string) => void;
|
|
189
|
+
/** R7:子代理面板的「继续」与「停止」。 */
|
|
190
|
+
onContinueChild?: (childId: string, recordId: string) => void;
|
|
191
|
+
onStopChild?: (childId: string) => void;
|
|
192
|
+
/** R7:子代理操作失败的原因(已关闭、不在运行等)。 */
|
|
193
|
+
childActionError?: string | null;
|
|
194
|
+
onDismissChildActionError?: () => void;
|
|
189
195
|
/** 分享当前对话(截图)。只画在最近一条助手消息的时间戳行上。 */
|
|
190
196
|
onShare?: () => Promise<boolean>;
|
|
191
197
|
/**
|
|
@@ -226,6 +232,10 @@ export function MessageList({
|
|
|
226
232
|
finishedTasks,
|
|
227
233
|
onInspectTask,
|
|
228
234
|
onDismissFinishedTask,
|
|
235
|
+
onContinueChild,
|
|
236
|
+
onStopChild,
|
|
237
|
+
childActionError,
|
|
238
|
+
onDismissChildActionError,
|
|
229
239
|
onShare,
|
|
230
240
|
suggestedReplies,
|
|
231
241
|
onSelectSuggestion,
|
|
@@ -559,6 +569,8 @@ export function MessageList({
|
|
|
559
569
|
turnFiles={turnFiles}
|
|
560
570
|
onShare={message.id === lastAssistantId ? onShare : undefined}
|
|
561
571
|
onInspectTask={onInspectTask}
|
|
572
|
+
onContinueChild={onContinueChild}
|
|
573
|
+
onStopChild={onStopChild}
|
|
562
574
|
/>
|
|
563
575
|
{!isStreaming &&
|
|
564
576
|
message.id === lastAssistantId &&
|
|
@@ -594,6 +606,28 @@ export function MessageList({
|
|
|
594
606
|
onDismiss={onDismissFinishedTask}
|
|
595
607
|
/>
|
|
596
608
|
) : null}
|
|
609
|
+
{/* R7:子代理操作失败(已关闭、不在运行)。与中断卡同列在尾部,
|
|
610
|
+
它回答的是「我点了继续,为什么没动」。 */}
|
|
611
|
+
{childActionError ? (
|
|
612
|
+
<div
|
|
613
|
+
className="mx-auto w-full max-w-3xl"
|
|
614
|
+
data-testid="child-action-error"
|
|
615
|
+
>
|
|
616
|
+
<div className="flex items-start justify-between gap-2 rounded-agent-md border border-agent-destructive/20 bg-agent-destructive/10 px-2.5 py-1.5 text-[11px] text-agent-destructive">
|
|
617
|
+
<span className="min-w-0 break-words">{childActionError}</span>
|
|
618
|
+
{onDismissChildActionError ? (
|
|
619
|
+
<button
|
|
620
|
+
type="button"
|
|
621
|
+
onClick={onDismissChildActionError}
|
|
622
|
+
className="shrink-0 rounded px-1 text-agent-destructive/70 hover:bg-agent-destructive/10 hover:text-agent-destructive"
|
|
623
|
+
aria-label={t('Dismiss')}
|
|
624
|
+
>
|
|
625
|
+
×
|
|
626
|
+
</button>
|
|
627
|
+
) : null}
|
|
628
|
+
</div>
|
|
629
|
+
</div>
|
|
630
|
+
) : null}
|
|
597
631
|
</div>
|
|
598
632
|
)}
|
|
599
633
|
</div>
|
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
OrchestrationPlanCard,
|
|
4
4
|
ORCHESTRATION_DOT_CLASS,
|
|
5
5
|
ORCHESTRATION_STATUS_LABEL,
|
|
6
|
+
type OrchestrationTaskStatus,
|
|
6
7
|
} from '@steerable/agent-ui/cards';
|
|
7
8
|
import {
|
|
8
9
|
childrenToCardModel,
|
|
9
10
|
findAgentForProfile,
|
|
11
|
+
isChildResumable,
|
|
10
12
|
shouldShowOrchestrationBoard,
|
|
11
13
|
type ChildInfo,
|
|
12
14
|
} from './orchestration-children-model';
|
|
@@ -14,28 +16,22 @@ import type { LocalChatAgent } from '@/lib/local-api';
|
|
|
14
16
|
import { t } from '@/i18n';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
|
-
* OrchestrationChildrenCard — the desktop surface of the framework's
|
|
18
|
-
* multi-agent
|
|
19
|
-
*
|
|
20
|
-
* `OrchestrationPlanCard`: one row per child,
|
|
21
|
-
*
|
|
22
|
-
* step: the plan IS the set of spawned children.
|
|
19
|
+
* OrchestrationChildrenCard — the desktop surface of the framework's
|
|
20
|
+
* multi-agent layer (R7). Adapts the live `ChildInfo` list (accumulated from
|
|
21
|
+
* `orchestration_child` SSE events) onto the framework's
|
|
22
|
+
* `OrchestrationPlanCard`: one row per child, with the profile, depth, status,
|
|
23
|
+
* token bill, elapsed time and the row's two actions.
|
|
23
24
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* user bubbles. Status labels and dot colors come from the card's own
|
|
27
|
-
* exported tables so the two surfaces cannot drift.
|
|
25
|
+
* The card payload is synthesized from lifecycle events, so there is no
|
|
26
|
+
* separate "plan" step: the plan IS the set of spawned children.
|
|
28
27
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* already shows 「委派 ·」.
|
|
28
|
+
* Rows are overridden (`renderTaskRow`) because the shape the card renders by
|
|
29
|
+
* default (a task list) is not what a sub-agent is: this row carries a
|
|
30
|
+
* lifetime measurement and a resume action, neither of which a plan task has.
|
|
33
31
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `ChildInfo` and the event fold stay in use — they feed the turn's agent
|
|
38
|
-
* badges — so putting the board back is one JSX line in `AssistantMessage`.
|
|
32
|
+
* The mapping logic lives in `./orchestration-children-model` (pure,
|
|
33
|
+
* runtime-dependency-free) so node-side tests do not pull the agent-ui dist
|
|
34
|
+
* build.
|
|
39
35
|
*/
|
|
40
36
|
|
|
41
37
|
export type { ChildInfo } from './orchestration-children-model';
|
|
@@ -43,9 +39,18 @@ export type { ChildInfo } from './orchestration-children-model';
|
|
|
43
39
|
export function OrchestrationChildrenCard({
|
|
44
40
|
children,
|
|
45
41
|
agents = [],
|
|
42
|
+
onViewProcess,
|
|
43
|
+
onContinue,
|
|
44
|
+
onStop,
|
|
46
45
|
}: {
|
|
47
46
|
children: ChildInfo[];
|
|
48
47
|
agents?: ReadonlyArray<Pick<LocalChatAgent, 'id' | 'slug' | 'name' | 'color'>>;
|
|
48
|
+
/** 「查看过程」— opens the child's own record in the process panel. */
|
|
49
|
+
onViewProcess?: (recordId: string) => void;
|
|
50
|
+
/** 「继续」— resumes an interrupted or budget-stopped child. */
|
|
51
|
+
onContinue?: (childId: string, recordId: string) => void;
|
|
52
|
+
/** 「停止」— cooperatively interrupts a running child. */
|
|
53
|
+
onStop?: (childId: string) => void;
|
|
49
54
|
}) {
|
|
50
55
|
const { payload, taskStatuses } = useMemo(
|
|
51
56
|
() => childrenToCardModel(children),
|
|
@@ -61,18 +66,27 @@ export function OrchestrationChildrenCard({
|
|
|
61
66
|
headerLabel={delegateOnly ? t('Subagents') : undefined}
|
|
62
67
|
hideMode={delegateOnly}
|
|
63
68
|
renderTaskRow={(task, status) => {
|
|
69
|
+
const child = children.find((item) => item.childId === task.id);
|
|
64
70
|
// 没有匹配的智能体:编排六件套的子代理(只有 lineage id)或被删掉的
|
|
65
71
|
// 智能体,显示画像原文。
|
|
66
72
|
const agent = findAgentForProfile(task.agentId, agents);
|
|
67
73
|
const displayName = agent?.name ?? task.agentId;
|
|
74
|
+
const depth = child?.depth;
|
|
75
|
+
const running = status === 'running';
|
|
68
76
|
return (
|
|
69
|
-
<li
|
|
77
|
+
<li
|
|
78
|
+
className="flex items-start gap-2 text-sm"
|
|
79
|
+
data-testid={`orchestration-child-${task.id}`}
|
|
80
|
+
// Grandchildren sit one step in, so the shape of the tree is
|
|
81
|
+
// visible without expanding anything.
|
|
82
|
+
style={depth && depth > 1 ? { paddingLeft: `${(depth - 1) * 14}px` } : undefined}
|
|
83
|
+
>
|
|
70
84
|
<span
|
|
71
85
|
className={`mt-1.5 h-2 w-2 flex-shrink-0 rounded-full ${ORCHESTRATION_DOT_CLASS[status]}`}
|
|
72
86
|
aria-hidden
|
|
73
87
|
/>
|
|
74
88
|
<div className="min-w-0 flex-1">
|
|
75
|
-
<div className="flex items-center gap-2">
|
|
89
|
+
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
|
76
90
|
<span
|
|
77
91
|
data-agent-color-dot=""
|
|
78
92
|
className="inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full text-[8px] font-semibold text-white"
|
|
@@ -81,13 +95,73 @@ export function OrchestrationChildrenCard({
|
|
|
81
95
|
>
|
|
82
96
|
{displayName.trim()[0]?.toUpperCase() ?? 'A'}
|
|
83
97
|
</span>
|
|
98
|
+
<span className="font-mono text-[11px] text-[var(--agent-muted-foreground,#6b7280)]">
|
|
99
|
+
{task.id}
|
|
100
|
+
</span>
|
|
84
101
|
<span className="font-medium text-[var(--agent-foreground,#111827)]">
|
|
85
102
|
{displayName}
|
|
86
103
|
</span>
|
|
104
|
+
{depth ? (
|
|
105
|
+
<span className="text-[10px] text-[var(--agent-muted-foreground,#6b7280)]">
|
|
106
|
+
{t('Depth {n}', { n: depth })}
|
|
107
|
+
</span>
|
|
108
|
+
) : null}
|
|
87
109
|
<span className="text-xs text-[var(--agent-muted-foreground,#6b7280)]">
|
|
88
|
-
{
|
|
110
|
+
{childRowStatusLabel(child, status)}
|
|
111
|
+
</span>
|
|
112
|
+
{child?.elapsedMs !== undefined ? (
|
|
113
|
+
<span className="text-[10px] tabular-nums text-[var(--agent-muted-foreground,#6b7280)]">
|
|
114
|
+
{formatElapsed(child.elapsedMs)}
|
|
115
|
+
</span>
|
|
116
|
+
) : null}
|
|
117
|
+
<span className="text-[10px] tabular-nums text-[var(--agent-muted-foreground,#6b7280)]">
|
|
118
|
+
{formatChildBill(child)}
|
|
119
|
+
</span>
|
|
120
|
+
<span className="ml-auto flex items-center gap-1.5">
|
|
121
|
+
{running && onStop ? (
|
|
122
|
+
<button
|
|
123
|
+
type="button"
|
|
124
|
+
onClick={() => onStop(task.id)}
|
|
125
|
+
className="rounded-full border border-agent-border px-1.5 py-0.5 text-[10px] text-agent-muted-foreground transition-colors hover:bg-agent-muted hover:text-agent-foreground"
|
|
126
|
+
data-testid={`orchestration-child-stop-${task.id}`}
|
|
127
|
+
>
|
|
128
|
+
{t('Stop')}
|
|
129
|
+
</button>
|
|
130
|
+
) : null}
|
|
131
|
+
{!running && child && isChildResumable(child) && onContinue ? (
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
onClick={() => onContinue(task.id, child.recordId ?? '')}
|
|
135
|
+
className="rounded-full border border-agent-border px-1.5 py-0.5 text-[10px] text-agent-muted-foreground transition-colors hover:bg-agent-muted hover:text-agent-foreground"
|
|
136
|
+
data-testid={`orchestration-child-continue-${task.id}`}
|
|
137
|
+
>
|
|
138
|
+
{t('Continue')}
|
|
139
|
+
</button>
|
|
140
|
+
) : null}
|
|
141
|
+
{child?.recordId && onViewProcess ? (
|
|
142
|
+
<button
|
|
143
|
+
type="button"
|
|
144
|
+
onClick={() => onViewProcess(child.recordId as string)}
|
|
145
|
+
className="rounded-full border border-agent-border px-1.5 py-0.5 text-[10px] text-agent-muted-foreground transition-colors hover:bg-agent-muted hover:text-agent-foreground"
|
|
146
|
+
aria-label={t('View process')}
|
|
147
|
+
title={t('View process')}
|
|
148
|
+
data-testid={`orchestration-child-process-${task.id}`}
|
|
149
|
+
>
|
|
150
|
+
…
|
|
151
|
+
</button>
|
|
152
|
+
) : null}
|
|
89
153
|
</span>
|
|
90
154
|
</div>
|
|
155
|
+
{child?.cacheNote === 'cold' ? (
|
|
156
|
+
// R2 允许 fork 换模型,代价是父历史整体重算缓存。这是提示,
|
|
157
|
+
// 不是错误——状态点不变色。
|
|
158
|
+
<p
|
|
159
|
+
className="mt-0.5 text-[10px] text-[var(--agent-muted-foreground,#6b7280)]"
|
|
160
|
+
title={`${child.parentModel ?? ''} → ${child.childModel ?? ''}`}
|
|
161
|
+
>
|
|
162
|
+
{t('Model switched · cache recomputed')}
|
|
163
|
+
</p>
|
|
164
|
+
) : null}
|
|
91
165
|
{task.prompt ? (
|
|
92
166
|
<p className="mt-0.5 line-clamp-2 text-xs text-[var(--agent-muted-foreground,#6b7280)]">
|
|
93
167
|
{task.prompt}
|
|
@@ -102,4 +176,48 @@ export function OrchestrationChildrenCard({
|
|
|
102
176
|
);
|
|
103
177
|
}
|
|
104
178
|
|
|
179
|
+
/**
|
|
180
|
+
* A row's status text.
|
|
181
|
+
*
|
|
182
|
+
* Two cases the card's own table cannot express: a child blocked on the user
|
|
183
|
+
* is not "paused" (nothing will resume it but an answer), and one whose
|
|
184
|
+
* question has been answered and handed to a new child is finished, not
|
|
185
|
+
* waiting. Both are the whole point of the source annotation.
|
|
186
|
+
*/
|
|
187
|
+
function childRowStatusLabel(
|
|
188
|
+
child: ChildInfo | undefined,
|
|
189
|
+
status: OrchestrationTaskStatus,
|
|
190
|
+
): string {
|
|
191
|
+
if (child?.needsInput) return t('Waiting for your answer');
|
|
192
|
+
if (child?.handedOver) return t('Finished · handed over');
|
|
193
|
+
return ORCHESTRATION_STATUS_LABEL[status];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A child's token bill, or the fact that its engine does not report one.
|
|
198
|
+
*
|
|
199
|
+
* The distinction is the whole point: "0 tok" reads as a free run, while an
|
|
200
|
+
* external ACP child really spent tokens nobody counted.
|
|
201
|
+
*/
|
|
202
|
+
function formatChildBill(child: ChildInfo | undefined): string {
|
|
203
|
+
if (!child) return '';
|
|
204
|
+
if (child.status === 'running') return '';
|
|
205
|
+
if (!child.usage) return t('Not counted');
|
|
206
|
+
return `${formatTokens(child.usage.totalTokens)} tok`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function formatTokens(n: number): string {
|
|
210
|
+
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(2)}M`;
|
|
211
|
+
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}k`;
|
|
212
|
+
return String(n);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function formatElapsed(ms: number): string {
|
|
216
|
+
if (ms < 1000) return `${ms}ms`;
|
|
217
|
+
const seconds = ms / 1000;
|
|
218
|
+
if (seconds < 60) return `${seconds.toFixed(1)}s`;
|
|
219
|
+
const minutes = Math.floor(seconds / 60);
|
|
220
|
+
return `${minutes}m${Math.round(seconds - minutes * 60)}s`;
|
|
221
|
+
}
|
|
222
|
+
|
|
105
223
|
export default OrchestrationChildrenCard;
|