create-pmos 0.450.0 → 0.452.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.450.0",
3
+ "version": "0.452.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,30 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.452.0",
37
+ "at": "2026-10-29T12:06:35.455Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 1098,
42
+ "t": "Settings > Claude: API key and Claude profile",
43
+ "s": "Settings > Claude: API key and Claude profile"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "v": "0.451.0",
49
+ "at": "2026-10-29T08:39:19.762Z",
50
+ "f": 2,
51
+ "prs": [
52
+ {
53
+ "n": 1097,
54
+ "t": "Catch up to Claude Code 2.1.312",
55
+ "s": "Catch up to Claude Code 2.1.312"
56
+ }
57
+ ]
58
+ },
35
59
  {
36
60
  "v": "0.450.0",
37
61
  "at": "2026-10-29T08:31:57.056Z",
@@ -247,30 +271,6 @@
247
271
  "s": "When an initiative has any dated milestone task, the end ◇ is one of them."
248
272
  }
249
273
  ]
250
- },
251
- {
252
- "v": "0.432.0",
253
- "at": "2026-10-28T02:08:08.690Z",
254
- "f": 2,
255
- "prs": [
256
- {
257
- "n": 1074,
258
- "t": "Fewer menus, a short initiative menu, Delete with Undo (batch 16 item 5)",
259
- "s": "Fewer menus, a short initiative menu, Delete with Undo (batch 16 item 5)"
260
- }
261
- ]
262
- },
263
- {
264
- "v": "0.431.0",
265
- "at": "2026-10-28T01:37:46.171Z",
266
- "f": 2,
267
- "prs": [
268
- {
269
- "n": 1075,
270
- "t": "A milestone on the timeline says its own name and date (hotfix)",
271
- "s": "A milestone on the Board timeline says its own name and date."
272
- }
273
- ]
274
274
  }
275
275
  ]
