create-pmos 0.796.0 → 0.798.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.
@@ -21,6 +21,7 @@ import * as M from './pop-work-model.js';
21
21
  import * as CB from './cozy-bar.js';
22
22
  import { openPop, closePop, undoToast } from './hi-pop.js';
23
23
  import { pmGet, pmPost } from './http.js';
24
+ import * as SE from './status-edit.js';
24
25
  import * as LE from './live-edit.js'; // an edit shows at once: this popup is drawn again the moment a task write is sent, and after each read
25
26
  import * as VW from './cozy-viewer.js';
26
27
  import * as ED from './ini-edit.js';
@@ -785,9 +786,7 @@ async function saveDesc(text, x, h) {
785
786
  * The editor counts the words ("9 of 12 words"); past 12 the count turns red and PMOS offers a short line from the text (POST
786
787
  * /api/initiative/status-suggest, a normal session, else the first 12 words). Use it puts the line in; Save keeps the whole text in the
787
788
  * item's log and the line as the status (POST /api/initiative/status). Escape leaves it as it was. */
788
- const SL_MAX = 12;
789
789
  let SLED = null; // the open status editor's Use it and Save
790
- const slWords = (t) => String(t || '').replace(/\s+/g, ' ').trim().split(' ').filter((w) => /[\p{L}\p{N}]/u.test(w)).length;
791
790
  function editStatus(btn, W, x, h) {
792
791
  const p = btn.closest('.pw-ostat');
793
792
  if (!p || p.querySelector('textarea')) return;
@@ -796,36 +795,36 @@ function editStatus(btn, W, x, h) {
796
795
  + `<span class="pw-swb"><button type="button" class="pw-lk" data-sw-save>Save</button></span>`;
797
796
  const ta = p.querySelector('textarea'), wc = p.querySelector('.pw-swc'), sg = p.querySelector('.pw-sws');
798
797
  ta.value = was; ta.focus();
799
- let line = '', tm = null, asked = '';
798
+ const st = SE.slState(was); // Use it keeps the whole text, so Save logs it (job #1817)
799
+ let tm = null, asked = '';
800
800
  const count = () => {
801
- const n = slWords(ta.value);
802
- wc.textContent = n + ' of ' + SL_MAX + ' words'; wc.classList.toggle('over', n > SL_MAX);
803
- if (n <= SL_MAX) { line = ''; sg.innerHTML = ''; return; }
801
+ const n = SE.slWords(ta.value);
802
+ st.input(ta.value);
803
+ wc.textContent = n + ' of ' + SE.SL_MAX + ' words'; wc.classList.toggle('over', n > SE.SL_MAX);
804
+ if (n <= SE.SL_MAX) { sg.innerHTML = ''; return; }
804
805
  clearTimeout(tm);
805
806
  tm = setTimeout(async () => {
806
807
  const text = ta.value; if (text === asked) return; asked = text;
807
808
  const w = h.where ? h.where() : {};
808
809
  const r = await pmPost('/api/initiative/status-suggest', { ws: w.ws, id: x.o().id, text }).catch(() => null);
809
810
  if (!r || r.ok === false || ta.value !== text) return;
810
- line = r.line;
811
- sg.innerHTML = `<i class="pw-spark" aria-hidden="true">✦</i> PMOS keeps the ${slWords(text)} words in the log and suggests: <b>${esc(r.line)}</b> <button type="button" class="pw-lk" data-sw-use>Use it</button>`;
811
+ st.suggest(r.line);
812
+ sg.innerHTML = `<i class="pw-spark" aria-hidden="true">✦</i> PMOS keeps the ${SE.slWords(text)} words in the log and suggests: <b>${esc(r.line)}</b> <button type="button" class="pw-lk" data-sw-use>Use it</button>`;
812
813
  }, 600);
813
814
  };
814
815
  ta.addEventListener('input', count); count();
815
816
  let done = false;
816
817
  const leave = async (save) => {
817
818
  if (done) return; done = true; clearTimeout(tm); SLED = null;
818
- const text = ta.value.replace(/\s+/g, ' ').trim();
819
- if (!save || !text || text === was) { if (h.redraw) h.redraw(); return; }
819
+ const b = save ? st.save(ta.value) : null;
820
+ if (!b) { if (h.redraw) h.redraw(); return; }
820
821
  const w = h.where ? h.where() : {};
821
- const body = { ws: w.ws, id: x.o().id, text };
822
- if (slWords(text) > SL_MAX && line) body.line = line;
823
- const res = await pmPost('/api/initiative/status', body).catch(() => null);
822
+ const res = await pmPost('/api/initiative/status', { ws: w.ws, id: x.o().id, ...b }).catch(() => null);
824
823
  if (!res || res.ok === false) { if (h.redraw) h.redraw(); if (h.toast) h.toast((res && res.error) || 'The status was not saved.'); return; }
825
- if (h.toast) h.toast(slWords(text) > SL_MAX ? 'Saved. The whole text is in the log.' : 'Saved.');
824
+ if (h.toast) h.toast(b.line ? 'Saved. The whole text is in the log.' : 'Saved.');
826
825
  if (h.reload) await h.reload(); else if (h.redraw) h.redraw();
827
826
  };
828
- SLED = { use: () => { ta.value = line; count(); ta.focus(); }, save: () => leave(true) }; // the presses come through wire()'s one listener
827
+ SLED = { use: () => { ta.value = st.use(ta.value); count(); ta.focus(); }, save: () => leave(true) }; // the presses come through wire()'s one listener
829
828
  ta.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); leave(false); } else if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); leave(true); } });
