aiterm-mcp 0.70.22 → 0.70.24

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/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.24] - 2026-11-11
11
+
12
+ - Closing a seat now also ends its idle-clock worker. `pty_close`, killing all sessions, and a fresh launch under the same name removed the clock record but left the waiting `sh`/`sleep` (PowerShell on Windows) running until its wake time, so a deleted member's `agent-idle-cli --session <name>` stayed visible on the host. Before the record is removed, the worker is ended when its PID and start time still match the record: on Linux and macOS its own process group (the shell, its sleep, and a checker that is just waking), on Windows its PowerShell. A process never ends its own clock. If the worker cannot be ended, it still exits at wake on the missing token, as before. Live seats are unchanged.
13
+
14
+ ## [0.70.23] - 2026-11-11
15
+
16
+ - A Claude seat that is signed out now reports failure category `authentication`. The real signed-out API error record of Claude Code 2.1.310/2.1.319 carries `error: "authentication_failed"` and no `apiErrorStatus`; that record, a 401, or (for a record with neither) the CLI's login line is now `authentication`, and the parent-delivery record accepts the value.
17
+ - Resuming a hibernated Claude seat through `agent_launch` with `env_vars` no longer conflicts on its login or config directory. `CLAUDE_CODE_OAUTH_TOKEN` is the seat's login, not a setting: it is left out of the env-name comparison, the launch's value (private env line, then process env) goes into the resumed seat, and a login that is not named or has no value is unset. `CLAUDE_CONFIG_DIR`, which Aiterm adds to every Claude recipe, is left out of the comparison too; before, every `env_vars` resume conflicted on it. On Linux and macOS the resume line reads the values from the same 0600 launch-env file a fresh launch uses instead of typing them into the pane, and the login stays out of the multiplexer environment and `pty_list`.
18
+
10
19
  ## [0.70.22] - 2026-11-11
11
20
 
12
21
  - A Claude launch no longer refuses on an authentication pre-check. `claude auth status` read the computer's own login, while a seat may run on a credential passed only in its private environment (for example `CLAUDE_CODE_OAUTH_TOKEN`); with the computer's own login expired, seats that would run were refused as `AGENT_AUTH_REQUIRED`. A logged-out Claude now stops at its own login screen (`vendor_onboarding_required`, initial prompt not sent). Terminals on older versions still answer the old codes, and callers keep reading them.
@@ -3292,7 +3301,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3292
3301
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3293
3302
  provenance.
3294
3303
 
3295
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.22...HEAD
3304
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.24...HEAD
3305
+ [0.70.24]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.23...v0.70.24
3306
+ [0.70.23]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.22...v0.70.23
3296
3307
  [0.70.22]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.21...v0.70.22
3297
3308
  [0.70.21]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.20...v0.70.21
3298
3309
  [0.70.20]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.19...v0.70.20
