@skillcdn/console 0.6.2 → 0.6.4
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 +16 -9
- package/SKILLCDN.md +3 -2
- package/dist/agent-page.d.ts +2 -0
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +46 -5
- package/dist/agent-page.js.map +1 -1
- package/dist/agent-state.d.ts +9 -0
- package/dist/agent-state.d.ts.map +1 -0
- package/dist/agent-state.js +28 -0
- package/dist/agent-state.js.map +1 -0
- package/dist/api.d.ts +6 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -4
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +948 -252
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +44 -7
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +168 -13
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +82 -9
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +855 -331
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/pack.d.ts +13 -12
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +33 -45
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/plugin-cli.d.ts.map +1 -1
- package/dist/cli/plugin-cli.js +8 -5
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/runner-files.d.ts +16 -0
- package/dist/cli/runner-files.d.ts.map +1 -0
- package/dist/cli/runner-files.js +125 -0
- package/dist/cli/runner-files.js.map +1 -0
- package/dist/cli/runner-host.d.ts +7 -0
- package/dist/cli/runner-host.d.ts.map +1 -1
- package/dist/cli/runner-host.js +40 -2
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/cli/skill-path.d.ts +11 -0
- package/dist/cli/skill-path.d.ts.map +1 -0
- package/dist/cli/skill-path.js +44 -0
- package/dist/cli/skill-path.js.map +1 -0
- package/dist/client.d.ts +32 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +93 -6
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +202 -10
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts +6 -6
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +16 -9
- package/dist/components/agents.js.map +1 -1
- package/dist/components/people.d.ts.map +1 -1
- package/dist/components/people.js +7 -2
- package/dist/components/people.js.map +1 -1
- package/dist/components/picker.d.ts +16 -0
- package/dist/components/picker.d.ts.map +1 -1
- package/dist/components/picker.js +69 -4
- package/dist/components/picker.js.map +1 -1
- package/dist/console.css +40 -0
- package/dist/console.js +2 -2
- package/dist/console.js.map +1 -1
- package/dist/feed-words.d.ts.map +1 -1
- package/dist/feed-words.js +12 -1
- package/dist/feed-words.js.map +1 -1
- package/dist/i18n/en.d.ts +64 -6
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +59 -10
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +49 -9
- package/dist/i18n/ko.js.map +1 -1
- package/dist/limits.d.ts +26 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +26 -0
- package/dist/limits.js.map +1 -1
- package/dist/onboarding.d.ts +18 -6
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +42 -7
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/args.d.ts +24 -2
- package/dist/plugin/args.d.ts.map +1 -1
- package/dist/plugin/args.js +20 -2
- package/dist/plugin/args.js.map +1 -1
- package/dist/plugin/context.d.ts +39 -7
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/define.d.ts.map +1 -1
- package/dist/plugin/define.js +12 -3
- package/dist/plugin/define.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +2 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +1 -0
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/routes.d.ts +2 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +2 -0
- package/dist/routes.js.map +1 -1
- package/dist/rules.d.ts +4 -1
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +5 -2
- package/dist/rules.js.map +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +9 -3
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +53 -1
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +18 -3
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +18 -0
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +77 -1
- package/dist/runner/config.js.map +1 -1
- package/dist/runner/desk.d.ts +7 -0
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +14 -4
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/message.d.ts +16 -22
- package/dist/runner/message.d.ts.map +1 -1
- package/dist/runner/message.js +72 -120
- package/dist/runner/message.js.map +1 -1
- package/dist/runner/runner.d.ts +41 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +557 -23
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack-status.d.ts +19 -0
- package/dist/runner/slack-status.d.ts.map +1 -0
- package/dist/runner/slack-status.js +332 -0
- package/dist/runner/slack-status.js.map +1 -0
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +258 -59
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +128 -15
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js.map +1 -1
- package/dist/runner/usage.d.ts +6 -1
- package/dist/runner/usage.d.ts.map +1 -1
- package/dist/runner/usage.js +9 -2
- package/dist/runner/usage.js.map +1 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +635 -6
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +197 -15
- package/dist/schemas.js.map +1 -1
- package/dist/secret-file.d.ts +21 -0
- package/dist/secret-file.d.ts.map +1 -0
- package/dist/secret-file.js +59 -0
- package/dist/secret-file.js.map +1 -0
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +3 -2
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +2 -2
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +6 -5
- package/dist/setup-guide.js.map +1 -1
- package/dist/vocabulary.d.ts +17 -2
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +15 -2
- package/dist/vocabulary.js.map +1 -1
- package/dist/wake-text.d.ts +43 -0
- package/dist/wake-text.d.ts.map +1 -0
- package/dist/wake-text.js +115 -0
- package/dist/wake-text.js.map +1 -0
- package/docs/specs/cli.md +39 -25
- package/docs/specs/plugins.md +10 -9
- package/docs/specs/rest.md +34 -15
- package/docs/specs/runner.md +108 -25
- package/docs/start.md +28 -6
- package/package.json +3 -3
- package/skills/building-a-plugin/SKILL.md +2 -2
- package/skills/deploying-a-console/SKILL.md +3 -3
- package/skills/deploying-a-console/references/access.md +15 -1
- package/skills/deploying-a-console/references/resources.md +2 -2
- package/skills/deploying-a-console/scripts/github-app.mjs +593 -0
- package/skills/keeping-the-pack/SKILL.md +87 -0
- package/skills/planning-the-board/SKILL.md +6 -6
- package/skills/planning-the-board/references/a-task.md +1 -1
- package/skills/planning-the-board/references/setting-up.md +9 -5
- package/skills/running-an-agent/SKILL.md +21 -17
- package/skills/running-an-agent/references/preparing-the-machine.md +4 -3
- package/skills/running-an-agent/references/several-tasks.md +8 -2
- package/skills/running-an-agent/references/slack-app.md +31 -8
- package/skills/running-an-agent/references/the-account-and-the-invitation.md +1 -1
- package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -1
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +4 -4
- package/skills/running-an-agent/references/your-first-task.md +11 -5
- package/skills/trying-a-console/SKILL.md +136 -0
- package/skills/trying-a-console/references/when-it-does-not-go.md +30 -0
- package/skills/working-the-board/SKILL.md +6 -6
- package/skills/working-the-board/references/terms.md +3 -1
- package/skills/working-the-board/references/the-pack.md +14 -7
- package/skills/working-the-board/references/what-they-were-told.md +1 -1
- package/src/agent-page.tsx +111 -4
- package/src/agent-state.ts +33 -0
- package/src/api.ts +43 -0
- package/src/cli/cli.ts +1190 -313
- package/src/cli/format.ts +207 -13
- package/src/cli/help.ts +991 -372
- package/src/cli/pack.ts +55 -62
- package/src/cli/plugin-cli.ts +8 -5
- package/src/cli/runner-files.ts +137 -0
- package/src/cli/runner-host.ts +48 -2
- package/src/cli/skill-path.ts +51 -0
- package/src/client.ts +103 -0
- package/src/components/agent-page.tsx +446 -20
- package/src/components/agents.tsx +27 -28
- package/src/components/people.tsx +7 -3
- package/src/components/picker.tsx +79 -5
- package/src/console.tsx +1 -1
- package/src/feed-words.ts +14 -1
- package/src/i18n/en.ts +64 -11
- package/src/i18n/ko.ts +55 -9
- package/src/limits.ts +26 -0
- package/src/onboarding.ts +60 -21
- package/src/plugin/args.ts +29 -3
- package/src/plugin/context.ts +40 -7
- package/src/plugin/define.ts +18 -3
- package/src/plugin/rest-schemas.ts +3 -0
- package/src/routes.ts +2 -0
- package/src/rules.ts +5 -2
- package/src/runner/acp.ts +9 -3
- package/src/runner/claude.ts +58 -1
- package/src/runner/codex.ts +18 -3
- package/src/runner/config.ts +114 -1
- package/src/runner/desk.ts +15 -4
- package/src/runner/message.ts +88 -126
- package/src/runner/runner.ts +682 -27
- package/src/runner/slack-status.ts +423 -0
- package/src/runner/slack.ts +310 -67
- package/src/runner/types.ts +124 -13
- package/src/runner/usage.ts +16 -3
- package/src/runner.ts +4 -0
- package/src/schemas.ts +245 -13
- package/src/secret-file.ts +76 -0
- package/src/services.ts +3 -2
- package/src/setup-guide.ts +6 -5
- package/src/styles/README.md +1 -1
- package/src/styles/pages/agents.css +40 -0
- package/src/vocabulary.ts +21 -2
- package/src/wake-text.ts +133 -0
- package/dist/cli/command-words.d.ts +0 -20
- package/dist/cli/command-words.d.ts.map +0 -1
- package/dist/cli/command-words.js +0 -51
- package/dist/cli/command-words.js.map +0 -1
- package/src/cli/command-words.ts +0 -56
|
@@ -9,20 +9,30 @@ import {
|
|
|
9
9
|
useRef,
|
|
10
10
|
useState,
|
|
11
11
|
} from "react";
|
|
12
|
+
import { reasonMoment } from "../agent-state.js";
|
|
12
13
|
import {
|
|
13
14
|
type AgentState,
|
|
14
15
|
type FileUpload,
|
|
16
|
+
isSecretName,
|
|
17
|
+
MAX_AGENT_SECRET_BYTES,
|
|
18
|
+
MAX_AGENT_SECRET_NAME_LENGTH,
|
|
15
19
|
MAX_FILE_BYTES,
|
|
20
|
+
MAX_SECRET_FILE_BYTES,
|
|
21
|
+
MAX_SECRET_OFFER_NOTE_LENGTH,
|
|
16
22
|
MAX_SIGNAL_ATTACHMENTS,
|
|
17
23
|
MAX_SIGNAL_LENGTH,
|
|
18
24
|
type RestAgent,
|
|
19
25
|
type RestAgentRunner,
|
|
20
26
|
type RestAgentSecret,
|
|
27
|
+
type RestAgentSecretOffer,
|
|
21
28
|
type RestAgentSession,
|
|
22
29
|
type RestAgentUsageWindow,
|
|
23
30
|
type RestPerson,
|
|
24
31
|
type RestSignal,
|
|
25
32
|
type RestTranscriptEvent,
|
|
33
|
+
SECRET_OFFER_DAYS,
|
|
34
|
+
type SecretFileRefusal,
|
|
35
|
+
secretOfFile,
|
|
26
36
|
usageNear,
|
|
27
37
|
usageSaidTogether,
|
|
28
38
|
usedHundredths,
|
|
@@ -123,10 +133,14 @@ export function AgentUsage(props: {
|
|
|
123
133
|
);
|
|
124
134
|
}
|
|
125
135
|
|
|
126
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* The state of an agent account as a badge: the word, and where there is room since when it
|
|
138
|
+
* stands so, right after the word it is the moment of, then why, with when that was said where
|
|
139
|
+
* it is another moment than the state's.
|
|
140
|
+
*/
|
|
127
141
|
export function AgentStateBadge(props: {
|
|
128
142
|
readonly state: RestAgent["state"];
|
|
129
|
-
/** With
|
|
143
|
+
/** With since when it stands so, why, and when its runner was last heard from. */
|
|
130
144
|
readonly full?: boolean | undefined;
|
|
131
145
|
}) {
|
|
132
146
|
const words = useWords().agents.page.state;
|
|
@@ -145,6 +159,7 @@ export function AgentStateBadge(props: {
|
|
|
145
159
|
}
|
|
146
160
|
const reasons: Readonly<Record<string, string>> = words.reasons;
|
|
147
161
|
const reason = state.reason === null ? undefined : (reasons[state.reason] ?? state.reason);
|
|
162
|
+
const said = reasonMoment(state);
|
|
148
163
|
const badge = (
|
|
149
164
|
<Badge
|
|
150
165
|
tone={STATE_TONES[state.state]}
|
|
@@ -162,7 +177,6 @@ export function AgentStateBadge(props: {
|
|
|
162
177
|
<span className="sc-agent-state">
|
|
163
178
|
{badge}
|
|
164
179
|
<span className="sc-note">
|
|
165
|
-
{reason !== undefined && `${reason} · `}
|
|
166
180
|
{words.since.before}
|
|
167
181
|
<Time iso={state.since} precision="clock" />
|
|
168
182
|
{words.since.after}
|
|
@@ -174,6 +188,19 @@ export function AgentStateBadge(props: {
|
|
|
174
188
|
{words.until.after}
|
|
175
189
|
</>
|
|
176
190
|
)}
|
|
191
|
+
{reason !== undefined && (
|
|
192
|
+
<>
|
|
193
|
+
{" · "}
|
|
194
|
+
{reason}
|
|
195
|
+
{said !== undefined && (
|
|
196
|
+
<>
|
|
197
|
+
{words.reasonAt.before}
|
|
198
|
+
<Time iso={said} precision="clock" />
|
|
199
|
+
{words.reasonAt.after}
|
|
200
|
+
</>
|
|
201
|
+
)}
|
|
202
|
+
</>
|
|
203
|
+
)}
|
|
177
204
|
{state.heardAt !== null && (
|
|
178
205
|
<>
|
|
179
206
|
{" · "}
|
|
@@ -2529,7 +2556,6 @@ export function AgentRunnerFacts(props: { readonly runner: RestAgentRunner | nul
|
|
|
2529
2556
|
<span key="product" className="sc-agent-product">
|
|
2530
2557
|
{runner.product.name}
|
|
2531
2558
|
{runner.product.version !== null && ` ${runner.product.version}`}
|
|
2532
|
-
{!runner.product.tried && <Badge tone="warning">{words.untried}</Badge>}
|
|
2533
2559
|
</span>,
|
|
2534
2560
|
],
|
|
2535
2561
|
] as [string, ReactNode][])),
|
|
@@ -2603,28 +2629,418 @@ export function AgentElsewhereList(props: {
|
|
|
2603
2629
|
);
|
|
2604
2630
|
}
|
|
2605
2631
|
|
|
2632
|
+
export interface AgentSecretOfferListProps {
|
|
2633
|
+
readonly offers: readonly RestAgentSecretOffer[];
|
|
2634
|
+
}
|
|
2635
|
+
|
|
2636
|
+
/** What a secret offered to an account stands as, in the tone a badge says it in. */
|
|
2637
|
+
const OFFER_TONES = {
|
|
2638
|
+
waiting: "accent",
|
|
2639
|
+
taken: "success",
|
|
2640
|
+
left: "neutral",
|
|
2641
|
+
lapsed: "neutral",
|
|
2642
|
+
} as const;
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* The secrets offered to an agent account (ADR-0169), a row each: the name proposed, who offers
|
|
2646
|
+
* it and when, and how the offer stands. Never a value.
|
|
2647
|
+
*/
|
|
2648
|
+
export function AgentSecretOfferList(props: AgentSecretOfferListProps) {
|
|
2649
|
+
const words = useWords().agents.page.offers;
|
|
2650
|
+
return (
|
|
2651
|
+
<ul className="sc-divided sc-agent-secret-list" aria-label={words.title}>
|
|
2652
|
+
{props.offers.map((offer) => (
|
|
2653
|
+
<li key={offer.id} className="sc-small sc-agent-secret">
|
|
2654
|
+
<code>{offer.name}</code>
|
|
2655
|
+
<span className="sc-muted">
|
|
2656
|
+
{offer.by === null ? words.someone : personName(offer.by)}
|
|
2657
|
+
{" · "}
|
|
2658
|
+
<Time iso={offer.at} precision="day" />
|
|
2659
|
+
{offer.takenAs !== null && offer.takenAs !== offer.name && (
|
|
2660
|
+
<>
|
|
2661
|
+
{" · "}
|
|
2662
|
+
{words.takenAs(offer.takenAs)}
|
|
2663
|
+
</>
|
|
2664
|
+
)}
|
|
2665
|
+
</span>
|
|
2666
|
+
<Badge tone={OFFER_TONES[offer.state]} kind="state">
|
|
2667
|
+
{words.state[offer.state]}
|
|
2668
|
+
</Badge>
|
|
2669
|
+
</li>
|
|
2670
|
+
))}
|
|
2671
|
+
</ul>
|
|
2672
|
+
);
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
/** A file chosen as a secret's value: what it is called and how large it is, to show, and its text, to send. */
|
|
2676
|
+
interface ChosenSecret {
|
|
2677
|
+
readonly name: string;
|
|
2678
|
+
readonly bytes: number;
|
|
2679
|
+
readonly value: string;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
/** Why a file a person chose stands for no value: what the file is, or that it could not be read here. */
|
|
2683
|
+
type SecretFileProblem = SecretFileRefusal | "unread";
|
|
2684
|
+
|
|
2685
|
+
/**
|
|
2686
|
+
* The value of a secret on a form of the page (ADR-0184): typed unseen, or the text of a file
|
|
2687
|
+
* the person chose, a `.env` of several lines among them, as the command takes one with
|
|
2688
|
+
* `--file`. The file is read here, as bytes, and what it comes to is held until the form is sent
|
|
2689
|
+
* or the file taken out; one that is no value, too large, no text or empty, is refused with why
|
|
2690
|
+
* and nothing of it is kept. What was typed and what a file holds are never both the value.
|
|
2691
|
+
*/
|
|
2692
|
+
function useSecretValue() {
|
|
2693
|
+
const [typed, setTyped] = useState("");
|
|
2694
|
+
const [chosen, setChosen] = useState<ChosenSecret>();
|
|
2695
|
+
const [problem, setProblem] = useState<SecretFileProblem>();
|
|
2696
|
+
/** The file asked for last: one chosen after another is the one that stands, whichever is read first. */
|
|
2697
|
+
const asked = useRef(0);
|
|
2698
|
+
const refuse = (why: SecretFileProblem) => {
|
|
2699
|
+
setChosen(undefined);
|
|
2700
|
+
setProblem(why);
|
|
2701
|
+
};
|
|
2702
|
+
const choose = (file: File | undefined) => {
|
|
2703
|
+
if (file === undefined) {
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
asked.current += 1;
|
|
2707
|
+
const mine = asked.current;
|
|
2708
|
+
setProblem(undefined);
|
|
2709
|
+
// A file past what a value may ever be is refused by its size, unread.
|
|
2710
|
+
if (file.size > MAX_SECRET_FILE_BYTES) {
|
|
2711
|
+
refuse("too_large");
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
if (typeof FileReader === "undefined") {
|
|
2715
|
+
refuse("unread");
|
|
2716
|
+
return;
|
|
2717
|
+
}
|
|
2718
|
+
const reader = new FileReader();
|
|
2719
|
+
reader.onload = () => {
|
|
2720
|
+
if (mine !== asked.current) {
|
|
2721
|
+
return;
|
|
2722
|
+
}
|
|
2723
|
+
const read = reader.result;
|
|
2724
|
+
if (!(read instanceof ArrayBuffer)) {
|
|
2725
|
+
refuse("unread");
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
const found = secretOfFile(new Uint8Array(read));
|
|
2729
|
+
if ("refused" in found) {
|
|
2730
|
+
refuse(found.refused);
|
|
2731
|
+
return;
|
|
2732
|
+
}
|
|
2733
|
+
setTyped("");
|
|
2734
|
+
setChosen({ name: file.name, bytes: file.size, value: found.value });
|
|
2735
|
+
};
|
|
2736
|
+
reader.onerror = () => {
|
|
2737
|
+
if (mine === asked.current) {
|
|
2738
|
+
refuse("unread");
|
|
2739
|
+
}
|
|
2740
|
+
};
|
|
2741
|
+
reader.readAsArrayBuffer(file);
|
|
2742
|
+
};
|
|
2743
|
+
return {
|
|
2744
|
+
/** The value as it would be sent: the file's text where one is chosen, else what was typed. */
|
|
2745
|
+
value: chosen?.value ?? typed,
|
|
2746
|
+
typed,
|
|
2747
|
+
chosen,
|
|
2748
|
+
problem,
|
|
2749
|
+
type: (value: string) => {
|
|
2750
|
+
setTyped(value);
|
|
2751
|
+
setProblem(undefined);
|
|
2752
|
+
},
|
|
2753
|
+
choose,
|
|
2754
|
+
/** Takes the file out, or empties the form once it was sent. */
|
|
2755
|
+
clear: () => {
|
|
2756
|
+
asked.current += 1;
|
|
2757
|
+
setTyped("");
|
|
2758
|
+
setChosen(undefined);
|
|
2759
|
+
setProblem(undefined);
|
|
2760
|
+
},
|
|
2761
|
+
};
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
export interface SecretValueInputProps {
|
|
2765
|
+
/** What the field is called, for whoever does not see it. */
|
|
2766
|
+
readonly label: string;
|
|
2767
|
+
readonly placeholder?: string | undefined;
|
|
2768
|
+
/** What was typed, shown as dots. */
|
|
2769
|
+
readonly typed: string;
|
|
2770
|
+
/** The file chosen in the place of what is typed: its name and how large it is, and never its text. */
|
|
2771
|
+
readonly chosen: { readonly name: string; readonly bytes: number } | undefined;
|
|
2772
|
+
readonly disabled?: boolean | undefined;
|
|
2773
|
+
readonly onType: (value: string) => void;
|
|
2774
|
+
/** Takes the chosen file out, and the field is typed into again. */
|
|
2775
|
+
readonly onClear: () => void;
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
/**
|
|
2779
|
+
* Where a secret's value stands on a form: a field typed unseen, or, once a file was chosen,
|
|
2780
|
+
* the file by its name with the way to take it out. A file's name is text a person brought, and
|
|
2781
|
+
* is drawn as text.
|
|
2782
|
+
*/
|
|
2783
|
+
export function SecretValueInput(props: SecretValueInputProps) {
|
|
2784
|
+
const words = useWords().agents.page.secretFile;
|
|
2785
|
+
const { chosen } = props;
|
|
2786
|
+
if (chosen === undefined) {
|
|
2787
|
+
return (
|
|
2788
|
+
<input
|
|
2789
|
+
className="sc-input"
|
|
2790
|
+
type="password"
|
|
2791
|
+
aria-label={props.label}
|
|
2792
|
+
placeholder={props.placeholder}
|
|
2793
|
+
value={props.typed}
|
|
2794
|
+
autoComplete="new-password"
|
|
2795
|
+
disabled={props.disabled}
|
|
2796
|
+
onChange={(event) => props.onType(event.target.value)}
|
|
2797
|
+
/>
|
|
2798
|
+
);
|
|
2799
|
+
}
|
|
2800
|
+
return (
|
|
2801
|
+
<ul className="sc-chosen-files" aria-label={props.label}>
|
|
2802
|
+
<li className="sc-chosen-file sc-agent-secret-file">
|
|
2803
|
+
<span className="sc-agent-secret-file-name">{chosen.name}</span>{" "}
|
|
2804
|
+
<span className="sc-muted">{formatBytes(chosen.bytes)}</span>{" "}
|
|
2805
|
+
<Button
|
|
2806
|
+
variant="ghost"
|
|
2807
|
+
size="sm"
|
|
2808
|
+
aria-label={words.remove(chosen.name)}
|
|
2809
|
+
disabled={props.disabled}
|
|
2810
|
+
onClick={props.onClear}
|
|
2811
|
+
>
|
|
2812
|
+
×
|
|
2813
|
+
</Button>
|
|
2814
|
+
</li>
|
|
2815
|
+
</ul>
|
|
2816
|
+
);
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
export interface SecretValueMoreProps {
|
|
2820
|
+
readonly disabled?: boolean | undefined;
|
|
2821
|
+
/** Called with the file a person chose as the value. */
|
|
2822
|
+
readonly onChoose: (file: File | undefined) => void;
|
|
2823
|
+
/**
|
|
2824
|
+
* The day the value ends on: `null` where it ends on none, which is how a form begins; else
|
|
2825
|
+
* what the date field gives, empty until a day is entered.
|
|
2826
|
+
*/
|
|
2827
|
+
readonly expiresOn: string | null;
|
|
2828
|
+
readonly onExpiresOn: (day: string | null) => void;
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
/**
|
|
2832
|
+
* Under a secret's fields, what the command says with flags (ADR-0184): the way to choose a
|
|
2833
|
+
* file as the value (`--file`), and the day the value ends on (`--expires`), which a token made
|
|
2834
|
+
* for a time has and most secrets have not. So that it ends on no day is what stands chosen, in
|
|
2835
|
+
* words, and the day's field is there only once a person says the value has one: an empty date
|
|
2836
|
+
* field said nothing of what leaving it empty means. The day is the value's own, never an
|
|
2837
|
+
* offer's, which waits its days whatever is said here.
|
|
2838
|
+
*/
|
|
2839
|
+
export function SecretValueMore(props: SecretValueMoreProps) {
|
|
2840
|
+
const words = useWords().agents.page.secretFile;
|
|
2841
|
+
const dated = props.expiresOn !== null;
|
|
2842
|
+
return (
|
|
2843
|
+
<div className="sc-agent-secret-more">
|
|
2844
|
+
<label className="sc-button sc-button-ghost sc-button-sm sc-file-choice">
|
|
2845
|
+
{words.choose}
|
|
2846
|
+
<input
|
|
2847
|
+
className="sc-file-input"
|
|
2848
|
+
type="file"
|
|
2849
|
+
disabled={props.disabled}
|
|
2850
|
+
onChange={(event) => {
|
|
2851
|
+
props.onChoose(event.target.files?.[0]);
|
|
2852
|
+
// The box is emptied, so that a file taken out can be chosen again.
|
|
2853
|
+
event.target.value = "";
|
|
2854
|
+
}}
|
|
2855
|
+
/>
|
|
2856
|
+
</label>
|
|
2857
|
+
<label className="sc-field sc-field-inline">
|
|
2858
|
+
<span className="sc-field-label">{words.ends}</span>
|
|
2859
|
+
<select
|
|
2860
|
+
className="sc-input"
|
|
2861
|
+
value={dated ? "day" : "none"}
|
|
2862
|
+
disabled={props.disabled}
|
|
2863
|
+
onChange={(event) => props.onExpiresOn(event.target.value === "day" ? "" : null)}
|
|
2864
|
+
>
|
|
2865
|
+
<option value="none">{words.endsNever}</option>
|
|
2866
|
+
<option value="day">{words.endsOnDay}</option>
|
|
2867
|
+
</select>
|
|
2868
|
+
</label>
|
|
2869
|
+
{dated && (
|
|
2870
|
+
<label className="sc-field sc-field-inline">
|
|
2871
|
+
<span className="sc-field-label">{words.expiresOn}</span>
|
|
2872
|
+
<input
|
|
2873
|
+
className="sc-input"
|
|
2874
|
+
type="date"
|
|
2875
|
+
// A day was asked for: the form is not sent without one, or the value would be kept
|
|
2876
|
+
// as one that never ends.
|
|
2877
|
+
required
|
|
2878
|
+
value={props.expiresOn ?? ""}
|
|
2879
|
+
disabled={props.disabled}
|
|
2880
|
+
onChange={(event) => props.onExpiresOn(event.target.value)}
|
|
2881
|
+
/>
|
|
2882
|
+
</label>
|
|
2883
|
+
)}
|
|
2884
|
+
</div>
|
|
2885
|
+
);
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
/** Why a chosen file stands for no value, as a line under the form. Nothing of the file but that. */
|
|
2889
|
+
export function SecretFileProblemLine(props: { readonly problem: SecretFileProblem | undefined }) {
|
|
2890
|
+
const words = useWords().agents.page.secretFile;
|
|
2891
|
+
if (props.problem === undefined) {
|
|
2892
|
+
return null;
|
|
2893
|
+
}
|
|
2894
|
+
return (
|
|
2895
|
+
<p className="sc-form-error" role="alert">
|
|
2896
|
+
{props.problem === "too_large"
|
|
2897
|
+
? words.tooLarge(formatBytes(MAX_AGENT_SECRET_BYTES))
|
|
2898
|
+
: props.problem === "not_text"
|
|
2899
|
+
? words.notText
|
|
2900
|
+
: props.problem === "empty"
|
|
2901
|
+
? words.empty
|
|
2902
|
+
: words.unread}
|
|
2903
|
+
</p>
|
|
2904
|
+
);
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
export interface AgentSecretOfferFormProps {
|
|
2908
|
+
/** What the account is called, for the line that says what becomes of an offer. */
|
|
2909
|
+
readonly account: string;
|
|
2910
|
+
readonly busy?: boolean | undefined;
|
|
2911
|
+
/** Offers a secret: the account takes it or leaves it, and nobody reads the value back. */
|
|
2912
|
+
readonly onOffer: (offer: {
|
|
2913
|
+
readonly name: string;
|
|
2914
|
+
readonly value: string;
|
|
2915
|
+
readonly note: string | undefined;
|
|
2916
|
+
/** The day the value ends on, where one was said. */
|
|
2917
|
+
readonly expiresOn: string | undefined;
|
|
2918
|
+
}) => void;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
/**
|
|
2922
|
+
* The way a member offers an agent account a secret (ADR-0169): its name, its value, typed
|
|
2923
|
+
* unseen or the text of a file chosen here (ADR-0184), the day it ends on where it has one, and
|
|
2924
|
+
* what it is for.
|
|
2925
|
+
*/
|
|
2926
|
+
export function AgentSecretOfferForm(props: AgentSecretOfferFormProps) {
|
|
2927
|
+
const words = useWords().agents.page.offers;
|
|
2928
|
+
const [name, setName] = useState("");
|
|
2929
|
+
const secret = useSecretValue();
|
|
2930
|
+
const [expiresOn, setExpiresOn] = useState<string | null>(null);
|
|
2931
|
+
const [note, setNote] = useState("");
|
|
2932
|
+
const busy = props.busy === true;
|
|
2933
|
+
const ready = isSecretName(name.trim()) && secret.value.length > 0;
|
|
2934
|
+
const submit = (event: FormEvent) => {
|
|
2935
|
+
event.preventDefault();
|
|
2936
|
+
if (!ready || busy) {
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
props.onOffer({
|
|
2940
|
+
name: name.trim(),
|
|
2941
|
+
value: secret.value,
|
|
2942
|
+
note: note.trim().length === 0 ? undefined : note.trim(),
|
|
2943
|
+
expiresOn: expiresOn === null || expiresOn === "" ? undefined : expiresOn,
|
|
2944
|
+
});
|
|
2945
|
+
setName("");
|
|
2946
|
+
secret.clear();
|
|
2947
|
+
setExpiresOn(null);
|
|
2948
|
+
setNote("");
|
|
2949
|
+
};
|
|
2950
|
+
// A field is its label's while it is typed into; a chosen file has a button of its own, which
|
|
2951
|
+
// a label would press.
|
|
2952
|
+
const ValueField = secret.chosen === undefined ? "label" : "div";
|
|
2953
|
+
return (
|
|
2954
|
+
<form className="sc-form" aria-label={words.offerAria} onSubmit={submit}>
|
|
2955
|
+
<div className="sc-field-row">
|
|
2956
|
+
<label className="sc-field">
|
|
2957
|
+
<span className="sc-field-label">{words.name}</span>
|
|
2958
|
+
<input
|
|
2959
|
+
className="sc-input"
|
|
2960
|
+
placeholder={words.namePlaceholder}
|
|
2961
|
+
value={name}
|
|
2962
|
+
maxLength={MAX_AGENT_SECRET_NAME_LENGTH}
|
|
2963
|
+
autoComplete="off"
|
|
2964
|
+
spellCheck={false}
|
|
2965
|
+
aria-invalid={name.trim() !== "" && !isSecretName(name.trim())}
|
|
2966
|
+
onChange={(event) => setName(event.target.value.toLowerCase())}
|
|
2967
|
+
/>
|
|
2968
|
+
</label>
|
|
2969
|
+
<ValueField className="sc-field">
|
|
2970
|
+
<span className="sc-field-label">{words.value}</span>
|
|
2971
|
+
<SecretValueInput
|
|
2972
|
+
label={words.value}
|
|
2973
|
+
typed={secret.typed}
|
|
2974
|
+
chosen={secret.chosen}
|
|
2975
|
+
disabled={busy}
|
|
2976
|
+
onType={secret.type}
|
|
2977
|
+
onClear={secret.clear}
|
|
2978
|
+
/>
|
|
2979
|
+
</ValueField>
|
|
2980
|
+
</div>
|
|
2981
|
+
<SecretValueMore
|
|
2982
|
+
disabled={busy}
|
|
2983
|
+
onChoose={secret.choose}
|
|
2984
|
+
expiresOn={expiresOn}
|
|
2985
|
+
onExpiresOn={setExpiresOn}
|
|
2986
|
+
/>
|
|
2987
|
+
<SecretFileProblemLine problem={secret.problem} />
|
|
2988
|
+
<label className="sc-field">
|
|
2989
|
+
<span className="sc-field-label">{words.note}</span>
|
|
2990
|
+
<input
|
|
2991
|
+
className="sc-input"
|
|
2992
|
+
value={note}
|
|
2993
|
+
maxLength={MAX_SECRET_OFFER_NOTE_LENGTH}
|
|
2994
|
+
autoComplete="off"
|
|
2995
|
+
onChange={(event) => setNote(event.target.value)}
|
|
2996
|
+
/>
|
|
2997
|
+
</label>
|
|
2998
|
+
<p className="sc-field-hint">{words.intro(props.account, SECRET_OFFER_DAYS)}</p>
|
|
2999
|
+
<div className="sc-form-actions">
|
|
3000
|
+
<Button type="submit" variant="primary" disabled={busy || !ready}>
|
|
3001
|
+
{words.offer}
|
|
3002
|
+
</Button>
|
|
3003
|
+
</div>
|
|
3004
|
+
</form>
|
|
3005
|
+
);
|
|
3006
|
+
}
|
|
3007
|
+
|
|
2606
3008
|
export interface AgentSecretListProps {
|
|
2607
3009
|
readonly secrets: readonly RestAgentSecret[];
|
|
2608
3010
|
readonly busy?: boolean | undefined;
|
|
2609
|
-
/**
|
|
2610
|
-
|
|
3011
|
+
/**
|
|
3012
|
+
* Seeds a secret, write-only: only the account reads the value back. With the day the value
|
|
3013
|
+
* ends on, where one was said.
|
|
3014
|
+
*/
|
|
3015
|
+
readonly onSeed: (name: string, value: string, expiresOn?: string) => void;
|
|
2611
3016
|
readonly onRemove: (name: string) => void;
|
|
2612
3017
|
}
|
|
2613
3018
|
|
|
2614
|
-
/**
|
|
3019
|
+
/**
|
|
3020
|
+
* The names of an agent account's secrets, and the way a supervisor seeds one or removes one:
|
|
3021
|
+
* the value typed unseen, or the text of a file chosen here, as the command takes one with
|
|
3022
|
+
* `--file` (ADR-0184). Never a value.
|
|
3023
|
+
*/
|
|
2615
3024
|
export function AgentSecretList(props: AgentSecretListProps) {
|
|
2616
3025
|
const words = useWords().agents.page.settings.secrets;
|
|
2617
3026
|
const [name, setName] = useState("");
|
|
2618
|
-
const
|
|
3027
|
+
const secret = useSecretValue();
|
|
3028
|
+
const [expiresOn, setExpiresOn] = useState<string | null>(null);
|
|
2619
3029
|
const busy = props.busy === true;
|
|
3030
|
+
const ready = isSecretName(name.trim()) && secret.value.length > 0;
|
|
2620
3031
|
const submit = (event: FormEvent) => {
|
|
2621
3032
|
event.preventDefault();
|
|
2622
|
-
if (
|
|
3033
|
+
if (!ready || busy) {
|
|
2623
3034
|
return;
|
|
2624
3035
|
}
|
|
2625
|
-
|
|
3036
|
+
if (expiresOn === null || expiresOn === "") {
|
|
3037
|
+
props.onSeed(name.trim(), secret.value);
|
|
3038
|
+
} else {
|
|
3039
|
+
props.onSeed(name.trim(), secret.value, expiresOn);
|
|
3040
|
+
}
|
|
2626
3041
|
setName("");
|
|
2627
|
-
|
|
3042
|
+
secret.clear();
|
|
3043
|
+
setExpiresOn(null);
|
|
2628
3044
|
};
|
|
2629
3045
|
return (
|
|
2630
3046
|
<div>
|
|
@@ -2658,22 +3074,32 @@ export function AgentSecretList(props: AgentSecretListProps) {
|
|
|
2658
3074
|
aria-label={words.name}
|
|
2659
3075
|
placeholder={words.namePlaceholder}
|
|
2660
3076
|
value={name}
|
|
3077
|
+
maxLength={MAX_AGENT_SECRET_NAME_LENGTH}
|
|
2661
3078
|
autoComplete="off"
|
|
2662
|
-
|
|
3079
|
+
spellCheck={false}
|
|
3080
|
+
aria-invalid={name.trim() !== "" && !isSecretName(name.trim())}
|
|
3081
|
+
onChange={(event) => setName(event.target.value.toLowerCase())}
|
|
2663
3082
|
/>
|
|
2664
|
-
<
|
|
2665
|
-
|
|
2666
|
-
type="password"
|
|
2667
|
-
aria-label={words.value}
|
|
3083
|
+
<SecretValueInput
|
|
3084
|
+
label={words.value}
|
|
2668
3085
|
placeholder={words.value}
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
3086
|
+
typed={secret.typed}
|
|
3087
|
+
chosen={secret.chosen}
|
|
3088
|
+
disabled={busy}
|
|
3089
|
+
onType={secret.type}
|
|
3090
|
+
onClear={secret.clear}
|
|
2672
3091
|
/>
|
|
2673
|
-
<Button type="submit" disabled={busy ||
|
|
3092
|
+
<Button type="submit" disabled={busy || !ready}>
|
|
2674
3093
|
{words.seed}
|
|
2675
3094
|
</Button>
|
|
3095
|
+
<SecretValueMore
|
|
3096
|
+
disabled={busy}
|
|
3097
|
+
onChoose={secret.choose}
|
|
3098
|
+
expiresOn={expiresOn}
|
|
3099
|
+
onExpiresOn={setExpiresOn}
|
|
3100
|
+
/>
|
|
2676
3101
|
</form>
|
|
3102
|
+
<SecretFileProblemLine problem={secret.problem} />
|
|
2677
3103
|
<p className="sc-field-hint">{words.intro}</p>
|
|
2678
3104
|
</div>
|
|
2679
3105
|
);
|