create-pmos 0.520.0 → 0.522.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/bin/create-pmos.js +81 -42
- package/package.json +39 -31
- 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/bin/pmos.js +2 -1
- package/workspace/board-publish-ui-test.js +1 -1
- package/workspace/changelog.json +38 -0
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/next-prompt.md +4 -4
- package/workspace/guide/published-board.md +15 -3
- package/workspace/lib/board-pack.js +44 -1
- package/workspace/lib/board-publish-choices.js +22 -6
- package/workspace/lib/board-publish-parts.js +95 -0
- package/workspace/lib/boards-host.js +3 -3
- package/workspace/lib/boards-received.js +105 -0
- package/workspace/lib/kit-update.js +51 -21
- package/workspace/lib/routes-board-publish.js +42 -12
- package/workspace/lib/routes-next-prompt.js +12 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-publish.css +3 -0
- package/workspace/public/pm/bd-publish.js +39 -9
- package/workspace/public/pm/bd-shared.css +5 -0
- package/workspace/public/pm/bd-shared.js +72 -10
- package/workspace/public/pm/chat-term.js +22 -0
- package/workspace/public/pm/cozy-board.css +10 -0
- package/workspace/public/pm/cozy-home.css +5 -5
- package/workspace/public/pm/home-chat.js +3 -0
- package/workspace/public/pm/next-prompt-ui.js +6 -3
- package/workspace/public/pm/premium-board.js +8 -2
- package/workspace/public/pm/premium-shell.js +2 -1
- package/workspace/public/pm/readonly-boot.js +4 -1
- package/workspace/public/pm/readonly.js +40 -5
- package/workspace/public/pm/term-view.js +39 -8
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* board-publish-parts.js — a publish of several products and programs in one link (batch 27 item 1, ShA; initiative board-share-several).
|
|
3
|
+
*
|
|
4
|
+
* A PART is one pick of the Share sheet, in pick order: { kind: 'product', ws, board } · { kind: 'program', id } · { kind: 'initiative', id, ws, board }.
|
|
5
|
+
* A program can reach several products: it is picked by id, and its products come from its members (GET /api/programs).
|
|
6
|
+
*
|
|
7
|
+
* groupsOf(parts, programs) -> { groups: [{ ws, board, select: 'kind:id,…' }], tabs: [{ label?, ws, board, program?, kind, id }] } | { error }
|
|
8
|
+
* one group per product the picks touch (its selection is the union of the picks there), one tab per pick. Pure.
|
|
9
|
+
* packOf(parts, { programs, boards, name, make }) -> { ok, pack, kind, label } | { ok: false, status, error }
|
|
10
|
+
* make(group) -> { ok, pack } is lib/routes-board-publish.js makePack: each product's pack is made and swept as today,
|
|
11
|
+
* then lib/board-pack.js combinePacks joins them. A product that cannot be read stops the publish with its sentence.
|
|
12
|
+
* parseParts(raw) -> [part] | null the parts of a request, checked; null when the request is not one of parts */
|
|
13
|
+
const Pack = require('./board-pack.js');
|
|
14
|
+
|
|
15
|
+
const MAX_PARTS = 12;
|
|
16
|
+
const ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
|
|
17
|
+
|
|
18
|
+
function parseParts(raw) {
|
|
19
|
+
if (!Array.isArray(raw) || !raw.length) return null;
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const p of raw.slice(0, MAX_PARTS + 1)) {
|
|
22
|
+
if (!p || typeof p !== 'object') return null;
|
|
23
|
+
const kind = String(p.kind || '');
|
|
24
|
+
if (kind === 'program') { if (!ID.test(String(p.id || ''))) return null; out.push({ kind, id: String(p.id) }); continue; }
|
|
25
|
+
if (kind !== 'product' && kind !== 'initiative') return null;
|
|
26
|
+
const ws = String(p.ws || ''); const board = String(p.board || ws);
|
|
27
|
+
if (!ID.test(ws) || !ID.test(board)) return null;
|
|
28
|
+
if (kind === 'initiative' && !ID.test(String(p.id || ''))) return null;
|
|
29
|
+
out.push(kind === 'product' ? { kind, ws, board } : { kind, id: String(p.id), ws, board });
|
|
30
|
+
}
|
|
31
|
+
return out.length > MAX_PARTS ? null : out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function groupsOf(parts, programs, boards) {
|
|
35
|
+
const G = new Map(); const tabs = [];
|
|
36
|
+
const boardOf = (ws) => ((boards || []).find((b) => b && b.ws === ws) || {}).id || ws;
|
|
37
|
+
const add = (ws, board, sel) => { const g = G.get(ws) || { ws, board, select: [] }; if (!g.select.includes(sel)) g.select.push(sel); G.set(ws, g); return g; };
|
|
38
|
+
for (const p of parts) {
|
|
39
|
+
if (p.kind === 'product') { add(p.ws, p.board, 'product:' + p.board); tabs.push({ kind: 'product', ws: p.ws, board: p.board }); continue; }
|
|
40
|
+
if (p.kind === 'initiative') { add(p.ws, p.board, 'initiative:' + p.id); tabs.push({ kind: 'initiative', id: p.id, ws: p.ws, board: p.board }); continue; }
|
|
41
|
+
const prog = (programs || []).find((x) => x && x.id === p.id);
|
|
42
|
+
if (!prog) return { error: 'The program "' + p.id + '" is not in this workspace.' };
|
|
43
|
+
const wss = [...new Set((prog.members || []).map((m) => m && m.ws).filter(Boolean))];
|
|
44
|
+
if (!wss.length) return { error: prog.title ? prog.title + ' has no initiatives to share yet.' : 'This program has no initiatives to share yet.' };
|
|
45
|
+
for (const ws of wss) add(ws, boardOf(ws), 'program:' + p.id);
|
|
46
|
+
const home = prog.home && wss.includes(prog.home) ? prog.home : wss[0];
|
|
47
|
+
tabs.push({ kind: 'program', id: p.id, ws: home, board: boardOf(home), program: p.id, label: prog.title || p.id });
|
|
48
|
+
}
|
|
49
|
+
return { groups: [...G.values()].map((g) => Object.assign({}, g, { select: g.select.join(',') })), tabs };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The label of a product or initiative tab, read from that product's own pack: the board's name, or the initiative's title. */
|
|
53
|
+
function labelFrom(pack, tab) {
|
|
54
|
+
const key = Object.keys((pack && pack.responses) || {}).find((k) => k.startsWith('/api/board-premium?') && new URLSearchParams(k.split('?')[1]).get('ws') === tab.ws);
|
|
55
|
+
const model = key && pack.responses[key] && pack.responses[key].model;
|
|
56
|
+
if (tab.kind === 'initiative') { const r = ((model && model.rows) || []).find((x) => x && x.id === tab.id); return (r && r.title) || tab.id; }
|
|
57
|
+
return (model && model.board && (model.board.product || model.board.name)) || tab.ws;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function packOf(parts, o) {
|
|
61
|
+
const g = groupsOf(parts, o.programs, o.boards);
|
|
62
|
+
if (g.error) return { ok: false, status: 400, error: g.error };
|
|
63
|
+
const packs = new Map();
|
|
64
|
+
for (const grp of g.groups) {
|
|
65
|
+
const r = await o.make(grp);
|
|
66
|
+
if (!r.ok) {
|
|
67
|
+
// a product a program only reaches, with nothing of the program on it now: left out, the program's other products still go
|
|
68
|
+
if (r.status === 400 && /not on this board/.test(r.error) && !parts.some((p) => p.ws === grp.ws)) continue;
|
|
69
|
+
return r;
|
|
70
|
+
}
|
|
71
|
+
packs.set(grp.ws, r.pack);
|
|
72
|
+
}
|
|
73
|
+
if (!packs.size) return { ok: false, status: 400, error: 'Nothing in these picks can be shared yet.' };
|
|
74
|
+
// one tab per pick; an initiative joins its product's tab when that product is picked too, and initiatives of one product share a tab
|
|
75
|
+
const tabs = []; const seen = new Map();
|
|
76
|
+
for (const t of g.tabs) {
|
|
77
|
+
if (!packs.has(t.ws)) continue;
|
|
78
|
+
const key = t.ws + '|' + (t.program || '');
|
|
79
|
+
const label = t.label || labelFrom(packs.get(t.ws), t);
|
|
80
|
+
if (seen.has(key)) { const was = seen.get(key); if (was.kind === 'initiative' && t.kind === 'product') { was.kind = 'product'; was.label = label; } continue; }
|
|
81
|
+
const tab = { kind: t.kind, label, ws: t.ws, board: t.board }; if (t.program) tab.program = t.program;
|
|
82
|
+
seen.set(key, tab); tabs.push(tab);
|
|
83
|
+
}
|
|
84
|
+
if (packs.size === 1 && tabs.length === 1 && !tabs[0].program) { // one pick on one product: the pack as it is today, renamed when the PM did
|
|
85
|
+
const pack = [...packs.values()][0]; if (String(o.name || '').trim()) pack.scope = Object.assign({}, pack.scope, { label: String(o.name).trim().slice(0, 120) });
|
|
86
|
+
return { ok: true, pack, kind: (pack.scope && pack.scope.kind) || tabs[0].kind, label: pack.scope.label };
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const pack = Pack.combinePacks([...packs.values()], tabs, o.name);
|
|
90
|
+
const kind = tabs.length > 1 ? 'multi' : (tabs[0] && tabs[0].kind) || 'multi';
|
|
91
|
+
return { ok: true, pack, kind, label: pack.scope.label };
|
|
92
|
+
} catch (e) { return { ok: false, status: 400, error: String((e && e.message) || e) }; }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = { MAX_PARTS, parseParts, groupsOf, packOf };
|
|
@@ -51,8 +51,8 @@ function hostOrigin(env = process.env) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function readState(dir) {
|
|
54
|
-
try { const s = JSON.parse(fs.readFileSync(fileOf(dir), 'utf8')); return { key: typeof s.key === 'string' ? s.key : null, host: typeof s.host === 'string' ? s.host : '', teams: Array.isArray(s.teams) ? s.teams : [], links: Array.isArray(s.links) ? s.links : [] }; }
|
|
55
|
-
catch { return { key: null, host: '', teams: [], links: [] }; }
|
|
54
|
+
try { const s = JSON.parse(fs.readFileSync(fileOf(dir), 'utf8')); return { key: typeof s.key === 'string' ? s.key : null, host: typeof s.host === 'string' ? s.host : '', teams: Array.isArray(s.teams) ? s.teams : [], links: Array.isArray(s.links) ? s.links : [], received: Array.isArray(s.received) ? s.received : [] }; }
|
|
55
|
+
catch { return { key: null, host: '', teams: [], links: [], received: [] }; }
|
|
56
56
|
}
|
|
57
57
|
/** The address the PM saved on the Publish popover ('' when none). The environment variable PMOS_BOARDS_HOST wins over it (see addressOf). */
|
|
58
58
|
function savedHost(dir) {
|
|
@@ -124,7 +124,7 @@ async function publish(dir, o, opts = {}) {
|
|
|
124
124
|
const now = new Date(opts.now || Date.now()).toISOString();
|
|
125
125
|
const cur = readState(dir);
|
|
126
126
|
cur.key = st.key;
|
|
127
|
-
cur.links = cur.links.filter((l) => l.id !== b.id).concat([{ id: b.id, url: b.url, team, name: String(o.name || ''), kind: o.kind, selection: o.selection || [], ws: o.ws || '', board: o.board || '', by: String(o.by || ''), made: now, ends: b.ends || null, views: 0 }]);
|
|
127
|
+
cur.links = cur.links.filter((l) => l.id !== b.id).concat([{ id: b.id, url: b.url, team, name: String(o.name || ''), kind: o.kind, selection: o.selection || [], parts: Array.isArray(o.parts) ? o.parts : undefined, ws: o.ws || '', board: o.board || '', by: String(o.by || ''), made: now, ends: b.ends || null, views: 0 }]);
|
|
128
128
|
writeState(dir, cur);
|
|
129
129
|
return { ok: true, id: b.id, url: b.url, ends: b.ends || null };
|
|
130
130
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* boards-received.js — boards other people shared with you, kept in your PMOS (batch 27 item 3, ShX X2 and X3; initiative board-share-several).
|
|
3
|
+
*
|
|
4
|
+
* A RECEIVED board is { id, host, url, password, name, by, kind, ends, added }, kept in <runtime state>/board-publish/state.json under `received`
|
|
5
|
+
* (lib/boards-host.js writeState: mode 0600). The password is a secret on this computer: never returned to the page, never logged (D08), like a
|
|
6
|
+
* team password. Every function takes the state folder.
|
|
7
|
+
*
|
|
8
|
+
* THE CONTRACT with the host (board-host/src/core.js):
|
|
9
|
+
* GET <host>/api/links/<id>/about X-Link-Password -> { ok, id, name, kind, by, made, ends }
|
|
10
|
+
* POST <host>/api/links/<id>/visit X-Link-Password -> { ok, url } one-time, 5 minutes
|
|
11
|
+
* 403 is a wrong password, 429 a lockout (the sentence names the minutes), 404 a link that ended or was turned off.
|
|
12
|
+
*
|
|
13
|
+
* parseLink(text) -> { host, id, url } | { error } "<host>/b/<id>" (a copy of the address bar works too)
|
|
14
|
+
* add(dir, { link, password }, { fetch }) -> { ok, board } | { ok: false, kind, error } checked with the host before anything is kept
|
|
15
|
+
* forget(dir, id) -> { ok }
|
|
16
|
+
* readAll(dir, { fetch, now }) -> [{ id, host, url, name, by, kind, ends, state }] state: open | ended | off | password | locked | unreachable
|
|
17
|
+
* visit(dir, id, { fetch }) -> { ok, url } | { ok: false, error }
|
|
18
|
+
* Ended and turned-off links stay as one quiet row until the PM forgets them: the host deletes both, so the end date kept here tells them apart. */
|
|
19
|
+
const Host = require('./boards-host.js');
|
|
20
|
+
|
|
21
|
+
const TIMEOUT_MS = 15000;
|
|
22
|
+
const MAX = 50;
|
|
23
|
+
const LINK_ID = /^[A-Za-z0-9_-]{8,64}$/;
|
|
24
|
+
|
|
25
|
+
function parseLink(text) {
|
|
26
|
+
const bad = { error: 'This is not a shared board link. It looks like https://boards.pm-os.app/b/…' };
|
|
27
|
+
let u; try { u = new URL(String(text || '').trim()); } catch { return bad; }
|
|
28
|
+
if (u.username || u.password) return bad;
|
|
29
|
+
const host = Host.hostOrigin({ PMOS_BOARDS_HOST: u.origin });
|
|
30
|
+
const m = /^\/b\/([A-Za-z0-9_-]+)\/?$/.exec(u.pathname);
|
|
31
|
+
if (!host || !m || !LINK_ID.test(m[1])) return bad;
|
|
32
|
+
return { host, id: m[1], url: host + '/b/' + m[1] };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function call(host, method, p, password, fetchFn) {
|
|
36
|
+
const f = fetchFn || (typeof fetch === 'function' ? fetch : null);
|
|
37
|
+
if (!f) return { ok: false, kind: 'unreachable', error: 'This computer cannot reach the host (no network client).' };
|
|
38
|
+
const ctl = typeof AbortController === 'function' ? new AbortController() : null; const timer = ctl ? setTimeout(() => ctl.abort(), TIMEOUT_MS) : null;
|
|
39
|
+
try {
|
|
40
|
+
const headers = { Accept: 'application/json' }; if (password) headers['X-Link-Password'] = password;
|
|
41
|
+
const res = await f(host + p, { method, redirect: 'error', signal: ctl ? ctl.signal : undefined, headers });
|
|
42
|
+
let j = null; try { j = await res.json(); } catch { /* not JSON */ }
|
|
43
|
+
if (res.ok && j && j.ok !== false) return { ok: true, body: j };
|
|
44
|
+
const say = (j && typeof j.error === 'string' && j.error.slice(0, 240)) || '';
|
|
45
|
+
if (res.status === 403) return { ok: false, kind: 'password', error: 'That password does not work. Ask the person who shared it.' };
|
|
46
|
+
if (res.status === 429) return { ok: false, kind: 'locked', error: say || 'Too many wrong tries. Try again in a few minutes.' };
|
|
47
|
+
if (res.status === 404) return { ok: false, kind: 'gone', error: 'This link has ended or was turned off.' };
|
|
48
|
+
return { ok: false, kind: 'other', error: say || 'The host refused the request (' + res.status + ').' };
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return { ok: false, kind: 'unreachable', error: e && e.name === 'AbortError' ? 'The host did not answer in time. Try again.' : 'The host could not be reached. Check the connection.' };
|
|
51
|
+
} finally { if (timer) clearTimeout(timer); }
|
|
52
|
+
}
|
|
53
|
+
const path = (id, what) => '/api/links/' + encodeURIComponent(id) + '/' + what;
|
|
54
|
+
const listOf = (st) => (Array.isArray(st.received) ? st.received : []);
|
|
55
|
+
const str = (v, n) => String(v == null ? '' : v).slice(0, n);
|
|
56
|
+
const about = (b) => ({ name: str(b.name, 120), by: str(b.by, 60), kind: str(b.kind, 20), ends: str(b.ends, 40) });
|
|
57
|
+
|
|
58
|
+
async function add(dir, o, opts = {}) {
|
|
59
|
+
const L = parseLink(o.link); if (L.error) return { ok: false, kind: 'link', error: L.error };
|
|
60
|
+
const password = o.password == null ? '' : String(o.password);
|
|
61
|
+
if (password.length > 100) return { ok: false, kind: 'password', error: 'A password is at most 100 characters.' };
|
|
62
|
+
const st = Host.readState(dir);
|
|
63
|
+
if (!listOf(st).some((r) => r.id === L.id) && listOf(st).length >= MAX) return { ok: false, kind: 'other', error: 'This computer keeps ' + MAX + ' shared boards. Forget one first.' };
|
|
64
|
+
const kept = listOf(st).find((r) => r.id === L.id && r.host === L.host);
|
|
65
|
+
const r = await call(L.host, 'GET', path(L.id, 'about'), password || (kept && kept.password) || '', opts.fetch);
|
|
66
|
+
if (!r.ok) return { ok: false, kind: r.kind, error: r.kind === 'password' && !password ? 'This board needs its password.' : r.error };
|
|
67
|
+
const cur = Host.readState(dir);
|
|
68
|
+
const row = Object.assign({ id: L.id, host: L.host, url: L.url, password: password || (kept && kept.password) || '', added: new Date(opts.now || Date.now()).toISOString() }, about(r.body));
|
|
69
|
+
cur.received = listOf(cur).filter((x) => x.id !== L.id).concat([row]);
|
|
70
|
+
Host.writeState(dir, cur);
|
|
71
|
+
return { ok: true, board: { id: row.id, name: row.name, by: row.by, ends: row.ends } };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function forget(dir, id) {
|
|
75
|
+
const st = Host.readState(dir); const had = listOf(st).some((r) => r.id === id);
|
|
76
|
+
st.received = listOf(st).filter((r) => r.id !== id); Host.writeState(dir, st); return { ok: had };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function readAll(dir, opts = {}) {
|
|
80
|
+
const now = opts.now || Date.now();
|
|
81
|
+
const list = listOf(Host.readState(dir));
|
|
82
|
+
const rows = await Promise.all(list.map(async (x) => {
|
|
83
|
+
const base = { id: x.id, host: new URL(x.host).host, url: x.url, name: x.name, by: x.by, kind: x.kind, ends: x.ends };
|
|
84
|
+
const r = await call(x.host, 'GET', path(x.id, 'about'), x.password, opts.fetch);
|
|
85
|
+
if (r.ok) return Object.assign(base, about(r.body), { state: 'open' });
|
|
86
|
+
if (r.kind === 'gone') return Object.assign(base, { state: x.ends && Date.parse(x.ends) <= now ? 'ended' : 'off' });
|
|
87
|
+
return Object.assign(base, { state: r.kind === 'password' || r.kind === 'locked' ? r.kind : 'unreachable', error: r.error });
|
|
88
|
+
}));
|
|
89
|
+
// what the host said is kept (the name and end date can change on a republish), so an ended row still says when it ended
|
|
90
|
+
const cur = Host.readState(dir); let changed = false;
|
|
91
|
+
for (const row of rows) { const k = listOf(cur).find((x) => x.id === row.id); if (k && row.state === 'open' && (k.name !== row.name || k.ends !== row.ends || k.by !== row.by)) { Object.assign(k, { name: row.name, ends: row.ends, by: row.by }); changed = true; } }
|
|
92
|
+
if (changed) Host.writeState(dir, cur);
|
|
93
|
+
return rows;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function visit(dir, id, opts = {}) {
|
|
97
|
+
const x = listOf(Host.readState(dir)).find((r) => r.id === id);
|
|
98
|
+
if (!x) return { ok: false, error: 'This board is not kept on this computer.' };
|
|
99
|
+
const r = await call(x.host, 'POST', path(x.id, 'visit'), x.password, opts.fetch);
|
|
100
|
+
if (!r.ok) return { ok: false, kind: r.kind, error: r.error };
|
|
101
|
+
const url = r.body.url; if (typeof url !== 'string' || !url.startsWith(x.host + '/b/' + x.id)) return { ok: false, error: 'The host sent an address this workspace does not accept.' };
|
|
102
|
+
return { ok: true, url };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = { MAX, parseLink, add, forget, readAll, visit };
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
*
|
|
16
16
|
* The page does what the terminal does, and nothing more. Each action runs the command the README tells the PM to type:
|
|
17
17
|
* check npm view create-pmos version
|
|
18
|
-
* kit npx -y create-pmos@<version> --update <repo>
|
|
19
|
-
* app npx -y create-pmos@<version> workspace --reinstall <repo> (what `pmos upgrade` runs)
|
|
18
|
+
* kit npx -y --prefer-online create-pmos@<version> --update <repo> (the kernel only; state/ and planning/ untouched)
|
|
19
|
+
* app npx -y --prefer-online create-pmos@<version> workspace --reinstall <repo> (what `pmos upgrade` runs)
|
|
20
20
|
* LOCAL SOURCE. PMOS_UPDATE_SOURCE names a built create-pmos package on this computer: its folder (with package.json, bin/
|
|
21
21
|
* and payload/ or workspace/) or its .tgz from `npm pack`. The check then reads that package's version instead of asking
|
|
22
22
|
* the registry, and the update runs `npx -y --package=<that path> -- create-pmos ...` in place of `npx -y create-pmos@<version> ...`. Nothing
|
|
@@ -116,11 +116,12 @@ function source(env = process.env) {
|
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* The npx arguments that run create-pmos: the registry package at a version, or the local path. A bare path is not
|
|
119
|
-
* enough: npx would try to run it as a command, so a local package goes in with --package.
|
|
119
|
+
* enough: npx would try to run it as a command, so a local package goes in with --package. --prefer-online makes npm ask
|
|
120
|
+
* the registry about the pinned version even when it has an older answer cached, which a cache clean used to force.
|
|
120
121
|
*/
|
|
121
122
|
const npxArgs = (src, version, rest) => (src && src.kind === 'local'
|
|
122
123
|
? ['-y', `--package=${src.path}`, '--', PKG_NAME, ...rest]
|
|
123
|
-
: ['-y', `${PKG_NAME}@${version}`, ...rest]);
|
|
124
|
+
: ['-y', '--prefer-online', `${PKG_NAME}@${version}`, ...rest]);
|
|
124
125
|
|
|
125
126
|
/** One changelog entry as the page may show it, or null: a version, a time, and PRs with a number, a summary, from
|
|
126
127
|
* kit-changelog format 2 a title, and from format 3 a kind (k: new, imp, fix or x), which decides New, Improved or Fixed.
|
|
@@ -266,10 +267,6 @@ function whereFrom({ desktop = false, onlineHost = false, tokenKept = false } =
|
|
|
266
267
|
return { ok: false, error: 'This page signed in with a token that changes when the workspace restarts, so it could not come back. Update the workspace on the computer it runs on, or at its Online address' };
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
/**
|
|
270
|
-
* Start the app reinstall and return at once. The child is detached from this server, because create-pmos stops this
|
|
271
|
-
* server before it reinstalls, and it starts the new one after. Its output goes to `logFile`.
|
|
272
|
-
*/
|
|
273
270
|
/**
|
|
274
271
|
* The environment of the app update. A server started by a login item or a desktop shortcut can have a PATH without
|
|
275
272
|
* the node that runs it, and then neither npx nor the pmos launcher is found. The folder of this node is added at the
|
|
@@ -282,26 +279,59 @@ function updateEnv(env = process.env, nodePath = process.execPath) {
|
|
|
282
279
|
return parts.includes(dir) ? { ...env } : { ...env, [key]: [...parts, dir].join(path.delimiter) };
|
|
283
280
|
}
|
|
284
281
|
|
|
285
|
-
|
|
282
|
+
/**
|
|
283
|
+
* On Windows the update runs through this hop, so no step of it opens a console window (batch 27 item 7).
|
|
284
|
+
* A DETACHED child has no console at all, and then every console program it starts (cmd, npm, node, node-gyp) gets a
|
|
285
|
+
* new, VISIBLE console of its own: npm starts create-pmos without windowsHide, so the server cannot hide those. The hop
|
|
286
|
+
* is a detached node with no console. It starts the update once with windowsHide, which gives that child a console with
|
|
287
|
+
* no window, and every program under it shares that hidden console. The hop waits for the update and passes on its exit
|
|
288
|
+
* code. argv: ['direct', cmd, ...args] runs cmd itself; ['shell', cmd, ...args] runs it through cmd.exe (npx.cmd needs
|
|
289
|
+
* a shell), each argument quoted, so a repository path with a space stays one argument.
|
|
290
|
+
*/
|
|
291
|
+
function windowsHop(argv, spawnSync) {
|
|
292
|
+
const [mode, cmd, ...args] = argv;
|
|
293
|
+
const q = (s) => (/[\s"&|<>^()]/.test(s) ? '"' + String(s).replace(/"/g, '""') + '"' : String(s));
|
|
294
|
+
const r = mode === 'shell'
|
|
295
|
+
? spawnSync([cmd, ...args].map(q).join(' '), { stdio: 'inherit', windowsHide: true, shell: true })
|
|
296
|
+
: spawnSync(cmd, args, { stdio: 'inherit', windowsHide: true });
|
|
297
|
+
if (r.error) console.error('The update could not start: ' + r.error.message);
|
|
298
|
+
return r.status == null ? 1 : r.status;
|
|
299
|
+
}
|
|
300
|
+
const HOP = `process.exit((${windowsHop.toString()})(process.argv.slice(1), require('child_process').spawnSync))`;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* The command that starts the app update: { cmd, args }. On macOS and Linux it is npx. On Windows it is this node
|
|
304
|
+
* running the hop above, and the hop runs npm's own npx-cli.js with this node when it is beside it (the usual Node
|
|
305
|
+
* install and nvm-windows), else npx.cmd through a shell.
|
|
306
|
+
*/
|
|
307
|
+
function appUpdateCommand(npx, { platform = process.platform, execPath = process.execPath, exists = fs.existsSync } = {}) {
|
|
308
|
+
if (platform !== 'win32') return { cmd: 'npx', args: npx };
|
|
309
|
+
const cli = path.win32.join(path.win32.dirname(String(execPath)), 'node_modules', 'npm', 'bin', 'npx-cli.js');
|
|
310
|
+
const run = exists(cli) ? ['direct', String(execPath), cli] : ['shell', 'npx.cmd'];
|
|
311
|
+
return { cmd: String(execPath), args: ['-e', HOP, ...run, ...npx] };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Start the app reinstall and return at once. The child is detached from this server, because create-pmos stops this
|
|
316
|
+
* server before it reinstalls, and it starts the new one after. Its output goes to `logFile`.
|
|
317
|
+
* No npm cache clean: the version is pinned and npx runs with --prefer-online, so npm asks the registry for that
|
|
318
|
+
* version's details again and downloads the version if it is not in the cache. A clean took the whole cache, so every
|
|
319
|
+
* update downloaded every dependency again and built node-pty again (batch 27 item 7).
|
|
320
|
+
*/
|
|
321
|
+
function upgradeApp(root, { version, logFile, spawn = cp.spawn, env = updateEnv(), source: src = source(),
|
|
322
|
+
platform = process.platform, execPath = process.execPath, exists = fs.existsSync } = {}) {
|
|
286
323
|
if (!validVersion(version)) return { ok: false, error: 'Check for updates first' };
|
|
287
324
|
if (src.kind === 'local' && src.error) return { ok: false, error: src.error };
|
|
325
|
+
const npx = npxArgs(src, version, ['workspace', '--reinstall', '--no-open', String(root)]);
|
|
326
|
+
const c = appUpdateCommand(npx, { platform, execPath, exists });
|
|
288
327
|
let fd;
|
|
289
328
|
try {
|
|
290
329
|
fs.mkdirSync(path.dirname(logFile), { recursive: true });
|
|
291
330
|
fd = fs.openSync(logFile, 'w');
|
|
292
|
-
fs.writeSync(fd, `${new Date().toISOString()}
|
|
293
|
-
fs.writeSync(fd, `${new Date().toISOString()} ${NPM} cache clean --force\n`);
|
|
294
|
-
fs.writeSync(fd, `${new Date().toISOString()} ${NPX} ${npxArgs(src, version, ['workspace', '--reinstall', '--no-open', String(root)]).join(' ')}\n`);
|
|
331
|
+
fs.writeSync(fd, `${new Date().toISOString()} ${platform === 'win32' ? 'npx.cmd' : 'npx'} ${npx.join(' ')}\n`);
|
|
295
332
|
} catch (e) { return { ok: false, error: `Could not write the log file: ${e.message}` }; }
|
|
296
333
|
try {
|
|
297
|
-
|
|
298
|
-
cp.execSync(`${NPM} cache clean --force`, { cwd: String(root), env, stdio: ['ignore', fd, fd] });
|
|
299
|
-
} catch (e) {
|
|
300
|
-
try { fs.appendFileSync(logFile, `Note: cache clear had an issue, but continuing: ${e.message}\n`); } catch { /* silent */ }
|
|
301
|
-
}
|
|
302
|
-
try {
|
|
303
|
-
const child = spawn(NPX, npxArgs(src, version, ['workspace', '--reinstall', '--no-open', String(root)]),
|
|
304
|
-
{ cwd: String(root), env, detached: true, stdio: ['ignore', fd, fd], windowsHide: true, shell: IS_WIN });
|
|
334
|
+
const child = spawn(c.cmd, c.args, { cwd: String(root), env, detached: true, stdio: ['ignore', fd, fd], windowsHide: true });
|
|
305
335
|
// A child that could not start writes nothing itself: say why in the log, which the page names when it gives up.
|
|
306
336
|
if (child && typeof child.on === 'function') {
|
|
307
337
|
child.on('error', (e) => { try { fs.appendFileSync(logFile, `The update could not start: ${e.message}\n`); } catch { /* the page times out */ } });
|
|
@@ -315,4 +345,4 @@ function upgradeApp(root, { version, logFile, spawn = cp.spawn, env = updateEnv(
|
|
|
315
345
|
}
|
|
316
346
|
}
|
|
317
347
|
|
|
318
|
-
module.exports = { PKG_NAME, cmpVer, readChanges, readLastCheck, writeLastCheck, notServedYet, validVersion, source, npxArgs, readKit, fromCheckout, status, compare, latest, updateKit, updateEnv, upgradeApp, whereFrom };
|
|
348
|
+
module.exports = { PKG_NAME, windowsHop, appUpdateCommand, cmpVer, readChanges, readLastCheck, writeLastCheck, notServedYet, validVersion, source, npxArgs, readKit, fromCheckout, status, compare, latest, updateKit, updateEnv, upgradeApp, whereFrom };
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/* routes-board-publish.js — publish a board to the central host from the workspace (initiative board-publish, slice 2; D103; PRD P1 to P5).
|
|
3
3
|
*
|
|
4
4
|
* GET /api/board-publish -> { ok, host, days, links } a read: whether a host is set, the choices, the open links (never the key)
|
|
5
|
-
* POST /api/board-publish { ws, board, select, team, password, days, shared_by } -> { ok, id, url, ends }
|
|
5
|
+
* POST /api/board-publish { ws, board, select | parts, name?, team, password, days, shared_by } -> { ok, id, url, ends, name }
|
|
6
|
+
* parts (batch 27 item 1): several products and programs in one link, one tab per pick (lib/board-publish-parts.js)
|
|
6
7
|
* POST /api/board-publish/republish { id } -> { ok, ends } the same selection, as the board is now; same link, same password
|
|
7
8
|
* POST /api/board-publish/off { id } -> { ok } the host deletes the copy at once
|
|
8
9
|
* POST /api/board-publish/password { id } -> { ok, password } a new link password from the host, shown once; the old one stops
|
|
@@ -11,6 +12,10 @@
|
|
|
11
12
|
* POST /api/board-publish/join { invite } or { host, team, password } -> { ok, team } verified with the host first; the password stays on this computer
|
|
12
13
|
* POST /api/board-publish/leave { team } -> { ok } forgets the team here
|
|
13
14
|
* POST /api/board-publish/open { team, id } -> { ok, url } a one-time address for a team member, opened in a browser tab
|
|
15
|
+
* POST /api/board-publish/receive { link, password? } -> { ok, board } a board shared with you, kept here (batch 27 item 3; lib/boards-received.js)
|
|
16
|
+
* POST /api/board-publish/forget { id } -> { ok } forgets it here
|
|
17
|
+
* POST /api/board-publish/visit { id } -> { ok, url } its one-time address, opened in a browser tab
|
|
18
|
+
* GET /api/board-publish/shared also answers withYou: [{ id, host, url, name, by, kind, ends, state }] (no password, ever)
|
|
14
19
|
*
|
|
15
20
|
* EVERY POST IS A PAGE PRESS (pm-guard requirePagePress): only a press on the page publishes, not a request an agent session makes (PRD P2, D97 S3).
|
|
16
21
|
* THE SECRET SCAN runs on the finished pack before anything leaves (P3): a hit blocks the publish and the answer names the rule, never the text (D08).
|
|
@@ -24,6 +29,8 @@ const Host = require('./boards-host.js');
|
|
|
24
29
|
const shareStore = require('./share-store.js');
|
|
25
30
|
const secretScan = require('./secret-scan.js');
|
|
26
31
|
const Teams = require('./boards-teams.js');
|
|
32
|
+
const Parts = require('./board-publish-parts.js');
|
|
33
|
+
const Received = require('./boards-received.js');
|
|
27
34
|
|
|
28
35
|
const PUBLIC = path.join(__dirname, '..', 'public');
|
|
29
36
|
let versionMemo = null;
|
|
@@ -74,7 +81,7 @@ module.exports = {
|
|
|
74
81
|
prefixes: ['/api/board-publish'],
|
|
75
82
|
handle: async (req, res, url, ctx) => {
|
|
76
83
|
const p = url.pathname;
|
|
77
|
-
if (!/^\/api\/board-publish(\/(republish|off|password|host|shared|join|leave|open))?$/.test(p)) return false;
|
|
84
|
+
if (!/^\/api\/board-publish(\/(republish|off|password|host|shared|join|leave|open|receive|forget|visit))?$/.test(p)) return false;
|
|
78
85
|
const send = (obj, code) => { ctx.json(res, obj, code); return true; };
|
|
79
86
|
const dir = stateDir(ctx);
|
|
80
87
|
if (!dir) return send({ ok: false, error: 'No state folder.' }, 500);
|
|
@@ -88,8 +95,8 @@ module.exports = {
|
|
|
88
95
|
}
|
|
89
96
|
// the Shared view's read (slice 4): your own links and every joined team's list, read now from each host. Nothing is kept from the read.
|
|
90
97
|
if (req.method === 'GET' && p === '/api/board-publish/shared') {
|
|
91
|
-
const teams = await Teams.readAll(dir);
|
|
92
|
-
return send({ ok: true, readAt: new Date().toISOString(), yours: Host.links(dir).map((l) => ({ id: l.id, url: l.url, team: l.team, name: l.name, kind: l.kind, by: l.by, made: l.made, ends: l.ends, views: l.views })), teams });
|
|
98
|
+
const [teams, withYou] = await Promise.all([Teams.readAll(dir), Received.readAll(dir)]);
|
|
99
|
+
return send({ ok: true, readAt: new Date().toISOString(), withYou, yours: Host.links(dir).map((l) => ({ id: l.id, url: l.url, team: l.team, name: l.name, kind: l.kind, by: l.by, made: l.made, ends: l.ends, views: l.views })), teams });
|
|
93
100
|
}
|
|
94
101
|
if (req.method !== 'POST') return send({ ok: false, error: 'GET or POST only' }, 405);
|
|
95
102
|
|
|
@@ -104,6 +111,16 @@ module.exports = {
|
|
|
104
111
|
const r = await Teams.join(dir, { invite: body.invite, host: body.host, team: body.team, password: body.password });
|
|
105
112
|
return send(r.ok ? { ok: true, team: r.team } : { ok: false, error: r.error, kind: r.kind }, r.ok ? 200 : (r.kind === 'locked' ? 429 : 400));
|
|
106
113
|
}
|
|
114
|
+
// a board someone shared with you (batch 27 item 3, ShX): checked with its host first; the password stays on this computer (D08)
|
|
115
|
+
if (p === '/api/board-publish/receive') {
|
|
116
|
+
const r = await Received.add(dir, { link: body.link, password: body.password });
|
|
117
|
+
return send(r.ok ? { ok: true, board: r.board } : { ok: false, error: r.error, kind: r.kind }, r.ok ? 200 : (r.kind === 'locked' ? 429 : r.kind === 'unreachable' ? 502 : 400));
|
|
118
|
+
}
|
|
119
|
+
if (p === '/api/board-publish/forget') { const r = Received.forget(dir, String(body.id || '')); return send(r.ok ? { ok: true } : { ok: false, error: 'This board is not kept on this computer.' }, r.ok ? 200 : 404); }
|
|
120
|
+
if (p === '/api/board-publish/visit') {
|
|
121
|
+
const r = await Received.visit(dir, String(body.id || ''));
|
|
122
|
+
return send(r.ok ? { ok: true, url: r.url } : { ok: false, error: r.error, kind: r.kind }, r.ok ? 200 : 502);
|
|
123
|
+
}
|
|
107
124
|
if (p === '/api/board-publish/leave') { const r = Teams.leave(dir, String(body.team || '')); return send(r.ok ? { ok: true } : { ok: false, error: 'This computer has not joined that team.' }, r.ok ? 200 : 404); }
|
|
108
125
|
if (p === '/api/board-publish/open') { // the one-time address of a team's board, to open in a browser tab
|
|
109
126
|
const r = await Teams.open(dir, String(body.team || ''), String(body.id || ''));
|
|
@@ -124,28 +141,41 @@ module.exports = {
|
|
|
124
141
|
|
|
125
142
|
// publish and republish both make a pack, scan it, then send it
|
|
126
143
|
const now = Date.now();
|
|
127
|
-
let sel; let meta;
|
|
144
|
+
let sel; let meta; let parts = null;
|
|
128
145
|
if (p === '/api/board-publish/republish') {
|
|
129
146
|
const l = Host.readState(dir).links.find((x) => x.id === String(body.id || ''));
|
|
130
147
|
if (!l) return send({ ok: false, error: 'This link is not one of yours.' }, 404);
|
|
131
148
|
sel = { ws: l.ws, board: l.board, select: (l.selection || []).map((s) => s.kind + ':' + s.id).join(','), by: l.by, ends: l.ends };
|
|
132
|
-
meta = l;
|
|
149
|
+
meta = l; parts = Array.isArray(l.parts) && l.parts.length ? Parts.parseParts(l.parts) : null;
|
|
133
150
|
} else {
|
|
134
151
|
const days = Number(body.days);
|
|
135
152
|
if (!Host.DAYS.includes(days)) return send({ ok: false, error: 'Ends in 1, 7 or 30 days.' }, 400);
|
|
136
153
|
sel = { ws: body.ws, board: body.board || body.ws, select: Array.isArray(body.select) ? body.select.map((s) => s.kind + ':' + s.id).join(',') : String(body.select || ''), by: String(body.shared_by || '').slice(0, 60) || sharedBy(), ends: new Date(now + days * 86400000).toISOString() };
|
|
154
|
+
if (body.parts != null) { parts = Parts.parseParts(body.parts); if (!parts) return send({ ok: false, error: 'Pick up to ' + Parts.MAX_PARTS + ' products, programs or initiatives to publish.' }, 400); }
|
|
155
|
+
}
|
|
156
|
+
const base = { at: new Date(now).toISOString(), viewer: viewerVersion(), view: body.view || (meta && meta.view) };
|
|
157
|
+
let pack; let name; let kind;
|
|
158
|
+
if (parts) {
|
|
159
|
+
// several picks (batch 27 item 1, ShA): a pack per product, each made and swept as today, joined into one pack with a tab per pick
|
|
160
|
+
const c = await require('./board-publish-choices.js').contextOf(req, ctx, sel.ws, sel.board);
|
|
161
|
+
if (!c) return send({ ok: false, error: 'The board is still being read. Try again in a moment.' }, 202);
|
|
162
|
+
const r = await Parts.packOf(parts, { programs: c.programs, boards: c.boards, name: meta ? meta.name : String(body.name || '').slice(0, 120), make: (g) => makePack(req, ctx, Object.assign({ by: sel.by, ends: sel.ends }, base, { ws: g.ws, board: g.board, select: g.select })) });
|
|
163
|
+
if (!r.ok) return send({ ok: false, error: r.error }, r.status || 502);
|
|
164
|
+
pack = r.pack; name = r.label; kind = r.kind;
|
|
165
|
+
} else {
|
|
166
|
+
const pk = await makePack(req, ctx, Object.assign({}, sel, base));
|
|
167
|
+
if (!pk.ok) return send({ ok: false, error: pk.error }, pk.status || 502);
|
|
168
|
+
pack = pk.pack; name = pack.scope.label; kind = kindOf(pack);
|
|
137
169
|
}
|
|
138
|
-
const
|
|
139
|
-
if (!pk.ok) return send({ ok: false, error: pk.error }, pk.status || 502);
|
|
140
|
-
const hits = secretScan.scan(JSON.stringify(pk.pack));
|
|
170
|
+
const hits = secretScan.scan(JSON.stringify(pack));
|
|
141
171
|
if (hits.length) return send({ ok: false, error: 'This board holds what looks like a secret (' + hits.join(', ') + '). Remove it, then publish again.', secrets: hits }, 422);
|
|
142
172
|
|
|
143
173
|
if (p === '/api/board-publish/republish') {
|
|
144
|
-
const r = await Host.republish(dir, meta.id,
|
|
174
|
+
const r = await Host.republish(dir, meta.id, pack, { env });
|
|
145
175
|
return send(r.ok ? { ok: true, ends: r.ends } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|
|
146
176
|
}
|
|
147
177
|
const selection = Array.isArray(body.select) ? body.select.map((s) => ({ kind: String(s.kind), id: String(s.id) })) : String(body.select || '').split(',').filter(Boolean).map((s) => ({ kind: s.slice(0, s.indexOf(':')), id: s.slice(s.indexOf(':') + 1) }));
|
|
148
|
-
const r = await Host.publish(dir, { pack
|
|
149
|
-
return send(r.ok ? { ok: true, id: r.id, url: r.url, ends: r.ends } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|
|
178
|
+
const r = await Host.publish(dir, { pack, team: body.team, name, kind, by: sel.by, days: Number(body.days), password: body.password == null ? '' : body.password, selection, parts, ws: sel.ws, board: sel.board }, { env });
|
|
179
|
+
return send(r.ok ? { ok: true, id: r.id, url: r.url, ends: r.ends, name } : { ok: false, error: r.error }, r.ok ? 200 : (r.status || 502));
|
|
150
180
|
},
|
|
151
181
|
};
|
|
@@ -31,6 +31,11 @@ const ROOT = path.join(__dirname, '..'); // the workspace package: the files t
|
|
|
31
31
|
const FIXTURE = path.join(ROOT, 'fixtures/next-prompt-replay.json');
|
|
32
32
|
const KEEP = 30;
|
|
33
33
|
const TIMEOUT_MS = 90000;
|
|
34
|
+
const SHARPEN_TIMEOUT_MS = 30000; // a sharper prompt that comes later than this is for words the PM has typed past: drop it
|
|
35
|
+
/* A background run for these two short jobs starts lean (hotfix 2026-11-04, Wawan: "Loading too long"): a fixed fast model at low effort,
|
|
36
|
+
* no MCP servers, no skills, only the PM's user settings (no project hooks such as a session-start script) and one read tool. Measured on
|
|
37
|
+
* one sharpen prompt: about 61,000 input tokens and 7 s before, about 10,000 and 5 s after; the rest is the CLI's own start. */
|
|
38
|
+
const LEAN_FLAGS = Object.freeze([{ flag: '--strict-mcp-config' }, { flag: '--disable-slash-commands' }, { flag: '--setting-sources', value: 'user' }, { flag: '--tools', value: 'Read' }]);
|
|
34
39
|
const DEFAULT_MODEL = 'claude-sonnet-5-5';
|
|
35
40
|
|
|
36
41
|
const text = (v, n) => (typeof v === 'string' ? v.slice(0, n) : '');
|
|
@@ -112,16 +117,18 @@ async function viaApi(key, prompt, env, create = null) {
|
|
|
112
117
|
return null;
|
|
113
118
|
}
|
|
114
119
|
/** A background read-only Claude run → its answer text, or null after `fail(why)` says why it gave none. */
|
|
115
|
-
function viaHeadless(ctx, prompt, origin, fail = () => {}) {
|
|
120
|
+
function viaHeadless(ctx, prompt, origin, fail = () => {}, { timeoutMs = TIMEOUT_MS } = {}) {
|
|
116
121
|
const headless = require('./headless.js');
|
|
117
122
|
if (typeof ctx.spawnSession !== 'function') { fail('no background run here'); return Promise.resolve(null); }
|
|
118
123
|
if (headless.kindFor({ agent: 'claude', origin }) !== 'ask') { fail('the run would not be read-only'); return Promise.resolve(null); }
|
|
119
124
|
return new Promise((resolve) => {
|
|
120
125
|
let settled = false; const done = (v, why) => { if (settled) return; settled = true; clearTimeout(t); if (v == null) fail(why); resolve(v); };
|
|
121
|
-
const t = setTimeout(() => done(null, 'the run took longer than ' + Math.round(
|
|
126
|
+
const t = setTimeout(() => done(null, 'the run took longer than ' + Math.round(timeoutMs / 1000) + ' s'), timeoutMs);
|
|
122
127
|
let s = null;
|
|
123
128
|
try {
|
|
129
|
+
const model = String(envOf(ctx).PMOS_NEXT_PROMPT_MODEL || '').trim() || DEFAULT_MODEL;
|
|
124
130
|
s = ctx.spawnSession({ name: 'chat: next prompt', agent: 'claude', origin, initialInput: prompt,
|
|
131
|
+
modelAsk: { explicit: { model, effort: 'low' } }, launchFlags: LEAN_FLAGS.map((f) => ({ ...f })),
|
|
125
132
|
onDone: (d) => { const r = d && d.result; done(r && r.ok && !r.isError ? String(r.text || '') : null, 'the run ended without an answer' + (d && d.note ? ': ' + String(d.note).slice(0, 80) : '')); } });
|
|
126
133
|
} catch (e) { s = null; }
|
|
127
134
|
if (!s || s.state === 'exited') done(null, 'the run did not start' + (s && s.note ? ': ' + String(s.note).slice(0, 80) : ''));
|
|
@@ -145,7 +152,8 @@ async function ask(ctx, prompt, { job, key, run }) {
|
|
|
145
152
|
catch (e) { failed(apiWhy(e), e && (e.status === 401 || e.status === 403)); }
|
|
146
153
|
}
|
|
147
154
|
return viaHeadless(ctx, prompt, `briefing-ask:next-prompt:${job}:${crypto.createHash('sha1').update(String(key)).digest('hex').slice(0, 10)}`,
|
|
148
|
-
(why) => AG.audit(ctx.runtimeDir, { job, version: VERSION, run, event: 'run-error', error: String(why).slice(0, 160) })
|
|
155
|
+
(why) => AG.audit(ctx.runtimeDir, { job, version: VERSION, run, event: 'run-error', error: String(why).slice(0, 160) }),
|
|
156
|
+
{ timeoutMs: job === NP.JOB_SHARPEN ? SHARPEN_TIMEOUT_MS : TIMEOUT_MS });
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
/* ── what a card cites ───────────────────────────────────────────────────────────────────── */
|
|
@@ -285,4 +293,4 @@ async function handle(req, res, url, ctx) {
|
|
|
285
293
|
catch (e) { return send(bad(500, 'The suggestion failed: ' + String((e && e.message) || e).slice(0, 200))); }
|
|
286
294
|
}
|
|
287
295
|
|
|
288
|
-
module.exports = { prefixes: ['/api/next-prompt'], handle, VERSION, FIXTURE, MODELS, prefs, setPref, lineRef, replayCases, next, sharpen };
|
|
296
|
+
module.exports = { prefixes: ['/api/next-prompt'], handle, VERSION, FIXTURE, MODELS, LEAN_FLAGS, prefs, setPref, lineRef, replayCases, next, sharpen };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.522.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.522.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -47,3 +47,6 @@
|
|
|
47
47
|
.bppop :focus-visible{outline:2px solid var(--ember);outline-offset:2px}
|
|
48
48
|
#bdPublish{position:relative}#bdPublish .bpn{position:absolute;top:2px;right:0;min-width:16px;padding:0 5px;border-radius:99px;background:var(--solid);color:var(--on-solid);font:var(--fw-strong) var(--fs-badge)/var(--lh-badge) var(--mono);text-align:center;line-height:16px}
|
|
49
49
|
@media (max-width:640px){.bppop{left:0 !important;right:0;bottom:0;top:auto !important;width:auto;max-width:none;border-radius:16px 16px 0 0;border-width:1px 0 0;box-shadow:0 -8px 30px rgb(0 0 0 / .18)}.bppop .bpbody{max-height:85vh;padding:12px 12px calc(18px + env(safe-area-inset-bottom,0px))}.bppop .bpcaret{display:none}}
|
|
50
|
+
/* several picks (batch 27 item 1, ShA): Products and Programs as chip groups, and the link's name made from the picks */
|
|
51
|
+
.bppop .bpcap{font:var(--fw-strong) var(--fs-meta)/var(--lh-meta) var(--sans,inherit);color:var(--ink-3);padding:6px 8px 0}
|
|
52
|
+
.bppop .bpname{font-weight:var(--fw-strong);color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|