@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
@@ -1,4 +1,5 @@
1
1
  import type { AgentStateReason, TranscriptKind } from "../vocabulary.js";
2
+ import type { WakePart } from "../wake-text.js";
2
3
 
3
4
  // What the runner's modules are to one another (ADR-0085, docs/specs/runner.md): a driver speaks
4
5
  // to one product, a wake source raises wakes from outside the console, a service keeps the
@@ -39,8 +40,13 @@ export type DriverEvent =
39
40
  readonly effort: string | null;
40
41
  readonly version: string | null;
41
42
  }
42
- /** The id the product resumes the conversation from next time. */
43
- | { readonly type: "conversation"; readonly id: string }
43
+ /**
44
+ * The id the product resumes the conversation from next time. With `anew`, the product was
45
+ * asked to go on with a conversation and began this one in its place, since it kept the other
46
+ * no more or goes on with none (ADR-0166): the runner then takes the agent's conversation to
47
+ * have begun with the session, which holds nothing it was handed before.
48
+ */
49
+ | { readonly type: "conversation"; readonly id: string; readonly anew?: boolean | undefined }
44
50
  /**
45
51
  * The product took a message: the oldest it was sent and had not said so of. Said once for
46
52
  * every message sent, when the product reads it, so that a message handed over in a turn is
@@ -49,6 +55,23 @@ export type DriverEvent =
49
55
  | { readonly type: "taken" }
50
56
  /** A turn completed: the agent is done with what it was sent, and waits for more. */
51
57
  | { readonly type: "turn_completed" }
58
+ /**
59
+ * The product put the conversation so far in fewer words of its own, as one does whose
60
+ * conversation grew long (ADR-0166): what the agent was handed before, it holds as a summary
61
+ * at best. Said by a driver whose product says so, and never by another.
62
+ */
63
+ | { readonly type: "compacted" }
64
+ /**
65
+ * How many sub-agents are at work in the background of the session, as the product lists
66
+ * them (ADR-0162): said as that changes, from the first that is. A driver whose product lists
67
+ * none says it never, and its sessions are waited for by their turns alone.
68
+ */
69
+ | { readonly type: "background"; readonly agents: number }
70
+ /**
71
+ * The product began a turn, one it starts by itself to hand the agent what a sub-agent in
72
+ * the background did among them. Said once a sub-agent was said to be at work there.
73
+ */
74
+ | { readonly type: "turn_started" }
52
75
  /**
53
76
  * The agent cannot go on: the model refused, or the product failed; with why, in the
54
77
  * heartbeat's words. For a usage limit (`usage_limit`), `until` is when the product says the
@@ -224,6 +247,15 @@ export interface Driver {
224
247
  readonly resume: boolean;
225
248
  /** Whether the model and the effort are taken in a running session. */
226
249
  readonly set: boolean;
250
+ /**
251
+ * Whether a message the driver said was taken stands in the product's conversation from
252
+ * then on, whatever became of the turn: the driver says `taken` when the product says the
253
+ * message back out of its conversation, or began a turn with it. Where it does, what the
254
+ * product took as a usage limit was reached is named to the agent in the same session and
255
+ * not said a second time (ADR-0166). Left out, or false, for a driver that says `taken` when
256
+ * it handed the message over: the runner then says such a message whole again.
257
+ */
258
+ readonly holdsTaken?: boolean | undefined;
227
259
  };
