oneslash-design-system 2.28.0 → 2.29.0
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 +1 -1
- package/dist/DESIGN.md +31 -1
- package/dist/cases/about-page.md +2 -0
- package/dist/cases/accept-invite.md +2 -0
- package/dist/cases/account-menu.md +2 -0
- package/dist/cases/activity-timeline.md +2 -0
- package/dist/cases/admin-inbox.md +2 -0
- package/dist/cases/agent-asks-before-risky-action.md +3 -1
- package/dist/cases/agent-cancels-when-unanswered.md +2 -0
- package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
- package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
- package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
- package/dist/cases/agent-changes-review/per-change.jsx +203 -0
- package/dist/cases/agent-changes-review.md +585 -0
- package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
- package/dist/cases/agent-handoff/to-agent.jsx +53 -0
- package/dist/cases/agent-handoff/to-person.d.ts +1 -0
- package/dist/cases/agent-handoff/to-person.jsx +84 -0
- package/dist/cases/agent-handoff.md +231 -0
- package/dist/cases/agent-memory/list.d.ts +1 -0
- package/dist/cases/agent-memory/list.jsx +256 -0
- package/dist/cases/agent-memory.md +354 -0
- package/dist/cases/agent-options.md +2 -0
- package/dist/cases/agent-pending-reply/steps.jsx +70 -21
- package/dist/cases/agent-pending-reply.md +74 -27
- package/dist/cases/agent-permissions/levels.d.ts +3 -0
- package/dist/cases/agent-permissions/levels.jsx +49 -0
- package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
- package/dist/cases/agent-permissions/per-tool.jsx +178 -0
- package/dist/cases/agent-permissions.md +314 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
- package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
- package/dist/cases/agent-plan-proposal.md +36 -21
- package/dist/cases/agent-question.md +2 -0
- package/dist/cases/agent-refuses-clearly.md +2 -0
- package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
- package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
- package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
- package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
- package/dist/cases/agent-run-failure.md +500 -0
- package/dist/cases/agent-says-what-it-is.md +2 -0
- package/dist/cases/agent-says-where-it-stopped.md +27 -0
- package/dist/cases/agent-settings.md +2 -0
- package/dist/cases/agent-shows-progress.md +2 -0
- package/dist/cases/agent-shows-sources.md +2 -0
- package/dist/cases/api-keys/list.jsx +30 -3
- package/dist/cases/api-keys.md +37 -3
- package/dist/cases/app-shell.md +2 -0
- package/dist/cases/artifact-card.md +2 -0
- package/dist/cases/ask-page.md +2 -0
- package/dist/cases/auth-gate-loading.md +2 -0
- package/dist/cases/billing-page.md +2 -0
- package/dist/cases/blog-index.md +2 -0
- package/dist/cases/breadcrumb.md +2 -0
- package/dist/cases/breakdown-list.md +2 -0
- package/dist/cases/bulk-actions/list.d.ts +1 -0
- package/dist/cases/bulk-actions/list.jsx +209 -0
- package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
- package/dist/cases/bulk-actions/paged-table.jsx +246 -0
- package/dist/cases/bulk-actions.md +559 -0
- package/dist/cases/changelog.md +2 -0
- package/dist/cases/chart.md +2 -0
- package/dist/cases/check-your-email.md +2 -0
- package/dist/cases/code-sample.md +2 -0
- package/dist/cases/collapsible-search.md +2 -0
- package/dist/cases/comment-thread.md +2 -0
- package/dist/cases/comparison-page/table.d.ts +1 -0
- package/dist/cases/comparison-page/table.jsx +97 -0
- package/dist/cases/comparison-page.md +156 -0
- package/dist/cases/composer-limit.md +2 -0
- package/dist/cases/confirm-destructive-action.md +2 -0
- package/dist/cases/confirm-dialogs.md +2 -0
- package/dist/cases/connection-status/card.d.ts +1 -0
- package/dist/cases/connection-status/card.jsx +97 -0
- package/dist/cases/connection-status/row.d.ts +1 -0
- package/dist/cases/connection-status/row.jsx +120 -0
- package/dist/cases/connection-status.md +330 -0
- package/dist/cases/contact-page.md +2 -0
- package/dist/cases/conversation-starters.md +2 -0
- package/dist/cases/cookie-choice.md +2 -0
- package/dist/cases/create-modal.md +2 -0
- package/dist/cases/danger-zone.md +2 -0
- package/dist/cases/dashboard.md +2 -0
- package/dist/cases/data-table-page.md +2 -0
- package/dist/cases/date-field.md +2 -0
- package/dist/cases/device-login.md +2 -0
- package/dist/cases/docs-component-page.md +2 -0
- package/dist/cases/email-confirmed.md +2 -0
- package/dist/cases/empty-list.md +2 -0
- package/dist/cases/empty-lists.md +2 -0
- package/dist/cases/empty-not-set-up.md +2 -0
- package/dist/cases/empty-search.md +2 -0
- package/dist/cases/error-page.md +2 -0
- package/dist/cases/faq.md +2 -0
- package/dist/cases/feature-grid.md +2 -0
- package/dist/cases/feedback-form.md +2 -0
- package/dist/cases/file-upload.md +2 -0
- package/dist/cases/filter-menu.md +2 -0
- package/dist/cases/forgot-password.md +2 -0
- package/dist/cases/form-errors.md +2 -0
- package/dist/cases/image-viewer.md +2 -0
- package/dist/cases/import-checklist.md +2 -0
- package/dist/cases/inline-form-feedback.md +2 -0
- package/dist/cases/integrations-list/nested.jsx +1 -1
- package/dist/cases/integrations-list/rows.jsx +1 -1
- package/dist/cases/integrations-list.md +6 -4
- package/dist/cases/invite-member.md +2 -0
- package/dist/cases/invoice-list.md +2 -0
- package/dist/cases/landing-hero.md +2 -0
- package/dist/cases/leaderboard.md +2 -0
- package/dist/cases/legal-page.md +2 -0
- package/dist/cases/load-failure.md +2 -0
- package/dist/cases/log-out-confirm.md +2 -0
- package/dist/cases/login-page.md +2 -0
- package/dist/cases/long-form-page.md +2 -0
- package/dist/cases/master-detail.md +2 -0
- package/dist/cases/members-list/rows.jsx +37 -6
- package/dist/cases/members-list/table.jsx +37 -6
- package/dist/cases/members-list.md +83 -12
- package/dist/cases/mention-list.md +2 -0
- package/dist/cases/message-actions.md +2 -0
- package/dist/cases/message-attachments.md +2 -0
- package/dist/cases/message-composer/with-tools.jsx +17 -7
- package/dist/cases/message-composer.md +28 -11
- package/dist/cases/message-edit.md +2 -0
- package/dist/cases/message-reactions.md +2 -0
- package/dist/cases/message-row.md +2 -0
- package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
- package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
- package/dist/cases/message-send-failure/retrying.d.ts +1 -0
- package/dist/cases/message-send-failure/retrying.jsx +116 -0
- package/dist/cases/message-send-failure.md +308 -0
- package/dist/cases/mobile-menu.md +2 -0
- package/dist/cases/newsletter-signup.md +2 -0
- package/dist/cases/no-access/page.d.ts +1 -0
- package/dist/cases/no-access/page.jsx +37 -0
- package/dist/cases/no-access/read-only.d.ts +1 -0
- package/dist/cases/no-access/read-only.jsx +33 -0
- package/dist/cases/no-access.md +147 -0
- package/dist/cases/not-found-page.md +2 -0
- package/dist/cases/notification-menu.md +2 -0
- package/dist/cases/number-format.md +2 -0
- package/dist/cases/oauth-consent.md +2 -0
- package/dist/cases/on-off-settings.md +2 -0
- package/dist/cases/on-this-page.md +2 -0
- package/dist/cases/onboarding.md +2 -0
- package/dist/cases/one-main-action.md +2 -0
- package/dist/cases/overflow-menu.md +2 -0
- package/dist/cases/page-end.md +2 -0
- package/dist/cases/page-header.md +2 -0
- package/dist/cases/paged-card.md +2 -0
- package/dist/cases/password-gate.md +2 -0
- package/dist/cases/payment-method.md +2 -0
- package/dist/cases/people-row.md +2 -0
- package/dist/cases/phone-navigation.md +2 -0
- package/dist/cases/plan-change-confirm.md +2 -0
- package/dist/cases/plan-comparison.md +3 -1
- package/dist/cases/plan-picker.md +4 -1
- package/dist/cases/plan-sign-off.md +2 -0
- package/dist/cases/pricing-section.md +5 -1
- package/dist/cases/product-cards.md +2 -0
- package/dist/cases/product-demo/scripted.d.ts +3 -0
- package/dist/cases/product-demo/scripted.jsx +95 -0
- package/dist/cases/product-demo/still.d.ts +1 -0
- package/dist/cases/product-demo/still.jsx +20 -0
- package/dist/cases/product-demo.md +221 -0
- package/dist/cases/profile-form.md +2 -0
- package/dist/cases/quick-switcher.md +2 -0
- package/dist/cases/range-switch.md +2 -0
- package/dist/cases/rename.md +2 -0
- package/dist/cases/reply-feedback.md +2 -0
- package/dist/cases/reply-sources.md +2 -0
- package/dist/cases/route-loading.md +2 -0
- package/dist/cases/scope-picker.md +2 -0
- package/dist/cases/section-index.md +2 -0
- package/dist/cases/session-expired/in-place.d.ts +1 -0
- package/dist/cases/session-expired/in-place.jsx +63 -0
- package/dist/cases/session-expired/redirect.d.ts +1 -0
- package/dist/cases/session-expired/redirect.jsx +62 -0
- package/dist/cases/session-expired.md +204 -0
- package/dist/cases/set-new-password.md +2 -0
- package/dist/cases/settings-page.md +2 -0
- package/dist/cases/settings-save.md +2 -0
- package/dist/cases/side-pane.md +2 -0
- package/dist/cases/sidebar-nav.md +2 -0
- package/dist/cases/sign-up-page.md +3 -0
- package/dist/cases/signup-from-site/plain.d.ts +1 -0
- package/dist/cases/signup-from-site/plain.jsx +125 -0
- package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
- package/dist/cases/signup-from-site/with-plan.jsx +151 -0
- package/dist/cases/signup-from-site.md +351 -0
- package/dist/cases/site-footer.md +2 -0
- package/dist/cases/site-header/links.d.ts +3 -1
- package/dist/cases/site-header/links.jsx +6 -2
- package/dist/cases/site-header.md +11 -3
- package/dist/cases/site-matches-app.md +32 -0
- package/dist/cases/site-search.md +2 -0
- package/dist/cases/slash-command-list.md +2 -0
- package/dist/cases/stat-row.md +2 -0
- package/dist/cases/status-label.md +3 -1
- package/dist/cases/success-feedback.md +2 -0
- package/dist/cases/tabbed-panels.md +2 -0
- package/dist/cases/tag-filter.md +2 -0
- package/dist/cases/task-header.md +2 -0
- package/dist/cases/theme-switcher.md +2 -0
- package/dist/cases/type-to-confirm.md +2 -0
- package/dist/cases/typing-and-status.md +2 -0
- package/dist/cases/unsaved-changes-guard.md +2 -0
- package/dist/cases/upgrade-prompt.md +2 -0
- package/dist/cases/usage-meters.md +2 -0
- package/dist/cases.json +1494 -42
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +23 -9
- package/dist/components/diff.d.ts +29 -0
- package/dist/components/diff.jsx +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/diff.d.ts +17 -0
- package/dist/internal/diff.js +44 -0
- package/dist/native-mapping.json +9 -2
- package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
- package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
- package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
- package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
- package/dist/stories/Cases.generated.stories.d.ts +24 -0
- package/dist/stories/Cases.generated.stories.jsx +48 -0
- package/dist/stories/Checkbox.stories.d.ts +2 -0
- package/dist/stories/Checkbox.stories.jsx +18 -0
- package/dist/stories/Diff.stories.d.ts +9 -0
- package/dist/stories/Diff.stories.jsx +40 -0
- package/dist/stories/ProductDemo.probe.stories.d.ts +6 -0
- package/dist/stories/ProductDemo.probe.stories.jsx +12 -0
- package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
- package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
- package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
- package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# What an agent may do
|
|
2
|
+
|
|
3
|
+
A person or an admin sets how much the agent does without asking, and which tools it may use.
|
|
4
|
+
|
|
5
|
+
For: an app, an agent
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Follow the rule 'A setting saves in place, or with one Save Button': each choice saves as soon as it is made, and shows nothing when it works.
|
|
10
|
+
- Offer three levels in a `RadioGroup`, named in plain words for what changes: 'Only suggest changes', 'Ask before every change', 'Ask before risky changes'.
|
|
11
|
+
- Give each level a `secondLabel` with an example: 'It drafts and checks alone. Every change to shared work, such as a page edit, a pull request or a deploy, waits for a yes.'
|
|
12
|
+
- Make plain how 'Ask before every change' differs: it asks even before it changes its own drafts.
|
|
13
|
+
- Say what counts as risky, under the levels.
|
|
14
|
+
- Keep every risky action behind a yes at every level, as the rule 'An agent asks before a risky action' says.
|
|
15
|
+
- Disable the group while it saves. When the save fails, put the old level back and say why under it: 'Could not save. Try again.'
|
|
16
|
+
- List the tools in a `TableContainer`, one row per tool, each with a line on what it does and a `SegmentedControl` of 'Allow', 'Ask' and 'Never'.
|
|
17
|
+
- Name each `SegmentedControl` for its row: 'Edit pages'.
|
|
18
|
+
- Offer only 'Ask' and 'Never' on a risky tool, and say why on its row: 'Risky: it changes what customers see, so it cannot be set to Allow.'
|
|
19
|
+
- List the apps that use these tools under the table, in a section titled 'Connected apps', each with who connected it and when, and 'Revoke'.
|
|
20
|
+
- Confirm 'Revoke' in the row, as the case 'API keys' does. Focus moves to 'Cancel' when the confirm opens, back to 'Revoke' on 'Cancel', and to the next row's 'Revoke' after the app is gone.
|
|
21
|
+
- Show everything read-only to a person who cannot change it, as the case 'No access' says.
|
|
22
|
+
|
|
23
|
+
## Don't
|
|
24
|
+
|
|
25
|
+
- Do not ask for blocked tools in a free-text list. List every tool with its own control.
|
|
26
|
+
- Do not offer four or more levels whose names do not say what the agent does at each one.
|
|
27
|
+
- Do not let a risky tool be set to 'Allow'.
|
|
28
|
+
- Do not offer a level that lets the agent do a risky action alone.
|
|
29
|
+
- Do not revoke an app on the first press.
|
|
30
|
+
|
|
31
|
+
## Option: One level
|
|
32
|
+
|
|
33
|
+
Use when: One setting for how much the agent does without asking is enough.
|
|
34
|
+
|
|
35
|
+
Uses: `Center`, `FormField`, `Heading`, `Paragraph`, `RadioGroup`, `SettingsSection`, `Stack`
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
'use client';
|
|
39
|
+
import { useEffect, useRef, useState } from 'react';
|
|
40
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
41
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
42
|
+
import FormField from 'oneslash-design-system/components/formField';
|
|
43
|
+
import RadioGroup from 'oneslash-design-system/components/radioGroup';
|
|
44
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
45
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
46
|
+
|
|
47
|
+
// Three levels, each named for what the agent does at it, with an example. No level lets it do a risky action alone.
|
|
48
|
+
const levels = [
|
|
49
|
+
{ value: 'suggest', label: 'Only suggest changes', secondLabel: 'It drafts a fix and proposes it in the thread. It changes nothing itself.' },
|
|
50
|
+
{ value: 'ask-every', label: 'Ask before every change', secondLabel: 'It asks before every change, even to its own drafts.' },
|
|
51
|
+
{ value: 'ask-risky', label: 'Ask before risky changes', secondLabel: 'It drafts and checks alone. Every change to shared work, such as a page edit, a pull request or a deploy, waits for a yes.' },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
// A real app reads `canChange` from the person's role. Only an admin can change how the agent works.
|
|
55
|
+
// The example shows an admin's view. A real app passes `canChange` from the person's role.
|
|
56
|
+
export default function AgentPermissionsLevels({ canChange = true }: { canChange?: boolean } = {}) {
|
|
57
|
+
const [level, setLevel] = useState('ask-every');
|
|
58
|
+
const [saving, setSaving] = useState(false);
|
|
59
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
60
|
+
|
|
61
|
+
// Stops the request if the example goes away before it ends.
|
|
62
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
63
|
+
|
|
64
|
+
// The choice stands alone, so it saves as soon as it is made. Nothing shows when it works.
|
|
65
|
+
// While the request runs the group is disabled. A real app puts the old level back if the save fails,
|
|
66
|
+
// and says why in the FormField's error line: 'Could not save. Try again.'
|
|
67
|
+
function choose(next: string) {
|
|
68
|
+
if (saving || next === level) return;
|
|
69
|
+
setLevel(next);
|
|
70
|
+
setSaving(true);
|
|
71
|
+
// Stands in for the request to the server.
|
|
72
|
+
timer.current = setTimeout(() => setSaving(false), 900);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Center width="page">
|
|
77
|
+
<Stack gap="xlarge">
|
|
78
|
+
<Stack gap="small">
|
|
79
|
+
<Heading level={1} size="h5">Agent</Heading>
|
|
80
|
+
<Paragraph tone="secondary" size="body2" measure="none">How Acme Agent works for everyone in this workspace.</Paragraph>
|
|
81
|
+
{!canChange && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change these settings. Your admin is Dana Lee.</Paragraph>}
|
|
82
|
+
</Stack>
|
|
83
|
+
<SettingsSection title="What Acme Agent does alone" description="Your choice saves as soon as you make it.">
|
|
84
|
+
<FormField id="agent-permissions-levels-level" label="Level" help="Risky changes are any change to shared work, such as a page edit or a pull request, and messages to people outside Acme, deploys and deletes. They wait for a yes at every level.">
|
|
85
|
+
{(f) => (
|
|
86
|
+
<RadioGroup
|
|
87
|
+
id={f.id}
|
|
88
|
+
aria-describedby={f['aria-describedby']}
|
|
89
|
+
aria-label="Level"
|
|
90
|
+
options={levels}
|
|
91
|
+
selectedValue={level}
|
|
92
|
+
disabled={!canChange || saving}
|
|
93
|
+
onChange={choose}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
</FormField>
|
|
97
|
+
</SettingsSection>
|
|
98
|
+
</Stack>
|
|
99
|
+
</Center>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Option: Each tool
|
|
105
|
+
|
|
106
|
+
Use when: An admin sets each tool or action on its own.
|
|
107
|
+
|
|
108
|
+
Uses: `Button`, `Center`, `Cluster`, `EmptyBox`, `Heading`, `Paragraph`, `SegmentedControl`, `SettingsSection`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Toaster`, `dismissToast`, `toast`
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
'use client';
|
|
112
|
+
import { useEffect, useRef, useState } from 'react';
|
|
113
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
114
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
115
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
116
|
+
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
117
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
118
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
119
|
+
import TableHeader from 'oneslash-design-system/components/tableHeader';
|
|
120
|
+
import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
|
|
121
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
122
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
123
|
+
import EmptyBox from 'oneslash-design-system/components/emptyBox';
|
|
124
|
+
import Button from 'oneslash-design-system/components/button';
|
|
125
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
126
|
+
|
|
127
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
128
|
+
type Setting = 'allow' | 'ask' | 'never';
|
|
129
|
+
|
|
130
|
+
type Tool = { id: string; name: string; does: string; risky?: string };
|
|
131
|
+
|
|
132
|
+
const tools: Tool[] = [
|
|
133
|
+
{ id: 'read', name: 'Read pages and files', does: 'Reads the workspace to answer and to plan.' },
|
|
134
|
+
{ id: 'post', name: 'Post in threads', does: 'Posts replies and updates in Acme threads.' },
|
|
135
|
+
{ id: 'edit', name: 'Edit pages', does: 'Changes the text of a page.', risky: 'Risky: it changes shared work, so it cannot be set to Allow.' },
|
|
136
|
+
{ id: 'pull', name: 'Open pull requests', does: 'Proposes code changes for review.', risky: 'Risky: it changes shared work, so it cannot be set to Allow.' },
|
|
137
|
+
{ id: 'deploy', name: 'Deploy to production', does: 'Puts a change live.', risky: 'Risky: it changes what customers see, so it cannot be set to Allow.' },
|
|
138
|
+
{ id: 'delete', name: 'Delete files', does: 'Removes files from the workspace.', risky: 'Risky: a deleted file cannot be brought back, so it cannot be set to Allow.' },
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
const allOptions = [
|
|
142
|
+
{ value: 'allow', label: 'Allow' },
|
|
143
|
+
{ value: 'ask', label: 'Ask' },
|
|
144
|
+
{ value: 'never', label: 'Never' },
|
|
145
|
+
];
|
|
146
|
+
// A risky tool offers no 'Allow'.
|
|
147
|
+
const riskyOptions = allOptions.filter((o) => o.value !== 'allow');
|
|
148
|
+
|
|
149
|
+
type Client = { id: string; name: string; connected: string };
|
|
150
|
+
|
|
151
|
+
const firstClients: Client[] = [
|
|
152
|
+
{ id: 'cli', name: 'Acme CLI', connected: 'Connected by Ben Carter on Oct 3, 2026' },
|
|
153
|
+
{ id: 'slack', name: 'Acme for Slack', connected: 'Connected by Dana Lee on Aug 19, 2026' },
|
|
154
|
+
{ id: 'reports', name: 'Reporting script', connected: 'Connected by Omar Reyes on Nov 2, 2026' },
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
// A real app reads `canChange` from the person's role. Only an admin can change the tools.
|
|
158
|
+
// The example shows an admin's view. A real app passes `canChange` from the person's role.
|
|
159
|
+
export default function AgentPermissionsPerTool({ canChange = true }: { canChange?: boolean } = {}) {
|
|
160
|
+
const [settings, setSettings] = useState<Record<string, Setting>>({ read: 'allow', post: 'allow', edit: 'ask', pull: 'ask', deploy: 'ask', delete: 'never' });
|
|
161
|
+
const [savingTool, setSavingTool] = useState<string | null>(null);
|
|
162
|
+
const [clients, setClients] = useState(firstClients);
|
|
163
|
+
const [confirming, setConfirming] = useState<string | null>(null);
|
|
164
|
+
const [revoking, setRevoking] = useState<string | null>(null);
|
|
165
|
+
const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
|
|
166
|
+
const toastIds = useRef<string[]>([]);
|
|
167
|
+
const cancelRevoke = useRef<Focusable>(null);
|
|
168
|
+
const guideButton = useRef<Focusable>(null);
|
|
169
|
+
// Each row's Revoke button by client id, so focus can move to one when the button that had it is gone.
|
|
170
|
+
const revokeButtons = useRef<Record<string, Focusable>>({});
|
|
171
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
172
|
+
const focusNext = useRef<() => void>();
|
|
173
|
+
|
|
174
|
+
// On unmount it stops every request and closes every toast it opened.
|
|
175
|
+
useEffect(() => () => {
|
|
176
|
+
timers.current.forEach(clearTimeout);
|
|
177
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
178
|
+
toastIds.current = [];
|
|
179
|
+
}, []);
|
|
180
|
+
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
const move = focusNext.current;
|
|
183
|
+
focusNext.current = undefined;
|
|
184
|
+
move?.();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Stands in for the request to the server.
|
|
188
|
+
function later(callback: () => void, ms: number) {
|
|
189
|
+
timers.current.push(setTimeout(callback, ms));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Each row's choice stands alone, so it saves as soon as it is made, and shows nothing when it works.
|
|
193
|
+
// SegmentedControl cannot be disabled, so a press on a row that is still saving does nothing.
|
|
194
|
+
function choose(tool: Tool, next: string) {
|
|
195
|
+
if (!canChange || savingTool === tool.id || next === settings[tool.id]) return;
|
|
196
|
+
setSettings((current) => ({ ...current, [tool.id]: next as Setting }));
|
|
197
|
+
setSavingTool(tool.id);
|
|
198
|
+
later(() => setSavingTool((id) => (id === tool.id ? null : id)), 900);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// The confirm opens in the row, with focus on 'Cancel'.
|
|
202
|
+
function askToRevoke(c: Client) {
|
|
203
|
+
setConfirming(c.id);
|
|
204
|
+
focusNext.current = () => cancelRevoke.current?.focus();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's Revoke button.
|
|
208
|
+
function keepClient(c: Client) {
|
|
209
|
+
if (revoking) return;
|
|
210
|
+
setConfirming(null);
|
|
211
|
+
focusNext.current = () => revokeButtons.current[c.id]?.focus();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function revoke(c: Client) {
|
|
215
|
+
if (revoking) return;
|
|
216
|
+
const at = clients.findIndex((x) => x.id === c.id);
|
|
217
|
+
const neighbor = clients[at + 1] ?? clients[at - 1];
|
|
218
|
+
setRevoking(c.id);
|
|
219
|
+
later(() => {
|
|
220
|
+
setRevoking(null);
|
|
221
|
+
setConfirming(null);
|
|
222
|
+
setClients((list) => list.filter((x) => x.id !== c.id));
|
|
223
|
+
// The row is gone: focus goes to the next row's Revoke, or the one before it when it was the last.
|
|
224
|
+
// With no client left, it goes to the guide Button in the empty list.
|
|
225
|
+
focusNext.current = () => (neighbor ? revokeButtons.current[neighbor.id] : guideButton.current)?.focus();
|
|
226
|
+
toastIds.current.push(toast({ type: 'success', message: `${c.name} revoked.` }));
|
|
227
|
+
}, 1200);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<Center width="page">
|
|
232
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
233
|
+
<Toaster />
|
|
234
|
+
<Stack gap="xlarge">
|
|
235
|
+
<Stack gap="small">
|
|
236
|
+
<Heading level={1} size="h5">Agent tools</Heading>
|
|
237
|
+
<Paragraph tone="secondary" size="body2" measure="none">What Acme Agent may do in this workspace, for everyone.</Paragraph>
|
|
238
|
+
{!canChange && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change these settings. Your admin is Dana Lee.</Paragraph>}
|
|
239
|
+
</Stack>
|
|
240
|
+
|
|
241
|
+
<SettingsSection title="Tools" description="Each choice saves as soon as you make it. Ask means Acme Agent asks before each use.">
|
|
242
|
+
<TableContainer>
|
|
243
|
+
<TableHeader>
|
|
244
|
+
<TableRow>
|
|
245
|
+
<TableHeaderCell>Tool</TableHeaderCell>
|
|
246
|
+
<TableHeaderCell width="184px">Setting</TableHeaderCell>
|
|
247
|
+
</TableRow>
|
|
248
|
+
</TableHeader>
|
|
249
|
+
{tools.map((t) => (
|
|
250
|
+
<TableRow key={t.id}>
|
|
251
|
+
<TableCell>
|
|
252
|
+
<Stack gap="small">
|
|
253
|
+
{t.name}
|
|
254
|
+
<Paragraph size="body2" tone="secondary" measure="none">{t.risky ?? t.does}</Paragraph>
|
|
255
|
+
</Stack>
|
|
256
|
+
</TableCell>
|
|
257
|
+
<TableCell width="184px">
|
|
258
|
+
<SegmentedControl
|
|
259
|
+
size="small"
|
|
260
|
+
aria-label={t.name}
|
|
261
|
+
options={t.risky ? riskyOptions : allOptions}
|
|
262
|
+
value={settings[t.id]}
|
|
263
|
+
onChange={(next) => choose(t, next)}
|
|
264
|
+
/>
|
|
265
|
+
</TableCell>
|
|
266
|
+
</TableRow>
|
|
267
|
+
))}
|
|
268
|
+
</TableContainer>
|
|
269
|
+
</SettingsSection>
|
|
270
|
+
|
|
271
|
+
<SettingsSection title="Connected apps" description="Apps that use Acme Agent from outside Acme. They can use the tools above.">
|
|
272
|
+
{clients.length > 0 ? (
|
|
273
|
+
<TableContainer>
|
|
274
|
+
{clients.map((c) => (
|
|
275
|
+
<TableRow key={c.id}>
|
|
276
|
+
<TableCell>
|
|
277
|
+
<Stack gap="small">
|
|
278
|
+
{c.name}
|
|
279
|
+
<Paragraph size="body2" tone="secondary" measure="none">{confirming === c.id ? `Revoke ${c.name}? It stops working until someone connects it again.` : c.connected}</Paragraph>
|
|
280
|
+
</Stack>
|
|
281
|
+
</TableCell>
|
|
282
|
+
{/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
|
|
283
|
+
<TableCell width="168px" align="right">
|
|
284
|
+
{confirming === c.id ? (
|
|
285
|
+
<Cluster gap="small" justify="end">
|
|
286
|
+
<Button ref={cancelRevoke} size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel revoking ${c.name}`} onClickButton={() => keepClient(c)} />
|
|
287
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={`Revoke ${c.name}`} loading={revoking === c.id} onClickButton={() => revoke(c)} />
|
|
288
|
+
</Cluster>
|
|
289
|
+
) : (
|
|
290
|
+
canChange && (
|
|
291
|
+
<Cluster justify="end">
|
|
292
|
+
<Button ref={(el) => { revokeButtons.current[c.id] = el; }} size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={`Revoke ${c.name}`} onClickButton={() => askToRevoke(c)} />
|
|
293
|
+
</Cluster>
|
|
294
|
+
)
|
|
295
|
+
)}
|
|
296
|
+
</TableCell>
|
|
297
|
+
</TableRow>
|
|
298
|
+
))}
|
|
299
|
+
</TableContainer>
|
|
300
|
+
) : (
|
|
301
|
+
<EmptyBox
|
|
302
|
+
size="small"
|
|
303
|
+
icon="Plug"
|
|
304
|
+
text="No connected apps"
|
|
305
|
+
secondText="Apps you connect to Acme Agent appear here."
|
|
306
|
+
action={<Button ref={guideButton} size="small" type="secondary" state="enabled" label="Read the Setup Guide" href="/docs/agent/clients" />}
|
|
307
|
+
/>
|
|
308
|
+
)}
|
|
309
|
+
</SettingsSection>
|
|
310
|
+
</Stack>
|
|
311
|
+
</Center>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
```
|
|
@@ -17,18 +17,20 @@ import { Center, Cluster, Stack } from '../../components/layout';
|
|
|
17
17
|
var agentName = 'Acme Agent';
|
|
18
18
|
var request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you update the pricing page for the new plans?' };
|
|
19
19
|
var proposedAt = new Date('2025-01-15T11:44:00Z');
|
|
20
|
-
//
|
|
20
|
+
// The changes are a list of the files they touch, each with what changes in it. The case 'Review of an agent's changes' shows the lines with `Diff`.
|
|
21
21
|
var changedFiles = [
|
|
22
22
|
{ path: 'pages/pricing.tsx', change: 'Adds the Team plan to the page.' },
|
|
23
23
|
{ path: 'data/plans.json', change: 'Sets the Pro price to $15 and adds the Team plan at $25 per seat.' },
|
|
24
24
|
{ path: 'components/planTable.tsx', change: 'Adds a column for the Team plan.' },
|
|
25
25
|
];
|
|
26
|
-
// The run after '
|
|
26
|
+
// The run after 'Apply Changes': one step per file.
|
|
27
27
|
var runSteps = changedFiles.map(function (f) { return "Change ".concat(f.path); });
|
|
28
28
|
var reply = 'The three files are changed. The pricing page shows the new plans.';
|
|
29
|
-
// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.
|
|
30
|
+
// Once the run is stopped, the whole list shows: the step it stopped on and the steps after it are cancelled.
|
|
31
|
+
function stepsUpTo(current, stopped) {
|
|
32
|
+
if (stopped === void 0) { stopped = false; }
|
|
33
|
+
return (stopped ? runSteps : runSteps.slice(0, current + 1)).map(function (label, i) { return ({ label: label, status: i < current ? 'done' : stopped ? 'cancelled' : 'running' }); });
|
|
32
34
|
}
|
|
33
35
|
function secondsLine(seconds) {
|
|
34
36
|
return "Working for ".concat(seconds, " ").concat(seconds === 1 ? 'second' : 'seconds');
|
|
@@ -46,7 +48,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
46
48
|
var _b = useState(null), pending = _b[0], setPending = _b[1];
|
|
47
49
|
var _c = useState(false), viewing = _c[0], setViewing = _c[1];
|
|
48
50
|
var _d = useState(''), draft = _d[0], setDraft = _d[1];
|
|
49
|
-
// The run after '
|
|
51
|
+
// The run after 'Apply Changes', in its own progress row under the card.
|
|
50
52
|
var _e = useState(null), run = _e[0], setRun = _e[1];
|
|
51
53
|
var _f = useState(0), current = _f[0], setCurrent = _f[1];
|
|
52
54
|
var _g = useState(0), seconds = _g[0], setSeconds = _g[1];
|
|
@@ -84,7 +86,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
84
86
|
}, 1500);
|
|
85
87
|
}
|
|
86
88
|
// The card stays as the record, and the run shows in its own progress row below it.
|
|
87
|
-
// '
|
|
89
|
+
// 'Apply Changes' is gone and 'Stop' is the control that took its place, so focus goes to 'Stop'.
|
|
88
90
|
function startRun() {
|
|
89
91
|
setRun('running');
|
|
90
92
|
setCurrent(0);
|
|
@@ -167,7 +169,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
167
169
|
{/* A real app announces the decided Tag in a polite live region. */}
|
|
168
170
|
<Cluster gap="small">
|
|
169
171
|
<Heading level={2} size="subtitle1">Changes ready</Heading>
|
|
170
|
-
{status === 'approved' && <Tag variant="contained" size="small" color="success" label="
|
|
172
|
+
{status === 'approved' && <Tag variant="contained" size="small" color="success" label="Applied"/>}
|
|
171
173
|
{status === 'cancelled' && <Tag variant="contained" size="small" label="Cancelled"/>}
|
|
172
174
|
</Cluster>
|
|
173
175
|
<Paragraph measure="none">These changes set the Pro price to $15 and add the Team plan to the pricing page. Three files change.</Paragraph>
|
|
@@ -182,7 +184,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
182
184
|
<Button size="small" type="tertiary" state={pending === 'approve' ? 'disabled' : 'enabled'} label="Cancel" loading={pending === 'cancel'} onClickButton={function () { return decide('cancel'); }}/>
|
|
183
185
|
<Button ref={requestButton} size="small" type="secondary" state={pending ? 'disabled' : 'enabled'} label="Request Changes" onClickButton={startRequest}/>
|
|
184
186
|
{/* The product writes this label, never the agent. */}
|
|
185
|
-
<Button size="small" type="primary" state={pending === 'cancel' ? 'disabled' : 'enabled'} label="
|
|
187
|
+
<Button size="small" type="primary" state={pending === 'cancel' ? 'disabled' : 'enabled'} label="Apply Changes" loading={pending === 'approve'} onClickButton={function () { return decide('approve'); }}/>
|
|
186
188
|
</Cluster>)}
|
|
187
189
|
{status === 'requesting' && (<Cluster gap="small">
|
|
188
190
|
<Button size="small" type="tertiary" state={pending === 'send' ? 'disabled' : 'enabled'} label="Discard" onClickButton={discard}/>
|
|
@@ -204,7 +206,12 @@ export default function AgentPlanProposalChanges() {
|
|
|
204
206
|
<Cluster>
|
|
205
207
|
<Button ref={stopButton} size="small" type="secondary" state="enabled" label="Stop" loading={run === 'stopping'} onClickButton={stop}/>
|
|
206
208
|
</Cluster>) : undefined}>
|
|
207
|
-
{run === 'done' ? (<Paragraph measure="none">{reply}</Paragraph>) : run === 'stopped' ? (
|
|
209
|
+
{run === 'done' ? (<Paragraph measure="none">{reply}</Paragraph>) : run === 'stopped' ? (
|
|
210
|
+
// The steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.
|
|
211
|
+
<Stack gap="medium">
|
|
212
|
+
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(current, true)}/>
|
|
213
|
+
<Paragraph measure="none">{stoppedNote}</Paragraph>
|
|
214
|
+
</Stack>) : (
|
|
208
215
|
// A real app wraps this part in a polite live region, since StepList has none.
|
|
209
216
|
<Stack gap="medium">
|
|
210
217
|
<Paragraph size="caption" tone="secondary" measure="none">{secondsLine(seconds)}</Paragraph>
|
|
@@ -214,7 +221,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
214
221
|
</Stack>
|
|
215
222
|
</Stack>
|
|
216
223
|
<Modal isOpen={viewing} title="Changed Files" onClose={function () { return setViewing(false); }} actions={<Button size="small" type="tertiary" state="enabled" label="Close" onClickButton={function () { return setViewing(false); }}/>}>
|
|
217
|
-
<Paragraph measure="none">
|
|
224
|
+
<Paragraph measure="none">These files change when you apply the changes.</Paragraph>
|
|
218
225
|
<List marker="dot" size="body1" items={changedFiles.map(function (f) { return (<Stack key={f.path} gap="small">
|
|
219
226
|
<Paragraph mono measure="none">{f.path}</Paragraph>
|
|
220
227
|
<Paragraph size="body2" tone="secondary" measure="none">{f.change}</Paragraph>
|
|
@@ -22,9 +22,11 @@ var firstSteps = [
|
|
|
22
22
|
'Open a pull request for review',
|
|
23
23
|
];
|
|
24
24
|
var reply = 'The pricing page is updated, and the pull request is open for review.';
|
|
25
|
-
// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.
|
|
26
|
+
// Once the run is stopped, the whole list shows: the step it stopped on and the steps after it are cancelled.
|
|
27
|
+
function stepsUpTo(steps, current, stopped) {
|
|
28
|
+
if (stopped === void 0) { stopped = false; }
|
|
29
|
+
return (stopped ? steps : steps.slice(0, current + 1)).map(function (label, i) { return ({ label: label, status: i < current ? 'done' : stopped ? 'cancelled' : 'running' }); });
|
|
28
30
|
}
|
|
29
31
|
function secondsLine(seconds) {
|
|
30
32
|
return "Working for ".concat(seconds, " ").concat(seconds === 1 ? 'second' : 'seconds');
|
|
@@ -198,7 +200,12 @@ export default function AgentPlanProposalSteps() {
|
|
|
198
200
|
<Cluster>
|
|
199
201
|
<Button ref={stopButton} size="small" type="secondary" state="enabled" label="Stop" loading={run === 'stopping'} onClickButton={stop}/>
|
|
200
202
|
</Cluster>) : undefined}>
|
|
201
|
-
{run === 'done' ? (<Paragraph measure="none">{reply}</Paragraph>) : run === 'stopped' ? (
|
|
203
|
+
{run === 'done' ? (<Paragraph measure="none">{reply}</Paragraph>) : run === 'stopped' ? (
|
|
204
|
+
// The steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.
|
|
205
|
+
<Stack gap="medium">
|
|
206
|
+
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(steps, current, true)}/>
|
|
207
|
+
<Paragraph measure="none">{stoppedNote}</Paragraph>
|
|
208
|
+
</Stack>) : (
|
|
202
209
|
// A real app wraps this part in a polite live region, since StepList has none.
|
|
203
210
|
<Stack gap="medium">
|
|
204
211
|
<Paragraph size="caption" tone="secondary" measure="none">{secondsLine(seconds)}</Paragraph>
|
|
@@ -2,21 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
The agent is about to change shared work and needs the person to approve it first.
|
|
4
4
|
|
|
5
|
+
For: an agent
|
|
6
|
+
|
|
5
7
|
## Do
|
|
6
8
|
|
|
7
|
-
- Follow the rule 'An agent asks before a risky action': the agent does nothing until the person presses 'Approve'.
|
|
9
|
+
- Follow the rule 'An agent asks before a risky action': the agent does nothing until the person presses 'Approve', or 'Apply Changes' on a changes card.
|
|
8
10
|
- Put the card in the agent's `Message`, in a `Surface` with a heading, the plan, then the buttons.
|
|
9
11
|
- List every step in a `<StepList numbered>`, in the order the agent will do them, each one waiting.
|
|
12
|
+
- Say what the run will touch before it starts: the files, tools or people.
|
|
10
13
|
- Offer 'View Changes' when the changes are ready, so the person sees them before they approve. It opens a `Modal` that lists them.
|
|
11
|
-
- List each changed file in that Modal with one line on what changes in it.
|
|
14
|
+
- List each changed file in that Modal with one line on what changes in it.
|
|
15
|
+
- Follow the case 'Review of an agent's changes' when the person needs to read the changed lines.
|
|
12
16
|
- Order the steps card's buttons 'Cancel', 'Edit', then 'Approve' as the primary Button, at the start of the row under the plan.
|
|
13
|
-
- Order the changes card's buttons 'Cancel', 'Request Changes', then '
|
|
14
|
-
- Let the product write the
|
|
17
|
+
- Order the changes card's buttons 'Cancel', 'Request Changes', then 'Apply Changes' as the primary Button, as the case 'Review of an agent's changes' does.
|
|
18
|
+
- Let the product write the labels 'Approve' and 'Apply Changes'. The agent never writes the label of an approve or merge button.
|
|
15
19
|
- Show the waiting time on the card while it waits, and while the person edits: 'Waits 10 more minutes, then cancels.'
|
|
16
20
|
- Notify the person who asked when the agent needs their answer.
|
|
17
21
|
- Make the pressed Button `loading` and keep its label. Disable the others while the request runs.
|
|
18
22
|
- Keep the card and its buttons when a request fails. Show an inline error `Alert` above the buttons, as the rule 'A form error shows next to the problem' says.
|
|
19
|
-
- Mark
|
|
23
|
+
- Mark a steps card with an 'Approved' or 'Cancelled' `Tag` once it is decided, and remove its buttons.
|
|
24
|
+
- Mark a changes card with an 'Applied', 'Rejected' or 'Cancelled' `Tag`, as the case 'Review of an agent's changes' does.
|
|
20
25
|
- Announce the decided `Tag` politely: the app wraps it in a polite live region.
|
|
21
26
|
- Keep an approved card as the record: the steps as they were approved, none running, and no buttons.
|
|
22
27
|
- Move the run to its own progress row under the card, as the case 'Agent at work' shows, with its 'Stop'.
|
|
@@ -84,9 +89,10 @@ const reply = 'The pricing page is updated, and the pull request is open for rev
|
|
|
84
89
|
type Status = 'open' | 'editing' | 'approved' | 'cancelled';
|
|
85
90
|
type Run = 'running' | 'stopping' | 'stopped' | 'done';
|
|
86
91
|
|
|
87
|
-
// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.
|
|
93
|
+
// Once the run is stopped, the whole list shows: the step it stopped on and the steps after it are cancelled.
|
|
94
|
+
function stepsUpTo(steps: string[], current: number, stopped = false): StepListStep[] {
|
|
95
|
+
return (stopped ? steps : steps.slice(0, current + 1)).map((label, i) => ({ label, status: i < current ? 'done' : stopped ? 'cancelled' : 'running' }));
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
function secondsLine(seconds: number) {
|
|
@@ -319,7 +325,11 @@ export default function AgentPlanProposalSteps() {
|
|
|
319
325
|
{run === 'done' ? (
|
|
320
326
|
<Paragraph measure="none">{reply}</Paragraph>
|
|
321
327
|
) : run === 'stopped' ? (
|
|
322
|
-
|
|
328
|
+
// The steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.
|
|
329
|
+
<Stack gap="medium">
|
|
330
|
+
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(steps, current, true)} />
|
|
331
|
+
<Paragraph measure="none">{stoppedNote}</Paragraph>
|
|
332
|
+
</Stack>
|
|
323
333
|
) : (
|
|
324
334
|
// A real app wraps this part in a polite live region, since StepList has none.
|
|
325
335
|
<Stack gap="medium">
|
|
@@ -338,7 +348,7 @@ export default function AgentPlanProposalSteps() {
|
|
|
338
348
|
|
|
339
349
|
## Option: Changes
|
|
340
350
|
|
|
341
|
-
Use when: The agent has changes ready to apply.
|
|
351
|
+
Use when: The agent has changes ready to apply, and one line for each file is enough.
|
|
342
352
|
|
|
343
353
|
Uses: `Button`, `Center`, `Cluster`, `Heading`, `List`, `Message`, `Modal`, `Paragraph`, `Stack`, `StepList`, `Surface`, `Tag`, `Textarea`, `TimeStamp`, `UserImage`
|
|
344
354
|
|
|
@@ -367,14 +377,14 @@ const agentName = 'Acme Agent';
|
|
|
367
377
|
const request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you update the pricing page for the new plans?' };
|
|
368
378
|
const proposedAt = new Date('2025-01-15T11:44:00Z');
|
|
369
379
|
|
|
370
|
-
//
|
|
380
|
+
// The changes are a list of the files they touch, each with what changes in it. The case 'Review of an agent's changes' shows the lines with `Diff`.
|
|
371
381
|
const changedFiles = [
|
|
372
382
|
{ path: 'pages/pricing.tsx', change: 'Adds the Team plan to the page.' },
|
|
373
383
|
{ path: 'data/plans.json', change: 'Sets the Pro price to $15 and adds the Team plan at $25 per seat.' },
|
|
374
384
|
{ path: 'components/planTable.tsx', change: 'Adds a column for the Team plan.' },
|
|
375
385
|
];
|
|
376
386
|
|
|
377
|
-
// The run after '
|
|
387
|
+
// The run after 'Apply Changes': one step per file.
|
|
378
388
|
const runSteps = changedFiles.map((f) => `Change ${f.path}`);
|
|
379
389
|
|
|
380
390
|
const reply = 'The three files are changed. The pricing page shows the new plans.';
|
|
@@ -382,9 +392,10 @@ const reply = 'The three files are changed. The pricing page shows the new plans
|
|
|
382
392
|
type Status = 'open' | 'requesting' | 'redoing' | 'approved' | 'cancelled';
|
|
383
393
|
type Run = 'running' | 'stopping' | 'stopped' | 'done';
|
|
384
394
|
|
|
385
|
-
// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
|
|
386
|
-
|
|
387
|
-
|
|
395
|
+
// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.
|
|
396
|
+
// Once the run is stopped, the whole list shows: the step it stopped on and the steps after it are cancelled.
|
|
397
|
+
function stepsUpTo(current: number, stopped = false): StepListStep[] {
|
|
398
|
+
return (stopped ? runSteps : runSteps.slice(0, current + 1)).map((label, i) => ({ label, status: i < current ? 'done' : stopped ? 'cancelled' : 'running' }));
|
|
388
399
|
}
|
|
389
400
|
|
|
390
401
|
function secondsLine(seconds: number) {
|
|
@@ -407,7 +418,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
407
418
|
const [pending, setPending] = useState<'approve' | 'cancel' | 'send' | null>(null);
|
|
408
419
|
const [viewing, setViewing] = useState(false);
|
|
409
420
|
const [draft, setDraft] = useState('');
|
|
410
|
-
// The run after '
|
|
421
|
+
// The run after 'Apply Changes', in its own progress row under the card.
|
|
411
422
|
const [run, setRun] = useState<Run | null>(null);
|
|
412
423
|
const [current, setCurrent] = useState(0);
|
|
413
424
|
const [seconds, setSeconds] = useState(0);
|
|
@@ -449,7 +460,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
449
460
|
}
|
|
450
461
|
|
|
451
462
|
// The card stays as the record, and the run shows in its own progress row below it.
|
|
452
|
-
// '
|
|
463
|
+
// 'Apply Changes' is gone and 'Stop' is the control that took its place, so focus goes to 'Stop'.
|
|
453
464
|
function startRun() {
|
|
454
465
|
setRun('running');
|
|
455
466
|
setCurrent(0);
|
|
@@ -547,7 +558,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
547
558
|
{/* A real app announces the decided Tag in a polite live region. */}
|
|
548
559
|
<Cluster gap="small">
|
|
549
560
|
<Heading level={2} size="subtitle1">Changes ready</Heading>
|
|
550
|
-
{status === 'approved' && <Tag variant="contained" size="small" color="success" label="
|
|
561
|
+
{status === 'approved' && <Tag variant="contained" size="small" color="success" label="Applied" />}
|
|
551
562
|
{status === 'cancelled' && <Tag variant="contained" size="small" label="Cancelled" />}
|
|
552
563
|
</Cluster>
|
|
553
564
|
<Paragraph measure="none">These changes set the Pro price to $15 and add the Team plan to the pricing page. Three files change.</Paragraph>
|
|
@@ -579,7 +590,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
579
590
|
<Button size="small" type="tertiary" state={pending === 'approve' ? 'disabled' : 'enabled'} label="Cancel" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />
|
|
580
591
|
<Button ref={requestButton} size="small" type="secondary" state={pending ? 'disabled' : 'enabled'} label="Request Changes" onClickButton={startRequest} />
|
|
581
592
|
{/* The product writes this label, never the agent. */}
|
|
582
|
-
<Button size="small" type="primary" state={pending === 'cancel' ? 'disabled' : 'enabled'} label="
|
|
593
|
+
<Button size="small" type="primary" state={pending === 'cancel' ? 'disabled' : 'enabled'} label="Apply Changes" loading={pending === 'approve'} onClickButton={() => decide('approve')} />
|
|
583
594
|
</Cluster>
|
|
584
595
|
)}
|
|
585
596
|
{status === 'requesting' && (
|
|
@@ -617,7 +628,11 @@ export default function AgentPlanProposalChanges() {
|
|
|
617
628
|
{run === 'done' ? (
|
|
618
629
|
<Paragraph measure="none">{reply}</Paragraph>
|
|
619
630
|
) : run === 'stopped' ? (
|
|
620
|
-
|
|
631
|
+
// The steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.
|
|
632
|
+
<Stack gap="medium">
|
|
633
|
+
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(current, true)} />
|
|
634
|
+
<Paragraph measure="none">{stoppedNote}</Paragraph>
|
|
635
|
+
</Stack>
|
|
621
636
|
) : (
|
|
622
637
|
// A real app wraps this part in a polite live region, since StepList has none.
|
|
623
638
|
<Stack gap="medium">
|
|
@@ -635,7 +650,7 @@ export default function AgentPlanProposalChanges() {
|
|
|
635
650
|
onClose={() => setViewing(false)}
|
|
636
651
|
actions={<Button size="small" type="tertiary" state="enabled" label="Close" onClickButton={() => setViewing(false)} />}
|
|
637
652
|
>
|
|
638
|
-
<Paragraph measure="none">
|
|
653
|
+
<Paragraph measure="none">These files change when you apply the changes.</Paragraph>
|
|
639
654
|
<List
|
|
640
655
|
marker="dot"
|
|
641
656
|
size="body1"
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The agent needs an answer from the person before it can go on. It needs a fact or a decision only the person has. For ways forward in its own work, see the case 'Agent options'.
|
|
4
4
|
|
|
5
|
+
For: an agent
|
|
6
|
+
|
|
5
7
|
## Do
|
|
6
8
|
|
|
7
9
|
- Put the card in the agent's `Message`, in a `Surface` with the question as its heading.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The product will not let the agent answer a request, for example because the workspace used all its agent replies for the month, reached its spending cap, or sent too many requests at once.
|
|
4
4
|
|
|
5
|
+
For: an agent
|
|
6
|
+
|
|
5
7
|
## Answer
|
|
6
8
|
|
|
7
9
|
The refusal says in one plain sentence which limit was reached, and either who can change it or when to try again. A person who can lift the limit gets the one button that does it, such as Upgrade or Change Budget Cap. When an admin can lift the limit, everyone else is told to ask a workspace admin. A limit that passes with time says when to try again instead.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AgentRunFailureLimitReached(): import("react").JSX.Element;
|