830
829
  }
831
830
  const findSug = (W, id) => W.suggests.find((s) => s.id === id) || [...W.rowSuggests.values()].find((s) => s.id === id) || null;
@@ -42,7 +42,8 @@ import { canDictate, dictate } from './home-dictate.js';
42
42
  import { adler } from './cozy-adler.js';
43
43
  import { snapOf, turnEnded } from './chat-turn-end.js'; // a finished turn re-reads what the Viewer shows (batch 25 item 3)
44
44
  import { nextPromptUi } from './next-prompt-ui.js'; // the suggested next prompt and the Sharper card above the box (batch 26 item 2)
45
- import { cardsUi } from './chat-cards.js'; // ask-cards-and-pickers: the rows an answer names, live, and a picker (canvas A2Cards, A2Ask)
45
+ import { cardsUi } from './chat-cards.js';
46
+ import { a2uiUi } from './a2ui-view.js'; // a2ui-inbound-render: another agent's A2UI v1.0 surface, drawn with PMOS's own parts; a press goes back as words // ask-cards-and-pickers: the rows an answer names, live, and a picker (canvas A2Cards, A2Ask)
46
47
  import { runAction, routeOf } from './action-run.js';
47
48
  import { tellCards } from './card-log.js'; // each answer's card list and each press to the local use log (card catalog rule 9, A511)
48
49
  /* The views a chat opens go in the Viewer: on a page with no dialog the old viewer's views draw in the cozy card (premium-viewer.js). */
