@skillcdn/console 0.6.1 → 0.6.3
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 +14 -7
- 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 +77 -30
- 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/agent-usage.d.ts +9 -6
- package/dist/agent-usage.d.ts.map +1 -1
- package/dist/agent-usage.js +38 -8
- package/dist/agent-usage.js.map +1 -1
- package/dist/api.d.ts +4 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4 -3
- 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 +369 -130
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +13 -4
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +43 -9
- 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 +780 -318
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/pack.d.ts +2 -2
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +6 -4
- package/dist/cli/pack.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 +110 -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/client.d.ts +22 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +61 -11
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +146 -35
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts +3 -2
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +9 -3
- package/dist/components/agents.js.map +1 -1
- package/dist/components/calendar.d.ts +24 -4
- package/dist/components/calendar.d.ts.map +1 -1
- package/dist/components/calendar.js +78 -35
- package/dist/components/calendar.js.map +1 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +40 -12
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts +2 -0
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +4 -0
- package/dist/data.js.map +1 -1
- package/dist/desk-page.js +5 -5
- package/dist/desk-page.js.map +1 -1
- package/dist/feed-words.d.ts.map +1 -1
- package/dist/feed-words.js +18 -1
- package/dist/feed-words.js.map +1 -1
- package/dist/i18n/en.d.ts +51 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +44 -2
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +52 -17
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +10 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +10 -0
- package/dist/limits.js.map +1 -1
- package/dist/plugin/capabilities.d.ts +1 -1
- package/dist/plugin/capabilities.d.ts.map +1 -1
- package/dist/plugin/capabilities.js +6 -1
- package/dist/plugin/capabilities.js.map +1 -1
- package/dist/plugin/context.d.ts +101 -8
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/limits.d.ts +7 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +7 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/testing.d.ts +2 -0
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +2 -0
- package/dist/plugin/testing.js.map +1 -1
- package/dist/rules.js +1 -1
- 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 +143 -10
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +14 -2
- 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 +20 -4
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/message.d.ts +26 -2
- package/dist/runner/message.d.ts.map +1 -1
- package/dist/runner/message.js +120 -32
- package/dist/runner/message.js.map +1 -1
- package/dist/runner/runner.d.ts +40 -2
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +533 -32
- 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 +17 -11
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +1199 -109
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +205 -6
- 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 +4 -4
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +3 -3
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +263 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +137 -5
- package/dist/schemas.js.map +1 -1
- package/dist/vocabulary.d.ts +7 -0
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +6 -0
- 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 +21 -12
- package/docs/specs/plugins.md +12 -7
- package/docs/specs/rest.md +14 -5
- package/docs/specs/runner.md +133 -26
- package/docs/start.md +26 -5
- package/package.json +3 -3
- package/skills/building-a-plugin/SKILL.md +3 -3
- 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/planning-the-board/references/setting-up.md +1 -1
- package/skills/running-an-agent/SKILL.md +18 -72
- package/skills/running-an-agent/references/preparing-the-machine.md +17 -0
- package/skills/running-an-agent/references/several-tasks.md +1 -1
- package/skills/running-an-agent/references/slack-app.md +55 -8
- package/skills/running-an-agent/references/the-account-and-the-invitation.md +5 -0
- package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -0
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +16 -0
- package/skills/running-an-agent/references/your-first-task.md +19 -0
- 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 +11 -15
- package/skills/working-the-board/references/a-pack-skills-questions.md +3 -0
- package/skills/working-the-board/references/a-plugins-commands.md +3 -0
- package/skills/working-the-board/references/a-review.md +3 -0
- package/skills/working-the-board/references/an-open-run.md +3 -0
- package/skills/working-the-board/references/requirements.md +7 -0
- package/skills/working-the-board/references/the-pack.md +3 -3
- package/skills/working-the-board/references/what-they-were-told.md +3 -0
- package/skills/working-the-board/references/work-given-in-chat.md +5 -0
- package/src/agent-page.tsx +133 -41
- package/src/agent-state.ts +33 -0
- package/src/agent-usage.ts +55 -12
- package/src/api.ts +23 -0
- package/src/cli/cli.ts +443 -137
- package/src/cli/format.ts +49 -9
- package/src/cli/help.ts +904 -359
- package/src/cli/pack.ts +6 -4
- package/src/cli/runner-files.ts +120 -0
- package/src/cli/runner-host.ts +48 -2
- package/src/client.ts +64 -0
- package/src/components/agent-page.tsx +264 -39
- package/src/components/agents.tsx +20 -5
- package/src/components/calendar.tsx +92 -36
- package/src/console.tsx +47 -10
- package/src/data.ts +6 -0
- package/src/desk-page.tsx +5 -5
- package/src/feed-words.ts +20 -1
- package/src/i18n/en.ts +50 -2
- package/src/i18n/ko.ts +62 -17
- package/src/index.ts +2 -0
- package/src/limits.ts +10 -0
- package/src/plugin/capabilities.ts +8 -1
- package/src/plugin/context.ts +103 -7
- package/src/plugin/limits.ts +7 -0
- package/src/plugin/testing.ts +4 -0
- package/src/rules.ts +1 -1
- package/src/runner/acp.ts +9 -3
- package/src/runner/claude.ts +159 -10
- package/src/runner/codex.ts +14 -2
- package/src/runner/config.ts +114 -1
- package/src/runner/desk.ts +23 -4
- package/src/runner/message.ts +144 -35
- package/src/runner/runner.ts +658 -35
- package/src/runner/slack-status.ts +423 -0
- package/src/runner/slack.ts +1509 -128
- package/src/runner/types.ts +200 -5
- package/src/runner/usage.ts +16 -3
- package/src/runner.ts +20 -1
- package/src/schemas.ts +161 -3
- package/src/vocabulary.ts +9 -0
- package/src/wake-text.ts +133 -0
package/src/cli/cli.ts
CHANGED
|
@@ -74,14 +74,9 @@ import {
|
|
|
74
74
|
deskWebTitleOf,
|
|
75
75
|
personDeskFiles,
|
|
76
76
|
} from "../runner/desk.js";
|
|
77
|
+
import { quotedLines } from "../runner/message.js";
|
|
77
78
|
import { ownRunnerModules } from "../runner/modules.js";
|
|
78
|
-
import {
|
|
79
|
-
createRunner,
|
|
80
|
-
GIT_TOKEN_SECRET,
|
|
81
|
-
type Runner,
|
|
82
|
-
type RunnerEnd,
|
|
83
|
-
type RunnerState,
|
|
84
|
-
} from "../runner/runner.js";
|
|
79
|
+
import { createRunner, GIT_TOKEN_SECRET, type Runner, type RunnerEnd } from "../runner/runner.js";
|
|
85
80
|
import type { ServiceCommand } from "../runner/types.js";
|
|
86
81
|
import {
|
|
87
82
|
hostOfLogin,
|
|
@@ -198,6 +193,7 @@ import {
|
|
|
198
193
|
formatRun,
|
|
199
194
|
formatRunLine,
|
|
200
195
|
formatSecretLine,
|
|
196
|
+
formatSecretOffer,
|
|
201
197
|
formatSignalLine,
|
|
202
198
|
formatTask,
|
|
203
199
|
formatTaskFollow,
|
|
@@ -213,7 +209,15 @@ import {
|
|
|
213
209
|
rulesMark,
|
|
214
210
|
setMomentZone,
|
|
215
211
|
} from "./format.js";
|
|
216
|
-
import {
|
|
212
|
+
import {
|
|
213
|
+
COMMAND_ALIASES,
|
|
214
|
+
formTyped,
|
|
215
|
+
held,
|
|
216
|
+
helpFor,
|
|
217
|
+
nearestCommands,
|
|
218
|
+
ownSkillPath,
|
|
219
|
+
usage,
|
|
220
|
+
} from "./help.js";
|
|
217
221
|
import { describeInstall, type Install, updateCommandFor } from "./install.js";
|
|
218
222
|
import {
|
|
219
223
|
awakeWords,
|
|
@@ -237,6 +241,7 @@ import {
|
|
|
237
241
|
skillPathIn,
|
|
238
242
|
skillsAround,
|
|
239
243
|
} from "./pack.js";
|
|
244
|
+
import { keptBySourceOf, keptFileOf, runnerStateOf } from "./runner-files.js";
|
|
240
245
|
import { type RunnerHost, workPath } from "./runner-host.js";
|
|
241
246
|
import { secretNotes } from "./secret-notes.js";
|
|
242
247
|
import {
|
|
@@ -416,10 +421,47 @@ function parse(args: readonly string[], options: OptionSpec, allowPositionals =
|
|
|
416
421
|
strict: true,
|
|
417
422
|
});
|
|
418
423
|
} catch (error) {
|
|
419
|
-
throw misuse(error
|
|
424
|
+
throw misuse(refusedByParser(error, options));
|
|
420
425
|
}
|
|
421
426
|
}
|
|
422
427
|
|
|
428
|
+
/**
|
|
429
|
+
* What the parser refused, in the command's own words (ADR-0167): an option that is none of
|
|
430
|
+
* the command's is answered with those it takes, so that the next try needs no page of help;
|
|
431
|
+
* what the parser says of a value is said as it says it, without its advice on other things.
|
|
432
|
+
*/
|
|
433
|
+
function refusedByParser(error: unknown, options: OptionSpec): string {
|
|
434
|
+
if (!(error instanceof Error)) {
|
|
435
|
+
return "The arguments were not understood.";
|
|
436
|
+
}
|
|
437
|
+
const code = "code" in error ? String(error.code) : "";
|
|
438
|
+
// What was typed is between the parser's first quote and the one its sentence goes on
|
|
439
|
+
// after: a word may hold a quote of its own (`it's`), and is said whole.
|
|
440
|
+
const ADVICE = ". To specify a positional argument ";
|
|
441
|
+
const named =
|
|
442
|
+
(code === "ERR_PARSE_ARGS_UNKNOWN_OPTION"
|
|
443
|
+
? /^Unknown option '(.*?)'(?:\. To specify a positional argument .*)?$/s
|
|
444
|
+
: /^Unexpected argument '(.*)'\. This command does not take positional arguments$/s
|
|
445
|
+
).exec(error.message)?.[1] ??
|
|
446
|
+
/'([^']*)'/.exec(error.message)?.[1] ??
|
|
447
|
+
"";
|
|
448
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
449
|
+
const own = Object.keys(options).map((name) => `--${name}`);
|
|
450
|
+
const takes = own.length === 0 ? "It takes none of its own" : `Its own are ${own.join(", ")}`;
|
|
451
|
+
// A word of a report or a title may begin with a dash, and is then no option at all:
|
|
452
|
+
// said where the command takes a word, and what was typed does not read as an option.
|
|
453
|
+
const dashed =
|
|
454
|
+
!error.message.includes(ADVICE) || /^--[a-z][a-z0-9-]*$/.test(named)
|
|
455
|
+
? ""
|
|
456
|
+
: " A word that begins with - and is no option goes after --.";
|
|
457
|
+
return `Not an option of this command: ${named}. ${takes}; --json, --project, --url and --account go with every command.${dashed}`;
|
|
458
|
+
}
|
|
459
|
+
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL") {
|
|
460
|
+
return `This command takes no word beside its options: ${named}.`;
|
|
461
|
+
}
|
|
462
|
+
return error.message;
|
|
463
|
+
}
|
|
464
|
+
|
|
423
465
|
type Values = ReturnType<typeof parse>["values"];
|
|
424
466
|
|
|
425
467
|
const text = (values: Values, name: string): string | undefined => {
|
|
@@ -1607,7 +1649,7 @@ const whoami: Command = async (args, io) => {
|
|
|
1607
1649
|
// agent here for where the skill is, and the workspace has rules whatever the project.
|
|
1608
1650
|
// The skill's path stands last, with nothing after it, to be copied as it is.
|
|
1609
1651
|
io.skillsDir === undefined
|
|
1610
|
-
? "Before the first task, read console rules and the skill working-the-board (
|
|
1652
|
+
? "Before the first task, read console rules and the skill working-the-board (in the skills folder of the package @skillcdn/console, which this build has none of beside it); for one command's flags, console help <command>."
|
|
1611
1653
|
: `Before the first task, read console rules and the skill working-the-board; for one command's flags, console help <command>. The skill: ${ownSkillPath(io.skillsDir)}`,
|
|
1612
1654
|
`This command is ${io.version ?? "of a version it does not know"}${io.install === undefined ? "" : `, ${describeInstall(io.install)}`}; ${consoleWords}.`,
|
|
1613
1655
|
...(verdict === "behind"
|
|
@@ -1895,6 +1937,7 @@ async function readThrough(
|
|
|
1895
1937
|
options: {
|
|
1896
1938
|
readonly words: ToolWords;
|
|
1897
1939
|
readonly nextPart?: ((cursor: string) => string) | undefined;
|
|
1940
|
+
readonly browseFolder?: ((path: string) => string) | undefined;
|
|
1898
1941
|
readonly data?: boolean | undefined;
|
|
1899
1942
|
readonly beside?: readonly (string | undefined)[] | undefined;
|
|
1900
1943
|
},
|
|
@@ -1904,6 +1947,7 @@ async function readThrough(
|
|
|
1904
1947
|
words: options.words,
|
|
1905
1948
|
json: session.json,
|
|
1906
1949
|
nextPart: options.nextPart,
|
|
1950
|
+
browseFolder: options.browseFolder,
|
|
1907
1951
|
room: roomFor(owner, options.beside ?? []),
|
|
1908
1952
|
});
|
|
1909
1953
|
} catch (error) {
|
|
@@ -2183,28 +2227,54 @@ async function readSkills(
|
|
|
2183
2227
|
});
|
|
2184
2228
|
return EXIT.ok;
|
|
2185
2229
|
}
|
|
2230
|
+
// The command that reads the next page of a folder or of a search (SkillCDN 0.6.3): this
|
|
2231
|
+
// one again, asked as it was, with the cursor the page ended on. Where a word of it has no
|
|
2232
|
+
// spelling both shells take, the command that was run is run again, and the line says why.
|
|
2233
|
+
const nextPage =
|
|
2234
|
+
(asked: readonly string[]) =>
|
|
2235
|
+
(next: string): string =>
|
|
2236
|
+
commandLine(extras.command, [
|
|
2237
|
+
...asked,
|
|
2238
|
+
...(limit === undefined ? [] : ["--limit", limit]),
|
|
2239
|
+
"--cursor",
|
|
2240
|
+
next,
|
|
2241
|
+
...(extras.again ?? []),
|
|
2242
|
+
]) ??
|
|
2243
|
+
`the command you ran, with --cursor ${commandWord(next) ?? JSON.stringify(next)} in place of any it had, each word quoted for your shell. ${NO_LINE_TO_RUN}`;
|
|
2186
2244
|
if (words !== undefined) {
|
|
2187
|
-
// One page of what the words find
|
|
2245
|
+
// One page of what the words find, which ends with the command that reads the next where
|
|
2246
|
+
// more was found. How a skill is loaded stands above it then, so that the command is last.
|
|
2188
2247
|
const found = await readThrough(
|
|
2189
2248
|
io,
|
|
2190
2249
|
session,
|
|
2191
2250
|
owner,
|
|
2192
2251
|
pack,
|
|
2193
2252
|
{ read: "find", words, path: folder, cursor, limit },
|
|
2194
|
-
{
|
|
2253
|
+
{
|
|
2254
|
+
words: toolWords,
|
|
2255
|
+
beside: [loading],
|
|
2256
|
+
nextPart: nextPage([
|
|
2257
|
+
"--search",
|
|
2258
|
+
words,
|
|
2259
|
+
...(given === undefined ? [] : [given]),
|
|
2260
|
+
...(within === undefined ? [] : ["--path", within]),
|
|
2261
|
+
]),
|
|
2262
|
+
},
|
|
2263
|
+
);
|
|
2264
|
+
say(jsonOfRead(session, pack, found), () =>
|
|
2265
|
+
found.next === undefined ? `${found.text}\n${loading}` : `${loading}\n${found.text}`,
|
|
2195
2266
|
);
|
|
2196
|
-
say(jsonOfRead(session, pack, found), () => `${found.text}\n${loading}`);
|
|
2197
2267
|
return EXIT.ok;
|
|
2198
2268
|
}
|
|
2199
2269
|
// One page of the folder, or of a file's outline, as the skillcdn command browses: a page
|
|
2200
|
-
// that ends before the folder does
|
|
2270
|
+
// that ends before the folder does ends with the command that reads the next.
|
|
2201
2271
|
const browsed = await readThrough(
|
|
2202
2272
|
io,
|
|
2203
2273
|
session,
|
|
2204
2274
|
owner,
|
|
2205
2275
|
pack,
|
|
2206
2276
|
{ read: "browse", path: folder, cursor, limit },
|
|
2207
|
-
{ words: toolWords },
|
|
2277
|
+
{ words: toolWords, nextPart: nextPage(given === undefined ? [] : [given]) },
|
|
2208
2278
|
);
|
|
2209
2279
|
say(jsonOfRead(session, pack, browsed), () => browsed.text);
|
|
2210
2280
|
return EXIT.ok;
|
|
@@ -2349,6 +2419,12 @@ async function readSkill(
|
|
|
2349
2419
|
nextPart: (next) =>
|
|
2350
2420
|
commandLine(command, [given, "--cursor", next, ...again]) ??
|
|
2351
2421
|
`the command you ran, with --cursor ${commandWord(next) ?? JSON.stringify(next)} in place of any it had, each word quoted for your shell. ${NO_LINE_TO_RUN}`,
|
|
2422
|
+
// The skill's own folder, where it does not list every file of it, as the command that
|
|
2423
|
+
// lists a folder of this pack (SkillCDN 0.6.3): the dot for the root, since the command
|
|
2424
|
+
// without a folder is the listing.
|
|
2425
|
+
browseFolder: (path) =>
|
|
2426
|
+
commandLine(`${command}s`, [path.length === 0 ? "." : path, ...again]) ??
|
|
2427
|
+
`${command}s with this skill's folder, quoted for your shell. ${NO_LINE_TO_RUN}`,
|
|
2352
2428
|
},
|
|
2353
2429
|
);
|
|
2354
2430
|
say(jsonOfRead(session, pack, loaded), () => loaded.text);
|
|
@@ -3463,6 +3539,9 @@ const task: Command = async (args, io) => {
|
|
|
3463
3539
|
if (args[0] === "restore") {
|
|
3464
3540
|
return taskRestore(args.slice(1), io);
|
|
3465
3541
|
}
|
|
3542
|
+
if (args[0] === "follow" || args[0] === "mute") {
|
|
3543
|
+
return following(args[0] === "follow")(args.slice(1), io);
|
|
3544
|
+
}
|
|
3466
3545
|
const { values, positionals } = parse(args, {});
|
|
3467
3546
|
const ref = theOne(positionals, "Say which task: console task <number|id>");
|
|
3468
3547
|
const session = await open(io, values);
|
|
@@ -3655,8 +3734,8 @@ const notify: Command = async (args, io) => {
|
|
|
3655
3734
|
);
|
|
3656
3735
|
};
|
|
3657
3736
|
|
|
3658
|
-
// Whether one task tells a member anything (ADR-0157): `follow` turns its notifications
|
|
3659
|
-
// `mute` off. A task turned on that their settings would be silent of tells them of
|
|
3737
|
+
// Whether one task tells a member anything (ADR-0157): `task follow` turns its notifications
|
|
3738
|
+
// on, `task mute` off. A task turned on that their settings would be silent of tells them of
|
|
3660
3739
|
// everything on it; one turned to what their settings say already is told by their kinds.
|
|
3661
3740
|
const following =
|
|
3662
3741
|
(turned: boolean): Command =>
|
|
@@ -3664,7 +3743,7 @@ const following =
|
|
|
3664
3743
|
const { values, positionals } = parse(args, {});
|
|
3665
3744
|
const ref = theOne(
|
|
3666
3745
|
positionals,
|
|
3667
|
-
`Say which task: console ${turned ? "follow" : "mute"} <number|id>`,
|
|
3746
|
+
`Say which task: console task ${turned ? "follow" : "mute"} <number|id>`,
|
|
3668
3747
|
);
|
|
3669
3748
|
const session = await open(io, values);
|
|
3670
3749
|
const project = await session.project();
|
|
@@ -4284,11 +4363,30 @@ const docs: Command = async (args, io) => {
|
|
|
4284
4363
|
return EXIT.ok;
|
|
4285
4364
|
};
|
|
4286
4365
|
|
|
4366
|
+
/** What a read of one page takes beside its path. */
|
|
4367
|
+
const DOC_READ_FLAGS: OptionSpec = {
|
|
4368
|
+
version: { type: "string" },
|
|
4369
|
+
versions: { type: "boolean" },
|
|
4370
|
+
};
|
|
4371
|
+
|
|
4372
|
+
/** Whether the words are a read of one page: one path, and no flag but a read's own. */
|
|
4373
|
+
function readsOnePage(args: readonly string[]): boolean {
|
|
4374
|
+
try {
|
|
4375
|
+
return parse(args, DOC_READ_FLAGS).positionals.length === 1;
|
|
4376
|
+
} catch {
|
|
4377
|
+
return false;
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4287
4381
|
const doc: Command = async (args, io) => {
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4382
|
+
// A page may be called by a form's word, `write`, and is read as any page is (ADR-0167):
|
|
4383
|
+
// the word is the form wherever more follows it than a read of one page takes, a path or a
|
|
4384
|
+
// flag of the form's own, before the path as after it.
|
|
4385
|
+
const form = held(DOC_FORMS, args[0]);
|
|
4386
|
+
if (form !== undefined && !readsOnePage(args)) {
|
|
4387
|
+
return form(args.slice(1), io);
|
|
4388
|
+
}
|
|
4389
|
+
const { values, positionals } = parse(args, DOC_READ_FLAGS);
|
|
4292
4390
|
const path = theOne(positionals, "Say which page: console doc <path> [--version <n>|--versions]");
|
|
4293
4391
|
const session = await open(io, values);
|
|
4294
4392
|
const project = await session.project();
|
|
@@ -4323,7 +4421,7 @@ const write: Command = async (args, io) => {
|
|
|
4323
4421
|
});
|
|
4324
4422
|
const path = theOne(
|
|
4325
4423
|
positionals,
|
|
4326
|
-
'Say which page: console write <path> --title "<title>" --body <markdown>|--file <path>',
|
|
4424
|
+
'Say which page: console doc write <path> --title "<title>" --body <markdown>|--file <path>',
|
|
4327
4425
|
);
|
|
4328
4426
|
const body = await bodyOf(io, values, text(values, "body"));
|
|
4329
4427
|
if (body === undefined) {
|
|
@@ -4372,7 +4470,7 @@ const attach: Command = async (args, io) => {
|
|
|
4372
4470
|
const { values, positionals } = parse(args, { label: { type: "string" } });
|
|
4373
4471
|
const [path, file] = positionals;
|
|
4374
4472
|
if (path === undefined || file === undefined || positionals.length > 2) {
|
|
4375
|
-
throw misuse("Say the page and the file: console attach <path> <file> [--label <words>]");
|
|
4473
|
+
throw misuse("Say the page and the file: console doc attach <path> <file> [--label <words>]");
|
|
4376
4474
|
}
|
|
4377
4475
|
const label = text(values, "label");
|
|
4378
4476
|
const session = await open(io, values);
|
|
@@ -4403,7 +4501,7 @@ const attach: Command = async (args, io) => {
|
|
|
4403
4501
|
|
|
4404
4502
|
const archive: Command = async (args, io) => {
|
|
4405
4503
|
const { values, positionals } = parse(args, {});
|
|
4406
|
-
const path = theOne(positionals, "Say which page: console archive <path>");
|
|
4504
|
+
const path = theOne(positionals, "Say which page: console doc archive <path>");
|
|
4407
4505
|
const session = await open(io, values);
|
|
4408
4506
|
const project = await session.project();
|
|
4409
4507
|
const put = await project.archiveDocument(path);
|
|
@@ -4419,7 +4517,7 @@ const archive: Command = async (args, io) => {
|
|
|
4419
4517
|
|
|
4420
4518
|
const restore: Command = async (args, io) => {
|
|
4421
4519
|
const { values, positionals } = parse(args, {});
|
|
4422
|
-
const path = theOne(positionals, "Say which page: console restore <path>");
|
|
4520
|
+
const path = theOne(positionals, "Say which page: console doc restore <path>");
|
|
4423
4521
|
const session = await open(io, values);
|
|
4424
4522
|
const project = await session.project();
|
|
4425
4523
|
const back = await project.restoreDocument(path);
|
|
@@ -4427,6 +4525,9 @@ const restore: Command = async (args, io) => {
|
|
|
4427
4525
|
return EXIT.ok;
|
|
4428
4526
|
};
|
|
4429
4527
|
|
|
4528
|
+
/** The forms of `console doc` that change a page, by the word that picks each. */
|
|
4529
|
+
const DOC_FORMS: Readonly<Record<string, Command>> = { write, attach, archive, restore };
|
|
4530
|
+
|
|
4430
4531
|
const goals: Command = async (args, io) => {
|
|
4431
4532
|
const { values } = parse(
|
|
4432
4533
|
args,
|
|
@@ -4829,69 +4930,6 @@ const serve: Command = async (args, io) => {
|
|
|
4829
4930
|
return EXIT.ok;
|
|
4830
4931
|
};
|
|
4831
4932
|
|
|
4832
|
-
/** What the runner keeps between its own restarts, as its file says it; nothing for a file that does not read. */
|
|
4833
|
-
function runnerStateOf(text: string | undefined): RunnerState | undefined {
|
|
4834
|
-
if (text === undefined) {
|
|
4835
|
-
return undefined;
|
|
4836
|
-
}
|
|
4837
|
-
let json: unknown;
|
|
4838
|
-
try {
|
|
4839
|
-
json = JSON.parse(text);
|
|
4840
|
-
} catch {
|
|
4841
|
-
return undefined;
|
|
4842
|
-
}
|
|
4843
|
-
if (typeof json !== "object" || json === null) {
|
|
4844
|
-
return undefined;
|
|
4845
|
-
}
|
|
4846
|
-
const delivered = "delivered" in json ? json.delivered : undefined;
|
|
4847
|
-
const conversation = "conversation" in json ? json.conversation : undefined;
|
|
4848
|
-
const driver = "driver" in json ? json.driver : undefined;
|
|
4849
|
-
const limited = "limited" in json ? json.limited : undefined;
|
|
4850
|
-
const kept: unknown = "kept" in json ? json.kept : undefined;
|
|
4851
|
-
if (typeof delivered !== "number" || !Number.isSafeInteger(delivered) || delivered < 0) {
|
|
4852
|
-
return undefined;
|
|
4853
|
-
}
|
|
4854
|
-
/**
|
|
4855
|
-
* A moment in milliseconds since the epoch, or nothing for anything else: a number past what
|
|
4856
|
-
* a date holds would fail the runner at every start, where it says the moment in words.
|
|
4857
|
-
*/
|
|
4858
|
-
const momentOf = (value: unknown): number | undefined =>
|
|
4859
|
-
typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value < 1e14
|
|
4860
|
-
? value
|
|
4861
|
-
: undefined;
|
|
4862
|
-
const since =
|
|
4863
|
-
typeof limited === "object" && limited !== null && "since" in limited
|
|
4864
|
-
? momentOf(limited.since)
|
|
4865
|
-
: undefined;
|
|
4866
|
-
return {
|
|
4867
|
-
delivered,
|
|
4868
|
-
conversation:
|
|
4869
|
-
typeof conversation === "string" && conversation.length > 0 && conversation.length <= 200
|
|
4870
|
-
? conversation
|
|
4871
|
-
: undefined,
|
|
4872
|
-
// The driver the conversation was begun under, as a registry spells one.
|
|
4873
|
-
driver:
|
|
4874
|
-
typeof driver === "string" && /^[a-z][a-z0-9-]{0,39}$/.test(driver) ? driver : undefined,
|
|
4875
|
-
// The usage limit the agent is not back from (ADR-0150): since when, and until when where the product said.
|
|
4876
|
-
...(since === undefined || typeof limited !== "object" || limited === null
|
|
4877
|
-
? {}
|
|
4878
|
-
: {
|
|
4879
|
-
limited: {
|
|
4880
|
-
since,
|
|
4881
|
-
until: "until" in limited ? momentOf(limited.until) : undefined,
|
|
4882
|
-
},
|
|
4883
|
-
}),
|
|
4884
|
-
// The signals the record has as delivered that the agent never read: taken from the stream once more.
|
|
4885
|
-
...(Array.isArray(kept)
|
|
4886
|
-
? {
|
|
4887
|
-
kept: kept
|
|
4888
|
-
.filter((number): number is number => momentOf(number) !== undefined)
|
|
4889
|
-
.slice(0, 50),
|
|
4890
|
-
}
|
|
4891
|
-
: {}),
|
|
4892
|
-
};
|
|
4893
|
-
}
|
|
4894
|
-
|
|
4895
4933
|
/** A line a runner says of its machine, within what the console takes one in. */
|
|
4896
4934
|
const machineLine = (text: string): string => {
|
|
4897
4935
|
const line = [...text]
|
|
@@ -5021,6 +5059,9 @@ const runner: Command = async (args, io) => {
|
|
|
5021
5059
|
});
|
|
5022
5060
|
}
|
|
5023
5061
|
const statePath = workPath("runner-state.json");
|
|
5062
|
+
// A wake source is named as a registry spells one, which is a file's name as it stands.
|
|
5063
|
+
const keptPath = (source: string): string =>
|
|
5064
|
+
workPath(`runner-kept-${source.replaceAll(/[^a-z0-9-]/g, "_")}.json`);
|
|
5024
5065
|
const person = me.person;
|
|
5025
5066
|
/** A runner for the desk's runner.json as it is read now: begun again whenever the file changed (ADR-0144). */
|
|
5026
5067
|
const runnerOf = (read: Extract<Awaited<ReturnType<typeof readConfig>>, { ok: true }>) => {
|
|
@@ -5055,6 +5096,8 @@ const runner: Command = async (args, io) => {
|
|
|
5055
5096
|
now: io.now,
|
|
5056
5097
|
random: host.random,
|
|
5057
5098
|
time: (iso) => clock.format(new Date(iso)),
|
|
5099
|
+
// What a wake source shows of the agent at its messenger is in the workspace's language (ADR-0170).
|
|
5100
|
+
language: me.workspace.language ?? undefined,
|
|
5058
5101
|
// A moment that may be on another day, a stretch the runner did not run in or when a
|
|
5059
5102
|
// usage limit resets, is said as the command prints any moment: with its day, in the
|
|
5060
5103
|
// workspace's zone where the login kept one.
|
|
@@ -5065,7 +5108,7 @@ const runner: Command = async (args, io) => {
|
|
|
5065
5108
|
},
|
|
5066
5109
|
state: {
|
|
5067
5110
|
load: async () => runnerStateOf(await host.readText(statePath)),
|
|
5068
|
-
save: (state) => host.
|
|
5111
|
+
save: (state) => host.replacePrivate(statePath, `${JSON.stringify(state)}\n`),
|
|
5069
5112
|
},
|
|
5070
5113
|
log: (line) => io.stdout(`${new Date(io.now()).toISOString()} ${line}\n`),
|
|
5071
5114
|
// The autosave's git: in the desk, asking nobody at a terminal, its words read and let go.
|
|
@@ -5095,6 +5138,12 @@ const runner: Command = async (args, io) => {
|
|
|
5095
5138
|
}),
|
|
5096
5139
|
fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
|
|
5097
5140
|
socket: (url) => host.socket(url),
|
|
5141
|
+
// What a source keeps of what it brought the agent, ids and moments and never a word,
|
|
5142
|
+
// in a file of its own beside the runner's state: a runner started again reads it.
|
|
5143
|
+
kept: {
|
|
5144
|
+
load: async (source) => keptBySourceOf(await host.readText(keptPath(source))),
|
|
5145
|
+
save: (source, kept) => host.replacePrivate(keptPath(source), keptFileOf(kept)),
|
|
5146
|
+
},
|
|
5098
5147
|
},
|
|
5099
5148
|
});
|
|
5100
5149
|
};
|
|
@@ -5209,7 +5258,7 @@ const agents: Command = async (args, io) => {
|
|
|
5209
5258
|
};
|
|
5210
5259
|
|
|
5211
5260
|
const AGENT_USAGE =
|
|
5212
|
-
|
|
5261
|
+
"Say which agent account, or what to do: console agent <handle>, or console agent new|tell|interrupt|stop|restart|reset|wake|set|signals|messages|secrets|secret|invite|setup ...";
|
|
5213
5262
|
|
|
5214
5263
|
// An administrator makes an agent account with flags, where the pages make one from a form
|
|
5215
5264
|
// (ADR-0084): the member's row at once, its login let in. What is left out is proposed: the
|
|
@@ -5329,11 +5378,24 @@ const SECRET_FLAGS: OptionSpec = {
|
|
|
5329
5378
|
expires: { type: "string" },
|
|
5330
5379
|
};
|
|
5331
5380
|
|
|
5381
|
+
/** What ends the listing of the offers that wait: the two things the account does with one. */
|
|
5382
|
+
const OFFERED_NEXT =
|
|
5383
|
+
"Take one into your store: console secret --accept <offer id> [--as <name>] [--replace] | leave one: console secret --decline <offer id>";
|
|
5384
|
+
|
|
5332
5385
|
// An agent account's own secret store (ADR-0087): the names it keeps, for the account itself,
|
|
5333
|
-
// signed in as itself.
|
|
5386
|
+
// signed in as itself; and, with --offered, what members offered it that waits (ADR-0169).
|
|
5334
5387
|
const secrets: Command = async (args, io) => {
|
|
5335
|
-
const { values } = parse(args, {}, false);
|
|
5388
|
+
const { values } = parse(args, { offered: { type: "boolean" } }, false);
|
|
5336
5389
|
const session = await open(io, values);
|
|
5390
|
+
if (on(values, "offered")) {
|
|
5391
|
+
const offered = await session.client.secretOffers();
|
|
5392
|
+
answer(io, session, offered, () =>
|
|
5393
|
+
offered.items.length === 0
|
|
5394
|
+
? "No offered secret waits for you."
|
|
5395
|
+
: [...offered.items.map((item) => formatSecretOffer(item)), OFFERED_NEXT].join("\n"),
|
|
5396
|
+
);
|
|
5397
|
+
return EXIT.ok;
|
|
5398
|
+
}
|
|
5337
5399
|
const found = await session.client.secrets();
|
|
5338
5400
|
answer(io, session, found, () =>
|
|
5339
5401
|
found.items.length === 0
|
|
@@ -5345,10 +5407,65 @@ const secrets: Command = async (args, io) => {
|
|
|
5345
5407
|
|
|
5346
5408
|
const SECRET_USAGE =
|
|
5347
5409
|
"Say which secret: console secret <name> | secret <name> --set [--file <path>] [--expires <day|none>] | secret <name> --remove";
|
|
5410
|
+
const OFFER_USAGE =
|
|
5411
|
+
"Say which offer, by its id as console secrets --offered lists it: console secret --accept <offer id> [--as <name>] [--replace] | secret --decline <offer id>";
|
|
5412
|
+
|
|
5413
|
+
/**
|
|
5414
|
+
* An offer the account takes into its store or leaves (ADR-0169): named by its id, since the
|
|
5415
|
+
* name an offerer proposed is theirs to choose and two may propose the same.
|
|
5416
|
+
*/
|
|
5417
|
+
async function offeredSecret(io: CliIo, values: Values, positionals: readonly string[]) {
|
|
5418
|
+
const taking = on(values, "accept");
|
|
5419
|
+
if ((taking && on(values, "decline")) || on(values, "set") || on(values, "remove")) {
|
|
5420
|
+
throw misuse("Say one of --accept, --decline, --set and --remove.");
|
|
5421
|
+
}
|
|
5422
|
+
const as = text(values, "as");
|
|
5423
|
+
if (!taking && (as !== undefined || on(values, "replace"))) {
|
|
5424
|
+
throw misuse(
|
|
5425
|
+
"--as and --replace go with --accept: an offer that is left is kept under no name.",
|
|
5426
|
+
);
|
|
5427
|
+
}
|
|
5428
|
+
const id = theOne(positionals, OFFER_USAGE);
|
|
5429
|
+
const session = await open(io, values);
|
|
5430
|
+
if (!taking) {
|
|
5431
|
+
await session.client.leaveSecretOffer(id);
|
|
5432
|
+
answer(io, session, { left: id }, () => `The offer ${id} is left, and its value is gone.`);
|
|
5433
|
+
return EXIT.ok;
|
|
5434
|
+
}
|
|
5435
|
+
let kept: Awaited<ReturnType<ConsoleClient["takeSecretOffer"]>>;
|
|
5436
|
+
try {
|
|
5437
|
+
kept = await session.client.takeSecretOffer(id, {
|
|
5438
|
+
...(as === undefined ? {} : { as }),
|
|
5439
|
+
...(on(values, "replace") ? { replace: true } : {}),
|
|
5440
|
+
});
|
|
5441
|
+
} catch (error) {
|
|
5442
|
+
if (error instanceof ApiError && error.code === "secret.exists") {
|
|
5443
|
+
throw failed(
|
|
5444
|
+
`secret.exists: you keep a secret ${as === undefined ? "of the name it was offered under" : `named ${as}`} already, and the offer still waits. Take it under another name with --as <name>, or in the place of the one you keep with --replace.`,
|
|
5445
|
+
);
|
|
5446
|
+
}
|
|
5447
|
+
throw error;
|
|
5448
|
+
}
|
|
5449
|
+
answer(io, session, kept, () => `Taken into your store: ${formatSecretLine(kept)}`);
|
|
5450
|
+
return EXIT.ok;
|
|
5451
|
+
}
|
|
5348
5452
|
|
|
5349
5453
|
// One secret of the account's own: its value, read and noted; or set, typed unseen; or removed.
|
|
5454
|
+
// And one offered to it, taken or left.
|
|
5350
5455
|
const secret: Command = async (args, io) => {
|
|
5351
|
-
const { values, positionals } = parse(args,
|
|
5456
|
+
const { values, positionals } = parse(args, {
|
|
5457
|
+
...SECRET_FLAGS,
|
|
5458
|
+
accept: { type: "boolean" },
|
|
5459
|
+
decline: { type: "boolean" },
|
|
5460
|
+
as: { type: "string" },
|
|
5461
|
+
replace: { type: "boolean" },
|
|
5462
|
+
});
|
|
5463
|
+
if (on(values, "accept") || on(values, "decline")) {
|
|
5464
|
+
return offeredSecret(io, values, positionals);
|
|
5465
|
+
}
|
|
5466
|
+
if (text(values, "as") !== undefined || on(values, "replace")) {
|
|
5467
|
+
throw misuse(`--as and --replace go with --accept. ${OFFER_USAGE}`);
|
|
5468
|
+
}
|
|
5352
5469
|
const name = theOne(positionals, SECRET_USAGE);
|
|
5353
5470
|
const session = await open(io, values);
|
|
5354
5471
|
if (on(values, "remove")) {
|
|
@@ -5377,9 +5494,22 @@ const secret: Command = async (args, io) => {
|
|
|
5377
5494
|
// A supervisor's part of an agent account's store (ADR-0087): the names; a secret seeded,
|
|
5378
5495
|
// write-only, which only the account reads back; one removed. Never a value.
|
|
5379
5496
|
const agentSecrets = async (args: readonly string[], io: CliIo): Promise<number> => {
|
|
5380
|
-
const { values, positionals } = parse(args, {});
|
|
5381
|
-
const handle = handleOf(
|
|
5497
|
+
const { values, positionals } = parse(args, { offered: { type: "boolean" } });
|
|
5498
|
+
const handle = handleOf(
|
|
5499
|
+
theOne(positionals, "Say whose: console agent secrets <handle> [--offered]"),
|
|
5500
|
+
);
|
|
5382
5501
|
const session = await open(io, values);
|
|
5502
|
+
if (on(values, "offered")) {
|
|
5503
|
+
// What the account was offered (ADR-0169): its record whole for a supervisor, and for any
|
|
5504
|
+
// other member what they offered it themselves.
|
|
5505
|
+
const offered = await session.client.agentSecretOffers(handle);
|
|
5506
|
+
answer(io, session, offered, () =>
|
|
5507
|
+
offered.items.length === 0
|
|
5508
|
+
? `Nothing was offered to @${handle} that is yours to read.`
|
|
5509
|
+
: offered.items.map((item) => formatSecretOffer(item)).join("\n"),
|
|
5510
|
+
);
|
|
5511
|
+
return EXIT.ok;
|
|
5512
|
+
}
|
|
5383
5513
|
let found: Awaited<ReturnType<ConsoleClient["agentSecrets"]>>;
|
|
5384
5514
|
try {
|
|
5385
5515
|
found = await session.client.agentSecrets(handle);
|
|
@@ -5405,13 +5535,48 @@ const agentSecrets = async (args: readonly string[], io: CliIo): Promise<number>
|
|
|
5405
5535
|
};
|
|
5406
5536
|
|
|
5407
5537
|
const agentSecret = async (args: readonly string[], io: CliIo): Promise<number> => {
|
|
5408
|
-
const { values, positionals } = parse(args,
|
|
5538
|
+
const { values, positionals } = parse(args, {
|
|
5539
|
+
...SECRET_FLAGS,
|
|
5540
|
+
offer: { type: "boolean" },
|
|
5541
|
+
note: { type: "string" },
|
|
5542
|
+
});
|
|
5409
5543
|
const [given, name] = theTwo(
|
|
5410
5544
|
positionals,
|
|
5411
|
-
|
|
5545
|
+
'Say whose and which: console agent secret <handle> <name> [--file <path>] [--expires <day|none>] | agent secret <handle> <name> --offer [--note "<what it is for>"] [--file <path>] [--expires <day|none>] | agent secret <handle> <name> --remove',
|
|
5412
5546
|
);
|
|
5413
5547
|
const handle = handleOf(given);
|
|
5548
|
+
const offering = on(values, "offer");
|
|
5549
|
+
const said = text(values, "note")?.trim();
|
|
5550
|
+
if (offering && on(values, "remove")) {
|
|
5551
|
+
throw misuse("Say one of --offer and --remove.");
|
|
5552
|
+
}
|
|
5553
|
+
if (said !== undefined && !offering) {
|
|
5554
|
+
throw misuse("--note says what an offered secret is for, and goes with --offer.");
|
|
5555
|
+
}
|
|
5414
5556
|
const session = await open(io, values);
|
|
5557
|
+
if (offering) {
|
|
5558
|
+
// Any member's (ADR-0169): the value waits, sealed, for the account to take or leave, and
|
|
5559
|
+
// nothing of what the account keeps changes.
|
|
5560
|
+
const expiresOn = expiryOf(io, values);
|
|
5561
|
+
const value = await secretValue(
|
|
5562
|
+
io,
|
|
5563
|
+
values,
|
|
5564
|
+
`Value of ${name} to offer @${handle} (typed unseen; Enter ends it): `,
|
|
5565
|
+
);
|
|
5566
|
+
const offered = await session.client.offerAgentSecret(handle, {
|
|
5567
|
+
name,
|
|
5568
|
+
value,
|
|
5569
|
+
...(said === undefined || said === "" ? {} : { note: said }),
|
|
5570
|
+
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
5571
|
+
});
|
|
5572
|
+
answer(io, session, offered, () =>
|
|
5573
|
+
[
|
|
5574
|
+
`Offered to @${handle}, which is told and takes it into its store or leaves it: ${formatSecretOffer(offered)}`,
|
|
5575
|
+
`Nothing @${handle} keeps changed, and nobody is answered the value. How it stands: console agent secrets ${handle} --offered`,
|
|
5576
|
+
].join("\n"),
|
|
5577
|
+
);
|
|
5578
|
+
return EXIT.ok;
|
|
5579
|
+
}
|
|
5415
5580
|
if (on(values, "remove")) {
|
|
5416
5581
|
await session.client.removeAgentSecret(handle, name);
|
|
5417
5582
|
answer(
|
|
@@ -5429,10 +5594,21 @@ const agentSecret = async (args: readonly string[], io: CliIo): Promise<number>
|
|
|
5429
5594
|
`Value of ${name} for @${handle} (typed unseen; Enter ends it): `,
|
|
5430
5595
|
);
|
|
5431
5596
|
const host = await gitHostFor(session.client, name);
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5597
|
+
let kept: Awaited<ReturnType<ConsoleClient["seedAgentSecret"]>>;
|
|
5598
|
+
try {
|
|
5599
|
+
kept = await session.client.seedAgentSecret(handle, name, {
|
|
5600
|
+
value,
|
|
5601
|
+
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
5602
|
+
});
|
|
5603
|
+
} catch (error) {
|
|
5604
|
+
// Whoever supervises the account not is told what is theirs to do in its place.
|
|
5605
|
+
if (error instanceof ApiError && error.code === "auth.forbidden") {
|
|
5606
|
+
throw failed(
|
|
5607
|
+
`auth.forbidden: only a supervisor of @${handle} sets a secret in its store. Any member may offer one, which @${handle} takes or leaves itself: say the same again with --offer, and with --note "<what it is for>".`,
|
|
5608
|
+
);
|
|
5609
|
+
}
|
|
5610
|
+
throw error;
|
|
5611
|
+
}
|
|
5436
5612
|
const notes = secretNotes(name, value, host);
|
|
5437
5613
|
answer(io, session, kept, () =>
|
|
5438
5614
|
[`Seeded for @${handle}, which alone reads it back: ${formatSecretLine(kept)}`, ...notes].join(
|
|
@@ -5612,6 +5788,21 @@ const WORDED_SIGNALS: Readonly<Record<string, { readonly needs: boolean }>> = {
|
|
|
5612
5788
|
wake: { needs: false },
|
|
5613
5789
|
};
|
|
5614
5790
|
|
|
5791
|
+
/**
|
|
5792
|
+
* Whether the words after `agent wake` or `agent reset` are the account's own form: `me` where
|
|
5793
|
+
* the handle stands, wherever that is among the form's flags. Read without refusing a word, so
|
|
5794
|
+
* that a mistake among them is answered by the form that was typed, and not by the other's.
|
|
5795
|
+
*/
|
|
5796
|
+
function isOwnForm(args: readonly string[], flags: OptionSpec): boolean {
|
|
5797
|
+
const { positionals } = parseArgs({
|
|
5798
|
+
args: [...args],
|
|
5799
|
+
options: { ...GLOBAL_OPTIONS, ...flags },
|
|
5800
|
+
allowPositionals: true,
|
|
5801
|
+
strict: false,
|
|
5802
|
+
});
|
|
5803
|
+
return positionals[0] === "me";
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5615
5806
|
// A supervisor's signal to an agent account (ADR-0085): a tell, an interruption, a stop, a start
|
|
5616
5807
|
// with the same conversation or with a new one, a wake; in their own name, on the account's
|
|
5617
5808
|
// record. What it says is given as words, or with --file, or on standard input as `-`.
|
|
@@ -5622,28 +5813,12 @@ const agentSignal = async (
|
|
|
5622
5813
|
): Promise<number> => {
|
|
5623
5814
|
// An account's own wake is another command under the same word: console agent wake me,
|
|
5624
5815
|
// wherever `me` stands among its flags.
|
|
5625
|
-
if (kind === "wake") {
|
|
5626
|
-
|
|
5627
|
-
try {
|
|
5628
|
-
whom = parse(args, OWN_WAKE_FLAGS).positionals[0];
|
|
5629
|
-
} catch {
|
|
5630
|
-
whom = undefined;
|
|
5631
|
-
}
|
|
5632
|
-
if (whom === "me") {
|
|
5633
|
-
return ownWake(args, io);
|
|
5634
|
-
}
|
|
5816
|
+
if (kind === "wake" && isOwnForm(args, OWN_WAKE_FLAGS)) {
|
|
5817
|
+
return ownWake(args, io);
|
|
5635
5818
|
}
|
|
5636
5819
|
// And so is its own reset: console agent reset me.
|
|
5637
|
-
if (kind === "reset") {
|
|
5638
|
-
|
|
5639
|
-
try {
|
|
5640
|
-
whom = parse(args, { file: { type: "string" } }).positionals[0];
|
|
5641
|
-
} catch {
|
|
5642
|
-
whom = undefined;
|
|
5643
|
-
}
|
|
5644
|
-
if (whom === "me") {
|
|
5645
|
-
return ownReset(args, io);
|
|
5646
|
-
}
|
|
5820
|
+
if (kind === "reset" && isOwnForm(args, { file: { type: "string" } })) {
|
|
5821
|
+
return ownReset(args, io);
|
|
5647
5822
|
}
|
|
5648
5823
|
const { values, positionals } = parse(args, { file: { type: "string" } });
|
|
5649
5824
|
const [given, words, ...rest] = positionals;
|
|
@@ -5751,6 +5926,86 @@ const agentSignals = async (args: readonly string[], io: CliIo): Promise<number>
|
|
|
5751
5926
|
return EXIT.ok;
|
|
5752
5927
|
};
|
|
5753
5928
|
|
|
5929
|
+
const AGENT_MESSAGES_USAGE =
|
|
5930
|
+
"Say where, as a wake's header names it after messenger: console agent messages <source>:<conversation>[:<thread>] [--limit <n>] [--after <moment>]";
|
|
5931
|
+
|
|
5932
|
+
// What was said where a wake from the messenger was raised (ADR-0163): the latest messages of the
|
|
5933
|
+
// conversation, or of the thread, that the wake's key names, read by the wake source the key
|
|
5934
|
+
// begins with, with a secret of the account's own store, which nobody else reads. For the
|
|
5935
|
+
// account itself, where a wake carried less than the agent needs, and before it answers where
|
|
5936
|
+
// others may have answered meanwhile. What a source's line says is printed as it is, and what
|
|
5937
|
+
// someone wrote behind `>`, a line each, so that no word of a message reads as a line.
|
|
5938
|
+
const agentMessages = async (args: readonly string[], io: CliIo): Promise<number> => {
|
|
5939
|
+
const { values, positionals } = parse(args, {
|
|
5940
|
+
limit: { type: "string" },
|
|
5941
|
+
after: { type: "string" },
|
|
5942
|
+
});
|
|
5943
|
+
const key = theOne(positionals, AGENT_MESSAGES_USAGE);
|
|
5944
|
+
const named = /^([a-z][a-z0-9-]{0,39}):(.+)$/.exec(key);
|
|
5945
|
+
const source =
|
|
5946
|
+
named?.[1] === undefined ? undefined : ownRunnerModules({ user: "" }).wakeSources.get(named[1]);
|
|
5947
|
+
if (named?.[2] === undefined || source?.read === undefined) {
|
|
5948
|
+
throw misuse(
|
|
5949
|
+
`No wake source of this command reads ${key.includes(":") ? `what ${key.slice(0, key.indexOf(":"))} names` : "that"}. ${AGENT_MESSAGES_USAGE}`,
|
|
5950
|
+
);
|
|
5951
|
+
}
|
|
5952
|
+
const limit = text(values, "limit");
|
|
5953
|
+
if (limit !== undefined && !(Number.isSafeInteger(Number(limit)) && Number(limit) >= 1)) {
|
|
5954
|
+
throw misuse(`Not a number of messages: ${limit}`);
|
|
5955
|
+
}
|
|
5956
|
+
const after = text(values, "after");
|
|
5957
|
+
const session = await open(io, values);
|
|
5958
|
+
const read = await source.read(
|
|
5959
|
+
{
|
|
5960
|
+
// A secret the account does not keep is none, and the source says what it lacks.
|
|
5961
|
+
secret: async (name) => {
|
|
5962
|
+
try {
|
|
5963
|
+
return (await session.client.secret(name)).value;
|
|
5964
|
+
} catch (error) {
|
|
5965
|
+
if (error instanceof ApiError && error.code === "secret.not_found") {
|
|
5966
|
+
return undefined;
|
|
5967
|
+
}
|
|
5968
|
+
throw error;
|
|
5969
|
+
}
|
|
5970
|
+
},
|
|
5971
|
+
fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
|
|
5972
|
+
// Who wrote each message, as the console says it (ADR-0164): where it says nothing, a
|
|
5973
|
+
// console older than the question say, the lines are as the messenger alone has them.
|
|
5974
|
+
writers: async (accounts, signal) =>
|
|
5975
|
+
(
|
|
5976
|
+
await session.client.writers(
|
|
5977
|
+
{ messenger: named[1] ?? "", accounts: [...accounts] },
|
|
5978
|
+
signal,
|
|
5979
|
+
)
|
|
5980
|
+
).items,
|
|
5981
|
+
},
|
|
5982
|
+
named[2],
|
|
5983
|
+
{
|
|
5984
|
+
...(limit === undefined ? {} : { limit: Number(limit) }),
|
|
5985
|
+
...(after === undefined ? {} : { after }),
|
|
5986
|
+
now: io.now(),
|
|
5987
|
+
signal: AbortSignal.timeout(30_000),
|
|
5988
|
+
},
|
|
5989
|
+
);
|
|
5990
|
+
if (!read.ok) {
|
|
5991
|
+
throw failed(
|
|
5992
|
+
read.why === "no_token"
|
|
5993
|
+
? `Nothing was read: this account keeps no secret the ${named[1]} wake source reads a conversation with (no_token). The skill running-an-agent says which to keep.`
|
|
5994
|
+
: read.why === "not_a_conversation"
|
|
5995
|
+
? `Nothing was read: ${named[2]} names no conversation as a wake of the ${named[1]} wake source does (not_a_conversation). ${AGENT_MESSAGES_USAGE}`
|
|
5996
|
+
: read.why === "not_a_moment"
|
|
5997
|
+
? `Nothing was read: ${after} is the moment of no message, as a wake of the ${named[1]} wake source says one (not_a_moment).`
|
|
5998
|
+
: `Nothing was read: the messenger did not answer the ${named[1]} wake source with the conversation (${read.why}).`,
|
|
5999
|
+
);
|
|
6000
|
+
}
|
|
6001
|
+
answer(io, session, { key, parts: read.parts }, () =>
|
|
6002
|
+
read.parts
|
|
6003
|
+
.map((part) => ("says" in part ? part.says : quotedLines(part.words).join("\n")))
|
|
6004
|
+
.join("\n"),
|
|
6005
|
+
);
|
|
6006
|
+
return EXIT.ok;
|
|
6007
|
+
};
|
|
6008
|
+
|
|
5754
6009
|
// The invitation that leads a machine to an agent account (ADR-0088): made, made again in place
|
|
5755
6010
|
// of the one before, or taken away, by a supervisor. Its code is no credential: it says which
|
|
5756
6011
|
// account a setup is for and opens the guide, and the account is entered through its own sign-in.
|
|
@@ -6512,7 +6767,7 @@ const DESK_USAGE = "Say at most one directory: console desk [<directory>] [--web
|
|
|
6512
6767
|
function deskNext(web: boolean, skillsDir: string | undefined): [string, string] {
|
|
6513
6768
|
return [
|
|
6514
6769
|
`Set this desk up as a repository of mine${web ? " and bring its pages up" : ""}, with the skill for it in the organization's pack where it has one: console skills --search "desk setup" --limit 5`,
|
|
6515
|
-
`Ask me what I want to keep and to see here, and shape the desk to it, as the skill keeping-a-desk says, shipped with the console command${skillsDir === undefined ? " (
|
|
6770
|
+
`Ask me what I want to keep and to see here, and shape the desk to it, as the skill keeping-a-desk says, shipped with the console command${skillsDir === undefined ? " (in the skills folder of the package @skillcdn/console, which this build has none of beside it)" : `: ${ownSkillPath(skillsDir, "keeping-a-desk")}`}`,
|
|
6516
6771
|
];
|
|
6517
6772
|
}
|
|
6518
6773
|
|
|
@@ -6733,6 +6988,9 @@ const agent: Command = async (args, io) => {
|
|
|
6733
6988
|
if (args[0] === "signals") {
|
|
6734
6989
|
return agentSignals(args.slice(1), io);
|
|
6735
6990
|
}
|
|
6991
|
+
if (args[0] === "messages") {
|
|
6992
|
+
return agentMessages(args.slice(1), io);
|
|
6993
|
+
}
|
|
6736
6994
|
if (args[0] === "invite") {
|
|
6737
6995
|
return agentInvite(args.slice(1), io);
|
|
6738
6996
|
}
|
|
@@ -7587,23 +7845,58 @@ const COMMANDS: Readonly<Record<string, Command>> = {
|
|
|
7587
7845
|
run,
|
|
7588
7846
|
docs,
|
|
7589
7847
|
doc,
|
|
7848
|
+
// The words of before (COMMAND_ALIASES, ADR-0167): they run as they did, and no list names them.
|
|
7590
7849
|
write,
|
|
7591
7850
|
attach,
|
|
7592
7851
|
archive,
|
|
7593
7852
|
restore,
|
|
7594
7853
|
};
|
|
7595
7854
|
|
|
7596
|
-
|
|
7597
|
-
|
|
7855
|
+
/** The words the dispatch takes: what a test holds to the pages of help and to the words of before. */
|
|
7856
|
+
export const COMMAND_WORDS: readonly string[] = Object.keys(COMMANDS);
|
|
7857
|
+
|
|
7858
|
+
/** What a word that is no command is answered with: the nearest there are, and where all are listed. */
|
|
7859
|
+
function notCommand(word: string, near: readonly string[] = nearestCommands(word)): CliExit {
|
|
7860
|
+
return misuse(
|
|
7861
|
+
`Not a command: ${word}.${near.length === 0 ? "" : ` Nearest: ${near.join(", ")}.`} console help lists the commands.`,
|
|
7862
|
+
);
|
|
7863
|
+
}
|
|
7864
|
+
|
|
7865
|
+
/**
|
|
7866
|
+
* The help the words ask for (ADR-0167): the table of the commands for none, else the page of
|
|
7867
|
+
* a command, or of one of its forms. Flags among the words are left unread.
|
|
7868
|
+
*/
|
|
7869
|
+
function help(io: CliIo, words: readonly string[]): number {
|
|
7870
|
+
const named = words.filter((word) => !word.startsWith("-"));
|
|
7871
|
+
// Help asked of help is the table too.
|
|
7872
|
+
if (named.length === 0 || (named.length === 1 && named[0] === "help")) {
|
|
7598
7873
|
io.stdout(usage(io.version, io.skillsDir));
|
|
7599
7874
|
return EXIT.ok;
|
|
7600
7875
|
}
|
|
7601
|
-
const found = helpFor(
|
|
7602
|
-
if (
|
|
7603
|
-
|
|
7876
|
+
const found = helpFor(named, io.skillsDir);
|
|
7877
|
+
if ("page" in found) {
|
|
7878
|
+
io.stdout(found.page);
|
|
7879
|
+
return EXIT.ok;
|
|
7604
7880
|
}
|
|
7605
|
-
|
|
7606
|
-
|
|
7881
|
+
if ("notCommand" in found) {
|
|
7882
|
+
throw notCommand(found.notCommand, found.near);
|
|
7883
|
+
}
|
|
7884
|
+
throw misuse(
|
|
7885
|
+
`Not a form of console ${found.command}: ${found.notForm}. Its forms with a page: ${found.forms.join(", ")}. console help ${found.command} says each in a line.`,
|
|
7886
|
+
);
|
|
7887
|
+
}
|
|
7888
|
+
|
|
7889
|
+
/**
|
|
7890
|
+
* The line after a command that was not understood (ADR-0167): where its forms and flags are,
|
|
7891
|
+
* the page of the form that was tried where it has one. Nothing where the words say it already.
|
|
7892
|
+
*/
|
|
7893
|
+
function helpPointer(name: string, rest: readonly string[], said: string): string {
|
|
7894
|
+
if (said.includes("console help")) {
|
|
7895
|
+
return "";
|
|
7896
|
+
}
|
|
7897
|
+
const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
|
|
7898
|
+
const form = aliased ?? formTyped(command, rest);
|
|
7899
|
+
return `Its forms and flags: console help ${command}${form === undefined ? "" : ` ${form}`}\n`;
|
|
7607
7900
|
}
|
|
7608
7901
|
|
|
7609
7902
|
/**
|
|
@@ -7723,11 +8016,11 @@ function hintFor(error: ApiError, io: CliIo, seen: ConsoleSeen): string {
|
|
|
7723
8016
|
case "project.not_found":
|
|
7724
8017
|
return "No project has this key, or it is not yours to see. console projects lists the projects you may work in.\n";
|
|
7725
8018
|
case "document.not_found":
|
|
7726
|
-
return "No page has this path, in this project. console docs lists the pages of a folder; console write <path> writes one.\n";
|
|
8019
|
+
return "No page has this path, in this project. console docs lists the pages of a folder; console doc write <path> writes one.\n";
|
|
7727
8020
|
case "document.conflict":
|
|
7728
8021
|
return "The page has moved on since the version you started from. Read it again, and write from there.\n";
|
|
7729
8022
|
case "document.archived":
|
|
7730
|
-
return "The page is archived. console restore <path> brings it back first.\n";
|
|
8023
|
+
return "The page is archived. console doc restore <path> brings it back first.\n";
|
|
7731
8024
|
case "task.invalid_category":
|
|
7732
8025
|
return "No category has that key. console categories lists them.\n";
|
|
7733
8026
|
case "task.invalid_goal":
|
|
@@ -7825,14 +8118,22 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<number
|
|
|
7825
8118
|
return EXIT.ok;
|
|
7826
8119
|
}
|
|
7827
8120
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
7828
|
-
return help(io, rest
|
|
8121
|
+
return help(io, rest);
|
|
7829
8122
|
}
|
|
7830
8123
|
if (rest.includes("--help") || rest.includes("-h")) {
|
|
7831
|
-
|
|
8124
|
+
// The page of the form that was being typed, where it has one.
|
|
8125
|
+
const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
|
|
8126
|
+
const form =
|
|
8127
|
+
aliased ??
|
|
8128
|
+
formTyped(
|
|
8129
|
+
command,
|
|
8130
|
+
rest.filter((word) => word !== "--help" && word !== "-h"),
|
|
8131
|
+
);
|
|
8132
|
+
return help(io, form === undefined ? [command] : [command, form]);
|
|
7832
8133
|
}
|
|
7833
|
-
const command = COMMANDS
|
|
8134
|
+
const command = held(COMMANDS, name);
|
|
7834
8135
|
if (command === undefined) {
|
|
7835
|
-
throw
|
|
8136
|
+
throw notCommand(name);
|
|
7836
8137
|
}
|
|
7837
8138
|
const exit = await command(rest, watched);
|
|
7838
8139
|
if (name !== "whoami") {
|
|
@@ -7841,7 +8142,12 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<number
|
|
|
7841
8142
|
return exit;
|
|
7842
8143
|
} catch (error) {
|
|
7843
8144
|
if (error instanceof CliExit) {
|
|
7844
|
-
|
|
8145
|
+
// A command that was not understood says where its forms and flags are, in a line.
|
|
8146
|
+
const pointer =
|
|
8147
|
+
error.exit === EXIT.usage && name !== undefined && held(COMMANDS, name) !== undefined
|
|
8148
|
+
? helpPointer(name, rest, error.message)
|
|
8149
|
+
: "";
|
|
8150
|
+
io.stderr(`${error.message}\n${pointer}`);
|
|
7845
8151
|
return error.exit;
|
|
7846
8152
|
}
|
|
7847
8153
|
if (error instanceof UnseenProject) {
|