228
260
  /**
229
261
  * The product's permission modes, in its own words: what runs without asking. `unattended` is
@@ -276,6 +308,54 @@ export interface WakeSocket {
276
308
  close(): void;
277
309
  }
278
310
 
311
+ // A part of a wake a source raises (ADR-0163): declared with how the parts are written as a
312
+ // signal's text, which the console writes too.
313
+ export type { WakePart } from "../wake-text.js";
314
+
315
+ /**
316
+ * A wake as a wake source raises one: `parts` where the source says something itself, who wrote
317
+ * and where say, beside what was written; `text` where all of it is someone else's words.
318
+ */
319
+ export type RaisedWake =
320
+ | { readonly key: string; readonly parts: readonly WakePart[] }
321
+ | { readonly key: string; readonly text: string };
322
+
323
+ /**
324
+ * What a source read of where one of its wakes was raised, for the account's own command
325
+ * (`console agent messages`): the parts to print, as a wake carries them, or why it read
326
+ * nothing, in a short name: `no_token` where the account keeps nothing to read with,
327
+ * `not_a_conversation` and `not_a_moment` where what was named is none, and otherwise the
328
+ * messenger's own word.
329
+ */
330
+ export type WakeRead =
331
+ | { readonly ok: true; readonly parts: readonly WakePart[] }
332
+ | { readonly ok: false; readonly why: string };
333
+
334
+ /** An account at a source's messenger, as a message names whoever wrote it: by the messenger's ids for the workspace and the account. */
335
+ export interface WakeAccount {
336
+ readonly workspace: string;
337
+ readonly account: string;
338
+ }
339
+
340
+ /**
341
+ * Who an account at a messenger is to the agent, as the console says it (ADR-0164): `told` where
342
+ * the console is told the accounts of that workspace at all, and the member the account is, by
343
+ * their login, with what kind of member they are and whether they supervise the agent; `null`
344
+ * for an account that is no member's as far as the console is told. `administrator` and `line`
345
+ * say how: an administrator, and where in the agent's reporting line the member stands, its
346
+ * `manager`, anyone further `above`, a `report` of its own or anyone further `below`.
347
+ */
348
+ export interface WakeWriter extends WakeAccount {
349
+ readonly told: boolean;
350
+ readonly member: {
351
+ readonly login: string | null;
352
+ readonly kind: "person" | "agent";
353
+ readonly supervisor: boolean;
354
+ readonly administrator?: boolean | undefined;
355
+ readonly line?: "manager" | "above" | "report" | "below" | null | undefined;
356
+ } | null;
357
+ }
358
+
279
359
  /** What a wake source is given of the runner and of the machine. */
