ai-agentmanager 1.58.0 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.59.0 (2026-11-19)
4
+
5
+ - **Updates for the people who asked.** When an agent finishes or opens a pull request, what to tell the requester and other stakeholders is written from its work: a Slack message of a few lines, a short email with its subject, and the details both point to. An **Update to send** card appears in the inbox and the alert says it is ready. **Update** with an agent's documents (or `agentmgr announce <agent>`) writes one at any time, for work under way too.
6
+ - **Drafts, sent by you.** Change the text in place, then **Copy**, **Post to Slack** (asked twice; to a webhook for updates, `agentmgr announce --webhook <url>`, or where the Slack alerts go) or **Open in mail**, which fills in your own mail program. Nothing is sent to anyone by itself.
7
+ - **The details as a link.** Paste where they can be read, or **Publish to Google Drive** makes a Google Doc of them; the link goes under both messages.
8
+ - **Cost and turning it off.** Each update is one more tool-less model call on the agent's engine. `agentmgr announce --auto off` stops writing them by themselves.
9
+ - **Tried:** in desktop Chrome with a stand-in Slack webhook, and the wording once with a real model on made-up work. Not yet on a real agent's work, a real Slack channel, a phone's mail program or Google Drive.
10
+ - **Tests on CI stop at the first failure.** A failing slice ends the others, so a failure is known as soon as it happens and not when the slowest slice is through.
11
+
3
12
  ## 1.58.0 (2026-11-18)
4
13
 
5
14
  - **Screen: Pad, the screen as a trackpad.** A fingertip covers the button it aims at. With **Pad** on, a drag anywhere moves a pointer drawn on the screen (a slow finger moves it finely, a quick one crosses the screen) and a tap clicks where the pointer is. Two fingers scroll or, tapped, right-click; a finger held still, then dragged, drags. Zoomed in, the screen follows the pointer. The button appears on a touch screen and the choice is remembered. Tried in desktop Chrome with made-up touches, not yet on a phone against a real Mac.
