@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.
Files changed (230) hide show
  1. package/README.md +14 -7
  2. package/SKILLCDN.md +3 -2
  3. package/dist/agent-page.d.ts +2 -0
  4. package/dist/agent-page.d.ts.map +1 -1
  5. package/dist/agent-page.js +77 -30
  6. package/dist/agent-page.js.map +1 -1
  7. package/dist/agent-state.d.ts +9 -0
  8. package/dist/agent-state.d.ts.map +1 -0
  9. package/dist/agent-state.js +28 -0
  10. package/dist/agent-state.js.map +1 -0
  11. package/dist/agent-usage.d.ts +9 -6
  12. package/dist/agent-usage.d.ts.map +1 -1
  13. package/dist/agent-usage.js +38 -8
  14. package/dist/agent-usage.js.map +1 -1
  15. package/dist/api.d.ts +4 -3
  16. package/dist/api.d.ts.map +1 -1
  17. package/dist/api.js +4 -3
  18. package/dist/api.js.map +1 -1
  19. package/dist/cli/cli.d.ts +2 -0
  20. package/dist/cli/cli.d.ts.map +1 -1
  21. package/dist/cli/cli.js +369 -130
  22. package/dist/cli/cli.js.map +1 -1
  23. package/dist/cli/format.d.ts +13 -4
  24. package/dist/cli/format.d.ts.map +1 -1
  25. package/dist/cli/format.js +43 -9
  26. package/dist/cli/format.js.map +1 -1
  27. package/dist/cli/help.d.ts +82 -9
  28. package/dist/cli/help.d.ts.map +1 -1
  29. package/dist/cli/help.js +780 -318
  30. package/dist/cli/help.js.map +1 -1
  31. package/dist/cli/pack.d.ts +2 -2
  32. package/dist/cli/pack.d.ts.map +1 -1
  33. package/dist/cli/pack.js +6 -4
  34. package/dist/cli/pack.js.map +1 -1
  35. package/dist/cli/runner-files.d.ts +16 -0
  36. package/dist/cli/runner-files.d.ts.map +1 -0
  37. package/dist/cli/runner-files.js +110 -0
  38. package/dist/cli/runner-files.js.map +1 -0
  39. package/dist/cli/runner-host.d.ts +7 -0
  40. package/dist/cli/runner-host.d.ts.map +1 -1
  41. package/dist/cli/runner-host.js +40 -2
  42. package/dist/cli/runner-host.js.map +1 -1
  43. package/dist/client.d.ts +22 -1
  44. package/dist/client.d.ts.map +1 -1
  45. package/dist/client.js +7 -1
  46. package/dist/client.js.map +1 -1
  47. package/dist/components/agent-page.d.ts +61 -11
  48. package/dist/components/agent-page.d.ts.map +1 -1
  49. package/dist/components/agent-page.js +146 -35
  50. package/dist/components/agent-page.js.map +1 -1
  51. package/dist/components/agents.d.ts +3 -2
  52. package/dist/components/agents.d.ts.map +1 -1
  53. package/dist/components/agents.js +9 -3
  54. package/dist/components/agents.js.map +1 -1
  55. package/dist/components/calendar.d.ts +24 -4
  56. package/dist/components/calendar.d.ts.map +1 -1
  57. package/dist/components/calendar.js +78 -35
  58. package/dist/components/calendar.js.map +1 -1
  59. package/dist/console.d.ts.map +1 -1
  60. package/dist/console.js +40 -12
  61. package/dist/console.js.map +1 -1
  62. package/dist/data.d.ts +2 -0
  63. package/dist/data.d.ts.map +1 -1
  64. package/dist/data.js +4 -0
  65. package/dist/data.js.map +1 -1
  66. package/dist/desk-page.js +5 -5
  67. package/dist/desk-page.js.map +1 -1
  68. package/dist/feed-words.d.ts.map +1 -1
  69. package/dist/feed-words.js +18 -1
  70. package/dist/feed-words.js.map +1 -1
  71. package/dist/i18n/en.d.ts +51 -1
  72. package/dist/i18n/en.d.ts.map +1 -1
  73. package/dist/i18n/en.js +44 -2
  74. package/dist/i18n/en.js.map +1 -1
  75. package/dist/i18n/ko.d.ts.map +1 -1
  76. package/dist/i18n/ko.js +52 -17
  77. package/dist/i18n/ko.js.map +1 -1
  78. package/dist/index.d.ts +1 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +1 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/limits.d.ts +10 -0
  83. package/dist/limits.d.ts.map +1 -1
  84. package/dist/limits.js +10 -0
  85. package/dist/limits.js.map +1 -1
  86. package/dist/plugin/capabilities.d.ts +1 -1
  87. package/dist/plugin/capabilities.d.ts.map +1 -1
  88. package/dist/plugin/capabilities.js +6 -1
  89. package/dist/plugin/capabilities.js.map +1 -1
  90. package/dist/plugin/context.d.ts +101 -8
  91. package/dist/plugin/context.d.ts.map +1 -1
  92. package/dist/plugin/limits.d.ts +7 -0
  93. package/dist/plugin/limits.d.ts.map +1 -1
  94. package/dist/plugin/limits.js +7 -0
  95. package/dist/plugin/limits.js.map +1 -1
  96. package/dist/plugin/testing.d.ts +2 -0
  97. package/dist/plugin/testing.d.ts.map +1 -1
  98. package/dist/plugin/testing.js +2 -0
  99. package/dist/plugin/testing.js.map +1 -1
  100. package/dist/rules.js +1 -1
  101. package/dist/rules.js.map +1 -1
  102. package/dist/runner/acp.d.ts.map +1 -1
  103. package/dist/runner/acp.js +9 -3
  104. package/dist/runner/acp.js.map +1 -1
  105. package/dist/runner/claude.d.ts.map +1 -1
  106. package/dist/runner/claude.js +143 -10
  107. package/dist/runner/claude.js.map +1 -1
  108. package/dist/runner/codex.d.ts.map +1 -1
  109. package/dist/runner/codex.js +14 -2
  110. package/dist/runner/codex.js.map +1 -1
  111. package/dist/runner/config.d.ts +18 -0
  112. package/dist/runner/config.d.ts.map +1 -1
  113. package/dist/runner/config.js +77 -1
  114. package/dist/runner/config.js.map +1 -1
  115. package/dist/runner/desk.d.ts +7 -0
  116. package/dist/runner/desk.d.ts.map +1 -1
  117. package/dist/runner/desk.js +20 -4
  118. package/dist/runner/desk.js.map +1 -1
  119. package/dist/runner/message.d.ts +26 -2
  120. package/dist/runner/message.d.ts.map +1 -1
  121. package/dist/runner/message.js +120 -32
  122. package/dist/runner/message.js.map +1 -1
  123. package/dist/runner/runner.d.ts +40 -2
  124. package/dist/runner/runner.d.ts.map +1 -1
  125. package/dist/runner/runner.js +533 -32
  126. package/dist/runner/runner.js.map +1 -1
  127. package/dist/runner/slack-status.d.ts +19 -0
  128. package/dist/runner/slack-status.d.ts.map +1 -0
  129. package/dist/runner/slack-status.js +332 -0
  130. package/dist/runner/slack-status.js.map +1 -0
  131. package/dist/runner/slack.d.ts +17 -11
  132. package/dist/runner/slack.d.ts.map +1 -1
  133. package/dist/runner/slack.js +1199 -109
  134. package/dist/runner/slack.js.map +1 -1
  135. package/dist/runner/types.d.ts +205 -6
  136. package/dist/runner/types.d.ts.map +1 -1
  137. package/dist/runner/types.js.map +1 -1
  138. package/dist/runner/usage.d.ts +6 -1
  139. package/dist/runner/usage.d.ts.map +1 -1
  140. package/dist/runner/usage.js +9 -2
  141. package/dist/runner/usage.js.map +1 -1
  142. package/dist/runner.d.ts +4 -4
  143. package/dist/runner.d.ts.map +1 -1
  144. package/dist/runner.js +3 -3
  145. package/dist/runner.js.map +1 -1
  146. package/dist/schemas.d.ts +263 -1
  147. package/dist/schemas.d.ts.map +1 -1
  148. package/dist/schemas.js +137 -5
  149. package/dist/schemas.js.map +1 -1
  150. package/dist/vocabulary.d.ts +7 -0
  151. package/dist/vocabulary.d.ts.map +1 -1
  152. package/dist/vocabulary.js +6 -0
  153. package/dist/vocabulary.js.map +1 -1
  154. package/dist/wake-text.d.ts +43 -0
  155. package/dist/wake-text.d.ts.map +1 -0
  156. package/dist/wake-text.js +115 -0
  157. package/dist/wake-text.js.map +1 -0
  158. package/docs/specs/cli.md +21 -12
  159. package/docs/specs/plugins.md +12 -7
  160. package/docs/specs/rest.md +14 -5
  161. package/docs/specs/runner.md +133 -26
  162. package/docs/start.md +26 -5
  163. package/package.json +3 -3
  164. package/skills/building-a-plugin/SKILL.md +3 -3
  165. package/skills/deploying-a-console/SKILL.md +3 -3
  166. package/skills/deploying-a-console/references/access.md +15 -1
  167. package/skills/deploying-a-console/references/resources.md +2 -2
  168. package/skills/deploying-a-console/scripts/github-app.mjs +593 -0
  169. package/skills/planning-the-board/references/setting-up.md +1 -1
  170. package/skills/running-an-agent/SKILL.md +18 -72
  171. package/skills/running-an-agent/references/preparing-the-machine.md +17 -0
  172. package/skills/running-an-agent/references/several-tasks.md +1 -1
  173. package/skills/running-an-agent/references/slack-app.md +55 -8
  174. package/skills/running-an-agent/references/the-account-and-the-invitation.md +5 -0
  175. package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -0
  176. package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +16 -0
  177. package/skills/running-an-agent/references/your-first-task.md +19 -0
  178. package/skills/trying-a-console/SKILL.md +136 -0
  179. package/skills/trying-a-console/references/when-it-does-not-go.md +30 -0
  180. package/skills/working-the-board/SKILL.md +11 -15
  181. package/skills/working-the-board/references/a-pack-skills-questions.md +3 -0
  182. package/skills/working-the-board/references/a-plugins-commands.md +3 -0
  183. package/skills/working-the-board/references/a-review.md +3 -0
  184. package/skills/working-the-board/references/an-open-run.md +3 -0
  185. package/skills/working-the-board/references/requirements.md +7 -0
  186. package/skills/working-the-board/references/the-pack.md +3 -3
  187. package/skills/working-the-board/references/what-they-were-told.md +3 -0
  188. package/skills/working-the-board/references/work-given-in-chat.md +5 -0
  189. package/src/agent-page.tsx +133 -41
  190. package/src/agent-state.ts +33 -0
  191. package/src/agent-usage.ts +55 -12
  192. package/src/api.ts +23 -0
  193. package/src/cli/cli.ts +443 -137
  194. package/src/cli/format.ts +49 -9
  195. package/src/cli/help.ts +904 -359
  196. package/src/cli/pack.ts +6 -4
  197. package/src/cli/runner-files.ts +120 -0
  198. package/src/cli/runner-host.ts +48 -2
  199. package/src/client.ts +64 -0
  200. package/src/components/agent-page.tsx +264 -39
  201. package/src/components/agents.tsx +20 -5
  202. package/src/components/calendar.tsx +92 -36
  203. package/src/console.tsx +47 -10
  204. package/src/data.ts +6 -0
  205. package/src/desk-page.tsx +5 -5
  206. package/src/feed-words.ts +20 -1
  207. package/src/i18n/en.ts +50 -2
  208. package/src/i18n/ko.ts +62 -17
  209. package/src/index.ts +2 -0
  210. package/src/limits.ts +10 -0
  211. package/src/plugin/capabilities.ts +8 -1
  212. package/src/plugin/context.ts +103 -7
  213. package/src/plugin/limits.ts +7 -0
  214. package/src/plugin/testing.ts +4 -0
  215. package/src/rules.ts +1 -1
  216. package/src/runner/acp.ts +9 -3
  217. package/src/runner/claude.ts +159 -10
  218. package/src/runner/codex.ts +14 -2
  219. package/src/runner/config.ts +114 -1
  220. package/src/runner/desk.ts +23 -4
  221. package/src/runner/message.ts +144 -35
  222. package/src/runner/runner.ts +658 -35
  223. package/src/runner/slack-status.ts +423 -0
  224. package/src/runner/slack.ts +1509 -128
  225. package/src/runner/types.ts +200 -5
  226. package/src/runner/usage.ts +16 -3
  227. package/src/runner.ts +20 -1
  228. package/src/schemas.ts +161 -3
  229. package/src/vocabulary.ts +9 -0
  230. package/src/wake-text.ts +133 -0
