create-pmos 0.490.0 → 0.491.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.490.0",
3
+ "version": "0.491.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -32,6 +32,19 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.491.0",
37
+ "at": "2026-11-02T09:09:04.158Z",
38
+ "f": 3,
39
+ "prs": [
40
+ {
41
+ "n": 1154,
42
+ "t": "New-user Claude sign-in reuses the real login, no first-run screens; session terminal is typeable",
43
+ "s": "New-user Claude sign-in reuses the real login, no first-run screens; session terminal is typeable",
44
+ "k": "fix"
45
+ }
46
+ ]
47
+ },
35
48
  {
36
49
  "v": "0.490.0",
37
50
  "at": "2026-11-02T08:52:24.978Z",
@@ -282,19 +295,6 @@
282
295
  "k": "fix"
283
296
  }
284
297
  ]
285
- },
286
- {
287
- "v": "0.471.0",
288
- "at": "2026-10-31T13:21:46.914Z",
289
- "f": 3,
290
- "prs": [
291
- {
292
- "n": 1124,
293
- "t": "The Shared tab on the Board — join a team, read its boards, open one (board-publish slice 4)",
294
- "s": "The Shared tab on the Board — join a team, read its boards, open one (board-publish slice 4)",
295
- "k": "new"
296
- }
297
- ]
298
298
  }
299
299
  ]