280
360
  export interface WakeHost {
281
361
  /** A secret of the account's store, by name; nothing where it keeps none. */
@@ -285,8 +365,28 @@ export interface WakeHost {
285
365
  * they are of: what a person says in one wakes the agent, named or not.
286
366
  */
287
367
  readonly channels: readonly string[];
288
- /** Raises a wake: the console records it, and it reaches the agent in order, as someone else's words. */
289
- raise(wake: { readonly key: string; readonly text: string }): Promise<void>;
368
+ /**
369
+ * Raises a wake: the console records it, and it reaches the agent in order, the source's own
370
+ * lines under the session's mark and everything else as someone else's words. Answers
371
+ * whether the console took it: a wake raised past what the console takes within an hour is
372
+ * let go, and reaches nobody.
373
+ */
374
+ raise(wake: RaisedWake): Promise<boolean>;
375
+ /**
376
+ * What the source keeps from one run of its own to the next, under names of its own, and from
377
+ * one runner to the one started after it where the machine keeps it (ADR-0166): the ids and
378
+ * the moments of what it brought the agent. Never a secret, and never a word of a message.
379
+ */
380
+ readonly kept: Map<string, string>;
381
+ /**
382
+ * When the conversation the agent goes on with began, in milliseconds since the epoch
383
+ * (ADR-0166): at a reset, with a new day where the desk says so, in a session whose product
384
+ * goes on with none, and when the product put it in fewer words. What the agent was handed
385
+ * before that moment its conversation holds no more, so a source counts nothing from before
386
+ * it as brought. 0 where nothing says when; left out by a host that says nothing of it, which
387
+ * a source reads as 0.
388
+ */
389
+ began?(): number;
290
390
  /** A line for whoever reads the runner's own output: never what a message says. */
291
391
  log(line: string): void;
292
392
  /**
@@ -294,17 +394,70 @@ export interface WakeHost {
294
394
  * yet, with why in a few words of the source's own. Never what a message says.
295
395
  */
296
396
  stands(state: "connected" | "waiting", why?: string): void;
397
+ /**
398
+ * Asks an address of the source's messenger. `body` is what a call that writes sends, as its
399
+ * text. Of the answer, what it says as JSON, and beside it the status of the answer and its
400
+ * headers where the host has them: a messenger that asks to be left alone for a while says so
401
+ * there.
402
+ */
297
403
  fetch(
298
404
  url: string,
299
405
  init: {
300
406
  readonly method: string;
301
407
  readonly headers: Readonly<Record<string, string>>;
408
+ readonly body?: string | undefined;
302
409
  readonly signal: AbortSignal;
303
410
  },
304
- ): Promise<{ json(): Promise<unknown> }>;
411
+ ): Promise<{
412
+ json(): Promise<unknown>;
413
+ readonly status?: number | undefined;
414
+ readonly headers?: { get(name: string): string | null } | undefined;
415
+ }>;
305
416
  socket(url: string): WakeSocket;
306
417
  /** Waits so long, or less where the signal ends the wait. */
307
418
  wait(ms: number, signal: AbortSignal): Promise<void>;
419
+ /**
420
+ * Who accounts at the source's messenger are, as the console knows them (ADR-0164), in the
421
+ * order asked: the one way a source learns that an account is a member's, or a supervisor's.
422
+ * It is the console's answer to the account's own sign-in, and nothing a message, a name or
423
+ * the messenger says stands in for it. Left out, or rejecting, where the console says nothing
424
+ * of it, one older than this say: the source then says of an account what the messenger does.
425
+ */
426
+ writers?(accounts: readonly WakeAccount[], signal: AbortSignal): Promise<readonly WakeWriter[]>;
427
+ }
428
+
429
+ /**
430
+ * How an agent stands to whoever waits for it where a wake source listens (ADR-0170), as the
431
+ * runner says it and the source shows it where it can:
432
+ *
433
+ * - `idle`: nothing to show. With `last`, the runner ends and says nothing after it: what the
434
+ * source showed is taken back now or not at all;
435
+ * - `thinking`: what that source raised reached the runner, and the turn it began is under way;
436
+ * - `working`: the agent has been at work for longer than `runner.json` gives a turn before it
437
+ * is said, whatever woke it, sub-agents in its background among it;
438
+ * - `limited`: the usage limit of its product stopped it, until the moment `until` where the
439
+ * product said one, in milliseconds since the epoch.
440
+ */
441
+ export type AgentStatus =
442
+ | { readonly state: "idle"; readonly last?: boolean | undefined }
443
+ | { readonly state: "thinking" }
444
+ | { readonly state: "working" }
445
+ | { readonly state: "limited"; readonly until?: number | undefined };
446
+
447
+ /**
448
+ * What `runner.json` says of how each of them is shown, under `status`: an emoji by its name
449
+ * and a line of words, each the source's own where the desk says none. `back` is what the
450
+ * words of `limited` go on with where the moment is known, `{time}` in it standing for the
451
+ * moment.
452
+ */
453
+ export interface StatusWords {
454
+ readonly thinking?: StatusLook | undefined;
455
+ readonly working?: StatusLook | undefined;
456
+ readonly limited?: (StatusLook & { readonly back?: string | undefined }) | undefined;
457
+ }
458
+ export interface StatusLook {
459
+ readonly emoji?: string | undefined;
460
+ readonly text?: string | undefined;
308
461
  }
309
462
 
310
463
  /** A module that raises wakes from outside the console. `console`, the console's own stream of signals, is the runner's own. */
