@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,6 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { memo, useCallback, useEffect, useMemo, useRef, useState, } from "react";
3
- import { MAX_FILE_BYTES, MAX_SIGNAL_ATTACHMENTS, MAX_SIGNAL_LENGTH, usageNear, usageSaidTogether, usedHundredths, } from "../api.js";
3
+ import { reasonMoment } from "../agent-state.js";
4
+ import { isSecretName, MAX_AGENT_SECRET_NAME_LENGTH, MAX_FILE_BYTES, MAX_SECRET_OFFER_NOTE_LENGTH, MAX_SIGNAL_ATTACHMENTS, MAX_SIGNAL_LENGTH, SECRET_OFFER_DAYS, usageNear, usageSaidTogether, usedHundredths, } from "../api.js";
4
5
  import { today } from "../dates.js";
5
6
  import { useWords } from "../i18n/index.js";
6
7
  import { isPicture } from "./files.js";
@@ -53,7 +54,11 @@ export function AgentUsage(props) {
53
54
  : undefined, note: resets === false && apart === false ? undefined : (_jsxs(_Fragment, { children: [resets, resets !== false && apart !== false && " · ", apart] })) }, place));
54
55
  }), props.said === true && together !== undefined && (_jsx("span", { className: "sc-progress-words", children: said(together) }))] }));
55
56
  }
56
- /** The state of an agent account as a badge: the word, and why and since when where there is room. */
57
+ /**
58
+ * The state of an agent account as a badge: the word, and where there is room since when it
59
+ * stands so, right after the word it is the moment of, then why, with when that was said where
60
+ * it is another moment than the state's.
61
+ */
57
62
  export function AgentStateBadge(props) {
58
63
  const words = useWords().agents.page.state;
59
64
  const state = props.state ?? null;
@@ -64,11 +69,12 @@ export function AgentStateBadge(props) {
64
69
  }
65
70
  const reasons = words.reasons;
66
71
  const reason = state.reason === null ? undefined : (reasons[state.reason] ?? state.reason);
72
+ const said = reasonMoment(state);
67
73
  const badge = (_jsx(Badge, { tone: STATE_TONES[state.state], kind: "state", live: state.state === "running", title: reason, children: words[state.state] }));
68
74
  if (props.full !== true) {
69
75
  return badge;
70
76
  }
71
- return (_jsxs("span", { className: "sc-agent-state", children: [badge, _jsxs("span", { className: "sc-note", children: [reason !== undefined && `${reason} · `, words.since.before, _jsx(Time, { iso: state.since, precision: "clock" }), words.since.after, state.until !== undefined && state.until !== null && (_jsxs(_Fragment, { children: [" · ", words.until.before, _jsx(Time, { iso: state.until, precision: "clock" }), words.until.after] })), state.heardAt !== null && (_jsxs(_Fragment, { children: [" · ", words.heard, " ", _jsx(Time, { iso: state.heardAt, precision: "clock" })] }))] })] }));
77
+ return (_jsxs("span", { className: "sc-agent-state", children: [badge, _jsxs("span", { className: "sc-note", children: [words.since.before, _jsx(Time, { iso: state.since, precision: "clock" }), words.since.after, state.until !== undefined && state.until !== null && (_jsxs(_Fragment, { children: [" · ", words.until.before, _jsx(Time, { iso: state.until, precision: "clock" }), words.until.after] })), reason !== undefined && (_jsxs(_Fragment, { children: [" · ", reason, said !== undefined && (_jsxs(_Fragment, { children: [words.reasonAt.before, _jsx(Time, { iso: said, precision: "clock" }), words.reasonAt.after] }))] })), state.heardAt !== null && (_jsxs(_Fragment, { children: [" · ", words.heard, " ", _jsx(Time, { iso: state.heardAt, precision: "clock" })] }))] })] }));
72
78
  }
73
79
  /** What a runner says of an event that is said apart from the rest: the tool it names. */
74
80
  const TOOL = "tool";
