aiterm-steer-delivery 0.4.5 → 0.4.7

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
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.7
4
+
5
+ Codexの受け口が断った配送の所有記録が残り、同じ配送IDの渡し直しが通らなくなっていたのを直します。関数の名前・引数・返りの形と置き場の作りは変わりません。符号が1つ増えます。
6
+
7
+ - **起きていた事。** `submitCodexParentAnswer`(CLIの`codex submit`)は、hookが有効な製品では、送る前に所有記録
8
+ (`inputs/<homeのhash>/<会話>/pending/<配送ID>.json`)を書く。送信が断られた後も、この記録と`settled`が残っていた。
9
+ 記録を片付けるのは、その会話で走るhook(PostToolUse/Stop)だけ。片付け済み(archived)の会話や止まっている会話ではhookが走らないので、
10
+ 記録が残り続け、同じ配送IDの渡し直しが`EEXIST: file already exists`(素のファイルの誤り)で失敗していた。
11
+ 2026-10-13、片付け済みの会話へ入れて`CODEX_RECEIVER_REJECTED`で断られた配送が、`codex unarchive`で会話を戻した後も通らなかった。
12
+ - **公式キューへ入らなかった配送の所有記録は、送信が自分で消す。** 受け口が断った時(`CODEX_RECEIVER_REJECTED`)と、キューへ頼む前に止まった時
13
+ (Codexを起こせない、`initialize`が返らない・断られる)。`outcome_unknown`がfalseの失敗の後は、`pending`も`settled`も残らず、同じ配送IDで送り直せる。
14
+ - **受け付けたか分からない失敗(`outcome_unknown`がtrue)の後と、受け付けた後は、今までどおり記録を残す。** キューに入っているかも知れない本文を、
15
+ hookが取り出せるようにするため。
16
+ - **記録が在る配送IDをもう一度渡した時の誤りが、符号つきになる。** `CODEX_DELIVERY_DUPLICATE`(`outcome_unknown`はfalse。この呼び出しでは何も送っていない)。
17
+ 今までは素の`EEXIST`で、CLIの返りの`code`は`EEXIST`、文面にファイルの場所が入っていた。
18
+ - 足した口: `withdrawCodexHookInput(home, thread, id, root)`(所有記録を自分で書いて送る製品が、キューに入らなかった時に呼ぶ)。
19
+ - **残っていた記録は本文を持たない**(配送ID・会話・本文のhashだけ)。会話が後で動いた時、hookはキューに在る項目しか取り出さないので、
20
+ 断られた配送の本文が会話へ入る事は無い。0.4.6までの記録が残っている会話では、次にhookが走った時に片付く。それまでは同じ配送IDが
21
+ `CODEX_DELIVERY_DUPLICATE`になる。
22
+ - 試験: 偽の受け口で、断り・キューの前の止まり・分からない失敗・受け付けた後・hookが無効な製品・前の版の残り。CLIの`codex submit`の返り。
23
+ 公式Codex 0.162.1で、片付け済みの会話に断られ、戻した後に同じ配送IDで入る所。
24
+
25
+ ## 0.4.6
26
+
27
+ 動いている最中にNodeが更新されて前の版の場所が消えると、Nodeを起こせなくなっていたのを直します。関数の名前・引数・返りの形、置き場の作り、符号は変わりません。
28
+
29
+ - **起きていた事。** 長く動くprocess(製品のMCP process)が、止まったCodexの会話を起こす見張り(`startCodexWakeWatch`)を起こす時、
30
+ Aitermの命令を起こす時(`findAitermDeliveryProvider`の`node`)、待ち受けの起動先を返す時(`channelReceiveProcess`・`cursorReceiveProcess`)に、
31
+ 自分が起きた時のNodeの場所(`process.execPath`)を使っていた。Homebrewは版ごとの場所へ入れて、更新で前の版を消す。
32
+ 2026-10-12にMacでNodeが26.10.0_1から26.11.1へ上がり、前から動いていたprocessが、無いNodeを指したまま黙って失敗していた。
33
+ - **足した関数。** `liveNodeExecutable(executable?, exists?)`。Homebrewの版つきの場所なら更新でも残る`opt`の場所、
34
+ それ以外で実体があればそのまま、実体が消えていればPATHから探させる`node`を返す。上の3か所と、Codexへ渡すPATH(`codexSpawnEnv`)が使う。
35
+ - **変わる値。** Homebrewの端末で、`channelReceiveProcess`・`cursorReceiveProcess`の`executable`と`findAitermDeliveryProvider`の`node`が、
36
+ `…/Cellar/node/<版>/bin/node`から`…/opt/node/bin/node`になる。ほかの端末では同じ値。
37
+ - **取り込む側。** 製品が自分でNodeの場所を控える時は、`setupNodeExecutable`(設定へ書く時)か`liveNodeExecutable`(動いている最中に使う時)を通す。
38
+ `process.execPath`や、linkをたどった先の場所を控えない。
39
+
3
40
  ## 0.4.5
