create-pmos 0.594.0 → 0.596.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 +39 -27
- package/payload/KIT-VERSION +1 -1
- 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/workspace/changelog.json +38 -0
- package/workspace/fixtures/transcript-task-tools.jsonl +5 -0
- package/workspace/guide/notes.md +2 -2
- package/workspace/guide/scheduled-tasks-and-cli.md +3 -1
- package/workspace/guide/settings-and-switches.md +35 -3
- package/workspace/lib/calendar-events.js +5 -1
- package/workspace/lib/connector-directory.js +70 -0
- package/workspace/lib/goal-chat.js +1 -1
- package/workspace/lib/refresh-run.js +23 -9
- package/workspace/lib/refresh.js +64 -19
- package/workspace/lib/schedule-cli.js +2 -2
- package/workspace/lib/schedule-logic.js +8 -2
- package/workspace/lib/transcript-steps.js +66 -17
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-conndir.js +67 -0
- package/workspace/public/pm/cozy-ev.css +52 -0
- package/workspace/public/pm/cozy-evmodel.js +45 -6
- package/workspace/public/pm/cozy-schedwork.js +201 -0
- package/workspace/public/pm/cozy-settings.js +106 -17
- package/workspace/public/pm/cozy-vw-mtg.css +3 -0
- package/workspace/public/pm/premium-vw-doc.css +0 -3
- package/workspace/public/pm/small-vw.js +1 -0
- package/workspace/server.js +52 -0
- package/workspace/test-lists/connectors-directory.json +9 -0
|
@@ -106,12 +106,45 @@ export function clockOf(iso, now = Date.now()) {
|
|
|
106
106
|
return d.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()];
|
|
107
107
|
}
|
|
108
108
|
const short = (a) => a.replace(/ hours? ago$/, ' h ago');
|
|
109
|
+
const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
110
|
+
/** When a next run is: "10:00" today, "tomorrow 08:00", "Mon 08:00" this week, else "3 Nov 08:00" (batch 31 item 2). */
|
|
111
|
+
export function nextOf(iso, now = Date.now()) {
|
|
112
|
+
const d = new Date(iso || ''); if (Number.isNaN(d.getTime())) return '';
|
|
113
|
+
const n = new Date(now), day = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
|
|
114
|
+
const diff = Math.round((day(d) - day(n)) / 86400000), t = two_(d.getHours()) + ':' + two_(d.getMinutes());
|
|
115
|
+
if (d.getTime() <= now) return 'now';
|
|
116
|
+
if (diff <= 0) return t;
|
|
117
|
+
if (diff === 1) return 'tomorrow ' + t;
|
|
118
|
+
if (diff < 7) return WD[d.getDay()] + ' ' + t;
|
|
119
|
+
return d.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()] + ' ' + t;
|
|
120
|
+
}
|
|
121
|
+
/** A past moment with its time: "09:15" today, "yesterday 17:31", "3 Nov 09:00". */
|
|
122
|
+
export function atOf(iso, now = Date.now()) {
|
|
123
|
+
const c = clockOf(iso, now), d = new Date(iso || '');
|
|
124
|
+
return !c || /^\d\d:\d\d$/.test(c) ? c : c + ' ' + two_(d.getHours()) + ':' + two_(d.getMinutes());
|
|
125
|
+
}
|
|
126
|
+
/** A schedule in the row's words: "Every 30 min, working hours only" → "Every 30 min in working hours". */
|
|
127
|
+
export const everyLine = (text) => String(text || '').replace(/, working hours only/, ' in working hours').replace(/^Only when you press Refresh$/, 'Only when you press read');
|
|
128
|
+
/**
|
|
129
|
+
* The line under a scheduled source (batch 31 item 2, agreed design SwC): how often · next, quiet grey; or, when PMOS missed a read,
|
|
130
|
+
* "Read yesterday 17:31 · missed 09:00", amber with ↻. → { text, missed } | null when the row has no schedule.
|
|
131
|
+
*/
|
|
132
|
+
export function scheduleLine(s, now = Date.now()) {
|
|
133
|
+
const sch = s && s.schedule;
|
|
134
|
+
if (!sch || !sch.cadence) return null;
|
|
135
|
+
if (sch.cadence === 'off') return { text: 'Off', missed: false };
|
|
136
|
+
if (sch.missed_at) return { text: (s.as_of ? 'Read ' + atOf(s.as_of, now) : 'Never read') + ' · missed ' + atOf(sch.missed_at, now), missed: true };
|
|
137
|
+
const nx = sch.next_run ? nextOf(sch.next_run, now) : '';
|
|
138
|
+
return { text: everyLine(sch.cadence) + (nx ? ' · next ' + nx : ''), missed: false };
|
|
139
|
+
}
|
|
109
140
|
/**
|
|
110
141
|
* connectorRows(sources, health, now) → [{ id, name, trouble, why, when, act }] trouble rows first (needs you, then failed, then
|
|
111
142
|
* the other issues), then the quiet rows in the server's order.
|
|
112
143
|
* why the one reason (trouble), or "Checked 10:42 · same since 09:15" on a quiet row a measured read applies to, else ''
|
|
113
144
|
* when the time on a quiet row ('3 h ago', 'Watching', 'Not connected', 'Reading now'); '' when `why` carries the time
|
|
114
145
|
* act { kind: 'read' | 'open' | 'sec', label, href?, sec? } | null the one icon action
|
|
146
|
+
* job the Settings › Connectors item page of a scheduled source (lib/refresh.js id: calendar, jira, mywork, tracker, tools) or null
|
|
147
|
+
* Batch 31 item 2 (SwC): a scheduled source's quiet line says how often and when it reads next; a missed read turns the row amber with ↻.
|
|
115
148
|
*/
|
|
116
149
|
export function connectorRows(sources, health, now = Date.now()) {
|
|
117
150
|
const issues = (health && (health.level === 'warn' || health.level === 'bad') && health.issues) || [];
|
|
@@ -120,29 +153,35 @@ export function connectorRows(sources, health, now = Date.now()) {
|
|
|
120
153
|
const out = [];
|
|
121
154
|
for (const s of (sources || []).filter(Boolean)) {
|
|
122
155
|
const name = sourceName(s), h = s.heal, iss = bySrc.get(s.id);
|
|
156
|
+
const jobOf = s.schedule && s.schedule.refresh ? { job: s.schedule.refresh } : {}; // the Scheduled work page of this source (batch 31 item 2)
|
|
123
157
|
const read = { kind: 'read', label: 'Read ' + name + ' again' };
|
|
124
158
|
if (h && h.state === 'needs-you' && h.action) {
|
|
125
159
|
const a = h.action, dur = s.as_of ? ago(s.as_of, now).replace(/ ago$/, '') : '';
|
|
126
160
|
const why = [s.as_of ? 'Not read for ' + dur + '.' : 'Never read.', h.tried || (h.why ? 'The read ' + h.why + '.' : ''), a.read ? '' : a.how].filter(Boolean).join(' ');
|
|
127
|
-
out.push({ id: s.id, name, trouble: 1, why, when: '', act: a.read ? { ...read, label: a.label } : a.href ? { kind: 'open', label: a.label, href: a.href } : { kind: 'sec', label: a.label, sec: a.sec || 'claude' } });
|
|
161
|
+
out.push({ id: s.id, name, trouble: 1, why, when: '', act: a.read ? { ...read, label: a.label } : a.href ? { kind: 'open', label: a.label, href: a.href } : { kind: 'sec', label: a.label, sec: a.sec || 'claude' }, ...jobOf });
|
|
128
162
|
continue;
|
|
129
163
|
}
|
|
130
164
|
if (s.state === 'failed' || iss) {
|
|
131
165
|
const why = iss ? iss.why : 'Could not be read.';
|
|
132
166
|
const act = s.id === 'repository' ? (iss ? { kind: 'sec', label: 'Check the repository address', sec: 'workspaces' } : null) : read;
|
|
133
|
-
out.push({ id: s.id, name, trouble: 2, why, when: '', act });
|
|
167
|
+
out.push({ id: s.id, name, trouble: 2, why, when: '', act, ...jobOf });
|
|
134
168
|
continue;
|
|
135
169
|
}
|
|
136
170
|
const mend = h && h.state === 'repairing' && (s.state === 'stale' || s.state === 'never');
|
|
137
|
-
const sch = s.schedule || {};
|
|
171
|
+
const sch = s.schedule || {}, job = sch.refresh || null, line = scheduleLine(s, now);
|
|
172
|
+
if (line && line.missed && !mend && s.state !== 'building' && s.state !== 'off') {
|
|
173
|
+
out.push({ id: s.id, name, trouble: 4, why: line.text, when: '', act: read, ...(job ? { job } : {}) });
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
138
176
|
if (s.state === 'fresh' && sch.same_since && sch.checked_at) {
|
|
139
|
-
out.push({ id: s.id, name, trouble: 0, why: 'Checked ' + clockOf(sch.checked_at, now) + ' · same since ' + clockOf(sch.same_since, now), when: '', act: null });
|
|
177
|
+
out.push({ id: s.id, name, trouble: 0, why: 'Checked ' + clockOf(sch.checked_at, now) + ' · same since ' + clockOf(sch.same_since, now) + (sch.next_run ? ' · next ' + nextOf(sch.next_run, now) : ''), when: '', act: null, ...(job ? { job } : {}) });
|
|
140
178
|
continue;
|
|
141
179
|
}
|
|
142
180
|
const when = s.state === 'off' ? 'Not connected' : s.state === 'building' ? 'Reading now' : mend ? 'Reading again' : s.state === 'never' ? 'Never read'
|
|
143
181
|
: s.id === 'repository' && s.state === 'fresh' ? 'Watching' : short(ago(s.as_of, now)) || 'Never read';
|
|
144
|
-
|
|
145
|
-
|
|
182
|
+
// a source PMOS reads on a schedule shows ↻ only when it missed a read (above); one with no next read keeps ↻ while it is behind
|
|
183
|
+
const behind = (s.state === 'stale' || s.state === 'never') && s.id !== 'repository' && !mend && !sch.next_run;
|
|
184
|
+
out.push({ id: s.id, name, trouble: 0, why: line && !mend && s.state !== 'building' ? line.text : '', when, act: behind ? read : null, ...(job ? { job } : {}) });
|
|
146
185
|
}
|
|
147
186
|
for (const i of alone) out.push({ id: 'issue:' + i.key, name: i.name || 'Background work', trouble: 3, why: i.why, when: '', act: i.key === 'signedout' ? { kind: 'sec', label: 'Open Settings › PMOS', sec: 'claude' } : null });
|
|
148
187
|
return out.map((r, k) => ({ r, k })).sort((a, b) => (a.r.trouble || 9) - (b.r.trouble || 9) || a.k - b.k).map((x) => x.r);
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/* pm/cozy-schedwork.js — Scheduled work in Settings › Connectors (batch 31 item 2, agreed design SwC, Wawan 2026-11-18 "Build C").
|
|
2
|
+
*
|
|
3
|
+
* The row line under each source (how often · next, amber with ↻ only when a read was missed) is pm/cozy-evmodel.js scheduleLine. This
|
|
4
|
+
* module draws the two panels the rows open, inside the Connectors section (cozy-settings.js T.sub):
|
|
5
|
+
* list "Scheduled work": every source PMOS reads on a schedule, PMOS's own jobs and your own scheduled tasks, each with how
|
|
6
|
+
* often and when it runs next. One quiet entry under the sources opens it (swEntry).
|
|
7
|
+
* job:<id> one source or job (lib/refresh.js id), like the scheduled task page of the Claude app: Active, Next run, Repeats,
|
|
8
|
+
* Working hours only, PMOS's ✦ rhythm proposal (✓ saves it, ✕ hides it for today), History and ▶ Read now.
|
|
9
|
+
* task:<id> one of your scheduled tasks (schedules.json): Active, Next run, Repeats (Every hour is new), last run and ▶ Run now.
|
|
10
|
+
* Reads GET /api/refresh?ws= (lib/routes-refresh.js: rows with next_at, missed_at, propose, runs) and GET /api/schedules?all=1. Writes are
|
|
11
|
+
* the PM's presses: POST /api/refresh/source { id, on | schedule }, /api/refresh/run { id, ws }, /api/schedules/update, /api/schedules/run.
|
|
12
|
+
* PMOS proposes the rhythm; the PM approves it or picks another. Nothing here changes a schedule by itself.
|
|
13
|
+
* swLine(row, now) · repeatOpts(row) · taskLine(s, now) — pure, for the tests. */
|
|
14
|
+
import { pmGet, pmPost } from './http.js';
|
|
15
|
+
import { esc, svg, ICON, toast, wsParam } from './cozy-evui.js';
|
|
16
|
+
import { nextOf, atOf, everyLine } from './cozy-evmodel.js';
|
|
17
|
+
|
|
18
|
+
const CHEV = 'M10 7l5 5-5 5', BACK = 'M15 18l-6-6 6-6', PLAY = 'M8 5l11 7-11 7z', SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', CLOCK = 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 7v5l3 2';
|
|
19
|
+
const S = { rows: null, win: null, tasks: null, err: '', busy: false, from: '', undo: null };
|
|
20
|
+
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* no storage */ } } };
|
|
21
|
+
const NOPE = (id) => 'pmos.sw.not-now.' + id;
|
|
22
|
+
const today = () => { const d = new Date(); return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate(); };
|
|
23
|
+
const ib = (attrs, label, d, cls = 'ev-ib') => `<button type="button" class="${cls}" ${attrs} aria-label="${esc(label)}" title="${esc(label)}">${svg(d, 18)}</button>`;
|
|
24
|
+
const swc = (on, attrs, label) => `<button type="button" class="ev-sw" role="switch" aria-checked="${!!on}" aria-label="${esc(label)}" ${attrs}>${on ? 'On' : 'Off'}</button>`;
|
|
25
|
+
const at = atOf;
|
|
26
|
+
const kv = (icon, k, v) => `<div class="ev-trow ev-sw-kv"><span class="ev-sw-ic" aria-hidden="true">${svg(icon, 18)}</span><span class="ev-grow">${esc(k)}</span>${v}</div>`;
|
|
27
|
+
|
|
28
|
+
/** The line under a row of the list: "Every 30 min in working hours · next 10:00", "Missed 09:00 · read yesterday", "Off". */
|
|
29
|
+
export function swLine(r, now = Date.now()) {
|
|
30
|
+
if (!r) return { text: '', missed: false };
|
|
31
|
+
if (!r.on) return { text: 'Off', missed: false };
|
|
32
|
+
if (r.missed_at) return { text: 'Missed ' + atOf(r.missed_at, now) + (r.last && r.last.at ? ' · read ' + atOf(r.last.at, now) : ' · never read'), missed: true };
|
|
33
|
+
if (r.state === 'running') return { text: 'Running now', missed: false };
|
|
34
|
+
const nx = r.next_at ? nextOf(r.next_at, now) : '';
|
|
35
|
+
if (!r.schedule_text && r.set_in) return { text: 'Set in ' + r.set_in.replace(/, /, ' › '), missed: false };
|
|
36
|
+
return { text: everyLine(r.schedule_text) + (nx ? ' · next ' + nx : ''), missed: false };
|
|
37
|
+
}
|
|
38
|
+
const EVERY_WORD = { 15: 'Every 15 min', 30: 'Every 30 min', 60: 'Every hour', 120: 'Every 2 hours', 240: 'Every 4 hours' };
|
|
39
|
+
/** The choices of Repeats for a row: [[value, label, selected]]: by the press, every 15 min to 4 hours, every day, working days, once a week.
|
|
40
|
+
* A day-based choice keeps its times (At) and day (On). */
|
|
41
|
+
export function repeatOpts(r) {
|
|
42
|
+
const s = r && r.schedule; if (!s) return [];
|
|
43
|
+
const cur = s.kind === 'every' ? 'every:' + s.every : s.kind;
|
|
44
|
+
const out = [];
|
|
45
|
+
if ((r.kinds || []).includes('manual')) out.push(['manual', 'Only when you press read', cur === 'manual']);
|
|
46
|
+
for (const v of r.every || []) out.push(['every:' + v, EVERY_WORD[v] || 'Every ' + v + ' min', cur === 'every:' + v]);
|
|
47
|
+
if ((r.kinds || []).includes('daily')) for (const [k, l] of [['daily', 'Every day'], ['weekdays', 'Working days'], ['weekly', 'Once a week']]) out.push([k, l, cur === k]);
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
const TASK_CAD = [['hourly', 'Every hour'], ['daily', 'Every day'], ['weekly', 'Every week'], ['bi-weekly', 'Every 2 weeks'], ['monthly', 'Every month']];
|
|
51
|
+
const DAYN = { Mon: 'Monday', Tue: 'Tuesday', Wed: 'Wednesday', Thu: 'Thursday', Fri: 'Friday', Sat: 'Saturday', Sun: 'Sunday' };
|
|
52
|
+
/** Your scheduled task in words: "Every hour at :15 · next 10:15", "Every Friday at 16:00 · next Fri 16:00", "Off". */
|
|
53
|
+
export function taskLine(s, now = Date.now()) {
|
|
54
|
+
if (!s) return '';
|
|
55
|
+
if (s.enabled === false) return 'Off';
|
|
56
|
+
const t = String(s.time || '09:00'), d = DAYN[s.day] || 'Monday';
|
|
57
|
+
const rep = s.cadence === 'hourly' ? 'Every hour at :' + t.slice(-2) : s.cadence === 'daily' ? 'Every day at ' + t : s.cadence === 'weekly' ? 'Every ' + d + ' at ' + t
|
|
58
|
+
: s.cadence === 'bi-weekly' ? 'Every other ' + d + ' at ' + t : s.cadence === 'monthly' ? 'On day ' + (s.dayOfMonth || 1) + ' of each month at ' + t : s.cadence === 'once' ? 'Once, ' + (s.date || '') + ' at ' + t : String(s.cadence || '');
|
|
59
|
+
const nx = s.next ? nextOf(s.next, now) : '';
|
|
60
|
+
return rep + (nx ? ' · next ' + nx : '');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Read the rows and your tasks. `draw` redraws Settings. */
|
|
64
|
+
export async function swLoad(draw) {
|
|
65
|
+
const ws = wsParam() || '';
|
|
66
|
+
const [r, t] = await Promise.all([pmGet('/api/refresh' + (ws ? '?ws=' + encodeURIComponent(ws) : '')), pmGet('/api/schedules?all=1')]);
|
|
67
|
+
S.rows = r && r.ok && Array.isArray(r.rows) ? r.rows : []; S.win = r && r.window ? r.window : null;
|
|
68
|
+
S.tasks = t && Array.isArray(t.schedules) ? t.schedules.filter((x) => !x.endedReason) : [];
|
|
69
|
+
S.err = !r || !r.ok ? 'The schedules could not be read' + (r && r.error ? ': ' + r.error : '') + '.' : '';
|
|
70
|
+
if (draw) draw();
|
|
71
|
+
}
|
|
72
|
+
export const swReset = () => { S.rows = null; S.tasks = null; S.err = ''; S.from = ''; };
|
|
73
|
+
const shown = () => (S.rows || []).filter((r) => r.run !== 'change');
|
|
74
|
+
/** The quiet entry under the sources: "Scheduled work · 9 jobs". */
|
|
75
|
+
export function swEntry() {
|
|
76
|
+
const n = S.rows ? shown().filter((r) => r.on).length + (S.tasks || []).filter((x) => x.enabled !== false).length : null;
|
|
77
|
+
return `<div class="ev-trow ev-fr ev-sw-entry"><span class="ev-gut"></span><span class="ev-sw-ic" aria-hidden="true">${svg(CLOCK, 18)}</span><div class="ev-tx ev-grow"><span>Scheduled work</span>${n != null ? `<p class="ev-small ev-mut">${n} ${n === 1 ? 'job runs' : 'jobs run'} on a schedule</p>` : ''}</div>`
|
|
78
|
+
+ ib('data-ev-sw="list"', 'Open Scheduled work', CHEV) + '</div>';
|
|
79
|
+
}
|
|
80
|
+
const head = (title, back, backLabel) => `<div class="ev-dr-hd">${ib(`data-ev-sw="${esc(back)}"`, backLabel, BACK)}<h4 class="ev-grow">${esc(title)}</h4></div>`;
|
|
81
|
+
|
|
82
|
+
function listHtml(now) {
|
|
83
|
+
const rows = shown();
|
|
84
|
+
const row = (r) => { const l = swLine(r, now); return `<div class="ev-trow ev-fr"><span class="ev-gut">${l.missed ? '<i class="ev-dot risk" aria-hidden="true"></i>' : ''}</span><div class="ev-tx ev-grow"><span>${esc(r.label)}</span><p class="ev-small ${l.missed ? 'ev-late' : 'ev-mut'}">${esc(l.text)}</p></div>${ib(`data-ev-sw="job:${esc(r.id)}" data-ev-sw-from="list"`, 'Open ' + r.label, CHEV)}</div>`; };
|
|
85
|
+
const grp = (label, list) => (list.length ? `<p class="ev-mlbl ev-sw-grp">${esc(label)}</p>` + list.join('') : '');
|
|
86
|
+
const tasks = (S.tasks || []).map((s) => `<div class="ev-trow ev-fr"><span class="ev-gut"></span><div class="ev-tx ev-grow"><span>${esc(s.name || s.skill)}</span><p class="ev-small ev-mut">${esc(taskLine(s, now))}</p></div>${ib(`data-ev-sw="task:${esc(s.id)}"`, 'Open ' + (s.name || s.skill), CHEV)}</div>`);
|
|
87
|
+
return head('Scheduled work', '', 'Back to Connectors')
|
|
88
|
+
+ (S.err ? `<p class="ev-small ev-mut">${esc(S.err)}</p>` : '')
|
|
89
|
+
+ grp('PMOS reads', rows.filter((r) => r.run === 'skill').map(row))
|
|
90
|
+
+ grp('PMOS’s own jobs', rows.filter((r) => r.run === 'job').map(row))
|
|
91
|
+
+ grp('Your scheduled tasks', tasks)
|
|
92
|
+
+ (S.tasks && !S.tasks.length ? '<p class="ev-small ev-mut">You have no scheduled tasks of your own.</p>' : '');
|
|
93
|
+
}
|
|
94
|
+
const RESULT = { done: 'done', failed: 'failed', skipped: 'skipped', interrupted: 'stopped', running: 'running' };
|
|
95
|
+
function jobHtml(r, now) {
|
|
96
|
+
const back = S.from === 'list' ? 'list' : '', backLabel = S.from === 'list' ? 'Back to Scheduled work' : 'Back to Connectors';
|
|
97
|
+
if (!r) return head('Scheduled work', back, backLabel) + '<p class="ev-small ev-mut">This job could not be read.</p>';
|
|
98
|
+
const s = r.schedule, skip = r.missed_at ? (r.runs || []).find((x) => x.result === 'skipped' && Date.parse(x.start_at) >= Date.parse(r.missed_at)) : null;
|
|
99
|
+
const warn = r.missed_at ? `<div class="ev-warn ev-line ev-sw-warn"><i class="ev-dot risk" aria-hidden="true"></i><p class="ev-grow">${esc((r.last && r.last.at ? 'Last read ' + at(r.last.at, now) + '. ' : 'Never read. ') + 'PMOS missed ' + atOf(r.missed_at, now) + (skip && skip.note ? ': ' + skip.note + '.' : ', because PMOS was not running then or your computer slept.'))}</p></div>` : '';
|
|
100
|
+
const opts = repeatOpts(r);
|
|
101
|
+
const rep = opts.length ? `<label class="ev-vh" for="evSwRep">Repeats</label><select id="evSwRep" class="ev-inp" data-ev-sw-rep="${esc(r.id)}"${S.busy ? ' disabled' : ''}>${opts.map(([v, l, on]) => `<option value="${esc(v)}"${on ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select>`
|
|
102
|
+
: `<span class="ev-small ev-mut">${esc(everyLine(r.schedule_text) || 'Not set here')}</span>`;
|
|
103
|
+
const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
104
|
+
const times = s && ['daily', 'weekdays', 'weekly'].includes(s.kind) ? kv(CLOCK, 'At', `<label class="ev-vh" for="evSwAt">At</label><input id="evSwAt" class="ev-inp ev-sw-at" type="time" value="${esc((s.times || ['09:00'])[0])}" data-ev-sw-at="${esc(r.id)}">`)
|
|
105
|
+
+ (s.kind === 'weekly' ? kv(ICON.cal, 'On', `<label class="ev-vh" for="evSwDay">On</label><select id="evSwDay" class="ev-inp" data-ev-sw-day="${esc(r.id)}">${DAYS.map((d) => `<option value="${d}"${s.day === d ? ' selected' : ''}>${esc(DAYN[d])}</option>`).join('')}</select>`) : '')
|
|
106
|
+
+ ((s.times || []).length > 1 ? `<p class="ev-small ev-mut ev-sw-more">Also at ${esc(s.times.slice(1).join(' and '))}.</p>` : '') : '';
|
|
107
|
+
const work = s && s.kind === 'every' && r.run === 'skill' ? kv(CLOCK, 'Working hours only' + (S.win ? ' (' + S.win.start + ' to ' + S.win.end + ')' : ''), swc(s.work, `data-ev-sw-work="${esc(r.id)}"`, 'Working hours only')) : '';
|
|
108
|
+
const nx = !r.on ? 'Off' : r.missed_at ? 'Now, when you press ▶' : r.state === 'running' ? 'Running now' : r.next_at ? nextOf(r.next_at, now) : r.run === 'skill' ? 'Only when you press' : everyLine(r.schedule_text) || '—';
|
|
109
|
+
const p = r.propose && store.get(NOPE(r.id)) !== today() ? r.propose : null;
|
|
110
|
+
const span = p && p.s.work && S.win ? ' from ' + S.win.start + ' to ' + S.win.end : '';
|
|
111
|
+
const prop = p ? `<div class="ev-card ev-sw-prop"><span class="ev-av sp" aria-hidden="true">${svg(SPARK, 15)}</span><div class="ev-grow"><b>Read it more often on meeting days</b><p class="ev-small">Every ${esc(p.every)} min${esc(span)} on days with ${p.meetings} or more meetings. Today has ${p.today}. Other days stay at ${esc(EVERY_WORD[p.s.every] ? EVERY_WORD[p.s.every].replace(/^Every /, '') : p.s.every + ' min')}.</p></div>`
|
|
112
|
+
+ ib(`data-ev-sw-nope="${esc(r.id)}"`, 'Not now', ICON.close) + ib(`data-ev-sw-yes="${esc(r.id)}"`, 'Use this', ICON.check, 'ev-ib ev-jl-pri') + '</div>' : '';
|
|
113
|
+
const runs = (r.runs || []).slice(0, 5).map((x) => `<div class="ev-sw-h"><span>${esc(at(x.start_at, now))}</span><span class="ev-mut">${esc([RESULT[x.result] || x.result || '', x.took_ms != null ? Math.max(1, Math.round(x.took_ms / 60000)) + ' min' : '', x.note || x.error || x.got || ''].filter(Boolean).join(' · '))}</span></div>`).join('');
|
|
114
|
+
const canRun = r.run === 'skill' || r.run === 'job';
|
|
115
|
+
return head(r.label, back, backLabel) + `<p class="ev-small ev-mut ev-sw-what">${esc(r.what || '')}</p>` + warn
|
|
116
|
+
+ `<div class="ev-sw-card">${kv(CLOCK, 'Active', swc(r.on, `data-ev-sw-on="${esc(r.id)}"`, r.label + ': active'))}${kv(ICON.cal, 'Next run', `<span class="ev-small ev-mut">${esc(nx)}</span>`)}${kv(ICON.refresh, 'Repeats', rep)}${times}${work}</div>`
|
|
117
|
+
+ (S.undo && S.undo.id === r.id ? `<div class="ev-trow ev-sw-undo"><p class="ev-small ev-grow">Saved. PMOS reads it more often on meeting days.</p><button type="button" class="ev-btn sm" data-ev-sw-undo="${esc(r.id)}">Undo</button></div>` : '')
|
|
118
|
+
+ prop
|
|
119
|
+
+ `<p class="ev-mlbl ev-sw-grp">History</p>` + (runs ? `<div class="ev-sw-hist">${runs}</div>` : '<p class="ev-small ev-mut">No runs yet.</p>')
|
|
120
|
+
+ (canRun ? `<div class="ev-sw-run">${ib(`data-ev-sw-run="${esc(r.id)}"`, r.run === 'skill' ? 'Read now' : 'Run now', PLAY, 'ev-ib ev-sw-play')}</div>` : '');
|
|
121
|
+
}
|
|
122
|
+
function taskHtml(s, now) {
|
|
123
|
+
if (!s) return head('Scheduled work', 'list', 'Back to Scheduled work') + '<p class="ev-small ev-mut">This task could not be read.</p>';
|
|
124
|
+
const cad = TASK_CAD.some(([v]) => v === s.cadence) ? TASK_CAD : TASK_CAD.concat([[s.cadence, s.cadence === 'once' ? 'Once' : s.cadence]]);
|
|
125
|
+
const rep = `<label class="ev-vh" for="evSwTask">Repeats</label><select id="evSwTask" class="ev-inp" data-ev-sw-cad="${esc(s.id)}"${S.busy ? ' disabled' : ''}>${cad.map(([v, l]) => `<option value="${esc(v)}"${v === s.cadence ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select>`;
|
|
126
|
+
const nx = s.enabled === false ? 'Off' : s.next ? nextOf(s.next, now) : 'Not scheduled';
|
|
127
|
+
const last = s.lastRun ? at(s.lastRun, now) + ({ ok: ' · finished', fail: ' · did not finish', started: ' · started' }[s.lastStatus] || '') : '';
|
|
128
|
+
return head(s.name || s.skill, 'list', 'Back to Scheduled work') + `<p class="ev-small ev-mut ev-sw-what">${esc(taskLine({ ...s, next: null }, now))}. It runs ${esc(s.skill || s.task || '')}.</p>`
|
|
129
|
+
+ `<div class="ev-sw-card">${kv(CLOCK, 'Active', swc(s.enabled !== false, `data-ev-sw-ton="${esc(s.id)}"`, (s.name || s.skill) + ': active'))}${kv(ICON.cal, 'Next run', `<span class="ev-small ev-mut">${esc(nx)}</span>`)}${kv(ICON.refresh, 'Repeats', rep)}</div>`
|
|
130
|
+
+ `<p class="ev-mlbl ev-sw-grp">History</p>` + (last ? `<div class="ev-sw-hist"><div class="ev-sw-h"><span>${esc(last)}</span></div></div>` : '<p class="ev-small ev-mut">No runs yet.</p>')
|
|
131
|
+
+ `<div class="ev-sw-run">${ib(`data-ev-sw-trun="${esc(s.id)}"`, 'Run now', PLAY, 'ev-ib ev-sw-play')}</div>`;
|
|
132
|
+
}
|
|
133
|
+
/** The panel for `sub` ('sw:list', 'sw:job:<id>', 'sw:task:<id>'). */
|
|
134
|
+
export function swBody(sub) {
|
|
135
|
+
const k = String(sub || '').slice(3), now = Date.now();
|
|
136
|
+
if (S.rows === null) return head('Scheduled work', k === 'list' ? '' : 'list', 'Back') + '<p class="ev-small ev-mut">Reading the schedules.</p>';
|
|
137
|
+
if (k === 'list') return listHtml(now);
|
|
138
|
+
if (k.startsWith('job:')) return jobHtml(S.rows.find((r) => r.id === k.slice(4)), now);
|
|
139
|
+
if (k.startsWith('task:')) return taskHtml((S.tasks || []).find((x) => x.id === k.slice(5)), now);
|
|
140
|
+
return '';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const said = (r, ok) => (r && r.ok ? ok : 'Not saved: ' + ((r && r.error) || 'the server did not answer') + '.');
|
|
144
|
+
/** A press inside Scheduled work. → true when it was one. `go(sub)` opens a panel ('' goes back to Connectors); `say(text)` the status line. */
|
|
145
|
+
export async function swPress(t, { go, say, draw }) {
|
|
146
|
+
const d = t.dataset;
|
|
147
|
+
if (d.evSw !== undefined) {
|
|
148
|
+
const k = d.evSw;
|
|
149
|
+
if (k === 'list' || k === '') S.from = '';
|
|
150
|
+
else S.from = d.evSwFrom || '';
|
|
151
|
+
go(k ? 'sw:' + k : '');
|
|
152
|
+
if (k && S.rows === null) swLoad(draw);
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
const id = d.evSwOn || d.evSwWork || d.evSwYes || d.evSwNope || d.evSwRun || d.evSwTon || d.evSwTrun || d.evSwUndo;
|
|
156
|
+
if (!id) return false;
|
|
157
|
+
if (d.evSwNope) { store.set(NOPE(id), today()); say('Hidden for today. PMOS keeps the rhythm you have.'); draw(); return true; }
|
|
158
|
+
if (S.busy) return true;
|
|
159
|
+
S.busy = true;
|
|
160
|
+
try {
|
|
161
|
+
const r = (S.rows || []).find((x) => x.id === id);
|
|
162
|
+
if (d.evSwOn && r) { const on = !r.on, x = await pmPost('/api/refresh/source', { id, on }); say(said(x, on ? r.label + ' is on.' : r.label + ' is off. PMOS does not run it on its own.')); }
|
|
163
|
+
else if (d.evSwWork && r) { const x = await pmPost('/api/refresh/source', { id, schedule: { ...r.schedule, work: !r.schedule.work } }); say(said(x, r.schedule.work ? 'Saved. It runs all day.' : 'Saved. It runs in working hours only.')); }
|
|
164
|
+
else if (d.evSwYes && r && r.propose) { const old = r.schedule, x = await pmPost('/api/refresh/source', { id, schedule: r.propose.s }); if (x && x.ok) S.undo = { id, s: old }; say(said(x, 'Saved. PMOS reads ' + r.label + ' every ' + r.propose.every + ' min on meeting days.')); }
|
|
165
|
+
else if (d.evSwUndo && S.undo && S.undo.id === id) { const x = await pmPost('/api/refresh/source', { id, schedule: S.undo.s }); if (x && x.ok) S.undo = null; say(said(x, 'Undone. The rhythm is as it was.')); }
|
|
166
|
+
else if (d.evSwRun && r) { const x = await pmPost('/api/refresh/run', { id, ws: wsParam() || undefined }); say(x && x.ok ? (x.waiting ? 'It starts once ' + x.waiting.join(', ') + ' finish.' : 'Started. ' + r.label + ' runs now.') : 'It did not start: ' + ((x && x.error) || 'the server did not answer') + '.'); if (x && x.ok) toast('Started.'); }
|
|
167
|
+
else if (d.evSwTon) { const s = (S.tasks || []).find((y) => y.id === id); if (s) { const on = s.enabled === false, x = await pmPost('/api/schedules/update', { id, enabled: on }); say(said(x, on ? 'It runs on its schedule again.' : 'It is off.')); } }
|
|
168
|
+
else if (d.evSwTrun) { const x = await pmPost('/api/schedules/run', { id }); say(x && x.ok !== false ? 'Started.' : 'It did not start: ' + ((x && x.error) || 'the server did not answer') + '.'); }
|
|
169
|
+
} finally { S.busy = false; }
|
|
170
|
+
await swLoad(draw);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
/** A change of Repeats. → true when it was one. */
|
|
174
|
+
export async function swChange(x, { say, draw }) {
|
|
175
|
+
const id = x.dataset.evSwRep || x.dataset.evSwCad || x.dataset.evSwAt || x.dataset.evSwDay;
|
|
176
|
+
if (!id) return false;
|
|
177
|
+
if (S.busy) return true;
|
|
178
|
+
S.busy = true;
|
|
179
|
+
try {
|
|
180
|
+
if (x.dataset.evSwRep) {
|
|
181
|
+
const r = (S.rows || []).find((y) => y.id === id); if (!r) return true;
|
|
182
|
+
const v = x.value, cur = r.schedule || {}, times = cur.times && cur.times.length ? cur.times : ['09:00'];
|
|
183
|
+
let sch;
|
|
184
|
+
if (x.dataset.evSwAt) { if (!/^\d\d:\d\d$/.test(v)) return true; sch = { ...cur, times: [v, ...times.slice(1).filter((y) => y !== v)] }; }
|
|
185
|
+
else if (x.dataset.evSwDay) sch = { ...cur, day: v };
|
|
186
|
+
else if (v === 'manual') sch = { kind: 'manual' };
|
|
187
|
+
else if (v.startsWith('every:')) sch = { kind: 'every', every: v.slice(6), work: cur.kind === 'every' ? !!cur.work : true, ...(cur.busy ? { busy: cur.busy } : {}) };
|
|
188
|
+
else sch = { kind: v, times: v === 'weekly' ? times.slice(0, 1) : times, ...(v === 'weekly' ? { day: cur.day || 'Mon' } : {}) };
|
|
189
|
+
const res = await pmPost('/api/refresh/source', { id, schedule: sch });
|
|
190
|
+
await swLoad();
|
|
191
|
+
const nr = (S.rows || []).find((y) => y.id === id);
|
|
192
|
+
say(said(res, 'Saved. ' + r.label + ': ' + (nr ? everyLine(nr.schedule_text).toLowerCase() : 'saved') + '.'));
|
|
193
|
+
} else {
|
|
194
|
+
const s = (S.tasks || []).find((y) => y.id === id); if (!s) return true;
|
|
195
|
+
const res = await pmPost('/api/schedules/update', { id, cadence: x.value });
|
|
196
|
+
say(said(res, 'Saved. ' + (TASK_CAD.find(([v]) => v === x.value) || [0, x.value])[1] + '.'));
|
|
197
|
+
}
|
|
198
|
+
} finally { S.busy = false; }
|
|
199
|
+
await swLoad(draw);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
* /api/sources/refresh, or the place to fix it); a quiet row has its name and time, and "Checked 10:42 · same since 09:15"
|
|
23
23
|
* where a measured read applies (SrSee R3). Claude's failed background work and the Git sync failure are rows too. ↻ in the
|
|
24
24
|
* header reads every source (POST /api/sources/refresh-all); (i) says what PMOS reads and that it never posts. The switches
|
|
25
|
-
* (what PMOS reads on its own, the connectors your sessions have; GET and POST /api/proactive/settings)
|
|
25
|
+
* (what PMOS reads on its own, the connectors your sessions have; GET and POST /api/proactive/settings) sit under a directory
|
|
26
|
+
* (initiative connectors-directory, CnA/CnB): search, category chips, Connected · N, More sources, ✦ For you, All connectors,
|
|
27
|
+
* a + that opens the Claude account's connector page; PMOS notices the new connector and ✦ proposes what to read (pm/cozy-conndir.js).
|
|
28
|
+
* Scheduled work (batch 31 item 2, agreed design SwC): a scheduled source's line says how often and when it reads next, amber
|
|
29
|
+
* with ↻ only when PMOS missed a read; › on the row opens its page (Active, Next run, Repeats, ✦ rhythm, History, ▶ Read now),
|
|
30
|
+
* and one quiet entry opens the Scheduled work list, your own scheduled tasks too (pm/cozy-schedwork.js; T.sub 'sw:…').
|
|
26
31
|
* Workspaces the repositories PMOS works in (GET and POST /api/workspaces, POST /api/workspaces/forget; the folder is never touched),
|
|
27
32
|
* then the row "Workflows ›" (U4; it was a section of its own that linked out): the stages each kind of initiative goes
|
|
28
33
|
* through (pm/wf-page.js, D99). It opens as a sub-panel here, the Settings dialog widened to the window (UI grill U1: the
|
|
@@ -46,6 +51,8 @@ import * as JL from './cozy-jl.js';
|
|
|
46
51
|
import { pmGet, pmPost, pressFetch } from './http.js';
|
|
47
52
|
import { esc, svg, ICON, toast, wsParam, wsQ } from './cozy-evui.js';
|
|
48
53
|
import { connectorRows, bannerOf } from './cozy-evmodel.js';
|
|
54
|
+
import * as CD from './cozy-conndir.js';
|
|
55
|
+
import * as SW from './cozy-schedwork.js';
|
|
49
56
|
import * as AD from './cozy-adler.js';
|
|
50
57
|
import * as SE from './cozy-seasons.js';
|
|
51
58
|
import { weeksOf, lineOf, storiesOf } from './upd-weeks.js';
|
|
@@ -59,7 +66,7 @@ const SECTIONS = [['general', 'General'], ['claude', 'PMOS'], ['connectors', 'Co
|
|
|
59
66
|
const SUBS = { adler: 'Adler', jl: 'Jev and Laya', workflows: 'Workflows' }; // General › Extras and Workspaces › Workflows: each opens as a sub-panel of its section (U4, U1)
|
|
60
67
|
const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
|
|
61
68
|
const VIEWER_KEY = 'pmos.cz.viewer';
|
|
62
|
-
const T = { el: null, sec: 'general', sub: '', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, info: false, fold: false, dress: false, more: false, bday: false, dset: {}, wkOpen: new Set(), wkMore: new Set(), arc: false };
|
|
69
|
+
const T = { el: null, sec: 'general', sub: '', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, info: false, fold: false, dir: null, q: '', cat: 'all', wait: null, dress: false, more: false, bday: false, dset: {}, wkOpen: new Set(), wkMore: new Set(), arc: false };
|
|
63
70
|
const cmpVer = (a, b) => { const x = String(a || '0').split('-')[0].split('.').map(Number), y = String(b || '0').split('-')[0].split('.').map(Number); for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) < (y[i] || 0) ? -1 : 1; return 0; };
|
|
64
71
|
const home = () => (T.ws && T.ws[0] ? T.st[T.ws[0].id] : null);
|
|
65
72
|
const latest = () => { const s = home(); return (s && (s.latest || (s.lastCheck && s.lastCheck.latest))) || null; };
|
|
@@ -203,8 +210,8 @@ function readsHtml() {
|
|
|
203
210
|
// one list, trouble first (CnA): the amber dot, the one reason and the one action on a trouble row; the name and the time on a quiet one
|
|
204
211
|
const rows = connectorRows(s.sources, s.health).map((x) => `<div class="ev-trow ev-fr${x.trouble ? ' ev-fr-t' : ''}" data-src="${esc(x.id)}"><span class="ev-gut">${x.trouble ? '<i class="ev-dot risk" aria-hidden="true"></i>' : ''}</span>`
|
|
205
212
|
+ `<div class="ev-tx ev-grow">${x.trouble ? `<b>${esc(x.name)}</b>` : `<span>${esc(x.name)}</span>`}${x.why ? `<p class="ev-small ev-why ${x.trouble ? 'ev-late' : 'ev-mut'}">${x.trouble ? '<span class="ev-vh">Needs a look: </span>' : ''}${esc(x.why)}</p>` : ''}${T.note[x.id] ? `<p class="ev-small" role="status">${esc(T.note[x.id])}</p>` : ''}</div>`
|
|
206
|
-
+ `${x.when ? `<span class="ev-small ev-mut">${esc(x.when)}</span>` : ''}${act(x)}</div>`).join('');
|
|
207
|
-
return `<div class="ev-reads">${rows}</div
|
|
213
|
+
+ `${x.when ? `<span class="ev-small ev-mut">${esc(x.when)}</span>` : ''}${act(x)}${x.job ? `<button type="button" class="ev-ib" data-ev-sw="job:${esc(x.job)}" aria-label="${esc('Open ' + x.name + ': how often and when it runs next')}" title="How often and when it runs next">${svg(CHEV, 18)}</button>` : ''}</div>`).join('');
|
|
214
|
+
return `<div class="ev-reads">${rows}</div>` + SW.swEntry();
|
|
208
215
|
}
|
|
209
216
|
/** The amber box at the top of Settings, only when the PM must act on a source (self-heal, feedback batch 26 item 7). While Claude
|
|
210
217
|
* reads a source again by itself, or after it did, there is no box. The box names the one action and links to the exact place:
|
|
@@ -217,19 +224,92 @@ function staleHtml() {
|
|
|
217
224
|
: `<a class="ev-ib ev-ib-card" href="${esc(a.href || '#' + a.sec)}"${a.href ? ' target="_blank" rel="noopener"' : ` data-ev-sec="${esc(a.sec)}"`} aria-label="${esc(a.label)}" title="${esc(a.label)}">${svg(ICON.open, 18)}</a>`;
|
|
218
225
|
return `<div class="ev-warn ev-line ev-st-warn" id="srcWarn" data-cause="${esc(b.cause || '')}"><i class="ev-dot risk" aria-hidden="true"></i><p class="ev-grow"><b>${esc(b.title)}</b> ${esc(b.body)}${a.read ? '' : ' ' + esc(a.how)}</p>${act}</div>`;
|
|
219
226
|
}
|
|
220
|
-
const INFO = 'PMOS reads these sources and never posts to them. A switch chooses only what PMOS reads on its own; your Claude sessions can use every connector.';
|
|
227
|
+
const INFO = 'PMOS reads these sources and never posts to them. A switch chooses only what PMOS reads on its own; your Claude sessions can use every connector. PMOS keeps no passwords or keys.';
|
|
228
|
+
/* The directory (initiative connectors-directory; canvas CnA, CnB): search and category chips, Connected · N with every switch of
|
|
229
|
+
* before (a brief source or a connector of the session; each row keeps a slot for the event relay's Listening), ✦ For you, All
|
|
230
|
+
* connectors, a + on each. PMOS cannot add a connector: + opens the connector page of the Claude account, and PMOS waits and notices
|
|
231
|
+
* it (GET /api/connectors/directory?probe=1 every 5 s for 2 minutes). A connector that appears gets one ✦ proposal of what to read;
|
|
232
|
+
* nothing reads it until ✓ (POST /api/proactive/settings with the proposal's patch, then POST /api/connectors/decide). */
|
|
233
|
+
const CONNECT_URL = 'https://claude.ai/settings/connectors';
|
|
234
|
+
const tile = (name) => `<span class="ev-cn-lg" aria-hidden="true">${esc(CD.letter(name))}</span>`;
|
|
235
|
+
const slot = (name) => `<span class="ev-cn-slot" data-ev-listen-slot="${esc(name)}"></span>`; // the event relay's Listening (initiative event-relay)
|
|
236
|
+
const plusBtn = (c) => T.wait && T.wait.id === c.id
|
|
237
|
+
? `<span class="ev-pill y ev-cn-wait" role="status">Waiting for ${esc(c.name)}</span>`
|
|
238
|
+
: `<a class="ev-ib ev-cn-add" href="${esc((T.dir && T.dir.connectUrl) || CONNECT_URL)}" target="_blank" rel="noopener" data-ev-cadd="${esc(c.id)}" aria-label="${esc('Connect ' + c.name + ' in your Claude account')}" title="${esc('Connect ' + c.name + ' in your Claude account')}">${svg(PLUS, 18)}</a>`;
|
|
239
|
+
function propCards() {
|
|
240
|
+
const ps = (T.dir && T.dir.proposals) || [];
|
|
241
|
+
return ps.map((x) => `<div class="ev-cn-rec" data-ev-prop="${esc(x.name)}">${tile(x.label, x.label)}<div class="ev-grow"><b>${esc(x.label)} is connected.</b><p class="ev-small ev-mut">${svg(SPARK, 14)} PMOS proposes: ${esc(x.reads)}. Nothing reads it until you approve.</p></div>`
|
|
242
|
+
+ `<button type="button" class="ev-ib" data-ev-pno="${esc(x.name)}" aria-label="${esc('Not now: ' + x.label)}" title="Not now">${svg(CROSS, 18)}</button>`
|
|
243
|
+
+ `<button type="button" class="ev-ib ev-cn-ok" data-ev-pok="${esc(x.name)}" aria-label="${esc('Approve: ' + x.reads)}" title="Approve">${svg(ICON.check, 18)}</button></div>`).join('');
|
|
244
|
+
}
|
|
245
|
+
function connList() {
|
|
246
|
+
const D = CD.directory({ connected: (T.dir && T.dir.connected) || T.conn, signals: (T.dir && T.dir.signals) || [], q: T.q, cat: T.cat });
|
|
247
|
+
const q = String(T.q || '').trim().toLowerCase(), cOk = (label) => (T.cat === 'all' || CD.catOf(label) === T.cat) && (!q || label.toLowerCase().includes(q));
|
|
248
|
+
const row = (label, key, sub, right, name) => `<div class="ev-trow ev-cn-r">${tile(label, key)}<div class="ev-tx ev-grow"><b>${esc(label)}</b><p class="ev-small ev-mut">${esc(sub)}</p></div>${slot(name || key)}${right}</div>`;
|
|
249
|
+
// a connected connector that backs a brief source carries that source's switch; one that backs none, its own switch (as before)
|
|
250
|
+
const list = (T.dir && T.dir.connected) || T.conn, backed = new Set(list.map((c) => c.source).filter(Boolean));
|
|
251
|
+
const conRows = D.connected.map((c) => { const label = c.label || c.name;
|
|
252
|
+
return c.source && c.source in T.src ? row(label, label, T.src[c.source] ? 'PMOS reads it on its own' : 'PMOS does not read it on its own', sw(T.src[c.source], `data-ev-src="${c.source}"`, label), c.name)
|
|
253
|
+
: row(label, label, T.con[c.name] ? 'On. Your sessions can use it' : 'Your sessions can use it', sw(T.con[c.name], `data-ev-conn="${esc(c.name)}"`, label), c.name); });
|
|
254
|
+
// the brief sources no connector backs yet keep their switch, with a + when the directory knows the service
|
|
255
|
+
const loose = Object.keys(SRC).filter((k) => k in T.src && !backed.has(k) && cOk(SRC[k]));
|
|
256
|
+
const looseIds = new Set(loose.map((k) => (CD.matchOf(SRC[k]) || {}).id).filter(Boolean));
|
|
257
|
+
const looseRows = loose.map((k) => { const m = CD.matchOf(SRC[k]); return row(SRC[k], SRC[k], T.src[k] ? 'PMOS reads it on its own' : 'PMOS does not read it on its own', (m ? plusBtn(m) : '') + sw(T.src[k], `data-ev-src="${k}"`, SRC[k]), k); });
|
|
258
|
+
const count = D.count;
|
|
259
|
+
const head = `<div class="ev-cn-sec"><b class="ev-lbl ev-grow">Connected · ${count}</b>`
|
|
260
|
+
+ `<button type="button" class="ev-ib" data-ev-fold aria-expanded="${!T.fold}" aria-controls="evConMore" aria-label="${T.fold ? 'Show the connected ones' : 'Hide the connected ones'}" title="${T.fold ? 'Show the connected ones' : 'Hide the connected ones'}">${svg(T.fold ? CHEV : ICON.down, 18)}</button></div><p class="ev-small ev-mut ev-cn-note">Your sessions can use all of them. A switch chooses what PMOS reads on its own.</p>`;
|
|
261
|
+
const conn = head + (T.fold && !q && T.cat === 'all' ? '' : `<div class="ev-cn-grp" id="evConMore">${conRows.join('') || '<p class="ev-small ev-mut ev-cn-none">None match.</p>'}</div>`)
|
|
262
|
+
+ (looseRows.length ? `<div class="ev-cn-sec"><b class="ev-lbl">More sources</b></div><div class="ev-cn-grp">${looseRows.join('')}</div>` : '');
|
|
263
|
+
const add = (c, sub) => `<div class="ev-trow ev-cn-r">${tile(c.name, c.id)}<div class="ev-tx ev-grow"><b>${esc(c.name)}</b><p class="ev-small ev-mut">${esc(sub)}</p></div>${plusBtn(c)}</div>`;
|
|
264
|
+
D.forYou = D.forYou.filter((c) => !looseIds.has(c.id));
|
|
265
|
+
const fy = D.forYou.length ? `<div class="ev-cn-sec"><b class="ev-lbl">For you</b></div><p class="ev-small ev-mut ev-cn-note">${svg(SPARK, 14)} PMOS suggests these from what you connected and what your initiatives link</p><div class="ev-cn-grp">${D.forYou.map((c) => add(c, c.why)).join('')}</div>` : '';
|
|
266
|
+
const rest = D.all.filter((c) => !looseIds.has(c.id));
|
|
267
|
+
const all = rest.length ? `<div class="ev-cn-sec"><b class="ev-lbl">All connectors</b></div><div class="ev-cn-grp">${rest.map((c) => add(c, c.what)).join('')}</div>` : '';
|
|
268
|
+
return conn + fy + all;
|
|
269
|
+
}
|
|
221
270
|
function connectors() {
|
|
271
|
+
if (T.sub && T.sub.startsWith('sw:')) return SW.swBody(T.sub);
|
|
222
272
|
const info = T.info ? `<p class="ev-small ev-mut ev-info" id="evConInfo">${esc(INFO)}</p>` : '';
|
|
223
273
|
if (T.src === null) return info + readsHtml() + '<p class="ev-small ev-mut">Reading the connectors.</p>';
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
274
|
+
const search = `<label class="ev-cn-search"><span class="ev-vh">Search connectors</span>${svg(ICON.search, 16)}<input type="search" class="ev-inp" id="evConQ" placeholder="Search connectors" value="${esc(T.q || '')}" autocomplete="off"></label>`;
|
|
275
|
+
const chips = `<div class="ev-cn-chips" role="group" aria-label="Category">${CD.CATS.map(([k, l]) => `<button type="button" class="ev-chip${T.cat === k ? ' on' : ''}" data-ev-ccat="${k}" aria-pressed="${T.cat === k}">${esc(l)}</button>`).join('')}</div>`;
|
|
276
|
+
return info + readsHtml() + propCards() + `<div class="ev-cn">${search}${chips}<div id="evConList">${connList()}</div>`
|
|
277
|
+
+ `<p class="ev-small ev-mut ev-cn-foot">PMOS keeps no passwords or keys. A connector is added in your Claude account: + opens that page, and PMOS notices when it is there.</p></div>`;
|
|
278
|
+
}
|
|
279
|
+
/** The directory's read; after a +, again every 5 s with the probe until the connector shows or 2 minutes pass. */
|
|
280
|
+
async function readDir(probe) {
|
|
281
|
+
const d = await pmGet('/api/connectors/directory' + (probe ? '?probe=1' : '')).catch(() => null);
|
|
282
|
+
if (d && d.ok) T.dir = d;
|
|
283
|
+
return d && d.ok ? d : null;
|
|
284
|
+
}
|
|
285
|
+
let waitTimer = null;
|
|
286
|
+
function stopWait() { if (waitTimer) clearTimeout(waitTimer); waitTimer = null; T.wait = null; }
|
|
287
|
+
function startWait(id) {
|
|
288
|
+
const c = CD.CATALOG.find((x) => x.id === id); if (!c) return;
|
|
289
|
+
stopWait();
|
|
290
|
+
const before = new Set(((T.dir && T.dir.connected) || T.conn).map((x) => x.name));
|
|
291
|
+
T.wait = { id, name: c.name, until: Date.now() + 120000 };
|
|
292
|
+
const tick = async () => {
|
|
293
|
+
if (!T.wait || T.wait.id !== id || !T.el || T.el.hidden) return;
|
|
294
|
+
const d = await readDir(true);
|
|
295
|
+
const got = d && d.connected.find((x) => !before.has(x.name) && (CD.matchOf(x.label || x.name) || {}).id === id);
|
|
296
|
+
if (got) { stopWait(); T.conn = d.connected; toast(c.name + ' is connected.'); draw(); return; }
|
|
297
|
+
if (Date.now() > T.wait.until) { stopWait(); T.msg = 'PMOS has not seen ' + c.name + ' yet. It shows here once it is added in your Claude account and a session starts.'; draw(); return; }
|
|
298
|
+
waitTimer = setTimeout(tick, 5000);
|
|
299
|
+
};
|
|
300
|
+
waitTimer = setTimeout(tick, 5000);
|
|
301
|
+
}
|
|
302
|
+
async function decideProp(name, ok) {
|
|
303
|
+
const x = ((T.dir && T.dir.proposals) || []).find((y) => y.name === name); if (!x) return;
|
|
304
|
+
if (ok) {
|
|
305
|
+
const r = await pmPost('/api/proactive/settings', x.patch);
|
|
306
|
+
if (!(r && r.ok)) { T.msg = (r && r.error) || 'Not saved.'; draw(); return; }
|
|
307
|
+
if (x.patch.briefSources) Object.assign(T.src, x.patch.briefSources); if (x.patch.connectors) Object.assign(T.con, x.patch.connectors);
|
|
308
|
+
}
|
|
309
|
+
const d = await pmPost('/api/connectors/decide', { name, verdict: ok ? 'approve' : 'dismiss' });
|
|
310
|
+
if (d && d.ok) T.dir = { ...T.dir, proposals: T.dir.proposals.filter((y) => y.name !== name) }; else if (!ok) T.msg = (d && d.error) || 'Not saved.';
|
|
311
|
+
if (ok) toast('Approved. PMOS will ' + x.reads + '.');
|
|
312
|
+
draw();
|
|
233
313
|
}
|
|
234
314
|
function workspaces() {
|
|
235
315
|
if (T.sub === 'workflows') return subHead('workflows') + '<div class="ev-wfh" data-ev-wfhost></div>'; // pm/wf-page.js draws into it (UI grill U1)
|
|
@@ -388,7 +468,7 @@ function checksSec() {
|
|
|
388
468
|
}
|
|
389
469
|
const BODY = { general, claude: claudeSec, connectors, workspaces, updates };
|
|
390
470
|
// the old section names (deep links, other pages' calls): where their controls are now (U4)
|
|
391
|
-
const MOVED = { checks: ['claude', ''], adler: ['general', 'adler'], jl: ['general', 'jl'], dress: ['general', 'adler'], workflows: ['workspaces', 'workflows'] };
|
|
471
|
+
const MOVED = { scheduled: ['connectors', 'sw:list'], checks: ['claude', ''], adler: ['general', 'adler'], jl: ['general', 'jl'], dress: ['general', 'adler'], workflows: ['workspaces', 'workflows'] };
|
|
392
472
|
let disposeClaudeSetup = null;
|
|
393
473
|
function draw() {
|
|
394
474
|
const el = T.el; if (!el || el.hidden) return;
|
|
@@ -447,6 +527,7 @@ function mount() {
|
|
|
447
527
|
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && T.el && !T.el.hidden && !T.el.contains(e.target) && !(e.target.closest && e.target.closest('.wf-menu'))) { e.preventDefault(); e.stopPropagation(); if (!vwFirst()) closeSettings(); } }, true);
|
|
448
528
|
T.el.addEventListener('change', async (e) => {
|
|
449
529
|
const x = e.target;
|
|
530
|
+
if (await SW.swChange(x, { say: (m) => { T.msg = m; }, draw })) return;
|
|
450
531
|
if (x.matches('[data-ev-prof]')) {
|
|
451
532
|
const r = await pmPost('/api/profiles/prefer', { agent: 'claude', profile: x.value || null });
|
|
452
533
|
if (r && r.ok) { T.cl = { ...T.cl, prefs: { ...((T.cl && T.cl.prefs) || {}) } }; if (x.value) T.cl.prefs.claude = x.value; else delete T.cl.prefs.claude; }
|
|
@@ -462,11 +543,15 @@ function mount() {
|
|
|
462
543
|
const we = r && r.ok && T.set && Array.isArray(T.set.settings) ? T.set.settings.find((x) => x.key === 'time.workEnd') : null; if (we) we.value = Number(e.target.value);
|
|
463
544
|
draw();
|
|
464
545
|
});
|
|
546
|
+
T.el.addEventListener('input', (e) => { if (e.target.id !== 'evConQ') return; T.q = e.target.value.slice(0, 80); const l = T.el.querySelector('#evConList'); if (l) l.innerHTML = connList(); });
|
|
465
547
|
T.el.addEventListener('click', press);
|
|
466
548
|
return T.el;
|
|
467
549
|
}
|
|
468
550
|
async function press(e) {
|
|
469
|
-
const t = e.target.closest('a[data-ev-sec], button'); if (!t) return;
|
|
551
|
+
const t = e.target.closest('a[data-ev-sec], a[data-ev-cadd], button'); if (!t) return;
|
|
552
|
+
if (t.dataset.evCadd) { startWait(t.dataset.evCadd); draw(); return; } // the link opens the Claude account's connector page; PMOS waits for it
|
|
553
|
+
if (t.dataset.evCcat) { T.cat = t.dataset.evCcat; draw(); const f = T.el.querySelector(`[data-ev-ccat="${T.cat}"]`); if (f) f.focus(); return; }
|
|
554
|
+
if (t.dataset.evPok || t.dataset.evPno) { if (T.busy) return; T.busy = true; try { await decideProp(t.dataset.evPok || t.dataset.evPno, !!t.dataset.evPok); } finally { T.busy = false; } return; }
|
|
470
555
|
if (t.dataset.evSec) { e.preventDefault(); const m = MOVED[t.dataset.evSec]; T.sec = m ? m[0] : t.dataset.evSec; T.sub = m ? m[1] : ''; T.msg = ''; T.dress = false; draw(); const f = T.el.querySelector(`[data-ev-sec="${T.sec}"]`); if (f) f.focus(); openCheck(); return; }
|
|
471
556
|
if ('evClose' in t.dataset) { closeSettings(); return; }
|
|
472
557
|
if (t.dataset.evWk) { const k = t.dataset.evWk; if (T.wkOpen.has(k)) T.wkOpen.delete(k); else T.wkOpen.add(k); draw(); return; }
|
|
@@ -524,6 +609,7 @@ async function press(e) {
|
|
|
524
609
|
draw(); return;
|
|
525
610
|
}
|
|
526
611
|
if (await JL.press(t, draw, (m) => { T.msg = m; })) return;
|
|
612
|
+
if (await SW.swPress(t, { go: (k) => { T.sub = k; T.msg = ''; draw(); const f = T.el.querySelector('.ev-dr-hd .ev-ib') || T.el.querySelector('[data-ev-sw="list"]'); if (f) f.focus(); }, say: (m) => { T.msg = m; }, draw })) return;
|
|
527
613
|
if (t.dataset.evRead || 'evReadall' in t.dataset) { readAgain(t.dataset.evRead || ''); return; }
|
|
528
614
|
if (T.busy) return;
|
|
529
615
|
T.busy = true; T.msg = '';
|
|
@@ -603,6 +689,7 @@ async function readAgain(id) {
|
|
|
603
689
|
}
|
|
604
690
|
async function load() {
|
|
605
691
|
readFresh();
|
|
692
|
+
SW.swLoad(draw);
|
|
606
693
|
pmGet('/api/autonomy/kinds').then((k) => { T.ck = k && k.ok ? k : { ok: false, error: (k && k.error) || '' }; draw(); }).catch(() => { T.ck = { ok: false }; draw(); });
|
|
607
694
|
pmGet('/api/artefacts/lessons').then((l) => { T.ls = l && l.ok ? l : null; draw(); }).catch(() => { T.ls = null; });
|
|
608
695
|
pmGet('/api/grill').then((g) => { T.gr = g && g.ok ? g : { ok: false, error: (g && g.error) || '' }; draw(); }).catch(() => { T.gr = { ok: false }; draw(); });
|
|
@@ -613,6 +700,7 @@ async function load() {
|
|
|
613
700
|
JL.load(T.ws.filter((x) => !x.linked), draw); // a linked worktree is its repository: one row each
|
|
614
701
|
T.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {}; T.con = p && p.ok && p.settings ? { ...p.settings.connectors } : {};
|
|
615
702
|
T.conn = p && p.connectors && Array.isArray(p.connectors.list) ? p.connectors.list : [];
|
|
703
|
+
readDir(false).then(() => draw()); // the directory: proposals, ✦ For you signals (initiative connectors-directory)
|
|
616
704
|
T.set = s && s.ok ? s : null;
|
|
617
705
|
if (T.set) await AD.loadPrefs(async () => T.set);
|
|
618
706
|
// the registered products with their ticks: the pick's own read, the one Home, Board and Intelligence share (workspace grill W4: the
|
|
@@ -631,7 +719,7 @@ export function openSettings(section, o = {}) {
|
|
|
631
719
|
const m = MOVED[section];
|
|
632
720
|
if (m) { T.sec = m[0]; T.sub = m[1]; T.dress = section === 'dress'; } else if (section && BODY[section]) { T.sec = section; T.sub = ''; T.dress = false; }
|
|
633
721
|
else if (el.hidden) { T.sec = 'general'; T.sub = ''; T.dress = false; } // a fresh open with no section opens on General (R2), not on the section of the last visit
|
|
634
|
-
if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.wkMore = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.info = false; T.fold = false; T.dset = {}; T.cl = null; T.gr = null; T.np = null; T.ck = null; T.ls = null; JL.reset(); }
|
|
722
|
+
if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.auto = false; T.wkOpen = new Set(); T.wkMore = new Set(); T.arc = false; T.fresh = null; T.note = {}; T.info = false; T.fold = false; T.dir = null; T.q = ''; T.cat = 'all'; stopWait(); T.dset = {}; T.cl = null; T.gr = null; T.np = null; T.ck = null; T.ls = null; JL.reset(); SW.swReset(); }
|
|
635
723
|
el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
|
|
636
724
|
draw();
|
|
637
725
|
const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();
|
|
@@ -640,6 +728,7 @@ export function openSettings(section, o = {}) {
|
|
|
640
728
|
return el;
|
|
641
729
|
}
|
|
642
730
|
export function closeSettings() {
|
|
731
|
+
stopWait();
|
|
643
732
|
if (!T.el || T.el.hidden) return;
|
|
644
733
|
if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
|
|
645
734
|
if (WF) WF.release();
|
|
@@ -530,3 +530,6 @@
|
|
|
530
530
|
.vzc-seg > button, .vzc-chips .vzm-chip { position: relative; overflow: visible; }
|
|
531
531
|
.vzc-seg > button::before, .vzc-chips .vzm-chip::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
|
|
532
532
|
}
|
|
533
|
+
/* the meeting share popover (shareable-meeting-notes): on a cozy page that does not load premium.css or cozy-viewer.css (premium-viewer.html), it names the cozy tokens itself. It lives here, not in premium-vw-doc.css, because the console type check (premium-console-type S1) would turn --sans and --mono back to the console fonts */
|
|
534
|
+
.cz-vw-hd > .vwshp{--hair:var(--cz-hair);--ink:var(--cz-ink);--ink-2:var(--cz-ink2);--ink-3:var(--cz-ink3);--ember:var(--cz-blue);--card:var(--cz-card);--card-solid:var(--cz-card);
|
|
535
|
+
--well:var(--cz-well);--ok:var(--cz-ok);--bad:var(--cz-red);--sans:var(--cz-sans);--mono:var(--cz-mono);--card-shadow:var(--cz-lift);border-radius:18px;padding:10px;max-height:calc(100dvh - 140px);overflow:auto}
|
|
@@ -231,9 +231,6 @@ iframe.vwprint{position:fixed;right:0;bottom:0;width:1px;height:1px;border:0;opa
|
|
|
231
231
|
@media (prefers-reduced-motion:reduce){.vwsw::after{transition:none}}
|
|
232
232
|
/* a meeting's share popover (shareable-meeting-notes, design A plus the follow-up draft, Exploring 2): under the share icon beside ⋯ */
|
|
233
233
|
.cz-vw-hd:has(> .vwshp){position:relative}.cz-vw-hd > .vwshp{top:calc(100% + 2px);right:8px}
|
|
234
|
-
/* on a cozy page that does not load premium.css or cozy-viewer.css (premium-viewer.html), the popover names the cozy tokens itself */
|
|
235
|
-
.cz-vw-hd > .vwshp{--hair:var(--cz-hair);--ink:var(--cz-ink);--ink-2:var(--cz-ink2);--ink-3:var(--cz-ink3);--ember:var(--cz-blue);--card:var(--cz-card);--card-solid:var(--cz-card);
|
|
236
|
-
--well:var(--cz-well);--ok:var(--cz-ok);--bad:var(--cz-red);--sans:var(--cz-sans);--mono:var(--cz-mono);--card-shadow:var(--cz-lift);border-radius:18px;padding:10px;max-height:calc(100dvh - 140px);overflow:auto}
|
|
237
234
|
.vwshp:has(.vwmc){width:380px;max-width:min(380px,calc(100vw - 32px))}
|
|
238
235
|
.vwmc{display:flex;flex-wrap:wrap;gap:6px;padding:4px 8px}
|
|
239
236
|
.vwmchip,.vwmout{display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 12px;border-radius:999px;border:1px solid var(--hair);background:var(--card-solid);color:var(--ink);font:var(--fw-regular) var(--fs-body)/1.2 var(--sans);cursor:pointer}
|
|
@@ -90,6 +90,7 @@ export function repeatsOf(s) {
|
|
|
90
90
|
const t = /^\d{1,2}:\d{2}$/.test(String(s.time || '')) ? String(s.time).padStart(5, '0') : '';
|
|
91
91
|
const at = t ? ' at ' + t : '';
|
|
92
92
|
const day = DAYS[s.day] || 'Monday';
|
|
93
|
+
if (s.cadence === 'hourly') return 'Every hour' + (t ? ' at :' + t.slice(-2) : '');
|
|
93
94
|
if (s.cadence === 'daily') return 'Every day' + at;
|
|
94
95
|
if (s.cadence === 'weekly') return 'Every ' + day + at;
|
|
95
96
|
if (s.cadence === 'bi-weekly') return 'Every other ' + day + at;
|