package/dist/cli/cli.js CHANGED
@@ -20,8 +20,9 @@ import { fillRules, RULES_PATH, RULES_TITLE } from "../rules.js";
20
20
  import { HEADLESS_TOOL } from "../runner/browser.js";
21
21
  import { DEFAULT_RUNNER_CONFIG, parseRunnerConfig } from "../runner/config.js";
22
22
  import { DESK_FOLDER, deskFiles, deskServicesOf, deskWebTitleOf, personDeskFiles, } from "../runner/desk.js";
23
+ import { quotedLines } from "../runner/message.js";
23
24
  import { ownRunnerModules } from "../runner/modules.js";
24
- import { createRunner, GIT_TOKEN_SECRET, } from "../runner/runner.js";
25
+ import { createRunner, GIT_TOKEN_SECRET } from "../runner/runner.js";
25
26
  import { hostOfLogin, } from "../schemas.js";
26
27
  import { agentLoginOf, deskRemoteOf } from "../services.js";
27
28
  import { setupGuideOf, setupGuideText, setupSentenceOf } from "../setup-guide.js";
@@ -30,11 +31,12 @@ import { loadWebRoot, WebRootError } from "../web.js";
30
31
  import { commandLine, commandWord, NO_LINE_TO_RUN } from "./command-words.js";
31
32
  import { CredentialsError, EMPTY_CREDENTIALS, fitsFile, keepsNothing, lasts, loginsAt, pendingAt, resolveLogin, withLogin, withoutLogin, withoutPending, withPending, } from "./credentials.js";
32
33
  import { DIRECTORY_FILE, THE_SENTENCE, } from "./directory.js";
