aiterm-mcp 0.61.21 → 0.61.22
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 +8 -1
- package/README.ja.md +5 -1
- package/README.md +5 -1
- package/dist/core.js +102 -39
- package/dist/errors.js +1 -0
- package/dist/harnesses/codex.js +16 -6
- package/dist/harnesses/cursor.js +1 -1
- package/dist/index.js +6 -0
- package/docs/DESIGN.md +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.61.22] - 2026-10-28
|
|
11
|
+
|
|
12
|
+
- Resolve Codex model picker labels through the native model catalog when display names differ from model IDs, including names containing spaces. Keep exact row matching and reject ambiguous labels without choosing another model.
|
|
13
|
+
- Resolve Claude catalog aliases and custom IDs through their native display names instead of choosing the first model in a family; require exact Cursor base IDs and their supported effort variants. Preserve Grok's exact native-ID controls.
|
|
14
|
+
- Require a fresh Codex model-change notice matching the requested model and effort. Return typed configuration errors for all four harnesses, distinguishing requests refused before a change from possibly applied or partially applied changes, without retrying them.
|
|
15
|
+
|
|
10
16
|
## [0.61.21] - 2026-10-26
|
|
11
17
|
|
|
12
18
|
- Distinguish tmux PTY EOF from a confirmed authentication process exit: observe missing exit status/signal for a bounded interval, preserve signals and nonzero exits as failures, and reject replaced generations without restarting login.
|
|
@@ -2907,7 +2913,8 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
2907
2913
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
2908
2914
|
provenance.
|
|
2909
2915
|
|
|
2910
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.
|
|
2916
|
+
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.22...HEAD
|
|
2917
|
+
[0.61.22]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.21...v0.61.22
|
|
2911
2918
|
[0.61.21]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.20...v0.61.21
|
|
2912
2919
|
[0.61.20]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.19...v0.61.20
|
|
2913
2920
|
[0.61.19]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.18...v0.61.19
|
package/README.ja.md
CHANGED
|
@@ -209,7 +209,7 @@ runtime-error store は canonical dotagents config の `collection.enabled: true
|
|
|
209
209
|
場合だけ収集し、既定OFF、network送信は行いません。tag起点CIのnpm provenance(OIDC Trusted
|
|
210
210
|
Publishing)で公開し、GitHub Release が Official MCP Registry を再登録します。
|
|
211
211
|
|
|
212
|
-
**状態:** 開発継続中 · 現行公開版 **v0.61.
|
|
212
|
+
**状態:** 開発継続中 · 現行公開版 **v0.61.22** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
|
|
213
213
|
|
|
214
214
|
### 更新と巻き戻し
|
|
215
215
|
|
|
@@ -631,6 +631,10 @@ Aitermは、既定では実行時エラーをどこへも送らない。送る
|
|
|
631
631
|
|
|
632
632
|
`agent_configure({ session_id, model?, reasoning_effort?, fast? })`はharness標準操作で起動中のClaude/Codex/Grok/Cursorを変更し、PTYと会話contextを維持する。
|
|
633
633
|
|
|
634
|
+
model IDは各harnessの正規catalogを使う。ClaudeのaliasとCodexのIDと異なるpicker名はcatalogの表示名へ結び、Cursorは完成ID又はそのIDに対応するeffortの組だけを認める。固定のモデル許可表や別modelへの置換は加えない。Codexの成功には指定ID・effortに一致する新しいnative変更通知が必要。
|
|
635
|
+
|
|
636
|
+
全4harnessの設定変更失敗は、`isError: true`と元エラー文を保ち、`structuredContent: { schema: "aiterm.agent-configure-error.v1", session_id, outcome, effect }`を返す。`not_applied`/`not_started`は当該要求のmodel・effort・fast変更を発行し得る前の拒否。`outcome_unknown`/`possible`は変更を発行した可能性があり、一部変更後の別項目失敗も含むので自動再送しない。以前の実設定の証明や別要求の不確定解除には使わない。この型付き結果を持たない旧serverの失敗は未確認として扱う。成功の`aiterm.agent-configure-result.v1`は維持する。
|
|
637
|
+
|
|
634
638
|
**ファスト(`fast`)。** 各harnessの、費用や利用量を多く払って応答を速くする切り替え(Claude Codeの`/fast`、Codexの速度の段、GrokとCursorのfast版のmodel)を、席ごとに切り替える(ADR 0114)。
|
|
635
639
|
|
|
636
640
|
- 席は必ず通常の速度で起きる。`agent_launch`の`fast`を省いた時とfalseは同じで、利用者の設定にファストが残っていても通常で始まる。`fast: true`は通常で起こしてから、その席を切り替える。
|
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.61.
|
|
230
|
+
**Status:** actively maintained · current public release **v0.61.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).
|
|
231
231
|
|
|
232
232
|
### Update and rollback
|
|
233
233
|
|
|
@@ -674,6 +674,10 @@ enables collection on that host.
|
|
|
674
674
|
|
|
675
675
|
`agent_configure({ session_id, model?, reasoning_effort?, fast? })` changes a running Claude, Codex, Grok, or Cursor TUI through the harness's standard controls, preserving the PTY and conversation context.
|
|
676
676
|
|
|
677
|
+
Model IDs come from each harness's native catalog. Claude aliases and differing Codex picker labels use that catalog's display name; Cursor matches complete native IDs or their exact supported effort variants. No model allowlist or alternate-model fallback is added. Codex success requires a fresh native change notice matching the requested ID and effort.
|
|
678
|
+
|
|
679
|
+
Configuration failures keep `isError: true` and the original error text, with `structuredContent: { schema: "aiterm.agent-configure-error.v1", session_id, outcome, effect }` for all four harnesses. `not_applied` / `not_started` means this request failed before a model, effort, or fast change could be issued. `outcome_unknown` / `possible` means a change may have been issued, including partial application before a later failure; do not replay it automatically. This receipt does not certify the session's previous configuration or clear unrelated uncertainty. Older servers without this receipt must be treated as unconfirmed on failure. Successful results retain `aiterm.agent-configure-result.v1`.
|
|
680
|
+
|
|
677
681
|
**ファスト(`fast`)。** 各harnessの、費用や利用量を多く払って応答を速くする切り替え(Claude Codeの`/fast`、Codexの速度の段、GrokとCursorのfast版のmodel)を、席ごとに切り替える(ADR 0114)。
|
|
678
682
|
|
|
679
683
|
- 席は必ず通常の速度で起きる。`agent_launch`の`fast`を省いた時とfalseは同じで、利用者の設定にファストが残っていても通常で始まる。`fast: true`は通常で起こしてから、その席を切り替える。
|
package/dist/core.js
CHANGED
|
@@ -43,7 +43,7 @@ import { FastModeError, fastModeFailure } from "./fast-mode.js";
|
|
|
43
43
|
import { readFileOrNull, restoreJsonSetting, withUserConfigLock } from "./user-config.js";
|
|
44
44
|
import { isDeepStrictEqual } from "node:util";
|
|
45
45
|
import { grokAuthPlan, grokAuthStatus, grokAuthPane, GROK_MODEL_DEFAULTS, realGrokHome, resolveAndValidateGrokAuth, assertGrokModelAvailable, grokModelChoices, grokModelFromFooter, grokFooterModelName, grokModelDefaultsFromBody, restoreGrokModelDefaults, grokEventsTranscript, grokSessionDirectory, latestGrokCompletion, grokTurnSettled, observeGrokDone, buildGrokAgentCmd, grokAgentArgv, grokLaunchNote, grokEnvTokens, grokEnvEntries, grokTuiReady, grokPaneObservation, GROK_INTERRUPT_KEY, grokRateLimitDialog, grokPromptAwaitingAccept, grokUnacceptedPromptRestored, grokStartupAction, grokFooterHasConfiguration, grokTranscriptText, createGrokAgentMetadata, } from "./harnesses/grok.js";
|
|
46
|
-
import { codexAuthPlan, codexAuthStatus, codexAuthPane, realCodexHome, readCodexConfigPins, bindCodexTranscriptSession, latestCodexCompletion, codexTurnSettled, codexRunningTurn, codexInterruptionRecord, observeCodexDone, buildCodexAgentCmd, codexAgentArgv, codexLaunchNote, codexPaneObservation, CODEX_INTERRUPT_KEY, codexHelperProcess, codexRateLimitModelSwitchDialog, codexApprovalDialog, codexStartupAction, codexModelChoice, codexEffortChoice, codexMoreReasoningChoice, codexTranscriptText, createCodexAgentMetadata, codexModelChoices, codexFastCommandOffered, codexFooterShowsFast, codexServiceTierNotices, restoreCodexDefaults, restoreCodexDefaultInFile, } from "./harnesses/codex.js";
|
|
46
|
+
import { codexAuthPlan, codexAuthStatus, codexAuthPane, realCodexHome, readCodexConfigPins, bindCodexTranscriptSession, latestCodexCompletion, codexTurnSettled, codexRunningTurn, codexInterruptionRecord, observeCodexDone, buildCodexAgentCmd, codexAgentArgv, codexLaunchNote, codexPaneObservation, CODEX_INTERRUPT_KEY, codexHelperProcess, codexRateLimitModelSwitchDialog, codexApprovalDialog, codexStartupAction, codexModelChoice, codexModelChangeNotices, codexEffortChoice, codexMoreReasoningChoice, codexTranscriptText, createCodexAgentMetadata, codexModelChoices, codexFastCommandOffered, codexFooterShowsFast, codexServiceTierNotices, restoreCodexDefaults, restoreCodexDefaultInFile, } from "./harnesses/codex.js";
|
|
47
47
|
import { claudeAuthPlan, claudeAuthStatus, claudeAuthPane, OPERATION_ID_RE, CLAUDE_RESULT_MAX_BYTES, CLAUDE_EFFORTS, agentManagedClaudeSettingsPath, agentClaudeResultPath, agentClaudeOperationPath, agentClaudeApprovalReceiptPath, agentClaudeDispatchReceiptPath, validateOperationId, readClaudeResultText, assertClaudeAuthenticationReady, claudeModelChoices, claudeConfigDir, claudeFastIndicatorShown, claudeFastResult, buildClaudeAgentCmd, claudeAgentArgv, claudeLaunchNote, claudePaneObservation, CLAUDE_INTERRUPT_KEY, claudeUsageLimit, claudeLiveSelectMenu, claudeModelPicker, claudeModelPickerRow, claudeModelSwitchConfirm, claudeModelSwitchResult, claudeStartupAction, createClaudeAgentMetadata, claudeSessionTranscriptPath, claudeApiErrorFromLine, claudeApiErrorAfter, } from "./harnesses/claude.js";
|
|
48
48
|
import { cursorAuthPlan, cursorAuthStatus, cursorAuthPane, bindCursorTranscriptSession, cursorTurnBoundary, latestCursorCompletion, observeCursorDone, cursorTranscriptText, assertCursorAuthenticationReady, assertCursorModelAvailable, cursorModelChoices, cursorModelIsFastVariant, cursorFastParameter, cursorHeaderShowsFast, cursorPickerView, cursorEffortSelected, cursorParameterRows, cursorUserConfigPath, CURSOR_DEFAULT_MODEL_KEYS, realCursorHome, buildCursorAgentCmd, cursorAgentArgv, cursorPromptWithLineage, createCursorAgentMetadata, cursorLaunchNote, cursorEffortNavigation, cursorTuiReady, cursorPaneObservation, CURSOR_INTERRUPT_KEY, cursorPromptHooksRunning, cursorUsageLimit, CURSOR_SUBMIT_SEQUENCE, validateCursorModelEffort, } from "./harnesses/cursor.js";
|
|
49
49
|
import { interimFromNow, readInterimWords, recordInterimBoundary } from "./interim-words.js";
|
|
@@ -4745,7 +4745,8 @@ const CLAUDE_EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"];
|
|
|
4745
4745
|
* (2.1.296で確かめた)。引数なしの `/model` の選ぶ画面で s を押すと保存されないので、画面を1歩ずつ読んでそちらを打つ。
|
|
4746
4746
|
* 保存しない選び方が画面に無い時、行やeffortを選べない時は、Escで閉じて何も変えずに断る。
|
|
4747
4747
|
*/
|
|
4748
|
-
async function configureClaudeForSessionOnly(name, meta, model, effort) {
|
|
4748
|
+
async function configureClaudeForSessionOnly(name, meta, model, effort, beforeChange) {
|
|
4749
|
+
let selectionIssued = false;
|
|
4749
4750
|
const screen = () => captureScreen(name, AGENT_TUI_READY_LINES);
|
|
4750
4751
|
const until = async (read, timeoutMs) => {
|
|
4751
4752
|
const deadline = performance.now() + timeoutMs;
|
|
@@ -4766,7 +4767,8 @@ async function configureClaudeForSessionOnly(name, meta, model, effort) {
|
|
|
4766
4767
|
sendMenuChoice(name, "Escape");
|
|
4767
4768
|
await sleep(300);
|
|
4768
4769
|
}
|
|
4769
|
-
throw new AitermError(`${code} vendor=claude session=${name}\n${reason}
|
|
4770
|
+
throw new AitermError(`${code} vendor=claude session=${name}\n${reason}。` +
|
|
4771
|
+
(selectionIssued ? "設定が変わった可能性があります。再送しないでください。" : "modelとreasoning_effortは変えていません。"), 2);
|
|
4770
4772
|
};
|
|
4771
4773
|
const picker = () => claudeModelPicker(screen());
|
|
4772
4774
|
const cursorOf = (p) => p?.rows.find((row) => row.cursor) ?? null;
|
|
@@ -4820,7 +4822,24 @@ async function configureClaudeForSessionOnly(name, meta, model, effort) {
|
|
|
4820
4822
|
break;
|
|
4821
4823
|
seen.add(at);
|
|
4822
4824
|
}
|
|
4823
|
-
|
|
4825
|
+
let target = claudeModelPickerRow([...known.values()], model);
|
|
4826
|
+
if (!target || /^[a-z]+$/iu.test(model)) {
|
|
4827
|
+
const bin = meta.agent_executable ?? resolveAgentBin("claude");
|
|
4828
|
+
if (!bin)
|
|
4829
|
+
return refuse("CLAUDE_MODEL_NOT_IN_PICKER", "Claude CodeのCLIが見つかりません");
|
|
4830
|
+
let catalog;
|
|
4831
|
+
try {
|
|
4832
|
+
catalog = await claudeModelChoices(bin, meta.cwd ?? process.cwd());
|
|
4833
|
+
}
|
|
4834
|
+
catch (error) {
|
|
4835
|
+
return refuse("CLAUDE_MODEL_CATALOG_UNAVAILABLE", error instanceof Error ? error.message : String(error));
|
|
4836
|
+
}
|
|
4837
|
+
const native = catalog.models.find(item => item.id.toLowerCase() === model.toLowerCase());
|
|
4838
|
+
// The native alias can resolve to an older model; picker order is not alias authority.
|
|
4839
|
+
const label = native?.display_name ?? native?.id ?? model;
|
|
4840
|
+
const matching = [...known.values()].filter(row => row.label.toLowerCase() === label.toLowerCase());
|
|
4841
|
+
target = matching.length === 1 ? matching[0] : null;
|
|
4842
|
+
}
|
|
4824
4843
|
if (!target) {
|
|
4825
4844
|
const names = [...known.values()].sort((a, b) => a.index - b.index).map((row) => row.label).join(", ");
|
|
4826
4845
|
return refuse("CLAUDE_MODEL_NOT_IN_PICKER", `Claude Codeの /model の選ぶ画面に ${model} がありません(選べる機種: ${names})`);
|
|
@@ -4866,6 +4885,8 @@ async function configureClaudeForSessionOnly(name, meta, model, effort) {
|
|
|
4866
4885
|
|| (effort && last.effort !== effort)) {
|
|
4867
4886
|
return refuse("CLAUDE_MODEL_PICKER_UNREADABLE", "選ぶ直前の画面が、選んだ行・effortと合いません");
|
|
4868
4887
|
}
|
|
4888
|
+
beforeChange();
|
|
4889
|
+
selectionIssued = true;
|
|
4869
4890
|
sendMenuChoice(name, "s");
|
|
4870
4891
|
let confirmed = false;
|
|
4871
4892
|
const result = await until(() => {
|
|
@@ -5641,33 +5662,43 @@ export async function pauseAgentGoalForStop(target) {
|
|
|
5641
5662
|
return { status: result.availability === "unsupported" || result.outcome === "unsupported" ? "unsupported" : result.outcome === "outcome_unknown" ? "outcome_unknown" : "unavailable", reason: result.reason };
|
|
5642
5663
|
}
|
|
5643
5664
|
export async function configureAgent(name, opts) {
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5665
|
+
let mayHaveChanged = false;
|
|
5666
|
+
const beforeChange = () => { mayHaveChanged = true; };
|
|
5667
|
+
try {
|
|
5668
|
+
assertExecutionContext(name);
|
|
5669
|
+
assertSessionName(name);
|
|
5670
|
+
const model = opts.model?.trim() || null;
|
|
5671
|
+
const effort = opts.reasoning_effort?.trim() || null;
|
|
5672
|
+
const fast = opts.fast ?? null;
|
|
5673
|
+
if (!model && !effort && fast === null)
|
|
5674
|
+
throw new AitermError("model、reasoning_effort、fast のいずれかを指定してください", 2);
|
|
5675
|
+
if ((model && /[\r\n]/.test(model)) || (effort && /[\r\n]/.test(effort))) {
|
|
5676
|
+
throw new AitermError("model/reasoning_effort に改行を含められません", 2);
|
|
5677
|
+
}
|
|
5678
|
+
if (fast === false && modelIsFastVariant(loadAgentMetadata(name).kind, model)) {
|
|
5679
|
+
throw new FastModeError("FAST_MODE_MODEL_CONFLICT", `model=${model} はfast版のIDですが、fast: false が渡されました。元のmodel IDを渡すか、fastを省いてください。設定は変えていません。`);
|
|
5680
|
+
}
|
|
5681
|
+
// 設定替えは席の入力欄へ命令を打つので、送信と同じ行列(ADR 0088)に並ぶ。替えている間に届いた文は、替え終えてから席へ入る(ADR 0120)。
|
|
5682
|
+
// 番が動いている席では、行列を持ったまま番の終わりを待たない(待つ間も、その席への差し込みを通す)。
|
|
5683
|
+
const deadline = performance.now() + AGENT_TUI_READY_TIMEOUT_MS;
|
|
5684
|
+
for (;;) {
|
|
5685
|
+
const result = await withAgentSendLock(name, () => configureAgentInLock(name, model, effort, fast, beforeChange), AGENT_CONFIGURE_UNCHANGED);
|
|
5686
|
+
if (result)
|
|
5687
|
+
return result;
|
|
5688
|
+
if (performance.now() >= deadline)
|
|
5689
|
+
throw new AitermError(`agent session '${name}' は入力待ちではありません`, 2);
|
|
5690
|
+
await sleep(AGENT_TUI_READY_POLL_MS);
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
catch (error) {
|
|
5694
|
+
const failure = error instanceof Error ? error : new AitermError(String(error), 2);
|
|
5695
|
+
Object.assign(failure, { configurationFailure: { schema: "aiterm.agent-configure-error.v1", session_id: name,
|
|
5696
|
+
outcome: mayHaveChanged ? "outcome_unknown" : "not_applied", effect: mayHaveChanged ? "possible" : "not_started" } });
|
|
5697
|
+
throw failure;
|
|
5667
5698
|
}
|
|
5668
5699
|
}
|
|
5669
5700
|
/** 返りの null は、席の画面が番の最中を示していて、何も打っていない時。 */
|
|
5670
|
-
async function configureAgentInLock(name, model, effort, fast) {
|
|
5701
|
+
async function configureAgentInLock(name, model, effort, fast, beforeChange) {
|
|
5671
5702
|
// 席の控えは、行列の順番が来てから読む(前の送信が書いた分を、古い控えで上書きしない)。
|
|
5672
5703
|
const meta = loadAgentMetadata(name);
|
|
5673
5704
|
bindCompletedInitialPrompt(meta);
|
|
@@ -5736,16 +5767,19 @@ async function configureAgentInLock(name, model, effort, fast) {
|
|
|
5736
5767
|
throw new AitermError("Claude Code の reasoning_effort は low/medium/high/xhigh/max/ultracode のいずれかです。設定は変えていません。", 2);
|
|
5737
5768
|
}
|
|
5738
5769
|
if (model || level)
|
|
5739
|
-
await configureClaudeForSessionOnly(name, meta, model, level);
|
|
5770
|
+
await configureClaudeForSessionOnly(name, meta, model, level, beforeChange);
|
|
5740
5771
|
if (effort && !level) {
|
|
5772
|
+
beforeChange();
|
|
5741
5773
|
await sendAgentPromptText(name, `/effort ${effort}`);
|
|
5742
5774
|
const effortReady = await waitAgentTuiReady(name, meta, AGENT_TUI_READY_TIMEOUT_MS);
|
|
5743
5775
|
if (!effortReady.ready)
|
|
5744
5776
|
throw new AitermError(`Claudeのeffort変更完了を確認できません`, 2);
|
|
5745
5777
|
}
|
|
5746
5778
|
rememberModel();
|
|
5747
|
-
if (fast !== null)
|
|
5779
|
+
if (fast !== null) {
|
|
5780
|
+
beforeChange();
|
|
5748
5781
|
recordAgentFast(meta, await switchClaudeFast(name, meta, fast, fastVerified));
|
|
5782
|
+
}
|
|
5749
5783
|
else
|
|
5750
5784
|
await dropFastIfUnsupported();
|
|
5751
5785
|
return configured();
|
|
@@ -5773,6 +5807,7 @@ async function configureAgentInLock(name, model, effort, fast) {
|
|
|
5773
5807
|
// Cursorは選んだmodelとパラメータを、利用者の既定(cli-config.json)へも書く版がある。席だけの替えにするため、直前の値へ戻す。
|
|
5774
5808
|
if (model)
|
|
5775
5809
|
await keepingCursorDefaults(meta, async () => {
|
|
5810
|
+
beforeChange();
|
|
5776
5811
|
await sendAgentPromptText(name, `/model ${model}`, meta.kind);
|
|
5777
5812
|
const modelReady = await waitAgentTuiReady(name, meta, AGENT_TUI_READY_TIMEOUT_MS);
|
|
5778
5813
|
if (!modelReady.ready)
|
|
@@ -5808,8 +5843,10 @@ async function configureAgentInLock(name, model, effort, fast) {
|
|
|
5808
5843
|
throw new AitermError("Cursorのreasoning effort変更完了を確認できません", 2);
|
|
5809
5844
|
});
|
|
5810
5845
|
rememberModel();
|
|
5811
|
-
if (fast !== null)
|
|
5846
|
+
if (fast !== null) {
|
|
5847
|
+
beforeChange();
|
|
5812
5848
|
recordAgentFast(meta, await switchCursorFast(name, meta, fast));
|
|
5849
|
+
}
|
|
5813
5850
|
else if (model) {
|
|
5814
5851
|
// modelを替えた後の実際の状態を、見出しのmodelの表示で読む。
|
|
5815
5852
|
const shown = cursorHeaderShowsFast(captureScreen(name, AGENT_TUI_READY_LINES));
|
|
@@ -5837,31 +5874,36 @@ async function configureAgentInLock(name, model, effort, fast) {
|
|
|
5837
5874
|
}
|
|
5838
5875
|
if (model || effort) {
|
|
5839
5876
|
// `/model` はGrokが利用者の既定([models].default)へも書くので、切り替えの直前の値へ戻す。
|
|
5877
|
+
beforeChange();
|
|
5840
5878
|
await sendGrokModelCommand(name, meta, next ? `/model ${next}${effort ? ` ${effort}` : ""}` : `/effort ${effort}`, next, effort);
|
|
5841
5879
|
if (model) {
|
|
5842
5880
|
rememberModel();
|
|
5843
5881
|
recordAgentFast(meta, next !== model || modelIsFastVariant("grok", model));
|
|
5844
5882
|
}
|
|
5845
5883
|
}
|
|
5846
|
-
if (!model && fast !== null)
|
|
5884
|
+
if (!model && fast !== null) {
|
|
5885
|
+
beforeChange();
|
|
5847
5886
|
recordAgentFast(meta, await switchGrokFast(name, meta, fast));
|
|
5887
|
+
}
|
|
5848
5888
|
return configured();
|
|
5849
5889
|
}
|
|
5850
5890
|
// `/model` の選択は、利用者のconfig.tomlへ model と model_reasoning_effort を既定として保存する。席だけの替えにするため、直前の値へ戻す。
|
|
5851
5891
|
if (model || effort) {
|
|
5852
|
-
await keepingCodexDefaults(meta.agent_executable ?? resolveAgentBin("codex"), meta.codex_home ?? realCodexHome(), ["model", "model_reasoning_effort"], () => configureCodexModel(name, model, effort));
|
|
5892
|
+
await keepingCodexDefaults(meta.agent_executable ?? resolveAgentBin("codex"), meta.codex_home ?? realCodexHome(), ["model", "model_reasoning_effort"], () => configureCodexModel(name, model, effort, beforeChange));
|
|
5853
5893
|
}
|
|
5854
5894
|
rememberModel();
|
|
5855
|
-
if (fast !== null)
|
|
5895
|
+
if (fast !== null) {
|
|
5896
|
+
beforeChange();
|
|
5856
5897
|
recordAgentFast(meta, await switchCodexFast(name, meta, fast, fastVerified));
|
|
5898
|
+
}
|
|
5857
5899
|
else
|
|
5858
5900
|
await dropFastIfUnsupported();
|
|
5859
5901
|
return configured();
|
|
5860
5902
|
}
|
|
5861
5903
|
/** Codexの `/model` の選ぶ画面で、modelとreasoning effortを替える。 */
|
|
5862
|
-
async function configureCodexModel(name, model, effort) {
|
|
5904
|
+
async function configureCodexModel(name, model, effort, beforeChange) {
|
|
5863
5905
|
try {
|
|
5864
|
-
await chooseCodexModel(name, model, effort);
|
|
5906
|
+
await chooseCodexModel(name, model, effort, beforeChange);
|
|
5865
5907
|
}
|
|
5866
5908
|
catch (error) {
|
|
5867
5909
|
// 選べずに断る時は、開いた選ぶ画面を閉じてから断る(開いたままだと、席は次の文を受け付けない)。
|
|
@@ -5875,16 +5917,31 @@ async function configureCodexModel(name, model, effort) {
|
|
|
5875
5917
|
throw error;
|
|
5876
5918
|
}
|
|
5877
5919
|
}
|
|
5878
|
-
async function chooseCodexModel(name, model, effort) {
|
|
5920
|
+
async function chooseCodexModel(name, model, effort, beforeChange) {
|
|
5921
|
+
const beforeCounts = lineCounts(captureScreen(name, AGENT_TUI_READY_LINES));
|
|
5879
5922
|
await sendAgentPromptText(name, "/model");
|
|
5880
5923
|
const modelScreen = await waitForScreenText(name, "Select Model and Effort");
|
|
5881
5924
|
if (model) {
|
|
5882
|
-
|
|
5925
|
+
let choice = codexModelChoice(modelScreen, model);
|
|
5926
|
+
if (!choice) {
|
|
5927
|
+
const meta = loadAgentMetadata(name);
|
|
5928
|
+
const bin = meta.agent_executable ?? resolveAgentBin("codex");
|
|
5929
|
+
if (!bin)
|
|
5930
|
+
throw new AitermError("Codex の CLI が見つかりません", 2);
|
|
5931
|
+
const catalog = await codexModelChoices(bin, true);
|
|
5932
|
+
const target = catalog.models.find(item => item.id.toLowerCase() === model.toLowerCase());
|
|
5933
|
+
const displayName = target?.display_name;
|
|
5934
|
+
if (displayName && catalog.models.filter(item => item.display_name?.toLowerCase() === displayName.toLowerCase()).length === 1) {
|
|
5935
|
+
choice = codexModelChoice(modelScreen, model, displayName);
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5883
5938
|
if (!choice)
|
|
5884
5939
|
throw new AitermError(`Codexの/modelに ${model} がありません`, 2);
|
|
5940
|
+
beforeChange();
|
|
5885
5941
|
sendMenuChoice(name, choice);
|
|
5886
5942
|
}
|
|
5887
5943
|
else {
|
|
5944
|
+
beforeChange();
|
|
5888
5945
|
sendMenuChoice(name, "Enter");
|
|
5889
5946
|
}
|
|
5890
5947
|
let effortScreen = await waitForScreenText(name, "Select Reasoning Level");
|
|
@@ -5905,7 +5962,13 @@ async function chooseCodexModel(name, model, effort) {
|
|
|
5905
5962
|
else {
|
|
5906
5963
|
sendMenuChoice(name, "Enter");
|
|
5907
5964
|
}
|
|
5908
|
-
|
|
5965
|
+
for (const deadline = performance.now() + 3_000; performance.now() < deadline; await sleep(100)) {
|
|
5966
|
+
const screen = captureScreen(name, AGENT_TUI_READY_LINES);
|
|
5967
|
+
const counts = lineCounts(screen);
|
|
5968
|
+
if (codexModelChangeNotices(screen, model, effort).some(line => (counts.get(line) ?? 0) > (beforeCounts.get(line) ?? 0)))
|
|
5969
|
+
return;
|
|
5970
|
+
}
|
|
5971
|
+
throw new AitermError("CODEX_MODEL_SWITCH_UNCONFIRMED: 指定したmodel/effortの新しい変更通知を確認できません。設定が変わった可能性があります。再送しないでください。", 2);
|
|
5909
5972
|
}
|
|
5910
5973
|
export function __testCodexConfigureChoices(screen, model, effort) {
|
|
5911
5974
|
return {
|
package/dist/errors.js
CHANGED
package/dist/harnesses/codex.js
CHANGED
|
@@ -1000,14 +1000,18 @@ export function codexLaunchBlockingDialog(screen) {
|
|
|
1000
1000
|
return "起動時ダイアログ(種別未特定)";
|
|
1001
1001
|
return null;
|
|
1002
1002
|
}
|
|
1003
|
-
export function codexModelChoice(screen, model) {
|
|
1003
|
+
export function codexModelChoice(screen, model, displayName = null) {
|
|
1004
|
+
const choices = [];
|
|
1004
1005
|
for (const line of screen.slice(screen.lastIndexOf("Select Model and Effort")).split("\n")) {
|
|
1005
|
-
const match = line.match(/^\s*(?:›\s*)?(\d+)\.\s+(\
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1006
|
+
const match = line.match(/^\s*(?:›\s*)?(\d+)\.\s+(.+?)\s*$/);
|
|
1007
|
+
if (!match)
|
|
1008
|
+
continue;
|
|
1009
|
+
// Native labels can contain spaces; descriptions and the current marker are not part of the label.
|
|
1010
|
+
const label = match[2].split(/\s{2,}/)[0].replace(/\s+\(current\)$/, "");
|
|
1011
|
+
if ([model, displayName].some(name => name !== null && label.toLowerCase() === name.toLowerCase()))
|
|
1012
|
+
choices.push(match[1]);
|
|
1009
1013
|
}
|
|
1010
|
-
return null;
|
|
1014
|
+
return choices.length === 1 ? choices[0] : null;
|
|
1011
1015
|
}
|
|
1012
1016
|
export function codexEffortChoice(screen, effort) {
|
|
1013
1017
|
const labels = {
|
|
@@ -1028,6 +1032,12 @@ export function codexEffortChoice(screen, effort) {
|
|
|
1028
1032
|
}
|
|
1029
1033
|
return null;
|
|
1030
1034
|
}
|
|
1035
|
+
export function codexModelChangeNotices(screen, model, effort) {
|
|
1036
|
+
return screen.split("\n").map(line => line.trim()).filter(line => {
|
|
1037
|
+
const match = line.match(/^(?:[•◦]\s*)?Model changed to (\S+)(?: (none|minimal|low|medium|high|xhigh|max|ultra)\b)?/);
|
|
1038
|
+
return match !== null && (!model || match[1].toLowerCase() === model.toLowerCase()) && (!effort || match[2] === effort);
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1031
1041
|
export function codexMoreReasoningChoice(screen) {
|
|
1032
1042
|
for (const line of screen.split("\n")) {
|
|
1033
1043
|
const match = line.match(/^\s*(?:›\s*)?(\d+)\.\s+More reasoning/);
|
package/dist/harnesses/cursor.js
CHANGED
|
@@ -477,7 +477,7 @@ export function assertCursorModelAvailable(bin, cwd, model, effort, fast = false
|
|
|
477
477
|
if (fast && !models.includes(effective)) {
|
|
478
478
|
throw new FastModeError("FAST_MODE_NOT_SUPPORTED", `Cursor の一覧に ${JSON.stringify(effective)} がありません(model=${model}${effort ? `、reasoning_effort=${effort}` : ""} のfast版)。起動していません。`);
|
|
479
479
|
}
|
|
480
|
-
const available = effort || fast ? models.includes(effective) : models.includes(model) || models.some((id)
|
|
480
|
+
const available = effort || fast ? models.includes(effective) : models.includes(model) || models.some(id => cursorBaseModel(id)?.base === model);
|
|
481
481
|
if (!available) {
|
|
482
482
|
throw new AitermError(`Cursor model catalog に ${JSON.stringify(effective)} がありません。` +
|
|
483
483
|
"modelとreasoning_effortから作る正規IDが存在しないため、別modelへfallbackせず中止しました", 2);
|
package/dist/index.js
CHANGED
|
@@ -176,6 +176,12 @@ export function createAitermServer(options = {}) {
|
|
|
176
176
|
}
|
|
177
177
|
function fail(e) {
|
|
178
178
|
const msg = e instanceof Error ? e.message : String(e);
|
|
179
|
+
const configurationFailure = e instanceof Error ? e.configurationFailure : undefined;
|
|
180
|
+
if (configurationFailure)
|
|
181
|
+
return {
|
|
182
|
+
content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
|
|
183
|
+
structuredContent: { ...configurationFailure },
|
|
184
|
+
};
|
|
179
185
|
if (e instanceof AgentAuthenticationPreflightError)
|
|
180
186
|
return {
|
|
181
187
|
content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
|
package/docs/DESIGN.md
CHANGED
|
@@ -168,6 +168,10 @@ harnessがagent loop、認証、hook、session、transcript、model catalogを
|
|
|
168
168
|
project/user環境を置換せず、launch相関と完了回収に必要なstateだけを加える。
|
|
169
169
|
Throughlineの補足記憶はpathを透過搬送するだけで、内容、project束縛、context予算はThroughlineが所有する。
|
|
170
170
|
|
|
171
|
+
設定変更もnative catalogと標準入力操作を使う。Claudeのaliasと任意IDはcatalogの表示名へ結び、CodexはID表記がpickerに無い時に同じ公式catalogの表示名を使う。名前のprefixや任意の空白置換で別modelを選ばない。Cursorの素ID判定は既存effort variantの解析と一致させ、Grokの完成IDはそのまま渡す。
|
|
172
|
+
|
|
173
|
+
4harness共通の`agent_configure`は、変更を発行し得る境界に達したかを要求内で保持する。失敗は`aiterm.agent-configure-error.v1`の`not_applied/not_started`又は`outcome_unknown/possible`で返し、後者には部分適用を含む。これは要求単位の保守的な分類で、以前の実設定や他要求の状態は証明しない。成功型は維持し、Codexの完了は指定ID・effortに一致する新規native通知を確認する。別modelの通知や残画面では成功にしない。
|
|
174
|
+
|
|
171
175
|
agent turnは常に非ブロックdispatchであり、receiptの`event_cursor`がturn境界になる。
|
|
172
176
|
Codex親にはAitermのMCP processが完了を観測し、選択設定に応じて公式Steerまたはqueueへ本文を自動配送する。
|
|
173
177
|
Claude Code親は公式の非同期hookで本文を受け取り、待機中も新しいturnへ進める。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.22",
|
|
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, and Cursor Agent CLI, plus durable PTYs for SSH, containers, and REPLs.",
|
|
6
6
|
"keywords": [
|