create-pmos 0.244.0 → 0.246.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.244.0",
3
+ "version": "0.246.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@c924d0d
1
+ kernel-source: pmos@0e2738a
2
2
  assembled: 2026-10-15
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-15T02:53:25Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-15T05:12:16Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-15T02:53:25Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-15T05:12:16Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-15T02:53:25Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-15T05:12:16Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -73,6 +73,9 @@ async function waitFor(page, fn, arg, ms = 8000) {
73
73
  ok(`B2 section ${id} draws`, drew);
74
74
  }
75
75
 
76
+ await page.click('[data-c3set-nav] [data-c3set-sec="sessions"]');
77
+ ok('B3 Claude sessions has the PMOS own-login row with Set up', await waitFor(page, () => { const r = document.querySelector('[data-c3set-section="sessions"] [data-c3set-own]'); const b = r && r.querySelector('[data-c3set-own-signin]'); return !!b && /Set up/.test(b.textContent) && !r.querySelector('[data-c3set-own-use]'); }, null, 4000));
78
+
76
79
  /* ── C: search ── */
77
80
  await page.fill('[data-c3set-search]', 'language');
78
81
  ok('C1 search finds the recording language', await waitFor(page, () => !!document.querySelector('[data-c3set-body] [data-c3set-row="notes.language"]')));
@@ -33,7 +33,8 @@ Settings holds settings only, in eight sections. On a wide screen they are cards
33
33
 
34
34
  - **Repositories**: every registered repository. Press a repository to make it the current one. Press its ⋯ for **Rename** or **Remove from PMOS**. Each asks in a sheet, and a remove asks you to confirm. **Add repository** shows the scan of a folder before you add it.
35
35
  - **Profiles**: the Claude profiles a session can start with. These are the descriptors in `~/.claude/profiles`, and also the profiles you already run: a shell command that sets `CLAUDE_CONFIG_DIR` (for example `alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'`), a launcher script named `claude-*`, or a config folder such as `~/.claude-work`. Each profile is a row with a **Detected** badge when PMOS found it rather than wrote it, and a **Default** badge when it is the default. Its ⋯ menu has **Use as default**. A profile found this way says where it was found, and a session under it sets only `CLAUDE_CONFIG_DIR`. The list reads again every few seconds while Settings is open, and **Look again** in the Claude profiles menu reads it at once. When nothing is found, the note names the start-up files and folders PMOS looked at. Press **New profile** to make one. This writes `~/.claude/profiles/<id>.json`. Account secrets are never shown in the browser.
36
- - **New sessions**: the default CLI, the default model, the default Claude profile and the default launch flags for a new session. The flags come from `claude --help`, for example `--chrome`. A flag that needs a value lists the values it accepts. The default profile is one setting for the whole workspace. PMOS keeps it on the server, so every browser, port and device starts a Claude session with the same profile. Choose it here or with "make … the default" in the New session form. Both change the same setting.
36
+ - **PMOS's own Claude login** (Claude sessions): a Claude login that only PMOS uses. A `/login` typed in a terminal replaces the account in `~/.claude`, and PMOS's background runs then fail with "OAuth session expired". Press **Set up**. PMOS makes the profile `pmos` (the folder `~/.claude-pmos`) and opens a Claude session under it. Type `/login` there and sign in once. Then press **Use for PMOS**. The row shows **In use**. Terminals keep working as before: sign in or switch there whenever you like, and PMOS's login is not touched. **Sign in again** opens the session again. PMOS never makes this the default by itself, and it holds no password.
37
+ - **New sessions**: the default CLI, the default model, the default Claude profile and the default launch flags for a new session. The flags come from `claude --help`, for example `--chrome`. A flag that needs a value lists the values it accepts. **Flags for automatic sessions** is a second list for the sessions PMOS starts for you, such as a scheduled brief. Such a session cannot answer a permission question, so it waits. Until you save a choice it starts with `--permission-mode=acceptEdits`, which ends the file-edit questions. A tool from a connector can still ask; allow it in your Claude settings or choose a looser mode here. The default profile is one setting for the whole workspace. PMOS keeps it on the server, so every browser, port and device starts a Claude session with the same profile. Choose it here or with "make … the default" in the New session form. Both change the same setting.
37
38
  - **Validate consent**: the consent of the current repository. Use its switch to turn it on or off. **Open Validate** opens the Validate page as a tab.