276
276
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@07f13caa
1
+ kernel-source: pmos@8ed1ed43
2
2
  assembled: 2026-10-29
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-29T08:31:54Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-29T12:06:31Z"}
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-29T08:31:54Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-29T12:06:31Z"}
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-29T08:31:54Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-29T12:06:31Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,28 @@
1
1
  [
2
+ {
3
+ "v": "0.452.0",
4
+ "at": "2026-10-29T12:06:35.455Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1098,
9
+ "t": "Settings > Claude: API key and Claude profile",
10
+ "s": "Settings > Claude: API key and Claude profile"
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "v": "0.451.0",
16
+ "at": "2026-10-29T08:39:19.762Z",
17
+ "f": 2,
18
+ "prs": [
19
+ {
20
+ "n": 1097,
21
+ "t": "Catch up to Claude Code 2.1.312",
22
+ "s": "Catch up to Claude Code 2.1.312"
23
+ }
24
+ ]
25
+ },
2
26
  {
3
27
  "v": "0.450.0",
4
28
  "at": "2026-10-29T08:31:57.056Z",
@@ -2,7 +2,7 @@
2
2
  type: Guide
3
3
  title: "Settings in console3: one home for each setting"
4
4
  description: "How to open Settings in console3, what each section holds, what the scope tags and the environment notes mean, and where the settings are kept."
5
- timestamp: 2026-10-28
5
+ timestamp: 2026-10-29
6
6
  ---
7
7
 
8
8
  # Settings in console3: one home for each setting
@@ -35,6 +35,7 @@ Settings is not a tab. While it is open, no tab is selected. Press a tab to go b
35
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
+ | Claude | The Claude profile that new Claude sessions start with, and the Anthropic API key for Claude's own runs on the API (see below). |
38
39
  | Updates | The version of the app and of each workspace's kit. Check for updates, and how updates are found and applied. |
39
40
 
40
41
  Type in **Search settings** to find a setting in any section. Press **Open section** to go to its section.
@@ -63,6 +64,12 @@ Open **Updates** and press **Check now**. PMOS asks the npm registry for the lat
63
64
  - When PMOS runs from a PMOS checkout, the row says to update it with `git pull`. There is no Update button.
64
65
  - **Update** on a workspace row updates the kit in that repository. It replaces the kit files in its `pmos/` folder (AGENTS.md, skills, scripts, templates, `okf/core`, the mod and KIT-VERSION). It does not change `state/`, `planning/` or `okf/product/`, and it does not commit. Review the change in the repository as a normal pull request.
65
66
 
67
+ ## Claude: the profile and the API key
68
+
69
+ **Claude profile.** Pick one of the profiles on this computer, or **No profile**. New Claude sessions start with it. The list comes from the profile files in `~/.claude/profiles/`.
70
+
71
+ **API key.** Some runs of Claude, for example Grill, can use the Claude API and not a Claude session. Paste an Anthropic API key and press **Save** to turn this on. The key stays on this computer, in a file only you can read, outside every repository. PMOS never shows the key again: the row only says that a key is set. Press **Remove** to delete it. A key saved here is used before `ANTHROPIC_API_KEY`. A command that a run starts does not get the key. Only the computer that runs the workspace can change it. Set `PMOS_GRILL_API=off` to stop runs on the API.
72
+
66
73
  ## Where the settings are kept
67
74
 
68
75
  The settings that had a home before this page keep it. For example, the recording engine is kept by the notes engine, Validate consent by the validate route, and the theme and the new-session defaults in this browser.
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+ /* anthropic-key.js — where the PM's Anthropic API key lives (D101). It pays for Claude's own runs on the API (lib/grill-api.js).
3
+ *
4
+ * The file is `<runtime state>/anthropic.json`, in the per-user runtime directory that lib/state-root.js keeps OUTSIDE every
5
+ * repository, so no commit, sync or share can carry it. It is written with mode 0600 through a temporary file and a rename, and
6
+ * a symlink at the target is refused (the lib/typesafe-settings.js pattern).
7
+ *
8
+ * What leaves this module: `status()` says whether a key is present and where it came from, never the key and never its length.
9
+ * `getKey()` is for the server's own API calls. No route returns its value, and nothing writes it to a log or to a child's
10
+ * environment: a session the server starts never sees it. `ANTHROPIC_API_KEY` in the environment is the fallback, read in place.
11
+ *
12
+ * validKey(k) · status(stateDir, env) → { present, source } · getKey(stateDir, env) → string | null
13
+ * setKey(stateDir, key) → { ok } | { ok: false, error } · clearKey(stateDir)
14
+ */
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+
18
+ const FILE = 'anthropic.json';
19
+ const ENV_NAME = 'ANTHROPIC_API_KEY';
20
+ const validKey = (k) => typeof k === 'string' && /^sk-ant-[A-Za-z0-9_-]{8,400}$/.test(k);
21
+ const file = (stateDir) => path.join(stateDir, FILE);
22
+
23
+ function read(stateDir) {
24
+ try {
25
+ if (!fs.lstatSync(file(stateDir)).isFile()) return null;
26
+ const o = JSON.parse(fs.readFileSync(file(stateDir), 'utf8'));
27
+ return o && validKey(o.key) ? o.key : null;
28
+ } catch { return null; }
29
+ }
30
+
31
+ function write(stateDir, data) {
32
+ const target = file(stateDir);
33
+ try { if (fs.lstatSync(target).isSymbolicLink()) return { ok: false, error: 'the settings file is a symlink and was not written' }; } catch { /* not there yet */ }
34
+ const tmp = target + '.' + process.pid + '.tmp';
35
+ try {
36
+ fs.mkdirSync(stateDir, { recursive: true });
37
+ fs.writeFileSync(tmp, JSON.stringify(data), { mode: 0o600 });
38
+ fs.chmodSync(tmp, 0o600);
39
+ fs.renameSync(tmp, target);
40
+ return { ok: true };
41
+ } catch (e) {
42
+ try { fs.unlinkSync(tmp); } catch { /* nothing to clean */ }
43
+ return { ok: false, error: 'the key could not be saved (' + String((e && e.code) || 'write failed') + ')' };
44
+ }
45
+ }
46
+
47
+ /** The key for the server's own use: the saved one first, then the environment. */
48
+ function getKey(stateDir, env = null) {
49
+ return read(stateDir) || (env && validKey(String(env[ENV_NAME] || '').trim()) ? String(env[ENV_NAME]).trim() : null);
50
+ }
51
+ /** What the browser may know: present or not, and from where. */
52
+ function status(stateDir, env = null) {
53
+ if (read(stateDir)) return { present: true, source: 'settings' };
54
+ if (env && validKey(String(env[ENV_NAME] || '').trim())) return { present: true, source: 'environment' };
55
+ return { present: false, source: null };
56
+ }
57
+ function setKey(stateDir, key) {
58
+ const k = typeof key === 'string' ? key.trim() : '';
59
+ if (!validKey(k)) return { ok: false, error: 'that does not look like an Anthropic key: it starts with sk-ant- and has no spaces' };
60
+ return write(stateDir, { key: k });
61
+ }
62
+ function clearKey(stateDir) {
63
+ try { fs.unlinkSync(file(stateDir)); return { ok: true }; } catch (e) { return e && e.code === 'ENOENT' ? { ok: true } : { ok: false, error: 'the key could not be removed (' + String((e && e.code) || 'failed') + ')' }; }
64
+ }
65
+
66
+ module.exports = { FILE, ENV_NAME, validKey, status, getKey, setKey, clearKey };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "source": "claude --help",
3
- "cli_version": "2.1.293",
3
+ "cli_version": "2.1.312",
4
4
  "flags": [
5
5
  {
6
6
  "flag": "--add-dir",
@@ -263,7 +263,7 @@
263
263
  "!1p,!file"
264
264
  ],
265
265
  "example": null,
266
- "description": "Enable debug mode with optional category filtering (e.g., \"api,hooks\" or \"!1p,!file\")",
266
+ "description": "Enable debug mode with optional category filtering (e.g., --debug=hooks,mcp or --debug='!hooks,!mcp')",
267
267
  "printOnly": false,
268
268
  "managed": null,
269
269
  "caution": false
@@ -305,7 +305,7 @@
305
305
  "choices": null,
306
306
  "suggestions": null,
307
307
  "example": null,
308
- "description": "Disable all skills",
308
+ "description": "Disable all skills and commands",
309
309
  "printOnly": false,
310
310
  "managed": null,
311
311
  "caution": false
@@ -516,8 +516,8 @@
516
516
  "choices": null,
517
517
  "suggestions": null,
518
518
  "example": "{\"type\":\"object\",…}",
519
- "description": "JSON Schema for structured output validation. Example: {\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"}},\"required\":[\"name\"]}",
520
- "printOnly": false,
519
+ "description": "JSON Schema for structured output validation (only works with --print). Example: {\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"}},\"required\":[\"name\"]}",
520
+ "printOnly": true,
521
521
  "managed": null,