4
41
 
5
42
  待機や受信hookが、端末の全processの一覧を取り続けて端末を重くしていたのを直します。関数の名前・引数・返り、置き場の作り、符号は変わりません。
package/README.ja.md CHANGED
@@ -143,6 +143,8 @@ await steer.verifyCodexParent(PROFILE, parent);
143
143
  const { queued_submission_id } = await steer.submitCodexParentAnswer(PROFILE, parent, deliveryId, text);
144
144
  ```
145
145
 
146
+ Codex への送信が失敗した時、本文が公式キューに入っていないと言える失敗(`outcome_unknown` が false。受け口が断った時、キューへ頼む前に止まった時)は、同じ配送IDでもう一度送れます。片付け済み(archived)の会話は Codex が `CODEX_RECEIVER_REJECTED` で断るので、`codex unarchive` で戻した後に同じ配送IDで送り直せます。受け付けた後と、受け付けたか分からない失敗(`outcome_unknown` が true)の後は、hook が有効な製品では、所有記録(`pending/<配送ID>.json`)が在る間、同じ配送IDを `CODEX_DELIVERY_DUPLICATE` で断り、何も送りません。配送IDは本文ごとに決め、別の本文で使い回しません。
147
+
146
148
  Claude Code は `claudeParentFromRequest`/`bindClaudeParentDelivery`/`submitClaudeParentAnswer`、Cursor は `cursorParentFromRequest`/`prepareCursorDelivery`/`submitCursorParentAnswer` で同じ流れになります。各 `…ParentFromRequest` は呼び出し元が別のクライアントなら `null` を返すので、順に試せます。Cursor では、hook が会話に結び付けられるよう、ツール結果に配送IDを入れます。`structuredContent` には `parent_delivery: { delivery_id }`、本文には `delivery_id=<uuid>` の行を書きます。
147
149
 
148
150
  Claude Code は、ツールの返りが誤り(`isError`)の時に `PostToolUse` の hook を走らせません。誤りで返す時は、返す前に `discardClaudeHookRequest(clientName, request.params._meta, claudeHookRoot(PROFILE))` を呼び、その呼び出しの置き場を消します。配送を結んだ置き場は消しません。呼ばなくても、残った置き場は1日後に次の依頼の hook が消します。
package/README.md CHANGED
@@ -143,6 +143,8 @@ await steer.verifyCodexParent(PROFILE, parent);
143
143
  const { queued_submission_id } = await steer.submitCodexParentAnswer(PROFILE, parent, deliveryId, text);
144
144
  ```
145
145
 
146
+ When a Codex submission fails and the text is known not to be in the official queue (`outcome_unknown` is false: the receiver rejected it, or the call stopped before asking the queue), you can submit again with the same delivery id. Codex rejects an archived thread with `CODEX_RECEIVER_REJECTED`, so after `codex unarchive` the same delivery id goes through. After an accepted submission, or a failure whose outcome is unknown (`outcome_unknown` is true), a product with hooks enabled gets `CODEX_DELIVERY_DUPLICATE` for the same delivery id while the ownership record (`pending/<delivery id>.json`) exists, and nothing is sent. Use one delivery id per text; never reuse an id for a different text.
147
+
146
148
  Claude Code and Cursor follow the same shape with `claudeParentFromRequest` / `bindClaudeParentDelivery` / `submitClaudeParentAnswer` and `cursorParentFromRequest` / `prepareCursorDelivery` / `submitCursorParentAnswer`. Each `…ParentFromRequest` returns `null` when the caller is a different client, so you can try them in turn. For Cursor, put the delivery id in your tool result, as `parent_delivery: { delivery_id }` in `structuredContent` and as a `delivery_id=<uuid>` line in the text, so the hook can bind it to the conversation.