33
- import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatNotificationSettings, formatNotifications, formatOptions, formatOwnWakeLine, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSignalLine, formatTask, formatTaskFollow, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
34
- import { COMMAND_HELP, helpFor, ownSkillPath, usage } from "./help.js";
34
+ import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatNotificationSettings, formatNotifications, formatOptions, formatOwnWakeLine, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSecretOffer, formatSignalLine, formatTask, formatTaskFollow, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
35
+ import { COMMAND_ALIASES, formTyped, held, helpFor, nearestCommands, ownSkillPath, usage, } from "./help.js";
35
36
  import { describeInstall, updateCommandFor } from "./install.js";
36
37
  import { awakeWords, heldAwake, lookAtMachine, standsInTheWay, } from "./machine-check.js";
37
38
  import { consolePack, formatSkills, holdsNothing, ORGANIZATION_PACK_LINE, PackRefusal, packWords, refusalWords, skillPathIn, skillsAround, } from "./pack.js";
39
+ import { keptBySourceOf, keptFileOf, runnerStateOf } from "./runner-files.js";
38
40
  import { workPath } from "./runner-host.js";
39
41
  import { secretNotes } from "./secret-notes.js";
40
42
  import { createServeHandler, DEFAULT_SERVE_PORT, loadRecordsRoot, RecordsRootError, } from "./serve.js";
@@ -106,9 +108,42 @@ function parse(args, options, allowPositionals = true) {
106
108
  });
107
109
  }
108
110
  catch (error) {
109
- throw misuse(error instanceof Error ? error.message : "The arguments were not understood.");
111
+ throw misuse(refusedByParser(error, options));
110
112
  }
111
113
  }
114
+ /**
115
+ * What the parser refused, in the command's own words (ADR-0167): an option that is none of
116
+ * the command's is answered with those it takes, so that the next try needs no page of help;
117
+ * what the parser says of a value is said as it says it, without its advice on other things.
118
+ */
119
+ function refusedByParser(error, options) {
120
+ if (!(error instanceof Error)) {
121
+ return "The arguments were not understood.";
122
+ }
123
+ const code = "code" in error ? String(error.code) : "";
124
+ // What was typed is between the parser's first quote and the one its sentence goes on
125
+ // after: a word may hold a quote of its own (`it's`), and is said whole.
126
+ const ADVICE = ". To specify a positional argument ";
127
+ const named = (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION"
128
+ ? /^Unknown option '(.*?)'(?:\. To specify a positional argument .*)?$/s
129
+ : /^Unexpected argument '(.*)'\. This command does not take positional arguments$/s).exec(error.message)?.[1] ??
130
+ /'([^']*)'/.exec(error.message)?.[1] ??
131
+ "";
132
+ if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
133
+ const own = Object.keys(options).map((name) => `--${name}`);
134
+ const takes = own.length === 0 ? "It takes none of its own" : `Its own are ${own.join(", ")}`;
135
+ // A word of a report or a title may begin with a dash, and is then no option at all:
136
+ // said where the command takes a word, and what was typed does not read as an option.
137
+ const dashed = !error.message.includes(ADVICE) || /^--[a-z][a-z0-9-]*$/.test(named)
138
+ ? ""
139
+ : " A word that begins with - and is no option goes after --.";
140
+ return `Not an option of this command: ${named}. ${takes}; --json, --project, --url and --account go with every command.${dashed}`;
141
+ }
142
+ if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL") {
143
+ return `This command takes no word beside its options: ${named}.`;
144
+ }
145
+ return error.message;
146
+ }
112
147
  const text = (values, name) => {
113
148
  const value = values[name];
114
149
  return typeof value === "string" ? value : undefined;
@@ -1056,7 +1091,7 @@ const whoami = async (args, io) => {
1056
1091
  // agent here for where the skill is, and the workspace has rules whatever the project.
1057
1092
  // The skill's path stands last, with nothing after it, to be copied as it is.
1058
1093
  io.skillsDir === undefined
1059
- ? "Before the first task, read console rules and the skill working-the-board (console skills says where it is); for one command's flags, console help <command>."
1094
+ ? "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>."
1060
1095
  : `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)}`,
1061
1096
  `This command is ${io.version ?? "of a version it does not know"}${io.install === undefined ? "" : `, ${describeInstall(io.install)}`}; ${consoleWords}.`,
1062
1097
  ...(verdict === "behind"
@@ -1288,6 +1323,7 @@ async function readThrough(io, session, owner, pack, read, options) {
1288
1323
  words: options.words,
1289
1324
  json: session.json,
1290
1325
  nextPart: options.nextPart,
1326
+ browseFolder: options.browseFolder,
1291
1327
  room: roomFor(owner, options.beside ?? []),
1292
1328
  });
1293
1329
  }
@@ -1498,15 +1534,36 @@ async function readSkills(io, session, reader, values, positionals, extras) {
1498
1534
  });
1499
1535
  return EXIT.ok;
1500
1536
  }
1537
+ // The command that reads the next page of a folder or of a search (SkillCDN 0.6.3): this
1538
+ // one again, asked as it was, with the cursor the page ended on. Where a word of it has no
1539
+ // spelling both shells take, the command that was run is run again, and the line says why.
1540
+ const nextPage = (asked) => (next) => commandLine(extras.command, [
1541
+ ...asked,
1542
+ ...(limit === undefined ? [] : ["--limit", limit]),
1543
+ "--cursor",
1544
+ next,
1545
+ ...(extras.again ?? []),
1546
+ ]) ??
1547
+ `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}`;
1501
1548
  if (words !== undefined) {
1502
- // One page of what the words find; more is said, and asked for with --cursor.
1503
- const found = await readThrough(io, session, owner, pack, { read: "find", words, path: folder, cursor, limit }, { words: toolWords, beside: [loading] });
1504
- say(jsonOfRead(session, pack, found), () => `${found.text}\n${loading}`);
1549
+ // One page of what the words find, which ends with the command that reads the next where
1550
+ // more was found. How a skill is loaded stands above it then, so that the command is last.
1551
+ const found = await readThrough(io, session, owner, pack, { read: "find", words, path: folder, cursor, limit }, {
1552
+ words: toolWords,
1553
+ beside: [loading],
1554
+ nextPart: nextPage([
1555
+ "--search",
1556
+ words,
1557
+ ...(given === undefined ? [] : [given]),
1558
+ ...(within === undefined ? [] : ["--path", within]),
1559
+ ]),
1560
+ });
1561
+ say(jsonOfRead(session, pack, found), () => found.next === undefined ? `${found.text}\n${loading}` : `${loading}\n${found.text}`);
1505
1562
  return EXIT.ok;
1506
1563
  }
1507
1564
  // One page of the folder, or of a file's outline, as the skillcdn command browses: a page
1508
- // that ends before the folder does names the cursor that continues it.
1509
- const browsed = await readThrough(io, session, owner, pack, { read: "browse", path: folder, cursor, limit }, { words: toolWords });
1565
+ // that ends before the folder does ends with the command that reads the next.
1566
+ const browsed = await readThrough(io, session, owner, pack, { read: "browse", path: folder, cursor, limit }, { words: toolWords, nextPart: nextPage(given === undefined ? [] : [given]) });
1510
1567
  say(jsonOfRead(session, pack, browsed), () => browsed.text);