522
522
  "caution": false
523
523
  },
@@ -781,7 +781,7 @@
781
781
  "choices": null,
782
782
  "suggestions": null,
783
783
  "example": null,
784
- "description": "Restricted mode: removes the built-in tools that run commands or code (Bash, PowerShell, REPL and the other code-running tools) and WebFetch unless --tools names them, and ignores user, project and local settings files (managed settings and --settings still apply; add --strict-mcp-config to skip MCP servers too). Also confines the file tools to the working directories (--add-dir included), refuses bypassPermissions, and lets only a person or the configured permission handler approve writes to settings, git and tool-configuration files.",
784
+ "description": "Restricted mode: removes the built-in tools that run commands or code (Bash, PowerShell and the other code-running tools) and WebFetch unless --tools names them, and ignores user, project and local settings files (managed settings and --settings still apply; add --strict-mcp-config to skip MCP servers too). Also confines the file tools to the working directories (--add-dir included), refuses bypassPermissions, and lets only a person or the configured permission handler approve writes to settings, git and tool-configuration files.",
785
785
  "printOnly": false,
786
786
  "managed": null,
787
787
  "caution": false
@@ -797,7 +797,7 @@
797
797
  "choices": null,
798
798
  "suggestions": null,
799
799
  "example": "a session id, or a search term",
800
- "description": "Resume a conversation by session ID, or open interactive picker with optional search term",
800
+ "description": "Resume a conversation by session ID or name, or open interactive picker with optional search term",
801
801
  "printOnly": false,
802
802
  "managed": null,
803
803
  "caution": false
@@ -907,7 +907,7 @@
907
907
  "off"
908
908
  ],
909
909
  "example": null,