38
39
  - **People**: whether the morning brief keeps attendee names from the calendar for the current repository. It is off until you turn it on. Turning it off also hides the names recorded before.
39
40
  - **Online**: puts this workspace at your own address, such as `pmos.pm-os.app`, through a Cloudflare tunnel. Enter the public address, the tunnel name, your Cloudflare team domain, the Access audience (AUD) tag and your email, then turn on the **Online** switch. The workspace runs the tunnel and remembers the switch when it restarts. On your phone, open the address and sign in with Cloudflare Access (Google or an email code). The workspace does not ask for its token there. Only the computer that runs the workspace can change this section. A phone sees whether it is on. When a sign-in at the address is refused, this section names the check that failed, such as the email or the AUD tag. [REMOTE.md](../REMOTE.md) has the one-time Cloudflare steps.
@@ -32,7 +32,7 @@ Settings is not a tab. While it is open, no tab is selected. Press a tab to go b
32
32
  | Day and time | The time zone, the first day of the week, your working hours, the free time before a meeting with prep, the buffer between meetings, and the time-of-day tint and daylight strip. |
33
33
  | Sharing | How a report is shared: off, a link, or sent by the sender. The audiences of the workspace. Schedules are not here. Each report has its own schedule, in Reports, under Set up. |
34
34
  | Access and devices | Use from a phone or another computer: the host, the tunnel and the people who may open it. |
35
- | Claude sessions | What a new session starts with: the CLI, the model, the Claude profile and the launch flags. The session limits. Validate consent for this workspace. |
35
+ | Claude sessions | What a new session starts with: the CLI, the model, the Claude profile and the launch flags for sessions you start, and the flags for automatic sessions. The session limits. Validate consent for this workspace. |
36
36
  | Privacy and data | A list of what leaves this computer and when. Whether a TypeSafe key is saved, the local model that answers when there is no key (Off, Winnow or Laya), and the data folder. |
37
37
  | Appearance | The theme (Same as system, Light or Dark) and the page that opens first. |
38
38
  | Updates | The version of the app and of each workspace's kit. Check for updates, and how updates are found and applied. |
@@ -24,6 +24,12 @@ const D = require('./driver.js');
24
24
  const facts = require('./driver-facts.js');
25
25
  const proactive = require('./proactive.js');
26
26
 
27
+ // A run that fails because the Claude login has expired fails again for every other target. Holding the next runs for this long (their
28
+ // wakes stay queued) stops one expired login from filing hundreds of failed runs; the first run after the wait is the probe.
29
+ const LOGIN_HOLD_MS = 30 * 60 * 1000;
30
+ const LOGIN_RE = /failed to authenticate|oauth (session|token)|session expired|could not be refreshed|not logged in|invalid api key|authentication_error|\b401\b/i;
31
+ const loginFailure = (r) => LOGIN_RE.test([r && r.note, r && r.result && r.result.text, r && r.result && r.result.error].filter(Boolean).join(' '));
32
+
27
33
  const off = (env) => /^(off|0|false|no)$/i.test(String((env || process.env).PMOS_DRIVER || '').trim());