@@ -315,6 +468,48 @@ export interface WakeSource {
315
468
  * source that ended is started again by the runner, after a while. `console` has none.
316
469
  */
317
470
  run?(host: WakeHost, signal: AbortSignal): Promise<void>;
471
+ /**
472
+ * Reads the latest of what was said where a wake of the source's was raised, named as the
473
+ * wake's key names it after the source's own name: for the account's own command, where a wake
474
+ * carried less than the agent needs. Left out by a source that reads nothing.
475
+ */
476
+ read?(
477
+ host: Pick<WakeHost, "secret" | "fetch" | "writers">,
478
+ where: string,
479
+ options: {
480
+ /** How many of the latest messages are asked for, held to the source's own bounds; its own number where none is said. */
481
+ readonly limit?: number | undefined;
482
+ /** The moment of a message, as the messenger spells one: what was written after it alone is read. */
483
+ readonly after?: string | undefined;
484
+ /** The moment the read is asked at, in milliseconds since the epoch: how long ago a message was written is said by it. */
485
+ readonly now: number;
486
+ readonly signal: AbortSignal;
487
+ },
488
+ ): Promise<WakeRead>;
489
+ /**
490
+ * Shows how the agent stands, where the source's messenger has a place for it (ADR-0170): the
491
+ * runner decides which, and the source how. Said when it changes, and again every half
492
+ * minute while it stands, so that a source keeps what it shows from lapsing and tries again
493
+ * what failed; with the host the source runs with, the same one every time. It never rejects
494
+ * for what the messenger answered, and what it cannot show costs the agent nothing: said
495
+ * once, in the runner's lines. Left out by a source that shows nothing.
496
+ */
497
+ show?(
498
+ host: Pick<WakeHost, "secret" | "fetch" | "wait" | "log" | "kept">,
499
+ status: AgentStatus,
500
+ options: {
501
+ /** What `runner.json` says of the emoji and the words. */
502
+ readonly words: StatusWords;
503
+ /** The language of the workspace, where the runner knows it: the source's own words are in it where it has them. */
504
+ readonly language?: string | undefined;
505
+ /** The moment, in milliseconds since the epoch. */
506
+ now(): number;
507
+ /** A moment as people read one, in the workspace's zone: the hour and the minute, with the day where it is not within the day to come. */
508
+ time(at: number): string;
509
+ /** Ends when the runner does, and with the last thing said a few seconds after it. */
510
+ readonly signal: AbortSignal;
511
+ },
512
+ ): Promise<void>;
318
513
  }
319
514
 
320
515
  /** What a service is told of the runner it keeps running. */