910
- "description": "Record the system prompt once per conversation and reuse it verbatim on every request and resume. on (the default): the prompt is rendered on the conversation's first request — a --system-prompt or --append-system-prompt included — sent, and recorded; every later request and resume sends the record as-is, even when a later launch passes different text, until the conversation is compacted. off: never record; the prompt is rendered fresh every request (for iterating on prompt text). No effect where system-prompt recording is not yet enabled. (choices: \"on\", \"off\")",
910
+ "description": "Record the system prompt once per conversation and reuse it verbatim on every request and resume. on (the default, except under --bare outside cloud and background sessions): the prompt is rendered on the conversation's first request — a --system-prompt or --append-system-prompt included — sent, and recorded; every later request and resume sends the record as-is, even when a later launch passes different text, until the conversation is compacted. off: never record; the prompt is rendered fresh every request (for iterating on prompt text). (choices: \"on\", \"off\")",
911
911
  "printOnly": false,
912
912
  "managed": null,
913
913
  "caution": false
@@ -953,7 +953,7 @@
953
953
  "Read,Grep,Glob"
954
954
  ],
955
955
  "example": null,
956
- "description": "Specify the list of available tools from the built-in set. Use \"\" to disable all tools, \"default\" to use all tools, or specify tool names (e.g. \"Bash,Edit,Read\").",
956
+ "description": "Specify the list of available tools from the built-in set. Use \"\" to disable all tools, \"default\" to use the default set, or specify tool names (e.g. \"Bash,Edit,Read\").",
957
957
  "printOnly": false,
958
958
  "managed": null,
959
959
  "caution": false
@@ -8,9 +8,9 @@
8
8
  * The run's only write is `pmos grill find` (pinned by the run's PMOS_GRILL_* env, as in the CLI run). The loop stops at its budget:
9
9
  * after every response the cost is counted from the usage, and the run ends before it can pass --budget.
10
10
  *
11
- * available(env) → bool an API key is set (ANTHROPIC_API_KEY) and PMOS_GRILL_API is not off
11
+ * available(env, apiKey?) → bool a key is saved in Settings (lib/anthropic-key.js) or set in ANTHROPIC_API_KEY, and PMOS_GRILL_API is not off
12
12
  * costOf(model, usage) → US dollars null for a model with no known price
13
- * run({ prompt, root, env, budget, model?, client?, signal?, pmosBin? }) → Promise<{ ok, code, costUsd, note?, turns }>
13
+ * run({ prompt, root, env, budget, model?, client?, signal?, pmosBin?, apiKey? }) → Promise<{ ok, code, costUsd, note?, turns }>
14
14
  * (the shape lib/grill-runs.js `ended` reads: { code, result: { ok, costUsd } })
15
15
  */
16
16
  const fs = require('fs');
@@ -29,7 +29,7 @@ const SKIP = new Set(['node_modules', '.git', 'dist', 'build']);
29
29
  const PMOS_OK = [['initiative', 'export'], ['task', 'list'], ['source', 'status'], ['source', 'show'], ['grill', 'find'], ['grill', 'voices'], ['grill', 'status']];
30
30
 
31
31
  const flagOff = (v) => /^(off|0|false|no)$/i.test(String(v || '').trim());
32
- const available = (env = process.env) => !!(env.ANTHROPIC_API_KEY && String(env.ANTHROPIC_API_KEY).trim()) && !flagOff(env.PMOS_GRILL_API);
32
+ const available = (env = process.env, apiKey = null) => !!((apiKey && String(apiKey).trim()) || (env.ANTHROPIC_API_KEY && String(env.ANTHROPIC_API_KEY).trim())) && !flagOff(env.PMOS_GRILL_API);
33
33
  const modelOf = (env = process.env) => String(env.PMOS_GRILL_MODEL || '').trim() || DEFAULT_MODEL;
34
34
  function costOf(model, usage) {
35
35
  const p = PRICE[model]; if (!p || !usage) return null;
@@ -105,12 +105,14 @@ async function callTool(name, input, ctx) {
105
105
  } catch (e) { return { text: 'failed: ' + String((e && e.message) || e).slice(0, 200), error: true }; }
106
106
  }
107
107
 