package/README.ja.md CHANGED
@@ -215,7 +215,7 @@ runtime-error store は canonical dotagents config の `collection.enabled: true
215
215
  場合だけ収集し、既定OFF、network送信は行いません。tag起点CIのnpm provenance(OIDC Trusted
216
216
  Publishing)で公開し、GitHub Release が Official MCP Registry を再登録します。
217
217
 
218
- **状態:** 開発継続中 · 現行公開版 **v0.70.22** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.24** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
219
219
 
220
220
  ### 更新と巻き戻し
221
221
 
package/README.md CHANGED
@@ -227,7 +227,7 @@ collection is off by default and performs no network I/O. It ships via
227
227
  tag-triggered CI with npm provenance (OIDC Trusted Publishing); the GitHub
228
228
  Release re-registers the Official MCP Registry entry.
229
229
 
230
- **Status:** actively maintained · current public release **v0.70.22** · runs on Linux · WSL2 · macOS · native Windows (tmux on POSIX, the tmux-CLI-compatible [psmux](https://github.com/psmux/psmux) on native Windows — no WSL required) · MIT · see the [CHANGELOG](CHANGELOG.md).
230
+ **Status:** actively maintained · current public release **v0.70.24** · runs on Linux · WSL2 · macOS · native Windows (tmux on POSIX, the tmux-CLI-compatible [psmux](https://github.com/psmux/psmux) on native Windows — no WSL required) · MIT · see the [CHANGELOG](CHANGELOG.md).
231
231
 
232
232
  ### Update and rollback
233
233
 
@@ -57,6 +57,16 @@ export function isAgentIdleClockOwner(clock) {
57
57
  return [process.pid, process.ppid].includes(clock.owner.pid) && readProcessIdentities([clock.owner.pid])
58
58
  .some(row => row.started_identity === clock.owner.started_identity);
59
59
  }
60
+ /** A closed seat's sleep worker ends with it; the caller's own clock (its checker or that checker's sh) is left alone. */
61
+ export function endAgentIdleClock(clock) {
62
+ const { pid, started_identity } = clock.owner;
63
+ if ([process.pid, process.ppid].includes(pid)
64
+ || !readProcessIdentities([pid]).some(row => row.started_identity === started_identity))
65
+ return;
66
+ // POSIX workers are spawned detached (setsid), so the owner leads a group holding its sleep and any waking checker.
67
+ const windows = process.platform === "win32";
68
+ signalRuntimeProcess({ pid, started_identity, process_group_id: pid, argv_digest: "" }, windows ? "SIGKILL" : "SIGTERM", !windows);
69
+ }
60
70
  /** Called under the existing seat send lock; the record is not an independent admission. */
61
71
  export async function armAgentIdleClock(meta, anchor, wakeAt, replaceToken) {
62
72
  const previous = readAgentIdleClock(meta);
package/dist/core.js CHANGED
@@ -38,7 +38,7 @@ import { withCodexGoal } from "./harnesses/codex-goal.js";
38
38
  import { configureWithPausedGoal } from "./configure-goal.js";
39
39
  import { initializeAgentActivity, recordAgentInput, recordAgentTurnEnd, readAgentActivity } from "./agent-activity.js";
40
40
  import { checkIdleSeat, decideIdleSeat, idleMinutes } from "./agent-idle.js";
41
- import { AGENT_IDLE_ENABLED, armAgentIdleClock, idleClockDeadline, isAgentIdleClockOwner, requestAgentIdleClock, requestAgentIdleClocks } from "./agent-idle-clock.js";
41
+ import { AGENT_IDLE_ENABLED, armAgentIdleClock, endAgentIdleClock, idleClockDeadline, isAgentIdleClockOwner, requestAgentIdleClock, requestAgentIdleClocks } from "./agent-idle-clock.js";
42
42
  import { stopProcessTree } from "./process-tree-stop.js";
43
43
  import { writeAgentResumeRecoveryOrigin, confirmedAgentResumeRecoveryOrigin, readAgentResumeResolution, writeAgentResumeResolution, agentResumeRecordDigest, captureAgentResumeTemplate, readAgentResumeTemplate, writeAgentResumeTemplate, finishAgentResumeConfiguration, refreshAgentResumeRecipe, readAgentIdleClock, retireAgentIdleClock, readAgentResumeRecipe, writeAgentResumeRecipe, agentResumeRecipeDigest, readAgentLifecycle, writeAgentLifecycle, cancelAgentStopping, readAgentResumeAttempt, writeAgentResumeAttempt, readAgentResumeNative, writeAgentResumeNative } from "./agent-lifecycle.js";
44
44
  import { createCodexGoalObjective, editCodexGoalObjective, submitCodexGoalCommand } from "./harnesses/codex-goal-editor.js";
@@ -369,6 +369,13 @@ function cleanupAgentState(name) {
369
369
  if (!f.startsWith(prefix))
370
370
  continue;
371
371
  const p = path.join(dir, f);
372
+ if (f.endsWith(".idle-clock.json"))
373
+ try {
374
+ const clock = readAgentIdleClock({ aiterm_session: name, launch_id: f.slice(prefix.length, -".idle-clock.json".length) });
375
+ if (clock)
376
+ endAgentIdleClock(clock);
377
+ }
378
+ catch { /* an unended worker still exits at wake: its token is gone with the record below */ }
372
379
  try {
373
380
  if (f.endsWith(".agent.json") ||
374
381
  f.endsWith(".active-launch.json") ||
@@ -2213,7 +2220,7 @@ export function listSessionsResult(envKeys = [], runTmux = tmux) {
2213
2220
  const recipe = readAgentResumeRecipe(meta);
2214
2221
  if (recipe?.kind === meta.kind && recipe.vendor_session_id === meta.vendor_session_id)
2215
2222
  for (const key of envKeys)
2216
- environment[key] = recipe.environment[key] ?? null;
2223
+ environment[key] = key === CLAUDE_LOGIN_ENV ? null : recipe.environment[key] ?? null;
2217
2224
  if (state === "hibernated") {
2218
2225
  try {
2219
2226
  confirmedAgentResumeRecipe(meta, readAgentLifecycle(meta));
@@ -6864,7 +6871,9 @@ function adoptVanishedAgentNative(meta) {
6864
6871
  "文字列は送信していません。agent_launchで起動し直してください。", 2);
6865
6872
  }
6866
6873
  }
6867
- async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
6874
+ // Claude's login, not a recipe setting (lifecycle-state-ownership 4b): a resume through agent_launch may replace it.
6875
+ const CLAUDE_LOGIN_ENV = "CLAUDE_CODE_OAUTH_TOKEN";
6876
+ async function resumeAgentInLock(name, readyTimeout, claudeRoot, claudeLogin) {
6868
6877
  const previous = loadAgentMetadata(name);
6869
6878
  readyTimeout ??= previous.kind === "codex" ? AGENT_TUI_FIRST_DRAW_TIMEOUT_MS : AGENT_TUI_READY_TIMEOUT_MS;
6870
6879
  let lifecycle = readAgentLifecycle(previous);
@@ -6915,8 +6924,11 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
6915
6924
  assertExecutionResumeSupported();
6916
6925
  const confirmed = confirmedAgentResumeRecipe(previous, lifecycle);
6917
6926
  // Same vendor session under another Claude root; the caller proved the transcript is there.
6918
- const recipe = claudeRoot && confirmed.kind === "claude" ? { ...confirmed, configuration_root: claudeRoot.root,
6927
+ const rooted = claudeRoot && confirmed.kind === "claude" ? { ...confirmed, configuration_root: claudeRoot.root,
6919
6928
  environment: { ...confirmed.environment, CLAUDE_CONFIG_DIR: claudeRoot.selector } } : confirmed;
6929
+ // null = unset in the seat: it resumes on the root's own login.
6930
+ const recipe = claudeLogin && rooted.kind === "claude"
6931
+ ? { ...rooted, environment: { ...rooted.environment, [CLAUDE_LOGIN_ENV]: claudeLogin.value } } : rooted;
6920
6932
  if (sessionExists(name))
6921
6933
  throw uncertain();
6922
6934
  const controlEnv = { ...process.env };
@@ -7010,6 +7022,9 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
7010
7022
  const environment = [...Object.entries(recipe.environment),
7011
7023
  ...(next.kind === "codex" ? [["CODEX_HOME", recipe.configuration_root]] : []), ...agentEnvEntries(next, name)];
7012
7024
  for (const [key, value] of environment) {
7025
+ // The Claude login never goes on a multiplexer argv or into pty_list; the launch reads it from the 0600 file.
7026
+ if (value !== null && key === CLAUDE_LOGIN_ENV)
7027
+ continue;
7013
7028
  const stored = value === null ? tmux("set-environment", isWin ? "-u" : "-r", "-t", name, key) : tmux("set-environment", "-t", name, key, value);
7014
7029
  if (stored.code !== 0)
7015
7030
  throw uncertain();
@@ -7023,8 +7038,9 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
7023
7038
  const forkBan = next.fork_of?.write_ban;
7024
7039
  const winArgv = () => (cli => forkBan ? windowsWriteBanArgv(forkBan, cli) : cli)(windowsAgentArgv(cliArgv, () => resolveWinPaneShell("bash")));
7025
7040
  const full = isWin ? windowsLaunchTyped(name, next.launch_id, windowsAgentLaunchLine(recipe.cwd, environment, winArgv(), { file: agentMetadataPath(name, next.launch_id) + ".launch-exited", launch_id: next.launch_id }))
7026
- : `cd ${shq(recipe.cwd)} && /usr/bin/env ${environment.filter(([, value]) => value === null).map(([key]) => `-u ${shq(key)}`).join(" ")} `
7027
- + `${environment.filter(([, value]) => value !== null).map(([key, value]) => shq(`${key}=${value}`)).join(" ")} ${argv.map(shq).join(" ")}`;
7041
+ // Values only by the 0600 launch-env file, as in a fresh launch: typed into the pane they stayed on its screen and log.
7042
+ : `cd ${shq(recipe.cwd)} && ${launchEnvSource(name, environment.filter((entry) => entry[1] !== null))}`
7043
+ + `/usr/bin/env ${environment.filter(([, value]) => value === null).map(([key]) => `-u ${shq(key)}`).join(" ")} ${argv.map(shq).join(" ")}`;
7028
7044
  agentLaunchLines.set(name, atomicShellMultiline(full, shell));
7029
7045
  send(name, full, { enter: true, mark: false, force: true, rtk: false, raw: true, launchShell: shell, preserveAgentOperation: true });
7030
7046
  phase = "generation_publish";
@@ -7661,6 +7677,11 @@ function agentEnvPrefix(meta, sid, envVars = []) {
7661
7677
  }
7662
7678
  /** Inherited values are written to a 0600 file the launch line sources and deletes, so the typed
7663
7679
  * line and the pane log carry only its path (remote-terminal.md R7). Identity names stay inline. */
7680
+ /** The env names a resume compares. Claude: the login is not a setting (lifecycle-state-ownership 4b), and every Claude
7681
+ * recipe carries CLAUDE_CONFIG_DIR, which Aiterm adds from the root (configuration_root decides it), not the caller. */
7682
+ function resumeEnvNames(kind, names) {
7683
+ return [...new Set(names)].filter(name => kind !== "claude" || (name !== CLAUDE_LOGIN_ENV && name !== "CLAUDE_CONFIG_DIR")).sort();
7684
+ }
7664
7685
  function launchEnvSource(sid, entries) {
7665
7686
  if (entries.length === 0)
7666
7687
  return "";
@@ -8227,7 +8248,7 @@ export async function openAgentWithInitialPrompt(kind, opts = {}) {
8227
8248
  || (opts.fast != null && opts.fast !== recipe.fast)
8228
8249
  || (opts.cwd != null && path.resolve(opts.cwd) !== recipe.cwd)
8229
8250
  || (opts.write_scope !== undefined && opts.write_scope !== previous.write_scope)
8230
- || (opts.env_vars !== undefined && !isDeepStrictEqual([...new Set(opts.env_vars)].sort(), Object.keys(recipe.environment).sort())))
8251
+ || (opts.env_vars !== undefined && !isDeepStrictEqual(resumeEnvNames(kind, opts.env_vars), resumeEnvNames(kind, Object.keys(recipe.environment)))))
8231
8252
  throw opts.require_existing_resume ? new AgentResumeUnavailableError(name) : new AitermError("AGENT_RESUME_CONFLICT: 同名の休止席は保存したharness・設定・project・明示envで再開します。変更は再開後に行ってください。", 2);
8232
8253
  // The only setting a resume may change: the Claude root, when it holds this conversation's transcript.
8233
8254
  const rootChange = claudeRoot && (claudeRoot.root !== recipe.configuration_root
@@ -8239,7 +8260,9 @@ export async function openAgentWithInitialPrompt(kind, opts = {}) {
8239
8260
  cwd: opts.cwd ?? null, agentDone: true }));
8240
8261
  if (preparedLifecycle)
8241
8262
  commitWorkingAgentResume(previous, preparedLifecycle);
8242
- const resumed = await resumeAgentInLock(name, opts.ready_timeout ?? undefined, rootChange);
8263
+ const claudeLogin = kind === "claude" && opts.env_vars !== undefined
8264
+ ? { value: opts.env_vars.includes(CLAUDE_LOGIN_ENV) ? launchEnvValue(CLAUDE_LOGIN_ENV) ?? null : null } : undefined;
8265
+ const resumed = await resumeAgentInLock(name, opts.ready_timeout ?? undefined, rootChange, claudeLogin);
8243
8266
  return withAgentResumeTarget(resumed, async () => {
8244
8267
  const hint = `${agentLabel(kind)} を保存した同じ会話へ再開した。\n${attachHint(name)}`;
8245
8268
  const fastState = { fast: resumed.fast === true, fast_error: null };
@@ -737,6 +737,10 @@ export function claudeApiErrorFromLine(line) {
737
737
  export function claudeFailureCategory(error) {
738
738
  if (error.status === 429 || error.kind === "rate_limit" || /^You've (?:reached your [^.\r\n]{1,80} limit\.|hit your (?:[a-z0-9-]+ ){0,3}limit\b)/i.test(error.text))
739
739
  return "rate_limited";
740
+ // The real record (2.1.310, 2.1.319): error "authentication_failed", no apiErrorStatus, "Login expired · Please run /login".
741
+ if (error.kind === "authentication_failed" || error.status === 401
742
+ || (error.kind === null && error.status === null && /Please run \/login|OAuth token (?:has been )?revoked|Invalid API key/i.test(error.text)))
743
+ return "authentication";
740
744
  if (error.status === 529)
741
745
  return "capacity";
742
746
  return error.status !== null && error.status >= 500 ? "transient" : "other";
@@ -10,7 +10,7 @@ import { executionRequestSchema } from "./execution-contract.js";
10
10
  import { parentSourceSchema } from "./execution-parent-source.js";
11
11
  import { executionActorSchema } from "./execution-inventory.js";
12
12
  export const failureObservationSchema = z.object({
13
- category: z.enum(["capacity", "rate_limited", "transient", "other"]),
13
+ category: z.enum(["capacity", "rate_limited", "transient", "authentication", "other"]),
14
14
  execution: z.enum(["not_started", "started", "unknown"]),
15
15
  boundary: z.object({ event_cursor: z.number().int().nonnegative(), operation_id: z.string().nullable(), turn_id: z.string().nullable(),
16
16
  input_id: z.string().regex(/^[a-f0-9]{32}$/).optional() }).strict().nullable(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.22",
3
+ "version": "0.70.24",
4
4
  "mcpName": "io.github.kitepon/aiterm-mcp",
5
5
  "description": "Persistent terminal MCP with one harness-based launcher for Claude Code, Codex CLI, Grok CLI, Cursor Agent CLI, and Antigravity CLI, plus durable PTYs for SSH, containers, and REPLs.",
6
6
  "keywords": [