package/README.md CHANGED
@@ -24,6 +24,7 @@ Run one background [Claude Code](https://claude.com/claude-code) agent per inten
24
24
  - **Projects.** The sidebar is a tree, project → agents, so you see how many projects are in flight and how many parallel sessions each has.
25
25
  - **Project shortcuts.** Each project gets a short name, such as `cc` for cloud-console. Use it instead of the repo URL: `agentmgr add @cc "…"`, `agentmgr ls cc`, `@cc` in the UI filter.
26
26
  - **Backlog.** Queue asks as work orders. Agents pick them up one by one, up to N in parallel per project, until each is done. You accept or reopen each one.
27
+ - **Updates for the people who asked.** When an agent finishes or opens a pull request, a short Slack message, a short email and the details they point to are written for you to read, change and send.
27
28
  - **Alerts, in Slack and on the phone.** A Slack message, a notification on the phone, or both, when an agent needs input, finishes a backlog item, or fails.
28
29
  - **Priority.** Mark agents P0–P3. P0 and P1 are highlighted, and lists sort by priority.
29
30
  - **Share for review.** One click writes an **Analysis**, **Design**, **Flow** or **Proposal** document from the agent's work, a human time **Estimate** for planning, or the change's **Documentation** with an OpenAPI spec of any API changes. Copy it as Markdown, download it, or print it to PDF with diagrams.
@@ -198,6 +199,7 @@ agentmgr explain <agent> # full briefing: ask, status, plan
198
199
  agentmgr remote on | off | status | rotate # phone / remote access (see below)
199
200
  agentmgr backlog add "ask" -r <repo> [-p 1] # queue work; also: ls, start, accept, reopen, move, limit, pause
200
201
  agentmgr notify slack --webhook <url> # Slack alerts; also: test, status, on, off, event <name> on|off
202
+ agentmgr announce <agent> # what to tell the people who asked: a Slack message, an email and the details (--post, --link <url>; no agent: the settings)
201
203
  agentmgr notify phone # the same alerts as notifications on the phone (ntfy app); --off stops them
202
204
  agentmgr debug <agent> "what goes wrong" # debug with an agent; no question prints its report; --fix applies the fixes
203
205
  agentmgr reverse <agent> -t /path/to/app "how does search work" # reverse engineer with an agent and REA; no question prints the report; --build builds your own
@@ -410,6 +412,24 @@ Type your answers in the viewer, or tap an option to fill one in. **Send my answ
410
412
 
411
413
  **Behaviour.** Documents are kept per agent and marked out of date when the brief changes. They come from the same separate, tool-less Claude call as Explain, so the agent isn't interrupted. On the phone link, the print page needs sign-in like everything else.
412
414
 
415
+ ## Updates for the people who asked
416
+
417
+ The people who asked for the work rarely watch it. **Update** (with the documents in the Brief panel, or `agentmgr announce <agent>`) writes what to tell them, from the agent's live context:
418
+
419
+ - **Slack:** at most five short lines: what it is about and where it stands, what was done, what is left or needed from the reader.
420
+ - **Email:** a subject and a short body saying the same, addressed to whoever asked when the work says who that is.
421
+ - **Details:** the full write-up both point to: what was asked, what was done, the status, what is left, decisions and risks, and the links. It is a document like the others: **Copy Markdown**, **Print / PDF**, **Listen**.
422
+
423
+ **They are drafts.** You read them and change them in place, then:
424
+
425
+ - **Copy** either one, or **Post to Slack**, which asks once more before it posts, since a channel is full of people. It posts to a webhook for updates (`agentmgr announce --webhook <url>`, set on the computer itself) or, without one, to where the Slack alerts go.
426
+ - **Open in mail** opens the email in the mail program of the device in your hand, filled in, for you to send from your own address.
427
+ - **Link to the details:** paste where they can be read (a Google Doc, Confluence, the pull request), or **Publish to Google Drive** makes a Google Doc of them through the Drive connector of your Claude account. The link goes under both messages as `Details: …`.
428
+
429
+ Nothing is sent to anyone by itself, and the messages never mention the agent: they are written as from the person responsible for the work.
430
+
431
+ **Written by themselves.** When an agent finishes (its brief says done) or opens a pull request, the update is written in the background, an **Update to send** card appears in the inbox, and the alert says so (the *update ready* alert). **Read and send** opens it; **Not needed** sets it aside. Only what happens while AI Agent Manager runs counts: agents already finished when it starts are not announced. Each one is a separate, tool-less model call on the agent's engine, like the other documents. `agentmgr announce --auto off` (or `"announce": { "auto": false }` in config.json) turns that off; **Update** on an agent still writes one when you ask.
432
+
413
433
  ## Plan review
414
434
 
415
435
  Tick **Review the implementation plan first** in New agent (or the backlog), or press **Review its plan first** on a running agent. The agent investigates, writes `PLAN.md` (goal, approach, steps, files, tests, risks) next to its brief, and stops. It doesn't edit, commit or run anything that changes the repo until you approve.
@@ -29,6 +29,7 @@ No build step: Node ES modules on the server, plain ES modules in the browser. S
29
29
  | `src/backlog.js`, `src/races.js` | Work orders picked up per project; several agents on one intent, compared. |
30
30
  | `src/teams.js` | Agents in roles on one problem: handoff files with a verdict line move the team from analysis to review. |
31
31
  | `src/notify.js` | Alerts to Slack and to the phone (ntfy), triaged by the judge. |
32
+ | `src/announce.js` | Updates for the people who asked: the prompt, the parts, and writing one when an agent finishes or opens a PR. |
32
33
  | `src/awake.js` | Keeps the computer from sleeping, always or while an agent works. |
33
34
  | `src/files.js` | This computer's folders for a signed-in device: list, send a file, fetch one. |
34
35
  | `src/preview.js`, `src/livebrowser.js` | Browser tabs: HTTPS relays for remote devices, and a headless Chrome streamed over the Chrome DevTools Protocol (frames, input, sound). |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.58.0",
3
+ "version": "1.59.0",
4
4
  "description": "Run background coding agents (Claude Code, Codex) per intent, and keep track of them from a web UI, your phone or the CLI",
5
5
  "keywords": [
6
6
  "claude",
@@ -0,0 +1,134 @@
1
+ // Update: what to tell the people who asked, in the document dialog. A Slack message and an email,
2
+ // both short and yours to change, and the details they point to (src/announce.js writes them).
3
+ // Nothing is sent from here until you press the button that sends it.
4
+
5
+ const withLink = (text, link) => (link ? `${text.trim()}\n\nDetails: ${link}` : text.trim());
6
+ /** A link that opens the device's mail program with the message filled in: addresses split on commas, spaces or semicolons. */
7
+ export function mailtoFor(to, subject, body) {
8
+ const list = String(to ?? '').split(/[,;\s]+/).filter(Boolean).map((addr) => encodeURIComponent(addr).replace(/%40/g, '@'));
9
+ return `mailto:${list.join(',')}?subject=${encodeURIComponent(subject ?? '')}&body=${encodeURIComponent(body ?? '')}`;
10
+ }
11
+ const sentSome = (u) => Boolean(u?.sent?.slack || u?.sent?.email);
12
+
13
+ /** Whether an update written by itself still waits to be sent (the inbox card). */
14
+ export const updateWaits = (a) => Boolean(a.announce?.auto && a.docs?.update?.markdown && !a.docs.update.pending && !a.announce.dismissedAt && !sentSome(a.announce));
15
+
16
+ export function updateHtml(a, d, { esc, docHtml }) {
17
+ const p = d.parts ?? {};
18
+ const to = a.announce?.to ?? (/@/.test(p.to ?? '') ? p.to : '');
19
+ return `<div class="upd" data-upd="${esc(a.id)}">
20
+ <p class="hint">Drafts, written from the work as it stands (${esc(d.stage ?? 'in progress')}). Change them as you like: nothing goes to anyone until you send it.</p>
21
+ <section class="ha-card upd-card">
22
+ <h3>Slack</h3>
23
+ <textarea data-upd-text="slack" rows="6" aria-label="The Slack message">${esc(p.slack ?? '')}</textarea>
24
+ <p class="hint" data-upd-note="slack"></p>
25
+ <div class="need-actions"><button type="button" class="small primary" data-upd-act="copy-slack">Copy</button><button type="button" class="small" data-upd-act="post-slack">Post to Slack</button></div>
26
+ </section>
27
+ <section class="ha-card upd-card">
28
+ <h3>Email</h3>
29
+ <label>To <input data-upd-text="to" type="text" inputmode="email" autocapitalize="none" autocorrect="off" spellcheck="false" placeholder="${esc(p.to && !to ? `${p.to}'s address` : 'name@example.com, another@example.com')}" value="${esc(to)}" /></label>
30
+ <label>Subject <input data-upd-text="subject" type="text" value="${esc(p.subject ?? '')}" /></label>
31
+ <textarea data-upd-text="email" rows="9" aria-label="The email">${esc(p.email ?? '')}</textarea>
32
+ <p class="hint" data-upd-note="email"></p>
33
+ <div class="need-actions"><button type="button" class="small primary" data-upd-act="mail" title="Open it in this device's mail program, ready to send">Open in mail</button><button type="button" class="small" data-upd-act="copy-email">Copy</button></div>
34
+ </section>
35
+ <section class="ha-card upd-card">
36
+ <h3>Details</h3>
37
+ <label>Link to the details <input data-upd-text="link" type="url" placeholder="https://… where they can read what is below" value="${esc(a.announce?.link ?? '')}" /></label>
38
+ <p class="hint" data-upd-note="link"></p>
39
+ <div class="need-actions"><button type="button" class="small" data-upd-act="publish" title="Put the details below in a Google Doc, through the Google Drive connector of your Claude account; its link then goes under both messages">Publish to Google Drive</button><button type="button" class="small ghost" data-upd-act="dismiss" title="This update is not needed: take it out of the inbox">Not needed</button></div>
40
+ <div class="md upd-details">${docHtml(d.markdown)}</div>
41
+ </section>
42
+ </div>`;
43
+ }
44
+
45
+ export function initUpdateView({ body, api, toast, ago, agentOf, upsert }) {
46
+ let slack; // where Post to Slack goes: undefined until asked, null when nowhere
47
+ const root = () => body.querySelector('[data-upd]');
48
+ const field = (k) => root()?.querySelector(`[data-upd-text="${k}"]`);
49
+ const note = (k, text) => {
50
+ const el = root()?.querySelector(`[data-upd-note="${k}"]`);
51
+ if (el && el.textContent !== text) el.textContent = text;
52
+ };
53
+
54
+ /** What changes around the drafts without touching what you typed: sent, the link, publishing. */
55
+ function refresh(a) {
56
+ if (!root() || !a) return;
57
+ const u = a.announce ?? {};
58
+ const link = u.link ? 'The link to the details goes under it.' : 'No link to the details yet: it goes without one.';
59
+ note('slack', `${u.sent?.slack ? `Posted ${ago(u.sent.slack)}. ` : ''}${link}`);
60
+ note('email', `${u.sent?.email ? `Opened in mail ${ago(u.sent.email)}. ` : ''}${link}`);
61
+ note('link', u.publishing ? 'Publishing to Google Drive… this takes a minute or two.' : u.publishError ? `Not published: ${u.publishError}` : u.link ? (u.published ? `A Google Doc, published ${ago(u.published.at)}. Publish again for a new one after changes.` : '') : 'Paste a link (a Google Doc, Confluence, the pull request), or publish the details below as a Google Doc.');
62
+ const linkField = field('link');
63
+ if (linkField && document.activeElement !== linkField && linkField.value !== (u.link ?? '')) linkField.value = u.link ?? '';
64
+ const post = root().querySelector('[data-upd-act="post-slack"]');
65
+ if (!post.dataset.sure) {
66
+ post.disabled = slack === null;
67
+ post.textContent = slack ? `Post to ${slack}` : 'Post to Slack';
68
+ post.title = slack === null ? 'Slack is not set up: agentmgr announce --webhook <url> on the computer, or set up Slack alerts' : 'Post the message above, as it reads now';
69
+ }
70
+ root().querySelector('[data-upd-act="publish"]').disabled = Boolean(u.publishing);
71
+ root().querySelector('[data-upd-act="dismiss"]').hidden = !updateWaits(a);
72
+ if (slack === undefined) {
73
+ slack = null;
74
+ api('GET', '/announce/settings').then((s) => {
75
+ slack = s.slack ?? null;
76
+ refresh(agentOf(root()?.dataset.upd));
77
+ }).catch(() => {});
78
+ }
79
+ }
80
+
81
+ const copy = (text, what) => navigator.clipboard.writeText(text).then(() => toast(`${what} copied`), () => toast('Copy failed: your browser blocked clipboard access'));
82
+ const save = (id, patch) => api('PUT', `/agents/${id}/announce`, patch).then(upsert);
83
+
84
+ body.addEventListener('change', (e) => {
85
+ const id = root()?.dataset.upd;
86
+ const k = e.target.dataset?.updText;
87
+ if (!id || !['link', 'to'].includes(k)) return;
88
+ save(id, { [k]: e.target.value }).catch((err) => toast(`Error: ${err.message}`, 6000));
89
+ });
90
+
91
+ body.addEventListener('click', async (e) => {
92
+ const b = e.target.closest('[data-upd-act]');
93
+ const id = root()?.dataset.upd;
94
+ if (!b || !id) return;
95
+ const link = agentOf(id)?.announce?.link ?? null;
96
+ const what = b.dataset.updAct;
97
+ try {
98
+ if (what === 'copy-slack') return await copy(withLink(field('slack').value, link), 'The Slack message');
99
+ if (what === 'copy-email') return await copy(`Subject: ${field('subject').value}\n\n${withLink(field('email').value, link)}`, 'The email');
100
+ if (what === 'mail') {
101
+ // The device's own mail program sends it, from your address: this page only fills it in.
102
+ location.href = mailtoFor(field('to').value, field('subject').value, withLink(field('email').value, link));
103
+ return await save(id, { sent: 'email', to: field('to').value });
104
+ }
105
+ if (what === 'post-slack') {
106
+ // A channel full of people: asked twice, so a slip of the thumb posts nothing.
107
+ if (!b.dataset.sure) {
108
+ b.dataset.sure = '1';
109
+ b.textContent = `Post it to ${slack}?`;
110
+ b.classList.add('primary');
111
+ return setTimeout(() => {
112
+ delete b.dataset.sure;
113
+ b.classList.remove('primary');
114
+ refresh(agentOf(id));
115
+ }, 5000);
116
+ }
117
+ delete b.dataset.sure;
118
+ b.classList.remove('primary');
119
+ const r = await api('POST', `/agents/${id}/announce/slack`, { text: field('slack').value });
120
+ upsert(r);
121
+ return toast(`Posted to ${r.postedTo}`);
122
+ }
123
+ if (what === 'publish') return upsert(await api('POST', `/agents/${id}/announce/publish`));
124
+ if (what === 'dismiss') {
125
+ await save(id, { dismissed: true });
126
+ return toast('Taken out of the inbox');
127
+ }
128
+ } catch (err) {
129
+ toast(`Error: ${err.message}`, 6000);
130
+ }
131
+ });
132
+
133
+ return { refresh };
134
+ }
package/public/app.js CHANGED
@@ -52,6 +52,7 @@ import { initCodeMap } from '/codemap.js';
52
52
  import { initKeys } from '/keys.js';
53
53
  import { initPalette } from '/palette.js';
54
54
  import { initFiles } from '/files.js';
55
+ import { initUpdateView, updateHtml, updateWaits } from '/announce.js';
55
56
  import { morph } from '/morph.js';
56
57
 
57
58
  const $ = (sel) => document.querySelector(sel);
@@ -629,16 +630,17 @@ const INSIGHT_ICONS = { why: '🎯', what: '📦', how: '🛠', now: '📍' };
629
630
 
630
631
  // ------------------------------------------------------------------ stakeholder documents
631
632
 
632
- const DOCS = { analysis: 'Analysis', design: 'Design', flow: 'Flow', proposal: 'Proposal', humanai: 'Human vs AI', estimate: 'Estimate', documentation: 'Documentation', diagrams: 'Diagrams', scorecard: 'Scorecard' };
633
+ const DOCS = { analysis: 'Analysis', design: 'Design', flow: 'Flow', proposal: 'Proposal', humanai: 'Human vs AI', estimate: 'Estimate', documentation: 'Documentation', diagrams: 'Diagrams', scorecard: 'Scorecard', update: 'Update' };
633
634
  // What a document is before it's written, where "Write a … document for stakeholders" doesn't say it.
634
635
  const DOC_HINTS = {
636
+ update: 'What to tell the people who asked: a short Slack message and a short email for you to send, and the details they point to. Written by itself when the agent finishes or opens a pull request',
635
637
  estimate: 'For planning: how long a person would take to do this work by hand, split into tasks with optimistic, likely and pessimistic hours, a suggested split into tickets, the roles needed and the risks',
636
638
  documentation: 'The documentation for this change: what is new, how to use it, configuration, upgrade notes, which docs to add or update, and an OpenAPI spec of any API changes',
637
639
  };
638
640
  /** The OpenAPI spec in a Documentation document (its ```yaml block), if the change has API changes. */
639
641
  const openApiOf = (markdown) => (markdown ?? '').match(/```ya?ml\s*\n((?:#.*\n|\s*\n)*openapi:[\s\S]*?)```/)?.[1] ?? null;
640
642
  // Optional extras that "Write all" leaves out.
641
- const DOC_EXTRAS = new Set(['diagrams', 'scorecard']);
643
+ const DOC_EXTRAS = new Set(['diagrams', 'scorecard', 'update']);
642
644
  const DOC_TITLES = { ...DOCS, estimate: 'Human time estimate', eval: 'Eval', plan: 'Plan', intent: 'Intent', spec: 'Spec', designdoc: 'Design doc', benchmark: 'Benchmark' };
643
645
  // The agent's intent, spec and plan files (read from the daemon when opened; kept here by agent and kind).
644
646
  const SPEC_KINDS = { intent: 'Intent', spec: 'Spec', plan: 'Plan', designdoc: 'Design doc', benchmark: 'Benchmark' };
@@ -784,10 +786,11 @@ function renderDocDialog() {
784
786
  // The scorecard's Improve button follows the agent being improved.
785
787
  const version = docView.kind === 'scorecard' ? `${d.at}:${Boolean(a.improving)}` : d.at;
786
788
  if (body.dataset.rendered !== version) {
787
- body.innerHTML = docView.kind === 'scorecard' ? scorecardHtml(d, esc, { actions: improveHtml(a) }) : d.data ? humanAiHtml(d) : docHtml(d.markdown);
789
+ body.innerHTML = docView.kind === 'scorecard' ? scorecardHtml(d, esc, { actions: improveHtml(a) }) : docView.kind === 'update' ? updateHtml(a, d, { esc, docHtml }) : d.data ? humanAiHtml(d) : docHtml(d.markdown);
788
790
  body.dataset.rendered = version;
789
791
  renderDiagrams(body);
790
792
  }
793
+ if (docView.kind === 'update') announceUi.refresh(a);
791
794
  }
792
795
  const stale = !plan && d?.markdown && a.brief?.updatedAt && d.briefUpdatedAt !== a.brief.updatedAt;
793
796
  const by = d?.writer ? ` by ${d.writer}${d.critique ? `, checked by ${d.critique.label}` : ''}${d.from ? ` from ${d.from.length ? d.from.join(', ') : "the agent's work"}` : ''}` : '';
@@ -875,6 +878,9 @@ $('#doc-body').addEventListener('submit', (e) => {
875
878
  });
876
879
  });