300
300
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@e63a60be
1
+ kernel-source: pmos@bd7f8188
2
2
  assembled: 2026-11-02
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-11-02T08:52:21Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-02T09:09:01Z"}
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-11-02T08:52:21Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-02T09:09:01Z"}
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-11-02T08:52:21Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-02T09:09:01Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.491.0",
4
+ "at": "2026-11-02T09:09:04.158Z",
5
+ "f": 3,
6
+ "prs": [
7
+ {
8
+ "n": 1154,
9
+ "t": "New-user Claude sign-in reuses the real login, no first-run screens; session terminal is typeable",
10
+ "s": "New-user Claude sign-in reuses the real login, no first-run screens; session terminal is typeable",
11
+ "k": "fix"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.490.0",
4
17
  "at": "2026-11-02T08:52:24.978Z",
@@ -180,6 +180,8 @@ There is no My work page. The list on Home is your list:
180
180
  - **Initiative.** The Board opens with **New initiative**, in the open product.
181
181
  - **Sessions.** A session row names its agent. The coloured dot beside it is its state: blue waits on you, amber may be blocked, green is running. A session PMOS started itself (a skill or a background job) shows on Home only while it works or asks you something. Once it finishes its prompt, it leaves the list. On an initiative's page, a session that waits on you shows once, under **Needs you**, not again under **Sessions**. **Finished sessions** does not list an old run of a chat that is open again.
182
182
  - **One chat box.** Every conversation has the same box: **+** (attach a file, notes, the terminal, and **Link to an initiative** for a loose chat), **/** for commands, **@** inside an initiative, the To or In chip, the mic, and Send. A chat opens at its newest message.
183
+ - **A session's terminal.** **Watch its terminal** in **+**, or a session row such as **Claude sign-in**, opens the session's terminal in the Viewer. While the session runs, it is a real terminal: type in it to answer Claude or paste a code. When the session has ended, the Viewer shows it read only and says so.
184
+ - **Signing in to Claude when you set up your first project.** If the login you choose is signed in already, PMOS does not open a terminal. It tests the login at once. Otherwise PMOS runs `claude auth login`: Claude opens your browser to sign in, and the terminal under the question shows only Claude's request for a code, if it needs one. Claude's theme and trust-this-folder screens do not appear. When the sign-in ends, PMOS tests the login by itself. **The Claude login on this computer** is the login your usual terminal uses (`~/.claude.json`); PMOS no longer points it at a different file.
183
185
  - **Documents not written yet.** A document that does not exist yet shows **Draft it**, in its stage or ahead of it. The agent writes a draft. Nothing is issued until you read it.
184
186
  - **Meeting notes.** A decision, to-do or question that the notes caught is not a fact until you confirm it in the meeting's Replay. Home, Your day and the evening recap do not count unconfirmed points.
185
187
 
@@ -34,7 +34,7 @@ Settings holds settings only, in eight sections. On a wide screen they are cards
34
34
 
35
35
  - **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.
36
36
  - **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.
37
- - **Claude login and profile** (Settings › Claude): the same profile-specific sign-in and verification controls as [Welcome](welcome.md). Set up a separate PMOS login or choose an existing setup. Complete Claude’s sign-in in that profile’s terminal. This terminal takes your keys, also when you open the sign-in session from the sessions list, so you can answer Claude’s first-run screens (the theme, the login method, folder trust). Then choose **Check and use this profile**. When the check fails, the message names the login it checked and its folder. Signing in to a different Claude login, for example in another terminal, does not sign this one in. PMOS does not copy credentials. A missing selected profile refuses new sessions instead of silently changing accounts.
37
+ - **Claude login and profile** (Settings › Claude): the same profile-specific sign-in and verification controls as [Welcome](welcome.md). Set up a separate PMOS login or choose an existing setup. If that login is signed in already, PMOS checks it at once. Otherwise PMOS runs `claude auth login` in that profile’s terminal: Claude opens your browser, and the terminal takes your keys if Claude asks for a code, also when you open the session from the sessions list. Claude’s first-run screens (theme, folder trust) do not appear. PMOS checks the login when the sign-in ends. When the check fails, the message names the login it checked and its folder. Signing in to a different Claude login, for example in another terminal, does not sign this one in. PMOS does not copy credentials. A missing selected profile refuses new sessions instead of silently changing accounts.
38
38
  - **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.
39
39
  - **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.
40
40
  - **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.
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+ /*
3
+ * lib/claude-home.js — which Claude Code configuration a process really uses.
4
+ *
5
+ * Claude Code keeps its main settings file in two different places:
6
+ * - CLAUDE_CONFIG_DIR not set: ~/.claude.json, and on macOS the login in the Keychain item "Claude Code-credentials".
7
+ * - CLAUDE_CONFIG_DIR set: <dir>/.claude.json, and on macOS a Keychain item whose name includes a hash of <dir>.
8
+ * So CLAUDE_CONFIG_DIR=~/.claude is NOT the same as no CLAUDE_CONFIG_DIR, although ~/.claude is the default folder.
9
+ * Claude then reads ~/.claude/.claude.json, which does not exist: it shows its first-run screens (theme, sign-in, folder
10
+ * trust) and does not find the login the PM already has (bug 2026-11-02, new-user onboarding on Windows).
11
+ *
12
+ * isDefaultDir(dir, home) → true when dir is Claude's default folder, ~/.claude
13
+ * overlay(env, { home, inherited }) → a copy of a profile's env without a CLAUDE_CONFIG_DIR that only names the default
14
+ * folder (kept when the PM's own environment already sets CLAUDE_CONFIG_DIR)
15
+ * configFile(env, home) → the .claude.json that a process with this env reads
16
+ */
17
+ const path = require('path');
18
+
19
+ const norm = (p) => {
20
+ let r = path.resolve(String(p));
21
+ if (r.length > 1 && /[\\/]$/.test(r)) r = r.slice(0, -1);
22
+ return process.platform === 'win32' || process.platform === 'darwin' ? r.toLowerCase() : r;
23
+ };
24
+
25
+ function isDefaultDir(dir, home) {
26
+ if (typeof dir !== 'string' || !dir || typeof home !== 'string' || !home) return false;
27
+ return norm(dir) === norm(path.join(home, '.claude'));
28
+ }
29
+
30
+ function overlay(env, { home, inherited = '' } = {}) {
31
+ const out = { ...(env || {}) };
32
+ if (!inherited && isDefaultDir(out.CLAUDE_CONFIG_DIR, home)) delete out.CLAUDE_CONFIG_DIR;
33
+ return out;
34
+ }
35
+
36
+ function configFile(env, home) {
37
+ const dir = env && env.CLAUDE_CONFIG_DIR;
38
+ return dir ? path.join(dir, '.claude.json') : path.join(home, '.claude.json');
39
+ }
40
+
41
+ module.exports = { isDefaultDir, overlay, configFile };
@@ -6,6 +6,7 @@ const os = require('os');
6
6
  const crypto = require('crypto');
7
7
  const cp = require('child_process');
8
8
  const win = require('./win-command');
9
+ const claudeHome = require('./claude-home');
9
10
  const DEFAULT = '__default__';
10
11
  const PROMPT = 'Reply with exactly PMOS_READY. Do not use tools.';
11
12
  const FLAGS = ['--safe-mode', '--tools', '--strict-mcp-config', '--mcp-config', '--disable-slash-commands', '--no-session-persistence', '--output-format'];
@@ -53,7 +54,9 @@ function create({ stateDir, home = os.homedir(), readProfiles, readPrefs, savePr
53
54
  const selected = () => readPrefs().claude || DEFAULT;
54
55
  function candidate(id = selected()) {
55
56
  if (typeof id !== 'string' || !/^[a-zA-Z0-9_.-]{1,80}$/.test(id)) return null;
56
- if (id === DEFAULT) return { id, label: 'My usual Claude login', env: { CLAUDE_CONFIG_DIR: path.resolve(envFor(null).CLAUDE_CONFIG_DIR || path.join(home, '.claude')) } };
57
+ // The usual login is Claude with no CLAUDE_CONFIG_DIR at all, unless the PM's own environment sets one. Naming ~/.claude
58
+ // here made Claude read ~/.claude/.claude.json and miss the login in ~/.claude.json (lib/claude-home.js).
59
+ if (id === DEFAULT) { const inherited = envFor(null).CLAUDE_CONFIG_DIR; return { id, label: 'My usual Claude login', env: inherited ? { CLAUDE_CONFIG_DIR: path.resolve(inherited) } : {} }; }
57
60
  return (readProfiles().profiles || []).find(p => p.id === id) || null;
58
61
  }
59
62
  function binding(p) {
@@ -61,8 +64,10 @@ function create({ stateDir, home = os.homedir(), readProfiles, readPrefs, savePr
61
64
  const command = resolveExecutable(env);
62
65
  const dir = path.resolve(env.CLAUDE_CONFIG_DIR || path.join(home, '.claude'));
63
66
  const authNames = ['ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN', 'ANTHROPIC_BASE_URL', 'CLAUDE_CODE_USE_BEDROCK', 'CLAUDE_CODE_USE_VERTEX', 'CLAUDE_CODE_USE_FOUNDRY'];
64
- const input = { command, executable: stamp(command.file), env: Object.entries(p.env || {}).sort(), dir,
65
- auth: authNames.map(k => [k, env[k] || '']), config: ['settings.json', '.claude.json', '.credentials.json'].map(n => stamp(path.join(dir, n))) };
67
+ // the env as it is applied (a CLAUDE_CONFIG_DIR that names only ~/.claude sets nothing), so an old descriptor and a new one match
68
+ const applied = claudeHome.overlay(p.env, { home, inherited: envFor(null).CLAUDE_CONFIG_DIR || '' });
69
+ const input = { command, executable: stamp(command.file), env: Object.entries(applied).sort(), dir,
70
+ auth: authNames.map(k => [k, env[k] || '']), config: [path.join(dir, 'settings.json'), claudeHome.configFile(env, home), path.join(dir, '.credentials.json')].map(stamp) };
66
71
  return { env, command, fingerprint: crypto.createHash('sha256').update(JSON.stringify(input)).digest('hex') };
67
72
  }
68
73
  // The sentence for a state. A signed-out or unverified login names the login it checked and its folder, because signing in to another
@@ -131,6 +136,22 @@ function create({ stateDir, home = os.homedir(), readProfiles, readPrefs, savePr
131
136
  return { ok: state === 'ready', state, message: say(state, p), profile: savedId, checked_at: record.checked_at, ready: state === 'ready' };
132
137
  } finally { if (scratch) fs.rmSync(scratch, { recursive: true, force: true }); }
133
138
  }
139
+ /** Whether this login is signed in already, from `claude auth status --json`: no model call, no usage. true, false, or null
140
+ * when it cannot be told (an older Claude Code with no `auth` command, a .cmd wrapper, unreadable output). */
141
+ async function signedIn(id) {
142
+ const p = candidate(id);
143
+ if (!p) return null;
144
+ const b = binding(p);
145
+ if (b.command.prefix.includes('/c')) return null;
146
+ let scratch;
147
+ try {
148
+ scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'pmos-claude-auth-'));
149
+ const r = await run(b.command.file, [...b.command.prefix, 'auth', 'status', '--json'], { env: b.env, cwd: scratch, timeout: 15000 });
150
+ let j; try { j = JSON.parse(String(r.stdout || '').trim()); } catch { return null; }
151
+ return j && typeof j.loggedIn === 'boolean' ? j.loggedIn : null;
152
+ } catch { return null; }
153
+ finally { if (scratch) fs.rmSync(scratch, { recursive: true, force: true }); }
154
+ }
134
155
  function check(id) {
135
156
  if (running) return running.id === id ? running.promise : Promise.resolve({ ok: false, state: 'busy', message: 'Another profile check is running.' });
136
157
  const promise = perform(id).finally(() => { running = null; });
@@ -147,6 +168,6 @@ function create({ stateDir, home = os.homedir(), readProfiles, readPrefs, savePr
147
168
  const b = binding(candidate(id));
148
169
  return { id, env: b.env, command: b.command, fingerprint: b.fingerprint };
149
170
  }
150
- return { list, status, selected, candidate, check, pinDefault, invalidate, bound };
171
+ return { list, status, selected, candidate, check, signedIn, pinDefault, invalidate, bound };
151
172
  }
152
173
  module.exports = { create, classify, DEFAULT, FLAGS, MESSAGES };
@@ -79,8 +79,8 @@ async function handle(req, res, url, ctx) {
79
79
  if (verb === 'own') return send(ctx.claudeSetup.ensureOwn());
80
80
  if (verb === 'login') {
81
81
  const dir = path.join(ctx.runtimeDir, 'onboarding', 'signin'); fs.mkdirSync(dir, { recursive: true });
82
- const r = ctx.claudeSetup.login(b.profile, null, 'login', dir);
83
- if (r.ok) write(ctx, { ...st, profile: r.profile, fingerprint: null });
82
+ const r = await ctx.claudeSetup.login(b.profile, null, 'login', dir);
83
+ if (r.ok) write(ctx, { ...st, profile: r.profile, fingerprint: null }); // r.signedIn: already signed in, no terminal; the page tests it next
84
84
  return send(r);
85
85
  }
86
86
  if (verb === 'check') {
@@ -43,7 +43,7 @@ async function handle(req, res, url, ctx) {
43
43
  const w = workspace(ctx, b.ws); if (!w) return send({ ok: false, error: 'No such workspace.' }, 404);
44
44
  try {
45
45
  if (verb === 'own') return send(ctx.claudeSetup.ensureOwn());
46
- if (verb === 'login') return send(ctx.claudeSetup.login(b.profile, w.id, b.purpose));
46
+ if (verb === 'login') return send(await ctx.claudeSetup.login(b.profile, w.id, b.purpose));
47
47
  if (verb === 'check') return send(await ctx.claudeSetup.check(b.profile));
48
48
  if (verb === 'progress') {
49
49
  if (!progress.STEPS.includes(b.step)) return send({ ok: false, error: 'Choose a setup step.' }, 400);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.490.0",
3
+ "version": "0.491.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.490.0",
9
+ "version": "0.491.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.490.0",
3
+ "version": "0.491.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",
@@ -63,8 +63,8 @@ const pressTerm = async (p) => { await p.click('#hmAdd'); await p.click('#hmTerm
63
63
  r.fulfill({ json: { ok: true, id: 'sess-7', cols: 60, rows: 12, gen: 0, end: RAW.length, reset: true, data: RAW } }); });
64
64
  let pops = 0; ctx.on('page', () => { pops++; });
65
65
  await pressTerm(p);
66
- const v = await until(() => p.evaluate(() => { const w = document.querySelector('#czViewer:not([hidden])'); return w && /working/.test(w.textContent) ? (w.querySelector('.cz-vw-kind') || {}).textContent : null; }));
67
- ok('O1 pressing it shows that same session\'s terminal, read only, in the Viewer; no tab opens and nothing links to the console', v === 'Terminal · read only' && read === 'sess-7' && pops === 0
66
+ const v = await until(() => p.evaluate(() => { const w = document.querySelector('#czViewer:not([hidden])'); return w && /working/.test(w.textContent) && w.querySelector('.hv-xt[role="log"]') ? (w.querySelector('.cz-vw-kind') || {}).textContent : null; })); // the read-only view: sess-7 is routed, not running, so the live attach finds nothing
67
+ ok('O1 pressing it shows that same session\'s terminal in the Viewer (read only when the socket has no live session to attach); no tab opens and nothing links to the console', v === 'Terminal · read only' && read === 'sess-7' && pops === 0
68
68
  && !(await p.evaluate(() => [...document.querySelectorAll('a[href]')].some((a) => /console/.test(a.getAttribute('href'))))), JSON.stringify([v, read, pops]));
69
69
  const lines = () => p.evaluate(() => [...document.querySelectorAll('#czViewer .xterm-rows > div')].map((d) => d.textContent.replace(/\u00a0/g, ' ').trimEnd()).filter(Boolean));
70
70
  const l1 = await until(async () => { const l = await lines(); return l.includes('next') ? l : null; }, 9000) || await lines();
@@ -1,5 +1,5 @@
1
1
  /* chat-term — the chat header's Open in terminal icon (chat-open-in-terminal, Wawan 2026-10-22). Pure: no DOM, so Node tests it.
2
- * A running session's terminal opens read only in the Viewer (term-view.js): nothing on the premium pages links to the console any more.
2
+ * A session's terminal opens in the Viewer (term-view.js): live and typeable while it runs, read only once it has ended: nothing on the premium pages links to the console any more.
3
3
  * An ended chat copies the line that resumes its Claude Code conversation in a terminal (lib/briefing-premium-agent.js resumeCommand).
4
4
  * Nothing to open or copy: the icon is hidden. */
5
5
  export const TERM_ICON = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 10 3 2-3 2M12 15h5"/></svg>';
@@ -6,7 +6,8 @@ function load(src) {
6
6
  if (!scripts.has(src)) scripts.set(src, new Promise((resolve, reject) => { const s = document.createElement('script'); s.src = src; s.onload = resolve; s.onerror = () => { scripts.delete(src); reject(new Error('The sign-in terminal could not load. Reload and try again.')); }; document.head.append(s); }));
7
7
  return scripts.get(src);
8
8
  }
9
- export async function signInTerminal(el, sid) {
9
+ /** onEnd(code) runs once when the session ends: the server writes `[exited (code N)]` into the pane (server.js attachPty). */
10
+ export async function signInTerminal(el, sid, { onEnd = null } = {}) {
10
11
  if (!/^sess-\d+$/.test(sid)) return () => {};
11
12
  if (!document.querySelector('[data-setup-xterm]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '/vendor/xterm.css'; l.dataset.setupXterm = '1'; document.head.append(l); }
12
13
  await load('/vendor/xterm.js'); await load('/vendor/addon-fit.js'); await load('/vendor/addon-web-links.js');
@@ -17,12 +18,13 @@ export async function signInTerminal(el, sid) {
17
18
  term.open(el); fit.fit();
18
19
  const sock = new WebSocket((location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/?pmos-nonce=' + encodeURIComponent(pageNonce()));
19
20
  const send = data => { if (sock.readyState === WebSocket.OPEN) sock.send(JSON.stringify(data)); };
21
+ const ended = text => { const end = onEnd && /\[exited \(code (\d+)\)\]/.exec(String(text)); if (end) { const f = onEnd; onEnd = null; setTimeout(() => f(Number(end[1])), 0); } };
20
22
  sock.addEventListener('open', () => send({ t: 'attach', id: sid }));
21
23
  sock.addEventListener('message', e => {
22
24
  if (!el.isConnected) { cleanup(); return; }
23
25
  let m; try { m = JSON.parse(e.data); } catch { return; }
24
- if (m.t === 'attached') { term.reset(); if (m.buf) term.write(m.buf); send({ t: 'resize', id: sid, cols: term.cols, rows: term.rows }); }
25
- if (m.t === 'data' && m.id === sid) term.write(m.data);
26
+ if (m.t === 'attached') { term.reset(); if (m.buf) { term.write(m.buf); ended(m.buf); } send({ t: 'resize', id: sid, cols: term.cols, rows: term.rows }); }
27
+ if (m.t === 'data' && m.id === sid) { term.write(m.data); ended(m.data); }
26
28
  if (m.t === 'error') term.write('\r\nThe session could not be attached. Reopen sign-in.\r\n');
27
29
  });
28
30
  const input = term.onData(data => send({ t: 'input', id: sid, data }));
@@ -55,9 +57,9 @@ export function mountClaudeSetup(el, { ws, onReady = () => {}, onManual = null }
55
57
  ${data && data.discovery_failed ? '<p role="alert">Some profile information could not be read. Your usual login is still a separate candidate, not a verified account.</p>' : ''}
56
58
  <div class="cs-actions"><button type="button" class="wl-btn" data-cs="check"${busy || !data || missing ? ' disabled' : ''}>${busy ? 'Working…' : 'Check and use this profile'}</button><button type="button" class="wl-btn alt" data-cs="login"${busy || !data || missing ? ' disabled' : ''}>Sign in to this profile</button></div>
57
59
  <p class="note">Checking makes a small Claude request and may use your account allowance. It does not scan your project.</p>
58
- ${session ? '<p>Complete Claude’s sign-in below. Type <code>/login</code> here if needed. Then select <b>Check and use this profile</b>.</p><div class="cs-term" aria-label="Claude sign-in terminal"></div>' : ''}
60
+ ${session ? '<p>Finish signing in in the browser window Claude opened. If Claude asks for a code, paste it below. PMOS checks the login when you are done.</p><div class="cs-term" aria-label="Claude sign-in terminal"></div>' : ''}
59
61
  ${onManual ? '<button type="button" class="wl-btn quiet" data-cs="manual">Continue without Claude</button>' : ''}</div>`;
60
- if (session) signInTerminal(el.querySelector('.cs-term'), session).then(stop => { if (disposed || !el.isConnected) stop(); else disposeTerm = stop; }).catch(e => { note = e.message; session = null; draw(); });
62
+ if (session) signInTerminal(el.querySelector('.cs-term'), session, { onEnd: code => { session = null; if (!code && !disposed && el.isConnected) run('check'); else draw(); } }).then(stop => { if (disposed || !el.isConnected) stop(); else disposeTerm = stop; }).catch(e => { note = e.message; session = null; draw(); });
61
63
  }
62
64
  el.addEventListener('change', async e => {
63
65
  if (!e.target.matches('[data-cs-profile]')) return;
@@ -68,6 +70,10 @@ ${onManual ? '<button type="button" class="wl-btn quiet" data-cs="manual">Contin
68
70
  const b = e.target.closest('[data-cs]'); if (!b || b.disabled || busy) return;
69
71
  const act = b.dataset.cs;
70
72
  if (act === 'manual') { await onManual(); return; }
73
+ await run(act);
74
+ });
75
+ async function run(act) {
76
+ if (busy) return;
71
77
  busy = true; note = act === 'check' ? 'Checking Claude access…' : 'Opening the selected sign-in setup…'; draw();
72
78
  try {
73
79
  if (act === 'own') {
@@ -81,10 +87,12 @@ ${onManual ? '<button type="button" class="wl-btn quiet" data-cs="manual">Contin
81
87
  if (r.session) session = r.session;
82
88
  await post('progress', { step: 'claude', profile });
83
89
  if (act === 'check') { session = null; await onReady(r); }
90
+ // already signed in: no terminal, the check runs at once
91
+ else if (r.signedIn) { busy = false; await run('check'); return; }
84
92
  }
85
93
  } catch { note = 'This action could not finish. Check your connection and try again.'; }
86
94
  busy = false; if (el.isConnected) await refresh();
87
- });
95
+ }
88
96
  refresh();
89
97
  return () => { disposed = true; stopTerm(); };
90
98
  }
@@ -53,7 +53,7 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
53
53
  + `<div class="ut-card ob-card" role="radiogroup" aria-label="Claude login">${opts}<label class="ob-opt${pick === '__own__' ? ' on' : ''}"><input type="radio" name="ob-login" value="__own__"${pick === '__own__' ? ' checked' : ''}><span><b>A separate login just for PMOS</b><em>Keeps PMOS on its own account. You sign in once.</em></span></label>`
54
54
  + `<div class="ob-row">${btn('check', 'Test this login', 'pri')}${btn('login', 'Sign in to it', '')}</div>`
55
55
  + `<p class="ob-note">The test sends one short message to Claude with no tools. It uses a little of this account’s usage.</p>`
56
- + (S.session ? '<p class="ob-note">Finish Claude’s sign-in below (type <code>/login</code> if it asks), then press Test this login.</p><div class="cs-term ob-term" aria-label="Claude sign-in terminal"></div>' : '')
56
+ + (S.session ? '<p class="ob-note">Finish signing in in the browser window Claude opened. If it asks for a code, paste it below. I test the login as soon as you are done.</p><div class="cs-term ob-term" aria-label="Claude sign-in terminal"></div>' : '')
57
57
  + `</div>` });
58
58
  return out;
59
59
  }
@@ -136,7 +136,8 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
136
136
  if (S.stopTerm) { S.stopTerm(); S.stopTerm = null; }
137
137
  log.innerHTML = intro + list.map((t, i) => (t.you ? youTurn(t.you) : claudeTurn(t.body, t.mood, i === lastClaude))).join('') + (S.note ? `<p class="ob-note ob-live" role="status">${esc(S.note)}</p>` : '');
138
138
  const term = log.querySelector('.ob-term');
139
- if (term && S.session) signInTerminal(term, S.session).then((stop) => { S.stopTerm = stop; }).catch((e) => { S.note = e.message; S.session = null; draw(); });
139
+ // the sign-in ends on its own once Claude has the login; a clean end runs the test at once
140
+ if (term && S.session) signInTerminal(term, S.session, { onEnd: (code) => { S.session = null; if (!code) act('check'); else { S.note = 'The sign-in stopped before it finished. Sign in again.'; draw(); } } }).then((stop) => { S.stopTerm = stop; }).catch((e) => { S.note = e.message; S.session = null; draw(); });
140
141
  const p = P(), asks = !done && p.verified && !p.project;
141
142
  foot.innerHTML = `<form class="hm-box" data-ob-form="say"><textarea rows="1" aria-label="Message Claude" placeholder="${asks ? 'e.g. Checkout redesign, payments team, Jira PAY' : done ? 'Message Claude' : !p.verified ? 'Test the login first, then tell me about your project' : 'Message Claude'}"${!asks ? ' disabled' : ''}></textarea><div class="hm-tb"><span class="sp"></span><span class="hm-key">Enter sends · Shift+Enter for a new line</span><button type="submit" class="hm-send" aria-label="Send"${!asks ? ' disabled' : ''}>${UP}</button></div></form>`;
142
143
  if (asks) foot.querySelector('textarea').focus({ preventScroll: true });
@@ -153,7 +154,11 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
153
154
  let profile = S.profile || p.profile || (S.data.claude && S.data.claude.selected);
154
155
  if (profile === '__own__') { const own = await post('own'); if (!own.ok) throw new Error(own.error || 'The PMOS login could not be made.'); profile = own.id; S.profile = profile; await load(); }
155
156
  const r = await post(a, { profile });
156
- if (a === 'login') { if (r.ok) S.session = r.session; else S.note = r.error || 'Sign-in could not open.'; }
157
+ if (a === 'login') {
158
+ if (!r.ok) S.note = r.error || 'Sign-in could not open.';
159
+ else if (r.signedIn) { S.session = null; S.busy = ''; return act('check'); } // already signed in: test it, no terminal
160
+ else S.session = r.session;
161
+ }
157
162
  else { S.session = null; if (!r.ok) S.note = r.message || r.error || 'The test did not pass.'; await load(); }
158
163
  } else if (a === 'relogin') { await post('reset'); S.profile = null; await load(); }
159
164
  else if (a === 'pick-existing' || a === 'pick-parent') {
@@ -559,6 +559,9 @@ function setCheck0(id, check) { if (V.cur && V.cur.id === String(id)) { V.cur.ch
559
559
  const each = (id, fn) => ALL.filter((x) => x.cur && x.cur.id === String(id)).forEach((x) => on(x, fn));
560
560
  export function setChip(id, chip) { each(id, () => setChip0(id, chip)); }
561
561
  export function setPresses(id, list) { each(id, () => setPresses0(id, list)); }
562
+ /** The small kind line above the title changes while it is shown (a terminal that turns out read only, term-view.js). */
563
+ function setKind0(id, kind) { if (V.cur && V.cur.id === String(id) && kind) { V.cur.kind = kind; if (V.cur.args) V.cur.args = { ...V.cur.args, kind }; if (!V.cur.renaming) redraw(); } }
564
+ export function setKind(id, kind) { each(id, () => setKind0(id, kind)); }
562
565
  export function setCheck(id, check) { each(id, () => setCheck0(id, check)); }
563
566
  export function retitle(id, title) { each(id, () => retitle0(id, title)); }
564
567
  /** The caller's own rename landed elsewhere (Undo, or a reload): the header shows the name. */
@@ -1,12 +1,14 @@
1
- /* pm/term-view.js — a running session's terminal, read only, in the Viewer card (initiative premium-agreed-design: nothing links to the console).
2
- * openTermView(sid, { title }) → the Viewer body. It reads GET /api/sessions/transcript?id=<sid>&raw=1 every 2 s while the card shows it and
3
- * draws the bytes in a read-only terminal (xterm.js, served from /vendor) the size of the session's own, so a full-screen agent's cursor moves
4
- * and redraws land where they did on the PM's screen. Plain text with the escapes taken out ran words together and piled spinner frames up
5
- * line by line (PM, 2026-10-27: "Broken format on terminal view"). After the first read it asks only for what was printed since (since + gen).
6
- * It keeps the view at the end unless the PM scrolled up. It writes nothing; keys typed in the card go nowhere. The one exception is a session that setup started for the PM's sign-in (the server marks it `typeable`): the card then hands over to the typeable terminal of cozy-claude-setup.js.
7
- * When xterm.js cannot load, it falls back to the plain text (GET …&max=12000, ANSI taken out). */
8
- import { open, current } from './cozy-viewer.js';
9
- import { pmGet } from './http.js';
1
+ /* pm/term-view.js — a session's terminal in the Viewer card (initiative premium-agreed-design: nothing links to the console).
2
+ * openTermView(sid, { title }) → the Viewer body.
3
+ * A RUNNING session is the real terminal (PM, 2026-11-02: "better to have actual terminal as well instead of just viewer"): the card attaches
4
+ * to the session over the page's WebSocket, as the sign-in terminal does (cozy-claude-setup.js signInTerminal), so keys typed in it reach the
5
+ * session — a first-run prompt, a pasted sign-in code, an answer to Claude. Before, it was read only, and a new user whose Claude stopped at its
6
+ * theme or trust-this-folder screen could not answer it.
7
+ * An ENDED session, or a page where the socket cannot attach, keeps the read-only view: GET /api/sessions/transcript?id=<sid>&raw=1 every 2 s,
8
+ * drawn in xterm.js the size of the session's own, after the first read only what was printed since (since + gen). When xterm.js cannot load,
9
+ * it falls back to the plain text (GET …&max=12000, ANSI taken out). */
10
+ import { open, current, setKind } from './cozy-viewer.js';
11
+ import { pmGet, pageNonce } from './http.js';
10
12
 
11
13
  let xtermP = null;
12
14
  /** window.Terminal from /vendor/xterm.js, loaded once with its stylesheet. Resolves null when it cannot load. */
@@ -35,13 +37,49 @@ function look(el) {
35
37
  fontFamily: v('--cz-mono') || 'ui-monospace, Menlo, monospace' };
36
38
  }
37
39
 
40
+ /** The live terminal: attach over the WebSocket and send what the PM types. Resolves true when it attached to a running session,
41
+ * false when the session has ended or the socket did not answer (the caller then shows the read-only view). */
42
+ function attachLive(Terminal, body, sid, live, keep) {
43
+ return new Promise((done) => {
44
+ let sock;
45
+ try { sock = new WebSocket((location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/?pmos-nonce=' + encodeURIComponent(pageNonce())); } catch { done(false); return; }
46
+ const send = (d) => { if (sock.readyState === WebSocket.OPEN) sock.send(JSON.stringify(d)); };
47
+ let term = null, settled = false;
48
+ const settle = (v) => { if (!settled) { settled = true; clearTimeout(t); done(v); } };
49
+ const close = () => { try { send({ t: 'detach', id: sid }); sock.close(); } catch { /* gone */ } if (term) { try { term.dispose(); } catch { /* gone */ } term = null; } };
50
+ const t = setTimeout(() => { close(); settle(false); }, 1500); // a session the server does not know never answers
51
+ sock.addEventListener('open', () => send({ t: 'attach', id: sid }));
52
+ sock.addEventListener('error', () => { close(); settle(false); });
53
+ sock.addEventListener('message', (e) => {
54
+ if (!live()) { close(); return; }
55
+ let m; try { m = JSON.parse(e.data); } catch { return; }
56
+ if (m.t === 'attached' && m.id === sid) {
57
+ if (m.state === 'exited') { close(); settle(false); return; }
58
+ body.innerHTML = '<div class="hv-xt hv-xt-live" aria-label="Terminal"></div>';
59
+ const host = body.firstChild, L = look(host);
60
+ term = new Terminal({ cols: m.cols || 80, rows: m.rows || 24, cursorBlink: true, scrollback: 5000, fontFamily: L.fontFamily, lineHeight: 1.25, theme: { ...L.theme, cursor: L.theme.foreground } });
61
+ term.open(host);
62
+ if (m.buf) term.write(m.buf, () => term && term.scrollToBottom());
63
+ term.onData((d) => send({ t: 'input', id: sid, data: d }));
64
+ // drawn at the session's own grid (as the read-only view is), so opening the card never reflows a running agent
65
+ keep(close);
66
+ term.focus();
67
+ settle(true);
68
+ }
69
+ if (m.t === 'data' && m.id === sid && term) { const b = term.buffer.active, atEnd = b.viewportY >= b.baseY; term.write(m.data, () => { if (atEnd && term) term.scrollToBottom(); }); }
70
+ if (m.t === 'size' && m.id === sid && term) { try { term.resize(m.cols, m.rows); } catch { /* keep */ } }
71
+ if (m.t === 'error' && !term) { close(); settle(false); }
72
+ });
73
+ });
74
+ }
75
+
38
76
  export function openTermView(sid, o = {}) {
39
77
  if (!/^sess-\d+$/.test(String(sid || ''))) return null;
40
78
  const id = 'term:' + sid;
41
- let stop = false, term = null, gen = null, end = null, plain = false, typed = false, stopTyped = null;
42
- const body = open({ id, kind: 'Terminal · read only', title: o.title || sid, icon: 'M4 5h16v14H4zM7 9l3 3-3 3M12 15h5',
79
+ let stop = false, term = null, gen = null, end = null, plain = false, closeLive = null;
80
+ const body = open({ id, kind: 'Terminal', title: o.title || sid, icon: 'M4 5h16v14H4zM7 9l3 3-3 3M12 15h5',
43
81
  html: '<pre class="hv-term" role="log" aria-live="off">Reading the terminal.</pre>',
44
- onClose: () => { stop = true; if (stopTyped) { try { stopTyped(); } catch { /* already gone */ } stopTyped = null; } if (term) { try { term.dispose(); } catch { /* already gone */ } term = null; } } });
82
+ onClose: () => { stop = true; if (closeLive) { closeLive(); closeLive = null; } if (term) { try { term.dispose(); } catch { /* already gone */ } term = null; } } });
45
83
  const live = () => { const c = current(); return !stop && c && c.id === id; };
46
84
 
47
85
  const plainTick = async () => {
@@ -59,17 +97,6 @@ export function openTermView(sid, o = {}) {
59
97
  const r = await pmGet('/api/sessions/transcript?id=' + encodeURIComponent(sid) + '&raw=1' + q);
60
98
  if (!live()) return;
61
99
  if (!r || !r.ok) { if (!term) { const pre = body.querySelector('.hv-term'); if (pre) pre.textContent = (r && r.error) || 'The terminal could not be read.'; } return; }
62
- if (r.typeable && !typed) {
63
- // A sign-in session that setup started: Claude's first-run screens (theme, login method, folder trust) need the PM's keys.
64
- // Hand the card to the same typeable terminal the setup page uses, and stop polling.
65
- typed = true;
66
- if (term) { try { term.dispose(); } catch { /* already gone */ } term = null; }
67
- body.innerHTML = '<p class="hv-note">Claude is waiting for you. Type here to choose, then sign in.</p><div class="cs-term" aria-label="Claude sign-in terminal"></div>';
68
- const { signInTerminal } = await import('./cozy-claude-setup.js');
69
- const stop = await signInTerminal(body.querySelector('.cs-term'), sid);
70
- if (live()) stopTyped = stop; else stop();
71
- return;
72
- }
73
100
  if (!term || r.reset) {
74
101
  if (term) { try { term.dispose(); } catch { /* already gone */ } }
75
102
  body.innerHTML = '<div class="hv-xt" role="log" aria-live="off" aria-label="Terminal, read only"></div>';
@@ -92,11 +119,15 @@ export function openTermView(sid, o = {}) {
92
119
  (async () => {
93
120
  const Terminal = await loadXterm();
94
121
  if (!Terminal) plain = true;
122
+ else if (await attachLive(Terminal, body, sid, live, (c) => { closeLive = c; })) return; // a running session: the real terminal
123
+ if (!live()) return;
124
+ // an ended session (or no socket): the read-only view, and the card says so
125
+ setKind(id, 'Terminal · read only');
95
126
  const loop = async () => {
96
127
  if (!live()) return;
97
128
  try { if (plain) await plainTick(); else await xtTick(Terminal); }
98
129
  catch { if (!plain) { plain = true; term = null; } }
99
- if (live() && !typed) setTimeout(loop, 2000);
130
+ if (live()) setTimeout(loop, 2000);
100
131
  };
101
132
  loop();
102
133
  })();
@@ -546,6 +546,7 @@ function defaultProfileFor(agent) {
546
546
  // The merged environment a session actually runs under. The overlay goes ON TOP of sessionEnv(),
547
547
  // AFTER the marker-stripping (R3) — never instead of it, or a profile would silently re-enable the
548
548
  // nested-session markers sessionEnv exists to remove.
549
+ const claudeHome = require('./lib/claude-home');
549
550
  function sessionEnvWithProfile(profile) {
550
551
  const env = sessionEnv();
551
552
  for (const [k, v] of Object.entries(profileOverlay(profile))) env[k] = v;
@@ -560,7 +561,9 @@ function profileOverlay(profile) {
560
561
  if (profile && profile.env && typeof profile.env === 'object') {
561
562
  for (const k of Object.keys(profile.env)) out[k] = String(profile.env[k]);
562
563
  }
563
- return out;
564
+ // CLAUDE_CONFIG_DIR=~/.claude makes Claude read ~/.claude/.claude.json instead of ~/.claude.json, so it shows its first-run
565
+ // screens and misses the login already there (lib/claude-home.js). A profile that names only the default folder sets nothing.
566
+ return claudeHome.overlay(out, { home: os.homedir(), inherited: process.env.CLAUDE_CONFIG_DIR || '' });
564
567
  }
565
568
 
566
569
  const SCROLLBACK = 200_000; // bytes of ring buffer per session
@@ -4258,14 +4261,19 @@ const claudeSetup = require('./lib/claude-readiness').create({
4258
4261
  savePreference: (id) => { const p = readPrefs(); p.claude = id; return writePrefs(p); },
4259
4262
  });
4260
4263
  claudeSetup.ensureOwn = () => require('./lib/own-profile').ensure(os.homedir(), profilesLib.profilesDir(os.homedir()));
4261
- claudeSetup.login = (id, ws, purpose, cwd) => {
4264
+ /* Sign-in (bug 2026-11-02): a login that is signed in already is used as it is, with no terminal. Otherwise the sign-in runs
4265
+ * `claude auth login`, not the full Claude Code screen: it opens the browser and at most asks for a pasted code, so a new user
4266
+ * never meets Claude's theme picker or its trust-this-folder question in a terminal they may only be able to watch. */
4267
+ claudeSetup.login = async (id, ws, purpose, cwd) => {
4262
4268
  const candidate = claudeSetup.candidate(id);
4263
4269
  if (!candidate) return { ok: false, error: 'Choose an available Claude profile.' };
4264
4270
  let pinned;
4265
4271
  try { pinned = claudeSetup.pinDefault(candidate); } catch { return { ok: false, error: 'The selected configuration could not be saved for sign-in.' }; }
4266
- const origin = purpose === 'permissions' ? 'onboarding-permissions' : 'onboarding-login';
4272
+ const signIn = purpose !== 'permissions';
4273
+ if (signIn && await claudeSetup.signedIn(pinned) === true) return { ok: true, signedIn: true, profile: pinned };
4274
+ const origin = signIn ? 'onboarding-login' : 'onboarding-permissions';
4267
4275
  const live = [...sessions.values()].find(s => s.origin === origin && s.profile === pinned && s.state !== 'exited');
4268
- const s = live || spawnSession({ agent: 'claude', profile: pinned, ws, ...(cwd ? { cwd } : {}), name: purpose === 'permissions' ? 'Claude connections and permissions' : 'Claude sign-in', origin, launchFlags: purpose === 'permissions' ? [] : [{ flag: '--safe-mode' }] });
4276
+ const s = live || spawnSession({ agent: 'claude', profile: pinned, ws, ...(cwd ? { cwd } : {}), name: signIn ? 'Claude sign-in' : 'Claude connections and permissions', origin, launchFlags: [], ...(signIn ? { authLogin: true } : {}) });
4269
4277
  return s && s.state !== 'exited' ? { ok: true, session: s.id, profile: pinned } : { ok: false, error: 'Claude could not start. Check its installation and this profile.' };
4270
4278
  };
4271
4279
 
@@ -4521,7 +4529,7 @@ function spawnSession(opts) {
4521
4529
  return s;
4522
4530
  }
4523
4531
  function noteSessionEnd(s) { try { if (refreshRun) refreshRun.ended(s); } catch (e) { warnWriteFail('refresh log (end)', e); } }
4524
- function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile, initiative, modelAsk, planItem, workType, autoDelete, launchFlags, addDirs, onDone, scratch, extraEnv, writePaths, chatClaude, byPm, typedByPm }) {
4532
+ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile, initiative, modelAsk, planItem, workType, autoDelete, launchFlags, addDirs, onDone, scratch, extraEnv, writePaths, chatClaude, byPm, typedByPm, authLogin }) {
4525
4533
  const id = nextSessionId();
4526
4534
  /* pm-os-absorb Run 1 — every AGENT session gets a token, `<id>.<8 hex>`, in its environment as PMOS_SESSION, and
4527
4535
  * PMOS_BIN, this workspace's own bin/pmos.js. `pmos item` run inside it is then attributed `agent:<token>` (the token
@@ -4636,6 +4644,8 @@ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile
4636
4644
  // premium-chat-session L2: a chat keeps one Claude Code conversation id, so the session that replaces an ended one resumes it
4637
4645
  if (agent === 'claude' && /^chat:/.test(String(tag || '')) && chatClaude && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(chatClaude.id || ''))) argv.push(chatClaude.resume ? '--resume' : '--session-id', String(chatClaude.id));
4638
4646
  else if (process.env.PMOS_AGENT_HOOKS === '1' && agent === 'claude') argv.push('--settings', JSON.stringify(require('./lib/routes-hooks.js').settingsFor(PORT)));
4647
+ // the onboarding sign-in runs only `claude auth login` (claudeSetup.login): no model, flag or hook argument belongs to it
4648
+ if (authLogin === true && agent === 'claude' && origin === 'onboarding-login') argv.splice(0, argv.length, 'auth', 'login');
4639
4649
  const launchArgs = argv;
4640
4650
  if (mres.tier) {
4641
4651
  const mc = modelLib.core();
@@ -5489,7 +5499,8 @@ function sessionConnectors() {
5489
5499
  const disc = require('./lib/profile-discovery');
5490
5500
  const id = defaultProfileFor('claude');
5491
5501
  const prof = id ? profileById(id).profile : null;
5492
- const dir = prof ? (prof.env && prof.env.CLAUDE_CONFIG_DIR) || null : process.env.CLAUDE_CONFIG_DIR || os.homedir();
5502
+ // a profile that names only ~/.claude reads ~/.claude.json, as Claude does (profileOverlay)
5503
+ const dir = prof ? profileOverlay(prof).CLAUDE_CONFIG_DIR || process.env.CLAUDE_CONFIG_DIR || os.homedir() : process.env.CLAUDE_CONFIG_DIR || os.homedir();
5493
5504
  const names = [...new Set([...(prof && Array.isArray(prof.mcp) ? prof.mcp : []), ...(dir ? disc.connectorsIn(dir) : [])])];
5494
5505
  return { profile: prof ? prof.id : null, list: names.slice(0, proactiveLib.MAX_CONNECTORS).map((name) => ({ name, label: proactiveLib.connectorLabel(name) || name, source: proactiveLib.connectorSource(name) })) };
5495
5506
  }