108
- async function run({ prompt, root, env: extra, budget, model, client, signal, pmosBin } = {}) {
108
+ async function run({ prompt, root, env: extra, budget, model, client, signal, pmosBin, apiKey } = {}) {
109
109
  const env = { ...process.env, ...(extra || {}) };
110
+ const key = (apiKey && String(apiKey).trim()) || env.ANTHROPIC_API_KEY;
111
+ delete env.ANTHROPIC_API_KEY; // the key is the loop's own: a pmos command it runs never sees it
110
112
  const useModel = model || modelOf(env), limit = Number(budget);
111
- if (!available(env) && !client) return { ok: false, code: 1, costUsd: 0, turns: 0, note: 'no ANTHROPIC_API_KEY' };
113
+ if (!key && !client) return { ok: false, code: 1, costUsd: 0, turns: 0, note: 'no ANTHROPIC_API_KEY' };
112
114
  if (PRICE[useModel] == null) return { ok: false, code: 1, costUsd: 0, turns: 0, note: `no known price for ${useModel}: the budget cannot be held` };
113
- const api = client || new (require('@anthropic-ai/sdk'))({ apiKey: env.ANTHROPIC_API_KEY });
115
+ const api = client || new (require('@anthropic-ai/sdk'))({ apiKey: key });
114
116
  const ctx = { root: path.resolve(root || process.cwd()), env, pmosBin: pmosBin || path.join(__dirname, '..', 'bin', 'pmos.js') };
115
117
  const messages = [{ role: 'user', content: String(prompt) }];
116
118
  let cost = 0, turns = 0;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.450.0",
3
+ "version": "0.452.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.450.0",
9
+ "version": "0.452.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.450.0",
3
+ "version": "0.452.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",
@@ -22,13 +22,18 @@
22
22
  * it with ↻ Read again, and the place menu opens Settings at Connectors. Every write is the PM's press (pmPost carries the launch nonce).
23
23
  * PMOS reads the sources and never posts to them.
24
24
  * openSettings(section?) */
25
- import { pmGet, pmPost } from './http.js';
25
+ import { pmGet, pmPost, pressFetch } from './http.js';
26
26
  import { esc, svg, ICON, toast, wsParam, wsQ } from './cozy-evui.js';
27
27
  import { sourceRows, staleOf, partsOf } from './cozy-evmodel.js';
28
28
  import * as AD from './cozy-adler.js';
29
29
  import * as SE from './cozy-seasons.js';
30
30
 
31
- const SECTIONS = [['general', 'General'], ['adler', 'Adler'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['workflows', 'Workflows'], ['updates', 'Updates'], ['whatsnew', "What's new"]];
31
+ /** PUT or DELETE with the page's launch nonce (pressFetch). Only the key row needs them. */
32
+ async function pmSend(method, path, body) {
33
+ try { const res = await pressFetch(path, { method, ...(body === undefined ? {} : { body: JSON.stringify(body) }) }); const out = await res.json(); if (out && typeof out === 'object' && !res.ok) out.status = res.status; return out; }
34
+ catch (e) { return { ok: false, error: 'could not reach the workspace server — ' + ((e && e.message) || String(e)) }; }
35
+ }
36
+ const SECTIONS = [['general', 'General'], ['claude', 'Claude'], ['adler', 'Adler'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['workflows', 'Workflows'], ['updates', 'Updates'], ['whatsnew', "What's new"]];
32
37
  const PAGE_LINKS = { workflows: '/premium-workflows.html' }; // a section that is a page of its own: the row goes there
33
38
  const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
34
39
  const VIEWER_KEY = 'pmos.cz.viewer';
@@ -205,7 +210,23 @@ function whatsnew() {
205
210
  if (!L.length) return '<p class="ev-small ev-mut">No kit summaries yet. Each kit published from now on carries one, and Check now reads the newest ones.</p>';
206
211
  return `<ul class="ev-kv">${L.slice(0, 40).map((e) => `<li><b>${esc(e.v)}</b><div class="ev-tx">${mine && e.v === mine ? '<span class="ev-pill">Yours</span> ' : mine && cmpVer(e.v, mine) > 0 ? '<span class="ev-pill y">Newer</span> ' : ''}${(e.prs || []).map((p) => `<p>${esc(p.t && p.t !== p.s ? p.t + ': ' + p.s : p.s)}${p.n ? ' <span class="ev-mut">#' + esc(p.n) + '</span>' : ''}</p>`).join('') || '<p class="ev-mut">No summary was recorded for this kit.</p>'}</div></li>`).join('')}</ul>`;
207
212
  }
208
- const BODY = { general, adler: adlerSec, connectors, workspaces, updates, whatsnew };
213
+ /* Settings > Claude: which Claude profile PMOS starts Claude sessions with, and the API key for Claude's own runs (D101).
214
+ * The key is typed here and goes to this computer only; the page never gets it back, only whether one is set and where from. */
215
+ function claudeSec() {
216
+ const C = T.cl;
217
+ if (!C) return '<p class="ev-small ev-mut">Reading the profiles and the key.</p>';
218
+ const ps = C.profiles || [], pref = (C.prefs && C.prefs.claude) || '';
219
+ const opts = `<option value=""${pref ? '' : ' selected'}>No profile</option>` + ps.map((x) => `<option value="${esc(x.id)}"${x.id === pref ? ' selected' : ''}>${esc(x.label || x.id)}${x.account ? ' · ' + esc(x.account) : ''}</option>`).join('');
220
+ const gone = pref && !ps.some((x) => x.id === pref);
221
+ const profSub = C.perr ? 'The profiles could not be read: ' + C.perr : !ps.length ? 'No profiles on this computer. PMOS starts Claude as you are signed in.' : gone ? 'The saved profile is no longer on this computer.' : pref ? 'New Claude sessions start with it.' : 'New Claude sessions start as you are signed in.';
222
+ const k = C.key || {};
223
+ const keySub = k.present ? (k.source === 'environment' ? 'Set in ANTHROPIC_API_KEY. A key saved here is used first.' : 'Saved on this computer only. PMOS never shows it again.') : 'Not set. Claude\u2019s own runs, such as Grill, use a Claude session instead.';
224
+ const keyRight = `<span class="ev-dr-pl"><label class="ev-vh" for="evKey">Anthropic API key</label><input id="evKey" class="ev-inp" type="password" autocomplete="off" spellcheck="false" placeholder="${k.present ? 'Replace the key' : 'sk-ant-\u2026'}" data-ev-key><button type="button" class="ev-btn sm pri" data-ev-keysave>Save</button>${k.source === 'settings' ? '<button type="button" class="ev-btn sm" data-ev-keyclear>Remove</button>' : ''}</span>`;
225
+ return trow('Claude profile', profSub, `<label class="ev-vh" for="evProf">Claude profile</label><select id="evProf" class="ev-inp" data-ev-prof>${opts}</select>`)
226
+ + trow('API key', keySub, keyRight)
227
+ + (k.present && C.off ? trow('Runs on the API', 'Off: PMOS_GRILL_API is off in the environment.', '<span class="ev-pill">Off</span>') : '');
228
+ }
229
+ const BODY = { general, claude: claudeSec, adler: adlerSec, connectors, workspaces, updates, whatsnew };
209
230
  function draw() {
210
231
  const el = T.el; if (!el || el.hidden) return;
211
232
  // a redraw replaces the nodes: keep focus on the same control (by its data-ev-* key), else on the open section, never on the body
@@ -231,6 +252,12 @@ function mount() {
231
252
  document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && T.el && !T.el.hidden && !T.el.contains(e.target)) { e.preventDefault(); e.stopPropagation(); closeSettings(); } }, true);
232
253
  T.el.addEventListener('change', async (e) => {
233
254
  const x = e.target;
255
+ if (x.matches('[data-ev-prof]')) {
256
+ const r = await pmPost('/api/profiles/prefer', { agent: 'claude', profile: x.value || null });
257
+ if (r && r.ok) { T.cl = { ...T.cl, prefs: { ...((T.cl && T.cl.prefs) || {}) } }; if (x.value) T.cl.prefs.claude = x.value; else delete T.cl.prefs.claude; }
258
+ T.msg = r && r.ok ? (x.value ? 'Saved. New Claude sessions start with this profile.' : 'Saved. New Claude sessions start without a profile.') : (r && r.error) || 'Not saved.';
259
+ draw(); return;
260
+ }
234
261
  if (x.matches('[data-ev-dsel]')) { await saveDress(x.dataset.evDsel, x.value); return; }
235
262
  if (x.matches('[data-ev-dcol]')) { const c = [...(dp()['adler.dress.colors'] || ['blue', 'green'])]; c[Number(x.dataset.evDcol)] = x.value; await saveDress('adler.dress.colors', c); return; }
236
263
  if (x.matches('[data-ev-bday]')) { if (!/^\d{4}-\d{2}-\d{2}$/.test(x.value)) return; T.bday = false; await saveDress('adler.dress.birthday', x.value.slice(5), 'Saved. He dresses up on your birthday.'); return; }
@@ -274,6 +301,15 @@ async function press(e) {
274
301
  PP.openPicker(t, { P, label: 'Products', onApply: async (on) => { const r = await PP.savePick(on); if (!r.ok) { T.msg = r.error; draw(); return; } T.prods = r.products; draw(); } });
275
302
  return;
276
303
  }
304
+ if ('evKeysave' in t.dataset || 'evKeyclear' in t.dataset) {
305
+ const clear = 'evKeyclear' in t.dataset, inp = T.el.querySelector('#evKey'), val = inp ? inp.value.trim() : '';
306
+ if (!clear && !val) { T.msg = 'Paste the key first.'; draw(); return; }
307
+ const r = clear ? await pmSend('DELETE', '/api/anthropic/key') : await pmSend('PUT', '/api/anthropic/key', { key: val });
308
+ if (inp) inp.value = '';
309
+ if (r && r.ok) T.cl = { ...T.cl, key: r.key };
310
+ T.msg = r && r.ok ? (clear ? 'The saved key is removed.' : 'Saved on this computer. Claude\u2019s own runs use it from now on.') : (r && r.error) || 'Not saved.';
311
+ draw(); return;
312
+ }
277
313
  if (t.dataset.evRead || 'evReadall' in t.dataset) { readAgain(t.dataset.evRead || ''); return; }
278
314
  if (T.busy) return;
279
315
  T.busy = true; T.msg = '';
@@ -349,6 +385,7 @@ async function readAgain(id) {
349
385
  }
350
386
  async function load() {
351
387
  readFresh();
388
+ pmGet('/api/profiles').then(async (pr) => { const k = await pmGet('/api/anthropic'); T.cl = { profiles: pr && Array.isArray(pr.profiles) ? pr.profiles : [], prefs: (pr && pr.prefs) || {}, perr: pr && pr.ok === false ? (pr.error || 'the server did not answer') : '', key: k && k.ok ? k.key : { present: false, source: null }, off: !!(k && k.off) }; draw(); }).catch(() => { T.cl = { profiles: [], prefs: {}, perr: 'the server did not answer', key: { present: false, source: null } }; draw(); });
352
389
  const [w, p, s, b] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings'), pmGet('/api/settings'), pmGet('/api/briefing-premium')]);
353
390
  T.ws = w && Array.isArray(w.workspaces) ? w.workspaces : [];
354
391
  T.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {}; T.con = p && p.ok && p.settings ? { ...p.settings.connectors } : {};
@@ -364,7 +401,7 @@ async function load() {
364
401
  export function openSettings(section) {
365
402
  const el = mount();
366
403
  if (section === 'dress') { T.sec = 'adler'; T.dress = true; } else if (section && BODY[section]) { T.sec = section; T.dress = false; }
367
- if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.fresh = null; T.note = {}; T.dset = {}; }
404
+ if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.fresh = null; T.note = {}; T.dset = {}; T.cl = null; }
368
405
  el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
369
406
  draw();
370
407
  const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();
@@ -355,7 +355,8 @@ function traceChanges(changes, ctx) {
355
355
  if (b) { const w = routes(b.keys, `server.js:${n}`); if (w) return w; continue; }
356
356
  const own = fnAt(n);
357
357
  if (own && own.name !== 'handleRequest') { const w = useOf(own.name); if (w) return `${own.name} (server.js:${n}) is used by ${w}`; continue; }
358
- const mod = wiringOf(n);
358
+ const req = /^(?:const|let)\s+\w+\s*=\s*require\(\s*'\.\/(lib\/[\w.-]+)'\s*\)\s*;?\s*$/.exec(raw); // a plain top-level `const x = require('./lib/m.js')`: its uses are other lines, traced on their own
359
+ const mod = wiringOf(n) || (req ? req[1] : null);
359
360
  if (mod) { nameHits(mod).forEach((x) => picked.add(x)); if (inList.has('test.js')) picked.add('test.js'); continue; } // start-up wiring of one lib module: the suites that name it, and the server boot suite
360
361
  return `server.js:${n}, outside every route and function`;
361
362
  }
@@ -73,6 +73,8 @@ ensureSpawnHelperExecutable();
73
73
  const { checkSurface } = require('./lib/surface-contract');
74
74
  const { createSinkGuard } = require('./lib/sink.js');
75
75
  const tsSettings = require('./lib/typesafe-settings.js');
76
+ const anthropicKey = require('./lib/anthropic-key.js'); // the PM's Anthropic API key for Claude's own API runs (D101)
77
+ const grillApi = require('./lib/grill-api.js');
76
78
  const sessionOrigin = require('./lib/session-origin'); // which sessions the workspace started itself, and when they may end (workspace-auto-sessions)
77
79
  const sessionFlag = require('./lib/session-flag'); // PMOS_WORKSPACE=1 in each agent terminal (cockpit mod, M12)
78
80
  const tsClient = require('./lib/typesafe.js');
@@ -2953,7 +2955,8 @@ const grillRuns = require('./lib/grill-runs.js').create({
2953
2955
  open: deepOpenNow,
2954
2956
  headlessOff: () => headlessLib.switchedOff(process.env),
2955
2957
  env: process.env,
2956
- api: require('./lib/grill-api.js'),
2958
+ // Claude's own API runs (D101): the key saved in Settings (lib/anthropic-key.js), else ANTHROPIC_API_KEY
2959
+ api: { available: (env) => grillApi.available(env, anthropicKey.getKey(STATE, null)), run: (o) => grillApi.run({ ...o, apiKey: anthropicKey.getKey(STATE, null) }) },
2957
2960
  promptFor: (skillId) => { const h = homeWorkspace(); const t = taskById(skillId, h ? h.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
2958
2961
  spawn: (spec) => orchSpawn.spawn({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative, extraEnv: spec.env, autoDelete: undefined, onDone: spec.onDone }),
2959
2962
  stop: (s) => { if (s && s.child) stopHeadless(s); },
@@ -9531,6 +9534,19 @@ async function handleRequest(req, res) {
9531
9534
  if (!out.ok) return json(res, { ok: false, error: out.error }, req.method === 'PUT' && /look like a key/.test(out.error) ? 400 : 500);
9532
9535
  return json(res, { ok: true, key: tsSettings.status(STATE) });
9533
9536
  }
9537
+ // D101 — the Anthropic API key. Status never carries the value; only the computer that runs the workspace may change it.
9538
+ if (p === '/api/anthropic' && req.method === 'GET') return json(res, { ok: true, key: anthropicKey.status(STATE, process.env), model: grillApi.modelOf(process.env), off: !grillApi.available(process.env, 'x') });
9539
+ if (p === '/api/anthropic/key' && (req.method === 'PUT' || req.method === 'DELETE')) {
9540
+ if (!onlineChangeAllowed(req)) return json(res, { ok: false, error: 'The key can only be changed on the computer that runs the workspace' }, 403);
9541
+ let body = {};
9542
+ if (req.method === 'PUT') {
9543
+ try { body = JSON.parse((await readBody(req)) || '{}'); }
9544
+ catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
9545
+ }
9546
+ const out = req.method === 'PUT' ? anthropicKey.setKey(STATE, body.key) : anthropicKey.clearKey(STATE);
9547
+ if (!out.ok) return json(res, { ok: false, error: out.error }, req.method === 'PUT' && /does not look like/.test(out.error) ? 400 : 500);
9548
+ return json(res, { ok: true, key: anthropicKey.status(STATE, process.env) });
9549
+ }
9534
9550
  if (p === '/api/validate/repo' && (req.method === 'GET' || req.method === 'POST')) {
9535
9551
  let body = {};
9536
9552
  if (req.method === 'POST') {
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The Anthropic API key store (D101) and the key path of Claude's own API runs: saved 0600, never in a status, never inherited by a command the run starts. Fake parts only.",
3
+ "modules": [
4
+ "anthropic-key.test.js"
5
+ ],
6
+ "seconds": {
7
+ "anthropic-key.test.js": 1
8
+ }
9
+ }