aiterm-mcp 0.70.42 → 0.70.43
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 +11 -1
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/agent-idle.js +3 -3
- package/dist/core.js +7 -2
- package/dist/index.js +13 -11
- package/dist/seat-turns-worker.js +69 -0
- package/package.json +1 -1
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.43] - 2026-11-13
|
|
11
|
+
|
|
12
|
+
- A kept (hibernated) seat can be closed, sent to, resumed or deleted on a fresh container before any launch: the send locks create the socket directory (`claude-tmux-sockets`) when it is missing, as a launch does. Before, the first `pty_close` / `pty_send` failed with `ENOENT ... <name>.agent-send.lock` until some other seat had been launched (a46 lab, 2026-11-13).
|
|
13
|
+
|
|
14
|
+
- `pty_list` with the seat-turns caller marker no longer stops the server: `readSeatTurns` runs on one persistent worker thread per server (created on the first marked call, unref'd, same environment), with unchanged results (Kiro a37/a44, 2026-11-13: on production 82 rows held the whole server for 2.4 s every 5 s poll, so BellTeam's goal list took 1.6-4.9 s). A lost worker answers with the synchronous read and the next call starts a new one.
|
|
15
|
+
- `pty_close {hibernate:true}` no longer needs the on-screen settings check: an explicit hibernate resumes with the saved settings (launch model/effort/fast; a model changed inside the seat is not kept), as the rate-limited case already did. Before, every Claude seat whose recipe names a model alias (`opus`, as BellTeam launches) failed with `AGENT_HIBERNATE_UNAVAILABLE: native_configuration_unconfirmed` (t29, Centi's lab 2026-11-13). The idle clock keeps the check.
|
|
16
|
+
- `pty_observe` on a hibernated seat says `reason: "native_vanished"` when the hibernation is a restart adoption (its native session vanished, e.g. a container replacement, and a send or launch adopted it), and `idle_timeout` only for the idle clock and an explicit hibernate.
|
|
17
|
+
- `AGENT_RESUME_SECRETS_REQUIRED` / `AGENT_RESUME_SECRET_MISSING` refusals carry their payload in `_meta["aiterm/resume_secrets"]` (`aiterm.agent-resume-secrets.v1`) plus `_meta["aiterm/error_code"]`, no longer in `structuredContent`. Likewise `aiterm.agent-resume-error.v1` moves to `_meta["aiterm/resume_error"]` and `aiterm.agent-send-error.v1` to `_meta["aiterm/send_error"]`, each with `aiterm/error_code` taken from the payload's code: an `isError` result never carries `structuredContent` outside the tool's declared `outputSchema` (`agent_configure`'s declared error variant stays). An MCP SDK client that has listed the tools validates `structuredContent` against the tool's success schema even on `isError`, so a `pty_send` to a hibernated seat whose recipe names a secret (every BellTeam Claude seat after a body swap) came back as `-32602 Structured content does not match the tool's output schema` with no code (Kiro, production 2026-11-13).
|
|
18
|
+
|
|
10
19
|
## [0.70.42] - 2026-11-13
|
|
11
20
|
|
|
12
21
|
- `pty_list` `aiterm/seat_turns` rows carry `own_work` when the caller sends `_meta["aiterm/own_work_exclusions"]` (a41; Kiro, Owner-approved design 2026-11-13): `{processes, excluded, child_results, exclusions_digest, oldest}` beside `turn`. `processes` are the processes the seat's CLI started after startup and still runs (the same set as `post_startup_process_count`), minus those a process entry of the caller's list names for this seat (exe + leading args, with the match's descendants and post-startup ancestors); `oldest` is the oldest one's descriptor and start time. Descriptors are built where the process runs and never carry raw argv: program basename, first two non-flag arguments as basenames, and any token over 40 characters or containing `=`, `://` or `@` becomes `…` (on macOS arguments are split on whitespace). One process-table read per call; terminals compute their own rows inside the relayed read.
|
|
@@ -3388,7 +3397,8 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
3388
3397
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
3389
3398
|
provenance.
|
|
3390
3399
|
|
|
3391
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.
|
|
3400
|
+
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.43...HEAD
|
|
3401
|
+
[0.70.43]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.42...v0.70.43
|
|
3392
3402
|
[0.70.42]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.41...v0.70.42
|
|
3393
3403
|
[0.70.41]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.40...v0.70.41
|
|
3394
3404
|
[0.70.40]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.39...v0.70.40
|
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.
|
|
218
|
+
**状態:** 開発継続中 · 現行公開版 **v0.70.43** · 動作対象は 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.
|
|
230
|
+
**Status:** actively maintained · current public release **v0.70.43** · 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
|
|
package/dist/agent-idle.js
CHANGED
|
@@ -7,7 +7,7 @@ export function idleMinutes(value = process.env.AITERM_IDLE_MINUTES) {
|
|
|
7
7
|
return minutes;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* `immediate` is an explicit hibernate request: no deadline and no
|
|
10
|
+
* `immediate` is an explicit hibernate request: no deadline, no attachment refusal and no screen settings check. A Claude turn that ended on a
|
|
11
11
|
* rate limit (no Stop event; the CLI then waits in its limit footer or menu) counts as ended at that error.
|
|
12
12
|
*/
|
|
13
13
|
export function decideIdleSeat(seat, now, minutes = 30, expectedAnchor, immediate = false) {
|
|
@@ -44,8 +44,8 @@ export function decideIdleSeat(seat, now, minutes = 30, expectedAnchor, immediat
|
|
|
44
44
|
return result;
|
|
45
45
|
if (expectedAnchor !== undefined && expectedAnchor !== anchor)
|
|
46
46
|
return { ...result, reason: "superseded_timer", anchor, due_at: due };
|
|
47
|
-
//
|
|
48
|
-
if (now >= due && !
|
|
47
|
+
// An explicit hibernate resumes with the saved recipe (no screen settings check; a model changed inside the seat is not kept).
|
|
48
|
+
if (now >= due && !immediate && !seat.native_configuration_confirmed)
|
|
49
49
|
return { ...result, reason: "native_configuration_unconfirmed", anchor, due_at: due };
|
|
50
50
|
return { ...result, outcome: now < due ? "not_due" : "ready", reason: now < due ? "before_deadline" : "idle_timeout", anchor, due_at: due };
|
|
51
51
|
}
|
package/dist/core.js
CHANGED
|
@@ -1882,8 +1882,9 @@ export function observeSession(name, cursor) {
|
|
|
1882
1882
|
result.reason = "resume_native_conflict";
|
|
1883
1883
|
return result;
|
|
1884
1884
|
}
|
|
1885
|
+
const lifecycle = readAgentLifecycle(meta);
|
|
1885
1886
|
try {
|
|
1886
|
-
confirmedAgentResumeRecipe(meta,
|
|
1887
|
+
confirmedAgentResumeRecipe(meta, lifecycle);
|
|
1887
1888
|
}
|
|
1888
1889
|
catch {
|
|
1889
1890
|
result.reason = "resume_unconfirmed";
|
|
@@ -1893,8 +1894,9 @@ export function observeSession(name, cursor) {
|
|
|
1893
1894
|
if (!isDeepStrictEqual(loadAgentMetadata(name), meta) || agentDormantState(meta) !== "hibernated"
|
|
1894
1895
|
|| nativeSessionExists(name))
|
|
1895
1896
|
return result;
|
|
1897
|
+
// A seat whose native vanished (container replaced) and was adopted at send/launch is not an idle seat (Kiro, 2026-11-13).
|
|
1896
1898
|
result.state = "hibernated";
|
|
1897
|
-
result.reason = "idle_timeout";
|
|
1899
|
+
result.reason = "origin" in lifecycle && lifecycle.origin === "restart" ? "native_vanished" : "idle_timeout";
|
|
1898
1900
|
result.pane_alive = false;
|
|
1899
1901
|
result.harness_alive = false;
|
|
1900
1902
|
result.pending_child_deliveries = 0;
|
|
@@ -3400,6 +3402,7 @@ function liveSendLocks(name) {
|
|
|
3400
3402
|
}
|
|
3401
3403
|
function acquireSessionSendFileLock(name) {
|
|
3402
3404
|
const p = sendLockPath(name);
|
|
3405
|
+
fs.mkdirSync(SOCKDIR, { recursive: true });
|
|
3403
3406
|
const token = randomBytes(16).toString("hex");
|
|
3404
3407
|
const nofollow = fs.constants.O_NOFOLLOW ?? 0;
|
|
3405
3408
|
const deadline = Date.now() + SESSION_SEND_LOCK_WAIT_MS;
|
|
@@ -3479,6 +3482,8 @@ export function __testSetAgentSendLockWaitMs(value) {
|
|
|
3479
3482
|
function tryCreateOwnedLock(p) {
|
|
3480
3483
|
const nofollow = fs.constants.O_NOFOLLOW ?? 0;
|
|
3481
3484
|
let fd;
|
|
3485
|
+
// A fresh container has no SOCKDIR until the first launch; close/send/resume/delete of a kept seat lock before that (a46 lab).
|
|
3486
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
3482
3487
|
try {
|
|
3483
3488
|
fd = fs.openSync(p, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY | nofollow, 0o600);
|
|
3484
3489
|
}
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,8 @@ import { AitermError, AgentResumeUnavailableError, AgentResumeError, AgentResume
|
|
|
20
20
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
21
21
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
22
22
|
import { readPrivateEnvLine, setPrivateEnv, privateEnvValue } from "./private-env.js";
|
|
23
|
-
import { withTerminalLaunchAction, withErrorCode, launchNotStartedMeta } from "./terminal-launch-error.js";
|
|
23
|
+
import { withTerminalLaunchAction, withErrorCode, launchNotStartedMeta, ERROR_CODE_META } from "./terminal-launch-error.js";
|
|
24
|
+
import { readSeatTurnsOffLoop } from "./seat-turns-worker.js";
|
|
24
25
|
import { codexMcpOverrides } from "./harnesses/codex.js";
|
|
25
26
|
import { CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
26
27
|
import { z } from "zod";
|
|
@@ -241,17 +242,18 @@ export function createAitermServer(options = {}) {
|
|
|
241
242
|
if (e instanceof AgentResumeUnavailableError)
|
|
242
243
|
return { content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
|
|
243
244
|
_meta: { "aiterm/resume_unavailable": { ...e.resumeUnavailable } } };
|
|
245
|
+
// Typed failures outside a tool's declared outputSchema go in _meta, never structuredContent: a client that listed the
|
|
246
|
+
// tools validates structuredContent against the success outputSchema even on isError -> -32602, code lost (Kiro, 2026-11-13).
|
|
247
|
+
const typed = (key, payload) => ({ content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
|
|
248
|
+
_meta: { [key]: payload, [ERROR_CODE_META]: { schema: "aiterm.error-code.v1", code: payload.code } } });
|
|
244
249
|
if (e instanceof AgentResumeSecretsError)
|
|
245
|
-
return
|
|
246
|
-
structuredContent: { ...e.resumeSecrets } };
|
|
250
|
+
return typed("aiterm/resume_secrets", { ...e.resumeSecrets });
|
|
247
251
|
if (e instanceof AgentResumeError)
|
|
248
|
-
return
|
|
249
|
-
structuredContent: { ...e.resumeFailure } };
|
|
252
|
+
return typed("aiterm/resume_error", { ...e.resumeFailure });
|
|
250
253
|
const sendFailure = e instanceof AitermError ? e.sendFailure : undefined;
|
|
251
254
|
if (sendFailure)
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
? core.agentWaitProcess(sendFailure.session_id, sendFailure.event_cursor, { launchId: sendFailure.launch_id }, sendFailure.steer_id) : null } };
|
|
255
|
+
return typed("aiterm/send_error", { ...sendFailure, wait_process: sendFailure.event_cursor !== null && sendFailure.steer_id
|
|
256
|
+
? core.agentWaitProcess(sendFailure.session_id, sendFailure.event_cursor, { launchId: sendFailure.launch_id }, sendFailure.steer_id) : null });
|
|
255
257
|
const configurationFailure = e instanceof Error ? e.configurationFailure : undefined;
|
|
256
258
|
if (configurationFailure)
|
|
257
259
|
return {
|
|
@@ -798,7 +800,7 @@ export function createAitermServer(options = {}) {
|
|
|
798
800
|
description: "セッションを閉じ、ログ/読取位置を破棄する。同じsession_idへの再試行は安全で、" +
|
|
799
801
|
"closed/already_closedのstructured receiptを返す。" +
|
|
800
802
|
"hibernate:trueはClaude・Codexのagent席を今すぐ休止し(idle時計と同じ手順)、会話と再開情報を残してhibernatedを返す。" +
|
|
801
|
-
"次のagent_launch(session_name
|
|
803
|
+
"次のagent_launch(session_name)が同じ会話へ、保存した設定(起動時のmodel等。席の中で替えた物は持ち越さない)で再開する。turn・子process・子への配送が動いている間はAGENT_BUSYで断る(終わってから呼び直す)。" +
|
|
802
804
|
"Claudeの席が利用上限でturnを終えている時(最後の入力の後の会話記録がrate_limited)は、上限の待ち画面のままでも休止できる。" +
|
|
803
805
|
"他の理由で休止できない時はAGENT_HIBERNATE_UNAVAILABLE、席は触らない。",
|
|
804
806
|
inputSchema: {
|
|
@@ -895,9 +897,9 @@ export function createAitermServer(options = {}) {
|
|
|
895
897
|
loopDeadline(4_000, { seats: [], unread: bound }),
|
|
896
898
|
]);
|
|
897
899
|
}));
|
|
898
|
-
// callRemoteTool spawns its ssh only after an await: let the relays start before
|
|
900
|
+
// callRemoteTool spawns its ssh only after an await: let the relays start before the local read.
|
|
899
901
|
await new Promise(resolve => setImmediate(resolve));
|
|
900
|
-
const local =
|
|
902
|
+
const local = await readSeatTurnsOffLoop(sessions.filter(session => session.harness !== null).map(session => session.session_id), core.readSeatTurns);
|
|
901
903
|
// a41: own_work only for a caller that sends its exclusion list (observation-results.md); terminals compute their own rows.
|
|
902
904
|
const ownWork = requestMeta && typeof requestMeta === "object" ? requestMeta["aiterm/own_work_exclusions"] : undefined;
|
|
903
905
|
if (ownWork !== undefined) {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// core.readSeatTurns on one persistent worker thread, so the server keeps answering other calls meanwhile
|
|
2
|
+
// (observation-results.md readSeatTurns, 0.70.43; before, ~2.4 s of production seats blocked the whole server per poll).
|
|
3
|
+
import { Worker, isMainThread, parentPort, workerData, SHARE_ENV } from "node:worker_threads";
|
|
4
|
+
const ROLE = "aiterm-seat-turns";
|
|
5
|
+
if (!isMainThread && workerData === ROLE && parentPort) {
|
|
6
|
+
const port = parentPort;
|
|
7
|
+
// Messages wait in the port until this listener is attached.
|
|
8
|
+
void import("./core.js").then(core => port.on("message", ({ id, ids }) => {
|
|
9
|
+
let reply;
|
|
10
|
+
try {
|
|
11
|
+
reply = { id, result: core.readSeatTurns(ids) };
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
reply = { id, error: e instanceof Error ? e.message : String(e) };
|
|
15
|
+
}
|
|
16
|
+
port.postMessage(reply);
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
let current = null;
|
|
20
|
+
let nextId = 0;
|
|
21
|
+
/** Reads in call order on the worker. A worker that dies answers its pending reads with `fallback` (the synchronous read). */
|
|
22
|
+
export function readSeatTurnsOffLoop(ids, fallback) {
|
|
23
|
+
if (!current) {
|
|
24
|
+
let worker;
|
|
25
|
+
// execArgv []: a parent's --import preload (e.g. one that re-roots HOME/TMPDIR) must not run again on the shared env.
|
|
26
|
+
try {
|
|
27
|
+
worker = new Worker(new URL(import.meta.url), { workerData: ROLE, env: SHARE_ENV, execArgv: [] });
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return Promise.resolve().then(() => fallback(ids));
|
|
31
|
+
}
|
|
32
|
+
worker.unref();
|
|
33
|
+
const slot = { worker, pending: new Map() };
|
|
34
|
+
worker.on("message", (reply) => {
|
|
35
|
+
const call = slot.pending.get(reply.id);
|
|
36
|
+
if (!call)
|
|
37
|
+
return;
|
|
38
|
+
slot.pending.delete(reply.id);
|
|
39
|
+
if (!slot.pending.size)
|
|
40
|
+
worker.unref();
|
|
41
|
+
if (reply.error !== undefined)
|
|
42
|
+
call.reject(new Error(reply.error));
|
|
43
|
+
else
|
|
44
|
+
call.resolve(reply.result);
|
|
45
|
+
});
|
|
46
|
+
const lost = () => {
|
|
47
|
+
if (current === slot)
|
|
48
|
+
current = null;
|
|
49
|
+
for (const call of slot.pending.values()) {
|
|
50
|
+
try {
|
|
51
|
+
call.resolve(fallback(call.ids));
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
call.reject(e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
slot.pending.clear();
|
|
58
|
+
};
|
|
59
|
+
worker.on("error", lost);
|
|
60
|
+
worker.on("exit", lost);
|
|
61
|
+
current = slot;
|
|
62
|
+
}
|
|
63
|
+
const slot = current, id = nextId++;
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
slot.pending.set(id, { ids, resolve, reject });
|
|
66
|
+
slot.worker.ref(); // an awaited read keeps the process alive; an idle worker does not
|
|
67
|
+
slot.worker.postMessage({ id, ids });
|
|
68
|
+
});
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.43",
|
|
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": [
|