@skillcdn/console 0.5.1 → 0.5.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 +20 -2
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +4 -4
- package/dist/agent-page.js.map +1 -1
- package/dist/api.d.ts +5 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +5 -4
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts +32 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +442 -93
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +6 -2
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +25 -3
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +10 -5
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/machine-check.d.ts +36 -0
- package/dist/cli/machine-check.d.ts.map +1 -0
- package/dist/cli/machine-check.js +151 -0
- package/dist/cli/machine-check.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 +2 -0
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/cli/secret-notes.d.ts +8 -0
- package/dist/cli/secret-notes.d.ts.map +1 -0
- package/dist/cli/secret-notes.js +48 -0
- package/dist/cli/secret-notes.js.map +1 -0
- package/dist/client.d.ts +7 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +106 -13
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +391 -102
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +1 -1
- package/dist/components/agents.js.map +1 -1
- package/dist/components/board.d.ts.map +1 -1
- package/dist/components/board.js +3 -2
- package/dist/components/board.js.map +1 -1
- package/dist/components/categories.js +1 -1
- package/dist/components/categories.js.map +1 -1
- package/dist/components/decision-list.d.ts.map +1 -1
- package/dist/components/decision-list.js +1 -1
- package/dist/components/decision-list.js.map +1 -1
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +3 -2
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/goals.d.ts +2 -0
- package/dist/components/goals.d.ts.map +1 -1
- package/dist/components/goals.js +1 -1
- package/dist/components/goals.js.map +1 -1
- package/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +13 -15
- package/dist/components/home.js.map +1 -1
- package/dist/components/icon.d.ts +31 -0
- package/dist/components/icon.d.ts.map +1 -0
- package/dist/components/icon.js +169 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/markdown.d.ts +6 -0
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +10 -2
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/people.js +1 -1
- package/dist/components/people.js.map +1 -1
- package/dist/components/plugin-frame.d.ts.map +1 -1
- package/dist/components/plugin-frame.js +7 -0
- package/dist/components/plugin-frame.js.map +1 -1
- package/dist/components/projects.d.ts +17 -4
- package/dist/components/projects.d.ts.map +1 -1
- package/dist/components/projects.js +25 -6
- package/dist/components/projects.js.map +1 -1
- package/dist/components/sessions.d.ts.map +1 -1
- package/dist/components/sessions.js +3 -2
- package/dist/components/sessions.js.map +1 -1
- package/dist/components/setup.d.ts.map +1 -1
- package/dist/components/setup.js +2 -2
- package/dist/components/setup.js.map +1 -1
- package/dist/components/shell.d.ts.map +1 -1
- package/dist/components/shell.js +3 -2
- package/dist/components/shell.js.map +1 -1
- package/dist/components/tokens.js +1 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/ui.d.ts +5 -2
- package/dist/components/ui.d.ts.map +1 -1
- package/dist/components/ui.js +10 -7
- package/dist/components/ui.js.map +1 -1
- package/dist/connect-page.js +1 -1
- package/dist/connect-page.js.map +1 -1
- package/dist/console.css +473 -77
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +38 -31
- package/dist/console.js.map +1 -1
- package/dist/home-tiles.d.ts +24 -33
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +65 -259
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +49 -2
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +126 -3
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +197 -79
- package/dist/i18n/ko.js.map +1 -1
- package/dist/i18n/particles.d.ts +7 -0
- package/dist/i18n/particles.d.ts.map +1 -0
- package/dist/i18n/particles.js +72 -0
- package/dist/i18n/particles.js.map +1 -0
- package/dist/icons/glyphs.d.ts +605 -0
- package/dist/icons/glyphs.d.ts.map +1 -0
- package/dist/icons/glyphs.js +104 -0
- package/dist/icons/glyphs.js.map +1 -0
- package/dist/icons/index.d.ts +59 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/icons/index.js +157 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +9 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +9 -0
- package/dist/limits.js.map +1 -1
- package/dist/marks.d.ts +9 -0
- package/dist/marks.d.ts.map +1 -1
- package/dist/marks.js +9 -0
- package/dist/marks.js.map +1 -1
- package/dist/onboarding.js +3 -3
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +3 -2
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/plugin/web.d.ts +3 -0
- package/dist/plugin/web.d.ts.map +1 -1
- package/dist/plugin/web.js +5 -1
- package/dist/plugin/web.js.map +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +2 -2
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/awake.d.ts +35 -0
- package/dist/runner/awake.d.ts.map +1 -0
- package/dist/runner/awake.js +95 -0
- package/dist/runner/awake.js.map +1 -0
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +19 -7
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +2 -2
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +5 -0
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +9 -0
- package/dist/runner/config.js.map +1 -1
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +5 -6
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/runner.d.ts +13 -2
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +141 -22
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +10 -4
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +15 -0
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js +9 -0
- package/dist/runner/types.js.map +1 -1
- package/dist/schemas.d.ts +94 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +81 -5
- package/dist/schemas.js.map +1 -1
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +9 -5
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +14 -3
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +41 -37
- package/dist/setup-guide.js.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +5 -1
- package/dist/tokens.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/docs/specs/cli.md +10 -7
- package/docs/specs/plugins.md +18 -7
- package/docs/specs/rest.md +10 -8
- package/docs/specs/runner.md +26 -8
- package/package.json +7 -3
- package/skills/building-a-console/SKILL.md +2 -2
- package/skills/building-a-plugin/SKILL.md +3 -3
- package/skills/keeping-a-desk/SKILL.md +2 -2
- package/skills/running-an-agent/SKILL.md +47 -57
- package/skills/working-the-board/SKILL.md +5 -4
- package/skills/working-the-board/references/the-pack.md +1 -1
- package/src/agent-page.tsx +13 -1
- package/src/api.ts +32 -1
- package/src/cli/cli.ts +530 -106
- package/src/cli/format.ts +31 -3
- package/src/cli/help.ts +12 -4
- package/src/cli/machine-check.ts +223 -0
- package/src/cli/runner-host.ts +8 -0
- package/src/cli/secret-notes.ts +63 -0
- package/src/client.ts +23 -0
- package/src/components/agent-page.tsx +629 -112
- package/src/components/agents.tsx +9 -5
- package/src/components/board.tsx +3 -15
- package/src/components/categories.tsx +2 -2
- package/src/components/decision-list.tsx +11 -7
- package/src/components/event-feed.tsx +7 -2
- package/src/components/goals.tsx +33 -25
- package/src/components/home.tsx +29 -26
- package/src/components/icon.tsx +337 -0
- package/src/components/markdown.tsx +22 -2
- package/src/components/people.tsx +1 -1
- package/src/components/plugin-frame.tsx +7 -0
- package/src/components/projects.tsx +39 -5
- package/src/components/sessions.tsx +2 -13
- package/src/components/setup.tsx +2 -2
- package/src/components/shell.tsx +3 -20
- package/src/components/tokens.tsx +1 -1
- package/src/components/ui.tsx +16 -8
- package/src/connect-page.tsx +1 -1
- package/src/console.tsx +87 -53
- package/src/home-tiles.ts +76 -291
- package/src/i18n/en.ts +128 -3
- package/src/i18n/ko.ts +200 -79
- package/src/i18n/particles.ts +79 -0
- package/src/icons/glyphs.ts +112 -0
- package/src/icons/index.ts +195 -0
- package/src/index.ts +7 -0
- package/src/limits.ts +9 -0
- package/src/marks.ts +12 -0
- package/src/onboarding.ts +3 -3
- package/src/plugin/manifest.ts +3 -2
- package/src/plugin/web.ts +9 -2
- package/src/runner/acp.ts +2 -1
- package/src/runner/awake.ts +135 -0
- package/src/runner/claude.ts +19 -4
- package/src/runner/codex.ts +2 -1
- package/src/runner/config.ts +9 -0
- package/src/runner/desk.ts +5 -6
- package/src/runner/runner.ts +183 -23
- package/src/runner/slack.ts +10 -4
- package/src/runner/types.ts +20 -0
- package/src/schemas.ts +94 -3
- package/src/services.ts +9 -5
- package/src/setup-guide.ts +43 -38
- package/src/styles/README.md +5 -4
- package/src/styles/base.css +17 -0
- package/src/styles/console.css +1 -0
- package/src/styles/drawn-by-pages.json +1 -1
- package/src/styles/pages/agents.css +103 -1
- package/src/styles/pages/board.css +0 -10
- package/src/styles/pages/calendar.css +1 -1
- package/src/styles/pages/connect.css +0 -10
- package/src/styles/pages/decisions.css +3 -1
- package/src/styles/pages/feed.css +5 -2
- package/src/styles/pages/home.css +5 -0
- package/src/styles/pages/roadmap.css +2 -2
- package/src/styles/pages/settings.css +11 -0
- package/src/styles/pages/task.css +0 -20
- package/src/styles/pages/thread.css +1 -1
- package/src/styles/parts/calendar.css +1 -1
- package/src/styles/parts/callout.css +1 -0
- package/src/styles/parts/detail.css +22 -0
- package/src/styles/parts/empty.css +2 -0
- package/src/styles/parts/eyebrow.css +1 -1
- package/src/styles/parts/facts.css +1 -1
- package/src/styles/parts/figures.css +1 -1
- package/src/styles/parts/form.css +2 -1
- package/src/styles/parts/icon.css +191 -0
- package/src/styles/parts/input.css +14 -4
- package/src/styles/parts/mark.css +36 -0
- package/src/styles/parts/menu.css +1 -7
- package/src/styles/parts/page.css +1 -1
- package/src/styles/parts/panel.css +10 -0
- package/src/styles/parts/person.css +5 -2
- package/src/styles/parts/progress.css +5 -2
- package/src/styles/parts/rows.css +1 -0
- package/src/styles/parts/settings.css +5 -0
- package/src/styles/parts/stat.css +1 -1
- package/src/styles/tokens.css +22 -7
- package/src/tokens.ts +5 -1
- package/src/vocabulary.ts +9 -0
package/dist/cli/cli.js
CHANGED
|
@@ -8,16 +8,18 @@ import { ApiError, createClient, } from "../client.js";
|
|
|
8
8
|
import { CLIENT_RANGE_HEADER, CONSOLE_AT_LEAST, consoleRange, formatRange, judgeClient, judgeConsole, parseVersion, VERSION_HEADER, formatVersion as versionText, } from "../compat.js";
|
|
9
9
|
import { normalizeConnectCode } from "../connect.js";
|
|
10
10
|
import { addDays, dayOf as dayOfDate, firstDayOfWeek, isDay, weekOf } from "../dates.js";
|
|
11
|
-
import {
|
|
11
|
+
import { ICON_NAMES, isIconName } from "../icons/index.js";
|
|
12
|
+
import { DEFAULT_PAGE_LIMIT, EVENTS_PAGE_LIMIT, LIST_LIMIT, MAX_DECIDERS, MAX_OPTIONS, MAX_OWN_WAKE_DAYS, MAX_RUNNER_LINE_LENGTH, MAX_SIGNALS_PAGE_LIMIT, MIN_OPTIONS, OWN_WAKE_KEY, } from "../limits.js";
|
|
13
|
+
import { onboardingTitle } from "../onboarding.js";
|
|
12
14
|
import { capabilityWords } from "../plugin/capabilities.js";
|
|
13
15
|
import { PLUGIN_LIST_LIMIT } from "../plugin/limits.js";
|
|
14
16
|
import { checkRecords, RECORDS_DIR, RECORDS_INDEX_FILE } from "../records.js";
|
|
15
|
-
import { decisionHref, docHref, myDecisionHref, taskHref } from "../router.js";
|
|
17
|
+
import { agentHref, decisionHref, docHref, myDecisionHref, taskHref } from "../router.js";
|
|
16
18
|
import { fillRules, RULES_PATH, RULES_TITLE } from "../rules.js";
|
|
17
19
|
import { DEFAULT_RUNNER_CONFIG, parseRunnerConfig } from "../runner/config.js";
|
|
18
20
|
import { DESK_FOLDER, deskFiles, deskServicesOf, deskWebTitleOf, personDeskFiles, } from "../runner/desk.js";
|
|
19
21
|
import { ownRunnerModules } from "../runner/modules.js";
|
|
20
|
-
import { createRunner, GIT_TOKEN_SECRET } from "../runner/runner.js";
|
|
22
|
+
import { createRunner, GIT_TOKEN_SECRET, } from "../runner/runner.js";
|
|
21
23
|
import { hostOfLogin, } from "../schemas.js";
|
|
22
24
|
import { agentLoginOf, deskRemoteOf } from "../services.js";
|
|
23
25
|
import { setupGuideOf, setupGuideText, setupSentenceOf } from "../setup-guide.js";
|
|
@@ -26,11 +28,13 @@ import { loadWebRoot, WebRootError } from "../web.js";
|
|
|
26
28
|
import { commandLine, commandWord, NO_LINE_TO_RUN } from "./command-words.js";
|
|
27
29
|
import { CredentialsError, EMPTY_CREDENTIALS, fitsFile, keepsNothing, lasts, loginsAt, pendingAt, resolveLogin, withLogin, withoutLogin, withoutPending, withPending, } from "./credentials.js";
|
|
28
30
|
import { DIRECTORY_FILE, THE_SENTENCE, } from "./directory.js";
|
|
29
|
-
import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatOptions, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSignalLine, formatTask, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
|
|
31
|
+
import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatOptions, formatOwnWakeLine, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSignalLine, formatTask, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
|
|
30
32
|
import { COMMAND_HELP, helpFor, ownSkillPath, usage } from "./help.js";
|
|
31
33
|
import { describeInstall, updateCommandFor } from "./install.js";
|
|
34
|
+
import { awakeWords, heldAwake, lookAtMachine } from "./machine-check.js";
|
|
32
35
|
import { consolePack, formatSkills, holdsNothing, ORGANIZATION_PACK_LINE, PackRefusal, packWords, refusalWords, skillPathIn, } from "./pack.js";
|
|
33
36
|
import { workPath } from "./runner-host.js";
|
|
37
|
+
import { secretNotes } from "./secret-notes.js";
|
|
34
38
|
import { createServeHandler, DEFAULT_SERVE_PORT, loadRecordsRoot, RecordsRootError, } from "./serve.js";
|
|
35
39
|
// The `console` command (docs/specs/cli.md): the agent's side of the console. A thin client of
|
|
36
40
|
// the REST API with no logic of its own: every command is one or two requests and the words to
|
|
@@ -3440,6 +3444,10 @@ const serve = async (args, io) => {
|
|
|
3440
3444
|
throw error;
|
|
3441
3445
|
}
|
|
3442
3446
|
}
|
|
3447
|
+
// Whether the records are there is asked before anything listens: the line says what the
|
|
3448
|
+
// command found when it began. Asked after, a directory made in the moment between, by a
|
|
3449
|
+
// session that began keeping something as the pages came up, read as there all along.
|
|
3450
|
+
const recordsThere = records === undefined ? false : await records.there();
|
|
3443
3451
|
const listening = await listen((bound) => createServeHandler({
|
|
3444
3452
|
upstream: session.url,
|
|
3445
3453
|
token: session.token,
|
|
@@ -3452,7 +3460,7 @@ const serve = async (args, io) => {
|
|
|
3452
3460
|
// nothing is kept there, and that what comes to be is served with no restart.
|
|
3453
3461
|
const served = kept === undefined || records === undefined
|
|
3454
3462
|
? ""
|
|
3455
|
-
:
|
|
3463
|
+
: recordsThere
|
|
3456
3464
|
? ` The records in ${kept} are at ${listening.url}records/, read as they are when they are asked for.`
|
|
3457
3465
|
: ` Nothing is kept in ${kept} yet: what comes to be kept there is at ${listening.url}records/ from then on, with no restart.`;
|
|
3458
3466
|
io.stdout(web === undefined
|
|
@@ -3503,6 +3511,41 @@ const machineLine = (text) => {
|
|
|
3503
3511
|
.slice(0, MAX_RUNNER_LINE_LENGTH);
|
|
3504
3512
|
return line.length === 0 ? "unknown" : line;
|
|
3505
3513
|
};
|
|
3514
|
+
/**
|
|
3515
|
+
* Keeps a runner going across its `runner.json` (ADR-0144): a runner that ended for its file is
|
|
3516
|
+
* followed by another, begun with the file as it is now, in this process. Where the file stopped
|
|
3517
|
+
* reading in between, the agent having written it again in the turn that was under way, the next
|
|
3518
|
+
* runner begins with the file as it last read, so that there is always one: it then says what is
|
|
3519
|
+
* wrong with the file to the agent, whose session it is the only way to. Answers how the last
|
|
3520
|
+
* runner ended, once one ended for anything else or whoever runs the command asked it to stop.
|
|
3521
|
+
*/
|
|
3522
|
+
export async function keepRunning(input) {
|
|
3523
|
+
let good = input.first;
|
|
3524
|
+
let running = input.start(good);
|
|
3525
|
+
let asked = false;
|
|
3526
|
+
void input.stopped.then(() => {
|
|
3527
|
+
asked = true;
|
|
3528
|
+
running.stop();
|
|
3529
|
+
});
|
|
3530
|
+
for (;;) {
|
|
3531
|
+
const how = await running.run();
|
|
3532
|
+
if (how !== "changed" || asked) {
|
|
3533
|
+
return how;
|
|
3534
|
+
}
|
|
3535
|
+
const next = await input.read();
|
|
3536
|
+
if (next.ok) {
|
|
3537
|
+
good = next.config;
|
|
3538
|
+
}
|
|
3539
|
+
else {
|
|
3540
|
+
input.say(`${next.problem}: the runner starts again with the runner.json it last read`);
|
|
3541
|
+
}
|
|
3542
|
+
running = input.start(good);
|
|
3543
|
+
// Asked to stop while the file was read: the runner just begun ends at once.
|
|
3544
|
+
if (asked) {
|
|
3545
|
+
running.stop();
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3506
3549
|
// The runner of an agent account (ADR-0085, docs/specs/runner.md): started in the account's
|
|
3507
3550
|
// desk, on the command signed in as the account itself. It keeps the agent's session going,
|
|
3508
3551
|
// feeds it what the console sends and reports what it does, until it is stopped.
|
|
@@ -3523,22 +3566,35 @@ const runner = async (args, io) => {
|
|
|
3523
3566
|
if (me.person.kind !== "agent" || me.session?.kind !== "command") {
|
|
3524
3567
|
throw failed("A runner is an agent account's own, on the command signed in as the account itself: console login --self, approved in a browser signed in as the account.");
|
|
3525
3568
|
}
|
|
3526
|
-
const written = await host.readText("runner.json");
|
|
3527
|
-
const read = written === undefined
|
|
3528
|
-
? { ok: true, config: DEFAULT_RUNNER_CONFIG }
|
|
3529
|
-
: parseRunnerConfig(written);
|
|
3530
|
-
if (!read.ok) {
|
|
3531
|
-
throw failed(`${read.problem}. Nothing of it is used: put it right, or remove it to run with the defaults.`);
|
|
3532
|
-
}
|
|
3533
3569
|
const modules = ownRunnerModules({ user: host.user });
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
const
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3570
|
+
/**
|
|
3571
|
+
* The desk's runner.json as it stands: its text, what it says, and the driver it names; or
|
|
3572
|
+
* what is wrong with it in a few words. No file is the defaults.
|
|
3573
|
+
*/
|
|
3574
|
+
const readConfig = async () => {
|
|
3575
|
+
const written = await host.readText("runner.json");
|
|
3576
|
+
const parsed = written === undefined
|
|
3577
|
+
? { ok: true, config: DEFAULT_RUNNER_CONFIG }
|
|
3578
|
+
: parseRunnerConfig(written);
|
|
3579
|
+
if (!parsed.ok) {
|
|
3580
|
+
return { ok: false, problem: parsed.problem };
|
|
3581
|
+
}
|
|
3582
|
+
const driverOf = modules.drivers.get(parsed.config.driver);
|
|
3583
|
+
if (driverOf === undefined) {
|
|
3584
|
+
return {
|
|
3585
|
+
ok: false,
|
|
3586
|
+
problem: `runner.json names the driver ${parsed.config.driver}, which this command does not have. It has: ${modules.drivers.names().join(", ")}`,
|
|
3587
|
+
};
|
|
3588
|
+
}
|
|
3589
|
+
const unknown = parsed.config.wake.find((name) => modules.wakeSources.get(name) === undefined);
|
|
3590
|
+
if (unknown !== undefined) {
|
|
3591
|
+
return {
|
|
3592
|
+
ok: false,
|
|
3593
|
+
problem: `runner.json names the wake source ${unknown}, which this command does not have. It has: ${modules.wakeSources.names().join(", ")}`,
|
|
3594
|
+
};
|
|
3595
|
+
}
|
|
3596
|
+
return { ok: true, config: parsed.config, driverOf, text: written ?? "" };
|
|
3597
|
+
};
|
|
3542
3598
|
// A header says the hour and the minute in the workspace's zone, or the machine's where it has none.
|
|
3543
3599
|
const zone = me.workspace.timeZone ?? undefined;
|
|
3544
3600
|
let clock;
|
|
@@ -3558,70 +3614,100 @@ const runner = async (args, io) => {
|
|
|
3558
3614
|
});
|
|
3559
3615
|
}
|
|
3560
3616
|
const statePath = workPath("runner-state.json");
|
|
3561
|
-
const
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
}),
|
|
3570
|
-
config: read.config,
|
|
3571
|
-
cwd: host.cwd,
|
|
3572
|
-
machine: {
|
|
3573
|
-
name: machineLine(io.hostname ?? ""),
|
|
3574
|
-
os: machineLine(host.os),
|
|
3575
|
-
user: machineLine(modules.boundaries.get("os-user")?.user() ?? host.user),
|
|
3576
|
-
},
|
|
3577
|
-
version: io.version ?? "0.0.0",
|
|
3578
|
-
// A runner whose own version is not known has nothing to hold the package's against.
|
|
3579
|
-
installed: io.version === undefined ? undefined : io.installedVersion,
|
|
3580
|
-
// What installs the console's version here, the way this command was installed.
|
|
3581
|
-
updateCommand: () => updateWords(io, io.consoleVersion?.()),
|
|
3582
|
-
now: io.now,
|
|
3583
|
-
random: host.random,
|
|
3584
|
-
time: (iso) => clock.format(new Date(iso)),
|
|
3585
|
-
files: {
|
|
3586
|
-
write: (path, text) => host.writePrivate(workPath(path), text),
|
|
3587
|
-
remove: (path) => host.remove(workPath(path)),
|
|
3588
|
-
},
|
|
3589
|
-
state: {
|
|
3590
|
-
load: async () => runnerStateOf(await host.readText(statePath)),
|
|
3591
|
-
save: (state) => host.writePrivate(statePath, `${JSON.stringify(state)}\n`),
|
|
3592
|
-
},
|
|
3593
|
-
log: (line) => io.stdout(`${new Date(io.now()).toISOString()} ${line}\n`),
|
|
3594
|
-
// The autosave's git: in the desk, asking nobody at a terminal, its words read and let go.
|
|
3595
|
-
// A step that reaches the git host is handed the account's token for it, as the clone of
|
|
3596
|
-
// the desk was: answered from the environment of that one command, and only to the host
|
|
3597
|
-
// the workspace keeps its desks at.
|
|
3598
|
-
git: async (args, handed) => {
|
|
3599
|
-
const origin = gitOriginOf(deskRemoteOf(me.workspace, me.person?.handle ?? ""));
|
|
3600
|
-
const child = host.spawn("git", args, {
|
|
3617
|
+
const person = me.person;
|
|
3618
|
+
/** A runner for the desk's runner.json as it is read now: begun again whenever the file changed (ADR-0144). */
|
|
3619
|
+
const runnerOf = (read) => {
|
|
3620
|
+
const { driverOf } = read;
|
|
3621
|
+
return createRunner({
|
|
3622
|
+
client: session.client,
|
|
3623
|
+
driver: driverOf({
|
|
3624
|
+
spawn: host.spawn,
|
|
3601
3625
|
cwd: host.cwd,
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
});
|
|
3606
|
-
child.end();
|
|
3607
|
-
for await (const _ of child.lines) {
|
|
3608
|
-
// Nothing of what git prints is kept.
|
|
3609
|
-
}
|
|
3610
|
-
return (await child.exited).code;
|
|
3611
|
-
},
|
|
3612
|
-
// The wake sources the desk names beside the console's own stream, which the runner listens to itself.
|
|
3613
|
-
wakes: {
|
|
3614
|
-
sources: read.config.wake.flatMap((name) => {
|
|
3615
|
-
const source = modules.wakeSources.get(name);
|
|
3616
|
-
return source === undefined || source.run === undefined ? [] : [source];
|
|
3626
|
+
command: read.config.product?.command,
|
|
3627
|
+
args: read.config.product?.args,
|
|
3628
|
+
version: io.version,
|
|
3617
3629
|
}),
|
|
3618
|
-
|
|
3619
|
-
|
|
3630
|
+
config: read.config,
|
|
3631
|
+
reconfigured: async () => {
|
|
3632
|
+
const now = await readConfig();
|
|
3633
|
+
return !now.ok ? { problem: now.problem } : now.text === read.text ? "same" : "changed";
|
|
3634
|
+
},
|
|
3635
|
+
cwd: host.cwd,
|
|
3636
|
+
machine: {
|
|
3637
|
+
name: machineLine(io.hostname ?? ""),
|
|
3638
|
+
os: machineLine(host.os),
|
|
3639
|
+
user: machineLine(modules.boundaries.get("os-user")?.user() ?? host.user),
|
|
3640
|
+
},
|
|
3641
|
+
version: io.version ?? "0.0.0",
|
|
3642
|
+
// A runner whose own version is not known has nothing to hold the package's against.
|
|
3643
|
+
installed: io.version === undefined ? undefined : io.installedVersion,
|
|
3644
|
+
// What installs the console's version here, the way this command was installed.
|
|
3645
|
+
updateCommand: () => updateWords(io, io.consoleVersion?.()),
|
|
3646
|
+
now: io.now,
|
|
3647
|
+
random: host.random,
|
|
3648
|
+
time: (iso) => clock.format(new Date(iso)),
|
|
3649
|
+
files: {
|
|
3650
|
+
write: (path, text) => host.writePrivate(workPath(path), text),
|
|
3651
|
+
remove: (path) => host.remove(workPath(path)),
|
|
3652
|
+
},
|
|
3653
|
+
state: {
|
|
3654
|
+
load: async () => runnerStateOf(await host.readText(statePath)),
|
|
3655
|
+
save: (state) => host.writePrivate(statePath, `${JSON.stringify(state)}\n`),
|
|
3656
|
+
},
|
|
3657
|
+
log: (line) => io.stdout(`${new Date(io.now()).toISOString()} ${line}\n`),
|
|
3658
|
+
// The autosave's git: in the desk, asking nobody at a terminal, its words read and let go.
|
|
3659
|
+
// A step that reaches the git host is handed the account's token for it, as the clone of
|
|
3660
|
+
// the desk was: answered from the environment of that one command, and only to the host
|
|
3661
|
+
// the workspace keeps its desks at.
|
|
3662
|
+
git: async (args, handed) => {
|
|
3663
|
+
const origin = gitOriginOf(deskRemoteOf(me.workspace, me.person?.handle ?? ""));
|
|
3664
|
+
const child = host.spawn("git", args, {
|
|
3665
|
+
cwd: host.cwd,
|
|
3666
|
+
env: handed?.token === undefined || origin === undefined
|
|
3667
|
+
? { GIT_TERMINAL_PROMPT: "0" }
|
|
3668
|
+
: gitTokenEnv(handed.token, origin),
|
|
3669
|
+
});
|
|
3670
|
+
child.end();
|
|
3671
|
+
for await (const _ of child.lines) {
|
|
3672
|
+
// Nothing of what git prints is kept.
|
|
3673
|
+
}
|
|
3674
|
+
return (await child.exited).code;
|
|
3675
|
+
},
|
|
3676
|
+
// The wake sources the desk names beside the console's own stream, which the runner listens to itself.
|
|
3677
|
+
wakes: {
|
|
3678
|
+
sources: read.config.wake.flatMap((name) => {
|
|
3679
|
+
const source = modules.wakeSources.get(name);
|
|
3680
|
+
return source === undefined || source.run === undefined ? [] : [source];
|
|
3681
|
+
}),
|
|
3682
|
+
fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
|
|
3683
|
+
socket: (url) => host.socket(url),
|
|
3684
|
+
},
|
|
3685
|
+
});
|
|
3686
|
+
};
|
|
3687
|
+
const first = await readConfig();
|
|
3688
|
+
if (!first.ok) {
|
|
3689
|
+
throw failed(`${first.problem}. Nothing of it is used: put it right, or remove it to run with the defaults.`);
|
|
3690
|
+
}
|
|
3691
|
+
io.stdout(`The runner of @${person.handle ?? person.login} at ${me.workspace.name} (${session.url}) starts in ${host.cwd}. Stop with Ctrl+C.\n`);
|
|
3692
|
+
// The machine is held awake while the runner runs, where the system has a way that needs no
|
|
3693
|
+
// administrator (ADR-0140): said in the runner's own lines, either way.
|
|
3694
|
+
const said = (line) => io.stdout(`${new Date(io.now()).toISOString()} ${line}\n`);
|
|
3695
|
+
void host
|
|
3696
|
+
.keepAwake?.()
|
|
3697
|
+
.then((awake) => said("by" in awake
|
|
3698
|
+
? `the machine is kept from sleeping while the runner runs (${awake.by})`
|
|
3699
|
+
: `the machine is not kept from sleeping by the runner (${awake.problem}): set it never to sleep when idle`));
|
|
3700
|
+
const how = await keepRunning({
|
|
3701
|
+
first,
|
|
3702
|
+
read: async () => {
|
|
3703
|
+
const next = await readConfig();
|
|
3704
|
+
return next.ok ? { ok: true, config: next } : next;
|
|
3620
3705
|
},
|
|
3706
|
+
start: runnerOf,
|
|
3707
|
+
stopped: host.untilStopped(),
|
|
3708
|
+
say: said,
|
|
3621
3709
|
});
|
|
3622
|
-
|
|
3623
|
-
void host.untilStopped().then(() => running.stop());
|
|
3624
|
-
if ((await running.run()) === "updated") {
|
|
3710
|
+
if (how === "updated") {
|
|
3625
3711
|
// The service that keeps a runner starts it again whenever it ends; one started by hand is
|
|
3626
3712
|
// started again by hand.
|
|
3627
3713
|
io.stdout("The command was updated: the runner ended, and the service that keeps it starts it again with the new one. Started by hand: console runner\n");
|
|
@@ -3773,6 +3859,13 @@ async function secretValue(io, values, prompt) {
|
|
|
3773
3859
|
}
|
|
3774
3860
|
return value;
|
|
3775
3861
|
}
|
|
3862
|
+
/**
|
|
3863
|
+
* The kind of git host the workspace names, where it names one: what a token for git is held to
|
|
3864
|
+
* the shape of. Asked for the secret that is one alone, since no other is held to a host's shape.
|
|
3865
|
+
*/
|
|
3866
|
+
const gitHostFor = async (client, name) => name === GIT_TOKEN_SECRET
|
|
3867
|
+
? ((await client.me().catch(() => undefined))?.workspace.services?.git?.kind ?? undefined)
|
|
3868
|
+
: undefined;
|
|
3776
3869
|
const SECRET_FLAGS = {
|
|
3777
3870
|
set: { type: "boolean" },
|
|
3778
3871
|
remove: { type: "boolean" },
|
|
@@ -3804,11 +3897,13 @@ const secret = async (args, io) => {
|
|
|
3804
3897
|
if (on(values, "set")) {
|
|
3805
3898
|
const expiresOn = expiryOf(io, values);
|
|
3806
3899
|
const value = await secretValue(io, values, `Value of ${name} (typed unseen; Enter ends it): `);
|
|
3900
|
+
const host = await gitHostFor(session.client, name);
|
|
3807
3901
|
const kept = await session.client.setSecret(name, {
|
|
3808
3902
|
value,
|
|
3809
3903
|
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
3810
3904
|
});
|
|
3811
|
-
|
|
3905
|
+
const notes = secretNotes(name, value, host);
|
|
3906
|
+
answer(io, session, kept, () => [`Kept: ${formatSecretLine(kept)}`, ...notes].join("\n"));
|
|
3812
3907
|
return EXIT.ok;
|
|
3813
3908
|
}
|
|
3814
3909
|
// The value alone, for whatever reads it next; the reading is on the account's record.
|
|
@@ -3854,11 +3949,125 @@ const agentSecret = async (args, io) => {
|
|
|
3854
3949
|
}
|
|
3855
3950
|
const expiresOn = expiryOf(io, values);
|
|
3856
3951
|
const value = await secretValue(io, values, `Value of ${name} for @${handle} (typed unseen; Enter ends it): `);
|
|
3952
|
+
const host = await gitHostFor(session.client, name);
|
|
3857
3953
|
const kept = await session.client.seedAgentSecret(handle, name, {
|
|
3858
3954
|
value,
|
|
3859
3955
|
...(expiresOn === undefined ? {} : { expiresOn }),
|
|
3860
3956
|
});
|
|
3861
|
-
|
|
3957
|
+
const notes = secretNotes(name, value, host);
|
|
3958
|
+
answer(io, session, kept, () => [`Seeded for @${handle}, which alone reads it back: ${formatSecretLine(kept)}`, ...notes].join("\n"));
|
|
3959
|
+
return EXIT.ok;
|
|
3960
|
+
};
|
|
3961
|
+
const OWN_WAKE_FLAGS = {
|
|
3962
|
+
file: { type: "string" },
|
|
3963
|
+
in: { type: "string" },
|
|
3964
|
+
at: { type: "string" },
|
|
3965
|
+
key: { type: "string" },
|
|
3966
|
+
cancel: { type: "boolean" },
|
|
3967
|
+
};
|
|
3968
|
+
const OWN_WAKE_USAGE = 'Say when, or nothing for now: console agent wake me ["<words>"] [--in <minutes> | --at <HH:MM>] [--key <name>] | agent wake me --cancel [--key <name>]';
|
|
3969
|
+
/** The hour and the minute it is in a time zone, as minutes of its day; in the machine's own where the zone names none. */
|
|
3970
|
+
function minutesOfDayIn(zone, now) {
|
|
3971
|
+
let parts;
|
|
3972
|
+
try {
|
|
3973
|
+
parts = new Intl.DateTimeFormat("en-GB", {
|
|
3974
|
+
hour: "2-digit",
|
|
3975
|
+
minute: "2-digit",
|
|
3976
|
+
hourCycle: "h23",
|
|
3977
|
+
...(zone === undefined ? {} : { timeZone: zone }),
|
|
3978
|
+
}).formatToParts(now);
|
|
3979
|
+
}
|
|
3980
|
+
catch {
|
|
3981
|
+
parts = new Intl.DateTimeFormat("en-GB", {
|
|
3982
|
+
hour: "2-digit",
|
|
3983
|
+
minute: "2-digit",
|
|
3984
|
+
hourCycle: "h23",
|
|
3985
|
+
}).formatToParts(now);
|
|
3986
|
+
}
|
|
3987
|
+
const of = (type) => Number(parts.find((part) => part.type === type)?.value ?? "0");
|
|
3988
|
+
return of("hour") * 60 + of("minute");
|
|
3989
|
+
}
|
|
3990
|
+
/**
|
|
3991
|
+
* When a wake for later is raised, as the flags say it: so many minutes from now, or the next
|
|
3992
|
+
* time the workspace's clock says an hour and a minute; nothing where neither flag is given.
|
|
3993
|
+
*/
|
|
3994
|
+
export function ownWakeMoment(given, zone, now) {
|
|
3995
|
+
if (given.in !== undefined && given.at !== undefined) {
|
|
3996
|
+
throw misuse(OWN_WAKE_USAGE);
|
|
3997
|
+
}
|
|
3998
|
+
if (given.in !== undefined) {
|
|
3999
|
+
const minutes = Number(given.in);
|
|
4000
|
+
if (!Number.isInteger(minutes) || minutes < 1 || minutes > MAX_OWN_WAKE_DAYS * 24 * 60) {
|
|
4001
|
+
throw misuse(`Not a number of minutes, from 1 to ${MAX_OWN_WAKE_DAYS * 24 * 60}: ${given.in}`);
|
|
4002
|
+
}
|
|
4003
|
+
return new Date(now.getTime() + minutes * 60_000);
|
|
4004
|
+
}
|
|
4005
|
+
if (given.at !== undefined) {
|
|
4006
|
+
const clock = /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/.exec(given.at);
|
|
4007
|
+
if (clock === null) {
|
|
4008
|
+
throw misuse(`Not an hour and a minute, as 14:30: ${given.at}`);
|
|
4009
|
+
}
|
|
4010
|
+
const wanted = Number(clock[1]) * 60 + Number(clock[2]);
|
|
4011
|
+
// The next time the clock says so: later today, or tomorrow where that hour has passed.
|
|
4012
|
+
const day = 24 * 60;
|
|
4013
|
+
const ahead = (wanted - minutesOfDayIn(zone, now) + day) % day || day;
|
|
4014
|
+
const at = new Date(now.getTime() + ahead * 60_000);
|
|
4015
|
+
at.setSeconds(0, 0);
|
|
4016
|
+
// Where the zone's clock is put forward or back before then, the moment is off by that
|
|
4017
|
+
// much: moved by what the clock says there, once, where the clock then says the hour asked
|
|
4018
|
+
// for and the moment is still to come. An hour the clock skips that night is no hour of
|
|
4019
|
+
// that day: the moment stays the one counted, just past it.
|
|
4020
|
+
const off = ((wanted - minutesOfDayIn(zone, at) + day + day / 2) % day) - day / 2;
|
|
4021
|
+
const moved = new Date(at.getTime() + off * 60_000);
|
|
4022
|
+
return off !== 0 && moved.getTime() > now.getTime() && minutesOfDayIn(zone, moved) === wanted
|
|
4023
|
+
? moved
|
|
4024
|
+
: at;
|
|
4025
|
+
}
|
|
4026
|
+
return undefined;
|
|
4027
|
+
}
|
|
4028
|
+
// A wake an agent account raises for itself (ADR-0145), by its own command: now, for whoever
|
|
4029
|
+
// prepared its machine or signed something in there to say so and for the agent to go on; or
|
|
4030
|
+
// kept for a moment to come, for an agent that has something to look at again.
|
|
4031
|
+
const ownWake = async (args, io) => {
|
|
4032
|
+
const { values, positionals } = parse(args, OWN_WAKE_FLAGS);
|
|
4033
|
+
const [, words, ...rest] = positionals;
|
|
4034
|
+
if (rest.length > 0) {
|
|
4035
|
+
throw misuse(OWN_WAKE_USAGE);
|
|
4036
|
+
}
|
|
4037
|
+
const key = text(values, "key");
|
|
4038
|
+
if (key !== undefined && !/^[a-z0-9][a-z0-9-]{0,39}$/.test(key)) {
|
|
4039
|
+
throw misuse(`Not a name for a wake, which is up to 40 lowercase letters, digits and hyphens: ${key}`);
|
|
4040
|
+
}
|
|
4041
|
+
const session = await open(io, values);
|
|
4042
|
+
/** A console of before knows no such route: said as what it is. */
|
|
4043
|
+
const asked = async (ask) => {
|
|
4044
|
+
try {
|
|
4045
|
+
return await ask();
|
|
4046
|
+
}
|
|
4047
|
+
catch (error) {
|
|
4048
|
+
if (error instanceof ApiError && error.status === 404 && error.code === "not_found") {
|
|
4049
|
+
throw failed("This console does not take an account's own wake yet: it does from 0.5.2 on.");
|
|
4050
|
+
}
|
|
4051
|
+
throw error;
|
|
4052
|
+
}
|
|
4053
|
+
};
|
|
4054
|
+
if (on(values, "cancel")) {
|
|
4055
|
+
const named = key ?? OWN_WAKE_KEY;
|
|
4056
|
+
await asked(() => session.client.cancelOwnWake(named));
|
|
4057
|
+
answer(io, session, { cancelled: named }, () => `The wake ${named} is taken away.`);
|
|
4058
|
+
return EXIT.ok;
|
|
4059
|
+
}
|
|
4060
|
+
const said = ((await bodyOf(io, values, words)) ?? "").trim();
|
|
4061
|
+
const me = await session.client.me();
|
|
4062
|
+
const at = ownWakeMoment({ in: text(values, "in"), at: text(values, "at") }, me.workspace.timeZone ?? undefined, new Date(io.now()));
|
|
4063
|
+
const raised = await asked(() => session.client.raiseOwnWake({
|
|
4064
|
+
...(said.length === 0 ? {} : { text: said }),
|
|
4065
|
+
...(at === undefined ? {} : { at: at.toISOString() }),
|
|
4066
|
+
...(key === undefined ? {} : { key }),
|
|
4067
|
+
}));
|
|
4068
|
+
answer(io, session, raised, () => raised.kept === null
|
|
4069
|
+
? `Raised, as signal #${raised.signal?.number ?? "?"} of your record: your runner takes it as it takes any wake.`
|
|
4070
|
+
: `Kept: ${formatOwnWakeLine(raised.kept)}\nTake it away: console agent wake me --cancel${raised.kept.key === OWN_WAKE_KEY ? "" : ` --key ${raised.kept.key}`}. A second under the same name takes its place.`);
|
|
3862
4071
|
return EXIT.ok;
|
|
3863
4072
|
};
|
|
3864
4073
|
/** The kinds of signal a supervisor sends with words: which need them, and which take them. */
|
|
@@ -3875,6 +4084,20 @@ const WORDED_SIGNALS = {
|
|
|
3875
4084
|
// with the same conversation or with a new one, a wake; in their own name, on the account's
|
|
3876
4085
|
// record. What it says is given as words, or with --file, or on standard input as `-`.
|
|
3877
4086
|
const agentSignal = async (kind, args, io) => {
|
|
4087
|
+
// An account's own wake is another command under the same word: console agent wake me,
|
|
4088
|
+
// wherever `me` stands among its flags.
|
|
4089
|
+
if (kind === "wake") {
|
|
4090
|
+
let whom;
|
|
4091
|
+
try {
|
|
4092
|
+
whom = parse(args, OWN_WAKE_FLAGS).positionals[0];
|
|
4093
|
+
}
|
|
4094
|
+
catch {
|
|
4095
|
+
whom = undefined;
|
|
4096
|
+
}
|
|
4097
|
+
if (whom === "me") {
|
|
4098
|
+
return ownWake(args, io);
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
3878
4101
|
const { values, positionals } = parse(args, { file: { type: "string" } });
|
|
3879
4102
|
const [given, words, ...rest] = positionals;
|
|
3880
4103
|
const needs = WORDED_SIGNALS[kind]?.needs === true;
|
|
@@ -3944,10 +4167,19 @@ const agentSignals = async (args, io) => {
|
|
|
3944
4167
|
...(limit === undefined ? {} : { limit: Number(limit) }),
|
|
3945
4168
|
...(before === undefined ? {} : { before: Number(before) }),
|
|
3946
4169
|
});
|
|
3947
|
-
|
|
4170
|
+
// What the account keeps for later (ADR-0145) stands over the record's first page: it is no
|
|
4171
|
+
// signal yet. A console of before keeps none, and says nothing of it.
|
|
4172
|
+
const kept = before === undefined
|
|
4173
|
+
? await session.client
|
|
4174
|
+
.ownWakes(handle)
|
|
4175
|
+
.then((wakes) => wakes.items)
|
|
4176
|
+
.catch(() => [])
|
|
4177
|
+
: [];
|
|
4178
|
+
answer(io, session, kept.length === 0 ? found : { ...found, kept }, () => found.items.length === 0 && kept.length === 0
|
|
3948
4179
|
? "No signal yet."
|
|
3949
4180
|
: [
|
|
3950
|
-
...
|
|
4181
|
+
...kept.map(formatOwnWakeLine),
|
|
4182
|
+
...found.items.map((signal) => formatSignalLine(signal, found.delivered)),
|
|
3951
4183
|
...(found.more
|
|
3952
4184
|
? [
|
|
3953
4185
|
`More before: console agent signals ${handle} --before ${found.items.at(-1)?.number}`,
|
|
@@ -3993,6 +4225,8 @@ const SETUP_FLAGS = {
|
|
|
3993
4225
|
refresh: { type: "boolean" },
|
|
3994
4226
|
"new-desk": { type: "boolean" },
|
|
3995
4227
|
"no-service": { type: "boolean" },
|
|
4228
|
+
driver: { type: "string" },
|
|
4229
|
+
"no-browser": { type: "boolean" },
|
|
3996
4230
|
};
|
|
3997
4231
|
/** The end of what a program said, for a refusal to carry: one line, bounded. */
|
|
3998
4232
|
function lastWords(ran) {
|
|
@@ -4075,7 +4309,9 @@ async function deskOf(machine, values) {
|
|
|
4075
4309
|
* host where the account keeps the token that reads it there, which is an account that pushed a
|
|
4076
4310
|
* desk before; written from the template otherwise, and no file that is there is written over.
|
|
4077
4311
|
*/
|
|
4078
|
-
async function settleDesk(io, machine, client, person, workspace, url, values
|
|
4312
|
+
async function settleDesk(io, machine, client, person, workspace, url, values,
|
|
4313
|
+
/** What a look at the machine found, for a setup that looked: the driver and the browser a new desk names. */
|
|
4314
|
+
look) {
|
|
4079
4315
|
const desk = await deskOf(machine, values);
|
|
4080
4316
|
const handle = person.handle ?? "";
|
|
4081
4317
|
if ((await machine.exists(machine.path(desk, "runner.json"))) ||
|
|
@@ -4098,6 +4334,7 @@ async function settleDesk(io, machine, client, person, workspace, url, values) {
|
|
|
4098
4334
|
throw failed(`The desk could not be cloned from ${remote}: ${lastWords(cloned)}. Put that right and run this again; or begin a new desk here with --new-desk, where the account never pushed one.`);
|
|
4099
4335
|
}
|
|
4100
4336
|
io.stdout(`The desk is cloned from ${remote} into ${desk}.\n`);
|
|
4337
|
+
await settleDeskGit(io, machine, desk, url, person.login, deskRemoteOf(workspace, handle));
|
|
4101
4338
|
return desk;
|
|
4102
4339
|
}
|
|
4103
4340
|
const written = [];
|
|
@@ -4105,6 +4342,14 @@ async function settleDesk(io, machine, client, person, workspace, url, values) {
|
|
|
4105
4342
|
agent: { name: person.name ?? handle, handle, title: person.title ?? null },
|
|
4106
4343
|
console: { url, workspace: workspace.name },
|
|
4107
4344
|
services: deskServicesOf(workspace, handle),
|
|
4345
|
+
// The product found on the machine, and its browser: what the runner starts with.
|
|
4346
|
+
runner: look === undefined
|
|
4347
|
+
? undefined
|
|
4348
|
+
: {
|
|
4349
|
+
...DEFAULT_RUNNER_CONFIG,
|
|
4350
|
+
...(look.driver === undefined ? {} : { driver: look.driver }),
|
|
4351
|
+
...(look.browser === undefined ? {} : { browser: look.browser }),
|
|
4352
|
+
},
|
|
4108
4353
|
})) {
|
|
4109
4354
|
const file = machine.path(desk, path);
|
|
4110
4355
|
if (!(await machine.exists(file))) {
|
|
@@ -4112,9 +4357,48 @@ async function settleDesk(io, machine, client, person, workspace, url, values) {
|
|
|
4112
4357
|
written.push(path);
|
|
4113
4358
|
}
|
|
4114
4359
|
}
|
|
4115
|
-
io.stdout(`A new desk is written at ${desk} (${written.join(", ")}). It is the agent's from now on: to edit
|
|
4360
|
+
io.stdout(`A new desk is written at ${desk} (${written.join(", ")}). It is the agent's from now on: to edit and to push to its git host.\n`);
|
|
4361
|
+
await settleDeskGit(io, machine, desk, url, person.login, deskRemoteOf(workspace, handle));
|
|
4116
4362
|
return desk;
|
|
4117
4363
|
}
|
|
4364
|
+
/**
|
|
4365
|
+
* The desk's own git settings (ADR-0140): a repository where it is none yet, and for the host
|
|
4366
|
+
* the workspace keeps its desks at, a credential helper that reads the account's token from its
|
|
4367
|
+
* store when git asks, in place of whatever the machine has configured. The agent then pushes
|
|
4368
|
+
* with nothing typed, and no copy of the token is left in a keychain or a file. Nothing where
|
|
4369
|
+
* the workspace names no git host, the command does not know how it was started, or git is not
|
|
4370
|
+
* there; what did not succeed is said and the setup goes on.
|
|
4371
|
+
*/
|
|
4372
|
+
async function settleDeskGit(io, machine, desk, url, login, remote) {
|
|
4373
|
+
const origin = gitOriginOf(remote);
|
|
4374
|
+
if (origin === undefined || machine.self === undefined) {
|
|
4375
|
+
return;
|
|
4376
|
+
}
|
|
4377
|
+
const git = (args) => machine.run("git", ["-C", desk, ...args]);
|
|
4378
|
+
if (!(await machine.exists(machine.path(desk, ".git")))) {
|
|
4379
|
+
if ((await git(["init", "--quiet"])).code !== 0) {
|
|
4380
|
+
return;
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
// The helper as git's own shell runs it: every word in single quotes, a path with its
|
|
4384
|
+
// slashes forward, which that shell takes on every system.
|
|
4385
|
+
const word = (text) => `'${text.replaceAll("\\", "/").replaceAll("'", "'\\''")}'`;
|
|
4386
|
+
const read = [...machine.self, "secret", GIT_TOKEN_SECRET, "--url", url, "--account", login]
|
|
4387
|
+
.map(word)
|
|
4388
|
+
.join(" ");
|
|
4389
|
+
const helper = `!f() { test "$1" = get && printf 'username=x-access-token\\npassword=%s\\n' "$(${read})"; }; f`;
|
|
4390
|
+
const key = `credential.${origin}.helper`;
|
|
4391
|
+
const kept = await git(["config", "--local", "--get-all", key]);
|
|
4392
|
+
if (kept.code === 0 && kept.out.includes(GIT_TOKEN_SECRET)) {
|
|
4393
|
+
return;
|
|
4394
|
+
}
|
|
4395
|
+
// An empty helper first: whatever the machine has configured for that host is left out.
|
|
4396
|
+
const cleared = await git(["config", "--local", "--replace-all", key, ""]);
|
|
4397
|
+
const added = cleared.code === 0 ? await git(["config", "--local", "--add", key, helper]) : cleared;
|
|
4398
|
+
io.stdout(added.code === 0
|
|
4399
|
+
? `The desk's git reads the account's ${GIT_TOKEN_SECRET} from its store when ${origin} asks: nothing is typed, and no copy is kept elsewhere.\n`
|
|
4400
|
+
: `The desk's git was not set to read the account's token from its store (${lastWords(added)}); the agent hands it to git itself.\n`);
|
|
4401
|
+
}
|
|
4118
4402
|
/**
|
|
4119
4403
|
* The service that keeps the runner running (ADR-0085), by the module of this platform: its
|
|
4120
4404
|
* files written and, for a first setup, its commands run; answers where the runner's own lines
|
|
@@ -4265,11 +4549,48 @@ async function awaitRunner(io, client, handle, heardBefore, log) {
|
|
|
4265
4549
|
const heard = found?.state?.heardAt ?? null;
|
|
4266
4550
|
const said = found?.runner?.machine ?? null;
|
|
4267
4551
|
if (heard !== null && heard !== heardBefore && said !== null) {
|
|
4268
|
-
io.stdout(`The runner is heard from: ${said.name}, ${said.os}, OS account ${said.user}. @${handle} is set up on this machine
|
|
4269
|
-
return;
|
|
4552
|
+
io.stdout(`The runner is heard from: ${said.name}, ${said.os}, OS account ${said.user}. @${handle} is set up on this machine.\n`);
|
|
4553
|
+
return true;
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
io.stdout(`The runner is not heard from yet. Its own lines are in ${log}: read them, since they say what it lacks; the account's page says when it is heard from.\n`);
|
|
4557
|
+
return false;
|
|
4558
|
+
}
|
|
4559
|
+
/** How often, and how many times, a setup looks whether the agent's first session has begun. */
|
|
4560
|
+
const FIRST_SESSION_PAUSE_MS = 2000;
|
|
4561
|
+
const FIRST_SESSION_TRIES = 30;
|
|
4562
|
+
/**
|
|
4563
|
+
* What a setup ends with (ADR-0140): whether the agent's first session has begun, where to
|
|
4564
|
+
* watch it, and that the machine's part ends here, since everything after is the agent's own.
|
|
4565
|
+
*/
|
|
4566
|
+
async function handOver(io, machine, client, url, handle,
|
|
4567
|
+
/** Where the runner's own lines are. */
|
|
4568
|
+
log) {
|
|
4569
|
+
let began = false;
|
|
4570
|
+
for (let tries = 0; tries < FIRST_SESSION_TRIES && !began; tries += 1) {
|
|
4571
|
+
const found = await client.agent(handle).catch(() => undefined);
|
|
4572
|
+
began = (found?.runner?.session ?? null) !== null;
|
|
4573
|
+
if (!began) {
|
|
4574
|
+
await io.sleep(FIRST_SESSION_PAUSE_MS);
|
|
4270
4575
|
}
|
|
4271
4576
|
}
|
|
4272
|
-
|
|
4577
|
+
const plate = await client.work().catch(() => undefined);
|
|
4578
|
+
const first = plate?.tasks.find((one) => one.task.title === onboardingTitle(handle));
|
|
4579
|
+
const lines = [
|
|
4580
|
+
began
|
|
4581
|
+
? `@${handle}'s session has begun: the agent is at work.`
|
|
4582
|
+
: `No session has begun yet: one begins when something wakes @${handle}.`,
|
|
4583
|
+
`Watch it: ${url}${agentHref(handle)}`,
|
|
4584
|
+
...(first === undefined
|
|
4585
|
+
? []
|
|
4586
|
+
: [
|
|
4587
|
+
`Its first task: #${first.task.number} "${first.task.title}" in ${first.project.key}, ${url}${taskHref(first.project.key, first.task.number)}`,
|
|
4588
|
+
]),
|
|
4589
|
+
`That is the machine prepared: stop here. What comes next, its sign-ins, its tokens, its desk's repository, its profile and its messenger, is @${handle}'s own, done in its own session: do none of it for it.`,
|
|
4590
|
+
`What you change on this machine afterwards, say to it: console agent wake me "<what changed>"`,
|
|
4591
|
+
awakeWords(machine.platform, await heldAwake(machine), log),
|
|
4592
|
+
];
|
|
4593
|
+
io.stdout(`${lines.join("\n")}\n`);
|
|
4273
4594
|
}
|
|
4274
4595
|
// Derives a machine again (ADR-0088): by the account's own command, in its desk, when the
|
|
4275
4596
|
// services or the account changed. It writes what is missing of the desk and the service where
|
|
@@ -4342,20 +4663,32 @@ const agentSetup = async (args, io) => {
|
|
|
4342
4663
|
}
|
|
4343
4664
|
const { handle } = setup.account;
|
|
4344
4665
|
io.stdout(`\nSetting this machine up for @${handle}, in the OS account ${machine.user}${io.hostname === undefined ? "" : ` on ${io.hostname}`}.\n`);
|
|
4666
|
+
// The machine first (ADR-0140): everything that is missing is said at once, before anyone is
|
|
4667
|
+
// asked to sign in, and nothing is set up on a machine the runner could not work on.
|
|
4668
|
+
const driver = text(values, "driver");
|
|
4669
|
+
if (driver !== undefined &&
|
|
4670
|
+
ownRunnerModules({ user: machine.user }).drivers.get(driver) === undefined) {
|
|
4671
|
+
throw misuse(`Not a driver this command has: ${driver}. It has: ${ownRunnerModules({ user: machine.user }).drivers.names().join(", ")}.`);
|
|
4672
|
+
}
|
|
4673
|
+
const look = await lookAtMachine(machine, { driver, browser: !on(values, "no-browser") });
|
|
4674
|
+
if (look.missing.length > 0) {
|
|
4675
|
+
throw failed(`This machine lacks what the setup needs. Install each yourself, without asking, and run the line again:\n${look.missing.map((line) => `- ${line}`).join("\n")}`);
|
|
4676
|
+
}
|
|
4677
|
+
io.stdout(`The machine has what the setup needs: git${look.product === undefined ? "" : `, ${look.product}`}${look.browser === undefined ? "" : ", Google Chrome"}.\n${look.notes.map((line) => `${line}\n`).join("")}`);
|
|
4345
4678
|
const client = await signInAsAccount(io, machine, url, setup);
|
|
4346
4679
|
const me = await client.me();
|
|
4347
4680
|
if (me.person === null) {
|
|
4348
4681
|
throw failed("The console does not know this sign-in any more. Run the line again.");
|
|
4349
4682
|
}
|
|
4350
4683
|
const heardBefore = (await client.agent(handle).catch(() => undefined))?.state?.heardAt ?? null;
|
|
4351
|
-
const desk = await settleDesk(io, machine, client, me.person, me.workspace, url, values);
|
|
4684
|
+
const desk = await settleDesk(io, machine, client, me.person, me.workspace, url, values, look);
|
|
4352
4685
|
if (on(values, "no-service")) {
|
|
4353
4686
|
io.stdout(`No service is written, as asked. Start the runner yourself and keep it running: ${runnerByHand(desk, url, me.person.login, machine.platform)}\n`);
|
|
4354
4687
|
return EXIT.ok;
|
|
4355
4688
|
}
|
|
4356
4689
|
const log = await settleService(io, machine, desk, url, me.person.login, "load");
|
|
4357
|
-
if (log !== undefined) {
|
|
4358
|
-
await
|
|
4690
|
+
if (log !== undefined && (await awaitRunner(io, client, handle, heardBefore, log))) {
|
|
4691
|
+
await handOver(io, machine, client, url, handle, log);
|
|
4359
4692
|
}
|
|
4360
4693
|
return EXIT.ok;
|
|
4361
4694
|
};
|
|
@@ -4890,7 +5223,21 @@ const PROJECT_FIELDS = {
|
|
|
4890
5223
|
skills: { type: "string" },
|
|
4891
5224
|
color: { type: "string" },
|
|
4892
5225
|
symbol: { type: "string" },
|
|
5226
|
+
glyph: { type: "string" },
|
|
4893
5227
|
};
|
|
5228
|
+
/** An icon of the pack as a flag names it, `null` for `none`; a name that is none of the pack's is answered with the pack's names. */
|
|
5229
|
+
function glyphOrNoneOf(value) {
|
|
5230
|
+
if (value === undefined) {
|
|
5231
|
+
return undefined;
|
|
5232
|
+
}
|
|
5233
|
+
if (value === "none") {
|
|
5234
|
+
return null;
|
|
5235
|
+
}
|
|
5236
|
+
if (!isIconName(value)) {
|
|
5237
|
+
throw misuse(`No icon of the pack is called ${value}. The pack's icons: ${ICON_NAMES.join(", ")}; none takes the icon away.`);
|
|
5238
|
+
}
|
|
5239
|
+
return value;
|
|
5240
|
+
}
|
|
4894
5241
|
/** What the flags say of a project; `none` clears what may be cleared. */
|
|
4895
5242
|
async function projectFieldsOf(io, values) {
|
|
4896
5243
|
const description = await bodyOf(io, values, text(values, "description"));
|
|
@@ -4898,6 +5245,7 @@ async function projectFieldsOf(io, values) {
|
|
|
4898
5245
|
const skills = orNone(text(values, "skills"));
|
|
4899
5246
|
const color = colorOrNoneOf(text(values, "color"));
|
|
4900
5247
|
const symbol = orNone(text(values, "symbol"));
|
|
5248
|
+
const glyph = glyphOrNoneOf(text(values, "glyph"));
|
|
4901
5249
|
return {
|
|
4902
5250
|
...(description === undefined
|
|
4903
5251
|
? {}
|
|
@@ -4906,6 +5254,7 @@ async function projectFieldsOf(io, values) {
|
|
|
4906
5254
|
...(skills === undefined ? {} : { skillsAddress: skills }),
|
|
4907
5255
|
...(color === undefined ? {} : { color }),
|
|
4908
5256
|
...(symbol === undefined ? {} : { symbol }),
|
|
5257
|
+
...(glyph === undefined ? {} : { glyph }),
|
|
4909
5258
|
};
|
|
4910
5259
|
}
|
|
4911
5260
|
const newProject = async (args, io) => {
|
|
@@ -4923,7 +5272,7 @@ const editProject = async (args, io) => {
|
|
|
4923
5272
|
const name = text(values, "name");
|
|
4924
5273
|
const patch = { ...(name === undefined ? {} : { name }), ...(await projectFieldsOf(io, values)) };
|
|
4925
5274
|
if (Object.keys(patch).length === 0) {
|
|
4926
|
-
throw misuse("Say what to change: --name, --description, --visibility, --skills, --color or --
|
|
5275
|
+
throw misuse("Say what to change: --name, --description, --visibility, --skills, --color, --symbol or --glyph; none clears the description, the skills address, the colour, the symbol or the icon.");
|
|
4927
5276
|
}
|
|
4928
5277
|
const session = await open(io, values);
|
|
4929
5278
|
const changed = await session.client.project(key).update(patch);
|