@tyhld/conductor 0.12.158 → 0.12.160
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 +40 -10
- package/dist/selfcheck.js +67 -2
- package/package.json +1 -1
package/dist/headless.js
CHANGED
|
@@ -1146,6 +1146,11 @@ function openRunLogs(commandId, attempt) {
|
|
|
1146
1146
|
// message/parent_tool_use_id/session_id/type/uuid だけ)。時刻つきの流れを出すには
|
|
1147
1147
|
// 拾った側で時刻を刻んで残すしかない。ここには秘密を隠して上限で切った物だけを書く。
|
|
1148
1148
|
const eventsLog = createWriteStream(eventsLogPath(commandId, attempt), { flags: 'a' });
|
|
1149
|
+
// ★開く・書くのは裏で後から起きる。失敗(フォルダが先に消えた・空きが無い等)を受け止めないと
|
|
1150
|
+
// 中継ごと落ちる(uncaughtException)。記録が残せないだけなので、知らせて仕事は続ける。
|
|
1151
|
+
for (const ws of [stdoutLog, stderrLog, eventsLog]) {
|
|
1152
|
+
ws.on('error', (err) => log(`WARN 実行ログを書けません: ${err.message}`));
|
|
1153
|
+
}
|
|
1149
1154
|
return { stdoutLog, stderrLog, eventsLog };
|
|
1150
1155
|
}
|
|
1151
1156
|
catch (err) {
|
|
@@ -1153,14 +1158,34 @@ function openRunLogs(commandId, attempt) {
|
|
|
1153
1158
|
return null;
|
|
1154
1159
|
}
|
|
1155
1160
|
}
|
|
1156
|
-
/**
|
|
1161
|
+
/** 実行ログを閉じ終わるのを待つ上限(ms)。書き込みが詰まっても止め方を止めない。 */
|
|
1162
|
+
const RUN_LOG_CLOSE_WAIT_MS = 2000;
|
|
1163
|
+
/**
|
|
1164
|
+
* WriteStream を安全に閉じ、閉じ終わる(開く・書く・閉じるが裏で全部済む)まで待つ。
|
|
1165
|
+
* ★end() だけでは裏の書き込みが残る=止めた後に記録ファイルへ書きに行く(便 edbfbee0)。
|
|
1166
|
+
*/
|
|
1157
1167
|
function closeLog(ws) {
|
|
1158
|
-
if (ws)
|
|
1168
|
+
if (!ws || ws.closed)
|
|
1169
|
+
return Promise.resolve();
|
|
1170
|
+
return new Promise((resolve) => {
|
|
1171
|
+
const t = setTimeout(resolve, RUN_LOG_CLOSE_WAIT_MS);
|
|
1172
|
+
t.unref();
|
|
1173
|
+
ws.once('close', () => {
|
|
1174
|
+
clearTimeout(t);
|
|
1175
|
+
resolve();
|
|
1176
|
+
});
|
|
1159
1177
|
try {
|
|
1160
1178
|
ws.end();
|
|
1161
1179
|
}
|
|
1162
|
-
catch {
|
|
1163
|
-
|
|
1180
|
+
catch {
|
|
1181
|
+
clearTimeout(t);
|
|
1182
|
+
resolve();
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
/** 便の3つの実行ログを閉じ、全部閉じ終わるまで待つ。 */
|
|
1187
|
+
async function closeJobLogs(job) {
|
|
1188
|
+
await Promise.all([closeLog(job.stdoutLog), closeLog(job.stderrLog), closeLog(job.eventsLog)]);
|
|
1164
1189
|
}
|
|
1165
1190
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
1166
1191
|
// 子プロセスの起動と停止
|
|
@@ -1336,6 +1361,8 @@ resumeNote) {
|
|
|
1336
1361
|
job.exitSignal = null;
|
|
1337
1362
|
job.finishedAt = Date.now();
|
|
1338
1363
|
job.stderrBuf += `\nspawn error: ${err.message}`;
|
|
1364
|
+
// 起動できなかったときは 'exit' が来ないので、ここで実行ログを閉じる
|
|
1365
|
+
job.logsClosed = closeJobLogs(job);
|
|
1339
1366
|
}
|
|
1340
1367
|
});
|
|
1341
1368
|
// stdin: 指示本文を書いて閉じる
|
|
@@ -1421,19 +1448,22 @@ resumeNote) {
|
|
|
1421
1448
|
job.exitSignal = signal?.toString() ?? null;
|
|
1422
1449
|
job.finishedAt = Date.now();
|
|
1423
1450
|
job.durationMs = Date.now() - job.startedAt;
|
|
1424
|
-
|
|
1425
|
-
closeLog(job.stderrLog);
|
|
1426
|
-
closeLog(job.eventsLog);
|
|
1451
|
+
job.logsClosed = closeJobLogs(job);
|
|
1427
1452
|
});
|
|
1428
1453
|
return job;
|
|
1429
1454
|
}
|
|
1430
1455
|
/**
|
|
1431
1456
|
* 子プロセスを停止する。SIGTERM → 猶予 → SIGKILL。
|
|
1432
|
-
*
|
|
1457
|
+
* プロセスが既に終わっていれば止めない(実行ログを閉じ終わるのだけ待つ)。
|
|
1433
1458
|
*/
|
|
1434
1459
|
export async function stopJob(job) {
|
|
1435
|
-
if (job.completed)
|
|
1436
|
-
|
|
1460
|
+
if (!job.completed)
|
|
1461
|
+
await killJob(job);
|
|
1462
|
+
// ★実行ログを閉じ終わってから返す=止めた後に記録ファイルへの書き込みを残さない(便 edbfbee0)。
|
|
1463
|
+
await job.logsClosed;
|
|
1464
|
+
}
|
|
1465
|
+
/** SIGTERM → 猶予 → SIGKILL で子プロセスを終わらせる。 */
|
|
1466
|
+
async function killJob(job) {
|
|
1437
1467
|
const proc = job.process;
|
|
1438
1468
|
proc.kill('SIGTERM');
|
|
1439
1469
|
// 猶予の間に終了するのを待つ
|
package/dist/selfcheck.js
CHANGED
|
@@ -137,6 +137,9 @@ export function selfcheckFingerprint(r) {
|
|
|
137
137
|
claudeVersion: r.claude.version,
|
|
138
138
|
checks: checksOf(r),
|
|
139
139
|
human: first ? first.what : null,
|
|
140
|
+
// ★アカウントの接続は合否に数えない(ok=null)ので、checks だけでは「ログインした」が指紋に出ない。
|
|
141
|
+
// 道具ごとの状態の言葉だけを足す(理由の括弧は入れない=時間切れの揺れで送り直さない・便 405bf440)。
|
|
142
|
+
accounts: accountStatesOf(r),
|
|
140
143
|
});
|
|
141
144
|
return createHash('sha256').update(body).digest('hex');
|
|
142
145
|
}
|
|
@@ -1562,6 +1565,66 @@ export function checkSiteGuard(d) {
|
|
|
1562
1565
|
note(item, 'この項目は合否に数えません(そろっていない現場は人の確認です・APPLY=1 bash scripts/update-guard.sh の最後の一覧にも出ます)');
|
|
1563
1566
|
return item;
|
|
1564
1567
|
}
|
|
1568
|
+
/**
|
|
1569
|
+
* アカウントの接続(Codex・Supabase・Vercel・便 405bf440/えふさん決定 2026-10-31)。
|
|
1570
|
+
* AI-Kana の準備ガイドは、この項目の ✓ の行だけを「確認済み」にする(ai-kana の src/lib/prep-path.ts の冒頭が行の形の正本)。
|
|
1571
|
+
* ✓ <名前> にログイン済み
|
|
1572
|
+
* ・<名前> にログインしていません
|
|
1573
|
+
* ・<道具> が入っていません
|
|
1574
|
+
* ・<名前> のログインを確かめられません(理由)
|
|
1575
|
+
* ★ログインできているかを、確かめる命令の【終了コードだけ】で見る。出力(鍵・名前・設定の中身)は読まない・行に出さない・送らない。
|
|
1576
|
+
* ★お客さまの準備の進み具合で PC の不調ではないので、合否には数えない(ok=null・✗ も人の手番も付けない)。
|
|
1577
|
+
* PC の健康・配布の止め・自動更新の判定に効かせない。
|
|
1578
|
+
* ★1つの道具は ACCOUNTS_TIMEOUT_MS で打ち切る(つながらなくても自己診断全体を遅くしない)。
|
|
1579
|
+
*/
|
|
1580
|
+
export const ACCOUNT_CHECKS = [
|
|
1581
|
+
{ name: 'Codex', bin: 'codex', args: ['login', 'status'] },
|
|
1582
|
+
{ name: 'Supabase', bin: 'supabase', args: ['projects', 'list'] },
|
|
1583
|
+
{ name: 'Vercel', bin: 'vercel', args: ['whoami'] },
|
|
1584
|
+
];
|
|
1585
|
+
export const ACCOUNTS_TIMEOUT_MS = 10_000;
|
|
1586
|
+
/** 確かめる命令の結果1つを、状態と1行にする(★出力の中身は見ない)。 */
|
|
1587
|
+
export function accountLine(c, r) {
|
|
1588
|
+
if (r.error && /ENOENT/.test(r.error))
|
|
1589
|
+
return { state: 'not_installed', line: `・${c.bin} が入っていません` };
|
|
1590
|
+
if (r.error && /ETIMEDOUT/.test(r.error))
|
|
1591
|
+
return { state: 'check_failed', line: `・${c.name} のログインを確かめられません(時間切れ)` };
|
|
1592
|
+
if (r.status === 0)
|
|
1593
|
+
return { state: 'pass', line: `✓ ${c.name} にログイン済み` };
|
|
1594
|
+
if (r.status === null)
|
|
1595
|
+
return { state: 'check_failed', line: `・${c.name} のログインを確かめられません(命令が途中で止まりました)` };
|
|
1596
|
+
return { state: 'not_logged_in', line: `・${c.name} にログインしていません` };
|
|
1597
|
+
}
|
|
1598
|
+
export function checkAccounts(d) {
|
|
1599
|
+
const item = { key: 'accounts', label: 'アカウントの接続', ok: null, detail: [] };
|
|
1600
|
+
// npm で入れた道具は、この道具を動かしている node の隣に置かれることが多い(常駐から呼ぶと PATH に無いことがある)。
|
|
1601
|
+
const npm = d.findNpm();
|
|
1602
|
+
const env = npm ? { ...d.env, PATH: `${path.dirname(npm)}:${d.env.PATH ?? ''}` } : d.env;
|
|
1603
|
+
for (const c of ACCOUNT_CHECKS) {
|
|
1604
|
+
const r = d.exec(c.bin, [...c.args], { env, timeoutMs: ACCOUNTS_TIMEOUT_MS });
|
|
1605
|
+
item.detail.push(accountLine(c, r).line);
|
|
1606
|
+
}
|
|
1607
|
+
item.detail.push('・この項目は合否に数えません(お客さまの準備の進み具合です・ログインの有無だけを見て、鍵や設定の中身は読みません)');
|
|
1608
|
+
return item;
|
|
1609
|
+
}
|
|
1610
|
+
/** 指紋に入れる、道具ごとの状態の言葉(★行の頭だけで決める・理由の括弧は入れない)。 */
|
|
1611
|
+
export function accountStatesOf(r) {
|
|
1612
|
+
const item = r.items.find((i) => i.key === 'accounts');
|
|
1613
|
+
if (!item)
|
|
1614
|
+
return null;
|
|
1615
|
+
const out = {};
|
|
1616
|
+
const has = (head) => item.detail.some((l) => l.startsWith(head));
|
|
1617
|
+
for (const c of ACCOUNT_CHECKS) {
|
|
1618
|
+
out[c.bin] = has(`✓ ${c.name} にログイン済み`)
|
|
1619
|
+
? 'pass'
|
|
1620
|
+
: has(`・${c.name} にログインしていません`)
|
|
1621
|
+
? 'not_logged_in'
|
|
1622
|
+
: has(`・${c.bin} が入っていません`)
|
|
1623
|
+
? 'not_installed'
|
|
1624
|
+
: 'check_failed';
|
|
1625
|
+
}
|
|
1626
|
+
return out;
|
|
1627
|
+
}
|
|
1565
1628
|
/** 項目ごとの合否(管制の checks)。見られなかった項目は skip。 */
|
|
1566
1629
|
export function checksOf(r) {
|
|
1567
1630
|
const out = {};
|
|
@@ -1722,6 +1785,8 @@ export async function runSelfcheck(d, trigger, opts = {}) {
|
|
|
1722
1785
|
const units = checkUnits(d);
|
|
1723
1786
|
// +現場の守りの置き場(★読むだけ・合否に数えない・便 52ae1d29)
|
|
1724
1787
|
const siteGuard = checkSiteGuard(d);
|
|
1788
|
+
// +アカウントの接続(★ログインを終了コードだけで読む・合否に数えない・便 405bf440)
|
|
1789
|
+
const accounts = checkAccounts(d);
|
|
1725
1790
|
if (!probe) {
|
|
1726
1791
|
// ★Claude を使わない確かめだけ(お客さまの機の毎日の定期・測り直し・常駐の定義だけを入れ替えた回)。
|
|
1727
1792
|
// 小さな試験・MCP の確かめ・囲いの中からの書き込み・内側の通信・候補の版は、Claude を呼ぶ回にだけ見る。
|
|
@@ -1729,7 +1794,7 @@ export async function runSelfcheck(d, trigger, opts = {}) {
|
|
|
1729
1794
|
note(headless, 'お客さまの機の定期の確かめでは Claude を呼びません(版を入れ替えた直後の1回だけ流します・使用量の上限)');
|
|
1730
1795
|
note(sandbox, '囲いの中からの書き込みは、Claude を呼ぶ回(版を入れ替えた直後)にだけ確かめます');
|
|
1731
1796
|
note(network, '囲いの内側からの通信は、Claude を呼ぶ回(版を入れ替えた直後)にだけ確かめます');
|
|
1732
|
-
const items = [conductor, claude.item, central, sandbox, network, headless, guard, managed, unsafe, units, siteGuard];
|
|
1797
|
+
const items = [conductor, claude.item, central, sandbox, network, headless, guard, managed, unsafe, units, siteGuard, accounts];
|
|
1733
1798
|
return {
|
|
1734
1799
|
schema: 'conductor-selfcheck/1',
|
|
1735
1800
|
machine: d.machine,
|
|
@@ -1832,7 +1897,7 @@ export async function runSelfcheck(d, trigger, opts = {}) {
|
|
|
1832
1897
|
else
|
|
1833
1898
|
fail(network, 'fault', `囲いの内側から ${u} → ${c}`);
|
|
1834
1899
|
}
|
|
1835
|
-
const items = [conductor, claude.item, central, sandbox, network, headless, guard, managed, unsafe, units, siteGuard];
|
|
1900
|
+
const items = [conductor, claude.item, central, sandbox, network, headless, guard, managed, unsafe, units, siteGuard, accounts];
|
|
1836
1901
|
const humanActions = items.flatMap((i) => i.human ?? []);
|
|
1837
1902
|
const candidates = pickCandidates({ conductor: version, claude: claude.version }, { conductor: net.latest, claude: await fetchClaudeStable(d.fetchImpl) });
|
|
1838
1903
|
return {
|