147
149
 
148
150
  Claude Code does not run the `PostToolUse` hook when a tool result is an error (`isError`). When you return an error, call `discardClaudeHookRequest(clientName, request.params._meta, claudeHookRoot(PROFILE))` before returning, to remove that call's request directory. A directory with a bound delivery is kept. If you do not call it, the next request's hook removes the leftover after one day.
@@ -7,6 +7,7 @@ import * as os from "node:os";
7
7
  import * as path from "node:path";
8
8
  import { z } from "zod";
9
9
  import { CodexDeliveryError } from "./errors.js";
10
+ import { liveNodeExecutable } from "./setup-node.js";
10
11
  export const AITERM_PARENT_DELIVERY_SCHEMA = "aiterm.parent-delivery.v1";
11
12
  export const AITERM_DELIVERY_PROVIDER_SCHEMA = "aiterm.delivery-provider.v1";
12
13
  const recordSchema = z.object({
@@ -25,7 +26,7 @@ export function findAitermDeliveryProvider(options = {}) {
25
26
  const explicit = options.cli ?? env.AITERM_PARENT_DELIVERY_CLI;
26
27
  if (explicit) {
27
28
  // 明示した場所が使えない時に、別の場所へ黙って移らない。
28
- return path.isAbsolute(explicit) && isFile(explicit) ? { node: options.node ?? process.execPath, cli: explicit, version: null, source: "explicit" } : null;
29
+ return path.isAbsolute(explicit) && isFile(explicit) ? { node: options.node ?? liveNodeExecutable(), cli: explicit, version: null, source: "explicit" } : null;
29
30
  }
30
31
  const home = options.home ?? env.HOME ?? os.homedir();
31
32
  try {
@@ -40,14 +41,14 @@ export function findAitermDeliveryProvider(options = {}) {
40
41
  // npmのshim(.cmd)と同じ場所のnode_modulesに本体がある。
41
42
  const cli = path.join(directory, "node_modules", "aiterm-mcp", "dist", "parent-delivery-cli.js");
42
43
  if (isFile(path.join(directory, "aiterm-parent-delivery.cmd")) && isFile(cli))
43
- return { node: options.node ?? process.execPath, cli, version: null, source: "path" };
44
+ return { node: options.node ?? liveNodeExecutable(), cli, version: null, source: "path" };
44
45
  continue;
45
46
  }
46
47
  const shim = path.join(directory, "aiterm-parent-delivery");
47
48
  if (!isFile(shim))
48
49
  continue;
49
50
  try {
50
- return { node: options.node ?? process.execPath, cli: fs.realpathSync(shim), version: null, source: "path" };
51
+ return { node: options.node ?? liveNodeExecutable(), cli: fs.realpathSync(shim), version: null, source: "path" };
51
52
  }
52
53
  catch { /* 壊れたlinkは飛ばす */ }
53
54
  }
package/dist/channel.js CHANGED
@@ -15,6 +15,7 @@ import { writeJson0600 } from "./files.js";
15
15
  import { hookOwnerProcess, processExists, processIsRunning, readProcessIdentities, readProcessLineage } from "./process.js";
16
16
  import { channelRoot } from "./profile.js";
17
17
  import { SteerDeliveryError } from "./errors.js";
18
+ import { liveNodeExecutable } from "./setup-node.js";
18
19
  import { submitCodexParentAnswer } from "./codex-receiver.js";
19
20
  import { windowsStartProcessArgumentList } from "./windows.js";
20
21
  const uuid = z.uuid();
@@ -494,7 +495,7 @@ export async function handleCursorChannelHook(profile, event, emit) {
494
495
  }
495
496
  // ---- 背景受信(Cursorのidle時、Grok等) ----
496
497
  /** 親の背景process APIへそのまま渡す起動情報。scriptは製品のchannel受信入口の絶対path。 */
497
- export function channelReceiveProcess(script, channelId, executable = process.execPath) {
498
+ export function channelReceiveProcess(script, channelId, executable = liveNodeExecutable()) {
498
499
  const args = [script, "--channel", uuid.parse(channelId)];
499
500
  return { executable, args, windows_start_process_argument_list: process.platform === "win32" ? windowsStartProcessArgumentList(args) : null };
500
501
  }
@@ -6,6 +6,7 @@ import * as fs from "node:fs";
6
6
  import * as os from "node:os";
7
7
  import * as path from "node:path";
8
8
  import { CodexDeliveryError, SetupError } from "./errors.js";
9
+ import { liveNodeExecutable } from "./setup-node.js";
9
10
  import { writeHookJson } from "./files.js";
10
11
  import { codexHookDirectory } from "./profile.js";
11
12
  import { windowsPowerShellSync } from "./windows.js";
@@ -93,7 +94,7 @@ export function resolveCodexExecutable() {
93
94
  * 無いと起きない(exit 127。素のsshの環境、製品の常駐process、アプリ配下のprocessはPATHが細い事がある)。
94
95
  * このprocessを動かしているnodeの場所を、PATHに無い時だけ頭へ足した写しを返す。既にあれば、並びも中身も変えない。
95
96
  */
96
- export function codexSpawnEnv(env = process.env, node = process.execPath, platform = process.platform) {
97
+ export function codexSpawnEnv(env = process.env, node = liveNodeExecutable(), platform = process.platform) {
97
98
  const windows = platform === "win32";
98
99
  // Windowsの環境変数名は大文字小文字を区別しない(`Path`で入っている事が多い)。
99
100
  const key = Object.keys(env).find(name => windows ? name.toLowerCase() === "path" : name === "PATH") ?? "PATH";
@@ -38,6 +38,8 @@ export declare const hookInputSchema: z.ZodObject<{
38
38
  }, z.core.$strict>;
39
39
  export declare function answerDigest(text: string): string;
40
40
  export declare function registerCodexHookInput(home: string, thread: string, id: string, text: string, root: string): void;
41
+ /** 公式キューへ入らなかった配送の所有記録を消す。呼ぶのは、その記録を書いた送信だけ。 */
42
+ export declare function withdrawCodexHookInput(home: string, thread: string, id: string, root: string): void;
41
43
  export declare function finishCodexHookSubmission(home: string, thread: string, id: string, root: string): void;
42
44
  export declare function codexHookDeliveryState(home: string, thread: string, id: string, root: string): "sending" | "unknown" | null;
43
45
  export declare function ownedCodexHooks(profile: ProductProfile, response: any, command: string, file: string): any[];
@@ -41,7 +41,20 @@ export function registerCodexHookInput(home, thread, id, text, root) {
41
41
  const directory = codexInputDirectory(root, home, thread);
42
42
  fs.mkdirSync(path.join(directory, "pending"), { recursive: true, mode: 0o700 });
43
43
  // 一つの配送IDを別の本文で再使用しない。送信前の所有記録は再送の指示にはしない。
44
- fs.writeFileSync(path.join(directory, "pending", `${id}.json`), JSON.stringify(input) + "\n", { flag: "wx", mode: 0o600 });
44
+ try {
45
+ fs.writeFileSync(path.join(directory, "pending", `${id}.json`), JSON.stringify(input) + "\n", { flag: "wx", mode: 0o600 });
46
+ }
47
+ catch (error) {
48
+ if (error.code !== "EEXIST")
49
+ throw error;
50
+ // 記録が在るのは、送っている最中・受け付けた後・受け付けたか分からない送信の後。この呼び出しでは何も送っていない。
51
+ throw new CodexDeliveryError("CODEX_DELIVERY_DUPLICATE", "同じ配送IDの所有記録がすでにあります。本文は送っていません");
52
+ }
53
+ }
54
+ /** 公式キューへ入らなかった配送の所有記録を消す。呼ぶのは、その記録を書いた送信だけ。 */
55
+ export function withdrawCodexHookInput(home, thread, id, root) {
56
+ // settledを書いていないので、hookはこの記録に触っていない(片付けるのはsettledが在る記録、取り出すのはキューに在る項目だけ)。
57
+ fs.rmSync(path.join(codexInputDirectory(root, home, thread), "pending", `${id}.json`), { force: true });
45
58
  }
46
59
  export function finishCodexHookSubmission(home, thread, id, root) {
47
60
  const directory = codexInputDirectory(root, home, thread);
@@ -4,10 +4,10 @@
4
4
  import { spawn } from "node:child_process";
5
5
  import { createInterface } from "node:readline";
6
6
  import * as path from "node:path";
7
- import { CodexDeliveryError } from "./errors.js";
7
+ import { CodexDeliveryError, SteerDeliveryError } from "./errors.js";
8
8
  import { codexHookDirectory } from "./profile.js";
9
9
  import { codexSpawnEnv, currentCodexDesktopBinary, realCodexHome, resolveCodexExecutable } from "./codex-binary.js";
10
- import { finishCodexHookSubmission, assertCodexHookParentCurrent, assertCodexHooksReady, readCodexHookConfig, registerCodexHookInput } from "./codex-hook-state.js";
10
+ import { finishCodexHookSubmission, assertCodexHookParentCurrent, assertCodexHooksReady, readCodexHookConfig, registerCodexHookInput, withdrawCodexHookInput } from "./codex-hook-state.js";
11
11
  import { startCodexWakeWatch } from "./codex-wake.js";
12
12
  /** modelの引数ではなく、CodexがMCP要求へ付けるmetadataだけを宛先にする。 */
13
13
  export function codexParentFromRequest(clientName, metadata) {
@@ -132,8 +132,10 @@ export async function submitCodexParentAnswer(profile, parent, deliveryId, text,
132
132
  if (hook)
133
133
  registerCodexHookInput(parent.codex_home, parent.thread_id, deliveryId, text, root);
134
134
  let accepted;
135
+ let asked = false;
135
136
  try {
136
137
  accepted = await withCodexReceiver(profile, parent, async (request) => {
138
+ asked = true;
137
139
  const result = await request("thread/queue/add", {
138
140
  threadId: parent.thread_id,
139
141
  input: [{ type: "text", text, text_elements: [] }],
@@ -145,10 +147,20 @@ export async function submitCodexParentAnswer(profile, parent, deliveryId, text,
145
147
  return { queued_submission_id: result.queuedSubmission.id };
146
148
  }, runtime);
147
149
  }
148
- finally {
149
- if (hook)
150
- finishCodexHookSubmission(parent.codex_home, parent.thread_id, deliveryId, root);
150
+ catch (error) {
151
+ if (hook) {
152
+ // 受け口が断った時と、キューへ頼む前に止まった時は、キューに入っていない。所有記録を残すと、hookが走るまで同じ配送IDの渡し直しが通らない
153
+ // (片付け済みの会話や止まっている会話では、hookが走らない)。受け付けたか分からない時は、hookが取り出せるように残す。
154
+ const maybeQueued = error instanceof SteerDeliveryError ? error.outcome_unknown : asked;
155
+ if (maybeQueued)
156
+ finishCodexHookSubmission(parent.codex_home, parent.thread_id, deliveryId, root);
157
+ else
158
+ withdrawCodexHookInput(parent.codex_home, parent.thread_id, deliveryId, root);
159
+ }
160
+ throw error;
151
161
  }
162
+ if (hook)
163
+ finishCodexHookSubmission(parent.codex_home, parent.thread_id, deliveryId, root);
152
164
  if (runtime?.wake ?? !runtime)
153
165
  startCodexWakeWatch(profile, parent, deliveryId);
154
166
  return accepted;
@@ -11,6 +11,7 @@ import { z } from "zod";
11
11
  import { codexHookDirectory } from "./profile.js";
12
12
  import { withCodexReceiver } from "./codex-receiver.js";
13
13
  import { writeHookJson } from "./files.js";
14
+ import { liveNodeExecutable } from "./setup-node.js";
14
15
  import { windowsPowerShellSync } from "./windows.js";
15
16
  const TAIL_FIRST_BYTES = 256 * 1024;
16
17
  const TAIL_MAX_BYTES = 16 * 1024 * 1024;
@@ -267,7 +268,7 @@ export function startCodexWakeWatch(profile, parent, deliveryId, options = {}) {
267
268
  return false;
268
269
  const payload = JSON.stringify({ profile: serializeWakeProfile(profile), parent, delivery_id: deliveryId,
269
270
  ...(options.delay_ms === undefined ? {} : { delay_ms: options.delay_ms }) });
270
- const child = spawn(process.execPath, [entry], { detached: true, stdio: "ignore", windowsHide: true, env: { ...env, [CODEX_WAKE_PAYLOAD_ENV]: payload } });
271
+ const child = spawn(liveNodeExecutable(), [entry], { detached: true, stdio: "ignore", windowsHide: true, env: { ...env, [CODEX_WAKE_PAYLOAD_ENV]: payload } });
271
272
  child.on("error", () => { });
272
273
  child.unref();
273
274
  return true;
@@ -5,8 +5,9 @@ import * as net from "node:net";
5
5
  import * as path from "node:path";
6
6
  import { receiveCursorAnswer } from "./cursor-receiver.js";
7
7
  import { windowsStartProcessArgumentList } from "./windows.js";
8
+ import { liveNodeExecutable } from "./setup-node.js";
8
9
  /** 親の背景process APIへそのまま渡す起動情報。scriptは製品のCursor受信入口の絶対path。 */
9
- export function cursorReceiveProcess(script, deliveryId, executable = process.execPath) {
10
+ export function cursorReceiveProcess(script, deliveryId, executable = liveNodeExecutable()) {
10
11
  const args = [script, "--delivery", deliveryId];
11
12
  return {
12
13
  executable,
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ export * from "./errors.js";
3
3
  export { writeJson0600, writeHookJson, waitForFileState, withoutBom } from "./files.js";
4
4
  export { readRuntimeProcesses, readProcessIdentities, readProcessLineage, processExists, processIsRunning, parsePosixProcessTable, hookOwnerProcess, type RuntimeProcess, type NativeProcessIdentity } from "./process.js";
5
5
  export { resolveWindowsPowerShell7, quotePowerShell, windowsPowerShellSync, windowsStartProcessArgumentList } from "./windows.js";
6
- export { setupNodeExecutable } from "./setup-node.js";
6
+ export { setupNodeExecutable, liveNodeExecutable } from "./setup-node.js";
7
7
  export { realCodexHome, resolveCodexExecutable, codexSpawnEnv, desktopBundledCodex, findDesktopBinary, findWindowsCodexCache, findWindowsCodexBinary, findLinuxDesktopBinary, findCliBinary, findSteerBinary, platformDesktopFinder, currentCodexDesktopBinary, type DesktopBinaryFinder, } from "./codex-binary.js";
8
- export { codexHookConfigSchema, readCodexHookConfig, codexInputDirectory, hookInputSchema, answerDigest, registerCodexHookInput, finishCodexHookSubmission, codexHookDeliveryState, ownedCodexHooks, assertCodexHooksReady, assertCodexHookParentCurrent, type CodexHookConfig, } from "./codex-hook-state.js";
8
+ export { codexHookConfigSchema, readCodexHookConfig, codexInputDirectory, hookInputSchema, answerDigest, registerCodexHookInput, withdrawCodexHookInput, 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";
11
11
  export { readCodexTurnTail, codexThreadUrl, codexThreadOpener, windowsInteractiveSession, codexWakeDirectory, readCodexWakeResult, wakeCodexParentIfAsleep, codexWakeWatchEnabled, startCodexWakeWatch, runCodexWakeMain, serializeWakeProfile, CODEX_WAKE_PAYLOAD_ENV, type CodexTurnTail, type CodexThreadOpener, type CodexWakeOutcome, type CodexWakeResult, type CodexWakeOptions, } from "./codex-wake.js";
package/dist/index.js CHANGED
@@ -5,9 +5,9 @@ export * from "./errors.js";
5
5
  export { writeJson0600, writeHookJson, waitForFileState, withoutBom } from "./files.js";
6
6
  export { readRuntimeProcesses, readProcessIdentities, readProcessLineage, processExists, processIsRunning, parsePosixProcessTable, hookOwnerProcess } from "./process.js";
7
7
  export { resolveWindowsPowerShell7, quotePowerShell, windowsPowerShellSync, windowsStartProcessArgumentList } from "./windows.js";
8
- export { setupNodeExecutable } from "./setup-node.js";
8
+ export { setupNodeExecutable, liveNodeExecutable } from "./setup-node.js";
9
9
  export { realCodexHome, resolveCodexExecutable, codexSpawnEnv, desktopBundledCodex, findDesktopBinary, findWindowsCodexCache, findWindowsCodexBinary, findLinuxDesktopBinary, findCliBinary, findSteerBinary, platformDesktopFinder, currentCodexDesktopBinary, } from "./codex-binary.js";
10
- export { codexHookConfigSchema, readCodexHookConfig, codexInputDirectory, hookInputSchema, answerDigest, registerCodexHookInput, finishCodexHookSubmission, codexHookDeliveryState, ownedCodexHooks, assertCodexHooksReady, assertCodexHookParentCurrent, } from "./codex-hook-state.js";
10
+ export { codexHookConfigSchema, readCodexHookConfig, codexInputDirectory, hookInputSchema, answerDigest, registerCodexHookInput, withdrawCodexHookInput, 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";
13
13
  export { readCodexTurnTail, codexThreadUrl, codexThreadOpener, windowsInteractiveSession, codexWakeDirectory, readCodexWakeResult, wakeCodexParentIfAsleep, codexWakeWatchEnabled, startCodexWakeWatch, runCodexWakeMain, serializeWakeProfile, CODEX_WAKE_PAYLOAD_ENV, } from "./codex-wake.js";
@@ -1 +1,8 @@
1
1
  export declare function setupNodeExecutable(executable?: string): string;
2
+ /**
3
+ * このprocessのNodeを、後からでも起こせる場所で返す。自分でNodeを起こす時と、呼び手へ「起こす先」として渡す時に使う。
4
+ * `process.execPath`は起きた時の実体で、長く動くprocessでは後から消える事がある(Homebrewは版ごとの場所へ入れ、更新で前の版を消す。
5
+ * 2026-10-12、MacでNodeが26.10.0_1から26.11.1へ上がり、前の版から起きていたprocessが、無いNodeを起こそうとして黙って失敗していた)。
6
+ * Homebrewの時は同じformulaのopt(更新でも残る)を返す。実体が消えていて代わりも無い時は、PATHから探させる(`node`)。
7
+ */
8
+ export declare function liveNodeExecutable(executable?: string, exists?: (file: string) => boolean): string;
@@ -1,8 +1,9 @@
1
- import { accessSync, constants } from "node:fs";
1
+ import { accessSync, constants, existsSync } from "node:fs";
2
2
  import { SetupError } from "./errors.js";
3
+ const BREW_NODE = /^(.*)\/Cellar\/(node(?:@\d+)?)\/[^/]+\/bin\/node$/;
3
4
  // HomebrewのCellar実体は更新で消える。保存する起動先には同じformulaのoptを使う。
4
5
  export function setupNodeExecutable(executable = process.execPath) {
5
- const brew = /^(.*)\/Cellar\/(node(?:@\d+)?)\/[^/]+\/bin\/node$/.exec(executable);
6
+ const brew = BREW_NODE.exec(executable);
6
7
  if (!brew)
7
8
  return executable;
8
9
  const node = `${brew[1]}/opt/${brew[2]}/bin/node`;
@@ -14,3 +15,18 @@ export function setupNodeExecutable(executable = process.execPath) {
14
15
  }
15
16
  return node;
16
17
  }
18
+ /**
19
+ * このprocessのNodeを、後からでも起こせる場所で返す。自分でNodeを起こす時と、呼び手へ「起こす先」として渡す時に使う。
20
+ * `process.execPath`は起きた時の実体で、長く動くprocessでは後から消える事がある(Homebrewは版ごとの場所へ入れ、更新で前の版を消す。
21
+ * 2026-10-12、MacでNodeが26.10.0_1から26.11.1へ上がり、前の版から起きていたprocessが、無いNodeを起こそうとして黙って失敗していた)。
22
+ * Homebrewの時は同じformulaのopt(更新でも残る)を返す。実体が消えていて代わりも無い時は、PATHから探させる(`node`)。
23
+ */
24
+ export function liveNodeExecutable(executable = process.execPath, exists = existsSync) {
25
+ const brew = BREW_NODE.exec(executable);
26
+ if (brew) {
27
+ const opt = `${brew[1]}/opt/${brew[2]}/bin/node`;
28
+ if (exists(opt))
29
+ return opt;
30
+ }
31
+ return exists(executable) ? executable : "node";
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-steer-delivery",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
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",