@@ -210,8 +210,13 @@ export function limitWords(
210
210
  options: {
211
211
  readonly now: number;
212
212
  readonly moment: (iso: string) => string;
213
- /** How many signals follow in the message. */
213
+ /** How many signals follow in the message, said whole. */
214
214
  readonly follow: number;
215
+ /**
216
+ * How many more the message only names (ADR-0166): what the product took in this
217
+ * conversation as the limit was reached and the agent never answered, which stands above.
218
+ */
219
+ readonly above?: number | undefined;
215
220
  /** Whether this is a supervisor's signal tried before the runner's own try, with what else is kept left for then. */
216
221
  readonly early?: boolean | undefined;
217
222
  },
@@ -224,11 +229,19 @@ export function limitWords(
224
229
  : limited.until === undefined
225
230
  ? `The product did not say when the limit resets, so the runner tries now, ${at(options.now)}, by itself.`
226
231
  : `The limit reset ${at(limited.until)}, and the runner brings you back by itself.`;
232
+ const above = options.above ?? 0;
233
+ // What the conversation holds is not said twice: it is named, and the agent reads it above.
234
+ const unanswered =
235
+ above === 0
236
+ ? ""
237
+ : `What you were handed as the limit was reached and had not answered stands above in this conversation: it is named below by its ${above === 1 ? "number" : "numbers"}, and not said again. `;
227
238
  const meanwhile = early
228
239
  ? "The message follows; what else reached you meanwhile is kept, and handed to you then."
229
240
  : options.follow === 0
230
- ? "Nothing reached you meanwhile."
231
- : "What reached you meanwhile follows, in the order it came, what you were handed as the limit was reached and had not read among it.";
241
+ ? `${unanswered}Nothing ${above === 0 ? "" : "else "}reached you meanwhile.`
242
+ : above === 0
243
+ ? "What reached you meanwhile follows, in the order it came, what you were handed as the limit was reached and had not read among it."
244
+ : `${unanswered}What reached you since follows, in the order it came.`;
232
245
  return `${stopped} ${now} Go on with what you were doing: look at what each sub-agent left before you start it again. ${meanwhile}`;
233
246
  }
234
247
 
package/src/runner.ts CHANGED
@@ -35,6 +35,8 @@ export {
35
35
  MAX_GROUP_LENGTH,
36
36
  MAX_GROUP_SIGNALS,
37
37
  makeMark,
38
+ wakePartsOf,
39
+ wakeTextOf,
38
40
  } from "./runner/message.js";
39
41
  export { ownRunnerModules } from "./runner/modules.js";
40
42
  export { createSpawn } from "./runner/process.js";
@@ -61,14 +63,23 @@ export {
61
63
  createRunner,
62
64
  HEARTBEAT_MS,
63
65
  HOLD_MS,
66
+ type KeptBySource,
64
67
  MAX_COOL_DOWN_MS,
65
68
  MAX_HOLD_MS,
69
+ REPORT_MS,
66
70
  type Runner,
67
71
  type RunnerClient,
68
72
  type RunnerOptions,
69
73
  type RunnerState,
74
+ SUBAGENTS_MS,
70
75
  } from "./runner/runner.js";
71
- export { SLACK_APP_TOKEN, slack, slackWakeOf } from "./runner/slack.js";
76
+ export {
77
+ SLACK_APP_TOKEN,
78
+ SLACK_USER_TOKEN,
79
+ type SlackWake,
80
+ slack,
81
+ slackWakeOf,
82
+ } from "./runner/slack.js";
72
83
  export { SYSTEMD_UNIT, systemdUnit, systemdUser } from "./runner/systemd-user.js";
73
84
  export {
74
85
  KEPT_LOGS,
@@ -81,6 +92,7 @@ export {
81
92
  taskScript,
82
93
  } from "./runner/task-scheduler.js";
83
94
  export type {
95
+ AgentStatus,
84
96
  Boundary,
85
97
  Child,
86
98
  Cut,
@@ -91,15 +103,22 @@ export type {
91
103
  Fact,
92
104
  Picture,
93
105
  Probe,
106
+ RaisedWake,
94
107
  Service,
95
108
  ServiceCommand,
96
109
  ServiceInput,
97
110
  ServicePlan,
98
111
  Spawn,
99
112
  StartOptions,
113
+ StatusLook,
114
+ StatusWords,
115
+ WakeAccount,
100
116
  WakeHost,
117
+ WakePart,
118
+ WakeRead,
101
119
  WakeSocket,
102
120
  WakeSource,
121
+ WakeWriter,
103
122
  } from "./runner/types.js";
104
123
  export {
105
124
  errorsShown,
package/src/schemas.ts CHANGED
@@ -52,6 +52,7 @@ import {
52
52
  MAX_RUNNER_USAGE_WINDOWS,
53
53
  MAX_SEAL_REASON_LENGTH,
54
54
  MAX_SECRET_LENGTH,
55
+ MAX_SECRET_OFFER_NOTE_LENGTH,
55
56
  MAX_SERVICE_PARAMETERS,
56
57
  MAX_SERVICE_VALUE_LENGTH,
57
58
  MAX_SIGNAL_KEY_LENGTH,
@@ -105,6 +106,7 @@ import {
105
106
  RUN_ENDINGS,
106
107
  RUN_STATUSES,
107
108
  SECRET_ACCESSES,
109
+ SECRET_OFFER_STATES,
108
110
  SERVICE_ROLES,
109
111
  SESSION_ENDS,
110
112
  SESSION_KINDS,
@@ -138,8 +140,22 @@ const paragraphs = (maxLength: number) =>
138
140
  /** A body in Markdown. */
139
141
  const body = paragraphs(MAX_BODY_LENGTH);
140
142
 
143
+ /**
144
+ * An address of the web someone sent, of the schemes named: trimmed, bounded, and with nothing
145
+ * in it that hides. A control character is run by the terminal a link is printed in, and an
146
+ * invisible one makes an address read as another, so neither is taken, a tab and a line break
147
+ * among them, which an address has no use for.
148
+ */
149
+ const link = (protocol: RegExp) =>
150
+ z.string().check(
151
+ z.trim(),
152
+ z.maxLength(MAX_URL_LENGTH),
153
+ z.refine((value) => !hasForbiddenCodePoint(value), "must not contain control characters"),
154
+ z.url({ protocol }),
155
+ );
156
+
141
157
  /** A link a person adds to a task: the web, over https, and nothing that runs. */
142
- const url = z.string().check(z.trim(), z.maxLength(MAX_URL_LENGTH), z.url({ protocol: /^https$/ }));
158
+ const url = link(/^https$/);
143
159
 
144
160
  const uuid = z.uuid();
145
161
  /** An ISO 8601 instant, as the server writes it. */
@@ -889,6 +905,13 @@ export const restRunnerHeartbeatInputSchema = z.object({
889
905
  * out by a runner of before, and empty where the product has said nothing.
890
906
  */
891
907
  usage: z.optional(z.array(runnerUsageWindow).check(z.maxLength(MAX_RUNNER_USAGE_WINDOWS))),
908
+ /**
909
+ * When the runner said the reason, by its machine's clock: a reason changes under a state
910
+ * that stays, a turn completes or a new conversation begins while the agent runs on, and is
911
+ * said again the same, so the console cannot tell a turn that just completed from one that
912
+ * did an hour ago. Left out by a runner of before.
913
+ */
914
+ reasonAt: z.optional(instant),
892
915
  });
893
916
  export type RestRunnerHeartbeatInput = z.infer<typeof restRunnerHeartbeatInputSchema>;
894
917
 
@@ -921,6 +944,59 @@ export const restOwnWakeRaisedSchema = z.object({
921
944
  });
922
945
  export type RestOwnWakeRaised = z.infer<typeof restOwnWakeRaisedSchema>;
923
946
 
947
+ /** How many accounts at a messenger one asking names. */
948
+ export const MAX_WRITERS_ASKED = 100;
949
+ const messengerId = z.string().check(z.regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/), z.maxLength(64));
950
+
951
+ /**
952
+ * What `POST /api/v1/agents/me/writers` is sent, by an agent account for itself (ADR-0164):
953
+ * accounts at a messenger, each by the messenger's ids for its workspace and for itself, as a
954
+ * message there names whoever wrote it.
955
+ */
956
+ export const restWritersInputSchema = z.object({
957
+ messenger: z.string().check(z.regex(/^[a-z][a-z0-9-]{1,31}$/)),
958
+ accounts: z
959
+ .array(z.object({ workspace: messengerId, account: messengerId }))
960
+ .check(z.minLength(1), z.maxLength(MAX_WRITERS_ASKED)),
961
+ });
962
+ export type RestWritersInput = z.infer<typeof restWritersInputSchema>;
963
+
964
+ /**
965
+ * Who an account at a messenger is to the agent account that asks (ADR-0164). `told` is whether
966
+ * the console is told the accounts of that workspace at all, by a plugin that is enabled and
967
+ * holds `people:accounts`: where it is not, nothing is known there, and `member` is `null` for
968
+ * every account. `member` is the active member whose account it is, by their login, `null` for
969
+ * one the account that asks may not see (ADR-0035), with what kind of member they are and
970
+ * whether they supervise the account; `null` itself for an account that is no member's as far as
971
+ * the console is told.
972
+ *
973
+ * `supervisor` is the whole of ADR-0084, point 5: an administrator, or anyone above the asker
974
+ * in the reporting line, its manager and every level above. `administrator` and `line` say
975
+ * which, and the other way too: `line` is where the member stands in the asker's line,
976
+ * `manager` whom it reports to, `above` anyone further up, `report` whoever reports to it,
977
+ * `below` anyone further down, `null` nowhere in it. An administrator may stand anywhere in
978
+ * the line, below the asker too, and supervises it all the same.
979
+ */
980
+ export const restWriterSchema = z.object({
981
+ workspace: z.string(),
982
+ account: z.string(),
983
+ told: z.boolean(),
984
+ member: z.nullable(
985
+ z.object({
986
+ login: z.nullable(z.string()),
987
+ kind: z.enum(PERSON_KINDS),
988
+ supervisor: z.boolean(),
989
+ administrator: z.boolean(),
990
+ line: z.nullable(z.enum(["manager", "above", "report", "below"])),
991
+ }),
992
+ ),
993
+ });
994
+ export type RestWriter = z.infer<typeof restWriterSchema>;
995
+
996
+ /** What `POST /api/v1/agents/me/writers` answers: the accounts asked of, in the order asked. */
997
+ export const restWritersSchema = z.object({ items: z.array(restWriterSchema) });
998
+ export type RestWriters = z.infer<typeof restWritersSchema>;
999
+
924
1000
  /** `GET /api/v1/agents/<handle>/wakes`: the wakes the account keeps for later, the soonest first. */
925
1001
  export const restOwnWakesSchema = z.object({ items: z.array(restOwnWakeSchema) });
926
1002
  export type RestOwnWakes = z.infer<typeof restOwnWakesSchema>;
@@ -951,7 +1027,14 @@ export type RestRunnerHeartbeat = z.infer<typeof restRunnerHeartbeatSchema>;
951
1027
  export const restAgentStateSchema = z.object({
952
1028
  state: z.enum(AGENT_STATES),
953
1029
  reason: z.nullable(z.string()),
1030
+ /** Since when the state stands: not when the reason was said, which changes under a state that stays. */
954
1031
  since: instant,
1032
+ /**
1033
+ * When the reason was said: the same moment as `since` where the two came together, a later
1034
+ * one where the reason changed under the state. Left out by a console of before, and `null`
1035
+ * where the console keeps no moment for it: the reason is then shown with none.
1036
+ */
1037
+ reasonAt: z.optional(z.nullable(instant)),
955
1038
  heardAt: z.nullable(instant),
956
1039
  /**
957
1040
  * Until when it stands so, where its runner said (ADR-0150): when a usage limit resets.
@@ -1371,6 +1454,65 @@ export const restAgentSecretAccessesSchema = z.object({
1371
1454
  });
1372
1455
  export type RestAgentSecretAccesses = z.infer<typeof restAgentSecretAccessesSchema>;
1373
1456
 
1457
+ /**
1458
+ * What `POST /api/v1/agents/<handle>/secret-offers` is sent (ADR-0169): the name the offerer
1459
+ * proposes, the value, up to `MAX_AGENT_SECRET_BYTES` of UTF-8, what it is for in a line, and
1460
+ * optionally the day the value ends on.
1461
+ */
1462
+ export const restAgentSecretOfferInputSchema = z.object({
1463
+ name: z.string().check(z.refine(isSecretName)),
1464
+ value: z.string().check(z.minLength(1), z.maxLength(MAX_AGENT_SECRET_BYTES)),
1465
+ note: z.optional(z.nullable(line(MAX_SECRET_OFFER_NOTE_LENGTH))),
1466
+ expiresOn: z.optional(z.nullable(day)),
1467
+ });
1468
+ export type RestAgentSecretOfferInput = z.infer<typeof restAgentSecretOfferInputSchema>;
1469
+
1470
+ /**
1471
+ * A secret offered to an agent account (ADR-0169), as its listing says it: never its value. The
1472
+ * name the offerer proposed, what they said it is for, who offered it and through which agent,
1473
+ * how it stands, until when it waits, and, once the account took it, the name it keeps it under.
1474
+ */
1475
+ export const restAgentSecretOfferSchema = z.object({
1476
+ id: uuid,
1477
+ name: z.string(),
1478
+ note: z.nullable(z.string()),
1479
+ /** Who offered it; `null` for someone who is no longer there. */
1480
+ by: z.nullable(restPersonSchema),
1481
+ /** The agent they offered it through, when they acted with a token; `null` when they did it themselves. */
1482
+ agent: z.nullable(z.string()),
1483
+ expiresOn: z.nullable(day),
1484
+ state: z.enum(SECRET_OFFER_STATES),
1485
+ at: instant,
1486
+ /** Until when it waits: past it, the offer is gone as one left is. */
1487
+ endsAt: instant,
1488
+ /** When the account took or left it, or its days ran out; `null` while it waits. */
1489
+ decidedAt: z.nullable(instant),
1490
+ /** The name the account keeps it under, once taken; `null` otherwise. */
1491
+ takenAs: z.nullable(z.string()),
1492
+ });
1493
+ export type RestAgentSecretOffer = z.infer<typeof restAgentSecretOfferSchema>;
1494
+
1495
+ /**
1496
+ * `GET /api/v1/agents/me/secret-offers`, the offers that wait for the account itself, and
1497
+ * `GET /api/v1/agents/<handle>/secret-offers`, the account's record of them for a supervisor,
1498
+ * the newest first.
1499
+ */
1500
+ export const restAgentSecretOffersSchema = z.object({
1501
+ items: z.array(restAgentSecretOfferSchema),
1502
+ });
1503
+ export type RestAgentSecretOffers = z.infer<typeof restAgentSecretOffersSchema>;
1504
+
1505
+ /**
1506
+ * What `POST /api/v1/agents/me/secret-offers/<id>/take` is sent: the name to keep the value
1507
+ * under, where another than the one offered, and whether it takes the place of a secret the
1508
+ * account keeps under that name already.
1509
+ */
1510
+ export const restAgentSecretOfferTakeInputSchema = z.object({
1511
+ as: z.optional(z.string().check(z.refine(isSecretName))),
1512
+ replace: z.optional(z.boolean()),
1513
+ });
1514
+ export type RestAgentSecretOfferTakeInput = z.infer<typeof restAgentSecretOfferTakeInputSchema>;
1515
+
1374
1516
  /**
1375
1517
  * `GET /api/v1/me/manager`: whom whoever asks reports to, a person or an agent account, `null`
1376
1518
  * for nobody; and the administrators of the workspace, who stand in where there is nobody, or
@@ -1786,6 +1928,8 @@ export const restTaskSchema = z.object({
1786
1928
  /** What happened: when the task was first moved past ready, and when it was moved to done; each or `null`. The board keeps both. */
1787
1929
  startedAt: z.nullable(instant),
1788
1930
  doneAt: z.nullable(instant),
1931
+ /** When the last of its runs to end ended, or `null` where none has (ADR-0159). Left out by an older console. */
1932
+ lastRunEndedAt: z.optional(z.nullable(instant)),
1789
1933
  /** When the task was put away (ADR-0029): out of the listings, the board and the calendar, open by its number; `null` while current. */
1790
1934
  archivedAt: z.nullable(instant),
1791
1935
  links: z.array(restTaskLinkSchema),
@@ -2268,6 +2412,15 @@ export const restEventDataSchema = z.object({
2268
2412
  team: z.optional(z.string()),
2269
2413
  /** For `person.email_changed`: whether the person has an address now; never the address itself. */
2270
2414
  set: z.optional(z.boolean()),
2415
+ /**
2416
+ * For a `person.updated` whose `fields` are `account` (ADR-0164), which says that a plugin
2417
+ * said an account at a messenger is the member's (`set`) or is theirs no longer: the messenger
2418
+ * by its name, the workspace there and the account, by the ids the messenger gives them; the
2419
+ * member is `login`, and the plugin that said it the event's own `plugin`.
2420
+ */
2421
+ messenger: z.optional(z.string()),
2422
+ workspace: z.optional(z.string()),
2423
+ account: z.optional(z.string()),
2271
2424
  /** For `person.updated` of an agent account and for `agent.state_changed`: the account's handle. */
2272
2425
  handle: z.optional(z.string()),
2273
2426
  /**
@@ -3102,9 +3255,14 @@ export const restCommentInputSchema = z.object({
3102
3255
  });
3103
3256
  export type RestCommentInput = z.infer<typeof restCommentInputSchema>;
3104
3257
 
3105
- /** What `POST .../runs/<id>/artifacts` is sent: a link to what was made. */
3258
+ /**
3259
+ * What `POST .../runs/<id>/artifacts` is sent: a link to what was made. Over https; over plain
3260
+ * http the console takes an address of its own alone, which a console on one machine is served
3261
+ * at (`http://127.0.0.1:11199`), and refuses any other, so the schema lets both schemes through
3262
+ * and the console says which.
3263
+ */
3106
3264
  export const restArtifactInputSchema = z.object({
3107
- url,
3265
+ url: link(/^https?$/),
3108
3266
  label: z.optional(line(MAX_LINK_LABEL_LENGTH)),
3109
3267
  });
3110
3268
  export type RestArtifactInput = z.infer<typeof restArtifactInputSchema>;
package/src/vocabulary.ts CHANGED
@@ -231,6 +231,15 @@ export const SECRET_ACCESSES = ["set", "read", "removed"] as const;
231
231
 
232
232
  export type SecretAccess = (typeof SECRET_ACCESSES)[number];
233
233
 
234
+ /**
235
+ * How a secret offered to an agent account stands (ADR-0169): it waits for the account; the
236
+ * account took it into its store; the account left it; or its days ran out. Only one that waits
237
+ * holds a value.
238
+ */
239
+ export const SECRET_OFFER_STATES = ["waiting", "taken", "left", "lapsed"] as const;
240
+
241
+ export type SecretOfferState = (typeof SECRET_OFFER_STATES)[number];
242
+
234
243
  /**
235
244
  * How an agent account stands, in one word (ADR-0085): `running`, its runner heard from and the
236
245
  * agent at work or ready for it; `stopped`, by a supervisor, until one starts it again; `refused`,