create-pmos 0.359.0 → 0.361.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/package.json +25 -25
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/briefing-premium-sources-test.js +22 -0
- package/workspace/briefing-premium-work-test.js +9 -11
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +4 -2
- package/workspace/lib/agent-inbox.js +30 -7
- package/workspace/lib/first-input.js +44 -5
- package/workspace/lib/harness-health.js +95 -0
- package/workspace/lib/my-work-premium.js +4 -5
- package/workspace/lib/refresh-run.js +20 -0
- package/workspace/lib/refresh.js +38 -4
- package/workspace/lib/routes-inbox.js +5 -1
- package/workspace/lib/routes-my-work-premium.js +1 -0
- package/workspace/lib/routes-sources.js +4 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/premium-shell.js +19 -10
- package/workspace/public/pm/premium-work.js +11 -21
- package/workspace/public/pm/premium.css +21 -9
- package/workspace/public/premium-work.html +0 -1
- package/workspace/server.js +56 -14
- package/workspace/test-lists/harness-health.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.361.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,30 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.361.0",
|
|
37
|
+
"at": "2026-10-21T00:14:19.012Z",
|
|
38
|
+
"f": 2,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 960,
|
|
42
|
+
"t": "The morning brief runs on fresh sources; Sources says whether background work runs",
|
|
43
|
+
"s": "PMOS reads the pane after it presses Enter."
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"v": "0.360.0",
|
|
49
|
+
"at": "2026-10-20T13:51:06.028Z",
|
|
50
|
+
"f": 2,
|
|
51
|
+
"prs": [
|
|
52
|
+
{
|
|
53
|
+
"n": 959,
|
|
54
|
+
"t": "The Work queue has no Agents tab; agent state is a chip on the row and drafts wait in the bell",
|
|
55
|
+
"s": "There is no Agents tab."
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
35
59
|
{
|
|
36
60
|
"v": "0.359.0",
|
|
37
61
|
"at": "2026-10-20T13:30:13.743Z",
|
|
@@ -267,30 +291,6 @@
|
|
|
267
291
|
"s": "The rows stay as two columns, one row per label, at every width."
|
|
268
292
|
}
|
|
269
293
|
]
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
"v": "0.341.0",
|
|
273
|
-
"at": "2026-10-20T03:46:04.473Z",
|
|
274
|
-
"f": 2,
|
|
275
|
-
"prs": [
|
|
276
|
-
{
|
|
277
|
-
"n": 936,
|
|
278
|
-
"t": "The premium chat panel draws Claude's markdown, hides paste tags and quiets tool lines",
|
|
279
|
-
"s": "Claude's turns render as markdown, the way Claude Code shows them."
|
|
280
|
-
}
|
|
281
|
-
]
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
"v": "0.340.0",
|
|
285
|
-
"at": "2026-10-20T03:15:05.728Z",
|
|
286
|
-
"f": 2,
|
|
287
|
-
"prs": [
|
|
288
|
-
{
|
|
289
|
-
"n": 935,
|
|
290
|
-
"t": "A Briefing row when a /goal ends or needs the PM",
|
|
291
|
-
"s": "Each such goal adds one row to the Briefing list, built in the existing row pattern."
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
294
|
}
|
|
295
295
|
]
|
|
296
296
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
kernel-source: pmos@
|
|
2
|
-
assembled: 2026-10-
|
|
1
|
+
kernel-source: pmos@48e14dd7
|
|
2
|
+
assembled: 2026-10-21
|
|
3
3
|
mode: vendor
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T00:14:15Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T00:14:15Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-21T00:14:15Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/payload/state/log.md
CHANGED
|
@@ -116,6 +116,28 @@ const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
|
|
|
116
116
|
await ctx.close();
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
{ /* harness-health: the background line at the top of Sources, and the chip's dot takes its level */
|
|
120
|
+
const api = (await json('GET', '/api/sources')).body;
|
|
121
|
+
const h = api && api.health;
|
|
122
|
+
ok('H1 GET /api/sources carries the background health: a level, a line and the issues', h && ['ok', 'warn', 'bad'].includes(h.level) && typeof h.line === 'string' && h.line.length > 10 && Array.isArray(h.issues), JSON.stringify(h));
|
|
123
|
+
const shot = process.env.PMOS_SHOT_DIR || '';
|
|
124
|
+
for (const theme of ['light', 'dark']) {
|
|
125
|
+
const { ctx, page, errors } = await open({ theme, w: theme === 'dark' ? 390 : 1280, h: 844 });
|
|
126
|
+
await page.waitForFunction(() => /sdot (ok|warn|bad)/.test((document.querySelector('#srcDot') || {}).className || ''), null, { timeout: 15000 }).catch(() => {});
|
|
127
|
+
const dot = await page.$eval('#srcDot', (e) => e.className);
|
|
128
|
+
if (theme === 'light') await page.click('#srcChip'); else { await page.click('#moreBtn'); await page.click('#srcItem'); }
|
|
129
|
+
await page.waitForSelector('#srcHealth .hline', { timeout: 15000 }).catch(() => {});
|
|
130
|
+
const line = await page.$eval('#srcHealth', (e) => ({ text: e.textContent.trim(), dot: (e.querySelector('.sdot') || {}).className || '', w: Math.round(e.getBoundingClientRect().width), sw: document.documentElement.scrollWidth }));
|
|
131
|
+
if (theme === 'light') {
|
|
132
|
+
ok('H2 Sources opens with the background line on top, in the level\'s colour', line.text.startsWith(h.line.slice(0, 20)) && line.dot === 'sdot ' + (h.level === 'ok' ? 'ok' : h.level), JSON.stringify(line));
|
|
133
|
+
ok('H3 the chip\'s dot is red only when background work stopped', h.level === 'bad' ? dot === 'sdot bad' : dot !== 'sdot bad', dot);
|
|
134
|
+
} else ok('H4 on a phone the line fits: no sideways scroll', line.sw <= 390 && line.w > 0, JSON.stringify(line));
|
|
135
|
+
if (shot) { await sleep(1200); await page.screenshot({ path: path.join(shot, 'sources-health-' + theme + '.png') }); }
|
|
136
|
+
ok('H no page error (' + theme + ')', errors.length === 0, errors.join(' | '));
|
|
137
|
+
await ctx.close();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
119
141
|
{
|
|
120
142
|
const html = await (await fetch(BASE + '/')).text();
|
|
121
143
|
const nonce = (/<meta name="pmos-nonce" content="([^"]*)"/.exec(html) || [])[1] || '';
|
|
@@ -94,7 +94,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
94
94
|
const qtab = (k) => p.click(`#qTabs [data-tab="${k}"]`);
|
|
95
95
|
const q = await p.evaluate(() => ({ tabs: [...document.querySelectorAll('#qTabs .qtb')].map((b) => b.textContent), sel: [...document.querySelectorAll('#qTabs [aria-selected="true"]')].map((b) => b.dataset.tab), tops: new Set([...document.querySelectorAll('#qTabs .qtb')].map((b) => Math.round(b.getBoundingClientRect().top))).size, cap: document.querySelector('#qCap').textContent, first: [...document.querySelectorAll('.tgf')].map((x) => x.closest('.wrow').dataset.key), titles: [...document.querySelectorAll('#qBody .wtit')].map((x) => x.textContent.replace('Do this first', '')), chips: [...document.querySelectorAll('#qBody .due')].map((x) => x.textContent), od: [...document.querySelectorAll('#qBody .due.od')].length, ck: [...document.querySelectorAll('#qBody .wck')].map((b) => Math.round(b.getBoundingClientRect().height)), cols: getComputedStyle(document.querySelector('#qBody')).gridTemplateColumns.split(' ').length, old: ['#plate', '#agCard', '#trayCard'].filter((x) => document.querySelector(x)), title: document.querySelector('#hQueue').textContent }));
|
|
96
96
|
ok('M4 one Work queue card replaces On your plate, With agents and the tray', q.title === 'Work queue' && q.old.length === 0, JSON.stringify(q));
|
|
97
|
-
ok('M4
|
|
97
|
+
ok('M4 six tabs in one pill row with their counts (no Agents tab), and the card opens on Today', q.tabs.join() === 'Today3,Inbox4,Upcoming2,Someday1,Kept0,Done0' && q.sel.join() === 'today' && q.tops === 1, JSON.stringify(q));
|
|
98
98
|
ok('M4 Today holds its rows in two columns, with a due chip only where a date was set; the overdue one says so', q.cols === 2 && q.titles.length === 3 && q.titles[0] === 'Sign off the fit-out contractor shortlist' && q.chips.join() === 'Overdue · 15 Oct,Today' && q.od === 1, JSON.stringify(q));
|
|
99
99
|
ok('M4 "Do this first" tags the overdue item only, and a check circle is 44 px', q.first.length === 1 && q.first[0] === 'work:wbs:alpha:4.2' && q.ck.length === 3 && q.ck.every((h) => h >= 44), JSON.stringify([q.first, q.ck]));
|
|
100
100
|
const dec = await p.evaluate(() => { const b = document.querySelector('#qBody .wrow[data-key="work:wbs:alpha:4.2"] .wck'); const r = b.closest('.wrow'); return { dec: b.classList.contains('dec'), eye: !!b.querySelector('circle'), label: b.getAttribute('aria-label'), first: r.classList.contains('first'), tagBlock: getComputedStyle(r.querySelector('.tgf')).display, bar: getComputedStyle(r).boxShadow !== 'none', others: [...document.querySelectorAll('#qBody .wck')].filter((x) => x !== b).every((x) => !x.classList.contains('dec')) }; });
|
|
@@ -103,19 +103,15 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
103
103
|
const ib = await p.evaluate(() => ({ labels: [...document.querySelectorAll('#qBody .wsec .label')].map((x) => x.textContent), counts: [...document.querySelectorAll('#qBody .wsec em')].map((x) => x.textContent), glyphs: [...document.querySelectorAll('#qBody .inb .wgl')].map((x) => x.title), titles: [...document.querySelectorAll('#qBody .wtit')].map((x) => x.textContent), checks: document.querySelectorAll('#qBody .wck').length, note: document.querySelector('#qNote').textContent, focus: document.activeElement && document.activeElement.dataset.tab }));
|
|
104
104
|
ok('M4 Inbox holds what is new from Jira and Slack, then what you added, each with its source; nothing there has a check', ib.labels.join() === 'New from Jira and Slack,Added by you' && /^3 · counts to clear/.test(ib.counts[0]) && /^1 · not counted/.test(ib.counts[1]) && ib.glyphs.join() === 'Jira,Jira,Slack,Yours' && ib.titles[3] === 'Is the payment-step experiment worth another week?' && ib.checks === 0 && /counts to clear only once you place it/.test(ib.note) && ib.focus === 'inbox', JSON.stringify(ib));
|
|
105
105
|
await p.focus('#qTabs [data-tab="inbox"]'); await p.keyboard.press('ArrowRight');
|
|
106
|
-
ok('M4 the arrow keys move between tabs', await p.evaluate(() => document.activeElement.dataset.tab === '
|
|
106
|
+
ok('M4 the arrow keys move between tabs', await p.evaluate(() => document.activeElement.dataset.tab === 'upcoming' && document.querySelector('#qTabs [aria-selected="true"]').dataset.tab === 'upcoming'));
|
|
107
107
|
ok('M4 the add box has no Enter label', !(await p.evaluate(() => !!document.querySelector('#cap kbd'))));
|
|
108
108
|
ok('M4 no suggestion, no estimate and no demo label is drawn', !(await p.evaluate(() => /Accept all|~\d+ min|demo|fold the laundry|on the shelf|composts/i.test(document.querySelector('#queue').textContent))));
|
|
109
109
|
|
|
110
|
-
/* M5
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const tf = await tile('failed'), tr = await tile('ready'), tc = await tile('ready');
|
|
116
|
-
ok('M5 a count filters the list to that state, a second press shows every item again, and focus stays on the tile', tf.pressed.join() === 'failed' && tf.rows.length === 1 && /the run failed/.test(tf.rows[0]) && tr.pressed.join() === 'ready' && tr.rows.length === 1 && /draft ready to review/.test(tr.rows[0]) && tc.pressed.length === 0 && tc.rows.length === 3 && tc.focus === 'ready', JSON.stringify({ tf, tr, tc }));
|
|
117
|
-
await qtab('upcoming');
|
|
118
|
-
ok('M5 the counts show only on the Agents tab', await p.evaluate(() => document.querySelector('#qPipe').hidden && document.querySelectorAll('#qBody .wrow').length === 2));
|
|
110
|
+
/* M5 no Agents tab: the agent's state is a chip on the row, in the tab where the item waits (PM, 2026-10-20) */
|
|
111
|
+
const chips = () => p.evaluate(() => [...document.querySelectorAll('#qBody .wrow')].map((r) => [r.dataset.key, (r.querySelector('.wag') || {}).textContent || ''].join('=')).filter((x) => !/=$/.test(x)));
|
|
112
|
+
const upc = await chips();
|
|
113
|
+
await qtab('today'); const tdc = await chips();
|
|
114
|
+
ok('M5 a failed run shows "Agent stopped" on its Upcoming row; Today shows "Draft ready" and "Agent working"; there are no counts tiles', upc.join() === 'work:item-ccccccccccc2=Agent stopped' && tdc.sort().join() === 'work:item-bbbbbbbbbbb3=Agent working,work:wbs:alpha:4.2=Draft ready' && !(await p.evaluate(() => !!document.querySelector('#qPipe'))), JSON.stringify({ upc, tdc }));
|
|
119
115
|
await qtab('today');
|
|
120
116
|
|
|
121
117
|
/* M6 */
|
|
@@ -245,6 +241,8 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
245
241
|
await q.keyboard.press('Escape'); await sleep(300);
|
|
246
242
|
const pg = await q.evaluate(() => ({ over: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('.wck, .capb, .wrh, #revBtn, .fchip, .qtb')].filter((b) => !b.closest('[hidden]') && b.getBoundingClientRect().height < 44 && b.getBoundingClientRect().height > 0).map((b) => b.className + ':' + Math.round(b.getBoundingClientRect().height)) }));
|
|
247
243
|
ok(`M12 at 390 px (${theme}) the page has no sideways scroll and every control is 44 px`, !pg.over && pg.small.length === 0, JSON.stringify(pg));
|
|
244
|
+
const tb = await q.evaluate(() => ({ rows: new Set([...document.querySelectorAll('#qTabs .qtb')].map((b) => Math.round(b.getBoundingClientRect().top))).size, scrolls: getComputedStyle(document.querySelector('#qTabs')).overflowX }));
|
|
245
|
+
ok(`M12 at 390 px (${theme}) the Work queue tabs are one row that scrolls sideways, never two`, tb.rows === 1 && tb.scrolls === 'auto', JSON.stringify(tb));
|
|
248
246
|
/* the rail after the keyboard (Wawan's phone, 2026-10-20): leaving a field nudges the scroll by a pixel and back, so iOS places the fixed rail at the bottom again */
|
|
249
247
|
await q.evaluate(() => { const y = document.querySelector('#qBody').getBoundingClientRect().top + scrollY - 250; scrollTo(0, y); window.__ys = []; addEventListener('scroll', () => window.__ys.push(scrollY)); });
|
|
250
248
|
await sleep(200); const y0 = await q.evaluate(() => scrollY);
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.361.0",
|
|
4
|
+
"at": "2026-10-21T00:14:19.012Z",
|
|
5
|
+
"f": 2,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 960,
|
|
9
|
+
"t": "The morning brief runs on fresh sources; Sources says whether background work runs",
|
|
10
|
+
"s": "PMOS reads the pane after it presses Enter."
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"v": "0.360.0",
|
|
16
|
+
"at": "2026-10-20T13:51:06.028Z",
|
|
17
|
+
"f": 2,
|
|
18
|
+
"prs": [
|
|
19
|
+
{
|
|
20
|
+
"n": 959,
|
|
21
|
+
"t": "The Work queue has no Agents tab; agent state is a chip on the row and drafts wait in the bell",
|
|
22
|
+
"s": "There is no Agents tab."
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
2
26
|
{
|
|
3
27
|
"v": "0.359.0",
|
|
4
28
|
"at": "2026-10-20T13:30:13.743Z",
|
|
@@ -26,6 +26,8 @@ Every premium page has the same top bar. On the left is where you are, then a ro
|
|
|
26
26
|
|
|
27
27
|
**Sources** is a dialog that lists each tracked source (Repository, Initiatives, Calendar, Jira status, My work and Tracker items) with its own state and the time it was last read. Each source except the repository has **Refresh**, and **Refresh all** reads them all again. Slack and email are read as part of My work, so they have no row of their own. A source PMOS does not track has no row: the dialog shows only what PMOS can say it read.
|
|
28
28
|
|
|
29
|
+
The first line of **Sources** says whether PMOS's background work is running. When everything is on time it reads like "Background on · brief 06:52 · sources 06:49": the time today's morning brief was saved and the time of the last source read. It turns orange when something is late, such as a source that missed its scheduled read by more than an hour, or Git sync that keeps failing. It turns red when something stopped: no morning brief 45 minutes after its time, a source whose last run failed, a session whose prompt was typed but not sent, or background checks that stopped. The line gives the reason in plain words, and other problems are listed under it. The Sources dot takes the same colour, and a stop is also added to the bell, once a day. When the morning brief is due, it first refreshes Calendar, Jira and My work if they are more than 2 hours old, then builds from them. It waits for them for at most 30 minutes.
|
|
30
|
+
|
|
29
31
|
**Sessions** lists every running session beside the chat. When a chat dialog is full screen on a desktop, it has three panels: the session list, the conversation and the viewer.
|
|
30
32
|
|
|
31
33
|
- **Groups.** **Goals** holds a chat whose goal is started or waiting on you. **Yours** holds the other sessions you started. **Started by PMOS** holds schedules, the day run, the Driver, the Checker, notes, document syncs and other background runs. A PMOS session shows only when it needs you. The rest fold into one line, "N more working on their own · Show".
|
|
@@ -267,7 +269,7 @@ My work is the second place on the rail, at `/premium-work.html`. It reads the l
|
|
|
267
269
|
|
|
268
270
|
**Decide.** An inbox row shows a **Decide** button that opens the item, where you give it a day, put it in Someday or drop it.
|
|
269
271
|
|
|
270
|
-
**Work queue.** One full-width card holds everything you sort, as tabs in one row: **Today**, **Inbox**, **
|
|
272
|
+
**Work queue.** One full-width card holds everything you sort, as tabs in one row: **Today**, **Inbox**, **Upcoming**, **Someday**, **Kept** and **Done**. Each tab shows its count, and the card opens on Today (or on the first tab that has something). On a phone the tabs stay in one row: swipe the row sideways to see the rest. Rows sit in two columns, one column on a narrow screen. The left and right arrow keys move between tabs. **Inbox** shows what is new from Jira and Slack first, then what you added. **Kept** gathers items you pressed Keep on, and **Done** shows what you added and marked done in the last 7 days. An item shows in one place tab only. Kept is a mark on an item, not a place, so a kept item also shows where it was placed. The card replaces the earlier On your plate, With agents and tray cards.
|
|
271
273
|
|
|
272
274
|
**The item dialog.** The dialog shows one labelled field for each choice. Each field shows its value from the record and opens when you press it: **When** (Today, Later today, Tomorrow, Next week, Not before a date, Someday), **Waiting on**, **Who does it** (the steps) and **Priority · Due** (the edit panel). One bar at the bottom holds **Done**, with **Keep it** and **Drop it** beside it. Every action stays reachable.
|
|
273
275
|
|
|
@@ -280,7 +282,7 @@ My work is the second place on the rail, at `/premium-work.html`. It reads the l
|
|
|
280
282
|
- **Add** takes one line, read by the Work page's own parser (`Reply to Rina about SSO by Friday !p1`). A new item with no date waits in the **Inbox** tab, under Added by you. The card opens on that tab and the item's dialog opens at once, so you can place it. An item with a date goes where its date says.
|
|
281
283
|
- **What you added** and have not placed is not counted to clear until you place it (Do today, Later, Not yet, Waiting, Done or Drop).
|
|
282
284
|
- **The Work queue's place tabs** are Today, Inbox, Upcoming and Someday. A row shows where it came from (Yours, Jira, Slack, Board) and a due chip only when a date was set. The round check marks it done, with Undo for a few seconds. "Do this first" appears only on an overdue item.
|
|
283
|
-
- **
|
|
285
|
+
- **Agent state on a row.** There is no Agents tab. An item that an agent works on stays in the tab where it waits, and a chip on its row shows the agent's state: **Draft ready**, **Agent working** or **Agent stopped**. A draft that is ready and a run that stopped also wait in the bell (top right), so you see them even when the item is in Someday. A press in the bell opens that item on My work. A draft is labelled "Agent draft, not checked" and is never counted as done. The agent itself is started, stopped, edited, sent back or approved in the item's dialog (see below).
|
|
284
286
|
- **Waiting on others** lists who you wait for and for how long. There is no nudge.
|
|
285
287
|
- **An item's dialog** offers Done, Drop (with Undo), and Keep for an item untouched for seven days, in the bar at the bottom. Its fields hold the rest, each through the Work page's own route:
|
|
286
288
|
- **When** shows where the item is (Today, Inbox, Upcoming, Waiting, Someday, or Not before a day). It offers Today, Not yet (later today, tomorrow, next week), Not before a date and Someday.
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* agent-inbox.js — the bell's inbox of agent results that wait on the PM (initiative premium-agent-inbox).
|
|
3
3
|
*
|
|
4
|
-
* build({ proposals, goals, seen, now }) → { count, newCount, items, bundles, seenAt } PURE
|
|
4
|
+
* build({ proposals, goals, work, seen, now }) → { count, newCount, items, bundles, seenAt } PURE
|
|
5
|
+
* workOf(v) → the My work items whose agent has a draft ready or stopped, from GET /api/pm-items' answer
|
|
5
6
|
* readProposals(available) → [{ p, ws, product, targetTitle }] the open proposals the Agent proposals dialog shows
|
|
6
7
|
* readSeen(runtimeDir) · appendSeen(runtimeDir, { ids } | { all: true }, now)
|
|
7
8
|
* split(model, goals) → the Briefing model with its agent and goal rows moved to model.agent (N6)
|
|
8
9
|
*
|
|
9
|
-
* An item is one open Driver proposal (a board in Approve mode only, as the dialog reads it)
|
|
10
|
+
* An item is one open Driver proposal (a board in Approve mode only, as the dialog reads it), one goal row of goal-chat, or one My work item
|
|
11
|
+
* whose agent has a draft ready or stopped (PM, 2026-10-20: the Work queue has no Agents tab, so these wait here). Every word
|
|
10
12
|
* comes from the record. NEW is filed after the PM's last "Mark all seen" and not opened since; seen is not done: an item goes only
|
|
11
13
|
* when its record changes. The only write is the seen line, <runtime>/inbox-seen.jsonl. Nothing here decides or sends anything. */
|
|
12
14
|
const fs = require('fs');
|
|
@@ -17,6 +19,7 @@ const MAX_NEW = 30;
|
|
|
17
19
|
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
18
20
|
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
19
21
|
const WHAT = { problem: 'Problem statement', evidence: 'Evidence', sizing: 'Opportunity sizing', assumption: 'Riskiest assumption', stakeholders: 'Stakeholders', move: 'Move', note: 'Note', 'next-step': 'Next step', 'follow-up': 'Follow-up', doc: 'Document draft' };
|
|
22
|
+
const WORK_KIND = { ready: 'work-draft', failed: 'work-stopped' };
|
|
20
23
|
const GOAL_KIND = { waiting: 'goal-waiting', done: 'goal-done', stopped: 'goal-stopped' };
|
|
21
24
|
|
|
22
25
|
/** The key of a target's drafts row on the Briefing (lib/briefing-premium-drafts.js keyOf of the driver-needs run id): its conversation is the proposal's session. */
|
|
@@ -31,8 +34,24 @@ function proposalTitle(p) {
|
|
|
31
34
|
return clip(text ? word + ': ' + text : word, 160);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
/**
|
|
35
|
-
|
|
37
|
+
/** The My work items whose agent has a draft ready or stopped, from GET /api/pm-items' answer (v.work's lists and the PM's own items). Pure.
|
|
38
|
+
* The id carries the state and the round, so a new round is new again. at is the agent's last log line, else when it started. */
|
|
39
|
+
function workOf(v) {
|
|
40
|
+
const w = (v && v.work) || {}, seen = new Set(), out = [];
|
|
41
|
+
for (const k of ['inbox', 'today', 'upcoming', 'waiting', 'someday']) for (const it of w[k] || []) {
|
|
42
|
+
const a = it && it.agent, kind = a && WORK_KIND[a.state];
|
|
43
|
+
if (!kind || !it.id || seen.has(it.id)) continue;
|
|
44
|
+
seen.add(it.id);
|
|
45
|
+
const log = Array.isArray(a.log) ? a.log : [], last = log[log.length - 1], at = Date.parse((last && last.at) || a.started_at || '');
|
|
46
|
+
const rounds = log.filter((t) => t && t.body).length;
|
|
47
|
+
out.push({ id: it.id, title: it.title || '', state: a.state, list: k, round: rounds, at: Number.isFinite(at) ? at : null, asks: !!a.asks });
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
const PLACE_WORD = { inbox: 'Inbox', today: 'Today', upcoming: 'Upcoming', waiting: 'Waiting', someday: 'Someday' };
|
|
52
|
+
|
|
53
|
+
/** Pure. proposals: [{ p, ws, product, targetTitle }]; goals: goal-chat goalRowsAt rows; work: workOf(); seen: readSeen(). */
|
|
54
|
+
function build({ proposals = [], goals = [], work = [], seen = { all: 0, ids: new Set() }, now = Date.now() } = {}) {
|
|
36
55
|
const items = [];
|
|
37
56
|
for (const x of proposals) {
|
|
38
57
|
const p = x.p, at = Date.parse(p.at || '');
|
|
@@ -48,6 +67,10 @@ function build({ proposals = [], goals = [], seen = { all: 0, ids: new Set() },
|
|
|
48
67
|
if (!g || !g.chatKey) continue;
|
|
49
68
|
items.push({ id: g.key, kind: GOAL_KIND[g.goalState] || 'goal-done', title: clip(g.title + ': ' + (g.subject || ''), 160), at: Number.isFinite(g.at) ? g.at : null, ws: '', product: 'Chat', target: null, open: 'row:' + g.key, pws: '', session: g.key });
|
|
50
69
|
}
|
|
70
|
+
for (const w of work) {
|
|
71
|
+
if (!w || !w.id || !WORK_KIND[w.state]) continue;
|
|
72
|
+
items.push({ id: 'work:' + w.id + ':' + w.state + ':' + (w.round || 0), kind: WORK_KIND[w.state], title: clip(w.title, 160), at: w.at, ws: '', product: 'My work · ' + (PLACE_WORD[w.list] || 'Inbox'), target: null, open: 'item:' + w.id, pws: '', session: '' });
|
|
73
|
+
}
|
|
51
74
|
for (const it of items) it.isNew = (it.at == null || it.at > seen.all) && !seen.ids.has(it.id);
|
|
52
75
|
const fresh = items.filter((i) => i.isNew).sort((a, b) => (b.at || now) - (a.at || now));
|
|
53
76
|
const rest = items.filter((i) => !i.isNew);
|
|
@@ -60,7 +83,7 @@ function build({ proposals = [], goals = [], seen = { all: 0, ids: new Set() },
|
|
|
60
83
|
}
|
|
61
84
|
const bundles = [...by.values()].sort((a, b) => (a.oldest || now) - (b.oldest || now)).map((b) => ({
|
|
62
85
|
key: b.key, title: b.title, product: b.product, count: b.n, oldest: b.oldest, open: b.open, pws: b.pws,
|
|
63
|
-
sub: b.kind === 'target' ? plural(b.n, 'proposal', 'proposals') : b.kind === 'goal-waiting' ? 'Goal waits on you' : 'Goal to check',
|
|
86
|
+
sub: b.kind === 'target' ? plural(b.n, 'proposal', 'proposals') : b.kind === 'work-draft' ? 'Agent draft to review' : b.kind === 'work-stopped' ? 'Agent stopped' : b.kind === 'goal-waiting' ? 'Goal waits on you' : 'Goal to check',
|
|
64
87
|
}));
|
|
65
88
|
const ages = items.map((i) => i.at).filter((v) => v != null);
|
|
66
89
|
return { count: items.length, newCount: fresh.length, items: fresh.slice(0, MAX_NEW), more: Math.max(0, fresh.length - MAX_NEW), bundles, oldest: ages.length ? Math.min(...ages) : null, seenAt: seen.all || null };
|
|
@@ -99,7 +122,7 @@ function readSeen(runtimeDir) {
|
|
|
99
122
|
}
|
|
100
123
|
return seen;
|
|
101
124
|
}
|
|
102
|
-
const ID_RE = /^(prop:[^\s]{1,200}|goal:[^\s]{1,200})$/;
|
|
125
|
+
const ID_RE = /^(prop:[^\s]{1,200}|goal:[^\s]{1,200}|work:[^\s]{1,200})$/;
|
|
103
126
|
/** The check of a body: null when it is good, else the reason. Pure. */
|
|
104
127
|
function badSeen(b) {
|
|
105
128
|
if (!b || typeof b !== 'object') return 'a body is required';
|
|
@@ -132,4 +155,4 @@ function split(model, goals = []) {
|
|
|
132
155
|
};
|
|
133
156
|
}
|
|
134
157
|
|
|
135
|
-
module.exports = { build, readProposals, readSeen, appendSeen, badSeen, split, draftsRowKey, SEEN, MAX_NEW };
|
|
158
|
+
module.exports = { build, workOf, readProposals, readSeen, appendSeen, badSeen, split, draftsRowKey, SEEN, MAX_NEW };
|
|
@@ -12,8 +12,17 @@
|
|
|
12
12
|
* lines stay one prompt. Otherwise it is sent as typed text.
|
|
13
13
|
* 3. ENTER: SUBMIT_MS later, Enter alone. A bracketed-paste program that printed nothing after that Enter gets Enter once
|
|
14
14
|
* more after RETRY_MS, because the first one can land while the paste is still being read.
|
|
15
|
+
*
|
|
16
|
+
* THE SCREEN (harness-health, 2026-10-21). "Printed nothing" is not enough: on 2026-10-21 both 06:45 morning briefs sat with
|
|
17
|
+
* their whole prompt in Claude Code's input box, because an Enter that is swallowed still redraws the box. The ready test was
|
|
18
|
+
* also fooled: the shell that starts the agent turns bracketed paste on and goes quiet before Claude Code has drawn its box.
|
|
19
|
+
* Claude Code keeps what was typed while it started and shows it in its box, so a prompt typed early is not lost; only its Enter
|
|
20
|
+
* is. So when the caller passes `screen` (the pane's visible text, from tmux capture-pane), the box is read after the Enter, at
|
|
21
|
+
* each of CHECK_MS. When it still holds the prompt, Enter is pressed again. When it still does after the last check, the
|
|
22
|
+
* delivery ends as 'unsent' so the caller can say so instead of leaving the session idle. Without `screen` (a plain shell, a
|
|
23
|
+
* test) the plan is as before.
|
|
15
24
|
* The clock and the timers are injected, so the plan is tested without waiting. No I/O of its own: it writes only through
|
|
16
|
-
* `write`.
|
|
25
|
+
* `write` and reads only through `screen`.
|
|
17
26
|
*/
|
|
18
27
|
|
|
19
28
|
const MIN_MS = 1200;
|
|
@@ -23,6 +32,7 @@ const MAX_MS = 20000;
|
|
|
23
32
|
const POLL_MS = 200;
|
|
24
33
|
const SUBMIT_MS = 500;
|
|
25
34
|
const RETRY_MS = 1500;
|
|
35
|
+
const CHECK_MS = Object.freeze([4000, 12000]); // after the Enter: read the input box at these delays, Enter again if it still holds the prompt
|
|
26
36
|
const PASTE_ON = '\x1b[?2004h';
|
|
27
37
|
const PASTE_OFF = '\x1b[?2004l';
|
|
28
38
|
|
|
@@ -41,6 +51,22 @@ function ready({ now, t0, lastOutputAt, firstOut }) {
|
|
|
41
51
|
return now - lastOutputAt >= QUIET_MS;
|
|
42
52
|
}
|
|
43
53
|
|
|
54
|
+
const BOX = /^\s*❯(?:\s|$)/;
|
|
55
|
+
const squash = (t) => String(t || '').replace(/\s+/g, '');
|
|
56
|
+
/** The text in the agent's input box: what follows ❯ on the LAST such line of the visible screen, or null when there is no box. */
|
|
57
|
+
function boxText(screen) {
|
|
58
|
+
const lines = String(screen || '').split('\n');
|
|
59
|
+
for (let i = lines.length - 1; i >= 0; i--) if (BOX.test(lines[i])) return lines[i].replace(BOX, '').trim();
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** Does the input box still hold (part of) `text`? The box may show the start or, for a long prompt, a later part. Spaces are
|
|
63
|
+
* ignored because the box wraps the prompt at its own width. */
|
|
64
|
+
function stillInBox(screen, text) {
|
|
65
|
+
const b = squash(boxText(screen));
|
|
66
|
+
if (b.length < 8) return false;
|
|
67
|
+
return squash(text).includes(b.slice(0, 40));
|
|
68
|
+
}
|
|
69
|
+
|
|
44
70
|
/** Split a first input into the text and whether it ended with Enter. */
|
|
45
71
|
function splitInput(input) {
|
|
46
72
|
const s = String(input == null ? '' : input);
|
|
@@ -58,6 +84,8 @@ function deliver(s, input, o = {}) {
|
|
|
58
84
|
const now = o.now || (() => Date.now());
|
|
59
85
|
const later = o.setTimeout || setTimeout;
|
|
60
86
|
const done = typeof o.onDone === 'function' ? o.onDone : () => {};
|
|
87
|
+
const screenFn = typeof o.screen === 'function' ? o.screen : null;
|
|
88
|
+
const screen = () => { try { return String(screenFn() || ''); } catch { return ''; } };
|
|
61
89
|
const { text, enter } = splitInput(input);
|
|
62
90
|
if (!s || (!text && !enter)) { done('nothing'); return; }
|
|
63
91
|
const t0 = now();
|
|
@@ -65,6 +93,17 @@ function deliver(s, input, o = {}) {
|
|
|
65
93
|
let firstOut = 0;
|
|
66
94
|
const alive = () => s.pty && s.state !== 'exited';
|
|
67
95
|
const write = (d) => { try { s.pty.write(d); return true; } catch { return false; } };
|
|
96
|
+
// after the Enter: read the box at each CHECK_MS; Enter again while it still holds the prompt
|
|
97
|
+
const check = (i, outcome) => {
|
|
98
|
+
if (!screenFn || !text || i >= CHECK_MS.length) { done(outcome); return; }
|
|
99
|
+
later(() => {
|
|
100
|
+
if (!alive()) { done('gone'); return; }
|
|
101
|
+
if (!stillInBox(screen(), text)) { done(outcome); return; }
|
|
102
|
+
write('\r');
|
|
103
|
+
if (i + 1 < CHECK_MS.length) { check(i + 1, 'resubmitted'); return; }
|
|
104
|
+
later(() => { done(alive() && stillInBox(screen(), text) ? 'unsent' : 'resubmitted'); }, CHECK_MS[0]);
|
|
105
|
+
}, CHECK_MS[i] - (i ? CHECK_MS[i - 1] : 0));
|
|
106
|
+
};
|
|
68
107
|
const tick = () => {
|
|
69
108
|
if (!alive()) { done('gone'); return; }
|
|
70
109
|
if (!firstOut && (s.lastOutputAt || 0) > base) firstOut = s.lastOutputAt;
|
|
@@ -76,14 +115,14 @@ function deliver(s, input, o = {}) {
|
|
|
76
115
|
if (!alive()) { done('gone'); return; }
|
|
77
116
|
const before = s.lastOutputAt || 0;
|
|
78
117
|
write('\r');
|
|
79
|
-
if (!paste) {
|
|
118
|
+
if (!paste) { check(0, 'submitted'); return; }
|
|
80
119
|
later(() => {
|
|
81
|
-
if (alive() && (s.lastOutputAt || 0) <= before) { write('\r');
|
|
82
|
-
|
|
120
|
+
if (alive() && (s.lastOutputAt || 0) <= before) { write('\r'); check(0, 'resubmitted'); return; }
|
|
121
|
+
check(0, 'submitted');
|
|
83
122
|
}, RETRY_MS);
|
|
84
123
|
}, text ? SUBMIT_MS : 0);
|
|
85
124
|
};
|
|
86
125
|
later(tick, POLL_MS);
|
|
87
126
|
}
|
|
88
127
|
|
|
89
|
-
module.exports = { deliver, ready, pasteOn, splitInput, MIN_MS, QUIET_MS, SILENT_MS, MAX_MS, SUBMIT_MS, RETRY_MS };
|
|
128
|
+
module.exports = { deliver, ready, pasteOn, splitInput, boxText, stillInBox, MIN_MS, QUIET_MS, SILENT_MS, MAX_MS, SUBMIT_MS, RETRY_MS, CHECK_MS };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* harness-health.js — one line that says whether PMOS's background work is running (initiative harness-health).
|
|
3
|
+
*
|
|
4
|
+
* of({ now, settings, state, log, briefAt, sessions, lastTick, win }) → { level, line, issues: [{ level, key, text }] } PURE.
|
|
5
|
+
*
|
|
6
|
+
* The PM asked on 2026-10-21 "how do I know the agent harness is working": the morning brief had sat unsent since 06:45 and
|
|
7
|
+
* nothing on any page said so. This reads what the refresh engine already keeps (lib/refresh.js settings, state and log), the
|
|
8
|
+
* day's brief file and the live sessions, and answers with one level:
|
|
9
|
+
* ok every background run is on time. The line names the last brief and the last source read: "Background on · brief 06:52 · sources 06:49".
|
|
10
|
+
* warn something is late: a source missed its slot by more than an hour, or Git sync keeps failing.
|
|
11
|
+
* bad something stopped: the background tick is not running, today's brief is missing 45 minutes after its time, a source's
|
|
12
|
+
* last run failed, or a session's prompt was typed but never sent.
|
|
13
|
+
* Every issue is a plain sentence with a time; `line` is the worst one. Nothing here reads a file or the clock.
|
|
14
|
+
*
|
|
15
|
+
* now ms
|
|
16
|
+
* settings refresh.json, with defaults (lib/refresh.js withDefaults)
|
|
17
|
+
* state refresh-state.json
|
|
18
|
+
* log the folded log (lib/refresh.js foldLog)
|
|
19
|
+
* briefAt ms the brief for today was saved, or 0
|
|
20
|
+
* sessions [{ id, name, origin, state, firstInput: { result } }]: the live sessions
|
|
21
|
+
* lastTick ms of the last background tick, or 0 before the first
|
|
22
|
+
* win the working hours { start, end }
|
|
23
|
+
*/
|
|
24
|
+
const R = require('./refresh.js');
|
|
25
|
+
|
|
26
|
+
const MIN = 60000;
|
|
27
|
+
const TICK_LATE_MS = 5 * MIN; // the background tick runs every minute
|
|
28
|
+
const BRIEF_LATE_MS = 45 * MIN; // a brief takes a few minutes; 45 leaves room for the sources it refreshes first (at most 30)
|
|
29
|
+
const MISSED_MS = 60 * MIN; // a source slot with no run an hour on was missed
|
|
30
|
+
const RANK = { ok: 0, warn: 1, bad: 2 };
|
|
31
|
+
|
|
32
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
33
|
+
const hm = (ms) => { const d = new Date(ms); return pad(d.getHours()) + ':' + pad(d.getMinutes()); };
|
|
34
|
+
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
35
|
+
const ms = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? t : 0; };
|
|
36
|
+
const sameDay = (a, b) => new Date(a).toDateString() === new Date(b).toDateString();
|
|
37
|
+
|
|
38
|
+
function of({ now, settings, state = {}, log, briefAt = 0, sessions = [], lastTick = 0, win } = {}) {
|
|
39
|
+
const issues = [];
|
|
40
|
+
const add = (level, key, text) => issues.push({ level, key, text });
|
|
41
|
+
const set = settings || R.withDefaults({});
|
|
42
|
+
const runs = (id) => (log ? log.runs(id, 10) : []).filter((r) => r.result !== 'skipped');
|
|
43
|
+
|
|
44
|
+
if (lastTick && now - lastTick > TICK_LATE_MS) add('bad', 'tick', `Background checks stopped at ${hm(lastTick)}. Restart PMOS to start them again.`);
|
|
45
|
+
|
|
46
|
+
for (const s of sessions) {
|
|
47
|
+
if (s.state !== 'exited' && s.firstInput && s.firstInput.result === 'unsent') add('bad', 'unsent:' + s.id, `${clip(s.name, 40)} is idle: its prompt was typed but not sent. Open it and press Enter.`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// today's morning brief
|
|
51
|
+
const bset = set.sources.brief;
|
|
52
|
+
const bslot = bset && bset.on ? R.lastSlot(bset.s, now, win) : null;
|
|
53
|
+
if (bslot != null && sameDay(bslot, now) && !(briefAt && sameDay(briefAt, now)) && now - bslot > BRIEF_LATE_MS) {
|
|
54
|
+
const bst = state.brief || {};
|
|
55
|
+
const open = Object.values(bst.open || {})[0];
|
|
56
|
+
const last = runs('brief').find((r) => ms(r.start_at) >= bslot - MIN);
|
|
57
|
+
let why;
|
|
58
|
+
if (open) why = `Morning brief started at ${hm(open.at)} and has not finished.`;
|
|
59
|
+
else if (bst.waiting_since) why = `Morning brief has waited for its sources since ${hm(bst.waiting_since)}.`;
|
|
60
|
+
else if (last && last.result && last.result !== 'done') why = `Morning brief ${last.result === 'interrupted' ? 'was stopped' : 'failed'} at ${hm(ms(last.end_at))}${last.error ? ': ' + clip(last.error, 90) : '.'}`;
|
|
61
|
+
else why = `Morning brief did not start at ${hm(bslot)}.`;
|
|
62
|
+
add('bad', 'brief', why);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// each skill source: a failed last run, or a slot that passed with no run
|
|
66
|
+
for (const src of R.SOURCES.filter((x) => x.run === 'skill' && x.id !== 'brief')) {
|
|
67
|
+
const x = set.sources[src.id]; if (!x || !x.on) continue;
|
|
68
|
+
const last = runs(src.id)[0];
|
|
69
|
+
if (last && last.end_at && ['failed', 'interrupted'].includes(last.result) && !(state[src.id] || {}).retry_at) {
|
|
70
|
+
add('bad', 'failed:' + src.id, `${src.label} ${last.result === 'interrupted' ? 'was stopped' : 'failed'} at ${hm(ms(last.end_at))}${last.error ? ': ' + clip(last.error, 90) : '.'}`);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const slot = R.lastSlot(x.s, now, win);
|
|
74
|
+
if (slot == null || now - slot < MISSED_MS) continue;
|
|
75
|
+
const st = state[src.id] || {};
|
|
76
|
+
const ran = Math.max(st.started_at || 0, ...runs(src.id).map((r) => ms(r.start_at)));
|
|
77
|
+
if (ran < slot && !Object.keys(st.open || {}).length) add('warn', 'missed:' + src.id, `${src.label} missed its ${hm(slot)} read.`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const sync = runs('sync')[0];
|
|
81
|
+
if (set.sources.sync && set.sources.sync.on && sync && sync.result === 'failed') {
|
|
82
|
+
const gone = /repository '(?:https?:\/\/[^/]+\/)?([^']+?)(?:\.git)?\/?' not found/.exec(sync.error || '');
|
|
83
|
+
add('warn', 'sync', gone ? `Git sync is failing: ${gone[1]} was not found. Check that remote's address or your access.` : `Git sync is failing: ${clip(sync.error || 'see Settings, Data refresh', 90)}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
issues.sort((a, b) => RANK[b.level] - RANK[a.level]);
|
|
87
|
+
const level = issues.length ? issues[0].level : 'ok';
|
|
88
|
+
if (issues.length) return { level, line: issues[0].text, issues };
|
|
89
|
+
const lastBrief = briefAt && sameDay(briefAt, now) ? 'brief ' + hm(briefAt) : 'no brief yet today';
|
|
90
|
+
const reads = R.SOURCES.filter((x) => x.run === 'skill' && x.id !== 'brief').map((x) => runs(x.id).find((r) => r.result === 'done')).filter(Boolean).map((r) => ms(r.end_at));
|
|
91
|
+
const src = reads.length ? 'sources ' + (sameDay(Math.max(...reads), now) ? hm(Math.max(...reads)) : 'read ' + new Date(Math.max(...reads)).toDateString().slice(4, 10)) : 'sources not read yet';
|
|
92
|
+
return { level, line: `Background on · ${lastBrief} · ${src}`, issues };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = { of, TICK_LATE_MS, BRIEF_LATE_MS, MISSED_MS };
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* The PM's own unsorted captures (an item the PM added, source local, that no date or flag has placed yet) wait in the inbox beside the items
|
|
10
10
|
* from Jira and Slack. They are not counted as work to clear until the PM places it. The shelf, the capacity figure and the week bars of the mockup
|
|
11
11
|
* have no record behind them and are not built (PRD D15, amended by the PM 2026-10-17 to add the captures).
|
|
12
|
-
* The Work queue (PM, 2026-10-19): one card holds what On your plate
|
|
13
|
-
* Kept, which is a mark on an item and not a place.
|
|
12
|
+
* The Work queue (PM, 2026-10-19): one card holds what On your plate and the tray held, as tabs. No item shows in two tabs except
|
|
13
|
+
* Kept, which is a mark on an item and not a place. There is no Agents tab (PM, 2026-10-20): an item an agent works on stays in the tab where it
|
|
14
|
+
* waits, and its row carries the agent's state (r.agent); a draft ready or a run stopped also waits in the bell (lib/agent-inbox.js).
|
|
14
15
|
* An agent draft is the agent's text: it is shown labelled and is never counted as done. */
|
|
15
16
|
|
|
16
17
|
const WORDS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'];
|
|
@@ -203,7 +204,7 @@ function build({ v, now }) {
|
|
|
203
204
|
const queue = queueOf();
|
|
204
205
|
const rowsAll = [...new Set([].concat(...sections.map((s) => s.rows), waitingRows, agentRows, ...Object.values(agentBy).map((g) => g.rows), trayRows, ...queue.tabs.map((t) => [].concat(...t.groups.map((g) => g.rows)))))]; // the queue's tabs reuse the section rows
|
|
205
206
|
/* The Work queue: one card, one tab for each place a thing waits, from the item records alone. Today, Inbox (new from Jira and Slack, then what
|
|
206
|
-
* the PM added),
|
|
207
|
+
* the PM added), Upcoming, Someday, Kept (a Keep press was recorded) and Done (done in the last
|
|
207
208
|
* 7 days). Answers and ideas an agent files on its own have no record, so no tab holds them. */
|
|
208
209
|
function queueOf() {
|
|
209
210
|
const loc = (v.items || all.map((x) => x.it)).filter(isLocal);
|
|
@@ -214,13 +215,11 @@ function build({ v, now }) {
|
|
|
214
215
|
const kept = loc.filter((it) => !it.done && it.kept_at), done = loc.filter((it) => it.done && String(it.done_at || '').slice(0, 10) >= week);
|
|
215
216
|
const placeOf = (it) => (it.done ? 'done' : (all.find((x) => x.it.id === it.id) || { list: 'tray' }).list);
|
|
216
217
|
const recRows = (items) => items.slice(0, MAX_PER).map((it) => rowOf(it, placeOf(it), v, reviewIds.has(it.id), focusIds));
|
|
217
|
-
const agN = ready.length + running.length + failed.filter((x) => !ready.includes(x)).length;
|
|
218
218
|
const inbox = sec('inbox');
|
|
219
219
|
const tabs = [
|
|
220
220
|
listTab('today', 'Today', 'What you placed for today. "Do this first" marks an overdue item only.'),
|
|
221
221
|
{ key: 'inbox', label: 'Inbox', n: inbox.n + tray.length, groups: [grp('new', 'New from Jira and Slack', inbox.n, inbox.rows, inbox.more, 'counts to clear'), grp('mine', 'Added by you', tray.length, trayRows, Math.max(0, tray.length - MAX_PER), 'not counted until you place it')],
|
|
222
222
|
note: 'Everything new or not yet placed. Open one to place it: Today, later, waiting on someone, or drop it. What you added counts to clear only once you place it.' },
|
|
223
|
-
{ key: 'agents', label: 'Agents', n: agN, groups: [grp('agents', '', agN, agentRows, Math.max(0, agN - MAX_PER))], by: agentBy, counts: { running: running.length, failed: failed.length, ready: ready.length }, note: HOLD.agent },
|
|
224
223
|
listTab('upcoming', 'Upcoming', 'Items with a later date.'),
|
|
225
224
|
listTab('someday', 'Someday', 'Items you parked with no date.'),
|
|
226
225
|
{ key: 'kept', label: 'Kept', n: kept.length, groups: [grp('kept', '', kept.length, recRows(kept), Math.max(0, kept.length - MAX_PER))], note: 'Items you pressed Keep on. They stay where they were placed; this tab gathers them.' },
|
|
@@ -29,6 +29,7 @@ function create(host) {
|
|
|
29
29
|
const expect = new Map(); // source id → { trigger, note, inputs } for the start the engine itself is making now
|
|
30
30
|
const jobWait = new Map(); // job id → ms it started waiting for an input
|
|
31
31
|
let lastPrune = 0;
|
|
32
|
+
let lastRetire = 0;
|
|
32
33
|
|
|
33
34
|
/* ── settings, with the one-time move of the seed schedules (R3) ── */
|
|
34
35
|
function settings() {
|
|
@@ -41,6 +42,12 @@ function create(host) {
|
|
|
41
42
|
s = R.withDefaults(m.settings);
|
|
42
43
|
} catch (e) { warn('refresh settings (moving the schedules)', e); }
|
|
43
44
|
}
|
|
45
|
+
// harness-health: a schedules.json entry of a managed skill that is still on (another workspace's morning brief) ends here.
|
|
46
|
+
if (s.migrated && now() - lastRetire >= 60000) {
|
|
47
|
+
lastRetire = now();
|
|
48
|
+
try { const r = R.retireLegacy(s, host.schedules.read()); if (r.retired.length) { host.schedules.write(r.schedules); warn('refresh settings', { message: 'ended the old schedules ' + r.retired.join(', ') + ': Settings › Data refresh runs them' }); } }
|
|
49
|
+
catch (e) { warn('refresh settings (ending old schedules)', e); }
|
|
50
|
+
}
|
|
44
51
|
// The day check's minutes have one home: the proactive settings.
|
|
45
52
|
const every = String(((host.proactive() || {}).dayCheck || {}).every || '60');
|
|
46
53
|
s.sources.daycheck.s = { kind: 'every', every: ['30', '60'].includes(every) ? every : '60', work: true };
|
|
@@ -173,6 +180,19 @@ function create(host) {
|
|
|
173
180
|
}
|
|
174
181
|
continue;
|
|
175
182
|
}
|
|
183
|
+
// harness-health: a scheduled run first refreshes its old inputs, then waits for them (the input wait above, at most 30 min).
|
|
184
|
+
if (['schedule', 'catch-up'].includes(d.trigger) && !(cur[src.id] || {}).waiting_since) {
|
|
185
|
+
const f = log();
|
|
186
|
+
const lastDone = (id) => { const runs = f.runs(id, 20) || []; const l = runs.find((r) => r.result === 'done'); return l ? Date.parse(l.end_at || l.start_at) || 0 : 0; };
|
|
187
|
+
const first = R.refreshFirst(src, { now: t, settings: set, inputState: inputStateFn(set, cur, t), lastDone });
|
|
188
|
+
const begun = first.filter((id) => { const x = R.BY_ID.get(id); return start(x, (set.sources[id] && set.sources[id].ws) || ws, { trigger: d.trigger, note: 'Refreshed first, before ' + src.label }).ok; });
|
|
189
|
+
if (begun.length) {
|
|
190
|
+
const nx = R.readState(dir);
|
|
191
|
+
nx[src.id] = { ...(nx[src.id] || {}), waiting_since: t, waiting_for: begun, waiting_why: null };
|
|
192
|
+
R.writeState(dir, nx);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
176
196
|
start(src, ws, { trigger: d.trigger, slot: d.slot, note: d.note });
|
|
177
197
|
}
|
|
178
198
|
if (t - lastPrune > PRUNE_EVERY_MS) {
|
package/workspace/lib/refresh.js
CHANGED
|
@@ -31,13 +31,14 @@ const SKILL_KINDS = Object.freeze(['manual', 'every', 'daily', 'weekdays', 'week
|
|
|
31
31
|
const EVERY = Object.freeze(['15', '30', '60', '120', '240']);
|
|
32
32
|
const WAIT_MS = 30 * 60 * 1000; // a refresh waits at most this long for its inputs
|
|
33
33
|
const LATE_MS = 15 * 60 * 1000; // a slot older than this when first seen was missed (PMOS was closed)
|
|
34
|
+
const FIRST_MS = 2 * 3600 * 1000; // harness-health: a scheduled run first refreshes its skill inputs whose last good read is older than this
|
|
34
35
|
const MAX_TIMES = 4;
|
|
35
36
|
|
|
36
37
|
/* The sources. `fresh` names the lib/freshness.js row whose age and detail this source shares; `copy` names the files a done run keeps. */
|
|
37
38
|
const SOURCES = Object.freeze([
|
|
38
39
|
{ id: 'calendar', label: 'Calendar', group: 'tools', ic: 'cal', run: 'skill', skill: 'calendar-sync', how: 'tool', fresh: 'calendar',
|
|
39
40
|
what: 'Events from your calendars, for Calendar, the phone day, meeting focus and meeting notes.', uses: [],
|
|
40
|
-
impact: 'Calendar, the phone day, meeting focus
|
|
41
|
+
impact: 'Calendar, the phone day, meeting focus, meeting notes and the Briefing\'s Today card show the last import.',
|
|
41
42
|
def: { kind: 'daily', times: ['06:30', '12:30'] } },
|
|
42
43
|
{ id: 'jira', label: 'Jira tickets and sprints', group: 'tools', ic: 'org', run: 'skill', skill: 'jira-sync', how: 'tool', fresh: 'jira', copy: 'jira',
|
|
43
44
|
what: 'The status of every pushed ticket, the active sprints, and each sprint\'s goal and team summary.', uses: [],
|
|
@@ -52,7 +53,7 @@ const SOURCES = Object.freeze([
|
|
|
52
53
|
impact: 'The bi-weekly report says the tracker was not refreshed.',
|
|
53
54
|
def: { kind: 'weekly', day: 'Fri', times: ['15:30'] } },
|
|
54
55
|
{ id: 'brief', label: 'Morning briefing', group: 'pmos', ic: 'sun', run: 'skill', skill: 'morning-brief', how: 'bg',
|
|
55
|
-
what: 'Your Briefing for the day, ranked by what needs you first.', uses: ['mywork'],
|
|
56
|
+
what: 'Your Briefing for the day, ranked by what needs you first. When it is due, the sources it is built on that are older than 2 hours are refreshed first.', uses: ['calendar', 'jira', 'mywork'],
|
|
56
57
|
impact: 'No new Briefing for the day, and the day check has nothing to update.',
|
|
57
58
|
def: { kind: 'daily', times: ['06:45'] } },
|
|
58
59
|
{ id: 'daycheck', label: 'Day check', group: 'pmos', ic: 'clock', run: 'job', how: 'bg',
|
|
@@ -212,6 +213,39 @@ function migrate(settings, schedules, { homeWs } = {}) {
|
|
|
212
213
|
return { settings: next, schedules: list, adopted };
|
|
213
214
|
}
|
|
214
215
|
|
|
216
|
+
/**
|
|
217
|
+
* The schedules.json entries that still run a managed skill after the move (harness-health). migrate() adopted the entries of ONE
|
|
218
|
+
* workspace; an entry of the same skill in another workspace stayed on and kept starting its own run, so two morning briefs started
|
|
219
|
+
* at 06:45 every day, outside the refresh order. Once the settings are migrated, every such entry ends with the same reason.
|
|
220
|
+
* → { schedules, retired: [id] }. Pure: the caller writes the list.
|
|
221
|
+
*/
|
|
222
|
+
function retireLegacy(settings, schedules) {
|
|
223
|
+
const list = (schedules || []).map((x) => ({ ...x }));
|
|
224
|
+
const retired = [];
|
|
225
|
+
if (!settings || !settings.migrated) return { schedules: list, retired };
|
|
226
|
+
for (const x of list) {
|
|
227
|
+
if (x.enabled === false || x.endedReason || !SKILL_OF.has(x.skill)) continue;
|
|
228
|
+
x.enabled = false; x.endedReason = 'Moved to Settings › Data refresh'; x.nextRun = null;
|
|
229
|
+
retired.push(x.id);
|
|
230
|
+
}
|
|
231
|
+
return { schedules: list, retired };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The inputs a scheduled run of `src` refreshes before it starts (harness-health): its skill inputs that are on, not running or
|
|
236
|
+
* waiting, and whose last good read is older than FIRST_MS. The morning brief at 06:45 read calendar, Jira and work assigned to you
|
|
237
|
+
* as they were at 09:00 the day before, because those refresh on their own later times. → [id]
|
|
238
|
+
* ctx { now, settings, inputState(id), lastDone(id) → ms|0 }
|
|
239
|
+
*/
|
|
240
|
+
function refreshFirst(src, ctx) {
|
|
241
|
+
return (src.uses || []).filter((id) => {
|
|
242
|
+
const x = BY_ID.get(id); const set = ctx.settings.sources[id];
|
|
243
|
+
if (!x || x.run !== 'skill' || !set || !set.on) return false;
|
|
244
|
+
if (ctx.inputState(id) !== 'ok') return false;
|
|
245
|
+
return ctx.now - (ctx.lastDone(id) || 0) > FIRST_MS;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
215
249
|
/* ── the decision ── */
|
|
216
250
|
/**
|
|
217
251
|
* What the tick should do for skill source `src` now. → { act: 'start'|'skip'|'wait'|'none', trigger?, slot?, why?, note? }
|
|
@@ -458,7 +492,7 @@ function toCsv(runs) {
|
|
|
458
492
|
}
|
|
459
493
|
|
|
460
494
|
module.exports = {
|
|
461
|
-
SOURCES, BY_ID, SKILL_OF, SKILL_KINDS, EVERY, WAIT_MS, LATE_MS, RULE_DEFAULTS, RULE_OPTS,
|
|
462
|
-
usedBy, normalize, normalizeRules, withDefaults, migrate, lastSlot, nextSlot, slotsOfDay, inWindow, inQuiet, decide, jobGate, sourceOfOrigin, rowsOf, textOf,
|
|
495
|
+
SOURCES, BY_ID, SKILL_OF, SKILL_KINDS, EVERY, WAIT_MS, LATE_MS, FIRST_MS, RULE_DEFAULTS, RULE_OPTS,
|
|
496
|
+
usedBy, normalize, normalizeRules, withDefaults, migrate, retireLegacy, refreshFirst, lastSlot, nextSlot, slotsOfDay, inWindow, inQuiet, decide, jobGate, sourceOfOrigin, rowsOf, textOf,
|
|
463
497
|
files, readSettings, writeSettings, readState, writeState, newRun, append, readLog, foldLog, keepCopy, prune, toCsv,
|
|
464
498
|
};
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* GET /api/inbox → { ok, count, newCount, items, more, bundles, oldest, seenAt } lib/agent-inbox.js build()
|
|
5
5
|
* POST /api/inbox/seen { ids } | { all } → { ok } one line in <runtime>/inbox-seen.jsonl, a page press only (pm-guard requirePagePress)
|
|
6
6
|
*
|
|
7
|
-
* The read takes the products the premium Briefing reads (routes-briefing-premium products), their Driver ledgers
|
|
7
|
+
* The read takes the products the premium Briefing reads (routes-briefing-premium products), their Driver ledgers, the goal rows and the
|
|
8
|
+
* My work list (the same answer the My work page reads).
|
|
8
9
|
* Seen is not done: an item goes only when its record changes. Nothing here decides a proposal or sends anything. */
|
|
9
10
|
const guard = require('./pm-guard.js');
|
|
10
11
|
const Inbox = require('./agent-inbox.js');
|
|
@@ -32,8 +33,11 @@ module.exports = {
|
|
|
32
33
|
const { products } = require('./routes-briefing-premium.js');
|
|
33
34
|
let available = [];
|
|
34
35
|
try { available = products(ctx).available; } catch { available = []; }
|
|
36
|
+
let work = [];
|
|
37
|
+
try { work = Inbox.workOf(await require('./routes-my-work-premium.js').listView(req, ctx)); } catch { work = []; } // My work drafts ready or stopped; an unreadable list gives none
|
|
35
38
|
const out = Inbox.build({
|
|
36
39
|
proposals: Inbox.readProposals(available),
|
|
40
|
+
work,
|
|
37
41
|
goals: ctx.runtimeDir ? Goal.goalRowsAt(ctx.runtimeDir) : [],
|
|
38
42
|
seen: ctx.runtimeDir ? Inbox.readSeen(ctx.runtimeDir) : undefined,
|
|
39
43
|
now: Date.now(),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-sources.js — how old each source of a workspace is, and Refresh now (workspace-data-freshness R6, R7).
|
|
3
3
|
*
|
|
4
|
-
* GET /api/sources?ws=<id> → { ok, ws, version, sources: [row] } lib/freshness.js sources()
|
|
4
|
+
* GET /api/sources?ws=<id> → { ok, ws, version, sources: [row], health } lib/freshness.js sources(); health is
|
|
5
|
+
* lib/harness-health.js of(): { level, line, issues } or null
|
|
5
6
|
* POST /api/sources/refresh { ws, source } → { ok, source, started: 'rebuild'|'session', session? }
|
|
6
7
|
* POST /api/sources/watch { ws, on } → { ok, watch } the change detector on or off for this repository
|
|
7
8
|
*
|
|
@@ -28,7 +29,8 @@ async function handle(req, res, url, ctx) {
|
|
|
28
29
|
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
29
30
|
if (!w) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
30
31
|
const sources = F.sources({ id: w.id, root: w.root, repoStateDir: repoStateDir(ctx, w) });
|
|
31
|
-
|
|
32
|
+
let health = null; try { health = ctx.health ? ctx.health() : null; } catch { health = null; }
|
|
33
|
+
ctx.json(res, { ok: true, ws: w.id, version: F.versions()[w.id] || 0, sources, health });
|
|
32
34
|
return true;
|
|
33
35
|
}
|
|
34
36
|
if (p !== '/api/sources/refresh' && p !== '/api/sources/watch') return false;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.361.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.361.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -102,8 +102,16 @@ function tbDot() {
|
|
|
102
102
|
const d = $('#srcDot'), c = $('#srcChip'); if (!d || !c) return;
|
|
103
103
|
const behind = TB.src && TB.src.ok ? behindOf(lineItems(TB.src.sources)) : [];
|
|
104
104
|
const n = behind.length + TB.gaps, known = TB.src && TB.src.ok;
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
// harness-health: the background line sets the dot first; red when background work stopped, orange when it is late
|
|
106
|
+
const h = known && TB.src.health ? TB.src.health : null;
|
|
107
|
+
d.className = 'sdot ' + (h && h.level === 'bad' ? 'bad' : n || (TB.src && !TB.src.ok) || (h && h.level === 'warn') ? 'warn' : known ? 'ok' : '');
|
|
108
|
+
c.title = [h && h.level !== 'ok' ? h.line : '', TB.src && !TB.src.ok ? 'The sources could not be read' : n ? [behind.length ? behind.map((b) => b.text).join(', ') : '', TB.gaps ? TB.gaps + (TB.gaps === 1 ? ' source this page could not read' : ' sources this page could not read') : ''].filter(Boolean).join(' · ') : known && !(h && h.level !== 'ok') ? 'Every source was read recently' : known ? '' : 'Reading the sources'].filter(Boolean).join(' · ');
|
|
109
|
+
}
|
|
110
|
+
/** The background line at the top of Sources (harness-health): a dot, the line, and any further issues under it. */
|
|
111
|
+
function healthHtml() {
|
|
112
|
+
const h = TB.src && TB.src.ok ? TB.src.health : null; if (!h) return '';
|
|
113
|
+
const more = (h.issues || []).slice(1, 4);
|
|
114
|
+
return `<div class="hline ${esc(h.level)}" role="status"><b><i class="sdot ${h.level === 'bad' ? 'bad' : h.level === 'warn' ? 'warn' : 'ok'}" aria-hidden="true"></i>${esc(h.line)}</b>${more.length ? `<ul>${more.map((i) => `<li>${esc(i.text)}</li>`).join('')}</ul>` : ''}</div>`;
|
|
107
115
|
}
|
|
108
116
|
/** n: how many sources the page itself could not read (its header's missing list). */
|
|
109
117
|
export function setPageGaps(n) { TB.gaps = n || 0; tbDot(); }
|
|
@@ -121,9 +129,10 @@ export async function openSources() {
|
|
|
121
129
|
// the frame is drawn once; a re-read redraws only the rows, the button and the message, so the page's own part (the Briefing's picker) is left alone
|
|
122
130
|
const rowsHtml = () => { const s = TB.src; return !s ? '<p class="note">Reading the sources.</p>' : !s.ok ? '<p class="note err" role="alert">The sources could not be read.</p>' : s.sources.map(srcRow).join(''); };
|
|
123
131
|
const draw = () => {
|
|
124
|
-
if ($('#srcRows')) { $('#srcRows').innerHTML = rowsHtml(); $('#srcAll').disabled = TB.busy; $('#srcM').textContent = TB.msg; return; }
|
|
132
|
+
if ($('#srcRows')) { $('#srcRows').innerHTML = rowsHtml(); $('#srcHealth').innerHTML = healthHtml(); $('#srcAll').disabled = TB.busy; $('#srcM').textContent = TB.msg; return; }
|
|
125
133
|
park();
|
|
126
134
|
$('#oMain').innerHTML = `<article class="paper doc"><div class="addf">
|
|
135
|
+
<div id="srcHealth">${healthHtml()}</div>
|
|
127
136
|
<div class="srctop"><p class="note" style="margin:0">Each source is read on its own schedule, not live. Each row says when it was last read.</p><button type="button" class="cta" id="srcAll"${TB.busy ? ' disabled' : ''}>Refresh all</button></div>
|
|
128
137
|
<div>${TB.extra ? '<span class="label">Sources</span>' : ''}<div id="srcRows">${rowsHtml()}</div></div>
|
|
129
138
|
${TB.extra ? TB.extra.html() : ''}
|
|
@@ -631,13 +640,13 @@ export function pvFeed(r) {
|
|
|
631
640
|
if (pvOv.kind === 'bell') pvBellDraw();
|
|
632
641
|
}
|
|
633
642
|
/* ── the bell's inbox (initiative premium-agent-inbox): one item per agent result that waits on the PM, a press opens that exact proposal or goal ── */
|
|
634
|
-
const IB_KIND = { proposal: 'Proposal', draft: 'Draft', 'goal-waiting': 'Goal needs you', 'goal-done': 'Goal finished', 'goal-stopped': 'Goal stopped' };
|
|
635
|
-
const IB_ACT = { proposal: 'Review', draft: 'Read', 'goal-waiting': 'Answer', 'goal-done': 'See result', 'goal-stopped': 'See why' };
|
|
636
|
-
const IB_GL = { proposal: IC('M4 20h4L19 9l-4-4L4 16zM14 6l4 4'), draft: GL.doc, 'goal-waiting': IC('M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8'), 'goal-done': IC('M5 12l5 5L20 7'), 'goal-stopped': IC('M6 6h12v12H6z') };
|
|
643
|
+
const IB_KIND = { 'work-draft': 'Draft ready', 'work-stopped': 'Agent stopped', proposal: 'Proposal', draft: 'Draft', 'goal-waiting': 'Goal needs you', 'goal-done': 'Goal finished', 'goal-stopped': 'Goal stopped' };
|
|
644
|
+
const IB_ACT = { 'work-draft': 'Review', 'work-stopped': 'Open', proposal: 'Review', draft: 'Read', 'goal-waiting': 'Answer', 'goal-done': 'See result', 'goal-stopped': 'See why' };
|
|
645
|
+
const IB_GL = { 'work-draft': IC('M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6'), 'work-stopped': IC('M12 8v5M12 16.5v.5M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18'), proposal: IC('M4 20h4L19 9l-4-4L4 16zM14 6l4 4'), draft: GL.doc, 'goal-waiting': IC('M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8'), 'goal-done': IC('M5 12l5 5L20 7'), 'goal-stopped': IC('M6 6h12v12H6z') };
|
|
637
646
|
const ibAgo = (ms) => { if (ms == null) return ''; const m = Math.round((Date.now() - ms) / 60000); return m < 1 ? 'just now' : m < 60 ? m + ' min ago' : m < 1440 ? Math.round(m / 60) + ' h ago' : Math.round(m / 1440) + (Math.round(m / 1440) === 1 ? ' day ago' : ' days ago'); };
|
|
638
647
|
const ibOld = (ms) => { if (ms == null) return ''; const d = Math.floor((Date.now() - ms) / 86400000); return d < 1 ? 'oldest is from today' : 'oldest is ' + d + (d === 1 ? ' day old' : ' days old'); };
|
|
639
|
-
/** The deep link of an inbox item or bundle: the Briefing opens it (premium.js openParam). */
|
|
640
|
-
export const ibHref = (open, pws) => '/premium.html?' + ['open=' + encodeURIComponent(open), pws ? 'pws=' + encodeURIComponent(pws) : '', PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&');
|
|
648
|
+
/** The deep link of an inbox item or bundle: the Briefing opens it (premium.js openParam); a My work item (item:<id>) opens its dialog on My work. */
|
|
649
|
+
export const ibHref = (open, pws) => /^item:/.test(open) ? '/premium-work.html?' + ['item=' + encodeURIComponent(open.slice(5)), PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&') : '/premium.html?' + ['open=' + encodeURIComponent(open), pws ? 'pws=' + encodeURIComponent(pws) : '', PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&');
|
|
641
650
|
/** The last inbox answer, for the Briefing's count line: { count, newCount, oldest } or null. */
|
|
642
651
|
export const ibState = () => IB.r;
|
|
643
652
|
async function ibRead() {
|
|
@@ -659,12 +668,12 @@ async function ibRead() {
|
|
|
659
668
|
function ibGo(open, pws, id) {
|
|
660
669
|
if (id) { IB.shown = IB.shown.filter((x) => x !== id); pmPost('/api/inbox/seen', { ids: [id] }); }
|
|
661
670
|
pvClose();
|
|
662
|
-
if (!pvOnBriefing()) { location.assign(ibHref(open, pws)); return; }
|
|
671
|
+
if (!pvOnBriefing() || /^item:/.test(open)) { location.assign(ibHref(open, pws)); return; }
|
|
663
672
|
document.dispatchEvent(new CustomEvent('pmos:open', { detail: { open, pws } }));
|
|
664
673
|
}
|
|
665
674
|
function ibHtml() {
|
|
666
675
|
const j = IB.r; if (!j) return '';
|
|
667
|
-
const item = (it) => `<div class="ib-it"><span class="gl">${IB_GL[it.kind] || GL.need}</span><span class="ib-b"><b><span class="ib-k">${esc(IB_KIND[it.kind] || 'Agent')}</span>${esc(it.title)}</b><small>${esc([it.product, it.target ? it.target.title : '', ibAgo(it.at)].filter(Boolean).join(' · '))}</small><span class="ib-acts"><button type="button" class="cta" data-ibo="${esc(it.open)}" data-ibw="${esc(it.pws || '')}" data-ibi="${esc(it.id)}">${esc(IB_ACT[it.kind] || 'Open')}</button>${/^row:/.test(it.open) ? '' : `<button type="button" class="cta alt" data-ibo="row:${esc(it.session)}" data-ibi="${esc(it.id)}">Session</button>`}</span></span></div>`;
|
|
676
|
+
const item = (it) => `<div class="ib-it"><span class="gl">${IB_GL[it.kind] || GL.need}</span><span class="ib-b"><b><span class="ib-k">${esc(IB_KIND[it.kind] || 'Agent')}</span>${esc(it.title)}</b><small>${esc([it.product, it.target ? it.target.title : '', ibAgo(it.at)].filter(Boolean).join(' · '))}</small><span class="ib-acts"><button type="button" class="cta" data-ibo="${esc(it.open)}" data-ibw="${esc(it.pws || '')}" data-ibi="${esc(it.id)}">${esc(IB_ACT[it.kind] || 'Open')}</button>${/^(row|item):/.test(it.open) ? '' : `<button type="button" class="cta alt" data-ibo="row:${esc(it.session)}" data-ibi="${esc(it.id)}">Session</button>`}</span></span></div>`;
|
|
668
677
|
const bun = (x) => `<button type="button" class="pv-row ib-bun" data-ibo="${esc(x.open)}" data-ibw="${esc(x.pws || '')}"><span class="gl">${GL.ini}</span><span><b>${esc(x.title)}</b><small>${esc([x.product, x.sub, ibOld(x.oldest)].filter(Boolean).join(' · '))}</small></span></button>`;
|
|
669
678
|
IB.shown = j.items.map((i) => i.id);
|
|
670
679
|
return (j.items.length ? `<div class="pv-grp">New from the agent · ${j.newCount}</div>` + j.items.map(item).join('') + (j.more ? `<p class="pv-note">${j.more} more new. Mark all seen to fold them by piece of work.</p>` : '') : '')
|
|
@@ -45,25 +45,22 @@ function rowHtml(r, o = {}) {
|
|
|
45
45
|
const sd = sm ? null : sideOf(r);
|
|
46
46
|
const desc = sd ? ` aria-description="${esc((sd.r ? 'Right arrow: ' + sd.r.label + '. ' : '') + (sd.l ? 'Left arrow: ' + sd.l.label + '. ' : '') + 'J and K move between rows.')}"` : '';
|
|
47
47
|
let lead;
|
|
48
|
-
if (sm === '
|
|
49
|
-
else if (sm === 'wait') lead = `<span class="avp" aria-hidden="true">${esc(((r.sub.match(/waiting on (\S)/) || [])[1] || '·'))}</span>`;
|
|
48
|
+
if (sm === 'wait') lead = `<span class="avp" aria-hidden="true">${esc(((r.sub.match(/waiting on (\S)/) || [])[1] || '·'))}</span>`;
|
|
50
49
|
else if (inbox) lead = `<span class="wgl" title="${esc(r.src)}">${ICO(glyph(r.src))}</span>`;
|
|
51
50
|
else if (r.agent === 'ready') lead = `<button class="wck dec" data-open="${esc(r.key)}" aria-label="Review the agent draft: ${esc(r.title)}" title="An agent draft is ready. Open it to review.">${ICO('<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>')}</button>`;
|
|
52
51
|
else lead = `<button class="wck" data-ck="${esc(r.id)}" aria-pressed="false" aria-label="Mark done: ${esc(r.title)}">${CHECK}</button>`;
|
|
53
52
|
const meta = r.chip ? `<span class="wm"><span class="due${r.overdue ? ' od' : ''}">${esc(r.chip)}</span></span>` : '';
|
|
54
|
-
const
|
|
53
|
+
const ag = AG_CHIP[r.agent], chip = ag ? `<em class="wag ${ag[0]}"><i></i>${ag[1]}</em>` : '';
|
|
55
54
|
const sug = !sm && r.sug ? `<span class="wsg">${ICO('<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>')}<span><b>${esc(r.sug.b)}</b> ${esc(r.sug.t)}</span></span>` : '';
|
|
56
|
-
return `<div class="wrw"><div class="wrow${sm ? ' sm' : ''}${inbox ? ' inb' : ''}${o.first ? ' first' : ''}" data-key="${esc(r.key)}">${lead}<button class="wrh" aria-haspopup="dialog"${desc}><span class="wtx"><span class="wtit">${esc(r.title)}${o.first ? '<em class="tgf">Do this first</em>' : ''}${r.focus ? '<em class="xfc">Focus</em>' : ''}</span><span class="ws">${esc(r.sub)}
|
|
55
|
+
return `<div class="wrw"><div class="wrow${sm ? ' sm' : ''}${inbox ? ' inb' : ''}${o.first ? ' first' : ''}" data-key="${esc(r.key)}">${lead}<button class="wrh" aria-haspopup="dialog"${desc}><span class="wtx"><span class="wtit">${esc(r.title)}${o.first ? '<em class="tgf">Do this first</em>' : ''}${r.focus ? '<em class="xfc">Focus</em>' : ''}</span><span class="ws">${chip}${esc(r.sub)}</span>${sug}</span>${meta}</button></div></div>`;
|
|
57
56
|
}
|
|
58
|
-
/* One card, one tab for each place a thing waits. A tab draws its groups in two columns
|
|
57
|
+
/* One card, one tab for each place a thing waits. A tab draws its groups in two columns. An item an agent works on stays in its own tab with a chip (PM, 2026-10-20). */
|
|
59
58
|
let qTab = null;
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const Q_EMPTY = { today: 'Nothing is placed for today.', inbox: 'Nothing waits to be sorted. Add a line above and it lands here first.', agents: 'No agent is working on your items.', upcoming: 'Nothing has a later date.', someday: 'Nothing is parked.', kept: 'Nothing kept yet.', done: 'Nothing done this week.' };
|
|
63
|
-
let agTile = null;
|
|
59
|
+
const AG_CHIP = { ready: ['ready', 'Draft ready'], queued: ['run', 'Agent working'], working: ['run', 'Agent working'], sending: ['run', 'Agent working'], failed: ['fail', 'Agent stopped'] };
|
|
60
|
+
const Q_EMPTY = { today: 'Nothing is placed for today.', inbox: 'Nothing waits to be sorted. Add a line above and it lands here first.', upcoming: 'Nothing has a later date.', someday: 'Nothing is parked.', kept: 'Nothing kept yet.', done: 'Nothing done this week.' };
|
|
64
61
|
function groupHtml(g, tab) {
|
|
65
|
-
const
|
|
66
|
-
return g.rows.map((r) => rowHtml(r, {
|
|
62
|
+
const first = tab === 'today' ? g.rows.find((r) => r.overdue) || null : null;
|
|
63
|
+
return g.rows.map((r) => rowHtml(r, { first: first && r.key === first.key })).join('') + (g.more ? `<p class="note">${g.more} more ${g.more === 1 ? 'item is' : 'items are'} not shown here.</p>` : '');
|
|
67
64
|
}
|
|
68
65
|
function drawQueue() {
|
|
69
66
|
const Q = M.queue, tabs = Q.tabs;
|
|
@@ -72,16 +69,8 @@ function drawQueue() {
|
|
|
72
69
|
$('#qCap').innerHTML = `<b>${Q.n}</b> to clear` + Q.cap.map((c) => ' · ' + esc(c)).join('');
|
|
73
70
|
$('#qTabs').innerHTML = tabs.map((t) => `<button type="button" role="tab" class="qtb" id="qt-${t.key}" data-tab="${t.key}" aria-selected="${t.key === qTab}" aria-controls="qBody" tabindex="${t.key === qTab ? 0 : -1}">${esc(t.label)}<em>${t.n}</em></button>`).join('');
|
|
74
71
|
$('#qBody').setAttribute('aria-labelledby', 'qt-' + qTab);
|
|
75
|
-
const pipe = $('#qPipe');
|
|
76
|
-
pipe.hidden = qTab !== 'agents';
|
|
77
72
|
let h = '';
|
|
78
|
-
if (qTab === '
|
|
79
|
-
const c = cur.counts;
|
|
80
|
-
if (agTile && !(cur.by && cur.by[agTile])) agTile = null;
|
|
81
|
-
pipe.innerHTML = AG_TILES.map(([k, label]) => `<button type="button" class="pst${agTile === k ? ' hot' : ''}" data-ag="${k}" aria-pressed="${agTile === k}" aria-controls="qBody" title="${agTile === k ? 'Show every item again' : 'Show only the items that are ' + label.toLowerCase()}"><b>${c[k]}</b><span>${label}</span></button>`).join('');
|
|
82
|
-
const g = agTile ? cur.by[agTile] : cur.groups[0];
|
|
83
|
-
h = g.rows.length ? groupHtml(g, 'agents') : `<p class="empty3 plain">${agTile ? AG_EMPTY[agTile] : Q_EMPTY.agents}</p>`;
|
|
84
|
-
} else if (!cur.n) h = `<p class="empty3${qTab === 'inbox' ? '' : ' plain'}">${qTab === 'inbox' ? CHECK : ''}${Q_EMPTY[qTab]}</p>`;
|
|
73
|
+
if (!cur.n) h = `<p class="empty3${qTab === 'inbox' ? '' : ' plain'}">${qTab === 'inbox' ? CHECK : ''}${Q_EMPTY[qTab]}</p>`;
|
|
85
74
|
else for (const g of cur.groups) {
|
|
86
75
|
if (cur.groups.length > 1) h += `<div class="wsec" data-lane="${g.key}"><span class="label">${esc(g.label)}</span><em>${g.n ? g.n + ' · ' + esc(g.hint) : 'empty'}</em></div>`;
|
|
87
76
|
h += groupHtml(g, qTab);
|
|
@@ -89,6 +78,8 @@ function drawQueue() {
|
|
|
89
78
|
$('#qBody').innerHTML = h;
|
|
90
79
|
$('#qBody').dataset.tab = qTab;
|
|
91
80
|
$('#qNote').textContent = cur.note;
|
|
81
|
+
const sel = $('#qTabs [aria-selected="true"]'), bar = $('#qTabs'); // one row that scrolls sideways on a phone: keep the chosen tab in view
|
|
82
|
+
if (sel && bar.scrollWidth > bar.clientWidth) bar.scrollLeft = Math.max(0, sel.offsetLeft - (bar.clientWidth - sel.offsetWidth) / 2);
|
|
92
83
|
}
|
|
93
84
|
$('#qTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-tab]'); if (!b) return; qTab = b.dataset.tab; drawQueue(); const n = $(`#qTabs [data-tab="${qTab}"]`); if (n) n.focus(); });
|
|
94
85
|
$('#qTabs').addEventListener('keydown', (e) => {
|
|
@@ -98,7 +89,6 @@ $('#qTabs').addEventListener('keydown', (e) => {
|
|
|
98
89
|
qTab = ks[e.key === 'Home' ? 0 : e.key === 'End' ? ks.length - 1 : (i + (e.key === 'ArrowRight' ? 1 : -1) + ks.length) % ks.length];
|
|
99
90
|
drawQueue(); $(`#qTabs [data-tab="${qTab}"]`).focus();
|
|
100
91
|
});
|
|
101
|
-
$('#qPipe').addEventListener('click', (e) => { const b = e.target.closest('[data-ag]'); if (!b) return; agTile = agTile === b.dataset.ag ? null : b.dataset.ag; drawQueue(); const n = $(`#qPipe [data-ag="${b.dataset.ag}"]`); if (n) n.focus(); });
|
|
102
92
|
function drawWaiting() {
|
|
103
93
|
const W = M.waiting;
|
|
104
94
|
$('#waitCap').textContent = W.cap;
|
|
@@ -543,9 +543,6 @@ a.round{color:inherit;text-decoration:none}
|
|
|
543
543
|
button.pst{border:0;font:inherit;color:inherit;text-align:left;cursor:pointer}button.pst:not(.hot):hover{box-shadow:inset 0 0 0 1px var(--hair)}
|
|
544
544
|
.agl{margin-top:8px}
|
|
545
545
|
.wrow.sm .wrh{padding:11px 0}.wrow.sm .wtit{font-size:var(--fs-3)}
|
|
546
|
-
.ags{width:34px;height:34px;border-radius:14px;display:grid;place-items:center;background:var(--well);color:var(--ink-2)}
|
|
547
|
-
.wrow:hover .ags{background:var(--card)}.ags svg{width:17px;height:17px}.ags.ready{background:var(--solid);color:var(--on-solid)}
|
|
548
|
-
.ags .spin{width:16px;height:16px}
|
|
549
546
|
.avp{width:34px;height:34px;border-radius:50%;background:var(--b3);display:grid;place-items:center;font:600 var(--fs-2) var(--mono);color:var(--ink)}
|
|
550
547
|
.nud{font-size:var(--fs-2);font-weight:600;color:var(--ember-ink)}
|
|
551
548
|
.nud.ok{color:var(--ok)}
|
|
@@ -632,7 +629,7 @@ button.pst{border:0;font:inherit;color:inherit;text-align:left;cursor:pointer}bu
|
|
|
632
629
|
|
|
633
630
|
@media (max-width:700px){
|
|
634
631
|
.cap{height:54px}.cap kbd{display:none}
|
|
635
|
-
.wgl,.
|
|
632
|
+
.wgl,.avp{width:30px;height:30px;border-radius:8px}.avp{border-radius:50%}
|
|
636
633
|
.wm .est{display:none}
|
|
637
634
|
.pst{padding:10px 12px}.pst b{font-size:var(--fs-4)}
|
|
638
635
|
.revc{grid-template-columns:1fr}
|
|
@@ -2041,21 +2038,30 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2041
2038
|
.mhint .lk{display:inline;font-size:var(--fs-2);font-weight:600;color:var(--ink);text-decoration:underline;text-underline-offset:2px;padding:0}
|
|
2042
2039
|
.mhint .lk:hover{color:var(--ember-ink)}
|
|
2043
2040
|
|
|
2044
|
-
/* My work: the Work queue (PM, 2026-10-19) — one card for what On your plate
|
|
2045
|
-
|
|
2041
|
+
/* My work: the Work queue (PM, 2026-10-19) — one card for what On your plate and the tray held. Tabs are one pill row as the mockup's tray,
|
|
2042
|
+
and one row on a phone too: it scrolls sideways and never wraps (PM, 2026-10-20). */
|
|
2043
|
+
.qtabs{position:relative;display:inline-flex;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;gap:2px;padding:4px;margin:14px 0 6px;border-radius:var(--r-chip);background:var(--well);max-width:100%}
|
|
2046
2044
|
.qtb{height:36px;padding:0 14px;border-radius:var(--r-chip);font-size:var(--t-small);font-weight:600;color:var(--ink-2);white-space:nowrap;transition:background .25s,color .25s}
|
|
2047
2045
|
.qtb em{font-style:normal;font-weight:500;margin-left:6px;opacity:.75}
|
|
2048
2046
|
.qtb:hover{color:var(--ink)}
|
|
2049
2047
|
.qtb[aria-selected="true"]{background:var(--solid);color:var(--on-solid)}
|
|
2050
2048
|
.qtb:focus-visible{outline:2px solid var(--ember);outline-offset:2px}
|
|
2051
|
-
.
|
|
2052
|
-
|
|
2049
|
+
.qtabs::-webkit-scrollbar{display:none}
|
|
2050
|
+
/* the agent's state on a row, in the tab where the item waits (PM, 2026-10-20: no Agents tab) */
|
|
2051
|
+
.wag{display:inline-flex;align-items:center;gap:5px;font:600 var(--fs-1) var(--sans);font-style:normal;color:var(--ink-2);background:var(--well);padding:1px 9px 1px 7px;border-radius:999px;margin-right:8px;vertical-align:1px;white-space:nowrap}
|
|
2052
|
+
.wag i{width:7px;height:7px;border-radius:50%;background:var(--ink-3)}
|
|
2053
|
+
.wag.ready{background:var(--spot);color:var(--ember-ink)}.wag.ready i{background:var(--ember)}
|
|
2054
|
+
.wag.fail{color:var(--bad)}.wag.fail i{background:var(--bad)}
|
|
2055
|
+
.wag.run i{background:var(--ok);animation:agp 1.4s ease-in-out infinite}
|
|
2056
|
+
@keyframes agp{50%{opacity:.3}}
|
|
2057
|
+
@media (prefers-reduced-motion:reduce){.wag.run i{animation:none}}
|
|
2058
|
+
.wrow:hover .wag{background:var(--card)}
|
|
2053
2059
|
#qCap b{color:var(--ink)}
|
|
2054
2060
|
.tgrid .wsec{grid-column:1/-1}
|
|
2055
2061
|
.tgrid .wsec+.wrw+.wrw{border-top:0}
|
|
2056
2062
|
#qBody .wsec:first-child{padding-top:8px}
|
|
2057
2063
|
@media (max-width:1000px){.tgrid .wsec+.wrw+.wrw{border-top:1px solid var(--hair)}}
|
|
2058
|
-
@media (max-width:700px){.qtabs{display:flex;
|
|
2064
|
+
@media (max-width:700px){.qtabs{display:flex;width:100%;-webkit-mask-image:linear-gradient(90deg,var(--ink) calc(100% - 28px),transparent);mask-image:linear-gradient(90deg,var(--ink) calc(100% - 28px),transparent)}.qtb{flex:0 0 auto;min-height:44px;padding:0 14px}}
|
|
2059
2065
|
.rdbtns{display:inline-flex;gap:6px;align-items:center}
|
|
2060
2066
|
.wks .wkc{font:400 var(--fs-2) var(--sans);letter-spacing:0;text-transform:none;padding:12px 4px 10px}
|
|
2061
2067
|
.wkc .wkl{font:500 var(--fs-1) var(--mono);letter-spacing:.08em}
|
|
@@ -2118,6 +2124,12 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
2118
2124
|
.sdot{width:8px;height:8px;border-radius:50%;background:var(--ink-3);flex:none;display:inline-block}
|
|
2119
2125
|
.sdot.ok{background:var(--ok)}
|
|
2120
2126
|
.sdot.warn{background:var(--ember)}
|
|
2127
|
+
.sdot.bad{background:var(--bad)}
|
|
2128
|
+
.hline{display:flex;flex-direction:column;gap:4px;padding:10px 12px;border-radius:12px;background:var(--well);font-size:var(--fs-2);color:var(--ink)}
|
|
2129
|
+
.hline b{display:inline-flex;align-items:center;gap:8px;font-weight:600}
|
|
2130
|
+
.hline.ok b{font-weight:500;color:var(--ink-2)}
|
|
2131
|
+
.hline ul{margin:0;padding:0 0 0 16px;color:var(--ink-2)}
|
|
2132
|
+
.hline:empty,#srcHealth:empty{display:none}
|
|
2121
2133
|
.sr .sn b{display:inline-flex;align-items:center;gap:8px}
|
|
2122
2134
|
.srctop{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
|
|
2123
2135
|
.mwrap{position:relative;display:inline-flex}
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
<section class="card rise" style="--d:5;margin-top:24px" id="queue" aria-labelledby="hQueue">
|
|
49
49
|
<div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="3"/><path d="M8 9h8M8 13h8M8 17h5"/></svg></span><h2 id="hQueue">Work queue</h2><small id="qCap"></small></div>
|
|
50
50
|
<div class="qtabs" id="qTabs" role="tablist" aria-label="Work queue"></div>
|
|
51
|
-
<div class="qpipe" id="qPipe" hidden></div>
|
|
52
51
|
<div class="tgrid" id="qBody" role="tabpanel" aria-labelledby="hQueue"></div>
|
|
53
52
|
<p class="note" id="qNote" style="margin-top:14px"></p>
|
|
54
53
|
</section>
|
package/workspace/server.js
CHANGED
|
@@ -84,6 +84,7 @@ const scanRunLib = require('./lib/scan-run.js'); // horizon-scan — the watch
|
|
|
84
84
|
const reportFinderLib = require('./lib/report-finder.js'); // report-workspace — the weekly look for the reports the PM already sends
|
|
85
85
|
const refreshLib = require('./lib/refresh.js'); // data-refresh-settings — the sources, their schedules and the refresh log
|
|
86
86
|
const refreshRunLib = require('./lib/refresh-run.js'); // data-refresh-settings — the engine bound to this server (created by the tick below)
|
|
87
|
+
const harnessHealthLib = require('./lib/harness-health.js'); // harness-health — one line on whether the background work runs
|
|
87
88
|
let refreshRun = null;
|
|
88
89
|
const driverRunLib = require('./lib/driver-run.js'); // initiative-driver — wakes, the unblock sweep and the runs, in the 60-second tick
|
|
89
90
|
const headlessLib = require('./lib/headless.js'); // workspace-headless-jobs — which jobs run as `claude -p`, and with which tools
|
|
@@ -2773,6 +2774,36 @@ const coreDocsTick = () => {
|
|
|
2773
2774
|
proSettings, inQuiet: (now, quiet) => proactiveLib.inQuietHours(now, quiet), isLead: (w) => isPlanNeedsTree(w) }, Number.isFinite(t) ? { now: t } : {});
|
|
2774
2775
|
} catch (e) { warnWriteFail('core documents tick', e); }
|
|
2775
2776
|
};
|
|
2777
|
+
/** One needs-you item, so it shows in the bell. */
|
|
2778
|
+
function tellNeed(ws, runId, label, question) {
|
|
2779
|
+
const w = getWs(ws || '') || homeWorkspace(); const nf = w ? needsFileFor(w) : null; if (!nf) return;
|
|
2780
|
+
let needs = []; try { needs = JSON.parse(fs.readFileSync(nf, 'utf8')); } catch { needs = []; }
|
|
2781
|
+
needs.push({ run_id: runId, kind: 'refresh', initiative_id: label, question });
|
|
2782
|
+
fs.writeFileSync(nf, JSON.stringify(needs)); invalidateNeedsAgg(w.id);
|
|
2783
|
+
}
|
|
2784
|
+
// harness-health: one line on whether the background work runs (lib/harness-health.js). GET /api/sources carries it, the Sources
|
|
2785
|
+
// chip's dot takes its colour, and a stop (no brief 45 minutes after its time, a prompt typed but not sent, the tick stopped) is
|
|
2786
|
+
// told once a day in the bell.
|
|
2787
|
+
let lastBgTick = 0;
|
|
2788
|
+
const healthTold = new Set();
|
|
2789
|
+
function harnessHealth(now = Date.now()) {
|
|
2790
|
+
const set = refreshRun.settings();
|
|
2791
|
+
const d = (proSettings() || {}).dayCheck || {};
|
|
2792
|
+
let briefAt = 0; try { briefAt = fs.statSync(path.join(STATE, 'briefs', briefLib.localDate(now) + '.json')).mtimeMs; } catch { /* no brief yet today */ }
|
|
2793
|
+
const live = [...sessions.values()].filter((x) => x.state !== 'exited').map((x) => ({ id: x.id, name: x.name, origin: x.origin, state: x.state, firstInput: x.firstInput || null }));
|
|
2794
|
+
return harnessHealthLib.of({ now, settings: set, state: refreshLib.readState(STATE), log: refreshLib.foldLog(refreshLib.readLog(STATE)), briefAt, sessions: live, lastTick: lastBgTick,
|
|
2795
|
+
win: { start: d.start || '08:00', end: d.end || '18:00' } });
|
|
2796
|
+
}
|
|
2797
|
+
function healthTick(now = Date.now()) {
|
|
2798
|
+
lastBgTick = now;
|
|
2799
|
+
const h = harnessHealth(now);
|
|
2800
|
+
const day = briefLib.localDate(now);
|
|
2801
|
+
for (const i of h.issues) {
|
|
2802
|
+
if (i.level !== 'bad' || !/^(brief|unsent:|tick)/.test(i.key) || healthTold.has(day + i.key)) continue;
|
|
2803
|
+
healthTold.add(day + i.key);
|
|
2804
|
+
tellNeed(null, `health-${i.key}-${now}`, 'Background work', i.text + ' See Sources.');
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2776
2807
|
// data-refresh-settings: the refresh engine. It starts the skill sources that are due (calendar, Jira, work assigned to you, tracker,
|
|
2777
2808
|
// the morning brief), writes the refresh log, and gates the job ticks below: a job that is off, or whose input is still running, waits.
|
|
2778
2809
|
const REFRESH_BOOT = Date.now();
|
|
@@ -2791,12 +2822,7 @@ refreshRun = refreshRunLib.create({
|
|
|
2791
2822
|
if (id === 'jira' && w) { let d = null; try { d = stateDirFor(w); } catch { d = null; } return d ? [path.join(d, 'tracker', 'jira')] : []; }
|
|
2792
2823
|
return [];
|
|
2793
2824
|
},
|
|
2794
|
-
tell: ({ source, label, error, ws }) => {
|
|
2795
|
-
const w = getWs(ws || '') || homeWorkspace(); const nf = w ? needsFileFor(w) : null; if (!nf) return;
|
|
2796
|
-
let needs = []; try { needs = JSON.parse(fs.readFileSync(nf, 'utf8')); } catch { needs = []; }
|
|
2797
|
-
needs.push({ run_id: `refresh-${source}-${Date.now()}`, kind: 'refresh', initiative_id: label, question: `${label} could not refresh: ${String(error).slice(0, 300)} See Settings, Data refresh.` });
|
|
2798
|
-
fs.writeFileSync(nf, JSON.stringify(needs)); invalidateNeedsAgg(w.id);
|
|
2799
|
-
},
|
|
2825
|
+
tell: ({ source, label, error, ws }) => tellNeed(ws, `refresh-${source}-${Date.now()}`, label, `${label} could not refresh: ${String(error).slice(0, 300)} See Settings, Data refresh.`),
|
|
2800
2826
|
setDayCheckEvery: (every) => {
|
|
2801
2827
|
let raw = {}; try { raw = JSON.parse(fs.readFileSync(PRO_SETTINGS(), 'utf8')); } catch { raw = {}; }
|
|
2802
2828
|
const cur = proSettings();
|
|
@@ -2832,7 +2858,7 @@ const gated = (id, fn) => () => { let g = { ok: true }; try { g = refreshRun.job
|
|
|
2832
2858
|
// data-refresh-settings: the seed schedules move to Settings › Data refresh (refreshRun.settings(), once) BEFORE checkDueSchedules reads
|
|
2833
2859
|
// schedules.json, so a schedule that is moving never fires once more from the old list on the first tick after an upgrade.
|
|
2834
2860
|
const scheduleOwner = require('./lib/schedule-owner.js').create({ port: PORT });
|
|
2835
|
-
try { const _tick = setInterval(() => { try { if (!scheduleOwner.mayRun()) return; } catch { /* no lock: run as before */ } try { refreshRun.settings(); } catch { /* the refresh tick tries again */ } checkDueSchedules(); proactiveTick(); try { prepareTick({ manual: false }); } catch { /* the next tick tries again */ } try { dayTick(); } catch (e) { warnWriteFail('day run tick', e); } try { refreshRun.tick(); } catch (e) { warnWriteFail('refresh tick', e); } gated('sync', () => autoSync.tick().catch(() => {}))(); dashboardScheduleTick(); orchTick(); gated('driver', driverTick)(); gated('scan', scanTick)(); gated('finder', reportFinderTick)(); gated('coredocs', coreDocsTick)(); reportDesignTick(); reportStructureTick(); }, TICK_MS); if (_tick.unref) _tick.unref(); } catch {}
|
|
2861
|
+
try { const _tick = setInterval(() => { try { if (!scheduleOwner.mayRun()) return; } catch { /* no lock: run as before */ } try { refreshRun.settings(); } catch { /* the refresh tick tries again */ } checkDueSchedules(); proactiveTick(); try { prepareTick({ manual: false }); } catch { /* the next tick tries again */ } try { dayTick(); } catch (e) { warnWriteFail('day run tick', e); } try { refreshRun.tick(); } catch (e) { warnWriteFail('refresh tick', e); } try { healthTick(); } catch (e) { warnWriteFail('health tick', e); } gated('sync', () => autoSync.tick().catch(() => {}))(); dashboardScheduleTick(); orchTick(); gated('driver', driverTick)(); gated('scan', scanTick)(); gated('finder', reportFinderTick)(); gated('coredocs', coreDocsTick)(); reportDesignTick(); reportStructureTick(); }, TICK_MS); if (_tick.unref) _tick.unref(); } catch {}
|
|
2836
2862
|
|
|
2837
2863
|
// ── Sessions: real PTYs, owned by the server, with disk-backed scrollback + metadata. ──
|
|
2838
2864
|
/** @type {Map<string, {id,ws,name,agent,cwd,state,note,created,pty,buf,cols,rows,clients:Set}>} */
|
|
@@ -3145,6 +3171,22 @@ function paneAsk(s, now = Date.now()) {
|
|
|
3145
3171
|
s.ask = r.status === 0 && r.stdout ? transcript.permissionAsk(r.stdout, scrub) : null;
|
|
3146
3172
|
return s.ask;
|
|
3147
3173
|
}
|
|
3174
|
+
// The pane's visible screen, plain text, or '' (no tmux pane). lib/first-input.js reads Claude Code's input box from it.
|
|
3175
|
+
function paneScreen(s) {
|
|
3176
|
+
if (!s || !s.tmux || !TMUX) return '';
|
|
3177
|
+
const r = tmuxCtl(['capture-pane', '-p', '-t', s.tmux]);
|
|
3178
|
+
return r.status === 0 && r.stdout ? String(r.stdout) : '';
|
|
3179
|
+
}
|
|
3180
|
+
/** Type `input` into session `s` (lib/first-input.js). A Claude Code pane is also read: the prompt is typed once its input box is
|
|
3181
|
+
* drawn, and Enter is pressed again while the box still holds the prompt (harness-health: the 2026-10-21 morning briefs sat
|
|
3182
|
+
* unsent). A prompt that is still not sent is written on the session, so the list and the health line say so. */
|
|
3183
|
+
function deliverInput(s, input) {
|
|
3184
|
+
const screen = s && s.agent === 'claude' && s.tmux && TMUX ? () => paneScreen(s) : null;
|
|
3185
|
+
firstInput.deliver(s, input, { screen, onDone: (why) => {
|
|
3186
|
+
if (why === 'resubmitted' || why === 'unsent') { try { s.firstInput = { result: why, at: Date.now() }; } catch { /* nothing to keep */ } }
|
|
3187
|
+
if (why === 'unsent') { s.note = 'its prompt was typed but not sent'; try { pushSessions(); } catch { /* the next list shows it */ } }
|
|
3188
|
+
} });
|
|
3189
|
+
}
|
|
3148
3190
|
function transcriptHarness(s) {
|
|
3149
3191
|
if (s.state === 'exited') return { missing: { all: 'the session has exited' } };
|
|
3150
3192
|
// A `shell` session is included: the PM launches `claude` INSIDE the default shell pane, so the
|
|
@@ -3784,7 +3826,7 @@ function sendToSession(id, text) {
|
|
|
3784
3826
|
if (!s || !s.pty || s.state === 'exited' || s.agent === 'shell') return false;
|
|
3785
3827
|
const t = String(text == null ? '' : text).replace(/[\r\n]+/g, ' ').trim();
|
|
3786
3828
|
if (!t) return false;
|
|
3787
|
-
try {
|
|
3829
|
+
try { deliverInput(s, safeFirstInput(t) + '\r'); return true; } catch { return false; }
|
|
3788
3830
|
}
|
|
3789
3831
|
|
|
3790
3832
|
/* premium-chat-session: what the premium chat panel needs from the session table. `type` keeps a leading `/`, so a slash command
|
|
@@ -3797,7 +3839,7 @@ const chatSessions = {
|
|
|
3797
3839
|
if (!s || !s.pty || s.state === 'exited') return false;
|
|
3798
3840
|
const t = String(text == null ? '' : text).replace(/[\r\n]+/g, ' ').trim();
|
|
3799
3841
|
if (!t) return false;
|
|
3800
|
-
try {
|
|
3842
|
+
try { deliverInput(s, t + '\r'); return true; } catch { return false; }
|
|
3801
3843
|
},
|
|
3802
3844
|
keys: (id, data) => { const s = sessions.get(String(id || '')); if (!s || !s.pty || s.state === 'exited') return false; try { s.pty.write(String(data)); return true; } catch { return false; } },
|
|
3803
3845
|
// slice 4 (PRD L3): the live chat sessions, so a new one can end the longest idle; busy = working or a permission prompt waits
|
|
@@ -3945,7 +3987,7 @@ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile
|
|
|
3945
3987
|
// safeFirstInput: a first input that begins with `/` is read by the agent as a slash command, not as the task.
|
|
3946
3988
|
// firstInput.deliver waits until the agent is ready to read, types the prompt, then presses Enter as its own key
|
|
3947
3989
|
// (lib/first-input.js): a burst written at a fixed 700 ms was lost or left unsent while the agent was still starting.
|
|
3948
|
-
const feed = (s) => { if (initialInput && s && s.pty) { try {
|
|
3990
|
+
const feed = (s) => { if (initialInput && s && s.pty) { try { deliverInput(s, safeFirstInput(initialInput)); } catch {} } };
|
|
3949
3991
|
// shell gets a real fallback to `sh`; agent CLIs run as-is (harness untouched), NO fallback —
|
|
3950
3992
|
// falling back from `claude` to `sh` would be a lie.
|
|
3951
3993
|
const cmd = isShell ? (commandExists(SHELL) ? SHELL : 'sh') : agent;
|
|
@@ -4605,7 +4647,7 @@ function startDayTask(run, t, now) {
|
|
|
4605
4647
|
const step = t.mode === 'send' && dayRunLib.stepOf(t);
|
|
4606
4648
|
const prev = !step && t.prev_session && sessions.get(t.prev_session);
|
|
4607
4649
|
if (!sk.error && prev && prev.state !== 'exited' && prev.pty) {
|
|
4608
|
-
try {
|
|
4650
|
+
try { deliverInput(prev, line + '\r'); s = prev; } catch { s = null; }
|
|
4609
4651
|
}
|
|
4610
4652
|
if (!sk.error && !s) {
|
|
4611
4653
|
const prompt = `${sk.prompt}\n\n${line}`;
|
|
@@ -4654,7 +4696,7 @@ function startDayCheck(run, reason, now) {
|
|
|
4654
4696
|
const prev = run.checks.prev_session && sessions.get(run.checks.prev_session);
|
|
4655
4697
|
let s = null;
|
|
4656
4698
|
if (prev && prev.pty && prev.state !== 'exited' && harness.deriveState(prev.state, prev.lastOutputAt, now).state !== 'working') {
|
|
4657
|
-
try {
|
|
4699
|
+
try { deliverInput(prev, line + '\r'); s = prev; } catch { s = null; }
|
|
4658
4700
|
}
|
|
4659
4701
|
if (!s) {
|
|
4660
4702
|
s = spawnSession({ name: 'Daytime check', agent: sk.task.agent || 'claude', ws: sk.w ? sk.w.id : run.ws, origin: 'day-check', initialInput: `${sk.prompt}\n\n${line}\r`,
|
|
@@ -8922,7 +8964,7 @@ async function handleRequest(req, res) {
|
|
|
8922
8964
|
const sk = daySkillPrompt(run, 'morning-brief');
|
|
8923
8965
|
const s = sessions.get(run.brief_session.id);
|
|
8924
8966
|
if (!sk.error) {
|
|
8925
|
-
try {
|
|
8967
|
+
try { deliverInput(s, `${sk.prompt}\n\nThis run: prepare the day again. Read every source again and submit a new brief for today.\r`); } catch { /* typed below as a new session */ }
|
|
8926
8968
|
run.brief_session = { id: s.id, started_at: new Date(pnow).toISOString(), ended_at: null };
|
|
8927
8969
|
writeDayRun(run);
|
|
8928
8970
|
return json(res, { ok: true, started: true, reused: true, session: s.id, run, goals: open.length });
|
|
@@ -9643,7 +9685,7 @@ async function handleRequest(req, res) {
|
|
|
9643
9685
|
else if (x.pty) { if (x.tmux) tmuxKillSession(x.tmux); try { x.pty.kill(); } catch { /* already ended */ } }
|
|
9644
9686
|
},
|
|
9645
9687
|
// workspace-data-freshness: the source table, the facts rebuild and Refresh now's skill sessions
|
|
9646
|
-
freshness, factsRefresh: (root) => factsAsync.refresh(root, { force: true }), startSkill: startSkillSession,
|
|
9688
|
+
freshness, factsRefresh: (root) => factsAsync.refresh(root, { force: true }), startSkill: startSkillSession, health: () => harnessHealth(),
|
|
9647
9689
|
// c3-initiative-boards: the PMOS checkout this server is embedded in, whose default board keeps its derived ladder
|
|
9648
9690
|
selfRoot: EMBEDDED_SELF ? SELF_ROOT : null,
|
|
9649
9691
|
// horizon-scan-portfolio: Scan now, Stop and an approved research proposal start and end runs in the scanner; scanClock fixes its clock in the suites
|