@tyhld/conductor 0.12.177 → 0.12.179

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/dist/headless.js CHANGED
@@ -1332,6 +1332,21 @@ export function buildWorkerPath(currentPath, claudeBin, nodeExecPath = process.e
1332
1332
  const rest = (currentPath ?? '').split(':').filter((d) => d !== '' && !front.includes(d));
1333
1333
  return [...front, ...rest].join(':');
1334
1334
  }
1335
+ /**
1336
+ * 職人(claude -p)が使う pnpm の置き場(便 26de5225・えふさん決定 2026-11-09)。
1337
+ *
1338
+ * 【なぜ決めるか】置き場が機・現場の設定でばらばらだと、控えが二重になり、囲いの書き込みを
1339
+ * 許していない場所へ書いて止まる。甲' の雛形が書き込みを許しているのは ~/.local/share/pnpm
1340
+ * (ALLOW_WRITE_HOME)なので、その下の囲いの外の既定の値と同じ1か所に決める。
1341
+ * 【名前】★pnpm 12 は npm_config_store_dir を読まない(実測 2026-11-09・pnpm 12.6.0)。
1342
+ * pnpm_config_store_dir なら効く(置き場はその下の v11 になる)。
1343
+ * 【ハードリンク】置き場と作業場所が別のファイルシステムでも、pnpm は写しに切り替えて止まらない
1344
+ * (作り物の囲いで確かめた・便 26de5225)。★秘密には触らない(場所の名前だけ)。
1345
+ */
1346
+ export const WORKER_PNPM_STORE_ENV = 'pnpm_config_store_dir';
1347
+ export function workerPnpmStoreDir(home = os.homedir()) {
1348
+ return path.join(home, '.local', 'share', 'pnpm', 'store');
1349
+ }
1335
1350
  export function spawnClaudeProcess(cfg, cmd, sessionId, attempt, isResume,
1336
1351
  /**
1337
1352
  * resume のときに続行の指示へ足す文(例「本番操作が終わりました。前の値 → 後の値」)。
@@ -1379,6 +1394,8 @@ resumeNote) {
1379
1394
  // ★職人の PATH の先頭に、中継を動かしている node の bin と claude の bin を足す
1380
1395
  // (便 24c9b6b6・e9276b86)。決め方は buildWorkerPath の説明を見ること。
1381
1396
  env.PATH = buildWorkerPath(env.PATH, claudeBin);
1397
+ // ★職人の pnpm の置き場を1か所に決める(便 26de5225)。決め方は workerPnpmStoreDir の説明を見ること。
1398
+ env[WORKER_PNPM_STORE_ENV] = workerPnpmStoreDir();
1382
1399
  // ★テスト用: CONDUCTOR_CLAUDE_CONFIG_DIR を設定すると、claude の設定フォルダを差し替える。
1383
1400
  // 本物のログインを壊さずに認証エラーを再現できる(空のフォルダを指す → not logged in)。
1384
1401
  // 本番では設定しない(claude は既定の ~/.claude を使う)。
package/dist/selfcheck.js CHANGED
@@ -1179,6 +1179,7 @@ function managedWhere(p) {
1179
1179
  * 1 置き場の有無と持ち主・権限 2 読めるか 3 書式が正しいか 4 安全を下げる明示が無いか
1180
1180
  * 5 対象の版で確かめてあるか(+実体の手がかり) 6 必要な守りの登録が在るか
1181
1181
  * 7 実際に守りが働いたか(★この項目では確かめられない=必ず「未確認」と出す) 8 抜け道の見張り
1182
+ * 9 設定が囲いの通信を記録の proxy へ向けているなら、proxy が待っているか(★待っていなければ FAIL・便 29d95ae4)
1182
1183
  *
1183
1184
  * 【★合否の決め方】
1184
1185
  * ・3(書式)か 4(安全を下げる明示)が駄目 → FAIL(fault)。★壊れていると、そのPCで
@@ -1287,8 +1288,80 @@ function checkManaged(d, claude) {
1287
1288
  note(item, st.windowsDir.exists
1288
1289
  ? `8 見張り: ★Windows 側の置き場が在ります(${st.windowsDir.name}・持ち主 ${st.windowsDir.owner}・権限 ${st.windowsDir.mode})`
1289
1290
  : '8 見張り: Windows 側の置き場はありません');
1291
+ // 9. 設定が囲いの通信を記録の proxy へ向けているなら、proxy が待っているか(便 29d95ae4)
1292
+ checkManagedProxy(d, item, good.map((f) => f.json));
1290
1293
  return item;
1291
1294
  }
1295
+ /** 記録の proxy を起こし直す1行(★利用者の systemd の常駐を入れ直す・無い PC は setsid の形で起こす)。 */
1296
+ export const SANDBOX_PROXY_FIX_COMMAND = 'bash ~/projects/conductor/scripts/sandbox-proxy/resident.sh install';
1297
+ /** 設定が囲いの通信を向けるポート(sandbox.network の httpProxyPort・socksProxyPort・重なりは1つ)。 */
1298
+ export function managedProxyPorts(bodies) {
1299
+ const ports = new Set();
1300
+ for (const b of bodies) {
1301
+ const sb = b?.sandbox;
1302
+ const net = sb && typeof sb === 'object' ? sb.network : null;
1303
+ if (!net || typeof net !== 'object')
1304
+ continue;
1305
+ for (const k of ['httpProxyPort', 'socksProxyPort']) {
1306
+ const v = net[k];
1307
+ if (typeof v === 'number' && Number.isInteger(v) && v > 0 && v < 65536)
1308
+ ports.add(v);
1309
+ }
1310
+ }
1311
+ return [...ports].sort((a, b) => a - b);
1312
+ }
1313
+ /**
1314
+ * この機で「待っている」TCP のポート(<proc>/net/tcp・tcp6 の状態 0A=LISTEN)。読めなければ null。
1315
+ * ★中身を読むのは番号と状態の欄だけ(相手の宛先は見ない)。
1316
+ */
1317
+ export function listeningTcpPorts(procDir) {
1318
+ const out = new Set();
1319
+ let read = 0;
1320
+ for (const name of ['tcp', 'tcp6']) {
1321
+ let body;
1322
+ try {
1323
+ body = readFileSync(path.join(procDir, 'net', name), 'utf8');
1324
+ }
1325
+ catch {
1326
+ continue;
1327
+ }
1328
+ read++;
1329
+ for (const line of body.split('\n').slice(1)) {
1330
+ const f = line.trim().split(/\s+/);
1331
+ if (f.length < 4 || f[3] !== '0A')
1332
+ continue;
1333
+ const port = parseInt(f[1].split(':').pop() ?? '', 16);
1334
+ if (Number.isInteger(port))
1335
+ out.add(port);
1336
+ }
1337
+ }
1338
+ return read > 0 ? out : null;
1339
+ }
1340
+ /**
1341
+ * 9 残した設定が囲いの通信を記録の proxy(18080/18081)へ向けているのに proxy が待っていなければ、赤(FAIL)。
1342
+ * ★proxy が居ないと、その PC のすべての職人の git push・npm・gh がつながらない(便 29d95ae4)。
1343
+ * ★/proc の一覧が読めない機では「未確認」と出すだけ(合否に数えない)。
1344
+ */
1345
+ function checkManagedProxy(d, item, bodies) {
1346
+ const ports = managedProxyPorts(bodies);
1347
+ if (ports.length === 0) {
1348
+ note(item, '9 通信の記録の proxy: 設定は囲いの通信を proxy へ向けていません');
1349
+ return;
1350
+ }
1351
+ const procDir = d.procDir ?? '/proc';
1352
+ const listening = listeningTcpPorts(procDir);
1353
+ if (!listening) {
1354
+ note(item, `9 通信の記録の proxy: 未確認(${procDir}/net の一覧を読めません・設定はポート ${ports.join('・')} へ向けています)`);
1355
+ return;
1356
+ }
1357
+ const down = ports.filter((p) => !listening.has(p));
1358
+ if (down.length === 0) {
1359
+ note(item, `9 通信の記録の proxy: 設定が向けるポート ${ports.join('・')} で待っています`);
1360
+ return;
1361
+ }
1362
+ fail(item, 'human', `9 ★設定は囲いの通信を記録の proxy(ポート ${ports.join('・')})へ向けていますが、${down.join('・')} で待っている物がありません` +
1363
+ `=囲いの中の git push・npm・gh がつながりません(直し方: ${SANDBOX_PROXY_FIX_COMMAND})`, { machine: d.machine, what: 'Ubuntu で記録の proxy を利用者の常駐で起こし直す(sudo は要りません)', command: SANDBOX_PROXY_FIX_COMMAND });
1364
+ }
1292
1365
  // ─────────────────────────────────────────────────────────────────────────────
1293
1366
  // +安全を外す指定の見張り(便 728c3bcc・けいさん承諾 2026-10-09 19:09/19:18 の決定)
1294
1367
  // ─────────────────────────────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tyhld/conductor",
3
- "version": "0.12.177",
3
+ "version": "0.12.179",
4
4
  "description": "采配くん管制の見守りアプリ(conductor-agent)。各PCで常駐し、中央(devlog-tracker)へ定期的に生存報告(heartbeat)を送る常駐CLI。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,6 +18,7 @@
18
18
  ★値そのもの(許可の中身など)は出さない。項目名と理由だけを出す。
19
19
  """
20
20
  import json
21
+ import re
21
22
  import sys
22
23
 
23
24
  _MISSING = object()
@@ -52,11 +53,31 @@ def _norm_path(p):
52
53
  return t.rstrip('/') or t
53
54
 
54
55
 
56
+ #: /tmp の直下で通してよいのは、pnpm の作業の鍵の置き場の形だけ(便 26de5225・えふさん決定 2026-11-09)。
57
+ # pnpm 12 は部品を足すとき、置き場とは別の固定の場所 /tmp/pnpm-store-operation-locks-<uid>/ に
58
+ # 空の鍵のファイルを作る(置き場・TMPDIR では動かせない=便 8c7fd2ba で実測)。中身は空で秘密は入らない。
59
+ # ★/tmp は皆で使う置き場なので、/tmp そのもの・/tmp/* など・ほかの直下の名前は今までどおり落とす。
60
+ _TMP_PNPM_LOCK = re.compile(r'/tmp/pnpm-store-operation-locks-[0-9]+')
61
+
62
+
63
+ def _tmp_too_wide(p):
64
+ """/tmp そのもの・包括の形・pnpm の鍵の置き場でない直下の名前なら True。"""
65
+ t = _norm_path(p)
66
+ if t == '/tmp':
67
+ return True
68
+ if not t.startswith('/tmp/'):
69
+ return False
70
+ rest = t[len('/tmp/'):]
71
+ if '*' in rest:
72
+ return True
73
+ return '/' not in rest and not _TMP_PNPM_LOCK.fullmatch(t)
74
+
75
+
55
76
  def _allows_everything(v):
56
- """書き込みを許す場所の一覧に【全体】か【ホームのまとめて広い置き場】が入っているか。"""
77
+ """書き込みを許す場所の一覧に【全体】か【ホームのまとめて広い置き場】か【/tmp の広い形】が入っているか。"""
57
78
  if not isinstance(v, list):
58
79
  return False
59
- return any(_norm_path(p) in (_EVERYTHING | _BROAD_HOME) for p in v)
80
+ return any(_norm_path(p) in (_EVERYTHING | _BROAD_HOME) or _tmp_too_wide(p) for p in v)
60
81
 
61
82
 
62
83
  # (項目, 安全を下げる値か判定する関数, 理由)。docs/managed-settings-methodD.md の「安全を下げる明示」と同じ並び。
@@ -74,7 +95,8 @@ RULES = [
74
95
  '読み取り禁止の場所を【空で明示】する。中央の空が現場の denyRead を上書きし、'
75
96
  '秘密ファイルが読めるようになる'),
76
97
  ('sandbox.filesystem.allowWrite', lambda v: _allows_everything(v),
77
- '書き込みを許す場所に【全体】を入れる(/ や ~ など)。囲いの中からどこへでも書けるようになる'),
98
+ '書き込みを許す場所に【全体】を入れる(/ や ~ や /tmp など)。囲いの中からどこへでも書けるようになる'
99
+ '(/tmp の直下は pnpm の鍵の置き場 /tmp/pnpm-store-operation-locks-<数字> だけ通す)'),
78
100
  ('sandbox.failIfUnavailable', lambda v: v is False,
79
101
  '囲いが使えない機でも、黙って囲いなしで動かす'),
80
102
  ('sandbox.enableWeakerNestedSandbox', lambda v: v is True,