@@ -101,6 +107,21 @@ const idOf = (event) => {
101
107
  const endsTurn = (event) => event.kind === "status" &&
102
108
  event.sealed === null &&
103
109
  (event.data.turn === "completed" || typeof event.data.ended === "string");
110
+ /** Whether an event is a sub-agent's word that it ended: a runner writes how under `over` (ADR-0161). */
111
+ const saysOver = (event) => event.kind === "status" && typeof event.data.over === "string";
112
+ /**
113
+ * The kinds of event by which a sub-agent that ended is at work again: what it says, thinks and
114
+ * calls, and its own word that it was started again. A tool's answer is none: a product that
115
+ * stops a sub-agent in the middle of a call says first that it ended, and then what became of
116
+ * the call.
117
+ */
118
+ const AT_WORK = new Set(["assistant", "thinking", "tool_call", "status"]);
119
+ /**
120
+ * Whether a call was answered with the word that its sub-agent goes on in the background
121
+ * (`background` on its answer, ADR-0161): the answer is then not the sub-agent's, which goes on
122
+ * past it, and past the turn it was started in.
123
+ */
124
+ const goesOn = (item) => item.result?.data.background === true;
104
125
  /**
105
126
  * The events of a session as the things a person reads, in order. A tool's call, what it
106
127
  * answered and what was asked before it ran are one thing, joined by the id the product gave
@@ -112,7 +133,9 @@ const endsTurn = (event) => event.kind === "status" &&
112
133
  * not a thing of the line the call stands in. A call that says it starts a sub-agent (`starts`)
113
134
  * has such a line from the first, empty; one a runner of before wrote has it from the first
114
135
  * event that names it. An event that names a call the events do not hold stays where it stood.
115
- * A turn or a session that ended ends every sub-agent still open in it.
136
+ * A turn or a session that ended ends every sub-agent still open in it, but for one that goes on
137
+ * in the background (ADR-0161): its own line says when it ended, and nothing but its session's
138
+ * end ends it before.
116
139
  */
117
140
  export function talkOf(events) {
118
141
  const top = [];
@@ -122,7 +145,7 @@ export function talkOf(events) {
122
145
  const calls = new Map();
123
146
  /** The line of each sub-agent, by the id of the call that started it. */
124
147
  const lines = new Map();
125
- /** The calls that started a sub-agent and were not answered, as far as the events read say. */
148
+ /** The calls that started a sub-agent that nothing ended yet, as far as the events read say. */
126
149
  let running = [];
127
150
  const toolAt = (place) => {
128
151
  const item = place === undefined ? undefined : place.line[place.at];
@@ -169,6 +192,13 @@ export function talkOf(events) {
169
192
  const parent = parentOf(event);
170
193
  const starter = parent === undefined ? undefined : calls.get(parent);
171
194
  const line = parent === undefined || starter === undefined ? top : lineOf(parent, starter);
195
+ // What a sub-agent's own line says of its end stands until the sub-agent does something
196
+ // after it, as one that was started again does: then it is at work again.
197
+ const begun = toolAt(starter);
198
+ if (starter !== undefined && begun !== undefined && event.sealed === null) {
199
+ const over = saysOver(event) ? event : AT_WORK.has(event.kind) ? undefined : begun.over;
200
+ set(starter, { ...begun, over });
201
+ }
172
202
  // A sealed event says who sealed it and why, wherever it stood.
173
203
  if (event.sealed !== null) {
174
204
  line.push({ type: "note", event });
@@ -249,15 +279,25 @@ export function talkOf(events) {
249
279
  else {
250
280
  line.push({ type: "note", event });
251
281
  // Where the session's own line says a turn ended, or the session did, nothing started in
252
- // it goes on: a sub-agent that was not answered by then is ended there.
282
+ // it goes on: a sub-agent that was not answered by then is ended there. One that goes on
283
+ // in the background goes on past a turn's end, and is ended by its session's alone.
253
284
  if (parent === undefined && endsTurn(event)) {
285
+ const session = typeof event.data.ended === "string";
286
+ const still = [];
254
287
  for (const place of running) {
255
288
  const tool = toolAt(place);
256
- if (tool !== undefined && tool.result === undefined && tool.endedAt === undefined) {
289
+ if (tool === undefined) {
290
+ continue;
291
+ }
292
+ if (goesOn(tool) && !session) {
293
+ still.push(place);
294
+ }
295
+ else if ((goesOn(tool) ? tool.over === undefined : tool.result === undefined) &&
296
+ tool.endedAt === undefined) {
257
297
  set(place, { ...tool, endedAt: event.at });
258
298
  }
259
299
  }
260
- running = [];
300
+ running = still;
261
301
  }
262
302
  }
263
303
  }
@@ -297,6 +337,11 @@ function atOf(steps) {
297
337
  * otherwise, which only an open session's is (`live`); how long it ran, to its answer, to where
298
338
  * it was ended or to the last thing it did, and to `now` while it runs; how many tools it
299
339
  * called; and what it is at. Nothing for a thing that is no call that started a sub-agent.
340
+ *
341
+ * One that goes on in the background (ADR-0161) is not answered for by its call's answer, which
342
+ * says only that it was started: it stands by its own word that it ended, done, failed or
343
+ * stopped, is ended where its session ended first, and is at work otherwise, whatever turn
344
+ * ended meanwhile.
300
345
  */
301
346
  export function subAgentOf(item, input) {
302
347
  if (item.type !== "tool" || item.steps === undefined) {
@@ -311,22 +356,32 @@ export function subAgentOf(item, input) {
311
356
  const named = typeof said === "string" ? said : steps.map(firstOf).find(Boolean)?.data.subagent;
312
357
  const name = typeof named === "string" ? named.trim().slice(0, MAX_SUBAGENT_NAME) : "";
313
358
  const started = Date.parse(first.at);
314
- const answered = item.result === undefined ? Number.NaN : Date.parse(item.result.at);
359
+ // What the sub-agent answered: the call's answer, but for one that says the sub-agent goes on.
360
+ const answer = goesOn(item) ? undefined : item.result;
361
+ const how = item.over?.data.over;
315
362
  const cut = item.endedAt === undefined ? Number.NaN : Date.parse(item.endedAt);
316
- const state = item.result !== undefined
317
- ? item.result.data.error === true
363
+ const state = answer !== undefined
364
+ ? answer.data.error === true
318
365
  ? "failed"
319
366
  : "done"
320
- : item.endedAt !== undefined || refusedOf(item) || !input.live
321
- ? "ended"
322
- : "running";
367
+ : item.over !== undefined
368
+ ? how === "failed"
369
+ ? "failed"
370
+ : how === "stopped"
371
+ ? "ended"
372
+ : "done"
373
+ : item.endedAt !== undefined || refusedOf(item) || !input.live
374
+ ? "ended"
375
+ : "running";
323
376
  const until = state === "running"
324
377
  ? input.now
325
- : item.result !== undefined
326
- ? answered
327
- : item.endedAt !== undefined
328
- ? cut
329
- : Math.max(started, ...steps.flatMap(momentsOf));
378
+ : answer !== undefined
379
+ ? Date.parse(answer.at)
380
+ : item.over !== undefined
381
+ ? Date.parse(item.over.at)
382
+ : item.endedAt !== undefined
383
+ ? cut
384
+ : Math.max(started, ...steps.flatMap(momentsOf));
330
385
  const seconds = Math.floor((until - started) / 1000);
331
386
  return {
332
387
  n: first.n,
@@ -348,20 +403,32 @@ function subAgentsIn(items, input) {
348
403
  });
349
404
  }
350
405
  /**
351
- * The sub-agents at work in the turn under way, read off a session's events alone, in the order
352
- * they were started: those a call of this turn started that was not answered yet. None where the
353
- * session has no event, or its last turn is over.
406
+ * The sub-agents at work in an open session, read off its events alone, in the order they were
407
+ * started: those a call of the turn under way started that was not answered yet, and those that
408
+ * go on in the background, whatever turn started them, until each says it ended (ADR-0161).
409
+ * None where the session has no event; none but those in the background where its last turn is
410
+ * over.
354
411
  */
355
412
  export function atWorkOf(events, now) {
356
- let from = 0;
357
- for (let at = events.length - 1; at >= 0; at -= 1) {
358
- const event = events[at];
359
- if (event !== undefined && parentOf(event) === undefined && endsTurn(event)) {
360
- from = at + 1;
361
- break;
413
+ return subAgentsIn(talkOf(events), { now, live: true }).filter((one) => one.state === "running");
414
+ }
415
+ /**
416
+ * Whether the events read hold what a sub-agent did and not the call that started it: the call
417
+ * then stands before them, as it does once a sub-agent has worked for long, and what it did is
418
+ * read under it only once the events before are read too.
419
+ */
420
+ export function lacksStarter(events) {
421
+ const calls = new Set();
422
+ for (const event of events) {
423
+ const id = event.kind === "tool_call" ? idOf(event) : undefined;
424
+ if (id !== undefined) {
425
+ calls.add(id);
362
426
  }
363
427
  }
364
- return subAgentsIn(talkOf(events.slice(from)), { now, live: true }).filter((one) => one.state === "running");
428
+ return events.some((event) => {
429
+ const parent = parentOf(event);
430
+ return parent !== undefined && !calls.has(parent);
431
+ });
365
432
  }
366
433
  /**
367
434
  * Whether a turn is under way, and what the agent is at, read off a session's events alone:
@@ -585,7 +652,8 @@ function sameItem(a, b) {
585
652
  a.call === b.call &&
586
653
  a.result === b.result &&
587
654
  a.permission === b.permission &&
588
- a.endedAt === b.endedAt);
655
+ a.endedAt === b.endedAt &&
656
+ a.over === b.over);
589
657
  }
590
658
  return a.type === b.type && a.event === b.event;
591
659
  }
@@ -802,13 +870,15 @@ const TalkLine = memo(function Line(props) {
802
870
  return (_jsx("li", { className: "sc-talk-item sc-talk-turn", "data-n": event.n, children: _jsxs("span", { className: "sc-talk-note-line", children: [words.turnDone(Number.isFinite(seconds) ? seconds : undefined), when(event)] }) }));
803
871
  }
804
872
  // A wake, a status, an error, and whatever a newer runner calls otherwise: a note between.
805
- // What the note's own words say already, how a session ended, is not said twice as a fact.
873
+ // What the note's own words say already, how a session or a sub-agent ended, is not said
874
+ // twice as a fact.
806
875
  // The id of the call that started a sub-agent is for joining, and says nothing to a reader;
807
876
  // whose a note is, is not said again under the sub-agent that made it.
808
877
  const facts = Object.entries(event.data).filter(([name, fact]) => fact !== null &&
809
878
  name !== "signal" &&
810
879
  name !== "kind" &&
811
880
  name !== "ended" &&
881
+ name !== "over" &&
812
882
  name !== "parent" &&
813
883
  !(name === "subagent" && props.inside === true));
814
884
  const lines = event.text.split("\n").filter((line) => line.trim().length > 0);
@@ -909,17 +979,19 @@ export function TalkWaiting(props) {
909
979
  * The sign that the agent is at work while a turn is under way: its picture, three dots, and
910
980
  * what it is at, a thought, a tool by its name, or the work between. Where sub-agents run, it
911
981
  * says how many, with each under it: its name, what it is at, how many tools it called and how
912
- * long it has run, which the page counts by itself (ADR-0141). A row of the conversation's list;
913
- * nothing where no turn is under way.
982
+ * long it has run, which the page counts by itself (ADR-0141). Sub-agents that go on in the
983
+ * background are at work past the turn that started them (ADR-0161), and the sign stands for
984
+ * them alone then. A row of the conversation's list; nothing where no turn is under way and no
985
+ * sub-agent is at work.
914
986
  */
915
987
  export function TalkWorking(props) {
916
988
  const live = useWords().agents.page.live;
917
989
  const words = live.working;
918
990
  const { working } = props;
919
- if (working === undefined) {
991
+ const agents = props.agents ?? [];
992
+ if (working === undefined && agents.length === 0) {
920
993
  return null;
921
994
  }
922
- const agents = props.agents ?? [];
923
995
  return (_jsxs("li", { className: cx("sc-talk-item", "sc-talk-working", "sc-note", agents.length > 0 && "sc-talk-working-agents"), role: "status", children: [props.agent !== undefined && _jsx(Avatar, { person: props.agent, size: "sm" }), _jsxs("span", { className: "sc-talk-dots", "aria-hidden": "true", children: [_jsx("span", {}), _jsx("span", {}), _jsx("span", {})] }), _jsx("span", { children: agents.length > 0 ? words.agents(agents.length) : workingWord(words, working) }), agents.length > 0 && (_jsx("ul", { className: "sc-talk-agents", "aria-live": "off", children: agents.map((one) => (_jsxs("li", { className: "sc-talk-agents-row", children: [_jsx("span", { className: "sc-name sc-talk-agent-name", children: one.name.length === 0 ? live.agent.label : one.name }), _jsxs("span", { className: "sc-talk-agents-facts", children: [workingWord(words, one.at), " \u00B7 ", live.agent.calls(one.calls), " \u00B7", " ", _jsx(RunningFor, { since: one.startedAt })] })] }, one.n))) }))] }));
924
996
  }
925
997
  /**
@@ -1318,6 +1390,45 @@ export function AgentElsewhereList(props) {
1318
1390
  const held = Object.entries(props.accounts ?? {});
1319
1391
  return (_jsxs("div", { children: [held.length === 0 ? (_jsx("p", { className: "sc-field-hint", children: words.empty })) : (_jsx("dl", { className: "sc-person-facts sc-agent-runner-facts", "aria-label": words.title, children: held.map(([service, name]) => (_jsxs("div", { className: "sc-person-fact", children: [_jsx("dt", { children: service }), _jsx("dd", { children: name })] }, service))) })), _jsx("p", { className: "sc-field-hint", children: words.intro })] }));
1320
1392
  }
1393
+ /** What a secret offered to an account stands as, in the tone a badge says it in. */
1394
+ const OFFER_TONES = {
1395
+ waiting: "accent",
1396
+ taken: "success",
1397
+ left: "neutral",
1398
+ lapsed: "neutral",
1399
+ };
1400
+ /**
1401
+ * The secrets offered to an agent account (ADR-0169), a row each: the name proposed, who offers
1402
+ * it and when, and how the offer stands. Never a value.
1403
+ */
1404
+ export function AgentSecretOfferList(props) {
1405
+ const words = useWords().agents.page.offers;
1406
+ return (_jsx("ul", { className: "sc-divided sc-agent-secret-list", "aria-label": words.title, children: props.offers.map((offer) => (_jsxs("li", { className: "sc-small sc-agent-secret", children: [_jsx("code", { children: offer.name }), _jsxs("span", { className: "sc-muted", children: [offer.by === null ? words.someone : personName(offer.by), " · ", _jsx(Time, { iso: offer.at, precision: "day" }), offer.takenAs !== null && offer.takenAs !== offer.name && (_jsxs(_Fragment, { children: [" · ", words.takenAs(offer.takenAs)] }))] }), _jsx(Badge, { tone: OFFER_TONES[offer.state], kind: "state", children: words.state[offer.state] })] }, offer.id))) }));
1407
+ }
1408
+ /** The way a member offers an agent account a secret (ADR-0169): its name, its value, typed unseen, and what it is for. */
1409
+ export function AgentSecretOfferForm(props) {
1410
+ const words = useWords().agents.page.offers;
1411
+ const [name, setName] = useState("");
1412
+ const [value, setValue] = useState("");
1413
+ const [note, setNote] = useState("");
1414
+ const busy = props.busy === true;
1415
+ const ready = isSecretName(name.trim()) && value.length > 0;
1416
+ const submit = (event) => {
1417
+ event.preventDefault();
1418
+ if (!ready || busy) {
1419
+ return;
1420
+ }
1421
+ props.onOffer({
1422
+ name: name.trim(),
1423
+ value,
1424
+ note: note.trim().length === 0 ? undefined : note.trim(),
1425
+ });
1426
+ setName("");
1427
+ setValue("");
1428
+ setNote("");
1429
+ };
1430
+ return (_jsxs("form", { className: "sc-form", "aria-label": words.offerAria, onSubmit: submit, children: [_jsxs("div", { className: "sc-field-row", children: [_jsxs("label", { className: "sc-field", children: [_jsx("span", { className: "sc-field-label", children: words.name }), _jsx("input", { className: "sc-input", placeholder: words.namePlaceholder, value: name, maxLength: MAX_AGENT_SECRET_NAME_LENGTH, autoComplete: "off", spellCheck: false, "aria-invalid": name.trim() !== "" && !isSecretName(name.trim()), onChange: (event) => setName(event.target.value.toLowerCase()) })] }), _jsxs("label", { className: "sc-field", children: [_jsx("span", { className: "sc-field-label", children: words.value }), _jsx("input", { className: "sc-input", type: "password", value: value, autoComplete: "new-password", onChange: (event) => setValue(event.target.value) })] })] }), _jsxs("label", { className: "sc-field", children: [_jsx("span", { className: "sc-field-label", children: words.note }), _jsx("input", { className: "sc-input", value: note, maxLength: MAX_SECRET_OFFER_NOTE_LENGTH, autoComplete: "off", onChange: (event) => setNote(event.target.value) })] }), _jsx("p", { className: "sc-field-hint", children: words.intro(props.account, SECRET_OFFER_DAYS) }), _jsx("div", { className: "sc-form-actions", children: _jsx(Button, { type: "submit", variant: "primary", disabled: busy || !ready, children: words.offer }) })] }));
1431
+ }
1321
1432
  /** The names of an agent account's secrets, and the way a supervisor seeds one or removes one. Never a value. */
1322
1433
  export function AgentSecretList(props) {
1323
1434
  const words = useWords().agents.page.settings.secrets;