28
34
  const hhmm = (ms) => { const d = new Date(ms); return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`; };
29
35
  const dayCheckOpen = (settings, now, inQuiet) => {
@@ -44,6 +50,7 @@ function readJsonl(f) {
44
50
  function create(deps) {
45
51
  const active = new Map(); // run id → { target, ledger, session }
46
52
  const lastSweep = new Map(); // ledger file → ms
53
+ let loginFailedAt = 0; // ms of the last run that failed on the Claude login; new runs wait LOGIN_HOLD_MS after it
47
54
  const warn = deps.warn || (() => {});
48
55
  const gather = deps.gather || facts.gather; // tests pass their own facts
49
56
 
@@ -122,6 +129,8 @@ function create(deps) {
122
129
  const res = (r && r.result) || {};
123
130
  const ok = !!(r && !r.timedOut && !r.stopped && r.code === 0 && res.ok && !res.isError);
124
131
  const reason = ok ? null : (r && r.note) || 'the run failed';
132
+ if (ok) loginFailedAt = 0;
133
+ else if (loginFailure(r)) loginFailedAt = Date.now();
125
134
  try {
126
135
  D.append(file, { ev: 'run-end', run: runId, ok, ...(reason ? { reason } : {}), ...(res.denied && res.denied.length ? { denied: res.denied } : {}),
127
136
  agent_run: agentRun(runId, target, ok) });
@@ -170,6 +179,7 @@ function create(deps) {
170
179
  }
171
180
  // Start what the rules allow.
172
181
  if (deps.headlessOff()) continue; // a driver never runs in a pane
182
+ if (loginFailedAt && now - loginFailedAt < LOGIN_HOLD_MS) { summary.held = 'login'; continue; } // wakes stay queued
173
183
  const running = [...active.values()];
174
184
  const p = D.plan(state, { now, running: active.size, activeTargets: running.map((r) => D.targetKey(r.target)) });
175
185
  for (const r of p.refused) { D.append(file, { ev: 'refused', target: r.target, wakes: r.wakes, reason: r.reason }, { now }); summary.refused++; }
@@ -191,4 +201,4 @@ function create(deps) {
191
201
  return { tick, active: () => [...active.keys()] };
192
202
  }
193
203
 
194
- module.exports = { create, off, dayCheckOpen };
204
+ module.exports = { create, off, dayCheckOpen, loginFailure, LOGIN_HOLD_MS };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+ /*
3
+ * lib/own-profile.js — PMOS's own Claude profile (initiative claude-own-login).
4
+ *
5
+ * By default a background run and a terminal session both use Claude Code's own folder, ~/.claude. A /login typed in a
6
+ * terminal then replaces the account PMOS's background runs use, and they fail with "OAuth session expired". PMOS holds no
7
+ * credential and cannot copy a login, so it can only keep the two apart: a profile of its own, `pmos`, whose
8
+ * CLAUDE_CONFIG_DIR is ~/.claude-pmos. The PM signs in to it once; terminal sessions (which take no profile) never touch it.
9
+ *
10
+ * ensure(homeDir, profilesDir) → { ok, id, dir, created } | { ok:false, error }
11
+ * makes ~/.claude-pmos (mode 0700) and ~/.claude/profiles/pmos.json when they are missing. It never overwrites a
12
+ * descriptor that exists, and it never sets the default: that is a separate press, after the PM has signed in.
13
+ */
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+
17
+ const ID = 'pmos';
18
+ const dirOf = (home) => path.join(home, '.claude-pmos');
19
+
20
+ function ensure(home, profilesDir) {
21
+ const dir = dirOf(home);
22
+ const file = path.join(profilesDir, ID + '.json');
23
+ try {
24
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
25
+ fs.mkdirSync(profilesDir, { recursive: true, mode: 0o700 });
26
+ } catch (e) { return { ok: false, error: 'the folders could not be made — ' + String((e && e.code) || (e && e.message) || 'write failed').slice(0, 120) }; }
27
+ const desc = { id: ID, label: 'PMOS', env: { CLAUDE_CONFIG_DIR: dir } };
28
+ try {
29
+ fs.writeFileSync(file, JSON.stringify(desc, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
30
+ return { ok: true, id: ID, dir, created: true };
31
+ } catch (e) {
32
+ if (e && e.code === 'EEXIST') return { ok: true, id: ID, dir, created: false };
33
+ return { ok: false, error: 'the profile could not be written — ' + String((e && e.code) || (e && e.message) || 'write failed').slice(0, 120) };
34
+ }
35
+ }
36
+
37
+ module.exports = { ID, dirOf, ensure };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.244.0",
3
+ "version": "0.246.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.244.0",
9
+ "version": "0.246.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.244.0",
3
+ "version": "0.246.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -25,6 +25,7 @@ import { button, SEL } from './primitives.js';
25
25
  import { pmGet, pmPost } from './http.js';
26
26
  import { c3ic } from './pm-work-view.js';
27
27
  import { sessionDefaults, setSessionDefaults } from './dock.js';
28
+ import { flagPicker, flagsLine, flagsMissingValue } from './flag-picker.js';
28
29
  import { toast } from './c3-toast.js';
29
30
  import { dayPartOf } from './c3-daypart.js';
30
31
  import { finderBlock } from './c3-report-store.js';
@@ -147,7 +148,7 @@ export function mountSettings(host, ctx = {}) {
147
148
  ensureCss();
148
149
  const M = {
149
150
  sec: SECTIONS.some((s) => s[0] === ctx.section) ? ctx.section : 'about', q: '', ws: ctx.ws || '', data: null, err: {},
150
- engine: null, people: null, consent: null, online: null, profiles: null, typesafe: null, kits: {}, kitBusy: null, app: { phase: null, error: '' }, about: null, running: null,
151
+ engine: null, flagList: null, autoFlags: null, flagFilter: '', flagsOpen: { mine: false, auto: false }, people: null, consent: null, online: null, profiles: null, typesafe: null, kits: {}, kitBusy: null, app: { phase: null, error: '' }, about: null, running: null,
151
152
  tplEdit: null, wsEdit: null, wsDrop: null, addPath: '',
152
153
  rf: null, rfLog: null, rfSig: '', rfFilter: 'all', rfEdit: null, rfAsk: null, rfErr: {}, rfAllBusy: false, rfLoading: false, logSource: '', logResult: '',
153
154
  };
@@ -191,6 +192,8 @@ export function mountSettings(host, ctx = {}) {
191
192
  function loadOnce() {
192
193
  pmGet('/api/online').then((r) => { M.online = r && r.ok !== false ? r : { error: (r && r.error) || 'not read' }; draw(); });
193
194
  pmGet('/api/profiles').then((r) => { M.profiles = r && r.ok !== false ? r : { error: (r && r.error) || 'not read', profiles: [] }; draw(); });
195
+ pmGet('/api/claude-flags').then((r) => { M.flagList = r || { ok: false, error: 'no answer', flags: [] }; draw(); });
196
+ pmGet('/api/auto-session-flags').then((r) => { M.autoFlags = r && r.ok !== false ? r : { error: (r && r.error) || 'not read', flags: [] }; draw(); });
194
197
  pmGet('/api/typesafe').then((r) => { M.typesafe = r && r.ok ? r.key : null; draw(); });
195
198
  pmGet('/api/proactive/settings').then((r) => { const s = r && r.ok && r.settings; M.about = s ? { name: s.name || '', role: (s.about || {}).role || '', work: (s.about || {}).work || '', duties: (s.about || {}).duties || '' } : { error: (r && r.error) || 'not read' }; draw(); });
196
199
  pmGet('/api/sessions').then((r) => { M.running = r && Array.isArray(r.sessions) ? r.sessions : null; draw(); });
@@ -541,6 +544,36 @@ export function mountSettings(host, ctx = {}) {
541
544
  ...later];
542
545
  }
543
546
 
547
+ /* Launch flags. 'mine': what a session you start begins with (kept in this browser, as the other defaults are).
548
+ * 'auto': what a session PMOS starts for you begins with (a schedule, a day run); kept on this computer, because no
549
+ * browser is open to answer a permission question when one fires. */
550
+ function flagsRow(which) {
551
+ const auto = which === 'auto';
552
+ const chosen = auto ? ((M.autoFlags && M.autoFlags.flags) || []) : sessionDefaults().flags;
553
+ const open = M.flagsOpen[which];
554
+ const save = async (next) => {
555
+ if (auto) {
556
+ const r = await pmPost('/api/auto-session-flags', { flags: next });
557
+ if (r && r.ok !== false) { M.autoFlags = r; delete M.err['sess.flags.auto']; toast('Saved: flags for automatic sessions'); }
558
+ else M.err['sess.flags.auto'] = (r && r.error) || 'Not saved.';
559
+ } else { setSessionDefaults({ flags: next }); toast('Saved: launch flags'); }
560
+ draw();
561
+ };
562
+ const missing = M.flagList ? flagsMissingValue(M.flagList, chosen) : [];
563
+ const control = el('div', { class: 'c3set-flags', 'data-c3set-flags': which },
564
+ el('p', { class: 'dim mono' }, chosen.length ? 'claude ' + flagsLine(chosen) : 'No flags.'),
565
+ missing.length ? el('p', { class: 'dim', role: 'alert' }, missing[0] + ' needs a value before it can be saved.') : null,
566
+ flagPicker({ list: M.flagList, chosen, filter: M.flagFilter, compact: !open, onFilter: (q) => { M.flagFilter = q; draw(); },
567
+ onChange: (next) => { if (auto && flagsMissingValue(M.flagList, next).length) { M.autoFlags = { ...M.autoFlags, flags: next }; draw(); } else save(next); } }),
568
+ btn(open ? 'Hide the full list' : 'Show every flag', { variant: 'ghost', onclick: () => { M.flagsOpen[which] = !open; draw(); }, attrs: { 'data-c3set-flags-all': which } }));
569
+ return frame(auto
570
+ ? { key: 'sess.flags.auto', label: 'Flags for automatic sessions', scope: 'computer', wide: true, control, err: M.err['sess.flags.auto'],
571
+ help: 'Sessions PMOS starts for you, such as a scheduled brief, cannot answer a permission question, so they wait. Set a permission mode here. Until you save a choice they start with --permission-mode=acceptEdits.',
572
+ note: M.autoFlags && M.autoFlags.saved === false ? 'Using the default. Change a flag to save your own.' : null }
573
+ : { key: 'sess.flags', label: 'Launch flags', scope: 'computer', wide: true, control,
574
+ help: 'Flags for the claude command when you start a session, such as a permission mode. You can change them for one session in the New session form.', note: 'Kept in this browser, as the dock keeps it.' });
575
+ }
576
+
544
577
  function sessionsSec() {
545
578
  const d = sessionDefaults(); const p = M.profiles;
546
579
  const profs = (p && p.profiles) || [];
@@ -559,7 +592,8 @@ export function mountSettings(host, ctx = {}) {
559
592
  extRow('sess.cli', seg('Start with', [['claude', 'Claude Code'], ['shell', 'A shell']], d.cli, (v) => setDef({ cli: v }, 'sess.cli', { cli: d.cli })), { scope: 'computer', note: 'Kept in this browser, as the dock keeps it.' }),
560
593
  extRow('sess.tier', seg('Model', [['auto', 'Auto'], ['fast', 'Fast'], ['balanced', 'Balanced'], ['deep', 'Deep']], d.tier, (v) => setDef({ tier: v }, 'sess.tier', { tier: d.tier })), { scope: 'computer' }),
561
594
  extRow('sess.profile', profileSelect('c3set-sess-profile'), { scope: 'computer', forId: 'c3set-sess-profile', note: profs.length ? null : p ? 'No profile was found. Make one in the classic app\'s Settings, Profiles (/classic.html).' : 'Reading profiles.' }),
562
- lockedRow('sess.flags', 'Launch flags', 'Flags for the claude command, such as a permission mode.', 'Set when you start a session', 'computer')], 'term'),
595
+ flagsRow('mine'), flagsRow('auto')], 'term'),
596
+ ownLoginSec(profs, def),
563
597
  profs.length ? sect('Profiles', [list(profRows), help('A new profile is made in the classic app\'s Settings, Profiles (/classic.html).')], { ic: 'user', count: profs.length }) : null,
564
598
  groupOf('sessions', 'Housekeeping', 'term'),
565
599
  sect('Running now' + (M.running ? ' · ' + run.length + (max ? ' of ' + max : '') : ''), [M.running ? (run.length ? list(runRows) : fold(null, 'No sessions running.')) : fold(null, 'Reading the sessions.'),
@@ -567,6 +601,31 @@ export function mountSettings(host, ctx = {}) {
567
601
  M.ws ? group('Workspace', [extRow('validate.consent', M.consent && !M.consent.error ? swBtn(M.consent.on, EXT['validate.consent'][2], async () => { const r = await pmPost('/api/validate/repo', { ws: M.ws, consent: !M.consent.on }); if (r && r.ok !== false) { M.consent.on = !!r.consent; toast('Saved: validate consent'); } else M.err['validate.consent'] = (r && r.error) || 'Not saved.'; draw(); }) : el('span', { class: 'dim' }, M.consent ? M.consent.error : 'Reading'), { scope: 'ws' })], 'term') : null];
568
602
  }
569
603
 
604
+ /* PMOS's own Claude login (claude-own-login): a profile of its own, so a /login typed in a terminal never signs PMOS out. */
605
+ async function ownSignIn() {
606
+ delete M.err['sess.own'];
607
+ const made = await pmPost('/api/profiles/own', {});
608
+ if (!made || !made.ok) { M.err['sess.own'] = (made && made.error) || 'The profile was not made.'; draw(); return; }
609
+ const term = await import('./tab-term.js').catch(() => null);
610
+ const res = term ? await term.requestSpawn({ name: 'Sign in · PMOS Claude', agent: 'claude', profile: made.id, ws: M.ws, start: true, workType: 'general' }) : null;
611
+ pmGet('/api/profiles').then((r) => { M.profiles = r && r.ok !== false ? r : M.profiles; draw(); });
612
+ if (!res || !res.ok) { M.err['sess.own'] = (res && res.error) || 'The session did not start.'; draw(); return; }
613
+ const m = await import('./c3-session-term.js');
614
+ m.openSessionTerm({ id: res.id, name: 'Sign in · PMOS Claude' });
615
+ toast('Type /login in the terminal and sign in. Then press Use for PMOS.');
616
+ }
617
+ function ownLoginSec(profs, def) {
618
+ const own = profs.find((x) => x.id === 'pmos');
619
+ const using = !!own && def === 'pmos';
620
+ return sect('PMOS\'s own Claude login', [
621
+ help('A /login typed in a terminal replaces the account PMOS uses in the background. Give PMOS its own login and a terminal can never sign it out. Terminal sessions keep working as they do now: sign in or switch there whenever you like.'),
622
+ el('div', { class: 'iacts', 'data-c3set-own': '' },
623
+ using ? tag('In use', 'ok') : null,
624
+ btn(own ? 'Sign in again' : 'Set up', { variant: own && !using ? 'outline' : using ? 'ghost' : 'primary', attrs: { 'data-c3set-own-signin': '' }, disabled: !M.ws, onclick: ownSignIn }),
625
+ own && !using ? btn('Use for PMOS', { variant: 'primary', attrs: { 'data-c3set-own-use': '' }, onclick: () => chooseProfile('pmos') }) : null),
626
+ M.err['sess.own'] ? fold('alert', M.err['sess.own'], 'w') : null], { ic: 'user' });
627
+ }
628
+
570
629
  function privacySec() {
571
630
  const w = M.engine && M.engine.whisper; const j = M.engine && M.engine.jev; const o = M.online;
572
631
  const jevOn = !!(j && (j.jev || j.check));
@@ -473,6 +473,22 @@ function writePrefs(prefs) {
473
473
  try { fs.writeFileSync(PREFS_FILE, JSON.stringify(prefs)); return null; }
474
474
  catch (e) { warnWriteFail('prefs.json (profile preselection)', e); return `the preference could not be saved — ${String((e && e.code) || 'write failed')}`; }
475
475
  }
476
+ // Launch flags for AUTOMATIC Claude panes (a schedule, a day run, a refresh): the ones the PM did not press. They cannot answer a
477
+ // permission question, so a pane that asks stays "Starting" for ever. The PM sets the flags here (Settings, New sessions);
478
+ // until then a pane starts in acceptEdits, which ends the file-edit prompts. Headless runs have their own fixed tool lists.
479
+ const AUTO_FLAGS_FILE = path.join(STATE, 'auto-session-flags.json');
480
+ const AUTO_FLAGS_DEFAULT = Object.freeze([{ flag: '--permission-mode', value: 'acceptEdits' }]);
481
+ function readAutoFlags() {
482
+ try {
483
+ const o = JSON.parse(fs.readFileSync(AUTO_FLAGS_FILE, 'utf8'));
484
+ if (o && Array.isArray(o.flags) && claudeFlags.resolve(o.flags, 'claude').ok) return { flags: o.flags.map((x) => ({ flag: x.flag, value: x.value || '' })), saved: true };
485
+ } catch { /* none saved, or unreadable: the default stands */ }
486
+ return { flags: AUTO_FLAGS_DEFAULT.map((x) => ({ ...x })), saved: false };
487
+ }
488
+ function writeAutoFlags(flags) {
489
+ try { fs.writeFileSync(AUTO_FLAGS_FILE, JSON.stringify({ flags })); return null; }
490
+ catch (e) { warnWriteFail('auto-session-flags.json', e); return `the flags could not be saved — ${String((e && e.code) || 'write failed')}`; }
491
+ }
476
492
  // The default profile for an agent, for a start the PM pressed that named no profile at all (`undefined`). An explicit
477
493
  // null means "no profile" and is never replaced. A remembered id that no longer reads yields undefined: the start then
478
494
  // runs with no profile and says nothing it did not do, rather than failing on a preference the PM did not just choose.
@@ -3826,6 +3842,10 @@ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile
3826
3842
  /* LAUNCH FLAGS (workspace-launch-flags). Checked against the generated claude flag list, and refused like a model
3827
3843
  * choice: a flag that cannot be honoured starts nothing. The tokens go AFTER the model's, and a flag the model
3828
3844
  * chips already own is refused by the list itself, so the two never both speak. */
3845
+ // An automatic PANE (not a headless run) that was handed no flags takes the PM's automatic-session flags, so it never waits on a prompt nobody sees.
3846
+ if (launchFlags === undefined && agent === 'claude' && sessionOrigin.isAutomatic(tag) && !(initialInput && headlessLib.kindFor({ agent, origin: tag, skill: modelAsk && modelAsk.skill }))) {
3847
+ launchFlags = readAutoFlags().flags;
3848
+ }
3829
3849
  const fres = claudeFlags.resolve(launchFlags, agent);
3830
3850
  if (!fres.ok) return exitedSession(base, workdir, `launch flag refused — ${fres.error}`);
3831
3851
  if (launchFlags !== undefined) base.launchFlags = fres.applied;
@@ -6660,6 +6680,19 @@ async function handleRequest(req, res) {
6660
6680
  }
6661
6681
  // Every flag `claude --help` lists, with whether the form may offer it (workspace-launch-flags). A static file.
6662
6682
  if (p === '/api/claude-flags' && req.method === 'GET') return json(res, claudeFlags.list());
6683
+ // The flags automatic Claude panes start with (a schedule, a day run). Checked against the same list as every other launch.
6684
+ if (p === '/api/auto-session-flags' && req.method === 'GET') { const a = readAutoFlags(); return json(res, { ok: true, flags: a.flags, saved: a.saved }); }
6685
+ if (p === '/api/auto-session-flags' && req.method === 'POST') {
6686
+ let body = {};
6687
+ try { body = JSON.parse((await readBody(req)) || '{}'); }
6688
+ catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
6689
+ const flags = Array.isArray(body.flags) ? body.flags.map((x) => ({ flag: x && x.flag, value: x && x.value ? String(x.value) : '' })) : null;
6690
+ if (!flags) return json(res, { ok: false, error: 'flags must be a list' }, 400);
6691
+ const chk = claudeFlags.resolve(flags, 'claude');
6692
+ if (!chk.ok) return json(res, { ok: false, error: chk.error }, 400);
6693
+ const err = writeAutoFlags(flags);
6694
+ return err ? json(res, { ok: false, error: err }, 500) : json(res, { ok: true, flags, saved: true });
6695
+ }
6663
6696
  /* Create one descriptor from the Settings form (workspace-launch-flags). It writes ONE file, ~/.claude/profiles/<id>.json,
6664
6697
  * and only when none by that name exists: PMOS never overwrites a descriptor the PM keeps. The file is read back through
6665
6698
  * the same reader every other surface uses, so a descriptor this route wrote that the reader would refuse is removed
@@ -6707,6 +6740,15 @@ async function handleRequest(req, res) {
6707
6740
  }
6708
6741
  return json(res, { ok: true, profile: profileWire(made, read), path: file });
6709
6742
  }
6743
+ /* PMOS's own Claude profile (lib/own-profile.js): makes ~/.claude-pmos and the descriptor `pmos`, once. It does not make it the
6744
+ * default and holds no login: the PM signs in to it in a session, then presses Make default. */
6745
+ if (p === '/api/profiles/own' && req.method === 'POST') {
6746
+ const made = require('./lib/own-profile.js').ensure(os.homedir(), profilesLib.profilesDir(os.homedir()));
6747
+ if (!made.ok) return json(res, { ok: false, error: made.error }, 500);
6748
+ const read = readProfilesNow();
6749
+ if (!(read.profiles || []).some((x) => x.id === made.id)) return json(res, { ok: false, error: 'the PMOS profile was written but could not be read back' }, 500);
6750
+ return json(res, { ok: true, id: made.id, created: made.created });
6751
+ }
6710
6752
  if (p === '/api/profiles/prefer' && req.method === 'POST') {
6711
6753
  let body = {};
6712
6754
  try { body = JSON.parse((await readBody(req)) || '{}'); }
@@ -8,6 +8,7 @@
8
8
  "test.js"
9
9
  ],
10
10
  "modules": [
11
+ "own-profile.test.js",
11
12
  "stage-tools.test.js",
12
13
  "report-template-cadence.test.js",
13
14
  "proactive.test.js",