@@ -90,7 +91,8 @@ export function mountChat(el, host) {
90
91
  const C = { t: null, th: null, conv: null, timer: null, show: 12, plOpen: false, plAll: false, open: new Set(), seq: 0, sending: false, files: [], seenAt: null, lastKey: null, picked: {}, pend: [], auto: { key: null, ctx: new Set(), rep: null, goal: null }, slashAt: 0 };
91
92
  const CU = cardsUi({ pmGet: (u) => host.pmGet(u), pmPost: (u, b) => host.pmPost(u, b), toast: (t) => host.toast(t), redraw: () => draw(), runAction, routeOf, tellCards,
92
93
  ws: () => (C.t && C.t.ws) || new URLSearchParams(location.search).get('ws') || '' });
93
- window.addEventListener('pmos:action', (e) => CU.onAction(e.detail)); // a row the chat shows follows a press or a chat write elsewhere
94
+ window.addEventListener('pmos:action', (e) => CU.onAction(e.detail));
95
+ const AU = a2uiUi({ send: (t) => send(t), redraw: () => draw() }); // a row the chat shows follows a press or a chat write elsewhere
94
96
  el.innerHTML = `<button type="button" class="hm-reopen" id="hmReopen" aria-label="Open the Viewer" title="Open the Viewer" hidden>${PANE}</button>`
95
97
  + '<div class="hm-chd" id="hmCh" hidden></div><div class="hm-sug" id="hmSug" hidden></div><div class="hm-plw" id="hmPl" hidden></div><div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
96
98
  const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen'), head = el.querySelector('#hmCh'), sug = el.querySelector('#hmSug'), pl = el.querySelector('#hmPl');
@@ -182,7 +184,9 @@ export function mountChat(el, host) {
182
184
  }
183
185
  const last = i === R.lastAgent;
184
186
  const asking = last && R.asking; // the message that asks before a change: no tools while the ask is open, and the name on its own line (AgChatAsk)
185
- const cd = CU.split(it.text); // the pmos-card and pmos-pick blocks (pm/chat-cards.js): drawn under the words, live
187
+ const a2 = AU.split(it.text); // a2ui blocks: another agent's surface (pm/a2ui-view.js), drawn after the words
188
+ const liveOf = { live: !((C.conv && C.conv.messages) || []).slice(it.mi + 1).some((x) => x.role === 'user') }; // its buttons work until the PM writes again
189
+ const cd = CU.split(a2.text); // the pmos-card and pmos-pick blocks (pm/chat-cards.js): drawn under the words, live
186
190
  const sr = splitSrc(cd.text); // chief-of-staff C1: the answer's sources, drawn under it (pm/chat-src.js)
187
191
  const g = splitGoal(sr.text), rp0 = splitReport(g.text), ak = splitAsk(splitChase(rp0.text).text), rp = { ...rp0, text: ak.text };
188
192
  const goal = C.th && C.th.goal, gl = it.mi === R.lastMsg && R.waiting && !!goal && goal.state === 'grilling';
@@ -190,7 +194,7 @@ export function mountChat(el, host) {
190
194
  // a run that stopped: the divider sits where it finished, over Claude's last message, and the fix sits under it (canvas XcbOptions, Routine)
191
195
  const stopAt = R.stop && i === R.lastAgent;
192
196
  const av = last && isClaude(R.role) ? adlerAvHtml(asking || ak.block ? 'needs-you' : stopAt ? 'honest' : running() ? 'thinking' : 'handled') : avHtml(R.role);
193
- return (stopAt ? dividerHtml({ tone: R.stop.tone, text: R.stop.text }) : '') + `<div class="hm-a${asking ? ' ask' : ''}${last ? ' last' : ''}">${av}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ? verHtml(rp.text) : ''}${CU.html(cd, 'm' + it.mi, { live: !((C.conv && C.conv.messages) || []).slice(it.mi + 1).some((x) => x.role === 'user') })}${srcHtml(sr.src)}${goalBlockHtml(go.block, go)}${reportChipHtml(rp.block, it.mi)}${R.chips(it.mi)}`
197
+ return (stopAt ? dividerHtml({ tone: R.stop.tone, text: R.stop.text }) : '') + `<div class="hm-a${asking ? ' ask' : ''}${last ? ' last' : ''}">${av}<div class="hm-ab"><p class="hm-who">${esc(R.role.name)} <span>${esc(hm(it.at))}</span></p>${rp.text ? verHtml(rp.text) : ''}${CU.html(cd, 'm' + it.mi, liveOf)}${AU.html(a2.blocks, 'm' + it.mi, liveOf)}${srcHtml(sr.src)}${goalBlockHtml(go.block, go)}${reportChipHtml(rp.block, it.mi)}${R.chips(it.mi)}`
194
198
  + (asking ? '' : `<div class="hm-tools" role="group" aria-label="Message actions"><button type="button" data-hm-copy="${i}">Copy</button>${last && !running() && !(stopAt && R.stop.actions.length) ? `<button type="button" data-hm-retry>Retry</button>` : ''}<button type="button" data-hm-wi="${i}">Make it a task</button></div>`) + '</div></div>'
195
199
  + (stopAt && R.stop.actions.length ? `<div class="hm-fix" role="group" aria-label="What to do next">${R.stop.actions.map((a, k) => iconBtn({ icon: a.icon, label: a.label, attr: a.data, pri: k === 0 })).join('')}</div>` : '')
196
200
  + blockAskHtml(ak.block, it, R);
@@ -621,6 +625,7 @@ export function mountChat(el, host) {
621
625
  if (b.dataset.hmCpt && C.cpt) { if (b.dataset.hmCpt === 'ok') host.compact(sid()); else host.dismissCompact(sid(), C.cpt.pct); C.cpt = null; sug.hidden = true; put(sug, ''); return; }
622
626
  if (b.dataset.hmSug && C.sug) { const g = C.sug; if (b.dataset.hmSug === 'link') host.linkTo(C.t.sid, g.id); else { host.dismissLink(C.t.sid); drawSug(); } return; }
623
627
  const d = b.dataset;
628
+ if (AU.owns(b)) { await AU.press(b); return; } // a press on another agent's surface goes back to it as one message (pm/a2ui-view.js)
624
629
  if (CU.owns(b)) { await CU.press(b); return; } // a row's button, a picker's choice, its ✓ or Undo (pm/chat-cards.js); any other button stays synchronous
625
630
  const ic = b.closest('.hm-icard'), card = C.t && C.t.intro && C.t.intro.card;
626
631
  if (ic && card && card.press) { if (await card.press(b)) draw(); return; }
@@ -706,6 +711,7 @@ export function mountChat(el, host) {
706
711
  if (e.key === 'Enter' && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) { e.preventDefault(); el.querySelector('#hmForm').requestSubmit(); }
707
712
  });
708
713
  el.addEventListener('input', (e) => {
714
+ if (AU.input(e.target)) return; // a field on another agent's surface: its bound value follows
709
715
  const card = C.t && C.t.intro && C.t.intro.card;
710
716
  if (card && card.input && e.target.closest('.hm-icard')) { card.input(e.target, e.target.closest('.hm-icard')); return; }
711
717
  if (e.target.id === 'hmIn') { grow(e.target); C.slashAt = 0; suggestFor(e.target.value); drawSlash(); NPU.input(e.target.value); if (C.err) { C.err = ''; const er = foot.querySelector('.hm-senderr'); if (er) er.remove(); foot.__h = null; } }
@@ -0,0 +1,30 @@
1
+ /* status-edit.js — the item header's status editor, without the page (status-line, A505; fix job #1817).
2
+ * The editor counts words; past 12 PMOS offers a short line. Use it puts the line in the box and keeps the whole text, so Save logs the
3
+ * whole text and records the line the person sees. Writing past 12 words again makes that new text the whole text.
4
+ *
5
+ * const s = slState(was)
6
+ * s.input(text) on each edit
7
+ * s.suggest(line) PMOS's line for the text now in the box ('' clears it)
8
+ * s.use(text) → line Use it: the box gets the line; the whole text is kept
9
+ * s.save(text) → { text, line? } | null the body for POST /api/initiative/status (null: nothing to save) */
10
+ export const SL_MAX = 12;
11
+ export const slWords = (t) => String(t || '').replace(/\s+/g, ' ').trim().split(' ').filter((w) => /[\p{L}\p{N}]/u.test(w)).length;
12
+ const clean = (t) => String(t || '').replace(/\s+/g, ' ').trim();
13
+
14
+ export function slState(was = '') {
15
+ let line = '', kept = '';
16
+ return {
17
+ get line() { return line; },
18
+ get kept() { return kept; },
19
+ input(text) { if (slWords(text) > SL_MAX) kept = ''; else line = ''; },
20
+ suggest(l) { line = clean(l); },
21
+ use(text) { if (!line) return text; kept = clean(text); const l = line; line = ''; return l; },
22
+ save(text0) {
23
+ const text = clean(text0);
24
+ if (!text) return null;
25
+ if (kept && slWords(text) <= SL_MAX) return { text: kept, line: text };
26
+ if (text === clean(was)) return null;
27
+ return slWords(text) > SL_MAX && line ? { text, line } : { text };
28
+ },
29
+ };
30
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "a2ui-inbound-render (job #1752, A459b): another agent's A2UI v1.0 surface drawn in the PMOS chat with PMOS's own parts; unsafe surfaces refused whole; a press goes back as words. The page module on plain objects, cross-checked against the vendored A2UI v1.0 schemas. No browser, no network.",
3
+ "modules": [
4
+ "a2ui-inbound.test.js"
5
+ ],
6
+ "seconds": {
7
+ "a2ui-inbound.test.js": 1
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "a2ui-mcp-outbound (job #1751, A459a): pmos mcp gives PMOS rows as A2UI v1.0 over MCP and runs a pressed button as its catalog command. The real launcher on stdio, the real task writer, and the vendored A2UI v1.0 schemas. No browser, no network.",
3
+ "modules": [
4
+ "a2ui-mcp.test.js"
5
+ ],
6
+ "seconds": {
7
+ "a2ui-mcp.test.js": 4
8
+ }
9
+ }