877
880
 
881
+ // The Update document's own buttons: copy, open in mail, post to Slack, the link to its details.
882
+ const announceUi = initUpdateView({ body: $('#doc-body'), api, toast, ago, agentOf: (id) => agents.get(id), upsert: (a) => upsert(a) });
883
+
878
884
  function generateDoc() {
879
885
  const { agentId, kind } = docView;
880
886
  act(async () => upsert(await api('POST', `/agents/${agentId}/docs/${kind}`)));
@@ -1543,7 +1549,7 @@ function loadLimitEngines() {
1543
1549
  })
1544
1550
  .catch(() => (limitEngines = null));
1545
1551
  }
1546
- const NEED_ORDER = { approval: 0, prompt: 0, limit: 1, waiting: 1, plan: 1, question: 1, team: 1, rule: 2, review: 2, prereview: 2, autopilot: 2, stuck: 3, conflict: 4, reminder: 5, close: 5, repeat: 5 };
1552
+ const NEED_ORDER = { approval: 0, prompt: 0, limit: 1, waiting: 1, plan: 1, question: 1, team: 1, rule: 2, review: 2, prereview: 2, autopilot: 2, stuck: 3, conflict: 4, reminder: 5, close: 5, repeat: 5, update: 4 };
1547
1553
  /** What an agent needs from the user. `both`: overlaps on both agents (detail), else only the one that should rebase (inbox). */
