@steerable/agent-ui 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cards/ActionSegmentCard.stories.d.ts +6 -0
- package/dist/cards/ActionSegmentCard.stories.js +48 -0
- package/dist/cards/AnalysisDocumentCard.js +1 -1
- package/dist/cards/AnalysisDocumentCard.stories.d.ts +6 -0
- package/dist/cards/AnalysisDocumentCard.stories.js +29 -0
- package/dist/cards/AskUserQuestionsCard.js +7 -7
- package/dist/cards/AskUserQuestionsCard.stories.d.ts +7 -0
- package/dist/cards/AskUserQuestionsCard.stories.js +56 -0
- package/dist/cards/CoverageReportCard.js +4 -4
- package/dist/cards/CoverageReportCard.stories.d.ts +6 -0
- package/dist/cards/CoverageReportCard.stories.js +69 -0
- package/dist/cards/OrchestrationPlanCard.js +5 -5
- package/dist/cards/OrchestrationPlanCard.stories.d.ts +6 -0
- package/dist/cards/OrchestrationPlanCard.stories.js +36 -0
- package/dist/cards/PlanSelectorCard.js +11 -11
- package/dist/cards/PlanSelectorCard.stories.d.ts +6 -0
- package/dist/cards/PlanSelectorCard.stories.js +50 -0
- package/dist/cards/PlanStepsCard.js +1 -1
- package/dist/cards/PlanStepsCard.stories.d.ts +6 -0
- package/dist/cards/PlanStepsCard.stories.js +25 -0
- package/dist/cards/QuizCard.js +3 -3
- package/dist/cards/QuizCard.stories.d.ts +6 -0
- package/dist/cards/QuizCard.stories.js +43 -0
- package/dist/cards/ResearchPlanCard.js +10 -10
- package/dist/cards/ResearchPlanCard.stories.d.ts +6 -0
- package/dist/cards/ResearchPlanCard.stories.js +50 -0
- package/dist/cards/SearchSourcesCard.js +4 -4
- package/dist/cards/SearchSourcesCard.stories.d.ts +6 -0
- package/dist/cards/SearchSourcesCard.stories.js +40 -0
- package/dist/cards/SuggestedRepliesCard.stories.d.ts +6 -0
- package/dist/cards/SuggestedRepliesCard.stories.js +31 -0
- package/dist/cards/SummaryMessageCard.js +3 -3
- package/dist/cards/SummaryMessageCard.stories.d.ts +7 -0
- package/dist/cards/SummaryMessageCard.stories.js +40 -0
- package/dist/cards/ThinkingProcessCard.js +3 -3
- package/dist/cards/ThinkingProcessCard.stories.d.ts +7 -0
- package/dist/cards/ThinkingProcessCard.stories.js +37 -0
- package/dist/cards/ToolExecutionCard.js +7 -7
- package/dist/cards/ToolExecutionCard.stories.d.ts +7 -0
- package/dist/cards/ToolExecutionCard.stories.js +53 -0
- package/package.json +2 -2
- package/src/DesignTokens.mdx +83 -0
- package/src/Introduction.mdx +21 -21
- package/src/cards/ActionSegmentCard.stories.tsx +57 -0
- package/src/cards/AnalysisDocumentCard.stories.tsx +38 -0
- package/src/cards/AnalysisDocumentCard.tsx +3 -3
- package/src/cards/AskUserQuestionsCard.stories.tsx +66 -0
- package/src/cards/AskUserQuestionsCard.tsx +11 -11
- package/src/cards/CoverageReportCard.stories.tsx +78 -0
- package/src/cards/CoverageReportCard.tsx +12 -12
- package/src/cards/OrchestrationPlanCard.stories.tsx +45 -0
- package/src/cards/OrchestrationPlanCard.tsx +19 -19
- package/src/cards/PlanSelectorCard.stories.tsx +59 -0
- package/src/cards/PlanSelectorCard.tsx +19 -19
- package/src/cards/PlanStepsCard.stories.tsx +34 -0
- package/src/cards/PlanStepsCard.tsx +2 -2
- package/src/cards/QuizCard.stories.tsx +52 -0
- package/src/cards/QuizCard.tsx +5 -5
- package/src/cards/ResearchPlanCard.stories.tsx +59 -0
- package/src/cards/ResearchPlanCard.tsx +14 -14
- package/src/cards/SearchSourcesCard.stories.tsx +49 -0
- package/src/cards/SearchSourcesCard.tsx +10 -10
- package/src/cards/SuggestedRepliesCard.stories.tsx +40 -0
- package/src/cards/SummaryMessageCard.stories.tsx +50 -0
- package/src/cards/SummaryMessageCard.tsx +3 -3
- package/src/cards/ThinkingProcessCard.stories.tsx +47 -0
- package/src/cards/ThinkingProcessCard.tsx +4 -4
- package/src/cards/ToolExecutionCard.stories.tsx +63 -0
- package/src/cards/ToolExecutionCard.tsx +13 -13
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { ActionSegmentCard } from './ActionSegmentCard.js';
|
|
3
|
+
declare const meta: Meta<typeof ActionSegmentCard>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof ActionSegmentCard>;
|
|
6
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ActionSegmentCard } from './ActionSegmentCard.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Cards/ActionSegmentCard',
|
|
5
|
+
component: ActionSegmentCard,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: 'Groups sequential or parallel tool segments inside a single assistant turn using `ToolExecutionCard` rows.',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
decorators: [
|
|
15
|
+
(Story) => (_jsx("div", { className: "w-[480px]", children: _jsx(Story, {}) })),
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
export const Default = {
|
|
20
|
+
args: {
|
|
21
|
+
payload: {
|
|
22
|
+
segments: [
|
|
23
|
+
{
|
|
24
|
+
id: 'seg-1',
|
|
25
|
+
kind: 'local_read_file',
|
|
26
|
+
status: 'succeeded',
|
|
27
|
+
label: 'Read docs/spec/runtime-contract.json',
|
|
28
|
+
args: { path: 'docs/spec/runtime-contract.json' },
|
|
29
|
+
output: '38 RPC methods loaded',
|
|
30
|
+
error: null,
|
|
31
|
+
startedAt: null,
|
|
32
|
+
finishedAt: null,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'seg-2',
|
|
36
|
+
kind: 'local_exec_shell',
|
|
37
|
+
status: 'running',
|
|
38
|
+
label: 'Running conformance checks',
|
|
39
|
+
args: { command: 'pnpm --filter @steerable/agent-protocol test' },
|
|
40
|
+
output: null,
|
|
41
|
+
error: null,
|
|
42
|
+
startedAt: null,
|
|
43
|
+
finishedAt: null,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -5,6 +5,6 @@ export const AnalysisDocumentCard = ({ payload, renderMarkdown, renderFooter, cl
|
|
|
5
5
|
return (_jsxs("article", { className: [
|
|
6
6
|
'steerable-analysis-document overflow-hidden rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm text-[var(--agent-foreground,#111827)]',
|
|
7
7
|
className,
|
|
8
|
-
].filter(Boolean).join(' '), children: [payload.title && headerVariant === 'strip' ? (_jsx("div", { className: "border-b border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-muted,#f3f4f6)]/50 px-4 py-2", children: _jsx("span", { className: "block truncate text-xs font-medium text-[var(--agent-muted-foreground,#
|
|
8
|
+
].filter(Boolean).join(' '), children: [payload.title && headerVariant === 'strip' ? (_jsx("div", { className: "border-b border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-muted,#f3f4f6)]/50 px-4 py-2", children: _jsx("span", { className: "block truncate text-xs font-medium text-[var(--agent-muted-foreground,#4b5563)]", children: payload.title }) })) : (_jsxs("header", { className: "mb-3 flex items-center gap-2 border-b border-[var(--agent-border,#e5e7eb)] px-4 pt-3 pb-2", children: [_jsx(BookIcon, { size: 14, className: "text-[var(--agent-muted-foreground,#4b5563)]" }), _jsx("h3", { className: "text-sm font-medium", children: payload.title || '分析报告' }), payload.modelId && (_jsx("span", { className: "ml-auto rounded-full bg-[var(--agent-muted,#f3f4f6)] px-2 py-0.5 text-[10px] uppercase tracking-wider text-[var(--agent-muted-foreground,#4b5563)]", children: payload.modelId }))] })), _jsx("div", { className: ['p-4', bodyClassName].filter(Boolean).join(' '), children: renderMarkdown ? (asReactNode(renderMarkdown(payload.body))) : (_jsx("pre", { className: "whitespace-pre-wrap break-words font-sans", children: payload.body })) }), renderFooter && asReactNode(renderFooter())] }));
|
|
9
9
|
};
|
|
10
10
|
export default AnalysisDocumentCard;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { AnalysisDocumentCard } from './AnalysisDocumentCard.js';
|
|
3
|
+
declare const meta: Meta<typeof AnalysisDocumentCard>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof AnalysisDocumentCard>;
|
|
6
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AnalysisDocumentCard } from './AnalysisDocumentCard.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Cards/AnalysisDocumentCard',
|
|
5
|
+
component: AnalysisDocumentCard,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: 'Structured long-form analysis report container with pluggable `renderMarkdown` and footer slots.',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
decorators: [
|
|
15
|
+
(Story) => (_jsx("div", { className: "w-[520px]", children: _jsx(Story, {}) })),
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
export const Default = {
|
|
20
|
+
args: {
|
|
21
|
+
payload: {
|
|
22
|
+
title: 'Sandbox & Egress Confinement Audit',
|
|
23
|
+
createdAt: '2026-11-17T09:00:00Z',
|
|
24
|
+
modelId: 'glm-5.3-flash',
|
|
25
|
+
body: 'All 38 JSON-RPC sidecar methods operate under Seatbelt/bwrap confinement with per-host CONNECT allow-listing.',
|
|
26
|
+
},
|
|
27
|
+
renderMarkdown: (body) => _jsx("p", { className: "text-sm leading-relaxed", children: body }),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -143,11 +143,11 @@ allowCustomText = true, requireAllAnswered = false, submitLabel = '提交', mult
|
|
|
143
143
|
return (_jsx("div", { className: [
|
|
144
144
|
'steerable-ask-user overflow-hidden rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm text-[var(--agent-foreground,#111827)]',
|
|
145
145
|
className,
|
|
146
|
-
].filter(Boolean).join(' '), children: _jsxs("div", { className: "space-y-4 p-3", children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-1 items-start gap-2", children: [!payload.intro && (_jsx(MessageQuestionIcon, { size: 14, className: "mt-0.5 text-[var(--agent-muted-foreground,#
|
|
146
|
+
].filter(Boolean).join(' '), children: _jsxs("div", { className: "space-y-4 p-3", children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-1 items-start gap-2", children: [!payload.intro && (_jsx(MessageQuestionIcon, { size: 14, className: "mt-0.5 text-[var(--agent-muted-foreground,#4b5563)]" })), payload.intro ? (_jsx("p", { className: "flex-1 text-sm", children: payload.intro })) : (_jsx("span", { className: "font-medium", children: "\u9700\u8981\u4F60\u7684\u8F93\u5165" }))] }), !isReadOnly && onAutoContinue && (_jsxs("button", { type: "button", onClick: onAutoContinue, className: "inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] px-3 py-1 text-xs font-medium text-[var(--agent-foreground,#111827)] transition-all duration-200 hover:bg-[var(--agent-muted,#f3f4f6)]", children: [_jsx(CheckIcon, { size: 12 }), autoContinueLabel] }))] }), _jsx("ol", { className: "space-y-3", children: (payload.questions ?? []).map((q, idx) => {
|
|
147
147
|
const value = draft[q.id];
|
|
148
148
|
const inputOnly = isInputOnly(q);
|
|
149
149
|
const isCustom = allowCustomText && customMode[q.id];
|
|
150
|
-
return (_jsxs("li", { className: "space-y-2", children: [_jsx("div", { className: "flex items-center gap-2", children: q.header && (_jsx("span", { className: "inline-flex items-center rounded-full bg-[var(--agent-muted,#f3f4f6)] px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-[var(--agent-muted-foreground,#
|
|
150
|
+
return (_jsxs("li", { className: "space-y-2", children: [_jsx("div", { className: "flex items-center gap-2", children: q.header && (_jsx("span", { className: "inline-flex items-center rounded-full bg-[var(--agent-muted,#f3f4f6)] px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-[var(--agent-muted-foreground,#4b5563)]", children: q.header })) }), _jsxs("p", { className: "text-sm font-medium", children: [idx + 1, ". ", q.text, !inputOnly && q.multiSelect && (_jsx("span", { className: "ml-1.5 text-xs font-normal text-[var(--agent-muted-foreground,#4b5563)]", children: multiSelectLabel }))] }), inputOnly && (_jsx("input", { type: q.type === 'password' ? 'password' : 'text', disabled: isReadOnly, placeholder: q.placeholder || (q.type === 'password' ? '输入密码' : '输入你的回答...'), value: customText[q.id] || '', onChange: (e) => setCustomText((p) => ({ ...p, [q.id]: e.target.value })), className: "w-full rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] px-3 py-1.5 text-xs text-[var(--agent-foreground,#111827)] outline-none placeholder:text-[var(--agent-muted-foreground,#4b5563)] focus:border-[var(--agent-primary,#18181b)] focus:ring-1 focus:ring-[var(--agent-primary,#18181b)] disabled:cursor-not-allowed disabled:opacity-60" })), !inputOnly && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-wrap gap-2", children: [(q.options ?? []).map((opt) => {
|
|
151
151
|
const selected = !isCustom &&
|
|
152
152
|
(q.multiSelect
|
|
153
153
|
? (Array.isArray(value) ? value : []).includes(opt)
|
|
@@ -156,17 +156,17 @@ allowCustomText = true, requireAllAnswered = false, submitLabel = '提交', mult
|
|
|
156
156
|
'rounded-full border px-3 py-1.5 text-xs font-medium transition-all duration-200',
|
|
157
157
|
selected
|
|
158
158
|
? 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-muted,#f3f4f6)] text-[var(--agent-foreground,#111827)] ring-1 ring-[var(--agent-border,#e5e7eb)]'
|
|
159
|
-
: 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-[var(--agent-muted-foreground,#
|
|
159
|
+
: 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-[var(--agent-muted-foreground,#4b5563)] hover:bg-[var(--agent-muted,#f3f4f6)] hover:text-[var(--agent-foreground,#111827)]',
|
|
160
160
|
isReadOnly ? 'cursor-not-allowed opacity-60' : 'cursor-pointer',
|
|
161
161
|
].join(' '), children: [q.multiSelect && selected && (_jsx(CheckIcon, { size: 10, className: "-ml-0.5 mr-1 inline" })), opt] }, opt));
|
|
162
162
|
}), allowCustomText && !isCustom && (_jsx("button", { type: "button", disabled: isReadOnly, onClick: () => enterCustom(q.id), className: [
|
|
163
|
-
'rounded-full border border-dashed border-[var(--agent-border,#e5e7eb)] px-3 py-1.5 text-xs font-medium text-[var(--agent-muted-foreground,#
|
|
163
|
+
'rounded-full border border-dashed border-[var(--agent-border,#e5e7eb)] px-3 py-1.5 text-xs font-medium text-[var(--agent-muted-foreground,#4b5563)] transition-all duration-200 hover:bg-[var(--agent-muted,#f3f4f6)] hover:text-[var(--agent-foreground,#111827)]',
|
|
164
164
|
isReadOnly ? 'cursor-not-allowed opacity-60' : 'cursor-pointer',
|
|
165
|
-
].join(' '), children: _jsxs("span", { className: "inline-flex items-center gap-1", children: [_jsx(PencilIcon, { size: 12 }), customLabel] }) }))] }), isCustom && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("input", { type: "text", disabled: isReadOnly, placeholder: "\u8F93\u5165\u4F60\u7684\u56DE\u7B54...", value: customText[q.id] || '', onChange: (e) => setCustomText((p) => ({ ...p, [q.id]: e.target.value })), className: "flex-1 rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] px-3 py-1.5 text-xs text-[var(--agent-foreground,#111827)] outline-none placeholder:text-[var(--agent-muted-foreground,#
|
|
166
|
-
}) }), payload.outro && (_jsx("p", { className: "text-xs text-[var(--agent-muted-foreground,#
|
|
165
|
+
].join(' '), children: _jsxs("span", { className: "inline-flex items-center gap-1", children: [_jsx(PencilIcon, { size: 12 }), customLabel] }) }))] }), isCustom && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("input", { type: "text", disabled: isReadOnly, placeholder: "\u8F93\u5165\u4F60\u7684\u56DE\u7B54...", value: customText[q.id] || '', onChange: (e) => setCustomText((p) => ({ ...p, [q.id]: e.target.value })), className: "flex-1 rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] px-3 py-1.5 text-xs text-[var(--agent-foreground,#111827)] outline-none placeholder:text-[var(--agent-muted-foreground,#4b5563)] focus:border-[var(--agent-primary,#18181b)] focus:ring-1 focus:ring-[var(--agent-primary,#18181b)] disabled:cursor-not-allowed disabled:opacity-60" }), _jsx("button", { type: "button", disabled: isReadOnly, onClick: () => cancelCustom(q.id), className: "text-xs text-[var(--agent-muted-foreground,#4b5563)] transition-colors duration-200 hover:text-[var(--agent-foreground,#111827)]", children: "\u53D6\u6D88" })] }))] }))] }, q.id));
|
|
166
|
+
}) }), payload.outro && (_jsx("p", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)] whitespace-pre-line", children: payload.outro })), !isReadOnly && onSubmit && (_jsxs("div", { className: "flex items-center justify-between pt-1", children: [_jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: bottomHint }), _jsxs("button", { type: "button", onClick: handleSubmit, disabled: submitting || (requireAllAnswered && !allAnswered), className: [
|
|
167
167
|
'inline-flex items-center gap-1.5 rounded-full px-4 py-1.5 text-xs font-medium transition-all duration-200',
|
|
168
168
|
submitting || (requireAllAnswered && !allAnswered)
|
|
169
|
-
? 'cursor-not-allowed bg-[var(--agent-muted,#f3f4f6)] text-[var(--agent-muted-foreground,#
|
|
169
|
+
? 'cursor-not-allowed bg-[var(--agent-muted,#f3f4f6)] text-[var(--agent-muted-foreground,#4b5563)]'
|
|
170
170
|
: 'bg-[var(--agent-primary,#18181b)] text-[var(--agent-primary-foreground,#fff)] shadow-sm hover:opacity-90',
|
|
171
171
|
].join(' '), children: [submitting ? _jsx(LoaderIcon, { size: 10, className: "animate-spin" }) : _jsx(CheckIcon, { size: 12 }), submitLabel] })] }))] }) }));
|
|
172
172
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { AskUserQuestionsCard } from './AskUserQuestionsCard.js';
|
|
3
|
+
declare const meta: Meta<typeof AskUserQuestionsCard>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof AskUserQuestionsCard>;
|
|
6
|
+
export declare const Interactive: Story;
|
|
7
|
+
export declare const Answered: Story;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AskUserQuestionsCard } from './AskUserQuestionsCard.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Cards/AskUserQuestionsCard',
|
|
5
|
+
component: AskUserQuestionsCard,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: 'Structured multi-question prompt emitted by `ask_user`, supporting single-select, multi-select, custom free-text, and read-only answered states.',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
decorators: [
|
|
16
|
+
(Story) => (_jsx("div", { className: "w-[480px]", children: _jsx(Story, {}) })),
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
export default meta;
|
|
20
|
+
export const Interactive = {
|
|
21
|
+
args: {
|
|
22
|
+
allowCustomText: true,
|
|
23
|
+
onSubmit: () => { },
|
|
24
|
+
onAutoContinue: () => { },
|
|
25
|
+
payload: {
|
|
26
|
+
intro: 'Choose how to configure the sandbox before running tests:',
|
|
27
|
+
questions: [
|
|
28
|
+
{
|
|
29
|
+
id: 'q1',
|
|
30
|
+
text: 'Which egress policy should this session enforce?',
|
|
31
|
+
type: 'select',
|
|
32
|
+
options: ['Allow-list only (recommended)', 'Offline (no network)', 'Audit mode'],
|
|
33
|
+
multiSelect: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const Answered = {
|
|
40
|
+
args: {
|
|
41
|
+
onSubmit: () => { },
|
|
42
|
+
payload: {
|
|
43
|
+
intro: 'Choose how to configure the sandbox before running tests:',
|
|
44
|
+
questions: [
|
|
45
|
+
{
|
|
46
|
+
id: 'q1',
|
|
47
|
+
text: 'Which egress policy should this session enforce?',
|
|
48
|
+
type: 'select',
|
|
49
|
+
options: ['Allow-list only (recommended)', 'Offline (no network)'],
|
|
50
|
+
multiSelect: false,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
answers: { q1: 'Allow-list only (recommended)' },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -44,11 +44,11 @@ export const CoverageReportCard = ({ payload, isComplete, onRemediate, className
|
|
|
44
44
|
return (_jsx("div", { className: [
|
|
45
45
|
'steerable-coverage-report rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm text-[var(--agent-foreground,#111827)]',
|
|
46
46
|
className,
|
|
47
|
-
].filter(Boolean).join(' '), children: _jsxs("div", { className: "space-y-3 p-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(ChartIcon, { size: 14, className: "text-blue-500" }), _jsx("span", { className: "font-medium", children: payload.title }), isComplete && _jsx(CheckIcon, { size: 12, className: "text-emerald-600" })] }), _jsxs("div", { className: "grid grid-cols-2 gap-2", children: [_jsxs("div", { className: "rounded-md border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] p-2", children: [_jsx("p", { className: "text-[11px] text-[var(--agent-muted-foreground,#
|
|
47
|
+
].filter(Boolean).join(' '), children: _jsxs("div", { className: "space-y-3 p-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(ChartIcon, { size: 14, className: "text-blue-500" }), _jsx("span", { className: "font-medium", children: payload.title }), isComplete && _jsx(CheckIcon, { size: 12, className: "text-emerald-600" })] }), _jsxs("div", { className: "grid grid-cols-2 gap-2", children: [_jsxs("div", { className: "rounded-md border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] p-2", children: [_jsx("p", { className: "text-[11px] text-[var(--agent-muted-foreground,#4b5563)]", children: "\u6574\u4F53\u8986\u76D6\u7387" }), _jsx("p", { className: "text-base font-semibold", children: pct(payload.overallCoverage) })] }), _jsxs("div", { className: "rounded-md border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] p-2", children: [_jsx("p", { className: "text-[11px] text-[var(--agent-muted-foreground,#4b5563)]", children: "\u6574\u4F53\u638C\u63E1\u7387" }), _jsx("p", { className: "text-base font-semibold", children: pct(payload.overallMastery) })] })] }), payload.summary && (_jsx("p", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)] whitespace-pre-line", children: payload.summary })), _jsx("div", { className: "space-y-2", children: sections.map((section) => {
|
|
48
48
|
const fill = progressMetric === 'coverage' ? section.coverage : section.mastery;
|
|
49
|
-
return (_jsxs("div", { className: "rounded-md border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] p-2", children: [_jsxs("div", { className: "mb-1 flex items-center justify-between", children: [_jsx("span", { className: "text-sm font-medium", children: section.name }), _jsxs("span", { className: "text-xs text-[var(--agent-muted-foreground,#
|
|
49
|
+
return (_jsxs("div", { className: "rounded-md border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] p-2", children: [_jsxs("div", { className: "mb-1 flex items-center justify-between", children: [_jsx("span", { className: "text-sm font-medium", children: section.name }), _jsxs("span", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: ["\u8986\u76D6 ", pct(section.coverage), " \u00B7 \u638C\u63E1 ", pct(section.mastery)] })] }), _jsx("div", { className: "h-2 w-full overflow-hidden rounded-full bg-[var(--agent-muted,#f3f4f6)]", children: _jsx("div", { className: progressMetric === 'coverage'
|
|
50
50
|
? 'h-full bg-[var(--agent-primary,#18181b)] transition-all duration-200'
|
|
51
|
-
: 'h-full bg-emerald-500 transition-all duration-200', style: { width: pct(fill) }, "aria-hidden": true }) }), renderSectionStats && (_jsx("div", { className: "mt-1 text-[11px] text-[var(--agent-muted-foreground,#
|
|
52
|
-
}) }), _jsxs("div", { className: "space-y-2 rounded-md border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] p-2", children: [_jsxs("div", { className: "flex items-center gap-1.5 text-xs font-medium text-amber-
|
|
51
|
+
: 'h-full bg-emerald-500 transition-all duration-200', style: { width: pct(fill) }, "aria-hidden": true }) }), renderSectionStats && (_jsx("div", { className: "mt-1 text-[11px] text-[var(--agent-muted-foreground,#4b5563)]", children: asReactNode(renderSectionStats(section)) }))] }, section.id));
|
|
52
|
+
}) }), _jsxs("div", { className: "space-y-2 rounded-md border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] p-2", children: [_jsxs("div", { className: "flex items-center gap-1.5 text-xs font-medium text-amber-700 dark:text-amber-400", children: [_jsx(AlertIcon, { size: 12 }), "\u8584\u5F31\u77E5\u8BC6\u70B9"] }), weakPoints.length === 0 ? (emptyWeakPointsLabel ? (_jsxs("div", { className: "inline-flex items-center gap-1.5 text-xs text-green-700 dark:text-green-400", children: [_jsx(CheckIcon, { size: 12 }), emptyWeakPointsLabel] })) : null) : allowWeakPointSelection ? (_jsx("div", { className: "space-y-1.5", children: weakPoints.map((point) => (_jsxs("label", { className: "flex cursor-pointer items-start gap-2", children: [_jsx("input", { type: "checkbox", className: "mt-0.5 h-4 w-4", checked: selected.includes(point.id), onChange: () => toggle(point.id), disabled: remediateDisabled }), _jsxs("div", { className: "min-w-0 text-xs", children: [_jsxs("p", { className: "font-medium", children: [point.name, point.sectionName ? ` · ${point.sectionName}` : ''] }), _jsxs("p", { className: "text-[var(--agent-muted-foreground,#4b5563)]", children: ["\u6B63\u786E\u7387 ", pct(point.accuracy), " \u00B7 ", point.recommendation] })] })] }, point.id))) })) : (_jsx("ul", { className: "space-y-1 text-xs", children: weakPoints.map((wp) => (_jsxs("li", { children: [_jsx("span", { className: "font-medium", children: wp.name }), wp.sectionName && (_jsxs("span", { className: "ml-1 text-[var(--agent-muted-foreground,#4b5563)]", children: ["\u00B7 ", wp.sectionName] })), _jsxs("span", { className: "ml-1 text-[var(--agent-muted-foreground,#4b5563)]", children: ["\u00B7 \u6B63\u786E\u7387 ", pct(wp.accuracy)] }), _jsx("p", { className: "text-[var(--agent-muted-foreground,#4b5563)]", children: wp.recommendation })] }, wp.id))) }))] }), payload.actions?.allowRemediateQuiz && onRemediate && weakPoints.length > 0 && (_jsxs("div", { className: "flex items-center justify-between pt-1", children: [_jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: remediateHint }), _jsx("button", { type: "button", onClick: handleClick, disabled: remediateDisabled, className: "inline-flex h-[28px] items-center rounded-full bg-[var(--agent-primary,#18181b)] px-3 text-xs font-medium text-[var(--agent-primary-foreground,#fff)] transition-all duration-200 hover:opacity-90 disabled:opacity-50", children: remediateLabel || payload.actions.remediateActionLabel || '为薄弱点出题' })] }))] }) }));
|
|
53
53
|
};
|
|
54
54
|
export default CoverageReportCard;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { CoverageReportCard } from './CoverageReportCard.js';
|
|
3
|
+
declare const meta: Meta<typeof CoverageReportCard>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof CoverageReportCard>;
|
|
6
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CoverageReportCard } from './CoverageReportCard.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Cards/CoverageReportCard',
|
|
5
|
+
component: CoverageReportCard,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: 'Displays topic coverage, mastery metrics, weak points, and optional remediation selection.',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
decorators: [
|
|
16
|
+
(Story) => (_jsx("div", { className: "w-[520px]", children: _jsx(Story, {}) })),
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
export default meta;
|
|
20
|
+
export const Default = {
|
|
21
|
+
args: {
|
|
22
|
+
allowWeakPointSelection: true,
|
|
23
|
+
onRemediate: () => { },
|
|
24
|
+
payload: {
|
|
25
|
+
reportId: 'cov-1',
|
|
26
|
+
title: 'Harness Conformance Coverage',
|
|
27
|
+
overallCoverage: 0.86,
|
|
28
|
+
overallMastery: 0.79,
|
|
29
|
+
summary: 'Strong coverage on wire types and retries; two edge cases flagged for follow-up.',
|
|
30
|
+
sections: [
|
|
31
|
+
{
|
|
32
|
+
id: 'sec-proto',
|
|
33
|
+
name: 'Protocol Schema',
|
|
34
|
+
coverage: 0.95,
|
|
35
|
+
mastery: 0.92,
|
|
36
|
+
totalCount: 20,
|
|
37
|
+
learnedCount: 19,
|
|
38
|
+
testedCount: 19,
|
|
39
|
+
masteredCount: 18,
|
|
40
|
+
weakKpIds: [],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'sec-recovery',
|
|
44
|
+
name: 'Tool Recovery',
|
|
45
|
+
coverage: 0.78,
|
|
46
|
+
mastery: 0.68,
|
|
47
|
+
totalCount: 14,
|
|
48
|
+
learnedCount: 11,
|
|
49
|
+
testedCount: 11,
|
|
50
|
+
masteredCount: 10,
|
|
51
|
+
weakKpIds: ['wp-1'],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
weakPoints: [
|
|
55
|
+
{
|
|
56
|
+
id: 'wp-1',
|
|
57
|
+
name: 'Unclosed nested XML tool tag',
|
|
58
|
+
sectionName: 'Tool Recovery',
|
|
59
|
+
accuracy: 0.55,
|
|
60
|
+
recommendation: 'Add edge-case regression test for truncated XML parameters.',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
actions: {
|
|
64
|
+
allowRemediateQuiz: true,
|
|
65
|
+
remediateActionLabel: 'Practice weak points',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -38,7 +38,7 @@ const STATUS_LABEL = {
|
|
|
38
38
|
ask_user_paused: '等待用户',
|
|
39
39
|
};
|
|
40
40
|
const DOT_CLASS = {
|
|
41
|
-
pending: 'bg-[var(--agent-muted-foreground,#
|
|
41
|
+
pending: 'bg-[var(--agent-muted-foreground,#4b5563)]',
|
|
42
42
|
running: 'bg-amber-500 animate-pulse',
|
|
43
43
|
ok: 'bg-emerald-500',
|
|
44
44
|
skipped: 'bg-[var(--agent-muted-foreground,#d1d5db)]',
|
|
@@ -61,14 +61,14 @@ export const OrchestrationPlanCard = ({ payload, taskStatuses, agentNameFor, cla
|
|
|
61
61
|
return (_jsxs("div", { className: [
|
|
62
62
|
'steerable-orchestration-plan',
|
|
63
63
|
className,
|
|
64
|
-
].filter(Boolean).join(' '), children: [above, _jsxs("div", { className: "rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm shadow-sm", children: [_jsxs("div", { className: "flex w-full items-center gap-2 px-3 py-2 text-xs text-[var(--agent-muted-foreground,#
|
|
64
|
+
].filter(Boolean).join(' '), children: [above, _jsxs("div", { className: "rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm shadow-sm", children: [_jsxs("div", { className: "flex w-full items-center gap-2 px-3 py-2 text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: [_jsx(LoaderIcon, { size: 14, className: "shrink-0 animate-spin" }), _jsx(GitBranchIcon, { size: 14, className: "shrink-0" }), _jsxs("span", { className: "inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap", children: [headerLabel ?? (_jsx("span", { className: "font-medium text-[var(--agent-foreground,#111827)]", children: "\u534F\u8C03\u5458" })), _jsx("span", { className: "text-[var(--agent-muted-foreground,#4b5563)]", children: "\u00B7" }), _jsx("span", { children: loadingHint ?? '正在规划' })] })] }), belowHeader] })] }));
|
|
65
65
|
}
|
|
66
66
|
// ---------------- failed shell ----------------
|
|
67
67
|
if (failed) {
|
|
68
68
|
return (_jsxs("div", { className: [
|
|
69
69
|
'steerable-orchestration-plan',
|
|
70
70
|
className,
|
|
71
|
-
].filter(Boolean).join(' '), children: [above, _jsxs("div", { className: "rounded-lg border border-rose-500/30 bg-rose-500/5 text-sm shadow-sm", children: [_jsxs("div", { className: "flex w-full items-start gap-2 px-3 py-2 text-xs", children: [_jsx(AlertIcon, { size: 14, className: "mt-0.5 shrink-0 text-rose-
|
|
71
|
+
].filter(Boolean).join(' '), children: [above, _jsxs("div", { className: "rounded-lg border border-rose-500/30 bg-rose-500/5 text-sm shadow-sm", children: [_jsxs("div", { className: "flex w-full items-start gap-2 px-3 py-2 text-xs", children: [_jsx(AlertIcon, { size: 14, className: "mt-0.5 shrink-0 text-rose-700" }), _jsx(GitBranchIcon, { size: 14, className: "mt-0.5 shrink-0 text-[var(--agent-muted-foreground,#4b5563)]" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "inline-flex items-center gap-1.5 whitespace-nowrap", children: [headerLabel ?? (_jsx("span", { className: "font-medium text-[var(--agent-foreground,#111827)]", children: "\u534F\u8C03\u5458" })), _jsx("span", { className: "text-[var(--agent-muted-foreground,#4b5563)]", children: "\u00B7" }), _jsx("span", { className: "text-rose-700", children: "\u89C4\u5212\u5931\u8D25" })] }), failure && (_jsx("div", { className: "mt-1 break-words leading-relaxed text-[var(--agent-muted-foreground,#4b5563)]", children: failure }))] })] }), belowHeader] })] }));
|
|
72
72
|
}
|
|
73
73
|
// ---------------- default ready shell ----------------
|
|
74
74
|
const tasks = payload.tasks ?? [];
|
|
@@ -90,12 +90,12 @@ export const OrchestrationPlanCard = ({ payload, taskStatuses, agentNameFor, cla
|
|
|
90
90
|
return (_jsxs("div", { className: [
|
|
91
91
|
'steerable-orchestration-plan',
|
|
92
92
|
className,
|
|
93
|
-
].filter(Boolean).join(' '), children: [above, _jsxs("div", { className: "rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm shadow-sm", children: [_jsxs("button", { type: "button", onClick: () => setExpanded(!expanded), className: "flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs text-[var(--agent-muted-foreground,#
|
|
93
|
+
].filter(Boolean).join(' '), children: [above, _jsxs("div", { className: "rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm shadow-sm", children: [_jsxs("button", { type: "button", onClick: () => setExpanded(!expanded), className: "flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs text-[var(--agent-muted-foreground,#4b5563)] transition-all duration-200 hover:text-[var(--agent-foreground,#111827)]", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [expanded ? _jsx(ChevronDownIcon, { size: 14 }) : _jsx(ChevronRightIcon, { size: 14 }), _jsx(GitBranchIcon, { size: 14, className: "shrink-0" }), _jsxs("span", { className: "inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap", children: [headerLabel ?? (_jsx("span", { className: "font-medium text-[var(--agent-foreground,#111827)]", children: "\u7F16\u6392\u8BA1\u5212" })), headerSecondary !== undefined ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-[var(--agent-muted-foreground,#4b5563)]", children: "\u00B7" }), _jsx("span", { children: headerSecondary })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-[var(--agent-muted-foreground,#4b5563)]", children: "\u00B7" }), _jsxs("span", { children: [tasks.length, " \u4E2A\u5B50\u4EFB\u52A1"] })] })), !hideMode && payload.mode && (_jsx("span", { className: "ml-1 rounded-full bg-[var(--agent-muted,#f3f4f6)] px-2 py-0.5 text-[10px] uppercase tracking-wider text-[var(--agent-muted-foreground,#4b5563)]", children: payload.mode }))] }), payload.rationale && !expanded && (_jsx("span", { className: "min-w-0 flex-1 truncate text-[var(--agent-muted-foreground,#4b5563)]", children: payload.rationale }))] }), !hideHeaderCounts && (_jsxs("span", { className: "flex shrink-0 items-center gap-2", children: [counts.running > 0 && (_jsxs("span", { className: "flex items-center gap-1", children: [_jsx(LoaderIcon, { size: 12, className: "text-amber-700" }), " ", counts.running] })), counts.failed > 0 && (_jsxs("span", { className: "flex items-center gap-1 text-rose-700", children: [_jsx(AlertIcon, { size: 12 }), " ", counts.failed] })), _jsxs("span", { children: [counts.ok, "/", counts.total] })] }))] }), belowHeader, expanded && (_jsxs("div", { className: "px-3 pb-3", children: [payload.rationale && (_jsx("p", { className: "pb-2 text-xs leading-relaxed text-[var(--agent-muted-foreground,#4b5563)]", children: payload.rationale })), _jsx("ul", { className: "space-y-1.5", children: tasks.map((t) => {
|
|
94
94
|
const status = (taskStatuses?.[t.id] ?? 'pending');
|
|
95
95
|
if (renderTaskRow) {
|
|
96
96
|
return (_jsx(React.Fragment, { children: asReactNode(renderTaskRow(t, status)) }, t.id));
|
|
97
97
|
}
|
|
98
|
-
return (_jsxs("li", { className: "flex items-start gap-2 text-sm", children: [_jsx("span", { className: `mt-1.5 h-2 w-2 flex-shrink-0 rounded-full ${DOT_CLASS[status]}`, "aria-hidden": true }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "font-medium text-[var(--agent-foreground,#111827)]", children: agentNameFor ? agentNameFor(t.agentId) : t.agentId }), _jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#
|
|
98
|
+
return (_jsxs("li", { className: "flex items-start gap-2 text-sm", children: [_jsx("span", { className: `mt-1.5 h-2 w-2 flex-shrink-0 rounded-full ${DOT_CLASS[status]}`, "aria-hidden": true }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "font-medium text-[var(--agent-foreground,#111827)]", children: agentNameFor ? agentNameFor(t.agentId) : t.agentId }), _jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: STATUS_LABEL[status] })] }), t.prompt && (_jsx("p", { className: "mt-0.5 line-clamp-2 text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: t.prompt })), (t.dependsOn?.length ?? 0) > 0 && (_jsxs("p", { className: "mt-0.5 text-[10px] uppercase tracking-wider text-[var(--agent-muted-foreground,#4b5563)]", children: ["\u4F9D\u8D56\uFF1A", t.dependsOn.join(', ')] }))] })] }, t.id));
|
|
99
99
|
}) })] }))] })] }));
|
|
100
100
|
};
|
|
101
101
|
export { STATUS_LABEL as ORCHESTRATION_STATUS_LABEL, DOT_CLASS as ORCHESTRATION_DOT_CLASS };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { OrchestrationPlanCard } from './OrchestrationPlanCard.js';
|
|
3
|
+
declare const meta: Meta<typeof OrchestrationPlanCard>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof OrchestrationPlanCard>;
|
|
6
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OrchestrationPlanCard } from './OrchestrationPlanCard.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Cards/OrchestrationPlanCard',
|
|
5
|
+
component: OrchestrationPlanCard,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: 'Schema-backed multi-agent orchestration plan card (`@steerable/agent-ui/cards`) tracking delegated tasks and live statuses.',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
decorators: [
|
|
15
|
+
(Story) => (_jsx("div", { className: "w-[480px]", children: _jsx(Story, {}) })),
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
export const Default = {
|
|
20
|
+
args: {
|
|
21
|
+
payload: {
|
|
22
|
+
rationale: 'Verify protocol drift and run sandbox conformance checks in parallel.',
|
|
23
|
+
mode: 'parallel',
|
|
24
|
+
tasks: [
|
|
25
|
+
{ id: 't1', agentId: 'spec-auditor', prompt: 'Validate runtime-contract.json against TS & Py types' },
|
|
26
|
+
{ id: 't2', agentId: 'sandbox-tester', prompt: 'Verify Seatbelt & CONNECT egress allow-list rules' },
|
|
27
|
+
{ id: 't3', agentId: 'reporter', prompt: 'Compile summary deliverable' },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
taskStatuses: {
|
|
31
|
+
t1: 'ok',
|
|
32
|
+
t2: 'running',
|
|
33
|
+
t3: 'pending',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -26,34 +26,34 @@ import { asReactNode } from './types.js';
|
|
|
26
26
|
const EFFORT_CONFIG = {
|
|
27
27
|
low: {
|
|
28
28
|
label: '低投入',
|
|
29
|
-
text: 'text-green-
|
|
29
|
+
text: 'text-green-700 dark:text-green-400',
|
|
30
30
|
bg: 'bg-green-50 dark:bg-green-950/30',
|
|
31
31
|
},
|
|
32
32
|
medium: {
|
|
33
33
|
label: '中投入',
|
|
34
|
-
text: 'text-amber-
|
|
34
|
+
text: 'text-amber-700 dark:text-amber-400',
|
|
35
35
|
bg: 'bg-amber-50 dark:bg-amber-950/30',
|
|
36
36
|
},
|
|
37
37
|
high: {
|
|
38
38
|
label: '高投入',
|
|
39
|
-
text: 'text-red-
|
|
39
|
+
text: 'text-red-700 dark:text-red-400',
|
|
40
40
|
bg: 'bg-red-50 dark:bg-red-950/30',
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
const RISK_CONFIG = {
|
|
44
44
|
low: {
|
|
45
45
|
label: '低风险',
|
|
46
|
-
text: 'text-green-
|
|
46
|
+
text: 'text-green-700 dark:text-green-400',
|
|
47
47
|
bg: 'bg-green-50 dark:bg-green-950/30',
|
|
48
48
|
},
|
|
49
49
|
medium: {
|
|
50
50
|
label: '中风险',
|
|
51
|
-
text: 'text-amber-
|
|
51
|
+
text: 'text-amber-700 dark:text-amber-400',
|
|
52
52
|
bg: 'bg-amber-50 dark:bg-amber-950/30',
|
|
53
53
|
},
|
|
54
54
|
high: {
|
|
55
55
|
label: '高风险',
|
|
56
|
-
text: 'text-red-
|
|
56
|
+
text: 'text-red-700 dark:text-red-400',
|
|
57
57
|
bg: 'bg-red-50 dark:bg-red-950/30',
|
|
58
58
|
},
|
|
59
59
|
};
|
|
@@ -84,7 +84,7 @@ export const PlanSelectorCard = ({ payload, isComplete, onSelect, className, exp
|
|
|
84
84
|
return (_jsx("div", { className: [
|
|
85
85
|
'steerable-plan-selector rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-sm text-[var(--agent-foreground,#111827)]',
|
|
86
86
|
className,
|
|
87
|
-
].filter(Boolean).join(' '), children: _jsxs("div", { className: "space-y-3 p-3", children: [renderHeader ? (_jsx("div", { children: asReactNode(renderHeader(plans.length)) })) : (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(TargetIcon, { size: 14, className: "text-blue-500" }), _jsx("span", { className: "text-sm font-medium", children: "\u5019\u9009\u65B9\u6848" }), goalLabel && (_jsxs("span", { className: "text-xs text-[var(--agent-muted-foreground,#
|
|
87
|
+
].filter(Boolean).join(' '), children: _jsxs("div", { className: "space-y-3 p-3", children: [renderHeader ? (_jsx("div", { children: asReactNode(renderHeader(plans.length)) })) : (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(TargetIcon, { size: 14, className: "text-blue-500" }), _jsx("span", { className: "text-sm font-medium", children: "\u5019\u9009\u65B9\u6848" }), goalLabel && (_jsxs("span", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: ["\u00B7 ", goalLabel] }))] })), renderHeader && goalLabel && (_jsx("p", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: goalLabel })), _jsx("div", { className: "space-y-2", children: plans.map((p) => {
|
|
88
88
|
const isSelected = payload.selectedPlan === p.id;
|
|
89
89
|
const effort = EFFORT_CONFIG[p.metrics?.effortLevel || 'medium'];
|
|
90
90
|
const risk = RISK_CONFIG[p.metrics?.riskLevel || 'medium'];
|
|
@@ -95,11 +95,11 @@ export const PlanSelectorCard = ({ payload, isComplete, onSelect, className, exp
|
|
|
95
95
|
? 'border-blue-400 dark:border-blue-600 bg-blue-50/50 dark:bg-blue-950/20 ring-1 ring-blue-200 dark:ring-blue-800'
|
|
96
96
|
: 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] hover:border-[var(--agent-border,#e5e7eb)]/80',
|
|
97
97
|
isReadOnly && !isSelected ? 'opacity-50' : '',
|
|
98
|
-
].filter(Boolean).join(' '), children: [_jsxs("div", { className: "p-3", children: [_jsx("div", { className: "flex items-start justify-between gap-2", children: _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("h4", { className: "truncate text-sm font-medium", children: p.name }), isSelected && (_jsxs("span", { className: "inline-flex items-center gap-0.5 rounded-full bg-blue-100 px-1.5 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/40 dark:text-blue-300", children: [_jsx(CheckIcon, { size: 10 }), " \u5DF2\u9009\u62E9"] }))] }), _jsx("p", { className: "mt-1 text-xs leading-relaxed text-[var(--agent-muted-foreground,#
|
|
99
|
-
}) }), payload.comparison && (_jsx("p", { className: "text-xs text-[var(--agent-muted-foreground,#
|
|
98
|
+
].filter(Boolean).join(' '), children: [_jsxs("div", { className: "p-3", children: [_jsx("div", { className: "flex items-start justify-between gap-2", children: _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("h4", { className: "truncate text-sm font-medium", children: p.name }), isSelected && (_jsxs("span", { className: "inline-flex items-center gap-0.5 rounded-full bg-blue-100 px-1.5 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/40 dark:text-blue-300", children: [_jsx(CheckIcon, { size: 10 }), " \u5DF2\u9009\u62E9"] }))] }), _jsx("p", { className: "mt-1 text-xs leading-relaxed text-[var(--agent-muted-foreground,#4b5563)]", children: p.summary })] }) }), _jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [p.metrics?.duration && (_jsxs("span", { className: "inline-flex items-center gap-1 rounded-full bg-[var(--agent-muted,#f3f4f6)] px-2 py-0.5 text-[10px] font-medium text-[var(--agent-muted-foreground,#4b5563)]", children: [_jsx(ClockIcon, { size: 11 }), p.metrics.duration] })), _jsxs("span", { className: `inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${effort.bg} ${effort.text}`, children: [_jsx(FlameIcon, { size: 11 }), effort.label] }), _jsxs("span", { className: `inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${risk.bg} ${risk.text}`, children: [_jsx(ShieldIcon, { size: 11 }), risk.label] })] }), _jsxs("div", { className: "mt-2 flex items-center justify-between", children: [expandableDetails ? (_jsx("button", { type: "button", onClick: () => setExpandedId(isExpanded ? null : p.id), className: "inline-flex items-center gap-1 text-[11px] text-[var(--agent-muted-foreground,#4b5563)] transition-colors duration-200 hover:text-[var(--agent-foreground,#111827)]", children: isExpanded ? (_jsxs(_Fragment, { children: [_jsx(ChevronUpIcon, { size: 11 }), " \u6536\u8D77\u8BE6\u60C5"] })) : (_jsxs(_Fragment, { children: [_jsx(ChevronDownIcon, { size: 11 }), " \u67E5\u770B\u8BE6\u60C5"] })) })) : (_jsx("span", {})), !isReadOnly && onSelect && (_jsxs("button", { type: "button", onClick: () => handleSelect(p.id), disabled: submittingFor !== null, className: "inline-flex items-center gap-1 rounded-full bg-[var(--agent-primary,#18181b)] px-3 py-1 text-xs font-medium text-[var(--agent-primary-foreground,#fff)] shadow-sm transition-all duration-200 hover:opacity-90 disabled:opacity-50", children: [submittingFor === p.id && _jsx(LoaderIcon, { size: 10 }), "\u9009\u62E9\u6B64\u65B9\u6848"] }))] })] }), isExpanded && (_jsxs("div", { className: "space-y-2 border-t border-[var(--agent-border,#e5e7eb)]/50 px-3 pb-3 pt-2", children: [p.approach && (_jsx("p", { className: "text-xs leading-relaxed", children: p.approach })), _jsxs("div", { className: "grid grid-cols-2 gap-2", children: [(p.pros?.length ?? 0) > 0 && (_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-1 text-[10px] font-medium text-green-700 dark:text-green-400", children: [_jsx(ThumbsUpIcon, { size: 11 }), "\u4F18\u52BF"] }), p.pros.map((pro, i) => (_jsx("p", { className: "pl-4 text-[11px] text-[var(--agent-muted-foreground,#4b5563)]", children: pro }, `pro-${i}`)))] })), (p.cons?.length ?? 0) > 0 && (_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-1 text-[10px] font-medium text-amber-700 dark:text-amber-400", children: [_jsx(AlertIcon, { size: 11 }), "\u6CE8\u610F"] }), p.cons.map((con, i) => (_jsx("p", { className: "pl-4 text-[11px] text-[var(--agent-muted-foreground,#4b5563)]", children: con }, `con-${i}`)))] }))] }), p.bestFor && (_jsxs("p", { className: "text-[11px] italic text-[var(--agent-muted-foreground,#4b5563)]", children: ["\u9002\u5408\uFF1A", p.bestFor] }))] }))] }, p.id));
|
|
99
|
+
}) }), payload.comparison && (_jsx("p", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: payload.comparison })), _jsx("div", { className: "flex items-center justify-between pt-1", children: renderBottomHint
|
|
100
100
|
? asReactNode(renderBottomHint({ submitted: isReadOnly }))
|
|
101
101
|
: !isReadOnly
|
|
102
|
-
? _jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#
|
|
103
|
-
: _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(CheckIcon, { size: 12, className: "text-blue-500" }), _jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#
|
|
102
|
+
? _jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: "\u70B9\u51FB\u9009\u62E9\u65B9\u6848" })
|
|
103
|
+
: _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(CheckIcon, { size: 12, className: "text-blue-500" }), _jsx("span", { className: "text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: "\u65B9\u6848\u5DF2\u9009\u62E9" })] }) })] }) }));
|
|
104
104
|
};
|
|
105
105
|
export default PlanSelectorCard;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { PlanSelectorCard } from './PlanSelectorCard.js';
|
|
3
|
+
declare const meta: Meta<typeof PlanSelectorCard>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof PlanSelectorCard>;
|
|
6
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PlanSelectorCard } from './PlanSelectorCard.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Cards/PlanSelectorCard',
|
|
5
|
+
component: PlanSelectorCard,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: 'Interactive plan comparison card allowing users to choose among competing execution strategies.',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
decorators: [
|
|
16
|
+
(Story) => (_jsx("div", { className: "w-[540px]", children: _jsx(Story, {}) })),
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
export default meta;
|
|
20
|
+
export const Default = {
|
|
21
|
+
args: {
|
|
22
|
+
payload: {
|
|
23
|
+
comparison: 'Fast path uses GLM-5.3-Flash with deterministic recovery; thorough path adds multi-run validation.',
|
|
24
|
+
goalAttribution: { type: 'new', newGoalTitle: 'Stabilize tool-call recovery' },
|
|
25
|
+
plans: [
|
|
26
|
+
{
|
|
27
|
+
id: 'flash-fast',
|
|
28
|
+
name: 'Flash + Deterministic Guard',
|
|
29
|
+
summary: 'Lowest cost per solved task using GLM-5.3-Flash with grounding vetoes.',
|
|
30
|
+
approach: 'Single-loop execution with automatic XML/text call recovery.',
|
|
31
|
+
bestFor: 'Fast daily coding & terminal automation',
|
|
32
|
+
metrics: { duration: '~15s', effortLevel: 'low', riskLevel: 'low' },
|
|
33
|
+
pros: ['Lowest token cost', 'Zero graph boilerplate'],
|
|
34
|
+
cons: ['Single pass on ambiguous tasks'],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'deep-verify',
|
|
38
|
+
name: 'Multi-pass Verification',
|
|
39
|
+
summary: 'Runs parallel subagents for schema audit and test verification.',
|
|
40
|
+
approach: 'Coordinator + specialist subagents with post-edit test gates.',
|
|
41
|
+
bestFor: 'Release-critical protocol changes',
|
|
42
|
+
metrics: { duration: '~45s', effortLevel: 'high', riskLevel: 'low' },
|
|
43
|
+
pros: ['Cross-checks TS and Python parity'],
|
|
44
|
+
cons: ['Higher token budget'],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
onSelect: () => { },
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -19,6 +19,6 @@ export const PlanStepsCard = ({ payload, isStreaming, className }) => {
|
|
|
19
19
|
? 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#f9fafb)] shadow-sm'
|
|
20
20
|
: 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-muted,#f3f4f6)]',
|
|
21
21
|
className,
|
|
22
|
-
].filter(Boolean).join(' '), children: [_jsx(ListChecksIcon, { size: 14, className: "mt-0.5 flex-shrink-0 text-[var(--agent-muted-foreground,#
|
|
22
|
+
].filter(Boolean).join(' '), children: [_jsx(ListChecksIcon, { size: 14, className: "mt-0.5 flex-shrink-0 text-[var(--agent-muted-foreground,#4b5563)]" }), _jsxs("div", { className: "flex flex-wrap items-center gap-1 text-xs text-[var(--agent-muted-foreground,#4b5563)]", children: [steps.map((step, idx) => (_jsxs(React.Fragment, { children: [idx > 0 && _jsx("span", { "aria-hidden": true, className: "select-none opacity-40", children: "/" }), _jsx("span", { className: "whitespace-nowrap", children: step })] }, `${idx}-${step}`))), isStreaming && (_jsx("span", { "aria-hidden": true, className: "ml-1 inline-block h-1.5 w-1.5 translate-y-[1px] animate-pulse rounded-full bg-current" }))] })] }));
|
|
23
23
|
};
|
|
24
24
|
export default PlanStepsCard;
|