1511
1568
  return EXIT.ok;
1512
1569
  }
@@ -1595,6 +1652,11 @@ async function readSkill(io, session, reader, values, positionals, command, owne
1595
1652
  // the command that was run is run again, with the cursor, and the line says why.
1596
1653
  nextPart: (next) => commandLine(command, [given, "--cursor", next, ...again]) ??
1597
1654
  `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}`,
1655
+ // The skill's own folder, where it does not list every file of it, as the command that
1656
+ // lists a folder of this pack (SkillCDN 0.6.3): the dot for the root, since the command
1657
+ // without a folder is the listing.
1658
+ browseFolder: (path) => commandLine(`${command}s`, [path.length === 0 ? "." : path, ...again]) ??
1659
+ `${command}s with this skill's folder, quoted for your shell. ${NO_LINE_TO_RUN}`,
1598
1660
  });
1599
1661
  say(jsonOfRead(session, pack, loaded), () => loaded.text);
1600
1662
  return EXIT.ok;
@@ -2496,6 +2558,9 @@ const task = async (args, io) => {
2496
2558
  if (args[0] === "restore") {
2497
2559
  return taskRestore(args.slice(1), io);
2498
2560
  }
2561
+ if (args[0] === "follow" || args[0] === "mute") {
2562
+ return following(args[0] === "follow")(args.slice(1), io);
2563
+ }
2499
2564
  const { values, positionals } = parse(args, {});
2500
2565
  const ref = theOne(positionals, "Say which task: console task <number|id>");
2501
2566
  const session = await open(io, values);
@@ -2645,12 +2710,12 @@ const notify = async (args, io) => {
2645
2710
  ...(ownAgents === undefined ? {} : { ownAgents }),
2646
2711
  })));
2647
2712
  };
2648
- // Whether one task tells a member anything (ADR-0157): `follow` turns its notifications on,
2649
- // `mute` off. A task turned on that their settings would be silent of tells them of
2713
+ // Whether one task tells a member anything (ADR-0157): `task follow` turns its notifications
2714
+ // on, `task mute` off. A task turned on that their settings would be silent of tells them of
2650
2715
  // everything on it; one turned to what their settings say already is told by their kinds.