1548
1554
  function needsFor(a, { both = false } = {}) {
1549
1555
  const items = [];
@@ -1555,6 +1561,7 @@ function needsFor(a, { both = false } = {}) {
1555
1561
  if (['stalled', 'error'].includes(a.preReview?.status)) items.push({ a, kind: 'prereview', key: `prereview:${a.id}` });
1556
1562
  for (const q of a.questions ?? []) if (!q.answer) items.push({ a, kind: 'question', key: `q:${a.id}:${q.id}`, q });
1557
1563
  for (const f of a.stuck ?? []) items.push({ a, kind: 'stuck', key: `stuck:${a.id}:${f.key}`, f });
1564
+ if (updateWaits(a)) items.push({ a, kind: 'update', key: `update:${a.id}` });
1558
1565
  if (a.followUp) items.push({ a, kind: a.followUp.kind === 'close' ? 'close' : 'reminder', key: `reminder:${a.id}`, r: a.followUp });
1559
1566
  for (const g of a.conflicts ?? []) if (both || g.mergeFirst !== a.id) items.push({ a, kind: 'conflict', key: `conflict:${a.id}:${g.agent.id}`, g });
1560
1567
  return items;
@@ -1591,7 +1598,7 @@ function inboxItems() {
1591
1598
  .sort((x, y) => NEED_ORDER[x.kind] - NEED_ORDER[y.kind] || (x.a.priority ?? 2) - (y.a.priority ?? 2));
1592
1599
  }
1593
1600
 
1594
- const NEED_LABEL = { limit: 'Limit', reminder: 'Follow up', close: 'Close session?', repeat: 'Make it a playbook?', autopilot: 'Autopilot held', rule: 'Always allow?', approval: 'Approval', team: 'Team', prompt: 'Needs input', waiting: 'Waiting on you', plan: 'Plan review', question: 'Question', review: 'AI review', prereview: 'Not approved', stuck: 'Stuck?', conflict: 'Overlap' };
1601
+ const NEED_LABEL = { update: 'Update to send', limit: 'Limit', reminder: 'Follow up', close: 'Close session?', repeat: 'Make it a playbook?', autopilot: 'Autopilot held', rule: 'Always allow?', approval: 'Approval', team: 'Team', prompt: 'Needs input', waiting: 'Waiting on you', plan: 'Plan review', question: 'Question', review: 'AI review', prereview: 'Not approved', stuck: 'Stuck?', conflict: 'Overlap' };
1595
1602
  /** Why the AI judge thinks so, as a small tag. */
1596
1603
  const aiTag = (confidence, what = 'AI') => `<span class="tag ai" title="Judged by a model from the agent's activity; your reactions tune later calls">🤖 ${what}${confidence != null ? ` ${Math.round(confidence * 100)}%` : ''}</span>`;
1597
1604
  /** What a permission prompt asks about: the command, file or tool. */
@@ -1734,6 +1741,12 @@ function needCard(it, { inDetail = false } = {}) {
1734
1741
  <textarea rows="2" data-draft="${esc(it.key)}:text">${draft('text', FOLLOW_UP)}</textarea>
1735
1742
  <div class="need-actions"><button class="small primary">Send</button><button type="button" class="small ghost" data-ib="terminal">Open terminal</button><button type="button" class="small ghost" data-ib="remind-close">Close session</button>${later}</div>
1736
1743
  </form>`}`;
1744
+ } else if (it.kind === 'update') {
1745
+ const d = a.docs.update;
1746
+ const why = a.announce.auto.milestone === 'done' ? 'It is finished' : 'It opened a pull request';
1747
+ body = `<p class="need-title">${esc(d.parts?.subject || 'An update for the people who asked')}</p>
1748
+ <p class="hint">${why}: what to tell the people who asked is written (${ago(d.at)}), a Slack message and an email. Nothing is sent until you send it.</p>
1749
+ <div class="need-actions"><button class="small primary" data-ib="update-open">Read and send</button><button class="small ghost" data-ib="update-dismiss" title="This one is not needed">Not needed</button></div>`;
1737
1750
  } else if (it.kind === 'stuck') {
1738
1751
  const f = it.f;
1739
1752
  const judged = f.ai?.verdict === 'stuck' ? aiTag(f.ai.confidence, 'confirmed') : f.ai?.verdict === 'checking' ? '<span class="tag ai">🤖 checking…</span>' : '';
@@ -1965,6 +1978,10 @@ async function onNeed(e) {
1965
1978
  return act(async () => upsert(await api('POST', `/agents/${id}/stop`)), 'Session closed; resume it any time');
1966
1979
  case 'remind-resume':
1967
1980
  return act(async () => upsert(await api('POST', `/agents/${id}/start`, {})), 'Resumed');
1981
+ case 'update-open':
1982
+ return openDoc(id, 'update');
1983
+ case 'update-dismiss':
1984
+ return act(async () => upsert(await api('PUT', `/agents/${id}/announce`, { dismissed: true })));
1968
1985
  case 'remind-later':
1969
1986
  return act(async () => upsert(await api('POST', `/agents/${id}/reminder`, { action: 'later' })), 'Reminding you later');
1970
1987
  case 'remind-dismiss':
package/public/index.html CHANGED
@@ -638,6 +638,7 @@
638
638
  <label class="check"><input type="checkbox" name="ev_standup" /> the daily standup is ready (with a link to play it)</label>
639
639
  <label class="check"><input type="checkbox" name="ev_value" /> value reports (weekly, monthly, quarterly, as set in Value)</label>
640
640
  <label class="check"><input type="checkbox" name="ev_usage" /> an engine's plan limit (Claude Code's 5-hour session or week, Codex's) is nearly used up (Usage)</label>
641
+ <label class="check"><input type="checkbox" name="ev_announce" /> an update for the people who asked is written and ready for you to send (when an agent finishes or opens a pull request)</label>
641
642
  <label class="check"><input type="checkbox" name="ev_decided" /> something was decided for you: a standing decision of yours applied, or it was within the autonomy you set (Decide)</label>
642
643
  <label class="check"><input type="checkbox" name="ev_milestone" /> a project's date (code complete, RC, GA) is 14, 7, 3 or 1 days away, today, or late (Plan → Dates)</label>
643
644
  <label class="check"><input type="checkbox" name="ev_waiting" /> finished its turn and is idle after <input name="waitingDelaySec" type="number" min="0" class="num" />s</label>
package/public/style.css CHANGED
@@ -653,6 +653,11 @@ pre.diff .meta { color: var(--muted); font-weight: 600; }
653
653
 
654
654
  /* ---------- Human vs AI, plan review */
655
655
  .ha-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
656
+ .upd-card h3 { margin: 0 0 6px; }
657
+ .upd-card textarea, .upd-card input { width: 100%; font: inherit; font-size: 16px; }
658
+ .upd-card label { display: block; margin: 6px 0; color: var(--muted); font-size: 12px; }
659
+ .upd-card textarea { resize: vertical; }
660
+ .upd-details { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 6px; }
656
661
  .ha-card.human { border-left: 3px solid var(--accent); }
657
662
  .ha-card h4 { margin: 0 0 6px; }
658
663
  .ha-card p { margin: 4px 0; }
@@ -0,0 +1,140 @@
1
+ // Announce: what to tell the people who asked for the work, once an agent has something to show
2
+ // (a pull request opened) or is finished. One tool-less model call writes three things from the
3
+ // agent's live context: a short Slack message, a short email, and the details as a document both
4
+ // point to. They are drafts: you read them, change them and send them. Nothing here writes to a
5
+ // person by itself.
6
+
7
+ /** The parts of the document, in order, as the model is told to write them and as they are read back. */
8
+ const PARTS = ['Slack', 'Email', 'Details'];
9
+
10
+ export const announceSettings = (config = {}) => ({ auto: config.announce?.auto !== false });
11
+
12
+ /**
13
+ * What stage the work is at, for the wording: finished, something to show, or under way. From
14
+ * what is tracked, not from what the agent says about itself in passing.
15
+ */
16
+ /** Finished: its brief says so, in its status or in its results. */
17
+ const done = (v) => v.brief?.status === 'done' || v.results?.outcome === 'done';
18
+
19
+ export function stageOf(v) {
20
+ const prs = (v.prs ?? []).filter((p) => p.source !== 'mentioned');
21
+ if (done(v) || (prs.length && prs.every((p) => p.state === 'MERGED'))) return 'finished';
22
+ if (prs.some((p) => p.state === 'OPEN' || p.state === 'MERGED')) return 'ready for review';
23
+ return 'in progress';
24
+ }
25
+
26
+ /** The moments an update is prepared for by itself: finished, and each pull request it opens. */
27
+ export function milestonesOf(v) {
28
+ const out = [];
29
+ for (const p of v.prs ?? []) if (p.source !== 'mentioned' && p.url && ['OPEN', 'MERGED'].includes(p.state)) out.push(`pr:${p.url}`);
30
+ if (done(v)) out.push('done');
31
+ return out;
32
+ }
33
+
34
+ export function updatePrompt({ intent, status, digest, repo, briefMarkdown, stage = 'in progress' }) {
35
+ return [
36
+ 'Write an update for the people who asked for a piece of software work: the requester and other stakeholders. They did not follow the work and may not read code.',
37
+ `The work is ${stage}. Base everything only on the context below: the original ask, the conversation and actions, the repository changes and the brief.`,
38
+ 'Write as the person responsible for the work, in the first person plural or neutral ("This is done", "We changed…"). No mention of an AI agent, its tools or this prompt.',
39
+ '',
40
+ 'Output Markdown with exactly these three level-2 sections, in this order, and nothing before the first:',
41
+ '',
42
+ '## Slack',
43
+ 'A message to paste into Slack: at most 5 lines of under 100 characters each, plain text. First line: what this is about and where it stands (finished, ready for review, in progress), in a few words. Then what was done, what is left or needed from the reader (a review, a decision, nothing), each in one line. No headings, no tables, no greeting, no sign-off, no links.',
44
+ '',
45
+ '## Email',
46
+ 'First line exactly "To: <the name of whoever asked, if the context says; otherwise leave empty>". Second line "Subject: <under 70 characters, saying what and where it stands>". Then an empty line and the body in plain text: a one-line greeting ("Hi <first name>," or "Hi,"), then 3 to 6 short sentences or bullets ("- ") covering what was asked, what was done, the status, and what is needed from the reader with any date the context gives. No signature, no links.',
47
+ '',
48
+ '## Details',
49
+ 'The full write-up the two messages point to, in Markdown, with these level-3 headings: "### What was asked", "### What was done" (specific: components, behaviour, pull requests by number and tickets by key), "### Status" (what is finished, tested, merged or released, and what is not), "### What is left" (or "Nothing."), "### Decisions and risks" (what needs a decision or could go wrong; or "None."), "### Links" (the pull requests, tickets and documents in the context, as a list).',
50
+ '',
51
+ 'Rules:',
52
+ '- Say only what the context supports. Where it does not say, write "To be confirmed" in Details and leave it out of the two messages.',
53
+ '- Plain words for a reader outside the team: what changes for users or the business before how it was built. No file paths in the two messages.',
54
+ '- Do not claim more than was checked: "tests pass" only if the context shows them passing, "released" only if it was.',
55
+ '- The two messages stand on their own and do not repeat each other word for word; Details is 150 to 500 words.',
56
+ '',
57
+ '<agent_status>',
58
+ status,
59
+ '</agent_status>',
60
+ '<intent>',
61
+ intent || '(none)',
62
+ '</intent>',
63
+ '<conversation>',
64
+ digest || '(no conversation recorded yet)',
65
+ '</conversation>',
66
+ '<repository>',
67
+ repo || '(no repository changes recorded)',
68
+ '</repository>',
69
+ '<brief>',
70
+ briefMarkdown || '(no brief yet)',
71
+ '</brief>',
72
+ ].join('\n');
73
+ }
74
+
75
+ /**
76
+ * The written update taken apart: { slack, to, subject, email, details }. A part the model left
77
+ * out is an empty string; a reply with none of them is all Details, so nothing written is lost.
78
+ */
79
+ export function parseUpdate(markdown) {
80
+ const text = String(markdown ?? '').replace(/\r\n/g, '\n');
81
+ const parts = {};
82
+ const heads = [...text.matchAll(/^##[ \t]+(Slack|Email|Details)\b[^\n]*\n/gim)];
83
+ heads.forEach((m, i) => {
84
+ const name = PARTS.find((p) => p.toLowerCase() === m[1].toLowerCase());
85
+ parts[name] ??= text.slice(m.index + m[0].length, heads[i + 1]?.index ?? text.length).trim();
86
+ });
87
+ if (!heads.length) return { slack: '', to: '', subject: '', email: '', details: text.trim() };
88
+ let email = parts.Email ?? '';
89
+ const line = (label) => {
90
+ const m = new RegExp(`^\\**${label}:\\**[ \\t]*(.*)$`, 'im').exec(email);
91
+ if (!m) return '';
92
+ email = (email.slice(0, m.index) + email.slice(m.index + m[0].length)).trim();
93
+ return m[1].replace(/^[<(\[]|[>)\]]$/g, '').trim();
94
+ };
95
+ const to = line('To');
96
+ const subject = line('Subject');
97
+ // A fenced block around a message is the model being careful, not part of the message.
98
+ const bare = (s) => s.replace(/^```\w*\n([\s\S]*?)\n```$/m, '$1').trim();
99
+ return { slack: bare(parts.Slack ?? ''), to: /^(to be confirmed|unknown|none|n\/a|-)?$/i.test(to) ? '' : to, subject, email: bare(email), details: parts.Details ?? '' };
100
+ }
101
+
102
+ /** A message with the link to the details under it, when there is one. */
103
+ export const withLink = (text, link) => (link ? `${text.trim()}\n\nDetails: ${link}` : text.trim());
104
+
105
+ /**
106
+ * Prepares an update by itself when an agent reaches a moment worth telling: it finished, or it
107
+ * opened a pull request. Only moments seen to happen while this runs count: what was already so
108
+ * when the daemon started (or when updates were turned on) is not announced after the fact.
109
+ */
110
+ export class Announcer {
111
+ /** `prepare(agentId, milestone)` writes the update and resolves when it is there. */
112
+ constructor({ manager, config = {}, prepare, log = () => {} }) {
113
+ Object.assign(this, { manager, config, prepare, log });
114
+ this.seen = new Map(); // agent id -> the milestones it had already reached
115
+ manager.on('change', (a) => this.observe(a));
116
+ }
117
+
118
+ get settings() {
119
+ return announceSettings(this.config);
120
+ }
121
+
122
+ change(b = {}) {
123
+ if (typeof b.auto !== 'boolean') throw Object.assign(new Error('auto is true or false'), { status: 400 });
124
+ this.config.announce = { ...this.config.announce, auto: b.auto };
125
+ return this.config.announce;
126
+ }
127
+
128
+ observe(a) {
129
+ if (!a?.id || ['general', 'assistant'].includes(a.kind) || a.hunting || a.reviewing) return;
130
+ const now = milestonesOf(a);
131
+ const before = this.seen.get(a.id);
132
+ this.seen.set(a.id, new Set([...(before ?? []), ...now]));
133
+ if (!before || !this.settings.auto) return;
134
+ const fresh = now.filter((m) => !before.has(m));
135
+ if (!fresh.length) return;
136
+ // Finished says more than the pull request that came with it: one update for both.
137
+ const milestone = fresh.includes('done') ? 'done' : fresh.at(-1);
138
+ this.prepare(a.id, milestone).catch((e) => this.log(`update for ${a.name}: ${e.message.slice(0, 160)}`));
139
+ }
140
+ }
package/src/cli.js CHANGED
@@ -504,6 +504,50 @@ export async function main(argv) {
504
504
  process.stdout.write(`${d.markdown}\n`);
505
505
  });
506
506
 
507
+ program
508
+ .command('announce')
509
+ .description('What to tell the people who asked: a short Slack message, a short email and the details, written from the agent work for you to send. Without an agent: the settings')
510
+ .argument('[agent]')
511
+ .option('--cached', 'print the last one instead of writing a new one')
512
+ .option('--slack', 'print only the Slack message')
513
+ .option('--email', 'print only the email')
514
+ .option('--details', 'print only the details (Markdown)')
515
+ .option('--link <url>', 'where the details can be read; it goes under both messages')
516
+ .option('--post', 'post the Slack message (to the webhook for updates, or where the Slack alerts go)')
517
+ .option('--auto <on|off>', 'settings: write one when an agent finishes or opens a pull request (on)')
518
+ .option('--webhook <url>', "settings: a Slack webhook for these (the stakeholders' channel); \"none\" goes back to where the alerts go")
519
+ .action(async (ref, opts) => {
520
+ await daemon();
521
+ if (!ref) {
522
+ if (opts.auto !== undefined) {
523
+ if (!['on', 'off'].includes(opts.auto)) throw new Error('--auto is on or off');
524
+ await api('PUT', '/announce/settings', { auto: opts.auto === 'on' });
525
+ }
526
+ if (opts.webhook !== undefined) await api('PUT', '/announce/slack', { webhookUrl: opts.webhook === 'none' ? '' : opts.webhook });
527
+ const v = await api('GET', '/announce/settings');
528
+ console.log(`Updates for the people who asked, written by themselves: ${v.auto ? green('on') : dim('off')} ${dim('(when an agent finishes or opens a pull request)')}`);
529
+ console.log(`Posted to Slack: ${v.slack ? v.slack : dim('nowhere yet: agentmgr announce --webhook <url>, or set up Slack alerts')}`);
530
+ return console.log(dim('They are drafts: nothing is sent to anyone until you send it (Update on an agent, or agentmgr announce <agent> --post).'));
531
+ }
532
+ let a = await resolveAgent(ref);
533
+ if (!opts.cached || !a.docs?.update?.markdown) {
534
+ process.stderr.write(dim('Writing the update… (a separate Claude call; the agent is not interrupted)\n'));
535
+ a = await api('POST', `/agents/${a.id}/docs/update`);
536
+ }
537
+ if (opts.link !== undefined) a = await api('PUT', `/agents/${a.id}/announce`, { link: opts.link });
538
+ const d = a.docs.update;
539
+ const link = a.announce?.link ? `\n\nDetails: ${a.announce.link}` : '';
540
+ const slack = `${d.parts.slack}${link}`;
541
+ const email = `${d.parts.to ? `To: ${d.parts.to}\n` : ''}Subject: ${d.parts.subject}\n\n${d.parts.email}${link}`;
542
+ if (opts.post) {
543
+ const r = await api('POST', `/agents/${a.id}/announce/slack`, {});
544
+ return console.log(`${green('✓')} posted to ${r.postedTo}`);
545
+ }
546
+ const only = opts.slack ? slack : opts.email ? email : opts.details ? d.markdown : null;
547
+ if (only !== null) return process.stdout.write(`${only}\n`);
548
+ process.stdout.write(`${bold('Slack')}\n${slack}\n\n${bold('Email')}\n${email}\n\n${bold('Details')}\n${d.markdown}\n`);
549
+ });
550
+
507
551
  program
508
552
  .command('insights')
509
553
  .description('Why / What / How / Now for an agent, three tidy points each (one-off Claude call)')
package/src/manager.js CHANGED
@@ -67,6 +67,7 @@ const SUMMARIES = {
67
67
  diagrams: { doc: 'diagrams', run: 'runDiagrams' },
68
68
  walkthrough: { doc: 'walkthrough', run: 'runWalkthrough' },
69
69
  scorecard: { doc: 'scorecard', run: 'runScorecard' },
70
+ update: { doc: 'update', run: 'runUpdate' },
70
71
  };
71
72
  /** Read / write where a summary of `kind` is kept on the agent record. */
72
73
  const getSummary = (agent, kind) => (SUMMARIES[kind].doc ? agent.docs?.[kind] : agent[SUMMARIES[kind].field]);
@@ -143,6 +144,7 @@ import { Rules, describeTool } from './rules.js';
143
144
  import { continuePrompt, findLimit } from './limits.js';
144
145
  import { runningClaude, scanClaudeSessions } from './sessions.js';
145
146
  import { builderAllowedTools, builderPrompt } from './builder.js';
147
+ import { parseUpdate, stageOf, updatePrompt, withLink } from './announce.js';
146
148
  import { DRIVE_DOCS, DRIVE_TOOLS, docUrl, driveHtml, drivePrompt, folderUrl, parseDrive } from './drive.js';
147
149
  import {
148
150
  bugFromRef,
@@ -2902,6 +2904,76 @@ export class AgentManager extends EventEmitter {
2902
2904
  return { folderId: r.folderId, id: r.files.doc, url: docUrl(r.files.doc) };
2903
2905
  }
2904
2906
 
2907
+ /**
2908
+ * An update for the people who asked (announce.js): a Slack message and an email to send, kept as
2909
+ * `parts`, and the details they point to, kept as the document itself so it reads, prints and
2910
+ * publishes like the others.
2911
+ */
2912
+ async runUpdate(agent, ctx) {
2913
+ const writer = this.writerFor(agent);
2914
+ const stage = stageOf(this.view(agent));
2915
+ const u = parseUpdate(await this.oneShot(agent, updatePrompt({ ...ctx, stage }), writer));
2916
+ const cur = this.store.get(agent.id);
2917
+ if (!cur) return null;
2918
+ return this.view(
2919
+ this.patch(
2920
+ agent.id,
2921
+ summaryPatch(cur, 'update', {
2922
+ markdown: `# Update: ${agent.name}\n\n${u.details || 'To be confirmed.'}`,
2923
+ parts: { slack: u.slack, to: u.to, subject: u.subject, email: u.email },
2924
+ stage,
2925
+ writer: `${writer.engine.label}${writer.model ? ` (${writer.model})` : ''}`,
2926
+ at: now(),
2927
+ briefUpdatedAt: cur.brief?.updatedAt ?? null,
2928
+ pending: false,
2929
+ error: null,
2930
+ }),
2931
+ ),
2932
+ );
2933
+ }
2934
+
2935
+ /** What goes with an update besides its text: the link to its details, who it is for, what was sent, set aside. */
2936
+ updateState(ref, b = {}) {
2937
+ const agent = this.mustGet(ref);
2938
+ const next = { ...agent.announce };
2939
+ if (b.link !== undefined) {
2940
+ const link = String(b.link ?? '').trim();
2941
+ if (link && !/^https?:\/\/\S+$/.test(link)) throw Object.assign(new Error('The link starts with https://'), { status: 400 });
2942
+ next.link = link || null;
2943
+ }
2944
+ if (b.to !== undefined) next.to = String(b.to ?? '').trim().slice(0, 500) || null;
2945
+ if (['slack', 'email'].includes(b.sent)) next.sent = { ...next.sent, [b.sent]: now() };
2946
+ if (b.dismissed !== undefined) next.dismissedAt = b.dismissed ? now() : null;
2947
+ return this.view(this.patch(agent.id, { announce: next }));
2948
+ }
2949
+
2950
+ /** The update's Slack message as it goes out: the text given (yours, edited) or the written one, with the link. */
2951
+ updateSlackText(ref, text = null) {
2952
+ const agent = this.mustGet(ref);
2953
+ const body = String(text ?? agent.docs?.update?.parts?.slack ?? '').trim();
2954
+ if (!body) throw Object.assign(new Error('There is no message to post: write the update first'), { status: 409 });
2955
+ return withLink(body.slice(0, 3000), agent.announce?.link);
2956
+ }
2957
+
2958
+ /** The update's details as one Google Doc, through the Drive connector; its link then goes under both messages. */
2959
+ publishUpdate(ref) {
2960
+ const agent = this.mustGet(ref);
2961
+ const markdown = agent.docs?.update?.markdown;
2962
+ if (!markdown) throw Object.assign(new Error('Write the update first'), { status: 409 });
2963
+ if (agent.announce?.publishing) return this.view(agent);
2964
+ this.patch(agent.id, { announce: { ...agent.announce, publishing: true, publishError: null } });
2965
+ this.publishDriveDoc({ folderTitle: `${agent.name} (AI Agent Manager)`, folderId: agent.drive?.folderId ?? null, title: `Update: ${agent.name}`, markdown })
2966
+ .then((r) => {
2967
+ const cur = this.store.get(agent.id);
2968
+ if (cur) this.patch(agent.id, { announce: { ...cur.announce, publishing: false, link: r.url, published: { id: r.id, at: now() } } });
2969
+ })
2970
+ .catch((e) => {
2971
+ const cur = this.store.get(agent.id);
2972
+ if (cur) this.patch(agent.id, { announce: { ...cur.announce, publishing: false, publishError: e.message } });
2973
+ });
2974
+ return this.view(this.store.get(agent.id));
2975
+ }
2976
+
2905
2977
  /** Diagrams only: the problem and its solution drawn from the documents already written and the live context. */
2906
2978
  async runDiagrams(agent, ctx) {
2907
2979
  const cur0 = this.store.get(agent.id) ?? agent;
package/src/notify.js CHANGED
@@ -25,6 +25,7 @@ export const EVENT_DEFAULTS = {
25
25
  milestone: true, // a project's date (code complete, RC, GA) is coming up, at risk or late
26
26
  usage: true, // an engine's plan limit is nearly used up (Usage)
27
27
  decided: true, // something was decided for you (a standing decision, or within the autonomy you set)
28
+ announce: true, // an update for the people who asked is written and ready for you to send
28
29
  };
29
30
 
30
31
  // Alerts the AI judge may hold for the digest or drop; the rest are always sent at once.
@@ -38,6 +39,8 @@ export function loadNotify() {
38
39
  return {
39
40
  slack: { webhookUrl: s.slack?.webhookUrl ?? null, botToken: s.slack?.botToken ?? null, channel: s.slack?.channel ?? null },
40
41
  phone: { server: s.phone?.server ?? NTFY, topic: s.phone?.topic ?? null, token: s.phone?.token ?? null },
42
+ // Where updates for stakeholders are posted (their channel), when not where the alerts go.
43
+ announce: { webhookUrl: s.announce?.webhookUrl ?? null },
41
44
  events: { ...EVENT_DEFAULTS, ...s.events },
42
45
  needsInputDelaySec: s.needsInputDelaySec ?? 60,
43
46
  waitingDelaySec: s.waitingDelaySec ?? 120,
@@ -51,6 +54,13 @@ const NTFY = 'https://ntfy.sh';
51
54
  const hasSlack = (n) => Boolean(n.slack.webhookUrl || (n.slack.botToken && n.slack.channel));
52
55
  const hasPhone = (n) => Boolean(n.phone.topic);
53
56
 
57
+ /** Where an update for stakeholders is posted: its own webhook, else the Slack the alerts use; null when neither. */
58
+ export function announceSlack(n = loadNotify()) {
59
+ if (n.announce.webhookUrl) return { slack: { webhookUrl: n.announce.webhookUrl, botToken: null, channel: null }, where: 'the updates webhook' };
60
+ if (hasSlack(n)) return { slack: n.slack, where: n.slack.botToken && n.slack.channel ? n.slack.channel : 'the alerts webhook' };
61
+ return null;
62
+ }
63
+
54
64
  /** A topic nobody can guess: on a public ntfy server, whoever knows the name can read the alerts. */
55
65
  export const newTopic = () => `agentmgr-${crypto.randomBytes(12).toString('base64url')}`;
56
66
 
@@ -61,6 +71,7 @@ export function saveNotify(patch) {
61
71
  ...patch,
62
72
  slack: { ...cur.slack, ...patch.slack },
63
73
  phone: { ...cur.phone, ...patch.phone },
74
+ announce: { ...cur.announce, ...patch.announce },
64
75
  events: { ...cur.events, ...patch.events },
65
76
  };
66
77
  fs.mkdirSync(paths.home, { recursive: true });
@@ -79,6 +90,7 @@ export function publicNotify() {
79
90
  slack: { webhookUrl: mask(n.slack.webhookUrl), botToken: mask(n.slack.botToken), channel: n.slack.channel },
80
91
  // The topic is shown: it is what you subscribe to on the phone, and these settings are local only.
81
92
  phone: { ...n.phone, token: mask(n.phone.token) },
93
+ announce: { webhookUrl: mask(n.announce.webhookUrl) },
82
94
  configured: hasSlack(n) || hasPhone(n),
83
95
  slackConfigured: hasSlack(n),
84
96
  };
@@ -334,7 +346,7 @@ export class Notifier {
334
346
 
335
347
  deliver(kind, agent, what, n, urgency = null) {
336
348
  if (!n.enabled || !n.events[kind]) return;
337
- const icon = { needsInput: ':raised_hand:', review: ':white_check_mark:', error: ':x:', waiting: ':hourglass_flowing_sand:', blocked: ':no_entry:', stuck: ':repeat:', conflict: ':crossed_swords:', question: ':question:', assistant: ':robot_face:', budget: ':moneybag:' }[kind];
349
+ const icon = { needsInput: ':raised_hand:', review: ':white_check_mark:', error: ':x:', waiting: ':hourglass_flowing_sand:', blocked: ':no_entry:', stuck: ':repeat:', conflict: ':crossed_swords:', question: ':question:', assistant: ':robot_face:', budget: ':moneybag:', announce: ':mega:' }[kind];
338
350
  const project = agent.projectInfo?.name ? ` (${agent.projectInfo.name})` : '';
339
351
  const link = this.linkFor(agent.id);
340
352
  const intent = n.includeIntent && agent.intent ? `\n> ${agent.intent.replace(/\s+/g, ' ').slice(0, 200)}` : '';
package/src/server.js CHANGED
@@ -21,6 +21,7 @@ import { PreReview } from './prereview.js';
21
21
  import { Screen } from './screen.js';
22
22
  import { Awake } from './awake.js';
23
23
  import { Files } from './files.js';
24
+ import { Announcer } from './announce.js';
24
25
  import { Autopilot } from './autopilot.js';
25
26
  import { Goals, goalMarkdown } from './goals.js';
26
27
  import { Budgets } from './budgets.js';
@@ -39,7 +40,7 @@ import { installed, listEngines, localEngineId, registerAcpEngines, registerEngi
39
40
  import { LOCAL_ENGINES } from './engines/local.js';
40
41
  import { Plugins, pluginSpecs } from './plugins.js';
41
42
  import { HubLink, linkUrls } from './hublink.js';
42
- import { Notifier, isWorkflowUrl, loadNotify, newTopic, publicNotify, saveNotify, sendAlert } from './notify.js';
43
+ import { Notifier, isWorkflowUrl, loadNotify, newTopic, publicNotify, saveNotify, sendAlert, sendSlack, announceSlack } from './notify.js';
43
44
  import { Previews, parseUrl } from './preview.js';
44
45
  import { LiveBrowser } from './livebrowser.js';
45
46
  import * as remote from './remote.js';
@@ -107,7 +108,7 @@ function isAllowedOrigin(origin, port) {
107
108
  const PUBLIC_REMOTE_API = new Set(['POST /api/login', 'GET /api/session']);
108
109
  // Updates are not here: a signed-in device (a phone) can install the newest release too. It only
109
110
  // ever installs an official release from where this copy came from (git tag or npm) and restarts.
110
- const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira(\/check)?$|isolation\/|screen\/settings$|editors$|agentkit\/connect$|agents\/[\w-]+\/open-in$|local-models\/settings$|shutdown$)/;
111
+ const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira(\/check)?$|isolation\/|screen\/settings$|announce\/slack$|editors$|agentkit\/connect$|agents\/[\w-]+\/open-in$|local-models\/settings$|shutdown$)/;
111
112
  const HOOK_PATH = '/api/hooks/agents';
112
113
  const REPORT_PATH = '/api/agentkit/report';
113
114
  const NO_REPO_KINDS = new Set(['general', 'assistant']);
@@ -264,6 +265,20 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
264
265
  return `${kind ? (/^[AEIOU]/i.test(kind) ? `an ${kind}` : `a ${kind}`) : 'a signed-in device'}${req.device?.ip ? ` (${String(req.device.ip).replace(/^::ffff:/, '')})` : ''}`;
265
266
  };
266
267
  const screen = new Screen({ config, onChange: (viewers) => pushScreen(viewers), log: (m) => console.log(`[agentmgr] ${m}`) });
268
+ // Announce (announce.js): when an agent finishes or opens a pull request, what to tell the people
269
+ // who asked is written and waits for you to send; the alert says it is ready.
270
+ const announcer = new Announcer({
271
+ manager,
272
+ config,
273
+ log: (m) => console.log(`[agentmgr] ${m}`),
274
+ prepare: async (id, milestone) => {
275
+ await manager.summarize(id, 'update');
276
+ const cur = store.get(id);
277
+ if (!cur?.docs?.update?.markdown) return;
278
+ manager.patch(id, { announce: { ...cur.announce, auto: { milestone, at: new Date().toISOString() }, sent: {}, dismissedAt: null } });
279
+ notifier.send('announce', manager.get(id), `${milestone === 'done' ? 'is finished' : 'opened a pull request'}: an update for the people who asked is ready for you to send`);
280
+ },
281
+ });
267
282
  // Awake (awake.js): the computer kept from sleeping, always or while an agent works.
268
283
  const awake = new Awake({ config, working: () => manager.list().some((a) => a.runtime?.busy), log: (m) => console.log(`[agentmgr] ${m}`) });
269
284
  const standup = new Standup({
@@ -587,6 +602,29 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
587
602
  return manager.document(req.params.id, req.params.kind);
588
603
  }),
589
604
  );
605
+ // An update for the people who asked: its link and recipients, what was sent, and the posting itself.
606
+ const announceView = () => ({ ...announcer.settings, slack: announceSlack()?.where ?? null, webhookUrl: publicNotify().announce.webhookUrl });
607
+ api.get('/announce/settings', wrap(() => announceView()));
608
+ api.put('/announce/settings', wrap((req) => {
609
+ saveConfig({ announce: announcer.change(req.body ?? {}) });
610
+ return announceView();
611
+ }));
612
+ // Where they are posted is a way out of this computer: set here only (local only, like the alerts).
613
+ api.put('/announce/slack', wrap((req) => {
614
+ const url = String(req.body?.webhookUrl ?? '').trim();
615
+ if (url && !okUrl(url)) throw fail(400, 'The webhook URL must be https://…');
616
+ saveNotify({ announce: { webhookUrl: url || null } });
617
+ return announceView();
618
+ }));
619
+ api.put('/agents/:id/announce', wrap((req) => manager.updateState(req.params.id, req.body ?? {})));
620
+ api.post('/agents/:id/announce/publish', wrap((req) => manager.publishUpdate(req.params.id)));
621
+ api.post('/agents/:id/announce/slack', wrap(async (req) => {
622
+ const to = announceSlack();
623
+ if (!to) throw fail(409, 'Slack is not set up: give a webhook for updates (agentmgr announce --webhook <url>), or set up Slack alerts');
624
+ const text = manager.updateSlackText(req.params.id, req.body?.text ?? null);
625
+ await sendSlack(text, to, text);
626
+ return { ...manager.updateState(req.params.id, { sent: 'slack' }), postedTo: to.where };
627
+ }));
590
628
  api.get('/agents/:id/specs/:name', wrap((req) => manager.specDoc(req.params.id, req.params.name)));
591
629
  // The agent's demo page, sandboxed: no access to this page's origin, and nothing loaded from elsewhere.
592
630
  api.get('/agents/:id/demo', (req, res) => {