aiterm-steer-delivery 0.1.1 → 0.1.3
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 -0
- package/README.md +2 -2
- package/dist/codex-binary.d.ts +10 -1
- package/dist/codex-binary.js +49 -4
- package/dist/codex-setup.js +17 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
- Codex CLIをsymlink経由で起動した形(`node <symlinkのpath>`)も、再起動待ちとして照合する。
|
|
6
|
+
- macOS・Windowsで失敗していた試験を直した(試験のコマンド行の書き方と、macOSの一時ディレクトリの実体path)。0.1.1・0.1.2のmainのCIはこの試験でmacOS・Windowsが失敗していた。
|
|
7
|
+
|
|
8
|
+
## 0.1.2
|
|
9
|
+
|
|
10
|
+
- CodexのSteer(作業中のturnへの差し込み)を、Codex Desktopの無い端末とLinuxにも広げた(指揮官氏の判断 2026-09-29)。公式Desktopの同梱CLI(macOS・Windows・Linux)を先に探し、無ければ通常のCodex CLI(0.154以上)を使う。以前はmacOS・WindowsのDesktopだけで、Linuxは`unsupported`だった。
|
|
11
|
+
- 使っていたCodexが更新で消えた時の探し直しも、同じ順(Desktop、無ければCLI)で行う。
|
|
12
|
+
- npm版のCodex CLI(`node …/codex.js`とその中のnative本体)も、導入前から動いている「再起動が要るCodex」として照合する。
|
|
13
|
+
|
|
3
14
|
## 0.1.1
|
|
4
15
|
|
|
5
16
|
- Codex hookの解除(disable)で、自製品のhookのまとまりを抜くと後ろの他製品・利用者のhookの位置がずれ、Codexが位置の鍵で持つ承認と合わなくなって「modified」になり動かなくなっていた(紅蓮氏の報告、macbookでgrokbot-bridgeとpeertableのhookが止まった)。位置が動くhookの承認(trusted_hash・enabled)を、hooks.jsonを書き換える前に新しい位置へ写し、書き換え後に空いた位置の承認を消す。承認を新たに与えたり外したりはしない。公式Codexで確かめる試験を加えた。
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ This is the delivery [Aiterm](https://github.com/kitepon/aiterm-mcp) uses to han
|
|
|
9
9
|
|
|
10
10
|
| Parent | How the parent is identified | How text arrives |
|
|
11
11
|
| --- | --- | --- |
|
|
12
|
-
| Codex | `_meta.threadId` of the MCP request | Official App Server queue (`thread/queue/add`).
|
|
12
|
+
| Codex | `_meta.threadId` of the MCP request | Official App Server queue (`thread/queue/add`). With Steer enabled, your sync `PostToolUse`/`Stop` hooks pull it into the running turn; otherwise the official queue delivers it at the next turn boundary. |
|
|
13
13
|
| Claude Code | Your `PreToolUse` hook record + `_meta["claudecode/toolUseId"]` | An `asyncRewake` hook writes the text to stderr and exits 2, waking the session (or steering into the running turn). |
|
|
14
14
|
| Cursor | Your hook binds the id in your tool result to the real `conversation_id` | `additional_context` on the next tool return while busy; a background receiver process while idle. |
|
|
15
15
|
| Others (Grok, …) | — | A background receiver process (`wait_process`). |
|
|
@@ -64,7 +64,7 @@ import { PROFILE } from "./profile.mjs";
|
|
|
64
64
|
await runClaudeHookMain(PROFILE);
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Register them with `mergeClaudeParentHooks`, `mergeCursorParentHooks`, and `configureCodexSteer
|
|
67
|
+
Register them with `mergeClaudeParentHooks`, `mergeCursorParentHooks`, and `configureCodexSteer`. Codex Steer uses the Codex Desktop's bundled CLI when present (macOS, Windows, Linux) and otherwise the regular Codex CLI (0.154+).
|
|
68
68
|
|
|
69
69
|
## Non-Node products
|
|
70
70
|
|
package/dist/codex-binary.d.ts
CHANGED
|
@@ -13,8 +13,17 @@ export declare function findDesktopBinary(): string;
|
|
|
13
13
|
export declare function findWindowsCodexCache(resources: string, cache: string): string;
|
|
14
14
|
/** Windowsの公式Codex Desktop(MSIX)が展開したCLI。 */
|
|
15
15
|
export declare function findWindowsCodexBinary(): string;
|
|
16
|
+
/** Linuxの公式Codex Desktop(deb・rpm)が同梱するCLI。 */
|
|
17
|
+
export declare function findLinuxDesktopBinary(candidates?: string[]): string;
|
|
18
|
+
/** Desktopの無い端末で使う、通常のCodex CLI。 */
|
|
19
|
+
export declare function findCliBinary(resolve?: () => string | null): string;
|
|
16
20
|
export type DesktopBinaryFinder = () => string;
|
|
17
|
-
export declare function platformDesktopFinder(): DesktopBinaryFinder;
|
|
21
|
+
export declare function platformDesktopFinder(platform?: NodeJS.Platform): DesktopBinaryFinder;
|
|
22
|
+
/**
|
|
23
|
+
* Steerのhookが公式キューを操作するのに使うCodex。公式Desktopの同梱CLIを先に探し、Desktopが無ければ
|
|
24
|
+
* 通常のCodex CLIを使う(どちらも同じ公式キューとhookを持つ)。
|
|
25
|
+
*/
|
|
26
|
+
export declare function findSteerBinary(desktop?: DesktopBinaryFinder, cli?: () => string): string;
|
|
18
27
|
export declare function currentCodexDesktopBinary(profile: ProductProfile, config: CodexHookConfig, options?: {
|
|
19
28
|
directory?: string;
|
|
20
29
|
find?: DesktopBinaryFinder;
|
package/dist/codex-binary.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Codexの実行ファイルとCODEX_HOMEの解決。Desktopが同梱するCLIは更新のたびに場所が変わることがあるので、
|
|
2
|
-
// setup
|
|
2
|
+
// setupで保存した場所が消えていたら、使う時点で同じ順(公式Desktop、無ければCodex CLI)で探し直す。探せなければ理由付きで止める。
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import * as fs from "node:fs";
|
|
@@ -156,8 +156,53 @@ Join-Path $packages[0].InstallLocation 'app/resources'`, () => new CodexDelivery
|
|
|
156
156
|
throw new SetupError("codex_version_unsupported", "公式Codex Desktopの対応CLIを確認できません。");
|
|
157
157
|
return value;
|
|
158
158
|
}
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
/** CLIが対応する最低版(公式キューとhookの取込み)。 */
|
|
160
|
+
function assertSteerVersion(executable, subject) {
|
|
161
|
+
const result = spawnSync(executable, ["--version"], { encoding: "utf8", windowsHide: true, timeout: 15_000 });
|
|
162
|
+
if (result.error || result.status !== 0)
|
|
163
|
+
throw new SetupError("codex_binary_unavailable", `${subject}を起動できません`);
|
|
164
|
+
const match = /codex-cli (\d+)\.(\d+)\.(\d+)/.exec(result.stdout ?? "");
|
|
165
|
+
if (!match || (Number(match[1]) === 0 && Number(match[2]) < 154)) {
|
|
166
|
+
throw new SetupError("codex_version_unsupported", `Steerには公式キューとhookに対応するCodex CLI 0.154以上が必要です(${subject})`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Linuxの公式Codex Desktop(deb・rpm)が同梱するCLI。 */
|
|
170
|
+
export function findLinuxDesktopBinary(candidates = ["/usr/lib/chatgpt/resources/codex", "/opt/ChatGPT/resources/codex"]) {
|
|
171
|
+
const found = candidates.filter(file => fs.existsSync(file));
|
|
172
|
+
if (found.length !== 1)
|
|
173
|
+
throw new SetupError("codex_desktop_not_identified", "Codex Desktopのインストール先を一つに特定できません");
|
|
174
|
+
assertSteerVersion(found[0], "Codex Desktopの同梱CLI");
|
|
175
|
+
return found[0];
|
|
176
|
+
}
|
|
177
|
+
/** Desktopの無い端末で使う、通常のCodex CLI。 */
|
|
178
|
+
export function findCliBinary(resolve = resolveCodexExecutable) {
|
|
179
|
+
const binary = resolve();
|
|
180
|
+
if (!binary)
|
|
181
|
+
throw new SetupError("codex_binary_unavailable", "Codex DesktopもCodex CLIも見つかりません");
|
|
182
|
+
assertSteerVersion(binary, "Codex CLI");
|
|
183
|
+
return binary;
|
|
184
|
+
}
|
|
185
|
+
export function platformDesktopFinder(platform = process.platform) {
|
|
186
|
+
return platform === "win32" ? findWindowsCodexBinary : platform === "darwin" ? findDesktopBinary : findLinuxDesktopBinary;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Steerのhookが公式キューを操作するのに使うCodex。公式Desktopの同梱CLIを先に探し、Desktopが無ければ
|
|
190
|
+
* 通常のCodex CLIを使う(どちらも同じ公式キューとhookを持つ)。
|
|
191
|
+
*/
|
|
192
|
+
export function findSteerBinary(desktop = platformDesktopFinder(), cli = () => findCliBinary()) {
|
|
193
|
+
try {
|
|
194
|
+
return desktop();
|
|
195
|
+
}
|
|
196
|
+
catch (desktopError) {
|
|
197
|
+
try {
|
|
198
|
+
return cli();
|
|
199
|
+
}
|
|
200
|
+
catch (cliError) {
|
|
201
|
+
if (cliError instanceof SetupError && cliError.code === "codex_binary_unavailable" && desktopError instanceof SetupError)
|
|
202
|
+
throw desktopError;
|
|
203
|
+
throw cliError;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
161
206
|
}
|
|
162
207
|
export async function currentCodexDesktopBinary(profile, config, options = {}) {
|
|
163
208
|
const exists = options.exists ?? fs.existsSync;
|
|
@@ -165,7 +210,7 @@ export async function currentCodexDesktopBinary(profile, config, options = {}) {
|
|
|
165
210
|
return config.binary;
|
|
166
211
|
let binary;
|
|
167
212
|
try {
|
|
168
|
-
binary = (options.find ??
|
|
213
|
+
binary = (options.find ?? (() => findSteerBinary()))();
|
|
169
214
|
}
|
|
170
215
|
catch (error) {
|
|
171
216
|
throw new CodexDeliveryError("CODEX_DESKTOP_BINARY_MOVED", `Codex Desktopの更新で ${config.binary} が無くなり、新しい場所も特定できません(${error instanceof Error ? error.message : String(error)})。` +
|
package/dist/codex-setup.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { isDeepStrictEqual } from "node:util";
|
|
5
|
-
import { currentCodexDesktopBinary,
|
|
5
|
+
import { currentCodexDesktopBinary, findSteerBinary, realCodexHome } from "./codex-binary.js";
|
|
6
6
|
import { withCodexReceiver } from "./codex-receiver.js";
|
|
7
7
|
import { SetupError } from "./errors.js";
|
|
8
8
|
import { setupNodeExecutable } from "./setup-node.js";
|
|
@@ -162,7 +162,7 @@ export async function verifyCodexHookRegistration(profile, config, approve, dire
|
|
|
162
162
|
export async function configureCodexSteer(profile, action = "status", overrides) {
|
|
163
163
|
const directory = overrides.directory ?? codexHookDirectory(profile);
|
|
164
164
|
const runtime = { platform: process.platform, directory, codex_home: realCodexHome(),
|
|
165
|
-
node: process.execPath, findBinary:
|
|
165
|
+
node: process.execPath, findBinary: () => findSteerBinary(),
|
|
166
166
|
processes: readRuntimeProcesses, legacy: () => null,
|
|
167
167
|
disableLegacy: async () => ({ status: "disabled" }), verify: (config, approve) => verifyCodexHookRegistration(profile, config, approve, directory),
|
|
168
168
|
prepareDirectory: () => undefined, powershell: () => resolveWindowsPowerShell7(), ...overrides };
|
|
@@ -189,8 +189,6 @@ export async function configureCodexSteer(profile, action = "status", overrides)
|
|
|
189
189
|
return runtime.disableLegacy();
|
|
190
190
|
return previous?.enabled ? { status: "restart_required", reason_code: "codex_restart_required" } : { status: "disabled" };
|
|
191
191
|
}
|
|
192
|
-
if (!["darwin", "win32"].includes(runtime.platform))
|
|
193
|
-
return { status: "unsupported", reason_code: "codex_steer_platform_unsupported" };
|
|
194
192
|
if (previous?.enabled && fs.realpathSync(previous.codex_home) !== fs.realpathSync(runtime.codex_home))
|
|
195
193
|
throw new SetupError("codex_steer_configuration_conflict", "別のCODEX_HOMEでSteerが有効です。先に既存の選択を解除してください");
|
|
196
194
|
const node = setupNodeExecutable(runtime.node);
|
|
@@ -202,13 +200,26 @@ export async function configureCodexSteer(profile, action = "status", overrides)
|
|
|
202
200
|
// hook導入前から動いているCodexを再起動待ちとして記録する。今のDesktop、前回の登録、旧方式が起動したCodexを、
|
|
203
201
|
// 引用符付きのコマンド行も含めて照合する(Windowsは区切りと大文字小文字を揃える)。
|
|
204
202
|
const normalize = (value) => runtime.platform === "win32" ? value.replaceAll("/", "\\").toLowerCase() : value;
|
|
203
|
+
// npm版のCodex CLIは `node …/@openai/codex/bin/codex.js` と、その中のnative本体として動く。実体のpackageも照合する。
|
|
204
|
+
const packageRoot = (file) => {
|
|
205
|
+
let real = file;
|
|
206
|
+
try {
|
|
207
|
+
real = fs.realpathSync(file);
|
|
208
|
+
}
|
|
209
|
+
catch { /* 無ければそのまま */ }
|
|
210
|
+
return /[\\/]bin[\\/]codex\.js$/u.test(real) ? path.dirname(path.dirname(real)) : null;
|
|
211
|
+
};
|
|
212
|
+
const roots = [binary, legacy?.binary, previous?.binary].filter((value) => !!value).flatMap(file => packageRoot(file) ?? []).map(normalize);
|
|
205
213
|
const binaries = [binary, legacy?.binary, previous?.binary].filter((value) => !!value).map(normalize);
|
|
206
214
|
const stale = !previous?.enabled || changed || legacy?.enabled
|
|
207
215
|
? runtime.processes().filter(row => binaries.some(candidate => {
|
|
208
216
|
const command = normalize(row.command);
|
|
217
|
+
// 実行ファイルそのもの、またはnode等に渡された引数として(`node <path>`)現れるもの。
|
|
209
218
|
return (row.executable !== undefined && normalize(row.executable) === candidate) || command === candidate || command === `"${candidate}"`
|
|
210
|
-
|| command.startsWith(candidate + " ") || command.startsWith(`"${candidate}" `)
|
|
211
|
-
|
|
219
|
+
|| command.startsWith(candidate + " ") || command.startsWith(`"${candidate}" `)
|
|
220
|
+
|| command.endsWith(" " + candidate) || command.includes(` ${candidate} `) || command.includes(` "${candidate}"`);
|
|
221
|
+
}) || roots.some(root => normalize(row.command).includes(root + (runtime.platform === "win32" ? "\\" : "/"))))
|
|
222
|
+
.map(({ pid, started_identity }) => ({ pid, started_identity }))
|
|
212
223
|
: previous.stale_processes;
|
|
213
224
|
const config = { schema: profile.codex_hook_schema, enabled: true,
|
|
214
225
|
codex_home: runtime.codex_home, binary, command, node, hook: runtime.hook, stale_processes: stale };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { writeJson0600, writeHookJson, waitForFileState } from "./files.js";
|
|
|
4
4
|
export { readRuntimeProcesses, parsePosixProcessTable, type RuntimeProcess, type NativeProcessIdentity } from "./process.js";
|
|
5
5
|
export { resolveWindowsPowerShell7, quotePowerShell, windowsPowerShellSync, windowsStartProcessArgumentList } from "./windows.js";
|
|
6
6
|
export { setupNodeExecutable } from "./setup-node.js";
|
|
7
|
-
export { realCodexHome, resolveCodexExecutable, desktopBundledCodex, findDesktopBinary, findWindowsCodexCache, findWindowsCodexBinary, platformDesktopFinder, currentCodexDesktopBinary, type DesktopBinaryFinder, } from "./codex-binary.js";
|
|
7
|
+
export { realCodexHome, resolveCodexExecutable, desktopBundledCodex, findDesktopBinary, findWindowsCodexCache, findWindowsCodexBinary, findLinuxDesktopBinary, findCliBinary, findSteerBinary, platformDesktopFinder, currentCodexDesktopBinary, type DesktopBinaryFinder, } from "./codex-binary.js";
|
|
8
8
|
export { codexHookConfigSchema, readCodexHookConfig, codexInputDirectory, hookInputSchema, answerDigest, registerCodexHookInput, finishCodexHookSubmission, codexHookDeliveryState, ownedCodexHooks, assertCodexHooksReady, assertCodexHookParentCurrent, type CodexHookConfig, } from "./codex-hook-state.js";
|
|
9
9
|
export { codexParentFromRequest, withCodexReceiver, verifyCodexParent, submitCodexParentAnswer, type CodexParent, type CodexParentThread, type CodexReceiverRuntime, } from "./codex-receiver.js";
|
|
10
10
|
export { runCodexResultHook } from "./codex-hooks.js";
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { writeJson0600, writeHookJson, waitForFileState } from "./files.js";
|
|
|
6
6
|
export { readRuntimeProcesses, parsePosixProcessTable } from "./process.js";
|
|
7
7
|
export { resolveWindowsPowerShell7, quotePowerShell, windowsPowerShellSync, windowsStartProcessArgumentList } from "./windows.js";
|
|
8
8
|
export { setupNodeExecutable } from "./setup-node.js";
|
|
9
|
-
export { realCodexHome, resolveCodexExecutable, desktopBundledCodex, findDesktopBinary, findWindowsCodexCache, findWindowsCodexBinary, platformDesktopFinder, currentCodexDesktopBinary, } from "./codex-binary.js";
|
|
9
|
+
export { realCodexHome, resolveCodexExecutable, desktopBundledCodex, findDesktopBinary, findWindowsCodexCache, findWindowsCodexBinary, findLinuxDesktopBinary, findCliBinary, findSteerBinary, platformDesktopFinder, currentCodexDesktopBinary, } from "./codex-binary.js";
|
|
10
10
|
export { codexHookConfigSchema, readCodexHookConfig, codexInputDirectory, hookInputSchema, answerDigest, registerCodexHookInput, finishCodexHookSubmission, codexHookDeliveryState, ownedCodexHooks, assertCodexHooksReady, assertCodexHookParentCurrent, } from "./codex-hook-state.js";
|
|
11
11
|
export { codexParentFromRequest, withCodexReceiver, verifyCodexParent, submitCodexParentAnswer, } from "./codex-receiver.js";
|
|
12
12
|
export { runCodexResultHook } from "./codex-hooks.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-steer-delivery",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Aiterm's steer delivery as a library: deliver text to the parent AI session that called your MCP tool — steered into the running turn when it is busy, delivered normally when it is idle. Codex (official queue + sync hooks), Claude Code (asyncRewake hooks), Cursor (hooks + background receiver).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|