2651
2716
  const following = (turned) => async (args, io) => {
2652
2717
  const { values, positionals } = parse(args, {});
2653
- const ref = theOne(positionals, `Say which task: console ${turned ? "follow" : "mute"} <number|id>`);
2718
+ const ref = theOne(positionals, `Say which task: console task ${turned ? "follow" : "mute"} <number|id>`);
2654
2719
  const session = await open(io, values);
2655
2720
  const project = await session.project();
2656
2721
  const found = await project.task(ref);
@@ -3169,11 +3234,29 @@ const docs = async (args, io) => {
3169
3234
  answer(io, session, found, () => formatDocuments(found));
3170
3235
  return EXIT.ok;
3171
3236
  };
3237
+ /** What a read of one page takes beside its path. */
3238
+ const DOC_READ_FLAGS = {
3239
+ version: { type: "string" },
3240
+ versions: { type: "boolean" },
3241
+ };
3242
+ /** Whether the words are a read of one page: one path, and no flag but a read's own. */
3243
+ function readsOnePage(args) {
3244
+ try {
3245
+ return parse(args, DOC_READ_FLAGS).positionals.length === 1;
3246
+ }
3247
+ catch {
3248
+ return false;
3249
+ }
3250
+ }
3172
3251
  const doc = async (args, io) => {
3173
- const { values, positionals } = parse(args, {
3174
- version: { type: "string" },
3175
- versions: { type: "boolean" },
3176
- });
3252
+ // A page may be called by a form's word, `write`, and is read as any page is (ADR-0167):
3253
+ // the word is the form wherever more follows it than a read of one page takes, a path or a
3254
+ // flag of the form's own, before the path as after it.
3255
+ const form = held(DOC_FORMS, args[0]);
3256
+ if (form !== undefined && !readsOnePage(args)) {
3257
+ return form(args.slice(1), io);
3258
+ }
3259
+ const { values, positionals } = parse(args, DOC_READ_FLAGS);
3177
3260
  const path = theOne(positionals, "Say which page: console doc <path> [--version <n>|--versions]");
3178
3261
  const session = await open(io, values);
3179
3262
  const project = await session.project();
@@ -3203,7 +3286,7 @@ const write = async (args, io) => {
3203
3286
  file: { type: "string" },
3204
3287
  base: { type: "string" },
3205
3288
  });
3206
- const path = theOne(positionals, 'Say which page: console write <path> --title "<title>" --body <markdown>|--file <path>');
3289
+ const path = theOne(positionals, 'Say which page: console doc write <path> --title "<title>" --body <markdown>|--file <path>');
3207
3290
  const body = await bodyOf(io, values, text(values, "body"));
3208
3291
  if (body === undefined) {
3209
3292
  throw misuse("Say what the page is to say: --body <markdown>, --file <path>, or --body - to read standard input.");
@@ -3243,7 +3326,7 @@ const attach = async (args, io) => {
3243
3326
  const { values, positionals } = parse(args, { label: { type: "string" } });
3244
3327
  const [path, file] = positionals;
3245
3328
  if (path === undefined || file === undefined || positionals.length > 2) {
3246
- throw misuse("Say the page and the file: console attach <path> <file> [--label <words>]");
3329
+ throw misuse("Say the page and the file: console doc attach <path> <file> [--label <words>]");
3247
3330
  }
3248
3331
  const label = text(values, "label");
3249
3332
  const session = await open(io, values);
@@ -3268,7 +3351,7 @@ const attach = async (args, io) => {
3268
3351
  };
3269
3352
  const archive = async (args, io) => {
3270
3353
  const { values, positionals } = parse(args, {});
3271
- const path = theOne(positionals, "Say which page: console archive <path>");
3354
+ const path = theOne(positionals, "Say which page: console doc archive <path>");
3272
3355
  const session = await open(io, values);
3273
3356
  const project = await session.project();
3274
3357
  const put = await project.archiveDocument(path);
@@ -3277,13 +3360,15 @@ const archive = async (args, io) => {
3277
3360
  };
3278
3361
  const restore = async (args, io) => {
3279
3362
  const { values, positionals } = parse(args, {});
3280
- const path = theOne(positionals, "Say which page: console restore <path>");
3363
+ const path = theOne(positionals, "Say which page: console doc restore <path>");
3281
3364
  const session = await open(io, values);
3282
3365
  const project = await session.project();
3283
3366
  const back = await project.restoreDocument(path);
3284
3367
  answer(io, session, back, () => `Restored ${back.path} (${back.title}).`);
3285
3368
  return EXIT.ok;
3286
3369
  };
3370
+ /** The forms of `console doc` that change a page, by the word that picks each. */
3371
+ const DOC_FORMS = { write, attach, archive, restore };
3287
3372
  const goals = async (args, io) => {
3288
3373
  const { values } = parse(args, {
3289
3374
  category: { type: "string" },
@@ -3626,65 +3711,6 @@ const serve = async (args, io) => {
3626
3711
  await listening.closed;
3627
3712
  return EXIT.ok;
3628
3713
  };
3629
- /** What the runner keeps between its own restarts, as its file says it; nothing for a file that does not read. */
3630
- function runnerStateOf(text) {
3631
- if (text === undefined) {
3632
- return undefined;
3633
- }
3634
- let json;
3635
- try {
3636
- json = JSON.parse(text);
3637
- }
3638
- catch {
3639
- return undefined;
3640
- }
3641
- if (typeof json !== "object" || json === null) {
3642
- return undefined;
3643
- }
3644
- const delivered = "delivered" in json ? json.delivered : undefined;
3645
- const conversation = "conversation" in json ? json.conversation : undefined;
3646
- const driver = "driver" in json ? json.driver : undefined;
3647
- const limited = "limited" in json ? json.limited : undefined;
3648
- const kept = "kept" in json ? json.kept : undefined;
3649
- if (typeof delivered !== "number" || !Number.isSafeInteger(delivered) || delivered < 0) {
3650
- return undefined;
3651
- }
3652
- /**
3653
- * A moment in milliseconds since the epoch, or nothing for anything else: a number past what
3654
- * a date holds would fail the runner at every start, where it says the moment in words.
3655
- */
3656
- const momentOf = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value < 1e14
3657
- ? value
3658
- : undefined;
3659
- const since = typeof limited === "object" && limited !== null && "since" in limited
3660
- ? momentOf(limited.since)
3661
- : undefined;
3662
- return {
3663
- delivered,
3664
- conversation: typeof conversation === "string" && conversation.length > 0 && conversation.length <= 200
3665
- ? conversation
3666
- : undefined,
3667
- // The driver the conversation was begun under, as a registry spells one.
3668
- driver: typeof driver === "string" && /^[a-z][a-z0-9-]{0,39}$/.test(driver) ? driver : undefined,
3669
- // The usage limit the agent is not back from (ADR-0150): since when, and until when where the product said.
3670
- ...(since === undefined || typeof limited !== "object" || limited === null
3671
- ? {}
3672
- : {
3673
- limited: {
3674
- since,
3675
- until: "until" in limited ? momentOf(limited.until) : undefined,
3676
- },
3677
- }),
3678
- // The signals the record has as delivered that the agent never read: taken from the stream once more.
3679
- ...(Array.isArray(kept)
3680
- ? {
3681
- kept: kept
3682
- .filter((number) => momentOf(number) !== undefined)
3683
- .slice(0, 50),
3684
- }
3685
- : {}),
3686
- };
3687
- }
3688
3714
  /** A line a runner says of its machine, within what the console takes one in. */
3689
3715
  const machineLine = (text) => {
3690
3716
  const line = [...text]
@@ -3800,6 +3826,8 @@ const runner = async (args, io) => {
3800
3826
  });
3801
3827
  }
3802
3828
  const statePath = workPath("runner-state.json");
3829
+ // A wake source is named as a registry spells one, which is a file's name as it stands.
3830
+ const keptPath = (source) => workPath(`runner-kept-${source.replaceAll(/[^a-z0-9-]/g, "_")}.json`);
3803
3831
  const person = me.person;
3804
3832
  /** A runner for the desk's runner.json as it is read now: begun again whenever the file changed (ADR-0144). */
3805
3833
  const runnerOf = (read) => {
@@ -3834,6 +3862,8 @@ const runner = async (args, io) => {
3834
3862
  now: io.now,
3835
3863
  random: host.random,
3836
3864
  time: (iso) => clock.format(new Date(iso)),
3865
+ // What a wake source shows of the agent at its messenger is in the workspace's language (ADR-0170).
3866
+ language: me.workspace.language ?? undefined,
3837
3867
  // A moment that may be on another day, a stretch the runner did not run in or when a
3838
3868
  // usage limit resets, is said as the command prints any moment: with its day, in the
3839
3869
  // workspace's zone where the login kept one.
@@ -3844,7 +3874,7 @@ const runner = async (args, io) => {
3844
3874
  },
3845
3875
  state: {
3846
3876
  load: async () => runnerStateOf(await host.readText(statePath)),
3847
- save: (state) => host.writePrivate(statePath, `${JSON.stringify(state)}\n`),
3877
+ save: (state) => host.replacePrivate(statePath, `${JSON.stringify(state)}\n`),
3848
3878
  },
3849
3879
  log: (line) => io.stdout(`${new Date(io.now()).toISOString()} ${line}\n`),
3850
3880
  // The autosave's git: in the desk, asking nobody at a terminal, its words read and let go.
@@ -3873,6 +3903,12 @@ const runner = async (args, io) => {
3873
3903
  }),
3874
3904
  fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
3875
3905
  socket: (url) => host.socket(url),
3906
+ // What a source keeps of what it brought the agent, ids and moments and never a word,
3907
+ // in a file of its own beside the runner's state: a runner started again reads it.
3908
+ kept: {
3909
+ load: async (source) => keptBySourceOf(await host.readText(keptPath(source))),
3910
+ save: (source, kept) => host.replacePrivate(keptPath(source), keptFileOf(kept)),
3911
+ },
3876
3912
  },
3877
3913
  });
3878
3914
  };
@@ -3959,7 +3995,7 @@ const agents = async (args, io) => {
3959
3995
  : found.items.map(formatAgentLine).join("\n"));
3960
3996
  return EXIT.ok;
3961
3997
  };
3962
- const AGENT_USAGE = 'Say what to do: console agent <handle> [--avatar <file>] | console agent new <handle> [--login <login>] [--project <key>] [--name "<name>"] [--title "<title>"] [--manager <login|me>] [--host gh|google] [--seed <seed>] [--convert]';
3998
+ const AGENT_USAGE = "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 ...";
3963
3999
  // An administrator makes an agent account with flags, where the pages make one from a form
3964
4000
  // (ADR-0084): the member's row at once, its login let in. What is left out is proposed: the
3965
4001
  // name is the handle's, capitalized, and the console rolls the avatar from the seed, or from one
@@ -4064,11 +4100,20 @@ const SECRET_FLAGS = {
4064
4100
  file: { type: "string" },
4065
4101
  expires: { type: "string" },
4066
4102
  };
4103
+ /** What ends the listing of the offers that wait: the two things the account does with one. */
4104
+ const OFFERED_NEXT = "Take one into your store: console secret --accept <offer id> [--as <name>] [--replace] | leave one: console secret --decline <offer id>";
4067
4105
  // An agent account's own secret store (ADR-0087): the names it keeps, for the account itself,
4068
- // signed in as itself.
4106
+ // signed in as itself; and, with --offered, what members offered it that waits (ADR-0169).
4069
4107
  const secrets = async (args, io) => {
4070
- const { values } = parse(args, {}, false);
4108
+ const { values } = parse(args, { offered: { type: "boolean" } }, false);
4071
4109
  const session = await open(io, values);
4110
+ if (on(values, "offered")) {
4111
+ const offered = await session.client.secretOffers();
4112
+ answer(io, session, offered, () => offered.items.length === 0
4113
+ ? "No offered secret waits for you."
4114
+ : [...offered.items.map((item) => formatSecretOffer(item)), OFFERED_NEXT].join("\n"));
4115
+ return EXIT.ok;
4116
+ }
4072
4117
  const found = await session.client.secrets();
4073
4118
  answer(io, session, found, () => found.items.length === 0
4074
4119
  ? "No secret is kept yet: console secret <name> --set keeps one."
@@ -4076,9 +4121,59 @@ const secrets = async (args, io) => {
4076
4121
  return EXIT.ok;
4077
4122
  };
4078
4123
  const SECRET_USAGE = "Say which secret: console secret <name> | secret <name> --set [--file <path>] [--expires <day|none>] | secret <name> --remove";
4124
+ const OFFER_USAGE = "Say which offer, by its id as console secrets --offered lists it: console secret --accept <offer id> [--as <name>] [--replace] | secret --decline <offer id>";
4125
+ /**
4126
+ * An offer the account takes into its store or leaves (ADR-0169): named by its id, since the
4127
+ * name an offerer proposed is theirs to choose and two may propose the same.
4128
+ */
4129
+ async function offeredSecret(io, values, positionals) {
4130
+ const taking = on(values, "accept");
4131
+ if ((taking && on(values, "decline")) || on(values, "set") || on(values, "remove")) {
4132
+ throw misuse("Say one of --accept, --decline, --set and --remove.");
4133
+ }
4134
+ const as = text(values, "as");
4135
+ if (!taking && (as !== undefined || on(values, "replace"))) {
4136
+ throw misuse("--as and --replace go with --accept: an offer that is left is kept under no name.");
4137
+ }
4138
+ const id = theOne(positionals, OFFER_USAGE);
4139
+ const session = await open(io, values);
4140
+ if (!taking) {
4141
+ await session.client.leaveSecretOffer(id);
4142
+ answer(io, session, { left: id }, () => `The offer ${id} is left, and its value is gone.`);
4143
+ return EXIT.ok;
4144
+ }
4145
+ let kept;
4146
+ try {
4147
+ kept = await session.client.takeSecretOffer(id, {
4148
+ ...(as === undefined ? {} : { as }),
4149
+ ...(on(values, "replace") ? { replace: true } : {}),
4150
+ });
4151
+ }
4152
+ catch (error) {
4153
+ if (error instanceof ApiError && error.code === "secret.exists") {
4154
+ throw failed(`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.`);
4155
+ }
4156
+ throw error;
4157
+ }
4158
+ answer(io, session, kept, () => `Taken into your store: ${formatSecretLine(kept)}`);
4159
+ return EXIT.ok;
4160
+ }
4079
4161
  // One secret of the account's own: its value, read and noted; or set, typed unseen; or removed.
4162
+ // And one offered to it, taken or left.
4080
4163
  const secret = async (args, io) => {
4081
- const { values, positionals } = parse(args, SECRET_FLAGS);
4164
+ const { values, positionals } = parse(args, {
4165
+ ...SECRET_FLAGS,
4166
+ accept: { type: "boolean" },
4167
+ decline: { type: "boolean" },
4168
+ as: { type: "string" },
4169
+ replace: { type: "boolean" },
4170
+ });
4171
+ if (on(values, "accept") || on(values, "decline")) {
4172
+ return offeredSecret(io, values, positionals);
4173
+ }
4174
+ if (text(values, "as") !== undefined || on(values, "replace")) {
4175
+ throw misuse(`--as and --replace go with --accept. ${OFFER_USAGE}`);
4176
+ }
4082
4177
  const name = theOne(positionals, SECRET_USAGE);
4083
4178
  const session = await open(io, values);
4084
4179
  if (on(values, "remove")) {
@@ -4106,9 +4201,18 @@ const secret = async (args, io) => {
4106
4201
  // A supervisor's part of an agent account's store (ADR-0087): the names; a secret seeded,
4107
4202
  // write-only, which only the account reads back; one removed. Never a value.
4108
4203
  const agentSecrets = async (args, io) => {
4109
- const { values, positionals } = parse(args, {});
4110
- const handle = handleOf(theOne(positionals, "Say whose: console agent secrets <handle>"));
4204
+ const { values, positionals } = parse(args, { offered: { type: "boolean" } });
4205
+ const handle = handleOf(theOne(positionals, "Say whose: console agent secrets <handle> [--offered]"));
4111
4206
  const session = await open(io, values);
4207
+ if (on(values, "offered")) {
4208
+ // What the account was offered (ADR-0169): its record whole for a supervisor, and for any
4209
+ // other member what they offered it themselves.
4210
+ const offered = await session.client.agentSecretOffers(handle);
4211
+ answer(io, session, offered, () => offered.items.length === 0
4212
+ ? `Nothing was offered to @${handle} that is yours to read.`
4213
+ : offered.items.map((item) => formatSecretOffer(item)).join("\n"));
4214
+ return EXIT.ok;
4215
+ }
4112
4216
  let found;
4113
4217
  try {
4114
4218
  found = await session.client.agentSecrets(handle);
@@ -4130,10 +4234,39 @@ const agentSecrets = async (args, io) => {
4130
4234
  return EXIT.ok;
4131
4235
  };
4132
4236
  const agentSecret = async (args, io) => {
4133
- const { values, positionals } = parse(args, SECRET_FLAGS);
4134
- const [given, name] = theTwo(positionals, "Say whose and which: console agent secret <handle> <name> [--file <path>] [--expires <day|none>] | agent secret <handle> <name> --remove");
4237
+ const { values, positionals } = parse(args, {
4238
+ ...SECRET_FLAGS,
4239
+ offer: { type: "boolean" },
4240
+ note: { type: "string" },
4241
+ });
4242
+ const [given, name] = theTwo(positionals, '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');
4135
4243
  const handle = handleOf(given);
4244
+ const offering = on(values, "offer");
4245
+ const said = text(values, "note")?.trim();
4246
+ if (offering && on(values, "remove")) {
4247
+ throw misuse("Say one of --offer and --remove.");
4248
+ }
4249
+ if (said !== undefined && !offering) {
4250
+ throw misuse("--note says what an offered secret is for, and goes with --offer.");
4251
+ }
4136
4252
  const session = await open(io, values);
4253
+ if (offering) {
4254
+ // Any member's (ADR-0169): the value waits, sealed, for the account to take or leave, and
4255
+ // nothing of what the account keeps changes.
4256
+ const expiresOn = expiryOf(io, values);
4257
+ const value = await secretValue(io, values, `Value of ${name} to offer @${handle} (typed unseen; Enter ends it): `);
4258
+ const offered = await session.client.offerAgentSecret(handle, {
4259
+ name,
4260
+ value,
4261
+ ...(said === undefined || said === "" ? {} : { note: said }),
4262
+ ...(expiresOn === undefined ? {} : { expiresOn }),
4263
+ });
4264
+ answer(io, session, offered, () => [
4265
+ `Offered to @${handle}, which is told and takes it into its store or leaves it: ${formatSecretOffer(offered)}`,
4266
+ `Nothing @${handle} keeps changed, and nobody is answered the value. How it stands: console agent secrets ${handle} --offered`,
4267
+ ].join("\n"));
4268
+ return EXIT.ok;
4269
+ }
4137
4270
  if (on(values, "remove")) {
4138
4271
  await session.client.removeAgentSecret(handle, name);
4139
4272
  answer(io, session, { handle, removed: name }, () => `The secret ${name} of @${handle} is removed.`);
@@ -4142,10 +4275,20 @@ const agentSecret = async (args, io) => {
4142
4275
  const expiresOn = expiryOf(io, values);
4143
4276
  const value = await secretValue(io, values, `Value of ${name} for @${handle} (typed unseen; Enter ends it): `);
4144
4277
  const host = await gitHostFor(session.client, name);
4145
- const kept = await session.client.seedAgentSecret(handle, name, {
4146
- value,
4147
- ...(expiresOn === undefined ? {} : { expiresOn }),
4148
- });
4278
+ let kept;
4279
+ try {
4280
+ kept = await session.client.seedAgentSecret(handle, name, {
4281
+ value,
4282
+ ...(expiresOn === undefined ? {} : { expiresOn }),
4283
+ });
4284
+ }
4285
+ catch (error) {
4286
+ // Whoever supervises the account not is told what is theirs to do in its place.
4287
+ if (error instanceof ApiError && error.code === "auth.forbidden") {
4288
+ throw failed(`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>".`);
4289
+ }
4290
+ throw error;
4291
+ }
4149
4292
  const notes = secretNotes(name, value, host);
4150
4293
  answer(io, session, kept, () => [`Seeded for @${handle}, which alone reads it back: ${formatSecretLine(kept)}`, ...notes].join("\n"));
4151
4294
  return EXIT.ok;
@@ -4289,36 +4432,32 @@ const WORDED_SIGNALS = {
4289
4432
  reset: { needs: false },
4290
4433
  wake: { needs: false },
4291
4434
  };
4435
+ /**
4436
+ * Whether the words after `agent wake` or `agent reset` are the account's own form: `me` where
4437
+ * the handle stands, wherever that is among the form's flags. Read without refusing a word, so
4438
+ * that a mistake among them is answered by the form that was typed, and not by the other's.
4439
+ */
4440
+ function isOwnForm(args, flags) {
4441
+ const { positionals } = parseArgs({
4442
+ args: [...args],
4443
+ options: { ...GLOBAL_OPTIONS, ...flags },
4444
+ allowPositionals: true,
4445
+ strict: false,
4446
+ });
4447
+ return positionals[0] === "me";
4448
+ }
4292
4449
  // A supervisor's signal to an agent account (ADR-0085): a tell, an interruption, a stop, a start
4293
4450
  // with the same conversation or with a new one, a wake; in their own name, on the account's
4294
4451
  // record. What it says is given as words, or with --file, or on standard input as `-`.
4295
4452
  const agentSignal = async (kind, args, io) => {
4296
4453
  // An account's own wake is another command under the same word: console agent wake me,
4297
4454
  // wherever `me` stands among its flags.
4298
- if (kind === "wake") {
4299
- let whom;
4300
- try {
4301
- whom = parse(args, OWN_WAKE_FLAGS).positionals[0];
4302
- }
4303
- catch {
4304
- whom = undefined;
4305
- }
4306
- if (whom === "me") {
4307
- return ownWake(args, io);
4308
- }
4455
+ if (kind === "wake" && isOwnForm(args, OWN_WAKE_FLAGS)) {
4456
+ return ownWake(args, io);
4309
4457
  }
4310
4458
  // And so is its own reset: console agent reset me.
4311
- if (kind === "reset") {
4312
- let whom;
4313
- try {
4314
- whom = parse(args, { file: { type: "string" } }).positionals[0];
4315
- }
4316
- catch {
4317
- whom = undefined;
4318
- }
4319
- if (whom === "me") {
4320
- return ownReset(args, io);
4321
- }
4459
+ if (kind === "reset" && isOwnForm(args, { file: { type: "string" } })) {
4460
+ return ownReset(args, io);
4322
4461
  }
4323
4462
  const { values, positionals } = parse(args, { file: { type: "string" } });
4324
4463
  const [given, words, ...rest] = positionals;
@@ -4410,6 +4549,67 @@ const agentSignals = async (args, io) => {
4410
4549
  ].join("\n"));
4411
4550
  return EXIT.ok;
4412
4551
  };
4552
+ const AGENT_MESSAGES_USAGE = "Say where, as a wake's header names it after messenger: console agent messages <source>:<conversation>[:<thread>] [--limit <n>] [--after <moment>]";
4553
+ // What was said where a wake from the messenger was raised (ADR-0163): the latest messages of the
4554
+ // conversation, or of the thread, that the wake's key names, read by the wake source the key
4555
+ // begins with, with a secret of the account's own store, which nobody else reads. For the
4556
+ // account itself, where a wake carried less than the agent needs, and before it answers where
4557
+ // others may have answered meanwhile. What a source's line says is printed as it is, and what
4558
+ // someone wrote behind `>`, a line each, so that no word of a message reads as a line.
4559
+ const agentMessages = async (args, io) => {
4560
+ const { values, positionals } = parse(args, {
4561
+ limit: { type: "string" },
4562
+ after: { type: "string" },
4563
+ });
4564
+ const key = theOne(positionals, AGENT_MESSAGES_USAGE);
4565
+ const named = /^([a-z][a-z0-9-]{0,39}):(.+)$/.exec(key);
4566
+ const source = named?.[1] === undefined ? undefined : ownRunnerModules({ user: "" }).wakeSources.get(named[1]);
4567
+ if (named?.[2] === undefined || source?.read === undefined) {
4568
+ throw misuse(`No wake source of this command reads ${key.includes(":") ? `what ${key.slice(0, key.indexOf(":"))} names` : "that"}. ${AGENT_MESSAGES_USAGE}`);
4569
+ }
4570
+ const limit = text(values, "limit");
4571
+ if (limit !== undefined && !(Number.isSafeInteger(Number(limit)) && Number(limit) >= 1)) {
4572
+ throw misuse(`Not a number of messages: ${limit}`);
4573
+ }
4574
+ const after = text(values, "after");
4575
+ const session = await open(io, values);
4576
+ const read = await source.read({
4577
+ // A secret the account does not keep is none, and the source says what it lacks.
4578
+ secret: async (name) => {
4579
+ try {
4580
+ return (await session.client.secret(name)).value;
4581
+ }
4582
+ catch (error) {
4583
+ if (error instanceof ApiError && error.code === "secret.not_found") {
4584
+ return undefined;
4585
+ }
4586
+ throw error;
4587
+ }
4588
+ },
4589
+ fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
4590
+ // Who wrote each message, as the console says it (ADR-0164): where it says nothing, a
4591
+ // console older than the question say, the lines are as the messenger alone has them.
4592
+ writers: async (accounts, signal) => (await session.client.writers({ messenger: named[1] ?? "", accounts: [...accounts] }, signal)).items,
4593
+ }, named[2], {
4594
+ ...(limit === undefined ? {} : { limit: Number(limit) }),
4595
+ ...(after === undefined ? {} : { after }),
4596
+ now: io.now(),
4597
+ signal: AbortSignal.timeout(30_000),
4598
+ });
4599
+ if (!read.ok) {
4600
+ throw failed(read.why === "no_token"
4601
+ ? `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.`
4602
+ : read.why === "not_a_conversation"
4603
+ ? `Nothing was read: ${named[2]} names no conversation as a wake of the ${named[1]} wake source does (not_a_conversation). ${AGENT_MESSAGES_USAGE}`
4604
+ : read.why === "not_a_moment"
4605
+ ? `Nothing was read: ${after} is the moment of no message, as a wake of the ${named[1]} wake source says one (not_a_moment).`
4606
+ : `Nothing was read: the messenger did not answer the ${named[1]} wake source with the conversation (${read.why}).`);
4607
+ }
4608
+ answer(io, session, { key, parts: read.parts }, () => read.parts
4609
+ .map((part) => ("says" in part ? part.says : quotedLines(part.words).join("\n")))
4610
+ .join("\n"));
4611
+ return EXIT.ok;
4612
+ };
4413
4613
  // The invitation that leads a machine to an agent account (ADR-0088): made, made again in place
4414
4614
  // of the one before, or taken away, by a supervisor. Its code is no credential: it says which
4415
4615
  // account a setup is for and opens the guide, and the account is entered through its own sign-in.
@@ -5022,7 +5222,7 @@ const DESK_USAGE = "Say at most one directory: console desk [<directory>] [--web
5022
5222
  function deskNext(web, skillsDir) {
5023
5223
  return [
5024
5224
  `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`,
5025
- `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 ? " (console skills says where it is)" : `: ${ownSkillPath(skillsDir, "keeping-a-desk")}`}`,
5225
+ `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")}`}`,
5026
5226
  ];
5027
5227
  }
5028
5228
  /** The files of the shell of a desk's pages as they are written: the two words the template leaves filled in. */
@@ -5211,6 +5411,9 @@ const agent = async (args, io) => {
5211
5411
  if (args[0] === "signals") {
5212
5412
  return agentSignals(args.slice(1), io);
5213
5413
  }
5414
+ if (args[0] === "messages") {
5415
+ return agentMessages(args.slice(1), io);
5416
+ }
5214
5417
  if (args[0] === "invite") {
5215
5418
  return agentInvite(args.slice(1), io);
5216
5419
  }
@@ -5894,22 +6097,50 @@ const COMMANDS = {
5894
6097
  run,
5895
6098
  docs,
5896
6099
  doc,
6100
+ // The words of before (COMMAND_ALIASES, ADR-0167): they run as they did, and no list names them.
5897
6101
  write,
5898
6102
  attach,
5899
6103
  archive,
5900
6104
  restore,
5901
6105
  };
5902
- function help(io, name) {
5903
- if (name === undefined) {
6106
+ /** The words the dispatch takes: what a test holds to the pages of help and to the words of before. */
6107
+ export const COMMAND_WORDS = Object.keys(COMMANDS);
6108
+ /** What a word that is no command is answered with: the nearest there are, and where all are listed. */
6109
+ function notCommand(word, near = nearestCommands(word)) {
6110
+ return misuse(`Not a command: ${word}.${near.length === 0 ? "" : ` Nearest: ${near.join(", ")}.`} console help lists the commands.`);
6111
+ }
6112
+ /**
6113
+ * The help the words ask for (ADR-0167): the table of the commands for none, else the page of
6114
+ * a command, or of one of its forms. Flags among the words are left unread.
6115
+ */
6116
+ function help(io, words) {
6117
+ const named = words.filter((word) => !word.startsWith("-"));
6118
+ // Help asked of help is the table too.
6119
+ if (named.length === 0 || (named.length === 1 && named[0] === "help")) {
5904
6120
  io.stdout(usage(io.version, io.skillsDir));
5905
6121
  return EXIT.ok;
5906
6122
  }
5907
- const found = helpFor(name, io.skillsDir);
5908
- if (found === undefined) {
5909
- throw misuse(`Not a command: ${name}. The commands: ${Object.keys(COMMAND_HELP).join(", ")}`);
6123
+ const found = helpFor(named, io.skillsDir);
6124
+ if ("page" in found) {
6125
+ io.stdout(found.page);
6126
+ return EXIT.ok;
5910
6127
  }
5911
- io.stdout(found);
5912
- return EXIT.ok;
6128
+ if ("notCommand" in found) {
6129
+ throw notCommand(found.notCommand, found.near);
6130
+ }
6131
+ throw misuse(`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.`);
6132
+ }
6133
+ /**
6134
+ * The line after a command that was not understood (ADR-0167): where its forms and flags are,
6135
+ * the page of the form that was tried where it has one. Nothing where the words say it already.
6136
+ */
6137
+ function helpPointer(name, rest, said) {
6138
+ if (said.includes("console help")) {
6139
+ return "";
6140
+ }
6141
+ const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
6142
+ const form = aliased ?? formTyped(command, rest);
6143
+ return `Its forms and flags: console help ${command}${form === undefined ? "" : ` ${form}`}\n`;
5913
6144
  }
5914
6145
  /**
5915
6146
  * A client of the console at `url`, naming the command on every request (ADR-0025). A redirect
@@ -6009,11 +6240,11 @@ function hintFor(error, io, seen) {
6009
6240
  case "project.not_found":
6010
6241
  return "No project has this key, or it is not yours to see. console projects lists the projects you may work in.\n";
6011
6242
  case "document.not_found":
6012
- return "No page has this path, in this project. console docs lists the pages of a folder; console write <path> writes one.\n";
6243
+ return "No page has this path, in this project. console docs lists the pages of a folder; console doc write <path> writes one.\n";
6013
6244
  case "document.conflict":
6014
6245
  return "The page has moved on since the version you started from. Read it again, and write from there.\n";
6015
6246
  case "document.archived":
6016
- return "The page is archived. console restore <path> brings it back first.\n";
6247
+ return "The page is archived. console doc restore <path> brings it back first.\n";
6017
6248
  case "task.invalid_category":
6018
6249
  return "No category has that key. console categories lists them.\n";
6019
6250
  case "task.invalid_goal":
@@ -6106,14 +6337,18 @@ export async function runCli(argv, io) {
6106
6337
  return EXIT.ok;
6107
6338
  }
6108
6339
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
6109
- return help(io, rest[0]);
6340
+ return help(io, rest);
6110
6341
  }
6111
6342
  if (rest.includes("--help") || rest.includes("-h")) {
6112
- return help(io, name);
6343
+ // The page of the form that was being typed, where it has one.
6344
+ const [command, aliased] = held(COMMAND_ALIASES, name) ?? [name, undefined];
6345
+ const form = aliased ??
6346
+ formTyped(command, rest.filter((word) => word !== "--help" && word !== "-h"));
6347
+ return help(io, form === undefined ? [command] : [command, form]);
6113
6348
  }
6114
- const command = COMMANDS[name];
6349
+ const command = held(COMMANDS, name);
6115
6350
  if (command === undefined) {
6116
- throw misuse(`Not a command: ${name}. Run: console help`);
6351
+ throw notCommand(name);
6117
6352
  }
6118
6353
  const exit = await command(rest, watched);
6119
6354
  if (name !== "whoami") {
@@ -6123,7 +6358,11 @@ export async function runCli(argv, io) {
6123
6358
  }
6124
6359
  catch (error) {
6125
6360
  if (error instanceof CliExit) {
6126
- io.stderr(`${error.message}\n`);
6361
+ // A command that was not understood says where its forms and flags are, in a line.
6362
+ const pointer = error.exit === EXIT.usage && name !== undefined && held(COMMANDS, name) !== undefined
6363
+ ? helpPointer(name, rest, error.message)
6364
+ : "";
6365
+ io.stderr(`${error.message}\n${pointer}`);
6127
6366
  return error.exit;
6128
6367
  }
6129
6368
  if (error instanceof UnseenProject) {